diff --git a/lib/ESPiLight/.gitignore b/lib/ESPiLight/.gitignore deleted file mode 100755 index d77faed..0000000 --- a/lib/ESPiLight/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -*~ -src/pilight/libs/pilight/core/binary.c -src/pilight/libs/pilight/core/binary.h -src/pilight/libs/pilight/core/dso.h -src/pilight/libs/pilight/core/json.c -src/pilight/libs/pilight/core/json.h -src/pilight/libs/pilight/core/mem.h -src/pilight/libs/pilight/protocols/433.92/* -src/pilight/libs/pilight/protocols/protocol_header.h -src/pilight/libs/pilight/protocols/protocol_init.h diff --git a/lib/ESPiLight/.gitmodules b/lib/ESPiLight/.gitmodules deleted file mode 100755 index dfdafd0..0000000 --- a/lib/ESPiLight/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "pilight"] - path = pilight - url = https://github.com/pilight/pilight - branch = development diff --git a/lib/ESPiLight/.travis.yml b/lib/ESPiLight/.travis.yml deleted file mode 100755 index 5946f08..0000000 --- a/lib/ESPiLight/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: python -python: - - "2.7" - -# Cache PlatformIO packages using Travis CI container-based infrastructure -sudo: false -cache: - directories: - - "~/.platformio" - -env: - - PLATFORMIO_CI_SRC=tests/test_parse - - PLATFORMIO_CI_SRC=tests/test_proto_limit - - PLATFORMIO_CI_SRC=tests/test_echo - - PLATFORMIO_CI_SRC=examples/Receive - - PLATFORMIO_CI_SRC=examples/Receive_Raw - - PLATFORMIO_CI_SRC=examples/Transmit - - PLATFORMIO_CI_SRC=examples/Transmit_Raw - -install: - # PlatformIO - - pip install -U platformio - # integrate pilight - - make - -script: - - platformio ci --lib="." --board=huzzah --board=d1_mini --board=esp32dev - - make stylecheck diff --git a/lib/ESPiLight/pilight/.gitattributes b/lib/ESPiLight/pilight/.gitattributes deleted file mode 100644 index 4eb2283..0000000 --- a/lib/ESPiLight/pilight/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -text eol=lf \ No newline at end of file diff --git a/lib/ESPiLight/pilight/.gitignore b/lib/ESPiLight/pilight/.gitignore deleted file mode 100644 index aecdf1f..0000000 --- a/lib/ESPiLight/pilight/.gitignore +++ /dev/null @@ -1,51 +0,0 @@ -# CMake and build files -*.o -build/ -CMakeFiles/ -Makefile -*.cmake -CMakeCache.txt -cmake_uninstall.cmake.in - -# Headers created when running cmake -inc/defines.h -*_header.h -*_init.h - -# Libraries and pilight executables -*.a -*.so -pilight-control -pilight-daemon -pilight-debug -pilight-flash -pilight-raw -pilight-receive -pilight-send -pilight-sha256 -pilight-uuid -*.exe - -# JSON files in base directory - often used for local testing of different configs -/*.json - -# IDE project files -.project -.settings/ -.cproject -.idea/ -*.iml -*.ipr -*.iws - -# General os files -*~ -*.bak -*.swp -.directory -._* -ehthumbs.db -Thumbs.db - -# docs -docs/build \ No newline at end of file diff --git a/lib/ESPiLight/pilight/CMakeConfig.txt b/lib/ESPiLight/pilight/CMakeConfig.txt deleted file mode 100644 index 36c5ddc..0000000 --- a/lib/ESPiLight/pilight/CMakeConfig.txt +++ /dev/null @@ -1,90 +0,0 @@ -set(WEBSERVER ON CACHE BOOL "enable the built-in webserver") -set(WEBSERVER_HTTPS ON CACHE BOOL "enable webserver ssl protocol") -set(EVENTS ON CACHE BOOL "enable the eventing functionality") -set(IR OFF CACHE BOOL "enable IR remotes support") -set(ZWAVE OFF CACHE BOOL "enable Z-Wave support") -set(PROTOCOL_ALECTO_WS1700 ON CACHE BOOL "support for the Alecto WS1700 protocol") -set(PROTOCOL_ALECTO_WSD17 ON CACHE BOOL "support for the Alecto WSD 17 protocol") -set(PROTOCOL_ALECTO_WX500 ON CACHE BOOL "support for the Alecto WX500 protocol") -set(PROTOCOL_AURIOL ON CACHE BOOL "support for the Auriol weather station protocol") -set(PROTOCOL_ARPING ON CACHE BOOL "support for the MAC based ping protocol") -set(PROTOCOL_BEAMISH_SWITCH ON CACHE BOOL "support for the Beamish switch protocol") -set(PROTOCOL_BMP180 ON CACHE BOOL "support for the BMP180/085 i2c barometric pressure-temperature sensor") -set(PROTOCOL_BRENNENSTUHL_SWITCH ON CACHE BOOL "support for the Brennenstuhl switch protocol") -set(PROTOCOL_BYEBYESTANDBY_SWITCH ON CACHE BOOL "support for the ByeByeStandBy switch protocol") -set(PROTOCOL_CLARUS ON CACHE BOOL "support for the Clarus switch protocol") -set(PROTOCOL_CLEVERWATTS ON CACHE BOOL "support for the Cleverwatts switch protocol") -set(PROTOCOL_COCO_SWITCH ON CACHE BOOL "support for the new ClickOnClickOff switch protocol") -set(PROTOCOL_COGEX_SWITCH ON CACHE BOOL "support for the Cogex switch protocol") -set(PROTOCOL_CONRAD_RSL_SWITCH ON CACHE BOOL "support for the Conrad RSL switch protocol") -set(PROTOCOL_CONRAD_RSL_CONTACT ON CACHE BOOL "support for the Conrad RSL contact sensor protocol") -set(PROTOCOL_CONRAD_WEATHER ON CACHE BOOL "support for the Conrad weather stations protocol") -set(PROTOCOL_CPU_TEMP ON CACHE BOOL "support for CPU temperature sensor") -set(PROTOCOL_DATETIME ON CACHE BOOL "support for the (NTP) date and time protocol") -set(PROTOCOL_DAYCOM ON CACHE BOOL "support Daycom switch (Pollin)") -set(PROTOCOL_DS18B20 ON CACHE BOOL "support for the 1-Wire ds18b20 temperature sensor") -set(PROTOCOL_DS18S20 ON CACHE BOOL "support for the 1-Wire ds18s20 temperature sensor") -set(PROTOCOL_DHT11 ON CACHE BOOL "support for the DHT11 temperature-humidity sensor") -set(PROTOCOL_DHT22 ON CACHE BOOL "support for the DHT22/AM2302 temperature-humidity sensor") -set(PROTOCOL_DIO_SWITCH ON CACHE BOOL "support for the D-IO switch protocol") -set(PROTOCOL_DUWI_SWITCH ON CACHE BOOL "support for the Düwi Terminal switch protocol") -set(PROTOCOL_EHOME ON CACHE BOOL "support for the eHome switch protocol") -set(PROTOCOL_ELRO_SWITCH ON CACHE BOOL "support for the Elro switch protocol") -set(PROTOCOL_ELRO_CONTACT ON CACHE BOOL "support for the Elro contact protocol") -set(PROTOCOL_EURODOMEST_SWITCH ON CACHE BOOL "support for the Eurodomest switch protocol") -set(PROTOCOL_EV1527 ON CACHE BOOL "support for the EV1527 contact protocol") -set(PROTOCOL_GENERIC_DIMMER ON CACHE BOOL "support for the generic dimmer protocol") -set(PROTOCOL_GENERIC_SCREEN ON CACHE BOOL "support for the generic screen protocol") -set(PROTOCOL_GENERIC_SWITCH ON CACHE BOOL "support for the generic switch protocol") -set(PROTOCOL_GENERIC_WEATHER ON CACHE BOOL "support for the generic weather protocol") -set(PROTOCOL_GENERIC_WEBCAM ON CACHE BOOL "support for the generic webcam protocol") -set(PROTOCOL_GPIO_SWITCH ON CACHE BOOL "support for the GPIO switch protocol") -set(PROTOCOL_HEITECH ON CACHE BOOL "support for the Heitech switch protocol") -set(PROTOCOL_IMPULS ON CACHE BOOL "support for the Impuls switch protocol") -set(PROTOCOL_INTERTECHNO_SWITCH ON CACHE BOOL "support for the new Intertechno switch protocol") -set(PROTOCOL_INTERTECHNO_OLD ON CACHE BOOL "support for the old Intertecho switch protocol") -set(PROTOCOL_KAKU_CONTACT ON CACHE BOOL "support for the new KlikAanKlikUit contact protocol") -set(PROTOCOL_KAKU_DIMMER ON CACHE BOOL "support for the old KlikAanKlikUit dimmer protocol") -set(PROTOCOL_KAKU_DUSK ON CACHE BOOL "support for the old KlikAanKlikUit dusk/dawn protocol") -set(PROTOCOL_KAKU_MOTION ON CACHE BOOL "support for the old KlikAanKlikUit PIR protocol") -set(PROTOCOL_KAKU_SWITCH_OLD ON CACHE BOOL "support for the old KlikAanKlikUit switch protocol") -set(PROTOCOL_KAKU_SCREEN_OLD ON CACHE BOOL "support for the old KlikAanKlikUit screen protocol") -set(PROTOCOL_KAKU_SWITCH ON CACHE BOOL "support for the new KlikAanKlikUit switch protocol") -set(PROTOCOL_KAKU_SCREEN ON CACHE BOOL "support for the new KlikAanKlikUit screen protocol") -set(PROTOCOL_LM75 ON CACHE BOOL "support for the lm75 i2c temperature sensor") -set(PROTOCOL_LM76 ON CACHE BOOL "support for the lm76 i2c temperature sensor") -set(PROTOCOL_LIRC ON CACHE BOOL "support for the Lirc API") -set(PROTOCOL_LIVOLO_SWITCH ON CACHE BOOL "support for the Livolo switch protocol") -set(PROTOCOL_LOGILINK_SWITCH ON CACHE BOOL "support for the Logilink switch protocol") -set(PROTOCOL_MUMBI_SWITCH ON CACHE BOOL "support for the Mumbi switch protocol") -set(PROTOCOL_NEXA_SWITCH ON CACHE BOOL "support for the Nexa switch protocol") -set(PROTOCOL_NINJABLOCKS_WEATHER ON CACHE BOOL "support for Ninjablocks temperature-humidity sensor protocol") -set(PROTOCOL_OPENWEATHERMAP ON CACHE BOOL "support for the Open Weather Map API") -set(PROTOCOL_PING ON CACHE BOOL "support for the ping protocol") -set(PROTOCOL_POLLIN_SWITCH ON CACHE BOOL "support for the polling switch protocol") -set(PROTOCOL_PROGRAM ON CACHE BOOL "support for the program switching protocol") -set(PROTOCOL_PROMAX_SWITCH ON CACHE BOOL "support for the PRO max switch protocol") -set(PROTOCOL_QUIGG_SCREEN ON CACHE BOOL "support for Quigg switch w screen protocol") -set(PROTOCOL_QUIGG_GT1000 ON CACHE BOOL "support for Quigg GT-1000 protocol") -set(PROTOCOL_QUIGG_GT7000 ON CACHE BOOL "support for Quigg GT-7000 protocol") -set(PROTOCOL_QUIGG_GT9000 ON CACHE BOOL "support for Quigg GT-9000 protocol") -set(PROTOCOL_RAW ON CACHE BOOL "support for the raw / simulator") -set(PROTOCOL_RELAY ON CACHE BOOL "support for GPIO relay devices") -set(PROTOCOL_REV ON CACHE BOOL "support for the Rev protocol") -set(PROTOCOL_RSL366 ON CACHE BOOL "support for RSL366 switch protocol") -set(PROTOCOL_RC101 ON CACHE BOOL "support for RC101 switch protocol") -set(PROTOCOL_RC102 ON CACHE BOOL "support for RC102 switch protocol") -set(PROTOCOL_SC2262 ON CACHE BOOL "support for the SC2262 Contact protocol") -set(PROTOCOL_SECUDO_SMOKE ON CACHE BOOL "support for Secudo/FlammEx smoke sensor protocol") -set(PROTOCOL_SELECTREMOTE ON CACHE BOOL "support for the Selectremote switch protocol") -set(PROTOCOL_SILVERCREST ON CACHE BOOL "support for the Silvercrest switch protocol") -set(PROTOCOL_SUNRISESET ON CACHE BOOL "support for the Sunrise / Sunset calculator") -set(PROTOCOL_TCM ON CACHE BOOL "support for the TCM 218943 weather station protocol") -set(PROTOCOL_TECHLICO ON CACHE BOOL "support for TechLiCo Lamps protocol") -set(PROTOCOL_TEKNIHALL ON CACHE BOOL "support for the Teknihall weather station protocol") -set(PROTOCOL_TFA ON CACHE BOOL "support for the TFA weather station protocol") -set(PROTOCOL_WUNDERGROUND ON CACHE BOOL "support for the Weather Underground API") -set(PROTOCOL_X10 ON CACHE BOOL "support for the X10 protocol") -set(PROTOCOL_XBMC ON CACHE BOOL "support for the XBMC API") -set(HARDWARE_433_GPIO ON CACHE BOOL "support for the direct GPIO communication") -set(HARDWARE_433_LIRC ON CACHE BOOL "support for the lirc_rpi kernel module") diff --git a/lib/ESPiLight/pilight/CMakeLists.txt b/lib/ESPiLight/pilight/CMakeLists.txt deleted file mode 100644 index 06ec44d..0000000 --- a/lib/ESPiLight/pilight/CMakeLists.txt +++ /dev/null @@ -1,732 +0,0 @@ -cmake_minimum_required(VERSION 2.8.8) - -include(CMakeConfig.txt) - -project(pilight) -set(VERSION 7.0) - -set(MODULESPACK OFF) -set(CMAKE_BUILD_TYPE Debug) - -set(CMAKE_SKIP_RULE_DEPENDENCY TRUE) -set(CPACK_DEB_COMPONENT_INSTALL TRUE) - -if(${ZWAVE} MATCHES "ON") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi") -endif() - -if(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)") - # Use the highest warning level for visual studio. - if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") - endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - if(CMAKE_C_FLAGS MATCHES "/W[0-4]") - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - else(CMAKE_C_FLAGS MATCHES "/W[0-4]") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") - endif(CMAKE_C_FLAGS MATCHES "/W[0-4]") - # Disable deprecation warnings for standard C functions in VS2005 and later - if(CMAKE_COMPILER_2005) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) - endif(CMAKE_COMPILER_2005) -endif(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)") -if(CMAKE_BUILD_TOOL MATCHES "make") - if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") - endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") - if(NOT CMAKE_C_FLAGS MATCHES "-Wall") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") - endif(NOT CMAKE_C_FLAGS MATCHES "-Wall") -endif(CMAKE_BUILD_TOOL MATCHES "make") - -if(NOT WIN32) - string(ASCII 27 Esc) - set(ColorReset "${Esc}[m") - set(ColorBold "${Esc}[1m") - set(Red "${Esc}[31m") - set(Green "${Esc}[32m") - set(Yellow "${Esc}[33m") - set(Blue "${Esc}[34m") - set(Magenta "${Esc}[35m") - set(Cyan "${Esc}[36m") - set(White "${Esc}[37m") - set(BoldRed "${Esc}[1;31m") - set(BoldGreen "${Esc}[1;32m") - set(BoldYellow "${Esc}[1;33m") - set(BoldBlue "${Esc}[1;34m") - set(BoldMagenta "${Esc}[1;35m") - set(BoldCyan "${Esc}[1;36m") - set(BoldWhite "${Esc}[1;37m") -endif() - -set(CMAKE_SKIP_RPATH TRUE) -if(NOT WIN32) - set(CMAKE_EXE_LINKER_FLAGS " -Wl,-rpath=.,-rpath=/usr/local/lib/,-rpath=/usr/lib/,-rpath=/lib/") - set(CMAKE_SHARED_LINKER_FLAGS " -Wl,-rpath=.,-rpath=/usr/local/lib/,-rpath=/usr/lib/,-rpath=/lib/") - set(CMAKE_MODULE_LINKER_FLAGS " -Wl,-rpath=.,-rpath=/usr/local/lib/,-rpath=/usr/lib/,-rpath=/lib/") -else() - set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc") -endif() - -if(NOT WIN32) -# Start uninstaller generator -function(WRITE_UNINSTALL_TARGET_SCRIPT) - # Create uninstall target template file, if it doesn't exist... - if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in) - set(__uninstall_filename ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake.in) - # BEGIN actual write to file... - file(WRITE ${__uninstall_filename} "\# - uninstall target template\n\#") - file(APPEND ${__uninstall_filename} " -if (NOT EXISTS \"\@CMAKE_CURRENT_BINARY_DIR\@/install_manifest.txt\") - message(FATAL_ERROR \"Cannot find install manifest: \\\"\@CMAKE_CURRENT_BINARY_DIR\@/install_manifest.txt\\\"\") -endif(NOT EXISTS \"\@CMAKE_CURRENT_BINARY_DIR\@/install_manifest.txt\") - -file(READ \"\@CMAKE_CURRENT_BINARY_DIR\@/install_manifest.txt\" files) -string(REGEX REPLACE \"\\n\" \";\" files \"\${files}\") - -foreach (file \${files}) - message(STATUS \"Uninstalling \\\"\$ENV{DESTDIR}\${file}\\\"\") - if (EXISTS \"\$ENV{DESTDIR}\${file}\") - execute_process( - COMMAND \@CMAKE_COMMAND\@ -E remove \"\$ENV{DESTDIR}\${file}\" - OUTPUT_VARIABLE rm_out - RESULT_VARIABLE rm_retval - ) - if(NOT \${rm_retval} EQUAL 0) - message(FATAL_ERROR \"Problem when removing \\\"\$ENV{DESTDIR}\${file}\\\"\") - endif (NOT \${rm_retval} EQUAL 0) - else (EXISTS \"\$ENV{DESTDIR}\${file}\") - message(STATUS \"File \\\"\$ENV{DESTDIR}\${file}\\\" does not exist.\") - endif (EXISTS \"\$ENV{DESTDIR}\${file}\") -endforeach(file) - -execute_process(COMMAND update-rc.d ${PROJECT_NAME} remove) -execute_process(COMMAND ldconfig) - -") # END of appending to file... - endif() -endfunction() -# End of the uninstaller generator - - if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake_postinstall.cmake) - set(__uninstall_filename ${CMAKE_CURRENT_BINARY_DIR}/cmake_postinstall.cmake) - # BEGIN actual write to file... - file(WRITE ${__uninstall_filename} "execute_process(COMMAND update-rc.d ${PROJECT_NAME} defaults)") - endif() -endif() - -execute_process(COMMAND git log -n 1 --pretty=format:"%h" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE git_result - OUTPUT_VARIABLE git_hash) - -execute_process(COMMAND git describe --always --abbrev=0 - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE git_result - OUTPUT_VARIABLE git_ver) - -string(REGEX REPLACE "\n" "" git_ver "${git_ver}") -string(REGEX REPLACE "\"" "" git_hash "${git_hash}") -add_definitions(-DHASH="${git_ver}-nightly-${git_hash}") - -file(MD5 ${PROJECT_SOURCE_DIR}/res/pilight.pem md5sum) -add_definitions(-DPILIGHT_PEM_MD5="${md5sum}") - -if(${MODULESPACK} MATCHES "ON" AND NOT WIN32) - add_definitions(-DMODULE="1") -endif() - -if(NOT WIN32) - if(${PROTOCOL_ARPING} MATCHES "ON") - set(CMAKE_PCAP_LIBS_INIT) - - find_library(CMAKE_PCAP_LIBS_INIT - NAME pcap - PATHS - ${CROSS_COMPILE_LIBS} - /usr/lib - /usr/lib32 - /usr/lib64 - /usr/lib/i386-linux-gnu - /usr/lib/x86_64-linux-gnu - /usr/local/lib - /usr/local/lib32 - /usr/local/lib64 - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu - NO_DEFAULT_PATH) - - if(${CMAKE_PCAP_LIBS_INIT} MATCHES "CMAKE_PCAP_LIBS_INIT-NOTFOUND") - message(FATAL_ERROR "Looking for libpcap - not found") - else() - message(STATUS "Looking for libpcap - found (${CMAKE_PCAP_LIBS_INIT})") - endif() - endif() - - set(CMAKE_UNWIND_LIBS_INIT) - - if(NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "^mips") - find_library(CMAKE_UNWIND_LIBS_INIT - NAME unwind - PATHS - ${CROSS_COMPILE_LIBS} - /usr/lib - /usr/lib32 - /usr/lib64 - /usr/lib/i386-linux-gnu - /usr/lib/x86_64-linux-gnu - /usr/local/lib - /usr/local/lib32 - /usr/local/lib64 - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu - NO_DEFAULT_PATH) - - if(${CMAKE_UNWIND_LIBS_INIT} MATCHES "CMAKE_UNWIND_LIBS_INIT-NOTFOUND") - message(FATAL_ERROR "Looking for libunwind - not found") - else() - message(STATUS "Looking for libunwind - found (${CMAKE_UNWIND_LIBS_INIT})") - endif() - endif() - - find_library(CMAKE_WIRINGX_LIBS_INIT - NAME wiringx - PATHS - ${CROSS_COMPILE_LIBS} - /usr/lib - /usr/lib32 - /usr/lib64 - /usr/lib/i386-linux-gnu - /usr/lib/x86_64-linux-gnu - /usr/local/lib - /usr/local/lib32 - /usr/local/lib64 - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu - NO_DEFAULT_PATH) - - if(${CMAKE_WIRINGX_LIBS_INIT} MATCHES "CMAKE_WIRINGX_LIBS_INIT-NOTFOUND") - message(FATAL_ERROR "Looking for libwiringx - not found") - else() - message(STATUS "Looking for libwiringx - found (${CMAKE_WIRINGX_LIBS_INIT})") - endif() -endif() - -find_library(CMAKE_MBEDTLS_LIBS_INIT - NAME mbedtls - PATHS - ${CROSS_COMPILE_LIBS} - /usr/lib - /usr/lib32 - /usr/lib64 - /usr/lib/i386-linux-gnu - /usr/lib/x86_64-linux-gnu - /usr/local/lib - /usr/local/lib32 - /usr/local/lib64 - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu - NO_DEFAULT_PATH) - -if(${CMAKE_MBEDTLS_LIBS_INIT} MATCHES "CMAKE_MBEDTLS_LIBS_INIT-NOTFOUND") - message(FATAL_ERROR "Looking for libmbedtls - not found") -else() - message(STATUS "Looking for libmbedtls - found (${CMAKE_MBEDTLS_LIBS_INIT})") -endif() - -find_library(CMAKE_MBEDCRYPTO_LIBS_INIT - NAME mbedcrypto - PATHS - ${CROSS_COMPILE_LIBS} - /usr/lib - /usr/lib32 - /usr/lib64 - /usr/lib/i386-linux-gnu - /usr/lib/x86_64-linux-gnu - /usr/local/lib - /usr/local/lib32 - /usr/local/lib64 - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu - NO_DEFAULT_PATH) - -if(${CMAKE_MBEDCRYPTO_LIBS_INIT} MATCHES "CMAKE_MBEDCRYPTO_LIBS_INIT-NOTFOUND") - message(FATAL_ERROR "Looking for libmbedcrypto - not found") -else() - message(STATUS "Looking for libmbedcrypto - found (${CMAKE_MBEDCRYPTO_LIBS_INIT})") -endif() - -find_library(CMAKE_MBEDX509_LIBS_INIT - NAME mbedx509 - PATHS - ${CROSS_COMPILE_LIBS} - /usr/lib - /usr/lib32 - /usr/lib64 - /usr/lib/i386-linux-gnu - /usr/lib/x86_64-linux-gnu - /usr/local/lib - /usr/local/lib32 - /usr/local/lib64 - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu - NO_DEFAULT_PATH) - -if(${CMAKE_MBEDX509_LIBS_INIT} MATCHES "CMAKE_MBEDX509_LIBS_INIT-NOTFOUND") - message(FATAL_ERROR "Looking for libmbedx509 - not found") -else() - message(STATUS "Looking for libmbedx509 - found (${CMAKE_MBEDX509_LIBS_INIT})") -endif() - -find_library(CMAKE_LUA_LIBS_INIT - NAME luajit-5.1 - PATHS - ${CROSS_COMPILE_LIBS} - /usr/lib - /usr/lib32 - /usr/lib64 - /usr/lib/i386-linux-gnu - /usr/lib/x86_64-linux-gnu - /usr/local/lib - /usr/local/lib32 - /usr/local/lib64 - /usr/lib/arm-linux-gnueabi - /usr/lib/arm-linux-gnueabihf - /usr/lib/aarch64-linux-gnu -NO_DEFAULT_PATH) - -if(${CMAKE_LUA_LIBS_INIT} MATCHES "CMAKE_LUA_LIBS_INIT-NOTFOUND") - message(FATAL_ERROR "Looking for libluajit - not found") -else() - message(STATUS "Looking for libluajit - found (${CMAKE_LUA_LIBS_INIT})") -endif() - -include_directories(${PROJECT_SOURCE_DIR}/inc) -include_directories(${PROJECT_SOURCE_DIR}/libs/libuv) -include_directories(/usr/local/include/) - -add_subdirectory(inc) -add_subdirectory(libs) - -if(WIN32) - set(THREADS_USE_PTHREADS_WIN32 true) -endif() -find_package(Threads REQUIRED) -if(NOT WIN32) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - find_package(Backtrace REQUIRED) - endif() -endif() - -if(${MODULESPACK} MATCHES "OFF" OR WIN32) - if(WIN32) - add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/res/win32/admin.obj COMMAND ${CMAKE_RC_COMPILER} -o ${PROJECT_SOURCE_DIR}/res/win32/admin.obj ${PROJECT_SOURCE_DIR}/res/win32/admin.rc) - add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/res/win32/icon.obj COMMAND ${CMAKE_RC_COMPILER} -o ${PROJECT_SOURCE_DIR}/res/win32/icon.obj ${PROJECT_SOURCE_DIR}/res/win32/icon.rc) - add_library(admin STATIC ${PROJECT_SOURCE_DIR}/res/win32/admin.obj) - add_library(icon STATIC ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - set_source_files_properties(${PROJECT_SOURCE_DIR}/res/win32/admin.obj PROPERTIES EXTERNAL_OBJECT true GENERATED true) - set_source_files_properties(${PROJECT_SOURCE_DIR}/res/win32/icon.obj PROPERTIES EXTERNAL_OBJECT true GENERATED true) - set_target_properties(admin PROPERTIES LINKER_LANGUAGE C) - set_target_properties(icon PROPERTIES LINKER_LANGUAGE C) - endif() - - add_library(${PROJECT_NAME} OBJECT ${libs_files}) - set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE TRUE) - - if(WIN32) - add_library(${PROJECT_NAME}_shared STATIC $) - else() - add_library(${PROJECT_NAME}_shared SHARED $) - endif() - add_library(${PROJECT_NAME}_static STATIC $) - - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_THREAD_LIBS_INIT}) - if(WIN32) - target_link_libraries(${PROJECT_NAME}_shared ws2_32) - target_link_libraries(${PROJECT_NAME}_shared user32) - target_link_libraries(${PROJECT_NAME}_shared userenv) - target_link_libraries(${PROJECT_NAME}_shared wsock32) - target_link_libraries(${PROJECT_NAME}_shared iphlpapi) - target_link_libraries(${PROJECT_NAME}_shared psapi) - target_link_libraries(${PROJECT_NAME}_static ws2_32) - target_link_libraries(${PROJECT_NAME}_static user32) - target_link_libraries(${PROJECT_NAME}_static userenv) - target_link_libraries(${PROJECT_NAME}_static wsock32) - target_link_libraries(${PROJECT_NAME}_static iphlpapi) - target_link_libraries(${PROJECT_NAME}_static psapi) - if(${PROTOCOL_ARPING} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}_shared ${PROJECT_SOURCE_DIR}/res/win32/libwpcap.dll.a) - target_link_libraries(${PROJECT_NAME}_static ${PROJECT_SOURCE_DIR}/res/win32/libwpcap.dll.a) - endif() - endif() - - target_link_libraries(${PROJECT_NAME}_shared m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}_shared ${Backtrace_LIBRARIES}) - endif() - if(NOT WIN32) - target_link_libraries(${PROJECT_NAME}_shared rt) - endif() - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_WIRINGX_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_MBEDTLS_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_MBEDCRYPTO_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_MBEDX509_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_LUA_LIBS_INIT}) - - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_THREAD_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_static m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}_static ${Backtrace_LIBRARIES}) - endif() - if(NOT WIN32) - target_link_libraries(${PROJECT_NAME}_static rt) - endif() - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_WIRINGX_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_MBEDTLS_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_MBEDCRYPTO_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_MBEDX509_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_LUA_LIBS_INIT}) - - if(${PROTOCOL_ARPING} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_PCAP_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_PCAP_LIBS_INIT}) - endif() - - if(NOT WIN32) - target_link_libraries(${PROJECT_NAME}_shared ${CMAKE_UNWIND_LIBS_INIT}) - target_link_libraries(${PROJECT_NAME}_static ${CMAKE_UNWIND_LIBS_INIT}) - endif() - - set_target_properties(${PROJECT_NAME}_shared ${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) - - if(NOT WIN32) - install(CODE "execute_process(COMMAND rm /usr/local/lib/lib${PROJECT_NAME}.so)") - install(FILES ${CMAKE_BINARY_DIR}/lib${PROJECT_NAME}.so DESTINATION lib RENAME lib${PROJECT_NAME}.so.${VERSION} COMPONENT ${PROJECT_NAME}) - install(FILES ${CMAKE_BINARY_DIR}/lib${PROJECT_NAME}.a DESTINATION lib RENAME lib${PROJECT_NAME}.a COMPONENT ${PROJECT_NAME}) - install(CODE "execute_process(COMMAND ln -s \"/usr/local/lib/lib${PROJECT_NAME}.so.${VERSION}\" \"/usr/local/lib/lib${PROJECT_NAME}.so\")") - - if(EXISTS "/usr/local/lib/${PROJECT_NAME}/protocols") - install(CODE "execute_process(COMMAND find /usr/local/lib/${PROJECT_NAME}/protocols/ -type f -exec rm {} \\;)") - endif() - if(EXISTS "/usr/local/lib/${PROJECT_NAME}/hardware") - install(CODE "execute_process(COMMAND find /usr/local/lib/${PROJECT_NAME}/hardware/ -type f -exec rm {} \\;)") - endif() - if(EXISTS "/usr/local/lib/${PROJECT_NAME}/actions") - install(CODE "execute_process(COMMAND find /usr/local/lib/${PROJECT_NAME}/actions/ -type f -exec rm {} \\;)") - endif() - if(EXISTS "/usr/local/lib/${PROJECT_NAME}/operators") - install(CODE "execute_process(COMMAND find /usr/local/lib/${PROJECT_NAME}/operators/ -type f -exec rm {} \\;)") - endif() - if(EXISTS "/usr/local/${PROJECT_NAME}/operators") - install(CODE "execute_process(COMMAND find /usr/local/${PROJECT_NAME}/operators/ -type f -exec rm {} \\;)") - endif() - - if(EXISTS "/etc/${PROJECT_NAME}/config.json") - install(CODE "execute_process(COMMAND mv /etc/${PROJECT_NAME}/config.json /etc/${PROJECT_NAME}/config.json.bak)") - endif() - - if(EXISTS "/etc/${PROJECT_NAME}/pilight.pem") - install(CODE "execute_process(COMMAND mv /etc/${PROJECT_NAME}/pilight.pem /etc/${PROJECT_NAME}/pilight.pem.bak)") - endif() - - install(PROGRAMS ${PROJECT_SOURCE_DIR}/res/init/${PROJECT_NAME}.initd DESTINATION /etc/init.d/ RENAME ${PROJECT_NAME}) - install(FILES ${PROJECT_SOURCE_DIR}/res/config/config.json-default DESTINATION /etc/${PROJECT_NAME}/ RENAME config.json COMPONENT ${PROJECT_NAME}) - install(FILES ${PROJECT_SOURCE_DIR}/res/pilight.pem DESTINATION /etc/${PROJECT_NAME}/ COMPONENT ${PROJECT_NAME}) - else() - # install(FILES ${CMAKE_BINARY_DIR}/lib${PROJECT_NAME}.dll DESTINATION . RENAME lib${PROJECT_NAME}.dll COMPONENT ${PROJECT_NAME}) - install(FILES ${PROJECT_SOURCE_DIR}/res/config/config.json-default-w32 DESTINATION . RENAME config.json-default COMPONENT ${PROJECT_NAME}) - endif() - - if(${WEBSERVER} MATCHES "ON") - if(WIN32) - install(DIRECTORY ${PROJECT_SOURCE_DIR}/libs/webgui/ DESTINATION web/ COMPONENT webgui) - else() - install(DIRECTORY ${PROJECT_SOURCE_DIR}/libs/webgui/ DESTINATION /usr/local/lib/${PROJECT_NAME}/webgui COMPONENT webgui) - endif() - endif() - - if(WIN32) - add_executable(${PROJECT_NAME}-daemon daemon.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - target_link_libraries(${PROJECT_NAME}-daemon "-Wl,--subsystem,windows") - else() - add_executable(${PROJECT_NAME}-daemon daemon.c) - endif() - target_link_libraries(${PROJECT_NAME}-daemon ${PROJECT_NAME}_shared) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-daemon stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-daemon ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}-daemon m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-daemon ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-daemon ${CMAKE_THREAD_LIBS_INIT}) - - # if(WIN32) - # add_executable(${PROJECT_NAME}-unittest unittest.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - # target_link_libraries(${PROJECT_NAME}-unittest "-Wl,--subsystem,windows") - # else() - # add_executable(${PROJECT_NAME}-unittest unittest.c) - # endif() - # target_link_libraries(${PROJECT_NAME}-unittest ${PROJECT_NAME}_shared) - # if(${ZWAVE} MATCHES "ON") - # target_link_libraries(${PROJECT_NAME}-unittest stdc++) - # endif() - # target_link_libraries(${PROJECT_NAME}-unittest ${CMAKE_DL_LIBS}) - # target_link_libraries(${PROJECT_NAME}-unittest m) - # if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - # target_link_libraries(${PROJECT_NAME}-unittest ${Backtrace_LIBRARIES}) - # endif() - # target_link_libraries(${PROJECT_NAME}-unittest ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-raw raw.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-raw raw.c) - endif() - target_link_libraries(${PROJECT_NAME}-raw ${PROJECT_NAME}_shared) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-raw stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-raw ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}-raw m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-raw ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-raw ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-send send.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-send send.c) - endif() - target_link_libraries(${PROJECT_NAME}-send ${PROJECT_NAME}_shared) - target_link_libraries(${PROJECT_NAME}-send ${CMAKE_DL_LIBS}) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-send stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-send m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-send ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-send ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-control control.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-control control.c) - endif() - target_link_libraries(${PROJECT_NAME}-control ${PROJECT_NAME}_shared) - target_link_libraries(${PROJECT_NAME}-control ${CMAKE_DL_LIBS}) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-control stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-control m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-control ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-control ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-receive receive.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-receive receive.c) - endif() - target_link_libraries(${PROJECT_NAME}-receive ${PROJECT_NAME}_shared) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-receive stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-receive ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}-receive m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-receive ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-receive ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-debug debug.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-debug debug.c) - endif() - target_link_libraries(${PROJECT_NAME}-debug ${PROJECT_NAME}_shared) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-debug stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-debug ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}-debug m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-debug ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-debug ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-uuid uuid.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-uuid uuid.c) - endif() - target_link_libraries(${PROJECT_NAME}-uuid ${PROJECT_NAME}_shared) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-uuid stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-uuid ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}-uuid m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-uuid ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-uuid ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-sha256 sha256.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-sha256 sha256.c) - endif() - target_link_libraries(${PROJECT_NAME}-sha256 ${PROJECT_NAME}_shared) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-sha256 stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-sha256 ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}-sha256 m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-sha256 ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-sha256 ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - add_executable(${PROJECT_NAME}-flash flash.c ${PROJECT_SOURCE_DIR}/res/win32/icon.obj) - else() - add_executable(${PROJECT_NAME}-flash flash.c) - endif() - target_link_libraries(${PROJECT_NAME}-flash ${PROJECT_NAME}_shared) - if(${ZWAVE} MATCHES "ON") - target_link_libraries(${PROJECT_NAME}-flash stdc++) - endif() - target_link_libraries(${PROJECT_NAME}-flash ${CMAKE_DL_LIBS}) - target_link_libraries(${PROJECT_NAME}-flash m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${PROJECT_NAME}-flash ${Backtrace_LIBRARIES}) - endif() - target_link_libraries(${PROJECT_NAME}-flash ${CMAKE_THREAD_LIBS_INIT}) - - if(WIN32) - install(FILES "${PROJECT_SOURCE_DIR}/res/firmware/${PROJECT_NAME}_usb_nano.hex" DESTINATION . COMPONENT ${PROJECT_NAME}) - endif() - - if(NOT WIN32) - if(EXISTS "/usr/local/sbin/${PROJECT_NAME}-send") - install(CODE "execute_process(COMMAND rm /usr/local/sbin/${PROJECT_NAME}-send)") - endif() - - if(EXISTS "/usr/local/sbin/${PROJECT_NAME}-receive") - install(CODE "execute_process(COMMAND rm /usr/local/sbin/${PROJECT_NAME}-receive)") - endif() - - if(EXISTS "/usr/local/sbin/${PROJECT_NAME}-control") - install(CODE "execute_process(COMMAND rm /usr/local/sbin/${PROJECT_NAME}-control)") - endif() - - if(EXISTS "/usr/local/sbin/${PROJECT_NAME}-uuid") - install(CODE "execute_process(COMMAND rm /usr/local/sbin/${PROJECT_NAME}-uuid)") - endif() - endif() - - if(WIN32) - install(FILES "${PROJECT_SOURCE_DIR}/LICENSE.txt" DESTINATION . COMPONENT ${PROJECT_NAME}) - install(FILES "${PROJECT_SOURCE_DIR}/res/win32/libmbedx509.dll" DESTINATION . COMPONENT ${PROJECT_NAME}) - install(FILES "${PROJECT_SOURCE_DIR}/res/win32/libmbedcrypto.dll" DESTINATION . COMPONENT ${PROJECT_NAME}) - install(FILES "${PROJECT_SOURCE_DIR}/res/win32/libmbedtls.dll" DESTINATION . COMPONENT ${PROJECT_NAME}) - install(FILES "${PROJECT_SOURCE_DIR}/res/win32/libwinpthread-1.dll" DESTINATION . COMPONENT ${PROJECT_NAME}) - install(FILES "${PROJECT_SOURCE_DIR}/res/win32/Packet.dll" DESTINATION . COMPONENT ${PROJECT_NAME}) - install(FILES "${PROJECT_SOURCE_DIR}/res/win32/wpcap.dll" DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-daemon.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-raw.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-send.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-control.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-receive.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-debug.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-flash.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-uuid.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-sha256.exe DESTINATION . COMPONENT ${PROJECT_NAME}) - else() - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-daemon DESTINATION sbin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-raw DESTINATION sbin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-send DESTINATION bin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-control DESTINATION bin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-receive DESTINATION bin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-debug DESTINATION sbin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-flash DESTINATION sbin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-uuid DESTINATION bin COMPONENT ${PROJECT_NAME}) - install(PROGRAMS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-sha256 DESTINATION bin COMPONENT ${PROJECT_NAME}) - install(CODE "execute_process(COMMAND update-rc.d ${PROJECT_NAME} defaults)") - install(CODE "execute_process(COMMAND ldconfig)") - endif() -endif() - -if(WIN32) - set(CPACK_MONOLITHIC_INSTALL True) - set(CPACK_NSIS_INSTALL_ROOT "c:") - set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}") - set(CPACK_NSIS_DISPLAY_NAME "${PROJECT_NAME}") - set(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME} ${git_ver}") - set(CPACK_NSIS_URL_INFO_ABOUT "http://www.${PROJECT_NAME}.org") - set(CPACK_NSIS_CONTACT "info@${PROJECT_NAME}.org") - set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") - set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL True) - set(CPACK_NSIS_MENU_LINKS - "${PROJECT_NAME}-daemon" "${PROJECT_NAME}-daemon" - ) - - set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt") - # set(CPACK_COMPONENTS_ALL ${PROJECT_NAME} webgui) - set(CPACK_GENERATOR "NSIS") - set(CPACK_PACKAGING_INSTALL_DIRECTORY "${PROJECT_NAME}") - set(CPACK_SOURCE_STRIP_FILES TRUE) - set(CPACK_STRIP_FILES TRUE) - set(CPACK_PACKAGE_CONTACT "CurlyMo ") - set(CPACK_PACKAGE_VERSION ${git_ver}) - set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") - set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME}") - set(CPACK_PACKAGE_DESCRIPTION "Control RF devices with the Raspberry Pi") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Control RF devices with the Raspberry Pi") - - include(CPack) -else() - WRITE_UNINSTALL_TARGET_SCRIPT() - configure_file("${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) - add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) - - set(CPACK_GENERATOR "DEB") - set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local/") - set(CPACK_SOURCE_STRIP_FILES TRUE) - set(CPACK_STRIP_FILES TRUE) - set(CPACK_PACKAGE_CONTACT "CurlyMo ") - set(CPACK_PACKAGE_VERSION ${VERSION}) - set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") - set(CPACK_DEBIAN_PACKAGE_DEPENDS "zlib1g-dev") - set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") - set(CPACK_PACKAGE_DESCRIPTION "Control RF devices with the Raspberry Pi") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Control RF devices with the Raspberry Pi") - - include(CPack) - - message("") - message("${Red}-- WARNING --${ColorReset}") - message("${Yellow}Manually compiling and installing ${PROJECT_NAME} will also clear all module folders: -/usr/local/lib/${PROJECT_NAME}/protocols/ -/usr/local/lib/${PROJECT_NAME}/hardware/ -/usr/local/lib/${PROJECT_NAME}/actions/ -/usr/local/lib/${PROJECT_NAME}/operators/${ColorReset}") - message("${Red}-- WARNING --${ColorReset}") - message("") -endif() diff --git a/lib/ESPiLight/pilight/CONTRIBUTING.md b/lib/ESPiLight/pilight/CONTRIBUTING.md deleted file mode 100644 index 213bce4..0000000 --- a/lib/ESPiLight/pilight/CONTRIBUTING.md +++ /dev/null @@ -1,77 +0,0 @@ -Rules for contributing to pilight -================================= -First of all, thanks for making this project better. Without your help, pilight wouldn't have come to what it is now! - -**BUT**, be aware that contributing to a big project shouldn't be considered a playground. It also isn't meant for you to learn `git`. -So if you don't know what you are doing then don't do it. Instead open a [forum topic](http://forum.pilight.org), point to your code and ask for help. - -Checklist ---------- -When you contribute to pilight make sure to follow this checklist: - -1. Is your pull request directed at the development branch? -*pilight doesn't accept contributions to the master branch because this branch reflects the latest stable code.* -2. Did you read the [development](http://manual.pilight.org/development/) pages of pilight? -*Even if you think you know all, please check and double check. There are always small syntax changes. Also check similar already existing modules for syntax.* -3. Keep the coding style in sync with that of pilight (see below). -4. First merge with the latest development code. -5. Make a different branch for each new feature you want to commit. -6. Test how pull-requests work on your own test repositories. -7. Make sure your pull-request contains [one single commit](http://eli.thegreenplace.net/2014/02/19/squashing-github-pull-requests-into-a-single-commit). -8. Open a pull-request when you indeed want to contribute and follow-up on our comments. If you don't want to implement our requested changes after reviewing your pull-request, don't bother opening one. -9. Re-read this file before every pull-request, because it will be updated regularly. -10. Don't forget to enjoy the appreciation of the end user! - -Coding style ------ -- No unnecessary spaces -``` -if ( 1 == 1 ) -{ -... -} -``` -should become: -``` -if(1 == 1) { -... -} -``` -- Don't inline variables: -``` -int x = 0; -int long_variable_name = 0; -int a = 0; -``` -but use -``` -int x = 0; -int long_variable_name = 0; -int a = 0; -``` -but preferable use for around max 50 characters: -``` -int x = 0, long_variable_name = 0, a = 0; -``` -- Variable defining order. -First start with `struct`, then specials types (`*_t`), then `char`, then `double` / `float` and end with `int`. -``` - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - time_t time; - char *tmp = NULL; - double itmp = 0.0; - int id = 0, state = 0, nstate = 0; -``` -- Initialize your variables. -``` -char *a = NULL; -char a[10]; -memset(&a, 0, 10); -double a = 0.0; -int a = 0; -``` -- User the `static` keyword for all variables and function only use in the single C file your module consists of. -- Always use tabs instead of spaces for inline markup. diff --git a/lib/ESPiLight/pilight/COPYING b/lib/ESPiLight/pilight/COPYING deleted file mode 100644 index 94a9ed0..0000000 --- a/lib/ESPiLight/pilight/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 3 of the License, 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, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/lib/ESPiLight/pilight/LICENSE.txt b/lib/ESPiLight/pilight/LICENSE.txt deleted file mode 100644 index 94a9ed0..0000000 --- a/lib/ESPiLight/pilight/LICENSE.txt +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 3 of the License, 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, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/lib/ESPiLight/pilight/README.md b/lib/ESPiLight/pilight/README.md deleted file mode 100644 index 4287cbb..0000000 --- a/lib/ESPiLight/pilight/README.md +++ /dev/null @@ -1,20 +0,0 @@ -pilight version 7.0 -======= - -Flattr this - -Visit http://www.pilight.org or http://wiki.pilight.org for more information. - -# Dependencies -The pilight development code depends on the following packages: - -1. [libmbedtls](https://github.com/ARMmbed/mbedtls) -2. [libmbedx509](https://github.com/ARMmbed/mbedtls) -3. [libmbedcrypto](https://github.com/ARMmbed/mbedtls) -4. [liblua5.2](https://github.com/lua/lua) -5. [libwiringx](https://github.com/wiringx/wiringx) (rewrite branch) -6. [libpcap](http://www.tcpdump.org/release/) -7. [libunwind](http://download.savannah.nongnu.org/releases/libunwind/) - -Either manually compile each of these packages or install them by using the package repository of your distribution of choice diff --git a/lib/ESPiLight/pilight/clients/process.java b/lib/ESPiLight/pilight/clients/process.java deleted file mode 100644 index 9d9cd2f..0000000 --- a/lib/ESPiLight/pilight/clients/process.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.ByteArrayInputStream; -import java.io.StringReader; -import java.nio.charset.Charset; -import java.io.PrintStream; -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.util.Collections; -import java.util.Enumeration; -import sun.net.*; -import java.net.*; -import java.util.Date; - -public class process { - public static void main(String[] args) { - String line = null; - DatagramSocket ssdp = null; - PrintStream printStream = null; - BufferedReader bufferedReader = null; - int port = 0; - String server = null; - Socket socket = null; - - String msg = "M-SEARCH * HTTP/1.1\r\n" - + "Host:239.255.255.250:1900\r\n" - + "ST:urn:schemas-upnp-org:service:pilight:1\r\n" - + "Man:\"ssdp:discover\"\r\n" - + "MX:3\r\n\r\n"; - - try { - Enumeration nets = NetworkInterface.getNetworkInterfaces(); - for(NetworkInterface netint : Collections.list(nets)) { - Enumeration inetAddresses = netint.getInetAddresses(); - for(InetAddress inetAddress : Collections.list(inetAddresses)) { - if(!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) { - try { - ssdp = new DatagramSocket(new InetSocketAddress(inetAddress.getHostAddress().toString(), 0)); - byte[] buff = msg.getBytes(); - DatagramPacket sendPack = new DatagramPacket(buff, buff.length); - sendPack.setAddress(InetAddress.getByName("239.255.255.250")); - sendPack.setPort(1900); - - try { - ssdp.send(sendPack); - ssdp.setSoTimeout(10); - boolean loop = true; - while(loop) { - DatagramPacket recvPack = new DatagramPacket(new byte[1024], 1024); - ssdp.receive(recvPack); - byte[] recvData = recvPack.getData(); - InputStreamReader recvInput = new InputStreamReader(new ByteArrayInputStream(recvData), Charset.forName("UTF-8")); - StringBuilder recvOutput = new StringBuilder(); - for(int value; (value = recvInput.read()) != -1;) { - recvOutput.append((char)value); - } - BufferedReader bufReader = new BufferedReader(new StringReader(recvOutput.toString())); - Pattern pattern = Pattern.compile("Location:([0-9.]+):(.*)"); - while((line=bufReader.readLine()) != null) { - Matcher matcher = pattern.matcher(line); - if(matcher.matches()) { - server = matcher.group(1); - port = Integer.parseInt(matcher.group(2)); - loop = false; - break; - } - } - } - } catch(SocketTimeoutException e) { - } catch(IOException e) { - System.out.println("no pilight ssdp connections found"); - ssdp.close(); - System.exit(0); - } - } catch(UnknownHostException e) { - } - } - } - } - } catch(SocketException e) { - } - - if(server == null || port == 0) { - System.out.println("no pilight ssdp connections found"); - System.exit(0); - } - - try { - socket = new Socket(); - socket.connect(new InetSocketAddress(server, port), 1000); - - try { - if(printStream == null) { - printStream = new PrintStream(socket.getOutputStream(), false); - } - printStream.print("{\"action\":\"identify\",\"options\":{\"receiver\":1}}\n"); - printStream.flush(); - } catch(IOException e) { - System.out.println("failed to write messages to server"); - } - - int size = 0; - if(size == 0) { - size = 1025; - } - try { - if(bufferedReader == null) { - bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"), size); - } - int c = 0; - StringBuilder response = new StringBuilder(); - if(bufferedReader.ready()) { - while((c = bufferedReader.read()) > 0) { - response.append((char)c); - } - System.out.println(response.toString()); - } - } catch(IOException e) { - System.out.println("failed to receive messages from server"); - } - - } catch (UnknownHostException e) { - System.out.println("don't know about host"); - } catch(IOException e) { - System.out.println("could not get I/O for connection"); - } - } -} diff --git a/lib/ESPiLight/pilight/clients/process.php b/lib/ESPiLight/pilight/clients/process.php deleted file mode 100644 index be8b937..0000000 --- a/lib/ESPiLight/pilight/clients/process.php +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env php - -*/ - -$sMsg = "M-SEARCH * HTTP/1.1\r\n"; -$sMsg .= "Host:239.255.255.250:1900\r\n"; -$sMsg .= "ST:urn:schemas-upnp-org:service:pilight:1\r\n"; -$sMsg .= "Man:\"ssdp:discover\"\r\n"; -$sMsg .= "MX:3\r\n\r\n"; - -$sBuffer = NULL; -$sTmp = NULL; -$rSocket = socket_create(AF_INET, SOCK_DGRAM, 0); -socket_set_option($rSocket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>0, 'usec'=>10000)); -$send_ret = socket_sendto($rSocket, $sMsg, 1024, 0, '239.255.255.250', 1900); -$aHosts = Array(); -$x = 0; -while(@socket_recvfrom($rSocket, $sBuffer, 1024, MSG_WAITALL, $sTmp, $sTmp)) { - if(strpos($sBuffer, 'pilight') !== false) { - $aLines = explode("\r\n", $sBuffer); - foreach($aLines as $sLine) { - if(sscanf($sLine, "Location:%d.%d.%d.%d:%d\r\n", $ip1, $ip2, $ip3, $ip4, $port) > 0) { - $ip = $ip1.'.'.$ip2.'.'.$ip3.'.'.$ip4; - $aHosts[$x]['ip'] = $ip; - $aHosts[$x]['port'] = $port; - $x++; - } - } - } -} -socket_close($rSocket); -$sLine = ''; -if(count($aHosts) > 0) { - $fp = fsockopen($aHosts[0]['ip'], $aHosts[0]['port'], $errno, $errdesc) or die ("Couldn't connect to server"); - fputs($fp, '{"action":"identify","options":{"receiver":1}}'); - $sLine = fgets($fp, 1024); - if($sLine == "{\"status\":\"success\"}\n") { - $iLen = 0; - $sLine = ''; - while(true) { - $sLine .= fgets($fp, 1024); - $iLen = strlen($sLine); - if($iLen > 2 && ord($sLine[$iLen-1]) === 10 && ord($sLine[$iLen-2]) === 10) { - $sLine = substr($sLine, 0, -2); - echo $sLine."\n"; - $sLine = ''; - } - } - } -} else { - die("no pilight ssdp connections found\n"); -} -?> \ No newline at end of file diff --git a/lib/ESPiLight/pilight/clients/process.pl b/lib/ESPiLight/pilight/clients/process.pl deleted file mode 100644 index 4b9a6d3..0000000 --- a/lib/ESPiLight/pilight/clients/process.pl +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env perl -# -# Copyright (C) 2013 CurlyMo -# -# This file is part of pilight. -# -# pilight 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 3 of the License, or (at your option) any later -# version. -# -# pilight 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 pilight. If not, see -# - -use IO::Socket; - -socket(sock, PF_INET, SOCK_DGRAM, getprotobyname("udp")) or die "socket:$@"; -setsockopt(sock, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt:$@"; -setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, pack('l!l!', 0, 10000)) or die "setsockopt:$@"; -my $dest = sockaddr_in(1900, inet_aton('239.255.255.250')); - -$msg = "M-SEARCH * HTTP/1.1\r\n"; -$msg .= "Host:239.255.255.250:1900\r\n"; -$msg .= "ST:urn:schemas-upnp-org:service:pilight:1\r\n"; -$msg .= "Man:\"ssdp:discover\"\r\n"; -$msg .= "MX:3\r\n\r\n"; - -my $ip = ''; -my $port = ''; -send(sock, $msg, 1024, $dest); -while(recv(sock, $data, 1024, $dest)) { - if(index($data, "pilight") != -1) { - foreach(split(/\r\n/, $data)) { - $_ =~ /Location:([0-9\.]+):([0-9]+)/ || next; - ($ip,$port) = ($1,$2); - } - } -} - -$socket = new IO::Socket::INET ( - PeerHost => $ip, - PeerPort => $port, - Proto => 'tcp', -) or die "no pilight ssdp connections found\n"; - -$socket->send('{"action":"identify","options":{"receiver":1}}'); -$socket->recv($recv_data, 1024); -my $text = ''; -while(1) { - $text = ''; - while(1) { - $socket->recv($recv_data, 1024); - $text .= $recv_data; - if($recv_data[(length $recv_data)-1] == '\n' || $recv_data[(length $recv_data)] == '\n') { - $text = substr $text, 0, -1; - last; - } - } - print $text; -} \ No newline at end of file diff --git a/lib/ESPiLight/pilight/clients/process.py b/lib/ESPiLight/pilight/clients/process.py deleted file mode 100644 index ad10375..0000000 --- a/lib/ESPiLight/pilight/clients/process.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2017 pilino1234 -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -"""Example Python 2 client for pilight daemon socket API - -Runs a SSDP discovery for pilight daemons on the network, and connects to it. -Identifies as a "receiver" type client, and prints received messages until -terminated. - -""" - -import socket -import struct -import re - - -def discover(service, retries=1): - """SSDP discovery function - - :param service: The name of the SSDP service to run discovery for - :type service: str - :param retries: The number of discovery retries. Defaults to 1. - :type retries: int - - """ - - group = ("239.255.255.250", 1900) - message = "\r\n".join([ - 'M-SEARCH * HTTP/1.1', - 'HOST: {0}:{1}'.format(*group), - 'MAN: "ssdp:discover"', - 'ST: {st}', 'MX: 3', '', '']) - - ssdp_responses = {} - - for i in range(retries): - sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, - socket.IPPROTO_UDP) - sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, - struct.pack('LL', 0, 10000)) - sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) - sock.sendto(message.format(st=service), group) - - while True: - try: - ssdp_responses[i] = sock.recv(1024) - break - except socket.timeout: - break - except IOError: - print "no pilight ssdp connections found" - break - - sock.close() - return ssdp_responses - - -if __name__ == "__main__": - - RESPONSES = discover("urn:schemas-upnp-org:service:pilight:1") - - if len(RESPONSES) > 0: - for resp in RESPONSES: - locationsrc = re.search('Location:([0-9.]+):(.*)', - str(RESPONSES[0]), re.IGNORECASE) - - if locationsrc: - location = locationsrc.group(1) - port = locationsrc.group(2) - - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - socket.setdefaulttimeout(0) - try: - s.connect((location, int(port))) - except ConnectionRefusedError: - # Connection was refused, try next SSDP response - print "connection refused" - continue - - s.send('{"action": "identify", "options": {"core": 1}}') - text = "" - while True: - line = s.recv(1024) - text += line - if "\n\n" in line[-2:]: - text = text[:-2] - break - - if text == '{"status":"success"}': - text = "" - while True: - line = s.recv(1024) - text += line - if "\n\n" in line[-2:]: - text = text[:-2] - for f in iter(text.splitlines()): - print f - text = "" - elif text == '{"status":"failure"}': - # connection failed, try next SSDP response - print "connection failed" - continue - s.close() diff --git a/lib/ESPiLight/pilight/clients/process.py3 b/lib/ESPiLight/pilight/clients/process.py3 deleted file mode 100644 index f11e5a7..0000000 --- a/lib/ESPiLight/pilight/clients/process.py3 +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2017 pilino1234 -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -"""Example Python 3 client for pilight daemon socket API - -Runs a SSDP discovery for pilight daemons on the network, and connects to it. -Identifies as a "receiver" type client, and prints received messages until -terminated. - -""" - -import socket -import struct -import re - - -def discover(service, retries=1): - """SSDP discovery function - - :param service: The name of the SSDP service to run discovery for - :type service: str - :param retries: The number of discovery retries. Defaults to 1. - :type retries: int - - """ - - group = ("239.255.255.250", 1900) - discover_message = "\r\n".join([ - 'M-SEARCH * HTTP/1.1', - 'HOST: {0}:{1}'.format(*group), - 'MAN: "ssdp:discover"', - 'ST: {st}', 'MX: 3', '', '']).format(st=service) - - ssdp_responses = {} - - for i in range(retries): - sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, - socket.IPPROTO_UDP) - sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, - struct.pack('LL', 0, 10000)) - sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) - sock.sendto(bytes(discover_message, "utf-8"), group) - - while True: - try: - ssdp_responses[i] = sock.recv(1024).decode("utf-8") - break - except socket.timeout: - break - except IOError: - print("no pilight ssdp connections found") - break - - sock.close() - return ssdp_responses - - -if __name__ == "__main__": - - RESPONSES = discover("urn:schemas-upnp-org:service:pilight:1") - - if len(RESPONSES) > 0: - for resp in RESPONSES: # try all responses until one works - locationsrc = re.search("Location:([0-9.]+):(.*)", - str(RESPONSES[resp]), re.IGNORECASE) - - if locationsrc: - location = locationsrc.group(1) - port = locationsrc.group(2) - - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - try: - s.connect((location, int(port))) - except ConnectionRefusedError: - # Connection was refused, try next SSDP response - print("connection refused") - continue - - s.send(bytes('{"action": "identify", \ - "options": {"receiver": 1}}', "utf-8")) - response = "" - while True: - line = s.recv(1024).decode("utf-8") - response += line - if "\n\n" in line[-2:]: - response = response[:-2] - break - - if response == '{"status":"success"}': - message = "" - while True: - line = s.recv(1024).decode("utf-8") - message += line - if "\n\n" in line[-2:]: - message = message[:-2] - for f in iter(message.splitlines()): - print(f) - message = "" - elif response == '{"status":"failure"}': - # connection failed, try next SSDP response - print("connection failed") - continue diff --git a/lib/ESPiLight/pilight/control.c b/lib/ESPiLight/pilight/control.c deleted file mode 100644 index f78eee8..0000000 --- a/lib/ESPiLight/pilight/control.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#endif - -#include "libs/pilight/core/threads.h" -#include "libs/pilight/core/pilight.h" -#include "libs/pilight/core/common.h" -#include "libs/pilight/core/config.h" -#include "libs/pilight/core/log.h" -#include "libs/pilight/core/options.h" -#include "libs/pilight/core/socket.h" -#include "libs/pilight/core/json.h" -#include "libs/pilight/core/ssdp.h" -#include "libs/pilight/core/dso.h" -#include "libs/pilight/core/gc.h" - -#include "libs/pilight/config/devices.h" - -#include "libs/pilight/protocols/protocol.h" - -#include "libs/pilight/events/events.h" - -int main(int argc, char **argv) { - // memtrack(); - - atomicinit(); - struct options_t *options = NULL; - struct ssdp_list_t *ssdp_list = NULL; - struct devices_t *dev = NULL; - struct JsonNode *json = NULL; - struct JsonNode *tmp = NULL; - char *recvBuff = NULL, *message = NULL, *output = NULL; - char *device = NULL, *state = NULL, *values = NULL; - char *server = NULL; - int has_values = 0, sockfd = 0, hasconfarg = 0; - unsigned short port = 0, showhelp = 0, showversion = 0; - - log_file_disable(); - log_shell_enable(); - log_level_set(LOG_NOTICE); - - if((progname = MALLOC(16)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(progname, "pilight-control"); - - /* Define all CLI arguments of this program */ - options_add(&options, 'H', "help", OPTION_NO_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'V', "version", OPTION_NO_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'd', "device", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 's', "state", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'v', "values", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'S', "server", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); - options_add(&options, 'P', "port", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, "[0-9]{1,4}"); - options_add(&options, 'C', "config", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, NULL); - - /* Store all CLI arguments for later usage - and also check if the CLI arguments where - used correctly by the user. This will also - fill all necessary values in the options struct */ - while(1) { - int c; - c = options_parse(&options, argc, argv, 1, &optarg); - if(c == -1) - break; - if(c == -2) { - showhelp = 1; - break; - } - switch(c) { - case 'H': - showhelp = 1; - break; - case 'V': - showversion = 1; - break; - case 'd': - if((device = REALLOC(device, strlen(optarg)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(device, optarg); - break; - case 's': - if((state = REALLOC(state, strlen(optarg)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(state, optarg); - break; - case 'v': - if((values = REALLOC(values, strlen(optarg)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(values, optarg); - break; - case 'C': - if(config_set_file(optarg) == EXIT_FAILURE) { - return EXIT_FAILURE; - } - hasconfarg = 1; - break; - case 'S': - if(!(server = REALLOC(server, strlen(optarg)+1))) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(server, optarg); - break; - case 'P': - port = (unsigned short)atoi(optarg); - break; - default: - printf("Usage: %s -l location -d device -s state\n", progname); - goto close; - break; - } - } - options_delete(options); - - if(showversion == 1) { - printf("%s v%s\n", progname, PILIGHT_VERSION); - goto close; - } - if(showhelp == 1) { - printf("\t -H --help\t\t\tdisplay this message\n"); - printf("\t -V --version\t\t\tdisplay version\n"); - printf("\t -S --server=x.x.x.x\t\tconnect to server address\n"); - printf("\t -C --config\t\t\tconfig file\n"); - printf("\t -P --port=xxxx\t\t\tconnect to server port\n"); - printf("\t -d --device=device\t\tthe device that you want to control\n"); - printf("\t -s --state=state\t\tthe new state of the device\n"); - printf("\t -v --values=values\t\tspecific comma separated values, e.g.:\n"); - printf("\t\t\t\t\t-v dimlevel=10\n"); - goto close; - } - if(device == NULL || state == NULL || - strlen(device) == 0 || strlen(state) == 0) { - printf("Usage: %s -d device -s state\n", progname); - goto close; - } - - if(server && port > 0) { - if((sockfd = socket_connect(server, port)) == -1) { - logprintf(LOG_ERR, "could not connect to pilight-daemon"); - goto close; - } - } else if(ssdp_seek(&ssdp_list) == -1) { - logprintf(LOG_NOTICE, "no pilight ssdp connections found"); - goto close; - } else { - if((sockfd = socket_connect(ssdp_list->ip, ssdp_list->port)) == -1) { - logprintf(LOG_ERR, "could not connect to pilight-daemon"); - goto close; - } - } - if(ssdp_list) { - ssdp_free(ssdp_list); - } - - protocol_init(); - config_init(); - if(hasconfarg == 1) { - if(config_read() != EXIT_SUCCESS) { - goto close; - } - } - - socket_write(sockfd, "{\"action\":\"identify\"}"); - if(socket_read(sockfd, &recvBuff, 0) != 0 - || strcmp(recvBuff, "{\"status\":\"success\"}") != 0) { - goto close; - } - - json = json_mkobject(); - json_append_member(json, "action", json_mkstring("request config")); - output = json_stringify(json, NULL); - socket_write(sockfd, output); - json_free(output); - json_delete(json); - - if(socket_read(sockfd, &recvBuff, 0) == 0) { - if(json_validate(recvBuff) == true) { - json = json_decode(recvBuff); - if(json_find_string(json, "message", &message) == 0) { - if(strcmp(message, "config") == 0) { - struct JsonNode *jconfig = NULL; - if((jconfig = json_find_member(json, "config")) != NULL) { - int match = 1; - while(match) { - struct JsonNode *jchilds = json_first_child(jconfig); - match = 0; - while(jchilds) { - if(strcmp(jchilds->key, "devices") != 0) { - json_remove_from_parent(jchilds); - tmp = jchilds; - match = 1; - } - jchilds = jchilds->next; - if(tmp != NULL) { - json_delete(tmp); - } - tmp = NULL; - } - } - config_parse(jconfig); - if(devices_get(device, &dev) == 0) { - JsonNode *joutput = json_mkobject(); - JsonNode *jcode = json_mkobject(); - JsonNode *jvalues = json_mkobject(); - json_append_member(jcode, "device", json_mkstring(device)); - - if(values != NULL) { - char *sptr = NULL; - char *ptr1 = strtok_r(values, ",", &sptr); - while(ptr1) { - char **array = NULL; - int n = explode(ptr1, "=", &array), q = 0; - if(n == 2) { - char *name = MALLOC(strlen(array[0])+1); - if(name == NULL) { - logprintf(LOG_ERR, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(name, array[q]); - char *val = MALLOC(strlen(array[q+1])+1); - if(val == NULL) { - logprintf(LOG_ERR, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(val, array[1]); - if(devices_valid_value(device, name, val) == 0) { - if(isNumeric(val) == EXIT_SUCCESS) { - json_append_member(jvalues, name, json_mknumber(atof(val), nrDecimals(val))); - } else { - json_append_member(jvalues, name, json_mkstring(val)); - } - has_values = 1; - FREE(name); - FREE(values); - array_free(&array, n); - } else { - logprintf(LOG_ERR, "\"%s\" is an invalid value for device \"%s\"", name, device); - array_free(&array, n); - FREE(name); - FREE(values); - json_delete(json); - goto close; - } - } else { - array_free(&array, n); - logprintf(LOG_ERR, "\"%s\" requires a name=value format", ptr1); - break; - } - ptr1 = strtok_r(NULL, ",", &sptr); - } - } - - if(devices_valid_state(device, state) == 0) { - json_append_member(jcode, "state", json_mkstring(state)); - } else { - logprintf(LOG_ERR, "\"%s\" is an invalid state for device \"%s\"", state, device); - json_delete(json); - goto close; - } - - if(has_values == 1) { - json_append_member(jcode, "values", jvalues); - } else { - json_delete(jvalues); - } - json_append_member(joutput, "action", json_mkstring("control")); - json_append_member(joutput, "code", jcode); - output = json_stringify(joutput, NULL); - socket_write(sockfd, output); - json_free(output); - json_delete(joutput); - if(socket_read(sockfd, &recvBuff, 0) != 0 - || strcmp(recvBuff, "{\"status\":\"success\"}") != 0) { - logprintf(LOG_ERR, "failed to control %s", device); - } - } else { - logprintf(LOG_ERR, "the device \"%s\" does not exist", device); - json_delete(json); - goto close; - } - } - } - } - json_delete(json); - } - } -close: - if(recvBuff) { - FREE(recvBuff); - } - if(sockfd > 0) { - socket_close(sockfd); - } - if(server != NULL) { - FREE(server); - } - if(device != NULL) { - FREE(device); - } - if(state != NULL) { - FREE(state); - } - if(values != NULL) { - FREE(values); - } - log_shell_disable(); - socket_gc(); - config_gc(); - protocol_gc(); - options_gc(); -#ifdef EVENTS - events_gc(); -#endif - dso_gc(); - log_gc(); - threads_gc(); - gc_clear(); - FREE(progname); - xfree(); - -#ifdef _WIN32 - WSACleanup(); -#endif - - return EXIT_SUCCESS; -} diff --git a/lib/ESPiLight/pilight/daemon.c b/lib/ESPiLight/pilight/daemon.c deleted file mode 100644 index c32a2d0..0000000 --- a/lib/ESPiLight/pilight/daemon.c +++ /dev/null @@ -1,3505 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #include - #include - #include - #include - #include - #define MSG_NOSIGNAL 0 -#else - #include - #include - #include - #include - #include - #include - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#endif - -#include "libs/pilight/core/pilight.h" -#include "libs/pilight/core/threads.h" -#include "libs/pilight/core/datetime.h" -#include "libs/pilight/core/common.h" -#include "libs/pilight/core/network.h" -#include "libs/pilight/core/gc.h" -#include "libs/pilight/core/log.h" -#include "libs/pilight/core/ssl.h" -#include "libs/pilight/core/options.h" -#include "libs/pilight/core/socket.h" -#include "libs/pilight/core/json.h" -#include "libs/pilight/core/ssdp.h" -#include "libs/pilight/core/dso.h" -#include "libs/pilight/core/firmware.h" -#include "libs/pilight/core/proc.h" -#include "libs/pilight/core/ntp.h" -#include "libs/pilight/core/config.h" -#include "libs/pilight/lua/lua.h" - -#ifdef EVENTS - #include "libs/pilight/events/events.h" -#endif - -#ifdef WEBSERVER - #ifdef WEBSERVER_HTTPS - #include - #endif - #include "libs/pilight/core/webserver.h" -#endif - -#include "libs/pilight/config/hardware.h" -#include "libs/pilight/config/registry.h" -#include "libs/pilight/config/devices.h" -#include "libs/pilight/config/settings.h" -#include "libs/pilight/config/gui.h" - -static uv_signal_t **signal_req = NULL; -static int signals[5] = { SIGINT, SIGQUIT, SIGTERM, SIGABRT, SIGTSTP }; -static uv_timer_t *timer_abort_req = NULL; -static uv_timer_t *timer_stats_req = NULL; - -#ifdef _WIN32 -static char server_name[40]; -#endif - -typedef struct clients_t { - char uuid[UUID_LENGTH]; - int id; - int receiver; - int config; - int core; - int stats; - int forward; - char media[8]; - double cpu; - double ram; - struct clients_t *next; -} clients_t; - -static struct clients_t *clients = NULL; - -typedef struct sendqueue_t { - unsigned int id; - char *protoname; - char *settings; - char *message; - enum origin_t origin; - struct protocol_t *protopt; - int code[MAXPULSESTREAMLENGTH]; - int length; - char uuid[UUID_LENGTH]; - struct sendqueue_t *next; -} sendqueue_t; - -static struct sendqueue_t *sendqueue; -static struct sendqueue_t *sendqueue_head; - -typedef struct recvqueue_t { - int raw[MAXPULSESTREAMLENGTH]; - int rawlen; - int hwtype; - int plslen; - struct recvqueue_t *next; -} recvqueue_t; - -static struct recvqueue_t *recvqueue; -static struct recvqueue_t *recvqueue_head; - -static pthread_mutex_t config_lock; -static pthread_mutexattr_t config_attr; - -static pthread_mutex_t sendqueue_lock; -static pthread_cond_t sendqueue_signal; -static pthread_mutexattr_t sendqueue_attr; -static unsigned short sendqueue_init = 0; - -static int sendqueue_number = 0; -static int recvqueue_number = 0; - -static pthread_mutex_t recvqueue_lock; -static pthread_cond_t recvqueue_signal; -static pthread_mutexattr_t recvqueue_attr; -static unsigned short recvqueue_init = 0; - -typedef struct bcqueue_t { - struct JsonNode *jmessage; - char *protoname; - enum origin_t origin; - struct bcqueue_t *next; -} bcqueue_t; - -static struct bcqueue_t *bcqueue; -static struct bcqueue_t *bcqueue_head; - -static pthread_mutex_t bcqueue_lock; -static pthread_cond_t bcqueue_signal; -static pthread_mutexattr_t bcqueue_attr; -static unsigned short bcqueue_init = 0; - -static int bcqueue_number = 0; - -static struct protocol_t *procProtocol; - -/* The pid_file and pid of this daemon */ -#ifndef _WIN32 -static char *pid_file; -static unsigned short pid_file_free = 0; -#endif -static pid_t pid; -/* Daemonize or not */ -static int nodaemon = 0; -/* Run tracktracer */ -static int stacktracer = 0; -/* Run thread profiler */ -static int threadprofiler = 0; -/* Are we already running */ -static int running = 1; -/* Are we currently sending code */ -static int sending = 0; -/* Socket identifier to the server if we are running as client */ -static int sockfd = 0; -/* Thread pointers */ -static pthread_t logpth; -/* While loop conditions */ -static unsigned short main_loop = 1; -/* Reset repeats after a certain amount of time */ -static struct timeval tv; -/* Are we running standalone */ -static int standalone = 0; -/* Do we need to connect to a master server:port? */ -static char *master_server = NULL; -static unsigned short master_port = 0; - -static int adhoc_pending = 0; -static char *configtmp = NULL; -static int verbosity = LOG_INFO; -struct socket_callback_t socket_callback; - -#ifdef _WIN32 - static int console = 0; - static int oldverbosity = LOG_NOTICE; -#endif - - -#ifdef WEBSERVER -/* Do we enable the webserver */ -static int webserver_enable = WEBSERVER_ENABLE; -static int webgui_websockets = WEBGUI_WEBSOCKETS; -/* On what port does the webserver run */ -static int webserver_http_port = WEBSERVER_HTTP_PORT; -/* The webroot of pilight */ -static char *webserver_root = NULL; -static int webserver_root_free = 0; -#endif - -static void *reason_forward_free(void *param) { - FREE(param); - return NULL; -} - -static void *reason_send_code_free(void *param) { - struct reason_send_code_t *data = param; - FREE(data); - return NULL; -} - -static void *reason_broadcast_core_free(void *param) { - char *code = param; - FREE(code); - return NULL; -} - -static void *reason_socket_send_free(void *param) { - struct reason_socket_send_t *data = param; - FREE(data->buffer); - FREE(data); - return NULL; -} - -static void client_remove(int id) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct clients_t *currP, *prevP; - - prevP = NULL; - - for(currP = clients; currP != NULL; prevP = currP, currP = currP->next) { - - if(currP->id == id) { - if(prevP == NULL) { - clients = currP->next; - } else { - prevP->next = currP->next; - } - - FREE(currP); - break; - } - } -} - -static void broadcast_queue(char *protoname, struct JsonNode *json, enum origin_t origin) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(main_loop == 1) { - pthread_mutex_lock(&bcqueue_lock); - if(bcqueue_number <= 1024) { - struct bcqueue_t *bnode = MALLOC(sizeof(struct bcqueue_t)); - if(bnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - char *jstr = json_stringify(json, NULL); - bnode->jmessage = json_decode(jstr); - if(json_find_member(bnode->jmessage, "uuid") == NULL && strlen(pilight_uuid) > 0) { - json_append_member(bnode->jmessage, "uuid", json_mkstring(pilight_uuid)); - } - json_free(jstr); - - if((bnode->protoname = MALLOC(strlen(protoname)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(bnode->protoname, protoname); - - bnode->origin = origin; - - if(bcqueue_number == 0) { - bcqueue = bnode; - bcqueue_head = bnode; - } else { - bcqueue_head->next = bnode; - bcqueue_head = bnode; - } - - bcqueue_number++; - } else { - logprintf(LOG_ERR, "broadcast queue full"); - } - pthread_mutex_unlock(&bcqueue_lock); - pthread_cond_signal(&bcqueue_signal); - } -} - -void *broadcast(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int broadcasted = 0/*, free_conf = 1*/; - - pthread_mutex_lock(&bcqueue_lock); - while(main_loop) { - if(bcqueue_number > 0) { - pthread_mutex_lock(&bcqueue_lock); - - logprintf(LOG_STACK, "%s::unlocked", __FUNCTION__); - - broadcasted = 0; - struct JsonNode *jret = NULL; - char *origin = NULL; - - if(json_find_string(bcqueue->jmessage, "origin", &origin) == 0) { - if(strcmp(origin, "core") == 0) { - double tmp = 0; - json_find_number(bcqueue->jmessage, "type", &tmp); - char *conf = json_stringify(bcqueue->jmessage, NULL); - struct clients_t *tmp_clients = clients; - while(tmp_clients) { - if(((int)tmp < 0 && tmp_clients->core == 1) || - ((int)tmp >= 0 && tmp_clients->config == 1) || - ((int)tmp == PROCESS && tmp_clients->stats == 1)) { - socket_write(tmp_clients->id, conf); - broadcasted = 1; - } - tmp_clients = tmp_clients->next; - } - - if(pilight.runmode == ADHOC && sockfd > 0) { - struct JsonNode *jupdate = json_decode(conf); - json_append_member(jupdate, "action", json_mkstring("update")); - char *ret = json_stringify(jupdate, NULL); - socket_write(sockfd, ret); - broadcasted = 1; - json_delete(jupdate); - json_free(ret); - } - if(broadcasted == 1) { - logprintf(LOG_DEBUG, "broadcasted: %s", conf); - } - eventpool_trigger(REASON_BROADCAST_CORE, reason_broadcast_core_free, conf); - } else { - /* Update the config */ - if(devices_update(bcqueue->protoname, bcqueue->jmessage, bcqueue->origin, &jret) == 0) { - char *tmp = json_stringify(jret, NULL); - struct clients_t *tmp_clients = clients; - unsigned short match1 = 0, match2 = 0; - - while(tmp_clients) { - if(tmp_clients->config == 1) { - struct JsonNode *jtmp = json_decode(tmp); - struct JsonNode *jdevices = json_find_member(jtmp, "devices"); - if(jdevices != NULL) { - match1 = 0; - struct JsonNode *jchilds = json_first_child(jdevices); - struct gui_values_t *gui_values = NULL; - while(jchilds) { - match2 = 0; - if(jchilds->tag == JSON_STRING) { - if((gui_values = gui_media(jchilds->string_)) != NULL) { - while(gui_values) { - if(gui_values->type == JSON_STRING) { - if(strcmp(gui_values->string_, tmp_clients->media) == 0 || - strcmp(gui_values->string_, "all") == 0 || - strcmp(tmp_clients->media, "all") == 0) { - match1 = 1; - match2 = 1; - } - } - gui_values = gui_values->next; - } - } else { - match1 = 1; - match2 = 1; - } - } - if(match2 == 0) { - json_remove_from_parent(jchilds); - } - struct JsonNode *jtmp1 = jchilds; - jchilds = jchilds->next; - if(match2 == 0) { - json_delete(jtmp1); - } - } - } - if(match1 == 1) { - char *conf = json_stringify(jtmp, NULL); - socket_write(tmp_clients->id, conf); - logprintf(LOG_DEBUG, "broadcasted: %s", conf); - json_free(conf); - } - json_delete(jtmp); - } - tmp_clients = tmp_clients->next; - } - eventpool_trigger(REASON_BROADCAST_CORE, reason_broadcast_core_free, tmp); - - // json_free(tmp); - json_delete(jret); - } - - /* The settings objects inside the broadcast queue is only of interest for the - internal pilight functions. For the outside world we only communicate the - message part of the queue so we remove the settings */ - char *internal = json_stringify(bcqueue->jmessage, NULL); - - struct JsonNode *jsettings = NULL; - if((jsettings = json_find_member(bcqueue->jmessage, "settings"))) { - json_remove_from_parent(jsettings); - json_delete(jsettings); - } - struct JsonNode *tmp = json_find_member(bcqueue->jmessage, "action"); - if(tmp != NULL && tmp->tag == JSON_STRING && strcmp(tmp->string_, "update") == 0) { - json_remove_from_parent(tmp); - json_delete(tmp); - } - - char *out = json_stringify(bcqueue->jmessage, NULL); - if(strcmp(bcqueue->protoname, "pilight_firmware") == 0) { - struct JsonNode *code = NULL; - if((code = json_find_member(bcqueue->jmessage, "message")) != NULL) { - json_find_number(code, "version", &firmware.version); - json_find_number(code, "lpf", &firmware.lpf); - json_find_number(code, "hpf", &firmware.hpf); - if(firmware.version > 0 && firmware.lpf > 0 && firmware.hpf > 0) { - registry_set_number("pilight.firmware.version", firmware.version, 0); - registry_set_number("pilight.firmware.lpf", firmware.lpf, 0); - registry_set_number("pilight.firmware.hpf", firmware.hpf, 0); - - struct JsonNode *jmessage = json_mkobject(); - struct JsonNode *jcode = json_mkobject(); - json_append_member(jcode, "version", json_mknumber(firmware.version, 0)); - json_append_member(jcode, "lpf", json_mknumber(firmware.lpf, 0)); - json_append_member(jcode, "hpf", json_mknumber(firmware.hpf, 0)); - json_append_member(jmessage, "values", jcode); - json_append_member(jmessage, "origin", json_mkstring("core")); - json_append_member(jmessage, "type", json_mknumber(FIRMWARE, 0)); - char pname[17]; - strcpy(pname, "pilight-firmware"); - pilight.broadcast(pname, jmessage, FW); - json_delete(jmessage); - jmessage = NULL; - } - } - } - broadcasted = 0; - - struct JsonNode *childs = json_first_child(bcqueue->jmessage); - int nrchilds = 0; - while(childs) { - nrchilds++; - childs = childs->next; - } - - /* Write the message to all receivers */ - struct clients_t *tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->receiver == 1 && tmp_clients->forward == 0) { - if(strcmp(out, "{}") != 0 && nrchilds > 1) { - socket_write(tmp_clients->id, out); - broadcasted = 1; - } - } - tmp_clients = tmp_clients->next; - } - - if(pilight.runmode == ADHOC && sockfd > 0) { - struct JsonNode *jupdate = json_decode(internal); - json_append_member(jupdate, "action", json_mkstring("update")); - char *ret = json_stringify(jupdate, NULL); - socket_write(sockfd, ret); - broadcasted = 1; - json_delete(jupdate); - json_free(ret); - } - if((broadcasted == 1 || nodaemon == 1) && (strcmp(out, "{}") != 0 && nrchilds > 1)) { - logprintf(LOG_DEBUG, "broadcasted: %s", out); - } - json_free(internal); - // json_free(out); - eventpool_trigger(REASON_BROADCAST_CORE, reason_broadcast_core_free, out); - } - } - struct bcqueue_t *tmp = bcqueue; - FREE(tmp->protoname); - json_delete(tmp->jmessage); - bcqueue = bcqueue->next; - FREE(tmp); - bcqueue_number--; - pthread_mutex_unlock(&bcqueue_lock); - } else { - pthread_cond_wait(&bcqueue_signal, &bcqueue_lock); - } - } - return (void *)NULL; -} - -static void receive_queue(int *raw, int rawlen, int plslen, int hwtype) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int i = 0; - - if(main_loop == 1) { - pthread_mutex_lock(&recvqueue_lock); - if(recvqueue_number <= 1024) { - struct recvqueue_t *rnode = MALLOC(sizeof(struct recvqueue_t)); - if(rnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - for(i=0;iraw[i] = raw[i]; - } - rnode->rawlen = rawlen; - rnode->plslen = plslen; - rnode->hwtype = hwtype; - - if(recvqueue_number == 0) { - recvqueue = rnode; - recvqueue_head = rnode; - } else { - recvqueue_head->next = rnode; - recvqueue_head = rnode; - } - - recvqueue_number++; - } else { - logprintf(LOG_ERR, "receiver queue full"); - } - pthread_mutex_unlock(&recvqueue_lock); - pthread_cond_signal(&recvqueue_signal); - } -} - -static void receiver_create_message(protocol_t *protocol) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(protocol->message != NULL) { - char *valid = json_stringify(protocol->message, NULL); - json_delete(protocol->message); - if(valid != NULL && json_validate(valid) == true) { - struct JsonNode *jmessage = json_mkobject(); - - json_append_member(jmessage, "message", json_decode(valid)); - json_append_member(jmessage, "origin", json_mkstring("receiver")); - json_append_member(jmessage, "protocol", json_mkstring(protocol->id)); - if(strlen(pilight_uuid) > 0) { - json_append_member(jmessage, "uuid", json_mkstring(pilight_uuid)); - } - if(protocol->repeats > -1) { - json_append_member(jmessage, "repeats", json_mknumber(protocol->repeats, 0)); - } - char *output = json_stringify(jmessage, NULL); - struct JsonNode *json = json_decode(output); - broadcast_queue(protocol->id, json, RECEIVER); - json_free(output); - json_delete(json); - json = NULL; - json_delete(jmessage); - } - json_free(valid); - } - protocol->message = NULL; -} - -static void receive_parse_api(struct JsonNode *code, int hwtype) { - struct protocol_t *protocol = NULL; - struct protocols_t *pnode = protocols; - - while(pnode != NULL) { - protocol = pnode->listener; - - if(protocol->hwtype == hwtype && protocol->parseCommand != NULL) { - protocol->parseCommand(code); - receiver_create_message(protocol); - } - pnode = pnode->next; - } -} - -void *receive_parse_code(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - pthread_mutex_lock(&recvqueue_lock); - while(main_loop) { - if(recvqueue_number > 0) { - pthread_mutex_lock(&recvqueue_lock); - - logprintf(LOG_STACK, "%s::unlocked", __FUNCTION__); - - struct protocol_t *protocol = NULL; - struct protocols_t *pnode = protocols; - - while(pnode != NULL && main_loop) { - protocol = pnode->listener; - - if((protocol->hwtype == recvqueue->hwtype || protocol->hwtype == -1 || recvqueue->hwtype == -1) && - (protocol->parseCode != NULL && protocol->validate != NULL)) { - - if(recvqueue->rawlen < MAXPULSESTREAMLENGTH) { - protocol->raw = recvqueue->raw; - } - protocol->rawlen = recvqueue->rawlen; - - if(protocol->validate() == 0) { - logprintf(LOG_DEBUG, "possible %s protocol", protocol->id); - gettimeofday(&tv, NULL); - if(protocol->first > 0) { - protocol->first = protocol->second; - } - protocol->second = 1000000 * (unsigned int)tv.tv_sec + (unsigned int)tv.tv_usec; - if(protocol->first == 0) { - protocol->first = protocol->second; - } - - /* Reset # of repeats after a certain delay */ - if(((int)protocol->second-(int)protocol->first) > 500000) { - protocol->repeats = 0; - } - - protocol->repeats++; - if(protocol->parseCode != NULL) { - logprintf(LOG_DEBUG, "recevied pulse length of %d", recvqueue->plslen); - logprintf(LOG_DEBUG, "caught minimum # of repeats %d of %s", protocol->repeats, protocol->id); - logprintf(LOG_DEBUG, "called %s parseRaw()", protocol->id); - protocol->parseCode(); - receiver_create_message(protocol); - } - } - } - pnode = pnode->next; - } - - struct recvqueue_t *tmp = recvqueue; - recvqueue = recvqueue->next; - FREE(tmp); - recvqueue_number--; - pthread_mutex_unlock(&recvqueue_lock); - } else { - pthread_cond_wait(&recvqueue_signal, &recvqueue_lock); - } - } - return (void *)NULL; -} - -void *send_code(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int i = 0; - - /* Make sure the pilight sender gets - the highest priority available */ -#ifdef _WIN32 - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); -#else - struct sched_param sched; - memset(&sched, 0, sizeof(sched)); - sched.sched_priority = 80; - pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched); -#endif - - pthread_mutex_lock(&sendqueue_lock); - - while(main_loop) { - if(sendqueue_number > 0) { - pthread_mutex_lock(&sendqueue_lock); - - logprintf(LOG_STACK, "%s::unlocked", __FUNCTION__); - - sending = 1; - - struct protocol_t *protocol = sendqueue->protopt; - struct hardware_t *hw = NULL; - - struct JsonNode *message = NULL; - - if(sendqueue->message != NULL && strcmp(sendqueue->message, "{}") != 0) { - if(json_validate(sendqueue->message) == true) { - if(message == NULL) { - message = json_mkobject(); - } - json_append_member(message, "origin", json_mkstring("sender")); - json_append_member(message, "protocol", json_mkstring(protocol->id)); - json_append_member(message, "message", json_decode(sendqueue->message)); - if(strlen(sendqueue->uuid) > 0) { - json_append_member(message, "uuid", json_mkstring(sendqueue->uuid)); - } - json_append_member(message, "repeat", json_mknumber(1, 0)); - } - } - if(sendqueue->settings != NULL && strcmp(sendqueue->settings, "{}") != 0) { - if(json_validate(sendqueue->settings) == true) { - if(message == NULL) { - message = json_mkobject(); - } - json_append_member(message, "settings", json_decode(sendqueue->settings)); - } - } - - struct conf_hardware_t *tmp_confhw = conf_hardware; - while(tmp_confhw) { - if(protocol->hwtype == tmp_confhw->hardware->hwtype) { - hw = tmp_confhw->hardware; - break; - } - tmp_confhw = tmp_confhw->next; - } - if(hw != NULL) { -#ifdef PILIGHT_DEVELOPMENT - if((hw->comtype == COMOOK || hw->comtype == COMPLSTRAIN) && hw->sendOOK != NULL) { - if(hw->receiveOOK != NULL || hw->receivePulseTrain != NULL) { - hw->wait = 1; - pthread_mutex_unlock(&hw->lock); - pthread_cond_signal(&hw->signal); - } -#else - if((hw->comtype == COMOOK) || (hw->comtype == COMPLSTRAIN && hw->sendOOK != NULL)) { -#endif - logprintf(LOG_DEBUG, "**** RAW CODE ****"); - if(log_level_get() >= LOG_DEBUG) { - for(i=0;ilength;i++) { - printf("%d ", sendqueue->code[i]); - } - printf("\n"); - } - logprintf(LOG_DEBUG, "**** RAW CODE ****"); - - /* - * Rewrite start - */ - struct reason_send_code_t *data = MALLOC(sizeof(struct reason_send_code_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - data->origin = ORIGIN_SENDER; - memset(&data->message, 0, 255); - // snprintf(data->message, 1024, "{\"message\":%s}", message); - data->rawlen = sendqueue->length; - memcpy(data->pulses, sendqueue->code, data->rawlen*sizeof(int)); - data->txrpt = protocol->txrpt; - strncpy(data->protocol, protocol->id, 255); - data->hwtype = hw->hwtype; - - memset(data->uuid, 0, UUID_LENGTH+1); - eventpool_trigger(REASON_SEND_CODE, reason_send_code_free, data); - /* - * Rewrite end - */ - -#ifdef PILIGHT_DEVELOPMENT - if(hw->sendOOK(sendqueue->code, sendqueue->length, protocol->txrpt) == 0) { - logprintf(LOG_DEBUG, "successfully send %s code", protocol->id); - } else { - logprintf(LOG_ERR, "failed to send code"); - } -#endif - if(strcmp(protocol->id, "raw") == 0) { - int plslen = sendqueue->code[sendqueue->length-1]/PULSE_DIV; - receive_queue(sendqueue->code, sendqueue->length, plslen, -1); - } -#ifdef PILIGHT_DEVELOPMENT - if(hw->receiveOOK != NULL || hw->receivePulseTrain != NULL) { - hw->wait = 0; - pthread_mutex_unlock(&hw->lock); - pthread_cond_signal(&hw->signal); - } -#endif - } else if(hw->comtype == COMAPI && hw->sendAPI != NULL) { - if(message != NULL) { - if(hw->sendAPI(message) == 0) { - logprintf(LOG_DEBUG, "successfully send %s command", protocol->id); - } else { - logprintf(LOG_ERR, "failed to send command"); - } - } - } - } else { - if(strcmp(protocol->id, "raw") == 0) { - int plslen = sendqueue->code[sendqueue->length-1]/PULSE_DIV; - receive_queue(sendqueue->code, sendqueue->length, plslen, -1); - } - } - if(message != NULL) { - broadcast_queue(sendqueue->protoname, message, sendqueue->origin); - json_delete(message); - message = NULL; - } - - struct sendqueue_t *tmp = sendqueue; - if(tmp->message != NULL) { - FREE(tmp->message); - } - if(tmp->settings != NULL) { - FREE(tmp->settings); - } - FREE(tmp->protoname); - sendqueue = sendqueue->next; - FREE(tmp); - sendqueue_number--; - sending = 0; - pthread_mutex_unlock(&sendqueue_lock); - } else { - pthread_cond_wait(&sendqueue_signal, &sendqueue_lock); - } - } - return (void *)NULL; -} - -/* Send a specific code */ -static int send_queue(struct JsonNode *json, enum origin_t origin) { - pthread_mutex_lock(&sendqueue_lock); - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int match = 0, raw[MAXPULSESTREAMLENGTH-1]; - struct timeval tcurrent; - struct clients_t *tmp_clients = NULL; - char *uuid = NULL, *buffer = NULL; - /* Hold the final protocol struct */ - struct protocol_t *protocol = NULL; - -#ifdef _WIN32 - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); -#else - /* Make sure the pilight sender gets - the highest priority available */ - struct sched_param sched; - memset(&sched, 0, sizeof(sched)); - sched.sched_priority = 80; - pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched); -#endif - - struct JsonNode *jcode = NULL; - struct JsonNode *jprotocols = NULL; - struct JsonNode *jprotocol = NULL; - - buffer = json_stringify(json, NULL); - tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->forward == 1) { - socket_write(tmp_clients->id, buffer); - } - tmp_clients = tmp_clients->next; - } - json_free(buffer); - - if((jcode = json_find_member(json, "code")) == NULL) { - logprintf(LOG_ERR, "sender did not send any codes"); - json_delete(jcode); - pthread_mutex_unlock(&sendqueue_lock); - return -1; - } else if((jprotocols = json_find_member(jcode, "protocol")) == NULL) { - logprintf(LOG_ERR, "sender did not provide a protocol name"); - json_delete(jcode); - pthread_mutex_unlock(&sendqueue_lock); - return -1; - } else { - json_find_string(jcode, "uuid", &uuid); - /* If we matched a protocol and are not already sending, continue */ - if(uuid == NULL || (uuid != NULL && strcmp(uuid, pilight_uuid) == 0)) { - jprotocol = json_first_child(jprotocols); - while(jprotocol && match == 0) { - match = 0; - if(jprotocol->tag == JSON_STRING) { - struct protocols_t *pnode = protocols; - /* Retrieve the used protocol */ - while(pnode) { - protocol = pnode->listener; - /* Check if the protocol exists */ - if(protocol_device_exists(protocol, jprotocol->string_) == 0 && match == 0) { - match = 1; - break; - } - pnode = pnode->next; - } - } - jprotocol = jprotocol->next; - } - memset(raw, 0, sizeof(raw)); - protocol->raw = raw; - if(match == 1 && protocol->createCode != NULL) { - /* Let the protocol create his code */ - if(protocol->createCode(jcode) == 0 && main_loop == 1) { - if(sendqueue_number <= 1024) { - struct sendqueue_t *mnode = MALLOC(sizeof(struct sendqueue_t)); - if(mnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - gettimeofday(&tcurrent, NULL); - mnode->origin = origin; - mnode->id = 1000000 * (unsigned int)tcurrent.tv_sec + (unsigned int)tcurrent.tv_usec; - mnode->message = NULL; - if(protocol->message != NULL) { - char *jsonstr = json_stringify(protocol->message, NULL); - json_delete(protocol->message); - if(json_validate(jsonstr) == true) { - if((mnode->message = MALLOC(strlen(jsonstr)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(mnode->message, jsonstr); - } - json_free(jsonstr); - protocol->message = NULL; - } - - mnode->length = protocol->rawlen; - memcpy(mnode->code, protocol->raw, sizeof(int)*protocol->rawlen); - - if((mnode->protoname = MALLOC(strlen(protocol->id)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(mnode->protoname, protocol->id); - mnode->protopt = protocol; - - struct options_t *tmp_options = protocol->options; - char *stmp = NULL; - struct JsonNode *jsettings = json_mkobject(); - struct JsonNode *jtmp = NULL; - while(tmp_options) { - if(tmp_options->conftype == DEVICES_SETTING) { - if(tmp_options->vartype == JSON_NUMBER && - (jtmp = json_find_member(jcode, tmp_options->name)) != NULL && - jtmp->tag == JSON_NUMBER) { - json_append_member(jsettings, tmp_options->name, json_mknumber(jtmp->number_, jtmp->decimals_)); - } else if(tmp_options->vartype == JSON_STRING && json_find_string(jcode, tmp_options->name, &stmp) == 0) { - json_append_member(jsettings, tmp_options->name, json_mkstring(stmp)); - } - } - tmp_options = tmp_options->next; - } - char *strsett = json_stringify(jsettings, NULL); - if((mnode->settings = MALLOC(strlen(strsett)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(mnode->settings, strsett); - json_free(strsett); - json_delete(jsettings); - - if(uuid != NULL) { - strcpy(mnode->uuid, uuid); - } else { - memset(mnode->uuid, '\0', UUID_LENGTH); - } - if(sendqueue_number == 0) { - sendqueue = mnode; - sendqueue_head = mnode; - } else { - sendqueue_head->next = mnode; - sendqueue_head = mnode; - } - sendqueue_number++; - } else { - logprintf(LOG_ERR, "send queue full"); - pthread_mutex_unlock(&sendqueue_lock); - return -1; - } - pthread_mutex_unlock(&sendqueue_lock); - pthread_cond_signal(&sendqueue_signal); - return 0; - } else { - pthread_mutex_unlock(&sendqueue_lock); - return -1; - } - } - } else { - pthread_mutex_unlock(&sendqueue_lock); - return 0; - } - } - pthread_mutex_unlock(&sendqueue_lock); - return -1; -} - -#ifdef WEBSERVER -static void client_webserver_parse_code(int i, char buffer[BUFFER_SIZE]) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int sd = socket_get_clients(i); - int x = 0; - FILE *f; - char *p = NULL; - char buff[BUFFER_SIZE]; - char *cache = NULL; - char *path = NULL, buf[INET_ADDRSTRLEN+1]; - struct stat sb; - struct sockaddr_in sockin; - socklen_t len = sizeof(sockin); - - if(getsockname(sd, (struct sockaddr *)&sockin, &len) == -1) { - logprintf(LOG_ERR, "could not determine server ip address"); - } else { - if(strstr(buffer, " HTTP/") == NULL) { - return; - } - p = buff; - if(strstr(buffer, "/logo.png") != NULL) { - if((path = MALLOC(strlen(webserver_root)+strlen("logo.png")+2)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - sprintf(path, "%s/logo.png", webserver_root); - if((f = fopen(path, "rb"))) { - fstat(fileno(f), &sb); - webserver_create_header(&p, "200 OK", "image/png", (unsigned int)sb.st_size); - send(sd, (const char *)buff, (size_t)(p-buff), MSG_NOSIGNAL); - x = 0; - if((cache = MALLOC(BUFFER_SIZE)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(cache, '\0', BUFFER_SIZE); - while(!feof(f)) { - x = (int)fread(cache, 1, BUFFER_SIZE, f); - send(sd, (const char *)cache, (size_t)x, MSG_NOSIGNAL); - } - fclose(f); - FREE(cache); - } else { - logprintf(LOG_WARNING, "pilight logo not found"); - } - FREE(path); - } else { - /* Catch all webserver page to inform users on which port the webserver runs */ - webserver_create_header(&p, "200 OK", "text/html", (unsigned int)BUFFER_SIZE); - send(sd, (const char *)buff, (size_t)(p-buff), MSG_NOSIGNAL); - if(webserver_enable == 1) { - if((cache = MALLOC(BUFFER_SIZE)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(cache, '\0', BUFFER_SIZE); - memset(&buf, '\0', INET_ADDRSTRLEN+1); - inet_ntop(AF_INET, (void *)&(sockin.sin_addr), buf, INET_ADDRSTRLEN+1); - sprintf(cache, "pilight" - "

" - "

" - "The pilight webgui is located at " - "http://%s:%d

" - "
", - buf, webserver_http_port, buf, webserver_http_port); - send(sd, (const char *)cache, strlen(cache), MSG_NOSIGNAL); - FREE(cache); - } else { - send(sd, "
", 57, MSG_NOSIGNAL); - } - } - } -} -#endif - -static int control_device(struct devices_t *dev, char *state, struct JsonNode *values, enum origin_t origin) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct devices_settings_t *sett = NULL; - struct devices_values_t *val = NULL; - struct options_t *opt = NULL; - struct protocols_t *tmp_protocols = NULL; - - struct JsonNode *code = json_mkobject(); - struct JsonNode *json = json_mkobject(); - struct JsonNode *jprotocols = json_mkarray(); - - /* Check all protocol options */ - tmp_protocols = dev->protocols; - while(tmp_protocols) { - json_append_element(jprotocols, json_mkstring(tmp_protocols->name)); - if((opt = tmp_protocols->listener->options)) { - while(opt) { - sett = dev->settings; - while(sett) { - /* Retrieve the device id's */ - if(strcmp(sett->name, "id") == 0) { - val = sett->values; - while(val) { - if((opt->conftype == DEVICES_ID) - && strcmp(val->name, opt->name) == 0 - && json_find_member(code, opt->name) == NULL) { - if(val->type == JSON_STRING) { - json_append_member(code, val->name, json_mkstring(val->string_)); - } else if(val->type == JSON_NUMBER) { - json_append_member(code, val->name, json_mknumber(val->number_, val->decimals)); - } - } - val = val->next; - } - } - if(strcmp(sett->name, opt->name) == 0 - && opt->conftype == DEVICES_SETTING) { - val = sett->values; - if(json_find_member(code, opt->name) == NULL) { - if(val->type == JSON_STRING) { - json_append_member(code, opt->name, json_mkstring(val->string_)); - } else if(val->type == JSON_NUMBER) { - json_append_member(code, opt->name, json_mknumber(val->number_, val->decimals)); - } - } - } - sett = sett->next; - } - opt = opt->next; - } - while(values) { - opt = tmp_protocols->listener->options; - while(opt) { - if((opt->conftype == DEVICES_VALUE || opt->conftype == DEVICES_OPTIONAL) - && strcmp(values->key, opt->name) == 0 - && json_find_member(code, opt->name) == NULL) { - if(values->tag == JSON_STRING) { - json_append_member(code, values->key, json_mkstring(values->string_)); - } else if(values->tag == JSON_NUMBER) { - json_append_member(code, values->key, json_mknumber(values->number_, values->decimals_)); - } - } - opt = opt->next; - } - values = values->next; - } - } - /* Send the new device state */ - if((opt = tmp_protocols->listener->options) && state != NULL) { - while(opt) { - if(json_find_member(code, opt->name) == NULL) { - if(opt->conftype == DEVICES_STATE && opt->argtype == OPTION_NO_VALUE && strcmp(opt->name, state) == 0) { - json_append_member(code, opt->name, json_mknumber(1, 0)); - break; - } else if(opt->conftype == DEVICES_STATE && opt->argtype == OPTION_HAS_VALUE) { - json_append_member(code, opt->name, json_mkstring(state)); - break; - } - } - opt = opt->next; - } - } - tmp_protocols = tmp_protocols->next; - } - - /* Construct the right json object */ - json_append_member(code, "protocol", jprotocols); - if(dev->dev_uuid != NULL && dev->cst_uuid == 1) { - /*if(dev->dev_uuid != NULL && (dev->protocols->listener->hwtype == SENSOR - || dev->protocols->listener->hwtype == HWRELAY)) {*/ - json_append_member(code, "uuid", json_mkstring(dev->dev_uuid)); - } - json_append_member(json, "code", code); - json_append_member(json, "action", json_mkstring("send")); - - if(send_queue(json, origin) == 0) { - json_delete(json); - return 0; - } - - json_delete(json); - return -1; -} - -/* Parse the incoming buffer from the client */ -static void socket_parse_data(int i, char *buffer) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr_in address; - struct JsonNode *json = NULL; - struct JsonNode *options = NULL; - struct clients_t *tmp_clients = NULL; - struct clients_t *client = NULL; - int sd = -1; - int addrlen = sizeof(address); - char *action = NULL, *media = NULL, *status = NULL; - int error = 0, exists = 0; - - if(pilight.runmode == ADHOC) { - sd = sockfd; - } else { - sd = socket_get_clients(i); - getpeername(sd, (struct sockaddr*)&address, (socklen_t*)&addrlen); - } - - if(strcmp(buffer, "HEART") == 0) { - socket_write(sd, "BEAT"); - } else { - if(pilight.runmode != ADHOC) { - logprintf(LOG_DEBUG, "socket recv: %s", buffer); - } - /* Serve static webserver page. This is the only request that is - expected not to be a json object */ -#ifdef WEBSERVER - if(strstr(buffer, " HTTP/")) { - client_webserver_parse_code(i, buffer); - socket_close(sd); - } else if(json_validate(buffer) == true) { -#else - if(json_validate(buffer) == true) { -#endif - json = json_decode(buffer); - if((json_find_string(json, "action", &action)) == 0) { - tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->id == sd) { - exists = 1; - client = tmp_clients; - break; - } - tmp_clients = tmp_clients->next; - } - if(strcmp(action, "identify") == 0) { - /* Check if client doesn't already exist */ - if(exists == 0) { - if((client = MALLOC(sizeof(struct clients_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - client->core = 0; - client->config = 0; - client->receiver = 0; - client->forward = 0; - client->stats = 0; - client->cpu = 0; - client->ram = 0; - strcpy(client->media, "all"); - client->next = NULL; - client->id = sd; - memset(client->uuid, '\0', sizeof(client->uuid)); - } - if(json_find_string(json, "media", &media) == 0) { - if(strcmp(media, "all") == 0 || strcmp(media, "mobile") == 0 || - strcmp(media, "desktop") == 0 || strcmp(media, "web") == 0) { - strcpy(client->media, media); - } - } else { - strcpy(client->media, "all"); - } - char *t = NULL; - if(json_find_string(json, "uuid", &t) == 0) { - strcpy(client->uuid, t); - } - if((options = json_find_member(json, "options")) != NULL) { - struct JsonNode *childs = json_first_child(options); - while(childs) { - if(strcmp(childs->key, "core") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->core = 1; - } else { - client->core = 0; - } - } else if(strcmp(childs->key, "stats") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->stats = 1; - } else { - client->stats = 0; - } - } else if(strcmp(childs->key, "receiver") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->receiver = 1; - } else { - client->receiver = 0; - } - } else if(strcmp(childs->key, "config") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->config = 1; - } else { - client->config = 0; - } - } else if(strcmp(childs->key, "forward") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->forward = 1; - } else { - client->forward = 0; - } - } else { - error = 1; - break; - } - childs = childs->next; - } - } - if(exists == 0) { - if(error == 1) { - FREE(client); - } else { - tmp_clients = clients; - if(tmp_clients) { - while(tmp_clients->next != NULL) { - tmp_clients = tmp_clients->next; - } - tmp_clients->next = client; - } else { - client->next = clients; - clients = client; - } - } - } - socket_write(sd, "{\"status\":\"success\"}"); - } else if(strcmp(action, "send") == 0) { - if(send_queue(json, SENDER) == 0) { - socket_write(sd, "{\"status\":\"success\"}"); - } else { - socket_write(sd, "{\"status\":\"failed\"}"); - } - } else if(strcmp(action, "control") == 0) { - struct JsonNode *code = NULL; - struct devices_t *dev = NULL; - char *device = NULL; - if((code = json_find_member(json, "code")) == NULL || code->tag != JSON_OBJECT) { - logprintf(LOG_ERR, "client did not send any codes"); - } else { - /* Check if a location and device are given */ - if(json_find_string(code, "device", &device) != 0) { - logprintf(LOG_ERR, "client did not send a device"); - /* Check if the device and location exists in the config file */ - } else if(devices_get(device, &dev) == 0) { - char *state = NULL; - struct JsonNode *values = NULL; - - json_find_string(code, "state", &state); - if((values = json_find_member(code, "values")) != NULL) { - values = json_first_child(values); - } - - if(control_device(dev, state, values, SENDER) == 0) { - socket_write(sd, "{\"status\":\"success\"}"); - } else { - socket_write(sd, "{\"status\":\"failed\"}"); - } - } else { - logprintf(LOG_ERR, "the device \"%s\" does not exist", device); - } - } - } else if(strcmp(action, "registry") == 0) { - struct JsonNode *value = NULL; - char *type = NULL; - char *key = NULL; - char *sval = NULL; - double nval = 0.0; - int dec = 0; - if(json_find_string(json, "type", &type) != 0) { - logprintf(LOG_ERR, "client did not send a type of action"); - } else { - if(strcmp(type, "set") == 0) { - if(json_find_string(json, "key", &key) != 0) { - logprintf(LOG_ERR, "client did not send a registry key"); - socket_write(sd, "{\"status\":\"failed\"}"); - } else if((value = json_find_member(json, "value")) == NULL) { - logprintf(LOG_ERR, "client did not send a registry value"); - socket_write(sd, "{\"status\":\"failed\"}"); - } else { - if(value->tag == JSON_NUMBER) { - if(registry_set_number(key, value->number_, value->decimals_) == 0) { - socket_write(sd, "{\"status\":\"success\"}"); - } else { - socket_write(sd, "{\"status\":\"failed\"}"); - } - } else if(value->tag == JSON_STRING) { - if(registry_set_string(key, value->string_) == 0) { - socket_write(sd, "{\"status\":\"success\"}"); - } else { - socket_write(sd, "{\"status\":\"failed\"}"); - } - } else { - logprintf(LOG_ERR, "registry value can only be a string or number"); - socket_write(sd, "{\"status\":\"failed\"}"); - } - } - } else if(strcmp(type, "remove") == 0) { - if(json_find_string(json, "key", &key) != 0) { - logprintf(LOG_ERR, "client did not send a registry key"); - socket_write(sd, "{\"status\":\"failed\"}"); - } else { - if(registry_remove_value(key) == 0) { - socket_write(sd, "{\"status\":\"success\"}"); - } else { - socket_write(sd, "{\"status\":\"failed\"}"); - } - } - } else if(strcmp(type, "get") == 0) { - if(json_find_string(json, "key", &key) != 0) { - logprintf(LOG_ERR, "client did not send a registry key"); - socket_write(sd, "{\"status\":\"failed\"}"); - } else { - if(registry_get_number(key, &nval, &dec) == 0) { - struct JsonNode *jsend = json_mkobject(); - json_append_member(jsend, "message", json_mkstring("registry")); - json_append_member(jsend, "value", json_mknumber(nval, dec)); - json_append_member(jsend, "key", json_mkstring(key)); - char *output = json_stringify(jsend, NULL); - socket_write(sd, output); - json_free(output); - json_delete(jsend); - } else if(registry_get_string(key, &sval) == 0) { - struct JsonNode *jsend = json_mkobject(); - json_append_member(jsend, "message", json_mkstring("registry")); - json_append_member(jsend, "value", json_mkstring(sval)); - json_append_member(jsend, "key", json_mkstring(key)); - char *output = json_stringify(jsend, NULL); - socket_write(sd, output); - json_free(output); - json_delete(jsend); - } else { - logprintf(LOG_ERR, "registry key '%s' doesn't exists", key); - socket_write(sd, "{\"status\":\"failed\"}"); - } - } - } - } - } else if(strcmp(action, "request config") == 0) { - struct JsonNode *jsend = json_mkobject(); - struct JsonNode *jconfig = NULL; - if(client->forward == 1) { - jconfig = config_print(CONFIG_FORWARD, client->media); - } else { - jconfig = config_print(CONFIG_INTERNAL, client->media); - } - json_append_member(jsend, "message", json_mkstring("config")); - json_append_member(jsend, "config", jconfig); - char *output = json_stringify(jsend, NULL); - str_replace("%", "%%", &output); - socket_write(sd, output); - json_free(output); - json_delete(jsend); - } else if(strcmp(action, "request values") == 0) { - struct JsonNode *jsend = json_mkobject(); - struct JsonNode *jvalues = devices_values(client->media); - json_append_member(jsend, "message", json_mkstring("values")); - json_append_member(jsend, "values", jvalues); - char *output = json_stringify(jsend, NULL); - socket_write(sd, output); - json_free(output); - json_delete(jsend); - /* send version packet */ - struct JsonNode *jsend_version = json_mkobject(); - json_append_member(jsend_version, "version", json_mkstring(PILIGHT_VERSION)); - char *output_version = json_stringify(jsend_version, NULL); - socket_write(sd, output_version); - json_free(output_version); - json_delete(jsend_version); - - /* - * Parse received codes from nodes - */ - } else if(strcmp(action, "update") == 0) { - struct JsonNode *jvalues = NULL; - char *pname = NULL; - if((jvalues = json_find_member(json, "values")) != NULL) { - exists = 0; - tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->id == sd) { - exists = 1; - client = tmp_clients; - break; - } - tmp_clients = tmp_clients->next; - } - if(exists) { - json_find_number(jvalues, "ram", &client->ram); - json_find_number(jvalues, "cpu", &client->cpu); - } - } - if(json_find_string(json, "protocol", &pname) == 0) { - broadcast_queue(pname, json, MASTER); - } - } else { - error = 1; - } - } else if((json_find_string(json, "status", &status)) == 0) { - tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->id == sd) { - exists = 1; - client = tmp_clients; - break; - } - tmp_clients = tmp_clients->next; - } - if(strcmp(status, "success") == 0) { - logprintf(LOG_DEBUG, "client \"%s\" successfully executed our latest request", client->uuid); - } else if(strcmp(status, "failed") == 0) { - logprintf(LOG_DEBUG, "client \"%s\" failed executing our latest request", client->uuid); - } - } else { - error = 1; - } - json_delete(json); - } - } - if(error == 1) { - client_remove(sd); - socket_close(sd); - } -} - -/* Rewrite code start */ - -static int socket_parse_responses(char *buffer, char *media, char **respons) { - struct JsonNode *json = NULL; - char *action = NULL, *status = NULL; - - if(strcmp(buffer, "HEART") == 0) { - if((*respons = MALLOC(strlen("BEAT")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "BEAT"); - return 0; - } else { - if(pilight.runmode != ADHOC) { - logprintf(LOG_DEBUG, "socket recv: %s", buffer); - } - - if(json_validate(buffer) == true) { - json = json_decode(buffer); - if((json_find_string(json, "status", &status)) == 0) { - if(strcmp(status, "success") == 0) { - if((*respons = MALLOC(strlen("{\"status\":\"success\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"success\"}"); - json_delete(json); - return 0; - } - } - if((json_find_string(json, "action", &action)) == 0) { - if(strcmp(action, "send") == 0) { - if(send_queue(json, ORIGIN_SENDER) == 0) { - if((*respons = MALLOC(strlen("{\"status\":\"success\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"success\"}"); - json_delete(json); - return 0; - } else { - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } - } else if(strcmp(action, "control") == 0) { - struct JsonNode *code = NULL; - char *device = NULL; - struct devices_t *dev = NULL; - if((code = json_find_member(json, "code")) == NULL || code->tag != JSON_OBJECT) { - logprintf(LOG_ERR, "client did not send any codes"); - json_delete(json); - return -1; - } else { - /* Check if a location and device are given */ - if(json_find_string(code, "device", &device) != 0) { - logprintf(LOG_ERR, "client did not send a device"); - json_delete(json); - return -1; - /* Check if the device and location exists in the config file */ - } else if(devices_get(device, &dev) == 0) { - char *state = NULL; - struct JsonNode *values = NULL; - - json_find_string(code, "state", &state); - if((values = json_find_member(code, "values")) != NULL) { - values = json_first_child(values); - } - - if(control_device(dev, state, values, ORIGIN_SENDER) == 0) { - if((*respons = MALLOC(strlen("{\"status\":\"success\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"success\"}"); - json_delete(json); - return 0; - } else { - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } - } else { - logprintf(LOG_ERR, "the device \"%s\" does not exist", device); - json_delete(json); - return -1; - } - } - } else if(strcmp(action, "registry") == 0) { - struct JsonNode *value = NULL; - char *type = NULL; - char *key = NULL; - char *sval = NULL; - double nval = 0.0; - int dec = 0; - if(json_find_string(json, "type", &type) != 0) { - logprintf(LOG_ERR, "client did not send a type of action"); - json_delete(json); - return -1; - } else { - if(strcmp(type, "set") == 0) { - if(json_find_string(json, "key", &key) != 0) { - logprintf(LOG_ERR, "client did not send a registry key"); - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } else if((value = json_find_member(json, "value")) == NULL) { - logprintf(LOG_ERR, "client did not send a registry value"); - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } else { - if(value->tag == JSON_NUMBER) { -#ifdef PILIGHT_REWRITE - if(registry_update(ORIGIN_MASTER, key, json_mknumber(value->number_, value->decimals_)) == 0) { -#else - if(registry_set_number(key, value->number_, value->decimals_) == 0) { -#endif - if((*respons = MALLOC(strlen("{\"status\":\"success\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"success\"}"); - json_delete(json); - return 0; - } else { - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } - } else if(value->tag == JSON_STRING) { -#ifdef PILIGHT_REWRITE - if(registry_update(ORIGIN_MASTER, key, json_mkstring(value->string_)) == 0) { -#else - if(registry_set_string(key, value->string_) == 0) { -#endif - if((*respons = MALLOC(strlen("{\"status\":\"success\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"success\"}"); - json_delete(json); - return 0; - } else { - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } - } else { - logprintf(LOG_ERR, "registry value can only be a string or number"); - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } - } - } else if(strcmp(type, "remove") == 0) { - if(json_find_string(json, "key", &key) != 0) { - logprintf(LOG_ERR, "client did not send a registry key"); - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } else { -#ifdef PILIGHT_REWRITE - if(registry_delete(ORIGIN_MASTER, key) == 0) { -#else - if(registry_remove_value(key) == 0) { -#endif - if((*respons = MALLOC(strlen("{\"status\":\"success\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"success\"}"); - json_delete(json); - return 0; - } else { - logprintf(LOG_ERR, "registry value can only be a string or number"); - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } - } - } else if(strcmp(type, "get") == 0) { - if(json_find_string(json, "key", &key) != 0) { - logprintf(LOG_ERR, "client did not send a registry key"); - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } else { -#ifdef PILIGHT_REWRITE - if(registry_select_number(ORIGIN_MASTER, key, &nval, &dec) == 0) { -#else - if(registry_get_number(key, &nval, &dec) == 0) { -#endif - struct JsonNode *jsend = json_mkobject(); - json_append_member(jsend, "message", json_mkstring("registry")); - json_append_member(jsend, "value", json_mknumber(nval, dec)); - json_append_member(jsend, "key", json_mkstring(key)); - char *output = json_stringify(jsend, NULL); - if((*respons = MALLOC(strlen(output)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, output); - json_free(output); - json_delete(jsend); - json_delete(json); - return 0; -#ifdef PILIGHT_REWRITE - } else if(registry_select_string(ORIGIN_MASTER, key, &sval) == 0) { -#else - } else if(registry_get_string(key, &sval) == 0) { -#endif - struct JsonNode *jsend = json_mkobject(); - json_append_member(jsend, "message", json_mkstring("registry")); - json_append_member(jsend, "value", json_mkstring(sval)); - json_append_member(jsend, "key", json_mkstring(key)); - char *output = json_stringify(jsend, NULL); - if((*respons = MALLOC(strlen(output)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, output); - json_free(output); - json_delete(jsend); - json_delete(json); - return 0; - } else { - logprintf(LOG_ERR, "registry key '%s' does not exist", key); - if((*respons = MALLOC(strlen("{\"status\":\"failed\"}")+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, "{\"status\":\"failed\"}"); - json_delete(json); - return 0; - } - } - } - } - } else if(strcmp(action, "request config") == 0) { - struct JsonNode *jsend = json_mkobject(); - struct JsonNode *jconfig = NULL; - jconfig = config_print(CONFIG_INTERNAL, media); - json_append_member(jsend, "message", json_mkstring("config")); - json_append_member(jsend, "config", jconfig); - char *output = json_stringify(jsend, NULL); - str_replace("%", "%%", &output); - if((*respons = MALLOC(strlen(output)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, output); - json_free(output); - json_delete(jsend); - json_delete(json); - return 0; - } else if(strcmp(action, "request values") == 0) { - struct JsonNode *jsend = json_mkobject(); -#ifdef PILIGHT_REWRITE - struct JsonNode *jvalues = values_print(media); -#else - JsonNode *jvalues = devices_values(media); -#endif - json_append_member(jsend, "message", json_mkstring("values")); - json_append_member(jsend, "values", jvalues); - char *output = json_stringify(jsend, NULL); - if((*respons = MALLOC(strlen(output)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(*respons, output); - json_free(output); - json_delete(jsend); - json_delete(json); - return 0; - } - } else { - json_delete(json); - return -1; - } - } - } - return -1; -} - -static void *socket_parse_data1(int reason, void *param) { - struct reason_socket_received_t *data = param; - - struct sockaddr_in address; - socklen_t socklen = sizeof(address); - - struct JsonNode *json = NULL; - struct JsonNode *options = NULL; - struct clients_t *tmp_clients = NULL; - struct clients_t *client = NULL; - char *action = NULL, *media = NULL, *status = NULL, *respons = NULL; - char all[] = "all"; - int error = 0, exists = 0, sd = -1; - - if(strlen(data->type) == 0) { - logprintf(LOG_ERR, "socket data misses a socket type"); - } - - if(data->buffer == NULL) { - logprintf(LOG_ERR, "socket message incorrectly formatted"); - return NULL; - } - - sd = data->fd; - getpeername(sd, (struct sockaddr*)&address, &socklen); - - tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->id == sd) { - exists = 1; - client = tmp_clients; - break; - } - tmp_clients = tmp_clients->next; - } - if(exists == 0) { - media = all; - } else { - media = client->media; - } - - if(json_validate(data->buffer) == true) { - json = json_decode(data->buffer); - if((json_find_string(json, "action", &action)) == 0) { - if(strcmp(action, "identify") == 0) { - /* Check if client doesn't already exist */ - if(exists == 0) { - if((client = MALLOC(sizeof(struct clients_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - client->core = 0; - client->config = 0; - client->receiver = 0; - client->forward = 0; - client->stats = 0; - client->cpu = 0; - strcpy(client->media, "all"); - client->next = NULL; - client->id = sd; - memset(client->uuid, '\0', sizeof(client->uuid)); - } - if(json_find_string(json, "media", &media) == 0) { - if(strcmp(media, "all") == 0 || strcmp(media, "mobile") == 0 || - strcmp(media, "desktop") == 0 || strcmp(media, "web") == 0) { - strcpy(client->media, media); - } - } else { - strcpy(client->media, "all"); - } - char *t = NULL; - if(json_find_string(json, "uuid", &t) == 0) { - strcpy(client->uuid, t); - } - if((options = json_find_member(json, "options")) != NULL) { - struct JsonNode *childs = json_first_child(options); - while(childs) { - if(strcmp(childs->key, "core") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->core = 1; - } else { - client->core = 0; - } - } else if(strcmp(childs->key, "stats") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->stats = 1; - } else { - client->stats = 0; - } - } else if(strcmp(childs->key, "receiver") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->receiver = 1; - } else { - client->receiver = 0; - } - } else if(strcmp(childs->key, "config") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->config = 1; - } else { - client->config = 0; - } - } else if(strcmp(childs->key, "forward") == 0 && - childs->tag == JSON_NUMBER) { - if((int)childs->number_ == 1) { - client->forward = 1; - } else { - client->forward = 0; - } - } else { - error = 1; - break; - } - childs = childs->next; - } - } - if(exists == 0) { - if(error == -1) { - FREE(client); - } else { - tmp_clients = clients; - if(tmp_clients) { - while(tmp_clients->next != NULL) { - tmp_clients = tmp_clients->next; - } - tmp_clients->next = client; - } else { - client->next = clients; - clients = client; - } - socket_write(sd, "{\"status\":\"success\"}"); - json_delete(json); - return NULL; - } - } - json_delete(json); - return NULL; - /* - * Parse received codes from nodes - */ - } else if(strcmp(action, "update") == 0) { - if(exists == 1) { - struct JsonNode *jvalues = NULL; - char *pname = NULL; - if((jvalues = json_find_member(json, "values")) != NULL) { - exists = 0; - tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->id == sd) { - exists = 1; - client = tmp_clients; - break; - } - tmp_clients = tmp_clients->next; - } - if(exists == 1) { - json_find_number(jvalues, "cpu", &client->cpu); - } - } - if(json_find_string(json, "protocol", &pname) == 0) { - char *out = MALLOC(strlen(data->buffer)+1); - if(out == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(out, data->buffer); - eventpool_trigger(REASON_FORWARD, reason_forward_free, out); - json_delete(json); - return NULL; - } - } - json_delete(json); - return NULL; - } else if((json_find_string(json, "status", &status)) == 0) { - tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->id == sd) { - exists = 1; - client = tmp_clients; - break; - } - tmp_clients = tmp_clients->next; - } - if(strcmp(status, "success") == 0) { - logprintf(LOG_DEBUG, "client \"%s\" successfully executed our latest request", client->uuid); - json_delete(json); - return NULL; - } else if(strcmp(status, "failed") == 0) { - logprintf(LOG_DEBUG, "client \"%s\" failed executing our latest request", client->uuid); - json_delete(json); - return NULL; - } - - json_delete(json); - return NULL; - } - } - } - - if(socket_parse_responses(data->buffer, media, &respons) == 0) { - struct reason_socket_send_t *data1 = MALLOC(sizeof(struct reason_socket_send_t)); - if(data1 == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - data1->fd = sd; - if((data1->buffer = MALLOC(strlen(respons)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/; - } - strcpy(data1->buffer, respons); - strncpy(data1->type, data->type, 255); - - eventpool_trigger(REASON_SOCKET_SEND, reason_socket_send_free, data1); - - FREE(respons); - json_delete(json); - return NULL; - } else { - logprintf(LOG_ERR, "could not parse response to: %s", data->buffer); - client_remove(sd); - socket_close(sd); - json_delete(json); - return NULL; - } - json_delete(json); - return NULL; -} -/* Rewrite code end */ - -static void socket_client_disconnected(int i) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - client_remove(socket_get_clients(i)); -} - -void *receivePulseTrain(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct rawcode_t r; - r.length = 0; - int plslen = 0; -#ifdef _WIN32 - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); -#else - /* Make sure the pilight receiving gets - the highest priority available */ - struct sched_param sched; - memset(&sched, 0, sizeof(sched)); - sched.sched_priority = 70; - pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched); -#endif - - struct hardware_t *hw = (hardware_t *)param; - pthread_mutex_lock(&hw->lock); - hw->running = 1; - - while(main_loop == 1 && hw->receivePulseTrain != NULL && hw->stop == 0) { - if(hw->wait == 0) { - pthread_mutex_lock(&hw->lock); - logprintf(LOG_STACK, "%s::unlocked", __FUNCTION__); - - hw->receivePulseTrain(&r); - plslen = r.pulses[r.length-1]/PULSE_DIV; - if(r.length > 0) { - receive_queue(r.pulses, r.length, plslen, hw->hwtype); - } else if(r.length == -1) { - hw->init(); - sleep(1); - } - - pthread_mutex_unlock(&hw->lock); - } else { - pthread_cond_wait(&hw->signal, &hw->lock); - } - } - hw->running = 0; - return (void *)NULL; -} - -#ifdef PILIGHT_DEVELOPMENT -// void *receiveOOK(void *param) { - // logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - // struct rawcode_t r; - // r.length = 0; - // int plslen = 0, duration = 0; - // struct timeval tp; - // struct timespec ts; - -// #ifdef _WIN32 - // SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); -// #else - // /* Make sure the pilight receiving gets - // the highest priority available */ - // struct sched_param sched; - // memset(&sched, 0, sizeof(sched)); - // sched.sched_priority = 70; - // pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched); -// #endif - - // struct hardware_t *hw = (hardware_t *)param; - // pthread_mutex_lock(&hw->lock); - // hw->running = 1; - - // while(main_loop == 1 && hw->receiveOOK != NULL && hw->stop == 0) { - // if(hw->wait == 0) { - // pthread_mutex_lock(&hw->lock); - // logprintf(LOG_STACK, "%s::unlocked", __FUNCTION__); - // duration = hw->receiveOOK(); - // if(duration > 0) { - // r.pulses[r.length++] = duration; - // if(r.length > MAXPULSESTREAMLENGTH-1) { - // r.length = 0; - // } - // if(duration > hw->mingaplen) { - // if(duration < hw->maxgaplen) { - // plslen = duration/PULSE_DIV; - // } - // /* Let's do a little filtering here as well */ - // if(r.length >= hw->minrawlen && r.length <= hw->maxrawlen) { - // receive_queue(r.pulses, r.length, plslen, hw->hwtype); - // } - // r.length = 0; - // } - // /* Hardware failure */ - // } else if(duration == -1) { - // pthread_mutex_unlock(&hw->lock); - // gettimeofday(&tp, NULL); - // ts.tv_sec = tp.tv_sec; - // ts.tv_nsec = tp.tv_usec * 1000; - // ts.tv_sec += 1; - // pthread_mutex_lock(&hw->lock); - // pthread_cond_timedwait(&hw->signal, &hw->lock, &ts); - // } - // pthread_mutex_unlock(&hw->lock); - // } else { - // pthread_cond_wait(&hw->signal, &hw->lock); - // } - // } - // hw->running = 0; - // return (void *)NULL; -// } -#endif - -static void *receivePulseTrain1(int reason, void *param) { - struct reason_received_pulsetrain_t *data = param; - int plslen = 0; - - if(data->hardware != NULL && data->pulses != NULL && data->length > 0) { -#ifndef PILIGHT_REWRITE - int hwtype = 0; - struct conf_hardware_t *tmp_confhw = conf_hardware; - while(tmp_confhw) { - if(strcmp(tmp_confhw->hardware->id, data->hardware) == 0) { - hwtype = tmp_confhw->hardware->hwtype; - } - tmp_confhw = tmp_confhw->next; - } -#endif -#ifdef PILIGHT_REWRITE - struct hardware_t *hw = NULL; - if(hardware_select_struct(ORIGIN_MASTER, data->hardware, &hw) == 0) { -#endif - plslen = data->pulses[data->length-1]/PULSE_DIV; - if(data->length > 0) { -#ifdef PILIGHT_REWRITE - receive_parse_code(data->pulses, data->length, plslen, hw->hwtype); -#else - receive_queue(data->pulses, data->length, plslen, hwtype); -#endif - } -#ifdef PILIGHT_REWRITE - } -#endif - } - - return (void *)NULL; -} - -void *clientize(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - adhoc_pending = 1; - struct ssdp_list_t *ssdp_list = NULL; - struct JsonNode *json = NULL; - struct JsonNode *joptions = NULL; - struct JsonNode *jchilds = NULL; - struct JsonNode *tmp = NULL; - char *recvBuff = NULL, *output = NULL; - char *message = NULL, *action = NULL; - char *origin = NULL, *protocol = NULL; - int client_loop = 0, config_synced = 0; - - while(main_loop) { - - if(client_loop == 1) { - logprintf(LOG_NOTICE, "connection to main pilight daemon lost"); - logprintf(LOG_NOTICE, "trying to reconnect..."); - sleep(1); - } - - client_loop = 1; - config_synced = 0; - - ssdp_list = NULL; - if(master_server != NULL && master_port > 0) { - if((sockfd = socket_connect(master_server, master_port)) == -1) { - logprintf(LOG_ERR, "could not connect to pilight-daemon"); - continue; - } - } else if(ssdp_seek(&ssdp_list) == -1) { - logprintf(LOG_NOTICE, "no pilight ssdp connections found"); - continue; - } else { - if((sockfd = socket_connect(ssdp_list->ip, ssdp_list->port)) == -1) { - logprintf(LOG_ERR, "could not connect to pilight-daemon"); - continue; - } - } - if(ssdp_list) { - ssdp_free(ssdp_list); - } - - json = json_mkobject(); - joptions = json_mkobject(); - json_append_member(json, "action", json_mkstring("identify")); - json_append_member(joptions, "receiver", json_mknumber(1, 0)); - json_append_member(joptions, "forward", json_mknumber(1, 0)); - json_append_member(joptions, "config", json_mknumber(1, 0)); - json_append_member(json, "uuid", json_mkstring(pilight_uuid)); - json_append_member(json, "options", joptions); - output = json_stringify(json, NULL); - if(socket_write(sockfd, output) != (strlen(output)+strlen(EOSS))) { - json_free(output); - json_delete(json); - continue; - } - json_free(output); - json_delete(json); - - if(socket_read(sockfd, &recvBuff, 1) != 0 - || strcmp(recvBuff, "{\"status\":\"success\"}") != 0) { - continue; - } - logprintf(LOG_DEBUG, "socket recv: %s", recvBuff); - - json = json_mkobject(); - json_append_member(json, "action", json_mkstring("request config")); - output = json_stringify(json, NULL); - if(socket_write(sockfd, output) != (strlen(output)+strlen(EOSS))) { - json_free(output); - json_delete(json); - continue; - } - json_free(output); - json_delete(json); - - if(socket_read(sockfd, &recvBuff, 0) == 0) { - logprintf(LOG_DEBUG, "socket recv: %s", recvBuff); - if(json_validate(recvBuff) == true) { - json = json_decode(recvBuff); - if(json_find_string(json, "message", &message) == 0) { - if(strcmp(message, "config") == 0) { - struct JsonNode *jconfig = NULL; - if((jconfig = json_find_member(json, "config")) != NULL) { - - pthread_mutex_lock(&config_lock); - gui_gc(); - devices_gc(); -#ifdef EVENTS - rules_gc(); -#endif - registry_gc(); - pthread_mutex_unlock(&config_lock); - - int match = 1; - while(match) { - jchilds = json_first_child(jconfig); - match = 0; - while(jchilds) { - tmp = jchilds; - if(strcmp(tmp->key, "devices") != 0) { - json_remove_from_parent(tmp); - match = 1; - } - jchilds = jchilds->next; - if(match == 1) { - json_delete(tmp); - } - } - } - if(config_parse(jconfig) == EXIT_SUCCESS) { - logprintf(LOG_DEBUG, "loaded master configuration"); - config_synced = 1; - } else { - logprintf(LOG_WARNING, "failed to load master configuration"); - } - } - } - } - json_delete(json); - } - } - - while(client_loop && config_synced) { - if(sockfd <= 0) { - break; - } - if(main_loop == 0) { - client_loop = 0; - break; - } - - int n = socket_read(sockfd, &recvBuff, 1); - if(n == -1) { - sockfd = 0; - break; - } else if(n == 1) { - continue; - } - - logprintf(LOG_DEBUG, "socket recv: %s", recvBuff); - char **array = NULL; - unsigned int z = explode(recvBuff, "\n", &array), q = 0; - for(q=0;qnext; - FREE(tmp_clients); - } - if(clients != NULL) { - FREE(clients); - } - -#ifndef _WIN32 - if(running == 0) { - /* Remove the stale pid file */ - if(access(pid_file, F_OK) != -1) { - if(remove(pid_file) != -1) { - logprintf(LOG_INFO, "removed stale pid_file %s", pid_file); - } else { - logprintf(LOG_ERR, "could not remove stale pid file %s", pid_file); - } - } - } - - if(pid_file_free) { - FREE(pid_file); - } -#endif - eventpool_gc(); -#ifdef WEBSERVER - if(webserver_enable == 1) { - webserver_gc(); - } - if(webserver_root_free == 1) { - FREE(webserver_root); - } -#endif - - if(master_server != NULL) { - FREE(master_server); - } - - datetime_gc(); - ssdp_gc(); - options_gc(); - socket_gc(); - - pthread_mutex_lock(&config_lock); - config_gc(); - pthread_mutex_unlock(&config_lock); - - protocol_gc(); - ntp_gc(); - whitelist_free(); - threads_gc(); -#ifndef _WIN32 - wiringXGC(); -#endif - dso_gc(); - log_gc(); - ssl_gc(); - plua_gc(); - if(configtmp != NULL) { - FREE(configtmp); - } - - uv_stop(uv_default_loop()); - gc_clear(); - FREE(progname); - xfree(); - -#ifdef _WIN32 - WSACleanup(); - if(console == 1) { - FreeConsole(); - } -#endif - - FREE(signal_req); - - return 0; -} - -static void procProtocolInit(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - protocol_register(&procProtocol); - protocol_set_id(procProtocol, "process"); - protocol_device_add(procProtocol, "process", "pilight proc. API"); - procProtocol->devtype = PROCESS; - procProtocol->hwtype = API; - procProtocol->multipleId = 0; - procProtocol->config = 0; - - options_add(&procProtocol->options, 'c', "cpu", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&procProtocol->options, 'r', "ram", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); -} - -#ifndef _WIN32 -#pragma GCC diagnostic push // require GCC 4.6 -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -void registerVersion(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - registry_remove_value("pilight.version"); - registry_set_string("pilight.version.current", (char *)PILIGHT_VERSION); -} -#ifndef _WIN32 -#pragma GCC diagnostic pop // require GCC 4.6 -#endif - -#ifdef _WIN32 -void closeconsole(void) { - log_shell_disable(); - verbosity = oldverbosity; - FreeConsole(); - console = 0; -} - -BOOL CtrlHandler(DWORD fdwCtrlType) { - closeconsole(); - return TRUE; -} - -void openconsole(void) { - DWORD lpMode; - AllocConsole(); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - HWND hWnd = GetConsoleWindow(); - if(hWnd != NULL) { - GetConsoleMode(hWnd, &lpMode); - SetConsoleMode(hWnd, lpMode & ~ENABLE_PROCESSED_INPUT); - SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); - HMENU hMenu = GetSystemMenu(hWnd, FALSE); - if(hMenu != NULL) { - RemoveMenu(hMenu, SC_CLOSE, MF_GRAYED); - RemoveMenu(hMenu, SC_MINIMIZE, MF_GRAYED); - RemoveMenu(hMenu, SC_MAXIMIZE, MF_GRAYED); - } - - console = 1; - oldverbosity = verbosity; - verbosity = LOG_DEBUG; - log_level_set(verbosity); - log_shell_enable(); - } -} -#endif - -static void pilight_abort(uv_timer_t *timer_req) { - exit(EXIT_FAILURE); -} - -static void pilight_stats(uv_timer_t *timer_req) { - int watchdog = 1, stats = 1; - // double itmp = 0.0; - settings_find_number("watchdog-enable", &watchdog); - settings_find_number("stats-enable", &stats); - - if(pilight.runmode == STANDALONE) { - registerVersion(); - } - - if(stats == 1) { - double cpu = 0.0; - cpu = getCPUUsage(); - if(watchdog == 1 && (cpu > 90)) { - logprintf(LOG_CRIT, "cpu usage too high %f%%, will abort when this persists", cpu); - } else { - if(watchdog == 1 && stats == 1 && timer_abort_req != NULL) { - uv_timer_stop(timer_abort_req); - uv_timer_start(timer_abort_req, pilight_abort, 9000, -1); - } - - procProtocol->message = json_mkobject(); - struct JsonNode *code = json_mkobject(); - json_append_member(code, "cpu", json_mknumber(cpu, 16)); - logprintf(LOG_DEBUG, "cpu: %f%%", cpu); - json_append_member(procProtocol->message, "values", code); - json_append_member(procProtocol->message, "origin", json_mkstring("core")); - json_append_member(procProtocol->message, "type", json_mknumber(PROCESS, 0)); - struct clients_t *tmp_clients = clients; - while(tmp_clients) { - if(tmp_clients->cpu > 0 && tmp_clients->ram > 0) { - logprintf(LOG_DEBUG, "- client: %s cpu: %f%%", - tmp_clients->uuid, tmp_clients->cpu); - } - tmp_clients = tmp_clients->next; - } - pilight.broadcast(procProtocol->id, procProtocol->message, STATS); - json_delete(procProtocol->message); - procProtocol->message = NULL; - } - } - return; -} - -static void signal_cb(uv_signal_t *handle, int signum) { - logprintf(LOG_INFO, "Interrupt signal received. Please wait while pilight is shutting down"); - - if(config_get_file() != NULL) { - if(pilight.runmode == STANDALONE) { - config_write(1, "all"); - } - } - - main_gc(); - uv_stop(uv_default_loop()); -} - -int start_pilight(int argc, char **argv) { - const uv_thread_t pth_cur_id = uv_thread_self(); - memcpy((void *)&pth_main_id, &pth_cur_id, sizeof(uv_thread_t)); - - struct options_t *options = NULL; - struct ssdp_list_t *ssdp_list = NULL; - - char buffer[BUFFER_SIZE]; - int verbosity_changed = 0, show_default = 0, show_version = 0, show_help = 0; -#ifndef _WIN32 - int f = 0; -#endif - char *stmp = NULL, *args = NULL, *p = NULL; - int port = 0; - - if((progname = MALLOC(16)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(progname, "pilight-daemon"); - - { - int nr = sizeof(signals)/sizeof(signals[0]), i = 0; - if((signal_req = MALLOC(sizeof(uv_signal_t *)*nr)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - for(i=0;i 0) { - for(x=0;xhardware->init) { - if(tmp_confhw->hardware->comtype == COMOOK) { - struct protocols_t *tmp = protocols; - while(tmp) { - if(tmp->listener->hwtype == tmp_confhw->hardware->hwtype) { - if(tmp->listener->maxrawlen > tmp_confhw->hardware->maxrawlen) { - tmp_confhw->hardware->maxrawlen = tmp->listener->maxrawlen; - } - if(tmp->listener->minrawlen > 0 && tmp->listener->minrawlen < tmp_confhw->hardware->minrawlen) { - tmp_confhw->hardware->minrawlen = tmp->listener->minrawlen; - } - if(tmp->listener->maxgaplen > tmp_confhw->hardware->maxgaplen) { - tmp_confhw->hardware->maxgaplen = tmp->listener->maxgaplen; - } - if(tmp->listener->mingaplen > 0 && tmp->listener->mingaplen < tmp_confhw->hardware->mingaplen) { - tmp_confhw->hardware->mingaplen = tmp->listener->mingaplen; - } - if(tmp->listener->rawlen > 0) { - logprintf(LOG_EMERG, "%s: setting \"rawlen\" length is not allowed, use the \"minrawlen\" and \"maxrawlen\" instead", tmp->listener->id); - goto clear; - } - } - tmp = tmp->next; - } - } - } - tmp_confhw = tmp_confhw->next; - } - - settings_find_number("port", &port); - settings_find_number("standalone", &standalone); - - pilight.runmode = STANDALONE; - if(standalone == 0 || (master_server != NULL && master_port > 0)) { - if(master_server != NULL && master_port > 0) { - if((sockfd = socket_connect(master_server, master_port)) == -1) { - logprintf(LOG_NOTICE, "pilight daemon not found @%s, waiting for it to come online", master_server); - } else { - logprintf(LOG_INFO, "a pilight daemon was found, clientizing"); - } - pilight.runmode = ADHOC; - } else if(ssdp_seek(&ssdp_list) == -1) { - logprintf(LOG_INFO, "no pilight daemon found, daemonizing"); - } else { - logprintf(LOG_NOTICE, "a pilight daemon was found @%s, clientizing", ssdp_list->ip); - pilight.runmode = ADHOC; - } - if(ssdp_list) { - ssdp_free(ssdp_list); - } - } - - ssl_init(); - if(pilight.runmode == STANDALONE) { - socket_start((unsigned short)port); - if(standalone == 0) { - ssdp_start(); - } - } - -#ifndef _WIN32 - if(nodaemon == 0) { - daemonize(); - } else { - save_pid(getpid()); - } -#endif - - pilight.running = 1; - - /* Threads are unable to survive forks properly. - * Therefor, we queue all messages until we're - * able to fork properly. - */ - threads_create(&logpth, NULL, &logloop, (void *)NULL); - - pthread_mutexattr_init(&sendqueue_attr); - pthread_mutexattr_settype(&sendqueue_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&sendqueue_lock, &sendqueue_attr); - pthread_cond_init(&sendqueue_signal, NULL); - sendqueue_init = 1; - - pthread_mutexattr_init(&config_attr); - pthread_mutexattr_settype(&config_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&config_lock, &config_attr); - - pthread_mutexattr_init(&recvqueue_attr); - pthread_mutexattr_settype(&recvqueue_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&recvqueue_lock, &recvqueue_attr); - pthread_cond_init(&recvqueue_signal, NULL); - recvqueue_init = 1; - - pthread_mutexattr_init(&bcqueue_attr); - pthread_mutexattr_settype(&bcqueue_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&bcqueue_lock, &bcqueue_attr); - pthread_cond_init(&bcqueue_signal, NULL); - bcqueue_init = 1; - - /* Run certain daemon functions from the socket library */ - socket_callback.client_disconnected_callback = &socket_client_disconnected; - socket_callback.client_connected_callback = NULL; - socket_callback.client_data_callback = &socket_parse_data; - - /* Start threads library that keeps track of all threads used */ - threads_start(); - - /* The daemon running in client mode, register a seperate thread that - communicates with the server */ - if(pilight.runmode == ADHOC) { - threads_register("node", &clientize, (void *)NULL, 0); - } else { - /* Register a seperate thread for the socket server */ - threads_register("socket", &socket_wait, (void *)&socket_callback, 0); - if(standalone == 0) { - threads_register("ssdp", &ssdp_wait, (void *)NULL, 0); - } - } - threads_register("sender", &send_code, (void *)NULL, 0); - threads_register("broadcaster", &broadcast, (void *)NULL, 0); - - tmp_confhw = conf_hardware; - while(tmp_confhw && main_loop) { - if(tmp_confhw->hardware->init) { - if(tmp_confhw->hardware->init() == EXIT_FAILURE) { - if(main_loop == 1) { - logprintf(LOG_ERR, "could not initialize %s hardware module", tmp_confhw->hardware->id); - goto clear; - } else { - break; - } - } - if(main_loop == 1) { - tmp_confhw->hardware->wait = 0; - tmp_confhw->hardware->stop = 0; - if(tmp_confhw->hardware->comtype == COMOOK) { -#ifdef PILIGHT_DEVELOPMENT - // threads_register(tmp_confhw->hardware->id, &receiveOOK, (void *)tmp_confhw->hardware, 0); -#endif - } else if(tmp_confhw->hardware->comtype == COMPLSTRAIN) { - threads_register(tmp_confhw->hardware->id, &receivePulseTrain, (void *)tmp_confhw->hardware, 0); - } else if(tmp_confhw->hardware->comtype == COMAPI) { - threads_register(tmp_confhw->hardware->id, tmp_confhw->hardware->receiveAPI, (void *)tmp_confhw->hardware, 0); - } - } else { - break; - } - } - if(main_loop == 0) { - break; - } - tmp_confhw = tmp_confhw->next; - } - if(main_loop == 0) { - goto clear; - } - - threads_register("receive parser", &receive_parse_code, (void *)NULL, 0); - -#ifdef EVENTS - if(pilight.runmode == STANDALONE) { - /* Register a seperate thread in which the daemon communicates the events library */ - threads_register("events client", &events_clientize, (void *)NULL, 0); - threads_register("events loop", &events_loop, (void *)NULL, 0); - } -#endif - -#ifdef WEBSERVER - settings_find_number("webgui-websockets", &webgui_websockets); - - /* Register a seperate thread for the webserver */ - if(webserver_enable == 1 && pilight.runmode == STANDALONE) { - /* Register a seperate thread in which the webserver communicates the main daemon */ -#ifdef PILIGHT_DEVELOPMENT - if(webgui_websockets == 1) { - threads_register("webserver broadcast", &webserver_broadcast, (void *)NULL, 0); - } -#endif - } else { - webserver_enable = 0; - } -#ifndef PILIGHT_DEVELOPMENT - if(webserver_enable == 1) { - webserver_start(); - } -#endif -#endif - - { - char name[25], *server = NULL; - unsigned int nrservers = 0; - while(1) { - sprintf(name, "ntpserver%d", nrservers); - if(settings_find_string(name, &server) == 0) { - strcpy(ntp_servers.server[nrservers].host, server); - ntp_servers.server[x].port = 123; - nrservers++; - } else { - break; - } - } - ntp_servers.nrservers = nrservers; - ntp_servers.callback = NULL; - if(nrservers > 0) { - ntpsync(); - } - } - -// #ifdef _WIN32 - // threads_register("stats", &pilight_stats, NULL, 0); -// #endif - - timer_stats_req = MALLOC(sizeof(uv_timer_t)); - if(timer_stats_req == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - uv_timer_init(uv_default_loop(), timer_stats_req); - uv_timer_start(timer_stats_req, pilight_stats, 1000, 3000); - return EXIT_SUCCESS; - -clear: - if(nodaemon == 0) { - log_level_set(LOG_NOTICE); - log_shell_disable(); - } - if(main_loop == 1) { - main_gc(); - } - uv_stop(uv_default_loop()); - return EXIT_FAILURE; -} - -#ifdef _WIN32 -#define ID_TRAYICON 100 -#define ID_QUIT 101 -#define ID_SEPARATOR 102 -#define ID_INSTALL_SERVICE 103 -#define ID_REMOVE_SERVICE 104 -#define ID_START 105 -#define ID_STOP 106 -#define ID_WEBGUI 107 -#define ID_CONSOLE 108 -#define ID_ICON 200 -static NOTIFYICONDATA TrayIcon; - -static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - char buf[200], *service_argv[] = {__argv[0], NULL}; - POINT pt; - HMENU hMenu; - - switch(msg) { - case WM_CREATE: - if(start_pilight(__argc, __argv) == EXIT_FAILURE) { - if(main_loop == 1) { - main_gc(); - } - exit(EXIT_FAILURE); - } - running = 1; - break; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case ID_QUIT: - if(main_loop == 1) { - main_gc(); - } - Shell_NotifyIcon(NIM_DELETE, &TrayIcon); - PostQuitMessage(0); - break; - case ID_STOP: - if(running == 1) { - if(main_loop == 1) { - main_gc(); - } - running = 0; - MessageBox(NULL, "pilight stopped", "pilight :: notice", MB_OK); - } - break; - case ID_CONSOLE: - if(console == 0) { - openconsole(); - } else { - closeconsole(); - } - break; - case ID_START: - if(running == 0) { - main_loop = 1; - if(start_pilight(1, service_argv) == EXIT_FAILURE) { - if(main_loop == 1) { - main_gc(); - MessageBox(NULL, "pilight failed to start", "pilight :: error", MB_OK); - } - } - running = 1; - MessageBox(NULL, "pilight started", "pilight :: notice", MB_OK); - } - break; - case ID_WEBGUI: - if(webserver_http_port == 80) { - snprintf(buf, sizeof(buf), "http://localhost"); - } else { - snprintf(buf, sizeof(buf), "http://localhost:%d", webserver_http_port); - } - ShellExecute(NULL, "open", buf, NULL, NULL, SW_SHOWNORMAL); - break; - } - break; - case WM_USER: - switch(lParam) { - case WM_RBUTTONUP: - case WM_LBUTTONUP: - case WM_LBUTTONDBLCLK: - hMenu = CreatePopupMenu(); - - AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, server_name); - AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); - AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, ((pilight.runmode == ADHOC) ? "Ad-Hoc mode" : "Standalone mode")); - AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); - if(pilight.runmode == STANDALONE) { - AppendMenu(hMenu, MF_STRING | (running ? 0 : MF_GRAYED), ID_WEBGUI, "Open webGUI"); - } - if(console == 0) { - AppendMenu(hMenu, MF_STRING, ID_CONSOLE, "Open console"); - } else { - AppendMenu(hMenu, MF_STRING, ID_CONSOLE, "Close console"); - } - AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); - - // snprintf(buf, sizeof(buf), "pilight is %s", running ? "running" : "stopped"); - - // AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, buf); - // AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); - - // AppendMenu(hMenu, MF_STRING | (running ? 0 : MF_GRAYED), ID_STOP, "Stop pilight"); - // AppendMenu(hMenu, MF_STRING | (running ? MF_GRAYED : 0), ID_START, "Start pilight"); - - AppendMenu(hMenu, MF_STRING, ID_QUIT, "Exit"); - - GetCursorPos(&pt); - SetForegroundWindow(hWnd); - TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL); - PostMessage(hWnd, WM_NULL, 0, 0); - DestroyMenu(hMenu); - break; - } - break; - } - - return DefWindowProc(hWnd, msg, wParam, lParam); -} - -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) { - pilight.running = 0; - pilight.debuglevel = 0; - - HWND hWnd; - WNDCLASS cls; - MSG msg; -#ifdef HASH - snprintf(server_name, sizeof(server_name), "pilight-daemon %s", HASH); -#else - snprintf(server_name, sizeof(server_name), "pilight-daemon %s", PILIGHT_VERSION); -#endif - memset(&cls, 0, sizeof(cls)); - cls.lpfnWndProc = (WNDPROC)WindowProc; - cls.hIcon = LoadIcon(NULL, IDI_APPLICATION); - cls.lpszClassName = server_name; - - RegisterClass(&cls); - hWnd = CreateWindow(cls.lpszClassName, server_name, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); - ShowWindow(hWnd, SW_HIDE); - - TrayIcon.cbSize = sizeof(TrayIcon); - TrayIcon.uID = ID_TRAYICON; - TrayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; - TrayIcon.hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON), IMAGE_ICON, 16, 16, 0); - TrayIcon.hWnd = hWnd; - snprintf(TrayIcon.szTip, sizeof(TrayIcon.szTip), "%s", server_name); - - TrayIcon.uCallbackMessage = WM_USER; - Shell_NotifyIcon(NIM_ADD, &TrayIcon); - - while(GetMessage(&msg, hWnd, 0, 0) && main_loop == 1) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return 0; -} -#else -int main(int argc, char **argv) { - pilight.running = 0; - pilight.debuglevel = 0; - - int ret = start_pilight(argc, argv); - if(ret == EXIT_SUCCESS) { - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - uv_walk(uv_default_loop(), walk_cb, NULL); - uv_run(uv_default_loop(), UV_RUN_ONCE); - - while(uv_loop_close(uv_default_loop()) == UV_EBUSY) { - uv_run(uv_default_loop(), UV_RUN_ONCE); - } - // pilight_stats((void *)NULL); - } - return ret; -} -#endif diff --git a/lib/ESPiLight/pilight/debug.c b/lib/ESPiLight/pilight/debug.c deleted file mode 100644 index f13fd8e..0000000 --- a/lib/ESPiLight/pilight/debug.c +++ /dev/null @@ -1,608 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 -#include -#endif - -#include "libs/pilight/core/threads.h" -#include "libs/pilight/core/pilight.h" -#include "libs/pilight/core/network.h" -#include "libs/pilight/core/config.h" -#include "libs/pilight/core/log.h" -#include "libs/pilight/core/options.h" -#include "libs/pilight/core/threads.h" -#include "libs/pilight/core/datetime.h" -#include "libs/pilight/core/ssdp.h" -#include "libs/pilight/core/socket.h" -#include "libs/pilight/core/gc.h" -#include "libs/pilight/core/dso.h" - -#include "libs/pilight/events/events.h" - -#include "libs/pilight/config/hardware.h" - -static unsigned short main_loop = 1; -static unsigned short inner_loop = 1; - -#ifndef PILIGHT_DEVELOPMENT -static uv_signal_t *signal_req = NULL; -static int doSkip = 0; -#endif - -static int normalize(int i, int pulselen) { - double x; - x=(double)i/pulselen; - - return (int)(round(x)); -} - -int main_gc(void) { - log_shell_disable(); - main_loop = 0; - inner_loop = 0; - - datetime_gc(); - ssdp_gc(); -#ifdef EVENTS - events_gc(); -#endif - options_gc(); - socket_gc(); - -#ifndef PILIGHT_DEVELOPMENT - eventpool_gc(); -#endif - config_gc(); - protocol_gc(); - whitelist_free(); - threads_gc(); - -#ifndef _WIN32 - wiringXGC(); -#endif - dso_gc(); - log_gc(); - gc_clear(); - - FREE(progname); - xfree(); - - return EXIT_SUCCESS; -} - -void *receivePulseTrain(void *param) { - int i = 0; - - int pulselen = 0; - int pulse = 0; - - struct rawcode_t r; - struct tm tm; - time_t now = 0; - - struct hardware_t *hw = (hardware_t *)param; - - while(main_loop) { - memset(&r.pulses, 0, sizeof(r.pulses)); - memset(&tm, '\0', sizeof(struct tm)); - pulse = 0; - inner_loop = 1; - - i = 0; - time(&now); - - hw->receivePulseTrain(&r); - if(r.length == -1) { - main_gc(); - break; - } else if(r.length > 0) { - pulselen = r.pulses[r.length-1]/PULSE_DIV; - - if(pulselen > 25) { - for(i=3;i= 2) { - pulse=r.pulses[i]; - break; - } - } - - if(normalize(pulse, pulselen) > 0 && r.length > 25) { - /* Print everything */ - printf("--[RESULTS]--\n"); - printf("\n"); -#ifdef _WIN32 - localtime(&now); -#else - localtime_r(&now, &tm); -#endif - -#ifdef _WIN32 - printf("time:\t\t%s\n", asctime(&tm)); -#else - char buf[128]; - char *p = buf; - memset(&buf, '\0', sizeof(buf)); - asctime_r(&tm, p); - printf("time:\t\t%s", buf); -#endif - printf("hardware:\t%s\n", hw->id); - printf("pulse:\t\t%d\n", normalize(pulse, pulselen)); - printf("rawlen:\t\t%d\n", r.length); - printf("pulselen:\t%d\n", pulselen); - printf("\n"); - printf("Raw code:\n"); - for(i=0;ihardware != NULL && data->pulses != NULL && data->length > 0) { -#ifndef PILIGHT_REWRITE - char *id = NULL; - struct conf_hardware_t *tmp_confhw = conf_hardware; - while(tmp_confhw) { - if(strcmp(tmp_confhw->hardware->id, data->hardware) == 0) { - id = tmp_confhw->hardware->id; - } - tmp_confhw = tmp_confhw->next; - } -#else - if(hardware_select_struct(ORIGIN_MASTER, data->hardware, &hw) == 0) { -#endif - memset(&tm, '\0', sizeof(struct tm)); - pulse = 0; - inner_loop = 1; - - i = 0; - time(&now); - - if(data->length > 0) { - pulselen = data->pulses[data->length-1]/PULSE_DIV; - if(pulselen > 25) { - for(i=3;ilength;i++) { - if((data->pulses[i]/pulselen) >= 2) { - pulse=data->pulses[i]; - break; - } - } - - if(normalize(pulse, pulselen) > 0 && data->length > 25) { - /* Print everything */ - printf("--[RESULTS]--\n"); - printf("\n"); -#ifdef _WIN32 - memcpy(&tm, localtime(&now), sizeof(struct tm)); -#else - localtime_r(&now, &tm); -#endif - -#ifdef _WIN32 - printf("time:\t\t%s", asctime(&tm)); -#else - char buf[128]; - char *p = buf; - memset(&buf, '\0', sizeof(buf)); - #ifdef __sun - asctime_r(&tm, p, sizeof(buf)); - #else - asctime_r(&tm, p); - #endif - printf("time:\t\t%s", buf); -#endif -#ifdef PILIGHT_DEVELOPMENT - printf("hardware:\t%s\n", hw->id); -#else - printf("hardware:\t%s\n", id); -#endif - printf("pulse:\t\t%d\n", normalize(pulse, pulselen)); - printf("rawlen:\t\t%d\n", data->length); - printf("pulselen:\t%d\n", pulselen); - printf("\n"); - printf("Raw code:\n"); - for(i=0;ilength;i++) { - printf("%d ", data->pulses[i]); - } - printf("\n"); - } - } - } -#ifdef PILIGHT_DEVELOPMENT - } -#endif - } - return (void *)NULL; -} - -void *receiveOOK(void *param) { - int duration = 0; - int i = 0; - unsigned int y = 0; - - int recording = 1; - int pulselen = 0; - int bit = 0; - int raw[MAXPULSESTREAMLENGTH] = {0}; - int pRaw[MAXPULSESTREAMLENGTH] = {0}; - int footer = 0; - int pulse = 0; - int rawLength = 0; - int plsdec = 1; - - struct tm tm; - time_t now = 0, later = 0; - - struct hardware_t *hw = (hardware_t *)param; - - while(main_loop) { - memset(&raw, '\0', sizeof(raw)); - memset(&pRaw, '\0', sizeof(pRaw)); - memset(&tm, '\0', sizeof(struct tm)); - recording = 1; - bit = 0; - footer = 0; - pulse = 0; - rawLength = 0; - inner_loop = 1; - pulselen = 0; - - duration = 0; - i = 0; - y = 0; - time(&now); - - while(inner_loop == 1 && hw->receiveOOK != NULL) { - duration = hw->receiveOOK(); - time(&later); - if(difftime(later, now) > 1) { - inner_loop = 0; - } - /* If we are recording, keep recording until the next footer has been matched */ - if(recording == 1) { - if(bit < MAXPULSESTREAMLENGTH) { - raw[bit++] = duration; - } else { - bit = 0; - recording = 0; - } - } - - /* First try to catch code that seems to be a footer. - If a real footer has been recognized, start using that as the new footer */ - if((duration > 5100 && footer == 0) || ((footer-(footer*0.3)duration))) { - recording = 1; - pulselen = (int)duration/PULSE_DIV; - - /* Check if we are recording similar codes */ - for(i=0;i<(bit-1);i++) { - if(!(((pRaw[i]-(pRaw[i]*0.3)) < raw[i]) && ((pRaw[i]+(pRaw[i]*0.3)) > raw[i]))) { - y=0; - recording=0; - } - pRaw[i]=raw[i]; - } - y++; - - /* Continue if we have 2 matches */ - if(y>=1) { - /* If we are certain we are recording similar codes. Save the raw code length. */ - if(footer>0) { - if(rawLength == 0) - rawLength=bit; - } - - if(pulselen > 1000) { - plsdec = 10; - } - /* Try to catch the footer, and the low and high values */ - for(i=0;i 2 && footer > 0) { - if((raw[i]/(pulselen/plsdec)) >= 2) { - pulse=raw[i]; - } - } - if(duration > 5100) { - footer=raw[i]; - } - } - - /* If we have gathered all data, stop with the loop */ - if(footer > 0 && pulse > 0 && rawLength > 0) { - inner_loop = 0; - } - } - bit=0; - } - - fflush(stdout); - } - - if(normalize(pulse, (pulselen/plsdec)) > 0 && rawLength > 25) { - /* Print everything */ - printf("--[RESULTS]--\n"); - printf("\n"); -#ifdef _WIN32 - localtime(&now); -#else - localtime_r(&now, &tm); -#endif - -#ifdef _WIN32 - printf("time:\t\t%s\n", asctime(&tm)); -#else - char buf[128]; - char *p = buf; - memset(&buf, '\0', sizeof(buf)); - asctime_r(&tm, p); - printf("time:\t\t%s", buf); -#endif - printf("hardware:\t%s\n", hw->id); - printf("pulse:\t\t%d\n", normalize(pulse, (pulselen/plsdec))); - printf("rawlen:\t\t%d\n", rawLength); - printf("pulselen:\t%d\n", pulselen); - printf("\n"); - printf("Raw code:\n"); - for(i=0;ihardware->init) { - if(tmp_confhw->hardware->comtype == COMOOK) { - tmp_confhw->hardware->maxrawlen = MAXPULSESTREAMLENGTH; - tmp_confhw->hardware->minrawlen = 25; - tmp_confhw->hardware->maxgaplen = 34000; - tmp_confhw->hardware->mingaplen = 5100; - } - if(tmp_confhw->hardware->init() == EXIT_FAILURE) { - logprintf(LOG_ERR, "could not initialize %s hardware mode", tmp_confhw->hardware->id); - goto clear; - } - if(tmp_confhw->hardware->comtype == COMOOK) { -#ifdef PILIGHT_DEVELOPMENT - // threads_register(tmp_confhw->hardware->id, &receiveOOK, (void *)tmp_confhw->hardware, 0); -#endif - } else if(tmp_confhw->hardware->comtype == COMPLSTRAIN) { - threads_register(tmp_confhw->hardware->id, &receivePulseTrain, (void *)tmp_confhw->hardware, 0); - } - } - tmp_confhw = tmp_confhw->next; - } - - printf("Press and hold one of the buttons on your remote or wait until\n"); - printf("another device such as a weather station has sent new codes\n"); - printf("The debugger will automatically reset itself after one second of\n"); - printf("failed leads. It will keep running until you explicitly stop it.\n"); - printf("This is done by pressing both the [CTRL] and C buttons on your keyboard.\n"); - -#ifdef PILIGHT_DEVELOPMENT - while(main_loop) { - sleep(1); - } -#else - main_loop1(0); -#endif - -clear: -#ifdef PILIGHT_DEVELOPMENT - if(main_loop == 1) { - main_gc(); - } -#else - main_loop1(1); - main_gc(); -#endif - return (EXIT_FAILURE); -} diff --git a/lib/ESPiLight/pilight/docs/make.bat b/lib/ESPiLight/pilight/docs/make.bat deleted file mode 100644 index a5ceec0..0000000 --- a/lib/ESPiLight/pilight/docs/make.bat +++ /dev/null @@ -1,36 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build -set SPHINXPROJ=pilight - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd diff --git a/lib/ESPiLight/pilight/docs/source/.static/Roboto-Condensed.woff b/lib/ESPiLight/pilight/docs/source/.static/Roboto-Condensed.woff deleted file mode 100644 index 23198d5..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/.static/Roboto-Condensed.woff and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/.static/Roboto-Condensed.woff2 b/lib/ESPiLight/pilight/docs/source/.static/Roboto-Condensed.woff2 deleted file mode 100644 index b2726ed..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/.static/Roboto-Condensed.woff2 and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/.static/custom.css b/lib/ESPiLight/pilight/docs/source/.static/custom.css deleted file mode 100644 index d0375da..0000000 --- a/lib/ESPiLight/pilight/docs/source/.static/custom.css +++ /dev/null @@ -1,212 +0,0 @@ -body, -h1, h2, h3, -h4, h5, h6, -dt, dl, dd, -blockquote, -td, th, div, -ul, li, ol, -a, p, input, -table, table td, -div.sphinxsidebar .sidebar-toc a, -.sidebar-block h2, -.text-logo, -.admonition-title { - font-family:'Roboto Condensed', sans-serif; -} - -blockquote { - padding: 0px; -} - -.underline { - text-decoration: underline; -} - -h1 { - background-color: #fafafa; -} - -img { - display: block; - width: 100%; -} - -div.sphinxsidebar { - margin-top: 5px; - padding-top: 80px; - background: url('pilight.png') no-repeat top center; -} - -.text-logo { - opacity: 0; - height: 102px; - margin-top: -100px; -} - -blockquote { - background: transparent; - border: 0px; -} - -table.footnote * { - font-size: 12px; -} - -table.footnote .label { - color: #428bca; -} - -table.docutils:not(.footnote) { - border: 0px solid transparent; - min-width: 100%; - margin-bottom: 10px; - display: block; - overflow: auto; -} - -table.docutils:not(.footnote).alt { - display: table; -} - -table.docutils:not(.footnote) img { - display: inline-block; - width: auto; -} - -table.docutils:not(.footnote).alt img { - display: block; - width: 100%; -} - -table.docutils:not(.footnote) td { - border: 0px solid transparent; - white-space: nowrap; - padding: 5px; - vertical-align: middle; -} - -table.docutils:not(.footnote) tr.row-odd td { - background: #fbfbfb; -} - -table.docutils:not(.footnote) tr:first-child td { - background: #fafafa; - font-weight: 800; - border-bottom: 1px solid #aaaaaa; -} - -div[class^='highlight'] { - overflow-x: auto; - margin: 1px 0 24px 0 -} - -div[class^='highlight'] div[class^='highlight'] { - margin: 0; - padding: 0; -} - -table { - border-collapse: collapse; - margin: 0px; - padding: 0px; -} - -pre { - margin: 0px; - padding: 0px; - border: 0px; -} - -.highlighttable pre { - margin: -5px 0px 0px 0px; - padding: 0px; - border-left: 1px solid #eeeeee; -} - -.event-success, -.event-fail { - position: relative; - float: right; - font-size: 16px; - padding: 0px; - margin-top: -1px; - width: 60px; - display: block; -} - -.event-success { - color: green; -} - -.event-fail { - color: red; -} - -.text-logo { - background: #fafafa; -} - -.sidebar-toc ul li a:hover { - background-color: white; - color: red; -} - -.sidebar-toc ul li.current > a, -.sidebar-toc ul li.current > a:hover { - background-color: #ffcc00; - color: #fff; -} - -/* .sidebar-toc .toctree-l1.current > a, */ -/* .sidebar-toc .toctree-l1.current > a:hover { */ - /* background-color: #dedede; */ -/* } */ - -h1:hover > a.headerlink, -h2:hover > a.headerlink, -h3:hover > a.headerlink, -h4:hover > a.headerlink, -h5:hover > a.headerlink, -h6:hover > a.headerlink, -dt:hover > a.headerlink { - visibility: hidden; -} - -.footnote-reference { - vertical-align: super; - font-size: 10px; -} - -table.field-list { - display: none!important; -} - -.versionchanged { - border-bottom: 1px solid #ffcc00; -} - -.deprecated { - border-bottom: 1px solid #ff0000; -} - -.versionadded { - border-bottom: 1px solid #aaffaa; -} - -.versionchanged, -.versionmodified, -.versionadded, -.deprecated { - color: black; - margin-bottom: 15px; - margin-top: 15px; -} - -.versionmodified *, -.versionchanged *, -.versionadded *, -.deprecated * { - font-style: normal; - padding: 0px; - margin: 0px; -} \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/.static/custom.js b/lib/ESPiLight/pilight/docs/source/.static/custom.js deleted file mode 100644 index a8675f5..0000000 --- a/lib/ESPiLight/pilight/docs/source/.static/custom.js +++ /dev/null @@ -1,6 +0,0 @@ -$(document).ready(function() { - $('.toctree-l1.current:has(.toctree-l2.current) > a').css({ - background: '#bbbbbb', - color: 'white' - }); -}); \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/.static/font.min.css b/lib/ESPiLight/pilight/docs/source/.static/font.min.css deleted file mode 100644 index b547982..0000000 --- a/lib/ESPiLight/pilight/docs/source/.static/font.min.css +++ /dev/null @@ -1 +0,0 @@ -@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:300;src:local('Roboto Condensed Light'),local('RobotoCondensed-Light'),url(Roboto-Condensed.woff2) format('woff2'),url(Roboto-Condensed.woff) format('woff')} \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/about_manual.rst b/lib/ESPiLight/pilight/docs/source/about_manual.rst deleted file mode 100644 index 76b957f..0000000 --- a/lib/ESPiLight/pilight/docs/source/about_manual.rst +++ /dev/null @@ -1,11 +0,0 @@ -About manual -============ - -The pilight manual is a community driven project open for everyone to participate in. The goal is to provide a multi-lingual and professional software manual for each pilight release. All users are invited to add, edit, or replace content to their best effort. If you want to contribute then also add your name in the contributor list below. - -The pilight manual consists of various so called RestructuredText documents which can be found in the `pilight development repository `_. - -These individual documents are transformed using the `Sphinx toolset `_ into the pilight manual. - -| Contributors: -| CurlyMo, pilino1234, wo_rasp \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/adhoc_network.rst b/lib/ESPiLight/pilight/docs/source/adhoc_network.rst deleted file mode 100644 index ef072bc..0000000 --- a/lib/ESPiLight/pilight/docs/source/adhoc_network.rst +++ /dev/null @@ -1,322 +0,0 @@ -Adhoc Network -============= - -- `Introduction`_ -- `Network of Senders and Receivers`_ -- `Network of (Conflicting) Sensors and Relays`_ -- `Stable Mail Daemon`_ - -Introduction ------------- - -The probably least known but advanced feature of pilight is its adhoc network functionality. This basically means that you can create a big network of pilight instances (such as several Raspberry Pis and Windows or Linux computers) working together. A bit like the Borg from Star Trek. - -Consider the following, quite common, user case scenario. We have one Raspberry Pi running pilight with a sender and receiver connected. This single pilight instance controls our remote controlled lights and can retrieve weather information from our weather station and/or from e.g. openweathermap.org. This system has already been set up and works. - -Network of Senders and Receivers --------------------------------- - -.. only:: html - - .. |fig1h| image:: images/adhoc-network-nodeA+B.svg - .. |fig2h| image:: images/adhoc-network-nodeA+B.svg - - .. rst-class:: alt - - +-----------------+-----------------+ - | |fig1h| | |fig2h| | - +-----------------+-----------------+ - | Image 1: Node A | Image 1: Node B | - +-----------------+-----------------+ - -.. only:: latex - - .. |fig1l| image:: images/adhoc-network-nodeA+B.pdf - .. |fig2l| image:: images/adhoc-network-nodeA+B.pdf - - .. rst-class:: alt - - +-----------------+-----------------+ - | |fig1l| | |fig2l| | - +-----------------+-----------------+ - | Image 1: Node A | Image 1: Node B | - +-----------------+-----------------+ - -The biggest limitation of a home domotica set-up is its range. Of course we can tinker with antennas and such, but that does not always solve the problem. How then, can we reach those corners in our house that the single Raspberry Pi with pilight cannot reach? - -The solution is to create a network of senders and receivers all working together. That is exactly what pilight offers with the AdHoc network functionality. To be able to use this feature, we need (at least) two pilight capable computers. In this example we use two Raspberry Pis to control our devices; a lamp in our bookshelf ("bookshelf") on one side of the house and a lamp in the garden ("gardenlights") on the other side: - -.. code-block:: json - :linenos: - - { - "devices": { - "bookshelf": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 1 - }], - "state": "off" - }, - "gardenlights": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 2 - }], - "state": "off" - } - } - } - -Our settings for Node A will look like this: - -.. code-block:: json - :linenos: - - { - "settings": { - "log-level": 6, - "log-file": "/var/log/pilight-daemon.log", - "webserver-enable": 1, - "webserver-cache": 1, - "webserver-http-port": 5001, - "webserver-root": "/usr/local/share/pilight/", - "whitelist": "" - } - -Now, when we start pilight in debug mode in Node A, we can see this: - -.. code-block:: console - - [Jan 24 15:34:18:191682] pilight-daemon: DEBUG: ssdp sent search - [Jan 24 15:34:18:292486] pilight-daemon: NOTICE: no pilight daemon found, daemonizing - -pilight knows it is (currently) the only instance running inside the home network and will therefore start as a main daemon. However, we notice that we cannot control both our bookshelf lamp and the light in the garden with a single Raspberry Pi with pilight, because of the limited range of the sender and receiver. The solution is to add another Raspberry Pi with pilight on the other side of the house and to connect them to the home network. The settings of Node B will look like this: - -.. code-block:: json - :linenos: - - { - "settings": { - "log-level": 6, - "log-file": "/var/log/pilight-daemon.log", - "whitelist": "" - } - } - -As you can see here, we have removed the **webserver settings**, because a pilight node **will not have its webserver enabled**. Once we start Node B in debug mode, we can see the following: - -.. code-block:: console - - [Jan 24 15:40:44:334028] pilight-daemon: DEBUG: ssdp sent search - [Jan 24 15:40:44:434492] pilight-daemon: NOTICE: a pilight daemon was found @192.168.1.100, clientizing - -pilight has found the first daemon Node A and will connect to it. It will identify as a node and connect to it -(clientizing): - -.. code-block:: console - - [Jan 24 15:40:44:544657] pilight-daemon: DEBUG: socket write succeeded: {"action":"identify","options":{"receiver":1,"forward":1,"config":1},"uuid":"0363-00-00-63-000300"} - [Jan 24 15:40:44:547148] pilight-daemon: DEBUG: socket recv: {"status":"success"} - [Jan 24 15:40:44:547455] pilight-daemon: DEBUG: socket write succeeded: {"action":"request config"} - -The last important part is that Node B will request the configuration from Node A, so that all nodes work with the same configuration definition as the main daemon (Node A). Once a code is received on Node B, it will be synchronised with Node A and Node A will again synchronize it with Node C etc. Whenever you send a code (using a 433MHz remote or the webGUI) it will automatically arrive at Node A, because all clients will always connect to the main daemon. Node A will transfer send request (such as to control a socket) to all connected nodes. So not only Node A will send but also **all other nodes**. - -If the main daemon Node A crashes, the network is down. However, the other nodes will keep running until the main daemon is back up again. They will of course first clear the local configuration and resynchronize it with the daemon (because pilight cannot know what the new configuration will be): - -.. code-block:: console - - [Jan 24 15:45:37:250271] pilight-daemon: DEBUG: garbage collected config library - [Jan 24 15:45:37:250397] pilight-daemon: NOTICE: connection to main pilight daemon lost - [Jan 24 15:45:37:250691] pilight-daemon: NOTICE: trying to reconnect... - [Jan 24 15:45:40:250971] pilight-daemon: DEBUG: ssdp sent search - [Jan 24 15:45:40:350471] pilight-daemon: ERROR: no pilight ssdp connections found - [Jan 24 15:45:40:350758] pilight-daemon: DEBUG: garbage collected config library - [Jan 24 15:45:40:350835] pilight-daemon: NOTICE: connection to main pilight daemon lost - [Jan 24 15:45:40:350913] pilight-daemon: NOTICE: trying to reconnect... - -Once the main daemon is back online (which does not necessarily have to be Node A), all nodes will reconnect: - -.. code-block:: console - - [Jan 24 15:47:50:565899] pilight-daemon: NOTICE: trying to reconnect... - [Jan 24 15:47:53:566159] pilight-daemon: DEBUG: ssdp sent search - [Jan 24 15:40:44:544657] pilight-daemon: DEBUG: socket write succeeded: {"action":"identify","options":{"receiver":1,"forward":1,"config":1},"uuid":"0363-00-00-63-000300"} - [Jan 24 15:40:44:547148] pilight-daemon: DEBUG: socket recv: {"status":"success"} - [Jan 24 15:40:44:547455] pilight-daemon: DEBUG: socket write succeeded: {"action":"request config"} - -This means that when you want to update the configuration with new devices, you only have to restart the main daemon and all nodes will reconnect and resynchronize the new configuration file. This way we can control both the bookshelf lamps in front of our house and the backyard light at the back. - -pilight can also control various other devices like relays and read from sensors for temperature and/or humidity in the same network. We are going to continue on the previous example but add two additional pilight instances. - -Network of (Conflicting) Sensors and Relays -------------------------------------------- - -pilight can also control various other devices like relays and read from sensors for temperature and/or humidity in the *same network*. We are going to continue on the previous example but add two additional pilight instances. - -.. only:: html - - .. |fig3h| image:: images/adhoc-network-nodeC.svg - .. |fig4h| image:: images/adhoc-network-nodeD.svg - - .. rst-class:: alt - - +-----------------+-----------------+ - | |fig3h| | |fig4h| | - +-----------------+-----------------+ - | Image 1: Node C | Image 1: Node D | - +-----------------+-----------------+ - -.. only:: latex - - .. |fig3l| image:: images/adhoc-network-nodeC.pdf - .. |fig4l| image:: images/adhoc-network-nodeD.pdf - - .. rst-class:: alt - - +-----------------+-----------------+ - | |fig3l| | |fig4l| | - +-----------------+-----------------+ - | Image 1: Node C | Image 1: Node D | - +-----------------+-----------------+ - -Node C is meant to add additional coverage in the house to make sure we receive all signals, but it also has a relay connected. We are going to use this relay to turn our television set on and off. The new configuration file will look like this: - -.. code-block:: json - :linenos: - - { - "devices": { - "bookshelf": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 1 - }], - "state": "off" - }, - "television": { - "protocol": [ "relay" ], - "id": [{ - "gpio": 4 - }], - "state": "off" - }, - "gardenlights": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 2 - }], - "state": "off" - } - } - } - -Until now, we did not encounter any issues with our pilight AdHoc network. But what happens when we add another relay (also connected to GPIO 3, but on Node D) to control a heater? Our new configuration file will look like this: - -.. code-block:: json - :linenos: - - { - "devices": { - "heater": { - "protocol": [ "relay" ], - "id": [{ - "gpio": 4 - }], - "state": "off" - }, - "bookshelf": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 1 - }], - "state": "off" - }, - "television": { - "protocol": [ "relay" ], - "id": [{ - "gpio": 4 - }], - "state": "off" - }, - "gardenlights": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 2 - }], - "state": "off" - } - } - } - -As you might see, we have a problem here. As soon as I turn my television set on, I also turn on the heater and when I turn the heater off, the television will go off as well. In this case, pilight has no way of knowing which relay it needs to control so it just switches all of them. So if I set GPIO 3 of Node D to HIGH, GPIO 3 of Node A, B, C will also be set HIGH. pilight offers a solution to this issue by giving all pilight instances a specific UUID. By adding the UUID of a pilight instance in the configuration file, pilight will know exactly what relay it should control. To know what the UUID of our pilight instance is, we can run the program called pilight-uuid. We are going to run this program first to know what the UUID of Node C is by running it on that Raspberry Pi: - -.. code-block:: console - - pi@pilight:~# pilight-uuid - 0338-00-00-38-000300 - -And then on the Raspberry Pi of Node D to see what his UUID is: - -.. code-block:: console - - - pi@pilight:~# pilight-uuid - 0363-00-00-63-000300 - -Now we edit our configuration file incorporating the new UUID values: - -.. code-block:: json - :linenos: - - { - "devices": { - "heater": { - "uuid": "0338-00-00-38-000300", - "protocol": [ "relay" ], - "id": [{ - "gpio": 4 - }], - "state": "off" - }, - "bookshelf": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 1 - }], - "state": "off" - }, - "television": { - "uuid": "0338-00-00-68-000300", - "protocol": [ "relay" ], - "id": [{ - "gpio": 4 - }], - "state": "off" - }, - "gardenlights": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456 - "unit": 2 - }], - "state": "off" - } - } - } - -If you now want to turn the television set on, pilight knows that it should only control the relay connected to Node C with the UUID 0338-00-00-38-000300. The same would count for sensors connected to your Raspberry Pi. Just add proper UUID values to them, and pilight will know which sensor is connected to which pilight node. - -Stable Mail Daemon ------------------- - -As you might have noticed, the main daemon is very important in the pilight AdHoc network. Once the main daemon crashes, the whole network will be down. You can easily restore the network by just restarting the main daemon. However, you might also have noticed that a Raspberry Pi is a bit less stable than normal everyday computers and less stable then your regular NAS system. What about running the main daemon on there? You can! - -pilight has been tested on various platforms other than just the Raspberry Pi. It successfully ran on \*BSD and Debian based systems. The only problem is that these consumer mainboards generally does not have GPIO capability. That is not a problem because pilight can just run on these devices when you remove all hardware definitions. diff --git a/lib/ESPiLight/pilight/docs/source/changelog.rst b/lib/ESPiLight/pilight/docs/source/changelog.rst deleted file mode 100644 index 2930f92..0000000 --- a/lib/ESPiLight/pilight/docs/source/changelog.rst +++ /dev/null @@ -1,216 +0,0 @@ -Changelog -========= - -.. versionadded:: 8.1.0 - -.. rubric:: Improvements - -- Ported events operators and functions to LUA -- Complete rewritten event parser with: - - (nested) IF/ELSE/THEN support - - case insensitive - - operator precedence compliant - - better error messages - - string concatenation - - calculations inside actions - - etc. - -.. rubric:: bugfixes - -- webGUI: Take `stats-enable` into account -- webGUI: Warp long labels into multiple lines -- webGUI: Keep values together on small screens -- webGUI: Fix dimmer element being too small - -.. versionadded:: 8.0.10 - -.. rubric:: Bugfixes - -- Ignore dst in DATE_FORMAT function to keep input datetime unaffected by dst. - -.. versionadded:: 8.0.9 - -.. rubric:: Bugfixes - -- Properly reset time variable in DATE_FORMAT function to correctly handle dst. - -.. versionadded:: 8.0.8 - -.. rubric:: Bugfixes - -- --debuglevel=2 replaced --debuglevel=1. Now both are allowed. - -.. versionadded:: 8.0.7 - -.. rubric:: Change functionality - -- Openweathermap now requires a personal API key. Until now, a free pilight organization API key was used, but that exceeded the maximum allowed requests per minute. - -.. rubric:: Bugfixes - -- Actually allow --debuglevel=2 to see additional mail logging - -.. versionadded:: 8.0.6 - -.. rubric:: Bugfixes - -- Readded min / max dimlevel in generic_dimmer, but validation is still disabled - -.. versionadded:: 8.0.5 - -.. rubric:: New functionality - -- IPv6 support for all in library clients -- Disable min / max dimlevel in generic_dimmer - -.. rubric:: Internal core changed - -- Callback in mail library when host is not reachable -- Shutdown on more signals - -.. rubric:: Bugfixes - -- Fixed pilight removal with apt -- Calling REST API with socket API -- Prevent using ``.`` as message body -- Segfault due to wrong memory freeing - -.. versionadded:: 8.0.4 - -.. rubric:: New functionality - -- webGUI long labels are wrapped - -.. rubric:: Internal core changed - -- Olsen timezone database is now used for timezone parsing -- 433.92Mhz now respect the UUID setting -- improved datetime, openweathermap, weatherunderground, and sunriseset library - -.. rubric:: Bugfixes - -- config not being saved at shutdown - -.. versionadded:: 8.0.3 - -.. rubric:: Bugfixes - -- webgui labels are word-wrapped into multiple lines on small screens -- webgui takes ``stats-enable`` into account by hiding CPU stats -- memory usage statistics has been removed because they were unreliable -- arctech_dimmer signals sent by pilight are now correctly received by pilight as well - -.. rubric:: webserver, mail and http library - -At this moment the https, mail, and webserver module and the full ``pilight-sha256`` program has been backported from rewrite. The asynchronous I/O library libuv has been added as well as the new SSL and eventpool module. The openweathermap and weather underground protocols have been adapted to use this new code as well as the pushbullet and pushover event actions. - -- pilight now supports a HTTPS webserver which can be configured in the settings: - - .. code-block:: json - - { "webserver-https-port": 5002 } - -- pilight also stopped detecting if the mailserver you have configures requires an SSL connection. To tell pilight about the SSL requirement of a mail server a new setting has been added. Servers that switch from a plain connection to SSL require a 0 value here: - - .. code-block:: json - - { "smtp-ssl": 1 } - -.. versionadded:: 8.0.2 - -.. rubric:: Bugfixes - -- wiringX log was scrambled - -.. versionadded:: 8.0.1 - -.. rubric:: Bugfixes - -- gpio_switch protocol that stops working after a while -- pilight not starting at boottime - -.. versionadded:: 8.0 - -.. note:: - - Not all changes from development where ported to stable. Especially the rules can break when upgraded from the latest development to the latest stable. Porting the new eventing code is in the planning real soon, but until then, just stick with development. - -.. rubric:: Breaking changes - -- The PHP parsing functionality has been removed. - -.. rubric:: New functionality - -- Proper REST API through the webserver. See `Development -> API `_. - -- Protocol names cannot be used anymore as configuration device names. - -- Supporting flashing the Arduino Uno. - -- Added TFA 30.X weather stations. FIXME -- Added Quigg GT-9000 protocol. See FIXME. -- Added Secudo / FlammEx smoke sensor. FIXME. -- Added Eurodomest protocol. `Protocols -> 433.92Mhz -> Switches -> Eurodomest `_ -- Added TCM 218943 protocol `Protocols -> 433.92Mhz -> Weather -> TCM `_ - -- Allow event triggers based on received actions. See `Eventing -> Syntax `_. -- Added the ISNOT operator. See `Eventing -> Operators `_ - -- Added webGUI support for illuminance sensor. - -- Allow filtering ``pilight-receive`` protocols. See `Programs -> pilight-receive `_ -- Split pilight daemon debug and foreground functionality in two parameters. See `Programs -> pilight-daemon `_ - -- Removed internal wiringX integration and changes to shared library linking. -- Validate duplicate 433gpio GPIO for both sender and receiver value. - -- Default pilight paths have changes. -- The tzdata.json file has been deprecated and moved internally into pilight. - -.. rubric:: Bugfixes - -- XBMC and LIRC protocol. Properly try to reconnect when connection is lost. -- X10 Switch. The same unit was sent for units 8 and 9. -- Beamisch Switch. Resend the beamisch switch 10 times again. -- Arctech Switch. More precise pulse lengths. -- EV1527 Switch. Allow a bigger ID range. -- Conrad RSL switch. Add learn parameter for device learning. -- RSL366 Switch. Better protocol validation for less false positives. -- Arctech Dusk. Fixed swapped states. -- Clarus Switch. Prevent crashes on too long ID parameter. -- Alecto WX500 Weather Station. Fixed negative temperatures. -- Alecto WS1700 Weather Station. Better protocol implementation according to specsheet. -- Arctech Old Switch. Better protocol validation for less false positives. -- Quigg GT-1000 Switch. Added support more group codes. -- Elro 800 Switch. Support for more systemcodes. -- Teknihall Weather Station. Fixed negatives temperature values. -- Dim action. IN timeout could take too long. -- ``smtp-user`` setting. Any character is now allowed. -- ``smtp-email`` setting. Better email address validation. -- pilight startup. Start pilight after network at boottime. - -.. rubric:: Internal core changes - -- Frequency properties are made hardware module independent. -- Added file_get_contents function. -- Updated webGUI jQuery and moment library . -- Better internal pushbullet and pushbullet action argument parsing. -- Better binary to decimals and vice versa parsing. -- Support for AArch64 compilation. -- Send version after request values API call. -- Differentiate JSON types using bitmasks. -- Better mail library status checking. -- Added python3 client example. - -- Various typo fixes. - -- Fixed shared and static library linking. -- Fixed unused protocol repeat parameter. -- Fixed various uninitialized fields or incomplete buffer initializations. -- Fixed memory leaks in Dim, Label, and Switch action. -- Fixed inconsistent min and max dimlevel parsing in generic dimmer. -- Fixed webGUI dimmer display bugs. -- Fixed possible deadlock in datetime library. -- Fixed various buffer overflows in protocols. -- Fixed lm75, lm76, and bmp180 i2c-patch parsing. -- Fixed ntp time library bugs. diff --git a/lib/ESPiLight/pilight/docs/source/conf.py b/lib/ESPiLight/pilight/docs/source/conf.py deleted file mode 100644 index ec36f4b..0000000 --- a/lib/ESPiLight/pilight/docs/source/conf.py +++ /dev/null @@ -1,173 +0,0 @@ -# -*- coding: utf-8 -*- -# -# pilight documentation build configuration file, created by -# sphinx-quickstart on Tue Sep 12 20:56:47 2017. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import sphinx_bootstrap_theme -import guzzle_sphinx_theme -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - -def setup(app): - app.add_stylesheet('font.min.css') - app.add_stylesheet('custom.css') - app.add_javascript('custom.js') - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -locale_dirs = ['.locale/'] -gettext_compact = False - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['.templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'pilight' -copyright = u'2017, pilight' -author = u'pilight contributors' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = u'7.0' -# The full version, including alpha/beta/rc tags. -release = u'7.0' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path -exclude_patterns = [] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'github' - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'guzzle_sphinx_theme' -html_theme_path = guzzle_sphinx_theme.html_theme_path() - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -html_theme_options = { - "project_nav_name": " ", -} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['.static'] - -html_favicon = 'images/favicon.ico' -html_logo = 'images/pilight.png' -html_show_sourcelink = False; -html_show_sphinx = False; - - -# -- Options for HTMLHelp output ------------------------------------------ - -# Output file base name for HTML help builder. -htmlhelp_basename = 'pilightdoc' - - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'pilight.tex', u'pilight documentation', - u'pilight contributors', 'howto'), -] - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'pilight', u'pilight Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'pilight', u'pilight Documentation', - author, 'pilight', 'One line description of project.', - 'Miscellaneous'), -] - - - diff --git a/lib/ESPiLight/pilight/docs/source/configuration/devices.rst b/lib/ESPiLight/pilight/docs/source/configuration/devices.rst deleted file mode 100644 index 6defc04..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/devices.rst +++ /dev/null @@ -1,198 +0,0 @@ -Devices -======= - -* `Introduction`_ -* `Structure`_ -* `Device Types`_ -* `Multiple IDs`_ -* `Multiple Protocols Per Device`_ -* `Overriding Protocol Settings`_ - -Introduction ------------- - -.. warning:: - - Make sure pilight is not running before editing your configuration or else all changes will be lost. - -.. note:: - - This page will only explain the device set-up basics with some protocols as an example. To see the full - list of supported protocols and their respective syntax read the protocol pages of this manual. - -pilight can be ran with or without a fixed devices set-up. The advantage of a fixed device set-up is that pilight can use them in events and for external clients such as the built-in webGUI. Status updates will automatically be updated just like information from weather information. - -The protocol names outputted by *pilight-receive* are not (always) the same as the protocols used in the device setup. The reason for this, is that various brands use the same underlying protocol. The arctech_switch protocol is used by at least five different brands. So there is the same underlying protocol for each of these brands. - -#. Check the brand of the device you want to define in the device set-up. -#. Check if your device is recognize in *pilight-receive*. -#. Check the protocol pages to see if your device is listed and what the device syntax is. - -If your specific brand / device is not listed, but *pilight-receive* does show output, then contact us so we can add the device to the specific protocol supported brand list. - -Structure ---------- - -.. code-block:: json - :linenos: - - { - "devices": { - "television": { - "protocol": [ "relay" ], - "id": [{ - "gpio": 3 - }], - "state": "off" - }, - "bookShelfLight": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456, - "unit": 1 - }], - "state": "off" - } - } - } - -Each device you want to set-up in pilight has its own entry. In this example we have set-up two devices. One GPIO connected Relay that turns the television on and off and KlikAanKlikUit controlled bookShelfLight. Whenever an action has been performed or received by pilight the registered device will update itself when necessary. So, would you in this example, turn the bookShelfLight to on with a KlikAanKlikUit remote, pilight will also record this, and change the status of the bookShelfLight to on. Of course, a receiver needs to be connected for this to work. Each device has its own specific syntax but its basic properties remain the same. That is: - -#. name -#. protocol -#. id - -To know the syntax of the specific protocol you want to use you can refer to the protocols description found in the protocol section of this manual. - -.. note:: changed in version 8 - - Protocol names cannot be used as device names. - -Device Types ------------- - -pilight can work with various device types. Each device type has different functionality and requirements, however, they sometimes use the same code characteristics. One example are the KlikAanKlikUit switches, dimmers, doorbells, and screens. In pilight a KlikAanKlikUit code can show up like this: - -.. code-block:: console - - { - "origin": "sender", - "protocol": "arctech_switches", - "code": { - "id": 100, - "unit": 15, - "state": off - }, - "repeat": 1, - } - { - "origin": "sender", - "protocol": "arctech_dimmers", - "code": { - "id": 100, - "unit": 15, - "state": off - }, - "repeat": 1, - } - { - "origin": "sender", - "protocol": "arctech_screens", - "code": { - "id": 100, - "unit": 15, - "state": up - }, - "repeat": 1, - } - -As you can see, a single KlikAanKlikUit command was interpreted as three different devices. You need to choose carefully which device actually sent the code to make sure how to define it in the device set-up. The difference is that a dimmer will have a slider and an on/off button, a switch will just show an on/off button, and a screen will have momentary up/down buttons. Defining a screen as a dimmer is possible but does not give you the ability to control the dimmer as a dimmer from the different GUIs. - -Multiple IDs ------------- - -Each protocol needs to have at least one id defined so pilight knows what device has been controlled. However, it is possible that you have multiple KlikAanKlikUit remotes that control the same KlikAanKlikUit switch. In that case, you can define multiple id's to your devices. In case of a KlikAanKlikUit switch: - -.. code-block:: json - :linenos: - - { - "devices": { - "bookShelfLight": { - "protocol": ["kaku_switch"], - "id": [{ - "id": 1234, - "unit": 0 - }, - { - "id": 2345, - "unit": 1 - }], - "state": "off" - } - } - } - -Whenever one of these id's have been received, pilight will update the device accordingly. - -Multiple Protocols Per Device ------------------------------ - -pilight supports multiple protocols per device. The new KlikAanKlikUit switches are backwards compatible with the old KlikAanKlikUit remotes. This means that pilight needs to check both protocols to know whether a device state was changed. In case of a KlikAanKlikUit dimmer, pilight needs to check three protocols. To add multiple protocols per device, the device must contain at least one ID for each protocol and all protocol values should be present. An example: - -.. code-block:: json - :linenos: - - { - "devices": { - "bookShelfLight": { - "protocol": [ "kaku_dimmer", "kaku_switch", "kaku_old" ], - "id": [{ - "id": 123456, - "unit": 1 - }, - { - "id": 10, - "unit": 5 - }], - "state": "off", - "dimlevel": 10 - } - } - } - -There are a few important steps when you use multiple protocols in a single device setup. - -1. The kaku_dimmer and kaku_switch protocols both share the same id specifications, but the kaku_old protocol can only have an id < 16 and a unit < 33. The id set for the kaku_switch and kaku_dimmer is thereby not supported by the kaku_old protocol. Therefore an additional id must be added to match the requirements by kaku_old. - -2. Because we have a dimmer and switch protocol combined we must have a dimlevel and state value present in the device. - -3. The kaku_dimmer is the first protocol defined. This is important, because pilight will now interpret this device as a dimmer instead of a switch. Would the kaku_dimmer protocol be defined as second or third protocol, then the device would be interpreted as a switch. - -Overriding Protocol Settings ----------------------------- - -Each protocol has some specific settings you can override in your device set-up. What these settings are, can be found in the protocols section of this manual. These settings can change the internal functioning of a protocol or the values a protocol can take. These settings are device specific. - -For example, we do not want to have our dimmer to go to a full dimlevel, because then it is to bright. But we also do not want it to go to its minimum dimlevel, because then it is to dim. In that case, you can override the minimum and maximum values of the dimmer: - -.. code-block:: json - :linenos: - - { - "devices": { - "bookShelfLight": { - "protocol": [ "kaku_dimmer" ], - "id": [{ - "id": 1234, - "unit": 1 - }], - "state": "on", - "dimlevel": 3, - "dimlevel-minimum": 3, - "dimlevel-maximum": 10 - } - } - } - -Of course, the maximum dimlevels can still be overridden by the KlikAanKlikUit remote, but pilight will make sure it cannot control the dimmers below or above these dimlevels within pilight. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/configuration/example.rst b/lib/ESPiLight/pilight/docs/source/configuration/example.rst deleted file mode 100644 index 39d1385..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/example.rst +++ /dev/null @@ -1,58 +0,0 @@ -Example -======= - -.. warning:: - - Make sure pilight is not running before editing your configuration or else all changes will be lost. - -.. code-block:: json - :linenos: - - { - "devices": { - "tv": { - "protocol": ["relay"], - "id": [{ - "gpio": 3 - }], - "state": "off", - "default-state": "off" - } - }, - "rules": { - "lightswitch": { - "rule": "IF tv.state IS on THEN switch DEVICE tv TO off", - "active": 1 - } - }, - "gui": { - "tv": { - "name": "Television", - "group": ["Living"], - "media": ["all"], - "readonly": 0 - } - }, - "settings": { - "log-level": 6, - "pid-file": "/var/run/pilight.pid", - "log-file": "/var/log/pilight.log", - "webserver-enable": 1, - "webserver-http-port": 5001, - "webserver-cache": 1, - "webserver-root": "/usr/local/share/pilight" - }, - "hardware": { - "433gpio": { - "sender": 0, - "receiver": 1 - } - }, - "registry": { - "pilight": { - "version": { - "current": "6.0" - } - } - } - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/configuration/gui.rst b/lib/ESPiLight/pilight/docs/source/configuration/gui.rst deleted file mode 100644 index a1d8b03..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/gui.rst +++ /dev/null @@ -1,90 +0,0 @@ -GUI -=== - -- `Introduction`_ -- `Elements`_ -- `Group`_ - -Introduction ------------- - -.. warning:: - - Make sure pilight is not running before editing your configuration or else all changes will be lost. - - -pilight has an extensive API that allows developers to create custom graphical user interfaces (GUI). A pilight GUI is actually nothing more then a presentation of the devices a user wants to easily control. This means that a GUI does not have to show all devices added to the device set-up and that not all GUIs have to show the same devices. You can have a more compact GUI for a small screen such as a mobile phone or a more extensive GUI for you computer screen. - -Elements --------- - -Remember the device set-up we created earlier. - -.. code-block:: json - :linenos: - - { - "devices": { - "television": { - "protocol": [ "relay" ], - "id": [{ - "gpio": 3 - }], - "state": "off" - }, - "bookShelfLight": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456, - "unit": 1 - }], - "state": "off" - } - } - } - -To present one of these two devices to our GUI, we add the to the GUI list like this: - -.. code-block:: json - :linenos: - - { - "gui": { - "television": { - "name": "Television", - "group": [ "Living" ], - "media": [ "web" ], - "readonly": 0 - }, - "bookShelfLight": { - "name": "Book Shelve", - "group": [ "Library" ], - "media": [ "mobile" ], - "readonly": 1 - } - } - } - -Each device you want to add to the GUI has its own entry. You can only add devices that are also registered in the device set-up, but of course, you do not have to present all those devices to the GUIs. There are some fixed fields that are common for all GUI elements: - -- name - The display name inside the GUI. -- group - See below. -- media - Which GUIs should display this devices: mobile, web, desktop, all (default) -- readonly - Should the GUI element be readonly? Default is 0. -- confirm - Should the GUI ask for confirmation before switching the device? Default is 0. - -To know what the additional options are for the specific protocols, check the protocol section of this manual. - -Group ------ - -The group attribute allows you to group GUI elements. pilight allows you to define multiple groups but it is dependent on the GUI how it will interpret these groups. Currently, the pilight webGUI and the Android App Illumina only parse the first group and will create different tabs for each one of them. However, possible implementation could be: - -- Assign element to multiple groups -- Create a treeview of descending parents / children -- Create pages with grouped widgets \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/configuration/hardware.rst b/lib/ESPiLight/pilight/docs/source/configuration/hardware.rst deleted file mode 100644 index 06a86bb..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/hardware.rst +++ /dev/null @@ -1,85 +0,0 @@ -Hardware -======== - -- `Disabled`_ -- `433.92Mhz`_ - - `433lirc`_ - - `433gpio`_ - - `433nano`_ - -Introduction ------------- - -.. warning:: - - Make sure pilight is not running before editing your configuration or else all changes will be lost. - -Since pilight 3.0 the feature to send and receive from multiple hardware modules has been introduced. This means you can control various different frequencies at the same time. However, only one module per frequency is supported. Each hardware module has its own syntax as listed below. - -Disabled --------- - -.. code-block:: json - :linenos: - - { - "hardware": { - "none": { } - } - } - -433.92Mhz ---------- - -.. _433lirc: -.. rubric:: Lirc Kernel Module - -.. code-block:: json - :linenos: - - { - "hardware": { - "433lirc": { - "socket": "/dev/lirc0" - } - } - } - -.. _433gpio: -.. rubric:: Direct GPIO Access - -.. code-block:: json - :linenos: - - { - "hardware": { - "433gpio": { - "sender": 0, - "receiver": 1 - } - } - } - -The default configuration to be used with the pilight PCB. When using custom wiring, refer to http://www.wiringx.org for the pin numbering of the various supported devices. If you want to disable the sender or receiver pin, set it to --1. - -.. versionchanged:: 8.0 - -You must now specify which GPIO platform pilight is running on. Refer to the settings page for more information. - -.. _433nano: -.. rubric:: pilight USB Nano - -.. code-block:: json - :linenos: - - { - "hardware": { - "433nano": { - "comport": "/dev/ttyUSB0" - } - } - } - -The comport value needs to correspond to a valid COM device on your platform. On Windows this value is generally formatted as COM1, on Linux as /dev/ttyUSB0, and on FreeBSD /dev/cuau0. - diff --git a/lib/ESPiLight/pilight/docs/source/configuration/index.rst b/lib/ESPiLight/pilight/docs/source/configuration/index.rst deleted file mode 100644 index cd2a983..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/index.rst +++ /dev/null @@ -1,17 +0,0 @@ -.. raw:: latex - - \newpage - -Configuration -============= - -.. toctree:: - :maxdepth: 1 - - devices - rules - gui - settings - hardware - registry - example \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/configuration/registry.rst b/lib/ESPiLight/pilight/docs/source/configuration/registry.rst deleted file mode 100644 index 1d4aada..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/registry.rst +++ /dev/null @@ -1,8 +0,0 @@ -Registry -======== - -.. warning:: - - Make sure pilight is not running before editing your configuration or else all changes will be lost. - -Besides all the fixed configuration objects, pilight also allows developers to use the integrated registry. This registry allows developers to store information that can later be retrieved when reading the configuration. pilight itself will for example store its current version and available version in the registry and the pilight webGUI will store additional settings in there as well. You are therefore advised to leave the registry untouched so all additional information created by the different webGUIs is not lost. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/configuration/rules.rst b/lib/ESPiLight/pilight/docs/source/configuration/rules.rst deleted file mode 100644 index 07f31bd..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/rules.rst +++ /dev/null @@ -1,30 +0,0 @@ -Rules -===== - -.. warning:: - - Make sure pilight is not running before editing your configuration or else all changes will be lost. - -Since pilight version 6, eventing has been introduced. To use events, you need to first define rules inside the pilight configuration. - -The basic pilight rule structure for the configuration looks like this: - -.. code-block:: json - :linenos: - - { - "rules": { - "rule_name": { - "rule": "IF switch.state IS on THEN switch DEVICE switch.state TO off", - "active": 1 - } - } - } - -As you can see, a rules object consists of various elements: - -#. Each rule is placed in its own object with a unique identifier. -#. Each rule consists of the actual rule placed in the rule field. -#. Each rule consists of an active field that tells pilight if the rule is active or not. - -You can of course define as many rules as you like. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/configuration/settings.rst b/lib/ESPiLight/pilight/docs/source/configuration/settings.rst deleted file mode 100644 index 07f0ef6..0000000 --- a/lib/ESPiLight/pilight/docs/source/configuration/settings.rst +++ /dev/null @@ -1,691 +0,0 @@ -Settings -======== - -- `Introduction`_ -- `Core`_ - - `port`_ - - `standalone`_ - - `pid-file`_ - - `pem-file`_ - - `log-file`_ - - `log-level`_ - - `whitelist`_ - - `stats-enable`_ - - `watchdog-enable`_ - - `gpio-platform`_ -- `Webserver`_ - - `webgui-websockets`_ - - `webserver-authentication`_ - - `webserver-cache`_ - - `webserver-enable`_ - - `webserver-http-port`_ - - `webserver-https-port`_ - - `webserver-root`_ - - `webserver-user`_ -- `SMTP`_ - - `smtp-sender`_ - - `smtp-user`_ - - `smtp-password`_ - - `smtp-host`_ - - `smtp-port`_ - - `smtp-ssl`_ -- `Miscellaneous`_ - - `ntp-servers`_ -- `Firmware`_ - - `firmware-gpio-miso`_ - - `firmware-gpio-mosi`_ - - `firmware-gpio-reset`_ - - `firmware-gpio-sck`_ -- `Module Paths`_ - - `action-root`_ - - `function-root`_ - - `hardware-root`_ - - `operator-root`_ - - `protocol-root`_ - -Introduction ------------- - -.. warning:: - - Make sure pilight is not running before editing your configuration or else all changes will be lost. - -The way pilight functions can be altered by changing various settings. All pilight settings will be described in this chapter grouped by their respective category. - -Core ----- - -.. _port: -.. rubric:: port - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "port": 5000 } - -By default, pilight uses a random port for its socket server. Use the port setting if you want to set this to a fixed port. - -.. _standalone: -.. rubric:: standalone - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "standalone": 0 } - -When pilight starts, it will first check if there are other instances running inside the same network. If it does, it will connect to the other pilight instance and will join or create the AdHoc network. If you want to force pilight into running as a standalone daemon, you can set the standalone setting to 1. When running pilight in standalone mode, the SSDP server will also be disabled. This means that other pilight clients will not be able to discover it using SSDP. - -.. _pid-file: -.. rubric:: pid-file - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "pid-file": "/var/run/pilight.pid" } - -The pid-file is used by pilight to save the process id number of the pilight-daemon. pilight itself uses this information as one of the ways to determine if pilight is already running or not. This setting must contain a valid path to store the pid-file. - -.. _pem-file: -.. rubric:: pem-file - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "pem-file": "/etc/pilight/pilight.pem" } - -.. note:: - - Windows - -.. code-block:: json - :linenos: - - { "pem-file": "c:/pilight/pilight.pem" } - -The pem-file is used by pilight for the secure https webserver. Using the default pilight pemfile makes the secure webserver still insecure, so users are adviced to generate a custom pem file. - -.. code-block:: console - - pi@pilight ~# openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout pilight.key -out pilight.crt -subj "/CN=pilight.org" -days 3650 - pi@pilight ~# cat pilight.key pilight.crt > /etc/pilight/pilight.pem - -.. _log-file: -.. rubric:: log-file - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "log-file": "/var/log/pilight.log" } - -.. note:: - - Windows - -.. code-block:: json - :linenos: - - { "log-file": "c:/pilight/pilight.log" } - -The log-file is used by pilight to various information gathered while pilight is running. This information can be used to debug errors or gather information about triggered actions. This setting must contain a valid path to store the log-file. - -.. _log-level: -.. rubric:: log-level - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "log-level": 4 } - -The log-level tells pilight what messages it should log into the log-file. The higher the log-level the more messages are logged into the log-file. The highest log-level is 6 and the lowest is 0. These log-levels correspond to the following log types: - -0 = emergency, 1 = alert, 2 = critical, 3 = , 4 = warning, -5 = notification, 6 = information - -.. _whitelist: -.. rubric:: whitelist - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "whitelist": [ "*.*.*.*" ] } - -All software able to use socket connections can communicate to pilight. Such software can be *pilight-receive*, a user visiting the webGUI, or external pilight plugins such a provided by FHEM. If you want to limit the computers in your network that can connect to pilight, you set up a whitelist. This setting should contain a list of valid IPv4 addresses that are allowed to connect to pilight. All other IPs will be blocked. If you want to allow IPv4 ranges, you can specify them by using wildcards. For example, if we want to allow all IP addresses ranging from 192.168.1.0 to 192.168.1.254 we can add the IP address 192.168.1.* to the list. If we want to allow all IP addresses ranging from 10.0.0.0 to 10.0.254.254 we can add the IP address 10.0.*.* to the list. Each whitelist entry should contain a valid IPv4 address with or without using wildcards. - -.. _stats-enable: -.. rubric:: stats-enable - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "stats-enable": 1 } - -pilight monitors its own CPU and RAM resource usage. This information can be shared with external clients and is shared by default with the websockets connections. If you want to disable the display of the CPU and RAM statistics and/or want to disable the communication of these statistics over the websocket connection you can set this to 0. This setting can be either 0 or 1. - -.. _watchdog-enable: -.. rubric:: watchdog-enable - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "watchdog-enable": 1 } - -pilight monitors its own CPU and RAM resource usage. This information is used to shutdown or terminate pilight when it uses too much CPU or RAM. If want to disable this watchdog feature and therefor the automatic termination of pilight when needed, you can set this setting to 0. This setting can be either 0 or 1. - -.. _gpio-platform: -.. rubric:: gpio-platform - -.. versionadded:: 8.0 - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "gpio-platform": "raspberrypi2" } - -pilight can be ran on various GPIO compatible platforms. However, it is impossible to reliably distinguish them all. Therefor, you must specify on which platform you are running pilight. Under the hood, pilight uses the wiringX library to interface with the GPIO of your platform. Only those platforms that are supported by wiringX are also supported by pilight. A full and recent list of supported platforms retrieved by calling the following command: - -.. code-block:: console - - # ./pilight-daemon -H - Usage: pilight-daemon [options] - -H --help display usage summary - -V --version display version - -C --config config file - -S --server=x.x.x.x connect to server address - -P --port=xxxx connect to server port - -F --foreground do not daemonize - -D --debug do not daemonize and - show debug information - --stacktracer show internal function calls - --threadprofiler show per thread cpu usage - --debuglevel show additional development info - - The following GPIO platforms are supported: - - none - - odroidxu4 - - odroidc2 - - odroidc1 - - raspberrypi3 - - raspberrypi2 - - raspberrypizero - - raspberrypi1b+ - - raspberrypi1b2 - - raspberrypi1b1 - - hummingboard_edge_dq - - hummingboard_gate_dq - - hummingboard_edge_sdl - - hummingboard_gate_sdl - - hummingboard_base_dq - - hummingboard_pro_dq - - hummingboard_base_sdl - - hummingboard_pro_sdl - - orangepipc+ - - bananapim2 - - bananapi1 - - pcduino1 - -If you are running on a platform that doesn't support GPIO, you can either use ``none`` as the ``gpio-platform`` or remove the setting altogether. - -Webserver ---------- - -The following settings change the way the internal webserver will serve the internal pilight webGUI or it can be disabled altogether. - -.. _webgui-websockets: -.. rubric:: webgui-websockets - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "webgui-websockets": 1 } - -By default the webGUI communicates to pilight by using websockets. This is a relatively new technique that allows us to receive all changes from pilight instead of having to poll pilight for changes. The problem is that some older devices and browsers do not support websockets, but they do support the polling technique. So to disable the websockets and use polling instead we set webgui-websockets setting to 0. This setting can be either 0 or 1. - -.. _webserver-authentication: -.. rubric:: webserver-authentication - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "webserver-authentication": [ "username", "password" ] } - -By default, pilight can be controlled from the webGUI by anyone that can access it. If you want to prevent this, you can secure the webGUI with a username and password. The username should be in plain text, the password is SHA256 encrypted. Use pilight-sha256 to create the encrypted password hash. Regular SHA256 encryption tools will not work because pilight hashes the password several thousand times. - -.. code-block:: console - - pi@pilight ~# pilight-sha256 -p admin - 4f32102debed8dabd87e88cf84c752ccb23a74b29f90b42edde05cbc7be41f80 - -So if we want to use a username user and password admin the values should look like this: - -.. code-block:: json - :linenos: - - { "webserver-authentication": [ "user", "4f32102debed8dabd87e88cf84c752ccb23a74b29f90b42edde05cbc7be41f80" ] } - -.. _webserver-cache: -.. rubric:: webserver-cache - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "webserver-cache": 1 } - -pilight has the ability to cache all files used for the webGUI. This reduces the amount of reads done from the SD card on devices like the Raspberry Pi and Hummingboard, and makes it faster to load the webGUI from devices with a slow internal storage such as routers. This setting can be either 0 or 1. - -.. _webserver-enable: -.. rubric:: webserver-enable - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "webserver-enable": 1 } - -The pilight webserver can be turned off as a whole. This could be useful if you do not want to use the webGUI at all or if you want to use your own webserver implementation. This setting can be either 0 or 1. - -.. _webserver-http-port: -.. rubric:: webserver-http-port - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "webserver-http-port": 5001 } - -The pilight webserver runs by default on the non-standard port 5001. This is done to prevent interference with other webservers running on the default HTTP port 80. If you do want to run the webserver on port 80 or any other port, you can change this setting. The port specified must be a valid and unused port. - -.. _webserver-https-port: -.. rubric:: webserver-https-port - -.. deprecated:: 8.0 - -.. versionadded:: 8.0.3 - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "webserver-https-port": 5002 } - -The webserver does not allow secure connections by default. Currently the only way to get HTTPS support is by manually compiling pilight. The pilight secure webserver runs by default on the non-standard port 5002. This is done to prevent interference with other webservers running on the default HTTPS port 443. If you do want to run the secure webserver on port 443 or any other port, you can change this setting. The port specified must be a valid and unused port. - -.. _webserver-root: -.. rubric:: webserver-root - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "webserver-root": "/usr/local/share/pilight" } - -.. versionchanged:: 8.0 - -.. code-block:: json - :linenos: - - { "webserver-root": "/usr/local/share/pilight/webgui" } - -The webserver root tells pilight where it should look for all files that should be served by the webserver. This setting must contain a valid path. - -.. _webserver-user: -.. rubric:: webserver-user - -.. note:: - - Linux - -.. code-block:: json - :linenos: - - { "webserver-user": "www-root" } - -.. note:: - - \*BSD - -.. code-block:: json - :linenos: - - { "webserver-user": "www" } - -The webserver runs by default as a non-root user. This to prevent the execution of malicious code. If you want to force the webserver to run as the root user or any other system user, you can change this setting accordingly. This setting needs to contain a valid system user. - -SMTP ----- - -pilight has the capability to communicate with several types of mail servers. This offers pilight the possibility to use for example mail actions inside our event rules, so email messages can be sent in case of a certain event. Most users will have an email account from their internet hosting provider or free mail solutions can be used like gmail. In case of a (non-existing) gmail account named: pilight@gmail.com with password: foobar, the SMTP settings should be configured like this: - -.. code-block:: json - :linenos: - - { - "smtp-sender": "pilight@gmail.com", - "smtp-host": "smtp.gmail.com", - "smtp-port": 465, - "smtp-user": "pilight@gmail.com", - "smtp-password": "foobar", - "smtp-ssl": 1 - } - -.. _smtp-sender: -.. rubric:: smtp-sender - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "smtp-sender": "...@....com" } - -The smtp-sender requires a valid e-mail address. As soon as a mail is sent by pilight, this e-mail address will be used as the address from with the mail was sent. - -.. _smtp-user: -.. rubric:: smtp-user - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "smtp-user": "...@....com" } - -The smtp-user requires a valid e-mail address. This e-mail address is used to validate the account details at the e-mail provider. - -.. versionchanged:: 8.0 Allow any string for smtp-user - -The smtp-user can be any string, and doesn't have to be an valid e-mail address anymore. - -.. _smtp-password: -.. rubric:: smtp-password - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "smtp-password": "..." } - -The smtp-password is used to validate the account details at the e-mail provider together with the smtp-user setting. The password should therefore be a valid password for this e-mail account. - -.. _smtp-host: -.. rubric:: smtp-host - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "smtp-host": "smtp.foo.com" } - -The smtp-host setting should contain a valid mail server hostname. Normally, the host name is similar to name of the internet hosting provider. - -.. _smtp-port: -.. rubric:: smtp-port - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "smtp-port": 25 } - -.. deprecated:: 8.0.3 - -The smtp-port should contain a valid smtp server port. This can currently be either 25, 465, or 587. pilight will communicate over a secure connection when using port 465, when using port 25 or 587 it will depend on the server how pilight will set-up the connection. - -.. versionchanged:: 8.0.3 - -The smtp-port should contain a valid smtp server port. This can be any port. SSL connections should be explicitly defined in the smtp-ssl setting. - -.. versionadded:: 8.0.3 - -.. _smtp-ssl: -.. rubric:: smtp-ssl - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "smtp-ssl": 0 } - -The smtp-ssl tells pilight if the mailserver uses a secure SSL communication from the start. If server change to SSL while initializing a connection, pilight will do so automatically as well. In those cases, this setting can be set to zero. - -Miscellaneous -------------- - -.. _ntp-servers: -.. rubric:: ntp-servers - -.. note:: - - Linux, \*BSD, and Windows - -.. code-block:: json - :linenos: - - { "ntp-servers": [ "eu.pool.ntp.org", "uk.pool.ntp.org" ] } - -One important feature of any automation setup is the ability to trigger time based actions. However, these events greatly rely on a correct date and time. Problems occur when the system time is not set to the correct time (for our specific timezone). This can happen on systems like the Raspberry Pi which does not have a RTC that allows it to keep track of time when turned off. To overcome this problem pilight has the ability to retrieve the correct time by synchronizing with NTP servers. You can pick any server from http://www.pool.ntp.org/. Any number of servers can be added to the ntp-servers list. pilight will first try to synchronize with the first server. If this fails it will try the second server etc. It will continue this process until an actual response was received. - -Firmware --------- - -pilight provides an easy tool to flash the firmware of several microcontrollers in the form of pilight-flash. pilight flashes microcontrollers by using either bitbanging or through USB. To use bitbanging we need four GPIOs. These GPIOs are by default configured for usage on a Raspberry Pi. They can however, be changed to other GPIOs according to the device you want to use. Each GPIO is named according to the SPI requirements, but any GPIO can be used because we are not actually using SPI to communicate with our microcontrollers. In pilight the SPI identifiers MISO, MOSI, Reset and SCK are only used to separate the different GPIO. - -If you are unsure what valid GPIOs are on your platform, -please refer to the http://www.wiringx.org documentation. - -.. _firmware-gpio-miso: -.. rubric:: firmware-gpio-miso - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "firmware-gpio-miso": 13 } - -This setting defines the GPIO pin to be used as MISO. Any valid GPIO for your platform can be used. - -.. _firmware-gpio-mosi: -.. rubric:: firmware-gpio-mosi - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "firmware-gpio-mosi": 12 } - -This setting defines the GPIO pin to be used as MOSI. Any valid GPIO for your platform can be used. - -.. _firmware-gpio-reset: -.. rubric:: firmware-gpio-reset - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "firmware-gpio-reset": 10 } - -This setting defines the GPIO pin to be used as Reset. Any valid GPIO for your platform can be used. - -.. _firmware-gpio-sck: -.. rubric:: firmware-gpio-sck - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "firmware-gpio-sck": 14 } - -This setting defines the GPIO pin to be used as SCK. Any valid GPIO for your platform can be used. - -Module Paths ------------- - -pilight has the possibility to load various external modules to enhance its functionality. These modules are single files and should be placed in fixed folders. However, these folders locations can be changed by altering one of the following settings. - -.. warning:: - - There is generally no reason to load external modules. - The latest pilight version always contains the latest - protocols, hardware drivers, event operators, functions, - and actions. - -.. _action-root: -.. rubric:: action-root - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "action-root": "/usr/local/lib/pilight/action" } - -pilight event actions are loaded from the action-root folder. The action-root setting must contain a valid path. - -.. _function-root: -.. rubric:: function-root - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "function-root": "/usr/local/lib/pilight/function" } - -pilight event actions are loaded from the function-root folder. The function-root setting must contain a valid path. - -.. _hardware-root: -.. rubric:: hardware-root - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "hardware-root": "/usr/local/lib/pilight/hardware" } - -pilight event actions are loaded from the hardware-root folder. The hardware-root setting must contain a valid path. - -.. _operator-root: -.. rubric:: operator-root - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "operator-root": "/usr/local/lib/pilight/operator" } - -pilight event actions are loaded from the operator-root folder. The operator-root setting must contain a valid path. - -.. _protocol-root: -.. rubric:: protocol-root - -.. note:: - - Linux and \*BSD - -.. code-block:: json - :linenos: - - { "protocol-root": "/usr/local/lib/pilight/protocol" } - -pilight event actions are loaded from the protocol-root folder. The protocol-root setting must contain a valid path. diff --git a/lib/ESPiLight/pilight/docs/source/development/api.rst b/lib/ESPiLight/pilight/docs/source/development/api.rst deleted file mode 100644 index 113b69e..0000000 --- a/lib/ESPiLight/pilight/docs/source/development/api.rst +++ /dev/null @@ -1,425 +0,0 @@ -API -=== - -- `Identification`_ -- `Options`_ -- `Actions`_ -- `Webserver (REST Api)`_ -- `Heartbeat`_ -- `Buffer Sizes`_ - -Identification --------------- - -All programs communicate with each other by using JSON objects. The normal identification process is as follows: - -- Connect to pilight-daemon by using the pilight IP and port. The port pilight is running at is either a randomly chosen number or a fixed number as configured in the pilight settings. -- The pilight-daemon waits for the client to identify itself by sending the following JSON object: - - .. code-block:: json - :linenos: - - { - "action": "identify" - } - -- Additionally, a client can send certain options to tell the daemon what level of communication is the client want to set-up. A full identification JSON looks like this: - - .. code-block:: json - :linenos: - - { - "action": "identify", - "options": { - "core": 1, - "receiver": 1, - "config": 1, - "forward": 0 - }, - "uuid": "0000-d0-63-00-000000", - "media": "all" - } - -- After each action, the daemon will send either one of the following two status responses indicating a success or failure: - - .. code-block:: json - :linenos: - - { - "status": "success" - } - - .. code-block:: json - :linenos: - - { - "status": "failure" - } - -Options -------- - -The identification options define what communication is set-up between the daemon and the client. - -- receiver - When the receiver option is set, the daemon will forward the received or sent codes to the client. An example: - - .. code-block:: json - :linenos: - - { - "origin": "receiver", - "protocol": "kaku_switch", - "code": { - "id": 1234, - "unit": 0, - "off": 1 - } - } - { - "origin": "sender", - "protocol": "kaku_switch", - "code": { - "id": 1234, - "unit": 0, - "off": 1 - } - } - - In the received JSON messages, the origin will tell if an externally received message was received or a code sent by pilight self. - -- config - When the config option is set, the daemon will communicate all configuration updates. An example: - - .. code-block:: json - :linenos: - - { - "origin": "config", - "devices": [ "mainlight" ], - "values": { - "state": "on" - } - } - - | - -- core - When the core option is set, the daemon will communicate pilight core information. - -- stats - When the stats option is set, the daemon will communicate the RAM and CPU statistics. - - .. code-block:: json - :linenos: - - { - "origin": "core", - "values": { - "cpu": 0.07822473698105643, - "ram": 0.1535397936955158 - }, - "type": -1, - "uuid": "0000-d0-63-00-000000" - } - - | - -- forward - When the forward option is enabled, all incoming (valid) socket data will be forwarded to the client. - -The uuid setting is meant for the client to send its unique UUID. - -The media setting is used to tell the daemon what information is sent based on the specific media. As can be read in the GUI configuration, a user can create different GUIs based on different devices. The currently supported GUI types are all, web, mobile, and desktop. If you define your client as one of those GUI types, pilight will only send devices, GUI elements, config updates and rules that apply the specific GUI type, leaving the rest out. Therefore, you do not have to do any additional parsing on the client side. - -These options can be updated on-the-fly while the client is running. The daemon will start or stop sending specific messages. To update these options, just send another identification request. An example identification object: - - - .. code-block:: json - :linenos: - - { - "action": "identify", - "options": { - "stats": 1, - "receiver": 1 - }, - "uuid": "0000-d0-63-00-000000" - } - -Actions -------- - -As we have seen in the identification process, pilight can handle several actions. The first action we encounter is the identification action. The following list contains all possible actions the daemon can handle. Again, the daemon will respond to all actions with a success and failure so the client can check if the action succeeded. - -- send - In case the client wants to send specific protocol codes, the send action is used. A sent action is accompanied by specific additional arguments: - - .. code-block:: json - :linenos: - - { - "action": "send", - "code": { - "protocol": [ "kaku_switch" ], - "id": 1234, - "unit": 0, - "off": 1 - } - } - - These are basically the command like arguments. If an argument requires a value, then the value is added to the argument (as with id and unit). If the argument does not take a value, than it is defaulted to 1 (as with off). The pilight-daemon will check if the code was valid, and report back with a failure if it was not. - -- control - The control action is used to control registered devices by using their device IDs. The pilight-daemon will check if the values are valid and report back with a failure if they are not. An example control object: - - .. code-block:: json - :linenos: - - { - "action": "control", - "code": { - "device": "mainlight", - "state": "on", - "values": { - "dimlevel": 10 - } - } - } - - | - -- registry - The pilight registry can be managed by the registry API. The registry is a multi-purpose storage solution within pilight. Developers can store any information they want inside it so it is retrievable later on. The registry allows three types of actions: set, get, remove. The syntax for each on of them is: - - .. code-block:: json - :linenos: - - { - "action": "registry", - "type": "set", - "key": "pilight.version", - "value": "6.0" - } - - .. code-block:: json - :linenos: - - { - "action": "registry", - "type": "get", - "key": "pilight.version" - } - - .. code-block:: json - :linenos: - - { - "action": "registry", - "type": "remove", - "key": "pilight.version" - } - - The response to a get command is as follows: - - .. code-block:: json - :linenos: - - { - "action": "registry", - "value": "6.0", - "key": "pilight.version" - } - - Please note that the pilight registry can only hold JSON string and number types. - -- request config - The request config is used to request the full configuration object from the pilight-daemon: - - .. code-block:: json - :linenos: - - { - "action": "request config" - } - - | - -After this command, the pilight-daemon will send the raw JSON configuration as it is used internally. - - .. code-block:: json - :linenos: - - { - "devices": { - "tv": { - "uuid": "0000-00-00-07-646b93", - "origin": "0000-d0-63-00-000000", - "timestamp": 0, - "protocol": [ "relay" ], - "id": [{ - "gpio": 3 - }], - "state": "off", - "default": "off" - } - }, - "rules": { - "tvswitch": { - "rule": "IF tv.state IS on THEN switch DEVICE tv TO off", - "active": 1 - } - }, - "gui": { - "television": { - "type": 4, - "order": 1, - "name": "tv", - "group": [ "Living" ], - "media": [ "all" ], - "readonly": 0 - } - }, - "settings": { - "log-level": 4, - "pid-file": "/var/run/pilight.pid", - "log-file": "/var/log/pilight.log", - "webserver-enable": 1, - "webserver-http-port": 5001, - "webserver-cache": 0, - "webserver-root": "/usr/local/share/pilight" - }, - "hardware": { - "433gpio": { - "sender": 0, - "receiver": 1 - } - }, - "registry": { - "pilight": { - "version": { - "current": "6.0" - } - } - } - } - - -- request values - - .. code-block:: json - :linenos: - - { - "action": "request values" - } - - pilight tries to make app development as easy as possible. This means that GUIs should only have to parse the GUI configuration object. The downside however is that the GUI object does not contain the device values. To solve this issue, the GUIs can request the values for all devices at once. The returned object will have the same information as the daemon communicates with the config option enabled, but now in bulk for all devices. An example: - - .. code-block:: json - :linenos: - - [{ - "type": 4, - "devices": [ "tv" ], - "values": { - "timestamp": 0, - "state": "off" - } - }, - { - "type": 1, - "devices": [ "bookShelfLight" ], - "values": { - "timestamp": 0, - "state": "off" - } - }] - - Please be aware that right after the request values object, the pilight version object is sent. It is up to the GUIs to ignore or parse this information. - -Webserver (REST API) --------------------- - -The webserver has some special pages: - -- The config page will present the latest configuration JSON object. -- The values page will present the latest values of all device. - - The values and config page will by default only show the configuration that applies to a web GUI type. To retrieve the configuration relevant for other GUI types, use the media argument: - - .. code-block:: console - - http://x.x.x.x:5001/config?media=all - -.. versionadded:: 4.0 Send codes through webserver - -- The send page can be used to control devices. To use this function, call the send page with a URL-encoded "send" or "registry" JSON object like this: - - .. code-block:: console - - send%3F%7B%0A%09%22action%22%3A%20%22control%22%2C%0A%09%22code%22%3A%20%7B%0A%09%09%22device%22%3A%20%22mainlight%22%2C%0A%09%09%22state%22%3A%20%22on%22%2C%0A%09%09%22values%22%3A%20%7B%0A%09%09%09%22dimlevel%22%3A%20%2210%22%0A%09%09%7D%0A%09%7D%0A%7D - - This will send the object as described earlier. - -.. versionchanged:: 8.0 Implemented REST API instead of posting arbitrary JSON codes - -- The send page has the same functionality as the ``pilight-send`` program and uses the same arguments: - - .. code-block:: guess - - http://x.x.x.x:5001/send?protocol=kaku_switch&on=1&id=1&unit=1 - - As can be seen, the URL arguments are the same as for the ``kaku_switch`` protocol: - - .. code-block:: console - - pi@pilight:~# pilight-send -p kaku_switch -H - ... - [kaku_switch] - -t --on send an on signal - -f --off send an off signal - -u --unit=unit control a device with this unit code - -i --id=id control a device with this id - -a --all send command to all devices with this id - -l --learn send multiple streams so switch can learn - - All protocols can be controlled using their respective arguments using the webserver send page as described in this example. - -- The control page has the same functionality as the ``pilight-control`` program and uses the same arguments: - - .. code-block:: guess - - http://x.x.x.x/control?device=nasStatus&values[label]=computer%20is%20disconnected&values[color]=red - - In this case a generic_label device is being controlled - -Heartbeat ---------- - -One special function of the *pilight-daemon* is the heartbeat. The heartbeat is meant to check if a connection is still alive. The client has to send a "HEART\n" on which the *pilight-daemon* will respond with a "BEAT\n". This is the only exception in which not a JSON object is sent. - -Buffer Sizes ------------- - -pilight will sends all streams in 1024 bits. If these streams are smaller than 1024 bits, everything was sent at once. If a stream is 1024 bits, then you will know it is a chunk of a bigger stream. In that case, read until you encounter the end of streams delimiter which is currently made up of two new lines "\n\n". - -If multiple streams were buffered somewhere, you can also distinguish them by the double new line delimiters. An example: - - .. code-block:: console - :linenos: - - {"message":"test"}\n\n - {"message":"test"}\n\n - {"message":"test"}\n\n - -As you can see. pilight wanted to send three messages, but the TCP sockets concatenated them to one. - -The pilight socket_read function takes care of these buffered messages to check if we encountered concatenated multiple streams. pilight will then convert these messages back so the output is just one big stream separated by single newlines: - - .. code-block:: console - :linenos: - - {"message":"test"}\n - {"message":"test"}\n - {"message":"test"}\n diff --git a/lib/ESPiLight/pilight/docs/source/development/debugging.rst b/lib/ESPiLight/pilight/docs/source/development/debugging.rst deleted file mode 100644 index 311ee91..0000000 --- a/lib/ESPiLight/pilight/docs/source/development/debugging.rst +++ /dev/null @@ -1,173 +0,0 @@ -Debugging -========= - -- `Introduction`_ -- `Prerequisites`_ -- `How to recognize a Bug?`_ -- `How to Debug?`_ - -Introduction ------------- - -pilight is a product developed by a growing community. Due to its Open Source character, developers around the world can contribute code. Although all developers try to write bug free code, it is not always possible for the developers of pilight to check for every possible mistake that can be made. Especially, because not everyone has every hardware available for testing. - -Prerequisites -------------- - -If you found this page, you probably encountered a bug in the pilight code or noticed that things are not working as they should be. Before you continue reading, consider the following. - -First, pilight offers code in several stages of stability: - -#. Stable apt repository and GitHub master branch - This code has been tested to work without bugs for various weeks by the developer and a large community. If bugs are found in this version of pilight, the problem has probably already been fixed in the developmental code. - -#. Nightly apt repository and GitHub development branch - This code always contains the very latest features and fixes. It is updated several times a week. However, this also means that not all bugs are already encountered when a user starts to use it. - -Second, this page is made for those users using the developmental GitHub branch. This tutorial assumes the following: - -#. You are aware of the distinction between bugs and changes in the pilight functionality. -#. You have read the GitHub commit messages to be sure that what you have encountered is indeed a bug and not a changed functionality. -#. You have enough experience working with your operating system. -#. You have the patience to help finding the problem. -#. You have some knowledge about programming (and the C language). -#. You know when to recognize a clear code bug. -#. You are able to manually compile pilight so debugging is possible. The automatically compiled versions do not support debugging as described here. - -How to Recognize a Bug? ------------------------ - -The two most encountered bugs are the memory issues or the segmentation faults. A memory bug can look like this: - -.. code-block:: console - - * glibc detected ./pilight-daemon: double free or corruption (!logfile): 0x0000000000c6ed50 ** - -This message means in this case that the variable logfile was freed twice. - -A segmentation fault looks like this: - -.. code-block:: console - - pi@raspberrypi ~/pilight $ sudo service pilight start - [....] Starting : pilightSegmentation fault - failed! - -This message means there has been a general error in which pilight so it cannot be started properly. - -How to Debug? -------------- - -To debug C code, the GNU Debugger is used, also called gdb. This program will run next to pilight without any performance issue, but when pilight crashes, it allows us to track the specific line where the error occurred. So first of all, make sure you have gdb installed. This is how you start gdb together with pilight: - -.. code-block:: console - - pi@pilight:~> sudo su - root@pilight:~# gdb --args pilight-daemon -D - GNU gdb (GDB) 7.4.1-debian - Copyright (C) 2012 Free Software Foundation, Inc. - License GPLv3+: GNU GPL version 3 or later - This is free software: you are free to change and redistribute it. - There is NO WARRANTY, to the extent permitted by law. Type "show copying" - and "show warranty" for details. - This GDB was configured as "arm-linux-gnueabihf". - For bug reporting instructions, please see: - ... - Reading symbols from /usr/local/sbin/pilight-daemon...done. - (gdb) run - Starting program: /usr/local/sbin/pilight-daemon -D - [Thread debugging using libthread_db enabled] - Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1". - [Jan 18 16:23:33:657363] pilight-daemon: DEBUG: ssdp sent search - [Jan 18 16:23:33:701618] pilight-daemon: NOTICE: no pilight daemon found, daemonizing - [Jan 18 16:23:33:718878] pilight-daemon: DEBUG: -- start parsed config file -- - -Now pilight will start as it you would have started it normally. Just let it run like this until it crashes or try to invoke the crash. If it crashes, you will see something like this: - -.. code-block:: console - - *** glibc detected *** /usr/local/sbin/pilight-daemon: double free or corruption (fasttop): 0x000369d8 *** - [New Thread 0xb228c470 (LWP 26235)] - Program received signal SIGABRT, Aborted. - [Switching to Thread 0xb4d7d470 (LWP 26230)] - 0xb6dddbfc in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:67 - 67 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. - (gdb) - -Again, you see the **(gdb)** prompt that allows you to type new commands. - -The first step is to get a backtrace of all functions called when this crash occurred: - -.. code-block:: console - - (gdb) backtrace - #0 0xb6dddbfc in __GI_raise (sig=6) - at ../nptl/sysdeps/unix/sysv/linux/raise.c:67 - #1 0xb6de197c in __GI_abort () at abort.c:92 - #2 0xb6e15cf8 in __libc_message (do_abort=2, - fmt=0xb6ec78d0 "*** glibc detected *** %s: %s: 0x%s ***\n") - at ../sysdeps/unix/sysv/linux/libc_fatal.c:189 - #3 0xb6e20584 in malloc_printerr (action=3, - str=0xb6ec7a6c "double free or corruption (fasttop)", ptr=) - at malloc.c:6283 - #4 0xb6e24e00 in __GI___libc_free (mem=) at malloc.c:3738 - #5 0x0000b5d8 in broadcast (param=) at daemon.c:260 - #6 0xb6ee6bfc in start_thread (arg=0xb4d7d470) at pthread_create.c:306 - #7 0xb6e7b758 in ?? () - at ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S:116 - from /lib/arm-linux-gnueabihf/libc.so.6 - #8 0xb6e7b758 in ?? () - at ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S:116 - from /lib/arm-linux-gnueabihf/libc.so.6 - Backtrace stopped: previous frame identical to this frame (corrupt stack?) - (gdb) - -Copy this output so it can be communicated on the forum. - -The second step is to look for the exact line causing this crash. This can be done by zooming into each part of each function related to this bug. We start at the end and work our way to the beginning. To zoom into a function the command **frame** # is used in which the # is replaced by one of the numbers you see in the backtrace. As said earlier, we will start at the end: - -.. code-block:: console - - (gdb) frame 8 - #8 0xb6e7b758 in ?? () - at ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S:116 - from /lib/arm-linux-gnueabihf/libc.so.6 - 116 ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S: No such file or directory. - -This doesn't tell us anything useful. So we continue to the previous frame. - -.. code-block:: console - - (gdb) frame 7 - #7 0xb6e7b758 in ?? () - at ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S:116 - from /lib/arm-linux-gnueabihf/libc.so.6 - 116 ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S: No such file or directory. - -Still no useful information here. - -.. code-block:: console - - (gdb) frame 6 - #6 0xb6ee6bfc in start_thread (arg=0xb4d7d470) at pthread_create.c:306 - 306 pthread_create.c: No such file or directory. - -Nope. - -.. code-block:: console - - (gdb) frame 5 - #5 0x0000b5d8 in broadcast (param=) at daemon.c:260 - 260 json_delete(jret); - -Yes, finally something related to pilight. As you can see here, the conflicting line can be found in daemon.c in the function broadcast at line 260. The actual command that leaded to the crash was json_delete. Although we now know that this was the line causing the crash, the actual bug could lay elsewhere. Therefore we continue until the last pilight related frame. - -No useful information in frame 4. So, frame 5 was the only interesting frame here. Make sure to copy the output of the informative frames so it can be used in a forum post later on. - -To exit: - -.. code-block:: console - - (gdb) q - -As you might have seen, this way of debugging makes it a lot easier to track bugging code. gdb will tell you the exact line on which the bug occurred to in can be easier tracked down and fixed. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/development/index.rst b/lib/ESPiLight/pilight/docs/source/development/index.rst deleted file mode 100644 index 879bf94..0000000 --- a/lib/ESPiLight/pilight/docs/source/development/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -Development -=========== - -.. toctree:: - :maxdepth: 1 - - api - debugging \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/electronics/index.rst b/lib/ESPiLight/pilight/docs/source/electronics/index.rst deleted file mode 100644 index baf81b8..0000000 --- a/lib/ESPiLight/pilight/docs/source/electronics/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -Electronics -=========== - -.. toctree:: - :maxdepth: 1 - - wiring - pcb_soldering \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/electronics/pcb_soldering.rst b/lib/ESPiLight/pilight/docs/source/electronics/pcb_soldering.rst deleted file mode 100644 index 062a7d4..0000000 --- a/lib/ESPiLight/pilight/docs/source/electronics/pcb_soldering.rst +++ /dev/null @@ -1,200 +0,0 @@ -PCB Soldering -============= - -- `Introduction`_ -- `PCB Eights`_ - - `Headers`_ - - `Voltage Regulator`_ -- `PCB Quarter`_ - - `P1 Meter`_ -- `PCB Half`_ - - `Pre-Filter`_ -- `PCB Full`_ - -Introduction ------------- - -The pilight PCB can be ordered as a do-it-yourself kit or pre-soldered. In case you want to solder it yourself, this page will show you all steps needed. If you follow all steps, you will eventually end up with the full pilight PCB. However, if you want to leave certain options, just pick the steps you need. - -PCB Eights ----------- - -.. _Headers: -.. rubric:: Headers - -First start by soldering the two headers. This makes it easier to position the rest of the components. - -.. |fig1| image:: ../images/soldering/1.jpg - -.. rst-class:: alt - -+-----------------------+ -| |fig1| | -+-----------------------+ -| Image 1: First Header | -+-----------------------+ - -.. |fig2| image:: ../images/soldering/2.jpg - -.. rst-class:: alt - -+------------------------+ -| |fig2| | -+------------------------+ -| Image 2: Second Header | -+------------------------+ - -As you can see, the second header is wider than the number of pins on the PCB. Just strip the unconnected connections on the left side to make the header evenly wide as the PCB. - -.. |fig3| image:: ../images/soldering/3.jpg - -.. rst-class:: alt - -+---------------------------------+ -| |fig3| | -+---------------------------------+ -| Image 3: Stripped Second Header | -+---------------------------------+ - -.. _Voltage Regulator: -.. rubric:: Voltage Regulator - -The voltage regulator consists of a capacitor, resistor, and transistor. First start by soldering the transistor close to the first header. Make sure to match the flat and rounded side of the transistor as shown on the PCB itself. Also make sure to push the transistor far through enough so it stays under the first header. - -.. |fig4| image:: ../images/soldering/4.jpg - -.. rst-class:: alt - -+---------------------------------------+ -| |fig4| | -+---------------------------------------+ -| Image 4: Voltage Regulator Transistor | -+---------------------------------------+ - -The capacitor can best be solder with a little more slack so you can bend it in such manner that it will stay under the first header. Do not bend it too much because then it can interfere with the resistors needed for the pre-filter. - -.. |fig5| image:: ../images/soldering/5.jpg - -.. rst-class:: alt - -+--------------------------------------+ -| |fig5| | -+--------------------------------------+ -| Image 5: Voltage Regulator Capacitor | -+--------------------------------------+ - -Finish the voltage regulator by soldering the resistor. - -.. |fig6| image:: ../images/soldering/6.jpg - -.. rst-class:: alt - -+-------------------------------------+ -| |fig6| | -+-------------------------------------+ -| Image 6: Voltage Regulator Resistor | -+-------------------------------------+ - -PCB Quarter ------------ - -.. _P1 Meter: -.. rubric:: P1 Meter - -The P1 meter consists of two resistors, a transistor and a wire terminal. Take care in placing the resistors, because they are placed in between the resistors of the pre-filter. Also check if the terminal is not too high for mounting on your final device. For example the System on Module of the Hummingboard together with the P1 terminal make it too high for proper mounting. In this case, leave the terminal and just connect the wires directly to the PCB. - -.. |fig7| image:: ../images/soldering/7.jpg - -.. rst-class:: alt - -+----------------------------------+ -| |fig7| | -+----------------------------------+ -| Image 7: P1 Meter First Resistor | -+----------------------------------+ - -.. |fig8| image:: ../images/soldering/8.jpg - -.. rst-class:: alt - -+-----------------------------------+ -| |fig8| | -+-----------------------------------+ -| Image 8: P1 Meter Second Resistor | -+-----------------------------------+ - -Place the transistor as shown on the PCB, with its flat side to the ATTiny. - -.. |fig9| image:: ../images/soldering/9.jpg - -.. rst-class:: alt - -+------------------------------+ -| |fig9| | -+------------------------------+ -| Image 9: P1 Meter Transistor | -+------------------------------+ - -.. |fig10| image:: ../images/soldering/10.jpg - -.. rst-class:: alt - -+-----------------------------+ -| |fig10| | -+-----------------------------+ -| Image 10: P1 Meter Terminal | -+-----------------------------+ - -PCB Half --------- - -.. _Pre-Filter: -.. rubric:: Pre-Filter - -.. - -.. |fig11| image:: ../images/soldering/11.jpg - -.. rst-class:: alt - -+--------------------------------+ -| |fig11| | -+--------------------------------+ -| Image 11: Pre-Filter Resistors | -+--------------------------------+ - -When installing the socket, please remember where the dot and notch are placed. In the final ATTiny installation, the dot on the PCB and on the ATTiny should match. - -.. |fig12| image:: ../images/soldering/12.jpg - -.. rst-class:: alt - -+-----------------------------+ -| |fig12| | -+-----------------------------+ -| Image 12: Pre-Filter Socket | -+-----------------------------+ - -PCB Full --------- - -.. |fig13| image:: ../images/soldering/13.jpg - -.. rst-class:: alt - -+------------------------------+ -| |fig13| | -+------------------------------+ -| Image 13: PCB Final Top View | -+------------------------------+ - - -.. |fig14| image:: ../images/soldering/14.jpg - -.. rst-class:: alt - -+---------------------------------+ -| |fig14| | -+---------------------------------+ -| Image 14: PCB Final Bottom View | -+---------------------------------+ diff --git a/lib/ESPiLight/pilight/docs/source/electronics/wiring.rst b/lib/ESPiLight/pilight/docs/source/electronics/wiring.rst deleted file mode 100644 index c98ea9a..0000000 --- a/lib/ESPiLight/pilight/docs/source/electronics/wiring.rst +++ /dev/null @@ -1,92 +0,0 @@ -Wiring -====== - -- `Introduction`_ -- `ATTiny pre-filter`_ -- `pilight USB nano`_ - -Introduction ------------- - -The wiring of the different pilight hardware solutions will be described here in the best possible way. Please refer to the Configuration – Hardware page to see how the hardware modules are configured on the software side. - -ATTiny pre-filter ------------------ - -.. only:: html - - .. figure:: ../images/attiny-wiring.svg - :align: left - -.. only: latex - - .. image:: ../images/attiny-wiring.pdf - -The ATTiny pre-filter is meant to filter the noise from 433.92Mhz receivers. Using a filter is not strictly necessary. However, it greatly reduces the CPU usage of your Raspberry Pi (and similar devices) so you can use it for more applications than just pilight. - -Wiring the filter can be done it two steps. A required one, and an optional one. All optional wirings are made purple in the drawing. These wires are only used for firmware upgrades, which only happen rarely. - -The different pins on the Raspberry Pi are numbered from bottom left (Pin 1) and top left (Pin 2) to bottom right (Pin 39) and top right (Pin 40). - -The pins on the receiver (large rectangle) are numbered from left (Pin 1) to right (Pin 8). - -The pins on the ATTiny are numbered from top left (Pin 1) to bottom left (Pin 4) and from bottom right (Pin 5) to top right (Pin 8). - -The pins on the sender (small rectangle) are numbered from left (Pin 1) to right (Pin 4). - -With this information, the following wiring scheme can be used for wiring up the ATTiny pre-filter together with the sender and receiver. - -+--------------+------------------+-+------------+------------------+-+------------+------------------+ -| **Receiver** | **ATTiny** | | **ATTiny** | **Raspberry Pi** | | **Sender** | **Raspberry Pi** | -+--------------+------------------+ +------------+------------------+-+------------+------------------+ -| Pin 7 (Data) | Pin 3 | | Pin 1 | Pin 24 (CE0) | | Pin 1 | Pin 2 (5V) | -+--------------+------------------+ +------------+------------------+-+------------+------------------+ -| **Receiver** | **Raspberry Pi** | | Pin 2 | Pin 12 (GPIO 1) | | Pin 2 | Pin 11 (GPIO 0) | -+--------------+------------------+ +------------+------------------+-+------------+------------------+ -| Pin 5 (VDD) | Pin 2 (5V) | | Pin 4 | Pin 6 (GND) | | Pin 3 | Pin 3 (GND) | -+--------------+------------------+ +------------+------------------+-+------------+------------------+ -| Pin 8 (GND) | Pin 6 (GND) | | Pin 5 | Pin 19 (MOSI) | | | -+--------------+------------------+ +------------+------------------+-+------------+------------------+ -| | | Pin 6 | Pin 21 (MISO) | | | -+--------------+------------------+ +------------+------------------+-+------------+------------------+ -| | | Pin 7 | Pin 23 (SCLK) | | | -+---------------------------------+-+------------+------------------+-+------------+------------------+ - -pilight USB nano ----------------- - -.. only:: html - - .. figure:: ../images/usb-nano-wiring.svg - :align: left - -.. only: latex - - .. image:: ../images/usb-nano-wiring.pdf - -The pilight USB nano allows users to use pilight on any computer with USB support. The wiring scheme of the sender and receiver with the Arduino Nano is shown in the drawing. The Arduino Nano should be connected to the final computer over USB. - -The pins on the Arduino Nano are as follow: - -+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ -| VIN | GND | RST | 5V | A7 | A6 | A5 | A4 | A3 | A1 | A2 | A0 | REF | 3V3 | D13 | | -+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ USB + -| TX1 | RX0 | RST | GND | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | D10 | D11 | D12 | | -+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ - -The pins on the receiver are numbered from left (Pin 1) to right (Pin 8). - -The pins on the sender are numbered from left (Pin 1) to right (Pin 4). - -With all this information, the following wiring scheme can be used for wiring up the pilight USB nano together with the sender and receiver. - -+--------------+----------+-+--------------+----------+ -| **Receiver** | **Nano** | | **Sender** | **Nano** | -+--------------+----------+ +--------------+----------+ -| Pin 1 (VDD) | 5V | | Pin 1 (GND) | GND | -+--------------+----------+ +--------------+----------+ -| Pin 7 (Data) | D2 | | Pin 2 (Data) | D5 | -+--------------+----------+ +--------------+----------+ -| Pin 8 (GND) | GND | | Pin 3 (VDD) | 5V | -+--------------+----------+-+--------------+----------+ - diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/dim.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/dim.rst deleted file mode 100644 index fbc93aa..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/dim.rst +++ /dev/null @@ -1,76 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Dim -=== - -.. rubric:: Description - -Dims a device to a dimlevel or starts a sequence from one dimlevel to another. - -.. rubric:: Options - -+----------+------------------+---------------------+-------------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+-------------------------------------------------------+ -| DEVICE | |yes| | |yes| | Device(s) to change | -+----------+------------------+---------------------+-------------------------------------------------------+ -| TO | |yes| | |no| | New dimlevel | -+----------+------------------+---------------------+-------------------------------------------------------+ - -.. versionadded:: 7.0 - -+----------+------------------+---------------------+-------------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+-------------------------------------------------------+ -| FOR | |no| | |no| | | Determine how long this new state lasts before | -| | | | | we change back to the previous dimlevel and state | -+----------+------------------+---------------------+-------------------------------------------------------+ -| AFTER | |no| | |no| | After how long do we want the new state to be set | -+----------+------------------+---------------------+-------------------------------------------------------+ -| IN | |no| | |no| | | To be combined with FROM. In what time do we want | -| | | | | to change the dimlevel FROM x TO y | -+----------+------------------+---------------------+-------------------------------------------------------+ -| FROM | |no| | |no| | | To be combined with IN. From what dimlevel do we | -| | | | | want to start a sequence to the target dimlevel | -+----------+------------------+---------------------+-------------------------------------------------------+ - -.. note:: Units for ``FOR``, ``AFTER``, and ``IN`` - - - MILLISECOND - - SECOND - - MINUTE - - HOUR - - DAY - -.. rubric:: Examples - -.. code-block:: console - - IF 1 == 1 THEN dim DEVICE mainlight TO 15 - IF 1 == 1 THEN dim DEVICE mainlight AND bookshelve AND hall TO 10 - -.. versionadded:: 7.0 - -.. code-block:: console - - IF 1 == 1 THEN dim DEVICE mainlight TO 15 FOR 10 MINUTE - IF 1 == 1 THEN dim DEVICE mainlight TO 15 AFTER 30 SECOND - IF 1 == 1 THEN dim DEVICE mainlight TO 15 AFTER 30 SECOND FOR 10 MINUTE - IF 1 == 1 THEN dim DEVICE mainlight TO 15 FROM 0 IN 45 MINUTE - IF 1 == 1 THEN dim DEVICE mainlight TO 15 FROM 0 IN 45 MINUTE FOR 15 MINUTE AFTER 5 MINUTE - IF 1 == 1 THEN switch DEVICE light TO off FOR 10 SECOND AFTER 30 MINUTE - -.. versionchanged:: 8.1.0 - -.. code-block:: console - - IF 1 == 1 THEN dim DEVICE mainlight TO 15 FOR '10 MINUTE' - IF 1 == 1 THEN dim DEVICE mainlight TO 15 AFTER '30 SECOND' - IF 1 == 1 THEN dim DEVICE mainlight TO 15 AFTER '30 SECOND' FOR '10 MINUTE' - IF 1 == 1 THEN dim DEVICE mainlight TO 15 FROM 0 IN '45 MINUTE' - IF 1 == 1 THEN dim DEVICE mainlight TO 15 FROM 0 IN '45 MINUTE' FOR '15 MINUTE' AFTER '5 MINUTE' - IF 1 == 1 THEN switch DEVICE light TO off FOR '10 SECOND' AFTER '30 MINUTE' \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/index.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/index.rst deleted file mode 100644 index b16a304..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/index.rst +++ /dev/null @@ -1,21 +0,0 @@ -Actions -======= - -.. versionadded:: 6.0 - -.. toctree:: - :maxdepth: 1 - - dim - pushover - switch - toggle - -.. versionadded:: 7.0 - -.. toctree:: - :maxdepth: 1 - - label - pushbullet - sendmail \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/label.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/label.rst deleted file mode 100644 index 77617c1..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/label.rst +++ /dev/null @@ -1,59 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Label -===== - -.. rubric:: Description - -Changes the text and color of a generic label device. - -.. rubric:: Options - -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| DEVICE | |yes| | |yes| | Device(s) to change | -+----------+------------------+---------------------+---------------------------------------------------+ -| TO | |yes| | |no| | New text | -+----------+------------------+---------------------+---------------------------------------------------+ -| COLOR | |no| | |no| | New color. If omitted, color is set to black | -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| FOR | |no| | |no| | | Determine how long this new label lasts | -| | | | | before we change back to the previous label | -+----------+------------------+---------------------+---------------------------------------------------+ -| AFTER | |no| | |no| | After how long do we want the new label to be set | -+----------+------------------+---------------------+---------------------------------------------------+ - -.. note:: Units for ``FOR`` and ``AFTER`` - - - MILLISECOND - - SECOND - - MINUTE - - HOUR - - DAY - -.. rubric:: Examples - -.. code-block:: console - - IF 1 == 1 THEN label DEVICE tempLabel TO on - IF 1 == 1 THEN label DEVICE tempLabel AND humiLabel TO No information - IF 1 == 1 THEN label DEVICE tempLabel TO 23.5 FOR 10 SECOND - IF 1 == 1 THEN label DEVICE tempLabel TO Bell rang AFTER 30 SECOND - IF 1 == 1 THEN label DEVICE tempLabel TO None FOR 10 MINUTE AFTER 30 SECOND - -.. versionchanged:: 8.1.0. - -.. code-block:: console - - IF 1 == 1 THEN label DEVICE tempLabel TO on - IF 1 == 1 THEN label DEVICE tempLabel AND humiLabel TO 'No information' - IF 1 == 1 THEN label DEVICE tempLabel TO 23.5 FOR '10 SECOND' - IF 1 == 1 THEN label DEVICE tempLabel TO 'Bell rang' AFTER '30 SECOND' - IF 1 == 1 THEN label DEVICE tempLabel TO None FOR '10 MINUTE' AFTER '30 SECOND' \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/pushbullet.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/pushbullet.rst deleted file mode 100644 index ebdfef4..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/pushbullet.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Pushbullet -========== - -.. rubric:: Description - -Send a message to your mobile phone with the pushbullet API - -.. rubric:: Options - -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| TITLE | |yes| | |no| | | -+----------+------------------+---------------------+---------------------------------------------------+ -| BODY | |yes| | |no| | | -+----------+------------------+---------------------+---------------------------------------------------+ -| TOKEN | |yes| | |no| | Unique pushbullet user account token | -+----------+------------------+---------------------+---------------------------------------------------+ -| TYPE | |yes| | |no| | Message type | -+----------+------------------+---------------------+---------------------------------------------------+ - -.. rubric:: Example - -.. code-block:: console - - IF 1 == 1 THEN pushbullet TITLE Doorbell rang BODY Doorbell rang TOKEN abcd123abc TYPE note - -.. versionchanged:: 8.1.0 - -.. code-block:: console - - IF 1 == 1 THEN pushbullet TITLE 'Doorbell rang' BODY 'Doorbell rang' TOKEN abcd123abc TYPE note \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/pushover.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/pushover.rst deleted file mode 100644 index 3c64033..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/pushover.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Pushover -======== - -.. rubric:: Description - -Send a message to your mobile phone with the pushover API - -.. rubric:: Options - -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| TITLE | |yes| | |no| | | -+----------+------------------+---------------------+---------------------------------------------------+ -| MESSAGE | |yes| | |no| | | -+----------+------------------+---------------------+---------------------------------------------------+ -| TOKEN | |yes| | |no| | Unique pushover user account token | -+----------+------------------+---------------------+---------------------------------------------------+ -| USER | |yes| | |no| | Unique pushover username | -+----------+------------------+---------------------+---------------------------------------------------+ - -.. rubric:: Example - -.. code-block:: console - - IF 1 == 1 THEN pushover TITLE Doorbell rang MESSAGE Doorbell rang TOKEN abcd123abc USER pilight - -.. versionchanged:: 8.1.0 - -.. code-block:: console - - IF 1 == 1 THEN pushover TITLE 'Doorbell rang' MESSAGE 'Doorbell rang' TOKEN abcd123abc USER pilight diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/sendmail.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/sendmail.rst deleted file mode 100644 index c2e74d2..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/sendmail.rst +++ /dev/null @@ -1,52 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Sendmail -======== - -.. rubric:: Description - -Send a message to any e-mail address - -.. rubric:: Options - -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| TO | |yes| | |no| | | -+----------+------------------+---------------------+---------------------------------------------------+ -| SUBJECT | |yes| | |no| | | -+----------+------------------+---------------------+---------------------------------------------------+ -| MESSAGE | |yes| | |no| | | -+----------+------------------+---------------------+---------------------------------------------------+ - -.. note:: - - The ``sendmail`` action requires some additional settings in the pilight configuration: - - .. code-block:: json - - { - "settings": { - "smtp-sender": "sender@domain.com", - "smtp-host": "smtp.smtphost.com", - "smtp-port": 465, - "smtp-user": "smtpuser@domain.com", - "smtp-password": "password" - } - } - -.. rubric:: Examples - -.. code-block:: console - - IF 1 == 1 THEN sendmail SUBJECT Doorbell rang MESSAGE Doorbell rang TO someone@somewhere.com - -.. versionchanged:: 8.1.0 - -.. code-block:: console - - IF 1 == 1 THEN sendmail SUBJECT 'Doorbell rang' MESSAGE 'Doorbell rang' TO someone@somewhere.com \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/switch.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/switch.rst deleted file mode 100644 index 0cbe562..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/switch.rst +++ /dev/null @@ -1,64 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Switch -====== - -.. rubric:: Description - -Changes the state of a switch, relay or dimmer. - -.. rubric:: Options - -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| DEVICE | |yes| | |yes| | Device(s) to change | -+----------+------------------+---------------------+---------------------------------------------------+ -| TO | |yes| | |no| | New state | -+----------+------------------+---------------------+---------------------------------------------------+ - -.. versionadded:: 7.0 - -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| FOR | |no| | |no| | | Determine how long this new state lasts | -| | | | | before we change back to the previous state | -+----------+------------------+---------------------+---------------------------------------------------+ -| AFTER | |no| | |no| | After how long do we want the new state to be set | -+----------+------------------+---------------------+---------------------------------------------------+ - -.. note:: Units for ``FOR`` and ``AFTER`` - - - MILLISECOND - - SECOND - - MINUTE - - HOUR - - DAY - -.. rubric:: Examples - -.. code-block:: console - - IF 1 == 1 THEN switch DEVICE light TO on - IF 1 == 1 THEN switch DEVICE mainlight AND bookshelve AND hall TO on - -.. versionadded:: 7.0 - -.. code-block:: console - - IF 1 == 1 THEN switch DEVICE light TO on FOR 10 MINUTE - IF 1 == 1 THEN switch DEVICE light TO on AFTER 30 MILLISECOND - IF 1 == 1 THEN switch DEVICE light TO off FOR 10 SECOND AFTER 30 MINUTE - -.. versionchanged:: 8.1.0 - -.. code-block:: console - - IF 1 == 1 THEN switch DEVICE light TO on FOR '10 MINUTE' - IF 1 == 1 THEN switch DEVICE light TO on AFTER '30 MILLISECOND' - IF 1 == 1 THEN switch DEVICE light TO off FOR '10 SECOND' AFTER '30 MINUTE' \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/actions/toggle.rst b/lib/ESPiLight/pilight/docs/source/eventing/actions/toggle.rst deleted file mode 100644 index 46c876d..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/actions/toggle.rst +++ /dev/null @@ -1,30 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Toggle -====== - -.. rubric:: Description - -Toggles a device between state X and state Y. This action is especially made for ``one-shot`` devices such as a remote control button where a normal separate 'switch-on' and separate 'switch-off' rule doesn't apply. This action will check what the current state of a device is, and will change it to the non-current state. - -.. rubric:: Options - -+----------+------------------+---------------------+---------------------------------------------------+ -| **Name** | **Required** | **Multiple Values** | **Description** | -+----------+------------------+---------------------+---------------------------------------------------+ -| DEVICE | |yes| | |yes| | Device(s) to change | -+----------+------------------+---------------------+---------------------------------------------------+ -| BETWEEN | |yes| | |no| | State 1 | -+----------+------------------+---------------------+---------------------------------------------------+ -| AND | |no| | |no| | State 2 | -+----------+------------------+---------------------+---------------------------------------------------+ - -.. rubric:: Example - -.. code-block:: console - - IF 1 == 1 THEN toggle DEVICE television BETWEEN on AND off \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/examples/index.rst b/lib/ESPiLight/pilight/docs/source/eventing/examples/index.rst deleted file mode 100644 index f90f765..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/examples/index.rst +++ /dev/null @@ -1,12 +0,0 @@ -Examples -======== - -.. toctree:: - :maxdepth: 1 - - ir - kodi - mail - mail1 - sunriseset - time \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/examples/ir.rst b/lib/ESPiLight/pilight/docs/source/eventing/examples/ir.rst deleted file mode 100644 index f323c22..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/examples/ir.rst +++ /dev/null @@ -1,62 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -IR Remote -========= - -.. rubric:: Description - -Switch devices based on your IR remote buttons - -.. rubric:: Devices - -.. code-block:: json - :linenos: - - { - "devices": { - "television": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456, - "unit": 0 - }], - "state": "off" - }, - "remote": { - "protocol": [ "lirc" ], - "id": [{ - "remote": "logitech" - }], - "code": "000000000000e290", - "repeat": 2, - "button": "KEY_P" - } - } - -.. rubric:: Rule - -.. code-block:: json - :linenos: - - { - "remote-television-switch": { - "rule": "IF remote.button IS KEY_P AND remote.repeat == 0 THEN toggle DEVICE television BETWEEN on AND off", - "active": 1 - } - } - -.. versionchanged:: 8.1.0 - -.. code-block:: json - :linenos: - - { - "remote-television-switch": { - "rule": "IF remote.button == KEY_P AND remote.repeat == 0 THEN toggle DEVICE television BETWEEN on AND off", - "active": 1 - } - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/examples/kodi.rst b/lib/ESPiLight/pilight/docs/source/eventing/examples/kodi.rst deleted file mode 100644 index 989b426..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/examples/kodi.rst +++ /dev/null @@ -1,69 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -XBMC / Kodi -=========== - -.. rubric:: Description - -Execute rules based on XBMC / KODI based events - -.. rubric:: Devices - -.. code-block:: json - :linenos: - - { - "xbmcControls": { - "protocol": [ "xbmc" ], - "id": [{ - "server": "127.0.0.1", - "port": 9090 - }], - "action": "home", - "media": "none" - }, - "speakers": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456, - "unit": 4 - }], - "state": "off" - } - } - -.. rubric:: Rule - -.. code-block:: json - :linenos: - - { - "speakers-on": { - "rule": "IF xbmcControls.action IS play THEN switch DEVICE speakers TO on", - "active": 1 - }, - "speakers-off": { - "rule": "IF xbmcControls.action IS pause OR xbmcControls.action IS home THEN switch DEVICE speakers TO off AFTER 3 MINUTES", - "active": 1 - } - } - -.. versionchanged:: 8.1.0 - -.. code-block:: json - :linenos: - - { - "speakers-on": { - "rule": "IF xbmcControls.action == play THEN switch DEVICE speakers TO on", - "active": 1 - }, - "speakers-off": { - "rule": "IF xbmcControls.action == pause OR xbmcControls.action == home THEN switch DEVICE speakers TO off AFTER '3 MINUTES'", - "active": 1 - } - } diff --git a/lib/ESPiLight/pilight/docs/source/eventing/examples/mail.rst b/lib/ESPiLight/pilight/docs/source/eventing/examples/mail.rst deleted file mode 100644 index 8307df3..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/examples/mail.rst +++ /dev/null @@ -1,67 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Mail on contact trigger -======================= - -.. rubric:: Description - -Sending a mail based on a contact device trigger including the time when it happened. - -.. rubric:: Devices - -.. code-block:: json - :linenos: - - { - "currentdatetime": { - "protocol": [ "datetime" ], - "id": [{ - "longitude": 1.2345, - "latitude": 12.3456 - }], - "year": 2015, - "month": 1, - "day": 27, - "hour": 14, - "minute": 37, - "second": 8, - "weekday": 3, - "dst": 1 - }, - "frontdoor-contact": { - "protocol": [ "kaku_contact" ], - "id": [{ - "id": 123456, - "unit": 0 - }], - "state": "opened" - } - } - -.. rubric:: Rule - -.. code-block:: json - :linenos: - - { - "frontdoor-contact-mail": { - "rule": "IF frontdoor-contact.state IS opened THEN sendmail TO foo@bar.com SUBJECT Frontdoor was opened at DATE_FORMAT(currentdatetime, %c) MESSAGE .", - "active": 1 - } - } - -.. versionchanged:: 8.1.0 - -.. code-block:: json - :linenos: - - { - "frontdoor-contact-mail": { - "rule": "IF frontdoor-contact.state == opened THEN sendmail TO foo@bar.com SUBJECT 'Frontdoor was opened at ' . DATE_FORMAT(currentdatetime, %c) MESSAGE ..", - "active": 1 - } - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/examples/mail1.rst b/lib/ESPiLight/pilight/docs/source/eventing/examples/mail1.rst deleted file mode 100644 index 9278c3f..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/examples/mail1.rst +++ /dev/null @@ -1,67 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Mail on computer disconnection -============================== - -.. rubric:: Description - -Send a mail when one of the computer goes offline. - -.. rubric:: Devices - -.. code-block:: json - :linenos: - - { - "currentdatetime": { - "protocol": [ "datetime" ], - "id": [{ - "longitude": 1.2345, - "latitude": 12.3456 - }], - "year": 2015, - "month": 1, - "day": 27, - "hour": 14, - "minute": 37, - "second": 8, - "weekday": 3, - "dst": 1 - }, - "nasPing": { - "protocol": [ "arping" ], - "id": [{ - "mac": "aa:bb:cc:dd:00:11" - }], - "ip": "192.168.1.1", - "state": "connected" - } - } - -.. rubric:: Rule - -.. code-block:: json - :linenos: - - { - "nas-mail": { - "rule": "IF nasPing.state IS disconnected THEN sendmail TO foo@bar.com SUBJECT NAS is offline since DATE_FORMAT(currentdatetime, %c) MESSAGE .", - "active": 1 - } - } - -.. versionchanged:: 8.1.0 - -.. code-block:: json - :linenos: - - { - "nas-mail": { - "rule": "IF nasPing.state IS disconnected THEN sendmail TO foo@bar.com SUBJECT 'NAS is offline since ' . DATE_FORMAT(currentdatetime, %c) MESSAGE ..", - "active": 1 - } - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/examples/sunriseset.rst b/lib/ESPiLight/pilight/docs/source/eventing/examples/sunriseset.rst deleted file mode 100644 index b206cab..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/examples/sunriseset.rst +++ /dev/null @@ -1,147 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Sunrise / Sunset Event -====================== - -.. rubric:: Description - -This rule executes when the sun sets or rises. - -.. rubric:: Devices - -.. code-block:: json - :linenos: - - { - "devices": { - "currentdatetime": { - "protocol": [ "datetime" ], - "id": [{ - "longitude": 1.2345, - "latitude": 12.3456 - }], - "year": 2015, - "month": 1, - "day": 27, - "hour": 14, - "minute": 37, - "second": 8, - "weekday": 3, - "dst": 1 - }, - "sunrisesetdevice": { - "protocol": [ "sunriseset" ], - "id": [{ - "longitude": 1.234567, - "latitude": 12.123456 - }], - "sunrise": 6.40, - "sunset": 18.50, - "sun": "rise" - }, - "light": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456, - "unit": 0 - }], - "state": "off" - } - } - } - -.. rubric:: Rule - -By using math - -.. code-block:: json - :linenos: - - { - "sunset": { - "rule": "IF ((sunrisesetdevice.sunset == (currentdatetime.hour + (currentdatetime.minute / 100)) AND light.state IS off) AND currentdatetime.second == 0) THEN switch DEVICE light TO on", - "active": 1 - }, - "sunrise": { - "rule": "IF ((sunrisesetdevice.sunrise == (currentdatetime.hour + (currentdatetime.minute / 100)) AND light.state IS off) AND currentdatetime.second == 0) THEN switch DEVICE light TO on", - "active": 1 - } - } - -By using the DATE_FORMAT function - -.. code-block:: json - :linenos: - - { - "sunset": { - "rule": "IF (sunrisesetdevice.sunset == DATE_FORMAT(currentdatetime, %H.%M)) AND light.state IS off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", - "active": 1 - }, - "sunrise": { - "rule": "IF (sunrisesetdevice.sunrise == DATE_FORMAT(currentdatetime, %H.%M)) AND light.state IS off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", - "active": 1 - } - } - -Or an hour before the sun sets: - -.. code-block:: json - :linenos: - - { - "sunset": { - "rule": "IF (sunrisesetdevice.sunset == DATE_FORMAT(DATE_ADD(currentdatetime, +1 HOUR), \"%Y-%m-%d %H:%M:%S\", %H.%M)) AND light.state IS off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", - "active": 1 - } - } - -.. versionchanged:: 8.1.0 - -By using math - -.. code-block:: json - :linenos: - - { - "sunset": { - "rule": "IF ((sunrisesetdevice.sunset == (currentdatetime.hour + (currentdatetime.minute / 100)) AND light.state == off) AND currentdatetime.second == 0) THEN switch DEVICE light TO on", - "active": 1 - }, - "sunrise": { - "rule": "IF ((sunrisesetdevice.sunrise == (currentdatetime.hour + (currentdatetime.minute / 100)) AND light.state == off) AND currentdatetime.second == 0) THEN switch DEVICE light TO on", - "active": 1 - } - } - -By using the DATE_FORMAT function - -.. code-block:: json - :linenos: - - { - "sunset": { - "rule": "IF (sunrisesetdevice.sunset == DATE_FORMAT(currentdatetime, %H.%M)) AND light.state == off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", - "active": 1 - }, - "sunrise": { - "rule": "IF (sunrisesetdevice.sunrise == DATE_FORMAT(currentdatetime, %H.%M)) AND light.state == off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", - "active": 1 - } - } - -Or an hour before the sun sets: - -.. code-block:: json - :linenos: - - { - "sunset": { - "rule": "IF (sunrisesetdevice.sunset == DATE_FORMAT(DATE_ADD(currentdatetime, '+1 HOUR'), '%Y-%m-%d %H:%M:%S', %H.%M)) AND light.state == off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", - "active": 1 - } - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/examples/time.rst b/lib/ESPiLight/pilight/docs/source/eventing/examples/time.rst deleted file mode 100644 index 35fc021..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/examples/time.rst +++ /dev/null @@ -1,67 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Time based -========== - -.. rubric:: Description - -Trigger events based on time - -.. rubric:: Devices - -.. code-block:: json - :linenos: - - { - "currentdatetime": { - "protocol": [ "datetime" ], - "id": [{ - "longitude": 1.2345, - "latitude": 12.3456 - }], - "year": 2015, - "month": 1, - "day": 27, - "hour": 14, - "minute": 37, - "second": 8, - "weekday": 3, - "dst": 1 - }, - "outsidelight": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 123456, - "unit": 0 - }], - "state": "off" - } - } - -.. rubric:: Rule - -.. code-block:: json - :linenos: - - { - "christmass-tree-off": { - "rule": "IF DATE_FORMAT(currentdatetime, %H.%M%S) == 23.0000 THEN switch DEVICE outsidelight TO on AFTER RANDOM(0, 90) MINUTE FOR RANDOM(5, 15) MINUTE", - "active": 1 - } - } - -.. versionchanged:: 8.1.0 - -.. code-block:: json - :linenos: - - { - "christmass-tree-off": { - "rule": "IF DATE_FORMAT(currentdatetime, %H.%M%S) == 23.0000 THEN switch DEVICE outsidelight TO on AFTER RANDOM(0, 90) . ' MINUTE' FOR RANDOM(5, 15) . ' MINUTE'", - "active": 1 - } - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/functions/date_add.rst b/lib/ESPiLight/pilight/docs/source/eventing/functions/date_add.rst deleted file mode 100644 index 9b39b56..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/functions/date_add.rst +++ /dev/null @@ -1,56 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -date_add -======== - -.. rubric:: Description - -Calculations with date and time values. - -.. rubric:: Arguments - -+----------+------------------+------------------------------------------+ -| **#** | **Required** | **Description** | -+----------+------------------+------------------------------------------+ -| 1 | |yes| | | A datetime device or a datetime string | -| | | | The datetime string must be in the | -| | | | format YYYY-MM-DD HH:MM:SS. | -+----------+------------------+------------------------------------------+ -| 2 | |yes| | | A number and unit. The number can be | -| | | | either positive or negative. | -| | | | The unit can be | -| | | | - SECOND | -| | | | - MINUTE | -| | | | - HOUR | -| | | | - DAY | -| | | | - MONTH | -| | | | - YEAR | -+----------+------------------+------------------------------------------+ - -.. rubric:: Return value - -The returned datetime string is always in the format ``%Y-%m-%d %H:%M:%S``. So in case of the third example, the output will be ``"2016-01-01 00:00:00"``. - -.. rubric:: Examples - -.. code-block:: console - - IF DATE_ADD(datetime, +1 HOUR) == ... - IF DATE_ADD(datetime, -1 DAY) == ... - IF DATE_ADD(2015-12-31, 23:59:59, +1 SECOND) == ... - IF DATE_ADD(datetime, RANDOM(-3, +3) DAY) == ... - IF DATE_FORMAT(DATE_ADD(2015-01-01 21:00:00, RANDOM(0, 120) MINUTE), \"%Y-%m-%d %H:%M:%S\", %H.%M) == ... - -.. versionchanged:: 8.1.0 - -.. code-block:: console - - IF DATE_ADD(datetime, '+1 HOUR') == ... - IF DATE_ADD(datetime, '-1 DAY') == ... - IF DATE_ADD('2015-12-31, 23:59:59', '+1 SECOND') == ... - IF DATE_ADD(datetime, RANDOM(-3, +3) . ' DAY') == ... - IF DATE_FORMAT(DATE_ADD('2015-01-01 21:00:00', RANDOM(0, 120) . ' MINUTE'), '%Y-%m-%d %H:%M:%S', %H.%M) == ... diff --git a/lib/ESPiLight/pilight/docs/source/eventing/functions/date_format.rst b/lib/ESPiLight/pilight/docs/source/eventing/functions/date_format.rst deleted file mode 100644 index 53e6739..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/functions/date_format.rst +++ /dev/null @@ -1,152 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -date_format -=========== - -.. rubric:: Description - -Reformat date and time values - -.. rubric:: Arguments - -+----------+------------------+------------------------------------------+ -| **#** | **Required** | **Description** | -+----------+------------------+------------------------------------------+ -| **Using two parameters** | -+----------+------------------+------------------------------------------+ -| 1 | |yes| | A datetime device | -+----------+------------------+------------------------------------------+ -| 2 | |yes| | Output format (see below) | -+----------+------------------+------------------------------------------+ -| **Using three parameters** | -+----------+------------------+------------------------------------------+ -| 1 | |yes| | A datetime string | -+----------+------------------+------------------------------------------+ -| 2 | |yes| | Input format (see below) | -+----------+------------------+------------------------------------------+ -| 3 | |yes| | Output format (see below) | -+----------+------------------+------------------------------------------+ - -.. note:: **Input / output** - - Consider that the flexibility of the function depends on the input. If you input just ``%H:%M:%S``, the DATE_FORMAT can't output a format like this ``%Y-%m-%d``, because the function didn't receive any date information. It only received time information. So, DATE_FORMAT can't be used to exterpolate information that's not present. - -.. rubric:: Return value - -The function will output the exact format as requested in the last (second or third argument). There are a few things you must consider when working with the DATE_FORMAT function. The types of operators you can use with DATE_FORMAT depends on the output format requested. If you want to compare the output format ``%c`` you can only use the ``IS`` operator, because the final output will be interpreted as a string value. If you want to compare ``%H.%M``, you will need numeric operators like ``==``, ``>``, or ``<``, because the output will be evaluated as a number. - -Also consider the usage of quotes. The flexibility in which DATE_FORMAT can format date and time values isn't always accepted by pilight. For example: ``DATE_FORMAT(datetime, %c)`` outputs ``Fri Apr 24 11:35:36 2015`` which pilight subsequently can't handle. If you want to output string like this, use quotes ``DATE_FORMAT(datetime, "%c")``, which will output as ``"Fri Apr 24 11:35:36 2015"``. - -.. rubric:: Examples - -.. code-block:: console - - IF DATE_ADD(datetime, +1 HOUR) == ... - IF DATE_ADD(datetime, -1 DAY) == ... - IF DATE_ADD(2015-12-31, 23:59:59, +1 SECOND) == ... - IF DATE_ADD(datetime, RANDOM(-3, +3) DAY) == ... - IF DATE_FORMAT(DATE_ADD(2015-01-01 21:00:00, RANDOM(0, 120) MINUTE), \"%Y-%m-%d %H:%M:%S\", %H.%M) == ... - -.. versionchanged:: 8.1.0 - -.. code-block:: console - - IF DATE_ADD(datetime, '+1 HOUR') == ... - IF DATE_ADD(datetime, '-1 DAY') == ... - IF DATE_ADD(2015-12-31, 23:59:59, '+1 SECOND') == ... - IF DATE_ADD(datetime, RANDOM(-3, +3) . ' DAY') == ... - IF DATE_FORMAT(DATE_ADD('2015-01-01 21:00:00', RANDOM(0, 120) . ' MINUTE'), '%Y-%m-%d %H:%M:%S', %H.%M) == ... - -.. note:: **DATE_ADD as an argument** - -When you use DATE_ADD as the first argument, you should consider the return value of DATE_ADD, because that's what DATE_FORMAT will eventually receive. The output format of DATE_ADD is ``"%Y-%m-%d %H:%M:%S"``, so the input format for DATE_FORMAT should be the same. - -.. rubric:: Formatting characters - -+---------------+------------------------------------------------------------------------+--------------------------+ -| **Specifier** | **Replaced by** | **Example** | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %a | Abbreviated weekday name [#f1]_ | Thu | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %A | Full weekday name [#f1]_ | Thursday | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %b %h | Abbreviated month name [#f1]_ | Aug | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %B | Full month name [#f1]_ | August | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %c | Date and time representation [#f1]_ | Thu Aug 23 14:55:02 2001 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %C | Year divided by 100 and truncated to integer (00-99) | 20 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %d | Day of the month, zero-padded (01-31) | 23 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %D | Short MM/DD/YY date, equivalent to %m/%d/%y | 08/23/01 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %e | Day of the month, space-padded (1-31) | 23 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %F | Short YYYY-MM-DD date, equivalent to %Y-%m-%d | 2001-08-23 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %g | Week-based year, last two digits (00-99) | 01 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %G | Week-based year | 2001 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %g | Week-based year | 2001 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %H | Hour in 24h format (00-23) | 14 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %I | Hour in 12h format (01-12) | 02 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %j | Day of the year (001-366) | 235 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %m | Month as a decimal number (01-12) | 08 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %M | Minute (00-59) | 55 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %n | New-line character ('\n') | | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %p | AM or PM designation | PM | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %r | 12-hour clock time [#f1]_ | 02:55:02 pm | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %R | 24-hour HH:MM time, equivalent to %H:%M | 14:55 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %S | Second (00-61) | 02 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %t | Horizontal-tab character ('\t') | | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %T | ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S | 14:55:02 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %u | ISO 8601 weekday as number with Monday as 1 (1-7) | 4 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %U | Week number with the first Sunday as the first day of week one (00-53) | 33 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %V | ISO 8601 week number (01-53) | 34 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %w | Weekday as a decimal number with Sunday as 0 (0-6) | 4 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %W | Week number with the first Monday as the first day of week one (00-53) | 34 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %x | Date representation [#f1]_ | 08/23/01 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %X | Time representation [#f1]_ | 14:55:02 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %y | Year, last two digits (00-99) | 01 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %Y | Year | 2001 | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %z | | ISO 8601 offset from UTC in timezone (1 minute=1, 1 hour=100) | +100 | -| | | If timezone cannot be determined, no characters | | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %Z | | Timezone name or abbreviation [#f1]_ | CDT | -| | | If timezone cannot be determined, no characters | | -+---------------+------------------------------------------------------------------------+--------------------------+ -| %% | A ``%`` sign | % | -+---------------+------------------------------------------------------------------------+--------------------------+ - -Copied from http://www.cplusplus.com/reference/ctime/strftime/ - -.. [#f1] These specifiers are locale-dependent. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/functions/index.rst b/lib/ESPiLight/pilight/docs/source/eventing/functions/index.rst deleted file mode 100644 index d6a376d..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/functions/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Functions -========= - -.. versionadded:: 7.0 - -.. toctree:: - :maxdepth: 1 - - random - date_add - date_format \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/functions/random.rst b/lib/ESPiLight/pilight/docs/source/eventing/functions/random.rst deleted file mode 100644 index 2a56db4..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/functions/random.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -random -====== - -.. rubric:: Description - -Generate a random number. - -.. rubric:: Parameters - -+----------+------------------+---------------------+ -| **#** | **Required** | **Description** | -+----------+------------------+---------------------+ -| 1 | |yes| | Lower boundary | -+----------+------------------+---------------------+ -| 2 | |yes| | Higher boundary | -+----------+------------------+---------------------+ - -.. rubric:: Return value - -A random number - -.. rubric:: Examples - -.. code-block:: console - - IF RANDOM(0, 10) == 5 THEN ... - IF RANDOM(1, 100) == 10 THEN ... - IF RANDOM(randomLow.dimlevel, randomHigh.dimlevel) == 10 THEN ... \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/index.rst b/lib/ESPiLight/pilight/docs/source/eventing/index.rst deleted file mode 100644 index adb5f5f..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Eventing -======== - -.. toctree:: - :maxdepth: 2 - - syntax - operators - actions/index - functions/index - examples/index \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/eventing/operators.rst b/lib/ESPiLight/pilight/docs/source/eventing/operators.rst deleted file mode 100644 index f94c96b..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/operators.rst +++ /dev/null @@ -1,106 +0,0 @@ -Operators -========= - -.. rubric:: Arithmetic - -+--------------+-------------------------------------------------+--------------------------+ -| **Operator** | **Description** | **Example** | -+--------------+-------------------------------------------------+--------------------------+ -| \+ | Adds two operands. | 10 + 20 = 30 | -+--------------+-------------------------------------------------+--------------------------+ -| − | Subtracts second operand from the first. | 10 − 20 = -10 | -+--------------+-------------------------------------------------+--------------------------+ -| \* | Multiplies both operands. | 10 * 20 = 200 | -+--------------+-------------------------------------------------+--------------------------+ -| / | Divides numerator by de-numerator. | | 10 / 20 = 2 | -| | | | 10 / 3 = 3.333... | -+--------------+-------------------------------------------------+--------------------------+ -| \\ [#f1]_ | Integer divides numerator by de-numerator. | 10 \\ 3 = 3 | -+--------------+-------------------------------------------------+--------------------------+ -| % | Remainder after an integer division. | | 20 % 10 = 0 | -| | | | 11 % 3 = 2 | -+--------------+-------------------------------------------------+--------------------------+ - -.. [#f1] The backslash is also used as an ``escape`` character. So if you want to use the intdivide operator inside a rule you must write your rulses like this: - - .. code-block:: json - - { - "rules": { - "rule": "IF 3 \\ 2 = 1 THEN switch DEVICE light TO on", - "active": 1 - } - } - -.. rubric:: Relational - -+--------------+-------------------------------------------------+--------------------------+ -| **Operator** | **Description** | **Example** | -+--------------+-------------------------------------------------+--------------------------+ -| == | | Checks if the first and second (nummeric) | | 20 == 10 = false | -| | | operand are equal. | | 10 == 10 = true | -+--------------+-------------------------------------------------+--------------------------+ -| != | | Checks if the first and second (nummeric) | | 20 != 10 = true | -| | | operand are unequal. | | 10 != 10 = false | -+--------------+-------------------------------------------------+--------------------------+ -| IS | | Checks if the first and second (character) | | a IS b = false | -| | | operand are equal. | | a IS a = true | -+--------------+-------------------------------------------------+--------------------------+ -| >= | | Checks if the first operand is greater or | | 20 >= 10 = true | -| | | equal to the second operand. | | 10 >= 20 = false | -| | | | 10 >= 10 = true | -+--------------+-------------------------------------------------+--------------------------+ -| > | | Checks if the first operand is greater than | | 20 > 10 = true | -| | | the second operand. | | 10 > 20 = false | -| | | | 10 > 10 = false | -+--------------+-------------------------------------------------+--------------------------+ -| <= | | Checks if the first operand is smaller or | | 20 <= 10 = false | -| | | equal to the second operand. | | 10 <= 20 = true | -| | | | 10 <= 10 = true | -+--------------+-------------------------------------------------+--------------------------+ -| < | | Checks if the first operand is smaller than | | 20 < 10 = false | -| | | the second operand. | | 10 < 20 = true | -| | | | 10 < 10 = false | -+--------------+-------------------------------------------------+--------------------------+ - -.. versionadded:: 8.0 ISNOT operator added - -.. deprecated:: 8.1.0 - -+--------------+-------------------------------------------------+--------------------------+ -| **Operator** | **Description** | **Example** | -+--------------+-------------------------------------------------+--------------------------+ -| ISNOT | | Checks if the first and second (character) | | a ISNOT b = true | -| | | operand are equal. | | a ISNOT a = false | -+--------------+-------------------------------------------------+--------------------------+ - -.. rubric:: Logical - -+--------------+-------------------------------------------------+--------------------------+ -| **Operator** | **Description** | **Example** | -+--------------+-------------------------------------------------+--------------------------+ -| AND | | Checks if the first and second operands are | | 1 AND 1 = true | -| | | true. | | 1 AND 0 = false | -| | | - values greater of smaller then 0 are true | | foo AND false = true | -| | | - strings equals to ``0`` are false | | true AND true = true | -| | | - strings other than ``0`` are true | | false AND false = true | -+--------------+-------------------------------------------------+--------------------------+ -| OR | | Checks if the first or second operands are | | 0 OR 0 = false | -| | | true. | | 1 OR 0 = true | -| | | - values greater of smaller then 0 are true | | foo OR false = true | -| | | - strings equals to ``0`` are false | | true OR true = true | -| | | - strings other than ``0`` are true | | false OR false = true | -+--------------+-------------------------------------------------+--------------------------+ - -.. rubric:: Other - -.. versionadded:: 8.1.0 - -+----------------+-------------------------------------------------+--------------------------+ -| **Operator** | **Description** | **Example** | -+----------------+-------------------------------------------------+--------------------------+ -| | . | Concatenates two strings | | a . b == 'ab' | -| | (single dot) | | | a . ' ' . b == 'a b' | -| | | | RANDOM(1, 2) . '34' | -+----------------+-------------------------------------------------+--------------------------+ - diff --git a/lib/ESPiLight/pilight/docs/source/eventing/syntax.rst b/lib/ESPiLight/pilight/docs/source/eventing/syntax.rst deleted file mode 100644 index b189ebf..0000000 --- a/lib/ESPiLight/pilight/docs/source/eventing/syntax.rst +++ /dev/null @@ -1,366 +0,0 @@ -.. role:: event-success -.. role:: event-fail - -Syntax -====== - -- `Introduction`_ -- `Rule Parsing`_ - - `Basic Structure`_ - - `True or False`_ - - `AND and OR`_ - - `Hooks`_ -- `Operator`_ -- `String and Concatenation`_ -- `Devices`_ -- `Functions`_ -- `Actions`_ -- `Using Device Parameters`_ - -Introduction ------------- - -The pilight eventing library allows you to automate your house by writing event rules. These rules tell pilight what should happen at a given time or at a given event. pilight event rules follow the regular mathematical conventions and because you can work with an infinite number of hooks, they can become highly complex but are also highly flexible. - -As with everything inside pilight, the eventing library is also highly modular. This means that the operators, actions, and functions are external modules that can be easily extended. Developers and users do not have to touch the core of the eventing library to add additional features. - -Rule Parsing ------------- - -There are few things that are useful to know before working with pilight event rules. When you better understand how pilight parses the rules, you can write really efficient and advanced rules. - -.. _Basic Structure: -.. rubric:: Basic Structure - -All rules basically consist of the same structure: - -.. code-block:: guess - - IF ... THEN ... - -A rule always start with the IF, followed by the rule logic, and is closed by a THEN. All actions are put after the THEN. - -.. versionadded:: 8.1.0 - -The IF / THEN logic can be expanded by an ELSE. The actions written after the ELSE will be executed if the logic contained in the first if block is false. - -.. code-block:: guess - - IF ... THEN ... ELSE ... - -Or you can nest an infinite number of IF/ELSE conditions by using adding the END keyword - -.. code-block:: guess - - IF ... THEN IF ... THEN ... ELSE ... END ELSE IF ... THEN ... ELSE ... END END - -.. _True or False: - -.. rubric:: True or False - -Let us start with how pilight handles succeeding or failing conditions. pilight converts each logical mathematical and logical step into a true or false. The final condition must be true before triggering an action. If the final result is false, the action is skipped. These two examples will both succeed: - -:event-success:`Succeeds` - -.. code-block:: guess - - IF (1 == 1) == True THEN - -:event-success:`Succeeds` - -.. code-block:: guess - - IF (1 == 1) != False THEN - -These two examples will both fail: - -:event-fail:`Fails` - -.. code-block:: guess - - IF (1 == 0) IS True THEN - -:event-fail:`Fails` - -.. code-block:: guess - - IF (1 != 1) IS False THEN - -.. _AND and OR: -.. rubric:: AND and OR - -In the first examples we only used one condition but this does not allow us to make very advanced and flexible rules. Therefore we need to be able to combine several conditions in a single rule. This is possible by combining them with AND and OR operators. Let us take a look at some basic examples: - -:event-fail:`Fails` - -.. code-block:: guess - - IF 1 == 1 AND 1 == 2 THEN ... - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 1 == 1 OR 1 == 2 THEN ... - -:event-fail:`Fails` - -.. code-block:: guess - - IF 1 == 2 OR 1 == 1 AND 2 == 3 THEN ... - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 1 == 1 OR 1 == 1 AND 2 == 3 THEN ... - -:event-fail:`Fails` - -.. code-block:: guess - - IF 1 == 2 AND 1 == 1 OR 2 == 3 THEN ... - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 1 == 1 AND 2 == 2 OR 2 == 3 THEN ... - -In the first two examples only a single AND and OR operator is used. In the rest of the examples we see multiple AND and OR operators. pilight follows standard operator associativity rules in parsing AND and OR operators. - -.. _Hooks: -.. rubric:: Hooks - -As we saw in our first examples, hooks can be used inside pilight rules. This can be useful to better structure and combine the various conditions of our rules. Let us create even more complex rules and see how hooks can change the outcome of a rule without changing the conditions. - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 1 == 2 OR 2 == 3 AND 2 == 3 OR 1 == 1 THEN ... - -:event-fail:`Fails` - -.. code-block:: guess - - IF (1 == 2 OR 2 == 3) AND (2 == 3 OR 1 == 1) THEN ... - -Operator --------- - -Various mathematical operators can be used to do calculations inside our rules. A list of these operators can be found further on in this manual. pilight follows standard operator associativity rules in parsing mathematical operators. Let us just show some basic self-explanatory examples: - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 1 + 1 == 2 THEN ... - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 2 % 2 == 0 THEN ... - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 1 < 10 THEN ... - -:event-fail:`Fails` - -.. code-block:: guess - - IF 10 / 2 == 4 THEN ... - -String and Concatenation ------------------------- - -.. versionadded:: 8.1.0 - -pilight parses individual components inside a rule by looking at queues like spaces, comma's, hooks, and preserved words (e.g. actions or functions). In any case, pilight can be forces to parse any of these components as strings by enclosing them into quotes. - -:event-success:`Succeeds` - -.. code-block:: guess - - IF 1 + 1 == 3 - 1 THEN ... - -In this case, pilight will compare the outcome of both formulas (which is 2) with each other for further parsing. We can also tell pilight to compare the same formula but now with strings: - -:event-fail:`Fails` - -.. code-block:: guess - - IF '1 + 1' == '3 - 1' THEN ... - -The same formula parsed with two strings will now fail because both strings are not equal anymore. - -It is important to understand how to enforce string parsing when working with functions. The following example with give a syntax error, because the DATE_ADD function only expects two arguments delimited by a comma when the first argument is a datetime device. However, pilight sees the ``+1`` and ``HOUR`` as two separate string that normally should be delimited by a comma. Would be add that comma, we would still call the DATE_ADD function with the wrong parameter count. - -.. code-block:: guess - - IF DATE_ADD(datetime, +1 HOUR) == ... - -The rule above should be written like this instead so the ``+1`` and ``HOUR`` are parsed like ``+1 HOUR``. - -.. code-block:: guess - - IF DATE_ADD(datetime, '+1 HOUR') == ... - -Another issue arises when strings and device values or functions need to be combined like in this example: - -.. code-block:: guess - - IF ... THEN label DEVICE alarm TO the alarm was trigger at DATE_FORMAT(datetime, %Y-%m-%d) - -This rule will trigger a syntax error because the TO argument only expects one string, but five strings and a function were given. To make this into one string we need to use quotes and the concatenate ``.`` operator: - -.. code-block:: guess - - IF ... THEN label DEVICE alarm TO 'the alarm was trigger at' . DATE_FORMAT(datetime, %Y-%m-%d) - -Another scenario in which we want to explicitly cast a keyword into a string is given in this example: - -.. code-block:: guess - - IF ... THEN label DEVICE label TO on - -The ``label`` device is parsed by pilight as the label action because it's a reserved keyword. pilight does allow using label as a device name when casting it as a string like this: - -.. code-block:: guess - - IF ... THEN label DEVICE 'label' TO on - -As shown above, keywords or operators can be parsed into strings so pilight will ignore their default meaning. - -Devices -------- - -pilight rules are quite useless if we cannot work with live data. This live data comes from our devices in and around the house. So let us say we have a switch called switch and we use this configured device to create a rule like this: - -.. code-block:: guess - - IF switch.state IS on THEN ... - -Depending on the actual state of the switch this rule will succeed or fail. Let us now use a dimmer device called *dimmer*. - -.. code-block:: guess - - IF dimmer.dimlevel > 10 THEN ... - -Again, this rule will succeed or fail depending on the actual dimlevel of the configured dimmer device. These two examples can of course be combined: - -.. code-block:: guess - - IF switch.state IS on AND dimmer.dimlevel > 10 THEN ... - -As you can also see, the fields (*state* or *dimlevel*) we can use depends on the device we are using inside our rules. A switch does not have a *dimlevel* field but a dimmer does have a *state* field. - -.. versionadded:: 8.0 rules based on received codes - -Some devices are only used inside rules. Configuring them as explicit devices might sometimes feel a bit bloated. Therefor, pilight allows you to trigger rules based on received codes instead of device updates: - -.. deprecated:: 8.1.0 - -.. code-block:: guess - - IF archtech_switch.state IS on AND archtech_switch.id == 123456 AND arctech_switch.unit == 0 THEN ... - -.. versionadded:: 8.1.0 - -.. code-block:: guess - - IF archtech_switch.state == on AND archtech_switch.id == 123456 AND arctech_switch.unit == 0 THEN ... - -In this case, an action will be triggered as soon as an ``archtech_switch`` code is received with a specific state, id, and unitcode. The ``arctech_switch`` doesn't have to be configured as an explicit device for this rule to work. - -Functions ---------- - -In some cases, standard operators limit us in writing our rules. For example, calculating with time is a hideous task considering that hours do not go above 24, minute and seconds do not go above 60, and there are no negative numbers. Other functionality like randomization are also not possible in the standard event operators. This more advanced functionality is added in the form of function. A simple example: - -.. code-block:: guess - - IF datetime.hour == RANDOM(21, 23) THEN ... - -As we can see in this example we use the RANDOM function to check if the hour is either 21, 22, or 23. This allows us to trigger an action on random hours each day. Actions can also be nested for more advanced logic: - -.. code-block:: guess - - IF datetime.hour == RANDOM(RANDOM(21, 22), RANDOM(22, 23)) THEN ... - -The output of this RANDOM function is the same as with the previous example, but the idea should be clear. - -Actions -------- - -Actions are the final goal of our rules. These actions tell pilight what should happen when certain conditions have been met. A rule can contain unlimited number of actions and each action can trigger an unlimited number of devices. First two examples of basic actions triggering a switch called *lamp* and a dimmer called *ambientLight*: - -.. code-block:: guess - - IF ... THEN switch DEVICE lamp TO on - IF ... THEN dim DEVICE ambientLight TO 10 - -Both actions only trigger a single device. However, if we wanted to trigger both device to just on we can combine them in a single action: - -.. code-block:: guess - - IF ... THEN switch DEVICE lamp AND ambientLight TO on - -As we can see here, the switch action takes at least the DEVICE and TO parameters. In case of the switch action, several values (as in devices) can be combined by separating them with ANDs. We can also combine dim and switch action would we want to switch the *lamp* to on and dim the *ambientLight* to dimlevel 10 based on the same condition: - -.. code-block:: guess - - IF ... THEN switch DEVICE lamp TO on AND dim DEVICE ambientLight TO 10 - -We can combine an unlimited number of actions like this. Again we see that we use the AND to combine several actions. We can also switch several devices across several actions in a single rule. Let's say we have a relay connected to our television set called television that we want to turn on as well. - -.. code-block:: guess - - IF ... THEN switch DEVICE lamp AND television TO on AND dim DEVICE ambientLight TO 10 - -.. versionadded:: 8.1.0 - -As described earlier, actions can also be trigger based on a false condition like this: - -.. code-block:: guess - - IF ... THEN switch DEVICE lamp AND television TO on ELSE dim DEVICE ambientLight TO 10 END - -Using Device Parameters ------------------------ - -Device parameters can be used as rule input almost everywhere. Let us look at a few examples to demonstrate this: - -.. code-block:: guess - - IF 1 == 1 THEN dim DEVICE dimmer TO dimmerMax.dimlevel FOR dimmerDuration.dimlevel - -In this case we use three dimmer devices. One dimmer called dimmer that we actually want to dim, and two dimmers that changes the way this rule behaves. The dimmerMax device tells pilight to what value the dimmer should dim. The dimmerDuration device tells pilight how long it should take to reach that dimlevel. Another example: - -.. code-block:: guess - - IF 1 == 1 THEN switch DEVICE lamp1 TO lamp2.state - -In this case we want to switch the device lamp1 to the same state as the device lamp2. - -Device parameters can also be used in function: - -.. code-block:: guess - - IF RANDOM(randomLow.dimlevel, randomHigh.dimlevel) == 10 THEN switch DEVICE lamp1 TO on - -In this case we use two dimmers called randomLow and randomHigh to dynamically change the input of the RANDOM function used in this rule. A comprehensive and advanced example: - -.. code-block:: guess - - IF sunriseset.sunset == DATE_FORMAT(DATE_ADD(datetime, +1 HOUR), \"%Y-%m-%d %H:%M:%S\", %H.%M) THEN switch DEVICE lamp1 TO on - -.. versionchanged:: 8.1.0 - -.. code-block:: guess - - IF sunriseset.sunset == DATE_FORMAT(DATE_ADD(datetime, '+1 HOUR'), '%Y-%m-%d %H:%M:%S', %H.%M) THEN switch DEVICE lamp1 TO on \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/faq.rst b/lib/ESPiLight/pilight/docs/source/faq.rst deleted file mode 100644 index 48fbd1e..0000000 --- a/lib/ESPiLight/pilight/docs/source/faq.rst +++ /dev/null @@ -1,186 +0,0 @@ -Frequently Asked Questions -========================== - -- `General`_ - - `Retrieving pilight version`_ - - `pilight doesn't start or immediately exits`_ - - `Fixing SSDP connection issues`_ - - `Disabling SSDP completely`_ - - `Using other devices besides 433.92 MHz`_ - - `Fixing broken Lirc and 1-wire protocols`_ - - `Fixing the high CPU usage after a Kernel upgrade`_ -- `Sending & Receiving`_ - - `The GPIO connected receiver does not work`_ - - `I only see sent codes, not received ones`_ - - `Let devices learn new codes sent from pilight`_ -- `Configuration`_ - - `How to use raw codes in the configuration`_ - - `How to fix an empty webGUI`_ - -.. deprecated:: 8.0 - -- `General`_ - - `Using PHP inside the pilight webserver`_ -- `Sending & Receiving`_ - - `The send-repeat setting does not work anymore`_ - -General -------- - -.. _Retrieving pilight version: -.. rubric:: Retrieving pilight version - -You can use the following command to retrieve the pilight version: - -.. code-block:: console - - pi@pilight:~# pilight-daemon -V - -If you run a stable version, only the version will be shown: - -.. code-block:: console - - pilight-daemon version v7.0 - -If you run a developmental version, a commit message will also be shown. It will point to the last commit included in your pilight compilation. - -.. code-block:: console - - pilight-daemon version v7.0-24-gb64a135 - -In this case, the 24th commit after version 7.0 with the SHA id gb64a135 is running. To see which commit this is, check the `git development commit list `_. - -.. _pilight doesn't start or immediately exits: -.. rubric:: pilight doesn't start or immediately exits - -Most probably you made an error in the pilight configuration. Start pilight in debug mode and check the output: - -.. code-block:: console - - pi@pilight:~# pilight-daemon -D - -.. _Fixing SSDP connection issues: -.. rubric:: Fixing SSDP connection issues - -Make sure your iptables are set correctly: - -.. code-block:: console - - pi@pilight:~# sudo iptables -A INPUT -s 127.0.0.1 -j ACCEPT - -Also make sure your network interfaces are configured correctly in **/etc/network/interfaces**: - -.. code-block:: guess - :linenos: - - auto lo - iface lo inet loopback - allow-hotplug eth0 - auto eth0 - iface eth0 inet static - address x.x.x.x - netmask 255.255.255.0 - gateway x.x.x.x - -Especially the **iface lo inet loopback** part is essential for SSDP to work. A reboot could be necessary after making these changes. - -.. _Disabling SSDP completely: -.. rubric:: Disabling SSDP completely - -Add the standalone setting in the config.json and set it to 1. - -.. code-block:: json - :linenos: - - { - "settings": { - "standalone": 1 - } - } - -However, because all pilight clients use SSDP to find the main pilight daemon, you need to pass the server and port arguments when you want to control this standalone running daemon. Check the documentation for the specific pilight client for additonal information. - -.. _Using PHP inside the pilight webserver: -.. rubric:: Using PHP inside the pilight webserver - -.. deprecated:: 8.0 - -You probably encounter this message when running pilight in debug mode: - -.. code-block:: guess - :linenos: - - pilight-daemon: ERROR: php support disabled due to missing php-cgi executable - -This means that you miss some packages to run PHP. The required packages pilight needs for PHP support are: - -- php-cgi -- base64 -- cat - -.. _Using other devices besides 433.92 MHz: -.. rubric:: Using other devices besides 433.92 MHz - -pilight was built with 433.92 MHz devices as a reference, but the code is not limited to this frequency. We actually always wrote the code with other frequencies in mind. The only reason no other frequencies like 868 MHz are supported is lack of time and the lack of other developers to do it for us. The hardware part of pilight is completely modular so adding support for other frequencies should be as easy as writing new protocols. - -.. _Fixing broken Lirc and 1-wire protocols: -.. rubric:: Fixing broken Lirc and 1-wire protocols - -You probably installed the latest Raspberry Pi kernel. The new kernel works with device trees so the kernel knows what devices you want to use. Check the Raspberry Pi documentation how to use this new device tree. - -.. _Fixing the high CPU usage after a Kernel upgrade: -.. rubric:: Fixing the high CPU usage after a Kernel upgrade - -The wiringPi GPIO library used in pilight version 5.0 and lower contained a bug. This is fixed in pilight version 6 and up. - -Version 8 and up use the wiringX library also written by the pilight developers which also fixes the (old) wiringPi bugs. - -Sending & Receiving -------------------- - -.. _The GPIO connected receiver does not work: -.. rubric:: The GPIO connected receiver does not work - -The most encountered reason for this problem is the quality of the receiver. A lot of users buy unsupported (cheap) receivers from either eBay, DealExtreme or similar sites often referred to as FS1000A and XY-MK-5V. However, these receivers have a terrible range. To make sure it is the receiver and not a fault in connecting the device to your Raspberry Pi, make sure to keep your remote next to the receiver. If it still fails, check then check your connections. - -If you do want to use pilight for controlling devices across your house, consider buying a good quality receiver. Refer to the pilight shop for supported peripherals. - -.. _I only see sent codes, not received ones: -.. rubric:: I only see sent codes, not received ones - -The pilight receive output always contains an origin value. This means you can see from were the outputted code came from. Only if this field says receiver you know that the code was picked up by the receiver. When it says sender the codes has been created and processed internally. pilight processes these codes as if it was a received code so it can update the GUIs and config. Only if you see receiver you know it was not generated by pilight. - -.. _Let devices learn new codes sent from pilight: -.. rubric:: Let devices learn new codes sent from pilight - -Some protocols support learning devices. This learn feature temporarily sends an increased amount of codes to the device. Check the protocol send arguments to see if your protocol supports it. For example, the KlikAanKlikUit protocol does this as follows: - -.. code-block:: console - - pi@pilight:~# pilight-send -p kaku_switch -i 1 -u 1 -t -l - -.. _The send-repeat setting does not work anymore: -.. rubric:: The send-repeat setting does not work anymore - -.. deprecated:: 6.0 - -pilight version 6 was the last version supporting the global send-repeat setting. This setting told pilight how often a pulsetrain was repeated. This setting got removed because it interfered with a lot of protocols. - -Most remote control devices repeat a pulsetrain two to six times on a single button press. On some devices all pulsetrains are identical, so repeating them does not introduce any issues. However, on some devices the 1st pulsetrain differs from the subsequent pulsetrains. In addition, some devices sent a wakeup pulse sequence before the very 1st pulsetrain to trigger internal wakeup logic. Most devices use footer pulses, while devices transmit header pulses, and some devices transmit both. -If you keep the button pressed on some remote controls, a series of pulsetrains is sent until the button is released, while others stop sending repetitive pulsetrains after a certain time period, and some set a toggle bit for repetitive pulsetrains each time a button is pressed. - -pilight was not differentiating between those various operating scenarios, because the send-repeat parameter specified only how often a single pulsetrain was re-transmitted for all devices. So increasing the global send-repeats actually broke a lot of these protocols. We therefore removed the old global send-repeat parameter and replaced it with a protocol specific repeat parameter, currently not configurable from userspace. -We also discovered that in almost all cases, the solution was not increasing the send-repeats parameter, but instead using a good antenna. - -Configuration -------------- - -.. _How to use raw codes in the configuration: -.. rubric:: How to use raw codes in the configuration - -This is not possible, because pilight cannot know what these codes mean and how to interpret them. - -.. _How to fix an empty webGUI: -.. rubric:: How to fix an empty webGUI - -You need to add devices to the "GUI" section of config.json as well, not just the "devices" section. diff --git a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeA+B.pdf b/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeA+B.pdf deleted file mode 100644 index 9b1a01b..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeA+B.pdf and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeA+B.svg b/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeA+B.svg deleted file mode 100644 index ebe141b..0000000 --- a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeA+B.svg +++ /dev/null @@ -1,1580 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeC.pdf b/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeC.pdf deleted file mode 100644 index 4a42075..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeC.pdf and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeC.svg b/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeC.svg deleted file mode 100644 index fdf80ef..0000000 --- a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeC.svg +++ /dev/null @@ -1,1623 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeD.pdf b/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeD.pdf deleted file mode 100644 index f0aeb5e..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeD.pdf and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeD.svg b/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeD.svg deleted file mode 100644 index cd4db83..0000000 --- a/lib/ESPiLight/pilight/docs/source/images/adhoc-network-nodeD.svg +++ /dev/null @@ -1,1444 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/images/attiny-wiring.pdf b/lib/ESPiLight/pilight/docs/source/images/attiny-wiring.pdf deleted file mode 100644 index 3ec6404..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/attiny-wiring.pdf and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/attiny-wiring.svg b/lib/ESPiLight/pilight/docs/source/images/attiny-wiring.svg deleted file mode 100644 index eb0a84c..0000000 --- a/lib/ESPiLight/pilight/docs/source/images/attiny-wiring.svg +++ /dev/null @@ -1,1701 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/images/favicon.ico b/lib/ESPiLight/pilight/docs/source/images/favicon.ico deleted file mode 100644 index d071c8c..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/favicon.ico and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/installation.png b/lib/ESPiLight/pilight/docs/source/images/installation.png deleted file mode 100644 index f818395..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/installation.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/no.png b/lib/ESPiLight/pilight/docs/source/images/no.png deleted file mode 100644 index 7b5cc8b..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/no.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/pilight.png b/lib/ESPiLight/pilight/docs/source/images/pilight.png deleted file mode 100644 index d86ce10..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/pilight.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/1.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/1.jpg deleted file mode 100644 index 5e14729..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/1.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/10.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/10.jpg deleted file mode 100644 index cc7be86..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/10.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/11.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/11.jpg deleted file mode 100644 index 076ca99..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/11.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/12.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/12.jpg deleted file mode 100644 index 5bd70f7..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/12.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/13.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/13.jpg deleted file mode 100644 index cf3b5d4..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/13.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/14.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/14.jpg deleted file mode 100644 index 0d9e973..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/14.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/2.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/2.jpg deleted file mode 100644 index 9d0cb2a..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/2.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/3.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/3.jpg deleted file mode 100644 index edcd629..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/3.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/4.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/4.jpg deleted file mode 100644 index 8e4292b..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/4.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/5.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/5.jpg deleted file mode 100644 index 6e7a8e1..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/5.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/6.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/6.jpg deleted file mode 100644 index b1a9c00..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/6.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/7.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/7.jpg deleted file mode 100644 index 51727a9..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/7.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/8.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/8.jpg deleted file mode 100644 index 5e5c5b8..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/8.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/soldering/9.jpg b/lib/ESPiLight/pilight/docs/source/images/soldering/9.jpg deleted file mode 100644 index ed75974..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/soldering/9.jpg and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/usb-nano-wiring.pdf b/lib/ESPiLight/pilight/docs/source/images/usb-nano-wiring.pdf deleted file mode 100644 index bad1776..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/usb-nano-wiring.pdf and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/images/usb-nano-wiring.svg b/lib/ESPiLight/pilight/docs/source/images/usb-nano-wiring.svg deleted file mode 100644 index 0923efe..0000000 --- a/lib/ESPiLight/pilight/docs/source/images/usb-nano-wiring.svg +++ /dev/null @@ -1,1925 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A7 - A6 - A5 - A4 - A3 - A2 - A1 - A0 - 3.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/images/yes.png b/lib/ESPiLight/pilight/docs/source/images/yes.png deleted file mode 100644 index 61bd0bb..0000000 Binary files a/lib/ESPiLight/pilight/docs/source/images/yes.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/docs/source/index.rst b/lib/ESPiLight/pilight/docs/source/index.rst deleted file mode 100644 index a5044b7..0000000 --- a/lib/ESPiLight/pilight/docs/source/index.rst +++ /dev/null @@ -1,88 +0,0 @@ -:tocdepth: 5 - -Welcome to pilight's documentation! -=================================== - -.. raw:: latex - - \newpage - -Overview --------- - -pilight is a free, open source, full fledged domotica solution that runs on a Raspberry Pi, Hummingboard, and BananaPi, but also on \*BSD, various Linux distributions (tested on Arch, Ubuntu, and Debian), Windows, and OpenWRT routers. pilight works with a great deal of devices and is frequency independent. Therefore, due to its modular set-up, it can control devices working at 315 MHz, 433 MHz, and 868 MHz, but only 433.92 MHz is currently supported. Support for other frequencies and/or devices is dependent on community input, because we as developers do not own them all. - -.. raw:: latex - - \newpage - -Features --------- -The main features of pilight are: - -* `Open Source`_ -* `Open Hardware`_ -* `Free`_ -* `Fully Modular`_ -* `High Quality Code`_ -* `Integrated Webserver and webGUI`_ -* `Light-Weight`_ - -.. _Open Source: -.. rubric:: Open Source - -The pilight source code can be found on the internet at https://www.github.com/pilight/. pilight is largely dependent on community input so if you have any suggestions, improvements, or fixes, feel free to provide them. - -.. _Open Hardware: -.. rubric:: Open Hardware - -The source and schematics of all pilight hardware is open and free for everyone. This means that you can easily build the hardware pilight offers yourself. However, by buying the hardware from pilight, you also support the project. - -.. _Free: -.. rubric:: Free - -pilight is free as in free speech. It is licensed under the GPLv3 license. If you have any plans with our source code, please make it clear that you are not affiliated to pilight in any way. We do not want to end up in a situation were we have to give support for something we did not approve. - -.. _Fully Modular: -.. rubric:: Fully Modular - -pilight is modular in about every inch. Adding new protocols is very easy just like adding new hardware modules. The API allows users to develop new applications that interact with pilight. The community already developed phone apps, desktop apps, and various plug-ins for various other projects. - -.. _High Quality Code: -.. rubric:: High quality code - -Almost everything pilight does is also developed by pilight from the ground up. This means that the developers of pilight know what is going on in every part of the pilight code. Whenever additional functionality is needed, external libraries are carefully selected for their own code quality. As an example, pilight does not use OpenSSL but polarSSL (currently called mbed TLS). OpenSSL has a bad reputation in terms of code quality while polarSSL is far more robust. pilight developers also constantly audit their own code by using tools like valgrind or gdb. Memory leaks or other common issues are therefore 99% nonexisting in pilight. The pilight code quality also allows it to be ported easily to any platform as was proven with the Windows and OpenWRT ports. - -.. _Integrated Webserver and webGUI: -.. rubric:: Integrated webserver and webGUI - -pilight has an integrated webserver and serves an intergrated webGUI. This allows users to immediately start using pilight in all its capacity. The webGUI makes it easy to control devices or to see their states. Those who do not want to install the phone apps can just use their regular browser to access pilight. - -.. _Light-Weight: -.. rubric:: Light-Weight - -pilight is written in C. This means that it is very fast and does not use much resources. All plug-ins are compiled into pilight so the overhead of the plug-ins is also kept to a minimum. This is also one of the reasons pilight can run on low-power consumer products like OpenWRT routers. All pilight hardware such as the ATTiny filter and the Arduino Nano interface are also written in pure C. This again allows us to have control over every inch of code and to prevent any overhead from tools like the Arduino programming libraries. - -.. raw:: latex - - \newpage - -Sitemap -------- - -.. toctree:: - :maxdepth: 4 - :titlesonly: - - changelog - installation - configuration/index - protocols/index - eventing/index - adhoc_network - programs/index - electronics/index - faq - development/index - about_manual - diff --git a/lib/ESPiLight/pilight/docs/source/installation.rst b/lib/ESPiLight/pilight/docs/source/installation.rst deleted file mode 100644 index 3529fcc..0000000 --- a/lib/ESPiLight/pilight/docs/source/installation.rst +++ /dev/null @@ -1,190 +0,0 @@ -Installation -============ - -* `Linux Debian Based`_ -* `Windows 7 and up`_ -* `OpenWRT Routers`_ - -Linux Debian Based ------------------- - -Install pilight by using the apt repository in Debian / Ubuntu based distributions. - -#. Login to your computer. -#. Make sure you are running as root. Run the following command and use your own password. - - .. code-block:: console - - pi@pilight:~# sudo su - Password: - -#. Add the apt repository to the apt sources list: - - .. code-block:: console - - pi@pilight:~# echo "deb http://apt.pilight.org/ stable main" > /etc/apt/sources.list.d/pilight.list - - If you want to install the nightly version of pilight then also add: - - .. code-block:: console - - root@pilight:~# echo "deb http://apt.pilight.org/ nightly main" >> /etc/apt/sources.list.d/pilight.list - -#. pilight uses a signed repository. This means packages get validated before installation. So, to safely download and install pilight packages the pilight key needs to be installed. - - .. code-block:: console - - root@pilight:~# wget -O - http://apt.pilight.org/pilight.key | apt-key add - - -#. Now update the apt package list: - - .. code-block:: console - - root@pilight:~# apt-get update - -#. And install pilight - - .. code-block:: console - - root@pilight:~# apt-get install pilight - -#. When no errors are shown, pilight will be installed and automatically started at boot time. To manually start pilight: - - .. code-block:: console - - root@pilight:~# service pilight start - -#. And to stop pilight: - - .. code-block:: console - - root@pilight:~# service pilight stop - -.. note:: - - pilight makes it easy to install previous version, because all stable versions and all nightly versions between two stable versions will remain available in the apt repository. - To see what versions are available, you can run the following command: - - .. code-block:: console - - root@pilight:~# apt-cache policy pilight - pilight: - Installed: 7.0.16-g233c268 - Candidate: 7.0.21-ga8b12ea - Version table: - 7.0.21-ga8b12ea 500 - 500 http://apt.pilight.org nightly/main armhf Packages - *** 7.0.16-g233c268 500 - 500 http://apt.pilight.org nightly/main armhf Packages - 7.0.9-gfbc2643 500 - 500 http://apt.pilight.org nightly/main armhf Packages - 7.0.8-g953bb85 500 - 500 http://apt.pilight.org nightly/main armhf Packages - 7.0 500 - 500 http://apt.pilight.org stable/main armhf Packages - 6.0 500 - 500 http://apt.pilight.org stable/main armhf Packages - 5.0 500 - 500 http://apt.pilight.org stable/main armhf Packages - 4.0 500 - 500 http://apt.pilight.org stable/main amd64 Package - - In this case, both the stable and the nightly apt repositories are enabled. If you want to install a specific version run the following command: - - .. code-block:: console - - root@pilight:~# apt-get install pilight=7.0.67-g960219e - -.. raw:: latex - - \newpage - -Windows 7 and up ----------------- - -#. Go to http://download.pilight.org. -#. Download the latest Windows executable called pilight-vX.0-win32.exe. Run it to install pilight. -#. By default pilight will install into to c:\\pilight\\. -#. A default configuration can also be found in that folder. -#. If you want to use the pilight USB nano you can use the pilight-usb-nano.hex found in the default folder. - -OpenWRT Routers ---------------- - -#. When using OpenWRT you are assumed also to know how to login to your router with SSH. -#. Go to http://download.pilight.org. -#. Download the latest pilight OpenWRT compilation called pilight-Atheros-AR9132-vX.0.tar.gz. -#. Unpack this file like this: - - .. code-block:: console - - root@OpenWrt:~# tar -zxvf pilight-Atheros-AR9132-vX.0.tar.gz -C / - -#. The OpenWRT package only contains pilight-daemon to save space. -#. A default configuration is put into /etc/pilight/config.json. - -Manually Compiled Version -------------------------- - -.. warning:: - - We try to provide as many options as possible for you to keep up-to-date with the latest developments. Compiling C software requires some level of expertise, which we cannot and will not provide. This means that **no support is given** if any issues occur with manually compiling pilight. - -Manually compiling pilight is also possible. Use this method is you are not using a Debian-based or a \*BSD based operating system. - -#. Login to your computer. -#. Make sure you've configured the pilight stable apt repository, because some required dependencies are not available elsewhere. -#. Make sure you are running as root. Run the following command and use your own password. - - .. code-block:: console - - pi@pilight:~# sudo su - Password: - -#. Install all packages needed for manually compiling pilight. The best way to do this depends on your operating system. The packages needed for Debian are: - - #. build-essential - #. cmake - #. git - #. dialog - #. libwiringx-dev - #. libwiringx - #. libpcap0.8-dev - #. libpcap0.8 - #. libmbedtls-dev - #. libmbedx509-0 - #. libmbedcrypto0 - #. libmbedtls10 - #. liblua5.2 - #. liblua5.2-dev - -#. Then download the pilight source code from the pilight GitHub: - - .. code-block:: console - - root@pilight:~# git clone --depth 5 -b [branch] https://www.github.com/pilight/pilight.git - root@pilight:~# cd pilight - - -#. Replace the [branch] with either **master** for the latest stable version. This version is exactly the same as the stable version available through the apt repository. Or use **development** for the very latest developmental build. This development version of pilight is also automatically generated each night. You can download it from the pilight nightly repository. -#. pilight can be compiled with various built-in features which can be included or excluded. This is done through a menu driven program. This program will also automatically compile and install pilight: - - .. code-block:: console - - root@pilight:~/pilight# chmod +x setup.sh - root@pilight:~/pilight# ./setup.sh - - .. image:: images/installation.png - -#. When you are thrown back into the command prompt without error(s), pilight has been installed successfully. It will also install a default configuration in /etc/pilight/config.json. -#. Make sure to run the following command after installation: - - .. code-block:: console - - root@pilight:~/pilight# ldconfig - -#. pilight can now be started with: - - .. code-block:: console - - root@pilight:~/pilight# service pilight start diff --git a/lib/ESPiLight/pilight/docs/source/programs/control.rst b/lib/ESPiLight/pilight/docs/source/programs/control.rst deleted file mode 100644 index a825f97..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/control.rst +++ /dev/null @@ -1,83 +0,0 @@ -=============== -pilight-control -=============== - -Control pilight devices ------------------------ - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-control`` --device DEVICE --state STATE -| ``pilight-control`` [OPTION]... --device DEVICE --values VALUES -| ``pilight-control`` [--server SERVER] [ --port PORT] [OPTION]... --device DEVICE - -DESCRIPTION -=========== - -``pilight-control`` is a tool to control a device configured in a pilight daemon configuration. It supports switching the state and/or modifying other values (such as dimlevel, temperature, or humidity) of the device. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-S``, ``--server=x.x.x.x`` -| Connect to a pilight daemon at this address. Requires -P -| -| ``-P``, ``--port=xxxx`` -| Connect to a pilight daemon at this port. Requires -S -| -| ``-C``, ``--config=PATH_TO_CONFIG`` -| Path to configuration file -| -| ``-d``, ``--device=DEVICE_NAME`` -| Name of the configured device to be controlled -| -| ``-s``, ``--state=STATE`` -| State to switch DEVICE to -| -| ``-v``, ``--values=VALUES`` -| Supply other values for DEVICE, such as dimlevel=10 - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-daemon`` -| ``pilight-debug`` -| ``pilight-flash`` -| ``pilight-raw`` -| ``pilight-receive`` -| ``pilight-send`` -| ``pilight-sha256`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/daemon.rst b/lib/ESPiLight/pilight/docs/source/programs/daemon.rst deleted file mode 100644 index da47a7a..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/daemon.rst +++ /dev/null @@ -1,98 +0,0 @@ -============== -pilight-daemon -============== - -The pilight daemon ------------------- - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-daemon`` -| ``pilight-daemon`` [OPTION]... -| ``pilight-daemon`` [--server SERVER] [ --port PORT] [OPTION]... - -DESCRIPTION -=========== - -``pilight-daemon`` is the main software of the pilight project. It is responsible for handling and interpreting received signals, as well as generating signals to communicate with and control various devices. - -A configuration file is required. By default, ``/etc/pilight/config.json`` is used. Configuration files are written in the JSON format. - -Consult the pilight manual for details on how to configure and use pilight. - -By default, the pilight daemon hosts a webgui which allows controlling devices through a clickable interface in a webbrowser. The pilight daemon runs a socket server and provides a REST API to interface with the pilight daemon. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-C``, ``--config=PATH_TO_CONFIG`` -| Specify to use configuration file at PATH rather than standard configuration -| -| ``-S``, ``--server=x.x.x.x`` -| Connect to a pilight daemon at this address. Requires -P -| -| ``-P``, ``--port=xxxx`` -| Connect to a pilight daemon at this port. Requires -S -| -| ``-F``, ``--foreground`` -| Do not daemonize -| -| ``-D``, ``--debug`` -| Do not daemonize and print more debug information - -Debugging options: - -| -| ``--stacktracer`` -| Show internal function calls -| -| ``--threadprofiler`` -| Show per thread CPU usage -| -| ``--debuglevel`` -| Show additional development information - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-debug`` -| ``pilight-flash`` -| ``pilight-raw`` -| ``pilight-receive`` -| ``pilight-send`` -| ``pilight-sha256`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/debug.rst b/lib/ESPiLight/pilight/docs/source/programs/debug.rst deleted file mode 100644 index 754bed2..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/debug.rst +++ /dev/null @@ -1,71 +0,0 @@ -============= -pilight-debug -============= - -Decode incoming raw streams into logical pulsetrains ----------------------------------------------------- - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-debug`` -| ``pilight-debug`` [OPTION] - -DESCRIPTION -=========== - -``pilight-debug`` is a tool to decode incoming raw streams into logical pulsetrains. It also prints certain calculated parameters of the caught pulsetrain. - -Prints data to STDOUT until interrupted with ^C. - -This tool requires root privileges. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-C``, ``--config=PATH_TO_CONFIG`` -| Path to configuration file - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-daemon`` -| ``pilight-flash`` -| ``pilight-raw`` -| ``pilight-receive`` -| ``pilight-send`` -| ``pilight-sha256`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/flash.rst b/lib/ESPiLight/pilight/docs/source/programs/flash.rst deleted file mode 100644 index 2e9dad4..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/flash.rst +++ /dev/null @@ -1,79 +0,0 @@ -============= -pilight-flash -============= - -Flash hardware with pilight firmware ------------------------------------- - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-flash`` --file FIRMWARE_FILE -| ``pilight-flash`` [OPTION]... --file FIRMWARE_FILE - -DESCRIPTION -=========== - -``pilight-flash`` is a tool to flash pilight firmware to ATMel chips (such as the ATTiny and ATMega). - -The pilight ATMel firmware pre-filters streams and prevents noise from reaching the pilight daemon. This -lowers the CPU usage of the pilight daemon greatly, because the pilight daemon will not continuously -attempt to interpret noise as valid protocols. Currently supported chips are the ATTiny25, ATTiny45, -ATTiny85, and ATMega328P. - -Besides acting as a pre-filter, the firmware also allows using pilight with senders and receivers on non -GPIO-capable hardware (such as most desktops, servers, etc.) The flashed ATMega chip is connected via USB, -and the sender and receiver are wired to the GPIO pins on the chip. Consult the pilight manual for wiring schematics. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-C``, ``--config=PATH_TO_CONFIG`` -| Path to configuration file -| -| ``-f``, ``--file=PATH_TO_FIRMWARE`` -| Firmware file to flashed - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-daemon`` -| ``pilight-debug`` -| ``pilight-raw`` -| ``pilight-receive`` -| ``pilight-send`` -| ``pilight-sha256`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/index.rst b/lib/ESPiLight/pilight/docs/source/programs/index.rst deleted file mode 100644 index 03c5661..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/index.rst +++ /dev/null @@ -1,15 +0,0 @@ -Programs -======== - -.. toctree:: - :maxdepth: 1 - - control - daemon - debug - flash - raw - receive - send - sha256 - uuid \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/programs/raw.rst b/lib/ESPiLight/pilight/docs/source/programs/raw.rst deleted file mode 100644 index df7903a..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/raw.rst +++ /dev/null @@ -1,74 +0,0 @@ -=========== -pilight-raw -=========== - -Print received raw streams --------------------------- - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-raw`` -| ``pilight-raw`` [OPTION]... - -DESCRIPTION -=========== - -``pilight-raw`` is a tool to print raw streams as they are picked up by the receiver hardware. - -Prints data to STDOUT until interrupted with ^C. - -This tool requires root privileges. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-C``, ``--config=PATH_TO_CONFIG`` -| Path to configuration file -| -| ``-L``, ``--linefeed`` -| Structure raw printout with newlines between (probably) separate pulsetrains. - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-daemon`` -| ``pilight-debug`` -| ``pilight-flash`` -| ``pilight-receive`` -| ``pilight-send`` -| ``pilight-sha256`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/receive.rst b/lib/ESPiLight/pilight/docs/source/programs/receive.rst deleted file mode 100644 index 1cc6941..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/receive.rst +++ /dev/null @@ -1,84 +0,0 @@ -=============== -pilight-receive -=============== - -Show datagrams received and transmitted by pilight --------------------------------------------------- - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-receive`` -| ``pilight-receive`` [OPTION]... -| ``pilight-receive`` [--server SERVER] [ --port PORT] [OPTION]... --device DEVICE - -DESCRIPTION -=========== - -``pilight-receive`` is a tool to show all data that is sent and received by a pilight daemon instance or a pilight adhoc network. All data is shown as-is in JSON format. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-S``, ``--server=x.x.x.x`` -| Connect to a pilight daemon at this address. Requires -P -| -| ``-P``, ``--port=xxxx`` -| Connect to a pilight daemon at this port. Requires -S -| -| ``-s``, ``--stats`` -| show CPU and RAM statistics in output -| -| ``-F``, ``--filter=PROTOCOL(S)`` -| Specify protocols that should not be printed in the -| output stream. This is useful when trying to find -| IDs of devices such as weather stations or remote -| controls, but certain protocols are spamming the -| output. For example, datetime protocol data is -| transmitted every second, and is likely to displace -| useful information in the output stream. It can -| then be hidden with --filter=datetime - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-daemon`` -| ``pilight-debug`` -| ``pilight-flash`` -| ``pilight-raw`` -| ``pilight-send`` -| ``pilight-sha256`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/send.rst b/lib/ESPiLight/pilight/docs/source/programs/send.rst deleted file mode 100644 index 25ecca9..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/send.rst +++ /dev/null @@ -1,160 +0,0 @@ -============ -pilight-send -============ - -Send data to a pilight daemon ------------------------------ - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-send`` --protocol PROTOCOL [OPTION]... -| ``pilight-send`` [--server SERVER] [ --port PORT] --protocol PROTOCOL [OPTION]... - -DESCRIPTION -=========== - -``pilight-send`` is a tool to send data to a pilight daemon instance. It is a more versatile tool than ``pilight-control``, because it does not require the device to be previously configured. - -It can be used to send signals for any pilight protocol that supports sending. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-p``, ``--protocol=PROTOCOL`` -| Protocol to be sent -| -| ``-S``, ``--server=x.x.x.x`` -| Connect to a pilight daemon at this address. Requires -P -| -| ``-P``, ``--port=xxxx`` -| Connect to a pilight daemon at this port. Requires -S -| -| ``-C``, ``--config=PATH_TO_CONFIG`` -| Path to configuration file -| -| ``-U``, ``--uuid=UUID`` -| UUID to identify as when connecting to the pilight daemon - -Further options are required, depending on the chosen protocol. Use ``pilight-send`` ``-p`` PROTOCOL ``--help`` to find which options are required for the protocol. Some long options differ between protocols. Protocol options include: - -| -| ``-a``, ``--all``, ``--id=ALL`` -| Send command to all devices with the same ID -| -| ``-a``, ``--api=API_KEY`` -| Update a Weather Underground entry with the API code -| -| ``-b``, ``--battery=BATTERY`` -| Send battery state (0 = low, 1 = normal) for weather -| stations -| -| ``-c``, ``--code=RAW_CODE`` -| Raw code to be transmitted, as emitted by -| ``pilight-debug`` -| -| ``-c``, ``--color=COLOR`` -| Set a label device to this text color -| -| ``-c``, ``--country=COUNTRY`` -| Update a Weather Underground entry with this country -| -| ``-d``, ``--dimlevel=DIMLEVEL`` -| Set a dimmer to a specific dimlevel -| -| ``-f``, ``--off``, ``--down``, ``--stopped`` -| Send an 'off' (for switches) or 'down' (for screens) or -| 'stopped' (for programs) signal -| -| ``-g``, ``--gpio=GPIO`` -| GPIO pin number a device (for example a relay) is -| connected to. -| -| ``-h``, ``--humidity=HUMIDITY`` -| Send humidity value for a weather station -| -| ``-i``, ``--id=ID`` -| Send a code with this id -| -| ``-l``, ``--label=LABEL`` -| Set text of a label device to this text -| -| ``-l``, ``--learn`` -| Send multiple streams when a device is in learning mode -| to emulate the learning mode of a remote control. -| -| ``-l``, ``--location=LOCATION`` -| Update a Weather Underground entry with this location -| -| ``-n``, ``--name=NAME`` -| Name of the program to be controlled -| -| ``-n``, ``--num`` -| Use random (super)code sequence number 0..3 (7) -| -| ``-s``, ``--systemcode=SYSTEMCODE`` -| Send a code with this systemcode -| -| ``-s``, ``--super`` -| Send to all devices, regardless of id -| -| ``-t``, ``--on``, ``--up``, ``--running`` -| Send an 'on' (for switches) or 'up' (for screens) or -| 'running' (for programs) signal. -| -| ``-t``, ``--temperature=TEMPERATURE`` -| Send temperature value for a weather station -| -| ``-u``, ``--unit=UNITCODE``, -| ``--unitcode=UNITCODE``, -| ``--programcode=PROGRAMCODE`` -| Send a code this unitcode. Note that some protocols use -| long option ``--unit`` while others use long option -| ``--unitcode`` or long option ``--programcode``. -| -| ``-u``, ``--update`` -| Update a defined Weather Underground entry - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-daemon`` -| ``pilight-debug`` -| ``pilight-flash`` -| ``pilight-raw`` -| ``pilight-receive`` -| ``pilight-sha256`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/sha256.rst b/lib/ESPiLight/pilight/docs/source/programs/sha256.rst deleted file mode 100644 index cd7b7f4..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/sha256.rst +++ /dev/null @@ -1,70 +0,0 @@ -============== -pilight-sha256 -============== - -Generate a pilight SHA-256 hash for a password ----------------------------------------------- - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-send`` --password PASSWORD - -DESCRIPTION -=========== - -``pilight-sha256`` is a tool to generate a SHA-256 hash for a webgui password to avoid storing cleartext passwords in configuration files. - -The hash can be added to config.json under "settings" - "webserver-password". Consult the pilight manual for configuration details. - -Prints the hashed PASSWORD to STDOUT. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit -| -| ``-p``, ``--password=PASSWORD`` -| Password to hash - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-daemon`` -| ``pilight-debug`` -| ``pilight-flash`` -| ``pilight-raw`` -| ``pilight-receive`` -| ``pilight-send`` -| ``pilight-uuid`` diff --git a/lib/ESPiLight/pilight/docs/source/programs/uuid.rst b/lib/ESPiLight/pilight/docs/source/programs/uuid.rst deleted file mode 100644 index bc35a53..0000000 --- a/lib/ESPiLight/pilight/docs/source/programs/uuid.rst +++ /dev/null @@ -1,65 +0,0 @@ -============ -pilight-uuid -============ - -Show pilight adhoc node UUID ----------------------------- - -:Date: 2017 -:Copyright: MPLv2 -:Version: 7.0 -:Manual section: 1 -:Manual group: pilight 7.0 man pages - -SYNOPSIS -======== - -| ``pilight-uuid`` - -DESCRIPTION -=========== - -``pilight-uuid`` is a tool to show the UUID for a pilight adhoc network node in order to identify as a unique node. This prevents multiple nodes from interfering with each other when sending and receiving. - -Prints the UUID to STDOUT. - -OPTIONS -======= - -Mandatory arguments to long options are mandatory for short options too. - -| -| ``-H``, ``--help`` -| Print allowed options and exit -| -| ``-V``, ``--version`` -| Print version information and exit - -BUGS -==== - -Please report all bugs on GitHub . - -AUTHOR -====== - -Curlymo and contributors. - -This man page was originally written by pilino1234 . - -WWW -=== - -https://www.pilight.org/ - -SEE ALSO -======== - -| ``pilight-control`` -| ``pilight-daemon`` -| ``pilight-debug`` -| ``pilight-flash`` -| ``pilight-raw`` -| ``pilight-receive`` -| ``pilight-send`` -| ``pilight-sha256`` diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/alarm/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/alarm/index.rst deleted file mode 100644 index 298b4e7..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/alarm/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -Alarm -===== - -.. toctree:: - :maxdepth: 1 - - secudo \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/alarm/secudo.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/alarm/secudo.rst deleted file mode 100644 index 173ba5d..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/alarm/secudo.rst +++ /dev/null @@ -1,117 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Secudo -====== - -.. versionadded:: 8.0 - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+-----------------------+----------------+ -| **Brand** | **Protocol** | -+-----------------------+----------------+ -| Secudo | secudo | -+-----------------------+----------------+ -| FlammEx | secudo | -+-----------------------+----------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "alarm": { - "protocol": [ "secudo" ], - "id": [{ - "id": 493 - }], - "state": "alarm" - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 1023 | -+------------------+-----------------+ -| state | alarm | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 26 pulses like this: - -.. code-block:: console - - 314 314 628 628 314 314 628 314 628 628 314 314 628 314 628 314 628 314 628 628 314 628 314 314 628 10676 - -The first pulse is the ``header`` and the last pulse is the ``footer``. -These are meant to identify the pulses as genuine. -We don't use them for further processing. -The next step is to transform the remaining pulses into 12 groups of two pulses (and thereby dropping the ``header`` and ``footer`` pulses): - -.. code-block:: guess - - 314 628 - 628 314 - 314 628 - 314 628 - 628 314 - 314 628 - 314 628 - 314 628 - 314 628 - 628 314 - 628 314 - 314 628 - -If we now look carefully at these groups you can distinguish two types of groups: - -#. 314 628 -#. 628 314 - -So the first group is defined by a high 2nd and the second group by a high 1st pulse. -So we take either of these two pulses to define a 0 or a 1. -In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. -We then get the following output: - -.. code-block:: guess - - 101101111001 - -The first 10 bits correspond to the setting of the ten dip switches inside the smoke sensor. -If a dip switch is ON, this corresponds to 1 and 0 otherwise. -The meaning of the two last bits is unknown. -When reversing the first 10 bits because the first bits are least signifant we get the smoke sensors ID as binary number - -.. code-block:: guess - - 0111101101 - -which is 493 as decimal number. -This means that the 2nd, 5th and 10th dip switch is OFF and all others are ON. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/elro.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/elro.rst deleted file mode 100644 index dbff04c..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/elro.rst +++ /dev/null @@ -1,142 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Elro HE Contact -=============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+------------------+ -| **Brand** | **Protocol** | -+------------------+------------------+ -| Elro 800 Series | elro_800_contact | -+------------------+------------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "contact": { - "protocol": [ "elro_800_contact" ], - "id": [{ - "systemcode": 31, - "unitcode": 0 - }], - "state": "closed" - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 31 | -+------------------+-----------------+ -| code | 0 - 31 | -+------------------+-----------------+ -| state | opened / closed | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 148 pulses like this - -.. code-block:: guess - - 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 960 320 320 960 960 320 320 960 960 320 320 960 960 320 320 960 320 960 320 960 960 320 320 9920 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: guess - - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 960 320 - 320 960 960 320 - 320 960 960 320 - 320 960 960 320 - 320 960 320 960 - 320 960 960 320 - 320 9920 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. 320 960 320 960 -#. 320 960 960 320 - -So the first group is defined by a high 4th pulse and the second group has a low 4th pulse. In this case we say a high 4th pulse means a 1 and a low 4th pulse means a 0. We then get the following output: - -.. code-block:: guess - - 11111 10000 1 0 - -Each (group) of numbers has a specific meaning: - -- SystemCode: 0 till 5 -- UnitCode: 6 till 10 -- State: 11 -- Check: 12 (inverse state) - -.. code-block:: guess - - 11111 10000 1 0 - -- The ``SystemCode`` is defined as a binary number -- The ``UnitCode`` is defined as a binary number -- The ``State`` defines whether a devices needs to be turned On or Off -- The ``Check`` defines whether a devices needs to be turned On or Off (but is inverse) - -So this code represents: - -- SystemCode: 31 -- UnitCode: 1 -- State: Opened -- Check: Opened (inverse state) - -Another example: - -- SystemCode: 0 -- UnitCode: 4 -- State: Closed -- Check: Closed (inverse state) - -.. code-block:: guess - - 00000 00100 0 1 - -Furthermore the protocol filters out false positives by checking if: - -- Every 1st bit of the first 12 groups of 4 bits is always LOW (0) -- 2nd bit of the first 12 groups of 4 bits is always HIGH (1) -- 3rd and 4th bit of the first 12 groups of 4 bits are different (NOT EQUAL) -- Bits 49 and 50 are LOW (0) and HIGH (1) respectively (fixed footer) - -This makes the protocol more accurate because it will respond less when arctech_old commands are sent. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/ev1527.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/ev1527.rst deleted file mode 100644 index cf6693e..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/ev1527.rst +++ /dev/null @@ -1,129 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -EV1527 Contact -============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| EV1527 | ev1527 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "contact": { - "protocol": [ "ev1527" ], - "id": [{ - "unitcode": 0 - }], - "state": "closed" - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 31 | -+------------------+-----------------+ -| code | 0 - 31 | -+------------------+-----------------+ -| state | opened / closed | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: guess - - 253 759 759 253 759 253 253 759 253 759 253 759 253 759 253 759 253 759 759 253 253 759 253 759 759 253 759 253 759 253 253 759 253 759 759 253 253 759 759 253 253 759 253 759 759 253 253 8602 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -The first six pulses are the address bits, followed by upto another 6 Address/Data Bits. Address Bits can have three states: 0, 1, F (tri-state). Data Bits have only two states: 0 or 1. - -.. code-block:: guess - - 253 759 - 759 253 - 759 253 - 253 759 - 253 759 - 253 759 - 253 759 - 253 759 - 253 759 - 759 253 - 253 759 - 253 759 - 759 253 - 759 253 - 759 253 - 253 759 - 253 759 - 759 253 - 253 759 - 759 253 - 253 759 - 253 759 - 759 253 - -If we now take a careful look at these groups you can distinguish three types of groups: - -#. ``253 759`` -#. ``759 253`` - -So the first group is defined by a high second pulse, the second group has a low second pulse. We then get the following output: - -.. code-block:: guess - - 10001111110110001101 0110 - -Each (group) of numbers has a specific meaning: - -- UnitCode: 0 till 20 -- State: 20 - -Bits 21-24 are not used. - -.. code-block:: guess - - 10001111110110001101 0 - -- The ``UnitCode`` is defined as a binary number -- The ``State`` defines whether a sensor state is opened or closed - -So this code represents: - -- UnitCode: 589197 -- State: opened diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/index.rst deleted file mode 100644 index 4c5af59..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -Contact -======= - -.. toctree:: - :maxdepth: 1 - - kaku - elro - sc2262 - ev1527 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/kaku.rst deleted file mode 100644 index d2bb85d..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/kaku.rst +++ /dev/null @@ -1,147 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -KlikAanKlikUit -============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| KlikAanKlikUit | kaku_contact | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "contact": { - "protocol": [ "kaku_contact" ], - "id": [{ - "id": 100, - "unit": 0 - }], - "state": "closed" - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 67108863 | -+------------------+-----------------+ -| code | 0 - 15 | -+------------------+-----------------+ -| state | opened / closed | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 148 pulses like this - -.. code-block:: guess - - 294 2646 294 294 294 1176 294 294 294 1176 294 1176 294 294 294 294 294 1176 294 1176 294 294 294 294 294 1176 294 1176 294 294 294 1176 294 294 294 1176 294 294 294 294 294 1176 294 1176 294 294 294 1176 294 294 294 294 294 1176 294 294 294 1176 294 1176 294 294 294 294 294 1176 294 294 294 1176 294 1176 294 294 294 294 294 1176 294 294 294 1176 294 294 294 1176 294 1176 294 294 294 294 294 1176 294 294 294 1176 294 1176 294 294 294 294 294 1176 294 294 294 1176 294 1176 294 294 294 1176 294 294 294 294 294 1176 294 294 294 1176 294 1176 294 294 294 294 294 1176 294 1176 294 294 294 1176 294 294 294 1176 294 294 294 9996 - -The first 2 pulses are the ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 36 groups of 4 pulses (and thereby dropping the ``header`` and ``footer`` pulses). - -.. code-block:: guess - - 294 294 294 1176 - 294 294 294 1176 - 294 1176 294 294 - 294 294 294 1176 - 294 1176 294 294 - 294 294 294 1176 - 294 1176 294 294 - 294 1176 294 294 - 294 1176 294 294 - 294 294 294 1176 - 294 1176 294 294 - 294 1176 294 294 - 294 294 294 1176 - 294 294 294 1176 - 294 1176 294 294 - 294 294 294 1176 - 294 294 294 1176 - 294 1176 294 294 - 294 294 294 1176 - 294 294 294 1176 - 294 294 294 1176 - 294 1176 294 294 - 294 294 294 1176 - 294 294 294 1176 - 294 1176 294 294 - 294 294 294 1176 - 294 294 294 1176 - 294 1176 294 294 - 294 1176 294 294 - 294 294 294 1176 - 294 294 294 1176 - 294 1176 294 294 - 294 294 294 1176 - 294 1176 294 294 - 294 1176 294 294 - 294 1176 294 294 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. 294 1176 294 294 -#. 294 294 294 1176 - -So the first group is defined by a high 2nd and the second group has a high 4th pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: guess - - 001010111011001001000100100110010111 - -Each (group) of numbers has a specific meaning: - -- ID: 0 till 25 -- All: 26 -- State: 27 -- Unit: 28 till 31 -- Unknown: 32 till 35 - -.. code-block:: guess - - 00101011101100100100010010 0 1 1001 0111 - -- The ``ID`` is defined as a binary number -- The ``All`` tells us if a code was meant for all devices with the same ID -- The ``State`` defines whether a devices is opened or closed -- The ``Unit`` is also defined as a binary number -- The ``Unknown`` is also defined as a binary number(bits are missing in the closed state) - -So this code represents: - -- ID: 11454738 -- All: Single -- State: Opened -- Unit: 9 diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/sc2262.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/sc2262.rst deleted file mode 100644 index 10573ff..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/contact/sc2262.rst +++ /dev/null @@ -1,158 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -SC2262 Contact -============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| SC2262 | sc2262 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "contact": { - "protocol": [ "sc2262" ], - "id": [{ - "systemcode": 31, - "unitcode": 0 - }], - "state": "closed" - } - } - } - - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 31 | -+------------------+-----------------+ -| code | 0 - 31 | -+------------------+-----------------+ -| state | opened / closed | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: guess - - 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1728 1296 432 432 1296 432 1296 432 1296 1296 432 1296 432 1296 432 1296 432 1296 432 432 13392 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -The first six pulses are the address bits, followed by upto another 6 Address/Data Bits. Address Bits can have three states: 0, 1, F (tri-state). Data Bits have only two states: 0 or 1. - -.. code-block:: guess - - 432 1296 1296 432 - 432 1296 1296 432 - 432 1296 1296 432 - 432 1296 1296 432 - 432 1296 1296 432 - 432 1296 1296 432 - 432 1296 1296 432 - 432 1728 1296 432 - 432 1296 432 1296 - 432 1296 1296 432 - 1296 432 1296 432 - 1296 432 1296 432 - 432 14688 - -If we now take a careful look at these groups you can distinguish three types of groups: - -#. ``432 1296 432 1296`` - Logical Zero -#. ``1296 432 1296 432`` - Logical One -#. ``432 1296 1296 432`` - Logical Tri-State - - -.. code-block:: guess - - FFFFFF FF0F11 - -Each (group) of numbers has a specific meaning: - -- SystemCode: 0 till 5 -- UnitCode: 6 till 10 -- State: 11 - -Depending on the device the Unit Code my be shorter in order to provide more bits for state / data value conditions. - -.. code-block:: guess - - FFFFFF FF0F11 - -- The SystemCode is defined as a binary number -- The UnitCode is defined as a binary number -- The State defines whether a devices state is considered to be opened or closed - -So this code represents: - -- SystemCode: 0 -- UnitCode: 2 -- State: Closed - -.. code-block:: json - - { - "devices": { - "window": { - "protocol": [ "sc2262" ], - "id": [{ - "systemcode": 0, - "unitcode": 8 - }], - "state": "closed" - } - }, - "gui": { - "window": { - "name": "Bedroom", - "group": [ "Windows" ], - "media": [ "all" ] - } - } - } - -This code sets the state to opened: - -.. code-block:: console - - pilight-send -p raw -c "432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1728 1296 432 432 1296 432 1296 432 1296 1296 432 1296 432 1296 432 1296 432 1296 432 432 14680" - -This code sets the state to closed: - -.. code-block:: console - - pilight-send -p raw -c "432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1296 1296 432 432 1728 1296 432 432 1296 432 1296 432 1296 1296 432 1296 432 1296 432 432 1296 432 1296 432 14681" \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/_kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/_kaku.rst deleted file mode 100644 index 2826dd1..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/_kaku.rst +++ /dev/null @@ -1,223 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+--------------+ -| **Brand** | **Protocol** | -+----------------------+--------------+ -| KlikAanKlikUit | kaku_dimmer | -+----------------------+--------------+ -| Nexa WMR-252 | kaku_dimmer | -+----------------------+--------------+ -| Intertechno ITDM-250 | kaku_dimmer | -+----------------------+--------------+ -| Intertechno ITDM-150 | kaku_dimmer | -+----------------------+--------------+ -| Intertechno ITL-210 | kaku_dimmer | -+----------------------+--------------+ -| Intertechno ITL-250 | kaku_dimmer | -+----------------------+--------------+ -| Intertechno ITLR-300 | kaku_dimmer | -+----------------------+--------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -u --unit=unit control a device with this unit code - -i --id=id control a device with this id - -a --all send command to all devices with this id - -d --dimlevel=dimlevel send a specific dimlevel - -l --learn send multiple streams so dimmer can learn - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "kaku_dimmer" ], - "id": [{ - "id": 100, - "unit": 0 - }], - "state": "off", - "dimlevel": 15 - } - }, - "gui": { - "dimmer": { - "name": "Dimmer", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 67108863 | -+------------------+-----------------+ -| code | 0 - 31 | -+------------------+-----------------+ -| dimlevel | 0 - 15 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| dimlevel-minimum | 0 | number | Minimum dimlevel | -+--------------------+-------------+------------+-------------------------------------------------+ -| dimlevel-maximum | 15 | number | Maximum dimlevel | -+--------------------+-------------+------------+-------------------------------------------------+ -| all | 0 | 1 or 0 | | If specified this will trigger the "group" | -| | | | | function of the advanced remotes and trigger | -| | | | | all registered devices for the given unitcode | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Notes - -If you want your switch to learn new codes, you can use the following command: - -.. code-block:: console - - pilight-send -p kaku_dimmer -i 1 -u 1 -t -l - -If you want your switch to remove a learned code, you can use the following command: - -.. code-block:: console - - pilight-send -p kaku_dimmer -i 1 -u 1 -f -l - -.. rubric:: Protocol - -This protocol sends 148 pulses like this - -.. code-block:: console - - 286 2825 286 201 289 1337 287 209 283 1351 287 204 289 1339 288 207 288 1341 289 207 281 1343 284 205 292 1346 282 212 283 1348 282 213 279 1352 282 211 281 1349 282 210 283 1347 284 211 288 1348 281 211 285 1353 278 213 280 1351 280 232 282 1356 279 213 285 1351 276 215 285 1348 277 216 278 1359 278 216 279 1353 272 214 283 1358 276 216 276 1351 278 214 284 1357 275 217 276 1353 270 217 277 1353 272 220 277 1351 275 220 272 1356 275 1353 273 224 277 236 282 1355 272 1353 273 233 273 222 268 1358 270 219 277 1361 274 218 280 1358 272 1355 271 243 273 222 268 1358 270 219 277 1361 274 218 280 1358 272 1355 271 243 251 11302 - -The first 2 pulses are the ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 36 groups of 4 pulses (and thereby dropping the ``header`` and ``footer`` pulses). - -.. code-block:: console - - 286 201 289 1337 - 287 209 283 1351 - 287 204 289 1339 - 288 207 288 1341 - 289 207 281 1343 - 284 205 292 1346 - 282 212 283 1348 - 282 213 279 1352 - 282 211 281 1349 - 282 210 283 1347 - 284 211 288 1348 - 281 211 285 1353 - 278 213 280 1351 - 280 232 282 1356 - 279 213 285 1351 - 276 215 285 1348 - 277 216 278 1359 - 278 216 279 1353 - 272 214 283 1358 - 276 216 276 1351 - 278 214 284 1357 - 275 217 276 1353 - 270 217 277 1353 - 272 220 277 1351 - 275 220 272 1356 - 275 1353 273 224 - 277 236 282 1353 - 272 1353 273 277 - 273 222 268 1358 - 270 219 277 1361 - 274 218 280 1358 - 272 1355 271 243 - 273 222 268 1358 - 270 219 277 1361 - 274 218 280 1358 - 272 1355 271 243 - -If we now look at carefully at these groups you can distinguish three types of groups: - -- ``272 1355 271 243`` -- ``274 218 280 1358`` -- ``277 236 282 277`` - -So the first group is defined by a high 2nd, the second group has a high 4th pulse, and the third group has a low 2nd and a low 4th pulse. This third group is a special one but not much of a use while receiving. However, it must be taken care of when sending arctech dimmer codes. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: console - - 000000000000000000000000010100010001 - -Each (group) of numbers has a specific meaning: - -- ID: 0 till 25 -- All: 26 -- Check: 27 -- Unit: 28 till 31 -- Dimlevel: 32 till 35 - -.. code-block:: console - - 00000000000000000000000001 0 1 0001 0001 - -- The ``ID`` is defined as a binary number -- The ``All`` special pulse to identify the code was meant for a dimmer -- The ``Check`` defines whether a devices needs to be turned On or Off -- The ``Unit`` is also defined as a binary number -- The ``Dimlevel`` defines the specific dimlevel - -So this code represents: - -- ID: 1 -- All: Single -- Check: Valid -- Unit: 1 -- Dimlevel: 1 - -Another example: - -- ID: 123456 -- All: All -- Check: Valid -- Unit: 15 -- Dimlevel: 8 - -.. code-block:: console - - 000000000111100010010000001011111000 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/index.rst deleted file mode 100644 index ebdb4b8..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Dimmers -======= - -.. toctree:: - :maxdepth: 1 - - intertechno - kaku - nexa \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/intertechno.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/intertechno.rst deleted file mode 100644 index c28f3c5..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/intertechno.rst +++ /dev/null @@ -1,4 +0,0 @@ -Intertechno -=========== - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/kaku.rst deleted file mode 100644 index 82b17cf..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/kaku.rst +++ /dev/null @@ -1,4 +0,0 @@ -KlikAanKlikUit -============== - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/nexa.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/nexa.rst deleted file mode 100644 index a64751b..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/dimmer/nexa.rst +++ /dev/null @@ -1,4 +0,0 @@ -Nexa WMR-252 -============ - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/index.rst deleted file mode 100644 index 3437455..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/index.rst +++ /dev/null @@ -1,13 +0,0 @@ -433.92Mhz -========= - -.. toctree:: - :maxdepth: 3 - - alarm/index - contact/index - dimmer/index - motion/index - screen/index - weather/index - switch/index \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/ev1527.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/ev1527.rst deleted file mode 100644 index 5b77414..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/ev1527.rst +++ /dev/null @@ -1,127 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -EV1527 Motion -============= - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| EV1527 | ev1527 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "contact": { - "protocol": [ "ev1527" ], - "id": [{ - "unitcode": 0 - }], - "state": "closed" - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| unitcode | 0 - 1048575 | -+------------------+-----------------+ -| state | opened / closed | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: guess - - 253 759 759 253 759 253 253 759 253 759 253 759 253 759 253 759 253 759 759 253 253 759 253 759 759 253 759 253 759 253 253 759 253 759 759 253 253 759 759 253 253 759 253 759 759 253 253 8602 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -The first six pulses are the address bits, followed by upto another 6 Address/Data Bits. Address Bits can have three states: 0, 1, F (tri-state). Data Bits have only two states: 0 or 1. - -.. code-block:: guess - - 253 759 - 759 253 - 759 253 - 253 759 - 253 759 - 253 759 - 253 759 - 253 759 - 253 759 - 759 253 - 253 759 - 253 759 - 759 253 - 759 253 - 759 253 - 253 759 - 253 759 - 759 253 - 253 759 - 759 253 - 253 759 - 253 759 - 759 253 - -If we now take a careful look at these groups you can distinguish three types of groups: - -#. ``253 759`` -#. ``759 253`` - -So the first group is defined by a high second pulse, the second group has a low second pulse. We then get the following output: - -.. code-block:: guess - - 10001111110110001101 0110 - -Each (group) of numbers has a specific meaning: - -- UnitCode: 0 till 20 -- State: 20 - -Bits 21-24 are not used. - -.. code-block:: guess - - 10001111110110001101 0 - -- The ``UnitCode`` is defined as a binary number -- The ``State`` defines whether a sensor state is opened or closed - -So this code represents: - -- UnitCode: 589197 -- State: opened \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/index.rst deleted file mode 100644 index b454ef1..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -Motion -======= - -.. toctree:: - :maxdepth: 1 - - ev1527 - kaku \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/kaku.rst deleted file mode 100644 index 72e59c8..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/motion/kaku.rst +++ /dev/null @@ -1,150 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -KlikAanKlikUit -============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| KlikAanKlikUit | kaku_motion | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "contact": { - "protocol": [ "kaku_motion" ], - "id": [{ - "id": 100, - "unit": 0 - }], - "state": "on" - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| unitcode | 0 - 67108863 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 148 pulses like this - -.. code-block:: guess - - 286 2825 286 201 289 1337 287 209 283 1351 287 204 289 1339 288 207 288 1341 289 207 281 1343 284 205 292 1346 282 212 283 1348 282 213 279 1352 282 211 281 1349 282 210 283 1347 284 211 288 1348 281 211 285 1353 278 213 280 1351 280 232 282 1356 279 213 285 1351 276 215 285 1348 277 216 278 1359 278 216 279 1353 272 214 283 1358 276 216 276 1351 278 214 284 1357 275 217 276 1353 270 217 277 1353 272 220 277 1351 275 220 272 1356 275 1353 273 224 277 236 282 1355 272 1353 273 233 273 222 268 1358 270 219 277 1361 274 218 280 1358 272 1355 271 243 251 11302 - -The first 2 pulses are the ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 36 groups of 4 pulses (and thereby dropping the ``header`` and ``footer`` pulses). - -.. code-block:: guess - - 286 201 289 1337 - 287 209 283 1351 - 287 204 289 1339 - 288 207 288 1341 - 289 207 281 1343 - 284 205 292 1346 - 282 212 283 1348 - 282 213 279 1352 - 282 211 281 1349 - 282 210 283 1347 - 284 211 288 1348 - 281 211 285 1353 - 278 213 280 1351 - 280 232 282 1356 - 279 213 285 1351 - 276 215 285 1348 - 277 216 278 1359 - 278 216 279 1353 - 272 214 283 1358 - 276 216 276 1351 - 278 214 284 1357 - 275 217 276 1353 - 270 217 277 1353 - 272 220 277 1351 - 275 220 272 1356 - 275 1353 273 224 - 277 236 282 1355 - 272 1353 273 233 - 273 222 268 1358 - 270 219 277 1361 - 274 218 280 1358 - 272 1355 271 243 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. 272 1355 271 243 -#. 274 218 280 1358 - -So the first group is defined by a high 2nd and the second group has a high 4th pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: guess - - 00000000000000000000000001010001 - -Each (group) of numbers has a specific meaning: - -- ID: 0 till 25(Convert the binary code to decimal to get the correct id) -- All: 26 -- State: 27 -- Unit: 28 till 31 - -.. code-block:: guess - - 00000000000000000000000001 0 1 0001 - -- The ``ID`` is defined as a binary number -- The ``All`` tells us if a code was meant for all devices with the same ID -- The ``State`` defines whether a devices is opened or closed -- The ``Unit`` is also defined as a binary number - -So this code represents: - -- ID: 1 -- All: Single -- State: On -- Unit: 1 - -Another example: - -- ID: 123456 -- All: All -- State: Off -- Unit: 15 - -.. code-block:: guess - - 00000000011110001001000000101111 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/_kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/_kaku.rst deleted file mode 100644 index ac6b05c..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/_kaku.rst +++ /dev/null @@ -1,187 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| KlikAanKlikUit | kaku_screen | -+------------------+--------------+ -| DI-O (Chacon) | dio_screen | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - - -t --up send an up signal - -f --down send an down signal - -u --unit=unit control a device with this unit code - -i --id=id control a device with this id - -a --all send command to all devices with this id - -l --learn send multiple streams so screen can learn - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "screen": { - "protocol": [ "kaku_screen" ], - "id": [{ - "id": 100, - "unit": 0 - }], - "state": "down" - } - }, - "gui": { - "screen": { - "name": "Screen", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 67108863 | -+------------------+-----------------+ -| unit | 0 - 15 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| readonly | 0 | 1 or 0 | Disable controlling this device from the GUIs | -+------------------+-------------+------------+-----------------------------------------------+ -| confirm | 0 | 1 or 0 | Ask for confirmation when switching device | -+------------------+-------------+------------+-----------------------------------------------+ - -.. rubric:: Notes - -If you want your switch to learn new codes, you can use the following command: - -.. code-block:: console - - pilight-send -p kaku_screen -i 1 -u 1 -t -l - -If you want your switch to remove a learned code, you can use the following command: - -.. code-block:: console - - pilight-send -p kaku_screen -i 1 -u 1 -f -l - -.. rubric:: Protocol - -This protocol sends 132 pulses like this - -.. code-block:: guess - - 286 2825 286 201 289 1337 287 209 283 1351 287 204 289 1339 288 207 288 1341 289 207 281 1343 284 205 292 1346 282 212 283 1348 282 213 279 1352 282 211 281 1349 282 210 283 1347 284 211 288 1348 281 211 285 1353 278 213 280 1351 280 232 282 1356 279 213 285 1351 276 215 285 1348 277 216 278 1359 278 216 279 1353 272 214 283 1358 276 216 276 1351 278 214 284 1357 275 217 276 1353 270 217 277 1353 272 220 277 1351 275 220 272 1356 275 1353 273 224 277 236 282 1355 272 1353 273 233 273 222 268 1358 270 219 277 1361 274 218 280 1358 272 1355 271 243 251 11302 - -The first 2 pulses are the ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 36 groups of 4 pulses (and thereby dropping the ``header`` and ``footer`` pulses). - -.. code-block:: guess - - 286 201 289 1337 - 287 209 283 1351 - 287 204 289 1339 - 288 207 288 1341 - 289 207 281 1343 - 284 205 292 1346 - 282 212 283 1348 - 282 213 279 1352 - 282 211 281 1349 - 282 210 283 1347 - 284 211 288 1348 - 281 211 285 1353 - 278 213 280 1351 - 280 232 282 1356 - 279 213 285 1351 - 276 215 285 1348 - 277 216 278 1359 - 278 216 279 1353 - 272 214 283 1358 - 276 216 276 1351 - 278 214 284 1357 - 275 217 276 1353 - 270 217 277 1353 - 272 220 277 1351 - 275 220 272 1356 - 275 1353 273 224 - 277 236 282 1355 - 272 1353 273 233 - 273 222 268 1358 - 270 219 277 1361 - 274 218 280 1358 - 272 1355 271 243 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. 272 1355 271 243 -#. 274 218 280 1358 - -So the first group is defined by a high 2nd and the second group has a high 4th pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: guess - - 00000000000000000000000001010001 - -Each (group) of numbers has a specific meaning: - -- ID: 0 till 25 -- All: 26 -- State: 27 -- Unit: 28 till 31 - -.. code-block:: guess - - 00000000000000000000000001 0 1 0001 - -- The ``ID`` is defined as a binary number -- The ``All`` tells us if a code was meant for all devices with the same ID -- The ``State`` defines whether a devices is opened or closed -- The ``Unit`` is also defined as a binary number - -So this code represents: - -- ID: 1 -- All: Single -- State: Up -- Unit: 1 - -Another example: - -- ID: 123456 -- All: All -- State: Down -- Unit: 15 - -.. code-block:: guess - - 00000000011110001001000000101111 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/d_io.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/d_io.rst deleted file mode 100644 index 238c973..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/d_io.rst +++ /dev/null @@ -1,4 +0,0 @@ -D-IO (Chacon) -============= - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/index.rst deleted file mode 100644 index d8de4ce..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Screens -======= - -.. toctree:: - :maxdepth: 1 - - kaku - d_io - kaku_old \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/kaku.rst deleted file mode 100644 index 82b17cf..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/kaku.rst +++ /dev/null @@ -1,4 +0,0 @@ -KlikAanKlikUit -============== - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/kaku_old.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/kaku_old.rst deleted file mode 100644 index ca3db4d..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/screen/kaku_old.rst +++ /dev/null @@ -1,173 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -KlikAanKlikUit (Old) -==================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+------------------+ -| **Brand** | **Protocol** | -+------------------+------------------+ -| KlikAanKlikUit | kaku_screen_old | -+------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - - -t --up send an up signal - -f --down send an down signal - -u --unit=unit control a device with this unit code - -i --id=id control a device with this id - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "screen": { - "protocol": [ "kaku_screen_old" ], - "id": [{ - "id": 16, - "unit": 0 - }], - "state": "down" - } - }, - "gui": { - "screen": { - "name": "Screen", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 31 | -+------------------+-----------------+ -| unit | 0 - 15 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| readonly | 0 | 1 or 0 | Disable controlling this device from the GUIs | -+------------------+-------------+------------+-----------------------------------------------+ -| confirm | 0 | 1 or 0 | Ask for confirmation when switching device | -+------------------+-------------+------------+-----------------------------------------------+ - -.. rubric:: Notes - - -The old KlikAanKlikUit devices work setting two wheels: group (0-H) and device number (0-16). To control a device from pilight you need to send the correct group and unit id, these do not correspond 1:1. - -A-1 on the unit corresponds with unit 0 id 0 in pilight A-2 on the unit corresponds with unit 0 id 1 in pilight etc. - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: guess - - 295 1180 295 1180 295 1180 1180 295 295 1180 295 1180 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 1180 295 1180 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 11210 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: guess - - 295 1180 295 1180 - 295 1180 1180 295 - 295 1180 295 1180 - 295 1180 1180 295 - 295 1180 1180 295 - - 295 1180 1180 295 - 295 1180 1180 295 - 295 1180 1180 295 - 295 1180 295 1180 - 295 1180 1180 295 - - 295 1180 1180 295 - 295 1180 1180 295 - - 295 11210 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. 295 1180 1180 295 -#. 295 1180 295 1180 - -So the first group is defined by a high 3th pulse and the second group has a low 3rd pulse. In this case we say a high 3rd pulse means a 0 and a high 3rd pulse means a 1. We then get the following output: - -.. code-block:: guess - - 10100 00010 0 0 - -Each (group) of numbers has a specific meaning: - -- Unit: 0 till 5 (inversed) -- ID: 6 till 10 (inversed) -- Fixed: 11 (always 0) -- State: 12 (inversed) - -.. code-block:: guess - - 10100 00010 0 0 - -- The ``Unit`` is defined as a binary number -- The ``ID`` is defined as a binary number -- The ``Fixed`` is always 0 -- The ``State`` defines whether a devices needs to be go Up or Down - -So this code represents: - -- Unit: 20 -- ID: 1 -- Fixed: always 0 -- State: Down - -Another example: - -- Unit: 0 -- ID: 4 -- Fixed: always 0 -- State: Up - -.. code-block:: guess - - 00000 00100 0 1 - -Furthermore the protocol filters out false positives by checking if: - -#. Every 1st bit of the first 12 groups of 4 bits is always LOW (0) -#. 2nd bit of the first 12 groups of 4 bits is always HIGH (1) -#. 3rd and 4th bit of the first 12 groups of 4 bits are different (NOT EQUAL) -#. Bits 49 and 50 are LOW (0) and HIGH (1) respectively (fixed footer) - -This makes the protocol more accurate because it will respond rarely now when sartano commands are sent. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_elro_800.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_elro_800.rst deleted file mode 100644 index b72fdc1..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_elro_800.rst +++ /dev/null @@ -1,178 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Elro 800 Series | elro_800_switch | -+----------------------+------------------+ -| Brennenstuhl | brennenstuhl | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -s --systemcode=systemcode control a device with this systemcode - -u --unitcode=unitcode control a device with this unitcode - -t --on send an on signal - -f --off send an off signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "elro_800_switch" ], - "id": [{ - "systemcode": 31, - "unitcode": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| systemcode | 0 - 1023 | -+------------------+-----------------+ -| unitcode | 0 - 31 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. Note:: Workaround for 800 Series - - 1. Set your remote DIP switches like this off|off|on|off (AB660 Code) if possible - 2. Now look for systemcode and unitcode with pilight-receive - 3. Setup the config.json with the received results - 4. Get the switches in learning mode and push the buttons on the webgui accordingly to the unit. - 5. This should work until there is a protocol for the 800 series. - - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 960 320 320 960 960 320 320 960 960 320 320 960 960 320 320 960 320 960 320 960 960 320 320 9920 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 960 320 - 320 960 960 320 - 320 960 960 320 - 320 960 960 320 - 320 960 320 960 - 320 960 960 320 - 320 9920 - -If we now look at carefully at these groups you can distinguish three types of groups: - -- ``320 960 320 960`` -- ``320 960 960 320`` - -So the first group is defined by a high 4th pulse and the second group has a low 4th pulse. In this case we say a high 4th pulse means a 1 and a low 4th pulse means a 0. We then get the following output: - -.. code-block:: console - - 11111 10000 1 0 - -Each (group) of numbers has a specific meaning: - -- SystemCode: 0 till 5 -- UnitCode: 6 till 10 -- State: 11 -- Check: 12 (inverse state) - - -- The ``SystemCode`` is defined as a binary number -- The ``UnitCode`` is defined as a binary number -- The ``State`` defines whether a devices needs to be turned On or Off -- The ``Check`` defines whether a devices needs to be turned On or Off (but is inverse) - -So this code represents: - -- SystemCode: 31 -- UnitCode: 1 -- State: On -- Check: On (inverse state) - -.. code-block:: console - - 00000 00100 0 1 - -Another example: - -- SystemCode: 0 -- UnitCode: 4 -- State: Off -- Check: Off (inverse state) - -Furthermore the protocol filters out false positives by checking if: - -- Every 1st bit of the first 12 groups of 4 bits is always LOW (0) -- 2nd bit of the first 12 groups of 4 bits is always HIGH (1) -- 3rd and 4th bit of the first 12 groups of 4 bits are different (NOT EQUAL) -- Bits 49 and 50 are LOW (0) and HIGH (1) respectively (fixed footer) - -This makes the protocol more accurate because it will respond less when arctech_old commands are sent. - -The numeric mapping of a button on the remote control is binary counted, as follows: - -- A = 1 -- B = 2 -- C = 4 -- D = 8 -- E = 16 - -All possible combinations of dip switches on the socket can be used with pilight. For instance, if you set the switches that correspond to A and E, the socket will react on unit code “A+E”: 17 (1+16). By pushing A and E simultaneously on the remote, you can also switch the corresponding socket. However, this may also trigger sockets that are listening to A and/or E if you don't push both buttons at exactly the same time. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_kaku.rst deleted file mode 100644 index a06d725..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_kaku.rst +++ /dev/null @@ -1,208 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+--------------------+ -| **Brand** | **Protocol** | -+----------------------+--------------------+ -| CoCo Technologies | coco_switch | -+----------------------+--------------------+ -| D-IO (Chacon) | dio_switch | -+----------------------+--------------------+ -| Intertechno | intertechno_switch | -+----------------------+--------------------+ -| KlikAanKlikUit | kaku_switch | -+----------------------+--------------------+ -| Nexa | nexa_switch | -+----------------------+--------------------+ -| Rev Ritter 8341LC | intertechno_switch | -+----------------------+--------------------+ -| Rev Ritter 8342LC | intertechno_switch | -+----------------------+--------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -t --on send an on signal - -f --off send an off signal - -u --unit=unit control a device with this unit code - -i --id=id control a device with this id - -a --all send command to all devices with this id - -l --learn send multiple streams so switch can learn - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "kaku_switch" ], - "id": [{ - "id": 100, - "unit": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 67108863 | -+------------------+-----------------+ -| unit | 0 - 15 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| all | 0 | 1 or 0 | | If specified this will trigger the "group" | -| | | | | function of the advanced remotes and trigger | -| | | | | all registered devices for the given unitcode | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Notes - -If you want your switch to learn new codes, you can use the following command: - -.. code-block:: console - - pilight-send -p kaku_switch -i 1 -u 1 -t -l - -If you want your switch to remove a learned code, you can use the following command: - -.. code-block:: console - - pilight-send -p kaku_switch -i 1 -u 1 -f -l - -.. rubric:: Protocol - -This protocol sends 132 pulses like this - -.. code-block:: console - - 286 2825 286 201 289 1337 287 209 283 1351 287 204 289 1339 288 207 288 1341 289 207 281 1343 284 205 292 1346 282 212 283 1348 282 213 279 1352 282 211 281 1349 282 210 283 1347 284 211 288 1348 281 211 285 1353 278 213 280 1351 280 232 282 1356 279 213 285 1351 276 215 285 1348 277 216 278 1359 278 216 279 1353 272 214 283 1358 276 216 276 1351 278 214 284 1357 275 217 276 1353 270 217 277 1353 272 220 277 1351 275 220 272 1356 275 1353 273 224 277 236 282 1355 272 1353 273 233 273 222 268 1358 270 219 277 1361 274 218 280 1358 272 1355 271 243 251 11302 - -The first 2 pulses are the ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 32 groups of 4 pulses (and thereby dropping the ``header`` and ``footer`` pulses). - -.. code-block:: console - - 286 201 289 1337 - 287 209 283 1351 - 287 204 289 1339 - 288 207 288 1341 - 289 207 281 1343 - 284 205 292 1346 - 282 212 283 1348 - 282 213 279 1352 - 282 211 281 1349 - 282 210 283 1347 - 284 211 288 1348 - 281 211 285 1353 - 278 213 280 1351 - 280 232 282 1356 - 279 213 285 1351 - 276 215 285 1348 - 277 216 278 1359 - 278 216 279 1353 - 272 214 283 1358 - 276 216 276 1351 - 278 214 284 1357 - 275 217 276 1353 - 270 217 277 1353 - 272 220 277 1351 - 275 220 272 1356 - 275 1353 273 224 - 277 236 282 1355 - 272 1353 273 233 - 273 222 268 1358 - 270 219 277 1361 - 274 218 280 1358 - 272 1355 271 243 - -If we now look at carefully at these groups you can distinguish two types of groups: - -- ``272 1355 271 243`` -- ``274 218 280 1358`` - -So the first group is defined by a high 2nd and the second group has a high 4th pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: console - - 00000000000000000000000001010001 - -Each (group) of numbers has a specific meaning: - -- ID: 0 till 25(Convert the binary code to decimal to get the correct id) -- All: 26 -- State: 27 -- Unit: 28 till 31 - -.. code-block:: console - - 00000000000000000000000001 0 1 0001 - -- The ``ID`` is defined as a binary number -- The ``All`` tells us if a code was meant for all devices with the same ID -- The ``State`` defines whether a devices needs to be turned On or Off -- The ``Unit`` is also defined as a binary number - -So this code represents: - -- ID: 1 -- All: Single -- State: On -- Unit: 1 - -Another example: - -- ID: 123456 -- All: All -- State: Off -- Unit: 15 - -.. code-block:: console - - 00000000011110001001000000101111 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_kaku_old.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_kaku_old.rst deleted file mode 100644 index 73fe57a..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_kaku_old.rst +++ /dev/null @@ -1,201 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Cogex | cogex | -+----------------------+------------------+ -| Dúwi Terminal | duwi | -+----------------------+------------------+ -| Eurodomest | kaku_switch_old | -+----------------------+------------------+ -| Intertechno | intertechno_old | -+----------------------+------------------+ -| Dúwi Terminal | duwi | -+----------------------+------------------+ -| KlikAanKlikUit | kaku_switch_old | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -t --on send an on signal - -f --off send an off signal - -u --unit=unit control a device with this unit code - -i --id=id control a device with this id - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "kaku_switch_old" ], - "id": [{ - "id": 10, - "unit": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 31 | -+------------------+-----------------+ -| unit | 0 - 15 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Notes - -The old KlikAanKlikUit devices work setting two wheels: group (0-H) and device number (0-16). To control a device from pilight you need to send the correct group and unit id, these do not correspond 1:1. - -A-1 on the unit corresponds with unit 0 id 0 in pilight A-2 on the unit corresponds with unit 0 id 1 in pilight etc. - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 295 1180 295 1180 295 1180 1180 295 295 1180 295 1180 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 1180 295 1180 295 1180 1180 295 295 1180 1180 295 295 1180 1180 295 295 11210 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 295 1180 295 1180 - 295 1180 1180 295 - 295 1180 295 1180 - 295 1180 1180 295 - 295 1180 1180 295 - - 295 1180 1180 295 - 295 1180 1180 295 - 295 1180 1180 295 - 295 1180 295 1180 - 295 1180 1180 295 - - 295 1180 1180 295 - 295 1180 1180 295 - - 295 11210 - -If we now look at carefully at these groups you can distinguish two types of groups: - -- ``295 1180 1180 295`` -- ``295 1180 295 1180`` - -So the first group is defined by a high 3th pulse and the second group has a low 3rd pulse. In this case we say a high 3rd pulse means a 0 and a low 3rd pulse means a 1. We then get the following output: - -.. code-block:: console - - 10100 00010 0 0 - -Each (group) of numbers has a specific meaning: - -- Unit: 0 till 5 (inversed) -- ID: 6 till 10 (inversed) -- Fixed: 11 (always 0) -- State: 12 (inversed) - -.. code-block:: console - - 10100 00010 0 0 - -- The ``Unit`` is defined as a binary number -- The ``ID`` is defined as a binary number -- The ``Fixed`` is always 0 -- The ``State`` defines whether a devices needs to be turned On or Off - -So this code represents: - -- Unit: 20 -- ID: 1 -- Fixed: always 0 -- State: Off - -Another example: - -- Unit: 0 -- ID: 4 -- Fixed: always 0 -- State: On - -.. code-block:: console - - 00000 00100 0 1 - -Furthermore the protocol filters out false positives by checking if: - -- Every 1st bit of the first 12 groups of 4 bits is always LOW (0) -- 2nd bit of the first 12 groups of 4 bits is always HIGH (1) -- 3rd and 4th bit of the first 12 groups of 4 bits are different (NOT EQUAL) -- Bits 49 and 50 are LOW (0) and HIGH (1) respectively (fixed footer) - -This makes the protocol more accurate because it will respond rarely now when sartano commands are sent. - -.. note:: **Eurodomest** - - The Eurodomest (Intertechno) switches listens to the kaku_switch_old protocol, but the remote doesn't send using the kaku_switch_old protocol. When using pilight-receive, the following protocols are received using the remote: - - - elro_800_contact - - elro_800_switch - - ehome - - cleverwatts - - To use the Eurodomest switches with the kaku_switch_old protocol on pilight, the following steps have to be performed: - - - Hold the On/Off button until the LED flashes. - - In a terminal window do: - - .. code-block:: console - - pilight-send -p kaku_switch_old -i -u 0 -t - - - If everything is Ok the switch is programmed. - - For wall-plug 2 & 3 change the value -u - diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_rsl366.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_rsl366.rst deleted file mode 100644 index 2fcca96..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/_rsl366.rst +++ /dev/null @@ -1,166 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Rising Sun RSL366 | rsl366 | -+----------------------+------------------+ -| Brennenstuhl | brennenstuhl | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -s --systemcode=systemcode control a device with this systemcode - -u --programcode=programcode control a device with this programcode - -t --on send an on signal - -f --off send an off signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "switch": { - "protocol": [ "promax" ], - "id": [{ - "systemcode": 4, - "programcode": 1 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| systemcode | 0 - 4 | -+------------------+-----------------+ -| unitcode | 0 - 4 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. note:: **RSL366** - - The RSL366 switches come with two dials, one selecting the Systemcode (1 to 4) and the Programcode (1 to 4). The systemcode allows one remote to control up to 16 switches. The systemcode parameter designates the dial on top of the back side of the switch, and the small lever on the back of the remote. The programcode parameter designates the lower dial on the back of the switch, and the individual buttons on the face of the remote. So if your switch has the higher dial set to 4, and the lower one set to 1, you should use: - - .. code-block:: console - - systemcode: 4 - programcode: 1 - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 390 1170 1170 390 390 1170 1170 390 390 1170 1170 390 390 1170 390 1170 390 1170 390 1170 390 1170 1170 390 390 1170 1170 390 390 1170 1170 390 390 1170 1170 390 390 1170 1170 390 390 1170 1170 390 390 1170 1170 390 390 13260 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 390 1170 - - 390 1170 390 1170 - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 1170 390 - - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 1170 390 - - 390 1170 1170 390 - -If we now look at carefully at these groups you can distinguish three types of groups: - -- ``390 1170 1170 390`` -- ``390 1170 390 1170`` - -#. The first group is defined by a low 1st and low 4th pulse, and we call it low. -#. The second group has a high 2nd and 4th pulse, and we call it high. - -We then get the following output: - -.. code-block:: console - - LLLH HLLL LL LL - -All H's can be translated to 1. All L's can be translated to 0. - -Each (group) of numbers has a specific meaning: - -- Systemcode: 1 till 4 -- Programcode: 5 till 8 -- 9 to 11 are always low and don't convey any information -- State: 12 (state) - -.. code-block:: console - - 0001 1000 000 0 - -- The ``SystemCode`` is defined as position of the pulse group that bears the **high** signal in the first grouping (i.e. if the third pulse group is high then systemcode is 3) -- The ``ProgramCode`` is defined as the position of the pulse group that bears the **high** signal in the second grouping (i.e. if the second pulse group is high then systemcode is 2) -- The ``State`` defines whether a devices needs to be turned On or Off. If it bears the **high** pulse group - the device must be turned off, if it bears the **low** pulse group it must be turned on - -So this code represents: - -- SystemCode: 4 -- ProgramCode: 1 -- State: On - -Another example: - -- Unit: 1 -- ID: 3 -- State: Off - -.. code-block:: console - - 1000 0010 000 1 diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/beamish.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/beamish.rst deleted file mode 100644 index 44617f4..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/beamish.rst +++ /dev/null @@ -1,221 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Beamish -======= - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Beamish 4-AE4 | beamish_switch | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -t --on send a toggle state signal to the device - -f --off send a toggle state signal to the device - -i --id=id control the device with this system id (1 ... 65535) - -u --unit=unit control the device with this unit code (1 ... 4) - -a --all send on/off command to all device units belonging to this system id - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "beamish_switch" ], - "id": [{ - "id": 8, - "unit": 2 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| systemcode | 1 - 65535 | -+------------------+-----------------+ -| unit | 1 - 4 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 323 1292 323 1292 323 1292 323 1292 323 1292 323 1292 323 1292 323 1292 323 1292 323 1292 323 1292 323 1292 1292 323 323 1292 323 1292 323 1292 323 1292 323 1292 1292 323 1292 323 323 1292 323 1292 323 1292 323 1292 323 10982 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 1292 323 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 1292 323 - 1292 323 - 323 1292 - 323 1292 - 323 1292 - 323 1292 - 323 10982 - -If we now look at carefully at these groups you can distinguish three types of groups: - -- ``323 1292`` -- ``1292 323`` - -The 1st group is defined by a short-long sequence (logical 0) The 2nd group is defined by a long-short sequence (logical 1): - -.. code-block:: console - - 000000000000100000110000 - -We can group the sequence of bits into the following groups A and B: - -.. code-block:: console - - AAAAAAAAAAAAAAAA BBBB BBBB - 0000000000001000 0011 0000 - -Each of the groups of bits (A and B) has a specific meaning: - -+-----------+-----------+-----------------+------------+-----------------+ -| **Group** | **Bit #** | **Config name** | **Range** | **Description** | -+-----------+-----------+-----------------+------------+-----------------+ -| A | 1 to 16 | id | 1 to 65535 | SystemCode id | -+-----------+-----------+-----------------+------------+-----------------+ -| B | 17 to 24 | unit | 1 to 4 | ButtonCode unit | -+-----------+-----------+-----------------+------------+-----------------+ - -The protocol driver creates the binary presentation as required by the device - -+------+------+-------+-------------------------------+ -| 1100 | 0000 | -u 1 | Button A Toggle device status | -+------+------+-------+-------------------------------+ -| 0011 | 0000 | -u 2 | Button B Toggle device status | -+------+------+-------+-------------------------------+ -| 0000 | 1100 | -u 3 | Button C Toggle device status | -+------+------+-------+-------------------------------+ -| 0000 | 0011 | -u 4 | Button D Toggle device status | -+------+------+-------+-------------------------------+ -| 0000 | 1111 | -a -t | Button ALL ON | -+------+------+-------+-------------------------------+ -| 1100 | 0011 | -a -f | Button ALL OFF | -+------+------+-------+-------------------------------+ - -So this code represents: - -.. code-block:: console - - { - "code": { - "id": 8, - "unit": 2 - }, - "origin": "receiver", - "protocol": "beamish_switch", - "uuid": "0000-00-00-00-000000", - "repeats": 2 - } - -.. rubric:: Examples - -CLI command: - -.. code-block:: console - - pilight-send -p beamish_switch -i 8 -u 1 - -.. code-block:: console - - { - "code": { - "systemcode": 2, - "id": 8, - "unit": 1 - }, - "origin": "receiver", - "protocol": "beamish_switch", - "uuid": "0000-00-00-00-000000", - "repeats": 1 - } - -.. code-block:: console - - pilight-send -p beamish_switch -i 8 -a -t - -.. code-block:: console - - { - "origin": "sender", - "protocol": "beamish_switch", - "code": { - "id": 8, - "all": 1, - "state": "on" - }, - "repeat": 1, - "uuid": "0000-00-00-00-000000" - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/brennenstuhl.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/brennenstuhl.rst deleted file mode 100644 index d59f633..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/brennenstuhl.rst +++ /dev/null @@ -1,4 +0,0 @@ -Brennenstuhl -============= - -.. include:: _elro_800.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/byebyestandby.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/byebyestandby.rst deleted file mode 100644 index c8af038..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/byebyestandby.rst +++ /dev/null @@ -1,4 +0,0 @@ -ByeByeStandby -============= - -.. include:: _kaku_old.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/clarus.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/clarus.rst deleted file mode 100644 index 045542e..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/clarus.rst +++ /dev/null @@ -1,160 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Clarus -====== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Clarus | clarus_switch | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -i --id=id control a device with this systemcode - -u --unit=unit control a device with this programcode - -t --on send an on signal - -f --off send an off signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "clarus_switch" ], - "id": [{ - "id": "A2", - "unit": 10 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | A0 - F32 | -+------------------+-----------------+ -| unit | 0 - 63 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 189 567 567 189 189 567 567 189 189 567 189 567 189 567 567 189 189 567 189 567 189 567 567 189 189 567 567 189 189 567 567 189 189 567 189 567 567 189 567 189 189 567 189 567 567 189 567 189 189 6426 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 189 567 567 189 - 189 567 567 189 - 189 567 189 567 - 189 567 567 189 - 189 567 189 567 - - 189 567 567 189 - 189 567 567 189 - 189 567 567 189 - 189 567 189 567 - 567 189 567 189 - - 189 567 189 567 - 567 189 567 189 - - 189 6426 - -If we now look at carefully at these groups you can distinguish three types of groups: - -#. ``189 567 567 189`` -#. ``567 189 567 189`` -#. ``189 567 189 567`` - -- The first group is defined by a low 1st and low 4rd pulse pulse, hence we call it low. -- The second group has a high 1st and 3rd pulse, hence we call it med. -- The final group has a low 1st and low 3rd pulse, hence we call it high. - -We then get the following output: - -.. code-block:: console - - LLHLH LLLHM HM - -All L's can be translated to 0, the H's to 1's, and M's to 2. - -Each (group) of numbers has a specific meaning: - -- Unit: 0 till 5 -- ID: 6 till 10 -- State: 12 (state) - -.. code-block:: console - - 00101 00012 12 - -- The ``Unit`` is defined as a binary number -- The ``ID`` is defined as a binary number combined with a letter -- The ``State`` defines whether a devices needs to be turned On or Off - -So this code represents: - -- Unit: 10 -- ID: A2 -- State: On - -Another example: - -- Unit: 0 -- ID: B1 -- State: Off - -.. code-block:: console - - 00101 00021 21 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/cleverwatts.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/cleverwatts.rst deleted file mode 100644 index 4690a24..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/cleverwatts.rst +++ /dev/null @@ -1,178 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Cleverwatts -=========== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Cleverwatts | cleverwatts | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -i --id=id control a device with this id - -u --unit=unit control a device with this unit - -t --on send an on signal - -f --off send an off signal - -a --all send an all signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "cleverwatts" ], - "id": [{ - "id": 73404, - "unit": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 1 - 1048575 | -+------------------+-----------------+ -| unit | 0 - 3 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 270 810 810 270 810 270 270 810 810 270 810 270 810 270 270 810 810 270 270 810 810 270 270 810 810 270 270 810 270 810 810 270 270 810 270 810 270 810 270 810 810 270 810 270 810 270 270 810 270 9180 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 270 810 - 810 270 - 810 270 - 270 810 - 810 270 - 810 270 - 810 270 - 270 810 - 810 270 - 270 810 - 810 270 - 270 810 - 810 270 - 270 810 - 270 810 - 810 270 - 270 810 - 270 810 - 270 810 - 270 810 - 810 270 - 810 270 - 810 270 - 270 810 - -If we now look at carefully at these groups you can distinguish three types of groups: - -#. ``270 810`` -#. ``810 270`` - -- The first group is defined by a low 1st and high 2nd pulse, hence we call it low. -- The second group has a high 1st and low 2nd pulse, hence we call it high. - -We then get the following output: - -.. code-block:: console - - 0 1 - 1 0 - 1 0 - 0 1 - 1 0 - 1 0 - 1 0 - 0 1 - 1 0 - 0 1 - 1 0 - 0 1 - 1 0 - 0 1 - 0 1 - 1 0 - 0 1 - 0 1 - 0 1 - 0 1 - 1 0 - 1 0 - 1 0 - 0 1 - -We then remove the first column of numbers and then put the remaining numbers in a row: - -.. code-block:: console - - 1001000101011011110001 - -Each (group) of numbers has a specific meaning and are defined in binary format: - -- ID: 0 till 19 -- State: 20 -- Unit: 21 and 22 -- All: 23 - -So this code represents: - -- Unit: 595311 -- ID: 0 -- State: On -- All: Single \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/coco.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/coco.rst deleted file mode 100644 index bba13c8..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/coco.rst +++ /dev/null @@ -1,4 +0,0 @@ -CoCo Technologies -================= - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/cogex.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/cogex.rst deleted file mode 100644 index a900513..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/cogex.rst +++ /dev/null @@ -1,4 +0,0 @@ -Cogex -===== - -.. include:: _kaku_old.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/dio.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/dio.rst deleted file mode 100644 index 238c973..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/dio.rst +++ /dev/null @@ -1,4 +0,0 @@ -D-IO (Chacon) -============= - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/duwi.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/duwi.rst deleted file mode 100644 index 9d9e352..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/duwi.rst +++ /dev/null @@ -1,4 +0,0 @@ -Dúwi Terminal -============= - -.. include:: _kaku_old.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_300.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_300.rst deleted file mode 100644 index be7e69c..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_300.rst +++ /dev/null @@ -1,274 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Elro HE (300 Series) -==================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Elro 300 Series | elro_300_switch | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -s --systemcode=systemcode control a device with this systemcode - -u --unitcode=unitcode control a device with this unitcode - -t --on send an on signal - -f --off send an off signal - -a --all trigger group switching - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "elro_300_switch" ], - "id": [{ - "systemcode": 123456, - "unitcode": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| systemcode | 0 - 4294967295 | -+------------------+-----------------+ -| unitcode | 0 - 99 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+----------------------+-------------+------------+------------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+------------------------------------------------------------+ -| all | 1 | 1 or 0 | | If specified this will trigger the **group** function of | -| | | | | the advanced remotes and trigger all registered devices | -| | | | | for the given Systemcode | -+----------------------+-------------+------------+------------------------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. Note:: - - The group button appears to be sending the unitcode of I-1 (First band, first unit) no matter to which band the remote is currently set. - -.. rubric:: Protocol - -This protocol sends 116 pulses like this - -.. code-block:: console - - 302 1208 302 1208 302 302 302 302 302 302 302 1208 302 1208 302 1208 302 1208 302 302 302 302 302 1208 302 302 302 1208 302 1208 302 1208 302 1208 302 302 302 302 302 1208 302 302 302 1208 302 1208 302 302 302 302 302 1208 302 302 302 1208 302 1208 302 1208 302 1208 302 302 302 302 302 1208 302 1208 302 302 302 1208 302 1208 302 302 302 302 302 1208 302 302 302 1208 302 1208 302 302 302 1208 302 1208 302 302 302 1208 302 302 302 1208 302 302 302 302 302 1208 302 1208 302 1208 302 302 302 10268 - -These pulses are separated into groups of 2: - -.. code-block:: console - - 302 1208 - 302 1208 - 302 302 - 302 302 - 302 302 - 302 1208 - 302 1208 - 302 1208 - 302 1208 - 302 302 - 302 302 - 302 1208 - 302 302 - 302 1208 - 302 1208 - 302 1208 - 302 1208 - 302 302 - 302 302 - 302 1208 - 302 302 - 302 1208 - 302 1208 - 302 302 - 302 302 - 302 1208 - 302 302 - 302 1208 - 302 1208 - 302 1208 - 302 1208 - 302 302 - 302 302 - 302 1208 - 302 1208 - 302 302 - 302 1208 - 302 1208 - 302 302 - 302 302 - 302 1208 - 302 302 - 302 1208 - 302 1208 - 302 302 - 302 1208 - 302 1208 - 302 302 - 302 1208 - 302 302 - 302 1208 - 302 302 - 302 302 - 302 1208 - 302 1208 - 302 1208 - 302 302 - 302 10268 - -There are several easily identifiable facts here: - -- ``320 960 320 960`` -- ``320 960 960 320`` - -#. The baseline is at 302 -#. The high Pulse is basline * 4 = 1208 -#. The last 2-pulse sequence is special, it's the footer of the message - -Using a translation pattern of **302 1208** → 1 and **302 302** → 0 we translate this sequence into the following pattern - -.. code-block::console - - 1100011110010111100101100101111001101100101101101010011101 - -Testing and some outside info reveals the following sections: - -.. code-block: console - - AAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCDDEEFFFFFFG - - A = Startbits/preamble - B = Address (32 Bit system code) - C = Group Code (Grouped: 1100, Non-Grouped: 1011) - D = Command, (On: 01, Off: 10) - E = Group Code 2 (Grouped: 11, Non Grouped: 01) - F = UnitCode - G = Stopbit - -So this code represents: - -- SystemCode: 3165844325 -- UnitCode: 28 -- State: Off -- UnitCode: NotSet - -The protocol filters out false positives by checking if: - -#. Every 1st pulse in groups of 2 is a low pulse -#. The last two pulses are 302 and 10268 (fixed footer) - -This is the readout from the writer's reference HE300 remote - -+----------+----------+--------------+------------+------------+ -| **Band** | **Code** | **UnitCode** | **GroupA** | **GroupB** | -+----------+----------+--------------+------------+------------+ -| I | 1 | 56 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| I | 2 | 52 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| I | 3 | 44 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| I | 4 | 28 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| II | 1 | 50 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| II | 2 | 42 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| II | 3 | 26 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| II | 4 | 38 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| III | 1 | 22 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| III | 2 | 14 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| III | 3 | 49 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| III | 4 | 41 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| IV | 1 | 25 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| IV | 2 | 37 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| IV | 3 | 21 | 13 | 2 | -+----------+----------+--------------+------------+------------+ -| IV | 4 | 13 | 13 | 2 | -+----------+----------+--------------+------------+------------+ - -This is translated: - -.. code-block:: console - - 1-1 11000111100 10111100101100101111001101100101 1011 10 01 000111 1 - 1-2 11000111100 10111100101100101111001101100101 1011 10 01 001011 1 - 1-3 11000111100 10111100101100101111001101100101 1011 10 01 001101 1 - 1-4 11000111100 10111100101100101111001101100101 1011 10 01 001110 1 - 2-1 11000111100 10111100101100101111001101100101 1011 10 01 010011 1 - 2-2 11000111100 10111100101100101111001101100101 1011 10 01 010101 1 - 2-3 11000111100 10111100101100101111001101100101 1011 10 01 010110 1 - 2-4 11000111100 10111100101100101111001101100101 1011 10 01 011001 1 - 3-1 11000111100 10111100101100101111001101100101 1011 10 01 011010 1 - 3-2 11000111100 10111100101100101111001101100101 1011 10 01 011100 1 - 3-3 11000111100 10111100101100101111001101100101 1011 10 01 100011 1 - 3-4 11000111100 10111100101100101111001101100101 1011 10 01 100101 1 - 4-1 11000111100 10111100101100101111001101100101 1011 10 01 100110 1 - 4-2 11000111100 10111100101100101111001101100101 1011 10 01 101001 1 - 4-3 11000111100 10111100101100101111001101100101 1011 10 01 101010 1 - 4-4 11000111100 10111100101100101111001101100101 1011 10 01 101100 1 - - G1 11000111100 10111100101100101111001101100101 1100 10 11 000111 1 - G2 11000111100 10111100101100101111001101100101 1100 10 11 000111 1 - G3 11000111100 10111100101100101111001101100101 1100 10 11 000111 1 - G4 11000111100 10111100101100101111001101100101 1100 10 11 000111 1 diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_400.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_400.rst deleted file mode 100644 index f0df75e..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_400.rst +++ /dev/null @@ -1,154 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Elro HE (300 Series) -==================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Elro 400 Series | elro_400_switch | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -s --systemcode=systemcode control a device with this systemcode - -u --unitcode=unitcode control a device with this unitcode - -t --on send an on signal - -f --off send an off signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "elro_400_switch" ], - "id": [{ - "systemcode": 31, - "unitcode": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| systemcode | 0 - 31 | -+------------------+-----------------+ -| unitcode | 0 - 31 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 320 960 960 320 320 960 960 320 320 960 960 320 320 960 960 320 320 960 320 960 320 960 960 320 320 9920 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 320 960 - 320 960 960 320 - 320 960 960 320 - 320 960 960 320 - 320 960 960 320 - 320 960 320 960 - 320 960 960 320 - 320 9920 - -If we now look at carefully at these groups you can distinguish two types of groups: - -- ``320 960 320 960`` -- ``320 960 960 320`` - -So the first group is defined by a high 4th pulse and the second group has a low 4th pulse. In this case we say a high 4th pulse means a 0 and a low 4th pulse means a 1. We then get the following output: - -.. code-block::console - - 00000 01111 0 1 - -Each (group) of numbers has a specific meaning: - -- SystemCode: 0 till 5 -- UnitCode: 6 till 10 -- State: 11 (inverse state) -- Check: 12 - -.. code-block: console - - 00000 01111 0 1 - -- The ``SystemCode`` is defined as a binary number -- The ``UnitCode`` is defined as a binary number -- The ``State`` defines whether a devices needs to be turned On or Off -- The ``Check`` defines whether a devices needs to be turned On or Off (but is inverse) - -So this code represents: - -- SystemCode: 31 (inversed) -- UnitCode: 1 (inversed) -- State: On (inverse state) -- Check: On - -Another example: - -- SystemCode: 0 (inversed) -- UnitCode: 4 (inversed) -- State: Off (inverse state) -- Check: Off - -.. code-block:: console - - 11111 11011 1 0 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_800.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_800.rst deleted file mode 100644 index 0fd9015..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/elro_800.rst +++ /dev/null @@ -1,4 +0,0 @@ -Elro HE (800 Series) -==================== - -.. include:: _elro_800.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/eurodomest.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/eurodomest.rst deleted file mode 100644 index 5f6a9d0..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/eurodomest.rst +++ /dev/null @@ -1,4 +0,0 @@ -Eurodomest -========== - -.. include:: _kaku_old.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/impuls.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/impuls.rst deleted file mode 100644 index a78d830..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/impuls.rst +++ /dev/null @@ -1,178 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Impuls -====== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Impuls | impuls | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -s --systemcode=systemcode control a device with this systemcode - -u --programcode=programcode control a device with this programcode - -t --on send an on signal - -f --off send an off signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "impuls" ], - "id": [{ - "programcode": 8, - "unitcode": 12 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| systemcode | 0 - 31 | -+------------------+-----------------+ -| unitcode | 0 - 31 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Notes - -The default settings for a set of Impuls switches are: - -#. SystemCode: 11111 and ProgramCode: 10000 -#. ProgramCode: 01000 -#. ProgramCode: 00100 - -This translates into the following pilight systemcode and unitcode: - -#. systemcode: 31, programcode: 1 -#. systemcode: 31, programcode: 2 -#. systemcode: 31, programcode: 4 - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 885 295 885 295 885 295 885 295 885 295 885 295 295 885 885 295 295 885 885 295 295 885 295 885 295 885 885 295 295 885 295 885 295 885 885 295 295 885 885 295 295 885 885 295 295 885 295 885 295 9735 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 885 295 885 295 - 885 295 885 295 - 885 295 885 295 - 295 885 885 295 - 295 885 885 295 - - 295 885 295 885 - 295 885 885 295 - 295 885 295 885 - 295 885 885 295 - 295 885 885 295 - - 295 885 885 295 - 295 885 295 885 - - 295 9735 - -If we now look at carefully at these groups you can distinguish three types of groups: - -#. ``295 885 295 885`` -#. ``885 295 885 295`` -#. ``295 885 885 295`` - -- The first group is defined by a low 1th and low 3rd pulse pulse, hence we call it low. -- The second group has a high 1st and 3rd pulse, hence we call it med. -- The final group has a low 1st and high 3rd pulse, hence we call it high. - -We then get the following output: - -.. code-block:: console - - MMMHH LHLHH H L - -All M's and H's can be translated to 1. All L's can be translated to 0. - -Each (group) of numbers has a specific meaning: - -- Unit: 0 till 5 -- ID: 6 till 10 -- Check: 11 (inverse state) -- State: 12 (state) - -.. code-block:: console - - 11100 10100 1 0 - -- The ``SystemCode`` is defined as a binary number -- The ``ProgramCode`` is defined as a binary number -- The ``Check`` is always inverse state -- The ``State`` defines whether a devices needs to be turned On or Off - -So this code represents: - -- SystemCode: 7 -- ProgramCode: 5 -- Check: Inverse state -- State: Off - -Another example: - -- Unit: 0 -- ID: 4 -- Fixed: Inverse state -- State: On - -.. code-block:: console - - 00000 00100 0 1 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/index.rst deleted file mode 100644 index b060e93..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/index.rst +++ /dev/null @@ -1,32 +0,0 @@ -Switches -======== - -.. toctree:: - :maxdepth: 1 - - beamish - brennenstuhl - byebyestandby - clarus - cleverwatts - coco - cogex - dio - duwi - elro_300 - elro_400 - elro_800 - eurodomest - quigg_1000 - quigg_7000 - impuls - intertechno - intertechno_old - kaku_old - kaku - nexa - rsl366 - selectremote - silvercrest - techlico - x10 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/intertechno.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/intertechno.rst deleted file mode 100644 index c28f3c5..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/intertechno.rst +++ /dev/null @@ -1,4 +0,0 @@ -Intertechno -=========== - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/intertechno_old.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/intertechno_old.rst deleted file mode 100644 index afc9764..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/intertechno_old.rst +++ /dev/null @@ -1,4 +0,0 @@ -Intertechno (Old Version) -========================= - -.. include:: _kaku_old.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/kaku.rst deleted file mode 100644 index 82b17cf..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/kaku.rst +++ /dev/null @@ -1,4 +0,0 @@ -KlikAanKlikUit -============== - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/kaku_old.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/kaku_old.rst deleted file mode 100644 index f8f058f..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/kaku_old.rst +++ /dev/null @@ -1,4 +0,0 @@ -KlikAanKlikUit (Old Version) -============================ - -.. include:: _kaku_old.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/nexa.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/nexa.rst deleted file mode 100644 index 39e3c38..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/nexa.rst +++ /dev/null @@ -1,4 +0,0 @@ -Nexa -==== - -.. include:: _kaku.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/quigg_1000.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/quigg_1000.rst deleted file mode 100644 index 4bd7711..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/quigg_1000.rst +++ /dev/null @@ -1,119 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Globaltronics Quigg GT-1000 -=========================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+-------------------------------+---------------+ -| **Brand** | **Protocol** | -+-------------------------------+---------------+ -| Globaltronics GmbH GT-1000 RC | quigg_gt1000 | -+-------------------------------+---------------+ -| Globaltronics GmbH GT-FSI-08 | quigg_gt1000 | -+-------------------------------+---------------+ -| Silvercrest AAA3680-A IP20 DE | quigg_gt1000 | -+-------------------------------+---------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -t send an on signal to a device - -f send an off signal to a device - -i control the device with this system id (1 ... 15) - -u control the device with this unit code (0 ... 3) - -a control all switches in the given group - -s control all switches in all groups - - The next two parameters are optional: - - -n specify the code sequence to use (0 ... 3) - -s specify the super codes (0 ... 7) - - If the specified sequence does not exists, sequence 0 will be used instead. - If not specified a sequence will be selected at random. - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "quigg_gt1000" ], - "id": [{ - "id": 15, - "unit": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 15 | -+------------------+-----------------+ -| unit | 0 - 3 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Examples - -.. code-block:: console - - pilight-send -p quigg_gt1000 -i [0..15] -u [0..3] [-t|-f] {-n [0..3]} - -Switch on or off the specified switch (-u) belonging to group (-i) optionally using specified codeseq (-n) - -.. code-block:: console - - pilight-send -p quigg_gt1000 -i [0..15] -a [-t|-f] {-n [0..3]} - -Switch on or off all switches belonging to group (-i) optionally using specified codeseq (-n) - -.. code-block:: console - - pilight-send -p quigg_gt1000 -s [-t|-f] {-n [0..7]} - -Switch on or off all compatible switches optionally using specified codeseq (-n) - -When using the Web-GUI use "unit": 4 in the config.json file for the master switch ("all": 1) and "id”: 16 with "unit”: 5 for the super code switch ("super”: 1). diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/quigg_7000.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/quigg_7000.rst deleted file mode 100644 index 795deb2..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/quigg_7000.rst +++ /dev/null @@ -1,232 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Globaltronics Quigg GT-7000 -=========================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+-------------------------------+---------------+ -| **Brand** | **Protocol** | -+-------------------------------+---------------+ -| Aldi Quigg GT-7000 | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics GT-7000 | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics GT-8000 | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics GT-FSI-02 | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics GT-FSI-04a | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics GT-FSI-05 | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics GT-FSI-05d | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics 7008AS | quigg_gt7000 | -+-------------------------------+---------------+ -| Conrad RC-710 | quigg_gt7000 | -+-------------------------------+---------------+ -| Globaltronics GT-FSI-05 | quigg_gt7000 | -+-------------------------------+---------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -t --on send an on signal to a device - -f --off send an off signal to a device - -i --id=id control the device with this system id (1 ... 4095) - -u --unit=unit control the device with this unit code (0 ... 3) - -a --all send command to all device units belonging to this system id - -l --learn send multiple streams so switch can learn - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "quigg_gt7000" ], - "id": [{ - "id": 15, - "unit": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 1 - 4095 | -+------------------+-----------------+ -| unit | 1 - 3 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. versionchanged:: 8.0 Allow ID 0 - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 4095 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| all | 0 | 1 or 0 | | If specified this will trigger the "group" | -| | | | | function of the advanced remotes and trigger | -| | | | | all registered devices for the given unitcode | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -The quigg_switch protocol sends 42 pulses like this - -.. code-block:: console - - 700 1400 700 700 1400 1400 700 1400 700 700 1400 700 1400 700 1400 700 1400 700 1400 700 1400 700 1400 700 1400 700 1400 700 1400 700 1400 1400 700 700 1400 700 1400 700 1400 1400 700 81000 - -The first pulse is the ``header`` and the last pulse is the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 20 groups of 2 pulses (and thereby dropping the ``header`` and ``footer`` pulse). - -.. code-block:: console - - 1400 700 - 700 1400 - 1400 700 - 1400 700 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 700 1400 - 1400 700 - 700 1400 - 700 1400 - 700 1400 - 1400 700 - -If we now analyse these groups we can distinguish two types of groups: - -#. ``700 1400`` -#. ``1400 700`` - -So the first group is defined by a short 1st and 2nd long and the second group by a long 1st and 2nd short pulse. So we take either of these two pulses to define a logical 0 or 1. In our case a long 1st pulse means a 1 and a short 1st pulse means a 0. We then get the following output: - -.. code-block:: console - - 10110000000000010001 - -We can group the sequence of bits into the following groups A to H: - -.. code-block:: console - - AAAAAAAAAAAA BB C D E F G H - 101100000000 00 0 1 0 0 0 1 - -Each of the groups of bits (A to H) has a specific meaning: - -+-----------+-----------+-----------------+------------+-----------------------------+ -| **Group** | **Bit #** | **Config name** | **Range** | **Description** | -+-----------+-----------+-----------------+------------+-----------------------------+ -| A | 1 to 12 | id | 1 to 4095 | SystemCode | -+-----------+-----------+-----------------+------------+-----------------------------+ -| B | 13, 14 | unit | 1 to 3 | UnitCode | -+-----------+-----------+-----------------+------------+-----------------------------+ -| C | 15 | id | 1 | Command to all devices | -+-----------+-----------+-----------------+------------+-----------------------------+ -| D | 16 | all | 0,1 | Switch ON or OFF | -+ + + + + Dimmer DOWN or UP + -| | | | | | -+-----------+-----------+-----------------+------------+-----------------------------+ -| E | 17 | dimm | 0,1 | switch, dimmer mode | -+-----------+-----------+-----------------+------------+-----------------------------+ -| F | 18 | | 0 | always zero | -+-----------+-----------+-----------------+------------+-----------------------------+ -| G | 19 | | 0,1 | internal, handled by driver | -+-----------+-----------+-----------------+------------+-----------------------------+ -| H | 20 | | 0,1 | even parity bit | -+-----------+-----------+-----------------+------------+-----------------------------+ - -So this code represents: - -.. code-block:: console - - "id": 2816, - "unit": 1 - "state": Off - -.. rubric:: Examples - -CLI command: - -.. code-block:: console - - pilight-send -p quigg_gt7000 -i 2816 -u 1 -f - -.. rubric:: Comment - -Extracting the system code id from an existing Globaltronics GT-7000 remote control device either requires a special version of the BPF, or you need to bypass the BPF. - -After insertion of batteries the GT-7000 defaults to system code id #2816. Pressing the button "Neuer Code" located in the battery compartment, will trigger the generation of a new system code id. These are generated in sequential order, for the current quigg_switch protocol driver the id's are: - -.. code-block:: console - - 2816, 1792, 3840, 128, 2176, 1152, 3200, 640, 2688, 1664, 3712, 384, 2432, 1408, 3456, 896, 2944, 1920, 3968, .... - -To let the device learn a new value, press the learning mode button on the switch and send the appropriate CLI command with pilight-send (configure a switch to be unit #2 and system code id #29): - -.. code-block:: console - - pilight-send -p quigg_gt7000 -i 29 -u 2 -l -t - -The device learns that it has now system code id #29 and that it is unit #2 and enters ON mode (e.q. the switch is turned on). If the switch is not connected to power for an extended period of time, it will loose its configuration and reset to the default id #2816 unit #0. QUIGG_GT7000 compatible switches with integrated dimmer require that you configure the quigg_screen protocol in addition to the quigg_gt7000 protocol. On the webgui you will get a separate button to dimm the device up and down. - -Subsequently the switch unit #1 with system code id #2816 is turned off. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/rsl366.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/rsl366.rst deleted file mode 100644 index c9a8f56..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/rsl366.rst +++ /dev/null @@ -1,4 +0,0 @@ -RSL366 -====== - -.. include:: _rsl366.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/selectremote.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/selectremote.rst deleted file mode 100644 index 766e4d8..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/selectremote.rst +++ /dev/null @@ -1,138 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -SelectRemote -============ - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| SelectRemote | selectremote | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -i --id=id control a device with this id - -t --on send an on signal - -f --off send an off signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "selectremote" ], - "id": [{ - "id": 4 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 7 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 396 1188 396 1188 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 1188 396 13464 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 390 1170 - - 390 1170 390 1170 - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 1170 390 - - 390 1170 1170 390 - 390 1170 1170 390 - 390 1170 1170 390 - - 390 1170 1170 390 - -If we now look at carefully at these groups you can distinguish three types of groups: - -- ``396 1188 396 1188`` -- ``1188 396 1188 396`` - -#. The first group is defined by a low 1th and low 3rd pulse pulse, hence we call it low. -#. The second group has a high 1st and 3rd pulse, hence we call it high. - -We then get the following output: - -.. code-block:: console - - 011100000000 - -Each (group) of numbers has a specific meaning: - -- ID: 1 till 3 -- State: 8 (state) - -.. code-block:: console - - x 111 xxxx 0 xxx - -- The ``ID`` is defined as a binary number. To calculate the ID we subtract the binary represented decimal from 7. In this case the binary ``111`` is equal to the decimal 7. That means this code represents ID 0. -- The ``State`` defines whether a devices needs to be turned On or Off - -So this code represents: - -- SystemCode: 0 -- State: Off \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/silvercrest.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/silvercrest.rst deleted file mode 100644 index 132a600..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/silvercrest.rst +++ /dev/null @@ -1,146 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -SilverCrest -=========== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| Silvercrest | silvercrest | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -t --on send an on signal - -f --off send an off signal - -u --unit=unit control a device with this unit code - -i --id=id control a device with this id - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "silvercrest" ], - "id": [{ - "systemcode": 22, - "unitcode": 0 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| systemcode | 0 - 31 | -+------------------+-----------------+ -| unitcode | 0 - 31 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -This protocol sends 50 pulses like this - -.. code-block:: console - - 312 936 936 312 312 936 312 936 312 936 312 936 312 936 936 312 312 936 312 936 312 936 936 312 312 936 312 936 312 936 936 312 312 936 936 312 312 936 936 312 312 936 936 312 312 936 312 936 312 10608 - -It has no ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine, and the protocol also has some bit checks to filter false positives. We don't use them for further processing. The next step is to transform this output into 12 groups of 4 pulses (and thereby dropping the ``footer`` pulses). - -.. code-block:: console - - 312 936 936 312 - 312 936 312 936 - 312 936 312 936 - 312 936 936 312 - 312 936 312 936 - - 312 936 936 312 - 312 936 312 936 - 312 936 936 312 - 312 936 936 312 - 312 936 936 312 - - 312 936 936 312 - 312 936 312 936 - - 312 10608 - -If we now look at carefully at these groups you can distinguish three types of groups: - -- ``312 936 936 312`` -- ``312 936 312 936`` - -So the first group is defined by a high 3th pulse and the second group has a low 3rd pulse. In this case we say a high 3rd pulse means a 0 and a high 3rd pulse means a 1. We then get the following output: - -.. code-block:: console - - 01101 01000 01 - -Each (group) of numbers has a specific meaning: - -- Unit: 0 till 5 (inversed) -- ID: 6 till 10 (inversed) -- Check: 11 (inverse of state) -- State: 12 (inversed) - -.. code-block:: console - - 10110 00010 0 0 - -- The ``Unit`` is defined as a binary number -- The ``ID`` is defined as a binary number -- The ``Check`` is always the inverse of the state -- The ``State`` defines whether a devices needs to be turned On or Off - -So this code represents: - -- Unit: 22 -- ID: 2 -- Fixed: Off -- State: On diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/techlico.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/techlico.rst deleted file mode 100644 index 0fff42b..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/techlico.rst +++ /dev/null @@ -1,190 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -TechLiCo -======== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+------------------+ -| **Brand** | **Protocol** | -+----------------------+------------------+ -| TechLiCo | techlico_switch | -+----------------------+------------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -t --on send a toggle state signal to the device - -f --off send a toggle state signal to the device - -i --id=id control the device with this system id (1 ... 65535) - -u --unit=unit control the device with this unit code (1 ... 4) - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "techlico_switch" ], - "id": [{ - "id": 4935, - "unit": 1 - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 1 - 65535 | -+------------------+-----------------+ -| unit | 1 - 4 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -The techlico_switch protocol sends 50 pulses like this - -.. code-block:: console - - 208 624 208 832 208 624 624 208 208 624 208 624 624 208 624 208 208 832 624 208 208 832 208 624 208 832 624 208 624 208 624 208 208 832 208 624 208 832 208 832 208 624 208 624 624 208 624 208 208 7072 - -The last two pulses are the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 24 groups of 2 pulses (and thereby dropping the ``footer`` pulse). - -.. code-block:: console - - 208 624 - 208 832 - 208 624 - 624 208 - 208 624 - 208 624 - 624 208 - 624 208 - 208 832 - 624 208 - 208 832 - 208 624 - 208 832 - 624 208 - 624 208 - 624 208 - 208 832 - 208 624 - 208 832 - 208 832 - 208 624 - 208 624 - 624 208 - 624 208 - 208 7072 - -If we now analyse these groups we can distinguish two types of groups: - -- ``208 624`` -- ``624 208`` - -The 1st group is defined by a short-long sequence (logical 0) The 2nd group is defined by a long-short sequence (logical 1): - -Binary representation: - -.. code-block:: console - - 000100110100011100000011 - -We can group the sequence of bits into the following groups A and B: - -.. code-block:: console - - AAAAAAAAAAAAAAAA BBBB BBBB - 0001001101000111 0000 0011 - -Each of the groups of bits (A and B) has a specific meaning: - -+-----------+-----------+-----------------+------------+-----------------+ -| **Group** | **Bit #** | **Config name** | **Range** | **Description** | -+-----------+-----------+-----------------+------------+-----------------+ -| A | 1 to 16 | id: | 1 to 65535 | SystemCode id | -+-----------+-----------+-----------------+------------+-----------------+ -| B | 17 to 24 | unit: | 1 to 4 | ButtonCode unit | -+-----------+-----------+-----------------+------------+-----------------+ - -The protocol driver creates the binary presentation as required by the device - -+-----------+------------------------------------+ -| 0000 0011 | -u 1 Button A Toogle device status | -+-----------+------------------------------------+ -| 1100 0000 | -u 2 Button B Toogle device status | -+-----------+------------------------------------+ -| 0000 1111 | -u 3 Button C Toogle device status | -+-----------+------------------------------------+ -| 0000 1100 | -u 4 Button D Toogle device status | -+-----------+------------------------------------+ - -So this code represents: - -.. code-block:: console - - { - "code": { - "id": 4935, - "unit": 1 - }, - "origin": "receiver", - "protocol": "techlico_switch", - "uuid": "0000-00-00-00-000000", - "repeats": 2 - } - -.. rubric:: Examples - -CLI command: - -.. code-block:: console - - pilight-send -p techlico_switch -i 4935 -u 1 - -.. rubric:: Known Limitations - -As the device will not report its state, and the same Button on the original remote control toggles the state of the device, the GUI may show the wrong status of the device. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/x10.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/x10.rst deleted file mode 100644 index f0981de..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/switch/x10.rst +++ /dev/null @@ -1,79 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -X10 -=== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - :linenos: - - -i --id=id control a device with this id - -t --on send an on signal - -f --off send an off signal - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "x10" ], - "id": [{ - "id": "A2" - }], - "state": "off" - } - }, - "gui": { - "Lamp": { - "name": "TV Backlit", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | A0 - P16 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| readonly | 1 | 1 or 0 | Disable controlling this device from the GUIs | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| confirm | 1 | 1 or 0 | Ask for confirmation when switching device | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -A good description on this protocol can be found in this document `x10 `_ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_alecto_ws1700.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_alecto_ws1700.rst deleted file mode 100644 index 4873a9c..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_alecto_ws1700.rst +++ /dev/null @@ -1,172 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| Alecto WSD17 | alecto_wsd17 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "alecto_wsd17" ], - "id": [{ - "id": 100 - }], - "temperature": 23.00 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 9 | -+------------------+-----------------+ -| temperature | -50 - 70 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-battery | 1 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Comment - -This weather station or just the sensor is available from several (mostly Chinese) suppliers on eBay or Alibaba. Description for device is usually like: “Digital Wireless Indoor/Outdoor Weather Station with 3 Remote Sensors”. The sensor can be identified by the option to choose from 3 different channels. - -Please be aware that the ID of a sensor changes after you replace the batteries. - -.. rubric:: Protocol - -The protocol sends 74 pulses like: - -.. code-block:: guess - - 540 1890 540 3780 540 1890 540 3780 540 3780 540 3780 540 3780 540 3780 540 1890 540 1890 540 3780 540 3780 540 3780 540 1890 540 1890 540 1890 540 1890 540 1890 540 1890 540 1890 540 3780 540 3780 540 1890 540 1890 540 4050 540 1890 540 4050 540 4050 540 1890 540 1890 540 4050 540 1890 540 3780 540 1890 540 3780 540 3780 540 9180 - -There first 8 pulses are the header and the last 2 pulses are the footer. These are meant to identify the pulses as genuine. We don't it for further processing. The next step is to transform this output into 36 groups of 2 pulses (and thereby dropping the footer pulses). - -.. code-block:: guess - - 540 1890 - 540 3780 - 540 1890 - 540 3780 - 540 3780 - 540 3780 - 540 3780 - 540 3780 - 540 1890 - 540 1890 - 540 3780 - 540 3780 - 540 3780 - 540 1890 - 540 1890 - 540 1890 - 540 1890 - 540 1890 - 540 1890 - 540 1890 - 540 3780 - 540 3780 - 540 1890 - 540 1890 - 540 4050 - 540 1890 - 540 4050 - 540 4050 - 540 1890 - 540 1890 - 540 4050 - 540 1890 - 540 3780 - 540 1890 - 540 3780 - 540 3780 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. ``540 1890`` -#. ``540 3780`` - -So the first group is defined by a low 2nd, the second group has a high 2nd pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: guess - - 010111110011000000011001011001010111 - -Each (group) of numbers has a specific meaning: - -- Header 0 till 3 -- ID: 4 till 11 -- Battery: 12 -- TX mode: 13 -- Channel: 14 till 15 -- Temperature: 16 till 27 -- Humidity: 28 till 35 - -.. code-block:: guess - - 0101 11110011 0 0 00 000110010110 01010111 - -- The ID is defined as a binary number -- The Battery identifies the state of the battery -- The TX mode defines whether the signal was sent automatic or manual -- The Channel is defined as a binary number and specifies which channel the sensor uses -- The Temperature is defined as a binary number and represents the temperature -- The Humidity is defined as a binary number and represents the humidity - -This protocol was created for pilight with the help of this thread: http://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_alecto_wx500.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_alecto_wx500.rst deleted file mode 100644 index 29ffe59..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_alecto_wx500.rst +++ /dev/null @@ -1,114 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+------------------+ -| **Brand** | **Protocol** | -+------------------+------------------+ -| Alecto WX500 | alecto_wx500 | -+------------------+------------------+ -| Auriol H13726 | auriol_h13726 | -+------------------+------------------+ -| Hama EWS1500 | hama_ews1500 | -+------------------+------------------+ -| Meteoscan W1XXX | meteoscan_w1XX | -+------------------+------------------+ -| Balance RF-WS105 | balance_rf_ws105 | -+------------------+------------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "alecto_wsd17" ], - "id": [{ - "id": 100 - }], - "temperature": 18.90, - "humidity": 41.00, - "windavg": 10.00, - "winddir": 90.00, - "windgust": 20.00, - "battery": 1 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 9 | -+------------------+-----------------+ -| temperature | -40 - 60 | -+------------------+-----------------+ -| humidity | 10 - 99 | -+------------------+-----------------+ -| windavg | 0 - 50 | -+------------------+-----------------+ -| windavg | 0 - 359 | -+------------------+-----------------+ -| windgust | 0 - 50 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-wind | 1 | 1 or 0 | Don't display the wind value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-battery | 1 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -A good description on this protocol can be found in `this `_ PDF. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_conrad.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_conrad.rst deleted file mode 100644 index 1ea7c45..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_conrad.rst +++ /dev/null @@ -1,205 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+-----------------------+----------------+ -| **Brand** | **Protocol** | -+-----------------------+----------------+ -| Soens Weather Station | soens | -+-----------------------+----------------+ -| TFA | tfa | -+-----------------------+----------------+ -| Conrad | conrad_weather | -+-----------------------+----------------+ - - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "tfa" ], - "id": [{ - "id": 108, - "channel": 3 - }], - "temperature": 18.90, - "humidity": 41.00, - "battery": 1 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 9 | -+------------------+-----------------+ -| temperature | -39.9 - 59.9 | -+------------------+-----------------+ -| humidity | 10 - 99 | -+------------------+-----------------+ -| battery | 0 - 1 | -+------------------+-----------------+ - -.. note:: **Conrad** - - This sensor does not support humidity measurements - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-battery | 1 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -The tfa protocol sends 86 pulses like - -.. code-block:: guess - - 498 1992 498 1992 498 1992 498 1992 498 1992 498 4233 498 4233 498 1992 498 1992 498 2241 498 1992 498 1992 498 2241 498 2241 498 1992 498 1992 498 4233 498 2241 498 2241 498 1992 498 1992 498 4482 498 1992 498 4233 498 4233 498 2241 498 4482 498 1992 498 1992 498 4233 498 1992 498 1992 498 4233 498 4233 498 1992 498 1992 498 1992 498 2241 498 2241 498 1992 498 4233 498 2241 498 8466 - -The next step is to transform this output into groups of 2 pulses. - -.. code-block:: guess - - 498 1992 - 498 1992 - 498 1992 - 498 1992 - 498 1992 - 498 4233 - 498 4233 - 498 1992 - 498 1992 - 498 2241 - 498 1992 - 498 1992 - 498 2241 - 498 2241 - 498 1992 - 498 1992 - 498 4233 - 498 2241 - 498 2241 - 498 1992 - 498 1992 - 498 4482 - 498 1992 - 498 4233 - 498 4233 - 498 2241 - 498 4482 - 498 1992 - 498 1992 - 498 4233 - 498 1992 - 498 1992 - 498 4233 - 498 4233 - 498 1992 - 498 1992 - 498 1992 - 498 2241 - 498 2241 - 498 1992 - 498 4233 - 498 2241 - 498 8466 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. ``498 1992`` -#. ``498 4233`` - -So the first group is defined by a low 2nd, the second group has a high 2nd pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: guess - - 000001100000000010000101101001001100000010 - -Each (group) of numbers has a specific meaning: - -- ID: 2 till 9 -- Channel: 12 till 13 -- Temperature: 14 till 25 -- Humidity: 26 till 33 -- Battery: 34 till 35 - -.. code-block:: guess - - ID : 00011000 | Channel : 00 | Temp : 011000010010 | Hum : 00111001 | Bat : 00 - -- The ID is defined as a binary number -- The Channel is defined as a binary number and specifies which channel the sensor uses -- The Temperature is defined as a binary number and represents the temperature (value is given in fahrenheit strating at -90°F). Assuming that the Temp binary value is AAAABBBBCCCC, the formula to calculate the temperature value in °C is - -.. code-block:: guess - - (((DEC(CCCC)*256) + (DEC(BBBB)*16) + (DEC(AAAA))/10) - 90 - 32) * (5/9) - -- The ``Humidity`` is defined as a binary number. Assuming that the Hum binary value is AAAABBBB, the formula to calculate the humidity percentage is DEC(BBBB)*16 + DEC(AAAA) -- The ``Battery`` identifies the state of the battery - -.. code-block:: guess - - ID : 24 | Channel : 1 | Temp : 18.56°C | Hum : 57% | Bat : OK - -This protocol was created for pilight with the help of this thread: http://forum.pilight.org/Thread-New-Protocol-Wireless-Indoor-Outdoor-Weather-Station-with-3-Sensors - -.. rubric:: Comments - -This weather station or just the sensor is available from several (mostly Chinese) suppliers on eBay or Alibaba. Description for device is usually like: “Digital Wireless Indoor/Outdoor Weather Station with 3 Remote Sensors”. The sensor can be identified by the option to choose from 3 different channels. - -Humidity and battery are supported by this protocol. The battery function is not tested 100%. Please be aware that the ID of a sensor changes after you replace the batteries. Conrad sensor only provide temperature (no humidity). diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_tfa30.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_tfa30.rst deleted file mode 100644 index 103ac8f..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/_tfa30.rst +++ /dev/null @@ -1,227 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+-----------------------+----------------+ -| **Brand** | **Protocol** | -+-----------------------+----------------+ -| Dostmann TFA 30.3200 | tfa30 | -+-----------------------+----------------+ -| TFA30 | tfa30 | -+-----------------------+----------------+ - - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "tfa30" ], - "id": [{ - "id": 228 - }], - "temperature": 18.90, - "humidity": 41.00 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 255 | -+------------------+-----------------+ -| temperature | -39.9 - 59.9 | -+------------------+-----------------+ -| humidity | 10 - 99 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -*After extensive testing it was detected that the Dostman TFA 30.3200 shares most parameters with the tfa and conrad weather station sensors, however due to the differences detected those are described in this document.* - -The protocol sends 88 pulses like: - -.. code-block:: guess - - 603 7630 601 1881 605 1897 610 3803 605 3811 651 3798 618 1884 600 1911 597 3806 599 1909 590 1930 595 1906 594 1905 591 1920 584 3804 593 3829 585 3808 600 1905 591 1937 602 3805 594 3809 599 3821 590 1903 595 1908 593 3826 586 1908 596 3837 597 3825 569 1918 594 3809 597 1911 594 1903 594 1909 591 3829 585 1926 592 1907 590 1972 531 1917 586 1911 607 1895 589 1952 556 3818 590 3811 594 7639 - -The next step is to transform this output into groups of 2 pulses. - -.. code-block:: guess - - 603 7630 - 601 1881 - 605 1897 - 610 3803 - 605 3811 - 651 3798 - 618 1884 - 600 1911 - 597 3806 - 599 1909 - 590 1930 - 595 1906 - 594 1905 - 591 1920 - 584 3804 - 593 3829 - 585 3808 - 600 1905 - 591 1937 - 602 3805 - 594 3809 - 599 3821 - 590 1903 - 595 1908 - 593 3826 - 586 1908 - 596 3837 - 597 3825 - 569 1918 - 594 3809 - 597 1911 - 594 1903 - 594 1909 - 591 3829 - 585 1926 - 592 1907 - 590 1972 - 531 1917 - 586 1911 - 607 1895 - 589 1952 - 556 3818 - 590 3811 - 594 7639 - -Analysing the pulsetrain, we can distinguish three types of groups: - -- The first group is defined by a short 2nd -- The second group has a long 2nd pulse. -- The third group has an extended long 2nd pulse, this 3rd group forms the header and the footer pulse group. - -The duration of the pulses varies between manufacturers. - -**Dostmann TFA 30.3200** - -#. ``605 1905`` -#. ``605 3811`` -#. ``594 7639`` - -Length of pulsetrain is 88. - -**TFA30 and conrad_weather** - -#. ``498 1992`` -#. ``498 4233`` -#. ``498 8466`` - -Length of pulsetrain is 80 or 86. - -It is currently unknown wether the ``tfa`` and the ``conrad weather pro`` are using identical protocols or not, due to discrepencies in the documentation. The current version of the tfa protocol module can handle both variants using the tfa30 protocol. The differentiation is analysing the header information and the length of the pulsetrain automatically. - -We take either of the two other pulse groups to define a logical 0 or a 1. A long 2nd pulse means a 1 and a short 2nd pulse means a 0. - -For the above pulsetrain we get the following binary output: - -.. code-block:: console - - MSB--LSB AAAABBBBCCCC AAAABBBB - 00 11100100 0 001 110011100101 10100010 0 0 000011 - -Each (group) of numbers has a specific meaning: - -**Dostmann TFA 30.3200** - -- unknown: 0 till 1 -- ID: 2 till 9 -- unknown: 10 -- Channel: 11 till 13 -- Temperature: 14 till 25 -- Humidity: 26 till 33 -- Tx Button: 34 -- Battery low: 35 -- unknown: 36 till 41 - -**tfa30 and conrad_weather** - -- unknown: 0 till 1 -- ID: 2 till 9 -- Channel: 12 till 13 -- Temperature: 14 till 25 -- Humidity: 26 till 33 -- Battery: 34 till 35 -- unknown: 36 till 41 - -.. code-block:: console - - ID : 11100100 | Channel : 01 | Temp : 0101 1110 1100 | Hum : 00101010 | Bar : 00 - -- The ``ID`` is defined as a binary number -- The ``Temperature`` is defined as a binary number and represents the temperature in Fahrenheit, starting at -90°F). Assuming that the Temp binary value is AAAABBBBCCCC, the formula to calculate the temperature value in °C is - -.. code-block:: console - - ( ((DEC(CCCC)*256)+(DEC(BBBB)*16)+(DEC(AAAA)))/10 -90 -32) * (5/9) - -The ``Humidity`` is defined as a binary number. Assuming that the Hum binary value is AAAABBBB, the formula to calculate the humidity percentage is DEC(BBBB)*16 + DEC(AAAA) - -.. code-block:: console - - ID : 228 | Temp : 16.44°C | Hum : 42% - diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_ws1700.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_ws1700.rst deleted file mode 100644 index 04c31dc..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_ws1700.rst +++ /dev/null @@ -1,4 +0,0 @@ -Alecto WS1700 -============= - -.. include:: _alecto_ws1700.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_wsd17.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_wsd17.rst deleted file mode 100644 index 1d6d698..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_wsd17.rst +++ /dev/null @@ -1,88 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Alecto WSD17 -============ - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+----------------+ -| **Brand** | **Protocol** | -+------------------+----------------+ -| Alecto WSD1700 | alecto_wsd1700 | -+------------------+----------------+ -| iBoutique | iboutique | -+------------------+----------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "alecto_ws1700" ], - "id": [{ - "id": 108 - }], - "temperature": 18.90, - "humidity": 41.00, - "battery": 1 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Comment - -This protocol was created for pilight with the help of this document: http://www.tfd.hu/tfdhu/files/wsprotocol/auriol_protocol_v20.pdf - -Humidity and battery are not supported yet \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_wx500.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_wx500.rst deleted file mode 100644 index 32cc2cd..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/alecto_wx500.rst +++ /dev/null @@ -1,4 +0,0 @@ -Alecto WX500 -============ - -.. include:: _alecto_wx500.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/auriol_89210.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/auriol_89210.rst deleted file mode 100644 index d83a129..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/auriol_89210.rst +++ /dev/null @@ -1,128 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Auriol 89210 -============ - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+------------------+ -| **Brand** | **Protocol** | -+------------------+------------------+ -| Auriol | auriol | -+------------------+------------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "auriol" ], - "id": [{ - "id": 3 - }], - "temperature": 18.90, - "humidity": 41.00, - "battery": 1 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 9 | -+------------------+-----------------+ -| temperature | 0 - 50 | -+------------------+-----------------+ -| humidity | 20 - 99 | -+------------------+-----------------+ -| battery | 0 - 1 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-battery | 1 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Comments - -This weather station was available at the Lidl. Description for device could be: “Auriol IAN 89210 FUNK-WEATHER STATION/RADIO CONTROLLED WEATHER”, Hama EWS-750 (not confirmed) and IAN 55982 (neither confirmed). The sensor can be identified by the option to choose from 3 different channels. - -Humidity and battery assumed to be supported by this protocol, but might not be. The battery function is not tested 100% and humidity seems to vary regularly. Please be aware that the ID of a sensor is actually the channel. - -.. rubric:: Protocol - -This protocol has similarities with the protocols alecto and threechan. - -Each (group of 2) numbers have the following specific meaning: - - - Battery ID 0 untill 7 (assumed) - - Battery: 8 - - TX mode: 9 - - Channel: 10 untill 11 (3 = 10, 2 = 01, 1 = 11) - - Temperature: 12 untill 23 - - Humidity: 24 untill 31 (assumed, alternatively this might be a checksum) - - Footer: 32 - - The Battery ID is not used - - The Battery identifies the state of the battery - - The TX mode defines whether the signal was sent automatically or manually - - The ID is defined as a binary number and specifies which channel the sensor uses - - The Temperature is defined as a binary number and represents the temperature - - The Humidity is defined as a binary number and represents the humidity (unconfirmed) - -.. rubric:: Checksum - -We need someone who is able to decipher the checksum and write a c snippet for it. - -This protocol was created for pilight with the help of pilight-debug. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/auriol_h13726.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/auriol_h13726.rst deleted file mode 100644 index 7710090..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/auriol_h13726.rst +++ /dev/null @@ -1,4 +0,0 @@ -Auriol H12726 -============= - -.. include:: _alecto_wx500.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/conrad.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/conrad.rst deleted file mode 100644 index 792ff25..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/conrad.rst +++ /dev/null @@ -1,4 +0,0 @@ -Conrad -====== - -.. include:: _conrad.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/dostmann.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/dostmann.rst deleted file mode 100644 index bf67cd6..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/dostmann.rst +++ /dev/null @@ -1,7 +0,0 @@ -Dostmann TFA 30.3200 -==================== - -.. versionchanged:: 8.0 - - -.. include:: _tfa30.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/hama_ews1500.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/hama_ews1500.rst deleted file mode 100644 index f2e9d32..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/hama_ews1500.rst +++ /dev/null @@ -1,4 +0,0 @@ -Hama EWS1500 -============ - -.. include:: _alecto_wx500.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/iboutique.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/iboutique.rst deleted file mode 100644 index 5a2e107..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/iboutique.rst +++ /dev/null @@ -1,4 +0,0 @@ -iBoutique -========= - -.. include:: _alecto_ws1700.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/index.rst deleted file mode 100644 index a506cdb..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/index.rst +++ /dev/null @@ -1,23 +0,0 @@ -Weather Stations -================ - -.. toctree:: - :maxdepth: 1 - - alecto_wsd17 - alecto_ws1700 - alecto_wx500 - auriol_89210 - auriol_h13726 - conrad - dostmann - hama_ews1500 - iboutique - kaku - meteoscan_w1xxx - ninja_blocks - soens - tcm - teknihall - tfa - ventus_wsxxx diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/kaku.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/kaku.rst deleted file mode 100644 index 76776dd..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/kaku.rst +++ /dev/null @@ -1,152 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -KlikAanKlikUit (Dusk/Dawn) -========================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+----------------------+--------------------+ -| **Brand** | **Protocol** | -+----------------------+--------------------+ -| KlikAanKlikUit | kaku_dusk | -+----------------------+--------------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "kaku_dusk" ], - "id": [{ - "id": 100, - "unit": 0 - }], - "state": "dusk" - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 67108863 | -+------------------+-----------------+ -| unit | 0 - 15 | -+------------------+-----------------+ -| state | dusk / dawn | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -*None* - -.. rubric:: Protocol - -This protocol sends 132 pulses like this - -.. code-block:: console - - 286 2825 286 201 289 1337 287 209 283 1351 287 204 289 1339 288 207 288 1341 289 207 281 1343 284 205 292 1346 282 212 283 1348 282 213 279 1352 282 211 281 1349 282 210 283 1347 284 211 288 1348 281 211 285 1353 278 213 280 1351 280 232 282 1356 279 213 285 1351 276 215 285 1348 277 216 278 1359 278 216 279 1353 272 214 283 1358 276 216 276 1351 278 214 284 1357 275 217 276 1353 270 217 277 1353 272 220 277 1351 275 220 272 1356 275 1353 273 224 277 236 282 1355 272 1353 273 233 273 222 268 1358 270 219 277 1361 274 218 280 1358 272 1355 271 243 251 11302 - -The first 2 pulses are the ``header`` and the last 2 pulses are the ``footer``. These are meant to identify the pulses as genuine. We don't use them for further processing. The next step is to transform this output into 32 groups of 4 pulses (and thereby dropping the ``header`` and ``footer`` pulses). - -.. code-block:: console - - 286 201 289 1337 - 287 209 283 1351 - 287 204 289 1339 - 288 207 288 1341 - 289 207 281 1343 - 284 205 292 1346 - 282 212 283 1348 - 282 213 279 1352 - 282 211 281 1349 - 282 210 283 1347 - 284 211 288 1348 - 281 211 285 1353 - 278 213 280 1351 - 280 232 282 1356 - 279 213 285 1351 - 276 215 285 1348 - 277 216 278 1359 - 278 216 279 1353 - 272 214 283 1358 - 276 216 276 1351 - 278 214 284 1357 - 275 217 276 1353 - 270 217 277 1353 - 272 220 277 1351 - 275 220 272 1356 - 275 1353 273 224 - 277 236 282 1355 - 272 1353 273 233 - 273 222 268 1358 - 270 219 277 1361 - 274 218 280 1358 - 272 1355 271 243 - -If we now look at carefully at these groups you can distinguish two types of groups: - -- ``272 1355 271 243`` -- ``274 218 280 1358`` - -So the first group is defined by a high 2nd and the second group has a high 4th pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: console - - 00000000000000000000000001010001 - -Each (group) of numbers has a specific meaning: - -- ID: 0 till 25(Convert the binary code to decimal to get the correct id) -- All: 26 -- State: 27 -- Unit: 28 till 31 - -.. code-block:: console - - 00000000000000000000000001 0 1 0001 - -- The ``ID`` is defined as a binary number -- The ``All`` tells us if a code was meant for all devices with the same ID -- The ``State`` defines whether a devices needs to be turned On or Off -- The ``Unit`` is also defined as a binary number - -So this code represents: - -- ID: 1 -- All: Single -- State: Dawn -- Unit: 1 - -Another example: - -- ID: 123456 -- All: All -- State: Dusk -- Unit: 15 - -.. code-block:: console - - 00000000011110001001000000101111 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/meteoscan_w1xxx.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/meteoscan_w1xxx.rst deleted file mode 100644 index eea1d69..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/meteoscan_w1xxx.rst +++ /dev/null @@ -1,4 +0,0 @@ -Meteoscan W1XXX -=============== - -.. include:: _alecto_wx500.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/ninja_blocks.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/ninja_blocks.rst deleted file mode 100644 index d270eaa..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/ninja_blocks.rst +++ /dev/null @@ -1,146 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Ninja Blocks Weather Sensor -=========================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+---------------------+ -| **Brand** | **Protocol** | -+------------------+---------------------+ -| Ninja Blocks | ninjablocks_weather | -+------------------+---------------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "ninjablocks_weather" ], - "id": [{ - "id": 1, - "unit": 1 - }], - "temperature": 18.90, - "humidity": 41.00 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 3 | -+------------------+-----------------+ -| unit | 0 - 15 | -+------------------+-----------------+ -| temperature | -50 - 205.99 | -+------------------+-----------------+ -| humidity | 0 - 99 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Comments - -This weather station was available at the Lidl. Description for device could be: “Auriol IAN 89210 FUNK-WEATHER STATION/RADIO CONTROLLED WEATHER”, Hama EWS-750 (not confirmed) and IAN 55982 (neither confirmed). The sensor can be identified by the option to choose from 3 different channels. - -Humidity and battery assumed to be supported by this protocol, but might not be. The battery function is not tested 100% and humidity seems to vary regularly. Please be aware that the ID of a sensor is actually the channel. - -.. rubric:: Protocol - -The protocol sends 74 pulses like: - -.. code-block:: guess - - 1083 860 966 986 1970 1953 2083 1829 1927 1014 938 1978 1943 993 946 1003 953 1983 2056 877 934 1020 931 1070 884 2013 1893 1012 930 2008 923 1019 1995 1930 925 1026 978 985 1891 1052 907 1036 913 2031 901 1034 916 1067 1881 1988 971 1004 890 1060 754 72330 - -The pulse stream uses the “Bi-Phase Mark Code” (BMC) or Frequencey/Double Frequency (F2F) principle as defined in ISO/IEC7811. - -The first 6 pulses are the SYNC header and the last pulse is the footer. These are meant to identify the pulses as genuine. We check for their presence, an error in the first pulse of the header is tolerated, if the second sync pulse after the Unit code and the parity bit is correct, the length of the footer pulse is used to identify the protocol and as end of data transmission. - -The first step is to transform this pulse stream into 36 logical bits We can group the sequence of bits into the following groups A to H: - -.. code-block:: guess - - AAAA BBBB CC DDD EEEEEEE FFFFFFFFFFFFFFF G H - 1100 0001 00 110 0111001 010011011011001 1 F - -Each of the groups of bits (A to H) has a specific meaning: - -+-----------+-----------+-----------------+------------+----------------------------------------+ -| **Group** | **Bit #** | **Config name** | **Range** | **Description** | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| A | 0-3 | 12 | SYNC Header | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| B | 4-7 | unit | 0 to 15 | Unit Code | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| C | 8-9 | id | 0 to 3 | Channel Code | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| D | 10-12 | 110 | Sync Data | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| E | 13-19 | humidity | 0 to 100 | Humidity in % | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| F | 20-34 | temperature | 0 to 32767 | Temperature -50°C to 205,99°C | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| G | 35 | 0,1 | Even Parity Bit | -+-----------+-----------+-----------------+------------+----------------------------------------+ -| H | 36 | Footer or gap pulse followed by Footer | -+-----------+-----------+-----------------+------------+----------------------------------------+ - -.. code-block:: console - - { - "code": { - "id": 0, - "unit": 1, - "temperature": 2769, - "humidity": 5700 - }, - "origin": "receiver", - "protocol": "ninjablocks_weather", - "uuid": "0000-00-00-b4-46a46b", - "repeats": 1 - } \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/soens.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/soens.rst deleted file mode 100644 index b030a8d..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/soens.rst +++ /dev/null @@ -1,4 +0,0 @@ -Soens Weather Station -===================== - -.. include:: _conrad.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/tcm.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/tcm.rst deleted file mode 100644 index 4caf123..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/tcm.rst +++ /dev/null @@ -1,187 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -TCM 218943 -========== - -.. versionadded:: 8.0 - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+-------------+----------------+ -| **Brand** | **Protocol** | -+-------------+----------------+ -| TCM 218943 | tcm | -+-------------+----------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "tcm" ], - "id": [{ - "id": 104, - }], - "temperature": 22.70, - "humidity": 50.00, - "battery": 1 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 255 | -+------------------+-----------------+ -| temperature | -39.9 - 59.9 | -+------------------+-----------------+ -| humidity | 0 - 99 | -+------------------+-----------------+ -| battery | 0 - 1 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-battery | 1 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Protocol - -The tcm protocol sends 74 pulses like - -.. code-block:: guess - - 194 1035 194 1994 194 1994 194 1035 194 1994 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1035 194 1994 194 1994 194 1035 194 1035 194 1994 194 1035 194 1035 194 1035 194 1035 194 1035 194 1994 194 1994 194 1994 194 1035 194 1035 194 1035 194 1994 194 1994 194 8037 - -The next step is to transform this output into groups of 2 pulses. - -.. code-block:: guess - - 194 1035 - 194 1994 - 194 1994 - 194 1035 - 194 1994 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1994 - 194 1994 - 194 1035 - 194 1035 - 194 1994 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1035 - 194 1994 - 194 1994 - 194 1994 - 194 1035 - 194 1035 - 194 1035 - 194 1994 - 194 1994 - 194 8037 - -If we now look at carefully at these groups you can distinguish two types of groups: - -#. ``194 1035`` -#. ``194 1994`` - -So the first group is defined by a low 2nd, the second group has a high 2nd pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. We then get the following output: - -.. code-block:: guess - - 011010000000000000110010000011100011 - -Each (group) of numbers has a specific meaning: - -- ID: 1 till 8 -- Battery: 9 -- Button: 12 -- Humidity: 17 till 24 -- Temperature: 25 till 36 - -.. code-block:: guess - - ID : 01101000 | Bat : 0 | But : 0 | Hum : 00110010 | Temp : 000011100011 - -- The ID is defined as a binary number. -- The Battery indicates low battery with 1. -- The Button is 1, if the button on the sensor is pressed. -- The Temperature is a 12 bits wide 2's complement signed binary number represents the actual temperature value in 0.1 °C units. DEC(AAAAAAAAAAAA)/10 -- The Humidity is defined as a binary number. - -.. code-block:: guess - - ID : 104 | Bat : OK | But : not pressed | Hum : 50% | Temp : 22.7°C - -This protocol was created for pilight with the help of this thread: http://forum.arduino.cc/index.php?topic=136836.0 (german) - -.. rubric:: Comments - -Please be aware that the ID of a sensor changes after you replace the batteries. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/teknihall.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/teknihall.rst deleted file mode 100644 index d8ede27..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/teknihall.rst +++ /dev/null @@ -1,185 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Teknihall GT-WT-02 -================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+--------------------+------------------+ -| **Brand** | **Protocol** | -+--------------------+------------------+ -| Teknihall GT-WT-02 | teknihall | -+--------------------+------------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "teknihall" ], - "id": [{ - "id": 108 - }], - "temperature": 18.90, - "humidity": 41.00, - "battery": 1 - } - }, - "gui": { - "weather": { - "name": "Weather Station", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 3 | -+------------------+-----------------+ -| unit | 0 - 15 | -+------------------+-----------------+ -| temperature | -15 - 60 | -+------------------+-----------------+ -| humidity | 20 - 99 | -+------------------+-----------------+ -| battery | 0 - 1 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-wind | 1 | 1 or 0 | Don't display the wind value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-battery | 1 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Comments - -This weather station is available at Aldi. Please be aware that there are several types of Teknihall weather stations and sensors available. Not all types might be compatible. - -Please be aware that the ID of a sensor could change after you replace the batteries. - -.. rubric:: Protocol - -The protocol sends 76 pulses like: - -.. code-block:: guess - - 532 2128 532 4256 532 4256 532 2128 532 4256 532 4256 532 2128 532 2128 532 2128 532 2128 532 2128 532 2128 532 2128 532 2128 532 2128 532 2128 532 4256 532 2128 532 4256 532 4256 532 4256 532 4256 532 2128 532 2128 532 2128 532 4256 532 4256 532 4256 532 2128 532 2128 532 2128 532 4256 532 4256 532 2128 532 2128 532 2128 532 2128 532 9044 - -The last 2 pulses are the footer. These are meant to identify the pulses as genuine. We don't it for further processing. The next step is to transform this output into 38 groups of 2 pulses (and thereby dropping the footer pulses). - -.. code-block:: guess - - 532 2128 - 532 4256 - 532 4256 - 532 2128 - 532 4256 - 532 4256 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 4256 - 532 2128 - 532 4256 - 532 4256 - 532 4256 - 532 4256 - 532 2128 - 532 2128 - 532 2128 - 532 4256 - 532 4256 - 532 4256 - 532 2128 - 532 2128 - 532 2128 - 532 4256 - 532 4256 - 532 2128 - 532 2128 - 532 2128 - 532 2128 - 532 9044 - -If we now look at carefully at these groups you can distinguish two types of groups: - -- ``540 2128`` -- ``540 4256`` - -So the first group is defined by a low 2nd, the second group has a high 2nd pulse. So we take either of these two pulses to define a 0 or a 1. In this case we say a high 2nd pulse means a 1 and a low 2nd pulse means a 0. The binary conversion could look as follows: - -.. code-block:: guess - - 0101111100111000000011001011001010111 - -Each (group) of numbers has a specific meaning: - -- ID: 0 till 7 -- Temperature: 14 till 23 -- Humidity: 24 till 30 - -.. code-block:: guess - - 01011111 001110 0000001100 1011001 010111 - - -- The ID is defined as a binary number -- The Temperature is defined as a binary number and represents the temperature -- The Humidity is defined as a binary number and represents the humidity - -This protocol was created for pilight with the help of this thread: http://forum.pilight.org/Thread-Connect-digital-weather-sensor \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/tfa.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/tfa.rst deleted file mode 100644 index c224ca1..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/tfa.rst +++ /dev/null @@ -1,4 +0,0 @@ -TFA -=== - -.. include:: _conrad.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/ventus_wsxxx.rst b/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/ventus_wsxxx.rst deleted file mode 100644 index 3dc17db..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/433.92/weather/ventus_wsxxx.rst +++ /dev/null @@ -1,4 +0,0 @@ -Ventus WSXXX -============ - -.. include:: _alecto_wx500.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/index.rst deleted file mode 100644 index 9fdf02f..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -API -=== - -.. toctree:: - :maxdepth: 3 - - program/index - weather/index \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/program/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/program/index.rst deleted file mode 100644 index 8c49fd5..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/program/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Program -=========== - -.. toctree:: - :maxdepth: 1 - - lirc - program - xbmc \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/program/lirc.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/program/lirc.rst deleted file mode 100644 index 38686b0..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/program/lirc.rst +++ /dev/null @@ -1,98 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Lirc -==== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "ab": { - "protocol": [ "lirc" ], - "id": [{ - "remote": "logitech" - }], - "code": "000000000000e204", - "repeat": 1, - "button": "KEY_ARROWDOWN" - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| remote | *any value* | -+------------------+-----------------+ -| code | *any value* | -+------------------+-----------------+ -| repeat | 1 - 999 | -+------------------+-----------------+ -| button | *any value* | -+------------------+-----------------+ - -.. rubric:: Comments - -The Lirc protocol tries to automatically connect to Lirc when pilight starts. When a connection can be made, it will send the same output as shown with ``irw`` in a pilight format. - -.. code-block:: console - - root@pi:~# irw - 000000037ff07be0 00 KEY_ARROWDOWN logitech-harmony-300i - -.. code-block:: console - - root@pi:~# pilight-receive - { - "code": { - "id": "000000000000e204", - "repeat": "01", - "button": "KEY_ARROWDOWN", - "remote": "logitech" - }, - "origin": "receiver", - "protocol": "lirc" - } - -Whenever, a connection to Lirc is lost, pilight will try to automatically reconnect. - -All signal processing will be done by Lirc, so make sure you have a working Lirc configuration. Tutorials on this can be found all around the internet. - -pilight tries to connect to the lirc socket found in ``/dev/lircd`` so make sure it exists or a symlink to the original socket is created to ``/dev/lircd``. - -**Raspbian Kernels 3.18 and higher** - -The most recent Raspbian release, with Pi 2 support, switches to a new kernel (3.18), and includes a configuration change to enable Device Tree support by default. - -You do need to add ``dtoverlay=lirc-rpi`` to ``/boot/config.txt``. - -Depending on your hardware setup, ``lirc-rpi`` module parameters are added to the end of the dtoverlay line: ``gpio_in_pin=16,gpio_in_pull=high,gpio_out_pin=17`` - -Example: - -.. code-block:: console - - dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/program/program.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/program/program.rst deleted file mode 100644 index 429c223..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/program/program.rst +++ /dev/null @@ -1,124 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Program -======= - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - - -t --running start the program - -f --stopped stop the program - -n --name=name name of the program - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "XBMC": { - "protocol": [ "program" ], - "id": [{ - "name": "xbmc" - }], - "program": "/usr/local/lib/xbmc/xbmc.bin", - "arguments": "", - "stop-command": "service xbmc stop", - "start-command": "service xbmc start", - "state": "running", - "pid": 11642 - } - }, - "gui": { - "xbmc": { - "name": "XBMC", - "group": [ "Programs" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| name | *any value* | -+------------------+-----------------+ -| arguments | *any value* | -+------------------+-----------------+ -| stop-command | *any value* | -+------------------+-----------------+ -| start-command | *any value* | -+------------------+-----------------+ -| state | | starting | -| | | running | -| | | stopped | -+------------------+-----------------+ -| pid | 0 - 9 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-------------------------------------------------+ -| poll-interval | 1 | >= 1 | How ofter do we want to check the program state | -+------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| readonly | 0 | 1 or 0 | Disable controlling this device from the GUIs | -+------------------+-------------+------------+-----------------------------------------------+ -| confirm | 0 | 1 or 0 | Ask for confirmation when switching device | -+------------------+-------------+------------+-----------------------------------------------+ - -.. rubric:: Comment - -The program protocol takes two important arguments - -- The program -- The arguments - -You can run ``ps aux`` to find out what these are. An example: - -.. code-block:: console - - USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND - root 11622 0.0 2.3 20216 8860 tty4 Ssl+ 20:04 0:01 /usr/local/sbin/splash-daemon - root 11636 0.0 0.4 4096 1540 ? Ss 20:04 0:00 sudo -u xbian /usr/local/lib/xbmc/xbmc.bin --standalone -fs --lircdev /run/lirc/lircd - xbian 11642 22.5 12.6 390836 48280 ? RNl 20:04 15:09 /usr/local/lib/xbmc/xbmc.bin --standalone -fs --lircdev /run/lirc/lircd - xbian 11734 0.0 0.2 2692 1092 ? S 20:04 0:00 /bin/bash - root 11868 0.0 1.4 9732 5432 ? Ss 20:04 0:00 python /usr/local/sbin/upstart-xbmc-bridge.py - root 11908 0.0 0.0 0 0 ? S 20:06 0:00 [btrfs-delalloc-] - root 13078 0.0 0.0 0 0 ? S 21:05 0:00 [kworker/u2:0] - root 13085 0.0 0.0 0 0 ? S 21:08 0:00 [btrfs-worker-2] - root 13166 0.0 0.0 0 0 ? S 21:10 0:00 [kworker/u2:1] - root 13186 0.0 0.2 4424 1116 pts/2 R+ 21:11 0:00 ps aux - -In thise case, i want to control XBMC. The xbian entry with the PID 11642 is what i want to use. The first word is the program name. In this case ``/usr/local/lib/xbmc/xbmc.bin``. Everything that comes after are the arguments ``–standalone -fs –lircdev /run/lirc/lircd``. pilight will now check for a program that matches these exact parameters. So the protocol looks for processes matching those lines and when a process is found, it updates the pid value accordingly. (The pid is just informative.) - -If you omit the arguments value, all matching programs will be processes with or without matching arguments. If there are more than once matches, pilight will use the first. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/program/xbmc.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/program/xbmc.rst deleted file mode 100644 index 5d50f6e..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/program/xbmc.rst +++ /dev/null @@ -1,115 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -XBMC / Kodi -=========== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "xbmc": { - "protocol": [ "xbmc" ], - "id": [{ - "server": "127.0.0.1", - "port": 9090 - }], - "action": "shutdown", - "media": "none" - } - }, - "gui": { - "xbmc": { - "name": "XBMC", - "group": [ "Programs" ], - "media": [ "all" ] - } - } - } - - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| server | *valid ip* | -+------------------+-----------------+ -| port | 1 - 65535 | -+------------------+-----------------+ -| action | | shutdown | -| | | home | -| | | play | -| | | pause | -| | | active | -| | | inactive | -+------------------+-----------------+ -| media | | none | -| | | episode | -| | | movie | -| | | movies | -| | | song | -| | | screensaver | -+------------------+-----------------+ - -.. note:: - - - The ``shutdown`` and ``home`` actions are only allowed for the ``none`` media. - - The ``play``, ``home``, and ``pause`` actions are only allowed for the ``episode``, ``movie``, ``movies``, or ``song`` media. - - The ``active`` and ``inactive`` actions are only allowed for the ``screensaver`` media. - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| show-media | 1 | 1 or 0 | Don't display the media icon | -+------------------+-------------+------------+-----------------------------------------------+ -| show-action | 1 | 1 or 0 | Don't display the action icon | -+------------------+-------------+------------+-----------------------------------------------+ - -.. rubric:: Comment - -The XBMC protocol will try to connect to a XBMC instance. However, make sure the JSON-RPC API is `enabled `_ in XBMC. You don't need to do anything more. Whenever a connection to XBMC is lost, the protocol will automatically try to reconnect. The XBMC protocol sends several messages depending on the actions in XBMC. - -+-----------+----------------+ -| **Media** | **Action** | -+-----------+----------------+ -| movie | play, pause | -+-----------+----------------+ -| song | play, pause | -+-----------+----------------+ -| episode | play, pause | -+-----------+----------------+ -| none | shutdown, home | -+-----------+----------------+ - -The stop event isn't recording, but pilight will interpret as the home action of the none media. So when XBMC is started or when nothing plays, the action will be home. When pilight can't connect to XBMC or when the connection is lost the shutdown action of the none media will be sent. - -Important - -pilight uses JSON-RPC via TCP-Port 9090. Don't mix it up with JSON-RPC via HTTP which is available over port 8080 by default (http://Kodi:8080/jsonrpc). This setting is hidden in Kodi/XBMC. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/weather/index.rst deleted file mode 100644 index d43fe26..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Weather -======= - -.. toctree:: - :maxdepth: 1 - - wunderground - openweathermap - sunriseset \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/openweathermap.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/weather/openweathermap.rst deleted file mode 100644 index 4e5712a..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/openweathermap.rst +++ /dev/null @@ -1,122 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -OpenWeatherMap -============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "outside": { - "protocol": [ "openweathermap" ], - "id": [{ - "location": "amsterdam", - "api": "1234567890", - "country": "nl" - }], - "humidity": 76.00, - "temperature": 7.00, - "sunrise": 7.00, - "sunset": 16.15, - "sun": "set", - "update": 1 - } - }, - "gui": { - "outside": { - "name": "Temperature", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+----------------------------------+ -| **Option** | **Value** | -+------------------+----------------------------------+ -| location | *valid openweathermap location* | -+------------------+----------------------------------+ -| country | *valid country abbreviation* | -+------------------+----------------------------------+ -| temperature | -100.00 - 100.00 | -+------------------+----------------------------------+ -| humitidy | 0.00 - 100.00 | -+------------------+----------------------------------+ -| sunrise | 00.00 - 23.59 | -+------------------+----------------------------------+ -| sunset | 00.00 - 23.59 | -+------------------+----------------------------------+ -| sun | rise / set | -+------------------+----------------------------------+ -| update | 0 - 1 | -+------------------+----------------------------------+ - -.. versionadded:: 8.0.7 - -+------------------+----------------------------------+ -| **Option** | **Value** | -+------------------+----------------------------------+ -| api | *valid openweathermap api key* | -+------------------+----------------------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------------------------+ -| poll-interval | 86400 | seconds | What should be the poll interval of the API | -+--------------------+-------------+------------+---------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| sunriseset-decimals | 2 | number | How many decimals the GUIs should display for sunrise/sunset time | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| show-battery | 0 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+----------------------------------------------------------------------+ - - -.. rubric:: Comment - -#. Please notice that the open weather map interval cannot be less than 10 minutes (600 seconds) to respect open weather map traffic and policy \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/sunriseset.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/weather/sunriseset.rst deleted file mode 100644 index 84d1b4c..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/sunriseset.rst +++ /dev/null @@ -1,138 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Sunriseset -========== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "outside": { - "protocol": [ "sunriseset" ], - "id": [{ - "longitude": 1.2345, - "latitude": 50.607080 - }], - "sunrise": 7.00, - "sunset": 16.15, - "sun": "set" - } - }, - "gui": { - "sun": { - "name": "Sunrise / Sunset", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+----------------------+ -| **Option** | **Value** | -+------------------+----------------------+ -| longitude | -180.0000 - 180.0000 | -+------------------+----------------------+ -| latitude | -90.0000 - 90.0000 | -+------------------+----------------------+ -| sunrise | 00.00 - 23.59 | -+------------------+----------------------+ -| sunset | 00.00 - 23.59 | -+------------------+----------------------+ -| sun | rise / set | -+------------------+----------------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| sunriseset-decimals | 2 | number | How many decimals the GUIs should display for sunrise/sunset time | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| show-sunriseset | 0 | 1 or 0 | Don't display the sunrise /sunset | -+----------------------+-------------+------------+----------------------------------------------------------------------+ - -.. rubric:: Comment - -The sunriseset will send three messages: - -#. When the sunset time has been arrived. -#. When the sunrise time has been arrived. -#. After midnight so all values can be updated for a new day. - -When using sunriseset in eventing, keep in mind of the following; The output of sunriseset.sunset and sunriseset.sunrise is just a number, so the time 17:00 equals 17.00. When using it in eventing make sure you get usable numbers. For example the time for sunriseset.sunset is 16:30 - -.. code-block:: guess - :linenos: - - IF ((sunrisesetdev.sunset == (datetime.hour + (datetime.minute / 100))) AND datetime.second == 0) THEN .." - -pilight will see this: - -.. code-block:: guess - :linenos: - - IF ((16.30 == (16 + (30 / 100))) AND 0 == 0) THEN ..." - -The math pilight will use: 16.30 == 16.30 - -When you look at the result you will see that the datetime.minute 30 will give 0.30 in the used rule (in normal case divide minutes through 100) - -Using the sunriseset. - -Example - -.. code-block:: guess - :linenos: - - IF sunrisesetdev.sun IS set THEN .... - IF sunrisesetdev.sun IS rise THEN .... - -Please note that with the three messages mentioned above, the first rule fires two times: At sunset, and at midnight (sunrisesetdev.sun is either set or rise, and will be set at midnight). So, it's better to use - -.. code-block:: guess - :linenos: - - IF (DATE_FORMAT(CurrentDateTime, %H.%M) == sunrisesetdev.sunset AND CurrentDateTime.second == 0) THEN ... - -with CurrentDateTime as a ``datetime`` device. - -.. rubric:: Notes - -ntpserver has been removed from the sunriseset id. Instead, ntp-servers are defined in the settings section of config.json in an array like this: - -.. code-block:: json - :linenos: - - { - "ntp-servers": [ "0.nl.pool.ntp.org", "1.nl.pool.ntp.org", "..." ], - "ntp-sync": 1 - } - -Both the datetime and sunriseset protocol will use the ntp time to adjust their time when needed. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/wunderground.rst b/lib/ESPiLight/pilight/docs/source/protocols/api/weather/wunderground.rst deleted file mode 100644 index ae8652b..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/api/weather/wunderground.rst +++ /dev/null @@ -1,119 +0,0 @@ -.. |yes| image:: ../../../images/yes.png -.. |no| image:: ../../../images/no.png - -.. role:: underline - :class: underline - -Weather Underground -=================== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "outside": { - "protocol": [ "wunderground" ], - "id": [{ - "api": "1ihn472a6ea384jd", - "location": "amsterdam", - "country": "nl" - }], - "humidity": 76.00, - "temperature": 7.00, - "sunrise": 7.00, - "sunset": 16.15, - "sun": "set", - "update": 1 - } - }, - "gui": { - "outside": { - "name": "Temperature", - "group": [ "Outside" ], - "media": [ "all" ] - } - } - } - -+------------------+--------------------------------------+ -| **Option** | **Value** | -+------------------+--------------------------------------+ -| api | *valid weather underground api key* | -+------------------+--------------------------------------+ -| location | *valid weather underground location* | -+------------------+--------------------------------------+ -| country | *valid country abbreviation* | -+------------------+--------------------------------------+ -| temperature | -100.00 - 100.00 | -+------------------+--------------------------------------+ -| humitidy | 0.00 - 100.00 | -+------------------+--------------------------------------+ -| sunrise | 00.00 - 23.59 | -+------------------+--------------------------------------+ -| sunset | 00.00 - 23.59 | -+------------------+--------------------------------------+ -| sun | rise / set | -+------------------+--------------------------------------+ -| update | 0 - 1 | -+------------------+--------------------------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------------------------+ -| poll-interval | 86400 | seconds | What should be the poll interval of the API | -+--------------------+-------------+------------+---------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| sunriseset-decimals | 2 | number | How many decimals the GUIs should display for sunrise/sunset time | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+----------------------------------------------------------------------+ -| show-battery | 0 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+----------------------------------------------------------------------+ - - -.. rubric:: Comment - - -#. Please notice that the weather underground interval cannot be less than 15 minutes due to daily polling restrictions. -#. This restriction also counts for the update button in the webgui. You won't receive updates within the 15 minutes between two updates. -#. This wiki page shows a random API key. Please register yourself at wunderground.com to get your own. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/dimmer.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/dimmer.rst deleted file mode 100644 index fc8a35c..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/dimmer.rst +++ /dev/null @@ -1,111 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Dimmer -====== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |no| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - - -t --on send an on signal - -f --off send an off signal - -i --id=id control a device with this id - -d --dimlevel=dimlevel send a specific dimlevel - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "dimmer": { - "protocol": [ "generic_dimmer" ], - "id": [{ - "id": 100 - }], - "state": "off", - "dimlevel": 0 - } - }, - "gui": { - "dimmer": { - "name": "Dimmer", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 99999 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ -| dimlevel | 0 - 99999 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| readonly | 0 | 1 or 0 | Disable controlling this device from the GUIs | -+------------------+-------------+------------+-----------------------------------------------+ -| confirm | 0 | 1 or 0 | Ask for confirmation when switching device | -+------------------+-------------+------------+-----------------------------------------------+ - -.. versionadded:: 8.0.6 - -.. note:: - - The minimum and maximum is dependent on the ``Device Settings`` below. - The actual dimlevel is not validated against these ranges. - -:underline:`GUI Settings` - -+------------------+-------------+------------+------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+------------------+ -| dimlevel-minimum | 0 | number | Minimum dimlevel | -+------------------+-------------+------------+------------------+ -| dimlevel-maximum | 15 | number | Maximum dimlevel | -+------------------+-------------+------------+------------------+ - -.. deprecated:: 8.0.5 - -.. note:: - - The minimum and maximum is dependent on the ``Device Settings`` below. - -:underline:`Device Settings` - -+------------------+-------------+------------+------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+------------------+ -| dimlevel-minimum | 0 | number | Minimum dimlevel | -+------------------+-------------+------------+------------------+ -| dimlevel-maximum | 15 | number | Maximum dimlevel | -+------------------+-------------+------------+------------------+ diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/index.rst deleted file mode 100644 index 436c594..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/index.rst +++ /dev/null @@ -1,13 +0,0 @@ -Generic -======= - -.. toctree:: - :maxdepth: 3 - - dimmer - label - raw - screen - switch - weather - webcam \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/label.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/label.rst deleted file mode 100644 index 9654405..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/label.rst +++ /dev/null @@ -1,69 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Label -===== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |no| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - - -i --id=id control a device with this id - -l --label=label show a specific label - -c --color=color give the label a specific color - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "label": { - "protocol": [ "generic_label" ], - "id": [{ - "id": 100 - }], - "label": "test1234", - "color": "red" - } - }, - "gui": { - "label": { - "name": "Label", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 99999 | -+------------------+-----------------+ -| label | *any value* | -+------------------+-----------------+ -| color | *any color* | -+------------------+-----------------+ - -.. note:: - - Please notice that the label color is not validated in any way. The color information is just forwarded to the GUIs as is. So it could be that some GUIs do not support certain color naming. Using hex colors is therefore the safest, e.g. #000000. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/raw.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/raw.rst deleted file mode 100644 index ef67872..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/raw.rst +++ /dev/null @@ -1,33 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Raw -=== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |no| | -+------------------+-------------+ -| Config | |no| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - - -c --code="raw" raw code divided by spaces - (just like the output of debug) - -.. rubric:: Config - -*None* \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/screen.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/screen.rst deleted file mode 100644 index 235be57..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/screen.rst +++ /dev/null @@ -1,74 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Screen -====== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |no| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - - -t --up send an up signal - -f --down send a down signal - -i --id=id control a device with this id - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "screen": { - "protocol": [ "generic_screen" ], - "id": [{ - "id": 100 - }], - "state": "down" - } - }, - "gui": { - "screen": { - "name": "Screen", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 99999 | -+------------------+-----------------+ -| state | up/down | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| readonly | 0 | 1 or 0 | Disable controlling this device from the GUIs | -+------------------+-------------+------------+-----------------------------------------------+ -| confirm | 0 | 1 or 0 | Ask for confirmation when switching device | -+------------------+-------------+------------+-----------------------------------------------+ diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/switch.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/switch.rst deleted file mode 100644 index c39cffb..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/switch.rst +++ /dev/null @@ -1,74 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Switch -====== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |no| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - - -t --on send an on signal - -f --off send an off signal - -i --id=id control a device with this id - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "switch": { - "protocol": [ "generic_switch" ], - "id": [{ - "id": 100 - }], - "state": "off" - } - }, - "gui": { - "switch": { - "name": "Switch", - "group": [ "Living" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 99999 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`GUI Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| readonly | 0 | 1 or 0 | Disable controlling this device from the GUIs | -+------------------+-------------+------------+-----------------------------------------------+ -| confirm | 0 | 1 or 0 | Ask for confirmation when switching device | -+------------------+-------------+------------+-----------------------------------------------+ diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/weather.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/weather.rst deleted file mode 100644 index 0184966..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/weather.rst +++ /dev/null @@ -1,97 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Weather -======= - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |yes| | -+------------------+-------------+ -| Receiving | |no| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -.. code-block:: console - - -t --temperature=temperature set the temperature - -h --humidity=humidity set the humidity - -b --battery=battery set the battery level - -i --id=id control a device with this id - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "generic_weather" ], - "id": [{ - "id": 100 - }], - "temperature": 23.00, - "humidity": 76.00, - "battery": 0 - } - }, - "gui": { - "weather": { - "name": "Weather", - "group": [ "Weather" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| id | 0 - 99999 | -+------------------+-----------------+ -| temperature | 0.00 - 100.00 | -+------------------+-----------------+ -| humidity | 0.00 - 100.00 | -+------------------+-----------------+ -| battery | 0 - 1 | -+------------------+-----------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+---------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+---------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+---------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+---------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 2 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-battery | 0 | 1 or 0 | Don't display the battery value | -+----------------------+-------------+------------+-----------------------------------------------------------+ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/generic/webcam.rst b/lib/ESPiLight/pilight/docs/source/protocols/generic/webcam.rst deleted file mode 100644 index 6e5969e..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/generic/webcam.rst +++ /dev/null @@ -1,80 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Webcam -======= - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |no| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "webcam": { - "protocol": [ "generic_webcam" ], - "id": [{ - "id": 100 - }], - "url": "http://x.x.x.x:xxxx" - } - }, - "gui": { - "webcam": { - "name": "Webcam", - "group": [ "Frontdoor" ], - "media": [ "all" ] - } - } - } - -+------------------+-------------------+ -| **Option** | **Value** | -+------------------+-------------------+ -| id | 0 - 99999 | -+------------------+-------------------+ -| url | *valid image url* | -+------------------+-------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------+ -| poll-interval | 10 | number | Refresh webcam image interval | -+--------------------+-------------+------------+-------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| image-width | NULL | number | Webcam image width | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| image-height | 300 | number | Webcam image height | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-webcam | 1 | 1 or 0 | Don't display the webcam image | -+----------------------+-------------+------------+-----------------------------------------------------------+ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_am2302.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/_am2302.rst deleted file mode 100644 index e39c9e5..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_am2302.rst +++ /dev/null @@ -1,99 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| 1-Wire DHT11 | dht11 | -+------------------+--------------+ -| 1-Wire DHT22 | dht22 | -+------------------+--------------+ -| 1-Wire AM2302 | am2302 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "dht22" ], - "id": [{ - "gpio": 7 - }], - "temperature": 5.2, - "humidity": 1.7, - "poll-interval": 5 - } - }, - "gui": { - "temperature": { - "name": "Temperature Sensor", - "group": [ "Misc" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| gpio | 0 - 255 | -+------------------+-----------------+ -| temperature | -40 - 80 | -+------------------+-----------------+ -| humidity | 0 - 100 | -+------------------+-----------------+ - -.. note:: - - The ``gpio`` value should be a valid GPIO for the platform used - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| poll-interval | 5 | seconds | What should be the poll interval of the sensors | -+--------------------+-------------+------------+-------------------------------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+-------------------------------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 1 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| humidity-decimals | 1 | number | How many decimals the GUIs should display for humidity | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-humidity | 1 | 1 or 0 | Don't display the humidity value | -+----------------------+-------------+------------+-----------------------------------------------------------+ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_bmp180.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/_bmp180.rst deleted file mode 100644 index 78536c2..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_bmp180.rst +++ /dev/null @@ -1,115 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| BMP180 | bmp180 | -+------------------+--------------+ -| BMP085 | bmp085 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "bmp180": { - "protocol": [ "bmp180" ], - "id": [{ - "id": "0x77" - }], - "temperature": 19.1, - "pressure": 1006.8, - "oversampling": 1 - } - }, - "gui": { - "temperature": { - "name": "Temperature Sensor", - "group": [ "Misc" ], - "media": [ "all" ] - } - } - } - -+------------------+------------------+ -| **Option** | **Value** | -+------------------+------------------+ -| id | *valid i2c path* | -+------------------+------------------+ -| temperature | -40 - 85 | -+------------------+------------------+ -| pressure | 300 - 1100 | -+------------------+------------------+ -| oversampling | 0 - 3 | -+------------------+------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| poll-interval | 10 | seconds | What should be the poll interval of the sensors | -+--------------------+-------------+------------+-------------------------------------------------+ -| humidity-offset | 0 | number | Correct humidity value | -+--------------------+-------------+------------+-------------------------------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| pressure-decimals | 2 | number | How many decimals the GUIs should display for pressure | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-pressure | 1 | 1 or 0 | Don't display the pressure value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Comments - -Pressure is provided in hectopascal (hPa) and temperature in degrees Celsius (°C). - -Option ``oversampling`` sets the BMP180 hardware accuracy mode which is relevant for pressure readings only. - -+-----------------------+--------------+-------------------------+------------------------------------+ -| Mode | oversampling | Internal no. of samples | Conversion time pressure max. [ms] | -+-----------------------+--------------+-------------------------+------------------------------------+ -| ultra low power | 0 | 1 | 4.5 | -+-----------------------+--------------+-------------------------+------------------------------------+ -| standard | 1 | 2 | 7.5 | -+-----------------------+--------------+-------------------------+------------------------------------+ -| high resolution | 2 | 4 | 13.5 | -+-----------------------+--------------+-------------------------+------------------------------------+ -| ultra high resolution | 3 | 8 | 25.5 | -+-----------------------+--------------+-------------------------+------------------------------------+ - -The algorithm for pressure and temperature measurement is based on the specification in the `official datasheet `_. diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_ds18b20.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/_ds18b20.rst deleted file mode 100644 index 27c5b0e..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_ds18b20.rst +++ /dev/null @@ -1,145 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| 1-Wire DS18B20 | ds18b20 | -+------------------+--------------+ -| 1-Wire DS18S20 | ds18s20 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "ds18b20" ], - "id": [{ - "id": "0000052ba3ac" - }], - "temperature": 19.562 - } - }, - "gui": { - "temperature": { - "name": "Temperature Sensor", - "group": [ "Misc" ], - "media": [ "all" ] - } - } - } - -+------------------+-------------------+ -| **Option** | **Value** | -+------------------+-------------------+ -| id | *valid 1-wire id* | -+------------------+-------------------+ -| temperature | -55 - 125 | -+------------------+-------------------+ - -.. note:: **DS18B20** - - Valid id's can be found in the path ``/sys/bus/w1/devices/`` starting with ``28-``. The prefix ``28-`` should be removed from the id. - -.. note:: **DS18S20** - - Valid id's can be found in the path ``/sys/bus/w1/devices/`` starting with ``10-``. The prefix ``10-`` should be removed from the id. - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| poll-interval | 5 | seconds | What should be the poll interval of the sensors | -+--------------------+-------------+------------+-------------------------------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -.. note:: DS18B20 - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 2 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. note:: DS18S20 - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 3 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - - -.. rubric:: Comments - -Before pilight can see the sensor, you have to run the following commands: - -.. code-block:: console - - sudo modprobe w1-gpio - sudo modprobe w1-therm - -To make sure this is done every reboot, edit ``/etc/modules`` and add the following lines: - -.. code-block:: console - - w1-gpio - w1-therm - -If you have enabled "Device tree support" (since Raspbian with kernel 3.18 it's the default configuration), you have to add the following line to ``/boot/config.txt``: - -.. code-block:: console - - dtoverlay=w1-gpio-pullup,gpiopin=4 - -.. note:: The GPIO pin number is the BCM GPIO and not the WiringX number. - -This will load the module ``w1-gpio``, so you only have to add ``w1-therm`` to your ``/etc/modules``. - -To find the correct sensor id, you have to run the following commands: - -.. code-block:: console - - cd /sys/bus/w1/devices - ls - -The result will look like: - -.. code-block:: console - - 28-0000055bd776 w1_bus_master1 - -Use the part after 28- as the correct id, e.g. 0000055bd776. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_lm75.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/_lm75.rst deleted file mode 100644 index 807a413..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/_lm75.rst +++ /dev/null @@ -1,131 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| LM75 | lm75 | -+------------------+--------------+ -| LM76 | lm76 | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "temperature": { - "protocol": [ "lm75" ], - "id": [{ - "id": "0x49" - }], - "temperature": 17.2 - } - }, - "gui": { - "temperature": { - "name": "Temperature Sensor", - "group": [ "Misc" ], - "media": [ "all" ] - } - } - } - -+------------------+-------------------+ -| **Option** | **Value** | -+------------------+-------------------+ -| id | *valid i2c id* | -+------------------+-------------------+ -| temperature | -55 - 125 | -+------------------+-------------------+ - -.. versionchanged:: 8.0 - -.. code-block:: json - :linenos: - - { - "devices": { - "temperature": { - "protocol": [ "lm75" ], - "id": [{ - "id": "0x49", - "i2c-path": "/dev/i2c-0" - }], - "temperature": 17.2 - } - }, - "gui": { - "temperature": { - "name": "Temperature Sensor", - "group": [ "Misc" ], - "media": [ "all" ] - } - } - } - - -+------------------+-------------------+ -| **Option** | **Value** | -+------------------+-------------------+ -| id | *valid i2c id* | -+------------------+-------------------+ -| i2c-path | *valid i2c path* | -+------------------+-------------------+ -| temperature | -55 - 125 | -+------------------+-------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| poll-interval | 5 | seconds | What should be the poll interval of the sensors | -+--------------------+-------------+------------+-------------------------------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -.. note:: LM75 - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 1 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. note:: LM76 - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 3 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/am2302.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/am2302.rst deleted file mode 100644 index 4b8fe7f..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/am2302.rst +++ /dev/null @@ -1,4 +0,0 @@ -1-Wire AM2302 -============= - -.. include:: _am2302.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/bmp085.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/bmp085.rst deleted file mode 100644 index 26cefce..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/bmp085.rst +++ /dev/null @@ -1,4 +0,0 @@ -BMP085 -====== - -.. include:: _bmp180.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/bmp180.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/bmp180.rst deleted file mode 100644 index 7331610..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/bmp180.rst +++ /dev/null @@ -1,4 +0,0 @@ -BMP180 -====== - -.. include:: _bmp180.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/cputemp.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/cputemp.rst deleted file mode 100644 index dfcf4e0..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/cputemp.rst +++ /dev/null @@ -1,105 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -CPU Temperature -=============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| Raspberry Pi | cpu_temp | -+------------------+--------------+ -| Hummingboard | cpu_temp | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "weather": { - "protocol": [ "cpu_temp" ], - "id": [{ - "id": 1 - }], - "temperature": 59.397, - "poll-interval": 10 - } - }, - "gui": { - "temperature": { - "name": "Temperature Sensor", - "group": [ "Misc" ], - "media": [ "all" ] - } - } - } - -+------------------+-------------------+ -| **Option** | **Value** | -+------------------+-------------------+ -| id | 0 - 99999 | -+------------------+-------------------+ -| temperature | -40.000 - 85.000 | -+------------------+-------------------+ -| poll-interval | 1 - 60 | -+------------------+-------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------+ -| poll-interval | 5 | seconds | What should be the poll interval of the sensors | -+--------------------+-------------+------------+-------------------------------------------------+ -| temperature-offset | 0 | number | Correct temperature value | -+--------------------+-------------+------------+-------------------------------------------------+ - -:underline:`GUI Settings` - -+----------------------+-------------+------------+-----------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| temperature-decimals | 1 | number | How many decimals the GUIs should display for temperature | -+----------------------+-------------+------------+-----------------------------------------------------------+ -| show-temperature | 1 | 1 or 0 | Don't display the temperature value | -+----------------------+-------------+------------+-----------------------------------------------------------+ - -.. rubric:: Comments - -On the Raspberry Pi: - -It is possible you need to first load the sensor module: - -.. code-block:: console - - sudo modprobe bcm2835_thermal - -To make sure this is done every reboot, edit ``/etc/modules`` and add the following lines: - -.. code-block:: console - - bcm2835_thermal \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/dht11.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/dht11.rst deleted file mode 100644 index f262c0d..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/dht11.rst +++ /dev/null @@ -1,4 +0,0 @@ -1-Wire DHT11 -============= - -.. include:: _am2302.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/dht22.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/dht22.rst deleted file mode 100644 index b7d838f..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/dht22.rst +++ /dev/null @@ -1,4 +0,0 @@ -1-Wire DHT22 -============= - -.. include:: _am2302.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/ds18b20.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/ds18b20.rst deleted file mode 100644 index 0b911d2..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/ds18b20.rst +++ /dev/null @@ -1,4 +0,0 @@ -DS18B20 -======= - -.. include:: _ds18b20.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/ds18s20.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/ds18s20.rst deleted file mode 100644 index d775465..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/ds18s20.rst +++ /dev/null @@ -1,4 +0,0 @@ -DS18S20 -======= - -.. include:: _ds18b20.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/gpio_switch.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/gpio_switch.rst deleted file mode 100644 index 4f48dff..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/gpio_switch.rst +++ /dev/null @@ -1,86 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -GPIO Switch -=============== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -+------------------+--------------+ -| **Brand** | **Protocol** | -+------------------+--------------+ -| Raspberry Pi | cpu_temp | -+------------------+--------------+ -| Hummingboard | cpu_temp | -+------------------+--------------+ - -.. rubric:: Sender Arguments - -.. code-block:: console - - -g --gpio=gpio the gpio the switch is connected to - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "switch": { - "protocol": [ "gpio_switch" ], - "id": [{ - "gpio": 1 - }], - "state": "off" - } - }, - "gui": { - "switch": { - "name": "Switch", - "group": [ "Misc" ], - "media": [ "all" ] - } - } - } - -+------------------+-----------------+ -| **Option** | **Value** | -+------------------+-----------------+ -| gpio | 0 - 255 | -+------------------+-----------------+ -| state | on / off | -+------------------+-----------------+ - -.. note:: - - The ``gpio`` value should be a valid GPIO for the platform used - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+------------------+-------------+------------+-----------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+------------------+-------------+------------+-----------------------------------------------+ -| readonly | 0 | 1 or 0 | Disable controlling this device from the GUIs | -+------------------+-------------+------------+-----------------------------------------------+ -| confirm | 0 | 1 or 0 | Ask for confirmation when switching device | -+------------------+-------------+------------+-----------------------------------------------+ - -.. rubric:: Comments - -The GPIO switch protocol follows the wiringX numbering as can be found here: http://wiringx.org \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/index.rst deleted file mode 100644 index 79693a3..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/index.rst +++ /dev/null @@ -1,17 +0,0 @@ -GPIO -==== - -.. toctree:: - :maxdepth: 3 - - am2302 - bmp180 - bmp085 - cputemp - dht22 - dht11 - ds18b20 - ds18s20 - gpio_switch - lm75 - lm76 \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/lm75.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/lm75.rst deleted file mode 100644 index 378ff89..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/lm75.rst +++ /dev/null @@ -1,4 +0,0 @@ -I2C-bus LM75 -============ - -.. include:: _lm75.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/gpio/lm76.rst b/lib/ESPiLight/pilight/docs/source/protocols/gpio/lm76.rst deleted file mode 100644 index 712c5ff..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/gpio/lm76.rst +++ /dev/null @@ -1,4 +0,0 @@ -I2C-bus LM76 -============ - -.. include:: _lm75.rst \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/index.rst deleted file mode 100644 index 335183c..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Protocols -========= - -.. toctree:: - :maxdepth: 3 - - 433.92/index - api/index - generic/index - network/index - gpio/index \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/network/arping.rst b/lib/ESPiLight/pilight/docs/source/protocols/network/arping.rst deleted file mode 100644 index c5a28af..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/network/arping.rst +++ /dev/null @@ -1,75 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Arping -====== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "arping": { - "protocol": [ "arping" ], - "id": [{ - "mac": "xx:xx:xx:xx:xx:xx" - }], - "ip": "0.0.0.0", - "state": "connected" - } - } - } - -+------------------+--------------------------+ -| **Option** | **Value** | -+------------------+--------------------------+ -| mac | *valid mac address* | -+------------------+--------------------------+ -| ip | *valid ip address* | -+------------------+--------------------------+ -| state | connected / disconnected | -+------------------+--------------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+-------------------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+-------------------------------------------------------------+ -| poll-interval | 1 | >= 1 | How often do we want to arping the mac address (in seconds) | -+--------------------+-------------+------------+-------------------------------------------------------------+ - -.. rubric::: Comment - - -The arping protocol doesn't have a GUI representation. You can of course use the arping protocol in your rules. - -The ping protocol doesn't have a GUI representation. You can of course use the ping protocol in your rules. - -.. rubric:: Note - -The MAC address must be written in lowercase. \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/network/index.rst b/lib/ESPiLight/pilight/docs/source/protocols/network/index.rst deleted file mode 100644 index 095e603..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/network/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -Network -======= - -.. toctree:: - :maxdepth: 3 - - ping - arping \ No newline at end of file diff --git a/lib/ESPiLight/pilight/docs/source/protocols/network/ping.rst b/lib/ESPiLight/pilight/docs/source/protocols/network/ping.rst deleted file mode 100644 index b22a880..0000000 --- a/lib/ESPiLight/pilight/docs/source/protocols/network/ping.rst +++ /dev/null @@ -1,82 +0,0 @@ -.. |yes| image:: ../../images/yes.png -.. |no| image:: ../../images/no.png - -.. role:: underline - :class: underline - -Ping -==== - -+------------------+-------------+ -| **Feature** | **Support** | -+------------------+-------------+ -| Sending | |no| | -+------------------+-------------+ -| Receiving | |yes| | -+------------------+-------------+ -| Config | |yes| | -+------------------+-------------+ - -.. rubric:: Supported Brands - -*None* - -.. rubric:: Sender Arguments - -*None* - -.. rubric:: Config - -.. code-block:: json - :linenos: - - { - "devices": { - "ping": { - "protocol": [ "ping" ], - "id": [{ - "ip": "x.x.x.x" - }], - "state": "connected" - } - } - } - -+------------------+--------------------------+ -| **Option** | **Value** | -+------------------+--------------------------+ -| ip | *valid ip address* | -+------------------+--------------------------+ -| state | connected / disconnected | -+------------------+--------------------------+ - -.. rubric:: Optional Settings - -:underline:`Device Settings` - -+--------------------+-------------+------------+--------------------------------------------------+ -| **Setting** | **Default** | **Format** | **Description** | -+--------------------+-------------+------------+--------------------------------------------------+ -| poll-interval | 1 | >= 1 | How often do we want to ping the ip (in seconds) | -+--------------------+-------------+------------+--------------------------------------------------+ - -.. rubric::: Comment - - -The ping protocol uses the ICMP ECHO request command and reports the state DISCONNECTED if it receives a response that it is not an ECHO REPLY. - -The ping protocol doesn't have a GUI representation. You can of course use the ping protocol in your rules. - -.. rubric:: Status Replies - -| 3 - Destination Unreachable -| 4 - Source Quench -| 5 - Redirect (change route) -| 11 - Time Exceeded -| 12 - Parameter Problem -| 13 - Timestamp Request -| 14 - Timestamp Reply -| 15 - Information Request -| 16 - Information Reply -| 17 - Address Mask Request -| 18 - Address Mask Reply \ No newline at end of file diff --git a/lib/ESPiLight/pilight/flash.c b/lib/ESPiLight/pilight/flash.c deleted file mode 100644 index 2cf6d65..0000000 --- a/lib/ESPiLight/pilight/flash.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#endif - -#include "libs/pilight/core/threads.h" -#include "libs/pilight/core/pilight.h" -#include "libs/pilight/core/gc.h" -#include "libs/pilight/core/common.h" -#include "libs/pilight/core/log.h" -#include "libs/pilight/core/options.h" -#include "libs/pilight/core/firmware.h" - -#include "libs/pilight/events/events.h" - -int main(int argc, char **argv) { - // memtrack(); - - atomicinit(); - log_shell_enable(); - log_file_disable(); - - struct options_t *options = NULL; - char *configtmp = MALLOC(strlen(CONFIG_FILE)+1); - char *args = NULL; - char *fwfile = NULL; - char comport[255]; - - memset(&comport, '\0', 255); - - strcpy(configtmp, CONFIG_FILE); - - if((progname = MALLOC(15)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(progname, "pilight-flash"); - - options_add(&options, 'H', "help", OPTION_NO_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'V', "version", OPTION_NO_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'C', "config", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'f', "file", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, NULL); - options_add(&options, 'p', "comport", OPTION_HAS_VALUE, 0, JSON_NULL, NULL, NULL); - - while (1) { - int c; - c = options_parse(&options, argc, argv, 1, &args); - if(c == -1) - break; - if(c == -2) - c = 'H'; - switch (c) { - case 'H': - printf("Usage: %s [options]\n", progname); - printf("\t -H --help\t\tdisplay usage summary\n"); - printf("\t -V --version\t\tdisplay version\n"); - printf("\t -C --config\t\tconfig file\n"); - printf("\t -p --comport\t\tserial COM port\n"); - printf("\t -f --file=firmware\tfirmware file\n"); - goto close; - break; - case 'V': - printf("%s v%s\n", progname, PILIGHT_VERSION); - goto close; - break; - case 'C': - configtmp = REALLOC(configtmp, strlen(args)+1); - strcpy(configtmp, args); - break; - case 'p': - strcpy(comport, args); - break; - case 'f': - if(access(args, F_OK) != -1) { - fwfile = REALLOC(fwfile, strlen(args)+1); - strcpy(fwfile, args); - } else { - fprintf(stderr, "%s: the firmware file %s does not exist\n", progname, args); - goto close; - } - break; - default: - printf("Usage: %s -f pilight_firmware_tX5_v3.hex\n", progname); - goto close; - break; - } - } - - if(config_set_file(configtmp) == EXIT_FAILURE) { - goto close; - } - - protocol_init(); - config_init(); - if(config_read() != EXIT_SUCCESS) { - FREE(configtmp); - goto close; - } - -#ifdef _WIN32 - if(fwfile == NULL || strlen(fwfile) == 0 || strlen(comport) == 0) { - printf("Usage: %s -f pilight_firmware_XXX_vX.hex -p comX\n", progname); - goto close; - } -#else - if(fwfile == NULL || strlen(fwfile) == 0) { - printf("Usage: %s -f pilight_firmware_XXX_vX.hex\n", progname); - goto close; - } -#endif - - log_level_set(LOG_DEBUG); - firmware.version = 0; - logprintf(LOG_INFO, "**** START UPD. FW ****"); - firmware_getmp(comport); - - if(firmware_update(fwfile, comport) != 0) { - logprintf(LOG_INFO, "**** FAILED UPD. FW ****"); - } else { - logprintf(LOG_INFO, "**** DONE UPD. FW ****"); - } - -close: - log_shell_disable(); - options_delete(options); - if(fwfile != NULL) { - FREE(fwfile); - } - if(configtmp != NULL) { - FREE(configtmp); - } - log_shell_disable(); - log_level_set(LOG_ERR); - config_gc(); - protocol_gc(); - options_gc(); -#ifdef EVENTS - events_gc(); -#endif -#ifndef _WIN32 - wiringXGC(); -#endif - log_gc(); - threads_gc(); - gc_clear(); - FREE(progname); - xfree(); - return (EXIT_SUCCESS); -} diff --git a/lib/ESPiLight/pilight/inc/CMakeLists.txt b/lib/ESPiLight/pilight/inc/CMakeLists.txt deleted file mode 100644 index b279a6a..0000000 --- a/lib/ESPiLight/pilight/inc/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -project(inc) - -include(../CMakeConfig.txt) - -configure_file(${PROJECT_SOURCE_DIR}/defines.h.in ${PROJECT_SOURCE_DIR}/defines.h) \ No newline at end of file diff --git a/lib/ESPiLight/pilight/inc/defines.h.in b/lib/ESPiLight/pilight/inc/defines.h.in deleted file mode 100644 index 3f01c6a..0000000 --- a/lib/ESPiLight/pilight/inc/defines.h.in +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _DEFINES_H_ -#define _DEFINES_H_ - -#cmakedefine WEBSERVER -#cmakedefine EVENTS - -#define PILIGHT_VERSION "7.0" -#define PULSE_DIV 34 -#define MAXPULSESTREAMLENGTH 512 -#define EPSILON 0.00001 -#define SHA256_ITERATIONS 25000 - -#ifdef WEBSERVER - #define WEBSERVER_HTTP_PORT 5001 - #define WEBSERVER_HTTPS_PORT 5002 - #ifdef _WIN32 - #define WEBSERVER_ROOT "c:/pilight/web/" - #else - #define WEBSERVER_ROOT "/usr/local/pilight/webgui/" - #endif - #define WEBSERVER_ENABLE 1 - #define WEBSERVER_CACHE 1 - #define MAX_UPLOAD_FILESIZE 5242880 - #define MAX_CACHE_FILESIZE 1048576 - #define WEBSERVER_WORKERS 1 - #define WEBSERVER_CHUNK_SIZE 4096 - #define WEBGUI_WEBSOCKETS 1 - #cmakedefine WEBSERVER_HTTPS 1 -#endif - -#define MAX_CLIENTS 30 -#define BUFFER_SIZE 1025 -#define MEMBUFFER 128 -#define EOSS "\n\n" // End Of Socket Stream - -#ifdef _WIN32 - #define PROTOCOL_ROOT "c:/pilight/protocols/" - #define HARDWARE_ROOT "c:/pilight/hardware/" - #define OPERATOR_ROOT "c:/pilight/operators/" - #define FUNCTION_ROOT "c:/pilight/functions/" - #define ACTION_ROOT "c:/pilight/actions/" - - #define CONFIG_FILE "c:/pilight/config.json" - #define LOG_FILE "c:/pilight/pilight.log" - #define PEM_FILE "c:/pilight/pilight.pem" -#else - #define PROTOCOL_ROOT "/usr/local/lib/pilight/protocols/" - #define HARDWARE_ROOT "/usr/local/lib/pilight/hardware/" - #define OPERATOR_ROOT "/usr/local/lib/pilight/operators/" - #define FUNCTION_ROOT "/usr/local/lib/pilight/functions/" - #define ACTION_ROOT "/usr/local/lib/pilight/actions/" - - #define PID_FILE "/var/run/pilight.pid" - #define CONFIG_FILE "/etc/pilight/config.json" - #define LOG_FILE "/var/log/pilight.log" - #define PEM_FILE "/etc/pilight/pilight.pem" -#endif -#define LOG_MAX_SIZE 1048576 // 1024*1024 - -#define UUID_LENGTH 21 - -#define FIRMWARE_PATH "c:/pilight/" -#define FIRMWARE_GPIO_RESET 10 -#define FIRMWARE_GPIO_SCK 14 -#define FIRMWARE_GPIO_MOSI 12 -#define FIRMWARE_GPIO_MISO 13 - -#define PILIGHT_V 7 - -#define GPIO_PLATFORM "none" - -#if !defined(PATH_MAX) - #if defined(_POSIX_PATH_MAX) - #define PATH_MAX _POSIX_PATH_MAX - #else - #define PATH_MAX 1024 - #endif -#endif - -#endif diff --git a/lib/ESPiLight/pilight/inc/i2c-dev.h b/lib/ESPiLight/pilight/inc/i2c-dev.h deleted file mode 100644 index 39f0fd5..0000000 --- a/lib/ESPiLight/pilight/inc/i2c-dev.h +++ /dev/null @@ -1,335 +0,0 @@ -/* - i2c-dev.h - i2c-bus driver, char device interface - - Copyright (C) 1995-97 Simon G. Vogl - Copyright (C) 1998-99 Frodo Looijaard - - 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 of the License, 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., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301 USA. -*/ - -/* $Id: i2c-dev.h 5894 2010-12-12 13:22:29Z khali $ */ - -#ifndef LIB_I2CDEV_H -#define LIB_I2CDEV_H - -#include -#include - - -/* -- i2c.h -- */ - - -/* - * I2C Message - used for pure i2c transaction, also from /dev interface - */ -struct i2c_msg { - __u16 addr; /* slave address */ - unsigned short flags; -#define I2C_M_TEN 0x10 /* we have a ten bit chip address */ -#define I2C_M_RD 0x01 -#define I2C_M_NOSTART 0x4000 -#define I2C_M_REV_DIR_ADDR 0x2000 -#define I2C_M_IGNORE_NAK 0x1000 -#define I2C_M_NO_RD_ACK 0x0800 - short len; /* msg length */ - char *buf; /* pointer to msg data */ -}; - -/* To determine what functionality is present */ - -#define I2C_FUNC_I2C 0x00000001 -#define I2C_FUNC_10BIT_ADDR 0x00000002 -#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ -#define I2C_FUNC_SMBUS_PEC 0x00000008 -#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ -#define I2C_FUNC_SMBUS_QUICK 0x00010000 -#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 -#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 -#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 -#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 -#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 -#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 -#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 -#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 -#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 -#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ -#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ - -#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ - I2C_FUNC_SMBUS_WRITE_BYTE) -#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ - I2C_FUNC_SMBUS_WRITE_BYTE_DATA) -#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ - I2C_FUNC_SMBUS_WRITE_WORD_DATA) -#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ - I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) -#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) - -/* Old name, for compatibility */ -#define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC - -/* - * Data for SMBus Messages - */ -#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ -#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */ -union i2c_smbus_data { - __u8 byte; - __u16 word; - __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ - /* and one more for PEC */ -}; - -/* smbus_access read or write markers */ -#define I2C_SMBUS_READ 1 -#define I2C_SMBUS_WRITE 0 - -/* SMBus transaction types (size parameter in the above functions) - Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ -#define I2C_SMBUS_QUICK 0 -#define I2C_SMBUS_BYTE 1 -#define I2C_SMBUS_BYTE_DATA 2 -#define I2C_SMBUS_WORD_DATA 3 -#define I2C_SMBUS_PROC_CALL 4 -#define I2C_SMBUS_BLOCK_DATA 5 -#define I2C_SMBUS_I2C_BLOCK_BROKEN 6 -#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ -#define I2C_SMBUS_I2C_BLOCK_DATA 8 - - -/* ----- commands for the ioctl like i2c_command call: - * note that additional calls are defined in the algorithm and hw - * dependent layers - these can be listed here, or see the - * corresponding header files. - */ - /* -> bit-adapter specific ioctls */ -#define I2C_RETRIES 0x0701 /* number of times a device address */ - /* should be polled when not */ - /* acknowledging */ -#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ - - -/* this is for i2c-dev.c */ -#define I2C_SLAVE 0x0703 /* Change slave address */ - /* Attn.: Slave address is 7 or 10 bits */ -#define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ - /* Attn.: Slave address is 7 or 10 bits */ - /* This changes the address, even if it */ - /* is already taken! */ -#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ - -#define I2C_FUNCS 0x0705 /* Get the adapter functionality */ -#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ -#define I2C_PEC 0x0708 /* != 0 for SMBus PEC */ - -#define I2C_SMBUS 0x0720 /* SMBus-level access */ - -/* -- i2c.h -- */ - - -/* Note: 10-bit addresses are NOT supported! */ - -/* This is the structure as used in the I2C_SMBUS ioctl call */ -struct i2c_smbus_ioctl_data { - char read_write; - __u8 command; - int size; - union i2c_smbus_data *data; -}; - -/* This is the structure as used in the I2C_RDWR ioctl call */ -struct i2c_rdwr_ioctl_data { - struct i2c_msg *msgs; /* pointers to i2c_msgs */ - int nmsgs; /* number of i2c_msgs */ -}; - - -static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, - int size, union i2c_smbus_data *data) -{ - struct i2c_smbus_ioctl_data args; - - args.read_write = read_write; - args.command = command; - args.size = size; - args.data = data; - return ioctl(file,I2C_SMBUS,&args); -} - - -static inline __s32 i2c_smbus_write_quick(int file, __u8 value) -{ - return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL); -} - -static inline __s32 i2c_smbus_read_byte(int file) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data)) - return -1; - else - return 0x0FF & data.byte; -} - -static inline __s32 i2c_smbus_write_byte(int file, __u8 value) -{ - return i2c_smbus_access(file,I2C_SMBUS_WRITE,value, - I2C_SMBUS_BYTE,NULL); -} - -static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_BYTE_DATA,&data)) - return -1; - else - return 0x0FF & data.byte; -} - -static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command, - __u8 value) -{ - union i2c_smbus_data data; - data.byte = value; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BYTE_DATA, &data); -} - -static inline __s32 i2c_smbus_read_word_data(int file, __u8 command) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_WORD_DATA,&data)) - return -1; - else - return 0x0FFFF & data.word; -} - -static inline __s32 i2c_smbus_write_word_data(int file, __u8 command, - __u16 value) -{ - union i2c_smbus_data data; - data.word = value; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_WORD_DATA, &data); -} - -static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value) -{ - union i2c_smbus_data data; - data.word = value; - if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_PROC_CALL,&data)) - return -1; - else - return 0x0FFFF & data.word; -} - - -/* Returns the number of read bytes */ -static inline __s32 i2c_smbus_read_block_data(int file, __u8 command, - __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_BLOCK_DATA,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - -static inline __s32 i2c_smbus_write_block_data(int file, __u8 command, - __u8 length, const __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BLOCK_DATA, &data); -} - -/* Returns the number of read bytes */ -/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you - ask for less than 32 bytes, your code will only work with kernels - 2.6.23 and later. */ -static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, - __u8 length, __u8 *values) -{ - union i2c_smbus_data data; - int i; - - if (length > 32) - length = 32; - data.block[0] = length; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN : - I2C_SMBUS_I2C_BLOCK_DATA,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - -static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, - __u8 length, - const __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_I2C_BLOCK_BROKEN, &data); -} - -/* Returns the number of read bytes */ -static inline __s32 i2c_smbus_block_process_call(int file, __u8 command, - __u8 length, __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BLOCK_PROC_CALL,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - - -#endif /* LIB_I2CDEV_H */ diff --git a/lib/ESPiLight/pilight/libs/CMakeLists.txt b/lib/ESPiLight/pilight/libs/CMakeLists.txt deleted file mode 100644 index 55c0742..0000000 --- a/lib/ESPiLight/pilight/libs/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -project(libs) - -include(../CMakeConfig.txt) - -if(${MODULESPACK} MATCHES "OFF" OR WIN32) - set(${PROJECT_NAME}_files "" CACHE INTERNAL "") - - add_subdirectory(libuv) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${libuv_files} CACHE INTERNAL "") - - add_subdirectory(avrdude) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${avrdude_files} CACHE INTERNAL "") - - if(${ZWAVE} MATCHES "ON") - add_subdirectory(openzwave) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${openzwave_files} CACHE INTERNAL "") - endif() - - add_subdirectory(pilight) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${pilight_files} CACHE INTERNAL "") -else() - add_subdirectory(pilight) -endif() diff --git a/lib/ESPiLight/pilight/libs/avrdude/CMakeLists.txt b/lib/ESPiLight/pilight/libs/avrdude/CMakeLists.txt deleted file mode 100644 index a8c4ab8..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(avrdude) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -if(WIN32) - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/avrgpio.c") -endif() - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/avrdude/arduino.c b/lib/ESPiLight/pilight/libs/avrdude/arduino.c deleted file mode 100644 index 6848adf..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/arduino.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2009 Lars Immisch - * - * 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 of the License, 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, see . - */ - -/* $Id: arduino.c 1294 2014-03-12 23:03:18Z joerg_wunsch $ */ - -/* - * avrdude interface for Arduino programmer - * - * The Arduino programmer is mostly a STK500v1, just the signature bytes - * are read differently. - */ - -#include -#include -#include - -#include "avrdude.h" -#include "pgm.h" -#include "stk500_private.h" -#include "stk500.h" -#include "serial.h" -#include "arduino.h" -#include "../pilight/core/log.h" - -/* read signature bytes - arduino version */ -static int arduino_read_sig_bytes(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m) { - unsigned char buf[32]; - - /* Signature byte reads are always 3 bytes. */ - - if(m->size < 3) { - logprintf(LOG_ERR, "memsize too small for sig byte read"); - return -1; - } - - buf[0] = Cmnd_STK_READ_SIGN; - buf[1] = Sync_CRC_EOP; - - serial_send(&pgm->fd, buf, 2); - - if(serial_recv(&pgm->fd, buf, 5) < 0) { - return -1; - } - if(buf[0] == Resp_STK_NOSYNC) { - logprintf(LOG_ERR, "stk500_cmd(): programmer is out of sync"); - return -1; - } else if (buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "arduino_read_sig_bytes(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - return -2; - } - if(buf[4] != Resp_STK_OK) { - logprintf(LOG_ERR, "arduino_read_sig_bytes(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_OK, buf[4]); - return -3; - } - - m->buf[0] = buf[1]; - m->buf[1] = buf[2]; - m->buf[2] = buf[3]; - - return 3; -} - -static int arduino_open(PROGRAMMER * pgm, char * port) { - union pinfo pinfo; - strcpy(pgm->port, port); - pinfo.baud = pgm->baudrate? pgm->baudrate: 115200; - - if(serial_open(port, pinfo, &pgm->fd) == -1) { - return -1; - } - - /* Clear DTR and RTS to unload the RESET capacitor - * (for example in Arduino) */ - serial_set_dtr_rts(&pgm->fd, 0); - usleep(250*1000); - /* Set DTR and RTS back to high */ - serial_set_dtr_rts(&pgm->fd, 1); - usleep(50*1000); - - /* - * drain any extraneous input - */ - stk500_drain(pgm, 0); - - if(stk500_getsync(pgm) < 0) { - return -1; - } - - return 0; -} - -static void arduino_close(PROGRAMMER * pgm) { - serial_set_dtr_rts(&pgm->fd, 0); - serial_close(&pgm->fd); - pgm->fd.ifd = -1; -} - -const char arduino_desc[] = "Arduino programmer"; - -void arduino_initpgm(PROGRAMMER * pgm) { - /* This is mostly a STK500; just the signature is read - differently than on real STK500v1 - and the DTR signal is set when opening the serial port - for the Auto-Reset feature */ - stk500_initpgm(pgm); - - strcpy(pgm->type, "Arduino"); - pgm->read_sig_bytes = arduino_read_sig_bytes; - pgm->open = arduino_open; - pgm->close = arduino_close; -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/arduino.h b/lib/ESPiLight/pilight/libs/avrdude/arduino.h deleted file mode 100644 index c2072ea..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/arduino.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2009 Lars Immisch - * - * 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 of the License, 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, see . - */ - -/* $Id: arduino.h 1294 2014-03-12 23:03:18Z joerg_wunsch $ */ - -#ifndef arduino_h__ -#define arduino_h__ - -extern const char arduino_desc[]; -void arduino_initpgm (PROGRAMMER * pgm); - -#endif - - diff --git a/lib/ESPiLight/pilight/libs/avrdude/avr.c b/lib/ESPiLight/pilight/libs/avrdude/avr.c deleted file mode 100644 index 25b8099..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avr.c +++ /dev/null @@ -1,915 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: avr.c 907 2010-01-12 15:42:40Z joerg_wunsch $ */ - -#include -#include -#include -#include -#include -#include - -#include "avrdude.h" - -#include "../pilight/core/log.h" -#include "../pilight/core/common.h" -#include "avr.h" -#include "pindefs.h" -#include "safemode.h" - -FP_UpdateProgress avr_update_progress; - -void avr_set_update_progress(FP_UpdateProgress callback) { - avr_update_progress = callback; -} - -int parse_cmdbits(OPCODE * op, char *t) { - int bitno; - unsigned int n = 0, i = 0; - char ch; - char *e = NULL; - char *q = NULL; - int len; - char **array = NULL; - - bitno = 32; - n = explode(t, " ", &array); - for(i=0;ibit[bitno].type = AVR_CMDBIT_VALUE; - op->bit[bitno].value = 1; - op->bit[bitno].bitno = bitno % 8; - break; - case '0': - op->bit[bitno].type = AVR_CMDBIT_VALUE; - op->bit[bitno].value = 0; - op->bit[bitno].bitno = bitno % 8; - break; - case 'x': - op->bit[bitno].type = AVR_CMDBIT_IGNORE; - op->bit[bitno].value = 0; - op->bit[bitno].bitno = bitno % 8; - break; - case 'a': - op->bit[bitno].type = AVR_CMDBIT_ADDRESS; - op->bit[bitno].value = 0; - op->bit[bitno].bitno = 8*(bitno/8) + bitno % 8; - break; - case 'i': - op->bit[bitno].type = AVR_CMDBIT_INPUT; - op->bit[bitno].value = 0; - op->bit[bitno].bitno = bitno % 8; - break; - case 'o': - op->bit[bitno].type = AVR_CMDBIT_OUTPUT; - op->bit[bitno].value = 0; - op->bit[bitno].bitno = bitno % 8; - break; - default : - break; - } - } else { - if(ch == 'a') { - q = &array[i][1]; - op->bit[bitno].bitno = strtol(q, &e, 0); - op->bit[bitno].type = AVR_CMDBIT_ADDRESS; - op->bit[bitno].value = 0; - } - } - } - array_free(&array, n); - return 0; -} - -int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char * value) -{ - unsigned char cmd[4]; - unsigned char res[4]; - unsigned char data; - OPCODE * readop, * lext; - - if (pgm->cmd == NULL) { - logprintf(LOG_ERR, "%s programmer uses avr_read_byte_default() but does not provide a cmd() method", pgm->type); - return -1; - } - - /* - * figure out what opcode to use - */ - if (mem->op[AVR_OP_READ_LO]) { - if (addr & 0x00000001) - readop = mem->op[AVR_OP_READ_HI]; - else - readop = mem->op[AVR_OP_READ_LO]; - addr = addr / 2; - } - else { - readop = mem->op[AVR_OP_READ]; - } - - if (readop == NULL) { - return -1; - } - - /* - * If this device has a "load extended address" command, issue it. - */ - lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; - - if (lext != NULL) { - memset(cmd, 0, sizeof(cmd)); - - avr_set_bits(lext, cmd); - avr_set_addr(lext, cmd, addr); - pgm->cmd(pgm, cmd, res); - } - - memset(cmd, 0, sizeof(cmd)); - - avr_set_bits(readop, cmd); - avr_set_addr(readop, cmd, addr); - pgm->cmd(pgm, cmd, res); - data = 0; - avr_get_output(readop, res, &data); - - *value = data; - - return 0; -} - - -/* - * Return the number of "interesting" bytes in a memory buffer, - * "interesting" being defined as up to the last non-0xff data - * value. This is useful for determining where to stop when dealing - * with "flash" memory, since writing 0xff to flash is typically a - * no-op. Always return an even number since flash is word addressed. - */ -int avr_mem_hiaddr(AVRMEM * mem) -{ - int i, n; - - /* return the highest non-0xff address regardless of how much - memory was read */ - for (i=mem->size-1; i>0; i--) { - if (mem->buf[i] != 0xff) { - n = i+1; - if (n & 0x01) - return n+1; - else - return n; - } - } - - return 0; -} - - -/* - * Read the entirety of the specified memory type into the - * corresponding buffer of the avrpart pointed to by 'p'. If size = - * 0, read the entire contents, otherwise, read 'size' bytes. - * - * Return the number of bytes read, or < 0 if an error occurs. - */ -int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size) -{ - int wsize; - unsigned char rbyte; - unsigned long i; - unsigned char * buf; - AVRMEM * mem = NULL; - int rc; - - /* NEW */ - if(strcmp(memtype, "signature") == 0) { - mem = p->sigmem; - } else if(strcmp(memtype, "flash") == 0) { - mem = p->flashmem; - } else if(strcmp(memtype, "lfuse") == 0) { - mem = p->lfusemem; - } else if(strcmp(memtype, "hfuse") == 0) { - mem = p->hfusemem; - } - // mem = avr_locate_mem(p, memtype); - if (mem == NULL) { - logprintf(LOG_ERR, "No \"%s\" memory for part %s", memtype, p->desc); - return -1; - } - - wsize = mem->size; - if (size < wsize) { - wsize = size; - } - - buf = mem->buf; - if (size == 0) { - size = mem->size; - } - - /* - * start with all 0xff - */ - memset(buf, 0xff, size); - - if (pgm->paged_load != NULL && mem->page_size != 0) { - /* - * the programmer supports a paged mode read - */ - int need_read, failure; - unsigned int pageaddr; - unsigned int npages, nread; - - /* quickly scan number of pages to be written to first */ - for (pageaddr = 0, npages = 0; - pageaddr < wsize; - pageaddr += mem->page_size) { - /* check whether this page must be read */ - for (i = pageaddr; - i < pageaddr + mem->page_size; - i++) - if (i < mem->size) { - npages++; - break; - } - } - - for (pageaddr = 0, failure = 0, nread = 0; - !failure && pageaddr < wsize; - pageaddr += mem->page_size) { - /* check whether this page must be read */ - for (i = pageaddr, need_read = 0; - i < pageaddr + mem->page_size; - i++) - if (i < mem->size) { - need_read = 1; - break; - } - if (need_read) { - rc = pgm->paged_load(pgm, p, mem, mem->page_size, - pageaddr, mem->page_size); - if (rc < 0) - /* paged load failed, fall back to byte-at-a-time read below */ - failure = 1; - } - nread++; - report_progress(nread, npages, NULL); - } - if (!failure) { - if (strcasecmp(mem->desc, "flash") == 0 || - strcasecmp(mem->desc, "application") == 0 || - strcasecmp(mem->desc, "apptable") == 0 || - strcasecmp(mem->desc, "boot") == 0) - return avr_mem_hiaddr(mem); - else - return mem->size; - } - } - - if (strcmp(mem->desc, "signature") == 0) { - if (pgm->read_sig_bytes) { - return pgm->read_sig_bytes(pgm, p, mem); - } - } - - for (i=0; iread_byte(pgm, p, mem, i, &rbyte); - if (rc != 0) { - logprintf(LOG_ERR, "avr_read(): error reading address 0x%04lx", i); - if (rc == -1) - logprintf(LOG_ERR, "read operation not supported for memory \"%s\"", memtype); - return -2; - } - buf[i] = rbyte; - report_progress(i, size, NULL); - } - - if (strcasecmp(mem->desc, "flash") == 0) - return avr_mem_hiaddr(mem); - else - return i; -} - - -/* - * write a page data at the specified address - */ -int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr) -{ - unsigned char cmd[4]; - unsigned char res[4]; - OPCODE * wp, * lext; - - if (pgm->cmd == NULL) { - logprintf(LOG_ERR, "%s programmer uses avr_write_page() but does not provide a cmd() method", pgm->type); - return -1; - } - - wp = mem->op[AVR_OP_WRITEPAGE]; - if (wp == NULL) { - logprintf(LOG_ERR, "avr_write_page(): memory \"%s\" not configured for page writes", mem->desc); - return -1; - } - - /* - * if this memory is word-addressable, adjust the address - * accordingly - */ - if ((mem->op[AVR_OP_LOADPAGE_LO]) || (mem->op[AVR_OP_READ_LO])) - addr = addr / 2; - - /* - * If this device has a "load extended address" command, issue it. - */ - lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; - if (lext != NULL) { - memset(cmd, 0, sizeof(cmd)); - - avr_set_bits(lext, cmd); - avr_set_addr(lext, cmd, addr); - pgm->cmd(pgm, cmd, res); - } - - memset(cmd, 0, sizeof(cmd)); - - avr_set_bits(wp, cmd); - avr_set_addr(wp, cmd, addr); - pgm->cmd(pgm, cmd, res); - - /* - * since we don't know what voltage the target AVR is powered by, be - * conservative and delay the max amount the spec says to wait - */ - usleep(mem->max_write_delay); - - return 0; -} - - -int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char data) -{ - unsigned char cmd[4]; - unsigned char res[4]; - unsigned char r; - int ready; - int tries; - unsigned long start_time; - unsigned long prog_time; - unsigned char b; - unsigned short caddr; - OPCODE * writeop; - int rc; - int readok=0; - struct timeval tv; - - if (pgm->cmd == NULL) { - logprintf(LOG_ERR, "%s programmer uses avr_write_byte_default() but does not provide a cmd() method.", pgm->type); - return -1; - } - - if (!mem->paged) { - /* - * check to see if the write is necessary by reading the existing - * value and only write if we are changing the value; we can't - * use this optimization for paged addressing. - */ - rc = pgm->read_byte(pgm, p, mem, addr, &b); - if (rc != 0) { - if (rc != -1) { - return -2; - } - /* - * the read operation is not support on this memory type - */ - } - else { - readok = 1; - if (b == data) { - return 0; - } - } - } - - /* - * determine which memory opcode to use - */ - if (mem->op[AVR_OP_WRITE_LO]) { - if (addr & 0x01) - writeop = mem->op[AVR_OP_WRITE_HI]; - else - writeop = mem->op[AVR_OP_WRITE_LO]; - caddr = addr / 2; - } - else if (mem->paged && mem->op[AVR_OP_LOADPAGE_LO]) { - if (addr & 0x01) - writeop = mem->op[AVR_OP_LOADPAGE_HI]; - else - writeop = mem->op[AVR_OP_LOADPAGE_LO]; - caddr = addr / 2; - } - else { - writeop = mem->op[AVR_OP_WRITE]; - caddr = addr; - } - - if (writeop == NULL) { - return -1; - } - - memset(cmd, 0, sizeof(cmd)); - - avr_set_bits(writeop, cmd); - avr_set_addr(writeop, cmd, caddr); - avr_set_input(writeop, cmd, data); - pgm->cmd(pgm, cmd, res); - - if (mem->paged) { - /* - * in paged addressing, single bytes to be written to the memory - * page complete immediately, we only need to delay when we commit - * the whole page via the avr_write_page() routine. - */ - return 0; - } - - if (readok == 0) { - /* - * read operation not supported for this memory type, just wait - * the max programming time and then return - */ - usleep(mem->max_write_delay); /* maximum write delay */ - return 0; - } - - tries = 0; - ready = 0; - while (!ready) { - - if ((data == mem->readback[0]) || - (data == mem->readback[1])) { - /* - * use an extra long delay when we happen to be writing values - * used for polled data read-back. In this case, polling - * doesn't work, and we need to delay the worst case write time - * specified for the chip. - */ - usleep(mem->max_write_delay); - rc = pgm->read_byte(pgm, p, mem, addr, &r); - if (rc != 0) { - return -5; - } - } - else { - gettimeofday (&tv, NULL); - start_time = (tv.tv_sec * 1000000) + tv.tv_usec; - do { - /* - * Do polling, but timeout after max_write_delay. - */ - rc = pgm->read_byte(pgm, p, mem, addr, &r); - if (rc != 0) { - return -4; - } - gettimeofday (&tv, NULL); - prog_time = (tv.tv_sec * 1000000) + tv.tv_usec; - } while ((r != data) && - ((prog_time-start_time) < mem->max_write_delay)); - } - - /* - * At this point we either have a valid readback or the - * max_write_delay is expired. - */ - - if (r == data) { - ready = 1; - } - else if (mem->pwroff_after_write) { - /* - * The device has been flagged as power-off after write to this - * memory type. The reason we don't just blindly follow the - * flag is that the power-off advice may only apply to some - * memory bits but not all. We only actually power-off the - * device if the data read back does not match what we wrote. - */ - logprintf(LOG_NOTICE, "this device must be powered off and back on to continue"); - if (pgm->pinno[PPI_AVR_VCC]) { - logprintf(LOG_NOTICE, "attempting to do this now ..."); - pgm->powerdown(pgm); - usleep(250000); - rc = pgm->initialize(pgm, p); - if (rc < 0) { - logprintf(LOG_ERR, "initialization failed, rc=%d", rc); - logprintf(LOG_ERR, "can't re-initialize device after programming the %s bits", mem->desc); - return -3; - } - - logprintf(LOG_NOTICE, "device was successfully re-initialized"); - return 0; - } - } - - tries++; - if (!ready && tries > 5) { - /* - * we wrote the data, but after waiting for what should have - * been plenty of time, the memory cell still doesn't match what - * we wrote. Indicate a write error. - */ - return -6; - } - } - - return 0; -} - - -/* - * write a byte of data at the specified address - */ -int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char data) -{ - - unsigned char safemode_lfuse; - unsigned char safemode_hfuse; - unsigned char safemode_efuse; - unsigned char safemode_fuse; - - /* If we write the fuses, then we need to tell safemode that they *should* change */ - safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); - - if (strcmp(mem->desc, "fuse")==0) { - safemode_fuse = data; - } - if (strcmp(mem->desc, "lfuse")==0) { - safemode_lfuse = data; - } - if (strcmp(mem->desc, "hfuse")==0) { - safemode_hfuse = data; - } - if (strcmp(mem->desc, "efuse")==0) { - safemode_efuse = data; - } - - safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); - - return pgm->write_byte(pgm, p, mem, addr, data); -} - - -/* - * Write the whole memory region of the specified memory from the - * corresponding buffer of the avrpart pointed to by 'p'. Write up to - * 'size' bytes from the buffer. Data is only written if the new data - * value is different from the existing data value. Data beyond - * 'size' bytes is not affected. - * - * Return the number of bytes written, or -1 if an error occurs. - */ -int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size) -{ - int rc; - int wsize; - long i; - unsigned char data; - AVRMEM * m = NULL; - - /* NEW */ - if(strcmp(memtype, "flash") == 0) { - m = p->flashmem; - } else if(strcmp(memtype, "lfuse") == 0) { - m = p->lfusemem; - } else if(strcmp(memtype, "hfuse") == 0) { - m = p->hfusemem; - } - - if (m == NULL) { - logprintf(LOG_ERR, "No \"%s\" memory for part %s", memtype, p->desc); - return -1; - } - - wsize = m->size; - if (size < wsize) { - wsize = size; - } - else if (size > wsize) { - logprintf(LOG_ERR, "%d bytes requested, but memory region is only %d bytes", size, wsize); - logprintf(LOG_ERR, "Only %d bytes will actually be written", wsize); - } - - if (pgm->paged_write != NULL && m->page_size != 0) { - /* - * the programmer supports a paged mode write - */ - int need_write, failure; - unsigned int pageaddr; - unsigned int npages, nwritten; - - /* quickly scan number of pages to be written to first */ - for (pageaddr = 0, npages = 0; - pageaddr < wsize; - pageaddr += m->page_size) { - /* check whether this page must be written to */ - for (i = pageaddr; - i < pageaddr + m->page_size; - i++) - if (i < m->size) { - npages++; - break; - } - } - - for (pageaddr = 0, failure = 0, nwritten = 0; - !failure && pageaddr < wsize; - pageaddr += m->page_size) { - /* check whether this page must be written to */ - for (i = pageaddr, need_write = 0; - i < pageaddr + m->page_size; - i++) - if (i < m->size) { - need_write = 1; - break; - } - if (need_write) { - rc = 0; - if (rc >= 0) - rc = pgm->paged_write(pgm, p, m, m->page_size, pageaddr, m->page_size); - if (rc < 0) - /* paged write failed, fall back to byte-at-a-time write below */ - failure = 1; - } - nwritten++; - report_progress(nwritten, npages, NULL); - } - if (!failure) - return wsize; - /* else: fall back to byte-at-a-time write, for historical reasons */ - } - - if (pgm->write_setup) { - pgm->write_setup(pgm, p, m); - } - - for (i=0; ibuf[i]; - report_progress(i, wsize, NULL); - - rc = avr_write_byte(pgm, p, m, i, data); - if (rc) { - logprintf(LOG_ERR, "***failed"); - } - - if (m->paged) { - /* - * check to see if it is time to flush the page with a page - * write - */ - if (((i % m->page_size) == m->page_size-1) || - (i == wsize-1)) { - rc = avr_write_page(pgm, p, m, i); - if (rc) { - logprintf(LOG_ERR, " *** page %ld (addresses 0x%04lx - 0x%04lx) failed to write", - i % m->page_size, - i - m->page_size + 1, i); - } - } - } - } - - return i; -} - - - -/* - * read the AVR device's signature bytes - */ -int avr_signature(PROGRAMMER * pgm, AVRPART * p) -{ - int rc; - - report_progress (0,1,"Reading"); - rc = avr_read(pgm, p, "signature", 0); - if (rc < 0) { - logprintf(LOG_ERR, "error reading signature data for part \"%s\", rc=%d", p->desc, rc); - return -1; - } - report_progress (1,1,NULL); - - return 0; -} - - -/* - * Verify the memory buffer of p with that of v. The byte range of v, - * may be a subset of p. The byte range of p should cover the whole - * chip's memory size. - * - * Return the number of bytes verified, or -1 if they don't match. - */ -int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size) -{ - int i; - unsigned char * buf1, * buf2; - int vsize; - AVRMEM * a = NULL, * b = NULL; - - /* NEW */ - if(strcmp(memtype, "flash") == 0) { - a = p->flashmem; - } else if(strcmp(memtype, "lfuse") == 0) { - a = p->lfusemem; - } else if(strcmp(memtype, "hfuse") == 0) { - a = p->hfusemem; - } - if (a == NULL) { - logprintf(LOG_ERR, "No \"%s\" memory for part %s", memtype, p->desc); - return -1; - } - - /* NEW */ - if(strcmp(memtype, "flash") == 0) { - b = v->flashmem; - } else if(strcmp(memtype, "lfuse") == 0) { - b = v->lfusemem; - } else if(strcmp(memtype, "hfuse") == 0) { - b = v->hfusemem; - } - if (b == NULL) { - logprintf(LOG_ERR, "No \"%s\" memory for part %s", memtype, p->desc); - return -1; - } - - buf1 = a->buf; - buf2 = b->buf; - vsize = a->size; - - if (vsize < size) { - logprintf(LOG_ERR, "requested verification for %d bytes", size); - logprintf(LOG_ERR, "%s memory region only contains %d bytes", memtype, vsize); - logprintf(LOG_ERR, "Only %d bytes will be verified.", vsize); - size = vsize; - } - - for (i=0; i0; i--) { - rc = pgm->read_byte(pgm, p, a, a->size-i, &v1); - if (rc < 0) { - logprintf(LOG_ERR, "can't read memory for cycle count, rc=%d", rc); - return -1; - } - cycle_count = (cycle_count << 8) | v1; - } - - /* - * If the EEPROM is erased, the cycle count reads 0xffffffff. - * In this case we return a cycle_count of zero. - * So, the calling function don't have to care about whether or not - * the cycle count was initialized. - */ - if (cycle_count == 0xffffffff) { - cycle_count = 0; - } - - *cycles = (int) cycle_count; - - return 0; -} - - -int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles) -{ - AVRMEM * a = NULL; - unsigned char v1; - int rc; - int i; - - // a = avr_locate_mem(p, "eeprom"); - if (a == NULL) { - return -1; - } - - for (i=1; i<=4; i++) { - v1 = cycles & 0xff; - cycles = cycles >> 8; - - rc = avr_write_byte(pgm, p, a, a->size-i, v1); - if (rc < 0) { - logprintf(LOG_ERR, "can't write memory for cycle count, rc=%d", rc); - return -1; - } - } - - return 0; - } - -int avr_chip_erase(PROGRAMMER * pgm, AVRPART * p) -{ - int rc; - - rc = pgm->chip_erase(pgm, p); - - return rc; -} - -/* - * Report the progress of a read or write operation from/to the - * device. - * - * The first call of report_progress() should look like this (for a write op): - * - * report_progress (0, 1, "Writing"); - * - * Then hdr should be passed NULL on subsequent calls while the - * operation is progressing. Once the operation is complete, a final - * call should be made as such to ensure proper termination of the - * progress report: - * - * report_progress (1, 1, NULL); - * - * It would be nice if we could reduce the usage to one and only one - * call for each of start, during and end cases. As things stand now, - * that is not possible and makes maintenance a bit more work. - */ -void report_progress (int completed, int total, char *hdr) -{ - static int last = 0; - static double start_time; - int percent = (completed * 100) / total; - struct timeval tv; - double t; - - if (avr_update_progress == NULL) - return; - - gettimeofday(&tv, NULL); - t = tv.tv_sec + ((double)tv.tv_usec)/1000000; - - if (hdr) { - last = 0; - start_time = t; - avr_update_progress (percent, t - start_time, hdr); - } - - if (percent > 100) - percent = 100; - - if (percent > last) { - last = percent; - avr_update_progress (percent, t - start_time, hdr); - } - - if (percent == 100) - last = 0; /* Get ready for next time. */ -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/avr.h b/lib/ESPiLight/pilight/libs/avrdude/avr.h deleted file mode 100644 index c85303c..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avr.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: avr.h 804 2009-02-23 22:04:57Z joerg_wunsch $ */ - -#ifndef __avr_h__ -#define __avr_h__ - -#include - -#include "avrpart.h" -#include "pgm.h" - -typedef void (*FP_UpdateProgress)(int percent, double etime, char *hdr); - -extern struct avrpart parts[]; - -#ifdef __cplusplus -extern "C" { -#endif - -void avr_set_update_progress(FP_UpdateProgress callback); - -int parse_cmdbits(OPCODE * op, char *t); - -int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char * value); - -int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size); - -int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr); - -int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char data); - -int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char data); - -int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size); - -int avr_signature(PROGRAMMER * pgm, AVRPART * p); - -int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size); - -int avr_get_cycle_count(PROGRAMMER * pgm, AVRPART * p, int * cycles); - -int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles); - -int avr_mem_hiaddr(AVRMEM * mem); - -int avr_chip_erase(PROGRAMMER * pgm, AVRPART * p); - -void report_progress (int completed, int total, char *hdr); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrbitbang.c b/lib/ESPiLight/pilight/libs/avrdude/avrbitbang.c deleted file mode 100644 index ee1afc8..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrbitbang.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean - * Copyright (C) 2005 Michael Holzt - * - * 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 of the License, 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 - */ -/* $Id: bitbang.c 898 2010-01-08 20:02:35Z joerg_wunsch $ */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "avrdude.h" -#include "avr.h" -#include "pindefs.h" -#include "pgm.h" - -#ifdef _WIN32 -struct itimerval { - struct timeval it_value, it_interval; -}; -#define SIGALRM 14 -#define ITIMER_REAL 0 -#endif - -static int delay_decrement; -static volatile int done; - -typedef void (*mysighandler_t)(int); -static mysighandler_t saved_alarmhandler; - -static void alarmhandler(int signo) -{ - done = 1; - signal(SIGALRM, saved_alarmhandler); -} - -/* - * Calibrate the microsecond delay loop below. - */ -static void bitbang_calibrate_delay(void) -{ - struct itimerval itv; - volatile int i; - - i = 0; - done = 0; - saved_alarmhandler = signal(SIGALRM, alarmhandler); - /* - * Set ITIMER_REAL to 100 ms. All known systems have a timer - * granularity of 10 ms or better, so counting the delay cycles - * accumulating over 100 ms should give us a rather realistic - * picture, without annoying the user by a lengthy startup time (as - * an alarm(1) would do). Of course, if heavy system activity - * happens just during calibration but stops before the remaining - * part of AVRDUDE runs, this will yield wrong values. There's not - * much we can do about this. - */ - itv.it_value.tv_sec = 0; - itv.it_value.tv_usec = 100000; - itv.it_interval.tv_sec = itv.it_interval.tv_usec = 0; -#ifndef _WIN32 - setitimer(ITIMER_REAL, &itv, 0); -#endif - while (!done) - i--; - itv.it_value.tv_sec = itv.it_value.tv_usec = 0; -#ifndef _WIN32 - setitimer(ITIMER_REAL, &itv, 0); -#endif - /* - * Calculate back from 100 ms to 1 us. - */ - delay_decrement = -i / 100000; -} - -/* - * Delay for approximately the number of microseconds specified. - * usleep()'s granularity is usually like 1 ms or 10 ms, so it's not - * really suitable for short delays in bit-bang algorithms. - */ -void bitbang_delay(int us) -{ - volatile int del = us * delay_decrement; - - while (del > 0) - del--; -} - -/* - * transmit and receive a byte of data to/from the AVR device - */ -static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte) -{ - int i; - unsigned char r, b, rbyte; - - rbyte = 0; - for (i=7; i>=0; i--) { - /* - * Write and read one bit on SPI. - * Some notes on timing: Let T be the time it takes to do - * one pgm->setpin()-call resp. par clrpin()-call, then - * - SCK is high for 2T - * - SCK is low for 2T - * - MOSI setuptime is 1T - * - MOSI holdtime is 3T - * - SCK low to MISO read is 2T to 3T - * So we are within programming specs (expect for AT90S1200), - * if and only if T>t_CLCL (t_CLCL=clock period of target system). - * - * Due to the delay introduced by "IN" and "OUT"-commands, - * T is greater than 1us (more like 2us) on x86-architectures. - * So programming works safely down to 1MHz target clock. - */ - - b = (byte >> i) & 0x01; - - /* set the data input line as desired */ - pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], b); - - pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 1); - - /* - * read the result bit (it is either valid from a previous falling - * edge or it is ignored in the current context) - */ - r = pgm->getpin(pgm, pgm->pinno[PIN_AVR_MISO]); - - pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0); - - rbyte |= r << i; - } - - return rbyte; -} - - -int bitbang_rdy_led(PROGRAMMER * pgm, int value) -{ - // pgm->setpin(pgm, pgm->pinno[PIN_LED_RDY], !value); - return 0; -} - -int bitbang_err_led(PROGRAMMER * pgm, int value) -{ - // pgm->setpin(pgm, pgm->pinno[PIN_LED_ERR], !value); - return 0; -} - -int bitbang_pgm_led(PROGRAMMER * pgm, int value) -{ - // pgm->setpin(pgm, pgm->pinno[PIN_LED_PGM], !value); - return 0; -} - -int bitbang_vfy_led(PROGRAMMER * pgm, int value) -{ - // pgm->setpin(pgm, pgm->pinno[PIN_LED_VFY], !value); - return 0; -} - - -/* - * transmit an AVR device command and return the results; 'cmd' and - * 'res' must point to at least a 4 byte data buffer - */ -int bitbang_cmd(PROGRAMMER * pgm, unsigned char cmd[4], - unsigned char res[4]) -{ - int i; - - for (i=0; i<4; i++) { - res[i] = bitbang_txrx(pgm, cmd[i]); - } - - return 0; -} - -/* - * transmit bytes via SPI and return the results; 'cmd' and - * 'res' must point to data buffers - */ -int bitbang_spi(PROGRAMMER * pgm, unsigned char cmd[], - unsigned char res[], int count) -{ - int i; - - pgm->setpin(pgm, pgm->pinno[PIN_LED_PGM], 0); - - for (i=0; isetpin(pgm, pgm->pinno[PIN_LED_PGM], 1); - - return 0; -} - - -/* - * issue the 'chip erase' command to the AVR device - */ -int bitbang_chip_erase(PROGRAMMER * pgm, AVRPART * p) -{ - unsigned char cmd[4]; - unsigned char res[4]; - - if (p->op[AVR_OP_CHIP_ERASE] == NULL) { - logprintf(LOG_ERR, "chip erase instruction not defined for part \"%s\"", p->desc); - return -1; - } - - pgm->pgm_led(pgm, ON); - - memset(cmd, 0, sizeof(cmd)); - - avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd); - pgm->cmd(pgm, cmd, res); - usleep(p->chip_erase_delay); - pgm->initialize(pgm, p); - - pgm->pgm_led(pgm, OFF); - - return 0; -} - -/* - * issue the 'program enable' command to the AVR device - */ -int bitbang_program_enable(PROGRAMMER * pgm, AVRPART * p) -{ - unsigned char cmd[4]; - unsigned char res[4]; - - if (p->op[AVR_OP_PGM_ENABLE] == NULL) { - logprintf(LOG_ERR, "program enable instruction not defined for part \"%s\"", p->desc); - return -1; - } - - memset(cmd, 0, sizeof(cmd)); - avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd); - pgm->cmd(pgm, cmd, res); - - if (res[2] != cmd[1]) - return -2; - - return 0; -} - -/* - * initialize the AVR device and prepare it to accept commands - */ -int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p) -{ - int rc; - int tries; - - bitbang_calibrate_delay(); - - pgm->powerup(pgm); - usleep(20000); - - pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0); - pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0); - usleep(20000); - - pgm->highpulsepin(pgm, pgm->pinno[PIN_AVR_RESET]); - - usleep(20000); /* 20 ms XXX should be a per-chip parameter */ - - /* - * Enable programming mode. If we are programming an AT90S1200, we - * can only issue the command and hope it worked. If we are using - * one of the other chips, the chip will echo 0x53 when issuing the - * third byte of the command. In this case, try up to 32 times in - * order to possibly get back into sync with the chip if we are out - * of sync. - */ - - if (strcmp(p->desc, "AT90S1200")==0) { - pgm->program_enable(pgm, p); - } - else { - tries = 0; - do { - rc = pgm->program_enable(pgm, p); - if ((rc == 0)||(rc == -1)) - break; - pgm->highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]); - tries++; - } while (tries < 65); - - /* - * can't sync with the device, maybe it's not attached? - */ - if (rc) { - logprintf(LOG_ERR, "AVR device not responding"); - return -1; - } - } - - return 0; -} - -static void verify_pin_assigned(PROGRAMMER * pgm, int pin, char * desc) -{ -} - - -/* - * Verify all prerequisites for a bit-bang programmer are present. - */ -void bitbang_check_prerequisites(PROGRAMMER *pgm) -{ - verify_pin_assigned(pgm, PIN_AVR_RESET, "AVR RESET"); - verify_pin_assigned(pgm, PIN_AVR_SCK, "AVR SCK"); - verify_pin_assigned(pgm, PIN_AVR_MISO, "AVR MISO"); - verify_pin_assigned(pgm, PIN_AVR_MOSI, "AVR MOSI"); -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrbitbang.h b/lib/ESPiLight/pilight/libs/avrdude/avrbitbang.h deleted file mode 100644 index 99197b3..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrbitbang.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean - * Copyright (C) 2005 Michael Holzt - * - * 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 of the License, 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 - */ -/* $Id: bitbang.h 797 2009-02-17 15:31:27Z joerg_wunsch $ */ - -#ifndef avrbitbang_h -#define avrbitbang_h - -#ifdef __cplusplus -extern "C" { -#endif - -int bitbang_setpin(int fd, int pin, int value); -int bitbang_getpin(int fd, int pin); -int bitbang_highpulsepin(int fd, int pin); -void bitbang_delay(unsigned int us); - -void bitbang_check_prerequisites(PROGRAMMER *pgm); - -int bitbang_rdy_led (PROGRAMMER * pgm, int value); -int bitbang_err_led (PROGRAMMER * pgm, int value); -int bitbang_pgm_led (PROGRAMMER * pgm, int value); -int bitbang_vfy_led (PROGRAMMER * pgm, int value); -int bitbang_cmd (PROGRAMMER * pgm, unsigned char cmd[4], - unsigned char res[4]); -int bitbang_spi (PROGRAMMER * pgm, unsigned char cmd[], - unsigned char res[], int count); -int bitbang_chip_erase (PROGRAMMER * pgm, AVRPART * p); -int bitbang_program_enable (PROGRAMMER * pgm, AVRPART * p); -void bitbang_powerup (PROGRAMMER * pgm); -void bitbang_powerdown (PROGRAMMER * pgm); -int bitbang_initialize (PROGRAMMER * pgm, AVRPART * p); -void bitbang_disable (PROGRAMMER * pgm); -void bitbang_enable (PROGRAMMER * pgm); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrconfig.c b/lib/ESPiLight/pilight/libs/avrdude/avrconfig.c deleted file mode 100644 index 4b72dff..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrconfig.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: config.c 725 2007-01-30 13:41:54Z joerg_wunsch $ */ - -#include -#include -#include -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "avrconfig.h" - -TOKEN * new_token(int primary) -{ - TOKEN * tkn; - - tkn = (TOKEN *)MALLOC(sizeof(TOKEN)); - if (tkn == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - memset(tkn, 0, sizeof(TOKEN)); - - tkn->primary = primary; - - return tkn; -} - -void free_token(TOKEN * tkn) -{ - if (tkn) { - switch (tkn->primary) { - case TKN_STRING: - case TKN_ID: - if (tkn->value.string) - FREE(tkn->value.string); - tkn->value.string = NULL; - break; - } - - FREE(tkn); - } -} - -TOKEN * number(char * text) -{ - struct token_t * tkn; - - tkn = new_token(TKN_NUMBER); - tkn->value.type = V_NUM; - tkn->value.number = atof(text); - - return tkn; -} - -TOKEN * hexnumber(char * text) -{ - struct token_t * tkn; - char * e; - - tkn = new_token(TKN_NUMBER); - tkn->value.type = V_NUM; - tkn->value.number = strtoul(text, &e, 16); - if ((e == text) || (*e != 0)) { - logprintf(LOG_ERR, "%s:%d: can't scan hex number \"%s\"", infile, lineno, text); - return NULL; - } - - return tkn; -} - -TOKEN * string(char * text) -{ - struct token_t * tkn; - int len; - - tkn = new_token(TKN_STRING); - - len = strlen(text); - - tkn->value.type = V_STR; - tkn->value.string = (char *) MALLOC(len+1); - if (tkn->value.string == NULL) { - fprintf(stderr, "out of memory\n"); - return NULL; - } - strcpy(tkn->value.string, text); - - return tkn; -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrconfig.h b/lib/ESPiLight/pilight/libs/avrdude/avrconfig.h deleted file mode 100644 index ad13d69..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrconfig.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: config.h 725 2007-01-30 13:41:54Z joerg_wunsch $ */ - -#ifndef avrconfig_h -#define avrconfig_h - -#include "avrpart.h" -#include "pindefs.h" -#include "avr.h" -#include "pgm.h" - -#define MAX_STR_CONST 1024 - -enum { V_NONE, V_NUM, V_STR }; -typedef struct value_t { - int type; - double number; - char * string; -} VALUE; - - -typedef struct token_t { - int primary; - VALUE value; -} TOKEN; -typedef struct token_t *token_p; - - -extern FILE * in; -extern PROGRAMMER * current_prog; -extern AVRPART * current_part; -extern AVRMEM * current_mem; -extern int lineno; -extern const char * infile; -extern char default_programmer[]; -extern char default_parallel[]; -extern char default_serial[]; - -enum tokentype { - K_READ = 258, - K_WRITE = 259, - K_READ_LO = 260, - K_READ_HI = 261, - K_WRITE_LO = 262, - K_WRITE_HI = 263, - K_LOADPAGE_LO = 264, - K_LOADPAGE_HI = 265, - K_LOAD_EXT_ADDR = 266, - K_WRITEPAGE = 267, - K_CHIP_ERASE = 268, - K_PGM_ENABLE = 269, - K_MEMORY = 270, - K_PAGE_SIZE = 271, - K_PAGED = 272, - K_ARDUINO = 273, - K_BAUDRATE = 274, - K_BS2 = 275, - K_BUFF = 276, - K_BUSPIRATE = 277, - K_CHIP_ERASE_DELAY = 278, - K_DEDICATED = 279, - K_DEFAULT_PARALLEL = 280, - K_DEFAULT_PROGRAMMER = 281, - K_DEFAULT_SERIAL = 282, - K_DESC = 283, - K_DEVICECODE = 284, - K_DRAGON_DW = 285, - K_DRAGON_HVSP = 286, - K_DRAGON_ISP = 287, - K_DRAGON_JTAG = 288, - K_DRAGON_PDI = 289, - K_DRAGON_PP = 290, - K_GPIO = 291, - K_STK500_DEVCODE = 292, - K_AVR910_DEVCODE = 293, - K_EEPROM = 294, - K_ERRLED = 295, - K_FLASH = 296, - K_ID = 297, - K_IO = 298, - K_JTAG_MKI = 299, - K_JTAG_MKII = 300, - K_JTAG_MKII_AVR32 = 301, - K_JTAG_MKII_DW = 302, - K_JTAG_MKII_ISP = 303, - K_JTAG_MKII_PDI = 304, - K_LOADPAGE = 305, - K_MAX_WRITE_DELAY = 306, - K_MIN_WRITE_DELAY = 307, - K_MISO = 308, - K_MOSI = 309, - K_NUM_PAGES = 310, - K_NVM_BASE = 311, - K_OFFSET = 312, - K_PAGEL = 313, - K_PAR = 314, - K_PARALLEL = 315, - K_PART = 316, - K_PGMLED = 317, - K_PROGRAMMER = 318, - K_PSEUDO = 319, - K_PWROFF_AFTER_WRITE = 320, - K_RDYLED = 321, - K_READBACK_P1 = 322, - K_READBACK_P2 = 323, - K_READMEM = 324, - K_RESET = 325, - K_RETRY_PULSE = 326, - K_SERBB = 327, - K_SERIAL = 328, - K_SCK = 329, - K_SIGNATURE = 330, - K_SIZE = 331, - K_STK500 = 332, - K_STK500HVSP = 333, - K_STK500PP = 334, - K_STK500V2 = 335, - K_STK500GENERIC = 336, - K_STK600 = 337, - K_STK600HVSP = 338, - K_STK600PP = 339, - K_AVR910 = 340, - K_USBASP = 341, - K_USBTINY = 342, - K_BUTTERFLY = 343, - K_TYPE = 344, - K_VCC = 345, - K_VFYLED = 346, - K_NO = 347, - K_YES = 348, - K_TIMEOUT = 349, - K_STABDELAY = 350, - K_CMDEXEDELAY = 351, - K_HVSPCMDEXEDELAY = 352, - K_SYNCHLOOPS = 353, - K_BYTEDELAY = 354, - K_POLLVALUE = 355, - K_POLLINDEX = 356, - K_PREDELAY = 357, - K_POSTDELAY = 358, - K_POLLMETHOD = 359, - K_MODE = 360, - K_DELAY = 361, - K_BLOCKSIZE = 362, - K_READSIZE = 363, - K_HVENTERSTABDELAY = 364, - K_PROGMODEDELAY = 365, - K_LATCHCYCLES = 366, - K_TOGGLEVTG = 367, - K_POWEROFFDELAY = 368, - K_RESETDELAYMS = 369, - K_RESETDELAYUS = 370, - K_HVLEAVESTABDELAY = 371, - K_RESETDELAY = 372, - K_SYNCHCYCLES = 373, - K_HVCMDEXEDELAY = 374, - K_CHIPERASEPULSEWIDTH = 375, - K_CHIPERASEPOLLTIMEOUT = 376, - K_CHIPERASETIME = 377, - K_PROGRAMFUSEPULSEWIDTH = 378, - K_PROGRAMFUSEPOLLTIMEOUT = 379, - K_PROGRAMLOCKPULSEWIDTH = 380, - K_PROGRAMLOCKPOLLTIMEOUT = 381, - K_PP_CONTROLSTACK = 382, - K_HVSP_CONTROLSTACK = 383, - K_ALLOWFULLPAGEBITSTREAM = 384, - K_ENABLEPAGEPROGRAMMING = 385, - K_HAS_JTAG = 386, - K_HAS_DW = 387, - K_HAS_PDI = 388, - K_HAS_TPI = 389, - K_IDR = 390, - K_IS_AVR32 = 391, - K_RAMPZ = 392, - K_SPMCR = 393, - K_EECR = 394, - K_FLASH_INSTR = 395, - K_EEPROM_INSTR = 396, - TKN_COMMA = 397, - TKN_EQUAL = 398, - TKN_SEMI = 399, - TKN_TILDE = 400, - TKN_NUMBER = 401, - TKN_STRING = 402, - TKN_ID = 403 -}; - -char default_programmer[MAX_STR_CONST]; -char default_parallel[4096]; -char default_serial[4096]; - -char string_buf[MAX_STR_CONST]; -char *string_buf_ptr; - -PROGRAMMER * current_prog; -AVRPART * current_part; - -int lineno; -const char * infile; -extern char string_buf[MAX_STR_CONST]; -extern char *string_buf_ptr; - -#ifdef __cplusplus -extern "C" { -#endif - -int init_config(void); -TOKEN * new_token(int primary); -void free_token(TOKEN * tkn); -void free_tokens(int n, ...); -TOKEN * number(char * text); -TOKEN * hexnumber(char * text); -TOKEN * string(char * text); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrdude.h b/lib/ESPiLight/pilight/libs/avrdude/avrdude.h deleted file mode 100644 index 2cbaec2..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrdude.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2007 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: avrdude.h 788 2008-11-19 23:32:30Z joerg_wunsch $ */ - -#ifndef avrdude_h -#define avrdude_h - -extern char * progname; /* name of program, for messages */ - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrgpio.c b/lib/ESPiLight/pilight/libs/avrdude/avrgpio.c deleted file mode 100644 index d732dc2..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrgpio.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Support for bitbanging GPIO pins using the /sys/class/gpio interface - * - * Copyright (C) 2010 Radoslav Kolev - * - * 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 of the License, 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 - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "avrdude.h" -#include "avr.h" -#include "pindefs.h" -#include "pgm.h" -#include "avrbitbang.h" -#include "defines.h" -#include "../pilight/core/log.h" -#include "../pilight/config/settings.h" - -/* - * GPIO user space helpers - * - * Copyright 2009 Analog Devices Inc. - * Michael Hennerich (hennerich@blackfin.uclinux.org) - * - * Licensed under the GPL-2 or later - */ - -#define GPIO_DIR_IN 0 -#define GPIO_DIR_OUT 1 -#define N_GPIO 256 - -/* -* an array which holds open FDs to /sys/class/gpio/gpioXX/value for all needed pins -*/ -static int gpio_fds[N_GPIO]; - -static int gpio_setpin(PROGRAMMER * pgm, int pin, int value) { - if(gpio_fds[pin] != PINMODE_OUTPUT) { - return -1; - } - - /* Small delay for too fast computers */ - delayMicroseconds(1); - - if(value == 1) { - digitalWrite(pin, HIGH); - } else { - digitalWrite(pin, LOW); - } - - if(pgm->ispdelay > 1) { - bitbang_delay(pgm->ispdelay); - } - - return 0; -} - -static int gpio_getpin(PROGRAMMER * pgm, int pin) { - if(gpio_fds[pin] == PINMODE_INPUT) { - return digitalRead(pin); - } else { - return -1; - } -} - -static int gpio_highpulsepin(PROGRAMMER * pgm, int pin) { - - if(gpio_fds[pin] == PINMODE_OUTPUT) { - digitalWrite(pin, HIGH); - digitalWrite(pin, LOW); - return 0; - } else { - return -1; - } -} - -static void gpio_display(PROGRAMMER *pgm, const char *p) { - /* MAYBE */ -} - -static void gpio_enable(PROGRAMMER *pgm) { - /* nothing */ -} - -static void gpio_disable(PROGRAMMER *pgm) { - /* nothing */ -} - -static void gpio_powerup(PROGRAMMER *pgm) { - /* nothing */ -} - -static void gpio_powerdown(PROGRAMMER *pgm) { - /* nothing */ -} - -static int gpio_open(PROGRAMMER *pgm, char *port) { - int i = 0; - - bitbang_check_prerequisites(pgm); - - for(i=0;ipinno[i] != 0) { - if(i == PIN_AVR_MISO) { - gpio_fds[pgm->pinno[i]] = PINMODE_INPUT; - pinMode(pgm->pinno[i], PINMODE_INPUT); - } else { - gpio_fds[pgm->pinno[i]] = PINMODE_OUTPUT;; - pinMode(pgm->pinno[i], PINMODE_OUTPUT); - } - } - } - - return(0); -} - -static void gpio_close(PROGRAMMER *pgm) { - if(gpio_fds[pgm->pinno[PIN_AVR_RESET]] == PINMODE_OUTPUT) { - digitalWrite(pgm->pinno[PIN_AVR_RESET], HIGH); - // digitalWrite(pgm->pinno[PIN_AVR_RESET], LOW); - } - - return; -} - -void gpio_initpgm(PROGRAMMER *pgm) -{ - strcpy(pgm->type, "GPIO"); - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "gpio_switch: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) < 0) { - exit(EXIT_FAILURE); - } - pgm->rdy_led = bitbang_rdy_led; - pgm->err_led = bitbang_err_led; - pgm->pgm_led = bitbang_pgm_led; - pgm->vfy_led = bitbang_vfy_led; - pgm->initialize = bitbang_initialize; - pgm->display = gpio_display; - pgm->enable = gpio_enable; - pgm->disable = gpio_disable; - pgm->powerup = gpio_powerup; - pgm->powerdown = gpio_powerdown; - pgm->program_enable = bitbang_program_enable; - pgm->chip_erase = bitbang_chip_erase; - pgm->cmd = bitbang_cmd; - pgm->open = gpio_open; - pgm->close = gpio_close; - pgm->setpin = gpio_setpin; - pgm->getpin = gpio_getpin; - pgm->highpulsepin = gpio_highpulsepin; - pgm->read_byte = avr_read_byte_default; - pgm->write_byte = avr_write_byte_default; -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrgpio.h b/lib/ESPiLight/pilight/libs/avrdude/avrgpio.h deleted file mode 100644 index 45868b4..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrgpio.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: par.h 722 2007-01-24 22:43:46Z joerg_wunsch $ */ - -#ifndef avrgpio_h -#define avrgpio_h - -#ifdef __cplusplus -extern "C" { -#endif - -void gpio_initpgm (PROGRAMMER * pgm); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrpart.c b/lib/ESPiLight/pilight/libs/avrdude/avrpart.c deleted file mode 100644 index 675b972..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrpart.c +++ /dev/null @@ -1,251 +0,0 @@ - -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * Copyright (C) 2006 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: avrpart.c 772 2008-06-07 21:03:41Z joerg_wunsch $ */ - -#include -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "avrdude.h" -#include "avrpart.h" -#include "pindefs.h" - -/*** - *** Elementary functions dealing with OPCODE structures - ***/ - -OPCODE * avr_new_opcode(void) -{ - OPCODE * m; - - m = (OPCODE *)MALLOC(sizeof(*m)); - if (m == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - memset(m, 0, sizeof(*m)); - - return m; -} - - -/* - * avr_set_bits() - * - * Set instruction bits in the specified command based on the opcode. - */ -int avr_set_bits(OPCODE * op, unsigned char * cmd) -{ - int i, j, bit; - unsigned char mask; - - for (i=0; i<32; i++) { - if (op->bit[i].type == AVR_CMDBIT_VALUE) { - j = 3 - i / 8; - bit = i % 8; - mask = 1 << bit; - if (op->bit[i].value) - cmd[j] = cmd[j] | mask; - else - cmd[j] = cmd[j] & ~mask; - } - } - - return 0; -} - - -/* - * avr_set_addr() - * - * Set address bits in the specified command based on the opcode, and - * the address. - */ -int avr_set_addr(OPCODE * op, unsigned char * cmd, unsigned long addr) -{ - int i, j, bit; - unsigned long value; - unsigned char mask; - - for (i=0; i<32; i++) { - if (op->bit[i].type == AVR_CMDBIT_ADDRESS) { - j = 3 - i / 8; - bit = i % 8; - mask = 1 << bit; - value = addr >> op->bit[i].bitno & 0x01; - if (value) - cmd[j] = cmd[j] | mask; - else - cmd[j] = cmd[j] & ~mask; - } - } - - return 0; -} - - -/* - * avr_set_input() - * - * Set input data bits in the specified command based on the opcode, - * and the data byte. - */ -int avr_set_input(OPCODE * op, unsigned char * cmd, unsigned char data) -{ - int i, j, bit; - unsigned char value; - unsigned char mask; - - for (i=0; i<32; i++) { - if (op->bit[i].type == AVR_CMDBIT_INPUT) { - j = 3 - i / 8; - bit = i % 8; - mask = 1 << bit; - value = data >> op->bit[i].bitno & 0x01; - if (value) - cmd[j] = cmd[j] | mask; - else - cmd[j] = cmd[j] & ~mask; - } - } - - return 0; -} - - -/* - * avr_get_output() - * - * Retreive output data bits from the command results based on the - * opcode data. - */ -int avr_get_output(OPCODE * op, unsigned char * res, unsigned char * data) -{ - int i, j, bit; - unsigned char value; - unsigned char mask; - - for (i=0; i<32; i++) { - if (op->bit[i].type == AVR_CMDBIT_OUTPUT) { - j = 3 - i / 8; - bit = i % 8; - mask = 1 << bit; - value = ((res[j] & mask) >> bit) & 0x01; - value = value << op->bit[i].bitno; - if (value) - *data = *data | value; - else - *data = *data & ~value; - } - } - - return 0; -} - -/*** - *** Elementary functions dealing with AVRMEM structures - ***/ - -AVRMEM * avr_new_memtype(void) -{ - AVRMEM * m; - - m = (AVRMEM *)MALLOC(sizeof(*m)); - if (m == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - memset(m, 0, sizeof(*m)); - - return m; -} - - -AVRMEM * avr_dup_mem(AVRMEM * m) -{ - AVRMEM * n; - - n = avr_new_memtype(); - - *n = *m; - - n->buf = (unsigned char *)MALLOC(n->size); - if (n->buf == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(n->buf, 0, n->size); - - memcpy(n->tags, m->tags, n->size); - - return n; -} - -/* - * Elementary functions dealing with AVRPART structures - */ - - -AVRPART * avr_new_part(void) -{ - AVRPART * p; - - p = (AVRPART *)MALLOC(sizeof(AVRPART)); - if (p == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - memset(p, 0, sizeof(*p)); - - p->id[0] = 0; - p->desc[0] = 0; - p->reset_disposition = RESET_DEDICATED; - p->retry_pulse = PIN_AVR_SCK; - p->flags = AVRPART_SERIALOK | AVRPART_PARALLELOK | AVRPART_ENABLEPAGEPROGRAMMING; - p->lineno = 0; - memset(p->signature, 0xFF, 3); - p->ctl_stack_type = CTL_STACK_NONE; - - return p; -} - - -AVRPART * avr_dup_part(AVRPART * d) -{ - AVRPART * p; - - p = avr_new_part(); - *p = *d; - - /* NEW */ - p->sigmem = avr_dup_mem(p->sigmem); - p->flashmem = avr_dup_mem(p->flashmem); - p->lfusemem = avr_dup_mem(p->lfusemem); - p->hfusemem = avr_dup_mem(p->hfusemem); - - return p; -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrpart.h b/lib/ESPiLight/pilight/libs/avrdude/avrpart.h deleted file mode 100644 index 906e3cb..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrpart.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Brian S. Dean - * Copyright (C) 2006 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: avrpart.h 916 2010-01-15 16:36:13Z joerg_wunsch $ */ - -#ifndef avrpart_h -#define avrpart_h - -#include - -/* - * AVR serial programming instructions - */ -enum { - AVR_OP_READ, - AVR_OP_WRITE, - AVR_OP_READ_LO, - AVR_OP_READ_HI, - AVR_OP_WRITE_LO, - AVR_OP_WRITE_HI, - AVR_OP_LOADPAGE_LO, - AVR_OP_LOADPAGE_HI, - AVR_OP_LOAD_EXT_ADDR, - AVR_OP_WRITEPAGE, - AVR_OP_CHIP_ERASE, - AVR_OP_PGM_ENABLE, - AVR_OP_MAX -}; - - -enum { - AVR_CMDBIT_IGNORE, /* bit is ignored on input and output */ - AVR_CMDBIT_VALUE, /* bit is set to 0 or 1 for input or output */ - AVR_CMDBIT_ADDRESS, /* this bit represents an input address bit */ - AVR_CMDBIT_INPUT, /* this bit is an input bit */ - AVR_CMDBIT_OUTPUT /* this bit is an output bit */ -}; - -enum { /* these are assigned to reset_disposition of AVRPART */ - RESET_DEDICATED, /* reset pin is dedicated */ - RESET_IO /* reset pin might be configured as an I/O pin */ -}; - -enum ctl_stack_t { - CTL_STACK_NONE, /* no control stack defined */ - CTL_STACK_PP, /* parallel programming control stack */ - CTL_STACK_HVSP /* high voltage serial programming control stack */ -}; - -/* - * serial programming instruction bit specifications - */ -typedef struct cmdbit { - int type; /* AVR_CMDBIT_* */ - int bitno; /* which input bit to use for this command bit */ - int value; /* bit value if type == AVR_CMDBIT_VALUD */ -} CMDBIT; - -typedef struct opcode { - CMDBIT bit[32]; /* opcode bit specs */ -} OPCODE; - - -#define AVRPART_SERIALOK 0x0001 /* part supports serial programming */ -#define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */ -#define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */ -#define AVRPART_HAS_JTAG 0x0008 /* part has a JTAG i/f */ -#define AVRPART_ALLOWFULLPAGEBITSTREAM 0x0010 /* JTAG ICE mkII param. */ -#define AVRPART_ENABLEPAGEPROGRAMMING 0x0020 /* JTAG ICE mkII param. */ -#define AVRPART_HAS_DW 0x0040 /* part has a debugWire i/f */ -#define AVRPART_HAS_PDI 0x0080 /* part has PDI i/f rather than ISP (ATxmega) */ -#define AVRPART_AVR32 0x0100 /* part is in AVR32 family */ -#define AVRPART_INIT_SMC 0x0200 /* part will undergo chip erase */ -#define AVRPART_WRITE 0x0400 /* at least one write operation specified */ -#define AVRPART_HAS_TPI 0x0800 /* part has TPI i/f rather than ISP (ATtiny4/5/9/10) */ - -#define AVR_DESCLEN 64 -#define AVR_IDLEN 32 -#define CTL_STACK_SIZE 32 -#define FLASH_INSTR_SIZE 3 -#define EEPROM_INSTR_SIZE 20 - -#define TAG_ALLOCATED 1 /* memory byte is allocated */ - -#define AVR_MEMDESCLEN 64 -typedef struct avrmem { - char desc[AVR_MEMDESCLEN]; /* memory description ("flash", "eeprom", etc) */ - int paged; /* page addressed (e.g. ATmega flash) */ - int size; /* total memory size in bytes */ - int page_size; /* size of memory page (if page addressed) */ - int num_pages; /* number of pages (if page addressed) */ - unsigned int offset; /* offset in IO memory (ATxmega) */ - int min_write_delay; /* microseconds */ - int max_write_delay; /* microseconds */ - int pwroff_after_write; /* after this memory type is written to, - the device must be powered off and - back on, see errata - http://www.atmel.com/atmel/acrobat/doc1280.pdf */ - unsigned char readback[2]; /* polled read-back values */ - - int mode; /* stk500 v2 xml file parameter */ - int delay; /* stk500 v2 xml file parameter */ - int blocksize; /* stk500 v2 xml file parameter */ - int readsize; /* stk500 v2 xml file parameter */ - int pollindex; /* stk500 v2 xml file parameter */ - - unsigned char * buf; /* pointer to memory buffer */ - unsigned char tags[1024*1024]; /* allocation tags */ - OPCODE * op[AVR_OP_MAX]; /* opcodes */ -} AVRMEM; - -typedef struct avrpart { - char desc[AVR_DESCLEN]; /* long part name */ - char id[AVR_IDLEN]; /* short part name */ - int stk500_devcode; /* stk500 device code */ - int avr910_devcode; /* avr910 device code */ - int chip_erase_delay; /* microseconds */ - unsigned char pagel; /* for parallel programming */ - unsigned char bs2; /* for parallel programming */ - unsigned char signature[3]; /* expected value of signature bytes */ - int reset_disposition; /* see RESET_ enums */ - int retry_pulse; /* retry program enable by pulsing - this pin (PIN_AVR_*) */ - unsigned flags; /* see AVRPART_ masks */ - - int timeout; /* stk500 v2 xml file parameter */ - int stabdelay; /* stk500 v2 xml file parameter */ - int cmdexedelay; /* stk500 v2 xml file parameter */ - int synchloops; /* stk500 v2 xml file parameter */ - int bytedelay; /* stk500 v2 xml file parameter */ - int pollindex; /* stk500 v2 xml file parameter */ - unsigned char pollvalue; /* stk500 v2 xml file parameter */ - int predelay; /* stk500 v2 xml file parameter */ - int postdelay; /* stk500 v2 xml file parameter */ - int pollmethod; /* stk500 v2 xml file parameter */ - - enum ctl_stack_t ctl_stack_type; /* what to use the ctl stack for */ - unsigned char controlstack[CTL_STACK_SIZE]; /* stk500v2 PP/HVSP ctl stack */ - unsigned char flash_instr[FLASH_INSTR_SIZE]; /* flash instructions (debugWire, JTAG) */ - unsigned char eeprom_instr[EEPROM_INSTR_SIZE]; /* EEPROM instructions (debugWire, JTAG) */ - - int hventerstabdelay; /* stk500 v2 hv mode parameter */ - int progmodedelay; /* stk500 v2 hv mode parameter */ - int latchcycles; /* stk500 v2 hv mode parameter */ - int togglevtg; /* stk500 v2 hv mode parameter */ - int poweroffdelay; /* stk500 v2 hv mode parameter */ - int resetdelayms; /* stk500 v2 hv mode parameter */ - int resetdelayus; /* stk500 v2 hv mode parameter */ - int hvleavestabdelay; /* stk500 v2 hv mode parameter */ - int resetdelay; /* stk500 v2 hv mode parameter */ - int chiperasepulsewidth; /* stk500 v2 hv mode parameter */ - int chiperasepolltimeout; /* stk500 v2 hv mode parameter */ - int chiperasetime; /* stk500 v2 hv mode parameter */ - int programfusepulsewidth; /* stk500 v2 hv mode parameter */ - int programfusepolltimeout; /* stk500 v2 hv mode parameter */ - int programlockpulsewidth; /* stk500 v2 hv mode parameter */ - int programlockpolltimeout; /* stk500 v2 hv mode parameter */ - int synchcycles; /* stk500 v2 hv mode parameter */ - int hvspcmdexedelay; /* stk500 v2 xml file parameter */ - - unsigned char idr; /* JTAG ICE mkII XML file parameter */ - unsigned char rampz; /* JTAG ICE mkII XML file parameter */ - unsigned char spmcr; /* JTAG ICE mkII XML file parameter */ - unsigned short eecr; /* JTAC ICE mkII XML file parameter */ - unsigned int nvm_base; /* Base address of NVM controller in ATxmega devices */ - - OPCODE * op[AVR_OP_MAX]; /* opcodes */ - - AVRMEM *sigmem; - AVRMEM *flashmem; - AVRMEM *lfusemem; - AVRMEM *hfusemem; - AVRMEM *fusesmem; - AVRMEM *lockmem; - char config_file[4096]; /* config file where defined */ - int lineno; /* config file line number */ -} AVRPART; - -#ifdef __cplusplus -extern "C" { -#endif - -/* Functions for OPCODE structures */ -OPCODE * avr_new_opcode(void); -int avr_set_bits(OPCODE * op, unsigned char * cmd); -int avr_set_addr(OPCODE * op, unsigned char * cmd, unsigned long addr); -int avr_set_input(OPCODE * op, unsigned char * cmd, unsigned char data); -int avr_get_output(OPCODE * op, unsigned char * res, unsigned char * data); - -/* Functions for AVRMEM structures */ -AVRMEM * avr_new_memtype(void); -int avr_initmem(AVRPART * p); -AVRMEM * avr_dup_mem(AVRMEM * m); -AVRMEM * avr_locate_mem(AVRPART * p, char * desc); - -/* Functions for AVRPART structures */ -AVRPART * avr_new_part(void); -AVRPART * avr_dup_part(AVRPART * d); -typedef void (*walk_avrparts_cb)(const char *name, const char *desc, - const char *cfgname, int cfglineno, - void *cookie); - -#ifdef __cplusplus -} -#endif - -#endif /* avrpart_h */ diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrupd.c b/lib/ESPiLight/pilight/libs/avrdude/avrupd.c deleted file mode 100644 index 5a74af4..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrupd.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2005 Brian S. Dean - * Copyright (C) 2007 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: AVRUPD.c 819 2009-04-28 18:35:14Z joerg_wunsch $ */ - -#include -#include -#include -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "avrdude.h" -#include "avr.h" -#include "avrconfig.h" -#include "fileio.h" -#include "avrupd.h" - -AVRUPD * parse_op(char * s) -{ - char buf[1024]; - char * p, * cp, c; - AVRUPD * upd; - int i; - size_t fnlen; - - upd = (AVRUPD *)MALLOC(sizeof(AVRUPD)); - if (upd == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - i = 0; - p = s; - while ((i < (sizeof(buf)-1) && *p && (*p != ':'))) - buf[i++] = *p++; - buf[i] = 0; - - if (*p != ':') { - upd->memtype = (char *)MALLOC(strlen("flash")+1); - if (upd->memtype == NULL) { - outofmem: - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(upd->memtype, "flash"); - upd->op = DEVICE_WRITE; - upd->filename = (char *)MALLOC(strlen(buf) + 1); - if (upd->filename == NULL) - goto outofmem; - strcpy(upd->filename, buf); - upd->format = FMT_AUTO; - return upd; - } - - upd->memtype = (char *)MALLOC(strlen(buf)+1); - if (upd->memtype == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(upd->memtype, buf); - - p++; - if (*p == 'r') { - upd->op = DEVICE_READ; - } - else if (*p == 'w') { - upd->op = DEVICE_WRITE; - } - else if (*p == 'v') { - upd->op = DEVICE_VERIFY; - } - else { - logprintf(LOG_ERR, "invalid I/O mode '%c' in update specification", *p); - logprintf(LOG_ERR, - " allowed values are:\n" - " r = read device\n" - " w = write device\n" - " v = verify device"); - FREE(upd->memtype); - FREE(upd); - return NULL; - } - - p++; - - if (*p != ':') { - logprintf(LOG_ERR, "invalid update specification"); - FREE(upd->memtype); - FREE(upd); - return NULL; - } - - p++; - - /* - * Now, parse the filename component. Instead of looking for the - * leftmost possible colon delimiter, we look for the rightmost one. - * If we found one, we do have a trailing :format specifier, and - * process it. Otherwise, the remainder of the string is our file - * name component. That way, the file name itself is allowed to - * contain a colon itself (e. g. C:/some/file.hex), except the - * optional format specifier becomes mandatory then. - */ - cp = p; - p = strrchr(cp, ':'); - if (p == NULL) { - upd->format = FMT_AUTO; - fnlen = strlen(cp); - upd->filename = (char *)MALLOC(fnlen + 1); - } else { - fnlen = p - cp; - upd->filename = (char *)MALLOC(fnlen +1); - c = *++p; - if (c && p[1]) - /* More than one char - force failure below. */ - c = '?'; - switch (c) { - case 'a': upd->format = FMT_AUTO; break; - case 's': upd->format = FMT_SREC; break; - case 'i': upd->format = FMT_IHEX; break; - case 'r': upd->format = FMT_RBIN; break; - case 'm': upd->format = FMT_IMM; break; - case 'b': upd->format = FMT_BIN; break; - case 'd': upd->format = FMT_DEC; break; - case 'h': upd->format = FMT_HEX; break; - case 'o': upd->format = FMT_OCT; break; - default: - logprintf(LOG_ERR, "invalid file format '%s' in update specifier", p); - FREE(upd->memtype); - FREE(upd); - return NULL; - } - } - - if (upd->filename == NULL) { - fprintf(stderr, "out of memory\n"); - FREE(upd->memtype); - FREE(upd); - return NULL; - } - memcpy(upd->filename, cp, fnlen); - upd->filename[fnlen] = 0; - - return upd; -} - -AVRUPD * dup_AVRUPD(AVRUPD * upd) -{ - AVRUPD * u; - - u = (AVRUPD *)MALLOC(sizeof(AVRUPD)); - if(u == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - memcpy(u, upd, sizeof(AVRUPD)); - - if((u->memtype = MALLOC(strlen(upd->memtype)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(u->memtype, upd->memtype); - if((u->filename = MALLOC(strlen(upd->filename)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(u->filename, upd->filename); - - return u; -} - -AVRUPD * new_AVRUPD(int op, char * memtype, int filefmt, char * filename) -{ - AVRUPD * u; - - u = (AVRUPD *)MALLOC(sizeof(AVRUPD)); - if (u == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - u->memtype = MALLOC(strlen(memtype)+1); - strcpy(u->memtype, memtype); - u->filename = MALLOC(strlen(filename)+1); - strcpy(u->filename, filename); - u->op = op; - u->format = filefmt; - - return u; -} - -int do_op(PROGRAMMER * pgm, struct avrpart * p, AVRUPD * upd, int nowrite, - int verify) -{ - struct avrpart * v; - AVRMEM * mem = NULL; - int size, vsize; - int rc; - - /* NEW */ - if(strcmp(upd->memtype, "flash") == 0) { - mem = p->flashmem; - } else if(strcmp(upd->memtype, "lfuse") == 0) { - mem = p->lfusemem; - } else if(strcmp(upd->memtype, "hfuse") == 0) { - mem = p->hfusemem; - } - - if (mem == NULL) { - logprintf(LOG_ERR, "\"%s\" memory type not defined for part \"%s\"", upd->memtype, p->desc); - return -1; - } - - if (upd->op == DEVICE_READ) { - /* - * read out the specified device memory and write it to a file - */ - - report_progress(0,1,"Reading"); - rc = avr_read(pgm, p, upd->memtype, 0); - if (rc < 0) { - logprintf(LOG_ERR, "failed to read all of %s memory, rc=%d", mem->desc, rc); - return -1; - } - report_progress(1,1,NULL); - size = rc; - - logprintf(LOG_INFO, - "writing output file \"%s\"", - strcmp(upd->filename, "-")==0 ? "" : upd->filename); - - rc = fileio(FIO_WRITE, upd->filename, upd->format, p, upd->memtype, size); - if (rc < 0) { - logprintf(LOG_ERR, "write to file '%s' failed", upd->filename); - return -1; - } - } - else if (upd->op == DEVICE_WRITE) { - /* - * write the selected device memory using data from a file; first - * read the data from the specified file - */ - - logprintf(LOG_INFO, - "reading input file \"%s\"", - strcmp(upd->filename, "-")==0 ? "" : upd->filename); - - rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1); - if (rc < 0) { - logprintf(LOG_INFO, "write to file '%s' failed", upd->filename); - return -1; - } - size = rc; - - /* - * write the buffer contents to the selected memory type - */ - logprintf(LOG_INFO, "writing %s (%d bytes)", mem->desc, size); - - if (!nowrite) { - report_progress(0,1,"Writing"); - rc = avr_write(pgm, p, upd->memtype, size); - report_progress(1,1,NULL); - } - else { - /* - * test mode, don't actually write to the chip, output the buffer - * to stdout in intel hex instead - */ - rc = fileio(FIO_WRITE, "-", FMT_IHEX, p, upd->memtype, size); - } - - if (rc < 0) { - logprintf(LOG_ERR, "failed to write %s memory, rc=%d", mem->desc, rc); - return -1; - } - - vsize = rc; - - logprintf(LOG_INFO, "%d bytes of %s written", vsize, mem->desc); - - } - else if (upd->op == DEVICE_VERIFY) { - /* - * verify that the in memory file (p->mem[AVR_M_FLASH|AVR_M_EEPROM]) - * is the same as what is on the chip - */ - v = avr_dup_part(p); - - logprintf(LOG_INFO, "verifying %s memory against %s:", mem->desc, upd->filename); - logprintf(LOG_INFO, "load data %s data from input file %s:", mem->desc, upd->filename); - - rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1); - if (rc < 0) { - logprintf(LOG_ERR, "read from file '%s' failed", upd->filename); - return -1; - } - size = rc; - - logprintf(LOG_INFO, "input file %s contains %d bytes", upd->filename, size); - - report_progress (0,1,"Reading"); - rc = avr_read(pgm, v, upd->memtype, size); - if (rc < 0) { - logprintf(LOG_ERR, "failed to read all of %s memory, rc=%d", mem->desc, rc); - return -1; - } - report_progress (1,1,NULL); - - logprintf(LOG_INFO, "verifying ..."); - - rc = avr_verify(p, v, upd->memtype, size); - if (rc < 0) { - logprintf(LOG_ERR, "verification error; content mismatch"); - return -1; - } - - logprintf(LOG_INFO, "%d bytes of %s verified", rc, mem->desc); - - FREE(v->sigmem->buf); - FREE(v->sigmem); - FREE(v->flashmem->buf); - FREE(v->flashmem); - FREE(v->hfusemem->buf); - FREE(v->hfusemem); - FREE(v->lfusemem->buf); - FREE(v->lfusemem); - FREE(v); - } - else { - logprintf(LOG_ERR, "invalid update operation (%d) requested", upd->op); - return -1; - } - - return 0; -} - diff --git a/lib/ESPiLight/pilight/libs/avrdude/avrupd.h b/lib/ESPiLight/pilight/libs/avrdude/avrupd.h deleted file mode 100644 index 2640d97..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/avrupd.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2005 Brian S. Dean - * Copyright (C) 2007 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: AVRUPD.h 722 2007-01-24 22:43:46Z joerg_wunsch $ */ - -#ifndef avrupd_h -#define avrupd_h - -enum { - DEVICE_READ, - DEVICE_WRITE, - DEVICE_VERIFY -}; - -typedef struct { - char * memtype; - int op; - char * filename; - int format; -} AVRUPD; - -#ifdef __cplusplus -extern "C" { -#endif - -AVRUPD * parse_op(char * s); -AVRUPD * dup_AVRUPD(AVRUPD * upd); -AVRUPD * new_AVRUPD(int op, char * memtype, int filefmt, char * filename); -int do_op(PROGRAMMER * pgm, struct avrpart * p, AVRUPD * upd, int nowrite, int verify); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/fileio.c b/lib/ESPiLight/pilight/libs/avrdude/fileio.c deleted file mode 100644 index c83e818..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/fileio.c +++ /dev/null @@ -1,544 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: fileio.c 929 2010-01-18 20:40:15Z joerg_wunsch $ */ - -#include -#include -#include -#include -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "../pilight/core/common.h" -#include "avrdude.h" -#include "avr.h" -#include "fileio.h" - -#define IHEX_MAXDATA 256 -#define MAX_LINE_LEN 256 /* max line length for ASCII format input files */ - -struct ihexrec { - unsigned char reclen; - unsigned int loadofs; - unsigned char rectyp; - unsigned char data[IHEX_MAXDATA]; - unsigned char cksum; -}; - -static int b2ihex(unsigned char * inbuf, int bufsize, - int recsize, int startaddr, - char * outfile, FILE * outf) -{ - unsigned char * buf; - unsigned int nextaddr; - int n, nbytes, n_64k; - int i; - unsigned char cksum; - - if (recsize > 255) { - logprintf(LOG_ERR, "recsize=%d, must be < 256", recsize); - return -1; - } - - n_64k = 0; - nextaddr = startaddr; - buf = inbuf; - nbytes = 0; - - while (bufsize) { - n = recsize; - if (n > bufsize) - n = bufsize; - - if ((nextaddr + n) > 0x10000) - n = 0x10000 - nextaddr; - - if (n) { - cksum = 0; - fprintf(outf, ":%02X%04X00", n, nextaddr); - cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff); - for (i=0; i= 0x10000) { - int lo, hi; - /* output an extended address record */ - n_64k++; - lo = n_64k & 0xff; - hi = (n_64k >> 8) & 0xff; - cksum = 0; - fprintf(outf, ":02000004%02X%02X", hi, lo); - cksum += 2 + 0 + 4 + hi + lo; - cksum = -cksum; - fprintf(outf, "%02X\n", cksum); - nextaddr = 0; - } - - /* advance to next 'recsize' bytes */ - buf += n; - bufsize -= n; - } - - /*----------------------------------------------------------------- - add the end of record data line - -----------------------------------------------------------------*/ - cksum = 0; - n = 0; - nextaddr = 0; - fprintf(outf, ":%02X%04X01", n, nextaddr); - cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff) + 1; - cksum = -cksum; - fprintf(outf, "%02X\n", cksum); - - return nbytes; -} - - -static int ihex_readrec(struct ihexrec * ihex, char * rec) -{ - int i, j; - char buf[8]; - int offset, len; - char * e; - unsigned char cksum; - int rc; - - len = strlen(rec); - offset = 1; - cksum = 0; - - /* reclen */ - if (offset + 2 > len) - return -1; - for (i=0; i<2; i++) - buf[i] = rec[offset++]; - buf[i] = 0; - ihex->reclen = strtoul(buf, &e, 16); - if (e == buf || *e != 0) - return -1; - - /* load offset */ - if (offset + 4 > len) - return -1; - for (i=0; i<4; i++) - buf[i] = rec[offset++]; - buf[i] = 0; - ihex->loadofs = strtoul(buf, &e, 16); - if (e == buf || *e != 0) - return -1; - - /* record type */ - if (offset + 2 > len) - return -1; - for (i=0; i<2; i++) - buf[i] = rec[offset++]; - buf[i] = 0; - ihex->rectyp = strtoul(buf, &e, 16); - if (e == buf || *e != 0) - return -1; - - cksum = ihex->reclen + ((ihex->loadofs >> 8) & 0x0ff) + (ihex->loadofs & 0x0ff) + ihex->rectyp; - - /* data */ - for (j=0; jreclen; j++) { - if (offset + 2 > len) - return -1; - for (i=0; i<2; i++) - buf[i] = rec[offset++]; - buf[i] = 0; - ihex->data[j] = strtoul(buf, &e, 16); - if (e == buf || *e != 0) - return -1; - cksum += ihex->data[j]; - } - - /* cksum */ - if (offset + 2 > len) - return -1; - for (i=0; i<2; i++) - buf[i] = rec[offset++]; - buf[i] = 0; - ihex->cksum = strtoul(buf, &e, 16); - if (e == buf || *e != 0) - return -1; - - rc = -cksum & 0x000000ff; - - return rc; -} - - - -/* - * Intel Hex to binary buffer - * - * Given an open file 'inf' which contains Intel Hex formated data, - * parse the file and lay it out within the memory buffer pointed to - * by outbuf. The size of outbuf, 'bufsize' is honored; if data would - * fall outsize of the memory buffer outbuf, an error is generated. - * - * Return the maximum memory address within 'outbuf' that was written. - * If an error occurs, return -1. - * - * */ -static int ihex2b(char * infile, FILE * inf, - unsigned char * outbuf, int bufsize) -{ - char buffer [ MAX_LINE_LEN ]; - unsigned char * buf; - unsigned int nextaddr, baseaddr, maxaddr, offsetaddr; - int i; - int lineno; - int len; - struct ihexrec ihex; - int rc; - - lineno = 0; - buf = outbuf; - baseaddr = 0; - maxaddr = 0; - offsetaddr = 0; - nextaddr = 0; - - while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) { - lineno++; - len = strlen(buffer); - if (buffer[len-1] == '\n') - buffer[--len] = 0; - if (buffer[0] != ':') - continue; - rc = ihex_readrec(&ihex, buffer); - if (rc < 0) { - logprintf(LOG_ERR, "invalid record at line %d of \"%s\"", lineno, infile); - return -1; - } - else if (rc != ihex.cksum) { - logprintf(LOG_ERR, "ERROR: checksum mismatch at line %d of \"%s\"", lineno, infile); - logprintf(LOG_ERR, "checksum=0x%02x, computed checksum=0x%02x", ihex.cksum, rc); - return -1; - } - - switch (ihex.rectyp) { - case 0: /* data record */ - nextaddr = ihex.loadofs + baseaddr; - if ((nextaddr + ihex.reclen) > (bufsize+offsetaddr)) { - logprintf(LOG_ERR, "ERROR: address 0x%04x out of range at line %d of %s", nextaddr+ihex.reclen, lineno, infile); - return -1; - } - for (i=0; i maxaddr) - maxaddr = nextaddr+ihex.reclen; - break; - - case 1: /* end of file record */ - return maxaddr-offsetaddr; - break; - - case 2: /* extended segment address record */ - baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 4; - break; - - case 3: /* start segment address record */ - /* we don't do anything with the start address */ - break; - - case 4: /* extended linear address record */ - baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 16; - if(nextaddr == 0) offsetaddr = baseaddr; // if provided before any data, then remember it - break; - - case 5: /* start linear address record */ - /* we don't do anything with the start address */ - break; - - default: - logprintf(LOG_ERR, "don't know how to deal with rectype=%d at line %d of %s", ihex.rectyp, lineno, infile); - return -1; - break; - } - - } /* while */ - - logprintf(LOG_ERR, "no end of file record found for Intel Hex file \"%s\"", infile); - - return maxaddr-offsetaddr; -} - -static int fileio_imm(struct fioparms * fio, - char * filename, FILE * f, unsigned char * buf, int size) -{ - int rc = 0; - char *e = NULL, **array = NULL; - unsigned long b = 0; - int loc = 0; - unsigned int n = 0, i = 0; - - switch (fio->op) { - case FIO_READ: - loc = 0; - n = explode(filename, " ,", &array); - for(i=0;iop); - return -1; - } - - if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) { - logprintf(LOG_ERR, "%s error %s %s: %s; %s %d of the expected %d bytes", - fio->iodesc, fio->dir, filename, strerror(errno), fio->rw, rc, size); - return -1; - } - - return rc; -} - - -static int fileio_ihex(struct fioparms * fio, - char * filename, FILE * f, unsigned char * buf, int size) -{ - int rc; - - switch (fio->op) { - case FIO_WRITE: - rc = b2ihex(buf, size, 32, 0, filename, f); - if (rc < 0) { - return -1; - } - break; - - case FIO_READ: - rc = ihex2b(filename, f, buf, size); - if (rc < 0) - return -1; - break; - - default: - logprintf(LOG_ERR, "invalid Intex Hex file I/O operation=%d", fio->op); - return -1; - break; - } - - return rc; -} - -int fileio_setparms(int op, struct fioparms * fp) -{ - fp->op = op; - - switch (op) { - case FIO_READ: - fp->mode = "r"; - fp->iodesc = "input"; - fp->dir = "from"; - fp->rw = "read"; - break; - - case FIO_WRITE: - fp->mode = "w"; - fp->iodesc = "output"; - fp->dir = "to"; - fp->rw = "wrote"; - break; - - default: - logprintf(LOG_ERR, "invalid I/O operation %d", op); - return -1; - break; - } - - return 0; -} - -int fmt_autodetect(char * fname) -{ - FILE * f; - unsigned char buf[MAX_LINE_LEN]; - int i; - int len; - int found; - - f = fopen(fname, "r"); - if (f == NULL) { - logprintf(LOG_ERR, "error opening %s: %s", fname, strerror(errno)); - return -1; - } - - while (fgets((char *)buf, MAX_LINE_LEN, f)!=NULL) { - buf[MAX_LINE_LEN-1] = 0; - len = strlen((char *)buf); - if (buf[len-1] == '\n') - buf[--len] = 0; - - /* check for binary data */ - found = 0; - for (i=0; i 127) { - found = 1; - break; - } - } - if (found) { - fclose(f); - return FMT_RBIN; - } - - /* check for lines that look like intel hex */ - if ((buf[0] == ':') && (len >= 11)) { - found = 1; - for (i=1; i= 10) && isdigit(buf[1])) { - found = 1; - for (i=1; iflashmem; - } else if(strcmp(memtype, "lfuse") == 0) { - mem = p->lfusemem; - } else if(strcmp(memtype, "hfuse") == 0) { - mem = p->hfusemem; - } - if (mem == NULL) { - logprintf(LOG_ERR, "fileio(): memory type \"%s\" not configured for device \"%s\"", memtype, p->desc); - return -1; - } - - rc = fileio_setparms(op, &fio); - if (rc < 0) - return -1; - - /* point at the requested memory buffer */ - buf = mem->buf; - if (fio.op == FIO_READ) - size = mem->size; - - if (fio.op == FIO_READ) { - /* 0xff fill unspecified memory */ - memset(buf, 0xff, size); - } - - fname = filename; - f = NULL; - - if (format == FMT_AUTO) { - format = fmt_autodetect(fname); - logprintf(LOG_INFO, "%s file %s auto detected as Intel Hex", fio.iodesc, fname); - } - - if (format != FMT_IMM) { - f = fopen(fname, fio.mode); - if (f == NULL) { - logprintf(LOG_ERR, "can't open %s file %s: %s", fio.iodesc, fname, strerror(errno)); - return -1; - } - } - - switch (format) { - case FMT_IHEX: - rc = fileio_ihex(&fio, fname, f, buf, size); - break; - case FMT_IMM: - rc = fileio_imm(&fio, fname, f, buf, size); - break; - default: - return -1; - } - - if (rc > 0) { - if ((op == FIO_READ) && (strcasecmp(mem->desc, "flash") == 0)) { - /* - * if we are reading flash, just mark the size as being the - * highest non-0xff byte - */ - rc = avr_mem_hiaddr(mem); - } - } - if (format != FMT_IMM) { - fclose(f); - } - - return rc; -} - diff --git a/lib/ESPiLight/pilight/libs/avrdude/fileio.h b/lib/ESPiLight/pilight/libs/avrdude/fileio.h deleted file mode 100644 index 8711d2d..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/fileio.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: fileio.h 722 2007-01-24 22:43:46Z joerg_wunsch $ */ - -#ifndef fileio_h -#define fileio_h - -typedef enum { - FMT_AUTO, - FMT_SREC, - FMT_IHEX, - FMT_RBIN, - FMT_IMM, - FMT_HEX, - FMT_DEC, - FMT_OCT, - FMT_BIN -} FILEFMT; - -struct fioparms { - int op; - char * mode; - char * iodesc; - char * dir; - char * rw; -}; - -enum { - FIO_READ, - FIO_WRITE -}; - -#ifdef __cplusplus -extern "C" { -#endif - -char * fmtstr(FILEFMT format); - -int fileio_setparms(int op, struct fioparms * fp); - -int fileio(int op, char * filename, FILEFMT format, - struct avrpart * p, char * memtype, int size); - -int fmt_autodetect(char * fname); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/pgm.c b/lib/ESPiLight/pilight/libs/avrdude/pgm.c deleted file mode 100644 index e56ba85..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/pgm.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean - * Copyright 2007 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: pgm.c 797 2009-02-17 15:31:27Z joerg_wunsch $ */ - -#include -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "avrdude.h" -#include "pgm.h" - -static int pgm_default_2 (struct programmer_t *, AVRPART *); -static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char * value); -static void pgm_default_4 (struct programmer_t *); -static int pgm_default_5 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char data); -static void pgm_default_6 (struct programmer_t *, const char *); - - -static int pgm_default_open (struct programmer_t *pgm, char * name) { - return 0; -} - -static int pgm_default_led (struct programmer_t * pgm, int value) -{ - /* - * If programmer has no LEDs, just do nothing. - */ - return 0; -} - - -static void pgm_default_powerup_powerdown (struct programmer_t * pgm) -{ - /* - * If programmer does not support powerup/down, just do nothing. - */ -} - - -PROGRAMMER * pgm_new(void) -{ - int i; - PROGRAMMER * pgm; - - pgm = (PROGRAMMER *)MALLOC(sizeof(*pgm)); - if (pgm == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - memset(pgm, 0, sizeof(*pgm)); - - pgm->desc[0] = 0; - pgm->type[0] = 0; - pgm->lineno = 0; - pgm->baudrate = 0; - - for (i=0; ipinno[i] = 0; - - /* - * mandatory functions - these are called without checking to see - * whether they are assigned or not - */ - pgm->initialize = pgm_default_2; - pgm->display = pgm_default_6; - pgm->enable = pgm_default_4; - pgm->disable = pgm_default_4; - pgm->powerup = pgm_default_powerup_powerdown; - pgm->powerdown = pgm_default_powerup_powerdown; - pgm->program_enable = pgm_default_2; - pgm->chip_erase = pgm_default_2; - pgm->open = pgm_default_open; - pgm->close = pgm_default_4; - pgm->read_byte = pgm_default_3; - pgm->write_byte = pgm_default_5; - - /* - * predefined functions - these functions have a valid default - * implementation. Hence, they don't need to be defined in - * the programmer. - */ - pgm->rdy_led = pgm_default_led; - pgm->err_led = pgm_default_led; - pgm->pgm_led = pgm_default_led; - pgm->vfy_led = pgm_default_led; - - /* - * optional functions - these are checked to make sure they are - * assigned before they are called - */ - pgm->cmd = NULL; - pgm->spi = NULL; - pgm->paged_write = NULL; - pgm->paged_load = NULL; - pgm->write_setup = NULL; - pgm->read_sig_bytes = NULL; - pgm->set_vtarget = NULL; - pgm->set_varef = NULL; - pgm->set_fosc = NULL; - pgm->perform_osccal = NULL; - pgm->setup = NULL; - pgm->teardown = NULL; - - return pgm; -} - - -static void pgm_default(void) -{ - logprintf(LOG_NOTICE, "AVR programmer operation not supported"); -} - - -static int pgm_default_2 (struct programmer_t * pgm, AVRPART * p) -{ - pgm_default(); - return -1; -} - -static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char * value) -{ - pgm_default(); - return -1; -} - -static void pgm_default_4 (struct programmer_t * pgm) -{ - pgm_default(); -} - -static int pgm_default_5 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, - unsigned long addr, unsigned char data) -{ - pgm_default(); - return -1; -} - -static void pgm_default_6 (struct programmer_t * pgm, const char * p) -{ - pgm_default(); -} - - -// void programmer_display(PROGRAMMER * pgm, const char * p) -// { - // logprintf(LOG_INFO, "%sProgrammer Type : %s", p, pgm->type); - // logprintf(LOG_INFO, "%sDescription : %s", p, pgm->desc); - - // pgm->display(pgm, p); -// } diff --git a/lib/ESPiLight/pilight/libs/avrdude/pgm.h b/lib/ESPiLight/pilight/libs/avrdude/pgm.h deleted file mode 100644 index 633c6dc..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/pgm.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean - * Copyright 2007 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: pgm.h 797 2009-02-17 15:31:27Z joerg_wunsch $ */ - -#ifndef pgm_h -#define pgm_h - -#include - -#include "avrpart.h" -#include "serial.h" -#include "pindefs.h" - -#define ON 1 -#define OFF 0 - -#define PGM_DESCLEN 80 -#define PGM_PORTLEN 4096 -#define PGM_TYPELEN 32 - -typedef enum { - EXIT_VCC_UNSPEC, - EXIT_VCC_ENABLED, - EXIT_VCC_DISABLED -} exit_vcc_t; - -typedef enum { - EXIT_RESET_UNSPEC, - EXIT_RESET_ENABLED, - EXIT_RESET_DISABLED -} exit_reset_t; - -typedef struct programmer_t { - char desc[PGM_DESCLEN]; - char type[PGM_TYPELEN]; - char port[PGM_PORTLEN]; - unsigned int pinno[N_PINS]; - exit_vcc_t exit_vcc; - exit_reset_t exit_reset; - int ppidata; - int ppictrl; - int baudrate; - double bitclock; /* JTAG ICE clock period in microseconds */ - int ispdelay; /* ISP clock delay */ - union filedescriptor fd; - int page_size; /* page size if the programmer supports paged write/load */ - int (*rdy_led) (struct programmer_t * pgm, int value); - int (*err_led) (struct programmer_t * pgm, int value); - int (*pgm_led) (struct programmer_t * pgm, int value); - int (*vfy_led) (struct programmer_t * pgm, int value); - int (*initialize) (struct programmer_t * pgm, AVRPART * p); - void (*display) (struct programmer_t * pgm, const char * p); - void (*enable) (struct programmer_t * pgm); - void (*disable) (struct programmer_t * pgm); - void (*powerup) (struct programmer_t * pgm); - void (*powerdown) (struct programmer_t * pgm); - int (*program_enable) (struct programmer_t * pgm, AVRPART * p); - int (*chip_erase) (struct programmer_t * pgm, AVRPART * p); - int (*cmd) (struct programmer_t * pgm, unsigned char cmd[4], - unsigned char res[4]); - int (*spi) (struct programmer_t * pgm, unsigned char cmd[], - unsigned char res[], int count); - int (*open) (struct programmer_t * pgm, char * port); - void (*close) (struct programmer_t * pgm); - int (*paged_write) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, - unsigned int page_size, unsigned int baseaddr, - unsigned int n_bytes); - int (*paged_load) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, - unsigned int page_size, unsigned int baseaddr, - unsigned int n_bytes); - void (*write_setup) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m); - int (*write_byte) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, - unsigned long addr, unsigned char value); - int (*read_byte) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, - unsigned long addr, unsigned char * value); - int (*read_sig_bytes) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m); - void (*print_parms) (struct programmer_t * pgm); - int (*set_vtarget) (struct programmer_t * pgm, double v); - int (*set_varef) (struct programmer_t * pgm, unsigned int chan, double v); - int (*set_fosc) (struct programmer_t * pgm, double v); - int (*set_sck_period) (struct programmer_t * pgm, double v); - int (*setpin) (struct programmer_t * pgm, int pin, int value); - int (*getpin) (struct programmer_t * pgm, int pin); - int (*highpulsepin) (struct programmer_t * pgm, int pin); - int (*parseexitspecs) (struct programmer_t * pgm, char *s); - int (*perform_osccal) (struct programmer_t * pgm); - void (*setup) (struct programmer_t * pgm); - void (*teardown) (struct programmer_t * pgm); - char config_file[4096]; /* config file where defined */ - int lineno; /* config file line number */ - void *cookie; /* for private use by the programmer */ - char flag; /* for private use of the programmer */ -} PROGRAMMER; - -#ifdef __cplusplus -extern "C" { -#endif - -PROGRAMMER * pgm_new(void); - -void programmer_display(PROGRAMMER * pgm, const char * p); - -typedef void (*walk_programmers_cb)(const char *name, const char *desc, - const char *cfgname, int cfglineno, - void *cookie); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/pindefs.h b/lib/ESPiLight/pilight/libs/avrdude/pindefs.h deleted file mode 100644 index 9d75a6d..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/pindefs.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2004 Brian S. Dean - * - * 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 of the License, 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 - */ - -/* $Id: pindefs.h 515 2005-09-18 20:12:23Z joerg_wunsch $ */ - -#ifndef __pindefs_h__ -#define __pindefs_h__ - -enum { - PPI_AVR_VCC=1, - PPI_AVR_BUFF, - PIN_AVR_RESET, - PIN_AVR_SCK, - PIN_AVR_MOSI, - PIN_AVR_MISO, - PIN_LED_ERR, - PIN_LED_RDY, - PIN_LED_PGM, - PIN_LED_VFY, - N_PINS -}; -#define PIN_INVERSE 0x80 /* flag for inverted pin in serbb */ -#define PIN_MASK 0x7f - -#define LED_ON(fd,pin) ppi_setpin(fd,pin,0) -#define LED_OFF(fd,pin) ppi_setpin(fd,pin,1) - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/safemode.c b/lib/ESPiLight/pilight/libs/avrdude/safemode.c deleted file mode 100644 index f201af2..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/safemode.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * avrdude is Copyright (C) 2000-2004 Brian S. Dean - * - * This file: Copyright (C) 2005-2007 Colin O'Flynn - * - * 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 of the License, 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 - */ - - -#include - -#include "../pilight/core/log.h" -#include "avrdude.h" -#include "avr.h" -#include "pgm.h" -#include "safemode.h" - -/* This value from ac_cfg.h */ -/* - * Writes the specified fuse in fusename (can be "lfuse", "hfuse", or - * "efuse") and verifies it. Will try up to tries amount of times - * before giving up - */ -int safemode_writefuse (unsigned char fuse, const char * fusename, PROGRAMMER * pgm, - AVRPART * p, int tries) -{ - AVRMEM * m = NULL; - unsigned char fuseread; - int returnvalue = -1; - - // m = avr_locate_mem(p, fusename); - if (m == NULL) { - return -1; - } - - /* Keep trying to write then read back the fuse values */ - while (tries > 0) { - if (avr_write_byte(pgm, p, m, 0, fuse) != 0) { - continue; - } - if (pgm->read_byte(pgm, p, m, 0, &fuseread) != 0) { - continue; - } - - /* Report information to user if needed */ - logprintf(LOG_ERR, "AVR wrote %s to %x, read as %x. %d attempts left", fusename, fuse, fuseread, tries-1); - - /* If fuse wrote OK, no need to keep going */ - if (fuse == fuseread) { - tries = 0; - returnvalue = 0; - } - tries--; - } - - return returnvalue; -} - -/* - * Reads the fuses three times, checking that all readings are the - * same. This will ensure that the before values aren't in error! - */ -int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, - unsigned char * efuse, unsigned char * fuse, - PROGRAMMER * pgm, AVRPART * p) -{ - - unsigned char value; - unsigned char fusegood = 0; - unsigned char allowfuseread = 1; - unsigned char safemode_lfuse; - unsigned char safemode_hfuse; - unsigned char safemode_efuse; - unsigned char safemode_fuse; - AVRMEM * m = NULL; - - safemode_lfuse = *lfuse; - safemode_hfuse = *hfuse; - safemode_efuse = *efuse; - safemode_fuse = *fuse; - - - /* Read fuse three times */ - // fusegood = 2; /* If AVR device doesn't support this fuse, don't want - // to generate a verify error */ - // m = avr_locate_mem(p, "fuse"); - // if (m != NULL) { - // fusegood = 0; /* By default fuse is a failure */ - // if(pgm->read_byte(pgm, p, m, 0, &safemode_fuse) != 0) - // { - // allowfuseread = 0; - // } - // if(pgm->read_byte(pgm, p, m, 0, &value) != 0) - // { - // allowfuseread = 0; - // } - // if (value == safemode_fuse) { - // if (pgm->read_byte(pgm, p, m, 0, &value) != 0) - // { - // allowfuseread = 0; - // } - // if (value == safemode_fuse) - // { - // fusegood = 1; /* Fuse read OK three times */ - // } - // } - // } - - // //Programmer does not allow fuse reading.... no point trying anymore - // if (allowfuseread == 0) - // { - // return -5; - // } - - // if (fusegood == 0) { - // logprintf(LOG_ERR, "AVR verify error, unable to read fuse properly."); - // logprintf(LOG_ERR, "Programmer may not be reliable."); - // return -1; - // } - // else if ((fusegood == 1)) { - // logprintf(LOG_INFO, "AVR fuse reads as %X", safemode_lfuse); - // } - - - /* Read lfuse three times */ - fusegood = 2; /* If AVR device doesn't support this fuse, don't want - to generate a verify error */ - m = p->lfusemem; - if (m != NULL) { - fusegood = 0; /* By default fuse is a failure */ - if (pgm->read_byte(pgm, p, m, 0, &safemode_lfuse) != 0) { - allowfuseread = 0; - } - if (pgm->read_byte(pgm, p, m, 0, &value) != 0) { - allowfuseread = 0; - } - if (value == safemode_lfuse) { - if (pgm->read_byte(pgm, p, m, 0, &value) != 0) { - allowfuseread = 0; - } - if (value == safemode_lfuse) { - fusegood = 1; /* Fuse read OK three times */ - } - } - } - - //Programmer does not allow fuse reading.... no point trying anymore - if (allowfuseread == 0) { - return -5; - } - - - if (fusegood == 0) { - logprintf(LOG_ERR, "AVR verify error, unable to read lfuse properly."); - logprintf(LOG_ERR, "Programmer may not be reliable."); - return -1; - } - else if (fusegood == 1) { - logprintf(LOG_INFO, "AVR lfuse reads as %X", safemode_lfuse); - } - - /* Read hfuse three times */ - fusegood = 2; /* If AVR device doesn't support this fuse, don't want - to generate a verify error */ - m = p->hfusemem; - if (m != NULL) { - fusegood = 0; /* By default fuse is a failure */ - if (pgm->read_byte(pgm, p, m, 0, &safemode_hfuse) != 0) { - allowfuseread = 0; - } - if (pgm->read_byte(pgm, p, m, 0, &value) != 0) { - allowfuseread = 0; - } - if (value == safemode_hfuse) { - if (pgm->read_byte(pgm, p, m, 0, &value) != 0) { - allowfuseread = 0; - } - if (value == safemode_hfuse) { - fusegood = 1; /* Fuse read OK three times */ - } - } - } - - //Programmer does not allow fuse reading.... no point trying anymore - if (allowfuseread == 0) { - return -5; - } - - if (fusegood == 0) { - logprintf(LOG_ERR, "AVR verify error, unable to read hfuse properly."); - logprintf(LOG_ERR, "Programmer may not be reliable."); - return -1; - } - else if (fusegood == 1) { - logprintf(LOG_INFO, "AVR hfuse reads as %X", safemode_lfuse); - } - - /* Read efuse three times */ - fusegood = 2; /* If AVR device doesn't support this fuse, don't want - to generate a verify error */ - // m = avr_locate_mem(p, "efuse"); - // if (m != NULL) { - // fusegood = 0; /* By default fuse is a failure */ - // if (pgm->read_byte(pgm, p, m, 0, &safemode_efuse) != 0) - // { - // allowfuseread = 0; - // } - // if (pgm->read_byte(pgm, p, m, 0, &value) != 0) - // { - // allowfuseread = 0; - // } - // if (value == safemode_efuse) { - // if (pgm->read_byte(pgm, p, m, 0, &value) != 0) - // { - // allowfuseread = 0; - // } - // if (value == safemode_efuse){ - // fusegood = 1; /* Fuse read OK three times */ - // } - // } - // } - - // //Programmer does not allow fuse reading.... no point trying anymore - // if (allowfuseread == 0) - // { - // return -5; - // } - - // if (fusegood == 0) { - // logprintf(LOG_ERR, "AVR verify error, unable to read efuse properly."); - // logprintf(LOG_ERR, "Programmer may not be reliable."); - // return -1; - // } - // else if ((fusegood == 1)) { - // logprintf(LOG_INFO, "AVR efuse reads as %X", safemode_lfuse); - // } - - *lfuse = safemode_lfuse; - *hfuse = safemode_hfuse; - *efuse = safemode_efuse; - *fuse = safemode_fuse; - - return 0; -} - - -/* - * This routine will store the current values pointed to by lfuse, - * hfuse, and efuse into an internal buffer in this routine when save - * is set to 1. When save is 0 (or not 1 really) it will copy the - * values from the internal buffer into the locations pointed to be - * lfuse, hfuse, and efuse. This allows you to change the fuse bits if - * needed from another routine (ie: have it so if user requests fuse - * bits are changed, the requested value is now verified - */ -int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse, - unsigned char * efuse, unsigned char * fuse) -{ - static unsigned char safemode_lfuse = 0xff; - static unsigned char safemode_hfuse = 0xff; - static unsigned char safemode_efuse = 0xff; - static unsigned char safemode_fuse = 0xff; - - switch (save) { - - /* Save the fuses as safemode setting */ - case 1: - safemode_lfuse = *lfuse; - safemode_hfuse = *hfuse; - safemode_efuse = *efuse; - safemode_fuse = *fuse; - - break; - /* Read back the fuses */ - default: - *lfuse = safemode_lfuse; - *hfuse = safemode_hfuse; - *efuse = safemode_efuse; - *fuse = safemode_fuse; - break; - } - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/safemode.h b/lib/ESPiLight/pilight/libs/avrdude/safemode.h deleted file mode 100644 index 9e0a0a0..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/safemode.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * avrdude is Copyright (C) 2000-2004 Brian S. Dean - * - * This file: Copyright (C) 2005 Colin O'Flynn - * - * 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 of the License, 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 - */ - - -#ifndef safemode_h -#define safemode_h - -#ifdef __cplusplus -extern "C" { -#endif - -/* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or "efuse") and verifies it. Will try up to tries -amount of times before giving up */ -int safemode_writefuse (unsigned char fuse, const char * fusename, PROGRAMMER * pgm, AVRPART * p, int tries); - -/* Reads the fuses three times, checking that all readings are the same. This will ensure that the before values aren't in error! */ -int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse, PROGRAMMER * pgm, AVRPART * p); - -/* This routine will store the current values pointed to by lfuse, hfuse, and efuse into an internal buffer in this routine -when save is set to 1. When save is 0 (or not 1 really) it will copy the values from the internal buffer into the locations -pointed to be lfuse, hfuse, and efuse. This allows you to change the fuse bits if needed from another routine (ie: have it so -if user requests fuse bits are changed, the requested value is now verified */ -int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse); - -#ifdef __cplusplus -} -#endif - -#endif /* safemode_h */ diff --git a/lib/ESPiLight/pilight/libs/avrdude/ser_posix.c b/lib/ESPiLight/pilight/libs/avrdude/ser_posix.c deleted file mode 100644 index ee5a77f..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/ser_posix.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth - * Copyright (C) 2006 Joerg Wunsch - * - * 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 of the License, 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, see . - */ - -/* $Id: ser_posix.c 1294 2014-03-12 23:03:18Z joerg_wunsch $ */ - -/* - * Posix serial interface for avrdude. - */ - -#ifndef _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "avrdude.h" -#include "serial.h" - -long serial_recv_timeout = 5000; /* ms */ - -static struct termios original_termios; -static int saved_original_termios; - -static int ser_setspeed(union filedescriptor *fd, long baud) { - int rc = 0; - struct termios termios; - speed_t speed = baud; - - if(!isatty(fd->ifd)) { - return -ENOTTY; - } - - /* - * initialize terminal modes - */ - if(tcgetattr(fd->ifd, &termios) < 0) { - logprintf(LOG_ERR, "ser_setspeed(): tcgetattr() failed"); - return -errno; - } - - /* - * copy termios for ser_close if we haven't already - */ - if(!saved_original_termios++) { - original_termios = termios; - } - - termios.c_iflag = IGNBRK; - termios.c_oflag = 0; - termios.c_lflag = 0; - termios.c_cflag = (CS8 | CREAD | CLOCAL); - termios.c_cc[VMIN] = 1; - termios.c_cc[VTIME] = 0; - - cfsetospeed(&termios, speed); - cfsetispeed(&termios, speed); - - if(tcsetattr(fd->ifd, TCSANOW, &termios) < 0) { - logprintf(LOG_ERR, "%s: ser_setspeed(): tcsetattr() failed"); - return -errno; - } - - /* - * Everything is now set up for a local line without modem control - * or flow control, so clear O_NONBLOCK again. - */ - rc = fcntl(fd->ifd, F_GETFL, 0); - if(rc != -1) { - fcntl(fd->ifd, F_SETFL, rc & ~O_NONBLOCK); - } - - return 0; -} - -static int ser_set_dtr_rts(union filedescriptor *fdp, int is_on) { - unsigned int ctl = 0; - - if(ioctl(fdp->ifd, TIOCMGET, &ctl) < 0) { - // perror("ioctl(\"TIOCMGET\")"); - return -1; - } - - if(is_on > 0) { - /* Set DTR and RTS */ - ctl |= (TIOCM_DTR | TIOCM_RTS); - } else { - /* Clear DTR and RTS */ - ctl &= ~(TIOCM_DTR | TIOCM_RTS); - } - - if(ioctl(fdp->ifd, TIOCMSET, &ctl) < 0) { - // perror("ioctl(\"TIOCMSET\")"); - return -1; - } - - return 0; -} - -static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp) { - int rc = 0, fd = 0; - - /* - * open the serial port - */ - if((fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) { - logprintf(LOG_ERR, "ser_open(): can't open device \"%s\": %s", port, strerror(errno)); - return -1; - } - - fdp->ifd = fd; - - /* - * set serial line attributes - */ - if((rc = ser_setspeed(fdp, pinfo.baud)) > 0) { - logprintf(LOG_ERR, "ser_open(): can't set attributes for device \"%s\": %s", port, strerror(-rc)); - close(fd); - return -1; - } - return 0; -} - - -static void ser_close(union filedescriptor *fd) { - /* - * restore original termios settings from ser_open - */ - if(saved_original_termios > 0) { - if(tcsetattr(fd->ifd, TCSANOW | TCSADRAIN, &original_termios) > 0) { - logprintf(LOG_ERR, "ser_close(): can't reset attributes for device: %s", strerror(errno)); - } - saved_original_termios = 0; - } - - close(fd->ifd); -} - - -static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen) { - int rc = 0; - unsigned char *p = buf; - size_t len = buflen; - - if(len <= 0) - return 0; - - while(len) { - rc = write(fd->ifd, p, (len > 1024) ? 1024 : len); - if(rc < 0) { - logprintf(LOG_ERR, "ser_send(): write error: %s", strerror(errno)); - exit(1); - } - p += rc; - len -= rc; - } - - return 0; -} - - -static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen) { - struct timeval timeout, to2; - fd_set rfds; - int nfds = 0, rc = 0; - unsigned char *p = buf; - size_t len = 0; - - timeout.tv_sec = serial_recv_timeout / 1000L; - timeout.tv_usec = (serial_recv_timeout % 1000L) * 1000; - to2 = timeout; - - while(len < buflen) { - reselect: - FD_ZERO(&rfds); - FD_SET(fd->ifd, &rfds); - - nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &to2); - if(nfds == 0) { - logprintf(LOG_ERR, "ser_recv(): programmer is not responding"); - return -1; - } else if(nfds == -1) { - if(errno == EINTR || errno == EAGAIN) { - logprintf(LOG_ERR, "ser_recv(): programmer is not responding, reselecting"); - goto reselect; - } else { - logprintf(LOG_ERR, "ser_recv(): select(): %s", strerror(errno)); - return -1; - } - } - - rc = read(fd->ifd, p, (buflen - len > 1024) ? 1024 : buflen - len); - if(rc < 0) { - logprintf(LOG_ERR, "ser_recv(): read error: %s", strerror(errno)); - return -1; - } - p += rc; - len += rc; - } - - p = buf; - - return 0; -} - - -static int ser_drain(union filedescriptor *fd, int display) { - struct timeval timeout; - fd_set rfds; - int nfds = 0, rc = 0; - unsigned char buf; - - timeout.tv_sec = 0; - timeout.tv_usec = 250000; - - while(1) { - FD_ZERO(&rfds); - FD_SET(fd->ifd, &rfds); - - reselect: - nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &timeout); - if(nfds == 0) { - break; - } else if(nfds == -1) { - if(errno == EINTR) { - goto reselect; - } else { - logprintf(LOG_ERR, "ser_drain(): select(): %s", strerror(errno)); - return -1; - } - } - - rc = read(fd->ifd, &buf, 1); - if(rc < 0) { - logprintf(LOG_ERR, "ser_drain(): read error: %s", strerror(errno)); - return -1; - } - } - - return 0; -} - -struct serial_device serial_serdev = { - .open = ser_open, - .setspeed = ser_setspeed, - .close = ser_close, - .send = ser_send, - .recv = ser_recv, - .drain = ser_drain, - .set_dtr_rts = ser_set_dtr_rts, - .flags = SERDEV_FL_CANSETSPEED, -}; - -struct serial_device *serdev = &serial_serdev; - -#endif /* WIN32NATIVE */ diff --git a/lib/ESPiLight/pilight/libs/avrdude/ser_win32.c b/lib/ESPiLight/pilight/libs/avrdude/ser_win32.c deleted file mode 100644 index 65dbdc8..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/ser_win32.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth - * Copyright (C) 2006 Joerg Wunsch - * - * 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 of the License, 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, see . - */ - -/* $Id: ser_win32.c 1294 2014-03-12 23:03:18Z joerg_wunsch $ */ - -/* -* Native Win32 serial interface for avrdude. -*/ - -#ifdef _WIN32 - -#include -#include -#include - -#include "../pilight/core/log.h" -#include "../pilight/core/mem.h" -#include "serial.h" - -long serial_recv_timeout = 5000; /* ms */ - -#define W32SERBUFSIZE 1024 - -static BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) { - COMMTIMEOUTS ctmo; - ZeroMemory (&ctmo, sizeof(COMMTIMEOUTS)); - ctmo.ReadIntervalTimeout = timeout; - ctmo.ReadTotalTimeoutMultiplier = timeout; - ctmo.ReadTotalTimeoutConstant = timeout; - - return SetCommTimeouts(hComPort, &ctmo); -} - -static int ser_setspeed(union filedescriptor *fd, long baud) { - DCB dcb; - HANDLE hComPort = (HANDLE)fd->pfd; - - ZeroMemory (&dcb, sizeof(DCB)); - dcb.DCBlength = sizeof(DCB); - dcb.BaudRate = baud; - dcb.fBinary = 1; - dcb.fDtrControl = DTR_CONTROL_DISABLE; - dcb.fRtsControl = RTS_CONTROL_DISABLE; - dcb.ByteSize = 8; - dcb.Parity = NOPARITY; - dcb.StopBits = ONESTOPBIT; - - if(!SetCommState(hComPort, &dcb)) { - return -1; - } - - return 0; -} - - -static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp) { - LPVOID lpMsgBuf; - HANDLE hComPort=INVALID_HANDLE_VALUE; - char *newname = 0; - - if(strncasecmp(port, "com", strlen("com")) == 0) { - // prepend "\\\\.\\" to name, required for port # >= 10 - newname = MALLOC(strlen("\\\\.\\") + strlen(port) + 1); - - if(newname == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(newname, "\\\\.\\"); - strcat(newname, port); - - port = newname; - } - - hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - - if(hComPort == INVALID_HANDLE_VALUE) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - logprintf(LOG_ERR, "ser_open(): can't open device \"%s\": %s", port, (char*)lpMsgBuf); - if(newname != NULL) { - FREE(newname); - } - LocalFree(lpMsgBuf); - return -1; - } - - if(!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE)) { - CloseHandle(hComPort); - logprintf(LOG_ERR, "ser_open(): can't set buffers for \"%s\"", port); - if(newname != NULL) { - FREE(newname); - } - return -1; - } - - fdp->pfd = (void *)hComPort; - if(ser_setspeed(fdp, pinfo.baud) != 0) { - CloseHandle(hComPort); - logprintf(LOG_ERR, "ser_open(): can't set com-state for \"%s\"", port); - if(newname != NULL) { - FREE(newname); - } - return -1; - } - - if(!serial_w32SetTimeOut(hComPort, 0)) { - CloseHandle(hComPort); - logprintf(LOG_ERR, "ser_open(): can't set initial timeout for \"%s\"", port); - if(newname != NULL) { - FREE(newname); - } - return -1; - } - - if(newname != NULL) { - FREE(newname); - } - return 0; -} - - -static void ser_close(union filedescriptor *fd) { - HANDLE hComPort=(HANDLE)fd->pfd; - if(hComPort != INVALID_HANDLE_VALUE) { - CloseHandle (hComPort); - } - - hComPort = INVALID_HANDLE_VALUE; -} - -static int ser_set_dtr_rts(union filedescriptor *fd, int is_on) { - HANDLE hComPort=(HANDLE)fd->pfd; - - if(is_on > 0) { - EscapeCommFunction(hComPort, SETDTR); - EscapeCommFunction(hComPort, SETRTS); - } else { - EscapeCommFunction(hComPort, CLRDTR); - EscapeCommFunction(hComPort, CLRRTS); - } - return 0; -} - - -static int ser_send(union filedescriptor *fd, unsigned char *buf, size_t buflen) { - size_t len = buflen; - DWORD written; - - HANDLE hComPort = (HANDLE)fd->pfd; - - if(hComPort == INVALID_HANDLE_VALUE) { - logprintf(LOG_ERR, "ser_send(): port not open"); - return -1; - } - - if(len <= 0) { - return 0; - } - - serial_w32SetTimeOut(hComPort,500); - - if(!WriteFile(hComPort, buf, buflen, &written, NULL)) { - logprintf(LOG_ERR, "ser_send(): write error"); // TODO - exit(1); - } - - if(written != buflen) { - logprintf(LOG_ERR, "ser_send(): size/send mismatch"); - return -1; - } - - return 0; -} - - -static int ser_recv(union filedescriptor *fd, unsigned char *buf, size_t buflen) { - DWORD read; - - HANDLE hComPort = (HANDLE)fd->pfd; - - if(hComPort == INVALID_HANDLE_VALUE) { - logprintf(LOG_ERR, "ser_read(): port not open"); - return -1; - } - - serial_w32SetTimeOut(hComPort, serial_recv_timeout); - - if(!ReadFile(hComPort, buf, buflen, &read, NULL)) { - LPVOID lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - logprintf(LOG_ERR, "ser_recv(): read error: %s", (char*)lpMsgBuf); - LocalFree(lpMsgBuf); - return -1; - } - - /* time out detected */ - if(read == 0) { - return -1; - } - - return 0; -} - - -static int ser_drain(union filedescriptor *fd, int display) { - unsigned char buf[10]; - BOOL readres; - DWORD read; - - HANDLE hComPort=(HANDLE)fd->pfd; - - if(hComPort == INVALID_HANDLE_VALUE) { - logprintf(LOG_ERR, "%s: ser_drain(): port not open"); - return -1; - } - - serial_w32SetTimeOut(hComPort,250); - - while(1) { - readres=ReadFile(hComPort, buf, 1, &read, NULL); - if(!readres) { - LPVOID lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - logprintf(LOG_ERR, "ser_drain(): read error: %s", (char*)lpMsgBuf); - LocalFree(lpMsgBuf); - return -1; - } - - if(read <= 0) { - break; - } - } - return 0; -} - -struct serial_device serial_serdev = { - .open = ser_open, - .setspeed = ser_setspeed, - .close = ser_close, - .send = ser_send, - .recv = ser_recv, - .drain = ser_drain, - .set_dtr_rts = ser_set_dtr_rts, - .flags = SERDEV_FL_CANSETSPEED, -}; - -struct serial_device *serdev = &serial_serdev; - -#endif diff --git a/lib/ESPiLight/pilight/libs/avrdude/serial.h b/lib/ESPiLight/pilight/libs/avrdude/serial.h deleted file mode 100644 index 3b07472..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/serial.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2003-2004 Theodore A. Roth - * - * 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 of the License, 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, see . - */ - -/* $Id: serial.h 1294 2014-03-12 23:03:18Z joerg_wunsch $ */ - -/* This is the API for the generic serial interface. The implementations are - actually provided by the target dependant files: - - ser_posix.c : posix serial interface. - ser_win32.c : native win32 serial interface. - - The target file will be selected at configure time. */ - -#ifndef serial_h -#define serial_h - -extern long serial_recv_timeout; -union filedescriptor -{ - int ifd; - void *pfd; - struct - { - void *handle; - int rep; /* bulk read endpoint */ - int wep; /* bulk write endpoint */ - int eep; /* event read endpoint */ - int max_xfer; /* max transfer size */ - int use_interrupt_xfer; /* device uses interrupt transfers */ - } usb; -}; - -union pinfo -{ - long baud; - struct - { - unsigned short vid; - unsigned short pid; - unsigned short flags; -#define PINFO_FL_USEHID 0x0001 -#define PINFO_FL_SILENT 0x0002 /* don't complain if not found */ - } usbinfo; -}; - - -struct serial_device -{ - // open should return -1 on error, other values on success - int (*open)(char * port, union pinfo pinfo, union filedescriptor *fd); - int (*setspeed)(union filedescriptor *fd, long baud); - void (*close)(union filedescriptor *fd); - - int (*send)(union filedescriptor *fd, unsigned char * buf, size_t buflen); - int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen); - int (*drain)(union filedescriptor *fd, int display); - - int (*set_dtr_rts)(union filedescriptor *fd, int is_on); - - int flags; -#define SERDEV_FL_NONE 0x0000 /* no flags */ -#define SERDEV_FL_CANSETSPEED 0x0001 /* device can change speed */ -}; - -extern struct serial_device *serdev; -extern struct serial_device serial_serdev; -extern struct serial_device usb_serdev; -extern struct serial_device usb_serdev_frame; -extern struct serial_device avrdoper_serdev; - -#define serial_open (serdev->open) -#define serial_setspeed (serdev->setspeed) -#define serial_close (serdev->close) -#define serial_send (serdev->send) -#define serial_recv (serdev->recv) -#define serial_drain (serdev->drain) -#define serial_set_dtr_rts (serdev->set_dtr_rts) - -#endif /* serial_h */ diff --git a/lib/ESPiLight/pilight/libs/avrdude/stk500.c b/lib/ESPiLight/pilight/libs/avrdude/stk500.c deleted file mode 100644 index 008a332..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/stk500.c +++ /dev/null @@ -1,624 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean - * Copyright (C) 2008,2014 Joerg Wunsch - * - * 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 of the License, 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, see . -*/ - -/* $Id: stk500.c 1294 2014-03-12 23:03:18Z joerg_wunsch $ */ - -/* - * avrdude interface for Atmel STK500 programmer - * - * Note: most commands use the "universal command" feature of the - * programmer in a "pass through" mode, exceptions are "program - * enable", "paged read", and "paged write". - * -*/ - -#include -#include -#include -#include -#include - -#include "../pilight/core/log.h" -#include "avrdude.h" -#include "avr.h" -#include "pgm.h" -#include "stk500.h" -#include "stk500_private.h" -#include "serial.h" - -#define STK500_XTAL 7372800U -#define MAX_SYNC_ATTEMPTS 1 - -struct pdata { - unsigned char ext_addr_byte; /* Record ext-addr byte set in the target device (if used) */ -}; - -#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) - -static int stk500_send(PROGRAMMER *pgm, unsigned char *buf, size_t len) { - return serial_send(&pgm->fd, buf, len); -} - -static int stk500_recv(PROGRAMMER *pgm, unsigned char *buf, size_t len) { - if(serial_recv(&pgm->fd, buf, len) < 0) { - logprintf(LOG_ERR, "stk500_recv(): programmer is not responding"); - return -1; - } - return 0; -} - - -int stk500_drain(PROGRAMMER *pgm, int display) { - return serial_drain(&pgm->fd, display); -} - -int stk500_getsync(PROGRAMMER * pgm) { - unsigned char buf[32], resp[32]; - int attempt = 0; - - /* - * get in sync */ - buf[0] = Cmnd_STK_GET_SYNC; - buf[1] = Sync_CRC_EOP; - - /* - * First send and drain a few times to get rid of line noise - */ - stk500_send(pgm, buf, 2); - stk500_drain(pgm, 0); - stk500_send(pgm, buf, 2); - stk500_drain(pgm, 0); - - for(attempt = 0; attempt < MAX_SYNC_ATTEMPTS; attempt++) { - stk500_send(pgm, buf, 2); - stk500_recv(pgm, resp, 1); - if(resp[0] == Resp_STK_INSYNC){ - break; - } - logprintf(LOG_ERR, "stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x", - attempt + 1, MAX_SYNC_ATTEMPTS, resp[0]); - } - if(attempt == MAX_SYNC_ATTEMPTS) { - stk500_drain(pgm, 0); - return -1; - } - - if(stk500_recv(pgm, resp, 1) < 0) { - return -1; - } - if(resp[0] != Resp_STK_OK) { - logprintf(LOG_ERR, "stk500_getsync(): can't communicate with device: resp=0x%02x", resp[0]); - return -1; - } - - return 0; -} - - -/* -* transmit an AVR device command and return the results; 'cmd' and -* 'res' must point to at least a 4 byte data buffer -*/ -static int stk500_cmd(PROGRAMMER *pgm, const unsigned char *cmd, unsigned char *res) { - unsigned char buf[32]; - - buf[0] = Cmnd_STK_UNIVERSAL; - buf[1] = cmd[0]; - buf[2] = cmd[1]; - buf[3] = cmd[2]; - buf[4] = cmd[3]; - buf[5] = Sync_CRC_EOP; - - stk500_send(pgm, buf, 6); - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "stk500_cmd(): programmer is out of sync"); - return -1; - } - - res[0] = cmd[1]; - res[1] = cmd[2]; - res[2] = cmd[3]; - if(stk500_recv(pgm, &res[3], 1) < 0) { - return -1; - } - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] != Resp_STK_OK) { - logprintf(LOG_ERR, "stk500_cmd(): protocol error"); - return -1; - } - - return 0; -} - - - -/* -* issue the 'chip erase' command to the AVR device -*/ -static int stk500_chip_erase(PROGRAMMER *pgm, AVRPART *p) { - unsigned char cmd[4]; - unsigned char res[4]; - - if(pgm->cmd == NULL) { - logprintf(LOG_ERR, "Error: %s programmer uses stk500_chip_erase() but does not provide a cmd() method.", pgm->type); - return -1; - } - - if(p->op[AVR_OP_CHIP_ERASE] == NULL) { - logprintf(LOG_ERR, "chip erase instruction not defined for part \"%s\"", p->desc); - return -1; - } - - pgm->pgm_led(pgm, ON); - - memset(cmd, 0, sizeof(cmd)); - - avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd); - pgm->cmd(pgm, cmd, res); - usleep(p->chip_erase_delay); - pgm->initialize(pgm, p); - - pgm->pgm_led(pgm, OFF); - - return 0; -} - -/* -* issue the 'program enable' command to the AVR device -*/ -static int stk500_program_enable(PROGRAMMER *pgm, AVRPART *p) { - unsigned char buf[16]; - int tries=0; - - retry: - - tries++; - - buf[0] = Cmnd_STK_ENTER_PROGMODE; - buf[1] = Sync_CRC_EOP; - - stk500_send(pgm, buf, 2); - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] == Resp_STK_NOSYNC) { - if(tries > 33) { - logprintf(LOG_ERR, "stk500_program_enable(): can't get into sync"); - return -1; - } - if(stk500_getsync(pgm) < 0) { - return -1; - } - goto retry; - } else if(buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "%s: stk500_program_enable(): protocol error, expect=0x%02x, resp=0x%02x\n", Resp_STK_INSYNC, buf[0]); - return -1; - } - - if(stk500_recv(pgm, buf, 1) < 0) - return -1; - if(buf[0] == Resp_STK_OK) { - return 0; - } else if(buf[0] == Resp_STK_NODEVICE) { - logprintf(LOG_ERR, "stk500_program_enable(): no device"); - return -1; - } - - if(buf[0] == Resp_STK_FAILED) { - logprintf(LOG_ERR, "stk500_program_enable(): failed to enter programming mode"); - return -1; - } - - - logprintf(LOG_ERR, "stk500_program_enable(): unknown response=0x%02x", buf[0]); - - return -1; -} - -/* -* initialize the AVR device and prepare it to accept commands -*/ -static int stk500_initialize(PROGRAMMER *pgm, AVRPART *p) { - unsigned char buf[32]; - AVRMEM *m = NULL; - int tries = 0; - - tries = 0; - -retry: - tries++; - - memset(buf, 0, sizeof(buf)); - - /* - * set device programming parameters - */ - buf[0] = Cmnd_STK_SET_DEVICE; - buf[1] = p->stk500_devcode; - buf[2] = 0; /* device revision */ - - if((p->flags & AVRPART_SERIALOK) && (p->flags & AVRPART_PARALLELOK)) { - buf[3] = 0; /* device supports parallel and serial programming */ - } else { - buf[3] = 1; /* device supports parallel only */ - } - - if(p->flags & AVRPART_PARALLELOK) { - if(p->flags & AVRPART_PSEUDOPARALLEL) { - buf[4] = 0; /* pseudo parallel interface */ - } else { - buf[4] = 1; /* full parallel interface */ - } - } - - buf[5] = 1; /* polling supported - XXX need this in config file */ - buf[6] = 1; /* programming is self-timed - XXX need in config file */ - buf[7] = 0; - buf[8] = 0; - buf[8] += p->lfusemem->size; - buf[8] += p->hfusemem->size; - - m = p->flashmem; - if(m != NULL) { - buf[9] = m->readback[0]; - buf[10] = m->readback[1]; - if(m->paged == 1) { - buf[13] = (m->page_size >> 8) & 0x00ff; - buf[14] = m->page_size & 0x00ff; - } - buf[17] = (m->size >> 24) & 0xff; - buf[18] = (m->size >> 16) & 0xff; - buf[19] = (m->size >> 8) & 0xff; - buf[20] = m->size & 0xff; - } - - buf[11] = 0xff; - buf[12] = 0xff; - buf[15] = 0; - buf[16] = 0; - buf[21] = Sync_CRC_EOP; - - stk500_send(pgm, buf, 22); - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] == Resp_STK_NOSYNC) { - logprintf(LOG_ERR, "stk500_initialize(): programmer not in sync, resp=0x%02x", buf[0]); - if(tries > 33) { - return -1; - } - if(stk500_getsync(pgm) < 0) { - return -1; - } - goto retry; - } else if(buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "stk500_initialize(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - return -1; - } - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] != Resp_STK_OK) { - logprintf(LOG_ERR, "stk500_initialize(): (b) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_OK, buf[0]); - return -1; - } - - return pgm->program_enable(pgm, p); -} - -static int stk500_loadaddr(PROGRAMMER *pgm, AVRMEM *mem, unsigned int addr) { - unsigned char buf[16]; - int tries = 0; - unsigned char ext_byte; - OPCODE * lext; - - tries = 0; - -retry: - tries++; - - /* To support flash > 64K words the correct Extended Address Byte is needed */ - lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; - if(lext != NULL) { - ext_byte = (addr >> 16) & 0xff; - if(ext_byte != PDATA(pgm)->ext_addr_byte) { - /* Either this is the first addr load, or a 64K word boundary is - * crossed, so set the ext addr byte */ - avr_set_bits(lext, buf); - avr_set_addr(lext, buf, addr); - stk500_cmd(pgm, buf, buf); - PDATA(pgm)->ext_addr_byte = ext_byte; - } - } - - buf[0] = Cmnd_STK_LOAD_ADDRESS; - buf[1] = addr & 0xff; - buf[2] = (addr >> 8) & 0xff; - buf[3] = Sync_CRC_EOP; - - stk500_send(pgm, buf, 4); - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] == Resp_STK_NOSYNC) { - if(tries > 33) { - logprintf(LOG_ERR, "stk500_loadaddr(): can't get into sync"); - return -1; - } - if(stk500_getsync(pgm) < 0) { - return -1; - } - goto retry; - } else if(buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "stk500_loadaddr(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - return -1; - } - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] == Resp_STK_OK) { - return 0; - } - - logprintf(LOG_ERR, "loadaddr(): (b) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - - return -1; -} - - -static int stk500_paged_write(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, - unsigned int page_size, - unsigned int addr, unsigned int n_bytes) { - - unsigned char buf[page_size + 16]; - int memtype = 0, a_div = 0, block_size = 0, tries = 0; - unsigned int n = 0, i = 0; - - if(strcmp(m->desc, "flash") == 0) { - memtype = 'F'; - } else if(strcmp(m->desc, "eeprom") == 0) { - memtype = 'E'; - } else { - return -2; - } - - if((m->op[AVR_OP_LOADPAGE_LO]) || (m->op[AVR_OP_READ_LO])) { - a_div = 2; - } else { - a_div = 1; - } - - n = addr + n_bytes; - - for(; addr < n; addr += block_size) { - if(n - addr < page_size) { - block_size = n - addr; - } else { - block_size = page_size; - } - tries = 0; - retry: - tries++; - stk500_loadaddr(pgm, m, addr/a_div); - - /* build command block and avoid multiple send commands as it leads to a crash - of the silabs usb serial driver on mac os x */ - i = 0; - buf[i++] = Cmnd_STK_PROG_PAGE; - buf[i++] = (block_size >> 8) & 0xff; - buf[i++] = block_size & 0xff; - buf[i++] = memtype; - - memcpy(&buf[i], &m->buf[addr], block_size); - - i += block_size; - buf[i++] = Sync_CRC_EOP; - stk500_send(pgm, buf, i); - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] == Resp_STK_NOSYNC) { - if(tries > 33) { - logprintf(LOG_ERR, "stk500_paged_write(): can't get into sync", progname); - return -3; - } - if(stk500_getsync(pgm) < 0) { - return -1; - } - goto retry; - } else if(buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "stk500_paged_write(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - return -4; - } - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] != Resp_STK_OK) { - logprintf(LOG_ERR, "stk500_paged_write(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - return -5; - } - } - - return n_bytes; -} - -static int stk500_paged_load(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, - unsigned int page_size, - unsigned int addr, unsigned int n_bytes) { - unsigned char buf[16]; - int memtype = 0, a_div = 0, tries = 0, block_size = 0; - unsigned int n = 0; - - if(strcmp(m->desc, "flash") == 0) { - memtype = 'F'; - } else if(strcmp(m->desc, "eeprom") == 0) { - memtype = 'E'; - } else { - return -2; - } - - if((m->op[AVR_OP_LOADPAGE_LO]) || (m->op[AVR_OP_READ_LO])) { - a_div = 2; - } else { - a_div = 1; - } - - n = addr + n_bytes; - for(; addr < n; addr += block_size) { - if(n - addr < page_size) { - block_size = n - addr; - } else { - block_size = page_size; - } - - tries = 0; - retry: - tries++; - stk500_loadaddr(pgm, m, addr/a_div); - buf[0] = Cmnd_STK_READ_PAGE; - buf[1] = (block_size >> 8) & 0xff; - buf[2] = block_size & 0xff; - buf[3] = memtype; - buf[4] = Sync_CRC_EOP; - stk500_send(pgm, buf, 5); - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - if(buf[0] == Resp_STK_NOSYNC) { - if(tries > 33) { - logprintf(LOG_ERR, "stk500_paged_load(): can't get into sync"); - return -3; - } - if(stk500_getsync(pgm) < 0) { - return -1; - goto retry; - } - } else if(buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "stk500_paged_load(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - return -4; - } - - if(stk500_recv(pgm, &m->buf[addr], block_size) < 0) { - return -1; - } - - if(stk500_recv(pgm, buf, 1) < 0) { - return -1; - } - - if(buf[0] != Resp_STK_OK) { - logprintf(LOG_ERR, "stk500_paged_load(): (a) protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_OK, buf[0]); - return -5; - } - } - - return n_bytes; -} - - -static void stk500_display(PROGRAMMER * pgm, const char * p) { -} - -static void stk500_disable(PROGRAMMER * pgm) { - unsigned char buf[16]; - int tries=0; - -retry: - tries++; - buf[0] = Cmnd_STK_LEAVE_PROGMODE; - buf[1] = Sync_CRC_EOP; - stk500_send(pgm, buf, 2); - - if(stk500_recv(pgm, buf, 1) < 0) { - return; - } - if(buf[0] == Resp_STK_NOSYNC) { - if(tries > 33) { - logprintf(LOG_ERR, "stk500_disable(): can't get into sync"); - return; - } - if(stk500_getsync(pgm) < 0) { - return; - } - goto retry; - } else if(buf[0] != Resp_STK_INSYNC) { - logprintf(LOG_ERR, "stk500_disable(): protocol error, expect=0x%02x, resp=0x%02x", Resp_STK_INSYNC, buf[0]); - return; - } - if(stk500_recv(pgm, buf, 1) < 0) { - return; - } - if(buf[0] == Resp_STK_OK) { - return; - } else if(buf[0] == Resp_STK_NODEVICE) { - logprintf(LOG_ERR, "stk500_disable(): no device"); - return; - } - logprintf(LOG_ERR, "stk500_disable(): unknown response=0x%02x", buf[0]); - return; -} - -static void stk500_enable(PROGRAMMER *pgm) { - return; -} - -static void stk500_close(PROGRAMMER *pgm) { - serial_close(&pgm->fd); - pgm->fd.ifd = -1; -} - -const char stk500_desc[] = "Atmel STK500 Version 1.x firmware"; - -void stk500_initpgm(PROGRAMMER * pgm) { - strcpy(pgm->type, "STK500"); - - /* - * mandatory functions - */ - pgm->initialize = stk500_initialize; - pgm->display = stk500_display; - pgm->enable = stk500_enable; - pgm->disable = stk500_disable; - pgm->program_enable = stk500_program_enable; - pgm->chip_erase = stk500_chip_erase; - pgm->cmd = stk500_cmd; - pgm->close = stk500_close; - pgm->read_byte = avr_read_byte_default; - pgm->write_byte = avr_write_byte_default; - - /* - * optional functions - */ - pgm->paged_write = stk500_paged_write; - pgm->paged_load = stk500_paged_load; - pgm->page_size = 256; -} diff --git a/lib/ESPiLight/pilight/libs/avrdude/stk500.h b/lib/ESPiLight/pilight/libs/avrdude/stk500.h deleted file mode 100644 index 1cdb6bf..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/stk500.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2002-2004 Brian S. Dean - * - * 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 of the License, 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, see . - */ - -/* $Id: stk500.h 1294 2014-03-12 23:03:18Z joerg_wunsch $ */ - -#ifndef stk500_h -#define stk500_h - -#ifdef __cplusplus -extern "C" { -#endif - -extern const char stk500_desc[]; -void stk500_initpgm (PROGRAMMER * pgm); - -/* used by arduino.c to avoid duplicate code */ -int stk500_getsync(PROGRAMMER * pgm); -int stk500_drain(PROGRAMMER * pgm, int display); - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/lib/ESPiLight/pilight/libs/avrdude/stk500_private.h b/lib/ESPiLight/pilight/libs/avrdude/stk500_private.h deleted file mode 100644 index 6e6e12a..0000000 --- a/lib/ESPiLight/pilight/libs/avrdude/stk500_private.h +++ /dev/null @@ -1,103 +0,0 @@ -//**** ATMEL AVR - A P P L I C A T I O N N O T E ************************ -//* -//* Title: AVR061 - STK500 Communication Protocol -//* Filename: command.h -//* Version: 1.0 -//* Last updated: 09.09.2002 -//* -//* Support E-mail: avr@atmel.com -//* -//************************************************************************** - -// *****************[ STK Message constants ]*************************** - -#define STK_SIGN_ON_MESSAGE "AVR STK" // Sign on string for Cmnd_STK_GET_SIGN_ON - -// *****************[ STK Response constants ]*************************** - -#define Resp_STK_OK 0x10 // ' ' -#define Resp_STK_FAILED 0x11 // ' ' -#define Resp_STK_UNKNOWN 0x12 // ' ' -#define Resp_STK_NODEVICE 0x13 // ' ' -#define Resp_STK_INSYNC 0x14 // ' ' -#define Resp_STK_NOSYNC 0x15 // ' ' - -#define Resp_ADC_CHANNEL_ERROR 0x16 // ' ' -#define Resp_ADC_MEASURE_OK 0x17 // ' ' -#define Resp_PWM_CHANNEL_ERROR 0x18 // ' ' -#define Resp_PWM_ADJUST_OK 0x19 // ' ' - -// *****************[ STK Special constants ]*************************** - -#define Sync_CRC_EOP 0x20 // 'SPACE' - -// *****************[ STK Command constants ]*************************** - -#define Cmnd_STK_GET_SYNC 0x30 // ' ' -#define Cmnd_STK_GET_SIGN_ON 0x31 // ' ' - -#define Cmnd_STK_SET_PARAMETER 0x40 // ' ' -#define Cmnd_STK_GET_PARAMETER 0x41 // ' ' -#define Cmnd_STK_SET_DEVICE 0x42 // ' ' -#define Cmnd_STK_SET_DEVICE_EXT 0x45 // ' ' - -#define Cmnd_STK_ENTER_PROGMODE 0x50 // ' ' -#define Cmnd_STK_LEAVE_PROGMODE 0x51 // ' ' -#define Cmnd_STK_CHIP_ERASE 0x52 // ' ' -#define Cmnd_STK_CHECK_AUTOINC 0x53 // ' ' -#define Cmnd_STK_LOAD_ADDRESS 0x55 // ' ' -#define Cmnd_STK_UNIVERSAL 0x56 // ' ' -#define Cmnd_STK_UNIVERSAL_MULTI 0x57 // ' ' - -#define Cmnd_STK_PROG_FLASH 0x60 // ' ' -#define Cmnd_STK_PROG_DATA 0x61 // ' ' -#define Cmnd_STK_PROG_FUSE 0x62 // ' ' -#define Cmnd_STK_PROG_LOCK 0x63 // ' ' -#define Cmnd_STK_PROG_PAGE 0x64 // ' ' -#define Cmnd_STK_PROG_FUSE_EXT 0x65 // ' ' - -#define Cmnd_STK_READ_FLASH 0x70 // ' ' -#define Cmnd_STK_READ_DATA 0x71 // ' ' -#define Cmnd_STK_READ_FUSE 0x72 // ' ' -#define Cmnd_STK_READ_LOCK 0x73 // ' ' -#define Cmnd_STK_READ_PAGE 0x74 // ' ' -#define Cmnd_STK_READ_SIGN 0x75 // ' ' -#define Cmnd_STK_READ_OSCCAL 0x76 // ' ' -#define Cmnd_STK_READ_FUSE_EXT 0x77 // ' ' -#define Cmnd_STK_READ_OSCCAL_EXT 0x78 // ' ' - -// *****************[ STK Parameter constants ]*************************** - -#define Parm_STK_HW_VER 0x80 // ' ' - R -#define Parm_STK_SW_MAJOR 0x81 // ' ' - R -#define Parm_STK_SW_MINOR 0x82 // ' ' - R -#define Parm_STK_LEDS 0x83 // ' ' - R/W -#define Parm_STK_VTARGET 0x84 // ' ' - R/W -#define Parm_STK_VADJUST 0x85 // ' ' - R/W -#define Parm_STK_OSC_PSCALE 0x86 // ' ' - R/W -#define Parm_STK_OSC_CMATCH 0x87 // ' ' - R/W -#define Parm_STK_RESET_DURATION 0x88 // ' ' - R/W -#define Parm_STK_SCK_DURATION 0x89 // ' ' - R/W - -#define Parm_STK_BUFSIZEL 0x90 // ' ' - R/W, Range {0..255} -#define Parm_STK_BUFSIZEH 0x91 // ' ' - R/W, Range {0..255} -#define Parm_STK_DEVICE 0x92 // ' ' - R/W, Range {0..255} -#define Parm_STK_PROGMODE 0x93 // ' ' - 'P' or 'S' -#define Parm_STK_PARAMODE 0x94 // ' ' - TRUE or FALSE -#define Parm_STK_POLLING 0x95 // ' ' - TRUE or FALSE -#define Parm_STK_SELFTIMED 0x96 // ' ' - TRUE or FALSE -#define Param_STK500_TOPCARD_DETECT 0x98 // ' ' - Detect top-card attached - -// *****************[ STK status bit definitions ]*************************** - -#define Stat_STK_INSYNC 0x01 // INSYNC status bit, '1' - INSYNC -#define Stat_STK_PROGMODE 0x02 // Programming mode, '1' - PROGMODE -#define Stat_STK_STANDALONE 0x04 // Standalone mode, '1' - SM mode -#define Stat_STK_RESET 0x08 // RESET button, '1' - Pushed -#define Stat_STK_PROGRAM 0x10 // Program button, ' 1' - Pushed -#define Stat_STK_LEDG 0x20 // Green LED status, '1' - Lit -#define Stat_STK_LEDR 0x40 // Red LED status, '1' - Lit -#define Stat_STK_LEDBLINK 0x80 // LED blink ON/OFF, '1' - Blink - - -// *****************************[ End Of COMMAND.H ]************************** diff --git a/lib/ESPiLight/pilight/libs/libuv/CMakeLists.txt b/lib/ESPiLight/pilight/libs/libuv/CMakeLists.txt deleted file mode 100644 index 7a2d7f8..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -project(libuv) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROJECT_SOURCE_DIR}/include/") - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -if(WIN32) - file(GLOB ${PROJECT_NAME}_sources ${${PROJECT_NAME}_sources} "${PROJECT_SOURCE_DIR}/win/*.c") - file(GLOB ${PROJECT_NAME}_headers ${${PROJECT_NAME}_headers} "${PROJECT_SOURCE_DIR}/win/*.h") -else() - file(GLOB ${PROJECT_NAME}_sources ${${PROJECT_NAME}_sources} "${PROJECT_SOURCE_DIR}/unix/*.c") - file(GLOB ${PROJECT_NAME}_headers ${${PROJECT_NAME}_headers} "${PROJECT_SOURCE_DIR}/unix/*.h") - - # Darwin only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/darwin-proctitle.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/fsevents.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/darwin.c") - # Sun only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/sunos.c") - # AIX only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/aix.c") - # OpenBSD only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/openbsd.c") - # NetBSD only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/netbsd.c") - # Android only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/android-ifaddrs.c") - # Cygwin only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/cygwin.c") - # OS390 only - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/os390.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/os390-syscalls.c") - # General - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/no-fsevents.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/no-proctitle.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/procfs-exepath.c") - # list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/posix-poll.c") - - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/pthread-barrier.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/linux-inotify.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/linux-core.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/proctitle.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/sunos.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/kqueue.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/freebsd.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/sysinfo-loadavg.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/sysinfo-memory.c") - # elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - # list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/pthread-barrier.c") - # list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/linux-inotify.c") - # list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/linux-core.c") - # list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/proctitle.c") - # list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/kqueue.c") - # list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/freebsd.c") - else() - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/posix-poll.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/posix-hrtime.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/kqueue.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/pthread-barrier.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/freebsd.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/bsd-ifaddrs.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/unix/sunos.c") - endif() -endif() - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/libuv/android-ifaddrs.h b/lib/ESPiLight/pilight/libs/libuv/android-ifaddrs.h deleted file mode 100644 index 9cd19fe..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/android-ifaddrs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1995, 1999 - * Berkeley Software Design, Inc. 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. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. - * - * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp - */ - -#ifndef _IFADDRS_H_ -#define _IFADDRS_H_ - -struct ifaddrs { - struct ifaddrs *ifa_next; - char *ifa_name; - unsigned int ifa_flags; - struct sockaddr *ifa_addr; - struct sockaddr *ifa_netmask; - struct sockaddr *ifa_dstaddr; - void *ifa_data; -}; - -/* - * This may have been defined in . Note that if is - * to be included it must be included before this header file. - */ -#ifndef ifa_broadaddr -#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ -#endif - -#include - -__BEGIN_DECLS -extern int getifaddrs(struct ifaddrs **ifap); -extern void freeifaddrs(struct ifaddrs *ifa); -__END_DECLS - -#endif diff --git a/lib/ESPiLight/pilight/libs/libuv/fs-poll.c b/lib/ESPiLight/pilight/libs/libuv/fs-poll.c deleted file mode 100644 index ee73d5a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/fs-poll.c +++ /dev/null @@ -1,256 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "uv-common.h" - -#include -#include -#include - -struct poll_ctx { - uv_fs_poll_t* parent_handle; /* NULL if parent has been stopped or closed */ - int busy_polling; - unsigned int interval; - uint64_t start_time; - uv_loop_t* loop; - uv_fs_poll_cb poll_cb; - uv_timer_t timer_handle; - uv_fs_t fs_req; /* TODO(bnoordhuis) mark fs_req internal */ - uv_stat_t statbuf; - char path[1]; /* variable length */ -}; - -static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b); -static void poll_cb(uv_fs_t* req); -static void timer_cb(uv_timer_t* timer); -static void timer_close_cb(uv_handle_t* handle); - -static uv_stat_t zero_statbuf; - - -int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_POLL); - return 0; -} - - -int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb cb, - const char* path, - unsigned int interval) { - struct poll_ctx* ctx; - uv_loop_t* loop; - size_t len; - int err; - - if (uv__is_active(handle)) - return 0; - - loop = handle->loop; - len = strlen(path); - ctx = uv__calloc(1, sizeof(*ctx) + len); - - if (ctx == NULL) - return UV_ENOMEM; - - ctx->loop = loop; - ctx->poll_cb = cb; - ctx->interval = interval ? interval : 1; - ctx->start_time = uv_now(loop); - ctx->parent_handle = handle; - memcpy(ctx->path, path, len + 1); - - err = uv_timer_init(loop, &ctx->timer_handle); - if (err < 0) - goto error; - - ctx->timer_handle.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&ctx->timer_handle); - - err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb); - if (err < 0) - goto error; - - handle->poll_ctx = ctx; - uv__handle_start(handle); - - return 0; - -error: - uv__free(ctx); - return err; -} - - -int uv_fs_poll_stop(uv_fs_poll_t* handle) { - struct poll_ctx* ctx; - - if (!uv__is_active(handle)) - return 0; - - ctx = handle->poll_ctx; - assert(ctx != NULL); - assert(ctx->parent_handle != NULL); - ctx->parent_handle = NULL; - handle->poll_ctx = NULL; - - /* Close the timer if it's active. If it's inactive, there's a stat request - * in progress and poll_cb will take care of the cleanup. - */ - if (uv__is_active(&ctx->timer_handle)) - uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); - - uv__handle_stop(handle); - - return 0; -} - - -int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) { - struct poll_ctx* ctx; - size_t required_len; - - if (!uv__is_active(handle)) { - *size = 0; - return UV_EINVAL; - } - - ctx = handle->poll_ctx; - assert(ctx != NULL); - - required_len = strlen(ctx->path); - if (required_len >= *size) { - *size = required_len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, ctx->path, required_len); - *size = required_len; - buffer[required_len] = '\0'; - - return 0; -} - - -void uv__fs_poll_close(uv_fs_poll_t* handle) { - uv_fs_poll_stop(handle); -} - - -static void timer_cb(uv_timer_t* timer) { - struct poll_ctx* ctx; - - ctx = container_of(timer, struct poll_ctx, timer_handle); - assert(ctx->parent_handle != NULL); - assert(ctx->parent_handle->poll_ctx == ctx); - ctx->start_time = uv_now(ctx->loop); - - if (uv_fs_stat(ctx->loop, &ctx->fs_req, ctx->path, poll_cb)) - abort(); -} - - -static void poll_cb(uv_fs_t* req) { - uv_stat_t* statbuf; - struct poll_ctx* ctx; - uint64_t interval; - - ctx = container_of(req, struct poll_ctx, fs_req); - - if (ctx->parent_handle == NULL) { /* handle has been stopped or closed */ - uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); - uv_fs_req_cleanup(req); - return; - } - - if (req->result != 0) { - if (ctx->busy_polling != req->result) { - ctx->poll_cb(ctx->parent_handle, - req->result, - &ctx->statbuf, - &zero_statbuf); - ctx->busy_polling = req->result; - } - goto out; - } - - statbuf = &req->statbuf; - - if (ctx->busy_polling != 0) - if (ctx->busy_polling < 0 || !statbuf_eq(&ctx->statbuf, statbuf)) - ctx->poll_cb(ctx->parent_handle, 0, &ctx->statbuf, statbuf); - - ctx->statbuf = *statbuf; - ctx->busy_polling = 1; - -out: - uv_fs_req_cleanup(req); - - if (ctx->parent_handle == NULL) { /* handle has been stopped by callback */ - uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); - return; - } - - /* Reschedule timer, subtract the delay from doing the stat(). */ - interval = ctx->interval; - interval -= (uv_now(ctx->loop) - ctx->start_time) % interval; - - if (uv_timer_start(&ctx->timer_handle, timer_cb, interval, 0)) - abort(); -} - - -static void timer_close_cb(uv_handle_t* handle) { - uv__free(container_of(handle, struct poll_ctx, timer_handle)); -} - - -static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b) { - return a->st_ctim.tv_nsec == b->st_ctim.tv_nsec - && a->st_mtim.tv_nsec == b->st_mtim.tv_nsec - && a->st_birthtim.tv_nsec == b->st_birthtim.tv_nsec - && a->st_ctim.tv_sec == b->st_ctim.tv_sec - && a->st_mtim.tv_sec == b->st_mtim.tv_sec - && a->st_birthtim.tv_sec == b->st_birthtim.tv_sec - && a->st_size == b->st_size - && a->st_mode == b->st_mode - && a->st_uid == b->st_uid - && a->st_gid == b->st_gid - && a->st_ino == b->st_ino - && a->st_dev == b->st_dev - && a->st_flags == b->st_flags - && a->st_gen == b->st_gen; -} - - -#if defined(_WIN32) - -#include "win/internal.h" -#include "win/handle-inl.h" - -void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); -} - -#endif /* _WIN32 */ diff --git a/lib/ESPiLight/pilight/libs/libuv/heap-inl.h b/lib/ESPiLight/pilight/libs/libuv/heap-inl.h deleted file mode 100644 index 1e2ed60..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/heap-inl.h +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or 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 THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. - */ - -#ifndef UV_SRC_HEAP_H_ -#define UV_SRC_HEAP_H_ - -#include /* NULL */ - -#if defined(__GNUC__) -# define HEAP_EXPORT(declaration) __attribute__((unused)) static declaration -#else -# define HEAP_EXPORT(declaration) static declaration -#endif - -struct heap_node { - struct heap_node* left; - struct heap_node* right; - struct heap_node* parent; -}; - -/* A binary min heap. The usual properties hold: the root is the lowest - * element in the set, the height of the tree is at most log2(nodes) and - * it's always a complete binary tree. - * - * The heap function try hard to detect corrupted tree nodes at the cost - * of a minor reduction in performance. Compile with -DNDEBUG to disable. - */ -struct heap { - struct heap_node* min; - unsigned int nelts; -}; - -/* Return non-zero if a < b. */ -typedef int (*heap_compare_fn)(const struct heap_node* a, - const struct heap_node* b); - -/* Public functions. */ -HEAP_EXPORT(void heap_init(struct heap* heap)); -HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap)); -HEAP_EXPORT(void heap_insert(struct heap* heap, - struct heap_node* newnode, - heap_compare_fn less_than)); -HEAP_EXPORT(void heap_remove(struct heap* heap, - struct heap_node* node, - heap_compare_fn less_than)); -HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than)); - -/* Implementation follows. */ - -HEAP_EXPORT(void heap_init(struct heap* heap)) { - heap->min = NULL; - heap->nelts = 0; -} - -HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap)) { - return heap->min; -} - -/* Swap parent with child. Child moves closer to the root, parent moves away. */ -static void heap_node_swap(struct heap* heap, - struct heap_node* parent, - struct heap_node* child) { - struct heap_node* sibling; - struct heap_node t; - - t = *parent; - *parent = *child; - *child = t; - - parent->parent = child; - if (child->left == child) { - child->left = parent; - sibling = child->right; - } else { - child->right = parent; - sibling = child->left; - } - if (sibling != NULL) - sibling->parent = child; - - if (parent->left != NULL) - parent->left->parent = parent; - if (parent->right != NULL) - parent->right->parent = parent; - - if (child->parent == NULL) - heap->min = child; - else if (child->parent->left == parent) - child->parent->left = child; - else - child->parent->right = child; -} - -HEAP_EXPORT(void heap_insert(struct heap* heap, - struct heap_node* newnode, - heap_compare_fn less_than)) { - struct heap_node** parent; - struct heap_node** child; - unsigned int path; - unsigned int n; - unsigned int k; - - newnode->left = NULL; - newnode->right = NULL; - newnode->parent = NULL; - - /* Calculate the path from the root to the insertion point. This is a min - * heap so we always insert at the left-most free node of the bottom row. - */ - path = 0; - for (k = 0, n = 1 + heap->nelts; n >= 2; k += 1, n /= 2) - path = (path << 1) | (n & 1); - - /* Now traverse the heap using the path we calculated in the previous step. */ - parent = child = &heap->min; - while (k > 0) { - parent = child; - if (path & 1) - child = &(*child)->right; - else - child = &(*child)->left; - path >>= 1; - k -= 1; - } - - /* Insert the new node. */ - newnode->parent = *parent; - *child = newnode; - heap->nelts += 1; - - /* Walk up the tree and check at each node if the heap property holds. - * It's a min heap so parent < child must be true. - */ - while (newnode->parent != NULL && less_than(newnode, newnode->parent)) - heap_node_swap(heap, newnode->parent, newnode); -} - -HEAP_EXPORT(void heap_remove(struct heap* heap, - struct heap_node* node, - heap_compare_fn less_than)) { - struct heap_node* smallest; - struct heap_node** max; - struct heap_node* child; - unsigned int path; - unsigned int k; - unsigned int n; - - if (heap->nelts == 0) - return; - - /* Calculate the path from the min (the root) to the max, the left-most node - * of the bottom row. - */ - path = 0; - for (k = 0, n = heap->nelts; n >= 2; k += 1, n /= 2) - path = (path << 1) | (n & 1); - - /* Now traverse the heap using the path we calculated in the previous step. */ - max = &heap->min; - while (k > 0) { - if (path & 1) - max = &(*max)->right; - else - max = &(*max)->left; - path >>= 1; - k -= 1; - } - - heap->nelts -= 1; - - /* Unlink the max node. */ - child = *max; - *max = NULL; - - if (child == node) { - /* We're removing either the max or the last node in the tree. */ - if (child == heap->min) { - heap->min = NULL; - } - return; - } - - /* Replace the to be deleted node with the max node. */ - child->left = node->left; - child->right = node->right; - child->parent = node->parent; - - if (child->left != NULL) { - child->left->parent = child; - } - - if (child->right != NULL) { - child->right->parent = child; - } - - if (node->parent == NULL) { - heap->min = child; - } else if (node->parent->left == node) { - node->parent->left = child; - } else { - node->parent->right = child; - } - - /* Walk down the subtree and check at each node if the heap property holds. - * It's a min heap so parent < child must be true. If the parent is bigger, - * swap it with the smallest child. - */ - for (;;) { - smallest = child; - if (child->left != NULL && less_than(child->left, smallest)) - smallest = child->left; - if (child->right != NULL && less_than(child->right, smallest)) - smallest = child->right; - if (smallest == child) - break; - heap_node_swap(heap, child, smallest); - } - - /* Walk up the subtree and check that each parent is less than the node - * this is required, because `max` node is not guaranteed to be the - * actual maximum in tree - */ - while (child->parent != NULL && less_than(child, child->parent)) - heap_node_swap(heap, child->parent, child); -} - -HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than)) { - heap_remove(heap, heap->min, less_than); -} - -#undef HEAP_EXPORT - -#endif /* UV_SRC_HEAP_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/inet.c b/lib/ESPiLight/pilight/libs/libuv/inet.c deleted file mode 100644 index da63a68..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/inet.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 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 ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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 -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#include "uv.h" -#include "uv-common.h" - -#define UV__INET_ADDRSTRLEN 16 -#define UV__INET6_ADDRSTRLEN 46 - - -static int inet_ntop4(const unsigned char *src, char *dst, size_t size); -static int inet_ntop6(const unsigned char *src, char *dst, size_t size); -static int inet_pton4(const char *src, unsigned char *dst); -static int inet_pton6(const char *src, unsigned char *dst); - - -int uv_inet_ntop(int af, const void* src, char* dst, size_t size) { - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); - case AF_INET6: - return (inet_ntop6(src, dst, size)); - default: - return UV_EAFNOSUPPORT; - } - /* NOTREACHED */ -} - - -static int inet_ntop4(const unsigned char *src, char *dst, size_t size) { - static const char fmt[] = "%u.%u.%u.%u"; - char tmp[UV__INET_ADDRSTRLEN]; - int l; - - l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]); - if (l <= 0 || (size_t) l >= size) { - return UV_ENOSPC; - } - strncpy(dst, tmp, size); - dst[size - 1] = '\0'; - return 0; -} - - -static int inet_ntop6(const unsigned 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[UV__INET6_ADDRSTRLEN], *tp; - struct { int base, len; } best, cur; - unsigned int words[sizeof(struct in6_addr) / sizeof(uint16_t)]; - 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 < (int) sizeof(struct in6_addr); i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - best.len = 0; - cur.base = -1; - cur.len = 0; - for (i = 0; i < (int) ARRAY_SIZE(words); 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) { - if (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 < (int) ARRAY_SIZE(words); 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 == 7 && words[7] != 0x0001) || - (best.len == 5 && words[5] == 0xffff))) { - int err = inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)); - if (err) - return err; - tp += strlen(tp); - break; - } - tp += sprintf(tp, "%x", words[i]); - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - return UV_ENOSPC; - } - strcpy(dst, tmp); - return 0; -} - - -int uv_inet_pton(int af, const char* src, void* dst) { - if (src == NULL || dst == NULL) - return UV_EINVAL; - - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); - case AF_INET6: { - int len; - char tmp[UV__INET6_ADDRSTRLEN], *s, *p; - s = (char*) src; - p = strchr(src, '%'); - if (p != NULL) { - s = tmp; - len = p - src; - if (len > UV__INET6_ADDRSTRLEN-1) - return UV_EINVAL; - memcpy(s, src, len); - s[len] = '\0'; - } - return inet_pton6(s, dst); - } - default: - return UV_EAFNOSUPPORT; - } - /* NOTREACHED */ -} - - -static int inet_pton4(const char *src, unsigned char *dst) { - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[sizeof(struct in_addr)], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int nw = *tp * 10 + (pch - digits); - - if (saw_digit && *tp == 0) - return UV_EINVAL; - if (nw > 255) - return UV_EINVAL; - *tp = nw; - if (!saw_digit) { - if (++octets > 4) - return UV_EINVAL; - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return UV_EINVAL; - *++tp = 0; - saw_digit = 0; - } else - return UV_EINVAL; - } - if (octets < 4) - return UV_EINVAL; - memcpy(dst, tmp, sizeof(struct in_addr)); - return 0; -} - - -static int inet_pton6(const char *src, unsigned char *dst) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[sizeof(struct in6_addr)], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, seen_xdigits; - unsigned int val; - - memset((tp = tmp), '\0', sizeof tmp); - endp = tp + sizeof tmp; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return UV_EINVAL; - curtok = src; - seen_xdigits = 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 (++seen_xdigits > 4) - return UV_EINVAL; - continue; - } - if (ch == ':') { - curtok = src; - if (!seen_xdigits) { - if (colonp) - return UV_EINVAL; - colonp = tp; - continue; - } else if (*src == '\0') { - return UV_EINVAL; - } - if (tp + sizeof(uint16_t) > endp) - return UV_EINVAL; - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - seen_xdigits = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + sizeof(struct in_addr)) <= endp)) { - int err = inet_pton4(curtok, tp); - if (err == 0) { - tp += sizeof(struct in_addr); - seen_xdigits = 0; - break; /*%< '\\0' was seen by inet_pton4(). */ - } - } - return UV_EINVAL; - } - if (seen_xdigits) { - if (tp + sizeof(uint16_t) > endp) - return UV_EINVAL; - *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; - - if (tp == endp) - return UV_EINVAL; - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return UV_EINVAL; - memcpy(dst, tmp, sizeof tmp); - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/pthread-barrier.h b/lib/ESPiLight/pilight/libs/libuv/pthread-barrier.h deleted file mode 100644 index 900ebed..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/pthread-barrier.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright (c) 2016, Kari Tristan Helgason - -Permission to use, copy, modify, and/or 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 THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. -*/ - -#ifndef _UV_PTHREAD_BARRIER_ -#define _UV_PTHREAD_BARRIER_ -#include -#include -#if !defined(__MVS__) -#include /* sem_t */ -#endif - -#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 - -/* - * To maintain ABI compatibility with - * libuv v1.x struct is padded according - * to target platform - */ -#if defined(__ANDROID__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - sizeof(pthread_cond_t) + \ - sizeof(unsigned int) - \ - sizeof(void *) -#elif defined(__APPLE__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - 2 * sizeof(sem_t) + \ - 2 * sizeof(unsigned int) - \ - sizeof(void *) -#else -# define UV_BARRIER_STRUCT_PADDING 0 -#endif - -typedef struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - unsigned threshold; - unsigned in; - unsigned out; -} _uv_barrier; - -typedef struct { - _uv_barrier* b; - char _pad[UV_BARRIER_STRUCT_PADDING]; -} pthread_barrier_t; - -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count); - -int pthread_barrier_wait(pthread_barrier_t* barrier); -int pthread_barrier_destroy(pthread_barrier_t *barrier); - -#endif /* _UV_PTHREAD_BARRIER_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/queue.h b/lib/ESPiLight/pilight/libs/libuv/queue.h deleted file mode 100644 index ff3540a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/queue.h +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or 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 THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. - */ - -#ifndef QUEUE_H_ -#define QUEUE_H_ - -#include - -typedef void *QUEUE[2]; - -/* Private macros. */ -#define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0])) -#define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1])) -#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q))) -#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) - -/* Public macros. */ -#define QUEUE_DATA(ptr, type, field) \ - ((type *) ((char *) (ptr) - offsetof(type, field))) - -/* Important note: mutating the list while QUEUE_FOREACH is - * iterating over its elements results in undefined behavior. - */ -#define QUEUE_FOREACH(q, h) \ - for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q)) - -#define QUEUE_EMPTY(q) \ - ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q)) - -#define QUEUE_HEAD(q) \ - (QUEUE_NEXT(q)) - -#define QUEUE_INIT(q) \ - do { \ - QUEUE_NEXT(q) = (q); \ - QUEUE_PREV(q) = (q); \ - } \ - while (0) - -#define QUEUE_ADD(h, n) \ - do { \ - QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ - QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ - QUEUE_PREV(h) = QUEUE_PREV(n); \ - QUEUE_PREV_NEXT(h) = (h); \ - } \ - while (0) - -#define QUEUE_SPLIT(h, q, n) \ - do { \ - QUEUE_PREV(n) = QUEUE_PREV(h); \ - QUEUE_PREV_NEXT(n) = (n); \ - QUEUE_NEXT(n) = (q); \ - QUEUE_PREV(h) = QUEUE_PREV(q); \ - QUEUE_PREV_NEXT(h) = (h); \ - QUEUE_PREV(q) = (n); \ - } \ - while (0) - -#define QUEUE_MOVE(h, n) \ - do { \ - if (QUEUE_EMPTY(h)) \ - QUEUE_INIT(n); \ - else { \ - QUEUE* q = QUEUE_HEAD(h); \ - QUEUE_SPLIT(h, q, n); \ - } \ - } \ - while (0) - -#define QUEUE_INSERT_HEAD(h, q) \ - do { \ - QUEUE_NEXT(q) = QUEUE_NEXT(h); \ - QUEUE_PREV(q) = (h); \ - QUEUE_NEXT_PREV(q) = (q); \ - QUEUE_NEXT(h) = (q); \ - } \ - while (0) - -#define QUEUE_INSERT_TAIL(h, q) \ - do { \ - QUEUE_NEXT(q) = (h); \ - QUEUE_PREV(q) = QUEUE_PREV(h); \ - QUEUE_PREV_NEXT(q) = (q); \ - QUEUE_PREV(h) = (q); \ - } \ - while (0) - -#define QUEUE_REMOVE(q) \ - do { \ - QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \ - QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \ - } \ - while (0) - -#endif /* QUEUE_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/stdint-msvc2008.h b/lib/ESPiLight/pilight/libs/libuv/stdint-msvc2008.h deleted file mode 100644 index d02608a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/stdint-msvc2008.h +++ /dev/null @@ -1,247 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// 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. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/lib/ESPiLight/pilight/libs/libuv/threadpool.c b/lib/ESPiLight/pilight/libs/libuv/threadpool.c deleted file mode 100644 index 7d80b89..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/threadpool.c +++ /dev/null @@ -1,366 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv-common.h" - -#include "../libs/pilight/core/pilight.h" -#include "../libs/pilight/core/proc.h" - -#if !defined(_WIN32) -# include "unix/internal.h" -#endif - -#include - -#define MAX_THREADPOOL_SIZE 128 - -static uv_once_t once = UV_ONCE_INIT; -static uv_cond_t cond; -static uv_mutex_t mutex; -static unsigned int idle_threads; -static unsigned int nthreads; -static uv_thread_t* threads; -static uv_thread_t default_threads[4]; -static QUEUE exit_message; -static QUEUE wq; -static volatile int initialized; - -typedef struct data_t { - int nr; - - struct { - struct timespec first; - struct timespec second; - } timestamp; - - struct cpu_usage_t cpu_usage; -} data_t; - -static void uv__cancelled(struct uv__work* w) { - abort(); -} - - -/* To avoid deadlock with uv_cancel() it's crucial that the worker - * never holds the global mutex and the loop-local mutex at the same time. - */ -static void worker(void* arg) { - struct uv__work* w; - QUEUE* q; - -#ifndef _WIN32 - struct data_t *data = arg; -#endif - - for (;;) { - uv_mutex_lock(&mutex); - - while (QUEUE_EMPTY(&wq)) { - idle_threads += 1; - uv_cond_wait(&cond, &mutex); - idle_threads -= 1; - } - - q = QUEUE_HEAD(&wq); - - if (q == &exit_message) - uv_cond_signal(&cond); - else { - QUEUE_REMOVE(q); - QUEUE_INIT(q); /* Signal uv_cancel() that the work req is - executing. */ - } - - uv_mutex_unlock(&mutex); - - if (q == &exit_message) - break; - - w = QUEUE_DATA(q, struct uv__work, wq); -#ifndef _WIN32 - if(pilight.debuglevel >= 2) { - getThreadCPUUsage(pthread_self(), &data->cpu_usage); - clock_gettime(CLOCK_MONOTONIC, &data->timestamp.first); - } -#endif - w->work(w); - -#ifndef _WIN32 - if(pilight.debuglevel >= 2) { - clock_gettime(CLOCK_MONOTONIC, &data->timestamp.second); - getThreadCPUUsage(pthread_self(), &data->cpu_usage); - fprintf(stderr, "worker %d, executed %s in %.6f sec using %f%% CPU\n", - data->nr, - w->name, - ((double)data->timestamp.second.tv_sec + 1.0e-9*data->timestamp.second.tv_nsec) - - ((double)data->timestamp.first.tv_sec + 1.0e-9*data->timestamp.first.tv_nsec), - data->cpu_usage.cpu_per - ); - } -#endif - - // free(w->name); - uv_mutex_lock(&w->loop->wq_mutex); - w->work = NULL; /* Signal uv_cancel() that the work req is done - executing. */ - QUEUE_INSERT_TAIL(&w->loop->wq, &w->wq); - uv_async_send(&w->loop->wq_async); - uv_mutex_unlock(&w->loop->wq_mutex); - } -#ifndef _WIN32 - free(data); -#endif -} - - -static void post(QUEUE* q) { - uv_mutex_lock(&mutex); - QUEUE_INSERT_TAIL(&wq, q); - if (idle_threads > 0) - uv_cond_signal(&cond); - uv_mutex_unlock(&mutex); -} - - -#ifndef _WIN32 -UV_DESTRUCTOR(static void cleanup(void)) { - unsigned int i; - - if (initialized == 0) - return; - - post(&exit_message); - - for (i = 0; i < nthreads; i++) - if (uv_thread_join(threads + i)) - abort(); - - if (threads != default_threads) - uv__free(threads); - - uv_mutex_destroy(&mutex); - uv_cond_destroy(&cond); - - threads = NULL; - nthreads = 0; - initialized = 0; -} -#endif - - -static void init_threads(void) { - unsigned int i; - const char* val; - - nthreads = ARRAY_SIZE(default_threads); - val = getenv("UV_THREADPOOL_SIZE"); - if (val != NULL) - nthreads = atoi(val); - if (nthreads == 0) - nthreads = 1; - if (nthreads > MAX_THREADPOOL_SIZE) - nthreads = MAX_THREADPOOL_SIZE; - - threads = default_threads; - if (nthreads > ARRAY_SIZE(default_threads)) { - threads = uv__malloc(nthreads * sizeof(threads[0])); - if (threads == NULL) { - nthreads = ARRAY_SIZE(default_threads); - threads = default_threads; - } - } - - if (uv_cond_init(&cond)) - abort(); - - if (uv_mutex_init(&mutex)) - abort(); - - QUEUE_INIT(&wq); - - for (i = 0; i < nthreads; i++) { -#ifndef _WIN32 - struct data_t *data = malloc(sizeof(struct data_t)); - memset(data, '\0', sizeof(struct data_t)); - data->nr = i; - if (uv_thread_create(threads + i, worker, data)) - abort(); -#else - if (uv_thread_create(threads + i, worker, NULL)) - abort(); -#endif - } - - initialized = 1; -} - - -#ifndef _WIN32 -static void reset_once(void) { - uv_once_t child_once = UV_ONCE_INIT; - memcpy(&once, &child_once, sizeof(child_once)); -} -#endif - - -static void init_once(void) { -#ifndef _WIN32 - /* Re-initialize the threadpool after fork. - * Note that this discards the global mutex and condition as well - * as the work queue. - */ - if (pthread_atfork(NULL, NULL, &reset_once)) - abort(); -#endif - init_threads(); -} - - -void uv__work_submit(uv_loop_t* loop, - struct uv__work* w, - void (*work)(struct uv__work* w), - void (*done)(struct uv__work* w, int status)) { - uv_once(&once, init_once); - w->loop = loop; - w->work = work; - w->done = done; - post(&w->wq); -} - - -static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) { - int cancelled; - - uv_mutex_lock(&mutex); - uv_mutex_lock(&w->loop->wq_mutex); - - cancelled = !QUEUE_EMPTY(&w->wq) && w->work != NULL; - if (cancelled) - QUEUE_REMOVE(&w->wq); - - uv_mutex_unlock(&w->loop->wq_mutex); - uv_mutex_unlock(&mutex); - - if (!cancelled) - return UV_EBUSY; - - w->work = uv__cancelled; - uv_mutex_lock(&loop->wq_mutex); - QUEUE_INSERT_TAIL(&loop->wq, &w->wq); - uv_async_send(&loop->wq_async); - uv_mutex_unlock(&loop->wq_mutex); - - return 0; -} - - -void uv__work_done(uv_async_t* handle) { - struct uv__work* w; - uv_loop_t* loop; - QUEUE* q; - QUEUE wq; - int err; - - loop = container_of(handle, uv_loop_t, wq_async); - uv_mutex_lock(&loop->wq_mutex); - QUEUE_MOVE(&loop->wq, &wq); - uv_mutex_unlock(&loop->wq_mutex); - - while (!QUEUE_EMPTY(&wq)) { - q = QUEUE_HEAD(&wq); - QUEUE_REMOVE(q); - - w = container_of(q, struct uv__work, wq); - err = (w->work == uv__cancelled) ? UV_ECANCELED : 0; - w->done(w, err); - } -} - - -static void uv__queue_work(struct uv__work* w) { - uv_work_t* req = container_of(w, uv_work_t, work_req); - - req->work_cb(req); -} - - -static void uv__queue_done(struct uv__work* w, int err) { - uv_work_t* req; - - req = container_of(w, uv_work_t, work_req); - if(QUEUE_EMPTY(&(req->loop)->active_reqs) != 0) { - printf("-- %s --\n", w->name); - } - free(w->name); - uv__req_unregister(req->loop, req); - - if (req->after_work_cb == NULL) - return; - - req->after_work_cb(req, err); -} - - -int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - char *name, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb) { - if (work_cb == NULL) - return UV_EINVAL; - - uv__req_init(loop, req, UV_WORK); - req->loop = loop; - req->work_cb = work_cb; - req->after_work_cb = after_work_cb; - req->work_req.name = strdup(name); - uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done); - return 0; -} - - -int uv_cancel(uv_req_t* req) { - struct uv__work* wreq; - uv_loop_t* loop; - - switch (req->type) { - case UV_FS: - loop = ((uv_fs_t*) req)->loop; - wreq = &((uv_fs_t*) req)->work_req; - break; - case UV_GETADDRINFO: - loop = ((uv_getaddrinfo_t*) req)->loop; - wreq = &((uv_getaddrinfo_t*) req)->work_req; - break; - case UV_GETNAMEINFO: - loop = ((uv_getnameinfo_t*) req)->loop; - wreq = &((uv_getnameinfo_t*) req)->work_req; - break; - case UV_WORK: - loop = ((uv_work_t*) req)->loop; - wreq = &((uv_work_t*) req)->work_req; - break; - default: - return UV_EINVAL; - } - - return uv__work_cancel(loop, req, wreq); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/threadpool.c.ori b/lib/ESPiLight/pilight/libs/libuv/threadpool.c.ori deleted file mode 100644 index 1089341..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/threadpool.c.ori +++ /dev/null @@ -1,312 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv-common.h" - -#if !defined(_WIN32) -# include "unix/internal.h" -#endif - -#include - -#define MAX_THREADPOOL_SIZE 128 - -static uv_once_t once = UV_ONCE_INIT; -static uv_cond_t cond; -static uv_mutex_t mutex; -static unsigned int idle_threads; -static unsigned int nthreads; -static uv_thread_t* threads; -static uv_thread_t default_threads[4]; -static QUEUE exit_message; -static QUEUE wq; -static volatile int initialized; - - -static void uv__cancelled(struct uv__work* w) { - abort(); -} - - -/* To avoid deadlock with uv_cancel() it's crucial that the worker - * never holds the global mutex and the loop-local mutex at the same time. - */ -static void worker(void* arg) { - struct uv__work* w; - QUEUE* q; - - (void) arg; - - for (;;) { - uv_mutex_lock(&mutex); - - while (QUEUE_EMPTY(&wq)) { - idle_threads += 1; - uv_cond_wait(&cond, &mutex); - idle_threads -= 1; - } - - q = QUEUE_HEAD(&wq); - - if (q == &exit_message) - uv_cond_signal(&cond); - else { - QUEUE_REMOVE(q); - QUEUE_INIT(q); /* Signal uv_cancel() that the work req is - executing. */ - } - - uv_mutex_unlock(&mutex); - - if (q == &exit_message) - break; - - w = QUEUE_DATA(q, struct uv__work, wq); - w->work(w); - - uv_mutex_lock(&w->loop->wq_mutex); - w->work = NULL; /* Signal uv_cancel() that the work req is done - executing. */ - QUEUE_INSERT_TAIL(&w->loop->wq, &w->wq); - uv_async_send(&w->loop->wq_async); - uv_mutex_unlock(&w->loop->wq_mutex); - } -} - - -static void post(QUEUE* q) { - uv_mutex_lock(&mutex); - QUEUE_INSERT_TAIL(&wq, q); - if (idle_threads > 0) - uv_cond_signal(&cond); - uv_mutex_unlock(&mutex); -} - - -#ifndef _WIN32 -UV_DESTRUCTOR(static void cleanup(void)) { - unsigned int i; - - if (initialized == 0) - return; - - post(&exit_message); - - for (i = 0; i < nthreads; i++) - if (uv_thread_join(threads + i)) - abort(); - - if (threads != default_threads) - uv__free(threads); - - uv_mutex_destroy(&mutex); - uv_cond_destroy(&cond); - - threads = NULL; - nthreads = 0; - initialized = 0; -} -#endif - - -static void init_threads(void) { - unsigned int i; - const char* val; - - nthreads = ARRAY_SIZE(default_threads); - val = getenv("UV_THREADPOOL_SIZE"); - if (val != NULL) - nthreads = atoi(val); - if (nthreads == 0) - nthreads = 1; - if (nthreads > MAX_THREADPOOL_SIZE) - nthreads = MAX_THREADPOOL_SIZE; - - threads = default_threads; - if (nthreads > ARRAY_SIZE(default_threads)) { - threads = uv__malloc(nthreads * sizeof(threads[0])); - if (threads == NULL) { - nthreads = ARRAY_SIZE(default_threads); - threads = default_threads; - } - } - - if (uv_cond_init(&cond)) - abort(); - - if (uv_mutex_init(&mutex)) - abort(); - - QUEUE_INIT(&wq); - - for (i = 0; i < nthreads; i++) - if (uv_thread_create(threads + i, worker, NULL)) - abort(); - - initialized = 1; -} - - -#ifndef _WIN32 -static void reset_once(void) { - uv_once_t child_once = UV_ONCE_INIT; - memcpy(&once, &child_once, sizeof(child_once)); -} -#endif - - -static void init_once(void) { -#ifndef _WIN32 - /* Re-initialize the threadpool after fork. - * Note that this discards the global mutex and condition as well - * as the work queue. - */ - if (pthread_atfork(NULL, NULL, &reset_once)) - abort(); -#endif - init_threads(); -} - - -void uv__work_submit(uv_loop_t* loop, - struct uv__work* w, - void (*work)(struct uv__work* w), - void (*done)(struct uv__work* w, int status)) { - uv_once(&once, init_once); - w->loop = loop; - w->work = work; - w->done = done; - post(&w->wq); -} - - -static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) { - int cancelled; - - uv_mutex_lock(&mutex); - uv_mutex_lock(&w->loop->wq_mutex); - - cancelled = !QUEUE_EMPTY(&w->wq) && w->work != NULL; - if (cancelled) - QUEUE_REMOVE(&w->wq); - - uv_mutex_unlock(&w->loop->wq_mutex); - uv_mutex_unlock(&mutex); - - if (!cancelled) - return UV_EBUSY; - - w->work = uv__cancelled; - uv_mutex_lock(&loop->wq_mutex); - QUEUE_INSERT_TAIL(&loop->wq, &w->wq); - uv_async_send(&loop->wq_async); - uv_mutex_unlock(&loop->wq_mutex); - - return 0; -} - - -void uv__work_done(uv_async_t* handle) { - struct uv__work* w; - uv_loop_t* loop; - QUEUE* q; - QUEUE wq; - int err; - - loop = container_of(handle, uv_loop_t, wq_async); - uv_mutex_lock(&loop->wq_mutex); - QUEUE_MOVE(&loop->wq, &wq); - uv_mutex_unlock(&loop->wq_mutex); - - while (!QUEUE_EMPTY(&wq)) { - q = QUEUE_HEAD(&wq); - QUEUE_REMOVE(q); - - w = container_of(q, struct uv__work, wq); - err = (w->work == uv__cancelled) ? UV_ECANCELED : 0; - w->done(w, err); - } -} - - -static void uv__queue_work(struct uv__work* w) { - uv_work_t* req = container_of(w, uv_work_t, work_req); - - req->work_cb(req); -} - - -static void uv__queue_done(struct uv__work* w, int err) { - uv_work_t* req; - - req = container_of(w, uv_work_t, work_req); - uv__req_unregister(req->loop, req); - - if (req->after_work_cb == NULL) - return; - - req->after_work_cb(req, err); -} - - -int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb) { - if (work_cb == NULL) - return UV_EINVAL; - - uv__req_init(loop, req, UV_WORK); - req->loop = loop; - req->work_cb = work_cb; - req->after_work_cb = after_work_cb; - uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done); - return 0; -} - - -int uv_cancel(uv_req_t* req) { - struct uv__work* wreq; - uv_loop_t* loop; - - switch (req->type) { - case UV_FS: - loop = ((uv_fs_t*) req)->loop; - wreq = &((uv_fs_t*) req)->work_req; - break; - case UV_GETADDRINFO: - loop = ((uv_getaddrinfo_t*) req)->loop; - wreq = &((uv_getaddrinfo_t*) req)->work_req; - break; - case UV_GETNAMEINFO: - loop = ((uv_getnameinfo_t*) req)->loop; - wreq = &((uv_getnameinfo_t*) req)->work_req; - break; - case UV_WORK: - loop = ((uv_work_t*) req)->loop; - wreq = &((uv_work_t*) req)->work_req; - break; - default: - return UV_EINVAL; - } - - return uv__work_cancel(loop, req, wreq); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/threadpool.patch b/lib/ESPiLight/pilight/libs/libuv/threadpool.patch deleted file mode 100644 index 03b08a8..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/threadpool.patch +++ /dev/null @@ -1,136 +0,0 @@ ---- uv.h 2017-06-27 11:20:03.336712000 +0200 -+++ uv.h 2017-06-27 11:32:42.786153181 +0200 -@@ -974,6 +974,7 @@ - - UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, -+ char *name, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - ---- uv-threadpool.h 2017-06-27 11:15:32.716593000 +0200 -+++ uv-threadpool.h 2017-06-27 11:34:19.966961233 +0200 -@@ -28,6 +28,7 @@ - #define UV_THREADPOOL_H_ - - struct uv__work { -+ char *name; - void (*work)(struct uv__work *w); - void (*done)(struct uv__work *w, int status); - struct uv_loop_s* loop; ---- threadpool.c 2017-06-27 11:15:32.719162000 +0200 -+++ threadpool.c 2017-06-27 11:33:06.220654218 +0200 -@@ -21,6 +21,9 @@ - - #include "uv-common.h" - -+#include "../libs/pilight/core/pilight.h" -+#include "../libs/pilight/core/proc.h" -+ - #if !defined(_WIN32) - # include "unix/internal.h" - #endif -@@ -40,6 +43,16 @@ - static QUEUE wq; - static volatile int initialized; - -+typedef struct data_t { -+ int nr; -+ -+ struct { -+ struct timespec first; -+ struct timespec second; -+ } timestamp; -+ -+ struct cpu_usage_t cpu_usage; -+} data_t; - - static void uv__cancelled(struct uv__work* w) { - abort(); -@@ -53,7 +66,9 @@ - struct uv__work* w; - QUEUE* q; - -- (void) arg; -+#ifndef _WIN32 -+ struct data_t *data = arg; -+#endif - - for (;;) { - uv_mutex_lock(&mutex); -@@ -80,8 +95,29 @@ - break; - - w = QUEUE_DATA(q, struct uv__work, wq); -+#ifndef _WIN32 -+ if(pilight.debuglevel >= 2) { -+ getThreadCPUUsage(pthread_self(), &data->cpu_usage); -+ clock_gettime(CLOCK_MONOTONIC, &data->timestamp.first); -+ } -+#endif - w->work(w); - -+#ifndef _WIN32 -+ if(pilight.debuglevel >= 2) { -+ clock_gettime(CLOCK_MONOTONIC, &data->timestamp.second); -+ getThreadCPUUsage(pthread_self(), &data->cpu_usage); -+ fprintf(stderr, "worker %d, executed %s in %.6f sec using %f%% CPU\n", -+ data->nr, -+ w->name, -+ ((double)data->timestamp.second.tv_sec + 1.0e-9*data->timestamp.second.tv_nsec) - -+ ((double)data->timestamp.first.tv_sec + 1.0e-9*data->timestamp.first.tv_nsec), -+ data->cpu_usage.cpu_per -+ ); -+ } -+#endif -+ -+ free(w->name); - uv_mutex_lock(&w->loop->wq_mutex); - w->work = NULL; /* Signal uv_cancel() that the work req is done - executing. */ -@@ -89,6 +125,9 @@ - uv_async_send(&w->loop->wq_async); - uv_mutex_unlock(&w->loop->wq_mutex); - } -+#ifndef _WIN32 -+ free(data); -+#endif - } - - -@@ -157,9 +196,18 @@ - - QUEUE_INIT(&wq); - -- for (i = 0; i < nthreads; i++) -+ for (i = 0; i < nthreads; i++) { -+#ifndef _WIN32 -+ struct data_t *data = malloc(sizeof(struct data_t)); -+ memset(data, '\0', sizeof(struct data_t)); -+ data->nr = i; -+ if (uv_thread_create(threads + i, worker, data)) -+ abort(); -+#else - if (uv_thread_create(threads + i, worker, NULL)) - abort(); -+#endif -+ } - - initialized = 1; - } -@@ -269,6 +317,7 @@ - - int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, -+ char *name, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb) { - if (work_cb == NULL) -@@ -278,6 +327,7 @@ - req->loop = loop; - req->work_cb = work_cb; - req->after_work_cb = after_work_cb; -+ req->work_req.name = strdup(name); - uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done); - return 0; - } diff --git a/lib/ESPiLight/pilight/libs/libuv/tree.h b/lib/ESPiLight/pilight/libs/libuv/tree.h deleted file mode 100644 index f936416..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/tree.h +++ /dev/null @@ -1,768 +0,0 @@ -/*- - * Copyright 2002 Niels Provos - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - */ - -#ifndef UV_TREE_H_ -#define UV_TREE_H_ - -#ifndef UV__UNUSED -# if __GNUC__ -# define UV__UNUSED __attribute__((unused)) -# else -# define UV__UNUSED -# endif -#endif - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while (1) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-black tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) do {} while (0) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ -attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ -attr struct type *name##_RB_INSERT(struct name *, struct type *); \ -attr struct type *name##_RB_FIND(struct name *, struct type *); \ -attr struct type *name##_RB_NFIND(struct name *, struct type *); \ -attr struct type *name##_RB_NEXT(struct type *); \ -attr struct type *name##_RB_PREV(struct type *); \ -attr struct type *name##_RB_MINMAX(struct name *, int); \ - \ - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp,) -#define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) != NULL && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} \ - \ -attr void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \ - struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)) \ - != NULL) \ - RB_COLOR(oleft, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)) \ - != NULL) \ - RB_COLOR(oright, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} \ - \ -attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field)) != NULL) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old) \ - RB_LEFT(RB_PARENT(old, field), field) = elm; \ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm; \ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field)) != NULL); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - \ -/* Inserts a node into the RB tree */ \ -attr struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} \ - \ -/* Finds the node with the same key as elm */ \ -attr struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} \ - \ -/* Finds the first node greater than or equal to the search key */ \ -attr struct type * \ -name##_RB_NFIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *res = NULL; \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) { \ - res = tmp; \ - tmp = RB_LEFT(tmp, field); \ - } \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (res); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_PREV(struct type *elm) \ -{ \ - if (RB_LEFT(elm, field)) { \ - elm = RB_LEFT(elm, field); \ - while (RB_RIGHT(elm, field)) \ - elm = RB_RIGHT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -attr struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_PREV(name, x, y) name##_RB_PREV(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#define RB_FOREACH_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_SAFE(x, name, head, y) \ - for ((x) = RB_MIN(name, head); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE(x, name, head) \ - for ((x) = RB_MAX(name, head); \ - (x) != NULL; \ - (x) = name##_RB_PREV(x)) - -#define RB_FOREACH_REVERSE_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ - for ((x) = RB_MAX(name, head); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#endif /* UV_TREE_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/aix.c b/lib/ESPiLight/pilight/libs/libuv/unix/aix.c deleted file mode 100644 index 388c9cc..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/aix.c +++ /dev/null @@ -1,1243 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#ifdef HAVE_SYS_AHAFS_EVPRODS_H -#include -#endif - -#include -#include -#include -#include -#include - -#define RDWR_BUF_SIZE 4096 -#define EQ(a,b) (strcmp(a,b) == 0) - -static void* args_mem = NULL; -static char** process_argv = NULL; -static int process_argc = 0; -static char* process_title_ptr = NULL; - -int uv__platform_loop_init(uv_loop_t* loop) { - loop->fs_fd = -1; - - /* Passing maxfd of -1 should mean the limit is determined - * by the user's ulimit or the global limit as per the doc */ - loop->backend_fd = pollset_create(-1); - - if (loop->backend_fd == -1) - return -1; - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->fs_fd != -1) { - uv__close(loop->fs_fd); - loop->fs_fd = -1; - } - - if (loop->backend_fd != -1) { - pollset_destroy(loop->backend_fd); - loop->backend_fd = -1; - } -} - - -int uv__io_fork(uv_loop_t* loop) { - uv__platform_loop_delete(loop); - - return uv__platform_loop_init(loop); -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct poll_ctl pc; - - pc.events = POLLIN; - pc.cmd = PS_MOD; /* Equivalent to PS_ADD if the fd is not in the pollset. */ - pc.fd = fd; - - if (pollset_ctl(loop->backend_fd, &pc, 1)) - return -errno; - - pc.cmd = PS_DELETE; - if (pollset_ctl(loop->backend_fd, &pc, 1)) - abort(); - - return 0; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - struct pollfd events[1024]; - struct pollfd pqry; - struct pollfd* pe; - struct poll_ctl pc; - QUEUE* q; - uv__io_t* w; - uint64_t base; - uint64_t diff; - int have_signals; - int nevents; - int count; - int nfds; - int i; - int rc; - int add_failed; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - pc.events = w->pevents; - pc.fd = w->fd; - - add_failed = 0; - if (w->events == 0) { - pc.cmd = PS_ADD; - if (pollset_ctl(loop->backend_fd, &pc, 1)) { - if (errno != EINVAL) { - assert(0 && "Failed to add file descriptor (pc.fd) to pollset"); - abort(); - } - /* Check if the fd is already in the pollset */ - pqry.fd = pc.fd; - rc = pollset_query(loop->backend_fd, &pqry); - switch (rc) { - case -1: - assert(0 && "Failed to query pollset for file descriptor"); - abort(); - case 0: - assert(0 && "Pollset does not contain file descriptor"); - abort(); - } - /* If we got here then the pollset already contained the file descriptor even though - * we didn't think it should. This probably shouldn't happen, but we can continue. */ - add_failed = 1; - } - } - if (w->events != 0 || add_failed) { - /* Modify, potentially removing events -- need to delete then add. - * Could maybe mod if we knew for sure no events are removed, but - * content of w->events is handled above as not reliable (falls back) - * so may require a pollset_query() which would have to be pretty cheap - * compared to a PS_DELETE to be worth optimizing. Alternatively, could - * lazily remove events, squelching them in the mean time. */ - pc.cmd = PS_DELETE; - if (pollset_ctl(loop->backend_fd, &pc, 1)) { - assert(0 && "Failed to delete file descriptor (pc.fd) from pollset"); - abort(); - } - pc.cmd = PS_ADD; - if (pollset_ctl(loop->backend_fd, &pc, 1)) { - assert(0 && "Failed to add file descriptor (pc.fd) to pollset"); - abort(); - } - } - - w->events = w->pevents; - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - - for (;;) { - nfds = pollset_poll(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - if (nfds == -1) { - if (errno != EINTR) { - abort(); - } - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - - for (i = 0; i < nfds; i++) { - pe = events + i; - pc.cmd = PS_DELETE; - pc.fd = pe->fd; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (pc.fd == -1) - continue; - - assert(pc.fd >= 0); - assert((unsigned) pc.fd < loop->nwatchers); - - w = loop->watchers[pc.fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. - * - * Ignore all errors because we may be racing with another thread - * when the file descriptor is closed. - */ - pollset_ctl(loop->backend_fd, &pc, 1); - continue; - } - - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, pe->revents); - - nevents++; - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - diff = loop->time - base; - if (diff >= (uint64_t) timeout) - return; - - timeout -= diff; - } -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - uint64_t G = 1000000000; - timebasestruct_t t; - read_wall_time(&t, TIMEBASE_SZ); - time_base_to_time(&t, TIMEBASE_SZ); - return (uint64_t) t.tb_high * G + t.tb_low; -} - - -/* - * We could use a static buffer for the path manipulations that we need outside - * of the function, but this function could be called by multiple consumers and - * we don't want to potentially create a race condition in the use of snprintf. - * There is no direct way of getting the exe path in AIX - either through /procfs - * or through some libc APIs. The below approach is to parse the argv[0]'s pattern - * and use it in conjunction with PATH environment variable to craft one. - */ -int uv_exepath(char* buffer, size_t* size) { - int res; - char args[PATH_MAX]; - char abspath[PATH_MAX]; - size_t abspath_size; - struct procsinfo pi; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - pi.pi_pid = getpid(); - res = getargs(&pi, sizeof(pi), args, sizeof(args)); - if (res < 0) - return -EINVAL; - - /* - * Possibilities for args: - * i) an absolute path such as: /home/user/myprojects/nodejs/node - * ii) a relative path such as: ./node or ../myprojects/nodejs/node - * iii) a bare filename such as "node", after exporting PATH variable - * to its location. - */ - - /* Case i) and ii) absolute or relative paths */ - if (strchr(args, '/') != NULL) { - if (realpath(args, abspath) != abspath) - return -errno; - - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; - } else { - /* Case iii). Search PATH environment variable */ - char trypath[PATH_MAX]; - char *clonedpath = NULL; - char *token = NULL; - char *path = getenv("PATH"); - - if (path == NULL) - return -EINVAL; - - clonedpath = uv__strdup(path); - if (clonedpath == NULL) - return -ENOMEM; - - token = strtok(clonedpath, ":"); - while (token != NULL) { - snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, args); - if (realpath(trypath, abspath) == abspath) { - /* Check the match is executable */ - if (access(abspath, X_OK) == 0) { - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - uv__free(clonedpath); - return 0; - } - } - token = strtok(NULL, ":"); - } - uv__free(clonedpath); - - /* Out of tokens (path entries), and no match found */ - return -EINVAL; - } -} - - -uint64_t uv_get_free_memory(void) { - perfstat_memory_total_t mem_total; - int result = perfstat_memory_total(NULL, &mem_total, sizeof(mem_total), 1); - if (result == -1) { - return 0; - } - return mem_total.real_free * 4096; -} - - -uint64_t uv_get_total_memory(void) { - perfstat_memory_total_t mem_total; - int result = perfstat_memory_total(NULL, &mem_total, sizeof(mem_total), 1); - if (result == -1) { - return 0; - } - return mem_total.real_total * 4096; -} - - -void uv_loadavg(double avg[3]) { - perfstat_cpu_total_t ps_total; - int result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1); - if (result == -1) { - avg[0] = 0.; avg[1] = 0.; avg[2] = 0.; - return; - } - avg[0] = ps_total.loadavg[0] / (double)(1 << SBITS); - avg[1] = ps_total.loadavg[1] / (double)(1 << SBITS); - avg[2] = ps_total.loadavg[2] / (double)(1 << SBITS); -} - - -#ifdef HAVE_SYS_AHAFS_EVPRODS_H -static char *uv__rawname(char *cp) { - static char rawbuf[FILENAME_MAX+1]; - char *dp = rindex(cp, '/'); - - if (dp == 0) - return 0; - - *dp = 0; - strcpy(rawbuf, cp); - *dp = '/'; - strcat(rawbuf, "/r"); - strcat(rawbuf, dp+1); - return rawbuf; -} - - -/* - * Determine whether given pathname is a directory - * Returns 0 if the path is a directory, -1 if not - * - * Note: Opportunity here for more detailed error information but - * that requires changing callers of this function as well - */ -static int uv__path_is_a_directory(char* filename) { - struct stat statbuf; - - if (stat(filename, &statbuf) < 0) - return -1; /* failed: not a directory, assume it is a file */ - - if (statbuf.st_type == VDIR) - return 0; - - return -1; -} - - -/* - * Check whether AHAFS is mounted. - * Returns 0 if AHAFS is mounted, or an error code < 0 on failure - */ -static int uv__is_ahafs_mounted(void){ - int rv, i = 2; - struct vmount *p; - int size_multiplier = 10; - size_t siz = sizeof(struct vmount)*size_multiplier; - struct vmount *vmt; - const char *dev = "/aha"; - char *obj, *stub; - - p = uv__malloc(siz); - if (p == NULL) - return -errno; - - /* Retrieve all mounted filesystems */ - rv = mntctl(MCTL_QUERY, siz, (char*)p); - if (rv < 0) - return -errno; - if (rv == 0) { - /* buffer was not large enough, reallocate to correct size */ - siz = *(int*)p; - uv__free(p); - p = uv__malloc(siz); - if (p == NULL) - return -errno; - rv = mntctl(MCTL_QUERY, siz, (char*)p); - if (rv < 0) - return -errno; - } - - /* Look for dev in filesystems mount info */ - for(vmt = p, i = 0; i < rv; i++) { - obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */ - stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */ - - if (EQ(obj, dev) || EQ(uv__rawname(obj), dev) || EQ(stub, dev)) { - uv__free(p); /* Found a match */ - return 0; - } - vmt = (struct vmount *) ((char *) vmt + vmt->vmt_length); - } - - /* /aha is required for monitoring filesystem changes */ - return -1; -} - -/* - * Recursive call to mkdir() to create intermediate folders, if any - * Returns code from mkdir call - */ -static int uv__makedir_p(const char *dir) { - char tmp[256]; - char *p = NULL; - size_t len; - int err; - - snprintf(tmp, sizeof(tmp),"%s",dir); - len = strlen(tmp); - if (tmp[len - 1] == '/') - tmp[len - 1] = 0; - for (p = tmp + 1; *p; p++) { - if (*p == '/') { - *p = 0; - err = mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - if (err != 0 && errno != EEXIST) - return err; - *p = '/'; - } - } - return mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); -} - -/* - * Creates necessary subdirectories in the AIX Event Infrastructure - * file system for monitoring the object specified. - * Returns code from mkdir call - */ -static int uv__make_subdirs_p(const char *filename) { - char cmd[2048]; - char *p; - int rc = 0; - - /* Strip off the monitor file name */ - p = strrchr(filename, '/'); - - if (p == NULL) - return 0; - - if (uv__path_is_a_directory((char*)filename) == 0) { - sprintf(cmd, "/aha/fs/modDir.monFactory"); - } else { - sprintf(cmd, "/aha/fs/modFile.monFactory"); - } - - strncat(cmd, filename, (p - filename)); - rc = uv__makedir_p(cmd); - - if (rc == -1 && errno != EEXIST){ - return -errno; - } - - return rc; -} - - -/* - * Checks if /aha is mounted, then proceeds to set up the monitoring - * objects for the specified file. - * Returns 0 on success, or an error code < 0 on failure - */ -static int uv__setup_ahafs(const char* filename, int *fd) { - int rc = 0; - char mon_file_write_string[RDWR_BUF_SIZE]; - char mon_file[PATH_MAX]; - int file_is_directory = 0; /* -1 == NO, 0 == YES */ - - /* Create monitor file name for object */ - file_is_directory = uv__path_is_a_directory((char*)filename); - - if (file_is_directory == 0) - sprintf(mon_file, "/aha/fs/modDir.monFactory"); - else - sprintf(mon_file, "/aha/fs/modFile.monFactory"); - - if ((strlen(mon_file) + strlen(filename) + 5) > PATH_MAX) - return -ENAMETOOLONG; - - /* Make the necessary subdirectories for the monitor file */ - rc = uv__make_subdirs_p(filename); - if (rc == -1 && errno != EEXIST) - return rc; - - strcat(mon_file, filename); - strcat(mon_file, ".mon"); - - *fd = 0; errno = 0; - - /* Open the monitor file, creating it if necessary */ - *fd = open(mon_file, O_CREAT|O_RDWR); - if (*fd < 0) - return -errno; - - /* Write out the monitoring specifications. - * In this case, we are monitoring for a state change event type - * CHANGED=YES - * We will be waiting in select call, rather than a read: - * WAIT_TYPE=WAIT_IN_SELECT - * We only want minimal information for files: - * INFO_LVL=1 - * For directories, we want more information to track what file - * caused the change - * INFO_LVL=2 - */ - - if (file_is_directory == 0) - sprintf(mon_file_write_string, "CHANGED=YES;WAIT_TYPE=WAIT_IN_SELECT;INFO_LVL=2"); - else - sprintf(mon_file_write_string, "CHANGED=YES;WAIT_TYPE=WAIT_IN_SELECT;INFO_LVL=1"); - - rc = write(*fd, mon_file_write_string, strlen(mon_file_write_string)+1); - if (rc < 0) - return -errno; - - return 0; -} - -/* - * Skips a specified number of lines in the buffer passed in. - * Walks the buffer pointed to by p and attempts to skip n lines. - * Returns the total number of lines skipped - */ -static int uv__skip_lines(char **p, int n) { - int lines = 0; - - while(n > 0) { - *p = strchr(*p, '\n'); - if (!p) - return lines; - - (*p)++; - n--; - lines++; - } - return lines; -} - - -/* - * Parse the event occurrence data to figure out what event just occurred - * and take proper action. - * - * The buf is a pointer to the buffer containing the event occurrence data - * Returns 0 on success, -1 if unrecoverable error in parsing - * - */ -static int uv__parse_data(char *buf, int *events, uv_fs_event_t* handle) { - int evp_rc, i; - char *p; - char filename[PATH_MAX]; /* To be used when handling directories */ - - p = buf; - *events = 0; - - /* Clean the filename buffer*/ - for(i = 0; i < PATH_MAX; i++) { - filename[i] = 0; - } - i = 0; - - /* Check for BUF_WRAP */ - if (strncmp(buf, "BUF_WRAP", strlen("BUF_WRAP")) == 0) { - assert(0 && "Buffer wrap detected, Some event occurrences lost!"); - return 0; - } - - /* Since we are using the default buffer size (4K), and have specified - * INFO_LVL=1, we won't see any EVENT_OVERFLOW conditions. Applications - * should check for this keyword if they are using an INFO_LVL of 2 or - * higher, and have a buffer size of <= 4K - */ - - /* Skip to RC_FROM_EVPROD */ - if (uv__skip_lines(&p, 9) != 9) - return -1; - - if (sscanf(p, "RC_FROM_EVPROD=%d\nEND_EVENT_DATA", &evp_rc) == 1) { - if (uv__path_is_a_directory(handle->path) == 0) { /* Directory */ - if (evp_rc == AHAFS_MODDIR_UNMOUNT || evp_rc == AHAFS_MODDIR_REMOVE_SELF) { - /* The directory is no longer available for monitoring */ - *events = UV_RENAME; - handle->dir_filename = NULL; - } else { - /* A file was added/removed inside the directory */ - *events = UV_CHANGE; - - /* Get the EVPROD_INFO */ - if (uv__skip_lines(&p, 1) != 1) - return -1; - - /* Scan out the name of the file that triggered the event*/ - if (sscanf(p, "BEGIN_EVPROD_INFO\n%sEND_EVPROD_INFO", filename) == 1) { - handle->dir_filename = uv__strdup((const char*)&filename); - } else - return -1; - } - } else { /* Regular File */ - if (evp_rc == AHAFS_MODFILE_RENAME) - *events = UV_RENAME; - else - *events = UV_CHANGE; - } - } - else - return -1; - - return 0; -} - - -/* This is the internal callback */ -static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int fflags) { - char result_data[RDWR_BUF_SIZE]; - int bytes, rc = 0; - uv_fs_event_t* handle; - int events = 0; - char fname[PATH_MAX]; - char *p; - - handle = container_of(event_watch, uv_fs_event_t, event_watcher); - - /* At this point, we assume that polling has been done on the - * file descriptor, so we can just read the AHAFS event occurrence - * data and parse its results without having to block anything - */ - bytes = pread(event_watch->fd, result_data, RDWR_BUF_SIZE, 0); - - assert((bytes >= 0) && "uv__ahafs_event - Error reading monitor file"); - - /* In file / directory move cases, AIX Event infrastructure - * produces a second event with no data. - * Ignore it and return gracefully. - */ - if(bytes == 0) - return; - - /* Parse the data */ - if(bytes > 0) - rc = uv__parse_data(result_data, &events, handle); - - /* Unrecoverable error */ - if (rc == -1) - return; - - /* For directory changes, the name of the files that triggered the change - * are never absolute pathnames - */ - if (uv__path_is_a_directory(handle->path) == 0) { - p = handle->dir_filename; - } else { - p = strrchr(handle->path, '/'); - if (p == NULL) - p = handle->path; - else - p++; - } - strncpy(fname, p, sizeof(fname) - 1); - /* Just in case */ - fname[sizeof(fname) - 1] = '\0'; - - handle->cb(handle, fname, events, 0); -} -#endif - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -#else - return -ENOSYS; -#endif -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* filename, - unsigned int flags) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - int fd, rc, str_offset = 0; - char cwd[PATH_MAX]; - char absolute_path[PATH_MAX]; - char readlink_cwd[PATH_MAX]; - - - /* Figure out whether filename is absolute or not */ - if (filename[0] == '/') { - /* We have absolute pathname */ - snprintf(absolute_path, sizeof(absolute_path), "%s", filename); - } else { - /* We have a relative pathname, compose the absolute pathname */ - snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid()); - rc = readlink(cwd, readlink_cwd, sizeof(readlink_cwd) - 1); - if (rc < 0) - return rc; - /* readlink does not null terminate our string */ - readlink_cwd[rc] = '\0'; - - if (filename[0] == '.' && filename[1] == '/') - str_offset = 2; - - snprintf(absolute_path, sizeof(absolute_path), "%s%s", readlink_cwd, - filename + str_offset); - } - - if (uv__is_ahafs_mounted() < 0) /* /aha checks failed */ - return UV_ENOSYS; - - /* Setup ahafs */ - rc = uv__setup_ahafs((const char *)absolute_path, &fd); - if (rc != 0) - return rc; - - /* Setup/Initialize all the libuv routines */ - uv__handle_start(handle); - uv__io_init(&handle->event_watcher, uv__ahafs_event, fd); - handle->path = uv__strdup(filename); - handle->cb = cb; - - uv__io_start(handle->loop, &handle->event_watcher, POLLIN); - - return 0; -#else - return -ENOSYS; -#endif -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - if (!uv__is_active(handle)) - return 0; - - uv__io_close(handle->loop, &handle->event_watcher); - uv__handle_stop(handle); - - if (uv__path_is_a_directory(handle->path) == 0) { - uv__free(handle->dir_filename); - handle->dir_filename = NULL; - } - - uv__free(handle->path); - handle->path = NULL; - uv__close(handle->event_watcher.fd); - handle->event_watcher.fd = -1; - - return 0; -#else - return -ENOSYS; -#endif -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { -#ifdef HAVE_SYS_AHAFS_EVPRODS_H - uv_fs_event_stop(handle); -#else - UNREACHABLE(); -#endif -} - - -char** uv_setup_args(int argc, char** argv) { - char** new_argv; - size_t size; - char* s; - int i; - - if (argc <= 0) - return argv; - - /* Save the original pointer to argv. - * AIX uses argv to read the process name. - * (Not the memory pointed to by argv[0..n] as on Linux.) - */ - process_argv = argv; - process_argc = argc; - - /* Calculate how much memory we need for the argv strings. */ - size = 0; - for (i = 0; i < argc; i++) - size += strlen(argv[i]) + 1; - - /* Add space for the argv pointers. */ - size += (argc + 1) * sizeof(char*); - - new_argv = uv__malloc(size); - if (new_argv == NULL) - return argv; - args_mem = new_argv; - - /* Copy over the strings and set up the pointer table. */ - s = (char*) &new_argv[argc + 1]; - for (i = 0; i < argc; i++) { - size = strlen(argv[i]) + 1; - memcpy(s, argv[i], size); - new_argv[i] = s; - s += size; - } - new_argv[i] = NULL; - - return new_argv; -} - - -int uv_set_process_title(const char* title) { - char* new_title; - - /* We cannot free this pointer when libuv shuts down, - * the process may still be using it. - */ - new_title = uv__strdup(title); - if (new_title == NULL) - return -ENOMEM; - - /* If this is the first time this is set, - * don't free and set argv[1] to NULL. - */ - if (process_title_ptr != NULL) - uv__free(process_title_ptr); - - process_title_ptr = new_title; - - process_argv[0] = process_title_ptr; - if (process_argc > 1) - process_argv[1] = NULL; - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - len = strlen(process_argv[0]); - if (buffer == NULL || size == 0) - return -EINVAL; - else if (size <= len) - return -ENOBUFS; - - memcpy(buffer, process_argv[0], len + 1); - - return 0; -} - - -UV_DESTRUCTOR(static void free_args_mem(void)) { - uv__free(args_mem); /* Keep valgrind happy. */ - args_mem = NULL; -} - - -int uv_resident_set_memory(size_t* rss) { - char pp[64]; - psinfo_t psinfo; - int err; - int fd; - - snprintf(pp, sizeof(pp), "/proc/%lu/psinfo", (unsigned long) getpid()); - - fd = open(pp, O_RDONLY); - if (fd == -1) - return -errno; - - /* FIXME(bnoordhuis) Handle EINTR. */ - err = -EINVAL; - if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) { - *rss = (size_t)psinfo.pr_rssize * 1024; - err = 0; - } - uv__close(fd); - - return err; -} - - -int uv_uptime(double* uptime) { - struct utmp *utmp_buf; - size_t entries = 0; - time_t boot_time; - - utmpname(UTMP_FILE); - - setutent(); - - while ((utmp_buf = getutent()) != NULL) { - if (utmp_buf->ut_user[0] && utmp_buf->ut_type == USER_PROCESS) - ++entries; - if (utmp_buf->ut_type == BOOT_TIME) - boot_time = utmp_buf->ut_time; - } - - endutent(); - - if (boot_time == 0) - return -ENOSYS; - - *uptime = time(NULL) - boot_time; - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - uv_cpu_info_t* cpu_info; - perfstat_cpu_total_t ps_total; - perfstat_cpu_t* ps_cpus; - perfstat_id_t cpu_id; - int result, ncpus, idx = 0; - - result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1); - if (result == -1) { - return -ENOSYS; - } - - ncpus = result = perfstat_cpu(NULL, NULL, sizeof(perfstat_cpu_t), 0); - if (result == -1) { - return -ENOSYS; - } - - ps_cpus = (perfstat_cpu_t*) uv__malloc(ncpus * sizeof(perfstat_cpu_t)); - if (!ps_cpus) { - return -ENOMEM; - } - - strcpy(cpu_id.name, FIRST_CPU); - result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus); - if (result == -1) { - uv__free(ps_cpus); - return -ENOSYS; - } - - *cpu_infos = (uv_cpu_info_t*) uv__malloc(ncpus * sizeof(uv_cpu_info_t)); - if (!*cpu_infos) { - uv__free(ps_cpus); - return -ENOMEM; - } - - *count = ncpus; - - cpu_info = *cpu_infos; - while (idx < ncpus) { - cpu_info->speed = (int)(ps_total.processorHZ / 1000000); - cpu_info->model = uv__strdup(ps_total.description); - cpu_info->cpu_times.user = ps_cpus[idx].user; - cpu_info->cpu_times.sys = ps_cpus[idx].sys; - cpu_info->cpu_times.idle = ps_cpus[idx].idle; - cpu_info->cpu_times.irq = ps_cpus[idx].wait; - cpu_info->cpu_times.nice = 0; - cpu_info++; - idx++; - } - - uv__free(ps_cpus); - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; ++i) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - - -int uv_interface_addresses(uv_interface_address_t** addresses, - int* count) { - uv_interface_address_t* address; - int sockfd, size = 1; - struct ifconf ifc; - struct ifreq *ifr, *p, flg; - - *count = 0; - - if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) { - return -errno; - } - - if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) { - uv__close(sockfd); - return -errno; - } - - ifc.ifc_req = (struct ifreq*)uv__malloc(size); - ifc.ifc_len = size; - if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) { - uv__close(sockfd); - return -errno; - } - -#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p)) - - /* Count all up and running ipv4/ipv6 addresses */ - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return -errno; - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - (*count)++; - } - - /* Alloc the return interface structs */ - *addresses = (uv_interface_address_t*) - uv__malloc(*count * sizeof(uv_interface_address_t)); - if (!(*addresses)) { - uv__close(sockfd); - return -ENOMEM; - } - address = *addresses; - - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return -ENOSYS; - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - /* All conditions above must match count loop */ - - address->name = uv__strdup(p->ifr_name); - - if (p->ifr_addr.sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr); - } - - /* TODO: Retrieve netmask using SIOCGIFNETMASK ioctl */ - - address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0; - - address++; - } - -#undef ADDR_SIZE - - uv__close(sockfd); - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; ++i) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct pollfd* events; - uintptr_t i; - uintptr_t nfds; - struct poll_ctl pc; - - assert(loop->watchers != NULL); - - events = (struct pollfd*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - - if (events != NULL) - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].fd == fd) - events[i].fd = -1; - - /* Remove the file descriptor from the poll set */ - pc.events = 0; - pc.cmd = PS_DELETE; - pc.fd = fd; - if(loop->backend_fd >= 0) - pollset_ctl(loop->backend_fd, &pc, 1); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/android-ifaddrs.c b/lib/ESPiLight/pilight/libs/libuv/unix/android-ifaddrs.c deleted file mode 100644 index 30f681b..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/android-ifaddrs.c +++ /dev/null @@ -1,703 +0,0 @@ -/* -Copyright (c) 2013, Kenneth MacKay -Copyright (c) 2014, Emergya (Cloud4all, FP7/2007-2013 grant agreement #289016) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 "android-ifaddrs.h" -#include "uv-common.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct NetlinkList -{ - struct NetlinkList *m_next; - struct nlmsghdr *m_data; - unsigned int m_size; -} NetlinkList; - -static int netlink_socket(void) -{ - struct sockaddr_nl l_addr; - - int l_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - if(l_socket < 0) - { - return -1; - } - - memset(&l_addr, 0, sizeof(l_addr)); - l_addr.nl_family = AF_NETLINK; - if(bind(l_socket, (struct sockaddr *)&l_addr, sizeof(l_addr)) < 0) - { - close(l_socket); - return -1; - } - - return l_socket; -} - -static int netlink_send(int p_socket, int p_request) -{ - char l_buffer[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct rtgenmsg))]; - - struct nlmsghdr *l_hdr; - struct rtgenmsg *l_msg; - struct sockaddr_nl l_addr; - - memset(l_buffer, 0, sizeof(l_buffer)); - - l_hdr = (struct nlmsghdr *)l_buffer; - l_msg = (struct rtgenmsg *)NLMSG_DATA(l_hdr); - - l_hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*l_msg)); - l_hdr->nlmsg_type = p_request; - l_hdr->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST; - l_hdr->nlmsg_pid = 0; - l_hdr->nlmsg_seq = p_socket; - l_msg->rtgen_family = AF_UNSPEC; - - memset(&l_addr, 0, sizeof(l_addr)); - l_addr.nl_family = AF_NETLINK; - return (sendto(p_socket, l_hdr, l_hdr->nlmsg_len, 0, (struct sockaddr *)&l_addr, sizeof(l_addr))); -} - -static int netlink_recv(int p_socket, void *p_buffer, size_t p_len) -{ - struct sockaddr_nl l_addr; - struct msghdr l_msg; - - struct iovec l_iov; - l_iov.iov_base = p_buffer; - l_iov.iov_len = p_len; - - for(;;) - { - int l_result; - l_msg.msg_name = (void *)&l_addr; - l_msg.msg_namelen = sizeof(l_addr); - l_msg.msg_iov = &l_iov; - l_msg.msg_iovlen = 1; - l_msg.msg_control = NULL; - l_msg.msg_controllen = 0; - l_msg.msg_flags = 0; - l_result = recvmsg(p_socket, &l_msg, 0); - - if(l_result < 0) - { - if(errno == EINTR) - { - continue; - } - return -2; - } - - /* Buffer was too small */ - if(l_msg.msg_flags & MSG_TRUNC) - { - return -1; - } - return l_result; - } -} - -static struct nlmsghdr *getNetlinkResponse(int p_socket, int *p_size, int *p_done) -{ - size_t l_size = 4096; - void *l_buffer = NULL; - - for(;;) - { - int l_read; - - uv__free(l_buffer); - l_buffer = uv__malloc(l_size); - if (l_buffer == NULL) - { - return NULL; - } - - l_read = netlink_recv(p_socket, l_buffer, l_size); - *p_size = l_read; - if(l_read == -2) - { - uv__free(l_buffer); - return NULL; - } - if(l_read >= 0) - { - pid_t l_pid = getpid(); - struct nlmsghdr *l_hdr; - for(l_hdr = (struct nlmsghdr *)l_buffer; NLMSG_OK(l_hdr, (unsigned int)l_read); l_hdr = (struct nlmsghdr *)NLMSG_NEXT(l_hdr, l_read)) - { - if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) - { - continue; - } - - if(l_hdr->nlmsg_type == NLMSG_DONE) - { - *p_done = 1; - break; - } - - if(l_hdr->nlmsg_type == NLMSG_ERROR) - { - uv__free(l_buffer); - return NULL; - } - } - return l_buffer; - } - - l_size *= 2; - } -} - -static NetlinkList *newListItem(struct nlmsghdr *p_data, unsigned int p_size) -{ - NetlinkList *l_item = uv__malloc(sizeof(NetlinkList)); - if (l_item == NULL) - { - return NULL; - } - - l_item->m_next = NULL; - l_item->m_data = p_data; - l_item->m_size = p_size; - return l_item; -} - -static void freeResultList(NetlinkList *p_list) -{ - NetlinkList *l_cur; - while(p_list) - { - l_cur = p_list; - p_list = p_list->m_next; - uv__free(l_cur->m_data); - uv__free(l_cur); - } -} - -static NetlinkList *getResultList(int p_socket, int p_request) -{ - int l_size; - int l_done; - NetlinkList *l_list; - NetlinkList *l_end; - - if(netlink_send(p_socket, p_request) < 0) - { - return NULL; - } - - l_list = NULL; - l_end = NULL; - - l_done = 0; - while(!l_done) - { - NetlinkList *l_item; - - struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, &l_size, &l_done); - /* Error */ - if(!l_hdr) - { - freeResultList(l_list); - return NULL; - } - - l_item = newListItem(l_hdr, l_size); - if (!l_item) - { - freeResultList(l_list); - return NULL; - } - if(!l_list) - { - l_list = l_item; - } - else - { - l_end->m_next = l_item; - } - l_end = l_item; - } - return l_list; -} - -static size_t maxSize(size_t a, size_t b) -{ - return (a > b ? a : b); -} - -static size_t calcAddrLen(sa_family_t p_family, int p_dataSize) -{ - switch(p_family) - { - case AF_INET: - return sizeof(struct sockaddr_in); - case AF_INET6: - return sizeof(struct sockaddr_in6); - case AF_PACKET: - return maxSize(sizeof(struct sockaddr_ll), offsetof(struct sockaddr_ll, sll_addr) + p_dataSize); - default: - return maxSize(sizeof(struct sockaddr), offsetof(struct sockaddr, sa_data) + p_dataSize); - } -} - -static void makeSockaddr(sa_family_t p_family, struct sockaddr *p_dest, void *p_data, size_t p_size) -{ - switch(p_family) - { - case AF_INET: - memcpy(&((struct sockaddr_in*)p_dest)->sin_addr, p_data, p_size); - break; - case AF_INET6: - memcpy(&((struct sockaddr_in6*)p_dest)->sin6_addr, p_data, p_size); - break; - case AF_PACKET: - memcpy(((struct sockaddr_ll*)p_dest)->sll_addr, p_data, p_size); - ((struct sockaddr_ll*)p_dest)->sll_halen = p_size; - break; - default: - memcpy(p_dest->sa_data, p_data, p_size); - break; - } - p_dest->sa_family = p_family; -} - -static void addToEnd(struct ifaddrs **p_resultList, struct ifaddrs *p_entry) -{ - if(!*p_resultList) - { - *p_resultList = p_entry; - } - else - { - struct ifaddrs *l_cur = *p_resultList; - while(l_cur->ifa_next) - { - l_cur = l_cur->ifa_next; - } - l_cur->ifa_next = p_entry; - } -} - -static int interpretLink(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList) -{ - struct ifaddrs *l_entry; - - char *l_index; - char *l_name; - char *l_addr; - char *l_data; - - struct ifinfomsg *l_info = (struct ifinfomsg *)NLMSG_DATA(p_hdr); - - size_t l_nameSize = 0; - size_t l_addrSize = 0; - size_t l_dataSize = 0; - - size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); - struct rtattr *l_rta; - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - switch(l_rta->rta_type) - { - case IFLA_ADDRESS: - case IFLA_BROADCAST: - l_addrSize += NLMSG_ALIGN(calcAddrLen(AF_PACKET, l_rtaDataSize)); - break; - case IFLA_IFNAME: - l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); - break; - case IFLA_STATS: - l_dataSize += NLMSG_ALIGN(l_rtaSize); - break; - default: - break; - } - } - - l_entry = uv__malloc(sizeof(struct ifaddrs) + sizeof(int) + l_nameSize + l_addrSize + l_dataSize); - if (l_entry == NULL) - { - return -1; - } - memset(l_entry, 0, sizeof(struct ifaddrs)); - l_entry->ifa_name = ""; - - l_index = ((char *)l_entry) + sizeof(struct ifaddrs); - l_name = l_index + sizeof(int); - l_addr = l_name + l_nameSize; - l_data = l_addr + l_addrSize; - - /* Save the interface index so we can look it up when handling the - * addresses. - */ - memcpy(l_index, &l_info->ifi_index, sizeof(int)); - - l_entry->ifa_flags = l_info->ifi_flags; - - l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - void *l_rtaData = RTA_DATA(l_rta); - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - switch(l_rta->rta_type) - { - case IFLA_ADDRESS: - case IFLA_BROADCAST: - { - size_t l_addrLen = calcAddrLen(AF_PACKET, l_rtaDataSize); - makeSockaddr(AF_PACKET, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); - ((struct sockaddr_ll *)l_addr)->sll_ifindex = l_info->ifi_index; - ((struct sockaddr_ll *)l_addr)->sll_hatype = l_info->ifi_type; - if(l_rta->rta_type == IFLA_ADDRESS) - { - l_entry->ifa_addr = (struct sockaddr *)l_addr; - } - else - { - l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; - } - l_addr += NLMSG_ALIGN(l_addrLen); - break; - } - case IFLA_IFNAME: - strncpy(l_name, l_rtaData, l_rtaDataSize); - l_name[l_rtaDataSize] = '\0'; - l_entry->ifa_name = l_name; - break; - case IFLA_STATS: - memcpy(l_data, l_rtaData, l_rtaDataSize); - l_entry->ifa_data = l_data; - break; - default: - break; - } - } - - addToEnd(p_resultList, l_entry); - return 0; -} - -static struct ifaddrs *findInterface(int p_index, struct ifaddrs **p_links, int p_numLinks) -{ - int l_num = 0; - struct ifaddrs *l_cur = *p_links; - while(l_cur && l_num < p_numLinks) - { - char *l_indexPtr = ((char *)l_cur) + sizeof(struct ifaddrs); - int l_index; - memcpy(&l_index, l_indexPtr, sizeof(int)); - if(l_index == p_index) - { - return l_cur; - } - - l_cur = l_cur->ifa_next; - ++l_num; - } - return NULL; -} - -static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, int p_numLinks) -{ - struct ifaddrmsg *l_info = (struct ifaddrmsg *)NLMSG_DATA(p_hdr); - struct ifaddrs *l_interface = findInterface(l_info->ifa_index, p_resultList, p_numLinks); - - size_t l_nameSize = 0; - size_t l_addrSize = 0; - - int l_addedNetmask = 0; - - size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); - struct rtattr *l_rta; - struct ifaddrs *l_entry; - - char *l_name; - char *l_addr; - - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - if(l_info->ifa_family == AF_PACKET) - { - continue; - } - - switch(l_rta->rta_type) - { - case IFA_ADDRESS: - case IFA_LOCAL: - if((l_info->ifa_family == AF_INET || l_info->ifa_family == AF_INET6) && !l_addedNetmask) - { - /* Make room for netmask */ - l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); - l_addedNetmask = 1; - } - case IFA_BROADCAST: - l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); - break; - case IFA_LABEL: - l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); - break; - default: - break; - } - } - - l_entry = uv__malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize); - if (l_entry == NULL) - { - return -1; - } - memset(l_entry, 0, sizeof(struct ifaddrs)); - l_entry->ifa_name = (l_interface ? l_interface->ifa_name : ""); - - l_name = ((char *)l_entry) + sizeof(struct ifaddrs); - l_addr = l_name + l_nameSize; - - l_entry->ifa_flags = l_info->ifa_flags; - if(l_interface) - { - l_entry->ifa_flags |= l_interface->ifa_flags; - } - - l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); - for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) - { - void *l_rtaData = RTA_DATA(l_rta); - size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); - switch(l_rta->rta_type) - { - case IFA_ADDRESS: - case IFA_BROADCAST: - case IFA_LOCAL: - { - size_t l_addrLen = calcAddrLen(l_info->ifa_family, l_rtaDataSize); - makeSockaddr(l_info->ifa_family, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); - if(l_info->ifa_family == AF_INET6) - { - if(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)l_rtaData) || IN6_IS_ADDR_MC_LINKLOCAL((struct in6_addr *)l_rtaData)) - { - ((struct sockaddr_in6 *)l_addr)->sin6_scope_id = l_info->ifa_index; - } - } - - /* Apparently in a point-to-point network IFA_ADDRESS contains - * the dest address and IFA_LOCAL contains the local address - */ - if(l_rta->rta_type == IFA_ADDRESS) - { - if(l_entry->ifa_addr) - { - l_entry->ifa_dstaddr = (struct sockaddr *)l_addr; - } - else - { - l_entry->ifa_addr = (struct sockaddr *)l_addr; - } - } - else if(l_rta->rta_type == IFA_LOCAL) - { - if(l_entry->ifa_addr) - { - l_entry->ifa_dstaddr = l_entry->ifa_addr; - } - l_entry->ifa_addr = (struct sockaddr *)l_addr; - } - else - { - l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; - } - l_addr += NLMSG_ALIGN(l_addrLen); - break; - } - case IFA_LABEL: - strncpy(l_name, l_rtaData, l_rtaDataSize); - l_name[l_rtaDataSize] = '\0'; - l_entry->ifa_name = l_name; - break; - default: - break; - } - } - - if(l_entry->ifa_addr && (l_entry->ifa_addr->sa_family == AF_INET || l_entry->ifa_addr->sa_family == AF_INET6)) - { - unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128); - unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen); - char l_mask[16] = {0}; - unsigned i; - for(i=0; i<(l_prefix/8); ++i) - { - l_mask[i] = 0xff; - } - if(l_prefix % 8) - { - l_mask[i] = 0xff << (8 - (l_prefix % 8)); - } - - makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8); - l_entry->ifa_netmask = (struct sockaddr *)l_addr; - } - - addToEnd(p_resultList, l_entry); - return 0; -} - -static int interpretLinks(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList) -{ - - int l_numLinks = 0; - pid_t l_pid = getpid(); - for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next) - { - unsigned int l_nlsize = p_netlinkList->m_size; - struct nlmsghdr *l_hdr; - for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) - { - if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) - { - continue; - } - - if(l_hdr->nlmsg_type == NLMSG_DONE) - { - break; - } - - if(l_hdr->nlmsg_type == RTM_NEWLINK) - { - if(interpretLink(l_hdr, p_resultList) == -1) - { - return -1; - } - ++l_numLinks; - } - } - } - return l_numLinks; -} - -static int interpretAddrs(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks) -{ - pid_t l_pid = getpid(); - for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next) - { - unsigned int l_nlsize = p_netlinkList->m_size; - struct nlmsghdr *l_hdr; - for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) - { - if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) - { - continue; - } - - if(l_hdr->nlmsg_type == NLMSG_DONE) - { - break; - } - - if(l_hdr->nlmsg_type == RTM_NEWADDR) - { - if (interpretAddr(l_hdr, p_resultList, p_numLinks) == -1) - { - return -1; - } - } - } - } - return 0; -} - -int getifaddrs(struct ifaddrs **ifap) -{ - int l_socket; - int l_result; - int l_numLinks; - NetlinkList *l_linkResults; - NetlinkList *l_addrResults; - - if(!ifap) - { - return -1; - } - *ifap = NULL; - - l_socket = netlink_socket(); - if(l_socket < 0) - { - return -1; - } - - l_linkResults = getResultList(l_socket, RTM_GETLINK); - if(!l_linkResults) - { - close(l_socket); - return -1; - } - - l_addrResults = getResultList(l_socket, RTM_GETADDR); - if(!l_addrResults) - { - close(l_socket); - freeResultList(l_linkResults); - return -1; - } - - l_result = 0; - l_numLinks = interpretLinks(l_socket, l_linkResults, ifap); - if(l_numLinks == -1 || interpretAddrs(l_socket, l_addrResults, ifap, l_numLinks) == -1) - { - l_result = -1; - } - - freeResultList(l_linkResults); - freeResultList(l_addrResults); - close(l_socket); - return l_result; -} - -void freeifaddrs(struct ifaddrs *ifa) -{ - struct ifaddrs *l_cur; - while(ifa) - { - l_cur = ifa; - ifa = ifa->ifa_next; - uv__free(l_cur); - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/async.c b/lib/ESPiLight/pilight/libs/libuv/unix/async.c deleted file mode 100644 index 45c088e..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/async.c +++ /dev/null @@ -1,269 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* This file contains both the uv__async internal infrastructure and the - * user-facing uv_async_t functions. - */ - -#include "uv.h" -#include "internal.h" -#include "atomic-ops.h" - -#include -#include /* snprintf() */ -#include -#include -#include -#include - -static void uv__async_send(uv_loop_t* loop); -static int uv__async_start(uv_loop_t* loop); -static int uv__async_eventfd(void); - - -int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { - int err; - - err = uv__async_start(loop); - if (err) - return err; - - uv__handle_init(loop, (uv_handle_t*)handle, UV_ASYNC); - handle->async_cb = async_cb; - handle->pending = 0; - - QUEUE_INSERT_TAIL(&loop->async_handles, &handle->queue); - uv__handle_start(handle); - - return 0; -} - - -int uv_async_send(uv_async_t* handle) { - /* Do a cheap read first. */ - if (ACCESS_ONCE(int, handle->pending) != 0) - return 0; - - if (cmpxchgi(&handle->pending, 0, 1) == 0) - uv__async_send(handle->loop); - - return 0; -} - - -void uv__async_close(uv_async_t* handle) { - QUEUE_REMOVE(&handle->queue); - uv__handle_stop(handle); -} - - -static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - char buf[1024]; - ssize_t r; - QUEUE queue; - QUEUE* q; - uv_async_t* h; - - assert(w == &loop->async_io_watcher); - - for (;;) { - r = read(w->fd, buf, sizeof(buf)); - - if (r == sizeof(buf)) - continue; - - if (r != -1) - break; - - if (errno == EAGAIN || errno == EWOULDBLOCK) - break; - - if (errno == EINTR) - continue; - - abort(); - } - - QUEUE_MOVE(&loop->async_handles, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - h = QUEUE_DATA(q, uv_async_t, queue); - - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&loop->async_handles, q); - - if (cmpxchgi(&h->pending, 1, 0) == 0) - continue; - - if (h->async_cb == NULL) - continue; - - h->async_cb(h); - } -} - - -static void uv__async_send(uv_loop_t* loop) { - const void* buf; - ssize_t len; - int fd; - int r; - - buf = ""; - len = 1; - fd = loop->async_wfd; - -#if defined(__linux__) - if (fd == -1) { - static const uint64_t val = 1; - buf = &val; - len = sizeof(val); - fd = loop->async_io_watcher.fd; /* eventfd */ - } -#endif - - do - r = write(fd, buf, len); - while (r == -1 && errno == EINTR); - - if (r == len) - return; - - if (r == -1) - if (errno == EAGAIN || errno == EWOULDBLOCK) - return; - - abort(); -} - - -static int uv__async_start(uv_loop_t* loop) { - int pipefd[2]; - int err; - - if (loop->async_io_watcher.fd != -1) - return 0; - - err = uv__async_eventfd(); - if (err >= 0) { - pipefd[0] = err; - pipefd[1] = -1; - } - else if (err == -ENOSYS) { - err = uv__make_pipe(pipefd, UV__F_NONBLOCK); -#if defined(__linux__) - /* Save a file descriptor by opening one of the pipe descriptors as - * read/write through the procfs. That file descriptor can then - * function as both ends of the pipe. - */ - if (err == 0) { - char buf[32]; - int fd; - - snprintf(buf, sizeof(buf), "/proc/self/fd/%d", pipefd[0]); - fd = uv__open_cloexec(buf, O_RDWR); - if (fd >= 0) { - uv__close(pipefd[0]); - uv__close(pipefd[1]); - pipefd[0] = fd; - pipefd[1] = fd; - } - } -#endif - } - - if (err < 0) - return err; - - uv__io_init(&loop->async_io_watcher, uv__async_io, pipefd[0]); - uv__io_start(loop, &loop->async_io_watcher, POLLIN); - loop->async_wfd = pipefd[1]; - - return 0; -} - - -int uv__async_fork(uv_loop_t* loop) { - if (loop->async_io_watcher.fd == -1) /* never started */ - return 0; - - uv__async_stop(loop); - - return uv__async_start(loop); -} - - -void uv__async_stop(uv_loop_t* loop) { - if (loop->async_io_watcher.fd == -1) - return; - - if (loop->async_wfd != -1) { - if (loop->async_wfd != loop->async_io_watcher.fd) - uv__close(loop->async_wfd); - loop->async_wfd = -1; - } - - uv__io_stop(loop, &loop->async_io_watcher, POLLIN); - uv__close(loop->async_io_watcher.fd); - loop->async_io_watcher.fd = -1; -} - - -static int uv__async_eventfd(void) { -#if defined(__linux__) - static int no_eventfd2; - static int no_eventfd; - int fd; - - if (no_eventfd2) - goto skip_eventfd2; - - fd = uv__eventfd2(0, UV__EFD_CLOEXEC | UV__EFD_NONBLOCK); - if (fd != -1) - return fd; - - if (errno != ENOSYS) - return -errno; - - no_eventfd2 = 1; - -skip_eventfd2: - - if (no_eventfd) - goto skip_eventfd; - - fd = uv__eventfd(0); - if (fd != -1) { - uv__cloexec(fd, 1); - uv__nonblock(fd, 1); - return fd; - } - - if (errno != ENOSYS) - return -errno; - - no_eventfd = 1; - -skip_eventfd: - -#endif - - return -ENOSYS; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/atomic-ops.h b/lib/ESPiLight/pilight/libs/libuv/unix/atomic-ops.h deleted file mode 100644 index 9dac255..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/atomic-ops.h +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or 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 THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. - */ - -#ifndef UV_ATOMIC_OPS_H_ -#define UV_ATOMIC_OPS_H_ - -#include "internal.h" /* UV_UNUSED */ - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#include -#define __sync_val_compare_and_swap(p, o, n) atomic_cas_ptr(p, o, n) -#endif - -UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)); -UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)); -UV_UNUSED(static void cpu_relax(void)); - -/* Prefer hand-rolled assembly over the gcc builtins because the latter also - * issue full memory barriers. - */ -UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) { -#if defined(__i386__) || defined(__x86_64__) - int out; - __asm__ __volatile__ ("lock; cmpxchg %2, %1;" - : "=a" (out), "+m" (*(volatile int*) ptr) - : "r" (newval), "0" (oldval) - : "memory"); - return out; -#elif defined(_AIX) && defined(__xlC__) - const int out = (*(volatile int*) ptr); - __compare_and_swap(ptr, &oldval, newval); - return out; -#elif defined(__MVS__) - unsigned int op4; - if (__plo_CSST(ptr, (unsigned int*) &oldval, newval, - (unsigned int*) ptr, *ptr, &op4)) - return oldval; - else - return op4; -#else - return __sync_val_compare_and_swap(ptr, oldval, newval); -#endif -} - -UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) { -#if defined(__i386__) || defined(__x86_64__) - long out; - __asm__ __volatile__ ("lock; cmpxchg %2, %1;" - : "=a" (out), "+m" (*(volatile long*) ptr) - : "r" (newval), "0" (oldval) - : "memory"); - return out; -#elif defined(_AIX) && defined(__xlC__) - const long out = (*(volatile int*) ptr); -# if defined(__64BIT__) - __compare_and_swaplp(ptr, &oldval, newval); -# else - __compare_and_swap(ptr, &oldval, newval); -# endif /* if defined(__64BIT__) */ - return out; -#elif defined (__MVS__) -#ifdef _LP64 - unsigned long long op4; - if (__plo_CSSTGR(ptr, (unsigned long long*) &oldval, newval, - (unsigned long long*) ptr, *ptr, &op4)) -#else - unsigned long op4; - if (__plo_CSST(ptr, (unsigned int*) &oldval, newval, - (unsigned int*) ptr, *ptr, &op4)) -#endif - return oldval; - else - return op4; -#else - return __sync_val_compare_and_swap(ptr, oldval, newval); -#endif -} - -UV_UNUSED(static void cpu_relax(void)) { -#if defined(__i386__) || defined(__x86_64__) - __asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */ -#endif -} - -#endif /* UV_ATOMIC_OPS_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/bsd-ifaddrs.c b/lib/ESPiLight/pilight/libs/libuv/unix/bsd-ifaddrs.c deleted file mode 100644 index ffcf156..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/bsd-ifaddrs.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -#include -#include -#if !defined(__CYGWIN__) && !defined(__MSYS__) -#include -#endif - -static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) { - if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING))) - return 1; - if (ent->ifa_addr == NULL) - return 1; - /* - * If `exclude_type` is `UV__EXCLUDE_IFPHYS`, just see whether `sa_family` - * equals to `AF_LINK` or not. Otherwise, the result depends on the operation - * system with `AF_LINK` or `PF_INET`. - */ - if (exclude_type == UV__EXCLUDE_IFPHYS) - return (ent->ifa_addr->sa_family != AF_LINK); -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) - /* - * On BSD getifaddrs returns information related to the raw underlying - * devices. We're not interested in this information. - */ - if (ent->ifa_addr->sa_family == AF_LINK) - return 1; -#elif defined(__NetBSD__) || defined(__OpenBSD__) - if (ent->ifa_addr->sa_family != PF_INET) - return 1; -#endif - return 0; -} - -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - struct ifaddrs* addrs; - struct ifaddrs* ent; - uv_interface_address_t* address; - int i; - - if (getifaddrs(&addrs) != 0) - return -errno; - - *count = 0; - - /* Count the number of interfaces */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - (*count)++; - } - - *addresses = uv__malloc(*count * sizeof(**addresses)); - - if (*addresses == NULL) { - freeifaddrs(addrs); - return -ENOMEM; - } - - address = *addresses; - - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - - address->name = uv__strdup(ent->ifa_name); - - if (ent->ifa_addr->sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr); - } - - if (ent->ifa_netmask->sa_family == AF_INET6) { - address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask); - } else { - address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask); - } - - address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK); - - address++; - } - - /* Fill in physical addresses for each interface */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFPHYS)) - continue; - - address = *addresses; - - for (i = 0; i < *count; i++) { - if (strcmp(address->name, ent->ifa_name) == 0) { -#if defined(__CYGWIN__) || defined(__MSYS__) - memset(address->phys_addr, 0, sizeof(address->phys_addr)); -#else - struct sockaddr_dl* sa_addr; - sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); - memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); -#endif - } - address++; - } - } - - freeifaddrs(addrs); - - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/core.c b/lib/ESPiLight/pilight/libs/libuv/unix/core.c deleted file mode 100644 index 07a1c19..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/core.c +++ /dev/null @@ -1,1334 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include /* NULL */ -#include /* printf */ -#include -#include /* strerror */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* INT_MAX, PATH_MAX, IOV_MAX */ -#include /* writev */ -#include /* getrusage */ -#include - -#ifdef __sun -# include /* MAXHOSTNAMELEN on Solaris */ -# include -# include -# include -#endif - -#ifdef __APPLE__ -# include /* _NSGetExecutablePath */ -# include -# if defined(O_CLOEXEC) -# define UV__O_CLOEXEC O_CLOEXEC -# endif -#endif - -#if defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) -# include -# include -# include -# define UV__O_CLOEXEC O_CLOEXEC -# if defined(__FreeBSD__) && __FreeBSD__ >= 10 -# define uv__accept4 accept4 -# define UV__SOCK_NONBLOCK SOCK_NONBLOCK -# define UV__SOCK_CLOEXEC SOCK_CLOEXEC -# endif -# if !defined(F_DUP2FD_CLOEXEC) && defined(_F_DUP2FD_CLOEXEC) -# define F_DUP2FD_CLOEXEC _F_DUP2FD_CLOEXEC -# endif -#endif - -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 -# include /* for dlsym */ -#endif - -#if defined(__MVS__) -#include -#endif - -#if !defined(__MVS__) -#include /* MAXHOSTNAMELEN on Linux and the BSDs */ -#endif - -/* Fallback for the maximum hostname length */ -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 256 -#endif - -static int uv__run_pending(uv_loop_t* loop); - -/* Verify that uv_buf_t is ABI-compatible with struct iovec. */ -STATIC_ASSERT(sizeof(uv_buf_t) == sizeof(struct iovec)); -STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->base) == - sizeof(((struct iovec*) 0)->iov_base)); -STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->len) == - sizeof(((struct iovec*) 0)->iov_len)); -STATIC_ASSERT(offsetof(uv_buf_t, base) == offsetof(struct iovec, iov_base)); -STATIC_ASSERT(offsetof(uv_buf_t, len) == offsetof(struct iovec, iov_len)); - - -uint64_t uv_hrtime(void) { - return uv__hrtime(UV_CLOCK_PRECISE); -} - - -void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { - assert(!uv__is_closing(handle)); - - handle->flags |= UV_CLOSING; - handle->close_cb = close_cb; - - switch (handle->type) { - case UV_NAMED_PIPE: - uv__pipe_close((uv_pipe_t*)handle); - break; - - case UV_TTY: - uv__stream_close((uv_stream_t*)handle); - break; - - case UV_TCP: - uv__tcp_close((uv_tcp_t*)handle); - break; - - case UV_UDP: - uv__udp_close((uv_udp_t*)handle); - break; - - case UV_PREPARE: - uv__prepare_close((uv_prepare_t*)handle); - break; - - case UV_CHECK: - uv__check_close((uv_check_t*)handle); - break; - - case UV_IDLE: - uv__idle_close((uv_idle_t*)handle); - break; - - case UV_ASYNC: - uv__async_close((uv_async_t*)handle); - break; - - case UV_TIMER: - uv__timer_close((uv_timer_t*)handle); - break; - - case UV_PROCESS: - uv__process_close((uv_process_t*)handle); - break; - - case UV_FS_EVENT: - uv__fs_event_close((uv_fs_event_t*)handle); - break; - - case UV_POLL: - uv__poll_close((uv_poll_t*)handle); - break; - - case UV_FS_POLL: - uv__fs_poll_close((uv_fs_poll_t*)handle); - break; - - case UV_SIGNAL: - uv__signal_close((uv_signal_t*) handle); - /* Signal handles may not be closed immediately. The signal code will */ - /* itself close uv__make_close_pending whenever appropriate. */ - return; - - default: - assert(0); - } - - uv__make_close_pending(handle); -} - -int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) { - int r; - int fd; - socklen_t len; - - if (handle == NULL || value == NULL) - return -EINVAL; - - if (handle->type == UV_TCP || handle->type == UV_NAMED_PIPE) - fd = uv__stream_fd((uv_stream_t*) handle); - else if (handle->type == UV_UDP) - fd = ((uv_udp_t *) handle)->io_watcher.fd; - else - return -ENOTSUP; - - len = sizeof(*value); - - if (*value == 0) - r = getsockopt(fd, SOL_SOCKET, optname, value, &len); - else - r = setsockopt(fd, SOL_SOCKET, optname, (const void*) value, len); - - if (r < 0) - return -errno; - - return 0; -} - -void uv__make_close_pending(uv_handle_t* handle) { - assert(handle->flags & UV_CLOSING); - assert(!(handle->flags & UV_CLOSED)); - handle->next_closing = handle->loop->closing_handles; - handle->loop->closing_handles = handle; -} - -int uv__getiovmax(void) { -#if defined(IOV_MAX) - return IOV_MAX; -#elif defined(_SC_IOV_MAX) - static int iovmax = -1; - if (iovmax == -1) { - iovmax = sysconf(_SC_IOV_MAX); - /* On some embedded devices (arm-linux-uclibc based ip camera), - * sysconf(_SC_IOV_MAX) can not get the correct value. The return - * value is -1 and the errno is EINPROGRESS. Degrade the value to 1. - */ - if (iovmax == -1) iovmax = 1; - } - return iovmax; -#else - return 1024; -#endif -} - - -static void uv__finish_close(uv_handle_t* handle) { - /* Note: while the handle is in the UV_CLOSING state now, it's still possible - * for it to be active in the sense that uv__is_active() returns true. - * A good example is when the user calls uv_shutdown(), immediately followed - * by uv_close(). The handle is considered active at this point because the - * completion of the shutdown req is still pending. - */ - assert(handle->flags & UV_CLOSING); - assert(!(handle->flags & UV_CLOSED)); - handle->flags |= UV_CLOSED; - - switch (handle->type) { - case UV_PREPARE: - case UV_CHECK: - case UV_IDLE: - case UV_ASYNC: - case UV_TIMER: - case UV_PROCESS: - case UV_FS_EVENT: - case UV_FS_POLL: - case UV_POLL: - case UV_SIGNAL: - break; - - case UV_NAMED_PIPE: - case UV_TCP: - case UV_TTY: - uv__stream_destroy((uv_stream_t*)handle); - break; - - case UV_UDP: - uv__udp_finish_close((uv_udp_t*)handle); - break; - - default: - assert(0); - break; - } - - uv__handle_unref(handle); - QUEUE_REMOVE(&handle->handle_queue); - - if (handle->close_cb) { - handle->close_cb(handle); - } -} - - -static void uv__run_closing_handles(uv_loop_t* loop) { - uv_handle_t* p; - uv_handle_t* q; - - p = loop->closing_handles; - loop->closing_handles = NULL; - - while (p) { - q = p->next_closing; - uv__finish_close(p); - p = q; - } -} - - -int uv_is_closing(const uv_handle_t* handle) { - return uv__is_closing(handle); -} - - -int uv_backend_fd(const uv_loop_t* loop) { - return loop->backend_fd; -} - - -int uv_backend_timeout(const uv_loop_t* loop) { - if (loop->stop_flag != 0) - return 0; - - if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop)) - return 0; - - if (!QUEUE_EMPTY(&loop->idle_handles)) - return 0; - - if (!QUEUE_EMPTY(&loop->pending_queue)) - return 0; - - if (loop->closing_handles) - return 0; - - return uv__next_timeout(loop); -} - - -static int uv__loop_alive(const uv_loop_t* loop) { - return uv__has_active_handles(loop) || - uv__has_active_reqs(loop) || - loop->closing_handles != NULL; -} - - -int uv_loop_alive(const uv_loop_t* loop) { - return uv__loop_alive(loop); -} - - -int uv_run(uv_loop_t* loop, uv_run_mode mode) { - int timeout; - int r; - int ran_pending; - - r = uv__loop_alive(loop); - if (!r) - uv__update_time(loop); - - while (r != 0 && loop->stop_flag == 0) { - uv__update_time(loop); - uv__run_timers(loop); - ran_pending = uv__run_pending(loop); - uv__run_idle(loop); - uv__run_prepare(loop); - - timeout = 0; - if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT) - timeout = uv_backend_timeout(loop); - - uv__io_poll(loop, timeout); - uv__run_check(loop); - uv__run_closing_handles(loop); - - if (mode == UV_RUN_ONCE) { - /* UV_RUN_ONCE implies forward progress: at least one callback must have - * been invoked when it returns. uv__io_poll() can return without doing - * I/O (meaning: no callbacks) when its timeout expires - which means we - * have pending timers that satisfy the forward progress constraint. - * - * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from - * the check. - */ - uv__update_time(loop); - uv__run_timers(loop); - } - - r = uv__loop_alive(loop); - if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) - break; - } - - /* The if statement lets gcc compile it to a conditional store. Avoids - * dirtying a cache line. - */ - if (loop->stop_flag != 0) - loop->stop_flag = 0; - - return r; -} - - -void uv_update_time(uv_loop_t* loop) { - uv__update_time(loop); -} - - -int uv_is_active(const uv_handle_t* handle) { - return uv__is_active(handle); -} - - -/* Open a socket in non-blocking close-on-exec mode, atomically if possible. */ -int uv__socket(int domain, int type, int protocol) { - int sockfd; - int err; - -#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC) - sockfd = socket(domain, type | SOCK_NONBLOCK | SOCK_CLOEXEC, protocol); - if (sockfd != -1) - return sockfd; - - if (errno != EINVAL) - return -errno; -#endif - - sockfd = socket(domain, type, protocol); - if (sockfd == -1) - return -errno; - - err = uv__nonblock(sockfd, 1); - if (err == 0) - err = uv__cloexec(sockfd, 1); - - if (err) { - uv__close(sockfd); - return err; - } - -#if defined(SO_NOSIGPIPE) - { - int on = 1; - setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on)); - } -#endif - - return sockfd; -} - -/* get a file pointer to a file in read-only and close-on-exec mode */ -FILE* uv__open_file(const char* path) { - int fd; - FILE* fp; - - fd = uv__open_cloexec(path, O_RDONLY); - if (fd < 0) - return NULL; - - fp = fdopen(fd, "r"); - if (fp == NULL) - uv__close(fd); - - return fp; -} - - -int uv__accept(int sockfd) { - int peerfd; - int err; - - assert(sockfd >= 0); - - while (1) { -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) - static int no_accept4; - - if (no_accept4) - goto skip; - - peerfd = uv__accept4(sockfd, - NULL, - NULL, - UV__SOCK_NONBLOCK|UV__SOCK_CLOEXEC); - if (peerfd != -1) - return peerfd; - - if (errno == EINTR) - continue; - - if (errno != ENOSYS) - return -errno; - - no_accept4 = 1; -skip: -#endif - - peerfd = accept(sockfd, NULL, NULL); - if (peerfd == -1) { - if (errno == EINTR) - continue; - return -errno; - } - - err = uv__cloexec(peerfd, 1); - if (err == 0) - err = uv__nonblock(peerfd, 1); - - if (err) { - uv__close(peerfd); - return err; - } - - return peerfd; - } -} - - -int uv__close_nocheckstdio(int fd) { - int saved_errno; - int rc; - - assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */ - - saved_errno = errno; - rc = close(fd); - if (rc == -1) { - rc = -errno; - if (rc == -EINTR || rc == -EINPROGRESS) - rc = 0; /* The close is in progress, not an error. */ - errno = saved_errno; - } - - return rc; -} - - -int uv__close(int fd) { - assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */ -#if defined(__MVS__) - epoll_file_close(fd); -#endif - return uv__close_nocheckstdio(fd); -} - - -int uv__nonblock_ioctl(int fd, int set) { - int r; - - do - r = ioctl(fd, FIONBIO, &set); - while (r == -1 && errno == EINTR); - - if (r) - return -errno; - - return 0; -} - - -#if !defined(__CYGWIN__) && !defined(__MSYS__) -int uv__cloexec_ioctl(int fd, int set) { - int r; - - do - r = ioctl(fd, set ? FIOCLEX : FIONCLEX); - while (r == -1 && errno == EINTR); - - if (r) - return -errno; - - return 0; -} -#endif - - -int uv__nonblock_fcntl(int fd, int set) { - int flags; - int r; - - do - r = fcntl(fd, F_GETFL); - while (r == -1 && errno == EINTR); - - if (r == -1) - return -errno; - - /* Bail out now if already set/clear. */ - if (!!(r & O_NONBLOCK) == !!set) - return 0; - - if (set) - flags = r | O_NONBLOCK; - else - flags = r & ~O_NONBLOCK; - - do - r = fcntl(fd, F_SETFL, flags); - while (r == -1 && errno == EINTR); - - if (r) - return -errno; - - return 0; -} - - -int uv__cloexec_fcntl(int fd, int set) { - int flags; - int r; - - do - r = fcntl(fd, F_GETFD); - while (r == -1 && errno == EINTR); - - if (r == -1) - return -errno; - - /* Bail out now if already set/clear. */ - if (!!(r & FD_CLOEXEC) == !!set) - return 0; - - if (set) - flags = r | FD_CLOEXEC; - else - flags = r & ~FD_CLOEXEC; - - do - r = fcntl(fd, F_SETFD, flags); - while (r == -1 && errno == EINTR); - - if (r) - return -errno; - - return 0; -} - - -/* This function is not execve-safe, there is a race window - * between the call to dup() and fcntl(FD_CLOEXEC). - */ -int uv__dup(int fd) { - int err; - - fd = dup(fd); - - if (fd == -1) - return -errno; - - err = uv__cloexec(fd, 1); - if (err) { - uv__close(fd); - return err; - } - - return fd; -} - - -ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) { - struct cmsghdr* cmsg; - ssize_t rc; - int* pfd; - int* end; -#if defined(__linux__) - static int no_msg_cmsg_cloexec; - if (no_msg_cmsg_cloexec == 0) { - rc = recvmsg(fd, msg, flags | 0x40000000); /* MSG_CMSG_CLOEXEC */ - if (rc != -1) - return rc; - if (errno != EINVAL) - return -errno; - rc = recvmsg(fd, msg, flags); - if (rc == -1) - return -errno; - no_msg_cmsg_cloexec = 1; - } else { - rc = recvmsg(fd, msg, flags); - } -#else - rc = recvmsg(fd, msg, flags); -#endif - if (rc == -1) - return -errno; - if (msg->msg_controllen == 0) - return rc; - for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) - if (cmsg->cmsg_type == SCM_RIGHTS) - for (pfd = (int*) CMSG_DATA(cmsg), - end = (int*) ((char*) cmsg + cmsg->cmsg_len); - pfd < end; - pfd += 1) - uv__cloexec(*pfd, 1); - return rc; -} - - -int uv_cwd(char* buffer, size_t* size) { - if (buffer == NULL || size == NULL) - return -EINVAL; - - if (getcwd(buffer, *size) == NULL) - return -errno; - - *size = strlen(buffer); - if (*size > 1 && buffer[*size - 1] == '/') { - buffer[*size-1] = '\0'; - (*size)--; - } - - return 0; -} - - -int uv_chdir(const char* dir) { - if (chdir(dir)) - return -errno; - - return 0; -} - - -void uv_disable_stdio_inheritance(void) { - int fd; - - /* Set the CLOEXEC flag on all open descriptors. Unconditionally try the - * first 16 file descriptors. After that, bail out after the first error. - */ - for (fd = 0; ; fd++) - if (uv__cloexec(fd, 1) && fd > 15) - break; -} - - -int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) { - int fd_out; - - switch (handle->type) { - case UV_TCP: - case UV_NAMED_PIPE: - case UV_TTY: - fd_out = uv__stream_fd((uv_stream_t*) handle); - break; - - case UV_UDP: - fd_out = ((uv_udp_t *) handle)->io_watcher.fd; - break; - - case UV_POLL: - fd_out = ((uv_poll_t *) handle)->io_watcher.fd; - break; - - default: - return -EINVAL; - } - - if (uv__is_closing(handle) || fd_out == -1) - return -EBADF; - - *fd = fd_out; - return 0; -} - - -static int uv__run_pending(uv_loop_t* loop) { - QUEUE* q; - QUEUE pq; - uv__io_t* w; - - if (QUEUE_EMPTY(&loop->pending_queue)) - return 0; - - QUEUE_MOVE(&loop->pending_queue, &pq); - - while (!QUEUE_EMPTY(&pq)) { - q = QUEUE_HEAD(&pq); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - w = QUEUE_DATA(q, uv__io_t, pending_queue); - w->cb(loop, w, POLLOUT); - } - - return 1; -} - - -static unsigned int next_power_of_two(unsigned int val) { - val -= 1; - val |= val >> 1; - val |= val >> 2; - val |= val >> 4; - val |= val >> 8; - val |= val >> 16; - val += 1; - return val; -} - -static void maybe_resize(uv_loop_t* loop, unsigned int len) { - uv__io_t** watchers; - void* fake_watcher_list; - void* fake_watcher_count; - unsigned int nwatchers; - unsigned int i; - - if (len <= loop->nwatchers) - return; - - /* Preserve fake watcher list and count at the end of the watchers */ - if (loop->watchers != NULL) { - fake_watcher_list = loop->watchers[loop->nwatchers]; - fake_watcher_count = loop->watchers[loop->nwatchers + 1]; - } else { - fake_watcher_list = NULL; - fake_watcher_count = NULL; - } - - nwatchers = next_power_of_two(len + 2) - 2; - watchers = uv__realloc(loop->watchers, - (nwatchers + 2) * sizeof(loop->watchers[0])); - - if (watchers == NULL) - abort(); - for (i = loop->nwatchers; i < nwatchers; i++) - watchers[i] = NULL; - watchers[nwatchers] = fake_watcher_list; - watchers[nwatchers + 1] = fake_watcher_count; - - loop->watchers = watchers; - loop->nwatchers = nwatchers; -} - - -void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) { - assert(cb != NULL); - assert(fd >= -1); - QUEUE_INIT(&w->pending_queue); - QUEUE_INIT(&w->watcher_queue); - w->cb = cb; - w->fd = fd; - w->events = 0; - w->pevents = 0; - -// #if defined(UV_HAVE_KQUEUE) - // w->rcount = 0; - // w->wcount = 0; -// #endif /* defined(UV_HAVE_KQUEUE) */ -} - - -void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI))); - assert(0 != events); - assert(w->fd >= 0); - assert(w->fd < INT_MAX); - - w->pevents |= events; - maybe_resize(loop, w->fd + 1); - -#if !defined(__sun) - /* The event ports backend needs to rearm all file descriptors on each and - * every tick of the event loop but the other backends allow us to - * short-circuit here if the event mask is unchanged. - */ - if (w->events == w->pevents) - return; -#endif - - if (QUEUE_EMPTY(&w->watcher_queue)) - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); - - if (loop->watchers[w->fd] == NULL) { - loop->watchers[w->fd] = w; - loop->nfds++; - } -} - - -void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI))); - assert(0 != events); - - if (w->fd == -1) - return; - - assert(w->fd >= 0); - - /* Happens when uv__io_stop() is called on a handle that was never started. */ - if ((unsigned) w->fd >= loop->nwatchers) - return; - - w->pevents &= ~events; - - if (w->pevents == 0) { - QUEUE_REMOVE(&w->watcher_queue); - QUEUE_INIT(&w->watcher_queue); - - if (loop->watchers[w->fd] != NULL) { - assert(loop->watchers[w->fd] == w); - assert(loop->nfds > 0); - loop->watchers[w->fd] = NULL; - loop->nfds--; - w->events = 0; - } - } - else if (QUEUE_EMPTY(&w->watcher_queue)) - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); -} - - -void uv__io_close(uv_loop_t* loop, uv__io_t* w) { - uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI); - QUEUE_REMOVE(&w->pending_queue); - - /* Remove stale events for this file descriptor */ - uv__platform_invalidate_fd(loop, w->fd); -} - - -void uv__io_feed(uv_loop_t* loop, uv__io_t* w) { - if (QUEUE_EMPTY(&w->pending_queue)) - QUEUE_INSERT_TAIL(&loop->pending_queue, &w->pending_queue); -} - - -int uv__io_active(const uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI))); - assert(0 != events); - return 0 != (w->pevents & events); -} - - -int uv_getrusage(uv_rusage_t* rusage) { - struct rusage usage; - - if (getrusage(RUSAGE_SELF, &usage)) - return -errno; - - rusage->ru_utime.tv_sec = usage.ru_utime.tv_sec; - rusage->ru_utime.tv_usec = usage.ru_utime.tv_usec; - - rusage->ru_stime.tv_sec = usage.ru_stime.tv_sec; - rusage->ru_stime.tv_usec = usage.ru_stime.tv_usec; - -#if !defined(__MVS__) - rusage->ru_maxrss = usage.ru_maxrss; - rusage->ru_ixrss = usage.ru_ixrss; - rusage->ru_idrss = usage.ru_idrss; - rusage->ru_isrss = usage.ru_isrss; - rusage->ru_minflt = usage.ru_minflt; - rusage->ru_majflt = usage.ru_majflt; - rusage->ru_nswap = usage.ru_nswap; - rusage->ru_inblock = usage.ru_inblock; - rusage->ru_oublock = usage.ru_oublock; - rusage->ru_msgsnd = usage.ru_msgsnd; - rusage->ru_msgrcv = usage.ru_msgrcv; - rusage->ru_nsignals = usage.ru_nsignals; - rusage->ru_nvcsw = usage.ru_nvcsw; - rusage->ru_nivcsw = usage.ru_nivcsw; -#endif - - return 0; -} - - -int uv__open_cloexec(const char* path, int flags) { - int err; - int fd; - -#if defined(UV__O_CLOEXEC) - static int no_cloexec; - - if (!no_cloexec) { - fd = open(path, flags | UV__O_CLOEXEC); - if (fd != -1) - return fd; - - if (errno != EINVAL) - return -errno; - - /* O_CLOEXEC not supported. */ - no_cloexec = 1; - } -#endif - - fd = open(path, flags); - if (fd == -1) - return -errno; - - err = uv__cloexec(fd, 1); - if (err) { - uv__close(fd); - return err; - } - - return fd; -} - - -int uv__dup2_cloexec(int oldfd, int newfd) { - int r; -#if defined(__FreeBSD__) && __FreeBSD__ >= 10 - r = dup3(oldfd, newfd, O_CLOEXEC); - if (r == -1) - return -errno; - return r; -#elif defined(__FreeBSD__) && defined(F_DUP2FD_CLOEXEC) - r = fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd); - if (r != -1) - return r; - if (errno != EINVAL) - return -errno; - /* Fall through. */ -#elif defined(__linux__) - static int no_dup3; - if (!no_dup3) { - do - r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC); - while (r == -1 && errno == EBUSY); - if (r != -1) - return r; - if (errno != ENOSYS) - return -errno; - /* Fall through. */ - no_dup3 = 1; - } -#endif - { - int err; - do - r = dup2(oldfd, newfd); -#if defined(__linux__) - while (r == -1 && errno == EBUSY); -#else - while (0); /* Never retry. */ -#endif - - if (r == -1) - return -errno; - - err = uv__cloexec(newfd, 1); - if (err) { - uv__close(newfd); - return err; - } - - return r; - } -} - - -int uv_os_homedir(char* buffer, size_t* size) { - uv_passwd_t pwd; - char* buf; - size_t len; - int r; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - /* Check if the HOME environment variable is set first */ - buf = getenv("HOME"); - - if (buf != NULL) { - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return -ENOBUFS; - } - - memcpy(buffer, buf, len + 1); - *size = len; - - return 0; - } - - /* HOME is not set, so call uv__getpwuid_r() */ - r = uv__getpwuid_r(&pwd); - - if (r != 0) { - return r; - } - - len = strlen(pwd.homedir); - - if (len >= *size) { - *size = len + 1; - uv_os_free_passwd(&pwd); - return -ENOBUFS; - } - - memcpy(buffer, pwd.homedir, len + 1); - *size = len; - uv_os_free_passwd(&pwd); - - return 0; -} - - -int uv_os_tmpdir(char* buffer, size_t* size) { - const char* buf; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - -#define CHECK_ENV_VAR(name) \ - do { \ - buf = getenv(name); \ - if (buf != NULL) \ - goto return_buffer; \ - } \ - while (0) - - /* Check the TMPDIR, TMP, TEMP, and TEMPDIR environment variables in order */ - CHECK_ENV_VAR("TMPDIR"); - CHECK_ENV_VAR("TMP"); - CHECK_ENV_VAR("TEMP"); - CHECK_ENV_VAR("TEMPDIR"); - -#undef CHECK_ENV_VAR - - /* No temp environment variables defined */ - #if defined(__ANDROID__) - buf = "/data/local/tmp"; - #else - buf = "/tmp"; - #endif - -return_buffer: - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return -ENOBUFS; - } - - /* The returned directory should not have a trailing slash. */ - if (len > 1 && buf[len - 1] == '/') { - len--; - } - - memcpy(buffer, buf, len + 1); - buffer[len] = '\0'; - *size = len; - - return 0; -} - - -int uv__getpwuid_r(uv_passwd_t* pwd) { - struct passwd pw; - struct passwd* result; - char* buf; - uid_t uid; - size_t bufsize; - size_t name_size; - size_t homedir_size; - size_t shell_size; - long initsize; - int r; -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 - int (*getpwuid_r)(uid_t, struct passwd*, char*, size_t, struct passwd**); - - getpwuid_r = dlsym(RTLD_DEFAULT, "getpwuid_r"); - if (getpwuid_r == NULL) - return -ENOSYS; -#endif - - if (pwd == NULL) - return -EINVAL; - - initsize = sysconf(_SC_GETPW_R_SIZE_MAX); - - if (initsize <= 0) - bufsize = 4096; - else - bufsize = (size_t) initsize; - - uid = geteuid(); - buf = NULL; - - for (;;) { - uv__free(buf); - buf = uv__malloc(bufsize); - - if (buf == NULL) - return -ENOMEM; - - r = getpwuid_r(uid, &pw, buf, bufsize, &result); - - if (r != ERANGE) - break; - - bufsize *= 2; - } - - if (r != 0) { - uv__free(buf); - return -r; - } - - if (result == NULL) { - uv__free(buf); - return -ENOENT; - } - - /* Allocate memory for the username, shell, and home directory */ - name_size = strlen(pw.pw_name) + 1; - homedir_size = strlen(pw.pw_dir) + 1; - shell_size = strlen(pw.pw_shell) + 1; - pwd->username = uv__malloc(name_size + homedir_size + shell_size); - - if (pwd->username == NULL) { - uv__free(buf); - return -ENOMEM; - } - - /* Copy the username */ - memcpy(pwd->username, pw.pw_name, name_size); - - /* Copy the home directory */ - pwd->homedir = pwd->username + name_size; - memcpy(pwd->homedir, pw.pw_dir, homedir_size); - - /* Copy the shell */ - pwd->shell = pwd->homedir + homedir_size; - memcpy(pwd->shell, pw.pw_shell, shell_size); - - /* Copy the uid and gid */ - pwd->uid = pw.pw_uid; - pwd->gid = pw.pw_gid; - - uv__free(buf); - - return 0; -} - - -void uv_os_free_passwd(uv_passwd_t* pwd) { - if (pwd == NULL) - return; - - /* - The memory for name, shell, and homedir are allocated in a single - uv__malloc() call. The base of the pointer is stored in pwd->username, so - that is the field that needs to be freed. - */ - uv__free(pwd->username); - pwd->username = NULL; - pwd->shell = NULL; - pwd->homedir = NULL; -} - - -int uv_os_get_passwd(uv_passwd_t* pwd) { - return uv__getpwuid_r(pwd); -} - - -int uv_translate_sys_error(int sys_errno) { - /* If < 0 then it's already a libuv error. */ - return sys_errno <= 0 ? sys_errno : -sys_errno; -} - - -int uv_os_getenv(const char* name, char* buffer, size_t* size) { - char* var; - size_t len; - - if (name == NULL || buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - var = getenv(name); - - if (var == NULL) - return -ENOENT; - - len = strlen(var); - - if (len >= *size) { - *size = len + 1; - return -ENOBUFS; - } - - memcpy(buffer, var, len + 1); - *size = len; - - return 0; -} - - -int uv_os_setenv(const char* name, const char* value) { - if (name == NULL || value == NULL) - return -EINVAL; - - if (setenv(name, value, 1) != 0) - return -errno; - - return 0; -} - - -int uv_os_unsetenv(const char* name) { - if (unsetenv(name) != 0) - return -errno; - - return 0; -} - - -int uv_os_gethostname(char* buffer, size_t* size) { - /* - On some platforms, if the input buffer is not large enough, gethostname() - succeeds, but truncates the result. libuv can detect this and return ENOBUFS - instead by creating a large enough buffer and comparing the hostname length - to the size input. - */ - char buf[MAXHOSTNAMELEN + 1]; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - if (gethostname(buf, sizeof(buf)) != 0) - return -errno; - - buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */ - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return -ENOBUFS; - } - - memcpy(buffer, buf, len + 1); - *size = len; - return 0; -} - - -uv_os_fd_t uv_get_osfhandle(int fd) { - return fd; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/cygwin.c b/lib/ESPiLight/pilight/libs/libuv/unix/cygwin.c deleted file mode 100644 index 5a887dd..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/cygwin.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -int uv_uptime(double* uptime) { - struct sysinfo info; - - if (sysinfo(&info) < 0) - return -errno; - - *uptime = info.uptime; - return 0; -} - -int uv_resident_set_memory(size_t* rss) { - /* FIXME: read /proc/meminfo? */ - *rss = 0; - return UV_ENOSYS; -} - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - /* FIXME: read /proc/stat? */ - *cpu_infos = NULL; - *count = 0; - return UV_ENOSYS; -} - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - (void)cpu_infos; - (void)count; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/darwin-proctitle.c b/lib/ESPiLight/pilight/libs/libuv/unix/darwin-proctitle.c deleted file mode 100644 index 1142311..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/darwin-proctitle.c +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include - -#include - -#if !TARGET_OS_IPHONE -# include -# include -#endif - - -static int uv__pthread_setname_np(const char* name) { - int (*dynamic_pthread_setname_np)(const char* name); - char namebuf[64]; /* MAXTHREADNAMESIZE */ - int err; - - /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */ - *(void **)(&dynamic_pthread_setname_np) = - dlsym(RTLD_DEFAULT, "pthread_setname_np"); - - if (dynamic_pthread_setname_np == NULL) - return -ENOSYS; - - strncpy(namebuf, name, sizeof(namebuf) - 1); - namebuf[sizeof(namebuf) - 1] = '\0'; - - err = dynamic_pthread_setname_np(namebuf); - if (err) - return -err; - - return 0; -} - - -int uv__set_process_title(const char* title) { -#if TARGET_OS_IPHONE - return uv__pthread_setname_np(title); -#else - CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef, - const char*, - CFStringEncoding); - CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef); - void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef); - void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef); - CFTypeRef (*pLSGetCurrentApplicationASN)(void); - OSStatus (*pLSSetApplicationInformationItem)(int, - CFTypeRef, - CFStringRef, - CFStringRef, - CFDictionaryRef*); - void* application_services_handle; - void* core_foundation_handle; - CFBundleRef launch_services_bundle; - CFStringRef* display_name_key; - CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef); - CFBundleRef (*pCFBundleGetMainBundle)(void); - CFBundleRef hi_services_bundle; - OSStatus (*pSetApplicationIsDaemon)(int); - CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef); - void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t, - void*); - CFTypeRef asn; - int err; - - err = -ENOENT; - application_services_handle = dlopen("/System/Library/Frameworks/" - "ApplicationServices.framework/" - "Versions/A/ApplicationServices", - RTLD_LAZY | RTLD_LOCAL); - core_foundation_handle = dlopen("/System/Library/Frameworks/" - "CoreFoundation.framework/" - "Versions/A/CoreFoundation", - RTLD_LAZY | RTLD_LOCAL); - - if (application_services_handle == NULL || core_foundation_handle == NULL) - goto out; - - *(void **)(&pCFStringCreateWithCString) = - dlsym(core_foundation_handle, "CFStringCreateWithCString"); - *(void **)(&pCFBundleGetBundleWithIdentifier) = - dlsym(core_foundation_handle, "CFBundleGetBundleWithIdentifier"); - *(void **)(&pCFBundleGetDataPointerForName) = - dlsym(core_foundation_handle, "CFBundleGetDataPointerForName"); - *(void **)(&pCFBundleGetFunctionPointerForName) = - dlsym(core_foundation_handle, "CFBundleGetFunctionPointerForName"); - - if (pCFStringCreateWithCString == NULL || - pCFBundleGetBundleWithIdentifier == NULL || - pCFBundleGetDataPointerForName == NULL || - pCFBundleGetFunctionPointerForName == NULL) { - goto out; - } - -#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8) - - launch_services_bundle = - pCFBundleGetBundleWithIdentifier(S("com.apple.LaunchServices")); - - if (launch_services_bundle == NULL) - goto out; - - *(void **)(&pLSGetCurrentApplicationASN) = - pCFBundleGetFunctionPointerForName(launch_services_bundle, - S("_LSGetCurrentApplicationASN")); - - if (pLSGetCurrentApplicationASN == NULL) - goto out; - - *(void **)(&pLSSetApplicationInformationItem) = - pCFBundleGetFunctionPointerForName(launch_services_bundle, - S("_LSSetApplicationInformationItem")); - - if (pLSSetApplicationInformationItem == NULL) - goto out; - - display_name_key = pCFBundleGetDataPointerForName(launch_services_bundle, - S("_kLSDisplayNameKey")); - - if (display_name_key == NULL || *display_name_key == NULL) - goto out; - - *(void **)(&pCFBundleGetInfoDictionary) = dlsym(core_foundation_handle, - "CFBundleGetInfoDictionary"); - *(void **)(&pCFBundleGetMainBundle) = dlsym(core_foundation_handle, - "CFBundleGetMainBundle"); - if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL) - goto out; - - /* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */ - hi_services_bundle = - pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices")); - err = -ENOENT; - if (hi_services_bundle == NULL) - goto out; - - *(void **)(&pSetApplicationIsDaemon) = pCFBundleGetFunctionPointerForName( - hi_services_bundle, - S("SetApplicationIsDaemon")); - *(void **)(&pLSApplicationCheckIn) = pCFBundleGetFunctionPointerForName( - launch_services_bundle, - S("_LSApplicationCheckIn")); - *(void **)(&pLSSetApplicationLaunchServicesServerConnectionStatus) = - pCFBundleGetFunctionPointerForName( - launch_services_bundle, - S("_LSSetApplicationLaunchServicesServerConnectionStatus")); - if (pSetApplicationIsDaemon == NULL || - pLSApplicationCheckIn == NULL || - pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) { - goto out; - } - - if (pSetApplicationIsDaemon(1) != noErr) - goto out; - - pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL); - - /* Check into process manager?! */ - pLSApplicationCheckIn(-2, - pCFBundleGetInfoDictionary(pCFBundleGetMainBundle())); - - asn = pLSGetCurrentApplicationASN(); - - err = -EINVAL; - if (pLSSetApplicationInformationItem(-2, /* Magic value. */ - asn, - *display_name_key, - S(title), - NULL) != noErr) { - goto out; - } - - uv__pthread_setname_np(title); /* Don't care if it fails. */ - err = 0; - -out: - if (core_foundation_handle != NULL) - dlclose(core_foundation_handle); - - if (application_services_handle != NULL) - dlclose(application_services_handle); - - return err; -#endif /* !TARGET_OS_IPHONE */ -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/darwin.c b/lib/ESPiLight/pilight/libs/libuv/unix/darwin.c deleted file mode 100644 index df6dd1c..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/darwin.c +++ /dev/null @@ -1,231 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include - -#include -#include -#include /* _NSGetExecutablePath */ -#include -#include -#include /* sysconf */ - - -int uv__platform_loop_init(uv_loop_t* loop) { - loop->cf_state = NULL; - - if (uv__kqueue_init(loop)) - return -errno; - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - uv__fsevents_loop_delete(loop); -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - static mach_timebase_info_data_t info; - - if ((ACCESS_ONCE(uint32_t, info.numer) == 0 || - ACCESS_ONCE(uint32_t, info.denom) == 0) && - mach_timebase_info(&info) != KERN_SUCCESS) - abort(); - - return mach_absolute_time() * info.numer / info.denom; -} - - -int uv_exepath(char* buffer, size_t* size) { - /* realpath(exepath) may be > PATH_MAX so double it to be on the safe side. */ - char abspath[PATH_MAX * 2 + 1]; - char exepath[PATH_MAX + 1]; - uint32_t exepath_size; - size_t abspath_size; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - exepath_size = sizeof(exepath); - if (_NSGetExecutablePath(exepath, &exepath_size)) - return -EIO; - - if (realpath(exepath, abspath) != abspath) - return -errno; - - abspath_size = strlen(abspath); - if (abspath_size == 0) - return -EIO; - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; -} - - -uint64_t uv_get_free_memory(void) { - vm_statistics_data_t info; - mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t); - - if (host_statistics(mach_host_self(), HOST_VM_INFO, - (host_info_t)&info, &count) != KERN_SUCCESS) { - return -EINVAL; /* FIXME(bnoordhuis) Translate error. */ - } - - return (uint64_t) info.free_count * sysconf(_SC_PAGESIZE); -} - - -uint64_t uv_get_total_memory(void) { - uint64_t info; - int which[] = {CTL_HW, HW_MEMSIZE}; - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - return (uint64_t) info; -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -int uv_resident_set_memory(size_t* rss) { - mach_msg_type_number_t count; - task_basic_info_data_t info; - kern_return_t err; - - count = TASK_BASIC_INFO_COUNT; - err = task_info(mach_task_self(), - TASK_BASIC_INFO, - (task_info_t) &info, - &count); - (void) &err; - /* task_info(TASK_BASIC_INFO) cannot really fail. Anything other than - * KERN_SUCCESS implies a libuv bug. - */ - assert(err == KERN_SUCCESS); - *rss = info.resident_size; - - return 0; -} - - -int uv_uptime(double* uptime) { - time_t now; - struct timeval info; - size_t size = sizeof(info); - static int which[] = {CTL_KERN, KERN_BOOTTIME}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - now = time(NULL); - *uptime = now - info.tv_sec; - - return 0; -} - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), - multiplier = ((uint64_t)1000L / ticks); - char model[512]; - uint64_t cpuspeed; - size_t size; - unsigned int i; - natural_t numcpus; - mach_msg_type_number_t msg_type; - processor_cpu_load_info_data_t *info; - uv_cpu_info_t* cpu_info; - - size = sizeof(model); - if (sysctlbyname("machdep.cpu.brand_string", &model, &size, NULL, 0) && - sysctlbyname("hw.model", &model, &size, NULL, 0)) { - return -errno; - } - - size = sizeof(cpuspeed); - if (sysctlbyname("hw.cpufrequency", &cpuspeed, &size, NULL, 0)) - return -errno; - - if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numcpus, - (processor_info_array_t*)&info, - &msg_type) != KERN_SUCCESS) { - return -EINVAL; /* FIXME(bnoordhuis) Translate error. */ - } - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) { - vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type); - return -ENOMEM; - } - - *count = numcpus; - - for (i = 0; i < numcpus; i++) { - cpu_info = &(*cpu_infos)[i]; - - cpu_info->cpu_times.user = (uint64_t)(info[i].cpu_ticks[0]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(info[i].cpu_ticks[3]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(info[i].cpu_ticks[1]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(info[i].cpu_ticks[2]) * multiplier; - cpu_info->cpu_times.irq = 0; - - cpu_info->model = uv__strdup(model); - cpu_info->speed = cpuspeed/1000000; - } - vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type); - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/dl.c b/lib/ESPiLight/pilight/libs/libuv/unix/dl.c deleted file mode 100644 index fc1c052..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/dl.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include - -static int uv__dlerror(uv_lib_t* lib); - - -int uv_dlopen(const char* filename, uv_lib_t* lib) { - dlerror(); /* Reset error status. */ - lib->errmsg = NULL; - lib->handle = dlopen(filename, RTLD_LAZY); - return lib->handle ? 0 : uv__dlerror(lib); -} - - -void uv_dlclose(uv_lib_t* lib) { - uv__free(lib->errmsg); - lib->errmsg = NULL; - - if (lib->handle) { - /* Ignore errors. No good way to signal them without leaking memory. */ - dlclose(lib->handle); - lib->handle = NULL; - } -} - - -int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { - dlerror(); /* Reset error status. */ - *ptr = dlsym(lib->handle, name); - return uv__dlerror(lib); -} - - -const char* uv_dlerror(const uv_lib_t* lib) { - return lib->errmsg ? lib->errmsg : "no error"; -} - - -static int uv__dlerror(uv_lib_t* lib) { - const char* errmsg; - - uv__free(lib->errmsg); - - errmsg = dlerror(); - - if (errmsg) { - lib->errmsg = uv__strdup(errmsg); - return -1; - } - else { - lib->errmsg = NULL; - return 0; - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/freebsd.c b/lib/ESPiLight/pilight/libs/libuv/unix/freebsd.c deleted file mode 100644 index e52ae99..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/freebsd.c +++ /dev/null @@ -1,346 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include /* VM_LOADAVG */ -#include -#include -#include /* sysconf */ -#include - -#ifndef CPUSTATES -# define CPUSTATES 5U -#endif -#ifndef CP_USER -# define CP_USER 0 -# define CP_NICE 1 -# define CP_SYS 2 -# define CP_IDLE 3 -# define CP_INTR 4 -#endif - -static char *process_title; - - -int uv__platform_loop_init(uv_loop_t* loop) { - return uv__kqueue_init(loop); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { -} - - -#ifdef __DragonFly__ -int uv_exepath(char* buffer, size_t* size) { - char abspath[PATH_MAX * 2 + 1]; - ssize_t abspath_size; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - abspath_size = readlink("/proc/curproc/file", abspath, sizeof(abspath)); - if (abspath_size < 0) - return -errno; - - assert(abspath_size > 0); - *size -= 1; - - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; -} -#else -int uv_exepath(char* buffer, size_t* size) { - char abspath[PATH_MAX * 2 + 1]; - int mib[4]; - size_t abspath_size; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PATHNAME; - mib[3] = -1; - - abspath_size = sizeof abspath; - if (sysctl(mib, 4, abspath, &abspath_size, NULL, 0)) - return -errno; - - assert(abspath_size > 0); - abspath_size -= 1; - *size -= 1; - - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; -} -#endif - -uint64_t uv_get_free_memory(void) { - int freecount; - size_t size = sizeof(freecount); - - if (sysctlbyname("vm.stats.vm.v_free_count", &freecount, &size, NULL, 0)) - return -errno; - - return (uint64_t) freecount * sysconf(_SC_PAGESIZE); - -} - - -uint64_t uv_get_total_memory(void) { - unsigned long info; - int which[] = {CTL_HW, HW_PHYSMEM}; - - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - return (uint64_t) info; -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - int oid[4]; - - uv__free(process_title); - process_title = uv__strdup(title); - - oid[0] = CTL_KERN; - oid[1] = KERN_PROC; - oid[2] = KERN_PROC_ARGS; - oid[3] = getpid(); - - sysctl(oid, - ARRAY_SIZE(oid), - NULL, - NULL, - process_title, - strlen(process_title) + 1); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return -EINVAL; - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) - return -ENOBUFS; - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - buffer[len] = '\0'; - - return 0; -} - - -int uv_resident_set_memory(size_t* rss) { - kvm_t *kd = NULL; - struct kinfo_proc *kinfo = NULL; - pid_t pid; - int nprocs; - size_t page_size = getpagesize(); - - pid = getpid(); - - kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open"); - if (kd == NULL) goto error; - - kinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, &nprocs); - if (kinfo == NULL) goto error; - -#ifdef __DragonFly__ - *rss = kinfo->kp_vm_rssize * page_size; -#else - *rss = kinfo->ki_rssize * page_size; -#endif - - kvm_close(kd); - - return 0; - -error: - if (kd) kvm_close(kd); - return -EPERM; -} - - -int uv_uptime(double* uptime) { - int r; - struct timespec sp; - r = clock_gettime(CLOCK_MONOTONIC, &sp); - if (r) - return -errno; - - *uptime = sp.tv_sec; - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), - multiplier = ((uint64_t)1000L / ticks), cpuspeed, maxcpus, - cur = 0; - uv_cpu_info_t* cpu_info; - const char* maxcpus_key; - const char* cptimes_key; - char model[512]; - long* cp_times; - int numcpus; - size_t size; - int i; - -#if defined(__DragonFly__) - /* This is not quite correct but DragonFlyBSD doesn't seem to have anything - * comparable to kern.smp.maxcpus or kern.cp_times (kern.cp_time is a total, - * not per CPU). At least this stops uv_cpu_info() from failing completely. - */ - maxcpus_key = "hw.ncpu"; - cptimes_key = "kern.cp_time"; -#else - maxcpus_key = "kern.smp.maxcpus"; - cptimes_key = "kern.cp_times"; -#endif - - size = sizeof(model); - if (sysctlbyname("hw.model", &model, &size, NULL, 0)) - return -errno; - - size = sizeof(numcpus); - if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0)) - return -errno; - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) - return -ENOMEM; - - *count = numcpus; - - size = sizeof(cpuspeed); - if (sysctlbyname("hw.clockrate", &cpuspeed, &size, NULL, 0)) { - uv__free(*cpu_infos); - return -errno; - } - - /* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of - * ncpu. - */ - size = sizeof(maxcpus); - if (sysctlbyname(maxcpus_key, &maxcpus, &size, NULL, 0)) { - uv__free(*cpu_infos); - return -errno; - } - - size = maxcpus * CPUSTATES * sizeof(long); - - cp_times = uv__malloc(size); - if (cp_times == NULL) { - uv__free(*cpu_infos); - return -ENOMEM; - } - - if (sysctlbyname(cptimes_key, cp_times, &size, NULL, 0)) { - uv__free(cp_times); - uv__free(*cpu_infos); - return -errno; - } - - for (i = 0; i < numcpus; i++) { - cpu_info = &(*cpu_infos)[i]; - - cpu_info->cpu_times.user = (uint64_t)(cp_times[CP_USER+cur]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(cp_times[CP_NICE+cur]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(cp_times[CP_SYS+cur]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(cp_times[CP_IDLE+cur]) * multiplier; - cpu_info->cpu_times.irq = (uint64_t)(cp_times[CP_INTR+cur]) * multiplier; - - cpu_info->model = uv__strdup(model); - cpu_info->speed = cpuspeed; - - cur+=CPUSTATES; - } - - uv__free(cp_times); - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/fs.c b/lib/ESPiLight/pilight/libs/libuv/unix/fs.c deleted file mode 100644 index f9513ea..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/fs.c +++ /dev/null @@ -1,1369 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* Caveat emptor: this file deviates from the libuv convention of returning - * negated errno codes. Most uv_fs_*() functions map directly to the system - * call of the same name. For more complex wrappers, it's easier to just - * return -1 with errno set. The dispatcher in uv__fs_work() takes care of - * getting the errno to the right place (req->result or as the return value.) - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include /* PATH_MAX */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel_) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# define HAVE_PREADV 1 -#else -# define HAVE_PREADV 0 -#endif - -#if defined(__linux__) || defined(__sun) -# include -#endif - -#define INIT(subtype) \ - do { \ - req->type = UV_FS; \ - if (cb != NULL) \ - uv__req_init(loop, req, UV_FS); \ - req->fs_type = UV_FS_ ## subtype; \ - req->result = 0; \ - req->ptr = NULL; \ - req->loop = loop; \ - req->path = NULL; \ - req->new_path = NULL; \ - req->cb = cb; \ - } \ - while (0) - -#define PATH \ - do { \ - assert(path != NULL); \ - if (cb == NULL) { \ - req->path = path; \ - } else { \ - req->path = uv__strdup(path); \ - if (req->path == NULL) { \ - uv__req_unregister(loop, req); \ - return -ENOMEM; \ - } \ - } \ - } \ - while (0) - -#define PATH2 \ - do { \ - if (cb == NULL) { \ - req->path = path; \ - req->new_path = new_path; \ - } else { \ - size_t path_len; \ - size_t new_path_len; \ - path_len = strlen(path) + 1; \ - new_path_len = strlen(new_path) + 1; \ - req->path = uv__malloc(path_len + new_path_len); \ - if (req->path == NULL) { \ - uv__req_unregister(loop, req); \ - return -ENOMEM; \ - } \ - req->new_path = req->path + path_len; \ - memcpy((void*) req->path, path, path_len); \ - memcpy((void*) req->new_path, new_path, new_path_len); \ - } \ - } \ - while (0) - -#define POST \ - do { \ - if (cb != NULL) { \ - uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \ - return 0; \ - } \ - else { \ - uv__fs_work(&req->work_req); \ - return req->result; \ - } \ - } \ - while (0) - - -static ssize_t uv__fs_fdatasync(uv_fs_t* req) { -#if defined(__linux__) || defined(__sun) || defined(__NetBSD__) - return fdatasync(req->file); -#elif defined(__APPLE__) - /* Apple's fdatasync and fsync explicitly do NOT flush the drive write cache - * to the drive platters. This is in contrast to Linux's fdatasync and fsync - * which do, according to recent man pages. F_FULLFSYNC is Apple's equivalent - * for flushing buffered data to permanent storage. - */ - return fcntl(req->file, F_FULLFSYNC); -#else - return fsync(req->file); -#endif -} - - -static ssize_t uv__fs_fsync(uv_fs_t* req) { -#if defined(__APPLE__) - /* See the comment in uv__fs_fdatasync. */ - return fcntl(req->file, F_FULLFSYNC); -#else - return fsync(req->file); -#endif -} - - -static ssize_t uv__fs_futime(uv_fs_t* req) { -#if defined(__linux__) - /* utimesat() has nanosecond resolution but we stick to microseconds - * for the sake of consistency with other platforms. - */ - static int no_utimesat; - struct timespec ts[2]; - struct timeval tv[2]; - char path[sizeof("/proc/self/fd/") + 3 * sizeof(int)]; - int r; - - if (no_utimesat) - goto skip; - - ts[0].tv_sec = req->atime; - ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = req->mtime; - ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; - - r = uv__utimesat(req->file, NULL, ts, 0); - if (r == 0) - return r; - - if (errno != ENOSYS) - return r; - - no_utimesat = 1; - -skip: - - tv[0].tv_sec = req->atime; - tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; - tv[1].tv_sec = req->mtime; - tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; - snprintf(path, sizeof(path), "/proc/self/fd/%d", (int) req->file); - - r = utimes(path, tv); - if (r == 0) - return r; - - switch (errno) { - case ENOENT: - if (fcntl(req->file, F_GETFL) == -1 && errno == EBADF) - break; - /* Fall through. */ - - case EACCES: - case ENOTDIR: - errno = ENOSYS; - break; - } - - return r; - -#elif defined(__APPLE__) \ - || defined(__DragonFly__) \ - || defined(__FreeBSD__) \ - || defined(__FreeBSD_kernel__) \ - || defined(__NetBSD__) \ - || defined(__OpenBSD__) \ - || defined(__sun) - struct timeval tv[2]; - tv[0].tv_sec = req->atime; - tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000; - tv[1].tv_sec = req->mtime; - tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000; -# if defined(__sun) - return futimesat(req->file, NULL, tv); -# else - return futimes(req->file, tv); -# endif -#elif defined(_AIX71) - struct timespec ts[2]; - ts[0].tv_sec = req->atime; - ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = req->mtime; - ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; - return futimens(req->file, ts); -#elif defined(__MVS__) - attrib_t atr; - memset(&atr, 0, sizeof(atr)); - atr.att_mtimechg = 1; - atr.att_atimechg = 1; - atr.att_mtime = req->mtime; - atr.att_atime = req->atime; - return __fchattr(req->file, &atr, sizeof(atr)); -#else - errno = ENOSYS; - return -1; -#endif -} - - -static ssize_t uv__fs_mkdtemp(uv_fs_t* req) { - return mkdtemp((char*) req->path) ? 0 : -1; -} - - -static ssize_t uv__fs_open(uv_fs_t* req) { - static int no_cloexec_support; - int r; - - /* Try O_CLOEXEC before entering locks */ - if (no_cloexec_support == 0) { -#ifdef O_CLOEXEC - r = open(req->path, req->flags | O_CLOEXEC, req->mode); - if (r >= 0) - return r; - if (errno != EINVAL) - return r; - no_cloexec_support = 1; -#endif /* O_CLOEXEC */ - } - - if (req->cb != NULL) - uv_rwlock_rdlock(&req->loop->cloexec_lock); - - r = open(req->path, req->flags, req->mode); - - /* In case of failure `uv__cloexec` will leave error in `errno`, - * so it is enough to just set `r` to `-1`. - */ - if (r >= 0 && uv__cloexec(r, 1) != 0) { - r = uv__close(r); - if (r != 0) - abort(); - r = -1; - } - - if (req->cb != NULL) - uv_rwlock_rdunlock(&req->loop->cloexec_lock); - - return r; -} - - -static ssize_t uv__fs_read(uv_fs_t* req) { -#if defined(__linux__) - static int no_preadv; -#endif - ssize_t result; - -#if defined(_AIX) - struct stat buf; - if(fstat(req->file, &buf)) - return -1; - if(S_ISDIR(buf.st_mode)) { - errno = EISDIR; - return -1; - } -#endif /* defined(_AIX) */ - if (req->off < 0) { - if (req->nbufs == 1) - result = read(req->file, req->bufs[0].base, req->bufs[0].len); - else - result = readv(req->file, (struct iovec*) req->bufs, req->nbufs); - } else { - if (req->nbufs == 1) { - result = pread(req->file, req->bufs[0].base, req->bufs[0].len, req->off); - goto done; - } - -#if HAVE_PREADV - result = preadv(req->file, (struct iovec*) req->bufs, req->nbufs, req->off); -#else -# if defined(__linux__) - if (no_preadv) retry: -# endif - { - off_t nread; - size_t index; - - nread = 0; - index = 0; - result = 1; - do { - if (req->bufs[index].len > 0) { - result = pread(req->file, - req->bufs[index].base, - req->bufs[index].len, - req->off + nread); - if (result > 0) - nread += result; - } - index++; - } while (index < req->nbufs && result > 0); - if (nread > 0) - result = nread; - } -# if defined(__linux__) - else { - result = uv__preadv(req->file, - (struct iovec*)req->bufs, - req->nbufs, - req->off); - if (result == -1 && errno == ENOSYS) { - no_preadv = 1; - goto retry; - } - } -# endif -#endif - } - -done: - return result; -} - - -#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_8) -#define UV_CONST_DIRENT uv__dirent_t -#else -#define UV_CONST_DIRENT const uv__dirent_t -#endif - - -static int uv__fs_scandir_filter(UV_CONST_DIRENT* dent) { - return strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0; -} - - -static int uv__fs_scandir_sort(UV_CONST_DIRENT** a, UV_CONST_DIRENT** b) { - return strcmp((*a)->d_name, (*b)->d_name); -} - - -static ssize_t uv__fs_scandir(uv_fs_t* req) { - uv__dirent_t **dents; - int n; - - dents = NULL; - n = scandir(req->path, &dents, uv__fs_scandir_filter, uv__fs_scandir_sort); - - /* NOTE: We will use nbufs as an index field */ - req->nbufs = 0; - - if (n == 0) { - /* OS X still needs to deallocate some memory. - * Memory was allocated using the system allocator, so use free() here. - */ - free(dents); - dents = NULL; - } else if (n == -1) { - return n; - } - - req->ptr = dents; - - return n; -} - - -static ssize_t uv__fs_pathmax_size(const char* path) { - ssize_t pathmax; - - pathmax = pathconf(path, _PC_PATH_MAX); - - if (pathmax == -1) { -#if defined(PATH_MAX) - return PATH_MAX; -#else -#error "PATH_MAX undefined in the current platform" -#endif - } - - return pathmax; -} - -static ssize_t uv__fs_readlink(uv_fs_t* req) { - ssize_t len; - char* buf; - - len = uv__fs_pathmax_size(req->path); - buf = uv__malloc(len + 1); - - if (buf == NULL) { - errno = ENOMEM; - return -1; - } - - len = readlink(req->path, buf, len); - - if (len == -1) { - uv__free(buf); - return -1; - } - - buf[len] = '\0'; - req->ptr = buf; - - return 0; -} - -static ssize_t uv__fs_realpath(uv_fs_t* req) { - ssize_t len; - char* buf; - - len = uv__fs_pathmax_size(req->path); - buf = uv__malloc(len + 1); - - if (buf == NULL) { - errno = ENOMEM; - return -1; - } - - if (realpath(req->path, buf) == NULL) { - uv__free(buf); - return -1; - } - - req->ptr = buf; - - return 0; -} - -static ssize_t uv__fs_sendfile_emul(uv_fs_t* req) { - struct pollfd pfd; - int use_pread; - off_t offset; - ssize_t nsent; - ssize_t nread; - ssize_t nwritten; - size_t buflen; - size_t len; - ssize_t n; - int in_fd; - int out_fd; - char buf[8192]; - - len = req->bufsml[0].len; - in_fd = req->flags; - out_fd = req->file; - offset = req->off; - use_pread = 1; - - /* Here are the rules regarding errors: - * - * 1. Read errors are reported only if nsent==0, otherwise we return nsent. - * The user needs to know that some data has already been sent, to stop - * them from sending it twice. - * - * 2. Write errors are always reported. Write errors are bad because they - * mean data loss: we've read data but now we can't write it out. - * - * We try to use pread() and fall back to regular read() if the source fd - * doesn't support positional reads, for example when it's a pipe fd. - * - * If we get EAGAIN when writing to the target fd, we poll() on it until - * it becomes writable again. - * - * FIXME: If we get a write error when use_pread==1, it should be safe to - * return the number of sent bytes instead of an error because pread() - * is, in theory, idempotent. However, special files in /dev or /proc - * may support pread() but not necessarily return the same data on - * successive reads. - * - * FIXME: There is no way now to signal that we managed to send *some* data - * before a write error. - */ - for (nsent = 0; (size_t) nsent < len; ) { - buflen = len - nsent; - - if (buflen > sizeof(buf)) - buflen = sizeof(buf); - - do - if (use_pread) - nread = pread(in_fd, buf, buflen, offset); - else - nread = read(in_fd, buf, buflen); - while (nread == -1 && errno == EINTR); - - if (nread == 0) - goto out; - - if (nread == -1) { - if (use_pread && nsent == 0 && (errno == EIO || errno == ESPIPE)) { - use_pread = 0; - continue; - } - - if (nsent == 0) - nsent = -1; - - goto out; - } - - for (nwritten = 0; nwritten < nread; ) { - do - n = write(out_fd, buf + nwritten, nread - nwritten); - while (n == -1 && errno == EINTR); - - if (n != -1) { - nwritten += n; - continue; - } - - if (errno != EAGAIN && errno != EWOULDBLOCK) { - nsent = -1; - goto out; - } - - pfd.fd = out_fd; - pfd.events = POLLOUT; - pfd.revents = 0; - - do - n = poll(&pfd, 1, -1); - while (n == -1 && errno == EINTR); - - if (n == -1 || (pfd.revents & ~POLLOUT) != 0) { - errno = EIO; - nsent = -1; - goto out; - } - } - - offset += nread; - nsent += nread; - } - -out: - if (nsent != -1) - req->off = offset; - - return nsent; -} - - -static ssize_t uv__fs_sendfile(uv_fs_t* req) { - int in_fd; - int out_fd; - - in_fd = req->flags; - out_fd = req->file; - -#if defined(__linux__) || defined(__sun) - { - off_t off; - ssize_t r; - - off = req->off; - r = sendfile(out_fd, in_fd, &off, req->bufsml[0].len); - - /* sendfile() on SunOS returns EINVAL if the target fd is not a socket but - * it still writes out data. Fortunately, we can detect it by checking if - * the offset has been updated. - */ - if (r != -1 || off > req->off) { - r = off - req->off; - req->off = off; - return r; - } - - if (errno == EINVAL || - errno == EIO || - errno == ENOTSOCK || - errno == EXDEV) { - errno = 0; - return uv__fs_sendfile_emul(req); - } - - return -1; - } -#elif defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) - { - off_t len; - ssize_t r; - - /* sendfile() on FreeBSD and Darwin returns EAGAIN if the target fd is in - * non-blocking mode and not all data could be written. If a non-zero - * number of bytes have been sent, we don't consider it an error. - */ - -#if defined(__FreeBSD__) || defined(__DragonFly__) - len = 0; - r = sendfile(in_fd, out_fd, req->off, req->bufsml[0].len, NULL, &len, 0); -#elif defined(__FreeBSD_kernel__) - len = 0; - r = bsd_sendfile(in_fd, - out_fd, - req->off, - req->bufsml[0].len, - NULL, - &len, - 0); -#else - /* The darwin sendfile takes len as an input for the length to send, - * so make sure to initialize it with the caller's value. */ - len = req->bufsml[0].len; - r = sendfile(in_fd, out_fd, req->off, &len, NULL, 0); -#endif - - /* - * The man page for sendfile(2) on DragonFly states that `len` contains - * a meaningful value ONLY in case of EAGAIN and EINTR. - * Nothing is said about it's value in case of other errors, so better - * not depend on the potential wrong assumption that is was not modified - * by the syscall. - */ - if (r == 0 || ((errno == EAGAIN || errno == EINTR) && len != 0)) { - req->off += len; - return (ssize_t) len; - } - - if (errno == EINVAL || - errno == EIO || - errno == ENOTSOCK || - errno == EXDEV) { - errno = 0; - return uv__fs_sendfile_emul(req); - } - - return -1; - } -#else - /* Squelch compiler warnings. */ - (void) &in_fd; - (void) &out_fd; - - return uv__fs_sendfile_emul(req); -#endif -} - - -static ssize_t uv__fs_utime(uv_fs_t* req) { - struct utimbuf buf; - buf.actime = req->atime; - buf.modtime = req->mtime; - return utime(req->path, &buf); /* TODO use utimes() where available */ -} - - -static ssize_t uv__fs_write(uv_fs_t* req) { -#if defined(__linux__) - static int no_pwritev; -#endif - ssize_t r; - - /* Serialize writes on OS X, concurrent write() and pwrite() calls result in - * data loss. We can't use a per-file descriptor lock, the descriptor may be - * a dup(). - */ -#if defined(__APPLE__) - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - - if (pthread_mutex_lock(&lock)) - abort(); -#endif - - if (req->off < 0) { - if (req->nbufs == 1) - r = write(req->file, req->bufs[0].base, req->bufs[0].len); - else - r = writev(req->file, (struct iovec*) req->bufs, req->nbufs); - } else { - if (req->nbufs == 1) { - r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off); - goto done; - } -#if HAVE_PREADV - r = pwritev(req->file, (struct iovec*) req->bufs, req->nbufs, req->off); -#else -# if defined(__linux__) - if (no_pwritev) retry: -# endif - { - off_t written; - size_t index; - - written = 0; - index = 0; - r = 0; - do { - if (req->bufs[index].len > 0) { - r = pwrite(req->file, - req->bufs[index].base, - req->bufs[index].len, - req->off + written); - if (r > 0) - written += r; - } - index++; - } while (index < req->nbufs && r >= 0); - if (written > 0) - r = written; - } -# if defined(__linux__) - else { - r = uv__pwritev(req->file, - (struct iovec*) req->bufs, - req->nbufs, - req->off); - if (r == -1 && errno == ENOSYS) { - no_pwritev = 1; - goto retry; - } - } -# endif -#endif - } - -done: -#if defined(__APPLE__) - if (pthread_mutex_unlock(&lock)) - abort(); -#endif - - return r; -} - -static void uv__to_stat(struct stat* src, uv_stat_t* dst) { - dst->st_dev = src->st_dev; - dst->st_mode = src->st_mode; - dst->st_nlink = src->st_nlink; - dst->st_uid = src->st_uid; - dst->st_gid = src->st_gid; - dst->st_rdev = src->st_rdev; - dst->st_ino = src->st_ino; - dst->st_size = src->st_size; - dst->st_blksize = src->st_blksize; - dst->st_blocks = src->st_blocks; - -#if defined(__APPLE__) - dst->st_atim.tv_sec = src->st_atimespec.tv_sec; - dst->st_atim.tv_nsec = src->st_atimespec.tv_nsec; - dst->st_mtim.tv_sec = src->st_mtimespec.tv_sec; - dst->st_mtim.tv_nsec = src->st_mtimespec.tv_nsec; - dst->st_ctim.tv_sec = src->st_ctimespec.tv_sec; - dst->st_ctim.tv_nsec = src->st_ctimespec.tv_nsec; - dst->st_birthtim.tv_sec = src->st_birthtimespec.tv_sec; - dst->st_birthtim.tv_nsec = src->st_birthtimespec.tv_nsec; - dst->st_flags = src->st_flags; - dst->st_gen = src->st_gen; -#elif defined(__ANDROID__) - dst->st_atim.tv_sec = src->st_atime; - dst->st_atim.tv_nsec = src->st_atimensec; - dst->st_mtim.tv_sec = src->st_mtime; - dst->st_mtim.tv_nsec = src->st_mtimensec; - dst->st_ctim.tv_sec = src->st_ctime; - dst->st_ctim.tv_nsec = src->st_ctimensec; - dst->st_birthtim.tv_sec = src->st_ctime; - dst->st_birthtim.tv_nsec = src->st_ctimensec; - dst->st_flags = 0; - dst->st_gen = 0; -#elif !defined(_AIX) && ( \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) || \ - defined(_GNU_SOURCE) || \ - defined(_BSD_SOURCE) || \ - defined(_SVID_SOURCE) || \ - defined(_XOPEN_SOURCE) || \ - defined(_DEFAULT_SOURCE)) - dst->st_atim.tv_sec = src->st_atim.tv_sec; - dst->st_atim.tv_nsec = src->st_atim.tv_nsec; - dst->st_mtim.tv_sec = src->st_mtim.tv_sec; - dst->st_mtim.tv_nsec = src->st_mtim.tv_nsec; - dst->st_ctim.tv_sec = src->st_ctim.tv_sec; - dst->st_ctim.tv_nsec = src->st_ctim.tv_nsec; -# if defined(__FreeBSD__) || \ - defined(__NetBSD__) - dst->st_birthtim.tv_sec = src->st_birthtim.tv_sec; - dst->st_birthtim.tv_nsec = src->st_birthtim.tv_nsec; - dst->st_flags = src->st_flags; - dst->st_gen = src->st_gen; -# else - dst->st_birthtim.tv_sec = src->st_ctim.tv_sec; - dst->st_birthtim.tv_nsec = src->st_ctim.tv_nsec; - dst->st_flags = 0; - dst->st_gen = 0; -# endif -#else - dst->st_atim.tv_sec = src->st_atime; - dst->st_atim.tv_nsec = 0; - dst->st_mtim.tv_sec = src->st_mtime; - dst->st_mtim.tv_nsec = 0; - dst->st_ctim.tv_sec = src->st_ctime; - dst->st_ctim.tv_nsec = 0; - dst->st_birthtim.tv_sec = src->st_ctime; - dst->st_birthtim.tv_nsec = 0; - dst->st_flags = 0; - dst->st_gen = 0; -#endif -} - - -static int uv__fs_stat(const char *path, uv_stat_t *buf) { - struct stat pbuf; - int ret; - - ret = stat(path, &pbuf); - if (ret == 0) - uv__to_stat(&pbuf, buf); - - return ret; -} - - -static int uv__fs_lstat(const char *path, uv_stat_t *buf) { - struct stat pbuf; - int ret; - - ret = lstat(path, &pbuf); - if (ret == 0) - uv__to_stat(&pbuf, buf); - - return ret; -} - - -static int uv__fs_fstat(int fd, uv_stat_t *buf) { - struct stat pbuf; - int ret; - - ret = fstat(fd, &pbuf); - if (ret == 0) - uv__to_stat(&pbuf, buf); - - return ret; -} - - -typedef ssize_t (*uv__fs_buf_iter_processor)(uv_fs_t* req); -static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process) { - unsigned int iovmax; - unsigned int nbufs; - uv_buf_t* bufs; - ssize_t total; - ssize_t result; - - iovmax = uv__getiovmax(); - nbufs = req->nbufs; - bufs = req->bufs; - total = 0; - - while (nbufs > 0) { - req->nbufs = nbufs; - if (req->nbufs > iovmax) - req->nbufs = iovmax; - - result = process(req); - if (result <= 0) { - if (total == 0) - total = result; - break; - } - - if (req->off >= 0) - req->off += result; - - req->bufs += req->nbufs; - nbufs -= req->nbufs; - total += result; - } - - if (errno == EINTR && total == -1) - return total; - - if (bufs != req->bufsml) - uv__free(bufs); - - req->bufs = NULL; - req->nbufs = 0; - - return total; -} - - -static void uv__fs_work(struct uv__work* w) { - int retry_on_eintr; - uv_fs_t* req; - ssize_t r; - - req = container_of(w, uv_fs_t, work_req); - retry_on_eintr = !(req->fs_type == UV_FS_CLOSE); - - do { - errno = 0; - -#define X(type, action) \ - case UV_FS_ ## type: \ - r = action; \ - break; - - switch (req->fs_type) { - X(ACCESS, access(req->path, req->flags)); - X(CHMOD, chmod(req->path, req->mode)); - X(CHOWN, chown(req->path, req->uid, req->gid)); - X(CLOSE, close(req->file)); - X(FCHMOD, fchmod(req->file, req->mode)); - X(FCHOWN, fchown(req->file, req->uid, req->gid)); - X(FDATASYNC, uv__fs_fdatasync(req)); - X(FSTAT, uv__fs_fstat(req->file, &req->statbuf)); - X(FSYNC, uv__fs_fsync(req)); - X(FTRUNCATE, ftruncate(req->file, req->off)); - X(FUTIME, uv__fs_futime(req)); - X(LSTAT, uv__fs_lstat(req->path, &req->statbuf)); - X(LINK, link(req->path, req->new_path)); - X(MKDIR, mkdir(req->path, req->mode)); - X(MKDTEMP, uv__fs_mkdtemp(req)); - X(OPEN, uv__fs_open(req)); - X(READ, uv__fs_buf_iter(req, uv__fs_read)); - X(SCANDIR, uv__fs_scandir(req)); - X(READLINK, uv__fs_readlink(req)); - X(REALPATH, uv__fs_realpath(req)); - X(RENAME, rename(req->path, req->new_path)); - X(RMDIR, rmdir(req->path)); - X(SENDFILE, uv__fs_sendfile(req)); - X(STAT, uv__fs_stat(req->path, &req->statbuf)); - X(SYMLINK, symlink(req->path, req->new_path)); - X(UNLINK, unlink(req->path)); - X(UTIME, uv__fs_utime(req)); - X(WRITE, uv__fs_buf_iter(req, uv__fs_write)); - default: abort(); - } -#undef X - } while (r == -1 && errno == EINTR && retry_on_eintr); - - if (r == -1) - req->result = -errno; - else - req->result = r; - - if (r == 0 && (req->fs_type == UV_FS_STAT || - req->fs_type == UV_FS_FSTAT || - req->fs_type == UV_FS_LSTAT)) { - req->ptr = &req->statbuf; - } -} - - -static void uv__fs_done(struct uv__work* w, int status) { - uv_fs_t* req; - - req = container_of(w, uv_fs_t, work_req); - uv__req_unregister(req->loop, req); - - if (status == -ECANCELED) { - assert(req->result == 0); - req->result = -ECANCELED; - } - - req->cb(req); -} - - -int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb) { - INIT(ACCESS); - PATH; - req->flags = flags; - POST; -} - - -int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb) { - INIT(CHMOD); - PATH; - req->mode = mode; - POST; -} - - -int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb) { - INIT(CHOWN); - PATH; - req->uid = uid; - req->gid = gid; - POST; -} - - -int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(CLOSE); - req->file = file; - POST; -} - - -int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb) { - INIT(FCHMOD); - req->file = file; - req->mode = mode; - POST; -} - - -int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb) { - INIT(FCHOWN); - req->file = file; - req->uid = uid; - req->gid = gid; - POST; -} - - -int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(FDATASYNC); - req->file = file; - POST; -} - - -int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(FSTAT); - req->file = file; - POST; -} - - -int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - INIT(FSYNC); - req->file = file; - POST; -} - - -int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t off, - uv_fs_cb cb) { - INIT(FTRUNCATE); - req->file = file; - req->off = off; - POST; -} - - -int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb) { - INIT(FUTIME); - req->file = file; - req->atime = atime; - req->mtime = mtime; - POST; -} - - -int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(LSTAT); - PATH; - POST; -} - - -int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb) { - INIT(LINK); - PATH2; - POST; -} - - -int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb) { - INIT(MKDIR); - PATH; - req->mode = mode; - POST; -} - - -int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb) { - INIT(MKDTEMP); - req->path = uv__strdup(tpl); - if (req->path == NULL) { - if (cb != NULL) - uv__req_unregister(loop, req); - return -ENOMEM; - } - POST; -} - - -int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb) { - INIT(OPEN); - PATH; - req->flags = flags; - req->mode = mode; - POST; -} - - -int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t off, - uv_fs_cb cb) { - if (bufs == NULL || nbufs == 0) - return -EINVAL; - - INIT(READ); - req->file = file; - - req->nbufs = nbufs; - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->bufs == NULL) { - if (cb != NULL) - uv__req_unregister(loop, req); - return -ENOMEM; - } - - memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); - - req->off = off; - POST; -} - - -int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb) { - INIT(SCANDIR); - PATH; - req->flags = flags; - POST; -} - - -int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb) { - INIT(READLINK); - PATH; - POST; -} - - -int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char * path, - uv_fs_cb cb) { - INIT(REALPATH); - PATH; - POST; -} - - -int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb) { - INIT(RENAME); - PATH2; - POST; -} - - -int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(RMDIR); - PATH; - POST; -} - - -int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t off, - size_t len, - uv_fs_cb cb) { - INIT(SENDFILE); - req->flags = in_fd; /* hack */ - req->file = out_fd; - req->off = off; - req->bufsml[0].len = len; - POST; -} - - -int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(STAT); - PATH; - POST; -} - - -int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb) { - INIT(SYMLINK); - PATH2; - req->flags = flags; - POST; -} - - -int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - INIT(UNLINK); - PATH; - POST; -} - - -int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb) { - INIT(UTIME); - PATH; - req->atime = atime; - req->mtime = mtime; - POST; -} - - -int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t off, - uv_fs_cb cb) { - if (bufs == NULL || nbufs == 0) - return -EINVAL; - - INIT(WRITE); - req->file = file; - - req->nbufs = nbufs; - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->bufs == NULL) { - if (cb != NULL) - uv__req_unregister(loop, req); - return -ENOMEM; - } - - memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); - - req->off = off; - POST; -} - - -void uv_fs_req_cleanup(uv_fs_t* req) { - /* Only necessary for asychronous requests, i.e., requests with a callback. - * Synchronous ones don't copy their arguments and have req->path and - * req->new_path pointing to user-owned memory. UV_FS_MKDTEMP is the - * exception to the rule, it always allocates memory. - */ - if (req->path != NULL && (req->cb != NULL || req->fs_type == UV_FS_MKDTEMP)) - uv__free((void*) req->path); /* Memory is shared with req->new_path. */ - - req->path = NULL; - req->new_path = NULL; - - if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL) - uv__fs_scandir_cleanup(req); - - if (req->ptr != &req->statbuf) - uv__free(req->ptr); - req->ptr = NULL; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/fsevents.c b/lib/ESPiLight/pilight/libs/libuv/unix/fsevents.c deleted file mode 100644 index 643e233..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/fsevents.c +++ /dev/null @@ -1,901 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#if TARGET_OS_IPHONE - -/* iOS (currently) doesn't provide the FSEvents-API (nor CoreServices) */ - -int uv__fsevents_init(uv_fs_event_t* handle) { - return 0; -} - - -int uv__fsevents_close(uv_fs_event_t* handle) { - return 0; -} - - -void uv__fsevents_loop_delete(uv_loop_t* loop) { -} - -#else /* TARGET_OS_IPHONE */ - -#include -#include -#include -#include - -#include -#include - -/* These are macros to avoid "initializer element is not constant" errors - * with old versions of gcc. - */ -#define kFSEventsModified (kFSEventStreamEventFlagItemFinderInfoMod | \ - kFSEventStreamEventFlagItemModified | \ - kFSEventStreamEventFlagItemInodeMetaMod | \ - kFSEventStreamEventFlagItemChangeOwner | \ - kFSEventStreamEventFlagItemXattrMod) - -#define kFSEventsRenamed (kFSEventStreamEventFlagItemCreated | \ - kFSEventStreamEventFlagItemRemoved | \ - kFSEventStreamEventFlagItemRenamed) - -#define kFSEventsSystem (kFSEventStreamEventFlagUserDropped | \ - kFSEventStreamEventFlagKernelDropped | \ - kFSEventStreamEventFlagEventIdsWrapped | \ - kFSEventStreamEventFlagHistoryDone | \ - kFSEventStreamEventFlagMount | \ - kFSEventStreamEventFlagUnmount | \ - kFSEventStreamEventFlagRootChanged) - -typedef struct uv__fsevents_event_s uv__fsevents_event_t; -typedef struct uv__cf_loop_signal_s uv__cf_loop_signal_t; -typedef struct uv__cf_loop_state_s uv__cf_loop_state_t; - -enum uv__cf_loop_signal_type_e { - kUVCFLoopSignalRegular, - kUVCFLoopSignalClosing -}; -typedef enum uv__cf_loop_signal_type_e uv__cf_loop_signal_type_t; - -struct uv__cf_loop_signal_s { - QUEUE member; - uv_fs_event_t* handle; - uv__cf_loop_signal_type_t type; -}; - -struct uv__fsevents_event_s { - QUEUE member; - int events; - char path[1]; -}; - -struct uv__cf_loop_state_s { - CFRunLoopRef loop; - CFRunLoopSourceRef signal_source; - int fsevent_need_reschedule; - FSEventStreamRef fsevent_stream; - uv_sem_t fsevent_sem; - uv_mutex_t fsevent_mutex; - void* fsevent_handles[2]; - unsigned int fsevent_handle_count; -}; - -/* Forward declarations */ -static void uv__cf_loop_cb(void* arg); -static void* uv__cf_loop_runner(void* arg); -static int uv__cf_loop_signal(uv_loop_t* loop, - uv_fs_event_t* handle, - uv__cf_loop_signal_type_t type); - -/* Lazy-loaded by uv__fsevents_global_init(). */ -static CFArrayRef (*pCFArrayCreate)(CFAllocatorRef, - const void**, - CFIndex, - const CFArrayCallBacks*); -static void (*pCFRelease)(CFTypeRef); -static void (*pCFRunLoopAddSource)(CFRunLoopRef, - CFRunLoopSourceRef, - CFStringRef); -static CFRunLoopRef (*pCFRunLoopGetCurrent)(void); -static void (*pCFRunLoopRemoveSource)(CFRunLoopRef, - CFRunLoopSourceRef, - CFStringRef); -static void (*pCFRunLoopRun)(void); -static CFRunLoopSourceRef (*pCFRunLoopSourceCreate)(CFAllocatorRef, - CFIndex, - CFRunLoopSourceContext*); -static void (*pCFRunLoopSourceSignal)(CFRunLoopSourceRef); -static void (*pCFRunLoopStop)(CFRunLoopRef); -static void (*pCFRunLoopWakeUp)(CFRunLoopRef); -static CFStringRef (*pCFStringCreateWithFileSystemRepresentation)( - CFAllocatorRef, - const char*); -static CFStringEncoding (*pCFStringGetSystemEncoding)(void); -static CFStringRef (*pkCFRunLoopDefaultMode); -static FSEventStreamRef (*pFSEventStreamCreate)(CFAllocatorRef, - FSEventStreamCallback, - FSEventStreamContext*, - CFArrayRef, - FSEventStreamEventId, - CFTimeInterval, - FSEventStreamCreateFlags); -static void (*pFSEventStreamFlushSync)(FSEventStreamRef); -static void (*pFSEventStreamInvalidate)(FSEventStreamRef); -static void (*pFSEventStreamRelease)(FSEventStreamRef); -static void (*pFSEventStreamScheduleWithRunLoop)(FSEventStreamRef, - CFRunLoopRef, - CFStringRef); -static Boolean (*pFSEventStreamStart)(FSEventStreamRef); -static void (*pFSEventStreamStop)(FSEventStreamRef); - -#define UV__FSEVENTS_PROCESS(handle, block) \ - do { \ - QUEUE events; \ - QUEUE* q; \ - uv__fsevents_event_t* event; \ - int err; \ - uv_mutex_lock(&(handle)->cf_mutex); \ - /* Split-off all events and empty original queue */ \ - QUEUE_MOVE(&(handle)->cf_events, &events); \ - /* Get error (if any) and zero original one */ \ - err = (handle)->cf_error; \ - (handle)->cf_error = 0; \ - uv_mutex_unlock(&(handle)->cf_mutex); \ - /* Loop through events, deallocating each after processing */ \ - while (!QUEUE_EMPTY(&events)) { \ - q = QUEUE_HEAD(&events); \ - event = QUEUE_DATA(q, uv__fsevents_event_t, member); \ - QUEUE_REMOVE(q); \ - /* NOTE: Checking uv__is_active() is required here, because handle \ - * callback may close handle and invoking it after it will lead to \ - * incorrect behaviour */ \ - if (!uv__is_closing((handle)) && uv__is_active((handle))) \ - block \ - /* Free allocated data */ \ - uv__free(event); \ - } \ - if (err != 0 && !uv__is_closing((handle)) && uv__is_active((handle))) \ - (handle)->cb((handle), NULL, 0, err); \ - } while (0) - - -/* Runs in UV loop's thread, when there're events to report to handle */ -static void uv__fsevents_cb(uv_async_t* cb) { - uv_fs_event_t* handle; - - handle = cb->data; - - UV__FSEVENTS_PROCESS(handle, { - handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0); - }); -} - - -/* Runs in CF thread, pushed event into handle's event list */ -static void uv__fsevents_push_event(uv_fs_event_t* handle, - QUEUE* events, - int err) { - assert(events != NULL || err != 0); - uv_mutex_lock(&handle->cf_mutex); - - /* Concatenate two queues */ - if (events != NULL) - QUEUE_ADD(&handle->cf_events, events); - - /* Propagate error */ - if (err != 0) - handle->cf_error = err; - uv_mutex_unlock(&handle->cf_mutex); - - uv_async_send(handle->cf_cb); -} - - -/* Runs in CF thread, when there're events in FSEventStream */ -static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, - void* info, - size_t numEvents, - void* eventPaths, - const FSEventStreamEventFlags eventFlags[], - const FSEventStreamEventId eventIds[]) { - size_t i; - int len; - char** paths; - char* path; - char* pos; - uv_fs_event_t* handle; - QUEUE* q; - uv_loop_t* loop; - uv__cf_loop_state_t* state; - uv__fsevents_event_t* event; - QUEUE head; - - loop = info; - state = loop->cf_state; - assert(state != NULL); - paths = eventPaths; - - /* For each handle */ - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_FOREACH(q, &state->fsevent_handles) { - handle = QUEUE_DATA(q, uv_fs_event_t, cf_member); - QUEUE_INIT(&head); - - /* Process and filter out events */ - for (i = 0; i < numEvents; i++) { - /* Ignore system events */ - if (eventFlags[i] & kFSEventsSystem) - continue; - - path = paths[i]; - len = strlen(path); - - /* Filter out paths that are outside handle's request */ - if (strncmp(path, handle->realpath, handle->realpath_len) != 0) - continue; - - if (handle->realpath_len > 1 || *handle->realpath != '/') { - path += handle->realpath_len; - len -= handle->realpath_len; - - /* Skip forward slash */ - if (*path != '\0') { - path++; - len--; - } - } - -#ifdef MAC_OS_X_VERSION_10_7 - /* Ignore events with path equal to directory itself */ - if (len == 0) - continue; -#endif /* MAC_OS_X_VERSION_10_7 */ - - /* Do not emit events from subdirectories (without option set) */ - if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != 0) { - pos = strchr(path + 1, '/'); - if (pos != NULL) - continue; - } - -#ifndef MAC_OS_X_VERSION_10_7 - path = ""; - len = 0; -#endif /* MAC_OS_X_VERSION_10_7 */ - - event = uv__malloc(sizeof(*event) + len); - if (event == NULL) - break; - - memset(event, 0, sizeof(*event)); - memcpy(event->path, path, len + 1); - - if ((eventFlags[i] & kFSEventsModified) != 0 && - (eventFlags[i] & kFSEventsRenamed) == 0) - event->events = UV_CHANGE; - else - event->events = UV_RENAME; - - QUEUE_INSERT_TAIL(&head, &event->member); - } - - if (!QUEUE_EMPTY(&head)) - uv__fsevents_push_event(handle, &head, 0); - } - uv_mutex_unlock(&state->fsevent_mutex); -} - - -/* Runs in CF thread */ -static int uv__fsevents_create_stream(uv_loop_t* loop, CFArrayRef paths) { - uv__cf_loop_state_t* state; - FSEventStreamContext ctx; - FSEventStreamRef ref; - CFAbsoluteTime latency; - FSEventStreamCreateFlags flags; - - /* Initialize context */ - ctx.version = 0; - ctx.info = loop; - ctx.retain = NULL; - ctx.release = NULL; - ctx.copyDescription = NULL; - - latency = 0.05; - - /* Explanation of selected flags: - * 1. NoDefer - without this flag, events that are happening continuously - * (i.e. each event is happening after time interval less than `latency`, - * counted from previous event), will be deferred and passed to callback - * once they'll either fill whole OS buffer, or when this continuous stream - * will stop (i.e. there'll be delay between events, bigger than - * `latency`). - * Specifying this flag will invoke callback after `latency` time passed - * since event. - * 2. FileEvents - fire callback for file changes too (by default it is firing - * it only for directory changes). - */ - flags = kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagFileEvents; - - /* - * NOTE: It might sound like a good idea to remember last seen StreamEventId, - * but in reality one dir might have last StreamEventId less than, the other, - * that is being watched now. Which will cause FSEventStream API to report - * changes to files from the past. - */ - ref = pFSEventStreamCreate(NULL, - &uv__fsevents_event_cb, - &ctx, - paths, - kFSEventStreamEventIdSinceNow, - latency, - flags); - assert(ref != NULL); - - state = loop->cf_state; - pFSEventStreamScheduleWithRunLoop(ref, - state->loop, - *pkCFRunLoopDefaultMode); - if (!pFSEventStreamStart(ref)) { - pFSEventStreamInvalidate(ref); - pFSEventStreamRelease(ref); - return -EMFILE; - } - - state->fsevent_stream = ref; - return 0; -} - - -/* Runs in CF thread */ -static void uv__fsevents_destroy_stream(uv_loop_t* loop) { - uv__cf_loop_state_t* state; - - state = loop->cf_state; - - if (state->fsevent_stream == NULL) - return; - - /* Stop emitting events */ - pFSEventStreamStop(state->fsevent_stream); - - /* Release stream */ - pFSEventStreamInvalidate(state->fsevent_stream); - pFSEventStreamRelease(state->fsevent_stream); - state->fsevent_stream = NULL; -} - - -/* Runs in CF thread, when there're new fsevent handles to add to stream */ -static void uv__fsevents_reschedule(uv_fs_event_t* handle, - uv__cf_loop_signal_type_t type) { - uv__cf_loop_state_t* state; - QUEUE* q; - uv_fs_event_t* curr; - CFArrayRef cf_paths; - CFStringRef* paths; - unsigned int i; - int err; - unsigned int path_count; - - state = handle->loop->cf_state; - paths = NULL; - cf_paths = NULL; - err = 0; - /* NOTE: `i` is used in deallocation loop below */ - i = 0; - - /* Optimization to prevent O(n^2) time spent when starting to watch - * many files simultaneously - */ - uv_mutex_lock(&state->fsevent_mutex); - if (state->fsevent_need_reschedule == 0) { - uv_mutex_unlock(&state->fsevent_mutex); - goto final; - } - state->fsevent_need_reschedule = 0; - uv_mutex_unlock(&state->fsevent_mutex); - - /* Destroy previous FSEventStream */ - uv__fsevents_destroy_stream(handle->loop); - - /* Any failure below will be a memory failure */ - err = -ENOMEM; - - /* Create list of all watched paths */ - uv_mutex_lock(&state->fsevent_mutex); - path_count = state->fsevent_handle_count; - if (path_count != 0) { - paths = uv__malloc(sizeof(*paths) * path_count); - if (paths == NULL) { - uv_mutex_unlock(&state->fsevent_mutex); - goto final; - } - - q = &state->fsevent_handles; - for (; i < path_count; i++) { - q = QUEUE_NEXT(q); - assert(q != &state->fsevent_handles); - curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); - - assert(curr->realpath != NULL); - paths[i] = - pCFStringCreateWithFileSystemRepresentation(NULL, curr->realpath); - if (paths[i] == NULL) { - uv_mutex_unlock(&state->fsevent_mutex); - goto final; - } - } - } - uv_mutex_unlock(&state->fsevent_mutex); - err = 0; - - if (path_count != 0) { - /* Create new FSEventStream */ - cf_paths = pCFArrayCreate(NULL, (const void**) paths, path_count, NULL); - if (cf_paths == NULL) { - err = -ENOMEM; - goto final; - } - err = uv__fsevents_create_stream(handle->loop, cf_paths); - } - -final: - /* Deallocate all paths in case of failure */ - if (err != 0) { - if (cf_paths == NULL) { - while (i != 0) - pCFRelease(paths[--i]); - uv__free(paths); - } else { - /* CFArray takes ownership of both strings and original C-array */ - pCFRelease(cf_paths); - } - - /* Broadcast error to all handles */ - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_FOREACH(q, &state->fsevent_handles) { - curr = QUEUE_DATA(q, uv_fs_event_t, cf_member); - uv__fsevents_push_event(curr, NULL, err); - } - uv_mutex_unlock(&state->fsevent_mutex); - } - - /* - * Main thread will block until the removal of handle from the list, - * we must tell it when we're ready. - * - * NOTE: This is coupled with `uv_sem_wait()` in `uv__fsevents_close` - */ - if (type == kUVCFLoopSignalClosing) - uv_sem_post(&state->fsevent_sem); -} - - -static int uv__fsevents_global_init(void) { - static pthread_mutex_t global_init_mutex = PTHREAD_MUTEX_INITIALIZER; - static void* core_foundation_handle; - static void* core_services_handle; - int err; - - err = 0; - pthread_mutex_lock(&global_init_mutex); - if (core_foundation_handle != NULL) - goto out; - - /* The libraries are never unloaded because we currently don't have a good - * mechanism for keeping a reference count. It's unlikely to be an issue - * but if it ever becomes one, we can turn the dynamic library handles into - * per-event loop properties and have the dynamic linker keep track for us. - */ - err = -ENOSYS; - core_foundation_handle = dlopen("/System/Library/Frameworks/" - "CoreFoundation.framework/" - "Versions/A/CoreFoundation", - RTLD_LAZY | RTLD_LOCAL); - if (core_foundation_handle == NULL) - goto out; - - core_services_handle = dlopen("/System/Library/Frameworks/" - "CoreServices.framework/" - "Versions/A/CoreServices", - RTLD_LAZY | RTLD_LOCAL); - if (core_services_handle == NULL) - goto out; - - err = -ENOENT; -#define V(handle, symbol) \ - do { \ - *(void **)(&p ## symbol) = dlsym((handle), #symbol); \ - if (p ## symbol == NULL) \ - goto out; \ - } \ - while (0) - V(core_foundation_handle, CFArrayCreate); - V(core_foundation_handle, CFRelease); - V(core_foundation_handle, CFRunLoopAddSource); - V(core_foundation_handle, CFRunLoopGetCurrent); - V(core_foundation_handle, CFRunLoopRemoveSource); - V(core_foundation_handle, CFRunLoopRun); - V(core_foundation_handle, CFRunLoopSourceCreate); - V(core_foundation_handle, CFRunLoopSourceSignal); - V(core_foundation_handle, CFRunLoopStop); - V(core_foundation_handle, CFRunLoopWakeUp); - V(core_foundation_handle, CFStringCreateWithFileSystemRepresentation); - V(core_foundation_handle, CFStringGetSystemEncoding); - V(core_foundation_handle, kCFRunLoopDefaultMode); - V(core_services_handle, FSEventStreamCreate); - V(core_services_handle, FSEventStreamFlushSync); - V(core_services_handle, FSEventStreamInvalidate); - V(core_services_handle, FSEventStreamRelease); - V(core_services_handle, FSEventStreamScheduleWithRunLoop); - V(core_services_handle, FSEventStreamStart); - V(core_services_handle, FSEventStreamStop); -#undef V - err = 0; - -out: - if (err && core_services_handle != NULL) { - dlclose(core_services_handle); - core_services_handle = NULL; - } - - if (err && core_foundation_handle != NULL) { - dlclose(core_foundation_handle); - core_foundation_handle = NULL; - } - - pthread_mutex_unlock(&global_init_mutex); - return err; -} - - -/* Runs in UV loop */ -static int uv__fsevents_loop_init(uv_loop_t* loop) { - CFRunLoopSourceContext ctx; - uv__cf_loop_state_t* state; - pthread_attr_t attr_storage; - pthread_attr_t* attr; - int err; - - if (loop->cf_state != NULL) - return 0; - - err = uv__fsevents_global_init(); - if (err) - return err; - - state = uv__calloc(1, sizeof(*state)); - if (state == NULL) - return -ENOMEM; - - err = uv_mutex_init(&loop->cf_mutex); - if (err) - goto fail_mutex_init; - - err = uv_sem_init(&loop->cf_sem, 0); - if (err) - goto fail_sem_init; - - QUEUE_INIT(&loop->cf_signals); - - err = uv_sem_init(&state->fsevent_sem, 0); - if (err) - goto fail_fsevent_sem_init; - - err = uv_mutex_init(&state->fsevent_mutex); - if (err) - goto fail_fsevent_mutex_init; - - QUEUE_INIT(&state->fsevent_handles); - state->fsevent_need_reschedule = 0; - state->fsevent_handle_count = 0; - - memset(&ctx, 0, sizeof(ctx)); - ctx.info = loop; - ctx.perform = uv__cf_loop_cb; - state->signal_source = pCFRunLoopSourceCreate(NULL, 0, &ctx); - if (state->signal_source == NULL) { - err = -ENOMEM; - goto fail_signal_source_create; - } - - /* In the unlikely event that pthread_attr_init() fails, create the thread - * with the default stack size. We'll use a little more address space but - * that in itself is not a fatal error. - */ - attr = &attr_storage; - if (pthread_attr_init(attr)) - attr = NULL; - - if (attr != NULL) - if (pthread_attr_setstacksize(attr, 4 * PTHREAD_STACK_MIN)) - abort(); - - loop->cf_state = state; - - /* uv_thread_t is an alias for pthread_t. */ - err = -pthread_create(&loop->cf_thread, attr, uv__cf_loop_runner, loop); - - if (attr != NULL) - pthread_attr_destroy(attr); - - if (err) - goto fail_thread_create; - - /* Synchronize threads */ - uv_sem_wait(&loop->cf_sem); - return 0; - -fail_thread_create: - loop->cf_state = NULL; - -fail_signal_source_create: - uv_mutex_destroy(&state->fsevent_mutex); - -fail_fsevent_mutex_init: - uv_sem_destroy(&state->fsevent_sem); - -fail_fsevent_sem_init: - uv_sem_destroy(&loop->cf_sem); - -fail_sem_init: - uv_mutex_destroy(&loop->cf_mutex); - -fail_mutex_init: - uv__free(state); - return err; -} - - -/* Runs in UV loop */ -void uv__fsevents_loop_delete(uv_loop_t* loop) { - uv__cf_loop_signal_t* s; - uv__cf_loop_state_t* state; - QUEUE* q; - - if (loop->cf_state == NULL) - return; - - if (uv__cf_loop_signal(loop, NULL, kUVCFLoopSignalRegular) != 0) - abort(); - - uv_thread_join(&loop->cf_thread); - uv_sem_destroy(&loop->cf_sem); - uv_mutex_destroy(&loop->cf_mutex); - - /* Free any remaining data */ - while (!QUEUE_EMPTY(&loop->cf_signals)) { - q = QUEUE_HEAD(&loop->cf_signals); - s = QUEUE_DATA(q, uv__cf_loop_signal_t, member); - QUEUE_REMOVE(q); - uv__free(s); - } - - /* Destroy state */ - state = loop->cf_state; - uv_sem_destroy(&state->fsevent_sem); - uv_mutex_destroy(&state->fsevent_mutex); - pCFRelease(state->signal_source); - uv__free(state); - loop->cf_state = NULL; -} - - -/* Runs in CF thread. This is the CF loop's body */ -static void* uv__cf_loop_runner(void* arg) { - uv_loop_t* loop; - uv__cf_loop_state_t* state; - - loop = arg; - state = loop->cf_state; - state->loop = pCFRunLoopGetCurrent(); - - pCFRunLoopAddSource(state->loop, - state->signal_source, - *pkCFRunLoopDefaultMode); - - uv_sem_post(&loop->cf_sem); - - pCFRunLoopRun(); - pCFRunLoopRemoveSource(state->loop, - state->signal_source, - *pkCFRunLoopDefaultMode); - - return NULL; -} - - -/* Runs in CF thread, executed after `uv__cf_loop_signal()` */ -static void uv__cf_loop_cb(void* arg) { - uv_loop_t* loop; - uv__cf_loop_state_t* state; - QUEUE* item; - QUEUE split_head; - uv__cf_loop_signal_t* s; - - loop = arg; - state = loop->cf_state; - - uv_mutex_lock(&loop->cf_mutex); - QUEUE_MOVE(&loop->cf_signals, &split_head); - uv_mutex_unlock(&loop->cf_mutex); - - while (!QUEUE_EMPTY(&split_head)) { - item = QUEUE_HEAD(&split_head); - QUEUE_REMOVE(item); - - s = QUEUE_DATA(item, uv__cf_loop_signal_t, member); - - /* This was a termination signal */ - if (s->handle == NULL) - pCFRunLoopStop(state->loop); - else - uv__fsevents_reschedule(s->handle, s->type); - - uv__free(s); - } -} - - -/* Runs in UV loop to notify CF thread */ -int uv__cf_loop_signal(uv_loop_t* loop, - uv_fs_event_t* handle, - uv__cf_loop_signal_type_t type) { - uv__cf_loop_signal_t* item; - uv__cf_loop_state_t* state; - - item = uv__malloc(sizeof(*item)); - if (item == NULL) - return -ENOMEM; - - item->handle = handle; - item->type = type; - - uv_mutex_lock(&loop->cf_mutex); - QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member); - uv_mutex_unlock(&loop->cf_mutex); - - state = loop->cf_state; - assert(state != NULL); - pCFRunLoopSourceSignal(state->signal_source); - pCFRunLoopWakeUp(state->loop); - - return 0; -} - - -/* Runs in UV loop to initialize handle */ -int uv__fsevents_init(uv_fs_event_t* handle) { - int err; - uv__cf_loop_state_t* state; - - err = uv__fsevents_loop_init(handle->loop); - if (err) - return err; - - /* Get absolute path to file */ - handle->realpath = realpath(handle->path, NULL); - if (handle->realpath == NULL) - return -errno; - handle->realpath_len = strlen(handle->realpath); - - /* Initialize event queue */ - QUEUE_INIT(&handle->cf_events); - handle->cf_error = 0; - - /* - * Events will occur in other thread. - * Initialize callback for getting them back into event loop's thread - */ - handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb)); - if (handle->cf_cb == NULL) { - err = -ENOMEM; - goto fail_cf_cb_malloc; - } - - handle->cf_cb->data = handle; - uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb); - handle->cf_cb->flags |= UV__HANDLE_INTERNAL; - uv_unref((uv_handle_t*) handle->cf_cb); - - err = uv_mutex_init(&handle->cf_mutex); - if (err) - goto fail_cf_mutex_init; - - /* Insert handle into the list */ - state = handle->loop->cf_state; - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_INSERT_TAIL(&state->fsevent_handles, &handle->cf_member); - state->fsevent_handle_count++; - state->fsevent_need_reschedule = 1; - uv_mutex_unlock(&state->fsevent_mutex); - - /* Reschedule FSEventStream */ - assert(handle != NULL); - err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalRegular); - if (err) - goto fail_loop_signal; - - return 0; - -fail_loop_signal: - uv_mutex_destroy(&handle->cf_mutex); - -fail_cf_mutex_init: - uv__free(handle->cf_cb); - handle->cf_cb = NULL; - -fail_cf_cb_malloc: - uv__free(handle->realpath); - handle->realpath = NULL; - handle->realpath_len = 0; - - return err; -} - - -/* Runs in UV loop to de-initialize handle */ -int uv__fsevents_close(uv_fs_event_t* handle) { - int err; - uv__cf_loop_state_t* state; - - if (handle->cf_cb == NULL) - return -EINVAL; - - /* Remove handle from the list */ - state = handle->loop->cf_state; - uv_mutex_lock(&state->fsevent_mutex); - QUEUE_REMOVE(&handle->cf_member); - state->fsevent_handle_count--; - state->fsevent_need_reschedule = 1; - uv_mutex_unlock(&state->fsevent_mutex); - - /* Reschedule FSEventStream */ - assert(handle != NULL); - err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalClosing); - if (err) - return -err; - - /* Wait for deinitialization */ - uv_sem_wait(&state->fsevent_sem); - - uv_close((uv_handle_t*) handle->cf_cb, (uv_close_cb) uv__free); - handle->cf_cb = NULL; - - /* Free data in queue */ - UV__FSEVENTS_PROCESS(handle, { - /* NOP */ - }); - - uv_mutex_destroy(&handle->cf_mutex); - uv__free(handle->realpath); - handle->realpath = NULL; - handle->realpath_len = 0; - - return 0; -} - -#endif /* TARGET_OS_IPHONE */ diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/getaddrinfo.c b/lib/ESPiLight/pilight/libs/libuv/unix/getaddrinfo.c deleted file mode 100644 index 2049aea..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/getaddrinfo.c +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* Expose glibc-specific EAI_* error codes. Needs to be defined before we - * include any headers. - */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include "uv.h" -#include "internal.h" - -#include -#include /* NULL */ -#include -#include - -/* EAI_* constants. */ -#include - - -int uv__getaddrinfo_translate_error(int sys_err) { - switch (sys_err) { - case 0: return 0; -#if defined(EAI_ADDRFAMILY) - case EAI_ADDRFAMILY: return UV_EAI_ADDRFAMILY; -#endif -#if defined(EAI_AGAIN) - case EAI_AGAIN: return UV_EAI_AGAIN; -#endif -#if defined(EAI_BADFLAGS) - case EAI_BADFLAGS: return UV_EAI_BADFLAGS; -#endif -#if defined(EAI_BADHINTS) - case EAI_BADHINTS: return UV_EAI_BADHINTS; -#endif -#if defined(EAI_CANCELED) - case EAI_CANCELED: return UV_EAI_CANCELED; -#endif -#if defined(EAI_FAIL) - case EAI_FAIL: return UV_EAI_FAIL; -#endif -#if defined(EAI_FAMILY) - case EAI_FAMILY: return UV_EAI_FAMILY; -#endif -#if defined(EAI_MEMORY) - case EAI_MEMORY: return UV_EAI_MEMORY; -#endif -#if defined(EAI_NODATA) - case EAI_NODATA: return UV_EAI_NODATA; -#endif -#if defined(EAI_NONAME) -# if !defined(EAI_NODATA) || EAI_NODATA != EAI_NONAME - case EAI_NONAME: return UV_EAI_NONAME; -# endif -#endif -#if defined(EAI_OVERFLOW) - case EAI_OVERFLOW: return UV_EAI_OVERFLOW; -#endif -#if defined(EAI_PROTOCOL) - case EAI_PROTOCOL: return UV_EAI_PROTOCOL; -#endif -#if defined(EAI_SERVICE) - case EAI_SERVICE: return UV_EAI_SERVICE; -#endif -#if defined(EAI_SOCKTYPE) - case EAI_SOCKTYPE: return UV_EAI_SOCKTYPE; -#endif -#if defined(EAI_SYSTEM) - case EAI_SYSTEM: return -errno; -#endif - } - assert(!"unknown EAI_* error code"); - abort(); - return 0; /* Pacify compiler. */ -} - - -static void uv__getaddrinfo_work(struct uv__work* w) { - uv_getaddrinfo_t* req; - int err; - - req = container_of(w, uv_getaddrinfo_t, work_req); - err = getaddrinfo(req->hostname, req->service, req->hints, &req->addrinfo); - req->retcode = uv__getaddrinfo_translate_error(err); -} - - -static void uv__getaddrinfo_done(struct uv__work* w, int status) { - uv_getaddrinfo_t* req; - - req = container_of(w, uv_getaddrinfo_t, work_req); - uv__req_unregister(req->loop, req); - - /* See initialization in uv_getaddrinfo(). */ - if (req->hints) - uv__free(req->hints); - else if (req->service) - uv__free(req->service); - else if (req->hostname) - uv__free(req->hostname); - else - assert(0); - - req->hints = NULL; - req->service = NULL; - req->hostname = NULL; - - if (status == -ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - } - - if (req->cb) - req->cb(req, req->retcode, req->addrinfo); -} - - -int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb cb, - const char* hostname, - const char* service, - const struct addrinfo* hints) { - size_t hostname_len; - size_t service_len; - size_t hints_len; - size_t len; - char* buf; - - if (req == NULL || (hostname == NULL && service == NULL)) - return -EINVAL; - - hostname_len = hostname ? strlen(hostname) + 1 : 0; - service_len = service ? strlen(service) + 1 : 0; - hints_len = hints ? sizeof(*hints) : 0; - buf = uv__malloc(hostname_len + service_len + hints_len); - - if (buf == NULL) - return -ENOMEM; - - uv__req_init(loop, req, UV_GETADDRINFO); - req->loop = loop; - req->cb = cb; - req->addrinfo = NULL; - req->hints = NULL; - req->service = NULL; - req->hostname = NULL; - req->retcode = 0; - - /* order matters, see uv_getaddrinfo_done() */ - len = 0; - - if (hints) { - req->hints = memcpy(buf + len, hints, sizeof(*hints)); - len += sizeof(*hints); - } - - if (service) { - req->service = memcpy(buf + len, service, service_len); - len += service_len; - } - - if (hostname) - req->hostname = memcpy(buf + len, hostname, hostname_len); - - if (cb) { - uv__work_submit(loop, - &req->work_req, - uv__getaddrinfo_work, - uv__getaddrinfo_done); - return 0; - } else { - uv__getaddrinfo_work(&req->work_req); - uv__getaddrinfo_done(&req->work_req, 0); - return req->retcode; - } -} - - -void uv_freeaddrinfo(struct addrinfo* ai) { - if (ai) - freeaddrinfo(ai); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/getnameinfo.c b/lib/ESPiLight/pilight/libs/libuv/unix/getnameinfo.c deleted file mode 100644 index daa798a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/getnameinfo.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to -* deal in the Software without restriction, including without limitation the -* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -* sell copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -* IN THE SOFTWARE. -*/ - -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" - - -static void uv__getnameinfo_work(struct uv__work* w) { - uv_getnameinfo_t* req; - int err; - socklen_t salen; - - req = container_of(w, uv_getnameinfo_t, work_req); - - if (req->storage.ss_family == AF_INET) - salen = sizeof(struct sockaddr_in); - else if (req->storage.ss_family == AF_INET6) - salen = sizeof(struct sockaddr_in6); - else - abort(); - - err = getnameinfo((struct sockaddr*) &req->storage, - salen, - req->host, - sizeof(req->host), - req->service, - sizeof(req->service), - req->flags); - req->retcode = uv__getaddrinfo_translate_error(err); -} - -static void uv__getnameinfo_done(struct uv__work* w, int status) { - uv_getnameinfo_t* req; - char* host; - char* service; - - req = container_of(w, uv_getnameinfo_t, work_req); - uv__req_unregister(req->loop, req); - host = service = NULL; - - if (status == -ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - } else if (req->retcode == 0) { - host = req->host; - service = req->service; - } - - if (req->getnameinfo_cb) - req->getnameinfo_cb(req, req->retcode, host, service); -} - -/* -* Entry point for getnameinfo -* return 0 if a callback will be made -* return error code if validation fails -*/ -int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags) { - if (req == NULL || addr == NULL) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in)); - } else if (addr->sa_family == AF_INET6) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in6)); - } else { - return UV_EINVAL; - } - - uv__req_init(loop, (uv_req_t*)req, UV_GETNAMEINFO); - - req->getnameinfo_cb = getnameinfo_cb; - req->flags = flags; - req->type = UV_GETNAMEINFO; - req->loop = loop; - req->retcode = 0; - - if (getnameinfo_cb) { - uv__work_submit(loop, - &req->work_req, - uv__getnameinfo_work, - uv__getnameinfo_done); - return 0; - } else { - uv__getnameinfo_work(&req->work_req); - uv__getnameinfo_done(&req->work_req, 0); - return req->retcode; - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/internal.h b/lib/ESPiLight/pilight/libs/libuv/unix/internal.h deleted file mode 100644 index c0898d9..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/internal.h +++ /dev/null @@ -1,338 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_UNIX_INTERNAL_H_ -#define UV_UNIX_INTERNAL_H_ - -#include "uv-common.h" - -#include -#include /* abort */ -#include /* strrchr */ -#include /* O_CLOEXEC, may be */ -#include - -#if defined(__STRICT_ANSI__) -# define inline __inline -#endif - -#if defined(__linux__) -# include "linux-syscalls.h" -#endif /* __linux__ */ - -#if defined(__MVS__) -# include "os390-syscalls.h" -#endif /* __MVS__ */ - -#if defined(__sun) -# include -# include -#endif /* __sun */ - -#if defined(_AIX) -# define reqevents events -# define rtnevents revents -# include -#else -# include -#endif /* _AIX */ - -#if defined(__APPLE__) && !TARGET_OS_IPHONE -# include -#endif - -#if defined(__ANDROID__) -int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset); -# ifdef pthread_sigmask -# undef pthread_sigmask -# endif -# define pthread_sigmask(how, set, oldset) uv__pthread_sigmask(how, set, oldset) -#endif - -#define ACCESS_ONCE(type, var) \ - (*(volatile type*) &(var)) - -#define ROUND_UP(a, b) \ - ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a)) - -#define UNREACHABLE() \ - do { \ - assert(0 && "unreachable code"); \ - abort(); \ - } \ - while (0) - -#define SAVE_ERRNO(block) \ - do { \ - int _saved_errno = errno; \ - do { block; } while (0); \ - errno = _saved_errno; \ - } \ - while (0) - -/* The __clang__ and __INTEL_COMPILER checks are superfluous because they - * define __GNUC__. They are here to convey to you, dear reader, that these - * macros are enabled when compiling with clang or icc. - */ -#if defined(__clang__) || \ - defined(__GNUC__) || \ - defined(__INTEL_COMPILER) || \ - defined(__SUNPRO_C) -# define UV_DESTRUCTOR(declaration) __attribute__((destructor)) declaration -# define UV_UNUSED(declaration) __attribute__((unused)) declaration -#else -# define UV_DESTRUCTOR(declaration) declaration -# define UV_UNUSED(declaration) declaration -#endif - -/* Leans on the fact that, on Linux, POLLRDHUP == EPOLLRDHUP. */ -#ifdef POLLRDHUP -# define UV__POLLRDHUP POLLRDHUP -#else -# define UV__POLLRDHUP 0x2000 -#endif - -#ifdef POLLPRI -# define UV__POLLPRI POLLPRI -#else -# define UV__POLLPRI 0 -#endif - -#if !defined(O_CLOEXEC) && defined(__FreeBSD__) -/* - * It may be that we are just missing `__POSIX_VISIBLE >= 200809`. - * Try using fixed value const and give up, if it doesn't work - */ -# define O_CLOEXEC 0x00100000 -#endif - -typedef struct uv__stream_queued_fds_s uv__stream_queued_fds_t; - -/* handle flags */ -enum { - UV_CLOSING = 0x01, /* uv_close() called but not finished. */ - UV_CLOSED = 0x02, /* close(2) finished. */ - UV_STREAM_READING = 0x04, /* uv_read_start() called. */ - UV_STREAM_SHUTTING = 0x08, /* uv_shutdown() called but not complete. */ - UV_STREAM_SHUT = 0x10, /* Write side closed. */ - UV_STREAM_READABLE = 0x20, /* The stream is readable */ - UV_STREAM_WRITABLE = 0x40, /* The stream is writable */ - UV_STREAM_BLOCKING = 0x80, /* Synchronous writes. */ - UV_STREAM_READ_PARTIAL = 0x100, /* read(2) read less than requested. */ - UV_STREAM_READ_EOF = 0x200, /* read(2) read EOF. */ - UV_TCP_NODELAY = 0x400, /* Disable Nagle. */ - UV_TCP_KEEPALIVE = 0x800, /* Turn on keep-alive. */ - UV_TCP_SINGLE_ACCEPT = 0x1000, /* Only accept() when idle. */ - UV_HANDLE_IPV6 = 0x10000, /* Handle is bound to a IPv6 socket. */ - UV_UDP_PROCESSING = 0x20000, /* Handle is running the send callback queue. */ - UV_HANDLE_BOUND = 0x40000 /* Handle is bound to an address and port */ -}; - -/* loop flags */ -enum { - UV_LOOP_BLOCK_SIGPROF = 1 -}; - -/* flags of excluding ifaddr */ -enum { - UV__EXCLUDE_IFPHYS, - UV__EXCLUDE_IFADDR -}; - -typedef enum { - UV_CLOCK_PRECISE = 0, /* Use the highest resolution clock available. */ - UV_CLOCK_FAST = 1 /* Use the fastest clock with <= 1ms granularity. */ -} uv_clocktype_t; - -struct uv__stream_queued_fds_s { - unsigned int size; - unsigned int offset; - int fds[1]; -}; - - -#if defined(_AIX) || \ - defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__linux__) || \ - defined(__OpenBSD__) -#define uv__cloexec uv__cloexec_ioctl -#define uv__nonblock uv__nonblock_ioctl -#else -#define uv__cloexec uv__cloexec_fcntl -#define uv__nonblock uv__nonblock_fcntl -#endif - -/* core */ -int uv__cloexec_ioctl(int fd, int set); -int uv__cloexec_fcntl(int fd, int set); -int uv__nonblock_ioctl(int fd, int set); -int uv__nonblock_fcntl(int fd, int set); -int uv__close(int fd); -int uv__close_nocheckstdio(int fd); -int uv__socket(int domain, int type, int protocol); -int uv__dup(int fd); -ssize_t uv__recvmsg(int fd, struct msghdr *msg, int flags); -void uv__make_close_pending(uv_handle_t* handle); -int uv__getiovmax(void); - -void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd); -void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events); -void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events); -void uv__io_close(uv_loop_t* loop, uv__io_t* w); -void uv__io_feed(uv_loop_t* loop, uv__io_t* w); -int uv__io_active(const uv__io_t* w, unsigned int events); -int uv__io_check_fd(uv_loop_t* loop, int fd); -void uv__io_poll(uv_loop_t* loop, int timeout); /* in milliseconds or -1 */ -int uv__io_fork(uv_loop_t* loop); - -/* async */ -void uv__async_stop(uv_loop_t* loop); -int uv__async_fork(uv_loop_t* loop); - - -/* loop */ -void uv__run_idle(uv_loop_t* loop); -void uv__run_check(uv_loop_t* loop); -void uv__run_prepare(uv_loop_t* loop); - -/* stream */ -void uv__stream_init(uv_loop_t* loop, uv_stream_t* stream, - uv_handle_type type); -int uv__stream_open(uv_stream_t*, int fd, int flags); -void uv__stream_destroy(uv_stream_t* stream); -#if defined(__APPLE__) -int uv__stream_try_select(uv_stream_t* stream, int* fd); -#endif /* defined(__APPLE__) */ -void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events); -int uv__accept(int sockfd); -int uv__dup2_cloexec(int oldfd, int newfd); -int uv__open_cloexec(const char* path, int flags); - -/* tcp */ -int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb); -int uv__tcp_nodelay(int fd, int on); -int uv__tcp_keepalive(int fd, int on, unsigned int delay); - -/* pipe */ -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); - -/* timer */ -void uv__run_timers(uv_loop_t* loop); -int uv__next_timeout(const uv_loop_t* loop); - -/* signal */ -void uv__signal_close(uv_signal_t* handle); -void uv__signal_global_once_init(void); -void uv__signal_loop_cleanup(uv_loop_t* loop); -int uv__signal_loop_fork(uv_loop_t* loop); - -/* platform specific */ -uint64_t uv__hrtime(uv_clocktype_t type); -int uv__kqueue_init(uv_loop_t* loop); -int uv__platform_loop_init(uv_loop_t* loop); -void uv__platform_loop_delete(uv_loop_t* loop); -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd); - -/* various */ -void uv__async_close(uv_async_t* handle); -void uv__check_close(uv_check_t* handle); -void uv__fs_event_close(uv_fs_event_t* handle); -void uv__idle_close(uv_idle_t* handle); -void uv__pipe_close(uv_pipe_t* handle); -void uv__poll_close(uv_poll_t* handle); -void uv__prepare_close(uv_prepare_t* handle); -void uv__process_close(uv_process_t* handle); -void uv__stream_close(uv_stream_t* handle); -void uv__tcp_close(uv_tcp_t* handle); -void uv__timer_close(uv_timer_t* handle); -void uv__udp_close(uv_udp_t* handle); -void uv__udp_finish_close(uv_udp_t* handle); -uv_handle_type uv__handle_type(int fd); -FILE* uv__open_file(const char* path); -int uv__getpwuid_r(uv_passwd_t* pwd); - - -#if defined(__APPLE__) -int uv___stream_fd(const uv_stream_t* handle); -#define uv__stream_fd(handle) (uv___stream_fd((const uv_stream_t*) (handle))) -#else -#define uv__stream_fd(handle) ((handle)->io_watcher.fd) -#endif /* defined(__APPLE__) */ - -#ifdef UV__O_NONBLOCK -# define UV__F_NONBLOCK UV__O_NONBLOCK -#else -# define UV__F_NONBLOCK 1 -#endif - -int uv__make_socketpair(int fds[2], int flags); -int uv__make_pipe(int fds[2], int flags); - -#if defined(__APPLE__) - -int uv__fsevents_init(uv_fs_event_t* handle); -int uv__fsevents_close(uv_fs_event_t* handle); -void uv__fsevents_loop_delete(uv_loop_t* loop); - -/* OSX < 10.7 has no file events, polyfill them */ -#ifndef MAC_OS_X_VERSION_10_7 - -static const int kFSEventStreamCreateFlagFileEvents = 0x00000010; -static const int kFSEventStreamEventFlagItemCreated = 0x00000100; -static const int kFSEventStreamEventFlagItemRemoved = 0x00000200; -static const int kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400; -static const int kFSEventStreamEventFlagItemRenamed = 0x00000800; -static const int kFSEventStreamEventFlagItemModified = 0x00001000; -static const int kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000; -static const int kFSEventStreamEventFlagItemChangeOwner = 0x00004000; -static const int kFSEventStreamEventFlagItemXattrMod = 0x00008000; -static const int kFSEventStreamEventFlagItemIsFile = 0x00010000; -static const int kFSEventStreamEventFlagItemIsDir = 0x00020000; -static const int kFSEventStreamEventFlagItemIsSymlink = 0x00040000; - -#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 */ - -#endif /* defined(__APPLE__) */ - -UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) { - /* Use a fast time source if available. We only need millisecond precision. - */ - loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000; -} - -UV_UNUSED(static char* uv__basename_r(const char* path)) { - char* s; - - s = strrchr(path, '/'); - if (s == NULL) - return (char*) path; - - return s + 1; -} - -#if defined(__linux__) -int uv__inotify_fork(uv_loop_t* loop, void* old_watchers); -#endif - -#endif /* UV_UNIX_INTERNAL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/kqueue.c b/lib/ESPiLight/pilight/libs/libuv/unix/kqueue.c deleted file mode 100644 index 300bac0..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/kqueue.c +++ /dev/null @@ -1,532 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -/* - * Required on - * - Until at least FreeBSD 11.0 - * - Older versions of Mac OS X - * - * http://www.boost.org/doc/libs/1_61_0/boost/asio/detail/kqueue_reactor.hpp - */ -#ifndef EV_OOBAND -#define EV_OOBAND EV_FLAG1 -#endif - -static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags); - - -int uv__kqueue_init(uv_loop_t* loop) { - loop->backend_fd = kqueue(); - if (loop->backend_fd == -1) - return -errno; - - uv__cloexec(loop->backend_fd, 1); - - return 0; -} - - -static int uv__has_forked_with_cfrunloop; - -int uv__io_fork(uv_loop_t* loop) { - int err; - uv__close(loop->backend_fd); - loop->backend_fd = -1; - err = uv__kqueue_init(loop); - if (err) - return err; - -#if defined(__APPLE__) - if (loop->cf_state != NULL) { - /* We cannot start another CFRunloop and/or thread in the child - process; CF aborts if you try or if you try to touch the thread - at all to kill it. So the best we can do is ignore it from now - on. This means we can't watch directories in the same way - anymore (like other BSDs). It also means we cannot properly - clean up the allocated resources; calling - uv__fsevents_loop_delete from uv_loop_close will crash the - process. So we sidestep the issue by pretending like we never - started it in the first place. - */ - uv__has_forked_with_cfrunloop = 1; - uv__free(loop->cf_state); - loop->cf_state = NULL; - } -#endif - return err; -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct kevent ev; - int rc; - - rc = 0; - EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0); - if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) - rc = -errno; - - EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0); - if (rc == 0) - if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) - abort(); - - return rc; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - struct kevent events[1024]; - struct kevent* ev; - struct timespec spec; - unsigned int nevents; - unsigned int revents; - QUEUE* q; - uv__io_t* w; - sigset_t* pset; - sigset_t set; - uint64_t base; - uint64_t diff; - int have_signals; - int filter; - int fflags; - int count; - int nfds; - int fd; - int op; - int i; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - nevents = 0; - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - if ((w->events & POLLIN) == 0 && (w->pevents & POLLIN) != 0) { - filter = EVFILT_READ; - fflags = 0; - op = EV_ADD; - - if (w->cb == uv__fs_event) { - filter = EVFILT_VNODE; - fflags = NOTE_ATTRIB | NOTE_WRITE | NOTE_RENAME - | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE; - op = EV_ADD | EV_ONESHOT; /* Stop the event from firing repeatedly. */ - } - - EV_SET(events + nevents, w->fd, filter, op, fflags, 0, 0); - - if (++nevents == ARRAY_SIZE(events)) { - if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) - abort(); - nevents = 0; - } - } - - if ((w->events & POLLOUT) == 0 && (w->pevents & POLLOUT) != 0) { - EV_SET(events + nevents, w->fd, EVFILT_WRITE, EV_ADD, 0, 0, 0); - - if (++nevents == ARRAY_SIZE(events)) { - if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) - abort(); - nevents = 0; - } - } - - if ((w->events & UV__POLLPRI) == 0 && (w->pevents & UV__POLLPRI) != 0) { - EV_SET(events + nevents, w->fd, EV_OOBAND, EV_ADD, 0, 0, 0); - - if (++nevents == ARRAY_SIZE(events)) { - if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) - abort(); - nevents = 0; - } - } - - w->events = w->pevents; - } - - pset = NULL; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - pset = &set; - sigemptyset(pset); - sigaddset(pset, SIGPROF); - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - - for (;; nevents = 0) { - if (timeout != -1) { - spec.tv_sec = timeout / 1000; - spec.tv_nsec = (timeout % 1000) * 1000000; - } - - if (pset != NULL) - pthread_sigmask(SIG_BLOCK, pset, NULL); - - nfds = kevent(loop->backend_fd, - events, - nevents, - events, - ARRAY_SIZE(events), - timeout == -1 ? NULL : &spec); - - if (pset != NULL) - pthread_sigmask(SIG_UNBLOCK, pset, NULL); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - if (nfds == -1) { - if (errno != EINTR) - abort(); - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - ev = events + i; - fd = ev->ident; - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. */ - /* TODO batch up */ - struct kevent events[1]; - - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != EBADF && errno != ENOENT) - abort(); - - continue; - } - - if (ev->filter == EVFILT_VNODE) { - assert(w->events == POLLIN); - assert(w->pevents == POLLIN); - w->cb(loop, w, ev->fflags); /* XXX always uv__fs_event() */ - nevents++; - continue; - } - - revents = 0; - - if (ev->filter == EVFILT_READ) { - if (w->pevents & POLLIN) { - revents |= POLLIN; - w->rcount = ev->data; - } else { - /* TODO batch up */ - struct kevent events[1]; - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != ENOENT) - abort(); - } - } - - if (ev->filter == EV_OOBAND) { - if (w->pevents & UV__POLLPRI) { - revents |= UV__POLLPRI; - w->rcount = ev->data; - } else { - /* TODO batch up */ - struct kevent events[1]; - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != ENOENT) - abort(); - } - } - - if (ev->filter == EVFILT_WRITE) { - if (w->pevents & POLLOUT) { - revents |= POLLOUT; - w->wcount = ev->data; - } else { - /* TODO batch up */ - struct kevent events[1]; - EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) - if (errno != ENOENT) - abort(); - } - } - - if (ev->flags & EV_ERROR) - revents |= POLLERR; - - if ((ev->flags & EV_EOF) && (w->pevents & UV__POLLRDHUP)) - revents |= UV__POLLRDHUP; - - if (revents == 0) - continue; - - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, revents); - - nevents++; - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - diff = loop->time - base; - if (diff >= (uint64_t) timeout) - return; - - timeout -= diff; - } -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct kevent* events; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct kevent*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events == NULL) - return; - - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].ident == fd) - events[i].ident = -1; -} - - -static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags) { - uv_fs_event_t* handle; - struct kevent ev; - int events; - const char* path; -#if defined(F_GETPATH) - /* MAXPATHLEN == PATH_MAX but the former is what XNU calls it internally. */ - char pathbuf[MAXPATHLEN]; -#endif - - handle = container_of(w, uv_fs_event_t, event_watcher); - - if (fflags & (NOTE_ATTRIB | NOTE_EXTEND)) - events = UV_CHANGE; - else - events = UV_RENAME; - - path = NULL; -#if defined(F_GETPATH) - /* Also works when the file has been unlinked from the file system. Passing - * in the path when the file has been deleted is arguably a little strange - * but it's consistent with what the inotify backend does. - */ - if (fcntl(handle->event_watcher.fd, F_GETPATH, pathbuf) == 0) - path = uv__basename_r(pathbuf); -#endif - handle->cb(handle, path, events, 0); - - if (handle->event_watcher.fd == -1) - return; - - /* Watcher operates in one-shot mode, re-arm it. */ - fflags = NOTE_ATTRIB | NOTE_WRITE | NOTE_RENAME - | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE; - - EV_SET(&ev, w->fd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, fflags, 0, 0); - - if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) - abort(); -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { -#if defined(__APPLE__) - struct stat statbuf; -#endif /* defined(__APPLE__) */ - int fd; - - if (uv__is_active(handle)) - return -EINVAL; - - /* TODO open asynchronously - but how do we report back errors? */ - fd = open(path, O_RDONLY); - if (fd == -1) - return -errno; - - uv__handle_start(handle); - uv__io_init(&handle->event_watcher, uv__fs_event, fd); - handle->path = uv__strdup(path); - handle->cb = cb; - -#if defined(__APPLE__) - if (uv__has_forked_with_cfrunloop) - goto fallback; - - /* Nullify field to perform checks later */ - handle->cf_cb = NULL; - handle->realpath = NULL; - handle->realpath_len = 0; - handle->cf_flags = flags; - - if (fstat(fd, &statbuf)) - goto fallback; - /* FSEvents works only with directories */ - if (!(statbuf.st_mode & S_IFDIR)) - goto fallback; - - /* The fallback fd is no longer needed */ - uv__close(fd); - handle->event_watcher.fd = -1; - - return uv__fsevents_init(handle); - -fallback: -#endif /* defined(__APPLE__) */ - - uv__io_start(handle->loop, &handle->event_watcher, POLLIN); - - return 0; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - if (!uv__is_active(handle)) - return 0; - - uv__handle_stop(handle); - -#if defined(__APPLE__) - if (uv__has_forked_with_cfrunloop || uv__fsevents_close(handle)) -#endif /* defined(__APPLE__) */ - { - uv__io_close(handle->loop, &handle->event_watcher); - } - - uv__free(handle->path); - handle->path = NULL; - - if (handle->event_watcher.fd != -1) { - /* When FSEvents is used, we don't use the event_watcher's fd under certain - * confitions. (see uv_fs_event_start) */ - uv__close(handle->event_watcher.fd); - handle->event_watcher.fd = -1; - } - - return 0; -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/linux-core.c b/lib/ESPiLight/pilight/libs/libuv/unix/linux-core.c deleted file mode 100644 index 52b468a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/linux-core.c +++ /dev/null @@ -1,951 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* We lean on the fact that POLL{IN,OUT,ERR,HUP} correspond with their - * EPOLL* counterparts. We use the POLL* variants in this file because that - * is what libuv uses elsewhere and it avoids a dependency on . - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define HAVE_IFADDRS_H 1 - -#ifdef __UCLIBC__ -# if __UCLIBC_MAJOR__ < 0 && __UCLIBC_MINOR__ < 9 && __UCLIBC_SUBLEVEL__ < 32 -# undef HAVE_IFADDRS_H -# endif -#endif - -#ifdef HAVE_IFADDRS_H -# if defined(__ANDROID__) -# include "android-ifaddrs.h" -# else -# include -# endif -# include -# include -# include -#endif /* HAVE_IFADDRS_H */ - -/* Available from 2.6.32 onwards. */ -#ifndef CLOCK_MONOTONIC_COARSE -# define CLOCK_MONOTONIC_COARSE 6 -#endif - -/* This is rather annoying: CLOCK_BOOTTIME lives in but we can't - * include that file because it conflicts with . We'll just have to - * define it ourselves. - */ -#ifndef CLOCK_BOOTTIME -# define CLOCK_BOOTTIME 7 -#endif - -static int read_models(unsigned int numcpus, uv_cpu_info_t* ci); -static int read_times(FILE* statfile_fp, - unsigned int numcpus, - uv_cpu_info_t* ci); -static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci); -static unsigned long read_cpufreq(unsigned int cpunum); - - -int uv__platform_loop_init(uv_loop_t* loop) { - int fd; - - fd = uv__epoll_create1(UV__EPOLL_CLOEXEC); - - /* epoll_create1() can fail either because it's not implemented (old kernel) - * or because it doesn't understand the EPOLL_CLOEXEC flag. - */ - if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) { - fd = uv__epoll_create(256); - - if (fd != -1) - uv__cloexec(fd, 1); - } - - loop->backend_fd = fd; - loop->inotify_fd = -1; - loop->inotify_watchers = NULL; - - if (fd == -1) - return -errno; - - return 0; -} - - -int uv__io_fork(uv_loop_t* loop) { - int err; - void* old_watchers; - - old_watchers = loop->inotify_watchers; - - uv__close(loop->backend_fd); - loop->backend_fd = -1; - uv__platform_loop_delete(loop); - - err = uv__platform_loop_init(loop); - if (err) - return err; - - return uv__inotify_fork(loop, old_watchers); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->inotify_fd == -1) return; - uv__io_stop(loop, &loop->inotify_read_watcher, POLLIN); - uv__close(loop->inotify_fd); - loop->inotify_fd = -1; -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct uv__epoll_event* events; - struct uv__epoll_event dummy; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct uv__epoll_event*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events != NULL) - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].data == fd) - events[i].data = -1; - - /* Remove the file descriptor from the epoll. - * This avoids a problem where the same file description remains open - * in another process, causing repeated junk epoll events. - * - * We pass in a dummy epoll_event, to work around a bug in old kernels. - */ - if (loop->backend_fd >= 0) { - /* Work around a bug in kernels 3.10 to 3.19 where passing a struct that - * has the EPOLLWAKEUP flag set generates spurious audit syslog warnings. - */ - memset(&dummy, 0, sizeof(dummy)); - uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &dummy); - } -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct uv__epoll_event e; - int rc; - - e.events = POLLIN; - e.data = -1; - - rc = 0; - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_ADD, fd, &e)) - if (errno != EEXIST) - rc = -errno; - - if (rc == 0) - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &e)) - abort(); - - return rc; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - /* A bug in kernels < 2.6.37 makes timeouts larger than ~30 minutes - * effectively infinite on 32 bits architectures. To avoid blocking - * indefinitely, we cap the timeout and poll again if necessary. - * - * Note that "30 minutes" is a simplification because it depends on - * the value of CONFIG_HZ. The magic constant assumes CONFIG_HZ=1200, - * that being the largest value I have seen in the wild (and only once.) - */ - static const int max_safe_timeout = 1789569; - static int no_epoll_pwait; - static int no_epoll_wait; - struct uv__epoll_event events[1024]; - struct uv__epoll_event* pe; - struct uv__epoll_event e; - int real_timeout; - QUEUE* q; - uv__io_t* w; - sigset_t sigset; - uint64_t sigmask; - uint64_t base; - int have_signals; - int nevents; - int count; - int nfds; - int fd; - int op; - int i; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - e.events = w->pevents; - e.data = w->fd; - - if (w->events == 0) - op = UV__EPOLL_CTL_ADD; - else - op = UV__EPOLL_CTL_MOD; - - /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching - * events, skip the syscall and squelch the events after epoll_wait(). - */ - if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) { - if (errno != EEXIST) - abort(); - - assert(op == UV__EPOLL_CTL_ADD); - - /* We've reactivated a file descriptor that's been watched before. */ - if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_MOD, w->fd, &e)) - abort(); - } - - w->events = w->pevents; - } - - sigmask = 0; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - sigemptyset(&sigset); - sigaddset(&sigset, SIGPROF); - sigmask |= 1 << (SIGPROF - 1); - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - real_timeout = timeout; - - for (;;) { - /* See the comment for max_safe_timeout for an explanation of why - * this is necessary. Executive summary: kernel bug workaround. - */ - if (sizeof(int32_t) == sizeof(long) && timeout >= max_safe_timeout) - timeout = max_safe_timeout; - - if (sigmask != 0 && no_epoll_pwait != 0) - if (pthread_sigmask(SIG_BLOCK, &sigset, NULL)) - abort(); - - if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) { - nfds = uv__epoll_pwait(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout, - sigmask); - if (nfds == -1 && errno == ENOSYS) - no_epoll_pwait = 1; - } else { - nfds = uv__epoll_wait(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout); - if (nfds == -1 && errno == ENOSYS) - no_epoll_wait = 1; - } - - if (sigmask != 0 && no_epoll_pwait != 0) - if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL)) - abort(); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - - if (timeout == 0) - return; - - /* We may have been inside the system call for longer than |timeout| - * milliseconds so we need to update the timestamp to avoid drift. - */ - goto update_timeout; - } - - if (nfds == -1) { - if (errno == ENOSYS) { - /* epoll_wait() or epoll_pwait() failed, try the other system call. */ - assert(no_epoll_wait == 0 || no_epoll_pwait == 0); - continue; - } - - if (errno != EINTR) - abort(); - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - pe = events + i; - fd = pe->data; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. - * - * Ignore all errors because we may be racing with another thread - * when the file descriptor is closed. - */ - uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, pe); - continue; - } - - /* Give users only events they're interested in. Prevents spurious - * callbacks when previous callback invocation in this loop has stopped - * the current watcher. Also, filters out events that users has not - * requested us to watch. - */ - pe->events &= w->pevents | POLLERR | POLLHUP; - - /* Work around an epoll quirk where it sometimes reports just the - * EPOLLERR or EPOLLHUP event. In order to force the event loop to - * move forward, we merge in the read/write events that the watcher - * is interested in; uv__read() and uv__write() will then deal with - * the error or hangup in the usual fashion. - * - * Note to self: happens when epoll reports EPOLLIN|EPOLLHUP, the user - * reads the available data, calls uv_read_stop(), then sometime later - * calls uv_read_start() again. By then, libuv has forgotten about the - * hangup and the kernel won't report EPOLLIN again because there's - * nothing left to read. If anything, libuv is to blame here. The - * current hack is just a quick bandaid; to properly fix it, libuv - * needs to remember the error/hangup event. We should get that for - * free when we switch over to edge-triggered I/O. - */ - if (pe->events == POLLERR || pe->events == POLLHUP) - pe->events |= w->pevents & (POLLIN | POLLOUT | UV__POLLPRI); - - if (pe->events != 0) { - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, pe->events); - - nevents++; - } - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - real_timeout -= (loop->time - base); - if (real_timeout <= 0) - return; - - timeout = real_timeout; - } -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - static clock_t fast_clock_id = -1; - struct timespec t; - clock_t clock_id; - - /* Prefer CLOCK_MONOTONIC_COARSE if available but only when it has - * millisecond granularity or better. CLOCK_MONOTONIC_COARSE is - * serviced entirely from the vDSO, whereas CLOCK_MONOTONIC may - * decide to make a costly system call. - */ - /* TODO(bnoordhuis) Use CLOCK_MONOTONIC_COARSE for UV_CLOCK_PRECISE - * when it has microsecond granularity or better (unlikely). - */ - if (type == UV_CLOCK_FAST && fast_clock_id == -1) { - if (clock_getres(CLOCK_MONOTONIC_COARSE, &t) == 0 && - t.tv_nsec <= 1 * 1000 * 1000) { - fast_clock_id = CLOCK_MONOTONIC_COARSE; - } else { - fast_clock_id = CLOCK_MONOTONIC; - } - } - - clock_id = CLOCK_MONOTONIC; - if (type == UV_CLOCK_FAST) - clock_id = fast_clock_id; - - if (clock_gettime(clock_id, &t)) - return 0; /* Not really possible. */ - - return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec; -} - - -int uv_resident_set_memory(size_t* rss) { - char buf[1024]; - const char* s; - ssize_t n; - long val; - int fd; - int i; - - do - fd = open("/proc/self/stat", O_RDONLY); - while (fd == -1 && errno == EINTR); - - if (fd == -1) - return -errno; - - do - n = read(fd, buf, sizeof(buf) - 1); - while (n == -1 && errno == EINTR); - - uv__close(fd); - if (n == -1) - return -errno; - buf[n] = '\0'; - - s = strchr(buf, ' '); - if (s == NULL) - goto err; - - s += 1; - if (*s != '(') - goto err; - - s = strchr(s, ')'); - if (s == NULL) - goto err; - - for (i = 1; i <= 22; i++) { - s = strchr(s + 1, ' '); - if (s == NULL) - goto err; - } - - errno = 0; - val = strtol(s, NULL, 10); - if (errno != 0) - goto err; - if (val < 0) - goto err; - - *rss = val * getpagesize(); - return 0; - -err: - return -EINVAL; -} - - -int uv_uptime(double* uptime) { - static volatile int no_clock_boottime; - struct timespec now; - int r; - - /* Try CLOCK_BOOTTIME first, fall back to CLOCK_MONOTONIC if not available - * (pre-2.6.39 kernels). CLOCK_MONOTONIC doesn't increase when the system - * is suspended. - */ - if (no_clock_boottime) { - retry: r = clock_gettime(CLOCK_MONOTONIC, &now); - } - else if ((r = clock_gettime(CLOCK_BOOTTIME, &now)) && errno == EINVAL) { - no_clock_boottime = 1; - goto retry; - } - - if (r) - return -errno; - - *uptime = now.tv_sec; - return 0; -} - - -static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) { - unsigned int num; - char buf[1024]; - - if (!fgets(buf, sizeof(buf), statfile_fp)) - return -EIO; - - num = 0; - while (fgets(buf, sizeof(buf), statfile_fp)) { - if (strncmp(buf, "cpu", 3)) - break; - num++; - } - - if (num == 0) - return -EIO; - - *numcpus = num; - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int numcpus; - uv_cpu_info_t* ci; - int err; - FILE* statfile_fp; - - *cpu_infos = NULL; - *count = 0; - - statfile_fp = uv__open_file("/proc/stat"); - if (statfile_fp == NULL) - return -errno; - - err = uv__cpu_num(statfile_fp, &numcpus); - if (err < 0) - goto out; - - err = -ENOMEM; - ci = uv__calloc(numcpus, sizeof(*ci)); - if (ci == NULL) - goto out; - - err = read_models(numcpus, ci); - if (err == 0) - err = read_times(statfile_fp, numcpus, ci); - - if (err) { - uv_free_cpu_info(ci, numcpus); - goto out; - } - - /* read_models() on x86 also reads the CPU speed from /proc/cpuinfo. - * We don't check for errors here. Worst case, the field is left zero. - */ - if (ci[0].speed == 0) - read_speeds(numcpus, ci); - - *cpu_infos = ci; - *count = numcpus; - err = 0; - -out: - - if (fclose(statfile_fp)) - if (errno != EINTR && errno != EINPROGRESS) - abort(); - - return err; -} - - -static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci) { - unsigned int num; - - for (num = 0; num < numcpus; num++) - ci[num].speed = read_cpufreq(num) / 1000; -} - - -/* Also reads the CPU frequency on x86. The other architectures only have - * a BogoMIPS field, which may not be very accurate. - * - * Note: Simply returns on error, uv_cpu_info() takes care of the cleanup. - */ -static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) { - static const char model_marker[] = "model name\t: "; - static const char speed_marker[] = "cpu MHz\t\t: "; - const char* inferred_model; - unsigned int model_idx; - unsigned int speed_idx; - char buf[1024]; - char* model; - FILE* fp; - - /* Most are unused on non-ARM, non-MIPS and non-x86 architectures. */ - (void) &model_marker; - (void) &speed_marker; - (void) &speed_idx; - (void) &model; - (void) &buf; - (void) &fp; - - model_idx = 0; - speed_idx = 0; - -#if defined(__arm__) || \ - defined(__i386__) || \ - defined(__mips__) || \ - defined(__x86_64__) - fp = uv__open_file("/proc/cpuinfo"); - if (fp == NULL) - return -errno; - - while (fgets(buf, sizeof(buf), fp)) { - if (model_idx < numcpus) { - if (strncmp(buf, model_marker, sizeof(model_marker) - 1) == 0) { - model = buf + sizeof(model_marker) - 1; - model = uv__strndup(model, strlen(model) - 1); /* Strip newline. */ - if (model == NULL) { - fclose(fp); - return -ENOMEM; - } - ci[model_idx++].model = model; - continue; - } - } -#if defined(__arm__) || defined(__mips__) - if (model_idx < numcpus) { -#if defined(__arm__) - /* Fallback for pre-3.8 kernels. */ - static const char model_marker[] = "Processor\t: "; -#else /* defined(__mips__) */ - static const char model_marker[] = "cpu model\t\t: "; -#endif - if (strncmp(buf, model_marker, sizeof(model_marker) - 1) == 0) { - model = buf + sizeof(model_marker) - 1; - model = uv__strndup(model, strlen(model) - 1); /* Strip newline. */ - if (model == NULL) { - fclose(fp); - return -ENOMEM; - } - ci[model_idx++].model = model; - continue; - } - } -#else /* !__arm__ && !__mips__ */ - if (speed_idx < numcpus) { - if (strncmp(buf, speed_marker, sizeof(speed_marker) - 1) == 0) { - ci[speed_idx++].speed = atoi(buf + sizeof(speed_marker) - 1); - continue; - } - } -#endif /* __arm__ || __mips__ */ - } - - fclose(fp); -#endif /* __arm__ || __i386__ || __mips__ || __x86_64__ */ - - /* Now we want to make sure that all the models contain *something* because - * it's not safe to leave them as null. Copy the last entry unless there - * isn't one, in that case we simply put "unknown" into everything. - */ - inferred_model = "unknown"; - if (model_idx > 0) - inferred_model = ci[model_idx - 1].model; - - while (model_idx < numcpus) { - model = uv__strndup(inferred_model, strlen(inferred_model)); - if (model == NULL) - return -ENOMEM; - ci[model_idx++].model = model; - } - - return 0; -} - - -static int read_times(FILE* statfile_fp, - unsigned int numcpus, - uv_cpu_info_t* ci) { - unsigned long clock_ticks; - struct uv_cpu_times_s ts; - unsigned long user; - unsigned long nice; - unsigned long sys; - unsigned long idle; - unsigned long dummy; - unsigned long irq; - unsigned int num; - unsigned int len; - char buf[1024]; - - clock_ticks = sysconf(_SC_CLK_TCK); - assert(clock_ticks != (unsigned long) -1); - assert(clock_ticks != 0); - - rewind(statfile_fp); - - if (!fgets(buf, sizeof(buf), statfile_fp)) - abort(); - - num = 0; - - while (fgets(buf, sizeof(buf), statfile_fp)) { - if (num >= numcpus) - break; - - if (strncmp(buf, "cpu", 3)) - break; - - /* skip "cpu " marker */ - { - unsigned int n; - int r = sscanf(buf, "cpu%u ", &n); - assert(r == 1); - (void) r; /* silence build warning */ - for (len = sizeof("cpu0"); n /= 10; len++); - } - - /* Line contains user, nice, system, idle, iowait, irq, softirq, steal, - * guest, guest_nice but we're only interested in the first four + irq. - * - * Don't use %*s to skip fields or %ll to read straight into the uint64_t - * fields, they're not allowed in C89 mode. - */ - if (6 != sscanf(buf + len, - "%lu %lu %lu %lu %lu %lu", - &user, - &nice, - &sys, - &idle, - &dummy, - &irq)) - abort(); - - ts.user = clock_ticks * user; - ts.nice = clock_ticks * nice; - ts.sys = clock_ticks * sys; - ts.idle = clock_ticks * idle; - ts.irq = clock_ticks * irq; - ci[num++].cpu_times = ts; - } - assert(num == numcpus); - - return 0; -} - - -static unsigned long read_cpufreq(unsigned int cpunum) { - unsigned long val; - char buf[1024]; - FILE* fp; - - snprintf(buf, - sizeof(buf), - "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq", - cpunum); - - fp = uv__open_file(buf); - if (fp == NULL) - return 0; - - if (fscanf(fp, "%lu", &val) != 1) - val = 0; - - fclose(fp); - - return val; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - -static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) { - if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING))) - return 1; - if (ent->ifa_addr == NULL) - return 1; - /* - * On Linux getifaddrs returns information related to the raw underlying - * devices. We're not interested in this information yet. - */ - if (ent->ifa_addr->sa_family == PF_PACKET) - return exclude_type; - return !exclude_type; -} - -int uv_interface_addresses(uv_interface_address_t** addresses, - int* count) { -#ifndef HAVE_IFADDRS_H - return -ENOSYS; -#else - struct ifaddrs *addrs, *ent; - uv_interface_address_t* address; - int i; - struct sockaddr_ll *sll; - - if (getifaddrs(&addrs)) - return -errno; - - *count = 0; - *addresses = NULL; - - /* Count the number of interfaces */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - - (*count)++; - } - - if (*count == 0) - return 0; - - *addresses = uv__malloc(*count * sizeof(**addresses)); - if (!(*addresses)) { - freeifaddrs(addrs); - return -ENOMEM; - } - - address = *addresses; - - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR)) - continue; - - address->name = uv__strdup(ent->ifa_name); - - if (ent->ifa_addr->sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr); - } - - if (ent->ifa_netmask->sa_family == AF_INET6) { - address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask); - } else { - address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask); - } - - address->is_internal = !!(ent->ifa_flags & IFF_LOOPBACK); - - address++; - } - - /* Fill in physical addresses for each interface */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFPHYS)) - continue; - - address = *addresses; - - for (i = 0; i < (*count); i++) { - if (strcmp(address->name, ent->ifa_name) == 0) { - sll = (struct sockaddr_ll*)ent->ifa_addr; - memcpy(address->phys_addr, sll->sll_addr, sizeof(address->phys_addr)); - } - address++; - } - } - - freeifaddrs(addrs); - - return 0; -#endif -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} - - -void uv__set_process_title(const char* title) { -#if defined(PR_SET_NAME) - prctl(PR_SET_NAME, title); /* Only copies first 16 characters. */ -#endif -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/linux-inotify.c b/lib/ESPiLight/pilight/libs/libuv/unix/linux-inotify.c deleted file mode 100644 index 5934c5d..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/linux-inotify.c +++ /dev/null @@ -1,352 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "tree.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -struct watcher_list { - RB_ENTRY(watcher_list) entry; - QUEUE watchers; - int iterating; - char* path; - int wd; -}; - -struct watcher_root { - struct watcher_list* rbh_root; -}; -#define CAST(p) ((struct watcher_root*)(p)) - - -static int compare_watchers(const struct watcher_list* a, - const struct watcher_list* b) { - if (a->wd < b->wd) return -1; - if (a->wd > b->wd) return 1; - return 0; -} - - -RB_GENERATE_STATIC(watcher_root, watcher_list, entry, compare_watchers) - - -static void uv__inotify_read(uv_loop_t* loop, - uv__io_t* w, - unsigned int revents); - -static void maybe_free_watcher_list(struct watcher_list* w, - uv_loop_t* loop); - -static int new_inotify_fd(void) { - int err; - int fd; - - fd = uv__inotify_init1(UV__IN_NONBLOCK | UV__IN_CLOEXEC); - if (fd != -1) - return fd; - - if (errno != ENOSYS) - return -errno; - - fd = uv__inotify_init(); - if (fd == -1) - return -errno; - - err = uv__cloexec(fd, 1); - if (err == 0) - err = uv__nonblock(fd, 1); - - if (err) { - uv__close(fd); - return err; - } - - return fd; -} - - -static int init_inotify(uv_loop_t* loop) { - int err; - - if (loop->inotify_fd != -1) - return 0; - - err = new_inotify_fd(); - if (err < 0) - return err; - - loop->inotify_fd = err; - uv__io_init(&loop->inotify_read_watcher, uv__inotify_read, loop->inotify_fd); - uv__io_start(loop, &loop->inotify_read_watcher, POLLIN); - - return 0; -} - - -int uv__inotify_fork(uv_loop_t* loop, void* old_watchers) { - /* Open the inotify_fd, and re-arm all the inotify watchers. */ - int err; - struct watcher_list* tmp_watcher_list_iter; - struct watcher_list* watcher_list; - struct watcher_list tmp_watcher_list; - QUEUE queue; - QUEUE* q; - uv_fs_event_t* handle; - char* tmp_path; - - if (old_watchers != NULL) { - /* We must restore the old watcher list to be able to close items - * out of it. - */ - loop->inotify_watchers = old_watchers; - - QUEUE_INIT(&tmp_watcher_list.watchers); - /* Note that the queue we use is shared with the start and stop() - * functions, making QUEUE_FOREACH unsafe to use. So we use the - * QUEUE_MOVE trick to safely iterate. Also don't free the watcher - * list until we're done iterating. c.f. uv__inotify_read. - */ - RB_FOREACH_SAFE(watcher_list, watcher_root, - CAST(&old_watchers), tmp_watcher_list_iter) { - watcher_list->iterating = 1; - QUEUE_MOVE(&watcher_list->watchers, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - handle = QUEUE_DATA(q, uv_fs_event_t, watchers); - /* It's critical to keep a copy of path here, because it - * will be set to NULL by stop() and then deallocated by - * maybe_free_watcher_list - */ - tmp_path = uv__strdup(handle->path); - assert(tmp_path != NULL); - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&watcher_list->watchers, q); - uv_fs_event_stop(handle); - - QUEUE_INSERT_TAIL(&tmp_watcher_list.watchers, &handle->watchers); - handle->path = tmp_path; - } - watcher_list->iterating = 0; - maybe_free_watcher_list(watcher_list, loop); - } - - QUEUE_MOVE(&tmp_watcher_list.watchers, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - QUEUE_REMOVE(q); - handle = QUEUE_DATA(q, uv_fs_event_t, watchers); - tmp_path = handle->path; - handle->path = NULL; - err = uv_fs_event_start(handle, handle->cb, tmp_path, 0); - uv__free(tmp_path); - if (err) - return err; - } - } - - return 0; -} - - -static struct watcher_list* find_watcher(uv_loop_t* loop, int wd) { - struct watcher_list w; - w.wd = wd; - return RB_FIND(watcher_root, CAST(&loop->inotify_watchers), &w); -} - -static void maybe_free_watcher_list(struct watcher_list* w, uv_loop_t* loop) { - /* if the watcher_list->watchers is being iterated over, we can't free it. */ - if ((!w->iterating) && QUEUE_EMPTY(&w->watchers)) { - /* No watchers left for this path. Clean up. */ - RB_REMOVE(watcher_root, CAST(&loop->inotify_watchers), w); - uv__inotify_rm_watch(loop->inotify_fd, w->wd); - uv__free(w); - } -} - -static void uv__inotify_read(uv_loop_t* loop, - uv__io_t* dummy, - unsigned int events) { - const struct uv__inotify_event* e; - struct watcher_list* w; - uv_fs_event_t* h; - QUEUE queue; - QUEUE* q; - const char* path; - ssize_t size; - const char *p; - /* needs to be large enough for sizeof(inotify_event) + strlen(path) */ - char buf[4096]; - - while (1) { - do - size = read(loop->inotify_fd, buf, sizeof(buf)); - while (size == -1 && errno == EINTR); - - if (size == -1) { - assert(errno == EAGAIN || errno == EWOULDBLOCK); - break; - } - - assert(size > 0); /* pre-2.6.21 thing, size=0 == read buffer too small */ - - /* Now we have one or more inotify_event structs. */ - for (p = buf; p < buf + size; p += sizeof(*e) + e->len) { - e = (const struct uv__inotify_event*)p; - - events = 0; - if (e->mask & (UV__IN_ATTRIB|UV__IN_MODIFY)) - events |= UV_CHANGE; - if (e->mask & ~(UV__IN_ATTRIB|UV__IN_MODIFY)) - events |= UV_RENAME; - - w = find_watcher(loop, e->wd); - if (w == NULL) - continue; /* Stale event, no watchers left. */ - - /* inotify does not return the filename when monitoring a single file - * for modifications. Repurpose the filename for API compatibility. - * I'm not convinced this is a good thing, maybe it should go. - */ - path = e->len ? (const char*) (e + 1) : uv__basename_r(w->path); - - /* We're about to iterate over the queue and call user's callbacks. - * What can go wrong? - * A callback could call uv_fs_event_stop() - * and the queue can change under our feet. - * So, we use QUEUE_MOVE() trick to safely iterate over the queue. - * And we don't free the watcher_list until we're done iterating. - * - * First, - * tell uv_fs_event_stop() (that could be called from a user's callback) - * not to free watcher_list. - */ - w->iterating = 1; - QUEUE_MOVE(&w->watchers, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - h = QUEUE_DATA(q, uv_fs_event_t, watchers); - - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&w->watchers, q); - - h->cb(h, path, events, 0); - } - /* done iterating, time to (maybe) free empty watcher_list */ - w->iterating = 0; - maybe_free_watcher_list(w, loop); - } - } -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { - struct watcher_list* w; - int events; - int err; - int wd; - - if (uv__is_active(handle)) - return -EINVAL; - - err = init_inotify(handle->loop); - if (err) - return err; - - events = UV__IN_ATTRIB - | UV__IN_CREATE - | UV__IN_MODIFY - | UV__IN_DELETE - | UV__IN_DELETE_SELF - | UV__IN_MOVE_SELF - | UV__IN_MOVED_FROM - | UV__IN_MOVED_TO; - - wd = uv__inotify_add_watch(handle->loop->inotify_fd, path, events); - if (wd == -1) - return -errno; - - w = find_watcher(handle->loop, wd); - if (w) - goto no_insert; - - w = uv__malloc(sizeof(*w) + strlen(path) + 1); - if (w == NULL) - return -ENOMEM; - - w->wd = wd; - w->path = strcpy((char*)(w + 1), path); - QUEUE_INIT(&w->watchers); - w->iterating = 0; - RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w); - -no_insert: - uv__handle_start(handle); - QUEUE_INSERT_TAIL(&w->watchers, &handle->watchers); - handle->path = w->path; - handle->cb = cb; - handle->wd = wd; - - return 0; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - struct watcher_list* w; - - if (!uv__is_active(handle)) - return 0; - - w = find_watcher(handle->loop, handle->wd); - assert(w != NULL); - - handle->wd = -1; - handle->path = NULL; - uv__handle_stop(handle); - QUEUE_REMOVE(&handle->watchers); - - maybe_free_watcher_list(w, handle->loop); - - return 0; -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/linux-syscalls.c b/lib/ESPiLight/pilight/libs/libuv/unix/linux-syscalls.c deleted file mode 100644 index 89998de..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/linux-syscalls.c +++ /dev/null @@ -1,471 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "linux-syscalls.h" -#include -#include -#include -#include -#include - -#if defined(__has_feature) -# if __has_feature(memory_sanitizer) -# define MSAN_ACTIVE 1 -# include -# endif -#endif - -#if defined(__i386__) -# ifndef __NR_socketcall -# define __NR_socketcall 102 -# endif -#endif - -#if defined(__arm__) -# if defined(__thumb__) || defined(__ARM_EABI__) -# define UV_SYSCALL_BASE 0 -# else -# define UV_SYSCALL_BASE 0x900000 -# endif -#endif /* __arm__ */ - -#ifndef __NR_accept4 -# if defined(__x86_64__) -# define __NR_accept4 288 -# elif defined(__i386__) - /* Nothing. Handled through socketcall(). */ -# elif defined(__arm__) -# define __NR_accept4 (UV_SYSCALL_BASE + 366) -# endif -#endif /* __NR_accept4 */ - -#ifndef __NR_eventfd -# if defined(__x86_64__) -# define __NR_eventfd 284 -# elif defined(__i386__) -# define __NR_eventfd 323 -# elif defined(__arm__) -# define __NR_eventfd (UV_SYSCALL_BASE + 351) -# endif -#endif /* __NR_eventfd */ - -#ifndef __NR_eventfd2 -# if defined(__x86_64__) -# define __NR_eventfd2 290 -# elif defined(__i386__) -# define __NR_eventfd2 328 -# elif defined(__arm__) -# define __NR_eventfd2 (UV_SYSCALL_BASE + 356) -# endif -#endif /* __NR_eventfd2 */ - -#ifndef __NR_epoll_create -# if defined(__x86_64__) -# define __NR_epoll_create 213 -# elif defined(__i386__) -# define __NR_epoll_create 254 -# elif defined(__arm__) -# define __NR_epoll_create (UV_SYSCALL_BASE + 250) -# endif -#endif /* __NR_epoll_create */ - -#ifndef __NR_epoll_create1 -# if defined(__x86_64__) -# define __NR_epoll_create1 291 -# elif defined(__i386__) -# define __NR_epoll_create1 329 -# elif defined(__arm__) -# define __NR_epoll_create1 (UV_SYSCALL_BASE + 357) -# endif -#endif /* __NR_epoll_create1 */ - -#ifndef __NR_epoll_ctl -# if defined(__x86_64__) -# define __NR_epoll_ctl 233 /* used to be 214 */ -# elif defined(__i386__) -# define __NR_epoll_ctl 255 -# elif defined(__arm__) -# define __NR_epoll_ctl (UV_SYSCALL_BASE + 251) -# endif -#endif /* __NR_epoll_ctl */ - -#ifndef __NR_epoll_wait -# if defined(__x86_64__) -# define __NR_epoll_wait 232 /* used to be 215 */ -# elif defined(__i386__) -# define __NR_epoll_wait 256 -# elif defined(__arm__) -# define __NR_epoll_wait (UV_SYSCALL_BASE + 252) -# endif -#endif /* __NR_epoll_wait */ - -#ifndef __NR_epoll_pwait -# if defined(__x86_64__) -# define __NR_epoll_pwait 281 -# elif defined(__i386__) -# define __NR_epoll_pwait 319 -# elif defined(__arm__) -# define __NR_epoll_pwait (UV_SYSCALL_BASE + 346) -# endif -#endif /* __NR_epoll_pwait */ - -#ifndef __NR_inotify_init -# if defined(__x86_64__) -# define __NR_inotify_init 253 -# elif defined(__i386__) -# define __NR_inotify_init 291 -# elif defined(__arm__) -# define __NR_inotify_init (UV_SYSCALL_BASE + 316) -# endif -#endif /* __NR_inotify_init */ - -#ifndef __NR_inotify_init1 -# if defined(__x86_64__) -# define __NR_inotify_init1 294 -# elif defined(__i386__) -# define __NR_inotify_init1 332 -# elif defined(__arm__) -# define __NR_inotify_init1 (UV_SYSCALL_BASE + 360) -# endif -#endif /* __NR_inotify_init1 */ - -#ifndef __NR_inotify_add_watch -# if defined(__x86_64__) -# define __NR_inotify_add_watch 254 -# elif defined(__i386__) -# define __NR_inotify_add_watch 292 -# elif defined(__arm__) -# define __NR_inotify_add_watch (UV_SYSCALL_BASE + 317) -# endif -#endif /* __NR_inotify_add_watch */ - -#ifndef __NR_inotify_rm_watch -# if defined(__x86_64__) -# define __NR_inotify_rm_watch 255 -# elif defined(__i386__) -# define __NR_inotify_rm_watch 293 -# elif defined(__arm__) -# define __NR_inotify_rm_watch (UV_SYSCALL_BASE + 318) -# endif -#endif /* __NR_inotify_rm_watch */ - -#ifndef __NR_pipe2 -# if defined(__x86_64__) -# define __NR_pipe2 293 -# elif defined(__i386__) -# define __NR_pipe2 331 -# elif defined(__arm__) -# define __NR_pipe2 (UV_SYSCALL_BASE + 359) -# endif -#endif /* __NR_pipe2 */ - -#ifndef __NR_recvmmsg -# if defined(__x86_64__) -# define __NR_recvmmsg 299 -# elif defined(__i386__) -# define __NR_recvmmsg 337 -# elif defined(__arm__) -# define __NR_recvmmsg (UV_SYSCALL_BASE + 365) -# endif -#endif /* __NR_recvmsg */ - -#ifndef __NR_sendmmsg -# if defined(__x86_64__) -# define __NR_sendmmsg 307 -# elif defined(__i386__) -# define __NR_sendmmsg 345 -# elif defined(__arm__) -# define __NR_sendmmsg (UV_SYSCALL_BASE + 374) -# endif -#endif /* __NR_sendmmsg */ - -#ifndef __NR_utimensat -# if defined(__x86_64__) -# define __NR_utimensat 280 -# elif defined(__i386__) -# define __NR_utimensat 320 -# elif defined(__arm__) -# define __NR_utimensat (UV_SYSCALL_BASE + 348) -# endif -#endif /* __NR_utimensat */ - -#ifndef __NR_preadv -# if defined(__x86_64__) -# define __NR_preadv 295 -# elif defined(__i386__) -# define __NR_preadv 333 -# elif defined(__arm__) -# define __NR_preadv (UV_SYSCALL_BASE + 361) -# endif -#endif /* __NR_preadv */ - -#ifndef __NR_pwritev -# if defined(__x86_64__) -# define __NR_pwritev 296 -# elif defined(__i386__) -# define __NR_pwritev 334 -# elif defined(__arm__) -# define __NR_pwritev (UV_SYSCALL_BASE + 362) -# endif -#endif /* __NR_pwritev */ - -#ifndef __NR_dup3 -# if defined(__x86_64__) -# define __NR_dup3 292 -# elif defined(__i386__) -# define __NR_dup3 330 -# elif defined(__arm__) -# define __NR_dup3 (UV_SYSCALL_BASE + 358) -# endif -#endif /* __NR_pwritev */ - - -int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) { -#if defined(__i386__) - unsigned long args[4]; - int r; - - args[0] = (unsigned long) fd; - args[1] = (unsigned long) addr; - args[2] = (unsigned long) addrlen; - args[3] = (unsigned long) flags; - - r = syscall(__NR_socketcall, 18 /* SYS_ACCEPT4 */, args); - - /* socketcall() raises EINVAL when SYS_ACCEPT4 is not supported but so does - * a bad flags argument. Try to distinguish between the two cases. - */ - if (r == -1) - if (errno == EINVAL) - if ((flags & ~(UV__SOCK_CLOEXEC|UV__SOCK_NONBLOCK)) == 0) - errno = ENOSYS; - - return r; -#elif defined(__NR_accept4) - return syscall(__NR_accept4, fd, addr, addrlen, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__eventfd(unsigned int count) { -#if defined(__NR_eventfd) - return syscall(__NR_eventfd, count); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__eventfd2(unsigned int count, int flags) { -#if defined(__NR_eventfd2) - return syscall(__NR_eventfd2, count, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_create(int size) { -#if defined(__NR_epoll_create) - return syscall(__NR_epoll_create, size); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_create1(int flags) { -#if defined(__NR_epoll_create1) - return syscall(__NR_epoll_create1, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event* events) { -#if defined(__NR_epoll_ctl) - return syscall(__NR_epoll_ctl, epfd, op, fd, events); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_wait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout) { -#if defined(__NR_epoll_wait) - int result; - result = syscall(__NR_epoll_wait, epfd, events, nevents, timeout); -#if MSAN_ACTIVE - if (result > 0) - __msan_unpoison(events, sizeof(events[0]) * result); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__epoll_pwait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout, - uint64_t sigmask) { -#if defined(__NR_epoll_pwait) - int result; - result = syscall(__NR_epoll_pwait, - epfd, - events, - nevents, - timeout, - &sigmask, - sizeof(sigmask)); -#if MSAN_ACTIVE - if (result > 0) - __msan_unpoison(events, sizeof(events[0]) * result); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_init(void) { -#if defined(__NR_inotify_init) - return syscall(__NR_inotify_init); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_init1(int flags) { -#if defined(__NR_inotify_init1) - return syscall(__NR_inotify_init1, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_add_watch(int fd, const char* path, uint32_t mask) { -#if defined(__NR_inotify_add_watch) - return syscall(__NR_inotify_add_watch, fd, path, mask); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__inotify_rm_watch(int fd, int32_t wd) { -#if defined(__NR_inotify_rm_watch) - return syscall(__NR_inotify_rm_watch, fd, wd); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__pipe2(int pipefd[2], int flags) { -#if defined(__NR_pipe2) - int result; - result = syscall(__NR_pipe2, pipefd, flags); -#if MSAN_ACTIVE - if (!result) - __msan_unpoison(pipefd, sizeof(int[2])); -#endif - return result; -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__sendmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags) { -#if defined(__NR_sendmmsg) - return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__recvmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags, - struct timespec* timeout) { -#if defined(__NR_recvmmsg) - return syscall(__NR_recvmmsg, fd, mmsg, vlen, flags, timeout); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__utimesat(int dirfd, - const char* path, - const struct timespec times[2], - int flags) -{ -#if defined(__NR_utimensat) - return syscall(__NR_utimensat, dirfd, path, times, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - -ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset) { -#if defined(__NR_preadv) - return syscall(__NR_preadv, fd, iov, iovcnt, (long)offset, (long)(offset >> 32)); -#else - return errno = ENOSYS, -1; -#endif -} - - -ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset) { -#if defined(__NR_pwritev) - return syscall(__NR_pwritev, fd, iov, iovcnt, (long)offset, (long)(offset >> 32)); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__dup3(int oldfd, int newfd, int flags) { -#if defined(__NR_dup3) - return syscall(__NR_dup3, oldfd, newfd, flags); -#else - return errno = ENOSYS, -1; -#endif -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/linux-syscalls.h b/lib/ESPiLight/pilight/libs/libuv/unix/linux-syscalls.h deleted file mode 100644 index 4c095e9..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/linux-syscalls.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_LINUX_SYSCALL_H_ -#define UV_LINUX_SYSCALL_H_ - -#undef _GNU_SOURCE -#define _GNU_SOURCE - -#include -#include -#include -#include -#include - -#if defined(__alpha__) -# define UV__O_CLOEXEC 0x200000 -#elif defined(__hppa__) -# define UV__O_CLOEXEC 0x200000 -#elif defined(__sparc__) -# define UV__O_CLOEXEC 0x400000 -#else -# define UV__O_CLOEXEC 0x80000 -#endif - -#if defined(__alpha__) -# define UV__O_NONBLOCK 0x4 -#elif defined(__hppa__) -# define UV__O_NONBLOCK O_NONBLOCK -#elif defined(__mips__) -# define UV__O_NONBLOCK 0x80 -#elif defined(__sparc__) -# define UV__O_NONBLOCK 0x4000 -#else -# define UV__O_NONBLOCK 0x800 -#endif - -#define UV__EFD_CLOEXEC UV__O_CLOEXEC -#define UV__EFD_NONBLOCK UV__O_NONBLOCK - -#define UV__IN_CLOEXEC UV__O_CLOEXEC -#define UV__IN_NONBLOCK UV__O_NONBLOCK - -#define UV__SOCK_CLOEXEC UV__O_CLOEXEC -#if defined(SOCK_NONBLOCK) -# define UV__SOCK_NONBLOCK SOCK_NONBLOCK -#else -# define UV__SOCK_NONBLOCK UV__O_NONBLOCK -#endif - -/* epoll flags */ -#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC -#define UV__EPOLL_CTL_ADD 1 -#define UV__EPOLL_CTL_DEL 2 -#define UV__EPOLL_CTL_MOD 3 - -/* inotify flags */ -#define UV__IN_ACCESS 0x001 -#define UV__IN_MODIFY 0x002 -#define UV__IN_ATTRIB 0x004 -#define UV__IN_CLOSE_WRITE 0x008 -#define UV__IN_CLOSE_NOWRITE 0x010 -#define UV__IN_OPEN 0x020 -#define UV__IN_MOVED_FROM 0x040 -#define UV__IN_MOVED_TO 0x080 -#define UV__IN_CREATE 0x100 -#define UV__IN_DELETE 0x200 -#define UV__IN_DELETE_SELF 0x400 -#define UV__IN_MOVE_SELF 0x800 - -#if defined(__x86_64__) -struct uv__epoll_event { - uint32_t events; - uint64_t data; -} __attribute__((packed)); -#else -struct uv__epoll_event { - uint32_t events; - uint64_t data; -}; -#endif - -struct uv__inotify_event { - int32_t wd; - uint32_t mask; - uint32_t cookie; - uint32_t len; - /* char name[0]; */ -}; - -struct uv__mmsghdr { - struct msghdr msg_hdr; - unsigned int msg_len; -}; - -int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags); -int uv__eventfd(unsigned int count); -int uv__epoll_create(int size); -int uv__epoll_create1(int flags); -int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event *ev); -int uv__epoll_wait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout); -int uv__epoll_pwait(int epfd, - struct uv__epoll_event* events, - int nevents, - int timeout, - uint64_t sigmask); -int uv__eventfd2(unsigned int count, int flags); -int uv__inotify_init(void); -int uv__inotify_init1(int flags); -int uv__inotify_add_watch(int fd, const char* path, uint32_t mask); -int uv__inotify_rm_watch(int fd, int32_t wd); -int uv__pipe2(int pipefd[2], int flags); -int uv__recvmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags, - struct timespec* timeout); -int uv__sendmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags); -int uv__utimesat(int dirfd, - const char* path, - const struct timespec times[2], - int flags); -ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset); -ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset); -int uv__dup3(int oldfd, int newfd, int flags); - -#endif /* UV_LINUX_SYSCALL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/loop-watcher.c b/lib/ESPiLight/pilight/libs/libuv/unix/loop-watcher.c deleted file mode 100644 index 340bb0d..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/loop-watcher.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#define UV_LOOP_WATCHER_DEFINE(name, type) \ - int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \ - uv__handle_init(loop, (uv_handle_t*)handle, UV_##type); \ - handle->name##_cb = NULL; \ - return 0; \ - } \ - \ - int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \ - if (uv__is_active(handle)) return 0; \ - if (cb == NULL) return -EINVAL; \ - QUEUE_INSERT_HEAD(&handle->loop->name##_handles, &handle->queue); \ - handle->name##_cb = cb; \ - uv__handle_start(handle); \ - return 0; \ - } \ - \ - int uv_##name##_stop(uv_##name##_t* handle) { \ - if (!uv__is_active(handle)) return 0; \ - QUEUE_REMOVE(&handle->queue); \ - uv__handle_stop(handle); \ - return 0; \ - } \ - \ - void uv__run_##name(uv_loop_t* loop) { \ - uv_##name##_t* h; \ - QUEUE queue; \ - QUEUE* q; \ - QUEUE_MOVE(&loop->name##_handles, &queue); \ - while (!QUEUE_EMPTY(&queue)) { \ - q = QUEUE_HEAD(&queue); \ - h = QUEUE_DATA(q, uv_##name##_t, queue); \ - QUEUE_REMOVE(q); \ - QUEUE_INSERT_TAIL(&loop->name##_handles, q); \ - h->name##_cb(h); \ - } \ - } \ - \ - void uv__##name##_close(uv_##name##_t* handle) { \ - uv_##name##_stop(handle); \ - } - -UV_LOOP_WATCHER_DEFINE(prepare, PREPARE) -UV_LOOP_WATCHER_DEFINE(check, CHECK) -UV_LOOP_WATCHER_DEFINE(idle, IDLE) diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/loop.c b/lib/ESPiLight/pilight/libs/libuv/unix/loop.c deleted file mode 100644 index bcd4924..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/loop.c +++ /dev/null @@ -1,193 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "tree.h" -#include "internal.h" -#include "heap-inl.h" -#include -#include -#include - -int uv_loop_init(uv_loop_t* loop) { - void* saved_data; - int err; - - uv__signal_global_once_init(); - - saved_data = loop->data; - memset(loop, 0, sizeof(*loop)); - loop->data = saved_data; - - heap_init((struct heap*) &loop->timer_heap); - QUEUE_INIT(&loop->wq); - QUEUE_INIT(&loop->active_reqs); - QUEUE_INIT(&loop->idle_handles); - QUEUE_INIT(&loop->async_handles); - QUEUE_INIT(&loop->check_handles); - QUEUE_INIT(&loop->prepare_handles); - QUEUE_INIT(&loop->handle_queue); - - loop->nfds = 0; - loop->watchers = NULL; - loop->nwatchers = 0; - QUEUE_INIT(&loop->pending_queue); - QUEUE_INIT(&loop->watcher_queue); - - loop->closing_handles = NULL; - uv__update_time(loop); - loop->async_io_watcher.fd = -1; - loop->async_wfd = -1; - loop->signal_pipefd[0] = -1; - loop->signal_pipefd[1] = -1; - loop->backend_fd = -1; - loop->emfile_fd = -1; - - loop->timer_counter = 0; - loop->stop_flag = 0; - - err = uv__platform_loop_init(loop); - if (err) - return err; - - err = uv_signal_init(loop, &loop->child_watcher); - if (err) - goto fail_signal_init; - - uv__handle_unref(&loop->child_watcher); - loop->child_watcher.flags |= UV__HANDLE_INTERNAL; - QUEUE_INIT(&loop->process_handles); - - err = uv_rwlock_init(&loop->cloexec_lock); - if (err) - goto fail_rwlock_init; - - err = uv_mutex_init(&loop->wq_mutex); - if (err) - goto fail_mutex_init; - - err = uv_async_init(loop, &loop->wq_async, uv__work_done); - if (err) - goto fail_async_init; - - uv__handle_unref(&loop->wq_async); - loop->wq_async.flags |= UV__HANDLE_INTERNAL; - - return 0; - -fail_async_init: - uv_mutex_destroy(&loop->wq_mutex); - -fail_mutex_init: - uv_rwlock_destroy(&loop->cloexec_lock); - -fail_rwlock_init: - uv__signal_loop_cleanup(loop); - -fail_signal_init: - uv__platform_loop_delete(loop); - - return err; -} - - -int uv_loop_fork(uv_loop_t* loop) { - int err; - unsigned int i; - uv__io_t* w; - - err = uv__io_fork(loop); - if (err) - return err; - - err = uv__async_fork(loop); - if (err) - return err; - - err = uv__signal_loop_fork(loop); - if (err) - return err; - - /* Rearm all the watchers that aren't re-queued by the above. */ - for (i = 0; i < loop->nwatchers; i++) { - w = loop->watchers[i]; - if (w == NULL) - continue; - - if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue)) { - w->events = 0; /* Force re-registration in uv__io_poll. */ - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); - } - } - - return 0; -} - - -void uv__loop_close(uv_loop_t* loop) { - uv__signal_loop_cleanup(loop); - uv__platform_loop_delete(loop); - uv__async_stop(loop); - - if (loop->emfile_fd != -1) { - uv__close(loop->emfile_fd); - loop->emfile_fd = -1; - } - - if (loop->backend_fd != -1) { - uv__close(loop->backend_fd); - loop->backend_fd = -1; - } - - uv_mutex_lock(&loop->wq_mutex); - assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!"); - assert(!uv__has_active_reqs(loop)); - uv_mutex_unlock(&loop->wq_mutex); - uv_mutex_destroy(&loop->wq_mutex); - - /* - * Note that all thread pool stuff is finished at this point and - * it is safe to just destroy rw lock - */ - uv_rwlock_destroy(&loop->cloexec_lock); - -#if 0 - assert(QUEUE_EMPTY(&loop->pending_queue)); - assert(QUEUE_EMPTY(&loop->watcher_queue)); - assert(loop->nfds == 0); -#endif - - uv__free(loop->watchers); - loop->watchers = NULL; - loop->nwatchers = 0; -} - - -int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) { - if (option != UV_LOOP_BLOCK_SIGNAL) - return UV_ENOSYS; - - if (va_arg(ap, int) != SIGPROF) - return UV_EINVAL; - - loop->flags |= UV_LOOP_BLOCK_SIGPROF; - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/netbsd.c b/lib/ESPiLight/pilight/libs/libuv/unix/netbsd.c deleted file mode 100644 index 9b5546b..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/netbsd.c +++ /dev/null @@ -1,272 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -static char *process_title; - - -int uv__platform_loop_init(uv_loop_t* loop) { - return uv__kqueue_init(loop); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) == -1) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -int uv_exepath(char* buffer, size_t* size) { - int mib[4]; - size_t cb; - pid_t mypid; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - mypid = getpid(); - mib[0] = CTL_KERN; - mib[1] = KERN_PROC_ARGS; - mib[2] = mypid; - mib[3] = KERN_PROC_ARGV; - - cb = *size; - if (sysctl(mib, 4, buffer, &cb, NULL, 0)) - return -errno; - *size = strlen(buffer); - - return 0; -} - - -uint64_t uv_get_free_memory(void) { - struct uvmexp info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_UVMEXP}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - return (uint64_t) info.free * sysconf(_SC_PAGESIZE); -} - - -uint64_t uv_get_total_memory(void) { -#if defined(HW_PHYSMEM64) - uint64_t info; - int which[] = {CTL_HW, HW_PHYSMEM64}; -#else - unsigned int info; - int which[] = {CTL_HW, HW_PHYSMEM}; -#endif - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - return (uint64_t) info; -} - - -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - if (process_title) uv__free(process_title); - - process_title = uv__strdup(title); - setproctitle("%s", title); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return -EINVAL; - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) - return -ENOBUFS; - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - buffer[len] = '\0'; - - return 0; -} - - -int uv_resident_set_memory(size_t* rss) { - kvm_t *kd = NULL; - struct kinfo_proc2 *kinfo = NULL; - pid_t pid; - int nprocs; - int max_size = sizeof(struct kinfo_proc2); - int page_size; - - page_size = getpagesize(); - pid = getpid(); - - kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open"); - - if (kd == NULL) goto error; - - kinfo = kvm_getproc2(kd, KERN_PROC_PID, pid, max_size, &nprocs); - if (kinfo == NULL) goto error; - - *rss = kinfo->p_vm_rssize * page_size; - - kvm_close(kd); - - return 0; - -error: - if (kd) kvm_close(kd); - return -EPERM; -} - - -int uv_uptime(double* uptime) { - time_t now; - struct timeval info; - size_t size = sizeof(info); - static int which[] = {CTL_KERN, KERN_BOOTTIME}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - now = time(NULL); - - *uptime = (double)(now - info.tv_sec); - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK); - unsigned int multiplier = ((uint64_t)1000L / ticks); - unsigned int cur = 0; - uv_cpu_info_t* cpu_info; - u_int64_t* cp_times; - char model[512]; - u_int64_t cpuspeed; - int numcpus; - size_t size; - int i; - - size = sizeof(model); - if (sysctlbyname("machdep.cpu_brand", &model, &size, NULL, 0) && - sysctlbyname("hw.model", &model, &size, NULL, 0)) { - return -errno; - } - - size = sizeof(numcpus); - if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0)) - return -errno; - *count = numcpus; - - /* Only i386 and amd64 have machdep.tsc_freq */ - size = sizeof(cpuspeed); - if (sysctlbyname("machdep.tsc_freq", &cpuspeed, &size, NULL, 0)) - cpuspeed = 0; - - size = numcpus * CPUSTATES * sizeof(*cp_times); - cp_times = uv__malloc(size); - if (cp_times == NULL) - return -ENOMEM; - - if (sysctlbyname("kern.cp_time", cp_times, &size, NULL, 0)) - return -errno; - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) { - uv__free(cp_times); - uv__free(*cpu_infos); - return -ENOMEM; - } - - for (i = 0; i < numcpus; i++) { - cpu_info = &(*cpu_infos)[i]; - cpu_info->cpu_times.user = (uint64_t)(cp_times[CP_USER+cur]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(cp_times[CP_NICE+cur]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(cp_times[CP_SYS+cur]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(cp_times[CP_IDLE+cur]) * multiplier; - cpu_info->cpu_times.irq = (uint64_t)(cp_times[CP_INTR+cur]) * multiplier; - cpu_info->model = uv__strdup(model); - cpu_info->speed = (int)(cpuspeed/(uint64_t) 1e6); - cur += CPUSTATES; - } - uv__free(cp_times); - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/no-fsevents.c b/lib/ESPiLight/pilight/libs/libuv/unix/no-fsevents.c deleted file mode 100644 index 38fb6ab..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/no-fsevents.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - return -ENOSYS; -} - -int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, - const char* filename, unsigned int flags) { - return -ENOSYS; -} - -int uv_fs_event_stop(uv_fs_event_t* handle) { - return -ENOSYS; -} - -void uv__fs_event_close(uv_fs_event_t* handle) { - UNREACHABLE(); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/no-proctitle.c b/lib/ESPiLight/pilight/libs/libuv/unix/no-proctitle.c deleted file mode 100644 index a5c19fb..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/no-proctitle.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -char** uv_setup_args(int argc, char** argv) { - return argv; -} - -int uv_set_process_title(const char* title) { - return 0; -} - -int uv_get_process_title(char* buffer, size_t size) { - if (buffer == NULL || size == 0) - return -EINVAL; - - buffer[0] = '\0'; - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/openbsd.c b/lib/ESPiLight/pilight/libs/libuv/unix/openbsd.c deleted file mode 100644 index 56f0af1..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/openbsd.c +++ /dev/null @@ -1,284 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -static char *process_title; - - -int uv__platform_loop_init(uv_loop_t* loop) { - return uv__kqueue_init(loop); -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { -} - - -void uv_loadavg(double avg[3]) { - struct loadavg info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_LOADAVG}; - - if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return; - - avg[0] = (double) info.ldavg[0] / info.fscale; - avg[1] = (double) info.ldavg[1] / info.fscale; - avg[2] = (double) info.ldavg[2] / info.fscale; -} - - -int uv_exepath(char* buffer, size_t* size) { - int mib[4]; - char **argsbuf = NULL; - char **argsbuf_tmp; - size_t argsbuf_size = 100U; - size_t exepath_size; - pid_t mypid; - int err; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - mypid = getpid(); - for (;;) { - err = -ENOMEM; - argsbuf_tmp = uv__realloc(argsbuf, argsbuf_size); - if (argsbuf_tmp == NULL) - goto out; - argsbuf = argsbuf_tmp; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC_ARGS; - mib[2] = mypid; - mib[3] = KERN_PROC_ARGV; - if (sysctl(mib, 4, argsbuf, &argsbuf_size, NULL, 0) == 0) { - break; - } - if (errno != ENOMEM) { - err = -errno; - goto out; - } - argsbuf_size *= 2U; - } - - if (argsbuf[0] == NULL) { - err = -EINVAL; /* FIXME(bnoordhuis) More appropriate error. */ - goto out; - } - - *size -= 1; - exepath_size = strlen(argsbuf[0]); - if (*size > exepath_size) - *size = exepath_size; - - memcpy(buffer, argsbuf[0], *size); - buffer[*size] = '\0'; - err = 0; - -out: - uv__free(argsbuf); - - return err; -} - - -uint64_t uv_get_free_memory(void) { - struct uvmexp info; - size_t size = sizeof(info); - int which[] = {CTL_VM, VM_UVMEXP}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - return (uint64_t) info.free * sysconf(_SC_PAGESIZE); -} - - -uint64_t uv_get_total_memory(void) { - uint64_t info; - int which[] = {CTL_HW, HW_PHYSMEM64}; - size_t size = sizeof(info); - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - return (uint64_t) info; -} - - -char** uv_setup_args(int argc, char** argv) { - process_title = argc ? uv__strdup(argv[0]) : NULL; - return argv; -} - - -int uv_set_process_title(const char* title) { - uv__free(process_title); - process_title = uv__strdup(title); - setproctitle("%s", title); - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return -EINVAL; - - if (process_title) { - len = strlen(process_title) + 1; - - if (size < len) - return -ENOBUFS; - - memcpy(buffer, process_title, len); - } else { - len = 0; - } - - buffer[len] = '\0'; - - return 0; -} - - -int uv_resident_set_memory(size_t* rss) { - struct kinfo_proc kinfo; - size_t page_size = getpagesize(); - size_t size = sizeof(struct kinfo_proc); - int mib[6]; - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - mib[4] = sizeof(struct kinfo_proc); - mib[5] = 1; - - if (sysctl(mib, 6, &kinfo, &size, NULL, 0) < 0) - return -errno; - - *rss = kinfo.p_vm_rssize * page_size; - return 0; -} - - -int uv_uptime(double* uptime) { - time_t now; - struct timeval info; - size_t size = sizeof(info); - static int which[] = {CTL_KERN, KERN_BOOTTIME}; - - if (sysctl(which, 2, &info, &size, NULL, 0)) - return -errno; - - now = time(NULL); - - *uptime = (double)(now - info.tv_sec); - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), - multiplier = ((uint64_t)1000L / ticks), cpuspeed; - uint64_t info[CPUSTATES]; - char model[512]; - int numcpus = 1; - int which[] = {CTL_HW,HW_MODEL,0}; - size_t size; - int i; - uv_cpu_info_t* cpu_info; - - size = sizeof(model); - if (sysctl(which, 2, &model, &size, NULL, 0)) - return -errno; - - which[1] = HW_NCPU; - size = sizeof(numcpus); - if (sysctl(which, 2, &numcpus, &size, NULL, 0)) - return -errno; - - *cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos)); - if (!(*cpu_infos)) - return -ENOMEM; - - *count = numcpus; - - which[1] = HW_CPUSPEED; - size = sizeof(cpuspeed); - if (sysctl(which, 2, &cpuspeed, &size, NULL, 0)) { - uv__free(*cpu_infos); - return -errno; - } - - size = sizeof(info); - which[0] = CTL_KERN; - which[1] = KERN_CPTIME2; - for (i = 0; i < numcpus; i++) { - which[2] = i; - size = sizeof(info); - if (sysctl(which, 3, &info, &size, NULL, 0)) { - uv__free(*cpu_infos); - return -errno; - } - - cpu_info = &(*cpu_infos)[i]; - - cpu_info->cpu_times.user = (uint64_t)(info[CP_USER]) * multiplier; - cpu_info->cpu_times.nice = (uint64_t)(info[CP_NICE]) * multiplier; - cpu_info->cpu_times.sys = (uint64_t)(info[CP_SYS]) * multiplier; - cpu_info->cpu_times.idle = (uint64_t)(info[CP_IDLE]) * multiplier; - cpu_info->cpu_times.irq = (uint64_t)(info[CP_INTR]) * multiplier; - - cpu_info->model = uv__strdup(model); - cpu_info->speed = cpuspeed; - } - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/os390-syscalls.c b/lib/ESPiLight/pilight/libs/libuv/unix/os390-syscalls.c deleted file mode 100644 index 7edf235..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/os390-syscalls.c +++ /dev/null @@ -1,334 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - - -#include "os390-syscalls.h" -#include -#include -#include -#include - -#define CW_CONDVAR 32 - -#pragma linkage(BPX4CTW, OS) -#pragma linkage(BPX1CTW, OS) - -static int number_of_epolls; -static QUEUE global_epoll_queue; -static uv_mutex_t global_epoll_lock; -static uv_once_t once = UV_ONCE_INIT; - -int scandir(const char* maindir, struct dirent*** namelist, - int (*filter)(const struct dirent*), - int (*compar)(const struct dirent**, - const struct dirent **)) { - struct dirent** nl; - struct dirent* dirent; - unsigned count; - size_t allocated; - DIR* mdir; - - nl = NULL; - count = 0; - allocated = 0; - mdir = opendir(maindir); - if (!mdir) - return -1; - - while (1) { - dirent = readdir(mdir); - if (!dirent) - break; - if (!filter || filter(dirent)) { - struct dirent* copy; - copy = uv__malloc(sizeof(*copy)); - if (!copy) { - while (count) { - dirent = nl[--count]; - uv__free(dirent); - } - uv__free(nl); - closedir(mdir); - errno = ENOMEM; - return -1; - } - memcpy(copy, dirent, sizeof(*copy)); - - nl = uv__realloc(nl, sizeof(*copy) * (count + 1)); - nl[count++] = copy; - } - } - - qsort(nl, count, sizeof(struct dirent *), - (int (*)(const void *, const void *)) compar); - - closedir(mdir); - - *namelist = nl; - return count; -} - - -static unsigned int next_power_of_two(unsigned int val) { - val -= 1; - val |= val >> 1; - val |= val >> 2; - val |= val >> 4; - val |= val >> 8; - val |= val >> 16; - val += 1; - return val; -} - - -static void maybe_resize(uv__os390_epoll* lst, unsigned int len) { - unsigned int newsize; - unsigned int i; - struct pollfd* newlst; - - if (len <= lst->size) - return; - - newsize = next_power_of_two(len); - newlst = uv__realloc(lst->items, newsize * sizeof(lst->items[0])); - - if (newlst == NULL) - abort(); - for (i = lst->size; i < newsize; ++i) - newlst[i].fd = -1; - - lst->items = newlst; - lst->size = newsize; -} - - -static void epoll_init(void) { - QUEUE_INIT(&global_epoll_queue); - if (uv_mutex_init(&global_epoll_lock)) - abort(); -} - - -uv__os390_epoll* epoll_create1(int flags) { - uv__os390_epoll* lst; - - uv_once(&once, epoll_init); - uv_mutex_lock(&global_epoll_lock); - lst = uv__malloc(sizeof(*lst)); - if (lst == -1) - return NULL; - QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member); - uv_mutex_unlock(&global_epoll_lock); - - /* initialize list */ - lst->size = 0; - lst->items = NULL; - return lst; -} - - -int epoll_ctl(uv__os390_epoll* lst, - int op, - int fd, - struct epoll_event *event) { - if(op == EPOLL_CTL_DEL) { - if (fd >= lst->size || lst->items[fd].fd == -1) { - errno = ENOENT; - return -1; - } - lst->items[fd].fd = -1; - } else if(op == EPOLL_CTL_ADD) { - maybe_resize(lst, fd + 1); - if (lst->items[fd].fd != -1) { - errno = EEXIST; - return -1; - } - lst->items[fd].fd = fd; - lst->items[fd].events = event->events; - } else if(op == EPOLL_CTL_MOD) { - if (fd >= lst->size || lst->items[fd].fd == -1) { - errno = ENOENT; - return -1; - } - lst->items[fd].events = event->events; - } else - abort(); - - return 0; -} - - -int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events, - int maxevents, int timeout) { - size_t size; - struct pollfd* pfds; - int pollret; - int reventcount; - - uv_mutex_lock(&global_epoll_lock); - uv_mutex_unlock(&global_epoll_lock); - size = lst->size; - pfds = lst->items; - pollret = poll(pfds, size, timeout); - if(pollret == -1) - return pollret; - - reventcount = 0; - for (int i = 0; i < lst->size && i < maxevents; ++i) { - struct epoll_event ev; - - ev.events = 0; - ev.fd = pfds[i].fd; - if(!pfds[i].revents) - continue; - - if(pfds[i].revents & POLLRDNORM) - ev.events = ev.events | POLLIN; - - if(pfds[i].revents & POLLWRNORM) - ev.events = ev.events | POLLOUT; - - if(pfds[i].revents & POLLHUP) - ev.events = ev.events | POLLHUP; - - pfds[i].revents = 0; - events[reventcount++] = ev; - } - - return reventcount; -} - - -int epoll_file_close(int fd) { - QUEUE* q; - - uv_once(&once, epoll_init); - uv_mutex_lock(&global_epoll_lock); - QUEUE_FOREACH(q, &global_epoll_queue) { - uv__os390_epoll* lst; - - lst = QUEUE_DATA(q, uv__os390_epoll, member); - if (fd < lst->size && lst->items != NULL && lst->items[fd].fd != -1) - lst->items[fd].fd = -1; - } - - uv_mutex_unlock(&global_epoll_lock); - return 0; -} - -void epoll_queue_close(uv__os390_epoll* lst) { - uv_mutex_lock(&global_epoll_lock); - QUEUE_REMOVE(&lst->member); - uv_mutex_unlock(&global_epoll_lock); - uv__free(lst->items); - lst->items = NULL; -} - - -int nanosleep(const struct timespec* req, struct timespec* rem) { - unsigned nano; - unsigned seconds; - unsigned events; - unsigned secrem; - unsigned nanorem; - int rv; - int rc; - int rsn; - - nano = (int)req->tv_nsec; - seconds = req->tv_sec; - events = CW_CONDVAR; - -#if defined(_LP64) - BPX4CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &rc, &rsn); -#else - BPX1CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &rc, &rsn); -#endif - - assert(rv == -1 && errno == EAGAIN); - - if(rem != NULL) { - rem->tv_nsec = nanorem; - rem->tv_sec = secrem; - } - - return 0; -} - - -char* mkdtemp(char* path) { - static const char* tempchars = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - static const size_t num_chars = 62; - static const size_t num_x = 6; - char *ep, *cp; - unsigned int tries, i; - size_t len; - uint64_t v; - int fd; - int retval; - int saved_errno; - - len = strlen(path); - ep = path + len; - if (len < num_x || strncmp(ep - num_x, "XXXXXX", num_x)) { - errno = EINVAL; - return NULL; - } - - fd = open("/dev/urandom", O_RDONLY); - if (fd == -1) - return NULL; - - tries = TMP_MAX; - retval = -1; - do { - if (read(fd, &v, sizeof(v)) != sizeof(v)) - break; - - cp = ep - num_x; - for (i = 0; i < num_x; i++) { - *cp++ = tempchars[v % num_chars]; - v /= num_chars; - } - - if (mkdir(path, S_IRWXU) == 0) { - retval = 0; - break; - } - else if (errno != EEXIST) - break; - } while (--tries); - - saved_errno = errno; - uv__close(fd); - if (tries == 0) { - errno = EEXIST; - return NULL; - } - - if (retval == -1) { - errno = saved_errno; - return NULL; - } - - return path; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/os390-syscalls.h b/lib/ESPiLight/pilight/libs/libuv/unix/os390-syscalls.h deleted file mode 100644 index 61a7cee..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/os390-syscalls.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - - -#ifndef UV_OS390_SYSCALL_H_ -#define UV_OS390_SYSCALL_H_ - -#include "uv.h" -#include "internal.h" -#include -#include -#include - -#define EPOLL_CTL_ADD 1 -#define EPOLL_CTL_DEL 2 -#define EPOLL_CTL_MOD 3 -#define MAX_EPOLL_INSTANCES 256 -#define MAX_ITEMS_PER_EPOLL 1024 - -#define UV__O_CLOEXEC 0x80000 -#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC -#define UV__EPOLL_CTL_ADD EPOLL_CTL_ADD -#define UV__EPOLL_CTL_DEL EPOLL_CTL_DEL -#define UV__EPOLL_CTL_MOD EPOLL_CTL_MOD - -struct epoll_event { - int events; - int fd; -}; - -typedef struct { - QUEUE member; - struct pollfd* items; - unsigned long size; -} uv__os390_epoll; - -/* epoll api */ -uv__os390_epoll* epoll_create1(int flags); -int epoll_ctl(uv__os390_epoll* ep, int op, int fd, struct epoll_event *event); -int epoll_wait(uv__os390_epoll* ep, struct epoll_event *events, int maxevents, int timeout); -int epoll_file_close(int fd); - -/* utility functions */ -int nanosleep(const struct timespec* req, struct timespec* rem); -int scandir(const char* maindir, struct dirent*** namelist, - int (*filter)(const struct dirent *), - int (*compar)(const struct dirent **, - const struct dirent **)); -char *mkdtemp(char* path); - -#endif /* UV_OS390_SYSCALL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/os390.c b/lib/ESPiLight/pilight/libs/libuv/unix/os390.c deleted file mode 100644 index 2ba5abf..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/os390.c +++ /dev/null @@ -1,849 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "internal.h" -#include -#include -#include -#include -#include -#if defined(__clang__) -#include "csrsic.h" -#else -#include "//'SYS1.SAMPLIB(CSRSIC)'" -#endif - -#define CVT_PTR 0x10 -#define CSD_OFFSET 0x294 - -/* - Long-term average CPU service used by this logical partition, - in millions of service units per hour. If this value is above - the partition's defined capacity, the partition will be capped. - It is calculated using the physical CPU adjustment factor - (RCTPCPUA) so it may not match other measures of service which - are based on the logical CPU adjustment factor. It is available - if the hardware supports LPAR cluster. -*/ -#define RCTLACS_OFFSET 0xC4 - -/* 32-bit count of alive CPUs. This includes both CPs and IFAs */ -#define CSD_NUMBER_ONLINE_CPUS 0xD4 - -/* Address of system resources manager (SRM) control table */ -#define CVTOPCTP_OFFSET 0x25C - -/* Address of the RCT table */ -#define RMCTRCT_OFFSET 0xE4 - -/* Address of the rsm control and enumeration area. */ -#define CVTRCEP_OFFSET 0x490 - -/* - Number of frames currently available to system. - Excluded are frames backing perm storage, frames offline, and bad frames. -*/ -#define RCEPOOL_OFFSET 0x004 - -/* Total number of frames currently on all available frame queues. */ -#define RCEAFC_OFFSET 0x088 - -/* CPC model length from the CSRSI Service. */ -#define CPCMODEL_LENGTH 16 - -/* Thread Entry constants */ -#define PGTH_CURRENT 1 -#define PGTH_LEN 26 -#define PGTHAPATH 0x20 -#pragma linkage(BPX4GTH, OS) -#pragma linkage(BPX1GTH, OS) - -typedef unsigned data_area_ptr_assign_type; - -typedef union { - struct { -#if defined(_LP64) - data_area_ptr_assign_type lower; -#endif - data_area_ptr_assign_type assign; - }; - char* deref; -} data_area_ptr; - - -void uv_loadavg(double avg[3]) { - /* TODO: implement the following */ - avg[0] = 0; - avg[1] = 0; - avg[2] = 0; -} - - -int uv__platform_loop_init(uv_loop_t* loop) { - uv__os390_epoll* ep; - - ep = epoll_create1(UV__EPOLL_CLOEXEC); - loop->ep = ep; - if (ep == NULL) - return -errno; - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->ep != NULL) { - epoll_queue_close(loop->ep); - loop->ep = NULL; - } -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - struct timeval time; - gettimeofday(&time, NULL); - return (uint64_t) time.tv_sec * 1e9 + time.tv_usec * 1e3; -} - - -/* - Get the exe path using the thread entry information - in the address space. -*/ -static int getexe(const int pid, char* buf, size_t len) { - struct { - int pid; - int thid[2]; - char accesspid; - char accessthid; - char asid[2]; - char loginname[8]; - char flag; - char len; - } Input_data; - - union { - struct { - char gthb[4]; - int pid; - int thid[2]; - char accesspid; - char accessthid[3]; - int lenused; - int offsetProcess; - int offsetConTTY; - int offsetPath; - int offsetCommand; - int offsetFileData; - int offsetThread; - } Output_data; - char buf[2048]; - } Output_buf; - - struct Output_path_type { - char gthe[4]; - short int len; - char path[1024]; - }; - - int Input_length; - int Output_length; - void* Input_address; - void* Output_address; - struct Output_path_type* Output_path; - int rv; - int rc; - int rsn; - - Input_length = PGTH_LEN; - Output_length = sizeof(Output_buf); - Output_address = &Output_buf; - Input_address = &Input_data; - memset(&Input_data, 0, sizeof Input_data); - Input_data.flag |= PGTHAPATH; - Input_data.pid = pid; - Input_data.accesspid = PGTH_CURRENT; - -#ifdef _LP64 - BPX4GTH(&Input_length, - &Input_address, - &Output_length, - &Output_address, - &rv, - &rc, - &rsn); -#else - BPX1GTH(&Input_length, - &Input_address, - &Output_length, - &Output_address, - &rv, - &rc, - &rsn); -#endif - - if (rv == -1) { - errno = rc; - return -1; - } - - /* Check highest byte to ensure data availability */ - assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) == 'A'); - - /* Get the offset from the lowest 3 bytes */ - Output_path = (char*)(&Output_buf) + - (Output_buf.Output_data.offsetPath & 0x00FFFFFF); - - if (Output_path->len >= len) { - errno = ENOBUFS; - return -1; - } - - strncpy(buf, Output_path->path, len); - - return 0; -} - - -/* - * We could use a static buffer for the path manipulations that we need outside - * of the function, but this function could be called by multiple consumers and - * we don't want to potentially create a race condition in the use of snprintf. - * There is no direct way of getting the exe path in zOS - either through /procfs - * or through some libc APIs. The below approach is to parse the argv[0]'s pattern - * and use it in conjunction with PATH environment variable to craft one. - */ -int uv_exepath(char* buffer, size_t* size) { - int res; - char args[PATH_MAX]; - char abspath[PATH_MAX]; - size_t abspath_size; - int pid; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - pid = getpid(); - res = getexe(pid, args, sizeof(args)); - if (res < 0) - return -EINVAL; - - /* - * Possibilities for args: - * i) an absolute path such as: /home/user/myprojects/nodejs/node - * ii) a relative path such as: ./node or ../myprojects/nodejs/node - * iii) a bare filename such as "node", after exporting PATH variable - * to its location. - */ - - /* Case i) and ii) absolute or relative paths */ - if (strchr(args, '/') != NULL) { - if (realpath(args, abspath) != abspath) - return -errno; - - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; - } else { - /* Case iii). Search PATH environment variable */ - char trypath[PATH_MAX]; - char* clonedpath = NULL; - char* token = NULL; - char* path = getenv("PATH"); - - if (path == NULL) - return -EINVAL; - - clonedpath = uv__strdup(path); - if (clonedpath == NULL) - return -ENOMEM; - - token = strtok(clonedpath, ":"); - while (token != NULL) { - snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, args); - if (realpath(trypath, abspath) == abspath) { - /* Check the match is executable */ - if (access(abspath, X_OK) == 0) { - abspath_size = strlen(abspath); - - *size -= 1; - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - uv__free(clonedpath); - return 0; - } - } - token = strtok(NULL, ":"); - } - uv__free(clonedpath); - - /* Out of tokens (path entries), and no match found */ - return -EINVAL; - } -} - - -uint64_t uv_get_free_memory(void) { - uint64_t freeram; - - data_area_ptr cvt = {0}; - data_area_ptr rcep = {0}; - cvt.assign = *(data_area_ptr_assign_type*)(CVT_PTR); - rcep.assign = *(data_area_ptr_assign_type*)(cvt.deref + CVTRCEP_OFFSET); - freeram = *((uint64_t*)(rcep.deref + RCEAFC_OFFSET)) * 4; - return freeram; -} - - -uint64_t uv_get_total_memory(void) { - uint64_t totalram; - - data_area_ptr cvt = {0}; - data_area_ptr rcep = {0}; - cvt.assign = *(data_area_ptr_assign_type*)(CVT_PTR); - rcep.assign = *(data_area_ptr_assign_type*)(cvt.deref + CVTRCEP_OFFSET); - totalram = *((uint64_t*)(rcep.deref + RCEPOOL_OFFSET)) * 4; - return totalram; -} - - -int uv_resident_set_memory(size_t* rss) { - W_PSPROC buf; - - memset(&buf, 0, sizeof(buf)); - if (w_getpsent(0, &buf, sizeof(W_PSPROC)) == -1) - return -EINVAL; - - *rss = buf.ps_size; - return 0; -} - - -int uv_uptime(double* uptime) { - struct utmpx u ; - struct utmpx *v; - time64_t t; - - u.ut_type = BOOT_TIME; - v = getutxid(&u); - if (v == NULL) - return -1; - *uptime = difftime64(time64(&t), v->ut_tv.tv_sec); - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - uv_cpu_info_t* cpu_info; - int result; - int idx; - siv1v2 info; - data_area_ptr cvt = {0}; - data_area_ptr csd = {0}; - data_area_ptr rmctrct = {0}; - data_area_ptr cvtopctp = {0}; - int cpu_usage_avg; - - cvt.assign = *(data_area_ptr_assign_type*)(CVT_PTR); - - csd.assign = *((data_area_ptr_assign_type *) (cvt.deref + CSD_OFFSET)); - cvtopctp.assign = *((data_area_ptr_assign_type *) (cvt.deref + CVTOPCTP_OFFSET)); - rmctrct.assign = *((data_area_ptr_assign_type *) (cvtopctp.deref + RMCTRCT_OFFSET)); - - *count = *((int*) (csd.deref + CSD_NUMBER_ONLINE_CPUS)); - cpu_usage_avg = *((unsigned short int*) (rmctrct.deref + RCTLACS_OFFSET)); - - *cpu_infos = uv__malloc(*count * sizeof(uv_cpu_info_t)); - if (!*cpu_infos) - return -ENOMEM; - - cpu_info = *cpu_infos; - idx = 0; - while (idx < *count) { - cpu_info->speed = *(int*)(info.siv1v2si22v1.si22v1cpucapability); - cpu_info->model = uv__malloc(CPCMODEL_LENGTH + 1); - memset(cpu_info->model, '\0', CPCMODEL_LENGTH + 1); - memcpy(cpu_info->model, info.siv1v2si11v1.si11v1cpcmodel, CPCMODEL_LENGTH); - cpu_info->cpu_times.user = cpu_usage_avg; - /* TODO: implement the following */ - cpu_info->cpu_times.sys = 0; - cpu_info->cpu_times.idle = 0; - cpu_info->cpu_times.irq = 0; - cpu_info->cpu_times.nice = 0; - ++cpu_info; - ++idx; - } - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - for (int i = 0; i < count; ++i) - uv__free(cpu_infos[i].model); - uv__free(cpu_infos); -} - - -static int uv__interface_addresses_v6(uv_interface_address_t** addresses, - int* count) { - uv_interface_address_t* address; - int sockfd; - int maxsize; - __net_ifconf6header_t ifc; - __net_ifconf6entry_t* ifr; - __net_ifconf6entry_t* p; - __net_ifconf6entry_t flg; - - *count = 0; - /* Assume maximum buffer size allowable */ - maxsize = 16384; - - if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) - return -errno; - - ifc.__nif6h_version = 1; - ifc.__nif6h_buflen = maxsize; - ifc.__nif6h_buffer = uv__calloc(1, maxsize);; - - if (ioctl(sockfd, SIOCGIFCONF6, &ifc) == -1) { - uv__close(sockfd); - return -errno; - } - - - *count = 0; - ifr = (__net_ifconf6entry_t*)(ifc.__nif6h_buffer); - while ((char*)ifr < (char*)ifc.__nif6h_buffer + ifc.__nif6h_buflen) { - p = ifr; - ifr = (__net_ifconf6entry_t*)((char*)ifr + ifc.__nif6h_entrylen); - - if (!(p->__nif6e_addr.sin6_family == AF_INET6 || - p->__nif6e_addr.sin6_family == AF_INET)) - continue; - - if (!(p->__nif6e_flags & _NIF6E_FLAGS_ON_LINK_ACTIVE)) - continue; - - ++(*count); - } - - /* Alloc the return interface structs */ - *addresses = uv__malloc(*count * sizeof(uv_interface_address_t)); - if (!(*addresses)) { - uv__close(sockfd); - return -ENOMEM; - } - address = *addresses; - - ifr = (__net_ifconf6entry_t*)(ifc.__nif6h_buffer); - while ((char*)ifr < (char*)ifc.__nif6h_buffer + ifc.__nif6h_buflen) { - p = ifr; - ifr = (__net_ifconf6entry_t*)((char*)ifr + ifc.__nif6h_entrylen); - - if (!(p->__nif6e_addr.sin6_family == AF_INET6 || - p->__nif6e_addr.sin6_family == AF_INET)) - continue; - - if (!(p->__nif6e_flags & _NIF6E_FLAGS_ON_LINK_ACTIVE)) - continue; - - /* All conditions above must match count loop */ - - address->name = uv__strdup(p->__nif6e_name); - - if (p->__nif6e_addr.sin6_family == AF_INET6) - address->address.address6 = *((struct sockaddr_in6*) &p->__nif6e_addr); - else - address->address.address4 = *((struct sockaddr_in*) &p->__nif6e_addr); - - /* TODO: Retrieve netmask using SIOCGIFNETMASK ioctl */ - - address->is_internal = flg.__nif6e_flags & _NIF6E_FLAGS_LOOPBACK ? 1 : 0; - - address++; - } - - uv__close(sockfd); - return 0; -} - - -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - uv_interface_address_t* address; - int sockfd; - int maxsize; - struct ifconf ifc; - struct ifreq flg; - struct ifreq* ifr; - struct ifreq* p; - int count_v6; - - /* get the ipv6 addresses first */ - uv_interface_address_t* addresses_v6; - uv__interface_addresses_v6(&addresses_v6, &count_v6); - - /* now get the ipv4 addresses */ - *count = 0; - - /* Assume maximum buffer size allowable */ - maxsize = 16384; - - sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); - if (0 > sockfd) - return -errno; - - ifc.ifc_req = uv__calloc(1, maxsize); - ifc.ifc_len = maxsize; - if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) { - uv__close(sockfd); - return -errno; - } - -#define MAX(a,b) (((a)>(b))?(a):(b)) -#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p)) - - /* Count all up and running ipv4/ipv6 addresses */ - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return -errno; - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - (*count)++; - } - - /* Alloc the return interface structs */ - *addresses = uv__malloc((*count + count_v6) * - sizeof(uv_interface_address_t)); - - if (!(*addresses)) { - uv__close(sockfd); - return -ENOMEM; - } - address = *addresses; - - /* copy over the ipv6 addresses */ - memcpy(address, addresses_v6, count_v6 * sizeof(uv_interface_address_t)); - address += count_v6; - *count += count_v6; - uv__free(addresses_v6); - - ifr = ifc.ifc_req; - while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { - p = ifr; - ifr = (struct ifreq*) - ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); - - if (!(p->ifr_addr.sa_family == AF_INET6 || - p->ifr_addr.sa_family == AF_INET)) - continue; - - memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return -ENOSYS; - } - - if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) - continue; - - /* All conditions above must match count loop */ - - address->name = uv__strdup(p->ifr_name); - - if (p->ifr_addr.sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr); - } - - address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0; - address++; - } - -#undef ADDR_SIZE -#undef MAX - - uv__close(sockfd); - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - for (i = 0; i < count; ++i) - uv__free(addresses[i].name); - uv__free(addresses); -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct epoll_event* events; - struct epoll_event dummy; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct epoll_event*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events != NULL) - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].fd == fd) - events[i].fd = -1; - - /* Remove the file descriptor from the epoll. */ - if (loop->ep != NULL) - epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, &dummy); -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct pollfd p[1]; - int rv; - - p[0].fd = fd; - p[0].events = POLLIN; - - do - rv = poll(p, 1, 0); - while (rv == -1 && errno == EINTR); - - if (rv == -1) - abort(); - - if (p[0].revents & POLLNVAL) - return -1; - - return 0; -} - -void uv__io_poll(uv_loop_t* loop, int timeout) { - static const int max_safe_timeout = 1789569; - struct epoll_event events[1024]; - struct epoll_event* pe; - struct epoll_event e; - int real_timeout; - QUEUE* q; - uv__io_t* w; - uint64_t base; - int count; - int nfds; - int fd; - int op; - int i; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - uv_stream_t* stream; - - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - - assert(w->pevents != 0); - assert(w->fd >= 0); - - stream= container_of(w, uv_stream_t, io_watcher); - - assert(w->fd < (int) loop->nwatchers); - - e.events = w->pevents; - e.fd = w->fd; - - if (w->events == 0) - op = UV__EPOLL_CTL_ADD; - else - op = UV__EPOLL_CTL_MOD; - - /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching - * events, skip the syscall and squelch the events after epoll_wait(). - */ - if (epoll_ctl(loop->ep, op, w->fd, &e)) { - if (errno != EEXIST) - abort(); - - assert(op == UV__EPOLL_CTL_ADD); - - /* We've reactivated a file descriptor that's been watched before. */ - if (epoll_ctl(loop->ep, UV__EPOLL_CTL_MOD, w->fd, &e)) - abort(); - } - - w->events = w->pevents; - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - real_timeout = timeout; - int nevents = 0; - - nfds = 0; - for (;;) { - if (sizeof(int32_t) == sizeof(long) && timeout >= max_safe_timeout) - timeout = max_safe_timeout; - - nfds = epoll_wait(loop->ep, events, - ARRAY_SIZE(events), timeout); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - base = loop->time; - SAVE_ERRNO(uv__update_time(loop)); - if (nfds == 0) { - assert(timeout != -1); - timeout = real_timeout - timeout; - if (timeout > 0) - continue; - - return; - } - - if (nfds == -1) { - - if (errno != EINTR) - abort(); - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - pe = events + i; - fd = pe->fd; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, disarm it. - * - * Ignore all errors because we may be racing with another thread - * when the file descriptor is closed. - */ - epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, pe); - continue; - } - - /* Give users only events they're interested in. Prevents spurious - * callbacks when previous callback invocation in this loop has stopped - * the current watcher. Also, filters out events that users has not - * requested us to watch. - */ - pe->events &= w->pevents | POLLERR | POLLHUP; - - if (pe->events == POLLERR || pe->events == POLLHUP) - pe->events |= w->pevents & (POLLIN | POLLOUT); - - if (pe->events != 0) { - w->cb(loop, w, pe->events); - nevents++; - } - } - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - real_timeout -= (loop->time - base); - if (real_timeout <= 0) - return; - - timeout = real_timeout; - } -} - -void uv__set_process_title(const char* title) { - /* do nothing */ -} - -int uv__io_fork(uv_loop_t* loop) { - uv__platform_loop_delete(loop); - - return uv__platform_loop_init(loop); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/pipe.c b/lib/ESPiLight/pilight/libs/libuv/unix/pipe.c deleted file mode 100644 index 4a81295..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/pipe.c +++ /dev/null @@ -1,304 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - - -int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) { - uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE); - handle->shutdown_req = NULL; - handle->connect_req = NULL; - handle->pipe_fname = NULL; - handle->ipc = ipc; - return 0; -} - - -int uv_pipe_bind(uv_pipe_t* handle, const char* name) { - struct sockaddr_un saddr; - const char* pipe_fname; - int sockfd; - int err; - - pipe_fname = NULL; - - /* Already bound? */ - if (uv__stream_fd(handle) >= 0) - return -EINVAL; - - /* Make a copy of the file name, it outlives this function's scope. */ - pipe_fname = uv__strdup(name); - if (pipe_fname == NULL) - return -ENOMEM; - - /* We've got a copy, don't touch the original any more. */ - name = NULL; - - err = uv__socket(AF_UNIX, SOCK_STREAM, 0); - if (err < 0) - goto err_socket; - sockfd = err; - - memset(&saddr, 0, sizeof saddr); - strncpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path) - 1); - saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0'; - saddr.sun_family = AF_UNIX; - - if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) { - err = -errno; - /* Convert ENOENT to EACCES for compatibility with Windows. */ - if (err == -ENOENT) - err = -EACCES; - - uv__close(sockfd); - goto err_socket; - } - - /* Success. */ - handle->flags |= UV_HANDLE_BOUND; - handle->pipe_fname = pipe_fname; /* Is a strdup'ed copy. */ - handle->io_watcher.fd = sockfd; - return 0; - -err_socket: - uv__free((void*)pipe_fname); - return err; -} - - -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { - if (uv__stream_fd(handle) == -1) - return -EINVAL; - -#if defined(__MVS__) - /* On zOS, backlog=0 has undefined behaviour */ - if (backlog == 0) - backlog = 1; - else if (backlog < 0) - backlog = SOMAXCONN; -#endif - - if (listen(uv__stream_fd(handle), backlog)) - return -errno; - - handle->connection_cb = cb; - handle->io_watcher.cb = uv__server_io; - uv__io_start(handle->loop, &handle->io_watcher, POLLIN); - return 0; -} - - -void uv__pipe_close(uv_pipe_t* handle) { - if (handle->pipe_fname) { - /* - * Unlink the file system entity before closing the file descriptor. - * Doing it the other way around introduces a race where our process - * unlinks a socket with the same name that's just been created by - * another thread or process. - */ - unlink(handle->pipe_fname); - uv__free((void*)handle->pipe_fname); - handle->pipe_fname = NULL; - } - - uv__stream_close((uv_stream_t*)handle); -} - - -int uv_pipe_open(uv_pipe_t* handle, uv_file fd) { - int err; - - err = uv__nonblock(fd, 1); - if (err) - return err; - -#if defined(__APPLE__) - err = uv__stream_try_select((uv_stream_t*) handle, &fd); - if (err) - return err; -#endif /* defined(__APPLE__) */ - - return uv__stream_open((uv_stream_t*)handle, - fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); -} - - -void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb) { - struct sockaddr_un saddr; - int new_sock; - int err; - int r; - - new_sock = (uv__stream_fd(handle) == -1); - - if (new_sock) { - err = uv__socket(AF_UNIX, SOCK_STREAM, 0); - if (err < 0) - goto out; - handle->io_watcher.fd = err; - } - - memset(&saddr, 0, sizeof saddr); - strncpy(saddr.sun_path, name, sizeof(saddr.sun_path) - 1); - saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0'; - saddr.sun_family = AF_UNIX; - - do { - r = connect(uv__stream_fd(handle), - (struct sockaddr*)&saddr, sizeof saddr); - } - while (r == -1 && errno == EINTR); - - if (r == -1 && errno != EINPROGRESS) { - err = -errno; -#if defined(__CYGWIN__) || defined(__MSYS__) - /* EBADF is supposed to mean that the socket fd is bad, but - Cygwin reports EBADF instead of ENOTSOCK when the file is - not a socket. We do not expect to see a bad fd here - (e.g. due to new_sock), so translate the error. */ - if (err == -EBADF) - err = -ENOTSOCK; -#endif - goto out; - } - - err = 0; - if (new_sock) { - err = uv__stream_open((uv_stream_t*)handle, - uv__stream_fd(handle), - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - } - - if (err == 0) - uv__io_start(handle->loop, &handle->io_watcher, POLLIN | POLLOUT); - -out: - handle->delayed_error = err; - handle->connect_req = req; - - uv__req_init(handle->loop, req, UV_CONNECT); - req->handle = (uv_stream_t*)handle; - req->cb = cb; - QUEUE_INIT(&req->queue); - - /* Force callback to run on next tick in case of error. */ - if (err) - uv__io_feed(handle->loop, &handle->io_watcher); - -} - - -typedef int (*uv__peersockfunc)(int, struct sockaddr*, socklen_t*); - - -static int uv__pipe_getsockpeername(const uv_pipe_t* handle, - uv__peersockfunc func, - char* buffer, - size_t* size) { - struct sockaddr_un sa; - socklen_t addrlen; - int err; - - addrlen = sizeof(sa); - memset(&sa, 0, addrlen); - err = func(uv__stream_fd(handle), (struct sockaddr*) &sa, &addrlen); - if (err < 0) { - *size = 0; - return -errno; - } - -#if defined(__linux__) - if (sa.sun_path[0] == 0) - /* Linux abstract namespace */ - addrlen -= offsetof(struct sockaddr_un, sun_path); - else -#endif - addrlen = strlen(sa.sun_path); - - - if (addrlen >= *size) { - *size = addrlen + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, sa.sun_path, addrlen); - *size = addrlen; - - /* only null-terminate if it's not an abstract socket */ - if (buffer[0] != '\0') - buffer[addrlen] = '\0'; - - return 0; -} - - -int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) { - return uv__pipe_getsockpeername(handle, getsockname, buffer, size); -} - - -int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) { - return uv__pipe_getsockpeername(handle, getpeername, buffer, size); -} - - -void uv_pipe_pending_instances(uv_pipe_t* handle, int count) { -} - - -int uv_pipe_pending_count(uv_pipe_t* handle) { - uv__stream_queued_fds_t* queued_fds; - - if (!handle->ipc) - return 0; - - if (handle->accepted_fd == -1) - return 0; - - if (handle->queued_fds == NULL) - return 1; - - queued_fds = handle->queued_fds; - return queued_fds->offset + 1; -} - - -uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) { - if (!handle->ipc) - return UV_UNKNOWN_HANDLE; - - if (handle->accepted_fd == -1) - return UV_UNKNOWN_HANDLE; - else - return uv__handle_type(handle->accepted_fd); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/poll.c b/lib/ESPiLight/pilight/libs/libuv/unix/poll.c deleted file mode 100644 index 2001fc8..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/poll.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include - - -static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - uv_poll_t* handle; - int pevents; - - handle = container_of(w, uv_poll_t, io_watcher); - - /* - * As documented in the kernel source fs/kernfs/file.c #780 - * poll will return POLLERR|POLLPRI in case of sysfs - * polling. This does not happen in case of out-of-band - * TCP messages. - * - * The above is the case on (at least) FreeBSD and Linux. - * - * So to properly determine a POLLPRI or a POLLERR we need - * to check for both. - */ - if ((events & POLLERR) && !(events & UV__POLLPRI)) { - uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI); - uv__handle_stop(handle); - handle->poll_cb(handle, -EBADF, 0); - return; - } - - pevents = 0; - if (events & POLLIN) - pevents |= UV_READABLE; - if (events & UV__POLLPRI) - pevents |= UV_PRIORITIZED; - if (events & POLLOUT) - pevents |= UV_WRITABLE; - if (events & UV__POLLRDHUP) - pevents |= UV_DISCONNECT; - - handle->poll_cb(handle, 0, pevents); -} - - -int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { - int err; - - err = uv__io_check_fd(loop, fd); - if (err) - return err; - - /* If ioctl(FIONBIO) reports ENOTTY, try fcntl(F_GETFL) + fcntl(F_SETFL). - * Workaround for e.g. kqueue fds not supporting ioctls. - */ - err = uv__nonblock(fd, 1); - if (err == -ENOTTY) - if (uv__nonblock == uv__nonblock_ioctl) - err = uv__nonblock_fcntl(fd, 1); - - if (err) - return err; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL); - uv__io_init(&handle->io_watcher, uv__poll_io, fd); - handle->poll_cb = NULL; - return 0; -} - - -int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, - uv_os_sock_t socket) { - return uv_poll_init(loop, handle, socket); -} - - -static void uv__poll_stop(uv_poll_t* handle) { - uv__io_stop(handle->loop, - &handle->io_watcher, - POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI); - uv__handle_stop(handle); -} - - -int uv_poll_stop(uv_poll_t* handle) { - assert(!uv__is_closing(handle)); - uv__poll_stop(handle); - return 0; -} - - -int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { - int events; - - assert((pevents & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT | - UV_PRIORITIZED)) == 0); - assert(!uv__is_closing(handle)); - - uv__poll_stop(handle); - - if (pevents == 0) - return 0; - - events = 0; - if (pevents & UV_READABLE) - events |= POLLIN; - if (pevents & UV_PRIORITIZED) - events |= UV__POLLPRI; - if (pevents & UV_WRITABLE) - events |= POLLOUT; - if (pevents & UV_DISCONNECT) - events |= UV__POLLRDHUP; - - uv__io_start(handle->loop, &handle->io_watcher, events); - uv__handle_start(handle); - handle->poll_cb = poll_cb; - - return 0; -} - - -void uv__poll_close(uv_poll_t* handle) { - uv__poll_stop(handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/posix-hrtime.c b/lib/ESPiLight/pilight/libs/libuv/unix/posix-hrtime.c deleted file mode 100644 index 323dfc2..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/posix-hrtime.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -#undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) - -uint64_t uv__hrtime(uv_clocktype_t type) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/posix-poll.c b/lib/ESPiLight/pilight/libs/libuv/unix/posix-poll.c deleted file mode 100644 index c80d43f..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/posix-poll.c +++ /dev/null @@ -1,357 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -/* POSIX defines poll() as a portable way to wait on file descriptors. - * Here we maintain a dynamically sized array of file descriptors and - * events to pass as the first argument to poll(). - */ - -#include -#include -#include -#include -#include - -int uv__platform_loop_init(uv_loop_t* loop) { - loop->poll_fds = NULL; - loop->poll_fds_used = 0; - loop->poll_fds_size = 0; - loop->poll_fds_iterating = 0; - return 0; -} - -void uv__platform_loop_delete(uv_loop_t* loop) { - uv__free(loop->poll_fds); - loop->poll_fds = NULL; -} - -int uv__io_fork(uv_loop_t* loop) { - uv__platform_loop_delete(loop); - return uv__platform_loop_init(loop); -} - -/* Allocate or dynamically resize our poll fds array. */ -static void uv__pollfds_maybe_resize(uv_loop_t* loop) { - size_t i; - size_t n; - struct pollfd* p; - - if (loop->poll_fds_used < loop->poll_fds_size) - return; - - n = loop->poll_fds_size ? loop->poll_fds_size * 2 : 64; - p = uv__realloc(loop->poll_fds, n * sizeof(*loop->poll_fds)); - if (p == NULL) - abort(); - - loop->poll_fds = p; - for (i = loop->poll_fds_size; i < n; i++) { - loop->poll_fds[i].fd = -1; - loop->poll_fds[i].events = 0; - loop->poll_fds[i].revents = 0; - } - loop->poll_fds_size = n; -} - -/* Primitive swap operation on poll fds array elements. */ -static void uv__pollfds_swap(uv_loop_t* loop, size_t l, size_t r) { - struct pollfd pfd; - pfd = loop->poll_fds[l]; - loop->poll_fds[l] = loop->poll_fds[r]; - loop->poll_fds[r] = pfd; -} - -/* Add a watcher's fd to our poll fds array with its pending events. */ -static void uv__pollfds_add(uv_loop_t* loop, uv__io_t* w) { - size_t i; - struct pollfd* pe; - - /* If the fd is already in the set just update its events. */ - assert(!loop->poll_fds_iterating); - for (i = 0; i < loop->poll_fds_used; ++i) { - if (loop->poll_fds[i].fd == w->fd) { - loop->poll_fds[i].events = w->pevents; - return; - } - } - - /* Otherwise, allocate a new slot in the set for the fd. */ - uv__pollfds_maybe_resize(loop); - pe = &loop->poll_fds[loop->poll_fds_used++]; - pe->fd = w->fd; - pe->events = w->pevents; -} - -/* Remove a watcher's fd from our poll fds array. */ -static void uv__pollfds_del(uv_loop_t* loop, int fd) { - size_t i; - assert(!loop->poll_fds_iterating); - for (i = 0; i < loop->poll_fds_used; ++i) { - if (loop->poll_fds[i].fd == fd) { - /* swap to last position and remove */ - --loop->poll_fds_used; - uv__pollfds_swap(loop, i, loop->poll_fds_used); - loop->poll_fds[loop->poll_fds_used].fd = -1; - loop->poll_fds[loop->poll_fds_used].events = 0; - loop->poll_fds[loop->poll_fds_used].revents = 0; - return; - } - } -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - sigset_t* pset; - sigset_t set; - uint64_t time_base; - uint64_t time_diff; - QUEUE* q; - uv__io_t* w; - size_t i; - unsigned int nevents; - int nfds; - int have_signals; - struct pollfd* pe; - int fd; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - /* Take queued watchers and add their fds to our poll fds array. */ - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - assert(w->fd >= 0); - assert(w->fd < (int) loop->nwatchers); - - uv__pollfds_add(loop, w); - - w->events = w->pevents; - } - - /* Prepare a set of signals to block around poll(), if any. */ - pset = NULL; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - pset = &set; - sigemptyset(pset); - sigaddset(pset, SIGPROF); - } - - assert(timeout >= -1); - time_base = loop->time; - - /* Loop calls to poll() and processing of results. If we get some - * results from poll() but they turn out not to be interesting to - * our caller then we need to loop around and poll() again. - */ - for (;;) { - if (pset != NULL) - if (pthread_sigmask(SIG_BLOCK, pset, NULL)) - abort(); - nfds = poll(loop->poll_fds, (nfds_t)loop->poll_fds_used, timeout); - if (pset != NULL) - if (pthread_sigmask(SIG_UNBLOCK, pset, NULL)) - abort(); - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - if (nfds == -1) { - if (errno != EINTR) - abort(); - - if (timeout == -1) - continue; - - if (timeout == 0) - return; - - /* Interrupted by a signal. Update timeout and poll again. */ - goto update_timeout; - } - - /* Tell uv__platform_invalidate_fd not to manipulate our array - * while we are iterating over it. - */ - loop->poll_fds_iterating = 1; - - /* Initialize a count of events that we care about. */ - nevents = 0; - have_signals = 0; - - /* Loop over the entire poll fds array looking for returned events. */ - for (i = 0; i < loop->poll_fds_used; i++) { - pe = loop->poll_fds + i; - fd = pe->fd; - - /* Skip invalidated events, see uv__platform_invalidate_fd. */ - if (fd == -1) - continue; - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - if (w == NULL) { - /* File descriptor that we've stopped watching, ignore. */ - uv__platform_invalidate_fd(loop, fd); - continue; - } - - /* Filter out events that user has not requested us to watch - * (e.g. POLLNVAL). - */ - pe->revents &= w->pevents | POLLERR | POLLHUP; - - if (pe->revents != 0) { - /* Run signal watchers last. */ - if (w == &loop->signal_io_watcher) { - have_signals = 1; - } else { - w->cb(loop, w, pe->revents); - } - - nevents++; - } - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->poll_fds_iterating = 0; - - /* Purge invalidated fds from our poll fds array. */ - uv__pollfds_del(loop, -1); - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) - return; - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - time_diff = loop->time - time_base; - if (time_diff >= (uint64_t) timeout) - return; - - timeout -= time_diff; - } -} - -/* Remove the given fd from our poll fds array because no one - * is interested in its events anymore. - */ -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - size_t i; - - if (loop->poll_fds_iterating) { - /* uv__io_poll is currently iterating. Just invalidate fd. */ - for (i = 0; i < loop->poll_fds_used; i++) - if (loop->poll_fds[i].fd == fd) { - loop->poll_fds[i].fd = -1; - loop->poll_fds[i].events = 0; - loop->poll_fds[i].revents = 0; - } - } else { - /* uv__io_poll is not iterating. Delete fd from the set. */ - uv__pollfds_del(loop, fd); - } -} - -/* Check whether the given fd is supported by poll(). */ -int uv__io_check_fd(uv_loop_t* loop, int fd) { - struct pollfd p[1]; - int rv; - - p[0].fd = fd; - p[0].events = POLLIN; - - do - rv = poll(p, 1, 0); - while (rv == -1 && (errno == EINTR || errno == EAGAIN)); - - if (rv == -1) - return -errno; - - if (p[0].revents & POLLNVAL) - return -EINVAL; - - return 0; -} - -/* - * NEW - */ -int uv_fs_event_stop(uv_fs_event_t* handle) { - if (!uv__is_active(handle)) - return 0; - - uv__handle_stop(handle); - -#if defined(__APPLE__) - if (uv__has_forked_with_cfrunloop || uv__fsevents_close(handle)) -#endif /* defined(__APPLE__) */ - { - uv__io_close(handle->loop, &handle->event_watcher); - } - - uv__free(handle->path); - handle->path = NULL; - - if (handle->event_watcher.fd != -1) { - /* When FSEvents is used, we don't use the event_watcher's fd under certain - * confitions. (see uv_fs_event_start) */ - uv__close(handle->event_watcher.fd); - handle->event_watcher.fd = -1; - } - - return 0; -} - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/process.c b/lib/ESPiLight/pilight/libs/libuv/unix/process.c deleted file mode 100644 index f2fe305..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/process.c +++ /dev/null @@ -1,563 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#if defined(__APPLE__) && !TARGET_OS_IPHONE -# include -# define environ (*_NSGetEnviron()) -#else -extern char **environ; -#endif - -#if defined(__linux__) || defined(__GLIBC__) -# include -#endif - - -static void uv__chld(uv_signal_t* handle, int signum) { - uv_process_t* process; - uv_loop_t* loop; - int exit_status; - int term_signal; - int status; - pid_t pid; - QUEUE pending; - QUEUE* q; - QUEUE* h; - - assert(signum == SIGCHLD); - - QUEUE_INIT(&pending); - loop = handle->loop; - - h = &loop->process_handles; - q = QUEUE_HEAD(h); - while (q != h) { - process = QUEUE_DATA(q, uv_process_t, queue); - q = QUEUE_NEXT(q); - - do - pid = waitpid(process->pid, &status, WNOHANG); - while (pid == -1 && errno == EINTR); - - if (pid == 0) - continue; - - if (pid == -1) { - if (errno != ECHILD) - abort(); - continue; - } - - process->status = status; - QUEUE_REMOVE(&process->queue); - QUEUE_INSERT_TAIL(&pending, &process->queue); - } - - h = &pending; - q = QUEUE_HEAD(h); - while (q != h) { - process = QUEUE_DATA(q, uv_process_t, queue); - q = QUEUE_NEXT(q); - - QUEUE_REMOVE(&process->queue); - QUEUE_INIT(&process->queue); - uv__handle_stop(process); - - if (process->exit_cb == NULL) - continue; - - exit_status = 0; - if (WIFEXITED(process->status)) - exit_status = WEXITSTATUS(process->status); - - term_signal = 0; - if (WIFSIGNALED(process->status)) - term_signal = WTERMSIG(process->status); - - process->exit_cb(process, exit_status, term_signal); - } - assert(QUEUE_EMPTY(&pending)); -} - - -int uv__make_socketpair(int fds[2], int flags) { -#if defined(__linux__) - static int no_cloexec; - - if (no_cloexec) - goto skip; - - if (socketpair(AF_UNIX, SOCK_STREAM | UV__SOCK_CLOEXEC | flags, 0, fds) == 0) - return 0; - - /* Retry on EINVAL, it means SOCK_CLOEXEC is not supported. - * Anything else is a genuine error. - */ - if (errno != EINVAL) - return -errno; - - no_cloexec = 1; - -skip: -#endif - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) - return -errno; - - uv__cloexec(fds[0], 1); - uv__cloexec(fds[1], 1); - - if (flags & UV__F_NONBLOCK) { - uv__nonblock(fds[0], 1); - uv__nonblock(fds[1], 1); - } - - return 0; -} - - -int uv__make_pipe(int fds[2], int flags) { -#if defined(__linux__) - static int no_pipe2; - - if (no_pipe2) - goto skip; - - if (uv__pipe2(fds, flags | UV__O_CLOEXEC) == 0) - return 0; - - if (errno != ENOSYS) - return -errno; - - no_pipe2 = 1; - -skip: -#endif - - if (pipe(fds)) - return -errno; - - uv__cloexec(fds[0], 1); - uv__cloexec(fds[1], 1); - - if (flags & UV__F_NONBLOCK) { - uv__nonblock(fds[0], 1); - uv__nonblock(fds[1], 1); - } - - return 0; -} - - -/* - * Used for initializing stdio streams like options.stdin_stream. Returns - * zero on success. See also the cleanup section in uv_spawn(). - */ -static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) { - int mask; - int fd; - - mask = UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD | UV_INHERIT_STREAM; - - switch (container->flags & mask) { - case UV_IGNORE: - return 0; - - case UV_CREATE_PIPE: - assert(container->data.stream != NULL); - if (container->data.stream->type != UV_NAMED_PIPE) - return -EINVAL; - else - return uv__make_socketpair(fds, 0); - - case UV_INHERIT_FD: - case UV_INHERIT_STREAM: - if (container->flags & UV_INHERIT_FD) - fd = container->data.fd; - else - fd = uv__stream_fd(container->data.stream); - - if (fd == -1) - return -EINVAL; - - fds[1] = fd; - return 0; - - default: - assert(0 && "Unexpected flags"); - return -EINVAL; - } -} - - -static int uv__process_open_stream(uv_stdio_container_t* container, - int pipefds[2], - int writable) { - int flags; - int err; - - if (!(container->flags & UV_CREATE_PIPE) || pipefds[0] < 0) - return 0; - - err = uv__close(pipefds[1]); - if (err != 0) - abort(); - - pipefds[1] = -1; - uv__nonblock(pipefds[0], 1); - - if (container->data.stream->type == UV_NAMED_PIPE && - ((uv_pipe_t*)container->data.stream)->ipc) - flags = UV_STREAM_READABLE | UV_STREAM_WRITABLE; - else if (writable) - flags = UV_STREAM_WRITABLE; - else - flags = UV_STREAM_READABLE; - - return uv__stream_open(container->data.stream, pipefds[0], flags); -} - - -static void uv__process_close_stream(uv_stdio_container_t* container) { - if (!(container->flags & UV_CREATE_PIPE)) return; - uv__stream_close((uv_stream_t*)container->data.stream); -} - - -static void uv__write_int(int fd, int val) { - ssize_t n; - - do - n = write(fd, &val, sizeof(val)); - while (n == -1 && errno == EINTR); - - if (n == -1 && errno == EPIPE) - return; /* parent process has quit */ - - assert(n == sizeof(val)); -} - - -#if !(defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH)) -/* execvp is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED, so must be - * avoided. Since this isn't called on those targets, the function - * doesn't even need to be defined for them. - */ -static void uv__process_child_init(const uv_process_options_t* options, - int stdio_count, - int (*pipes)[2], - int error_fd) { - int close_fd; - int use_fd; - int fd; - - if (options->flags & UV_PROCESS_DETACHED) - setsid(); - - /* First duplicate low numbered fds, since it's not safe to duplicate them, - * they could get replaced. Example: swapping stdout and stderr; without - * this fd 2 (stderr) would be duplicated into fd 1, thus making both - * stdout and stderr go to the same fd, which was not the intention. */ - for (fd = 0; fd < stdio_count; fd++) { - use_fd = pipes[fd][1]; - if (use_fd < 0 || use_fd >= fd) - continue; - pipes[fd][1] = fcntl(use_fd, F_DUPFD, stdio_count); - if (pipes[fd][1] == -1) { - uv__write_int(error_fd, -errno); - _exit(127); - } - } - - for (fd = 0; fd < stdio_count; fd++) { - close_fd = pipes[fd][0]; - use_fd = pipes[fd][1]; - - if (use_fd < 0) { - if (fd >= 3) - continue; - else { - /* redirect stdin, stdout and stderr to /dev/null even if UV_IGNORE is - * set - */ - use_fd = open("/dev/null", fd == 0 ? O_RDONLY : O_RDWR); - close_fd = use_fd; - - if (use_fd == -1) { - uv__write_int(error_fd, -errno); - _exit(127); - } - } - } - - if (fd == use_fd) - uv__cloexec_fcntl(use_fd, 0); - else - fd = dup2(use_fd, fd); - - if (fd == -1) { - uv__write_int(error_fd, -errno); - _exit(127); - } - - if (fd <= 2) - uv__nonblock_fcntl(fd, 0); - - if (close_fd >= stdio_count) - uv__close(close_fd); - } - - for (fd = 0; fd < stdio_count; fd++) { - use_fd = pipes[fd][1]; - - if (use_fd >= stdio_count) - uv__close(use_fd); - } - - if (options->cwd != NULL && chdir(options->cwd)) { - uv__write_int(error_fd, -errno); - _exit(127); - } - - if (options->flags & (UV_PROCESS_SETUID | UV_PROCESS_SETGID)) { - /* When dropping privileges from root, the `setgroups` call will - * remove any extraneous groups. If we don't call this, then - * even though our uid has dropped, we may still have groups - * that enable us to do super-user things. This will fail if we - * aren't root, so don't bother checking the return value, this - * is just done as an optimistic privilege dropping function. - */ - SAVE_ERRNO(setgroups(0, NULL)); - } - - if ((options->flags & UV_PROCESS_SETGID) && setgid(options->gid)) { - uv__write_int(error_fd, -errno); - _exit(127); - } - - if ((options->flags & UV_PROCESS_SETUID) && setuid(options->uid)) { - uv__write_int(error_fd, -errno); - _exit(127); - } - - if (options->env != NULL) { - environ = options->env; - } - - execvp(options->file, options->args); - uv__write_int(error_fd, -errno); - _exit(127); -} -#endif - - -int uv_spawn(uv_loop_t* loop, - uv_process_t* process, - const uv_process_options_t* options) { -#if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) - /* fork is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED. */ - return -ENOSYS; -#else - int signal_pipe[2] = { -1, -1 }; - int (*pipes)[2]; - int stdio_count; - ssize_t r; - pid_t pid; - int err; - int exec_errorno; - int i; - int status; - - assert(options->file != NULL); - assert(!(options->flags & ~(UV_PROCESS_DETACHED | - UV_PROCESS_SETGID | - UV_PROCESS_SETUID | - UV_PROCESS_WINDOWS_HIDE | - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS))); - - uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS); - QUEUE_INIT(&process->queue); - - stdio_count = options->stdio_count; - if (stdio_count < 3) - stdio_count = 3; - - err = -ENOMEM; - pipes = uv__malloc(stdio_count * sizeof(*pipes)); - if (pipes == NULL) - goto error; - - for (i = 0; i < stdio_count; i++) { - pipes[i][0] = -1; - pipes[i][1] = -1; - } - - for (i = 0; i < options->stdio_count; i++) { - err = uv__process_init_stdio(options->stdio + i, pipes[i]); - if (err) - goto error; - } - - /* This pipe is used by the parent to wait until - * the child has called `execve()`. We need this - * to avoid the following race condition: - * - * if ((pid = fork()) > 0) { - * kill(pid, SIGTERM); - * } - * else if (pid == 0) { - * execve("/bin/cat", argp, envp); - * } - * - * The parent sends a signal immediately after forking. - * Since the child may not have called `execve()` yet, - * there is no telling what process receives the signal, - * our fork or /bin/cat. - * - * To avoid ambiguity, we create a pipe with both ends - * marked close-on-exec. Then, after the call to `fork()`, - * the parent polls the read end until it EOFs or errors with EPIPE. - */ - err = uv__make_pipe(signal_pipe, 0); - if (err) - goto error; - - uv_signal_start(&loop->child_watcher, uv__chld, SIGCHLD); - - /* Acquire write lock to prevent opening new fds in worker threads */ - uv_rwlock_wrlock(&loop->cloexec_lock); - pid = fork(); - - if (pid == -1) { - err = -errno; - uv_rwlock_wrunlock(&loop->cloexec_lock); - uv__close(signal_pipe[0]); - uv__close(signal_pipe[1]); - goto error; - } - - if (pid == 0) { - uv__process_child_init(options, stdio_count, pipes, signal_pipe[1]); - abort(); - } - - /* Release lock in parent process */ - uv_rwlock_wrunlock(&loop->cloexec_lock); - uv__close(signal_pipe[1]); - - process->status = 0; - exec_errorno = 0; - do - r = read(signal_pipe[0], &exec_errorno, sizeof(exec_errorno)); - while (r == -1 && errno == EINTR); - - if (r == 0) - ; /* okay, EOF */ - else if (r == sizeof(exec_errorno)) { - do - err = waitpid(pid, &status, 0); /* okay, read errorno */ - while (err == -1 && errno == EINTR); - assert(err == pid); - } else if (r == -1 && errno == EPIPE) { - do - err = waitpid(pid, &status, 0); /* okay, got EPIPE */ - while (err == -1 && errno == EINTR); - assert(err == pid); - } else - abort(); - - uv__close_nocheckstdio(signal_pipe[0]); - - for (i = 0; i < options->stdio_count; i++) { - err = uv__process_open_stream(options->stdio + i, pipes[i], i == 0); - if (err == 0) - continue; - - while (i--) - uv__process_close_stream(options->stdio + i); - - goto error; - } - - /* Only activate this handle if exec() happened successfully */ - if (exec_errorno == 0) { - QUEUE_INSERT_TAIL(&loop->process_handles, &process->queue); - uv__handle_start(process); - } - - process->pid = pid; - process->exit_cb = options->exit_cb; - - uv__free(pipes); - return exec_errorno; - -error: - if (pipes != NULL) { - for (i = 0; i < stdio_count; i++) { - if (i < options->stdio_count) - if (options->stdio[i].flags & (UV_INHERIT_FD | UV_INHERIT_STREAM)) - continue; - if (pipes[i][0] != -1) - uv__close_nocheckstdio(pipes[i][0]); - if (pipes[i][1] != -1) - uv__close_nocheckstdio(pipes[i][1]); - } - uv__free(pipes); - } - - return err; -#endif -} - - -int uv_process_kill(uv_process_t* process, int signum) { - return uv_kill(process->pid, signum); -} - - -int uv_kill(int pid, int signum) { - if (kill(pid, signum)) - return -errno; - else - return 0; -} - - -void uv__process_close(uv_process_t* handle) { - QUEUE_REMOVE(&handle->queue); - uv__handle_stop(handle); - if (QUEUE_EMPTY(&handle->loop->process_handles)) - uv_signal_stop(&handle->loop->child_watcher); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/procfs-exepath.c b/lib/ESPiLight/pilight/libs/libuv/unix/procfs-exepath.c deleted file mode 100644 index 5fdb611..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/procfs-exepath.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -int uv_exepath(char* buffer, size_t* size) { - ssize_t n; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - n = *size - 1; - if (n > 0) - n = readlink("/proc/self/exe", buffer, n); - - if (n == -1) - return -errno; - - buffer[n] = '\0'; - *size = n; - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/proctitle.c b/lib/ESPiLight/pilight/libs/libuv/unix/proctitle.c deleted file mode 100644 index 2ed0b21..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/proctitle.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -extern void uv__set_process_title(const char* title); - -static void* args_mem; - -static struct { - char* str; - size_t len; -} process_title; - - -char** uv_setup_args(int argc, char** argv) { - char** new_argv; - size_t size; - char* s; - int i; - - if (argc <= 0) - return argv; - - /* Calculate how much memory we need for the argv strings. */ - size = 0; - for (i = 0; i < argc; i++) - size += strlen(argv[i]) + 1; - -#if defined(__MVS__) - /* argv is not adjacent. So just use argv[0] */ - process_title.str = argv[0]; - process_title.len = strlen(argv[0]); -#else - process_title.str = argv[0]; - process_title.len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[0]; - assert(process_title.len + 1 == size); /* argv memory should be adjacent. */ -#endif - - /* Add space for the argv pointers. */ - size += (argc + 1) * sizeof(char*); - - new_argv = uv__malloc(size); - if (new_argv == NULL) - return argv; - args_mem = new_argv; - - /* Copy over the strings and set up the pointer table. */ - s = (char*) &new_argv[argc + 1]; - for (i = 0; i < argc; i++) { - size = strlen(argv[i]) + 1; - memcpy(s, argv[i], size); - new_argv[i] = s; - s += size; - } - new_argv[i] = NULL; - - return new_argv; -} - - -int uv_set_process_title(const char* title) { - if (process_title.len == 0) - return 0; - - /* No need to terminate, byte after is always '\0'. */ - strncpy(process_title.str, title, process_title.len); - uv__set_process_title(title); - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - if (buffer == NULL || size == 0) - return -EINVAL; - else if (size <= process_title.len) - return -ENOBUFS; - - if (process_title.len != 0) - memcpy(buffer, process_title.str, process_title.len + 1); - - buffer[process_title.len] = '\0'; - - return 0; -} - - -UV_DESTRUCTOR(static void free_args_mem(void)) { - uv__free(args_mem); /* Keep valgrind happy. */ - args_mem = NULL; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/pthread-barrier.c b/lib/ESPiLight/pilight/libs/libuv/unix/pthread-barrier.c deleted file mode 100644 index b6e604d..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/pthread-barrier.c +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright (c) 2016, Kari Tristan Helgason - -Permission to use, copy, modify, and/or 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 THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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 "uv-common.h" -#include "pthread-barrier.h" - -#include -#include - -/* TODO: support barrier_attr */ -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count) { - int rc; - _uv_barrier* b; - - if (barrier == NULL || count == 0) - return EINVAL; - - if (barrier_attr != NULL) - return ENOTSUP; - - b = uv__malloc(sizeof(*b)); - if (b == NULL) - return ENOMEM; - - b->in = 0; - b->out = 0; - b->threshold = count; - - if ((rc = pthread_mutex_init(&b->mutex, NULL)) != 0) - goto error2; - if ((rc = pthread_cond_init(&b->cond, NULL)) != 0) - goto error; - - barrier->b = b; - return 0; - -error: - pthread_mutex_destroy(&b->mutex); -error2: - uv__free(b); - return rc; -} - -int pthread_barrier_wait(pthread_barrier_t* barrier) { - int rc; - _uv_barrier* b; - - if (barrier == NULL || barrier->b == NULL) - return EINVAL; - - b = barrier->b; - /* Lock the mutex*/ - if ((rc = pthread_mutex_lock(&b->mutex)) != 0) - return rc; - - /* Increment the count. If this is the first thread to reach the threshold, - wake up waiters, unlock the mutex, then return - PTHREAD_BARRIER_SERIAL_THREAD. */ - if (++b->in == b->threshold) { - b->in = 0; - b->out = b->threshold - 1; - rc = pthread_cond_signal(&b->cond); - assert(rc == 0); - - pthread_mutex_unlock(&b->mutex); - return PTHREAD_BARRIER_SERIAL_THREAD; - } - /* Otherwise, wait for other threads until in is set to 0, - then return 0 to indicate this is not the first thread. */ - do { - if ((rc = pthread_cond_wait(&b->cond, &b->mutex)) != 0) - break; - } while (b->in != 0); - - /* mark thread exit */ - b->out--; - pthread_cond_signal(&b->cond); - pthread_mutex_unlock(&b->mutex); - return rc; -} - -int pthread_barrier_destroy(pthread_barrier_t* barrier) { - int rc; - _uv_barrier* b; - - if (barrier == NULL || barrier->b == NULL) - return EINVAL; - - b = barrier->b; - - if ((rc = pthread_mutex_lock(&b->mutex)) != 0) - return rc; - - if (b->in > 0 || b->out > 0) - rc = EBUSY; - - pthread_mutex_unlock(&b->mutex); - - if (rc) - return rc; - - pthread_cond_destroy(&b->cond); - pthread_mutex_destroy(&b->mutex); - uv__free(barrier->b); - barrier->b = NULL; - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/pthread-fixes.c b/lib/ESPiLight/pilight/libs/libuv/unix/pthread-fixes.c deleted file mode 100644 index fb17995..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/pthread-fixes.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2013, Sony Mobile Communications AB - * Copyright (c) 2012, Google Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Android versions < 4.1 have a broken pthread_sigmask. */ -#include -#include -#include - -int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset) { - static int workaround; - int err; - - if (workaround) { - return sigprocmask(how, set, oset); - } else { - err = pthread_sigmask(how, set, oset); - if (err) { - if (err == EINVAL && sigprocmask(how, set, oset) == 0) { - workaround = 1; - return 0; - } else { - return -1; - } - } - } - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/signal.c b/lib/ESPiLight/pilight/libs/libuv/unix/signal.c deleted file mode 100644 index cb09ead..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/signal.c +++ /dev/null @@ -1,559 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - - -typedef struct { - uv_signal_t* handle; - int signum; -} uv__signal_msg_t; - -RB_HEAD(uv__signal_tree_s, uv_signal_s); - - -static int uv__signal_unlock(void); -static int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot); -static void uv__signal_event(uv_loop_t* loop, uv__io_t* w, unsigned int events); -static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2); -static void uv__signal_stop(uv_signal_t* handle); -static void uv__signal_unregister_handler(int signum); - - -static uv_once_t uv__signal_global_init_guard = UV_ONCE_INIT; -static struct uv__signal_tree_s uv__signal_tree = - RB_INITIALIZER(uv__signal_tree); -static int uv__signal_lock_pipefd[2]; - - -RB_GENERATE_STATIC(uv__signal_tree_s, - uv_signal_s, tree_entry, - uv__signal_compare) - -static void uv__signal_global_reinit(void); - -static void uv__signal_global_init(void) { - if (!uv__signal_lock_pipefd[0]) - /* pthread_atfork can register before and after handlers, one - * for each child. This only registers one for the child. That - * state is both persistent and cumulative, so if we keep doing - * it the handler functions will be called multiple times. Thus - * we only want to do it once. - */ - if (pthread_atfork(NULL, NULL, &uv__signal_global_reinit)) - abort(); - - if (uv__make_pipe(uv__signal_lock_pipefd, 0)) - abort(); - - if (uv__signal_unlock()) - abort(); -} - - -static void uv__signal_global_reinit(void) { - /* We can only use signal-safe functions here. - * That includes read/write and close, fortunately. - * We do all of this directly here instead of resetting - * uv__signal_global_init_guard because - * uv__signal_global_once_init is only called from uv_loop_init - * and this needs to function in existing loops. - */ - uv__close(uv__signal_lock_pipefd[0]); - uv__signal_lock_pipefd[0] = -1; - uv__close(uv__signal_lock_pipefd[1]); - uv__signal_lock_pipefd[1] = -1; - uv__signal_global_init(); -} - - -void uv__signal_global_once_init(void) { - uv_once(&uv__signal_global_init_guard, uv__signal_global_init); -} - - - -static int uv__signal_lock(void) { - int r; - char data; - - do { - r = read(uv__signal_lock_pipefd[0], &data, sizeof data); - } while (r < 0 && errno == EINTR); - - return (r < 0) ? -1 : 0; -} - - -static int uv__signal_unlock(void) { - int r; - char data = 42; - - do { - r = write(uv__signal_lock_pipefd[1], &data, sizeof data); - } while (r < 0 && errno == EINTR); - - return (r < 0) ? -1 : 0; -} - - -static void uv__signal_block_and_lock(sigset_t* saved_sigmask) { - sigset_t new_mask; - - if (sigfillset(&new_mask)) - abort(); - - if (pthread_sigmask(SIG_SETMASK, &new_mask, saved_sigmask)) - abort(); - - if (uv__signal_lock()) - abort(); -} - - -static void uv__signal_unlock_and_unblock(sigset_t* saved_sigmask) { - if (uv__signal_unlock()) - abort(); - - if (pthread_sigmask(SIG_SETMASK, saved_sigmask, NULL)) - abort(); -} - - -static uv_signal_t* uv__signal_first_handle(int signum) { - /* This function must be called with the signal lock held. */ - uv_signal_t lookup; - uv_signal_t* handle; - - lookup.signum = signum; - lookup.flags = 0; - lookup.loop = NULL; - - handle = RB_NFIND(uv__signal_tree_s, &uv__signal_tree, &lookup); - - if (handle != NULL && handle->signum == signum) - return handle; - - return NULL; -} - - -static void uv__signal_handler(int signum) { - uv__signal_msg_t msg; - uv_signal_t* handle; - int saved_errno; - - saved_errno = errno; - memset(&msg, 0, sizeof msg); - - if (uv__signal_lock()) { - errno = saved_errno; - return; - } - - for (handle = uv__signal_first_handle(signum); - handle != NULL && handle->signum == signum; - handle = RB_NEXT(uv__signal_tree_s, &uv__signal_tree, handle)) { - int r; - - msg.signum = signum; - msg.handle = handle; - - /* write() should be atomic for small data chunks, so the entire message - * should be written at once. In theory the pipe could become full, in - * which case the user is out of luck. - */ - do { - r = write(handle->loop->signal_pipefd[1], &msg, sizeof msg); - } while (r == -1 && errno == EINTR); - - assert(r == sizeof msg || - (r == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))); - - if (r != -1) - handle->caught_signals++; - } - - uv__signal_unlock(); - errno = saved_errno; -} - - -static int uv__signal_register_handler(int signum, int oneshot) { - /* When this function is called, the signal lock must be held. */ - struct sigaction sa; - - /* XXX use a separate signal stack? */ - memset(&sa, 0, sizeof(sa)); - if (sigfillset(&sa.sa_mask)) - abort(); - sa.sa_handler = uv__signal_handler; - sa.sa_flags = oneshot ? SA_RESETHAND : 0; - - /* XXX save old action so we can restore it later on? */ - if (sigaction(signum, &sa, NULL)) - return -errno; - - return 0; -} - - -static void uv__signal_unregister_handler(int signum) { - /* When this function is called, the signal lock must be held. */ - struct sigaction sa; - - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = SIG_DFL; - - /* sigaction can only fail with EINVAL or EFAULT; an attempt to deregister a - * signal implies that it was successfully registered earlier, so EINVAL - * should never happen. - */ - if (sigaction(signum, &sa, NULL)) - abort(); -} - - -static int uv__signal_loop_once_init(uv_loop_t* loop) { - int err; - - /* Return if already initialized. */ - if (loop->signal_pipefd[0] != -1) - return 0; - - err = uv__make_pipe(loop->signal_pipefd, UV__F_NONBLOCK); - if (err) - return err; - - uv__io_init(&loop->signal_io_watcher, - uv__signal_event, - loop->signal_pipefd[0]); - uv__io_start(loop, &loop->signal_io_watcher, POLLIN); - - return 0; -} - - -int uv__signal_loop_fork(uv_loop_t* loop) { - uv__io_stop(loop, &loop->signal_io_watcher, POLLIN); - uv__close(loop->signal_pipefd[0]); - uv__close(loop->signal_pipefd[1]); - loop->signal_pipefd[0] = -1; - loop->signal_pipefd[1] = -1; - return uv__signal_loop_once_init(loop); -} - - -void uv__signal_loop_cleanup(uv_loop_t* loop) { - QUEUE* q; - - /* Stop all the signal watchers that are still attached to this loop. This - * ensures that the (shared) signal tree doesn't contain any invalid entries - * entries, and that signal handlers are removed when appropriate. - * It's safe to use QUEUE_FOREACH here because the handles and the handle - * queue are not modified by uv__signal_stop(). - */ - QUEUE_FOREACH(q, &loop->handle_queue) { - uv_handle_t* handle = QUEUE_DATA(q, uv_handle_t, handle_queue); - - if (handle->type == UV_SIGNAL) - uv__signal_stop((uv_signal_t*) handle); - } - - if (loop->signal_pipefd[0] != -1) { - uv__close(loop->signal_pipefd[0]); - loop->signal_pipefd[0] = -1; - } - - if (loop->signal_pipefd[1] != -1) { - uv__close(loop->signal_pipefd[1]); - loop->signal_pipefd[1] = -1; - } -} - - -int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle) { - int err; - - err = uv__signal_loop_once_init(loop); - if (err) - return err; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_SIGNAL); - handle->signum = 0; - handle->caught_signals = 0; - handle->dispatched_signals = 0; - - return 0; -} - - -void uv__signal_close(uv_signal_t* handle) { - - uv__signal_stop(handle); - - /* If there are any caught signals "trapped" in the signal pipe, we can't - * call the close callback yet. Otherwise, add the handle to the finish_close - * queue. - */ - if (handle->caught_signals == handle->dispatched_signals) { - uv__make_close_pending((uv_handle_t*) handle); - } -} - - -int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum) { - return uv__signal_start(handle, signal_cb, signum, 0); -} - - -int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum) { - return uv__signal_start(handle, signal_cb, signum, 1); -} - - -static int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot) { - sigset_t saved_sigmask; - int err; - uv_signal_t* first_handle; - - assert(!uv__is_closing(handle)); - - /* If the user supplies signum == 0, then return an error already. If the - * signum is otherwise invalid then uv__signal_register will find out - * eventually. - */ - if (signum == 0) - return -EINVAL; - - /* Short circuit: if the signal watcher is already watching {signum} don't - * go through the process of deregistering and registering the handler. - * Additionally, this avoids pending signals getting lost in the small time - * time frame that handle->signum == 0. - */ - if (signum == handle->signum) { - handle->signal_cb = signal_cb; - return 0; - } - - /* If the signal handler was already active, stop it first. */ - if (handle->signum != 0) { - uv__signal_stop(handle); - } - - uv__signal_block_and_lock(&saved_sigmask); - - /* If at this point there are no active signal watchers for this signum (in - * any of the loops), it's time to try and register a handler for it here. - * Also in case there's only one-shot handlers and a regular handler comes in. - */ - first_handle = uv__signal_first_handle(signum); - if (first_handle == NULL || - (!oneshot && (first_handle->flags & UV__SIGNAL_ONE_SHOT))) { - err = uv__signal_register_handler(signum, oneshot); - if (err) { - /* Registering the signal handler failed. Must be an invalid signal. */ - uv__signal_unlock_and_unblock(&saved_sigmask); - return err; - } - } - - handle->signum = signum; - if (oneshot) - handle->flags |= UV__SIGNAL_ONE_SHOT; - - RB_INSERT(uv__signal_tree_s, &uv__signal_tree, handle); - - uv__signal_unlock_and_unblock(&saved_sigmask); - - handle->signal_cb = signal_cb; - uv__handle_start(handle); - - return 0; -} - - -static void uv__signal_event(uv_loop_t* loop, - uv__io_t* w, - unsigned int events) { - uv__signal_msg_t* msg; - uv_signal_t* handle; - char buf[sizeof(uv__signal_msg_t) * 32]; - size_t bytes, end, i; - int r; - - bytes = 0; - end = 0; - - do { - r = read(loop->signal_pipefd[0], buf + bytes, sizeof(buf) - bytes); - - if (r == -1 && errno == EINTR) - continue; - - if (r == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { - /* If there are bytes in the buffer already (which really is extremely - * unlikely if possible at all) we can't exit the function here. We'll - * spin until more bytes are read instead. - */ - if (bytes > 0) - continue; - - /* Otherwise, there was nothing there. */ - return; - } - - /* Other errors really should never happen. */ - if (r == -1) - abort(); - - bytes += r; - - /* `end` is rounded down to a multiple of sizeof(uv__signal_msg_t). */ - end = (bytes / sizeof(uv__signal_msg_t)) * sizeof(uv__signal_msg_t); - - for (i = 0; i < end; i += sizeof(uv__signal_msg_t)) { - msg = (uv__signal_msg_t*) (buf + i); - handle = msg->handle; - - if (msg->signum == handle->signum) { - assert(!(handle->flags & UV_CLOSING)); - handle->signal_cb(handle, handle->signum); - } - - handle->dispatched_signals++; - - if (handle->flags & UV__SIGNAL_ONE_SHOT) - uv__signal_stop(handle); - - /* If uv_close was called while there were caught signals that were not - * yet dispatched, the uv__finish_close was deferred. Make close pending - * now if this has happened. - */ - if ((handle->flags & UV_CLOSING) && - (handle->caught_signals == handle->dispatched_signals)) { - uv__make_close_pending((uv_handle_t*) handle); - } - } - - bytes -= end; - - /* If there are any "partial" messages left, move them to the start of the - * the buffer, and spin. This should not happen. - */ - if (bytes) { - memmove(buf, buf + end, bytes); - continue; - } - } while (end == sizeof buf); -} - - -static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { - int f1; - int f2; - /* Compare signums first so all watchers with the same signnum end up - * adjacent. - */ - if (w1->signum < w2->signum) return -1; - if (w1->signum > w2->signum) return 1; - - /* Handlers without UV__SIGNAL_ONE_SHOT set will come first, so if the first - * handler returned is a one-shot handler, the rest will be too. - */ - f1 = w1->flags & UV__SIGNAL_ONE_SHOT; - f2 = w2->flags & UV__SIGNAL_ONE_SHOT; - if (f1 < f2) return -1; - if (f1 > f2) return 1; - - /* Sort by loop pointer, so we can easily look up the first item after - * { .signum = x, .loop = NULL }. - */ - if (w1->loop < w2->loop) return -1; - if (w1->loop > w2->loop) return 1; - - if (w1 < w2) return -1; - if (w1 > w2) return 1; - - return 0; -} - - -int uv_signal_stop(uv_signal_t* handle) { - assert(!uv__is_closing(handle)); - uv__signal_stop(handle); - return 0; -} - - -static void uv__signal_stop(uv_signal_t* handle) { - uv_signal_t* removed_handle; - sigset_t saved_sigmask; - uv_signal_t* first_handle; - int rem_oneshot; - int first_oneshot; - int ret; - - /* If the watcher wasn't started, this is a no-op. */ - if (handle->signum == 0) - return; - - uv__signal_block_and_lock(&saved_sigmask); - - removed_handle = RB_REMOVE(uv__signal_tree_s, &uv__signal_tree, handle); - assert(removed_handle == handle); - (void) removed_handle; - - /* Check if there are other active signal watchers observing this signal. If - * not, unregister the signal handler. - */ - first_handle = uv__signal_first_handle(handle->signum); - if (first_handle == NULL) { - uv__signal_unregister_handler(handle->signum); - } else { - rem_oneshot = handle->flags & UV__SIGNAL_ONE_SHOT; - first_oneshot = first_handle->flags & UV__SIGNAL_ONE_SHOT; - if (first_oneshot && !rem_oneshot) { - ret = uv__signal_register_handler(handle->signum, 1); - assert(ret == 0); - } - } - - uv__signal_unlock_and_unblock(&saved_sigmask); - - handle->signum = 0; - uv__handle_stop(handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/spinlock.h b/lib/ESPiLight/pilight/libs/libuv/unix/spinlock.h deleted file mode 100644 index a20c83c..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/spinlock.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2013, Ben Noordhuis - * - * Permission to use, copy, modify, and/or 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 THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. - */ - -#ifndef UV_SPINLOCK_H_ -#define UV_SPINLOCK_H_ - -#include "internal.h" /* ACCESS_ONCE, UV_UNUSED */ -#include "atomic-ops.h" - -#define UV_SPINLOCK_INITIALIZER { 0 } - -typedef struct { - int lock; -} uv_spinlock_t; - -UV_UNUSED(static void uv_spinlock_init(uv_spinlock_t* spinlock)); -UV_UNUSED(static void uv_spinlock_lock(uv_spinlock_t* spinlock)); -UV_UNUSED(static void uv_spinlock_unlock(uv_spinlock_t* spinlock)); -UV_UNUSED(static int uv_spinlock_trylock(uv_spinlock_t* spinlock)); - -UV_UNUSED(static void uv_spinlock_init(uv_spinlock_t* spinlock)) { - ACCESS_ONCE(int, spinlock->lock) = 0; -} - -UV_UNUSED(static void uv_spinlock_lock(uv_spinlock_t* spinlock)) { - while (!uv_spinlock_trylock(spinlock)) cpu_relax(); -} - -UV_UNUSED(static void uv_spinlock_unlock(uv_spinlock_t* spinlock)) { - ACCESS_ONCE(int, spinlock->lock) = 0; -} - -UV_UNUSED(static int uv_spinlock_trylock(uv_spinlock_t* spinlock)) { - /* TODO(bnoordhuis) Maybe change to a ticket lock to guarantee fair queueing. - * Not really critical until we have locks that are (frequently) contended - * for by several threads. - */ - return 0 == cmpxchgi(&spinlock->lock, 0, 1); -} - -#endif /* UV_SPINLOCK_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/stream.c b/lib/ESPiLight/pilight/libs/libuv/unix/stream.c deleted file mode 100644 index 657e018..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/stream.c +++ /dev/null @@ -1,1689 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include /* IOV_MAX */ - -#if defined(__APPLE__) -# include -# include -# include - -/* Forward declaration */ -typedef struct uv__stream_select_s uv__stream_select_t; - -struct uv__stream_select_s { - uv_stream_t* stream; - uv_thread_t thread; - uv_sem_t close_sem; - uv_sem_t async_sem; - uv_async_t async; - int events; - int fake_fd; - int int_fd; - int fd; - fd_set* sread; - size_t sread_sz; - fd_set* swrite; - size_t swrite_sz; -}; -#endif /* defined(__APPLE__) */ - -static void uv__stream_connect(uv_stream_t*); -static void uv__write(uv_stream_t* stream); -static void uv__read(uv_stream_t* stream); -static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events); -static void uv__write_callbacks(uv_stream_t* stream); -static size_t uv__write_req_size(uv_write_t* req); - - -void uv__stream_init(uv_loop_t* loop, - uv_stream_t* stream, - uv_handle_type type) { - int err; - - uv__handle_init(loop, (uv_handle_t*)stream, type); - stream->read_cb = NULL; - stream->alloc_cb = NULL; - stream->close_cb = NULL; - stream->connection_cb = NULL; - stream->connect_req = NULL; - stream->shutdown_req = NULL; - stream->accepted_fd = -1; - stream->queued_fds = NULL; - stream->delayed_error = 0; - QUEUE_INIT(&stream->write_queue); - QUEUE_INIT(&stream->write_completed_queue); - stream->write_queue_size = 0; - - if (loop->emfile_fd == -1) { - err = uv__open_cloexec("/dev/null", O_RDONLY); - if (err < 0) - /* In the rare case that "/dev/null" isn't mounted open "/" - * instead. - */ - err = uv__open_cloexec("/", O_RDONLY); - if (err >= 0) - loop->emfile_fd = err; - } - -#if defined(__APPLE__) - stream->select = NULL; -#endif /* defined(__APPLE_) */ - - uv__io_init(&stream->io_watcher, uv__stream_io, -1); -} - - -static void uv__stream_osx_interrupt_select(uv_stream_t* stream) { -#if defined(__APPLE__) - /* Notify select() thread about state change */ - uv__stream_select_t* s; - int r; - - s = stream->select; - if (s == NULL) - return; - - /* Interrupt select() loop - * NOTE: fake_fd and int_fd are socketpair(), thus writing to one will - * emit read event on other side - */ - do - r = write(s->fake_fd, "x", 1); - while (r == -1 && errno == EINTR); - - assert(r == 1); -#else /* !defined(__APPLE__) */ - /* No-op on any other platform */ -#endif /* !defined(__APPLE__) */ -} - - -#if defined(__APPLE__) -static void uv__stream_osx_select(void* arg) { - uv_stream_t* stream; - uv__stream_select_t* s; - char buf[1024]; - int events; - int fd; - int r; - int max_fd; - - stream = arg; - s = stream->select; - fd = s->fd; - - if (fd > s->int_fd) - max_fd = fd; - else - max_fd = s->int_fd; - - while (1) { - /* Terminate on semaphore */ - if (uv_sem_trywait(&s->close_sem) == 0) - break; - - /* Watch fd using select(2) */ - memset(s->sread, 0, s->sread_sz); - memset(s->swrite, 0, s->swrite_sz); - - if (uv__io_active(&stream->io_watcher, POLLIN)) - FD_SET(fd, s->sread); - if (uv__io_active(&stream->io_watcher, POLLOUT)) - FD_SET(fd, s->swrite); - FD_SET(s->int_fd, s->sread); - - /* Wait indefinitely for fd events */ - r = select(max_fd + 1, s->sread, s->swrite, NULL, NULL); - if (r == -1) { - if (errno == EINTR) - continue; - - /* XXX: Possible?! */ - abort(); - } - - /* Ignore timeouts */ - if (r == 0) - continue; - - /* Empty socketpair's buffer in case of interruption */ - if (FD_ISSET(s->int_fd, s->sread)) - while (1) { - r = read(s->int_fd, buf, sizeof(buf)); - - if (r == sizeof(buf)) - continue; - - if (r != -1) - break; - - if (errno == EAGAIN || errno == EWOULDBLOCK) - break; - - if (errno == EINTR) - continue; - - abort(); - } - - /* Handle events */ - events = 0; - if (FD_ISSET(fd, s->sread)) - events |= POLLIN; - if (FD_ISSET(fd, s->swrite)) - events |= POLLOUT; - - assert(events != 0 || FD_ISSET(s->int_fd, s->sread)); - if (events != 0) { - ACCESS_ONCE(int, s->events) = events; - - uv_async_send(&s->async); - uv_sem_wait(&s->async_sem); - - /* Should be processed at this stage */ - assert((s->events == 0) || (stream->flags & UV_CLOSING)); - } - } -} - - -static void uv__stream_osx_select_cb(uv_async_t* handle) { - uv__stream_select_t* s; - uv_stream_t* stream; - int events; - - s = container_of(handle, uv__stream_select_t, async); - stream = s->stream; - - /* Get and reset stream's events */ - events = s->events; - ACCESS_ONCE(int, s->events) = 0; - - assert(events != 0); - assert(events == (events & (POLLIN | POLLOUT))); - - /* Invoke callback on event-loop */ - if ((events & POLLIN) && uv__io_active(&stream->io_watcher, POLLIN)) - uv__stream_io(stream->loop, &stream->io_watcher, POLLIN); - - if ((events & POLLOUT) && uv__io_active(&stream->io_watcher, POLLOUT)) - uv__stream_io(stream->loop, &stream->io_watcher, POLLOUT); - - if (stream->flags & UV_CLOSING) - return; - - /* NOTE: It is important to do it here, otherwise `select()` might be called - * before the actual `uv__read()`, leading to the blocking syscall - */ - uv_sem_post(&s->async_sem); -} - - -static void uv__stream_osx_cb_close(uv_handle_t* async) { - uv__stream_select_t* s; - - s = container_of(async, uv__stream_select_t, async); - uv__free(s); -} - - -int uv__stream_try_select(uv_stream_t* stream, int* fd) { - /* - * kqueue doesn't work with some files from /dev mount on osx. - * select(2) in separate thread for those fds - */ - - struct kevent filter[1]; - struct kevent events[1]; - struct timespec timeout; - uv__stream_select_t* s; - int fds[2]; - int err; - int ret; - int kq; - int old_fd; - int max_fd; - size_t sread_sz; - size_t swrite_sz; - - kq = kqueue(); - if (kq == -1) { - perror("(libuv) kqueue()"); - return -errno; - } - - EV_SET(&filter[0], *fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0); - - /* Use small timeout, because we only want to capture EINVALs */ - timeout.tv_sec = 0; - timeout.tv_nsec = 1; - - do - ret = kevent(kq, filter, 1, events, 1, &timeout); - while (ret == -1 && errno == EINTR); - - uv__close(kq); - - if (ret == -1) - return -errno; - - if (ret == 0 || (events[0].flags & EV_ERROR) == 0 || events[0].data != EINVAL) - return 0; - - /* At this point we definitely know that this fd won't work with kqueue */ - - /* - * Create fds for io watcher and to interrupt the select() loop. - * NOTE: do it ahead of malloc below to allocate enough space for fd_sets - */ - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) - return -errno; - - max_fd = *fd; - if (fds[1] > max_fd) - max_fd = fds[1]; - - sread_sz = ROUND_UP(max_fd + 1, sizeof(uint32_t) * NBBY) / NBBY; - swrite_sz = sread_sz; - - s = uv__malloc(sizeof(*s) + sread_sz + swrite_sz); - if (s == NULL) { - err = -ENOMEM; - goto failed_malloc; - } - - s->events = 0; - s->fd = *fd; - s->sread = (fd_set*) ((char*) s + sizeof(*s)); - s->sread_sz = sread_sz; - s->swrite = (fd_set*) ((char*) s->sread + sread_sz); - s->swrite_sz = swrite_sz; - - err = uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb); - if (err) - goto failed_async_init; - - s->async.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&s->async); - - err = uv_sem_init(&s->close_sem, 0); - if (err != 0) - goto failed_close_sem_init; - - err = uv_sem_init(&s->async_sem, 0); - if (err != 0) - goto failed_async_sem_init; - - s->fake_fd = fds[0]; - s->int_fd = fds[1]; - - old_fd = *fd; - s->stream = stream; - stream->select = s; - *fd = s->fake_fd; - - err = uv_thread_create(&s->thread, uv__stream_osx_select, stream); - if (err != 0) - goto failed_thread_create; - - return 0; - -failed_thread_create: - s->stream = NULL; - stream->select = NULL; - *fd = old_fd; - - uv_sem_destroy(&s->async_sem); - -failed_async_sem_init: - uv_sem_destroy(&s->close_sem); - -failed_close_sem_init: - uv__close(fds[0]); - uv__close(fds[1]); - uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close); - return err; - -failed_async_init: - uv__free(s); - -failed_malloc: - uv__close(fds[0]); - uv__close(fds[1]); - - return err; -} -#endif /* defined(__APPLE__) */ - - -int uv__stream_open(uv_stream_t* stream, int fd, int flags) { -#if defined(__APPLE__) - int enable; -#endif - - if (!(stream->io_watcher.fd == -1 || stream->io_watcher.fd == fd)) - return -EBUSY; - - assert(fd >= 0); - stream->flags |= flags; - - if (stream->type == UV_TCP) { - if ((stream->flags & UV_TCP_NODELAY) && uv__tcp_nodelay(fd, 1)) - return -errno; - - /* TODO Use delay the user passed in. */ - if ((stream->flags & UV_TCP_KEEPALIVE) && uv__tcp_keepalive(fd, 1, 60)) - return -errno; - } - -#if defined(__APPLE__) - enable = 1; - if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &enable, sizeof(enable)) && - errno != ENOTSOCK && - errno != EINVAL) { - return -errno; - } -#endif - - stream->io_watcher.fd = fd; - - return 0; -} - - -void uv__stream_flush_write_queue(uv_stream_t* stream, int error) { - uv_write_t* req; - QUEUE* q; - while (!QUEUE_EMPTY(&stream->write_queue)) { - q = QUEUE_HEAD(&stream->write_queue); - QUEUE_REMOVE(q); - - req = QUEUE_DATA(q, uv_write_t, queue); - req->error = error; - - QUEUE_INSERT_TAIL(&stream->write_completed_queue, &req->queue); - } -} - - -void uv__stream_destroy(uv_stream_t* stream) { - assert(!uv__io_active(&stream->io_watcher, POLLIN | POLLOUT)); - assert(stream->flags & UV_CLOSED); - - if (stream->connect_req) { - uv__req_unregister(stream->loop, stream->connect_req); - stream->connect_req->cb(stream->connect_req, -ECANCELED); - stream->connect_req = NULL; - } - - uv__stream_flush_write_queue(stream, -ECANCELED); - uv__write_callbacks(stream); - - if (stream->shutdown_req) { - /* The ECANCELED error code is a lie, the shutdown(2) syscall is a - * fait accompli at this point. Maybe we should revisit this in v0.11. - * A possible reason for leaving it unchanged is that it informs the - * callee that the handle has been destroyed. - */ - uv__req_unregister(stream->loop, stream->shutdown_req); - stream->shutdown_req->cb(stream->shutdown_req, -ECANCELED); - stream->shutdown_req = NULL; - } - - assert(stream->write_queue_size == 0); -} - - -/* Implements a best effort approach to mitigating accept() EMFILE errors. - * We have a spare file descriptor stashed away that we close to get below - * the EMFILE limit. Next, we accept all pending connections and close them - * immediately to signal the clients that we're overloaded - and we are, but - * we still keep on trucking. - * - * There is one caveat: it's not reliable in a multi-threaded environment. - * The file descriptor limit is per process. Our party trick fails if another - * thread opens a file or creates a socket in the time window between us - * calling close() and accept(). - */ -static int uv__emfile_trick(uv_loop_t* loop, int accept_fd) { - int err; - int emfile_fd; - - if (loop->emfile_fd == -1) - return -EMFILE; - - uv__close(loop->emfile_fd); - loop->emfile_fd = -1; - - do { - err = uv__accept(accept_fd); - if (err >= 0) - uv__close(err); - } while (err >= 0 || err == -EINTR); - - emfile_fd = uv__open_cloexec("/", O_RDONLY); - if (emfile_fd >= 0) - loop->emfile_fd = emfile_fd; - - return err; -} - - -// #if defined(UV_HAVE_KQUEUE) -// # define UV_DEC_BACKLOG(w) w->rcount--; -// #else -# define UV_DEC_BACKLOG(w) /* no-op */ -// #endif /* defined(UV_HAVE_KQUEUE) */ - - -void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - uv_stream_t* stream; - int err; - - stream = container_of(w, uv_stream_t, io_watcher); - assert(events == POLLIN); - assert(stream->accepted_fd == -1); - assert(!(stream->flags & UV_CLOSING)); - - uv__io_start(stream->loop, &stream->io_watcher, POLLIN); - - /* connection_cb can close the server socket while we're - * in the loop so check it on each iteration. - */ - while (uv__stream_fd(stream) != -1) { - assert(stream->accepted_fd == -1); - -// #if defined(UV_HAVE_KQUEUE) - // if (w->rcount <= 0) - // return; -// #endif /* defined(UV_HAVE_KQUEUE) */ - - err = uv__accept(uv__stream_fd(stream)); - if (err < 0) { - if (err == -EAGAIN || err == -EWOULDBLOCK) - return; /* Not an error. */ - - if (err == -ECONNABORTED) - continue; /* Ignore. Nothing we can do about that. */ - - if (err == -EMFILE || err == -ENFILE) { - err = uv__emfile_trick(loop, uv__stream_fd(stream)); - if (err == -EAGAIN || err == -EWOULDBLOCK) - break; - } - - stream->connection_cb(stream, err); - continue; - } - - UV_DEC_BACKLOG(w) - stream->accepted_fd = err; - stream->connection_cb(stream, 0); - - if (stream->accepted_fd != -1) { - /* The user hasn't yet accepted called uv_accept() */ - uv__io_stop(loop, &stream->io_watcher, POLLIN); - return; - } - - if (stream->type == UV_TCP && (stream->flags & UV_TCP_SINGLE_ACCEPT)) { - /* Give other processes a chance to accept connections. */ - struct timespec timeout = { 0, 1 }; - nanosleep(&timeout, NULL); - } - } -} - - -#undef UV_DEC_BACKLOG - - -int uv_accept(uv_stream_t* server, uv_stream_t* client) { - int err; - - assert(server->loop == client->loop); - - if (server->accepted_fd == -1) - return -EAGAIN; - - switch (client->type) { - case UV_NAMED_PIPE: - case UV_TCP: - err = uv__stream_open(client, - server->accepted_fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - if (err) { - /* TODO handle error */ - uv__close(server->accepted_fd); - goto done; - } - break; - - case UV_UDP: - err = uv_udp_open((uv_udp_t*) client, server->accepted_fd); - if (err) { - uv__close(server->accepted_fd); - goto done; - } - break; - - default: - return -EINVAL; - } - - client->flags |= UV_HANDLE_BOUND; - -done: - /* Process queued fds */ - if (server->queued_fds != NULL) { - uv__stream_queued_fds_t* queued_fds; - - queued_fds = server->queued_fds; - - /* Read first */ - server->accepted_fd = queued_fds->fds[0]; - - /* All read, free */ - assert(queued_fds->offset > 0); - if (--queued_fds->offset == 0) { - uv__free(queued_fds); - server->queued_fds = NULL; - } else { - /* Shift rest */ - memmove(queued_fds->fds, - queued_fds->fds + 1, - queued_fds->offset * sizeof(*queued_fds->fds)); - } - } else { - server->accepted_fd = -1; - if (err == 0) - uv__io_start(server->loop, &server->io_watcher, POLLIN); - } - return err; -} - - -int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) { - int err; - - switch (stream->type) { - case UV_TCP: - err = uv_tcp_listen((uv_tcp_t*)stream, backlog, cb); - break; - - case UV_NAMED_PIPE: - err = uv_pipe_listen((uv_pipe_t*)stream, backlog, cb); - break; - - default: - err = -EINVAL; - } - - if (err == 0) - uv__handle_start(stream); - - return err; -} - - -static void uv__drain(uv_stream_t* stream) { - uv_shutdown_t* req; - int err; - - assert(QUEUE_EMPTY(&stream->write_queue)); - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - - /* Shutdown? */ - if ((stream->flags & UV_STREAM_SHUTTING) && - !(stream->flags & UV_CLOSING) && - !(stream->flags & UV_STREAM_SHUT)) { - assert(stream->shutdown_req); - - req = stream->shutdown_req; - stream->shutdown_req = NULL; - stream->flags &= ~UV_STREAM_SHUTTING; - uv__req_unregister(stream->loop, req); - - err = 0; - if (shutdown(uv__stream_fd(stream), SHUT_WR)) - err = -errno; - - if (err == 0) - stream->flags |= UV_STREAM_SHUT; - - if (req->cb != NULL) - req->cb(req, err); - } -} - - -static size_t uv__write_req_size(uv_write_t* req) { - size_t size; - - assert(req->bufs != NULL); - size = uv__count_bufs(req->bufs + req->write_index, - req->nbufs - req->write_index); - assert(req->handle->write_queue_size >= size); - - return size; -} - - -static void uv__write_req_finish(uv_write_t* req) { - uv_stream_t* stream = req->handle; - - /* Pop the req off tcp->write_queue. */ - QUEUE_REMOVE(&req->queue); - - /* Only free when there was no error. On error, we touch up write_queue_size - * right before making the callback. The reason we don't do that right away - * is that a write_queue_size > 0 is our only way to signal to the user that - * they should stop writing - which they should if we got an error. Something - * to revisit in future revisions of the libuv API. - */ - if (req->error == 0) { - if (req->bufs != req->bufsml) - uv__free(req->bufs); - req->bufs = NULL; - } - - /* Add it to the write_completed_queue where it will have its - * callback called in the near future. - */ - QUEUE_INSERT_TAIL(&stream->write_completed_queue, &req->queue); - uv__io_feed(stream->loop, &stream->io_watcher); -} - - -static int uv__handle_fd(uv_handle_t* handle) { - switch (handle->type) { - case UV_NAMED_PIPE: - case UV_TCP: - return ((uv_stream_t*) handle)->io_watcher.fd; - - case UV_UDP: - return ((uv_udp_t*) handle)->io_watcher.fd; - - default: - return -1; - } -} - -static void uv__write(uv_stream_t* stream) { - struct iovec* iov; - QUEUE* q; - uv_write_t* req; - int iovmax; - int iovcnt; - ssize_t n; - int err; - -start: - - assert(uv__stream_fd(stream) >= 0); - - if (QUEUE_EMPTY(&stream->write_queue)) - return; - - q = QUEUE_HEAD(&stream->write_queue); - req = QUEUE_DATA(q, uv_write_t, queue); - assert(req->handle == stream); - - /* - * Cast to iovec. We had to have our own uv_buf_t instead of iovec - * because Windows's WSABUF is not an iovec. - */ - assert(sizeof(uv_buf_t) == sizeof(struct iovec)); - iov = (struct iovec*) &(req->bufs[req->write_index]); - iovcnt = req->nbufs - req->write_index; - - iovmax = uv__getiovmax(); - - /* Limit iov count to avoid EINVALs from writev() */ - if (iovcnt > iovmax) - iovcnt = iovmax; - - /* - * Now do the actual writev. Note that we've been updating the pointers - * inside the iov each time we write. So there is no need to offset it. - */ - - if (req->send_handle) { - int fd_to_send; - struct msghdr msg; - struct cmsghdr *cmsg; - union { - char data[64]; - struct cmsghdr alias; - } scratch; - - if (uv__is_closing(req->send_handle)) { - err = -EBADF; - goto error; - } - - fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle); - - memset(&scratch, 0, sizeof(scratch)); - - assert(fd_to_send >= 0); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = iov; - msg.msg_iovlen = iovcnt; - msg.msg_flags = 0; - - msg.msg_control = &scratch.alias; - msg.msg_controllen = CMSG_SPACE(sizeof(fd_to_send)); - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(fd_to_send)); - - /* silence aliasing warning */ - { - void* pv = CMSG_DATA(cmsg); - int* pi = pv; - *pi = fd_to_send; - } - - do { - n = sendmsg(uv__stream_fd(stream), &msg, 0); - } -#if defined(__APPLE__) - /* - * Due to a possible kernel bug at least in OS X 10.10 "Yosemite", - * EPROTOTYPE can be returned while trying to write to a socket that is - * shutting down. If we retry the write, we should get the expected EPIPE - * instead. - */ - while (n == -1 && (errno == EINTR || errno == EPROTOTYPE)); -#else - while (n == -1 && errno == EINTR); -#endif - } else { - do { - if (iovcnt == 1) { - n = write(uv__stream_fd(stream), iov[0].iov_base, iov[0].iov_len); - } else { - n = writev(uv__stream_fd(stream), iov, iovcnt); - } - } -#if defined(__APPLE__) - /* - * Due to a possible kernel bug at least in OS X 10.10 "Yosemite", - * EPROTOTYPE can be returned while trying to write to a socket that is - * shutting down. If we retry the write, we should get the expected EPIPE - * instead. - */ - while (n == -1 && (errno == EINTR || errno == EPROTOTYPE)); -#else - while (n == -1 && errno == EINTR); -#endif - } - - if (n < 0) { - if (errno != EAGAIN && errno != EWOULDBLOCK) { - err = -errno; - goto error; - } else if (stream->flags & UV_STREAM_BLOCKING) { - /* If this is a blocking stream, try again. */ - goto start; - } - } else { - /* Successful write */ - - while (n >= 0) { - uv_buf_t* buf = &(req->bufs[req->write_index]); - size_t len = buf->len; - - assert(req->write_index < req->nbufs); - - if ((size_t)n < len) { - buf->base += n; - buf->len -= n; - stream->write_queue_size -= n; - n = 0; - - /* There is more to write. */ - if (stream->flags & UV_STREAM_BLOCKING) { - /* - * If we're blocking then we should not be enabling the write - * watcher - instead we need to try again. - */ - goto start; - } else { - /* Break loop and ensure the watcher is pending. */ - break; - } - - } else { - /* Finished writing the buf at index req->write_index. */ - req->write_index++; - - assert((size_t)n >= len); - n -= len; - - assert(stream->write_queue_size >= len); - stream->write_queue_size -= len; - - if (req->write_index == req->nbufs) { - /* Then we're done! */ - assert(n == 0); - uv__write_req_finish(req); - /* TODO: start trying to write the next request. */ - return; - } - } - } - } - - /* Either we've counted n down to zero or we've got EAGAIN. */ - assert(n == 0 || n == -1); - - /* Only non-blocking streams should use the write_watcher. */ - assert(!(stream->flags & UV_STREAM_BLOCKING)); - - /* We're not done. */ - uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); - - /* Notify select() thread about state change */ - uv__stream_osx_interrupt_select(stream); - - return; - -error: - req->error = err; - uv__write_req_finish(req); - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - if (!uv__io_active(&stream->io_watcher, POLLIN)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); -} - - -static void uv__write_callbacks(uv_stream_t* stream) { - uv_write_t* req; - QUEUE* q; - - while (!QUEUE_EMPTY(&stream->write_completed_queue)) { - /* Pop a req off write_completed_queue. */ - q = QUEUE_HEAD(&stream->write_completed_queue); - req = QUEUE_DATA(q, uv_write_t, queue); - QUEUE_REMOVE(q); - uv__req_unregister(stream->loop, req); - - if (req->bufs != NULL) { - stream->write_queue_size -= uv__write_req_size(req); - if (req->bufs != req->bufsml) - uv__free(req->bufs); - req->bufs = NULL; - } - - /* NOTE: call callback AFTER freeing the request data. */ - if (req->cb) - req->cb(req, req->error); - } - - assert(QUEUE_EMPTY(&stream->write_completed_queue)); -} - - -uv_handle_type uv__handle_type(int fd) { - struct sockaddr_storage ss; - socklen_t sslen; - socklen_t len; - int type; - - memset(&ss, 0, sizeof(ss)); - sslen = sizeof(ss); - - if (getsockname(fd, (struct sockaddr*)&ss, &sslen)) - return UV_UNKNOWN_HANDLE; - - len = sizeof type; - - if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &len)) - return UV_UNKNOWN_HANDLE; - - if (type == SOCK_STREAM) { -#if defined(_AIX) || defined(__DragonFly__) - /* on AIX/DragonFly the getsockname call returns an empty sa structure - * for sockets of type AF_UNIX. For all other types it will - * return a properly filled in structure. - */ - if (sslen == 0) - return UV_NAMED_PIPE; -#endif - switch (ss.ss_family) { - case AF_UNIX: - return UV_NAMED_PIPE; - case AF_INET: - case AF_INET6: - return UV_TCP; - } - } - - if (type == SOCK_DGRAM && - (ss.ss_family == AF_INET || ss.ss_family == AF_INET6)) - return UV_UDP; - - return UV_UNKNOWN_HANDLE; -} - - -static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) { - stream->flags |= UV_STREAM_READ_EOF; - uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); - if (!uv__io_active(&stream->io_watcher, POLLOUT)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); - stream->read_cb(stream, UV_EOF, buf); - stream->flags &= ~UV_STREAM_READING; -} - - -static int uv__stream_queue_fd(uv_stream_t* stream, int fd) { - uv__stream_queued_fds_t* queued_fds; - unsigned int queue_size; - - queued_fds = stream->queued_fds; - if (queued_fds == NULL) { - queue_size = 8; - queued_fds = uv__malloc((queue_size - 1) * sizeof(*queued_fds->fds) + - sizeof(*queued_fds)); - if (queued_fds == NULL) - return -ENOMEM; - queued_fds->size = queue_size; - queued_fds->offset = 0; - stream->queued_fds = queued_fds; - - /* Grow */ - } else if (queued_fds->size == queued_fds->offset) { - queue_size = queued_fds->size + 8; - queued_fds = uv__realloc(queued_fds, - (queue_size - 1) * sizeof(*queued_fds->fds) + - sizeof(*queued_fds)); - - /* - * Allocation failure, report back. - * NOTE: if it is fatal - sockets will be closed in uv__stream_close - */ - if (queued_fds == NULL) - return -ENOMEM; - queued_fds->size = queue_size; - stream->queued_fds = queued_fds; - } - - /* Put fd in a queue */ - queued_fds->fds[queued_fds->offset++] = fd; - - return 0; -} - - -#define UV__CMSG_FD_COUNT 64 -#define UV__CMSG_FD_SIZE (UV__CMSG_FD_COUNT * sizeof(int)) - - -static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) { - struct cmsghdr* cmsg; - - for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) { - char* start; - char* end; - int err; - void* pv; - int* pi; - unsigned int i; - unsigned int count; - - if (cmsg->cmsg_type != SCM_RIGHTS) { - fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n", - cmsg->cmsg_type); - continue; - } - - /* silence aliasing warning */ - pv = CMSG_DATA(cmsg); - pi = pv; - - /* Count available fds */ - start = (char*) cmsg; - end = (char*) cmsg + cmsg->cmsg_len; - count = 0; - while (start + CMSG_LEN(count * sizeof(*pi)) < end) - count++; - assert(start + CMSG_LEN(count * sizeof(*pi)) == end); - - for (i = 0; i < count; i++) { - /* Already has accepted fd, queue now */ - if (stream->accepted_fd != -1) { - err = uv__stream_queue_fd(stream, pi[i]); - if (err != 0) { - /* Close rest */ - for (; i < count; i++) - uv__close(pi[i]); - return err; - } - } else { - stream->accepted_fd = pi[i]; - } - } - } - - return 0; -} - - -#ifdef __clang__ -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wgnu-folding-constant" -#endif - -static void uv__read(uv_stream_t* stream) { - uv_buf_t buf; - ssize_t nread; - struct msghdr msg; - char cmsg_space[CMSG_SPACE(UV__CMSG_FD_SIZE)]; - int count; - int err; - int is_ipc; - - stream->flags &= ~UV_STREAM_READ_PARTIAL; - - /* Prevent loop starvation when the data comes in as fast as (or faster than) - * we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O. - */ - count = 32; - - is_ipc = stream->type == UV_NAMED_PIPE && ((uv_pipe_t*) stream)->ipc; - - /* XXX: Maybe instead of having UV_STREAM_READING we just test if - * tcp->read_cb is NULL or not? - */ - while (stream->read_cb - && (stream->flags & UV_STREAM_READING) - && (count-- > 0)) { - assert(stream->alloc_cb != NULL); - - buf = uv_buf_init(NULL, 0); - stream->alloc_cb((uv_handle_t*)stream, 64 * 1024, &buf); - if (buf.base == NULL || buf.len == 0) { - /* User indicates it can't or won't handle the read. */ - stream->read_cb(stream, UV_ENOBUFS, &buf); - return; - } - - assert(buf.base != NULL); - assert(uv__stream_fd(stream) >= 0); - - if (!is_ipc) { - do { - nread = read(uv__stream_fd(stream), buf.base, buf.len); - } - while (nread < 0 && errno == EINTR); - } else { - /* ipc uses recvmsg */ - msg.msg_flags = 0; - msg.msg_iov = (struct iovec*) &buf; - msg.msg_iovlen = 1; - msg.msg_name = NULL; - msg.msg_namelen = 0; - /* Set up to receive a descriptor even if one isn't in the message */ - msg.msg_controllen = sizeof(cmsg_space); - msg.msg_control = cmsg_space; - - do { - nread = uv__recvmsg(uv__stream_fd(stream), &msg, 0); - } - while (nread < 0 && errno == EINTR); - } - - if (nread < 0) { - /* Error */ - if (errno == EAGAIN || errno == EWOULDBLOCK) { - /* Wait for the next one. */ - if (stream->flags & UV_STREAM_READING) { - uv__io_start(stream->loop, &stream->io_watcher, POLLIN); - uv__stream_osx_interrupt_select(stream); - } - stream->read_cb(stream, 0, &buf); -#if defined(__CYGWIN__) || defined(__MSYS__) - } else if (errno == ECONNRESET && stream->type == UV_NAMED_PIPE) { - uv__stream_eof(stream, &buf); - return; -#endif - } else { - /* Error. User should call uv_close(). */ - stream->read_cb(stream, -errno, &buf); - if (stream->flags & UV_STREAM_READING) { - stream->flags &= ~UV_STREAM_READING; - uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); - if (!uv__io_active(&stream->io_watcher, POLLOUT)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); - } - } - return; - } else if (nread == 0) { - uv__stream_eof(stream, &buf); - return; - } else { - /* Successful read */ - ssize_t buflen = buf.len; - - if (is_ipc) { - err = uv__stream_recv_cmsg(stream, &msg); - if (err != 0) { - stream->read_cb(stream, err, &buf); - return; - } - } - -#if defined(__MVS__) - if (is_ipc && msg.msg_controllen > 0) { - uv_buf_t blankbuf; - int nread; - struct iovec *old; - - blankbuf.base = 0; - blankbuf.len = 0; - old = msg.msg_iov; - msg.msg_iov = (struct iovec*) &blankbuf; - nread = 0; - do { - nread = uv__recvmsg(uv__stream_fd(stream), &msg, 0); - err = uv__stream_recv_cmsg(stream, &msg); - if (err != 0) { - stream->read_cb(stream, err, &buf); - msg.msg_iov = old; - return; - } - } while (nread == 0 && msg.msg_controllen > 0); - msg.msg_iov = old; - } -#endif - stream->read_cb(stream, nread, &buf); - - /* Return if we didn't fill the buffer, there is no more data to read. */ - if (nread < buflen) { - stream->flags |= UV_STREAM_READ_PARTIAL; - return; - } - } - } -} - - -#ifdef __clang__ -# pragma clang diagnostic pop -#endif - -#undef UV__CMSG_FD_COUNT -#undef UV__CMSG_FD_SIZE - - -int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) { - assert((stream->type == UV_TCP || stream->type == UV_NAMED_PIPE) && - "uv_shutdown (unix) only supports uv_handle_t right now"); - - if (!(stream->flags & UV_STREAM_WRITABLE) || - stream->flags & UV_STREAM_SHUT || - stream->flags & UV_STREAM_SHUTTING || - uv__is_closing(stream)) { - return -ENOTCONN; - } - - assert(uv__stream_fd(stream) >= 0); - - /* Initialize request */ - uv__req_init(stream->loop, req, UV_SHUTDOWN); - req->handle = stream; - req->cb = cb; - stream->shutdown_req = req; - stream->flags |= UV_STREAM_SHUTTING; - - uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - - return 0; -} - - -static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - uv_stream_t* stream; - - stream = container_of(w, uv_stream_t, io_watcher); - - assert(stream->type == UV_TCP || - stream->type == UV_NAMED_PIPE || - stream->type == UV_TTY); - assert(!(stream->flags & UV_CLOSING)); - - if (stream->connect_req) { - uv__stream_connect(stream); - return; - } - - assert(uv__stream_fd(stream) >= 0); - - /* Ignore POLLHUP here. Even it it's set, there may still be data to read. */ - if (events & (POLLIN | POLLERR | POLLHUP)) - uv__read(stream); - - if (uv__stream_fd(stream) == -1) - return; /* read_cb closed stream. */ - - /* Short-circuit iff POLLHUP is set, the user is still interested in read - * events and uv__read() reported a partial read but not EOF. If the EOF - * flag is set, uv__read() called read_cb with err=UV_EOF and we don't - * have to do anything. If the partial read flag is not set, we can't - * report the EOF yet because there is still data to read. - */ - if ((events & POLLHUP) && - (stream->flags & UV_STREAM_READING) && - (stream->flags & UV_STREAM_READ_PARTIAL) && - !(stream->flags & UV_STREAM_READ_EOF)) { - uv_buf_t buf = { NULL, 0 }; - uv__stream_eof(stream, &buf); - } - - if (uv__stream_fd(stream) == -1) - return; /* read_cb closed stream. */ - - if (events & (POLLOUT | POLLERR | POLLHUP)) { - uv__write(stream); - uv__write_callbacks(stream); - - /* Write queue drained. */ - if (QUEUE_EMPTY(&stream->write_queue)) - uv__drain(stream); - } -} - - -/** - * We get called here from directly following a call to connect(2). - * In order to determine if we've errored out or succeeded must call - * getsockopt. - */ -static void uv__stream_connect(uv_stream_t* stream) { - int error; - uv_connect_t* req = stream->connect_req; - socklen_t errorsize = sizeof(int); - - assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE); - assert(req); - - if (stream->delayed_error) { - /* To smooth over the differences between unixes errors that - * were reported synchronously on the first connect can be delayed - * until the next tick--which is now. - */ - error = stream->delayed_error; - stream->delayed_error = 0; - } else { - /* Normal situation: we need to get the socket error from the kernel. */ - assert(uv__stream_fd(stream) >= 0); - getsockopt(uv__stream_fd(stream), - SOL_SOCKET, - SO_ERROR, - &error, - &errorsize); - error = -error; - } - - if (error == -EINPROGRESS) - return; - - stream->connect_req = NULL; - uv__req_unregister(stream->loop, req); - - if (error < 0 || QUEUE_EMPTY(&stream->write_queue)) { - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - } - - if (req->cb) - req->cb(req, error); - - if (uv__stream_fd(stream) == -1) - return; - - if (error < 0) { - uv__stream_flush_write_queue(stream, -ECANCELED); - uv__write_callbacks(stream); - } -} - - -int uv_write2(uv_write_t* req, - uv_stream_t* stream, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - int empty_queue; - - assert(nbufs > 0); - assert((stream->type == UV_TCP || - stream->type == UV_NAMED_PIPE || - stream->type == UV_TTY) && - "uv_write (unix) does not yet support other types of streams"); - - if (uv__stream_fd(stream) < 0) - return -EBADF; - - if (send_handle) { - if (stream->type != UV_NAMED_PIPE || !((uv_pipe_t*)stream)->ipc) - return -EINVAL; - - /* XXX We abuse uv_write2() to send over UDP handles to child processes. - * Don't call uv__stream_fd() on those handles, it's a macro that on OS X - * evaluates to a function that operates on a uv_stream_t with a couple of - * OS X specific fields. On other Unices it does (handle)->io_watcher.fd, - * which works but only by accident. - */ - if (uv__handle_fd((uv_handle_t*) send_handle) < 0) - return -EBADF; - -#if defined(__CYGWIN__) || defined(__MSYS__) - /* Cygwin recvmsg always sets msg_controllen to zero, so we cannot send it. - See https://github.com/mirror/newlib-cygwin/blob/86fc4bf0/winsup/cygwin/fhandler_socket.cc#L1736-L1743 */ - return -ENOSYS; -#endif - } - - /* It's legal for write_queue_size > 0 even when the write_queue is empty; - * it means there are error-state requests in the write_completed_queue that - * will touch up write_queue_size later, see also uv__write_req_finish(). - * We could check that write_queue is empty instead but that implies making - * a write() syscall when we know that the handle is in error mode. - */ - empty_queue = (stream->write_queue_size == 0); - - /* Initialize the req */ - uv__req_init(stream->loop, req, UV_WRITE); - req->cb = cb; - req->handle = stream; - req->error = 0; - req->send_handle = send_handle; - QUEUE_INIT(&req->queue); - - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(bufs[0])); - - if (req->bufs == NULL) - return -ENOMEM; - - memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0])); - req->nbufs = nbufs; - req->write_index = 0; - stream->write_queue_size += uv__count_bufs(bufs, nbufs); - - /* Append the request to write_queue. */ - QUEUE_INSERT_TAIL(&stream->write_queue, &req->queue); - - /* If the queue was empty when this function began, we should attempt to - * do the write immediately. Otherwise start the write_watcher and wait - * for the fd to become writable. - */ - if (stream->connect_req) { - /* Still connecting, do nothing. */ - } - else if (empty_queue) { - uv__write(stream); - } - else { - /* - * blocking streams should never have anything in the queue. - * if this assert fires then somehow the blocking stream isn't being - * sufficiently flushed in uv__write. - */ - assert(!(stream->flags & UV_STREAM_BLOCKING)); - uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - } - - return 0; -} - - -/* The buffers to be written must remain valid until the callback is called. - * This is not required for the uv_buf_t array. - */ -int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - return uv_write2(req, handle, bufs, nbufs, NULL, cb); -} - - -void uv_try_write_cb(uv_write_t* req, int status) { - /* Should not be called */ - abort(); -} - - -int uv_try_write(uv_stream_t* stream, - const uv_buf_t bufs[], - unsigned int nbufs) { - int r; - int has_pollout; - size_t written; - size_t req_size; - uv_write_t req; - - /* Connecting or already writing some data */ - if (stream->connect_req != NULL || stream->write_queue_size != 0) - return -EAGAIN; - - has_pollout = uv__io_active(&stream->io_watcher, POLLOUT); - - r = uv_write(&req, stream, bufs, nbufs, uv_try_write_cb); - if (r != 0) - return r; - - /* Remove not written bytes from write queue size */ - written = uv__count_bufs(bufs, nbufs); - if (req.bufs != NULL) - req_size = uv__write_req_size(&req); - else - req_size = 0; - written -= req_size; - stream->write_queue_size -= req_size; - - /* Unqueue request, regardless of immediateness */ - QUEUE_REMOVE(&req.queue); - uv__req_unregister(stream->loop, &req); - if (req.bufs != req.bufsml) - uv__free(req.bufs); - req.bufs = NULL; - - /* Do not poll for writable, if we wasn't before calling this */ - if (!has_pollout) { - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - uv__stream_osx_interrupt_select(stream); - } - - if (written == 0 && req_size != 0) - return -EAGAIN; - else - return written; -} - - -int uv_read_start(uv_stream_t* stream, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE || - stream->type == UV_TTY); - - if (stream->flags & UV_CLOSING) - return -EINVAL; - - /* The UV_STREAM_READING flag is irrelevant of the state of the tcp - it just - * expresses the desired state of the user. - */ - stream->flags |= UV_STREAM_READING; - - /* TODO: try to do the read inline? */ - /* TODO: keep track of tcp state. If we've gotten a EOF then we should - * not start the IO watcher. - */ - assert(uv__stream_fd(stream) >= 0); - assert(alloc_cb); - - stream->read_cb = read_cb; - stream->alloc_cb = alloc_cb; - - uv__io_start(stream->loop, &stream->io_watcher, POLLIN); - uv__handle_start(stream); - uv__stream_osx_interrupt_select(stream); - - return 0; -} - - -int uv_read_stop(uv_stream_t* stream) { - if (!(stream->flags & UV_STREAM_READING)) - return 0; - - stream->flags &= ~UV_STREAM_READING; - uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); - if (!uv__io_active(&stream->io_watcher, POLLOUT)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); - - stream->read_cb = NULL; - stream->alloc_cb = NULL; - return 0; -} - - -int uv_is_readable(const uv_stream_t* stream) { - return !!(stream->flags & UV_STREAM_READABLE); -} - - -int uv_is_writable(const uv_stream_t* stream) { - return !!(stream->flags & UV_STREAM_WRITABLE); -} - - -#if defined(__APPLE__) -int uv___stream_fd(const uv_stream_t* handle) { - const uv__stream_select_t* s; - - assert(handle->type == UV_TCP || - handle->type == UV_TTY || - handle->type == UV_NAMED_PIPE); - - s = handle->select; - if (s != NULL) - return s->fd; - - return handle->io_watcher.fd; -} -#endif /* defined(__APPLE__) */ - - -void uv__stream_close(uv_stream_t* handle) { - unsigned int i; - uv__stream_queued_fds_t* queued_fds; - -#if defined(__APPLE__) - /* Terminate select loop first */ - if (handle->select != NULL) { - uv__stream_select_t* s; - - s = handle->select; - - uv_sem_post(&s->close_sem); - uv_sem_post(&s->async_sem); - uv__stream_osx_interrupt_select(handle); - uv_thread_join(&s->thread); - uv_sem_destroy(&s->close_sem); - uv_sem_destroy(&s->async_sem); - uv__close(s->fake_fd); - uv__close(s->int_fd); - uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close); - - handle->select = NULL; - } -#endif /* defined(__APPLE__) */ - - uv__io_close(handle->loop, &handle->io_watcher); - uv_read_stop(handle); - uv__handle_stop(handle); - - if (handle->io_watcher.fd != -1) { - /* Don't close stdio file descriptors. Nothing good comes from it. */ - if (handle->io_watcher.fd > STDERR_FILENO) - uv__close(handle->io_watcher.fd); - handle->io_watcher.fd = -1; - } - - if (handle->accepted_fd != -1) { - uv__close(handle->accepted_fd); - handle->accepted_fd = -1; - } - - /* Close all queued fds */ - if (handle->queued_fds != NULL) { - queued_fds = handle->queued_fds; - for (i = 0; i < queued_fds->offset; i++) - uv__close(queued_fds->fds[i]); - uv__free(handle->queued_fds); - handle->queued_fds = NULL; - } - - assert(!uv__io_active(&handle->io_watcher, POLLIN | POLLOUT)); -} - - -int uv_stream_set_blocking(uv_stream_t* handle, int blocking) { - /* Don't need to check the file descriptor, uv__nonblock() - * will fail with EBADF if it's not valid. - */ - return uv__nonblock(uv__stream_fd(handle), !blocking); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/sunos.c b/lib/ESPiLight/pilight/libs/libuv/unix/sunos.c deleted file mode 100644 index 2dc02ae..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/sunos.c +++ /dev/null @@ -1,821 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include - -#ifndef SUNOS_NO_IFADDRS -# include -#endif -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#define PORT_FIRED 0x69 -#define PORT_UNUSED 0x0 -#define PORT_LOADED 0x99 -#define PORT_DELETED -1 - -#if (!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64) -#define PROCFS_FILE_OFFSET_BITS_HACK 1 -#undef _FILE_OFFSET_BITS -#else -#define PROCFS_FILE_OFFSET_BITS_HACK 0 -#endif - -#include - -#if (PROCFS_FILE_OFFSET_BITS_HACK - 0 == 1) -#define _FILE_OFFSET_BITS 64 -#endif - - -int uv__platform_loop_init(uv_loop_t* loop) { - int err; - int fd; - - loop->fs_fd = -1; - loop->backend_fd = -1; - - fd = port_create(); - if (fd == -1) - return -errno; - - err = uv__cloexec(fd, 1); - if (err) { - uv__close(fd); - return err; - } - loop->backend_fd = fd; - - return 0; -} - - -void uv__platform_loop_delete(uv_loop_t* loop) { - if (loop->fs_fd != -1) { - uv__close(loop->fs_fd); - loop->fs_fd = -1; - } - - if (loop->backend_fd != -1) { - uv__close(loop->backend_fd); - loop->backend_fd = -1; - } -} - - -int uv__io_fork(uv_loop_t* loop) { -#if defined(PORT_SOURCE_FILE) - if (loop->fs_fd != -1) { - /* stop the watcher before we blow away its fileno */ - uv__io_stop(loop, &loop->fs_event_watcher, POLLIN); - } -#endif - uv__platform_loop_delete(loop); - return uv__platform_loop_init(loop); -} - - -void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { - struct port_event* events; - uintptr_t i; - uintptr_t nfds; - - assert(loop->watchers != NULL); - - events = (struct port_event*) loop->watchers[loop->nwatchers]; - nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events == NULL) - return; - - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].portev_object == fd) - events[i].portev_object = -1; -} - - -int uv__io_check_fd(uv_loop_t* loop, int fd) { - if (port_associate(loop->backend_fd, PORT_SOURCE_FD, fd, POLLIN, 0)) - return -errno; - - if (port_dissociate(loop->backend_fd, PORT_SOURCE_FD, fd)) - abort(); - - return 0; -} - - -void uv__io_poll(uv_loop_t* loop, int timeout) { - struct port_event events[1024]; - struct port_event* pe; - struct timespec spec; - QUEUE* q; - uv__io_t* w; - sigset_t* pset; - sigset_t set; - uint64_t base; - uint64_t diff; - unsigned int nfds; - unsigned int i; - int saved_errno; - int have_signals; - int nevents; - int count; - int err; - int fd; - - if (loop->nfds == 0) { - assert(QUEUE_EMPTY(&loop->watcher_queue)); - return; - } - - while (!QUEUE_EMPTY(&loop->watcher_queue)) { - q = QUEUE_HEAD(&loop->watcher_queue); - QUEUE_REMOVE(q); - QUEUE_INIT(q); - - w = QUEUE_DATA(q, uv__io_t, watcher_queue); - assert(w->pevents != 0); - - if (port_associate(loop->backend_fd, PORT_SOURCE_FD, w->fd, w->pevents, 0)) - abort(); - - w->events = w->pevents; - } - - pset = NULL; - if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { - pset = &set; - sigemptyset(pset); - sigaddset(pset, SIGPROF); - } - - assert(timeout >= -1); - base = loop->time; - count = 48; /* Benchmarks suggest this gives the best throughput. */ - - for (;;) { - if (timeout != -1) { - spec.tv_sec = timeout / 1000; - spec.tv_nsec = (timeout % 1000) * 1000000; - } - - /* Work around a kernel bug where nfds is not updated. */ - events[0].portev_source = 0; - - nfds = 1; - saved_errno = 0; - - if (pset != NULL) - pthread_sigmask(SIG_BLOCK, pset, NULL); - - err = port_getn(loop->backend_fd, - events, - ARRAY_SIZE(events), - &nfds, - timeout == -1 ? NULL : &spec); - - if (pset != NULL) - pthread_sigmask(SIG_UNBLOCK, pset, NULL); - - if (err) { - /* Work around another kernel bug: port_getn() may return events even - * on error. - */ - if (errno == EINTR || errno == ETIME) - saved_errno = errno; - else - abort(); - } - - /* Update loop->time unconditionally. It's tempting to skip the update when - * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the - * operating system didn't reschedule our process while in the syscall. - */ - SAVE_ERRNO(uv__update_time(loop)); - - if (events[0].portev_source == 0) { - if (timeout == 0) - return; - - if (timeout == -1) - continue; - - goto update_timeout; - } - - if (nfds == 0) { - assert(timeout != -1); - return; - } - - have_signals = 0; - nevents = 0; - - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; - for (i = 0; i < nfds; i++) { - pe = events + i; - fd = pe->portev_object; - - /* Skip invalidated events, see uv__platform_invalidate_fd */ - if (fd == -1) - continue; - - assert(fd >= 0); - assert((unsigned) fd < loop->nwatchers); - - w = loop->watchers[fd]; - - /* File descriptor that we've stopped watching, ignore. */ - if (w == NULL) - continue; - - /* Run signal watchers last. This also affects child process watchers - * because those are implemented in terms of signal watchers. - */ - if (w == &loop->signal_io_watcher) - have_signals = 1; - else - w->cb(loop, w, pe->portev_events); - - nevents++; - - if (w != loop->watchers[fd]) - continue; /* Disabled by callback. */ - - /* Events Ports operates in oneshot mode, rearm timer on next run. */ - if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue)) - QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); - } - - if (have_signals != 0) - loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); - - loop->watchers[loop->nwatchers] = NULL; - loop->watchers[loop->nwatchers + 1] = NULL; - - if (have_signals != 0) - return; /* Event loop should cycle now so don't poll again. */ - - if (nevents != 0) { - if (nfds == ARRAY_SIZE(events) && --count != 0) { - /* Poll for more events but don't block this time. */ - timeout = 0; - continue; - } - return; - } - - if (saved_errno == ETIME) { - assert(timeout != -1); - return; - } - - if (timeout == 0) - return; - - if (timeout == -1) - continue; - -update_timeout: - assert(timeout > 0); - - diff = loop->time - base; - if (diff >= (uint64_t) timeout) - return; - - timeout -= diff; - } -} - - -uint64_t uv__hrtime(uv_clocktype_t type) { - return gethrtime(); -} - - -/* - * We could use a static buffer for the path manipulations that we need outside - * of the function, but this function could be called by multiple consumers and - * we don't want to potentially create a race condition in the use of snprintf. - */ -int uv_exepath(char* buffer, size_t* size) { - ssize_t res; - char buf[128]; - - if (buffer == NULL || size == NULL || *size == 0) - return -EINVAL; - - snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid()); - - res = *size - 1; - if (res > 0) - res = readlink(buf, buffer, res); - - if (res == -1) - return -errno; - - buffer[res] = '\0'; - *size = res; - return 0; -} - - -uint64_t uv_get_free_memory(void) { - return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES); -} - - -uint64_t uv_get_total_memory(void) { - return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES); -} - - -void uv_loadavg(double avg[3]) { - (void) getloadavg(avg, 3); -} - - -#if defined(PORT_SOURCE_FILE) - -static int uv__fs_event_rearm(uv_fs_event_t *handle) { - if (handle->fd == -1) - return -EBADF; - - if (port_associate(handle->loop->fs_fd, - PORT_SOURCE_FILE, - (uintptr_t) &handle->fo, - FILE_ATTRIB | FILE_MODIFIED, - handle) == -1) { - return -errno; - } - handle->fd = PORT_LOADED; - - return 0; -} - - -static void uv__fs_event_read(uv_loop_t* loop, - uv__io_t* w, - unsigned int revents) { - uv_fs_event_t *handle = NULL; - timespec_t timeout; - port_event_t pe; - int events; - int r; - - (void) w; - (void) revents; - - do { - uint_t n = 1; - - /* - * Note that our use of port_getn() here (and not port_get()) is deliberate: - * there is a bug in event ports (Sun bug 6456558) whereby a zeroed timeout - * causes port_get() to return success instead of ETIME when there aren't - * actually any events (!); by using port_getn() in lieu of port_get(), - * we can at least workaround the bug by checking for zero returned events - * and treating it as we would ETIME. - */ - do { - memset(&timeout, 0, sizeof timeout); - r = port_getn(loop->fs_fd, &pe, 1, &n, &timeout); - } - while (r == -1 && errno == EINTR); - - if ((r == -1 && errno == ETIME) || n == 0) - break; - - handle = (uv_fs_event_t*) pe.portev_user; - assert((r == 0) && "unexpected port_get() error"); - - events = 0; - if (pe.portev_events & (FILE_ATTRIB | FILE_MODIFIED)) - events |= UV_CHANGE; - if (pe.portev_events & ~(FILE_ATTRIB | FILE_MODIFIED)) - events |= UV_RENAME; - assert(events != 0); - handle->fd = PORT_FIRED; - handle->cb(handle, NULL, events, 0); - - if (handle->fd != PORT_DELETED) { - r = uv__fs_event_rearm(handle); - if (r != 0) - handle->cb(handle, NULL, 0, r); - } - } - while (handle->fd != PORT_DELETED); -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { - int portfd; - int first_run; - int err; - - if (uv__is_active(handle)) - return -EINVAL; - - first_run = 0; - if (handle->loop->fs_fd == -1) { - portfd = port_create(); - if (portfd == -1) - return -errno; - handle->loop->fs_fd = portfd; - first_run = 1; - } - - uv__handle_start(handle); - handle->path = uv__strdup(path); - handle->fd = PORT_UNUSED; - handle->cb = cb; - - memset(&handle->fo, 0, sizeof handle->fo); - handle->fo.fo_name = handle->path; - err = uv__fs_event_rearm(handle); - if (err != 0) { - uv_fs_event_stop(handle); - return err; - } - - if (first_run) { - uv__io_init(&handle->loop->fs_event_watcher, uv__fs_event_read, portfd); - uv__io_start(handle->loop, &handle->loop->fs_event_watcher, POLLIN); - } - - return 0; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - if (!uv__is_active(handle)) - return 0; - - if (handle->fd == PORT_FIRED || handle->fd == PORT_LOADED) { - port_dissociate(handle->loop->fs_fd, - PORT_SOURCE_FILE, - (uintptr_t) &handle->fo); - } - - handle->fd = PORT_DELETED; - uv__free(handle->path); - handle->path = NULL; - handle->fo.fo_name = NULL; - uv__handle_stop(handle); - - return 0; -} - -void uv__fs_event_close(uv_fs_event_t* handle) { - uv_fs_event_stop(handle); -} - -#else /* !defined(PORT_SOURCE_FILE) */ - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - return -ENOSYS; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* filename, - unsigned int flags) { - return -ENOSYS; -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - return -ENOSYS; -} - - -void uv__fs_event_close(uv_fs_event_t* handle) { - UNREACHABLE(); -} - -#endif /* defined(PORT_SOURCE_FILE) */ - - -int uv_resident_set_memory(size_t* rss) { - psinfo_t psinfo; - int err; - int fd; - - fd = open("/proc/self/psinfo", O_RDONLY); - if (fd == -1) - return -errno; - - /* FIXME(bnoordhuis) Handle EINTR. */ - err = -EINVAL; - if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) { - *rss = (size_t)psinfo.pr_rssize * 1024; - err = 0; - } - uv__close(fd); - - return err; -} - - -int uv_uptime(double* uptime) { - kstat_ctl_t *kc; - kstat_t *ksp; - kstat_named_t *knp; - - long hz = sysconf(_SC_CLK_TCK); - - kc = kstat_open(); - if (kc == NULL) - return -EPERM; - - ksp = kstat_lookup(kc, (char*) "unix", 0, (char*) "system_misc"); - if (kstat_read(kc, ksp, NULL) == -1) { - *uptime = -1; - } else { - knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "clk_intr"); - *uptime = knp->value.ul / hz; - } - kstat_close(kc); - - return 0; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { - int lookup_instance; - kstat_ctl_t *kc; - kstat_t *ksp; - kstat_named_t *knp; - uv_cpu_info_t* cpu_info; - - kc = kstat_open(); - if (kc == NULL) - return -EPERM; - - /* Get count of cpus */ - lookup_instance = 0; - while ((ksp = kstat_lookup(kc, (char*) "cpu_info", lookup_instance, NULL))) { - lookup_instance++; - } - - *cpu_infos = uv__malloc(lookup_instance * sizeof(**cpu_infos)); - if (!(*cpu_infos)) { - kstat_close(kc); - return -ENOMEM; - } - - *count = lookup_instance; - - cpu_info = *cpu_infos; - lookup_instance = 0; - while ((ksp = kstat_lookup(kc, (char*) "cpu_info", lookup_instance, NULL))) { - if (kstat_read(kc, ksp, NULL) == -1) { - cpu_info->speed = 0; - cpu_info->model = NULL; - } else { - knp = kstat_data_lookup(ksp, (char*) "clock_MHz"); - assert(knp->data_type == KSTAT_DATA_INT32 || - knp->data_type == KSTAT_DATA_INT64); - cpu_info->speed = (knp->data_type == KSTAT_DATA_INT32) ? knp->value.i32 - : knp->value.i64; - - knp = kstat_data_lookup(ksp, (char*) "brand"); - assert(knp->data_type == KSTAT_DATA_STRING); - cpu_info->model = uv__strdup(KSTAT_NAMED_STR_PTR(knp)); - } - - lookup_instance++; - cpu_info++; - } - - cpu_info = *cpu_infos; - lookup_instance = 0; - for (;;) { - ksp = kstat_lookup(kc, (char*) "cpu", lookup_instance, (char*) "sys"); - - if (ksp == NULL) - break; - - if (kstat_read(kc, ksp, NULL) == -1) { - cpu_info->cpu_times.user = 0; - cpu_info->cpu_times.nice = 0; - cpu_info->cpu_times.sys = 0; - cpu_info->cpu_times.idle = 0; - cpu_info->cpu_times.irq = 0; - } else { - knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_user"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.user = knp->value.ui64; - - knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_kernel"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.sys = knp->value.ui64; - - knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_idle"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.idle = knp->value.ui64; - - knp = kstat_data_lookup(ksp, (char*) "intr"); - assert(knp->data_type == KSTAT_DATA_UINT64); - cpu_info->cpu_times.irq = knp->value.ui64; - cpu_info->cpu_times.nice = 0; - } - - lookup_instance++; - cpu_info++; - } - - kstat_close(kc); - - return 0; -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - -#ifdef SUNOS_NO_IFADDRS -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - return -ENOSYS; -} -#else /* SUNOS_NO_IFADDRS */ -/* - * Inspired By: - * https://blogs.oracle.com/paulie/entry/retrieving_mac_address_in_solaris - * http://www.pauliesworld.org/project/getmac.c - */ -static int uv__set_phys_addr(uv_interface_address_t* address, - struct ifaddrs* ent) { - - struct sockaddr_dl* sa_addr; - int sockfd; - int i; - struct arpreq arpreq; - - /* This appears to only work as root */ - sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); - memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); - for (i = 0; i < sizeof(address->phys_addr); i++) { - if (address->phys_addr[i] != 0) - return 0; - } - memset(&arpreq, 0, sizeof(arpreq)); - if (address->address.address4.sin_family == AF_INET) { - struct sockaddr_in* sin = ((struct sockaddr_in*)&arpreq.arp_pa); - sin->sin_addr.s_addr = address->address.address4.sin_addr.s_addr; - } else if (address->address.address4.sin_family == AF_INET6) { - struct sockaddr_in6* sin = ((struct sockaddr_in6*)&arpreq.arp_pa); - memcpy(sin->sin6_addr.s6_addr, - address->address.address6.sin6_addr.s6_addr, - sizeof(address->address.address6.sin6_addr.s6_addr)); - } else { - return 0; - } - - sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd < 0) - return -errno; - - if (ioctl(sockfd, SIOCGARP, (char*)&arpreq) == -1) { - uv__close(sockfd); - return -errno; - } - memcpy(address->phys_addr, arpreq.arp_ha.sa_data, sizeof(address->phys_addr)); - uv__close(sockfd); - return 0; -} - - -static int uv__ifaddr_exclude(struct ifaddrs *ent) { - if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING))) - return 1; - if (ent->ifa_addr == NULL) - return 1; - if (ent->ifa_addr->sa_family == PF_PACKET) - return 1; - return 0; -} - -int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { - uv_interface_address_t* address; - struct ifaddrs* addrs; - struct ifaddrs* ent; - int i; - - if (getifaddrs(&addrs)) - return -errno; - - *count = 0; - - /* Count the number of interfaces */ - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent)) - continue; - (*count)++; - } - - *addresses = uv__malloc(*count * sizeof(**addresses)); - if (!(*addresses)) { - freeifaddrs(addrs); - return -ENOMEM; - } - - address = *addresses; - - for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - if (uv__ifaddr_exclude(ent)) - continue; - - address->name = uv__strdup(ent->ifa_name); - - if (ent->ifa_addr->sa_family == AF_INET6) { - address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr); - } else { - address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr); - } - - if (ent->ifa_netmask->sa_family == AF_INET6) { - address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask); - } else { - address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask); - } - - address->is_internal = !!((ent->ifa_flags & IFF_PRIVATE) || - (ent->ifa_flags & IFF_LOOPBACK)); - - uv__set_phys_addr(address, ent); - address++; - } - - freeifaddrs(addrs); - - return 0; -} -#endif /* SUNOS_NO_IFADDRS */ - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(addresses[i].name); - } - - uv__free(addresses); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/sysinfo-loadavg.c b/lib/ESPiLight/pilight/libs/libuv/unix/sysinfo-loadavg.c deleted file mode 100644 index ebad0e8..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/sysinfo-loadavg.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -void uv_loadavg(double avg[3]) { - struct sysinfo info; - - if (sysinfo(&info) < 0) return; - - avg[0] = (double) info.loads[0] / 65536.0; - avg[1] = (double) info.loads[1] / 65536.0; - avg[2] = (double) info.loads[2] / 65536.0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/sysinfo-memory.c b/lib/ESPiLight/pilight/libs/libuv/unix/sysinfo-memory.c deleted file mode 100644 index 23b4fc6..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/sysinfo-memory.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include - -uint64_t uv_get_free_memory(void) { - struct sysinfo info; - - if (sysinfo(&info) == 0) - return (uint64_t) info.freeram * info.mem_unit; - return 0; -} - -uint64_t uv_get_total_memory(void) { - struct sysinfo info; - - if (sysinfo(&info) == 0) - return (uint64_t) info.totalram * info.mem_unit; - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/tcp.c b/lib/ESPiLight/pilight/libs/libuv/unix/tcp.c deleted file mode 100644 index c423dcb..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/tcp.c +++ /dev/null @@ -1,395 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include - - -static int maybe_new_socket(uv_tcp_t* handle, int domain, int flags) { - int sockfd; - int err; - - if (domain == AF_UNSPEC || uv__stream_fd(handle) != -1) { - handle->flags |= flags; - return 0; - } - - err = uv__socket(domain, SOCK_STREAM, 0); - if (err < 0) - return err; - sockfd = err; - - err = uv__stream_open((uv_stream_t*) handle, sockfd, flags); - if (err) { - uv__close(sockfd); - return err; - } - - return 0; -} - - -int uv_tcp_init_ex(uv_loop_t* loop, uv_tcp_t* tcp, unsigned int flags) { - int domain; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return -EINVAL; - - if (flags & ~0xFF) - return -EINVAL; - - uv__stream_init(loop, (uv_stream_t*)tcp, UV_TCP); - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init in uv_stream_init. - */ - - if (domain != AF_UNSPEC) { - int err = maybe_new_socket(tcp, domain, 0); - if (err) { - QUEUE_REMOVE(&tcp->handle_queue); - return err; - } - } - - return 0; -} - - -int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* tcp) { - return uv_tcp_init_ex(loop, tcp, AF_UNSPEC); -} - - -int uv__tcp_bind(uv_tcp_t* tcp, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - int on; - - /* Cannot set IPv6-only mode on non-IPv6 socket. */ - if ((flags & UV_TCP_IPV6ONLY) && addr->sa_family != AF_INET6) - return -EINVAL; - - err = maybe_new_socket(tcp, - addr->sa_family, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - if (err) - return err; - - on = 1; - if (setsockopt(tcp->io_watcher.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) - return -errno; - -#ifdef IPV6_V6ONLY - if (addr->sa_family == AF_INET6) { - on = (flags & UV_TCP_IPV6ONLY) != 0; - if (setsockopt(tcp->io_watcher.fd, - IPPROTO_IPV6, - IPV6_V6ONLY, - &on, - sizeof on) == -1) { -#if defined(__MVS__) - if (errno == EOPNOTSUPP) - return -EINVAL; -#endif - return -errno; - } - } -#endif - - errno = 0; - if (bind(tcp->io_watcher.fd, addr, addrlen) && errno != EADDRINUSE) { - if (errno == EAFNOSUPPORT) - /* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a - * socket created with AF_INET to an AF_INET6 address or vice versa. */ - return -EINVAL; - return -errno; - } - tcp->delayed_error = -errno; - - tcp->flags |= UV_HANDLE_BOUND; - if (addr->sa_family == AF_INET6) - tcp->flags |= UV_HANDLE_IPV6; - - return 0; -} - - -int uv__tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb) { - int err; - int r; - - assert(handle->type == UV_TCP); - - if (handle->connect_req != NULL) - return -EALREADY; /* FIXME(bnoordhuis) -EINVAL or maybe -EBUSY. */ - - err = maybe_new_socket(handle, - addr->sa_family, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); - if (err) - return err; - - handle->delayed_error = 0; - - do { - errno = 0; - r = connect(uv__stream_fd(handle), addr, addrlen); - } while (r == -1 && errno == EINTR); - - /* We not only check the return value, but also check the errno != 0. - * Because in rare cases connect() will return -1 but the errno - * is 0 (for example, on Android 4.3, OnePlus phone A0001_12_150227) - * and actually the tcp three-way handshake is completed. - */ - if (r == -1 && errno != 0) { - if (errno == EINPROGRESS) - ; /* not an error */ - else if (errno == ECONNREFUSED) - /* If we get a ECONNREFUSED wait until the next tick to report the - * error. Solaris wants to report immediately--other unixes want to - * wait. - */ - handle->delayed_error = -errno; - else - return -errno; - } - - uv__req_init(handle->loop, req, UV_CONNECT); - req->cb = cb; - req->handle = (uv_stream_t*) handle; - QUEUE_INIT(&req->queue); - handle->connect_req = req; - - uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); - - if (handle->delayed_error) - uv__io_feed(handle->loop, &handle->io_watcher); - - return 0; -} - - -int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) { - int err; - - err = uv__nonblock(sock, 1); - if (err) - return err; - - return uv__stream_open((uv_stream_t*)handle, - sock, - UV_STREAM_READABLE | UV_STREAM_WRITABLE); -} - - -int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - socklen_t socklen; - - if (handle->delayed_error) - return handle->delayed_error; - - if (uv__stream_fd(handle) < 0) - return -EINVAL; /* FIXME(bnoordhuis) -EBADF */ - - /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t) *namelen; - - if (getsockname(uv__stream_fd(handle), name, &socklen)) - return -errno; - - *namelen = (int) socklen; - return 0; -} - - -int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - socklen_t socklen; - - if (handle->delayed_error) - return handle->delayed_error; - - if (uv__stream_fd(handle) < 0) - return -EINVAL; /* FIXME(bnoordhuis) -EBADF */ - - /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t) *namelen; - - if (getpeername(uv__stream_fd(handle), name, &socklen)) - return -errno; - - *namelen = (int) socklen; - return 0; -} - - -int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) { - static int single_accept = -1; - int err; - - if (tcp->delayed_error) - return tcp->delayed_error; - - if (single_accept == -1) { - const char* val = getenv("UV_TCP_SINGLE_ACCEPT"); - single_accept = (val != NULL && atoi(val) != 0); /* Off by default. */ - } - - if (single_accept) - tcp->flags |= UV_TCP_SINGLE_ACCEPT; - - err = maybe_new_socket(tcp, AF_INET, UV_STREAM_READABLE); - if (err) - return err; - -#ifdef __MVS__ - /* on zOS the listen call does not bind automatically - if the socket is unbound. Hence the manual binding to - an arbitrary port is required to be done manually - */ - - if (!(tcp->flags & UV_HANDLE_BOUND)) { - struct sockaddr_storage saddr; - socklen_t slen = sizeof(saddr); - memset(&saddr, 0, sizeof(saddr)); - - if (getsockname(tcp->io_watcher.fd, (struct sockaddr*) &saddr, &slen)) - return -errno; - - if (bind(tcp->io_watcher.fd, (struct sockaddr*) &saddr, slen)) - return -errno; - - tcp->flags |= UV_HANDLE_BOUND; - } -#endif - - if (listen(tcp->io_watcher.fd, backlog)) - return -errno; - - tcp->connection_cb = cb; - tcp->flags |= UV_HANDLE_BOUND; - - /* Start listening for connections. */ - tcp->io_watcher.cb = uv__server_io; - uv__io_start(tcp->loop, &tcp->io_watcher, POLLIN); - - return 0; -} - - -int uv__tcp_nodelay(int fd, int on) { - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on))) - return -errno; - return 0; -} - - -int uv__tcp_keepalive(int fd, int on, unsigned int delay) { - if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on))) - return -errno; - -#ifdef TCP_KEEPIDLE - if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay))) - return -errno; -#endif - - /* Solaris/SmartOS, if you don't support keep-alive, - * then don't advertise it in your system headers... - */ - /* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */ -#if defined(TCP_KEEPALIVE) && !defined(__sun) - if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay))) - return -errno; -#endif - - return 0; -} - - -int uv_tcp_nodelay(uv_tcp_t* handle, int on) { - int err; - - if (uv__stream_fd(handle) != -1) { - err = uv__tcp_nodelay(uv__stream_fd(handle), on); - if (err) - return err; - } - - if (on) - handle->flags |= UV_TCP_NODELAY; - else - handle->flags &= ~UV_TCP_NODELAY; - - return 0; -} - - -int uv_tcp_keepalive(uv_tcp_t* handle, int on, unsigned int delay) { - int err; - - if (uv__stream_fd(handle) != -1) { - err =uv__tcp_keepalive(uv__stream_fd(handle), on, delay); - if (err) - return err; - } - - if (on) - handle->flags |= UV_TCP_KEEPALIVE; - else - handle->flags &= ~UV_TCP_KEEPALIVE; - - /* TODO Store delay if uv__stream_fd(handle) == -1 but don't want to enlarge - * uv_tcp_t with an int that's almost never used... - */ - - return 0; -} - - -int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { - if (enable) - handle->flags &= ~UV_TCP_SINGLE_ACCEPT; - else - handle->flags |= UV_TCP_SINGLE_ACCEPT; - return 0; -} - - -void uv__tcp_close(uv_tcp_t* handle) { - uv__stream_close((uv_stream_t*)handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/thread.c b/lib/ESPiLight/pilight/libs/libuv/unix/thread.c deleted file mode 100644 index a9b5e4c..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/thread.c +++ /dev/null @@ -1,575 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include - -#include -#include /* getrlimit() */ -#include /* getpagesize() */ - -#include - -#ifdef __MVS__ -#include -#include -#endif - -#undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) - - -int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { - int err; - pthread_attr_t* attr; -#if defined(__APPLE__) - pthread_attr_t attr_storage; - struct rlimit lim; -#endif - - /* On OSX threads other than the main thread are created with a reduced stack - * size by default, adjust it to RLIMIT_STACK. - */ -#if defined(__APPLE__) - if (getrlimit(RLIMIT_STACK, &lim)) - abort(); - - attr = &attr_storage; - if (pthread_attr_init(attr)) - abort(); - - if (lim.rlim_cur != RLIM_INFINITY) { - /* pthread_attr_setstacksize() expects page-aligned values. */ - lim.rlim_cur -= lim.rlim_cur % (rlim_t) getpagesize(); - - if (lim.rlim_cur >= PTHREAD_STACK_MIN) - if (pthread_attr_setstacksize(attr, lim.rlim_cur)) - abort(); - } -#else - attr = NULL; -#endif - - err = pthread_create(tid, attr, (void*(*)(void*)) entry, arg); - - if (attr != NULL) - pthread_attr_destroy(attr); - - return -err; -} - - -uv_thread_t uv_thread_self(void) { - return pthread_self(); -} - -int uv_thread_join(uv_thread_t *tid) { - return -pthread_join(*tid, NULL); -} - - -int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) { - return pthread_equal(*t1, *t2); -} - - -int uv_mutex_init(uv_mutex_t* mutex) { -#if defined(NDEBUG) || !defined(PTHREAD_MUTEX_ERRORCHECK) - return -pthread_mutex_init(mutex, NULL); -#else - pthread_mutexattr_t attr; - int err; - - if (pthread_mutexattr_init(&attr)) - abort(); - - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK)) - abort(); - - err = pthread_mutex_init(mutex, &attr); - - if (pthread_mutexattr_destroy(&attr)) - abort(); - - return -err; -#endif -} - - -void uv_mutex_destroy(uv_mutex_t* mutex) { - if (pthread_mutex_destroy(mutex)) - abort(); -} - - -void uv_mutex_lock(uv_mutex_t* mutex) { - if (pthread_mutex_lock(mutex)) - abort(); -} - - -int uv_mutex_trylock(uv_mutex_t* mutex) { - int err; - - err = pthread_mutex_trylock(mutex); - if (err) { - if (err != EBUSY && err != EAGAIN) - abort(); - return -EBUSY; - } - - return 0; -} - - -void uv_mutex_unlock(uv_mutex_t* mutex) { - if (pthread_mutex_unlock(mutex)) - abort(); -} - - -int uv_rwlock_init(uv_rwlock_t* rwlock) { - return -pthread_rwlock_init(rwlock, NULL); -} - - -void uv_rwlock_destroy(uv_rwlock_t* rwlock) { - if (pthread_rwlock_destroy(rwlock)) - abort(); -} - - -void uv_rwlock_rdlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_rdlock(rwlock)) - abort(); -} - - -int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) { - int err; - - err = pthread_rwlock_tryrdlock(rwlock); - if (err) { - if (err != EBUSY && err != EAGAIN) - abort(); - return -EBUSY; - } - - return 0; -} - - -void uv_rwlock_rdunlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_unlock(rwlock)) - abort(); -} - - -void uv_rwlock_wrlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_wrlock(rwlock)) - abort(); -} - - -int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) { - int err; - - err = pthread_rwlock_trywrlock(rwlock); - if (err) { - if (err != EBUSY && err != EAGAIN) - abort(); - return -EBUSY; - } - - return 0; -} - - -void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) { - if (pthread_rwlock_unlock(rwlock)) - abort(); -} - - -void uv_once(uv_once_t* guard, void (*callback)(void)) { - if (pthread_once(guard, callback)) - abort(); -} - -#if defined(__APPLE__) && defined(__MACH__) - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - kern_return_t err; - - err = semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value); - if (err == KERN_SUCCESS) - return 0; - if (err == KERN_INVALID_ARGUMENT) - return -EINVAL; - if (err == KERN_RESOURCE_SHORTAGE) - return -ENOMEM; - - abort(); - return -EINVAL; /* Satisfy the compiler. */ -} - - -void uv_sem_destroy(uv_sem_t* sem) { - if (semaphore_destroy(mach_task_self(), *sem)) - abort(); -} - - -void uv_sem_post(uv_sem_t* sem) { - if (semaphore_signal(*sem)) - abort(); -} - - -void uv_sem_wait(uv_sem_t* sem) { - int r; - - do - r = semaphore_wait(*sem); - while (r == KERN_ABORTED); - - if (r != KERN_SUCCESS) - abort(); -} - - -int uv_sem_trywait(uv_sem_t* sem) { - mach_timespec_t interval; - kern_return_t err; - - interval.tv_sec = 0; - interval.tv_nsec = 0; - - err = semaphore_timedwait(*sem, interval); - if (err == KERN_SUCCESS) - return 0; - if (err == KERN_OPERATION_TIMED_OUT) - return -EAGAIN; - - abort(); - return -EINVAL; /* Satisfy the compiler. */ -} - -#elif defined(__MVS__) - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - uv_sem_t semid; - struct sembuf buf; - int err; - - buf.sem_num = 0; - buf.sem_op = value; - buf.sem_flg = 0; - - semid = semget(IPC_PRIVATE, 1, S_IRUSR | S_IWUSR); - if (semid == -1) - return -errno; - - if (-1 == semop(semid, &buf, 1)) { - err = errno; - if (-1 == semctl(*sem, 0, IPC_RMID)) - abort(); - return -err; - } - - *sem = semid; - return 0; -} - -void uv_sem_destroy(uv_sem_t* sem) { - if (-1 == semctl(*sem, 0, IPC_RMID)) - abort(); -} - -void uv_sem_post(uv_sem_t* sem) { - struct sembuf buf; - - buf.sem_num = 0; - buf.sem_op = 1; - buf.sem_flg = 0; - - if (-1 == semop(*sem, &buf, 1)) - abort(); -} - -void uv_sem_wait(uv_sem_t* sem) { - struct sembuf buf; - int op_status; - - buf.sem_num = 0; - buf.sem_op = -1; - buf.sem_flg = 0; - - do - op_status = semop(*sem, &buf, 1); - while (op_status == -1 && errno == EINTR); - - if (op_status) - abort(); -} - -int uv_sem_trywait(uv_sem_t* sem) { - struct sembuf buf; - int op_status; - - buf.sem_num = 0; - buf.sem_op = -1; - buf.sem_flg = IPC_NOWAIT; - - do - op_status = semop(*sem, &buf, 1); - while (op_status == -1 && errno == EINTR); - - if (op_status) { - if (errno == EAGAIN) - return -EAGAIN; - abort(); - } - - return 0; -} - -#else /* !(defined(__APPLE__) && defined(__MACH__)) */ - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - if (sem_init(sem, 0, value)) - return -errno; - return 0; -} - - -void uv_sem_destroy(uv_sem_t* sem) { - if (sem_destroy(sem)) - abort(); -} - - -void uv_sem_post(uv_sem_t* sem) { - if (sem_post(sem)) - abort(); -} - - -void uv_sem_wait(uv_sem_t* sem) { - int r; - - do - r = sem_wait(sem); - while (r == -1 && errno == EINTR); - - if (r) - abort(); -} - - -int uv_sem_trywait(uv_sem_t* sem) { - int r; - - do - r = sem_trywait(sem); - while (r == -1 && errno == EINTR); - - if (r) { - if (errno == EAGAIN) - return -EAGAIN; - abort(); - } - - return 0; -} - -#endif /* defined(__APPLE__) && defined(__MACH__) */ - - -#if defined(__APPLE__) && defined(__MACH__) || defined(__MVS__) - -int uv_cond_init(uv_cond_t* cond) { - return -pthread_cond_init(cond, NULL); -} - -#else /* !(defined(__APPLE__) && defined(__MACH__)) */ - -int uv_cond_init(uv_cond_t* cond) { - pthread_condattr_t attr; - int err; - - err = pthread_condattr_init(&attr); - if (err) - return -err; - -#if !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) - err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); - if (err) - goto error2; -#endif - - err = pthread_cond_init(cond, &attr); - if (err) - goto error2; - - err = pthread_condattr_destroy(&attr); - if (err) - goto error; - - return 0; - -error: - pthread_cond_destroy(cond); -error2: - pthread_condattr_destroy(&attr); - return -err; -} - -#endif /* defined(__APPLE__) && defined(__MACH__) */ - -void uv_cond_destroy(uv_cond_t* cond) { -#if defined(__APPLE__) && defined(__MACH__) - /* It has been reported that destroying condition variables that have been - * signalled but not waited on can sometimes result in application crashes. - * See https://codereview.chromium.org/1323293005. - */ - pthread_mutex_t mutex; - struct timespec ts; - int err; - - if (pthread_mutex_init(&mutex, NULL)) - abort(); - - if (pthread_mutex_lock(&mutex)) - abort(); - - ts.tv_sec = 0; - ts.tv_nsec = 1; - - err = pthread_cond_timedwait_relative_np(cond, &mutex, &ts); - if (err != 0 && err != ETIMEDOUT) - abort(); - - if (pthread_mutex_unlock(&mutex)) - abort(); - - if (pthread_mutex_destroy(&mutex)) - abort(); -#endif /* defined(__APPLE__) && defined(__MACH__) */ - - if (pthread_cond_destroy(cond)) - abort(); -} - -void uv_cond_signal(uv_cond_t* cond) { - if (pthread_cond_signal(cond)) - abort(); -} - -void uv_cond_broadcast(uv_cond_t* cond) { - if (pthread_cond_broadcast(cond)) - abort(); -} - -void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (pthread_cond_wait(cond, mutex)) - abort(); -} - - -int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { - int r; - struct timespec ts; - -#if defined(__APPLE__) && defined(__MACH__) - ts.tv_sec = timeout / NANOSEC; - ts.tv_nsec = timeout % NANOSEC; - r = pthread_cond_timedwait_relative_np(cond, mutex, &ts); -#else - timeout += uv__hrtime(UV_CLOCK_PRECISE); - ts.tv_sec = timeout / NANOSEC; - ts.tv_nsec = timeout % NANOSEC; -#if defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) - /* - * The bionic pthread implementation doesn't support CLOCK_MONOTONIC, - * but has this alternative function instead. - */ - r = pthread_cond_timedwait_monotonic_np(cond, mutex, &ts); -#else - r = pthread_cond_timedwait(cond, mutex, &ts); -#endif /* __ANDROID__ */ -#endif - - - if (r == 0) - return 0; - - if (r == ETIMEDOUT) - return -ETIMEDOUT; - - abort(); - return -EINVAL; /* Satisfy the compiler. */ -} - - -int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { - return -pthread_barrier_init(barrier, NULL, count); -} - - -void uv_barrier_destroy(uv_barrier_t* barrier) { - if (pthread_barrier_destroy(barrier)) - abort(); -} - - -int uv_barrier_wait(uv_barrier_t* barrier) { - int r = pthread_barrier_wait(barrier); - if (r && r != PTHREAD_BARRIER_SERIAL_THREAD) - abort(); - return r == PTHREAD_BARRIER_SERIAL_THREAD; -} - - -int uv_key_create(uv_key_t* key) { - return -pthread_key_create(key, NULL); -} - - -void uv_key_delete(uv_key_t* key) { - if (pthread_key_delete(*key)) - abort(); -} - - -void* uv_key_get(uv_key_t* key) { - return pthread_getspecific(*key); -} - - -void uv_key_set(uv_key_t* key, void* value) { - if (pthread_setspecific(*key, value)) - abort(); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/timer.c b/lib/ESPiLight/pilight/libs/libuv/unix/timer.c deleted file mode 100644 index f46bdf4..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/timer.c +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" -#include "heap-inl.h" - -#include -#include - - -static int timer_less_than(const struct heap_node* ha, - const struct heap_node* hb) { - const uv_timer_t* a; - const uv_timer_t* b; - - a = container_of(ha, uv_timer_t, heap_node); - b = container_of(hb, uv_timer_t, heap_node); - - if (a->timeout < b->timeout) - return 1; - if (b->timeout < a->timeout) - return 0; - - /* Compare start_id when both have the same timeout. start_id is - * allocated with loop->timer_counter in uv_timer_start(). - */ - if (a->start_id < b->start_id) - return 1; - if (b->start_id < a->start_id) - return 0; - - return 0; -} - - -int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { - uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER); - handle->timer_cb = NULL; - handle->repeat = 0; - return 0; -} - - -int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat) { - uint64_t clamped_timeout; - - if (cb == NULL) - return -EINVAL; - - if (uv__is_active(handle)) - uv_timer_stop(handle); - - clamped_timeout = handle->loop->time + timeout; - if (clamped_timeout < timeout) - clamped_timeout = (uint64_t) -1; - - handle->timer_cb = cb; - handle->timeout = clamped_timeout; - handle->repeat = repeat; - /* start_id is the second index to be compared in uv__timer_cmp() */ - handle->start_id = handle->loop->timer_counter++; - - heap_insert((struct heap*) &handle->loop->timer_heap, - (struct heap_node*) &handle->heap_node, - timer_less_than); - uv__handle_start(handle); - - return 0; -} - - -int uv_timer_stop(uv_timer_t* handle) { - if (!uv__is_active(handle)) - return 0; - - heap_remove((struct heap*) &handle->loop->timer_heap, - (struct heap_node*) &handle->heap_node, - timer_less_than); - uv__handle_stop(handle); - - return 0; -} - - -int uv_timer_again(uv_timer_t* handle) { - if (handle->timer_cb == NULL) - return -EINVAL; - - if (handle->repeat) { - uv_timer_stop(handle); - uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat); - } - - return 0; -} - - -void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) { - handle->repeat = repeat; -} - - -uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { - return handle->repeat; -} - - -int uv__next_timeout(const uv_loop_t* loop) { - const struct heap_node* heap_node; - const uv_timer_t* handle; - uint64_t diff; - - heap_node = heap_min((const struct heap*) &loop->timer_heap); - if (heap_node == NULL) - return -1; /* block indefinitely */ - - handle = container_of(heap_node, uv_timer_t, heap_node); - if (handle->timeout <= loop->time) - return 0; - - diff = handle->timeout - loop->time; - if (diff > INT_MAX) - diff = INT_MAX; - - return diff; -} - - -void uv__run_timers(uv_loop_t* loop) { - struct heap_node* heap_node; - uv_timer_t* handle; - - for (;;) { - heap_node = heap_min((struct heap*) &loop->timer_heap); - if (heap_node == NULL) - break; - - handle = container_of(heap_node, uv_timer_t, heap_node); - if (handle->timeout > loop->time) - break; - - uv_timer_stop(handle); - uv_timer_again(handle); - handle->timer_cb(handle); - } -} - - -void uv__timer_close(uv_timer_t* handle) { - uv_timer_stop(handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/tty.c b/lib/ESPiLight/pilight/libs/libuv/unix/tty.c deleted file mode 100644 index b2d37f4..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/tty.c +++ /dev/null @@ -1,336 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" -#include "spinlock.h" - -#include -#include -#include -#include -#include -#include - -#if defined(__MVS__) && !defined(IMAXBEL) -#define IMAXBEL 0 -#endif - -static int orig_termios_fd = -1; -static struct termios orig_termios; -static uv_spinlock_t termios_spinlock = UV_SPINLOCK_INITIALIZER; - -static int uv__tty_is_slave(const int fd) { - int result; -#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - int dummy; - - result = ioctl(fd, TIOCGPTN, &dummy) != 0; -#elif defined(__APPLE__) - char dummy[256]; - - result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0; -#else - /* Fallback to ptsname - */ - result = ptsname(fd) == NULL; -#endif - return result; -} - -int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { - uv_handle_type type; - int flags; - int newfd; - int r; - int saved_flags; - char path[256]; - - /* File descriptors that refer to files cannot be monitored with epoll. - * That restriction also applies to character devices like /dev/random - * (but obviously not /dev/tty.) - */ - type = uv_guess_handle(fd); - if (type == UV_FILE || type == UV_UNKNOWN_HANDLE) - return -EINVAL; - - flags = 0; - newfd = -1; - - /* Reopen the file descriptor when it refers to a tty. This lets us put the - * tty in non-blocking mode without affecting other processes that share it - * with us. - * - * Example: `node | cat` - if we put our fd 0 in non-blocking mode, it also - * affects fd 1 of `cat` because both file descriptors refer to the same - * struct file in the kernel. When we reopen our fd 0, it points to a - * different struct file, hence changing its properties doesn't affect - * other processes. - */ - if (type == UV_TTY) { - /* Reopening a pty in master mode won't work either because the reopened - * pty will be in slave mode (*BSD) or reopening will allocate a new - * master/slave pair (Linux). Therefore check if the fd points to a - * slave device. - */ - if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0) - r = uv__open_cloexec(path, O_RDWR); - else - r = -1; - - if (r < 0) { - /* fallback to using blocking writes */ - if (!readable) - flags |= UV_STREAM_BLOCKING; - goto skip; - } - - newfd = r; - - r = uv__dup2_cloexec(newfd, fd); - if (r < 0 && r != -EINVAL) { - /* EINVAL means newfd == fd which could conceivably happen if another - * thread called close(fd) between our calls to isatty() and open(). - * That's a rather unlikely event but let's handle it anyway. - */ - uv__close(newfd); - return r; - } - - fd = newfd; - } - -#if defined(__APPLE__) - /* Save the fd flags in case we need to restore them due to an error. */ - do - saved_flags = fcntl(fd, F_GETFL); - while (saved_flags == -1 && errno == EINTR); - - if (saved_flags == -1) { - if (newfd != -1) - uv__close(newfd); - return -errno; - } -#endif - - /* Pacify the compiler. */ - (void) &saved_flags; - -skip: - uv__stream_init(loop, (uv_stream_t*) tty, UV_TTY); - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init in uv_stream_init. - */ - - if (!(flags & UV_STREAM_BLOCKING)) - uv__nonblock(fd, 1); - -#if defined(__APPLE__) - r = uv__stream_try_select((uv_stream_t*) tty, &fd); - if (r) { - int rc = r; - if (newfd != -1) - uv__close(newfd); - QUEUE_REMOVE(&tty->handle_queue); - do - r = fcntl(fd, F_SETFL, saved_flags); - while (r == -1 && errno == EINTR); - return rc; - } -#endif - - if (readable) - flags |= UV_STREAM_READABLE; - else - flags |= UV_STREAM_WRITABLE; - - uv__stream_open((uv_stream_t*) tty, fd, flags); - tty->mode = UV_TTY_MODE_NORMAL; - - return 0; -} - -static void uv__tty_make_raw(struct termios* tio) { - assert(tio != NULL); - -#if defined __sun || defined __MVS__ - /* - * This implementation of cfmakeraw for Solaris and derivatives is taken from - * http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html. - */ - tio->c_iflag &= ~(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | - IGNCR | ICRNL | IXON); - tio->c_oflag &= ~OPOST; - tio->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - tio->c_cflag &= ~(CSIZE | PARENB); - tio->c_cflag |= CS8; -#else - cfmakeraw(tio); -#endif /* #ifdef __sun */ -} - -int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { - struct termios tmp; - int fd; - - if (tty->mode == (int) mode) - return 0; - - fd = uv__stream_fd(tty); - if (tty->mode == UV_TTY_MODE_NORMAL && mode != UV_TTY_MODE_NORMAL) { - if (tcgetattr(fd, &tty->orig_termios)) - return -errno; - - /* This is used for uv_tty_reset_mode() */ - uv_spinlock_lock(&termios_spinlock); - if (orig_termios_fd == -1) { - orig_termios = tty->orig_termios; - orig_termios_fd = fd; - } - uv_spinlock_unlock(&termios_spinlock); - } - - tmp = tty->orig_termios; - switch (mode) { - case UV_TTY_MODE_NORMAL: - break; - case UV_TTY_MODE_RAW: - tmp.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); - tmp.c_oflag |= (ONLCR); - tmp.c_cflag |= (CS8); - tmp.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); - tmp.c_cc[VMIN] = 1; - tmp.c_cc[VTIME] = 0; - break; - case UV_TTY_MODE_IO: - uv__tty_make_raw(&tmp); - break; - } - - /* Apply changes after draining */ - if (tcsetattr(fd, TCSADRAIN, &tmp)) - return -errno; - - tty->mode = mode; - return 0; -} - - -int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { - struct winsize ws; - int err; - - do - err = ioctl(uv__stream_fd(tty), TIOCGWINSZ, &ws); - while (err == -1 && errno == EINTR); - - if (err == -1) - return -errno; - - *width = ws.ws_col; - *height = ws.ws_row; - - return 0; -} - - -uv_handle_type uv_guess_handle(uv_file file) { - struct sockaddr sa; - struct stat s; - socklen_t len; - int type; - - if (file < 0) - return UV_UNKNOWN_HANDLE; - - if (isatty(file)) - return UV_TTY; - - if (fstat(file, &s)) - return UV_UNKNOWN_HANDLE; - - if (S_ISREG(s.st_mode)) - return UV_FILE; - - if (S_ISCHR(s.st_mode)) - return UV_FILE; /* XXX UV_NAMED_PIPE? */ - - if (S_ISFIFO(s.st_mode)) - return UV_NAMED_PIPE; - - if (!S_ISSOCK(s.st_mode)) - return UV_UNKNOWN_HANDLE; - - len = sizeof(type); - if (getsockopt(file, SOL_SOCKET, SO_TYPE, &type, &len)) - return UV_UNKNOWN_HANDLE; - - len = sizeof(sa); - if (getsockname(file, &sa, &len)) - return UV_UNKNOWN_HANDLE; - - if (type == SOCK_DGRAM) - if (sa.sa_family == AF_INET || sa.sa_family == AF_INET6) - return UV_UDP; - - if (type == SOCK_STREAM) { -#if defined(_AIX) || defined(__DragonFly__) - /* on AIX/DragonFly the getsockname call returns an empty sa structure - * for sockets of type AF_UNIX. For all other types it will - * return a properly filled in structure. - */ - if (len == 0) - return UV_NAMED_PIPE; -#endif /* defined(_AIX) || defined(__DragonFly__) */ - - if (sa.sa_family == AF_INET || sa.sa_family == AF_INET6) - return UV_TCP; - if (sa.sa_family == AF_UNIX) - return UV_NAMED_PIPE; - } - - return UV_UNKNOWN_HANDLE; -} - - -/* This function is async signal-safe, meaning that it's safe to call from - * inside a signal handler _unless_ execution was inside uv_tty_set_mode()'s - * critical section when the signal was raised. - */ -int uv_tty_reset_mode(void) { - int saved_errno; - int err; - - saved_errno = errno; - if (!uv_spinlock_trylock(&termios_spinlock)) - return -EBUSY; /* In uv_tty_set_mode(). */ - - err = 0; - if (orig_termios_fd != -1) - if (tcsetattr(orig_termios_fd, TCSANOW, &orig_termios)) - err = -errno; - - uv_spinlock_unlock(&termios_spinlock); - errno = saved_errno; - - return err; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/unix/udp.c b/lib/ESPiLight/pilight/libs/libuv/unix/udp.c deleted file mode 100644 index c556325..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/unix/udp.c +++ /dev/null @@ -1,900 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#if defined(__MVS__) -#include -#endif - -#if defined(IPV6_JOIN_GROUP) && !defined(IPV6_ADD_MEMBERSHIP) -# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP -#endif - -#if defined(IPV6_LEAVE_GROUP) && !defined(IPV6_DROP_MEMBERSHIP) -# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP -#endif - - -static void uv__udp_run_completed(uv_udp_t* handle); -static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents); -static void uv__udp_recvmsg(uv_udp_t* handle); -static void uv__udp_sendmsg(uv_udp_t* handle); -static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, - int domain, - unsigned int flags); - - -void uv__udp_close(uv_udp_t* handle) { - uv__io_close(handle->loop, &handle->io_watcher); - uv__handle_stop(handle); - - if (handle->io_watcher.fd != -1) { - uv__close(handle->io_watcher.fd); - handle->io_watcher.fd = -1; - } -} - - -void uv__udp_finish_close(uv_udp_t* handle) { - uv_udp_send_t* req; - QUEUE* q; - - assert(!uv__io_active(&handle->io_watcher, POLLIN | POLLOUT)); - assert(handle->io_watcher.fd == -1); - - while (!QUEUE_EMPTY(&handle->write_queue)) { - q = QUEUE_HEAD(&handle->write_queue); - QUEUE_REMOVE(q); - - req = QUEUE_DATA(q, uv_udp_send_t, queue); - req->status = -ECANCELED; - QUEUE_INSERT_TAIL(&handle->write_completed_queue, &req->queue); - } - - uv__udp_run_completed(handle); - - assert(handle->send_queue_size == 0); - assert(handle->send_queue_count == 0); - - /* Now tear down the handle. */ - handle->recv_cb = NULL; - handle->alloc_cb = NULL; - /* but _do not_ touch close_cb */ -} - - -static void uv__udp_run_completed(uv_udp_t* handle) { - uv_udp_send_t* req; - QUEUE* q; - - assert(!(handle->flags & UV_UDP_PROCESSING)); - handle->flags |= UV_UDP_PROCESSING; - - while (!QUEUE_EMPTY(&handle->write_completed_queue)) { - q = QUEUE_HEAD(&handle->write_completed_queue); - QUEUE_REMOVE(q); - - req = QUEUE_DATA(q, uv_udp_send_t, queue); - uv__req_unregister(handle->loop, req); - - handle->send_queue_size -= uv__count_bufs(req->bufs, req->nbufs); - handle->send_queue_count--; - - if (req->bufs != req->bufsml) - uv__free(req->bufs); - req->bufs = NULL; - - if (req->send_cb == NULL) - continue; - - /* req->status >= 0 == bytes written - * req->status < 0 == errno - */ - if (req->status >= 0) - req->send_cb(req, 0); - else - req->send_cb(req, req->status); - } - - if (QUEUE_EMPTY(&handle->write_queue)) { - /* Pending queue and completion queue empty, stop watcher. */ - uv__io_stop(handle->loop, &handle->io_watcher, POLLOUT); - if (!uv__io_active(&handle->io_watcher, POLLIN)) - uv__handle_stop(handle); - } - - handle->flags &= ~UV_UDP_PROCESSING; -} - - -static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) { - uv_udp_t* handle; - - handle = container_of(w, uv_udp_t, io_watcher); - assert(handle->type == UV_UDP); - - if (revents & POLLIN) - uv__udp_recvmsg(handle); - - if (revents & POLLOUT) { - uv__udp_sendmsg(handle); - uv__udp_run_completed(handle); - } -} - - -static void uv__udp_recvmsg(uv_udp_t* handle) { - struct sockaddr_storage peer; - struct msghdr h; - ssize_t nread; - uv_buf_t buf; - int flags; - int count; - - assert(handle->recv_cb != NULL); - assert(handle->alloc_cb != NULL); - - /* Prevent loop starvation when the data comes in as fast as (or faster than) - * we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O. - */ - count = 32; - - memset(&h, 0, sizeof(h)); - h.msg_name = &peer; - - do { - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 64 * 1024, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->recv_cb(handle, UV_ENOBUFS, &buf, NULL, 0); - return; - } - assert(buf.base != NULL); - - h.msg_namelen = sizeof(peer); - h.msg_iov = (void*) &buf; - h.msg_iovlen = 1; - - do { - nread = recvmsg(handle->io_watcher.fd, &h, 0); - } - while (nread == -1 && errno == EINTR); - - if (nread == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK) - handle->recv_cb(handle, 0, &buf, NULL, 0); - else - handle->recv_cb(handle, -errno, &buf, NULL, 0); - } - else { - const struct sockaddr *addr; - if (h.msg_namelen == 0) - addr = NULL; - else - addr = (const struct sockaddr*) &peer; - - flags = 0; - if (h.msg_flags & MSG_TRUNC) - flags |= UV_UDP_PARTIAL; - - handle->recv_cb(handle, nread, &buf, addr, flags); - } - } - /* recv_cb callback may decide to pause or close the handle */ - while (nread != -1 - && count-- > 0 - && handle->io_watcher.fd != -1 - && handle->recv_cb != NULL); -} - - -static void uv__udp_sendmsg(uv_udp_t* handle) { - uv_udp_send_t* req; - QUEUE* q; - struct msghdr h; - ssize_t size; - - while (!QUEUE_EMPTY(&handle->write_queue)) { - q = QUEUE_HEAD(&handle->write_queue); - assert(q != NULL); - - req = QUEUE_DATA(q, uv_udp_send_t, queue); - assert(req != NULL); - - memset(&h, 0, sizeof h); - h.msg_name = &req->addr; - h.msg_namelen = (req->addr.ss_family == AF_INET6 ? - sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)); - h.msg_iov = (struct iovec*) req->bufs; - h.msg_iovlen = req->nbufs; - - do { - size = sendmsg(handle->io_watcher.fd, &h, 0); - } while (size == -1 && errno == EINTR); - - if (size == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) - break; - - req->status = (size == -1 ? -errno : size); - - /* Sending a datagram is an atomic operation: either all data - * is written or nothing is (and EMSGSIZE is raised). That is - * why we don't handle partial writes. Just pop the request - * off the write queue and onto the completed queue, done. - */ - QUEUE_REMOVE(&req->queue); - QUEUE_INSERT_TAIL(&handle->write_completed_queue, &req->queue); - uv__io_feed(handle->loop, &handle->io_watcher); - } -} - - -/* On the BSDs, SO_REUSEPORT implies SO_REUSEADDR but with some additional - * refinements for programs that use multicast. - * - * Linux as of 3.9 has a SO_REUSEPORT socket option but with semantics that - * are different from the BSDs: it _shares_ the port rather than steal it - * from the current listener. While useful, it's not something we can emulate - * on other platforms so we don't enable it. - */ -static int uv__set_reuse(int fd) { - int yes; - -#if defined(SO_REUSEPORT) && !defined(__linux__) - yes = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes))) - return -errno; -#else - yes = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes))) - return -errno; -#endif - - return 0; -} - - -int uv__udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - int yes; - int fd; - - /* Check for bad flags. */ - if (flags & ~(UV_UDP_IPV6ONLY | UV_UDP_REUSEADDR)) - return -EINVAL; - - /* Cannot set IPv6-only mode on non-IPv6 socket. */ - if ((flags & UV_UDP_IPV6ONLY) && addr->sa_family != AF_INET6) - return -EINVAL; - - fd = handle->io_watcher.fd; - if (fd == -1) { - err = uv__socket(addr->sa_family, SOCK_DGRAM, 0); - if (err < 0) - return err; - fd = err; - handle->io_watcher.fd = fd; - } - - if (flags & UV_UDP_REUSEADDR) { - err = uv__set_reuse(fd); - if (err) - return err; - } - - if (flags & UV_UDP_IPV6ONLY) { -#ifdef IPV6_V6ONLY - yes = 1; - if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof yes) == -1) { - err = -errno; - return err; - } -#else - err = -ENOTSUP; - return err; -#endif - } - - if (bind(fd, addr, addrlen)) { - err = -errno; - if (errno == EAFNOSUPPORT) - /* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a - * socket created with AF_INET to an AF_INET6 address or vice versa. */ - err = -EINVAL; - return err; - } - - if (addr->sa_family == AF_INET6) - handle->flags |= UV_HANDLE_IPV6; - - handle->flags |= UV_HANDLE_BOUND; - return 0; -} - - -static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, - int domain, - unsigned int flags) { - union { - struct sockaddr_in6 in6; - struct sockaddr_in in; - struct sockaddr addr; - } taddr; - socklen_t addrlen; - - if (handle->io_watcher.fd != -1) - return 0; - - switch (domain) { - case AF_INET: - { - struct sockaddr_in* addr = &taddr.in; - memset(addr, 0, sizeof *addr); - addr->sin_family = AF_INET; - addr->sin_addr.s_addr = INADDR_ANY; - addrlen = sizeof *addr; - break; - } - case AF_INET6: - { - struct sockaddr_in6* addr = &taddr.in6; - memset(addr, 0, sizeof *addr); - addr->sin6_family = AF_INET6; - addr->sin6_addr = in6addr_any; - addrlen = sizeof *addr; - break; - } - default: - assert(0 && "unsupported address family"); - abort(); - } - - return uv__udp_bind(handle, &taddr.addr, addrlen, flags); -} - - -int uv__udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb send_cb) { - int err; - int empty_queue; - - assert(nbufs > 0); - - err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0); - if (err) - return err; - - /* It's legal for send_queue_count > 0 even when the write_queue is empty; - * it means there are error-state requests in the write_completed_queue that - * will touch up send_queue_size/count later. - */ - empty_queue = (handle->send_queue_count == 0); - - uv__req_init(handle->loop, req, UV_UDP_SEND); - assert(addrlen <= sizeof(req->addr)); - memcpy(&req->addr, addr, addrlen); - req->send_cb = send_cb; - req->handle = handle; - req->nbufs = nbufs; - - req->bufs = req->bufsml; - if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = uv__malloc(nbufs * sizeof(bufs[0])); - - if (req->bufs == NULL) { - uv__req_unregister(handle->loop, req); - return -ENOMEM; - } - - memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0])); - handle->send_queue_size += uv__count_bufs(req->bufs, req->nbufs); - handle->send_queue_count++; - QUEUE_INSERT_TAIL(&handle->write_queue, &req->queue); - uv__handle_start(handle); - - if (empty_queue && !(handle->flags & UV_UDP_PROCESSING)) { - uv__udp_sendmsg(handle); - - /* `uv__udp_sendmsg` may not be able to do non-blocking write straight - * away. In such cases the `io_watcher` has to be queued for asynchronous - * write. - */ - if (!QUEUE_EMPTY(&handle->write_queue)) - uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); - } else { - uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); - } - - return 0; -} - - -int uv__udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen) { - int err; - struct msghdr h; - ssize_t size; - - assert(nbufs > 0); - - /* already sending a message */ - if (handle->send_queue_count != 0) - return -EAGAIN; - - err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0); - if (err) - return err; - - memset(&h, 0, sizeof h); - h.msg_name = (struct sockaddr*) addr; - h.msg_namelen = addrlen; - h.msg_iov = (struct iovec*) bufs; - h.msg_iovlen = nbufs; - - do { - size = sendmsg(handle->io_watcher.fd, &h, 0); - } while (size == -1 && errno == EINTR); - - if (size == -1) { - if (errno == EAGAIN || errno == EWOULDBLOCK) - return -EAGAIN; - else - return -errno; - } - - return size; -} - - -static int uv__udp_set_membership4(uv_udp_t* handle, - const struct sockaddr_in* multicast_addr, - const char* interface_addr, - uv_membership membership) { - struct ip_mreq mreq; - int optname; - int err; - - memset(&mreq, 0, sizeof mreq); - - if (interface_addr) { - err = uv_inet_pton(AF_INET, interface_addr, &mreq.imr_interface.s_addr); - if (err) - return err; - } else { - mreq.imr_interface.s_addr = htonl(INADDR_ANY); - } - - mreq.imr_multiaddr.s_addr = multicast_addr->sin_addr.s_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IP_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IP_DROP_MEMBERSHIP; - break; - default: - return -EINVAL; - } - - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IP, - optname, - &mreq, - sizeof(mreq))) { -#if defined(__MVS__) - if (errno == ENXIO) - return -ENODEV; -#endif - return -errno; - } - - return 0; -} - - -static int uv__udp_set_membership6(uv_udp_t* handle, - const struct sockaddr_in6* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int optname; - struct ipv6_mreq mreq; - struct sockaddr_in6 addr6; - - memset(&mreq, 0, sizeof mreq); - - if (interface_addr) { - if (uv_ip6_addr(interface_addr, 0, &addr6)) - return -EINVAL; - mreq.ipv6mr_interface = addr6.sin6_scope_id; - } else { - mreq.ipv6mr_interface = 0; - } - - mreq.ipv6mr_multiaddr = multicast_addr->sin6_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IPV6_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IPV6_DROP_MEMBERSHIP; - break; - default: - return -EINVAL; - } - - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IPV6, - optname, - &mreq, - sizeof(mreq))) { -#if defined(__MVS__) - if (errno == ENXIO) - return -ENODEV; -#endif - return -errno; - } - - return 0; -} - - -int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) { - int domain; - int err; - int fd; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return -EINVAL; - - if (flags & ~0xFF) - return -EINVAL; - - if (domain != AF_UNSPEC) { - err = uv__socket(domain, SOCK_DGRAM, 0); - if (err < 0) - return err; - fd = err; - } else { - fd = -1; - } - - uv__handle_init(loop, (uv_handle_t*)handle, UV_UDP); - handle->alloc_cb = NULL; - handle->recv_cb = NULL; - handle->send_queue_size = 0; - handle->send_queue_count = 0; - uv__io_init(&handle->io_watcher, uv__udp_io, fd); - QUEUE_INIT(&handle->write_queue); - QUEUE_INIT(&handle->write_completed_queue); - return 0; -} - - -int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) { - return uv_udp_init_ex(loop, handle, AF_UNSPEC); -} - - -int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { - int err; - - /* Check for already active socket. */ - if (handle->io_watcher.fd != -1) - return -EBUSY; - - err = uv__nonblock(sock, 1); - if (err) - return err; - - err = uv__set_reuse(sock); - if (err) - return err; - - handle->io_watcher.fd = sock; - return 0; -} - - -int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int err; - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - - if (uv_ip4_addr(multicast_addr, 0, &addr4) == 0) { - err = uv__udp_maybe_deferred_bind(handle, AF_INET, UV_UDP_REUSEADDR); - if (err) - return err; - return uv__udp_set_membership4(handle, &addr4, interface_addr, membership); - } else if (uv_ip6_addr(multicast_addr, 0, &addr6) == 0) { - err = uv__udp_maybe_deferred_bind(handle, AF_INET6, UV_UDP_REUSEADDR); - if (err) - return err; - return uv__udp_set_membership6(handle, &addr6, interface_addr, membership); - } else { - return -EINVAL; - } -} - -static int uv__setsockopt(uv_udp_t* handle, - int option4, - int option6, - const void* val, - size_t size) { - int r; - - if (handle->flags & UV_HANDLE_IPV6) - r = setsockopt(handle->io_watcher.fd, - IPPROTO_IPV6, - option6, - val, - size); - else - r = setsockopt(handle->io_watcher.fd, - IPPROTO_IP, - option4, - val, - size); - if (r) - return -errno; - - return 0; -} - -static int uv__setsockopt_maybe_char(uv_udp_t* handle, - int option4, - int option6, - int val) { -#if defined(__sun) || defined(_AIX) || defined(__MVS__) - char arg = val; -#elif defined(__OpenBSD__) - unsigned char arg = val; -#else - int arg = val; -#endif - - if (val < 0 || val > 255) - return -EINVAL; - - return uv__setsockopt(handle, option4, option6, &arg, sizeof(arg)); -} - - -int uv_udp_set_broadcast(uv_udp_t* handle, int on) { - if (setsockopt(handle->io_watcher.fd, - SOL_SOCKET, - SO_BROADCAST, - &on, - sizeof(on))) { - return -errno; - } - - return 0; -} - - -int uv_udp_set_ttl(uv_udp_t* handle, int ttl) { - if (ttl < 1 || ttl > 255) - return -EINVAL; - -#if defined(__MVS__) - if (!(handle->flags & UV_HANDLE_IPV6)) - return -ENOTSUP; /* zOS does not support setting ttl for IPv4 */ -#endif - -/* - * On Solaris and derivatives such as SmartOS, the length of socket options - * is sizeof(int) for IP_TTL and IPV6_UNICAST_HOPS, - * so hardcode the size of these options on this platform, - * and use the general uv__setsockopt_maybe_char call on other platforms. - */ -#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ - defined(__MVS__) - - return uv__setsockopt(handle, - IP_TTL, - IPV6_UNICAST_HOPS, - &ttl, - sizeof(ttl)); -#endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) || - defined(__MVS__) */ - - return uv__setsockopt_maybe_char(handle, - IP_TTL, - IPV6_UNICAST_HOPS, - ttl); -} - - -int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) { -/* - * On Solaris and derivatives such as SmartOS, the length of socket options - * is sizeof(int) for IPV6_MULTICAST_HOPS and sizeof(char) for - * IP_MULTICAST_TTL, so hardcode the size of the option in the IPv6 case, - * and use the general uv__setsockopt_maybe_char call otherwise. - */ -#if defined(__sun) || defined(_AIX) || defined(__MVS__) - if (handle->flags & UV_HANDLE_IPV6) - return uv__setsockopt(handle, - IP_MULTICAST_TTL, - IPV6_MULTICAST_HOPS, - &ttl, - sizeof(ttl)); -#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */ - - return uv__setsockopt_maybe_char(handle, - IP_MULTICAST_TTL, - IPV6_MULTICAST_HOPS, - ttl); -} - - -int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) { -/* - * On Solaris and derivatives such as SmartOS, the length of socket options - * is sizeof(int) for IPV6_MULTICAST_LOOP and sizeof(char) for - * IP_MULTICAST_LOOP, so hardcode the size of the option in the IPv6 case, - * and use the general uv__setsockopt_maybe_char call otherwise. - */ -#if defined(__sun) || defined(_AIX) || defined(__MVS__) - if (handle->flags & UV_HANDLE_IPV6) - return uv__setsockopt(handle, - IP_MULTICAST_LOOP, - IPV6_MULTICAST_LOOP, - &on, - sizeof(on)); -#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */ - - return uv__setsockopt_maybe_char(handle, - IP_MULTICAST_LOOP, - IPV6_MULTICAST_LOOP, - on); -} - -int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) { - struct sockaddr_storage addr_st; - struct sockaddr_in* addr4; - struct sockaddr_in6* addr6; - - addr4 = (struct sockaddr_in*) &addr_st; - addr6 = (struct sockaddr_in6*) &addr_st; - - if (!interface_addr) { - memset(&addr_st, 0, sizeof addr_st); - if (handle->flags & UV_HANDLE_IPV6) { - addr_st.ss_family = AF_INET6; - addr6->sin6_scope_id = 0; - } else { - addr_st.ss_family = AF_INET; - addr4->sin_addr.s_addr = htonl(INADDR_ANY); - } - } else if (uv_ip4_addr(interface_addr, 0, addr4) == 0) { - /* nothing, address was parsed */ - } else if (uv_ip6_addr(interface_addr, 0, addr6) == 0) { - /* nothing, address was parsed */ - } else { - return -EINVAL; - } - - if (addr_st.ss_family == AF_INET) { - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IP, - IP_MULTICAST_IF, - (void*) &addr4->sin_addr, - sizeof(addr4->sin_addr)) == -1) { - return -errno; - } - } else if (addr_st.ss_family == AF_INET6) { - if (setsockopt(handle->io_watcher.fd, - IPPROTO_IPV6, - IPV6_MULTICAST_IF, - &addr6->sin6_scope_id, - sizeof(addr6->sin6_scope_id)) == -1) { - return -errno; - } - } else { - assert(0 && "unexpected address family"); - abort(); - } - - return 0; -} - - -int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen) { - socklen_t socklen; - - if (handle->io_watcher.fd == -1) - return -EINVAL; /* FIXME(bnoordhuis) -EBADF */ - - /* sizeof(socklen_t) != sizeof(int) on some systems. */ - socklen = (socklen_t) *namelen; - - if (getsockname(handle->io_watcher.fd, name, &socklen)) - return -errno; - - *namelen = (int) socklen; - return 0; -} - - -int uv__udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb) { - int err; - - if (alloc_cb == NULL || recv_cb == NULL) - return -EINVAL; - - if (uv__io_active(&handle->io_watcher, POLLIN)) - return -EALREADY; /* FIXME(bnoordhuis) Should be -EBUSY. */ - - err = uv__udp_maybe_deferred_bind(handle, AF_INET, 0); - if (err) - return err; - - handle->alloc_cb = alloc_cb; - handle->recv_cb = recv_cb; - - uv__io_start(handle->loop, &handle->io_watcher, POLLIN); - uv__handle_start(handle); - - return 0; -} - - -int uv__udp_recv_stop(uv_udp_t* handle) { - uv__io_stop(handle->loop, &handle->io_watcher, POLLIN); - - if (!uv__io_active(&handle->io_watcher, POLLOUT)) - uv__handle_stop(handle); - - handle->alloc_cb = NULL; - handle->recv_cb = NULL; - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-aix.h b/lib/ESPiLight/pilight/libs/libuv/uv-aix.h deleted file mode 100644 index 7dc992f..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-aix.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_AIX_H -#define UV_AIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - int fs_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char *dir_filename; \ - -#endif /* UV_AIX_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-bsd.h b/lib/ESPiLight/pilight/libs/libuv/uv-bsd.h deleted file mode 100644 index 914d717..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-bsd.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_BSD_H -#define UV_BSD_H - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -/* - * NEW - */ -#define UV_PLATFORM_LOOP_FIELDS \ - struct pollfd* poll_fds; \ - size_t poll_fds_used; \ - size_t poll_fds_size; \ - unsigned char poll_fds_iterating; \ -/* - * - */ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_BSD_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-common.c b/lib/ESPiLight/pilight/libs/libuv/uv-common.c deleted file mode 100644 index bc7d137..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-common.c +++ /dev/null @@ -1,664 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "uv-common.h" - -#include -#include -#include -#include /* NULL */ -#include -#include /* malloc */ -#include /* memset */ - -#if defined(_WIN32) -# include /* malloc */ -#else -# include /* if_nametoindex */ -#endif - - -typedef struct { - uv_malloc_func local_malloc; - uv_realloc_func local_realloc; - uv_calloc_func local_calloc; - uv_free_func local_free; -} uv__allocator_t; - -static uv__allocator_t uv__allocator = { - malloc, - realloc, - calloc, - free, -}; - -char* uv__strdup(const char* s) { - size_t len = strlen(s) + 1; - char* m = uv__malloc(len); - if (m == NULL) - return NULL; - return memcpy(m, s, len); -} - -char* uv__strndup(const char* s, size_t n) { - char* m; - size_t len = strlen(s); - if (n < len) - len = n; - m = uv__malloc(len + 1); - if (m == NULL) - return NULL; - m[len] = '\0'; - return memcpy(m, s, len); -} - -void* uv__malloc(size_t size) { - return uv__allocator.local_malloc(size); -} - -void uv__free(void* ptr) { - int saved_errno; - - /* Libuv expects that free() does not clobber errno. The system allocator - * honors that assumption but custom allocators may not be so careful. - */ - saved_errno = errno; - uv__allocator.local_free(ptr); - errno = saved_errno; -} - -void* uv__calloc(size_t count, size_t size) { - return uv__allocator.local_calloc(count, size); -} - -void* uv__realloc(void* ptr, size_t size) { - return uv__allocator.local_realloc(ptr, size); -} - -int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func) { - if (malloc_func == NULL || realloc_func == NULL || - calloc_func == NULL || free_func == NULL) { - return UV_EINVAL; - } - - uv__allocator.local_malloc = malloc_func; - uv__allocator.local_realloc = realloc_func; - uv__allocator.local_calloc = calloc_func; - uv__allocator.local_free = free_func; - - return 0; -} - -#define XX(uc, lc) case UV_##uc: return sizeof(uv_##lc##_t); - -size_t uv_handle_size(uv_handle_type type) { - switch (type) { - UV_HANDLE_TYPE_MAP(XX) - default: - return -1; - } -} - -size_t uv_req_size(uv_req_type type) { - switch(type) { - UV_REQ_TYPE_MAP(XX) - default: - return -1; - } -} - -#undef XX - - -size_t uv_loop_size(void) { - return sizeof(uv_loop_t); -} - - -uv_buf_t uv_buf_init(char* base, unsigned int len) { - uv_buf_t buf; - buf.base = base; - buf.len = len; - return buf; -} - - -static const char* uv__unknown_err_code(int err) { - char buf[32]; - char* copy; - - snprintf(buf, sizeof(buf), "Unknown system error %d", err); - copy = uv__strdup(buf); - - return copy != NULL ? copy : "Unknown system error"; -} - - -#define UV_ERR_NAME_GEN(name, _) case UV_ ## name: return #name; -const char* uv_err_name(int err) { - switch (err) { - UV_ERRNO_MAP(UV_ERR_NAME_GEN) - } - return uv__unknown_err_code(err); -} -#undef UV_ERR_NAME_GEN - - -#define UV_STRERROR_GEN(name, msg) case UV_ ## name: return msg; -const char* uv_strerror(int err) { - switch (err) { - UV_ERRNO_MAP(UV_STRERROR_GEN) - } - return uv__unknown_err_code(err); -} -#undef UV_STRERROR_GEN - - -int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr) { - memset(addr, 0, sizeof(*addr)); - addr->sin_family = AF_INET; - addr->sin_port = htons(port); - return uv_inet_pton(AF_INET, ip, &(addr->sin_addr.s_addr)); -} - - -int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr) { - char address_part[40]; - size_t address_part_size; - const char* zone_index; - - memset(addr, 0, sizeof(*addr)); - addr->sin6_family = AF_INET6; - addr->sin6_port = htons(port); - - zone_index = strchr(ip, '%'); - if (zone_index != NULL) { - address_part_size = zone_index - ip; - if (address_part_size >= sizeof(address_part)) - address_part_size = sizeof(address_part) - 1; - - memcpy(address_part, ip, address_part_size); - address_part[address_part_size] = '\0'; - ip = address_part; - - zone_index++; /* skip '%' */ - /* NOTE: unknown interface (id=0) is silently ignored */ -#ifdef _WIN32 - addr->sin6_scope_id = atoi(zone_index); -#else - addr->sin6_scope_id = if_nametoindex(zone_index); -#endif - } - - return uv_inet_pton(AF_INET6, ip, &addr->sin6_addr); -} - - -int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size) { - return uv_inet_ntop(AF_INET, &src->sin_addr, dst, size); -} - - -int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size) { - return uv_inet_ntop(AF_INET6, &src->sin6_addr, dst, size); -} - - -int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags) { - unsigned int addrlen; - - if (handle->type != UV_TCP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__tcp_bind(handle, addr, addrlen, flags); -} - - -int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags) { - unsigned int addrlen; - - if (handle->type != UV_UDP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__udp_bind(handle, addr, addrlen, flags); -} - - -int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb) { - unsigned int addrlen; - - if (handle->type != UV_TCP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__tcp_connect(req, handle, addr, addrlen, cb); -} - - -int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb) { - unsigned int addrlen; - - if (handle->type != UV_UDP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__udp_send(req, handle, bufs, nbufs, addr, addrlen, send_cb); -} - - -int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr) { - unsigned int addrlen; - - if (handle->type != UV_UDP) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) - addrlen = sizeof(struct sockaddr_in); - else if (addr->sa_family == AF_INET6) - addrlen = sizeof(struct sockaddr_in6); - else - return UV_EINVAL; - - return uv__udp_try_send(handle, bufs, nbufs, addr, addrlen); -} - - -int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb) { - if (handle->type != UV_UDP || alloc_cb == NULL || recv_cb == NULL) - return UV_EINVAL; - else - return uv__udp_recv_start(handle, alloc_cb, recv_cb); -} - - -int uv_udp_recv_stop(uv_udp_t* handle) { - if (handle->type != UV_UDP) - return UV_EINVAL; - else - return uv__udp_recv_stop(handle); -} - - -void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) { - QUEUE queue; - QUEUE* q; - uv_handle_t* h; - - QUEUE_MOVE(&loop->handle_queue, &queue); - while (!QUEUE_EMPTY(&queue)) { - q = QUEUE_HEAD(&queue); - h = QUEUE_DATA(q, uv_handle_t, handle_queue); - - QUEUE_REMOVE(q); - QUEUE_INSERT_TAIL(&loop->handle_queue, q); - - if (h->flags & UV__HANDLE_INTERNAL) continue; - walk_cb(h, arg); - } -} - - -static void uv__print_handles(uv_loop_t* loop, int only_active, FILE* stream) { - const char* type; - QUEUE* q; - uv_handle_t* h; - - if (loop == NULL) - loop = uv_default_loop(); - - QUEUE_FOREACH(q, &loop->handle_queue) { - h = QUEUE_DATA(q, uv_handle_t, handle_queue); - - if (only_active && !uv__is_active(h)) - continue; - - switch (h->type) { -#define X(uc, lc) case UV_##uc: type = #lc; break; - UV_HANDLE_TYPE_MAP(X) -#undef X - default: type = ""; - } - - fprintf(stream, - "[%c%c%c] %-8s %p\n", - "R-"[!(h->flags & UV__HANDLE_REF)], - "A-"[!(h->flags & UV__HANDLE_ACTIVE)], - "I-"[!(h->flags & UV__HANDLE_INTERNAL)], - type, - (void*)h); - } -} - - -void uv_print_all_handles(uv_loop_t* loop, FILE* stream) { - uv__print_handles(loop, 0, stream); -} - - -void uv_print_active_handles(uv_loop_t* loop, FILE* stream) { - uv__print_handles(loop, 1, stream); -} - - -void uv_ref(uv_handle_t* handle) { - uv__handle_ref(handle); -} - - -void uv_unref(uv_handle_t* handle) { - uv__handle_unref(handle); -} - - -int uv_has_ref(const uv_handle_t* handle) { - return uv__has_ref(handle); -} - - -void uv_stop(uv_loop_t* loop) { - loop->stop_flag = 1; -} - - -uint64_t uv_now(const uv_loop_t* loop) { - return loop->time; -} - - - -size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs) { - unsigned int i; - size_t bytes; - - bytes = 0; - for (i = 0; i < nbufs; i++) - bytes += (size_t) bufs[i].len; - - return bytes; -} - -int uv_recv_buffer_size(uv_handle_t* handle, int* value) { - return uv__socket_sockopt(handle, SO_RCVBUF, value); -} - -int uv_send_buffer_size(uv_handle_t* handle, int *value) { - return uv__socket_sockopt(handle, SO_SNDBUF, value); -} - -int uv_fs_event_getpath(uv_fs_event_t* handle, char* buffer, size_t* size) { - size_t required_len; - - if (!uv__is_active(handle)) { - *size = 0; - return UV_EINVAL; - } - - required_len = strlen(handle->path); - if (required_len >= *size) { - *size = required_len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, handle->path, required_len); - *size = required_len; - buffer[required_len] = '\0'; - - return 0; -} - -/* The windows implementation does not have the same structure layout as - * the unix implementation (nbufs is not directly inside req but is - * contained in a nested union/struct) so this function locates it. -*/ -static unsigned int* uv__get_nbufs(uv_fs_t* req) { -#ifdef _WIN32 - return &req->fs.info.nbufs; -#else - return &req->nbufs; -#endif -} - -/* uv_fs_scandir() uses the system allocator to allocate memory on non-Windows - * systems. So, the memory should be released using free(). On Windows, - * uv__malloc() is used, so use uv__free() to free memory. -*/ -#ifdef _WIN32 -# define uv__fs_scandir_free uv__free -#else -# define uv__fs_scandir_free free -#endif - -void uv__fs_scandir_cleanup(uv_fs_t* req) { - uv__dirent_t** dents; - - unsigned int* nbufs = uv__get_nbufs(req); - - dents = req->ptr; - if (*nbufs > 0 && *nbufs != (unsigned int) req->result) - (*nbufs)--; - for (; *nbufs < (unsigned int) req->result; (*nbufs)++) - uv__fs_scandir_free(dents[*nbufs]); - - uv__fs_scandir_free(req->ptr); - req->ptr = NULL; -} - - -int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) { - uv__dirent_t** dents; - uv__dirent_t* dent; - unsigned int* nbufs; - - /* Check to see if req passed */ - if (req->result < 0) - return req->result; - - /* Ptr will be null if req was canceled or no files found */ - if (!req->ptr) - return UV_EOF; - - nbufs = uv__get_nbufs(req); - assert(nbufs); - - dents = req->ptr; - - /* Free previous entity */ - if (*nbufs > 0) - uv__fs_scandir_free(dents[*nbufs - 1]); - - /* End was already reached */ - if (*nbufs == (unsigned int) req->result) { - uv__fs_scandir_free(dents); - req->ptr = NULL; - return UV_EOF; - } - - dent = dents[(*nbufs)++]; - - ent->name = dent->d_name; -#ifdef HAVE_DIRENT_TYPES - switch (dent->d_type) { - case UV__DT_DIR: - ent->type = UV_DIRENT_DIR; - break; - case UV__DT_FILE: - ent->type = UV_DIRENT_FILE; - break; - case UV__DT_LINK: - ent->type = UV_DIRENT_LINK; - break; - case UV__DT_FIFO: - ent->type = UV_DIRENT_FIFO; - break; - case UV__DT_SOCKET: - ent->type = UV_DIRENT_SOCKET; - break; - case UV__DT_CHAR: - ent->type = UV_DIRENT_CHAR; - break; - case UV__DT_BLOCK: - ent->type = UV_DIRENT_BLOCK; - break; - default: - ent->type = UV_DIRENT_UNKNOWN; - } -#else - ent->type = UV_DIRENT_UNKNOWN; -#endif - - return 0; -} - - -int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) { - va_list ap; - int err; - - va_start(ap, option); - /* Any platform-agnostic options should be handled here. */ - err = uv__loop_configure(loop, option, ap); - va_end(ap); - - return err; -} - - -static uv_loop_t default_loop_struct; -static uv_loop_t* default_loop_ptr; - - -uv_loop_t* uv_default_loop(void) { - if (default_loop_ptr != NULL) - return default_loop_ptr; - - if (uv_loop_init(&default_loop_struct)) - return NULL; - - default_loop_ptr = &default_loop_struct; - return default_loop_ptr; -} - - -uv_loop_t* uv_loop_new(void) { - uv_loop_t* loop; - - loop = uv__malloc(sizeof(*loop)); - if (loop == NULL) - return NULL; - - if (uv_loop_init(loop)) { - uv__free(loop); - return NULL; - } - - return loop; -} - - -int uv_loop_close(uv_loop_t* loop) { - QUEUE* q; - uv_handle_t* h; -#ifndef NDEBUG - void* saved_data; -#endif - - if (!QUEUE_EMPTY(&(loop)->active_reqs)) - return UV_EBUSY; - - QUEUE_FOREACH(q, &loop->handle_queue) { - h = QUEUE_DATA(q, uv_handle_t, handle_queue); - if (!(h->flags & UV__HANDLE_INTERNAL)) - return UV_EBUSY; - } - - uv__loop_close(loop); - -#ifndef NDEBUG - saved_data = loop->data; - memset(loop, -1, sizeof(*loop)); - loop->data = saved_data; -#endif - if (loop == default_loop_ptr) - default_loop_ptr = NULL; - - return 0; -} - - -void uv_loop_delete(uv_loop_t* loop) { - uv_loop_t* default_loop; - int err; - - default_loop = default_loop_ptr; - - err = uv_loop_close(loop); - (void) err; /* Squelch compiler warnings. */ - assert(err == 0); - if (loop != default_loop) - uv__free(loop); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-common.h b/lib/ESPiLight/pilight/libs/libuv/uv-common.h deleted file mode 100644 index 781a855..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-common.h +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_COMMON_H_ -#define UV_COMMON_H_ - -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#include "uv.h" -#include "tree.h" -#include "queue.h" - -#if !defined(snprintf) && defined(_MSC_VER) && _MSC_VER < 1900 -extern int snprintf(char*, size_t, const char*, ...); -#endif - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - -#define container_of(ptr, type, member) \ - ((type *) ((char *) (ptr) - offsetof(type, member))) - -#define STATIC_ASSERT(expr) \ - void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)]) - -#ifndef _WIN32 -enum { - UV__SIGNAL_ONE_SHOT = 0x80000, /* On signal reception remove sighandler */ - UV__HANDLE_INTERNAL = 0x8000, - UV__HANDLE_ACTIVE = 0x4000, - UV__HANDLE_REF = 0x2000, - UV__HANDLE_CLOSING = 0 /* no-op on unix */ -}; -#else -# define UV__SIGNAL_ONE_SHOT_DISPATCHED 0x200 -# define UV__SIGNAL_ONE_SHOT 0x100 -# define UV__HANDLE_INTERNAL 0x80 -# define UV__HANDLE_ACTIVE 0x40 -# define UV__HANDLE_REF 0x20 -# define UV__HANDLE_CLOSING 0x01 -#endif - -int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap); - -void uv__loop_close(uv_loop_t* loop); - -int uv__tcp_bind(uv_tcp_t* tcp, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags); - -int uv__tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb); - -int uv__udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags); - -int uv__udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb send_cb); - -int uv__udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen); - -int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloccb, - uv_udp_recv_cb recv_cb); - -int uv__udp_recv_stop(uv_udp_t* handle); - -void uv__fs_poll_close(uv_fs_poll_t* handle); - -int uv__getaddrinfo_translate_error(int sys_err); /* EAI_* error. */ - -void uv__work_submit(uv_loop_t* loop, - struct uv__work *w, - void (*work)(struct uv__work *w), - void (*done)(struct uv__work *w, int status)); - -void uv__work_done(uv_async_t* handle); - -size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs); - -int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value); - -void uv__fs_scandir_cleanup(uv_fs_t* req); - -#define uv__has_active_reqs(loop) \ - (QUEUE_EMPTY(&(loop)->active_reqs) == 0) - -#define uv__req_register(loop, req) \ - do { \ - QUEUE_INSERT_TAIL(&(loop)->active_reqs, &(req)->active_queue); \ - } \ - while (0) - -#define uv__req_unregister(loop, req) \ - do { \ - assert(uv__has_active_reqs(loop)); \ - QUEUE_REMOVE(&(req)->active_queue); \ - } \ - while (0) - -#define uv__has_active_handles(loop) \ - ((loop)->active_handles > 0) - -#define uv__active_handle_add(h) \ - do { \ - (h)->loop->active_handles++; \ - } \ - while (0) - -#define uv__active_handle_rm(h) \ - do { \ - (h)->loop->active_handles--; \ - } \ - while (0) - -#define uv__is_active(h) \ - (((h)->flags & UV__HANDLE_ACTIVE) != 0) - -#define uv__is_closing(h) \ - (((h)->flags & (UV_CLOSING | UV_CLOSED)) != 0) - -#define uv__handle_start(h) \ - do { \ - assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) break; \ - (h)->flags |= UV__HANDLE_ACTIVE; \ - if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_add(h); \ - } \ - while (0) - -#define uv__handle_stop(h) \ - do { \ - assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \ - if (((h)->flags & UV__HANDLE_ACTIVE) == 0) break; \ - (h)->flags &= ~UV__HANDLE_ACTIVE; \ - if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_rm(h); \ - } \ - while (0) - -#define uv__handle_ref(h) \ - do { \ - if (((h)->flags & UV__HANDLE_REF) != 0) break; \ - (h)->flags |= UV__HANDLE_REF; \ - if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_add(h); \ - } \ - while (0) - -#define uv__handle_unref(h) \ - do { \ - if (((h)->flags & UV__HANDLE_REF) == 0) break; \ - (h)->flags &= ~UV__HANDLE_REF; \ - if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \ - if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_rm(h); \ - } \ - while (0) - -#define uv__has_ref(h) \ - (((h)->flags & UV__HANDLE_REF) != 0) - -#if defined(_WIN32) -# define uv__handle_platform_init(h) ((h)->u.fd = -1) -#else -# define uv__handle_platform_init(h) ((h)->next_closing = NULL) -#endif - -#define uv__handle_init(loop_, h, type_) \ - do { \ - (h)->loop = (loop_); \ - (h)->type = (type_); \ - (h)->flags = UV__HANDLE_REF; /* Ref the loop when active. */ \ - QUEUE_INSERT_TAIL(&(loop_)->handle_queue, &(h)->handle_queue); \ - uv__handle_platform_init(h); \ - } \ - while (0) - -/* Note: uses an open-coded version of SET_REQ_SUCCESS() because of - * a circular dependency between src/uv-common.h and src/win/internal.h. - */ -#if defined(_WIN32) -# define UV_REQ_INIT(req, typ) \ - do { \ - (req)->type = (typ); \ - (req)->u.io.overlapped.Internal = 0; /* SET_REQ_SUCCESS() */ \ - } \ - while (0) -#else -# define UV_REQ_INIT(req, typ) \ - do { \ - (req)->type = (typ); \ - } \ - while (0) -#endif - -#define uv__req_init(loop, req, typ) \ - do { \ - UV_REQ_INIT(req, typ); \ - uv__req_register(loop, req); \ - } \ - while (0) - -/* Allocator prototypes */ -void *uv__calloc(size_t count, size_t size); -char *uv__strdup(const char* s); -char *uv__strndup(const char* s, size_t n); -void* uv__malloc(size_t size); -void uv__free(void* ptr); -void* uv__realloc(void* ptr, size_t size); - -#endif /* UV_COMMON_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-darwin.h b/lib/ESPiLight/pilight/libs/libuv/uv-darwin.h deleted file mode 100644 index d226415..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-darwin.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_DARWIN_H -#define UV_DARWIN_H - -#if defined(__APPLE__) && defined(__MACH__) -# include -# include -# include -# include -# define UV_PLATFORM_SEM_T semaphore_t -#endif - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_PLATFORM_LOOP_FIELDS \ - uv_thread_t cf_thread; \ - void* _cf_reserved; \ - void* cf_state; \ - uv_mutex_t cf_mutex; \ - uv_sem_t cf_sem; \ - void* cf_signals[2]; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char* realpath; \ - int realpath_len; \ - int cf_flags; \ - uv_async_t* cf_cb; \ - void* cf_events[2]; \ - void* cf_member[2]; \ - int cf_error; \ - uv_mutex_t cf_mutex; \ - -#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - void* select; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_DARWIN_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-errno.h b/lib/ESPiLight/pilight/libs/libuv/uv-errno.h deleted file mode 100644 index f137151..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-errno.h +++ /dev/null @@ -1,419 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_ERRNO_H_ -#define UV_ERRNO_H_ - -#include - -#define UV__EOF (-4095) -#define UV__UNKNOWN (-4094) - -#define UV__EAI_ADDRFAMILY (-3000) -#define UV__EAI_AGAIN (-3001) -#define UV__EAI_BADFLAGS (-3002) -#define UV__EAI_CANCELED (-3003) -#define UV__EAI_FAIL (-3004) -#define UV__EAI_FAMILY (-3005) -#define UV__EAI_MEMORY (-3006) -#define UV__EAI_NODATA (-3007) -#define UV__EAI_NONAME (-3008) -#define UV__EAI_OVERFLOW (-3009) -#define UV__EAI_SERVICE (-3010) -#define UV__EAI_SOCKTYPE (-3011) -#define UV__EAI_BADHINTS (-3013) -#define UV__EAI_PROTOCOL (-3014) - -/* Only map to the system errno on non-Windows platforms. It's apparently - * a fairly common practice for Windows programmers to redefine errno codes. - */ -#if defined(E2BIG) && !defined(_WIN32) -# define UV__E2BIG (-E2BIG) -#else -# define UV__E2BIG (-4093) -#endif - -#if defined(EACCES) && !defined(_WIN32) -# define UV__EACCES (-EACCES) -#else -# define UV__EACCES (-4092) -#endif - -#if defined(EADDRINUSE) && !defined(_WIN32) -# define UV__EADDRINUSE (-EADDRINUSE) -#else -# define UV__EADDRINUSE (-4091) -#endif - -#if defined(EADDRNOTAVAIL) && !defined(_WIN32) -# define UV__EADDRNOTAVAIL (-EADDRNOTAVAIL) -#else -# define UV__EADDRNOTAVAIL (-4090) -#endif - -#if defined(EAFNOSUPPORT) && !defined(_WIN32) -# define UV__EAFNOSUPPORT (-EAFNOSUPPORT) -#else -# define UV__EAFNOSUPPORT (-4089) -#endif - -#if defined(EAGAIN) && !defined(_WIN32) -# define UV__EAGAIN (-EAGAIN) -#else -# define UV__EAGAIN (-4088) -#endif - -#if defined(EALREADY) && !defined(_WIN32) -# define UV__EALREADY (-EALREADY) -#else -# define UV__EALREADY (-4084) -#endif - -#if defined(EBADF) && !defined(_WIN32) -# define UV__EBADF (-EBADF) -#else -# define UV__EBADF (-4083) -#endif - -#if defined(EBUSY) && !defined(_WIN32) -# define UV__EBUSY (-EBUSY) -#else -# define UV__EBUSY (-4082) -#endif - -#if defined(ECANCELED) && !defined(_WIN32) -# define UV__ECANCELED (-ECANCELED) -#else -# define UV__ECANCELED (-4081) -#endif - -#if defined(ECHARSET) && !defined(_WIN32) -# define UV__ECHARSET (-ECHARSET) -#else -# define UV__ECHARSET (-4080) -#endif - -#if defined(ECONNABORTED) && !defined(_WIN32) -# define UV__ECONNABORTED (-ECONNABORTED) -#else -# define UV__ECONNABORTED (-4079) -#endif - -#if defined(ECONNREFUSED) && !defined(_WIN32) -# define UV__ECONNREFUSED (-ECONNREFUSED) -#else -# define UV__ECONNREFUSED (-4078) -#endif - -#if defined(ECONNRESET) && !defined(_WIN32) -# define UV__ECONNRESET (-ECONNRESET) -#else -# define UV__ECONNRESET (-4077) -#endif - -#if defined(EDESTADDRREQ) && !defined(_WIN32) -# define UV__EDESTADDRREQ (-EDESTADDRREQ) -#else -# define UV__EDESTADDRREQ (-4076) -#endif - -#if defined(EEXIST) && !defined(_WIN32) -# define UV__EEXIST (-EEXIST) -#else -# define UV__EEXIST (-4075) -#endif - -#if defined(EFAULT) && !defined(_WIN32) -# define UV__EFAULT (-EFAULT) -#else -# define UV__EFAULT (-4074) -#endif - -#if defined(EHOSTUNREACH) && !defined(_WIN32) -# define UV__EHOSTUNREACH (-EHOSTUNREACH) -#else -# define UV__EHOSTUNREACH (-4073) -#endif - -#if defined(EINTR) && !defined(_WIN32) -# define UV__EINTR (-EINTR) -#else -# define UV__EINTR (-4072) -#endif - -#if defined(EINVAL) && !defined(_WIN32) -# define UV__EINVAL (-EINVAL) -#else -# define UV__EINVAL (-4071) -#endif - -#if defined(EIO) && !defined(_WIN32) -# define UV__EIO (-EIO) -#else -# define UV__EIO (-4070) -#endif - -#if defined(EISCONN) && !defined(_WIN32) -# define UV__EISCONN (-EISCONN) -#else -# define UV__EISCONN (-4069) -#endif - -#if defined(EISDIR) && !defined(_WIN32) -# define UV__EISDIR (-EISDIR) -#else -# define UV__EISDIR (-4068) -#endif - -#if defined(ELOOP) && !defined(_WIN32) -# define UV__ELOOP (-ELOOP) -#else -# define UV__ELOOP (-4067) -#endif - -#if defined(EMFILE) && !defined(_WIN32) -# define UV__EMFILE (-EMFILE) -#else -# define UV__EMFILE (-4066) -#endif - -#if defined(EMSGSIZE) && !defined(_WIN32) -# define UV__EMSGSIZE (-EMSGSIZE) -#else -# define UV__EMSGSIZE (-4065) -#endif - -#if defined(ENAMETOOLONG) && !defined(_WIN32) -# define UV__ENAMETOOLONG (-ENAMETOOLONG) -#else -# define UV__ENAMETOOLONG (-4064) -#endif - -#if defined(ENETDOWN) && !defined(_WIN32) -# define UV__ENETDOWN (-ENETDOWN) -#else -# define UV__ENETDOWN (-4063) -#endif - -#if defined(ENETUNREACH) && !defined(_WIN32) -# define UV__ENETUNREACH (-ENETUNREACH) -#else -# define UV__ENETUNREACH (-4062) -#endif - -#if defined(ENFILE) && !defined(_WIN32) -# define UV__ENFILE (-ENFILE) -#else -# define UV__ENFILE (-4061) -#endif - -#if defined(ENOBUFS) && !defined(_WIN32) -# define UV__ENOBUFS (-ENOBUFS) -#else -# define UV__ENOBUFS (-4060) -#endif - -#if defined(ENODEV) && !defined(_WIN32) -# define UV__ENODEV (-ENODEV) -#else -# define UV__ENODEV (-4059) -#endif - -#if defined(ENOENT) && !defined(_WIN32) -# define UV__ENOENT (-ENOENT) -#else -# define UV__ENOENT (-4058) -#endif - -#if defined(ENOMEM) && !defined(_WIN32) -# define UV__ENOMEM (-ENOMEM) -#else -# define UV__ENOMEM (-4057) -#endif - -#if defined(ENONET) && !defined(_WIN32) -# define UV__ENONET (-ENONET) -#else -# define UV__ENONET (-4056) -#endif - -#if defined(ENOSPC) && !defined(_WIN32) -# define UV__ENOSPC (-ENOSPC) -#else -# define UV__ENOSPC (-4055) -#endif - -#if defined(ENOSYS) && !defined(_WIN32) -# define UV__ENOSYS (-ENOSYS) -#else -# define UV__ENOSYS (-4054) -#endif - -#if defined(ENOTCONN) && !defined(_WIN32) -# define UV__ENOTCONN (-ENOTCONN) -#else -# define UV__ENOTCONN (-4053) -#endif - -#if defined(ENOTDIR) && !defined(_WIN32) -# define UV__ENOTDIR (-ENOTDIR) -#else -# define UV__ENOTDIR (-4052) -#endif - -#if defined(ENOTEMPTY) && !defined(_WIN32) -# define UV__ENOTEMPTY (-ENOTEMPTY) -#else -# define UV__ENOTEMPTY (-4051) -#endif - -#if defined(ENOTSOCK) && !defined(_WIN32) -# define UV__ENOTSOCK (-ENOTSOCK) -#else -# define UV__ENOTSOCK (-4050) -#endif - -#if defined(ENOTSUP) && !defined(_WIN32) -# define UV__ENOTSUP (-ENOTSUP) -#else -# define UV__ENOTSUP (-4049) -#endif - -#if defined(EPERM) && !defined(_WIN32) -# define UV__EPERM (-EPERM) -#else -# define UV__EPERM (-4048) -#endif - -#if defined(EPIPE) && !defined(_WIN32) -# define UV__EPIPE (-EPIPE) -#else -# define UV__EPIPE (-4047) -#endif - -#if defined(EPROTO) && !defined(_WIN32) -# define UV__EPROTO (-EPROTO) -#else -# define UV__EPROTO (-4046) -#endif - -#if defined(EPROTONOSUPPORT) && !defined(_WIN32) -# define UV__EPROTONOSUPPORT (-EPROTONOSUPPORT) -#else -# define UV__EPROTONOSUPPORT (-4045) -#endif - -#if defined(EPROTOTYPE) && !defined(_WIN32) -# define UV__EPROTOTYPE (-EPROTOTYPE) -#else -# define UV__EPROTOTYPE (-4044) -#endif - -#if defined(EROFS) && !defined(_WIN32) -# define UV__EROFS (-EROFS) -#else -# define UV__EROFS (-4043) -#endif - -#if defined(ESHUTDOWN) && !defined(_WIN32) -# define UV__ESHUTDOWN (-ESHUTDOWN) -#else -# define UV__ESHUTDOWN (-4042) -#endif - -#if defined(ESPIPE) && !defined(_WIN32) -# define UV__ESPIPE (-ESPIPE) -#else -# define UV__ESPIPE (-4041) -#endif - -#if defined(ESRCH) && !defined(_WIN32) -# define UV__ESRCH (-ESRCH) -#else -# define UV__ESRCH (-4040) -#endif - -#if defined(ETIMEDOUT) && !defined(_WIN32) -# define UV__ETIMEDOUT (-ETIMEDOUT) -#else -# define UV__ETIMEDOUT (-4039) -#endif - -#if defined(ETXTBSY) && !defined(_WIN32) -# define UV__ETXTBSY (-ETXTBSY) -#else -# define UV__ETXTBSY (-4038) -#endif - -#if defined(EXDEV) && !defined(_WIN32) -# define UV__EXDEV (-EXDEV) -#else -# define UV__EXDEV (-4037) -#endif - -#if defined(EFBIG) && !defined(_WIN32) -# define UV__EFBIG (-EFBIG) -#else -# define UV__EFBIG (-4036) -#endif - -#if defined(ENOPROTOOPT) && !defined(_WIN32) -# define UV__ENOPROTOOPT (-ENOPROTOOPT) -#else -# define UV__ENOPROTOOPT (-4035) -#endif - -#if defined(ERANGE) && !defined(_WIN32) -# define UV__ERANGE (-ERANGE) -#else -# define UV__ERANGE (-4034) -#endif - -#if defined(ENXIO) && !defined(_WIN32) -# define UV__ENXIO (-ENXIO) -#else -# define UV__ENXIO (-4033) -#endif - -#if defined(EMLINK) && !defined(_WIN32) -# define UV__EMLINK (-EMLINK) -#else -# define UV__EMLINK (-4032) -#endif - -/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is - * defined. Fortunately, its value is always 64 so it's possible albeit - * icky to hard-code it. - */ -#if defined(EHOSTDOWN) && !defined(_WIN32) -# define UV__EHOSTDOWN (-EHOSTDOWN) -#elif defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) -# define UV__EHOSTDOWN (-64) -#else -# define UV__EHOSTDOWN (-4031) -#endif - -#endif /* UV_ERRNO_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-linux.h b/lib/ESPiLight/pilight/libs/libuv/uv-linux.h deleted file mode 100644 index 9b38405..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-linux.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_LINUX_H -#define UV_LINUX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t inotify_read_watcher; \ - void* inotify_watchers; \ - int inotify_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - void* watchers[2]; \ - int wd; \ - -#endif /* UV_LINUX_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-os390.h b/lib/ESPiLight/pilight/libs/libuv/uv-os390.h deleted file mode 100644 index 58f9261..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-os390.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_MVS_H -#define UV_MVS_H - -#define UV_PLATFORM_SEM_T int - -#define UV_PLATFORM_LOOP_FIELDS \ - void* ep; \ - -#endif /* UV_MVS_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-posix.h b/lib/ESPiLight/pilight/libs/libuv/uv-posix.h deleted file mode 100644 index 9a96634..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-posix.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_POSIX_H -#define UV_POSIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - struct pollfd* poll_fds; \ - size_t poll_fds_used; \ - size_t poll_fds_size; \ - unsigned char poll_fds_iterating; \ - -#endif /* UV_POSIX_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-sunos.h b/lib/ESPiLight/pilight/libs/libuv/uv-sunos.h deleted file mode 100644 index 0421664..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-sunos.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_SUNOS_H -#define UV_SUNOS_H - -#include -#include - -/* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, - * add the fs_event fields even when this version of SunOS doesn't support - * file watching. - */ -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t fs_event_watcher; \ - int fs_fd; \ - -#if defined(PORT_SOURCE_FILE) - -# define UV_PLATFORM_FS_EVENT_FIELDS \ - file_obj_t fo; \ - int fd; \ - -#endif /* defined(PORT_SOURCE_FILE) */ - -#endif /* UV_SUNOS_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-threadpool.h b/lib/ESPiLight/pilight/libs/libuv/uv-threadpool.h deleted file mode 100644 index 8fd2301..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-threadpool.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_THREADPOOL_H_ -#define UV_THREADPOOL_H_ - -struct uv__work { - char *name; - void (*work)(struct uv__work *w); - void (*done)(struct uv__work *w, int status); - struct uv_loop_s* loop; - void* wq[2]; -}; - -#endif /* UV_THREADPOOL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-threadpool.h.ori b/lib/ESPiLight/pilight/libs/libuv/uv-threadpool.h.ori deleted file mode 100644 index 9708ebd..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-threadpool.h.ori +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_THREADPOOL_H_ -#define UV_THREADPOOL_H_ - -struct uv__work { - void (*work)(struct uv__work *w); - void (*done)(struct uv__work *w, int status); - struct uv_loop_s* loop; - void* wq[2]; -}; - -#endif /* UV_THREADPOOL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-unix.h b/lib/ESPiLight/pilight/libs/libuv/uv-unix.h deleted file mode 100644 index d775450..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-unix.h +++ /dev/null @@ -1,368 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_UNIX_H -#define UV_UNIX_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#if !defined(__MVS__) -#include -#endif -#include -#include - -#include "uv-threadpool.h" - -#if defined(__linux__) -# include "uv-linux.h" -#elif defined (__MVS__) -# include "uv-os390.h" -#elif defined(_AIX) -# include "uv-aix.h" -#elif defined(__sun) -# include "uv-sunos.h" -#elif defined(__APPLE__) -# include "uv-darwin.h" -#elif defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# include "uv-bsd.h" -#elif defined(__CYGWIN__) || defined(__MSYS__) -# include "uv-posix.h" -#endif - -#ifndef PTHREAD_BARRIER_SERIAL_THREAD -# include "pthread-barrier.h" -#endif - -#ifndef NI_MAXHOST -# define NI_MAXHOST 1025 -#endif - -#ifndef NI_MAXSERV -# define NI_MAXSERV 32 -#endif - -#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS -# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -struct uv__io_s; -struct uv_loop_s; - -typedef void (*uv__io_cb)(struct uv_loop_s* loop, - struct uv__io_s* w, - unsigned int events); -typedef struct uv__io_s uv__io_t; - -struct uv__io_s { - uv__io_cb cb; - void* pending_queue[2]; - void* watcher_queue[2]; - unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ - unsigned int events; /* Current event mask. */ - int fd; - UV_IO_PRIVATE_PLATFORM_FIELDS -}; - -#ifndef UV_PLATFORM_SEM_T -# define UV_PLATFORM_SEM_T sem_t -#endif - -#ifndef UV_PLATFORM_LOOP_FIELDS -# define UV_PLATFORM_LOOP_FIELDS /* empty */ -#endif - -#ifndef UV_PLATFORM_FS_EVENT_FIELDS -# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ -#endif - -#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS -# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -/* Note: May be cast to struct iovec. See writev(2). */ -typedef struct uv_buf_t { - char* base; - size_t len; -} uv_buf_t; - -typedef int uv_file; -typedef int uv_os_sock_t; -typedef int uv_os_fd_t; - -#define UV_ONCE_INIT PTHREAD_ONCE_INIT - -typedef pthread_once_t uv_once_t; -typedef pthread_t uv_thread_t; -typedef pthread_mutex_t uv_mutex_t; -typedef pthread_rwlock_t uv_rwlock_t; -typedef UV_PLATFORM_SEM_T uv_sem_t; -typedef pthread_cond_t uv_cond_t; -typedef pthread_key_t uv_key_t; -typedef pthread_barrier_t uv_barrier_t; - - -/* Platform-specific definitions for uv_spawn support. */ -typedef gid_t uv_gid_t; -typedef uid_t uv_uid_t; - -typedef struct dirent uv__dirent_t; - -#if defined(DT_UNKNOWN) -# define HAVE_DIRENT_TYPES -# if defined(DT_REG) -# define UV__DT_FILE DT_REG -# else -# define UV__DT_FILE -1 -# endif -# if defined(DT_DIR) -# define UV__DT_DIR DT_DIR -# else -# define UV__DT_DIR -2 -# endif -# if defined(DT_LNK) -# define UV__DT_LINK DT_LNK -# else -# define UV__DT_LINK -3 -# endif -# if defined(DT_FIFO) -# define UV__DT_FIFO DT_FIFO -# else -# define UV__DT_FIFO -4 -# endif -# if defined(DT_SOCK) -# define UV__DT_SOCKET DT_SOCK -# else -# define UV__DT_SOCKET -5 -# endif -# if defined(DT_CHR) -# define UV__DT_CHAR DT_CHR -# else -# define UV__DT_CHAR -6 -# endif -# if defined(DT_BLK) -# define UV__DT_BLOCK DT_BLK -# else -# define UV__DT_BLOCK -7 -# endif -#endif - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC /* empty */ - -typedef struct { - void* handle; - char* errmsg; -} uv_lib_t; - -#define UV_LOOP_PRIVATE_FIELDS \ - unsigned long flags; \ - int backend_fd; \ - void* pending_queue[2]; \ - void* watcher_queue[2]; \ - uv__io_t** watchers; \ - unsigned int nwatchers; \ - unsigned int nfds; \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; \ - uv_rwlock_t cloexec_lock; \ - uv_handle_t* closing_handles; \ - void* process_handles[2]; \ - void* prepare_handles[2]; \ - void* check_handles[2]; \ - void* idle_handles[2]; \ - void* async_handles[2]; \ - void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ - uv__io_t async_io_watcher; \ - int async_wfd; \ - struct { \ - void* min; \ - unsigned int nelts; \ - } timer_heap; \ - uint64_t timer_counter; \ - uint64_t time; \ - int signal_pipefd[2]; \ - uv__io_t signal_io_watcher; \ - uv_signal_t child_watcher; \ - int emfile_fd; \ - UV_PLATFORM_LOOP_FIELDS \ - -#define UV_REQ_TYPE_PRIVATE /* empty */ - -#define UV_REQ_PRIVATE_FIELDS /* empty */ - -#define UV_PRIVATE_REQ_TYPES /* empty */ - -#define UV_WRITE_PRIVATE_FIELDS \ - void* queue[2]; \ - unsigned int write_index; \ - uv_buf_t* bufs; \ - unsigned int nbufs; \ - int error; \ - uv_buf_t bufsml[4]; \ - -#define UV_CONNECT_PRIVATE_FIELDS \ - void* queue[2]; \ - -#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - void* queue[2]; \ - struct sockaddr_storage addr; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - ssize_t status; \ - uv_udp_send_cb send_cb; \ - uv_buf_t bufsml[4]; \ - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* next_closing; \ - unsigned int flags; \ - -#define UV_STREAM_PRIVATE_FIELDS \ - uv_connect_t *connect_req; \ - uv_shutdown_t *shutdown_req; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - uv_connection_cb connection_cb; \ - int delayed_error; \ - int accepted_fd; \ - void* queued_fds; \ - UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - -#define UV_TCP_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_PRIVATE_FIELDS \ - uv_alloc_cb alloc_cb; \ - uv_udp_recv_cb recv_cb; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - -#define UV_PIPE_PRIVATE_FIELDS \ - const char* pipe_fname; /* strdup'ed */ - -#define UV_POLL_PRIVATE_FIELDS \ - uv__io_t io_watcher; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_cb prepare_cb; \ - void* queue[2]; \ - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_cb check_cb; \ - void* queue[2]; \ - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_cb idle_cb; \ - void* queue[2]; \ - -#define UV_ASYNC_PRIVATE_FIELDS \ - uv_async_cb async_cb; \ - void* queue[2]; \ - int pending; \ - -#define UV_TIMER_PRIVATE_FIELDS \ - uv_timer_cb timer_cb; \ - void* heap_node[3]; \ - uint64_t timeout; \ - uint64_t repeat; \ - uint64_t start_id; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb cb; \ - struct addrinfo* hints; \ - char* hostname; \ - char* service; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - void* queue[2]; \ - int status; \ - -#define UV_FS_PRIVATE_FIELDS \ - const char *new_path; \ - uv_file file; \ - int flags; \ - mode_t mode; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - off_t off; \ - uv_uid_t uid; \ - uv_gid_t gid; \ - double atime; \ - double mtime; \ - struct uv__work work_req; \ - uv_buf_t bufsml[4]; \ - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_TTY_PRIVATE_FIELDS \ - struct termios orig_termios; \ - int mode; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - /* RB_ENTRY(uv_signal_s) tree_entry; */ \ - struct { \ - struct uv_signal_s* rbe_left; \ - struct uv_signal_s* rbe_right; \ - struct uv_signal_s* rbe_parent; \ - int rbe_color; \ - } tree_entry; \ - /* Use two counters here so we don have to fiddle with atomics. */ \ - unsigned int caught_signals; \ - unsigned int dispatched_signals; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - uv_fs_event_cb cb; \ - UV_PLATFORM_FS_EVENT_FIELDS \ - -#endif /* UV_UNIX_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-version.h b/lib/ESPiLight/pilight/libs/libuv/uv-version.h deleted file mode 100644 index 77bd262..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-version.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_VERSION_H -#define UV_VERSION_H - - /* - * Versions with the same major number are ABI stable. API is allowed to - * evolve between minor releases, but only in a backwards compatible way. - * Make sure you update the -soname directives in configure.ac - * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but - * not UV_VERSION_PATCH.) - */ - -#define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 12 -#define UV_VERSION_PATCH 1 -#define UV_VERSION_IS_RELEASE 0 -#define UV_VERSION_SUFFIX "dev" - -#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ - (UV_VERSION_MINOR << 8) | \ - (UV_VERSION_PATCH)) - -#endif /* UV_VERSION_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv-win.h b/lib/ESPiLight/pilight/libs/libuv/uv-win.h deleted file mode 100644 index 9677ff1..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv-win.h +++ /dev/null @@ -1,650 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0502 -#endif - -#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) -typedef intptr_t ssize_t; -# define _SSIZE_T_ -# define _SSIZE_T_DEFINED -#endif - -#include - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -typedef struct pollfd { - SOCKET fd; - short events; - short revents; -} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; -#endif - -#ifndef LOCALE_INVARIANT -# define LOCALE_INVARIANT 0x007f -#endif - -#include -#include -#include - -#include -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#include "tree.h" -#include "uv-threadpool.h" - -#define MAX_PIPENAME_LEN 256 - -#ifndef S_IFLNK -# define S_IFLNK 0xA000 -#endif - -/* Additional signals supported by uv_signal and or uv_kill. The CRT defines - * the following signals already: - * - * #define SIGINT 2 - * #define SIGILL 4 - * #define SIGABRT_COMPAT 6 - * #define SIGFPE 8 - * #define SIGSEGV 11 - * #define SIGTERM 15 - * #define SIGBREAK 21 - * #define SIGABRT 22 - * - * The additional signals have values that are common on other Unix - * variants (Linux and Darwin) - */ -#define SIGHUP 1 -#define SIGKILL 9 -#define SIGWINCH 28 - -/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */ -/* unix-like platforms. However MinGW doesn't define it, so we do. */ -#ifndef SIGABRT_COMPAT -# define SIGABRT_COMPAT 6 -#endif - -/* - * Guids and typedefs for winsock extension functions - * Mingw32 doesn't have these :-( - */ -#ifndef WSAID_ACCEPTEX -# define WSAID_ACCEPTEX \ - {0xb5367df1, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_CONNECTEX \ - {0x25a207b9, 0xddf3, 0x4660, \ - {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} - -# define WSAID_GETACCEPTEXSOCKADDRS \ - {0xb5367df2, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_DISCONNECTEX \ - {0x7fda2e11, 0x8630, 0x436f, \ - {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} - -# define WSAID_TRANSMITFILE \ - {0xb5367df0, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - - typedef BOOL (PASCAL *LPFN_ACCEPTEX) - (SOCKET sListenSocket, - SOCKET sAcceptSocket, - PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPDWORD lpdwBytesReceived, - LPOVERLAPPED lpOverlapped); - - typedef BOOL (PASCAL *LPFN_CONNECTEX) - (SOCKET s, - const struct sockaddr* name, - int namelen, - PVOID lpSendBuffer, - DWORD dwSendDataLength, - LPDWORD lpdwBytesSent, - LPOVERLAPPED lpOverlapped); - - typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) - (PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPSOCKADDR* LocalSockaddr, - LPINT LocalSockaddrLength, - LPSOCKADDR* RemoteSockaddr, - LPINT RemoteSockaddrLength); - - typedef BOOL (PASCAL *LPFN_DISCONNECTEX) - (SOCKET hSocket, - LPOVERLAPPED lpOverlapped, - DWORD dwFlags, - DWORD reserved); - - typedef BOOL (PASCAL *LPFN_TRANSMITFILE) - (SOCKET hSocket, - HANDLE hFile, - DWORD nNumberOfBytesToWrite, - DWORD nNumberOfBytesPerSend, - LPOVERLAPPED lpOverlapped, - LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, - DWORD dwFlags); - - typedef PVOID RTL_SRWLOCK; - typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; -#endif - -typedef int (WSAAPI* LPFN_WSARECV) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -typedef int (WSAAPI* LPFN_WSARECVFROM) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - struct sockaddr* addr, - LPINT addr_len, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -#ifndef _NTDEF_ - typedef LONG NTSTATUS; - typedef NTSTATUS *PNTSTATUS; -#endif - -#ifndef RTL_CONDITION_VARIABLE_INIT - typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; -#endif - -typedef struct _AFD_POLL_HANDLE_INFO { - HANDLE Handle; - ULONG Events; - NTSTATUS Status; -} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; - -typedef struct _AFD_POLL_INFO { - LARGE_INTEGER Timeout; - ULONG NumberOfHandles; - ULONG Exclusive; - AFD_POLL_HANDLE_INFO Handles[1]; -} AFD_POLL_INFO, *PAFD_POLL_INFO; - -#define UV_MSAFD_PROVIDER_COUNT 3 - - -/** - * It should be possible to cast uv_buf_t[] to WSABUF[] - * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx - */ -typedef struct uv_buf_t { - ULONG len; - char* base; -} uv_buf_t; - -typedef int uv_file; -typedef SOCKET uv_os_sock_t; -typedef HANDLE uv_os_fd_t; - -typedef HANDLE uv_thread_t; - -typedef HANDLE uv_sem_t; - -typedef CRITICAL_SECTION uv_mutex_t; - -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -typedef union { - CONDITION_VARIABLE cond_var; - struct { - unsigned int waiters_count; - CRITICAL_SECTION waiters_count_lock; - HANDLE signal_event; - HANDLE broadcast_event; - } fallback; -} uv_cond_t; - -typedef union { - struct { - unsigned int num_readers_; - CRITICAL_SECTION num_readers_lock_; - HANDLE write_semaphore_; - } state_; - /* TODO: remove me in v2.x. */ - struct { - SRWLOCK unused_; - } unused1_; - /* TODO: remove me in v2.x. */ - struct { - uv_mutex_t unused1_; - uv_mutex_t unused2_; - } unused2_; -} uv_rwlock_t; - -typedef struct { - unsigned int n; - unsigned int count; - uv_mutex_t mutex; - uv_sem_t turnstile1; - uv_sem_t turnstile2; -} uv_barrier_t; - -typedef struct { - DWORD tls_index; -} uv_key_t; - -#define UV_ONCE_INIT { 0, NULL } - -typedef struct uv_once_s { - unsigned char ran; - HANDLE event; -} uv_once_t; - -/* Platform-specific definitions for uv_spawn support. */ -typedef unsigned char uv_uid_t; -typedef unsigned char uv_gid_t; - -typedef struct uv__dirent_s { - int d_type; - char d_name[1]; -} uv__dirent_t; - -#define HAVE_DIRENT_TYPES -#define UV__DT_DIR UV_DIRENT_DIR -#define UV__DT_FILE UV_DIRENT_FILE -#define UV__DT_LINK UV_DIRENT_LINK -#define UV__DT_FIFO UV_DIRENT_FIFO -#define UV__DT_SOCKET UV_DIRENT_SOCKET -#define UV__DT_CHAR UV_DIRENT_CHAR -#define UV__DT_BLOCK UV_DIRENT_BLOCK - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC FAR WINAPI -typedef struct { - HMODULE handle; - char* errmsg; -} uv_lib_t; - -RB_HEAD(uv_timer_tree_s, uv_timer_s); - -#define UV_LOOP_PRIVATE_FIELDS \ - /* The loop's I/O completion port */ \ - HANDLE iocp; \ - /* The current time according to the event loop. in msecs. */ \ - uint64_t time; \ - /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ - /* is empty, tail_ is NULL. If there is only one item, */ \ - /* tail_->next_req == tail_ */ \ - uv_req_t* pending_reqs_tail; \ - /* Head of a single-linked list of closed handles */ \ - uv_handle_t* endgame_handles; \ - /* The head of the timers tree */ \ - struct uv_timer_tree_s timers; \ - /* Lists of active loop (prepare / check / idle) watchers */ \ - uv_prepare_t* prepare_handles; \ - uv_check_t* check_handles; \ - uv_idle_t* idle_handles; \ - /* This pointer will refer to the prepare/check/idle handle whose */ \ - /* callback is scheduled to be called next. This is needed to allow */ \ - /* safe removal from one of the lists above while that list being */ \ - /* iterated over. */ \ - uv_prepare_t* next_prepare_handle; \ - uv_check_t* next_check_handle; \ - uv_idle_t* next_idle_handle; \ - /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ - SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ - /* Counter to keep track of active tcp streams */ \ - unsigned int active_tcp_streams; \ - /* Counter to keep track of active udp streams */ \ - unsigned int active_udp_streams; \ - /* Counter to started timer */ \ - uint64_t timer_counter; \ - /* Threadpool */ \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; - -#define UV_REQ_TYPE_PRIVATE \ - /* TODO: remove the req suffix */ \ - UV_ACCEPT, \ - UV_FS_EVENT_REQ, \ - UV_POLL_REQ, \ - UV_PROCESS_EXIT, \ - UV_READ, \ - UV_UDP_RECV, \ - UV_WAKEUP, \ - UV_SIGNAL_REQ, - -#define UV_REQ_PRIVATE_FIELDS \ - union { \ - /* Used by I/O operations */ \ - struct { \ - OVERLAPPED overlapped; \ - size_t queued_bytes; \ - } io; \ - } u; \ - struct uv_req_s* next_req; - -#define UV_WRITE_PRIVATE_FIELDS \ - int ipc_header; \ - uv_buf_t write_buffer; \ - HANDLE event_handle; \ - HANDLE wait_handle; - -#define UV_CONNECT_PRIVATE_FIELDS \ - /* empty */ - -#define UV_SHUTDOWN_PRIVATE_FIELDS \ - /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - /* empty */ - -#define UV_PRIVATE_REQ_TYPES \ - typedef struct uv_pipe_accept_s { \ - UV_REQ_FIELDS \ - HANDLE pipeHandle; \ - struct uv_pipe_accept_s* next_pending; \ - } uv_pipe_accept_t; \ - \ - typedef struct uv_tcp_accept_s { \ - UV_REQ_FIELDS \ - SOCKET accept_socket; \ - char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - struct uv_tcp_accept_s* next_pending; \ - } uv_tcp_accept_t; \ - \ - typedef struct uv_read_s { \ - UV_REQ_FIELDS \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - } uv_read_t; - -#define uv_stream_connection_fields \ - unsigned int write_reqs_pending; \ - uv_shutdown_t* shutdown_req; - -#define uv_stream_server_fields \ - uv_connection_cb connection_cb; - -#define UV_STREAM_PRIVATE_FIELDS \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_read_t read_req; \ - union { \ - struct { uv_stream_connection_fields } conn; \ - struct { uv_stream_server_fields } serv; \ - } stream; - -#define uv_tcp_server_fields \ - uv_tcp_accept_t* accept_reqs; \ - unsigned int processed_accepts; \ - uv_tcp_accept_t* pending_accepts; \ - LPFN_ACCEPTEX func_acceptex; - -#define uv_tcp_connection_fields \ - uv_buf_t read_buffer; \ - LPFN_CONNECTEX func_connectex; - -#define UV_TCP_PRIVATE_FIELDS \ - SOCKET socket; \ - int delayed_error; \ - union { \ - struct { uv_tcp_server_fields } serv; \ - struct { uv_tcp_connection_fields } conn; \ - } tcp; - -#define UV_UDP_PRIVATE_FIELDS \ - SOCKET socket; \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_req_t recv_req; \ - uv_buf_t recv_buffer; \ - struct sockaddr_storage recv_from; \ - int recv_from_len; \ - uv_udp_recv_cb recv_cb; \ - uv_alloc_cb alloc_cb; \ - LPFN_WSARECV func_wsarecv; \ - LPFN_WSARECVFROM func_wsarecvfrom; - -#define uv_pipe_server_fields \ - int pending_instances; \ - uv_pipe_accept_t* accept_reqs; \ - uv_pipe_accept_t* pending_accepts; - -#define uv_pipe_connection_fields \ - uv_timer_t* eof_timer; \ - uv_write_t ipc_header_write_req; \ - int ipc_pid; \ - uint64_t remaining_ipc_rawdata_bytes; \ - struct { \ - void* queue[2]; \ - int queue_len; \ - } pending_ipc_info; \ - uv_write_t* non_overlapped_writes_tail; \ - uv_mutex_t readfile_mutex; \ - volatile HANDLE readfile_thread; - -#define UV_PIPE_PRIVATE_FIELDS \ - HANDLE handle; \ - WCHAR* name; \ - union { \ - struct { uv_pipe_server_fields } serv; \ - struct { uv_pipe_connection_fields } conn; \ - } pipe; - -/* TODO: put the parser states in an union - TTY handles are always */ -/* half-duplex so read-state can safely overlap write-state. */ -#define UV_TTY_PRIVATE_FIELDS \ - HANDLE handle; \ - union { \ - struct { \ - /* Used for readable TTY handles */ \ - /* TODO: remove me in v2.x. */ \ - HANDLE unused_; \ - uv_buf_t read_line_buffer; \ - HANDLE read_raw_wait; \ - /* Fields used for translating win keystrokes into vt100 characters */ \ - char last_key[8]; \ - unsigned char last_key_offset; \ - unsigned char last_key_len; \ - WCHAR last_utf16_high_surrogate; \ - INPUT_RECORD last_input_record; \ - } rd; \ - struct { \ - /* Used for writable TTY handles */ \ - /* utf8-to-utf16 conversion state */ \ - unsigned int utf8_codepoint; \ - unsigned char utf8_bytes_left; \ - /* eol conversion state */ \ - unsigned char previous_eol; \ - /* ansi parser state */ \ - unsigned char ansi_parser_state; \ - unsigned char ansi_csi_argc; \ - unsigned short ansi_csi_argv[4]; \ - COORD saved_position; \ - WORD saved_attributes; \ - } wr; \ - } tty; - -#define UV_POLL_PRIVATE_FIELDS \ - SOCKET socket; \ - /* Used in fast mode */ \ - SOCKET peer_socket; \ - AFD_POLL_INFO afd_poll_info_1; \ - AFD_POLL_INFO afd_poll_info_2; \ - /* Used in fast and slow mode. */ \ - uv_req_t poll_req_1; \ - uv_req_t poll_req_2; \ - unsigned char submitted_events_1; \ - unsigned char submitted_events_2; \ - unsigned char mask_events_1; \ - unsigned char mask_events_2; \ - unsigned char events; - -#define UV_TIMER_PRIVATE_FIELDS \ - RB_ENTRY(uv_timer_s) tree_entry; \ - uint64_t due; \ - uint64_t repeat; \ - uint64_t start_id; \ - uv_timer_cb timer_cb; - -#define UV_ASYNC_PRIVATE_FIELDS \ - struct uv_req_s async_req; \ - uv_async_cb async_cb; \ - /* char to avoid alignment issues */ \ - char volatile async_sent; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_t* prepare_prev; \ - uv_prepare_t* prepare_next; \ - uv_prepare_cb prepare_cb; - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_t* check_prev; \ - uv_check_t* check_next; \ - uv_check_cb check_cb; - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_t* idle_prev; \ - uv_idle_t* idle_next; \ - uv_idle_cb idle_cb; - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* endgame_next; \ - unsigned int flags; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb getaddrinfo_cb; \ - void* alloc; \ - WCHAR* node; \ - WCHAR* service; \ - /* The addrinfoW field is used to store a pointer to the hints, and */ \ - /* later on to store the result of GetAddrInfoW. The final result will */ \ - /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ - struct addrinfoW* addrinfow; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - struct uv_process_exit_s { \ - UV_REQ_FIELDS \ - } exit_req; \ - BYTE* child_stdio_buffer; \ - int exit_signal; \ - HANDLE wait_handle; \ - HANDLE process_handle; \ - volatile char exit_cb_pending; - -#define UV_FS_PRIVATE_FIELDS \ - struct uv__work work_req; \ - int flags; \ - DWORD sys_errno_; \ - union { \ - /* TODO: remove me in 0.9. */ \ - WCHAR* pathw; \ - int fd; \ - } file; \ - union { \ - struct { \ - int mode; \ - WCHAR* new_pathw; \ - int file_flags; \ - int fd_out; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - int64_t offset; \ - uv_buf_t bufsml[4]; \ - } info; \ - struct { \ - double atime; \ - double mtime; \ - } time; \ - } fs; - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - struct uv_fs_event_req_s { \ - UV_REQ_FIELDS \ - } req; \ - HANDLE dir_handle; \ - int req_pending; \ - uv_fs_event_cb cb; \ - WCHAR* filew; \ - WCHAR* short_filew; \ - WCHAR* dirw; \ - char* buffer; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - RB_ENTRY(uv_signal_s) tree_entry; \ - struct uv_req_s signal_req; \ - unsigned long pending_signum; - -#ifndef F_OK -#define F_OK 0 -#endif -#ifndef R_OK -#define R_OK 4 -#endif -#ifndef W_OK -#define W_OK 2 -#endif -#ifndef X_OK -#define X_OK 1 -#endif diff --git a/lib/ESPiLight/pilight/libs/libuv/uv.h b/lib/ESPiLight/pilight/libs/libuv/uv.h deleted file mode 100644 index 1f8f4d7..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv.h +++ /dev/null @@ -1,1510 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* See https://github.com/libuv/libuv#documentation for documentation. */ - -#ifndef UV_H -#define UV_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 - /* Windows - set up dll import/export decorators. */ -# if defined(BUILDING_UV_SHARED) - /* Building shared library. */ -# define UV_EXTERN __declspec(dllexport) -# elif defined(USING_UV_SHARED) - /* Using shared library. */ -# define UV_EXTERN __declspec(dllimport) -# else - /* Building static library. */ -# define UV_EXTERN /* nothing */ -# endif -#elif __GNUC__ >= 4 -# define UV_EXTERN __attribute__((visibility("default"))) -#else -# define UV_EXTERN /* nothing */ -#endif - -#include "uv-errno.h" -#include "uv-version.h" -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#if defined(_WIN32) -# include "uv-win.h" -#else -# include "uv-unix.h" -#endif - -/* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX(E2BIG, "argument list too long") \ - XX(EACCES, "permission denied") \ - XX(EADDRINUSE, "address already in use") \ - XX(EADDRNOTAVAIL, "address not available") \ - XX(EAFNOSUPPORT, "address family not supported") \ - XX(EAGAIN, "resource temporarily unavailable") \ - XX(EAI_ADDRFAMILY, "address family not supported") \ - XX(EAI_AGAIN, "temporary failure") \ - XX(EAI_BADFLAGS, "bad ai_flags value") \ - XX(EAI_BADHINTS, "invalid value for hints") \ - XX(EAI_CANCELED, "request canceled") \ - XX(EAI_FAIL, "permanent failure") \ - XX(EAI_FAMILY, "ai_family not supported") \ - XX(EAI_MEMORY, "out of memory") \ - XX(EAI_NODATA, "no address") \ - XX(EAI_NONAME, "unknown node or service") \ - XX(EAI_OVERFLOW, "argument buffer overflow") \ - XX(EAI_PROTOCOL, "resolved protocol is unknown") \ - XX(EAI_SERVICE, "service not available for socket type") \ - XX(EAI_SOCKTYPE, "socket type not supported") \ - XX(EALREADY, "connection already in progress") \ - XX(EBADF, "bad file descriptor") \ - XX(EBUSY, "resource busy or locked") \ - XX(ECANCELED, "operation canceled") \ - XX(ECHARSET, "invalid Unicode character") \ - XX(ECONNABORTED, "software caused connection abort") \ - XX(ECONNREFUSED, "connection refused") \ - XX(ECONNRESET, "connection reset by peer") \ - XX(EDESTADDRREQ, "destination address required") \ - XX(EEXIST, "file already exists") \ - XX(EFAULT, "bad address in system call argument") \ - XX(EFBIG, "file too large") \ - XX(EHOSTUNREACH, "host is unreachable") \ - XX(EINTR, "interrupted system call") \ - XX(EINVAL, "invalid argument") \ - XX(EIO, "i/o error") \ - XX(EISCONN, "socket is already connected") \ - XX(EISDIR, "illegal operation on a directory") \ - XX(ELOOP, "too many symbolic links encountered") \ - XX(EMFILE, "too many open files") \ - XX(EMSGSIZE, "message too long") \ - XX(ENAMETOOLONG, "name too long") \ - XX(ENETDOWN, "network is down") \ - XX(ENETUNREACH, "network is unreachable") \ - XX(ENFILE, "file table overflow") \ - XX(ENOBUFS, "no buffer space available") \ - XX(ENODEV, "no such device") \ - XX(ENOENT, "no such file or directory") \ - XX(ENOMEM, "not enough memory") \ - XX(ENONET, "machine is not on the network") \ - XX(ENOPROTOOPT, "protocol not available") \ - XX(ENOSPC, "no space left on device") \ - XX(ENOSYS, "function not implemented") \ - XX(ENOTCONN, "socket is not connected") \ - XX(ENOTDIR, "not a directory") \ - XX(ENOTEMPTY, "directory not empty") \ - XX(ENOTSOCK, "socket operation on non-socket") \ - XX(ENOTSUP, "operation not supported on socket") \ - XX(EPERM, "operation not permitted") \ - XX(EPIPE, "broken pipe") \ - XX(EPROTO, "protocol error") \ - XX(EPROTONOSUPPORT, "protocol not supported") \ - XX(EPROTOTYPE, "protocol wrong type for socket") \ - XX(ERANGE, "result too large") \ - XX(EROFS, "read-only file system") \ - XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ - XX(ESPIPE, "invalid seek") \ - XX(ESRCH, "no such process") \ - XX(ETIMEDOUT, "connection timed out") \ - XX(ETXTBSY, "text file is busy") \ - XX(EXDEV, "cross-device link not permitted") \ - XX(UNKNOWN, "unknown error") \ - XX(EOF, "end of file") \ - XX(ENXIO, "no such device or address") \ - XX(EMLINK, "too many links") \ - XX(EHOSTDOWN, "host is down") \ - -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(HANDLE, handle) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(STREAM, stream) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - XX(SIGNAL, signal) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(REQ, req) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ - XX(GETNAMEINFO, getnameinfo) \ - -typedef enum { -#define XX(code, _) UV_ ## code = UV__ ## code, - UV_ERRNO_MAP(XX) -#undef XX - UV_ERRNO_MAX = UV__EOF - 1 -} uv_errno_t; - -typedef enum { - UV_UNKNOWN_HANDLE = 0, -#define XX(uc, lc) UV_##uc, - UV_HANDLE_TYPE_MAP(XX) -#undef XX - UV_FILE, - UV_HANDLE_TYPE_MAX -} uv_handle_type; - -typedef enum { - UV_UNKNOWN_REQ = 0, -#define XX(uc, lc) UV_##uc, - UV_REQ_TYPE_MAP(XX) -#undef XX - UV_REQ_TYPE_PRIVATE - UV_REQ_TYPE_MAX -} uv_req_type; - - -/* Handle types. */ -typedef struct uv_loop_s uv_loop_t; -typedef struct uv_handle_s uv_handle_t; -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tcp_s uv_tcp_t; -typedef struct uv_udp_s uv_udp_t; -typedef struct uv_pipe_s uv_pipe_t; -typedef struct uv_tty_s uv_tty_t; -typedef struct uv_poll_s uv_poll_t; -typedef struct uv_timer_s uv_timer_t; -typedef struct uv_prepare_s uv_prepare_t; -typedef struct uv_check_s uv_check_t; -typedef struct uv_idle_s uv_idle_t; -typedef struct uv_async_s uv_async_t; -typedef struct uv_process_s uv_process_t; -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; -typedef struct uv_signal_s uv_signal_t; - -/* Request types. */ -typedef struct uv_req_s uv_req_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; -typedef struct uv_getnameinfo_s uv_getnameinfo_t; -typedef struct uv_shutdown_s uv_shutdown_t; -typedef struct uv_write_s uv_write_t; -typedef struct uv_connect_s uv_connect_t; -typedef struct uv_udp_send_s uv_udp_send_t; -typedef struct uv_fs_s uv_fs_t; -typedef struct uv_work_s uv_work_t; - -/* None of the above. */ -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -typedef struct uv_dirent_s uv_dirent_t; -typedef struct uv_passwd_s uv_passwd_t; - -typedef enum { - UV_LOOP_BLOCK_SIGNAL -} uv_loop_option; - -typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT -} uv_run_mode; - - -UV_EXTERN unsigned int uv_version(void); -UV_EXTERN const char* uv_version_string(void); - -typedef void* (*uv_malloc_func)(size_t size); -typedef void* (*uv_realloc_func)(void* ptr, size_t size); -typedef void* (*uv_calloc_func)(size_t count, size_t size); -typedef void (*uv_free_func)(void* ptr); - -UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func); - -UV_EXTERN uv_loop_t* uv_default_loop(void); -UV_EXTERN int uv_loop_init(uv_loop_t* loop); -UV_EXTERN int uv_loop_close(uv_loop_t* loop); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12), users should - * allocate the loop manually and use uv_loop_init instead. - */ -UV_EXTERN uv_loop_t* uv_loop_new(void); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12). Users should use - * uv_loop_close and free the memory manually instead. - */ -UV_EXTERN void uv_loop_delete(uv_loop_t*); -UV_EXTERN size_t uv_loop_size(void); -UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); -UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); -UV_EXTERN int uv_loop_fork(uv_loop_t* loop); - -UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); -UV_EXTERN void uv_stop(uv_loop_t*); - -UV_EXTERN void uv_ref(uv_handle_t*); -UV_EXTERN void uv_unref(uv_handle_t*); -UV_EXTERN int uv_has_ref(const uv_handle_t*); - -UV_EXTERN void uv_update_time(uv_loop_t*); -UV_EXTERN uint64_t uv_now(const uv_loop_t*); - -UV_EXTERN int uv_backend_fd(const uv_loop_t*); -UV_EXTERN int uv_backend_timeout(const uv_loop_t*); - -typedef void (*uv_alloc_cb)(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); -typedef void (*uv_read_cb)(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); -typedef void (*uv_write_cb)(uv_write_t* req, int status); -typedef void (*uv_connect_cb)(uv_connect_t* req, int status); -typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); -typedef void (*uv_connection_cb)(uv_stream_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle); -typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); -typedef void (*uv_timer_cb)(uv_timer_t* handle); -typedef void (*uv_async_cb)(uv_async_t* handle); -typedef void (*uv_prepare_cb)(uv_prepare_t* handle); -typedef void (*uv_check_cb)(uv_check_t* handle); -typedef void (*uv_idle_cb)(uv_idle_t* handle); -typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); -typedef void (*uv_fs_cb)(uv_fs_t* req); -typedef void (*uv_work_cb)(uv_work_t* req); -typedef void (*uv_after_work_cb)(uv_work_t* req, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res); -typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, - int status, - const char* hostname, - const char* service); - -typedef struct { - long tv_sec; - long tv_nsec; -} uv_timespec_t; - - -typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; -} uv_stat_t; - - -typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, - const char* filename, - int events, - int status); - -typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); - - -typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP -} uv_membership; - - -UV_EXTERN int uv_translate_sys_error(int sys_errno); - -UV_EXTERN const char* uv_strerror(int err); -UV_EXTERN const char* uv_err_name(int err); - - -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_req_type type; \ - /* private */ \ - void* active_queue[2]; \ - void* reserved[4]; \ - UV_REQ_PRIVATE_FIELDS \ - -/* Abstract base class of all requests. */ -struct uv_req_s { - UV_REQ_FIELDS -}; - - -/* Platform-specific request types. */ -UV_PRIVATE_REQ_TYPES - - -UV_EXTERN int uv_shutdown(uv_shutdown_t* req, - uv_stream_t* handle, - uv_shutdown_cb cb); - -struct uv_shutdown_s { - UV_REQ_FIELDS - uv_stream_t* handle; - uv_shutdown_cb cb; - UV_SHUTDOWN_PRIVATE_FIELDS -}; - - -#define UV_HANDLE_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_loop_t* loop; \ - uv_handle_type type; \ - /* private */ \ - uv_close_cb close_cb; \ - void* handle_queue[2]; \ - union { \ - int fd; \ - void* reserved[4]; \ - } u; \ - UV_HANDLE_PRIVATE_FIELDS \ - -/* The abstract base class of all handles. */ -struct uv_handle_s { - UV_HANDLE_FIELDS -}; - -UV_EXTERN size_t uv_handle_size(uv_handle_type type); -UV_EXTERN size_t uv_req_size(uv_req_type type); - -UV_EXTERN int uv_is_active(const uv_handle_t* handle); - -UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); - -/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ -UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); -UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - -UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); - -UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); -UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); - -UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); - -UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); - - -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - /* private */ \ - UV_STREAM_PRIVATE_FIELDS - -/* - * uv_stream_t is a subclass of uv_handle_t. - * - * uv_stream is an abstract class. - * - * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. - */ -struct uv_stream_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS -}; - -UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); -UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); - -UV_EXTERN int uv_read_start(uv_stream_t*, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -UV_EXTERN int uv_read_stop(uv_stream_t*); - -UV_EXTERN int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb); -UV_EXTERN int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb); -UV_EXTERN int uv_try_write(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs); - -/* uv_write_t is a subclass of uv_req_t. */ -struct uv_write_s { - UV_REQ_FIELDS - uv_write_cb cb; - uv_stream_t* send_handle; - uv_stream_t* handle; - UV_WRITE_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_is_readable(const uv_stream_t* handle); -UV_EXTERN int uv_is_writable(const uv_stream_t* handle); - -UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); - -UV_EXTERN int uv_is_closing(const uv_handle_t* handle); - - -/* - * uv_tcp_t is a subclass of uv_stream_t. - * - * Represents a TCP stream or TCP server. - */ -struct uv_tcp_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TCP_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); -UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); -UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, - int enable, - unsigned int delay); -UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); - -enum uv_tcp_flags { - /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1 -}; - -UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb); - -/* uv_connect_t is a subclass of uv_req_t. */ -struct uv_connect_s { - UV_REQ_FIELDS - uv_connect_cb cb; - uv_stream_t* handle; - UV_CONNECT_PRIVATE_FIELDS -}; - - -/* - * UDP support. - */ - -enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4 -}; - -typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); -typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags); - -/* uv_udp_t is a subclass of uv_handle_t. */ -struct uv_udp_s { - UV_HANDLE_FIELDS - /* read-only */ - /* - * Number of bytes queued for sending. This field strictly shows how much - * information is currently queued. - */ - size_t send_queue_size; - /* - * Number of send requests currently in the queue awaiting to be processed. - */ - size_t send_queue_count; - UV_UDP_PRIVATE_FIELDS -}; - -/* uv_udp_send_t is a subclass of uv_req_t. */ -struct uv_udp_send_s { - UV_REQ_FIELDS - uv_udp_t* handle; - uv_udp_send_cb cb; - UV_UDP_SEND_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); -UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); -UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags); - -UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, - const char* interface_addr); -UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb); -UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr); -UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb); -UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); - - -/* - * uv_tty_t is a subclass of uv_stream_t. - * - * Representing a stream for the console. - */ -struct uv_tty_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TTY_PRIVATE_FIELDS -}; - -typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO -} uv_tty_mode_t; - -UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); -UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); -UV_EXTERN int uv_tty_reset_mode(void); -UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); - -#ifdef __cplusplus -extern "C++" { - -inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { - return uv_tty_set_mode(handle, static_cast(mode)); -} - -} -#endif - -UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); - -/* - * uv_pipe_t is a subclass of uv_stream_t. - * - * Representing a pipe stream or pipe server. On Windows this is a Named - * Pipe. On Unix this is a Unix domain socket. - */ -struct uv_pipe_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - int ipc; /* non-zero if this pipe is used for passing handles */ - UV_PIPE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); -UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); -UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); -UV_EXTERN void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb); -UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); -UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); -UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); - - -struct uv_poll_s { - UV_HANDLE_FIELDS - uv_poll_cb poll_cb; - UV_POLL_PRIVATE_FIELDS -}; - -enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4, - UV_PRIORITIZED = 8 -}; - -UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); -UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, - uv_poll_t* handle, - uv_os_sock_t socket); -UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); -UV_EXTERN int uv_poll_stop(uv_poll_t* handle); - - -struct uv_prepare_s { - UV_HANDLE_FIELDS - UV_PREPARE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); -UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); -UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); - - -struct uv_check_s { - UV_HANDLE_FIELDS - UV_CHECK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); -UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); -UV_EXTERN int uv_check_stop(uv_check_t* check); - - -struct uv_idle_s { - UV_HANDLE_FIELDS - UV_IDLE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); -UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); -UV_EXTERN int uv_idle_stop(uv_idle_t* idle); - - -struct uv_async_s { - UV_HANDLE_FIELDS - UV_ASYNC_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_async_init(uv_loop_t*, - uv_async_t* async, - uv_async_cb async_cb); -UV_EXTERN int uv_async_send(uv_async_t* async); - - -/* - * uv_timer_t is a subclass of uv_handle_t. - * - * Used to get woken up at a specified time in the future. - */ -struct uv_timer_s { - UV_HANDLE_FIELDS - UV_TIMER_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); -UV_EXTERN int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat); -UV_EXTERN int uv_timer_stop(uv_timer_t* handle); -UV_EXTERN int uv_timer_again(uv_timer_t* handle); -UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); -UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); - - -/* - * uv_getaddrinfo_t is a subclass of uv_req_t. - * - * Request object for uv_getaddrinfo. - */ -struct uv_getaddrinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ - UV_GETADDRINFO_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints); -UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); - - -/* -* uv_getnameinfo_t is a subclass of uv_req_t. -* -* Request object for uv_getnameinfo. -*/ -struct uv_getnameinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* host and service are marked as private, but they really aren't. */ - UV_GETNAMEINFO_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags); - - -/* uv_spawn() options. */ -typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 -} uv_stdio_flags; - -typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - - union { - uv_stream_t* stream; - int fd; - } data; -} uv_stdio_container_t; - -typedef struct uv_process_options_s { - uv_exit_cb exit_cb; /* Called after the process exits. */ - const char* file; /* Path to program to execute. */ - /* - * Command line arguments. args[0] should be the path to the program. On - * Windows this uses CreateProcess which concatenates the arguments into a - * string this can cause some strange errors. See the note at - * windows_verbatim_arguments. - */ - char** args; - /* - * This will be set as the environ variable in the subprocess. If this is - * NULL then the parents environ will be used. - */ - char** env; - /* - * If non-null this represents a directory the subprocess should execute - * in. Stands for current working directory. - */ - const char* cwd; - /* - * Various flags that control how uv_spawn() behaves. See the definition of - * `enum uv_process_flags` below. - */ - unsigned int flags; - /* - * The `stdio` field points to an array of uv_stdio_container_t structs that - * describe the file descriptors that will be made available to the child - * process. The convention is that stdio[0] points to stdin, fd 1 is used for - * stdout, and fd 2 is stderr. - * - * Note that on windows file descriptors greater than 2 are available to the - * child process only if the child processes uses the MSVCRT runtime. - */ - int stdio_count; - uv_stdio_container_t* stdio; - /* - * Libuv can change the child process' user/group id. This happens only when - * the appropriate bits are set in the flags fields. This is not supported on - * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. - */ - uv_uid_t uid; - uv_gid_t gid; -} uv_process_options_t; - -/* - * These are the flags that can be used for the uv_process_options.flags field. - */ -enum uv_process_flags { - /* - * Set the child process' user id. The user id is supplied in the `uid` field - * of the options struct. This does not work on windows; setting this flag - * will cause uv_spawn() to fail. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. The user id is supplied in the `gid` - * field of the options struct. This does not work on windows; setting this - * flag will cause uv_spawn() to fail. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4) -}; - -/* - * uv_process_t is a subclass of uv_handle_t. - */ -struct uv_process_s { - UV_HANDLE_FIELDS - uv_exit_cb exit_cb; - int pid; - UV_PROCESS_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_spawn(uv_loop_t* loop, - uv_process_t* handle, - const uv_process_options_t* options); -UV_EXTERN int uv_process_kill(uv_process_t*, int signum); -UV_EXTERN int uv_kill(int pid, int signum); - - -/* - * uv_work_t is a subclass of uv_req_t. - */ -struct uv_work_s { - UV_REQ_FIELDS - uv_loop_t* loop; - uv_work_cb work_cb; - uv_after_work_cb after_work_cb; - UV_WORK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - char *name, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - -UV_EXTERN int uv_cancel(uv_req_t* req); - - -struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; - } cpu_times; -}; - -struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; -}; - -struct uv_passwd_s { - char* username; - long uid; - long gid; - char* shell; - char* homedir; -}; - -typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK -} uv_dirent_type_t; - -struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; -}; - -UV_EXTERN char** uv_setup_args(int argc, char** argv); -UV_EXTERN int uv_get_process_title(char* buffer, size_t size); -UV_EXTERN int uv_set_process_title(const char* title); -UV_EXTERN int uv_resident_set_memory(size_t* rss); -UV_EXTERN int uv_uptime(double* uptime); -UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); - -typedef struct { - long tv_sec; - long tv_usec; -} uv_timeval_t; - -typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size */ - uint64_t ru_idrss; /* integral unshared data size */ - uint64_t ru_isrss; /* integral unshared stack size */ - uint64_t ru_minflt; /* page reclaims (soft page faults) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent */ - uint64_t ru_msgrcv; /* IPC messages received */ - uint64_t ru_nsignals; /* signals received */ - uint64_t ru_nvcsw; /* voluntary context switches */ - uint64_t ru_nivcsw; /* involuntary context switches */ -} uv_rusage_t; - -UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); - -UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); -UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); -UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); -UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); - -UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); -UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); - -UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, - int* count); -UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count); - -UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); -UV_EXTERN int uv_os_setenv(const char* name, const char* value); -UV_EXTERN int uv_os_unsetenv(const char* name); - -UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); - - -typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH -} uv_fs_type; - -/* uv_fs_t is a subclass of uv_req_t. */ -struct uv_fs_s { - UV_REQ_FIELDS - uv_fs_type fs_type; - uv_loop_t* loop; - uv_fs_cb cb; - ssize_t result; - void* ptr; - const char* path; - uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ - UV_FS_PRIVATE_FIELDS -}; - -UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); -UV_EXTERN int uv_fs_close(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, - uv_dirent_t* ent); -UV_EXTERN int uv_fs_stat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t in_offset, - size_t length, - uv_fs_cb cb); -UV_EXTERN int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * path argument points to a directory. - */ -#define UV_FS_SYMLINK_DIR 0x0001 - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * the symlink is to be created using junction points. - */ -#define UV_FS_SYMLINK_JUNCTION 0x0002 - -UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); - - -enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 -}; - - -struct uv_fs_event_s { - UV_HANDLE_FIELDS - /* private */ - char* path; - UV_FS_EVENT_PRIVATE_FIELDS -}; - - -/* - * uv_fs_stat() based polling file watcher. - */ -struct uv_fs_poll_s { - UV_HANDLE_FIELDS - /* Private, don't touch. */ - void* poll_ctx; -}; - -UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb poll_cb, - const char* path, - unsigned int interval); -UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, - char* buffer, - size_t* size); - - -struct uv_signal_s { - UV_HANDLE_FIELDS - uv_signal_cb signal_cb; - int signum; - UV_SIGNAL_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); -UV_EXTERN int uv_signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_stop(uv_signal_t* handle); - -UV_EXTERN void uv_loadavg(double avg[3]); - - -/* - * Flags to be passed to uv_fs_event_start(). - */ -enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote filesystems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in it's subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 -}; - - -UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags); -UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, - char* buffer, - size_t* size); - -UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); -UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); - -UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); -UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); - -UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); -UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); - -UV_EXTERN int uv_exepath(char* buffer, size_t* size); - -UV_EXTERN int uv_cwd(char* buffer, size_t* size); - -UV_EXTERN int uv_chdir(const char* dir); - -UV_EXTERN uint64_t uv_get_free_memory(void); -UV_EXTERN uint64_t uv_get_total_memory(void); - -UV_EXTERN uint64_t uv_hrtime(void); - -UV_EXTERN void uv_disable_stdio_inheritance(void); - -UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); -UV_EXTERN void uv_dlclose(uv_lib_t* lib); -UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); -UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); - -UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); - -UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); - -UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); -UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); -UV_EXTERN void uv_sem_post(uv_sem_t* sem); -UV_EXTERN void uv_sem_wait(uv_sem_t* sem); -UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); - -UV_EXTERN int uv_cond_init(uv_cond_t* cond); -UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); -UV_EXTERN void uv_cond_signal(uv_cond_t* cond); -UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); - -UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); -UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); -UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); - -UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); -UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, - uint64_t timeout); - -UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); - -UV_EXTERN int uv_key_create(uv_key_t* key); -UV_EXTERN void uv_key_delete(uv_key_t* key); -UV_EXTERN void* uv_key_get(uv_key_t* key); -UV_EXTERN void uv_key_set(uv_key_t* key, void* value); - -typedef void (*uv_thread_cb)(void* arg); - -UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); -UV_EXTERN uv_thread_t uv_thread_self(void); -UV_EXTERN int uv_thread_join(uv_thread_t *tid); -UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); - -/* The presence of these unions force similar struct layout. */ -#define XX(_, name) uv_ ## name ## _t name; -union uv_any_handle { - UV_HANDLE_TYPE_MAP(XX) -}; - -union uv_any_req { - UV_REQ_TYPE_MAP(XX) -}; -#undef XX - - -struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - void* active_reqs[2]; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - UV_LOOP_PRIVATE_FIELDS -}; - - -/* Don't export the private CPP symbols. */ -#undef UV_HANDLE_TYPE_PRIVATE -#undef UV_REQ_TYPE_PRIVATE -#undef UV_REQ_PRIVATE_FIELDS -#undef UV_STREAM_PRIVATE_FIELDS -#undef UV_TCP_PRIVATE_FIELDS -#undef UV_PREPARE_PRIVATE_FIELDS -#undef UV_CHECK_PRIVATE_FIELDS -#undef UV_IDLE_PRIVATE_FIELDS -#undef UV_ASYNC_PRIVATE_FIELDS -#undef UV_TIMER_PRIVATE_FIELDS -#undef UV_GETADDRINFO_PRIVATE_FIELDS -#undef UV_GETNAMEINFO_PRIVATE_FIELDS -#undef UV_FS_REQ_PRIVATE_FIELDS -#undef UV_WORK_PRIVATE_FIELDS -#undef UV_FS_EVENT_PRIVATE_FIELDS -#undef UV_SIGNAL_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS - -#ifdef __cplusplus -} -#endif -#endif /* UV_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/uv.h.ori b/lib/ESPiLight/pilight/libs/libuv/uv.h.ori deleted file mode 100644 index af500cb..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/uv.h.ori +++ /dev/null @@ -1,1509 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* See https://github.com/libuv/libuv#documentation for documentation. */ - -#ifndef UV_H -#define UV_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 - /* Windows - set up dll import/export decorators. */ -# if defined(BUILDING_UV_SHARED) - /* Building shared library. */ -# define UV_EXTERN __declspec(dllexport) -# elif defined(USING_UV_SHARED) - /* Using shared library. */ -# define UV_EXTERN __declspec(dllimport) -# else - /* Building static library. */ -# define UV_EXTERN /* nothing */ -# endif -#elif __GNUC__ >= 4 -# define UV_EXTERN __attribute__((visibility("default"))) -#else -# define UV_EXTERN /* nothing */ -#endif - -#include "uv-errno.h" -#include "uv-version.h" -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#if defined(_WIN32) -# include "uv-win.h" -#else -# include "uv-unix.h" -#endif - -/* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX(E2BIG, "argument list too long") \ - XX(EACCES, "permission denied") \ - XX(EADDRINUSE, "address already in use") \ - XX(EADDRNOTAVAIL, "address not available") \ - XX(EAFNOSUPPORT, "address family not supported") \ - XX(EAGAIN, "resource temporarily unavailable") \ - XX(EAI_ADDRFAMILY, "address family not supported") \ - XX(EAI_AGAIN, "temporary failure") \ - XX(EAI_BADFLAGS, "bad ai_flags value") \ - XX(EAI_BADHINTS, "invalid value for hints") \ - XX(EAI_CANCELED, "request canceled") \ - XX(EAI_FAIL, "permanent failure") \ - XX(EAI_FAMILY, "ai_family not supported") \ - XX(EAI_MEMORY, "out of memory") \ - XX(EAI_NODATA, "no address") \ - XX(EAI_NONAME, "unknown node or service") \ - XX(EAI_OVERFLOW, "argument buffer overflow") \ - XX(EAI_PROTOCOL, "resolved protocol is unknown") \ - XX(EAI_SERVICE, "service not available for socket type") \ - XX(EAI_SOCKTYPE, "socket type not supported") \ - XX(EALREADY, "connection already in progress") \ - XX(EBADF, "bad file descriptor") \ - XX(EBUSY, "resource busy or locked") \ - XX(ECANCELED, "operation canceled") \ - XX(ECHARSET, "invalid Unicode character") \ - XX(ECONNABORTED, "software caused connection abort") \ - XX(ECONNREFUSED, "connection refused") \ - XX(ECONNRESET, "connection reset by peer") \ - XX(EDESTADDRREQ, "destination address required") \ - XX(EEXIST, "file already exists") \ - XX(EFAULT, "bad address in system call argument") \ - XX(EFBIG, "file too large") \ - XX(EHOSTUNREACH, "host is unreachable") \ - XX(EINTR, "interrupted system call") \ - XX(EINVAL, "invalid argument") \ - XX(EIO, "i/o error") \ - XX(EISCONN, "socket is already connected") \ - XX(EISDIR, "illegal operation on a directory") \ - XX(ELOOP, "too many symbolic links encountered") \ - XX(EMFILE, "too many open files") \ - XX(EMSGSIZE, "message too long") \ - XX(ENAMETOOLONG, "name too long") \ - XX(ENETDOWN, "network is down") \ - XX(ENETUNREACH, "network is unreachable") \ - XX(ENFILE, "file table overflow") \ - XX(ENOBUFS, "no buffer space available") \ - XX(ENODEV, "no such device") \ - XX(ENOENT, "no such file or directory") \ - XX(ENOMEM, "not enough memory") \ - XX(ENONET, "machine is not on the network") \ - XX(ENOPROTOOPT, "protocol not available") \ - XX(ENOSPC, "no space left on device") \ - XX(ENOSYS, "function not implemented") \ - XX(ENOTCONN, "socket is not connected") \ - XX(ENOTDIR, "not a directory") \ - XX(ENOTEMPTY, "directory not empty") \ - XX(ENOTSOCK, "socket operation on non-socket") \ - XX(ENOTSUP, "operation not supported on socket") \ - XX(EPERM, "operation not permitted") \ - XX(EPIPE, "broken pipe") \ - XX(EPROTO, "protocol error") \ - XX(EPROTONOSUPPORT, "protocol not supported") \ - XX(EPROTOTYPE, "protocol wrong type for socket") \ - XX(ERANGE, "result too large") \ - XX(EROFS, "read-only file system") \ - XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ - XX(ESPIPE, "invalid seek") \ - XX(ESRCH, "no such process") \ - XX(ETIMEDOUT, "connection timed out") \ - XX(ETXTBSY, "text file is busy") \ - XX(EXDEV, "cross-device link not permitted") \ - XX(UNKNOWN, "unknown error") \ - XX(EOF, "end of file") \ - XX(ENXIO, "no such device or address") \ - XX(EMLINK, "too many links") \ - XX(EHOSTDOWN, "host is down") \ - -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(HANDLE, handle) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(STREAM, stream) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - XX(SIGNAL, signal) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(REQ, req) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ - XX(GETNAMEINFO, getnameinfo) \ - -typedef enum { -#define XX(code, _) UV_ ## code = UV__ ## code, - UV_ERRNO_MAP(XX) -#undef XX - UV_ERRNO_MAX = UV__EOF - 1 -} uv_errno_t; - -typedef enum { - UV_UNKNOWN_HANDLE = 0, -#define XX(uc, lc) UV_##uc, - UV_HANDLE_TYPE_MAP(XX) -#undef XX - UV_FILE, - UV_HANDLE_TYPE_MAX -} uv_handle_type; - -typedef enum { - UV_UNKNOWN_REQ = 0, -#define XX(uc, lc) UV_##uc, - UV_REQ_TYPE_MAP(XX) -#undef XX - UV_REQ_TYPE_PRIVATE - UV_REQ_TYPE_MAX -} uv_req_type; - - -/* Handle types. */ -typedef struct uv_loop_s uv_loop_t; -typedef struct uv_handle_s uv_handle_t; -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tcp_s uv_tcp_t; -typedef struct uv_udp_s uv_udp_t; -typedef struct uv_pipe_s uv_pipe_t; -typedef struct uv_tty_s uv_tty_t; -typedef struct uv_poll_s uv_poll_t; -typedef struct uv_timer_s uv_timer_t; -typedef struct uv_prepare_s uv_prepare_t; -typedef struct uv_check_s uv_check_t; -typedef struct uv_idle_s uv_idle_t; -typedef struct uv_async_s uv_async_t; -typedef struct uv_process_s uv_process_t; -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; -typedef struct uv_signal_s uv_signal_t; - -/* Request types. */ -typedef struct uv_req_s uv_req_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; -typedef struct uv_getnameinfo_s uv_getnameinfo_t; -typedef struct uv_shutdown_s uv_shutdown_t; -typedef struct uv_write_s uv_write_t; -typedef struct uv_connect_s uv_connect_t; -typedef struct uv_udp_send_s uv_udp_send_t; -typedef struct uv_fs_s uv_fs_t; -typedef struct uv_work_s uv_work_t; - -/* None of the above. */ -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -typedef struct uv_dirent_s uv_dirent_t; -typedef struct uv_passwd_s uv_passwd_t; - -typedef enum { - UV_LOOP_BLOCK_SIGNAL -} uv_loop_option; - -typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT -} uv_run_mode; - - -UV_EXTERN unsigned int uv_version(void); -UV_EXTERN const char* uv_version_string(void); - -typedef void* (*uv_malloc_func)(size_t size); -typedef void* (*uv_realloc_func)(void* ptr, size_t size); -typedef void* (*uv_calloc_func)(size_t count, size_t size); -typedef void (*uv_free_func)(void* ptr); - -UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func); - -UV_EXTERN uv_loop_t* uv_default_loop(void); -UV_EXTERN int uv_loop_init(uv_loop_t* loop); -UV_EXTERN int uv_loop_close(uv_loop_t* loop); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12), users should - * allocate the loop manually and use uv_loop_init instead. - */ -UV_EXTERN uv_loop_t* uv_loop_new(void); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12). Users should use - * uv_loop_close and free the memory manually instead. - */ -UV_EXTERN void uv_loop_delete(uv_loop_t*); -UV_EXTERN size_t uv_loop_size(void); -UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); -UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); -UV_EXTERN int uv_loop_fork(uv_loop_t* loop); - -UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); -UV_EXTERN void uv_stop(uv_loop_t*); - -UV_EXTERN void uv_ref(uv_handle_t*); -UV_EXTERN void uv_unref(uv_handle_t*); -UV_EXTERN int uv_has_ref(const uv_handle_t*); - -UV_EXTERN void uv_update_time(uv_loop_t*); -UV_EXTERN uint64_t uv_now(const uv_loop_t*); - -UV_EXTERN int uv_backend_fd(const uv_loop_t*); -UV_EXTERN int uv_backend_timeout(const uv_loop_t*); - -typedef void (*uv_alloc_cb)(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); -typedef void (*uv_read_cb)(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); -typedef void (*uv_write_cb)(uv_write_t* req, int status); -typedef void (*uv_connect_cb)(uv_connect_t* req, int status); -typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); -typedef void (*uv_connection_cb)(uv_stream_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle); -typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); -typedef void (*uv_timer_cb)(uv_timer_t* handle); -typedef void (*uv_async_cb)(uv_async_t* handle); -typedef void (*uv_prepare_cb)(uv_prepare_t* handle); -typedef void (*uv_check_cb)(uv_check_t* handle); -typedef void (*uv_idle_cb)(uv_idle_t* handle); -typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); -typedef void (*uv_fs_cb)(uv_fs_t* req); -typedef void (*uv_work_cb)(uv_work_t* req); -typedef void (*uv_after_work_cb)(uv_work_t* req, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res); -typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, - int status, - const char* hostname, - const char* service); - -typedef struct { - long tv_sec; - long tv_nsec; -} uv_timespec_t; - - -typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; -} uv_stat_t; - - -typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, - const char* filename, - int events, - int status); - -typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); - - -typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP -} uv_membership; - - -UV_EXTERN int uv_translate_sys_error(int sys_errno); - -UV_EXTERN const char* uv_strerror(int err); -UV_EXTERN const char* uv_err_name(int err); - - -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_req_type type; \ - /* private */ \ - void* active_queue[2]; \ - void* reserved[4]; \ - UV_REQ_PRIVATE_FIELDS \ - -/* Abstract base class of all requests. */ -struct uv_req_s { - UV_REQ_FIELDS -}; - - -/* Platform-specific request types. */ -UV_PRIVATE_REQ_TYPES - - -UV_EXTERN int uv_shutdown(uv_shutdown_t* req, - uv_stream_t* handle, - uv_shutdown_cb cb); - -struct uv_shutdown_s { - UV_REQ_FIELDS - uv_stream_t* handle; - uv_shutdown_cb cb; - UV_SHUTDOWN_PRIVATE_FIELDS -}; - - -#define UV_HANDLE_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_loop_t* loop; \ - uv_handle_type type; \ - /* private */ \ - uv_close_cb close_cb; \ - void* handle_queue[2]; \ - union { \ - int fd; \ - void* reserved[4]; \ - } u; \ - UV_HANDLE_PRIVATE_FIELDS \ - -/* The abstract base class of all handles. */ -struct uv_handle_s { - UV_HANDLE_FIELDS -}; - -UV_EXTERN size_t uv_handle_size(uv_handle_type type); -UV_EXTERN size_t uv_req_size(uv_req_type type); - -UV_EXTERN int uv_is_active(const uv_handle_t* handle); - -UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); - -/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ -UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); -UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - -UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); - -UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); -UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); - -UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); - -UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); - - -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - /* private */ \ - UV_STREAM_PRIVATE_FIELDS - -/* - * uv_stream_t is a subclass of uv_handle_t. - * - * uv_stream is an abstract class. - * - * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. - */ -struct uv_stream_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS -}; - -UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); -UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); - -UV_EXTERN int uv_read_start(uv_stream_t*, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -UV_EXTERN int uv_read_stop(uv_stream_t*); - -UV_EXTERN int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb); -UV_EXTERN int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb); -UV_EXTERN int uv_try_write(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs); - -/* uv_write_t is a subclass of uv_req_t. */ -struct uv_write_s { - UV_REQ_FIELDS - uv_write_cb cb; - uv_stream_t* send_handle; - uv_stream_t* handle; - UV_WRITE_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_is_readable(const uv_stream_t* handle); -UV_EXTERN int uv_is_writable(const uv_stream_t* handle); - -UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); - -UV_EXTERN int uv_is_closing(const uv_handle_t* handle); - - -/* - * uv_tcp_t is a subclass of uv_stream_t. - * - * Represents a TCP stream or TCP server. - */ -struct uv_tcp_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TCP_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); -UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); -UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, - int enable, - unsigned int delay); -UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); - -enum uv_tcp_flags { - /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1 -}; - -UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb); - -/* uv_connect_t is a subclass of uv_req_t. */ -struct uv_connect_s { - UV_REQ_FIELDS - uv_connect_cb cb; - uv_stream_t* handle; - UV_CONNECT_PRIVATE_FIELDS -}; - - -/* - * UDP support. - */ - -enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4 -}; - -typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); -typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags); - -/* uv_udp_t is a subclass of uv_handle_t. */ -struct uv_udp_s { - UV_HANDLE_FIELDS - /* read-only */ - /* - * Number of bytes queued for sending. This field strictly shows how much - * information is currently queued. - */ - size_t send_queue_size; - /* - * Number of send requests currently in the queue awaiting to be processed. - */ - size_t send_queue_count; - UV_UDP_PRIVATE_FIELDS -}; - -/* uv_udp_send_t is a subclass of uv_req_t. */ -struct uv_udp_send_s { - UV_REQ_FIELDS - uv_udp_t* handle; - uv_udp_send_cb cb; - UV_UDP_SEND_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); -UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); -UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags); - -UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, - const char* interface_addr); -UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb); -UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr); -UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb); -UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); - - -/* - * uv_tty_t is a subclass of uv_stream_t. - * - * Representing a stream for the console. - */ -struct uv_tty_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TTY_PRIVATE_FIELDS -}; - -typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO -} uv_tty_mode_t; - -UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); -UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); -UV_EXTERN int uv_tty_reset_mode(void); -UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); - -#ifdef __cplusplus -extern "C++" { - -inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { - return uv_tty_set_mode(handle, static_cast(mode)); -} - -} -#endif - -UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); - -/* - * uv_pipe_t is a subclass of uv_stream_t. - * - * Representing a pipe stream or pipe server. On Windows this is a Named - * Pipe. On Unix this is a Unix domain socket. - */ -struct uv_pipe_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - int ipc; /* non-zero if this pipe is used for passing handles */ - UV_PIPE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); -UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); -UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); -UV_EXTERN void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb); -UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); -UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); -UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); - - -struct uv_poll_s { - UV_HANDLE_FIELDS - uv_poll_cb poll_cb; - UV_POLL_PRIVATE_FIELDS -}; - -enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4, - UV_PRIORITIZED = 8 -}; - -UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); -UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, - uv_poll_t* handle, - uv_os_sock_t socket); -UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); -UV_EXTERN int uv_poll_stop(uv_poll_t* handle); - - -struct uv_prepare_s { - UV_HANDLE_FIELDS - UV_PREPARE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); -UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); -UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); - - -struct uv_check_s { - UV_HANDLE_FIELDS - UV_CHECK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); -UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); -UV_EXTERN int uv_check_stop(uv_check_t* check); - - -struct uv_idle_s { - UV_HANDLE_FIELDS - UV_IDLE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); -UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); -UV_EXTERN int uv_idle_stop(uv_idle_t* idle); - - -struct uv_async_s { - UV_HANDLE_FIELDS - UV_ASYNC_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_async_init(uv_loop_t*, - uv_async_t* async, - uv_async_cb async_cb); -UV_EXTERN int uv_async_send(uv_async_t* async); - - -/* - * uv_timer_t is a subclass of uv_handle_t. - * - * Used to get woken up at a specified time in the future. - */ -struct uv_timer_s { - UV_HANDLE_FIELDS - UV_TIMER_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); -UV_EXTERN int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat); -UV_EXTERN int uv_timer_stop(uv_timer_t* handle); -UV_EXTERN int uv_timer_again(uv_timer_t* handle); -UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); -UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); - - -/* - * uv_getaddrinfo_t is a subclass of uv_req_t. - * - * Request object for uv_getaddrinfo. - */ -struct uv_getaddrinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ - UV_GETADDRINFO_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints); -UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); - - -/* -* uv_getnameinfo_t is a subclass of uv_req_t. -* -* Request object for uv_getnameinfo. -*/ -struct uv_getnameinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* host and service are marked as private, but they really aren't. */ - UV_GETNAMEINFO_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags); - - -/* uv_spawn() options. */ -typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 -} uv_stdio_flags; - -typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - - union { - uv_stream_t* stream; - int fd; - } data; -} uv_stdio_container_t; - -typedef struct uv_process_options_s { - uv_exit_cb exit_cb; /* Called after the process exits. */ - const char* file; /* Path to program to execute. */ - /* - * Command line arguments. args[0] should be the path to the program. On - * Windows this uses CreateProcess which concatenates the arguments into a - * string this can cause some strange errors. See the note at - * windows_verbatim_arguments. - */ - char** args; - /* - * This will be set as the environ variable in the subprocess. If this is - * NULL then the parents environ will be used. - */ - char** env; - /* - * If non-null this represents a directory the subprocess should execute - * in. Stands for current working directory. - */ - const char* cwd; - /* - * Various flags that control how uv_spawn() behaves. See the definition of - * `enum uv_process_flags` below. - */ - unsigned int flags; - /* - * The `stdio` field points to an array of uv_stdio_container_t structs that - * describe the file descriptors that will be made available to the child - * process. The convention is that stdio[0] points to stdin, fd 1 is used for - * stdout, and fd 2 is stderr. - * - * Note that on windows file descriptors greater than 2 are available to the - * child process only if the child processes uses the MSVCRT runtime. - */ - int stdio_count; - uv_stdio_container_t* stdio; - /* - * Libuv can change the child process' user/group id. This happens only when - * the appropriate bits are set in the flags fields. This is not supported on - * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. - */ - uv_uid_t uid; - uv_gid_t gid; -} uv_process_options_t; - -/* - * These are the flags that can be used for the uv_process_options.flags field. - */ -enum uv_process_flags { - /* - * Set the child process' user id. The user id is supplied in the `uid` field - * of the options struct. This does not work on windows; setting this flag - * will cause uv_spawn() to fail. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. The user id is supplied in the `gid` - * field of the options struct. This does not work on windows; setting this - * flag will cause uv_spawn() to fail. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4) -}; - -/* - * uv_process_t is a subclass of uv_handle_t. - */ -struct uv_process_s { - UV_HANDLE_FIELDS - uv_exit_cb exit_cb; - int pid; - UV_PROCESS_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_spawn(uv_loop_t* loop, - uv_process_t* handle, - const uv_process_options_t* options); -UV_EXTERN int uv_process_kill(uv_process_t*, int signum); -UV_EXTERN int uv_kill(int pid, int signum); - - -/* - * uv_work_t is a subclass of uv_req_t. - */ -struct uv_work_s { - UV_REQ_FIELDS - uv_loop_t* loop; - uv_work_cb work_cb; - uv_after_work_cb after_work_cb; - UV_WORK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - -UV_EXTERN int uv_cancel(uv_req_t* req); - - -struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; - } cpu_times; -}; - -struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; -}; - -struct uv_passwd_s { - char* username; - long uid; - long gid; - char* shell; - char* homedir; -}; - -typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK -} uv_dirent_type_t; - -struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; -}; - -UV_EXTERN char** uv_setup_args(int argc, char** argv); -UV_EXTERN int uv_get_process_title(char* buffer, size_t size); -UV_EXTERN int uv_set_process_title(const char* title); -UV_EXTERN int uv_resident_set_memory(size_t* rss); -UV_EXTERN int uv_uptime(double* uptime); -UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); - -typedef struct { - long tv_sec; - long tv_usec; -} uv_timeval_t; - -typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size */ - uint64_t ru_idrss; /* integral unshared data size */ - uint64_t ru_isrss; /* integral unshared stack size */ - uint64_t ru_minflt; /* page reclaims (soft page faults) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent */ - uint64_t ru_msgrcv; /* IPC messages received */ - uint64_t ru_nsignals; /* signals received */ - uint64_t ru_nvcsw; /* voluntary context switches */ - uint64_t ru_nivcsw; /* involuntary context switches */ -} uv_rusage_t; - -UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); - -UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); -UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); -UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); -UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); - -UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); -UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); - -UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, - int* count); -UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count); - -UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); -UV_EXTERN int uv_os_setenv(const char* name, const char* value); -UV_EXTERN int uv_os_unsetenv(const char* name); - -UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); - - -typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH -} uv_fs_type; - -/* uv_fs_t is a subclass of uv_req_t. */ -struct uv_fs_s { - UV_REQ_FIELDS - uv_fs_type fs_type; - uv_loop_t* loop; - uv_fs_cb cb; - ssize_t result; - void* ptr; - const char* path; - uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ - UV_FS_PRIVATE_FIELDS -}; - -UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); -UV_EXTERN int uv_fs_close(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, - uv_dirent_t* ent); -UV_EXTERN int uv_fs_stat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t in_offset, - size_t length, - uv_fs_cb cb); -UV_EXTERN int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * path argument points to a directory. - */ -#define UV_FS_SYMLINK_DIR 0x0001 - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * the symlink is to be created using junction points. - */ -#define UV_FS_SYMLINK_JUNCTION 0x0002 - -UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); - - -enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 -}; - - -struct uv_fs_event_s { - UV_HANDLE_FIELDS - /* private */ - char* path; - UV_FS_EVENT_PRIVATE_FIELDS -}; - - -/* - * uv_fs_stat() based polling file watcher. - */ -struct uv_fs_poll_s { - UV_HANDLE_FIELDS - /* Private, don't touch. */ - void* poll_ctx; -}; - -UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb poll_cb, - const char* path, - unsigned int interval); -UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, - char* buffer, - size_t* size); - - -struct uv_signal_s { - UV_HANDLE_FIELDS - uv_signal_cb signal_cb; - int signum; - UV_SIGNAL_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); -UV_EXTERN int uv_signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_stop(uv_signal_t* handle); - -UV_EXTERN void uv_loadavg(double avg[3]); - - -/* - * Flags to be passed to uv_fs_event_start(). - */ -enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote filesystems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in it's subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 -}; - - -UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags); -UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, - char* buffer, - size_t* size); - -UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); -UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); - -UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); -UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); - -UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); -UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); - -UV_EXTERN int uv_exepath(char* buffer, size_t* size); - -UV_EXTERN int uv_cwd(char* buffer, size_t* size); - -UV_EXTERN int uv_chdir(const char* dir); - -UV_EXTERN uint64_t uv_get_free_memory(void); -UV_EXTERN uint64_t uv_get_total_memory(void); - -UV_EXTERN uint64_t uv_hrtime(void); - -UV_EXTERN void uv_disable_stdio_inheritance(void); - -UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); -UV_EXTERN void uv_dlclose(uv_lib_t* lib); -UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); -UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); - -UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); - -UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); - -UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); -UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); -UV_EXTERN void uv_sem_post(uv_sem_t* sem); -UV_EXTERN void uv_sem_wait(uv_sem_t* sem); -UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); - -UV_EXTERN int uv_cond_init(uv_cond_t* cond); -UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); -UV_EXTERN void uv_cond_signal(uv_cond_t* cond); -UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); - -UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); -UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); -UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); - -UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); -UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, - uint64_t timeout); - -UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); - -UV_EXTERN int uv_key_create(uv_key_t* key); -UV_EXTERN void uv_key_delete(uv_key_t* key); -UV_EXTERN void* uv_key_get(uv_key_t* key); -UV_EXTERN void uv_key_set(uv_key_t* key, void* value); - -typedef void (*uv_thread_cb)(void* arg); - -UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); -UV_EXTERN uv_thread_t uv_thread_self(void); -UV_EXTERN int uv_thread_join(uv_thread_t *tid); -UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); - -/* The presence of these unions force similar struct layout. */ -#define XX(_, name) uv_ ## name ## _t name; -union uv_any_handle { - UV_HANDLE_TYPE_MAP(XX) -}; - -union uv_any_req { - UV_REQ_TYPE_MAP(XX) -}; -#undef XX - - -struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - void* active_reqs[2]; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - UV_LOOP_PRIVATE_FIELDS -}; - - -/* Don't export the private CPP symbols. */ -#undef UV_HANDLE_TYPE_PRIVATE -#undef UV_REQ_TYPE_PRIVATE -#undef UV_REQ_PRIVATE_FIELDS -#undef UV_STREAM_PRIVATE_FIELDS -#undef UV_TCP_PRIVATE_FIELDS -#undef UV_PREPARE_PRIVATE_FIELDS -#undef UV_CHECK_PRIVATE_FIELDS -#undef UV_IDLE_PRIVATE_FIELDS -#undef UV_ASYNC_PRIVATE_FIELDS -#undef UV_TIMER_PRIVATE_FIELDS -#undef UV_GETADDRINFO_PRIVATE_FIELDS -#undef UV_GETNAMEINFO_PRIVATE_FIELDS -#undef UV_FS_REQ_PRIVATE_FIELDS -#undef UV_WORK_PRIVATE_FIELDS -#undef UV_FS_EVENT_PRIVATE_FIELDS -#undef UV_SIGNAL_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS - -#ifdef __cplusplus -} -#endif -#endif /* UV_H */ diff --git a/lib/ESPiLight/pilight/libs/libuv/version.c b/lib/ESPiLight/pilight/libs/libuv/version.c deleted file mode 100644 index 686dedd..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/version.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" - -#define UV_STRINGIFY(v) UV_STRINGIFY_HELPER(v) -#define UV_STRINGIFY_HELPER(v) #v - -#define UV_VERSION_STRING_BASE UV_STRINGIFY(UV_VERSION_MAJOR) "." \ - UV_STRINGIFY(UV_VERSION_MINOR) "." \ - UV_STRINGIFY(UV_VERSION_PATCH) - -#if UV_VERSION_IS_RELEASE -# define UV_VERSION_STRING UV_VERSION_STRING_BASE -#else -# define UV_VERSION_STRING UV_VERSION_STRING_BASE "-" UV_VERSION_SUFFIX -#endif - - -unsigned int uv_version(void) { - return UV_VERSION_HEX; -} - - -const char* uv_version_string(void) { - return UV_VERSION_STRING; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/async.c b/lib/ESPiLight/pilight/libs/libuv/win/async.c deleted file mode 100644 index 0b636ed..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/async.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include - -#include "uv.h" -#include "internal.h" -#include "atomicops-inl.h" -#include "handle-inl.h" -#include "req-inl.h" - - -void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING && - !handle->async_sent) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { - uv_req_t* req; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_ASYNC); - handle->async_sent = 0; - handle->async_cb = async_cb; - - req = &handle->async_req; - UV_REQ_INIT(req, UV_WAKEUP); - req->data = handle; - - uv__handle_start(handle); - - return 0; -} - - -void uv_async_close(uv_loop_t* loop, uv_async_t* handle) { - if (!((uv_async_t*)handle)->async_sent) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - - uv__handle_closing(handle); -} - - -int uv_async_send(uv_async_t* handle) { - uv_loop_t* loop = handle->loop; - - if (handle->type != UV_ASYNC) { - /* Can't set errno because that's not thread-safe. */ - return -1; - } - - /* The user should make sure never to call uv_async_send to a closing */ - /* or closed handle. */ - assert(!(handle->flags & UV__HANDLE_CLOSING)); - - if (!uv__atomic_exchange_set(&handle->async_sent)) { - POST_COMPLETION_FOR_REQ(loop, &handle->async_req); - } - - return 0; -} - - -void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle, - uv_req_t* req) { - assert(handle->type == UV_ASYNC); - assert(req->type == UV_WAKEUP); - - handle->async_sent = 0; - - if (handle->flags & UV__HANDLE_CLOSING) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } else if (handle->async_cb != NULL) { - handle->async_cb(handle); - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/atomicops-inl.h b/lib/ESPiLight/pilight/libs/libuv/win/atomicops-inl.h deleted file mode 100644 index 6d8126f..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/atomicops-inl.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_ATOMICOPS_INL_H_ -#define UV_WIN_ATOMICOPS_INL_H_ - -#include "uv.h" -#include "internal.h" - - -/* Atomic set operation on char */ -#ifdef _MSC_VER /* MSVC */ - -/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less */ -/* efficient than InterlockedExchange, but InterlockedExchange8 does not */ -/* exist, and interlocked operations on larger targets might require the */ -/* target to be aligned. */ -#pragma intrinsic(_InterlockedOr8) - -static char INLINE uv__atomic_exchange_set(char volatile* target) { - return _InterlockedOr8(target, 1); -} - -#else /* GCC */ - -/* Mingw-32 version, hopefully this works for 64-bit gcc as well. */ -static inline char uv__atomic_exchange_set(char volatile* target) { - const char one = 1; - char old_value; - __asm__ __volatile__ ("lock xchgb %0, %1\n\t" - : "=r"(old_value), "=m"(*target) - : "0"(one), "m"(*target) - : "memory"); - return old_value; -} - -#endif - -#endif /* UV_WIN_ATOMICOPS_INL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/win/core.c b/lib/ESPiLight/pilight/libs/libuv/win/core.c deleted file mode 100644 index 9ed4e82..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/core.c +++ /dev/null @@ -1,605 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR) -#include -#endif - -#include "uv.h" -#include "internal.h" -#include "queue.h" -#include "handle-inl.h" -#include "req-inl.h" - -/* uv_once initialization guards */ -static uv_once_t uv_init_guard_ = UV_ONCE_INIT; - - -#if defined(_DEBUG) && (defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)) -/* Our crt debug report handler allows us to temporarily disable asserts - * just for the current thread. - */ - -UV_THREAD_LOCAL int uv__crt_assert_enabled = TRUE; - -static int uv__crt_dbg_report_handler(int report_type, char *message, int *ret_val) { - if (uv__crt_assert_enabled || report_type != _CRT_ASSERT) - return FALSE; - - if (ret_val) { - /* Set ret_val to 0 to continue with normal execution. - * Set ret_val to 1 to trigger a breakpoint. - */ - - if(IsDebuggerPresent()) - *ret_val = 1; - else - *ret_val = 0; - } - - /* Don't call _CrtDbgReport. */ - return TRUE; -} -#else -UV_THREAD_LOCAL int uv__crt_assert_enabled = FALSE; -#endif - - -#if !defined(__MINGW32__) || __MSVCRT_VERSION__ >= 0x800 -static void uv__crt_invalid_parameter_handler(const wchar_t* expression, - const wchar_t* function, const wchar_t * file, unsigned int line, - uintptr_t reserved) { - /* No-op. */ -} -#endif - -static uv_loop_t** uv__loops; -static int uv__loops_size; -static int uv__loops_capacity; -#define UV__LOOPS_CHUNK_SIZE 8 -static uv_mutex_t uv__loops_lock; - -static void uv__loops_init(void) { - uv_mutex_init(&uv__loops_lock); -} - -static int uv__loops_add(uv_loop_t* loop) { - uv_loop_t** new_loops; - int new_capacity, i; - - uv_mutex_lock(&uv__loops_lock); - - if (uv__loops_size == uv__loops_capacity) { - new_capacity = uv__loops_capacity + UV__LOOPS_CHUNK_SIZE; - new_loops = uv__realloc(uv__loops, sizeof(uv_loop_t*) * new_capacity); - if (!new_loops) - goto failed_loops_realloc; - uv__loops = new_loops; - for (i = uv__loops_capacity; i < new_capacity; ++i) - uv__loops[i] = NULL; - uv__loops_capacity = new_capacity; - } - uv__loops[uv__loops_size] = loop; - ++uv__loops_size; - - uv_mutex_unlock(&uv__loops_lock); - return 0; - -failed_loops_realloc: - uv_mutex_unlock(&uv__loops_lock); - return ERROR_OUTOFMEMORY; -} - -static void uv__loops_remove(uv_loop_t* loop) { - int loop_index; - int smaller_capacity; - uv_loop_t** new_loops; - - uv_mutex_lock(&uv__loops_lock); - - for (loop_index = 0; loop_index < uv__loops_size; ++loop_index) { - if (uv__loops[loop_index] == loop) - break; - } - /* If loop was not found, ignore */ - if (loop_index == uv__loops_size) - goto loop_removed; - - uv__loops[loop_index] = uv__loops[uv__loops_size - 1]; - uv__loops[uv__loops_size - 1] = NULL; - --uv__loops_size; - - if (uv__loops_size == 0) { - uv__loops_capacity = 0; - uv__free(uv__loops); - uv__loops = NULL; - goto loop_removed; - } - - /* If we didn't grow to big skip downsizing */ - if (uv__loops_capacity < 4 * UV__LOOPS_CHUNK_SIZE) - goto loop_removed; - - /* Downsize only if more than half of buffer is free */ - smaller_capacity = uv__loops_capacity / 2; - if (uv__loops_size >= smaller_capacity) - goto loop_removed; - new_loops = uv__realloc(uv__loops, sizeof(uv_loop_t*) * smaller_capacity); - if (!new_loops) - goto loop_removed; - uv__loops = new_loops; - uv__loops_capacity = smaller_capacity; - -loop_removed: - uv_mutex_unlock(&uv__loops_lock); -} - -void uv__wake_all_loops(void) { - int i; - uv_loop_t* loop; - - uv_mutex_lock(&uv__loops_lock); - for (i = 0; i < uv__loops_size; ++i) { - loop = uv__loops[i]; - assert(loop); - if (loop->iocp != INVALID_HANDLE_VALUE) - PostQueuedCompletionStatus(loop->iocp, 0, 0, NULL); - } - uv_mutex_unlock(&uv__loops_lock); -} - -static void uv_init(void) { - /* Tell Windows that we will handle critical errors. */ - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | - SEM_NOOPENFILEERRORBOX); - - /* Tell the CRT to not exit the application when an invalid parameter is - * passed. The main issue is that invalid FDs will trigger this behavior. - */ -#if !defined(__MINGW32__) || __MSVCRT_VERSION__ >= 0x800 - _set_invalid_parameter_handler(uv__crt_invalid_parameter_handler); -#endif - - /* We also need to setup our debug report handler because some CRT - * functions (eg _get_osfhandle) raise an assert when called with invalid - * FDs even though they return the proper error code in the release build. - */ -#if defined(_DEBUG) && (defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)) - _CrtSetReportHook(uv__crt_dbg_report_handler); -#endif - - /* Initialize tracking of all uv loops */ - uv__loops_init(); - - /* Fetch winapi function pointers. This must be done first because other - * initialization code might need these function pointers to be loaded. - */ - uv_winapi_init(); - - /* Initialize winsock */ - uv_winsock_init(); - - /* Initialize FS */ - uv_fs_init(); - - /* Initialize signal stuff */ - uv_signals_init(); - - /* Initialize console */ - uv_console_init(); - - /* Initialize utilities */ - uv__util_init(); - - /* Initialize system wakeup detection */ - uv__init_detect_system_wakeup(); -} - - -int uv_loop_init(uv_loop_t* loop) { - int err; - - /* Initialize libuv itself first */ - uv__once_init(); - - /* Create an I/O completion port */ - loop->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1); - if (loop->iocp == NULL) - return uv_translate_sys_error(GetLastError()); - - /* To prevent uninitialized memory access, loop->time must be initialized - * to zero before calling uv_update_time for the first time. - */ - loop->time = 0; - uv_update_time(loop); - - QUEUE_INIT(&loop->wq); - QUEUE_INIT(&loop->handle_queue); - QUEUE_INIT(&loop->active_reqs); - loop->active_handles = 0; - - loop->pending_reqs_tail = NULL; - - loop->endgame_handles = NULL; - - RB_INIT(&loop->timers); - - loop->check_handles = NULL; - loop->prepare_handles = NULL; - loop->idle_handles = NULL; - - loop->next_prepare_handle = NULL; - loop->next_check_handle = NULL; - loop->next_idle_handle = NULL; - - memset(&loop->poll_peer_sockets, 0, sizeof loop->poll_peer_sockets); - - loop->active_tcp_streams = 0; - loop->active_udp_streams = 0; - - loop->timer_counter = 0; - loop->stop_flag = 0; - - err = uv_mutex_init(&loop->wq_mutex); - if (err) - goto fail_mutex_init; - - err = uv_async_init(loop, &loop->wq_async, uv__work_done); - if (err) - goto fail_async_init; - - uv__handle_unref(&loop->wq_async); - loop->wq_async.flags |= UV__HANDLE_INTERNAL; - - err = uv__loops_add(loop); - if (err) - goto fail_async_init; - - return 0; - -fail_async_init: - uv_mutex_destroy(&loop->wq_mutex); - -fail_mutex_init: - CloseHandle(loop->iocp); - loop->iocp = INVALID_HANDLE_VALUE; - - return err; -} - - -void uv__once_init(void) { - uv_once(&uv_init_guard_, uv_init); -} - - -void uv__loop_close(uv_loop_t* loop) { - size_t i; - - uv__loops_remove(loop); - - /* close the async handle without needing an extra loop iteration */ - assert(!loop->wq_async.async_sent); - loop->wq_async.close_cb = NULL; - uv__handle_closing(&loop->wq_async); - uv__handle_close(&loop->wq_async); - - for (i = 0; i < ARRAY_SIZE(loop->poll_peer_sockets); i++) { - SOCKET sock = loop->poll_peer_sockets[i]; - if (sock != 0 && sock != INVALID_SOCKET) - closesocket(sock); - } - - uv_mutex_lock(&loop->wq_mutex); - assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!"); - assert(!uv__has_active_reqs(loop)); - uv_mutex_unlock(&loop->wq_mutex); - uv_mutex_destroy(&loop->wq_mutex); - - CloseHandle(loop->iocp); -} - - -int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) { - return UV_ENOSYS; -} - - -int uv_backend_fd(const uv_loop_t* loop) { - return -1; -} - - -int uv_loop_fork(uv_loop_t* loop) { - return UV_ENOSYS; -} - - -int uv_backend_timeout(const uv_loop_t* loop) { - if (loop->stop_flag != 0) - return 0; - - if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop)) - return 0; - - if (loop->pending_reqs_tail) - return 0; - - if (loop->endgame_handles) - return 0; - - if (loop->idle_handles) - return 0; - - return uv__next_timeout(loop); -} - - -static void uv_poll(uv_loop_t* loop, DWORD timeout) { - DWORD bytes; - ULONG_PTR key; - OVERLAPPED* overlapped; - uv_req_t* req; - int repeat; - uint64_t timeout_time; - - timeout_time = loop->time + timeout; - - for (repeat = 0; ; repeat++) { - GetQueuedCompletionStatus(loop->iocp, - &bytes, - &key, - &overlapped, - timeout); - - if (overlapped) { - /* Package was dequeued */ - req = uv_overlapped_to_req(overlapped); - uv_insert_pending_req(loop, req); - - /* Some time might have passed waiting for I/O, - * so update the loop time here. - */ - uv_update_time(loop); - } else if (GetLastError() != WAIT_TIMEOUT) { - /* Serious error */ - uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus"); - } else if (timeout > 0) { - /* GetQueuedCompletionStatus can occasionally return a little early. - * Make sure that the desired timeout target time is reached. - */ - uv_update_time(loop); - if (timeout_time > loop->time) { - timeout = (DWORD)(timeout_time - loop->time); - /* The first call to GetQueuedCompletionStatus should return very - * close to the target time and the second should reach it, but - * this is not stated in the documentation. To make sure a busy - * loop cannot happen, the timeout is increased exponentially - * starting on the third round. - */ - timeout += repeat ? (1 << (repeat - 1)) : 0; - continue; - } - } - break; - } -} - - -static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) { - BOOL success; - uv_req_t* req; - OVERLAPPED_ENTRY overlappeds[128]; - ULONG count; - ULONG i; - int repeat; - uint64_t timeout_time; - - timeout_time = loop->time + timeout; - - for (repeat = 0; ; repeat++) { - success = pGetQueuedCompletionStatusEx(loop->iocp, - overlappeds, - ARRAY_SIZE(overlappeds), - &count, - timeout, - FALSE); - - if (success) { - for (i = 0; i < count; i++) { - /* Package was dequeued, but see if it is not a empty package - * meant only to wake us up. - */ - if (overlappeds[i].lpOverlapped) { - req = uv_overlapped_to_req(overlappeds[i].lpOverlapped); - uv_insert_pending_req(loop, req); - } - } - - /* Some time might have passed waiting for I/O, - * so update the loop time here. - */ - uv_update_time(loop); - } else if (GetLastError() != WAIT_TIMEOUT) { - /* Serious error */ - uv_fatal_error(GetLastError(), "GetQueuedCompletionStatusEx"); - } else if (timeout > 0) { - /* GetQueuedCompletionStatus can occasionally return a little early. - * Make sure that the desired timeout target time is reached. - */ - uv_update_time(loop); - if (timeout_time > loop->time) { - timeout = (DWORD)(timeout_time - loop->time); - /* The first call to GetQueuedCompletionStatus should return very - * close to the target time and the second should reach it, but - * this is not stated in the documentation. To make sure a busy - * loop cannot happen, the timeout is increased exponentially - * starting on the third round. - */ - timeout += repeat ? (1 << (repeat - 1)) : 0; - continue; - } - } - break; - } -} - - -static int uv__loop_alive(const uv_loop_t* loop) { - return loop->active_handles > 0 || - !QUEUE_EMPTY(&loop->active_reqs) || - loop->endgame_handles != NULL; -} - - -int uv_loop_alive(const uv_loop_t* loop) { - return uv__loop_alive(loop); -} - - -int uv_run(uv_loop_t *loop, uv_run_mode mode) { - DWORD timeout; - int r; - int ran_pending; - void (*poll)(uv_loop_t* loop, DWORD timeout); - - if (pGetQueuedCompletionStatusEx) - poll = &uv_poll_ex; - else - poll = &uv_poll; - - r = uv__loop_alive(loop); - if (!r) - uv_update_time(loop); - - while (r != 0 && loop->stop_flag == 0) { - uv_update_time(loop); - uv_process_timers(loop); - - ran_pending = uv_process_reqs(loop); - uv_idle_invoke(loop); - uv_prepare_invoke(loop); - - timeout = 0; - if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT) - timeout = uv_backend_timeout(loop); - - (*poll)(loop, timeout); - - uv_check_invoke(loop); - uv_process_endgames(loop); - - if (mode == UV_RUN_ONCE) { - /* UV_RUN_ONCE implies forward progress: at least one callback must have - * been invoked when it returns. uv__io_poll() can return without doing - * I/O (meaning: no callbacks) when its timeout expires - which means we - * have pending timers that satisfy the forward progress constraint. - * - * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from - * the check. - */ - uv_process_timers(loop); - } - - r = uv__loop_alive(loop); - if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) - break; - } - - /* The if statement lets the compiler compile it to a conditional store. - * Avoids dirtying a cache line. - */ - if (loop->stop_flag != 0) - loop->stop_flag = 0; - - return r; -} - - -int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) { - uv_os_fd_t fd_out; - - switch (handle->type) { - case UV_TCP: - fd_out = (uv_os_fd_t)((uv_tcp_t*) handle)->socket; - break; - - case UV_NAMED_PIPE: - fd_out = ((uv_pipe_t*) handle)->handle; - break; - - case UV_TTY: - fd_out = ((uv_tty_t*) handle)->handle; - break; - - case UV_UDP: - fd_out = (uv_os_fd_t)((uv_udp_t*) handle)->socket; - break; - - case UV_POLL: - fd_out = (uv_os_fd_t)((uv_poll_t*) handle)->socket; - break; - - default: - return UV_EINVAL; - } - - if (uv_is_closing(handle) || fd_out == INVALID_HANDLE_VALUE) - return UV_EBADF; - - *fd = fd_out; - return 0; -} - - -int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) { - int r; - int len; - SOCKET socket; - - if (handle == NULL || value == NULL) - return UV_EINVAL; - - if (handle->type == UV_TCP) - socket = ((uv_tcp_t*) handle)->socket; - else if (handle->type == UV_UDP) - socket = ((uv_udp_t*) handle)->socket; - else - return UV_ENOTSUP; - - len = sizeof(*value); - - if (*value == 0) - r = getsockopt(socket, SOL_SOCKET, optname, (char*) value, &len); - else - r = setsockopt(socket, SOL_SOCKET, optname, (const char*) value, len); - - if (r == SOCKET_ERROR) - return uv_translate_sys_error(WSAGetLastError()); - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/detect-wakeup.c b/lib/ESPiLight/pilight/libs/libuv/win/detect-wakeup.c deleted file mode 100644 index 72dfb7a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/detect-wakeup.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "uv.h" -#include "internal.h" -#include "winapi.h" - -static void uv__register_system_resume_callback(void); - -void uv__init_detect_system_wakeup(void) { - /* Try registering system power event callback. This is the cleanest - * method, but it will only work on Win8 and above. - */ - uv__register_system_resume_callback(); -} - -static ULONG CALLBACK uv__system_resume_callback(PVOID Context, - ULONG Type, - PVOID Setting) { - if (Type == PBT_APMRESUMESUSPEND || Type == PBT_APMRESUMEAUTOMATIC) - uv__wake_all_loops(); - - return 0; -} - -static void uv__register_system_resume_callback(void) { - _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS recipient; - _HPOWERNOTIFY registration_handle; - - if (pPowerRegisterSuspendResumeNotification == NULL) - return; - - recipient.Callback = uv__system_resume_callback; - recipient.Context = NULL; - (*pPowerRegisterSuspendResumeNotification)(DEVICE_NOTIFY_CALLBACK, - &recipient, - ®istration_handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/dl.c b/lib/ESPiLight/pilight/libs/libuv/win/dl.c deleted file mode 100644 index 39e400a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/dl.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "internal.h" - -static int uv__dlerror(uv_lib_t* lib, int errorno); - - -int uv_dlopen(const char* filename, uv_lib_t* lib) { - WCHAR filename_w[32768]; - - lib->handle = NULL; - lib->errmsg = NULL; - - if (!MultiByteToWideChar(CP_UTF8, - 0, - filename, - -1, - filename_w, - ARRAY_SIZE(filename_w))) { - return uv__dlerror(lib, GetLastError()); - } - - lib->handle = LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (lib->handle == NULL) { - return uv__dlerror(lib, GetLastError()); - } - - return 0; -} - - -void uv_dlclose(uv_lib_t* lib) { - if (lib->errmsg) { - LocalFree((void*)lib->errmsg); - lib->errmsg = NULL; - } - - if (lib->handle) { - /* Ignore errors. No good way to signal them without leaking memory. */ - FreeLibrary(lib->handle); - lib->handle = NULL; - } -} - - -int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { - *ptr = (void*) GetProcAddress(lib->handle, name); - return uv__dlerror(lib, *ptr ? 0 : GetLastError()); -} - - -const char* uv_dlerror(const uv_lib_t* lib) { - return lib->errmsg ? lib->errmsg : "no error"; -} - - -static void uv__format_fallback_error(uv_lib_t* lib, int errorno){ - DWORD_PTR args[1] = { (DWORD_PTR) errorno }; - LPSTR fallback_error = "error: %1!d!"; - - FormatMessageA(FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY | - FORMAT_MESSAGE_ALLOCATE_BUFFER, - fallback_error, 0, 0, - (LPSTR) &lib->errmsg, - 0, (va_list*) args); -} - - - -static int uv__dlerror(uv_lib_t* lib, int errorno) { - DWORD res; - - if (lib->errmsg) { - LocalFree((void*)lib->errmsg); - lib->errmsg = NULL; - } - - if (errorno) { - res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, - MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), - (LPSTR) &lib->errmsg, 0, NULL); - if (!res && GetLastError() == ERROR_MUI_FILE_NOT_FOUND) { - res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, - 0, (LPSTR) &lib->errmsg, 0, NULL); - } - - if (!res) { - uv__format_fallback_error(lib, errorno); - } - } - - return errorno ? -1 : 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/error.c b/lib/ESPiLight/pilight/libs/libuv/win/error.c deleted file mode 100644 index 642d111..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/error.c +++ /dev/null @@ -1,171 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" - - -/* - * Display an error message and abort the event loop. - */ -void uv_fatal_error(const int errorno, const char* syscall) { - char* buf = NULL; - const char* errmsg; - - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL); - - if (buf) { - errmsg = buf; - } else { - errmsg = "Unknown error"; - } - - /* FormatMessage messages include a newline character already, */ - /* so don't add another. */ - if (syscall) { - fprintf(stderr, "%s: (%d) %s", syscall, errorno, errmsg); - } else { - fprintf(stderr, "(%d) %s", errorno, errmsg); - } - - if (buf) { - LocalFree(buf); - } - - *((char*)NULL) = 0xff; /* Force debug break */ - abort(); -} - - -int uv_translate_sys_error(int sys_errno) { - if (sys_errno <= 0) { - return sys_errno; /* If < 0 then it's already a libuv error. */ - } - - switch (sys_errno) { - case ERROR_NOACCESS: return UV_EACCES; - case WSAEACCES: return UV_EACCES; - case ERROR_ELEVATION_REQUIRED: return UV_EACCES; - case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE; - case WSAEADDRINUSE: return UV_EADDRINUSE; - case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL; - case WSAEAFNOSUPPORT: return UV_EAFNOSUPPORT; - case WSAEWOULDBLOCK: return UV_EAGAIN; - case WSAEALREADY: return UV_EALREADY; - case ERROR_INVALID_FLAGS: return UV_EBADF; - case ERROR_INVALID_HANDLE: return UV_EBADF; - case ERROR_LOCK_VIOLATION: return UV_EBUSY; - case ERROR_PIPE_BUSY: return UV_EBUSY; - case ERROR_SHARING_VIOLATION: return UV_EBUSY; - case ERROR_OPERATION_ABORTED: return UV_ECANCELED; - case WSAEINTR: return UV_ECANCELED; - case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET; - case ERROR_CONNECTION_ABORTED: return UV_ECONNABORTED; - case WSAECONNABORTED: return UV_ECONNABORTED; - case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED; - case WSAECONNREFUSED: return UV_ECONNREFUSED; - case ERROR_NETNAME_DELETED: return UV_ECONNRESET; - case WSAECONNRESET: return UV_ECONNRESET; - case ERROR_ALREADY_EXISTS: return UV_EEXIST; - case ERROR_FILE_EXISTS: return UV_EEXIST; - case ERROR_BUFFER_OVERFLOW: return UV_EFAULT; - case WSAEFAULT: return UV_EFAULT; - case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH; - case WSAEHOSTUNREACH: return UV_EHOSTUNREACH; - case ERROR_INSUFFICIENT_BUFFER: return UV_EINVAL; - case ERROR_INVALID_DATA: return UV_EINVAL; - case ERROR_INVALID_PARAMETER: return UV_EINVAL; - case ERROR_SYMLINK_NOT_SUPPORTED: return UV_EINVAL; - case WSAEINVAL: return UV_EINVAL; - case WSAEPFNOSUPPORT: return UV_EINVAL; - case WSAESOCKTNOSUPPORT: return UV_EINVAL; - case ERROR_BEGINNING_OF_MEDIA: return UV_EIO; - case ERROR_BUS_RESET: return UV_EIO; - case ERROR_CRC: return UV_EIO; - case ERROR_DEVICE_DOOR_OPEN: return UV_EIO; - case ERROR_DEVICE_REQUIRES_CLEANING: return UV_EIO; - case ERROR_DISK_CORRUPT: return UV_EIO; - case ERROR_EOM_OVERFLOW: return UV_EIO; - case ERROR_FILEMARK_DETECTED: return UV_EIO; - case ERROR_GEN_FAILURE: return UV_EIO; - case ERROR_INVALID_BLOCK_LENGTH: return UV_EIO; - case ERROR_IO_DEVICE: return UV_EIO; - case ERROR_NO_DATA_DETECTED: return UV_EIO; - case ERROR_NO_SIGNAL_SENT: return UV_EIO; - case ERROR_OPEN_FAILED: return UV_EIO; - case ERROR_SETMARK_DETECTED: return UV_EIO; - case ERROR_SIGNAL_REFUSED: return UV_EIO; - case WSAEISCONN: return UV_EISCONN; - case ERROR_CANT_RESOLVE_FILENAME: return UV_ELOOP; - case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE; - case WSAEMFILE: return UV_EMFILE; - case WSAEMSGSIZE: return UV_EMSGSIZE; - case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG; - case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH; - case WSAENETUNREACH: return UV_ENETUNREACH; - case WSAENOBUFS: return UV_ENOBUFS; - case ERROR_BAD_PATHNAME: return UV_ENOENT; - case ERROR_DIRECTORY: return UV_ENOENT; - case ERROR_FILE_NOT_FOUND: return UV_ENOENT; - case ERROR_INVALID_NAME: return UV_ENOENT; - case ERROR_INVALID_DRIVE: return UV_ENOENT; - case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT; - case ERROR_MOD_NOT_FOUND: return UV_ENOENT; - case ERROR_PATH_NOT_FOUND: return UV_ENOENT; - case WSAHOST_NOT_FOUND: return UV_ENOENT; - case WSANO_DATA: return UV_ENOENT; - case ERROR_NOT_ENOUGH_MEMORY: return UV_ENOMEM; - case ERROR_OUTOFMEMORY: return UV_ENOMEM; - case ERROR_CANNOT_MAKE: return UV_ENOSPC; - case ERROR_DISK_FULL: return UV_ENOSPC; - case ERROR_EA_TABLE_FULL: return UV_ENOSPC; - case ERROR_END_OF_MEDIA: return UV_ENOSPC; - case ERROR_HANDLE_DISK_FULL: return UV_ENOSPC; - case ERROR_NOT_CONNECTED: return UV_ENOTCONN; - case WSAENOTCONN: return UV_ENOTCONN; - case ERROR_DIR_NOT_EMPTY: return UV_ENOTEMPTY; - case WSAENOTSOCK: return UV_ENOTSOCK; - case ERROR_NOT_SUPPORTED: return UV_ENOTSUP; - case ERROR_BROKEN_PIPE: return UV_EOF; - case ERROR_ACCESS_DENIED: return UV_EPERM; - case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM; - case ERROR_BAD_PIPE: return UV_EPIPE; - case ERROR_NO_DATA: return UV_EPIPE; - case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE; - case WSAESHUTDOWN: return UV_EPIPE; - case WSAEPROTONOSUPPORT: return UV_EPROTONOSUPPORT; - case ERROR_WRITE_PROTECT: return UV_EROFS; - case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT; - case WSAETIMEDOUT: return UV_ETIMEDOUT; - case ERROR_NOT_SAME_DEVICE: return UV_EXDEV; - case ERROR_INVALID_FUNCTION: return UV_EISDIR; - case ERROR_META_EXPANSION_TOO_LONG: return UV_E2BIG; - default: return UV_UNKNOWN; - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/fs-event.c b/lib/ESPiLight/pilight/libs/libuv/win/fs-event.c deleted file mode 100644 index 95f843a..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/fs-event.c +++ /dev/null @@ -1,561 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -const unsigned int uv_directory_watcher_buffer_size = 4096; - - -static void uv_fs_event_queue_readdirchanges(uv_loop_t* loop, - uv_fs_event_t* handle) { - assert(handle->dir_handle != INVALID_HANDLE_VALUE); - assert(!handle->req_pending); - - memset(&(handle->req.u.io.overlapped), 0, - sizeof(handle->req.u.io.overlapped)); - if (!ReadDirectoryChangesW(handle->dir_handle, - handle->buffer, - uv_directory_watcher_buffer_size, - (handle->flags & UV_FS_EVENT_RECURSIVE) ? TRUE : FALSE, - FILE_NOTIFY_CHANGE_FILE_NAME | - FILE_NOTIFY_CHANGE_DIR_NAME | - FILE_NOTIFY_CHANGE_ATTRIBUTES | - FILE_NOTIFY_CHANGE_SIZE | - FILE_NOTIFY_CHANGE_LAST_WRITE | - FILE_NOTIFY_CHANGE_LAST_ACCESS | - FILE_NOTIFY_CHANGE_CREATION | - FILE_NOTIFY_CHANGE_SECURITY, - NULL, - &handle->req.u.io.overlapped, - NULL)) { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(&handle->req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)&handle->req); - } - - handle->req_pending = 1; -} - -static void uv_relative_path(const WCHAR* filename, - const WCHAR* dir, - WCHAR** relpath) { - size_t relpathlen; - size_t filenamelen = wcslen(filename); - size_t dirlen = wcslen(dir); - if (dirlen > 0 && dir[dirlen - 1] == '\\') - dirlen--; - relpathlen = filenamelen - dirlen - 1; - *relpath = uv__malloc((relpathlen + 1) * sizeof(WCHAR)); - if (!*relpath) - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - wcsncpy(*relpath, filename + dirlen + 1, relpathlen); - (*relpath)[relpathlen] = L'\0'; -} - -static int uv_split_path(const WCHAR* filename, WCHAR** dir, - WCHAR** file) { - size_t len, i; - - if (filename == NULL) { - if (dir != NULL) - *dir = NULL; - *file = NULL; - return 0; - } - - len = wcslen(filename); - i = len; - while (i > 0 && filename[--i] != '\\' && filename[i] != '/'); - - if (i == 0) { - if (dir) { - *dir = (WCHAR*)uv__malloc((MAX_PATH + 1) * sizeof(WCHAR)); - if (!*dir) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!GetCurrentDirectoryW(MAX_PATH, *dir)) { - uv__free(*dir); - *dir = NULL; - return -1; - } - } - - *file = wcsdup(filename); - } else { - if (dir) { - *dir = (WCHAR*)uv__malloc((i + 2) * sizeof(WCHAR)); - if (!*dir) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - wcsncpy(*dir, filename, i + 1); - (*dir)[i + 1] = L'\0'; - } - - *file = (WCHAR*)uv__malloc((len - i) * sizeof(WCHAR)); - if (!*file) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - wcsncpy(*file, filename + i + 1, len - i - 1); - (*file)[len - i - 1] = L'\0'; - } - - return 0; -} - - -int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_FS_EVENT); - handle->dir_handle = INVALID_HANDLE_VALUE; - handle->buffer = NULL; - handle->req_pending = 0; - handle->filew = NULL; - handle->short_filew = NULL; - handle->dirw = NULL; - - UV_REQ_INIT(&handle->req, UV_FS_EVENT_REQ); - handle->req.data = handle; - - return 0; -} - - -int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags) { - int name_size, is_path_dir; - DWORD attr, last_error; - WCHAR* dir = NULL, *dir_to_watch, *pathw = NULL; - WCHAR short_path_buffer[MAX_PATH]; - WCHAR* short_path; - - if (uv__is_active(handle)) - return UV_EINVAL; - - handle->cb = cb; - handle->path = uv__strdup(path); - if (!handle->path) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - uv__handle_start(handle); - - /* Convert name to UTF16. */ - - name_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0) * - sizeof(WCHAR); - pathw = (WCHAR*)uv__malloc(name_size); - if (!pathw) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - path, - -1, - pathw, - name_size / sizeof(WCHAR))) { - return uv_translate_sys_error(GetLastError()); - } - - /* Determine whether path is a file or a directory. */ - attr = GetFileAttributesW(pathw); - if (attr == INVALID_FILE_ATTRIBUTES) { - last_error = GetLastError(); - goto error; - } - - is_path_dir = (attr & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; - - if (is_path_dir) { - /* path is a directory, so that's the directory that we will watch. */ - dir_to_watch = pathw; - } else { - /* - * path is a file. So we split path into dir & file parts, and - * watch the dir directory. - */ - - /* Convert to short path. */ - short_path = short_path_buffer; - if (!GetShortPathNameW(pathw, short_path, ARRAY_SIZE(short_path))) { - short_path = NULL; - } - - if (uv_split_path(pathw, &dir, &handle->filew) != 0) { - last_error = GetLastError(); - goto error; - } - - if (uv_split_path(short_path, NULL, &handle->short_filew) != 0) { - last_error = GetLastError(); - goto error; - } - - dir_to_watch = dir; - uv__free(pathw); - pathw = NULL; - } - - handle->dir_handle = CreateFileW(dir_to_watch, - FILE_LIST_DIRECTORY, - FILE_SHARE_READ | FILE_SHARE_DELETE | - FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | - FILE_FLAG_OVERLAPPED, - NULL); - - if (dir) { - uv__free(dir); - dir = NULL; - } - - if (handle->dir_handle == INVALID_HANDLE_VALUE) { - last_error = GetLastError(); - goto error; - } - - if (CreateIoCompletionPort(handle->dir_handle, - handle->loop->iocp, - (ULONG_PTR)handle, - 0) == NULL) { - last_error = GetLastError(); - goto error; - } - - if (!handle->buffer) { - handle->buffer = (char*)uv__malloc(uv_directory_watcher_buffer_size); - } - if (!handle->buffer) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - memset(&(handle->req.u.io.overlapped), 0, - sizeof(handle->req.u.io.overlapped)); - - if (!ReadDirectoryChangesW(handle->dir_handle, - handle->buffer, - uv_directory_watcher_buffer_size, - (flags & UV_FS_EVENT_RECURSIVE) ? TRUE : FALSE, - FILE_NOTIFY_CHANGE_FILE_NAME | - FILE_NOTIFY_CHANGE_DIR_NAME | - FILE_NOTIFY_CHANGE_ATTRIBUTES | - FILE_NOTIFY_CHANGE_SIZE | - FILE_NOTIFY_CHANGE_LAST_WRITE | - FILE_NOTIFY_CHANGE_LAST_ACCESS | - FILE_NOTIFY_CHANGE_CREATION | - FILE_NOTIFY_CHANGE_SECURITY, - NULL, - &handle->req.u.io.overlapped, - NULL)) { - last_error = GetLastError(); - goto error; - } - - assert(is_path_dir ? pathw != NULL : pathw == NULL); - handle->dirw = pathw; - handle->req_pending = 1; - return 0; - -error: - if (handle->path) { - uv__free(handle->path); - handle->path = NULL; - } - - if (handle->filew) { - uv__free(handle->filew); - handle->filew = NULL; - } - - if (handle->short_filew) { - uv__free(handle->short_filew); - handle->short_filew = NULL; - } - - uv__free(pathw); - - if (handle->dir_handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle->dir_handle); - handle->dir_handle = INVALID_HANDLE_VALUE; - } - - if (handle->buffer) { - uv__free(handle->buffer); - handle->buffer = NULL; - } - - if (uv__is_active(handle)) - uv__handle_stop(handle); - - return uv_translate_sys_error(last_error); -} - - -int uv_fs_event_stop(uv_fs_event_t* handle) { - if (!uv__is_active(handle)) - return 0; - - if (handle->dir_handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle->dir_handle); - handle->dir_handle = INVALID_HANDLE_VALUE; - } - - uv__handle_stop(handle); - - if (handle->filew) { - uv__free(handle->filew); - handle->filew = NULL; - } - - if (handle->short_filew) { - uv__free(handle->short_filew); - handle->short_filew = NULL; - } - - if (handle->path) { - uv__free(handle->path); - handle->path = NULL; - } - - if (handle->dirw) { - uv__free(handle->dirw); - handle->dirw = NULL; - } - - return 0; -} - - -static int file_info_cmp(WCHAR* str, WCHAR* file_name, size_t file_name_len) { - size_t str_len; - - if (str == NULL) - return -1; - - str_len = wcslen(str); - - /* - Since we only care about equality, return early if the strings - aren't the same length - */ - if (str_len != (file_name_len / sizeof(WCHAR))) - return -1; - - return _wcsnicmp(str, file_name, str_len); -} - - -void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, - uv_fs_event_t* handle) { - FILE_NOTIFY_INFORMATION* file_info; - int err, sizew, size; - char* filename = NULL; - WCHAR* filenamew = NULL; - WCHAR* long_filenamew = NULL; - DWORD offset = 0; - - assert(req->type == UV_FS_EVENT_REQ); - assert(handle->req_pending); - handle->req_pending = 0; - - /* Don't report any callbacks if: - * - We're closing, just push the handle onto the endgame queue - * - We are not active, just ignore the callback - */ - if (!uv__is_active(handle)) { - if (handle->flags & UV__HANDLE_CLOSING) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - return; - } - - file_info = (FILE_NOTIFY_INFORMATION*)(handle->buffer + offset); - - if (REQ_SUCCESS(req)) { - if (req->u.io.overlapped.InternalHigh > 0) { - do { - file_info = (FILE_NOTIFY_INFORMATION*)((char*)file_info + offset); - assert(!filename); - assert(!filenamew); - assert(!long_filenamew); - - /* - * Fire the event only if we were asked to watch a directory, - * or if the filename filter matches. - */ - if (handle->dirw || - file_info_cmp(handle->filew, - file_info->FileName, - file_info->FileNameLength) == 0 || - file_info_cmp(handle->short_filew, - file_info->FileName, - file_info->FileNameLength) == 0) { - - if (handle->dirw) { - /* - * We attempt to resolve the long form of the file name explicitly. - * We only do this for file names that might still exist on disk. - * If this fails, we use the name given by ReadDirectoryChangesW. - * This may be the long form or the 8.3 short name in some cases. - */ - if (file_info->Action != FILE_ACTION_REMOVED && - file_info->Action != FILE_ACTION_RENAMED_OLD_NAME) { - /* Construct a full path to the file. */ - size = wcslen(handle->dirw) + - file_info->FileNameLength / sizeof(WCHAR) + 2; - - filenamew = (WCHAR*)uv__malloc(size * sizeof(WCHAR)); - if (!filenamew) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - _snwprintf(filenamew, size, L"%s\\%.*s", handle->dirw, - file_info->FileNameLength / (DWORD)sizeof(WCHAR), - file_info->FileName); - - filenamew[size - 1] = L'\0'; - - /* Convert to long name. */ - size = GetLongPathNameW(filenamew, NULL, 0); - - if (size) { - long_filenamew = (WCHAR*)uv__malloc(size * sizeof(WCHAR)); - if (!long_filenamew) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - size = GetLongPathNameW(filenamew, long_filenamew, size); - if (size) { - long_filenamew[size] = '\0'; - } else { - uv__free(long_filenamew); - long_filenamew = NULL; - } - } - - uv__free(filenamew); - - if (long_filenamew) { - /* Get the file name out of the long path. */ - uv_relative_path(long_filenamew, - handle->dirw, - &filenamew); - uv__free(long_filenamew); - long_filenamew = filenamew; - sizew = -1; - } else { - /* We couldn't get the long filename, use the one reported. */ - filenamew = file_info->FileName; - sizew = file_info->FileNameLength / sizeof(WCHAR); - } - } else { - /* - * Removed or renamed events cannot be resolved to the long form. - * We therefore use the name given by ReadDirectoryChangesW. - * This may be the long form or the 8.3 short name in some cases. - */ - filenamew = file_info->FileName; - sizew = file_info->FileNameLength / sizeof(WCHAR); - } - } else { - /* We already have the long name of the file, so just use it. */ - filenamew = handle->filew; - sizew = -1; - } - - /* Convert the filename to utf8. */ - uv__convert_utf16_to_utf8(filenamew, sizew, &filename); - - switch (file_info->Action) { - case FILE_ACTION_ADDED: - case FILE_ACTION_REMOVED: - case FILE_ACTION_RENAMED_OLD_NAME: - case FILE_ACTION_RENAMED_NEW_NAME: - handle->cb(handle, filename, UV_RENAME, 0); - break; - - case FILE_ACTION_MODIFIED: - handle->cb(handle, filename, UV_CHANGE, 0); - break; - } - - uv__free(filename); - filename = NULL; - uv__free(long_filenamew); - long_filenamew = NULL; - filenamew = NULL; - } - - offset = file_info->NextEntryOffset; - } while (offset && !(handle->flags & UV__HANDLE_CLOSING)); - } else { - handle->cb(handle, NULL, UV_CHANGE, 0); - } - } else { - err = GET_REQ_ERROR(req); - handle->cb(handle, NULL, 0, uv_translate_sys_error(err)); - } - - if (!(handle->flags & UV__HANDLE_CLOSING)) { - uv_fs_event_queue_readdirchanges(loop, handle); - } else { - uv_want_endgame(loop, (uv_handle_t*)handle); - } -} - - -void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) { - uv_fs_event_stop(handle); - - uv__handle_closing(handle); - - if (!handle->req_pending) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - -} - - -void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) { - if ((handle->flags & UV__HANDLE_CLOSING) && !handle->req_pending) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - if (handle->buffer) { - uv__free(handle->buffer); - handle->buffer = NULL; - } - - uv__handle_close(handle); - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/fs.c b/lib/ESPiLight/pilight/libs/libuv/win/fs.c deleted file mode 100644 index 8223d6f..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/fs.c +++ /dev/null @@ -1,2516 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "req-inl.h" -#include "handle-inl.h" - -#include - - -#define UV_FS_FREE_PATHS 0x0002 -#define UV_FS_FREE_PTR 0x0008 -#define UV_FS_CLEANEDUP 0x0010 - - -#define QUEUE_FS_TP_JOB(loop, req) \ - do { \ - uv__req_register(loop, req); \ - uv__work_submit((loop), &(req)->work_req, uv__fs_work, uv__fs_done); \ - } while (0) - -#define SET_REQ_RESULT(req, result_value) \ - do { \ - req->result = (result_value); \ - if (req->result == -1) { \ - req->sys_errno_ = _doserrno; \ - req->result = uv_translate_sys_error(req->sys_errno_); \ - } \ - } while (0) - -#define SET_REQ_WIN32_ERROR(req, sys_errno) \ - do { \ - req->sys_errno_ = (sys_errno); \ - req->result = uv_translate_sys_error(req->sys_errno_); \ - } while (0) - -#define SET_REQ_UV_ERROR(req, uv_errno, sys_errno) \ - do { \ - req->result = (uv_errno); \ - req->sys_errno_ = (sys_errno); \ - } while (0) - -#define VERIFY_FD(fd, req) \ - if (fd == -1) { \ - req->result = UV_EBADF; \ - req->sys_errno_ = ERROR_INVALID_HANDLE; \ - return; \ - } - -#define FILETIME_TO_UINT(filetime) \ - (*((uint64_t*) &(filetime)) - 116444736000000000ULL) - -#define FILETIME_TO_TIME_T(filetime) \ - (FILETIME_TO_UINT(filetime) / 10000000ULL) - -#define FILETIME_TO_TIME_NS(filetime, secs) \ - ((FILETIME_TO_UINT(filetime) - (secs * 10000000ULL)) * 100) - -#define FILETIME_TO_TIMESPEC(ts, filetime) \ - do { \ - (ts).tv_sec = (long) FILETIME_TO_TIME_T(filetime); \ - (ts).tv_nsec = (long) FILETIME_TO_TIME_NS(filetime, (ts).tv_sec); \ - } while(0) - -#define TIME_T_TO_FILETIME(time, filetime_ptr) \ - do { \ - uint64_t bigtime = ((uint64_t) ((time) * 10000000ULL)) + \ - 116444736000000000ULL; \ - (filetime_ptr)->dwLowDateTime = bigtime & 0xFFFFFFFF; \ - (filetime_ptr)->dwHighDateTime = bigtime >> 32; \ - } while(0) - -#define IS_SLASH(c) ((c) == L'\\' || (c) == L'/') -#define IS_LETTER(c) (((c) >= L'a' && (c) <= L'z') || \ - ((c) >= L'A' && (c) <= L'Z')) - -const WCHAR JUNCTION_PREFIX[] = L"\\??\\"; -const WCHAR JUNCTION_PREFIX_LEN = 4; - -const WCHAR LONG_PATH_PREFIX[] = L"\\\\?\\"; -const WCHAR LONG_PATH_PREFIX_LEN = 4; - -const WCHAR UNC_PATH_PREFIX[] = L"\\\\?\\UNC\\"; -const WCHAR UNC_PATH_PREFIX_LEN = 8; - - -void uv_fs_init(void) { - _fmode = _O_BINARY; -} - - -INLINE static int fs__capture_path(uv_fs_t* req, const char* path, - const char* new_path, const int copy_path) { - char* buf; - char* pos; - ssize_t buf_sz = 0, path_len = 0, pathw_len = 0, new_pathw_len = 0; - - /* new_path can only be set if path is also set. */ - assert(new_path == NULL || path != NULL); - - if (path != NULL) { - pathw_len = MultiByteToWideChar(CP_UTF8, - 0, - path, - -1, - NULL, - 0); - if (pathw_len == 0) { - return GetLastError(); - } - - buf_sz += pathw_len * sizeof(WCHAR); - } - - if (path != NULL && copy_path) { - path_len = 1 + strlen(path); - buf_sz += path_len; - } - - if (new_path != NULL) { - new_pathw_len = MultiByteToWideChar(CP_UTF8, - 0, - new_path, - -1, - NULL, - 0); - if (new_pathw_len == 0) { - return GetLastError(); - } - - buf_sz += new_pathw_len * sizeof(WCHAR); - } - - - if (buf_sz == 0) { - req->file.pathw = NULL; - req->fs.info.new_pathw = NULL; - req->path = NULL; - return 0; - } - - buf = (char*) uv__malloc(buf_sz); - if (buf == NULL) { - return ERROR_OUTOFMEMORY; - } - - pos = buf; - - if (path != NULL) { - DWORD r = MultiByteToWideChar(CP_UTF8, - 0, - path, - -1, - (WCHAR*) pos, - pathw_len); - assert(r == (DWORD) pathw_len); - req->file.pathw = (WCHAR*) pos; - pos += r * sizeof(WCHAR); - } else { - req->file.pathw = NULL; - } - - if (new_path != NULL) { - DWORD r = MultiByteToWideChar(CP_UTF8, - 0, - new_path, - -1, - (WCHAR*) pos, - new_pathw_len); - assert(r == (DWORD) new_pathw_len); - req->fs.info.new_pathw = (WCHAR*) pos; - pos += r * sizeof(WCHAR); - } else { - req->fs.info.new_pathw = NULL; - } - - req->path = path; - if (path != NULL && copy_path) { - memcpy(pos, path, path_len); - assert(path_len == buf_sz - (pos - buf)); - req->path = pos; - } - - req->flags |= UV_FS_FREE_PATHS; - - return 0; -} - - - -INLINE static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req, - uv_fs_type fs_type, const uv_fs_cb cb) { - UV_REQ_INIT(req, UV_FS); - req->loop = loop; - req->flags = 0; - req->fs_type = fs_type; - req->result = 0; - req->ptr = NULL; - req->path = NULL; - req->cb = cb; - memset(&req->fs, 0, sizeof(req->fs)); -} - - -static int fs__wide_to_utf8(WCHAR* w_source_ptr, - DWORD w_source_len, - char** target_ptr, - uint64_t* target_len_ptr) { - int r; - int target_len; - char* target; - target_len = WideCharToMultiByte(CP_UTF8, - 0, - w_source_ptr, - w_source_len, - NULL, - 0, - NULL, - NULL); - - if (target_len == 0) { - return -1; - } - - if (target_len_ptr != NULL) { - *target_len_ptr = target_len; - } - - if (target_ptr == NULL) { - return 0; - } - - target = uv__malloc(target_len + 1); - if (target == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return -1; - } - - r = WideCharToMultiByte(CP_UTF8, - 0, - w_source_ptr, - w_source_len, - target, - target_len, - NULL, - NULL); - assert(r == target_len); - target[target_len] = '\0'; - *target_ptr = target; - return 0; -} - - -INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr, - uint64_t* target_len_ptr) { - char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; - REPARSE_DATA_BUFFER* reparse_data = (REPARSE_DATA_BUFFER*) buffer; - WCHAR* w_target; - DWORD w_target_len; - DWORD bytes; - - if (!DeviceIoControl(handle, - FSCTL_GET_REPARSE_POINT, - NULL, - 0, - buffer, - sizeof buffer, - &bytes, - NULL)) { - return -1; - } - - if (reparse_data->ReparseTag == IO_REPARSE_TAG_SYMLINK) { - /* Real symlink */ - w_target = reparse_data->SymbolicLinkReparseBuffer.PathBuffer + - (reparse_data->SymbolicLinkReparseBuffer.SubstituteNameOffset / - sizeof(WCHAR)); - w_target_len = - reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength / - sizeof(WCHAR); - - /* Real symlinks can contain pretty much everything, but the only thing */ - /* we really care about is undoing the implicit conversion to an NT */ - /* namespaced path that CreateSymbolicLink will perform on absolute */ - /* paths. If the path is win32-namespaced then the user must have */ - /* explicitly made it so, and we better just return the unmodified */ - /* reparse data. */ - if (w_target_len >= 4 && - w_target[0] == L'\\' && - w_target[1] == L'?' && - w_target[2] == L'?' && - w_target[3] == L'\\') { - /* Starts with \??\ */ - if (w_target_len >= 6 && - ((w_target[4] >= L'A' && w_target[4] <= L'Z') || - (w_target[4] >= L'a' && w_target[4] <= L'z')) && - w_target[5] == L':' && - (w_target_len == 6 || w_target[6] == L'\\')) { - /* \??\:\ */ - w_target += 4; - w_target_len -= 4; - - } else if (w_target_len >= 8 && - (w_target[4] == L'U' || w_target[4] == L'u') && - (w_target[5] == L'N' || w_target[5] == L'n') && - (w_target[6] == L'C' || w_target[6] == L'c') && - w_target[7] == L'\\') { - /* \??\UNC\\\ - make sure the final path looks like */ - /* \\\\ */ - w_target += 6; - w_target[0] = L'\\'; - w_target_len -= 6; - } - } - - } else if (reparse_data->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { - /* Junction. */ - w_target = reparse_data->MountPointReparseBuffer.PathBuffer + - (reparse_data->MountPointReparseBuffer.SubstituteNameOffset / - sizeof(WCHAR)); - w_target_len = reparse_data->MountPointReparseBuffer.SubstituteNameLength / - sizeof(WCHAR); - - /* Only treat junctions that look like \??\:\ as symlink. */ - /* Junctions can also be used as mount points, like \??\Volume{}, */ - /* but that's confusing for programs since they wouldn't be able to */ - /* actually understand such a path when returned by uv_readlink(). */ - /* UNC paths are never valid for junctions so we don't care about them. */ - if (!(w_target_len >= 6 && - w_target[0] == L'\\' && - w_target[1] == L'?' && - w_target[2] == L'?' && - w_target[3] == L'\\' && - ((w_target[4] >= L'A' && w_target[4] <= L'Z') || - (w_target[4] >= L'a' && w_target[4] <= L'z')) && - w_target[5] == L':' && - (w_target_len == 6 || w_target[6] == L'\\'))) { - SetLastError(ERROR_SYMLINK_NOT_SUPPORTED); - return -1; - } - - /* Remove leading \??\ */ - w_target += 4; - w_target_len -= 4; - - } else { - /* Reparse tag does not indicate a symlink. */ - SetLastError(ERROR_SYMLINK_NOT_SUPPORTED); - return -1; - } - - return fs__wide_to_utf8(w_target, w_target_len, target_ptr, target_len_ptr); -} - - -void fs__open(uv_fs_t* req) { - DWORD access; - DWORD share; - DWORD disposition; - DWORD attributes = 0; - HANDLE file; - int fd, current_umask; - int flags = req->fs.info.file_flags; - - /* Obtain the active umask. umask() never fails and returns the previous */ - /* umask. */ - current_umask = umask(0); - umask(current_umask); - - /* convert flags and mode to CreateFile parameters */ - switch (flags & (_O_RDONLY | _O_WRONLY | _O_RDWR)) { - case _O_RDONLY: - access = FILE_GENERIC_READ; - break; - case _O_WRONLY: - access = FILE_GENERIC_WRITE; - break; - case _O_RDWR: - access = FILE_GENERIC_READ | FILE_GENERIC_WRITE; - break; - default: - goto einval; - } - - if (flags & _O_APPEND) { - access &= ~FILE_WRITE_DATA; - access |= FILE_APPEND_DATA; - } - - /* - * Here is where we deviate significantly from what CRT's _open() - * does. We indiscriminately use all the sharing modes, to match - * UNIX semantics. In particular, this ensures that the file can - * be deleted even whilst it's open, fixing issue #1449. - */ - share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - - switch (flags & (_O_CREAT | _O_EXCL | _O_TRUNC)) { - case 0: - case _O_EXCL: - disposition = OPEN_EXISTING; - break; - case _O_CREAT: - disposition = OPEN_ALWAYS; - break; - case _O_CREAT | _O_EXCL: - case _O_CREAT | _O_TRUNC | _O_EXCL: - disposition = CREATE_NEW; - break; - case _O_TRUNC: - case _O_TRUNC | _O_EXCL: - disposition = TRUNCATE_EXISTING; - break; - case _O_CREAT | _O_TRUNC: - disposition = CREATE_ALWAYS; - break; - default: - goto einval; - } - - attributes |= FILE_ATTRIBUTE_NORMAL; - if (flags & _O_CREAT) { - if (!((req->fs.info.mode & ~current_umask) & _S_IWRITE)) { - attributes |= FILE_ATTRIBUTE_READONLY; - } - } - - if (flags & _O_TEMPORARY ) { - attributes |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; - access |= DELETE; - } - - if (flags & _O_SHORT_LIVED) { - attributes |= FILE_ATTRIBUTE_TEMPORARY; - } - - switch (flags & (_O_SEQUENTIAL | _O_RANDOM)) { - case 0: - break; - case _O_SEQUENTIAL: - attributes |= FILE_FLAG_SEQUENTIAL_SCAN; - break; - case _O_RANDOM: - attributes |= FILE_FLAG_RANDOM_ACCESS; - break; - default: - goto einval; - } - - /* Setting this flag makes it possible to open a directory. */ - attributes |= FILE_FLAG_BACKUP_SEMANTICS; - - file = CreateFileW(req->file.pathw, - access, - share, - NULL, - disposition, - attributes, - NULL); - if (file == INVALID_HANDLE_VALUE) { - DWORD error = GetLastError(); - if (error == ERROR_FILE_EXISTS && (flags & _O_CREAT) && - !(flags & _O_EXCL)) { - /* Special case: when ERROR_FILE_EXISTS happens and O_CREAT was */ - /* specified, it means the path referred to a directory. */ - SET_REQ_UV_ERROR(req, UV_EISDIR, error); - } else { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } - return; - } - - fd = _open_osfhandle((intptr_t) file, flags); - if (fd < 0) { - /* The only known failure mode for _open_osfhandle() is EMFILE, in which - * case GetLastError() will return zero. However we'll try to handle other - * errors as well, should they ever occur. - */ - if (errno == EMFILE) - SET_REQ_UV_ERROR(req, UV_EMFILE, ERROR_TOO_MANY_OPEN_FILES); - else if (GetLastError() != ERROR_SUCCESS) - SET_REQ_WIN32_ERROR(req, GetLastError()); - else - SET_REQ_WIN32_ERROR(req, UV_UNKNOWN); - CloseHandle(file); - return; - } - - SET_REQ_RESULT(req, fd); - return; - - einval: - SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); -} - -void fs__close(uv_fs_t* req) { - int fd = req->file.fd; - int result; - - VERIFY_FD(fd, req); - - if (fd > 2) - result = _close(fd); - else - result = 0; - - /* _close doesn't set _doserrno on failure, but it does always set errno - * to EBADF on failure. - */ - if (result == -1) { - assert(errno == EBADF); - SET_REQ_UV_ERROR(req, UV_EBADF, ERROR_INVALID_HANDLE); - } else { - req->result = 0; - } -} - - -void fs__read(uv_fs_t* req) { - int fd = req->file.fd; - int64_t offset = req->fs.info.offset; - HANDLE handle; - OVERLAPPED overlapped, *overlapped_ptr; - LARGE_INTEGER offset_; - DWORD bytes; - DWORD error; - int result; - unsigned int index; - LARGE_INTEGER original_position; - LARGE_INTEGER zero_offset; - int restore_position; - - VERIFY_FD(fd, req); - - zero_offset.QuadPart = 0; - restore_position = 0; - handle = uv__get_osfhandle(fd); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (offset != -1) { - memset(&overlapped, 0, sizeof overlapped); - overlapped_ptr = &overlapped; - if (SetFilePointerEx(handle, zero_offset, &original_position, - FILE_CURRENT)) { - restore_position = 1; - } - } else { - overlapped_ptr = NULL; - } - - index = 0; - bytes = 0; - do { - DWORD incremental_bytes; - - if (offset != -1) { - offset_.QuadPart = offset + bytes; - overlapped.Offset = offset_.LowPart; - overlapped.OffsetHigh = offset_.HighPart; - } - - result = ReadFile(handle, - req->fs.info.bufs[index].base, - req->fs.info.bufs[index].len, - &incremental_bytes, - overlapped_ptr); - bytes += incremental_bytes; - ++index; - } while (result && index < req->fs.info.nbufs); - - if (restore_position) - SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN); - - if (result || bytes > 0) { - SET_REQ_RESULT(req, bytes); - } else { - error = GetLastError(); - if (error == ERROR_HANDLE_EOF) { - SET_REQ_RESULT(req, bytes); - } else { - SET_REQ_WIN32_ERROR(req, error); - } - } -} - - -void fs__write(uv_fs_t* req) { - int fd = req->file.fd; - int64_t offset = req->fs.info.offset; - HANDLE handle; - OVERLAPPED overlapped, *overlapped_ptr; - LARGE_INTEGER offset_; - DWORD bytes; - int result; - unsigned int index; - LARGE_INTEGER original_position; - LARGE_INTEGER zero_offset; - int restore_position; - - VERIFY_FD(fd, req); - - zero_offset.QuadPart = 0; - restore_position = 0; - handle = uv__get_osfhandle(fd); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (offset != -1) { - memset(&overlapped, 0, sizeof overlapped); - overlapped_ptr = &overlapped; - if (SetFilePointerEx(handle, zero_offset, &original_position, - FILE_CURRENT)) { - restore_position = 1; - } - } else { - overlapped_ptr = NULL; - } - - index = 0; - bytes = 0; - do { - DWORD incremental_bytes; - - if (offset != -1) { - offset_.QuadPart = offset + bytes; - overlapped.Offset = offset_.LowPart; - overlapped.OffsetHigh = offset_.HighPart; - } - - result = WriteFile(handle, - req->fs.info.bufs[index].base, - req->fs.info.bufs[index].len, - &incremental_bytes, - overlapped_ptr); - bytes += incremental_bytes; - ++index; - } while (result && index < req->fs.info.nbufs); - - if (restore_position) - SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN); - - if (result || bytes > 0) { - SET_REQ_RESULT(req, bytes); - } else { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } -} - - -void fs__rmdir(uv_fs_t* req) { - int result = _wrmdir(req->file.pathw); - SET_REQ_RESULT(req, result); -} - - -void fs__unlink(uv_fs_t* req) { - const WCHAR* pathw = req->file.pathw; - HANDLE handle; - BY_HANDLE_FILE_INFORMATION info; - FILE_DISPOSITION_INFORMATION disposition; - IO_STATUS_BLOCK iosb; - NTSTATUS status; - - handle = CreateFileW(pathw, - FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | DELETE, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, - NULL); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (!GetFileInformationByHandle(handle, &info)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - CloseHandle(handle); - return; - } - - if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - /* Do not allow deletion of directories, unless it is a symlink. When */ - /* the path refers to a non-symlink directory, report EPERM as mandated */ - /* by POSIX.1. */ - - /* Check if it is a reparse point. If it's not, it's a normal directory. */ - if (!(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { - SET_REQ_WIN32_ERROR(req, ERROR_ACCESS_DENIED); - CloseHandle(handle); - return; - } - - /* Read the reparse point and check if it is a valid symlink. */ - /* If not, don't unlink. */ - if (fs__readlink_handle(handle, NULL, NULL) < 0) { - DWORD error = GetLastError(); - if (error == ERROR_SYMLINK_NOT_SUPPORTED) - error = ERROR_ACCESS_DENIED; - SET_REQ_WIN32_ERROR(req, error); - CloseHandle(handle); - return; - } - } - - if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - /* Remove read-only attribute */ - FILE_BASIC_INFORMATION basic = { 0 }; - - basic.FileAttributes = info.dwFileAttributes & ~(FILE_ATTRIBUTE_READONLY); - - status = pNtSetInformationFile(handle, - &iosb, - &basic, - sizeof basic, - FileBasicInformation); - if (!NT_SUCCESS(status)) { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - CloseHandle(handle); - return; - } - } - - /* Try to set the delete flag. */ - disposition.DeleteFile = TRUE; - status = pNtSetInformationFile(handle, - &iosb, - &disposition, - sizeof disposition, - FileDispositionInformation); - if (NT_SUCCESS(status)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - } - - CloseHandle(handle); -} - - -void fs__mkdir(uv_fs_t* req) { - /* TODO: use req->mode. */ - int result = _wmkdir(req->file.pathw); - SET_REQ_RESULT(req, result); -} - - -/* OpenBSD original: lib/libc/stdio/mktemp.c */ -void fs__mkdtemp(uv_fs_t* req) { - static const WCHAR *tempchars = - L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - static const size_t num_chars = 62; - static const size_t num_x = 6; - WCHAR *cp, *ep; - unsigned int tries, i; - size_t len; - HCRYPTPROV h_crypt_prov; - uint64_t v; - BOOL released; - - len = wcslen(req->file.pathw); - ep = req->file.pathw + len; - if (len < num_x || wcsncmp(ep - num_x, L"XXXXXX", num_x)) { - SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); - return; - } - - if (!CryptAcquireContext(&h_crypt_prov, NULL, NULL, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - tries = TMP_MAX; - do { - if (!CryptGenRandom(h_crypt_prov, sizeof(v), (BYTE*) &v)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - break; - } - - cp = ep - num_x; - for (i = 0; i < num_x; i++) { - *cp++ = tempchars[v % num_chars]; - v /= num_chars; - } - - if (_wmkdir(req->file.pathw) == 0) { - len = strlen(req->path); - wcstombs((char*) req->path + len - num_x, ep - num_x, num_x); - SET_REQ_RESULT(req, 0); - break; - } else if (errno != EEXIST) { - SET_REQ_RESULT(req, -1); - break; - } - } while (--tries); - - released = CryptReleaseContext(h_crypt_prov, 0); - assert(released); - if (tries == 0) { - SET_REQ_RESULT(req, -1); - } -} - - -void fs__scandir(uv_fs_t* req) { - static const size_t dirents_initial_size = 32; - - HANDLE dir_handle = INVALID_HANDLE_VALUE; - - uv__dirent_t** dirents = NULL; - size_t dirents_size = 0; - size_t dirents_used = 0; - - IO_STATUS_BLOCK iosb; - NTSTATUS status; - - /* Buffer to hold directory entries returned by NtQueryDirectoryFile. - * It's important that this buffer can hold at least one entry, regardless - * of the length of the file names present in the enumerated directory. - * A file name is at most 256 WCHARs long. - * According to MSDN, the buffer must be aligned at an 8-byte boundary. - */ -#if _MSC_VER - __declspec(align(8)) char buffer[8192]; -#else - __attribute__ ((aligned (8))) char buffer[8192]; -#endif - - STATIC_ASSERT(sizeof buffer >= - sizeof(FILE_DIRECTORY_INFORMATION) + 256 * sizeof(WCHAR)); - - /* Open the directory. */ - dir_handle = - CreateFileW(req->file.pathw, - FILE_LIST_DIRECTORY | SYNCHRONIZE, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL); - if (dir_handle == INVALID_HANDLE_VALUE) - goto win32_error; - - /* Read the first chunk. */ - status = pNtQueryDirectoryFile(dir_handle, - NULL, - NULL, - NULL, - &iosb, - &buffer, - sizeof buffer, - FileDirectoryInformation, - FALSE, - NULL, - TRUE); - - /* If the handle is not a directory, we'll get STATUS_INVALID_PARAMETER. - * This should be reported back as UV_ENOTDIR. - */ - if (status == STATUS_INVALID_PARAMETER) - goto not_a_directory_error; - - while (NT_SUCCESS(status)) { - char* position = buffer; - size_t next_entry_offset = 0; - - do { - FILE_DIRECTORY_INFORMATION* info; - uv__dirent_t* dirent; - - size_t wchar_len; - size_t utf8_len; - - /* Obtain a pointer to the current directory entry. */ - position += next_entry_offset; - info = (FILE_DIRECTORY_INFORMATION*) position; - - /* Fetch the offset to the next directory entry. */ - next_entry_offset = info->NextEntryOffset; - - /* Compute the length of the filename in WCHARs. */ - wchar_len = info->FileNameLength / sizeof info->FileName[0]; - - /* Skip over '.' and '..' entries. It has been reported that - * the SharePoint driver includes the terminating zero byte in - * the filename length. Strip those first. - */ - while (wchar_len > 0 && info->FileName[wchar_len - 1] == L'\0') - wchar_len -= 1; - - if (wchar_len == 0) - continue; - if (wchar_len == 1 && info->FileName[0] == L'.') - continue; - if (wchar_len == 2 && info->FileName[0] == L'.' && - info->FileName[1] == L'.') - continue; - - /* Compute the space required to store the filename as UTF-8. */ - utf8_len = WideCharToMultiByte( - CP_UTF8, 0, &info->FileName[0], wchar_len, NULL, 0, NULL, NULL); - if (utf8_len == 0) - goto win32_error; - - /* Resize the dirent array if needed. */ - if (dirents_used >= dirents_size) { - size_t new_dirents_size = - dirents_size == 0 ? dirents_initial_size : dirents_size << 1; - uv__dirent_t** new_dirents = - uv__realloc(dirents, new_dirents_size * sizeof *dirents); - - if (new_dirents == NULL) - goto out_of_memory_error; - - dirents_size = new_dirents_size; - dirents = new_dirents; - } - - /* Allocate space for the uv dirent structure. The dirent structure - * includes room for the first character of the filename, but `utf8_len` - * doesn't count the NULL terminator at this point. - */ - dirent = uv__malloc(sizeof *dirent + utf8_len); - if (dirent == NULL) - goto out_of_memory_error; - - dirents[dirents_used++] = dirent; - - /* Convert file name to UTF-8. */ - if (WideCharToMultiByte(CP_UTF8, - 0, - &info->FileName[0], - wchar_len, - &dirent->d_name[0], - utf8_len, - NULL, - NULL) == 0) - goto win32_error; - - /* Add a null terminator to the filename. */ - dirent->d_name[utf8_len] = '\0'; - - /* Fill out the type field. */ - if (info->FileAttributes & FILE_ATTRIBUTE_DEVICE) - dirent->d_type = UV__DT_CHAR; - else if (info->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) - dirent->d_type = UV__DT_LINK; - else if (info->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) - dirent->d_type = UV__DT_DIR; - else - dirent->d_type = UV__DT_FILE; - } while (next_entry_offset != 0); - - /* Read the next chunk. */ - status = pNtQueryDirectoryFile(dir_handle, - NULL, - NULL, - NULL, - &iosb, - &buffer, - sizeof buffer, - FileDirectoryInformation, - FALSE, - NULL, - FALSE); - - /* After the first pNtQueryDirectoryFile call, the function may return - * STATUS_SUCCESS even if the buffer was too small to hold at least one - * directory entry. - */ - if (status == STATUS_SUCCESS && iosb.Information == 0) - status = STATUS_BUFFER_OVERFLOW; - } - - if (status != STATUS_NO_MORE_FILES) - goto nt_error; - - CloseHandle(dir_handle); - - /* Store the result in the request object. */ - req->ptr = dirents; - if (dirents != NULL) - req->flags |= UV_FS_FREE_PTR; - - SET_REQ_RESULT(req, dirents_used); - - /* `nbufs` will be used as index by uv_fs_scandir_next. */ - req->fs.info.nbufs = 0; - - return; - -nt_error: - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - goto cleanup; - -win32_error: - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto cleanup; - -not_a_directory_error: - SET_REQ_UV_ERROR(req, UV_ENOTDIR, ERROR_DIRECTORY); - goto cleanup; - -out_of_memory_error: - SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); - goto cleanup; - -cleanup: - if (dir_handle != INVALID_HANDLE_VALUE) - CloseHandle(dir_handle); - while (dirents_used > 0) - uv__free(dirents[--dirents_used]); - if (dirents != NULL) - uv__free(dirents); -} - - -INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf) { - FILE_ALL_INFORMATION file_info; - FILE_FS_VOLUME_INFORMATION volume_info; - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - - nt_status = pNtQueryInformationFile(handle, - &io_status, - &file_info, - sizeof file_info, - FileAllInformation); - - /* Buffer overflow (a warning status code) is expected here. */ - if (NT_ERROR(nt_status)) { - SetLastError(pRtlNtStatusToDosError(nt_status)); - return -1; - } - - nt_status = pNtQueryVolumeInformationFile(handle, - &io_status, - &volume_info, - sizeof volume_info, - FileFsVolumeInformation); - - /* Buffer overflow (a warning status code) is expected here. */ - if (io_status.Status == STATUS_NOT_IMPLEMENTED) { - statbuf->st_dev = 0; - } else if (NT_ERROR(nt_status)) { - SetLastError(pRtlNtStatusToDosError(nt_status)); - return -1; - } else { - statbuf->st_dev = volume_info.VolumeSerialNumber; - } - - /* Todo: st_mode should probably always be 0666 for everyone. We might also - * want to report 0777 if the file is a .exe or a directory. - * - * Currently it's based on whether the 'readonly' attribute is set, which - * makes little sense because the semantics are so different: the 'read-only' - * flag is just a way for a user to protect against accidental deletion, and - * serves no security purpose. Windows uses ACLs for that. - * - * Also people now use uv_fs_chmod() to take away the writable bit for good - * reasons. Windows however just makes the file read-only, which makes it - * impossible to delete the file afterwards, since read-only files can't be - * deleted. - * - * IOW it's all just a clusterfuck and we should think of something that - * makes slightly more sense. - * - * And uv_fs_chmod should probably just fail on windows or be a total no-op. - * There's nothing sensible it can do anyway. - */ - statbuf->st_mode = 0; - - if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { - /* - * It is possible for a file to have FILE_ATTRIBUTE_REPARSE_POINT but not have - * any link data. In that case DeviceIoControl() in fs__readlink_handle() sets - * the last error to ERROR_NOT_A_REPARSE_POINT. Then the stat result mode - * calculated below will indicate a normal directory or file, as if - * FILE_ATTRIBUTE_REPARSE_POINT was not present. - */ - if (fs__readlink_handle(handle, NULL, &statbuf->st_size) == 0) { - statbuf->st_mode |= S_IFLNK; - } else if (GetLastError() != ERROR_NOT_A_REPARSE_POINT) { - return -1; - } - } - - if (statbuf->st_mode == 0) { - if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - statbuf->st_mode |= _S_IFDIR; - statbuf->st_size = 0; - } else { - statbuf->st_mode |= _S_IFREG; - statbuf->st_size = file_info.StandardInformation.EndOfFile.QuadPart; - } - } - - if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_READONLY) - statbuf->st_mode |= _S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6); - else - statbuf->st_mode |= (_S_IREAD | _S_IWRITE) | ((_S_IREAD | _S_IWRITE) >> 3) | - ((_S_IREAD | _S_IWRITE) >> 6); - - FILETIME_TO_TIMESPEC(statbuf->st_atim, file_info.BasicInformation.LastAccessTime); - FILETIME_TO_TIMESPEC(statbuf->st_ctim, file_info.BasicInformation.ChangeTime); - FILETIME_TO_TIMESPEC(statbuf->st_mtim, file_info.BasicInformation.LastWriteTime); - FILETIME_TO_TIMESPEC(statbuf->st_birthtim, file_info.BasicInformation.CreationTime); - - statbuf->st_ino = file_info.InternalInformation.IndexNumber.QuadPart; - - /* st_blocks contains the on-disk allocation size in 512-byte units. */ - statbuf->st_blocks = - file_info.StandardInformation.AllocationSize.QuadPart >> 9ULL; - - statbuf->st_nlink = file_info.StandardInformation.NumberOfLinks; - - /* The st_blksize is supposed to be the 'optimal' number of bytes for reading - * and writing to the disk. That is, for any definition of 'optimal' - it's - * supposed to at least avoid read-update-write behavior when writing to the - * disk. - * - * However nobody knows this and even fewer people actually use this value, - * and in order to fill it out we'd have to make another syscall to query the - * volume for FILE_FS_SECTOR_SIZE_INFORMATION. - * - * Therefore we'll just report a sensible value that's quite commonly okay - * on modern hardware. - */ - statbuf->st_blksize = 2048; - - /* Todo: set st_flags to something meaningful. Also provide a wrapper for - * chattr(2). - */ - statbuf->st_flags = 0; - - /* Windows has nothing sensible to say about these values, so they'll just - * remain empty. - */ - statbuf->st_gid = 0; - statbuf->st_uid = 0; - statbuf->st_rdev = 0; - statbuf->st_gen = 0; - - return 0; -} - - -INLINE static void fs__stat_prepare_path(WCHAR* pathw) { - size_t len = wcslen(pathw); - - /* TODO: ignore namespaced paths. */ - if (len > 1 && pathw[len - 2] != L':' && - (pathw[len - 1] == L'\\' || pathw[len - 1] == L'/')) { - pathw[len - 1] = '\0'; - } -} - - -INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) { - HANDLE handle; - DWORD flags; - - flags = FILE_FLAG_BACKUP_SEMANTICS; - if (do_lstat) { - flags |= FILE_FLAG_OPEN_REPARSE_POINT; - } - - handle = CreateFileW(req->file.pathw, - FILE_READ_ATTRIBUTES, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - flags, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__stat_handle(handle, &req->statbuf) != 0) { - DWORD error = GetLastError(); - if (do_lstat && error == ERROR_SYMLINK_NOT_SUPPORTED) { - /* We opened a reparse point but it was not a symlink. Try again. */ - fs__stat_impl(req, 0); - - } else { - /* Stat failed. */ - SET_REQ_WIN32_ERROR(req, GetLastError()); - } - - CloseHandle(handle); - return; - } - - req->ptr = &req->statbuf; - req->result = 0; - CloseHandle(handle); -} - - -static void fs__stat(uv_fs_t* req) { - fs__stat_prepare_path(req->file.pathw); - fs__stat_impl(req, 0); -} - - -static void fs__lstat(uv_fs_t* req) { - fs__stat_prepare_path(req->file.pathw); - fs__stat_impl(req, 1); -} - - -static void fs__fstat(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (fs__stat_handle(handle, &req->statbuf) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - req->ptr = &req->statbuf; - req->result = 0; -} - - -static void fs__rename(uv_fs_t* req) { - if (!MoveFileExW(req->file.pathw, req->fs.info.new_pathw, MOVEFILE_REPLACE_EXISTING)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - SET_REQ_RESULT(req, 0); -} - - -INLINE static void fs__sync_impl(uv_fs_t* req) { - int fd = req->file.fd; - int result; - - VERIFY_FD(fd, req); - - result = FlushFileBuffers(uv__get_osfhandle(fd)) ? 0 : -1; - if (result == -1) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } else { - SET_REQ_RESULT(req, result); - } -} - - -static void fs__fsync(uv_fs_t* req) { - fs__sync_impl(req); -} - - -static void fs__fdatasync(uv_fs_t* req) { - fs__sync_impl(req); -} - - -static void fs__ftruncate(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - NTSTATUS status; - IO_STATUS_BLOCK io_status; - FILE_END_OF_FILE_INFORMATION eof_info; - - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - eof_info.EndOfFile.QuadPart = req->fs.info.offset; - - status = pNtSetInformationFile(handle, - &io_status, - &eof_info, - sizeof eof_info, - FileEndOfFileInformation); - - if (NT_SUCCESS(status)) { - SET_REQ_RESULT(req, 0); - } else { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); - } -} - - -static void fs__sendfile(uv_fs_t* req) { - int fd_in = req->file.fd, fd_out = req->fs.info.fd_out; - size_t length = req->fs.info.bufsml[0].len; - int64_t offset = req->fs.info.offset; - const size_t max_buf_size = 65536; - size_t buf_size = length < max_buf_size ? length : max_buf_size; - int n, result = 0; - int64_t result_offset = 0; - char* buf = (char*) uv__malloc(buf_size); - if (!buf) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (offset != -1) { - result_offset = _lseeki64(fd_in, offset, SEEK_SET); - } - - if (result_offset == -1) { - result = -1; - } else { - while (length > 0) { - n = _read(fd_in, buf, length < buf_size ? length : buf_size); - if (n == 0) { - break; - } else if (n == -1) { - result = -1; - break; - } - - length -= n; - - n = _write(fd_out, buf, n); - if (n == -1) { - result = -1; - break; - } - - result += n; - } - } - - uv__free(buf); - - SET_REQ_RESULT(req, result); -} - - -static void fs__access(uv_fs_t* req) { - DWORD attr = GetFileAttributesW(req->file.pathw); - - if (attr == INVALID_FILE_ATTRIBUTES) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - /* - * Access is possible if - * - write access wasn't requested, - * - or the file isn't read-only, - * - or it's a directory. - * (Directories cannot be read-only on Windows.) - */ - if (!(req->fs.info.mode & W_OK) || - !(attr & FILE_ATTRIBUTE_READONLY) || - (attr & FILE_ATTRIBUTE_DIRECTORY)) { - SET_REQ_RESULT(req, 0); - } else { - SET_REQ_WIN32_ERROR(req, UV_EPERM); - } - -} - - -static void fs__chmod(uv_fs_t* req) { - int result = _wchmod(req->file.pathw, req->fs.info.mode); - SET_REQ_RESULT(req, result); -} - - -static void fs__fchmod(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_BASIC_INFORMATION file_info; - - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - nt_status = pNtQueryInformationFile(handle, - &io_status, - &file_info, - sizeof file_info, - FileBasicInformation); - - if (!NT_SUCCESS(nt_status)) { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); - return; - } - - if (req->fs.info.mode & _S_IWRITE) { - file_info.FileAttributes &= ~FILE_ATTRIBUTE_READONLY; - } else { - file_info.FileAttributes |= FILE_ATTRIBUTE_READONLY; - } - - nt_status = pNtSetInformationFile(handle, - &io_status, - &file_info, - sizeof file_info, - FileBasicInformation); - - if (!NT_SUCCESS(nt_status)) { - SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); - return; - } - - SET_REQ_SUCCESS(req); -} - - -INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) { - FILETIME filetime_a, filetime_m; - - TIME_T_TO_FILETIME(atime, &filetime_a); - TIME_T_TO_FILETIME(mtime, &filetime_m); - - if (!SetFileTime(handle, NULL, &filetime_a, &filetime_m)) { - return -1; - } - - return 0; -} - - -static void fs__utime(uv_fs_t* req) { - HANDLE handle; - - handle = CreateFileW(req->file.pathw, - FILE_WRITE_ATTRIBUTES, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__utime_handle(handle, req->fs.time.atime, req->fs.time.mtime) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - CloseHandle(handle); - return; - } - - CloseHandle(handle); - - req->result = 0; -} - - -static void fs__futime(uv_fs_t* req) { - int fd = req->file.fd; - HANDLE handle; - VERIFY_FD(fd, req); - - handle = uv__get_osfhandle(fd); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); - return; - } - - if (fs__utime_handle(handle, req->fs.time.atime, req->fs.time.mtime) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - req->result = 0; -} - - -static void fs__link(uv_fs_t* req) { - DWORD r = CreateHardLinkW(req->fs.info.new_pathw, req->file.pathw, NULL); - if (r == 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } else { - req->result = 0; - } -} - - -static void fs__create_junction(uv_fs_t* req, const WCHAR* path, - const WCHAR* new_path) { - HANDLE handle = INVALID_HANDLE_VALUE; - REPARSE_DATA_BUFFER *buffer = NULL; - int created = 0; - int target_len; - int is_absolute, is_long_path; - int needed_buf_size, used_buf_size, used_data_size, path_buf_len; - int start, len, i; - int add_slash; - DWORD bytes; - WCHAR* path_buf; - - target_len = wcslen(path); - is_long_path = wcsncmp(path, LONG_PATH_PREFIX, LONG_PATH_PREFIX_LEN) == 0; - - if (is_long_path) { - is_absolute = 1; - } else { - is_absolute = target_len >= 3 && IS_LETTER(path[0]) && - path[1] == L':' && IS_SLASH(path[2]); - } - - if (!is_absolute) { - /* Not supporting relative paths */ - SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_NOT_SUPPORTED); - return; - } - - /* Do a pessimistic calculation of the required buffer size */ - needed_buf_size = - FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) + - JUNCTION_PREFIX_LEN * sizeof(WCHAR) + - 2 * (target_len + 2) * sizeof(WCHAR); - - /* Allocate the buffer */ - buffer = (REPARSE_DATA_BUFFER*)uv__malloc(needed_buf_size); - if (!buffer) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - /* Grab a pointer to the part of the buffer where filenames go */ - path_buf = (WCHAR*)&(buffer->MountPointReparseBuffer.PathBuffer); - path_buf_len = 0; - - /* Copy the substitute (internal) target path */ - start = path_buf_len; - - wcsncpy((WCHAR*)&path_buf[path_buf_len], JUNCTION_PREFIX, - JUNCTION_PREFIX_LEN); - path_buf_len += JUNCTION_PREFIX_LEN; - - add_slash = 0; - for (i = is_long_path ? LONG_PATH_PREFIX_LEN : 0; path[i] != L'\0'; i++) { - if (IS_SLASH(path[i])) { - add_slash = 1; - continue; - } - - if (add_slash) { - path_buf[path_buf_len++] = L'\\'; - add_slash = 0; - } - - path_buf[path_buf_len++] = path[i]; - } - path_buf[path_buf_len++] = L'\\'; - len = path_buf_len - start; - - /* Set the info about the substitute name */ - buffer->MountPointReparseBuffer.SubstituteNameOffset = start * sizeof(WCHAR); - buffer->MountPointReparseBuffer.SubstituteNameLength = len * sizeof(WCHAR); - - /* Insert null terminator */ - path_buf[path_buf_len++] = L'\0'; - - /* Copy the print name of the target path */ - start = path_buf_len; - add_slash = 0; - for (i = is_long_path ? LONG_PATH_PREFIX_LEN : 0; path[i] != L'\0'; i++) { - if (IS_SLASH(path[i])) { - add_slash = 1; - continue; - } - - if (add_slash) { - path_buf[path_buf_len++] = L'\\'; - add_slash = 0; - } - - path_buf[path_buf_len++] = path[i]; - } - len = path_buf_len - start; - if (len == 2) { - path_buf[path_buf_len++] = L'\\'; - len++; - } - - /* Set the info about the print name */ - buffer->MountPointReparseBuffer.PrintNameOffset = start * sizeof(WCHAR); - buffer->MountPointReparseBuffer.PrintNameLength = len * sizeof(WCHAR); - - /* Insert another null terminator */ - path_buf[path_buf_len++] = L'\0'; - - /* Calculate how much buffer space was actually used */ - used_buf_size = FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) + - path_buf_len * sizeof(WCHAR); - used_data_size = used_buf_size - - FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer); - - /* Put general info in the data buffer */ - buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; - buffer->ReparseDataLength = used_data_size; - buffer->Reserved = 0; - - /* Create a new directory */ - if (!CreateDirectoryW(new_path, NULL)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto error; - } - created = 1; - - /* Open the directory */ - handle = CreateFileW(new_path, - GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | - FILE_FLAG_OPEN_REPARSE_POINT, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto error; - } - - /* Create the actual reparse point */ - if (!DeviceIoControl(handle, - FSCTL_SET_REPARSE_POINT, - buffer, - used_buf_size, - NULL, - 0, - &bytes, - NULL)) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - goto error; - } - - /* Clean up */ - CloseHandle(handle); - uv__free(buffer); - - SET_REQ_RESULT(req, 0); - return; - -error: - uv__free(buffer); - - if (handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle); - } - - if (created) { - RemoveDirectoryW(new_path); - } -} - - -static void fs__symlink(uv_fs_t* req) { - WCHAR* pathw = req->file.pathw; - WCHAR* new_pathw = req->fs.info.new_pathw; - int flags = req->fs.info.file_flags; - int result; - - - if (flags & UV_FS_SYMLINK_JUNCTION) { - fs__create_junction(req, pathw, new_pathw); - } else if (pCreateSymbolicLinkW) { - result = pCreateSymbolicLinkW(new_pathw, - pathw, - flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1; - if (result == -1) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } else { - SET_REQ_RESULT(req, result); - } - } else { - SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED); - } -} - - -static void fs__readlink(uv_fs_t* req) { - HANDLE handle; - - handle = CreateFileW(req->file.pathw, - 0, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, - NULL); - - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__readlink_handle(handle, (char**) &req->ptr, NULL) != 0) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - CloseHandle(handle); - return; - } - - req->flags |= UV_FS_FREE_PTR; - SET_REQ_RESULT(req, 0); - - CloseHandle(handle); -} - - -static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { - int r; - DWORD w_realpath_len; - WCHAR* w_realpath_ptr = NULL; - WCHAR* w_realpath_buf; - - w_realpath_len = pGetFinalPathNameByHandleW(handle, NULL, 0, VOLUME_NAME_DOS); - if (w_realpath_len == 0) { - return -1; - } - - w_realpath_buf = uv__malloc((w_realpath_len + 1) * sizeof(WCHAR)); - if (w_realpath_buf == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return -1; - } - w_realpath_ptr = w_realpath_buf; - - if (pGetFinalPathNameByHandleW(handle, - w_realpath_ptr, - w_realpath_len, - VOLUME_NAME_DOS) == 0) { - uv__free(w_realpath_buf); - SetLastError(ERROR_INVALID_HANDLE); - return -1; - } - - /* convert UNC path to long path */ - if (wcsncmp(w_realpath_ptr, - UNC_PATH_PREFIX, - UNC_PATH_PREFIX_LEN) == 0) { - w_realpath_ptr += 6; - *w_realpath_ptr = L'\\'; - w_realpath_len -= 6; - } else if (wcsncmp(w_realpath_ptr, - LONG_PATH_PREFIX, - LONG_PATH_PREFIX_LEN) == 0) { - w_realpath_ptr += 4; - w_realpath_len -= 4; - } else { - uv__free(w_realpath_buf); - SetLastError(ERROR_INVALID_HANDLE); - return -1; - } - - r = fs__wide_to_utf8(w_realpath_ptr, w_realpath_len, realpath_ptr, NULL); - uv__free(w_realpath_buf); - return r; -} - -static void fs__realpath(uv_fs_t* req) { - HANDLE handle; - - if (!pGetFinalPathNameByHandleW) { - SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED); - return; - } - - handle = CreateFileW(req->file.pathw, - 0, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - if (fs__realpath_handle(handle, (char**) &req->ptr) == -1) { - CloseHandle(handle); - SET_REQ_WIN32_ERROR(req, GetLastError()); - return; - } - - CloseHandle(handle); - req->flags |= UV_FS_FREE_PTR; - SET_REQ_RESULT(req, 0); -} - - -static void fs__chown(uv_fs_t* req) { - req->result = 0; -} - - -static void fs__fchown(uv_fs_t* req) { - req->result = 0; -} - - -static void uv__fs_work(struct uv__work* w) { - uv_fs_t* req; - - req = container_of(w, uv_fs_t, work_req); - assert(req->type == UV_FS); - -#define XX(uc, lc) case UV_FS_##uc: fs__##lc(req); break; - switch (req->fs_type) { - XX(OPEN, open) - XX(CLOSE, close) - XX(READ, read) - XX(WRITE, write) - XX(SENDFILE, sendfile) - XX(STAT, stat) - XX(LSTAT, lstat) - XX(FSTAT, fstat) - XX(FTRUNCATE, ftruncate) - XX(UTIME, utime) - XX(FUTIME, futime) - XX(ACCESS, access) - XX(CHMOD, chmod) - XX(FCHMOD, fchmod) - XX(FSYNC, fsync) - XX(FDATASYNC, fdatasync) - XX(UNLINK, unlink) - XX(RMDIR, rmdir) - XX(MKDIR, mkdir) - XX(MKDTEMP, mkdtemp) - XX(RENAME, rename) - XX(SCANDIR, scandir) - XX(LINK, link) - XX(SYMLINK, symlink) - XX(READLINK, readlink) - XX(REALPATH, realpath) - XX(CHOWN, chown) - XX(FCHOWN, fchown); - default: - assert(!"bad uv_fs_type"); - } -} - - -static void uv__fs_done(struct uv__work* w, int status) { - uv_fs_t* req; - - req = container_of(w, uv_fs_t, work_req); - uv__req_unregister(req->loop, req); - - if (status == UV_ECANCELED) { - assert(req->result == 0); - req->result = UV_ECANCELED; - } - - req->cb(req); -} - - -void uv_fs_req_cleanup(uv_fs_t* req) { - if (req->flags & UV_FS_CLEANEDUP) - return; - - if (req->flags & UV_FS_FREE_PATHS) - uv__free(req->file.pathw); - - if (req->flags & UV_FS_FREE_PTR) { - if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL) - uv__fs_scandir_cleanup(req); - else - uv__free(req->ptr); - } - - if (req->fs.info.bufs != req->fs.info.bufsml) - uv__free(req->fs.info.bufs); - - req->path = NULL; - req->file.pathw = NULL; - req->fs.info.new_pathw = NULL; - req->fs.info.bufs = NULL; - req->ptr = NULL; - - req->flags |= UV_FS_CLEANEDUP; -} - - -int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, - int mode, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_OPEN, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.file_flags = flags; - req->fs.info.mode = mode; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__open(req); - return req->result; - } -} - - -int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_CLOSE, cb); - req->file.fd = fd; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__close(req); - return req->result; - } -} - - -int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file fd, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb) { - if (bufs == NULL || nbufs == 0) - return UV_EINVAL; - - uv_fs_req_init(loop, req, UV_FS_READ, cb); - - req->file.fd = fd; - - req->fs.info.nbufs = nbufs; - req->fs.info.bufs = req->fs.info.bufsml; - if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) - req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->fs.info.bufs == NULL) - return UV_ENOMEM; - - memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs)); - - req->fs.info.offset = offset; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__read(req); - return req->result; - } -} - - -int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file fd, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb) { - if (bufs == NULL || nbufs == 0) - return UV_EINVAL; - - uv_fs_req_init(loop, req, UV_FS_WRITE, cb); - - req->file.fd = fd; - - req->fs.info.nbufs = nbufs; - req->fs.info.bufs = req->fs.info.bufsml; - if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) - req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs)); - - if (req->fs.info.bufs == NULL) - return UV_ENOMEM; - - memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs)); - - req->fs.info.offset = offset; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__write(req); - return req->result; - } -} - - -int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_UNLINK, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__unlink(req); - return req->result; - } -} - - -int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, - uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_MKDIR, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.mode = mode; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__mkdir(req); - return req->result; - } -} - - -int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, - uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_MKDTEMP, cb); - - err = fs__capture_path(req, tpl, NULL, TRUE); - if (err) - return uv_translate_sys_error(err); - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__mkdtemp(req); - return req->result; - } -} - - -int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_RMDIR, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__rmdir(req); - return req->result; - } -} - - -int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, - uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_SCANDIR, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.file_flags = flags; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__scandir(req); - return req->result; - } -} - - -int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_LINK, cb); - - err = fs__capture_path(req, path, new_path, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__link(req); - return req->result; - } -} - - -int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, int flags, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_SYMLINK, cb); - - err = fs__capture_path(req, path, new_path, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.file_flags = flags; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__symlink(req); - return req->result; - } -} - - -int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_READLINK, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__readlink(req); - return req->result; - } -} - - -int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, - uv_fs_cb cb) { - int err; - - if (!req || !path) { - return UV_EINVAL; - } - - uv_fs_req_init(loop, req, UV_FS_REALPATH, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__realpath(req); - return req->result; - } -} - - -int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, - uv_gid_t gid, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_CHOWN, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__chown(req); - return req->result; - } -} - - -int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid, - uv_gid_t gid, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FCHOWN, cb); - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__fchown(req); - return req->result; - } -} - - -int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_STAT, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__stat(req); - return req->result; - } -} - - -int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_LSTAT, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__lstat(req); - return req->result; - } -} - - -int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FSTAT, cb); - req->file.fd = fd; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__fstat(req); - return req->result; - } -} - - -int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_RENAME, cb); - - err = fs__capture_path(req, path, new_path, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__rename(req); - return req->result; - } -} - - -int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FSYNC, cb); - req->file.fd = fd; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__fsync(req); - return req->result; - } -} - - -int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FDATASYNC, cb); - req->file.fd = fd; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__fdatasync(req); - return req->result; - } -} - - -int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file fd, - int64_t offset, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FTRUNCATE, cb); - - req->file.fd = fd; - req->fs.info.offset = offset; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__ftruncate(req); - return req->result; - } -} - - - -int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file fd_out, - uv_file fd_in, int64_t in_offset, size_t length, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_SENDFILE, cb); - - req->file.fd = fd_in; - req->fs.info.fd_out = fd_out; - req->fs.info.offset = in_offset; - req->fs.info.bufsml[0].len = length; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__sendfile(req); - return req->result; - } -} - - -int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_ACCESS, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) - return uv_translate_sys_error(err); - - req->fs.info.mode = flags; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } - - fs__access(req); - return req->result; -} - - -int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, - uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_CHMOD, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.info.mode = mode; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__chmod(req); - return req->result; - } -} - - -int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file fd, int mode, - uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FCHMOD, cb); - - req->file.fd = fd; - req->fs.info.mode = mode; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__fchmod(req); - return req->result; - } -} - - -int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, - double mtime, uv_fs_cb cb) { - int err; - - uv_fs_req_init(loop, req, UV_FS_UTIME, cb); - - err = fs__capture_path(req, path, NULL, cb != NULL); - if (err) { - return uv_translate_sys_error(err); - } - - req->fs.time.atime = atime; - req->fs.time.mtime = mtime; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__utime(req); - return req->result; - } -} - - -int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file fd, double atime, - double mtime, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FUTIME, cb); - - req->file.fd = fd; - req->fs.time.atime = atime; - req->fs.time.mtime = mtime; - - if (cb) { - QUEUE_FS_TP_JOB(loop, req); - return 0; - } else { - fs__futime(req); - return req->result; - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/getaddrinfo.c b/lib/ESPiLight/pilight/libs/libuv/win/getaddrinfo.c deleted file mode 100644 index baab838..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/getaddrinfo.c +++ /dev/null @@ -1,382 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include - -#include "uv.h" -#include "internal.h" -#include "req-inl.h" - -/* EAI_* constants. */ -#include - - -int uv__getaddrinfo_translate_error(int sys_err) { - switch (sys_err) { - case 0: return 0; - case WSATRY_AGAIN: return UV_EAI_AGAIN; - case WSAEINVAL: return UV_EAI_BADFLAGS; - case WSANO_RECOVERY: return UV_EAI_FAIL; - case WSAEAFNOSUPPORT: return UV_EAI_FAMILY; - case WSA_NOT_ENOUGH_MEMORY: return UV_EAI_MEMORY; - case WSAHOST_NOT_FOUND: return UV_EAI_NONAME; - case WSATYPE_NOT_FOUND: return UV_EAI_SERVICE; - case WSAESOCKTNOSUPPORT: return UV_EAI_SOCKTYPE; - default: return uv_translate_sys_error(sys_err); - } -} - - -/* - * MinGW is missing this - */ -#if !defined(_MSC_VER) && !defined(__MINGW64_VERSION_MAJOR) - typedef struct addrinfoW { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - WCHAR* ai_canonname; - struct sockaddr* ai_addr; - struct addrinfoW* ai_next; - } ADDRINFOW, *PADDRINFOW; - - DECLSPEC_IMPORT int WSAAPI GetAddrInfoW(const WCHAR* node, - const WCHAR* service, - const ADDRINFOW* hints, - PADDRINFOW* result); - - DECLSPEC_IMPORT void WSAAPI FreeAddrInfoW(PADDRINFOW pAddrInfo); -#endif - - -/* adjust size value to be multiple of 4. Use to keep pointer aligned */ -/* Do we need different versions of this for different architectures? */ -#define ALIGNED_SIZE(X) ((((X) + 3) >> 2) << 2) - - -static void uv__getaddrinfo_work(struct uv__work* w) { - uv_getaddrinfo_t* req; - struct addrinfoW* hints; - int err; - - req = container_of(w, uv_getaddrinfo_t, work_req); - hints = req->addrinfow; - req->addrinfow = NULL; - err = GetAddrInfoW(req->node, req->service, hints, &req->addrinfow); - req->retcode = uv__getaddrinfo_translate_error(err); -} - - -/* - * Called from uv_run when complete. Call user specified callback - * then free returned addrinfo - * Returned addrinfo strings are converted from UTF-16 to UTF-8. - * - * To minimize allocation we calculate total size required, - * and copy all structs and referenced strings into the one block. - * Each size calculation is adjusted to avoid unaligned pointers. - */ -static void uv__getaddrinfo_done(struct uv__work* w, int status) { - uv_getaddrinfo_t* req; - int addrinfo_len = 0; - int name_len = 0; - size_t addrinfo_struct_len = ALIGNED_SIZE(sizeof(struct addrinfo)); - struct addrinfoW* addrinfow_ptr; - struct addrinfo* addrinfo_ptr; - char* alloc_ptr = NULL; - char* cur_ptr = NULL; - - req = container_of(w, uv_getaddrinfo_t, work_req); - - /* release input parameter memory */ - uv__free(req->alloc); - req->alloc = NULL; - - if (status == UV_ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - goto complete; - } - - if (req->retcode == 0) { - /* convert addrinfoW to addrinfo */ - /* first calculate required length */ - addrinfow_ptr = req->addrinfow; - while (addrinfow_ptr != NULL) { - addrinfo_len += addrinfo_struct_len + - ALIGNED_SIZE(addrinfow_ptr->ai_addrlen); - if (addrinfow_ptr->ai_canonname != NULL) { - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - NULL, - 0, - NULL, - NULL); - if (name_len == 0) { - req->retcode = uv_translate_sys_error(GetLastError()); - goto complete; - } - addrinfo_len += ALIGNED_SIZE(name_len); - } - addrinfow_ptr = addrinfow_ptr->ai_next; - } - - /* allocate memory for addrinfo results */ - alloc_ptr = (char*)uv__malloc(addrinfo_len); - - /* do conversions */ - if (alloc_ptr != NULL) { - cur_ptr = alloc_ptr; - addrinfow_ptr = req->addrinfow; - - while (addrinfow_ptr != NULL) { - /* copy addrinfo struct data */ - assert(cur_ptr + addrinfo_struct_len <= alloc_ptr + addrinfo_len); - addrinfo_ptr = (struct addrinfo*)cur_ptr; - addrinfo_ptr->ai_family = addrinfow_ptr->ai_family; - addrinfo_ptr->ai_socktype = addrinfow_ptr->ai_socktype; - addrinfo_ptr->ai_protocol = addrinfow_ptr->ai_protocol; - addrinfo_ptr->ai_flags = addrinfow_ptr->ai_flags; - addrinfo_ptr->ai_addrlen = addrinfow_ptr->ai_addrlen; - addrinfo_ptr->ai_canonname = NULL; - addrinfo_ptr->ai_addr = NULL; - addrinfo_ptr->ai_next = NULL; - - cur_ptr += addrinfo_struct_len; - - /* copy sockaddr */ - if (addrinfo_ptr->ai_addrlen > 0) { - assert(cur_ptr + addrinfo_ptr->ai_addrlen <= - alloc_ptr + addrinfo_len); - memcpy(cur_ptr, addrinfow_ptr->ai_addr, addrinfo_ptr->ai_addrlen); - addrinfo_ptr->ai_addr = (struct sockaddr*)cur_ptr; - cur_ptr += ALIGNED_SIZE(addrinfo_ptr->ai_addrlen); - } - - /* convert canonical name to UTF-8 */ - if (addrinfow_ptr->ai_canonname != NULL) { - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - NULL, - 0, - NULL, - NULL); - assert(name_len > 0); - assert(cur_ptr + name_len <= alloc_ptr + addrinfo_len); - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - cur_ptr, - name_len, - NULL, - NULL); - assert(name_len > 0); - addrinfo_ptr->ai_canonname = cur_ptr; - cur_ptr += ALIGNED_SIZE(name_len); - } - assert(cur_ptr <= alloc_ptr + addrinfo_len); - - /* set next ptr */ - addrinfow_ptr = addrinfow_ptr->ai_next; - if (addrinfow_ptr != NULL) { - addrinfo_ptr->ai_next = (struct addrinfo*)cur_ptr; - } - } - req->addrinfo = (struct addrinfo*)alloc_ptr; - } else { - req->retcode = UV_EAI_MEMORY; - } - } - - /* return memory to system */ - if (req->addrinfow != NULL) { - FreeAddrInfoW(req->addrinfow); - req->addrinfow = NULL; - } - -complete: - uv__req_unregister(req->loop, req); - - /* finally do callback with converted result */ - if (req->getaddrinfo_cb) - req->getaddrinfo_cb(req, req->retcode, req->addrinfo); -} - - -void uv_freeaddrinfo(struct addrinfo* ai) { - char* alloc_ptr = (char*)ai; - - /* release copied result memory */ - uv__free(alloc_ptr); -} - - -/* - * Entry point for getaddrinfo - * we convert the UTF-8 strings to UNICODE - * and save the UNICODE string pointers in the req - * We also copy hints so that caller does not need to keep memory until the - * callback. - * return 0 if a callback will be made - * return error code if validation fails - * - * To minimize allocation we calculate total size required, - * and copy all structs and referenced strings into the one block. - * Each size calculation is adjusted to avoid unaligned pointers. - */ -int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints) { - int nodesize = 0; - int servicesize = 0; - int hintssize = 0; - char* alloc_ptr = NULL; - int err; - - if (req == NULL || (node == NULL && service == NULL)) { - return UV_EINVAL; - } - - UV_REQ_INIT(req, UV_GETADDRINFO); - req->getaddrinfo_cb = getaddrinfo_cb; - req->addrinfo = NULL; - req->loop = loop; - req->retcode = 0; - - /* calculate required memory size for all input values */ - if (node != NULL) { - nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, node, -1, NULL, 0) * - sizeof(WCHAR)); - if (nodesize == 0) { - err = GetLastError(); - goto error; - } - } - - if (service != NULL) { - servicesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, - 0, - service, - -1, - NULL, - 0) * - sizeof(WCHAR)); - if (servicesize == 0) { - err = GetLastError(); - goto error; - } - } - if (hints != NULL) { - hintssize = ALIGNED_SIZE(sizeof(struct addrinfoW)); - } - - /* allocate memory for inputs, and partition it as needed */ - alloc_ptr = (char*)uv__malloc(nodesize + servicesize + hintssize); - if (!alloc_ptr) { - err = WSAENOBUFS; - goto error; - } - - /* save alloc_ptr now so we can free if error */ - req->alloc = (void*)alloc_ptr; - - /* convert node string to UTF16 into allocated memory and save pointer in */ - /* the request. */ - if (node != NULL) { - req->node = (WCHAR*)alloc_ptr; - if (MultiByteToWideChar(CP_UTF8, - 0, - node, - -1, - (WCHAR*) alloc_ptr, - nodesize / sizeof(WCHAR)) == 0) { - err = GetLastError(); - goto error; - } - alloc_ptr += nodesize; - } else { - req->node = NULL; - } - - /* convert service string to UTF16 into allocated memory and save pointer */ - /* in the req. */ - if (service != NULL) { - req->service = (WCHAR*)alloc_ptr; - if (MultiByteToWideChar(CP_UTF8, - 0, - service, - -1, - (WCHAR*) alloc_ptr, - servicesize / sizeof(WCHAR)) == 0) { - err = GetLastError(); - goto error; - } - alloc_ptr += servicesize; - } else { - req->service = NULL; - } - - /* copy hints to allocated memory and save pointer in req */ - if (hints != NULL) { - req->addrinfow = (struct addrinfoW*)alloc_ptr; - req->addrinfow->ai_family = hints->ai_family; - req->addrinfow->ai_socktype = hints->ai_socktype; - req->addrinfow->ai_protocol = hints->ai_protocol; - req->addrinfow->ai_flags = hints->ai_flags; - req->addrinfow->ai_addrlen = 0; - req->addrinfow->ai_canonname = NULL; - req->addrinfow->ai_addr = NULL; - req->addrinfow->ai_next = NULL; - } else { - req->addrinfow = NULL; - } - - uv__req_register(loop, req); - - if (getaddrinfo_cb) { - uv__work_submit(loop, - &req->work_req, - uv__getaddrinfo_work, - uv__getaddrinfo_done); - return 0; - } else { - uv__getaddrinfo_work(&req->work_req); - uv__getaddrinfo_done(&req->work_req, 0); - return req->retcode; - } - -error: - if (req != NULL) { - uv__free(req->alloc); - req->alloc = NULL; - } - return uv_translate_sys_error(err); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/getnameinfo.c b/lib/ESPiLight/pilight/libs/libuv/win/getnameinfo.c deleted file mode 100644 index 9f10cd2..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/getnameinfo.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to -* deal in the Software without restriction, including without limitation the -* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -* sell copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -* IN THE SOFTWARE. -*/ - -#include -#include - -#include "uv.h" -#include "internal.h" -#include "req-inl.h" - -#ifndef GetNameInfo -int WSAAPI GetNameInfoW( - const SOCKADDR *pSockaddr, - socklen_t SockaddrLength, - PWCHAR pNodeBuffer, - DWORD NodeBufferSize, - PWCHAR pServiceBuffer, - DWORD ServiceBufferSize, - INT Flags -); -#endif - -static void uv__getnameinfo_work(struct uv__work* w) { - uv_getnameinfo_t* req; - WCHAR host[NI_MAXHOST]; - WCHAR service[NI_MAXSERV]; - int ret = 0; - - req = container_of(w, uv_getnameinfo_t, work_req); - if (GetNameInfoW((struct sockaddr*)&req->storage, - sizeof(req->storage), - host, - ARRAY_SIZE(host), - service, - ARRAY_SIZE(service), - req->flags)) { - ret = WSAGetLastError(); - } - req->retcode = uv__getaddrinfo_translate_error(ret); - - /* convert results to UTF-8 */ - WideCharToMultiByte(CP_UTF8, - 0, - host, - -1, - req->host, - sizeof(req->host), - NULL, - NULL); - - WideCharToMultiByte(CP_UTF8, - 0, - service, - -1, - req->service, - sizeof(req->service), - NULL, - NULL); -} - - -/* -* Called from uv_run when complete. -*/ -static void uv__getnameinfo_done(struct uv__work* w, int status) { - uv_getnameinfo_t* req; - char* host; - char* service; - - req = container_of(w, uv_getnameinfo_t, work_req); - uv__req_unregister(req->loop, req); - host = service = NULL; - - if (status == UV_ECANCELED) { - assert(req->retcode == 0); - req->retcode = UV_EAI_CANCELED; - } else if (req->retcode == 0) { - host = req->host; - service = req->service; - } - - if (req->getnameinfo_cb) - req->getnameinfo_cb(req, req->retcode, host, service); -} - - -/* -* Entry point for getnameinfo -* return 0 if a callback will be made -* return error code if validation fails -*/ -int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags) { - if (req == NULL || addr == NULL) - return UV_EINVAL; - - if (addr->sa_family == AF_INET) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in)); - } else if (addr->sa_family == AF_INET6) { - memcpy(&req->storage, - addr, - sizeof(struct sockaddr_in6)); - } else { - return UV_EINVAL; - } - - UV_REQ_INIT(req, UV_GETNAMEINFO); - uv__req_register(loop, req); - - req->getnameinfo_cb = getnameinfo_cb; - req->flags = flags; - req->loop = loop; - req->retcode = 0; - - if (getnameinfo_cb) { - uv__work_submit(loop, - &req->work_req, - uv__getnameinfo_work, - uv__getnameinfo_done); - return 0; - } else { - uv__getnameinfo_work(&req->work_req); - uv__getnameinfo_done(&req->work_req, 0); - return req->retcode; - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/handle-inl.h b/lib/ESPiLight/pilight/libs/libuv/win/handle-inl.h deleted file mode 100644 index 8d0334c..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/handle-inl.h +++ /dev/null @@ -1,179 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_HANDLE_INL_H_ -#define UV_WIN_HANDLE_INL_H_ - -#include -#include - -#include "uv.h" -#include "internal.h" - - -#define DECREASE_ACTIVE_COUNT(loop, handle) \ - do { \ - if (--(handle)->activecnt == 0 && \ - !((handle)->flags & UV__HANDLE_CLOSING)) { \ - uv__handle_stop((handle)); \ - } \ - assert((handle)->activecnt >= 0); \ - } while (0) - - -#define INCREASE_ACTIVE_COUNT(loop, handle) \ - do { \ - if ((handle)->activecnt++ == 0) { \ - uv__handle_start((handle)); \ - } \ - assert((handle)->activecnt > 0); \ - } while (0) - - -#define DECREASE_PENDING_REQ_COUNT(handle) \ - do { \ - assert(handle->reqs_pending > 0); \ - handle->reqs_pending--; \ - \ - if (handle->flags & UV__HANDLE_CLOSING && \ - handle->reqs_pending == 0) { \ - uv_want_endgame(loop, (uv_handle_t*)handle); \ - } \ - } while (0) - - -#define uv__handle_closing(handle) \ - do { \ - assert(!((handle)->flags & UV__HANDLE_CLOSING)); \ - \ - if (!(((handle)->flags & UV__HANDLE_ACTIVE) && \ - ((handle)->flags & UV__HANDLE_REF))) \ - uv__active_handle_add((uv_handle_t*) (handle)); \ - \ - (handle)->flags |= UV__HANDLE_CLOSING; \ - (handle)->flags &= ~UV__HANDLE_ACTIVE; \ - } while (0) - - -#define uv__handle_close(handle) \ - do { \ - QUEUE_REMOVE(&(handle)->handle_queue); \ - uv__active_handle_rm((uv_handle_t*) (handle)); \ - \ - (handle)->flags |= UV_HANDLE_CLOSED; \ - \ - if ((handle)->close_cb) \ - (handle)->close_cb((uv_handle_t*) (handle)); \ - } while (0) - - -INLINE static void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle) { - if (!(handle->flags & UV_HANDLE_ENDGAME_QUEUED)) { - handle->flags |= UV_HANDLE_ENDGAME_QUEUED; - - handle->endgame_next = loop->endgame_handles; - loop->endgame_handles = handle; - } -} - - -INLINE static void uv_process_endgames(uv_loop_t* loop) { - uv_handle_t* handle; - - while (loop->endgame_handles) { - handle = loop->endgame_handles; - loop->endgame_handles = handle->endgame_next; - - handle->flags &= ~UV_HANDLE_ENDGAME_QUEUED; - - switch (handle->type) { - case UV_TCP: - uv_tcp_endgame(loop, (uv_tcp_t*) handle); - break; - - case UV_NAMED_PIPE: - uv_pipe_endgame(loop, (uv_pipe_t*) handle); - break; - - case UV_TTY: - uv_tty_endgame(loop, (uv_tty_t*) handle); - break; - - case UV_UDP: - uv_udp_endgame(loop, (uv_udp_t*) handle); - break; - - case UV_POLL: - uv_poll_endgame(loop, (uv_poll_t*) handle); - break; - - case UV_TIMER: - uv_timer_endgame(loop, (uv_timer_t*) handle); - break; - - case UV_PREPARE: - case UV_CHECK: - case UV_IDLE: - uv_loop_watcher_endgame(loop, handle); - break; - - case UV_ASYNC: - uv_async_endgame(loop, (uv_async_t*) handle); - break; - - case UV_SIGNAL: - uv_signal_endgame(loop, (uv_signal_t*) handle); - break; - - case UV_PROCESS: - uv_process_endgame(loop, (uv_process_t*) handle); - break; - - case UV_FS_EVENT: - uv_fs_event_endgame(loop, (uv_fs_event_t*) handle); - break; - - case UV_FS_POLL: - uv__fs_poll_endgame(loop, (uv_fs_poll_t*) handle); - break; - - default: - assert(0); - break; - } - } -} - -INLINE static HANDLE uv__get_osfhandle(int fd) -{ - /* _get_osfhandle() raises an assert in debug builds if the FD is invalid. */ - /* But it also correctly checks the FD and returns INVALID_HANDLE_VALUE */ - /* for invalid FDs in release builds (or if you let the assert continue). */ - /* So this wrapper function disables asserts when calling _get_osfhandle. */ - - HANDLE handle; - UV_BEGIN_DISABLE_CRT_ASSERT(); - handle = (HANDLE) _get_osfhandle(fd); - UV_END_DISABLE_CRT_ASSERT(); - return handle; -} - -#endif /* UV_WIN_HANDLE_INL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/win/handle.c b/lib/ESPiLight/pilight/libs/libuv/win/handle.c deleted file mode 100644 index 3915070..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/handle.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" - - -uv_handle_type uv_guess_handle(uv_file file) { - HANDLE handle; - DWORD mode; - - if (file < 0) { - return UV_UNKNOWN_HANDLE; - } - - handle = uv__get_osfhandle(file); - - switch (GetFileType(handle)) { - case FILE_TYPE_CHAR: - if (GetConsoleMode(handle, &mode)) { - return UV_TTY; - } else { - return UV_FILE; - } - - case FILE_TYPE_PIPE: - return UV_NAMED_PIPE; - - case FILE_TYPE_DISK: - return UV_FILE; - - default: - return UV_UNKNOWN_HANDLE; - } -} - - -int uv_is_active(const uv_handle_t* handle) { - return (handle->flags & UV__HANDLE_ACTIVE) && - !(handle->flags & UV__HANDLE_CLOSING); -} - - -void uv_close(uv_handle_t* handle, uv_close_cb cb) { - uv_loop_t* loop = handle->loop; - - if (handle->flags & UV__HANDLE_CLOSING) { - assert(0); - return; - } - - handle->close_cb = cb; - - /* Handle-specific close actions */ - switch (handle->type) { - case UV_TCP: - uv_tcp_close(loop, (uv_tcp_t*)handle); - return; - - case UV_NAMED_PIPE: - uv_pipe_close(loop, (uv_pipe_t*) handle); - return; - - case UV_TTY: - uv_tty_close((uv_tty_t*) handle); - return; - - case UV_UDP: - uv_udp_close(loop, (uv_udp_t*) handle); - return; - - case UV_POLL: - uv_poll_close(loop, (uv_poll_t*) handle); - return; - - case UV_TIMER: - uv_timer_stop((uv_timer_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_PREPARE: - uv_prepare_stop((uv_prepare_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_CHECK: - uv_check_stop((uv_check_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_IDLE: - uv_idle_stop((uv_idle_t*)handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - case UV_ASYNC: - uv_async_close(loop, (uv_async_t*) handle); - return; - - case UV_SIGNAL: - uv_signal_close(loop, (uv_signal_t*) handle); - return; - - case UV_PROCESS: - uv_process_close(loop, (uv_process_t*) handle); - return; - - case UV_FS_EVENT: - uv_fs_event_close(loop, (uv_fs_event_t*) handle); - return; - - case UV_FS_POLL: - uv__fs_poll_close((uv_fs_poll_t*) handle); - uv__handle_closing(handle); - uv_want_endgame(loop, handle); - return; - - default: - /* Not supported */ - abort(); - } -} - - -int uv_is_closing(const uv_handle_t* handle) { - return !!(handle->flags & (UV__HANDLE_CLOSING | UV_HANDLE_CLOSED)); -} - - -uv_os_fd_t uv_get_osfhandle(int fd) { - return uv__get_osfhandle(fd); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/internal.h b/lib/ESPiLight/pilight/libs/libuv/win/internal.h deleted file mode 100644 index 444327d..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/internal.h +++ /dev/null @@ -1,395 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_INTERNAL_H_ -#define UV_WIN_INTERNAL_H_ - -#include "uv.h" -#include "../uv-common.h" - -#include "tree.h" -#include "winapi.h" -#include "winsock.h" - -#ifdef _MSC_VER -# define INLINE __inline -# define UV_THREAD_LOCAL __declspec( thread ) -#else -# define INLINE inline -# define UV_THREAD_LOCAL __thread -#endif - - -#ifdef _DEBUG - -extern UV_THREAD_LOCAL int uv__crt_assert_enabled; - -#define UV_BEGIN_DISABLE_CRT_ASSERT() \ - { \ - int uv__saved_crt_assert_enabled = uv__crt_assert_enabled; \ - uv__crt_assert_enabled = FALSE; - - -#define UV_END_DISABLE_CRT_ASSERT() \ - uv__crt_assert_enabled = uv__saved_crt_assert_enabled; \ - } - -#else -#define UV_BEGIN_DISABLE_CRT_ASSERT() -#define UV_END_DISABLE_CRT_ASSERT() -#endif - -/* - * Handles - * (also see handle-inl.h) - */ - -/* Used by all handles. */ -#define UV_HANDLE_CLOSED 0x00000002 -#define UV_HANDLE_ENDGAME_QUEUED 0x00000008 - -/* uv-common.h: #define UV__HANDLE_CLOSING 0x00000001 */ -/* uv-common.h: #define UV__HANDLE_ACTIVE 0x00000040 */ -/* uv-common.h: #define UV__HANDLE_REF 0x00000020 */ -/* uv-common.h: #define UV_HANDLE_INTERNAL 0x00000080 */ - -/* Used by streams and UDP handles. */ -#define UV_HANDLE_READING 0x00000100 -#define UV_HANDLE_BOUND 0x00000200 -#define UV_HANDLE_LISTENING 0x00000800 -#define UV_HANDLE_CONNECTION 0x00001000 -#define UV_HANDLE_READABLE 0x00008000 -#define UV_HANDLE_WRITABLE 0x00010000 -#define UV_HANDLE_READ_PENDING 0x00020000 -#define UV_HANDLE_SYNC_BYPASS_IOCP 0x00040000 -#define UV_HANDLE_ZERO_READ 0x00080000 -#define UV_HANDLE_EMULATE_IOCP 0x00100000 -#define UV_HANDLE_BLOCKING_WRITES 0x00200000 -#define UV_HANDLE_CANCELLATION_PENDING 0x00400000 - -/* Used by uv_tcp_t and uv_udp_t handles */ -#define UV_HANDLE_IPV6 0x01000000 - -/* Only used by uv_tcp_t handles. */ -#define UV_HANDLE_TCP_NODELAY 0x02000000 -#define UV_HANDLE_TCP_KEEPALIVE 0x04000000 -#define UV_HANDLE_TCP_SINGLE_ACCEPT 0x08000000 -#define UV_HANDLE_TCP_ACCEPT_STATE_CHANGING 0x10000000 -#define UV_HANDLE_TCP_SOCKET_CLOSED 0x20000000 -#define UV_HANDLE_SHARED_TCP_SOCKET 0x40000000 - -/* Only used by uv_pipe_t handles. */ -#define UV_HANDLE_NON_OVERLAPPED_PIPE 0x01000000 -#define UV_HANDLE_PIPESERVER 0x02000000 -#define UV_HANDLE_PIPE_READ_CANCELABLE 0x04000000 - -/* Only used by uv_tty_t handles. */ -#define UV_HANDLE_TTY_READABLE 0x01000000 -#define UV_HANDLE_TTY_RAW 0x02000000 -#define UV_HANDLE_TTY_SAVED_POSITION 0x04000000 -#define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x08000000 - -/* Only used by uv_poll_t handles. */ -#define UV_HANDLE_POLL_SLOW 0x02000000 - - -/* - * Requests: see req-inl.h - */ - - -/* - * Streams: see stream-inl.h - */ - - -/* - * TCP - */ - -typedef struct { - WSAPROTOCOL_INFOW socket_info; - int delayed_error; -} uv__ipc_socket_info_ex; - -int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb); -int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client); -int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -int uv_tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); -int uv__tcp_try_write(uv_tcp_t* handle, const uv_buf_t bufs[], - unsigned int nbufs); - -void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, uv_req_t* req); -void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_write_t* req); -void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_req_t* req); -void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_connect_t* req); - -void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp); -void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle); - -int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex, - int tcp_connection); - -int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, - LPWSAPROTOCOL_INFOW protocol_info); - - -/* - * UDP - */ -void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, uv_req_t* req); -void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, - uv_udp_send_t* req); - -void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle); -void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle); - - -/* - * Pipes - */ -int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access, - char* name, size_t nameSize); - -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); -int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client); -int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); -int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle, - uv_write_cb cb); -void uv__pipe_pause_read(uv_pipe_t* handle); -void uv__pipe_unpause_read(uv_pipe_t* handle); -void uv__pipe_stop_read(uv_pipe_t* handle); - -void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* req); -void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_write_t* req); -void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* raw_req); -void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_connect_t* req); -void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_shutdown_t* req); - -void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle); -void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle); -void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle); - - -/* - * TTY - */ -void uv_console_init(void); - -int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -int uv_tty_read_stop(uv_tty_t* handle); -int uv_tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle, - const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb); -int uv__tty_try_write(uv_tty_t* handle, const uv_buf_t bufs[], - unsigned int nbufs); -void uv_tty_close(uv_tty_t* handle); - -void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req); -void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, - uv_write_t* req); -/* TODO: remove me */ -void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* raw_req); -/* TODO: remove me */ -void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle, - uv_connect_t* req); - -void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle); - - -/* - * Poll watchers - */ -void uv_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, - uv_req_t* req); - -int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle); -void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle); - - -/* - * Timers - */ -void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle); - -DWORD uv__next_timeout(const uv_loop_t* loop); -void uv_process_timers(uv_loop_t* loop); - - -/* - * Loop watchers - */ -void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle); - -void uv_prepare_invoke(uv_loop_t* loop); -void uv_check_invoke(uv_loop_t* loop); -void uv_idle_invoke(uv_loop_t* loop); - -void uv__once_init(void); - - -/* - * Async watcher - */ -void uv_async_close(uv_loop_t* loop, uv_async_t* handle); -void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle); - -void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle, - uv_req_t* req); - - -/* - * Signal watcher - */ -void uv_signals_init(void); -int uv__signal_dispatch(int signum); - -void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle); -void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle); - -void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle, - uv_req_t* req); - - -/* - * Spawn - */ -void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle); -void uv_process_close(uv_loop_t* loop, uv_process_t* handle); -void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle); - - -/* - * Error - */ -int uv_translate_sys_error(int sys_errno); - - -/* - * FS - */ -void uv_fs_init(void); - - -/* - * FS Event - */ -void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, - uv_fs_event_t* handle); -void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle); -void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle); - - -/* - * Stat poller. - */ -void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle); - - -/* - * Utilities. - */ -void uv__util_init(void); - -uint64_t uv__hrtime(double scale); -int uv_parent_pid(void); -int uv_current_pid(void); -__declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall); -int uv__getpwuid_r(uv_passwd_t* pwd); -int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8); -int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16); - - -/* - * Process stdio handles. - */ -int uv__stdio_create(uv_loop_t* loop, - const uv_process_options_t* options, - BYTE** buffer_ptr); -void uv__stdio_destroy(BYTE* buffer); -void uv__stdio_noinherit(BYTE* buffer); -int uv__stdio_verify(BYTE* buffer, WORD size); -WORD uv__stdio_size(BYTE* buffer); -HANDLE uv__stdio_handle(BYTE* buffer, int fd); - - -/* - * Winapi and ntapi utility functions - */ -void uv_winapi_init(void); - - -/* - * Winsock utility functions - */ -void uv_winsock_init(void); - -int uv_ntstatus_to_winsock_error(NTSTATUS status); - -BOOL uv_get_acceptex_function(SOCKET socket, LPFN_ACCEPTEX* target); -BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target); - -int WSAAPI uv_wsarecv_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); -int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, struct sockaddr* addr, - int* addr_len, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in, - AFD_POLL_INFO* info_out, OVERLAPPED* overlapped); - -/* Whether there are any non-IFS LSPs stacked on TCP */ -extern int uv_tcp_non_ifs_lsp_ipv4; -extern int uv_tcp_non_ifs_lsp_ipv6; - -/* Ip address used to bind to any port at any interface */ -extern struct sockaddr_in uv_addr_ip4_any_; -extern struct sockaddr_in6 uv_addr_ip6_any_; - -/* - * Wake all loops with fake message - */ -void uv__wake_all_loops(void); - -/* - * Init system wake-up detection - */ -void uv__init_detect_system_wakeup(void); - -#endif /* UV_WIN_INTERNAL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/win/loop-watcher.c b/lib/ESPiLight/pilight/libs/libuv/win/loop-watcher.c deleted file mode 100644 index 20e4509..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/loop-watcher.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" - - -void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - handle->flags |= UV_HANDLE_CLOSED; - uv__handle_close(handle); - } -} - - -#define UV_LOOP_WATCHER_DEFINE(name, NAME) \ - int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \ - uv__handle_init(loop, (uv_handle_t*) handle, UV_##NAME); \ - \ - return 0; \ - } \ - \ - \ - int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \ - uv_loop_t* loop = handle->loop; \ - uv_##name##_t* old_head; \ - \ - assert(handle->type == UV_##NAME); \ - \ - if (uv__is_active(handle)) \ - return 0; \ - \ - if (cb == NULL) \ - return UV_EINVAL; \ - \ - old_head = loop->name##_handles; \ - \ - handle->name##_next = old_head; \ - handle->name##_prev = NULL; \ - \ - if (old_head) { \ - old_head->name##_prev = handle; \ - } \ - \ - loop->name##_handles = handle; \ - \ - handle->name##_cb = cb; \ - uv__handle_start(handle); \ - \ - return 0; \ - } \ - \ - \ - int uv_##name##_stop(uv_##name##_t* handle) { \ - uv_loop_t* loop = handle->loop; \ - \ - assert(handle->type == UV_##NAME); \ - \ - if (!uv__is_active(handle)) \ - return 0; \ - \ - /* Update loop head if needed */ \ - if (loop->name##_handles == handle) { \ - loop->name##_handles = handle->name##_next; \ - } \ - \ - /* Update the iterator-next pointer of needed */ \ - if (loop->next_##name##_handle == handle) { \ - loop->next_##name##_handle = handle->name##_next; \ - } \ - \ - if (handle->name##_prev) { \ - handle->name##_prev->name##_next = handle->name##_next; \ - } \ - if (handle->name##_next) { \ - handle->name##_next->name##_prev = handle->name##_prev; \ - } \ - \ - uv__handle_stop(handle); \ - \ - return 0; \ - } \ - \ - \ - void uv_##name##_invoke(uv_loop_t* loop) { \ - uv_##name##_t* handle; \ - \ - (loop)->next_##name##_handle = (loop)->name##_handles; \ - \ - while ((loop)->next_##name##_handle != NULL) { \ - handle = (loop)->next_##name##_handle; \ - (loop)->next_##name##_handle = handle->name##_next; \ - \ - handle->name##_cb(handle); \ - } \ - } - -UV_LOOP_WATCHER_DEFINE(prepare, PREPARE) -UV_LOOP_WATCHER_DEFINE(check, CHECK) -UV_LOOP_WATCHER_DEFINE(idle, IDLE) diff --git a/lib/ESPiLight/pilight/libs/libuv/win/pipe.c b/lib/ESPiLight/pilight/libs/libuv/win/pipe.c deleted file mode 100644 index 9b10cc9..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/pipe.c +++ /dev/null @@ -1,2132 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - -typedef struct uv__ipc_queue_item_s uv__ipc_queue_item_t; - -struct uv__ipc_queue_item_s { - /* - * NOTE: It is important for socket_info_ex to be the first field, - * because we will we assigning it to the pending_ipc_info.socket_info - */ - uv__ipc_socket_info_ex socket_info_ex; - QUEUE member; - int tcp_connection; -}; - -/* A zero-size buffer for use by uv_pipe_read */ -static char uv_zero_[] = ""; - -/* Null uv_buf_t */ -static const uv_buf_t uv_null_buf_ = { 0, NULL }; - -/* The timeout that the pipe will wait for the remote end to write data */ -/* when the local ends wants to shut it down. */ -static const int64_t eof_timeout = 50; /* ms */ - -static const int default_pending_pipe_instances = 4; - -/* Pipe prefix */ -static char pipe_prefix[] = "\\\\?\\pipe"; -static const int pipe_prefix_len = sizeof(pipe_prefix) - 1; - -/* IPC protocol flags. */ -#define UV_IPC_RAW_DATA 0x0001 -#define UV_IPC_TCP_SERVER 0x0002 -#define UV_IPC_TCP_CONNECTION 0x0004 - -/* IPC frame header. */ -typedef struct { - int flags; - uint64_t raw_data_length; -} uv_ipc_frame_header_t; - -/* IPC frame, which contains an imported TCP socket stream. */ -typedef struct { - uv_ipc_frame_header_t header; - uv__ipc_socket_info_ex socket_info_ex; -} uv_ipc_frame_uv_stream; - -static void eof_timer_init(uv_pipe_t* pipe); -static void eof_timer_start(uv_pipe_t* pipe); -static void eof_timer_stop(uv_pipe_t* pipe); -static void eof_timer_cb(uv_timer_t* timer); -static void eof_timer_destroy(uv_pipe_t* pipe); -static void eof_timer_close_cb(uv_handle_t* handle); - - -static void uv_unique_pipe_name(char* ptr, char* name, size_t size) { - snprintf(name, size, "\\\\?\\pipe\\uv\\%p-%lu", ptr, GetCurrentProcessId()); -} - - -int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) { - uv_stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE); - - handle->reqs_pending = 0; - handle->handle = INVALID_HANDLE_VALUE; - handle->name = NULL; - handle->pipe.conn.ipc_pid = 0; - handle->pipe.conn.remaining_ipc_rawdata_bytes = 0; - QUEUE_INIT(&handle->pipe.conn.pending_ipc_info.queue); - handle->pipe.conn.pending_ipc_info.queue_len = 0; - handle->ipc = ipc; - handle->pipe.conn.non_overlapped_writes_tail = NULL; - handle->pipe.conn.readfile_thread = NULL; - - UV_REQ_INIT(&handle->pipe.conn.ipc_header_write_req, UV_UNKNOWN_REQ); - - return 0; -} - - -static void uv_pipe_connection_init(uv_pipe_t* handle) { - uv_connection_init((uv_stream_t*) handle); - handle->read_req.data = handle; - handle->pipe.conn.eof_timer = NULL; - assert(!(handle->flags & UV_HANDLE_PIPESERVER)); - if (pCancelSynchronousIo && - handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - uv_mutex_init(&handle->pipe.conn.readfile_mutex); - handle->flags |= UV_HANDLE_PIPE_READ_CANCELABLE; - } -} - - -static HANDLE open_named_pipe(const WCHAR* name, DWORD* duplex_flags) { - HANDLE pipeHandle; - - /* - * Assume that we have a duplex pipe first, so attempt to - * connect with GENERIC_READ | GENERIC_WRITE. - */ - pipeHandle = CreateFileW(name, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - if (pipeHandle != INVALID_HANDLE_VALUE) { - *duplex_flags = UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - return pipeHandle; - } - - /* - * If the pipe is not duplex CreateFileW fails with - * ERROR_ACCESS_DENIED. In that case try to connect - * as a read-only or write-only. - */ - if (GetLastError() == ERROR_ACCESS_DENIED) { - pipeHandle = CreateFileW(name, - GENERIC_READ | FILE_WRITE_ATTRIBUTES, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - - if (pipeHandle != INVALID_HANDLE_VALUE) { - *duplex_flags = UV_HANDLE_READABLE; - return pipeHandle; - } - } - - if (GetLastError() == ERROR_ACCESS_DENIED) { - pipeHandle = CreateFileW(name, - GENERIC_WRITE | FILE_READ_ATTRIBUTES, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - - if (pipeHandle != INVALID_HANDLE_VALUE) { - *duplex_flags = UV_HANDLE_WRITABLE; - return pipeHandle; - } - } - - return INVALID_HANDLE_VALUE; -} - - -static void close_pipe(uv_pipe_t* pipe) { - assert(pipe->u.fd == -1 || pipe->u.fd > 2); - if (pipe->u.fd == -1) - CloseHandle(pipe->handle); - else - close(pipe->u.fd); - - pipe->u.fd = -1; - pipe->handle = INVALID_HANDLE_VALUE; -} - - -int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access, - char* name, size_t nameSize) { - HANDLE pipeHandle; - int err; - char* ptr = (char*)handle; - - for (;;) { - uv_unique_pipe_name(ptr, name, nameSize); - - pipeHandle = CreateNamedPipeA(name, - access | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 65536, 65536, 0, - NULL); - - if (pipeHandle != INVALID_HANDLE_VALUE) { - /* No name collisions. We're done. */ - break; - } - - err = GetLastError(); - if (err != ERROR_PIPE_BUSY && err != ERROR_ACCESS_DENIED) { - goto error; - } - - /* Pipe name collision. Increment the pointer and try again. */ - ptr++; - } - - if (CreateIoCompletionPort(pipeHandle, - loop->iocp, - (ULONG_PTR)handle, - 0) == NULL) { - err = GetLastError(); - goto error; - } - - uv_pipe_connection_init(handle); - handle->handle = pipeHandle; - - return 0; - - error: - if (pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(pipeHandle); - } - - return err; -} - - -static int uv_set_pipe_handle(uv_loop_t* loop, - uv_pipe_t* handle, - HANDLE pipeHandle, - int fd, - DWORD duplex_flags) { - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_MODE_INFORMATION mode_info; - DWORD mode = PIPE_READMODE_BYTE | PIPE_WAIT; - DWORD current_mode = 0; - DWORD err = 0; - - if (!(handle->flags & UV_HANDLE_PIPESERVER) && - handle->handle != INVALID_HANDLE_VALUE) - return UV_EBUSY; - - if (!SetNamedPipeHandleState(pipeHandle, &mode, NULL, NULL)) { - err = GetLastError(); - if (err == ERROR_ACCESS_DENIED) { - /* - * SetNamedPipeHandleState can fail if the handle doesn't have either - * GENERIC_WRITE or FILE_WRITE_ATTRIBUTES. - * But if the handle already has the desired wait and blocking modes - * we can continue. - */ - if (!GetNamedPipeHandleState(pipeHandle, ¤t_mode, NULL, NULL, - NULL, NULL, 0)) { - return -1; - } else if (current_mode & PIPE_NOWAIT) { - SetLastError(ERROR_ACCESS_DENIED); - return -1; - } - } else { - /* If this returns ERROR_INVALID_PARAMETER we probably opened - * something that is not a pipe. */ - if (err == ERROR_INVALID_PARAMETER) { - SetLastError(WSAENOTSOCK); - } - return -1; - } - } - - /* Check if the pipe was created with FILE_FLAG_OVERLAPPED. */ - nt_status = pNtQueryInformationFile(pipeHandle, - &io_status, - &mode_info, - sizeof(mode_info), - FileModeInformation); - if (nt_status != STATUS_SUCCESS) { - return -1; - } - - if (mode_info.Mode & FILE_SYNCHRONOUS_IO_ALERT || - mode_info.Mode & FILE_SYNCHRONOUS_IO_NONALERT) { - /* Non-overlapped pipe. */ - handle->flags |= UV_HANDLE_NON_OVERLAPPED_PIPE; - } else { - /* Overlapped pipe. Try to associate with IOCP. */ - if (CreateIoCompletionPort(pipeHandle, - loop->iocp, - (ULONG_PTR)handle, - 0) == NULL) { - handle->flags |= UV_HANDLE_EMULATE_IOCP; - } - } - - handle->handle = pipeHandle; - handle->u.fd = fd; - handle->flags |= duplex_flags; - - return 0; -} - - -static DWORD WINAPI pipe_shutdown_thread_proc(void* parameter) { - uv_loop_t* loop; - uv_pipe_t* handle; - uv_shutdown_t* req; - - req = (uv_shutdown_t*) parameter; - assert(req); - handle = (uv_pipe_t*) req->handle; - assert(handle); - loop = handle->loop; - assert(loop); - - FlushFileBuffers(handle->handle); - - /* Post completed */ - POST_COMPLETION_FOR_REQ(loop, req); - - return 0; -} - - -void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { - int err; - DWORD result; - uv_shutdown_t* req; - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_PIPE_LOCAL_INFORMATION pipe_info; - uv__ipc_queue_item_t* item; - - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - handle->flags &= ~UV_HANDLE_PIPE_READ_CANCELABLE; - uv_mutex_destroy(&handle->pipe.conn.readfile_mutex); - } - - if ((handle->flags & UV_HANDLE_CONNECTION) && - handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - req = handle->stream.conn.shutdown_req; - - /* Clear the shutdown_req field so we don't go here again. */ - handle->stream.conn.shutdown_req = NULL; - - if (handle->flags & UV__HANDLE_CLOSING) { - UNREGISTER_HANDLE_REQ(loop, handle, req); - - /* Already closing. Cancel the shutdown. */ - if (req->cb) { - req->cb(req, UV_ECANCELED); - } - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - /* Try to avoid flushing the pipe buffer in the thread pool. */ - nt_status = pNtQueryInformationFile(handle->handle, - &io_status, - &pipe_info, - sizeof pipe_info, - FilePipeLocalInformation); - - if (nt_status != STATUS_SUCCESS) { - /* Failure */ - UNREGISTER_HANDLE_REQ(loop, handle, req); - - handle->flags |= UV_HANDLE_WRITABLE; /* Questionable */ - if (req->cb) { - err = pRtlNtStatusToDosError(nt_status); - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (pipe_info.OutboundQuota == pipe_info.WriteQuotaAvailable) { - /* Short-circuit, no need to call FlushFileBuffers. */ - uv_insert_pending_req(loop, (uv_req_t*) req); - return; - } - - /* Run FlushFileBuffers in the thread pool. */ - result = QueueUserWorkItem(pipe_shutdown_thread_proc, - req, - WT_EXECUTELONGFUNCTION); - if (result) { - return; - - } else { - /* Failure. */ - UNREGISTER_HANDLE_REQ(loop, handle, req); - - handle->flags |= UV_HANDLE_WRITABLE; /* Questionable */ - if (req->cb) { - err = GetLastError(); - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - } - - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - if (handle->flags & UV_HANDLE_CONNECTION) { - /* Free pending sockets */ - while (!QUEUE_EMPTY(&handle->pipe.conn.pending_ipc_info.queue)) { - QUEUE* q; - SOCKET socket; - - q = QUEUE_HEAD(&handle->pipe.conn.pending_ipc_info.queue); - QUEUE_REMOVE(q); - item = QUEUE_DATA(q, uv__ipc_queue_item_t, member); - - /* Materialize socket and close it */ - socket = WSASocketW(FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - &item->socket_info_ex.socket_info, - 0, - WSA_FLAG_OVERLAPPED); - uv__free(item); - - if (socket != INVALID_SOCKET) - closesocket(socket); - } - handle->pipe.conn.pending_ipc_info.queue_len = 0; - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(handle->read_req.wait_handle); - handle->read_req.wait_handle = INVALID_HANDLE_VALUE; - } - if (handle->read_req.event_handle) { - CloseHandle(handle->read_req.event_handle); - handle->read_req.event_handle = NULL; - } - } - } - - if (handle->flags & UV_HANDLE_PIPESERVER) { - assert(handle->pipe.serv.accept_reqs); - uv__free(handle->pipe.serv.accept_reqs); - handle->pipe.serv.accept_reqs = NULL; - } - - uv__handle_close(handle); - } -} - - -void uv_pipe_pending_instances(uv_pipe_t* handle, int count) { - if (handle->flags & UV_HANDLE_BOUND) - return; - handle->pipe.serv.pending_instances = count; - handle->flags |= UV_HANDLE_PIPESERVER; -} - - -/* Creates a pipe server. */ -int uv_pipe_bind(uv_pipe_t* handle, const char* name) { - uv_loop_t* loop = handle->loop; - int i, err, nameSize; - uv_pipe_accept_t* req; - - if (handle->flags & UV_HANDLE_BOUND) { - return UV_EINVAL; - } - - if (!name) { - return UV_EINVAL; - } - - if (!(handle->flags & UV_HANDLE_PIPESERVER)) { - handle->pipe.serv.pending_instances = default_pending_pipe_instances; - } - - handle->pipe.serv.accept_reqs = (uv_pipe_accept_t*) - uv__malloc(sizeof(uv_pipe_accept_t) * handle->pipe.serv.pending_instances); - if (!handle->pipe.serv.accept_reqs) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - for (i = 0; i < handle->pipe.serv.pending_instances; i++) { - req = &handle->pipe.serv.accept_reqs[i]; - UV_REQ_INIT(req, UV_ACCEPT); - req->data = handle; - req->pipeHandle = INVALID_HANDLE_VALUE; - req->next_pending = NULL; - } - - /* Convert name to UTF16. */ - nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); - handle->name = (WCHAR*)uv__malloc(nameSize); - if (!handle->name) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - name, - -1, - handle->name, - nameSize / sizeof(WCHAR))) { - err = GetLastError(); - goto error; - } - - /* - * Attempt to create the first pipe with FILE_FLAG_FIRST_PIPE_INSTANCE. - * If this fails then there's already a pipe server for the given pipe name. - */ - handle->pipe.serv.accept_reqs[0].pipeHandle = CreateNamedPipeW(handle->name, - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | - FILE_FLAG_FIRST_PIPE_INSTANCE, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL); - - if (handle->pipe.serv.accept_reqs[0].pipeHandle == INVALID_HANDLE_VALUE) { - err = GetLastError(); - if (err == ERROR_ACCESS_DENIED) { - err = WSAEADDRINUSE; /* Translates to UV_EADDRINUSE. */ - } else if (err == ERROR_PATH_NOT_FOUND || err == ERROR_INVALID_NAME) { - err = WSAEACCES; /* Translates to UV_EACCES. */ - } - goto error; - } - - if (uv_set_pipe_handle(loop, - handle, - handle->pipe.serv.accept_reqs[0].pipeHandle, - -1, - 0)) { - err = GetLastError(); - goto error; - } - - handle->pipe.serv.pending_accepts = NULL; - handle->flags |= UV_HANDLE_PIPESERVER; - handle->flags |= UV_HANDLE_BOUND; - - return 0; - -error: - if (handle->name) { - uv__free(handle->name); - handle->name = NULL; - } - - if (handle->pipe.serv.accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(handle->pipe.serv.accept_reqs[0].pipeHandle); - handle->pipe.serv.accept_reqs[0].pipeHandle = INVALID_HANDLE_VALUE; - } - - return uv_translate_sys_error(err); -} - - -static DWORD WINAPI pipe_connect_thread_proc(void* parameter) { - uv_loop_t* loop; - uv_pipe_t* handle; - uv_connect_t* req; - HANDLE pipeHandle = INVALID_HANDLE_VALUE; - DWORD duplex_flags; - - req = (uv_connect_t*) parameter; - assert(req); - handle = (uv_pipe_t*) req->handle; - assert(handle); - loop = handle->loop; - assert(loop); - - /* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. */ - /* We wait for the pipe to become available with WaitNamedPipe. */ - while (WaitNamedPipeW(handle->name, 30000)) { - /* The pipe is now available, try to connect. */ - pipeHandle = open_named_pipe(handle->name, &duplex_flags); - if (pipeHandle != INVALID_HANDLE_VALUE) { - break; - } - - SwitchToThread(); - } - - if (pipeHandle != INVALID_HANDLE_VALUE && - !uv_set_pipe_handle(loop, handle, pipeHandle, -1, duplex_flags)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_ERROR(req, GetLastError()); - } - - /* Post completed */ - POST_COMPLETION_FOR_REQ(loop, req); - - return 0; -} - - -void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, - const char* name, uv_connect_cb cb) { - uv_loop_t* loop = handle->loop; - int err, nameSize; - HANDLE pipeHandle = INVALID_HANDLE_VALUE; - DWORD duplex_flags; - - UV_REQ_INIT(req, UV_CONNECT); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - - /* Convert name to UTF16. */ - nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); - handle->name = (WCHAR*)uv__malloc(nameSize); - if (!handle->name) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - name, - -1, - handle->name, - nameSize / sizeof(WCHAR))) { - err = GetLastError(); - goto error; - } - - pipeHandle = open_named_pipe(handle->name, &duplex_flags); - if (pipeHandle == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_PIPE_BUSY) { - /* Wait for the server to make a pipe instance available. */ - if (!QueueUserWorkItem(&pipe_connect_thread_proc, - req, - WT_EXECUTELONGFUNCTION)) { - err = GetLastError(); - goto error; - } - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - - return; - } - - err = GetLastError(); - goto error; - } - - assert(pipeHandle != INVALID_HANDLE_VALUE); - - if (uv_set_pipe_handle(loop, - (uv_pipe_t*) req->handle, - pipeHandle, - -1, - duplex_flags)) { - err = GetLastError(); - goto error; - } - - SET_REQ_SUCCESS(req); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - return; - -error: - if (handle->name) { - uv__free(handle->name); - handle->name = NULL; - } - - if (pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(pipeHandle); - } - - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, err); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - return; -} - - -void uv__pipe_pause_read(uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - /* Pause the ReadFile task briefly, to work - around the Windows kernel bug that causes - any access to a NamedPipe to deadlock if - any process has called ReadFile */ - HANDLE h; - uv_mutex_lock(&handle->pipe.conn.readfile_mutex); - h = handle->pipe.conn.readfile_thread; - while (h) { - /* spinlock: we expect this to finish quickly, - or we are probably about to deadlock anyways - (in the kernel), so it doesn't matter */ - pCancelSynchronousIo(h); - SwitchToThread(); /* yield thread control briefly */ - h = handle->pipe.conn.readfile_thread; - } - } -} - - -void uv__pipe_unpause_read(uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - uv_mutex_unlock(&handle->pipe.conn.readfile_mutex); - } -} - - -void uv__pipe_stop_read(uv_pipe_t* handle) { - handle->flags &= ~UV_HANDLE_READING; - uv__pipe_pause_read((uv_pipe_t*)handle); - uv__pipe_unpause_read((uv_pipe_t*)handle); -} - - -/* Cleans up uv_pipe_t (server or connection) and all resources associated */ -/* with it. */ -void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle) { - int i; - HANDLE pipeHandle; - - uv__pipe_stop_read(handle); - - if (handle->name) { - uv__free(handle->name); - handle->name = NULL; - } - - if (handle->flags & UV_HANDLE_PIPESERVER) { - for (i = 0; i < handle->pipe.serv.pending_instances; i++) { - pipeHandle = handle->pipe.serv.accept_reqs[i].pipeHandle; - if (pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(pipeHandle); - handle->pipe.serv.accept_reqs[i].pipeHandle = INVALID_HANDLE_VALUE; - } - } - handle->handle = INVALID_HANDLE_VALUE; - } - - if (handle->flags & UV_HANDLE_CONNECTION) { - handle->flags &= ~UV_HANDLE_WRITABLE; - eof_timer_destroy(handle); - } - - if ((handle->flags & UV_HANDLE_CONNECTION) - && handle->handle != INVALID_HANDLE_VALUE) - close_pipe(handle); -} - - -void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle) { - if (handle->flags & UV_HANDLE_READING) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - } - - if (handle->flags & UV_HANDLE_LISTENING) { - handle->flags &= ~UV_HANDLE_LISTENING; - DECREASE_ACTIVE_COUNT(loop, handle); - } - - uv_pipe_cleanup(loop, handle); - - if (handle->reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - - handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); - uv__handle_closing(handle); -} - - -static void uv_pipe_queue_accept(uv_loop_t* loop, uv_pipe_t* handle, - uv_pipe_accept_t* req, BOOL firstInstance) { - assert(handle->flags & UV_HANDLE_LISTENING); - - if (!firstInstance) { - assert(req->pipeHandle == INVALID_HANDLE_VALUE); - - req->pipeHandle = CreateNamedPipeW(handle->name, - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL); - - if (req->pipeHandle == INVALID_HANDLE_VALUE) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - return; - } - - if (uv_set_pipe_handle(loop, handle, req->pipeHandle, -1, 0)) { - CloseHandle(req->pipeHandle); - req->pipeHandle = INVALID_HANDLE_VALUE; - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - return; - } - } - - assert(req->pipeHandle != INVALID_HANDLE_VALUE); - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - - if (!ConnectNamedPipe(req->pipeHandle, &req->u.io.overlapped) && - GetLastError() != ERROR_IO_PENDING) { - if (GetLastError() == ERROR_PIPE_CONNECTED) { - SET_REQ_SUCCESS(req); - } else { - CloseHandle(req->pipeHandle); - req->pipeHandle = INVALID_HANDLE_VALUE; - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - } - uv_insert_pending_req(loop, (uv_req_t*) req); - handle->reqs_pending++; - return; - } - - handle->reqs_pending++; -} - - -int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) { - uv_loop_t* loop = server->loop; - uv_pipe_t* pipe_client; - uv_pipe_accept_t* req; - QUEUE* q; - uv__ipc_queue_item_t* item; - int err; - - if (server->ipc) { - if (QUEUE_EMPTY(&server->pipe.conn.pending_ipc_info.queue)) { - /* No valid pending sockets. */ - return WSAEWOULDBLOCK; - } - - q = QUEUE_HEAD(&server->pipe.conn.pending_ipc_info.queue); - QUEUE_REMOVE(q); - server->pipe.conn.pending_ipc_info.queue_len--; - item = QUEUE_DATA(q, uv__ipc_queue_item_t, member); - - err = uv_tcp_import((uv_tcp_t*)client, - &item->socket_info_ex, - item->tcp_connection); - if (err != 0) - return err; - - uv__free(item); - - } else { - pipe_client = (uv_pipe_t*)client; - - /* Find a connection instance that has been connected, but not yet */ - /* accepted. */ - req = server->pipe.serv.pending_accepts; - - if (!req) { - /* No valid connections found, so we error out. */ - return WSAEWOULDBLOCK; - } - - /* Initialize the client handle and copy the pipeHandle to the client */ - uv_pipe_connection_init(pipe_client); - pipe_client->handle = req->pipeHandle; - pipe_client->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - - /* Prepare the req to pick up a new connection */ - server->pipe.serv.pending_accepts = req->next_pending; - req->next_pending = NULL; - req->pipeHandle = INVALID_HANDLE_VALUE; - - if (!(server->flags & UV__HANDLE_CLOSING)) { - uv_pipe_queue_accept(loop, server, req, FALSE); - } - } - - return 0; -} - - -/* Starts listening for connections for the given pipe. */ -int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { - uv_loop_t* loop = handle->loop; - int i; - - if (handle->flags & UV_HANDLE_LISTENING) { - handle->stream.serv.connection_cb = cb; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) { - return WSAEINVAL; - } - - if (handle->flags & UV_HANDLE_READING) { - return WSAEISCONN; - } - - if (!(handle->flags & UV_HANDLE_PIPESERVER)) { - return ERROR_NOT_SUPPORTED; - } - - handle->flags |= UV_HANDLE_LISTENING; - INCREASE_ACTIVE_COUNT(loop, handle); - handle->stream.serv.connection_cb = cb; - - /* First pipe handle should have already been created in uv_pipe_bind */ - assert(handle->pipe.serv.accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE); - - for (i = 0; i < handle->pipe.serv.pending_instances; i++) { - uv_pipe_queue_accept(loop, handle, &handle->pipe.serv.accept_reqs[i], i == 0); - } - - return 0; -} - - -static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) { - int result; - DWORD bytes; - uv_read_t* req = (uv_read_t*) parameter; - uv_pipe_t* handle = (uv_pipe_t*) req->data; - uv_loop_t* loop = handle->loop; - HANDLE hThread = NULL; - DWORD err; - uv_mutex_t *m = &handle->pipe.conn.readfile_mutex; - - assert(req != NULL); - assert(req->type == UV_READ); - assert(handle->type == UV_NAMED_PIPE); - - if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - uv_mutex_lock(m); /* mutex controls *setting* of readfile_thread */ - if (DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), - GetCurrentProcess(), &hThread, - 0, FALSE, DUPLICATE_SAME_ACCESS)) { - handle->pipe.conn.readfile_thread = hThread; - } else { - hThread = NULL; - } - uv_mutex_unlock(m); - } -restart_readfile: - if (handle->flags & UV_HANDLE_READING) { - result = ReadFile(handle->handle, - &uv_zero_, - 0, - &bytes, - NULL); - if (!result) { - err = GetLastError(); - if (err == ERROR_OPERATION_ABORTED && - handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - if (handle->flags & UV_HANDLE_READING) { - /* just a brief break to do something else */ - handle->pipe.conn.readfile_thread = NULL; - /* resume after it is finished */ - uv_mutex_lock(m); - handle->pipe.conn.readfile_thread = hThread; - uv_mutex_unlock(m); - goto restart_readfile; - } else { - result = 1; /* successfully stopped reading */ - } - } - } - } else { - result = 1; /* successfully aborted read before it even started */ - } - if (hThread) { - assert(hThread == handle->pipe.conn.readfile_thread); - /* mutex does not control clearing readfile_thread */ - handle->pipe.conn.readfile_thread = NULL; - uv_mutex_lock(m); - /* only when we hold the mutex lock is it safe to - open or close the handle */ - CloseHandle(hThread); - uv_mutex_unlock(m); - } - - if (!result) { - SET_REQ_ERROR(req, err); - } - - POST_COMPLETION_FOR_REQ(loop, req); - return 0; -} - - -static DWORD WINAPI uv_pipe_writefile_thread_proc(void* parameter) { - int result; - DWORD bytes; - uv_write_t* req = (uv_write_t*) parameter; - uv_pipe_t* handle = (uv_pipe_t*) req->handle; - uv_loop_t* loop = handle->loop; - - assert(req != NULL); - assert(req->type == UV_WRITE); - assert(handle->type == UV_NAMED_PIPE); - assert(req->write_buffer.base); - - result = WriteFile(handle->handle, - req->write_buffer.base, - req->write_buffer.len, - &bytes, - NULL); - - if (!result) { - SET_REQ_ERROR(req, GetLastError()); - } - - POST_COMPLETION_FOR_REQ(loop, req); - return 0; -} - - -static void CALLBACK post_completion_read_wait(void* context, BOOLEAN timed_out) { - uv_read_t* req; - uv_tcp_t* handle; - - req = (uv_read_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->data; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void CALLBACK post_completion_write_wait(void* context, BOOLEAN timed_out) { - uv_write_t* req; - uv_tcp_t* handle; - - req = (uv_write_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->handle; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void uv_pipe_queue_read(uv_loop_t* loop, uv_pipe_t* handle) { - uv_read_t* req; - int result; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - assert(handle->handle != INVALID_HANDLE_VALUE); - - req = &handle->read_req; - - if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - if (!QueueUserWorkItem(&uv_pipe_zero_readfile_thread_proc, - req, - WT_EXECUTELONGFUNCTION)) { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - goto error; - } - } else { - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->u.io.overlapped.hEvent = (HANDLE) ((uintptr_t) req->event_handle | 1); - } - - /* Do 0-read */ - result = ReadFile(handle->handle, - &uv_zero_, - 0, - NULL, - &req->u.io.overlapped); - - if (!result && GetLastError() != ERROR_IO_PENDING) { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - goto error; - } - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (!req->event_handle) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - } - if (req->wait_handle == INVALID_HANDLE_VALUE) { - if (!RegisterWaitForSingleObject(&req->wait_handle, - req->u.io.overlapped.hEvent, post_completion_read_wait, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - SET_REQ_ERROR(req, GetLastError()); - goto error; - } - } - } - } - - /* Start the eof timer if there is one */ - eof_timer_start(handle); - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - return; - -error: - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; -} - - -int uv_pipe_read_start(uv_pipe_t* handle, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - uv_loop_t* loop = handle->loop; - - handle->flags |= UV_HANDLE_READING; - INCREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb = read_cb; - handle->alloc_cb = alloc_cb; - - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ - if (!(handle->flags & UV_HANDLE_READ_PENDING)) - uv_pipe_queue_read(loop, handle); - - return 0; -} - - -static void uv_insert_non_overlapped_write_req(uv_pipe_t* handle, - uv_write_t* req) { - req->next_req = NULL; - if (handle->pipe.conn.non_overlapped_writes_tail) { - req->next_req = - handle->pipe.conn.non_overlapped_writes_tail->next_req; - handle->pipe.conn.non_overlapped_writes_tail->next_req = (uv_req_t*)req; - handle->pipe.conn.non_overlapped_writes_tail = req; - } else { - req->next_req = (uv_req_t*)req; - handle->pipe.conn.non_overlapped_writes_tail = req; - } -} - - -static uv_write_t* uv_remove_non_overlapped_write_req(uv_pipe_t* handle) { - uv_write_t* req; - - if (handle->pipe.conn.non_overlapped_writes_tail) { - req = (uv_write_t*)handle->pipe.conn.non_overlapped_writes_tail->next_req; - - if (req == handle->pipe.conn.non_overlapped_writes_tail) { - handle->pipe.conn.non_overlapped_writes_tail = NULL; - } else { - handle->pipe.conn.non_overlapped_writes_tail->next_req = - req->next_req; - } - - return req; - } else { - /* queue empty */ - return NULL; - } -} - - -static void uv_queue_non_overlapped_write(uv_pipe_t* handle) { - uv_write_t* req = uv_remove_non_overlapped_write_req(handle); - if (req) { - if (!QueueUserWorkItem(&uv_pipe_writefile_thread_proc, - req, - WT_EXECUTELONGFUNCTION)) { - uv_fatal_error(GetLastError(), "QueueUserWorkItem"); - } - } -} - - -static int uv_pipe_write_impl(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - int err; - int result; - uv_tcp_t* tcp_send_handle; - uv_write_t* ipc_header_req = NULL; - uv_ipc_frame_uv_stream ipc_frame; - - if (nbufs != 1 && (nbufs != 0 || !send_handle)) { - return ERROR_NOT_SUPPORTED; - } - - /* Only TCP handles are supported for sharing. */ - if (send_handle && ((send_handle->type != UV_TCP) || - (!(send_handle->flags & UV_HANDLE_BOUND) && - !(send_handle->flags & UV_HANDLE_CONNECTION)))) { - return ERROR_NOT_SUPPORTED; - } - - assert(handle->handle != INVALID_HANDLE_VALUE); - - UV_REQ_INIT(req, UV_WRITE); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - req->ipc_header = 0; - req->event_handle = NULL; - req->wait_handle = INVALID_HANDLE_VALUE; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - if (handle->ipc) { - assert(!(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)); - ipc_frame.header.flags = 0; - - /* Use the IPC framing protocol. */ - if (send_handle) { - tcp_send_handle = (uv_tcp_t*)send_handle; - - if (handle->pipe.conn.ipc_pid == 0) { - handle->pipe.conn.ipc_pid = uv_current_pid(); - } - - err = uv_tcp_duplicate_socket(tcp_send_handle, handle->pipe.conn.ipc_pid, - &ipc_frame.socket_info_ex.socket_info); - if (err) { - return err; - } - - ipc_frame.socket_info_ex.delayed_error = tcp_send_handle->delayed_error; - - ipc_frame.header.flags |= UV_IPC_TCP_SERVER; - - if (tcp_send_handle->flags & UV_HANDLE_CONNECTION) { - ipc_frame.header.flags |= UV_IPC_TCP_CONNECTION; - } - } - - if (nbufs == 1) { - ipc_frame.header.flags |= UV_IPC_RAW_DATA; - ipc_frame.header.raw_data_length = bufs[0].len; - } - - /* - * Use the provided req if we're only doing a single write. - * If we're doing multiple writes, use ipc_header_write_req to do - * the first write, and then use the provided req for the second write. - */ - if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) { - ipc_header_req = req; - } else { - /* - * Try to use the preallocated write req if it's available. - * Otherwise allocate a new one. - */ - if (handle->pipe.conn.ipc_header_write_req.type != UV_WRITE) { - ipc_header_req = (uv_write_t*)&handle->pipe.conn.ipc_header_write_req; - } else { - ipc_header_req = (uv_write_t*)uv__malloc(sizeof(uv_write_t)); - if (!ipc_header_req) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - } - - UV_REQ_INIT(ipc_header_req, UV_WRITE); - ipc_header_req->handle = (uv_stream_t*) handle; - ipc_header_req->cb = NULL; - ipc_header_req->ipc_header = 1; - } - - /* Write the header or the whole frame. */ - memset(&ipc_header_req->u.io.overlapped, 0, - sizeof(ipc_header_req->u.io.overlapped)); - - /* Using overlapped IO, but wait for completion before returning. - This write is blocking because ipc_frame is on stack. */ - ipc_header_req->u.io.overlapped.hEvent = CreateEvent(NULL, 1, 0, NULL); - if (!ipc_header_req->u.io.overlapped.hEvent) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - - result = WriteFile(handle->handle, - &ipc_frame, - ipc_frame.header.flags & UV_IPC_TCP_SERVER ? - sizeof(ipc_frame) : sizeof(ipc_frame.header), - NULL, - &ipc_header_req->u.io.overlapped); - if (!result && GetLastError() != ERROR_IO_PENDING) { - err = GetLastError(); - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - return err; - } - - if (!result) { - /* Request not completed immediately. Wait for it.*/ - if (WaitForSingleObject(ipc_header_req->u.io.overlapped.hEvent, INFINITE) != - WAIT_OBJECT_0) { - err = GetLastError(); - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - return err; - } - } - ipc_header_req->u.io.queued_bytes = 0; - CloseHandle(ipc_header_req->u.io.overlapped.hEvent); - ipc_header_req->u.io.overlapped.hEvent = NULL; - - REGISTER_HANDLE_REQ(loop, handle, ipc_header_req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - - /* If we don't have any raw data to write - we're done. */ - if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) { - return 0; - } - } - - if ((handle->flags & - (UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) == - (UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) { - DWORD bytes; - result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, - &bytes, - NULL); - - if (!result) { - err = GetLastError(); - return err; - } else { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - } - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - POST_COMPLETION_FOR_REQ(loop, req); - return 0; - } else if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) { - req->write_buffer = bufs[0]; - uv_insert_non_overlapped_write_req(handle, req); - if (handle->stream.conn.write_reqs_pending == 0) { - uv_queue_non_overlapped_write(handle); - } - - /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; - handle->write_queue_size += req->u.io.queued_bytes; - } else if (handle->flags & UV_HANDLE_BLOCKING_WRITES) { - /* Using overlapped IO, but wait for completion before returning */ - req->u.io.overlapped.hEvent = CreateEvent(NULL, 1, 0, NULL); - if (!req->u.io.overlapped.hEvent) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - - result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, - NULL, - &req->u.io.overlapped); - - if (!result && GetLastError() != ERROR_IO_PENDING) { - err = GetLastError(); - CloseHandle(req->u.io.overlapped.hEvent); - return err; - } - - if (result) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - } else { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; - handle->write_queue_size += req->u.io.queued_bytes; - if (WaitForSingleObject(req->u.io.overlapped.hEvent, INFINITE) != - WAIT_OBJECT_0) { - err = GetLastError(); - CloseHandle(req->u.io.overlapped.hEvent); - return uv_translate_sys_error(err); - } - } - CloseHandle(req->u.io.overlapped.hEvent); - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - return 0; - } else { - result = WriteFile(handle->handle, - bufs[0].base, - bufs[0].len, - NULL, - &req->u.io.overlapped); - - if (!result && GetLastError() != ERROR_IO_PENDING) { - return GetLastError(); - } - - if (result) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - } else { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = bufs[0].len; - handle->write_queue_size += req->u.io.queued_bytes; - } - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - if (!RegisterWaitForSingleObject(&req->wait_handle, - req->u.io.overlapped.hEvent, post_completion_write_wait, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - return GetLastError(); - } - } - } - - REGISTER_HANDLE_REQ(loop, handle, req); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - - return 0; -} - - -int uv_pipe_write(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, NULL, cb); -} - - -int uv_pipe_write2(uv_loop_t* loop, - uv_write_t* req, - uv_pipe_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - if (!handle->ipc) { - return WSAEINVAL; - } - - return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, send_handle, cb); -} - - -static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle, - uv_buf_t buf) { - /* If there is an eof timer running, we don't need it any more, */ - /* so discard it. */ - eof_timer_destroy(handle); - - handle->flags &= ~UV_HANDLE_READABLE; - uv_read_stop((uv_stream_t*) handle); - - handle->read_cb((uv_stream_t*) handle, UV_EOF, &buf); -} - - -static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error, - uv_buf_t buf) { - /* If there is an eof timer running, we don't need it any more, */ - /* so discard it. */ - eof_timer_destroy(handle); - - uv_read_stop((uv_stream_t*) handle); - - handle->read_cb((uv_stream_t*)handle, uv_translate_sys_error(error), &buf); -} - - -static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle, - int error, uv_buf_t buf) { - if (error == ERROR_OPERATION_ABORTED) { - /* do nothing (equivalent to EINTR) */ - } - else if (error == ERROR_BROKEN_PIPE) { - uv_pipe_read_eof(loop, handle, buf); - } else { - uv_pipe_read_error(loop, handle, error, buf); - } -} - - -void uv__pipe_insert_pending_socket(uv_pipe_t* handle, - uv__ipc_socket_info_ex* info, - int tcp_connection) { - uv__ipc_queue_item_t* item; - - item = (uv__ipc_queue_item_t*) uv__malloc(sizeof(*item)); - if (item == NULL) - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - - memcpy(&item->socket_info_ex, info, sizeof(item->socket_info_ex)); - item->tcp_connection = tcp_connection; - QUEUE_INSERT_TAIL(&handle->pipe.conn.pending_ipc_info.queue, &item->member); - handle->pipe.conn.pending_ipc_info.queue_len++; -} - - -void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* req) { - DWORD bytes, avail; - uv_buf_t buf; - uv_ipc_frame_uv_stream ipc_frame; - - assert(handle->type == UV_NAMED_PIPE); - - handle->flags &= ~UV_HANDLE_READ_PENDING; - eof_timer_stop(handle); - - if (!REQ_SUCCESS(req)) { - /* An error occurred doing the 0-read. */ - if (handle->flags & UV_HANDLE_READING) { - uv_pipe_read_error_or_eof(loop, - handle, - GET_REQ_ERROR(req), - uv_null_buf_); - } - } else { - /* Do non-blocking reads until the buffer is empty */ - while (handle->flags & UV_HANDLE_READING) { - if (!PeekNamedPipe(handle->handle, - NULL, - 0, - NULL, - &avail, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_); - break; - } - - if (avail == 0) { - /* There is nothing to read after all. */ - break; - } - - if (handle->ipc) { - /* Use the IPC framing protocol to read the incoming data. */ - if (handle->pipe.conn.remaining_ipc_rawdata_bytes == 0) { - /* We're reading a new frame. First, read the header. */ - assert(avail >= sizeof(ipc_frame.header)); - - if (!ReadFile(handle->handle, - &ipc_frame.header, - sizeof(ipc_frame.header), - &bytes, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), - uv_null_buf_); - break; - } - - assert(bytes == sizeof(ipc_frame.header)); - assert(ipc_frame.header.flags <= (UV_IPC_TCP_SERVER | UV_IPC_RAW_DATA | - UV_IPC_TCP_CONNECTION)); - - if (ipc_frame.header.flags & UV_IPC_TCP_SERVER) { - assert(avail - sizeof(ipc_frame.header) >= - sizeof(ipc_frame.socket_info_ex)); - - /* Read the TCP socket info. */ - if (!ReadFile(handle->handle, - &ipc_frame.socket_info_ex, - sizeof(ipc_frame) - sizeof(ipc_frame.header), - &bytes, - NULL)) { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), - uv_null_buf_); - break; - } - - assert(bytes == sizeof(ipc_frame) - sizeof(ipc_frame.header)); - - /* Store the pending socket info. */ - uv__pipe_insert_pending_socket( - handle, - &ipc_frame.socket_info_ex, - ipc_frame.header.flags & UV_IPC_TCP_CONNECTION); - } - - if (ipc_frame.header.flags & UV_IPC_RAW_DATA) { - handle->pipe.conn.remaining_ipc_rawdata_bytes = - ipc_frame.header.raw_data_length; - continue; - } - } else { - avail = min(avail, (DWORD)handle->pipe.conn.remaining_ipc_rawdata_bytes); - } - } - - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, avail, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); - break; - } - assert(buf.base != NULL); - - if (ReadFile(handle->handle, - buf.base, - min(buf.len, avail), - &bytes, - NULL)) { - /* Successful read */ - if (handle->ipc) { - assert(handle->pipe.conn.remaining_ipc_rawdata_bytes >= bytes); - handle->pipe.conn.remaining_ipc_rawdata_bytes = - handle->pipe.conn.remaining_ipc_rawdata_bytes - bytes; - } - handle->read_cb((uv_stream_t*)handle, bytes, &buf); - - /* Read again only if bytes == buf.len */ - if (bytes <= buf.len) { - break; - } - } else { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf); - break; - } - } - - /* Post another 0-read if still reading and not closing. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_pipe_queue_read(loop, handle); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_write_t* req) { - int err; - - assert(handle->type == UV_NAMED_PIPE); - - assert(handle->write_queue_size >= req->u.io.queued_bytes); - handle->write_queue_size -= req->u.io.queued_bytes; - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (req->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(req->wait_handle); - req->wait_handle = INVALID_HANDLE_VALUE; - } - if (req->event_handle) { - CloseHandle(req->event_handle); - req->event_handle = NULL; - } - } - - if (req->ipc_header) { - if (req == &handle->pipe.conn.ipc_header_write_req) { - req->type = UV_UNKNOWN_REQ; - } else { - uv__free(req); - } - } else { - if (req->cb) { - err = GET_REQ_ERROR(req); - req->cb(req, uv_translate_sys_error(err)); - } - } - - handle->stream.conn.write_reqs_pending--; - - if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE && - handle->pipe.conn.non_overlapped_writes_tail) { - assert(handle->stream.conn.write_reqs_pending > 0); - uv_queue_non_overlapped_write(handle); - } - - if (handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_req_t* raw_req) { - uv_pipe_accept_t* req = (uv_pipe_accept_t*) raw_req; - - assert(handle->type == UV_NAMED_PIPE); - - if (handle->flags & UV__HANDLE_CLOSING) { - /* The req->pipeHandle should be freed already in uv_pipe_cleanup(). */ - assert(req->pipeHandle == INVALID_HANDLE_VALUE); - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (REQ_SUCCESS(req)) { - assert(req->pipeHandle != INVALID_HANDLE_VALUE); - req->next_pending = handle->pipe.serv.pending_accepts; - handle->pipe.serv.pending_accepts = req; - - if (handle->stream.serv.connection_cb) { - handle->stream.serv.connection_cb((uv_stream_t*)handle, 0); - } - } else { - if (req->pipeHandle != INVALID_HANDLE_VALUE) { - CloseHandle(req->pipeHandle); - req->pipeHandle = INVALID_HANDLE_VALUE; - } - if (!(handle->flags & UV__HANDLE_CLOSING)) { - uv_pipe_queue_accept(loop, handle, req, FALSE); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_connect_t* req) { - int err; - - assert(handle->type == UV_NAMED_PIPE); - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (req->cb) { - err = 0; - if (REQ_SUCCESS(req)) { - uv_pipe_connection_init(handle); - } else { - err = GET_REQ_ERROR(req); - } - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle, - uv_shutdown_t* req) { - assert(handle->type == UV_NAMED_PIPE); - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (handle->flags & UV_HANDLE_READABLE) { - /* Initialize and optionally start the eof timer. Only do this if the */ - /* pipe is readable and we haven't seen EOF come in ourselves. */ - eof_timer_init(handle); - - /* If reading start the timer right now. */ - /* Otherwise uv_pipe_queue_read will start it. */ - if (handle->flags & UV_HANDLE_READ_PENDING) { - eof_timer_start(handle); - } - - } else { - /* This pipe is not readable. We can just close it to let the other end */ - /* know that we're done writing. */ - close_pipe(handle); - } - - if (req->cb) { - req->cb(req, 0); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -static void eof_timer_init(uv_pipe_t* pipe) { - int r; - - assert(pipe->pipe.conn.eof_timer == NULL); - assert(pipe->flags & UV_HANDLE_CONNECTION); - - pipe->pipe.conn.eof_timer = (uv_timer_t*) uv__malloc(sizeof *pipe->pipe.conn.eof_timer); - - r = uv_timer_init(pipe->loop, pipe->pipe.conn.eof_timer); - assert(r == 0); /* timers can't fail */ - pipe->pipe.conn.eof_timer->data = pipe; - uv_unref((uv_handle_t*) pipe->pipe.conn.eof_timer); -} - - -static void eof_timer_start(uv_pipe_t* pipe) { - assert(pipe->flags & UV_HANDLE_CONNECTION); - - if (pipe->pipe.conn.eof_timer != NULL) { - uv_timer_start(pipe->pipe.conn.eof_timer, eof_timer_cb, eof_timeout, 0); - } -} - - -static void eof_timer_stop(uv_pipe_t* pipe) { - assert(pipe->flags & UV_HANDLE_CONNECTION); - - if (pipe->pipe.conn.eof_timer != NULL) { - uv_timer_stop(pipe->pipe.conn.eof_timer); - } -} - - -static void eof_timer_cb(uv_timer_t* timer) { - uv_pipe_t* pipe = (uv_pipe_t*) timer->data; - uv_loop_t* loop = timer->loop; - - assert(pipe->type == UV_NAMED_PIPE); - - /* This should always be true, since we start the timer only */ - /* in uv_pipe_queue_read after successfully calling ReadFile, */ - /* or in uv_process_pipe_shutdown_req if a read is pending, */ - /* and we always immediately stop the timer in */ - /* uv_process_pipe_read_req. */ - assert(pipe->flags & UV_HANDLE_READ_PENDING); - - /* If there are many packets coming off the iocp then the timer callback */ - /* may be called before the read request is coming off the queue. */ - /* Therefore we check here if the read request has completed but will */ - /* be processed later. */ - if ((pipe->flags & UV_HANDLE_READ_PENDING) && - HasOverlappedIoCompleted(&pipe->read_req.u.io.overlapped)) { - return; - } - - /* Force both ends off the pipe. */ - close_pipe(pipe); - - /* Stop reading, so the pending read that is going to fail will */ - /* not be reported to the user. */ - uv_read_stop((uv_stream_t*) pipe); - - /* Report the eof and update flags. This will get reported even if the */ - /* user stopped reading in the meantime. TODO: is that okay? */ - uv_pipe_read_eof(loop, pipe, uv_null_buf_); -} - - -static void eof_timer_destroy(uv_pipe_t* pipe) { - assert(pipe->flags & UV_HANDLE_CONNECTION); - - if (pipe->pipe.conn.eof_timer) { - uv_close((uv_handle_t*) pipe->pipe.conn.eof_timer, eof_timer_close_cb); - pipe->pipe.conn.eof_timer = NULL; - } -} - - -static void eof_timer_close_cb(uv_handle_t* handle) { - assert(handle->type == UV_TIMER); - uv__free(handle); -} - - -int uv_pipe_open(uv_pipe_t* pipe, uv_file file) { - HANDLE os_handle = uv__get_osfhandle(file); - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_ACCESS_INFORMATION access; - DWORD duplex_flags = 0; - - if (os_handle == INVALID_HANDLE_VALUE) - return UV_EBADF; - - /* In order to avoid closing a stdio file descriptor 0-2, duplicate the - * underlying OS handle and forget about the original fd. - * We could also opt to use the original OS handle and just never close it, - * but then there would be no reliable way to cancel pending read operations - * upon close. - */ - if (file <= 2) { - if (!DuplicateHandle(INVALID_HANDLE_VALUE, - os_handle, - INVALID_HANDLE_VALUE, - &os_handle, - 0, - FALSE, - DUPLICATE_SAME_ACCESS)) - return uv_translate_sys_error(GetLastError()); - file = -1; - } - - /* Determine what kind of permissions we have on this handle. - * Cygwin opens the pipe in message mode, but we can support it, - * just query the access flags and set the stream flags accordingly. - */ - nt_status = pNtQueryInformationFile(os_handle, - &io_status, - &access, - sizeof(access), - FileAccessInformation); - if (nt_status != STATUS_SUCCESS) - return UV_EINVAL; - - if (pipe->ipc) { - if (!(access.AccessFlags & FILE_WRITE_DATA) || - !(access.AccessFlags & FILE_READ_DATA)) { - return UV_EINVAL; - } - } - - if (access.AccessFlags & FILE_WRITE_DATA) - duplex_flags |= UV_HANDLE_WRITABLE; - if (access.AccessFlags & FILE_READ_DATA) - duplex_flags |= UV_HANDLE_READABLE; - - if (os_handle == INVALID_HANDLE_VALUE || - uv_set_pipe_handle(pipe->loop, - pipe, - os_handle, - file, - duplex_flags) == -1) { - return UV_EINVAL; - } - - uv_pipe_connection_init(pipe); - - if (pipe->ipc) { - assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)); - pipe->pipe.conn.ipc_pid = uv_parent_pid(); - assert(pipe->pipe.conn.ipc_pid != -1); - } - return 0; -} - - -static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) { - NTSTATUS nt_status; - IO_STATUS_BLOCK io_status; - FILE_NAME_INFORMATION tmp_name_info; - FILE_NAME_INFORMATION* name_info; - WCHAR* name_buf; - unsigned int addrlen; - unsigned int name_size; - unsigned int name_len; - int err; - - name_info = NULL; - - if (handle->handle == INVALID_HANDLE_VALUE) { - *size = 0; - return UV_EINVAL; - } - - uv__pipe_pause_read((uv_pipe_t*)handle); /* cast away const warning */ - - nt_status = pNtQueryInformationFile(handle->handle, - &io_status, - &tmp_name_info, - sizeof tmp_name_info, - FileNameInformation); - if (nt_status == STATUS_BUFFER_OVERFLOW) { - name_size = sizeof(*name_info) + tmp_name_info.FileNameLength; - name_info = uv__malloc(name_size); - if (!name_info) { - *size = 0; - err = UV_ENOMEM; - goto cleanup; - } - - nt_status = pNtQueryInformationFile(handle->handle, - &io_status, - name_info, - name_size, - FileNameInformation); - } - - if (nt_status != STATUS_SUCCESS) { - *size = 0; - err = uv_translate_sys_error(pRtlNtStatusToDosError(nt_status)); - goto error; - } - - if (!name_info) { - /* the struct on stack was used */ - name_buf = tmp_name_info.FileName; - name_len = tmp_name_info.FileNameLength; - } else { - name_buf = name_info->FileName; - name_len = name_info->FileNameLength; - } - - if (name_len == 0) { - *size = 0; - err = 0; - goto error; - } - - name_len /= sizeof(WCHAR); - - /* check how much space we need */ - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - NULL, - 0, - NULL, - NULL); - if (!addrlen) { - *size = 0; - err = uv_translate_sys_error(GetLastError()); - goto error; - } else if (pipe_prefix_len + addrlen >= *size) { - /* "\\\\.\\pipe" + name */ - *size = pipe_prefix_len + addrlen + 1; - err = UV_ENOBUFS; - goto error; - } - - memcpy(buffer, pipe_prefix, pipe_prefix_len); - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - buffer+pipe_prefix_len, - *size-pipe_prefix_len, - NULL, - NULL); - if (!addrlen) { - *size = 0; - err = uv_translate_sys_error(GetLastError()); - goto error; - } - - addrlen += pipe_prefix_len; - *size = addrlen; - buffer[addrlen] = '\0'; - - err = 0; - -error: - uv__free(name_info); - -cleanup: - uv__pipe_unpause_read((uv_pipe_t*)handle); /* cast away const warning */ - return err; -} - - -int uv_pipe_pending_count(uv_pipe_t* handle) { - if (!handle->ipc) - return 0; - return handle->pipe.conn.pending_ipc_info.queue_len; -} - - -int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) { - if (handle->flags & UV_HANDLE_BOUND) - return uv__pipe_getname(handle, buffer, size); - - if (handle->flags & UV_HANDLE_CONNECTION || - handle->handle != INVALID_HANDLE_VALUE) { - *size = 0; - return 0; - } - - return UV_EBADF; -} - - -int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) { - /* emulate unix behaviour */ - if (handle->flags & UV_HANDLE_BOUND) - return UV_ENOTCONN; - - if (handle->handle != INVALID_HANDLE_VALUE) - return uv__pipe_getname(handle, buffer, size); - - return UV_EBADF; -} - - -uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) { - if (!handle->ipc) - return UV_UNKNOWN_HANDLE; - if (handle->pipe.conn.pending_ipc_info.queue_len == 0) - return UV_UNKNOWN_HANDLE; - else - return UV_TCP; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/poll.c b/lib/ESPiLight/pilight/libs/libuv/win/poll.c deleted file mode 100644 index a648ba7..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/poll.c +++ /dev/null @@ -1,644 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -static const GUID uv_msafd_provider_ids[UV_MSAFD_PROVIDER_COUNT] = { - {0xe70f1aa0, 0xab8b, 0x11cf, - {0x8c, 0xa3, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}, - {0xf9eab0c0, 0x26d4, 0x11d0, - {0xbb, 0xbf, 0x00, 0xaa, 0x00, 0x6c, 0x34, 0xe4}}, - {0x9fc48064, 0x7298, 0x43e4, - {0xb7, 0xbd, 0x18, 0x1f, 0x20, 0x89, 0x79, 0x2a}} -}; - -typedef struct uv_single_fd_set_s { - unsigned int fd_count; - SOCKET fd_array[1]; -} uv_single_fd_set_t; - - -static OVERLAPPED overlapped_dummy_; -static uv_once_t overlapped_dummy_init_guard_ = UV_ONCE_INIT; - -static AFD_POLL_INFO afd_poll_info_dummy_; - - -static void uv__init_overlapped_dummy(void) { - HANDLE event; - - event = CreateEvent(NULL, TRUE, TRUE, NULL); - if (event == NULL) - uv_fatal_error(GetLastError(), "CreateEvent"); - - memset(&overlapped_dummy_, 0, sizeof overlapped_dummy_); - overlapped_dummy_.hEvent = (HANDLE) ((uintptr_t) event | 1); -} - - -static OVERLAPPED* uv__get_overlapped_dummy(void) { - uv_once(&overlapped_dummy_init_guard_, uv__init_overlapped_dummy); - return &overlapped_dummy_; -} - - -static AFD_POLL_INFO* uv__get_afd_poll_info_dummy(void) { - return &afd_poll_info_dummy_; -} - - -static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { - uv_req_t* req; - AFD_POLL_INFO* afd_poll_info; - DWORD result; - - /* Find a yet unsubmitted req to submit. */ - if (handle->submitted_events_1 == 0) { - req = &handle->poll_req_1; - afd_poll_info = &handle->afd_poll_info_1; - handle->submitted_events_1 = handle->events; - handle->mask_events_1 = 0; - handle->mask_events_2 = handle->events; - } else if (handle->submitted_events_2 == 0) { - req = &handle->poll_req_2; - afd_poll_info = &handle->afd_poll_info_2; - handle->submitted_events_2 = handle->events; - handle->mask_events_1 = handle->events; - handle->mask_events_2 = 0; - } else { - /* Just wait until there's an unsubmitted req. */ - /* This will happen almost immediately as one of the 2 outstanding */ - /* requests is about to return. When this happens, */ - /* uv__fast_poll_process_poll_req will be called, and the pending */ - /* events, if needed, will be processed in a subsequent request. */ - return; - } - - /* Setting Exclusive to TRUE makes the other poll request return if there */ - /* is any. */ - afd_poll_info->Exclusive = TRUE; - afd_poll_info->NumberOfHandles = 1; - afd_poll_info->Timeout.QuadPart = INT64_MAX; - afd_poll_info->Handles[0].Handle = (HANDLE) handle->socket; - afd_poll_info->Handles[0].Status = 0; - afd_poll_info->Handles[0].Events = 0; - - if (handle->events & UV_READABLE) { - afd_poll_info->Handles[0].Events |= AFD_POLL_RECEIVE | - AFD_POLL_DISCONNECT | AFD_POLL_ACCEPT | AFD_POLL_ABORT; - } else { - if (handle->events & UV_DISCONNECT) { - afd_poll_info->Handles[0].Events |= AFD_POLL_DISCONNECT; - } - } - if (handle->events & UV_WRITABLE) { - afd_poll_info->Handles[0].Events |= AFD_POLL_SEND | AFD_POLL_CONNECT_FAIL; - } - - memset(&req->u.io.overlapped, 0, sizeof req->u.io.overlapped); - - result = uv_msafd_poll((SOCKET) handle->peer_socket, - afd_poll_info, - afd_poll_info, - &req->u.io.overlapped); - if (result != 0 && WSAGetLastError() != WSA_IO_PENDING) { - /* Queue this req, reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); - } -} - - -static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) { - AFD_POLL_INFO afd_poll_info; - DWORD result; - - afd_poll_info.Exclusive = TRUE; - afd_poll_info.NumberOfHandles = 1; - afd_poll_info.Timeout.QuadPart = INT64_MAX; - afd_poll_info.Handles[0].Handle = (HANDLE) handle->socket; - afd_poll_info.Handles[0].Status = 0; - afd_poll_info.Handles[0].Events = AFD_POLL_ALL; - - result = uv_msafd_poll(handle->socket, - &afd_poll_info, - uv__get_afd_poll_info_dummy(), - uv__get_overlapped_dummy()); - - if (result == SOCKET_ERROR) { - DWORD error = WSAGetLastError(); - if (error != WSA_IO_PENDING) - return error; - } - - return 0; -} - - -static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, - uv_req_t* req) { - unsigned char mask_events; - AFD_POLL_INFO* afd_poll_info; - - if (req == &handle->poll_req_1) { - afd_poll_info = &handle->afd_poll_info_1; - handle->submitted_events_1 = 0; - mask_events = handle->mask_events_1; - } else if (req == &handle->poll_req_2) { - afd_poll_info = &handle->afd_poll_info_2; - handle->submitted_events_2 = 0; - mask_events = handle->mask_events_2; - } else { - assert(0); - return; - } - - /* Report an error unless the select was just interrupted. */ - if (!REQ_SUCCESS(req)) { - DWORD error = GET_REQ_SOCK_ERROR(req); - if (error != WSAEINTR && handle->events != 0) { - handle->events = 0; /* Stop the watcher */ - handle->poll_cb(handle, uv_translate_sys_error(error), 0); - } - - } else if (afd_poll_info->NumberOfHandles >= 1) { - unsigned char events = 0; - - if ((afd_poll_info->Handles[0].Events & (AFD_POLL_RECEIVE | - AFD_POLL_DISCONNECT | AFD_POLL_ACCEPT | AFD_POLL_ABORT)) != 0) { - events |= UV_READABLE; - if ((afd_poll_info->Handles[0].Events & AFD_POLL_DISCONNECT) != 0) { - events |= UV_DISCONNECT; - } - } - if ((afd_poll_info->Handles[0].Events & (AFD_POLL_SEND | - AFD_POLL_CONNECT_FAIL)) != 0) { - events |= UV_WRITABLE; - } - - events &= handle->events & ~mask_events; - - if (afd_poll_info->Handles[0].Events & AFD_POLL_LOCAL_CLOSE) { - /* Stop polling. */ - handle->events = 0; - if (uv__is_active(handle)) - uv__handle_stop(handle); - } - - if (events != 0) { - handle->poll_cb(handle, 0, events); - } - } - - if ((handle->events & ~(handle->submitted_events_1 | - handle->submitted_events_2)) != 0) { - uv__fast_poll_submit_poll_req(loop, handle); - } else if ((handle->flags & UV__HANDLE_CLOSING) && - handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) { - assert(handle->type == UV_POLL); - assert(!(handle->flags & UV__HANDLE_CLOSING)); - assert((events & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0); - - handle->events = events; - - if (handle->events != 0) { - uv__handle_start(handle); - } else { - uv__handle_stop(handle); - } - - if ((handle->events & ~(handle->submitted_events_1 | - handle->submitted_events_2)) != 0) { - uv__fast_poll_submit_poll_req(handle->loop, handle); - } - - return 0; -} - - -static int uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) { - handle->events = 0; - uv__handle_closing(handle); - - if (handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - return 0; - } else { - /* Cancel outstanding poll requests by executing another, unique poll */ - /* request that forces the outstanding ones to return. */ - return uv__fast_poll_cancel_poll_req(loop, handle); - } -} - - -static SOCKET uv__fast_poll_create_peer_socket(HANDLE iocp, - WSAPROTOCOL_INFOW* protocol_info) { - SOCKET sock = 0; - - sock = WSASocketW(protocol_info->iAddressFamily, - protocol_info->iSocketType, - protocol_info->iProtocol, - protocol_info, - 0, - WSA_FLAG_OVERLAPPED); - if (sock == INVALID_SOCKET) { - return INVALID_SOCKET; - } - - if (!SetHandleInformation((HANDLE) sock, HANDLE_FLAG_INHERIT, 0)) { - goto error; - }; - - if (CreateIoCompletionPort((HANDLE) sock, - iocp, - (ULONG_PTR) sock, - 0) == NULL) { - goto error; - } - - return sock; - - error: - closesocket(sock); - return INVALID_SOCKET; -} - - -static SOCKET uv__fast_poll_get_peer_socket(uv_loop_t* loop, - WSAPROTOCOL_INFOW* protocol_info) { - int index, i; - SOCKET peer_socket; - - index = -1; - for (i = 0; (size_t) i < ARRAY_SIZE(uv_msafd_provider_ids); i++) { - if (memcmp((void*) &protocol_info->ProviderId, - (void*) &uv_msafd_provider_ids[i], - sizeof protocol_info->ProviderId) == 0) { - index = i; - } - } - - /* Check if the protocol uses an msafd socket. */ - if (index < 0) { - return INVALID_SOCKET; - } - - /* If we didn't (try) to create a peer socket yet, try to make one. Don't */ - /* try again if the peer socket creation failed earlier for the same */ - /* protocol. */ - peer_socket = loop->poll_peer_sockets[index]; - if (peer_socket == 0) { - peer_socket = uv__fast_poll_create_peer_socket(loop->iocp, protocol_info); - loop->poll_peer_sockets[index] = peer_socket; - } - - return peer_socket; -} - - -static DWORD WINAPI uv__slow_poll_thread_proc(void* arg) { - uv_req_t* req = (uv_req_t*) arg; - uv_poll_t* handle = (uv_poll_t*) req->data; - unsigned char reported_events; - int r; - uv_single_fd_set_t rfds, wfds, efds; - struct timeval timeout; - - assert(handle->type == UV_POLL); - assert(req->type == UV_POLL_REQ); - - if (handle->events & UV_READABLE) { - rfds.fd_count = 1; - rfds.fd_array[0] = handle->socket; - } else { - rfds.fd_count = 0; - } - - if (handle->events & UV_WRITABLE) { - wfds.fd_count = 1; - wfds.fd_array[0] = handle->socket; - efds.fd_count = 1; - efds.fd_array[0] = handle->socket; - } else { - wfds.fd_count = 0; - efds.fd_count = 0; - } - - /* Make the select() time out after 3 minutes. If select() hangs because */ - /* the user closed the socket, we will at least not hang indefinitely. */ - timeout.tv_sec = 3 * 60; - timeout.tv_usec = 0; - - r = select(1, (fd_set*) &rfds, (fd_set*) &wfds, (fd_set*) &efds, &timeout); - if (r == SOCKET_ERROR) { - /* Queue this req, reporting an error. */ - SET_REQ_ERROR(&handle->poll_req_1, WSAGetLastError()); - POST_COMPLETION_FOR_REQ(handle->loop, req); - return 0; - } - - reported_events = 0; - - if (r > 0) { - if (rfds.fd_count > 0) { - assert(rfds.fd_count == 1); - assert(rfds.fd_array[0] == handle->socket); - reported_events |= UV_READABLE; - } - - if (wfds.fd_count > 0) { - assert(wfds.fd_count == 1); - assert(wfds.fd_array[0] == handle->socket); - reported_events |= UV_WRITABLE; - } else if (efds.fd_count > 0) { - assert(efds.fd_count == 1); - assert(efds.fd_array[0] == handle->socket); - reported_events |= UV_WRITABLE; - } - } - - SET_REQ_SUCCESS(req); - req->u.io.overlapped.InternalHigh = (DWORD) reported_events; - POST_COMPLETION_FOR_REQ(handle->loop, req); - - return 0; -} - - -static void uv__slow_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { - uv_req_t* req; - - /* Find a yet unsubmitted req to submit. */ - if (handle->submitted_events_1 == 0) { - req = &handle->poll_req_1; - handle->submitted_events_1 = handle->events; - handle->mask_events_1 = 0; - handle->mask_events_2 = handle->events; - } else if (handle->submitted_events_2 == 0) { - req = &handle->poll_req_2; - handle->submitted_events_2 = handle->events; - handle->mask_events_1 = handle->events; - handle->mask_events_2 = 0; - } else { - assert(0); - return; - } - - if (!QueueUserWorkItem(uv__slow_poll_thread_proc, - (void*) req, - WT_EXECUTELONGFUNCTION)) { - /* Make this req pending, reporting an error. */ - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, req); - } -} - - - -static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, - uv_req_t* req) { - unsigned char mask_events; - int err; - - if (req == &handle->poll_req_1) { - handle->submitted_events_1 = 0; - mask_events = handle->mask_events_1; - } else if (req == &handle->poll_req_2) { - handle->submitted_events_2 = 0; - mask_events = handle->mask_events_2; - } else { - assert(0); - return; - } - - if (!REQ_SUCCESS(req)) { - /* Error. */ - if (handle->events != 0) { - err = GET_REQ_ERROR(req); - handle->events = 0; /* Stop the watcher */ - handle->poll_cb(handle, uv_translate_sys_error(err), 0); - } - } else { - /* Got some events. */ - int events = req->u.io.overlapped.InternalHigh & handle->events & ~mask_events; - if (events != 0) { - handle->poll_cb(handle, 0, events); - } - } - - if ((handle->events & ~(handle->submitted_events_1 | - handle->submitted_events_2)) != 0) { - uv__slow_poll_submit_poll_req(loop, handle); - } else if ((handle->flags & UV__HANDLE_CLOSING) && - handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -static int uv__slow_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) { - assert(handle->type == UV_POLL); - assert(!(handle->flags & UV__HANDLE_CLOSING)); - assert((events & ~(UV_READABLE | UV_WRITABLE)) == 0); - - handle->events = events; - - if (handle->events != 0) { - uv__handle_start(handle); - } else { - uv__handle_stop(handle); - } - - if ((handle->events & - ~(handle->submitted_events_1 | handle->submitted_events_2)) != 0) { - uv__slow_poll_submit_poll_req(handle->loop, handle); - } - - return 0; -} - - -static int uv__slow_poll_close(uv_loop_t* loop, uv_poll_t* handle) { - handle->events = 0; - uv__handle_closing(handle); - - if (handle->submitted_events_1 == 0 && - handle->submitted_events_2 == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } - - return 0; -} - - -int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { - return uv_poll_init_socket(loop, handle, (SOCKET) uv__get_osfhandle(fd)); -} - - -int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, - uv_os_sock_t socket) { - WSAPROTOCOL_INFOW protocol_info; - int len; - SOCKET peer_socket, base_socket; - DWORD bytes; - DWORD yes = 1; - - /* Set the socket to nonblocking mode */ - if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) - return uv_translate_sys_error(WSAGetLastError()); - - /* Try to obtain a base handle for the socket. This increases this chances */ - /* that we find an AFD handle and are able to use the fast poll mechanism. */ - /* This will always fail on windows XP/2k3, since they don't support the */ - /* SIO_BASE_HANDLE ioctl. */ -#ifndef NDEBUG - base_socket = INVALID_SOCKET; -#endif - - if (WSAIoctl(socket, - SIO_BASE_HANDLE, - NULL, - 0, - &base_socket, - sizeof base_socket, - &bytes, - NULL, - NULL) == 0) { - assert(base_socket != 0 && base_socket != INVALID_SOCKET); - socket = base_socket; - } - - uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL); - handle->socket = socket; - handle->events = 0; - - /* Obtain protocol information about the socket. */ - len = sizeof protocol_info; - if (getsockopt(socket, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &len) != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - /* Get the peer socket that is needed to enable fast poll. If the returned */ - /* value is NULL, the protocol is not implemented by MSAFD and we'll have */ - /* to use slow mode. */ - peer_socket = uv__fast_poll_get_peer_socket(loop, &protocol_info); - - if (peer_socket != INVALID_SOCKET) { - /* Initialize fast poll specific fields. */ - handle->peer_socket = peer_socket; - } else { - /* Initialize slow poll specific fields. */ - handle->flags |= UV_HANDLE_POLL_SLOW; - } - - /* Initialize 2 poll reqs. */ - handle->submitted_events_1 = 0; - UV_REQ_INIT(&handle->poll_req_1, UV_POLL_REQ); - handle->poll_req_1.data = handle; - - handle->submitted_events_2 = 0; - UV_REQ_INIT(&handle->poll_req_2, UV_POLL_REQ); - handle->poll_req_2.data = handle; - - return 0; -} - - -int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) { - int err; - - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - err = uv__fast_poll_set(handle->loop, handle, events); - } else { - err = uv__slow_poll_set(handle->loop, handle, events); - } - - if (err) { - return uv_translate_sys_error(err); - } - - handle->poll_cb = cb; - - return 0; -} - - -int uv_poll_stop(uv_poll_t* handle) { - int err; - - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - err = uv__fast_poll_set(handle->loop, handle, 0); - } else { - err = uv__slow_poll_set(handle->loop, handle, 0); - } - - return uv_translate_sys_error(err); -} - - -void uv_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, uv_req_t* req) { - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - uv__fast_poll_process_poll_req(loop, handle, req); - } else { - uv__slow_poll_process_poll_req(loop, handle, req); - } -} - - -int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle) { - if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { - return uv__fast_poll_close(loop, handle); - } else { - return uv__slow_poll_close(loop, handle); - } -} - - -void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - assert(handle->submitted_events_1 == 0); - assert(handle->submitted_events_2 == 0); - - uv__handle_close(handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/process-stdio.c b/lib/ESPiLight/pilight/libs/libuv/win/process-stdio.c deleted file mode 100644 index 032e309..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/process-stdio.c +++ /dev/null @@ -1,511 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" - - -/* - * The `child_stdio_buffer` buffer has the following layout: - * int number_of_fds - * unsigned char crt_flags[number_of_fds] - * HANDLE os_handle[number_of_fds] - */ -#define CHILD_STDIO_SIZE(count) \ - (sizeof(int) + \ - sizeof(unsigned char) * (count) + \ - sizeof(uintptr_t) * (count)) - -#define CHILD_STDIO_COUNT(buffer) \ - *((unsigned int*) (buffer)) - -#define CHILD_STDIO_CRT_FLAGS(buffer, fd) \ - *((unsigned char*) (buffer) + sizeof(int) + fd) - -#define CHILD_STDIO_HANDLE(buffer, fd) \ - *((HANDLE*) ((unsigned char*) (buffer) + \ - sizeof(int) + \ - sizeof(unsigned char) * \ - CHILD_STDIO_COUNT((buffer)) + \ - sizeof(HANDLE) * (fd))) - - -/* CRT file descriptor mode flags */ -#define FOPEN 0x01 -#define FEOFLAG 0x02 -#define FCRLF 0x04 -#define FPIPE 0x08 -#define FNOINHERIT 0x10 -#define FAPPEND 0x20 -#define FDEV 0x40 -#define FTEXT 0x80 - - -/* - * Clear the HANDLE_FLAG_INHERIT flag from all HANDLEs that were inherited - * the parent process. Don't check for errors - the stdio handles may not be - * valid, or may be closed already. There is no guarantee that this function - * does a perfect job. - */ -void uv_disable_stdio_inheritance(void) { - HANDLE handle; - STARTUPINFOW si; - - /* Make the windows stdio handles non-inheritable. */ - handle = GetStdHandle(STD_INPUT_HANDLE); - if (handle != NULL && handle != INVALID_HANDLE_VALUE) - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - - handle = GetStdHandle(STD_OUTPUT_HANDLE); - if (handle != NULL && handle != INVALID_HANDLE_VALUE) - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - - handle = GetStdHandle(STD_ERROR_HANDLE); - if (handle != NULL && handle != INVALID_HANDLE_VALUE) - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - - /* Make inherited CRT FDs non-inheritable. */ - GetStartupInfoW(&si); - if (uv__stdio_verify(si.lpReserved2, si.cbReserved2)) - uv__stdio_noinherit(si.lpReserved2); -} - - -static int uv__create_stdio_pipe_pair(uv_loop_t* loop, - uv_pipe_t* server_pipe, HANDLE* child_pipe_ptr, unsigned int flags) { - char pipe_name[64]; - SECURITY_ATTRIBUTES sa; - DWORD server_access = 0; - DWORD client_access = 0; - HANDLE child_pipe = INVALID_HANDLE_VALUE; - int err; - - if (flags & UV_READABLE_PIPE) { - /* The server needs inbound access too, otherwise CreateNamedPipe() */ - /* won't give us the FILE_READ_ATTRIBUTES permission. We need that to */ - /* probe the state of the write buffer when we're trying to shutdown */ - /* the pipe. */ - server_access |= PIPE_ACCESS_OUTBOUND | PIPE_ACCESS_INBOUND; - client_access |= GENERIC_READ | FILE_WRITE_ATTRIBUTES; - } - if (flags & UV_WRITABLE_PIPE) { - server_access |= PIPE_ACCESS_INBOUND; - client_access |= GENERIC_WRITE | FILE_READ_ATTRIBUTES; - } - - /* Create server pipe handle. */ - err = uv_stdio_pipe_server(loop, - server_pipe, - server_access, - pipe_name, - sizeof(pipe_name)); - if (err) - goto error; - - /* Create child pipe handle. */ - sa.nLength = sizeof sa; - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - - child_pipe = CreateFileA(pipe_name, - client_access, - 0, - &sa, - OPEN_EXISTING, - server_pipe->ipc ? FILE_FLAG_OVERLAPPED : 0, - NULL); - if (child_pipe == INVALID_HANDLE_VALUE) { - err = GetLastError(); - goto error; - } - -#ifndef NDEBUG - /* Validate that the pipe was opened in the right mode. */ - { - DWORD mode; - BOOL r = GetNamedPipeHandleState(child_pipe, - &mode, - NULL, - NULL, - NULL, - NULL, - 0); - assert(r == TRUE); - assert(mode == (PIPE_READMODE_BYTE | PIPE_WAIT)); - } -#endif - - /* Do a blocking ConnectNamedPipe. This should not block because we have */ - /* both ends of the pipe created. */ - if (!ConnectNamedPipe(server_pipe->handle, NULL)) { - if (GetLastError() != ERROR_PIPE_CONNECTED) { - err = GetLastError(); - goto error; - } - } - - /* The server end is now readable and/or writable. */ - if (flags & UV_READABLE_PIPE) - server_pipe->flags |= UV_HANDLE_WRITABLE; - if (flags & UV_WRITABLE_PIPE) - server_pipe->flags |= UV_HANDLE_READABLE; - - *child_pipe_ptr = child_pipe; - return 0; - - error: - if (server_pipe->handle != INVALID_HANDLE_VALUE) { - uv_pipe_cleanup(loop, server_pipe); - } - - if (child_pipe != INVALID_HANDLE_VALUE) { - CloseHandle(child_pipe); - } - - return err; -} - - -static int uv__duplicate_handle(uv_loop_t* loop, HANDLE handle, HANDLE* dup) { - HANDLE current_process; - - - /* _get_osfhandle will sometimes return -2 in case of an error. This seems */ - /* to happen when fd <= 2 and the process' corresponding stdio handle is */ - /* set to NULL. Unfortunately DuplicateHandle will happily duplicate */ - /* (HANDLE) -2, so this situation goes unnoticed until someone tries to */ - /* use the duplicate. Therefore we filter out known-invalid handles here. */ - if (handle == INVALID_HANDLE_VALUE || - handle == NULL || - handle == (HANDLE) -2) { - *dup = INVALID_HANDLE_VALUE; - return ERROR_INVALID_HANDLE; - } - - current_process = GetCurrentProcess(); - - if (!DuplicateHandle(current_process, - handle, - current_process, - dup, - 0, - TRUE, - DUPLICATE_SAME_ACCESS)) { - *dup = INVALID_HANDLE_VALUE; - return GetLastError(); - } - - return 0; -} - - -static int uv__duplicate_fd(uv_loop_t* loop, int fd, HANDLE* dup) { - HANDLE handle; - - if (fd == -1) { - *dup = INVALID_HANDLE_VALUE; - return ERROR_INVALID_HANDLE; - } - - handle = uv__get_osfhandle(fd); - return uv__duplicate_handle(loop, handle, dup); -} - - -int uv__create_nul_handle(HANDLE* handle_ptr, - DWORD access) { - HANDLE handle; - SECURITY_ATTRIBUTES sa; - - sa.nLength = sizeof sa; - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - - handle = CreateFileW(L"NUL", - access, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sa, - OPEN_EXISTING, - 0, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - return GetLastError(); - } - - *handle_ptr = handle; - return 0; -} - - -int uv__stdio_create(uv_loop_t* loop, - const uv_process_options_t* options, - BYTE** buffer_ptr) { - BYTE* buffer; - int count, i; - int err; - - count = options->stdio_count; - - if (count < 0 || count > 255) { - /* Only support FDs 0-255 */ - return ERROR_NOT_SUPPORTED; - } else if (count < 3) { - /* There should always be at least 3 stdio handles. */ - count = 3; - } - - /* Allocate the child stdio buffer */ - buffer = (BYTE*) uv__malloc(CHILD_STDIO_SIZE(count)); - if (buffer == NULL) { - return ERROR_OUTOFMEMORY; - } - - /* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can */ - /* clean up on failure. */ - CHILD_STDIO_COUNT(buffer) = count; - for (i = 0; i < count; i++) { - CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; - CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE; - } - - for (i = 0; i < count; i++) { - uv_stdio_container_t fdopt; - if (i < options->stdio_count) { - fdopt = options->stdio[i]; - } else { - fdopt.flags = UV_IGNORE; - } - - switch (fdopt.flags & (UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD | - UV_INHERIT_STREAM)) { - case UV_IGNORE: - /* Starting a process with no stdin/stout/stderr can confuse it. */ - /* So no matter what the user specified, we make sure the first */ - /* three FDs are always open in their typical modes, e.g. stdin */ - /* be readable and stdout/err should be writable. For FDs > 2, don't */ - /* do anything - all handles in the stdio buffer are initialized with */ - /* INVALID_HANDLE_VALUE, which should be okay. */ - if (i <= 2) { - DWORD access = (i == 0) ? FILE_GENERIC_READ : - FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES; - - err = uv__create_nul_handle(&CHILD_STDIO_HANDLE(buffer, i), - access); - if (err) - goto error; - - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FDEV; - } - break; - - case UV_CREATE_PIPE: { - /* Create a pair of two connected pipe ends; one end is turned into */ - /* an uv_pipe_t for use by the parent. The other one is given to */ - /* the child. */ - uv_pipe_t* parent_pipe = (uv_pipe_t*) fdopt.data.stream; - HANDLE child_pipe = INVALID_HANDLE_VALUE; - - /* Create a new, connected pipe pair. stdio[i].stream should point */ - /* to an uninitialized, but not connected pipe handle. */ - assert(fdopt.data.stream->type == UV_NAMED_PIPE); - assert(!(fdopt.data.stream->flags & UV_HANDLE_CONNECTION)); - assert(!(fdopt.data.stream->flags & UV_HANDLE_PIPESERVER)); - - err = uv__create_stdio_pipe_pair(loop, - parent_pipe, - &child_pipe, - fdopt.flags); - if (err) - goto error; - - CHILD_STDIO_HANDLE(buffer, i) = child_pipe; - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FPIPE; - break; - } - - case UV_INHERIT_FD: { - /* Inherit a raw FD. */ - HANDLE child_handle; - - /* Make an inheritable duplicate of the handle. */ - err = uv__duplicate_fd(loop, fdopt.data.fd, &child_handle); - if (err) { - /* If fdopt.data.fd is not valid and fd fd <= 2, then ignore the */ - /* error. */ - if (fdopt.data.fd <= 2 && err == ERROR_INVALID_HANDLE) { - CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; - CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE; - break; - } - goto error; - } - - /* Figure out what the type is. */ - switch (GetFileType(child_handle)) { - case FILE_TYPE_DISK: - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN; - break; - - case FILE_TYPE_PIPE: - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FPIPE; - break; - - case FILE_TYPE_CHAR: - case FILE_TYPE_REMOTE: - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FDEV; - break; - - case FILE_TYPE_UNKNOWN: - if (GetLastError() != 0) { - err = GetLastError(); - CloseHandle(child_handle); - goto error; - } - CHILD_STDIO_CRT_FLAGS(buffer, i) = FOPEN | FDEV; - break; - - default: - assert(0); - return -1; - } - - CHILD_STDIO_HANDLE(buffer, i) = child_handle; - break; - } - - case UV_INHERIT_STREAM: { - /* Use an existing stream as the stdio handle for the child. */ - HANDLE stream_handle, child_handle; - unsigned char crt_flags; - uv_stream_t* stream = fdopt.data.stream; - - /* Leech the handle out of the stream. */ - if (stream->type == UV_TTY) { - stream_handle = ((uv_tty_t*) stream)->handle; - crt_flags = FOPEN | FDEV; - } else if (stream->type == UV_NAMED_PIPE && - stream->flags & UV_HANDLE_CONNECTION) { - stream_handle = ((uv_pipe_t*) stream)->handle; - crt_flags = FOPEN | FPIPE; - } else { - stream_handle = INVALID_HANDLE_VALUE; - crt_flags = 0; - } - - if (stream_handle == NULL || - stream_handle == INVALID_HANDLE_VALUE) { - /* The handle is already closed, or not yet created, or the */ - /* stream type is not supported. */ - err = ERROR_NOT_SUPPORTED; - goto error; - } - - /* Make an inheritable copy of the handle. */ - err = uv__duplicate_handle(loop, stream_handle, &child_handle); - if (err) - goto error; - - CHILD_STDIO_HANDLE(buffer, i) = child_handle; - CHILD_STDIO_CRT_FLAGS(buffer, i) = crt_flags; - break; - } - - default: - assert(0); - return -1; - } - } - - *buffer_ptr = buffer; - return 0; - - error: - uv__stdio_destroy(buffer); - return err; -} - - -void uv__stdio_destroy(BYTE* buffer) { - int i, count; - - count = CHILD_STDIO_COUNT(buffer); - for (i = 0; i < count; i++) { - HANDLE handle = CHILD_STDIO_HANDLE(buffer, i); - if (handle != INVALID_HANDLE_VALUE) { - CloseHandle(handle); - } - } - - uv__free(buffer); -} - - -void uv__stdio_noinherit(BYTE* buffer) { - int i, count; - - count = CHILD_STDIO_COUNT(buffer); - for (i = 0; i < count; i++) { - HANDLE handle = CHILD_STDIO_HANDLE(buffer, i); - if (handle != INVALID_HANDLE_VALUE) { - SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0); - } - } -} - - -int uv__stdio_verify(BYTE* buffer, WORD size) { - unsigned int count; - - /* Check the buffer pointer. */ - if (buffer == NULL) - return 0; - - /* Verify that the buffer is at least big enough to hold the count. */ - if (size < CHILD_STDIO_SIZE(0)) - return 0; - - /* Verify if the count is within range. */ - count = CHILD_STDIO_COUNT(buffer); - if (count > 256) - return 0; - - /* Verify that the buffer size is big enough to hold info for N FDs. */ - if (size < CHILD_STDIO_SIZE(count)) - return 0; - - return 1; -} - - -WORD uv__stdio_size(BYTE* buffer) { - return (WORD) CHILD_STDIO_SIZE(CHILD_STDIO_COUNT((buffer))); -} - - -HANDLE uv__stdio_handle(BYTE* buffer, int fd) { - return CHILD_STDIO_HANDLE(buffer, fd); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/process.c b/lib/ESPiLight/pilight/libs/libuv/win/process.c deleted file mode 100644 index d141601..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/process.c +++ /dev/null @@ -1,1246 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include /* alloca */ - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -#define SIGKILL 9 - - -typedef struct env_var { - const WCHAR* const wide; - const WCHAR* const wide_eq; - const size_t len; /* including null or '=' */ -} env_var_t; - -#define E_V(str) { L##str, L##str L"=", sizeof(str) } - -static const env_var_t required_vars[] = { /* keep me sorted */ - E_V("HOMEDRIVE"), - E_V("HOMEPATH"), - E_V("LOGONSERVER"), - E_V("PATH"), - E_V("SYSTEMDRIVE"), - E_V("SYSTEMROOT"), - E_V("TEMP"), - E_V("USERDOMAIN"), - E_V("USERNAME"), - E_V("USERPROFILE"), - E_V("WINDIR"), -}; -static size_t n_required_vars = ARRAY_SIZE(required_vars); - - -static HANDLE uv_global_job_handle_; -static uv_once_t uv_global_job_handle_init_guard_ = UV_ONCE_INIT; - - -static void uv__init_global_job_handle(void) { - /* Create a job object and set it up to kill all contained processes when - * it's closed. Since this handle is made non-inheritable and we're not - * giving it to anyone, we're the only process holding a reference to it. - * That means that if this process exits it is closed and all the processes - * it contains are killed. All processes created with uv_spawn that are not - * spawned with the UV_PROCESS_DETACHED flag are assigned to this job. - * - * We're setting the JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK flag so only the - * processes that we explicitly add are affected, and *their* subprocesses - * are not. This ensures that our child processes are not limited in their - * ability to use job control on Windows versions that don't deal with - * nested jobs (prior to Windows 8 / Server 2012). It also lets our child - * processes created detached processes without explicitly breaking away - * from job control (which uv_spawn doesn't, either). - */ - SECURITY_ATTRIBUTES attr; - JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; - - memset(&attr, 0, sizeof attr); - attr.bInheritHandle = FALSE; - - memset(&info, 0, sizeof info); - info.BasicLimitInformation.LimitFlags = - JOB_OBJECT_LIMIT_BREAKAWAY_OK | - JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK | - JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION | - JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; - - uv_global_job_handle_ = CreateJobObjectW(&attr, NULL); - if (uv_global_job_handle_ == NULL) - uv_fatal_error(GetLastError(), "CreateJobObjectW"); - - if (!SetInformationJobObject(uv_global_job_handle_, - JobObjectExtendedLimitInformation, - &info, - sizeof info)) - uv_fatal_error(GetLastError(), "SetInformationJobObject"); -} - - -static int uv_utf8_to_utf16_alloc(const char* s, WCHAR** ws_ptr) { - int ws_len, r; - WCHAR* ws; - - ws_len = MultiByteToWideChar(CP_UTF8, - 0, - s, - -1, - NULL, - 0); - if (ws_len <= 0) { - return GetLastError(); - } - - ws = (WCHAR*) uv__malloc(ws_len * sizeof(WCHAR)); - if (ws == NULL) { - return ERROR_OUTOFMEMORY; - } - - r = MultiByteToWideChar(CP_UTF8, - 0, - s, - -1, - ws, - ws_len); - assert(r == ws_len); - - *ws_ptr = ws; - return 0; -} - - -static void uv_process_init(uv_loop_t* loop, uv_process_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_PROCESS); - handle->exit_cb = NULL; - handle->pid = 0; - handle->exit_signal = 0; - handle->wait_handle = INVALID_HANDLE_VALUE; - handle->process_handle = INVALID_HANDLE_VALUE; - handle->child_stdio_buffer = NULL; - handle->exit_cb_pending = 0; - - UV_REQ_INIT(&handle->exit_req, UV_PROCESS_EXIT); - handle->exit_req.data = handle; -} - - -/* - * Path search functions - */ - -/* - * Helper function for search_path - */ -static WCHAR* search_path_join_test(const WCHAR* dir, - size_t dir_len, - const WCHAR* name, - size_t name_len, - const WCHAR* ext, - size_t ext_len, - const WCHAR* cwd, - size_t cwd_len) { - WCHAR *result, *result_pos; - DWORD attrs; - if (dir_len > 2 && dir[0] == L'\\' && dir[1] == L'\\') { - /* It's a UNC path so ignore cwd */ - cwd_len = 0; - } else if (dir_len >= 1 && (dir[0] == L'/' || dir[0] == L'\\')) { - /* It's a full path without drive letter, use cwd's drive letter only */ - cwd_len = 2; - } else if (dir_len >= 2 && dir[1] == L':' && - (dir_len < 3 || (dir[2] != L'/' && dir[2] != L'\\'))) { - /* It's a relative path with drive letter (ext.g. D:../some/file) - * Replace drive letter in dir by full cwd if it points to the same drive, - * otherwise use the dir only. - */ - if (cwd_len < 2 || _wcsnicmp(cwd, dir, 2) != 0) { - cwd_len = 0; - } else { - dir += 2; - dir_len -= 2; - } - } else if (dir_len > 2 && dir[1] == L':') { - /* It's an absolute path with drive letter - * Don't use the cwd at all - */ - cwd_len = 0; - } - - /* Allocate buffer for output */ - result = result_pos = (WCHAR*)uv__malloc(sizeof(WCHAR) * - (cwd_len + 1 + dir_len + 1 + name_len + 1 + ext_len + 1)); - - /* Copy cwd */ - wcsncpy(result_pos, cwd, cwd_len); - result_pos += cwd_len; - - /* Add a path separator if cwd didn't end with one */ - if (cwd_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) { - result_pos[0] = L'\\'; - result_pos++; - } - - /* Copy dir */ - wcsncpy(result_pos, dir, dir_len); - result_pos += dir_len; - - /* Add a separator if the dir didn't end with one */ - if (dir_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) { - result_pos[0] = L'\\'; - result_pos++; - } - - /* Copy filename */ - wcsncpy(result_pos, name, name_len); - result_pos += name_len; - - if (ext_len) { - /* Add a dot if the filename didn't end with one */ - if (name_len && result_pos[-1] != '.') { - result_pos[0] = L'.'; - result_pos++; - } - - /* Copy extension */ - wcsncpy(result_pos, ext, ext_len); - result_pos += ext_len; - } - - /* Null terminator */ - result_pos[0] = L'\0'; - - attrs = GetFileAttributesW(result); - - if (attrs != INVALID_FILE_ATTRIBUTES && - !(attrs & FILE_ATTRIBUTE_DIRECTORY)) { - return result; - } - - uv__free(result); - return NULL; -} - - -/* - * Helper function for search_path - */ -static WCHAR* path_search_walk_ext(const WCHAR *dir, - size_t dir_len, - const WCHAR *name, - size_t name_len, - WCHAR *cwd, - size_t cwd_len, - int name_has_ext) { - WCHAR* result; - - /* If the name itself has a nonempty extension, try this extension first */ - if (name_has_ext) { - result = search_path_join_test(dir, dir_len, - name, name_len, - L"", 0, - cwd, cwd_len); - if (result != NULL) { - return result; - } - } - - /* Try .com extension */ - result = search_path_join_test(dir, dir_len, - name, name_len, - L"com", 3, - cwd, cwd_len); - if (result != NULL) { - return result; - } - - /* Try .exe extension */ - result = search_path_join_test(dir, dir_len, - name, name_len, - L"exe", 3, - cwd, cwd_len); - if (result != NULL) { - return result; - } - - return NULL; -} - - -/* - * search_path searches the system path for an executable filename - - * the windows API doesn't provide this as a standalone function nor as an - * option to CreateProcess. - * - * It tries to return an absolute filename. - * - * Furthermore, it tries to follow the semantics that cmd.exe, with this - * exception that PATHEXT environment variable isn't used. Since CreateProcess - * can start only .com and .exe files, only those extensions are tried. This - * behavior equals that of msvcrt's spawn functions. - * - * - Do not search the path if the filename already contains a path (either - * relative or absolute). - * - * - If there's really only a filename, check the current directory for file, - * then search all path directories. - * - * - If filename specified has *any* extension, search for the file with the - * specified extension first. - * - * - If the literal filename is not found in a directory, try *appending* - * (not replacing) .com first and then .exe. - * - * - The path variable may contain relative paths; relative paths are relative - * to the cwd. - * - * - Directories in path may or may not end with a trailing backslash. - * - * - CMD does not trim leading/trailing whitespace from path/pathex entries - * nor from the environment variables as a whole. - * - * - When cmd.exe cannot read a directory, it will just skip it and go on - * searching. However, unlike posix-y systems, it will happily try to run a - * file that is not readable/executable; if the spawn fails it will not - * continue searching. - * - * UNC path support: we are dealing with UNC paths in both the path and the - * filename. This is a deviation from what cmd.exe does (it does not let you - * start a program by specifying an UNC path on the command line) but this is - * really a pointless restriction. - * - */ -static WCHAR* search_path(const WCHAR *file, - WCHAR *cwd, - const WCHAR *path) { - int file_has_dir; - WCHAR* result = NULL; - WCHAR *file_name_start; - WCHAR *dot; - const WCHAR *dir_start, *dir_end, *dir_path; - size_t dir_len; - int name_has_ext; - - size_t file_len = wcslen(file); - size_t cwd_len = wcslen(cwd); - - /* If the caller supplies an empty filename, - * we're not gonna return c:\windows\.exe -- GFY! - */ - if (file_len == 0 - || (file_len == 1 && file[0] == L'.')) { - return NULL; - } - - /* Find the start of the filename so we can split the directory from the */ - /* name. */ - for (file_name_start = (WCHAR*)file + file_len; - file_name_start > file - && file_name_start[-1] != L'\\' - && file_name_start[-1] != L'/' - && file_name_start[-1] != L':'; - file_name_start--); - - file_has_dir = file_name_start != file; - - /* Check if the filename includes an extension */ - dot = wcschr(file_name_start, L'.'); - name_has_ext = (dot != NULL && dot[1] != L'\0'); - - if (file_has_dir) { - /* The file has a path inside, don't use path */ - result = path_search_walk_ext( - file, file_name_start - file, - file_name_start, file_len - (file_name_start - file), - cwd, cwd_len, - name_has_ext); - - } else { - dir_end = path; - - /* The file is really only a name; look in cwd first, then scan path */ - result = path_search_walk_ext(L"", 0, - file, file_len, - cwd, cwd_len, - name_has_ext); - - while (result == NULL) { - if (*dir_end == L'\0') { - break; - } - - /* Skip the separator that dir_end now points to */ - if (dir_end != path || *path == L';') { - dir_end++; - } - - /* Next slice starts just after where the previous one ended */ - dir_start = dir_end; - - /* Slice until the next ; or \0 is found */ - dir_end = wcschr(dir_start, L';'); - if (dir_end == NULL) { - dir_end = wcschr(dir_start, L'\0'); - } - - /* If the slice is zero-length, don't bother */ - if (dir_end - dir_start == 0) { - continue; - } - - dir_path = dir_start; - dir_len = dir_end - dir_start; - - /* Adjust if the path is quoted. */ - if (dir_path[0] == '"' || dir_path[0] == '\'') { - ++dir_path; - --dir_len; - } - - if (dir_path[dir_len - 1] == '"' || dir_path[dir_len - 1] == '\'') { - --dir_len; - } - - result = path_search_walk_ext(dir_path, dir_len, - file, file_len, - cwd, cwd_len, - name_has_ext); - } - } - - return result; -} - - -/* - * Quotes command line arguments - * Returns a pointer to the end (next char to be written) of the buffer - */ -WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target) { - size_t len = wcslen(source); - size_t i; - int quote_hit; - WCHAR* start; - - if (len == 0) { - /* Need double quotation for empty argument */ - *(target++) = L'"'; - *(target++) = L'"'; - return target; - } - - if (NULL == wcspbrk(source, L" \t\"")) { - /* No quotation needed */ - wcsncpy(target, source, len); - target += len; - return target; - } - - if (NULL == wcspbrk(source, L"\"\\")) { - /* - * No embedded double quotes or backlashes, so I can just wrap - * quote marks around the whole thing. - */ - *(target++) = L'"'; - wcsncpy(target, source, len); - target += len; - *(target++) = L'"'; - return target; - } - - /* - * Expected input/output: - * input : hello"world - * output: "hello\"world" - * input : hello""world - * output: "hello\"\"world" - * input : hello\world - * output: hello\world - * input : hello\\world - * output: hello\\world - * input : hello\"world - * output: "hello\\\"world" - * input : hello\\"world - * output: "hello\\\\\"world" - * input : hello world\ - * output: "hello world\\" - */ - - *(target++) = L'"'; - start = target; - quote_hit = 1; - - for (i = len; i > 0; --i) { - *(target++) = source[i - 1]; - - if (quote_hit && source[i - 1] == L'\\') { - *(target++) = L'\\'; - } else if(source[i - 1] == L'"') { - quote_hit = 1; - *(target++) = L'\\'; - } else { - quote_hit = 0; - } - } - target[0] = L'\0'; - wcsrev(start); - *(target++) = L'"'; - return target; -} - - -int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { - char** arg; - WCHAR* dst = NULL; - WCHAR* temp_buffer = NULL; - size_t dst_len = 0; - size_t temp_buffer_len = 0; - WCHAR* pos; - int arg_count = 0; - int err = 0; - - /* Count the required size. */ - for (arg = args; *arg; arg++) { - DWORD arg_len; - - arg_len = MultiByteToWideChar(CP_UTF8, - 0, - *arg, - -1, - NULL, - 0); - if (arg_len == 0) { - return GetLastError(); - } - - dst_len += arg_len; - - if (arg_len > temp_buffer_len) - temp_buffer_len = arg_len; - - arg_count++; - } - - /* Adjust for potential quotes. Also assume the worst-case scenario */ - /* that every character needs escaping, so we need twice as much space. */ - dst_len = dst_len * 2 + arg_count * 2; - - /* Allocate buffer for the final command line. */ - dst = (WCHAR*) uv__malloc(dst_len * sizeof(WCHAR)); - if (dst == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - /* Allocate temporary working buffer. */ - temp_buffer = (WCHAR*) uv__malloc(temp_buffer_len * sizeof(WCHAR)); - if (temp_buffer == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - pos = dst; - for (arg = args; *arg; arg++) { - DWORD arg_len; - - /* Convert argument to wide char. */ - arg_len = MultiByteToWideChar(CP_UTF8, - 0, - *arg, - -1, - temp_buffer, - (int) (dst + dst_len - pos)); - if (arg_len == 0) { - err = GetLastError(); - goto error; - } - - if (verbatim_arguments) { - /* Copy verbatim. */ - wcscpy(pos, temp_buffer); - pos += arg_len - 1; - } else { - /* Quote/escape, if needed. */ - pos = quote_cmd_arg(temp_buffer, pos); - } - - *pos++ = *(arg + 1) ? L' ' : L'\0'; - } - - uv__free(temp_buffer); - - *dst_ptr = dst; - return 0; - -error: - uv__free(dst); - uv__free(temp_buffer); - return err; -} - - -int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { - wchar_t* a_eq; - wchar_t* b_eq; - wchar_t* A; - wchar_t* B; - int nb; - int r; - - if (na < 0) { - a_eq = wcschr(a, L'='); - assert(a_eq); - na = (int)(long)(a_eq - a); - } else { - na--; - } - b_eq = wcschr(b, L'='); - assert(b_eq); - nb = b_eq - b; - - A = alloca((na+1) * sizeof(wchar_t)); - B = alloca((nb+1) * sizeof(wchar_t)); - - r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, a, na, A, na); - assert(r==na); - A[na] = L'\0'; - r = LCMapStringW(LOCALE_INVARIANT, LCMAP_UPPERCASE, b, nb, B, nb); - assert(r==nb); - B[nb] = L'\0'; - - while (1) { - wchar_t AA = *A++; - wchar_t BB = *B++; - if (AA < BB) { - return -1; - } else if (AA > BB) { - return 1; - } else if (!AA && !BB) { - return 0; - } - } -} - - -static int qsort_wcscmp(const void *a, const void *b) { - wchar_t* astr = *(wchar_t* const*)a; - wchar_t* bstr = *(wchar_t* const*)b; - return env_strncmp(astr, -1, bstr); -} - - -/* - * The way windows takes environment variables is different than what C does; - * Windows wants a contiguous block of null-terminated strings, terminated - * with an additional null. - * - * Windows has a few "essential" environment variables. winsock will fail - * to initialize if SYSTEMROOT is not defined; some APIs make reference to - * TEMP. SYSTEMDRIVE is probably also important. We therefore ensure that - * these get defined if the input environment block does not contain any - * values for them. - * - * Also add variables known to Cygwin to be required for correct - * subprocess operation in many cases: - * https://github.com/Alexpux/Cygwin/blob/b266b04fbbd3a595f02ea149e4306d3ab9b1fe3d/winsup/cygwin/environ.cc#L955 - * - */ -int make_program_env(char* env_block[], WCHAR** dst_ptr) { - WCHAR* dst; - WCHAR* ptr; - char** env; - size_t env_len = 0; - int len; - size_t i; - DWORD var_size; - size_t env_block_count = 1; /* 1 for null-terminator */ - WCHAR* dst_copy; - WCHAR** ptr_copy; - WCHAR** env_copy; - DWORD* required_vars_value_len = alloca(n_required_vars * sizeof(DWORD*)); - - /* first pass: determine size in UTF-16 */ - for (env = env_block; *env; env++) { - int len; - if (strchr(*env, '=')) { - len = MultiByteToWideChar(CP_UTF8, - 0, - *env, - -1, - NULL, - 0); - if (len <= 0) { - return GetLastError(); - } - env_len += len; - env_block_count++; - } - } - - /* second pass: copy to UTF-16 environment block */ - dst_copy = (WCHAR*)uv__malloc(env_len * sizeof(WCHAR)); - if (!dst_copy) { - return ERROR_OUTOFMEMORY; - } - env_copy = alloca(env_block_count * sizeof(WCHAR*)); - - ptr = dst_copy; - ptr_copy = env_copy; - for (env = env_block; *env; env++) { - if (strchr(*env, '=')) { - len = MultiByteToWideChar(CP_UTF8, - 0, - *env, - -1, - ptr, - (int) (env_len - (ptr - dst_copy))); - if (len <= 0) { - DWORD err = GetLastError(); - uv__free(dst_copy); - return err; - } - *ptr_copy++ = ptr; - ptr += len; - } - } - *ptr_copy = NULL; - assert(env_len == ptr - dst_copy); - - /* sort our (UTF-16) copy */ - qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp); - - /* third pass: check for required variables */ - for (ptr_copy = env_copy, i = 0; i < n_required_vars; ) { - int cmp; - if (!*ptr_copy) { - cmp = -1; - } else { - cmp = env_strncmp(required_vars[i].wide_eq, - required_vars[i].len, - *ptr_copy); - } - if (cmp < 0) { - /* missing required var */ - var_size = GetEnvironmentVariableW(required_vars[i].wide, NULL, 0); - required_vars_value_len[i] = var_size; - if (var_size != 0) { - env_len += required_vars[i].len; - env_len += var_size; - } - i++; - } else { - ptr_copy++; - if (cmp == 0) - i++; - } - } - - /* final pass: copy, in sort order, and inserting required variables */ - dst = uv__malloc((1+env_len) * sizeof(WCHAR)); - if (!dst) { - uv__free(dst_copy); - return ERROR_OUTOFMEMORY; - } - - for (ptr = dst, ptr_copy = env_copy, i = 0; - *ptr_copy || i < n_required_vars; - ptr += len) { - int cmp; - if (i >= n_required_vars) { - cmp = 1; - } else if (!*ptr_copy) { - cmp = -1; - } else { - cmp = env_strncmp(required_vars[i].wide_eq, - required_vars[i].len, - *ptr_copy); - } - if (cmp < 0) { - /* missing required var */ - len = required_vars_value_len[i]; - if (len) { - wcscpy(ptr, required_vars[i].wide_eq); - ptr += required_vars[i].len; - var_size = GetEnvironmentVariableW(required_vars[i].wide, - ptr, - (int) (env_len - (ptr - dst))); - if (var_size != len-1) { /* race condition? */ - uv_fatal_error(GetLastError(), "GetEnvironmentVariableW"); - } - } - i++; - } else { - /* copy var from env_block */ - len = wcslen(*ptr_copy) + 1; - wmemcpy(ptr, *ptr_copy, len); - ptr_copy++; - if (cmp == 0) - i++; - } - } - - /* Terminate with an extra NULL. */ - assert(env_len == (ptr - dst)); - *ptr = L'\0'; - - uv__free(dst_copy); - *dst_ptr = dst; - return 0; -} - -/* - * Attempt to find the value of the PATH environment variable in the child's - * preprocessed environment. - * - * If found, a pointer into `env` is returned. If not found, NULL is returned. - */ -static WCHAR* find_path(WCHAR *env) { - for (; env != NULL && *env != 0; env += wcslen(env) + 1) { - if (wcsncmp(env, L"PATH=", 5) == 0) - return &env[5]; - } - - return NULL; -} - -/* - * Called on Windows thread-pool thread to indicate that - * a child process has exited. - */ -static void CALLBACK exit_wait_callback(void* data, BOOLEAN didTimeout) { - uv_process_t* process = (uv_process_t*) data; - uv_loop_t* loop = process->loop; - - assert(didTimeout == FALSE); - assert(process); - assert(!process->exit_cb_pending); - - process->exit_cb_pending = 1; - - /* Post completed */ - POST_COMPLETION_FOR_REQ(loop, &process->exit_req); -} - - -/* Called on main thread after a child process has exited. */ -void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) { - int64_t exit_code; - DWORD status; - - assert(handle->exit_cb_pending); - handle->exit_cb_pending = 0; - - /* If we're closing, don't call the exit callback. Just schedule a close */ - /* callback now. */ - if (handle->flags & UV__HANDLE_CLOSING) { - uv_want_endgame(loop, (uv_handle_t*) handle); - return; - } - - /* Unregister from process notification. */ - if (handle->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(handle->wait_handle); - handle->wait_handle = INVALID_HANDLE_VALUE; - } - - /* Set the handle to inactive: no callbacks will be made after the exit */ - /* callback.*/ - uv__handle_stop(handle); - - if (GetExitCodeProcess(handle->process_handle, &status)) { - exit_code = status; - } else { - /* Unable to to obtain the exit code. This should never happen. */ - exit_code = uv_translate_sys_error(GetLastError()); - } - - /* Fire the exit callback. */ - if (handle->exit_cb) { - handle->exit_cb(handle, exit_code, handle->exit_signal); - } -} - - -void uv_process_close(uv_loop_t* loop, uv_process_t* handle) { - uv__handle_closing(handle); - - if (handle->wait_handle != INVALID_HANDLE_VALUE) { - /* This blocks until either the wait was cancelled, or the callback has */ - /* completed. */ - BOOL r = UnregisterWaitEx(handle->wait_handle, INVALID_HANDLE_VALUE); - if (!r) { - /* This should never happen, and if it happens, we can't recover... */ - uv_fatal_error(GetLastError(), "UnregisterWaitEx"); - } - - handle->wait_handle = INVALID_HANDLE_VALUE; - } - - if (!handle->exit_cb_pending) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } -} - - -void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle) { - assert(!handle->exit_cb_pending); - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - /* Clean-up the process handle. */ - CloseHandle(handle->process_handle); - - uv__handle_close(handle); -} - - -int uv_spawn(uv_loop_t* loop, - uv_process_t* process, - const uv_process_options_t* options) { - int i; - int err = 0; - WCHAR* path = NULL, *alloc_path = NULL; - BOOL result; - WCHAR* application_path = NULL, *application = NULL, *arguments = NULL, - *env = NULL, *cwd = NULL; - STARTUPINFOW startup; - PROCESS_INFORMATION info; - DWORD process_flags; - - uv_process_init(loop, process); - process->exit_cb = options->exit_cb; - - if (options->flags & (UV_PROCESS_SETGID | UV_PROCESS_SETUID)) { - return UV_ENOTSUP; - } - - if (options->file == NULL || - options->args == NULL) { - return UV_EINVAL; - } - - assert(options->file != NULL); - assert(!(options->flags & ~(UV_PROCESS_DETACHED | - UV_PROCESS_SETGID | - UV_PROCESS_SETUID | - UV_PROCESS_WINDOWS_HIDE | - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS))); - - err = uv_utf8_to_utf16_alloc(options->file, &application); - if (err) - goto done; - - err = make_program_args( - options->args, - options->flags & UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS, - &arguments); - if (err) - goto done; - - if (options->env) { - err = make_program_env(options->env, &env); - if (err) - goto done; - } - - if (options->cwd) { - /* Explicit cwd */ - err = uv_utf8_to_utf16_alloc(options->cwd, &cwd); - if (err) - goto done; - - } else { - /* Inherit cwd */ - DWORD cwd_len, r; - - cwd_len = GetCurrentDirectoryW(0, NULL); - if (!cwd_len) { - err = GetLastError(); - goto done; - } - - cwd = (WCHAR*) uv__malloc(cwd_len * sizeof(WCHAR)); - if (cwd == NULL) { - err = ERROR_OUTOFMEMORY; - goto done; - } - - r = GetCurrentDirectoryW(cwd_len, cwd); - if (r == 0 || r >= cwd_len) { - err = GetLastError(); - goto done; - } - } - - /* Get PATH environment variable. */ - path = find_path(env); - if (path == NULL) { - DWORD path_len, r; - - path_len = GetEnvironmentVariableW(L"PATH", NULL, 0); - if (path_len == 0) { - err = GetLastError(); - goto done; - } - - alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR)); - if (alloc_path == NULL) { - err = ERROR_OUTOFMEMORY; - goto done; - } - path = alloc_path; - - r = GetEnvironmentVariableW(L"PATH", path, path_len); - if (r == 0 || r >= path_len) { - err = GetLastError(); - goto done; - } - } - - err = uv__stdio_create(loop, options, &process->child_stdio_buffer); - if (err) - goto done; - - application_path = search_path(application, - cwd, - path); - if (application_path == NULL) { - /* Not found. */ - err = ERROR_FILE_NOT_FOUND; - goto done; - } - - startup.cb = sizeof(startup); - startup.lpReserved = NULL; - startup.lpDesktop = NULL; - startup.lpTitle = NULL; - startup.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - - startup.cbReserved2 = uv__stdio_size(process->child_stdio_buffer); - startup.lpReserved2 = (BYTE*) process->child_stdio_buffer; - - startup.hStdInput = uv__stdio_handle(process->child_stdio_buffer, 0); - startup.hStdOutput = uv__stdio_handle(process->child_stdio_buffer, 1); - startup.hStdError = uv__stdio_handle(process->child_stdio_buffer, 2); - - if (options->flags & UV_PROCESS_WINDOWS_HIDE) { - /* Use SW_HIDE to avoid any potential process window. */ - startup.wShowWindow = SW_HIDE; - } else { - startup.wShowWindow = SW_SHOWDEFAULT; - } - - process_flags = CREATE_UNICODE_ENVIRONMENT; - - if (options->flags & UV_PROCESS_DETACHED) { - /* Note that we're not setting the CREATE_BREAKAWAY_FROM_JOB flag. That - * means that libuv might not let you create a fully daemonized process - * when run under job control. However the type of job control that libuv - * itself creates doesn't trickle down to subprocesses so they can still - * daemonize. - * - * A reason to not do this is that CREATE_BREAKAWAY_FROM_JOB makes the - * CreateProcess call fail if we're under job control that doesn't allow - * breakaway. - */ - process_flags |= DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP; - } - - if (!CreateProcessW(application_path, - arguments, - NULL, - NULL, - 1, - process_flags, - env, - cwd, - &startup, - &info)) { - /* CreateProcessW failed. */ - err = GetLastError(); - goto done; - } - - /* Spawn succeeded */ - /* Beyond this point, failure is reported asynchronously. */ - - process->process_handle = info.hProcess; - process->pid = info.dwProcessId; - - /* If the process isn't spawned as detached, assign to the global job */ - /* object so windows will kill it when the parent process dies. */ - if (!(options->flags & UV_PROCESS_DETACHED)) { - uv_once(&uv_global_job_handle_init_guard_, uv__init_global_job_handle); - - if (!AssignProcessToJobObject(uv_global_job_handle_, info.hProcess)) { - /* AssignProcessToJobObject might fail if this process is under job - * control and the job doesn't have the - * JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK flag set, on a Windows version - * that doesn't support nested jobs. - * - * When that happens we just swallow the error and continue without - * establishing a kill-child-on-parent-exit relationship, otherwise - * there would be no way for libuv applications run under job control - * to spawn processes at all. - */ - DWORD err = GetLastError(); - if (err != ERROR_ACCESS_DENIED) - uv_fatal_error(err, "AssignProcessToJobObject"); - } - } - - /* Set IPC pid to all IPC pipes. */ - for (i = 0; i < options->stdio_count; i++) { - const uv_stdio_container_t* fdopt = &options->stdio[i]; - if (fdopt->flags & UV_CREATE_PIPE && - fdopt->data.stream->type == UV_NAMED_PIPE && - ((uv_pipe_t*) fdopt->data.stream)->ipc) { - ((uv_pipe_t*) fdopt->data.stream)->pipe.conn.ipc_pid = info.dwProcessId; - } - } - - /* Setup notifications for when the child process exits. */ - result = RegisterWaitForSingleObject(&process->wait_handle, - process->process_handle, exit_wait_callback, (void*)process, INFINITE, - WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE); - if (!result) { - uv_fatal_error(GetLastError(), "RegisterWaitForSingleObject"); - } - - CloseHandle(info.hThread); - - assert(!err); - - /* Make the handle active. It will remain active until the exit callback */ - /* is made or the handle is closed, whichever happens first. */ - uv__handle_start(process); - - /* Cleanup, whether we succeeded or failed. */ - done: - uv__free(application); - uv__free(application_path); - uv__free(arguments); - uv__free(cwd); - uv__free(env); - uv__free(alloc_path); - - if (process->child_stdio_buffer != NULL) { - /* Clean up child stdio handles. */ - uv__stdio_destroy(process->child_stdio_buffer); - process->child_stdio_buffer = NULL; - } - - return uv_translate_sys_error(err); -} - - -static int uv__kill(HANDLE process_handle, int signum) { - switch (signum) { - case SIGTERM: - case SIGKILL: - case SIGINT: { - /* Unconditionally terminate the process. On Windows, killed processes */ - /* normally return 1. */ - DWORD status; - int err; - - if (TerminateProcess(process_handle, 1)) - return 0; - - /* If the process already exited before TerminateProcess was called, */ - /* TerminateProcess will fail with ERROR_ACCESS_DENIED. */ - err = GetLastError(); - if (err == ERROR_ACCESS_DENIED && - GetExitCodeProcess(process_handle, &status) && - status != STILL_ACTIVE) { - return UV_ESRCH; - } - - return uv_translate_sys_error(err); - } - - case 0: { - /* Health check: is the process still alive? */ - DWORD status; - - if (!GetExitCodeProcess(process_handle, &status)) - return uv_translate_sys_error(GetLastError()); - - if (status != STILL_ACTIVE) - return UV_ESRCH; - - return 0; - } - - default: - /* Unsupported signal. */ - return UV_ENOSYS; - } -} - - -int uv_process_kill(uv_process_t* process, int signum) { - int err; - - if (process->process_handle == INVALID_HANDLE_VALUE) { - return UV_EINVAL; - } - - err = uv__kill(process->process_handle, signum); - if (err) { - return err; /* err is already translated. */ - } - - process->exit_signal = signum; - - return 0; -} - - -int uv_kill(int pid, int signum) { - int err; - HANDLE process_handle = OpenProcess(PROCESS_TERMINATE | - PROCESS_QUERY_INFORMATION, FALSE, pid); - - if (process_handle == NULL) { - err = GetLastError(); - if (err == ERROR_INVALID_PARAMETER) { - return UV_ESRCH; - } else { - return uv_translate_sys_error(err); - } - } - - err = uv__kill(process_handle, signum); - CloseHandle(process_handle); - - return err; /* err is already translated. */ -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/req-inl.h b/lib/ESPiLight/pilight/libs/libuv/win/req-inl.h deleted file mode 100644 index f2513b7..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/req-inl.h +++ /dev/null @@ -1,221 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_REQ_INL_H_ -#define UV_WIN_REQ_INL_H_ - -#include - -#include "uv.h" -#include "internal.h" - - -#define SET_REQ_STATUS(req, status) \ - (req)->u.io.overlapped.Internal = (ULONG_PTR) (status) - -#define SET_REQ_ERROR(req, error) \ - SET_REQ_STATUS((req), NTSTATUS_FROM_WIN32((error))) - -/* Note: used open-coded in UV_REQ_INIT() because of a circular dependency - * between src/uv-common.h and src/win/internal.h. - */ -#define SET_REQ_SUCCESS(req) \ - SET_REQ_STATUS((req), STATUS_SUCCESS) - -#define GET_REQ_STATUS(req) \ - ((NTSTATUS) (req)->u.io.overlapped.Internal) - -#define REQ_SUCCESS(req) \ - (NT_SUCCESS(GET_REQ_STATUS((req)))) - -#define GET_REQ_ERROR(req) \ - (pRtlNtStatusToDosError(GET_REQ_STATUS((req)))) - -#define GET_REQ_SOCK_ERROR(req) \ - (uv_ntstatus_to_winsock_error(GET_REQ_STATUS((req)))) - - -#define REGISTER_HANDLE_REQ(loop, handle, req) \ - do { \ - INCREASE_ACTIVE_COUNT((loop), (handle)); \ - uv__req_register((loop), (req)); \ - } while (0) - -#define UNREGISTER_HANDLE_REQ(loop, handle, req) \ - do { \ - DECREASE_ACTIVE_COUNT((loop), (handle)); \ - uv__req_unregister((loop), (req)); \ - } while (0) - - -#define UV_SUCCEEDED_WITHOUT_IOCP(result) \ - ((result) && (handle->flags & UV_HANDLE_SYNC_BYPASS_IOCP)) - -#define UV_SUCCEEDED_WITH_IOCP(result) \ - ((result) || (GetLastError() == ERROR_IO_PENDING)) - - -#define POST_COMPLETION_FOR_REQ(loop, req) \ - if (!PostQueuedCompletionStatus((loop)->iocp, \ - 0, \ - 0, \ - &((req)->u.io.overlapped))) { \ - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); \ - } - - -INLINE static uv_req_t* uv_overlapped_to_req(OVERLAPPED* overlapped) { - return CONTAINING_RECORD(overlapped, uv_req_t, u.io.overlapped); -} - - -INLINE static void uv_insert_pending_req(uv_loop_t* loop, uv_req_t* req) { - req->next_req = NULL; - if (loop->pending_reqs_tail) { -#ifdef _DEBUG - /* Ensure the request is not already in the queue, or the queue - * will get corrupted. - */ - uv_req_t* current = loop->pending_reqs_tail; - do { - assert(req != current); - current = current->next_req; - } while(current != loop->pending_reqs_tail); -#endif - - req->next_req = loop->pending_reqs_tail->next_req; - loop->pending_reqs_tail->next_req = req; - loop->pending_reqs_tail = req; - } else { - req->next_req = req; - loop->pending_reqs_tail = req; - } -} - - -#define DELEGATE_STREAM_REQ(loop, req, method, handle_at) \ - do { \ - switch (((uv_handle_t*) (req)->handle_at)->type) { \ - case UV_TCP: \ - uv_process_tcp_##method##_req(loop, \ - (uv_tcp_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - case UV_NAMED_PIPE: \ - uv_process_pipe_##method##_req(loop, \ - (uv_pipe_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - case UV_TTY: \ - uv_process_tty_##method##_req(loop, \ - (uv_tty_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - default: \ - assert(0); \ - } \ - } while (0) - - -INLINE static int uv_process_reqs(uv_loop_t* loop) { - uv_req_t* req; - uv_req_t* first; - uv_req_t* next; - - if (loop->pending_reqs_tail == NULL) - return 0; - - first = loop->pending_reqs_tail->next_req; - next = first; - loop->pending_reqs_tail = NULL; - - while (next != NULL) { - req = next; - next = req->next_req != first ? req->next_req : NULL; - - switch (req->type) { - case UV_READ: - DELEGATE_STREAM_REQ(loop, req, read, data); - break; - - case UV_WRITE: - DELEGATE_STREAM_REQ(loop, (uv_write_t*) req, write, handle); - break; - - case UV_ACCEPT: - DELEGATE_STREAM_REQ(loop, req, accept, data); - break; - - case UV_CONNECT: - DELEGATE_STREAM_REQ(loop, (uv_connect_t*) req, connect, handle); - break; - - case UV_SHUTDOWN: - /* Tcp shutdown requests don't come here. */ - assert(((uv_shutdown_t*) req)->handle->type == UV_NAMED_PIPE); - uv_process_pipe_shutdown_req( - loop, - (uv_pipe_t*) ((uv_shutdown_t*) req)->handle, - (uv_shutdown_t*) req); - break; - - case UV_UDP_RECV: - uv_process_udp_recv_req(loop, (uv_udp_t*) req->data, req); - break; - - case UV_UDP_SEND: - uv_process_udp_send_req(loop, - ((uv_udp_send_t*) req)->handle, - (uv_udp_send_t*) req); - break; - - case UV_WAKEUP: - uv_process_async_wakeup_req(loop, (uv_async_t*) req->data, req); - break; - - case UV_SIGNAL_REQ: - uv_process_signal_req(loop, (uv_signal_t*) req->data, req); - break; - - case UV_POLL_REQ: - uv_process_poll_req(loop, (uv_poll_t*) req->data, req); - break; - - case UV_PROCESS_EXIT: - uv_process_proc_exit(loop, (uv_process_t*) req->data); - break; - - case UV_FS_EVENT_REQ: - uv_process_fs_event_req(loop, req, (uv_fs_event_t*) req->data); - break; - - default: - assert(0); - } - } - - return 1; -} - -#endif /* UV_WIN_REQ_INL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/win/req.c b/lib/ESPiLight/pilight/libs/libuv/win/req.c deleted file mode 100644 index 111cc5e..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/req.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include - -#include "uv.h" -#include "internal.h" diff --git a/lib/ESPiLight/pilight/libs/libuv/win/signal.c b/lib/ESPiLight/pilight/libs/libuv/win/signal.c deleted file mode 100644 index 7b42dd9..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/signal.c +++ /dev/null @@ -1,277 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -RB_HEAD(uv_signal_tree_s, uv_signal_s); - -static struct uv_signal_tree_s uv__signal_tree = RB_INITIALIZER(uv__signal_tree); -static CRITICAL_SECTION uv__signal_lock; - -static BOOL WINAPI uv__signal_control_handler(DWORD type); - -int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot); - -void uv_signals_init(void) { - InitializeCriticalSection(&uv__signal_lock); - if (!SetConsoleCtrlHandler(uv__signal_control_handler, TRUE)) - abort(); -} - - -static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) { - /* Compare signums first so all watchers with the same signnum end up */ - /* adjacent. */ - if (w1->signum < w2->signum) return -1; - if (w1->signum > w2->signum) return 1; - - /* Sort by loop pointer, so we can easily look up the first item after */ - /* { .signum = x, .loop = NULL } */ - if ((uintptr_t) w1->loop < (uintptr_t) w2->loop) return -1; - if ((uintptr_t) w1->loop > (uintptr_t) w2->loop) return 1; - - if ((uintptr_t) w1 < (uintptr_t) w2) return -1; - if ((uintptr_t) w1 > (uintptr_t) w2) return 1; - - return 0; -} - - -RB_GENERATE_STATIC(uv_signal_tree_s, uv_signal_s, tree_entry, uv__signal_compare); - - -/* - * Dispatches signal {signum} to all active uv_signal_t watchers in all loops. - * Returns 1 if the signal was dispatched to any watcher, or 0 if there were - * no active signal watchers observing this signal. - */ -int uv__signal_dispatch(int signum) { - uv_signal_t lookup; - uv_signal_t* handle; - int dispatched; - - dispatched = 0; - - EnterCriticalSection(&uv__signal_lock); - - lookup.signum = signum; - lookup.loop = NULL; - - for (handle = RB_NFIND(uv_signal_tree_s, &uv__signal_tree, &lookup); - handle != NULL && handle->signum == signum; - handle = RB_NEXT(uv_signal_tree_s, &uv__signal_tree, handle)) { - unsigned long previous = InterlockedExchange( - (volatile LONG*) &handle->pending_signum, signum); - - if (handle->flags & UV__SIGNAL_ONE_SHOT_DISPATCHED) - continue; - - if (!previous) { - POST_COMPLETION_FOR_REQ(handle->loop, &handle->signal_req); - } - - dispatched = 1; - if (handle->flags & UV__SIGNAL_ONE_SHOT) - handle->flags |= UV__SIGNAL_ONE_SHOT_DISPATCHED; - } - - LeaveCriticalSection(&uv__signal_lock); - - return dispatched; -} - - -static BOOL WINAPI uv__signal_control_handler(DWORD type) { - switch (type) { - case CTRL_C_EVENT: - return uv__signal_dispatch(SIGINT); - - case CTRL_BREAK_EVENT: - return uv__signal_dispatch(SIGBREAK); - - case CTRL_CLOSE_EVENT: - if (uv__signal_dispatch(SIGHUP)) { - /* Windows will terminate the process after the control handler */ - /* returns. After that it will just terminate our process. Therefore */ - /* block the signal handler so the main loop has some time to pick */ - /* up the signal and do something for a few seconds. */ - Sleep(INFINITE); - return TRUE; - } - return FALSE; - - case CTRL_LOGOFF_EVENT: - case CTRL_SHUTDOWN_EVENT: - /* These signals are only sent to services. Services have their own */ - /* notification mechanism, so there's no point in handling these. */ - - default: - /* We don't handle these. */ - return FALSE; - } -} - - -int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_SIGNAL); - handle->pending_signum = 0; - handle->signum = 0; - handle->signal_cb = NULL; - - UV_REQ_INIT(&handle->signal_req, UV_SIGNAL_REQ); - handle->signal_req.data = handle; - - return 0; -} - - -int uv_signal_stop(uv_signal_t* handle) { - uv_signal_t* removed_handle; - - /* If the watcher wasn't started, this is a no-op. */ - if (handle->signum == 0) - return 0; - - EnterCriticalSection(&uv__signal_lock); - - removed_handle = RB_REMOVE(uv_signal_tree_s, &uv__signal_tree, handle); - assert(removed_handle == handle); - - LeaveCriticalSection(&uv__signal_lock); - - handle->signum = 0; - uv__handle_stop(handle); - - return 0; -} - - -int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum) { - return uv__signal_start(handle, signal_cb, signum, 0); -} - - -int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum) { - return uv__signal_start(handle, signal_cb, signum, 1); -} - - -int uv__signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum, - int oneshot) { - /* Test for invalid signal values. */ - if (signum != SIGWINCH && (signum <= 0 || signum >= NSIG)) - return UV_EINVAL; - - /* Short circuit: if the signal watcher is already watching {signum} don't */ - /* go through the process of deregistering and registering the handler. */ - /* Additionally, this avoids pending signals getting lost in the (small) */ - /* time frame that handle->signum == 0. */ - if (signum == handle->signum) { - handle->signal_cb = signal_cb; - return 0; - } - - /* If the signal handler was already active, stop it first. */ - if (handle->signum != 0) { - int r = uv_signal_stop(handle); - /* uv_signal_stop is infallible. */ - assert(r == 0); - } - - EnterCriticalSection(&uv__signal_lock); - - handle->signum = signum; - if (oneshot) - handle->flags |= UV__SIGNAL_ONE_SHOT; - - RB_INSERT(uv_signal_tree_s, &uv__signal_tree, handle); - - LeaveCriticalSection(&uv__signal_lock); - - handle->signal_cb = signal_cb; - uv__handle_start(handle); - - return 0; -} - - -void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle, - uv_req_t* req) { - long dispatched_signum; - - assert(handle->type == UV_SIGNAL); - assert(req->type == UV_SIGNAL_REQ); - - dispatched_signum = InterlockedExchange( - (volatile LONG*) &handle->pending_signum, 0); - assert(dispatched_signum != 0); - - /* Check if the pending signal equals the signum that we are watching for. */ - /* These can get out of sync when the handler is stopped and restarted */ - /* while the signal_req is pending. */ - if (dispatched_signum == handle->signum) - handle->signal_cb(handle, dispatched_signum); - - if (handle->flags & UV__SIGNAL_ONE_SHOT) - uv_signal_stop(handle); - - if (handle->flags & UV__HANDLE_CLOSING) { - /* When it is closing, it must be stopped at this point. */ - assert(handle->signum == 0); - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle) { - uv_signal_stop(handle); - uv__handle_closing(handle); - - if (handle->pending_signum == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle) { - assert(handle->flags & UV__HANDLE_CLOSING); - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - assert(handle->signum == 0); - assert(handle->pending_signum == 0); - - handle->flags |= UV_HANDLE_CLOSED; - - uv__handle_close(handle); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/snprintf.c b/lib/ESPiLight/pilight/libs/libuv/win/snprintf.c deleted file mode 100644 index 776c0e3..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/snprintf.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright the libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#if defined(_MSC_VER) && _MSC_VER < 1900 - -#include -#include - -/* Emulate snprintf() on MSVC<2015, _snprintf() doesn't zero-terminate the buffer - * on overflow... - */ -int snprintf(char* buf, size_t len, const char* fmt, ...) { - int n; - va_list ap; - va_start(ap, fmt); - - n = _vscprintf(fmt, ap); - vsnprintf_s(buf, len, _TRUNCATE, fmt, ap); - - va_end(ap); - return n; -} - -#endif diff --git a/lib/ESPiLight/pilight/libs/libuv/win/stream-inl.h b/lib/ESPiLight/pilight/libs/libuv/win/stream-inl.h deleted file mode 100644 index bf12148..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/stream-inl.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_STREAM_INL_H_ -#define UV_WIN_STREAM_INL_H_ - -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -INLINE static void uv_stream_init(uv_loop_t* loop, - uv_stream_t* handle, - uv_handle_type type) { - uv__handle_init(loop, (uv_handle_t*) handle, type); - handle->write_queue_size = 0; - handle->activecnt = 0; -} - - -INLINE static void uv_connection_init(uv_stream_t* handle) { - handle->flags |= UV_HANDLE_CONNECTION; - handle->stream.conn.write_reqs_pending = 0; - - UV_REQ_INIT(&handle->read_req, UV_READ); - handle->read_req.event_handle = NULL; - handle->read_req.wait_handle = INVALID_HANDLE_VALUE; - handle->read_req.data = handle; - - handle->stream.conn.shutdown_req = NULL; -} - - -#endif /* UV_WIN_STREAM_INL_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/win/stream.c b/lib/ESPiLight/pilight/libs/libuv/win/stream.c deleted file mode 100644 index 13cbfdc..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/stream.c +++ /dev/null @@ -1,248 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "req-inl.h" - - -int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) { - int err; - - err = ERROR_INVALID_PARAMETER; - switch (stream->type) { - case UV_TCP: - err = uv_tcp_listen((uv_tcp_t*)stream, backlog, cb); - break; - case UV_NAMED_PIPE: - err = uv_pipe_listen((uv_pipe_t*)stream, backlog, cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_accept(uv_stream_t* server, uv_stream_t* client) { - int err; - - err = ERROR_INVALID_PARAMETER; - switch (server->type) { - case UV_TCP: - err = uv_tcp_accept((uv_tcp_t*)server, (uv_tcp_t*)client); - break; - case UV_NAMED_PIPE: - err = uv_pipe_accept((uv_pipe_t*)server, client); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_read_start(uv_stream_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - int err; - - if (handle->flags & UV_HANDLE_READING) { - return UV_EALREADY; - } - - if (!(handle->flags & UV_HANDLE_READABLE)) { - return UV_ENOTCONN; - } - - err = ERROR_INVALID_PARAMETER; - switch (handle->type) { - case UV_TCP: - err = uv_tcp_read_start((uv_tcp_t*)handle, alloc_cb, read_cb); - break; - case UV_NAMED_PIPE: - err = uv_pipe_read_start((uv_pipe_t*)handle, alloc_cb, read_cb); - break; - case UV_TTY: - err = uv_tty_read_start((uv_tty_t*) handle, alloc_cb, read_cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_read_stop(uv_stream_t* handle) { - int err; - - if (!(handle->flags & UV_HANDLE_READING)) - return 0; - - err = 0; - if (handle->type == UV_TTY) { - err = uv_tty_read_stop((uv_tty_t*) handle); - } else { - if (handle->type == UV_NAMED_PIPE) { - uv__pipe_stop_read((uv_pipe_t*) handle); - } else { - handle->flags &= ~UV_HANDLE_READING; - } - DECREASE_ACTIVE_COUNT(handle->loop, handle); - } - - return uv_translate_sys_error(err); -} - - -int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - uv_loop_t* loop = handle->loop; - int err; - - if (!(handle->flags & UV_HANDLE_WRITABLE)) { - return UV_EPIPE; - } - - err = ERROR_INVALID_PARAMETER; - switch (handle->type) { - case UV_TCP: - err = uv_tcp_write(loop, req, (uv_tcp_t*) handle, bufs, nbufs, cb); - break; - case UV_NAMED_PIPE: - err = uv_pipe_write(loop, req, (uv_pipe_t*) handle, bufs, nbufs, cb); - break; - case UV_TTY: - err = uv_tty_write(loop, req, (uv_tty_t*) handle, bufs, nbufs, cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb) { - uv_loop_t* loop = handle->loop; - int err; - - if (!(handle->flags & UV_HANDLE_WRITABLE)) { - return UV_EPIPE; - } - - err = ERROR_INVALID_PARAMETER; - switch (handle->type) { - case UV_NAMED_PIPE: - err = uv_pipe_write2(loop, - req, - (uv_pipe_t*) handle, - bufs, - nbufs, - send_handle, - cb); - break; - default: - assert(0); - } - - return uv_translate_sys_error(err); -} - - -int uv_try_write(uv_stream_t* stream, - const uv_buf_t bufs[], - unsigned int nbufs) { - if (stream->flags & UV__HANDLE_CLOSING) - return UV_EBADF; - if (!(stream->flags & UV_HANDLE_WRITABLE)) - return UV_EPIPE; - - switch (stream->type) { - case UV_TCP: - return uv__tcp_try_write((uv_tcp_t*) stream, bufs, nbufs); - case UV_TTY: - return uv__tty_try_write((uv_tty_t*) stream, bufs, nbufs); - case UV_NAMED_PIPE: - return UV_EAGAIN; - default: - assert(0); - return UV_ENOSYS; - } -} - - -int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) { - uv_loop_t* loop = handle->loop; - - if (!(handle->flags & UV_HANDLE_WRITABLE)) { - return UV_EPIPE; - } - - UV_REQ_INIT(req, UV_SHUTDOWN); - req->handle = handle; - req->cb = cb; - - handle->flags &= ~UV_HANDLE_WRITABLE; - handle->stream.conn.shutdown_req = req; - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - - uv_want_endgame(loop, (uv_handle_t*)handle); - - return 0; -} - - -int uv_is_readable(const uv_stream_t* handle) { - return !!(handle->flags & UV_HANDLE_READABLE); -} - - -int uv_is_writable(const uv_stream_t* handle) { - return !!(handle->flags & UV_HANDLE_WRITABLE); -} - - -int uv_stream_set_blocking(uv_stream_t* handle, int blocking) { - if (handle->type != UV_NAMED_PIPE) - return UV_EINVAL; - - if (blocking != 0) - handle->flags |= UV_HANDLE_BLOCKING_WRITES; - else - handle->flags &= ~UV_HANDLE_BLOCKING_WRITES; - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/tcp.c b/lib/ESPiLight/pilight/libs/libuv/win/tcp.c deleted file mode 100644 index 972539f..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/tcp.c +++ /dev/null @@ -1,1505 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - - -/* - * Threshold of active tcp streams for which to preallocate tcp read buffers. - * (Due to node slab allocator performing poorly under this pattern, - * the optimization is temporarily disabled (threshold=0). This will be - * revisited once node allocator is improved.) - */ -const unsigned int uv_active_tcp_streams_threshold = 0; - -/* - * Number of simultaneous pending AcceptEx calls. - */ -const unsigned int uv_simultaneous_server_accepts = 32; - -/* A zero-size buffer for use by uv_tcp_read */ -static char uv_zero_[] = ""; - -static int uv__tcp_nodelay(uv_tcp_t* handle, SOCKET socket, int enable) { - if (setsockopt(socket, - IPPROTO_TCP, - TCP_NODELAY, - (const char*)&enable, - sizeof enable) == -1) { - return WSAGetLastError(); - } - return 0; -} - - -static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsigned int delay) { - if (setsockopt(socket, - SOL_SOCKET, - SO_KEEPALIVE, - (const char*)&enable, - sizeof enable) == -1) { - return WSAGetLastError(); - } - - if (enable && setsockopt(socket, - IPPROTO_TCP, - TCP_KEEPALIVE, - (const char*)&delay, - sizeof delay) == -1) { - return WSAGetLastError(); - } - - return 0; -} - - -static int uv_tcp_set_socket(uv_loop_t* loop, - uv_tcp_t* handle, - SOCKET socket, - int family, - int imported) { - DWORD yes = 1; - int non_ifs_lsp; - int err; - - if (handle->socket != INVALID_SOCKET) - return UV_EBUSY; - - /* Set the socket to nonblocking mode */ - if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) { - return WSAGetLastError(); - } - - /* Make the socket non-inheritable */ - if (!SetHandleInformation((HANDLE) socket, HANDLE_FLAG_INHERIT, 0)) - return GetLastError(); - - /* Associate it with the I/O completion port. */ - /* Use uv_handle_t pointer as completion key. */ - if (CreateIoCompletionPort((HANDLE)socket, - loop->iocp, - (ULONG_PTR)socket, - 0) == NULL) { - if (imported) { - handle->flags |= UV_HANDLE_EMULATE_IOCP; - } else { - return GetLastError(); - } - } - - if (family == AF_INET6) { - non_ifs_lsp = uv_tcp_non_ifs_lsp_ipv6; - } else { - non_ifs_lsp = uv_tcp_non_ifs_lsp_ipv4; - } - - if (pSetFileCompletionNotificationModes && - !(handle->flags & UV_HANDLE_EMULATE_IOCP) && !non_ifs_lsp) { - if (pSetFileCompletionNotificationModes((HANDLE) socket, - FILE_SKIP_SET_EVENT_ON_HANDLE | - FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { - handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; - } else if (GetLastError() != ERROR_INVALID_FUNCTION) { - return GetLastError(); - } - } - - if (handle->flags & UV_HANDLE_TCP_NODELAY) { - err = uv__tcp_nodelay(handle, socket, 1); - if (err) - return err; - } - - /* TODO: Use stored delay. */ - if (handle->flags & UV_HANDLE_TCP_KEEPALIVE) { - err = uv__tcp_keepalive(handle, socket, 1, 60); - if (err) - return err; - } - - handle->socket = socket; - - if (family == AF_INET6) { - handle->flags |= UV_HANDLE_IPV6; - } else { - assert(!(handle->flags & UV_HANDLE_IPV6)); - } - - return 0; -} - - -int uv_tcp_init_ex(uv_loop_t* loop, uv_tcp_t* handle, unsigned int flags) { - int domain; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return UV_EINVAL; - - if (flags & ~0xFF) - return UV_EINVAL; - - uv_stream_init(loop, (uv_stream_t*) handle, UV_TCP); - handle->tcp.serv.accept_reqs = NULL; - handle->tcp.serv.pending_accepts = NULL; - handle->socket = INVALID_SOCKET; - handle->reqs_pending = 0; - handle->tcp.serv.func_acceptex = NULL; - handle->tcp.conn.func_connectex = NULL; - handle->tcp.serv.processed_accepts = 0; - handle->delayed_error = 0; - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init in uv_stream_init. - */ - - if (domain != AF_UNSPEC) { - SOCKET sock; - DWORD err; - - sock = socket(domain, SOCK_STREAM, 0); - if (sock == INVALID_SOCKET) { - err = WSAGetLastError(); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - - err = uv_tcp_set_socket(handle->loop, handle, sock, domain, 0); - if (err) { - closesocket(sock); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - - } - - return 0; -} - - -int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* handle) { - return uv_tcp_init_ex(loop, handle, AF_UNSPEC); -} - - -void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) { - int err; - unsigned int i; - uv_tcp_accept_t* req; - - if (handle->flags & UV_HANDLE_CONNECTION && - handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - - UNREGISTER_HANDLE_REQ(loop, handle, handle->stream.conn.shutdown_req); - - err = 0; - if (handle->flags & UV__HANDLE_CLOSING) { - err = ERROR_OPERATION_ABORTED; - } else if (shutdown(handle->socket, SD_SEND) == SOCKET_ERROR) { - err = WSAGetLastError(); - } - - if (handle->stream.conn.shutdown_req->cb) { - handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, - uv_translate_sys_error(err)); - } - - handle->stream.conn.shutdown_req = NULL; - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - - if (!(handle->flags & UV_HANDLE_TCP_SOCKET_CLOSED)) { - closesocket(handle->socket); - handle->socket = INVALID_SOCKET; - handle->flags |= UV_HANDLE_TCP_SOCKET_CLOSED; - } - - if (!(handle->flags & UV_HANDLE_CONNECTION) && handle->tcp.serv.accept_reqs) { - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - for (i = 0; i < uv_simultaneous_server_accepts; i++) { - req = &handle->tcp.serv.accept_reqs[i]; - if (req->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(req->wait_handle); - req->wait_handle = INVALID_HANDLE_VALUE; - } - if (req->event_handle) { - CloseHandle(req->event_handle); - req->event_handle = NULL; - } - } - } - - uv__free(handle->tcp.serv.accept_reqs); - handle->tcp.serv.accept_reqs = NULL; - } - - if (handle->flags & UV_HANDLE_CONNECTION && - handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(handle->read_req.wait_handle); - handle->read_req.wait_handle = INVALID_HANDLE_VALUE; - } - if (handle->read_req.event_handle) { - CloseHandle(handle->read_req.event_handle); - handle->read_req.event_handle = NULL; - } - } - - uv__handle_close(handle); - loop->active_tcp_streams--; - } -} - - -/* Unlike on Unix, here we don't set SO_REUSEADDR, because it doesn't just - * allow binding to addresses that are in use by sockets in TIME_WAIT, it - * effectively allows 'stealing' a port which is in use by another application. - * - * SO_EXCLUSIVEADDRUSE is also not good here because it does check all sockets, - * regardless of state, so we'd get an error even if the port is in use by a - * socket in TIME_WAIT state. - * - * See issue #1360. - * - */ -static int uv_tcp_try_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - DWORD err; - int r; - - if (handle->socket == INVALID_SOCKET) { - SOCKET sock; - - /* Cannot set IPv6-only mode on non-IPv6 socket. */ - if ((flags & UV_TCP_IPV6ONLY) && addr->sa_family != AF_INET6) - return ERROR_INVALID_PARAMETER; - - sock = socket(addr->sa_family, SOCK_STREAM, 0); - if (sock == INVALID_SOCKET) { - return WSAGetLastError(); - } - - err = uv_tcp_set_socket(handle->loop, handle, sock, addr->sa_family, 0); - if (err) { - closesocket(sock); - return err; - } - } - -#ifdef IPV6_V6ONLY - if (addr->sa_family == AF_INET6) { - int on; - - on = (flags & UV_TCP_IPV6ONLY) != 0; - - /* TODO: how to handle errors? This may fail if there is no ipv4 stack */ - /* available, or when run on XP/2003 which have no support for dualstack */ - /* sockets. For now we're silently ignoring the error. */ - setsockopt(handle->socket, - IPPROTO_IPV6, - IPV6_V6ONLY, - (const char*)&on, - sizeof on); - } -#endif - - r = bind(handle->socket, addr, addrlen); - - if (r == SOCKET_ERROR) { - err = WSAGetLastError(); - if (err == WSAEADDRINUSE) { - /* Some errors are not to be reported until connect() or listen() */ - handle->delayed_error = err; - } else { - return err; - } - } - - handle->flags |= UV_HANDLE_BOUND; - - return 0; -} - - -static void CALLBACK post_completion(void* context, BOOLEAN timed_out) { - uv_req_t* req; - uv_tcp_t* handle; - - req = (uv_req_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->data; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void CALLBACK post_write_completion(void* context, BOOLEAN timed_out) { - uv_write_t* req; - uv_tcp_t* handle; - - req = (uv_write_t*) context; - assert(req != NULL); - handle = (uv_tcp_t*)req->handle; - assert(handle != NULL); - assert(!timed_out); - - if (!PostQueuedCompletionStatus(handle->loop->iocp, - req->u.io.overlapped.InternalHigh, - 0, - &req->u.io.overlapped)) { - uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); - } -} - - -static void uv_tcp_queue_accept(uv_tcp_t* handle, uv_tcp_accept_t* req) { - uv_loop_t* loop = handle->loop; - BOOL success; - DWORD bytes; - SOCKET accept_socket; - short family; - - assert(handle->flags & UV_HANDLE_LISTENING); - assert(req->accept_socket == INVALID_SOCKET); - - /* choose family and extension function */ - if (handle->flags & UV_HANDLE_IPV6) { - family = AF_INET6; - } else { - family = AF_INET; - } - - /* Open a socket for the accepted connection. */ - accept_socket = socket(family, SOCK_STREAM, 0); - if (accept_socket == INVALID_SOCKET) { - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - return; - } - - /* Make the socket non-inheritable */ - if (!SetHandleInformation((HANDLE) accept_socket, HANDLE_FLAG_INHERIT, 0)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - closesocket(accept_socket); - return; - } - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); - } - - success = handle->tcp.serv.func_acceptex(handle->socket, - accept_socket, - (void*)req->accept_buffer, - 0, - sizeof(struct sockaddr_storage), - sizeof(struct sockaddr_storage), - &bytes, - &req->u.io.overlapped); - - if (UV_SUCCEEDED_WITHOUT_IOCP(success)) { - /* Process the req without IOCP. */ - req->accept_socket = accept_socket; - handle->reqs_pending++; - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(success)) { - /* The req will be processed with IOCP. */ - req->accept_socket = accept_socket; - handle->reqs_pending++; - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - req->wait_handle == INVALID_HANDLE_VALUE && - !RegisterWaitForSingleObject(&req->wait_handle, - req->event_handle, post_completion, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - return; - } - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - /* Destroy the preallocated client socket. */ - closesocket(accept_socket); - /* Destroy the event handle */ - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - CloseHandle(req->u.io.overlapped.hEvent); - req->event_handle = NULL; - } - } -} - - -static void uv_tcp_queue_read(uv_loop_t* loop, uv_tcp_t* handle) { - uv_read_t* req; - uv_buf_t buf; - int result; - DWORD bytes, flags; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - /* - * Preallocate a read buffer if the number of active streams is below - * the threshold. - */ - if (loop->active_tcp_streams < uv_active_tcp_streams_threshold) { - handle->flags &= ~UV_HANDLE_ZERO_READ; - handle->tcp.conn.read_buffer = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &handle->tcp.conn.read_buffer); - if (handle->tcp.conn.read_buffer.base == NULL || - handle->tcp.conn.read_buffer.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &handle->tcp.conn.read_buffer); - return; - } - assert(handle->tcp.conn.read_buffer.base != NULL); - buf = handle->tcp.conn.read_buffer; - } else { - handle->flags |= UV_HANDLE_ZERO_READ; - buf.base = (char*) &uv_zero_; - buf.len = 0; - } - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - assert(req->event_handle); - req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); - } - - flags = 0; - result = WSARecv(handle->socket, - (WSABUF*)&buf, - 1, - &bytes, - &flags, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Process the req without IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - req->u.io.overlapped.InternalHigh = bytes; - handle->reqs_pending++; - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* The req will be processed with IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - req->wait_handle == INVALID_HANDLE_VALUE && - !RegisterWaitForSingleObject(&req->wait_handle, - req->event_handle, post_completion, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - handle->reqs_pending++; - } -} - - -int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { - unsigned int i, simultaneous_accepts; - uv_tcp_accept_t* req; - int err; - - assert(backlog > 0); - - if (handle->flags & UV_HANDLE_LISTENING) { - handle->stream.serv.connection_cb = cb; - } - - if (handle->flags & UV_HANDLE_READING) { - return WSAEISCONN; - } - - if (handle->delayed_error) { - return handle->delayed_error; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) { - err = uv_tcp_try_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - 0); - if (err) - return err; - if (handle->delayed_error) - return handle->delayed_error; - } - - if (!handle->tcp.serv.func_acceptex) { - if (!uv_get_acceptex_function(handle->socket, &handle->tcp.serv.func_acceptex)) { - return WSAEAFNOSUPPORT; - } - } - - if (!(handle->flags & UV_HANDLE_SHARED_TCP_SOCKET) && - listen(handle->socket, backlog) == SOCKET_ERROR) { - return WSAGetLastError(); - } - - handle->flags |= UV_HANDLE_LISTENING; - handle->stream.serv.connection_cb = cb; - INCREASE_ACTIVE_COUNT(loop, handle); - - simultaneous_accepts = handle->flags & UV_HANDLE_TCP_SINGLE_ACCEPT ? 1 - : uv_simultaneous_server_accepts; - - if(!handle->tcp.serv.accept_reqs) { - handle->tcp.serv.accept_reqs = (uv_tcp_accept_t*) - uv__malloc(uv_simultaneous_server_accepts * sizeof(uv_tcp_accept_t)); - if (!handle->tcp.serv.accept_reqs) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - for (i = 0; i < simultaneous_accepts; i++) { - req = &handle->tcp.serv.accept_reqs[i]; - UV_REQ_INIT(req, UV_ACCEPT); - req->accept_socket = INVALID_SOCKET; - req->data = handle; - - req->wait_handle = INVALID_HANDLE_VALUE; - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - } else { - req->event_handle = NULL; - } - - uv_tcp_queue_accept(handle, req); - } - - /* Initialize other unused requests too, because uv_tcp_endgame */ - /* doesn't know how how many requests were initialized, so it will */ - /* try to clean up {uv_simultaneous_server_accepts} requests. */ - for (i = simultaneous_accepts; i < uv_simultaneous_server_accepts; i++) { - req = &handle->tcp.serv.accept_reqs[i]; - UV_REQ_INIT(req, UV_ACCEPT); - req->accept_socket = INVALID_SOCKET; - req->data = handle; - req->wait_handle = INVALID_HANDLE_VALUE; - req->event_handle = NULL; - } - } - - return 0; -} - - -int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client) { - uv_loop_t* loop = server->loop; - int err = 0; - int family; - - uv_tcp_accept_t* req = server->tcp.serv.pending_accepts; - - if (!req) { - /* No valid connections found, so we error out. */ - return WSAEWOULDBLOCK; - } - - if (req->accept_socket == INVALID_SOCKET) { - return WSAENOTCONN; - } - - if (server->flags & UV_HANDLE_IPV6) { - family = AF_INET6; - } else { - family = AF_INET; - } - - err = uv_tcp_set_socket(client->loop, - client, - req->accept_socket, - family, - 0); - if (err) { - closesocket(req->accept_socket); - } else { - uv_connection_init((uv_stream_t*) client); - /* AcceptEx() implicitly binds the accepted socket. */ - client->flags |= UV_HANDLE_BOUND | UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - } - - /* Prepare the req to pick up a new connection */ - server->tcp.serv.pending_accepts = req->next_pending; - req->next_pending = NULL; - req->accept_socket = INVALID_SOCKET; - - if (!(server->flags & UV__HANDLE_CLOSING)) { - /* Check if we're in a middle of changing the number of pending accepts. */ - if (!(server->flags & UV_HANDLE_TCP_ACCEPT_STATE_CHANGING)) { - uv_tcp_queue_accept(server, req); - } else { - /* We better be switching to a single pending accept. */ - assert(server->flags & UV_HANDLE_TCP_SINGLE_ACCEPT); - - server->tcp.serv.processed_accepts++; - - if (server->tcp.serv.processed_accepts >= uv_simultaneous_server_accepts) { - server->tcp.serv.processed_accepts = 0; - /* - * All previously queued accept requests are now processed. - * We now switch to queueing just a single accept. - */ - uv_tcp_queue_accept(server, &server->tcp.serv.accept_reqs[0]); - server->flags &= ~UV_HANDLE_TCP_ACCEPT_STATE_CHANGING; - server->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT; - } - } - } - - loop->active_tcp_streams++; - - return err; -} - - -int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - uv_loop_t* loop = handle->loop; - - handle->flags |= UV_HANDLE_READING; - handle->read_cb = read_cb; - handle->alloc_cb = alloc_cb; - INCREASE_ACTIVE_COUNT(loop, handle); - - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ - if (!(handle->flags & UV_HANDLE_READ_PENDING)) { - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - !handle->read_req.event_handle) { - handle->read_req.event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!handle->read_req.event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - } - uv_tcp_queue_read(loop, handle); - } - - return 0; -} - - -static int uv_tcp_try_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb) { - uv_loop_t* loop = handle->loop; - const struct sockaddr* bind_addr; - BOOL success; - DWORD bytes; - int err; - - if (handle->delayed_error) { - return handle->delayed_error; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) { - if (addrlen == sizeof(uv_addr_ip4_any_)) { - bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_; - } else if (addrlen == sizeof(uv_addr_ip6_any_)) { - bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; - } else { - abort(); - } - err = uv_tcp_try_bind(handle, bind_addr, addrlen, 0); - if (err) - return err; - if (handle->delayed_error) - return handle->delayed_error; - } - - if (!handle->tcp.conn.func_connectex) { - if (!uv_get_connectex_function(handle->socket, &handle->tcp.conn.func_connectex)) { - return WSAEAFNOSUPPORT; - } - } - - UV_REQ_INIT(req, UV_CONNECT); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - success = handle->tcp.conn.func_connectex(handle->socket, - addr, - addrlen, - NULL, - 0, - &bytes, - &req->u.io.overlapped); - - if (UV_SUCCEEDED_WITHOUT_IOCP(success)) { - /* Process the req without IOCP. */ - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(success)) { - /* The req will be processed with IOCP. */ - handle->reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - } else { - return WSAGetLastError(); - } - - return 0; -} - - -int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - int result; - - if (handle->socket == INVALID_SOCKET) { - return UV_EINVAL; - } - - if (handle->delayed_error) { - return uv_translate_sys_error(handle->delayed_error); - } - - result = getsockname(handle->socket, name, namelen); - if (result != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen) { - int result; - - if (handle->socket == INVALID_SOCKET) { - return UV_EINVAL; - } - - if (handle->delayed_error) { - return uv_translate_sys_error(handle->delayed_error); - } - - result = getpeername(handle->socket, name, namelen); - if (result != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_tcp_write(uv_loop_t* loop, - uv_write_t* req, - uv_tcp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - int result; - DWORD bytes; - - UV_REQ_INIT(req, UV_WRITE); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - - /* Prepare the overlapped structure. */ - memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - req->event_handle = CreateEvent(NULL, 0, 0, NULL); - if (!req->event_handle) { - uv_fatal_error(GetLastError(), "CreateEvent"); - } - req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); - req->wait_handle = INVALID_HANDLE_VALUE; - } - - result = WSASend(handle->socket, - (WSABUF*) bufs, - nbufs, - &bytes, - 0, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - uv_insert_pending_req(loop, (uv_req_t*) req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = uv__count_bufs(bufs, nbufs); - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - handle->write_queue_size += req->u.io.queued_bytes; - if (handle->flags & UV_HANDLE_EMULATE_IOCP && - !RegisterWaitForSingleObject(&req->wait_handle, - req->event_handle, post_write_completion, (void*) req, - INFINITE, WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE)) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - } else { - /* Send failed due to an error, report it later */ - req->u.io.queued_bytes = 0; - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, (uv_req_t*) req); - } - - return 0; -} - - -int uv__tcp_try_write(uv_tcp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs) { - int result; - DWORD bytes; - - if (handle->stream.conn.write_reqs_pending > 0) - return UV_EAGAIN; - - result = WSASend(handle->socket, - (WSABUF*) bufs, - nbufs, - &bytes, - 0, - NULL, - NULL); - - if (result == SOCKET_ERROR) - return uv_translate_sys_error(WSAGetLastError()); - else - return bytes; -} - - -void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_req_t* req) { - DWORD bytes, flags, err; - uv_buf_t buf; - - assert(handle->type == UV_TCP); - - handle->flags &= ~UV_HANDLE_READ_PENDING; - - if (!REQ_SUCCESS(req)) { - /* An error occurred doing the read. */ - if ((handle->flags & UV_HANDLE_READING) || - !(handle->flags & UV_HANDLE_ZERO_READ)) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - buf = (handle->flags & UV_HANDLE_ZERO_READ) ? - uv_buf_init(NULL, 0) : handle->tcp.conn.read_buffer; - - err = GET_REQ_SOCK_ERROR(req); - - if (err == WSAECONNABORTED) { - /* - * Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix. - */ - err = WSAECONNRESET; - } - - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(err), - &buf); - } - } else { - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - /* The read was done with a non-zero buffer length. */ - if (req->u.io.overlapped.InternalHigh > 0) { - /* Successful read */ - handle->read_cb((uv_stream_t*)handle, - req->u.io.overlapped.InternalHigh, - &handle->tcp.conn.read_buffer); - /* Read again only if bytes == buf.len */ - if (req->u.io.overlapped.InternalHigh < handle->tcp.conn.read_buffer.len) { - goto done; - } - } else { - /* Connection closed */ - if (handle->flags & UV_HANDLE_READING) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - } - handle->flags &= ~UV_HANDLE_READABLE; - - buf.base = 0; - buf.len = 0; - handle->read_cb((uv_stream_t*)handle, UV_EOF, &handle->tcp.conn.read_buffer); - goto done; - } - } - - /* Do nonblocking reads until the buffer is empty */ - while (handle->flags & UV_HANDLE_READING) { - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); - break; - } - assert(buf.base != NULL); - - flags = 0; - if (WSARecv(handle->socket, - (WSABUF*)&buf, - 1, - &bytes, - &flags, - NULL, - NULL) != SOCKET_ERROR) { - if (bytes > 0) { - /* Successful read */ - handle->read_cb((uv_stream_t*)handle, bytes, &buf); - /* Read again only if bytes == buf.len */ - if (bytes < buf.len) { - break; - } - } else { - /* Connection closed */ - handle->flags &= ~(UV_HANDLE_READING | UV_HANDLE_READABLE); - DECREASE_ACTIVE_COUNT(loop, handle); - - handle->read_cb((uv_stream_t*)handle, UV_EOF, &buf); - break; - } - } else { - err = WSAGetLastError(); - if (err == WSAEWOULDBLOCK) { - /* Read buffer was completely empty, report a 0-byte read. */ - handle->read_cb((uv_stream_t*)handle, 0, &buf); - } else { - /* Ouch! serious error. */ - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - - if (err == WSAECONNABORTED) { - /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with */ - /* Unix. */ - err = WSAECONNRESET; - } - - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(err), - &buf); - } - break; - } - } - -done: - /* Post another read if still reading and not closing. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_tcp_queue_read(loop, handle); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_write_t* req) { - int err; - - assert(handle->type == UV_TCP); - - assert(handle->write_queue_size >= req->u.io.queued_bytes); - handle->write_queue_size -= req->u.io.queued_bytes; - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (handle->flags & UV_HANDLE_EMULATE_IOCP) { - if (req->wait_handle != INVALID_HANDLE_VALUE) { - UnregisterWait(req->wait_handle); - req->wait_handle = INVALID_HANDLE_VALUE; - } - if (req->event_handle) { - CloseHandle(req->event_handle); - req->event_handle = NULL; - } - } - - if (req->cb) { - err = uv_translate_sys_error(GET_REQ_SOCK_ERROR(req)); - if (err == UV_ECONNABORTED) { - /* use UV_ECANCELED for consistency with Unix */ - err = UV_ECANCELED; - } - req->cb(req, err); - } - - handle->stream.conn.write_reqs_pending--; - if (handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_req_t* raw_req) { - uv_tcp_accept_t* req = (uv_tcp_accept_t*) raw_req; - int err; - - assert(handle->type == UV_TCP); - - /* If handle->accepted_socket is not a valid socket, then */ - /* uv_queue_accept must have failed. This is a serious error. We stop */ - /* accepting connections and report this error to the connection */ - /* callback. */ - if (req->accept_socket == INVALID_SOCKET) { - if (handle->flags & UV_HANDLE_LISTENING) { - handle->flags &= ~UV_HANDLE_LISTENING; - DECREASE_ACTIVE_COUNT(loop, handle); - if (handle->stream.serv.connection_cb) { - err = GET_REQ_SOCK_ERROR(req); - handle->stream.serv.connection_cb((uv_stream_t*)handle, - uv_translate_sys_error(err)); - } - } - } else if (REQ_SUCCESS(req) && - setsockopt(req->accept_socket, - SOL_SOCKET, - SO_UPDATE_ACCEPT_CONTEXT, - (char*)&handle->socket, - sizeof(handle->socket)) == 0) { - req->next_pending = handle->tcp.serv.pending_accepts; - handle->tcp.serv.pending_accepts = req; - - /* Accept and SO_UPDATE_ACCEPT_CONTEXT were successful. */ - if (handle->stream.serv.connection_cb) { - handle->stream.serv.connection_cb((uv_stream_t*)handle, 0); - } - } else { - /* Error related to accepted socket is ignored because the server */ - /* socket may still be healthy. If the server socket is broken */ - /* uv_queue_accept will detect it. */ - closesocket(req->accept_socket); - req->accept_socket = INVALID_SOCKET; - if (handle->flags & UV_HANDLE_LISTENING) { - uv_tcp_queue_accept(handle, req); - } - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_connect_t* req) { - int err; - - assert(handle->type == UV_TCP); - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - err = 0; - if (REQ_SUCCESS(req)) { - if (setsockopt(handle->socket, - SOL_SOCKET, - SO_UPDATE_CONNECT_CONTEXT, - NULL, - 0) == 0) { - uv_connection_init((uv_stream_t*)handle); - handle->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - loop->active_tcp_streams++; - } else { - err = WSAGetLastError(); - } - } else { - err = GET_REQ_SOCK_ERROR(req); - } - req->cb(req, uv_translate_sys_error(err)); - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex, - int tcp_connection) { - int err; - SOCKET socket = WSASocketW(FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - FROM_PROTOCOL_INFO, - &socket_info_ex->socket_info, - 0, - WSA_FLAG_OVERLAPPED); - - if (socket == INVALID_SOCKET) { - return WSAGetLastError(); - } - - err = uv_tcp_set_socket(tcp->loop, - tcp, - socket, - socket_info_ex->socket_info.iAddressFamily, - 1); - if (err) { - closesocket(socket); - return err; - } - - if (tcp_connection) { - uv_connection_init((uv_stream_t*)tcp); - tcp->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE; - } - - tcp->flags |= UV_HANDLE_BOUND; - tcp->flags |= UV_HANDLE_SHARED_TCP_SOCKET; - - tcp->delayed_error = socket_info_ex->delayed_error; - - tcp->loop->active_tcp_streams++; - return 0; -} - - -int uv_tcp_nodelay(uv_tcp_t* handle, int enable) { - int err; - - if (handle->socket != INVALID_SOCKET) { - err = uv__tcp_nodelay(handle, handle->socket, enable); - if (err) - return err; - } - - if (enable) { - handle->flags |= UV_HANDLE_TCP_NODELAY; - } else { - handle->flags &= ~UV_HANDLE_TCP_NODELAY; - } - - return 0; -} - - -int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { - int err; - - if (handle->socket != INVALID_SOCKET) { - err = uv__tcp_keepalive(handle, handle->socket, enable, delay); - if (err) - return err; - } - - if (enable) { - handle->flags |= UV_HANDLE_TCP_KEEPALIVE; - } else { - handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE; - } - - /* TODO: Store delay if handle->socket isn't created yet. */ - - return 0; -} - - -int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, - LPWSAPROTOCOL_INFOW protocol_info) { - if (!(handle->flags & UV_HANDLE_CONNECTION)) { - /* - * We're about to share the socket with another process. Because - * this is a listening socket, we assume that the other process will - * be accepting connections on it. So, before sharing the socket - * with another process, we call listen here in the parent process. - */ - - if (!(handle->flags & UV_HANDLE_LISTENING)) { - if (!(handle->flags & UV_HANDLE_BOUND)) { - return ERROR_INVALID_PARAMETER; - } - - if (!(handle->delayed_error)) { - if (listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) { - handle->delayed_error = WSAGetLastError(); - } - } - } - } - - if (WSADuplicateSocketW(handle->socket, pid, protocol_info)) { - return WSAGetLastError(); - } - - handle->flags |= UV_HANDLE_SHARED_TCP_SOCKET; - - return 0; -} - - -int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { - if (handle->flags & UV_HANDLE_CONNECTION) { - return UV_EINVAL; - } - - /* Check if we're already in the desired mode. */ - if ((enable && !(handle->flags & UV_HANDLE_TCP_SINGLE_ACCEPT)) || - (!enable && handle->flags & UV_HANDLE_TCP_SINGLE_ACCEPT)) { - return 0; - } - - /* Don't allow switching from single pending accept to many. */ - if (enable) { - return UV_ENOTSUP; - } - - /* Check if we're in a middle of changing the number of pending accepts. */ - if (handle->flags & UV_HANDLE_TCP_ACCEPT_STATE_CHANGING) { - return 0; - } - - handle->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT; - - /* Flip the changing flag if we have already queued multiple accepts. */ - if (handle->flags & UV_HANDLE_LISTENING) { - handle->flags |= UV_HANDLE_TCP_ACCEPT_STATE_CHANGING; - } - - return 0; -} - - -static int uv_tcp_try_cancel_io(uv_tcp_t* tcp) { - SOCKET socket = tcp->socket; - int non_ifs_lsp; - - /* Check if we have any non-IFS LSPs stacked on top of TCP */ - non_ifs_lsp = (tcp->flags & UV_HANDLE_IPV6) ? uv_tcp_non_ifs_lsp_ipv6 : - uv_tcp_non_ifs_lsp_ipv4; - - /* If there are non-ifs LSPs then try to obtain a base handle for the */ - /* socket. This will always fail on Windows XP/3k. */ - if (non_ifs_lsp) { - DWORD bytes; - if (WSAIoctl(socket, - SIO_BASE_HANDLE, - NULL, - 0, - &socket, - sizeof socket, - &bytes, - NULL, - NULL) != 0) { - /* Failed. We can't do CancelIo. */ - return -1; - } - } - - assert(socket != 0 && socket != INVALID_SOCKET); - - if (!CancelIo((HANDLE) socket)) { - return GetLastError(); - } - - /* It worked. */ - return 0; -} - - -void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) { - int close_socket = 1; - - if (tcp->flags & UV_HANDLE_READ_PENDING) { - /* In order for winsock to do a graceful close there must not be any */ - /* any pending reads, or the socket must be shut down for writing */ - if (!(tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET)) { - /* Just do shutdown on non-shared sockets, which ensures graceful close. */ - shutdown(tcp->socket, SD_SEND); - - } else if (uv_tcp_try_cancel_io(tcp) == 0) { - /* In case of a shared socket, we try to cancel all outstanding I/O, */ - /* If that works, don't close the socket yet - wait for the read req to */ - /* return and close the socket in uv_tcp_endgame. */ - close_socket = 0; - - } else { - /* When cancelling isn't possible - which could happen when an LSP is */ - /* present on an old Windows version, we will have to close the socket */ - /* with a read pending. That is not nice because trailing sent bytes */ - /* may not make it to the other side. */ - } - - } else if ((tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET) && - tcp->tcp.serv.accept_reqs != NULL) { - /* Under normal circumstances closesocket() will ensure that all pending */ - /* accept reqs are canceled. However, when the socket is shared the */ - /* presence of another reference to the socket in another process will */ - /* keep the accept reqs going, so we have to ensure that these are */ - /* canceled. */ - if (uv_tcp_try_cancel_io(tcp) != 0) { - /* When cancellation is not possible, there is another option: we can */ - /* close the incoming sockets, which will also cancel the accept */ - /* operations. However this is not cool because we might inadvertently */ - /* close a socket that just accepted a new connection, which will */ - /* cause the connection to be aborted. */ - unsigned int i; - for (i = 0; i < uv_simultaneous_server_accepts; i++) { - uv_tcp_accept_t* req = &tcp->tcp.serv.accept_reqs[i]; - if (req->accept_socket != INVALID_SOCKET && - !HasOverlappedIoCompleted(&req->u.io.overlapped)) { - closesocket(req->accept_socket); - req->accept_socket = INVALID_SOCKET; - } - } - } - } - - if (tcp->flags & UV_HANDLE_READING) { - tcp->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, tcp); - } - - if (tcp->flags & UV_HANDLE_LISTENING) { - tcp->flags &= ~UV_HANDLE_LISTENING; - DECREASE_ACTIVE_COUNT(loop, tcp); - } - - if (close_socket) { - closesocket(tcp->socket); - tcp->socket = INVALID_SOCKET; - tcp->flags |= UV_HANDLE_TCP_SOCKET_CLOSED; - } - - tcp->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); - uv__handle_closing(tcp); - - if (tcp->reqs_pending == 0) { - uv_want_endgame(tcp->loop, (uv_handle_t*)tcp); - } -} - - -int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) { - WSAPROTOCOL_INFOW protocol_info; - int opt_len; - int err; - - /* Detect the address family of the socket. */ - opt_len = (int) sizeof protocol_info; - if (getsockopt(sock, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) { - return uv_translate_sys_error(GetLastError()); - } - - err = uv_tcp_set_socket(handle->loop, - handle, - sock, - protocol_info.iAddressFamily, - 1); - if (err) { - return uv_translate_sys_error(err); - } - - return 0; -} - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - - err = uv_tcp_try_bind(handle, addr, addrlen, flags); - if (err) - return uv_translate_sys_error(err); - - return 0; -} - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - uv_connect_cb cb) { - int err; - - err = uv_tcp_try_connect(req, handle, addr, addrlen, cb); - if (err) - return uv_translate_sys_error(err); - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/thread.c b/lib/ESPiLight/pilight/libs/libuv/win/thread.c deleted file mode 100644 index 91684e9..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/thread.c +++ /dev/null @@ -1,697 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include - -#include "uv.h" -#include "internal.h" - - -#define HAVE_CONDVAR_API() (pInitializeConditionVariable != NULL) - -static int uv_cond_fallback_init(uv_cond_t* cond); -static void uv_cond_fallback_destroy(uv_cond_t* cond); -static void uv_cond_fallback_signal(uv_cond_t* cond); -static void uv_cond_fallback_broadcast(uv_cond_t* cond); -static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex); -static int uv_cond_fallback_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout); - -static int uv_cond_condvar_init(uv_cond_t* cond); -static void uv_cond_condvar_destroy(uv_cond_t* cond); -static void uv_cond_condvar_signal(uv_cond_t* cond); -static void uv_cond_condvar_broadcast(uv_cond_t* cond); -static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex); -static int uv_cond_condvar_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout); - - -static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) { - DWORD result; - HANDLE existing_event, created_event; - - created_event = CreateEvent(NULL, 1, 0, NULL); - if (created_event == 0) { - /* Could fail in a low-memory situation? */ - uv_fatal_error(GetLastError(), "CreateEvent"); - } - - existing_event = InterlockedCompareExchangePointer(&guard->event, - created_event, - NULL); - - if (existing_event == NULL) { - /* We won the race */ - callback(); - - result = SetEvent(created_event); - assert(result); - guard->ran = 1; - - } else { - /* We lost the race. Destroy the event we created and wait for the */ - /* existing one to become signaled. */ - CloseHandle(created_event); - result = WaitForSingleObject(existing_event, INFINITE); - assert(result == WAIT_OBJECT_0); - } -} - - -void uv_once(uv_once_t* guard, void (*callback)(void)) { - /* Fast case - avoid WaitForSingleObject. */ - if (guard->ran) { - return; - } - - uv__once_inner(guard, callback); -} - - -/* Verify that uv_thread_t can be stored in a TLS slot. */ -STATIC_ASSERT(sizeof(uv_thread_t) <= sizeof(void*)); - -static uv_key_t uv__current_thread_key; -static uv_once_t uv__current_thread_init_guard = UV_ONCE_INIT; - - -static void uv__init_current_thread_key(void) { - if (uv_key_create(&uv__current_thread_key)) - abort(); -} - - -struct thread_ctx { - void (*entry)(void* arg); - void* arg; - uv_thread_t self; -}; - - -static UINT __stdcall uv__thread_start(void* arg) { - struct thread_ctx *ctx_p; - struct thread_ctx ctx; - - ctx_p = arg; - ctx = *ctx_p; - uv__free(ctx_p); - - uv_once(&uv__current_thread_init_guard, uv__init_current_thread_key); - uv_key_set(&uv__current_thread_key, (void*) ctx.self); - - ctx.entry(ctx.arg); - - return 0; -} - - -int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { - struct thread_ctx* ctx; - int err; - HANDLE thread; - - ctx = uv__malloc(sizeof(*ctx)); - if (ctx == NULL) - return UV_ENOMEM; - - ctx->entry = entry; - ctx->arg = arg; - - /* Create the thread in suspended state so we have a chance to pass - * its own creation handle to it */ - thread = (HANDLE) _beginthreadex(NULL, - 0, - uv__thread_start, - ctx, - CREATE_SUSPENDED, - NULL); - if (thread == NULL) { - err = errno; - uv__free(ctx); - } else { - err = 0; - *tid = thread; - ctx->self = thread; - ResumeThread(thread); - } - - switch (err) { - case 0: - return 0; - case EACCES: - return UV_EACCES; - case EAGAIN: - return UV_EAGAIN; - case EINVAL: - return UV_EINVAL; - } - - return UV_EIO; -} - - -uv_thread_t uv_thread_self(void) { - uv_once(&uv__current_thread_init_guard, uv__init_current_thread_key); - return (uv_thread_t) uv_key_get(&uv__current_thread_key); -} - - -int uv_thread_join(uv_thread_t *tid) { - if (WaitForSingleObject(*tid, INFINITE)) - return uv_translate_sys_error(GetLastError()); - else { - CloseHandle(*tid); - *tid = 0; - return 0; - } -} - - -int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) { - return *t1 == *t2; -} - - -int uv_mutex_init(uv_mutex_t* mutex) { - InitializeCriticalSection(mutex); - return 0; -} - - -void uv_mutex_destroy(uv_mutex_t* mutex) { - DeleteCriticalSection(mutex); -} - - -void uv_mutex_lock(uv_mutex_t* mutex) { - EnterCriticalSection(mutex); -} - - -int uv_mutex_trylock(uv_mutex_t* mutex) { - if (TryEnterCriticalSection(mutex)) - return 0; - else - return UV_EBUSY; -} - - -void uv_mutex_unlock(uv_mutex_t* mutex) { - LeaveCriticalSection(mutex); -} - - -int uv_rwlock_init(uv_rwlock_t* rwlock) { - /* Initialize the semaphore that acts as the write lock. */ - HANDLE handle = CreateSemaphoreW(NULL, 1, 1, NULL); - if (handle == NULL) - return uv_translate_sys_error(GetLastError()); - rwlock->state_.write_semaphore_ = handle; - - /* Initialize the critical section protecting the reader count. */ - InitializeCriticalSection(&rwlock->state_.num_readers_lock_); - - /* Initialize the reader count. */ - rwlock->state_.num_readers_ = 0; - - return 0; -} - - -void uv_rwlock_destroy(uv_rwlock_t* rwlock) { - DeleteCriticalSection(&rwlock->state_.num_readers_lock_); - CloseHandle(rwlock->state_.write_semaphore_); -} - - -void uv_rwlock_rdlock(uv_rwlock_t* rwlock) { - /* Acquire the lock that protects the reader count. */ - EnterCriticalSection(&rwlock->state_.num_readers_lock_); - - /* Increase the reader count, and lock for write if this is the first - * reader. - */ - if (++rwlock->state_.num_readers_ == 1) { - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, INFINITE); - if (r != WAIT_OBJECT_0) - uv_fatal_error(GetLastError(), "WaitForSingleObject"); - } - - /* Release the lock that protects the reader count. */ - LeaveCriticalSection(&rwlock->state_.num_readers_lock_); -} - - -int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) { - int err; - - if (!TryEnterCriticalSection(&rwlock->state_.num_readers_lock_)) - return UV_EBUSY; - - err = 0; - - if (rwlock->state_.num_readers_ == 0) { - /* Currently there are no other readers, which means that the write lock - * needs to be acquired. - */ - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, 0); - if (r == WAIT_OBJECT_0) - rwlock->state_.num_readers_++; - else if (r == WAIT_TIMEOUT) - err = UV_EBUSY; - else if (r == WAIT_FAILED) - uv_fatal_error(GetLastError(), "WaitForSingleObject"); - - } else { - /* The write lock has already been acquired because there are other - * active readers. - */ - rwlock->state_.num_readers_++; - } - - LeaveCriticalSection(&rwlock->state_.num_readers_lock_); - return err; -} - - -void uv_rwlock_rdunlock(uv_rwlock_t* rwlock) { - EnterCriticalSection(&rwlock->state_.num_readers_lock_); - - if (--rwlock->state_.num_readers_ == 0) { - if (!ReleaseSemaphore(rwlock->state_.write_semaphore_, 1, NULL)) - uv_fatal_error(GetLastError(), "ReleaseSemaphore"); - } - - LeaveCriticalSection(&rwlock->state_.num_readers_lock_); -} - - -void uv_rwlock_wrlock(uv_rwlock_t* rwlock) { - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, INFINITE); - if (r != WAIT_OBJECT_0) - uv_fatal_error(GetLastError(), "WaitForSingleObject"); -} - - -int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) { - DWORD r = WaitForSingleObject(rwlock->state_.write_semaphore_, 0); - if (r == WAIT_OBJECT_0) - return 0; - else if (r == WAIT_TIMEOUT) - return UV_EBUSY; - else - uv_fatal_error(GetLastError(), "WaitForSingleObject"); -} - - -void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) { - if (!ReleaseSemaphore(rwlock->state_.write_semaphore_, 1, NULL)) - uv_fatal_error(GetLastError(), "ReleaseSemaphore"); -} - - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - *sem = CreateSemaphore(NULL, value, INT_MAX, NULL); - if (*sem == NULL) - return uv_translate_sys_error(GetLastError()); - else - return 0; -} - - -void uv_sem_destroy(uv_sem_t* sem) { - if (!CloseHandle(*sem)) - abort(); -} - - -void uv_sem_post(uv_sem_t* sem) { - if (!ReleaseSemaphore(*sem, 1, NULL)) - abort(); -} - - -void uv_sem_wait(uv_sem_t* sem) { - if (WaitForSingleObject(*sem, INFINITE) != WAIT_OBJECT_0) - abort(); -} - - -int uv_sem_trywait(uv_sem_t* sem) { - DWORD r = WaitForSingleObject(*sem, 0); - - if (r == WAIT_OBJECT_0) - return 0; - - if (r == WAIT_TIMEOUT) - return UV_EAGAIN; - - abort(); - return -1; /* Satisfy the compiler. */ -} - - -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -static int uv_cond_fallback_init(uv_cond_t* cond) { - int err; - - /* Initialize the count to 0. */ - cond->fallback.waiters_count = 0; - - InitializeCriticalSection(&cond->fallback.waiters_count_lock); - - /* Create an auto-reset event. */ - cond->fallback.signal_event = CreateEvent(NULL, /* no security */ - FALSE, /* auto-reset event */ - FALSE, /* non-signaled initially */ - NULL); /* unnamed */ - if (!cond->fallback.signal_event) { - err = GetLastError(); - goto error2; - } - - /* Create a manual-reset event. */ - cond->fallback.broadcast_event = CreateEvent(NULL, /* no security */ - TRUE, /* manual-reset */ - FALSE, /* non-signaled */ - NULL); /* unnamed */ - if (!cond->fallback.broadcast_event) { - err = GetLastError(); - goto error; - } - - return 0; - -error: - CloseHandle(cond->fallback.signal_event); -error2: - DeleteCriticalSection(&cond->fallback.waiters_count_lock); - return uv_translate_sys_error(err); -} - - -static int uv_cond_condvar_init(uv_cond_t* cond) { - pInitializeConditionVariable(&cond->cond_var); - return 0; -} - - -int uv_cond_init(uv_cond_t* cond) { - uv__once_init(); - - if (HAVE_CONDVAR_API()) - return uv_cond_condvar_init(cond); - else - return uv_cond_fallback_init(cond); -} - - -static void uv_cond_fallback_destroy(uv_cond_t* cond) { - if (!CloseHandle(cond->fallback.broadcast_event)) - abort(); - if (!CloseHandle(cond->fallback.signal_event)) - abort(); - DeleteCriticalSection(&cond->fallback.waiters_count_lock); -} - - -static void uv_cond_condvar_destroy(uv_cond_t* cond) { - /* nothing to do */ -} - - -void uv_cond_destroy(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_destroy(cond); - else - uv_cond_fallback_destroy(cond); -} - - -static void uv_cond_fallback_signal(uv_cond_t* cond) { - int have_waiters; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - have_waiters = cond->fallback.waiters_count > 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - if (have_waiters) - SetEvent(cond->fallback.signal_event); -} - - -static void uv_cond_condvar_signal(uv_cond_t* cond) { - pWakeConditionVariable(&cond->cond_var); -} - - -void uv_cond_signal(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_signal(cond); - else - uv_cond_fallback_signal(cond); -} - - -static void uv_cond_fallback_broadcast(uv_cond_t* cond) { - int have_waiters; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - have_waiters = cond->fallback.waiters_count > 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - if (have_waiters) - SetEvent(cond->fallback.broadcast_event); -} - - -static void uv_cond_condvar_broadcast(uv_cond_t* cond) { - pWakeAllConditionVariable(&cond->cond_var); -} - - -void uv_cond_broadcast(uv_cond_t* cond) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_broadcast(cond); - else - uv_cond_fallback_broadcast(cond); -} - - -static int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex, - DWORD dwMilliseconds) { - DWORD result; - int last_waiter; - HANDLE handles[2] = { - cond->fallback.signal_event, - cond->fallback.broadcast_event - }; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->fallback.waiters_count_lock); - cond->fallback.waiters_count++; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - /* It's ok to release the here since Win32 manual-reset events */ - /* maintain state when used with . This avoids the "lost wakeup" */ - /* bug. */ - uv_mutex_unlock(mutex); - - /* Wait for either event to become signaled due to being */ - /* called or being called. */ - result = WaitForMultipleObjects(2, handles, FALSE, dwMilliseconds); - - EnterCriticalSection(&cond->fallback.waiters_count_lock); - cond->fallback.waiters_count--; - last_waiter = result == WAIT_OBJECT_0 + 1 - && cond->fallback.waiters_count == 0; - LeaveCriticalSection(&cond->fallback.waiters_count_lock); - - /* Some thread called . */ - if (last_waiter) { - /* We're the last waiter to be notified or to stop waiting, so reset the */ - /* the manual-reset event. */ - ResetEvent(cond->fallback.broadcast_event); - } - - /* Reacquire the . */ - uv_mutex_lock(mutex); - - if (result == WAIT_OBJECT_0 || result == WAIT_OBJECT_0 + 1) - return 0; - - if (result == WAIT_TIMEOUT) - return UV_ETIMEDOUT; - - abort(); - return -1; /* Satisfy the compiler. */ -} - - -static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (uv_cond_wait_helper(cond, mutex, INFINITE)) - abort(); -} - - -static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (!pSleepConditionVariableCS(&cond->cond_var, mutex, INFINITE)) - abort(); -} - - -void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { - if (HAVE_CONDVAR_API()) - uv_cond_condvar_wait(cond, mutex); - else - uv_cond_fallback_wait(cond, mutex); -} - - -static int uv_cond_fallback_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout) { - return uv_cond_wait_helper(cond, mutex, (DWORD)(timeout / 1e6)); -} - - -static int uv_cond_condvar_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, uint64_t timeout) { - if (pSleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6))) - return 0; - if (GetLastError() != ERROR_TIMEOUT) - abort(); - return UV_ETIMEDOUT; -} - - -int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, - uint64_t timeout) { - if (HAVE_CONDVAR_API()) - return uv_cond_condvar_timedwait(cond, mutex, timeout); - else - return uv_cond_fallback_timedwait(cond, mutex, timeout); -} - - -int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { - int err; - - barrier->n = count; - barrier->count = 0; - - err = uv_mutex_init(&barrier->mutex); - if (err) - return err; - - err = uv_sem_init(&barrier->turnstile1, 0); - if (err) - goto error2; - - err = uv_sem_init(&barrier->turnstile2, 1); - if (err) - goto error; - - return 0; - -error: - uv_sem_destroy(&barrier->turnstile1); -error2: - uv_mutex_destroy(&barrier->mutex); - return err; - -} - - -void uv_barrier_destroy(uv_barrier_t* barrier) { - uv_sem_destroy(&barrier->turnstile2); - uv_sem_destroy(&barrier->turnstile1); - uv_mutex_destroy(&barrier->mutex); -} - - -int uv_barrier_wait(uv_barrier_t* barrier) { - int serial_thread; - - uv_mutex_lock(&barrier->mutex); - if (++barrier->count == barrier->n) { - uv_sem_wait(&barrier->turnstile2); - uv_sem_post(&barrier->turnstile1); - } - uv_mutex_unlock(&barrier->mutex); - - uv_sem_wait(&barrier->turnstile1); - uv_sem_post(&barrier->turnstile1); - - uv_mutex_lock(&barrier->mutex); - serial_thread = (--barrier->count == 0); - if (serial_thread) { - uv_sem_wait(&barrier->turnstile1); - uv_sem_post(&barrier->turnstile2); - } - uv_mutex_unlock(&barrier->mutex); - - uv_sem_wait(&barrier->turnstile2); - uv_sem_post(&barrier->turnstile2); - return serial_thread; -} - - -int uv_key_create(uv_key_t* key) { - key->tls_index = TlsAlloc(); - if (key->tls_index == TLS_OUT_OF_INDEXES) - return UV_ENOMEM; - return 0; -} - - -void uv_key_delete(uv_key_t* key) { - if (TlsFree(key->tls_index) == FALSE) - abort(); - key->tls_index = TLS_OUT_OF_INDEXES; -} - - -void* uv_key_get(uv_key_t* key) { - void* value; - - value = TlsGetValue(key->tls_index); - if (value == NULL) - if (GetLastError() != ERROR_SUCCESS) - abort(); - - return value; -} - - -void uv_key_set(uv_key_t* key, void* value) { - if (TlsSetValue(key->tls_index, value) == FALSE) - abort(); -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/timer.c b/lib/ESPiLight/pilight/libs/libuv/win/timer.c deleted file mode 100644 index 27ca771..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/timer.c +++ /dev/null @@ -1,195 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include - -#include "uv.h" -#include "internal.h" -#include "tree.h" -#include "handle-inl.h" - - -/* The number of milliseconds in one second. */ -#define UV__MILLISEC 1000 - - -void uv_update_time(uv_loop_t* loop) { - uint64_t new_time = uv__hrtime(UV__MILLISEC); - assert(new_time >= loop->time); - loop->time = new_time; -} - - -static int uv_timer_compare(uv_timer_t* a, uv_timer_t* b) { - if (a->due < b->due) - return -1; - if (a->due > b->due) - return 1; - /* - * compare start_id when both has the same due. start_id is - * allocated with loop->timer_counter in uv_timer_start(). - */ - if (a->start_id < b->start_id) - return -1; - if (a->start_id > b->start_id) - return 1; - return 0; -} - - -RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare); - - -int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { - uv__handle_init(loop, (uv_handle_t*) handle, UV_TIMER); - handle->timer_cb = NULL; - handle->repeat = 0; - - return 0; -} - - -void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -static uint64_t get_clamped_due_time(uint64_t loop_time, uint64_t timeout) { - uint64_t clamped_timeout; - - clamped_timeout = loop_time + timeout; - if (clamped_timeout < timeout) - clamped_timeout = (uint64_t) -1; - - return clamped_timeout; -} - - -int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout, - uint64_t repeat) { - uv_loop_t* loop = handle->loop; - uv_timer_t* old; - - if (timer_cb == NULL) - return UV_EINVAL; - - if (uv__is_active(handle)) - uv_timer_stop(handle); - - handle->timer_cb = timer_cb; - handle->due = get_clamped_due_time(loop->time, timeout); - handle->repeat = repeat; - uv__handle_start(handle); - - /* start_id is the second index to be compared in uv__timer_cmp() */ - handle->start_id = handle->loop->timer_counter++; - - old = RB_INSERT(uv_timer_tree_s, &loop->timers, handle); - assert(old == NULL); - - return 0; -} - - -int uv_timer_stop(uv_timer_t* handle) { - uv_loop_t* loop = handle->loop; - - if (!uv__is_active(handle)) - return 0; - - RB_REMOVE(uv_timer_tree_s, &loop->timers, handle); - uv__handle_stop(handle); - - return 0; -} - - -int uv_timer_again(uv_timer_t* handle) { - /* If timer_cb is NULL that means that the timer was never started. */ - if (!handle->timer_cb) { - return UV_EINVAL; - } - - if (handle->repeat) { - uv_timer_stop(handle); - uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat); - } - - return 0; -} - - -void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) { - assert(handle->type == UV_TIMER); - handle->repeat = repeat; -} - - -uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { - assert(handle->type == UV_TIMER); - return handle->repeat; -} - - -DWORD uv__next_timeout(const uv_loop_t* loop) { - uv_timer_t* timer; - int64_t delta; - - /* Check if there are any running timers - * Need to cast away const first, since RB_MIN doesn't know what we are - * going to do with this return value, it can't be marked const - */ - timer = RB_MIN(uv_timer_tree_s, &((uv_loop_t*)loop)->timers); - if (timer) { - delta = timer->due - loop->time; - if (delta >= UINT_MAX - 1) { - /* A timeout value of UINT_MAX means infinite, so that's no good. */ - return UINT_MAX - 1; - } else if (delta < 0) { - /* Negative timeout values are not allowed */ - return 0; - } else { - return (DWORD)delta; - } - } else { - /* No timers */ - return INFINITE; - } -} - - -void uv_process_timers(uv_loop_t* loop) { - uv_timer_t* timer; - - /* Call timer callbacks */ - for (timer = RB_MIN(uv_timer_tree_s, &loop->timers); - timer != NULL && timer->due <= loop->time; - timer = RB_MIN(uv_timer_tree_s, &loop->timers)) { - - uv_timer_stop(timer); - uv_timer_again(timer); - timer->timer_cb((uv_timer_t*) timer); - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/tty.c b/lib/ESPiLight/pilight/libs/libuv/win/tty.c deleted file mode 100644 index a6f5839..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/tty.c +++ /dev/null @@ -1,2281 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include -#endif - -#ifndef COMMON_LVB_REVERSE_VIDEO -# define COMMON_LVB_REVERSE_VIDEO 0x4000 -#endif - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - -#ifndef InterlockedOr -# define InterlockedOr _InterlockedOr -#endif - -#define UNICODE_REPLACEMENT_CHARACTER (0xfffd) - -#define ANSI_NORMAL 0x00 -#define ANSI_ESCAPE_SEEN 0x02 -#define ANSI_CSI 0x04 -#define ANSI_ST_CONTROL 0x08 -#define ANSI_IGNORE 0x10 -#define ANSI_IN_ARG 0x20 -#define ANSI_IN_STRING 0x40 -#define ANSI_BACKSLASH_SEEN 0x80 - -#define MAX_INPUT_BUFFER_LENGTH 8192 -#define MAX_CONSOLE_CHAR 8192 - -#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING -#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 -#endif - -static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info); -static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info); -static int uv__cancel_read_console(uv_tty_t* handle); - - -/* Null uv_buf_t */ -static const uv_buf_t uv_null_buf_ = { 0, NULL }; - -enum uv__read_console_status_e { - NOT_STARTED, - IN_PROGRESS, - TRAP_REQUESTED, - COMPLETED -}; - -static volatile LONG uv__read_console_status = NOT_STARTED; -static volatile LONG uv__restore_screen_state; -static CONSOLE_SCREEN_BUFFER_INFO uv__saved_screen_state; - - -/* - * The console virtual window. - * - * Normally cursor movement in windows is relative to the console screen buffer, - * e.g. the application is allowed to overwrite the 'history'. This is very - * inconvenient, it makes absolute cursor movement pretty useless. There is - * also the concept of 'client rect' which is defined by the actual size of - * the console window and the scroll position of the screen buffer, but it's - * very volatile because it changes when the user scrolls. - * - * To make cursor movement behave sensibly we define a virtual window to which - * cursor movement is confined. The virtual window is always as wide as the - * console screen buffer, but it's height is defined by the size of the - * console window. The top of the virtual window aligns with the position - * of the caret when the first stdout/err handle is created, unless that would - * mean that it would extend beyond the bottom of the screen buffer - in that - * that case it's located as far down as possible. - * - * When the user writes a long text or many newlines, such that the output - * reaches beyond the bottom of the virtual window, the virtual window is - * shifted downwards, but not resized. - * - * Since all tty i/o happens on the same console, this window is shared - * between all stdout/stderr handles. - */ - -static int uv_tty_virtual_offset = -1; -static int uv_tty_virtual_height = -1; -static int uv_tty_virtual_width = -1; - -/* We use a semaphore rather than a mutex or critical section because in some - cases (uv__cancel_read_console) we need take the lock in the main thread and - release it in another thread. Using a semaphore ensures that in such - scenario the main thread will still block when trying to acquire the lock. */ -static uv_sem_t uv_tty_output_lock; - -static HANDLE uv_tty_output_handle = INVALID_HANDLE_VALUE; - -static WORD uv_tty_default_text_attributes = - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; - -static char uv_tty_default_fg_color = 7; -static char uv_tty_default_bg_color = 0; -static char uv_tty_default_fg_bright = 0; -static char uv_tty_default_bg_bright = 0; -static char uv_tty_default_inverse = 0; - -typedef enum { - UV_SUPPORTED, - UV_UNCHECKED, - UV_UNSUPPORTED -} uv_vtermstate_t; -/* Determine whether or not ANSI support is enabled. */ -static uv_vtermstate_t uv__vterm_state = UV_UNCHECKED; -static void uv__determine_vterm_state(HANDLE handle); - -void uv_console_init(void) { - if (uv_sem_init(&uv_tty_output_lock, 1)) - abort(); -} - - -int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { - HANDLE handle; - CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info; - - handle = (HANDLE) uv__get_osfhandle(fd); - if (handle == INVALID_HANDLE_VALUE) - return UV_EBADF; - - if (fd <= 2) { - /* In order to avoid closing a stdio file descriptor 0-2, duplicate the - * underlying OS handle and forget about the original fd. - * We could also opt to use the original OS handle and just never close it, - * but then there would be no reliable way to cancel pending read operations - * upon close. - */ - if (!DuplicateHandle(INVALID_HANDLE_VALUE, - handle, - INVALID_HANDLE_VALUE, - &handle, - 0, - FALSE, - DUPLICATE_SAME_ACCESS)) - return uv_translate_sys_error(GetLastError()); - fd = -1; - } - - if (!readable) { - /* Obtain the screen buffer info with the output handle. */ - if (!GetConsoleScreenBufferInfo(handle, &screen_buffer_info)) { - return uv_translate_sys_error(GetLastError()); - } - - /* Obtain the the tty_output_lock because the virtual window state is */ - /* shared between all uv_tty_t handles. */ - uv_sem_wait(&uv_tty_output_lock); - - if (uv__vterm_state == UV_UNCHECKED) - uv__determine_vterm_state(handle); - - /* Store the global tty output handle. This handle is used by TTY read */ - /* streams to update the virtual window when a CONSOLE_BUFFER_SIZE_EVENT */ - /* is received. */ - uv_tty_output_handle = handle; - - /* Remember the original console text attributes. */ - uv_tty_capture_initial_style(&screen_buffer_info); - - uv_tty_update_virtual_window(&screen_buffer_info); - - uv_sem_post(&uv_tty_output_lock); - } - - - uv_stream_init(loop, (uv_stream_t*) tty, UV_TTY); - uv_connection_init((uv_stream_t*) tty); - - tty->handle = handle; - tty->u.fd = fd; - tty->reqs_pending = 0; - tty->flags |= UV_HANDLE_BOUND; - - if (readable) { - /* Initialize TTY input specific fields. */ - tty->flags |= UV_HANDLE_TTY_READABLE | UV_HANDLE_READABLE; - /* TODO: remove me in v2.x. */ - tty->tty.rd.unused_ = NULL; - tty->tty.rd.read_line_buffer = uv_null_buf_; - tty->tty.rd.read_raw_wait = NULL; - - /* Init keycode-to-vt100 mapper state. */ - tty->tty.rd.last_key_len = 0; - tty->tty.rd.last_key_offset = 0; - tty->tty.rd.last_utf16_high_surrogate = 0; - memset(&tty->tty.rd.last_input_record, 0, sizeof tty->tty.rd.last_input_record); - } else { - /* TTY output specific fields. */ - tty->flags |= UV_HANDLE_WRITABLE; - - /* Init utf8-to-utf16 conversion state. */ - tty->tty.wr.utf8_bytes_left = 0; - tty->tty.wr.utf8_codepoint = 0; - - /* Initialize eol conversion state */ - tty->tty.wr.previous_eol = 0; - - /* Init ANSI parser state. */ - tty->tty.wr.ansi_parser_state = ANSI_NORMAL; - } - - return 0; -} - - -/* Set the default console text attributes based on how the console was - * configured when libuv started. - */ -static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info) { - static int style_captured = 0; - - /* Only do this once. - Assumption: Caller has acquired uv_tty_output_lock. */ - if (style_captured) - return; - - /* Save raw win32 attributes. */ - uv_tty_default_text_attributes = info->wAttributes; - - /* Convert black text on black background to use white text. */ - if (uv_tty_default_text_attributes == 0) - uv_tty_default_text_attributes = 7; - - /* Convert Win32 attributes to ANSI colors. */ - uv_tty_default_fg_color = 0; - uv_tty_default_bg_color = 0; - uv_tty_default_fg_bright = 0; - uv_tty_default_bg_bright = 0; - uv_tty_default_inverse = 0; - - if (uv_tty_default_text_attributes & FOREGROUND_RED) - uv_tty_default_fg_color |= 1; - - if (uv_tty_default_text_attributes & FOREGROUND_GREEN) - uv_tty_default_fg_color |= 2; - - if (uv_tty_default_text_attributes & FOREGROUND_BLUE) - uv_tty_default_fg_color |= 4; - - if (uv_tty_default_text_attributes & BACKGROUND_RED) - uv_tty_default_bg_color |= 1; - - if (uv_tty_default_text_attributes & BACKGROUND_GREEN) - uv_tty_default_bg_color |= 2; - - if (uv_tty_default_text_attributes & BACKGROUND_BLUE) - uv_tty_default_bg_color |= 4; - - if (uv_tty_default_text_attributes & FOREGROUND_INTENSITY) - uv_tty_default_fg_bright = 1; - - if (uv_tty_default_text_attributes & BACKGROUND_INTENSITY) - uv_tty_default_bg_bright = 1; - - if (uv_tty_default_text_attributes & COMMON_LVB_REVERSE_VIDEO) - uv_tty_default_inverse = 1; - - style_captured = 1; -} - - -int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { - DWORD flags; - unsigned char was_reading; - uv_alloc_cb alloc_cb; - uv_read_cb read_cb; - int err; - - if (!(tty->flags & UV_HANDLE_TTY_READABLE)) { - return UV_EINVAL; - } - - if (!!mode == !!(tty->flags & UV_HANDLE_TTY_RAW)) { - return 0; - } - - switch (mode) { - case UV_TTY_MODE_NORMAL: - flags = ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT; - break; - case UV_TTY_MODE_RAW: - flags = ENABLE_WINDOW_INPUT; - break; - case UV_TTY_MODE_IO: - return UV_ENOTSUP; - default: - return UV_EINVAL; - } - - /* If currently reading, stop, and restart reading. */ - if (tty->flags & UV_HANDLE_READING) { - was_reading = 1; - alloc_cb = tty->alloc_cb; - read_cb = tty->read_cb; - err = uv_tty_read_stop(tty); - if (err) { - return uv_translate_sys_error(err); - } - } else { - was_reading = 0; - } - - uv_sem_wait(&uv_tty_output_lock); - if (!SetConsoleMode(tty->handle, flags)) { - err = uv_translate_sys_error(GetLastError()); - uv_sem_post(&uv_tty_output_lock); - return err; - } - uv_sem_post(&uv_tty_output_lock); - - /* Update flag. */ - tty->flags &= ~UV_HANDLE_TTY_RAW; - tty->flags |= mode ? UV_HANDLE_TTY_RAW : 0; - - /* If we just stopped reading, restart. */ - if (was_reading) { - err = uv_tty_read_start(tty, alloc_cb, read_cb); - if (err) { - return uv_translate_sys_error(err); - } - } - - return 0; -} - - -int uv_is_tty(uv_file file) { - DWORD result; - return GetConsoleMode((HANDLE) _get_osfhandle(file), &result) != 0; -} - - -int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { - CONSOLE_SCREEN_BUFFER_INFO info; - - if (!GetConsoleScreenBufferInfo(tty->handle, &info)) { - return uv_translate_sys_error(GetLastError()); - } - - uv_sem_wait(&uv_tty_output_lock); - uv_tty_update_virtual_window(&info); - uv_sem_post(&uv_tty_output_lock); - - *width = uv_tty_virtual_width; - *height = uv_tty_virtual_height; - - return 0; -} - - -static void CALLBACK uv_tty_post_raw_read(void* data, BOOLEAN didTimeout) { - uv_loop_t* loop; - uv_tty_t* handle; - uv_req_t* req; - - assert(data); - assert(!didTimeout); - - req = (uv_req_t*) data; - handle = (uv_tty_t*) req->data; - loop = handle->loop; - - UnregisterWait(handle->tty.rd.read_raw_wait); - handle->tty.rd.read_raw_wait = NULL; - - SET_REQ_SUCCESS(req); - POST_COMPLETION_FOR_REQ(loop, req); -} - - -static void uv_tty_queue_read_raw(uv_loop_t* loop, uv_tty_t* handle) { - uv_read_t* req; - BOOL r; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - assert(handle->handle && handle->handle != INVALID_HANDLE_VALUE); - - handle->tty.rd.read_line_buffer = uv_null_buf_; - - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - r = RegisterWaitForSingleObject(&handle->tty.rd.read_raw_wait, - handle->handle, - uv_tty_post_raw_read, - (void*) req, - INFINITE, - WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE); - if (!r) { - handle->tty.rd.read_raw_wait = NULL; - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; -} - - -static DWORD CALLBACK uv_tty_line_read_thread(void* data) { - uv_loop_t* loop; - uv_tty_t* handle; - uv_req_t* req; - DWORD bytes, read_bytes; - WCHAR utf16[MAX_INPUT_BUFFER_LENGTH / 3]; - DWORD chars, read_chars; - LONG status; - COORD pos; - BOOL read_console_success; - - assert(data); - - req = (uv_req_t*) data; - handle = (uv_tty_t*) req->data; - loop = handle->loop; - - assert(handle->tty.rd.read_line_buffer.base != NULL); - assert(handle->tty.rd.read_line_buffer.len > 0); - - /* ReadConsole can't handle big buffers. */ - if (handle->tty.rd.read_line_buffer.len < MAX_INPUT_BUFFER_LENGTH) { - bytes = handle->tty.rd.read_line_buffer.len; - } else { - bytes = MAX_INPUT_BUFFER_LENGTH; - } - - /* At last, unicode! */ - /* One utf-16 codeunit never takes more than 3 utf-8 codeunits to encode */ - chars = bytes / 3; - - status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS); - if (status == TRAP_REQUESTED) { - SET_REQ_SUCCESS(req); - req->u.io.overlapped.InternalHigh = 0; - POST_COMPLETION_FOR_REQ(loop, req); - return 0; - } - - read_console_success = ReadConsoleW(handle->handle, - (void*) utf16, - chars, - &read_chars, - NULL); - - if (read_console_success) { - read_bytes = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - read_chars, - handle->tty.rd.read_line_buffer.base, - bytes, - NULL, - NULL); - SET_REQ_SUCCESS(req); - req->u.io.overlapped.InternalHigh = read_bytes; - } else { - SET_REQ_ERROR(req, GetLastError()); - } - - status = InterlockedExchange(&uv__read_console_status, COMPLETED); - - if (status == TRAP_REQUESTED) { - /* If we canceled the read by sending a VK_RETURN event, restore the - screen state to undo the visual effect of the VK_RETURN */ - if (read_console_success && InterlockedOr(&uv__restore_screen_state, 0)) { - HANDLE active_screen_buffer; - active_screen_buffer = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (active_screen_buffer != INVALID_HANDLE_VALUE) { - pos = uv__saved_screen_state.dwCursorPosition; - - /* If the cursor was at the bottom line of the screen buffer, the - VK_RETURN would have caused the buffer contents to scroll up by one - line. The right position to reset the cursor to is therefore one line - higher */ - if (pos.Y == uv__saved_screen_state.dwSize.Y - 1) - pos.Y--; - - SetConsoleCursorPosition(active_screen_buffer, pos); - CloseHandle(active_screen_buffer); - } - } - uv_sem_post(&uv_tty_output_lock); - } - POST_COMPLETION_FOR_REQ(loop, req); - return 0; -} - - -static void uv_tty_queue_read_line(uv_loop_t* loop, uv_tty_t* handle) { - uv_read_t* req; - BOOL r; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - assert(handle->handle && handle->handle != INVALID_HANDLE_VALUE); - - req = &handle->read_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - handle->tty.rd.read_line_buffer = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 8192, &handle->tty.rd.read_line_buffer); - if (handle->tty.rd.read_line_buffer.base == NULL || - handle->tty.rd.read_line_buffer.len == 0) { - handle->read_cb((uv_stream_t*) handle, - UV_ENOBUFS, - &handle->tty.rd.read_line_buffer); - return; - } - assert(handle->tty.rd.read_line_buffer.base != NULL); - - /* Reset flags No locking is required since there cannot be a line read - in progress. We are also relying on the memory barrier provided by - QueueUserWorkItem*/ - uv__restore_screen_state = FALSE; - uv__read_console_status = NOT_STARTED; - r = QueueUserWorkItem(uv_tty_line_read_thread, - (void*) req, - WT_EXECUTELONGFUNCTION); - if (!r) { - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - } - - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; -} - - -static void uv_tty_queue_read(uv_loop_t* loop, uv_tty_t* handle) { - if (handle->flags & UV_HANDLE_TTY_RAW) { - uv_tty_queue_read_raw(loop, handle); - } else { - uv_tty_queue_read_line(loop, handle); - } -} - - -static const char* get_vt100_fn_key(DWORD code, char shift, char ctrl, - size_t* len) { -#define VK_CASE(vk, normal_str, shift_str, ctrl_str, shift_ctrl_str) \ - case (vk): \ - if (shift && ctrl) { \ - *len = sizeof shift_ctrl_str; \ - return "\033" shift_ctrl_str; \ - } else if (shift) { \ - *len = sizeof shift_str ; \ - return "\033" shift_str; \ - } else if (ctrl) { \ - *len = sizeof ctrl_str; \ - return "\033" ctrl_str; \ - } else { \ - *len = sizeof normal_str; \ - return "\033" normal_str; \ - } - - switch (code) { - /* These mappings are the same as Cygwin's. Unmodified and alt-modified */ - /* keypad keys comply with linux console, modifiers comply with xterm */ - /* modifier usage. F1..f12 and shift-f1..f10 comply with linux console, */ - /* f6..f12 with and without modifiers comply with rxvt. */ - VK_CASE(VK_INSERT, "[2~", "[2;2~", "[2;5~", "[2;6~") - VK_CASE(VK_END, "[4~", "[4;2~", "[4;5~", "[4;6~") - VK_CASE(VK_DOWN, "[B", "[1;2B", "[1;5B", "[1;6B") - VK_CASE(VK_NEXT, "[6~", "[6;2~", "[6;5~", "[6;6~") - VK_CASE(VK_LEFT, "[D", "[1;2D", "[1;5D", "[1;6D") - VK_CASE(VK_CLEAR, "[G", "[1;2G", "[1;5G", "[1;6G") - VK_CASE(VK_RIGHT, "[C", "[1;2C", "[1;5C", "[1;6C") - VK_CASE(VK_UP, "[A", "[1;2A", "[1;5A", "[1;6A") - VK_CASE(VK_HOME, "[1~", "[1;2~", "[1;5~", "[1;6~") - VK_CASE(VK_PRIOR, "[5~", "[5;2~", "[5;5~", "[5;6~") - VK_CASE(VK_DELETE, "[3~", "[3;2~", "[3;5~", "[3;6~") - VK_CASE(VK_NUMPAD0, "[2~", "[2;2~", "[2;5~", "[2;6~") - VK_CASE(VK_NUMPAD1, "[4~", "[4;2~", "[4;5~", "[4;6~") - VK_CASE(VK_NUMPAD2, "[B", "[1;2B", "[1;5B", "[1;6B") - VK_CASE(VK_NUMPAD3, "[6~", "[6;2~", "[6;5~", "[6;6~") - VK_CASE(VK_NUMPAD4, "[D", "[1;2D", "[1;5D", "[1;6D") - VK_CASE(VK_NUMPAD5, "[G", "[1;2G", "[1;5G", "[1;6G") - VK_CASE(VK_NUMPAD6, "[C", "[1;2C", "[1;5C", "[1;6C") - VK_CASE(VK_NUMPAD7, "[A", "[1;2A", "[1;5A", "[1;6A") - VK_CASE(VK_NUMPAD8, "[1~", "[1;2~", "[1;5~", "[1;6~") - VK_CASE(VK_NUMPAD9, "[5~", "[5;2~", "[5;5~", "[5;6~") - VK_CASE(VK_DECIMAL, "[3~", "[3;2~", "[3;5~", "[3;6~") - VK_CASE(VK_F1, "[[A", "[23~", "[11^", "[23^" ) - VK_CASE(VK_F2, "[[B", "[24~", "[12^", "[24^" ) - VK_CASE(VK_F3, "[[C", "[25~", "[13^", "[25^" ) - VK_CASE(VK_F4, "[[D", "[26~", "[14^", "[26^" ) - VK_CASE(VK_F5, "[[E", "[28~", "[15^", "[28^" ) - VK_CASE(VK_F6, "[17~", "[29~", "[17^", "[29^" ) - VK_CASE(VK_F7, "[18~", "[31~", "[18^", "[31^" ) - VK_CASE(VK_F8, "[19~", "[32~", "[19^", "[32^" ) - VK_CASE(VK_F9, "[20~", "[33~", "[20^", "[33^" ) - VK_CASE(VK_F10, "[21~", "[34~", "[21^", "[34^" ) - VK_CASE(VK_F11, "[23~", "[23$", "[23^", "[23@" ) - VK_CASE(VK_F12, "[24~", "[24$", "[24^", "[24@" ) - - default: - *len = 0; - return NULL; - } -#undef VK_CASE -} - - -void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req) { - /* Shortcut for handle->tty.rd.last_input_record.Event.KeyEvent. */ -#define KEV handle->tty.rd.last_input_record.Event.KeyEvent - - DWORD records_left, records_read; - uv_buf_t buf; - off_t buf_used; - - assert(handle->type == UV_TTY); - assert(handle->flags & UV_HANDLE_TTY_READABLE); - handle->flags &= ~UV_HANDLE_READ_PENDING; - - if (!(handle->flags & UV_HANDLE_READING) || - !(handle->flags & UV_HANDLE_TTY_RAW)) { - goto out; - } - - if (!REQ_SUCCESS(req)) { - /* An error occurred while waiting for the event. */ - if ((handle->flags & UV_HANDLE_READING)) { - handle->flags &= ~UV_HANDLE_READING; - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(GET_REQ_ERROR(req)), - &uv_null_buf_); - } - goto out; - } - - /* Fetch the number of events */ - if (!GetNumberOfConsoleInputEvents(handle->handle, &records_left)) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*)handle, - uv_translate_sys_error(GetLastError()), - &uv_null_buf_); - goto out; - } - - /* Windows sends a lot of events that we're not interested in, so buf */ - /* will be allocated on demand, when there's actually something to emit. */ - buf = uv_null_buf_; - buf_used = 0; - - while ((records_left > 0 || handle->tty.rd.last_key_len > 0) && - (handle->flags & UV_HANDLE_READING)) { - if (handle->tty.rd.last_key_len == 0) { - /* Read the next input record */ - if (!ReadConsoleInputW(handle->handle, - &handle->tty.rd.last_input_record, - 1, - &records_read)) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*) handle, - uv_translate_sys_error(GetLastError()), - &buf); - goto out; - } - records_left--; - - /* If the window was resized, recompute the virtual window size. This */ - /* will trigger a SIGWINCH signal if the window size changed in an */ - /* way that matters to libuv. */ - if (handle->tty.rd.last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) { - CONSOLE_SCREEN_BUFFER_INFO info; - - uv_sem_wait(&uv_tty_output_lock); - - if (uv_tty_output_handle != INVALID_HANDLE_VALUE && - GetConsoleScreenBufferInfo(uv_tty_output_handle, &info)) { - uv_tty_update_virtual_window(&info); - } - - uv_sem_post(&uv_tty_output_lock); - - continue; - } - - /* Ignore other events that are not key or resize events. */ - if (handle->tty.rd.last_input_record.EventType != KEY_EVENT) { - continue; - } - - /* Ignore keyup events, unless the left alt key was held and a valid */ - /* unicode character was emitted. */ - if (!KEV.bKeyDown && !(((KEV.dwControlKeyState & LEFT_ALT_PRESSED) || - KEV.wVirtualKeyCode==VK_MENU) && KEV.uChar.UnicodeChar != 0)) { - continue; - } - - /* Ignore keypresses to numpad number keys if the left alt is held */ - /* because the user is composing a character, or windows simulating */ - /* this. */ - if ((KEV.dwControlKeyState & LEFT_ALT_PRESSED) && - !(KEV.dwControlKeyState & ENHANCED_KEY) && - (KEV.wVirtualKeyCode == VK_INSERT || - KEV.wVirtualKeyCode == VK_END || - KEV.wVirtualKeyCode == VK_DOWN || - KEV.wVirtualKeyCode == VK_NEXT || - KEV.wVirtualKeyCode == VK_LEFT || - KEV.wVirtualKeyCode == VK_CLEAR || - KEV.wVirtualKeyCode == VK_RIGHT || - KEV.wVirtualKeyCode == VK_HOME || - KEV.wVirtualKeyCode == VK_UP || - KEV.wVirtualKeyCode == VK_PRIOR || - KEV.wVirtualKeyCode == VK_NUMPAD0 || - KEV.wVirtualKeyCode == VK_NUMPAD1 || - KEV.wVirtualKeyCode == VK_NUMPAD2 || - KEV.wVirtualKeyCode == VK_NUMPAD3 || - KEV.wVirtualKeyCode == VK_NUMPAD4 || - KEV.wVirtualKeyCode == VK_NUMPAD5 || - KEV.wVirtualKeyCode == VK_NUMPAD6 || - KEV.wVirtualKeyCode == VK_NUMPAD7 || - KEV.wVirtualKeyCode == VK_NUMPAD8 || - KEV.wVirtualKeyCode == VK_NUMPAD9)) { - continue; - } - - if (KEV.uChar.UnicodeChar != 0) { - int prefix_len, char_len; - - /* Character key pressed */ - if (KEV.uChar.UnicodeChar >= 0xD800 && - KEV.uChar.UnicodeChar < 0xDC00) { - /* UTF-16 high surrogate */ - handle->tty.rd.last_utf16_high_surrogate = KEV.uChar.UnicodeChar; - continue; - } - - /* Prefix with \u033 if alt was held, but alt was not used as part */ - /* a compose sequence. */ - if ((KEV.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) - && !(KEV.dwControlKeyState & (LEFT_CTRL_PRESSED | - RIGHT_CTRL_PRESSED)) && KEV.bKeyDown) { - handle->tty.rd.last_key[0] = '\033'; - prefix_len = 1; - } else { - prefix_len = 0; - } - - if (KEV.uChar.UnicodeChar >= 0xDC00 && - KEV.uChar.UnicodeChar < 0xE000) { - /* UTF-16 surrogate pair */ - WCHAR utf16_buffer[2] = { handle->tty.rd.last_utf16_high_surrogate, - KEV.uChar.UnicodeChar}; - char_len = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - 2, - &handle->tty.rd.last_key[prefix_len], - sizeof handle->tty.rd.last_key, - NULL, - NULL); - } else { - /* Single UTF-16 character */ - char_len = WideCharToMultiByte(CP_UTF8, - 0, - &KEV.uChar.UnicodeChar, - 1, - &handle->tty.rd.last_key[prefix_len], - sizeof handle->tty.rd.last_key, - NULL, - NULL); - } - - /* Whatever happened, the last character wasn't a high surrogate. */ - handle->tty.rd.last_utf16_high_surrogate = 0; - - /* If the utf16 character(s) couldn't be converted something must */ - /* be wrong. */ - if (!char_len) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*) handle, - uv_translate_sys_error(GetLastError()), - &buf); - goto out; - } - - handle->tty.rd.last_key_len = (unsigned char) (prefix_len + char_len); - handle->tty.rd.last_key_offset = 0; - continue; - - } else { - /* Function key pressed */ - const char* vt100; - size_t prefix_len, vt100_len; - - vt100 = get_vt100_fn_key(KEV.wVirtualKeyCode, - !!(KEV.dwControlKeyState & SHIFT_PRESSED), - !!(KEV.dwControlKeyState & ( - LEFT_CTRL_PRESSED | - RIGHT_CTRL_PRESSED)), - &vt100_len); - - /* If we were unable to map to a vt100 sequence, just ignore. */ - if (!vt100) { - continue; - } - - /* Prefix with \x033 when the alt key was held. */ - if (KEV.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { - handle->tty.rd.last_key[0] = '\033'; - prefix_len = 1; - } else { - prefix_len = 0; - } - - /* Copy the vt100 sequence to the handle buffer. */ - assert(prefix_len + vt100_len < sizeof handle->tty.rd.last_key); - memcpy(&handle->tty.rd.last_key[prefix_len], vt100, vt100_len); - - handle->tty.rd.last_key_len = (unsigned char) (prefix_len + vt100_len); - handle->tty.rd.last_key_offset = 0; - continue; - } - } else { - /* Copy any bytes left from the last keypress to the user buffer. */ - if (handle->tty.rd.last_key_offset < handle->tty.rd.last_key_len) { - /* Allocate a buffer if needed */ - if (buf_used == 0) { - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 1024, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf); - goto out; - } - assert(buf.base != NULL); - } - - buf.base[buf_used++] = handle->tty.rd.last_key[handle->tty.rd.last_key_offset++]; - - /* If the buffer is full, emit it */ - if ((size_t) buf_used == buf.len) { - handle->read_cb((uv_stream_t*) handle, buf_used, &buf); - buf = uv_null_buf_; - buf_used = 0; - } - - continue; - } - - /* Apply dwRepeat from the last input record. */ - if (--KEV.wRepeatCount > 0) { - handle->tty.rd.last_key_offset = 0; - continue; - } - - handle->tty.rd.last_key_len = 0; - continue; - } - } - - /* Send the buffer back to the user */ - if (buf_used > 0) { - handle->read_cb((uv_stream_t*) handle, buf_used, &buf); - } - - out: - /* Wait for more input events. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_tty_queue_read(loop, handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); - -#undef KEV -} - - - -void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req) { - uv_buf_t buf; - - assert(handle->type == UV_TTY); - assert(handle->flags & UV_HANDLE_TTY_READABLE); - - buf = handle->tty.rd.read_line_buffer; - - handle->flags &= ~UV_HANDLE_READ_PENDING; - handle->tty.rd.read_line_buffer = uv_null_buf_; - - if (!REQ_SUCCESS(req)) { - /* Read was not successful */ - if (handle->flags & UV_HANDLE_READING) { - /* Real error */ - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb((uv_stream_t*) handle, - uv_translate_sys_error(GET_REQ_ERROR(req)), - &buf); - } else { - /* The read was cancelled, or whatever we don't care */ - handle->read_cb((uv_stream_t*) handle, 0, &buf); - } - - } else { - if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { - /* Read successful */ - /* TODO: read unicode, convert to utf-8 */ - DWORD bytes = req->u.io.overlapped.InternalHigh; - handle->read_cb((uv_stream_t*) handle, bytes, &buf); - } else { - handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; - handle->read_cb((uv_stream_t*) handle, 0, &buf); - } - } - - /* Wait for more input events. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_tty_queue_read(loop, handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* req) { - assert(handle->type == UV_TTY); - assert(handle->flags & UV_HANDLE_TTY_READABLE); - - /* If the read_line_buffer member is zero, it must have been an raw read. */ - /* Otherwise it was a line-buffered read. */ - /* FIXME: This is quite obscure. Use a flag or something. */ - if (handle->tty.rd.read_line_buffer.len == 0) { - uv_process_tty_read_raw_req(loop, handle, req); - } else { - uv_process_tty_read_line_req(loop, handle, req); - } -} - - -int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, - uv_read_cb read_cb) { - uv_loop_t* loop = handle->loop; - - if (!(handle->flags & UV_HANDLE_TTY_READABLE)) { - return ERROR_INVALID_PARAMETER; - } - - handle->flags |= UV_HANDLE_READING; - INCREASE_ACTIVE_COUNT(loop, handle); - handle->read_cb = read_cb; - handle->alloc_cb = alloc_cb; - - /* If reading was stopped and then started again, there could still be a */ - /* read request pending. */ - if (handle->flags & UV_HANDLE_READ_PENDING) { - return 0; - } - - /* Maybe the user stopped reading half-way while processing key events. */ - /* Short-circuit if this could be the case. */ - if (handle->tty.rd.last_key_len > 0) { - SET_REQ_SUCCESS(&handle->read_req); - uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req); - /* Make sure no attempt is made to insert it again until it's handled. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - return 0; - } - - uv_tty_queue_read(loop, handle); - - return 0; -} - - -int uv_tty_read_stop(uv_tty_t* handle) { - INPUT_RECORD record; - DWORD written, err; - - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(handle->loop, handle); - - if (!(handle->flags & UV_HANDLE_READ_PENDING)) - return 0; - - if (handle->flags & UV_HANDLE_TTY_RAW) { - /* Cancel raw read */ - /* Write some bullshit event to force the console wait to return. */ - memset(&record, 0, sizeof record); - if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) { - return GetLastError(); - } - } else if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { - /* Cancel line-buffered read if not already pending */ - err = uv__cancel_read_console(handle); - if (err) - return err; - - handle->flags |= UV_HANDLE_CANCELLATION_PENDING; - } - - return 0; -} - -static int uv__cancel_read_console(uv_tty_t* handle) { - HANDLE active_screen_buffer = INVALID_HANDLE_VALUE; - INPUT_RECORD record; - DWORD written; - DWORD err = 0; - LONG status; - - assert(!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)); - - /* Hold the output lock during the cancellation, to ensure that further - writes don't interfere with the screen state. It will be the ReadConsole - thread's responsibility to release the lock. */ - uv_sem_wait(&uv_tty_output_lock); - status = InterlockedExchange(&uv__read_console_status, TRAP_REQUESTED); - if (status != IN_PROGRESS) { - /* Either we have managed to set a trap for the other thread before - ReadConsole is called, or ReadConsole has returned because the user - has pressed ENTER. In either case, there is nothing else to do. */ - uv_sem_post(&uv_tty_output_lock); - return 0; - } - - /* Save screen state before sending the VK_RETURN event */ - active_screen_buffer = CreateFileA("conout$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (active_screen_buffer != INVALID_HANDLE_VALUE && - GetConsoleScreenBufferInfo(active_screen_buffer, - &uv__saved_screen_state)) { - InterlockedOr(&uv__restore_screen_state, 1); - } - - /* Write enter key event to force the console wait to return. */ - record.EventType = KEY_EVENT; - record.Event.KeyEvent.bKeyDown = TRUE; - record.Event.KeyEvent.wRepeatCount = 1; - record.Event.KeyEvent.wVirtualKeyCode = VK_RETURN; - record.Event.KeyEvent.wVirtualScanCode = - MapVirtualKeyW(VK_RETURN, MAPVK_VK_TO_VSC); - record.Event.KeyEvent.uChar.UnicodeChar = L'\r'; - record.Event.KeyEvent.dwControlKeyState = 0; - if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) - err = GetLastError(); - - if (active_screen_buffer != INVALID_HANDLE_VALUE) - CloseHandle(active_screen_buffer); - - return err; -} - - -static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) { - int old_virtual_width = uv_tty_virtual_width; - int old_virtual_height = uv_tty_virtual_height; - - uv_tty_virtual_width = info->dwSize.X; - uv_tty_virtual_height = info->srWindow.Bottom - info->srWindow.Top + 1; - - /* Recompute virtual window offset row. */ - if (uv_tty_virtual_offset == -1) { - uv_tty_virtual_offset = info->dwCursorPosition.Y; - } else if (uv_tty_virtual_offset < info->dwCursorPosition.Y - - uv_tty_virtual_height + 1) { - /* If suddenly find the cursor outside of the virtual window, it must */ - /* have somehow scrolled. Update the virtual window offset. */ - uv_tty_virtual_offset = info->dwCursorPosition.Y - - uv_tty_virtual_height + 1; - } - if (uv_tty_virtual_offset + uv_tty_virtual_height > info->dwSize.Y) { - uv_tty_virtual_offset = info->dwSize.Y - uv_tty_virtual_height; - } - if (uv_tty_virtual_offset < 0) { - uv_tty_virtual_offset = 0; - } - - /* If the virtual window size changed, emit a SIGWINCH signal. Don't emit */ - /* if this was the first time the virtual window size was computed. */ - if (old_virtual_width != -1 && old_virtual_height != -1 && - (uv_tty_virtual_width != old_virtual_width || - uv_tty_virtual_height != old_virtual_height)) { - uv__signal_dispatch(SIGWINCH); - } -} - - -static COORD uv_tty_make_real_coord(uv_tty_t* handle, - CONSOLE_SCREEN_BUFFER_INFO* info, int x, unsigned char x_relative, int y, - unsigned char y_relative) { - COORD result; - - uv_tty_update_virtual_window(info); - - /* Adjust y position */ - if (y_relative) { - y = info->dwCursorPosition.Y + y; - } else { - y = uv_tty_virtual_offset + y; - } - /* Clip y to virtual client rectangle */ - if (y < uv_tty_virtual_offset) { - y = uv_tty_virtual_offset; - } else if (y >= uv_tty_virtual_offset + uv_tty_virtual_height) { - y = uv_tty_virtual_offset + uv_tty_virtual_height - 1; - } - - /* Adjust x */ - if (x_relative) { - x = info->dwCursorPosition.X + x; - } - /* Clip x */ - if (x < 0) { - x = 0; - } else if (x >= uv_tty_virtual_width) { - x = uv_tty_virtual_width - 1; - } - - result.X = (unsigned short) x; - result.Y = (unsigned short) y; - return result; -} - - -static int uv_tty_emit_text(uv_tty_t* handle, WCHAR buffer[], DWORD length, - DWORD* error) { - DWORD written; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (!WriteConsoleW(handle->handle, - (void*) buffer, - length, - &written, - NULL)) { - *error = GetLastError(); - return -1; - } - - return 0; -} - - -static int uv_tty_move_caret(uv_tty_t* handle, int x, unsigned char x_relative, - int y, unsigned char y_relative, DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - COORD pos; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - retry: - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - } - - pos = uv_tty_make_real_coord(handle, &info, x, x_relative, y, y_relative); - - if (!SetConsoleCursorPosition(handle->handle, pos)) { - if (GetLastError() == ERROR_INVALID_PARAMETER) { - /* The console may be resized - retry */ - goto retry; - } else { - *error = GetLastError(); - return -1; - } - } - - return 0; -} - - -static int uv_tty_reset(uv_tty_t* handle, DWORD* error) { - const COORD origin = {0, 0}; - const WORD char_attrs = uv_tty_default_text_attributes; - CONSOLE_SCREEN_BUFFER_INFO info; - DWORD count, written; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - /* Reset original text attributes. */ - if (!SetConsoleTextAttribute(handle->handle, char_attrs)) { - *error = GetLastError(); - return -1; - } - - /* Move the cursor position to (0, 0). */ - if (!SetConsoleCursorPosition(handle->handle, origin)) { - *error = GetLastError(); - return -1; - } - - /* Clear the screen buffer. */ - retry: - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - count = info.dwSize.X * info.dwSize.Y; - - if (!(FillConsoleOutputCharacterW(handle->handle, - L'\x20', - count, - origin, - &written) && - FillConsoleOutputAttribute(handle->handle, - char_attrs, - written, - origin, - &written))) { - if (GetLastError() == ERROR_INVALID_PARAMETER) { - /* The console may be resized - retry */ - goto retry; - } else { - *error = GetLastError(); - return -1; - } - } - - /* Move the virtual window up to the top. */ - uv_tty_virtual_offset = 0; - uv_tty_update_virtual_window(&info); - - return 0; -} - - -static int uv_tty_clear(uv_tty_t* handle, int dir, char entire_screen, - DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - COORD start, end; - DWORD count, written; - - int x1, x2, y1, y2; - int x1r, x2r, y1r, y2r; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (dir == 0) { - /* Clear from current position */ - x1 = 0; - x1r = 1; - } else { - /* Clear from column 0 */ - x1 = 0; - x1r = 0; - } - - if (dir == 1) { - /* Clear to current position */ - x2 = 0; - x2r = 1; - } else { - /* Clear to end of row. We pretend the console is 65536 characters wide, */ - /* uv_tty_make_real_coord will clip it to the actual console width. */ - x2 = 0xffff; - x2r = 0; - } - - if (!entire_screen) { - /* Stay on our own row */ - y1 = y2 = 0; - y1r = y2r = 1; - } else { - /* Apply columns direction to row */ - y1 = x1; - y1r = x1r; - y2 = x2; - y2r = x2r; - } - - retry: - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - start = uv_tty_make_real_coord(handle, &info, x1, x1r, y1, y1r); - end = uv_tty_make_real_coord(handle, &info, x2, x2r, y2, y2r); - count = (end.Y * info.dwSize.X + end.X) - - (start.Y * info.dwSize.X + start.X) + 1; - - if (!(FillConsoleOutputCharacterW(handle->handle, - L'\x20', - count, - start, - &written) && - FillConsoleOutputAttribute(handle->handle, - info.wAttributes, - written, - start, - &written))) { - if (GetLastError() == ERROR_INVALID_PARAMETER) { - /* The console may be resized - retry */ - goto retry; - } else { - *error = GetLastError(); - return -1; - } - } - - return 0; -} - -#define FLIP_FGBG \ - do { \ - WORD fg = info.wAttributes & 0xF; \ - WORD bg = info.wAttributes & 0xF0; \ - info.wAttributes &= 0xFF00; \ - info.wAttributes |= fg << 4; \ - info.wAttributes |= bg >> 4; \ - } while (0) - -static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) { - unsigned short argc = handle->tty.wr.ansi_csi_argc; - unsigned short* argv = handle->tty.wr.ansi_csi_argv; - int i; - CONSOLE_SCREEN_BUFFER_INFO info; - - char fg_color = -1, bg_color = -1; - char fg_bright = -1, bg_bright = -1; - char inverse = -1; - - if (argc == 0) { - /* Reset mode */ - fg_color = uv_tty_default_fg_color; - bg_color = uv_tty_default_bg_color; - fg_bright = uv_tty_default_fg_bright; - bg_bright = uv_tty_default_bg_bright; - inverse = uv_tty_default_inverse; - } - - for (i = 0; i < argc; i++) { - short arg = argv[i]; - - if (arg == 0) { - /* Reset mode */ - fg_color = uv_tty_default_fg_color; - bg_color = uv_tty_default_bg_color; - fg_bright = uv_tty_default_fg_bright; - bg_bright = uv_tty_default_bg_bright; - inverse = uv_tty_default_inverse; - - } else if (arg == 1) { - /* Foreground bright on */ - fg_bright = 1; - - } else if (arg == 2) { - /* Both bright off */ - fg_bright = 0; - bg_bright = 0; - - } else if (arg == 5) { - /* Background bright on */ - bg_bright = 1; - - } else if (arg == 7) { - /* Inverse: on */ - inverse = 1; - - } else if (arg == 21 || arg == 22) { - /* Foreground bright off */ - fg_bright = 0; - - } else if (arg == 25) { - /* Background bright off */ - bg_bright = 0; - - } else if (arg == 27) { - /* Inverse: off */ - inverse = 0; - - } else if (arg >= 30 && arg <= 37) { - /* Set foreground color */ - fg_color = arg - 30; - - } else if (arg == 39) { - /* Default text color */ - fg_color = uv_tty_default_fg_color; - fg_bright = uv_tty_default_fg_bright; - - } else if (arg >= 40 && arg <= 47) { - /* Set background color */ - bg_color = arg - 40; - - } else if (arg == 49) { - /* Default background color */ - bg_color = uv_tty_default_bg_color; - bg_bright = uv_tty_default_bg_bright; - - } else if (arg >= 90 && arg <= 97) { - /* Set bold foreground color */ - fg_bright = 1; - fg_color = arg - 90; - - } else if (arg >= 100 && arg <= 107) { - /* Set bold background color */ - bg_bright = 1; - bg_color = arg - 100; - - } - } - - if (fg_color == -1 && bg_color == -1 && fg_bright == -1 && - bg_bright == -1 && inverse == -1) { - /* Nothing changed */ - return 0; - } - - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - if ((info.wAttributes & COMMON_LVB_REVERSE_VIDEO) > 0) { - FLIP_FGBG; - } - - if (fg_color != -1) { - info.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); - if (fg_color & 1) info.wAttributes |= FOREGROUND_RED; - if (fg_color & 2) info.wAttributes |= FOREGROUND_GREEN; - if (fg_color & 4) info.wAttributes |= FOREGROUND_BLUE; - } - - if (fg_bright != -1) { - if (fg_bright) { - info.wAttributes |= FOREGROUND_INTENSITY; - } else { - info.wAttributes &= ~FOREGROUND_INTENSITY; - } - } - - if (bg_color != -1) { - info.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE); - if (bg_color & 1) info.wAttributes |= BACKGROUND_RED; - if (bg_color & 2) info.wAttributes |= BACKGROUND_GREEN; - if (bg_color & 4) info.wAttributes |= BACKGROUND_BLUE; - } - - if (bg_bright != -1) { - if (bg_bright) { - info.wAttributes |= BACKGROUND_INTENSITY; - } else { - info.wAttributes &= ~BACKGROUND_INTENSITY; - } - } - - if (inverse != -1) { - if (inverse) { - info.wAttributes |= COMMON_LVB_REVERSE_VIDEO; - } else { - info.wAttributes &= ~COMMON_LVB_REVERSE_VIDEO; - } - } - - if ((info.wAttributes & COMMON_LVB_REVERSE_VIDEO) > 0) { - FLIP_FGBG; - } - - if (!SetConsoleTextAttribute(handle->handle, info.wAttributes)) { - *error = GetLastError(); - return -1; - } - - return 0; -} - - -static int uv_tty_save_state(uv_tty_t* handle, unsigned char save_attributes, - DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - uv_tty_update_virtual_window(&info); - - handle->tty.wr.saved_position.X = info.dwCursorPosition.X; - handle->tty.wr.saved_position.Y = info.dwCursorPosition.Y - uv_tty_virtual_offset; - handle->flags |= UV_HANDLE_TTY_SAVED_POSITION; - - if (save_attributes) { - handle->tty.wr.saved_attributes = info.wAttributes & - (FOREGROUND_INTENSITY | BACKGROUND_INTENSITY); - handle->flags |= UV_HANDLE_TTY_SAVED_ATTRIBUTES; - } - - return 0; -} - - -static int uv_tty_restore_state(uv_tty_t* handle, - unsigned char restore_attributes, DWORD* error) { - CONSOLE_SCREEN_BUFFER_INFO info; - WORD new_attributes; - - if (*error != ERROR_SUCCESS) { - return -1; - } - - if (handle->flags & UV_HANDLE_TTY_SAVED_POSITION) { - if (uv_tty_move_caret(handle, - handle->tty.wr.saved_position.X, - 0, - handle->tty.wr.saved_position.Y, - 0, - error) != 0) { - return -1; - } - } - - if (restore_attributes && - (handle->flags & UV_HANDLE_TTY_SAVED_ATTRIBUTES)) { - if (!GetConsoleScreenBufferInfo(handle->handle, &info)) { - *error = GetLastError(); - return -1; - } - - new_attributes = info.wAttributes; - new_attributes &= ~(FOREGROUND_INTENSITY | BACKGROUND_INTENSITY); - new_attributes |= handle->tty.wr.saved_attributes; - - if (!SetConsoleTextAttribute(handle->handle, new_attributes)) { - *error = GetLastError(); - return -1; - } - } - - return 0; -} - -static int uv_tty_set_cursor_visibility(uv_tty_t* handle, - BOOL visible, - DWORD* error) { - CONSOLE_CURSOR_INFO cursor_info; - - if (!GetConsoleCursorInfo(handle->handle, &cursor_info)) { - *error = GetLastError(); - return -1; - } - - cursor_info.bVisible = visible; - - if (!SetConsoleCursorInfo(handle->handle, &cursor_info)) { - *error = GetLastError(); - return -1; - } - - return 0; -} - -static int uv_tty_write_bufs(uv_tty_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - DWORD* error) { - /* We can only write 8k characters at a time. Windows can't handle */ - /* much more characters in a single console write anyway. */ - WCHAR utf16_buf[MAX_CONSOLE_CHAR]; - WCHAR* utf16_buffer; - DWORD utf16_buf_used = 0; - unsigned int i, len, max_len, pos; - int allocate = 0; - -#define FLUSH_TEXT() \ - do { \ - pos = 0; \ - do { \ - len = utf16_buf_used - pos; \ - if (len > MAX_CONSOLE_CHAR) \ - len = MAX_CONSOLE_CHAR; \ - uv_tty_emit_text(handle, &utf16_buffer[pos], len, error); \ - pos += len; \ - } while (pos < utf16_buf_used); \ - if (allocate) { \ - uv__free(utf16_buffer); \ - allocate = 0; \ - utf16_buffer = utf16_buf; \ - } \ - utf16_buf_used = 0; \ - } while (0) - -#define ENSURE_BUFFER_SPACE(wchars_needed) \ - if (wchars_needed > ARRAY_SIZE(utf16_buf) - utf16_buf_used) { \ - FLUSH_TEXT(); \ - } - - /* Cache for fast access */ - unsigned char utf8_bytes_left = handle->tty.wr.utf8_bytes_left; - unsigned int utf8_codepoint = handle->tty.wr.utf8_codepoint; - unsigned char previous_eol = handle->tty.wr.previous_eol; - unsigned char ansi_parser_state = handle->tty.wr.ansi_parser_state; - - /* Store the error here. If we encounter an error, stop trying to do i/o */ - /* but keep parsing the buffer so we leave the parser in a consistent */ - /* state. */ - *error = ERROR_SUCCESS; - - utf16_buffer = utf16_buf; - - uv_sem_wait(&uv_tty_output_lock); - - for (i = 0; i < nbufs; i++) { - uv_buf_t buf = bufs[i]; - unsigned int j; - - if (uv__vterm_state == UV_SUPPORTED && buf.len > 0) { - utf16_buf_used = MultiByteToWideChar(CP_UTF8, - 0, - buf.base, - buf.len, - NULL, - 0); - - if (utf16_buf_used == 0) { - *error = GetLastError(); - break; - } - - max_len = (utf16_buf_used + 1) * sizeof(WCHAR); - allocate = max_len > MAX_CONSOLE_CHAR; - if (allocate) - utf16_buffer = uv__malloc(max_len); - if (!MultiByteToWideChar(CP_UTF8, - 0, - buf.base, - buf.len, - utf16_buffer, - utf16_buf_used)) { - if (allocate) - uv__free(utf16_buffer); - *error = GetLastError(); - break; - } - - FLUSH_TEXT(); - - continue; - } - - for (j = 0; j < buf.len; j++) { - unsigned char c = buf.base[j]; - - /* Run the character through the utf8 decoder We happily accept non */ - /* shortest form encodings and invalid code points - there's no real */ - /* harm that can be done. */ - if (utf8_bytes_left == 0) { - /* Read utf-8 start byte */ - DWORD first_zero_bit; - unsigned char not_c = ~c; -#ifdef _MSC_VER /* msvc */ - if (_BitScanReverse(&first_zero_bit, not_c)) { -#else /* assume gcc */ - if (c != 0) { - first_zero_bit = (sizeof(int) * 8) - 1 - __builtin_clz(not_c); -#endif - if (first_zero_bit == 7) { - /* Ascii - pass right through */ - utf8_codepoint = (unsigned int) c; - - } else if (first_zero_bit <= 5) { - /* Multibyte sequence */ - utf8_codepoint = (0xff >> (8 - first_zero_bit)) & c; - utf8_bytes_left = (char) (6 - first_zero_bit); - - } else { - /* Invalid continuation */ - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - } - - } else { - /* 0xff -- invalid */ - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - } - - } else if ((c & 0xc0) == 0x80) { - /* Valid continuation of utf-8 multibyte sequence */ - utf8_bytes_left--; - utf8_codepoint <<= 6; - utf8_codepoint |= ((unsigned int) c & 0x3f); - - } else { - /* Start byte where continuation was expected. */ - utf8_bytes_left = 0; - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - /* Patch buf offset so this character will be parsed again as a */ - /* start byte. */ - j--; - } - - /* Maybe we need to parse more bytes to find a character. */ - if (utf8_bytes_left != 0) { - continue; - } - - /* Parse vt100/ansi escape codes */ - if (ansi_parser_state == ANSI_NORMAL) { - switch (utf8_codepoint) { - case '\033': - ansi_parser_state = ANSI_ESCAPE_SEEN; - continue; - - case 0233: - ansi_parser_state = ANSI_CSI; - handle->tty.wr.ansi_csi_argc = 0; - continue; - } - - } else if (ansi_parser_state == ANSI_ESCAPE_SEEN) { - switch (utf8_codepoint) { - case '[': - ansi_parser_state = ANSI_CSI; - handle->tty.wr.ansi_csi_argc = 0; - continue; - - case '^': - case '_': - case 'P': - case ']': - /* Not supported, but we'll have to parse until we see a stop */ - /* code, e.g. ESC \ or BEL. */ - ansi_parser_state = ANSI_ST_CONTROL; - continue; - - case '\033': - /* Ignore double escape. */ - continue; - - case 'c': - /* Full console reset. */ - FLUSH_TEXT(); - uv_tty_reset(handle, error); - ansi_parser_state = ANSI_NORMAL; - continue; - - case '7': - /* Save the cursor position and text attributes. */ - FLUSH_TEXT(); - uv_tty_save_state(handle, 1, error); - ansi_parser_state = ANSI_NORMAL; - continue; - - case '8': - /* Restore the cursor position and text attributes */ - FLUSH_TEXT(); - uv_tty_restore_state(handle, 1, error); - ansi_parser_state = ANSI_NORMAL; - continue; - - default: - if (utf8_codepoint >= '@' && utf8_codepoint <= '_') { - /* Single-char control. */ - ansi_parser_state = ANSI_NORMAL; - continue; - } else { - /* Invalid - proceed as normal, */ - ansi_parser_state = ANSI_NORMAL; - } - } - - } else if (ansi_parser_state & ANSI_CSI) { - if (!(ansi_parser_state & ANSI_IGNORE)) { - if (utf8_codepoint >= '0' && utf8_codepoint <= '9') { - /* Parsing a numerical argument */ - - if (!(ansi_parser_state & ANSI_IN_ARG)) { - /* We were not currently parsing a number */ - - /* Check for too many arguments */ - if (handle->tty.wr.ansi_csi_argc >= ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) { - ansi_parser_state |= ANSI_IGNORE; - continue; - } - - ansi_parser_state |= ANSI_IN_ARG; - handle->tty.wr.ansi_csi_argc++; - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = - (unsigned short) utf8_codepoint - '0'; - continue; - } else { - /* We were already parsing a number. Parse next digit. */ - uint32_t value = 10 * - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1]; - - /* Check for overflow. */ - if (value > UINT16_MAX) { - ansi_parser_state |= ANSI_IGNORE; - continue; - } - - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = - (unsigned short) value + (utf8_codepoint - '0'); - continue; - } - - } else if (utf8_codepoint == ';') { - /* Denotes the end of an argument. */ - if (ansi_parser_state & ANSI_IN_ARG) { - ansi_parser_state &= ~ANSI_IN_ARG; - continue; - - } else { - /* If ANSI_IN_ARG is not set, add another argument and */ - /* default it to 0. */ - /* Check for too many arguments */ - if (handle->tty.wr.ansi_csi_argc >= ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) { - ansi_parser_state |= ANSI_IGNORE; - continue; - } - - handle->tty.wr.ansi_csi_argc++; - handle->tty.wr.ansi_csi_argv[handle->tty.wr.ansi_csi_argc - 1] = 0; - continue; - } - - } else if (utf8_codepoint == '?' && !(ansi_parser_state & ANSI_IN_ARG) && - handle->tty.wr.ansi_csi_argc == 0) { - /* Ignores '?' if it is the first character after CSI[ */ - /* This is an extension character from the VT100 codeset */ - /* that is supported and used by most ANSI terminals today. */ - continue; - - } else if (utf8_codepoint >= '@' && utf8_codepoint <= '~' && - (handle->tty.wr.ansi_csi_argc > 0 || utf8_codepoint != '[')) { - int x, y, d; - - /* Command byte */ - switch (utf8_codepoint) { - case 'A': - /* cursor up */ - FLUSH_TEXT(); - y = -(handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1); - uv_tty_move_caret(handle, 0, 1, y, 1, error); - break; - - case 'B': - /* cursor down */ - FLUSH_TEXT(); - y = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1; - uv_tty_move_caret(handle, 0, 1, y, 1, error); - break; - - case 'C': - /* cursor forward */ - FLUSH_TEXT(); - x = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1; - uv_tty_move_caret(handle, x, 1, 0, 1, error); - break; - - case 'D': - /* cursor back */ - FLUSH_TEXT(); - x = -(handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1); - uv_tty_move_caret(handle, x, 1, 0, 1, error); - break; - - case 'E': - /* cursor next line */ - FLUSH_TEXT(); - y = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1; - uv_tty_move_caret(handle, 0, 0, y, 1, error); - break; - - case 'F': - /* cursor previous line */ - FLUSH_TEXT(); - y = -(handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 1); - uv_tty_move_caret(handle, 0, 0, y, 1, error); - break; - - case 'G': - /* cursor horizontal move absolute */ - FLUSH_TEXT(); - x = (handle->tty.wr.ansi_csi_argc >= 1 && handle->tty.wr.ansi_csi_argv[0]) - ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0; - uv_tty_move_caret(handle, x, 0, 0, 1, error); - break; - - case 'H': - case 'f': - /* cursor move absolute */ - FLUSH_TEXT(); - y = (handle->tty.wr.ansi_csi_argc >= 1 && handle->tty.wr.ansi_csi_argv[0]) - ? handle->tty.wr.ansi_csi_argv[0] - 1 : 0; - x = (handle->tty.wr.ansi_csi_argc >= 2 && handle->tty.wr.ansi_csi_argv[1]) - ? handle->tty.wr.ansi_csi_argv[1] - 1 : 0; - uv_tty_move_caret(handle, x, 0, y, 0, error); - break; - - case 'J': - /* Erase screen */ - FLUSH_TEXT(); - d = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 0; - if (d >= 0 && d <= 2) { - uv_tty_clear(handle, d, 1, error); - } - break; - - case 'K': - /* Erase line */ - FLUSH_TEXT(); - d = handle->tty.wr.ansi_csi_argc ? handle->tty.wr.ansi_csi_argv[0] : 0; - if (d >= 0 && d <= 2) { - uv_tty_clear(handle, d, 0, error); - } - break; - - case 'm': - /* Set style */ - FLUSH_TEXT(); - uv_tty_set_style(handle, error); - break; - - case 's': - /* Save the cursor position. */ - FLUSH_TEXT(); - uv_tty_save_state(handle, 0, error); - break; - - case 'u': - /* Restore the cursor position */ - FLUSH_TEXT(); - uv_tty_restore_state(handle, 0, error); - break; - - case 'l': - /* Hide the cursor */ - if (handle->tty.wr.ansi_csi_argc == 1 && - handle->tty.wr.ansi_csi_argv[0] == 25) { - FLUSH_TEXT(); - uv_tty_set_cursor_visibility(handle, 0, error); - } - break; - - case 'h': - /* Show the cursor */ - if (handle->tty.wr.ansi_csi_argc == 1 && - handle->tty.wr.ansi_csi_argv[0] == 25) { - FLUSH_TEXT(); - uv_tty_set_cursor_visibility(handle, 1, error); - } - break; - } - - /* Sequence ended - go back to normal state. */ - ansi_parser_state = ANSI_NORMAL; - continue; - - } else { - /* We don't support commands that use private mode characters or */ - /* intermediaries. Ignore the rest of the sequence. */ - ansi_parser_state |= ANSI_IGNORE; - continue; - } - } else { - /* We're ignoring this command. Stop only on command character. */ - if (utf8_codepoint >= '@' && utf8_codepoint <= '~') { - ansi_parser_state = ANSI_NORMAL; - } - continue; - } - - } else if (ansi_parser_state & ANSI_ST_CONTROL) { - /* Unsupported control code */ - /* Ignore everything until we see BEL or ESC \ */ - if (ansi_parser_state & ANSI_IN_STRING) { - if (!(ansi_parser_state & ANSI_BACKSLASH_SEEN)) { - if (utf8_codepoint == '"') { - ansi_parser_state &= ~ANSI_IN_STRING; - } else if (utf8_codepoint == '\\') { - ansi_parser_state |= ANSI_BACKSLASH_SEEN; - } - } else { - ansi_parser_state &= ~ANSI_BACKSLASH_SEEN; - } - } else { - if (utf8_codepoint == '\007' || (utf8_codepoint == '\\' && - (ansi_parser_state & ANSI_ESCAPE_SEEN))) { - /* End of sequence */ - ansi_parser_state = ANSI_NORMAL; - } else if (utf8_codepoint == '\033') { - /* Escape character */ - ansi_parser_state |= ANSI_ESCAPE_SEEN; - } else if (utf8_codepoint == '"') { - /* String starting */ - ansi_parser_state |= ANSI_IN_STRING; - ansi_parser_state &= ~ANSI_ESCAPE_SEEN; - ansi_parser_state &= ~ANSI_BACKSLASH_SEEN; - } else { - ansi_parser_state &= ~ANSI_ESCAPE_SEEN; - } - } - continue; - } else { - /* Inconsistent state */ - abort(); - } - - /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the */ - /* windows console doesn't really support UTF-16, so just emit the */ - /* replacement character. */ - if (utf8_codepoint > 0xffff) { - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - } - - if (utf8_codepoint == 0x0a || utf8_codepoint == 0x0d) { - /* EOL conversion - emit \r\n when we see \n. */ - - if (utf8_codepoint == 0x0a && previous_eol != 0x0d) { - /* \n was not preceded by \r; print \r\n. */ - ENSURE_BUFFER_SPACE(2); - utf16_buf[utf16_buf_used++] = L'\r'; - utf16_buf[utf16_buf_used++] = L'\n'; - } else if (utf8_codepoint == 0x0d && previous_eol == 0x0a) { - /* \n was followed by \r; do not print the \r, since */ - /* the source was either \r\n\r (so the second \r is */ - /* redundant) or was \n\r (so the \n was processed */ - /* by the last case and an \r automatically inserted). */ - } else { - /* \r without \n; print \r as-is. */ - ENSURE_BUFFER_SPACE(1); - utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint; - } - - previous_eol = (char) utf8_codepoint; - - } else if (utf8_codepoint <= 0xffff) { - /* Encode character into utf-16 buffer. */ - ENSURE_BUFFER_SPACE(1); - utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint; - previous_eol = 0; - } - } - } - - /* Flush remaining characters */ - FLUSH_TEXT(); - - /* Copy cached values back to struct. */ - handle->tty.wr.utf8_bytes_left = utf8_bytes_left; - handle->tty.wr.utf8_codepoint = utf8_codepoint; - handle->tty.wr.previous_eol = previous_eol; - handle->tty.wr.ansi_parser_state = ansi_parser_state; - - uv_sem_post(&uv_tty_output_lock); - - if (*error == STATUS_SUCCESS) { - return 0; - } else { - return -1; - } - -#undef FLUSH_TEXT -} - - -int uv_tty_write(uv_loop_t* loop, - uv_write_t* req, - uv_tty_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb) { - DWORD error; - - UV_REQ_INIT(req, UV_WRITE); - req->handle = (uv_stream_t*) handle; - req->cb = cb; - - handle->reqs_pending++; - handle->stream.conn.write_reqs_pending++; - REGISTER_HANDLE_REQ(loop, handle, req); - - req->u.io.queued_bytes = 0; - - if (!uv_tty_write_bufs(handle, bufs, nbufs, &error)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_ERROR(req, error); - } - - uv_insert_pending_req(loop, (uv_req_t*) req); - - return 0; -} - - -int uv__tty_try_write(uv_tty_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs) { - DWORD error; - - if (handle->stream.conn.write_reqs_pending > 0) - return UV_EAGAIN; - - if (uv_tty_write_bufs(handle, bufs, nbufs, &error)) - return uv_translate_sys_error(error); - - return uv__count_bufs(bufs, nbufs); -} - - -void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, - uv_write_t* req) { - int err; - - handle->write_queue_size -= req->u.io.queued_bytes; - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (req->cb) { - err = GET_REQ_ERROR(req); - req->cb(req, uv_translate_sys_error(err)); - } - - handle->stream.conn.write_reqs_pending--; - if (handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*)handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_tty_close(uv_tty_t* handle) { - assert(handle->u.fd == -1 || handle->u.fd > 2); - if (handle->u.fd == -1) - CloseHandle(handle->handle); - else - close(handle->u.fd); - - if (handle->flags & UV_HANDLE_READING) - uv_tty_read_stop(handle); - - handle->u.fd = -1; - handle->handle = INVALID_HANDLE_VALUE; - handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); - uv__handle_closing(handle); - - if (handle->reqs_pending == 0) { - uv_want_endgame(handle->loop, (uv_handle_t*) handle); - } -} - - -void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) { - if (!(handle->flags & UV_HANDLE_TTY_READABLE) && - handle->stream.conn.shutdown_req != NULL && - handle->stream.conn.write_reqs_pending == 0) { - UNREGISTER_HANDLE_REQ(loop, handle, handle->stream.conn.shutdown_req); - - /* TTY shutdown is really just a no-op */ - if (handle->stream.conn.shutdown_req->cb) { - if (handle->flags & UV__HANDLE_CLOSING) { - handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, UV_ECANCELED); - } else { - handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, 0); - } - } - - handle->stream.conn.shutdown_req = NULL; - - DECREASE_PENDING_REQ_COUNT(handle); - return; - } - - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - /* The wait handle used for raw reading should be unregistered when the */ - /* wait callback runs. */ - assert(!(handle->flags & UV_HANDLE_TTY_READABLE) || - handle->tty.rd.read_raw_wait == NULL); - - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -/* TODO: remove me */ -void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle, - uv_req_t* raw_req) { - abort(); -} - - -/* TODO: remove me */ -void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle, - uv_connect_t* req) { - abort(); -} - - -int uv_tty_reset_mode(void) { - /* Not necessary to do anything. */ - return 0; -} - -/* Determine whether or not this version of windows supports - * proper ANSI color codes. Should be supported as of windows - * 10 version 1511, build number 10.0.10586. - */ -static void uv__determine_vterm_state(HANDLE handle) { - DWORD dwMode = 0; - - if (!GetConsoleMode(handle, &dwMode)) { - uv__vterm_state = UV_UNSUPPORTED; - return; - } - - dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; - if (!SetConsoleMode(handle, dwMode)) { - uv__vterm_state = UV_UNSUPPORTED; - return; - } - - uv__vterm_state = UV_SUPPORTED; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/udp.c b/lib/ESPiLight/pilight/libs/libuv/win/udp.c deleted file mode 100644 index 2fd15cf..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/udp.c +++ /dev/null @@ -1,926 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include - -#include "uv.h" -#include "internal.h" -#include "handle-inl.h" -#include "stream-inl.h" -#include "req-inl.h" - - -/* - * Threshold of active udp streams for which to preallocate udp read buffers. - */ -const unsigned int uv_active_udp_streams_threshold = 0; - -/* A zero-size buffer for use by uv_udp_read */ -static char uv_zero_[] = ""; - -int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen) { - int result; - - if (handle->socket == INVALID_SOCKET) { - return UV_EINVAL; - } - - result = getsockname(handle->socket, name, namelen); - if (result != 0) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket, - int family) { - DWORD yes = 1; - WSAPROTOCOL_INFOW info; - int opt_len; - - if (handle->socket != INVALID_SOCKET) - return UV_EBUSY; - - /* Set the socket to nonblocking mode */ - if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) { - return WSAGetLastError(); - } - - /* Make the socket non-inheritable */ - if (!SetHandleInformation((HANDLE)socket, HANDLE_FLAG_INHERIT, 0)) { - return GetLastError(); - } - - /* Associate it with the I/O completion port. */ - /* Use uv_handle_t pointer as completion key. */ - if (CreateIoCompletionPort((HANDLE)socket, - loop->iocp, - (ULONG_PTR)socket, - 0) == NULL) { - return GetLastError(); - } - - if (pSetFileCompletionNotificationModes) { - /* All known Windows that support SetFileCompletionNotificationModes */ - /* have a bug that makes it impossible to use this function in */ - /* conjunction with datagram sockets. We can work around that but only */ - /* if the user is using the default UDP driver (AFD) and has no other */ - /* LSPs stacked on top. Here we check whether that is the case. */ - opt_len = (int) sizeof info; - if (getsockopt(socket, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &info, - &opt_len) == SOCKET_ERROR) { - return GetLastError(); - } - - if (info.ProtocolChain.ChainLen == 1) { - if (pSetFileCompletionNotificationModes((HANDLE)socket, - FILE_SKIP_SET_EVENT_ON_HANDLE | - FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { - handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; - handle->func_wsarecv = uv_wsarecv_workaround; - handle->func_wsarecvfrom = uv_wsarecvfrom_workaround; - } else if (GetLastError() != ERROR_INVALID_FUNCTION) { - return GetLastError(); - } - } - } - - handle->socket = socket; - - if (family == AF_INET6) { - handle->flags |= UV_HANDLE_IPV6; - } else { - assert(!(handle->flags & UV_HANDLE_IPV6)); - } - - return 0; -} - - -int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) { - int domain; - - /* Use the lower 8 bits for the domain */ - domain = flags & 0xFF; - if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC) - return UV_EINVAL; - - if (flags & ~0xFF) - return UV_EINVAL; - - uv__handle_init(loop, (uv_handle_t*) handle, UV_UDP); - handle->socket = INVALID_SOCKET; - handle->reqs_pending = 0; - handle->activecnt = 0; - handle->func_wsarecv = WSARecv; - handle->func_wsarecvfrom = WSARecvFrom; - handle->send_queue_size = 0; - handle->send_queue_count = 0; - UV_REQ_INIT(&handle->recv_req, UV_UDP_RECV); - handle->recv_req.data = handle; - - /* If anything fails beyond this point we need to remove the handle from - * the handle queue, since it was added by uv__handle_init. - */ - - if (domain != AF_UNSPEC) { - SOCKET sock; - DWORD err; - - sock = socket(domain, SOCK_DGRAM, 0); - if (sock == INVALID_SOCKET) { - err = WSAGetLastError(); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - - err = uv_udp_set_socket(handle->loop, handle, sock, domain); - if (err) { - closesocket(sock); - QUEUE_REMOVE(&handle->handle_queue); - return uv_translate_sys_error(err); - } - } - - return 0; -} - - -int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) { - return uv_udp_init_ex(loop, handle, AF_UNSPEC); -} - - -void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) { - uv_udp_recv_stop(handle); - closesocket(handle->socket); - handle->socket = INVALID_SOCKET; - - uv__handle_closing(handle); - - if (handle->reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); - } -} - - -void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) { - if (handle->flags & UV__HANDLE_CLOSING && - handle->reqs_pending == 0) { - assert(!(handle->flags & UV_HANDLE_CLOSED)); - uv__handle_close(handle); - } -} - - -static int uv_udp_maybe_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int r; - int err; - DWORD no = 0; - - if (handle->flags & UV_HANDLE_BOUND) - return 0; - - if ((flags & UV_UDP_IPV6ONLY) && addr->sa_family != AF_INET6) { - /* UV_UDP_IPV6ONLY is supported only for IPV6 sockets */ - return ERROR_INVALID_PARAMETER; - } - - if (handle->socket == INVALID_SOCKET) { - SOCKET sock = socket(addr->sa_family, SOCK_DGRAM, 0); - if (sock == INVALID_SOCKET) { - return WSAGetLastError(); - } - - err = uv_udp_set_socket(handle->loop, handle, sock, addr->sa_family); - if (err) { - closesocket(sock); - return err; - } - } - - if (flags & UV_UDP_REUSEADDR) { - DWORD yes = 1; - /* Set SO_REUSEADDR on the socket. */ - if (setsockopt(handle->socket, - SOL_SOCKET, - SO_REUSEADDR, - (char*) &yes, - sizeof yes) == SOCKET_ERROR) { - err = WSAGetLastError(); - return err; - } - } - - if (addr->sa_family == AF_INET6) - handle->flags |= UV_HANDLE_IPV6; - - if (addr->sa_family == AF_INET6 && !(flags & UV_UDP_IPV6ONLY)) { - /* On windows IPV6ONLY is on by default. */ - /* If the user doesn't specify it libuv turns it off. */ - - /* TODO: how to handle errors? This may fail if there is no ipv4 stack */ - /* available, or when run on XP/2003 which have no support for dualstack */ - /* sockets. For now we're silently ignoring the error. */ - setsockopt(handle->socket, - IPPROTO_IPV6, - IPV6_V6ONLY, - (char*) &no, - sizeof no); - } - - r = bind(handle->socket, addr, addrlen); - if (r == SOCKET_ERROR) { - return WSAGetLastError(); - } - - handle->flags |= UV_HANDLE_BOUND; - - return 0; -} - - -static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { - uv_req_t* req; - uv_buf_t buf; - DWORD bytes, flags; - int result; - - assert(handle->flags & UV_HANDLE_READING); - assert(!(handle->flags & UV_HANDLE_READ_PENDING)); - - req = &handle->recv_req; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - /* - * Preallocate a read buffer if the number of active streams is below - * the threshold. - */ - if (loop->active_udp_streams < uv_active_udp_streams_threshold) { - handle->flags &= ~UV_HANDLE_ZERO_READ; - - handle->recv_buffer = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &handle->recv_buffer); - if (handle->recv_buffer.base == NULL || handle->recv_buffer.len == 0) { - handle->recv_cb(handle, UV_ENOBUFS, &handle->recv_buffer, NULL, 0); - return; - } - assert(handle->recv_buffer.base != NULL); - - buf = handle->recv_buffer; - memset(&handle->recv_from, 0, sizeof handle->recv_from); - handle->recv_from_len = sizeof handle->recv_from; - flags = 0; - - result = handle->func_wsarecvfrom(handle->socket, - (WSABUF*) &buf, - 1, - &bytes, - &flags, - (struct sockaddr*) &handle->recv_from, - &handle->recv_from_len, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Process the req without IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - req->u.io.overlapped.InternalHigh = bytes; - handle->reqs_pending++; - uv_insert_pending_req(loop, req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* The req will be processed with IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); - handle->reqs_pending++; - } - - } else { - handle->flags |= UV_HANDLE_ZERO_READ; - - buf.base = (char*) uv_zero_; - buf.len = 0; - flags = MSG_PEEK; - - result = handle->func_wsarecv(handle->socket, - (WSABUF*) &buf, - 1, - &bytes, - &flags, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Process the req without IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - req->u.io.overlapped.InternalHigh = bytes; - handle->reqs_pending++; - uv_insert_pending_req(loop, req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* The req will be processed with IOCP. */ - handle->flags |= UV_HANDLE_READ_PENDING; - handle->reqs_pending++; - } else { - /* Make this req pending reporting an error. */ - SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); - handle->reqs_pending++; - } - } -} - - -int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb) { - uv_loop_t* loop = handle->loop; - int err; - - if (handle->flags & UV_HANDLE_READING) { - return WSAEALREADY; - } - - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - 0); - if (err) - return err; - - handle->flags |= UV_HANDLE_READING; - INCREASE_ACTIVE_COUNT(loop, handle); - loop->active_udp_streams++; - - handle->recv_cb = recv_cb; - handle->alloc_cb = alloc_cb; - - /* If reading was stopped and then started again, there could still be a */ - /* recv request pending. */ - if (!(handle->flags & UV_HANDLE_READ_PENDING)) - uv_udp_queue_recv(loop, handle); - - return 0; -} - - -int uv__udp_recv_stop(uv_udp_t* handle) { - if (handle->flags & UV_HANDLE_READING) { - handle->flags &= ~UV_HANDLE_READING; - handle->loop->active_udp_streams--; - DECREASE_ACTIVE_COUNT(loop, handle); - } - - return 0; -} - - -static int uv__send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb cb) { - uv_loop_t* loop = handle->loop; - DWORD result, bytes; - - UV_REQ_INIT(req, UV_UDP_SEND); - req->handle = handle; - req->cb = cb; - memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - - result = WSASendTo(handle->socket, - (WSABUF*)bufs, - nbufs, - &bytes, - 0, - addr, - addrlen, - &req->u.io.overlapped, - NULL); - - if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) { - /* Request completed immediately. */ - req->u.io.queued_bytes = 0; - handle->reqs_pending++; - handle->send_queue_size += req->u.io.queued_bytes; - handle->send_queue_count++; - REGISTER_HANDLE_REQ(loop, handle, req); - uv_insert_pending_req(loop, (uv_req_t*)req); - } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { - /* Request queued by the kernel. */ - req->u.io.queued_bytes = uv__count_bufs(bufs, nbufs); - handle->reqs_pending++; - handle->send_queue_size += req->u.io.queued_bytes; - handle->send_queue_count++; - REGISTER_HANDLE_REQ(loop, handle, req); - } else { - /* Send failed due to an error. */ - return WSAGetLastError(); - } - - return 0; -} - - -void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, - uv_req_t* req) { - uv_buf_t buf; - int partial; - - assert(handle->type == UV_UDP); - - handle->flags &= ~UV_HANDLE_READ_PENDING; - - if (!REQ_SUCCESS(req)) { - DWORD err = GET_REQ_SOCK_ERROR(req); - if (err == WSAEMSGSIZE) { - /* Not a real error, it just indicates that the received packet */ - /* was bigger than the receive buffer. */ - } else if (err == WSAECONNRESET || err == WSAENETRESET) { - /* A previous sendto operation failed; ignore this error. If */ - /* zero-reading we need to call WSARecv/WSARecvFrom _without_ the */ - /* MSG_PEEK flag to clear out the error queue. For nonzero reads, */ - /* immediately queue a new receive. */ - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - goto done; - } - } else { - /* A real error occurred. Report the error to the user only if we're */ - /* currently reading. */ - if (handle->flags & UV_HANDLE_READING) { - uv_udp_recv_stop(handle); - buf = (handle->flags & UV_HANDLE_ZERO_READ) ? - uv_buf_init(NULL, 0) : handle->recv_buffer; - handle->recv_cb(handle, uv_translate_sys_error(err), &buf, NULL, 0); - } - goto done; - } - } - - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - /* Successful read */ - partial = !REQ_SUCCESS(req); - handle->recv_cb(handle, - req->u.io.overlapped.InternalHigh, - &handle->recv_buffer, - (const struct sockaddr*) &handle->recv_from, - partial ? UV_UDP_PARTIAL : 0); - } else if (handle->flags & UV_HANDLE_READING) { - DWORD bytes, err, flags; - struct sockaddr_storage from; - int from_len; - - /* Do a nonblocking receive */ - /* TODO: try to read multiple datagrams at once. FIONREAD maybe? */ - buf = uv_buf_init(NULL, 0); - handle->alloc_cb((uv_handle_t*) handle, 65536, &buf); - if (buf.base == NULL || buf.len == 0) { - handle->recv_cb(handle, UV_ENOBUFS, &buf, NULL, 0); - goto done; - } - assert(buf.base != NULL); - - memset(&from, 0, sizeof from); - from_len = sizeof from; - - flags = 0; - - if (WSARecvFrom(handle->socket, - (WSABUF*)&buf, - 1, - &bytes, - &flags, - (struct sockaddr*) &from, - &from_len, - NULL, - NULL) != SOCKET_ERROR) { - - /* Message received */ - handle->recv_cb(handle, bytes, &buf, (const struct sockaddr*) &from, 0); - } else { - err = WSAGetLastError(); - if (err == WSAEMSGSIZE) { - /* Message truncated */ - handle->recv_cb(handle, - bytes, - &buf, - (const struct sockaddr*) &from, - UV_UDP_PARTIAL); - } else if (err == WSAEWOULDBLOCK) { - /* Kernel buffer empty */ - handle->recv_cb(handle, 0, &buf, NULL, 0); - } else if (err == WSAECONNRESET || err == WSAENETRESET) { - /* WSAECONNRESET/WSANETRESET is ignored because this just indicates - * that a previous sendto operation failed. - */ - handle->recv_cb(handle, 0, &buf, NULL, 0); - } else { - /* Any other error that we want to report back to the user. */ - uv_udp_recv_stop(handle); - handle->recv_cb(handle, uv_translate_sys_error(err), &buf, NULL, 0); - } - } - } - -done: - /* Post another read if still reading and not closing. */ - if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_udp_queue_recv(loop, handle); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, - uv_udp_send_t* req) { - int err; - - assert(handle->type == UV_UDP); - - assert(handle->send_queue_size >= req->u.io.queued_bytes); - assert(handle->send_queue_count >= 1); - handle->send_queue_size -= req->u.io.queued_bytes; - handle->send_queue_count--; - - UNREGISTER_HANDLE_REQ(loop, handle, req); - - if (req->cb) { - err = 0; - if (!REQ_SUCCESS(req)) { - err = GET_REQ_SOCK_ERROR(req); - } - req->cb(req, uv_translate_sys_error(err)); - } - - DECREASE_PENDING_REQ_COUNT(handle); -} - - -static int uv__udp_set_membership4(uv_udp_t* handle, - const struct sockaddr_in* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int err; - int optname; - struct ip_mreq mreq; - - if (handle->flags & UV_HANDLE_IPV6) - return UV_EINVAL; - - /* If the socket is unbound, bind to inaddr_any. */ - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - UV_UDP_REUSEADDR); - if (err) - return uv_translate_sys_error(err); - - memset(&mreq, 0, sizeof mreq); - - if (interface_addr) { - err = uv_inet_pton(AF_INET, interface_addr, &mreq.imr_interface.s_addr); - if (err) - return err; - } else { - mreq.imr_interface.s_addr = htonl(INADDR_ANY); - } - - mreq.imr_multiaddr.s_addr = multicast_addr->sin_addr.s_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IP_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IP_DROP_MEMBERSHIP; - break; - default: - return UV_EINVAL; - } - - if (setsockopt(handle->socket, - IPPROTO_IP, - optname, - (char*) &mreq, - sizeof mreq) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv__udp_set_membership6(uv_udp_t* handle, - const struct sockaddr_in6* multicast_addr, - const char* interface_addr, - uv_membership membership) { - int optname; - int err; - struct ipv6_mreq mreq; - struct sockaddr_in6 addr6; - - if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6)) - return UV_EINVAL; - - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip6_any_, - sizeof(uv_addr_ip6_any_), - UV_UDP_REUSEADDR); - - if (err) - return uv_translate_sys_error(err); - - memset(&mreq, 0, sizeof(mreq)); - - if (interface_addr) { - if (uv_ip6_addr(interface_addr, 0, &addr6)) - return UV_EINVAL; - mreq.ipv6mr_interface = addr6.sin6_scope_id; - } else { - mreq.ipv6mr_interface = 0; - } - - mreq.ipv6mr_multiaddr = multicast_addr->sin6_addr; - - switch (membership) { - case UV_JOIN_GROUP: - optname = IPV6_ADD_MEMBERSHIP; - break; - case UV_LEAVE_GROUP: - optname = IPV6_DROP_MEMBERSHIP; - break; - default: - return UV_EINVAL; - } - - if (setsockopt(handle->socket, - IPPROTO_IPV6, - optname, - (char*) &mreq, - sizeof mreq) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership) { - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - - if (uv_ip4_addr(multicast_addr, 0, &addr4) == 0) - return uv__udp_set_membership4(handle, &addr4, interface_addr, membership); - else if (uv_ip6_addr(multicast_addr, 0, &addr6) == 0) - return uv__udp_set_membership6(handle, &addr6, interface_addr, membership); - else - return UV_EINVAL; -} - - -int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) { - struct sockaddr_storage addr_st; - struct sockaddr_in* addr4; - struct sockaddr_in6* addr6; - - addr4 = (struct sockaddr_in*) &addr_st; - addr6 = (struct sockaddr_in6*) &addr_st; - - if (!interface_addr) { - memset(&addr_st, 0, sizeof addr_st); - if (handle->flags & UV_HANDLE_IPV6) { - addr_st.ss_family = AF_INET6; - addr6->sin6_scope_id = 0; - } else { - addr_st.ss_family = AF_INET; - addr4->sin_addr.s_addr = htonl(INADDR_ANY); - } - } else if (uv_ip4_addr(interface_addr, 0, addr4) == 0) { - /* nothing, address was parsed */ - } else if (uv_ip6_addr(interface_addr, 0, addr6) == 0) { - /* nothing, address was parsed */ - } else { - return UV_EINVAL; - } - - if (!(handle->flags & UV_HANDLE_BOUND)) - return UV_EBADF; - - if (addr_st.ss_family == AF_INET) { - if (setsockopt(handle->socket, - IPPROTO_IP, - IP_MULTICAST_IF, - (char*) &addr4->sin_addr, - sizeof(addr4->sin_addr)) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - } else if (addr_st.ss_family == AF_INET6) { - if (setsockopt(handle->socket, - IPPROTO_IPV6, - IPV6_MULTICAST_IF, - (char*) &addr6->sin6_scope_id, - sizeof(addr6->sin6_scope_id)) == SOCKET_ERROR) { - return uv_translate_sys_error(WSAGetLastError()); - } - } else { - assert(0 && "unexpected address family"); - abort(); - } - - return 0; -} - - -int uv_udp_set_broadcast(uv_udp_t* handle, int value) { - BOOL optval = (BOOL) value; - - if (!(handle->flags & UV_HANDLE_BOUND)) - return UV_EBADF; - - if (setsockopt(handle->socket, - SOL_SOCKET, - SO_BROADCAST, - (char*) &optval, - sizeof optval)) { - return uv_translate_sys_error(WSAGetLastError()); - } - - return 0; -} - - -int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { - WSAPROTOCOL_INFOW protocol_info; - int opt_len; - int err; - - /* Detect the address family of the socket. */ - opt_len = (int) sizeof protocol_info; - if (getsockopt(sock, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) { - return uv_translate_sys_error(GetLastError()); - } - - err = uv_udp_set_socket(handle->loop, - handle, - sock, - protocol_info.iAddressFamily); - return uv_translate_sys_error(err); -} - - -#define SOCKOPT_SETTER(name, option4, option6, validate) \ - int uv_udp_set_##name(uv_udp_t* handle, int value) { \ - DWORD optval = (DWORD) value; \ - \ - if (!(validate(value))) { \ - return UV_EINVAL; \ - } \ - \ - if (!(handle->flags & UV_HANDLE_BOUND)) \ - return UV_EBADF; \ - \ - if (!(handle->flags & UV_HANDLE_IPV6)) { \ - /* Set IPv4 socket option */ \ - if (setsockopt(handle->socket, \ - IPPROTO_IP, \ - option4, \ - (char*) &optval, \ - sizeof optval)) { \ - return uv_translate_sys_error(WSAGetLastError()); \ - } \ - } else { \ - /* Set IPv6 socket option */ \ - if (setsockopt(handle->socket, \ - IPPROTO_IPV6, \ - option6, \ - (char*) &optval, \ - sizeof optval)) { \ - return uv_translate_sys_error(WSAGetLastError()); \ - } \ - } \ - return 0; \ - } - -#define VALIDATE_TTL(value) ((value) >= 1 && (value) <= 255) -#define VALIDATE_MULTICAST_TTL(value) ((value) >= -1 && (value) <= 255) -#define VALIDATE_MULTICAST_LOOP(value) (1) - -SOCKOPT_SETTER(ttl, - IP_TTL, - IPV6_HOPLIMIT, - VALIDATE_TTL) -SOCKOPT_SETTER(multicast_ttl, - IP_MULTICAST_TTL, - IPV6_MULTICAST_HOPS, - VALIDATE_MULTICAST_TTL) -SOCKOPT_SETTER(multicast_loop, - IP_MULTICAST_LOOP, - IPV6_MULTICAST_LOOP, - VALIDATE_MULTICAST_LOOP) - -#undef SOCKOPT_SETTER -#undef VALIDATE_TTL -#undef VALIDATE_MULTICAST_TTL -#undef VALIDATE_MULTICAST_LOOP - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { - int err; - - err = uv_udp_maybe_bind(handle, addr, addrlen, flags); - if (err) - return uv_translate_sys_error(err); - - return 0; -} - - -/* This function is an egress point, i.e. it returns libuv errors rather than - * system errors. - */ -int uv__udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen, - uv_udp_send_cb send_cb) { - const struct sockaddr* bind_addr; - int err; - - if (!(handle->flags & UV_HANDLE_BOUND)) { - if (addrlen == sizeof(uv_addr_ip4_any_)) { - bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_; - } else if (addrlen == sizeof(uv_addr_ip6_any_)) { - bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; - } else { - abort(); - } - err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); - if (err) - return uv_translate_sys_error(err); - } - - err = uv__send(req, handle, bufs, nbufs, addr, addrlen, send_cb); - if (err) - return uv_translate_sys_error(err); - - return 0; -} - - -int uv__udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - unsigned int addrlen) { - return UV_ENOSYS; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/util.c b/lib/ESPiLight/pilight/libs/libuv/win/util.c deleted file mode 100644 index d2e7f77..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/util.c +++ /dev/null @@ -1,1576 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "uv.h" -#include "internal.h" - -#include -#include -#include -#include -#include -#include -#include - - -/* - * Max title length; the only thing MSDN tells us about the maximum length - * of the console title is that it is smaller than 64K. However in practice - * it is much smaller, and there is no way to figure out what the exact length - * of the title is or can be, at least not on XP. To make it even more - * annoying, GetConsoleTitle fails when the buffer to be read into is bigger - * than the actual maximum length. So we make a conservative guess here; - * just don't put the novel you're writing in the title, unless the plot - * survives truncation. - */ -#define MAX_TITLE_LENGTH 8192 - -/* The number of nanoseconds in one second. */ -#define UV__NANOSEC 1000000000 - -/* Max user name length, from iphlpapi.h */ -#ifndef UNLEN -# define UNLEN 256 -#endif - -/* - Max hostname length. The Windows gethostname() documentation states that 256 - bytes will always be large enough to hold the null-terminated hostname. -*/ -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 256 -#endif - -/* Maximum environment variable size, including the terminating null */ -#define MAX_ENV_VAR_LENGTH 32767 - -/* Cached copy of the process title, plus a mutex guarding it. */ -static char *process_title; -static CRITICAL_SECTION process_title_lock; - -/* Cached copy of the process id, written once. */ -static DWORD current_pid = 0; - - -/* Interval (in seconds) of the high-resolution clock. */ -static double hrtime_interval_ = 0; - - -/* - * One-time initialization code for functionality defined in util.c. - */ -void uv__util_init(void) { - LARGE_INTEGER perf_frequency; - - /* Initialize process title access mutex. */ - InitializeCriticalSection(&process_title_lock); - - /* Retrieve high-resolution timer frequency - * and precompute its reciprocal. - */ - if (QueryPerformanceFrequency(&perf_frequency)) { - hrtime_interval_ = 1.0 / perf_frequency.QuadPart; - } else { - hrtime_interval_= 0; - } -} - - -int uv_exepath(char* buffer, size_t* size_ptr) { - int utf8_len, utf16_buffer_len, utf16_len; - WCHAR* utf16_buffer; - int err; - - if (buffer == NULL || size_ptr == NULL || *size_ptr == 0) { - return UV_EINVAL; - } - - if (*size_ptr > 32768) { - /* Windows paths can never be longer than this. */ - utf16_buffer_len = 32768; - } else { - utf16_buffer_len = (int) *size_ptr; - } - - utf16_buffer = (WCHAR*) uv__malloc(sizeof(WCHAR) * utf16_buffer_len); - if (!utf16_buffer) { - return UV_ENOMEM; - } - - /* Get the path as UTF-16. */ - utf16_len = GetModuleFileNameW(NULL, utf16_buffer, utf16_buffer_len); - if (utf16_len <= 0) { - err = GetLastError(); - goto error; - } - - /* utf16_len contains the length, *not* including the terminating null. */ - utf16_buffer[utf16_len] = L'\0'; - - /* Convert to UTF-8 */ - utf8_len = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - buffer, - (int) *size_ptr, - NULL, - NULL); - if (utf8_len == 0) { - err = GetLastError(); - goto error; - } - - uv__free(utf16_buffer); - - /* utf8_len *does* include the terminating null at this point, but the */ - /* returned size shouldn't. */ - *size_ptr = utf8_len - 1; - return 0; - - error: - uv__free(utf16_buffer); - return uv_translate_sys_error(err); -} - - -int uv_cwd(char* buffer, size_t* size) { - DWORD utf16_len; - WCHAR utf16_buffer[MAX_PATH]; - int r; - - if (buffer == NULL || size == NULL) { - return UV_EINVAL; - } - - utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer); - if (utf16_len == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (utf16_len > MAX_PATH) { - /* This should be impossible; however the CRT has a code path to deal */ - /* with this scenario, so I added a check anyway. */ - return UV_EIO; - } - - /* utf16_len contains the length, *not* including the terminating null. */ - utf16_buffer[utf16_len] = L'\0'; - - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed.*/ - if (utf16_buffer[utf16_len - 1] == L'\\' && - !(utf16_len == 3 && utf16_buffer[1] == L':')) { - utf16_len--; - utf16_buffer[utf16_len] = L'\0'; - } - - /* Check how much space we need */ - r = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - NULL, - 0, - NULL, - NULL); - if (r == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (r > (int) *size) { - *size = r; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - r = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - buffer, - *size > INT_MAX ? INT_MAX : (int) *size, - NULL, - NULL); - if (r == 0) { - return uv_translate_sys_error(GetLastError()); - } - - *size = r - 1; - return 0; -} - - -int uv_chdir(const char* dir) { - WCHAR utf16_buffer[MAX_PATH]; - size_t utf16_len; - WCHAR drive_letter, env_var[4]; - - if (dir == NULL) { - return UV_EINVAL; - } - - if (MultiByteToWideChar(CP_UTF8, - 0, - dir, - -1, - utf16_buffer, - MAX_PATH) == 0) { - DWORD error = GetLastError(); - /* The maximum length of the current working directory is 260 chars, */ - /* including terminating null. If it doesn't fit, the path name must be */ - /* too long. */ - if (error == ERROR_INSUFFICIENT_BUFFER) { - return UV_ENAMETOOLONG; - } else { - return uv_translate_sys_error(error); - } - } - - if (!SetCurrentDirectoryW(utf16_buffer)) { - return uv_translate_sys_error(GetLastError()); - } - - /* Windows stores the drive-local path in an "hidden" environment variable, */ - /* which has the form "=C:=C:\Windows". SetCurrentDirectory does not */ - /* update this, so we'll have to do it. */ - utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer); - if (utf16_len == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (utf16_len > MAX_PATH) { - return UV_EIO; - } - - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed. */ - if (utf16_buffer[utf16_len - 1] == L'\\' && - !(utf16_len == 3 && utf16_buffer[1] == L':')) { - utf16_len--; - utf16_buffer[utf16_len] = L'\0'; - } - - if (utf16_len < 2 || utf16_buffer[1] != L':') { - /* Doesn't look like a drive letter could be there - probably an UNC */ - /* path. TODO: Need to handle win32 namespaces like \\?\C:\ ? */ - drive_letter = 0; - } else if (utf16_buffer[0] >= L'A' && utf16_buffer[0] <= L'Z') { - drive_letter = utf16_buffer[0]; - } else if (utf16_buffer[0] >= L'a' && utf16_buffer[0] <= L'z') { - /* Convert to uppercase. */ - drive_letter = utf16_buffer[0] - L'a' + L'A'; - } else { - /* Not valid. */ - drive_letter = 0; - } - - if (drive_letter != 0) { - /* Construct the environment variable name and set it. */ - env_var[0] = L'='; - env_var[1] = drive_letter; - env_var[2] = L':'; - env_var[3] = L'\0'; - - if (!SetEnvironmentVariableW(env_var, utf16_buffer)) { - return uv_translate_sys_error(GetLastError()); - } - } - - return 0; -} - - -void uv_loadavg(double avg[3]) { - /* Can't be implemented */ - avg[0] = avg[1] = avg[2] = 0; -} - - -uint64_t uv_get_free_memory(void) { - MEMORYSTATUSEX memory_status; - memory_status.dwLength = sizeof(memory_status); - - if (!GlobalMemoryStatusEx(&memory_status)) { - return -1; - } - - return (uint64_t)memory_status.ullAvailPhys; -} - - -uint64_t uv_get_total_memory(void) { - MEMORYSTATUSEX memory_status; - memory_status.dwLength = sizeof(memory_status); - - if (!GlobalMemoryStatusEx(&memory_status)) { - return -1; - } - - return (uint64_t)memory_status.ullTotalPhys; -} - - -int uv_parent_pid(void) { - int parent_pid = -1; - HANDLE handle; - PROCESSENTRY32 pe; - DWORD current_pid = GetCurrentProcessId(); - - pe.dwSize = sizeof(PROCESSENTRY32); - handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - - if (Process32First(handle, &pe)) { - do { - if (pe.th32ProcessID == current_pid) { - parent_pid = pe.th32ParentProcessID; - break; - } - } while( Process32Next(handle, &pe)); - } - - CloseHandle(handle); - return parent_pid; -} - - -int uv_current_pid(void) { - if (current_pid == 0) { - current_pid = GetCurrentProcessId(); - } - return current_pid; -} - - -char** uv_setup_args(int argc, char** argv) { - return argv; -} - - -int uv_set_process_title(const char* title) { - int err; - int length; - WCHAR* title_w = NULL; - - uv__once_init(); - - /* Find out how big the buffer for the wide-char title must be */ - length = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0); - if (!length) { - err = GetLastError(); - goto done; - } - - /* Convert to wide-char string */ - title_w = (WCHAR*)uv__malloc(sizeof(WCHAR) * length); - if (!title_w) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - length = MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, length); - if (!length) { - err = GetLastError(); - goto done; - } - - /* If the title must be truncated insert a \0 terminator there */ - if (length > MAX_TITLE_LENGTH) { - title_w[MAX_TITLE_LENGTH - 1] = L'\0'; - } - - if (!SetConsoleTitleW(title_w)) { - err = GetLastError(); - goto done; - } - - EnterCriticalSection(&process_title_lock); - uv__free(process_title); - process_title = uv__strdup(title); - LeaveCriticalSection(&process_title_lock); - - err = 0; - -done: - uv__free(title_w); - return uv_translate_sys_error(err); -} - - -static int uv__get_process_title(void) { - WCHAR title_w[MAX_TITLE_LENGTH]; - - if (!GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR))) { - return -1; - } - - if (uv__convert_utf16_to_utf8(title_w, -1, &process_title) != 0) - return -1; - - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - size_t len; - - if (buffer == NULL || size == 0) - return UV_EINVAL; - - uv__once_init(); - - EnterCriticalSection(&process_title_lock); - /* - * If the process_title was never read before nor explicitly set, - * we must query it with getConsoleTitleW - */ - if (!process_title && uv__get_process_title() == -1) { - LeaveCriticalSection(&process_title_lock); - return uv_translate_sys_error(GetLastError()); - } - - assert(process_title); - len = strlen(process_title) + 1; - - if (size < len) { - LeaveCriticalSection(&process_title_lock); - return UV_ENOBUFS; - } - - memcpy(buffer, process_title, len); - LeaveCriticalSection(&process_title_lock); - - return 0; -} - - -uint64_t uv_hrtime(void) { - uv__once_init(); - return uv__hrtime(UV__NANOSEC); -} - -uint64_t uv__hrtime(double scale) { - LARGE_INTEGER counter; - - /* If the performance interval is zero, there's no support. */ - if (hrtime_interval_ == 0) { - return 0; - } - - if (!QueryPerformanceCounter(&counter)) { - return 0; - } - - /* Because we have no guarantee about the order of magnitude of the - * performance counter interval, integer math could cause this computation - * to overflow. Therefore we resort to floating point math. - */ - return (uint64_t) ((double) counter.QuadPart * hrtime_interval_ * scale); -} - - -int uv_resident_set_memory(size_t* rss) { - HANDLE current_process; - PROCESS_MEMORY_COUNTERS pmc; - - current_process = GetCurrentProcess(); - - if (!GetProcessMemoryInfo(current_process, &pmc, sizeof(pmc))) { - return uv_translate_sys_error(GetLastError()); - } - - *rss = pmc.WorkingSetSize; - - return 0; -} - - -int uv_uptime(double* uptime) { - BYTE stack_buffer[4096]; - BYTE* malloced_buffer = NULL; - BYTE* buffer = (BYTE*) stack_buffer; - size_t buffer_size = sizeof(stack_buffer); - DWORD data_size; - - PERF_DATA_BLOCK* data_block; - PERF_OBJECT_TYPE* object_type; - PERF_COUNTER_DEFINITION* counter_definition; - - DWORD i; - - for (;;) { - LONG result; - - data_size = (DWORD) buffer_size; - result = RegQueryValueExW(HKEY_PERFORMANCE_DATA, - L"2", - NULL, - NULL, - buffer, - &data_size); - if (result == ERROR_SUCCESS) { - break; - } else if (result != ERROR_MORE_DATA) { - *uptime = 0; - return uv_translate_sys_error(result); - } - - buffer_size *= 2; - /* Don't let the buffer grow infinitely. */ - if (buffer_size > 1 << 20) { - goto internalError; - } - - uv__free(malloced_buffer); - - buffer = malloced_buffer = (BYTE*) uv__malloc(buffer_size); - if (malloced_buffer == NULL) { - *uptime = 0; - return UV_ENOMEM; - } - } - - if (data_size < sizeof(*data_block)) - goto internalError; - - data_block = (PERF_DATA_BLOCK*) buffer; - - if (wmemcmp(data_block->Signature, L"PERF", 4) != 0) - goto internalError; - - if (data_size < data_block->HeaderLength + sizeof(*object_type)) - goto internalError; - - object_type = (PERF_OBJECT_TYPE*) (buffer + data_block->HeaderLength); - - if (object_type->NumInstances != PERF_NO_INSTANCES) - goto internalError; - - counter_definition = (PERF_COUNTER_DEFINITION*) (buffer + - data_block->HeaderLength + object_type->HeaderLength); - for (i = 0; i < object_type->NumCounters; i++) { - if ((BYTE*) counter_definition + sizeof(*counter_definition) > - buffer + data_size) { - break; - } - - if (counter_definition->CounterNameTitleIndex == 674 && - counter_definition->CounterSize == sizeof(uint64_t)) { - if (counter_definition->CounterOffset + sizeof(uint64_t) > data_size || - !(counter_definition->CounterType & PERF_OBJECT_TIMER)) { - goto internalError; - } else { - BYTE* address = (BYTE*) object_type + object_type->DefinitionLength + - counter_definition->CounterOffset; - uint64_t value = *((uint64_t*) address); - *uptime = (double) (object_type->PerfTime.QuadPart - value) / - (double) object_type->PerfFreq.QuadPart; - uv__free(malloced_buffer); - return 0; - } - } - - counter_definition = (PERF_COUNTER_DEFINITION*) - ((BYTE*) counter_definition + counter_definition->ByteLength); - } - - /* If we get here, the uptime value was not found. */ - uv__free(malloced_buffer); - *uptime = 0; - return UV_ENOSYS; - - internalError: - uv__free(malloced_buffer); - *uptime = 0; - return UV_EIO; -} - - -int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) { - uv_cpu_info_t* cpu_infos; - SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi; - DWORD sppi_size; - SYSTEM_INFO system_info; - DWORD cpu_count, r, i; - NTSTATUS status; - ULONG result_size; - int err; - uv_cpu_info_t* cpu_info; - - cpu_infos = NULL; - cpu_count = 0; - sppi = NULL; - - uv__once_init(); - - GetSystemInfo(&system_info); - cpu_count = system_info.dwNumberOfProcessors; - - cpu_infos = uv__calloc(cpu_count, sizeof *cpu_infos); - if (cpu_infos == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - sppi_size = cpu_count * sizeof(*sppi); - sppi = uv__malloc(sppi_size); - if (sppi == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, - sppi, - sppi_size, - &result_size); - if (!NT_SUCCESS(status)) { - err = pRtlNtStatusToDosError(status); - goto error; - } - - assert(result_size == sppi_size); - - for (i = 0; i < cpu_count; i++) { - WCHAR key_name[128]; - HKEY processor_key; - DWORD cpu_speed; - DWORD cpu_speed_size = sizeof(cpu_speed); - WCHAR cpu_brand[256]; - DWORD cpu_brand_size = sizeof(cpu_brand); - size_t len; - - len = _snwprintf(key_name, - ARRAY_SIZE(key_name), - L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d", - i); - - assert(len > 0 && len < ARRAY_SIZE(key_name)); - - r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - key_name, - 0, - KEY_QUERY_VALUE, - &processor_key); - if (r != ERROR_SUCCESS) { - err = GetLastError(); - goto error; - } - - if (RegQueryValueExW(processor_key, - L"~MHz", - NULL, - NULL, - (BYTE*) &cpu_speed, - &cpu_speed_size) != ERROR_SUCCESS) { - err = GetLastError(); - RegCloseKey(processor_key); - goto error; - } - - if (RegQueryValueExW(processor_key, - L"ProcessorNameString", - NULL, - NULL, - (BYTE*) &cpu_brand, - &cpu_brand_size) != ERROR_SUCCESS) { - err = GetLastError(); - RegCloseKey(processor_key); - goto error; - } - - RegCloseKey(processor_key); - - cpu_info = &cpu_infos[i]; - cpu_info->speed = cpu_speed; - cpu_info->cpu_times.user = sppi[i].UserTime.QuadPart / 10000; - cpu_info->cpu_times.sys = (sppi[i].KernelTime.QuadPart - - sppi[i].IdleTime.QuadPart) / 10000; - cpu_info->cpu_times.idle = sppi[i].IdleTime.QuadPart / 10000; - cpu_info->cpu_times.irq = sppi[i].InterruptTime.QuadPart / 10000; - cpu_info->cpu_times.nice = 0; - - uv__convert_utf16_to_utf8(cpu_brand, - cpu_brand_size / sizeof(WCHAR), - &(cpu_info->model)); - } - - uv__free(sppi); - - *cpu_count_ptr = cpu_count; - *cpu_infos_ptr = cpu_infos; - - return 0; - - error: - /* This is safe because the cpu_infos array is zeroed on allocation. */ - for (i = 0; i < cpu_count; i++) - uv__free(cpu_infos[i].model); - - uv__free(cpu_infos); - uv__free(sppi); - - return uv_translate_sys_error(err); -} - - -void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { - int i; - - for (i = 0; i < count; i++) { - uv__free(cpu_infos[i].model); - } - - uv__free(cpu_infos); -} - - -static int is_windows_version_or_greater(DWORD os_major, - DWORD os_minor, - WORD service_pack_major, - WORD service_pack_minor) { - OSVERSIONINFOEX osvi; - DWORDLONG condition_mask = 0; - int op = VER_GREATER_EQUAL; - - /* Initialize the OSVERSIONINFOEX structure. */ - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - osvi.dwMajorVersion = os_major; - osvi.dwMinorVersion = os_minor; - osvi.wServicePackMajor = service_pack_major; - osvi.wServicePackMinor = service_pack_minor; - - /* Initialize the condition mask. */ - VER_SET_CONDITION(condition_mask, VER_MAJORVERSION, op); - VER_SET_CONDITION(condition_mask, VER_MINORVERSION, op); - VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, op); - VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMINOR, op); - - /* Perform the test. */ - return (int) VerifyVersionInfo( - &osvi, - VER_MAJORVERSION | VER_MINORVERSION | - VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, - condition_mask); -} - - -static int address_prefix_match(int family, - struct sockaddr* address, - struct sockaddr* prefix_address, - int prefix_len) { - uint8_t* address_data; - uint8_t* prefix_address_data; - int i; - - assert(address->sa_family == family); - assert(prefix_address->sa_family == family); - - if (family == AF_INET6) { - address_data = (uint8_t*) &(((struct sockaddr_in6 *) address)->sin6_addr); - prefix_address_data = - (uint8_t*) &(((struct sockaddr_in6 *) prefix_address)->sin6_addr); - } else { - address_data = (uint8_t*) &(((struct sockaddr_in *) address)->sin_addr); - prefix_address_data = - (uint8_t*) &(((struct sockaddr_in *) prefix_address)->sin_addr); - } - - for (i = 0; i < prefix_len >> 3; i++) { - if (address_data[i] != prefix_address_data[i]) - return 0; - } - - if (prefix_len % 8) - return prefix_address_data[i] == - (address_data[i] & (0xff << (8 - prefix_len % 8))); - - return 1; -} - - -int uv_interface_addresses(uv_interface_address_t** addresses_ptr, - int* count_ptr) { - IP_ADAPTER_ADDRESSES* win_address_buf; - ULONG win_address_buf_size; - IP_ADAPTER_ADDRESSES* adapter; - - uv_interface_address_t* uv_address_buf; - char* name_buf; - size_t uv_address_buf_size; - uv_interface_address_t* uv_address; - - int count; - - int is_vista_or_greater; - ULONG flags; - - is_vista_or_greater = is_windows_version_or_greater(6, 0, 0, 0); - if (is_vista_or_greater) { - flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | - GAA_FLAG_SKIP_DNS_SERVER; - } else { - /* We need at least XP SP1. */ - if (!is_windows_version_or_greater(5, 1, 1, 0)) - return UV_ENOTSUP; - - flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | - GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_INCLUDE_PREFIX; - } - - - /* Fetch the size of the adapters reported by windows, and then get the */ - /* list itself. */ - win_address_buf_size = 0; - win_address_buf = NULL; - - for (;;) { - ULONG r; - - /* If win_address_buf is 0, then GetAdaptersAddresses will fail with */ - /* ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in */ - /* win_address_buf_size. */ - r = GetAdaptersAddresses(AF_UNSPEC, - flags, - NULL, - win_address_buf, - &win_address_buf_size); - - if (r == ERROR_SUCCESS) - break; - - uv__free(win_address_buf); - - switch (r) { - case ERROR_BUFFER_OVERFLOW: - /* This happens when win_address_buf is NULL or too small to hold */ - /* all adapters. */ - win_address_buf = uv__malloc(win_address_buf_size); - if (win_address_buf == NULL) - return UV_ENOMEM; - - continue; - - case ERROR_NO_DATA: { - /* No adapters were found. */ - uv_address_buf = uv__malloc(1); - if (uv_address_buf == NULL) - return UV_ENOMEM; - - *count_ptr = 0; - *addresses_ptr = uv_address_buf; - - return 0; - } - - case ERROR_ADDRESS_NOT_ASSOCIATED: - return UV_EAGAIN; - - case ERROR_INVALID_PARAMETER: - /* MSDN says: - * "This error is returned for any of the following conditions: the - * SizePointer parameter is NULL, the Address parameter is not - * AF_INET, AF_INET6, or AF_UNSPEC, or the address information for - * the parameters requested is greater than ULONG_MAX." - * Since the first two conditions are not met, it must be that the - * adapter data is too big. - */ - return UV_ENOBUFS; - - default: - /* Other (unspecified) errors can happen, but we don't have any */ - /* special meaning for them. */ - assert(r != ERROR_SUCCESS); - return uv_translate_sys_error(r); - } - } - - /* Count the number of enabled interfaces and compute how much space is */ - /* needed to store their info. */ - count = 0; - uv_address_buf_size = 0; - - for (adapter = win_address_buf; - adapter != NULL; - adapter = adapter->Next) { - IP_ADAPTER_UNICAST_ADDRESS* unicast_address; - int name_size; - - /* Interfaces that are not 'up' should not be reported. Also skip */ - /* interfaces that have no associated unicast address, as to avoid */ - /* allocating space for the name for this interface. */ - if (adapter->OperStatus != IfOperStatusUp || - adapter->FirstUnicastAddress == NULL) - continue; - - /* Compute the size of the interface name. */ - name_size = WideCharToMultiByte(CP_UTF8, - 0, - adapter->FriendlyName, - -1, - NULL, - 0, - NULL, - FALSE); - if (name_size <= 0) { - uv__free(win_address_buf); - return uv_translate_sys_error(GetLastError()); - } - uv_address_buf_size += name_size; - - /* Count the number of addresses associated with this interface, and */ - /* compute the size. */ - for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*) - adapter->FirstUnicastAddress; - unicast_address != NULL; - unicast_address = unicast_address->Next) { - count++; - uv_address_buf_size += sizeof(uv_interface_address_t); - } - } - - /* Allocate space to store interface data plus adapter names. */ - uv_address_buf = uv__malloc(uv_address_buf_size); - if (uv_address_buf == NULL) { - uv__free(win_address_buf); - return UV_ENOMEM; - } - - /* Compute the start of the uv_interface_address_t array, and the place in */ - /* the buffer where the interface names will be stored. */ - uv_address = uv_address_buf; - name_buf = (char*) (uv_address_buf + count); - - /* Fill out the output buffer. */ - for (adapter = win_address_buf; - adapter != NULL; - adapter = adapter->Next) { - IP_ADAPTER_UNICAST_ADDRESS* unicast_address; - int name_size; - size_t max_name_size; - - if (adapter->OperStatus != IfOperStatusUp || - adapter->FirstUnicastAddress == NULL) - continue; - - /* Convert the interface name to UTF8. */ - max_name_size = (char*) uv_address_buf + uv_address_buf_size - name_buf; - if (max_name_size > (size_t) INT_MAX) - max_name_size = INT_MAX; - name_size = WideCharToMultiByte(CP_UTF8, - 0, - adapter->FriendlyName, - -1, - name_buf, - (int) max_name_size, - NULL, - FALSE); - if (name_size <= 0) { - uv__free(win_address_buf); - uv__free(uv_address_buf); - return uv_translate_sys_error(GetLastError()); - } - - /* Add an uv_interface_address_t element for every unicast address. */ - for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*) - adapter->FirstUnicastAddress; - unicast_address != NULL; - unicast_address = unicast_address->Next) { - struct sockaddr* sa; - ULONG prefix_len; - - sa = unicast_address->Address.lpSockaddr; - - /* XP has no OnLinkPrefixLength field. */ - if (is_vista_or_greater) { - prefix_len = - ((IP_ADAPTER_UNICAST_ADDRESS_LH*) unicast_address)->OnLinkPrefixLength; - } else { - /* Prior to Windows Vista the FirstPrefix pointed to the list with - * single prefix for each IP address assigned to the adapter. - * Order of FirstPrefix does not match order of FirstUnicastAddress, - * so we need to find corresponding prefix. - */ - IP_ADAPTER_PREFIX* prefix; - prefix_len = 0; - - for (prefix = adapter->FirstPrefix; prefix; prefix = prefix->Next) { - /* We want the longest matching prefix. */ - if (prefix->Address.lpSockaddr->sa_family != sa->sa_family || - prefix->PrefixLength <= prefix_len) - continue; - - if (address_prefix_match(sa->sa_family, sa, - prefix->Address.lpSockaddr, prefix->PrefixLength)) { - prefix_len = prefix->PrefixLength; - } - } - - /* If there is no matching prefix information, return a single-host - * subnet mask (e.g. 255.255.255.255 for IPv4). - */ - if (!prefix_len) - prefix_len = (sa->sa_family == AF_INET6) ? 128 : 32; - } - - memset(uv_address, 0, sizeof *uv_address); - - uv_address->name = name_buf; - - if (adapter->PhysicalAddressLength == sizeof(uv_address->phys_addr)) { - memcpy(uv_address->phys_addr, - adapter->PhysicalAddress, - sizeof(uv_address->phys_addr)); - } - - uv_address->is_internal = - (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK); - - if (sa->sa_family == AF_INET6) { - uv_address->address.address6 = *((struct sockaddr_in6 *) sa); - - uv_address->netmask.netmask6.sin6_family = AF_INET6; - memset(uv_address->netmask.netmask6.sin6_addr.s6_addr, 0xff, prefix_len >> 3); - /* This check ensures that we don't write past the size of the data. */ - if (prefix_len % 8) { - uv_address->netmask.netmask6.sin6_addr.s6_addr[prefix_len >> 3] = - 0xff << (8 - prefix_len % 8); - } - - } else { - uv_address->address.address4 = *((struct sockaddr_in *) sa); - - uv_address->netmask.netmask4.sin_family = AF_INET; - uv_address->netmask.netmask4.sin_addr.s_addr = (prefix_len > 0) ? - htonl(0xffffffff << (32 - prefix_len)) : 0; - } - - uv_address++; - } - - name_buf += name_size; - } - - uv__free(win_address_buf); - - *addresses_ptr = uv_address_buf; - *count_ptr = count; - - return 0; -} - - -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} - - -int uv_getrusage(uv_rusage_t *uv_rusage) { - FILETIME createTime, exitTime, kernelTime, userTime; - SYSTEMTIME kernelSystemTime, userSystemTime; - PROCESS_MEMORY_COUNTERS memCounters; - IO_COUNTERS ioCounters; - int ret; - - ret = GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = FileTimeToSystemTime(&kernelTime, &kernelSystemTime); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = FileTimeToSystemTime(&userTime, &userSystemTime); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = GetProcessMemoryInfo(GetCurrentProcess(), - &memCounters, - sizeof(memCounters)); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - ret = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); - if (ret == 0) { - return uv_translate_sys_error(GetLastError()); - } - - memset(uv_rusage, 0, sizeof(*uv_rusage)); - - uv_rusage->ru_utime.tv_sec = userSystemTime.wHour * 3600 + - userSystemTime.wMinute * 60 + - userSystemTime.wSecond; - uv_rusage->ru_utime.tv_usec = userSystemTime.wMilliseconds * 1000; - - uv_rusage->ru_stime.tv_sec = kernelSystemTime.wHour * 3600 + - kernelSystemTime.wMinute * 60 + - kernelSystemTime.wSecond; - uv_rusage->ru_stime.tv_usec = kernelSystemTime.wMilliseconds * 1000; - - uv_rusage->ru_majflt = (uint64_t) memCounters.PageFaultCount; - uv_rusage->ru_maxrss = (uint64_t) memCounters.PeakWorkingSetSize / 1024; - - uv_rusage->ru_oublock = (uint64_t) ioCounters.WriteOperationCount; - uv_rusage->ru_inblock = (uint64_t) ioCounters.ReadOperationCount; - - return 0; -} - - -int uv_os_homedir(char* buffer, size_t* size) { - uv_passwd_t pwd; - wchar_t path[MAX_PATH]; - DWORD bufsize; - size_t len; - int r; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - /* Check if the USERPROFILE environment variable is set first */ - len = GetEnvironmentVariableW(L"USERPROFILE", path, MAX_PATH); - - if (len == 0) { - r = GetLastError(); - - /* Don't return an error if USERPROFILE was not found */ - if (r != ERROR_ENVVAR_NOT_FOUND) - return uv_translate_sys_error(r); - } else if (len > MAX_PATH) { - /* This should not be possible */ - return UV_EIO; - } else { - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - path, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; - } - - /* USERPROFILE is not set, so call uv__getpwuid_r() */ - r = uv__getpwuid_r(&pwd); - - if (r != 0) { - return r; - } - - len = strlen(pwd.homedir); - - if (len >= *size) { - *size = len + 1; - uv_os_free_passwd(&pwd); - return UV_ENOBUFS; - } - - memcpy(buffer, pwd.homedir, len + 1); - *size = len; - uv_os_free_passwd(&pwd); - - return 0; -} - - -int uv_os_tmpdir(char* buffer, size_t* size) { - wchar_t path[MAX_PATH + 1]; - DWORD bufsize; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - len = GetTempPathW(MAX_PATH + 1, path); - - if (len == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (len > MAX_PATH + 1) { - /* This should not be possible */ - return UV_EIO; - } - - /* The returned directory should not have a trailing slash, unless it */ - /* points at a drive root, like c:\. Remove it if needed.*/ - if (path[len - 1] == L'\\' && - !(len == 3 && path[1] == L':')) { - len--; - path[len] = L'\0'; - } - - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - path, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; -} - - -void uv_os_free_passwd(uv_passwd_t* pwd) { - if (pwd == NULL) - return; - - uv__free(pwd->username); - uv__free(pwd->homedir); - pwd->username = NULL; - pwd->homedir = NULL; -} - - -/* - * Converts a UTF-16 string into a UTF-8 one. The resulting string is - * null-terminated. - * - * If utf16 is null terminated, utf16len can be set to -1, otherwise it must - * be specified. - */ -int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8) { - DWORD bufsize; - - if (utf16 == NULL) - return UV_EINVAL; - - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - utf16len, - NULL, - 0, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - /* Allocate the destination buffer adding an extra byte for the terminating - * NULL. If utf16len is not -1 WideCharToMultiByte will not add it, so - * we do it ourselves always, just in case. */ - *utf8 = uv__malloc(bufsize + 1); - - if (*utf8 == NULL) - return UV_ENOMEM; - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - utf16len, - *utf8, - bufsize, - NULL, - NULL); - - if (bufsize == 0) { - uv__free(*utf8); - *utf8 = NULL; - return uv_translate_sys_error(GetLastError()); - } - - (*utf8)[bufsize] = '\0'; - return 0; -} - - -/* - * Converts a UTF-8 string into a UTF-16 one. The resulting string is - * null-terminated. - * - * If utf8 is null terminated, utf8len can be set to -1, otherwise it must - * be specified. - */ -int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) { - int bufsize; - - if (utf8 == NULL) - return UV_EINVAL; - - /* Check how much space we need */ - bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, NULL, 0); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - /* Allocate the destination buffer adding an extra byte for the terminating - * NULL. If utf8len is not -1 MultiByteToWideChar will not add it, so - * we do it ourselves always, just in case. */ - *utf16 = uv__malloc(sizeof(WCHAR) * (bufsize + 1)); - - if (*utf16 == NULL) - return UV_ENOMEM; - - /* Convert to UTF-16 */ - bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, *utf16, bufsize); - - if (bufsize == 0) { - uv__free(*utf16); - *utf16 = NULL; - return uv_translate_sys_error(GetLastError()); - } - - (*utf16)[bufsize] = '\0'; - return 0; -} - - -int uv__getpwuid_r(uv_passwd_t* pwd) { - HANDLE token; - wchar_t username[UNLEN + 1]; - wchar_t path[MAX_PATH]; - DWORD bufsize; - int r; - - if (pwd == NULL) - return UV_EINVAL; - - /* Get the home directory using GetUserProfileDirectoryW() */ - if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0) - return uv_translate_sys_error(GetLastError()); - - bufsize = sizeof(path); - if (!GetUserProfileDirectoryW(token, path, &bufsize)) { - r = GetLastError(); - CloseHandle(token); - - /* This should not be possible */ - if (r == ERROR_INSUFFICIENT_BUFFER) - return UV_ENOMEM; - - return uv_translate_sys_error(r); - } - - CloseHandle(token); - - /* Get the username using GetUserNameW() */ - bufsize = sizeof(username); - if (!GetUserNameW(username, &bufsize)) { - r = GetLastError(); - - /* This should not be possible */ - if (r == ERROR_INSUFFICIENT_BUFFER) - return UV_ENOMEM; - - return uv_translate_sys_error(r); - } - - pwd->homedir = NULL; - r = uv__convert_utf16_to_utf8(path, -1, &pwd->homedir); - - if (r != 0) - return r; - - pwd->username = NULL; - r = uv__convert_utf16_to_utf8(username, -1, &pwd->username); - - if (r != 0) { - uv__free(pwd->homedir); - return r; - } - - pwd->shell = NULL; - pwd->uid = -1; - pwd->gid = -1; - - return 0; -} - - -int uv_os_get_passwd(uv_passwd_t* pwd) { - return uv__getpwuid_r(pwd); -} - - -int uv_os_getenv(const char* name, char* buffer, size_t* size) { - wchar_t var[MAX_ENV_VAR_LENGTH]; - wchar_t* name_w; - DWORD bufsize; - size_t len; - int r; - - if (name == NULL || buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - r = uv__convert_utf8_to_utf16(name, -1, &name_w); - - if (r != 0) - return r; - - len = GetEnvironmentVariableW(name_w, var, MAX_ENV_VAR_LENGTH); - uv__free(name_w); - assert(len < MAX_ENV_VAR_LENGTH); /* len does not include the null */ - - if (len == 0) { - r = GetLastError(); - - if (r == ERROR_ENVVAR_NOT_FOUND) - return UV_ENOENT; - - return uv_translate_sys_error(r); - } - - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, var, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - var, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; -} - - -int uv_os_setenv(const char* name, const char* value) { - wchar_t* name_w; - wchar_t* value_w; - int r; - - if (name == NULL || value == NULL) - return UV_EINVAL; - - r = uv__convert_utf8_to_utf16(name, -1, &name_w); - - if (r != 0) - return r; - - r = uv__convert_utf8_to_utf16(value, -1, &value_w); - - if (r != 0) { - uv__free(name_w); - return r; - } - - r = SetEnvironmentVariableW(name_w, value_w); - uv__free(name_w); - uv__free(value_w); - - if (r == 0) - return uv_translate_sys_error(GetLastError()); - - return 0; -} - - -int uv_os_unsetenv(const char* name) { - wchar_t* name_w; - int r; - - if (name == NULL) - return UV_EINVAL; - - r = uv__convert_utf8_to_utf16(name, -1, &name_w); - - if (r != 0) - return r; - - r = SetEnvironmentVariableW(name_w, NULL); - uv__free(name_w); - - if (r == 0) - return uv_translate_sys_error(GetLastError()); - - return 0; -} - - -int uv_os_gethostname(char* buffer, size_t* size) { - char buf[MAXHOSTNAMELEN + 1]; - size_t len; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - uv__once_init(); /* Initialize winsock */ - - if (gethostname(buf, sizeof(buf)) != 0) - return uv_translate_sys_error(WSAGetLastError()); - - buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */ - len = strlen(buf); - - if (len >= *size) { - *size = len + 1; - return UV_ENOBUFS; - } - - memcpy(buffer, buf, len + 1); - *size = len; - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/winapi.c b/lib/ESPiLight/pilight/libs/libuv/win/winapi.c deleted file mode 100644 index aa5d719..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/winapi.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include - -#include "uv.h" -#include "internal.h" - - -/* Ntdll function pointers */ -sRtlNtStatusToDosError pRtlNtStatusToDosError; -sNtDeviceIoControlFile pNtDeviceIoControlFile; -sNtQueryInformationFile pNtQueryInformationFile; -sNtSetInformationFile pNtSetInformationFile; -sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; -sNtQueryDirectoryFile pNtQueryDirectoryFile; -sNtQuerySystemInformation pNtQuerySystemInformation; - - -/* Kernel32 function pointers */ -sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; -sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; -sCreateSymbolicLinkW pCreateSymbolicLinkW; -sCancelIoEx pCancelIoEx; -sInitializeConditionVariable pInitializeConditionVariable; -sSleepConditionVariableCS pSleepConditionVariableCS; -sSleepConditionVariableSRW pSleepConditionVariableSRW; -sWakeAllConditionVariable pWakeAllConditionVariable; -sWakeConditionVariable pWakeConditionVariable; -sCancelSynchronousIo pCancelSynchronousIo; -sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; - - -/* Powrprof.dll function pointer */ -sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; - - -void uv_winapi_init(void) { - HMODULE ntdll_module; - HMODULE kernel32_module; - HMODULE powrprof_module; - - ntdll_module = GetModuleHandleA("ntdll.dll"); - if (ntdll_module == NULL) { - uv_fatal_error(GetLastError(), "GetModuleHandleA"); - } - - pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress( - ntdll_module, - "RtlNtStatusToDosError"); - if (pRtlNtStatusToDosError == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtDeviceIoControlFile = (sNtDeviceIoControlFile) GetProcAddress( - ntdll_module, - "NtDeviceIoControlFile"); - if (pNtDeviceIoControlFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress( - ntdll_module, - "NtQueryInformationFile"); - if (pNtQueryInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress( - ntdll_module, - "NtSetInformationFile"); - if (pNtSetInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQueryVolumeInformationFile = (sNtQueryVolumeInformationFile) - GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile"); - if (pNtQueryVolumeInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQueryDirectoryFile = (sNtQueryDirectoryFile) - GetProcAddress(ntdll_module, "NtQueryDirectoryFile"); - if (pNtQueryVolumeInformationFile == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - pNtQuerySystemInformation = (sNtQuerySystemInformation) GetProcAddress( - ntdll_module, - "NtQuerySystemInformation"); - if (pNtQuerySystemInformation == NULL) { - uv_fatal_error(GetLastError(), "GetProcAddress"); - } - - kernel32_module = GetModuleHandleA("kernel32.dll"); - if (kernel32_module == NULL) { - uv_fatal_error(GetLastError(), "GetModuleHandleA"); - } - - pGetQueuedCompletionStatusEx = (sGetQueuedCompletionStatusEx) GetProcAddress( - kernel32_module, - "GetQueuedCompletionStatusEx"); - - pSetFileCompletionNotificationModes = (sSetFileCompletionNotificationModes) - GetProcAddress(kernel32_module, "SetFileCompletionNotificationModes"); - - pCreateSymbolicLinkW = (sCreateSymbolicLinkW) - GetProcAddress(kernel32_module, "CreateSymbolicLinkW"); - - pCancelIoEx = (sCancelIoEx) - GetProcAddress(kernel32_module, "CancelIoEx"); - - pInitializeConditionVariable = (sInitializeConditionVariable) - GetProcAddress(kernel32_module, "InitializeConditionVariable"); - - pSleepConditionVariableCS = (sSleepConditionVariableCS) - GetProcAddress(kernel32_module, "SleepConditionVariableCS"); - - pSleepConditionVariableSRW = (sSleepConditionVariableSRW) - GetProcAddress(kernel32_module, "SleepConditionVariableSRW"); - - pWakeAllConditionVariable = (sWakeAllConditionVariable) - GetProcAddress(kernel32_module, "WakeAllConditionVariable"); - - pWakeConditionVariable = (sWakeConditionVariable) - GetProcAddress(kernel32_module, "WakeConditionVariable"); - - pCancelSynchronousIo = (sCancelSynchronousIo) - GetProcAddress(kernel32_module, "CancelSynchronousIo"); - - pGetFinalPathNameByHandleW = (sGetFinalPathNameByHandleW) - GetProcAddress(kernel32_module, "GetFinalPathNameByHandleW"); - - - powrprof_module = LoadLibraryA("powrprof.dll"); - if (powrprof_module != NULL) { - pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification) - GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification"); - } - -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/winapi.h b/lib/ESPiLight/pilight/libs/libuv/win/winapi.h deleted file mode 100644 index 9401676..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/winapi.h +++ /dev/null @@ -1,4752 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_WINAPI_H_ -#define UV_WIN_WINAPI_H_ - -#include - - -/* - * Ntdll headers - */ -#ifndef STATUS_SEVERITY_SUCCESS -# define STATUS_SEVERITY_SUCCESS 0x0 -#endif - -#ifndef STATUS_SEVERITY_INFORMATIONAL -# define STATUS_SEVERITY_INFORMATIONAL 0x1 -#endif - -#ifndef STATUS_SEVERITY_WARNING -# define STATUS_SEVERITY_WARNING 0x2 -#endif - -#ifndef STATUS_SEVERITY_ERROR -# define STATUS_SEVERITY_ERROR 0x3 -#endif - -#ifndef FACILITY_NTWIN32 -# define FACILITY_NTWIN32 0x7 -#endif - -#ifndef NT_SUCCESS -# define NT_SUCCESS(status) (((NTSTATUS) (status)) >= 0) -#endif - -#ifndef NT_INFORMATION -# define NT_INFORMATION(status) ((((ULONG) (status)) >> 30) == 1) -#endif - -#ifndef NT_WARNING -# define NT_WARNING(status) ((((ULONG) (status)) >> 30) == 2) -#endif - -#ifndef NT_ERROR -# define NT_ERROR(status) ((((ULONG) (status)) >> 30) == 3) -#endif - -#ifndef STATUS_SUCCESS -# define STATUS_SUCCESS ((NTSTATUS) 0x00000000L) -#endif - -#ifndef STATUS_WAIT_0 -# define STATUS_WAIT_0 ((NTSTATUS) 0x00000000L) -#endif - -#ifndef STATUS_WAIT_1 -# define STATUS_WAIT_1 ((NTSTATUS) 0x00000001L) -#endif - -#ifndef STATUS_WAIT_2 -# define STATUS_WAIT_2 ((NTSTATUS) 0x00000002L) -#endif - -#ifndef STATUS_WAIT_3 -# define STATUS_WAIT_3 ((NTSTATUS) 0x00000003L) -#endif - -#ifndef STATUS_WAIT_63 -# define STATUS_WAIT_63 ((NTSTATUS) 0x0000003FL) -#endif - -#ifndef STATUS_ABANDONED -# define STATUS_ABANDONED ((NTSTATUS) 0x00000080L) -#endif - -#ifndef STATUS_ABANDONED_WAIT_0 -# define STATUS_ABANDONED_WAIT_0 ((NTSTATUS) 0x00000080L) -#endif - -#ifndef STATUS_ABANDONED_WAIT_63 -# define STATUS_ABANDONED_WAIT_63 ((NTSTATUS) 0x000000BFL) -#endif - -#ifndef STATUS_USER_APC -# define STATUS_USER_APC ((NTSTATUS) 0x000000C0L) -#endif - -#ifndef STATUS_KERNEL_APC -# define STATUS_KERNEL_APC ((NTSTATUS) 0x00000100L) -#endif - -#ifndef STATUS_ALERTED -# define STATUS_ALERTED ((NTSTATUS) 0x00000101L) -#endif - -#ifndef STATUS_TIMEOUT -# define STATUS_TIMEOUT ((NTSTATUS) 0x00000102L) -#endif - -#ifndef STATUS_PENDING -# define STATUS_PENDING ((NTSTATUS) 0x00000103L) -#endif - -#ifndef STATUS_REPARSE -# define STATUS_REPARSE ((NTSTATUS) 0x00000104L) -#endif - -#ifndef STATUS_MORE_ENTRIES -# define STATUS_MORE_ENTRIES ((NTSTATUS) 0x00000105L) -#endif - -#ifndef STATUS_NOT_ALL_ASSIGNED -# define STATUS_NOT_ALL_ASSIGNED ((NTSTATUS) 0x00000106L) -#endif - -#ifndef STATUS_SOME_NOT_MAPPED -# define STATUS_SOME_NOT_MAPPED ((NTSTATUS) 0x00000107L) -#endif - -#ifndef STATUS_OPLOCK_BREAK_IN_PROGRESS -# define STATUS_OPLOCK_BREAK_IN_PROGRESS ((NTSTATUS) 0x00000108L) -#endif - -#ifndef STATUS_VOLUME_MOUNTED -# define STATUS_VOLUME_MOUNTED ((NTSTATUS) 0x00000109L) -#endif - -#ifndef STATUS_RXACT_COMMITTED -# define STATUS_RXACT_COMMITTED ((NTSTATUS) 0x0000010AL) -#endif - -#ifndef STATUS_NOTIFY_CLEANUP -# define STATUS_NOTIFY_CLEANUP ((NTSTATUS) 0x0000010BL) -#endif - -#ifndef STATUS_NOTIFY_ENUM_DIR -# define STATUS_NOTIFY_ENUM_DIR ((NTSTATUS) 0x0000010CL) -#endif - -#ifndef STATUS_NO_QUOTAS_FOR_ACCOUNT -# define STATUS_NO_QUOTAS_FOR_ACCOUNT ((NTSTATUS) 0x0000010DL) -#endif - -#ifndef STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED -# define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED ((NTSTATUS) 0x0000010EL) -#endif - -#ifndef STATUS_PAGE_FAULT_TRANSITION -# define STATUS_PAGE_FAULT_TRANSITION ((NTSTATUS) 0x00000110L) -#endif - -#ifndef STATUS_PAGE_FAULT_DEMAND_ZERO -# define STATUS_PAGE_FAULT_DEMAND_ZERO ((NTSTATUS) 0x00000111L) -#endif - -#ifndef STATUS_PAGE_FAULT_COPY_ON_WRITE -# define STATUS_PAGE_FAULT_COPY_ON_WRITE ((NTSTATUS) 0x00000112L) -#endif - -#ifndef STATUS_PAGE_FAULT_GUARD_PAGE -# define STATUS_PAGE_FAULT_GUARD_PAGE ((NTSTATUS) 0x00000113L) -#endif - -#ifndef STATUS_PAGE_FAULT_PAGING_FILE -# define STATUS_PAGE_FAULT_PAGING_FILE ((NTSTATUS) 0x00000114L) -#endif - -#ifndef STATUS_CACHE_PAGE_LOCKED -# define STATUS_CACHE_PAGE_LOCKED ((NTSTATUS) 0x00000115L) -#endif - -#ifndef STATUS_CRASH_DUMP -# define STATUS_CRASH_DUMP ((NTSTATUS) 0x00000116L) -#endif - -#ifndef STATUS_BUFFER_ALL_ZEROS -# define STATUS_BUFFER_ALL_ZEROS ((NTSTATUS) 0x00000117L) -#endif - -#ifndef STATUS_REPARSE_OBJECT -# define STATUS_REPARSE_OBJECT ((NTSTATUS) 0x00000118L) -#endif - -#ifndef STATUS_RESOURCE_REQUIREMENTS_CHANGED -# define STATUS_RESOURCE_REQUIREMENTS_CHANGED ((NTSTATUS) 0x00000119L) -#endif - -#ifndef STATUS_TRANSLATION_COMPLETE -# define STATUS_TRANSLATION_COMPLETE ((NTSTATUS) 0x00000120L) -#endif - -#ifndef STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY -# define STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY ((NTSTATUS) 0x00000121L) -#endif - -#ifndef STATUS_NOTHING_TO_TERMINATE -# define STATUS_NOTHING_TO_TERMINATE ((NTSTATUS) 0x00000122L) -#endif - -#ifndef STATUS_PROCESS_NOT_IN_JOB -# define STATUS_PROCESS_NOT_IN_JOB ((NTSTATUS) 0x00000123L) -#endif - -#ifndef STATUS_PROCESS_IN_JOB -# define STATUS_PROCESS_IN_JOB ((NTSTATUS) 0x00000124L) -#endif - -#ifndef STATUS_VOLSNAP_HIBERNATE_READY -# define STATUS_VOLSNAP_HIBERNATE_READY ((NTSTATUS) 0x00000125L) -#endif - -#ifndef STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY -# define STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY ((NTSTATUS) 0x00000126L) -#endif - -#ifndef STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED -# define STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED ((NTSTATUS) 0x00000127L) -#endif - -#ifndef STATUS_INTERRUPT_STILL_CONNECTED -# define STATUS_INTERRUPT_STILL_CONNECTED ((NTSTATUS) 0x00000128L) -#endif - -#ifndef STATUS_PROCESS_CLONED -# define STATUS_PROCESS_CLONED ((NTSTATUS) 0x00000129L) -#endif - -#ifndef STATUS_FILE_LOCKED_WITH_ONLY_READERS -# define STATUS_FILE_LOCKED_WITH_ONLY_READERS ((NTSTATUS) 0x0000012AL) -#endif - -#ifndef STATUS_FILE_LOCKED_WITH_WRITERS -# define STATUS_FILE_LOCKED_WITH_WRITERS ((NTSTATUS) 0x0000012BL) -#endif - -#ifndef STATUS_RESOURCEMANAGER_READ_ONLY -# define STATUS_RESOURCEMANAGER_READ_ONLY ((NTSTATUS) 0x00000202L) -#endif - -#ifndef STATUS_RING_PREVIOUSLY_EMPTY -# define STATUS_RING_PREVIOUSLY_EMPTY ((NTSTATUS) 0x00000210L) -#endif - -#ifndef STATUS_RING_PREVIOUSLY_FULL -# define STATUS_RING_PREVIOUSLY_FULL ((NTSTATUS) 0x00000211L) -#endif - -#ifndef STATUS_RING_PREVIOUSLY_ABOVE_QUOTA -# define STATUS_RING_PREVIOUSLY_ABOVE_QUOTA ((NTSTATUS) 0x00000212L) -#endif - -#ifndef STATUS_RING_NEWLY_EMPTY -# define STATUS_RING_NEWLY_EMPTY ((NTSTATUS) 0x00000213L) -#endif - -#ifndef STATUS_RING_SIGNAL_OPPOSITE_ENDPOINT -# define STATUS_RING_SIGNAL_OPPOSITE_ENDPOINT ((NTSTATUS) 0x00000214L) -#endif - -#ifndef STATUS_OPLOCK_SWITCHED_TO_NEW_HANDLE -# define STATUS_OPLOCK_SWITCHED_TO_NEW_HANDLE ((NTSTATUS) 0x00000215L) -#endif - -#ifndef STATUS_OPLOCK_HANDLE_CLOSED -# define STATUS_OPLOCK_HANDLE_CLOSED ((NTSTATUS) 0x00000216L) -#endif - -#ifndef STATUS_WAIT_FOR_OPLOCK -# define STATUS_WAIT_FOR_OPLOCK ((NTSTATUS) 0x00000367L) -#endif - -#ifndef STATUS_OBJECT_NAME_EXISTS -# define STATUS_OBJECT_NAME_EXISTS ((NTSTATUS) 0x40000000L) -#endif - -#ifndef STATUS_THREAD_WAS_SUSPENDED -# define STATUS_THREAD_WAS_SUSPENDED ((NTSTATUS) 0x40000001L) -#endif - -#ifndef STATUS_WORKING_SET_LIMIT_RANGE -# define STATUS_WORKING_SET_LIMIT_RANGE ((NTSTATUS) 0x40000002L) -#endif - -#ifndef STATUS_IMAGE_NOT_AT_BASE -# define STATUS_IMAGE_NOT_AT_BASE ((NTSTATUS) 0x40000003L) -#endif - -#ifndef STATUS_RXACT_STATE_CREATED -# define STATUS_RXACT_STATE_CREATED ((NTSTATUS) 0x40000004L) -#endif - -#ifndef STATUS_SEGMENT_NOTIFICATION -# define STATUS_SEGMENT_NOTIFICATION ((NTSTATUS) 0x40000005L) -#endif - -#ifndef STATUS_LOCAL_USER_SESSION_KEY -# define STATUS_LOCAL_USER_SESSION_KEY ((NTSTATUS) 0x40000006L) -#endif - -#ifndef STATUS_BAD_CURRENT_DIRECTORY -# define STATUS_BAD_CURRENT_DIRECTORY ((NTSTATUS) 0x40000007L) -#endif - -#ifndef STATUS_SERIAL_MORE_WRITES -# define STATUS_SERIAL_MORE_WRITES ((NTSTATUS) 0x40000008L) -#endif - -#ifndef STATUS_REGISTRY_RECOVERED -# define STATUS_REGISTRY_RECOVERED ((NTSTATUS) 0x40000009L) -#endif - -#ifndef STATUS_FT_READ_RECOVERY_FROM_BACKUP -# define STATUS_FT_READ_RECOVERY_FROM_BACKUP ((NTSTATUS) 0x4000000AL) -#endif - -#ifndef STATUS_FT_WRITE_RECOVERY -# define STATUS_FT_WRITE_RECOVERY ((NTSTATUS) 0x4000000BL) -#endif - -#ifndef STATUS_SERIAL_COUNTER_TIMEOUT -# define STATUS_SERIAL_COUNTER_TIMEOUT ((NTSTATUS) 0x4000000CL) -#endif - -#ifndef STATUS_NULL_LM_PASSWORD -# define STATUS_NULL_LM_PASSWORD ((NTSTATUS) 0x4000000DL) -#endif - -#ifndef STATUS_IMAGE_MACHINE_TYPE_MISMATCH -# define STATUS_IMAGE_MACHINE_TYPE_MISMATCH ((NTSTATUS) 0x4000000EL) -#endif - -#ifndef STATUS_RECEIVE_PARTIAL -# define STATUS_RECEIVE_PARTIAL ((NTSTATUS) 0x4000000FL) -#endif - -#ifndef STATUS_RECEIVE_EXPEDITED -# define STATUS_RECEIVE_EXPEDITED ((NTSTATUS) 0x40000010L) -#endif - -#ifndef STATUS_RECEIVE_PARTIAL_EXPEDITED -# define STATUS_RECEIVE_PARTIAL_EXPEDITED ((NTSTATUS) 0x40000011L) -#endif - -#ifndef STATUS_EVENT_DONE -# define STATUS_EVENT_DONE ((NTSTATUS) 0x40000012L) -#endif - -#ifndef STATUS_EVENT_PENDING -# define STATUS_EVENT_PENDING ((NTSTATUS) 0x40000013L) -#endif - -#ifndef STATUS_CHECKING_FILE_SYSTEM -# define STATUS_CHECKING_FILE_SYSTEM ((NTSTATUS) 0x40000014L) -#endif - -#ifndef STATUS_FATAL_APP_EXIT -# define STATUS_FATAL_APP_EXIT ((NTSTATUS) 0x40000015L) -#endif - -#ifndef STATUS_PREDEFINED_HANDLE -# define STATUS_PREDEFINED_HANDLE ((NTSTATUS) 0x40000016L) -#endif - -#ifndef STATUS_WAS_UNLOCKED -# define STATUS_WAS_UNLOCKED ((NTSTATUS) 0x40000017L) -#endif - -#ifndef STATUS_SERVICE_NOTIFICATION -# define STATUS_SERVICE_NOTIFICATION ((NTSTATUS) 0x40000018L) -#endif - -#ifndef STATUS_WAS_LOCKED -# define STATUS_WAS_LOCKED ((NTSTATUS) 0x40000019L) -#endif - -#ifndef STATUS_LOG_HARD_ERROR -# define STATUS_LOG_HARD_ERROR ((NTSTATUS) 0x4000001AL) -#endif - -#ifndef STATUS_ALREADY_WIN32 -# define STATUS_ALREADY_WIN32 ((NTSTATUS) 0x4000001BL) -#endif - -#ifndef STATUS_WX86_UNSIMULATE -# define STATUS_WX86_UNSIMULATE ((NTSTATUS) 0x4000001CL) -#endif - -#ifndef STATUS_WX86_CONTINUE -# define STATUS_WX86_CONTINUE ((NTSTATUS) 0x4000001DL) -#endif - -#ifndef STATUS_WX86_SINGLE_STEP -# define STATUS_WX86_SINGLE_STEP ((NTSTATUS) 0x4000001EL) -#endif - -#ifndef STATUS_WX86_BREAKPOINT -# define STATUS_WX86_BREAKPOINT ((NTSTATUS) 0x4000001FL) -#endif - -#ifndef STATUS_WX86_EXCEPTION_CONTINUE -# define STATUS_WX86_EXCEPTION_CONTINUE ((NTSTATUS) 0x40000020L) -#endif - -#ifndef STATUS_WX86_EXCEPTION_LASTCHANCE -# define STATUS_WX86_EXCEPTION_LASTCHANCE ((NTSTATUS) 0x40000021L) -#endif - -#ifndef STATUS_WX86_EXCEPTION_CHAIN -# define STATUS_WX86_EXCEPTION_CHAIN ((NTSTATUS) 0x40000022L) -#endif - -#ifndef STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE -# define STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE ((NTSTATUS) 0x40000023L) -#endif - -#ifndef STATUS_NO_YIELD_PERFORMED -# define STATUS_NO_YIELD_PERFORMED ((NTSTATUS) 0x40000024L) -#endif - -#ifndef STATUS_TIMER_RESUME_IGNORED -# define STATUS_TIMER_RESUME_IGNORED ((NTSTATUS) 0x40000025L) -#endif - -#ifndef STATUS_ARBITRATION_UNHANDLED -# define STATUS_ARBITRATION_UNHANDLED ((NTSTATUS) 0x40000026L) -#endif - -#ifndef STATUS_CARDBUS_NOT_SUPPORTED -# define STATUS_CARDBUS_NOT_SUPPORTED ((NTSTATUS) 0x40000027L) -#endif - -#ifndef STATUS_WX86_CREATEWX86TIB -# define STATUS_WX86_CREATEWX86TIB ((NTSTATUS) 0x40000028L) -#endif - -#ifndef STATUS_MP_PROCESSOR_MISMATCH -# define STATUS_MP_PROCESSOR_MISMATCH ((NTSTATUS) 0x40000029L) -#endif - -#ifndef STATUS_HIBERNATED -# define STATUS_HIBERNATED ((NTSTATUS) 0x4000002AL) -#endif - -#ifndef STATUS_RESUME_HIBERNATION -# define STATUS_RESUME_HIBERNATION ((NTSTATUS) 0x4000002BL) -#endif - -#ifndef STATUS_FIRMWARE_UPDATED -# define STATUS_FIRMWARE_UPDATED ((NTSTATUS) 0x4000002CL) -#endif - -#ifndef STATUS_DRIVERS_LEAKING_LOCKED_PAGES -# define STATUS_DRIVERS_LEAKING_LOCKED_PAGES ((NTSTATUS) 0x4000002DL) -#endif - -#ifndef STATUS_MESSAGE_RETRIEVED -# define STATUS_MESSAGE_RETRIEVED ((NTSTATUS) 0x4000002EL) -#endif - -#ifndef STATUS_SYSTEM_POWERSTATE_TRANSITION -# define STATUS_SYSTEM_POWERSTATE_TRANSITION ((NTSTATUS) 0x4000002FL) -#endif - -#ifndef STATUS_ALPC_CHECK_COMPLETION_LIST -# define STATUS_ALPC_CHECK_COMPLETION_LIST ((NTSTATUS) 0x40000030L) -#endif - -#ifndef STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION -# define STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION ((NTSTATUS) 0x40000031L) -#endif - -#ifndef STATUS_ACCESS_AUDIT_BY_POLICY -# define STATUS_ACCESS_AUDIT_BY_POLICY ((NTSTATUS) 0x40000032L) -#endif - -#ifndef STATUS_ABANDON_HIBERFILE -# define STATUS_ABANDON_HIBERFILE ((NTSTATUS) 0x40000033L) -#endif - -#ifndef STATUS_BIZRULES_NOT_ENABLED -# define STATUS_BIZRULES_NOT_ENABLED ((NTSTATUS) 0x40000034L) -#endif - -#ifndef STATUS_GUARD_PAGE_VIOLATION -# define STATUS_GUARD_PAGE_VIOLATION ((NTSTATUS) 0x80000001L) -#endif - -#ifndef STATUS_DATATYPE_MISALIGNMENT -# define STATUS_DATATYPE_MISALIGNMENT ((NTSTATUS) 0x80000002L) -#endif - -#ifndef STATUS_BREAKPOINT -# define STATUS_BREAKPOINT ((NTSTATUS) 0x80000003L) -#endif - -#ifndef STATUS_SINGLE_STEP -# define STATUS_SINGLE_STEP ((NTSTATUS) 0x80000004L) -#endif - -#ifndef STATUS_BUFFER_OVERFLOW -# define STATUS_BUFFER_OVERFLOW ((NTSTATUS) 0x80000005L) -#endif - -#ifndef STATUS_NO_MORE_FILES -# define STATUS_NO_MORE_FILES ((NTSTATUS) 0x80000006L) -#endif - -#ifndef STATUS_WAKE_SYSTEM_DEBUGGER -# define STATUS_WAKE_SYSTEM_DEBUGGER ((NTSTATUS) 0x80000007L) -#endif - -#ifndef STATUS_HANDLES_CLOSED -# define STATUS_HANDLES_CLOSED ((NTSTATUS) 0x8000000AL) -#endif - -#ifndef STATUS_NO_INHERITANCE -# define STATUS_NO_INHERITANCE ((NTSTATUS) 0x8000000BL) -#endif - -#ifndef STATUS_GUID_SUBSTITUTION_MADE -# define STATUS_GUID_SUBSTITUTION_MADE ((NTSTATUS) 0x8000000CL) -#endif - -#ifndef STATUS_PARTIAL_COPY -# define STATUS_PARTIAL_COPY ((NTSTATUS) 0x8000000DL) -#endif - -#ifndef STATUS_DEVICE_PAPER_EMPTY -# define STATUS_DEVICE_PAPER_EMPTY ((NTSTATUS) 0x8000000EL) -#endif - -#ifndef STATUS_DEVICE_POWERED_OFF -# define STATUS_DEVICE_POWERED_OFF ((NTSTATUS) 0x8000000FL) -#endif - -#ifndef STATUS_DEVICE_OFF_LINE -# define STATUS_DEVICE_OFF_LINE ((NTSTATUS) 0x80000010L) -#endif - -#ifndef STATUS_DEVICE_BUSY -# define STATUS_DEVICE_BUSY ((NTSTATUS) 0x80000011L) -#endif - -#ifndef STATUS_NO_MORE_EAS -# define STATUS_NO_MORE_EAS ((NTSTATUS) 0x80000012L) -#endif - -#ifndef STATUS_INVALID_EA_NAME -# define STATUS_INVALID_EA_NAME ((NTSTATUS) 0x80000013L) -#endif - -#ifndef STATUS_EA_LIST_INCONSISTENT -# define STATUS_EA_LIST_INCONSISTENT ((NTSTATUS) 0x80000014L) -#endif - -#ifndef STATUS_INVALID_EA_FLAG -# define STATUS_INVALID_EA_FLAG ((NTSTATUS) 0x80000015L) -#endif - -#ifndef STATUS_VERIFY_REQUIRED -# define STATUS_VERIFY_REQUIRED ((NTSTATUS) 0x80000016L) -#endif - -#ifndef STATUS_EXTRANEOUS_INFORMATION -# define STATUS_EXTRANEOUS_INFORMATION ((NTSTATUS) 0x80000017L) -#endif - -#ifndef STATUS_RXACT_COMMIT_NECESSARY -# define STATUS_RXACT_COMMIT_NECESSARY ((NTSTATUS) 0x80000018L) -#endif - -#ifndef STATUS_NO_MORE_ENTRIES -# define STATUS_NO_MORE_ENTRIES ((NTSTATUS) 0x8000001AL) -#endif - -#ifndef STATUS_FILEMARK_DETECTED -# define STATUS_FILEMARK_DETECTED ((NTSTATUS) 0x8000001BL) -#endif - -#ifndef STATUS_MEDIA_CHANGED -# define STATUS_MEDIA_CHANGED ((NTSTATUS) 0x8000001CL) -#endif - -#ifndef STATUS_BUS_RESET -# define STATUS_BUS_RESET ((NTSTATUS) 0x8000001DL) -#endif - -#ifndef STATUS_END_OF_MEDIA -# define STATUS_END_OF_MEDIA ((NTSTATUS) 0x8000001EL) -#endif - -#ifndef STATUS_BEGINNING_OF_MEDIA -# define STATUS_BEGINNING_OF_MEDIA ((NTSTATUS) 0x8000001FL) -#endif - -#ifndef STATUS_MEDIA_CHECK -# define STATUS_MEDIA_CHECK ((NTSTATUS) 0x80000020L) -#endif - -#ifndef STATUS_SETMARK_DETECTED -# define STATUS_SETMARK_DETECTED ((NTSTATUS) 0x80000021L) -#endif - -#ifndef STATUS_NO_DATA_DETECTED -# define STATUS_NO_DATA_DETECTED ((NTSTATUS) 0x80000022L) -#endif - -#ifndef STATUS_REDIRECTOR_HAS_OPEN_HANDLES -# define STATUS_REDIRECTOR_HAS_OPEN_HANDLES ((NTSTATUS) 0x80000023L) -#endif - -#ifndef STATUS_SERVER_HAS_OPEN_HANDLES -# define STATUS_SERVER_HAS_OPEN_HANDLES ((NTSTATUS) 0x80000024L) -#endif - -#ifndef STATUS_ALREADY_DISCONNECTED -# define STATUS_ALREADY_DISCONNECTED ((NTSTATUS) 0x80000025L) -#endif - -#ifndef STATUS_LONGJUMP -# define STATUS_LONGJUMP ((NTSTATUS) 0x80000026L) -#endif - -#ifndef STATUS_CLEANER_CARTRIDGE_INSTALLED -# define STATUS_CLEANER_CARTRIDGE_INSTALLED ((NTSTATUS) 0x80000027L) -#endif - -#ifndef STATUS_PLUGPLAY_QUERY_VETOED -# define STATUS_PLUGPLAY_QUERY_VETOED ((NTSTATUS) 0x80000028L) -#endif - -#ifndef STATUS_UNWIND_CONSOLIDATE -# define STATUS_UNWIND_CONSOLIDATE ((NTSTATUS) 0x80000029L) -#endif - -#ifndef STATUS_REGISTRY_HIVE_RECOVERED -# define STATUS_REGISTRY_HIVE_RECOVERED ((NTSTATUS) 0x8000002AL) -#endif - -#ifndef STATUS_DLL_MIGHT_BE_INSECURE -# define STATUS_DLL_MIGHT_BE_INSECURE ((NTSTATUS) 0x8000002BL) -#endif - -#ifndef STATUS_DLL_MIGHT_BE_INCOMPATIBLE -# define STATUS_DLL_MIGHT_BE_INCOMPATIBLE ((NTSTATUS) 0x8000002CL) -#endif - -#ifndef STATUS_STOPPED_ON_SYMLINK -# define STATUS_STOPPED_ON_SYMLINK ((NTSTATUS) 0x8000002DL) -#endif - -#ifndef STATUS_CANNOT_GRANT_REQUESTED_OPLOCK -# define STATUS_CANNOT_GRANT_REQUESTED_OPLOCK ((NTSTATUS) 0x8000002EL) -#endif - -#ifndef STATUS_NO_ACE_CONDITION -# define STATUS_NO_ACE_CONDITION ((NTSTATUS) 0x8000002FL) -#endif - -#ifndef STATUS_UNSUCCESSFUL -# define STATUS_UNSUCCESSFUL ((NTSTATUS) 0xC0000001L) -#endif - -#ifndef STATUS_NOT_IMPLEMENTED -# define STATUS_NOT_IMPLEMENTED ((NTSTATUS) 0xC0000002L) -#endif - -#ifndef STATUS_INVALID_INFO_CLASS -# define STATUS_INVALID_INFO_CLASS ((NTSTATUS) 0xC0000003L) -#endif - -#ifndef STATUS_INFO_LENGTH_MISMATCH -# define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xC0000004L) -#endif - -#ifndef STATUS_ACCESS_VIOLATION -# define STATUS_ACCESS_VIOLATION ((NTSTATUS) 0xC0000005L) -#endif - -#ifndef STATUS_IN_PAGE_ERROR -# define STATUS_IN_PAGE_ERROR ((NTSTATUS) 0xC0000006L) -#endif - -#ifndef STATUS_PAGEFILE_QUOTA -# define STATUS_PAGEFILE_QUOTA ((NTSTATUS) 0xC0000007L) -#endif - -#ifndef STATUS_INVALID_HANDLE -# define STATUS_INVALID_HANDLE ((NTSTATUS) 0xC0000008L) -#endif - -#ifndef STATUS_BAD_INITIAL_STACK -# define STATUS_BAD_INITIAL_STACK ((NTSTATUS) 0xC0000009L) -#endif - -#ifndef STATUS_BAD_INITIAL_PC -# define STATUS_BAD_INITIAL_PC ((NTSTATUS) 0xC000000AL) -#endif - -#ifndef STATUS_INVALID_CID -# define STATUS_INVALID_CID ((NTSTATUS) 0xC000000BL) -#endif - -#ifndef STATUS_TIMER_NOT_CANCELED -# define STATUS_TIMER_NOT_CANCELED ((NTSTATUS) 0xC000000CL) -#endif - -#ifndef STATUS_INVALID_PARAMETER -# define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xC000000DL) -#endif - -#ifndef STATUS_NO_SUCH_DEVICE -# define STATUS_NO_SUCH_DEVICE ((NTSTATUS) 0xC000000EL) -#endif - -#ifndef STATUS_NO_SUCH_FILE -# define STATUS_NO_SUCH_FILE ((NTSTATUS) 0xC000000FL) -#endif - -#ifndef STATUS_INVALID_DEVICE_REQUEST -# define STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS) 0xC0000010L) -#endif - -#ifndef STATUS_END_OF_FILE -# define STATUS_END_OF_FILE ((NTSTATUS) 0xC0000011L) -#endif - -#ifndef STATUS_WRONG_VOLUME -# define STATUS_WRONG_VOLUME ((NTSTATUS) 0xC0000012L) -#endif - -#ifndef STATUS_NO_MEDIA_IN_DEVICE -# define STATUS_NO_MEDIA_IN_DEVICE ((NTSTATUS) 0xC0000013L) -#endif - -#ifndef STATUS_UNRECOGNIZED_MEDIA -# define STATUS_UNRECOGNIZED_MEDIA ((NTSTATUS) 0xC0000014L) -#endif - -#ifndef STATUS_NONEXISTENT_SECTOR -# define STATUS_NONEXISTENT_SECTOR ((NTSTATUS) 0xC0000015L) -#endif - -#ifndef STATUS_MORE_PROCESSING_REQUIRED -# define STATUS_MORE_PROCESSING_REQUIRED ((NTSTATUS) 0xC0000016L) -#endif - -#ifndef STATUS_NO_MEMORY -# define STATUS_NO_MEMORY ((NTSTATUS) 0xC0000017L) -#endif - -#ifndef STATUS_CONFLICTING_ADDRESSES -# define STATUS_CONFLICTING_ADDRESSES ((NTSTATUS) 0xC0000018L) -#endif - -#ifndef STATUS_NOT_MAPPED_VIEW -# define STATUS_NOT_MAPPED_VIEW ((NTSTATUS) 0xC0000019L) -#endif - -#ifndef STATUS_UNABLE_TO_FREE_VM -# define STATUS_UNABLE_TO_FREE_VM ((NTSTATUS) 0xC000001AL) -#endif - -#ifndef STATUS_UNABLE_TO_DELETE_SECTION -# define STATUS_UNABLE_TO_DELETE_SECTION ((NTSTATUS) 0xC000001BL) -#endif - -#ifndef STATUS_INVALID_SYSTEM_SERVICE -# define STATUS_INVALID_SYSTEM_SERVICE ((NTSTATUS) 0xC000001CL) -#endif - -#ifndef STATUS_ILLEGAL_INSTRUCTION -# define STATUS_ILLEGAL_INSTRUCTION ((NTSTATUS) 0xC000001DL) -#endif - -#ifndef STATUS_INVALID_LOCK_SEQUENCE -# define STATUS_INVALID_LOCK_SEQUENCE ((NTSTATUS) 0xC000001EL) -#endif - -#ifndef STATUS_INVALID_VIEW_SIZE -# define STATUS_INVALID_VIEW_SIZE ((NTSTATUS) 0xC000001FL) -#endif - -#ifndef STATUS_INVALID_FILE_FOR_SECTION -# define STATUS_INVALID_FILE_FOR_SECTION ((NTSTATUS) 0xC0000020L) -#endif - -#ifndef STATUS_ALREADY_COMMITTED -# define STATUS_ALREADY_COMMITTED ((NTSTATUS) 0xC0000021L) -#endif - -#ifndef STATUS_ACCESS_DENIED -# define STATUS_ACCESS_DENIED ((NTSTATUS) 0xC0000022L) -#endif - -#ifndef STATUS_BUFFER_TOO_SMALL -# define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xC0000023L) -#endif - -#ifndef STATUS_OBJECT_TYPE_MISMATCH -# define STATUS_OBJECT_TYPE_MISMATCH ((NTSTATUS) 0xC0000024L) -#endif - -#ifndef STATUS_NONCONTINUABLE_EXCEPTION -# define STATUS_NONCONTINUABLE_EXCEPTION ((NTSTATUS) 0xC0000025L) -#endif - -#ifndef STATUS_INVALID_DISPOSITION -# define STATUS_INVALID_DISPOSITION ((NTSTATUS) 0xC0000026L) -#endif - -#ifndef STATUS_UNWIND -# define STATUS_UNWIND ((NTSTATUS) 0xC0000027L) -#endif - -#ifndef STATUS_BAD_STACK -# define STATUS_BAD_STACK ((NTSTATUS) 0xC0000028L) -#endif - -#ifndef STATUS_INVALID_UNWIND_TARGET -# define STATUS_INVALID_UNWIND_TARGET ((NTSTATUS) 0xC0000029L) -#endif - -#ifndef STATUS_NOT_LOCKED -# define STATUS_NOT_LOCKED ((NTSTATUS) 0xC000002AL) -#endif - -#ifndef STATUS_PARITY_ERROR -# define STATUS_PARITY_ERROR ((NTSTATUS) 0xC000002BL) -#endif - -#ifndef STATUS_UNABLE_TO_DECOMMIT_VM -# define STATUS_UNABLE_TO_DECOMMIT_VM ((NTSTATUS) 0xC000002CL) -#endif - -#ifndef STATUS_NOT_COMMITTED -# define STATUS_NOT_COMMITTED ((NTSTATUS) 0xC000002DL) -#endif - -#ifndef STATUS_INVALID_PORT_ATTRIBUTES -# define STATUS_INVALID_PORT_ATTRIBUTES ((NTSTATUS) 0xC000002EL) -#endif - -#ifndef STATUS_PORT_MESSAGE_TOO_LONG -# define STATUS_PORT_MESSAGE_TOO_LONG ((NTSTATUS) 0xC000002FL) -#endif - -#ifndef STATUS_INVALID_PARAMETER_MIX -# define STATUS_INVALID_PARAMETER_MIX ((NTSTATUS) 0xC0000030L) -#endif - -#ifndef STATUS_INVALID_QUOTA_LOWER -# define STATUS_INVALID_QUOTA_LOWER ((NTSTATUS) 0xC0000031L) -#endif - -#ifndef STATUS_DISK_CORRUPT_ERROR -# define STATUS_DISK_CORRUPT_ERROR ((NTSTATUS) 0xC0000032L) -#endif - -#ifndef STATUS_OBJECT_NAME_INVALID -# define STATUS_OBJECT_NAME_INVALID ((NTSTATUS) 0xC0000033L) -#endif - -#ifndef STATUS_OBJECT_NAME_NOT_FOUND -# define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS) 0xC0000034L) -#endif - -#ifndef STATUS_OBJECT_NAME_COLLISION -# define STATUS_OBJECT_NAME_COLLISION ((NTSTATUS) 0xC0000035L) -#endif - -#ifndef STATUS_PORT_DISCONNECTED -# define STATUS_PORT_DISCONNECTED ((NTSTATUS) 0xC0000037L) -#endif - -#ifndef STATUS_DEVICE_ALREADY_ATTACHED -# define STATUS_DEVICE_ALREADY_ATTACHED ((NTSTATUS) 0xC0000038L) -#endif - -#ifndef STATUS_OBJECT_PATH_INVALID -# define STATUS_OBJECT_PATH_INVALID ((NTSTATUS) 0xC0000039L) -#endif - -#ifndef STATUS_OBJECT_PATH_NOT_FOUND -# define STATUS_OBJECT_PATH_NOT_FOUND ((NTSTATUS) 0xC000003AL) -#endif - -#ifndef STATUS_OBJECT_PATH_SYNTAX_BAD -# define STATUS_OBJECT_PATH_SYNTAX_BAD ((NTSTATUS) 0xC000003BL) -#endif - -#ifndef STATUS_DATA_OVERRUN -# define STATUS_DATA_OVERRUN ((NTSTATUS) 0xC000003CL) -#endif - -#ifndef STATUS_DATA_LATE_ERROR -# define STATUS_DATA_LATE_ERROR ((NTSTATUS) 0xC000003DL) -#endif - -#ifndef STATUS_DATA_ERROR -# define STATUS_DATA_ERROR ((NTSTATUS) 0xC000003EL) -#endif - -#ifndef STATUS_CRC_ERROR -# define STATUS_CRC_ERROR ((NTSTATUS) 0xC000003FL) -#endif - -#ifndef STATUS_SECTION_TOO_BIG -# define STATUS_SECTION_TOO_BIG ((NTSTATUS) 0xC0000040L) -#endif - -#ifndef STATUS_PORT_CONNECTION_REFUSED -# define STATUS_PORT_CONNECTION_REFUSED ((NTSTATUS) 0xC0000041L) -#endif - -#ifndef STATUS_INVALID_PORT_HANDLE -# define STATUS_INVALID_PORT_HANDLE ((NTSTATUS) 0xC0000042L) -#endif - -#ifndef STATUS_SHARING_VIOLATION -# define STATUS_SHARING_VIOLATION ((NTSTATUS) 0xC0000043L) -#endif - -#ifndef STATUS_QUOTA_EXCEEDED -# define STATUS_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000044L) -#endif - -#ifndef STATUS_INVALID_PAGE_PROTECTION -# define STATUS_INVALID_PAGE_PROTECTION ((NTSTATUS) 0xC0000045L) -#endif - -#ifndef STATUS_MUTANT_NOT_OWNED -# define STATUS_MUTANT_NOT_OWNED ((NTSTATUS) 0xC0000046L) -#endif - -#ifndef STATUS_SEMAPHORE_LIMIT_EXCEEDED -# define STATUS_SEMAPHORE_LIMIT_EXCEEDED ((NTSTATUS) 0xC0000047L) -#endif - -#ifndef STATUS_PORT_ALREADY_SET -# define STATUS_PORT_ALREADY_SET ((NTSTATUS) 0xC0000048L) -#endif - -#ifndef STATUS_SECTION_NOT_IMAGE -# define STATUS_SECTION_NOT_IMAGE ((NTSTATUS) 0xC0000049L) -#endif - -#ifndef STATUS_SUSPEND_COUNT_EXCEEDED -# define STATUS_SUSPEND_COUNT_EXCEEDED ((NTSTATUS) 0xC000004AL) -#endif - -#ifndef STATUS_THREAD_IS_TERMINATING -# define STATUS_THREAD_IS_TERMINATING ((NTSTATUS) 0xC000004BL) -#endif - -#ifndef STATUS_BAD_WORKING_SET_LIMIT -# define STATUS_BAD_WORKING_SET_LIMIT ((NTSTATUS) 0xC000004CL) -#endif - -#ifndef STATUS_INCOMPATIBLE_FILE_MAP -# define STATUS_INCOMPATIBLE_FILE_MAP ((NTSTATUS) 0xC000004DL) -#endif - -#ifndef STATUS_SECTION_PROTECTION -# define STATUS_SECTION_PROTECTION ((NTSTATUS) 0xC000004EL) -#endif - -#ifndef STATUS_EAS_NOT_SUPPORTED -# define STATUS_EAS_NOT_SUPPORTED ((NTSTATUS) 0xC000004FL) -#endif - -#ifndef STATUS_EA_TOO_LARGE -# define STATUS_EA_TOO_LARGE ((NTSTATUS) 0xC0000050L) -#endif - -#ifndef STATUS_NONEXISTENT_EA_ENTRY -# define STATUS_NONEXISTENT_EA_ENTRY ((NTSTATUS) 0xC0000051L) -#endif - -#ifndef STATUS_NO_EAS_ON_FILE -# define STATUS_NO_EAS_ON_FILE ((NTSTATUS) 0xC0000052L) -#endif - -#ifndef STATUS_EA_CORRUPT_ERROR -# define STATUS_EA_CORRUPT_ERROR ((NTSTATUS) 0xC0000053L) -#endif - -#ifndef STATUS_FILE_LOCK_CONFLICT -# define STATUS_FILE_LOCK_CONFLICT ((NTSTATUS) 0xC0000054L) -#endif - -#ifndef STATUS_LOCK_NOT_GRANTED -# define STATUS_LOCK_NOT_GRANTED ((NTSTATUS) 0xC0000055L) -#endif - -#ifndef STATUS_DELETE_PENDING -# define STATUS_DELETE_PENDING ((NTSTATUS) 0xC0000056L) -#endif - -#ifndef STATUS_CTL_FILE_NOT_SUPPORTED -# define STATUS_CTL_FILE_NOT_SUPPORTED ((NTSTATUS) 0xC0000057L) -#endif - -#ifndef STATUS_UNKNOWN_REVISION -# define STATUS_UNKNOWN_REVISION ((NTSTATUS) 0xC0000058L) -#endif - -#ifndef STATUS_REVISION_MISMATCH -# define STATUS_REVISION_MISMATCH ((NTSTATUS) 0xC0000059L) -#endif - -#ifndef STATUS_INVALID_OWNER -# define STATUS_INVALID_OWNER ((NTSTATUS) 0xC000005AL) -#endif - -#ifndef STATUS_INVALID_PRIMARY_GROUP -# define STATUS_INVALID_PRIMARY_GROUP ((NTSTATUS) 0xC000005BL) -#endif - -#ifndef STATUS_NO_IMPERSONATION_TOKEN -# define STATUS_NO_IMPERSONATION_TOKEN ((NTSTATUS) 0xC000005CL) -#endif - -#ifndef STATUS_CANT_DISABLE_MANDATORY -# define STATUS_CANT_DISABLE_MANDATORY ((NTSTATUS) 0xC000005DL) -#endif - -#ifndef STATUS_NO_LOGON_SERVERS -# define STATUS_NO_LOGON_SERVERS ((NTSTATUS) 0xC000005EL) -#endif - -#ifndef STATUS_NO_SUCH_LOGON_SESSION -# define STATUS_NO_SUCH_LOGON_SESSION ((NTSTATUS) 0xC000005FL) -#endif - -#ifndef STATUS_NO_SUCH_PRIVILEGE -# define STATUS_NO_SUCH_PRIVILEGE ((NTSTATUS) 0xC0000060L) -#endif - -#ifndef STATUS_PRIVILEGE_NOT_HELD -# define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS) 0xC0000061L) -#endif - -#ifndef STATUS_INVALID_ACCOUNT_NAME -# define STATUS_INVALID_ACCOUNT_NAME ((NTSTATUS) 0xC0000062L) -#endif - -#ifndef STATUS_USER_EXISTS -# define STATUS_USER_EXISTS ((NTSTATUS) 0xC0000063L) -#endif - -#ifndef STATUS_NO_SUCH_USER -# define STATUS_NO_SUCH_USER ((NTSTATUS) 0xC0000064L) -#endif - -#ifndef STATUS_GROUP_EXISTS -# define STATUS_GROUP_EXISTS ((NTSTATUS) 0xC0000065L) -#endif - -#ifndef STATUS_NO_SUCH_GROUP -# define STATUS_NO_SUCH_GROUP ((NTSTATUS) 0xC0000066L) -#endif - -#ifndef STATUS_MEMBER_IN_GROUP -# define STATUS_MEMBER_IN_GROUP ((NTSTATUS) 0xC0000067L) -#endif - -#ifndef STATUS_MEMBER_NOT_IN_GROUP -# define STATUS_MEMBER_NOT_IN_GROUP ((NTSTATUS) 0xC0000068L) -#endif - -#ifndef STATUS_LAST_ADMIN -# define STATUS_LAST_ADMIN ((NTSTATUS) 0xC0000069L) -#endif - -#ifndef STATUS_WRONG_PASSWORD -# define STATUS_WRONG_PASSWORD ((NTSTATUS) 0xC000006AL) -#endif - -#ifndef STATUS_ILL_FORMED_PASSWORD -# define STATUS_ILL_FORMED_PASSWORD ((NTSTATUS) 0xC000006BL) -#endif - -#ifndef STATUS_PASSWORD_RESTRICTION -# define STATUS_PASSWORD_RESTRICTION ((NTSTATUS) 0xC000006CL) -#endif - -#ifndef STATUS_LOGON_FAILURE -# define STATUS_LOGON_FAILURE ((NTSTATUS) 0xC000006DL) -#endif - -#ifndef STATUS_ACCOUNT_RESTRICTION -# define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS) 0xC000006EL) -#endif - -#ifndef STATUS_INVALID_LOGON_HOURS -# define STATUS_INVALID_LOGON_HOURS ((NTSTATUS) 0xC000006FL) -#endif - -#ifndef STATUS_INVALID_WORKSTATION -# define STATUS_INVALID_WORKSTATION ((NTSTATUS) 0xC0000070L) -#endif - -#ifndef STATUS_PASSWORD_EXPIRED -# define STATUS_PASSWORD_EXPIRED ((NTSTATUS) 0xC0000071L) -#endif - -#ifndef STATUS_ACCOUNT_DISABLED -# define STATUS_ACCOUNT_DISABLED ((NTSTATUS) 0xC0000072L) -#endif - -#ifndef STATUS_NONE_MAPPED -# define STATUS_NONE_MAPPED ((NTSTATUS) 0xC0000073L) -#endif - -#ifndef STATUS_TOO_MANY_LUIDS_REQUESTED -# define STATUS_TOO_MANY_LUIDS_REQUESTED ((NTSTATUS) 0xC0000074L) -#endif - -#ifndef STATUS_LUIDS_EXHAUSTED -# define STATUS_LUIDS_EXHAUSTED ((NTSTATUS) 0xC0000075L) -#endif - -#ifndef STATUS_INVALID_SUB_AUTHORITY -# define STATUS_INVALID_SUB_AUTHORITY ((NTSTATUS) 0xC0000076L) -#endif - -#ifndef STATUS_INVALID_ACL -# define STATUS_INVALID_ACL ((NTSTATUS) 0xC0000077L) -#endif - -#ifndef STATUS_INVALID_SID -# define STATUS_INVALID_SID ((NTSTATUS) 0xC0000078L) -#endif - -#ifndef STATUS_INVALID_SECURITY_DESCR -# define STATUS_INVALID_SECURITY_DESCR ((NTSTATUS) 0xC0000079L) -#endif - -#ifndef STATUS_PROCEDURE_NOT_FOUND -# define STATUS_PROCEDURE_NOT_FOUND ((NTSTATUS) 0xC000007AL) -#endif - -#ifndef STATUS_INVALID_IMAGE_FORMAT -# define STATUS_INVALID_IMAGE_FORMAT ((NTSTATUS) 0xC000007BL) -#endif - -#ifndef STATUS_NO_TOKEN -# define STATUS_NO_TOKEN ((NTSTATUS) 0xC000007CL) -#endif - -#ifndef STATUS_BAD_INHERITANCE_ACL -# define STATUS_BAD_INHERITANCE_ACL ((NTSTATUS) 0xC000007DL) -#endif - -#ifndef STATUS_RANGE_NOT_LOCKED -# define STATUS_RANGE_NOT_LOCKED ((NTSTATUS) 0xC000007EL) -#endif - -#ifndef STATUS_DISK_FULL -# define STATUS_DISK_FULL ((NTSTATUS) 0xC000007FL) -#endif - -#ifndef STATUS_SERVER_DISABLED -# define STATUS_SERVER_DISABLED ((NTSTATUS) 0xC0000080L) -#endif - -#ifndef STATUS_SERVER_NOT_DISABLED -# define STATUS_SERVER_NOT_DISABLED ((NTSTATUS) 0xC0000081L) -#endif - -#ifndef STATUS_TOO_MANY_GUIDS_REQUESTED -# define STATUS_TOO_MANY_GUIDS_REQUESTED ((NTSTATUS) 0xC0000082L) -#endif - -#ifndef STATUS_GUIDS_EXHAUSTED -# define STATUS_GUIDS_EXHAUSTED ((NTSTATUS) 0xC0000083L) -#endif - -#ifndef STATUS_INVALID_ID_AUTHORITY -# define STATUS_INVALID_ID_AUTHORITY ((NTSTATUS) 0xC0000084L) -#endif - -#ifndef STATUS_AGENTS_EXHAUSTED -# define STATUS_AGENTS_EXHAUSTED ((NTSTATUS) 0xC0000085L) -#endif - -#ifndef STATUS_INVALID_VOLUME_LABEL -# define STATUS_INVALID_VOLUME_LABEL ((NTSTATUS) 0xC0000086L) -#endif - -#ifndef STATUS_SECTION_NOT_EXTENDED -# define STATUS_SECTION_NOT_EXTENDED ((NTSTATUS) 0xC0000087L) -#endif - -#ifndef STATUS_NOT_MAPPED_DATA -# define STATUS_NOT_MAPPED_DATA ((NTSTATUS) 0xC0000088L) -#endif - -#ifndef STATUS_RESOURCE_DATA_NOT_FOUND -# define STATUS_RESOURCE_DATA_NOT_FOUND ((NTSTATUS) 0xC0000089L) -#endif - -#ifndef STATUS_RESOURCE_TYPE_NOT_FOUND -# define STATUS_RESOURCE_TYPE_NOT_FOUND ((NTSTATUS) 0xC000008AL) -#endif - -#ifndef STATUS_RESOURCE_NAME_NOT_FOUND -# define STATUS_RESOURCE_NAME_NOT_FOUND ((NTSTATUS) 0xC000008BL) -#endif - -#ifndef STATUS_ARRAY_BOUNDS_EXCEEDED -# define STATUS_ARRAY_BOUNDS_EXCEEDED ((NTSTATUS) 0xC000008CL) -#endif - -#ifndef STATUS_FLOAT_DENORMAL_OPERAND -# define STATUS_FLOAT_DENORMAL_OPERAND ((NTSTATUS) 0xC000008DL) -#endif - -#ifndef STATUS_FLOAT_DIVIDE_BY_ZERO -# define STATUS_FLOAT_DIVIDE_BY_ZERO ((NTSTATUS) 0xC000008EL) -#endif - -#ifndef STATUS_FLOAT_INEXACT_RESULT -# define STATUS_FLOAT_INEXACT_RESULT ((NTSTATUS) 0xC000008FL) -#endif - -#ifndef STATUS_FLOAT_INVALID_OPERATION -# define STATUS_FLOAT_INVALID_OPERATION ((NTSTATUS) 0xC0000090L) -#endif - -#ifndef STATUS_FLOAT_OVERFLOW -# define STATUS_FLOAT_OVERFLOW ((NTSTATUS) 0xC0000091L) -#endif - -#ifndef STATUS_FLOAT_STACK_CHECK -# define STATUS_FLOAT_STACK_CHECK ((NTSTATUS) 0xC0000092L) -#endif - -#ifndef STATUS_FLOAT_UNDERFLOW -# define STATUS_FLOAT_UNDERFLOW ((NTSTATUS) 0xC0000093L) -#endif - -#ifndef STATUS_INTEGER_DIVIDE_BY_ZERO -# define STATUS_INTEGER_DIVIDE_BY_ZERO ((NTSTATUS) 0xC0000094L) -#endif - -#ifndef STATUS_INTEGER_OVERFLOW -# define STATUS_INTEGER_OVERFLOW ((NTSTATUS) 0xC0000095L) -#endif - -#ifndef STATUS_PRIVILEGED_INSTRUCTION -# define STATUS_PRIVILEGED_INSTRUCTION ((NTSTATUS) 0xC0000096L) -#endif - -#ifndef STATUS_TOO_MANY_PAGING_FILES -# define STATUS_TOO_MANY_PAGING_FILES ((NTSTATUS) 0xC0000097L) -#endif - -#ifndef STATUS_FILE_INVALID -# define STATUS_FILE_INVALID ((NTSTATUS) 0xC0000098L) -#endif - -#ifndef STATUS_ALLOTTED_SPACE_EXCEEDED -# define STATUS_ALLOTTED_SPACE_EXCEEDED ((NTSTATUS) 0xC0000099L) -#endif - -#ifndef STATUS_INSUFFICIENT_RESOURCES -# define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS) 0xC000009AL) -#endif - -#ifndef STATUS_DFS_EXIT_PATH_FOUND -# define STATUS_DFS_EXIT_PATH_FOUND ((NTSTATUS) 0xC000009BL) -#endif - -#ifndef STATUS_DEVICE_DATA_ERROR -# define STATUS_DEVICE_DATA_ERROR ((NTSTATUS) 0xC000009CL) -#endif - -#ifndef STATUS_DEVICE_NOT_CONNECTED -# define STATUS_DEVICE_NOT_CONNECTED ((NTSTATUS) 0xC000009DL) -#endif - -#ifndef STATUS_DEVICE_POWER_FAILURE -# define STATUS_DEVICE_POWER_FAILURE ((NTSTATUS) 0xC000009EL) -#endif - -#ifndef STATUS_FREE_VM_NOT_AT_BASE -# define STATUS_FREE_VM_NOT_AT_BASE ((NTSTATUS) 0xC000009FL) -#endif - -#ifndef STATUS_MEMORY_NOT_ALLOCATED -# define STATUS_MEMORY_NOT_ALLOCATED ((NTSTATUS) 0xC00000A0L) -#endif - -#ifndef STATUS_WORKING_SET_QUOTA -# define STATUS_WORKING_SET_QUOTA ((NTSTATUS) 0xC00000A1L) -#endif - -#ifndef STATUS_MEDIA_WRITE_PROTECTED -# define STATUS_MEDIA_WRITE_PROTECTED ((NTSTATUS) 0xC00000A2L) -#endif - -#ifndef STATUS_DEVICE_NOT_READY -# define STATUS_DEVICE_NOT_READY ((NTSTATUS) 0xC00000A3L) -#endif - -#ifndef STATUS_INVALID_GROUP_ATTRIBUTES -# define STATUS_INVALID_GROUP_ATTRIBUTES ((NTSTATUS) 0xC00000A4L) -#endif - -#ifndef STATUS_BAD_IMPERSONATION_LEVEL -# define STATUS_BAD_IMPERSONATION_LEVEL ((NTSTATUS) 0xC00000A5L) -#endif - -#ifndef STATUS_CANT_OPEN_ANONYMOUS -# define STATUS_CANT_OPEN_ANONYMOUS ((NTSTATUS) 0xC00000A6L) -#endif - -#ifndef STATUS_BAD_VALIDATION_CLASS -# define STATUS_BAD_VALIDATION_CLASS ((NTSTATUS) 0xC00000A7L) -#endif - -#ifndef STATUS_BAD_TOKEN_TYPE -# define STATUS_BAD_TOKEN_TYPE ((NTSTATUS) 0xC00000A8L) -#endif - -#ifndef STATUS_BAD_MASTER_BOOT_RECORD -# define STATUS_BAD_MASTER_BOOT_RECORD ((NTSTATUS) 0xC00000A9L) -#endif - -#ifndef STATUS_INSTRUCTION_MISALIGNMENT -# define STATUS_INSTRUCTION_MISALIGNMENT ((NTSTATUS) 0xC00000AAL) -#endif - -#ifndef STATUS_INSTANCE_NOT_AVAILABLE -# define STATUS_INSTANCE_NOT_AVAILABLE ((NTSTATUS) 0xC00000ABL) -#endif - -#ifndef STATUS_PIPE_NOT_AVAILABLE -# define STATUS_PIPE_NOT_AVAILABLE ((NTSTATUS) 0xC00000ACL) -#endif - -#ifndef STATUS_INVALID_PIPE_STATE -# define STATUS_INVALID_PIPE_STATE ((NTSTATUS) 0xC00000ADL) -#endif - -#ifndef STATUS_PIPE_BUSY -# define STATUS_PIPE_BUSY ((NTSTATUS) 0xC00000AEL) -#endif - -#ifndef STATUS_ILLEGAL_FUNCTION -# define STATUS_ILLEGAL_FUNCTION ((NTSTATUS) 0xC00000AFL) -#endif - -#ifndef STATUS_PIPE_DISCONNECTED -# define STATUS_PIPE_DISCONNECTED ((NTSTATUS) 0xC00000B0L) -#endif - -#ifndef STATUS_PIPE_CLOSING -# define STATUS_PIPE_CLOSING ((NTSTATUS) 0xC00000B1L) -#endif - -#ifndef STATUS_PIPE_CONNECTED -# define STATUS_PIPE_CONNECTED ((NTSTATUS) 0xC00000B2L) -#endif - -#ifndef STATUS_PIPE_LISTENING -# define STATUS_PIPE_LISTENING ((NTSTATUS) 0xC00000B3L) -#endif - -#ifndef STATUS_INVALID_READ_MODE -# define STATUS_INVALID_READ_MODE ((NTSTATUS) 0xC00000B4L) -#endif - -#ifndef STATUS_IO_TIMEOUT -# define STATUS_IO_TIMEOUT ((NTSTATUS) 0xC00000B5L) -#endif - -#ifndef STATUS_FILE_FORCED_CLOSED -# define STATUS_FILE_FORCED_CLOSED ((NTSTATUS) 0xC00000B6L) -#endif - -#ifndef STATUS_PROFILING_NOT_STARTED -# define STATUS_PROFILING_NOT_STARTED ((NTSTATUS) 0xC00000B7L) -#endif - -#ifndef STATUS_PROFILING_NOT_STOPPED -# define STATUS_PROFILING_NOT_STOPPED ((NTSTATUS) 0xC00000B8L) -#endif - -#ifndef STATUS_COULD_NOT_INTERPRET -# define STATUS_COULD_NOT_INTERPRET ((NTSTATUS) 0xC00000B9L) -#endif - -#ifndef STATUS_FILE_IS_A_DIRECTORY -# define STATUS_FILE_IS_A_DIRECTORY ((NTSTATUS) 0xC00000BAL) -#endif - -#ifndef STATUS_NOT_SUPPORTED -# define STATUS_NOT_SUPPORTED ((NTSTATUS) 0xC00000BBL) -#endif - -#ifndef STATUS_REMOTE_NOT_LISTENING -# define STATUS_REMOTE_NOT_LISTENING ((NTSTATUS) 0xC00000BCL) -#endif - -#ifndef STATUS_DUPLICATE_NAME -# define STATUS_DUPLICATE_NAME ((NTSTATUS) 0xC00000BDL) -#endif - -#ifndef STATUS_BAD_NETWORK_PATH -# define STATUS_BAD_NETWORK_PATH ((NTSTATUS) 0xC00000BEL) -#endif - -#ifndef STATUS_NETWORK_BUSY -# define STATUS_NETWORK_BUSY ((NTSTATUS) 0xC00000BFL) -#endif - -#ifndef STATUS_DEVICE_DOES_NOT_EXIST -# define STATUS_DEVICE_DOES_NOT_EXIST ((NTSTATUS) 0xC00000C0L) -#endif - -#ifndef STATUS_TOO_MANY_COMMANDS -# define STATUS_TOO_MANY_COMMANDS ((NTSTATUS) 0xC00000C1L) -#endif - -#ifndef STATUS_ADAPTER_HARDWARE_ERROR -# define STATUS_ADAPTER_HARDWARE_ERROR ((NTSTATUS) 0xC00000C2L) -#endif - -#ifndef STATUS_INVALID_NETWORK_RESPONSE -# define STATUS_INVALID_NETWORK_RESPONSE ((NTSTATUS) 0xC00000C3L) -#endif - -#ifndef STATUS_UNEXPECTED_NETWORK_ERROR -# define STATUS_UNEXPECTED_NETWORK_ERROR ((NTSTATUS) 0xC00000C4L) -#endif - -#ifndef STATUS_BAD_REMOTE_ADAPTER -# define STATUS_BAD_REMOTE_ADAPTER ((NTSTATUS) 0xC00000C5L) -#endif - -#ifndef STATUS_PRINT_QUEUE_FULL -# define STATUS_PRINT_QUEUE_FULL ((NTSTATUS) 0xC00000C6L) -#endif - -#ifndef STATUS_NO_SPOOL_SPACE -# define STATUS_NO_SPOOL_SPACE ((NTSTATUS) 0xC00000C7L) -#endif - -#ifndef STATUS_PRINT_CANCELLED -# define STATUS_PRINT_CANCELLED ((NTSTATUS) 0xC00000C8L) -#endif - -#ifndef STATUS_NETWORK_NAME_DELETED -# define STATUS_NETWORK_NAME_DELETED ((NTSTATUS) 0xC00000C9L) -#endif - -#ifndef STATUS_NETWORK_ACCESS_DENIED -# define STATUS_NETWORK_ACCESS_DENIED ((NTSTATUS) 0xC00000CAL) -#endif - -#ifndef STATUS_BAD_DEVICE_TYPE -# define STATUS_BAD_DEVICE_TYPE ((NTSTATUS) 0xC00000CBL) -#endif - -#ifndef STATUS_BAD_NETWORK_NAME -# define STATUS_BAD_NETWORK_NAME ((NTSTATUS) 0xC00000CCL) -#endif - -#ifndef STATUS_TOO_MANY_NAMES -# define STATUS_TOO_MANY_NAMES ((NTSTATUS) 0xC00000CDL) -#endif - -#ifndef STATUS_TOO_MANY_SESSIONS -# define STATUS_TOO_MANY_SESSIONS ((NTSTATUS) 0xC00000CEL) -#endif - -#ifndef STATUS_SHARING_PAUSED -# define STATUS_SHARING_PAUSED ((NTSTATUS) 0xC00000CFL) -#endif - -#ifndef STATUS_REQUEST_NOT_ACCEPTED -# define STATUS_REQUEST_NOT_ACCEPTED ((NTSTATUS) 0xC00000D0L) -#endif - -#ifndef STATUS_REDIRECTOR_PAUSED -# define STATUS_REDIRECTOR_PAUSED ((NTSTATUS) 0xC00000D1L) -#endif - -#ifndef STATUS_NET_WRITE_FAULT -# define STATUS_NET_WRITE_FAULT ((NTSTATUS) 0xC00000D2L) -#endif - -#ifndef STATUS_PROFILING_AT_LIMIT -# define STATUS_PROFILING_AT_LIMIT ((NTSTATUS) 0xC00000D3L) -#endif - -#ifndef STATUS_NOT_SAME_DEVICE -# define STATUS_NOT_SAME_DEVICE ((NTSTATUS) 0xC00000D4L) -#endif - -#ifndef STATUS_FILE_RENAMED -# define STATUS_FILE_RENAMED ((NTSTATUS) 0xC00000D5L) -#endif - -#ifndef STATUS_VIRTUAL_CIRCUIT_CLOSED -# define STATUS_VIRTUAL_CIRCUIT_CLOSED ((NTSTATUS) 0xC00000D6L) -#endif - -#ifndef STATUS_NO_SECURITY_ON_OBJECT -# define STATUS_NO_SECURITY_ON_OBJECT ((NTSTATUS) 0xC00000D7L) -#endif - -#ifndef STATUS_CANT_WAIT -# define STATUS_CANT_WAIT ((NTSTATUS) 0xC00000D8L) -#endif - -#ifndef STATUS_PIPE_EMPTY -# define STATUS_PIPE_EMPTY ((NTSTATUS) 0xC00000D9L) -#endif - -#ifndef STATUS_CANT_ACCESS_DOMAIN_INFO -# define STATUS_CANT_ACCESS_DOMAIN_INFO ((NTSTATUS) 0xC00000DAL) -#endif - -#ifndef STATUS_CANT_TERMINATE_SELF -# define STATUS_CANT_TERMINATE_SELF ((NTSTATUS) 0xC00000DBL) -#endif - -#ifndef STATUS_INVALID_SERVER_STATE -# define STATUS_INVALID_SERVER_STATE ((NTSTATUS) 0xC00000DCL) -#endif - -#ifndef STATUS_INVALID_DOMAIN_STATE -# define STATUS_INVALID_DOMAIN_STATE ((NTSTATUS) 0xC00000DDL) -#endif - -#ifndef STATUS_INVALID_DOMAIN_ROLE -# define STATUS_INVALID_DOMAIN_ROLE ((NTSTATUS) 0xC00000DEL) -#endif - -#ifndef STATUS_NO_SUCH_DOMAIN -# define STATUS_NO_SUCH_DOMAIN ((NTSTATUS) 0xC00000DFL) -#endif - -#ifndef STATUS_DOMAIN_EXISTS -# define STATUS_DOMAIN_EXISTS ((NTSTATUS) 0xC00000E0L) -#endif - -#ifndef STATUS_DOMAIN_LIMIT_EXCEEDED -# define STATUS_DOMAIN_LIMIT_EXCEEDED ((NTSTATUS) 0xC00000E1L) -#endif - -#ifndef STATUS_OPLOCK_NOT_GRANTED -# define STATUS_OPLOCK_NOT_GRANTED ((NTSTATUS) 0xC00000E2L) -#endif - -#ifndef STATUS_INVALID_OPLOCK_PROTOCOL -# define STATUS_INVALID_OPLOCK_PROTOCOL ((NTSTATUS) 0xC00000E3L) -#endif - -#ifndef STATUS_INTERNAL_DB_CORRUPTION -# define STATUS_INTERNAL_DB_CORRUPTION ((NTSTATUS) 0xC00000E4L) -#endif - -#ifndef STATUS_INTERNAL_ERROR -# define STATUS_INTERNAL_ERROR ((NTSTATUS) 0xC00000E5L) -#endif - -#ifndef STATUS_GENERIC_NOT_MAPPED -# define STATUS_GENERIC_NOT_MAPPED ((NTSTATUS) 0xC00000E6L) -#endif - -#ifndef STATUS_BAD_DESCRIPTOR_FORMAT -# define STATUS_BAD_DESCRIPTOR_FORMAT ((NTSTATUS) 0xC00000E7L) -#endif - -#ifndef STATUS_INVALID_USER_BUFFER -# define STATUS_INVALID_USER_BUFFER ((NTSTATUS) 0xC00000E8L) -#endif - -#ifndef STATUS_UNEXPECTED_IO_ERROR -# define STATUS_UNEXPECTED_IO_ERROR ((NTSTATUS) 0xC00000E9L) -#endif - -#ifndef STATUS_UNEXPECTED_MM_CREATE_ERR -# define STATUS_UNEXPECTED_MM_CREATE_ERR ((NTSTATUS) 0xC00000EAL) -#endif - -#ifndef STATUS_UNEXPECTED_MM_MAP_ERROR -# define STATUS_UNEXPECTED_MM_MAP_ERROR ((NTSTATUS) 0xC00000EBL) -#endif - -#ifndef STATUS_UNEXPECTED_MM_EXTEND_ERR -# define STATUS_UNEXPECTED_MM_EXTEND_ERR ((NTSTATUS) 0xC00000ECL) -#endif - -#ifndef STATUS_NOT_LOGON_PROCESS -# define STATUS_NOT_LOGON_PROCESS ((NTSTATUS) 0xC00000EDL) -#endif - -#ifndef STATUS_LOGON_SESSION_EXISTS -# define STATUS_LOGON_SESSION_EXISTS ((NTSTATUS) 0xC00000EEL) -#endif - -#ifndef STATUS_INVALID_PARAMETER_1 -# define STATUS_INVALID_PARAMETER_1 ((NTSTATUS) 0xC00000EFL) -#endif - -#ifndef STATUS_INVALID_PARAMETER_2 -# define STATUS_INVALID_PARAMETER_2 ((NTSTATUS) 0xC00000F0L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_3 -# define STATUS_INVALID_PARAMETER_3 ((NTSTATUS) 0xC00000F1L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_4 -# define STATUS_INVALID_PARAMETER_4 ((NTSTATUS) 0xC00000F2L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_5 -# define STATUS_INVALID_PARAMETER_5 ((NTSTATUS) 0xC00000F3L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_6 -# define STATUS_INVALID_PARAMETER_6 ((NTSTATUS) 0xC00000F4L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_7 -# define STATUS_INVALID_PARAMETER_7 ((NTSTATUS) 0xC00000F5L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_8 -# define STATUS_INVALID_PARAMETER_8 ((NTSTATUS) 0xC00000F6L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_9 -# define STATUS_INVALID_PARAMETER_9 ((NTSTATUS) 0xC00000F7L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_10 -# define STATUS_INVALID_PARAMETER_10 ((NTSTATUS) 0xC00000F8L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_11 -# define STATUS_INVALID_PARAMETER_11 ((NTSTATUS) 0xC00000F9L) -#endif - -#ifndef STATUS_INVALID_PARAMETER_12 -# define STATUS_INVALID_PARAMETER_12 ((NTSTATUS) 0xC00000FAL) -#endif - -#ifndef STATUS_REDIRECTOR_NOT_STARTED -# define STATUS_REDIRECTOR_NOT_STARTED ((NTSTATUS) 0xC00000FBL) -#endif - -#ifndef STATUS_REDIRECTOR_STARTED -# define STATUS_REDIRECTOR_STARTED ((NTSTATUS) 0xC00000FCL) -#endif - -#ifndef STATUS_STACK_OVERFLOW -# define STATUS_STACK_OVERFLOW ((NTSTATUS) 0xC00000FDL) -#endif - -#ifndef STATUS_NO_SUCH_PACKAGE -# define STATUS_NO_SUCH_PACKAGE ((NTSTATUS) 0xC00000FEL) -#endif - -#ifndef STATUS_BAD_FUNCTION_TABLE -# define STATUS_BAD_FUNCTION_TABLE ((NTSTATUS) 0xC00000FFL) -#endif - -#ifndef STATUS_VARIABLE_NOT_FOUND -# define STATUS_VARIABLE_NOT_FOUND ((NTSTATUS) 0xC0000100L) -#endif - -#ifndef STATUS_DIRECTORY_NOT_EMPTY -# define STATUS_DIRECTORY_NOT_EMPTY ((NTSTATUS) 0xC0000101L) -#endif - -#ifndef STATUS_FILE_CORRUPT_ERROR -# define STATUS_FILE_CORRUPT_ERROR ((NTSTATUS) 0xC0000102L) -#endif - -#ifndef STATUS_NOT_A_DIRECTORY -# define STATUS_NOT_A_DIRECTORY ((NTSTATUS) 0xC0000103L) -#endif - -#ifndef STATUS_BAD_LOGON_SESSION_STATE -# define STATUS_BAD_LOGON_SESSION_STATE ((NTSTATUS) 0xC0000104L) -#endif - -#ifndef STATUS_LOGON_SESSION_COLLISION -# define STATUS_LOGON_SESSION_COLLISION ((NTSTATUS) 0xC0000105L) -#endif - -#ifndef STATUS_NAME_TOO_LONG -# define STATUS_NAME_TOO_LONG ((NTSTATUS) 0xC0000106L) -#endif - -#ifndef STATUS_FILES_OPEN -# define STATUS_FILES_OPEN ((NTSTATUS) 0xC0000107L) -#endif - -#ifndef STATUS_CONNECTION_IN_USE -# define STATUS_CONNECTION_IN_USE ((NTSTATUS) 0xC0000108L) -#endif - -#ifndef STATUS_MESSAGE_NOT_FOUND -# define STATUS_MESSAGE_NOT_FOUND ((NTSTATUS) 0xC0000109L) -#endif - -#ifndef STATUS_PROCESS_IS_TERMINATING -# define STATUS_PROCESS_IS_TERMINATING ((NTSTATUS) 0xC000010AL) -#endif - -#ifndef STATUS_INVALID_LOGON_TYPE -# define STATUS_INVALID_LOGON_TYPE ((NTSTATUS) 0xC000010BL) -#endif - -#ifndef STATUS_NO_GUID_TRANSLATION -# define STATUS_NO_GUID_TRANSLATION ((NTSTATUS) 0xC000010CL) -#endif - -#ifndef STATUS_CANNOT_IMPERSONATE -# define STATUS_CANNOT_IMPERSONATE ((NTSTATUS) 0xC000010DL) -#endif - -#ifndef STATUS_IMAGE_ALREADY_LOADED -# define STATUS_IMAGE_ALREADY_LOADED ((NTSTATUS) 0xC000010EL) -#endif - -#ifndef STATUS_ABIOS_NOT_PRESENT -# define STATUS_ABIOS_NOT_PRESENT ((NTSTATUS) 0xC000010FL) -#endif - -#ifndef STATUS_ABIOS_LID_NOT_EXIST -# define STATUS_ABIOS_LID_NOT_EXIST ((NTSTATUS) 0xC0000110L) -#endif - -#ifndef STATUS_ABIOS_LID_ALREADY_OWNED -# define STATUS_ABIOS_LID_ALREADY_OWNED ((NTSTATUS) 0xC0000111L) -#endif - -#ifndef STATUS_ABIOS_NOT_LID_OWNER -# define STATUS_ABIOS_NOT_LID_OWNER ((NTSTATUS) 0xC0000112L) -#endif - -#ifndef STATUS_ABIOS_INVALID_COMMAND -# define STATUS_ABIOS_INVALID_COMMAND ((NTSTATUS) 0xC0000113L) -#endif - -#ifndef STATUS_ABIOS_INVALID_LID -# define STATUS_ABIOS_INVALID_LID ((NTSTATUS) 0xC0000114L) -#endif - -#ifndef STATUS_ABIOS_SELECTOR_NOT_AVAILABLE -# define STATUS_ABIOS_SELECTOR_NOT_AVAILABLE ((NTSTATUS) 0xC0000115L) -#endif - -#ifndef STATUS_ABIOS_INVALID_SELECTOR -# define STATUS_ABIOS_INVALID_SELECTOR ((NTSTATUS) 0xC0000116L) -#endif - -#ifndef STATUS_NO_LDT -# define STATUS_NO_LDT ((NTSTATUS) 0xC0000117L) -#endif - -#ifndef STATUS_INVALID_LDT_SIZE -# define STATUS_INVALID_LDT_SIZE ((NTSTATUS) 0xC0000118L) -#endif - -#ifndef STATUS_INVALID_LDT_OFFSET -# define STATUS_INVALID_LDT_OFFSET ((NTSTATUS) 0xC0000119L) -#endif - -#ifndef STATUS_INVALID_LDT_DESCRIPTOR -# define STATUS_INVALID_LDT_DESCRIPTOR ((NTSTATUS) 0xC000011AL) -#endif - -#ifndef STATUS_INVALID_IMAGE_NE_FORMAT -# define STATUS_INVALID_IMAGE_NE_FORMAT ((NTSTATUS) 0xC000011BL) -#endif - -#ifndef STATUS_RXACT_INVALID_STATE -# define STATUS_RXACT_INVALID_STATE ((NTSTATUS) 0xC000011CL) -#endif - -#ifndef STATUS_RXACT_COMMIT_FAILURE -# define STATUS_RXACT_COMMIT_FAILURE ((NTSTATUS) 0xC000011DL) -#endif - -#ifndef STATUS_MAPPED_FILE_SIZE_ZERO -# define STATUS_MAPPED_FILE_SIZE_ZERO ((NTSTATUS) 0xC000011EL) -#endif - -#ifndef STATUS_TOO_MANY_OPENED_FILES -# define STATUS_TOO_MANY_OPENED_FILES ((NTSTATUS) 0xC000011FL) -#endif - -#ifndef STATUS_CANCELLED -# define STATUS_CANCELLED ((NTSTATUS) 0xC0000120L) -#endif - -#ifndef STATUS_CANNOT_DELETE -# define STATUS_CANNOT_DELETE ((NTSTATUS) 0xC0000121L) -#endif - -#ifndef STATUS_INVALID_COMPUTER_NAME -# define STATUS_INVALID_COMPUTER_NAME ((NTSTATUS) 0xC0000122L) -#endif - -#ifndef STATUS_FILE_DELETED -# define STATUS_FILE_DELETED ((NTSTATUS) 0xC0000123L) -#endif - -#ifndef STATUS_SPECIAL_ACCOUNT -# define STATUS_SPECIAL_ACCOUNT ((NTSTATUS) 0xC0000124L) -#endif - -#ifndef STATUS_SPECIAL_GROUP -# define STATUS_SPECIAL_GROUP ((NTSTATUS) 0xC0000125L) -#endif - -#ifndef STATUS_SPECIAL_USER -# define STATUS_SPECIAL_USER ((NTSTATUS) 0xC0000126L) -#endif - -#ifndef STATUS_MEMBERS_PRIMARY_GROUP -# define STATUS_MEMBERS_PRIMARY_GROUP ((NTSTATUS) 0xC0000127L) -#endif - -#ifndef STATUS_FILE_CLOSED -# define STATUS_FILE_CLOSED ((NTSTATUS) 0xC0000128L) -#endif - -#ifndef STATUS_TOO_MANY_THREADS -# define STATUS_TOO_MANY_THREADS ((NTSTATUS) 0xC0000129L) -#endif - -#ifndef STATUS_THREAD_NOT_IN_PROCESS -# define STATUS_THREAD_NOT_IN_PROCESS ((NTSTATUS) 0xC000012AL) -#endif - -#ifndef STATUS_TOKEN_ALREADY_IN_USE -# define STATUS_TOKEN_ALREADY_IN_USE ((NTSTATUS) 0xC000012BL) -#endif - -#ifndef STATUS_PAGEFILE_QUOTA_EXCEEDED -# define STATUS_PAGEFILE_QUOTA_EXCEEDED ((NTSTATUS) 0xC000012CL) -#endif - -#ifndef STATUS_COMMITMENT_LIMIT -# define STATUS_COMMITMENT_LIMIT ((NTSTATUS) 0xC000012DL) -#endif - -#ifndef STATUS_INVALID_IMAGE_LE_FORMAT -# define STATUS_INVALID_IMAGE_LE_FORMAT ((NTSTATUS) 0xC000012EL) -#endif - -#ifndef STATUS_INVALID_IMAGE_NOT_MZ -# define STATUS_INVALID_IMAGE_NOT_MZ ((NTSTATUS) 0xC000012FL) -#endif - -#ifndef STATUS_INVALID_IMAGE_PROTECT -# define STATUS_INVALID_IMAGE_PROTECT ((NTSTATUS) 0xC0000130L) -#endif - -#ifndef STATUS_INVALID_IMAGE_WIN_16 -# define STATUS_INVALID_IMAGE_WIN_16 ((NTSTATUS) 0xC0000131L) -#endif - -#ifndef STATUS_LOGON_SERVER_CONFLICT -# define STATUS_LOGON_SERVER_CONFLICT ((NTSTATUS) 0xC0000132L) -#endif - -#ifndef STATUS_TIME_DIFFERENCE_AT_DC -# define STATUS_TIME_DIFFERENCE_AT_DC ((NTSTATUS) 0xC0000133L) -#endif - -#ifndef STATUS_SYNCHRONIZATION_REQUIRED -# define STATUS_SYNCHRONIZATION_REQUIRED ((NTSTATUS) 0xC0000134L) -#endif - -#ifndef STATUS_DLL_NOT_FOUND -# define STATUS_DLL_NOT_FOUND ((NTSTATUS) 0xC0000135L) -#endif - -#ifndef STATUS_OPEN_FAILED -# define STATUS_OPEN_FAILED ((NTSTATUS) 0xC0000136L) -#endif - -#ifndef STATUS_IO_PRIVILEGE_FAILED -# define STATUS_IO_PRIVILEGE_FAILED ((NTSTATUS) 0xC0000137L) -#endif - -#ifndef STATUS_ORDINAL_NOT_FOUND -# define STATUS_ORDINAL_NOT_FOUND ((NTSTATUS) 0xC0000138L) -#endif - -#ifndef STATUS_ENTRYPOINT_NOT_FOUND -# define STATUS_ENTRYPOINT_NOT_FOUND ((NTSTATUS) 0xC0000139L) -#endif - -#ifndef STATUS_CONTROL_C_EXIT -# define STATUS_CONTROL_C_EXIT ((NTSTATUS) 0xC000013AL) -#endif - -#ifndef STATUS_LOCAL_DISCONNECT -# define STATUS_LOCAL_DISCONNECT ((NTSTATUS) 0xC000013BL) -#endif - -#ifndef STATUS_REMOTE_DISCONNECT -# define STATUS_REMOTE_DISCONNECT ((NTSTATUS) 0xC000013CL) -#endif - -#ifndef STATUS_REMOTE_RESOURCES -# define STATUS_REMOTE_RESOURCES ((NTSTATUS) 0xC000013DL) -#endif - -#ifndef STATUS_LINK_FAILED -# define STATUS_LINK_FAILED ((NTSTATUS) 0xC000013EL) -#endif - -#ifndef STATUS_LINK_TIMEOUT -# define STATUS_LINK_TIMEOUT ((NTSTATUS) 0xC000013FL) -#endif - -#ifndef STATUS_INVALID_CONNECTION -# define STATUS_INVALID_CONNECTION ((NTSTATUS) 0xC0000140L) -#endif - -#ifndef STATUS_INVALID_ADDRESS -# define STATUS_INVALID_ADDRESS ((NTSTATUS) 0xC0000141L) -#endif - -#ifndef STATUS_DLL_INIT_FAILED -# define STATUS_DLL_INIT_FAILED ((NTSTATUS) 0xC0000142L) -#endif - -#ifndef STATUS_MISSING_SYSTEMFILE -# define STATUS_MISSING_SYSTEMFILE ((NTSTATUS) 0xC0000143L) -#endif - -#ifndef STATUS_UNHANDLED_EXCEPTION -# define STATUS_UNHANDLED_EXCEPTION ((NTSTATUS) 0xC0000144L) -#endif - -#ifndef STATUS_APP_INIT_FAILURE -# define STATUS_APP_INIT_FAILURE ((NTSTATUS) 0xC0000145L) -#endif - -#ifndef STATUS_PAGEFILE_CREATE_FAILED -# define STATUS_PAGEFILE_CREATE_FAILED ((NTSTATUS) 0xC0000146L) -#endif - -#ifndef STATUS_NO_PAGEFILE -# define STATUS_NO_PAGEFILE ((NTSTATUS) 0xC0000147L) -#endif - -#ifndef STATUS_INVALID_LEVEL -# define STATUS_INVALID_LEVEL ((NTSTATUS) 0xC0000148L) -#endif - -#ifndef STATUS_WRONG_PASSWORD_CORE -# define STATUS_WRONG_PASSWORD_CORE ((NTSTATUS) 0xC0000149L) -#endif - -#ifndef STATUS_ILLEGAL_FLOAT_CONTEXT -# define STATUS_ILLEGAL_FLOAT_CONTEXT ((NTSTATUS) 0xC000014AL) -#endif - -#ifndef STATUS_PIPE_BROKEN -# define STATUS_PIPE_BROKEN ((NTSTATUS) 0xC000014BL) -#endif - -#ifndef STATUS_REGISTRY_CORRUPT -# define STATUS_REGISTRY_CORRUPT ((NTSTATUS) 0xC000014CL) -#endif - -#ifndef STATUS_REGISTRY_IO_FAILED -# define STATUS_REGISTRY_IO_FAILED ((NTSTATUS) 0xC000014DL) -#endif - -#ifndef STATUS_NO_EVENT_PAIR -# define STATUS_NO_EVENT_PAIR ((NTSTATUS) 0xC000014EL) -#endif - -#ifndef STATUS_UNRECOGNIZED_VOLUME -# define STATUS_UNRECOGNIZED_VOLUME ((NTSTATUS) 0xC000014FL) -#endif - -#ifndef STATUS_SERIAL_NO_DEVICE_INITED -# define STATUS_SERIAL_NO_DEVICE_INITED ((NTSTATUS) 0xC0000150L) -#endif - -#ifndef STATUS_NO_SUCH_ALIAS -# define STATUS_NO_SUCH_ALIAS ((NTSTATUS) 0xC0000151L) -#endif - -#ifndef STATUS_MEMBER_NOT_IN_ALIAS -# define STATUS_MEMBER_NOT_IN_ALIAS ((NTSTATUS) 0xC0000152L) -#endif - -#ifndef STATUS_MEMBER_IN_ALIAS -# define STATUS_MEMBER_IN_ALIAS ((NTSTATUS) 0xC0000153L) -#endif - -#ifndef STATUS_ALIAS_EXISTS -# define STATUS_ALIAS_EXISTS ((NTSTATUS) 0xC0000154L) -#endif - -#ifndef STATUS_LOGON_NOT_GRANTED -# define STATUS_LOGON_NOT_GRANTED ((NTSTATUS) 0xC0000155L) -#endif - -#ifndef STATUS_TOO_MANY_SECRETS -# define STATUS_TOO_MANY_SECRETS ((NTSTATUS) 0xC0000156L) -#endif - -#ifndef STATUS_SECRET_TOO_LONG -# define STATUS_SECRET_TOO_LONG ((NTSTATUS) 0xC0000157L) -#endif - -#ifndef STATUS_INTERNAL_DB_ERROR -# define STATUS_INTERNAL_DB_ERROR ((NTSTATUS) 0xC0000158L) -#endif - -#ifndef STATUS_FULLSCREEN_MODE -# define STATUS_FULLSCREEN_MODE ((NTSTATUS) 0xC0000159L) -#endif - -#ifndef STATUS_TOO_MANY_CONTEXT_IDS -# define STATUS_TOO_MANY_CONTEXT_IDS ((NTSTATUS) 0xC000015AL) -#endif - -#ifndef STATUS_LOGON_TYPE_NOT_GRANTED -# define STATUS_LOGON_TYPE_NOT_GRANTED ((NTSTATUS) 0xC000015BL) -#endif - -#ifndef STATUS_NOT_REGISTRY_FILE -# define STATUS_NOT_REGISTRY_FILE ((NTSTATUS) 0xC000015CL) -#endif - -#ifndef STATUS_NT_CROSS_ENCRYPTION_REQUIRED -# define STATUS_NT_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS) 0xC000015DL) -#endif - -#ifndef STATUS_DOMAIN_CTRLR_CONFIG_ERROR -# define STATUS_DOMAIN_CTRLR_CONFIG_ERROR ((NTSTATUS) 0xC000015EL) -#endif - -#ifndef STATUS_FT_MISSING_MEMBER -# define STATUS_FT_MISSING_MEMBER ((NTSTATUS) 0xC000015FL) -#endif - -#ifndef STATUS_ILL_FORMED_SERVICE_ENTRY -# define STATUS_ILL_FORMED_SERVICE_ENTRY ((NTSTATUS) 0xC0000160L) -#endif - -#ifndef STATUS_ILLEGAL_CHARACTER -# define STATUS_ILLEGAL_CHARACTER ((NTSTATUS) 0xC0000161L) -#endif - -#ifndef STATUS_UNMAPPABLE_CHARACTER -# define STATUS_UNMAPPABLE_CHARACTER ((NTSTATUS) 0xC0000162L) -#endif - -#ifndef STATUS_UNDEFINED_CHARACTER -# define STATUS_UNDEFINED_CHARACTER ((NTSTATUS) 0xC0000163L) -#endif - -#ifndef STATUS_FLOPPY_VOLUME -# define STATUS_FLOPPY_VOLUME ((NTSTATUS) 0xC0000164L) -#endif - -#ifndef STATUS_FLOPPY_ID_MARK_NOT_FOUND -# define STATUS_FLOPPY_ID_MARK_NOT_FOUND ((NTSTATUS) 0xC0000165L) -#endif - -#ifndef STATUS_FLOPPY_WRONG_CYLINDER -# define STATUS_FLOPPY_WRONG_CYLINDER ((NTSTATUS) 0xC0000166L) -#endif - -#ifndef STATUS_FLOPPY_UNKNOWN_ERROR -# define STATUS_FLOPPY_UNKNOWN_ERROR ((NTSTATUS) 0xC0000167L) -#endif - -#ifndef STATUS_FLOPPY_BAD_REGISTERS -# define STATUS_FLOPPY_BAD_REGISTERS ((NTSTATUS) 0xC0000168L) -#endif - -#ifndef STATUS_DISK_RECALIBRATE_FAILED -# define STATUS_DISK_RECALIBRATE_FAILED ((NTSTATUS) 0xC0000169L) -#endif - -#ifndef STATUS_DISK_OPERATION_FAILED -# define STATUS_DISK_OPERATION_FAILED ((NTSTATUS) 0xC000016AL) -#endif - -#ifndef STATUS_DISK_RESET_FAILED -# define STATUS_DISK_RESET_FAILED ((NTSTATUS) 0xC000016BL) -#endif - -#ifndef STATUS_SHARED_IRQ_BUSY -# define STATUS_SHARED_IRQ_BUSY ((NTSTATUS) 0xC000016CL) -#endif - -#ifndef STATUS_FT_ORPHANING -# define STATUS_FT_ORPHANING ((NTSTATUS) 0xC000016DL) -#endif - -#ifndef STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT -# define STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT ((NTSTATUS) 0xC000016EL) -#endif - -#ifndef STATUS_PARTITION_FAILURE -# define STATUS_PARTITION_FAILURE ((NTSTATUS) 0xC0000172L) -#endif - -#ifndef STATUS_INVALID_BLOCK_LENGTH -# define STATUS_INVALID_BLOCK_LENGTH ((NTSTATUS) 0xC0000173L) -#endif - -#ifndef STATUS_DEVICE_NOT_PARTITIONED -# define STATUS_DEVICE_NOT_PARTITIONED ((NTSTATUS) 0xC0000174L) -#endif - -#ifndef STATUS_UNABLE_TO_LOCK_MEDIA -# define STATUS_UNABLE_TO_LOCK_MEDIA ((NTSTATUS) 0xC0000175L) -#endif - -#ifndef STATUS_UNABLE_TO_UNLOAD_MEDIA -# define STATUS_UNABLE_TO_UNLOAD_MEDIA ((NTSTATUS) 0xC0000176L) -#endif - -#ifndef STATUS_EOM_OVERFLOW -# define STATUS_EOM_OVERFLOW ((NTSTATUS) 0xC0000177L) -#endif - -#ifndef STATUS_NO_MEDIA -# define STATUS_NO_MEDIA ((NTSTATUS) 0xC0000178L) -#endif - -#ifndef STATUS_NO_SUCH_MEMBER -# define STATUS_NO_SUCH_MEMBER ((NTSTATUS) 0xC000017AL) -#endif - -#ifndef STATUS_INVALID_MEMBER -# define STATUS_INVALID_MEMBER ((NTSTATUS) 0xC000017BL) -#endif - -#ifndef STATUS_KEY_DELETED -# define STATUS_KEY_DELETED ((NTSTATUS) 0xC000017CL) -#endif - -#ifndef STATUS_NO_LOG_SPACE -# define STATUS_NO_LOG_SPACE ((NTSTATUS) 0xC000017DL) -#endif - -#ifndef STATUS_TOO_MANY_SIDS -# define STATUS_TOO_MANY_SIDS ((NTSTATUS) 0xC000017EL) -#endif - -#ifndef STATUS_LM_CROSS_ENCRYPTION_REQUIRED -# define STATUS_LM_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS) 0xC000017FL) -#endif - -#ifndef STATUS_KEY_HAS_CHILDREN -# define STATUS_KEY_HAS_CHILDREN ((NTSTATUS) 0xC0000180L) -#endif - -#ifndef STATUS_CHILD_MUST_BE_VOLATILE -# define STATUS_CHILD_MUST_BE_VOLATILE ((NTSTATUS) 0xC0000181L) -#endif - -#ifndef STATUS_DEVICE_CONFIGURATION_ERROR -# define STATUS_DEVICE_CONFIGURATION_ERROR ((NTSTATUS) 0xC0000182L) -#endif - -#ifndef STATUS_DRIVER_INTERNAL_ERROR -# define STATUS_DRIVER_INTERNAL_ERROR ((NTSTATUS) 0xC0000183L) -#endif - -#ifndef STATUS_INVALID_DEVICE_STATE -# define STATUS_INVALID_DEVICE_STATE ((NTSTATUS) 0xC0000184L) -#endif - -#ifndef STATUS_IO_DEVICE_ERROR -# define STATUS_IO_DEVICE_ERROR ((NTSTATUS) 0xC0000185L) -#endif - -#ifndef STATUS_DEVICE_PROTOCOL_ERROR -# define STATUS_DEVICE_PROTOCOL_ERROR ((NTSTATUS) 0xC0000186L) -#endif - -#ifndef STATUS_BACKUP_CONTROLLER -# define STATUS_BACKUP_CONTROLLER ((NTSTATUS) 0xC0000187L) -#endif - -#ifndef STATUS_LOG_FILE_FULL -# define STATUS_LOG_FILE_FULL ((NTSTATUS) 0xC0000188L) -#endif - -#ifndef STATUS_TOO_LATE -# define STATUS_TOO_LATE ((NTSTATUS) 0xC0000189L) -#endif - -#ifndef STATUS_NO_TRUST_LSA_SECRET -# define STATUS_NO_TRUST_LSA_SECRET ((NTSTATUS) 0xC000018AL) -#endif - -#ifndef STATUS_NO_TRUST_SAM_ACCOUNT -# define STATUS_NO_TRUST_SAM_ACCOUNT ((NTSTATUS) 0xC000018BL) -#endif - -#ifndef STATUS_TRUSTED_DOMAIN_FAILURE -# define STATUS_TRUSTED_DOMAIN_FAILURE ((NTSTATUS) 0xC000018CL) -#endif - -#ifndef STATUS_TRUSTED_RELATIONSHIP_FAILURE -# define STATUS_TRUSTED_RELATIONSHIP_FAILURE ((NTSTATUS) 0xC000018DL) -#endif - -#ifndef STATUS_EVENTLOG_FILE_CORRUPT -# define STATUS_EVENTLOG_FILE_CORRUPT ((NTSTATUS) 0xC000018EL) -#endif - -#ifndef STATUS_EVENTLOG_CANT_START -# define STATUS_EVENTLOG_CANT_START ((NTSTATUS) 0xC000018FL) -#endif - -#ifndef STATUS_TRUST_FAILURE -# define STATUS_TRUST_FAILURE ((NTSTATUS) 0xC0000190L) -#endif - -#ifndef STATUS_MUTANT_LIMIT_EXCEEDED -# define STATUS_MUTANT_LIMIT_EXCEEDED ((NTSTATUS) 0xC0000191L) -#endif - -#ifndef STATUS_NETLOGON_NOT_STARTED -# define STATUS_NETLOGON_NOT_STARTED ((NTSTATUS) 0xC0000192L) -#endif - -#ifndef STATUS_ACCOUNT_EXPIRED -# define STATUS_ACCOUNT_EXPIRED ((NTSTATUS) 0xC0000193L) -#endif - -#ifndef STATUS_POSSIBLE_DEADLOCK -# define STATUS_POSSIBLE_DEADLOCK ((NTSTATUS) 0xC0000194L) -#endif - -#ifndef STATUS_NETWORK_CREDENTIAL_CONFLICT -# define STATUS_NETWORK_CREDENTIAL_CONFLICT ((NTSTATUS) 0xC0000195L) -#endif - -#ifndef STATUS_REMOTE_SESSION_LIMIT -# define STATUS_REMOTE_SESSION_LIMIT ((NTSTATUS) 0xC0000196L) -#endif - -#ifndef STATUS_EVENTLOG_FILE_CHANGED -# define STATUS_EVENTLOG_FILE_CHANGED ((NTSTATUS) 0xC0000197L) -#endif - -#ifndef STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT -# define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT ((NTSTATUS) 0xC0000198L) -#endif - -#ifndef STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT -# define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT ((NTSTATUS) 0xC0000199L) -#endif - -#ifndef STATUS_NOLOGON_SERVER_TRUST_ACCOUNT -# define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT ((NTSTATUS) 0xC000019AL) -#endif - -#ifndef STATUS_DOMAIN_TRUST_INCONSISTENT -# define STATUS_DOMAIN_TRUST_INCONSISTENT ((NTSTATUS) 0xC000019BL) -#endif - -#ifndef STATUS_FS_DRIVER_REQUIRED -# define STATUS_FS_DRIVER_REQUIRED ((NTSTATUS) 0xC000019CL) -#endif - -#ifndef STATUS_IMAGE_ALREADY_LOADED_AS_DLL -# define STATUS_IMAGE_ALREADY_LOADED_AS_DLL ((NTSTATUS) 0xC000019DL) -#endif - -#ifndef STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING -# define STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING ((NTSTATUS) 0xC000019EL) -#endif - -#ifndef STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME -# define STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME ((NTSTATUS) 0xC000019FL) -#endif - -#ifndef STATUS_SECURITY_STREAM_IS_INCONSISTENT -# define STATUS_SECURITY_STREAM_IS_INCONSISTENT ((NTSTATUS) 0xC00001A0L) -#endif - -#ifndef STATUS_INVALID_LOCK_RANGE -# define STATUS_INVALID_LOCK_RANGE ((NTSTATUS) 0xC00001A1L) -#endif - -#ifndef STATUS_INVALID_ACE_CONDITION -# define STATUS_INVALID_ACE_CONDITION ((NTSTATUS) 0xC00001A2L) -#endif - -#ifndef STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT -# define STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT ((NTSTATUS) 0xC00001A3L) -#endif - -#ifndef STATUS_NOTIFICATION_GUID_ALREADY_DEFINED -# define STATUS_NOTIFICATION_GUID_ALREADY_DEFINED ((NTSTATUS) 0xC00001A4L) -#endif - -#ifndef STATUS_NETWORK_OPEN_RESTRICTION -# define STATUS_NETWORK_OPEN_RESTRICTION ((NTSTATUS) 0xC0000201L) -#endif - -#ifndef STATUS_NO_USER_SESSION_KEY -# define STATUS_NO_USER_SESSION_KEY ((NTSTATUS) 0xC0000202L) -#endif - -#ifndef STATUS_USER_SESSION_DELETED -# define STATUS_USER_SESSION_DELETED ((NTSTATUS) 0xC0000203L) -#endif - -#ifndef STATUS_RESOURCE_LANG_NOT_FOUND -# define STATUS_RESOURCE_LANG_NOT_FOUND ((NTSTATUS) 0xC0000204L) -#endif - -#ifndef STATUS_INSUFF_SERVER_RESOURCES -# define STATUS_INSUFF_SERVER_RESOURCES ((NTSTATUS) 0xC0000205L) -#endif - -#ifndef STATUS_INVALID_BUFFER_SIZE -# define STATUS_INVALID_BUFFER_SIZE ((NTSTATUS) 0xC0000206L) -#endif - -#ifndef STATUS_INVALID_ADDRESS_COMPONENT -# define STATUS_INVALID_ADDRESS_COMPONENT ((NTSTATUS) 0xC0000207L) -#endif - -#ifndef STATUS_INVALID_ADDRESS_WILDCARD -# define STATUS_INVALID_ADDRESS_WILDCARD ((NTSTATUS) 0xC0000208L) -#endif - -#ifndef STATUS_TOO_MANY_ADDRESSES -# define STATUS_TOO_MANY_ADDRESSES ((NTSTATUS) 0xC0000209L) -#endif - -#ifndef STATUS_ADDRESS_ALREADY_EXISTS -# define STATUS_ADDRESS_ALREADY_EXISTS ((NTSTATUS) 0xC000020AL) -#endif - -#ifndef STATUS_ADDRESS_CLOSED -# define STATUS_ADDRESS_CLOSED ((NTSTATUS) 0xC000020BL) -#endif - -#ifndef STATUS_CONNECTION_DISCONNECTED -# define STATUS_CONNECTION_DISCONNECTED ((NTSTATUS) 0xC000020CL) -#endif - -#ifndef STATUS_CONNECTION_RESET -# define STATUS_CONNECTION_RESET ((NTSTATUS) 0xC000020DL) -#endif - -#ifndef STATUS_TOO_MANY_NODES -# define STATUS_TOO_MANY_NODES ((NTSTATUS) 0xC000020EL) -#endif - -#ifndef STATUS_TRANSACTION_ABORTED -# define STATUS_TRANSACTION_ABORTED ((NTSTATUS) 0xC000020FL) -#endif - -#ifndef STATUS_TRANSACTION_TIMED_OUT -# define STATUS_TRANSACTION_TIMED_OUT ((NTSTATUS) 0xC0000210L) -#endif - -#ifndef STATUS_TRANSACTION_NO_RELEASE -# define STATUS_TRANSACTION_NO_RELEASE ((NTSTATUS) 0xC0000211L) -#endif - -#ifndef STATUS_TRANSACTION_NO_MATCH -# define STATUS_TRANSACTION_NO_MATCH ((NTSTATUS) 0xC0000212L) -#endif - -#ifndef STATUS_TRANSACTION_RESPONDED -# define STATUS_TRANSACTION_RESPONDED ((NTSTATUS) 0xC0000213L) -#endif - -#ifndef STATUS_TRANSACTION_INVALID_ID -# define STATUS_TRANSACTION_INVALID_ID ((NTSTATUS) 0xC0000214L) -#endif - -#ifndef STATUS_TRANSACTION_INVALID_TYPE -# define STATUS_TRANSACTION_INVALID_TYPE ((NTSTATUS) 0xC0000215L) -#endif - -#ifndef STATUS_NOT_SERVER_SESSION -# define STATUS_NOT_SERVER_SESSION ((NTSTATUS) 0xC0000216L) -#endif - -#ifndef STATUS_NOT_CLIENT_SESSION -# define STATUS_NOT_CLIENT_SESSION ((NTSTATUS) 0xC0000217L) -#endif - -#ifndef STATUS_CANNOT_LOAD_REGISTRY_FILE -# define STATUS_CANNOT_LOAD_REGISTRY_FILE ((NTSTATUS) 0xC0000218L) -#endif - -#ifndef STATUS_DEBUG_ATTACH_FAILED -# define STATUS_DEBUG_ATTACH_FAILED ((NTSTATUS) 0xC0000219L) -#endif - -#ifndef STATUS_SYSTEM_PROCESS_TERMINATED -# define STATUS_SYSTEM_PROCESS_TERMINATED ((NTSTATUS) 0xC000021AL) -#endif - -#ifndef STATUS_DATA_NOT_ACCEPTED -# define STATUS_DATA_NOT_ACCEPTED ((NTSTATUS) 0xC000021BL) -#endif - -#ifndef STATUS_NO_BROWSER_SERVERS_FOUND -# define STATUS_NO_BROWSER_SERVERS_FOUND ((NTSTATUS) 0xC000021CL) -#endif - -#ifndef STATUS_VDM_HARD_ERROR -# define STATUS_VDM_HARD_ERROR ((NTSTATUS) 0xC000021DL) -#endif - -#ifndef STATUS_DRIVER_CANCEL_TIMEOUT -# define STATUS_DRIVER_CANCEL_TIMEOUT ((NTSTATUS) 0xC000021EL) -#endif - -#ifndef STATUS_REPLY_MESSAGE_MISMATCH -# define STATUS_REPLY_MESSAGE_MISMATCH ((NTSTATUS) 0xC000021FL) -#endif - -#ifndef STATUS_MAPPED_ALIGNMENT -# define STATUS_MAPPED_ALIGNMENT ((NTSTATUS) 0xC0000220L) -#endif - -#ifndef STATUS_IMAGE_CHECKSUM_MISMATCH -# define STATUS_IMAGE_CHECKSUM_MISMATCH ((NTSTATUS) 0xC0000221L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA -# define STATUS_LOST_WRITEBEHIND_DATA ((NTSTATUS) 0xC0000222L) -#endif - -#ifndef STATUS_CLIENT_SERVER_PARAMETERS_INVALID -# define STATUS_CLIENT_SERVER_PARAMETERS_INVALID ((NTSTATUS) 0xC0000223L) -#endif - -#ifndef STATUS_PASSWORD_MUST_CHANGE -# define STATUS_PASSWORD_MUST_CHANGE ((NTSTATUS) 0xC0000224L) -#endif - -#ifndef STATUS_NOT_FOUND -# define STATUS_NOT_FOUND ((NTSTATUS) 0xC0000225L) -#endif - -#ifndef STATUS_NOT_TINY_STREAM -# define STATUS_NOT_TINY_STREAM ((NTSTATUS) 0xC0000226L) -#endif - -#ifndef STATUS_RECOVERY_FAILURE -# define STATUS_RECOVERY_FAILURE ((NTSTATUS) 0xC0000227L) -#endif - -#ifndef STATUS_STACK_OVERFLOW_READ -# define STATUS_STACK_OVERFLOW_READ ((NTSTATUS) 0xC0000228L) -#endif - -#ifndef STATUS_FAIL_CHECK -# define STATUS_FAIL_CHECK ((NTSTATUS) 0xC0000229L) -#endif - -#ifndef STATUS_DUPLICATE_OBJECTID -# define STATUS_DUPLICATE_OBJECTID ((NTSTATUS) 0xC000022AL) -#endif - -#ifndef STATUS_OBJECTID_EXISTS -# define STATUS_OBJECTID_EXISTS ((NTSTATUS) 0xC000022BL) -#endif - -#ifndef STATUS_CONVERT_TO_LARGE -# define STATUS_CONVERT_TO_LARGE ((NTSTATUS) 0xC000022CL) -#endif - -#ifndef STATUS_RETRY -# define STATUS_RETRY ((NTSTATUS) 0xC000022DL) -#endif - -#ifndef STATUS_FOUND_OUT_OF_SCOPE -# define STATUS_FOUND_OUT_OF_SCOPE ((NTSTATUS) 0xC000022EL) -#endif - -#ifndef STATUS_ALLOCATE_BUCKET -# define STATUS_ALLOCATE_BUCKET ((NTSTATUS) 0xC000022FL) -#endif - -#ifndef STATUS_PROPSET_NOT_FOUND -# define STATUS_PROPSET_NOT_FOUND ((NTSTATUS) 0xC0000230L) -#endif - -#ifndef STATUS_MARSHALL_OVERFLOW -# define STATUS_MARSHALL_OVERFLOW ((NTSTATUS) 0xC0000231L) -#endif - -#ifndef STATUS_INVALID_VARIANT -# define STATUS_INVALID_VARIANT ((NTSTATUS) 0xC0000232L) -#endif - -#ifndef STATUS_DOMAIN_CONTROLLER_NOT_FOUND -# define STATUS_DOMAIN_CONTROLLER_NOT_FOUND ((NTSTATUS) 0xC0000233L) -#endif - -#ifndef STATUS_ACCOUNT_LOCKED_OUT -# define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS) 0xC0000234L) -#endif - -#ifndef STATUS_HANDLE_NOT_CLOSABLE -# define STATUS_HANDLE_NOT_CLOSABLE ((NTSTATUS) 0xC0000235L) -#endif - -#ifndef STATUS_CONNECTION_REFUSED -# define STATUS_CONNECTION_REFUSED ((NTSTATUS) 0xC0000236L) -#endif - -#ifndef STATUS_GRACEFUL_DISCONNECT -# define STATUS_GRACEFUL_DISCONNECT ((NTSTATUS) 0xC0000237L) -#endif - -#ifndef STATUS_ADDRESS_ALREADY_ASSOCIATED -# define STATUS_ADDRESS_ALREADY_ASSOCIATED ((NTSTATUS) 0xC0000238L) -#endif - -#ifndef STATUS_ADDRESS_NOT_ASSOCIATED -# define STATUS_ADDRESS_NOT_ASSOCIATED ((NTSTATUS) 0xC0000239L) -#endif - -#ifndef STATUS_CONNECTION_INVALID -# define STATUS_CONNECTION_INVALID ((NTSTATUS) 0xC000023AL) -#endif - -#ifndef STATUS_CONNECTION_ACTIVE -# define STATUS_CONNECTION_ACTIVE ((NTSTATUS) 0xC000023BL) -#endif - -#ifndef STATUS_NETWORK_UNREACHABLE -# define STATUS_NETWORK_UNREACHABLE ((NTSTATUS) 0xC000023CL) -#endif - -#ifndef STATUS_HOST_UNREACHABLE -# define STATUS_HOST_UNREACHABLE ((NTSTATUS) 0xC000023DL) -#endif - -#ifndef STATUS_PROTOCOL_UNREACHABLE -# define STATUS_PROTOCOL_UNREACHABLE ((NTSTATUS) 0xC000023EL) -#endif - -#ifndef STATUS_PORT_UNREACHABLE -# define STATUS_PORT_UNREACHABLE ((NTSTATUS) 0xC000023FL) -#endif - -#ifndef STATUS_REQUEST_ABORTED -# define STATUS_REQUEST_ABORTED ((NTSTATUS) 0xC0000240L) -#endif - -#ifndef STATUS_CONNECTION_ABORTED -# define STATUS_CONNECTION_ABORTED ((NTSTATUS) 0xC0000241L) -#endif - -#ifndef STATUS_BAD_COMPRESSION_BUFFER -# define STATUS_BAD_COMPRESSION_BUFFER ((NTSTATUS) 0xC0000242L) -#endif - -#ifndef STATUS_USER_MAPPED_FILE -# define STATUS_USER_MAPPED_FILE ((NTSTATUS) 0xC0000243L) -#endif - -#ifndef STATUS_AUDIT_FAILED -# define STATUS_AUDIT_FAILED ((NTSTATUS) 0xC0000244L) -#endif - -#ifndef STATUS_TIMER_RESOLUTION_NOT_SET -# define STATUS_TIMER_RESOLUTION_NOT_SET ((NTSTATUS) 0xC0000245L) -#endif - -#ifndef STATUS_CONNECTION_COUNT_LIMIT -# define STATUS_CONNECTION_COUNT_LIMIT ((NTSTATUS) 0xC0000246L) -#endif - -#ifndef STATUS_LOGIN_TIME_RESTRICTION -# define STATUS_LOGIN_TIME_RESTRICTION ((NTSTATUS) 0xC0000247L) -#endif - -#ifndef STATUS_LOGIN_WKSTA_RESTRICTION -# define STATUS_LOGIN_WKSTA_RESTRICTION ((NTSTATUS) 0xC0000248L) -#endif - -#ifndef STATUS_IMAGE_MP_UP_MISMATCH -# define STATUS_IMAGE_MP_UP_MISMATCH ((NTSTATUS) 0xC0000249L) -#endif - -#ifndef STATUS_INSUFFICIENT_LOGON_INFO -# define STATUS_INSUFFICIENT_LOGON_INFO ((NTSTATUS) 0xC0000250L) -#endif - -#ifndef STATUS_BAD_DLL_ENTRYPOINT -# define STATUS_BAD_DLL_ENTRYPOINT ((NTSTATUS) 0xC0000251L) -#endif - -#ifndef STATUS_BAD_SERVICE_ENTRYPOINT -# define STATUS_BAD_SERVICE_ENTRYPOINT ((NTSTATUS) 0xC0000252L) -#endif - -#ifndef STATUS_LPC_REPLY_LOST -# define STATUS_LPC_REPLY_LOST ((NTSTATUS) 0xC0000253L) -#endif - -#ifndef STATUS_IP_ADDRESS_CONFLICT1 -# define STATUS_IP_ADDRESS_CONFLICT1 ((NTSTATUS) 0xC0000254L) -#endif - -#ifndef STATUS_IP_ADDRESS_CONFLICT2 -# define STATUS_IP_ADDRESS_CONFLICT2 ((NTSTATUS) 0xC0000255L) -#endif - -#ifndef STATUS_REGISTRY_QUOTA_LIMIT -# define STATUS_REGISTRY_QUOTA_LIMIT ((NTSTATUS) 0xC0000256L) -#endif - -#ifndef STATUS_PATH_NOT_COVERED -# define STATUS_PATH_NOT_COVERED ((NTSTATUS) 0xC0000257L) -#endif - -#ifndef STATUS_NO_CALLBACK_ACTIVE -# define STATUS_NO_CALLBACK_ACTIVE ((NTSTATUS) 0xC0000258L) -#endif - -#ifndef STATUS_LICENSE_QUOTA_EXCEEDED -# define STATUS_LICENSE_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000259L) -#endif - -#ifndef STATUS_PWD_TOO_SHORT -# define STATUS_PWD_TOO_SHORT ((NTSTATUS) 0xC000025AL) -#endif - -#ifndef STATUS_PWD_TOO_RECENT -# define STATUS_PWD_TOO_RECENT ((NTSTATUS) 0xC000025BL) -#endif - -#ifndef STATUS_PWD_HISTORY_CONFLICT -# define STATUS_PWD_HISTORY_CONFLICT ((NTSTATUS) 0xC000025CL) -#endif - -#ifndef STATUS_PLUGPLAY_NO_DEVICE -# define STATUS_PLUGPLAY_NO_DEVICE ((NTSTATUS) 0xC000025EL) -#endif - -#ifndef STATUS_UNSUPPORTED_COMPRESSION -# define STATUS_UNSUPPORTED_COMPRESSION ((NTSTATUS) 0xC000025FL) -#endif - -#ifndef STATUS_INVALID_HW_PROFILE -# define STATUS_INVALID_HW_PROFILE ((NTSTATUS) 0xC0000260L) -#endif - -#ifndef STATUS_INVALID_PLUGPLAY_DEVICE_PATH -# define STATUS_INVALID_PLUGPLAY_DEVICE_PATH ((NTSTATUS) 0xC0000261L) -#endif - -#ifndef STATUS_DRIVER_ORDINAL_NOT_FOUND -# define STATUS_DRIVER_ORDINAL_NOT_FOUND ((NTSTATUS) 0xC0000262L) -#endif - -#ifndef STATUS_DRIVER_ENTRYPOINT_NOT_FOUND -# define STATUS_DRIVER_ENTRYPOINT_NOT_FOUND ((NTSTATUS) 0xC0000263L) -#endif - -#ifndef STATUS_RESOURCE_NOT_OWNED -# define STATUS_RESOURCE_NOT_OWNED ((NTSTATUS) 0xC0000264L) -#endif - -#ifndef STATUS_TOO_MANY_LINKS -# define STATUS_TOO_MANY_LINKS ((NTSTATUS) 0xC0000265L) -#endif - -#ifndef STATUS_QUOTA_LIST_INCONSISTENT -# define STATUS_QUOTA_LIST_INCONSISTENT ((NTSTATUS) 0xC0000266L) -#endif - -#ifndef STATUS_FILE_IS_OFFLINE -# define STATUS_FILE_IS_OFFLINE ((NTSTATUS) 0xC0000267L) -#endif - -#ifndef STATUS_EVALUATION_EXPIRATION -# define STATUS_EVALUATION_EXPIRATION ((NTSTATUS) 0xC0000268L) -#endif - -#ifndef STATUS_ILLEGAL_DLL_RELOCATION -# define STATUS_ILLEGAL_DLL_RELOCATION ((NTSTATUS) 0xC0000269L) -#endif - -#ifndef STATUS_LICENSE_VIOLATION -# define STATUS_LICENSE_VIOLATION ((NTSTATUS) 0xC000026AL) -#endif - -#ifndef STATUS_DLL_INIT_FAILED_LOGOFF -# define STATUS_DLL_INIT_FAILED_LOGOFF ((NTSTATUS) 0xC000026BL) -#endif - -#ifndef STATUS_DRIVER_UNABLE_TO_LOAD -# define STATUS_DRIVER_UNABLE_TO_LOAD ((NTSTATUS) 0xC000026CL) -#endif - -#ifndef STATUS_DFS_UNAVAILABLE -# define STATUS_DFS_UNAVAILABLE ((NTSTATUS) 0xC000026DL) -#endif - -#ifndef STATUS_VOLUME_DISMOUNTED -# define STATUS_VOLUME_DISMOUNTED ((NTSTATUS) 0xC000026EL) -#endif - -#ifndef STATUS_WX86_INTERNAL_ERROR -# define STATUS_WX86_INTERNAL_ERROR ((NTSTATUS) 0xC000026FL) -#endif - -#ifndef STATUS_WX86_FLOAT_STACK_CHECK -# define STATUS_WX86_FLOAT_STACK_CHECK ((NTSTATUS) 0xC0000270L) -#endif - -#ifndef STATUS_VALIDATE_CONTINUE -# define STATUS_VALIDATE_CONTINUE ((NTSTATUS) 0xC0000271L) -#endif - -#ifndef STATUS_NO_MATCH -# define STATUS_NO_MATCH ((NTSTATUS) 0xC0000272L) -#endif - -#ifndef STATUS_NO_MORE_MATCHES -# define STATUS_NO_MORE_MATCHES ((NTSTATUS) 0xC0000273L) -#endif - -#ifndef STATUS_NOT_A_REPARSE_POINT -# define STATUS_NOT_A_REPARSE_POINT ((NTSTATUS) 0xC0000275L) -#endif - -#ifndef STATUS_IO_REPARSE_TAG_INVALID -# define STATUS_IO_REPARSE_TAG_INVALID ((NTSTATUS) 0xC0000276L) -#endif - -#ifndef STATUS_IO_REPARSE_TAG_MISMATCH -# define STATUS_IO_REPARSE_TAG_MISMATCH ((NTSTATUS) 0xC0000277L) -#endif - -#ifndef STATUS_IO_REPARSE_DATA_INVALID -# define STATUS_IO_REPARSE_DATA_INVALID ((NTSTATUS) 0xC0000278L) -#endif - -#ifndef STATUS_IO_REPARSE_TAG_NOT_HANDLED -# define STATUS_IO_REPARSE_TAG_NOT_HANDLED ((NTSTATUS) 0xC0000279L) -#endif - -#ifndef STATUS_REPARSE_POINT_NOT_RESOLVED -# define STATUS_REPARSE_POINT_NOT_RESOLVED ((NTSTATUS) 0xC0000280L) -#endif - -#ifndef STATUS_DIRECTORY_IS_A_REPARSE_POINT -# define STATUS_DIRECTORY_IS_A_REPARSE_POINT ((NTSTATUS) 0xC0000281L) -#endif - -#ifndef STATUS_RANGE_LIST_CONFLICT -# define STATUS_RANGE_LIST_CONFLICT ((NTSTATUS) 0xC0000282L) -#endif - -#ifndef STATUS_SOURCE_ELEMENT_EMPTY -# define STATUS_SOURCE_ELEMENT_EMPTY ((NTSTATUS) 0xC0000283L) -#endif - -#ifndef STATUS_DESTINATION_ELEMENT_FULL -# define STATUS_DESTINATION_ELEMENT_FULL ((NTSTATUS) 0xC0000284L) -#endif - -#ifndef STATUS_ILLEGAL_ELEMENT_ADDRESS -# define STATUS_ILLEGAL_ELEMENT_ADDRESS ((NTSTATUS) 0xC0000285L) -#endif - -#ifndef STATUS_MAGAZINE_NOT_PRESENT -# define STATUS_MAGAZINE_NOT_PRESENT ((NTSTATUS) 0xC0000286L) -#endif - -#ifndef STATUS_REINITIALIZATION_NEEDED -# define STATUS_REINITIALIZATION_NEEDED ((NTSTATUS) 0xC0000287L) -#endif - -#ifndef STATUS_DEVICE_REQUIRES_CLEANING -# define STATUS_DEVICE_REQUIRES_CLEANING ((NTSTATUS) 0x80000288L) -#endif - -#ifndef STATUS_DEVICE_DOOR_OPEN -# define STATUS_DEVICE_DOOR_OPEN ((NTSTATUS) 0x80000289L) -#endif - -#ifndef STATUS_ENCRYPTION_FAILED -# define STATUS_ENCRYPTION_FAILED ((NTSTATUS) 0xC000028AL) -#endif - -#ifndef STATUS_DECRYPTION_FAILED -# define STATUS_DECRYPTION_FAILED ((NTSTATUS) 0xC000028BL) -#endif - -#ifndef STATUS_RANGE_NOT_FOUND -# define STATUS_RANGE_NOT_FOUND ((NTSTATUS) 0xC000028CL) -#endif - -#ifndef STATUS_NO_RECOVERY_POLICY -# define STATUS_NO_RECOVERY_POLICY ((NTSTATUS) 0xC000028DL) -#endif - -#ifndef STATUS_NO_EFS -# define STATUS_NO_EFS ((NTSTATUS) 0xC000028EL) -#endif - -#ifndef STATUS_WRONG_EFS -# define STATUS_WRONG_EFS ((NTSTATUS) 0xC000028FL) -#endif - -#ifndef STATUS_NO_USER_KEYS -# define STATUS_NO_USER_KEYS ((NTSTATUS) 0xC0000290L) -#endif - -#ifndef STATUS_FILE_NOT_ENCRYPTED -# define STATUS_FILE_NOT_ENCRYPTED ((NTSTATUS) 0xC0000291L) -#endif - -#ifndef STATUS_NOT_EXPORT_FORMAT -# define STATUS_NOT_EXPORT_FORMAT ((NTSTATUS) 0xC0000292L) -#endif - -#ifndef STATUS_FILE_ENCRYPTED -# define STATUS_FILE_ENCRYPTED ((NTSTATUS) 0xC0000293L) -#endif - -#ifndef STATUS_WAKE_SYSTEM -# define STATUS_WAKE_SYSTEM ((NTSTATUS) 0x40000294L) -#endif - -#ifndef STATUS_WMI_GUID_NOT_FOUND -# define STATUS_WMI_GUID_NOT_FOUND ((NTSTATUS) 0xC0000295L) -#endif - -#ifndef STATUS_WMI_INSTANCE_NOT_FOUND -# define STATUS_WMI_INSTANCE_NOT_FOUND ((NTSTATUS) 0xC0000296L) -#endif - -#ifndef STATUS_WMI_ITEMID_NOT_FOUND -# define STATUS_WMI_ITEMID_NOT_FOUND ((NTSTATUS) 0xC0000297L) -#endif - -#ifndef STATUS_WMI_TRY_AGAIN -# define STATUS_WMI_TRY_AGAIN ((NTSTATUS) 0xC0000298L) -#endif - -#ifndef STATUS_SHARED_POLICY -# define STATUS_SHARED_POLICY ((NTSTATUS) 0xC0000299L) -#endif - -#ifndef STATUS_POLICY_OBJECT_NOT_FOUND -# define STATUS_POLICY_OBJECT_NOT_FOUND ((NTSTATUS) 0xC000029AL) -#endif - -#ifndef STATUS_POLICY_ONLY_IN_DS -# define STATUS_POLICY_ONLY_IN_DS ((NTSTATUS) 0xC000029BL) -#endif - -#ifndef STATUS_VOLUME_NOT_UPGRADED -# define STATUS_VOLUME_NOT_UPGRADED ((NTSTATUS) 0xC000029CL) -#endif - -#ifndef STATUS_REMOTE_STORAGE_NOT_ACTIVE -# define STATUS_REMOTE_STORAGE_NOT_ACTIVE ((NTSTATUS) 0xC000029DL) -#endif - -#ifndef STATUS_REMOTE_STORAGE_MEDIA_ERROR -# define STATUS_REMOTE_STORAGE_MEDIA_ERROR ((NTSTATUS) 0xC000029EL) -#endif - -#ifndef STATUS_NO_TRACKING_SERVICE -# define STATUS_NO_TRACKING_SERVICE ((NTSTATUS) 0xC000029FL) -#endif - -#ifndef STATUS_SERVER_SID_MISMATCH -# define STATUS_SERVER_SID_MISMATCH ((NTSTATUS) 0xC00002A0L) -#endif - -#ifndef STATUS_DS_NO_ATTRIBUTE_OR_VALUE -# define STATUS_DS_NO_ATTRIBUTE_OR_VALUE ((NTSTATUS) 0xC00002A1L) -#endif - -#ifndef STATUS_DS_INVALID_ATTRIBUTE_SYNTAX -# define STATUS_DS_INVALID_ATTRIBUTE_SYNTAX ((NTSTATUS) 0xC00002A2L) -#endif - -#ifndef STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED -# define STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED ((NTSTATUS) 0xC00002A3L) -#endif - -#ifndef STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS -# define STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS ((NTSTATUS) 0xC00002A4L) -#endif - -#ifndef STATUS_DS_BUSY -# define STATUS_DS_BUSY ((NTSTATUS) 0xC00002A5L) -#endif - -#ifndef STATUS_DS_UNAVAILABLE -# define STATUS_DS_UNAVAILABLE ((NTSTATUS) 0xC00002A6L) -#endif - -#ifndef STATUS_DS_NO_RIDS_ALLOCATED -# define STATUS_DS_NO_RIDS_ALLOCATED ((NTSTATUS) 0xC00002A7L) -#endif - -#ifndef STATUS_DS_NO_MORE_RIDS -# define STATUS_DS_NO_MORE_RIDS ((NTSTATUS) 0xC00002A8L) -#endif - -#ifndef STATUS_DS_INCORRECT_ROLE_OWNER -# define STATUS_DS_INCORRECT_ROLE_OWNER ((NTSTATUS) 0xC00002A9L) -#endif - -#ifndef STATUS_DS_RIDMGR_INIT_ERROR -# define STATUS_DS_RIDMGR_INIT_ERROR ((NTSTATUS) 0xC00002AAL) -#endif - -#ifndef STATUS_DS_OBJ_CLASS_VIOLATION -# define STATUS_DS_OBJ_CLASS_VIOLATION ((NTSTATUS) 0xC00002ABL) -#endif - -#ifndef STATUS_DS_CANT_ON_NON_LEAF -# define STATUS_DS_CANT_ON_NON_LEAF ((NTSTATUS) 0xC00002ACL) -#endif - -#ifndef STATUS_DS_CANT_ON_RDN -# define STATUS_DS_CANT_ON_RDN ((NTSTATUS) 0xC00002ADL) -#endif - -#ifndef STATUS_DS_CANT_MOD_OBJ_CLASS -# define STATUS_DS_CANT_MOD_OBJ_CLASS ((NTSTATUS) 0xC00002AEL) -#endif - -#ifndef STATUS_DS_CROSS_DOM_MOVE_FAILED -# define STATUS_DS_CROSS_DOM_MOVE_FAILED ((NTSTATUS) 0xC00002AFL) -#endif - -#ifndef STATUS_DS_GC_NOT_AVAILABLE -# define STATUS_DS_GC_NOT_AVAILABLE ((NTSTATUS) 0xC00002B0L) -#endif - -#ifndef STATUS_DIRECTORY_SERVICE_REQUIRED -# define STATUS_DIRECTORY_SERVICE_REQUIRED ((NTSTATUS) 0xC00002B1L) -#endif - -#ifndef STATUS_REPARSE_ATTRIBUTE_CONFLICT -# define STATUS_REPARSE_ATTRIBUTE_CONFLICT ((NTSTATUS) 0xC00002B2L) -#endif - -#ifndef STATUS_CANT_ENABLE_DENY_ONLY -# define STATUS_CANT_ENABLE_DENY_ONLY ((NTSTATUS) 0xC00002B3L) -#endif - -#ifndef STATUS_FLOAT_MULTIPLE_FAULTS -# define STATUS_FLOAT_MULTIPLE_FAULTS ((NTSTATUS) 0xC00002B4L) -#endif - -#ifndef STATUS_FLOAT_MULTIPLE_TRAPS -# define STATUS_FLOAT_MULTIPLE_TRAPS ((NTSTATUS) 0xC00002B5L) -#endif - -#ifndef STATUS_DEVICE_REMOVED -# define STATUS_DEVICE_REMOVED ((NTSTATUS) 0xC00002B6L) -#endif - -#ifndef STATUS_JOURNAL_DELETE_IN_PROGRESS -# define STATUS_JOURNAL_DELETE_IN_PROGRESS ((NTSTATUS) 0xC00002B7L) -#endif - -#ifndef STATUS_JOURNAL_NOT_ACTIVE -# define STATUS_JOURNAL_NOT_ACTIVE ((NTSTATUS) 0xC00002B8L) -#endif - -#ifndef STATUS_NOINTERFACE -# define STATUS_NOINTERFACE ((NTSTATUS) 0xC00002B9L) -#endif - -#ifndef STATUS_DS_ADMIN_LIMIT_EXCEEDED -# define STATUS_DS_ADMIN_LIMIT_EXCEEDED ((NTSTATUS) 0xC00002C1L) -#endif - -#ifndef STATUS_DRIVER_FAILED_SLEEP -# define STATUS_DRIVER_FAILED_SLEEP ((NTSTATUS) 0xC00002C2L) -#endif - -#ifndef STATUS_MUTUAL_AUTHENTICATION_FAILED -# define STATUS_MUTUAL_AUTHENTICATION_FAILED ((NTSTATUS) 0xC00002C3L) -#endif - -#ifndef STATUS_CORRUPT_SYSTEM_FILE -# define STATUS_CORRUPT_SYSTEM_FILE ((NTSTATUS) 0xC00002C4L) -#endif - -#ifndef STATUS_DATATYPE_MISALIGNMENT_ERROR -# define STATUS_DATATYPE_MISALIGNMENT_ERROR ((NTSTATUS) 0xC00002C5L) -#endif - -#ifndef STATUS_WMI_READ_ONLY -# define STATUS_WMI_READ_ONLY ((NTSTATUS) 0xC00002C6L) -#endif - -#ifndef STATUS_WMI_SET_FAILURE -# define STATUS_WMI_SET_FAILURE ((NTSTATUS) 0xC00002C7L) -#endif - -#ifndef STATUS_COMMITMENT_MINIMUM -# define STATUS_COMMITMENT_MINIMUM ((NTSTATUS) 0xC00002C8L) -#endif - -#ifndef STATUS_REG_NAT_CONSUMPTION -# define STATUS_REG_NAT_CONSUMPTION ((NTSTATUS) 0xC00002C9L) -#endif - -#ifndef STATUS_TRANSPORT_FULL -# define STATUS_TRANSPORT_FULL ((NTSTATUS) 0xC00002CAL) -#endif - -#ifndef STATUS_DS_SAM_INIT_FAILURE -# define STATUS_DS_SAM_INIT_FAILURE ((NTSTATUS) 0xC00002CBL) -#endif - -#ifndef STATUS_ONLY_IF_CONNECTED -# define STATUS_ONLY_IF_CONNECTED ((NTSTATUS) 0xC00002CCL) -#endif - -#ifndef STATUS_DS_SENSITIVE_GROUP_VIOLATION -# define STATUS_DS_SENSITIVE_GROUP_VIOLATION ((NTSTATUS) 0xC00002CDL) -#endif - -#ifndef STATUS_PNP_RESTART_ENUMERATION -# define STATUS_PNP_RESTART_ENUMERATION ((NTSTATUS) 0xC00002CEL) -#endif - -#ifndef STATUS_JOURNAL_ENTRY_DELETED -# define STATUS_JOURNAL_ENTRY_DELETED ((NTSTATUS) 0xC00002CFL) -#endif - -#ifndef STATUS_DS_CANT_MOD_PRIMARYGROUPID -# define STATUS_DS_CANT_MOD_PRIMARYGROUPID ((NTSTATUS) 0xC00002D0L) -#endif - -#ifndef STATUS_SYSTEM_IMAGE_BAD_SIGNATURE -# define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE ((NTSTATUS) 0xC00002D1L) -#endif - -#ifndef STATUS_PNP_REBOOT_REQUIRED -# define STATUS_PNP_REBOOT_REQUIRED ((NTSTATUS) 0xC00002D2L) -#endif - -#ifndef STATUS_POWER_STATE_INVALID -# define STATUS_POWER_STATE_INVALID ((NTSTATUS) 0xC00002D3L) -#endif - -#ifndef STATUS_DS_INVALID_GROUP_TYPE -# define STATUS_DS_INVALID_GROUP_TYPE ((NTSTATUS) 0xC00002D4L) -#endif - -#ifndef STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN -# define STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN ((NTSTATUS) 0xC00002D5L) -#endif - -#ifndef STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN -# define STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN ((NTSTATUS) 0xC00002D6L) -#endif - -#ifndef STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER -# define STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS) 0xC00002D7L) -#endif - -#ifndef STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER -# define STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS) 0xC00002D8L) -#endif - -#ifndef STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER -# define STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS) 0xC00002D9L) -#endif - -#ifndef STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER -# define STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER ((NTSTATUS) 0xC00002DAL) -#endif - -#ifndef STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER -# define STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER ((NTSTATUS) 0xC00002DBL) -#endif - -#ifndef STATUS_DS_HAVE_PRIMARY_MEMBERS -# define STATUS_DS_HAVE_PRIMARY_MEMBERS ((NTSTATUS) 0xC00002DCL) -#endif - -#ifndef STATUS_WMI_NOT_SUPPORTED -# define STATUS_WMI_NOT_SUPPORTED ((NTSTATUS) 0xC00002DDL) -#endif - -#ifndef STATUS_INSUFFICIENT_POWER -# define STATUS_INSUFFICIENT_POWER ((NTSTATUS) 0xC00002DEL) -#endif - -#ifndef STATUS_SAM_NEED_BOOTKEY_PASSWORD -# define STATUS_SAM_NEED_BOOTKEY_PASSWORD ((NTSTATUS) 0xC00002DFL) -#endif - -#ifndef STATUS_SAM_NEED_BOOTKEY_FLOPPY -# define STATUS_SAM_NEED_BOOTKEY_FLOPPY ((NTSTATUS) 0xC00002E0L) -#endif - -#ifndef STATUS_DS_CANT_START -# define STATUS_DS_CANT_START ((NTSTATUS) 0xC00002E1L) -#endif - -#ifndef STATUS_DS_INIT_FAILURE -# define STATUS_DS_INIT_FAILURE ((NTSTATUS) 0xC00002E2L) -#endif - -#ifndef STATUS_SAM_INIT_FAILURE -# define STATUS_SAM_INIT_FAILURE ((NTSTATUS) 0xC00002E3L) -#endif - -#ifndef STATUS_DS_GC_REQUIRED -# define STATUS_DS_GC_REQUIRED ((NTSTATUS) 0xC00002E4L) -#endif - -#ifndef STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY -# define STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY ((NTSTATUS) 0xC00002E5L) -#endif - -#ifndef STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS -# define STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS ((NTSTATUS) 0xC00002E6L) -#endif - -#ifndef STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED -# define STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED ((NTSTATUS) 0xC00002E7L) -#endif - -#ifndef STATUS_MULTIPLE_FAULT_VIOLATION -# define STATUS_MULTIPLE_FAULT_VIOLATION ((NTSTATUS) 0xC00002E8L) -#endif - -#ifndef STATUS_CURRENT_DOMAIN_NOT_ALLOWED -# define STATUS_CURRENT_DOMAIN_NOT_ALLOWED ((NTSTATUS) 0xC00002E9L) -#endif - -#ifndef STATUS_CANNOT_MAKE -# define STATUS_CANNOT_MAKE ((NTSTATUS) 0xC00002EAL) -#endif - -#ifndef STATUS_SYSTEM_SHUTDOWN -# define STATUS_SYSTEM_SHUTDOWN ((NTSTATUS) 0xC00002EBL) -#endif - -#ifndef STATUS_DS_INIT_FAILURE_CONSOLE -# define STATUS_DS_INIT_FAILURE_CONSOLE ((NTSTATUS) 0xC00002ECL) -#endif - -#ifndef STATUS_DS_SAM_INIT_FAILURE_CONSOLE -# define STATUS_DS_SAM_INIT_FAILURE_CONSOLE ((NTSTATUS) 0xC00002EDL) -#endif - -#ifndef STATUS_UNFINISHED_CONTEXT_DELETED -# define STATUS_UNFINISHED_CONTEXT_DELETED ((NTSTATUS) 0xC00002EEL) -#endif - -#ifndef STATUS_NO_TGT_REPLY -# define STATUS_NO_TGT_REPLY ((NTSTATUS) 0xC00002EFL) -#endif - -#ifndef STATUS_OBJECTID_NOT_FOUND -# define STATUS_OBJECTID_NOT_FOUND ((NTSTATUS) 0xC00002F0L) -#endif - -#ifndef STATUS_NO_IP_ADDRESSES -# define STATUS_NO_IP_ADDRESSES ((NTSTATUS) 0xC00002F1L) -#endif - -#ifndef STATUS_WRONG_CREDENTIAL_HANDLE -# define STATUS_WRONG_CREDENTIAL_HANDLE ((NTSTATUS) 0xC00002F2L) -#endif - -#ifndef STATUS_CRYPTO_SYSTEM_INVALID -# define STATUS_CRYPTO_SYSTEM_INVALID ((NTSTATUS) 0xC00002F3L) -#endif - -#ifndef STATUS_MAX_REFERRALS_EXCEEDED -# define STATUS_MAX_REFERRALS_EXCEEDED ((NTSTATUS) 0xC00002F4L) -#endif - -#ifndef STATUS_MUST_BE_KDC -# define STATUS_MUST_BE_KDC ((NTSTATUS) 0xC00002F5L) -#endif - -#ifndef STATUS_STRONG_CRYPTO_NOT_SUPPORTED -# define STATUS_STRONG_CRYPTO_NOT_SUPPORTED ((NTSTATUS) 0xC00002F6L) -#endif - -#ifndef STATUS_TOO_MANY_PRINCIPALS -# define STATUS_TOO_MANY_PRINCIPALS ((NTSTATUS) 0xC00002F7L) -#endif - -#ifndef STATUS_NO_PA_DATA -# define STATUS_NO_PA_DATA ((NTSTATUS) 0xC00002F8L) -#endif - -#ifndef STATUS_PKINIT_NAME_MISMATCH -# define STATUS_PKINIT_NAME_MISMATCH ((NTSTATUS) 0xC00002F9L) -#endif - -#ifndef STATUS_SMARTCARD_LOGON_REQUIRED -# define STATUS_SMARTCARD_LOGON_REQUIRED ((NTSTATUS) 0xC00002FAL) -#endif - -#ifndef STATUS_KDC_INVALID_REQUEST -# define STATUS_KDC_INVALID_REQUEST ((NTSTATUS) 0xC00002FBL) -#endif - -#ifndef STATUS_KDC_UNABLE_TO_REFER -# define STATUS_KDC_UNABLE_TO_REFER ((NTSTATUS) 0xC00002FCL) -#endif - -#ifndef STATUS_KDC_UNKNOWN_ETYPE -# define STATUS_KDC_UNKNOWN_ETYPE ((NTSTATUS) 0xC00002FDL) -#endif - -#ifndef STATUS_SHUTDOWN_IN_PROGRESS -# define STATUS_SHUTDOWN_IN_PROGRESS ((NTSTATUS) 0xC00002FEL) -#endif - -#ifndef STATUS_SERVER_SHUTDOWN_IN_PROGRESS -# define STATUS_SERVER_SHUTDOWN_IN_PROGRESS ((NTSTATUS) 0xC00002FFL) -#endif - -#ifndef STATUS_NOT_SUPPORTED_ON_SBS -# define STATUS_NOT_SUPPORTED_ON_SBS ((NTSTATUS) 0xC0000300L) -#endif - -#ifndef STATUS_WMI_GUID_DISCONNECTED -# define STATUS_WMI_GUID_DISCONNECTED ((NTSTATUS) 0xC0000301L) -#endif - -#ifndef STATUS_WMI_ALREADY_DISABLED -# define STATUS_WMI_ALREADY_DISABLED ((NTSTATUS) 0xC0000302L) -#endif - -#ifndef STATUS_WMI_ALREADY_ENABLED -# define STATUS_WMI_ALREADY_ENABLED ((NTSTATUS) 0xC0000303L) -#endif - -#ifndef STATUS_MFT_TOO_FRAGMENTED -# define STATUS_MFT_TOO_FRAGMENTED ((NTSTATUS) 0xC0000304L) -#endif - -#ifndef STATUS_COPY_PROTECTION_FAILURE -# define STATUS_COPY_PROTECTION_FAILURE ((NTSTATUS) 0xC0000305L) -#endif - -#ifndef STATUS_CSS_AUTHENTICATION_FAILURE -# define STATUS_CSS_AUTHENTICATION_FAILURE ((NTSTATUS) 0xC0000306L) -#endif - -#ifndef STATUS_CSS_KEY_NOT_PRESENT -# define STATUS_CSS_KEY_NOT_PRESENT ((NTSTATUS) 0xC0000307L) -#endif - -#ifndef STATUS_CSS_KEY_NOT_ESTABLISHED -# define STATUS_CSS_KEY_NOT_ESTABLISHED ((NTSTATUS) 0xC0000308L) -#endif - -#ifndef STATUS_CSS_SCRAMBLED_SECTOR -# define STATUS_CSS_SCRAMBLED_SECTOR ((NTSTATUS) 0xC0000309L) -#endif - -#ifndef STATUS_CSS_REGION_MISMATCH -# define STATUS_CSS_REGION_MISMATCH ((NTSTATUS) 0xC000030AL) -#endif - -#ifndef STATUS_CSS_RESETS_EXHAUSTED -# define STATUS_CSS_RESETS_EXHAUSTED ((NTSTATUS) 0xC000030BL) -#endif - -#ifndef STATUS_PKINIT_FAILURE -# define STATUS_PKINIT_FAILURE ((NTSTATUS) 0xC0000320L) -#endif - -#ifndef STATUS_SMARTCARD_SUBSYSTEM_FAILURE -# define STATUS_SMARTCARD_SUBSYSTEM_FAILURE ((NTSTATUS) 0xC0000321L) -#endif - -#ifndef STATUS_NO_KERB_KEY -# define STATUS_NO_KERB_KEY ((NTSTATUS) 0xC0000322L) -#endif - -#ifndef STATUS_HOST_DOWN -# define STATUS_HOST_DOWN ((NTSTATUS) 0xC0000350L) -#endif - -#ifndef STATUS_UNSUPPORTED_PREAUTH -# define STATUS_UNSUPPORTED_PREAUTH ((NTSTATUS) 0xC0000351L) -#endif - -#ifndef STATUS_EFS_ALG_BLOB_TOO_BIG -# define STATUS_EFS_ALG_BLOB_TOO_BIG ((NTSTATUS) 0xC0000352L) -#endif - -#ifndef STATUS_PORT_NOT_SET -# define STATUS_PORT_NOT_SET ((NTSTATUS) 0xC0000353L) -#endif - -#ifndef STATUS_DEBUGGER_INACTIVE -# define STATUS_DEBUGGER_INACTIVE ((NTSTATUS) 0xC0000354L) -#endif - -#ifndef STATUS_DS_VERSION_CHECK_FAILURE -# define STATUS_DS_VERSION_CHECK_FAILURE ((NTSTATUS) 0xC0000355L) -#endif - -#ifndef STATUS_AUDITING_DISABLED -# define STATUS_AUDITING_DISABLED ((NTSTATUS) 0xC0000356L) -#endif - -#ifndef STATUS_PRENT4_MACHINE_ACCOUNT -# define STATUS_PRENT4_MACHINE_ACCOUNT ((NTSTATUS) 0xC0000357L) -#endif - -#ifndef STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER -# define STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS) 0xC0000358L) -#endif - -#ifndef STATUS_INVALID_IMAGE_WIN_32 -# define STATUS_INVALID_IMAGE_WIN_32 ((NTSTATUS) 0xC0000359L) -#endif - -#ifndef STATUS_INVALID_IMAGE_WIN_64 -# define STATUS_INVALID_IMAGE_WIN_64 ((NTSTATUS) 0xC000035AL) -#endif - -#ifndef STATUS_BAD_BINDINGS -# define STATUS_BAD_BINDINGS ((NTSTATUS) 0xC000035BL) -#endif - -#ifndef STATUS_NETWORK_SESSION_EXPIRED -# define STATUS_NETWORK_SESSION_EXPIRED ((NTSTATUS) 0xC000035CL) -#endif - -#ifndef STATUS_APPHELP_BLOCK -# define STATUS_APPHELP_BLOCK ((NTSTATUS) 0xC000035DL) -#endif - -#ifndef STATUS_ALL_SIDS_FILTERED -# define STATUS_ALL_SIDS_FILTERED ((NTSTATUS) 0xC000035EL) -#endif - -#ifndef STATUS_NOT_SAFE_MODE_DRIVER -# define STATUS_NOT_SAFE_MODE_DRIVER ((NTSTATUS) 0xC000035FL) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT -# define STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT ((NTSTATUS) 0xC0000361L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_PATH -# define STATUS_ACCESS_DISABLED_BY_POLICY_PATH ((NTSTATUS) 0xC0000362L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER -# define STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER ((NTSTATUS) 0xC0000363L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_BY_POLICY_OTHER -# define STATUS_ACCESS_DISABLED_BY_POLICY_OTHER ((NTSTATUS) 0xC0000364L) -#endif - -#ifndef STATUS_FAILED_DRIVER_ENTRY -# define STATUS_FAILED_DRIVER_ENTRY ((NTSTATUS) 0xC0000365L) -#endif - -#ifndef STATUS_DEVICE_ENUMERATION_ERROR -# define STATUS_DEVICE_ENUMERATION_ERROR ((NTSTATUS) 0xC0000366L) -#endif - -#ifndef STATUS_MOUNT_POINT_NOT_RESOLVED -# define STATUS_MOUNT_POINT_NOT_RESOLVED ((NTSTATUS) 0xC0000368L) -#endif - -#ifndef STATUS_INVALID_DEVICE_OBJECT_PARAMETER -# define STATUS_INVALID_DEVICE_OBJECT_PARAMETER ((NTSTATUS) 0xC0000369L) -#endif - -#ifndef STATUS_MCA_OCCURED -# define STATUS_MCA_OCCURED ((NTSTATUS) 0xC000036AL) -#endif - -#ifndef STATUS_DRIVER_BLOCKED_CRITICAL -# define STATUS_DRIVER_BLOCKED_CRITICAL ((NTSTATUS) 0xC000036BL) -#endif - -#ifndef STATUS_DRIVER_BLOCKED -# define STATUS_DRIVER_BLOCKED ((NTSTATUS) 0xC000036CL) -#endif - -#ifndef STATUS_DRIVER_DATABASE_ERROR -# define STATUS_DRIVER_DATABASE_ERROR ((NTSTATUS) 0xC000036DL) -#endif - -#ifndef STATUS_SYSTEM_HIVE_TOO_LARGE -# define STATUS_SYSTEM_HIVE_TOO_LARGE ((NTSTATUS) 0xC000036EL) -#endif - -#ifndef STATUS_INVALID_IMPORT_OF_NON_DLL -# define STATUS_INVALID_IMPORT_OF_NON_DLL ((NTSTATUS) 0xC000036FL) -#endif - -#ifndef STATUS_DS_SHUTTING_DOWN -# define STATUS_DS_SHUTTING_DOWN ((NTSTATUS) 0x40000370L) -#endif - -#ifndef STATUS_NO_SECRETS -# define STATUS_NO_SECRETS ((NTSTATUS) 0xC0000371L) -#endif - -#ifndef STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY -# define STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY ((NTSTATUS) 0xC0000372L) -#endif - -#ifndef STATUS_FAILED_STACK_SWITCH -# define STATUS_FAILED_STACK_SWITCH ((NTSTATUS) 0xC0000373L) -#endif - -#ifndef STATUS_HEAP_CORRUPTION -# define STATUS_HEAP_CORRUPTION ((NTSTATUS) 0xC0000374L) -#endif - -#ifndef STATUS_SMARTCARD_WRONG_PIN -# define STATUS_SMARTCARD_WRONG_PIN ((NTSTATUS) 0xC0000380L) -#endif - -#ifndef STATUS_SMARTCARD_CARD_BLOCKED -# define STATUS_SMARTCARD_CARD_BLOCKED ((NTSTATUS) 0xC0000381L) -#endif - -#ifndef STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED -# define STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED ((NTSTATUS) 0xC0000382L) -#endif - -#ifndef STATUS_SMARTCARD_NO_CARD -# define STATUS_SMARTCARD_NO_CARD ((NTSTATUS) 0xC0000383L) -#endif - -#ifndef STATUS_SMARTCARD_NO_KEY_CONTAINER -# define STATUS_SMARTCARD_NO_KEY_CONTAINER ((NTSTATUS) 0xC0000384L) -#endif - -#ifndef STATUS_SMARTCARD_NO_CERTIFICATE -# define STATUS_SMARTCARD_NO_CERTIFICATE ((NTSTATUS) 0xC0000385L) -#endif - -#ifndef STATUS_SMARTCARD_NO_KEYSET -# define STATUS_SMARTCARD_NO_KEYSET ((NTSTATUS) 0xC0000386L) -#endif - -#ifndef STATUS_SMARTCARD_IO_ERROR -# define STATUS_SMARTCARD_IO_ERROR ((NTSTATUS) 0xC0000387L) -#endif - -#ifndef STATUS_DOWNGRADE_DETECTED -# define STATUS_DOWNGRADE_DETECTED ((NTSTATUS) 0xC0000388L) -#endif - -#ifndef STATUS_SMARTCARD_CERT_REVOKED -# define STATUS_SMARTCARD_CERT_REVOKED ((NTSTATUS) 0xC0000389L) -#endif - -#ifndef STATUS_ISSUING_CA_UNTRUSTED -# define STATUS_ISSUING_CA_UNTRUSTED ((NTSTATUS) 0xC000038AL) -#endif - -#ifndef STATUS_REVOCATION_OFFLINE_C -# define STATUS_REVOCATION_OFFLINE_C ((NTSTATUS) 0xC000038BL) -#endif - -#ifndef STATUS_PKINIT_CLIENT_FAILURE -# define STATUS_PKINIT_CLIENT_FAILURE ((NTSTATUS) 0xC000038CL) -#endif - -#ifndef STATUS_SMARTCARD_CERT_EXPIRED -# define STATUS_SMARTCARD_CERT_EXPIRED ((NTSTATUS) 0xC000038DL) -#endif - -#ifndef STATUS_DRIVER_FAILED_PRIOR_UNLOAD -# define STATUS_DRIVER_FAILED_PRIOR_UNLOAD ((NTSTATUS) 0xC000038EL) -#endif - -#ifndef STATUS_SMARTCARD_SILENT_CONTEXT -# define STATUS_SMARTCARD_SILENT_CONTEXT ((NTSTATUS) 0xC000038FL) -#endif - -#ifndef STATUS_PER_USER_TRUST_QUOTA_EXCEEDED -# define STATUS_PER_USER_TRUST_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000401L) -#endif - -#ifndef STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED -# define STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000402L) -#endif - -#ifndef STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED -# define STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000403L) -#endif - -#ifndef STATUS_DS_NAME_NOT_UNIQUE -# define STATUS_DS_NAME_NOT_UNIQUE ((NTSTATUS) 0xC0000404L) -#endif - -#ifndef STATUS_DS_DUPLICATE_ID_FOUND -# define STATUS_DS_DUPLICATE_ID_FOUND ((NTSTATUS) 0xC0000405L) -#endif - -#ifndef STATUS_DS_GROUP_CONVERSION_ERROR -# define STATUS_DS_GROUP_CONVERSION_ERROR ((NTSTATUS) 0xC0000406L) -#endif - -#ifndef STATUS_VOLSNAP_PREPARE_HIBERNATE -# define STATUS_VOLSNAP_PREPARE_HIBERNATE ((NTSTATUS) 0xC0000407L) -#endif - -#ifndef STATUS_USER2USER_REQUIRED -# define STATUS_USER2USER_REQUIRED ((NTSTATUS) 0xC0000408L) -#endif - -#ifndef STATUS_STACK_BUFFER_OVERRUN -# define STATUS_STACK_BUFFER_OVERRUN ((NTSTATUS) 0xC0000409L) -#endif - -#ifndef STATUS_NO_S4U_PROT_SUPPORT -# define STATUS_NO_S4U_PROT_SUPPORT ((NTSTATUS) 0xC000040AL) -#endif - -#ifndef STATUS_CROSSREALM_DELEGATION_FAILURE -# define STATUS_CROSSREALM_DELEGATION_FAILURE ((NTSTATUS) 0xC000040BL) -#endif - -#ifndef STATUS_REVOCATION_OFFLINE_KDC -# define STATUS_REVOCATION_OFFLINE_KDC ((NTSTATUS) 0xC000040CL) -#endif - -#ifndef STATUS_ISSUING_CA_UNTRUSTED_KDC -# define STATUS_ISSUING_CA_UNTRUSTED_KDC ((NTSTATUS) 0xC000040DL) -#endif - -#ifndef STATUS_KDC_CERT_EXPIRED -# define STATUS_KDC_CERT_EXPIRED ((NTSTATUS) 0xC000040EL) -#endif - -#ifndef STATUS_KDC_CERT_REVOKED -# define STATUS_KDC_CERT_REVOKED ((NTSTATUS) 0xC000040FL) -#endif - -#ifndef STATUS_PARAMETER_QUOTA_EXCEEDED -# define STATUS_PARAMETER_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000410L) -#endif - -#ifndef STATUS_HIBERNATION_FAILURE -# define STATUS_HIBERNATION_FAILURE ((NTSTATUS) 0xC0000411L) -#endif - -#ifndef STATUS_DELAY_LOAD_FAILED -# define STATUS_DELAY_LOAD_FAILED ((NTSTATUS) 0xC0000412L) -#endif - -#ifndef STATUS_AUTHENTICATION_FIREWALL_FAILED -# define STATUS_AUTHENTICATION_FIREWALL_FAILED ((NTSTATUS) 0xC0000413L) -#endif - -#ifndef STATUS_VDM_DISALLOWED -# define STATUS_VDM_DISALLOWED ((NTSTATUS) 0xC0000414L) -#endif - -#ifndef STATUS_HUNG_DISPLAY_DRIVER_THREAD -# define STATUS_HUNG_DISPLAY_DRIVER_THREAD ((NTSTATUS) 0xC0000415L) -#endif - -#ifndef STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE -# define STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE ((NTSTATUS) 0xC0000416L) -#endif - -#ifndef STATUS_INVALID_CRUNTIME_PARAMETER -# define STATUS_INVALID_CRUNTIME_PARAMETER ((NTSTATUS) 0xC0000417L) -#endif - -#ifndef STATUS_NTLM_BLOCKED -# define STATUS_NTLM_BLOCKED ((NTSTATUS) 0xC0000418L) -#endif - -#ifndef STATUS_DS_SRC_SID_EXISTS_IN_FOREST -# define STATUS_DS_SRC_SID_EXISTS_IN_FOREST ((NTSTATUS) 0xC0000419L) -#endif - -#ifndef STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST -# define STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST ((NTSTATUS) 0xC000041AL) -#endif - -#ifndef STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST -# define STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST ((NTSTATUS) 0xC000041BL) -#endif - -#ifndef STATUS_INVALID_USER_PRINCIPAL_NAME -# define STATUS_INVALID_USER_PRINCIPAL_NAME ((NTSTATUS) 0xC000041CL) -#endif - -#ifndef STATUS_FATAL_USER_CALLBACK_EXCEPTION -# define STATUS_FATAL_USER_CALLBACK_EXCEPTION ((NTSTATUS) 0xC000041DL) -#endif - -#ifndef STATUS_ASSERTION_FAILURE -# define STATUS_ASSERTION_FAILURE ((NTSTATUS) 0xC0000420L) -#endif - -#ifndef STATUS_VERIFIER_STOP -# define STATUS_VERIFIER_STOP ((NTSTATUS) 0xC0000421L) -#endif - -#ifndef STATUS_CALLBACK_POP_STACK -# define STATUS_CALLBACK_POP_STACK ((NTSTATUS) 0xC0000423L) -#endif - -#ifndef STATUS_INCOMPATIBLE_DRIVER_BLOCKED -# define STATUS_INCOMPATIBLE_DRIVER_BLOCKED ((NTSTATUS) 0xC0000424L) -#endif - -#ifndef STATUS_HIVE_UNLOADED -# define STATUS_HIVE_UNLOADED ((NTSTATUS) 0xC0000425L) -#endif - -#ifndef STATUS_COMPRESSION_DISABLED -# define STATUS_COMPRESSION_DISABLED ((NTSTATUS) 0xC0000426L) -#endif - -#ifndef STATUS_FILE_SYSTEM_LIMITATION -# define STATUS_FILE_SYSTEM_LIMITATION ((NTSTATUS) 0xC0000427L) -#endif - -#ifndef STATUS_INVALID_IMAGE_HASH -# define STATUS_INVALID_IMAGE_HASH ((NTSTATUS) 0xC0000428L) -#endif - -#ifndef STATUS_NOT_CAPABLE -# define STATUS_NOT_CAPABLE ((NTSTATUS) 0xC0000429L) -#endif - -#ifndef STATUS_REQUEST_OUT_OF_SEQUENCE -# define STATUS_REQUEST_OUT_OF_SEQUENCE ((NTSTATUS) 0xC000042AL) -#endif - -#ifndef STATUS_IMPLEMENTATION_LIMIT -# define STATUS_IMPLEMENTATION_LIMIT ((NTSTATUS) 0xC000042BL) -#endif - -#ifndef STATUS_ELEVATION_REQUIRED -# define STATUS_ELEVATION_REQUIRED ((NTSTATUS) 0xC000042CL) -#endif - -#ifndef STATUS_NO_SECURITY_CONTEXT -# define STATUS_NO_SECURITY_CONTEXT ((NTSTATUS) 0xC000042DL) -#endif - -#ifndef STATUS_PKU2U_CERT_FAILURE -# define STATUS_PKU2U_CERT_FAILURE ((NTSTATUS) 0xC000042FL) -#endif - -#ifndef STATUS_BEYOND_VDL -# define STATUS_BEYOND_VDL ((NTSTATUS) 0xC0000432L) -#endif - -#ifndef STATUS_ENCOUNTERED_WRITE_IN_PROGRESS -# define STATUS_ENCOUNTERED_WRITE_IN_PROGRESS ((NTSTATUS) 0xC0000433L) -#endif - -#ifndef STATUS_PTE_CHANGED -# define STATUS_PTE_CHANGED ((NTSTATUS) 0xC0000434L) -#endif - -#ifndef STATUS_PURGE_FAILED -# define STATUS_PURGE_FAILED ((NTSTATUS) 0xC0000435L) -#endif - -#ifndef STATUS_CRED_REQUIRES_CONFIRMATION -# define STATUS_CRED_REQUIRES_CONFIRMATION ((NTSTATUS) 0xC0000440L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE -# define STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE ((NTSTATUS) 0xC0000441L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER -# define STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER ((NTSTATUS) 0xC0000442L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE -# define STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE ((NTSTATUS) 0xC0000443L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE -# define STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE ((NTSTATUS) 0xC0000444L) -#endif - -#ifndef STATUS_CS_ENCRYPTION_FILE_NOT_CSE -# define STATUS_CS_ENCRYPTION_FILE_NOT_CSE ((NTSTATUS) 0xC0000445L) -#endif - -#ifndef STATUS_INVALID_LABEL -# define STATUS_INVALID_LABEL ((NTSTATUS) 0xC0000446L) -#endif - -#ifndef STATUS_DRIVER_PROCESS_TERMINATED -# define STATUS_DRIVER_PROCESS_TERMINATED ((NTSTATUS) 0xC0000450L) -#endif - -#ifndef STATUS_AMBIGUOUS_SYSTEM_DEVICE -# define STATUS_AMBIGUOUS_SYSTEM_DEVICE ((NTSTATUS) 0xC0000451L) -#endif - -#ifndef STATUS_SYSTEM_DEVICE_NOT_FOUND -# define STATUS_SYSTEM_DEVICE_NOT_FOUND ((NTSTATUS) 0xC0000452L) -#endif - -#ifndef STATUS_RESTART_BOOT_APPLICATION -# define STATUS_RESTART_BOOT_APPLICATION ((NTSTATUS) 0xC0000453L) -#endif - -#ifndef STATUS_INSUFFICIENT_NVRAM_RESOURCES -# define STATUS_INSUFFICIENT_NVRAM_RESOURCES ((NTSTATUS) 0xC0000454L) -#endif - -#ifndef STATUS_INVALID_TASK_NAME -# define STATUS_INVALID_TASK_NAME ((NTSTATUS) 0xC0000500L) -#endif - -#ifndef STATUS_INVALID_TASK_INDEX -# define STATUS_INVALID_TASK_INDEX ((NTSTATUS) 0xC0000501L) -#endif - -#ifndef STATUS_THREAD_ALREADY_IN_TASK -# define STATUS_THREAD_ALREADY_IN_TASK ((NTSTATUS) 0xC0000502L) -#endif - -#ifndef STATUS_CALLBACK_BYPASS -# define STATUS_CALLBACK_BYPASS ((NTSTATUS) 0xC0000503L) -#endif - -#ifndef STATUS_FAIL_FAST_EXCEPTION -# define STATUS_FAIL_FAST_EXCEPTION ((NTSTATUS) 0xC0000602L) -#endif - -#ifndef STATUS_IMAGE_CERT_REVOKED -# define STATUS_IMAGE_CERT_REVOKED ((NTSTATUS) 0xC0000603L) -#endif - -#ifndef STATUS_PORT_CLOSED -# define STATUS_PORT_CLOSED ((NTSTATUS) 0xC0000700L) -#endif - -#ifndef STATUS_MESSAGE_LOST -# define STATUS_MESSAGE_LOST ((NTSTATUS) 0xC0000701L) -#endif - -#ifndef STATUS_INVALID_MESSAGE -# define STATUS_INVALID_MESSAGE ((NTSTATUS) 0xC0000702L) -#endif - -#ifndef STATUS_REQUEST_CANCELED -# define STATUS_REQUEST_CANCELED ((NTSTATUS) 0xC0000703L) -#endif - -#ifndef STATUS_RECURSIVE_DISPATCH -# define STATUS_RECURSIVE_DISPATCH ((NTSTATUS) 0xC0000704L) -#endif - -#ifndef STATUS_LPC_RECEIVE_BUFFER_EXPECTED -# define STATUS_LPC_RECEIVE_BUFFER_EXPECTED ((NTSTATUS) 0xC0000705L) -#endif - -#ifndef STATUS_LPC_INVALID_CONNECTION_USAGE -# define STATUS_LPC_INVALID_CONNECTION_USAGE ((NTSTATUS) 0xC0000706L) -#endif - -#ifndef STATUS_LPC_REQUESTS_NOT_ALLOWED -# define STATUS_LPC_REQUESTS_NOT_ALLOWED ((NTSTATUS) 0xC0000707L) -#endif - -#ifndef STATUS_RESOURCE_IN_USE -# define STATUS_RESOURCE_IN_USE ((NTSTATUS) 0xC0000708L) -#endif - -#ifndef STATUS_HARDWARE_MEMORY_ERROR -# define STATUS_HARDWARE_MEMORY_ERROR ((NTSTATUS) 0xC0000709L) -#endif - -#ifndef STATUS_THREADPOOL_HANDLE_EXCEPTION -# define STATUS_THREADPOOL_HANDLE_EXCEPTION ((NTSTATUS) 0xC000070AL) -#endif - -#ifndef STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070BL) -#endif - -#ifndef STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070CL) -#endif - -#ifndef STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070DL) -#endif - -#ifndef STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED -# define STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070EL) -#endif - -#ifndef STATUS_THREADPOOL_RELEASED_DURING_OPERATION -# define STATUS_THREADPOOL_RELEASED_DURING_OPERATION ((NTSTATUS) 0xC000070FL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING -# define STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING ((NTSTATUS) 0xC0000710L) -#endif - -#ifndef STATUS_APC_RETURNED_WHILE_IMPERSONATING -# define STATUS_APC_RETURNED_WHILE_IMPERSONATING ((NTSTATUS) 0xC0000711L) -#endif - -#ifndef STATUS_PROCESS_IS_PROTECTED -# define STATUS_PROCESS_IS_PROTECTED ((NTSTATUS) 0xC0000712L) -#endif - -#ifndef STATUS_MCA_EXCEPTION -# define STATUS_MCA_EXCEPTION ((NTSTATUS) 0xC0000713L) -#endif - -#ifndef STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE -# define STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE ((NTSTATUS) 0xC0000714L) -#endif - -#ifndef STATUS_SYMLINK_CLASS_DISABLED -# define STATUS_SYMLINK_CLASS_DISABLED ((NTSTATUS) 0xC0000715L) -#endif - -#ifndef STATUS_INVALID_IDN_NORMALIZATION -# define STATUS_INVALID_IDN_NORMALIZATION ((NTSTATUS) 0xC0000716L) -#endif - -#ifndef STATUS_NO_UNICODE_TRANSLATION -# define STATUS_NO_UNICODE_TRANSLATION ((NTSTATUS) 0xC0000717L) -#endif - -#ifndef STATUS_ALREADY_REGISTERED -# define STATUS_ALREADY_REGISTERED ((NTSTATUS) 0xC0000718L) -#endif - -#ifndef STATUS_CONTEXT_MISMATCH -# define STATUS_CONTEXT_MISMATCH ((NTSTATUS) 0xC0000719L) -#endif - -#ifndef STATUS_PORT_ALREADY_HAS_COMPLETION_LIST -# define STATUS_PORT_ALREADY_HAS_COMPLETION_LIST ((NTSTATUS) 0xC000071AL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_THREAD_PRIORITY -# define STATUS_CALLBACK_RETURNED_THREAD_PRIORITY ((NTSTATUS) 0xC000071BL) -#endif - -#ifndef STATUS_INVALID_THREAD -# define STATUS_INVALID_THREAD ((NTSTATUS) 0xC000071CL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_TRANSACTION -# define STATUS_CALLBACK_RETURNED_TRANSACTION ((NTSTATUS) 0xC000071DL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_LDR_LOCK -# define STATUS_CALLBACK_RETURNED_LDR_LOCK ((NTSTATUS) 0xC000071EL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_LANG -# define STATUS_CALLBACK_RETURNED_LANG ((NTSTATUS) 0xC000071FL) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_PRI_BACK -# define STATUS_CALLBACK_RETURNED_PRI_BACK ((NTSTATUS) 0xC0000720L) -#endif - -#ifndef STATUS_CALLBACK_RETURNED_THREAD_AFFINITY -# define STATUS_CALLBACK_RETURNED_THREAD_AFFINITY ((NTSTATUS) 0xC0000721L) -#endif - -#ifndef STATUS_DISK_REPAIR_DISABLED -# define STATUS_DISK_REPAIR_DISABLED ((NTSTATUS) 0xC0000800L) -#endif - -#ifndef STATUS_DS_DOMAIN_RENAME_IN_PROGRESS -# define STATUS_DS_DOMAIN_RENAME_IN_PROGRESS ((NTSTATUS) 0xC0000801L) -#endif - -#ifndef STATUS_DISK_QUOTA_EXCEEDED -# define STATUS_DISK_QUOTA_EXCEEDED ((NTSTATUS) 0xC0000802L) -#endif - -#ifndef STATUS_DATA_LOST_REPAIR -# define STATUS_DATA_LOST_REPAIR ((NTSTATUS) 0x80000803L) -#endif - -#ifndef STATUS_CONTENT_BLOCKED -# define STATUS_CONTENT_BLOCKED ((NTSTATUS) 0xC0000804L) -#endif - -#ifndef STATUS_BAD_CLUSTERS -# define STATUS_BAD_CLUSTERS ((NTSTATUS) 0xC0000805L) -#endif - -#ifndef STATUS_VOLUME_DIRTY -# define STATUS_VOLUME_DIRTY ((NTSTATUS) 0xC0000806L) -#endif - -#ifndef STATUS_FILE_CHECKED_OUT -# define STATUS_FILE_CHECKED_OUT ((NTSTATUS) 0xC0000901L) -#endif - -#ifndef STATUS_CHECKOUT_REQUIRED -# define STATUS_CHECKOUT_REQUIRED ((NTSTATUS) 0xC0000902L) -#endif - -#ifndef STATUS_BAD_FILE_TYPE -# define STATUS_BAD_FILE_TYPE ((NTSTATUS) 0xC0000903L) -#endif - -#ifndef STATUS_FILE_TOO_LARGE -# define STATUS_FILE_TOO_LARGE ((NTSTATUS) 0xC0000904L) -#endif - -#ifndef STATUS_FORMS_AUTH_REQUIRED -# define STATUS_FORMS_AUTH_REQUIRED ((NTSTATUS) 0xC0000905L) -#endif - -#ifndef STATUS_VIRUS_INFECTED -# define STATUS_VIRUS_INFECTED ((NTSTATUS) 0xC0000906L) -#endif - -#ifndef STATUS_VIRUS_DELETED -# define STATUS_VIRUS_DELETED ((NTSTATUS) 0xC0000907L) -#endif - -#ifndef STATUS_BAD_MCFG_TABLE -# define STATUS_BAD_MCFG_TABLE ((NTSTATUS) 0xC0000908L) -#endif - -#ifndef STATUS_CANNOT_BREAK_OPLOCK -# define STATUS_CANNOT_BREAK_OPLOCK ((NTSTATUS) 0xC0000909L) -#endif - -#ifndef STATUS_WOW_ASSERTION -# define STATUS_WOW_ASSERTION ((NTSTATUS) 0xC0009898L) -#endif - -#ifndef STATUS_INVALID_SIGNATURE -# define STATUS_INVALID_SIGNATURE ((NTSTATUS) 0xC000A000L) -#endif - -#ifndef STATUS_HMAC_NOT_SUPPORTED -# define STATUS_HMAC_NOT_SUPPORTED ((NTSTATUS) 0xC000A001L) -#endif - -#ifndef STATUS_AUTH_TAG_MISMATCH -# define STATUS_AUTH_TAG_MISMATCH ((NTSTATUS) 0xC000A002L) -#endif - -#ifndef STATUS_IPSEC_QUEUE_OVERFLOW -# define STATUS_IPSEC_QUEUE_OVERFLOW ((NTSTATUS) 0xC000A010L) -#endif - -#ifndef STATUS_ND_QUEUE_OVERFLOW -# define STATUS_ND_QUEUE_OVERFLOW ((NTSTATUS) 0xC000A011L) -#endif - -#ifndef STATUS_HOPLIMIT_EXCEEDED -# define STATUS_HOPLIMIT_EXCEEDED ((NTSTATUS) 0xC000A012L) -#endif - -#ifndef STATUS_PROTOCOL_NOT_SUPPORTED -# define STATUS_PROTOCOL_NOT_SUPPORTED ((NTSTATUS) 0xC000A013L) -#endif - -#ifndef STATUS_FASTPATH_REJECTED -# define STATUS_FASTPATH_REJECTED ((NTSTATUS) 0xC000A014L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED -# define STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED ((NTSTATUS) 0xC000A080L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR -# define STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR ((NTSTATUS) 0xC000A081L) -#endif - -#ifndef STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR -# define STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR ((NTSTATUS) 0xC000A082L) -#endif - -#ifndef STATUS_XML_PARSE_ERROR -# define STATUS_XML_PARSE_ERROR ((NTSTATUS) 0xC000A083L) -#endif - -#ifndef STATUS_XMLDSIG_ERROR -# define STATUS_XMLDSIG_ERROR ((NTSTATUS) 0xC000A084L) -#endif - -#ifndef STATUS_WRONG_COMPARTMENT -# define STATUS_WRONG_COMPARTMENT ((NTSTATUS) 0xC000A085L) -#endif - -#ifndef STATUS_AUTHIP_FAILURE -# define STATUS_AUTHIP_FAILURE ((NTSTATUS) 0xC000A086L) -#endif - -#ifndef STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS -# define STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS ((NTSTATUS) 0xC000A087L) -#endif - -#ifndef STATUS_DS_OID_NOT_FOUND -# define STATUS_DS_OID_NOT_FOUND ((NTSTATUS) 0xC000A088L) -#endif - -#ifndef STATUS_HASH_NOT_SUPPORTED -# define STATUS_HASH_NOT_SUPPORTED ((NTSTATUS) 0xC000A100L) -#endif - -#ifndef STATUS_HASH_NOT_PRESENT -# define STATUS_HASH_NOT_PRESENT ((NTSTATUS) 0xC000A101L) -#endif - -/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the */ -/* DDK got it wrong! */ -#ifdef NTSTATUS_FROM_WIN32 -# undef NTSTATUS_FROM_WIN32 -#endif -#define NTSTATUS_FROM_WIN32(error) ((NTSTATUS) (error) <= 0 ? \ - ((NTSTATUS) (error)) : ((NTSTATUS) (((error) & 0x0000FFFF) | \ - (FACILITY_NTWIN32 << 16) | ERROR_SEVERITY_WARNING))) - -#ifndef JOB_OBJECT_LIMIT_PROCESS_MEMORY -# define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100 -#endif -#ifndef JOB_OBJECT_LIMIT_JOB_MEMORY -# define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200 -#endif -#ifndef JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION -# define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400 -#endif -#ifndef JOB_OBJECT_LIMIT_BREAKAWAY_OK -# define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800 -#endif -#ifndef JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK -# define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000 -#endif -#ifndef JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE -# define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000 -#endif - -/* from winternl.h */ -typedef struct _UNICODE_STRING { - USHORT Length; - USHORT MaximumLength; - PWSTR Buffer; -} UNICODE_STRING, *PUNICODE_STRING; - -typedef const UNICODE_STRING *PCUNICODE_STRING; - -/* from ntifs.h */ -#ifndef DEVICE_TYPE -# define DEVICE_TYPE DWORD -#endif - -/* MinGW already has a definition for REPARSE_DATA_BUFFER, but mingw-w64 does - * not. - */ -#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR) - typedef struct _REPARSE_DATA_BUFFER { - ULONG ReparseTag; - USHORT ReparseDataLength; - USHORT Reserved; - union { - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - ULONG Flags; - WCHAR PathBuffer[1]; - } SymbolicLinkReparseBuffer; - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - WCHAR PathBuffer[1]; - } MountPointReparseBuffer; - struct { - UCHAR DataBuffer[1]; - } GenericReparseBuffer; - }; - } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; -#endif - -typedef struct _IO_STATUS_BLOCK { - union { - NTSTATUS Status; - PVOID Pointer; - }; - ULONG_PTR Information; -} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; - -typedef enum _FILE_INFORMATION_CLASS { - FileDirectoryInformation = 1, - FileFullDirectoryInformation, - FileBothDirectoryInformation, - FileBasicInformation, - FileStandardInformation, - FileInternalInformation, - FileEaInformation, - FileAccessInformation, - FileNameInformation, - FileRenameInformation, - FileLinkInformation, - FileNamesInformation, - FileDispositionInformation, - FilePositionInformation, - FileFullEaInformation, - FileModeInformation, - FileAlignmentInformation, - FileAllInformation, - FileAllocationInformation, - FileEndOfFileInformation, - FileAlternateNameInformation, - FileStreamInformation, - FilePipeInformation, - FilePipeLocalInformation, - FilePipeRemoteInformation, - FileMailslotQueryInformation, - FileMailslotSetInformation, - FileCompressionInformation, - FileObjectIdInformation, - FileCompletionInformation, - FileMoveClusterInformation, - FileQuotaInformation, - FileReparsePointInformation, - FileNetworkOpenInformation, - FileAttributeTagInformation, - FileTrackingInformation, - FileIdBothDirectoryInformation, - FileIdFullDirectoryInformation, - FileValidDataLengthInformation, - FileShortNameInformation, - FileIoCompletionNotificationInformation, - FileIoStatusBlockRangeInformation, - FileIoPriorityHintInformation, - FileSfioReserveInformation, - FileSfioVolumeInformation, - FileHardLinkInformation, - FileProcessIdsUsingFileInformation, - FileNormalizedNameInformation, - FileNetworkPhysicalNameInformation, - FileIdGlobalTxDirectoryInformation, - FileIsRemoteDeviceInformation, - FileAttributeCacheInformation, - FileNumaNodeInformation, - FileStandardLinkInformation, - FileRemoteProtocolInformation, - FileMaximumInformation -} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; - -typedef struct _FILE_DIRECTORY_INFORMATION { - ULONG NextEntryOffset; - ULONG FileIndex; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION; - -typedef struct _FILE_BOTH_DIR_INFORMATION { - ULONG NextEntryOffset; - ULONG FileIndex; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - ULONG EaSize; - CCHAR ShortNameLength; - WCHAR ShortName[12]; - WCHAR FileName[1]; -} FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION; - -typedef struct _FILE_BASIC_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - DWORD FileAttributes; -} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; - -typedef struct _FILE_STANDARD_INFORMATION { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG NumberOfLinks; - BOOLEAN DeletePending; - BOOLEAN Directory; -} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; - -typedef struct _FILE_INTERNAL_INFORMATION { - LARGE_INTEGER IndexNumber; -} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION; - -typedef struct _FILE_EA_INFORMATION { - ULONG EaSize; -} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION; - -typedef struct _FILE_ACCESS_INFORMATION { - ACCESS_MASK AccessFlags; -} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION; - -typedef struct _FILE_POSITION_INFORMATION { - LARGE_INTEGER CurrentByteOffset; -} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; - -typedef struct _FILE_MODE_INFORMATION { - ULONG Mode; -} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION; - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; - -typedef struct _FILE_END_OF_FILE_INFORMATION { - LARGE_INTEGER EndOfFile; -} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; - -typedef struct _FILE_ALL_INFORMATION { - FILE_BASIC_INFORMATION BasicInformation; - FILE_STANDARD_INFORMATION StandardInformation; - FILE_INTERNAL_INFORMATION InternalInformation; - FILE_EA_INFORMATION EaInformation; - FILE_ACCESS_INFORMATION AccessInformation; - FILE_POSITION_INFORMATION PositionInformation; - FILE_MODE_INFORMATION ModeInformation; - FILE_ALIGNMENT_INFORMATION AlignmentInformation; - FILE_NAME_INFORMATION NameInformation; -} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION; - -typedef struct _FILE_DISPOSITION_INFORMATION { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; - -typedef struct _FILE_PIPE_LOCAL_INFORMATION { - ULONG NamedPipeType; - ULONG NamedPipeConfiguration; - ULONG MaximumInstances; - ULONG CurrentInstances; - ULONG InboundQuota; - ULONG ReadDataAvailable; - ULONG OutboundQuota; - ULONG WriteQuotaAvailable; - ULONG NamedPipeState; - ULONG NamedPipeEnd; -} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; - -#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 -#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 - -typedef enum _FS_INFORMATION_CLASS { - FileFsVolumeInformation = 1, - FileFsLabelInformation = 2, - FileFsSizeInformation = 3, - FileFsDeviceInformation = 4, - FileFsAttributeInformation = 5, - FileFsControlInformation = 6, - FileFsFullSizeInformation = 7, - FileFsObjectIdInformation = 8, - FileFsDriverPathInformation = 9, - FileFsVolumeFlagsInformation = 10, - FileFsSectorSizeInformation = 11 -} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; - -typedef struct _FILE_FS_VOLUME_INFORMATION { - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - BOOLEAN SupportsObjects; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_LABEL_INFORMATION { - ULONG VolumeLabelLength; - WCHAR VolumeLabel[1]; -} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; - -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; -} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; - -typedef struct _FILE_FS_ATTRIBUTE_INFORMATION { - ULONG FileSystemAttributes; - LONG MaximumComponentNameLength; - ULONG FileSystemNameLength; - WCHAR FileSystemName[1]; -} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; - -typedef struct _FILE_FS_CONTROL_INFORMATION { - LARGE_INTEGER FreeSpaceStartFiltering; - LARGE_INTEGER FreeSpaceThreshold; - LARGE_INTEGER FreeSpaceStopFiltering; - LARGE_INTEGER DefaultQuotaThreshold; - LARGE_INTEGER DefaultQuotaLimit; - ULONG FileSystemControlFlags; -} FILE_FS_CONTROL_INFORMATION, *PFILE_FS_CONTROL_INFORMATION; - -typedef struct _FILE_FS_FULL_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER CallerAvailableAllocationUnits; - LARGE_INTEGER ActualAvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_OBJECTID_INFORMATION { - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; - -typedef struct _FILE_FS_DRIVER_PATH_INFORMATION { - BOOLEAN DriverInPath; - ULONG DriverNameLength; - WCHAR DriverName[1]; -} FILE_FS_DRIVER_PATH_INFORMATION, *PFILE_FS_DRIVER_PATH_INFORMATION; - -typedef struct _FILE_FS_VOLUME_FLAGS_INFORMATION { - ULONG Flags; -} FILE_FS_VOLUME_FLAGS_INFORMATION, *PFILE_FS_VOLUME_FLAGS_INFORMATION; - -typedef struct _FILE_FS_SECTOR_SIZE_INFORMATION { - ULONG LogicalBytesPerSector; - ULONG PhysicalBytesPerSectorForAtomicity; - ULONG PhysicalBytesPerSectorForPerformance; - ULONG FileSystemEffectivePhysicalBytesPerSectorForAtomicity; - ULONG Flags; - ULONG ByteOffsetForSectorAlignment; - ULONG ByteOffsetForPartitionAlignment; -} FILE_FS_SECTOR_SIZE_INFORMATION, *PFILE_FS_SECTOR_SIZE_INFORMATION; - -typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION { - LARGE_INTEGER IdleTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER DpcTime; - LARGE_INTEGER InterruptTime; - ULONG InterruptCount; -} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION; - -#ifndef SystemProcessorPerformanceInformation -# define SystemProcessorPerformanceInformation 8 -#endif - -#ifndef FILE_DEVICE_FILE_SYSTEM -# define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#endif - -#ifndef FILE_DEVICE_NETWORK -# define FILE_DEVICE_NETWORK 0x00000012 -#endif - -#ifndef METHOD_BUFFERED -# define METHOD_BUFFERED 0 -#endif - -#ifndef METHOD_IN_DIRECT -# define METHOD_IN_DIRECT 1 -#endif - -#ifndef METHOD_OUT_DIRECT -# define METHOD_OUT_DIRECT 2 -#endif - -#ifndef METHOD_NEITHER -#define METHOD_NEITHER 3 -#endif - -#ifndef METHOD_DIRECT_TO_HARDWARE -# define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT -#endif - -#ifndef METHOD_DIRECT_FROM_HARDWARE -# define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT -#endif - -#ifndef FILE_ANY_ACCESS -# define FILE_ANY_ACCESS 0 -#endif - -#ifndef FILE_SPECIAL_ACCESS -# define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) -#endif - -#ifndef FILE_READ_ACCESS -# define FILE_READ_ACCESS 0x0001 -#endif - -#ifndef FILE_WRITE_ACCESS -# define FILE_WRITE_ACCESS 0x0002 -#endif - -#ifndef CTL_CODE -# define CTL_CODE(device_type, function, method, access) \ - (((device_type) << 16) | ((access) << 14) | ((function) << 2) | (method)) -#endif - -#ifndef FSCTL_SET_REPARSE_POINT -# define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, \ - 41, \ - METHOD_BUFFERED, \ - FILE_SPECIAL_ACCESS) -#endif - -#ifndef FSCTL_GET_REPARSE_POINT -# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, \ - 42, \ - METHOD_BUFFERED, \ - FILE_ANY_ACCESS) -#endif - -#ifndef FSCTL_DELETE_REPARSE_POINT -# define FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, \ - 43, \ - METHOD_BUFFERED, \ - FILE_SPECIAL_ACCESS) -#endif - -#ifndef IO_REPARSE_TAG_SYMLINK -# define IO_REPARSE_TAG_SYMLINK (0xA000000CL) -#endif - -typedef VOID (NTAPI *PIO_APC_ROUTINE) - (PVOID ApcContext, - PIO_STATUS_BLOCK IoStatusBlock, - ULONG Reserved); - -typedef ULONG (NTAPI *sRtlNtStatusToDosError) - (NTSTATUS Status); - -typedef NTSTATUS (NTAPI *sNtDeviceIoControlFile) - (HANDLE FileHandle, - HANDLE Event, - PIO_APC_ROUTINE ApcRoutine, - PVOID ApcContext, - PIO_STATUS_BLOCK IoStatusBlock, - ULONG IoControlCode, - PVOID InputBuffer, - ULONG InputBufferLength, - PVOID OutputBuffer, - ULONG OutputBufferLength); - -typedef NTSTATUS (NTAPI *sNtQueryInformationFile) - (HANDLE FileHandle, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FileInformation, - ULONG Length, - FILE_INFORMATION_CLASS FileInformationClass); - -typedef NTSTATUS (NTAPI *sNtSetInformationFile) - (HANDLE FileHandle, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FileInformation, - ULONG Length, - FILE_INFORMATION_CLASS FileInformationClass); - -typedef NTSTATUS (NTAPI *sNtQueryVolumeInformationFile) - (HANDLE FileHandle, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FsInformation, - ULONG Length, - FS_INFORMATION_CLASS FsInformationClass); - -typedef NTSTATUS (NTAPI *sNtQuerySystemInformation) - (UINT SystemInformationClass, - PVOID SystemInformation, - ULONG SystemInformationLength, - PULONG ReturnLength); - -typedef NTSTATUS (NTAPI *sNtQueryDirectoryFile) - (HANDLE FileHandle, - HANDLE Event, - PIO_APC_ROUTINE ApcRoutine, - PVOID ApcContext, - PIO_STATUS_BLOCK IoStatusBlock, - PVOID FileInformation, - ULONG Length, - FILE_INFORMATION_CLASS FileInformationClass, - BOOLEAN ReturnSingleEntry, - PUNICODE_STRING FileName, - BOOLEAN RestartScan - ); - -/* - * Kernel32 headers - */ -#ifndef FILE_SKIP_COMPLETION_PORT_ON_SUCCESS -# define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 -#endif - -#ifndef FILE_SKIP_SET_EVENT_ON_HANDLE -# define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 -#endif - -#ifndef SYMBOLIC_LINK_FLAG_DIRECTORY -# define SYMBOLIC_LINK_FLAG_DIRECTORY 0x1 -#endif - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) - typedef struct _OVERLAPPED_ENTRY { - ULONG_PTR lpCompletionKey; - LPOVERLAPPED lpOverlapped; - ULONG_PTR Internal; - DWORD dwNumberOfBytesTransferred; - } OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; -#endif - -/* from wincon.h */ -#ifndef ENABLE_INSERT_MODE -# define ENABLE_INSERT_MODE 0x20 -#endif - -#ifndef ENABLE_QUICK_EDIT_MODE -# define ENABLE_QUICK_EDIT_MODE 0x40 -#endif - -#ifndef ENABLE_EXTENDED_FLAGS -# define ENABLE_EXTENDED_FLAGS 0x80 -#endif - -/* from winerror.h */ -#ifndef ERROR_ELEVATION_REQUIRED -# define ERROR_ELEVATION_REQUIRED 740 -#endif - -#ifndef ERROR_SYMLINK_NOT_SUPPORTED -# define ERROR_SYMLINK_NOT_SUPPORTED 1464 -#endif - -#ifndef ERROR_MUI_FILE_NOT_FOUND -# define ERROR_MUI_FILE_NOT_FOUND 15100 -#endif - -#ifndef ERROR_MUI_INVALID_FILE -# define ERROR_MUI_INVALID_FILE 15101 -#endif - -#ifndef ERROR_MUI_INVALID_RC_CONFIG -# define ERROR_MUI_INVALID_RC_CONFIG 15102 -#endif - -#ifndef ERROR_MUI_INVALID_LOCALE_NAME -# define ERROR_MUI_INVALID_LOCALE_NAME 15103 -#endif - -#ifndef ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME -# define ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME 15104 -#endif - -#ifndef ERROR_MUI_FILE_NOT_LOADED -# define ERROR_MUI_FILE_NOT_LOADED 15105 -#endif - -typedef BOOL (WINAPI *sGetQueuedCompletionStatusEx) - (HANDLE CompletionPort, - LPOVERLAPPED_ENTRY lpCompletionPortEntries, - ULONG ulCount, - PULONG ulNumEntriesRemoved, - DWORD dwMilliseconds, - BOOL fAlertable); - -typedef BOOL (WINAPI* sSetFileCompletionNotificationModes) - (HANDLE FileHandle, - UCHAR Flags); - -typedef BOOLEAN (WINAPI* sCreateSymbolicLinkW) - (LPCWSTR lpSymlinkFileName, - LPCWSTR lpTargetFileName, - DWORD dwFlags); - -typedef BOOL (WINAPI* sCancelIoEx) - (HANDLE hFile, - LPOVERLAPPED lpOverlapped); - -typedef VOID (WINAPI* sInitializeConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef BOOL (WINAPI* sSleepConditionVariableCS) - (PCONDITION_VARIABLE ConditionVariable, - PCRITICAL_SECTION CriticalSection, - DWORD dwMilliseconds); - -typedef BOOL (WINAPI* sSleepConditionVariableSRW) - (PCONDITION_VARIABLE ConditionVariable, - PSRWLOCK SRWLock, - DWORD dwMilliseconds, - ULONG Flags); - -typedef VOID (WINAPI* sWakeAllConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef VOID (WINAPI* sWakeConditionVariable) - (PCONDITION_VARIABLE ConditionVariable); - -typedef BOOL (WINAPI* sCancelSynchronousIo) - (HANDLE hThread); - -typedef DWORD (WINAPI* sGetFinalPathNameByHandleW) - (HANDLE hFile, - LPWSTR lpszFilePath, - DWORD cchFilePath, - DWORD dwFlags); - -/* from powerbase.h */ -#ifndef DEVICE_NOTIFY_CALLBACK -# define DEVICE_NOTIFY_CALLBACK 2 -#endif - -#ifndef PBT_APMRESUMEAUTOMATIC -# define PBT_APMRESUMEAUTOMATIC 18 -#endif - -#ifndef PBT_APMRESUMESUSPEND -# define PBT_APMRESUMESUSPEND 7 -#endif - -typedef ULONG CALLBACK _DEVICE_NOTIFY_CALLBACK_ROUTINE( - PVOID Context, - ULONG Type, - PVOID Setting -); -typedef _DEVICE_NOTIFY_CALLBACK_ROUTINE* _PDEVICE_NOTIFY_CALLBACK_ROUTINE; - -typedef struct _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS { - _PDEVICE_NOTIFY_CALLBACK_ROUTINE Callback; - PVOID Context; -} _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS, *_PDEVICE_NOTIFY_SUBSCRIBE_PARAMETERS; - -typedef PVOID _HPOWERNOTIFY; -typedef _HPOWERNOTIFY *_PHPOWERNOTIFY; - -typedef DWORD (WINAPI *sPowerRegisterSuspendResumeNotification) - (DWORD Flags, - HANDLE Recipient, - _PHPOWERNOTIFY RegistrationHandle); - - -/* Ntdll function pointers */ -extern sRtlNtStatusToDosError pRtlNtStatusToDosError; -extern sNtDeviceIoControlFile pNtDeviceIoControlFile; -extern sNtQueryInformationFile pNtQueryInformationFile; -extern sNtSetInformationFile pNtSetInformationFile; -extern sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; -extern sNtQueryDirectoryFile pNtQueryDirectoryFile; -extern sNtQuerySystemInformation pNtQuerySystemInformation; - - -/* Kernel32 function pointers */ -extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; -extern sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; -extern sCreateSymbolicLinkW pCreateSymbolicLinkW; -extern sCancelIoEx pCancelIoEx; -extern sInitializeConditionVariable pInitializeConditionVariable; -extern sSleepConditionVariableCS pSleepConditionVariableCS; -extern sSleepConditionVariableSRW pSleepConditionVariableSRW; -extern sWakeAllConditionVariable pWakeAllConditionVariable; -extern sWakeConditionVariable pWakeConditionVariable; -extern sCancelSynchronousIo pCancelSynchronousIo; -extern sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; - - -/* Powrprof.dll function pointer */ -extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; - -#endif /* UV_WIN_WINAPI_H_ */ diff --git a/lib/ESPiLight/pilight/libs/libuv/win/winsock.c b/lib/ESPiLight/pilight/libs/libuv/win/winsock.c deleted file mode 100644 index e86d76b..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/winsock.c +++ /dev/null @@ -1,561 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include - -#include "uv.h" -#include "internal.h" - - -/* Whether there are any non-IFS LSPs stacked on TCP */ -int uv_tcp_non_ifs_lsp_ipv4; -int uv_tcp_non_ifs_lsp_ipv6; - -/* Ip address used to bind to any port at any interface */ -struct sockaddr_in uv_addr_ip4_any_; -struct sockaddr_in6 uv_addr_ip6_any_; - - -/* - * Retrieves the pointer to a winsock extension function. - */ -static BOOL uv_get_extension_function(SOCKET socket, GUID guid, - void **target) { - int result; - DWORD bytes; - - result = WSAIoctl(socket, - SIO_GET_EXTENSION_FUNCTION_POINTER, - &guid, - sizeof(guid), - (void*)target, - sizeof(*target), - &bytes, - NULL, - NULL); - - if (result == SOCKET_ERROR) { - *target = NULL; - return FALSE; - } else { - return TRUE; - } -} - - -BOOL uv_get_acceptex_function(SOCKET socket, LPFN_ACCEPTEX* target) { - const GUID wsaid_acceptex = WSAID_ACCEPTEX; - return uv_get_extension_function(socket, wsaid_acceptex, (void**)target); -} - - -BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target) { - const GUID wsaid_connectex = WSAID_CONNECTEX; - return uv_get_extension_function(socket, wsaid_connectex, (void**)target); -} - - -static int error_means_no_support(DWORD error) { - return error == WSAEPROTONOSUPPORT || error == WSAESOCKTNOSUPPORT || - error == WSAEPFNOSUPPORT || error == WSAEAFNOSUPPORT; -} - - -void uv_winsock_init(void) { - WSADATA wsa_data; - int errorno; - SOCKET dummy; - WSAPROTOCOL_INFOW protocol_info; - int opt_len; - - /* Initialize winsock */ - errorno = WSAStartup(MAKEWORD(2, 2), &wsa_data); - if (errorno != 0) { - uv_fatal_error(errorno, "WSAStartup"); - } - - /* Set implicit binding address used by connectEx */ - if (uv_ip4_addr("0.0.0.0", 0, &uv_addr_ip4_any_)) { - abort(); - } - - if (uv_ip6_addr("::", 0, &uv_addr_ip6_any_)) { - abort(); - } - - /* Detect non-IFS LSPs */ - dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); - - if (dummy != INVALID_SOCKET) { - opt_len = (int) sizeof protocol_info; - if (getsockopt(dummy, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "getsockopt"); - - if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) - uv_tcp_non_ifs_lsp_ipv4 = 1; - - if (closesocket(dummy) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "closesocket"); - - } else if (!error_means_no_support(WSAGetLastError())) { - /* Any error other than "socket type not supported" is fatal. */ - uv_fatal_error(WSAGetLastError(), "socket"); - } - - /* Detect IPV6 support and non-IFS LSPs */ - dummy = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); - - if (dummy != INVALID_SOCKET) { - opt_len = (int) sizeof protocol_info; - if (getsockopt(dummy, - SOL_SOCKET, - SO_PROTOCOL_INFOW, - (char*) &protocol_info, - &opt_len) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "getsockopt"); - - if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) - uv_tcp_non_ifs_lsp_ipv6 = 1; - - if (closesocket(dummy) == SOCKET_ERROR) - uv_fatal_error(WSAGetLastError(), "closesocket"); - - } else if (!error_means_no_support(WSAGetLastError())) { - /* Any error other than "socket type not supported" is fatal. */ - uv_fatal_error(WSAGetLastError(), "socket"); - } -} - - -int uv_ntstatus_to_winsock_error(NTSTATUS status) { - switch (status) { - case STATUS_SUCCESS: - return ERROR_SUCCESS; - - case STATUS_PENDING: - return ERROR_IO_PENDING; - - case STATUS_INVALID_HANDLE: - case STATUS_OBJECT_TYPE_MISMATCH: - return WSAENOTSOCK; - - case STATUS_INSUFFICIENT_RESOURCES: - case STATUS_PAGEFILE_QUOTA: - case STATUS_COMMITMENT_LIMIT: - case STATUS_WORKING_SET_QUOTA: - case STATUS_NO_MEMORY: - case STATUS_QUOTA_EXCEEDED: - case STATUS_TOO_MANY_PAGING_FILES: - case STATUS_REMOTE_RESOURCES: - return WSAENOBUFS; - - case STATUS_TOO_MANY_ADDRESSES: - case STATUS_SHARING_VIOLATION: - case STATUS_ADDRESS_ALREADY_EXISTS: - return WSAEADDRINUSE; - - case STATUS_LINK_TIMEOUT: - case STATUS_IO_TIMEOUT: - case STATUS_TIMEOUT: - return WSAETIMEDOUT; - - case STATUS_GRACEFUL_DISCONNECT: - return WSAEDISCON; - - case STATUS_REMOTE_DISCONNECT: - case STATUS_CONNECTION_RESET: - case STATUS_LINK_FAILED: - case STATUS_CONNECTION_DISCONNECTED: - case STATUS_PORT_UNREACHABLE: - case STATUS_HOPLIMIT_EXCEEDED: - return WSAECONNRESET; - - case STATUS_LOCAL_DISCONNECT: - case STATUS_TRANSACTION_ABORTED: - case STATUS_CONNECTION_ABORTED: - return WSAECONNABORTED; - - case STATUS_BAD_NETWORK_PATH: - case STATUS_NETWORK_UNREACHABLE: - case STATUS_PROTOCOL_UNREACHABLE: - return WSAENETUNREACH; - - case STATUS_HOST_UNREACHABLE: - return WSAEHOSTUNREACH; - - case STATUS_CANCELLED: - case STATUS_REQUEST_ABORTED: - return WSAEINTR; - - case STATUS_BUFFER_OVERFLOW: - case STATUS_INVALID_BUFFER_SIZE: - return WSAEMSGSIZE; - - case STATUS_BUFFER_TOO_SMALL: - case STATUS_ACCESS_VIOLATION: - return WSAEFAULT; - - case STATUS_DEVICE_NOT_READY: - case STATUS_REQUEST_NOT_ACCEPTED: - return WSAEWOULDBLOCK; - - case STATUS_INVALID_NETWORK_RESPONSE: - case STATUS_NETWORK_BUSY: - case STATUS_NO_SUCH_DEVICE: - case STATUS_NO_SUCH_FILE: - case STATUS_OBJECT_PATH_NOT_FOUND: - case STATUS_OBJECT_NAME_NOT_FOUND: - case STATUS_UNEXPECTED_NETWORK_ERROR: - return WSAENETDOWN; - - case STATUS_INVALID_CONNECTION: - return WSAENOTCONN; - - case STATUS_REMOTE_NOT_LISTENING: - case STATUS_CONNECTION_REFUSED: - return WSAECONNREFUSED; - - case STATUS_PIPE_DISCONNECTED: - return WSAESHUTDOWN; - - case STATUS_CONFLICTING_ADDRESSES: - case STATUS_INVALID_ADDRESS: - case STATUS_INVALID_ADDRESS_COMPONENT: - return WSAEADDRNOTAVAIL; - - case STATUS_NOT_SUPPORTED: - case STATUS_NOT_IMPLEMENTED: - return WSAEOPNOTSUPP; - - case STATUS_ACCESS_DENIED: - return WSAEACCES; - - default: - if ((status & (FACILITY_NTWIN32 << 16)) == (FACILITY_NTWIN32 << 16) && - (status & (ERROR_SEVERITY_ERROR | ERROR_SEVERITY_WARNING))) { - /* It's a windows error that has been previously mapped to an */ - /* ntstatus code. */ - return (DWORD) (status & 0xffff); - } else { - /* The default fallback for unmappable ntstatus codes. */ - return WSAEINVAL; - } - } -} - - -/* - * This function provides a workaround for a bug in the winsock implementation - * of WSARecv. The problem is that when SetFileCompletionNotificationModes is - * used to avoid IOCP notifications of completed reads, WSARecv does not - * reliably indicate whether we can expect a completion package to be posted - * when the receive buffer is smaller than the received datagram. - * - * However it is desirable to use SetFileCompletionNotificationModes because - * it yields a massive performance increase. - * - * This function provides a workaround for that bug, but it only works for the - * specific case that we need it for. E.g. it assumes that the "avoid iocp" - * bit has been set, and supports only overlapped operation. It also requires - * the user to use the default msafd driver, doesn't work when other LSPs are - * stacked on top of it. - */ -int WSAAPI uv_wsarecv_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine) { - NTSTATUS status; - void* apc_context; - IO_STATUS_BLOCK* iosb = (IO_STATUS_BLOCK*) &overlapped->Internal; - AFD_RECV_INFO info; - DWORD error; - - if (overlapped == NULL || completion_routine != NULL) { - WSASetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - - info.BufferArray = buffers; - info.BufferCount = buffer_count; - info.AfdFlags = AFD_OVERLAPPED; - info.TdiFlags = TDI_RECEIVE_NORMAL; - - if (*flags & MSG_PEEK) { - info.TdiFlags |= TDI_RECEIVE_PEEK; - } - - if (*flags & MSG_PARTIAL) { - info.TdiFlags |= TDI_RECEIVE_PARTIAL; - } - - if (!((intptr_t) overlapped->hEvent & 1)) { - apc_context = (void*) overlapped; - } else { - apc_context = NULL; - } - - iosb->Status = STATUS_PENDING; - iosb->Pointer = 0; - - status = pNtDeviceIoControlFile((HANDLE) socket, - overlapped->hEvent, - NULL, - apc_context, - iosb, - IOCTL_AFD_RECEIVE, - &info, - sizeof(info), - NULL, - 0); - - *flags = 0; - *bytes = (DWORD) iosb->Information; - - switch (status) { - case STATUS_SUCCESS: - error = ERROR_SUCCESS; - break; - - case STATUS_PENDING: - error = WSA_IO_PENDING; - break; - - case STATUS_BUFFER_OVERFLOW: - error = WSAEMSGSIZE; - break; - - case STATUS_RECEIVE_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL | MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL; - break; - - default: - error = uv_ntstatus_to_winsock_error(status); - break; - } - - WSASetLastError(error); - - if (error == ERROR_SUCCESS) { - return 0; - } else { - return SOCKET_ERROR; - } -} - - -/* See description of uv_wsarecv_workaround. */ -int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers, - DWORD buffer_count, DWORD* bytes, DWORD* flags, struct sockaddr* addr, - int* addr_len, WSAOVERLAPPED *overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine) { - NTSTATUS status; - void* apc_context; - IO_STATUS_BLOCK* iosb = (IO_STATUS_BLOCK*) &overlapped->Internal; - AFD_RECV_DATAGRAM_INFO info; - DWORD error; - - if (overlapped == NULL || addr == NULL || addr_len == NULL || - completion_routine != NULL) { - WSASetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - - info.BufferArray = buffers; - info.BufferCount = buffer_count; - info.AfdFlags = AFD_OVERLAPPED; - info.TdiFlags = TDI_RECEIVE_NORMAL; - info.Address = addr; - info.AddressLength = addr_len; - - if (*flags & MSG_PEEK) { - info.TdiFlags |= TDI_RECEIVE_PEEK; - } - - if (*flags & MSG_PARTIAL) { - info.TdiFlags |= TDI_RECEIVE_PARTIAL; - } - - if (!((intptr_t) overlapped->hEvent & 1)) { - apc_context = (void*) overlapped; - } else { - apc_context = NULL; - } - - iosb->Status = STATUS_PENDING; - iosb->Pointer = 0; - - status = pNtDeviceIoControlFile((HANDLE) socket, - overlapped->hEvent, - NULL, - apc_context, - iosb, - IOCTL_AFD_RECEIVE_DATAGRAM, - &info, - sizeof(info), - NULL, - 0); - - *flags = 0; - *bytes = (DWORD) iosb->Information; - - switch (status) { - case STATUS_SUCCESS: - error = ERROR_SUCCESS; - break; - - case STATUS_PENDING: - error = WSA_IO_PENDING; - break; - - case STATUS_BUFFER_OVERFLOW: - error = WSAEMSGSIZE; - break; - - case STATUS_RECEIVE_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL_EXPEDITED: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL | MSG_OOB; - break; - - case STATUS_RECEIVE_PARTIAL: - error = ERROR_SUCCESS; - *flags = MSG_PARTIAL; - break; - - default: - error = uv_ntstatus_to_winsock_error(status); - break; - } - - WSASetLastError(error); - - if (error == ERROR_SUCCESS) { - return 0; - } else { - return SOCKET_ERROR; - } -} - - -int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in, - AFD_POLL_INFO* info_out, OVERLAPPED* overlapped) { - IO_STATUS_BLOCK iosb; - IO_STATUS_BLOCK* iosb_ptr; - HANDLE event = NULL; - void* apc_context; - NTSTATUS status; - DWORD error; - - if (overlapped != NULL) { - /* Overlapped operation. */ - iosb_ptr = (IO_STATUS_BLOCK*) &overlapped->Internal; - event = overlapped->hEvent; - - /* Do not report iocp completion if hEvent is tagged. */ - if ((uintptr_t) event & 1) { - event = (HANDLE)((uintptr_t) event & ~(uintptr_t) 1); - apc_context = NULL; - } else { - apc_context = overlapped; - } - - } else { - /* Blocking operation. */ - iosb_ptr = &iosb; - event = CreateEvent(NULL, FALSE, FALSE, NULL); - if (event == NULL) { - return SOCKET_ERROR; - } - apc_context = NULL; - } - - iosb_ptr->Status = STATUS_PENDING; - status = pNtDeviceIoControlFile((HANDLE) socket, - event, - NULL, - apc_context, - iosb_ptr, - IOCTL_AFD_POLL, - info_in, - sizeof *info_in, - info_out, - sizeof *info_out); - - if (overlapped == NULL) { - /* If this is a blocking operation, wait for the event to become */ - /* signaled, and then grab the real status from the io status block. */ - if (status == STATUS_PENDING) { - DWORD r = WaitForSingleObject(event, INFINITE); - - if (r == WAIT_FAILED) { - DWORD saved_error = GetLastError(); - CloseHandle(event); - WSASetLastError(saved_error); - return SOCKET_ERROR; - } - - status = iosb.Status; - } - - CloseHandle(event); - } - - switch (status) { - case STATUS_SUCCESS: - error = ERROR_SUCCESS; - break; - - case STATUS_PENDING: - error = WSA_IO_PENDING; - break; - - default: - error = uv_ntstatus_to_winsock_error(status); - break; - } - - WSASetLastError(error); - - if (error == ERROR_SUCCESS) { - return 0; - } else { - return SOCKET_ERROR; - } -} diff --git a/lib/ESPiLight/pilight/libs/libuv/win/winsock.h b/lib/ESPiLight/pilight/libs/libuv/win/winsock.h deleted file mode 100644 index 7c007ab..0000000 --- a/lib/ESPiLight/pilight/libs/libuv/win/winsock.h +++ /dev/null @@ -1,190 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_WINSOCK_H_ -#define UV_WIN_WINSOCK_H_ - -#include -#include -#include -#include -#include - -#include "winapi.h" - - -/* - * MinGW is missing these too - */ -#ifndef SO_UPDATE_CONNECT_CONTEXT -# define SO_UPDATE_CONNECT_CONTEXT 0x7010 -#endif - -#ifndef TCP_KEEPALIVE -# define TCP_KEEPALIVE 3 -#endif - -#ifndef IPV6_V6ONLY -# define IPV6_V6ONLY 27 -#endif - -#ifndef IPV6_HOPLIMIT -# define IPV6_HOPLIMIT 21 -#endif - -#ifndef SIO_BASE_HANDLE -# define SIO_BASE_HANDLE 0x48000022 -#endif - -/* - * TDI defines that are only in the DDK. - * We only need receive flags so far. - */ -#ifndef TDI_RECEIVE_NORMAL - #define TDI_RECEIVE_BROADCAST 0x00000004 - #define TDI_RECEIVE_MULTICAST 0x00000008 - #define TDI_RECEIVE_PARTIAL 0x00000010 - #define TDI_RECEIVE_NORMAL 0x00000020 - #define TDI_RECEIVE_EXPEDITED 0x00000040 - #define TDI_RECEIVE_PEEK 0x00000080 - #define TDI_RECEIVE_NO_RESPONSE_EXP 0x00000100 - #define TDI_RECEIVE_COPY_LOOKAHEAD 0x00000200 - #define TDI_RECEIVE_ENTIRE_MESSAGE 0x00000400 - #define TDI_RECEIVE_AT_DISPATCH_LEVEL 0x00000800 - #define TDI_RECEIVE_CONTROL_INFO 0x00001000 - #define TDI_RECEIVE_FORCE_INDICATION 0x00002000 - #define TDI_RECEIVE_NO_PUSH 0x00004000 -#endif - -/* - * The "Auxiliary Function Driver" is the windows kernel-mode driver that does - * TCP, UDP etc. Winsock is just a layer that dispatches requests to it. - * Having these definitions allows us to bypass winsock and make an AFD kernel - * call directly, avoiding a bug in winsock's recvfrom implementation. - */ - -#define AFD_NO_FAST_IO 0x00000001 -#define AFD_OVERLAPPED 0x00000002 -#define AFD_IMMEDIATE 0x00000004 - -#define AFD_POLL_RECEIVE_BIT 0 -#define AFD_POLL_RECEIVE (1 << AFD_POLL_RECEIVE_BIT) -#define AFD_POLL_RECEIVE_EXPEDITED_BIT 1 -#define AFD_POLL_RECEIVE_EXPEDITED (1 << AFD_POLL_RECEIVE_EXPEDITED_BIT) -#define AFD_POLL_SEND_BIT 2 -#define AFD_POLL_SEND (1 << AFD_POLL_SEND_BIT) -#define AFD_POLL_DISCONNECT_BIT 3 -#define AFD_POLL_DISCONNECT (1 << AFD_POLL_DISCONNECT_BIT) -#define AFD_POLL_ABORT_BIT 4 -#define AFD_POLL_ABORT (1 << AFD_POLL_ABORT_BIT) -#define AFD_POLL_LOCAL_CLOSE_BIT 5 -#define AFD_POLL_LOCAL_CLOSE (1 << AFD_POLL_LOCAL_CLOSE_BIT) -#define AFD_POLL_CONNECT_BIT 6 -#define AFD_POLL_CONNECT (1 << AFD_POLL_CONNECT_BIT) -#define AFD_POLL_ACCEPT_BIT 7 -#define AFD_POLL_ACCEPT (1 << AFD_POLL_ACCEPT_BIT) -#define AFD_POLL_CONNECT_FAIL_BIT 8 -#define AFD_POLL_CONNECT_FAIL (1 << AFD_POLL_CONNECT_FAIL_BIT) -#define AFD_POLL_QOS_BIT 9 -#define AFD_POLL_QOS (1 << AFD_POLL_QOS_BIT) -#define AFD_POLL_GROUP_QOS_BIT 10 -#define AFD_POLL_GROUP_QOS (1 << AFD_POLL_GROUP_QOS_BIT) - -#define AFD_NUM_POLL_EVENTS 11 -#define AFD_POLL_ALL ((1 << AFD_NUM_POLL_EVENTS) - 1) - -typedef struct _AFD_RECV_DATAGRAM_INFO { - LPWSABUF BufferArray; - ULONG BufferCount; - ULONG AfdFlags; - ULONG TdiFlags; - struct sockaddr* Address; - int* AddressLength; -} AFD_RECV_DATAGRAM_INFO, *PAFD_RECV_DATAGRAM_INFO; - -typedef struct _AFD_RECV_INFO { - LPWSABUF BufferArray; - ULONG BufferCount; - ULONG AfdFlags; - ULONG TdiFlags; -} AFD_RECV_INFO, *PAFD_RECV_INFO; - - -#define _AFD_CONTROL_CODE(operation, method) \ - ((FSCTL_AFD_BASE) << 12 | (operation << 2) | method) - -#define FSCTL_AFD_BASE FILE_DEVICE_NETWORK - -#define AFD_RECEIVE 5 -#define AFD_RECEIVE_DATAGRAM 6 -#define AFD_POLL 9 - -#define IOCTL_AFD_RECEIVE \ - _AFD_CONTROL_CODE(AFD_RECEIVE, METHOD_NEITHER) - -#define IOCTL_AFD_RECEIVE_DATAGRAM \ - _AFD_CONTROL_CODE(AFD_RECEIVE_DATAGRAM, METHOD_NEITHER) - -#define IOCTL_AFD_POLL \ - _AFD_CONTROL_CODE(AFD_POLL, METHOD_BUFFERED) - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -typedef struct _IP_ADAPTER_UNICAST_ADDRESS_XP { - /* FIXME: __C89_NAMELESS was removed */ - /* __C89_NAMELESS */ union { - ULONGLONG Alignment; - /* __C89_NAMELESS */ struct { - ULONG Length; - DWORD Flags; - }; - }; - struct _IP_ADAPTER_UNICAST_ADDRESS_XP *Next; - SOCKET_ADDRESS Address; - IP_PREFIX_ORIGIN PrefixOrigin; - IP_SUFFIX_ORIGIN SuffixOrigin; - IP_DAD_STATE DadState; - ULONG ValidLifetime; - ULONG PreferredLifetime; - ULONG LeaseLifetime; -} IP_ADAPTER_UNICAST_ADDRESS_XP,*PIP_ADAPTER_UNICAST_ADDRESS_XP; - -typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH { - union { - ULONGLONG Alignment; - struct { - ULONG Length; - DWORD Flags; - }; - }; - struct _IP_ADAPTER_UNICAST_ADDRESS_LH *Next; - SOCKET_ADDRESS Address; - IP_PREFIX_ORIGIN PrefixOrigin; - IP_SUFFIX_ORIGIN SuffixOrigin; - IP_DAD_STATE DadState; - ULONG ValidLifetime; - ULONG PreferredLifetime; - ULONG LeaseLifetime; - UINT8 OnLinkPrefixLength; -} IP_ADAPTER_UNICAST_ADDRESS_LH,*PIP_ADAPTER_UNICAST_ADDRESS_LH; - -#endif - -#endif /* UV_WIN_WINSOCK_H_ */ diff --git a/lib/ESPiLight/pilight/libs/openzwave/Bitfield.h b/lib/ESPiLight/pilight/libs/openzwave/Bitfield.h deleted file mode 100644 index 7533eb7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Bitfield.h +++ /dev/null @@ -1,162 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Bitfield.h -// -// Variable length bitfield implementation -// -// Copyright (c) 2011 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Bitfield_H -#define _Bitfield_H - -#include -#include "Defs.h" - -namespace OpenZWave -{ - class OPENZWAVE_EXPORT Bitfield - { - friend class Iterator; - - public: - Bitfield():m_numSetBits(0){} - ~Bitfield(){} - - void Set( uint32 _idx ) - { - if( !IsSet(_idx) ) - { - uint32 newSize = (_idx>>5)+1; - if( newSize > m_bits.size() ) - { - m_bits.resize( newSize, 0 ); - } - m_bits[_idx>>5] |= (1<<(_idx&0x1f)); - ++m_numSetBits; - } - } - - void Clear( uint32 _idx ) - { - if( IsSet(_idx) ) - { - m_bits[_idx>>5] &= ~(1<<(_idx&0x1f)); - --m_numSetBits; - } - } - - bool IsSet( uint32 _idx )const - { - if( (_idx>>5) < m_bits.size() ) - { - return( ( m_bits[_idx>>5] & (1<<(_idx&0x1f)) ) !=0 ); - } - return false; - } - - uint32 GetNumSetBits()const{ return m_numSetBits; } - - class Iterator - { - friend class Bitfield; - - public: - uint32 operator *() const - { - return m_idx; - } - - Iterator& operator++() - { - // Search forward to next set bit - NextSetBit(); - return *this; - } - - Iterator operator++(int) - { - Iterator tmp = *this; - ++tmp; - return tmp; - } - - bool operator ==(const Iterator &rhs) - { - return m_idx == rhs.m_idx; - } - - bool operator !=(const Iterator &rhs) - { - return m_idx != rhs.m_idx; - } - - private: - Iterator( Bitfield const* _bitfield, uint32 _idx ): m_idx( _idx ), m_bitfield( _bitfield ) - { - // If this is a begin iterator, move it to the first set bit - if( ( _idx == 0 ) && ( !m_bitfield->IsSet(0) ) ) - { - NextSetBit(); - } - } - - void NextSetBit() - { - while( ((++m_idx)>>5)m_bits.size() ) - { - // See if there are any bits left to find in the current uint32 - if( ( m_bitfield->m_bits[m_idx>>5] & ~((1<<(m_idx&0x1f))-1) ) == 0 ) - { - // No more bits - move on to next uint32 (or rather one less than - // the next uint32 because of the preincrement in the while statement) - m_idx = (m_idx&0xffffffe0)+31; - } - else - { - if( (m_bitfield->m_bits[m_idx>>5] & (1<<(m_idx&0x1f))) !=0 ) - { - // This bit is set - return; - } - } - } - } - - uint32 m_idx; - Bitfield const* m_bitfield; - }; - - Iterator Begin()const{ return Iterator( this, 0 ); } - Iterator End()const{ return Iterator( this, (uint32) m_bits.size()<<5 ); } - - private: -OPENZWAVE_EXPORT_WARNINGS_OFF - vector m_bits; -OPENZWAVE_EXPORT_WARNINGS_ON - uint32 m_numSetBits; - }; -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/CMakeLists.txt b/lib/ESPiLight/pilight/libs/openzwave/CMakeLists.txt deleted file mode 100644 index 5ae1c15..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -project(openzwave) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.cpp") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -add_subdirectory(aes) -add_subdirectory(command_classes) -add_subdirectory(platform) -add_subdirectory(value_classes) - -set(${PROJECT_NAME}_files - ${${PROJECT_NAME}_aes_files} - ${${PROJECT_NAME}_command_classes_files} - ${${PROJECT_NAME}_platform_files} - ${${PROJECT_NAME}_value_classes_files} - ${${PROJECT_NAME}_sources} - ${${PROJECT_NAME}_headers} -CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/openzwave/Defs.h b/lib/ESPiLight/pilight/libs/openzwave/Defs.h deleted file mode 100644 index 0ead487..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Defs.h +++ /dev/null @@ -1,363 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Defs.h -// -// Basic types and preprocessor directives -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Defs_H -#define _Defs_H -#include -#include -#include -#include - - - -// Compilation export flags -#if (defined _WINDOWS || defined WIN32 || defined _WIN32) && !defined MINGW -# if defined OPENZWAVE_MAKEDLL // Create the dynamic library. -# define OPENZWAVE_EXPORT __declspec(dllexport) -# elif defined OPENZWAVE_USEDLL // Use the dynamic library -# define OPENZWAVE_EXPORT __declspec(dllimport) -# else // Create/Use the static library -# define OPENZWAVE_EXPORT -# endif -// Disable export warnings -# define OPENZWAVE_EXPORT -# define OPENZWAVE_EXPORT_WARNINGS_OFF -# define OPENZWAVE_EXPORT_WARNINGS_ON -#else -# define OPENZWAVE_EXPORT -# define OPENZWAVE_EXPORT_WARNINGS_OFF -# define OPENZWAVE_EXPORT_WARNINGS_ON -#endif - -#ifdef NULL -#undef NULL -#endif -#define NULL 0 - -// Basic types -typedef signed char int8; -typedef unsigned char uint8; - -typedef signed short int16; -typedef unsigned short uint16; - -typedef signed int int32; -typedef unsigned int uint32; - -#ifdef _WIN32 -typedef signed __int64 int64; -typedef unsigned __int64 uint64; -#endif - -#ifdef __GNUC__ -typedef signed long long int64; -typedef unsigned long long uint64; -#endif - -typedef float float32; -typedef double float64; - -typedef struct ozwversion { - uint32_t _v; /* major << 16 | minor */ -} ozwversion; - -/** - * \brief version_major - return the major version of the given struct - * \param v: the version number to obtain the major number from - * \return the Major Version Number - */ -static inline uint16_t version_major(struct ozwversion v) { - return (v._v & 0xFFFF0000) >> 16; -} - -/** - * \brief version_minor - return the minor version of the given struct - * \param v: the version number to obtain the minor number from - * \return the Minor Version Number - */ -static inline uint16_t version_minor(const struct ozwversion &v) { - return v._v & 0xFFFF; -} - -/** - * \brief version - create a new version number - * \param major: major version number - * \param minor: minor version number - * \return the Version Number Struct - */ -static inline struct ozwversion version(uint16_t major, uint16_t minor) -{ - struct ozwversion v; - v._v = (uint32_t)(major << 16) | (uint32_t)minor; - return v; -} - -/** - * \brief version_cmp - compare two versions - * \param a: the first version number - * \param b: the second version number - * \return a number greater, equal, or less than 0 if a is greater, equal or - * less than b, respectively - * - * Example: - * struct version a = version(1, 0); - * struct version b = version(1, 3); - * if (version_cmp(a, b) < 0) - * printf("b is smaller than b\n"); - */ -static inline int version_cmp(struct ozwversion a, struct ozwversion b) -{ - return (a._v == b._v) ? 0 : (a._v > b._v) ? 1 : - 1; -} - - -// Declare the OpenZWave namespace -namespace std {} -namespace OpenZWave -{ - // Include the STL namespace - using namespace std; -} - -// Modifications for Microsoft compilers -// #ifdef _WIN32 - -// // Fix for namespace-related compiler bug -// namespace OpenZWave -// { -// } - -// // Rename safe versions of sprintf etc -// #define snprintf sprintf_s -// #define strcasecmp _stricmp -// #define sscanf sscanf_s - -// #endif - -// Modifications for MiNGW32 compiler -#ifdef _WIN32 - -// Replace "safe" versions of sprintf -#define sprintf_s snprintf - -// seems some MINGW versions don't have a errno_t -#ifndef errno_t -#define errno_t int -#endif - -#define fopen_s fopen - - -#endif - -#define MAX_TRIES 3 // Retry sends up to 3 times -#define MAX_MAX_TRIES 7 // Don't exceed this retry limit -#define ACK_TIMEOUT 1000 // How long to wait for an ACK -#define BYTE_TIMEOUT 150 -#define RETRY_TIMEOUT 40000 // Retry send after 40 seconds - -#define SOF 0x01 -#define ACK 0x06 -#define NAK 0x15 -#define CAN 0x18 - -#define NUM_NODE_BITFIELD_BYTES 29 // 29 bytes = 232 bits, one for each possible node in the network. - -#define REQUEST 0x00 -#define RESPONSE 0x01 - -#define ZW_CLOCK_SET 0x30 - -#define TRANSMIT_OPTION_ACK 0x01 -#define TRANSMIT_OPTION_LOW_POWER 0x02 -#define TRANSMIT_OPTION_AUTO_ROUTE 0x04 -#define TRANSMIT_OPTION_NO_ROUTE 0x10 -#define TRANSMIT_OPTION_EXPLORE 0x20 - -#define TRANSMIT_COMPLETE_OK 0x00 -#define TRANSMIT_COMPLETE_NO_ACK 0x01 -#define TRANSMIT_COMPLETE_FAIL 0x02 -#define TRANSMIT_COMPLETE_NOT_IDLE 0x03 -#define TRANSMIT_COMPLETE_NOROUTE 0x04 - -#define RECEIVE_STATUS_ROUTED_BUSY 0x01 -#define RECEIVE_STATUS_TYPE_BROAD 0x04 - -#define FUNC_ID_SERIAL_API_GET_INIT_DATA 0x02 -#define FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION 0x03 -#define FUNC_ID_APPLICATION_COMMAND_HANDLER 0x04 -#define FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES 0x05 -#define FUNC_ID_SERIAL_API_SET_TIMEOUTS 0x06 -#define FUNC_ID_SERIAL_API_GET_CAPABILITIES 0x07 -#define FUNC_ID_SERIAL_API_SOFT_RESET 0x08 - -#define FUNC_ID_ZW_SEND_NODE_INFORMATION 0x12 -#define FUNC_ID_ZW_SEND_DATA 0x13 -#define FUNC_ID_ZW_GET_VERSION 0x15 -#define FUNC_ID_ZW_R_F_POWER_LEVEL_SET 0x17 -#define FUNC_ID_ZW_GET_RANDOM 0x1c -#define FUNC_ID_ZW_MEMORY_GET_ID 0x20 -#define FUNC_ID_MEMORY_GET_BYTE 0x21 -#define FUNC_ID_ZW_READ_MEMORY 0x23 - -#define FUNC_ID_ZW_SET_LEARN_NODE_STATE 0x40 // Not implemented -#define FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO 0x41 // Get protocol info (baud rate, listening, etc.) for a given node -#define FUNC_ID_ZW_SET_DEFAULT 0x42 // Reset controller and node info to default (original) values -#define FUNC_ID_ZW_NEW_CONTROLLER 0x43 // Not implemented -#define FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE 0x44 // Replication send data complete -#define FUNC_ID_ZW_REPLICATION_SEND_DATA 0x45 // Replication send data -#define FUNC_ID_ZW_ASSIGN_RETURN_ROUTE 0x46 // Assign a return route from the specified node to the controller -#define FUNC_ID_ZW_DELETE_RETURN_ROUTE 0x47 // Delete all return routes from the specified node -#define FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE 0x48 // Ask the specified node to update its neighbors (then read them from the controller) -#define FUNC_ID_ZW_APPLICATION_UPDATE 0x49 // Get a list of supported (and controller) command classes -#define FUNC_ID_ZW_ADD_NODE_TO_NETWORK 0x4a // Control the addnode (or addcontroller) process...start, stop, etc. -#define FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK 0x4b // Control the removenode (or removecontroller) process...start, stop, etc. -#define FUNC_ID_ZW_CREATE_NEW_PRIMARY 0x4c // Control the createnewprimary process...start, stop, etc. -#define FUNC_ID_ZW_CONTROLLER_CHANGE 0x4d // Control the transferprimary process...start, stop, etc. -#define FUNC_ID_ZW_SET_LEARN_MODE 0x50 // Put a controller into learn mode for replication/ receipt of configuration info -#define FUNC_ID_ZW_ASSIGN_SUC_RETURN_ROUTE 0x51 // Assign a return route to the SUC -#define FUNC_ID_ZW_ENABLE_SUC 0x52 // Make a controller a Static Update Controller -#define FUNC_ID_ZW_REQUEST_NETWORK_UPDATE 0x53 // Network update for a SUC(?) -#define FUNC_ID_ZW_SET_SUC_NODE_ID 0x54 // Identify a Static Update Controller node id -#define FUNC_ID_ZW_DELETE_SUC_RETURN_ROUTE 0x55 // Remove return routes to the SUC -#define FUNC_ID_ZW_GET_SUC_NODE_ID 0x56 // Try to retrieve a Static Update Controller node id (zero if no SUC present) -#define FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE_OPTIONS 0x5a // Allow options for request node neighbor update -#define FUNC_ID_ZW_REQUEST_NODE_INFO 0x60 // Get info (supported command classes) for the specified node -#define FUNC_ID_ZW_REMOVE_FAILED_NODE_ID 0x61 // Mark a specified node id as failed -#define FUNC_ID_ZW_IS_FAILED_NODE_ID 0x62 // Check to see if a specified node has failed -#define FUNC_ID_ZW_REPLACE_FAILED_NODE 0x63 // Remove a failed node from the controller's list (?) -#define FUNC_ID_ZW_GET_ROUTING_INFO 0x80 // Get a specified node's neighbor information from the controller -#define FUNC_ID_SERIAL_API_SLAVE_NODE_INFO 0xA0 // Set application virtual slave node information -#define FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER 0xA1 // Slave command handler -#define FUNC_ID_ZW_SEND_SLAVE_NODE_INFO 0xA2 // Send a slave node information frame -#define FUNC_ID_ZW_SEND_SLAVE_DATA 0xA3 // Send data from slave -#define FUNC_ID_ZW_SET_SLAVE_LEARN_MODE 0xA4 // Enter slave learn mode -#define FUNC_ID_ZW_GET_VIRTUAL_NODES 0xA5 // Return all virtual nodes -#define FUNC_ID_ZW_IS_VIRTUAL_NODE 0xA6 // Virtual node test -#define FUNC_ID_ZW_SET_PROMISCUOUS_MODE 0xD0 // Set controller into promiscuous mode to listen to all frames -#define FUNC_ID_PROMISCUOUS_APPLICATION_COMMAND_HANDLER 0xD1 - -#define ADD_NODE_ANY 0x01 -#define ADD_NODE_CONTROLLER 0x02 -#define ADD_NODE_SLAVE 0x03 -#define ADD_NODE_EXISTING 0x04 -#define ADD_NODE_STOP 0x05 -#define ADD_NODE_STOP_FAILED 0x06 - -#define ADD_NODE_STATUS_LEARN_READY 0x01 -#define ADD_NODE_STATUS_NODE_FOUND 0x02 -#define ADD_NODE_STATUS_ADDING_SLAVE 0x03 -#define ADD_NODE_STATUS_ADDING_CONTROLLER 0x04 -#define ADD_NODE_STATUS_PROTOCOL_DONE 0x05 -#define ADD_NODE_STATUS_DONE 0x06 -#define ADD_NODE_STATUS_FAILED 0x07 - -#define REMOVE_NODE_ANY 0x01 -#define REMOVE_NODE_CONTROLLER 0x02 -#define REMOVE_NODE_SLAVE 0x03 -#define REMOVE_NODE_STOP 0x05 - -#define REMOVE_NODE_STATUS_LEARN_READY 0x01 -#define REMOVE_NODE_STATUS_NODE_FOUND 0x02 -#define REMOVE_NODE_STATUS_REMOVING_SLAVE 0x03 -#define REMOVE_NODE_STATUS_REMOVING_CONTROLLER 0x04 -#define REMOVE_NODE_STATUS_DONE 0x06 -#define REMOVE_NODE_STATUS_FAILED 0x07 - -#define CREATE_PRIMARY_START 0x02 -#define CREATE_PRIMARY_STOP 0x05 -#define CREATE_PRIMARY_STOP_FAILED 0x06 - -#define CONTROLLER_CHANGE_START 0x02 -#define CONTROLLER_CHANGE_STOP 0x05 -#define CONTROLLER_CHANGE_STOP_FAILED 0x06 - -#define LEARN_MODE_STARTED 0x01 -#define LEARN_MODE_DONE 0x06 -#define LEARN_MODE_FAILED 0x07 -#define LEARN_MODE_DELETED 0x80 - -#define REQUEST_NEIGHBOR_UPDATE_STARTED 0x21 -#define REQUEST_NEIGHBOR_UPDATE_DONE 0x22 -#define REQUEST_NEIGHBOR_UPDATE_FAILED 0x23 - -#define FAILED_NODE_OK 0x00 -#define FAILED_NODE_REMOVED 0x01 -#define FAILED_NODE_NOT_REMOVED 0x02 - -#define FAILED_NODE_REPLACE_WAITING 0x03 -#define FAILED_NODE_REPLACE_DONE 0x04 -#define FAILED_NODE_REPLACE_FAILED 0x05 - -#define FAILED_NODE_REMOVE_STARTED 0x00 -#define FAILED_NODE_NOT_PRIMARY_CONTROLLER 0x02 -#define FAILED_NODE_NO_CALLBACK_FUNCTION 0x04 -#define FAILED_NODE_NOT_FOUND 0x08 -#define FAILED_NODE_REMOVE_PROCESS_BUSY 0x10 -#define FAILED_NODE_REMOVE_FAIL 0x20 - -#define SUC_UPDATE_DONE 0x00 -#define SUC_UPDATE_ABORT 0x01 -#define SUC_UPDATE_WAIT 0x02 -#define SUC_UPDATE_DISABLED 0x03 -#define SUC_UPDATE_OVERFLOW 0x04 - -#define SUC_FUNC_BASIC_SUC 0x00 -#define SUC_FUNC_NODEID_SERVER 0x01 - -#define UPDATE_STATE_NODE_INFO_RECEIVED 0x84 -#define UPDATE_STATE_NODE_INFO_REQ_DONE 0x82 -#define UPDATE_STATE_NODE_INFO_REQ_FAILED 0x81 -#define UPDATE_STATE_ROUTING_PENDING 0x80 -#define UPDATE_STATE_NEW_ID_ASSIGNED 0x40 -#define UPDATE_STATE_DELETE_DONE 0x20 -#define UPDATE_STATE_SUC_ID 0x10 - -#define APPLICATION_NODEINFO_LISTENING 0x01 -#define APPLICATION_NODEINFO_OPTIONAL_FUNCTIONALITY 0x02 - -#define SLAVE_ASSIGN_COMPLETE 0x00 -#define SLAVE_ASSIGN_NODEID_DONE 0x01 // Node ID has been assigned -#define SLAVE_ASSIGN_RANGE_INFO_UPDATE 0x02 // Node is doing neighbor discovery - -#define SLAVE_LEARN_MODE_DISABLE 0x00 // disable add/remove virtual slave nodes -#define SLAVE_LEARN_MODE_ENABLE 0x01 // enable ability to include/exclude virtual slave nodes -#define SLAVE_LEARN_MODE_ADD 0x02 // add node directly but only if primary/inclusion controller -#define SLAVE_LEARN_MODE_REMOVE 0x03 // remove node directly but only if primary/inclusion controller - -#define OPTION_HIGH_POWER 0x80 - -//Device request related -#define BASIC_SET 0x01 -#define BASIC_REPORT 0x03 - -#define COMMAND_CLASS_BASIC 0x20 -#define COMMAND_CLASS_CONTROLLER_REPLICATION 0x21 -#define COMMAND_CLASS_APPLICATION_STATUS 0x22 -#define COMMAND_CLASS_HAIL 0x82 - -#endif // _Defs_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/DoxygenMain.h b/lib/ESPiLight/pilight/libs/openzwave/DoxygenMain.h deleted file mode 100644 index 2268261..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/DoxygenMain.h +++ /dev/null @@ -1,154 +0,0 @@ - -/** - * \mainpage OpenZWave - * \section Introduction Introduction to OpenZWave - * OpenZWave is an open-source, cross-platform library designed to enable - * anyone to add support for Z-Wave home-automation devices to their - * applications, without requiring any in depth knowledge of the Z-Wave - * protocol. - *

- * Z-Wave employs a proprietary protocol which the owners, Sigma Designs, - * have chosen not to release into the public domain. There is also no - * official free or low-cost SDK that can be used to develop applications - * (The ControlThink SDK is now tied exclusively to their own Z-Wave PC - * interface). The only way to obtain the protocol documentation and sample - * code is to purchase an expensive development kit, and sign a non-disclosure - * agreement (NDA) preventing the release of that knowledge. - *

- * OpenZWave was created to fill that gap. We do not have the official - * documentation, have signed no NDA, and are free to develop the library as - * we see fit. Our knowledge comes from existing bodies of open-source code - * (principally the Z-Wave parts of LinuxMCE), and through examining the - * messages sent by Z-Wave devices. - *

- * The goal of the project is to make a positive contribution to the Z-Wave - * community by creating a library that supports as much of the Z-Wave - * specification as possible, and that can be used as a "black-box" - * solution by anyone wanting to add Z-Wave to their application. It is NOT - * our aim to publish alternative documentation of the Z-Wave protocol, or - * to attempt to "punish" Sigma Designs for their decision to keep the - * protocol closed. - - * \section ZWave Z-Wave Concepts - * Z-Wave is a proprietary wireless communications protocol employing mesh - * networking technology. A mesh network allows low power devices to - * communicate over long ranges, and around radio blackspots by passing - * messages from one node to another. It is important to note that not all - * Z-Wave devices are active all the time, especially those that are battery - * powered. These nodes cannot take part in the forwarding of messages - * across the mesh. - *

- * Each Z-Wave device is known as "Node" in the network. A Z-Wave network - * can contain up to 232 nodes. If more devices are required, then - * multiple networks need to be set up using separate Z-Wave controller. - * OpenZWave supports multiple controllers, but on its own does not bridge - * the networks allowing a device on one to directly control a device on - * another. This functionality would have to be supplied by the application. - *

- * Z-Wave nodes can be divided into two types: Controllers and Slaves. The - * controllers are usually in the form of hand-held remote controls, or PC - * interfaces. The switches, dimmers, movement sensors etc are all slaves. - * Controllers and Devices - * Replication - * Command Classes - * Values - - *


- * \section Library The OpenZWave Library - * \subsection Overview Overview - - * \subsection Manager The Manager - * All Z-Wave functionality is accessed via the Manager class. While this - * does not make for the most efficient code structure, it does enable - * the library to handle potentially complex and hard-to-debug issues - * such as multi-threading and object lifespans behind the scenes. - * Application development is therefore simplified and less prone to bugs. - *

- - * \subsection Notifications Notifications - * Communication between the PC and devices on the the Z-Wave network occurs - * asynchronously. Some devices, notably movement sensors, sleep most of the - * time to save battery power, and can only receive commands when awake. - * Therefore a command to change a value in a device may not occur immediately. - * It may take several seconds or minutes, or even never arrive at all. - * For this reason, many OpenZWave methods, even those that request - * information, do not return that information directly. A request will be - * sent to the network, and the response sent to the application some time - * later via a system of notification callbacks. The notification handler - * will be at the core of any application using OpenZWave. It is here that - * all information regarding device configurations and states will be reported. - *

- * A Z-Wave network is a dynamic entity. Controllers and devices can be - * added or removed at any time. Once a network has been set up, this - * probably won't happen very often, but OpenZWave, and any application - * built upon it, must cope all the same. The notification callback system - * is used to inform the application of any changes to the structure of the - * network. - - * \subsection Values Working with Values - * - - * \subsection Guidelines Application Development Guidelines - * The main considerations when designing an application based upon - * OpenZWave are: - * - * - Communication with Z-Wave devices is asynchronous and not guaranteed - * to be reliable. Do not rely on receiving a response to any request. - * - * - A Z-Wave network may change at any time. The application's notification - * callback handler must deal woth all notifications, and any representation - * of the state of the Z-Wave network held by the application must be - * modified to match. User interfaces should be built dynamically from the - * information reported in the notification callbacks, and must be able to cope - * with the addition and removal of devices. - * - * Some users will have more than one Z-Wave controller, to allow for remote - * locations or to work around the 232 device limit. OpenZWave is designed - * for use with multiple controllers, and all applications should be written - * to support this. - * - * - There is no need to save the state of the network and restore it on - * the next run. OpenZWave does this automatically, and is designed to cope - * with any changes that occur to the network while the application is not - * running. - * - - *


- * \section Structure Source Code Structure - * - - *
- * \section Samples Samples - * The SDK package includes skeleton code for creating xPL-enabled - * applications. Code is provided for three types of application - a Windows - * service, a Windowed application, and a console application. The Windows - * service is quite flexible - it will run as a console application if no - * command line parameters are passed to it. This makes it possible to - * ship one application that will run on all versions of Windows, whether or - * not there is support for services. It is also useful for debugging. - *

- * The full source code for the W800RF32 service is also provided as a real - * life example of using the SDK to build a complete xPL application. - - *


- * \section Licensing Licensing - * OpenZWave is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, - * or (at your option) any later version. - *

- * OpenZWave is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - *

- * You should have received a copy of the GNU Lesser General Public License - * along with OpenZWave. If not, see . - - *


- * \section Support Support - * Assistance with all OpenZWave issues can be obtained by posting a message - * to the OpenZWave Google Group (http://groups.google.com/group/openzwave) - *

- */ - diff --git a/lib/ESPiLight/pilight/libs/openzwave/Driver.cpp b/lib/ESPiLight/pilight/libs/openzwave/Driver.cpp deleted file mode 100644 index 30237bb..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Driver.cpp +++ /dev/null @@ -1,6317 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Driver.cpp -// -// Communicates with a Z-Wave network -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "Defs.h" -#include "Driver.h" -#include "Options.h" -#include "Manager.h" -#include "Node.h" -#include "Msg.h" -#include "Notification.h" -#include "Scene.h" - -#include "platform/Event.h" -#include "platform/Mutex.h" -#include "platform/SerialController.h" -// #include "platform/HidController.h" -#include "platform/Thread.h" -#include "platform/Log.h" -#include "platform/TimeStamp.h" - -#include "command_classes/CommandClasses.h" -#include "command_classes/ApplicationStatus.h" -#include "command_classes/ControllerReplication.h" -#include "command_classes/Security.h" -#include "command_classes/WakeUp.h" -#include "command_classes/SwitchAll.h" -#include "command_classes/ManufacturerSpecific.h" -#include "command_classes/NoOperation.h" - -#include "value_classes/ValueID.h" -#include "value_classes/Value.h" -#include "value_classes/ValueStore.h" - -#include "tinyxml.h" - - -#include "Utils.h" -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -# include -#elif defined _WIN32 -# include -#define sleep(x) Sleep(1000 * x) -#endif -#include -#include - -using namespace OpenZWave; - -// Version numbering for saved configurations. Any change that will invalidate -// previously saved configurations must be accompanied by an increment to the -// version number, and a comment explaining the date of, and reason for, the change. -// -// 01: 12-31-2010 - Introduced config version numbering due to ValueID format change. -// 02: 01-12-2011 - Command class m_afterMark sense corrected, and attribute named to match. -// 03: 08-04-2011 - Changed command class instance handling for non-sequential MultiChannel endpoints. -// -uint32 const c_configVersion = 3; - -static char const* c_libraryTypeNames[] = -{ - "Unknown", // library type 0 - "Static Controller", // library type 1 - "Controller", // library type 2 - "Enhanced Slave", // library type 3 - "Slave", // library type 4 - "Installer", // library type 5 - "Routing Slave", // library type 6 - "Bridge Controller", // library type 7 - "Device Under Test" // library type 8 -}; - -static char const* c_controllerCommandNames[] = -{ - "None", - "Add Device", - "Create New Primary", - "Receive Configuration", - "Remove Device", - "Remove Failed Node", - "Has Node Failed", - "Replace Failed Node", - "Transfer Primary Role", - "Request Network Update", - "Request Node Neighbor Update", - "Assign Return Route", - "Delete All Return Routes", - "Send Node Information", - "Replication Send", - "Create Button", - "Delete Button" -}; - -static char const* c_sendQueueNames[] = -{ - "Command", - "Security", - "NoOp", - "Controller", - "WakeUp", - "Send", - "Query", - "Poll" -}; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Driver::Driver -( - string const& _controllerPath, - ControllerInterface const& _interface -): - m_driverThread( new Thread( "driver" ) ), - m_exit( false ), - m_init( false ), - m_awakeNodesQueried( false ), - m_allNodesQueried( false ), - m_notifytransactions( false ), - m_controllerInterfaceType( _interface ), - m_controllerPath( _controllerPath ), - m_controller( NULL ), - m_homeId( 0 ), - m_libraryVersion( "" ), - m_libraryTypeName( "" ), - m_libraryType( 0 ), - m_manufacturerId( 0 ), - m_productType( 0 ), - m_productId ( 0 ), - m_initVersion( 0 ), - m_initCaps( 0 ), - m_controllerCaps( 0 ), - m_nodeMutex( new Mutex() ), - m_controllerReplication( NULL ), - m_transmitOptions( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE | TRANSMIT_OPTION_EXPLORE ), - m_waitingForAck( false ), - m_expectedCallbackId( 0 ), - m_expectedReply( 0 ), - m_expectedCommandClassId( 0 ), - m_expectedNodeId( 0 ), - m_pollThread( new Thread( "poll" ) ), - m_pollMutex( new Mutex() ), - m_pollInterval( 0 ), - m_bIntervalBetweenPolls( false ), // if set to true (via SetPollInterval), the pollInterval will be interspersed between each poll (so a much smaller m_pollInterval like 100, 500, or 1,000 may be appropriate) - m_currentControllerCommand( NULL ), - m_SUCNodeId( 0 ), - m_controllerResetEvent( NULL ), - m_sendMutex( new Mutex() ), - m_currentMsg( NULL ), - m_virtualNeighborsReceived( false ), - m_notificationsEvent( new Event() ), - m_SOFCnt( 0 ), - m_ACKWaiting( 0 ), - m_readAborts( 0 ), - m_badChecksum( 0 ), - m_readCnt( 0 ), - m_writeCnt( 0 ), - m_CANCnt( 0 ), - m_NAKCnt( 0 ), - m_ACKCnt( 0 ), - m_OOFCnt( 0 ), - m_dropped( 0 ), - m_retries( 0 ), - m_callbacks( 0 ), - m_badroutes( 0 ), - m_noack( 0 ), - m_netbusy( 0 ), - m_notidle( 0 ), - m_nondelivery( 0 ), - m_routedbusy( 0 ), - m_broadcastReadCnt( 0 ), - m_broadcastWriteCnt( 0 ) -{ - // set a timestamp to indicate when this driver started - TimeStamp m_startTime; - - // Create the message queue events - for( int32 i=0; iSetSignalThreshold( 1 ); - - Options::Get()->GetOptionAsBool( "NotifyTransactions", &m_notifytransactions ); - Options::Get()->GetOptionAsInt( "PollInterval", &m_pollInterval ); - Options::Get()->GetOptionAsBool( "IntervalBetweenPolls", &m_bIntervalBetweenPolls ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Driver::~Driver -( -) -{ - /* Signal that we are going away... so at least Apps know... */ - Notification* notification = new Notification( Notification::Type_DriverRemoved ); - notification->SetHomeAndNodeIds( m_homeId, 0 ); - QueueNotification( notification ); - NotifyWatchers(); - - - // append final driver stats output to the log file - LogDriverStatistics(); - - // Save the driver config before deleting anything else - bool save; - if( Options::Get()->GetOptionAsBool( "SaveConfiguration", &save) ) - { - if( save ) - { - WriteConfig(); - Scene::WriteXML( "zwscene.xml" ); - } - } - - // The order of the statements below has been achieved by mitigating freed memory - //references using a memory allocator checker. Do not rearrange unless you are - //certain memory won't be referenced out of order. --Greg Satz, April 2010 - m_exit = true; - - m_pollThread->Stop(); - m_pollThread->Release(); - - m_driverThread->Stop(); - m_driverThread->Release(); - - m_sendMutex->Release(); - - m_controller->Close(); - m_controller->Release(); - - if( m_currentMsg != NULL ) - { - RemoveCurrentMsg(); - } - - // Clear the node data - LockNodes(); - for( int i=0; i<256; ++i ) - { - if( GetNodeUnsafe( i ) ) - { - delete m_nodes[i]; - m_nodes[i] = NULL; - Notification* notification = new Notification( Notification::Type_NodeRemoved ); - notification->SetHomeAndNodeIds( m_homeId, i ); - QueueNotification( notification ); - } - } - ReleaseNodes(); - - // Don't release until all nodes have removed their poll values - m_pollMutex->Release(); - - // Clear the send Queue - for( int32 i=0; iRelease(); - } - /* Doing our Notification Call back here in the destructor is just asking for trouble - * as there is a good chance that the application will do some sort of GetDriver() supported - * method on the Manager Class, which by this time, most of the OZW Classes associated with the - * Driver class is 99% destructed. (mainly nodes, which cascade to CC, which cascade to ValueID - * classes etc). We might need a flag around the Manager::GetDriver() class that stops applications - * from getting a half destructed Driver Reference, but still retain a Internal GetDriver() method - * that can return half destructed Driver references for internal classes (as per Greg's note above) - */ - bool notify; - if( Options::Get()->GetOptionAsBool( "NotifyOnDriverUnload", ¬ify) ) - { - if( notify ) - { - NotifyWatchers(); - } - } - m_notificationsEvent->Release(); - m_nodeMutex->Release(); - - delete m_controllerReplication; -} - -//----------------------------------------------------------------------------- -// -// Start the driver thread -//----------------------------------------------------------------------------- -void Driver::Start -( -) -{ - // Start the thread that will handle communications with the Z-Wave network - m_driverThread->Start( Driver::DriverThreadEntryPoint, this ); -} - -//----------------------------------------------------------------------------- -// -// Entry point of the thread for creating and managing the worker threads -//----------------------------------------------------------------------------- -void Driver::DriverThreadEntryPoint -( - Event* _exitEvent, - void* _context -) -{ - Driver* driver = (Driver*)_context; - if( driver ) - { - driver->DriverThreadProc( _exitEvent ); - } -} - -//----------------------------------------------------------------------------- -// -// Create and manage the worker threads -//----------------------------------------------------------------------------- -void Driver::DriverThreadProc -( - Event* _exitEvent -) -{ - uint32 attempts = 0; - while( true ) - { - if( Init( attempts ) ) - { - // Driver has been initialised - Wait* waitObjects[11]; - waitObjects[0] = _exitEvent; // Thread must exit. - waitObjects[1] = m_notificationsEvent; // Notifications waiting to be sent. - waitObjects[2] = m_controller; // Controller has received data. - waitObjects[3] = m_queueEvent[MsgQueue_Command]; // A controller command is in progress. - waitObjects[4] = m_queueEvent[MsgQueue_Security]; // Security Related Commands (As they have a timeout) - waitObjects[5] = m_queueEvent[MsgQueue_NoOp]; // Send device probes and diagnostics messages - waitObjects[6] = m_queueEvent[MsgQueue_Controller]; // A multi-part controller command is in progress - waitObjects[7] = m_queueEvent[MsgQueue_WakeUp]; // A node has woken. Pending messages should be sent. - waitObjects[8] = m_queueEvent[MsgQueue_Send]; // Ordinary requests to be sent. - waitObjects[9] = m_queueEvent[MsgQueue_Query]; // Node queries are pending. - waitObjects[10] = m_queueEvent[MsgQueue_Poll]; // Poll request is waiting. - - TimeStamp retryTimeStamp; - int retryTimeout = RETRY_TIMEOUT; - Options::Get()->GetOptionAsInt( "RetryTimeout", &retryTimeout ); - - while( true ) - { - Log::Write( LogLevel_StreamDetail, " Top of DriverThreadProc loop." ); - uint32 count = 11; - int32 timeout = Wait::Timeout_Infinite; - - // If we're waiting for a message to complete, we can only - // handle incoming data, notifications and exit events. - if( m_waitingForAck || m_expectedCallbackId || m_expectedReply ) - { - count = 3; - timeout = m_waitingForAck ? ACK_TIMEOUT : retryTimeStamp.TimeRemaining(); - if( timeout < 0 ) - { - timeout = 0; - } - } - else if( m_currentControllerCommand != NULL ) - { - count = 7; - } - else - { - Log::QueueClear(); // clear the log queue when starting a new message - } - - // Wait for something to do - int32 res = Wait::Multiple( waitObjects, count, timeout ); - - switch( res ) - { - case -1: - { - // Wait has timed out - time to resend - if( m_currentMsg != NULL ) - { - Notification* notification = new Notification( Notification::Type_Notification ); - notification->SetHomeAndNodeIds( m_homeId, m_currentMsg->GetTargetNodeId() ); - notification->SetNotification( Notification::Code_Timeout ); - QueueNotification( notification ); - } - if( WriteMsg( "Wait Timeout" ) ) - { - retryTimeStamp.SetTime( retryTimeout ); - } - break; - } - case 0: - { - // Exit has been signalled - return; - } - case 1: - { - // Notifications are waiting to be sent - NotifyWatchers(); - break; - } - case 2: - { - // Data has been received - ReadMsg(); - break; - } - default: - { - // All the other events are sending message queue items - if( WriteNextMsg( (MsgQueue)(res-3) ) ) - { - retryTimeStamp.SetTime( retryTimeout ); - } - break; - } - } - } - } - - ++attempts; - - uint32 maxAttempts = 0; - Options::Get()->GetOptionAsInt("DriverMaxAttempts", (int32 *)&maxAttempts); - if( maxAttempts && (attempts >= maxAttempts) ) - { - Manager::Get()->Manager::SetDriverReady(this, false); - NotifyWatchers(); - break; - } - - if( attempts < 25 ) - { - // Retry every 5 seconds for the first two minutes - if( Wait::Single( _exitEvent, 5000 ) == 0 ) - { - // Exit signalled. - return; - } - } - else - { - // Retry every 30 seconds after that - if( Wait::Single( _exitEvent, 30000 ) == 0 ) - { - // Exit signalled. - return; - } - } - } -} - - -//----------------------------------------------------------------------------- -// -// Initialize the controller -//----------------------------------------------------------------------------- -bool Driver::Init -( - uint32 _attempts -) -{ - m_nodeId = -1; - m_waitingForAck = false; - - // Open the controller - Log::Write( LogLevel_Info, " Opening controller %s", m_controllerPath.c_str() ); - - if( !m_controller->Open( m_controllerPath ) ) - { - Log::Write( LogLevel_Warning, "WARNING: Failed to init the controller (attempt %d)", _attempts ); - return false; - } - - // Controller opened successfully, so we need to start all the worker threads - m_pollThread->Start( Driver::PollThreadEntryPoint, this ); - - // Send a NAK to the ZWave device - uint8 nak = NAK; - m_controller->Write( &nak, 1 ); - - // Get/set ZWave controller information in its preferred initialization order - m_controller->PlayInitSequence( this ); - - //If we ever want promiscuous mode uncomment this code. - //Msg* msg = new Msg( "FUNC_ID_ZW_SET_PROMISCUOUS_MODE", 0xff, REQUEST, FUNC_ID_ZW_SET_PROMISCUOUS_MODE, false, false ); - //msg->Append( 0xff ); - //SendMsg( msg ); - - // Init successful - return true; -} - -//----------------------------------------------------------------------------- -// -// Clean up any messages to a node -//----------------------------------------------------------------------------- -void Driver::RemoveQueues -( - uint8 const _nodeId -) -{ - if( m_currentMsg != NULL && m_currentMsg->GetTargetNodeId() == _nodeId ) - { - RemoveCurrentMsg(); - } - - // Clear the send Queue - for( int32 i=0; i::iterator it = m_msgQueue[i].begin(); - while( it != m_msgQueue[i].end() ) - { - bool remove = false; - MsgQueueItem const& item = *it; - if( MsgQueueCmd_SendMsg == item.m_command && _nodeId == item.m_msg->GetTargetNodeId() ) - { - delete item.m_msg; - remove = true; - } - else if( MsgQueueCmd_QueryStageComplete == item.m_command && _nodeId == item.m_nodeId ) - { - remove = true; - } - else if( MsgQueueCmd_Controller == item.m_command && _nodeId == item.m_cci->m_controllerCommandNode && m_currentControllerCommand != item.m_cci ) - { - delete item.m_cci; - remove = true; - } - if( remove ) - { - it = m_msgQueue[i].erase( it ); - } - else - { - ++it; - } - } - if( m_msgQueue[i].empty() ) - { - m_queueEvent[i]->Reset(); - } - } -} - -//----------------------------------------------------------------------------- -// Configuration -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Read our configuration from an XML document -//----------------------------------------------------------------------------- -bool Driver::ReadConfig -( -) -{ - char str[32]; - int32 intVal; - - // Load the XML document that contains the driver configuration - string userPath; - Options::Get()->GetOptionAsString( "UserPath", &userPath ); - - snprintf( str, sizeof(str), "zwcfg_0x%08x.xml", m_homeId ); - string filename = userPath + string(str); - - TiXmlDocument doc; - if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) - { - return false; - } - - TiXmlElement const* driverElement = doc.RootElement(); - - // Version - if( TIXML_SUCCESS != driverElement->QueryIntAttribute( "version", &intVal ) || (uint32)intVal != c_configVersion ) - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadConfig - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() ); - return false; - } - - // Home ID - char const* homeIdStr = driverElement->Attribute( "home_id" ); - if( homeIdStr ) - { - char* p; - uint32 homeId = (uint32)strtoul( homeIdStr, &p, 0 ); - - if( homeId != m_homeId ) - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadConfig - Home ID in file %s is incorrect", filename.c_str() ); - return false; - } - } - else - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadConfig - Home ID is missing from file %s", filename.c_str() ); - return false; - } - - // Node ID - if( TIXML_SUCCESS == driverElement->QueryIntAttribute( "node_id", &intVal ) ) - { - if( (uint8)intVal != m_nodeId ) - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadConfig - Controller Node ID in file %s is incorrect", filename.c_str() ); - return false; - } - } - else - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadConfig - Node ID is missing from file %s", filename.c_str() ); - return false; - } - - // Capabilities - if( TIXML_SUCCESS == driverElement->QueryIntAttribute( "api_capabilities", &intVal ) ) - { - m_initCaps = (uint8)intVal; - } - - if( TIXML_SUCCESS == driverElement->QueryIntAttribute( "controller_capabilities", &intVal ) ) - { - m_controllerCaps = (uint8)intVal; - } - - // Poll Interval - if( TIXML_SUCCESS == driverElement->QueryIntAttribute( "poll_interval", &intVal ) ) - { - m_pollInterval = intVal; - } - - // Poll Interval--between polls or period for polling the entire pollList? - char const* cstr = driverElement->Attribute( "poll_interval_between" ); - if( cstr ) - { - m_bIntervalBetweenPolls = !strcmp( str, "true" ); - } - - // Read the nodes - LockNodes(); - TiXmlElement const* nodeElement = driverElement->FirstChildElement(); - while( nodeElement ) - { - char const* str = nodeElement->Value(); - if( str && !strcmp( str, "Node" ) ) - { - // Get the node Id from the XML - if( TIXML_SUCCESS == nodeElement->QueryIntAttribute( "id", &intVal ) ) - { - uint8 nodeId = (uint8)intVal; - Node* node = new Node( m_homeId, nodeId ); - m_nodes[nodeId] = node; - - Notification* notification = new Notification( Notification::Type_NodeAdded ); - notification->SetHomeAndNodeIds( m_homeId, nodeId ); - QueueNotification( notification ); - - // Read the rest of the node configuration from the XML - node->ReadXML( nodeElement ); - } - } - - nodeElement = nodeElement->NextSiblingElement(); - } - - ReleaseNodes(); - - // restore the previous state (for now, polling) for the nodes/values just retrieved - for( int i=0; i<256; i++ ) - { - if( m_nodes[i] != NULL ) - { - ValueStore* vs = m_nodes[i]->m_values; - for( ValueStore::Iterator it = vs->Begin(); it != vs->End(); ++it ) - { - Value* value = it->second; - if( value->m_pollIntensity != 0 ) - EnablePoll( value->GetID(), value->m_pollIntensity ); - } - } - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void Driver::WriteConfig -( -) -{ - char str[32]; - - if (!m_homeId) { - Log::Write( LogLevel_Warning, "WARNING: Tried to write driver config with no home ID set"); - return; - } - - // Create a new XML document to contain the driver configuration - TiXmlDocument doc; - TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" ); - TiXmlElement* driverElement = new TiXmlElement( "Driver" ); - doc.LinkEndChild( decl ); - doc.LinkEndChild( driverElement ); - - driverElement->SetAttribute( "xmlns", "http://code.google.com/p/open-zwave/" ); - - snprintf( str, sizeof(str), "%d", c_configVersion ); - driverElement->SetAttribute( "version", str ); - - snprintf( str, sizeof(str), "0x%.8x", m_homeId ); - driverElement->SetAttribute( "home_id", str ); - - snprintf( str, sizeof(str), "%d", m_nodeId ); - driverElement->SetAttribute( "node_id", str ); - - snprintf( str, sizeof(str), "%d", m_initCaps ); - driverElement->SetAttribute( "api_capabilities", str ); - - snprintf( str, sizeof(str), "%d", m_controllerCaps ); - driverElement->SetAttribute( "controller_capabilities", str ); - - snprintf( str, sizeof(str), "%d", m_pollInterval ); - driverElement->SetAttribute( "poll_interval", str ); - - snprintf( str, sizeof(str), "%d", (int) m_bIntervalBetweenPolls ); - driverElement->SetAttribute( "poll_interval_between", str ); - - LockNodes(); - for( int i=0; i<256; ++i ) - { - if( m_nodes[i] ) - { - m_nodes[i]->WriteXML( driverElement ); - } - } - ReleaseNodes(); - - string userPath; - Options::Get()->GetOptionAsString( "UserPath", &userPath ); - - snprintf( str, sizeof(str), "zwcfg_0x%08x.xml", m_homeId ); - string filename = userPath + string(str); - - doc.SaveFile( filename.c_str() ); -} - -//----------------------------------------------------------------------------- -// Controller -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Returns a pointer to the requested node without locking. -// Only to be used by main thread code. -//----------------------------------------------------------------------------- -Node* Driver::GetNodeUnsafe -( - uint8 _nodeId -) -{ - if( Node* node = m_nodes[_nodeId] ) - { - return node; - } - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Locks the nodes and returns a pointer to the requested one -//----------------------------------------------------------------------------- -Node* Driver::GetNode -( - uint8 _nodeId -) -{ - LockNodes(); - if( Node* node = m_nodes[_nodeId] ) - { - return node; - } - - ReleaseNodes(); - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Lock the nodes so that no other thread can modify them -//----------------------------------------------------------------------------- -void Driver::LockNodes -( -) -{ - m_nodeMutex->Lock(); -} - -//----------------------------------------------------------------------------- -// -// Unlock the nodes so that other threads can modify them -//----------------------------------------------------------------------------- -void Driver::ReleaseNodes -( -) -{ - m_nodeMutex->Unlock(); -} - -//----------------------------------------------------------------------------- -// Sending Z-Wave messages -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Queue an item on the query queue that indicates a stage is complete -//----------------------------------------------------------------------------- -void Driver::SendQueryStageComplete -( - uint8 const _nodeId, - Node::QueryStage const _stage -) -{ - MsgQueueItem item; - item.m_command = MsgQueueCmd_QueryStageComplete; - item.m_nodeId = _nodeId; - item.m_queryStage = _stage; - item.m_retry = false; - - if( Node* node = GetNode( _nodeId ) ) - { - if( !node->IsListeningDevice() ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - if( !wakeUp->IsAwake() ) - { - // If the message is for a sleeping node, we queue it in the node itself. - Log::Write( LogLevel_Info, "" ); - Log::Write( LogLevel_Detail, node->GetNodeId(), "Queuing (%s) Query Stage Complete (%s)", c_sendQueueNames[MsgQueue_WakeUp], node->GetQueryStageName( _stage ).c_str() ); - wakeUp->QueueMsg( item ); - ReleaseNodes(); - return; - } - } - } - - // Non-sleeping node - Log::Write( LogLevel_Detail, node->GetNodeId(), "Queuing (%s) Query Stage Complete (%s)", c_sendQueueNames[MsgQueue_Query], node->GetQueryStageName( _stage ).c_str() ); - m_sendMutex->Lock(); - m_msgQueue[MsgQueue_Query].push_back( item ); - m_queueEvent[MsgQueue_Query]->Set(); - m_sendMutex->Unlock(); - - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Request the current stage will be repeated -//----------------------------------------------------------------------------- -void Driver::RetryQueryStageComplete -( - uint8 const _nodeId, - Node::QueryStage const _stage -) -{ - MsgQueueItem item; - item.m_command = MsgQueueCmd_QueryStageComplete; - item.m_nodeId = _nodeId; - item.m_queryStage = _stage; - - m_sendMutex->Lock(); - - for( list::iterator it = m_msgQueue[MsgQueue_Query].begin(); it != m_msgQueue[MsgQueue_Query].end(); ++it ) - { - if( *it == item ) - { - (*it).m_retry = true; - break; - } - } - m_sendMutex->Unlock(); -} - -//----------------------------------------------------------------------------- -// -// Queue a message to be sent to the Z-Wave PC Interface -//----------------------------------------------------------------------------- -void Driver::SendMsg -( - Msg* _msg, - MsgQueue const _queue -) -{ - MsgQueueItem item; - - item.m_command = MsgQueueCmd_SendMsg; - item.m_msg = _msg; - _msg->Finalize(); - - - if( Node* node = GetNode(_msg->GetTargetNodeId()) ) - { - // If the message is for a sleeping node, we queue it in the node itself. - if( !node->IsListeningDevice() ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - if( !wakeUp->IsAwake() ) - { - Log::Write( LogLevel_Detail, "" ); - // Handle saving multi-step controller commands - if( m_currentControllerCommand != NULL ) - { - Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Queuing (%s) %s", c_sendQueueNames[MsgQueue_Controller], c_controllerCommandNames[m_currentControllerCommand->m_controllerCommand] ); - delete _msg; - item.m_command = MsgQueueCmd_Controller; - item.m_cci = new ControllerCommandItem( *m_currentControllerCommand ); - item.m_msg = NULL; - UpdateControllerState( ControllerState_Sleeping ); - } - else - { - Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Queuing (%s) %s", c_sendQueueNames[MsgQueue_WakeUp], _msg->GetAsString().c_str() ); - } - wakeUp->QueueMsg( item ); - ReleaseNodes(); - return; - } - } - } - - /* if the node Supports the Security Class - check if this message is meant to be encapsulated */ - if ( Security* security = static_cast( node->GetCommandClass(Security::StaticGetCommandClassId() ) ) ) - { - CommandClass *cc = node->GetCommandClass(_msg->GetSendingCommandClass()); - if ( (cc) && (cc->IsSecured()) ) - { - Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Encrypting Message For Command Class %s", cc->GetCommandClassName().c_str()); - security->SendMsg(_msg); - ReleaseNodes(); - return; - } - } - ReleaseNodes(); - } - - Log::Write( LogLevel_Detail, GetNodeNumber( _msg ), "Queuing (%s) %s", c_sendQueueNames[_queue], _msg->GetAsString().c_str() ); - m_sendMutex->Lock(); - m_msgQueue[_queue].push_back( item ); - m_queueEvent[_queue]->Set(); - m_sendMutex->Unlock(); -} - -//----------------------------------------------------------------------------- -// -// Transmit a queued message to the Z-Wave controller -//----------------------------------------------------------------------------- -bool Driver::WriteNextMsg -( - MsgQueue const _queue -) -{ - - // There are messages to send, so get the one at the front of the queue - m_sendMutex->Lock(); - MsgQueueItem item = m_msgQueue[_queue].front(); - - if( MsgQueueCmd_SendMsg == item.m_command ) - { - // Send a message - m_currentMsg = item.m_msg; - m_currentMsgQueueSource = _queue; - m_msgQueue[_queue].pop_front(); - if( m_msgQueue[_queue].empty() ) - { - m_queueEvent[_queue]->Reset(); - } - m_sendMutex->Unlock(); - return WriteMsg( "WriteNextMsg" ); - } - - if( MsgQueueCmd_QueryStageComplete == item.m_command ) - { - // Move to the next query stage - m_currentMsg = NULL; - Node::QueryStage stage = item.m_queryStage; - m_msgQueue[_queue].pop_front(); - if( m_msgQueue[_queue].empty() ) - { - m_queueEvent[_queue]->Reset(); - } - m_sendMutex->Unlock(); - - Node* node = GetNodeUnsafe( item.m_nodeId ); - if( node != NULL ) - { - Log::Write( LogLevel_Detail, node->GetNodeId(), "Query Stage Complete (%s)", node->GetQueryStageName( stage ).c_str() ); - if( !item.m_retry ) - { - node->QueryStageComplete( stage ); - } - node->AdvanceQueries(); - return true; - } - } - - if( MsgQueueCmd_Controller == item.m_command ) - { - // Run a multi-step controller command - m_currentControllerCommand = item.m_cci; - m_sendMutex->Unlock(); - // Figure out if done with command - if ( m_currentControllerCommand->m_controllerCommandDone ) - { - m_sendMutex->Lock(); - m_msgQueue[_queue].pop_front(); - if( m_msgQueue[_queue].empty() ) - { - m_queueEvent[_queue]->Reset(); - } - m_sendMutex->Unlock(); - if( m_currentControllerCommand->m_controllerCallback ) - { - m_currentControllerCommand->m_controllerCallback( m_currentControllerCommand->m_controllerState, m_currentControllerCommand->m_controllerReturnError, m_currentControllerCommand->m_controllerCallbackContext ); - } - m_sendMutex->Lock(); - delete m_currentControllerCommand; - m_currentControllerCommand = NULL; - m_sendMutex->Unlock(); - } - else if( m_currentControllerCommand->m_controllerState == ControllerState_Normal ) - { - DoControllerCommand(); - } - else if( m_currentControllerCommand->m_controllerStateChanged ) - { - if( m_currentControllerCommand->m_controllerCallback ) - { - m_currentControllerCommand->m_controllerCallback( m_currentControllerCommand->m_controllerState, m_currentControllerCommand->m_controllerReturnError, m_currentControllerCommand->m_controllerCallbackContext ); - m_currentControllerCommand->m_controllerStateChanged = false; - } - } - else - { - Log::Write( LogLevel_Info, "WriteNextMsg Controller nothing to do" ); - m_sendMutex->Lock(); - m_queueEvent[_queue]->Reset(); - m_sendMutex->Unlock(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Transmit the current message to the Z-Wave controller -//----------------------------------------------------------------------------- -bool Driver::WriteMsg -( - string const &msg -) -{ - if( !m_currentMsg ) - { - Log::Write( LogLevel_Detail, GetNodeNumber( m_currentMsg ), "WriteMsg %s m_currentMsg=%08x", msg.c_str(), m_currentMsg ); - // We try not to hang when this happenes - m_expectedCallbackId = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - m_expectedReply = 0; - m_waitingForAck = false; - return false; - } - - uint8 attempts = m_currentMsg->GetSendAttempts(); - uint8 nodeId = m_currentMsg->GetTargetNodeId(); - Node* node = GetNode( nodeId ); - if( attempts >= m_currentMsg->GetMaxSendAttempts() || (node != NULL && !node->IsNodeAlive() && !m_currentMsg->IsNoOperation() ) ) - { - if( node != NULL && !node->IsNodeAlive() ) - { - Log::Write( LogLevel_Error, nodeId, "ERROR: Dropping command because node is presumed dead" ); - } - else - { - // That's it - already tried to send GetMaxSendAttempt() times. - Log::Write( LogLevel_Error, nodeId, "ERROR: Dropping command, expected response not received after %d attempt(s)", m_currentMsg->GetMaxSendAttempts() ); - } - RemoveCurrentMsg(); - m_dropped++; - if( node != NULL ) - { - ReleaseNodes(); - } - return false; - } - - if( attempts != 0) - { - // this is not the first attempt, so increment the callback id before sending - m_currentMsg->UpdateCallbackId(); - } - - m_currentMsg->SetSendAttempts( ++attempts ); - m_expectedCallbackId = m_currentMsg->GetCallbackId(); - m_expectedCommandClassId = m_currentMsg->GetExpectedCommandClassId(); - m_expectedNodeId = m_currentMsg->GetTargetNodeId(); - m_expectedReply = m_currentMsg->GetExpectedReply(); - m_waitingForAck = true; - string attemptsstr = ""; - if( attempts > 1 ) - { - char buf[15]; - snprintf( buf, sizeof(buf), "Attempt %d, ", attempts ); - attemptsstr = buf; - m_retries++; - if( node != NULL ) - { - node->m_retries++; - } - } - - Log::Write( LogLevel_Detail, "" ); - Log::Write( LogLevel_Info, nodeId, "Sending (%s) message (%sCallback ID=0x%.2x, Expected Reply=0x%.2x) - %s", c_sendQueueNames[m_currentMsgQueueSource], attemptsstr.c_str(), m_expectedCallbackId, m_expectedReply, m_currentMsg->GetAsString().c_str() ); - - m_controller->Write( m_currentMsg->GetBuffer(), m_currentMsg->GetLength() ); - m_writeCnt++; - - if( nodeId == 0xff ) - { - m_broadcastWriteCnt++; // not accurate since library uses 0xff for the controller too - } - else - { - if( node != NULL ) - { - node->m_sentCnt++; - node->m_sentTS.SetTime(); - if( m_expectedReply == FUNC_ID_APPLICATION_COMMAND_HANDLER ) - { - CommandClass* cc = node->GetCommandClass( m_expectedCommandClassId ); - if( cc != NULL ) - { - cc->SentCntIncr(); - } - } - } - } - if( node != NULL ) - { - ReleaseNodes(); - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Delete the current message -//----------------------------------------------------------------------------- -void Driver::RemoveCurrentMsg -( -) -{ - Log::Write( LogLevel_Detail, GetNodeNumber( m_currentMsg ), "Removing current message" ); - if( m_currentMsg != NULL) - { - delete m_currentMsg; - m_currentMsg = NULL; - } - - m_expectedCallbackId = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - m_expectedReply = 0; - m_waitingForAck = false; -} - -//----------------------------------------------------------------------------- -// -// Move messages for a sleeping device to its wake-up queue -//----------------------------------------------------------------------------- -bool Driver::MoveMessagesToWakeUpQueue -( - uint8 const _targetNodeId, - bool const _move -) -{ - // If the target node is one that goes to sleep, transfer - // all messages for it to its Wake-Up queue. - if( Node* node = GetNodeUnsafe(_targetNodeId) ) - { - if( !node->IsListeningDevice() && !node->IsFrequentListeningDevice() && _targetNodeId != m_nodeId ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - // Mark the node as asleep - wakeUp->SetAwake( false ); - - // If we need to save the messages - if( _move ) - { - // Move all messages for this node to the wake-up queue - m_sendMutex->Lock(); - - // See if we are working on a controller command - if( m_currentControllerCommand ) - { - // Don't save controller message as it will be recreated - RemoveCurrentMsg(); - } - - // Then try the current message first - if( m_currentMsg ) - { - if( _targetNodeId == m_currentMsg->GetTargetNodeId() ) - { - // This message is for the unresponsive node - // We do not move any "Wake Up No More Information" - // commands or NoOperations to the pending queue. - if( !m_currentMsg->IsWakeUpNoMoreInformationCommand() && !m_currentMsg->IsNoOperation() ) - { - Log::Write( LogLevel_Info, _targetNodeId, "Node not responding - moving message to Wake-Up queue: %s", m_currentMsg->GetAsString().c_str() ); - MsgQueueItem item; - item.m_command = MsgQueueCmd_SendMsg; - item.m_msg = m_currentMsg; - wakeUp->QueueMsg( item ); - } - else - { - delete m_currentMsg; - } - - m_currentMsg = NULL; - m_expectedCallbackId = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - m_expectedReply = 0; - m_waitingForAck = false; - } - } - - // Now the message queues - for( int i=0; i::iterator it = m_msgQueue[i].begin(); - while( it != m_msgQueue[i].end() ) - { - bool remove = false; - MsgQueueItem const& item = *it; - if( MsgQueueCmd_SendMsg == item.m_command ) - { - if( _targetNodeId == item.m_msg->GetTargetNodeId() ) - { - // This message is for the unresponsive node - // We do not move any "Wake Up No More Information" - // commands or NoOperations to the pending queue. - if( !item.m_msg->IsWakeUpNoMoreInformationCommand() && !item.m_msg->IsNoOperation() ) - { - Log::Write( LogLevel_Info, item.m_msg->GetTargetNodeId(), "Node not responding - moving message to Wake-Up queue: %s", item.m_msg->GetAsString().c_str() ); - wakeUp->QueueMsg( item ); - } - else - { - delete item.m_msg; - } - remove = true; - } - } - if( MsgQueueCmd_QueryStageComplete == item.m_command ) - { - if( _targetNodeId == item.m_nodeId ) - { - Log::Write( LogLevel_Info, _targetNodeId, "Node not responding - moving QueryStageComplete command to Wake-Up queue" ); - wakeUp->QueueMsg( item ); - remove = true; - } - } - if( MsgQueueCmd_Controller == item.m_command ) - { - if( _targetNodeId == item.m_cci->m_controllerCommandNode ) - { - Log::Write( LogLevel_Info, _targetNodeId, "Node not responding - moving controller command to Wake-Up queue: %s", c_controllerCommandNames[item.m_cci->m_controllerCommand] ); - wakeUp->QueueMsg( item ); - remove = true; - } - } - - if( remove ) - { - it = m_msgQueue[i].erase( it ); - } - else - { - ++it; - } - } - - // If the queue is now empty, we need to clear its event - if( m_msgQueue[i].empty() ) - { - m_queueEvent[i]->Reset(); - } - } - - if( m_currentControllerCommand ) - { - // Put command back on queue so it will be cleaned up - UpdateControllerState( ControllerState_Sleeping ); - MsgQueueItem item; - item.m_command = MsgQueueCmd_Controller; - item.m_cci = new ControllerCommandItem( *m_currentControllerCommand ); - m_currentControllerCommand = item.m_cci; - m_msgQueue[MsgQueue_Controller].push_back( item ); - m_queueEvent[MsgQueue_Controller]->Set(); - } - - m_sendMutex->Unlock(); - - // Move completed successfully - return true; - } - } - } - } - - // Failed to move messages - return false; -} - -//----------------------------------------------------------------------------- -// -// For messages that return a ZW_SEND_DATA response, process the results here -// If it is a non-listeing (sleeping) node return true. -//----------------------------------------------------------------------------- -bool Driver::HandleErrorResponse -( - uint8 const _error, - uint8 const _nodeId, - char const* _funcStr, - bool _sleepCheck // = 0 -) -{ - // Only called with a ZW_SEND_DATA error response. We count and output the message here. - if( _error == TRANSMIT_COMPLETE_NOROUTE ) - { - m_badroutes++; - Log::Write( LogLevel_Info, _nodeId, "ERROR: %s failed. No route available.", _funcStr ); - } - else if( _error == TRANSMIT_COMPLETE_NO_ACK ) - { - m_noack++; - Log::Write( LogLevel_Info, _nodeId, "WARNING: %s failed. No ACK received - device may be asleep.", _funcStr ); - if( m_currentMsg ) - { - // In case the failure is due to the target being a sleeping node, we - // first try to move its pending messages to its wake-up queue. - if( MoveMessagesToWakeUpQueue( m_currentMsg->GetTargetNodeId(), _sleepCheck ) ) - { - return true; - } - Log::Write( LogLevel_Warning, _nodeId, "WARNING: Device is not a sleeping node." ); - } - } - else if( _error == TRANSMIT_COMPLETE_FAIL ) - { - m_netbusy++; - Log::Write( LogLevel_Info, _nodeId, "ERROR: %s failed. Network is busy.", _funcStr ); - } - else if( _error == TRANSMIT_COMPLETE_NOT_IDLE ) - { - m_notidle++; - Log::Write( LogLevel_Info, _nodeId, "ERROR: %s failed. Network is busy.", _funcStr ); - } - if( Node* node = GetNodeUnsafe( _nodeId ) ) - { - if( ++node->m_errors >= 3 ) - { - node->SetNodeAlive( false ); - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Identify controller (as opposed to node) commands...especially blocking ones -//----------------------------------------------------------------------------- -void Driver::CheckCompletedNodeQueries -( -) -{ - Log::Write( LogLevel_Warning, "CheckCompletedNodeQueries m_allNodesQueried=%d m_awakeNodesQueried=%d", m_allNodesQueried, m_awakeNodesQueried ); - if( !m_allNodesQueried ) - { - bool all = true; - bool sleepingOnly = true; - bool deadFound = false; - - LockNodes(); - for( int i=0; i<256; ++i ) - { - if( m_nodes[i] ) - { - if( m_nodes[i]->GetCurrentQueryStage() != Node::QueryStage_Complete ) - { - if ( !m_nodes[i]->IsNodeAlive() ) - { - deadFound = true; - continue; - } - all = false; - if( m_nodes[i]->IsListeningDevice() ) - { - sleepingOnly = false; - } - } - } - } - ReleaseNodes(); - - Log::Write( LogLevel_Warning, "CheckCompletedNodeQueries all=%d, deadFound=%d sleepingOnly=%d", all, deadFound, sleepingOnly ); - if( all ) - { - if( deadFound ) - { - // only dead nodes left to query - Log::Write( LogLevel_Info, " Node query processing complete except for dead nodes." ); - Notification* notification = new Notification( Notification::Type_AllNodesQueriedSomeDead ); - notification->SetHomeAndNodeIds( m_homeId, 0xff ); - QueueNotification( notification ); - } - else - { - // no sleeping nodes, no dead nodes and no more nodes in the queue, so...All done - Log::Write( LogLevel_Info, " Node query processing complete." ); - Notification* notification = new Notification( Notification::Type_AllNodesQueried ); - notification->SetHomeAndNodeIds( m_homeId, 0xff ); - QueueNotification( notification ); - } - m_awakeNodesQueried = true; - m_allNodesQueried = true; - } - else if( sleepingOnly ) - { - if (!m_awakeNodesQueried ) - { - // only sleeping nodes remain, so signal awake nodes queried complete - Log::Write( LogLevel_Info, " Node query processing complete except for sleeping nodes." ); - Notification* notification = new Notification( Notification::Type_AwakeNodesQueried ); - notification->SetHomeAndNodeIds( m_homeId, 0xff ); - QueueNotification( notification ); - m_awakeNodesQueried = true; - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Determine if the reply is from the node we are expecting. -//----------------------------------------------------------------------------- -bool Driver::IsExpectedReply -( - const uint8 _nodeId -) -{ - // Accept all controller commands or where the protocol doesn't identify the actual node - if( m_expectedNodeId == 255 || _nodeId == 0 ) - { - return true; - } - // Accept all messages that do not convey source node identification. - if( m_expectedReply == FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO || - m_expectedReply == FUNC_ID_ZW_REQUEST_NODE_INFO || - m_expectedReply == FUNC_ID_ZW_GET_ROUTING_INFO || - m_expectedReply == FUNC_ID_ZW_ASSIGN_RETURN_ROUTE || - m_expectedReply == FUNC_ID_ZW_DELETE_RETURN_ROUTE || - m_expectedReply == FUNC_ID_ZW_SEND_DATA || - m_expectedReply == FUNC_ID_ZW_SEND_NODE_INFORMATION || - m_expectedReply == FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE || - m_expectedReply == FUNC_ID_ZW_ENABLE_SUC || - m_expectedReply == FUNC_ID_ZW_SET_SUC_NODE_ID || - m_expectedReply == FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE_OPTIONS ) - { - return true; - } - // Accept if source message contains node info and it is from the one we are expecting - if( m_expectedNodeId == _nodeId ) - { - return true; - } - Log::Write( LogLevel_Detail, "IsExpectedReply: m_expectedNodeId = %d m_expectedReply = %02x", m_expectedNodeId, m_expectedReply ); - return false; -} -//----------------------------------------------------------------------------- -// Receiving Z-Wave messages -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Read data from the serial port -//----------------------------------------------------------------------------- -bool Driver::ReadMsg -( -) -{ - uint8 buffer[1024] = {0}; - - if( !m_controller->Read( buffer, 1 ) ) - { - // Nothing to read - return false; - } - - switch( buffer[0] ) - { - case SOF: - { - m_SOFCnt++; - if( m_waitingForAck ) - { - // This can happen on any normal network when a transmission overlaps an unexpected - // reception and the data in the buffer doesn't contain the ACK. The controller will - // notice and send us a CAN to retransmit. - Log::Write( LogLevel_Detail, "Unsolicited message received while waiting for ACK." ); - m_ACKWaiting++; - } - - // Read the length byte. Keep trying until we get it. - m_controller->SetSignalThreshold( 1 ); - int32 response = Wait::Single( m_controller, 50 ); - if( response < 0 ) - { - Log::Write( LogLevel_Warning, "WARNING: 50ms passed without finding the length byte...aborting frame read"); - m_readAborts++; - break; - } - - m_controller->Read( &buffer[1], 1 ); - m_controller->SetSignalThreshold( buffer[1] ); - if( Wait::Single( m_controller, 500 ) < 0 ) - { - Log::Write( LogLevel_Warning, "WARNING: 500ms passed without reading the rest of the frame...aborting frame read" ); - m_readAborts++; - m_controller->SetSignalThreshold( 1 ); - break; - } - - m_controller->Read( &buffer[2], buffer[1] ); - m_controller->SetSignalThreshold( 1 ); - - uint32 length = buffer[1] + 2; - - // Log the data - string str = ""; - for( uint32 i=0; iWrite( &ack, 1 ); - m_readCnt++; - - // Process the received message - ProcessMsg( &buffer[2] ); - } - else - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Checksum incorrect - sending NAK" ); - m_badChecksum++; - uint8 nak = NAK; - m_controller->Write( &nak, 1 ); - m_controller->Purge(); - } - break; - } - - case CAN: - { - // This is the other side of an unsolicited ACK. As mentioned there if we receive a message - // just after we transmitted one, the controller will notice and tell us to retransmit here. - // Don't increment the transmission counter as it is possible the message will never get out - // on very busy networks with lots of unsolicited messages being received. Increase the amount - // of retries but only up to a limit so we don't stay here forever. - Log::Write( LogLevel_Detail, GetNodeNumber( m_currentMsg ), "CAN received...triggering resend" ); - m_CANCnt++; - if( m_currentMsg != NULL ) - { - m_currentMsg->SetMaxSendAttempts( m_currentMsg->GetMaxSendAttempts() + 1 ); - } - else - { - Log::Write( LogLevel_Warning, "m_currentMsg was NULL when trying to set MaxSendAttempts" ); - Log::QueueDump(); - } - WriteMsg( "CAN" ); - break; - } - - case NAK: - { - Log::Write( LogLevel_Warning, GetNodeNumber( m_currentMsg ), "WARNING: NAK received...triggering resend" ); - m_NAKCnt++; - WriteMsg( "NAK" ); - break; - } - - case ACK: - { - m_ACKCnt++; - m_waitingForAck = false; - if( m_currentMsg == NULL ) - { - Log::Write( LogLevel_StreamDetail, 255, " ACK received" ); - } - else - { - Log::Write( LogLevel_StreamDetail, GetNodeNumber( m_currentMsg ), " ACK received CallbackId 0x%.2x Reply 0x%.2x", m_expectedCallbackId, m_expectedReply ); - if( ( 0 == m_expectedCallbackId ) && ( 0 == m_expectedReply ) ) - { - // Remove the message from the queue, now that it has been acknowledged. - RemoveCurrentMsg(); - } - } - break; - } - - default: - { - Log::Write( LogLevel_Warning, "WARNING: Out of frame flow! (0x%.2x). Sending NAK.", buffer[0] ); - m_OOFCnt++; - uint8 nak = NAK; - m_controller->Write( &nak, 1 ); - m_controller->Purge(); - break; - } - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Process data received from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::ProcessMsg -( - uint8* _data -) -{ - bool handleCallback = true; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - - if( RESPONSE == _data[0] ) - { - switch( _data[1] ) - { - case FUNC_ID_SERIAL_API_GET_INIT_DATA: - { - Log::Write( LogLevel_Detail, "" ); - HandleSerialAPIGetInitDataResponse( _data ); - break; - } - case FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetControllerCapabilitiesResponse( _data ); - break; - } - case FUNC_ID_SERIAL_API_GET_CAPABILITIES: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetSerialAPICapabilitiesResponse( _data ); - break; - } - case FUNC_ID_SERIAL_API_SOFT_RESET: - { - Log::Write( LogLevel_Detail, "" ); - HandleSerialAPISoftResetResponse( _data ); - break; - } - case FUNC_ID_ZW_SEND_DATA: - { - HandleSendDataResponse( _data, false ); - handleCallback = false; // Skip the callback handling - a subsequent FUNC_ID_ZW_SEND_DATA request will deal with that - break; - } - case FUNC_ID_ZW_GET_VERSION: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetVersionResponse( _data ); - break; - } - case FUNC_ID_ZW_GET_RANDOM: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetRandomResponse( _data ); - break; - } - case FUNC_ID_ZW_MEMORY_GET_ID: - { - Log::Write( LogLevel_Detail, "" ); - HandleMemoryGetIdResponse( _data ); - break; - } - case FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetNodeProtocolInfoResponse( _data ); - break; - } - case FUNC_ID_ZW_REPLICATION_SEND_DATA: - { - HandleSendDataResponse( _data, true ); - handleCallback = false; // Skip the callback handling - a subsequent FUNC_ID_ZW_REPLICATION_SEND_DATA request will deal with that - break; - } - case FUNC_ID_ZW_ASSIGN_RETURN_ROUTE: - { - Log::Write( LogLevel_Detail, "" ); - if( !HandleAssignReturnRouteResponse( _data ) ) - { - m_expectedCallbackId = _data[2]; // The callback message won't be coming, so we force the transaction to complete - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - break; - } - case FUNC_ID_ZW_DELETE_RETURN_ROUTE: - { - Log::Write( LogLevel_Detail, "" ); - if( !HandleDeleteReturnRouteResponse( _data ) ) - { - m_expectedCallbackId = _data[2]; // The callback message won't be coming, so we force the transaction to complete - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - break; - } - case FUNC_ID_ZW_ENABLE_SUC: - { - Log::Write( LogLevel_Detail, "" ); - HandleEnableSUCResponse( _data ); - break; - } - case FUNC_ID_ZW_REQUEST_NETWORK_UPDATE: - { - Log::Write( LogLevel_Detail, "" ); - if( !HandleNetworkUpdateResponse( _data ) ) - { - m_expectedCallbackId = _data[2]; // The callback message won't be coming, so we force the transaction to complete - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - break; - } - case FUNC_ID_ZW_SET_SUC_NODE_ID: - { - Log::Write( LogLevel_Detail, "" ); - HandleSetSUCNodeIdResponse( _data ); - break; - } - case FUNC_ID_ZW_GET_SUC_NODE_ID: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetSUCNodeIdResponse( _data ); - break; - } - case FUNC_ID_ZW_REQUEST_NODE_INFO: - { - Log::Write( LogLevel_Detail, "" ); - if( _data[2] ) - { - Log::Write( LogLevel_Info, nodeId, "FUNC_ID_ZW_REQUEST_NODE_INFO Request successful." ); - } - else - { - Log::Write( LogLevel_Info, nodeId, "FUNC_ID_ZW_REQUEST_NODE_INFO Request failed." ); - } - break; - } - case FUNC_ID_ZW_REMOVE_FAILED_NODE_ID: - { - Log::Write( LogLevel_Detail, "" ); - if( !HandleRemoveFailedNodeResponse( _data ) ) - { - m_expectedCallbackId = _data[2]; // The callback message won't be coming, so we force the transaction to complete - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - break; - } - case FUNC_ID_ZW_IS_FAILED_NODE_ID: - { - Log::Write( LogLevel_Detail, "" ); - HandleIsFailedNodeResponse( _data ); - break; - } - case FUNC_ID_ZW_REPLACE_FAILED_NODE: - { - Log::Write( LogLevel_Detail, "" ); - if( !HandleReplaceFailedNodeResponse( _data ) ) - { - m_expectedCallbackId = _data[2]; // The callback message won't be coming, so we force the transaction to complete - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - break; - } - case FUNC_ID_ZW_GET_ROUTING_INFO: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetRoutingInfoResponse( _data ); - break; - } - case FUNC_ID_ZW_R_F_POWER_LEVEL_SET: - { - Log::Write( LogLevel_Detail, "" ); - HandleRfPowerLevelSetResponse( _data ); - break; - } - case FUNC_ID_ZW_READ_MEMORY: - { - Log::Write( LogLevel_Detail, "" ); - HandleReadMemoryResponse( _data ); - break; - } - case FUNC_ID_SERIAL_API_SET_TIMEOUTS: - { - Log::Write( LogLevel_Detail, "" ); - HandleSerialApiSetTimeoutsResponse( _data ); - break; - } - case FUNC_ID_MEMORY_GET_BYTE: - { - Log::Write( LogLevel_Detail, "" ); - HandleMemoryGetByteResponse( _data ); - break; - } - case FUNC_ID_ZW_GET_VIRTUAL_NODES: - { - Log::Write( LogLevel_Detail, "" ); - HandleGetVirtualNodesResponse( _data ); - break; - } - case FUNC_ID_ZW_SET_SLAVE_LEARN_MODE: - { - Log::Write( LogLevel_Detail, "" ); - if( !HandleSetSlaveLearnModeResponse( _data ) ) - { - m_expectedCallbackId = _data[2]; // The callback message won't be coming, so we force the transaction to complete - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - break; - } - case FUNC_ID_ZW_SEND_SLAVE_NODE_INFO: - { - Log::Write( LogLevel_Detail, "" ); - if( !HandleSendSlaveNodeInfoResponse( _data ) ) - { - m_expectedCallbackId = _data[2]; // The callback message won't be coming, so we force the transaction to complete - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - break; - } - default: - { - Log::Write( LogLevel_Detail, "" ); - Log::Write( LogLevel_Info, "**TODO: handle response for 0x%.2x** Please report this message.", _data[1] ); - break; - } - } - } - else if( REQUEST == _data[0] ) - { - switch( _data[1] ) - { - case FUNC_ID_APPLICATION_COMMAND_HANDLER: - { - Log::Write( LogLevel_Detail, "" ); - HandleApplicationCommandHandlerRequest( _data ); - break; - } - case FUNC_ID_ZW_SEND_DATA: - { - HandleSendDataRequest( _data, false ); - break; - } - case FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE: - { - if( m_controllerReplication ) - { - Log::Write( LogLevel_Detail, "" ); - m_controllerReplication->SendNextData(); - } - break; - } - case FUNC_ID_ZW_REPLICATION_SEND_DATA: - { - HandleSendDataRequest( _data, true ); - break; - } - case FUNC_ID_ZW_ASSIGN_RETURN_ROUTE: - { - Log::Write( LogLevel_Detail, "" ); - HandleAssignReturnRouteRequest( _data ); - break; - } - case FUNC_ID_ZW_DELETE_RETURN_ROUTE: - { - Log::Write( LogLevel_Detail, "" ); - HandleDeleteReturnRouteRequest( _data ); - break; - } - case FUNC_ID_ZW_SEND_NODE_INFORMATION: - { - Log::Write( LogLevel_Detail, "" ); - HandleSendNodeInformationRequest( _data ); - break; - } - case FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE: - case FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE_OPTIONS: - { - Log::Write( LogLevel_Detail, "" ); - HandleNodeNeighborUpdateRequest( _data ); - break; - } - case FUNC_ID_ZW_APPLICATION_UPDATE: - { - Log::Write( LogLevel_Detail, "" ); - handleCallback = !HandleApplicationUpdateRequest( _data ); - break; - } - case FUNC_ID_ZW_ADD_NODE_TO_NETWORK: - { - Log::Write( LogLevel_Detail, "" ); - HandleAddNodeToNetworkRequest( _data ); - break; - } - case FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK: - { - Log::Write( LogLevel_Detail, "" ); - HandleRemoveNodeFromNetworkRequest( _data ); - break; - } - case FUNC_ID_ZW_CREATE_NEW_PRIMARY: - { - Log::Write( LogLevel_Detail, "" ); - HandleCreateNewPrimaryRequest( _data ); - break; - } - case FUNC_ID_ZW_CONTROLLER_CHANGE: - { - Log::Write( LogLevel_Detail, "" ); - HandleControllerChangeRequest( _data ); - break; - } - case FUNC_ID_ZW_SET_LEARN_MODE: - { - Log::Write( LogLevel_Detail, "" ); - HandleSetLearnModeRequest( _data ); - break; - } - case FUNC_ID_ZW_REQUEST_NETWORK_UPDATE: - { - Log::Write( LogLevel_Detail, "" ); - HandleNetworkUpdateRequest( _data ); - break; - } - case FUNC_ID_ZW_REMOVE_FAILED_NODE_ID: - { - Log::Write( LogLevel_Detail, "" ); - HandleRemoveFailedNodeRequest( _data ); - break; - } - case FUNC_ID_ZW_REPLACE_FAILED_NODE: - { - Log::Write( LogLevel_Detail, "" ); - HandleReplaceFailedNodeRequest( _data ); - break; - } - case FUNC_ID_ZW_SET_SLAVE_LEARN_MODE: - { - Log::Write( LogLevel_Detail, "" ); - HandleSetSlaveLearnModeRequest( _data ); - break; - } - case FUNC_ID_ZW_SEND_SLAVE_NODE_INFO: - { - Log::Write( LogLevel_Detail, "" ); - HandleSendSlaveNodeInfoRequest( _data ); - break; - } - case FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER: - { - Log::Write( LogLevel_Detail, "" ); - HandleApplicationSlaveCommandRequest( _data ); - break; - } - case FUNC_ID_PROMISCUOUS_APPLICATION_COMMAND_HANDLER: - { - Log::Write( LogLevel_Detail, "" ); - HandlePromiscuousApplicationCommandHandlerRequest( _data ); - break; - } - case FUNC_ID_ZW_SET_DEFAULT: - { - Log::Write( LogLevel_Detail, "" ); - HandleSerialAPIResetRequest( _data ); - break; - } - default: - { - Log::Write( LogLevel_Detail, "" ); - Log::Write( LogLevel_Info, "**TODO: handle request for 0x%.2x** Please report this message.", _data[1] ); - break; - } - } - } - - // Generic callback handling - if( handleCallback ) - { - if( ( m_expectedCallbackId || m_expectedReply ) ) - { - if( m_expectedCallbackId ) - { - if( m_expectedCallbackId == _data[2] ) - { - Log::Write( LogLevel_Detail, nodeId, " Expected callbackId was received" ); - m_expectedCallbackId = 0; - } - } - if( m_expectedReply ) - { - if( m_expectedReply == _data[1] ) - { - if( m_expectedCommandClassId && ( m_expectedReply == FUNC_ID_APPLICATION_COMMAND_HANDLER ) ) - { - if( m_expectedCallbackId == 0 && m_expectedCommandClassId == _data[5] && m_expectedNodeId == _data[3] ) - { - Log::Write( LogLevel_Detail, nodeId, " Expected reply and command class was received" ); - m_waitingForAck = false; - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - } - else - { - if( IsExpectedReply( _data[3] ) ) - - { - Log::Write( LogLevel_Detail, nodeId, " Expected reply was received" ); - m_expectedReply = 0; - m_expectedNodeId = 0; - } - } - } - } - - if( !( m_expectedCallbackId || m_expectedReply ) ) - { - Log::Write( LogLevel_Detail, nodeId, " Message transaction complete" ); - Log::Write( LogLevel_Detail, "" ); - - if( m_notifytransactions ) - { - Notification* notification = new Notification( Notification::Type_Notification ); - notification->SetHomeAndNodeIds( m_homeId, nodeId ); - notification->SetNotification( Notification::Code_MsgComplete ); - QueueNotification( notification ); - } - RemoveCurrentMsg(); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleGetVersionResponse -( - uint8* _data -) -{ - m_libraryVersion = (char*)&_data[2]; - - m_libraryType = _data[m_libraryVersion.size()+3]; - if( m_libraryType < 9 ) - { - m_libraryTypeName = c_libraryTypeNames[m_libraryType]; - } - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_GET_VERSION:" ); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " %s library, version %s", m_libraryTypeName.c_str(), m_libraryVersion.c_str() ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- - -void Driver::HandleGetRandomResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_GET_RANDOM: %s", _data[2] ? "true" : "false" ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleGetControllerCapabilitiesResponse -( - uint8* _data -) -{ - m_controllerCaps = _data[2]; - - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES:" ); - - char str[256]; - if( m_controllerCaps & ControllerCaps_SIS ) - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " There is a SUC ID Server (SIS) in this network." ); - snprintf( str, sizeof(str), " The PC controller is an inclusion %s%s%s", - ( m_controllerCaps & ControllerCaps_SUC ) ? "static update controller (SUC)" : "controller", - ( m_controllerCaps & ControllerCaps_OnOtherNetwork ) ? " which is using a Home ID from another network" : "", - ( m_controllerCaps & ControllerCaps_RealPrimary ) ? " and was the original primary before the SIS was added." : "." ); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), str ); - - } - else - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " There is no SUC ID Server (SIS) in this network." ); - snprintf( str, sizeof(str), " The PC controller is a %s%s%s", - ( m_controllerCaps & ControllerCaps_Secondary ) ? "secondary" : "primary", - ( m_controllerCaps & ControllerCaps_SUC ) ? " static update controller (SUC)" : " controller", - ( m_controllerCaps & ControllerCaps_OnOtherNetwork ) ? " which is using a Home ID from another network." : "." ); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), str ); - } -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleGetSerialAPICapabilitiesResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Received reply to FUNC_ID_SERIAL_API_GET_CAPABILITIES" ); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Serial API Version: %d.%d", _data[2], _data[3] ); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Manufacturer ID: 0x%.2x%.2x", _data[4], _data[5] ); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Product Type: 0x%.2x%.2x", _data[6], _data[7] ); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Product ID: 0x%.2x%.2x", _data[8], _data[9] ); - - // _data[10] to _data[41] are a 256-bit bitmask with one bit set for - // each FUNC_ID_ method supported by the controller. - // Bit 0 is FUNC_ID_ 1. So FUNC_ID_SERIAL_API_GET_CAPABILITIES (0x07) will be bit 6 of the first byte. - m_serialAPIVersion[0] = _data[2]; - m_serialAPIVersion[1] = _data[3]; - m_manufacturerId = ( ( (uint16)_data[4] )<<8) | (uint16)_data[5]; - m_productType = ( ( (uint16)_data[6] )<<8 ) | (uint16)_data[7]; - m_productId = ( ( (uint16)_data[8] )<<8 ) | (uint16)_data[9]; - memcpy( m_apiMask, &_data[10], sizeof( m_apiMask ) ); - - if( IsBridgeController() ) - { - SendMsg( new Msg( "FUNC_ID_ZW_GET_VIRTUAL_NODES", 0xff, REQUEST, FUNC_ID_ZW_GET_VIRTUAL_NODES, false ), MsgQueue_Command); - } - else if( IsAPICallSupported( FUNC_ID_ZW_GET_RANDOM ) ) - - { - Msg *msg = new Msg( "FUNC_ID_ZW_GET_RANDOM", 0xff, REQUEST, FUNC_ID_ZW_GET_RANDOM, false ); - msg->Append( 32 ); // 32 bytes - SendMsg( msg, MsgQueue_Command ); - } - SendMsg( new Msg( "FUNC_ID_SERIAL_API_GET_INIT_DATA", 0xff, REQUEST, FUNC_ID_SERIAL_API_GET_INIT_DATA, false ), MsgQueue_Command); - if( !IsBridgeController() ) - { - Msg* msg = new Msg( "FUNC_ID_SERIAL_API_SET_TIMEOUTS", 0xff, REQUEST, FUNC_ID_SERIAL_API_SET_TIMEOUTS, false ); - msg->Append( ACK_TIMEOUT / 10 ); - msg->Append( BYTE_TIMEOUT / 10 ); - SendMsg( msg, MsgQueue_Command ); - } - Msg* msg = new Msg( "FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION", 0xff, REQUEST, FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION, false, false ); - msg->Append( APPLICATION_NODEINFO_LISTENING ); - msg->Append( 0x02 ); // Generic Static Controller - msg->Append( 0x01 ); // Specific Static PC Controller - msg->Append( 0x00 ); // Length - SendMsg( msg, MsgQueue_Command ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSerialAPISoftResetResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to Soft Reset." ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSerialAPIResetRequest -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to complete Controller Reset." ); - if( m_controllerResetEvent != NULL ) - { - m_controllerResetEvent->Set(); - m_controllerResetEvent = NULL; - } -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleEnableSUCResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to Enable SUC." ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleNetworkUpdateResponse -( - uint8* _data -) -{ - bool res = true; - ControllerState state = ControllerState_InProgress; - if( _data[2] ) - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_REQUEST_NETWORK_UPDATE - command in progress" ); - } - else - { - // Failed - Log::Write( LogLevel_Warning, GetNodeNumber( m_currentMsg ), "WARNING: Received reply to FUNC_ID_ZW_REQUEST_NETWORK_UPDATE - command failed" ); - state = ControllerState_Failed; - res = false; - } - - UpdateControllerState( state ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSetSUCNodeIdResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to SET_SUC_NODE_ID." ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleGetSUCNodeIdResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to GET_SUC_NODE_ID. Node ID = %d", _data[2] ); - m_SUCNodeId = _data[2]; - - if( _data[2] == 0) - { - bool enableSIS = true; - Options::Get()->GetOptionAsBool("EnableSIS", &enableSIS); - if (enableSIS) { - Log::Write( LogLevel_Info, " No SUC, so we become SIS" ); - - Msg* msg; - msg = new Msg( "Enable SUC", m_nodeId, REQUEST, FUNC_ID_ZW_ENABLE_SUC, false ); - msg->Append( 1 ); - msg->Append( SUC_FUNC_NODEID_SERVER ); // SIS; SUC would be ZW_SUC_FUNC_BASIC_SUC - SendMsg( msg, MsgQueue_Send ); - - msg = new Msg( "Set SUC node ID", m_nodeId, REQUEST, FUNC_ID_ZW_SET_SUC_NODE_ID, false ); - msg->Append( m_nodeId ); - msg->Append( 1 ); // TRUE, we want to be SUC/SIS - msg->Append( 0 ); // no low power - msg->Append( SUC_FUNC_NODEID_SERVER ); - SendMsg( msg, MsgQueue_Send ); - } else { - Log::Write( LogLevel_Info, " No SUC, not becoming SUC as option is disabled" ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleMemoryGetIdResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_MEMORY_GET_ID. Home ID = 0x%02x%02x%02x%02x. Our node ID = %d", _data[2], _data[3], _data[4], _data[5], _data[6] ); - m_homeId = ( ( (uint32)_data[2] )<<24 ) | ( ( (uint32)_data[3] )<<16 ) | ( ( (uint32)_data[4] )<<8 ) | ( (uint32)_data[5] ); - m_nodeId = _data[6]; - m_controllerReplication = static_cast(ControllerReplication::Create( m_homeId, m_nodeId )); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSerialAPIGetInitDataResponse -( - uint8* _data -) -{ - int32 i; - - if( !m_init ) - { - // Mark the driver as ready (we have to do this first or - // all the code handling notifications will go awry). - Manager::Get()->SetDriverReady( this, true ); - - // Read the config file first, to get the last known state - ReadConfig(); - } - else - { - // Notify the user that all node and value information has been deleted - // We need to wait to do this here so we have new information to report. - Notification* notification = new Notification( Notification::Type_DriverReset ); - notification->SetHomeAndNodeIds( m_homeId, 0 ); - QueueNotification( notification ); - } - - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_SERIAL_API_GET_INIT_DATA:" ); - m_initVersion = _data[2]; - m_initCaps = _data[3]; - - if( _data[4] == NUM_NODE_BITFIELD_BYTES ) - { - for( i=0; iSetQueryStage( Node::QueryStage_Probe1 ); - } - - ReleaseNodes(); - } - else - { - // This node is new - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Node %.3d - New", nodeId ); - Notification* notification = new Notification( Notification::Type_NodeNew ); - notification->SetHomeAndNodeIds( m_homeId, nodeId ); - QueueNotification( notification ); - - // Create the node and request its info - InitNode( nodeId ); - } - } - } - else - { - if( GetNode(nodeId) ) - { - // This node no longer exists in the Z-Wave network - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Node %.3d - Removed", nodeId ); - delete m_nodes[nodeId]; - m_nodes[nodeId] = NULL; - Notification* notification = new Notification( Notification::Type_NodeRemoved ); - notification->SetHomeAndNodeIds( m_homeId, nodeId ); - QueueNotification( notification ); - - ReleaseNodes(); - } - } - } - } - } - - m_init = true; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleGetNodeProtocolInfoResponse -( - uint8* _data -) -{ - // The node that the protocol info response is for is not included in the message. - // We have to assume that the node is the same one as in the most recent request. - if( !m_currentMsg ) - { - Log::Write( LogLevel_Warning, "WARNING: Received unexpected FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO message - ignoring."); - return; - } - - uint8 nodeId = m_currentMsg->GetTargetNodeId(); - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO" ); - - // Update the node with the protocol info - if( Node* node = GetNodeUnsafe( nodeId ) ) - { - node->UpdateProtocolInfo( &_data[2] ); - } -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleAssignReturnRouteResponse -( - uint8* _data -) -{ - bool res = true; - ControllerState state = ControllerState_InProgress; - if( _data[2] ) - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_ASSIGN_RETURN_ROUTE - command in progress" ); - } - else - { - // Failed - Log::Write( LogLevel_Warning, GetNodeNumber( m_currentMsg ), "WARNING: Received reply to FUNC_ID_ZW_ASSIGN_RETURN_ROUTE - command failed" ); - state = ControllerState_Failed; - res = false; - } - - UpdateControllerState( state ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleDeleteReturnRouteResponse -( - uint8* _data -) -{ - bool res = true; - ControllerState state = ControllerState_InProgress; - if( _data[2] ) - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_DELETE_RETURN_ROUTE - command in progress" ); - } - else - { - // Failed - Log::Write( LogLevel_Warning, GetNodeNumber( m_currentMsg ), "WARNING: Received reply to FUNC_ID_ZW_DELETE_RETURN_ROUTE - command failed" ); - state = ControllerState_Failed; - res = false; - } - - UpdateControllerState( state ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleRemoveFailedNodeResponse -( - uint8* _data -) -{ - bool res = true; - ControllerState state = ControllerState_InProgress; - ControllerError error = ControllerError_None; - if( _data[2] ) - { - string reason; - switch( _data[2] ) - { - case FAILED_NODE_NOT_FOUND: - { - reason = "Node not found"; - error = ControllerError_NotFound; - break; - } - case FAILED_NODE_REMOVE_PROCESS_BUSY: - { - reason = "Remove process busy"; - error = ControllerError_Busy; - break; - } - case FAILED_NODE_REMOVE_FAIL: - { - reason = "Remove failed"; - error = ControllerError_Failed; - break; - } - case FAILED_NODE_NOT_PRIMARY_CONTROLLER: - { - reason = "Not Primary Controller"; - error = ControllerError_NotPrimary; - break; - } - default: - { - reason = "Command failed"; - break; - } - } - - Log::Write( LogLevel_Warning, GetNodeNumber( m_currentMsg ), "WARNING: Received reply to FUNC_ID_ZW_REMOVE_FAILED_NODE_ID - %s", reason.c_str() ); - state = ControllerState_Failed; - res = false; - } - else - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_REMOVE_FAILED_NODE_ID - Command in progress" ); - } - - UpdateControllerState( state, error ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleIsFailedNodeResponse -( - uint8* _data -) -{ - ControllerState state; - uint8 nodeId = m_currentControllerCommand ? m_currentControllerCommand->m_controllerCommandNode : GetNodeNumber( m_currentMsg ); - if( _data[2] ) - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_IS_FAILED_NODE_ID - node %d failed", nodeId ); - state = ControllerState_NodeFailed; - } - else - { - Log::Write( LogLevel_Warning, nodeId, "Received reply to FUNC_ID_ZW_IS_FAILED_NODE_ID - node %d has not failed", nodeId ); - if( Node* node = GetNodeUnsafe( nodeId ) ) - { - node->SetNodeAlive( true ); - } - state = ControllerState_NodeOK; - } - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleReplaceFailedNodeResponse -( - uint8* _data -) -{ - bool res = true; - ControllerState state = ControllerState_InProgress; - if( _data[2] ) - { - // Command failed - Log::Write( LogLevel_Warning, GetNodeNumber( m_currentMsg ), "WARNING: Received reply to FUNC_ID_ZW_REPLACE_FAILED_NODE - command failed" ); - state = ControllerState_Failed; - res = false; - } - else - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_REPLACE_FAILED_NODE - command in progress" ); - } - - UpdateControllerState( state ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSendDataResponse -( - uint8* _data, - bool _replication -) -{ - if( _data[2] ) - { - Log::Write( LogLevel_Detail, GetNodeNumber( m_currentMsg ), " %s delivered to Z-Wave stack", _replication ? "ZW_REPLICATION_SEND_DATA" : "ZW_SEND_DATA" ); - } - else - { - Log::Write( LogLevel_Error, GetNodeNumber( m_currentMsg ), "ERROR: %s could not be delivered to Z-Wave stack", _replication ? "ZW_REPLICATION_SEND_DATA" : "ZW_SEND_DATA" ); - m_nondelivery++; - if( Node* node = GetNodeUnsafe( GetNodeNumber( m_currentMsg ) ) ) - { - node->m_sentFailed++; - } - } -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleGetRoutingInfoResponse -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_GET_ROUTING_INFO" ); - - if( Node* node = GetNode( GetNodeNumber( m_currentMsg ) ) ) - { - // copy the 29-byte bitmap received (29*8=232 possible nodes) into this node's neighbors member variable - memcpy( node->m_neighbors, &_data[2], 29 ); - ReleaseNodes(); - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), " Neighbors of this node are:" ); - bool bNeighbors = false; - for( int by=0; by<29; by++ ) - { - for( int bi=0; bi<8; bi++ ) - { - if( (_data[2+by] & (0x01< -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSendDataRequest -( - uint8* _data, - bool _replication -) -{ - uint8 nodeId = GetNodeNumber( m_currentMsg ); - Log::Write( LogLevel_Detail, nodeId, " %s Request with callback ID 0x%.2x received (expected 0x%.2x)", _replication ? "ZW_REPLICATION_SEND_DATA" : "ZW_SEND_DATA", _data[2], m_expectedCallbackId ); - - if( _data[2] != m_expectedCallbackId ) - { - // Wrong callback ID - m_callbacks++; - Log::Write( LogLevel_Warning, nodeId, "WARNING: Unexpected Callback ID received" ); - } - else - { - Node* node = GetNodeUnsafe( nodeId ); - if( node != NULL ) - { - if( _data[3] != 0 ) - { - node->m_sentFailed++; - } - else - { - node->m_lastRequestRTT = -node->m_sentTS.TimeRemaining(); - - if( node->m_averageRequestRTT ) - { - // if the average has been established, update by averaging the average and the last RTT - node->m_averageRequestRTT = ( node->m_averageRequestRTT + node->m_lastRequestRTT ) >> 1; - } - else - { - // if this is the first observed RTT, set the average to this value - node->m_averageRequestRTT = node->m_lastRequestRTT; - } - Log::Write(LogLevel_Info, nodeId, "Request RTT %d Average Request RTT %d", node->m_lastRequestRTT, node->m_averageRequestRTT ); - } - } - - // We do this here since HandleErrorResponse/MoveMessagesToWakeUpQueue can delete m_currentMsg - if( m_currentMsg->IsNoOperation() ) - { - Notification* notification = new Notification( Notification::Type_Notification ); - notification->SetHomeAndNodeIds( m_homeId, GetNodeNumber( m_currentMsg) ); - notification->SetNotification( Notification::Code_NoOperation ); - QueueNotification( notification ); - } - - // Callback ID matches our expectation - if( _data[3] != 0 ) - { - if( !HandleErrorResponse( _data[3], nodeId, _replication ? "ZW_REPLICATION_END_DATA" : "ZW_SEND_DATA", !_replication ) ) - { - if( m_currentMsg->IsNoOperation() && node != NULL && - ( node->GetCurrentQueryStage() == Node::QueryStage_Probe || - node->GetCurrentQueryStage() == Node::QueryStage_Probe1 ) ) - { - node->QueryStageRetry( node->GetCurrentQueryStage(), 3 ); - } - } - } - else if( node != NULL ) - { - // If WakeUpNoMoreInformation request succeeds, update our status - if( m_currentMsg->IsWakeUpNoMoreInformationCommand() ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - // Mark the node as asleep - wakeUp->SetAwake( false ); - } - } - // If node is not alive, mark it alive now - if( !node->IsNodeAlive() ) - { - node->SetNodeAlive( true ); - } - } - // Command reception acknowledged by node, error or not - m_expectedCallbackId = 0; - } -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleNetworkUpdateRequest -( - uint8* _data -) -{ - ControllerState state = ControllerState_Failed; - ControllerError error = ControllerError_None; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - switch( _data[3] ) - { - case SUC_UPDATE_DONE: - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_REQUEST_NETWORK_UPDATE: Success" ); - state = ControllerState_Completed; - break; - } - case SUC_UPDATE_ABORT: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_REQUEST_NETWORK_UPDATE: Failed - Error. Process aborted." ); - error = ControllerError_Failed; - break; - } - case SUC_UPDATE_WAIT: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_REQUEST_NETWORK_UPDATE: Failed - SUC is busy." ); - error = ControllerError_Busy; - break; - } - case SUC_UPDATE_DISABLED: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_REQUEST_NETWORK_UPDATE: Failed - SUC is disabled." ); - error = ControllerError_Disabled; - break; - } - case SUC_UPDATE_OVERFLOW: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_REQUEST_NETWORK_UPDATE: Failed - Overflow. Full replication required." ); - error = ControllerError_Overflow; - break; - } - default: - { - } - } - - UpdateControllerState( state, error ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleAddNodeToNetworkRequest -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "FUNC_ID_ZW_ADD_NODE_TO_NETWORK:" ); - CommonAddNodeStatusRequestHandler( FUNC_ID_ZW_ADD_NODE_TO_NETWORK, _data ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleRemoveNodeFromNetworkRequest -( - uint8* _data -) -{ - //uint8 nodeId = GetNodeNumber( m_currentMsg ); - if( m_currentControllerCommand == NULL ) - { - return; - } - ControllerState state = m_currentControllerCommand->m_controllerState; - Log::Write( LogLevel_Info, "FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK:" ); - - switch( _data[3] ) - { - case REMOVE_NODE_STATUS_LEARN_READY: - { - Log::Write( LogLevel_Info, "REMOVE_NODE_STATUS_LEARN_READY" ); - state = ControllerState_Waiting; - m_currentControllerCommand->m_controllerCommandNode = 0; - break; - } - case REMOVE_NODE_STATUS_NODE_FOUND: - { - Log::Write( LogLevel_Info, "REMOVE_NODE_STATUS_NODE_FOUND" ); - state = ControllerState_InProgress; - break; - } - case REMOVE_NODE_STATUS_REMOVING_SLAVE: - { - Log::Write( LogLevel_Info, "REMOVE_NODE_STATUS_REMOVING_SLAVE" ); - if (_data[4] != 0) - { - Log::Write( LogLevel_Info, "Removing node ID %d", _data[4] ); - m_currentControllerCommand->m_controllerCommandNode = _data[4]; - } - else - { - Log::Write( LogLevel_Warning, "Remove Node Failed - NodeID 0 Returned"); - state = ControllerState_Failed; - } - break; - } - case REMOVE_NODE_STATUS_REMOVING_CONTROLLER: - { - Log::Write( LogLevel_Info, "REMOVE_NODE_STATUS_REMOVING_CONTROLLER" ); - m_currentControllerCommand->m_controllerCommandNode = _data[4]; - if( m_currentControllerCommand->m_controllerCommandNode == 0 ) // Some controllers don't return node number - { - if( _data[5] >= 3 ) - { - LockNodes(); - for( int i=0; i<256; i++ ) - { - if( m_nodes[i] == NULL ) - { - continue; - } - // Ignore primary controller - if( m_nodes[i]->m_nodeId == m_nodeId ) - { - continue; - } - // See if we can match another way - if( m_nodes[i]->m_basic == _data[6] && - m_nodes[i]->m_generic == _data[7] && - m_nodes[i]->m_specific == _data[8] ) - { - if( m_currentControllerCommand->m_controllerCommandNode != 0 ) - { - Log::Write( LogLevel_Info, "Alternative controller lookup found more then one match. Using the first one found." ); - } - else - { - m_currentControllerCommand->m_controllerCommandNode = m_nodes[i]->m_nodeId; - } - } - } - ReleaseNodes(); - } - else - { - Log::Write( LogLevel_Warning, "WARNING: Node is 0 but not enough data to perform alternative match." ); - } - } - else - { - m_currentControllerCommand->m_controllerCommandNode = _data[4]; - } - Log::Write( LogLevel_Info, "Removing controller ID %d", m_currentControllerCommand->m_controllerCommandNode ); - break; - } - case REMOVE_NODE_STATUS_DONE: - { - Log::Write( LogLevel_Info, "REMOVE_NODE_STATUS_DONE" ); - if( !m_currentControllerCommand->m_controllerCommandDone ) - { - - // Remove Node Stop calls back through here so make sure - // we do't do it again. - UpdateControllerState( ControllerState_Completed ); - AddNodeStop( FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK ); - if ( m_currentControllerCommand->m_controllerCommandNode == 0 ) // never received "removing" update - { - if ( _data[4] != 0 ) // but message has the clue - { - m_currentControllerCommand->m_controllerCommandNode = _data[4]; - } - } - - if ( m_currentControllerCommand->m_controllerCommandNode != 0 && m_currentControllerCommand->m_controllerCommandNode != 0xff ) - { - LockNodes(); - delete m_nodes[m_currentControllerCommand->m_controllerCommandNode]; - m_nodes[m_currentControllerCommand->m_controllerCommandNode] = NULL; - ReleaseNodes(); - - Notification* notification = new Notification( Notification::Type_NodeRemoved ); - notification->SetHomeAndNodeIds( m_homeId, m_currentControllerCommand->m_controllerCommandNode ); - QueueNotification( notification ); - } - } - return; - } - case REMOVE_NODE_STATUS_FAILED: - { - AddNodeStop( FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK ); - Log::Write( LogLevel_Warning, "WARNING: REMOVE_NODE_STATUS_FAILED" ); - state = ControllerState_Failed; - break; - } - default: - { - break; - } - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleControllerChangeRequest -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "FUNC_ID_ZW_CONTROLLER_CHANGE:" ); - CommonAddNodeStatusRequestHandler( FUNC_ID_ZW_CONTROLLER_CHANGE, _data ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleCreateNewPrimaryRequest -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "FUNC_ID_ZW_CREATE_NEW_PRIMARY:" ); - CommonAddNodeStatusRequestHandler( FUNC_ID_ZW_CREATE_NEW_PRIMARY, _data ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSetLearnModeRequest -( - uint8* _data -) -{ - uint8 nodeId = GetNodeNumber( m_currentMsg ); - if( m_currentControllerCommand == NULL ) - { - return; - } - ControllerState state = m_currentControllerCommand->m_controllerState; - Log::Write( LogLevel_Info, nodeId, "FUNC_ID_ZW_SET_LEARN_MODE:" ); - - switch( _data[3] ) - { - case LEARN_MODE_STARTED: - { - Log::Write( LogLevel_Info, nodeId, "LEARN_MODE_STARTED" ); - state = ControllerState_Waiting; - break; - } - case LEARN_MODE_DONE: - { - Log::Write( LogLevel_Info, nodeId, "LEARN_MODE_DONE" ); - state = ControllerState_Completed; - - // Stop learn mode - Msg* msg = new Msg( "End Learn Mode", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, false, false ); - msg->Append( 0 ); - SendMsg( msg, MsgQueue_Command ); - - // Rebuild all the node info. Group and scene data that we stored - // during replication will be applied as we discover each node. - InitAllNodes(); - break; - } - case LEARN_MODE_FAILED: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: LEARN_MODE_FAILED" ); - state = ControllerState_Failed; - - // Stop learn mode - Msg* msg = new Msg( "End Learn Mode", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, false, false ); - msg->Append( 0 ); - SendMsg( msg, MsgQueue_Command ); - - // Rebuild all the node info, since it may have been partially - // updated by the failed command. Group and scene data that we - // stored during replication will be applied as we discover each node. - InitAllNodes(); - break; - } - case LEARN_MODE_DELETED: - { - Log::Write( LogLevel_Info, nodeId, "LEARN_MODE_DELETED" ); - state = ControllerState_Failed; - // Stop learn mode - Msg* msg = new Msg( "End Learn Mode", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, false, false ); - msg->Append( 0 ); - SendMsg( msg, MsgQueue_Command ); - break; - } - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleRemoveFailedNodeRequest -( - uint8* _data -) -{ - ControllerState state = ControllerState_Completed; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - switch( _data[3] ) - { - case FAILED_NODE_OK: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_REMOVE_FAILED_NODE_ID - Node %d is OK, so command failed", m_currentControllerCommand->m_controllerCommandNode ); - state = ControllerState_NodeOK; - break; - } - case FAILED_NODE_REMOVED: - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_REMOVE_FAILED_NODE_ID - node %d successfully moved to failed nodes list", m_currentControllerCommand->m_controllerCommandNode ); - state = ControllerState_Completed; - - LockNodes(); - delete m_nodes[m_currentControllerCommand->m_controllerCommandNode]; - m_nodes[m_currentControllerCommand->m_controllerCommandNode] = NULL; - ReleaseNodes(); - - Notification* notification = new Notification( Notification::Type_NodeRemoved ); - notification->SetHomeAndNodeIds( m_homeId, m_currentControllerCommand->m_controllerCommandNode ); - QueueNotification( notification ); - - break; - } - case FAILED_NODE_NOT_REMOVED: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_REMOVE_FAILED_NODE_ID - unable to move node %d to failed nodes list", m_currentControllerCommand->m_controllerCommandNode ); - state = ControllerState_Failed; - break; - } - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleReplaceFailedNodeRequest -( - uint8* _data -) -{ - ControllerState state = ControllerState_Completed; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - switch( _data[3] ) - { - case FAILED_NODE_OK: - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_REPLACE_FAILED_NODE - Node is OK, so command failed" ); - state = ControllerState_NodeOK; - break; - } - case FAILED_NODE_REPLACE_WAITING: - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_REPLACE_FAILED_NODE - Waiting for new node" ); - state = ControllerState_Waiting; - break; - } - case FAILED_NODE_REPLACE_DONE: - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_REPLACE_FAILED_NODE - Node successfully replaced" ); - state = ControllerState_Completed; - - // Request new node info for this device - if( m_currentControllerCommand != NULL ) - { - InitNode( m_currentControllerCommand->m_controllerCommandNode, true ); - } - break; - } - case FAILED_NODE_REPLACE_FAILED: - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_REPLACE_FAILED_NODE - Node replacement failed" ); - state = ControllerState_Failed; - break; - } - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleApplicationCommandHandlerRequest -( - uint8* _data -) -{ - uint8 status = _data[2]; - uint8 nodeId = _data[3]; - uint8 classId = _data[5]; - Node* node = GetNodeUnsafe( nodeId ); - - if( ( status & RECEIVE_STATUS_ROUTED_BUSY ) != 0 ) - { - m_routedbusy++; - } - if( ( status & RECEIVE_STATUS_TYPE_BROAD ) != 0 ) - { - m_broadcastReadCnt++; - } - if( node != NULL ) - { - node->m_receivedCnt++; - node->m_errors = 0; - int cmp = memcmp( _data, node->m_lastReceivedMessage, sizeof(node->m_lastReceivedMessage)); - if( cmp == 0 && node->m_receivedTS.TimeRemaining() > -500 ) - { - // if the exact same sequence of bytes are received within 500ms - node->m_receivedDups++; - } - else - { - memcpy( node->m_lastReceivedMessage, _data, sizeof(node->m_lastReceivedMessage) ); - } - node->m_receivedTS.SetTime(); - if( m_expectedReply == FUNC_ID_APPLICATION_COMMAND_HANDLER && m_expectedNodeId == nodeId ) - { - // Need to confirm this is the correct response to the last sent request. - // At least ignore any received messages prior to the send data request. - node->m_lastResponseRTT = -node->m_sentTS.TimeRemaining(); - - if( node->m_averageResponseRTT ) - { - // if the average has been established, update by averaging the average and the last RTT - node->m_averageResponseRTT = ( node->m_averageResponseRTT + node->m_lastResponseRTT ) >> 1; - } - else - { - // if this is the first observed RTT, set the average to this value - node->m_averageResponseRTT = node->m_lastResponseRTT; - } - Log::Write(LogLevel_Info, nodeId, "Response RTT %d Average Response RTT %d", node->m_lastResponseRTT, node->m_averageResponseRTT ); - } - else - { - node->m_receivedUnsolicited++; - } - if ( !node->IsNodeAlive() ) - { - node->SetNodeAlive( true ); - } - } - if( ApplicationStatus::StaticGetCommandClassId() == classId ) - { - //TODO: Test this class function or implement - } - else if( ControllerReplication::StaticGetCommandClassId() == classId ) - { - if( m_controllerReplication && m_currentControllerCommand && ( ControllerCommand_ReceiveConfiguration == m_currentControllerCommand->m_controllerCommand ) ) - { - m_controllerReplication->HandleMsg( &_data[6], _data[4] ); - - UpdateControllerState( ControllerState_InProgress ); - } - } - else - { - // Allow the node to handle the message itself - if( node != NULL ) - { - node->ApplicationCommandHandler( _data ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface when in promiscuous mode. -//----------------------------------------------------------------------------- -void Driver::HandlePromiscuousApplicationCommandHandlerRequest -( - uint8* _data -) -{ - //uint8 nodeId = _data[3]; - //uint8 len = _data[4]; - //uint8 classId = _data[5]; - //uint8 destNodeId = _data[5+len]; -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleAssignReturnRouteRequest -( - uint8* _data -) -{ - ControllerState state; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - if( m_currentControllerCommand == NULL ) - { - return; - } - if( _data[3] ) - { - // Failed - HandleErrorResponse( _data[3], m_currentControllerCommand->m_controllerCommandNode, "ZW_ASSIGN_RETURN_ROUTE", true ); - state = ControllerState_Failed; - } - else - { - // Success - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_ASSIGN_RETURN_ROUTE for node %d - SUCCESS", m_currentControllerCommand->m_controllerCommandNode ); - state = ControllerState_Completed; - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleDeleteReturnRouteRequest -( - uint8* _data -) -{ - ControllerState state; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - if( m_currentControllerCommand == NULL ) - { - return; - } - if( _data[3] ) - { - // Failed - HandleErrorResponse( _data[3], m_currentControllerCommand->m_controllerCommandNode, "ZW_DELETE_RETURN_ROUTE", true ); - state = ControllerState_Failed; - } - else - { - // Success - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_DELETE_RETURN_ROUTE for node %d - SUCCESS", m_currentControllerCommand->m_controllerCommandNode ); - state = ControllerState_Completed; - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSendNodeInformationRequest -( - uint8* _data -) -{ - ControllerState state; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - if( m_currentControllerCommand == NULL ) - { - return; - } - if( _data[3] ) - { - // Failed - HandleErrorResponse( _data[3], m_currentControllerCommand->m_controllerCommandNode, "ZW_SEND_NODE_INFORMATION" ); - state = ControllerState_Failed; - } - else - { - // Success - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_SEND_NODE_INFORMATION - SUCCESS" ); - state = ControllerState_Completed; - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleNodeNeighborUpdateRequest -( - uint8* _data -) -{ - uint8 nodeId = GetNodeNumber( m_currentMsg ); - ControllerState state = ControllerState_Normal; - switch( _data[3] ) - { - case REQUEST_NEIGHBOR_UPDATE_STARTED: - { - Log::Write( LogLevel_Info, nodeId, "REQUEST_NEIGHBOR_UPDATE_STARTED" ); - state = ControllerState_InProgress; - break; - } - case REQUEST_NEIGHBOR_UPDATE_DONE: - { - Log::Write( LogLevel_Info, nodeId, "REQUEST_NEIGHBOR_UPDATE_DONE" ); - state = ControllerState_Completed; - - // We now request the neighbour information from the - // controller and store it in our node object. - if( m_currentControllerCommand != NULL ) - { - RequestNodeNeighbors( m_currentControllerCommand->m_controllerCommandNode, 0 ); - } - break; - } - case REQUEST_NEIGHBOR_UPDATE_FAILED: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: REQUEST_NEIGHBOR_UPDATE_FAILED" ); - state = ControllerState_Failed; - break; - } - default: - { - break; - } - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleApplicationUpdateRequest -( - uint8* _data -) -{ - bool messageRemoved = false; - uint8 nodeId = _data[3]; - Node* node = GetNodeUnsafe( nodeId ); - - // If node is not alive, mark it alive now - if( node != NULL && !node->IsNodeAlive() ) - { - node->SetNodeAlive( true ); - } - - switch( _data[2] ) - { - case UPDATE_STATE_SUC_ID: - { - Log::Write( LogLevel_Info, nodeId, "UPDATE_STATE_SUC_ID from node %d", nodeId ); - m_SUCNodeId = nodeId; // need to confirm real data here - break; - } - case UPDATE_STATE_DELETE_DONE: - { - Log::Write( LogLevel_Info, nodeId, "** Network change **: Z-Wave node %d was removed", nodeId ); - - LockNodes(); - delete m_nodes[nodeId]; - m_nodes[nodeId] = NULL; - ReleaseNodes(); - - Notification* notification = new Notification( Notification::Type_NodeRemoved ); - notification->SetHomeAndNodeIds( m_homeId, nodeId ); - QueueNotification( notification ); - break; - } - case UPDATE_STATE_NEW_ID_ASSIGNED: - { - Log::Write( LogLevel_Info, nodeId, "** Network change **: ID %d was assigned to a new Z-Wave node", nodeId ); - - // Request the node protocol info (also removes any existing node and creates a new one) - InitNode( nodeId ); - break; - } - case UPDATE_STATE_ROUTING_PENDING: - { - Log::Write( LogLevel_Info, nodeId, "UPDATE_STATE_ROUTING_PENDING from node %d", nodeId ); - break; - } - case UPDATE_STATE_NODE_INFO_REQ_FAILED: - { - Log::Write( LogLevel_Warning, nodeId, "WARNING: FUNC_ID_ZW_APPLICATION_UPDATE: UPDATE_STATE_NODE_INFO_REQ_FAILED received" ); - - // Note: Unhelpfully, the nodeId is always zero in this message. We have to - // assume the message came from the last node to which we sent a request. - if( m_currentMsg ) - { - Node* tnode = GetNodeUnsafe( m_currentMsg->GetTargetNodeId() ); - if( tnode ) - { - // Retry the query twice - tnode->QueryStageRetry( Node::QueryStage_NodeInfo, 2 ); - - // Just in case the failure was due to the node being asleep, we try - // to move its pending messages to its wakeup queue. If it is not - // a sleeping device, this will have no effect. - if( MoveMessagesToWakeUpQueue( tnode->GetNodeId(), true ) ) - { - messageRemoved = true; - } - } - } - break; - } - case UPDATE_STATE_NODE_INFO_REQ_DONE: - { - Log::Write( LogLevel_Info, nodeId, "UPDATE_STATE_NODE_INFO_REQ_DONE from node %d", nodeId ); - break; - } - case UPDATE_STATE_NODE_INFO_RECEIVED: - { - Log::Write( LogLevel_Info, nodeId, "UPDATE_STATE_NODE_INFO_RECEIVED from node %d", nodeId ); - if( node ) - { - node->UpdateNodeInfo( &_data[8], _data[4] - 3 ); - } - break; - } - } - - if( messageRemoved ) - { - m_waitingForAck = false; - m_expectedCallbackId = 0; - m_expectedReply = 0; - m_expectedCommandClassId = 0; - m_expectedNodeId = 0; - } - - return messageRemoved; -} - -//----------------------------------------------------------------------------- -// -// Handle common AddNode processing for many similar commands -//----------------------------------------------------------------------------- -void Driver::CommonAddNodeStatusRequestHandler -( - uint8 _funcId, - uint8* _data -) -{ - uint8 nodeId = GetNodeNumber( m_currentMsg ); - ControllerState state = ControllerState_Normal; - if( m_currentControllerCommand != NULL ) - { - state = m_currentControllerCommand->m_controllerState; - } - switch( _data[3] ) - { - case ADD_NODE_STATUS_LEARN_READY: - { - Log::Write( LogLevel_Info, nodeId, "ADD_NODE_STATUS_LEARN_READY" ); - m_currentControllerCommand->m_controllerAdded = false; - state = ControllerState_Waiting; - break; - } - case ADD_NODE_STATUS_NODE_FOUND: - { - Log::Write( LogLevel_Info, nodeId, "ADD_NODE_STATUS_NODE_FOUND" ); - state = ControllerState_InProgress; - break; - } - case ADD_NODE_STATUS_ADDING_SLAVE: - { - Log::Write( LogLevel_Info, nodeId, "ADD_NODE_STATUS_ADDING_SLAVE" ); - Log::Write( LogLevel_Info, nodeId, "Adding node ID %d", _data[4] ); - /* Discovered all the CC's are sent in this packet as well: - * position description - * 4 - Node ID - * 5 - Length - * 6 - Basic Device Class - * 7 - Generic Device Class - * 8 - Specific Device Class - * 9 to Length - Command Classes - * Last pck - CRC - */ - if( m_currentControllerCommand != NULL ) - { - m_currentControllerCommand->m_controllerAdded = false; - m_currentControllerCommand->m_controllerCommandNode = _data[4]; - } - AddNodeStop( _funcId ); - sleep(1); - break; - } - case ADD_NODE_STATUS_ADDING_CONTROLLER: - { - Log::Write( LogLevel_Info, nodeId, "ADD_NODE_STATUS_ADDING_CONTROLLER"); - Log::Write( LogLevel_Info, nodeId, "Adding controller ID %d", _data[4] ); - /* Discovered all the CC's are sent in this packet as well: - * position description - * 4 - Node ID - * 5 - Length - * 6 - Basic Device Class - * 7 - Generic Device Class - * 8 - Specific Device Class - * 9 to Length - Command Classes - * Last pck - CRC - */ - - - if( m_currentControllerCommand != NULL ) - { - m_currentControllerCommand->m_controllerAdded = true; - m_currentControllerCommand->m_controllerCommandNode = _data[4]; - } - AddNodeStop( _funcId ); - break; - } - case ADD_NODE_STATUS_PROTOCOL_DONE: - { - Log::Write( LogLevel_Info, nodeId, "ADD_NODE_STATUS_PROTOCOL_DONE" ); - // We added a device. - // Get the controller out of add mode to avoid accidentally adding other devices. - // We used to call replication here. - AddNodeStop( _funcId ); - break; - } - case ADD_NODE_STATUS_DONE: - { - Log::Write( LogLevel_Info, nodeId, "ADD_NODE_STATUS_DONE" ); - state = ControllerState_Completed; - if( m_currentControllerCommand != NULL && m_currentControllerCommand->m_controllerCommandNode != 0xff ) - { - InitNode( m_currentControllerCommand->m_controllerCommandNode, true ); - } - - // Not sure about the new controller function here. - if( _funcId != FUNC_ID_ZW_ADD_NODE_TO_NETWORK && m_currentControllerCommand != NULL && m_currentControllerCommand->m_controllerAdded ) - { - // Rebuild all the node info. Group and scene data that we stored - // during replication will be applied as we discover each node. - InitAllNodes(); - } - break; - } - case ADD_NODE_STATUS_FAILED: - { - Log::Write( LogLevel_Info, nodeId, "ADD_NODE_STATUS_FAILED" ); - state = ControllerState_Failed; - - // Remove the AddNode command from the queue - RemoveCurrentMsg(); - - // Get the controller out of add mode to avoid accidentally adding other devices. - AddNodeStop( _funcId ); - break; - } - default: - { - break; - } - } - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// Polling Z-Wave devices -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Enable polling of a value -//----------------------------------------------------------------------------- -bool Driver::EnablePoll -( - ValueID const &_valueId, - uint8 const _intensity -) -{ - // make sure the polling thread doesn't lock the node while we're in this function - m_pollMutex->Lock(); - - // confirm that this node exists - uint8 nodeId = _valueId.GetNodeId(); - Node* node = GetNode( nodeId ); - if( node != NULL ) - { - // confirm that this value is in the node's value store - if( Value* value = node->GetValue( _valueId ) ) - { - // update the value's pollIntensity - value->SetPollIntensity( _intensity ); - - // Add the valueid to the polling list - // See if the node is already in the poll list. - for( list::iterator it = m_pollList.begin(); it != m_pollList.end(); ++it ) - { - if( (*it).m_id == _valueId ) - { - // It is already in the poll list, so we have nothing to do. - Log::Write( LogLevel_Detail, "EnablePoll not required to do anything (value is already in the poll list)" ); - value->Release(); - m_pollMutex->Unlock(); - ReleaseNodes(); - return true; - } - } - - // Not in the list, so we add it - PollEntry pe; - pe.m_id = _valueId; - pe.m_pollCounter = value->GetPollIntensity(); - m_pollList.push_back( pe ); - value->Release(); - m_pollMutex->Unlock(); - ReleaseNodes(); - - // send notification to indicate polling is enabled - Notification* notification = new Notification( Notification::Type_PollingEnabled ); - notification->SetHomeAndNodeIds( m_homeId, _valueId.GetNodeId() ); - QueueNotification( notification ); - Log::Write( LogLevel_Info, nodeId, "EnablePoll for HomeID 0x%.8x, value(cc=0x%02x,in=0x%02x,id=0x%02x)--poll list has %d items", - _valueId.GetHomeId(), _valueId.GetCommandClassId(), _valueId.GetIndex(), _valueId.GetInstance(), m_pollList.size() ); - return true; - } - - // allow the poll thread to continue - m_pollMutex->Unlock(); - ReleaseNodes(); - - Log::Write( LogLevel_Info, nodeId, "EnablePoll failed - value not found for node %d", nodeId ); - return false; - } - - // allow the poll thread to continue - m_pollMutex->Unlock(); - - Log::Write( LogLevel_Info, "EnablePoll failed - node %d not found", nodeId ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Disable polling of a node -//----------------------------------------------------------------------------- -bool Driver::DisablePoll -( - ValueID const &_valueId -) -{ - // make sure the polling thread doesn't lock the node while we're in this function - m_pollMutex->Lock(); - - // confirm that this node exists - uint8 nodeId = _valueId.GetNodeId(); - Node* node = GetNode( nodeId ); - if( node != NULL) - { - // See if the value is already in the poll list. - for( list::iterator it = m_pollList.begin(); it != m_pollList.end(); ++it ) - { - if( (*it).m_id == _valueId ) - { - // Found it - // remove it from the poll list - m_pollList.erase( it ); - - // get the value object and reset pollIntensity to zero (indicating no polling) - Value* value = GetValue( _valueId ); - if (!value) - continue; - value->SetPollIntensity( 0 ); - value->Release(); - m_pollMutex->Unlock(); - ReleaseNodes(); - - // send notification to indicate polling is disabled - Notification* notification = new Notification( Notification::Type_PollingDisabled ); - notification->SetHomeAndNodeIds( m_homeId, _valueId.GetNodeId() ); - QueueNotification( notification ); - Log::Write( LogLevel_Info, nodeId, "DisablePoll for HomeID 0x%.8x, value(cc=0x%02x,in=0x%02x,id=0x%02x)--poll list has %d items", - _valueId.GetHomeId(), _valueId.GetCommandClassId(), _valueId.GetIndex(), _valueId.GetInstance(), m_pollList.size() ); - return true; - } - } - - // Not in the list - m_pollMutex->Unlock(); - ReleaseNodes(); - Log::Write( LogLevel_Info, nodeId, "DisablePoll failed - value not on list"); - return false; - } - - // allow the poll thread to continue - m_pollMutex->Unlock(); - - Log::Write( LogLevel_Info, "DisablePoll failed - node %d not found", nodeId ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Check polling status of a value -//----------------------------------------------------------------------------- -bool Driver::isPolled -( - ValueID const &_valueId -) -{ - bool bPolled; - - // make sure the polling thread doesn't lock the node while we're in this function - m_pollMutex->Lock(); - - Value* value = GetValue( _valueId ); - if( value && value->GetPollIntensity() != 0 ) - { - bPolled = true; - } - else - { - bPolled = false; - } - - if (value) value->Release(); - - /* - * This code is retained for the moment as a belt-and-suspenders test to confirm that - * the pollIntensity member of each value and the pollList contents do not get out - * of sync. - */ - // confirm that this node exists - uint8 nodeId = _valueId.GetNodeId(); - Node* node = GetNode( nodeId ); - if( node != NULL) - { - - // See if the value is already in the poll list. - for( list::iterator it = m_pollList.begin(); it != m_pollList.end(); ++it ) - { - if( (*it).m_id == _valueId ) - { - // Found it - if( bPolled ) - { - m_pollMutex->Unlock(); - ReleaseNodes(); - return true; - } - else - { - Log::Write( LogLevel_Error, nodeId, "IsPolled setting for valueId 0x%016x is not consistent with the poll list", _valueId.GetId() ); - } - } - } - - // Not in the list - - if( !bPolled ) - { - m_pollMutex->Unlock(); - ReleaseNodes(); - return false; - } - else - { - Log::Write( LogLevel_Error, nodeId, "IsPolled setting for valueId 0x%016x is not consistent with the poll list", _valueId.GetId() ); - } - } - - // allow the poll thread to continue - m_pollMutex->Unlock(); - - Log::Write( LogLevel_Info, "isPolled failed - node %d not found (the value reported that it is%s polled)", nodeId, bPolled?"":" not" ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the intensity with which this value is polled -//----------------------------------------------------------------------------- -void Driver::SetPollIntensity -( - ValueID const &_valueId, - uint8 const _intensity -) -{ - // make sure the polling thread doesn't lock the value while we're in this function - m_pollMutex->Lock(); - - Value* value = GetValue( _valueId ); - if (!value) - return; - value->SetPollIntensity( _intensity ); - - value->Release(); - m_pollMutex->Unlock(); -} - -//----------------------------------------------------------------------------- -// -// Entry point of the thread for poll Z-Wave devices -//----------------------------------------------------------------------------- -void Driver::PollThreadEntryPoint -( - Event* _exitEvent, - void* _context -) -{ - Driver* driver = (Driver*)_context; - if( driver ) - { - driver->PollThreadProc( _exitEvent ); - } -} - -//----------------------------------------------------------------------------- -// -// Thread for poll Z-Wave devices -//----------------------------------------------------------------------------- -void Driver::PollThreadProc -( - Event* _exitEvent -) -{ - while( 1 ) - { - int32 pollInterval = m_pollInterval; - - if( m_awakeNodesQueried && !m_pollList.empty() ) - { - // We only bother getting the lock if the pollList is not empty - m_pollMutex->Lock(); - - // Get the next value to be polled - PollEntry pe = m_pollList.front(); - m_pollList.pop_front(); - ValueID valueId = pe.m_id; - - // only execute this poll if pe.m_pollCounter == 1; otherwise decrement the counter and process the next polled value - if( pe.m_pollCounter != 1) - { - pe.m_pollCounter--; - m_pollList.push_back( pe ); - m_pollMutex->Unlock(); - continue; - } - - // reset the poll counter to the full pollIntensity value and push it at the end of the list - // release the value object referenced; call GetNode to ensure the node objects are locked during this period - (void)GetNode( valueId.GetNodeId() ); - Value* value = GetValue( valueId ); - if (!value) - continue; - pe.m_pollCounter = value->GetPollIntensity(); - m_pollList.push_back( pe ); - value->Release(); - ReleaseNodes(); - - // If the polling interval is for the whole poll list, calculate the time before the next poll, - // so that all polls can take place within the user-specified interval. - if( !m_bIntervalBetweenPolls ) - { - if( pollInterval < 100 ) - { - Log::Write( LogLevel_Info, "The pollInterval setting is only %d, which appears to be a legacy setting. Multiplying by 1000 to convert to ms.", pollInterval ); - pollInterval *= 1000; - } - pollInterval /= (int32) m_pollList.size(); - } - - // Request the state of the value from the node to which it belongs - if( Node* node = GetNode( valueId.GetNodeId() ) ) - { - bool requestState = true; - if( !node->IsListeningDevice() ) - { - // The device is not awake all the time. If it is not awake, we mark it - // as requiring a poll. The poll will be done next time the node wakes up. - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - if( !wakeUp->IsAwake() ) - { - wakeUp->SetPollRequired(); - requestState = false; - } - } - } - - if( requestState ) - { - // Request an update of the value - CommandClass* cc = node->GetCommandClass( valueId.GetCommandClassId() ); - if (cc) { - uint8 index = valueId.GetIndex(); - uint8 instance = valueId.GetInstance(); - Log::Write( LogLevel_Detail, node->m_nodeId, "Polling: %s index = %d instance = %d (poll queue has %d messages)", cc->GetCommandClassName().c_str(), index, instance, m_msgQueue[MsgQueue_Poll].size() ); - cc->RequestValue( 0, index, instance, MsgQueue_Poll ); - } - } - - ReleaseNodes(); - } - - m_pollMutex->Unlock(); - - // Polling messages are only sent when there are no other messages waiting to be sent - // While this makes the polls much more variable and uncertain if some other activity dominates - // a send queue, that may be appropriate - // TODO we can have a debate about whether to test all four queues or just the Poll queue - // Wait until the library isn't actively sending messages (or in the midst of a transaction) - int i32; - int loopCount = 0; - while( !m_msgQueue[MsgQueue_Poll].empty() - || !m_msgQueue[MsgQueue_Send].empty() - || !m_msgQueue[MsgQueue_Command].empty() - || !m_msgQueue[MsgQueue_Query].empty() - || m_currentMsg != NULL ) - { - i32 = Wait::Single( _exitEvent, 10); // test conditions every 10ms - if( i32 == 0 ) - { - // Exit has been called - return; - } - loopCount++; - if( loopCount == 3000*10 ) // 300 seconds worth of delay? Something unusual is going on - { - Log::Write( LogLevel_Warning, "Poll queue hasn't been able to execute for 300 secs or more" ); - Log::QueueDump(); -// assert( 0 ); - } - } - - // ready for next poll...insert the pollInterval delay - i32 = Wait::Single( _exitEvent, pollInterval ); - if( i32 == 0 ) - { - // Exit has been called - return; - } - } - else // poll list is empty or awake nodes haven't been fully queried yet - { - // don't poll just yet, wait for the pollInterval or exit before re-checking to see if the pollList has elements - int32 i32 = Wait::Single( _exitEvent, 500 ); - if( i32 == 0 ) - { - // Exit has been called - return; - } - } - } -} - -//----------------------------------------------------------------------------- -// Retrieving Node information -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Delete all nodes and fetch new node data from the Z-Wave network -//----------------------------------------------------------------------------- -void Driver::InitAllNodes -( -) -{ - // Delete all the node data - LockNodes(); - for( int i=0; i<256; ++i ) - { - if( m_nodes[i] ) - { - delete m_nodes[i]; - m_nodes[i] = NULL; - } - } - ReleaseNodes(); - - // Fetch new node data from the Z-Wave network - m_controller->PlayInitSequence( this ); -} - -//----------------------------------------------------------------------------- -// -// Queue a node to be interrogated for its setup details -//----------------------------------------------------------------------------- -void Driver::InitNode -( - uint8 const _nodeId, - bool newNode -) -{ - // Delete any existing node and replace it with a new one - LockNodes(); - if( m_nodes[_nodeId] ) - { - // Remove the original node - delete m_nodes[_nodeId]; - Notification* notification = new Notification( Notification::Type_NodeRemoved ); - notification->SetHomeAndNodeIds( m_homeId, _nodeId ); - QueueNotification( notification ); - } - - // Add the new node - m_nodes[_nodeId] = new Node( m_homeId, _nodeId ); - if (newNode == true) static_cast(m_nodes[_nodeId])->SetAddingNode(); - ReleaseNodes(); - - Notification* notification = new Notification( Notification::Type_NodeAdded ); - notification->SetHomeAndNodeIds( m_homeId, _nodeId ); - QueueNotification( notification ); - - // Request the node info - m_nodes[_nodeId]->SetQueryStage( Node::QueryStage_ProtocolInfo ); - Log::Write(LogLevel_Info, "Initilizing Node. New Node: %s (%s)", static_cast(m_nodes[_nodeId])->IsAddingNode() ? "true" : "false", newNode ? "true" : "false"); -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a listening device that does not go to sleep -//----------------------------------------------------------------------------- -bool Driver::IsNodeListeningDevice -( - uint8 const _nodeId -) -{ - bool res = false; - if( Node* node = GetNode( _nodeId ) ) - { - res = node->IsListeningDevice(); - ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a listening device that does not go to sleep -//----------------------------------------------------------------------------- -bool Driver::IsNodeFrequentListeningDevice -( - uint8 const _nodeId -) -{ - bool res = false; - if( Node* node = GetNode( _nodeId ) ) - { - res = node->IsFrequentListeningDevice(); - ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a beam capable device. -//----------------------------------------------------------------------------- -bool Driver::IsNodeBeamingDevice -( - uint8 const _nodeId -) -{ - bool res = false; - if( Node* node = GetNode( _nodeId ) ) - { - res = node->IsBeamingDevice(); - ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a routing device that passes messages to other nodes -//----------------------------------------------------------------------------- -bool Driver::IsNodeRoutingDevice -( - uint8 const _nodeId -) -{ - bool res = false; - if( Node* node = GetNode( _nodeId ) ) - { - res = node->IsRoutingDevice(); - ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get the security attribute for a node -//----------------------------------------------------------------------------- -bool Driver::IsNodeSecurityDevice -( - uint8 const _nodeId -) -{ - bool security = false; - if( Node* node = GetNode( _nodeId ) ) - { - security = node->IsSecurityDevice(); - ReleaseNodes(); - } - - return security; -} - -//----------------------------------------------------------------------------- -// -// Get the maximum baud rate of a node's communications -//----------------------------------------------------------------------------- -uint32 Driver::GetNodeMaxBaudRate -( - uint8 const _nodeId -) -{ - uint32 baud = 0; - if( Node* node = GetNode( _nodeId ) ) - { - baud = node->GetMaxBaudRate(); - ReleaseNodes(); - } - - return baud; -} - -//----------------------------------------------------------------------------- -// -// Get the version number of a node -//----------------------------------------------------------------------------- -uint8 Driver::GetNodeVersion -( - uint8 const _nodeId -) -{ - uint8 version = 0; - if( Node* node = GetNode( _nodeId ) ) - { - version = node->GetVersion(); - ReleaseNodes(); - } - - return version; -} - -//----------------------------------------------------------------------------- -// -// Get the security byte of a node -//----------------------------------------------------------------------------- -uint8 Driver::GetNodeSecurity -( - uint8 const _nodeId -) -{ - uint8 security = 0; - if( Node* node = GetNode( _nodeId ) ) - { - security = node->GetSecurity(); - ReleaseNodes(); - } - - return security; -} - -//----------------------------------------------------------------------------- -// -// Get the basic type of a node -//----------------------------------------------------------------------------- -uint8 Driver::GetNodeBasic -( - uint8 const _nodeId -) -{ - uint8 basic = 0; - if( Node* node = GetNode( _nodeId ) ) - { - basic = node->GetBasic(); - ReleaseNodes(); - } - - return basic; -} - -//----------------------------------------------------------------------------- -// -// Get the generic type of a node -//----------------------------------------------------------------------------- -uint8 Driver::GetNodeGeneric -( - uint8 const _nodeId -) -{ - uint8 genericType = 0; - if( Node* node = GetNode( _nodeId ) ) - { - genericType = node->GetGeneric(); - ReleaseNodes(); - } - - return genericType; -} - -//----------------------------------------------------------------------------- -// -// Get the specific type of a node -//----------------------------------------------------------------------------- -uint8 Driver::GetNodeSpecific -( - uint8 const _nodeId -) -{ - uint8 specific = 0; - if( Node* node = GetNode( _nodeId ) ) - { - specific = node->GetSpecific(); - ReleaseNodes(); - } - - return specific; -} - -//----------------------------------------------------------------------------- -// -// Get the basic/generic/specific type of the specified node -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeType -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetType(); - ReleaseNodes(); - return str; - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Gets the neighbors for a node -//----------------------------------------------------------------------------- -uint32 Driver::GetNodeNeighbors -( - uint8 const _nodeId, - uint8** o_neighbors -) -{ - uint32 numNeighbors = 0; - if( Node* node = GetNode( _nodeId ) ) - { - numNeighbors = node->GetNeighbors( o_neighbors ); - ReleaseNodes(); - } - - return numNeighbors; -} - -//----------------------------------------------------------------------------- -// -// Get the manufacturer name for the node with the specified ID -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeManufacturerName -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetManufacturerName(); - ReleaseNodes(); - return str; - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Get the product name for the node with the specified ID -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeProductName -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetProductName(); - ReleaseNodes(); - return str; - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Get the user-editable name for the node with the specified ID -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeName -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetNodeName(); - ReleaseNodes(); - return str; - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Get the user-editable string for location of the specified node -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeLocation -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetLocation(); - ReleaseNodes(); - return str; - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Get the manufacturer Id string value with the specified ID -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeManufacturerId -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetManufacturerId(); - ReleaseNodes(); - return str; - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Get the product type string value with the specified ID -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeProductType -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetProductType(); - ReleaseNodes(); - return str; - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Get the product Id string value with the specified ID -// Returns a copy of the string rather than a const ref for thread safety -//----------------------------------------------------------------------------- -string Driver::GetNodeProductId -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - string str = node->GetProductId(); - ReleaseNodes(); - return str; - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Set the manufacturer name for the node with the specified ID -//----------------------------------------------------------------------------- -void Driver::SetNodeManufacturerName -( - uint8 const _nodeId, - string const& _manufacturerName -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->SetManufacturerName( _manufacturerName ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Set the product name string value with the specified ID -//----------------------------------------------------------------------------- -void Driver::SetNodeProductName -( - uint8 const _nodeId, - string const& _productName -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->SetProductName( _productName ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Set the node name string value with the specified ID -//----------------------------------------------------------------------------- -void Driver::SetNodeName -( - uint8 const _nodeId, - string const& _nodeName -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->SetNodeName( _nodeName ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Set the location string value with the specified ID -//----------------------------------------------------------------------------- -void Driver::SetNodeLocation -( - uint8 const _nodeId, - string const& _location -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->SetLocation( _location ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Helper to set the node level through the basic command class -//----------------------------------------------------------------------------- -void Driver::SetNodeLevel -( - uint8 const _nodeId, - uint8 const _level -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->SetLevel( _level ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Helper to set the node on through the basic command class -//----------------------------------------------------------------------------- -void Driver::SetNodeOn -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->SetNodeOn(); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Helper to set the node off through the basic command class -//----------------------------------------------------------------------------- -void Driver::SetNodeOff -( - uint8 const _nodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->SetNodeOff(); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Get a pointer to a Value object for the specified ValueID -//----------------------------------------------------------------------------- -Value* Driver::GetValue -( - ValueID const& _id -) -{ - // This method is only called by code that has already locked the node - if( Node* node = m_nodes[_id.GetNodeId()] ) - { - return node->GetValue( _id ); - } - - return NULL; -} - -//----------------------------------------------------------------------------- -// Controller commands -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Reset controller and erase all node information -//----------------------------------------------------------------------------- -void Driver::ResetController -( - Event* _evt -) -{ - m_controllerResetEvent = _evt; - Log::Write( LogLevel_Info, "Reset controller and erase all node information"); - Msg* msg = new Msg( "Reset controller and erase all node information", 0xff, REQUEST, FUNC_ID_ZW_SET_DEFAULT, true ); - SendMsg( msg, MsgQueue_Command ); -} - -//----------------------------------------------------------------------------- -// -// Soft-reset the Z-Wave controller chip -//----------------------------------------------------------------------------- -void Driver::SoftReset -( -) -{ - Log::Write( LogLevel_Info, "Soft-resetting the Z-Wave controller chip"); - Msg* msg = new Msg( "Soft-resetting the Z-Wave controller chip", 0xff, REQUEST, FUNC_ID_SERIAL_API_SOFT_RESET, false, false ); - SendMsg( msg, MsgQueue_Command ); -} - -//----------------------------------------------------------------------------- -// -// Get the neighbour information for a node from the controller -//----------------------------------------------------------------------------- -void Driver::RequestNodeNeighbors -( - uint8 const _nodeId, - uint32 const _requestFlags -) -{ - if( IsAPICallSupported( FUNC_ID_ZW_GET_ROUTING_INFO ) ) - { - // Note: This is not the same as RequestNodeNeighbourUpdate. This method - // merely requests the controller's current neighbour information and - // the reply will be copied into the relevant Node object for later use. - Log::Write( LogLevel_Detail, GetNodeNumber( m_currentMsg ), "Requesting routing info (neighbor list) for Node %d", _nodeId ); - Msg* msg = new Msg( "Get Routing Info", _nodeId, REQUEST, FUNC_ID_ZW_GET_ROUTING_INFO, false ); - msg->Append( _nodeId ); - msg->Append( 0 ); // don't remove bad links - msg->Append( 0 ); // don't remove non-repeaters - msg->Append( 3 ); // funcid - SendMsg( msg, MsgQueue_Command ); - } -} - -//----------------------------------------------------------------------------- -// -// Start the controller performing one of its network management functions -// Create a ControllerCommand request. -//----------------------------------------------------------------------------- -bool Driver::BeginControllerCommand -( - ControllerCommand _command, - pfnControllerCallback_t _callback, - void* _context, - bool _highPower, - uint8 _nodeId, - uint8 _arg -) -{ - ControllerCommandItem* cci; - MsgQueueItem item; - - if( _command == ControllerCommand_None ) - { - return false; - } - - Log::Write( LogLevel_Detail, _nodeId, "Queuing (%s) %s", c_sendQueueNames[MsgQueue_Controller], c_controllerCommandNames[_command] ); - cci = new ControllerCommandItem(); - cci->m_controllerCommand = _command; - cci->m_controllerCallback = _callback; - cci->m_controllerCallbackContext = _context; - cci->m_highPower = _highPower; - cci->m_controllerCommandNode = _nodeId; - cci->m_controllerCommandArg = _arg; - cci->m_controllerState = ControllerState_Normal; - cci->m_controllerStateChanged = false; - cci->m_controllerCommandDone = false; - - item.m_command = MsgQueueCmd_Controller; - item.m_cci = cci; - - m_sendMutex->Lock(); - m_msgQueue[MsgQueue_Controller].push_back( item ); - m_queueEvent[MsgQueue_Controller]->Set(); - m_sendMutex->Unlock(); - - return true; -} - -//----------------------------------------------------------------------------- -// -// Start the controller performing one of its network management functions -//----------------------------------------------------------------------------- -void Driver::DoControllerCommand -( -) -{ - UpdateControllerState( ControllerState_Starting ); - switch( m_currentControllerCommand->m_controllerCommand ) - { - case ControllerCommand_AddDevice: - { - if( !IsPrimaryController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotPrimary ); - } - else - { - Log::Write( LogLevel_Info, 0, "Add Device" ); - Msg* msg = new Msg( "AddDevice", 0xff, REQUEST, FUNC_ID_ZW_ADD_NODE_TO_NETWORK, true ); - msg->Append( m_currentControllerCommand->m_highPower ? ADD_NODE_ANY | OPTION_HIGH_POWER : ADD_NODE_ANY ); - SendMsg( msg, MsgQueue_Command ); - } - break; - } - case ControllerCommand_CreateNewPrimary: - { - if( IsPrimaryController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotSecondary ); - } - else if( !IsStaticUpdateController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotSUC ); - } - else - { - Log::Write( LogLevel_Info, 0, "Create New Primary" ); - Msg* msg = new Msg( "CreateNewPrimary", 0xff, REQUEST, FUNC_ID_ZW_CREATE_NEW_PRIMARY, true ); - msg->Append( CREATE_PRIMARY_START ); - SendMsg( msg, MsgQueue_Command ); - } - break; - } - case ControllerCommand_ReceiveConfiguration: - { - Log::Write( LogLevel_Info, 0, "Receive Configuration" ); - Msg* msg = new Msg( "ReceiveConfiguration", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, true ); - msg->Append( 0xff ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_RemoveDevice: - { - if( !IsPrimaryController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotPrimary ); - } - else - { - Log::Write( LogLevel_Info, 0, "Remove Device" ); - Msg* msg = new Msg( "RemoveDevice", 0xff, REQUEST, FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK, true ); - msg->Append( m_currentControllerCommand->m_highPower ? REMOVE_NODE_ANY | OPTION_HIGH_POWER : REMOVE_NODE_ANY ); - SendMsg( msg, MsgQueue_Command ); - } - break; - } - case ControllerCommand_HasNodeFailed: - { - Log::Write( LogLevel_Info, 0, "Requesting whether node %d has failed", m_currentControllerCommand->m_controllerCommandNode ); - Msg* msg = new Msg( "Has Node Failed?", 0xff, REQUEST, FUNC_ID_ZW_IS_FAILED_NODE_ID, false ); - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_RemoveFailedNode: - { - Log::Write( LogLevel_Info, 0, "Marking node %d as having failed", m_currentControllerCommand->m_controllerCommandNode ); - Msg* msg = new Msg( "Mark Node As Failed", 0xff, REQUEST, FUNC_ID_ZW_REMOVE_FAILED_NODE_ID, true ); - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_ReplaceFailedNode: - { - Log::Write( LogLevel_Info, 0, "Replace Failed Node %d", m_currentControllerCommand->m_controllerCommandNode ); - Msg* msg = new Msg( "ReplaceFailedNode", 0xff, REQUEST, FUNC_ID_ZW_REPLACE_FAILED_NODE, true ); - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_TransferPrimaryRole: - { - if( !IsPrimaryController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotPrimary ); - } - else - { - Log::Write( LogLevel_Info, 0, "Transfer Primary Role" ); - Msg* msg = new Msg( "TransferPrimaryRole", 0xff, REQUEST, FUNC_ID_ZW_CONTROLLER_CHANGE, true ); - msg->Append( m_currentControllerCommand->m_highPower ? CONTROLLER_CHANGE_START | OPTION_HIGH_POWER : CONTROLLER_CHANGE_START ); - SendMsg( msg, MsgQueue_Command ); - } - break; - } - case ControllerCommand_RequestNetworkUpdate: - { - if( !IsStaticUpdateController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotSUC ); - } - else - { - Log::Write( LogLevel_Info, 0, "Request Network Update" ); - Msg* msg = new Msg( "RequestNetworkUpdate", 0xff, REQUEST, FUNC_ID_ZW_REQUEST_NETWORK_UPDATE, true ); - SendMsg( msg, MsgQueue_Command ); - } - break; - } - case ControllerCommand_RequestNodeNeighborUpdate: - { - if( !IsPrimaryController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotPrimary ); - } - else - { - Log::Write( LogLevel_Info, 0, "Requesting Neighbor Update for node %d", m_currentControllerCommand->m_controllerCommandNode ); - bool opts = IsAPICallSupported( FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE_OPTIONS ); - Msg* msg; - if( opts ) - { - msg = new Msg( "Requesting Neighbor Update", m_currentControllerCommand->m_controllerCommandNode, REQUEST, FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE_OPTIONS, true ); - } - else - { - msg = new Msg( "Requesting Neighbor Update", m_currentControllerCommand->m_controllerCommandNode, REQUEST, FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE, true ); - } - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); - if( opts ) - { - msg->Append( GetTransmitOptions() ); - } - SendMsg( msg, MsgQueue_Command ); - } - break; - } - case ControllerCommand_AssignReturnRoute: - { - Log::Write( LogLevel_Info, 0, "Assigning return route from node %d to node %d", m_currentControllerCommand->m_controllerCommandNode, m_currentControllerCommand->m_controllerCommandArg ); - Msg* msg = new Msg( "Assigning return route", m_currentControllerCommand->m_controllerCommandNode, REQUEST, FUNC_ID_ZW_ASSIGN_RETURN_ROUTE, true ); - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); // from the node - msg->Append( m_currentControllerCommand->m_controllerCommandArg ); // to the specific destination - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_DeleteAllReturnRoutes: - { - Log::Write( LogLevel_Info, 0, "Deleting all return routes from node %d", m_currentControllerCommand->m_controllerCommandNode ); - Msg* msg = new Msg( "Deleting return routes", m_currentControllerCommand->m_controllerCommandNode, REQUEST, FUNC_ID_ZW_DELETE_RETURN_ROUTE, true ); - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); // from the node - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_SendNodeInformation: - { - Log::Write( LogLevel_Info, 0, "Sending a node information frame" ); - Msg* msg = new Msg( "Send Node Information", m_currentControllerCommand->m_controllerCommandNode, REQUEST, FUNC_ID_ZW_SEND_NODE_INFORMATION, true ); - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); // to the node - msg->Append( GetTransmitOptions() ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_ReplicationSend: - { - if( !IsPrimaryController() ) - { - UpdateControllerState( ControllerState_Error, ControllerError_NotPrimary ); - } - else - { - Log::Write( LogLevel_Info, 0, "Replication Send" ); - Msg* msg = new Msg( "ReplicationSend", 0xff, REQUEST, FUNC_ID_ZW_ADD_NODE_TO_NETWORK, true ); - msg->Append( m_currentControllerCommand->m_highPower ? ADD_NODE_CONTROLLER | OPTION_HIGH_POWER : ADD_NODE_CONTROLLER ); - SendMsg( msg, MsgQueue_Command ); - } - break; - } - case ControllerCommand_CreateButton: - { - if( IsBridgeController() ) - { - Node* node = GetNodeUnsafe( m_currentControllerCommand->m_controllerCommandNode ); - if( node != NULL ) - { - if( node->m_buttonMap.find( m_currentControllerCommand->m_controllerCommandArg ) == node->m_buttonMap.end() && m_virtualNeighborsReceived ) - { - bool found = false; - for( uint8 n = 1; n <= 232 && !found; n++ ) - { - if( !IsVirtualNode( n )) - continue; - - map::iterator it = node->m_buttonMap.begin(); - for( ; it != node->m_buttonMap.end(); ++it ) - { - // is virtual node already in map? - if( it->second == n ) - break; - } - if( it == node->m_buttonMap.end() ) // found unused virtual node - { - node->m_buttonMap[m_currentControllerCommand->m_controllerCommandArg] = n; - SendVirtualNodeInfo( n, m_currentControllerCommand->m_controllerCommandNode ); - found = true; - } - } - if( !found ) // create a new virtual node - { - Log::Write( LogLevel_Info, 0, "AddVirtualNode" ); - Msg* msg = new Msg( "Slave Node Information", 0xff, REQUEST, FUNC_ID_SERIAL_API_SLAVE_NODE_INFO, false, false ); - msg->Append( 0 ); // node 0 - msg->Append( 1 ); // listening - msg->Append( 0x09 ); // genericType window covering - msg->Append( 0x00 ); // specificType undefined - msg->Append( 0 ); // length - SendMsg( msg, MsgQueue_Command ); - - msg = new Msg( "Add Virtual Node", 0xff, REQUEST, FUNC_ID_ZW_SET_SLAVE_LEARN_MODE, true ); - msg->Append( 0 ); // node 0 to add - if( IsPrimaryController() || IsInclusionController() ) - { - msg->Append( SLAVE_LEARN_MODE_ADD ); - } - else - { - msg->Append( SLAVE_LEARN_MODE_ENABLE ); - } - SendMsg( msg, MsgQueue_Command ); - } - } - else - { - UpdateControllerState( ControllerState_Error, ControllerError_ButtonNotFound ); - } - } - else - { - UpdateControllerState( ControllerState_Error, ControllerError_NodeNotFound ); - } - } else - { - UpdateControllerState( ControllerState_Error, ControllerError_NotBridge ); - } - break; - } - case ControllerCommand_DeleteButton: - { - if( IsBridgeController() ) - { - Node* node = GetNodeUnsafe( m_currentControllerCommand->m_controllerCommandNode ); - if( node != NULL ) - { - // Make sure button is allocated to a virtual node. - if( node->m_buttonMap.find( m_currentControllerCommand->m_controllerCommandArg ) != node->m_buttonMap.end() ) - { -#ifdef notdef - // We would need a reference count to decide when to free virtual nodes - // We could do this by making the bitmap of virtual nodes into a map that also holds a reference count. - Log::Write( LogLevel_Info, 0, "RemoveVirtualNode %d", m_currentControllerCommand->m_controllerCommandNode ); - Msg* msg = new Msg( "Remove Virtual Node", 0xff, REQUEST, FUNC_ID_ZW_SET_SLAVE_LEARN_MODE, true ); - msg->Append( m_currentControllerCommand->m_controllerCommandNode ); // from the node - if( IsPrimaryController() || IsInclusionController() ) - msg->Append( SLAVE_LEARN_MODE_REMOVE ); - else - msg->Append( SLAVE_LEARN_MODE_ENABLE ); - SendMsg( msg ); -#endif - node->m_buttonMap.erase( m_currentControllerCommand->m_controllerCommandArg ); - SaveButtons(); - - Notification* notification = new Notification( Notification::Type_DeleteButton ); - notification->SetHomeAndNodeIds( m_homeId, m_currentControllerCommand->m_controllerCommandNode ); - notification->SetButtonId( m_currentControllerCommand->m_controllerCommandArg ); - QueueNotification( notification ); - } - else - { - UpdateControllerState( ControllerState_Error, ControllerError_ButtonNotFound ); - } - } - else - { - UpdateControllerState( ControllerState_Error, ControllerError_NodeNotFound ); - } - } - else - { - UpdateControllerState( ControllerState_Error, ControllerError_NotBridge ); - } - break; - } - case ControllerCommand_None: - { - // To keep gcc quiet - break; - } - } -} - -//----------------------------------------------------------------------------- -// -// Stop the current controller function -//----------------------------------------------------------------------------- -bool Driver::CancelControllerCommand -( -) -{ - if( m_currentControllerCommand == NULL ) - { - // Controller is not doing anything - return false; - } - - switch( m_currentControllerCommand->m_controllerCommand ) - { - case ControllerCommand_AddDevice: - { - Log::Write( LogLevel_Info, 0, "Cancel Add Node" ); - m_currentControllerCommand->m_controllerCommandNode = 0xff; // identify the fact that there is no new node to initialize - AddNodeStop( FUNC_ID_ZW_ADD_NODE_TO_NETWORK ); - break; - } - case ControllerCommand_CreateNewPrimary: - { - Log::Write( LogLevel_Info, 0, "Cancel Create New Primary" ); - Msg* msg = new Msg( "CreateNewPrimary Stop", 0xff, REQUEST, FUNC_ID_ZW_CREATE_NEW_PRIMARY, true ); - msg->Append( CREATE_PRIMARY_STOP ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_ReceiveConfiguration: - { - Log::Write( LogLevel_Info, 0, "Cancel Receive Configuration" ); - Msg* msg = new Msg( "ReceiveConfiguration Stop", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, false, false ); - msg->Append( 0 ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_RemoveDevice: - { - Log::Write( LogLevel_Info, 0, "Cancel Remove Device" ); - m_currentControllerCommand->m_controllerCommandNode = 0xff; // identify the fact that there is no node to remove - AddNodeStop( FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK ); - break; - } - case ControllerCommand_TransferPrimaryRole: - { - Log::Write( LogLevel_Info, 0, "Cancel Transfer Primary Role" ); - Msg* msg = new Msg( "Transfer Primary Role Stop", 0xff, REQUEST, FUNC_ID_ZW_CONTROLLER_CHANGE, true ); - msg->Append( CONTROLLER_CHANGE_STOP ); - SendMsg( msg, MsgQueue_Command ); - break; - } - case ControllerCommand_ReplicationSend: - { - Log::Write( LogLevel_Info, 0, "Cancel Replication Send" ); - m_currentControllerCommand->m_controllerCommandNode = 0xff; // identify the fact that there is no new node to initialize - AddNodeStop( FUNC_ID_ZW_ADD_NODE_TO_NETWORK ); - break; - } - case ControllerCommand_CreateButton: - case ControllerCommand_DeleteButton: - { - if( m_currentControllerCommand->m_controllerCommandNode != 0 ) - { - SendSlaveLearnModeOff(); - } - break; - } - case ControllerCommand_None: - case ControllerCommand_RequestNetworkUpdate: - case ControllerCommand_RequestNodeNeighborUpdate: - case ControllerCommand_AssignReturnRoute: - case ControllerCommand_DeleteAllReturnRoutes: - case ControllerCommand_RemoveFailedNode: - case ControllerCommand_HasNodeFailed: - case ControllerCommand_ReplaceFailedNode: - case ControllerCommand_SendNodeInformation: - { - // Cannot cancel - return false; - } - } - - UpdateControllerState( ControllerState_Cancel ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Stop the Add Node mode based on API of controller -//----------------------------------------------------------------------------- -void Driver::AddNodeStop -( - uint8 const _funcId -) -{ - if( m_currentControllerCommand == NULL ) - { - // Controller is not doing anything - return; - } - - if( m_serialAPIVersion[0] == 2 && m_serialAPIVersion[1] == 76 ) - { - Msg* msg = new Msg( "Add Node Stop", 0xff, REQUEST, _funcId, false, false ); - msg->Append( ADD_NODE_STOP ); - SendMsg( msg, Driver::MsgQueue_Command ); - } - else - { - Msg* msg = new Msg( "Add Node Stop", 0xff, REQUEST, _funcId, false, true ); - msg->Append( ADD_NODE_STOP ); - SendMsg( msg, Driver::MsgQueue_Command ); - } -} - -//----------------------------------------------------------------------------- -// -// Run a series of messages to a single node or every node on the network. -//----------------------------------------------------------------------------- -void Driver::TestNetwork -( - uint8 const _nodeId, - uint32 const _count -) -{ - LockNodes(); - if( _nodeId == 0 ) // send _count messages to every node - { - for( int i=0; i<256; ++i ) - { - if( i == m_nodeId ) // ignore sending to ourself - { - continue; - } - if( m_nodes[i] != NULL ) - { - NoOperation *noop = static_cast( m_nodes[i]->GetCommandClass( NoOperation::StaticGetCommandClassId() ) ); - for( int j=0; j < (int)_count; j++ ) - { - noop->Set( true ); - } - } - } - } - else if( _nodeId != m_nodeId && m_nodes[_nodeId] != NULL ) - { - NoOperation *noop = static_cast( m_nodes[_nodeId]->GetCommandClass( NoOperation::StaticGetCommandClassId() ) ); - for( int i=0; i < (int)_count; i++ ) - { - noop->Set( true ); - } - } - ReleaseNodes(); -} - -//----------------------------------------------------------------------------- -// SwitchAll -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// All devices that support the SwitchAll command class will be turned on -//----------------------------------------------------------------------------- -void Driver::SwitchAllOn -( -) -{ - SwitchAll::On( this, 0xff ); - - LockNodes(); - for( int i=0; i<256; ++i ) - { - if( GetNodeUnsafe( i ) ) - { - if( m_nodes[i]->GetCommandClass( SwitchAll::StaticGetCommandClassId() ) ) - { - SwitchAll::On( this, (uint8)i ); - } - } - } - ReleaseNodes(); -} - -//----------------------------------------------------------------------------- -// -// All devices that support the SwitchAll command class will be turned off -//----------------------------------------------------------------------------- -void Driver::SwitchAllOff -( -) -{ - SwitchAll::Off( this, 0xff ); - - LockNodes(); - for( int i=0; i<256; ++i ) - { - if( GetNodeUnsafe( i ) ) - { - if( m_nodes[i]->GetCommandClass( SwitchAll::StaticGetCommandClassId() ) ) - { - SwitchAll::Off( this, (uint8)i ); - } - } - } - ReleaseNodes(); -} - -//----------------------------------------------------------------------------- -// -// Set the value of one of the configuration parameters of a device -//----------------------------------------------------------------------------- -bool Driver::SetConfigParam -( - uint8 const _nodeId, - uint8 const _param, - int32 _value, - uint8 _size -) -{ - bool res = false; - if( Node* node = GetNode( _nodeId ) ) - { - res = node->SetConfigParam( _param, _value, _size ); - ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Request the value of one of the configuration parameters of a device -//----------------------------------------------------------------------------- -void Driver::RequestConfigParam -( - uint8 const _nodeId, - uint8 const _param -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->RequestConfigParam( _param ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Gets the number of association groups reported by this node -//----------------------------------------------------------------------------- -uint8 Driver::GetNumGroups -( - uint8 const _nodeId -) -{ - uint8 numGroups = 0; - if( Node* node = GetNode( _nodeId ) ) - { - numGroups = node->GetNumGroups(); - ReleaseNodes(); - } - - return numGroups; -} - -//----------------------------------------------------------------------------- -// -// Gets the associations for a group -//----------------------------------------------------------------------------- -uint32 Driver::GetAssociations -( - uint8 const _nodeId, - uint8 const _groupIdx, - uint8** o_associations -) -{ - uint32 numAssociations = 0; - if( Node* node = GetNode( _nodeId ) ) - { - numAssociations = node->GetAssociations( _groupIdx, o_associations ); - ReleaseNodes(); - } - - return numAssociations; -} - -//----------------------------------------------------------------------------- -// -// Gets the maximum number of associations for a group -//----------------------------------------------------------------------------- -uint8 Driver::GetMaxAssociations -( - uint8 const _nodeId, - uint8 const _groupIdx -) -{ - uint8 maxAssociations = 0; - if( Node* node = GetNode( _nodeId ) ) - { - maxAssociations = node->GetMaxAssociations( _groupIdx ); - ReleaseNodes(); - } - - return maxAssociations; -} - -//----------------------------------------------------------------------------- -// -// Gets the label for a particular group -//----------------------------------------------------------------------------- -string Driver::GetGroupLabel -( - uint8 const _nodeId, - uint8 const _groupIdx -) -{ - string label = ""; - if( Node* node = GetNode( _nodeId ) ) - { - label = node->GetGroupLabel( _groupIdx ); - ReleaseNodes(); - } - - return label; -} - -//----------------------------------------------------------------------------- -// -// Adds a node to an association group -//----------------------------------------------------------------------------- -void Driver::AddAssociation -( - uint8 const _nodeId, - uint8 const _groupIdx, - uint8 const _targetNodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->AddAssociation( _groupIdx, _targetNodeId ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Removes a node from an association group -//----------------------------------------------------------------------------- -void Driver::RemoveAssociation -( - uint8 const _nodeId, - uint8 const _groupIdx, - uint8 const _targetNodeId -) -{ - if( Node* node = GetNode( _nodeId ) ) - { - node->RemoveAssociation( _groupIdx, _targetNodeId ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Add a notification to the queue to be sent at a later, safe time. -//----------------------------------------------------------------------------- -void Driver::QueueNotification -( - Notification* _notification -) -{ - m_notifications.push_back( _notification ); - m_notificationsEvent->Set(); -} - -//----------------------------------------------------------------------------- -// -// Notify any watching objects of a value change -//----------------------------------------------------------------------------- -void Driver::NotifyWatchers -( -) -{ - list::iterator nit = m_notifications.begin(); - while( nit != m_notifications.end() ) - { - Notification* notification = m_notifications.front(); - m_notifications.pop_front(); - - Manager::Get()->NotifyWatchers( notification ); - - delete notification; - nit = m_notifications.begin(); - } - m_notificationsEvent->Reset(); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleRfPowerLevelSetResponse -( - uint8* _data -) -{ - bool res = true; - // the meaning of this command is currently unclear, and there - // isn't any returned response data, so just log the function call - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_R_F_POWER_LEVEL_SET" ); - - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleSerialApiSetTimeoutsResponse -( - uint8* _data -) -{ - // the meaning of this command and its response is currently unclear - bool res = true; - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_SERIAL_API_SET_TIMEOUTS" ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleMemoryGetByteResponse -( - uint8* _data -) -{ - bool res = true; - // the meaning of this command and its response is currently unclear - // it seems to return three bytes of data, so print them out - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_ZW_MEMORY_GET_BYTE, returned data: 0x%02hx 0x%02hx 0x%02hx", _data[0], _data[1], _data[2] ); - - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleReadMemoryResponse -( - uint8* _data -) -{ - // the meaning of this command and its response is currently unclear - bool res = true; - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "Received reply to FUNC_ID_MEMORY_GET_BYTE" ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleGetVirtualNodesResponse -( - uint8* _data -) -{ - uint8 nodeId = GetNodeNumber( m_currentMsg ); - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_GET_VIRTUAL_NODES" ); - memcpy( m_virtualNeighbors, &_data[2], 29 ); - m_virtualNeighborsReceived = true; - bool bNeighbors = false; - for( int by=0; by<29; by++ ) - { - for( int bi=0; bi<8; bi++ ) - { - if( (_data[2+by] & (0x01< -// Gets the virtual neighbors for a network -//----------------------------------------------------------------------------- -uint32 Driver::GetVirtualNeighbors -( - uint8** o_neighbors -) -{ - int i; - uint32 numNeighbors = 0; - if( !m_virtualNeighborsReceived ) - { - *o_neighbors = NULL; - return 0; - } - for( i = 0; i < 29; i++ ) - { - for( unsigned char mask = 0x80; mask != 0; mask >>= 1 ) - if( m_virtualNeighbors[i] & mask ) - numNeighbors++; - } - - // handle the possibility that no neighbors are reported - if( !numNeighbors ) - { - *o_neighbors = NULL; - return 0; - } - - // create and populate an array with neighbor node ids - uint8* neighbors = new uint8[numNeighbors]; - uint32 index = 0; - for( int by=0; by<29; by++ ) - { - for( int bi=0; bi<8; bi++ ) - { - if( (m_virtualNeighbors[by] & (0x01< -// Get the virtual neighbour information from the controller -//----------------------------------------------------------------------------- -void Driver::RequestVirtualNeighbors -( - MsgQueue const _queue -) -{ - Msg* msg = new Msg( "Get Virtual Neighbor List", 0xff, REQUEST, FUNC_ID_ZW_GET_VIRTUAL_NODES, false ); - SendMsg( msg, _queue ); -} - -//----------------------------------------------------------------------------- -// -// Send node info frame on behalf of a virtual node. -//----------------------------------------------------------------------------- -void Driver::SendVirtualNodeInfo -( - uint8 const _FromNodeId, - uint8 const _ToNodeId -) -{ - char str[80]; - - snprintf( str, sizeof(str), "Send Virtual Node Info from %d to %d", _FromNodeId, _ToNodeId ); - Msg* msg = new Msg( str, 0xff, REQUEST, FUNC_ID_ZW_SEND_SLAVE_NODE_INFO, true ); - msg->Append( _FromNodeId ); // from the virtual node - msg->Append( _ToNodeId ); // to the handheld controller - msg->Append( TRANSMIT_OPTION_ACK ); - SendMsg( msg, MsgQueue_Command ); -} - -//----------------------------------------------------------------------------- -// -// Disable Slave Learn Mode. -//----------------------------------------------------------------------------- -void Driver::SendSlaveLearnModeOff -( -) -{ - if( !( IsPrimaryController() || IsInclusionController() ) ) - { - Msg* msg = new Msg( "Set Slave Learn Mode Off ", 0xff, REQUEST, FUNC_ID_ZW_SET_SLAVE_LEARN_MODE, true ); - msg->Append( 0 ); // filler node id - msg->Append( SLAVE_LEARN_MODE_DISABLE ); - SendMsg( msg, MsgQueue_Command ); - } -} - -//----------------------------------------------------------------------------- -// -// Save button info into file. -//----------------------------------------------------------------------------- -void Driver::SaveButtons -( -) -{ - char str[16]; - - // Create a new XML document to contain the driver configuration - TiXmlDocument doc; - TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" ); - TiXmlElement* nodesElement = new TiXmlElement( "Nodes" ); - doc.LinkEndChild( decl ); - doc.LinkEndChild( nodesElement ); - - nodesElement->SetAttribute( "xmlns", "http://code.google.com/p/open-zwave/" ); - - snprintf( str, sizeof(str), "%d", 1 ); - nodesElement->SetAttribute( "version", str); - - LockNodes(); - for( int i = 1; i < 256; i++ ) - { - if( m_nodes[i] == NULL || m_nodes[i]->m_buttonMap.empty() ) - { - continue; - } - - TiXmlElement* nodeElement = new TiXmlElement( "Node" ); - - snprintf( str, sizeof(str), "%d", i ); - nodeElement->SetAttribute( "id", str ); - - for( map::iterator it = m_nodes[i]->m_buttonMap.begin(); it != m_nodes[i]->m_buttonMap.end(); ++it ) - { - TiXmlElement* valueElement = new TiXmlElement( "Button" ); - - snprintf( str, sizeof(str), "%d", it->first ); - valueElement->SetAttribute( "id", str ); - - snprintf( str, sizeof(str), "%d", it->second ); - TiXmlText* textElement = new TiXmlText( str ); - valueElement->LinkEndChild( textElement ); - - nodeElement->LinkEndChild( valueElement ); - } - - nodesElement->LinkEndChild( nodeElement ); - } - ReleaseNodes(); - - string userPath; - Options::Get()->GetOptionAsString( "UserPath", &userPath ); - - string filename = userPath + "zwbutton.xml"; - - doc.SaveFile( filename.c_str() ); -} -//----------------------------------------------------------------------------- -// -// Read button info per node from file. -//----------------------------------------------------------------------------- -void Driver::ReadButtons -( - uint8 const _nodeId -) -{ - int32 intVal; - int32 nodeId; - int32 buttonId; - char const* str; - - // Load the XML document that contains the driver configuration - string userPath; - Options::Get()->GetOptionAsString( "UserPath", &userPath ); - - string filename = userPath + "zwbutton.xml"; - - TiXmlDocument doc; - if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) - { - Log::Write( LogLevel_Debug, "Driver::ReadButtons - zwbutton.xml file not found."); - return; - } - - TiXmlElement const* nodesElement = doc.RootElement(); - str = nodesElement->Value(); - if( str && strcmp( str, "Nodes" )) - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadButtons - zwbutton.xml is malformed"); - return; - } - - // Version - if( TIXML_SUCCESS == nodesElement->QueryIntAttribute( "version", &intVal ) ) - { - if( (uint32)intVal != 1 ) - { - Log::Write( LogLevel_Info, "Driver::ReadButtons - %s is from an older version of OpenZWave and cannot be loaded.", "zwbutton.xml" ); - return; - } - } - else - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadButtons - zwbutton.xml is from an older version of OpenZWave and cannot be loaded." ); - return; - } - - TiXmlElement const* nodeElement = nodesElement->FirstChildElement(); - while( nodeElement ) - { - str = nodeElement->Value(); - if( str && !strcmp( str, "Node" )) - { - Node* node = NULL; - if( TIXML_SUCCESS == nodeElement->QueryIntAttribute( "id", &intVal ) ) - { - if( _nodeId == intVal ) - { - node = GetNodeUnsafe( intVal ); - } - } - if( node != NULL ) - { - TiXmlElement const* buttonElement = nodeElement->FirstChildElement(); - while( buttonElement ) - { - str = buttonElement->Value(); - if( str && !strcmp( str, "Button")) - { - if (TIXML_SUCCESS != buttonElement->QueryIntAttribute( "id", &buttonId ) ) - { - Log::Write( LogLevel_Warning, "WARNING: Driver::ReadButtons - cannot find Button Id for node %d", _nodeId ); - return; - } - str = buttonElement->GetText(); - if( str ) - { - char *p; - nodeId = (int32)strtol( str, &p, 0 ); - } - else - { - Log::Write( LogLevel_Info, "Driver::ReadButtons - missing virtual node value for node %d button id %d", _nodeId, buttonId ); - return; - } - node->m_buttonMap[buttonId] = nodeId; - Notification* notification = new Notification( Notification::Type_CreateButton ); - notification->SetHomeAndNodeIds( m_homeId, nodeId ); - notification->SetButtonId( buttonId ); - QueueNotification( notification ); - } - buttonElement = buttonElement->NextSiblingElement(); - } - } - } - nodeElement = nodeElement->NextSiblingElement(); - } -} -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleSetSlaveLearnModeResponse -( - uint8* _data -) -{ - bool res = true; - ControllerState state = ControllerState_InProgress; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - if( _data[2] ) - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_SET_SLAVE_LEARN_MODE - command in progress" ); - } - else - { - // Failed - Log::Write( LogLevel_Warning, nodeId, "WARNING: Received reply to FUNC_ID_ZW_SET_SLAVE_LEARN_MODE - command failed" ); - state = ControllerState_Failed; - res = false; - SendSlaveLearnModeOff(); - } - - UpdateControllerState( state ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSetSlaveLearnModeRequest -( - uint8* _data -) -{ - ControllerState state = ControllerState_Waiting; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - - if( m_currentControllerCommand == NULL ) - { - return; - } - - SendSlaveLearnModeOff(); - switch( _data[3] ) - { - case SLAVE_ASSIGN_COMPLETE: - { - Log::Write( LogLevel_Info, nodeId, "SLAVE_ASSIGN_COMPLETE" ); - if( _data[4] == 0 ) // original node is 0 so adding - { - Log::Write( LogLevel_Info, nodeId, "Adding virtual node ID %d", _data[5] ); - Node* node = GetNodeUnsafe( m_currentControllerCommand->m_controllerCommandNode ); - if( node != NULL ) - { - node->m_buttonMap[m_currentControllerCommand->m_controllerCommandArg] = _data[5]; - SendVirtualNodeInfo( _data[5], m_currentControllerCommand->m_controllerCommandNode ); - } - } - else - if( _data[5] == 0 ) - { - Log::Write( LogLevel_Info, nodeId, "Removing virtual node ID %d", _data[4] ); - } - break; - } - case SLAVE_ASSIGN_NODEID_DONE: - { - Log::Write( LogLevel_Info, nodeId, "SLAVE_ASSIGN_NODEID_DONE" ); - if( _data[4] == 0 ) // original node is 0 so adding - { - Log::Write( LogLevel_Info, nodeId, "Adding virtual node ID %d", _data[5] ); - Node* node = GetNodeUnsafe( m_currentControllerCommand->m_controllerCommandNode ); - if( node != NULL ) - { - node->m_buttonMap[m_currentControllerCommand->m_controllerCommandArg] = _data[5]; - SendVirtualNodeInfo( _data[5], m_currentControllerCommand->m_controllerCommandNode ); - } - } - else - if( _data[5] == 0 ) - { - Log::Write( LogLevel_Info, nodeId, "Removing virtual node ID %d", _data[4] ); - } - break; - } - case SLAVE_ASSIGN_RANGE_INFO_UPDATE: - { - Log::Write( LogLevel_Info, nodeId, "SLAVE_ASSIGN_RANGE_INFO_UPDATE" ); - break; - } - } - m_currentControllerCommand->m_controllerAdded = false; - - UpdateControllerState( state ); -} - -//----------------------------------------------------------------------------- -// -// Process a response from the Z-Wave PC interface -//----------------------------------------------------------------------------- -bool Driver::HandleSendSlaveNodeInfoResponse -( - uint8* _data -) -{ - bool res = true; - ControllerState state = ControllerState_InProgress; - uint8 nodeId = GetNodeNumber( m_currentMsg ); - if( m_currentControllerCommand == NULL ) - { - return false; - } - if( _data[2] ) - { - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_SEND_SLAVE_NODE_INFO - command in progress" ); - } - else - { - // Failed - Log::Write( LogLevel_Info, nodeId, "Received reply to FUNC_ID_ZW_SEND_SLAVE_NODE_INFO - command failed" ); - state = ControllerState_Failed; - // Undo button map settings - Node* node = GetNodeUnsafe( m_currentControllerCommand->m_controllerCommandNode ); - if( node != NULL ) - { - node->m_buttonMap.erase( m_currentControllerCommand->m_controllerCommandArg ); - } - res = false; - } - - UpdateControllerState( state ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleSendSlaveNodeInfoRequest -( - uint8* _data -) -{ - if( m_currentControllerCommand == NULL ) - { - return; - } - if( _data[3] == 0 ) // finish up - { - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "SEND_SLAVE_NODE_INFO_COMPLETE OK" ); - SaveButtons(); - Notification* notification = new Notification( Notification::Type_CreateButton ); - notification->SetHomeAndNodeIds( m_homeId, m_currentControllerCommand->m_controllerCommandNode ); - notification->SetButtonId( m_currentControllerCommand->m_controllerCommandArg ); - QueueNotification( notification ); - - UpdateControllerState( ControllerState_Completed ); - RequestVirtualNeighbors( MsgQueue_Send ); - } - else // error. try again - { - HandleErrorResponse( _data[3], m_currentControllerCommand->m_controllerCommandNode, "SLAVE_NODE_INFO_COMPLETE" ); - Node* node = GetNodeUnsafe( m_currentControllerCommand->m_controllerCommandNode ); - if( node != NULL) - { - SendVirtualNodeInfo( node->m_buttonMap[m_currentControllerCommand->m_controllerCommandArg], m_currentControllerCommand->m_controllerCommandNode ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Process a request from the Z-Wave PC interface -//----------------------------------------------------------------------------- -void Driver::HandleApplicationSlaveCommandRequest -( - uint8* _data -) -{ - Log::Write( LogLevel_Info, GetNodeNumber( m_currentMsg ), "APPLICATION_SLAVE_COMMAND_HANDLER rxStatus %x dest %d source %d len %d", _data[2], _data[3], _data[4], _data[5] ); - Node* node = GetNodeUnsafe( _data[4] ); - if( node != NULL && _data[5] == 3 && _data[6] == 0x20 && _data[7] == 0x01 ) // only support Basic Set for now - { - map::iterator it = node->m_buttonMap.begin(); - for( ; it != node->m_buttonMap.end(); ++it ) - { - if( it->second == _data[3] ) - break; - } - if( it != node->m_buttonMap.end() ) - { - Notification *notification; - if( _data[8] == 0 ) - { - notification = new Notification( Notification::Type_ButtonOff ); - } - else - { - notification = new Notification( Notification::Type_ButtonOn ); - } - notification->SetHomeAndNodeIds( m_homeId, _data[4] ); - notification->SetButtonId( it->first ); - QueueNotification( notification ); - } - } -} - -//----------------------------------------------------------------------------- -// -// See if we can get node from incoming message data -//----------------------------------------------------------------------------- -uint8 Driver::NodeFromMessage -( - uint8 const* buffer -) -{ - uint8 nodeId = 0; - - if( buffer[1] >= 5 ) - { - switch( buffer[3] ) - { - case FUNC_ID_APPLICATION_COMMAND_HANDLER: nodeId = buffer[5]; break; - case FUNC_ID_ZW_APPLICATION_UPDATE: nodeId = buffer[5]; break; - } - } - return nodeId; -} -//----------------------------------------------------------------------------- -// -// Update a node's routing information -//----------------------------------------------------------------------------- -void Driver::UpdateNodeRoutes -( - uint8 const _nodeId, - bool _doUpdate // = false -) -{ - // Only for routing slaves - Node* node = GetNodeUnsafe( _nodeId ); - if( node != NULL && node->GetBasic() == 0x04 ) - { - uint8 numGroups = GetNumGroups( _nodeId ); - uint8 numNodes = 0; - uint8 nodes[5]; - uint8* associations; - uint8 i; - - // Determine up to 5 destinations - - memset( nodes, 0, sizeof(nodes) ); - for( i = 1; i <= numGroups && numNodes < sizeof(nodes) ; i++ ) - { - associations = NULL; - uint32 len = GetAssociations( _nodeId, i, &associations ); - for( uint8 j = 0; j < len; j++ ) - { - uint8 k; - for( k = 0; k < numNodes; k++ ) - { - if( nodes[k] == associations[j] ) - { - break; - } - } - if( k >= numNodes && numNodes < sizeof(nodes) ) // not in list so add it - { - nodes[numNodes++] = associations[j]; - } - } - if( associations != NULL ) - { - delete [] associations; - } - } - if( _doUpdate || numNodes != node->m_numRouteNodes || memcmp( nodes, node->m_routeNodes, sizeof(node->m_routeNodes) ) != 0 ) - { - // Figure out what to do if one of these fail. - BeginControllerCommand( ControllerCommand_DeleteAllReturnRoutes, NULL, NULL, true, _nodeId, 0 ); - for( i = 0; i < numNodes; i++ ) - { - BeginControllerCommand( ControllerCommand_AssignReturnRoute, NULL, NULL, true, _nodeId, nodes[i] ); - } - node->m_numRouteNodes = numNodes; - memcpy( node->m_routeNodes, nodes, sizeof(nodes) ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Return driver statistics -//----------------------------------------------------------------------------- -void Driver::GetDriverStatistics -( - DriverData* _data -) -{ - _data->m_SOFCnt = m_SOFCnt; - _data->m_ACKWaiting = m_ACKWaiting; - _data->m_readAborts = m_readAborts; - _data->m_badChecksum = m_badChecksum; - _data->m_readCnt = m_readCnt; - _data->m_writeCnt = m_writeCnt; - _data->m_CANCnt = m_CANCnt; - _data->m_NAKCnt = m_NAKCnt; - _data->m_ACKCnt = m_ACKCnt; - _data->m_OOFCnt = m_OOFCnt; - _data->m_dropped = m_dropped; - _data->m_retries = m_retries; - _data->m_callbacks = m_callbacks; - _data->m_badroutes = m_badroutes; - _data->m_noack = m_noack; - _data->m_netbusy = m_netbusy; - _data->m_notidle = m_notidle; - _data->m_nondelivery = m_nondelivery; - _data->m_routedbusy = m_routedbusy; - _data->m_broadcastReadCnt = m_broadcastReadCnt; - _data->m_broadcastWriteCnt = m_broadcastWriteCnt; -} - -//----------------------------------------------------------------------------- -// -// Return per node statistics -//----------------------------------------------------------------------------- -void Driver::GetNodeStatistics -( - uint8 const _nodeId, - Node::NodeData* _data -) -{ - Node* node = GetNode( _nodeId ); - if( node != NULL ) - { - node->GetNodeStatistics( _data ); - ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Report driver statistics to the driver's log -//----------------------------------------------------------------------------- -void Driver::LogDriverStatistics -( -) -{ - DriverData data; - - GetDriverStatistics(&data); - int32 totalElapsed = -m_startTime.TimeRemaining(); - int32 days = totalElapsed / (1000*60*60*24); - - totalElapsed -= days*1000*60*60*24; - int32 hours = totalElapsed/(1000*60*60); - - totalElapsed -= hours*1000*60*60; - int32 minutes = totalElapsed/(1000*60); - - Log::Write( LogLevel_Always, "***************************************************************************" ); - Log::Write( LogLevel_Always, "********************* Cumulative Network Statistics *********************" ); - Log::Write( LogLevel_Always, "*** General" ); - Log::Write( LogLevel_Always, "Driver run time: . . . %ld days, %ld hours, %ld minutes", days, hours, minutes); - Log::Write( LogLevel_Always, "Frames processed: . . . . . . . . . . . . . . . . . . . . %ld", data.m_SOFCnt ); - Log::Write( LogLevel_Always, "Total messages successfully received: . . . . . . . . . . %ld", data.m_readCnt ); - Log::Write( LogLevel_Always, "Total Messages successfully sent: . . . . . . . . . . . . %ld", data.m_writeCnt ); - Log::Write( LogLevel_Always, "ACKs received from controller: . . . . . . . . . . . . . %ld", data.m_ACKCnt ); - // Consider tracking and adding: - // Initialization messages - // Ad-hoc command messages - // Polling messages - // Messages inititated by network - // Others? - Log::Write( LogLevel_Always, "*** Errors" ); - Log::Write( LogLevel_Always, "Unsolicited messages received while waiting for ACK: . . %ld", data.m_ACKWaiting ); - Log::Write( LogLevel_Always, "Reads aborted due to timeouts: . . . . . . . . . . . . . %ld", data.m_readAborts ); - Log::Write( LogLevel_Always, "Bad checksum errors: . . . . . . . . . . . . . . . . . . %ld", data.m_badChecksum ); - Log::Write( LogLevel_Always, "CANs received from controller: . . . . . . . . . . . . . %ld", data.m_CANCnt ); - Log::Write( LogLevel_Always, "NAKs received from controller: . . . . . . . . . . . . . %ld", data.m_NAKCnt ); - Log::Write( LogLevel_Always, "Out of frame data flow errors: . . . . . . . . . . . . . %ld", data.m_OOFCnt ); - Log::Write( LogLevel_Always, "Messages retransmitted: . . . . . . . . . . . . . . . . . %ld", data.m_retries ); - Log::Write( LogLevel_Always, "Messages dropped and not delivered: . . . . . . . . . . . %ld", data.m_dropped ); - Log::Write( LogLevel_Always, "***************************************************************************" ); -} - -//----------------------------------------------------------------------------- -// -// Get the Network Key we will use for Security Command Class -//----------------------------------------------------------------------------- -uint8 *Driver::GetNetworkKey() { - std::string networkKey; - std::vector elems; - unsigned int tempkey[16]; - static uint8 keybytes[16]; - static bool keySet = false; - if (keySet == false) { - Options::Get()->GetOptionAsString("NetworkKey", &networkKey ); - OpenZWave::split(elems, networkKey, ",", true); - if (elems.size() != 16) { - Log::Write(LogLevel_Warning, "Invalid Network Key. Does not contain 16 Bytes - Contains %d", elems.size()); - Log::Write(LogLevel_Warning, "Raw Key: %s", networkKey.c_str()); - Log::Write(LogLevel_Warning, "Parsed Key:"); - int i = 0; - for (std::vector::iterator it = elems.begin(); it != elems.end(); it++) - Log::Write(LogLevel_Warning, "%d) - %s", ++i, (*it).c_str()); - assert(0); - exit(-1); - } - int i = 0; - for (std::vector::iterator it = elems.begin(); it != elems.end(); it++) { - if (0 == sscanf(OpenZWave::trim(*it).c_str(), "%x", &tempkey[i])) { - Log::Write(LogLevel_Warning, "Cannot Convert Network Key Byte %s to Key", (*it).c_str()); - assert(0); - exit(-1); - } else { - keybytes[i] = (tempkey[i] & 0xFF); - } - i++; - } - keySet = true; - } - return keybytes; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/Driver.h b/lib/ESPiLight/pilight/libs/openzwave/Driver.h deleted file mode 100644 index 79d1e4b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Driver.h +++ /dev/null @@ -1,856 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Driver.h -// -// Communicates with a Z-Wave network -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Driver_H -#define _Driver_H - -#include -#include -#include - -#include "Defs.h" -#include "value_classes/ValueID.h" -#include "Node.h" -#include "platform/Event.h" -#include "platform/Mutex.h" -#include "platform/TimeStamp.h" - -namespace OpenZWave -{ - class Msg; - class Value; - class Event; - class Mutex; - class Controller; - class Thread; - class ControllerReplication; - class Notification; - - /** \brief The Driver class handles communication between OpenZWave - * and a device attached via a serial port (typically a controller). - */ - class OPENZWAVE_EXPORT Driver - { - friend class Manager; - friend class Node; - friend class Group; - friend class CommandClass; - friend class ControllerReplication; - friend class Value; - friend class ValueStore; - friend class ValueButton; - friend class Association; - friend class Basic; - friend class ManufacturerSpecific; - friend class NodeNaming; - friend class NoOperation; - friend class SceneActivation; - friend class WakeUp; - friend class Security; - - //----------------------------------------------------------------------------- - // Controller Interfaces - //----------------------------------------------------------------------------- - public: - enum ControllerInterface - { - ControllerInterface_Unknown = 0, - ControllerInterface_Serial, - ControllerInterface_Hid - }; - - //----------------------------------------------------------------------------- - // Construction / Destruction - //----------------------------------------------------------------------------- - private: - /** - * Creates threads, events and initializes member variables and the node array. - */ - Driver( string const& _controllerPath, ControllerInterface const& _interface ); - /** Sets "exit" flags and stops the three background threads (pollThread, serialThread - * and driverThread). Then clears out the send queue and node array. Notifies - * watchers and exits. - */ - virtual ~Driver(); - - /** - * Start the driverThread - */ - void Start(); - /** - * Entry point for driverThread - */ - static void DriverThreadEntryPoint( Event* _exitEvent, void* _context ); - /** - * ThreadProc for driverThread. This is where all the "action" takes place. - *

- * First, the thread is initialized by calling Init(). If Init() fails, it will be retried - * every 5 seconds for the first two minutes and every 30 seconds thereafter. - *

- * After the thread is successfully initialized, the thread enters a loop with the - * following elements: - * - Confirm that m_exit is still false (or exit from the thread if it is true) - * - Call ReadMsg() to consume any available messages from the controller - * - Call NotifyWatchers() to send any pending notifications - * - If the thread is not waiting for an ACK, a callback or a message reply, send [any][the next] queued message[s] - * - If there was no message read or sent (workDone=false), sleep for 5 seconds. If nothing happened - * within this time frame and something was expected (ACK, callback or reply), retrieve the - * last message from the send queue and examine GetSendAttempts(). If greater than 2, give up - * and remove the message from the queue. Otherwise, resend the message. - * - If something did happen [reset m_wakeEvent] - */ - void DriverThreadProc( Event* _exitEvent ); - /** - * Initialize the controller. Open the specified serial port, start the serialThread - * and pollThread, then send a NAK to the device [presumably to flush it]. - *

- * Then queue the commands to retrieve the Z-Wave interface: - * - Get version - * - Get home and node IDs - * - Get controller capabilities - * - Get serial API capabilties - * - [Get SUC node ID] - * - Get init data [identifying the nodes on the network] - * Init() will return false if the serial port could not be opened. - */ - bool Init( uint32 _attempts ); - - /** - * Remove any messages to a node on the queues - * Used when deleting a node. - */ - void RemoveQueues( uint8 const _nodeId ); - - Thread* m_driverThread; /**< Thread for reading from the Z-Wave controller, and for creating and managing the other threads for sending, polling etc. */ - bool m_exit; /**< Flag that is set when the application is exiting. */ - bool m_init; /**< Set to true once the driver has been initialised */ - bool m_awakeNodesQueried; /**< Set to true once the driver has polled all awake nodes */ - bool m_allNodesQueried; /**< Set to true once the driver has polled all nodes */ - bool m_notifytransactions; - TimeStamp m_startTime; /**< Time this driver started (for log report purposes) */ - - //----------------------------------------------------------------------------- - // Configuration - //----------------------------------------------------------------------------- - private: - void RequestConfig(); // Get the network configuration from the Z-Wave network - bool ReadConfig(); // Read the configuration from a file - void WriteConfig(); // Save the configuration to a file - - //----------------------------------------------------------------------------- - // Controller - //----------------------------------------------------------------------------- - private: - // Controller Capabilities (return in FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES) - enum - { - ControllerCaps_Secondary = 0x01, /**< The controller is a secondary. */ - ControllerCaps_OnOtherNetwork = 0x02, /**< The controller is not using its default HomeID. */ - ControllerCaps_SIS = 0x04, /**< There is a SUC ID Server on the network. */ - ControllerCaps_RealPrimary = 0x08, /**< Controller was the primary before the SIS was added. */ - ControllerCaps_SUC = 0x10 /**< Controller is a static update controller. */ - }; - - // Init Capabilities (return in FUNC_ID_SERIAL_API_GET_INIT_DATA) - enum - { - InitCaps_Slave = 0x01, /**< */ - InitCaps_TimerSupport = 0x02, /**< Controller supports timers. */ - InitCaps_Secondary = 0x04, /**< Controller is a secondary. */ - InitCaps_SUC = 0x08 /**< Controller is a static update controller. */ - }; - - bool IsPrimaryController()const{ return ((m_initCaps & InitCaps_Secondary) == 0); } - bool IsStaticUpdateController()const{ return ((m_initCaps & InitCaps_SUC) != 0); } - bool IsBridgeController()const{ return (m_libraryType == 7); } - bool IsInclusionController()const{ return ((m_controllerCaps & ControllerCaps_SIS) != 0); } - - - uint32 GetHomeId()const{ return m_homeId; } - uint8 GetNodeId()const{ return m_nodeId; } - uint8 GetSUCNodeId()const{ return m_SUCNodeId; } - uint16 GetManufacturerId()const{ return m_manufacturerId; } - uint16 GetProductType()const{ return m_productType; } - uint16 GetProductId()const{ return m_productId; } - string GetControllerPath()const{ return m_controllerPath; } - ControllerInterface GetControllerInterfaceType()const{ return m_controllerInterfaceType; } - string GetLibraryVersion()const{ return m_libraryVersion; } - string GetLibraryTypeName()const{ return m_libraryTypeName; } - int32 GetSendQueueCount()const - { - int32 count = 0; - for( int32 i=0; i - * The response message contains a bitmap identifying which of the 232 possible nodes - * in the network are actually present. These bitmap values are compared with the - * node map (read in from zwcfg_0x[homeid].xml) to see if the node has already been registered - * by the OpenZWave library. If it has (the log will show it as "Known") and this is - * the first time this message was sent (m_init is false), then AddNodeQuery() is called - * to retrieve its current state. If this is a "New" node to OpenZWave, then InitNode() - * is called. - * \see AddNodeQuery, InitNode, GetNode, ReleaseNodes - */ - void HandleSerialAPIGetInitDataResponse( uint8* _data ); - void HandleGetNodeProtocolInfoResponse( uint8* _data ); - bool HandleRemoveFailedNodeResponse( uint8* _data ); - void HandleIsFailedNodeResponse( uint8* _data ); - bool HandleReplaceFailedNodeResponse( uint8* _data ); - bool HandleAssignReturnRouteResponse( uint8* _data ); - bool HandleDeleteReturnRouteResponse( uint8* _data ); - void HandleSendNodeInformationRequest( uint8* _data ); - void HandleSendDataResponse( uint8* _data, bool _replication ); - bool HandleNetworkUpdateResponse( uint8* _data ); - void HandleGetRoutingInfoResponse( uint8* _data ); - - void HandleSendDataRequest( uint8* _data, bool _replication ); - void HandleAddNodeToNetworkRequest( uint8* _data ); - void HandleCreateNewPrimaryRequest( uint8* _data ); - void HandleControllerChangeRequest( uint8* _data ); - void HandleSetLearnModeRequest( uint8* _data ); - void HandleRemoveFailedNodeRequest( uint8* _data ); - void HandleReplaceFailedNodeRequest( uint8* _data ); - void HandleRemoveNodeFromNetworkRequest( uint8* _data ); - void HandleApplicationCommandHandlerRequest( uint8* _data ); - void HandlePromiscuousApplicationCommandHandlerRequest( uint8* _data ); - void HandleAssignReturnRouteRequest( uint8* _data ); - void HandleDeleteReturnRouteRequest( uint8* _data ); - void HandleNodeNeighborUpdateRequest( uint8* _data ); - void HandleNetworkUpdateRequest( uint8* _data ); - bool HandleApplicationUpdateRequest( uint8* _data ); - bool HandleRfPowerLevelSetResponse( uint8* _data ); - bool HandleSerialApiSetTimeoutsResponse( uint8* _data ); - bool HandleMemoryGetByteResponse( uint8* _data ); - bool HandleReadMemoryResponse( uint8* _data ); - void HandleGetVirtualNodesResponse( uint8* _data ); - bool HandleSetSlaveLearnModeResponse( uint8* _data ); - void HandleSetSlaveLearnModeRequest( uint8* _data ); - bool HandleSendSlaveNodeInfoResponse( uint8* _data ); - void HandleSendSlaveNodeInfoRequest( uint8* _data ); - void HandleApplicationSlaveCommandRequest( uint8* _data ); - void HandleSerialAPIResetRequest( uint8* _data ); - - void CommonAddNodeStatusRequestHandler( uint8 _funcId, uint8* _data ); - - bool m_waitingForAck; // True when we are waiting for an ACK from the dongle - uint8 m_expectedCallbackId; // If non-zero, we wait for a message with this callback Id - uint8 m_expectedReply; // If non-zero, we wait for a message with this function Id - uint8 m_expectedCommandClassId; // If the expected reply is FUNC_ID_APPLICATION_COMMAND_HANDLER, this value stores the command class we're waiting to hear from - uint8 m_expectedNodeId; // If we are waiting for a FUNC_ID_APPLICATION_COMMAND_HANDLER, make sure we only accept it from this node. - - //----------------------------------------------------------------------------- - // Polling Z-Wave devices - //----------------------------------------------------------------------------- - private: - int32 GetPollInterval(){ return m_pollInterval ; } - void SetPollInterval( int32 _milliseconds, bool _bIntervalBetweenPolls ){ m_pollInterval = _milliseconds; m_bIntervalBetweenPolls = _bIntervalBetweenPolls; } - bool EnablePoll( const ValueID &_valueId, uint8 _intensity = 1 ); - bool DisablePoll( const ValueID &_valueId ); - bool isPolled( const ValueID &_valueId ); - void SetPollIntensity( const ValueID &_valueId, uint8 _intensity ); - static void PollThreadEntryPoint( Event* _exitEvent, void* _context ); - void PollThreadProc( Event* _exitEvent ); - - Thread* m_pollThread; // Thread for polling devices on the Z-Wave network - struct PollEntry - { - ValueID m_id; - uint8 m_pollCounter; - }; -OPENZWAVE_EXPORT_WARNINGS_OFF - list m_pollList; // List of nodes that need to be polled -OPENZWAVE_EXPORT_WARNINGS_ON - Mutex* m_pollMutex; // Serialize access to the polling list - int32 m_pollInterval; // Time interval during which all nodes must be polled - bool m_bIntervalBetweenPolls; // if true, the library intersperses m_pollInterval between polls; if false, the library attempts to complete all polls within m_pollInterval - - //----------------------------------------------------------------------------- - // Retrieving Node information - //----------------------------------------------------------------------------- - public: - uint8 GetNodeNumber( Msg const* _msg )const{ return ( _msg == NULL ? 0 : _msg->GetTargetNodeId() ); } - - private: - /** - * Creates a new Node object (deleting any previous Node object with the same nodeId) and - * queues a full query of the node's parameters (starting at the beginning of the query - * stages--Node::QueryStage_None). This function will send Notification::Type_NodeAdded - * and Notification::Type_NodeRemoved messages to identify these modifications. - * \param _nodeId The node ID of the node to create and query. - * \see Notification::Type_NodeAdded, Notification::Type_NodeRemoved, Node::QueryStage_None, - */ - void InitNode( uint8 const _nodeId, bool newNode = false ); - - void InitAllNodes(); // Delete all nodes and fetch the data from the Z-Wave network again. - - bool IsNodeListeningDevice( uint8 const _nodeId ); - bool IsNodeFrequentListeningDevice( uint8 const _nodeId ); - bool IsNodeBeamingDevice( uint8 const _nodeId ); - bool IsNodeRoutingDevice( uint8 const _nodeId ); - bool IsNodeSecurityDevice( uint8 const _nodeId ); - uint32 GetNodeMaxBaudRate( uint8 const _nodeId ); - uint8 GetNodeVersion( uint8 const _nodeId ); - uint8 GetNodeSecurity( uint8 const _nodeId ); - uint8 GetNodeBasic( uint8 const _nodeId ); - uint8 GetNodeGeneric( uint8 const _nodeId ); - uint8 GetNodeSpecific( uint8 const _nodeId ); - string GetNodeType( uint8 const _nodeId ); - uint32 GetNodeNeighbors( uint8 const _nodeId, uint8** o_neighbors ); - - string GetNodeManufacturerName( uint8 const _nodeId ); - string GetNodeProductName( uint8 const _nodeId ); - string GetNodeName( uint8 const _nodeId ); - string GetNodeLocation( uint8 const _nodeId ); - - string GetNodeManufacturerId( uint8 const _nodeId ); - string GetNodeProductType( uint8 const _nodeId ); - string GetNodeProductId( uint8 const _nodeId ); - void SetNodeManufacturerName( uint8 const _nodeId, string const& _manufacturerName ); - void SetNodeProductName( uint8 const _nodeId, string const& _productName ); - void SetNodeName( uint8 const _nodeId, string const& _nodeName ); - void SetNodeLocation( uint8 const _nodeId, string const& _location ); - void SetNodeLevel( uint8 const _nodeId, uint8 const _level ); - void SetNodeOn( uint8 const _nodeId ); - void SetNodeOff( uint8 const _nodeId ); - - Value* GetValue( ValueID const& _id ); - - bool IsAPICallSupported( uint8 const _apinum )const{ return (( m_apiMask[( _apinum - 1 ) >> 3] & ( 1 << (( _apinum - 1 ) & 0x07 ))) != 0 ); } - void SetAPICall( uint8 const _apinum, bool _toSet ) - { - if( _toSet ) - { - m_apiMask[( _apinum - 1 ) >> 3] |= ( 1 << (( _apinum - 1 ) & 0x07 )); - } - else - { - m_apiMask[( _apinum - 1 ) >> 3] &= ~( 1 << (( _apinum - 1 ) & 0x07 )); - } - } - uint8 NodeFromMessage( uint8 const* buffer ); - - //----------------------------------------------------------------------------- - // Controller commands - //----------------------------------------------------------------------------- - public: - /** - * Controller Commands. - * Commands to be used with the BeginControllerCommand method. - * \see Manager::BeginControllerCommand - */ - enum ControllerCommand - { - ControllerCommand_None = 0, /**< No command. */ - ControllerCommand_AddDevice, /**< Add a new device or controller to the Z-Wave network. */ - ControllerCommand_CreateNewPrimary, /**< Add a new controller to the Z-Wave network. Used when old primary fails. Requires SUC. */ - ControllerCommand_ReceiveConfiguration, /**< Receive Z-Wave network configuration information from another controller. */ - ControllerCommand_RemoveDevice, /**< Remove a device or controller from the Z-Wave network. */ - ControllerCommand_RemoveFailedNode, /**< Move a node to the controller's failed nodes list. This command will only work if the node cannot respond. */ - ControllerCommand_HasNodeFailed, /**< Check whether a node is in the controller's failed nodes list. */ - ControllerCommand_ReplaceFailedNode, /**< Replace a non-responding node with another. The node must be in the controller's list of failed nodes for this command to succeed. */ - ControllerCommand_TransferPrimaryRole, /**< Make a different controller the primary. */ - ControllerCommand_RequestNetworkUpdate, /**< Request network information from the SUC/SIS. */ - ControllerCommand_RequestNodeNeighborUpdate, /**< Get a node to rebuild its neighbour list. This method also does RequestNodeNeighbors */ - ControllerCommand_AssignReturnRoute, /**< Assign a network return routes to a device. */ - ControllerCommand_DeleteAllReturnRoutes, /**< Delete all return routes from a device. */ - ControllerCommand_SendNodeInformation, /**< Send a node information frame */ - ControllerCommand_ReplicationSend, /**< Send information from primary to secondary */ - ControllerCommand_CreateButton, /**< Create an id that tracks handheld button presses */ - ControllerCommand_DeleteButton /**< Delete id that tracks handheld button presses */ - }; - - /** - * Controller States. - * States reported via the callback handler passed into the BeginControllerCommand method. - * \see Manager::BeginControllerCommand - */ - enum ControllerState - { - ControllerState_Normal = 0, /**< No command in progress. */ - ControllerState_Starting, /**< The command is starting. */ - ControllerState_Cancel, /**< The command was cancelled. */ - ControllerState_Error, /**< Command invocation had error(s) and was aborted */ - ControllerState_Waiting, /**< Controller is waiting for a user action. */ - ControllerState_Sleeping, /**< Controller command is on a sleep queue wait for device. */ - ControllerState_InProgress, /**< The controller is communicating with the other device to carry out the command. */ - ControllerState_Completed, /**< The command has completed successfully. */ - ControllerState_Failed, /**< The command has failed. */ - ControllerState_NodeOK, /**< Used only with ControllerCommand_HasNodeFailed to indicate that the controller thinks the node is OK. */ - ControllerState_NodeFailed /**< Used only with ControllerCommand_HasNodeFailed to indicate that the controller thinks the node has failed. */ - }; - - /** - * Controller Errors - * Provide some more information about controller failures. - */ - enum ControllerError - { - ControllerError_None = 0, - ControllerError_ButtonNotFound, /**< Button */ - ControllerError_NodeNotFound, /**< Button */ - ControllerError_NotBridge, /**< Button */ - ControllerError_NotSUC, /**< CreateNewPrimary */ - ControllerError_NotSecondary, /**< CreateNewPrimary */ - ControllerError_NotPrimary, /**< RemoveFailedNode, AddNodeToNetwork */ - ControllerError_IsPrimary, /**< ReceiveConfiguration */ - ControllerError_NotFound, /**< RemoveFailedNode */ - ControllerError_Busy, /**< RemoveFailedNode, RequestNetworkUpdate */ - ControllerError_Failed, /**< RemoveFailedNode, RequestNetworkUpdate */ - ControllerError_Disabled, /**< RequestNetworkUpdate error */ - ControllerError_Overflow /**< RequestNetworkUpdate error */ - }; - - typedef void (*pfnControllerCallback_t)( ControllerState _state, ControllerError _err, void* _context ); - - private: - // The public interface is provided via the wrappers in the Manager class - void ResetController( Event* _evt ); - void SoftReset(); - void RequestNodeNeighbors( uint8 const _nodeId, uint32 const _requestFlags ); - - bool BeginControllerCommand( ControllerCommand _command, pfnControllerCallback_t _callback, void* _context, bool _highPower, uint8 _nodeId, uint8 _arg ); - bool CancelControllerCommand(); - void AddNodeStop( uint8 const _funcId ); // Handle different controller behaviors - - struct ControllerCommandItem - { - ControllerState m_controllerState; - bool m_controllerStateChanged; - bool m_controllerCommandDone; - ControllerCommand m_controllerCommand; - pfnControllerCallback_t m_controllerCallback; - ControllerError m_controllerReturnError; - void* m_controllerCallbackContext; - bool m_highPower; - bool m_controllerAdded; - uint8 m_controllerCommandNode; - uint8 m_controllerCommandArg; - }; - - ControllerCommandItem* m_currentControllerCommand; - - void DoControllerCommand(); - void UpdateControllerState( ControllerState const _state, ControllerError const _error = ControllerError_None ) - { - if( m_currentControllerCommand != NULL ) - { - if( _state != m_currentControllerCommand->m_controllerState ) - { - m_currentControllerCommand->m_controllerStateChanged = true; - m_currentControllerCommand->m_controllerState = _state; - switch( _state ) - { - case ControllerState_Error: - case ControllerState_Cancel: - case ControllerState_Failed: - case ControllerState_Sleeping: - case ControllerState_NodeFailed: - case ControllerState_NodeOK: - case ControllerState_Completed: - { - m_currentControllerCommand->m_controllerCommandDone = true; - m_sendMutex->Lock(); - m_queueEvent[MsgQueue_Controller]->Set(); - m_sendMutex->Unlock(); - break; - } - default: - { - break; - } - } - - } - if( _error != ControllerError_None ) - { - m_currentControllerCommand->m_controllerReturnError = _error; - } - } - } - - uint8 m_SUCNodeId; - - void UpdateNodeRoutes( uint8 const_nodeId, bool _doUpdate = false ); - - Event* m_controllerResetEvent; - - //----------------------------------------------------------------------------- - // Sending Z-Wave messages - //----------------------------------------------------------------------------- - public: - enum MsgQueue - { - MsgQueue_Command = 0, - MsgQueue_Security, - MsgQueue_NoOp, - MsgQueue_Controller, - MsgQueue_WakeUp, - MsgQueue_Send, - MsgQueue_Query, - MsgQueue_Poll, - MsgQueue_Count // Number of message queues - }; - - void SendMsg( Msg* _msg, MsgQueue const _queue ); - - /** - * Fetch the transmit options - */ - uint8 GetTransmitOptions()const{ return m_transmitOptions; } - - private: - /** - * If there are messages in the send queue (m_sendQueue), gets the next message in the - * queue and writes it to the serial port. In sending the message, SendMsg also initializes - * variables tracking the message's callback ID (m_expectedCallbackId), expected reply - * (m_expectedReply) and expected command class ID (m_expectedCommandClassId). It also - * sets m_waitingForAck to true and increments the message's send attempts counter. - *

- * If there are no messages in the send queue, then SendMsg checks the query queue to - * see if there are any outstanding queries that can be processed (target node not asleep). - * If so, it retrieves the Node object that needs to be queried and calls that node's - * AdvanceQueries member function. If this call results in all of the node's queries to be - * completed, SendMsg will remove the node query item from the query queue. - * \return TRUE if data was written, FALSE if not - * \see Msg, m_sendQueue, m_expectedCallbackId, m_expectedReply, m_expectedCommandClassId, - * m_waitingForAck, Msg::GetSendAttempts, Node::AdvanceQueries, GetCurrentNodeQuery, - * RemoveNodeQuery, Node::AllQueriesCompleted - */ - bool WriteNextMsg( MsgQueue const _queue ); // Extracts the first message from the queue, and makes it the current one. - bool WriteMsg( string const &str); // Sends the current message to the Z-Wave network - void RemoveCurrentMsg(); // Deletes the current message and cleans up the callback etc states - bool MoveMessagesToWakeUpQueue( uint8 const _targetNodeId, bool const _move ); // If a node does not respond, and is of a type that can sleep, this method is used to move all its pending messages to another queue ready for when it mext wakes up. - bool HandleErrorResponse( uint8 const _error, uint8 const _nodeId, char const* _funcStr, bool _sleepCheck = false ); // Handle data errors and process consistently. If message is moved to wake-up queue, return true. - bool IsExpectedReply( uint8 const _nodeId ); // Determine if reply message is the one we are expecting - void SendQueryStageComplete( uint8 const _nodeId, Node::QueryStage const _stage ); - void RetryQueryStageComplete( uint8 const _nodeId, Node::QueryStage const _stage ); - void CheckCompletedNodeQueries(); // Send notifications if all awake and/or sleeping nodes have completed their queries - - // Requests to be sent to nodes are assigned to one of five queues. - // From highest to lowest priority, these are - // - // 0) The security queue, for handling encrypted messages. This is the - // highest priority send queue, because the security process inserts - // messages to handle the encryption process that must be sent before - // a new message can be wrapped. - // - // 1) The command queue, for controller commands. This is the 2nd highest - // priority send queue, because the controller command processes are not - // permitted to be interupted by other requests. - // - // 2) The controller queue exists to handle multi-step controller commands. These - // typically require user interaction or affect the network in some way. - // - // 3) The No Operation command class queue. This is used for device probing - // at startup as well as network diagostics. - // - // 4) The wakeup queue. This holds messages that have been held for a - // sleeping device that has now woken up. These get a high priority - // because such devices do not stay awake for very long. - // - // 5) The send queue. This is for normal messages, usually triggered by - // a user interaction with the application. - // - // 6) The query queue. For node query messages sent when a new node is - // discovered. The query process generates a large number of requests, - // so the query queue has a low priority to avoid making the system - // unresponsive. - // - // 7) The poll queue. Requests to devices that need their state polling - // at regular intervals. These are of the lowest priority, and are only - // sent when nothing else is going on - // - enum MsgQueueCmd - { - MsgQueueCmd_SendMsg = 0, - MsgQueueCmd_QueryStageComplete, - MsgQueueCmd_Controller - }; - - class MsgQueueItem - { - public: - MsgQueueItem() : - m_msg(NULL), - m_nodeId(0), - m_queryStage(Node::QueryStage_None), - m_retry(false), - m_cci(NULL) - {} - - bool operator == ( MsgQueueItem const& _other )const - { - if( _other.m_command == m_command ) - { - if( m_command == MsgQueueCmd_SendMsg ) - { - return( (*_other.m_msg) == (*m_msg) ); - } - else if( m_command == MsgQueueCmd_QueryStageComplete ) - { - return( (_other.m_nodeId == m_nodeId) && (_other.m_queryStage == m_queryStage) ); - } - else if( m_command == MsgQueueCmd_Controller ) - { - return( (_other.m_cci->m_controllerCommand == m_cci->m_controllerCommand) && (_other.m_cci->m_controllerCallback == m_cci->m_controllerCallback) ); - } - } - - return false; - } - - MsgQueueCmd m_command; - Msg* m_msg; - uint8 m_nodeId; - Node::QueryStage m_queryStage; - bool m_retry; - ControllerCommandItem* m_cci; - }; - -OPENZWAVE_EXPORT_WARNINGS_OFF - list m_msgQueue[MsgQueue_Count]; -OPENZWAVE_EXPORT_WARNINGS_ON - Event* m_queueEvent[MsgQueue_Count]; // Events for each queue, which are signalled when the queue is not empty - Mutex* m_sendMutex; // Serialize access to the queues - Msg* m_currentMsg; - MsgQueue m_currentMsgQueueSource; // identifies which queue held m_currentMsg - TimeStamp m_resendTimeStamp; - - //----------------------------------------------------------------------------- - // Network functions - //----------------------------------------------------------------------------- - private: - void TestNetwork( uint8 const _nodeId, uint32 const _count ); - - //----------------------------------------------------------------------------- - // Virtual Node commands - //----------------------------------------------------------------------------- - public: - /** - * Virtual Node Commands. - * Commands to be used with virtual nodes. - */ - private: - uint32 GetVirtualNeighbors( uint8** o_neighbors ); - void RequestVirtualNeighbors( MsgQueue const _queue ); - bool IsVirtualNode( uint8 const _nodeId )const{ return (( m_virtualNeighbors[( _nodeId - 1 ) >> 3] & 1 << (( _nodeId - 1 ) & 0x07 )) != 0 ); } - void SendVirtualNodeInfo( uint8 const _fromNodeId, uint8 const _ToNodeId ); - void SendSlaveLearnModeOff(); - void SaveButtons(); - void ReadButtons( uint8 const _nodeId ); - - bool m_virtualNeighborsReceived; - uint8 m_virtualNeighbors[NUM_NODE_BITFIELD_BYTES]; // Bitmask containing virtual neighbors - - //----------------------------------------------------------------------------- - // SwitchAll - //----------------------------------------------------------------------------- - private: - // The public interface is provided via the wrappers in the Manager class - void SwitchAllOn(); - void SwitchAllOff(); - - //----------------------------------------------------------------------------- - // Configuration Parameters (wrappers for the Node methods) - //----------------------------------------------------------------------------- - private: - // The public interface is provided via the wrappers in the Manager class - bool SetConfigParam( uint8 const _nodeId, uint8 const _param, int32 _value, uint8 const _size ); - void RequestConfigParam( uint8 const _nodeId, uint8 const _param ); - - //----------------------------------------------------------------------------- - // Groups (wrappers for the Node methods) - //----------------------------------------------------------------------------- - private: - // The public interface is provided via the wrappers in the Manager class - uint8 GetNumGroups( uint8 const _nodeId ); - uint32 GetAssociations( uint8 const _nodeId, uint8 const _groupIdx, uint8** o_associations ); - uint8 GetMaxAssociations( uint8 const _nodeId, uint8 const _groupIdx ); - string GetGroupLabel( uint8 const _nodeId, uint8 const _groupIdx ); - void AddAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId ); - void RemoveAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId ); - - //----------------------------------------------------------------------------- - // Notifications - //----------------------------------------------------------------------------- - private: - void QueueNotification( Notification* _notification ); // Adds a notification to the list. Notifications are queued until a point in the thread where we know we do not have any nodes locked. - void NotifyWatchers(); // Passes the notifications to all the registered watcher callbacks in turn. - -OPENZWAVE_EXPORT_WARNINGS_OFF - list m_notifications; -OPENZWAVE_EXPORT_WARNINGS_ON - Event* m_notificationsEvent; - - //----------------------------------------------------------------------------- - // Statistics - //----------------------------------------------------------------------------- - public: - struct DriverData - { - uint32 m_SOFCnt; // Number of SOF bytes received - uint32 m_ACKWaiting; // Number of unsolicited messages while waiting for an ACK - uint32 m_readAborts; // Number of times read were aborted due to timeouts - uint32 m_badChecksum; // Number of bad checksums - uint32 m_readCnt; // Number of messages successfully read - uint32 m_writeCnt; // Number of messages successfully sent - uint32 m_CANCnt; // Number of CAN bytes received - uint32 m_NAKCnt; // Number of NAK bytes received - uint32 m_ACKCnt; // Number of ACK bytes received - uint32 m_OOFCnt; // Number of bytes out of framing - uint32 m_dropped; // Number of messages dropped & not delivered - uint32 m_retries; // Number of messages retransmitted - uint32 m_callbacks; // Number of unexpected callbacks - uint32 m_badroutes; // Number of failed messages due to bad route response - uint32 m_noack; // Number of no ACK returned errors - uint32 m_netbusy; // Number of network busy/failure messages - uint32 m_notidle; - uint32 m_nondelivery; // Number of messages not delivered to network - uint32 m_routedbusy; // Number of messages received with routed busy status - uint32 m_broadcastReadCnt; // Number of broadcasts read - uint32 m_broadcastWriteCnt; // Number of broadcasts sent - }; - - void LogDriverStatistics(); - - private: - void GetDriverStatistics( DriverData* _data ); - void GetNodeStatistics( uint8 const _nodeId, Node::NodeData* _data ); - - uint32 m_SOFCnt; // Number of SOF bytes received - uint32 m_ACKWaiting; // Number of unsolcited messages while waiting for an ACK - uint32 m_readAborts; // Number of times read were aborted due to timeouts - uint32 m_badChecksum; // Number of bad checksums - uint32 m_readCnt; // Number of messages successfully read - uint32 m_writeCnt; // Number of messages successfully sent - uint32 m_CANCnt; // Number of CAN bytes received - uint32 m_NAKCnt; // Number of NAK bytes received - uint32 m_ACKCnt; // Number of ACK bytes received - uint32 m_OOFCnt; // Number of bytes out of framing - uint32 m_dropped; // Number of messages dropped & not delivered - uint32 m_retries; // Number of retransmitted messages - uint32 m_callbacks; // Number of unexpected callbacks - uint32 m_badroutes; // Number of failed messages due to bad route response - uint32 m_noack; // Number of no ACK returned errors - uint32 m_netbusy; // Number of network busy/failure messages - uint32 m_notidle; // Number of not idle messages - uint32 m_nondelivery; // Number of messages not delivered to network - uint32 m_routedbusy; // Number of messages received with routed busy status - uint32 m_broadcastReadCnt; // Number of broadcasts read - uint32 m_broadcastWriteCnt; // Number of broadcasts sent - //time_t m_commandStart; // Start time of last command - //time_t m_timeoutLost; // Cumulative time lost to timeouts - - - //----------------------------------------------------------------------------- - // Security Command Class Related (Version 1.1) - //----------------------------------------------------------------------------- - private: - uint8 *GetNetworkKey(); - }; - -} // namespace OpenZWave - -#endif // _Driver_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/Group.cpp b/lib/ESPiLight/pilight/libs/openzwave/Group.cpp deleted file mode 100644 index acd1776..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Group.cpp +++ /dev/null @@ -1,422 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Group.cpp -// -// A set of associations in a Z-Wave device. -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include "Group.h" -#include "Manager.h" -#include "Driver.h" -#include "Node.h" -#include "Notification.h" -#include "Options.h" -#include "command_classes/Association.h" -#include "command_classes/AssociationCommandConfiguration.h" - -#include "tinyxml.h" - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Group::Group -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _groupIdx, - uint8 const _maxAssociations -): - m_homeId( _homeId ), - m_nodeId( _nodeId ), - m_groupIdx( _groupIdx ), - m_maxAssociations( _maxAssociations ), - m_auto( false ) -{ - char str[16]; - snprintf( str, sizeof(str), "Group %d", m_groupIdx ); - m_label = str; - - // Auto-association by default is with group 1 or 255, with group 1 taking precedence. - // Group 255 is always created first, so if this is group 1, we need to turn off the - // auto flag in group 255. All this messing about is to support the various behaviours - // of certain Cooper devices. - if( _groupIdx == 255 ) - { - m_auto = true; - } - else if( _groupIdx == 1 ) - { - m_auto = true; - - // Clear the flag from Group 255, if it exists. - if( Driver* driver = Manager::Get()->GetDriver( m_homeId ) ) - { - if( Node* node = driver->GetNodeUnsafe( m_nodeId ) ) - { - if( Group* group = node->GetGroup( 255 ) ) - { - group->SetAuto( false ); - } - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Constructor (from XML) -//----------------------------------------------------------------------------- -Group::Group -( - uint32 const _homeId, - uint8 const _nodeId, - TiXmlElement const* _groupElement -): - m_homeId( _homeId ), - m_nodeId( _nodeId ), - m_groupIdx( 0 ), - m_maxAssociations( 0 ), - m_auto( false ) -{ - int intVal; - char const* str; - vector pending; - - if( TIXML_SUCCESS == _groupElement->QueryIntAttribute( "index", &intVal ) ) - { - m_groupIdx = (uint8)intVal; - } - - if( TIXML_SUCCESS == _groupElement->QueryIntAttribute( "max_associations", &intVal ) ) - { - m_maxAssociations = (uint8)intVal; - } - - str = _groupElement->Attribute( "auto" ); - if( str ) - { - m_auto = !strcmp( str, "true" ); - } - - str = _groupElement->Attribute( "label" ); - if( str ) - { - m_label = str; - } - - // Read the associations for this group - TiXmlElement const* associationElement = _groupElement->FirstChildElement(); - while( associationElement ) - { - char const* elementName = associationElement->Value(); - if( elementName && !strcmp( elementName, "Node" ) ) - { - if (associationElement->QueryIntAttribute( "id", &intVal ) == TIXML_SUCCESS) - pending.push_back( (uint8)intVal ); - } - - associationElement = associationElement->NextSiblingElement(); - } - - // Group must be added before OnGroupChanged is called so UpdateNodeRoutes can find it. - // Since we do not want to update return routes UpdateNodeRoutes won't find the group - // so nothing will go out from here. The not sending of return routes information - // only works by a side effect of not finding the group. - OnGroupChanged( pending ); -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void Group::WriteXML -( - TiXmlElement* _groupElement -) -{ - char str[16]; - - snprintf( str, 16, "%d", m_groupIdx ); - _groupElement->SetAttribute( "index", str ); - - snprintf( str, 16, "%d", m_maxAssociations ); - _groupElement->SetAttribute( "max_associations", str ); - - _groupElement->SetAttribute( "label", m_label.c_str() ); - _groupElement->SetAttribute( "auto", m_auto ? "true" : "false" ); - - for( map::iterator it = m_associations.begin(); it != m_associations.end(); ++it ) - { - TiXmlElement* associationElement = new TiXmlElement( "Node" ); - - snprintf( str, 16, "%d", it->first ); - associationElement->SetAttribute( "id", str ); - - _groupElement->LinkEndChild( associationElement ); - } -} - -//----------------------------------------------------------------------------- -// -// Whether a group contains a particular node -//----------------------------------------------------------------------------- -bool Group::Contains -( - uint8 const _nodeId -) -{ - map::iterator it = m_associations.find( _nodeId ); - return( it != m_associations.end() ); -} - -//----------------------------------------------------------------------------- -// -// Associate a node with this group -//----------------------------------------------------------------------------- -void Group::AddAssociation -( - uint8 const _nodeId -) -{ - if( Driver* driver = Manager::Get()->GetDriver( m_homeId ) ) - { - if( Node* node = driver->GetNodeUnsafe( m_nodeId ) ) - { - if( Association* cc = static_cast( node->GetCommandClass( Association::StaticGetCommandClassId() ) ) ) - { - cc->Set( m_groupIdx, _nodeId ); - cc->QueryGroup( m_groupIdx, 0 ); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Remove a node from this group -//----------------------------------------------------------------------------- -void Group::RemoveAssociation -( - uint8 const _nodeId -) -{ - if( Driver* driver = Manager::Get()->GetDriver( m_homeId ) ) - { - if( Node* node = driver->GetNodeUnsafe( m_nodeId ) ) - { - if( Association* cc = static_cast( node->GetCommandClass( Association::StaticGetCommandClassId() ) ) ) - { - cc->Remove( m_groupIdx, _nodeId ); - cc->QueryGroup( m_groupIdx, 0 ); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Change the group contents and notify the watchers -//----------------------------------------------------------------------------- -void Group::OnGroupChanged -( - vector const& _associations -) -{ - bool notify = false; - - // If the number of associations is different, we'll save - // ourselves some work and clear the old set now. - if( _associations.size() != m_associations.size() ) - { - m_associations.clear(); - notify = true; - } - else - { - // Handle initial group creation case - if ( _associations.size() == 0 && m_associations.size() == 0 ) - { - notify = true; - } - } - - // Add the new associations. - uint8 oldSize = (uint8)m_associations.size(); - - uint8 i; - for( i=0; i<_associations.size(); ++i ) - { - m_associations[_associations[i]] = AssociationCommandVec(); - } - - if( (!notify) && ( oldSize != m_associations.size() ) ) - { - // The number of nodes in the original and new groups is the same, but - // the number of associations has grown. There must be different nodes - // in the original and new sets of nodes in the group. The easiest way - // to sort this out is to clear the associations and add the new nodes again. - m_associations.clear(); - for( i=0; i<_associations.size(); ++i ) - { - m_associations[_associations[i]] = AssociationCommandVec(); - } - notify = true; - } - - if( notify ) - { - // If the node supports COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION, we need to request the command data. - if( Driver* driver = Manager::Get()->GetDriver( m_homeId ) ) - { - if( Node* node = driver->GetNodeUnsafe( m_nodeId ) ) - { - if( AssociationCommandConfiguration* cc = static_cast( node->GetCommandClass( AssociationCommandConfiguration::StaticGetCommandClassId() ) ) ) - { - for( map::iterator it = m_associations.begin(); it != m_associations.end(); ++it ) - { - cc->RequestCommands( m_groupIdx, it->first ); - } - } - } - } - - // Send notification that the group contents have changed - Notification* notification = new Notification( Notification::Type_Group ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - notification->SetGroupIdx( m_groupIdx ); - Manager::Get()->GetDriver( m_homeId )->QueueNotification( notification ); - // Update routes on remote node if necessary - bool update = false; - Options::Get()->GetOptionAsBool( "PerformReturnRoutes", &update ); - if( update ) - { - Driver *drv = Manager::Get()->GetDriver( m_homeId ); - if (drv) - drv->UpdateNodeRoutes( m_nodeId ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Get a list of associations for this group -//----------------------------------------------------------------------------- -uint32 Group::GetAssociations -( - uint8** o_associations -) -{ - size_t numNodes = m_associations.size(); - if( !numNodes ) - { - *o_associations = NULL; - return 0; - } - - uint8* associations = new uint8[numNodes]; - uint32 i = 0; - for( map::iterator it = m_associations.begin(); it != m_associations.end(); ++it ) - { - associations[i++] = it->first; - } - - *o_associations = associations; - return (uint32) numNodes; -} - -//----------------------------------------------------------------------------- -// Command methods (COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION) -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Clear all the commands for the specified node -//----------------------------------------------------------------------------- -bool Group::ClearCommands -( - uint8 const _nodeId -) -{ - map::iterator it = m_associations.find( _nodeId ); - if( it != m_associations.end() ) - { - it->second.clear(); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a command to the list for the specified node -//----------------------------------------------------------------------------- -bool Group::AddCommand -( - uint8 const _nodeId, - uint8 const _length, - uint8 const* _data -) -{ - map::iterator it = m_associations.find( _nodeId ); - if( it != m_associations.end() ) - { - it->second.push_back( AssociationCommand( _length, _data ) ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Group::AssociationCommand::AssociationCommand -( - uint8 const _length, - uint8 const* _data -): - m_length( _length ) -{ - m_data = new uint8[_length]; - memcpy( m_data, _data, _length ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Group::AssociationCommand::~AssociationCommand -( -) -{ - delete [] m_data; -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/Group.h b/lib/ESPiLight/pilight/libs/openzwave/Group.h deleted file mode 100644 index 39f600e..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Group.h +++ /dev/null @@ -1,114 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Group.h -// -// A set of associations in a Z-Wave device. -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Group_H -#define _Group_H - -#include -#include -#include -#include "Defs.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Node; - - /** \brief Manages a group of devices (various nodes associated with each other). - */ - class Group - { - friend class Node; - friend class Association; - - //----------------------------------------------------------------------------- - // Construction - //----------------------------------------------------------------------------- - public: - Group( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _maxAssociations ); - Group( uint32 const _homeId, uint8 const _nodeId, TiXmlElement const* _valueElement ); - ~Group(){} - - void WriteXML( TiXmlElement* _groupElement ); - - //----------------------------------------------------------------------------- - // Association methods (COMMAND_CLASS_ASSOCIATION) - //----------------------------------------------------------------------------- - public: - string const& GetLabel()const{ return m_label; } - uint32 GetAssociations( uint8** o_associations ); - uint8 GetMaxAssociations()const{ return m_maxAssociations; } - uint8 GetIdx()const{ return m_groupIdx; } - bool Contains( uint8 const _nodeId ); - - private: - bool IsAuto()const{ return m_auto; } - void SetAuto( bool const _state ){ m_auto = _state; } - - void AddAssociation( uint8 const _nodeId ); - void RemoveAssociation( uint8 const _nodeId ); - void OnGroupChanged( vector const& _associations ); - - //----------------------------------------------------------------------------- - // Command methods (COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION) - //----------------------------------------------------------------------------- - public: - bool ClearCommands( uint8 const _nodeId ); - bool AddCommand( uint8 const _nodeId, uint8 const _length, uint8 const* _data ); - - private: - class AssociationCommand - { - public: - AssociationCommand( uint8 const _length, uint8 const* _data ); - ~AssociationCommand(); - - private: - uint8 m_length; - uint8* m_data; - }; - - typedef vector AssociationCommandVec; - - //----------------------------------------------------------------------------- - // Member variables - //----------------------------------------------------------------------------- - private: - string m_label; - uint32 m_homeId; - uint8 m_nodeId; - uint8 m_groupIdx; - uint8 m_maxAssociations; - bool m_auto; // If true, the controller will automatically be associated with the group - map m_associations; - }; - -} //namespace OpenZWave - -#endif //_Group_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/Manager.cpp b/lib/ESPiLight/pilight/libs/openzwave/Manager.cpp deleted file mode 100644 index 621fbe1..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Manager.cpp +++ /dev/null @@ -1,4049 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Manager.cpp -// -// The main public interface to OpenZWave. -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include -#include - -#include "Defs.h" -#include "Manager.h" -#include "Driver.h" -#include "Node.h" -#include "Notification.h" -#include "Options.h" -#include "Scene.h" - -#include "platform/Mutex.h" -#include "platform/Event.h" -#include "platform/Log.h" - -#include "command_classes/CommandClasses.h" -#include "command_classes/CommandClass.h" -#include "command_classes/WakeUp.h" - -#include "value_classes/ValueID.h" -#include "value_classes/ValueBool.h" -#include "value_classes/ValueButton.h" -#include "value_classes/ValueByte.h" -#include "value_classes/ValueDecimal.h" -#include "value_classes/ValueInt.h" -#include "value_classes/ValueList.h" -#include "value_classes/ValueRaw.h" -#include "value_classes/ValueSchedule.h" -#include "value_classes/ValueShort.h" -#include "value_classes/ValueString.h" - -using namespace OpenZWave; - -Manager* Manager::s_instance = NULL; -extern uint16_t ozw_vers_major; -extern uint16_t ozw_vers_minor; -extern uint16_t ozw_vers_revision; - -//----------------------------------------------------------------------------- -// Construction -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Static creation of the singleton -//----------------------------------------------------------------------------- -Manager* Manager::Create -( -) -{ - if( Options::Get() && Options::Get()->AreLocked() ) - { - if( NULL == s_instance ) - { - s_instance = new Manager(); - } - return s_instance; - } - - // Options have not been created and locked. - Log::Create( "", false, true, LogLevel_Debug, LogLevel_Debug, LogLevel_None ); - Log::Write( LogLevel_Error, "Options have not been created and locked. Exiting..." ); - exit(1); - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Static method to destroy the singleton. -//----------------------------------------------------------------------------- -void Manager::Destroy -( -) -{ - delete s_instance; - s_instance = NULL; -} - -//----------------------------------------------------------------------------- -// -// Static method to get the Version of OZW as a string. -//----------------------------------------------------------------------------- -std::string Manager::getVersionAsString() { - std::ostringstream versionstream; - versionstream << ozw_vers_major << "." << ozw_vers_minor << "." << ozw_vers_revision; - return versionstream.str(); -} -//----------------------------------------------------------------------------- -// -// Static method to get the Version of OZW. -//----------------------------------------------------------------------------- -ozwversion Manager::getVersion() { - return version(ozw_vers_major, ozw_vers_minor); -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Manager::Manager -( -): - m_notificationMutex( new Mutex() ) -{ - // Ensure the singleton instance is set - s_instance = this; - - // Create the log file (if enabled) - bool logging = false; - Options::Get()->GetOptionAsBool( "Logging", &logging ); - - string userPath = ""; - Options::Get()->GetOptionAsString( "UserPath", &userPath ); - - string logFileNameBase = "OZW_Log.txt"; - Options::Get()->GetOptionAsString( "LogFileName", &logFileNameBase ); - - bool bAppend = false; - Options::Get()->GetOptionAsBool( "AppendLogFile", &bAppend ); - - bool bConsoleOutput = true; - Options::Get()->GetOptionAsBool( "ConsoleOutput", &bConsoleOutput ); - - int nSaveLogLevel = (int) LogLevel_Detail; - Options::Get()->GetOptionAsInt( "SaveLogLevel", &nSaveLogLevel ); - - int nQueueLogLevel = (int) LogLevel_Debug; - Options::Get()->GetOptionAsInt( "QueueLogLevel", &nQueueLogLevel ); - - int nDumpTrigger = (int) LogLevel_Warning; - Options::Get()->GetOptionAsInt( "DumpTriggerLevel", &nDumpTrigger ); - - string logFilename = userPath + logFileNameBase; - Log::Create( logFilename, bAppend, bConsoleOutput, (LogLevel) nSaveLogLevel, (LogLevel) nQueueLogLevel, (LogLevel) nDumpTrigger ); - Log::SetLoggingState( logging ); - - CommandClasses::RegisterCommandClasses(); - Scene::ReadScenes(); - Log::Write(LogLevel_Always, "OpenZwave Version %s Starting Up", getVersionAsString().c_str()); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Manager::~Manager -( -) -{ - // Clear the pending list - while( !m_pendingDrivers.empty() ) - { - list::iterator it = m_pendingDrivers.begin(); - delete *it; - m_pendingDrivers.erase( it ); - } - - // Clear the ready map - while( !m_readyDrivers.empty() ) - { - map::iterator it = m_readyDrivers.begin(); - delete it->second; - m_readyDrivers.erase( it ); - } - - m_notificationMutex->Release(); - - // Clear the watchers list - while( !m_watchers.empty() ) - { - list::iterator it = m_watchers.begin(); - delete *it; - m_watchers.erase( it ); - } - - // Clear the generic device class list - while( !Node::s_genericDeviceClasses.empty() ) - { - map::iterator git = Node::s_genericDeviceClasses.begin(); - delete git->second; - Node::s_genericDeviceClasses.erase( git ); - } - - Log::Destroy(); -} - -//----------------------------------------------------------------------------- -// Configuration -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Save the configuration of a driver to a file -//----------------------------------------------------------------------------- -void Manager::WriteConfig -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->WriteConfig(); - Log::Write( LogLevel_Info, "mgr, Manager::WriteConfig completed for driver with home ID of 0x%.8x", _homeId ); - } - else - { - Log::Write( LogLevel_Info, "mgr, Manager::WriteConfig failed - _homeId %d not found", _homeId ); - } - Scene::WriteXML( "zwscene.xml" ); -} - -//----------------------------------------------------------------------------- -// Drivers -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Add a new Z-Wave PC Interface -//----------------------------------------------------------------------------- -bool Manager::AddDriver -( - string const& _controllerPath, - Driver::ControllerInterface const& _interface -) -{ - // Make sure we don't already have a driver for this controller - - // Search the pending list - for( list::iterator pit = m_pendingDrivers.begin(); pit != m_pendingDrivers.end(); ++pit ) - { - if( _controllerPath == (*pit)->GetControllerPath() ) - { - Log::Write( LogLevel_Info, "mgr, Cannot add driver for controller %s - driver already exists", _controllerPath.c_str() ); - return false; - } - } - - // Search the ready map - for( map::iterator rit = m_readyDrivers.begin(); rit != m_readyDrivers.end(); ++rit ) - { - if( _controllerPath == rit->second->GetControllerPath() ) - { - Log::Write( LogLevel_Info, "mgr, Cannot add driver for controller %s - driver already exists", _controllerPath.c_str() ); - return false; - } - } - - Driver* driver = new Driver( _controllerPath, _interface ); - m_pendingDrivers.push_back( driver ); - driver->Start(); - - Log::Write( LogLevel_Info, "mgr, Added driver for controller %s", _controllerPath.c_str() ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Remove a Z-Wave PC Interface -//----------------------------------------------------------------------------- -bool Manager::RemoveDriver -( - string const& _controllerPath -) -{ - // Search the pending list - for( list::iterator pit = m_pendingDrivers.begin(); pit != m_pendingDrivers.end(); ++pit ) - { - if( _controllerPath == (*pit)->GetControllerPath() ) - { - delete *pit; - m_pendingDrivers.erase( pit ); - Log::Write( LogLevel_Info, "mgr, Driver for controller %s removed", _controllerPath.c_str() ); - return true; - } - } - - // Search the ready map - for( map::iterator rit = m_readyDrivers.begin(); rit != m_readyDrivers.end(); ++rit ) - { - if( _controllerPath == rit->second->GetControllerPath() ) - { - /* data race right here: - * Before, we were deleting the Driver Class direct from the Map... this was causing a datarace: - * 1) Driver::~Driver destructor starts deleting everything.... - * 2) This Triggers Notifications such as ValueDeleted etc - * 3) Notifications are delivered to applications, and applications start calling - * Manager Functions which require the Driver (such as IsPolled(valueid)) - * 4) Manager looks up the Driver in the m_readyDriver and returns a pointer to the Driver Class - * which is currently being destructed. - * 5) All Hell Breaks loose and we crash and burn. - * - * But we can't change this, as the Driver Destructor triggers internal GetDriver calls... which - * will crash and burn if they can't get a valid Driver back... - */ - Log::Write( LogLevel_Info, "mgr, Driver for controller %s pending removal", _controllerPath.c_str() ); - delete rit->second; - m_readyDrivers.erase( rit ); - Log::Write( LogLevel_Info, "mgr, Driver for controller %s removed", _controllerPath.c_str() ); - return true; - } - } - - Log::Write( LogLevel_Info, "mgr, Failed to remove driver for controller %s", _controllerPath.c_str() ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Get a pointer to the driver for a Z-Wave PC Interface -//----------------------------------------------------------------------------- -Driver* Manager::GetDriver -( - uint32 const _homeId -) -{ - map::iterator it = m_readyDrivers.find( _homeId ); - if( it != m_readyDrivers.end() ) - { - return it->second; - } - - Log::Write( LogLevel_Error, "mgr, Manager::GetDriver failed - Home ID 0x%.8x is unknown", _homeId ); - //assert(0); << Don't assert as this might be a valid condition when we call RemoveDriver. See comments above. - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Move a driver from pending to ready, and notify any watchers -//----------------------------------------------------------------------------- -void Manager::SetDriverReady -( - Driver* _driver, - bool success -) -{ - // Search the pending list - bool found = false; - for( list::iterator it = m_pendingDrivers.begin(); it != m_pendingDrivers.end(); ++it ) - { - if( (*it) == _driver ) - { - // Remove the driver from the pending list - m_pendingDrivers.erase( it ); - found = true; - break; - } - } - - if( found ) - { - if (success) { - Log::Write( LogLevel_Info, "mgr, Driver with Home ID of 0x%.8x is now ready.", _driver->GetHomeId() ); - Log::Write( LogLevel_Info, "" ); - } - - // Add the driver to the ready map - m_readyDrivers[_driver->GetHomeId()] = _driver; - - // Notify the watchers - Notification* notification = new Notification(success ? Notification::Type_DriverReady : Notification::Type_DriverFailed ); - notification->SetHomeAndNodeIds( _driver->GetHomeId(), _driver->GetNodeId() ); - _driver->QueueNotification( notification ); - } -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -uint8 Manager::GetControllerNodeId -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeId(); - } - - Log::Write( LogLevel_Info, "mgr, GetControllerNodeId() failed - _homeId %d not found", _homeId ); - return 0xff; -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -uint8 Manager::GetSUCNodeId -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetSUCNodeId(); - } - - Log::Write( LogLevel_Info, "mgr, GetSUCNodeId() failed - _homeId %d not found", _homeId ); - return 0xff; -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -bool Manager::IsPrimaryController -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->IsPrimaryController(); - } - - Log::Write( LogLevel_Info, "mgr, IsPrimaryController() failed - _homeId %d not found", _homeId ); - return false; -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -bool Manager::IsStaticUpdateController -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->IsStaticUpdateController(); - } - - Log::Write( LogLevel_Info, "mgr, IsStaticUpdateController() failed - _homeId %d not found", _homeId ); - return false; -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -bool Manager::IsBridgeController -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->IsBridgeController(); - } - - Log::Write( LogLevel_Info, "mgr, IsBridgeController() failed - _homeId %d not found", _homeId ); - return false; -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -string Manager::GetLibraryVersion -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetLibraryVersion(); - } - - Log::Write( LogLevel_Info, "mgr, GetLibraryVersion() failed - _homeId %d not found", _homeId ); - return ""; -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -string Manager::GetLibraryTypeName -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetLibraryTypeName(); - } - - Log::Write( LogLevel_Info, "mgr, GetLibraryTypeName() failed - _homeId %d not found", _homeId ); - return ""; -} - -//----------------------------------------------------------------------------- -// -// -//----------------------------------------------------------------------------- -int32 Manager::GetSendQueueCount -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetSendQueueCount(); - } - - Log::Write( LogLevel_Info, "mgr, GetSendQueueCount() failed - _homeId %d not found", _homeId ); - return -1; -} - -//----------------------------------------------------------------------------- -// -// Send driver statistics to the log file -//----------------------------------------------------------------------------- -void Manager::LogDriverStatistics -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->LogDriverStatistics(); - } - - Log::Write( LogLevel_Warning, "mgr, LogDriverStatistics() failed - _homeId %d not found", _homeId ); -} - -//----------------------------------------------------------------------------- -// -// Retrieve controller interface type -//----------------------------------------------------------------------------- -Driver::ControllerInterface Manager::GetControllerInterfaceType -( - uint32 const _homeId -) -{ - Driver::ControllerInterface ifType = Driver::ControllerInterface_Unknown; - if( Driver* driver = GetDriver( _homeId ) ) - { - ifType = driver->GetControllerInterfaceType(); - } - return ifType; -} - -//----------------------------------------------------------------------------- -// -// Retrieve controller interface path -//----------------------------------------------------------------------------- -string Manager::GetControllerPath -( - uint32 const _homeId -) -{ - string path = ""; - if( Driver* driver = GetDriver( _homeId ) ) - { - path = driver->GetControllerPath(); - } - return path; -} -//----------------------------------------------------------------------------- -// Polling Z-Wave values -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Return the polling interval -//----------------------------------------------------------------------------- -int32 Manager::GetPollInterval -( -) -{ - for( map::iterator rit = m_readyDrivers.begin(); rit != m_readyDrivers.end(); ++rit ) - { - return rit->second->GetPollInterval(); - } - for( list::iterator pit = m_pendingDrivers.begin(); pit != m_pendingDrivers.end(); ++pit ) - { - return (*pit)->GetPollInterval(); - } - return 0; - -} - -//----------------------------------------------------------------------------- -// -// Set the polling interval on all drivers -//----------------------------------------------------------------------------- -void Manager::SetPollInterval -( - int32 _milliseconds, - bool _bIntervalBetweenPolls -) -{ - for( list::iterator pit = m_pendingDrivers.begin(); pit != m_pendingDrivers.end(); ++pit ) - { - (*pit)->SetPollInterval( _milliseconds, _bIntervalBetweenPolls ); - } - - for( map::iterator rit = m_readyDrivers.begin(); rit != m_readyDrivers.end(); ++rit ) - { - rit->second->SetPollInterval( _milliseconds, _bIntervalBetweenPolls ); - } -} - -//----------------------------------------------------------------------------- -// -// Enable polling of a value -//----------------------------------------------------------------------------- -bool Manager::EnablePoll -( - ValueID const &_valueId, - uint8 const _intensity -) -{ - if( Driver* driver = GetDriver( _valueId.GetHomeId() ) ) - { - return( driver->EnablePoll( _valueId, _intensity ) ); - } - - Log::Write( LogLevel_Info, "mgr, EnablePoll failed - Driver with Home ID 0x%.8x is not available", _valueId.GetHomeId() ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Disable polling of a value -//----------------------------------------------------------------------------- -bool Manager::DisablePoll -( - ValueID const &_valueId -) -{ - if( Driver* driver = GetDriver( _valueId.GetHomeId() ) ) - { - return( driver->DisablePoll( _valueId ) ); - } - - Log::Write( LogLevel_Info, "mgr, DisablePoll failed - Driver with Home ID 0x%.8x is not available", _valueId.GetHomeId() ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Check polling status of a value -//----------------------------------------------------------------------------- -bool Manager::isPolled -( - ValueID const &_valueId -) -{ - if( Driver* driver = GetDriver( _valueId.GetHomeId() ) ) - { - return( driver->isPolled( _valueId ) ); - } - - Log::Write( LogLevel_Info, "mgr, isPolled failed - Driver with Home ID 0x%.8x is not available", _valueId.GetHomeId() ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Change the intensity with which this value is polled -//----------------------------------------------------------------------------- -void Manager::SetPollIntensity -( - ValueID const &_valueId, - uint8 const _intensity -) -{ - if( Driver* driver = GetDriver( _valueId.GetHomeId() ) ) - { - return( driver->SetPollIntensity( _valueId, _intensity ) ); - } - - Log::Write( LogLevel_Error, "mgr, SetPollIntensity failed - Driver with Home ID 0x%.8x is not available", _valueId.GetHomeId() ); -} - -//----------------------------------------------------------------------------- -// -// Change the intensity with which this value is polled -//----------------------------------------------------------------------------- -uint8 Manager::GetPollIntensity -( - ValueID const &_valueId -) -{ - uint8 intensity = 0; - if( Driver* driver = GetDriver( _valueId.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _valueId ) ) - { - intensity = value->GetPollIntensity(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return intensity; -} - -//----------------------------------------------------------------------------- -// Retrieving Node information -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Fetch the data for a node from the Z-Wave network -//----------------------------------------------------------------------------- -bool Manager::RefreshNodeInfo -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - // Cause the node's data to be obtained from the Z-Wave network - // in the same way as if it had just been added. - Node* node = driver->GetNode( _nodeId ); - if( node ) - { - node->SetQueryStage( Node::QueryStage_ProtocolInfo ); - driver->ReleaseNodes(); - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Fetch the command class data for a node from the Z-Wave network -//----------------------------------------------------------------------------- -bool Manager::RequestNodeState -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - // Retreive the Node's session and dynamic data - Node* node = driver->GetNode( _nodeId ); - if( node ) - { - node->SetQueryStage( Node::QueryStage_Associations ); - driver->ReleaseNodes(); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Fetch only the dynamic command class data for a node from the Z-Wave network -//----------------------------------------------------------------------------- -bool Manager::RequestNodeDynamic -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - // Retreive the Node's dynamic data - Node* node = driver->GetNode( _nodeId ); - if( node ) - { - node->SetQueryStage( Node::QueryStage_Dynamic ); - driver->ReleaseNodes(); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a listening device that does not go to sleep -//----------------------------------------------------------------------------- -bool Manager::IsNodeListeningDevice -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - bool res = false; - if( Driver* driver = GetDriver( _homeId ) ) - { - res = driver->IsNodeListeningDevice( _nodeId ); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a listening device that does not go to sleep -//----------------------------------------------------------------------------- -bool Manager::IsNodeFrequentListeningDevice -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - bool res = false; - if( Driver* driver = GetDriver( _homeId ) ) - { - res = driver->IsNodeFrequentListeningDevice( _nodeId ); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a beam capable device. -//----------------------------------------------------------------------------- -bool Manager::IsNodeBeamingDevice -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - bool res = false; - if( Driver* driver = GetDriver( _homeId ) ) - { - res = driver->IsNodeBeamingDevice( _nodeId ); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get whether the node is a routing device that passes messages to other nodes -//----------------------------------------------------------------------------- -bool Manager::IsNodeRoutingDevice -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - bool res = false; - if( Driver* driver = GetDriver( _homeId ) ) - { - res = driver->IsNodeRoutingDevice( _nodeId ); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Get the security attribute for a node. -//----------------------------------------------------------------------------- -bool Manager::IsNodeSecurityDevice -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - bool security = 0; - if( Driver* driver = GetDriver( _homeId ) ) - { - security = driver->IsNodeSecurityDevice( _nodeId ); - } - - return security; -} - -//----------------------------------------------------------------------------- -// -// Get the maximum baud rate of a node's communications -//----------------------------------------------------------------------------- -uint32 Manager::GetNodeMaxBaudRate -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - uint32 baud = 0; - if( Driver* driver = GetDriver( _homeId ) ) - { - baud = driver->GetNodeMaxBaudRate( _nodeId ); - } - - return baud; -} - -//----------------------------------------------------------------------------- -// -// Get the version number of a node -//----------------------------------------------------------------------------- -uint8 Manager::GetNodeVersion -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - uint8 version = 0; - if( Driver* driver = GetDriver( _homeId ) ) - { - version = driver->GetNodeVersion( _nodeId ); - } - - return version; -} - -//----------------------------------------------------------------------------- -// -// Get the security byte of a node -//----------------------------------------------------------------------------- -uint8 Manager::GetNodeSecurity -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - uint8 version = 0; - if( Driver* driver = GetDriver( _homeId ) ) - { - version = driver->GetNodeSecurity( _nodeId ); - } - - return version; -} - -//----------------------------------------------------------------------------- -// -// Get the basic type of a node -//----------------------------------------------------------------------------- -uint8 Manager::GetNodeBasic -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - uint8 basic = 0; - if( Driver* driver = GetDriver( _homeId ) ) - { - basic = driver->GetNodeBasic( _nodeId ); - } - - return basic; -} - -//----------------------------------------------------------------------------- -// -// Get the generic type of a node -//----------------------------------------------------------------------------- -uint8 Manager::GetNodeGeneric -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - uint8 genericType = 0; - if( Driver* driver = GetDriver( _homeId ) ) - { - genericType = driver->GetNodeGeneric( _nodeId ); - } - - return genericType; -} - -//----------------------------------------------------------------------------- -// -// Get the specific type of a node -//----------------------------------------------------------------------------- -uint8 Manager::GetNodeSpecific -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - uint8 specific = 0; - if( Driver* driver = GetDriver( _homeId ) ) - { - specific = driver->GetNodeSpecific( _nodeId ); - } - - return specific; -} - -//----------------------------------------------------------------------------- -// -// Get a string describing the type of a node -//----------------------------------------------------------------------------- -string Manager::GetNodeType -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeType( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Get the bitmap of this node's neighbors -//----------------------------------------------------------------------------- -uint32 Manager::GetNodeNeighbors -( - uint32 const _homeId, - uint8 const _nodeId, - uint8** o_neighbors -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeNeighbors( _nodeId, o_neighbors ); - } - - return 0; -} - -//----------------------------------------------------------------------------- -// -// Get the manufacturer name of a node -//----------------------------------------------------------------------------- -string Manager::GetNodeManufacturerName -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeManufacturerName( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Get the product name of a node -//----------------------------------------------------------------------------- -string Manager::GetNodeProductName -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeProductName( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Get the user-editable name of a node -//----------------------------------------------------------------------------- -string Manager::GetNodeName -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeName( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Get the location of a node -//----------------------------------------------------------------------------- -string Manager::GetNodeLocation -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeLocation( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Set the manufacturer name a node -//----------------------------------------------------------------------------- -void Manager::SetNodeManufacturerName -( - uint32 const _homeId, - uint8 const _nodeId, - string const& _manufacturerName -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->SetNodeManufacturerName( _nodeId, _manufacturerName ); - } -} - -//----------------------------------------------------------------------------- -// -// Set the product name of a node -//----------------------------------------------------------------------------- -void Manager::SetNodeProductName -( - uint32 const _homeId, - uint8 const _nodeId, - string const& _productName -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->SetNodeProductName( _nodeId, _productName ); - } -} - -//----------------------------------------------------------------------------- -// -// Set the node name value with the specified ID -//----------------------------------------------------------------------------- -void Manager::SetNodeName -( - uint32 const _homeId, - uint8 const _nodeId, - string const& _nodeName -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->SetNodeName( _nodeId, _nodeName ); - } -} - -//----------------------------------------------------------------------------- -// -// Set a string describing the location of a node -//----------------------------------------------------------------------------- -void Manager::SetNodeLocation -( - uint32 const _homeId, - uint8 const _nodeId, - string const& _location - -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->SetNodeLocation( _nodeId, _location ); - } -} - -//----------------------------------------------------------------------------- -// -// Get the manufacturer ID value of a node -//----------------------------------------------------------------------------- -string Manager::GetNodeManufacturerId -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeManufacturerId( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Get the product type value of a node -//----------------------------------------------------------------------------- -string Manager::GetNodeProductType -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeProductType( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Get the product Id value with the specified ID -//----------------------------------------------------------------------------- -string Manager::GetNodeProductId -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNodeProductId( _nodeId ); - } - - return "Unknown"; -} - -//----------------------------------------------------------------------------- -// -// Helper method to turn a node on -//----------------------------------------------------------------------------- -void Manager::SetNodeOn -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->SetNodeOn( _nodeId ); - } -} - -//----------------------------------------------------------------------------- -// -// Helper method to turn a node off -//----------------------------------------------------------------------------- -void Manager::SetNodeOff -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->SetNodeOff( _nodeId ); - } -} - -//----------------------------------------------------------------------------- -// -// Helper method to return whether a particular class is available in a node -//----------------------------------------------------------------------------- -bool Manager::IsNodeInfoReceived -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - bool result = false; - - if( Driver* driver = GetDriver( _homeId ) ) - { - Node *node; - - // Need to lock and unlock nodes to check this information - driver->LockNodes(); - - if( (node = driver->GetNodeUnsafe( _nodeId ) ) != NULL) - { - result = node->NodeInfoReceived(); - } - - driver->ReleaseNodes(); - } - - return result; -} - -//----------------------------------------------------------------------------- -// -// Helper method to return whether a particular class is available in a node -//----------------------------------------------------------------------------- -bool Manager::GetNodeClassInformation -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - string *_className, - uint8 *_classVersion -) -{ - bool result = false; - - if( Driver* driver = GetDriver( _homeId ) ) - { - Node *node; - - // Need to lock and unlock nodes to check this information - driver->LockNodes(); - - if( ( node = driver->GetNodeUnsafe( _nodeId ) ) != NULL ) - { - CommandClass *cc; - if( node->NodeInfoReceived() && ( ( cc = node->GetCommandClass( _commandClassId ) ) != NULL ) ) - { - if( _className ) - { - *_className = cc->GetCommandClassName(); - } - if( _classVersion ) - { - *_classVersion = cc->GetVersion(); - } - // Positive result - result = true; - } - } - - driver->ReleaseNodes(); - } - - return result; -} - -//----------------------------------------------------------------------------- -// -// Helper method to return whether a node is awake or sleeping -//----------------------------------------------------------------------------- -bool Manager::IsNodeAwake -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( IsNodeListeningDevice( _homeId, _nodeId ) ) - { - return true; // if listening then always awake - } - bool result = true; - if( Driver* driver = GetDriver( _homeId ) ) - { - // Need to lock and unlock nodes to check this information - driver->LockNodes(); - - if( Node* node = driver->GetNodeUnsafe( _nodeId ) ) - { - if( WakeUp* wcc = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - result = wcc->IsAwake(); - } - } - driver->ReleaseNodes(); - } - return result; -} - -//----------------------------------------------------------------------------- -// -// Helper method to return whether a node is on the network or not -//----------------------------------------------------------------------------- -bool Manager::IsNodeFailed -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - bool result = false; - if( Driver* driver = GetDriver( _homeId ) ) - { - if( Node* node = driver->GetNode( _nodeId ) ) - { - result = !node->IsNodeAlive(); - driver->ReleaseNodes(); - } - } - return result; -} - -//----------------------------------------------------------------------------- -// -// Helper method to return whether a node's query stage -//----------------------------------------------------------------------------- -string Manager::GetNodeQueryStage -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - string result = "Unknown"; - if( Driver* driver = GetDriver( _homeId ) ) - { - if( Node* node = driver->GetNode( _nodeId ) ) - { - result = node->GetQueryStageName( node->GetCurrentQueryStage() ); - driver->ReleaseNodes(); - } - } - return result; -} - -//----------------------------------------------------------------------------- -// -// Helper method to set the basic level of a node -//----------------------------------------------------------------------------- -void Manager::SetNodeLevel -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _level -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->SetNodeLevel( _nodeId, _level ); - } -} - -//----------------------------------------------------------------------------- -// Values -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Gets the user-friendly label for the value -//----------------------------------------------------------------------------- -string Manager::GetValueLabel -( - ValueID const& _id -) -{ - string label; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - label = value->GetLabel(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return label; -} - -//----------------------------------------------------------------------------- -// -// Sets the user-friendly label for the value -//----------------------------------------------------------------------------- -void Manager::SetValueLabel -( - ValueID const& _id, - string const& _value -) -{ - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - value->SetLabel( _value ); - value->Release(); - } - driver->ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Gets the units that the value is measured in -//----------------------------------------------------------------------------- -string Manager::GetValueUnits -( - ValueID const& _id -) -{ - string units; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - units = value->GetUnits(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return units; -} - -//----------------------------------------------------------------------------- -// -// Sets the units that the value is measured in -//----------------------------------------------------------------------------- -void Manager::SetValueUnits -( - ValueID const& _id, - string const& _value -) -{ - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - value->SetUnits( _value ); - value->Release(); - } - driver->ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Gets a help string describing the value's purpose and usage -//----------------------------------------------------------------------------- -string Manager::GetValueHelp -( - ValueID const& _id -) -{ - string help; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - help = value->GetHelp(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return help; -} - -//----------------------------------------------------------------------------- -// -// Sets a help string describing the value's purpose and usage -//----------------------------------------------------------------------------- -void Manager::SetValueHelp -( - ValueID const& _id, - string const& _value -) -{ - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - value->SetHelp( _value ); - value->Release(); - } - driver->ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Gets the minimum for a value -//----------------------------------------------------------------------------- -int32 Manager::GetValueMin -( - ValueID const& _id -) -{ - int32 limit = 0; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - limit = value->GetMin(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return limit; -} - -//----------------------------------------------------------------------------- -// -// Gets the maximum for a value -//----------------------------------------------------------------------------- -int32 Manager::GetValueMax -( - ValueID const& _id -) -{ - int32 limit = 0; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - limit = value->GetMax(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return limit; -} - -//----------------------------------------------------------------------------- -// -// Test whether the value is read-only -//----------------------------------------------------------------------------- -bool Manager::IsValueReadOnly -( - ValueID const& _id -) -{ - bool res = false; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - res = value->IsReadOnly(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Test whether the value is write-only -//----------------------------------------------------------------------------- -bool Manager::IsValueWriteOnly -( - ValueID const& _id -) -{ - bool res = false; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - res = value->IsWriteOnly(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Test whether the value has been set by a status message from the device -//----------------------------------------------------------------------------- -bool Manager::IsValueSet -( - ValueID const& _id -) -{ - bool res = false; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - res = value->IsSet(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Test whether the value is currently being polled -//----------------------------------------------------------------------------- -bool Manager::IsValuePolled -( - ValueID const& _id -) -{ - bool res = false; - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - res = value->IsPolled(); - value->Release(); - } - driver->ReleaseNodes(); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets a value as a bool -//----------------------------------------------------------------------------- -bool Manager::GetValueAsBool -( - ValueID const& _id, - bool* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_Bool == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueBool* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetValue(); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - else if( ValueID::ValueType_Button == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueButton* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->IsPressed(); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets a value as an 8-bit unsigned integer -//----------------------------------------------------------------------------- -bool Manager::GetValueAsByte -( - ValueID const& _id, - uint8* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_Byte == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueByte* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetValue(); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets a value as a floating point number -//----------------------------------------------------------------------------- -bool Manager::GetValueAsFloat -( - ValueID const& _id, - float* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_Decimal == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueDecimal* value = static_cast( driver->GetValue( _id ) ) ) - { - string str = value->GetValue(); - *o_value = (float)atof( str.c_str() ); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets a value as a 32-bit signed integer -//----------------------------------------------------------------------------- -bool Manager::GetValueAsInt -( - ValueID const& _id, - int32* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_Int == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueInt* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetValue(); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets a value as a collection of bytes -//----------------------------------------------------------------------------- -bool Manager::GetValueAsRaw -( - ValueID const& _id, - uint8** o_value, - uint8* o_length -) -{ - bool res = false; - - if( o_value && o_length ) - { - if( ValueID::ValueType_Raw == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueRaw* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_length = value->GetLength(); - *o_value = new uint8[*o_length]; - memcpy( *o_value, value->GetValue(), *o_length ); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets a value as a 16-bit signed integer -//----------------------------------------------------------------------------- -bool Manager::GetValueAsShort -( - ValueID const& _id, - int16* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_Short == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueShort* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetValue(); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Creates a string representation of the value, regardless of type -//----------------------------------------------------------------------------- -bool Manager::GetValueAsString -( - ValueID const& _id, - string* o_value -) -{ - bool res = false; - char str[256] = {0}; - - if( o_value ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - - switch( _id.GetType() ) - { - case ValueID::ValueType_Bool: - { - if( ValueBool* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetValue() ? "True" : "False"; - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_Byte: - { - if( ValueByte* value = static_cast( driver->GetValue( _id ) ) ) - { - snprintf( str, sizeof(str), "%u", value->GetValue() ); - *o_value = str; - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_Decimal: - { - if( ValueDecimal* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetValue(); - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_Int: - { - if( ValueInt* value = static_cast( driver->GetValue( _id ) ) ) - { - snprintf( str, sizeof(str), "%d", value->GetValue() ); - *o_value = str; - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_List: - { - if( ValueList* value = static_cast( driver->GetValue( _id ) ) ) - { - ValueList::Item const& item = value->GetItem(); - *o_value = item.m_label; - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_Raw: - { - if( ValueRaw* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetAsString(); - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_Short: - { - if( ValueShort* value = static_cast( driver->GetValue( _id ) ) ) - { - snprintf( str, sizeof(str), "%d", value->GetValue() ); - *o_value = str; - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_String: - { - if( ValueString* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetValue(); - value->Release(); - res = true; - } - break; - } - case ValueID::ValueType_Button: - { - if( ValueButton* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->IsPressed() ? "True" : "False"; - value->Release(); - res = true; - } - break; - } - default: - { - // To keep GCC happy - break; - } - } - - driver->ReleaseNodes(); - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets the selected item from a list value (returning a string) -//----------------------------------------------------------------------------- -bool Manager::GetValueListSelection -( - ValueID const& _id, - string* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_List == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueList* value = static_cast( driver->GetValue( _id ) ) ) - { - ValueList::Item const& item = value->GetItem(); - if( &item != NULL ) - { - *o_value = item.m_label; - res = true; - } - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets the selected item from a list value (returning the index) -//----------------------------------------------------------------------------- -bool Manager::GetValueListSelection -( - ValueID const& _id, - int32* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_List == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueList* value = static_cast( driver->GetValue( _id ) ) ) - { - ValueList::Item const& item = value->GetItem(); - *o_value = item.m_value; - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets the list of items from a list value -//----------------------------------------------------------------------------- -bool Manager::GetValueListItems -( - ValueID const& _id, - vector* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_List == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueList* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->GetItemLabels( o_value ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Gets a value's scale as a uint8 -//----------------------------------------------------------------------------- -bool Manager::GetValueFloatPrecision -( - ValueID const& _id, - uint8* o_value -) -{ - bool res = false; - - if( o_value ) - { - if( ValueID::ValueType_Decimal == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueDecimal* value = static_cast( driver->GetValue( _id ) ) ) - { - *o_value = value->GetPrecision(); - value->Release(); - res = true; - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the value from a bool -//----------------------------------------------------------------------------- -bool Manager::SetValue -( - ValueID const& _id, - bool const _value -) -{ - bool res = false; - - if( ValueID::ValueType_Bool == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - if( ValueBool* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->Set( _value ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the value from a byte -//----------------------------------------------------------------------------- -bool Manager::SetValue -( - ValueID const& _id, - uint8 const _value -) -{ - bool res = false; - - if( ValueID::ValueType_Byte == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - if( ValueByte* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->Set( _value ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the value from a floating point number -//----------------------------------------------------------------------------- -bool Manager::SetValue -( - ValueID const& _id, - float const _value -) -{ - bool res = false; - - if( ValueID::ValueType_Decimal == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - if( ValueDecimal* value = static_cast( driver->GetValue( _id ) ) ) - { - char str[256]; - snprintf( str, sizeof(str), "%f", _value ); - - // remove trailing zeros (and the decimal point, if present) - // TODO: better way of figuring out which locale is being used ('.' or ',' to separate decimals) - size_t nLen; - if( ( strchr( str, '.' ) != NULL) || (strchr( str, ',' ) != NULL ) ) - { - for( nLen = strlen( str ) - 1; nLen > 0; nLen-- ) - { - if( str[nLen] == '0' ) - str[nLen] = 0; - else - break; - } - if( (str[nLen] == '.') || (str[nLen] == ',') ) - str[nLen] = 0; - } - - // now set the value - res = value->Set( str ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the value from a 32-bit signed integer -//----------------------------------------------------------------------------- -bool Manager::SetValue -( - ValueID const& _id, - int32 const _value -) -{ - bool res = false; - - if( ValueID::ValueType_Int == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - if( ValueInt* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->Set( _value ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the value from a collection of bytes -//----------------------------------------------------------------------------- -bool Manager::SetValue -( - ValueID const& _id, - uint8 const* _value, - uint8 const _length -) -{ - bool res = false; - - if( ValueID::ValueType_Raw == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - if( ValueRaw* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->Set( _value, _length ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the value from a 16-bit signed integer -//----------------------------------------------------------------------------- -bool Manager::SetValue -( - ValueID const& _id, - int16 const _value -) -{ - bool res = false; - - if( ValueID::ValueType_Short == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - if( ValueShort* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->Set( _value ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the selected item in a list by value -//----------------------------------------------------------------------------- -bool Manager::SetValueListSelection -( - ValueID const& _id, - string const& _selectedItem -) -{ - bool res = false; - - if( ValueID::ValueType_List == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - if( ValueList* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->SetByLabel( _selectedItem ); - value->Release(); - } - driver->ReleaseNodes(); - } - - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Sets the value from a string -//----------------------------------------------------------------------------- -bool Manager::SetValue -( - ValueID const& _id, - string const& _value -) -{ - bool res = false; - - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - if( _id.GetNodeId() != driver->GetNodeId() ) - { - driver->LockNodes(); - - switch( _id.GetType() ) - { - case ValueID::ValueType_Bool: - { - if( ValueBool* value = static_cast( driver->GetValue( _id ) ) ) - { - if( !strcasecmp( "true", _value.c_str() ) ) - { - res = value->Set( true ); - } - else if( !strcasecmp( "false", _value.c_str() ) ) - { - res = value->Set( false ); - } - value->Release(); - } - break; - } - case ValueID::ValueType_Byte: - { - if( ValueByte* value = static_cast( driver->GetValue( _id ) ) ) - { - uint32 val = (uint32)atoi( _value.c_str() ); - if( val < 256 ) - { - res = value->Set( (uint8)val ); - } - value->Release(); - } - break; - } - case ValueID::ValueType_Decimal: - { - if( ValueDecimal* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->Set( _value ); - value->Release(); - } - break; - } - case ValueID::ValueType_Int: - { - if( ValueInt* value = static_cast( driver->GetValue( _id ) ) ) - { - int32 val = atoi( _value.c_str() ); - res = value->Set( val ); - value->Release(); - } - break; - } - case ValueID::ValueType_List: - { - if( ValueList* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->SetByLabel( _value ); - value->Release(); - } - break; - } - case ValueID::ValueType_Short: - { - if( ValueShort* value = static_cast( driver->GetValue( _id ) ) ) - { - int32 val = (uint32)atoi( _value.c_str() ); - if( ( val < 32768 ) && ( val >= -32768 ) ) - { - res = value->Set( (int16)val ); - } - value->Release(); - } - break; - } - case ValueID::ValueType_String: - { - if( ValueString* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->Set( _value ); - value->Release(); - } - break; - } - case ValueID::ValueType_Raw: - { - if( ValueRaw* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->SetFromString( _value ); - value->Release(); - } - break; - } - default: - { - // To keep GCC happy - break; - } - } - driver->ReleaseNodes(); - } - } - return res; -} - -//----------------------------------------------------------------------------- -// -// Instruct the driver to refresh this value by sending a message to the device -//----------------------------------------------------------------------------- -bool Manager::RefreshValue -( - ValueID const& _id -) -{ - bool bRet = false; // return value - - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - Node *node; - - // Need to lock and unlock nodes to check this information - driver->LockNodes(); - - if( (node = driver->GetNodeUnsafe( _id.GetNodeId() ) ) != NULL) - { - CommandClass* cc = node->GetCommandClass( _id.GetCommandClassId() ); - if (cc) { - uint8 index = _id.GetIndex(); - uint8 instance = _id.GetInstance(); - Log::Write( LogLevel_Info, "mgr, Refreshing node %d: %s index = %d instance = %d (to confirm a reported change)", node->m_nodeId, cc->GetCommandClassName().c_str(), index, instance ); - cc->RequestValue( 0, index, instance, Driver::MsgQueue_Send ); - bRet = true; - } else { - bRet = false; - } - } - driver->ReleaseNodes(); - } - return bRet; -} - -//----------------------------------------------------------------------------- -// -// Set the verify changes flag for the specified value -//----------------------------------------------------------------------------- -void Manager::SetChangeVerified -( - ValueID const& _id, - bool _verify -) -{ - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( Value* value = driver->GetValue( _id ) ) - { - value->SetChangeVerified( _verify ); - value->Release(); - } - driver->ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Starts an activity in a device. -//----------------------------------------------------------------------------- -bool Manager::PressButton -( - ValueID const& _id -) -{ - bool res = false; - - if( ValueID::ValueType_Button == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueButton* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->PressButton(); - value->Release(); - } - driver->ReleaseNodes(); - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Stops an activity in a device. -//----------------------------------------------------------------------------- -bool Manager::ReleaseButton -( - ValueID const& _id -) -{ - bool res = false; - - if( ValueID::ValueType_Button == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueButton* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->ReleaseButton(); - value->Release(); - } - driver->ReleaseNodes(); - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// Climate Control Schedules -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Get the number of switch points defined in a schedule -//----------------------------------------------------------------------------- -uint8 Manager::GetNumSwitchPoints -( - ValueID const& _id -) -{ -// bool res = false; - - uint8 numSwitchPoints = 0; - if( ValueID::ValueType_Schedule == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueSchedule* value = static_cast( driver->GetValue( _id ) ) ) - { - numSwitchPoints = value->GetNumSwitchPoints(); - value->Release(); - } - driver->ReleaseNodes(); - } - } - - return numSwitchPoints; -} - -//----------------------------------------------------------------------------- -// -// Set a switch point in the schedule -//----------------------------------------------------------------------------- -bool Manager::SetSwitchPoint -( - ValueID const& _id, - uint8 const _hours, - uint8 const _minutes, - int8 const _setback -) -{ - bool res = false; - - if( ValueID::ValueType_Schedule == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueSchedule* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->SetSwitchPoint( _hours, _minutes, _setback ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Remove a switch point from the schedule -//----------------------------------------------------------------------------- -bool Manager::RemoveSwitchPoint -( - ValueID const& _id, - uint8 const _hours, - uint8 const _minutes -) -{ - bool res = false; - - if( ValueID::ValueType_Schedule == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueSchedule* value = static_cast( driver->GetValue( _id ) ) ) - { - uint8 idx; - res = value->FindSwitchPoint( _hours, _minutes, &idx ); - - if( res ) - { - res = value->RemoveSwitchPoint( idx ); - } - value->Release(); - } - driver->ReleaseNodes(); - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Clears all switch points from the schedule -//----------------------------------------------------------------------------- -void Manager::ClearSwitchPoints -( - ValueID const& _id -) -{ - if( ValueID::ValueType_Schedule == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueSchedule* value = static_cast( driver->GetValue( _id ) ) ) - { - value->ClearSwitchPoints(); - value->Release(); - } - driver->ReleaseNodes(); - } - } -} - -//----------------------------------------------------------------------------- -// -// Gets switch point data from the schedule -//----------------------------------------------------------------------------- -bool Manager::GetSwitchPoint -( - ValueID const& _id, - uint8 const _idx, - uint8* o_hours, - uint8* o_minutes, - int8* o_setback -) -{ - bool res = false; - - if( ValueID::ValueType_Schedule == _id.GetType() ) - { - if( Driver* driver = GetDriver( _id.GetHomeId() ) ) - { - driver->LockNodes(); - if( ValueSchedule* value = static_cast( driver->GetValue( _id ) ) ) - { - res = value->GetSwitchPoint( _idx, o_hours, o_minutes, o_setback ); - value->Release(); - } - driver->ReleaseNodes(); - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// SwitchAll -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// All devices that support the SwitchAll command class will be turned on -//----------------------------------------------------------------------------- -void Manager::SwitchAllOn -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->SwitchAllOn(); - } -} - -//----------------------------------------------------------------------------- -// -// All devices that support the SwitchAll command class will be turned off -//----------------------------------------------------------------------------- -void Manager::SwitchAllOff -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->SwitchAllOff(); - } -} - -//----------------------------------------------------------------------------- -// Configuration Parameters -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Set the value of one of the configuration parameters of a device -//----------------------------------------------------------------------------- -bool Manager::SetConfigParam -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _param, - int32 _value, - uint8 const _size -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->SetConfigParam( _nodeId, _param, _value, _size ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request the value of one of the configuration parameters of a device -//----------------------------------------------------------------------------- -void Manager::RequestConfigParam -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _param -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->RequestConfigParam( _nodeId, _param ); - } -} - -//----------------------------------------------------------------------------- -// -// Request the values of all of the known configuration parameters of a device -//----------------------------------------------------------------------------- -void Manager::RequestAllConfigParams -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - Node* node = driver->GetNode( _nodeId ); - if( node ) - { - node->SetQueryStage( Node::QueryStage_Configuration ); - driver->ReleaseNodes(); - } - } -} - -//----------------------------------------------------------------------------- -// Groups -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Gets the number of association groups reported by this node -//----------------------------------------------------------------------------- -uint8 Manager::GetNumGroups -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetNumGroups( _nodeId ); - } - - return 0; -} - -//----------------------------------------------------------------------------- -// -// Gets the associations for a group -//----------------------------------------------------------------------------- -uint32 Manager::GetAssociations -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _groupIdx, - uint8** o_associations -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetAssociations( _nodeId, _groupIdx, o_associations ); - } - - return 0; -} - -//----------------------------------------------------------------------------- -// -// Gets the maximum number of associations for a group -//----------------------------------------------------------------------------- -uint8 Manager::GetMaxAssociations -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _groupIdx -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetMaxAssociations( _nodeId, _groupIdx ); - } - - return 0; -} - -//----------------------------------------------------------------------------- -// -// Gets the label for a particular group -//----------------------------------------------------------------------------- -string Manager::GetGroupLabel -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _groupIdx -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->GetGroupLabel( _nodeId, _groupIdx ); - } - - return ""; -} - -//----------------------------------------------------------------------------- -// -// Adds a node to an association group -//----------------------------------------------------------------------------- -void Manager::AddAssociation -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _groupIdx, - uint8 const _targetNodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->AddAssociation( _nodeId, _groupIdx, _targetNodeId ); - } -} - -//----------------------------------------------------------------------------- -// -// Removes a node from an association group -//----------------------------------------------------------------------------- -void Manager::RemoveAssociation -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _groupIdx, - uint8 const _targetNodeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->RemoveAssociation( _nodeId, _groupIdx, _targetNodeId ); - } -} - - -//----------------------------------------------------------------------------- -// Notifications -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Add a watcher to the list -//----------------------------------------------------------------------------- -bool Manager::AddWatcher -( - pfnOnNotification_t _watcher, - void* _context -) -{ - // Ensure this watcher is not already on the list - m_notificationMutex->Lock(); - for( list::iterator it = m_watchers.begin(); it != m_watchers.end(); ++it ) - { - if( ((*it)->m_callback == _watcher ) && ( (*it)->m_context == _context ) ) - { - // Already in the list - m_notificationMutex->Unlock(); - return false; - } - } - - m_watchers.push_back( new Watcher( _watcher, _context ) ); - m_notificationMutex->Unlock(); - return true; -} - -//----------------------------------------------------------------------------- -// -// Remove a watcher from the list -//----------------------------------------------------------------------------- -bool Manager::RemoveWatcher -( - pfnOnNotification_t _watcher, - void* _context -) -{ - m_notificationMutex->Lock(); - list::iterator it = m_watchers.begin(); - while( it != m_watchers.end() ) - { - if( ((*it)->m_callback == _watcher ) && ( (*it)->m_context == _context ) ) - { - delete (*it); - m_watchers.erase( it ); - m_notificationMutex->Unlock(); - return true; - } - ++it; - } - - m_notificationMutex->Unlock(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Notify any watching objects of a value change -//----------------------------------------------------------------------------- -void Manager::NotifyWatchers -( - Notification* _notification -) -{ - m_notificationMutex->Lock(); - for( list::iterator it = m_watchers.begin(); it != m_watchers.end(); ++it ) - { - Watcher* pWatcher = *it; - pWatcher->m_callback( _notification, pWatcher->m_context ); - } - m_notificationMutex->Unlock(); -} - -//----------------------------------------------------------------------------- -// Controller commands -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Reset controller and erase all node information -//----------------------------------------------------------------------------- -void Manager::ResetController -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - Event *event = new Event(); - driver->ResetController( event ); - Wait::Single( event ); - event->Release(); - string path = driver->GetControllerPath(); - Driver::ControllerInterface intf = driver->GetControllerInterfaceType(); - RemoveDriver( path ); - AddDriver( path, intf ); - Wait::Multiple( NULL, 0, 500 ); - } - RemoveAllScenes( _homeId ); -} - -//----------------------------------------------------------------------------- -// -// Soft-reset the Z-Wave controller chip -//----------------------------------------------------------------------------- -void Manager::SoftReset -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->SoftReset(); - } -} - -//----------------------------------------------------------------------------- -// -// Start the controller performing one of its network management functions -//----------------------------------------------------------------------------- -bool Manager::BeginControllerCommand -( - uint32 const _homeId, - Driver::ControllerCommand _command, - Driver::pfnControllerCallback_t _callback, // = NULL - void* _context, // = NULL - bool _highPower, // = false - uint8 _nodeId, // = 0xff - uint8 _arg // = 0 -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return driver->BeginControllerCommand( _command, _callback, _context, _highPower, _nodeId, _arg ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Stop the current controller function -//----------------------------------------------------------------------------- -bool Manager::CancelControllerCommand -( - uint32 const _homeId -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - return( driver->CancelControllerCommand() ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Send a number of test messages to a node and record results. -//----------------------------------------------------------------------------- -void Manager::TestNetworkNode -( - uint32 const _homeId, - uint8 const _nodeId, - uint32 const _count -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->TestNetwork( _nodeId, _count ); - } -} - -//----------------------------------------------------------------------------- -// -// Send a number of test messages to every node and record results. -//----------------------------------------------------------------------------- -void Manager::TestNetwork -( - uint32 const _homeId, - uint32 const _count -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->TestNetwork( 0, _count ); - } -} - -//----------------------------------------------------------------------------- -// -// Heal a single node in the network -//----------------------------------------------------------------------------- -void Manager::HealNetworkNode -( - uint32 const _homeId, - uint8 const _nodeId, - bool _doRR -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - Node* node = driver->GetNode( _nodeId ); - if( node ) - { - driver->BeginControllerCommand( Driver::ControllerCommand_RequestNodeNeighborUpdate, NULL, NULL, true, _nodeId, 0 ); - if( _doRR ) - { - driver->UpdateNodeRoutes( _nodeId, true ); - } - driver->ReleaseNodes(); - } - } -} - -//----------------------------------------------------------------------------- -// -// Heal the Z-Wave network one node at a time. -//----------------------------------------------------------------------------- -void Manager::HealNetwork -( - uint32 const _homeId, - bool _doRR -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->LockNodes(); - for( uint8 i=0; i<255; i++ ) - { - if( driver->m_nodes[i] != NULL ) - { - driver->BeginControllerCommand( Driver::ControllerCommand_RequestNodeNeighborUpdate, NULL, NULL, true, i, 0 ); - if( _doRR ) - { - driver->UpdateNodeRoutes( i, true ); - } - } - } - driver->ReleaseNodes(); - } -} - -//----------------------------------------------------------------------------- -// -// Return the number of defined scenes. -//----------------------------------------------------------------------------- -uint8 Manager::GetNumScenes -( -) -{ - return Scene::s_sceneCnt; -} - -//----------------------------------------------------------------------------- -// -// Return an array of all Scene Ids -//----------------------------------------------------------------------------- -uint8 Manager::GetAllScenes -( - uint8** _sceneIds -) -{ - *_sceneIds = NULL; - return Scene::GetAllScenes( _sceneIds ); -} - -//----------------------------------------------------------------------------- -// -// Remove every scene id -//----------------------------------------------------------------------------- -void Manager::RemoveAllScenes -( - uint32 const _homeId -) -{ - for( int i = 1; i < 256; i++ ) - { - if( _homeId == 0 ) // remove every device from every scene - { - RemoveScene( i ); - } - else - { - Scene *scene = Scene::Get( i ); - if( scene != NULL ) - { - scene->RemoveValues( _homeId ); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Create a new scene and return new Scene ID. -//----------------------------------------------------------------------------- -uint8 Manager::CreateScene -( -) -{ - for( int i = 1; i < 256; i++ ) - { - Scene* scene = Scene::Get( i ); - if( scene != NULL ) - { - continue; - } - new Scene( i ); - return i; - } - return 0; -} - -//----------------------------------------------------------------------------- -// -// Remove scene and delete its contents -//----------------------------------------------------------------------------- -bool Manager::RemoveScene -( - uint8 const _sceneId -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - delete scene; - return true; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a bool ValueID/value pair to the scene -//----------------------------------------------------------------------------- -bool Manager::AddSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - bool const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->AddValue( _valueId, _value ? "True" : "False"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a byte ValueID/value pair to the scene -//----------------------------------------------------------------------------- -bool Manager::AddSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - uint8 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->AddValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a decimal ValueID/value pair to the scene -//----------------------------------------------------------------------------- -bool Manager::AddSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - float const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%f", _value ); - return scene->AddValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add an integer ValueID/value pair to the scene -//----------------------------------------------------------------------------- -bool Manager::AddSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - int32 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->AddValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a short ValueID/value pair to the scene -//----------------------------------------------------------------------------- -bool Manager::AddSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - int16 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->AddValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a string ValueID/value pair to the scene -//----------------------------------------------------------------------------- -bool Manager::AddSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - string const& _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->AddValue( _valueId, _value ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a list selection item ValueID/value pair to the scene (as string) -//----------------------------------------------------------------------------- -bool Manager::AddSceneValueListSelection -( - uint8 const _sceneId, - ValueID const& _valueId, - string const& _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->AddValue( _valueId, _value ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Add a list selection item ValueID/value pair to the scene (as integer) -//----------------------------------------------------------------------------- -bool Manager::AddSceneValueListSelection -( - uint8 const _sceneId, - ValueID const& _valueId, - int32 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->AddValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Remove a ValueID/value pair from the scene -//----------------------------------------------------------------------------- -bool Manager::RemoveSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->RemoveValue( _valueId ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID -//----------------------------------------------------------------------------- -int Manager::SceneGetValues -( - uint8 const _sceneId, - vector* o_value -) -{ - o_value->clear(); - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->GetValues( o_value ); - } - return 0; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID bool value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueAsBool -( - uint8 const _sceneId, - ValueID const& _valueId, - bool* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - string str; - if( scene->GetValue( _valueId, &str ) ) - { - *o_value = !strcasecmp( "true", str.c_str() ); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID byte value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueAsByte -( - uint8 const _sceneId, - ValueID const& _valueId, - uint8* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - string str; - if( scene->GetValue( _valueId, &str ) ) - { - *o_value = (uint8)atoi( str.c_str() ); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID float value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueAsFloat -( - uint8 const _sceneId, - ValueID const& _valueId, - float* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - string str; - if( scene->GetValue( _valueId, &str ) ) - { - *o_value = (float)atof( str.c_str() ); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID integer value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueAsInt -( - uint8 const _sceneId, - ValueID const& _valueId, - int32* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - string str; - if( scene->GetValue( _valueId, &str ) ) - { - *o_value = (int32)atoi( str.c_str() ); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID short value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueAsShort -( - uint8 const _sceneId, - ValueID const& _valueId, - int16* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - string str; - if( scene->GetValue( _valueId, &str ) ) - { - *o_value = (int16)atoi( str.c_str() ); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID string value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueAsString -( - uint8 const _sceneId, - ValueID const& _valueId, - string* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - if( scene->GetValue( _valueId, o_value ) ) - { - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID list selection (as string) value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueListSelection -( - uint8 const _sceneId, - ValueID const& _valueId, - string* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - if( scene->GetValue( _valueId, o_value ) ) - { - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's Value ID list selection (as integer) value -//----------------------------------------------------------------------------- -bool Manager::SceneGetValueListSelection -( - uint8 const _sceneId, - ValueID const& _valueId, - int32* o_value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - string str; - if( scene->GetValue( _valueId, &str ) ) - { - *o_value = (int32)atoi( str.c_str() ); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID bool value. -//----------------------------------------------------------------------------- -bool Manager::SetSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - bool const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->SetValue( _valueId, _value ? "True" : "False" ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID byte value. -//----------------------------------------------------------------------------- -bool Manager::SetSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - uint8 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->SetValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID float value. -//----------------------------------------------------------------------------- -bool Manager::SetSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - float const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%f", _value ); - return scene->SetValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID integer value. -//----------------------------------------------------------------------------- -bool Manager::SetSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - int32 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->SetValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID short value. -//----------------------------------------------------------------------------- -bool Manager::SetSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - int16 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->SetValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID string value. -//----------------------------------------------------------------------------- -bool Manager::SetSceneValue -( - uint8 const _sceneId, - ValueID const& _valueId, - string const& _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->SetValue( _valueId, _value ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID list item value (as string). -//----------------------------------------------------------------------------- -bool Manager::SetSceneValueListSelection -( - uint8 const _sceneId, - ValueID const& _valueId, - string const& _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->SetValue( _valueId, _value ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's ValueID list item value (as integer). -//----------------------------------------------------------------------------- -bool Manager::SetSceneValueListSelection -( - uint8 const _sceneId, - ValueID const& _valueId, - int32 const _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - char str[16]; - snprintf( str, sizeof(str), "%d", _value ); - return scene->SetValue( _valueId, str ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Return a scene's label -//----------------------------------------------------------------------------- -string Manager::GetSceneLabel -( - uint8 const _sceneId -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->GetLabel(); - } - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Set a scene's label -//----------------------------------------------------------------------------- -void Manager::SetSceneLabel -( - uint8 const _sceneId, - string const& _value -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - scene->SetLabel( _value ); - } -} - -//----------------------------------------------------------------------------- -// -// Check if a Scene ID exists -//----------------------------------------------------------------------------- -bool Manager::SceneExists -( - uint8 const _sceneId -) -{ - return Scene::Get( _sceneId ) != NULL; -} - -//----------------------------------------------------------------------------- -// -// Perform all the settings for the given Scene ID -//----------------------------------------------------------------------------- -bool Manager::ActivateScene -( - uint8 const _sceneId -) -{ - Scene *scene = Scene::Get( _sceneId ); - if( scene != NULL ) - { - return scene->Activate(); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Retrieve driver based counters. -//----------------------------------------------------------------------------- -void Manager::GetDriverStatistics -( - uint32 const _homeId, - Driver::DriverData* _data -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->GetDriverStatistics( _data ); - } - -} - -//----------------------------------------------------------------------------- -// -// Retrieve driver based counters. -//----------------------------------------------------------------------------- -void Manager::GetNodeStatistics -( - uint32 const _homeId, - uint8 const _nodeId, - Node::NodeData* _data -) -{ - if( Driver* driver = GetDriver( _homeId ) ) - { - driver->GetNodeStatistics( _nodeId, _data ); - } - -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/Manager.h b/lib/ESPiLight/pilight/libs/openzwave/Manager.h deleted file mode 100644 index 2d49625..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Manager.h +++ /dev/null @@ -1,1924 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Manager.h -// -// The main public interface to OpenZWave. -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Manager_H -#define _Manager_H - -#include -#include -#include -#include -#include -#include - -#include "Defs.h" -#include "Driver.h" -#include "value_classes/ValueID.h" - -namespace OpenZWave -{ - class Options; - class Node; - class Msg; - class Value; - class Event; - class Mutex; - class SerialPort; - class Thread; - class Notification; - class ValueBool; - class ValueByte; - class ValueDecimal; - class ValueInt; - class ValueList; - class ValueShort; - class ValueString; - class ValueRaw; - - /** \brief - * The main public interface to OpenZWave. - * - * \nosubgrouping - * A singleton class providing the main public interface to OpenZWave. - * The Manager class exposes all the functionality required to add - * Z-Wave support to an application. It handles the sending and receiving - * of Z-Wave messages as well as the configuration of a Z-Wave network - * and its devices, freeing the library user from the burden of learning - * the low-level details of the Z-Wave protocol. - *

- * All Z-Wave functionality is accessed via the Manager class. While this - * does not make for the most efficient code structure, it does enable - * the library to handle potentially complex and hard-to-debug issues - * such as multi-threading and object lifespans behind the scenes. - * Application development is therefore simplified and less prone to bugs. - *

- * There can be only one instance of the Manager class, and all applications - * will start by calling Manager::Create static method to create that instance. - * From then on, a call to the Manager::Get static method will return the - * pointer to the Manager object. On application exit, Manager::Destroy - * should be called to allow OpenZWave to clean up and delete any other - * objects it has created. - *

- * Once the Manager has been created, a call should be made to Manager::AddWatcher - * to install a notification callback handler. This handler will receive - * notifications of Z-Wave network changes and updates to device values, and is - * an essential element of OpenZWave. - *

- * Next, a call should be made to Manager::AddDriver for each Z-Wave controller - * attached to the PC. Each Driver will handle the sending and receiving of - * messages for all the devices in its controller's Z-Wave network. The Driver - * will read any previously saved configuration and then query the Z-Wave controller - * for any missing information. Once that process is complete, a DriverReady - * notification callback will be sent containing the Home ID of the controller, - * which is required by most of the other Manager class methods. - *

- * [After the DriverReady notification is sent, the Driver will poll each node on - * the network to update information about each node. After all "awake" nodes - * have been polled, an "AllAwakeNodesQueried" notification is sent. This is when - * a client application can expect all of the node information (both static - * information, like the physical device's capabilities, session information - * (like [associations and/or names] and dynamic information (like temperature or - * on/off state) to be available. Finally, after all nodes (whether listening or - * sleeping) have been polled, an "AllNodesQueried" notification is sent.] - */ - class OPENZWAVE_EXPORT Manager - { - friend class Driver; - friend class CommandClass; - friend class Group; - friend class Node; - friend class Value; - friend class ValueStore; - friend class ValueButton; - - public: - typedef void (*pfnOnNotification_t)( Notification const* _pNotification, void* _context ); - - //----------------------------------------------------------------------------- - // Construction - //----------------------------------------------------------------------------- - /** \name Construction - * For creating and destroying the Manager singleton. - */ - /*@{*/ - public: - /** - * \brief Creates the Manager singleton object. - * The Manager provides the public interface to OpenZWave, exposing all the functionality required - * to add Z-Wave support to an application. There can be only one Manager in an OpenZWave application. - * An Options object must be created and Locked first, otherwise the call to Manager::Create will - * fail. Once the Manager has been created, call AddWatcher to install a notification callback handler, - * and then call the AddDriver method for each attached PC Z-Wave controller in turn. - * \param _options a locked Options object containing all the application's configurable option values. - * \return a pointer to the newly created Manager object, or NULL if creation failed. - * \see Options, Get, Destroy, AddWatcher, AddDriver - */ - static Manager* Create(); - - /** - * \brief Gets a pointer to the Manager object. - * \return pointer to the Manager object, or NULL if Create has not yet been called. - * \see Create, Destroy - */ - static Manager* Get(){ return s_instance; } - - /** - * \brief Deletes the Manager and cleans up any associated objects. - * \see Create, Get - */ - static void Destroy(); - - /** - * \brief Get the Version Number of OZW as a string - * \return a String representing the version number as MAJOR.MINOR.REVISION - */ - static std::string getVersionAsString(); - - /** - * \brief Get the Version Number as the Version Struct (Only Major/Minor returned) - * \return the version struct representing the version - */ - static ozwversion getVersion(); - /*@}*/ - - private: - Manager(); // Constructor, to be called only via the static Create method. - virtual ~Manager(); // Destructor, to be called only via the static Destroy method. - - bool m_exit; // Flag indicating that program exit is in progress. - static Manager* s_instance; // Pointer to the instance of the Manager singleton. - - //----------------------------------------------------------------------------- - // Configuration - //----------------------------------------------------------------------------- - /** \name Configuration - * For saving the Z-Wave network configuration so that the entire network does not need to be - * polled every time the application starts. - */ - /*@{*/ - public: - /** - * \brief Saves the configuration of a PC Controller's Z-Wave network to the application's user data folder. - * This method does not normally need to be called, since OpenZWave will save the state automatically - * during the shutdown process. It is provided here only as an aid to development. - * The configuration of each PC Controller's Z-Wave network is stored in a separate file. The filename - * consists of the 8 digit hexadecimal version of the controller's Home ID, prefixed with the string 'zwcfg_'. - * This convention allows OpenZWave to find the correct configuration file for a controller, even if it is - * attached to a different serial port, USB device path, etc. - * \param _homeId The Home ID of the Z-Wave controller to save. - */ - void WriteConfig( uint32 const _homeId ); - - /** - * \brief Gets a pointer to the locked Options object. - * \return pointer to the Options object. - * \see Create - */ - Options* GetOptions()const{ return m_options; } - /*@}*/ - - private: - Options* m_options; // Pointer to the locked Options object that was passed in during creation. - - //----------------------------------------------------------------------------- - // Drivers - //----------------------------------------------------------------------------- - /** \name Drivers - * Methods for adding and removing drivers and obtaining basic controller information. - */ - /*@{*/ - public: - /** - * \brief Creates a new driver for a Z-Wave controller. - * This method creates a Driver object for handling communications with a single Z-Wave controller. In the background, the - * driver first tries to read configuration data saved during a previous run. It then queries the controller directly for any - * missing information, and a refresh of the list of nodes that it controls. Once this information - * has been received, a DriverReady notification callback is sent, containing the Home ID of the controller. This Home ID is - * required by most of the OpenZWave Manager class methods. - * @param _controllerPath The string used to open the controller. On Windows this might be something like - * "\\.\COM3", or on Linux "/dev/ttyUSB0". - * \return True if a new driver was created, false if a driver for the controller already exists. - * \see Create, Get, RemoveDriver - */ - bool AddDriver( string const& _controllerPath, Driver::ControllerInterface const& _interface = Driver::ControllerInterface_Serial); - - /** - * \brief Removes the driver for a Z-Wave controller, and closes the controller. - * Drivers do not need to be explicitly removed before calling Destroy - this is handled automatically. - * \warning You should NOT call any Manager methods that require the Driver Reference (eg, in response to - * Notifications recieved about NodeRemoved etc) once you call this, as your application will most likely - * break - * @param _controllerPath The same string as was passed in the original call to AddDriver. - * @returns True if the driver was removed, false if it could not be found. - * @see Destroy, AddDriver - */ - bool RemoveDriver( string const& _controllerPath ); - - /** - * \brief Get the node ID of the Z-Wave controller. - * \param _homeId The Home ID of the Z-Wave controller. - * \return the node ID of the Z-Wave controller. - */ - uint8 GetControllerNodeId( uint32 const _homeId ); - - /** - * \brief Get the node ID of the Static Update Controller. - * \param _homeId The Home ID of the Z-Wave controller. - * \return the node ID of the Z-Wave controller. - */ - uint8 GetSUCNodeId( uint32 const _homeId ); - - /** - * \brief Query if the controller is a primary controller. - * The primary controller is the main device used to configure and control a Z-Wave network. - * There can only be one primary controller - all other controllers are secondary controllers. - *

- * The only difference between a primary and secondary controller is that the primary is the - * only one that can be used to add or remove other devices. For this reason, it is usually - * better for the promary controller to be portable, since most devices must be added when - * installed in their final location. - *

- * Calls to BeginControllerCommand will fail if the controller is not the primary. - * \param _homeId The Home ID of the Z-Wave controller. - * \return true if it is a primary controller, false if not. - */ - bool IsPrimaryController( uint32 const _homeId ); - - /** - * \brief Query if the controller is a static update controller. - * A Static Update Controller (SUC) is a controller that must never be moved in normal operation - * and which can be used by other nodes to receive information about network changes. - * \param _homeId The Home ID of the Z-Wave controller. - * \return true if it is a static update controller, false if not. - */ - bool IsStaticUpdateController( uint32 const _homeId ); - - /** - * \brief Query if the controller is using the bridge controller library. - * A bridge controller is able to create virtual nodes that can be associated - * with other controllers to enable events to be passed on. - * \param _homeId The Home ID of the Z-Wave controller. - * \return true if it is a bridge controller, false if not. - */ - bool IsBridgeController( uint32 const _homeId ); - - /** - * \brief Get the version of the Z-Wave API library used by a controller. - * \param _homeId The Home ID of the Z-Wave controller. - * \return a string containing the library version. For example, "Z-Wave 2.48". - */ - string GetLibraryVersion( uint32 const _homeId ); - - /** - * \brief Get a string containing the Z-Wave API library type used by a controller. - * The possible library types are: - * - Static Controller - * - Controller - * - Enhanced Slave - * - Slave - * - Installer - * - Routing Slave - * - Bridge Controller - * - Device Under Test - * The controller should never return a slave library type. - * For a more efficient test of whether a controller is a Bridge Controller, use - * the IsBridgeController method. - * \param _homeId The Home ID of the Z-Wave controller. - * \return a string containing the library type. - * \see GetLibraryVersion, IsBridgeController - */ - string GetLibraryTypeName( uint32 const _homeId ); - - /** - * \brief Get count of messages in the outgoing send queue. - * \param _homeId The Home ID of the Z-Wave controller. - * \return a integer message count - */ - int32 GetSendQueueCount( uint32 const _homeId ); - - /** - * \brief Send current driver statistics to the log file - * \param _homeId The Home ID of the Z-Wave controller. - */ - void LogDriverStatistics( uint32 const _homeId ); - - /** - * \brief Obtain controller interface type - * \param _homeId The Home ID of the Z-Wave controller. - */ - Driver::ControllerInterface GetControllerInterfaceType( uint32 const _homeId ); - - /** - * \brief Obtain controller interface name - * \param _homeId The Home ID of the Z-Wave controller. - */ - string GetControllerPath( uint32 const _homeId ); - /*@}*/ - - private: - Driver* GetDriver( uint32 const _homeId ); /**< Get a pointer to a Driver object from the HomeID. Only to be used by OpenZWave. */ - void SetDriverReady( Driver* _driver, bool success ); /**< Indicate that the Driver is ready to be used, and send the notification callback. */ - -OPENZWAVE_EXPORT_WARNINGS_OFF - list m_pendingDrivers; /**< Drivers that are in the process of reading saved data and querying their Z-Wave network for basic information. */ - map m_readyDrivers; /**< Drivers that are ready to be used by the application. */ -OPENZWAVE_EXPORT_WARNINGS_ON - - //----------------------------------------------------------------------------- - // Polling Z-Wave devices - //----------------------------------------------------------------------------- - /** \name Polling Z-Wave devices - * Methods for controlling the polling of Z-Wave devices. Modern devices will not - * require polling. Some old devices need to be polled as the only way to detect - * status changes. - */ - /*@{*/ - public: - /** - * \brief Get the time period between polls of a node's state. - */ - int32 GetPollInterval(); - - /** - * \brief Set the time period between polls of a node's state. - * Due to patent concerns, some devices do not report state changes automatically to the controller. - * These devices need to have their state polled at regular intervals. The length of the interval - * is the same for all devices. To even out the Z-Wave network traffic generated by polling, OpenZWave - * divides the polling interval by the number of devices that have polling enabled, and polls each - * in turn. It is recommended that if possible, the interval should not be set shorter than the - * number of polled devices in seconds (so that the network does not have to cope with more than one - * poll per second). - * \param _seconds The length of the polling interval in seconds. - */ - void SetPollInterval( int32 _milliseconds, bool _bIntervalBetweenPolls ); - - /** - * \brief Enable the polling of a device's state. - * \param _valueId The ID of the value to start polling. - * \return True if polling was enabled. - */ - bool EnablePoll( ValueID const &_valueId, uint8 const _intensity = 1 ); - - /** - * \brief Disable the polling of a device's state. - * \param _valueId The ID of the value to stop polling. - * \return True if polling was disabled. - */ - bool DisablePoll( ValueID const &_valueId ); - - /** - * \brief Determine the polling of a device's state. - * \param _valueId The ID of the value to check polling. - * \return True if polling is active. - */ - bool isPolled( ValueID const &_valueId ); - - /** - * \brief Set the frequency of polling (0=none, 1=every time through the list, 2-every other time, etc) - * \param _valueId The ID of the value whose intensity should be set - */ - void SetPollIntensity( ValueID const &_valueId, uint8 const _intensity ); - - /** - * \brief Get the polling intensity of a device's state. - * \param _valueId The ID of the value to check polling. - * \return Intensity, number of polling for one polling interval. - */ - uint8 GetPollIntensity( ValueID const &_valueId ); - - /*@}*/ - - //----------------------------------------------------------------------------- - // Node information - //----------------------------------------------------------------------------- - /** \name Node information - * Methods for accessing information on indivdual nodes. - */ - /*@{*/ - public: - /** - * \brief Trigger the fetching of fixed data about a node. - * Causes the node's data to be obtained from the Z-Wave network in the same way as if it had just been added. - * This method would normally be called automatically by OpenZWave, but if you know that a node has been - * changed, calling this method will force a refresh of all of the data held by the library. This can be especially - * useful for devices that were asleep when the application was first run. This is the - * same as the query state starting from the beginning. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if the request was sent successfully. - */ - bool RefreshNodeInfo( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Trigger the fetching of dynamic value data for a node. - * Causes the node's values to be requested from the Z-Wave network. This is the - * same as the query state starting from the associations state. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if the request was sent successfully. - */ - bool RequestNodeState( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Trigger the fetching of just the dynamic value data for a node. - * Causes the node's values to be requested from the Z-Wave network. This is the - * same as the query state starting from the dynamic state. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if the request was sent successfully. - */ - bool RequestNodeDynamic( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get whether the node is a listening device that does not go to sleep - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if it is a listening node. - */ - bool IsNodeListeningDevice( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get whether the node is a frequent listening device that goes to sleep but - * can be woken up by a beam. Useful to determine node and controller consistency. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if it is a frequent listening node. - */ - bool IsNodeFrequentListeningDevice( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get whether the node is a beam capable device. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if it is a beam capable node. - */ - bool IsNodeBeamingDevice( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get whether the node is a routing device that passes messages to other nodes - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if the node is a routing device - */ - bool IsNodeRoutingDevice( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the security attribute for a node. True if node supports security features. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return true if security features implemented. - */ - bool IsNodeSecurityDevice( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the maximum baud rate of a node's communications - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return the baud rate in bits per second. - */ - uint32 GetNodeMaxBaudRate( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the version number of a node - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return the node's version number - */ - uint8 GetNodeVersion( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the security byte of a node - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return the node's security byte - */ - uint8 GetNodeSecurity( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the basic type of a node. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return the node's basic type. - */ - uint8 GetNodeBasic( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the generic type of a node. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return the node's generic type. - */ - uint8 GetNodeGeneric( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the specific type of a node. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return the node's specific type. - */ - uint8 GetNodeSpecific( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get a human-readable label describing the node - * The label is taken from the Z-Wave specific, generic or basic type, depending on which of those values are specified by the node. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the label text. - */ - string GetNodeType( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the bitmap of this node's neighbors - * - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \param _nodeNeighbors An array of 29 uint8s to hold the neighbor bitmap - */ - uint32 GetNodeNeighbors( uint32 const _homeId, uint8 const _nodeId, uint8** _nodeNeighbors ); - - /** - * \brief Get the manufacturer name of a device - * The manufacturer name would normally be handled by the Manufacturer Specific commmand class, - * taking the manufacturer ID reported by the device and using it to look up the name from the - * manufacturer_specific.xml file in the OpenZWave config folder. - * However, there are some devices that do not support the command class, so to enable the user - * to manually set the name, it is stored with the node data and accessed via this method rather - * than being reported via a command class Value object. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the node's manufacturer name. - * \see SetNodeManufacturerName, GetNodeProductName, SetNodeProductName - */ - string GetNodeManufacturerName( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the product name of a device - * The product name would normally be handled by the Manufacturer Specific commmand class, - * taking the product Type and ID reported by the device and using it to look up the name from the - * manufacturer_specific.xml file in the OpenZWave config folder. - * However, there are some devices that do not support the command class, so to enable the user - * to manually set the name, it is stored with the node data and accessed via this method rather - * than being reported via a command class Value object. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the node's product name. - * \see SetNodeProductName, GetNodeManufacturerName, SetNodeManufacturerName - */ - string GetNodeProductName( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the name of a node - * The node name is a user-editable label for the node that would normally be handled by the - * Node Naming commmand class, but many devices do not support it. So that a node can always - * be named, OpenZWave stores it with the node data, and provides access through this method - * and SetNodeName, rather than reporting it via a command class Value object. - * The maximum length of a node name is 16 characters. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the node's name. - * \see SetNodeName, GetNodeLocation, SetNodeLocation - */ - string GetNodeName( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the location of a node - * The node location is a user-editable string that would normally be handled by the Node Naming - * commmand class, but many devices do not support it. So that a node can always report its - * location, OpenZWave stores it with the node data, and provides access through this method - * and SetNodeLocation, rather than reporting it via a command class Value object. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the node's location. - * \see SetNodeLocation, GetNodeName, SetNodeName - */ - string GetNodeLocation( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the manufacturer ID of a device - * The manufacturer ID is a four digit hex code and would normally be handled by the Manufacturer - * Specific commmand class, but not all devices support it. Although the value reported by this - * method will be an empty string if the command class is not supported and cannot be set by the - * user, the manufacturer ID is still stored with the node data (rather than being reported via a - * command class Value object) to retain a consistent approach with the other manufacturer specific data. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the node's manufacturer ID, or an empty string if the manufactuer - * specific command class is not supported by the device. - * \see GetNodeProductType, GetNodeProductId, GetNodeManufacturerName, GetNodeProductName - */ - string GetNodeManufacturerId( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the product type of a device - * The product type is a four digit hex code and would normally be handled by the Manufacturer Specific - * commmand class, but not all devices support it. Although the value reported by this method will - * be an empty string if the command class is not supported and cannot be set by the user, the product - * type is still stored with the node data (rather than being reported via a command class Value object) - * to retain a consistent approach with the other manufacturer specific data. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the node's product type, or an empty string if the manufactuer - * specific command class is not supported by the device. - * \see GetNodeManufacturerId, GetNodeProductId, GetNodeManufacturerName, GetNodeProductName - */ - string GetNodeProductType( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get the product ID of a device - * The product ID is a four digit hex code and would normally be handled by the Manufacturer Specific - * commmand class, but not all devices support it. Although the value reported by this method will - * be an empty string if the command class is not supported and cannot be set by the user, the product - * ID is still stored with the node data (rather than being reported via a command class Value object) - * to retain a consistent approach with the other manufacturer specific data. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return A string containing the node's product ID, or an empty string if the manufactuer - * specific command class is not supported by the device. - * \see GetNodeManufacturerId, GetNodeProductType, GetNodeManufacturerName, GetNodeProductName - */ - string GetNodeProductId( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Set the manufacturer name of a device - * The manufacturer name would normally be handled by the Manufacturer Specific commmand class, - * taking the manufacturer ID reported by the device and using it to look up the name from the - * manufacturer_specific.xml file in the OpenZWave config folder. - * However, there are some devices that do not support the command class, so to enable the user - * to manually set the name, it is stored with the node data and accessed via this method rather - * than being reported via a command class Value object. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \param _manufacturerName A string containing the node's manufacturer name. - * \see GetNodeManufacturerName, GetNodeProductName, SetNodeProductName - */ - void SetNodeManufacturerName( uint32 const _homeId, uint8 const _nodeId, string const& _manufacturerName ); - - /** - * \brief Set the product name of a device - * The product name would normally be handled by the Manufacturer Specific commmand class, - * taking the product Type and ID reported by the device and using it to look up the name from the - * manufacturer_specific.xml file in the OpenZWave config folder. - * However, there are some devices that do not support the command class, so to enable the user - * to manually set the name, it is stored with the node data and accessed via this method rather - * than being reported via a command class Value object. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \param _productName A string containing the node's product name. - * \see GetNodeProductName, GetNodeManufacturerName, SetNodeManufacturerName - */ - void SetNodeProductName( uint32 const _homeId, uint8 const _nodeId, string const& _productName ); - - /** - * \brief Set the name of a node - * The node name is a user-editable label for the node that would normally be handled by the - * Node Naming commmand class, but many devices do not support it. So that a node can always - * be named, OpenZWave stores it with the node data, and provides access through this method - * and GetNodeName, rather than reporting it via a command class Value object. - * If the device does support the Node Naming command class, the new name will be sent to the node. - * The maximum length of a node name is 16 characters. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \param _nodeName A string containing the node's name. - * \see GetNodeName, GetNodeLocation, SetNodeLocation - */ - void SetNodeName( uint32 const _homeId, uint8 const _nodeId, string const& _nodeName ); - - /** - * \brief Set the location of a node - * The node location is a user-editable string that would normally be handled by the Node Naming - * commmand class, but many devices do not support it. So that a node can always report its - * location, OpenZWave stores it with the node data, and provides access through this method - * and GetNodeLocation, rather than reporting it via a command class Value object. - * If the device does support the Node Naming command class, the new location will be sent to the node. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \param _location A string containing the node's location. - * \see GetNodeLocation, GetNodeName, SetNodeName - */ - void SetNodeLocation( uint32 const _homeId, uint8 const _nodeId, string const& _location ); - - /** - * \brief Turns a node on - * This is a helper method to simplify basic control of a node. It is the equivalent of - * changing the level reported by the node's Basic command class to 255, and will generate a - * ValueChanged notification from that class. This command will turn on the device at its - * last known level, if supported by the device, otherwise it will turn it on at 100%. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to be changed. - * \see SetNodeOff, SetNodeLevel - */ - void SetNodeOn( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Turns a node off - * This is a helper method to simplify basic control of a node. It is the equivalent of - * changing the level reported by the node's Basic command class to zero, and will generate - * a ValueChanged notification from that class. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to be changed. - * \see SetNodeOn, SetNodeLevel - */ - void SetNodeOff( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Sets the basic level of a node - * This is a helper method to simplify basic control of a node. It is the equivalent of - * changing the value reported by the node's Basic command class and will generate a - * ValueChanged notification from that class. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to be changed. - * \param _level The level to set the node. Valid values are 0-99 and 255. Zero is off and - * 99 is fully on. 255 will turn on the device at its last known level (if supported). - * \see SetNodeOn, SetNodeOff - */ - void SetNodeLevel( uint32 const _homeId, uint8 const _nodeId, uint8 const _level ); - - /** - * \brief Get whether the node information has been received - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if the node information has been received yet - */ - bool IsNodeInfoReceived( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get whether the node has the defined class available or not - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \param _commandClassId Id of the class to test for - * \return True if the node does have the class instantiated, will return name & version - */ - bool GetNodeClassInformation( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, - string *_className = NULL, uint8 *_classVersion = NULL); - /** - * \brief Get whether the node is awake or asleep - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if the node is awake - */ - bool IsNodeAwake( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get whether the node is working or has failed - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return True if the node has failed and is no longer part of the network - */ - bool IsNodeFailed( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Get whether the node's query stage as a string - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to query. - * \return name of current query stage as a string. - */ - string GetNodeQueryStage( uint32 const _homeId, uint8 const _nodeId ); - - /*@}*/ - - //----------------------------------------------------------------------------- - // Values - //----------------------------------------------------------------------------- - /** \name Values - * Methods for accessing device values. All the methods require a ValueID, which will have been provided - * in the ValueAdded Notification callback when the the value was first discovered by OpenZWave. - */ - /*@{*/ - public: - /** - * \brief Gets the user-friendly label for the value. - * \param _id The unique identifier of the value. - * \return The value label. - * \see ValueID - */ - string GetValueLabel( ValueID const& _id ); - - /** - * \brief Sets the user-friendly label for the value. - * \param _id The unique identifier of the value. - * \param _value The new value of the label. - * \see ValueID - */ - void SetValueLabel( ValueID const& _id, string const& _value ); - - /** - * \brief Gets the units that the value is measured in. - * \param _id The unique identifier of the value. - * \return The value units. - * \see ValueID - */ - string GetValueUnits( ValueID const& _id ); - - /** - * \brief Sets the units that the value is measured in. - * \param _id The unique identifier of the value. - * \param _value The new value of the units. - * \see ValueID - */ - void SetValueUnits( ValueID const& _id, string const& _value ); - - /** - * \brief Gets a help string describing the value's purpose and usage. - * \param _id The unique identifier of the value. - * \return The value help text. - * \see ValueID - */ - string GetValueHelp( ValueID const& _id ); - - /** - * \brief Sets a help string describing the value's purpose and usage. - * \param _id The unique identifier of the value. - * \param _value The new value of the help text. - * \see ValueID - */ - void SetValueHelp( ValueID const& _id, string const& _value ); - - /** - * \brief Gets the minimum that this value may contain. - * \param _id The unique identifier of the value. - * \return The value minimum. - * \see ValueID - */ - int32 GetValueMin( ValueID const& _id ); - - /** - * \brief Gets the maximum that this value may contain. - * \param _id The unique identifier of the value. - * \return The value maximum. - * \see ValueID - */ - int32 GetValueMax( ValueID const& _id ); - - /** - * \brief Test whether the value is read-only. - * \param _id The unique identifier of the value. - * \return true if the value cannot be changed by the user. - * \see ValueID - */ - bool IsValueReadOnly( ValueID const& _id ); - - /** - * \brief Test whether the value is write-only. - * \param _id The unique identifier of the value. - * \return true if the value can only be written to and not read. - * \see ValueID - */ - bool IsValueWriteOnly( ValueID const& _id ); - - /** - * \brief Test whether the value has been set. - * \param _id The unique identifier of the value. - * \return true if the value has actually been set by a status message from the device, rather than simply being the default. - * \see ValueID - */ - bool IsValueSet( ValueID const& _id ); - - /** - * \brief Test whether the value is currently being polled. - * \param _id The unique identifier of the value. - * \return true if the value is being polled, otherwise false. - * \see ValueID - */ - bool IsValuePolled( ValueID const& _id ); - - /** - * \brief Gets a value as a bool. - * \param _id The unique identifier of the value. - * \param o_value Pointer to a bool that will be filled with the value. - * \return true if the value was obtained. Returns false if the value is not a ValueID::ValueType_Bool. The type can be tested with a call to ValueID::GetType. - * \see ValueID::GetType, GetValueAsByte, GetValueAsFloat, GetValueAsInt, GetValueAsShort, GetValueAsString, GetValueListSelection, GetValueListItems, GetValueAsRaw - */ - bool GetValueAsBool( ValueID const& _id, bool* o_value ); - - /** - * \brief Gets a value as an 8-bit unsigned integer. - * \param _id The unique identifier of the value. - * \param o_value Pointer to a uint8 that will be filled with the value. - * \return true if the value was obtained. Returns false if the value is not a ValueID::ValueType_Byte. The type can be tested with a call to ValueID::GetType - * \see ValueID::GetType, GetValueAsBool, GetValueAsFloat, GetValueAsInt, GetValueAsShort, GetValueAsString, GetValueListSelection, GetValueListItems, GetValueAsRaw - */ - bool GetValueAsByte( ValueID const& _id, uint8* o_value ); - - /** - * \brief Gets a value as a float. - * \param _id The unique identifier of the value. - * \param o_value Pointer to a float that will be filled with the value. - * \return true if the value was obtained. Returns false if the value is not a ValueID::ValueType_Decimal. The type can be tested with a call to ValueID::GetType - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsInt, GetValueAsShort, GetValueAsString, GetValueListSelection, GetValueListItems, GetValueAsRaw - */ - bool GetValueAsFloat( ValueID const& _id, float* o_value ); - - /** - * \brief Gets a value as a 32-bit signed integer. - * \param _id The unique identifier of the value. - * \param o_value Pointer to an int32 that will be filled with the value. - * \return true if the value was obtained. Returns false if the value is not a ValueID::ValueType_Int. The type can be tested with a call to ValueID::GetType - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsFloat, GetValueAsShort, GetValueAsString, GetValueListSelection, GetValueListItems, GetValueAsRaw - */ - bool GetValueAsInt( ValueID const& _id, int32* o_value ); - - /** - * \brief Gets a value as a 16-bit signed integer. - * \param _id The unique identifier of the value. - * \param o_value Pointer to an int16 that will be filled with the value. - * \return true if the value was obtained. Returns false if the value is not a ValueID::ValueType_Short. The type can be tested with a call to ValueID::GetType. - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsFloat, GetValueAsInt, GetValueAsString, GetValueListSelection, GetValueListItems, GetValueAsRaw - */ - bool GetValueAsShort( ValueID const& _id, int16* o_value ); - - /** - * \brief Gets a value as a string. - * Creates a string representation of a value, regardless of type. - * \param _id The unique identifier of the value. - * \param o_value Pointer to a string that will be filled with the value. - * \return true if the value was obtained. - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsFloat, GetValueAsInt, GetValueAsShort, GetValueListSelection, GetValueListItems, GetValueAsRaw - */ - bool GetValueAsString( ValueID const& _id, string* o_value ); - - /** - * \brief Gets a value as a collection of bytes. - * \param _id The unique identifier of the value. - * \param o_value Pointer to a uint8* that will be filled with the value. This return value will need to be freed as it was dynamically allocated. - * \param o_length Pointer to a uint8 that will be fill with the data length. - * \return true if the value was obtained. Returns false if the value is not a ValueID::ValueType_Raw. The type can be tested with a call to ValueID::GetType. - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsFloat, GetValueAsInt, GetValueAsShort, GetValueListSelection, GetValueListItems, GetValueAsRaw - */ - bool GetValueAsRaw( ValueID const& _id, uint8** o_value, uint8* o_length ); - - /** - * \brief Gets the selected item from a list (as a string). - * \param _id The unique identifier of the value. - * \param o_value Pointer to a string that will be filled with the selected item. - * \return True if the value was obtained. Returns false if the value is not a ValueID::ValueType_List. The type can be tested with a call to ValueID::GetType. - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsFloat, GetValueAsInt, GetValueAsShort, GetValueAsString, GetValueListItems, GetValueAsRaw - */ - bool GetValueListSelection( ValueID const& _id, string* o_value ); - - /** - * \brief Gets the selected item from a list (as an integer). - * \param _id The unique identifier of the value. - * \param o_value Pointer to an integer that will be filled with the selected item. - * \return True if the value was obtained. Returns false if the value is not a ValueID::ValueType_List. The type can be tested with a call to ValueID::GetType. - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsFloat, GetValueAsInt, GetValueAsShort, GetValueAsString, GetValueListItems, GetValueAsRaw - */ - bool GetValueListSelection( ValueID const& _id, int32* o_value ); - - /** - * \brief Gets the list of items from a list value. - * \param _id The unique identifier of the value. - * \param o_value Pointer to a vector of strings that will be filled with list items. The vector will be cleared before the items are added. - * \return true if the list items were obtained. Returns false if the value is not a ValueID::ValueType_List. The type can be tested with a call to ValueID::GetType. - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsFloat, GetValueAsInt, GetValueAsShort, GetValueAsString, GetValueListSelection, GetValueAsRaw - */ - bool GetValueListItems( ValueID const& _id, vector* o_value ); - - /** - * \brief Gets a float value's precision. - * \param _id The unique identifier of the value. - * \param o_value Pointer to a uint8 that will be filled with the precision value. - * \return true if the value was obtained. Returns false if the value is not a ValueID::ValueType_Decimal. The type can be tested with a call to ValueID::GetType - * \see ValueID::GetType, GetValueAsBool, GetValueAsByte, GetValueAsInt, GetValueAsShort, GetValueAsString, GetValueListSelection, GetValueListItems - */ - bool GetValueFloatPrecision( ValueID const& _id, uint8* o_value ); - - /** - * \brief Sets the state of a bool. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the bool value. - * \param _value The new value of the bool. - * \return true if the value was set. Returns false if the value is not a ValueID::ValueType_Bool. The type can be tested with a call to ValueID::GetType. - */ - bool SetValue( ValueID const& _id, bool const _value ); - - /** - * \brief Sets the value of a byte. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the byte value. - * \param _value The new value of the byte. - * \return true if the value was set. Returns false if the value is not a ValueID::ValueType_Byte. The type can be tested with a call to ValueID::GetType. - */ - bool SetValue( ValueID const& _id, uint8 const _value ); - - /** - * \brief Sets the value of a decimal. - * It is usually better to handle decimal values using strings rather than floats, to avoid floating point accuracy issues. - * Due to the possibility of a device being asleep, the command is assumed to succeed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the decimal value. - * \param _value The new value of the decimal. - * \return true if the value was set. Returns false if the value is not a ValueID::ValueType_Decimal. The type can be tested with a call to ValueID::GetType. - */ - bool SetValue( ValueID const& _id, float const _value ); - - /** - * \brief Sets the value of a 32-bit signed integer. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the integer value. - * \param _value The new value of the integer. - * \return true if the value was set. Returns false if the value is not a ValueID::ValueType_Int. The type can be tested with a call to ValueID::GetType. - */ - bool SetValue( ValueID const& _id, int32 const _value ); - - /** - * \brief Sets the value of a 16-bit signed integer. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the integer value. - * \param _value The new value of the integer. - * \return true if the value was set. Returns false if the value is not a ValueID::ValueType_Short. The type can be tested with a call to ValueID::GetType. - */ - bool SetValue( ValueID const& _id, int16 const _value ); - - /** - * \brief Sets the value of a collection of bytes. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the raw value. - * \param _value The new collection of bytes. - * \return true if the value was set. Returns false if the value is not a ValueID::ValueType_Raw. The type can be tested with a call to ValueID::GetType. - */ - bool SetValue( ValueID const& _id, uint8 const* _value, uint8 const _length ); - - /** - * \brief Sets the value from a string, regardless of type. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the integer value. - * \param _value The new value of the string. - * \return true if the value was set. Returns false if the value could not be parsed into the correct type for the value. - */ - bool SetValue( ValueID const& _id, string const& _value ); - - /** - * \brief Sets the selected item in a list. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the value - * held by the node is updated directly. This will be reverted by a future status message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _id The unique identifier of the list value. - * \param _selectedItem A string matching the new selected item in the list. - * \return true if the value was set. Returns false if the selection is not in the list, or if the value is not a ValueID::ValueType_List. - * The type can be tested with a call to ValueID::GetType - */ - bool SetValueListSelection( ValueID const& _id, string const& _selectedItem ); - - /** - * \brief Refreshes the specified value from the Z-Wave network. - * A call to this function causes the library to send a message to the network to retrieve the current value - * of the specified ValueID (just like a poll, except only one-time, not recurring). - * \param _id The unique identifier of the value to be refreshed. - * \return true if the driver and node were found; false otherwise - */ - bool RefreshValue( ValueID const& _id); - - /** - * \brief Sets a flag indicating whether value changes noted upon a refresh should be verified. If so, the - * library will immediately refresh the value a second time whenever a change is observed. This helps to filter - * out spurious data reported occasionally by some devices. - * \param _id The unique identifier of the value whose changes should or should not be verified. - * \param _verify if true, verify changes; if false, don't verify changes. - */ - void SetChangeVerified( ValueID const& _id, bool _verify ); - - /** - * \brief Starts an activity in a device. - * Since buttons are write-only values that do not report a state, no notification callbacks are sent. - * \param _id The unique identifier of the integer value. - * \return true if the activity was started. Returns false if the value is not a ValueID::ValueType_Button. The type can be tested with a call to ValueID::GetType. - */ - bool PressButton( ValueID const& _id ); - - /** - * \brief Stops an activity in a device. - * Since buttons are write-only values that do not report a state, no notification callbacks are sent. - * \param _id The unique identifier of the integer value. - * \return true if the activity was stopped. Returns false if the value is not a ValueID::ValueType_Button. The type can be tested with a call to ValueID::GetType. - */ - bool ReleaseButton( ValueID const& _id ); - /*@}*/ - - //----------------------------------------------------------------------------- - // Climate Control Schedules - //----------------------------------------------------------------------------- - /** \name Climate Control Schedules - * Methods for accessing schedule values. All the methods require a ValueID, which will have been provided - * in the ValueAdded Notification callback when the the value was first discovered by OpenZWave. - *

The ValueType_Schedule is a specialized Value used to simplify access to the switch point schedule - * information held by a setback thermostat that supports the Climate Control Schedule command class. - * Each schedule contains up to nine switch points for a single day, consisting of a time in - * hours and minutes (24 hour clock) and a setback in tenths of a degree Celsius. The setback value can - * range from -128 (-12.8C) to 120 (12.0C). There are two special setback values - 121 is used to set - * Frost Protection mode, and 122 is used to set Energy Saving mode. - *

The switch point methods only modify OpenZWave's copy of the schedule information. Once all changes - * have been made, they are sent to the device by calling SetSchedule. - */ - /*@{*/ - - /** - * \brief Get the number of switch points defined in a schedule. - * \param _id The unique identifier of the schedule value. - * \return the number of switch points defined in this schedule. Returns zero if the value is not a ValueID::ValueType_Schedule. The type can be tested with a call to ValueID::GetType. - */ - uint8 GetNumSwitchPoints( ValueID const& _id ); - - /** - * \brief Set a switch point in the schedule. - * Inserts a new switch point into the schedule, unless a switch point already exists at the specified - * time in which case that switch point is updated with the new setback value instead. - * A maximum of nine switch points can be set in the schedule. - * \param _id The unique identifier of the schedule value. - * \param _hours The hours part of the time when the switch point will trigger. The time is set using - * the 24-hour clock, so this value must be between 0 and 23. - * \param _minutes The minutes part of the time when the switch point will trigger. This value must be - * between 0 and 59. - * \param _setback The setback in tenths of a degree Celsius. The setback value can range from -128 (-12.8C) - * to 120 (12.0C). There are two special setback values - 121 is used to set Frost Protection mode, and - * 122 is used to set Energy Saving mode. - * \return true if successful. Returns false if the value is not a ValueID::ValueType_Schedule. The type can be tested with a call to ValueID::GetType. - * \see GetNumSwitchPoints, RemoveSwitchPoint, ClearSwitchPoints - */ - bool SetSwitchPoint( ValueID const& _id, uint8 const _hours, uint8 const _minutes, int8 const _setback ); - - /** - * \brief Remove a switch point from the schedule. - * Removes the switch point at the specified time from the schedule. - * \param _id The unique identifier of the schedule value. - * \param _hours The hours part of the time when the switch point will trigger. The time is set using - * the 24-hour clock, so this value must be between 0 and 23. - * \param _minutes The minutes part of the time when the switch point will trigger. This value must be - * between 0 and 59. - * \return true if successful. Returns false if the value is not a ValueID::ValueType_Schedule or if there - * is not switch point with the specified time values. The type can be tested with a call to ValueID::GetType. - * \see GetNumSwitchPoints, SetSwitchPoint, ClearSwitchPoints - */ - bool RemoveSwitchPoint( ValueID const& _id, uint8 const _hours, uint8 const _minutes ); - - /** - * \brief Clears all switch points from the schedule. - * \param _id The unique identifier of the schedule value. - * \see GetNumSwitchPoints, SetSwitchPoint, RemoveSwitchPoint - */ - void ClearSwitchPoints( ValueID const& _id ); - - /** - * \brief Gets switch point data from the schedule. - * Retrieves the time and setback values from a switch point in the schedule. - * \param _id The unique identifier of the schedule value. - * \param _idx The index of the switch point, between zero and one less than the value - * returned by GetNumSwitchPoints. - * \param o_hours a pointer to a uint8 that will be filled with the hours part of the switch point data. - * \param o_minutes a pointer to a uint8 that will be filled with the minutes part of the switch point data. - * \param o_setback a pointer to an int8 that will be filled with the setback value. This can range from -128 - * (-12.8C)to 120 (12.0C). There are two special setback values - 121 is used to set Frost Protection mode, and - * 122 is used to set Energy Saving mode. - * \return true if successful. Returns false if the value is not a ValueID::ValueType_Schedule. The type can be tested with a call to ValueID::GetType. - * \see GetNumSwitchPoints - */ - bool GetSwitchPoint( ValueID const& _id, uint8 const _idx, uint8* o_hours, uint8* o_minutes, int8* o_setback ); - - /*@}*/ - - //----------------------------------------------------------------------------- - // SwitchAll - //----------------------------------------------------------------------------- - /** \name SwitchAll - * Methods for switching all devices on or off together. The devices must support - * the SwitchAll command class. The command is first broadcast to all nodes, and - * then followed up with individual commands to each node (because broadcasts are - * not routed, the message might not otherwise reach all the nodes). - */ - /*@{*/ - - /** - * \brief Switch all devices on. - * All devices that support the SwitchAll command class will be turned on. - */ - void SwitchAllOn( uint32 const _homeId ); - - /** - * \brief Switch all devices off. - * All devices that support the SwitchAll command class will be turned off. - */ - void SwitchAllOff( uint32 const _homeId ); - - /*@}*/ - - //----------------------------------------------------------------------------- - // Configuration Parameters - //----------------------------------------------------------------------------- - /** \name Configuration Parameters - * Methods for accessing device configuration parameters. - * Configuration parameters are values that are managed by the Configuration command class. - * The values are device-specific and are not reported by the devices. Information on parameters - * is provided only in the device user manual. - *

An ongoing task for the OpenZWave project is to create XML files describing the available - * parameters for every Z-Wave. See the config folder in the project source code for examples. - */ - /*@{*/ - public: - /** - * \brief Set the value of a configurable parameter in a device. - * Some devices have various parameters that can be configured to control the device behaviour. - * These are not reported by the device over the Z-Wave network, but can usually be found in - * the device's user manual. - * This method returns immediately, without waiting for confirmation from the device that the - * change has been made. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to configure. - * \param _param The index of the parameter. - * \param _value The value to which the parameter should be set. - * \param _size Is an optional number of bytes to be sent for the paramter _value. Defaults to 2. - * \return true if the a message setting the value was sent to the device. - * \see RequestConfigParam - */ - bool SetConfigParam( uint32 const _homeId, uint8 const _nodeId, uint8 const _param, int32 _value, uint8 const _size = 2 ); - - /** - * \brief Request the value of a configurable parameter from a device. - * Some devices have various parameters that can be configured to control the device behaviour. - * These are not reported by the device over the Z-Wave network, but can usually be found in - * the device's user manual. - * This method requests the value of a parameter from the device, and then returns immediately, - * without waiting for a response. If the parameter index is valid for this device, and the - * device is awake, the value will eventually be reported via a ValueChanged notification callback. - * The ValueID reported in the callback will have an index set the same as _param and a command class - * set to the same value as returned by a call to Configuration::StaticGetCommandClassId. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to configure. - * \param _param The index of the parameter. - * \see SetConfigParam, ValueID, Notification - */ - void RequestConfigParam( uint32 const _homeId, uint8 const _nodeId, uint8 const _param ); - - /** - * \brief Request the values of all known configurable parameters from a device. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node to configure. - * \see SetConfigParam, ValueID, Notification - */ - void RequestAllConfigParams( uint32 const _homeId, uint8 const _nodeId ); - /*@}*/ - - //----------------------------------------------------------------------------- - // Groups (wrappers for the Node methods) - //----------------------------------------------------------------------------- - /** \name Groups - * Methods for accessing device association groups. - */ - /*@{*/ - public: - /** - * \brief Gets the number of association groups reported by this node - * In Z-Wave, groups are numbered starting from one. For example, if a call to GetNumGroups returns 4, the _groupIdx - * value to use in calls to GetAssociations, AddAssociation and RemoveAssociation will be a number between 1 and 4. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node whose groups we are interested in. - * \return The number of groups. - * \see GetAssociations, GetMaxAssociations, AddAssociation, RemoveAssociation - */ - uint8 GetNumGroups( uint32 const _homeId, uint8 const _nodeId ); - - /** - * \brief Gets the associations for a group. - * Makes a copy of the list of associated nodes in the group, and returns it in an array of uint8's. - * The caller is responsible for freeing the array memory with a call to delete []. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node whose associations we are interested in. - * \param _groupIdx One-based index of the group (because Z-Wave product manuals use one-based group numbering). - * \param o_associations If the number of associations returned is greater than zero, o_associations will be set to point to an array containing the IDs of the associated nodes. - * \return The number of nodes in the associations array. If zero, the array will point to NULL, and does not need to be deleted. - * \see GetNumGroups, AddAssociation, RemoveAssociation, GetMaxAssociations - */ - uint32 GetAssociations( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8** o_associations ); - - /** - * \brief Gets the maximum number of associations for a group. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node whose associations we are interested in. - * \param _groupIdx one-based index of the group (because Z-Wave product manuals use one-based group numbering). - * \return The maximum number of nodes that can be associated into the group. - * \see GetNumGroups, AddAssociation, RemoveAssociation, GetAssociations - */ - uint8 GetMaxAssociations( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx ); - - /** - * \brief Returns a label for the particular group of a node. - * This label is populated by the device specific configuration files. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node whose associations are to be changed. - * \param _groupIdx One-based index of the group (because Z-Wave product manuals use one-based group numbering). - * \see GetNumGroups, GetAssociations, GetMaxAssociations, AddAssociation - */ - string GetGroupLabel( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx ); - - /** - * \brief Adds a node to an association group. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the association data - * held in this class is updated directly. This will be reverted by a future Association message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node whose associations are to be changed. - * \param _groupIdx One-based index of the group (because Z-Wave product manuals use one-based group numbering). - * \param _targetNodeId Identifier for the node that will be added to the association group. - * \see GetNumGroups, GetAssociations, GetMaxAssociations, RemoveAssociation - */ - void AddAssociation( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId ); - - /** - * \brief Removes a node from an association group. - * Due to the possibility of a device being asleep, the command is assumed to suceed, and the association data - * held in this class is updated directly. This will be reverted by a future Association message from the device - * if the Z-Wave message actually failed to get through. Notification callbacks will be sent in both cases. - * \param _homeId The Home ID of the Z-Wave controller that manages the node. - * \param _nodeId The ID of the node whose associations are to be changed. - * \param _groupIdx One-based index of the group (because Z-Wave product manuals use one-based group numbering). - * \param _targetNodeId Identifier for the node that will be removed from the association group. - * \see GetNumGroups, GetAssociations, GetMaxAssociations, AddAssociation - */ - void RemoveAssociation( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId ); - - /*@}*/ - - //----------------------------------------------------------------------------- - // Notifications - //----------------------------------------------------------------------------- - /** \name Notifications - * For notification of changes to the Z-Wave network or device values and associations. - */ - /*@{*/ - public: - /** - * \brief Add a notification watcher. - * In OpenZWave, all feedback from the Z-Wave network is sent to the application via callbacks. - * This method allows the application to add a notification callback handler, known as a "watcher" to OpenZWave. - * An application needs only add a single watcher - all notifications will be reported to it. - * \param _watcher pointer to a function that will be called by the notification system. - * \param _context pointer to user defined data that will be passed to the watcher function with each notification. - * \return true if the watcher was successfully added. - * \see RemoveWatcher, Notification - */ - bool AddWatcher( pfnOnNotification_t _watcher, void* _context ); - - /** - * \brief Remove a notification watcher. - * \param _watcher pointer to a function that must match that passed to a previous call to AddWatcher - * \param _context pointer to user defined data that must match the one passed in that same previous call to AddWatcher. - * \return true if the watcher was successfully removed. - * \see AddWatcher, Notification - */ - bool RemoveWatcher( pfnOnNotification_t _watcher, void* _context ); - /*@}*/ - - private: - void NotifyWatchers( Notification* _notification ); // Passes the notifications to all the registered watcher callbacks in turn. - - struct Watcher - { - pfnOnNotification_t m_callback; - void* m_context; - - Watcher - ( - pfnOnNotification_t _callback, - void* _context - ): - m_callback( _callback ), - m_context( _context ) - { - } - }; - -OPENZWAVE_EXPORT_WARNINGS_OFF - list m_watchers; // List of all the registered watchers. -OPENZWAVE_EXPORT_WARNINGS_ON - Mutex* m_notificationMutex; - - //----------------------------------------------------------------------------- - // Controller commands - //----------------------------------------------------------------------------- - /** \name Controller Commands - * Commands for Z-Wave network management using the PC Controller. - */ - /*@{*/ - public: - /** - * \brief Hard Reset a PC Z-Wave Controller. - * Resets a controller and erases its network configuration settings. The controller becomes a primary controller ready to add devices to a new network. - * \param _homeId The Home ID of the Z-Wave controller to be reset. - * \see SoftReset - */ - void ResetController( uint32 const _homeId ); - - /** - * \brief Soft Reset a PC Z-Wave Controller. - * Resets a controller without erasing its network configuration settings. - * \param _homeId The Home ID of the Z-Wave controller to be reset. - * \see SoftReset - */ - void SoftReset( uint32 const _homeId ); - - /** - * \brief Start a controller command process. - * \param _homeId The Home ID of the Z-Wave controller. - * \param _command The command to be sent to the controller. - * \param _callback pointer to a function that will be called at various stages during the command process - * to notify the user of progress or to request actions on the user's part. Defaults to NULL. - * \param _context pointer to user defined data that will be passed into to the callback function. Defaults to NULL. - * \param _highPower used only with the AddDevice, AddController, RemoveDevice and RemoveController commands. - * Usually when adding or removing devices, the controller operates at low power so that the controller must - * be physically close to the device for security reasons. If _highPower is true, the controller will - * operate at normal power levels instead. Defaults to false. - * \param _nodeId is the node ID used by the command if necessary. - * \param _arg is an optional argument, usually another node ID, that is used by the command. - * \return true if the command was accepted and has queued to be executed. - * \see CancelControllerCommand, HasNodeFailed, RemoveFailedNode, Driver::ControllerCommand, Driver::pfnControllerCallback_t, - *

Commands - * - Driver::ControllerCommand_AddDevice - Add a new device or controller to the Z-Wave network. - * - Driver::ControllerCommand_CreateNewPrimary - Create a new primary controller when old primary fails. Requires SUC. - * - Driver::ControllerCommand_ReceiveConfiguration - Receive network configuration information from primary controller. Requires secondary. - * - Driver::ControllerCommand_RemoveDevice - Remove a device or controller from the Z-Wave network. - * - Driver::ControllerCommand_RemoveFailedNode - Remove a node from the network. The node must not be responding - * and be on the controller's failed node list. - * - Driver::ControllerCommand_HasNodeFailed - Check whether a node is in the controller's failed nodes list. - * - Driver::ControllerCommand_ReplaceFailedNode - Replace a failed device with another. If the node is not in - * the controller's failed nodes list, or the node responds, this command will fail. - * - Driver:: ControllerCommand_TransferPrimaryRole - Add a new controller to the network and - * make it the primary. The existing primary will become a secondary controller. - * - Driver::ControllerCommand_RequestNetworkUpdate - Update the controller with network information from the SUC/SIS. - * - Driver::ControllerCommand_RequestNodeNeighborUpdate - Get a node to rebuild its neighbour list. This method also does RequestNodeNeighbors afterwards. - * - Driver::ControllerCommand_AssignReturnRoute - Assign a network return route to a device. - * - Driver::ControllerCommand_DeleteAllReturnRoutes - Delete all network return routes from a device. - * - Driver::ControllerCommand_SendNodeInformation - Send a node information frame. - * - Driver::ControllerCommand_ReplicationSend - Send information from primary to secondary - * - Driver::ControllerCommand_CreateButton - Create a handheld button id. - * - Driver::ControllerCommand_DeleteButton - Delete a handheld button id. - *

Callbacks - * - Driver::ControllerState_Starting, the controller command has begun - * - Driver::ControllerState_Waiting, the controller is waiting for a user action. A notice should be displayed - * to the user at this point, telling them what to do next. - * For the add, remove, replace and transfer primary role commands, the user needs to be told to press the - * inclusion button on the device that is going to be added or removed. For ControllerCommand_ReceiveConfiguration, - * they must set their other controller to send its data, and for ControllerCommand_CreateNewPrimary, set the other - * controller to learn new data. - * - Driver::ControllerState_InProgress - the controller is in the process of adding or removing the chosen node. It is now too late to cancel the command. - * - Driver::ControllerState_Complete - the controller has finished adding or removing the node, and the command is complete. - * - Driver::ControllerState_Failed - will be sent if the command fails for any reason. - */ - bool BeginControllerCommand( uint32 const _homeId, Driver::ControllerCommand _command, Driver::pfnControllerCallback_t _callback = NULL, void* _context = NULL, bool _highPower = false, uint8 _nodeId = 0xff, uint8 _arg = 0 ); - - /** - * \brief Cancels any in-progress command running on a controller. - * \param _homeId The Home ID of the Z-Wave controller. - * \return true if a command was running and was cancelled. - * \see BeginControllerCommand - */ - bool CancelControllerCommand( uint32 const _homeId ); - /*@}*/ - - //----------------------------------------------------------------------------- - // Network commands - //----------------------------------------------------------------------------- - /** \name Network Commands - * Commands for Z-Wave network for testing, routing and other internal - * operations. - */ - /*@{*/ - public: - /** - * \brief Test network node. - * Sends a series of messages to a network node for testing network reliability. - * \param _homeId The Home ID of the Z-Wave controller to be reset. - * \param _count This is the number of test messages to send. - * \see TestNetwork - */ - void TestNetworkNode( uint32 const _homeId, uint8 const _nodeId, uint32 const _count ); - - /** - * \brief Test network. - * Sends a series of messages to every node on the network for testing network reliability. - * \param _homeId The Home ID of the Z-Wave controller to be reset. - * \param _count This is the number of test messages to send. - * \see TestNetwork - */ - void TestNetwork( uint32 const _homeId, uint32 const _count ); - - /** - * \brief Heal network node by requesting the node rediscover their neighbors. - * Sends a ControllerCommand_RequestNodeNeighborUpdate to the node. - * \param _homeId The Home ID of the Z-Wave network to be healed. - * \param _nodeId The node to heal. - * \param _doRR Whether to perform return routes initialization. - */ - void HealNetworkNode( uint32 const _homeId, uint8 const _nodeId, bool _doRR ); - - /** - * \brief Heal network by requesting node's rediscover their neighbors. - * Sends a ControllerCommand_RequestNodeNeighborUpdate to every node. - * Can take a while on larger networks. - * \param _homeId The Home ID of the Z-Wave network to be healed. - * \param _doRR Whether to perform return routes initialization. - */ - void HealNetwork( uint32 const _homeId, bool _doRR ); - - /*@}*/ - - //----------------------------------------------------------------------------- - // Scene commands - //----------------------------------------------------------------------------- - /** \name Scene Commands - * Commands for Z-Wave scene interface. - */ - /*@{*/ - public: - /** - * \brief Gets the number of scenes that have been defined. - * \return The number of scenes. - * \see GetAllScenes, RemoveAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - uint8 GetNumScenes( ); - - /** - * \brief Gets a list of all the SceneIds. - * \param _sceneIds is a pointer to an array of integers. - * \return The number of scenes. If zero, _sceneIds will be NULL and doesn't need to be freed. - * \see GetNumScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - uint8 GetAllScenes( uint8** _sceneIds ); - - /** - * \brief Remove all the SceneIds. - * \param _homeId The Home ID of the Z-Wave controller. 0 for all devices from all scenes. - * \see GetAllScenes, GetNumScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - void RemoveAllScenes( uint32 const _homeId ); - - /** - * \brief Create a new Scene passing in Scene ID - * \return uint8 Scene ID used to reference the scene. 0 is failure result. - * \see GetNumScenes, GetAllScenes, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - - */ - uint8 CreateScene(); - - /** - * \brief Remove an existing Scene. - * \param _sceneId is an integer representing the unique Scene ID to be removed. - * \return true if scene was removed. - * \see GetNumScenes, GetAllScenes, CreateScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool RemoveScene( uint8 const _sceneId ); - - /** - * \brief Add a bool Value ID to an existing scene. - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the bool value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, bool const _value ); - - /** - * \brief Add a byte Value ID to an existing scene. - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the byte value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, uint8 const _value ); - - /** - * \brief Add a decimal Value ID to an existing scene. - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the float value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, float const _value ); - - /** - * \brief Add a 32-bit signed integer Value ID to an existing scene. - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the int32 value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, int32 const _value ); - - /** - * \brief Add a 16-bit signed integer Value ID to an existing scene. - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the int16 value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, int16 const _value ); - - /** - * \brief Add a string Value ID to an existing scene. - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the string value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, string const& _value ); - - /** - * \brief Add the selected item list Value ID to an existing scene (as a string). - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the string value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string const& _value ); - - /** - * \brief Add the selected item list Value ID to an existing scene (as a integer). - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the integer value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool AddSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32 const _value ); - - /** - * \brief Remove the Value ID from an existing scene. - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be removed. - * \return true if Value ID was removed. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool RemoveSceneValue( uint8 const _sceneId, ValueID const& _valueId ); - - /** - * \brief Retrieves the scene's list of values. - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param o_value Pointer to an array of ValueIDs if return is non-zero. - * \return The number of nodes in the o_value array. If zero, the array will point to NULL and does not need to be deleted. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - int SceneGetValues( uint8 const _sceneId, vector* o_value ); - - /** - * \brief Retrieves a scene's value as a bool. - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a bool that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueAsBool( uint8 const _sceneId, ValueID const& _valueId, bool* o_value ); - - /** - * \brief Retrieves a scene's value as an 8-bit unsigned integer. - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a uint8 that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueAsByte( uint8 const _sceneId, ValueID const& _valueId, uint8* o_value ); - - /** - * \brief Retrieves a scene's value as a float. - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a float that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueAsFloat( uint8 const _sceneId, ValueID const& _valueId, float* o_value ); - - /** - * \brief Retrieves a scene's value as a 32-bit signed integer. - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a int32 that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueAsInt( uint8 const _sceneId, ValueID const& _valueId, int32* o_value ); - - /** - * \brief Retrieves a scene's value as a 16-bit signed integer. - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a int16 that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueAsShort( uint8 const _sceneId, ValueID const& _valueId, int16* o_value ); - - /** - * \brief Retrieves a scene's value as a string. - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a string that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueAsString( uint8 const _sceneId, ValueID const& _valueId, string* o_value ); - - /** - * \brief Retrieves a scene's value as a list (as a string). - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a string that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string* o_value ); - - /** - * \brief Retrieves a scene's value as a list (as a integer). - * \param _sceneId The Scene ID of the scene to retrieve the value from. - * \param _valueId The Value ID of the value to retrieve. - * \param o_value Pointer to a integer that will be filled with the returned value. - * \return true if the value was obtained. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SceneGetValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32* o_value ); - - /** - * \brief Set a bool Value ID to an existing scene's ValueID - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the bool value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, bool const _value ); - - /** - * \brief Set a byte Value ID to an existing scene's ValueID - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the byte value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, uint8 const _value ); - - /** - * \brief Set a decimal Value ID to an existing scene's ValueID - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the float value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, float const _value ); - - /** - * \brief Set a 32-bit signed integer Value ID to an existing scene's ValueID - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the int32 value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, int32 const _value ); - - /** - * \brief Set a 16-bit integer Value ID to an existing scene's ValueID - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the int16 value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, int16 const _value ); - - /** - * \brief Set a string Value ID to an existing scene's ValueID - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the string value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, string const& _value ); - - /** - * \brief Set the list selected item Value ID to an existing scene's ValueID (as a string). - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the string value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string const& _value ); - - /** - * \brief Set the list selected item Value ID to an existing scene's ValueID (as a integer). - * \param _sceneId is an integer representing the unique Scene ID. - * \param _valueId is the Value ID to be added. - * \param _value is the integer value to be saved. - * \return true if Value ID was added. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists, ActivateScene - */ - bool SetSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32 const _value ); - - /** - * \brief Returns a label for the particular scene. - * \param _sceneId The Scene ID - * \return The label string. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, SetSceneLabel, SceneExists, ActivateScene - */ - string GetSceneLabel( uint8 const _sceneId ); - - /** - * \brief Sets a label for the particular scene. - * \param _sceneId The Scene ID - * \param _value The new value of the label. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SceneExists, ActivateScene - */ - void SetSceneLabel( uint8 const _sceneId, string const& _value ); - - /** - * \brief Check if a Scene ID is defined. - * \param _sceneId The Scene ID. - * \return true if Scene ID exists. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, ActivateScene - */ - bool SceneExists( uint8 const _sceneId ); - - /** - * \brief Activate given scene to perform all its actions. - * \param _sceneId The Scene ID. - * \return true if it is successful. - * \see GetNumScenes, GetAllScenes, CreateScene, RemoveScene, AddSceneValue, RemoveSceneValue, SceneGetValues, SceneGetValueAsBool, SceneGetValueAsByte, SceneGetValueAsFloat, SceneGetValueAsInt, SceneGetValueAsShort, SceneGetValueAsString, SetSceneValue, GetSceneLabel, SetSceneLabel, SceneExists - */ - bool ActivateScene( uint8 const _sceneId ); - - /*@}*/ - - //----------------------------------------------------------------------------- - // Statistics interface - //----------------------------------------------------------------------------- - /** \name Statistics retrieval interface - * Commands for Z-Wave statistics interface. - */ - /*@{*/ - public: - /** - * \brief Retrieve statistics from driver - * \param _homeId The Home ID of the driver to obtain counters - * \param _data Pointer to structure DriverData to return values - */ - void GetDriverStatistics( uint32 const _homeId, Driver::DriverData* _data ); - - /** - * \brief Retrieve statistics per node - * \param _homeId The Home ID of the driver for the node - * \param _nodeId The node number - * \param _data Pointer to structure NodeData to return values - */ - void GetNodeStatistics( uint32 const _homeId, uint8 const _nodeId, Node::NodeData* _data ); - - }; - /*@}*/ -} // namespace OpenZWave - -#endif // _Manager_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/Msg.cpp b/lib/ESPiLight/pilight/libs/openzwave/Msg.cpp deleted file mode 100644 index 200f658..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Msg.cpp +++ /dev/null @@ -1,283 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Msg.cpp -// -// Represents a Z-Wave message -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "Defs.h" -#include "Msg.h" -#include "Node.h" -#include "platform/Log.h" -#include "command_classes/MultiInstance.h" - -using namespace OpenZWave; - -uint8 Msg::s_nextCallbackId = 1; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Msg::Msg -( - string const& _logText, - uint8 _targetNodeId, - uint8 const _msgType, - uint8 const _function, - bool const _bCallbackRequired, - bool const _bReplyRequired, // = true - uint8 const _expectedReply, // = 0 - uint8 const _expectedCommandClassId // = 0 -): - m_logText( _logText ), - m_bFinal( false ), - m_bCallbackRequired( _bCallbackRequired ), - m_callbackId( 0 ), - m_expectedReply( 0 ), - m_expectedCommandClassId( _expectedCommandClassId ), - m_length( 4 ), - m_targetNodeId( _targetNodeId ), - m_sendAttempts( 0 ), - m_maxSendAttempts( MAX_TRIES ), - m_instance( 1 ), - m_endPoint( 0 ), - m_flags( 0 ) -{ - if( _bReplyRequired ) - { - // Wait for this message before considering the transaction complete - m_expectedReply = _expectedReply ? _expectedReply : _function; - } - - m_buffer[0] = SOF; - m_buffer[1] = 0; // Length of the following data, filled in during Finalize. - m_buffer[2] = _msgType; - m_buffer[3] = _function; -} - -//----------------------------------------------------------------------------- -// -// Used to enable wrapping with MultiInstance/MultiChannel during finalize. -//----------------------------------------------------------------------------- -void Msg::SetInstance -( - CommandClass* _cc, - uint8 const _instance -) -{ - // Determine whether we should encapsulate the message in MultiInstance or MultiCommand - if( Node* node = _cc->GetNodeUnsafe() ) - { - MultiInstance* micc = static_cast( node->GetCommandClass( MultiInstance::StaticGetCommandClassId() ) ); - m_instance = _instance; - if( micc ) - { - if( micc->GetVersion() > 1 ) - { - m_endPoint = _cc->GetEndPoint( _instance ); - if( m_endPoint != 0 ) - { - // Set the flag bit to indicate MultiChannel rather than MultiInstance - m_flags |= m_MultiChannel; - m_expectedCommandClassId = MultiInstance::StaticGetCommandClassId(); - } - } - else if( m_instance > 1 ) - { - // Set the flag bit to indicate MultiInstance rather than MultiChannel - m_flags |= m_MultiInstance; - m_expectedCommandClassId = MultiInstance::StaticGetCommandClassId(); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Add a byte to the message -//----------------------------------------------------------------------------- -void Msg::Append -( - uint8 const _data -) -{ - m_buffer[m_length++] = _data; -} - -//----------------------------------------------------------------------------- -// -// Fill in the length and checksum values for the message -//----------------------------------------------------------------------------- -void Msg::Finalize() -{ - if( m_bFinal ) - { - // Already finalized - return; - } - - // Deal with Multi-Channel/Instance encapsulation - if( ( m_flags & ( m_MultiChannel | m_MultiInstance ) ) != 0 ) - { - MultiEncap(); - } - - // Add the callback id - if( m_bCallbackRequired ) - { - // Set the length byte - m_buffer[1] = m_length; // Length of following data - - if( 0 == s_nextCallbackId ) - { - s_nextCallbackId = 1; - } - - m_buffer[m_length++] = s_nextCallbackId; - m_callbackId = s_nextCallbackId++; - } - else - { - // Set the length byte - m_buffer[1] = m_length - 1; // Length of following data - } - - // Calculate the checksum - uint8 checksum = 0xff; - for( uint32 i=1; i -// If this message has a callback ID, increment it and recalculate the checksum -//----------------------------------------------------------------------------- -void Msg::UpdateCallbackId() -{ - if( m_bCallbackRequired ) - { - // update the callback ID - m_buffer[m_length-2] = s_nextCallbackId; - m_callbackId = s_nextCallbackId++; - - // Recalculate the checksum - uint8 checksum = 0xff; - for( int32 i=1; i -// Create a string containing the raw data -//----------------------------------------------------------------------------- -string Msg::GetAsString() -{ - string str = m_logText; - - char byteStr[16]; - if( m_targetNodeId != 0xff ) - { - snprintf( byteStr, sizeof(byteStr), " (Node=%d)", m_targetNodeId ); - str += byteStr; - } - - str += ": "; - - for( uint32 i=0; i -// Encapsulate the data inside a MultiInstance/Multicommand message -//----------------------------------------------------------------------------- -void Msg::MultiEncap -( -) -{ - char str[256]; - if( m_buffer[3] != FUNC_ID_ZW_SEND_DATA ) - { - return; - } - - // Insert the encap header - if( ( m_flags & m_MultiChannel ) != 0 ) - { - // MultiChannel - for( uint32 i=m_length-1; i>=6; --i ) - { - m_buffer[i+4] = m_buffer[i]; - } - - m_buffer[5] += 4; - m_buffer[6] = MultiInstance::StaticGetCommandClassId(); - m_buffer[7] = MultiInstance::MultiChannelCmd_Encap; - m_buffer[8] = 1; - m_buffer[9] = m_endPoint; - m_length += 4; - - snprintf( str, sizeof(str), "MultiChannel Encapsulated (instance=%d): %s", m_instance, m_logText.c_str() ); - m_logText = str; - } - else - { - // MultiInstance - for( uint32 i=m_length-1; i>=6; --i ) - { - m_buffer[i+3] = m_buffer[i]; - } - - m_buffer[5] += 3; - m_buffer[6] = MultiInstance::StaticGetCommandClassId(); - m_buffer[7] = MultiInstance::MultiInstanceCmd_Encap; - m_buffer[8] = m_instance; - m_length += 3; - - snprintf( str, sizeof(str), "MultiInstance Encapsulated (instance=%d): %s", m_instance, m_logText.c_str() ); - m_logText = str; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/Msg.h b/lib/ESPiLight/pilight/libs/openzwave/Msg.h deleted file mode 100644 index b66c7ec..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Msg.h +++ /dev/null @@ -1,173 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Msg.h -// -// Represents a Z-Wave message -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Msg_H -#define _Msg_H - -#include -#include -#include -#include "Defs.h" - -namespace OpenZWave -{ - class CommandClass; - - /** \brief Message object to be passed to and from devices on the Z-Wave network. - */ - class OPENZWAVE_EXPORT Msg - { - public: - enum MessageFlags - { - m_MultiChannel = 0x01, // Indicate MultiChannel encapsulation - m_MultiInstance = 0x02, // Indicate MultiInstance encapsulation - }; - - Msg( string const& _logtext, uint8 _targetNodeId, uint8 const _msgType, uint8 const _function, bool const _bCallbackRequired, bool const _bReplyRequired = true, uint8 const _expectedReply = 0, uint8 const _expectedCommandClassId = 0 ); - ~Msg(){} - - void SetInstance( CommandClass* _cc, uint8 const _instance ); // Used to enable wrapping with MultiInstance/MultiChannel during finalize. - - void Append( uint8 const _data ); - void Finalize(); - void UpdateCallbackId(); - - /** - * \brief Identifies the Node ID of the "target" node (if any) for this function. - * \return Node ID of the target. - */ - uint8 GetTargetNodeId()const{ return m_targetNodeId; } - - /** - * \brief Identifies the Callback ID (if any) for this message. Callback ID is a value (OpenZWave uses sequential IDs) that - * helps the application associate message responses with the original message request. - * \return Callback ID for this message. - */ - uint8 GetCallbackId()const{ return m_callbackId; } - - /** - * \brief Identifies the expected reply type (if any) for this message. The expected reply is a function code...one - * of the FUNC_ID... values defined in Defs.h. Many Z-Wave functions generate responses with the same function code - * (for example, a FUNC_ID_ZW_GET_VERSION message generates a FUNC_ID_ZW_GET_VERSION response. But other functions - * generate a different response. FUNC_ID_ZW_SEND_DATA triggers several responses, but ultimately, a "Get" sent with - * this function should result in a FUNC_ID_APPLICATION_COMMAND_HANDLER response. - * \return Expected reply (function code) for this message. - */ - uint8 GetExpectedReply()const{ return m_expectedReply; } - - /** - * \brief Identifies the expected Command Class ID (if any) for this message. - * \return Expected command class ID for this message. - */ - uint8 GetExpectedCommandClassId()const{ return m_expectedCommandClassId; } - - /** - * \brief For messages that request a Report for a specified command class, identifies the expected Instance - * for the variable being obtained in the report. - * \return Expected Instance value for this message. - */ - uint8 GetExpectedInstance()const{ return m_instance; } - - /** - * \brief For messages that request a Report for a specified command class, identifies the expected Index - * for the variable being obtained in the report. - * \return Expected Index value for this message. - */ -// uint8 GetExpectedIndex()const{ return m_expectedIndex; } - /** - * \brief get the LogText Associated with this message - * \return the LogText used during the constructor - */ - string GetLogText()const{ return m_logText; } - - uint32 GetLength()const{ return m_length; } - uint8* GetBuffer(){ return m_buffer; } - string GetAsString(); - - uint8 GetSendAttempts()const{ return m_sendAttempts; } - void SetSendAttempts( uint8 _count ){ m_sendAttempts = _count; } - - uint8 GetMaxSendAttempts()const{ return m_maxSendAttempts; } - void SetMaxSendAttempts( uint8 _count ){ if( _count < MAX_MAX_TRIES ) m_maxSendAttempts = _count; } - - bool IsWakeUpNoMoreInformationCommand() - { - return( m_bFinal && (m_length==11) && (m_buffer[3]==0x13) && (m_buffer[6]==0x84) && (m_buffer[7]==0x08) ); - } - bool IsNoOperation() - { - return( m_bFinal && (m_length==11) && (m_buffer[3]==0x13) && (m_buffer[6]==0x00) && (m_buffer[7]==0x00) ); - } - - bool operator == ( Msg const& _other )const - { - if( m_bFinal && _other.m_bFinal ) - { - // Do not include the callback Id or checksum in the comparison. - uint8 length = m_length - (m_bCallbackRequired ? 2: 1 ); - return( !memcmp( m_buffer, _other.m_buffer, length ) ); - } - - return false; - } - uint8 GetSendingCommandClass() { - if (m_buffer[3] == 0x13) { - return m_buffer[6]; - } - return 0; - - } - - private: - void MultiEncap(); // Encapsulate the data inside a MultiInstance/Multicommand message - - string m_logText; - bool m_bFinal; - bool m_bCallbackRequired; - - uint8 m_callbackId; - uint8 m_expectedReply; - uint8 m_expectedCommandClassId; - uint8 m_length; - uint8 m_buffer[256]; - - uint8 m_targetNodeId; - uint8 m_sendAttempts; - uint8 m_maxSendAttempts; - - uint8 m_instance; - uint8 m_endPoint; // Endpoint to use if the message must be wrapped in a multiInstance or multiChannel command class - uint8 m_flags; - - static uint8 s_nextCallbackId; // counter to get a unique callback id - }; - -} // namespace OpenZWave - -#endif //_Msg_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/Node.cpp b/lib/ESPiLight/pilight/libs/openzwave/Node.cpp deleted file mode 100644 index 6f460a9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Node.cpp +++ /dev/null @@ -1,2896 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Node.cpp -// -// A node in the Z-Wave network. -// -// Copyright (c) 2009 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "Node.h" -#include "Defs.h" -#include "Group.h" -#include "Options.h" -#include "Manager.h" -#include "Driver.h" -#include "Notification.h" -#include "Msg.h" -#include "platform/Log.h" -#include "platform/Mutex.h" - -#include "tinyxml.h" - -#include "command_classes/CommandClasses.h" -#include "command_classes/CommandClass.h" -#include "command_classes/Association.h" -#include "command_classes/Basic.h" -#include "command_classes/Configuration.h" -#include "command_classes/ControllerReplication.h" -#include "command_classes/ManufacturerSpecific.h" -#include "command_classes/MultiInstance.h" -#include "command_classes/Security.h" -#include "command_classes/WakeUp.h" -#include "command_classes/NodeNaming.h" -#include "command_classes/NoOperation.h" -#include "command_classes/Version.h" -#include "command_classes/SwitchAll.h" - -#include "Scene.h" - -#include "value_classes/ValueID.h" -#include "value_classes/Value.h" -#include "value_classes/ValueBool.h" -#include "value_classes/ValueButton.h" -#include "value_classes/ValueByte.h" -#include "value_classes/ValueDecimal.h" -#include "value_classes/ValueInt.h" -#include "value_classes/ValueRaw.h" -#include "value_classes/ValueList.h" -#include "value_classes/ValueSchedule.h" -#include "value_classes/ValueShort.h" -#include "value_classes/ValueString.h" -#include "value_classes/ValueStore.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// Statics -//----------------------------------------------------------------------------- -bool Node::s_deviceClassesLoaded = false; -map Node::s_basicDeviceClasses; -map Node::s_genericDeviceClasses; - -static char const* c_queryStageNames[] = -{ - "ProtocolInfo", - "Probe", - "WakeUp", - "ManufacturerSpecific1", - "NodeInfo", - "SecurityReport", - "ManufacturerSpecific2", - "Versions", - "Instances", - "Static", - "Probe1", - "Associations", - "Neighbors", - "Session", - "Dynamic", - "Configuration", - "Complete", - "None" -}; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Node::Node -( - uint32 const _homeId, - uint8 const _nodeId -): - m_queryStage( QueryStage_None ), - m_queryPending( false ), - m_queryConfiguration( false ), - m_queryRetries( 0 ), - m_protocolInfoReceived( false ), - m_nodeInfoReceived( false ), - m_manufacturerSpecificClassReceived( false ), - m_nodeInfoSupported( true ), - m_nodeAlive( true ), // assome live node - m_listening( true ), // assume we start out listening - m_frequentListening( false ), - m_beaming( false ), - m_routing( false ), - m_maxBaudRate( 0 ), - m_version( 0 ), - m_security( false ), - m_homeId( _homeId ), - m_nodeId( _nodeId ), - m_basic( 0 ), - m_generic( 0 ), - m_specific( 0 ), - m_type( "" ), - m_numRouteNodes( 0 ), - m_addingNode( false ), - m_manufacturerName( "" ), - m_productName( "" ), - m_nodeName( "" ), - m_location( "" ), - m_manufacturerId( "" ), - m_productType( "" ), - m_productId( "" ), - m_values( new ValueStore() ), - m_sentCnt( 0 ), - m_sentFailed( 0 ), - m_retries( 0 ), - m_receivedCnt( 0 ), - m_receivedDups( 0 ), - m_receivedUnsolicited( 0 ), - m_lastRequestRTT( 0 ), - m_lastResponseRTT( 0 ), - m_averageRequestRTT( 0 ), - m_averageResponseRTT( 0 ), - m_quality( 0 ), - m_lastReceivedMessage(), - m_errors( 0 ) -{ - memset( m_neighbors, 0, sizeof(m_neighbors) ); - memset( m_routeNodes, 0, sizeof(m_routeNodes) ); - AddCommandClass( 0 ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Node::~Node -( -) -{ - // Remove any messages from queues - GetDriver()->RemoveQueues( m_nodeId ); - - // Remove the values from the poll list - for( ValueStore::Iterator it = m_values->Begin(); it != m_values->End(); ++it ) - { - ValueID const& valueId = it->second->GetID(); - if( GetDriver()->isPolled( valueId ) ) - { - GetDriver()->DisablePoll( valueId ); - } - } - - Scene::RemoveValues( m_homeId, m_nodeId ); - - // Delete the values - delete m_values; - - // Delete the command classes - while( !m_commandClassMap.empty() ) - { - map::iterator it = m_commandClassMap.begin(); - delete it->second; - m_commandClassMap.erase( it ); - } - - // Delete the groups - while( !m_groups.empty() ) - { - map::iterator it = m_groups.begin(); - delete it->second; - m_groups.erase( it ); - } - - // Delete the button map - while( !m_buttonMap.empty() ) - { - map::iterator it = m_buttonMap.begin(); - m_buttonMap.erase( it ); - } -} - -//----------------------------------------------------------------------------- -// -// Proceed through the initialisation process -//----------------------------------------------------------------------------- -void Node::AdvanceQueries -( -) -{ - // For OpenZWave to discover everything about a node, we have to follow a certain - // order of queries, because the results of one stage may affect what is requested - // in the next stage. The stage is saved with the node data, so that any incomplete - // queries can be restarted the next time the application runs. - // The individual command classes also store some state as to whether they have - // had a response to certain queries. This state is initilized by the SetStaticRequests - // call in QueryStage_None. It is also saved, so we do not need to request state - // from every command class if some have previously responded. - // - // Each stage must generate all the messages for its particular stage as - // assumptions are made in later code (RemoveMsg) that this is the case. This means - // each stage is only visited once. - - Log::Write( LogLevel_Detail, m_nodeId, "AdvanceQueries queryPending=%d queryRetries=%d queryStage=%s live=%d", m_queryPending, m_queryRetries, c_queryStageNames[m_queryStage], m_nodeAlive ); - bool addQSC = false; // We only want to add a query stage complete if we did some work. - while( !m_queryPending && m_nodeAlive ) - { - switch( m_queryStage ) - { - case QueryStage_None: - { - // Init the node query process - m_queryStage = QueryStage_ProtocolInfo; - m_queryRetries = 0; - break; - } - case QueryStage_ProtocolInfo: - { - // determines, among other things, whether this node is a listener, its maximum baud rate and its device classes - if( !ProtocolInfoReceived() ) - { - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_ProtocolInfo" ); - Msg* msg = new Msg( "Get Node Protocol Info", m_nodeId, REQUEST, FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO, false ); - msg->Append( m_nodeId ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Query ); - m_queryPending = true; - addQSC = true; - } - else - { - // This stage has been done already, so move to the Neighbours stage - m_queryStage = QueryStage_Probe; - m_queryRetries = 0; - } - break; - } - case QueryStage_Probe: - { - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Probe" ); - // - // Send a NoOperation message to see if the node is awake - // and alive. Based on the response or lack of response - // will determine next step. - // - NoOperation* noop = static_cast( GetCommandClass( NoOperation::StaticGetCommandClassId() ) ); - if( GetDriver()->GetNodeId() != m_nodeId ) - { - noop->Set( true ); - m_queryPending = true; - addQSC = true; - } - else - { - m_queryStage = QueryStage_WakeUp; - m_queryRetries = 0; - } - break; - } - case QueryStage_WakeUp: - { - // For sleeping devices other than controllers, we need to defer the usual requests until - // we have told the device to send it's wake-up notifications to the PC controller. - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_WakeUp" ); - - WakeUp* wakeUp = static_cast( GetCommandClass( WakeUp::StaticGetCommandClassId() ) ); - - // if this device is a "sleeping device" and not a controller and not a - // FLiRS device. FLiRS will wake up when you send them something and they - // don't seem to support Wakeup - if( wakeUp && !IsController() && !IsFrequentListeningDevice() ) - { - // start the process of requesting node state from this sleeping device - wakeUp->Init(); - m_queryPending = true; - addQSC = true; - } - else - { - // this is not a sleeping device, so move to the ManufacturerSpecific1 stage - m_queryStage = QueryStage_ManufacturerSpecific1; - m_queryRetries = 0; - } - break; - } - case QueryStage_ManufacturerSpecific1: - { - // Obtain manufacturer, product type and product ID code from the node device - // Manufacturer Specific data is requested before the other command class data so - // that we can modify the supported command classes list through the product XML files. - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_ManufacturerSpecific1" ); - if( GetDriver()->GetNodeId() == m_nodeId ) - { - string configPath = ManufacturerSpecific::SetProductDetails( this, GetDriver()->GetManufacturerId(), GetDriver()->GetProductType(), GetDriver()->GetProductId() ); - if( configPath.length() > 0 ) - { - ManufacturerSpecific::LoadConfigXML( this, configPath ); - } - m_queryStage = QueryStage_NodeInfo; - m_queryRetries = 0; - } - else - { - ManufacturerSpecific* cc = static_cast( GetCommandClass( ManufacturerSpecific::StaticGetCommandClassId() ) ); - if( cc ) - { - m_queryPending = cc->RequestState( CommandClass::RequestFlag_Static, 1, Driver::MsgQueue_Query ); - addQSC = m_queryPending; - } - if( !m_queryPending ) - { - m_queryStage = QueryStage_NodeInfo; - m_queryRetries = 0; - } - } - break; - } - case QueryStage_NodeInfo: - { - if( !NodeInfoReceived() && m_nodeInfoSupported ) - { - // obtain from the node a list of command classes that it 1) supports and 2) controls (separated by a mark in the buffer) - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_NodeInfo" ); - Msg* msg = new Msg( "Request Node Info", m_nodeId, REQUEST, FUNC_ID_ZW_REQUEST_NODE_INFO, false, true, FUNC_ID_ZW_APPLICATION_UPDATE ); - msg->Append( m_nodeId ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Query ); - m_queryPending = true; - addQSC = true; - } - else - { - // This stage has been done already, so move to the Manufacturer Specific stage - m_queryStage = QueryStage_SecurityReport; - m_queryRetries = 0; - } - break; - } - case QueryStage_SecurityReport: - { - /* For Devices that Support the Security Class, we have to request a list of - * Command Classes that Require Security. - */ - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_SecurityReport" ); - - Security* seccc = static_cast( GetCommandClass( Security::StaticGetCommandClassId() ) ); - - if( seccc ) - { - // start the process of requesting node state from this sleeping device - m_queryPending = seccc->Init(); - /* Dont add a Notification Callback here, as this is a multipacket exchange. - * the Security Command Class will automatically advance the Query Stage - * when we recieve a SecurityCmd_SupportedReport - */ - addQSC = false; - } - else - { - // this is not a Security Device, so move onto the next querystage - m_queryStage = QueryStage_ManufacturerSpecific2; - m_queryRetries = 0; - } - - break; - } - case QueryStage_ManufacturerSpecific2: - { - if( !m_manufacturerSpecificClassReceived ) - { - // Obtain manufacturer, product type and product ID code from the node device - // Manufacturer Specific data is requested before the other command class data so - // that we can modify the supported command classes list through the product XML files. - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_ManufacturerSpecific2" ); - ManufacturerSpecific* cc = static_cast( GetCommandClass( ManufacturerSpecific::StaticGetCommandClassId() ) ); - if( cc ) - { - m_queryPending = cc->RequestState( CommandClass::RequestFlag_Static, 1, Driver::MsgQueue_Query ); - addQSC = m_queryPending; - } - if( !m_queryPending ) - { - m_queryStage = QueryStage_Versions; - m_queryRetries = 0; - } - } - else - { - ManufacturerSpecific* cc = static_cast( GetCommandClass( ManufacturerSpecific::StaticGetCommandClassId() ) ); - if( cc ) - { - cc->ReLoadConfigXML(); - } - m_queryStage = QueryStage_Versions; - m_queryRetries = 0; - } - break; - } - case QueryStage_Versions: - { - // Get the version information (if the device supports COMMAND_CLASS_VERSION - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Versions" ); - Version* vcc = static_cast( GetCommandClass( Version::StaticGetCommandClassId() ) ); - if( vcc ) - { - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - CommandClass* cc = it->second; - if( cc->GetMaxVersion() > 1 ) - { - // Get the version for each supported command class that - // we have implemented at greater than version one. - m_queryPending |= vcc->RequestCommandClassVersion( it->second ); - } - } - addQSC = m_queryPending; - } - // advance to Instances stage when finished - if( !m_queryPending ) - { - m_queryStage = QueryStage_Instances; - m_queryRetries = 0; - } - break; - } - case QueryStage_Instances: - { - // if the device at this node supports multiple instances, obtain a list of these instances - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Instances" ); - MultiInstance* micc = static_cast( GetCommandClass( MultiInstance::StaticGetCommandClassId() ) ); - if( micc ) - { - m_queryPending = micc->RequestInstances(); - addQSC = m_queryPending; - } - - // when done, advance to the Static stage - if( !m_queryPending ) - { - m_queryStage = QueryStage_Static; - m_queryRetries = 0; - - Log::Write( LogLevel_Info, m_nodeId, "Essential node queries are complete" ); - Notification* notification = new Notification( Notification::Type_EssentialNodeQueriesComplete ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - } - break; - } - case QueryStage_Static: - { - // Request any other static values associated with each command class supported by this node - // examples are supported thermostat operating modes, setpoints and fan modes - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Static" ); - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - if( !it->second->IsAfterMark() ) - { - m_queryPending |= it->second->RequestStateForAllInstances( CommandClass::RequestFlag_Static, Driver::MsgQueue_Query ); - } - } - addQSC = m_queryPending; - - if( !m_queryPending ) - { - // when all (if any) static information has been retrieved, advance to the Associations stage - m_queryStage = QueryStage_Associations; - m_queryRetries = 0; - } - break; - } - case QueryStage_Probe1: - { - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Probe1" ); - // - // Send a NoOperation message to see if the node is awake - // and alive. Based on the response or lack of response - // will determine next step. Called here when configuration exists. - // - NoOperation* noop = static_cast( GetCommandClass( NoOperation::StaticGetCommandClassId() ) ); - if( GetDriver()->GetNodeId() != m_nodeId ) - { - noop->Set( true ); - m_queryPending = true; - addQSC = true; - } - else - { - m_queryStage = QueryStage_Associations; - m_queryRetries = 0; - } - break; - } - case QueryStage_Associations: - { - // if this device supports COMMAND_CLASS_ASSOCIATION, determine to which groups this node belong - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Associations" ); - Association* acc = static_cast( GetCommandClass( Association::StaticGetCommandClassId() ) ); - if( acc ) - { - acc->RequestAllGroups( 0 ); - m_queryPending = true; - addQSC = true; - } - else - { - // if this device doesn't support Associations, move to retrieve Session information - m_queryStage = QueryStage_Neighbors; - m_queryRetries = 0; - } - break; - } - case QueryStage_Neighbors: - { - // retrieves this node's neighbors and stores the neighbor bitmap in the node object - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Neighbors" ); - GetDriver()->RequestNodeNeighbors( m_nodeId, 0 ); - m_queryPending = true; - addQSC = true; - break; - } - case QueryStage_Session: - { - // Request the session values from the command classes in turn - // examples of Session information are: current thermostat setpoints, node names and climate control schedules - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Session" ); - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - if( !it->second->IsAfterMark() ) - { - m_queryPending |= it->second->RequestStateForAllInstances( CommandClass::RequestFlag_Session, Driver::MsgQueue_Query ); - } - } - addQSC = m_queryPending; - if( !m_queryPending ) - { - m_queryStage = QueryStage_Dynamic; - m_queryRetries = 0; - } - break; - } - case QueryStage_Dynamic: - { - // Request the dynamic values from the node, that can change at any time - // Examples include on/off state, heating mode, temperature, etc. - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Dynamic" ); - m_queryPending = RequestDynamicValues(); - addQSC = m_queryPending; - - if( !m_queryPending ) - { - m_queryStage = QueryStage_Configuration; - m_queryRetries = 0; - } - break; - } - case QueryStage_Configuration: - { - // Request the configurable parameter values from the node. - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Configuration" ); - if( m_queryConfiguration ) - { - if( RequestAllConfigParams( 0 ) ) - { - m_queryPending = true; - addQSC = true; - } - m_queryConfiguration = false; - } - if( !m_queryPending ) - { - m_queryStage = QueryStage_Complete; - m_queryRetries = 0; - } - break; - } - case QueryStage_Complete: - { - ClearAddingNode(); - // Notify the watchers that the queries are complete for this node - Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Complete" ); - Notification* notification = new Notification( Notification::Type_NodeQueriesComplete ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - - // Check whether all nodes are now complete - GetDriver()->CheckCompletedNodeQueries(); - return; - } - default: - { - break; - } - } - } - - if( addQSC && m_nodeAlive ) - { - // Add a marker to the query queue so this advance method - // gets called again once this stage has completed. - GetDriver()->SendQueryStageComplete( m_nodeId, m_queryStage ); - } -} - -//----------------------------------------------------------------------------- -// -// We are done with a stage in the query process -//----------------------------------------------------------------------------- -void Node::QueryStageComplete -( - QueryStage const _stage -) -{ - // Check that we are actually on the specified stage - if( _stage != m_queryStage ) - { - return; - } - - if( m_queryStage != QueryStage_Complete ) - { - // Move to the next stage - m_queryPending = false; - m_queryStage = (QueryStage)( (uint32)m_queryStage + 1 ); - if( m_queryStage == QueryStage_Probe1 ) - { - m_queryStage = (QueryStage)( (uint32)m_queryStage + 1 ); - } - m_queryRetries = 0; - } -} - -//----------------------------------------------------------------------------- -// -// Retry a stage up to the specified maximum -//----------------------------------------------------------------------------- -void Node::QueryStageRetry -( - QueryStage const _stage, - uint8 const _maxAttempts // = 0 -) -{ - Log::Write( LogLevel_Info, m_nodeId, "QueryStageRetry stage %s requested stage %s max %d retries %d pending %d", c_queryStageNames[_stage], c_queryStageNames[m_queryStage], _maxAttempts, m_queryRetries, m_queryPending); - - // Check that we are actually on the specified stage - if( _stage != m_queryStage ) - { - return; - } - - m_queryPending = false; - if( _maxAttempts && ( ++m_queryRetries >= _maxAttempts ) ) - { - m_queryRetries = 0; - // We've retried too many times. Move to the next stage but only if - // we aren't in any of the probe stages. - if( m_queryStage != QueryStage_Probe && m_queryStage != QueryStage_Probe1 ) - { - m_queryStage = (Node::QueryStage)( (uint32)(m_queryStage + 1) ); - } - } - // Repeat the current query stage - GetDriver()->RetryQueryStageComplete( m_nodeId, m_queryStage ); -} - -//----------------------------------------------------------------------------- -// -// Set the query stage (but only to an earlier stage) -//----------------------------------------------------------------------------- -void Node::SetQueryStage -( - QueryStage const _stage, - bool const _advance // = true -) -{ - if( (int)_stage < (int)m_queryStage ) - { - m_queryStage = _stage; - m_queryPending = false; - - if( QueryStage_Configuration == _stage ) - { - m_queryConfiguration = true; - } - } - - if( _advance ) - { - AdvanceQueries(); - } -} - -//----------------------------------------------------------------------------- -// -// Gets the query stage name -//----------------------------------------------------------------------------- -string Node::GetQueryStageName -( - QueryStage const _stage -) -{ - return c_queryStageNames[_stage]; -} - -//----------------------------------------------------------------------------- -// -// Gets the neighbors of a node -//----------------------------------------------------------------------------- -uint32 Node::GetNeighbors -( - uint8** o_neighbors -) -{ - // determine how many neighbors there are - int i; - uint32 numNeighbors = 0; - if( m_queryStage < QueryStage_Session ) - { - *o_neighbors = NULL; - return 0; - } - for( i = 0; i < 29; i++ ) - { - for( unsigned char mask = 0x80; mask != 0; mask >>= 1 ) - if( ( m_neighbors[i] & mask ) != 0 ) - numNeighbors++; - } - - // handle the possibility that no neighbors are reported - if( !numNeighbors ) - { - *o_neighbors = NULL; - return 0; - } - - // create and populate an array with neighbor node ids - uint8* neighbors = new uint8[numNeighbors]; - uint32 index = 0; - for( int by=0; by<29; by++ ) - { - for( int bi=0; bi<8; bi++ ) - { - if( (m_neighbors[by] & ( 0x01< -// Read the node config from XML -//----------------------------------------------------------------------------- -void Node::ReadXML -( - TiXmlElement const* _node -) -{ - char const* str; - int intVal; - - str = _node->Attribute( "query_stage" ); - if( str ) - { - // After restoring state from a file, we need to at least refresh the association, session and dynamic values. - QueryStage queryStage = QueryStage_Associations; - for( uint32 i=0; i<(uint32)QueryStage_Associations; ++i ) - { - if( !strcmp( str, c_queryStageNames[i] ) ) - { - queryStage = (QueryStage)i; - break; - } - } - - SetQueryStage( queryStage, false ); - } - - if( m_queryStage != QueryStage_None ) - { - if( m_queryStage > QueryStage_ProtocolInfo ) - { - // Notify the watchers of the protocol info. - // We do the notification here so that it gets into the queue ahead of - // any other notifications generated by adding command classes etc. - m_protocolInfoReceived = true; - Notification* notification = new Notification( Notification::Type_NodeProtocolInfo ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - } - - if( m_queryStage > QueryStage_NodeInfo ) - { - m_nodeInfoReceived = true; - } - - if( m_queryStage > QueryStage_Instances ) - { - Notification* notification = new Notification( Notification::Type_EssentialNodeQueriesComplete ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - } - } - - str = _node->Attribute( "name" ); - if( str ) - { - m_nodeName = str; - } - - str = _node->Attribute( "location" ); - if( str ) - { - m_location = str; - } - - if( TIXML_SUCCESS == _node->QueryIntAttribute( "basic", &intVal ) ) - { - m_basic = (uint8)intVal; - } - - if( TIXML_SUCCESS == _node->QueryIntAttribute( "generic", &intVal ) ) - { - m_generic = (uint8)intVal; - } - - if( TIXML_SUCCESS == _node->QueryIntAttribute( "specific", &intVal ) ) - { - m_specific = (uint8)intVal; - } - - str = _node->Attribute( "type" ); - if( str ) - { - m_type = str; - } - - m_listening = true; - str = _node->Attribute( "listening" ); - if( str ) - { - m_listening = !strcmp( str, "true" ); - } - - m_frequentListening = false; - str = _node->Attribute( "frequentListening" ); - if( str ) - { - m_frequentListening = !strcmp( str, "true" ); - } - - m_beaming = false; - str = _node->Attribute( "beaming" ); - if( str ) - { - m_beaming = !strcmp( str, "true" ); - } - - m_routing = true; - str = _node->Attribute( "routing" ); - if( str ) - { - m_routing = !strcmp( str, "true" ); - } - - m_maxBaudRate = 0; - if( TIXML_SUCCESS == _node->QueryIntAttribute( "max_baud_rate", &intVal ) ) - { - m_maxBaudRate = (uint32)intVal; - } - - m_version = 0; - if( TIXML_SUCCESS == _node->QueryIntAttribute( "version", &intVal ) ) - { - m_version = (uint8)intVal; - } - - m_security = false; - str = _node->Attribute( "security" ); - if( str ) - { - m_security = !strcmp( str, "true" ); - } - - m_nodeInfoSupported = true; - str = _node->Attribute( "nodeinfosupported" ); - if( str ) - { - m_nodeInfoSupported = !strcmp( str, "true" ); - } - - // Read the manufacturer info and create the command classes - TiXmlElement const* child = _node->FirstChildElement(); - while( child ) - { - str = child->Value(); - if( str ) - { - if( !strcmp( str, "CommandClasses" ) ) - { - ReadCommandClassesXML( child ); - } - else if( !strcmp( str, "Manufacturer" ) ) - { - str = child->Attribute( "id" ); - if( str ) - { - m_manufacturerId = str; - } - - str = child->Attribute( "name" ); - if( str ) - { - m_manufacturerName = str; - } - - TiXmlElement const* product = child->FirstChildElement(); - if( !strcmp( product->Value(), "Product" ) ) - { - str = product->Attribute( "type" ); - if( str ) - { - m_productType = str; - } - - str = product->Attribute( "id" ); - if( str ) - { - m_productId = str; - } - - str = product->Attribute( "name" ); - if( str ) - { - m_productName = str; - } - } - } - } - - // Move to the next child node - child = child->NextSiblingElement(); - } - - if( m_nodeName.length() > 0 || m_location.length() > 0 || m_manufacturerId.length() > 0 ) - { - // Notify the watchers of the name changes - Notification* notification = new Notification( Notification::Type_NodeNaming ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - } -} - -//----------------------------------------------------------------------------- -// -// Read the device's protocol configuration from XML -//----------------------------------------------------------------------------- -void Node::ReadDeviceProtocolXML -( - TiXmlElement const* _ccsElement -) -{ - TiXmlElement const* ccElement = _ccsElement->FirstChildElement(); - while( ccElement ) - { - char const* str = ccElement->Value(); - if( str && !strcmp( str, "Protocol" ) ) - { - str = ccElement->Attribute( "nodeinfosupported" ); - if( str ) - { - m_nodeInfoSupported = !strcmp( str, "true" ); - } - - // Some controllers support API calls that aren't advertised in their returned data. - // So provide a way to manipulate the returned data to reflect reality. - TiXmlElement const* childElement = _ccsElement->FirstChildElement(); - while( childElement ) - { - str = childElement->Value(); - if( str && !strcmp( str, "APIcall" ) ) - { - char const* funcStr = childElement->Attribute( "function" ); - char *p; - uint8 func = (uint8)strtol( funcStr, &p, 16 ); - if( p != funcStr ) - { - char const* presStr = ccElement->Attribute( "present" ); - GetDriver()->SetAPICall( func, !strcmp( presStr, "true" ) ); - } - } - childElement = childElement->NextSiblingElement(); - } - return; - } - ccElement = ccElement->NextSiblingElement(); - } -} - -//----------------------------------------------------------------------------- -// -// Read the command classes from XML -//----------------------------------------------------------------------------- -void Node::ReadCommandClassesXML -( - TiXmlElement const* _ccsElement -) -{ - char const* str; - int32 intVal; - - TiXmlElement const* ccElement = _ccsElement->FirstChildElement(); - while( ccElement ) - { - str = ccElement->Value(); - if( str && !strcmp( str, "CommandClass" ) ) - { - if( TIXML_SUCCESS == ccElement->QueryIntAttribute( "id", &intVal ) ) - { - uint8 id = (uint8)intVal; - - // Check whether this command class is to be removed (product XMLs might - // request this if a class is not implemented properly by the device) - bool remove = false; - char const* action = ccElement->Attribute( "action" ); - if( action && !strcasecmp( action, "remove" ) ) - { - remove = true; - } - - CommandClass* cc = GetCommandClass( id ); - if( remove ) - { - // Remove support for the command class - RemoveCommandClass( id ); - } - else - { - if( NULL == cc ) - { - // Command class support does not exist yet, so we create it - cc = AddCommandClass( id ); - } - - if( NULL != cc ) - { - cc->ReadXML( ccElement ); - } - } - } - } - - ccElement = ccElement->NextSiblingElement(); - } -} - -//----------------------------------------------------------------------------- -// -// Save the static node configuration data -//----------------------------------------------------------------------------- -void Node::WriteXML -( - TiXmlElement* _driverElement -) -{ - char str[32]; - - TiXmlElement* nodeElement = new TiXmlElement( "Node" ); - _driverElement->LinkEndChild( nodeElement ); - - snprintf( str, 32, "%d", m_nodeId ); - nodeElement->SetAttribute( "id", str ); - - nodeElement->SetAttribute( "name", m_nodeName.c_str() ); - nodeElement->SetAttribute( "location", m_location.c_str() ); - - snprintf( str, 32, "%d", m_basic ); - nodeElement->SetAttribute( "basic", str ); - - snprintf( str, 32, "%d", m_generic ); - nodeElement->SetAttribute( "generic", str ); - - snprintf( str, 32, "%d", m_specific ); - nodeElement->SetAttribute( "specific", str ); - - nodeElement->SetAttribute( "type", m_type.c_str() ); - - nodeElement->SetAttribute( "listening", m_listening ? "true" : "false" ); - nodeElement->SetAttribute( "frequentListening", m_frequentListening ? "true" : "false" ); - nodeElement->SetAttribute( "beaming", m_beaming ? "true" : "false" ); - nodeElement->SetAttribute( "routing", m_routing ? "true" : "false" ); - - snprintf( str, 32, "%d", m_maxBaudRate ); - nodeElement->SetAttribute( "max_baud_rate", str ); - - snprintf( str, 32, "%d", m_version ); - nodeElement->SetAttribute( "version", str ); - - if( m_security ) - { - nodeElement->SetAttribute( "security", "true" ); - } - - if( !m_nodeInfoSupported ) - { - nodeElement->SetAttribute( "nodeinfosupported", "false" ); - } - - nodeElement->SetAttribute( "query_stage", c_queryStageNames[m_queryStage] ); - - // Write the manufacturer and product data in the same format - // as used in the ManyfacturerSpecfic.xml file. This will - // allow new devices to be added via a simple cut and paste. - TiXmlElement* manufacturerElement = new TiXmlElement( "Manufacturer" ); - nodeElement->LinkEndChild( manufacturerElement ); - - manufacturerElement->SetAttribute( "id", m_manufacturerId.c_str() ); - manufacturerElement->SetAttribute( "name", m_manufacturerName.c_str() ); - - TiXmlElement* productElement = new TiXmlElement( "Product" ); - manufacturerElement->LinkEndChild( productElement ); - - productElement->SetAttribute( "type", m_productType.c_str() ); - productElement->SetAttribute( "id", m_productId.c_str() ); - productElement->SetAttribute( "name", m_productName.c_str() ); - - // Write the command classes - TiXmlElement* ccsElement = new TiXmlElement( "CommandClasses" ); - nodeElement->LinkEndChild( ccsElement ); - - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - if( it->second->GetCommandClassId() == NoOperation::StaticGetCommandClassId() ) // don't output NoOperation - { - continue; - } - TiXmlElement* ccElement = new TiXmlElement( "CommandClass" ); - ccsElement->LinkEndChild( ccElement ); - it->second->WriteXML( ccElement ); - } -} - -//----------------------------------------------------------------------------- -// -// Handle the FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO response -//----------------------------------------------------------------------------- -void Node::UpdateProtocolInfo -( - uint8 const* _data -) -{ - if( ProtocolInfoReceived() ) - { - // We already have this info - return; - } - - if( _data[4] == 0 ) - { - // Node doesn't exist if Generic class is zero. - Log::Write( LogLevel_Info, m_nodeId, " Protocol Info for Node %d reports node nonexistent", m_nodeId ); - SetNodeAlive( false ); - return; - } - - // Notify the watchers of the protocol info. - // We do the notification here so that it gets into the queue ahead of - // any other notifications generated by adding command classes etc. - Notification* notification = new Notification( Notification::Type_NodeProtocolInfo ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - - // Capabilities - m_listening = ( ( _data[0] & 0x80 ) != 0 ); - m_routing = ( ( _data[0] & 0x40 ) != 0 ); - - m_maxBaudRate = 9600; - if( ( _data[0] & 0x38 ) == 0x10 ) - { - m_maxBaudRate = 40000; - } - - m_version = ( _data[0] & 0x07 ) + 1; - - m_frequentListening = ( ( _data[1] & ( SecurityFlag_Sensor250ms | SecurityFlag_Sensor1000ms ) ) != 0 ); - m_beaming = ( ( _data[1] & SecurityFlag_BeamCapability ) != 0 ); - - // Security - m_security = ( ( _data[1] & SecurityFlag_Security ) != 0 ); - - // Optional flag is true if the device reports optional command classes. - // NOTE: We stopped using this because not all devices report it properly, - // and now just request the optional classes regardless. - // bool optional = (( _data[1] & 0x80 ) != 0 ); - - Log::Write( LogLevel_Info, m_nodeId, " Protocol Info for Node %d:", m_nodeId ); - if( m_listening ) - Log::Write( LogLevel_Info, m_nodeId, " Listening = true" ); - else - { - Log::Write( LogLevel_Info, m_nodeId, " Listening = false" ); - Log::Write( LogLevel_Info, m_nodeId, " Frequent = %s", m_frequentListening ? "true" : "false" ); - } - Log::Write( LogLevel_Info, m_nodeId, " Beaming = %s", m_beaming ? "true" : "false" ); - Log::Write( LogLevel_Info, m_nodeId, " Routing = %s", m_routing ? "true" : "false" ); - Log::Write( LogLevel_Info, m_nodeId, " Max Baud Rate = %d", m_maxBaudRate ); - Log::Write( LogLevel_Info, m_nodeId, " Version = %d", m_version ); - Log::Write( LogLevel_Info, m_nodeId, " Security = %s", m_security ? "true" : "false" ); - - // Set up the device class based data for the node, including mandatory command classes - SetDeviceClasses( _data[3], _data[4], _data[5] ); - // Do this for every controller. A little extra work but it won't be a large file. - if( IsController() ) - { - GetDriver()->ReadButtons( m_nodeId ); - } - m_protocolInfoReceived = true; -} - -void Node::SetSecuredClasses -( - uint8 const* _data, - uint8 const _length -) -{ - uint32 i; - Log::Write( LogLevel_Info, m_nodeId, " Secured command classes for node %d:", m_nodeId ); - - bool afterMark = false; - for( i=0; i<_length; ++i ) - { - if( _data[i] == 0xef ) - { - // COMMAND_CLASS_MARK. - // Marks the end of the list of supported command classes. The remaining classes - // are those that can be controlled by the device. These classes are created - // without values. Messages received cause notification events instead. - afterMark = true; - continue; - } - /* Check if this is a CC that is already registered with the node */ - if (CommandClass *pCommandClass = GetCommandClass(_data[i])) - { - if (pCommandClass->IsSecureSupported()) { - pCommandClass->SetSecured(); - Log::Write( LogLevel_Info, m_nodeId, " %s (Secured)", pCommandClass->GetCommandClassName().c_str() ); - } else { - Log::Write( LogLevel_Info, m_nodeId, " %s (Downgraded)", pCommandClass->GetCommandClassName().c_str() ); - } - } - /* it might be a new CC we havn't seen as part of the NIF */ - else if( CommandClasses::IsSupported( _data[i] ) ) - { - if( CommandClass* pCommandClass = AddCommandClass( _data[i] ) ) - { - // If this class came after the COMMAND_CLASS_MARK, then we do not create values. - if( afterMark ) - { - pCommandClass->SetAfterMark(); - } - if (pCommandClass->IsSecureSupported()) { - pCommandClass->SetSecured(); - Log::Write( LogLevel_Info, m_nodeId, " %s (Secured)", pCommandClass->GetCommandClassName().c_str() ); - } else { - Log::Write( LogLevel_Info, m_nodeId, " %s (Downgraded)", pCommandClass->GetCommandClassName().c_str() ); - } - // Start with an instance count of one. If the device supports COMMMAND_CLASS_MULTI_INSTANCE - // then some command class instance counts will increase once the responses to the RequestState - // call at the end of this method have been processed. - pCommandClass->SetInstance( 1 ); - - } - } - else - { - Log::Write( LogLevel_Info, m_nodeId, " Secure CommandClass 0x%.2x - NOT SUPPORTED", _data[i] ); - } - } - Log::Write( LogLevel_Info, m_nodeId, " UnSecured command classes for node %d:", m_nodeId ); - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - if (!it->second->IsSecured()) - Log::Write( LogLevel_Info, m_nodeId, " %s (Unsecured)", it->second->GetCommandClassName().c_str() ); - } - - -} -//----------------------------------------------------------------------------- -// -// Set up the command classes from the node info frame -//----------------------------------------------------------------------------- -void Node::UpdateNodeInfo -( - uint8 const* _data, - uint8 const _length -) -{ - if( !NodeInfoReceived() ) - { - // Add the command classes specified by the device - Log::Write( LogLevel_Info, m_nodeId, " Optional command classes for node %d:", m_nodeId ); - - bool newCommandClasses = false; - uint32 i; - - bool afterMark = false; - for( i=0; i<_length; ++i ) - { - if( _data[i] == 0xef ) - { - // COMMAND_CLASS_MARK. - // Marks the end of the list of supported command classes. The remaining classes - // are those that can be controlled by the device. These classes are created - // without values. Messages received cause notification events instead. - afterMark = true; - - if( !newCommandClasses ) - { - Log::Write( LogLevel_Info, m_nodeId, " None" ); - } - Log::Write( LogLevel_Info, m_nodeId, " Optional command classes controlled by node %d:", m_nodeId ); - newCommandClasses = false; - continue; - } - - if( CommandClasses::IsSupported( _data[i] ) ) - { - if( CommandClass* pCommandClass = AddCommandClass( _data[i] ) ) - { - // If this class came after the COMMAND_CLASS_MARK, then we do not create values. - if( afterMark ) - { - pCommandClass->SetAfterMark(); - } - - // Start with an instance count of one. If the device supports COMMMAND_CLASS_MULTI_INSTANCE - // then some command class instance counts will increase once the responses to the RequestState - // call at the end of this method have been processed. - pCommandClass->SetInstance( 1 ); - newCommandClasses = true; - Log::Write( LogLevel_Info, m_nodeId, " %s", pCommandClass->GetCommandClassName().c_str() ); - } - } - else - { - Log::Write( LogLevel_Info, m_nodeId, " CommandClass 0x%.2x - NOT REQUIRED", _data[i] ); - } - } - - if( !newCommandClasses ) - { - // No additional command classes over the mandatory ones. - Log::Write( LogLevel_Info, m_nodeId, " None" ); - } - - SetStaticRequests(); - m_nodeInfoReceived = true; - } - else - { - // We probably only need to do the dynamic stuff - SetQueryStage( QueryStage_Dynamic ); - } - - // Treat the node info frame as a sign that the node is awake - if( WakeUp* wakeUp = static_cast( GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - wakeUp->SetAwake( true ); - } -} - -//----------------------------------------------------------------------------- -// -// Track alive state of a node for dead node detection. -//----------------------------------------------------------------------------- -void Node::SetNodeAlive -( - bool const _isAlive -) -{ - Notification* notification; - - if( _isAlive ) - { - Log::Write( LogLevel_Error, m_nodeId, "WARNING: node revived" ); - m_nodeAlive = true; - m_errors = 0; - if( m_queryStage != Node::QueryStage_Complete ) - { - m_queryRetries = 0; // restart at last stage - AdvanceQueries(); - } - notification = new Notification( Notification::Type_Notification ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - notification->SetNotification( Notification::Code_Alive ); - } - else - { - Log::Write( LogLevel_Error, m_nodeId, "ERROR: node presumed dead" ); - m_nodeAlive = false; - if( m_queryStage != Node::QueryStage_Complete ) - { - // Check whether all nodes are now complete - GetDriver()->CheckCompletedNodeQueries(); - } - notification = new Notification( Notification::Type_Notification ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - notification->SetNotification( Notification::Code_Dead ); - } - GetDriver()->QueueNotification( notification ); -} - -//----------------------------------------------------------------------------- -// -// The first time we hear from a node, we set flags to indicate the -// need to request certain static data from the device. This is so that -// we can track which data has been received, and which has not. -//----------------------------------------------------------------------------- -void Node::SetStaticRequests -( -) -{ - uint8 request = 0; - - if( GetCommandClass( MultiInstance::StaticGetCommandClassId() ) ) - { - // Request instances - request |= (uint8)CommandClass::StaticRequest_Instances; - } - - if( GetCommandClass( Version::StaticGetCommandClassId() ) ) - { - // Request versions - request |= (uint8)CommandClass::StaticRequest_Version; - } - - if( request ) - { - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - it->second->SetStaticRequest( request ); - } - SetQueryStage( QueryStage_ManufacturerSpecific2 ); - } -} - -//----------------------------------------------------------------------------- -// -// Set the name of the node -//----------------------------------------------------------------------------- -void Node::SetNodeName -( - string const& _nodeName -) -{ - m_nodeName = _nodeName; - // Notify the watchers of the name changes - Notification* notification = new Notification( Notification::Type_NodeNaming ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - if( NodeNaming* cc = static_cast( GetCommandClass( NodeNaming::StaticGetCommandClassId() ) ) ) - { - // The node supports naming, so we try to write the name into the device - cc->SetName( _nodeName ); - } -} - -//----------------------------------------------------------------------------- -// -// Set the location of the node -//----------------------------------------------------------------------------- -void Node::SetLocation -( - string const& _location -) -{ - m_location = _location; - // Notify the watchers of the name changes - Notification* notification = new Notification( Notification::Type_NodeNaming ); - notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); - GetDriver()->QueueNotification( notification ); - if( NodeNaming* cc = static_cast( GetCommandClass( NodeNaming::StaticGetCommandClassId() ) ) ) - { - // The node supports naming, so we try to write the location into the device - cc->SetLocation( _location ); - } -} - -//----------------------------------------------------------------------------- -// -// Handle a command class message -//----------------------------------------------------------------------------- -void Node::ApplicationCommandHandler -( - uint8 const* _data -) -{ - if( CommandClass* pCommandClass = GetCommandClass( _data[5] ) ) - { - pCommandClass->ReceivedCntIncr(); - pCommandClass->HandleMsg( &_data[6], _data[4] ); - } - else - { - if( _data[5] == ControllerReplication::StaticGetCommandClassId() ) - { - // This is a controller replication message, and we do not support it. - // We have to at least acknowledge the message to avoid locking the sending device. - Log::Write( LogLevel_Info, m_nodeId, "ApplicationCommandHandler - Default acknowledgement of controller replication data" ); - - Msg* msg = new Msg( "Replication Command Complete", m_nodeId, REQUEST, FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE, false ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Command ); - } - else - { - Log::Write( LogLevel_Info, m_nodeId, "ApplicationCommandHandler - Unhandled Command Class 0x%.2x", _data[5] ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Get the specified command class object if supported, otherwise NULL -//----------------------------------------------------------------------------- -CommandClass* Node::GetCommandClass -( - uint8 const _commandClassId -)const -{ - map::const_iterator it = m_commandClassMap.find( _commandClassId ); - if( it != m_commandClassMap.end() ) - { - return it->second; - } - - // Not found - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Add a command class to the node -//----------------------------------------------------------------------------- -CommandClass* Node::AddCommandClass -( - uint8 const _commandClassId -) -{ - if( GetCommandClass( _commandClassId ) ) - { - // Class and instance have already been added - return NULL; - } - - // Create the command class object and add it to our map - if( CommandClass* pCommandClass = CommandClasses::CreateCommandClass( _commandClassId, m_homeId, m_nodeId ) ) - { - m_commandClassMap[_commandClassId] = pCommandClass; - return pCommandClass; - } - else - { - Log::Write( LogLevel_Info, m_nodeId, "AddCommandClass - Unsupported Command Class 0x%.2x", _commandClassId ); - } - - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Remove a command class from the node -//----------------------------------------------------------------------------- -void Node::RemoveCommandClass -( - uint8 const _commandClassId -) -{ - map::iterator it = m_commandClassMap.find( _commandClassId ); - if( it == m_commandClassMap.end() ) - { - // Class is not found - return; - } - - // Remove all the values associated with this class - if( ValueStore* store = GetValueStore() ) - { - store->RemoveCommandClassValues( _commandClassId ); - } - - // Destroy the command class object and remove it from our map - Log::Write( LogLevel_Info, m_nodeId, "RemoveCommandClass - Removed support for %s", it->second->GetCommandClassName().c_str() ); - - delete it->second; - m_commandClassMap.erase( it ); -} - -//----------------------------------------------------------------------------- -// -// Set a configuration parameter in a device -//----------------------------------------------------------------------------- -bool Node::SetConfigParam -( - uint8 const _param, - int32 _value, - uint8 const _size -) -{ - if( Configuration* cc = static_cast( GetCommandClass( Configuration::StaticGetCommandClassId() ) ) ) - { - // First try to find an existing value representing the parameter, and set that. - if( Value* value = cc->GetValue( 1, _param ) ) - { - switch( value->GetID().GetType() ) - { - case ValueID::ValueType_Bool: - { - ValueBool* valueBool = static_cast( value ); - valueBool->Set( _value != 0 ); - break; - } - case ValueID::ValueType_Byte: - { - ValueByte* valueByte = static_cast( value ); - valueByte->Set( (uint8)_value ); - break; - } - case ValueID::ValueType_Short: - { - ValueShort* valueShort = static_cast( value ); - valueShort->Set( (uint16)_value ); - break; - } - case ValueID::ValueType_Int: - { - ValueInt* valueInt = static_cast( value ); - valueInt->Set( _value ); - break; - } - case ValueID::ValueType_List: - { - ValueList* valueList = static_cast( value ); - valueList->SetByValue( _value ); - break; - } - default: - { - } - } - - return true; - } - - // Failed to find an existing value object representing this - // configuration parameter, so we try using the default or - // included size through the Configuration command class. - cc->Set( _param, _value, _size ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request the value of a configuration parameter from the device -//----------------------------------------------------------------------------- -void Node::RequestConfigParam -( - uint8 const _param -) -{ - if( Configuration* cc = static_cast( GetCommandClass( Configuration::StaticGetCommandClassId() ) ) ) - { - cc->RequestValue( 0, _param, 1, Driver::MsgQueue_Send ); - } -} - -//----------------------------------------------------------------------------- -// -// Request the values of all known configuration parameters from the device -//----------------------------------------------------------------------------- -bool Node::RequestAllConfigParams -( - uint32 const _requestFlags -) -{ - bool res = false; - if( Configuration* cc = static_cast( GetCommandClass( Configuration::StaticGetCommandClassId() ) ) ) - { - // Go through all the values in the value store, and request all those which are in the Configuration command class - for( ValueStore::Iterator it = m_values->Begin(); it != m_values->End(); ++it ) - { - Value* value = it->second; - if( value->GetID().GetCommandClassId() == Configuration::StaticGetCommandClassId() && !value->IsWriteOnly() ) - { - res |= cc->RequestValue( _requestFlags, value->GetID().GetIndex(), 1, Driver::MsgQueue_Send ); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Request an update of all known dynamic values from the device -//----------------------------------------------------------------------------- -bool Node::RequestDynamicValues -( -) -{ - bool res = false; - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - if( !it->second->IsAfterMark() ) - { - res |= it->second->RequestStateForAllInstances( CommandClass::RequestFlag_Dynamic, Driver::MsgQueue_Send ); - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Helper method to set a device's basic level -//----------------------------------------------------------------------------- -void Node::SetLevel -( - uint8 const _level -) -{ - // Level is 0-99, with 0 = off and 99 = fully on. 255 = turn on at last level. - uint8 adjustedLevel = _level; - if( ( _level > 99 ) && ( _level < 255 ) ) - { - adjustedLevel = 99; - } - - if( Basic* cc = static_cast( GetCommandClass( Basic::StaticGetCommandClassId() ) ) ) - { - cc->Set( adjustedLevel ); - } -} - -//----------------------------------------------------------------------------- -// -// Helper method to set a device to be on -//----------------------------------------------------------------------------- -void Node::SetNodeOn -( -) -{ - // Level is 0-99, with 0 = off and 99 = fully on. 255 = turn on at last level. - if( Basic* cc = static_cast( GetCommandClass( Basic::StaticGetCommandClassId() ) ) ) - { - cc->Set( 255 ); - } -} - -//----------------------------------------------------------------------------- -// -// Helper method to set a device to be off -//----------------------------------------------------------------------------- -void Node::SetNodeOff -( -) -{ - // Level is 0-99, with 0 = off and 99 = fully on. 255 = turn on at last level. - if( Basic* cc = static_cast( GetCommandClass( Basic::StaticGetCommandClassId() ) ) ) - { - cc->Set( 0 ); - } -} - -//----------------------------------------------------------------------------- -// -// Helper to create a ValueID -//----------------------------------------------------------------------------- -ValueID Node::CreateValueID -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - ValueID::ValueType const _type -) -{ - return ValueID( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _type ); -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new bool value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueBool -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - bool const _default, - uint8 const _pollIntensity -) -{ - ValueBool* value = new ValueBool( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _default, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new trigger value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueButton -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - uint8 const _pollIntensity -) -{ - ValueButton* value = new ValueButton( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new byte value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueByte -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - uint8 const _default, - uint8 const _pollIntensity -) -{ - ValueByte* value = new ValueByte( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _default, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new decimal value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueDecimal -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - string const& _default, - uint8 const _pollIntensity -) -{ - ValueDecimal* value = new ValueDecimal( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _default, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new int value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueInt -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - int32 const _default, - uint8 const _pollIntensity -) -{ - ValueInt* value = new ValueInt( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _default, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new list value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueList -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - uint8 const _size, - vector const& _items, - int32 const _default, - uint8 const _pollIntensity -) -{ - ValueList* value = new ValueList( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _items, _default, _pollIntensity, _size ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new raw value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueRaw -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - uint8 const* _default, - uint8 const _length, - uint8 const _pollIntensity -) -{ - ValueRaw* value = new ValueRaw( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _default, _length, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new schedule value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueSchedule -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - uint8 const _pollIntensity -) -{ - ValueSchedule* value = new ValueSchedule( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new short value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueShort -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - int16 const _default, - uint8 const _pollIntensity -) -{ - ValueShort* value = new ValueShort( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _default, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to create a new string value and add it to the value store -//----------------------------------------------------------------------------- -bool Node::CreateValueString -( - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - string const& _default, - uint8 const _pollIntensity -) -{ - ValueString* value = new ValueString( m_homeId, m_nodeId, _genre, _commandClassId, _instance, _valueIndex, _label, _units, _readOnly, _writeOnly, _default, _pollIntensity ); - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - return false; -} - -//----------------------------------------------------------------------------- -// -// Helper to remove an existing list value from the value store -//----------------------------------------------------------------------------- -void Node::RemoveValueList -( - ValueList* _value -) -{ - ValueStore* store = GetValueStore(); - store->RemoveValue( _value->GetID().GetValueStoreKey() ); -} - -//----------------------------------------------------------------------------- -// -// Get the value object with the specified ID -//----------------------------------------------------------------------------- -bool Node::CreateValueFromXML -( - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value* value = NULL; - - // Create the value - ValueID::ValueType type = Value::GetTypeEnumFromName( _valueElement->Attribute( "type" ) ); - - switch( type ) - { - case ValueID::ValueType_Bool: { value = new ValueBool(); break; } - case ValueID::ValueType_Byte: { value = new ValueByte(); break; } - case ValueID::ValueType_Decimal: { value = new ValueDecimal(); break; } - case ValueID::ValueType_Int: { value = new ValueInt(); break; } - case ValueID::ValueType_List: { value = new ValueList(); break; } - case ValueID::ValueType_Schedule: { value = new ValueSchedule(); break; } - case ValueID::ValueType_Short: { value = new ValueShort(); break; } - case ValueID::ValueType_String: { value = new ValueString(); break; } - case ValueID::ValueType_Button: { value = new ValueButton(); break; } - case ValueID::ValueType_Raw: { value = new ValueRaw(); break; } - default: { Log::Write( LogLevel_Info, m_nodeId, "Unknown ValueType in XML: %s", _valueElement->Attribute( "type" ) ); break; } - } - - if( value ) - { - value->ReadXML( m_homeId, m_nodeId, _commandClassId, _valueElement ); - - ValueStore* store = GetValueStore(); - if( store->AddValue( value ) ) - { - value->Release(); - return true; - } - - value->Release(); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Apply XML differences to a value -//----------------------------------------------------------------------------- -void Node::ReadValueFromXML -( - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - int32 intVal; - - ValueID::ValueGenre genre = Value::GetGenreEnumFromName( _valueElement->Attribute( "genre" ) ); - ValueID::ValueType type = Value::GetTypeEnumFromName( _valueElement->Attribute( "type" ) ); - - uint8 instance = 0; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "instance", &intVal ) ) - { - instance = (uint8)intVal; - } - - uint8 index = 0; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "index", &intVal ) ) - { - index = (uint8)intVal; - } - - ValueID id = ValueID( m_homeId, m_nodeId, genre, _commandClassId, instance, index, type ); - - // Try to get the value from the ValueStore (everything except configuration parameters - // should already have been created when the command class instance count was read in). - // Create it if it doesn't already exist. - if( ValueStore* store = GetValueStore() ) - { - if( Value* value = store->GetValue( id.GetValueStoreKey() ) ) - { - value->ReadXML( m_homeId, m_nodeId, _commandClassId, _valueElement ); - value->Release(); - } - else - { - CreateValueFromXML( _commandClassId, _valueElement ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Get the value object with the specified ID -//----------------------------------------------------------------------------- -Value* Node::GetValue -( - ValueID const& _id -) -{ - // This increments the value's reference count - return GetValueStore()->GetValue( _id.GetValueStoreKey() ); -} - -//----------------------------------------------------------------------------- -// -// Get the value object with the specified settings -//----------------------------------------------------------------------------- -Value* Node::GetValue -( - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex -) -{ - Value* value = NULL; - ValueStore* store = GetValueStore(); - // This increments the value's reference count - value = store->GetValue( ValueID::GetValueStoreKey( _commandClassId, _instance, _valueIndex ) ); - return value; -} - -//----------------------------------------------------------------------------- -// -// Remove the value object with the specified settings -//----------------------------------------------------------------------------- -bool Node::RemoveValue -( - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex -) -{ - ValueStore* store = GetValueStore(); - return store->RemoveValue( ValueID::GetValueStoreKey( _commandClassId, _instance, _valueIndex ) ); -} - -//----------------------------------------------------------------------------- -// -// Get a Group from the node's map -//----------------------------------------------------------------------------- -Group* Node::GetGroup -( - uint8 const _groupIdx -) -{ - map::iterator it = m_groups.find( _groupIdx ); - if( it == m_groups.end() ) - { - return NULL; - } - - return it->second; -} - -//----------------------------------------------------------------------------- -// -// Add a group into the node's map -//----------------------------------------------------------------------------- -void Node::AddGroup -( - Group* _group -) -{ - map::iterator it = m_groups.find( _group->GetIdx() ); - if( it != m_groups.end() ) - { - // There is already a group with this id. We will replace it. - delete it->second; - m_groups.erase( it ); - } - - m_groups[_group->GetIdx()] = _group; -} - -//----------------------------------------------------------------------------- -// -// Save the group data -//----------------------------------------------------------------------------- -void Node::WriteGroups -( - TiXmlElement* _associationsElement -) -{ - for( map::iterator it = m_groups.begin(); it != m_groups.end(); ++it ) - { - Group* group = it->second; - - TiXmlElement* groupElement = new TiXmlElement( "Group" ); - _associationsElement->LinkEndChild( groupElement ); - group->WriteXML( groupElement ); - } -} - -//----------------------------------------------------------------------------- -// -// Gets the number of association groups reported by this node -//----------------------------------------------------------------------------- -uint8 Node::GetNumGroups -( -) -{ - return (uint8) m_groups.size(); -} - -//----------------------------------------------------------------------------- -// -// Gets the associations for a group -//----------------------------------------------------------------------------- -uint32 Node::GetAssociations -( - uint8 const _groupIdx, - uint8** o_associations -) -{ - uint32 numAssociations = 0; - if( Group* group = GetGroup( _groupIdx ) ) - { - numAssociations = group->GetAssociations( o_associations ); - } - - return numAssociations; -} - -//----------------------------------------------------------------------------- -// -// Gets the maximum number of associations for a group -//----------------------------------------------------------------------------- -uint8 Node::GetMaxAssociations -( - uint8 const _groupIdx -) -{ - uint8 maxAssociations = 0; - if( Group* group = GetGroup( _groupIdx ) ) - { - maxAssociations = group->GetMaxAssociations(); - } - - return maxAssociations; -} - -//----------------------------------------------------------------------------- -// -// Gets the label for a particular group -//----------------------------------------------------------------------------- -string Node::GetGroupLabel -( - uint8 const _groupIdx -) -{ - string label = ""; - if( Group* group = GetGroup( _groupIdx ) ) - { - label = group->GetLabel(); - } - - return label; -} - -//----------------------------------------------------------------------------- -// -// Adds a node to an association group -//----------------------------------------------------------------------------- -void Node::AddAssociation -( - uint8 const _groupIdx, - uint8 const _targetNodeId -) -{ - if( Group* group = GetGroup( _groupIdx ) ) - { - group->AddAssociation( _targetNodeId ); - } -} - -//----------------------------------------------------------------------------- -// -// Removes a node from an association group -//----------------------------------------------------------------------------- -void Node::RemoveAssociation -( - uint8 const _groupIdx, - uint8 const _targetNodeId -) -{ - if( Group* group = GetGroup( _groupIdx ) ) - { - group->RemoveAssociation( _targetNodeId ); - } -} - -//----------------------------------------------------------------------------- -// -// Automatically associate the controller with certain groups -//----------------------------------------------------------------------------- -void Node::AutoAssociate -( -) -{ - bool autoAssociate = false; - Options::Get()->GetOptionAsBool( "Associate", &autoAssociate ); - if( autoAssociate ) - { - // Try to automatically associate with any groups that have been flagged. - uint8 controllerNodeId = GetDriver()->GetNodeId(); - - for( map::iterator it = m_groups.begin(); it != m_groups.end(); ++it ) - { - Group* group = it->second; - if( group->IsAuto() && !group->Contains( controllerNodeId ) ) - { - // Associate the controller into the group - Log::Write( LogLevel_Info, m_nodeId, "Adding the controller to group %d (%s) of node %d", group->GetIdx(), group->GetLabel().c_str(), GetNodeId() ); - group->AddAssociation( controllerNodeId ); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Get a pointer to our driver -//----------------------------------------------------------------------------- -Driver* Node::GetDriver -( -)const -{ - return( Manager::Get()->GetDriver( m_homeId ) ); -} - -//----------------------------------------------------------------------------- -// Device Classes -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// -// Use the device class data to get a label for a MultiChannel EndPoint. -//----------------------------------------------------------------------------- -string Node::GetEndPointDeviceClassLabel -( - uint8 const _generic, - uint8 const _specific -) -{ - char str[32]; - string label; - - snprintf( str, sizeof(str), "Generic 0x%.2x Specific 0x%.2x", _generic, _specific ); - label = str; - - // Read in the device class data if it has not been read already. - if( !s_deviceClassesLoaded ) - { - ReadDeviceClasses(); - } - - // Get the Generic device class label - map::iterator git = s_genericDeviceClasses.find( _generic ); - if( git != s_genericDeviceClasses.end() ) - { - GenericDeviceClass* genericDeviceClass = git->second; - label = genericDeviceClass->GetLabel(); - - // Override with any specific device class label - if( DeviceClass* specificDeviceClass = genericDeviceClass->GetSpecificDeviceClass( _specific ) ) - { - label = specificDeviceClass->GetLabel(); - } - } - - return label; -} - -//----------------------------------------------------------------------------- -// -// Set the device class data for the node -//----------------------------------------------------------------------------- -bool Node::SetDeviceClasses -( - uint8 const _basic, - uint8 const _generic, - uint8 const _specific -) -{ - m_basic = _basic; - m_generic = _generic; - m_specific = _specific; - - // Read in the device class data if it has not been read already. - if( !s_deviceClassesLoaded ) - { - ReadDeviceClasses(); - } - - // Get the basic device class label - map::iterator bit = s_basicDeviceClasses.find( _basic ); - if( bit != s_basicDeviceClasses.end() ) - { - m_type = bit->second; - Log::Write( LogLevel_Info, m_nodeId, " Basic device class (0x%.2x) - %s", m_basic, m_type.c_str() ); - } - else - { - Log::Write( LogLevel_Info, m_nodeId, " Basic device class unknown" ); - } - - // Apply any Generic device class data - uint8 basicMapping = 0; - map::iterator git = s_genericDeviceClasses.find( _generic ); - if( git != s_genericDeviceClasses.end() ) - { - GenericDeviceClass* genericDeviceClass = git->second; - m_type = genericDeviceClass->GetLabel(); - - Log::Write( LogLevel_Info, m_nodeId, " Generic device Class (0x%.2x) - %s", m_generic, m_type.c_str() ); - - // Add the mandatory command classes for this generic class type - AddMandatoryCommandClasses( genericDeviceClass->GetMandatoryCommandClasses() ); - - // Get the command class that COMMAND_CLASS_BASIC maps to. - basicMapping = genericDeviceClass->GetBasicMapping(); - - // Apply any Specific device class data - if( DeviceClass* specificDeviceClass = genericDeviceClass->GetSpecificDeviceClass( _specific ) ) - { - m_type = specificDeviceClass->GetLabel(); - - Log::Write( LogLevel_Info, m_nodeId, " Specific device class (0x%.2x) - %s", m_specific, m_type.c_str() ); - - // Add the mandatory command classes for this specific class type - AddMandatoryCommandClasses( specificDeviceClass->GetMandatoryCommandClasses() ); - - if( specificDeviceClass->GetBasicMapping() ) - { - // Override the generic device class basic mapping with the specific device class one. - basicMapping = specificDeviceClass->GetBasicMapping(); - } - } - else - { - Log::Write( LogLevel_Info, m_nodeId, " No specific device class defined" ); - } - } - else - { - Log::Write( LogLevel_Info, m_nodeId, " No generic or specific device classes defined" ); - } - - // Deal with sleeping devices - if( !m_listening && !IsFrequentListeningDevice()) - { - // Device does not always listen, so we need the WakeUp handler. We can't - // wait for the command class list because the request for the command - // classes may need to go in the wakeup queue itself! - if( CommandClass* pCommandClass = AddCommandClass( WakeUp::StaticGetCommandClassId() ) ) - { - pCommandClass->SetInstance( 1 ); - } - } - - // Apply any COMMAND_CLASS_BASIC remapping - if( Basic* cc = static_cast( GetCommandClass( Basic::StaticGetCommandClassId() ) ) ) - { - cc->SetMapping( basicMapping ); - } - - // Write the mandatory command classes to the log - if( !m_commandClassMap.empty() ) - { - map::const_iterator cit; - - Log::Write( LogLevel_Info, m_nodeId, " Mandatory Command Classes for Node %d:", m_nodeId ); - bool reportedClasses = false; - for( cit = m_commandClassMap.begin(); cit != m_commandClassMap.end(); ++cit ) - { - if( !cit->second->IsAfterMark() && cit->second->GetCommandClassId() != NoOperation::StaticGetCommandClassId() ) - { - Log::Write( LogLevel_Info, m_nodeId, " %s", cit->second->GetCommandClassName().c_str() ); - reportedClasses = true; - } - } - if( !reportedClasses ) - { - Log::Write( LogLevel_Info, m_nodeId, " None" ); - } - - Log::Write( LogLevel_Info, m_nodeId, " Mandatory Command Classes controlled by Node %d:", m_nodeId ); - reportedClasses = false; - for( cit = m_commandClassMap.begin(); cit != m_commandClassMap.end(); ++cit ) - { - if( cit->second->IsAfterMark() ) - { - Log::Write( LogLevel_Info, m_nodeId, " %s", cit->second->GetCommandClassName().c_str() ); - reportedClasses = true; - } - } - if( !reportedClasses ) - { - Log::Write( LogLevel_Info, m_nodeId, " None" ); - } - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Add mandatory command classes to the node -//----------------------------------------------------------------------------- -bool Node::AddMandatoryCommandClasses -( - uint8 const* _commandClasses -) -{ - if( NULL == _commandClasses ) - { - // No command classes to add - return false; - } - - int i=0; - bool afterMark = false; - while( uint8 cc = _commandClasses[i++] ) - { - if( cc == 0xef ) - { - // COMMAND_CLASS_MARK. - // Marks the end of the list of supported command classes. The remaining classes - // are those that can be controlled by this device, which we can ignore. - afterMark = true; - continue; - } - - if( CommandClasses::IsSupported( cc ) ) - { - if( CommandClass* commandClass = AddCommandClass( cc ) ) - { - // If this class came after the COMMAND_CLASS_MARK, then we do not create values. - if( afterMark ) - { - commandClass->SetAfterMark(); - } - - // Start with an instance count of one. If the device supports COMMMAND_CLASS_MULTI_INSTANCE - // then some command class instance counts will increase. - commandClass->SetInstance( 1 ); - } - } - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Read the static device class data from the device_classes.xml file -//----------------------------------------------------------------------------- -void Node::ReadDeviceClasses -( -) -{ - // Load the XML document that contains the device class information - string configPath; - Options::Get()->GetOptionAsString( "ConfigPath", &configPath ); - - string filename = configPath + string("device_classes.xml"); - - TiXmlDocument doc; - if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) - { - Log::Write( LogLevel_Info, "Failed to load device_classes.xml" ); - Log::Write( LogLevel_Info, "Check that the config path provided when creating the Manager points to the correct location." ); - return; - } - - TiXmlElement const* deviceClassesElement = doc.RootElement(); - - // Read the basic and generic device classes - TiXmlElement const* child = deviceClassesElement->FirstChildElement(); - while( child ) - { - char const* str = child->Value(); - if( str ) - { - char const* keyStr = child->Attribute( "key" ); - if( keyStr ) - { - char* pStop; - uint8 key = (uint8)strtol( keyStr, &pStop, 16 ); - - if( !strcmp( str, "Generic" ) ) - { - s_genericDeviceClasses[key] = new GenericDeviceClass( child ); - } - else if( !strcmp( str, "Basic" ) ) - { - char const* label = child->Attribute( "label" ); - if( label ) - { - s_basicDeviceClasses[key] = label; - } - } - } - } - - child = child->NextSiblingElement(); - } - - s_deviceClassesLoaded = true; -} - -//----------------------------------------------------------------------------- -// -// Return driver statistics -//----------------------------------------------------------------------------- -void Node::GetNodeStatistics -( - NodeData* _data -) -{ - _data->m_sentCnt = m_sentCnt; - _data->m_sentFailed = m_sentFailed; - _data->m_retries = m_retries; - _data->m_receivedCnt = m_receivedCnt; - _data->m_receivedDups = m_receivedDups; - _data->m_receivedUnsolicited = m_receivedUnsolicited; - _data->m_lastRequestRTT = m_lastRequestRTT; - _data->m_lastResponseRTT = m_lastResponseRTT; - _data->m_sentTS = m_sentTS.GetAsString(); - _data->m_receivedTS = m_receivedTS.GetAsString(); - _data->m_averageRequestRTT = m_averageRequestRTT; - _data->m_averageResponseRTT = m_averageResponseRTT; - _data->m_quality = m_quality; - memcpy( _data->m_lastReceivedMessage, m_lastReceivedMessage, sizeof(m_lastReceivedMessage) ); - for( map::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) - { - CommandClassData ccData; - ccData.m_commandClassId = it->second->GetCommandClassId(); - ccData.m_sentCnt = it->second->GetSentCnt(); - ccData.m_receivedCnt = it->second->GetReceivedCnt(); - _data->m_ccData.push_back( ccData ); - } -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Node::DeviceClass::DeviceClass -( - TiXmlElement const* _el -): - m_mandatoryCommandClasses(NULL), - m_basicMapping(0) -{ - char const* str = _el->Attribute( "label" ); - if( str ) - { - m_label = str; - } - - str = _el->Attribute( "command_classes" ); - if( str ) - { - // Parse the comma delimted command class - // list into a temporary vector. - vector ccs; - char* pos = const_cast(str); - while( *pos ) - { - ccs.push_back( (uint8)strtol( pos, &pos, 16 ) ); - if( (*pos) == ',' ) - { - ++pos; - } - } - - // Copy the vector contents into an array. - size_t numCCs = ccs.size(); - m_mandatoryCommandClasses = new uint8[numCCs+1]; - m_mandatoryCommandClasses[numCCs] = 0; // Zero terminator - - for( uint32 i=0; iAttribute( "basic" ); - if( str ) - { - char* pStop; - m_basicMapping = (uint8)strtol( str, &pStop, 16 ); - } -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Node::GenericDeviceClass::GenericDeviceClass -( - TiXmlElement const* _el -): - DeviceClass( _el ) -{ - // Add any specific device classes - TiXmlElement const* child = _el->FirstChildElement(); - while( child ) - { - char const* str = child->Value(); - if( str && !strcmp( str, "Specific" ) ) - { - char const* keyStr = child->Attribute( "key" ); - if( keyStr ) - { - char* pStop; - uint8 key = (uint8)strtol( keyStr, &pStop, 16 ); - - m_specificDeviceClasses[key] = new DeviceClass( child ); - } - } - - child = child->NextSiblingElement(); - } -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Node::GenericDeviceClass::~GenericDeviceClass -( -) -{ - while( !m_specificDeviceClasses.empty() ) - { - map::iterator it = m_specificDeviceClasses.begin(); - delete it->second; - m_specificDeviceClasses.erase( it ); - } -} - -//----------------------------------------------------------------------------- -// -// Get a specific device class object -//----------------------------------------------------------------------------- -Node::DeviceClass* Node::GenericDeviceClass::GetSpecificDeviceClass -( - uint8 const& _specific -) -{ - map::iterator it = m_specificDeviceClasses.find( _specific ); - if( it != m_specificDeviceClasses.end() ) - { - return it->second; - } - - return NULL; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/Node.h b/lib/ESPiLight/pilight/libs/openzwave/Node.h deleted file mode 100644 index 2264b9e..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Node.h +++ /dev/null @@ -1,577 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Node.h -// -// A node in the Z-Wave network -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Node_H -#define _Node_H - -#include -#include -#include -#include -#include "Defs.h" -#include "value_classes/ValueID.h" -#include "value_classes/ValueList.h" -#include "Msg.h" -#include "platform/TimeStamp.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class CommandClass; - class Driver; - class Group; - class ValueStore; - class Value; - class ValueBool; - class ValueButton; - class ValueByte; - class ValueDecimal; - class ValueInt; - class ValueSchedule; - class ValueShort; - class ValueString; - class Mutex; - - /** \brief The Node class describes a Z-Wave node object...typically a device on the - * Z-Wave network. - */ - class Node - { - friend class Manager; - friend class Driver; - friend class Group; - friend class Value; - friend class ValueButton; - friend class Alarm; - friend class Association; - friend class AssociationCommandConfiguration; - friend class Basic; - friend class Battery; - friend class ClimateControlSchedule; - friend class Clock; - friend class CommandClass; - friend class ControllerReplication; - friend class EnergyProduction; - friend class Hail; - friend class Indicator; - friend class Language; - friend class Lock; - friend class ManufacturerSpecific; - friend class Meter; - friend class MeterPulse; - friend class MultiInstance; - friend class NodeNaming; - friend class Protection; - friend class Security; - friend class SensorAlarm; - friend class SensorBinary; - friend class SensorMultilevel; - friend class SwitchAll; - friend class SwitchBinary; - friend class SwitchMultilevel; - friend class SwitchToggleBinary; - friend class SwitchToggleMultilevel; - friend class ThermostatFanMode; - friend class ThermostatFanState; - friend class ThermostatMode; - friend class ThermostatOperatingState; - friend class ThermostatSetpoint; - friend class Version; - friend class WakeUp; - - //----------------------------------------------------------------------------- - // Construction - //----------------------------------------------------------------------------- - public: - /** Constructor initializes the node object, associating it with a specific - * network (_homeId) and network node (_nodeId). - * \param _homeId The homeId of the network to which this node is connected. - * \param _nodeId The nodeId of this node. - */ - Node( uint32 const _homeId, uint8 const _nodeId ); - /** Destructor cleans up memory allocated to node and its child objects. - */ - virtual ~Node(); - - private: - /** Returns a pointer to the driver (interface with a Z-Wave controller) - * associated with this node. - */ - Driver* GetDriver()const; - - //----------------------------------------------------------------------------- - // Initialization - //----------------------------------------------------------------------------- - public: - enum QueryStage - { - QueryStage_ProtocolInfo, /**< Retrieve protocol information */ - QueryStage_Probe, /**< Ping device to see if alive */ - QueryStage_WakeUp, /**< Start wake up process if a sleeping node */ - QueryStage_ManufacturerSpecific1, /**< Retrieve manufacturer name and product ids if ProtocolInfo lets us */ - QueryStage_NodeInfo, /**< Retrieve info about supported, controlled command classes */ - QueryStage_SecurityReport, /**< Retrive a list of Command Classes that require Security */ - QueryStage_ManufacturerSpecific2, /**< Retrieve manufacturer name and product ids */ - QueryStage_Versions, /**< Retrieve version information */ - QueryStage_Instances, /**< Retrieve information about multiple command class instances */ - QueryStage_Static, /**< Retrieve static information (doesn't change) */ - QueryStage_Probe1, /**< Ping a device upon starting with configuration */ - QueryStage_Associations, /**< Retrieve information about associations */ - QueryStage_Neighbors, /**< Retrieve node neighbor list */ - QueryStage_Session, /**< Retrieve session information (changes infrequently) */ - QueryStage_Dynamic, /**< Retrieve dynamic information (changes frequently) */ - QueryStage_Configuration, /**< Retrieve configurable parameter information (only done on request) */ - QueryStage_Complete, /**< Query process is completed for this node */ - QueryStage_None /**< Query process hasn't started for this node */ - }; - - - /** - * This function advances the query process (see Remarks below for more detail on the - * process). It iterates through the various query stages enumerated in Node::QueryStage. - * - * \remark - * For OpenZWave to discover everything about a node, we have to follow a certain - * order of queries, because the results of one stage may affect what is requested - * in the next stage. The stage is saved with the node data, so that any incomplete - * queries can be restarted the next time the application runs. - *

- * The individual command classes also store some state information as to whether - * they have had a response to certain queries. This state information is - * initilized by the SetStaticRequests call in QueryStage_None. It is also saved, - * so we do not need to request state from every command class if some have previously - * responded. - */ - void AdvanceQueries(); - - /** - * Signal that a specific query stage has been completed for this node. This will - * only work if the query process for this node is indeed at the specified stage. - * Otherwise, the function returns with no action. - * \param _stage The current stage of the query process. - */ - void QueryStageComplete( QueryStage const _stage ); - - /** - * Retry the specified query stage (up to _maxAttempts retries). This will - * only work if the query process for this node is indeed at the specified stage. - * Otherwise, the function returns with no action. - * \param _stage The query stage to retry. - * \param _maxAttempts - */ - void QueryStageRetry( QueryStage const _stage, uint8 const _maxAttempts = 0 ); // maxAttempts of zero means no limit - - /** - * This function sets the query stage for the node (but only to an earlier stage). - * If a later stage is specified than the current one, it is ignored. - * \param _stage The desired query stage. - * \see m_queryStage, m_queryPending - */ - void SetQueryStage( QueryStage const _stage, bool const _advance = true ); - - /** - * Returns the current query stage enum. - * \return Enum value with the current query stage. - * \see m_queryStage - */ - Node::QueryStage GetCurrentQueryStage() { return m_queryStage; } - - /** - * Returns the specified query stage string. - * \param _stage The query stage. - * \return Specified query stage string. - * \see m_queryStage, m_queryPending - */ - string GetQueryStageName( QueryStage const _stage ); - - /** - * Returns whether the library thinks a node is functioning properly - * \return boolean status of node. - */ - bool IsNodeAlive()const{ return m_nodeAlive; } - - /** - * This function handles a response to the FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO - * command for this node. If protocol information has already been retrieved - * for the node, the function simply returns. Otherwise, it populates several - * member variables about the device at this node: - * - m_routing (whether it is a routing node (capable of passing commands along to other nodes in the network) or not - * - m_maxBaudRate (the maximum baud rate at which this device can communicate) - * - m_version (TODO) - * - m_security (whether device supports security features) - * - m_listening (device is powered and listening constantly) - * - m_frequentListening (device can be woken up with a beam) - * - m_beaming (device is beam capable) - */ - void UpdateProtocolInfo( uint8 const* _data ); - void UpdateNodeInfo( uint8 const* _data, uint8 const _length ); - - bool ProtocolInfoReceived()const{ return m_protocolInfoReceived; } - bool NodeInfoReceived()const{ return m_nodeInfoReceived; } - - bool AllQueriesCompleted()const{ return( QueryStage_Complete == m_queryStage ); } - - /** - * Handle dead node detection tracking. - * Use this routine to set state of nodes. - * Tracks state as well as send notifications. - */ - void SetNodeAlive( bool const _isAlive ); - - private: - void SetStaticRequests(); - - QueryStage m_queryStage; - bool m_queryPending; - bool m_queryConfiguration; - uint8 m_queryRetries; - bool m_protocolInfoReceived; - bool m_nodeInfoReceived; - bool m_manufacturerSpecificClassReceived; - bool m_nodeInfoSupported; - bool m_nodeAlive; - - //----------------------------------------------------------------------------- - // Capabilities - //----------------------------------------------------------------------------- - public: - // Security flags - enum - { - SecurityFlag_Security = 0x01, - SecurityFlag_Controller = 0x02, - SecurityFlag_SpecificDevice = 0x04, - SecurityFlag_RoutingSlave = 0x08, - SecurityFlag_BeamCapability = 0x10, - SecurityFlag_Sensor250ms = 0x20, - SecurityFlag_Sensor1000ms = 0x40, - SecurityFlag_OptionalFunctionality = 0x80 - }; - - // Node Ids - enum - { - NodeBroadcast = 0xff - }; - - bool IsListeningDevice()const{ return m_listening; } - bool IsFrequentListeningDevice()const{ return m_frequentListening; } - bool IsBeamingDevice()const{ return m_beaming; } - bool IsRoutingDevice()const{ return m_routing; } - bool IsSecurityDevice()const{ return m_security; } - uint32 GetMaxBaudRate()const{ return m_maxBaudRate; } - uint8 GetVersion()const{ return m_version; } - uint8 GetSecurity()const{ return m_security; } - - uint8 GetNodeId()const{ return m_nodeId; } - - uint8 GetBasic()const{ return m_basic; } - uint8 GetGeneric()const{ return m_generic; } - uint8 GetSpecific()const{ return m_specific; } - string const& GetType()const{ return m_type; } - uint32 GetNeighbors( uint8** o_associations ); - bool IsController()const{ return ( m_basic == 0x01 || m_basic == 0x02 ) && ( m_generic == 0x01 || m_generic == 0x02 ); } - bool IsAddingNode() const { return m_addingNode; } /* These three *AddingNode functions are used to tell if we this node is just being discovered. Currently used by the Security CC to initiate the Network Key Exchange */ - void SetAddingNode() { m_addingNode = true; } - void ClearAddingNode() { m_addingNode = false; } - - private: - bool m_listening; - bool m_frequentListening; - bool m_beaming; - bool m_routing; - uint32 m_maxBaudRate; - uint8 m_version; - bool m_security; - uint32 m_homeId; - uint8 m_nodeId; - uint8 m_basic; //*< Basic device class (0x01-Controller, 0x02-Static Controller, 0x03-Slave, 0x04-Routing Slave - uint8 m_generic; - uint8 m_specific; - string m_type; // Label representing the specific/generic/basic value - uint8 m_neighbors[29]; // Bitmask containing the neighbouring nodes - uint8 m_numRouteNodes; // number of node routes - uint8 m_routeNodes[5]; // nodes to route to - map m_buttonMap; // Map button IDs into virtual node numbers - bool m_addingNode; - - //----------------------------------------------------------------------------- - // Device Naming - //----------------------------------------------------------------------------- - private: - // Manufacturer, Product and Name are stored here so they can be set by the - // user even if the device does not support the relevant command classes. - string GetManufacturerName()const{ return m_manufacturerName; } - string GetProductName()const{ return m_productName; } - string GetNodeName()const{ return m_nodeName; } - string GetLocation()const{ return m_location; } - - string GetManufacturerId()const{ return m_manufacturerId; } - string GetProductType()const{ return m_productType; } - string GetProductId()const{ return m_productId; } - - void SetManufacturerName( string const& _manufacturerName ){ m_manufacturerName = _manufacturerName; } - void SetProductName( string const& _productName ){ m_productName = _productName; } - void SetNodeName( string const& _nodeName ); - void SetLocation( string const& _location ); - - void SetManufacturerId( string const& _manufacturerId ){ m_manufacturerId = _manufacturerId; } - void SetProductType( string const& _productType ){ m_productType = _productType; } - void SetProductId( string const& _productId ){ m_productId = _productId; } - - string m_manufacturerName; - string m_productName; - string m_nodeName; - string m_location; - - string m_manufacturerId; - string m_productType; - string m_productId; - - //----------------------------------------------------------------------------- - // Command Classes - //----------------------------------------------------------------------------- - public: - /** - * This function retrieves a pointer to the requested command class object (if supported by this node). - * \param _commandClassId Class ID (a single byte value) identifying the command class requested. - * \return Pointer to the requested CommandClass object if supported, otherwise NULL. - * \see CommandClass, m_commandClassMap - */ - CommandClass* GetCommandClass( uint8 const _commandClassId )const; - void ApplicationCommandHandler( uint8 const* _data ); - - /** - * This function sets up Secured Command Classes. It iterates over the existing command classes marking them - * as Secured if they exist, and if they don't, it creates new Command Classes and sets them up as Secured - * @param _data a list of Command Classes that are Secured by the Device - * @param _length the length of the _data string - */ - void SetSecuredClasses( uint8 const* _data, uint8 const _length ); - - private: - /** - * Creates the specified command class object and adds it to the node (via the - * m_commandClassMap) if it doesn't exist. - * No new object is created if it already exists for this node. - * \param _commandClassId Class ID (a single byte value) identifying the command class requested. - * \return Pointer to the CommandClass object just added to the map (NULL if the object - * was already there or if the CommandClass object creation failed). - * \see CommandClass, CommandClasses::CreateCommandClass, m_commandClassMap - */ - CommandClass* AddCommandClass( uint8 const _commandClassId ); - /** - * Removes a command class object from the node (via the m_commandClassMap). Before removing the - * object, this function also removes any values stored in the object's ValueStore. - * \param _commandClassId Class ID (a single byte value) identifying the command class to be removed. - * \see m_commandClassMap, ValueStore, GetValueStore, ValueStore::RemoveCommandClassValues - */ - void RemoveCommandClass( uint8 const _commandClassId ); - void ReadXML( TiXmlElement const* _nodeElement ); - void ReadDeviceProtocolXML( TiXmlElement const* _ccsElement ); - void ReadCommandClassesXML( TiXmlElement const* _ccsElement ); - void WriteXML( TiXmlElement* _nodeElement ); - - map m_commandClassMap; /**< Map of command class ids and pointers to associated command class objects */ - - //----------------------------------------------------------------------------- - // Basic commands (helpers that go through the basic command class) - //----------------------------------------------------------------------------- - public: - void SetLevel( uint8 const _level ); - - //----------------------------------------------------------------------------- - // On/Off commands (helpers that go through the basic or switchall command class) - //----------------------------------------------------------------------------- - public: - void SetNodeOn(); - void SetNodeOff(); - - //----------------------------------------------------------------------------- - // Values (handled by the command classes) - //----------------------------------------------------------------------------- - public: - ValueID CreateValueID( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, ValueID::ValueType const _type ); - - Value* GetValue( ValueID const& _id ); - Value* GetValue( uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex ); - bool RemoveValue( uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex ); - - // Helpers for creating values - bool CreateValueBool( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, bool const _default, uint8 const _pollIntensity ); - bool CreateValueButton( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, uint8 const _pollIntensity ); - bool CreateValueByte( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _default, uint8 const _pollIntensity ); - bool CreateValueDecimal( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, string const& _default, uint8 const _pollIntensity ); - bool CreateValueInt( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, int32 const _default, uint8 const _pollIntensity ); - bool CreateValueList( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _size, vector const& _items, int32 const _default, uint8 const _pollIntensity ); - bool CreateValueRaw( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const* _default, uint8 const _length, uint8 const _pollIntensity ); - bool CreateValueSchedule( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _pollIntensity ); - bool CreateValueShort( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, int16 const _default, uint8 const _pollIntensity ); - bool CreateValueString( ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, string const& _default, uint8 const _pollIntensity ); - - // helpers for removing values - void RemoveValueList( ValueList* _value ); - - void ReadValueFromXML( uint8 const _commandClassId, TiXmlElement const* _valueElement ); - bool CreateValueFromXML( uint8 const _commandClassId, TiXmlElement const* _valueElement ); - - private: - ValueStore* GetValueStore()const{ return m_values; } - - ValueStore* m_values; // Values reported via command classes - - //----------------------------------------------------------------------------- - // Configuration Parameters (handled by the Configuration command class) - //----------------------------------------------------------------------------- - private: - bool SetConfigParam( uint8 const _param, int32 _value, uint8 const _size ); - void RequestConfigParam( uint8 const _param ); - bool RequestAllConfigParams( uint32 const _requestFlags ); - - //----------------------------------------------------------------------------- - // Dynamic Values (used by query and other command classes for updating) - //----------------------------------------------------------------------------- - private: - bool RequestDynamicValues(); - //----------------------------------------------------------------------------- - // Groups - //----------------------------------------------------------------------------- - private: - // The public interface is provided via the wrappers in the Manager class - uint8 GetNumGroups(); - uint32 GetAssociations( uint8 const _groupIdx, uint8** o_associations ); - uint8 GetMaxAssociations( uint8 const _groupIdx ); - string GetGroupLabel( uint8 const _groupIdx ); - void AddAssociation( uint8 const _groupIdx, uint8 const _targetNodeId ); - void RemoveAssociation( uint8 const _groupIdx, uint8 const _targetNodeId ); - void AutoAssociate(); - - // The following methods are not exposed - Group* GetGroup( uint8 const _groupIdx ); // Get a pointer to a Group object. This must only be called while holding the node Lock. - void AddGroup( Group* _group ); // The groups are fixed properties of a device, so there is no need for a matching RemoveGroup. - void WriteGroups( TiXmlElement* _associationsElement ); // Write the group data out to XNL - - map m_groups; // Maps group indices to Group objects. - - //----------------------------------------------------------------------------- - // Device Classes (static data read from the device_classes.xml file) - //----------------------------------------------------------------------------- - private: - // Container for device class info - class DeviceClass - { - public: - DeviceClass( TiXmlElement const* _el ); - ~DeviceClass(){ delete [] m_mandatoryCommandClasses; } - - uint8 const* GetMandatoryCommandClasses(){ return m_mandatoryCommandClasses; } - uint8 GetBasicMapping(){ return m_basicMapping; } - string const& GetLabel(){ return m_label; } - - private: - uint8* m_mandatoryCommandClasses; // Zero terminated array of mandatory command classes for this device type. - uint8 m_basicMapping; // Command class that COMMAND_CLASS_BASIC maps on to, or zero if there is no mapping. - string m_label; // Descriptive label for the device. - }; - - // Container for generic device class info - class GenericDeviceClass : public DeviceClass - { - public: - GenericDeviceClass( TiXmlElement const* _el ); - ~GenericDeviceClass(); - - DeviceClass* GetSpecificDeviceClass( uint8 const& _specific ); - - private: - map m_specificDeviceClasses; - }; - - - bool SetDeviceClasses( uint8 const _basic, uint8 const _generic, uint8 const _specific ); // Set the device class data for the node - bool AddMandatoryCommandClasses( uint8 const* _commandClasses ); // Add mandatory command classes as specified in the device_classes.xml to the node. - void ReadDeviceClasses(); // Read the static device class data from the device_classes.xml file - string GetEndPointDeviceClassLabel( uint8 const _generic, uint8 const _specific ); - - static bool s_deviceClassesLoaded; // True if the xml file has alreayd been loaded - static map s_basicDeviceClasses; // Map of basic device classes. - static map s_genericDeviceClasses; // Map of generic device classes. - - //----------------------------------------------------------------------------- - // Statistics - //----------------------------------------------------------------------------- - public: - struct CommandClassData - { - uint8 m_commandClassId; - uint32 m_sentCnt; - uint32 m_receivedCnt; - }; - - struct NodeData - { - uint32 m_sentCnt; - uint32 m_sentFailed; - uint32 m_retries; - uint32 m_receivedCnt; - uint32 m_receivedDups; - uint32 m_receivedUnsolicited; - string m_sentTS; - string m_receivedTS; - uint32 m_lastRequestRTT; - uint32 m_averageRequestRTT; // ms - uint32 m_lastResponseRTT; - uint32 m_averageResponseRTT; - uint8 m_quality; // Node quality measure - uint8 m_lastReceivedMessage[254]; - list m_ccData; - }; - - private: - void GetNodeStatistics( NodeData* _data ); - - uint32 m_sentCnt; // Number of messages sent from this node. - uint32 m_sentFailed; // Number of sent messages failed - uint32 m_retries; // Number of message retries - uint32 m_receivedCnt; // Number of messages received from this node. - uint32 m_receivedDups; // Number of duplicated messages received; - uint32 m_receivedUnsolicited; // Number of messages received unsolicited - uint32 m_lastRequestRTT; // Last message request RTT - uint32 m_lastResponseRTT; // Last message response RTT - TimeStamp m_sentTS; // Last message sent time - TimeStamp m_receivedTS; // Last message received time - uint32 m_averageRequestRTT; // Average Request round trip time. - uint32 m_averageResponseRTT; // Average Reponse round trip time. - uint8 m_quality; // Node quality measure - uint8 m_lastReceivedMessage[254]; // Place to hold last received message - uint8 m_errors; // Count errors for dead node detection - }; - -} //namespace OpenZWave - -#endif //_Node_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/Notification.h b/lib/ESPiLight/pilight/libs/openzwave/Notification.h deleted file mode 100644 index 715375b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Notification.h +++ /dev/null @@ -1,195 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Notification.h -// -// Contains details of a Z-Wave event reported to the user -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Notification_H -#define _Notification_H - -#include "Defs.h" -#include "value_classes/ValueID.h" - -namespace OpenZWave -{ - /** \brief Provides a container for data sent via the notification callback - * handler installed by a call to Manager::AddWatcher. - * - * A notification object is only ever created or deleted internally by - * OpenZWave. - */ - class OPENZWAVE_EXPORT Notification - { - friend class Manager; - friend class Driver; - friend class Node; - friend class Group; - friend class Value; - friend class ValueStore; - friend class Basic; - friend class ManufacturerSpecific; - friend class NodeNaming; - friend class NoOperation; - friend class SceneActivation; - friend class WakeUp; - - public: - /** - * Notification types. - * Notifications of various Z-Wave events sent to the watchers - * registered with the Manager::AddWatcher method. - * \see Manager::AddWatcher - */ - enum NotificationType - { - Type_ValueAdded = 0, /**< A new node value has been added to OpenZWave's list. These notifications occur after a node has been discovered, and details of its command classes have been received. Each command class may generate one or more values depending on the complexity of the item being represented. */ - Type_ValueRemoved, /**< A node value has been removed from OpenZWave's list. This only occurs when a node is removed. */ - Type_ValueChanged, /**< A node value has been updated from the Z-Wave network and it is different from the previous value. */ - Type_ValueRefreshed, /**< A node value has been updated from the Z-Wave network. */ - Type_Group, /**< The associations for the node have changed. The application should rebuild any group information it holds about the node. */ - Type_NodeNew, /**< A new node has been found (not already stored in zwcfg*.xml file) */ - Type_NodeAdded, /**< A new node has been added to OpenZWave's list. This may be due to a device being added to the Z-Wave network, or because the application is initializing itself. */ - Type_NodeRemoved, /**< A node has been removed from OpenZWave's list. This may be due to a device being removed from the Z-Wave network, or because the application is closing. */ - Type_NodeProtocolInfo, /**< Basic node information has been receievd, such as whether the node is a listening device, a routing device and its baud rate and basic, generic and specific types. It is after this notification that you can call Manager::GetNodeType to obtain a label containing the device description. */ - Type_NodeNaming, /**< One of the node names has changed (name, manufacturer, product). */ - Type_NodeEvent, /**< A node has triggered an event. This is commonly caused when a node sends a Basic_Set command to the controller. The event value is stored in the notification. */ - Type_PollingDisabled, /**< Polling of a node has been successfully turned off by a call to Manager::DisablePoll */ - Type_PollingEnabled, /**< Polling of a node has been successfully turned on by a call to Manager::EnablePoll */ - Type_SceneEvent, /**< Scene Activation Set received */ - Type_CreateButton, /**< Handheld controller button event created */ - Type_DeleteButton, /**< Handheld controller button event deleted */ - Type_ButtonOn, /**< Handheld controller button on pressed event */ - Type_ButtonOff, /**< Handheld controller button off pressed event */ - Type_DriverReady, /**< A driver for a PC Z-Wave controller has been added and is ready to use. The notification will contain the controller's Home ID, which is needed to call most of the Manager methods. */ - Type_DriverFailed, /**< Driver failed to load */ - Type_DriverReset, /**< All nodes and values for this driver have been removed. This is sent instead of potentially hundreds of individual node and value notifications. */ - Type_EssentialNodeQueriesComplete, /**< The queries on a node that are essential to its operation have been completed. The node can now handle incoming messages. */ - Type_NodeQueriesComplete, /**< All the initialisation queries on a node have been completed. */ - Type_AwakeNodesQueried, /**< All awake nodes have been queried, so client application can expected complete data for these nodes. */ - Type_AllNodesQueriedSomeDead, /**< All nodes have been queried but some dead nodes found. */ - Type_AllNodesQueried, /**< All nodes have been queried, so client application can expected complete data. */ - Type_Notification, /**< An error has occured that we need to report. */ - Type_DriverRemoved /**< The Driver is being removed. (either due to Error or by request) Do Not Call Any Driver Related Methods after recieving this call */ - }; - - /** - * Notification codes. - * Notifications of the type Type_Notification convey some - * extra information defined here. - */ - enum NotificationCode - { - Code_MsgComplete = 0, /**< Completed messages */ - Code_Timeout, /**< Messages that timeout will send a Notification with this code. */ - Code_NoOperation, /**< Report on NoOperation message sent completion */ - Code_Awake, /**< Report when a sleeping node wakes up */ - Code_Sleep, /**< Report when a node goes to sleep */ - Code_Dead, /**< Report when a node is presumed dead */ - Code_Alive /**< Report when a node is revived */ - }; - - /** - * Get the type of this notification. - * \return the notification type. - * \see NotificationType - */ - NotificationType GetType()const{ return m_type; } - - /** - * Get the Home ID of the driver sending this notification. - * \return the driver Home ID - */ - uint32 GetHomeId()const{ return m_valueId.GetHomeId(); } - - /** - * Get the ID of any node involved in this notification. - * \return the node's ID - */ - uint8 GetNodeId()const{ return m_valueId.GetNodeId(); } - - /** - * Get the unique ValueID of any value involved in this notification. - * \return the value's ValueID - */ - ValueID const& GetValueID()const{ return m_valueId; } - - /** - * Get the index of the association group that has been changed. Only valid in NotificationType::Type_Group notifications. - * \return the group index. - */ - uint8 GetGroupIdx()const{ assert(Type_Group==m_type); return m_byte; } - - /** - * Get the event value of a notification. Only valid in NotificationType::Type_NodeEvent notifications. - * \return the event value. - */ - uint8 GetEvent()const{ assert(Type_NodeEvent==m_type); return m_byte; } - - /** - * Get the button id of a notification. Only valid in NotificationType::Type_CreateButton, DeleteButton, - * ButtonOn and ButtonOff notifications. - * \return the button id. - */ - uint8 GetButtonId()const{ assert(Type_CreateButton==m_type || Type_DeleteButton==m_type || Type_ButtonOn==m_type || Type_ButtonOff==m_type); return m_byte; } - - /** - * Get the scene Id of a notification. Only valid in NotificationType::Type_SceneEvent notifications. - * \return the event value. - */ - uint8 GetSceneId()const{ assert(Type_SceneEvent==m_type); return m_byte; } - - /** - * Get the notification code from a notification. Only valid for NotificationType::Type_Notification notifications. - * \return the notification code. - */ - uint8 GetNotification()const{ assert(Type_Notification==m_type); return m_byte; } - - /** - * Helper function to simplify wrapping the notification class. Should not normally need to be called. - * \return the internal byte value of the notification. - */ - uint8 GetByte()const{ return m_byte; } - - private: - Notification( NotificationType _type ): m_type( _type ), m_byte(0){} - ~Notification(){} - - void SetHomeAndNodeIds( uint32 const _homeId, uint8 const _nodeId ){ m_valueId = ValueID( _homeId, _nodeId ); } - void SetHomeNodeIdAndInstance ( uint32 const _homeId, uint8 const _nodeId, uint32 const _instance ){ m_valueId = ValueID( _homeId, _nodeId, _instance ); } - void SetValueId( ValueID const& _valueId ){ m_valueId = _valueId; } - void SetGroupIdx( uint8 const _groupIdx ){ assert(Type_Group==m_type); m_byte = _groupIdx; } - void SetEvent( uint8 const _event ){ assert(Type_NodeEvent==m_type); m_byte = _event; } - void SetSceneId( uint8 const _sceneId ){ assert(Type_SceneEvent==m_type); m_byte = _sceneId; } - void SetButtonId( uint8 const _buttonId ){ assert(Type_CreateButton==m_type||Type_DeleteButton==m_type||Type_ButtonOn==m_type||Type_ButtonOff==m_type); m_byte = _buttonId; } - void SetNotification( uint8 const _noteId ){ assert(Type_Notification==m_type); m_byte = _noteId; } - - NotificationType m_type; - ValueID m_valueId; - uint8 m_byte; - }; - -} //namespace OpenZWave - -#endif //_Notification_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/Options.cpp b/lib/ESPiLight/pilight/libs/openzwave/Options.cpp deleted file mode 100644 index 45ab58d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Options.cpp +++ /dev/null @@ -1,603 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Options.h -// -// Program options read from XML files or the command line. -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include - -#include "Defs.h" -#include "Options.h" -#include "Utils.h" -#include "Manager.h" -#include "platform/Log.h" -#include "platform/FileOps.h" -#include "tinyxml.h" - -using namespace OpenZWave; - -Options* Options::s_instance = NULL; - -//----------------------------------------------------------------------------- -// -// Static method to create an Options object -//----------------------------------------------------------------------------- -Options* Options::Create -( - string const& _configPath, - string const& _userPath, - string const& _commandLine -) -{ - if( s_instance == NULL ) - { - string configPath = _configPath; - string userPath = _userPath; - - // Make sure a trailing path delimiter is present - if( configPath.size() > 0 && configPath[configPath.size() - 1] != '/' ) - { - configPath += "/"; - } - if( userPath.size() > 0 && userPath[userPath.size() - 1] != '/' ) - { - userPath += "/"; - } - - FileOps::Create(); - if( !FileOps::FolderExists( configPath ) ) - { - Log::Create( "", false, true, LogLevel_Debug, LogLevel_Debug, LogLevel_None ); - /* Try some default directories */ - if ( FileOps::FolderExists( "config/" ) ) - { - Log::Write( LogLevel_Error, "Cannot find a path to the configuration files at %s, Using config/ instead...", configPath.c_str() ); - configPath = "config/"; - } else if (FileOps::FolderExists("/etc/openzwave/" ) ) - { - Log::Write( LogLevel_Error, "Cannot find a path to the configuration files at %s, Using /etc/openzwave/ instead...", configPath.c_str() ); - configPath = "/etc/openzwave/"; -#ifdef SYSCONFDIR - } else if ( FileOps::FolderExists(SYSCONFDIR ) ) - { - Log::Write( LogLevel_Error, "Cannot find a path to the configuration files at %s, Using %s instead...", configPath.c_str(), SYSCONFDIR); - configPath = SYSCONFDIR; -#endif - } else { - Log::Write( LogLevel_Error, "Cannot find a path to the configuration files at %s. Exiting...", configPath.c_str() ); - exit( 1 ); - } - } - FileOps::Destroy(); - s_instance = new Options( configPath, userPath, _commandLine ); - - // Add the default options - s_instance->AddOptionString( "ConfigPath", configPath, false ); // Path to the OpenZWave config folder. - s_instance->AddOptionString( "UserPath", userPath, false ); // Path to the user's data folder. - - s_instance->AddOptionBool( "Logging", true ); // Enable logging of library activity. - s_instance->AddOptionString( "LogFileName", "OZW_Log.txt", false ); // Name of the log file (can be changed via Log::SetLogFileName) - s_instance->AddOptionBool( "AppendLogFile", false ); // Append new session logs to existing log file (false = overwrite) - s_instance->AddOptionBool( "ConsoleOutput", true ); // Display log information on console (as well as save to disk) - s_instance->AddOptionInt( "SaveLogLevel", LogLevel_Detail ); // Save (to file) log messages equal to or above LogLevel_Detail - s_instance->AddOptionInt( "QueueLogLevel", LogLevel_Debug ); // Save (in RAM) log messages equal to or above LogLevel_Debug - s_instance->AddOptionInt( "DumpTriggerLevel", LogLevel_None ); // Default is to never dump RAM-stored log messages - - s_instance->AddOptionBool( "Associate", true ); // Enable automatic association of the controller with group one of every device. - s_instance->AddOptionString( "Exclude", string(""), true ); // Remove support for the listed command classes. - s_instance->AddOptionString( "Include", string(""), true ); // Only handle the specified command classes. The Exclude option is ignored if anything is listed here. - s_instance->AddOptionBool( "NotifyTransactions", false ); // Notifications when transaction complete is reported. - s_instance->AddOptionString( "Interface", string(""), true ); // Identify the serial port to be accessed (TODO: change the code so more than one serial port can be specified and HID) - s_instance->AddOptionBool( "SaveConfiguration", true ); // Save the XML configuration upon driver close. - s_instance->AddOptionInt( "DriverMaxAttempts", 0); - - s_instance->AddOptionInt( "PollInterval", 30000); // 30 seconds (can easily poll 30 values in this time; ~120 values is the effective limit for 30 seconds) - s_instance->AddOptionBool( "IntervalBetweenPolls", false ); // if false, try to execute the entire poll list within the PollInterval time frame - // if true, wait for PollInterval milliseconds between polls - s_instance->AddOptionBool( "SuppressValueRefresh", false ); // if true, notifications for refreshed (but unchanged) values will not be sent - s_instance->AddOptionBool( "PerformReturnRoutes", true ); // if true, return routes will be updated - s_instance->AddOptionString( "NetworkKey", string(""), false); - s_instance->AddOptionBool( "RefreshAllUserCodes", false ); // if true, during startup, we refresh all the UserCodes the device reports it supports. If False, we stop after we get the first "Available" slot (Some devices have 250+ usercode slots! - That makes our Session Stage Very Long ) - s_instance->AddOptionInt( "RetryTimeout", RETRY_TIMEOUT); // How long do we wait to timeout messages sent - s_instance->AddOptionBool( "EnableSIS", true); // Automatically become a SUC if there is no SUC on the network. - s_instance->AddOptionBool( "AssumeAwake", true); // Assume Devices that Support the Wakeup CC are awake when we first query them.... - s_instance->AddOptionBool( "NotifyOnDriverUnload", false); // Should we send the Node/Value Notifications on Driver Unloading - Read comments in Driver::~Driver() method about possible race conditions - } - - return s_instance; -} - -//----------------------------------------------------------------------------- -// -// Static method to destroy an Options object -//----------------------------------------------------------------------------- -bool Options::Destroy -( -) -{ - if( Manager::Get() ) - { - // Cannot delete Options because Manager object still exists - assert(0); - return false; - } - - delete s_instance; - s_instance = NULL; - - return true; -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Options::Options -( - string const& _configPath, - string const& _userPath, - string const& _commandLine -): - m_xml ("options.xml"), - m_commandLine( _commandLine ), - m_SystemPath (_configPath), - m_LocalPath (_userPath), - m_locked( false ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Options::~Options -( -) -{ - // Clear the options map - while( !m_options.empty() ) - { - map::iterator it = m_options.begin(); - delete it->second; - m_options.erase( it ); - } -} - -//----------------------------------------------------------------------------- -// -// Add a boolean option. -//----------------------------------------------------------------------------- -bool Options::AddOptionBool -( - string const& _name, - bool const _value -) -{ - // get (or create) option - Option* option = AddOption( _name ); - - if (option == NULL) return false; - - // set unique option members - option->m_type = Options::OptionType_Bool; - option->m_valueBool = _value; - - // save in m_options map - string lowerName = ToLower( _name ); - m_options[lowerName] = option; - return true; -} - -//----------------------------------------------------------------------------- -// -// Add an integer option. -//----------------------------------------------------------------------------- -bool Options::AddOptionInt -( - string const& _name, - int32 const _value -) -{ - // get (or create) option - Option* option = AddOption( _name ); - - if (option == NULL) return false; - - // set unique option members - option->m_type = Options::OptionType_Int; - option->m_valueInt = _value; - - // save in m_options map - string lowerName = ToLower( _name ); - m_options[lowerName] = option; - return true; -} - -//----------------------------------------------------------------------------- -// -// Add a string option. -//----------------------------------------------------------------------------- -bool Options::AddOptionString -( - string const& _name, - string const& _value, - bool const _append -) -{ - // get (or create) option - Option* option = AddOption( _name ); - - if (option == NULL) return false; - - // set unique option members - option->m_type = Options::OptionType_String; - option->m_valueString = _value; - option->m_append = _append; - - // save in m_options map - string lowerName = ToLower( _name ); - m_options[lowerName] = option; - return true; -} - -//----------------------------------------------------------------------------- -// -// Get the value of a boolean option. -//----------------------------------------------------------------------------- -bool Options::GetOptionAsBool -( - string const& _name, - bool* o_value -) -{ - Option* option = Find( _name ); - if( o_value && option && ( OptionType_Bool == option->m_type ) ) - { - *o_value = option->m_valueBool; - return true; - } - - Log::Write( LogLevel_Warning, "Specified option [%s] was not found.", _name.c_str() ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Get the value of an integer option. -//----------------------------------------------------------------------------- -bool Options::GetOptionAsInt -( - string const& _name, - int32* o_value -) -{ - Option* option = Find( _name ); - if( o_value && option && ( OptionType_Int == option->m_type ) ) - { - *o_value = option->m_valueInt; - return true; - } - - Log::Write( LogLevel_Warning, "Specified option [%s] was not found.", _name.c_str() ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Get the value of a string option. -//----------------------------------------------------------------------------- -bool Options::GetOptionAsString -( - string const& _name, - string* o_value -) -{ - Option* option = Find( _name ); - if( o_value && option && ( OptionType_String == option->m_type ) ) - { - *o_value = option->m_valueString; - return true; - } - - Log::Write( LogLevel_Warning, "Specified option [%s] was not found.", _name.c_str() ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Get the type of value stored in an option. -//----------------------------------------------------------------------------- -Options::OptionType Options::GetOptionType -( - string const& _name -) -{ - Option* option = Find( _name ); - if( option ) - { - return option->m_type; - } - - // Option not found - Log::Write( LogLevel_Warning, "Specified option [%s] was not found.", _name.c_str() ); - return OptionType_Invalid; -} - -//----------------------------------------------------------------------------- -// -// Read all the option XMLs and Command Lines, and lock their values. -//----------------------------------------------------------------------------- -bool Options::Lock -( -) -{ - if( m_locked ) - { - Log::Write( LogLevel_Error, "Options are already final (locked)." ); - return false; - } - - ParseOptionsXML( m_SystemPath + m_xml ); - ParseOptionsXML( m_LocalPath + m_xml); - ParseOptionsString( m_commandLine ); - m_locked = true; - - return true; -} - -//----------------------------------------------------------------------------- -// -// Parse a string containing program options, such as a command line -//----------------------------------------------------------------------------- -bool Options::ParseOptionsString -( - string const& _commandLine -) -{ - bool res = true; - - size_t pos = 0; - size_t start = 0; - while( 1 ) - { - // find start of first option name - pos = _commandLine.find_first_of( "--", start ); - if( string::npos == pos ) - { - break; - } - start = pos + 2; - - // found an option. Get the name. - string optionName; - pos = _commandLine.find( " ", start ); - if( string::npos == pos ) - { - optionName = _commandLine.substr( start ); - start = pos; - } - else - { - optionName = _commandLine.substr( start, pos-start ); - start = pos + 1; - } - - // Find the matching option object - Option* option = Find( optionName ); - if( option ) - { - // Read the values - int numValues = 0; - bool parsing = true; - while( parsing ) - { - string value; - size_t back = start; - pos = _commandLine.find( " ", start ); - if( string::npos == pos ) - { - // Last value in string - value = _commandLine.substr( start ); - parsing = false; - start = pos; - } - else - { - value = _commandLine.substr( start, pos-start ); - start = pos+1; - } - - if( !value.compare( 0, 2, "--" ) ) - { - // Value is actually the next option. - if( !numValues ) - { - // No values were read for this option - // This is ok only for bool options, where we assume no value means "true". - if( OptionType_Bool == option->m_type ) - { - option->m_valueBool = true; - } - else - { - res = false; - } - } - start = back; // back up to the beginning of the next option - break; - } - else if( value.size() > 0 ) - { - // Set the value - option->SetValueFromString( value ); - numValues++; - } - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Parse an XML file containing program options -//----------------------------------------------------------------------------- -bool Options::ParseOptionsXML -( - string const& _filename -) -{ - TiXmlDocument doc; - if( !doc.LoadFile( _filename.c_str(), TIXML_ENCODING_UTF8 ) ) - { - Log::Write(LogLevel_Warning, "Failed to Parse %s: %s", _filename.c_str(), doc.ErrorDesc()); - return false; - } - Log::Write(LogLevel_Info, "Reading %s for Options", _filename.c_str()); - - TiXmlElement const* optionsElement = doc.RootElement(); - - // Read the options - TiXmlElement const* optionElement = optionsElement->FirstChildElement(); - while( optionElement ) - { - char const* str = optionElement->Value(); - if( str && !strcmp( str, "Option" ) ) - { - char const* name = optionElement->Attribute( "name" ); - if( name ) - { - Option* option = Find( name ); - if( option ) - { - char const* value = optionElement->Attribute( "value" ); - if( value ) - { - // Set the value - option->SetValueFromString( value ); - } - } - } - } - - optionElement = optionElement->NextSiblingElement(); - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// General setup for adding a specific option -//----------------------------------------------------------------------------- -Options::Option* Options::AddOption -( - string const& _name -) -{ - if( m_locked ) - { - Log::Write( LogLevel_Error, "Options have been locked. No more may be added." ); - return NULL; - } - - // get a pointer to the option (and create a new Option if it doesn't already exist) - Option* option = Find( _name ); - if( option == NULL ) - { - option = new Option( _name ); - } - - return option; -} - -//----------------------------------------------------------------------------- -// -// Find an option by name -//----------------------------------------------------------------------------- -Options::Option* Options::Find -( - string const& _name -) -{ - string lowername = ToLower( _name ); - map::iterator it = m_options.find( lowername ); - if( it != m_options.end() ) - { - return it->second; - } - - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Find an option by name -//----------------------------------------------------------------------------- -bool Options::Option::SetValueFromString -( - string const& _value -) -{ - if( OptionType_Bool == m_type ) - { - string lowerValue = ToLower( _value ); - if( ( lowerValue == "true" ) || ( lowerValue == "1" ) ) - { - m_valueBool = true; - return true; - } - - if( ( lowerValue == "false" ) || ( lowerValue == "0" ) ) - { - m_valueBool = false; - return true; - } - - return false; - } - - if( OptionType_Int == m_type ) - { - m_valueInt = (int32)atol( _value.c_str() ); - return true; - } - - if( OptionType_String == m_type ) - { - if( m_append && ( m_valueString.size() > 0 ) ) - { - m_valueString += ( string(",") + _value ); - } - else - { - m_valueString = _value; - } - return true; - } - - return false; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/Options.h b/lib/ESPiLight/pilight/libs/openzwave/Options.h deleted file mode 100644 index ffa02e6..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Options.h +++ /dev/null @@ -1,254 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Options.h -// -// Program options read from XML files or the command line. -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Options_H -#define _Options_H - -#include -#include -#include - -#include "Defs.h" - -namespace OpenZWave -{ - /** \brief Manages library options read from XML files or the command line. - * - * A class that manages program options read from XML files or the command line. - * The OpenZWave Manager class requires a complete and locked Options - * object when created. The Options are therefore one of the first things that - * any OpenZWave application must deal with. - * Options are first read from an XML file called options.xml located in the - * User data folder (the path to which is supplied to the Options::Create method). - * This is the same folder that will be used by the Manager to save the state of - * each controller in the Z-Wave network, to avoid querying them for their entire - * state every time the application starts up. - * The second source of program options is a string, which will normally be the - * command line used to launch the application. - * In this way, common options can be specified in the XML, but over-ridden if - * necessary by the command line. - * The Options process is as follows: - * 1) Create an Options object, providing paths to the OpenZWave config folder, - * the User data folder and any command line string containing program options. - * 2) Call Options::AddOptionBool, Options::AddOptionInt or Options::AddOptionString - * to add any application-specific configurable options. In this way, the Options - * class can be used for non-OpenZWave options as well. (OpenZWave options must - * be specified in step #1 above (either via xml file or a command line string). - * 3) Call Options::Lock. This will cause the option values to be read from - * the options.xml file and the command line string, and will lock the options - * so that no more calls aside from GetOptionAs may be made. - * 4) Create the OpenZWave Manager object. - */ - class OPENZWAVE_EXPORT Options - { - public: - enum OptionType - { - OptionType_Invalid = 0, - OptionType_Bool, - OptionType_Int, - OptionType_String - }; - - /** - * Creates an object to manage the program options. - * \param _configPath a string containing the path to the OpenZWave library config - * folder, which contains XML descriptions of Z-Wave manufacturers and products. - * \param _userPath a string containing the path to the application's user data - * folder where the OpenZWave should store the Z-Wave network configuration and state. - * The _userPath is also the folder where OpenZWave will look for the file Options.xml - * which contains program option values. The file should be in the form outlined below, - * with one or more Option elements containing a name and value attribute. Multiple - * values with the same option name should be listed separately. Note that option names - * are case insensitive. - * \code - * - * - * - * \endcode - * \param _commandLine a string containing the program's command line options. - * Command line options are parsed after the options.xml file, and so take precedence. - * Options are identified by a leading -- (two minus signs). The following items - * in the string are treated as values for this option, until the next -- is - * reached. For boolean options only, it is possible to omit the value, in which case - * the value is assumed to be "true". Note that option names are case insensitive, and - * that option values should be separated by a space. - * \return Pointer to the newly created Options object. - * \see Get, Destroy, AddOption, GetOptionAs, Lock - */ - static Options* Create( string const& _configPath, string const& _userPath, string const& _commandLine ); - - /** - * Deletes the Options and cleans up any associated objects. - * The application is responsible for destroying the Options object, - * but this must not be done until after the Manager object has been - * destroyed. - * \param _options Pointer to the Options object to be destroyed. - * \return true if the Options object was destroyed. If the manager - * object still exists, this call will return false. - * \see Create, Get - */ - static bool Destroy(); - - /** - * Gets a pointer to the Options singleton object. - * \return a pointer to the Options singleton object. - * \see Create, Destroy - */ - static Options* Get(){ return s_instance; } - - /** - * Locks the options. - * Reads in option values from the XML options file and command line string and - * marks the options as locked. Once locked, no more calls to AddOption - * can be made. - * The options must be locked before the Manager::Create method is called. - * \see AddOption - */ - bool Lock(); - - /** - * Add a boolean option to the program. - * Adds an option to the program whose value can then be read from a file or command line. - * All calls to AddOptionInt must be made before Lock. - * \param _name the name of the option. Option names are case insensitive and must be unique. - * \param _default the default value for this option. - * \see GetOptionAsBool - */ - bool AddOptionBool( string const& _name, bool const _default ); - - /** - * Add an integer option to the program. - * Adds an option to the program whose value can then be read from a file or command line. - * All calls to AddOptionInt must be made before Lock. - * \param _name the name of the option. Option names are case insensitive and must be unique. - * \param _default the default value for this option. - * \see GetOptionAsInt - */ - bool AddOptionInt( string const& _name, int32 const _default ); - - /** - * Add a string option to the program. - * Adds an option to the program whose value can then be read from a file or command line. - * All calls to AddOptionString must be made before Lock. - * \param _name the name of the option. Option names are case insensitive and must be unique. - * \param _default the default value for this option. - * \param _append Setting append to true will cause values read from the command line - * or XML file to be concatenated into a comma delimited list. If _append is false, - * newer values will overwrite older ones. - * \see GetOptionAsString - */ - bool AddOptionString( string const& _name, string const& _default, bool const _append ); - - /** - * Get the value of a boolean option. - * \param _name the name of the option. Option names are case insensitive. - * \param o_value a pointer to the item that will be filled with the option value. - * \return true if the option value was fetched successfully, false if the - * option does not exist, or does not contain a boolean value - * \see AddOptionBool, GetOptionType - */ - bool GetOptionAsBool( string const& _name, bool* o_value ); - - /** - * Get the value of an integer option. - * \param _name the name of the option. Option names are case insensitive. - * \param o_value a pointer to the item that will be filled with the option value. - * \return true if the option value was fetched successfully, false if the - * option does not exist, or does not contain an integer value - * \see AddOptionInt, GetOptionType - */ - bool GetOptionAsInt( string const& _name, int32* o_value ); - - /** - * Get the value of a string option. - * \param _name the name of the option. Option names are case insensitive. - * \param o_value a pointer to the item that will be filled with the option value. - * \return true if the option value was fetched successfully, false if the - * option does not exist, or does not contain a string value - * \see AddOptionString, GetOptionType - */ - bool GetOptionAsString( string const& _name, string* o_value ); - - /** - * Get the type of value stored in an option. - * \param _name the name of the option. Option names are case insensitive. - * \return An enum value representing the type of the option value. If the - * option does not exist, OptionType_Invalid is returned. - * \see GetOptionAsBool, GetOptionAsInt, GetOptionAsString - */ - OptionType GetOptionType( string const& _name ); - - /** - * Test whether the options have been locked. - * \return true if the options have been locked. - * \see Lock - */ - bool AreLocked()const{ return m_locked; } - - - private: - class Option - { - friend class Options; - - public: - Option( string const& _name ): m_name( _name ), m_append( false ){} - bool SetValueFromString( string const& _value ); - - Options::OptionType m_type; - string m_name; - bool m_valueBool; - int32 m_valueInt; - string m_valueString; - bool m_append; - }; - - Options( string const& _configPath, string const& _userPath, string const& _commandLine ); // Constructor, to be called only via the static Create method. - ~Options(); // Destructor, to be called only via the static Destroy method. - - bool ParseOptionsString( string const& _options ); // Parse a string containing program options, such as a command line. - bool ParseOptionsXML( string const& _filename ); // Parse an XML file containing program options. - Option* AddOption( string const& _name ); // check lock and create (or open existing) option - Option* Find( string const& _name ); - -OPENZWAVE_EXPORT_WARNINGS_OFF - map m_options; // Map of option names to values. -OPENZWAVE_EXPORT_WARNINGS_ON - string m_xml; // Path to XML options file. - string m_commandLine; // String containing command line options. - string m_SystemPath; - string m_LocalPath; - bool m_locked; // If true, the options are final and AddOption can no longer be called. - static Options* s_instance; - }; -} // namespace OpenZWave - -#endif // _Options_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/Scene.cpp b/lib/ESPiLight/pilight/libs/openzwave/Scene.cpp deleted file mode 100644 index e828ede..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Scene.cpp +++ /dev/null @@ -1,481 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Scene.cpp -// -// A collection of ValueIDs to be used together. -// -// Copyright (c) 2011 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include "Manager.h" -#include "platform/Log.h" -#include "value_classes/Value.h" -#include "value_classes/ValueID.h" -#include "Scene.h" -#include "Options.h" - -#include "tinyxml.h" - -using namespace OpenZWave; - -uint32 const c_sceneVersion = 1; - -//----------------------------------------------------------------------------- -// Statics -//----------------------------------------------------------------------------- -uint8 Scene::s_sceneCnt = 0; -Scene* Scene::s_scenes[256] = { 0 }; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Scene::Scene -( - uint8 const _sceneId -): - m_sceneId( _sceneId ), - m_label( "" ) -{ - s_scenes[_sceneId] = this; - s_sceneCnt++; -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Scene::~Scene -( -) -{ - while( !m_values.empty() ) - { - SceneStorage* ss = m_values.back(); - m_values.pop_back(); - delete ss; - } - - s_sceneCnt--; - s_scenes[m_sceneId] = NULL; -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void Scene::WriteXML -( - string const& _name -) -{ - char str[16]; - - // Create a new XML document to contain the driver configuration - TiXmlDocument doc; - TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" ); - TiXmlElement* scenesElement = new TiXmlElement( "Scenes" ); - doc.LinkEndChild( decl ); - doc.LinkEndChild( scenesElement ); - - scenesElement->SetAttribute( "xmlns", "http://code.google.com/p/open-zwave/" ); - - snprintf( str, sizeof(str), "%d", c_sceneVersion ); - scenesElement->SetAttribute( "version", str); - - for( int i = 1; i < 256; i++ ) - { - if( s_scenes[i] == NULL ) - { - continue; - } - - TiXmlElement* sceneElement = new TiXmlElement( "Scene" ); - - snprintf( str, sizeof(str), "%d", i ); - sceneElement->SetAttribute( "id", str ); - sceneElement->SetAttribute( "label", s_scenes[i]->m_label.c_str() ); - - for( vector::iterator vt = s_scenes[i]->m_values.begin(); vt != s_scenes[i]->m_values.end(); ++vt ) - { - TiXmlElement* valueElement = new TiXmlElement( "Value" ); - - snprintf( str, sizeof(str), "0x%.8x", (*vt)->m_id.GetHomeId() ); - valueElement->SetAttribute( "homeId", str ); - - snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetNodeId() ); - valueElement->SetAttribute( "nodeId", str ); - - valueElement->SetAttribute( "genre", Value::GetGenreNameFromEnum((*vt)->m_id.GetGenre()) ); - - snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetCommandClassId() ); - valueElement->SetAttribute( "commandClassId", str ); - - snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetInstance() ); - valueElement->SetAttribute( "instance", str ); - - snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetIndex() ); - valueElement->SetAttribute( "index", str ); - - valueElement->SetAttribute( "type", Value::GetTypeNameFromEnum((*vt)->m_id.GetType()) ); - - TiXmlText* textElement = new TiXmlText( (*vt)->m_value.c_str() ); - valueElement->LinkEndChild( textElement ); - - sceneElement->LinkEndChild( valueElement ); - } - - scenesElement->LinkEndChild( sceneElement ); - } - - string userPath; - Options::Get()->GetOptionAsString( "UserPath", &userPath ); - - string filename = userPath + _name; - - doc.SaveFile( filename.c_str() ); -} - -//----------------------------------------------------------------------------- -// -// Read scene configuration from an XML document -//----------------------------------------------------------------------------- -bool Scene::ReadScenes -( -) -{ - int32 intVal; - char const* str; - - // Load the XML document that contains the driver configuration - string userPath; - Options::Get()->GetOptionAsString( "UserPath", &userPath ); - - string filename = userPath + "zwscene.xml"; - - TiXmlDocument doc; - if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) - { - return false; - } - - TiXmlElement const* scenesElement = doc.RootElement(); - - // Version - if( TIXML_SUCCESS == scenesElement->QueryIntAttribute( "version", &intVal ) ) - { - if( (uint32)intVal != c_sceneVersion ) - { - Log::Write( LogLevel_Alert, "Driver::ReadScenes - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() ); - return false; - } - } - else - { - Log::Write( LogLevel_Alert, "Driver::ReadScenes - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() ); - return false; - } - - TiXmlElement const* sceneElement = scenesElement->FirstChildElement(); - while( sceneElement ) - { - Scene* scene = NULL; - - if( TIXML_SUCCESS == sceneElement->QueryIntAttribute( "id", &intVal ) ) - { - scene = new Scene( (uint8)intVal ); - } - - if( scene == NULL ) - { - continue; - } - - str = sceneElement->Attribute( "label" ); - if( str ) - { - scene->m_label = str; - } - - // Read the ValueId for this scene - TiXmlElement const* valueElement = sceneElement->FirstChildElement(); - while( valueElement ) - { - char const* elementName = valueElement->Value(); - if( elementName && !strcmp( elementName, "Value" ) ) - { - uint32 homeId = 0; - str = valueElement->Attribute( "homeId" ); - if( str ) - { - char *p; - homeId = (uint32)strtol( str, &p, 0 ); - } - uint8 nodeId = 0; - if (TIXML_SUCCESS == valueElement->QueryIntAttribute( "nodeId", &intVal ) ) - { - nodeId = intVal; - } - ValueID::ValueGenre genre = Value::GetGenreEnumFromName( valueElement->Attribute( "genre" ) ); - uint8 commandClassId = 0; - if (TIXML_SUCCESS == valueElement->QueryIntAttribute( "commandClassId", &intVal ) ) - { - commandClassId = intVal; - } - uint8 instance = 0; - if (TIXML_SUCCESS == valueElement->QueryIntAttribute( "instance", &intVal ) ) - { - instance = intVal; - } - uint8 index = 0; - if (TIXML_SUCCESS == valueElement->QueryIntAttribute( "index", &intVal ) ) - { - index = intVal; - } - ValueID::ValueType type = Value::GetTypeEnumFromName( valueElement->Attribute( "type" ) ); - char const* data = valueElement->GetText(); - - scene->m_values.push_back( new SceneStorage( ValueID(homeId, nodeId, genre, commandClassId, instance, index, type), data ) ); - } - - valueElement = valueElement->NextSiblingElement(); - } - sceneElement = sceneElement->NextSiblingElement(); - } - return true; -} - -//----------------------------------------------------------------------------- -// -// Return the Scene object given the Scene Id -//----------------------------------------------------------------------------- -Scene* Scene::Get -( - uint8 const _sceneId -) -{ - if ( s_scenes[_sceneId] != NULL ) - { - return s_scenes[_sceneId]; - } - return NULL; -} - -//----------------------------------------------------------------------------- -// -// Return an array of uint8 of used Scene IDs and the count -//----------------------------------------------------------------------------- -uint8 Scene::GetAllScenes -( - uint8** _sceneIds -) -{ - if( s_sceneCnt > 0 ) - { - *_sceneIds = new uint8[s_sceneCnt]; - int j = 0; - for( int i = 1; i < 256; i++ ) - { - if (s_scenes[i] != NULL) - { - (*_sceneIds)[j++] = s_scenes[i]->m_sceneId; - } - } - } - return s_sceneCnt; -} - -//----------------------------------------------------------------------------- -// -// Add a ValueID and a string to the scene. -//----------------------------------------------------------------------------- -bool Scene::AddValue -( - ValueID const& _valueId, - string const& _value -) -{ - m_values.push_back( new SceneStorage( _valueId, _value ) ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Remove the first ValueID found -//----------------------------------------------------------------------------- -bool Scene::RemoveValue -( - ValueID const& _valueId -) -{ - for( vector::iterator it = m_values.begin(); it != m_values.end(); ++it ) - { - if( (*it)->m_id == _valueId ) - { - delete *it; - m_values.erase( it ); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Remove all ValueIDs from given Home ID -//----------------------------------------------------------------------------- -void Scene::RemoveValues -( - uint32 const _homeId -) -{ - again: - for( vector::iterator it = m_values.begin(); it != m_values.end(); ++it ) - { - if( (*it)->m_id.GetHomeId() == _homeId ) - { - delete *it; - m_values.erase( it ); - goto again; - } - } - // If the scene is now empty, delete it. - if( m_values.empty() ) - { - delete this; - } -} - -//----------------------------------------------------------------------------- -// -// Remove all ValueIDs from given Home ID and node ID -//----------------------------------------------------------------------------- -void Scene::RemoveValues -( - uint32 const _homeId, - uint8 const _nodeId -) -{ - for( int i = 1; i < 256; i++ ) - { - Scene *scene = Scene::Get( i ); - if( scene != NULL ) - { - again: - for( vector::iterator it = scene->m_values.begin(); it != scene->m_values.end(); ++it ) - { - if( (*it)->m_id.GetHomeId() == _homeId && (*it)->m_id.GetNodeId() == _nodeId ) - { - delete *it; - scene->m_values.erase( it ); - goto again; - } - } - // If the scene is now empty, delete it. - if( scene->m_values.empty() ) - { - delete scene; - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Return all ValueIDs for the given scene. -//----------------------------------------------------------------------------- -int Scene::GetValues -( - vector* o_value -) -{ - int size = (int) m_values.size(); - if( size > 0 ) - { - for( vector::iterator it = m_values.begin(); it != m_values.end(); ++it ) - { - o_value->push_back( (*it)->m_id ); - } - } - return size; -} - -//----------------------------------------------------------------------------- -// -// Return a ValueID's value as string -//----------------------------------------------------------------------------- -bool Scene::GetValue -( - ValueID const& _valueId, - string* o_value -) -{ - for( vector::iterator it = m_values.begin(); it != m_values.end(); ++it ) - { - if( (*it)->m_id == _valueId ) - { - *o_value = (*it)->m_value; - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a ValueID's value as string -//----------------------------------------------------------------------------- -bool Scene::SetValue -( - ValueID const& _valueId, - string const& _value -) -{ - for( vector::iterator it = m_values.begin(); it != m_values.end(); ++it ) - { - if( (*it)->m_id == _valueId ) - { - (*it)->m_value = _value; - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Execute scene activation by running each ValueId/value -//----------------------------------------------------------------------------- -bool Scene::Activate -( -) -{ - bool res = true; - for( vector::iterator it = m_values.begin(); it != m_values.end(); ++it ) - { - if ( !Manager::Get()->SetValue( (*it)->m_id, (*it)->m_value ) ) - { - res = false; - } - } - return res; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/Scene.h b/lib/ESPiLight/pilight/libs/openzwave/Scene.h deleted file mode 100644 index 26739ea..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Scene.h +++ /dev/null @@ -1,105 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Scene.h -// -// A collection of ValueIDs to be used together. -// -// Copyright (c) 2011 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Scene_H -#define _Scene_H - -#include -#include - -#include "Defs.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class ValueID; - - /** \brief Collection of ValueIDs to be treated as a unit. - */ - class Scene - { - friend class Manager; - friend class Driver; - friend class Node; - - //----------------------------------------------------------------------------- - // Construction - //----------------------------------------------------------------------------- - private: - Scene( uint8 const _sceneId ); - ~Scene(); - - static void WriteXML( string const& _name ); - static bool ReadScenes(); - - //----------------------------------------------------------------------------- - // Scene functions - //----------------------------------------------------------------------------- - private: - static Scene* Get( uint8 const _sceneId ); - static uint8 GetAllScenes( uint8** _sceneIds ); - - string const& GetLabel()const{ return m_label; } - void SetLabel( string const &_label ){ m_label = _label; } - - bool AddValue( ValueID const& _valueId, string const& _value ); - bool RemoveValue( ValueID const& _valueId ); - void RemoveValues( uint32 const _homeId ); - static void RemoveValues( uint32 const _homeId, uint8 const _nodeId ); - int GetValues( vector* o_value ); - bool GetValue( ValueID const& _valueId, string* o_value ); - bool SetValue( ValueID const& _valueId, string const& _value ); - bool Activate(); - - //----------------------------------------------------------------------------- - // ValueID/value storage - //----------------------------------------------------------------------------- - private: - class SceneStorage - { - public: - SceneStorage( ValueID const& _id, string const& _value ): m_id( _id ), m_value( _value ) {}; - ~SceneStorage() {}; - - ValueID const m_id; - string m_value; - }; - //----------------------------------------------------------------------------- - // Member variables - //----------------------------------------------------------------------------- - private: - uint8 m_sceneId; - string m_label; - vector m_values; - static uint8 s_sceneCnt; - static Scene* s_scenes[256]; - }; - -} //namespace OpenZWave - -#endif //_Scene_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/Utils.cpp b/lib/ESPiLight/pilight/libs/openzwave/Utils.cpp deleted file mode 100644 index 466908c..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Utils.cpp +++ /dev/null @@ -1,116 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Utils.h -// -// Miscellaneous helper functions -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - - -#include "Defs.h" -#include "Utils.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Convert a string to all upper-case. -//----------------------------------------------------------------------------- -string OpenZWave::ToUpper -( - string const& _str -) -{ - string upper = _str; - transform( upper.begin(), upper.end(), upper.begin(), ::toupper ); - return upper; -} - -//----------------------------------------------------------------------------- -// -// Convert a string to all lower-case. -//----------------------------------------------------------------------------- -string OpenZWave::ToLower -( - string const& _str -) -{ - string lower = _str; - transform( lower.begin(), lower.end(), lower.begin(), ::tolower ); - return lower; -} - -//----------------------------------------------------------------------------- -// -// Remove WhiteSpaces from the begining and end of a string -//----------------------------------------------------------------------------- - -std::string &OpenZWave::trim -( - std::string &s -) -{ - if(s.size() == 0) - { - return s; - } - - int val = 0; - for (size_t cur = 0; cur < s.size(); cur++) - { - if(s[cur] != ' ' && isalnum(s[cur])) - { - s[val] = s[cur]; - val++; - } - } - s.resize(val); - return s; -} - -//----------------------------------------------------------------------------- -// -// Split a String into a vector, seperated by anything specified in seperators. -//----------------------------------------------------------------------------- -void OpenZWave::split -( - std::vector& lst, - const std::string& input, - const std::string& separators, - bool remove_empty -) -{ - std::ostringstream word; - for (size_t n = 0; n < input.size(); ++n) - { - if (std::string::npos == separators.find(input[n])) - word << input[n]; - else - { - if (!word.str().empty() || !remove_empty) - lst.push_back(word.str()); - word.str(""); - } - } - if (!word.str().empty() || !remove_empty) - lst.push_back(word.str()); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/Utils.h b/lib/ESPiLight/pilight/libs/openzwave/Utils.h deleted file mode 100644 index 76db22f..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/Utils.h +++ /dev/null @@ -1,76 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Utils.h -// -// Miscellaneous helper functions -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Utils_H -#define _Utils_H - -#include -#include -#include -#include -#include - -namespace OpenZWave -{ - /** - * Convert a string to all upper-case. - * \param _str the string to be converted. - * \return the upper-case string. - * \see ToLower, Trim - */ - string ToUpper( string const& _str ); - - /** - * Convert a string to all lower-case. - * \param _str the string to be converted. - * \return the lower-case string. - * \see ToUpper, Trim - */ - string ToLower( string const& _str ); - - /** - * Split a String into a Vector, seperated by seperators - * \param lst the vector to store the results in - * \param input the input string to split - * \param seperators a string containing a list of valid seperators - * \param remove_empty if after spliting a string, the any of the results are a empty string, should we preseve them or not - */ - void split (std::vector& lst, const std::string& input, const std::string& separators, bool remove_empty = true); - - /** - * Trim Whitespace from the start and end of a string. - * \param s the string to trim - * \return the trimmed string - */ - std::string &trim ( std::string &s ); - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/ZWaveCommandClasses.h b/lib/ESPiLight/pilight/libs/openzwave/ZWaveCommandClasses.h deleted file mode 100644 index cf59590..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/ZWaveCommandClasses.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _ZWAVE_COMMAND_CLASSES_H_ -#define _ZWAVE_COMMAND_CLASSES_H_ - -#define COMMAND_CLASS_NO_OPERATION 0x00 -#define COMMAND_CLASS_BASIC 0x20 -#define COMMAND_CLASS_CONTROLLER_REPLICATION 0x21 -#define COMMAND_CLASS_APPLICATION_STATUS 0x22 -#define COMMAND_CLASS_ZIP_SERVICES 0x23 -#define COMMAND_CLASS_ZIP_SERVER 0x24 -#define COMMAND_CLASS_SWITCH_BINARY 0x25 -#define COMMAND_CLASS_SWITCH_MULTILEVEL 0x26 -#define COMMAND_CLASS_SWITCH_ALL 0x27 -#define COMMAND_CLASS_SWITCH_TOGGLE_BINARY 0x28 -#define COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL 0x29 -#define COMMAND_CLASS_CHIMNEY_FAN 0x2A -#define COMMAND_CLASS_SCENE_ACTIVATION 0x2B -#define COMMAND_CLASS_SCENE_ACTUATOR_CONF 0x2C -#define COMMAND_CLASS_SCENE_CONTROLLER_CONF 0x2D -#define COMMAND_CLASS_ZIP_CLIENT 0x2E -#define COMMAND_CLASS_ZIP_ADV_SERVICES 0x2F -#define COMMAND_CLASS_SENSOR_BINARY 0x30 -#define COMMAND_CLASS_SENSOR_MULTILEVEL 0x31 -#define COMMAND_CLASS_METER 0x32 -#define COMMAND_CLASS_COLOR_CONTROL 0x33 -#define COMMAND_CLASS_ZIP_ADV_CLIENT 0x34 -#define COMMAND_CLASS_METER_PULSE 0x35 -#define COMMAND_CLASS_THERMOSTAT_HEATING 0x38 -#define COMMAND_CLASS_THERMOSTAT_MODE 0x40 -#define COMMAND_CLASS_THERMOSTAT_OPERATING_STATE 0x42 -#define COMMAND_CLASS_THERMOSTAT_SETPOINT 0x43 -#define COMMAND_CLASS_THERMOSTAT_FAN_MODE 0x44 -#define COMMAND_CLASS_THERMOSTAT_FAN_STATE 0x45 -#define COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE 0x46 -#define COMMAND_CLASS_THERMOSTAT_SETBACK 0x47 -#define COMMAND_CLASS_BASIC_WINDOW_COVERING 0x50 -#define COMMAND_CLASS_MTP_WINDOW_COVERING 0x51 -#define COMMAND_CLASS_MULTI_INSTANCE 0x60 -#define COMMAND_CLASS_DOOR_LOCK 0x62 -#define COMMAND_CLASS_USER_CODE 0x63 -#define COMMAND_CLASS_CONFIGURATION 0x70 -#define COMMAND_CLASS_ALARM 0x71 -#define COMMAND_CLASS_MANUFACTURER_SPECIFIC 0x72 -#define COMMAND_CLASS_POWERLEVEL 0x73 -#define COMMAND_CLASS_PROTECTION 0x75 -#define COMMAND_CLASS_LOCK 0x76 -#define COMMAND_CLASS_NODE_NAMING 0x77 -#define COMMAND_CLASS_FIRMWARE_UPDATE_MD 0x7A -#define COMMAND_CLASS_GROUPING_NAME 0x7B -#define COMMAND_CLASS_REMOTE_ASSOCIATION_ACTIVATE 0x7C -#define COMMAND_CLASS_REMOTE_ASSOCIATION 0x7D -#define COMMAND_CLASS_BATTERY 0x80 -#define COMMAND_CLASS_CLOCK 0x81 -#define COMMAND_CLASS_HAIL 0x82 -#define COMMAND_CLASS_WAKE_UP 0x84 -#define COMMAND_CLASS_ASSOCIATION 0x85 -#define COMMAND_CLASS_VERSION 0x86 -#define COMMAND_CLASS_INDICATOR 0x87 -#define COMMAND_CLASS_PROPRIETARY 0x88 -#define COMMAND_CLASS_LANGUAGE 0x89 -#define COMMAND_CLASS_TIME 0x8A -#define COMMAND_CLASS_TIME_PARAMETERS 0x8B -#define COMMAND_CLASS_GEOGRAPHIC_LOCATION 0x8C -#define COMMAND_CLASS_COMPOSITE 0x8D -#define COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION 0x8E -#define COMMAND_CLASS_MULTI_CMD 0x8F -#define COMMAND_CLASS_ENERGY_PRODUCTION 0x90 -#define COMMAND_CLASS_MANUFACTURER_PROPRIETARY 0x91 -#define COMMAND_CLASS_SCREEN_MD 0x92 -#define COMMAND_CLASS_SCREEN_ATTRIBUTES 0x93 -#define COMMAND_CLASS_SIMPLE_AV_CONTROL 0x94 -#define COMMAND_CLASS_AV_CONTENT_DIRECTORY_MD 0x95 -#define COMMAND_CLASS_AV_RENDERER_STATUS 0x96 -#define COMMAND_CLASS_AV_CONTENT_SEARCH_MD 0x97 -#define COMMAND_CLASS_SECURITY 0x98 -#define COMMAND_CLASS_AV_TAGGING_MD 0x99 -#define COMMAND_CLASS_IP_CONFIGURATION 0x9A -#define COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION 0x9B -#define COMMAND_CLASS_SENSOR_ALARM 0x9C -#define COMMAND_CLASS_SILENCE_ALARM 0x9D -#define COMMAND_CLASS_SENSOR_CONFIGURATION 0x9E -#define COMMAND_CLASS_NON_INTEROPERABLE 0xF0 - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/CMakeLists.txt b/lib/ESPiLight/pilight/libs/openzwave/aes/CMakeLists.txt deleted file mode 100644 index b529462..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -project(openzwave_aes) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aes.h b/lib/ESPiLight/pilight/libs/openzwave/aes/aes.h deleted file mode 100644 index 8835ebf..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aes.h +++ /dev/null @@ -1,203 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 - - This file contains the definitions required to use AES in C. See aesopt.h - for optimisation details. -*/ - -#ifndef _AES_H -#define _AES_H - -#include - -/* This include is used to find 8 & 32 bit unsigned integer types */ -#include "brg_types.h" - -#if defined(__cplusplus) -extern "C" -{ -#endif - -#define AES_128 /* if a fast 128 bit key scheduler is needed */ -#define AES_192 /* if a fast 192 bit key scheduler is needed */ -#define AES_256 /* if a fast 256 bit key scheduler is needed */ -#define AES_VAR /* if variable key size scheduler is needed */ -#define AES_MODES /* if support is needed for modes */ - -/* The following must also be set in assembler files if being used */ - -#define AES_ENCRYPT /* if support for encryption is needed */ -#define AES_DECRYPT /* if support for decryption is needed */ - -#define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ -#define N_COLS 4 /* the number of columns in the state */ - -/* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */ -/* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */ -/* or 44, 52 or 60 32-bit words. */ - -#if defined( AES_VAR ) || defined( AES_256 ) -#define KS_LENGTH 60 -#elif defined( AES_192 ) -#define KS_LENGTH 52 -#else -#define KS_LENGTH 44 -#endif - -#define AES_RETURN INT_RETURN - -/* the character array 'inf' in the following structures is used */ -/* to hold AES context information. This AES code uses cx->inf.b[0] */ -/* to hold the number of rounds multiplied by 16. The other three */ -/* elements can be used by code that implements additional modes */ - -typedef union -{ uint32_t l; - uint8_t b[4]; -} aes_inf; - -#ifdef _WIN64 -__declspec(align(16)) -#endif -typedef struct -{ uint32_t ks[KS_LENGTH]; - aes_inf inf; -} aes_encrypt_ctx; - -#ifdef _WIN64 -__declspec(align(16)) -#endif -typedef struct -{ uint32_t ks[KS_LENGTH]; - aes_inf inf; -} aes_decrypt_ctx; - -/* This routine must be called before first use if non-static */ -/* tables are being used */ - -AES_RETURN aes_init1(void); - -/* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */ -/* those in the range 128 <= key_len <= 256 are given in bits */ - -#if defined( AES_ENCRYPT ) - -#if defined( AES_128 ) || defined( AES_VAR) -AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); -#endif - -#if defined( AES_192 ) || defined( AES_VAR) -AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]); -#endif - -#if defined( AES_256 ) || defined( AES_VAR) -AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); -#endif - -#if defined( AES_VAR ) -AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]); -#endif - -AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); - -#endif - -#if defined( AES_DECRYPT ) - -#if defined( AES_128 ) || defined( AES_VAR) -AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); -#endif - -#if defined( AES_192 ) || defined( AES_VAR) -AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]); -#endif - -#if defined( AES_256 ) || defined( AES_VAR) -AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); -#endif - -#if defined( AES_VAR ) -AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]); -#endif - -AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); - -#endif - -#if defined( AES_MODES ) - -/* Multiple calls to the following subroutines for multiple block */ -/* ECB, CBC, CFB, OFB and CTR mode encryption can be used to handle */ -/* long messages incrementally provided that the context AND the iv */ -/* are preserved between all such calls. For the ECB and CBC modes */ -/* each individual call within a series of incremental calls must */ -/* process only full blocks (i.e. len must be a multiple of 16) but */ -/* the CFB, OFB and CTR mode calls can handle multiple incremental */ -/* calls of any length. Each mode is reset when a new AES key is */ -/* set but ECB and CBC operations can be reset without setting a */ -/* new key by setting a new IV value. To reset CFB, OFB and CTR */ -/* without setting the key, aes_mode_reset() must be called and the */ -/* IV must be set. NOTE: All these calls update the IV on exit so */ -/* this has to be reset if a new operation with the same IV as the */ -/* previous one is required (or decryption follows encryption with */ -/* the same IV array). */ - -AES_RETURN aes_test_alignment_detection(unsigned int n); - -AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, const aes_encrypt_ctx cx[1]); - -AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, const aes_decrypt_ctx cx[1]); - -AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, const aes_encrypt_ctx cx[1]); - -AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, const aes_decrypt_ctx cx[1]); - -AES_RETURN aes_mode_reset(aes_encrypt_ctx cx[1]); - -AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, aes_encrypt_ctx cx[1]); - -AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, aes_encrypt_ctx cx[1]); - -#define aes_ofb_encrypt aes_ofb_crypt -#define aes_ofb_decrypt aes_ofb_crypt - -AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, aes_encrypt_ctx cx[1]); - -typedef void cbuf_inc(unsigned char *cbuf); - -#define aes_ctr_encrypt aes_ctr_crypt -#define aes_ctr_decrypt aes_ctr_crypt - -AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]); - -#endif - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aes_modes.c b/lib/ESPiLight/pilight/libs/openzwave/aes/aes_modes.c deleted file mode 100644 index 42bc8d0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aes_modes.c +++ /dev/null @@ -1,947 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 - - These subroutines implement multiple block AES modes for ECB, CBC, CFB, - OFB and CTR encryption, The code provides support for the VIA Advanced - Cryptography Engine (ACE). - - NOTE: In the following subroutines, the AES contexts (ctx) must be - 16 byte aligned if VIA ACE is being used -*/ - -#include -#include -#include - -#include "aesopt.h" - -#if defined( AES_MODES ) -#if defined(__cplusplus) -extern "C" -{ -#endif - -#if defined( _WIN32 ) && ( _WIN32 > 800 ) -#pragma intrinsic(memcpy) -#endif - -#define BFR_BLOCKS 8 - -/* These values are used to detect long word alignment in order to */ -/* speed up some buffer operations. This facility may not work on */ -/* some machines so this define can be commented out if necessary */ - -#define FAST_BUFFER_OPERATIONS - -#define lp32(x) ((uint32_t*)(x)) - -#if defined( USE_VIA_ACE_IF_PRESENT ) - -#include "aes_via_ace.h" - -#pragma pack(16) - -aligned_array(unsigned long, enc_gen_table, 12, 16) = NEH_ENC_GEN_DATA; -aligned_array(unsigned long, enc_load_table, 12, 16) = NEH_ENC_LOAD_DATA; -aligned_array(unsigned long, enc_hybrid_table, 12, 16) = NEH_ENC_HYBRID_DATA; -aligned_array(unsigned long, dec_gen_table, 12, 16) = NEH_DEC_GEN_DATA; -aligned_array(unsigned long, dec_load_table, 12, 16) = NEH_DEC_LOAD_DATA; -aligned_array(unsigned long, dec_hybrid_table, 12, 16) = NEH_DEC_HYBRID_DATA; - -/* NOTE: These control word macros must only be used after */ -/* a key has been set up because they depend on key size */ -/* See the VIA ACE documentation for key type information */ -/* and aes_via_ace.h for non-default NEH_KEY_TYPE values */ - -#ifndef NEH_KEY_TYPE -# define NEH_KEY_TYPE NEH_HYBRID -#endif - -#if NEH_KEY_TYPE == NEH_LOAD -#define kd_adr(c) ((uint8_t*)(c)->ks) -#elif NEH_KEY_TYPE == NEH_GENERATE -#define kd_adr(c) ((uint8_t*)(c)->ks + (c)->inf.b[0]) -#elif NEH_KEY_TYPE == NEH_HYBRID -#define kd_adr(c) ((uint8_t*)(c)->ks + ((c)->inf.b[0] == 160 ? 160 : 0)) -#else -#error no key type defined for VIA ACE -#endif - -#else - -#define aligned_array(type, name, no, stride) type name[no] -#define aligned_auto(type, name, no, stride) type name[no] - -#endif - -#if defined( _WIN32 ) && _WIN32 > 1200 - -#define via_cwd(cwd, ty, dir, len) \ - unsigned long* cwd = (dir##_##ty##_table + ((len - 128) >> 4)) - -#else - -#define via_cwd(cwd, ty, dir, len) \ - aligned_auto(unsigned long, cwd, 4, 16); \ - cwd[1] = cwd[2] = cwd[3] = 0; \ - cwd[0] = neh_##dir##_##ty##_key(len) - -#endif - -/* test the code for detecting and setting pointer alignment */ - -AES_RETURN aes_test_alignment_detection(unsigned int n) /* 4 <= n <= 16 */ -{ uint8_t p[16]; - uint32_t i, count_eq = 0, count_neq = 0; - - if(n < 4 || n > 16) - return EXIT_FAILURE; - - for(i = 0; i < n; ++i) - { - uint8_t *qf = ALIGN_FLOOR(p + i, n), - *qh = ALIGN_CEIL(p + i, n); - - if(qh == qf) - ++count_eq; - else if(qh == qf + n) - ++count_neq; - else - return EXIT_FAILURE; - } - return (count_eq != 1 || count_neq != n - 1 ? EXIT_FAILURE : EXIT_SUCCESS); -} - -AES_RETURN aes_mode_reset(aes_encrypt_ctx ctx[1]) -{ - ctx->inf.b[2] = 0; - return EXIT_SUCCESS; -} - -AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, const aes_encrypt_ctx ctx[1]) -{ int nb = len >> 4; - - if(len & (AES_BLOCK_SIZE - 1)) - return EXIT_FAILURE; - -#if defined( USE_VIA_ACE_IF_PRESENT ) - - if(ctx->inf.b[1] == 0xff) - { uint8_t *ksp = (uint8_t*)(ctx->ks); - via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); - - if(ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; - - if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) - { - via_ecb_op5(ksp, cwd, ibuf, obuf, nb); - } - else - { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); - uint8_t *ip, *op; - - while(nb) - { - int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); - - ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); - op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); - - if(ip != ibuf) - memcpy(buf, ibuf, m * AES_BLOCK_SIZE); - - via_ecb_op5(ksp, cwd, ip, op, m); - - if(op != obuf) - memcpy(obuf, buf, m * AES_BLOCK_SIZE); - - ibuf += m * AES_BLOCK_SIZE; - obuf += m * AES_BLOCK_SIZE; - nb -= m; - } - } - - return EXIT_SUCCESS; - } - -#endif - -#if !defined( ASSUME_VIA_ACE_PRESENT ) - while(nb--) - { - if(aes_encrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } -#endif - return EXIT_SUCCESS; -} - -AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, const aes_decrypt_ctx ctx[1]) -{ int nb = len >> 4; - - if(len & (AES_BLOCK_SIZE - 1)) - return EXIT_FAILURE; - -#if defined( USE_VIA_ACE_IF_PRESENT ) - - if(ctx->inf.b[1] == 0xff) - { uint8_t *ksp = kd_adr(ctx); - via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); - - if(ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; - - if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) - { - via_ecb_op5(ksp, cwd, ibuf, obuf, nb); - } - else - { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); - uint8_t *ip, *op; - - while(nb) - { - int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); - - ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); - op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); - - if(ip != ibuf) - memcpy(buf, ibuf, m * AES_BLOCK_SIZE); - - via_ecb_op5(ksp, cwd, ip, op, m); - - if(op != obuf) - memcpy(obuf, buf, m * AES_BLOCK_SIZE); - - ibuf += m * AES_BLOCK_SIZE; - obuf += m * AES_BLOCK_SIZE; - nb -= m; - } - } - - return EXIT_SUCCESS; - } - -#endif - -#if !defined( ASSUME_VIA_ACE_PRESENT ) - while(nb--) - { - if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } -#endif - return EXIT_SUCCESS; -} - -AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, const aes_encrypt_ctx ctx[1]) -{ int nb = len >> 4; - - if(len & (AES_BLOCK_SIZE - 1)) - return EXIT_FAILURE; - -#if defined( USE_VIA_ACE_IF_PRESENT ) - - if(ctx->inf.b[1] == 0xff) - { uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; - aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); - via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); - - if(ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; - - if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ - { - ivp = liv; - memcpy(liv, iv, AES_BLOCK_SIZE); - } - - if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 ) && !ALIGN_OFFSET( iv, 16 )) - { - via_cbc_op7(ksp, cwd, ibuf, obuf, nb, ivp, ivp); - } - else - { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); - uint8_t *ip, *op; - - while(nb) - { - int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); - - ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); - op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); - - if(ip != ibuf) - memcpy(buf, ibuf, m * AES_BLOCK_SIZE); - - via_cbc_op7(ksp, cwd, ip, op, m, ivp, ivp); - - if(op != obuf) - memcpy(obuf, buf, m * AES_BLOCK_SIZE); - - ibuf += m * AES_BLOCK_SIZE; - obuf += m * AES_BLOCK_SIZE; - nb -= m; - } - } - - if(iv != ivp) - memcpy(iv, ivp, AES_BLOCK_SIZE); - - return EXIT_SUCCESS; - } - -#endif - -#if !defined( ASSUME_VIA_ACE_PRESENT ) -# ifdef FAST_BUFFER_OPERATIONS - if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) - while(nb--) - { - lp32(iv)[0] ^= lp32(ibuf)[0]; - lp32(iv)[1] ^= lp32(ibuf)[1]; - lp32(iv)[2] ^= lp32(ibuf)[2]; - lp32(iv)[3] ^= lp32(ibuf)[3]; - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - memcpy(obuf, iv, AES_BLOCK_SIZE); - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } - else -# endif - while(nb--) - { - iv[ 0] ^= ibuf[ 0]; iv[ 1] ^= ibuf[ 1]; - iv[ 2] ^= ibuf[ 2]; iv[ 3] ^= ibuf[ 3]; - iv[ 4] ^= ibuf[ 4]; iv[ 5] ^= ibuf[ 5]; - iv[ 6] ^= ibuf[ 6]; iv[ 7] ^= ibuf[ 7]; - iv[ 8] ^= ibuf[ 8]; iv[ 9] ^= ibuf[ 9]; - iv[10] ^= ibuf[10]; iv[11] ^= ibuf[11]; - iv[12] ^= ibuf[12]; iv[13] ^= ibuf[13]; - iv[14] ^= ibuf[14]; iv[15] ^= ibuf[15]; - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - memcpy(obuf, iv, AES_BLOCK_SIZE); - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } -#endif - return EXIT_SUCCESS; -} - -AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, const aes_decrypt_ctx ctx[1]) -{ unsigned char tmp[AES_BLOCK_SIZE]; - int nb = len >> 4; - - if(len & (AES_BLOCK_SIZE - 1)) - return EXIT_FAILURE; - -#if defined( USE_VIA_ACE_IF_PRESENT ) - - if(ctx->inf.b[1] == 0xff) - { uint8_t *ksp = kd_adr(ctx), *ivp = iv; - aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); - via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); - - if(ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; - - if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ - { - ivp = liv; - memcpy(liv, iv, AES_BLOCK_SIZE); - } - - if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 ) && !ALIGN_OFFSET( iv, 16 )) - { - via_cbc_op6(ksp, cwd, ibuf, obuf, nb, ivp); - } - else - { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); - uint8_t *ip, *op; - - while(nb) - { - int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); - - ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); - op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); - - if(ip != ibuf) - memcpy(buf, ibuf, m * AES_BLOCK_SIZE); - - via_cbc_op6(ksp, cwd, ip, op, m, ivp); - - if(op != obuf) - memcpy(obuf, buf, m * AES_BLOCK_SIZE); - - ibuf += m * AES_BLOCK_SIZE; - obuf += m * AES_BLOCK_SIZE; - nb -= m; - } - } - - if(iv != ivp) - memcpy(iv, ivp, AES_BLOCK_SIZE); - - return EXIT_SUCCESS; - } -#endif - -#if !defined( ASSUME_VIA_ACE_PRESENT ) -# ifdef FAST_BUFFER_OPERATIONS - if(!ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) - while(nb--) - { - memcpy(tmp, ibuf, AES_BLOCK_SIZE); - if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - lp32(obuf)[0] ^= lp32(iv)[0]; - lp32(obuf)[1] ^= lp32(iv)[1]; - lp32(obuf)[2] ^= lp32(iv)[2]; - lp32(obuf)[3] ^= lp32(iv)[3]; - memcpy(iv, tmp, AES_BLOCK_SIZE); - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } - else -# endif - while(nb--) - { - memcpy(tmp, ibuf, AES_BLOCK_SIZE); - if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - obuf[ 0] ^= iv[ 0]; obuf[ 1] ^= iv[ 1]; - obuf[ 2] ^= iv[ 2]; obuf[ 3] ^= iv[ 3]; - obuf[ 4] ^= iv[ 4]; obuf[ 5] ^= iv[ 5]; - obuf[ 6] ^= iv[ 6]; obuf[ 7] ^= iv[ 7]; - obuf[ 8] ^= iv[ 8]; obuf[ 9] ^= iv[ 9]; - obuf[10] ^= iv[10]; obuf[11] ^= iv[11]; - obuf[12] ^= iv[12]; obuf[13] ^= iv[13]; - obuf[14] ^= iv[14]; obuf[15] ^= iv[15]; - memcpy(iv, tmp, AES_BLOCK_SIZE); - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } -#endif - return EXIT_SUCCESS; -} - -AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) -{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; - - if(b_pos) /* complete any partial block */ - { - while(b_pos < AES_BLOCK_SIZE && cnt < len) - { - *obuf++ = (iv[b_pos++] ^= *ibuf++); - cnt++; - } - - b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); - } - - if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ - { -#if defined( USE_VIA_ACE_IF_PRESENT ) - - if(ctx->inf.b[1] == 0xff) - { int m; - uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; - aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); - via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); - - if(ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; - - if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ - { - ivp = liv; - memcpy(liv, iv, AES_BLOCK_SIZE); - } - - if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) - { - via_cfb_op7(ksp, cwd, ibuf, obuf, nb, ivp, ivp); - ibuf += nb * AES_BLOCK_SIZE; - obuf += nb * AES_BLOCK_SIZE; - cnt += nb * AES_BLOCK_SIZE; - } - else /* input, output or both are unaligned */ - { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); - uint8_t *ip, *op; - - while(nb) - { - m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; - - ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); - op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); - - if(ip != ibuf) - memcpy(buf, ibuf, m * AES_BLOCK_SIZE); - - via_cfb_op7(ksp, cwd, ip, op, m, ivp, ivp); - - if(op != obuf) - memcpy(obuf, buf, m * AES_BLOCK_SIZE); - - ibuf += m * AES_BLOCK_SIZE; - obuf += m * AES_BLOCK_SIZE; - cnt += m * AES_BLOCK_SIZE; - } - } - - if(ivp != iv) - memcpy(iv, ivp, AES_BLOCK_SIZE); - } -#else -# ifdef FAST_BUFFER_OPERATIONS - if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) - while(cnt + AES_BLOCK_SIZE <= len) - { - assert(b_pos == 0); - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - lp32(obuf)[0] = lp32(iv)[0] ^= lp32(ibuf)[0]; - lp32(obuf)[1] = lp32(iv)[1] ^= lp32(ibuf)[1]; - lp32(obuf)[2] = lp32(iv)[2] ^= lp32(ibuf)[2]; - lp32(obuf)[3] = lp32(iv)[3] ^= lp32(ibuf)[3]; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - cnt += AES_BLOCK_SIZE; - } - else -# endif - while(cnt + AES_BLOCK_SIZE <= len) - { - assert(b_pos == 0); - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - obuf[ 0] = iv[ 0] ^= ibuf[ 0]; obuf[ 1] = iv[ 1] ^= ibuf[ 1]; - obuf[ 2] = iv[ 2] ^= ibuf[ 2]; obuf[ 3] = iv[ 3] ^= ibuf[ 3]; - obuf[ 4] = iv[ 4] ^= ibuf[ 4]; obuf[ 5] = iv[ 5] ^= ibuf[ 5]; - obuf[ 6] = iv[ 6] ^= ibuf[ 6]; obuf[ 7] = iv[ 7] ^= ibuf[ 7]; - obuf[ 8] = iv[ 8] ^= ibuf[ 8]; obuf[ 9] = iv[ 9] ^= ibuf[ 9]; - obuf[10] = iv[10] ^= ibuf[10]; obuf[11] = iv[11] ^= ibuf[11]; - obuf[12] = iv[12] ^= ibuf[12]; obuf[13] = iv[13] ^= ibuf[13]; - obuf[14] = iv[14] ^= ibuf[14]; obuf[15] = iv[15] ^= ibuf[15]; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - cnt += AES_BLOCK_SIZE; - } -#endif - } - - while(cnt < len) - { - if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - - while(cnt < len && b_pos < AES_BLOCK_SIZE) - { - *obuf++ = (iv[b_pos++] ^= *ibuf++); - cnt++; - } - - b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); - } - - ctx->inf.b[2] = (uint8_t)b_pos; - return EXIT_SUCCESS; -} - -AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) -{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; - - if(b_pos) /* complete any partial block */ - { uint8_t t; - - while(b_pos < AES_BLOCK_SIZE && cnt < len) - { - t = *ibuf++; - *obuf++ = t ^ iv[b_pos]; - iv[b_pos++] = t; - cnt++; - } - - b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); - } - - if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ - { -#if defined( USE_VIA_ACE_IF_PRESENT ) - - if(ctx->inf.b[1] == 0xff) - { int m; - uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; - aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); - via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); - - if(ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; - - if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ - { - ivp = liv; - memcpy(liv, iv, AES_BLOCK_SIZE); - } - - if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) - { - via_cfb_op6(ksp, cwd, ibuf, obuf, nb, ivp); - ibuf += nb * AES_BLOCK_SIZE; - obuf += nb * AES_BLOCK_SIZE; - cnt += nb * AES_BLOCK_SIZE; - } - else /* input, output or both are unaligned */ - { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); - uint8_t *ip, *op; - - while(nb) - { - m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; - - ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); - op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); - - if(ip != ibuf) /* input buffer is not aligned */ - memcpy(buf, ibuf, m * AES_BLOCK_SIZE); - - via_cfb_op6(ksp, cwd, ip, op, m, ivp); - - if(op != obuf) /* output buffer is not aligned */ - memcpy(obuf, buf, m * AES_BLOCK_SIZE); - - ibuf += m * AES_BLOCK_SIZE; - obuf += m * AES_BLOCK_SIZE; - cnt += m * AES_BLOCK_SIZE; - } - } - - if(ivp != iv) - memcpy(iv, ivp, AES_BLOCK_SIZE); - } -#else -# ifdef FAST_BUFFER_OPERATIONS - if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) &&!ALIGN_OFFSET( iv, 4 )) - while(cnt + AES_BLOCK_SIZE <= len) - { uint32_t t; - - assert(b_pos == 0); - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - t = lp32(ibuf)[0], lp32(obuf)[0] = t ^ lp32(iv)[0], lp32(iv)[0] = t; - t = lp32(ibuf)[1], lp32(obuf)[1] = t ^ lp32(iv)[1], lp32(iv)[1] = t; - t = lp32(ibuf)[2], lp32(obuf)[2] = t ^ lp32(iv)[2], lp32(iv)[2] = t; - t = lp32(ibuf)[3], lp32(obuf)[3] = t ^ lp32(iv)[3], lp32(iv)[3] = t; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - cnt += AES_BLOCK_SIZE; - } - else -# endif - while(cnt + AES_BLOCK_SIZE <= len) - { uint8_t t; - - assert(b_pos == 0); - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - t = ibuf[ 0], obuf[ 0] = t ^ iv[ 0], iv[ 0] = t; - t = ibuf[ 1], obuf[ 1] = t ^ iv[ 1], iv[ 1] = t; - t = ibuf[ 2], obuf[ 2] = t ^ iv[ 2], iv[ 2] = t; - t = ibuf[ 3], obuf[ 3] = t ^ iv[ 3], iv[ 3] = t; - t = ibuf[ 4], obuf[ 4] = t ^ iv[ 4], iv[ 4] = t; - t = ibuf[ 5], obuf[ 5] = t ^ iv[ 5], iv[ 5] = t; - t = ibuf[ 6], obuf[ 6] = t ^ iv[ 6], iv[ 6] = t; - t = ibuf[ 7], obuf[ 7] = t ^ iv[ 7], iv[ 7] = t; - t = ibuf[ 8], obuf[ 8] = t ^ iv[ 8], iv[ 8] = t; - t = ibuf[ 9], obuf[ 9] = t ^ iv[ 9], iv[ 9] = t; - t = ibuf[10], obuf[10] = t ^ iv[10], iv[10] = t; - t = ibuf[11], obuf[11] = t ^ iv[11], iv[11] = t; - t = ibuf[12], obuf[12] = t ^ iv[12], iv[12] = t; - t = ibuf[13], obuf[13] = t ^ iv[13], iv[13] = t; - t = ibuf[14], obuf[14] = t ^ iv[14], iv[14] = t; - t = ibuf[15], obuf[15] = t ^ iv[15], iv[15] = t; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - cnt += AES_BLOCK_SIZE; - } -#endif - } - - while(cnt < len) - { uint8_t t; - - if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - - while(cnt < len && b_pos < AES_BLOCK_SIZE) - { - t = *ibuf++; - *obuf++ = t ^ iv[b_pos]; - iv[b_pos++] = t; - cnt++; - } - - b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); - } - - ctx->inf.b[2] = (uint8_t)b_pos; - return EXIT_SUCCESS; -} - -AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) -{ int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; - - if(b_pos) /* complete any partial block */ - { - while(b_pos < AES_BLOCK_SIZE && cnt < len) - { - *obuf++ = iv[b_pos++] ^ *ibuf++; - cnt++; - } - - b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); - } - - if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ - { -#if defined( USE_VIA_ACE_IF_PRESENT ) - - if(ctx->inf.b[1] == 0xff) - { int m; - uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; - aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); - via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); - - if(ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; - - if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ - { - ivp = liv; - memcpy(liv, iv, AES_BLOCK_SIZE); - } - - if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) - { - via_ofb_op6(ksp, cwd, ibuf, obuf, nb, ivp); - ibuf += nb * AES_BLOCK_SIZE; - obuf += nb * AES_BLOCK_SIZE; - cnt += nb * AES_BLOCK_SIZE; - } - else /* input, output or both are unaligned */ - { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); - uint8_t *ip, *op; - - while(nb) - { - m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; - - ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); - op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); - - if(ip != ibuf) - memcpy(buf, ibuf, m * AES_BLOCK_SIZE); - - via_ofb_op6(ksp, cwd, ip, op, m, ivp); - - if(op != obuf) - memcpy(obuf, buf, m * AES_BLOCK_SIZE); - - ibuf += m * AES_BLOCK_SIZE; - obuf += m * AES_BLOCK_SIZE; - cnt += m * AES_BLOCK_SIZE; - } - } - - if(ivp != iv) - memcpy(iv, ivp, AES_BLOCK_SIZE); - } -#else -# ifdef FAST_BUFFER_OPERATIONS - if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) - while(cnt + AES_BLOCK_SIZE <= len) - { - assert(b_pos == 0); - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - lp32(obuf)[0] = lp32(iv)[0] ^ lp32(ibuf)[0]; - lp32(obuf)[1] = lp32(iv)[1] ^ lp32(ibuf)[1]; - lp32(obuf)[2] = lp32(iv)[2] ^ lp32(ibuf)[2]; - lp32(obuf)[3] = lp32(iv)[3] ^ lp32(ibuf)[3]; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - cnt += AES_BLOCK_SIZE; - } - else -# endif - while(cnt + AES_BLOCK_SIZE <= len) - { - assert(b_pos == 0); - if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - obuf[ 0] = iv[ 0] ^ ibuf[ 0]; obuf[ 1] = iv[ 1] ^ ibuf[ 1]; - obuf[ 2] = iv[ 2] ^ ibuf[ 2]; obuf[ 3] = iv[ 3] ^ ibuf[ 3]; - obuf[ 4] = iv[ 4] ^ ibuf[ 4]; obuf[ 5] = iv[ 5] ^ ibuf[ 5]; - obuf[ 6] = iv[ 6] ^ ibuf[ 6]; obuf[ 7] = iv[ 7] ^ ibuf[ 7]; - obuf[ 8] = iv[ 8] ^ ibuf[ 8]; obuf[ 9] = iv[ 9] ^ ibuf[ 9]; - obuf[10] = iv[10] ^ ibuf[10]; obuf[11] = iv[11] ^ ibuf[11]; - obuf[12] = iv[12] ^ ibuf[12]; obuf[13] = iv[13] ^ ibuf[13]; - obuf[14] = iv[14] ^ ibuf[14]; obuf[15] = iv[15] ^ ibuf[15]; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - cnt += AES_BLOCK_SIZE; - } -#endif - } - - while(cnt < len) - { - if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - - while(cnt < len && b_pos < AES_BLOCK_SIZE) - { - *obuf++ = iv[b_pos++] ^ *ibuf++; - cnt++; - } - - b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); - } - - ctx->inf.b[2] = (uint8_t)b_pos; - return EXIT_SUCCESS; -} - -#define BFR_LENGTH (BFR_BLOCKS * AES_BLOCK_SIZE) - -AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf, - int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx ctx[1]) -{ unsigned char *ip; - int i, blen, b_pos = (int)(ctx->inf.b[2]); - -#if defined( USE_VIA_ACE_IF_PRESENT ) - aligned_auto(uint8_t, buf, BFR_LENGTH, 16); - if(ctx->inf.b[1] == 0xff && ALIGN_OFFSET( ctx, 16 )) - return EXIT_FAILURE; -#else - uint8_t buf[BFR_LENGTH]; -#endif - - if(b_pos) - { - memcpy(buf, cbuf, AES_BLOCK_SIZE); - if(aes_ecb_encrypt(buf, buf, AES_BLOCK_SIZE, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - - while(b_pos < AES_BLOCK_SIZE && len) - { - *obuf++ = *ibuf++ ^ buf[b_pos++]; - --len; - } - - if(len) - ctr_inc(cbuf), b_pos = 0; - } - - while(len) - { - blen = (len > BFR_LENGTH ? BFR_LENGTH : len), len -= blen; - - for(i = 0, ip = buf; i < (blen >> 4); ++i) - { - memcpy(ip, cbuf, AES_BLOCK_SIZE); - ctr_inc(cbuf); - ip += AES_BLOCK_SIZE; - } - - if(blen & (AES_BLOCK_SIZE - 1)) - memcpy(ip, cbuf, AES_BLOCK_SIZE), i++; - -#if defined( USE_VIA_ACE_IF_PRESENT ) - if(ctx->inf.b[1] == 0xff) - { - via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); - via_ecb_op5((ctx->ks), cwd, buf, buf, i); - } - else -#endif - if(aes_ecb_encrypt(buf, buf, i * AES_BLOCK_SIZE, ctx) != EXIT_SUCCESS) - return EXIT_FAILURE; - - i = 0; ip = buf; -# ifdef FAST_BUFFER_OPERATIONS - if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( ip, 4 )) - while(i + AES_BLOCK_SIZE <= blen) - { - lp32(obuf)[0] = lp32(ibuf)[0] ^ lp32(ip)[0]; - lp32(obuf)[1] = lp32(ibuf)[1] ^ lp32(ip)[1]; - lp32(obuf)[2] = lp32(ibuf)[2] ^ lp32(ip)[2]; - lp32(obuf)[3] = lp32(ibuf)[3] ^ lp32(ip)[3]; - i += AES_BLOCK_SIZE; - ip += AES_BLOCK_SIZE; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } - else -#endif - while(i + AES_BLOCK_SIZE <= blen) - { - obuf[ 0] = ibuf[ 0] ^ ip[ 0]; obuf[ 1] = ibuf[ 1] ^ ip[ 1]; - obuf[ 2] = ibuf[ 2] ^ ip[ 2]; obuf[ 3] = ibuf[ 3] ^ ip[ 3]; - obuf[ 4] = ibuf[ 4] ^ ip[ 4]; obuf[ 5] = ibuf[ 5] ^ ip[ 5]; - obuf[ 6] = ibuf[ 6] ^ ip[ 6]; obuf[ 7] = ibuf[ 7] ^ ip[ 7]; - obuf[ 8] = ibuf[ 8] ^ ip[ 8]; obuf[ 9] = ibuf[ 9] ^ ip[ 9]; - obuf[10] = ibuf[10] ^ ip[10]; obuf[11] = ibuf[11] ^ ip[11]; - obuf[12] = ibuf[12] ^ ip[12]; obuf[13] = ibuf[13] ^ ip[13]; - obuf[14] = ibuf[14] ^ ip[14]; obuf[15] = ibuf[15] ^ ip[15]; - i += AES_BLOCK_SIZE; - ip += AES_BLOCK_SIZE; - ibuf += AES_BLOCK_SIZE; - obuf += AES_BLOCK_SIZE; - } - - while(i++ < blen) - *obuf++ = *ibuf++ ^ ip[b_pos++]; - } - - ctx->inf.b[2] = (uint8_t)b_pos; - return EXIT_SUCCESS; -} - -#if defined(__cplusplus) -} -#endif -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aescpp.h b/lib/ESPiLight/pilight/libs/openzwave/aes/aescpp.h deleted file mode 100644 index 1ceefd7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aescpp.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 - - This file contains the definitions required to use AES (Rijndael) in C++. -*/ - -#ifndef _AESCPP_H -#define _AESCPP_H - -#include "aes.h" - -#if defined( AES_ENCRYPT ) - -class AESencrypt -{ -public: - aes_encrypt_ctx cx[1]; - AESencrypt(void) { aes_init1(); }; -#if defined(AES_128) - AESencrypt(const unsigned char key[]) - { aes_encrypt_key128(key, cx); } - AES_RETURN key128(const unsigned char key[]) - { return aes_encrypt_key128(key, cx); } -#endif -#if defined(AES_192) - AES_RETURN key192(const unsigned char key[]) - { return aes_encrypt_key192(key, cx); } -#endif -#if defined(AES_256) - AES_RETURN key256(const unsigned char key[]) - { return aes_encrypt_key256(key, cx); } -#endif -#if defined(AES_VAR) - AES_RETURN key(const unsigned char key[], int key_len) - { return aes_encrypt_key(key, key_len, cx); } -#endif - AES_RETURN encrypt(const unsigned char in[], unsigned char out[]) const - { return aes_encrypt(in, out, cx); } -#ifndef AES_MODES - AES_RETURN ecb_encrypt(const unsigned char in[], unsigned char out[], int nb) const - { while(nb--) - { aes_encrypt(in, out, cx), in += AES_BLOCK_SIZE, out += AES_BLOCK_SIZE; } - } -#endif -#ifdef AES_MODES - AES_RETURN mode_reset(void) { return aes_mode_reset(cx); } - - AES_RETURN ecb_encrypt(const unsigned char in[], unsigned char out[], int nb) const - { return aes_ecb_encrypt(in, out, nb, cx); } - - AES_RETURN cbc_encrypt(const unsigned char in[], unsigned char out[], int nb, - unsigned char iv[]) const - { return aes_cbc_encrypt(in, out, nb, iv, cx); } - - AES_RETURN cfb_encrypt(const unsigned char in[], unsigned char out[], int nb, - unsigned char iv[]) - { return aes_cfb_encrypt(in, out, nb, iv, cx); } - - AES_RETURN cfb_decrypt(const unsigned char in[], unsigned char out[], int nb, - unsigned char iv[]) - { return aes_cfb_decrypt(in, out, nb, iv, cx); } - - AES_RETURN ofb_crypt(const unsigned char in[], unsigned char out[], int nb, - unsigned char iv[]) - { return aes_ofb_crypt(in, out, nb, iv, cx); } - - typedef void ctr_fn(unsigned char ctr[]); - - AES_RETURN ctr_crypt(const unsigned char in[], unsigned char out[], int nb, - unsigned char iv[], ctr_fn cf) - { return aes_ctr_crypt(in, out, nb, iv, cf, cx); } - -#endif - -}; - -#endif - -#if defined( AES_DECRYPT ) - -class AESdecrypt -{ -public: - aes_decrypt_ctx cx[1]; - AESdecrypt(void) { aes_init1(); }; -#if defined(AES_128) - AESdecrypt(const unsigned char key[]) - { aes_decrypt_key128(key, cx); } - AES_RETURN key128(const unsigned char key[]) - { return aes_decrypt_key128(key, cx); } -#endif -#if defined(AES_192) - AES_RETURN key192(const unsigned char key[]) - { return aes_decrypt_key192(key, cx); } -#endif -#if defined(AES_256) - AES_RETURN key256(const unsigned char key[]) - { return aes_decrypt_key256(key, cx); } -#endif -#if defined(AES_VAR) - AES_RETURN key(const unsigned char key[], int key_len) - { return aes_decrypt_key(key, key_len, cx); } -#endif - AES_RETURN decrypt(const unsigned char in[], unsigned char out[]) const - { return aes_decrypt(in, out, cx); } -#ifndef AES_MODES - AES_RETURN ecb_decrypt(const unsigned char in[], unsigned char out[], int nb) const - { while(nb--) - { aes_decrypt(in, out, cx), in += AES_BLOCK_SIZE, out += AES_BLOCK_SIZE; } - } -#endif -#ifdef AES_MODES - - AES_RETURN ecb_decrypt(const unsigned char in[], unsigned char out[], int nb) const - { return aes_ecb_decrypt(in, out, nb, cx); } - - AES_RETURN cbc_decrypt(const unsigned char in[], unsigned char out[], int nb, - unsigned char iv[]) const - { return aes_cbc_decrypt(in, out, nb, iv, cx); } -#endif -}; - -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aescrypt.c b/lib/ESPiLight/pilight/libs/openzwave/aes/aescrypt.c deleted file mode 100644 index f1b70e3..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aescrypt.c +++ /dev/null @@ -1,301 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 -*/ - -#include "aesopt.h" -#include "aestab.h" - -#if defined( USE_INTEL_AES_IF_PRESENT ) -#include -#else -/* map names here to provide the external API ('name' -> 'aes_name') */ -# define aes_xi(x) aes_ ## x -#endif - -#if defined(__cplusplus) -extern "C" -{ -#endif - -#define si(y,x,k,c) (s(y,c) = word_in(x, c) ^ (k)[c]) -#define so(y,x,c) word_out(y, c, s(x,c)) - -#if defined(ARRAYS) -#define locals(y,x) x[4],y[4] -#else -#define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3 -#endif - -#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \ - s(y,2) = s(x,2); s(y,3) = s(x,3); -#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3) -#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3) -#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3) - -#if ( FUNCS_IN_C & ENCRYPTION_IN_C ) - -/* Visual C++ .Net v7.1 provides the fastest encryption code when using - Pentium optimiation with small code but this is poor for decryption - so we need to control this with the following VC++ pragmas -*/ - -#if defined( _WIN32 ) && !defined( _WIN64 ) -#pragma optimize( "s", on ) -#endif - -/* Given the column (c) of the output state variable, the following - macros give the input state variables which are needed in its - computation for each row (r) of the state. All the alternative - macros give the same end values but expand into different ways - of calculating these values. In particular the complex macro - used for dynamically variable block sizes is designed to expand - to a compile time constant whenever possible but will expand to - conditional clauses on some branches (I am grateful to Frank - Yellin for this construction) -*/ - -#define fwd_var(x,r,c)\ - ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ - : r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\ - : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ - : ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))) - -#if defined(FT4_SET) -#undef dec_fmvars -#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c)) -#elif defined(FT1_SET) -#undef dec_fmvars -#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(f,n),fwd_var,rf1,c)) -#else -#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ fwd_mcol(no_table(x,t_use(s,box),fwd_var,rf1,c))) -#endif - -#if defined(FL4_SET) -#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,l),fwd_var,rf1,c)) -#elif defined(FL1_SET) -#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(f,l),fwd_var,rf1,c)) -#else -#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c)) -#endif - -AES_RETURN aes_xi(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) -{ uint32_t locals(b0, b1); - const uint32_t *kp; -#if defined( dec_fmvars ) - dec_fmvars; /* declare variables for fwd_mcol() if needed */ -#endif - - if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16) - return EXIT_FAILURE; - - kp = cx->ks; - state_in(b0, in, kp); - -#if (ENC_UNROLL == FULL) - - switch(cx->inf.b[0]) - { - case 14 * 16: - round(fwd_rnd, b1, b0, kp + 1 * N_COLS); - round(fwd_rnd, b0, b1, kp + 2 * N_COLS); - kp += 2 * N_COLS; - case 12 * 16: - round(fwd_rnd, b1, b0, kp + 1 * N_COLS); - round(fwd_rnd, b0, b1, kp + 2 * N_COLS); - kp += 2 * N_COLS; - case 10 * 16: - round(fwd_rnd, b1, b0, kp + 1 * N_COLS); - round(fwd_rnd, b0, b1, kp + 2 * N_COLS); - round(fwd_rnd, b1, b0, kp + 3 * N_COLS); - round(fwd_rnd, b0, b1, kp + 4 * N_COLS); - round(fwd_rnd, b1, b0, kp + 5 * N_COLS); - round(fwd_rnd, b0, b1, kp + 6 * N_COLS); - round(fwd_rnd, b1, b0, kp + 7 * N_COLS); - round(fwd_rnd, b0, b1, kp + 8 * N_COLS); - round(fwd_rnd, b1, b0, kp + 9 * N_COLS); - round(fwd_lrnd, b0, b1, kp +10 * N_COLS); - } - -#else - -#if (ENC_UNROLL == PARTIAL) - { uint32_t rnd; - for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd) - { - kp += N_COLS; - round(fwd_rnd, b1, b0, kp); - kp += N_COLS; - round(fwd_rnd, b0, b1, kp); - } - kp += N_COLS; - round(fwd_rnd, b1, b0, kp); -#else - { uint32_t rnd; - for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd) - { - kp += N_COLS; - round(fwd_rnd, b1, b0, kp); - l_copy(b0, b1); - } -#endif - kp += N_COLS; - round(fwd_lrnd, b0, b1, kp); - } -#endif - - state_out(out, b0); - return EXIT_SUCCESS; -} - -#endif - -#if ( FUNCS_IN_C & DECRYPTION_IN_C) - -/* Visual C++ .Net v7.1 provides the fastest encryption code when using - Pentium optimiation with small code but this is poor for decryption - so we need to control this with the following VC++ pragmas -*/ - -#if defined( _WIN32 ) && !defined( _WIN64 ) -#pragma optimize( "t", on ) -#endif - -/* Given the column (c) of the output state variable, the following - macros give the input state variables which are needed in its - computation for each row (r) of the state. All the alternative - macros give the same end values but expand into different ways - of calculating these values. In particular the complex macro - used for dynamically variable block sizes is designed to expand - to a compile time constant whenever possible but will expand to - conditional clauses on some branches (I am grateful to Frank - Yellin for this construction) -*/ - -#define inv_var(x,r,c)\ - ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ - : r == 1 ? ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))\ - : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ - : ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))) - -#if defined(IT4_SET) -#undef dec_imvars -#define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,n),inv_var,rf1,c)) -#elif defined(IT1_SET) -#undef dec_imvars -#define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(i,n),inv_var,rf1,c)) -#else -#define inv_rnd(y,x,k,c) (s(y,c) = inv_mcol((k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c))) -#endif - -#if defined(IL4_SET) -#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,l),inv_var,rf1,c)) -#elif defined(IL1_SET) -#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(i,l),inv_var,rf1,c)) -#else -#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c)) -#endif - -/* This code can work with the decryption key schedule in the */ -/* order that is used for encrytpion (where the 1st decryption */ -/* round key is at the high end ot the schedule) or with a key */ -/* schedule that has been reversed to put the 1st decryption */ -/* round key at the low end of the schedule in memory (when */ -/* AES_REV_DKS is defined) */ - -#ifdef AES_REV_DKS -#define key_ofs 0 -#define rnd_key(n) (kp + n * N_COLS) -#else -#define key_ofs 1 -#define rnd_key(n) (kp - n * N_COLS) -#endif - -AES_RETURN aes_xi(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) -{ uint32_t locals(b0, b1); -#if defined( dec_imvars ) - dec_imvars; /* declare variables for inv_mcol() if needed */ -#endif - const uint32_t *kp; - - if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16) - return EXIT_FAILURE; - - kp = cx->ks + (key_ofs ? (cx->inf.b[0] >> 2) : 0); - state_in(b0, in, kp); - -#if (DEC_UNROLL == FULL) - - kp = cx->ks + (key_ofs ? 0 : (cx->inf.b[0] >> 2)); - switch(cx->inf.b[0]) - { - case 14 * 16: - round(inv_rnd, b1, b0, rnd_key(-13)); - round(inv_rnd, b0, b1, rnd_key(-12)); - case 12 * 16: - round(inv_rnd, b1, b0, rnd_key(-11)); - round(inv_rnd, b0, b1, rnd_key(-10)); - case 10 * 16: - round(inv_rnd, b1, b0, rnd_key(-9)); - round(inv_rnd, b0, b1, rnd_key(-8)); - round(inv_rnd, b1, b0, rnd_key(-7)); - round(inv_rnd, b0, b1, rnd_key(-6)); - round(inv_rnd, b1, b0, rnd_key(-5)); - round(inv_rnd, b0, b1, rnd_key(-4)); - round(inv_rnd, b1, b0, rnd_key(-3)); - round(inv_rnd, b0, b1, rnd_key(-2)); - round(inv_rnd, b1, b0, rnd_key(-1)); - round(inv_lrnd, b0, b1, rnd_key( 0)); - } - -#else - -#if (DEC_UNROLL == PARTIAL) - { uint32_t rnd; - for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd) - { - kp = rnd_key(1); - round(inv_rnd, b1, b0, kp); - kp = rnd_key(1); - round(inv_rnd, b0, b1, kp); - } - kp = rnd_key(1); - round(inv_rnd, b1, b0, kp); -#else - { uint32_t rnd; - for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd) - { - kp = rnd_key(1); - round(inv_rnd, b1, b0, kp); - l_copy(b0, b1); - } -#endif - kp = rnd_key(1); - round(inv_lrnd, b0, b1, kp); - } -#endif - - state_out(out, b0); - return EXIT_SUCCESS; -} - -#endif - -#if defined(__cplusplus) -} -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aeskey.c b/lib/ESPiLight/pilight/libs/openzwave/aes/aeskey.c deleted file mode 100644 index 16e9607..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aeskey.c +++ /dev/null @@ -1,554 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 -*/ - -#include "aesopt.h" -#include "aestab.h" - -#if defined( USE_INTEL_AES_IF_PRESENT ) -# include "aes_ni.h" -#else -/* map names here to provide the external API ('name' -> 'aes_name') */ -# define aes_xi(x) aes_ ## x -#endif - -#ifdef USE_VIA_ACE_IF_PRESENT -# include "aes_via_ace.h" -#endif - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/* Initialise the key schedule from the user supplied key. The key - length can be specified in bytes, with legal values of 16, 24 - and 32, or in bits, with legal values of 128, 192 and 256. These - values correspond with Nk values of 4, 6 and 8 respectively. - - The following macros implement a single cycle in the key - schedule generation process. The number of cycles needed - for each cx->n_col and nk value is: - - nk = 4 5 6 7 8 - ------------------------------ - cx->n_col = 4 10 9 8 7 7 - cx->n_col = 5 14 11 10 9 9 - cx->n_col = 6 19 15 12 11 11 - cx->n_col = 7 21 19 16 13 14 - cx->n_col = 8 29 23 19 17 14 -*/ - -#if defined( REDUCE_CODE_SIZE ) -# define ls_box ls_sub - uint32_t ls_sub(const uint32_t t, const uint32_t n); -# define inv_mcol im_sub - uint32_t im_sub(const uint32_t x); -# ifdef ENC_KS_UNROLL -# undef ENC_KS_UNROLL -# endif -# ifdef DEC_KS_UNROLL -# undef DEC_KS_UNROLL -# endif -#endif - -#if (FUNCS_IN_C & ENC_KEYING_IN_C) - -#if defined(AES_128) || defined( AES_VAR ) - -#define ke4(k,i) \ -{ k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \ - k[4*(i)+5] = ss[1] ^= ss[0]; \ - k[4*(i)+6] = ss[2] ^= ss[1]; \ - k[4*(i)+7] = ss[3] ^= ss[2]; \ -} - -AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1]) -{ uint32_t ss[4]; - - cx->ks[0] = ss[0] = word_in(key, 0); - cx->ks[1] = ss[1] = word_in(key, 1); - cx->ks[2] = ss[2] = word_in(key, 2); - cx->ks[3] = ss[3] = word_in(key, 3); - -#ifdef ENC_KS_UNROLL - ke4(cx->ks, 0); ke4(cx->ks, 1); - ke4(cx->ks, 2); ke4(cx->ks, 3); - ke4(cx->ks, 4); ke4(cx->ks, 5); - ke4(cx->ks, 6); ke4(cx->ks, 7); - ke4(cx->ks, 8); -#else - { uint32_t i; - for(i = 0; i < 9; ++i) - ke4(cx->ks, i); - } -#endif - ke4(cx->ks, 9); - cx->inf.l = 0; - cx->inf.b[0] = 10 * 16; - -#ifdef USE_VIA_ACE_IF_PRESENT - if(VIA_ACE_AVAILABLE) - cx->inf.b[1] = 0xff; -#endif - return EXIT_SUCCESS; -} - -#endif - -#if defined(AES_192) || defined( AES_VAR ) - -#define kef6(k,i) \ -{ k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \ - k[6*(i)+ 7] = ss[1] ^= ss[0]; \ - k[6*(i)+ 8] = ss[2] ^= ss[1]; \ - k[6*(i)+ 9] = ss[3] ^= ss[2]; \ -} - -#define ke6(k,i) \ -{ kef6(k,i); \ - k[6*(i)+10] = ss[4] ^= ss[3]; \ - k[6*(i)+11] = ss[5] ^= ss[4]; \ -} - -AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1]) -{ uint32_t ss[6]; - - cx->ks[0] = ss[0] = word_in(key, 0); - cx->ks[1] = ss[1] = word_in(key, 1); - cx->ks[2] = ss[2] = word_in(key, 2); - cx->ks[3] = ss[3] = word_in(key, 3); - cx->ks[4] = ss[4] = word_in(key, 4); - cx->ks[5] = ss[5] = word_in(key, 5); - -#ifdef ENC_KS_UNROLL - ke6(cx->ks, 0); ke6(cx->ks, 1); - ke6(cx->ks, 2); ke6(cx->ks, 3); - ke6(cx->ks, 4); ke6(cx->ks, 5); - ke6(cx->ks, 6); -#else - { uint32_t i; - for(i = 0; i < 7; ++i) - ke6(cx->ks, i); - } -#endif - kef6(cx->ks, 7); - cx->inf.l = 0; - cx->inf.b[0] = 12 * 16; - -#ifdef USE_VIA_ACE_IF_PRESENT - if(VIA_ACE_AVAILABLE) - cx->inf.b[1] = 0xff; -#endif - return EXIT_SUCCESS; -} - -#endif - -#if defined(AES_256) || defined( AES_VAR ) - -#define kef8(k,i) \ -{ k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \ - k[8*(i)+ 9] = ss[1] ^= ss[0]; \ - k[8*(i)+10] = ss[2] ^= ss[1]; \ - k[8*(i)+11] = ss[3] ^= ss[2]; \ -} - -#define ke8(k,i) \ -{ kef8(k,i); \ - k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0); \ - k[8*(i)+13] = ss[5] ^= ss[4]; \ - k[8*(i)+14] = ss[6] ^= ss[5]; \ - k[8*(i)+15] = ss[7] ^= ss[6]; \ -} - -AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1]) -{ uint32_t ss[8]; - - cx->ks[0] = ss[0] = word_in(key, 0); - cx->ks[1] = ss[1] = word_in(key, 1); - cx->ks[2] = ss[2] = word_in(key, 2); - cx->ks[3] = ss[3] = word_in(key, 3); - cx->ks[4] = ss[4] = word_in(key, 4); - cx->ks[5] = ss[5] = word_in(key, 5); - cx->ks[6] = ss[6] = word_in(key, 6); - cx->ks[7] = ss[7] = word_in(key, 7); - -#ifdef ENC_KS_UNROLL - ke8(cx->ks, 0); ke8(cx->ks, 1); - ke8(cx->ks, 2); ke8(cx->ks, 3); - ke8(cx->ks, 4); ke8(cx->ks, 5); -#else - { uint32_t i; - for(i = 0; i < 6; ++i) - ke8(cx->ks, i); - } -#endif - kef8(cx->ks, 6); - cx->inf.l = 0; - cx->inf.b[0] = 14 * 16; - -#ifdef USE_VIA_ACE_IF_PRESENT - if(VIA_ACE_AVAILABLE) - cx->inf.b[1] = 0xff; -#endif - return EXIT_SUCCESS; -} - -#endif - -#endif - -#if (FUNCS_IN_C & DEC_KEYING_IN_C) - -/* this is used to store the decryption round keys */ -/* in forward or reverse order */ - -#ifdef AES_REV_DKS -#define v(n,i) ((n) - (i) + 2 * ((i) & 3)) -#else -#define v(n,i) (i) -#endif - -#if DEC_ROUND == NO_TABLES -#define ff(x) (x) -#else -#define ff(x) inv_mcol(x) -#if defined( dec_imvars ) -#define d_vars dec_imvars -#endif -#endif - -#if defined(AES_128) || defined( AES_VAR ) - -#define k4e(k,i) \ -{ k[v(40,(4*(i))+4)] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \ - k[v(40,(4*(i))+5)] = ss[1] ^= ss[0]; \ - k[v(40,(4*(i))+6)] = ss[2] ^= ss[1]; \ - k[v(40,(4*(i))+7)] = ss[3] ^= ss[2]; \ -} - -#if 1 - -#define kdf4(k,i) \ -{ ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3]; \ - ss[1] = ss[1] ^ ss[3]; \ - ss[2] = ss[2] ^ ss[3]; \ - ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \ - ss[i % 4] ^= ss[4]; \ - ss[4] ^= k[v(40,(4*(i)))]; k[v(40,(4*(i))+4)] = ff(ss[4]); \ - ss[4] ^= k[v(40,(4*(i))+1)]; k[v(40,(4*(i))+5)] = ff(ss[4]); \ - ss[4] ^= k[v(40,(4*(i))+2)]; k[v(40,(4*(i))+6)] = ff(ss[4]); \ - ss[4] ^= k[v(40,(4*(i))+3)]; k[v(40,(4*(i))+7)] = ff(ss[4]); \ -} - -#define kd4(k,i) \ -{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \ - ss[i % 4] ^= ss[4]; ss[4] = ff(ss[4]); \ - k[v(40,(4*(i))+4)] = ss[4] ^= k[v(40,(4*(i)))]; \ - k[v(40,(4*(i))+5)] = ss[4] ^= k[v(40,(4*(i))+1)]; \ - k[v(40,(4*(i))+6)] = ss[4] ^= k[v(40,(4*(i))+2)]; \ - k[v(40,(4*(i))+7)] = ss[4] ^= k[v(40,(4*(i))+3)]; \ -} - -#define kdl4(k,i) \ -{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; ss[i % 4] ^= ss[4]; \ - k[v(40,(4*(i))+4)] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3]; \ - k[v(40,(4*(i))+5)] = ss[1] ^ ss[3]; \ - k[v(40,(4*(i))+6)] = ss[0]; \ - k[v(40,(4*(i))+7)] = ss[1]; \ -} - -#else - -#define kdf4(k,i) \ -{ ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ff(ss[0]); \ - ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ff(ss[1]); \ - ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ff(ss[2]); \ - ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ff(ss[3]); \ -} - -#define kd4(k,i) \ -{ ss[4] = ls_box(ss[3],3) ^ t_use(r,c)[i]; \ - ss[0] ^= ss[4]; ss[4] = ff(ss[4]); k[v(40,(4*(i))+ 4)] = ss[4] ^= k[v(40,(4*(i)))]; \ - ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[4] ^= k[v(40,(4*(i))+ 1)]; \ - ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[4] ^= k[v(40,(4*(i))+ 2)]; \ - ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[4] ^= k[v(40,(4*(i))+ 3)]; \ -} - -#define kdl4(k,i) \ -{ ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ss[0]; \ - ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[1]; \ - ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[2]; \ - ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[3]; \ -} - -#endif - -AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1]) -{ uint32_t ss[5]; -#if defined( d_vars ) - d_vars; -#endif - - cx->ks[v(40,(0))] = ss[0] = word_in(key, 0); - cx->ks[v(40,(1))] = ss[1] = word_in(key, 1); - cx->ks[v(40,(2))] = ss[2] = word_in(key, 2); - cx->ks[v(40,(3))] = ss[3] = word_in(key, 3); - -#ifdef DEC_KS_UNROLL - kdf4(cx->ks, 0); kd4(cx->ks, 1); - kd4(cx->ks, 2); kd4(cx->ks, 3); - kd4(cx->ks, 4); kd4(cx->ks, 5); - kd4(cx->ks, 6); kd4(cx->ks, 7); - kd4(cx->ks, 8); kdl4(cx->ks, 9); -#else - { uint32_t i; - for(i = 0; i < 10; ++i) - k4e(cx->ks, i); -#if !(DEC_ROUND == NO_TABLES) - for(i = N_COLS; i < 10 * N_COLS; ++i) - cx->ks[i] = inv_mcol(cx->ks[i]); -#endif - } -#endif - cx->inf.l = 0; - cx->inf.b[0] = 10 * 16; - -#ifdef USE_VIA_ACE_IF_PRESENT - if(VIA_ACE_AVAILABLE) - cx->inf.b[1] = 0xff; -#endif - return EXIT_SUCCESS; -} - -#endif - -#if defined(AES_192) || defined( AES_VAR ) - -#define k6ef(k,i) \ -{ k[v(48,(6*(i))+ 6)] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \ - k[v(48,(6*(i))+ 7)] = ss[1] ^= ss[0]; \ - k[v(48,(6*(i))+ 8)] = ss[2] ^= ss[1]; \ - k[v(48,(6*(i))+ 9)] = ss[3] ^= ss[2]; \ -} - -#define k6e(k,i) \ -{ k6ef(k,i); \ - k[v(48,(6*(i))+10)] = ss[4] ^= ss[3]; \ - k[v(48,(6*(i))+11)] = ss[5] ^= ss[4]; \ -} - -#define kdf6(k,i) \ -{ ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ff(ss[0]); \ - ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ff(ss[1]); \ - ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ff(ss[2]); \ - ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ff(ss[3]); \ - ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ff(ss[4]); \ - ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ff(ss[5]); \ -} - -#define kd6(k,i) \ -{ ss[6] = ls_box(ss[5],3) ^ t_use(r,c)[i]; \ - ss[0] ^= ss[6]; ss[6] = ff(ss[6]); k[v(48,(6*(i))+ 6)] = ss[6] ^= k[v(48,(6*(i)))]; \ - ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[6] ^= k[v(48,(6*(i))+ 1)]; \ - ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[6] ^= k[v(48,(6*(i))+ 2)]; \ - ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[6] ^= k[v(48,(6*(i))+ 3)]; \ - ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ss[6] ^= k[v(48,(6*(i))+ 4)]; \ - ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ss[6] ^= k[v(48,(6*(i))+ 5)]; \ -} - -#define kdl6(k,i) \ -{ ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ss[0]; \ - ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[1]; \ - ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[2]; \ - ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[3]; \ -} - -AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1]) -{ uint32_t ss[7]; -#if defined( d_vars ) - d_vars; -#endif - - cx->ks[v(48,(0))] = ss[0] = word_in(key, 0); - cx->ks[v(48,(1))] = ss[1] = word_in(key, 1); - cx->ks[v(48,(2))] = ss[2] = word_in(key, 2); - cx->ks[v(48,(3))] = ss[3] = word_in(key, 3); - -#ifdef DEC_KS_UNROLL - cx->ks[v(48,(4))] = ff(ss[4] = word_in(key, 4)); - cx->ks[v(48,(5))] = ff(ss[5] = word_in(key, 5)); - kdf6(cx->ks, 0); kd6(cx->ks, 1); - kd6(cx->ks, 2); kd6(cx->ks, 3); - kd6(cx->ks, 4); kd6(cx->ks, 5); - kd6(cx->ks, 6); kdl6(cx->ks, 7); -#else - cx->ks[v(48,(4))] = ss[4] = word_in(key, 4); - cx->ks[v(48,(5))] = ss[5] = word_in(key, 5); - { uint32_t i; - - for(i = 0; i < 7; ++i) - k6e(cx->ks, i); - k6ef(cx->ks, 7); -#if !(DEC_ROUND == NO_TABLES) - for(i = N_COLS; i < 12 * N_COLS; ++i) - cx->ks[i] = inv_mcol(cx->ks[i]); -#endif - } -#endif - cx->inf.l = 0; - cx->inf.b[0] = 12 * 16; - -#ifdef USE_VIA_ACE_IF_PRESENT - if(VIA_ACE_AVAILABLE) - cx->inf.b[1] = 0xff; -#endif - return EXIT_SUCCESS; -} - -#endif - -#if defined(AES_256) || defined( AES_VAR ) - -#define k8ef(k,i) \ -{ k[v(56,(8*(i))+ 8)] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \ - k[v(56,(8*(i))+ 9)] = ss[1] ^= ss[0]; \ - k[v(56,(8*(i))+10)] = ss[2] ^= ss[1]; \ - k[v(56,(8*(i))+11)] = ss[3] ^= ss[2]; \ -} - -#define k8e(k,i) \ -{ k8ef(k,i); \ - k[v(56,(8*(i))+12)] = ss[4] ^= ls_box(ss[3],0); \ - k[v(56,(8*(i))+13)] = ss[5] ^= ss[4]; \ - k[v(56,(8*(i))+14)] = ss[6] ^= ss[5]; \ - k[v(56,(8*(i))+15)] = ss[7] ^= ss[6]; \ -} - -#define kdf8(k,i) \ -{ ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ff(ss[0]); \ - ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ff(ss[1]); \ - ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ff(ss[2]); \ - ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ff(ss[3]); \ - ss[4] ^= ls_box(ss[3],0); k[v(56,(8*(i))+12)] = ff(ss[4]); \ - ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ff(ss[5]); \ - ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ff(ss[6]); \ - ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ff(ss[7]); \ -} - -#define kd8(k,i) \ -{ ss[8] = ls_box(ss[7],3) ^ t_use(r,c)[i]; \ - ss[0] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+ 8)] = ss[8] ^= k[v(56,(8*(i)))]; \ - ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[8] ^= k[v(56,(8*(i))+ 1)]; \ - ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[8] ^= k[v(56,(8*(i))+ 2)]; \ - ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[8] ^= k[v(56,(8*(i))+ 3)]; \ - ss[8] = ls_box(ss[3],0); \ - ss[4] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+12)] = ss[8] ^= k[v(56,(8*(i))+ 4)]; \ - ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ss[8] ^= k[v(56,(8*(i))+ 5)]; \ - ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ss[8] ^= k[v(56,(8*(i))+ 6)]; \ - ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ss[8] ^= k[v(56,(8*(i))+ 7)]; \ -} - -#define kdl8(k,i) \ -{ ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ss[0]; \ - ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[1]; \ - ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[2]; \ - ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[3]; \ -} - -AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1]) -{ uint32_t ss[9]; -#if defined( d_vars ) - d_vars; -#endif - - cx->ks[v(56,(0))] = ss[0] = word_in(key, 0); - cx->ks[v(56,(1))] = ss[1] = word_in(key, 1); - cx->ks[v(56,(2))] = ss[2] = word_in(key, 2); - cx->ks[v(56,(3))] = ss[3] = word_in(key, 3); - -#ifdef DEC_KS_UNROLL - cx->ks[v(56,(4))] = ff(ss[4] = word_in(key, 4)); - cx->ks[v(56,(5))] = ff(ss[5] = word_in(key, 5)); - cx->ks[v(56,(6))] = ff(ss[6] = word_in(key, 6)); - cx->ks[v(56,(7))] = ff(ss[7] = word_in(key, 7)); - kdf8(cx->ks, 0); kd8(cx->ks, 1); - kd8(cx->ks, 2); kd8(cx->ks, 3); - kd8(cx->ks, 4); kd8(cx->ks, 5); - kdl8(cx->ks, 6); -#else - cx->ks[v(56,(4))] = ss[4] = word_in(key, 4); - cx->ks[v(56,(5))] = ss[5] = word_in(key, 5); - cx->ks[v(56,(6))] = ss[6] = word_in(key, 6); - cx->ks[v(56,(7))] = ss[7] = word_in(key, 7); - { uint32_t i; - - for(i = 0; i < 6; ++i) - k8e(cx->ks, i); - k8ef(cx->ks, 6); -#if !(DEC_ROUND == NO_TABLES) - for(i = N_COLS; i < 14 * N_COLS; ++i) - cx->ks[i] = inv_mcol(cx->ks[i]); -#endif - } -#endif - cx->inf.l = 0; - cx->inf.b[0] = 14 * 16; - -#ifdef USE_VIA_ACE_IF_PRESENT - if(VIA_ACE_AVAILABLE) - cx->inf.b[1] = 0xff; -#endif - return EXIT_SUCCESS; -} - -#endif - -#endif - -#if defined( AES_VAR ) - -AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]) -{ - switch(key_len) - { - case 16: case 128: return aes_encrypt_key128(key, cx); - case 24: case 192: return aes_encrypt_key192(key, cx); - case 32: case 256: return aes_encrypt_key256(key, cx); - default: return EXIT_FAILURE; - } -} - -AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]) -{ - switch(key_len) - { - case 16: case 128: return aes_decrypt_key128(key, cx); - case 24: case 192: return aes_decrypt_key192(key, cx); - case 32: case 256: return aes_decrypt_key256(key, cx); - default: return EXIT_FAILURE; - } -} - -#endif - -#if defined(__cplusplus) -} -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aesopt.h b/lib/ESPiLight/pilight/libs/openzwave/aes/aesopt.h deleted file mode 100644 index 715fa93..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aesopt.h +++ /dev/null @@ -1,769 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 - - This file contains the compilation options for AES (Rijndael) and code - that is common across encryption, key scheduling and table generation. - - OPERATION - - These source code files implement the AES algorithm Rijndael designed by - Joan Daemen and Vincent Rijmen. This version is designed for the standard - block size of 16 bytes and for key sizes of 128, 192 and 256 bits (16, 24 - and 32 bytes). - - This version is designed for flexibility and speed using operations on - 32-bit words rather than operations on bytes. It can be compiled with - either big or little endian internal byte order but is faster when the - native byte order for the processor is used. - - THE CIPHER INTERFACE - - The cipher interface is implemented as an array of bytes in which lower - AES bit sequence indexes map to higher numeric significance within bytes. - - uint8_t (an unsigned 8-bit type) - uint32_t (an unsigned 32-bit type) - struct aes_encrypt_ctx (structure for the cipher encryption context) - struct aes_decrypt_ctx (structure for the cipher decryption context) - AES_RETURN the function return type - - C subroutine calls: - - AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); - AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]); - AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); - AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, - const aes_encrypt_ctx cx[1]); - - AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); - AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]); - AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); - AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, - const aes_decrypt_ctx cx[1]); - - IMPORTANT NOTE: If you are using this C interface with dynamic tables make sure that - you call aes_init() before AES is used so that the tables are initialised. - - C++ aes class subroutines: - - Class AESencrypt for encryption - - Construtors: - AESencrypt(void) - AESencrypt(const unsigned char *key) - 128 bit key - Members: - AES_RETURN key128(const unsigned char *key) - AES_RETURN key192(const unsigned char *key) - AES_RETURN key256(const unsigned char *key) - AES_RETURN encrypt(const unsigned char *in, unsigned char *out) const - - Class AESdecrypt for encryption - Construtors: - AESdecrypt(void) - AESdecrypt(const unsigned char *key) - 128 bit key - Members: - AES_RETURN key128(const unsigned char *key) - AES_RETURN key192(const unsigned char *key) - AES_RETURN key256(const unsigned char *key) - AES_RETURN decrypt(const unsigned char *in, unsigned char *out) const -*/ - -#if !defined( _AESOPT_H ) -#define _AESOPT_H - -#if defined( __cplusplus ) -#include "aescpp.h" -#else -#include "aes.h" -#endif - -/* PLATFORM SPECIFIC INCLUDES */ - -#include "brg_endian.h" - -/* CONFIGURATION - THE USE OF DEFINES - - Later in this section there are a number of defines that control the - operation of the code. In each section, the purpose of each define is - explained so that the relevant form can be included or excluded by - setting either 1's or 0's respectively on the branches of the related - #if clauses. The following local defines should not be changed. -*/ - -#define ENCRYPTION_IN_C 1 -#define DECRYPTION_IN_C 2 -#define ENC_KEYING_IN_C 4 -#define DEC_KEYING_IN_C 8 - -#define NO_TABLES 0 -#define ONE_TABLE 1 -#define FOUR_TABLES 4 -#define NONE 0 -#define PARTIAL 1 -#define FULL 2 - -/* --- START OF USER CONFIGURED OPTIONS --- */ - -/* 1. BYTE ORDER WITHIN 32 BIT WORDS - - The fundamental data processing units in Rijndael are 8-bit bytes. The - input, output and key input are all enumerated arrays of bytes in which - bytes are numbered starting at zero and increasing to one less than the - number of bytes in the array in question. This enumeration is only used - for naming bytes and does not imply any adjacency or order relationship - from one byte to another. When these inputs and outputs are considered - as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to - byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte. - In this implementation bits are numbered from 0 to 7 starting at the - numerically least significant end of each byte (bit n represents 2^n). - - However, Rijndael can be implemented more efficiently using 32-bit - words by packing bytes into words so that bytes 4*n to 4*n+3 are placed - into word[n]. While in principle these bytes can be assembled into words - in any positions, this implementation only supports the two formats in - which bytes in adjacent positions within words also have adjacent byte - numbers. This order is called big-endian if the lowest numbered bytes - in words have the highest numeric significance and little-endian if the - opposite applies. - - This code can work in either order irrespective of the order used by the - machine on which it runs. Normally the internal byte order will be set - to the order of the processor on which the code is to be run but this - define can be used to reverse this in special situations - - WARNING: Assembler code versions rely on PLATFORM_BYTE_ORDER being set. - This define will hence be redefined later (in section 4) if necessary -*/ - -#if 1 -# define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER -#elif 0 -# define ALGORITHM_BYTE_ORDER IS_LITTLE_ENDIAN -#elif 0 -# define ALGORITHM_BYTE_ORDER IS_BIG_ENDIAN -#else -# error The algorithm byte order is not defined -#endif - -/* 2. Intel AES AND VIA ACE SUPPORT */ - -#if defined( __GNUC__ ) && defined( __i386__ ) \ - || defined(_WIN32) && defined(_M_IX86) \ - && !(defined(_WIN64) || defined(_WIN32_WCE) || defined(_WIN32) && (_WIN32 <= 800)) -# define VIA_ACE_POSSIBLE -#endif - -/* Define this option if support for the Intel AESNI is required (not - currently available with GCC). If AESNI is known to be present, then - defining ASSUME_INTEL_AES_VIA_PRESENT will replace the ordinary - encryption/decryption. If USE_INTEL_AES_IF_PRESENT is defined then - AESNI will be used if it is detected (both present and enabled). - - AESNI uses a decryption key schedule with the first decryption - round key at the high end of the key scedule with the following - round keys at lower positions in memory. So AES_REV_DKS must NOT - be defined when AESNI will be used. ALthough it is unlikely that - assembler code will be used with an AESNI build, if it is then - AES_REV_DKS must NOT be defined when such assembler files are - built -*/ -#if 0 && defined( _WIN64 ) && defined( _WIN32 ) -# define INTEL_AES_POSSIBLE -#endif - -#if defined( INTEL_AES_POSSIBLE ) && !defined( USE_INTEL_AES_IF_PRESENT ) -# define USE_INTEL_AES_IF_PRESENT -#endif - -/* Define this option if support for the VIA ACE is required. This uses - inline assembler instructions and is only implemented for the Microsoft, - Intel and GCC compilers. If VIA ACE is known to be present, then defining - ASSUME_VIA_ACE_PRESENT will remove the ordinary encryption/decryption - code. If USE_VIA_ACE_IF_PRESENT is defined then VIA ACE will be used if - it is detected (both present and enabled) but the normal AES code will - also be present. - - When VIA ACE is to be used, all AES encryption contexts MUST be 16 byte - aligned; other input/output buffers do not need to be 16 byte aligned - but there are very large performance gains if this can be arranged. - VIA ACE also requires the decryption key schedule to be in reverse - order (which later checks below ensure). - - AES_REV_DKS must be set for assembler code used with a VIA ACE build -*/ - -#if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( USE_VIA_ACE_IF_PRESENT ) -# define USE_VIA_ACE_IF_PRESENT -#endif - -#if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( ASSUME_VIA_ACE_PRESENT ) -# define ASSUME_VIA_ACE_PRESENT -# endif - -/* 3. ASSEMBLER SUPPORT - - This define (which can be on the command line) enables the use of the - assembler code routines for encryption, decryption and key scheduling - as follows: - - ASM_X86_V1C uses the assembler (aes_x86_v1.asm) with large tables for - encryption and decryption and but with key scheduling in C - ASM_X86_V2 uses assembler (aes_x86_v2.asm) with compressed tables for - encryption, decryption and key scheduling - ASM_X86_V2C uses assembler (aes_x86_v2.asm) with compressed tables for - encryption and decryption and but with key scheduling in C - ASM_AMD64_C uses assembler (aes_amd64.asm) with compressed tables for - encryption and decryption and but with key scheduling in C - - Change one 'if 0' below to 'if 1' to select the version or define - as a compilation option. -*/ - -#if 0 && !defined( ASM_X86_V1C ) -# define ASM_X86_V1C -#elif 0 && !defined( ASM_X86_V2 ) -# define ASM_X86_V2 -#elif 0 && !defined( ASM_X86_V2C ) -# define ASM_X86_V2C -#elif 0 && !defined( ASM_AMD64_C ) -# define ASM_AMD64_C -#endif - -#if (defined ( ASM_X86_V1C ) || defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) \ - && !defined( _M_IX86 ) || defined( ASM_AMD64_C ) && !defined( _M_X64 ) -# error Assembler code is only available for x86 and AMD64 systems -#endif - -/* 4. FAST INPUT/OUTPUT OPERATIONS. - - On some machines it is possible to improve speed by transferring the - bytes in the input and output arrays to and from the internal 32-bit - variables by addressing these arrays as if they are arrays of 32-bit - words. On some machines this will always be possible but there may - be a large performance penalty if the byte arrays are not aligned on - the normal word boundaries. On other machines this technique will - lead to memory access errors when such 32-bit word accesses are not - properly aligned. The option SAFE_IO avoids such problems but will - often be slower on those machines that support misaligned access - (especially so if care is taken to align the input and output byte - arrays on 32-bit word boundaries). If SAFE_IO is not defined it is - assumed that access to byte arrays as if they are arrays of 32-bit - words will not cause problems when such accesses are misaligned. -*/ -#if 1 && !defined( _WIN32 ) -# define SAFE_IO -#endif - -/* 5. LOOP UNROLLING - - The code for encryption and decrytpion cycles through a number of rounds - that can be implemented either in a loop or by expanding the code into a - long sequence of instructions, the latter producing a larger program but - one that will often be much faster. The latter is called loop unrolling. - There are also potential speed advantages in expanding two iterations in - a loop with half the number of iterations, which is called partial loop - unrolling. The following options allow partial or full loop unrolling - to be set independently for encryption and decryption -*/ -#if 1 -# define ENC_UNROLL FULL -#elif 0 -# define ENC_UNROLL PARTIAL -#else -# define ENC_UNROLL NONE -#endif - -#if 1 -# define DEC_UNROLL FULL -#elif 0 -# define DEC_UNROLL PARTIAL -#else -# define DEC_UNROLL NONE -#endif - -#if 1 -# define ENC_KS_UNROLL -#endif - -#if 1 -# define DEC_KS_UNROLL -#endif - -/* 6. FAST FINITE FIELD OPERATIONS - - If this section is included, tables are used to provide faster finite - field arithmetic (this has no effect if FIXED_TABLES is defined). -*/ -#if 1 -# define FF_TABLES -#endif - -/* 7. INTERNAL STATE VARIABLE FORMAT - - The internal state of Rijndael is stored in a number of local 32-bit - word varaibles which can be defined either as an array or as individual - names variables. Include this section if you want to store these local - varaibles in arrays. Otherwise individual local variables will be used. -*/ -#if 1 -# define ARRAYS -#endif - -/* 8. FIXED OR DYNAMIC TABLES - - When this section is included the tables used by the code are compiled - statically into the binary file. Otherwise the subroutine aes_init() - must be called to compute them before the code is first used. -*/ -#if 1 && !(defined( _WIN32 ) && ( _WIN32 <= 800 )) -# define FIXED_TABLES -#endif - -/* 9. MASKING OR CASTING FROM LONGER VALUES TO BYTES - - In some systems it is better to mask longer values to extract bytes - rather than using a cast. This option allows this choice. -*/ -#if 0 -# define to_byte(x) ((uint8_t)(x)) -#else -# define to_byte(x) ((x) & 0xff) -#endif - -/* 10. TABLE ALIGNMENT - - On some sytsems speed will be improved by aligning the AES large lookup - tables on particular boundaries. This define should be set to a power of - two giving the desired alignment. It can be left undefined if alignment - is not needed. This option is specific to the Microsft VC++ compiler - - it seems to sometimes cause trouble for the VC++ version 6 compiler. -*/ - -#if 1 && defined( _WIN32 ) && ( _WIN32 >= 1300 ) -# define TABLE_ALIGN 32 -#endif - -/* 11. REDUCE CODE AND TABLE SIZE - - This replaces some expanded macros with function calls if AES_ASM_V2 or - AES_ASM_V2C are defined -*/ - -#if 0 && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) -# define REDUCE_CODE_SIZE -#endif - -/* 12. TABLE OPTIONS - - This cipher proceeds by repeating in a number of cycles known as 'rounds' - which are implemented by a round function which can optionally be speeded - up using tables. The basic tables are each 256 32-bit words, with either - one or four tables being required for each round function depending on - how much speed is required. The encryption and decryption round functions - are different and the last encryption and decrytpion round functions are - different again making four different round functions in all. - - This means that: - 1. Normal encryption and decryption rounds can each use either 0, 1 - or 4 tables and table spaces of 0, 1024 or 4096 bytes each. - 2. The last encryption and decryption rounds can also use either 0, 1 - or 4 tables and table spaces of 0, 1024 or 4096 bytes each. - - Include or exclude the appropriate definitions below to set the number - of tables used by this implementation. -*/ - -#if 1 /* set tables for the normal encryption round */ -# define ENC_ROUND FOUR_TABLES -#elif 0 -# define ENC_ROUND ONE_TABLE -#else -# define ENC_ROUND NO_TABLES -#endif - -#if 1 /* set tables for the last encryption round */ -# define LAST_ENC_ROUND FOUR_TABLES -#elif 0 -# define LAST_ENC_ROUND ONE_TABLE -#else -# define LAST_ENC_ROUND NO_TABLES -#endif - -#if 1 /* set tables for the normal decryption round */ -# define DEC_ROUND FOUR_TABLES -#elif 0 -# define DEC_ROUND ONE_TABLE -#else -# define DEC_ROUND NO_TABLES -#endif - -#if 1 /* set tables for the last decryption round */ -# define LAST_DEC_ROUND FOUR_TABLES -#elif 0 -# define LAST_DEC_ROUND ONE_TABLE -#else -# define LAST_DEC_ROUND NO_TABLES -#endif - -/* The decryption key schedule can be speeded up with tables in the same - way that the round functions can. Include or exclude the following - defines to set this requirement. -*/ -#if 1 -# define KEY_SCHED FOUR_TABLES -#elif 0 -# define KEY_SCHED ONE_TABLE -#else -# define KEY_SCHED NO_TABLES -#endif - -/* ---- END OF USER CONFIGURED OPTIONS ---- */ - -/* VIA ACE support is only available for VC++ and GCC */ - -#if !defined( _WIN32 ) && !defined( __GNUC__ ) -# if defined( ASSUME_VIA_ACE_PRESENT ) -# undef ASSUME_VIA_ACE_PRESENT -# endif -# if defined( USE_VIA_ACE_IF_PRESENT ) -# undef USE_VIA_ACE_IF_PRESENT -# endif -#endif - -#if defined( ASSUME_VIA_ACE_PRESENT ) && !defined( USE_VIA_ACE_IF_PRESENT ) -# define USE_VIA_ACE_IF_PRESENT -#endif - -/* define to reverse decryption key schedule */ -#if 1 || defined( USE_VIA_ACE_IF_PRESENT ) && !defined ( AES_REV_DKS ) -# define AES_REV_DKS -#endif - -/* Intel AESNI uses a decryption key schedule in the encryption order */ -#if defined( USE_INTEL_AES_IF_PRESENT ) && defined ( AES_REV_DKS ) -# undef AES_REV_DKS -#endif - -/* Assembler support requires the use of platform byte order */ - -#if ( defined( ASM_X86_V1C ) || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) ) \ - && (ALGORITHM_BYTE_ORDER != PLATFORM_BYTE_ORDER) -# undef ALGORITHM_BYTE_ORDER -# define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER -#endif - -/* In this implementation the columns of the state array are each held in - 32-bit words. The state array can be held in various ways: in an array - of words, in a number of individual word variables or in a number of - processor registers. The following define maps a variable name x and - a column number c to the way the state array variable is to be held. - The first define below maps the state into an array x[c] whereas the - second form maps the state into a number of individual variables x0, - x1, etc. Another form could map individual state colums to machine - register names. -*/ - -#if defined( ARRAYS ) -# define s(x,c) x[c] -#else -# define s(x,c) x##c -#endif - -/* This implementation provides subroutines for encryption, decryption - and for setting the three key lengths (separately) for encryption - and decryption. Since not all functions are needed, masks are set - up here to determine which will be implemented in C -*/ - -#if !defined( AES_ENCRYPT ) -# define EFUNCS_IN_C 0 -#elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \ - || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) -# define EFUNCS_IN_C ENC_KEYING_IN_C -#elif !defined( ASM_X86_V2 ) -# define EFUNCS_IN_C ( ENCRYPTION_IN_C | ENC_KEYING_IN_C ) -#else -# define EFUNCS_IN_C 0 -#endif - -#if !defined( AES_DECRYPT ) -# define DFUNCS_IN_C 0 -#elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \ - || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) -# define DFUNCS_IN_C DEC_KEYING_IN_C -#elif !defined( ASM_X86_V2 ) -# define DFUNCS_IN_C ( DECRYPTION_IN_C | DEC_KEYING_IN_C ) -#else -# define DFUNCS_IN_C 0 -#endif - -#define FUNCS_IN_C ( EFUNCS_IN_C | DFUNCS_IN_C ) - -/* END OF CONFIGURATION OPTIONS */ - -#define RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2)) - -/* Disable or report errors on some combinations of options */ - -#if ENC_ROUND == NO_TABLES && LAST_ENC_ROUND != NO_TABLES -# undef LAST_ENC_ROUND -# define LAST_ENC_ROUND NO_TABLES -#elif ENC_ROUND == ONE_TABLE && LAST_ENC_ROUND == FOUR_TABLES -# undef LAST_ENC_ROUND -# define LAST_ENC_ROUND ONE_TABLE -#endif - -#if ENC_ROUND == NO_TABLES && ENC_UNROLL != NONE -# undef ENC_UNROLL -# define ENC_UNROLL NONE -#endif - -#if DEC_ROUND == NO_TABLES && LAST_DEC_ROUND != NO_TABLES -# undef LAST_DEC_ROUND -# define LAST_DEC_ROUND NO_TABLES -#elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES -# undef LAST_DEC_ROUND -# define LAST_DEC_ROUND ONE_TABLE -#endif - -#if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE -# undef DEC_UNROLL -# define DEC_UNROLL NONE -#endif - -#if defined( bswap32 ) -# define aes_sw32 bswap32 -#elif defined( bswap_32 ) -# define aes_sw32 bswap_32 -#else -# define brot(x,n) (((uint32_t)(x) << n) | ((uint32_t)(x) >> (32 - n))) -# define aes_sw32(x) ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00)) -#endif - -/* upr(x,n): rotates bytes within words by n positions, moving bytes to - higher index positions with wrap around into low positions - ups(x,n): moves bytes by n positions to higher index positions in - words but without wrap around - bval(x,n): extracts a byte from a word - - WARNING: The definitions given here are intended only for use with - unsigned variables and with shift counts that are compile - time constants -*/ - -#if ( ALGORITHM_BYTE_ORDER == IS_LITTLE_ENDIAN ) -# define upr(x,n) (((uint32_t)(x) << (8 * (n))) | ((uint32_t)(x) >> (32 - 8 * (n)))) -# define ups(x,n) ((uint32_t) (x) << (8 * (n))) -# define bval(x,n) to_byte((x) >> (8 * (n))) -# define bytes2word(b0, b1, b2, b3) \ - (((uint32_t)(b3) << 24) | ((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0)) -#endif - -#if ( ALGORITHM_BYTE_ORDER == IS_BIG_ENDIAN ) -# define upr(x,n) (((uint32_t)(x) >> (8 * (n))) | ((uint32_t)(x) << (32 - 8 * (n)))) -# define ups(x,n) ((uint32_t) (x) >> (8 * (n))) -# define bval(x,n) to_byte((x) >> (24 - 8 * (n))) -# define bytes2word(b0, b1, b2, b3) \ - (((uint32_t)(b0) << 24) | ((uint32_t)(b1) << 16) | ((uint32_t)(b2) << 8) | (b3)) -#endif - -#if defined( SAFE_IO ) -# define word_in(x,c) bytes2word(((const uint8_t*)(x)+4*c)[0], ((const uint8_t*)(x)+4*c)[1], \ - ((const uint8_t*)(x)+4*c)[2], ((const uint8_t*)(x)+4*c)[3]) -# define word_out(x,c,v) { ((uint8_t*)(x)+4*c)[0] = bval(v,0); ((uint8_t*)(x)+4*c)[1] = bval(v,1); \ - ((uint8_t*)(x)+4*c)[2] = bval(v,2); ((uint8_t*)(x)+4*c)[3] = bval(v,3); } -#elif ( ALGORITHM_BYTE_ORDER == PLATFORM_BYTE_ORDER ) -# define word_in(x,c) (*((uint32_t*)(x)+(c))) -# define word_out(x,c,v) (*((uint32_t*)(x)+(c)) = (v)) -#else -# define word_in(x,c) aes_sw32(*((uint32_t*)(x)+(c))) -# define word_out(x,c,v) (*((uint32_t*)(x)+(c)) = aes_sw32(v)) -#endif - -/* the finite field modular polynomial and elements */ - -#define WPOLY 0x011b -#define BPOLY 0x1b - -/* multiply four bytes in GF(2^8) by 'x' {02} in parallel */ - -#define gf_c1 0x80808080 -#define gf_c2 0x7f7f7f7f -#define gf_mulx(x) ((((x) & gf_c2) << 1) ^ ((((x) & gf_c1) >> 7) * BPOLY)) - -/* The following defines provide alternative definitions of gf_mulx that might - give improved performance if a fast 32-bit multiply is not available. Note - that a temporary variable u needs to be defined where gf_mulx is used. - -#define gf_mulx(x) (u = (x) & gf_c1, u |= (u >> 1), ((x) & gf_c2) << 1) ^ ((u >> 3) | (u >> 6)) -#define gf_c4 (0x01010101 * BPOLY) -#define gf_mulx(x) (u = (x) & gf_c1, ((x) & gf_c2) << 1) ^ ((u - (u >> 7)) & gf_c4) -*/ - -/* Work out which tables are needed for the different options */ - -#if defined( ASM_X86_V1C ) -# if defined( ENC_ROUND ) -# undef ENC_ROUND -# endif -# define ENC_ROUND FOUR_TABLES -# if defined( LAST_ENC_ROUND ) -# undef LAST_ENC_ROUND -# endif -# define LAST_ENC_ROUND FOUR_TABLES -# if defined( DEC_ROUND ) -# undef DEC_ROUND -# endif -# define DEC_ROUND FOUR_TABLES -# if defined( LAST_DEC_ROUND ) -# undef LAST_DEC_ROUND -# endif -# define LAST_DEC_ROUND FOUR_TABLES -# if defined( KEY_SCHED ) -# undef KEY_SCHED -# define KEY_SCHED FOUR_TABLES -# endif -#endif - -#if ( FUNCS_IN_C & ENCRYPTION_IN_C ) || defined( ASM_X86_V1C ) -# if ENC_ROUND == ONE_TABLE -# define FT1_SET -# elif ENC_ROUND == FOUR_TABLES -# define FT4_SET -# else -# define SBX_SET -# endif -# if LAST_ENC_ROUND == ONE_TABLE -# define FL1_SET -# elif LAST_ENC_ROUND == FOUR_TABLES -# define FL4_SET -# elif !defined( SBX_SET ) -# define SBX_SET -# endif -#endif - -#if ( FUNCS_IN_C & DECRYPTION_IN_C ) || defined( ASM_X86_V1C ) -# if DEC_ROUND == ONE_TABLE -# define IT1_SET -# elif DEC_ROUND == FOUR_TABLES -# define IT4_SET -# else -# define ISB_SET -# endif -# if LAST_DEC_ROUND == ONE_TABLE -# define IL1_SET -# elif LAST_DEC_ROUND == FOUR_TABLES -# define IL4_SET -# elif !defined(ISB_SET) -# define ISB_SET -# endif -#endif - -#if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))) -# if ((FUNCS_IN_C & ENC_KEYING_IN_C) || (FUNCS_IN_C & DEC_KEYING_IN_C)) -# if KEY_SCHED == ONE_TABLE -# if !defined( FL1_SET ) && !defined( FL4_SET ) -# define LS1_SET -# endif -# elif KEY_SCHED == FOUR_TABLES -# if !defined( FL4_SET ) -# define LS4_SET -# endif -# elif !defined( SBX_SET ) -# define SBX_SET -# endif -# endif -# if (FUNCS_IN_C & DEC_KEYING_IN_C) -# if KEY_SCHED == ONE_TABLE -# define IM1_SET -# elif KEY_SCHED == FOUR_TABLES -# define IM4_SET -# elif !defined( SBX_SET ) -# define SBX_SET -# endif -# endif -#endif - -/* generic definitions of Rijndael macros that use tables */ - -#define no_table(x,box,vf,rf,c) bytes2word( \ - box[bval(vf(x,0,c),rf(0,c))], \ - box[bval(vf(x,1,c),rf(1,c))], \ - box[bval(vf(x,2,c),rf(2,c))], \ - box[bval(vf(x,3,c),rf(3,c))]) - -#define one_table(x,op,tab,vf,rf,c) \ - ( tab[bval(vf(x,0,c),rf(0,c))] \ - ^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \ - ^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \ - ^ op(tab[bval(vf(x,3,c),rf(3,c))],3)) - -#define four_tables(x,tab,vf,rf,c) \ - ( tab[0][bval(vf(x,0,c),rf(0,c))] \ - ^ tab[1][bval(vf(x,1,c),rf(1,c))] \ - ^ tab[2][bval(vf(x,2,c),rf(2,c))] \ - ^ tab[3][bval(vf(x,3,c),rf(3,c))]) - -#define vf1(x,r,c) (x) -#define rf1(r,c) (r) -#define rf2(r,c) ((8+r-c)&3) - -/* perform forward and inverse column mix operation on four bytes in long word x in */ -/* parallel. NOTE: x must be a simple variable, NOT an expression in these macros. */ - -#if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))) - -#if defined( FM4_SET ) /* not currently used */ -# define fwd_mcol(x) four_tables(x,t_use(f,m),vf1,rf1,0) -#elif defined( FM1_SET ) /* not currently used */ -# define fwd_mcol(x) one_table(x,upr,t_use(f,m),vf1,rf1,0) -#else -# define dec_fmvars uint32_t g2 -# define fwd_mcol(x) (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1)) -#endif - -#if defined( IM4_SET ) -# define inv_mcol(x) four_tables(x,t_use(i,m),vf1,rf1,0) -#elif defined( IM1_SET ) -# define inv_mcol(x) one_table(x,upr,t_use(i,m),vf1,rf1,0) -#else -# define dec_imvars uint32_t g2, g4, g9 -# define inv_mcol(x) (g2 = gf_mulx(x), g4 = gf_mulx(g2), g9 = (x) ^ gf_mulx(g4), g4 ^= g9, \ - (x) ^ g2 ^ g4 ^ upr(g2 ^ g9, 3) ^ upr(g4, 2) ^ upr(g9, 1)) -#endif - -#if defined( FL4_SET ) -# define ls_box(x,c) four_tables(x,t_use(f,l),vf1,rf2,c) -#elif defined( LS4_SET ) -# define ls_box(x,c) four_tables(x,t_use(l,s),vf1,rf2,c) -#elif defined( FL1_SET ) -# define ls_box(x,c) one_table(x,upr,t_use(f,l),vf1,rf2,c) -#elif defined( LS1_SET ) -# define ls_box(x,c) one_table(x,upr,t_use(l,s),vf1,rf2,c) -#else -# define ls_box(x,c) no_table(x,t_use(s,box),vf1,rf2,c) -#endif - -#endif - -#if defined( ASM_X86_V1C ) && defined( AES_DECRYPT ) && !defined( ISB_SET ) -# define ISB_SET -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aestab.c b/lib/ESPiLight/pilight/libs/openzwave/aes/aestab.c deleted file mode 100644 index 6ae64a7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aestab.c +++ /dev/null @@ -1,391 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 -*/ - -#define DO_TABLES - -#include "aes.h" -#include "aesopt.h" - -#if defined(FIXED_TABLES) - -#define sb_data(w) {\ - w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ - w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\ - w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\ - w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\ - w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\ - w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\ - w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\ - w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\ - w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\ - w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\ - w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\ - w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\ - w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\ - w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\ - w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\ - w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\ - w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\ - w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\ - w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\ - w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\ - w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\ - w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\ - w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\ - w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\ - w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\ - w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\ - w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\ - w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\ - w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\ - w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\ - w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\ - w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) } - -#define isb_data(w) {\ - w(0x52), w(0x09), w(0x6a), w(0xd5), w(0x30), w(0x36), w(0xa5), w(0x38),\ - w(0xbf), w(0x40), w(0xa3), w(0x9e), w(0x81), w(0xf3), w(0xd7), w(0xfb),\ - w(0x7c), w(0xe3), w(0x39), w(0x82), w(0x9b), w(0x2f), w(0xff), w(0x87),\ - w(0x34), w(0x8e), w(0x43), w(0x44), w(0xc4), w(0xde), w(0xe9), w(0xcb),\ - w(0x54), w(0x7b), w(0x94), w(0x32), w(0xa6), w(0xc2), w(0x23), w(0x3d),\ - w(0xee), w(0x4c), w(0x95), w(0x0b), w(0x42), w(0xfa), w(0xc3), w(0x4e),\ - w(0x08), w(0x2e), w(0xa1), w(0x66), w(0x28), w(0xd9), w(0x24), w(0xb2),\ - w(0x76), w(0x5b), w(0xa2), w(0x49), w(0x6d), w(0x8b), w(0xd1), w(0x25),\ - w(0x72), w(0xf8), w(0xf6), w(0x64), w(0x86), w(0x68), w(0x98), w(0x16),\ - w(0xd4), w(0xa4), w(0x5c), w(0xcc), w(0x5d), w(0x65), w(0xb6), w(0x92),\ - w(0x6c), w(0x70), w(0x48), w(0x50), w(0xfd), w(0xed), w(0xb9), w(0xda),\ - w(0x5e), w(0x15), w(0x46), w(0x57), w(0xa7), w(0x8d), w(0x9d), w(0x84),\ - w(0x90), w(0xd8), w(0xab), w(0x00), w(0x8c), w(0xbc), w(0xd3), w(0x0a),\ - w(0xf7), w(0xe4), w(0x58), w(0x05), w(0xb8), w(0xb3), w(0x45), w(0x06),\ - w(0xd0), w(0x2c), w(0x1e), w(0x8f), w(0xca), w(0x3f), w(0x0f), w(0x02),\ - w(0xc1), w(0xaf), w(0xbd), w(0x03), w(0x01), w(0x13), w(0x8a), w(0x6b),\ - w(0x3a), w(0x91), w(0x11), w(0x41), w(0x4f), w(0x67), w(0xdc), w(0xea),\ - w(0x97), w(0xf2), w(0xcf), w(0xce), w(0xf0), w(0xb4), w(0xe6), w(0x73),\ - w(0x96), w(0xac), w(0x74), w(0x22), w(0xe7), w(0xad), w(0x35), w(0x85),\ - w(0xe2), w(0xf9), w(0x37), w(0xe8), w(0x1c), w(0x75), w(0xdf), w(0x6e),\ - w(0x47), w(0xf1), w(0x1a), w(0x71), w(0x1d), w(0x29), w(0xc5), w(0x89),\ - w(0x6f), w(0xb7), w(0x62), w(0x0e), w(0xaa), w(0x18), w(0xbe), w(0x1b),\ - w(0xfc), w(0x56), w(0x3e), w(0x4b), w(0xc6), w(0xd2), w(0x79), w(0x20),\ - w(0x9a), w(0xdb), w(0xc0), w(0xfe), w(0x78), w(0xcd), w(0x5a), w(0xf4),\ - w(0x1f), w(0xdd), w(0xa8), w(0x33), w(0x88), w(0x07), w(0xc7), w(0x31),\ - w(0xb1), w(0x12), w(0x10), w(0x59), w(0x27), w(0x80), w(0xec), w(0x5f),\ - w(0x60), w(0x51), w(0x7f), w(0xa9), w(0x19), w(0xb5), w(0x4a), w(0x0d),\ - w(0x2d), w(0xe5), w(0x7a), w(0x9f), w(0x93), w(0xc9), w(0x9c), w(0xef),\ - w(0xa0), w(0xe0), w(0x3b), w(0x4d), w(0xae), w(0x2a), w(0xf5), w(0xb0),\ - w(0xc8), w(0xeb), w(0xbb), w(0x3c), w(0x83), w(0x53), w(0x99), w(0x61),\ - w(0x17), w(0x2b), w(0x04), w(0x7e), w(0xba), w(0x77), w(0xd6), w(0x26),\ - w(0xe1), w(0x69), w(0x14), w(0x63), w(0x55), w(0x21), w(0x0c), w(0x7d) } - -#define mm_data(w) {\ - w(0x00), w(0x01), w(0x02), w(0x03), w(0x04), w(0x05), w(0x06), w(0x07),\ - w(0x08), w(0x09), w(0x0a), w(0x0b), w(0x0c), w(0x0d), w(0x0e), w(0x0f),\ - w(0x10), w(0x11), w(0x12), w(0x13), w(0x14), w(0x15), w(0x16), w(0x17),\ - w(0x18), w(0x19), w(0x1a), w(0x1b), w(0x1c), w(0x1d), w(0x1e), w(0x1f),\ - w(0x20), w(0x21), w(0x22), w(0x23), w(0x24), w(0x25), w(0x26), w(0x27),\ - w(0x28), w(0x29), w(0x2a), w(0x2b), w(0x2c), w(0x2d), w(0x2e), w(0x2f),\ - w(0x30), w(0x31), w(0x32), w(0x33), w(0x34), w(0x35), w(0x36), w(0x37),\ - w(0x38), w(0x39), w(0x3a), w(0x3b), w(0x3c), w(0x3d), w(0x3e), w(0x3f),\ - w(0x40), w(0x41), w(0x42), w(0x43), w(0x44), w(0x45), w(0x46), w(0x47),\ - w(0x48), w(0x49), w(0x4a), w(0x4b), w(0x4c), w(0x4d), w(0x4e), w(0x4f),\ - w(0x50), w(0x51), w(0x52), w(0x53), w(0x54), w(0x55), w(0x56), w(0x57),\ - w(0x58), w(0x59), w(0x5a), w(0x5b), w(0x5c), w(0x5d), w(0x5e), w(0x5f),\ - w(0x60), w(0x61), w(0x62), w(0x63), w(0x64), w(0x65), w(0x66), w(0x67),\ - w(0x68), w(0x69), w(0x6a), w(0x6b), w(0x6c), w(0x6d), w(0x6e), w(0x6f),\ - w(0x70), w(0x71), w(0x72), w(0x73), w(0x74), w(0x75), w(0x76), w(0x77),\ - w(0x78), w(0x79), w(0x7a), w(0x7b), w(0x7c), w(0x7d), w(0x7e), w(0x7f),\ - w(0x80), w(0x81), w(0x82), w(0x83), w(0x84), w(0x85), w(0x86), w(0x87),\ - w(0x88), w(0x89), w(0x8a), w(0x8b), w(0x8c), w(0x8d), w(0x8e), w(0x8f),\ - w(0x90), w(0x91), w(0x92), w(0x93), w(0x94), w(0x95), w(0x96), w(0x97),\ - w(0x98), w(0x99), w(0x9a), w(0x9b), w(0x9c), w(0x9d), w(0x9e), w(0x9f),\ - w(0xa0), w(0xa1), w(0xa2), w(0xa3), w(0xa4), w(0xa5), w(0xa6), w(0xa7),\ - w(0xa8), w(0xa9), w(0xaa), w(0xab), w(0xac), w(0xad), w(0xae), w(0xaf),\ - w(0xb0), w(0xb1), w(0xb2), w(0xb3), w(0xb4), w(0xb5), w(0xb6), w(0xb7),\ - w(0xb8), w(0xb9), w(0xba), w(0xbb), w(0xbc), w(0xbd), w(0xbe), w(0xbf),\ - w(0xc0), w(0xc1), w(0xc2), w(0xc3), w(0xc4), w(0xc5), w(0xc6), w(0xc7),\ - w(0xc8), w(0xc9), w(0xca), w(0xcb), w(0xcc), w(0xcd), w(0xce), w(0xcf),\ - w(0xd0), w(0xd1), w(0xd2), w(0xd3), w(0xd4), w(0xd5), w(0xd6), w(0xd7),\ - w(0xd8), w(0xd9), w(0xda), w(0xdb), w(0xdc), w(0xdd), w(0xde), w(0xdf),\ - w(0xe0), w(0xe1), w(0xe2), w(0xe3), w(0xe4), w(0xe5), w(0xe6), w(0xe7),\ - w(0xe8), w(0xe9), w(0xea), w(0xeb), w(0xec), w(0xed), w(0xee), w(0xef),\ - w(0xf0), w(0xf1), w(0xf2), w(0xf3), w(0xf4), w(0xf5), w(0xf6), w(0xf7),\ - w(0xf8), w(0xf9), w(0xfa), w(0xfb), w(0xfc), w(0xfd), w(0xfe), w(0xff) } - -#define rc_data(w) {\ - w(0x01), w(0x02), w(0x04), w(0x08), w(0x10),w(0x20), w(0x40), w(0x80),\ - w(0x1b), w(0x36) } - -#define h0(x) (x) - -#define w0(p) bytes2word(p, 0, 0, 0) -#define w1(p) bytes2word(0, p, 0, 0) -#define w2(p) bytes2word(0, 0, p, 0) -#define w3(p) bytes2word(0, 0, 0, p) - -#define u0(p) bytes2word(f2(p), p, p, f3(p)) -#define u1(p) bytes2word(f3(p), f2(p), p, p) -#define u2(p) bytes2word(p, f3(p), f2(p), p) -#define u3(p) bytes2word(p, p, f3(p), f2(p)) - -#define v0(p) bytes2word(fe(p), f9(p), fd(p), fb(p)) -#define v1(p) bytes2word(fb(p), fe(p), f9(p), fd(p)) -#define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p)) -#define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p)) - -#endif - -#if defined(FIXED_TABLES) || !defined(FF_TABLES) - -#define f2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY)) -#define f4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY)) -#define f8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \ - ^ (((x>>5) & 4) * WPOLY)) -#define f3(x) (f2(x) ^ x) -#define f9(x) (f8(x) ^ x) -#define fb(x) (f8(x) ^ f2(x) ^ x) -#define fd(x) (f8(x) ^ f4(x) ^ x) -#define fe(x) (f8(x) ^ f4(x) ^ f2(x)) - -#else - -#define f2(x) ((x) ? pow[log[x] + 0x19] : 0) -#define f3(x) ((x) ? pow[log[x] + 0x01] : 0) -#define f9(x) ((x) ? pow[log[x] + 0xc7] : 0) -#define fb(x) ((x) ? pow[log[x] + 0x68] : 0) -#define fd(x) ((x) ? pow[log[x] + 0xee] : 0) -#define fe(x) ((x) ? pow[log[x] + 0xdf] : 0) - -#endif - -#include "aestab.h" - -#if defined(__cplusplus) -extern "C" -{ -#endif - -#if defined(FIXED_TABLES) - -/* implemented in case of wrong call for fixed tables */ - -AES_RETURN aes_init1(void) -{ - return EXIT_SUCCESS; -} - -#else /* Generate the tables for the dynamic table option */ - -#if defined(FF_TABLES) - -#define gf_inv(x) ((x) ? pow[ 255 - log[x]] : 0) - -#else - -/* It will generally be sensible to use tables to compute finite - field multiplies and inverses but where memory is scarse this - code might sometimes be better. But it only has effect during - initialisation so its pretty unimportant in overall terms. -*/ - -/* return 2 ^ (n - 1) where n is the bit number of the highest bit - set in x with x in the range 1 < x < 0x00000200. This form is - used so that locals within fi can be bytes rather than words -*/ - -static uint8_t hibit(const uint32_t x) -{ uint8_t r = (uint8_t)((x >> 1) | (x >> 2)); - - r |= (r >> 2); - r |= (r >> 4); - return (r + 1) >> 1; -} - -/* return the inverse of the finite field element x */ - -static uint8_t gf_inv(const uint8_t x) -{ uint8_t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0; - - if(x < 2) - return x; - - for( ; ; ) - { - if(n1) - while(n2 >= n1) /* divide polynomial p2 by p1 */ - { - n2 /= n1; /* shift smaller polynomial left */ - p2 ^= (p1 * n2) & 0xff; /* and remove from larger one */ - v2 ^= v1 * n2; /* shift accumulated value and */ - n2 = hibit(p2); /* add into result */ - } - else - return v1; - - if(n2) /* repeat with values swapped */ - while(n1 >= n2) - { - n1 /= n2; - p1 ^= p2 * n1; - v1 ^= v2 * n1; - n1 = hibit(p1); - } - else - return v2; - } -} - -#endif - -/* The forward and inverse affine transformations used in the S-box */ -uint8_t fwd_affine(const uint8_t x) -{ uint32_t w = x; - w ^= (w << 1) ^ (w << 2) ^ (w << 3) ^ (w << 4); - return 0x63 ^ ((w ^ (w >> 8)) & 0xff); -} - -uint8_t inv_affine(const uint8_t x) -{ uint32_t w = x; - w = (w << 1) ^ (w << 3) ^ (w << 6); - return 0x05 ^ ((w ^ (w >> 8)) & 0xff); -} - -static int init = 0; - -AES_RETURN aes_init1(void) -{ uint32_t i, w; - -#if defined(FF_TABLES) - - uint8_t pow[512], log[256]; - - if(init) - return EXIT_SUCCESS; - /* log and power tables for GF(2^8) finite field with - WPOLY as modular polynomial - the simplest primitive - root is 0x03, used here to generate the tables - */ - - i = 0; w = 1; - do - { - pow[i] = (uint8_t)w; - pow[i + 255] = (uint8_t)w; - log[w] = (uint8_t)i++; - w ^= (w << 1) ^ (w & 0x80 ? WPOLY : 0); - } - while (w != 1); - -#else - if(init) - return EXIT_SUCCESS; -#endif - - for(i = 0, w = 1; i < RC_LENGTH; ++i) - { - t_set(r,c)[i] = bytes2word(w, 0, 0, 0); - w = f2(w); - } - - for(i = 0; i < 256; ++i) - { uint8_t b; - - b = fwd_affine(gf_inv((uint8_t)i)); - w = bytes2word(f2(b), b, b, f3(b)); - -#if defined( SBX_SET ) - t_set(s,box)[i] = b; -#endif - -#if defined( FT1_SET ) /* tables for a normal encryption round */ - t_set(f,n)[i] = w; -#endif -#if defined( FT4_SET ) - t_set(f,n)[0][i] = w; - t_set(f,n)[1][i] = upr(w,1); - t_set(f,n)[2][i] = upr(w,2); - t_set(f,n)[3][i] = upr(w,3); -#endif - w = bytes2word(b, 0, 0, 0); - -#if defined( FL1_SET ) /* tables for last encryption round (may also */ - t_set(f,l)[i] = w; /* be used in the key schedule) */ -#endif -#if defined( FL4_SET ) - t_set(f,l)[0][i] = w; - t_set(f,l)[1][i] = upr(w,1); - t_set(f,l)[2][i] = upr(w,2); - t_set(f,l)[3][i] = upr(w,3); -#endif - -#if defined( LS1_SET ) /* table for key schedule if t_set(f,l) above is*/ - t_set(l,s)[i] = w; /* not of the required form */ -#endif -#if defined( LS4_SET ) - t_set(l,s)[0][i] = w; - t_set(l,s)[1][i] = upr(w,1); - t_set(l,s)[2][i] = upr(w,2); - t_set(l,s)[3][i] = upr(w,3); -#endif - - b = gf_inv(inv_affine((uint8_t)i)); - w = bytes2word(fe(b), f9(b), fd(b), fb(b)); - -#if defined( IM1_SET ) /* tables for the inverse mix column operation */ - t_set(i,m)[b] = w; -#endif -#if defined( IM4_SET ) - t_set(i,m)[0][b] = w; - t_set(i,m)[1][b] = upr(w,1); - t_set(i,m)[2][b] = upr(w,2); - t_set(i,m)[3][b] = upr(w,3); -#endif - -#if defined( ISB_SET ) - t_set(i,box)[i] = b; -#endif -#if defined( IT1_SET ) /* tables for a normal decryption round */ - t_set(i,n)[i] = w; -#endif -#if defined( IT4_SET ) - t_set(i,n)[0][i] = w; - t_set(i,n)[1][i] = upr(w,1); - t_set(i,n)[2][i] = upr(w,2); - t_set(i,n)[3][i] = upr(w,3); -#endif - w = bytes2word(b, 0, 0, 0); -#if defined( IL1_SET ) /* tables for last decryption round */ - t_set(i,l)[i] = w; -#endif -#if defined( IL4_SET ) - t_set(i,l)[0][i] = w; - t_set(i,l)[1][i] = upr(w,1); - t_set(i,l)[2][i] = upr(w,2); - t_set(i,l)[3][i] = upr(w,3); -#endif - } - init = 1; - return EXIT_SUCCESS; -} - -#endif - -#if defined(__cplusplus) -} -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/aestab.h b/lib/ESPiLight/pilight/libs/openzwave/aes/aestab.h deleted file mode 100644 index d95a5fc..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/aestab.h +++ /dev/null @@ -1,173 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 - - This file contains the code for declaring the tables needed to implement - AES. The file aesopt.h is assumed to be included before this header file. - If there are no global variables, the definitions here can be used to put - the AES tables in a structure so that a pointer can then be added to the - AES context to pass them to the AES routines that need them. If this - facility is used, the calling program has to ensure that this pointer is - managed appropriately. In particular, the value of the t_dec(in,it) item - in the table structure must be set to zero in order to ensure that the - tables are initialised. In practice the three code sequences in aeskey.c - that control the calls to aes_init() and the aes_init() routine itself will - have to be changed for a specific implementation. If global variables are - available it will generally be preferable to use them with the precomputed - FIXED_TABLES option that uses static global tables. - - The following defines can be used to control the way the tables - are defined, initialised and used in embedded environments that - require special features for these purposes - - the 't_dec' construction is used to declare fixed table arrays - the 't_set' construction is used to set fixed table values - the 't_use' construction is used to access fixed table values - - 256 byte tables: - - t_xxx(s,box) => forward S box - t_xxx(i,box) => inverse S box - - 256 32-bit word OR 4 x 256 32-bit word tables: - - t_xxx(f,n) => forward normal round - t_xxx(f,l) => forward last round - t_xxx(i,n) => inverse normal round - t_xxx(i,l) => inverse last round - t_xxx(l,s) => key schedule table - t_xxx(i,m) => key schedule table - - Other variables and tables: - - t_xxx(r,c) => the rcon table -*/ - -#if !defined( _AESTAB_H ) -#define _AESTAB_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#define t_dec(m,n) t_##m##n -#define t_set(m,n) t_##m##n -#define t_use(m,n) t_##m##n - -#if defined(FIXED_TABLES) -# if !defined( __GNUC__ ) && (defined( __MSDOS__ ) || defined( __WIN16__ )) -/* make tables far data to avoid using too much DGROUP space (PG) */ -# define CONST const far -# else -# define CONST const -# endif -#else -# define CONST -#endif - -#if defined(DO_TABLES) -# define EXTERN -#else -# define EXTERN extern -#endif - -#if defined(_WIN32) && defined(TABLE_ALIGN) -#define ALIGN __declspec(align(TABLE_ALIGN)) -#else -#define ALIGN -#endif - -#if defined( __WATCOMC__ ) && ( __WATCOMC__ >= 1100 ) -# define XP_DIR __cdecl -#else -# define XP_DIR -#endif - -#if defined(DO_TABLES) && defined(FIXED_TABLES) -#define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256] = b(e) -#define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256] = { b(e), b(f), b(g), b(h) } -EXTERN ALIGN CONST uint32_t t_dec(r,c)[RC_LENGTH] = rc_data(w0); -#else -#define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256] -#define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256] -EXTERN ALIGN CONST uint32_t t_dec(r,c)[RC_LENGTH]; -#endif - -#if defined( SBX_SET ) - d_1(uint8_t, t_dec(s,box), sb_data, h0); -#endif -#if defined( ISB_SET ) - d_1(uint8_t, t_dec(i,box), isb_data, h0); -#endif - -#if defined( FT1_SET ) - d_1(uint32_t, t_dec(f,n), sb_data, u0); -#endif -#if defined( FT4_SET ) - d_4(uint32_t, t_dec(f,n), sb_data, u0, u1, u2, u3); -#endif - -#if defined( FL1_SET ) - d_1(uint32_t, t_dec(f,l), sb_data, w0); -#endif -#if defined( FL4_SET ) - d_4(uint32_t, t_dec(f,l), sb_data, w0, w1, w2, w3); -#endif - -#if defined( IT1_SET ) - d_1(uint32_t, t_dec(i,n), isb_data, v0); -#endif -#if defined( IT4_SET ) - d_4(uint32_t, t_dec(i,n), isb_data, v0, v1, v2, v3); -#endif - -#if defined( IL1_SET ) - d_1(uint32_t, t_dec(i,l), isb_data, w0); -#endif -#if defined( IL4_SET ) - d_4(uint32_t, t_dec(i,l), isb_data, w0, w1, w2, w3); -#endif - -#if defined( LS1_SET ) -#if defined( FL1_SET ) -#undef LS1_SET -#else - d_1(uint32_t, t_dec(l,s), sb_data, w0); -#endif -#endif - -#if defined( LS4_SET ) -#if defined( FL4_SET ) -#undef LS4_SET -#else - d_4(uint32_t, t_dec(l,s), sb_data, w0, w1, w2, w3); -#endif -#endif - -#if defined( IM1_SET ) - d_1(uint32_t, t_dec(i,m), mm_data, v0); -#endif -#if defined( IM4_SET ) - d_4(uint32_t, t_dec(i,m), mm_data, v0, v1, v2, v3); -#endif - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/brg_endian.h b/lib/ESPiLight/pilight/libs/openzwave/aes/brg_endian.h deleted file mode 100644 index b44c5cb..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/brg_endian.h +++ /dev/null @@ -1,126 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 -*/ - -#ifndef _BRG_ENDIAN_H -#define _BRG_ENDIAN_H - -#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ -#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ - -/* Include files where endian defines and byteswap functions may reside */ -#if defined( __sun ) -# include -#elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ ) -# include -#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \ - defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ ) -# include -#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ ) -# if !defined( __MINGW32__ ) && !defined( _AIX ) -# include -# if !defined( __BEOS__ ) -# include -# endif -# endif -#endif - -/* Now attempt to set the define for platform byte order using any */ -/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */ -/* seem to encompass most endian symbol definitions */ - -#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN ) -# if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( BIG_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( LITTLE_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN ) -# if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( _BIG_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( _LITTLE_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN ) -# if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( __BIG_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( __LITTLE_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ ) -# if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__ -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__ -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( __BIG_ENDIAN__ ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( __LITTLE_ENDIAN__ ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -/* if the platform byte order could not be determined, then try to */ -/* set this define using common machine defines */ -#if !defined(PLATFORM_BYTE_ORDER) - -#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ - defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \ - defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \ - defined( vax ) || defined( vms ) || defined( VMS ) || \ - defined( __VMS ) || defined( _M_X64 ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN - -#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \ - defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \ - defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \ - defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \ - defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \ - defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \ - defined( THINK_C ) || defined( __VMCMS__ ) || defined( _AIX ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN - -#elif 0 /* **** EDIT HERE IF NECESSARY **** */ -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#elif 0 /* **** EDIT HERE IF NECESSARY **** */ -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#else -# error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order -#endif - -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/aes/brg_types.h b/lib/ESPiLight/pilight/libs/openzwave/aes/brg_types.h deleted file mode 100644 index 0d16baa..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/aes/brg_types.h +++ /dev/null @@ -1,191 +0,0 @@ -/* ---------------------------------------------------------------------------- -Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. - -The redistribution and use of this software (with or without changes) -is allowed without the payment of fees or royalties provided that: - - source code distributions include the above copyright notice, this - list of conditions and the following disclaimer; - - binary distributions include the above copyright notice, this list - of conditions and the following disclaimer in their documentation. - -This software is provided 'as is' with no explicit or implied warranties -in respect of its operation, including, but not limited to, correctness -and fitness for purpose. ---------------------------------------------------------------------------- -Issue Date: 20/12/2007 - - The unsigned integer types defined here are of the form uint_t where - is the length of the type; for example, the unsigned 32-bit type is - 'uint32_t'. These are NOT the same as the 'C99 integer types' that are - defined in the inttypes.h and stdint.h headers since attempts to use these - types have shown that support for them is still highly variable. However, - since the latter are of the form uint_t, a regular expression search - and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t') - can be used to convert the types used here to the C99 standard types. -*/ - -#ifndef _BRG_TYPES_H -#define _BRG_TYPES_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#include -#include - -#if defined( _WIN32 ) && ( _WIN32 >= 1300 ) -# include -# define ptrint_t intptr_t -#elif defined( __ECOS__ ) -# define intptr_t unsigned int -# define ptrint_t intptr_t -#elif defined( __GNUC__ ) && ( __GNUC__ >= 3 ) -# define ptrint_t intptr_t -#else -# define ptrint_t int -#endif - -#ifndef BRG_UI32 -# define BRG_UI32 -# if UINT_MAX == 4294967295u -# define li_32(h) 0x##h##u -# elif ULONG_MAX == 4294967295u -# define li_32(h) 0x##h##ul -# elif defined( _CRAY ) -# error This code needs 32-bit data types, which Cray machines do not provide -# else -# error Please define uint32_t as a 32-bit unsigned integer type in brg_types.h -# endif -#endif - -#ifndef BRG_UI64 -# if defined( __BORLANDC__ ) && !defined( __MSDOS__ ) -# define BRG_UI64 -# define li_64(h) 0x##h##ui64 -# elif defined( _WIN32 ) && ( _WIN32 < 1300 ) /* 1300 == VC++ 7.0 */ -# define BRG_UI64 -# define li_64(h) 0x##h##ui64 -# elif defined( __sun ) && defined( ULONG_MAX ) && ULONG_MAX == 0xfffffffful -# define BRG_UI64 -# define li_64(h) 0x##h##ull -# elif defined( __MVS__ ) -# define BRG_UI64 -# define li_64(h) 0x##h##ull -# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u -# if UINT_MAX == 18446744073709551615u -# define BRG_UI64 -# define li_64(h) 0x##h##u -# endif -# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u -# if ULONG_MAX == 18446744073709551615ul -# define BRG_UI64 -# define li_64(h) 0x##h##ul -# endif -# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u -# if ULLONG_MAX == 18446744073709551615ull -# define BRG_UI64 -# define li_64(h) 0x##h##ull -# endif -# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u -# if ULONG_LONG_MAX == 18446744073709551615ull -# define BRG_UI64 -# define li_64(h) 0x##h##ull -# endif -# endif -#endif - -#if !defined( BRG_UI64 ) -# if defined( NEED_UINT_64T ) -# error Please define uint64_t as an unsigned 64 bit type in brg_types.h -# endif -#endif - -#ifndef RETURN_VALUES -# define RETURN_VALUES -# if defined( DLL_EXPORT ) -# if defined( _WIN32 ) || defined ( __INTEL_COMPILER ) -# define VOID_RETURN __declspec( dllexport ) void __stdcall -# define INT_RETURN __declspec( dllexport ) int __stdcall -# elif defined( __GNUC__ ) -# define VOID_RETURN __declspec( __dllexport__ ) void -# define INT_RETURN __declspec( __dllexport__ ) int -# else -# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers -# endif -# elif defined( DLL_IMPORT ) -# if defined( _WIN32 ) || defined ( __INTEL_COMPILER ) -# define VOID_RETURN __declspec( dllimport ) void __stdcall -# define INT_RETURN __declspec( dllimport ) int __stdcall -# elif defined( __GNUC__ ) -# define VOID_RETURN __declspec( __dllimport__ ) void -# define INT_RETURN __declspec( __dllimport__ ) int -# else -# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers -# endif -# elif defined( __WATCOMC__ ) -# define VOID_RETURN void __cdecl -# define INT_RETURN int __cdecl -# else -# define VOID_RETURN void -# define INT_RETURN int -# endif -#endif - -/* These defines are used to detect and set the memory alignment of pointers. - Note that offsets are in bytes. - - ALIGN_OFFSET(x,n) return the positive or zero offset of - the memory addressed by the pointer 'x' - from an address that is aligned on an - 'n' byte boundary ('n' is a power of 2) - - ALIGN_FLOOR(x,n) return a pointer that points to memory - that is aligned on an 'n' byte boundary - and is not higher than the memory address - pointed to by 'x' ('n' is a power of 2) - - ALIGN_CEIL(x,n) return a pointer that points to memory - that is aligned on an 'n' byte boundary - and is not lower than the memory address - pointed to by 'x' ('n' is a power of 2) -*/ - -#define ALIGN_OFFSET(x,n) (((ptrint_t)(x)) & ((n) - 1)) -#define ALIGN_FLOOR(x,n) ((uint8_t*)(x) - ( ((ptrint_t)(x)) & ((n) - 1))) -#define ALIGN_CEIL(x,n) ((uint8_t*)(x) + (-((ptrint_t)(x)) & ((n) - 1))) - -/* These defines are used to declare buffers in a way that allows - faster operations on longer variables to be used. In all these - defines 'size' must be a power of 2 and >= 8. NOTE that the - buffer size is in bytes but the type length is in bits - - UNIT_TYPEDEF(x,size) declares a variable 'x' of length - 'size' bits - - BUFR_TYPEDEF(x,size,bsize) declares a buffer 'x' of length 'bsize' - bytes defined as an array of variables - each of 'size' bits (bsize must be a - multiple of size / 8) - - UNIT_CAST(x,size) casts a variable to a type of - length 'size' bits - - UPTR_CAST(x,size) casts a pointer to a pointer to a - varaiable of length 'size' bits -*/ - -#define UI_TYPE(size) uint##size##_t -#define UNIT_TYPEDEF(x,size) typedef UI_TYPE(size) x -#define BUFR_TYPEDEF(x,size,bsize) typedef UI_TYPE(size) x[bsize / (size >> 3)] -#define UNIT_CAST(x,size) ((UI_TYPE(size) )(x)) -#define UPTR_CAST(x,size) ((UI_TYPE(size)*)(x)) - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Alarm.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Alarm.cpp deleted file mode 100644 index 870d123..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Alarm.cpp +++ /dev/null @@ -1,148 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Alarm.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_ALARM -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Alarm.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" - -using namespace OpenZWave; - -enum AlarmCmd -{ - AlarmCmd_Get = 0x04, - AlarmCmd_Report = 0x05 -}; - -enum -{ - AlarmIndex_Type = 0, - AlarmIndex_Level -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Alarm::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Alarm::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( IsGetSupported() ) - { - Msg* msg = new Msg( "AlarmCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( AlarmCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "AlarmCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Alarm::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (AlarmCmd_Report == (AlarmCmd)_data[0]) - { - // We have received a report from the Z-Wave device - Log::Write( LogLevel_Info, GetNodeId(), "Received Alarm report: type=%d, level=%d", _data[1], _data[2] ); - - ValueByte* value; - if( (value = static_cast( GetValue( _instance, AlarmIndex_Type ) )) ) - { - value->OnValueRefreshed( _data[1] ); - value->Release(); - } - if( (value = static_cast( GetValue( _instance, AlarmIndex_Level ) )) ) - { - value->OnValueRefreshed( _data[2] ); - value->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Alarm::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, AlarmIndex_Type, "Alarm Type", "", true, false, 0, 0 ); - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, AlarmIndex_Level, "Alarm Level", "", true, false, 0, 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Alarm.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Alarm.h deleted file mode 100644 index becc4a9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Alarm.h +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Alarm.h -// -// Implementation of the Z-Wave COMMAND_CLASS_ALARM -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Alarm_H -#define _Alarm_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - - /** \brief Implements COMMAND_CLASS_ALARM (0x71), a Z-Wave device command class. - */ - class Alarm: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Alarm( _homeId, _nodeId ); } - virtual ~Alarm(){} - - /** \brief Get command class ID (1 byte) identifying this command class. */ - static uint8 const StaticGetCommandClassId(){ return 0x71; } - /** \brief Get a string containing the name of this command class. */ - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_ALARM"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - /** \brief Get command class ID (1 byte) identifying this command class. (Inherited from CommandClass) */ - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - /** \brief Get a string containing the name of this command class. (Inherited from CommandClass) */ - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - /** \brief Handle a response to a message associated with this command class. (Inherited from CommandClass) */ - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - virtual uint8 GetMaxVersion(){ return 2; } - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Alarm( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ApplicationStatus.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ApplicationStatus.cpp deleted file mode 100644 index 94b1525..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ApplicationStatus.cpp +++ /dev/null @@ -1,93 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ApplicationStatus.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_APPLICATION_STATUS -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ApplicationStatus.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -enum ApplicationStatusCmd -{ - ApplicationStatusCmd_Busy = 0x01, - ApplicationStatusCmd_RejectedRequest = 0x02 -}; - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ApplicationStatus::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ApplicationStatusCmd_Busy == (ApplicationStatusCmd)_data[0] ) - { - char msg[64]; - switch( _data[1] ) - { - case 0: - { - snprintf( msg, sizeof(msg), "Try again later" ); - break; - } - case 1: - { - snprintf( msg, sizeof(msg), "Try again in %d seconds", _data[2] ); - break; - } - case 2: - { - snprintf( msg, sizeof(msg), "Request queued, will be executed later" ); - break; - } - default: - { - // Invalid status - snprintf( msg, sizeof(msg), "Unknown status %d", _data[1] ); - } - } - Log::Write( LogLevel_Info, GetNodeId(), "Received Application Status Busy: %s", msg ); - return true; - } - - if( ApplicationStatusCmd_RejectedRequest == (ApplicationStatusCmd)_data[0] ) - { - Log::Write( LogLevel_Info, "Received Application Rejected Request: Status=%d", _data[1] ); - return true; - } - - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ApplicationStatus.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ApplicationStatus.h deleted file mode 100644 index 02a491b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ApplicationStatus.h +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ApplicationStatus.h -// -// Implementation of the Z-Wave COMMAND_CLASS_APPLICATION_STATUS -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ApplicationStatus_H -#define _ApplicationStatus_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_APPLICATION_STATUS (0x22), a Z-Wave device command class. - */ - class ApplicationStatus: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ApplicationStatus( _homeId, _nodeId ); } - virtual ~ApplicationStatus(){} - - static uint8 const StaticGetCommandClassId(){ return 0x22; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_APPLICATION_STATUS"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - ApplicationStatus( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Association.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Association.cpp deleted file mode 100644 index 534ecfb..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Association.cpp +++ /dev/null @@ -1,390 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Association.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_ASSOCIATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "CommandClasses.h" -#include "Association.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../Group.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -enum AssociationCmd -{ - AssociationCmd_Set = 0x01, - AssociationCmd_Get = 0x02, - AssociationCmd_Report = 0x03, - AssociationCmd_Remove = 0x04, - AssociationCmd_GroupingsGet = 0x05, - AssociationCmd_GroupingsReport = 0x06 -}; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Association::Association -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_queryAll(false), - m_numGroups(0) -{ - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Read the saved association data -//----------------------------------------------------------------------------- -void Association::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - TiXmlElement const* associationsElement = _ccElement->FirstChildElement(); - while( associationsElement ) - { - char const* str = associationsElement->Value(); - if( str && !strcmp( str, "Associations" ) ) - { - int intVal; - if( TIXML_SUCCESS == associationsElement->QueryIntAttribute( "num_groups", &intVal ) ) - { - m_numGroups = (uint8)intVal; - } - - TiXmlElement const* groupElement = associationsElement->FirstChildElement(); - while( groupElement ) - { - if( Node* node = GetNodeUnsafe() ) - { - Group* group = new Group( GetHomeId(), GetNodeId(), groupElement ); - node->AddGroup( group ); - } - - groupElement = groupElement->NextSiblingElement(); - } - - break; - } - - associationsElement = associationsElement->NextSiblingElement(); - } -} - -//----------------------------------------------------------------------------- -// -// Save the association data -//----------------------------------------------------------------------------- -void Association::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); - - if( Node* node = GetNodeUnsafe() ) - { - TiXmlElement* associationsElement = new TiXmlElement( "Associations" ); - - char str[8]; - snprintf( str, 8, "%d", m_numGroups ); - associationsElement->SetAttribute( "num_groups", str ); - - _ccElement->LinkEndChild( associationsElement ); - node->WriteGroups( associationsElement ); - } -} - -//----------------------------------------------------------------------------- -// -// Nothing to do for Association -//----------------------------------------------------------------------------- -bool Association::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - // Request the supported group info - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Nothing to do for Association -//----------------------------------------------------------------------------- -bool Association::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - // Request the supported group info - Msg* msg = new Msg( "Get Association Groupings", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( AssociationCmd_GroupingsGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Request the contents of each group in turn -//----------------------------------------------------------------------------- -void Association::RequestAllGroups -( - uint32 const _requestFlags -) -{ - m_queryAll = true; - - // Request the contents of the individual groups in turn. - if( m_numGroups == 0xff ) - { - // We start with group 255, and will then move to group 1, 2 etc and stop when we find a group with a maxAssociations of zero. - Log::Write( LogLevel_Info, GetNodeId(), "Number of association groups reported for node %d is 255, which requires special case handling.", GetNodeId() ); - QueryGroup( 0xff, _requestFlags ); - } - else - { - // We start with group 1, and will then move to group 2, 3 etc and stop when the group index is greater than m_numGroups. - Log::Write( LogLevel_Info, GetNodeId(), "Number of association groups reported for node %d is %d.", GetNodeId(), m_numGroups ); - QueryGroup( 1, _requestFlags ); - } -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Association::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - bool handled = false; - uint32 i; - - if( Node* node = GetNodeUnsafe() ) - { - if( AssociationCmd_GroupingsReport == (AssociationCmd)_data[0] ) - { - // Retrieve the number of groups this device supports. - // The groups will be queried with the session data. - m_numGroups = _data[1]; - Log::Write( LogLevel_Info, GetNodeId(), "Received Association Groupings report from node %d. Number of groups is %d", GetNodeId(), m_numGroups ); - ClearStaticRequest( StaticRequest_Values ); - handled = true; - } - else if( AssociationCmd_Report == (AssociationCmd)_data[0] ) - { - // Get the group info - uint8 groupIdx = _data[1]; - uint8 maxAssociations = _data[2]; // If the maxAssociations is zero, this is not a supported group. - uint8 numReportsToFollow = _data[3]; // If a device supports a lot of associations, they may come in more than one message. - - if( maxAssociations ) - { - if( _length >= 5 ) - { - uint8 numAssociations = _length - 5; - - Log::Write( LogLevel_Info, GetNodeId(), "Received Association report from node %d, group %d, containing %d associations", GetNodeId(), groupIdx, numAssociations ); - if( numAssociations ) - { - Log::Write( LogLevel_Info, GetNodeId(), " The group contains:" ); - for( i=0; iGetGroup( groupIdx ); - if( NULL == group ) - { - // Group has not been created yet - group = new Group( GetHomeId(), GetNodeId(), groupIdx, maxAssociations ); - node->AddGroup( group ); - } - - // Update the group with its new contents - group->OnGroupChanged( m_pendingMembers ); - m_pendingMembers.clear(); - } - } - else - { - // maxAssociations is zero, so we've reached the end of the query process - Log::Write( LogLevel_Info, GetNodeId(), "Max associations for node %d, group %d is zero. Querying associations for this node is complete.", GetNodeId(), groupIdx ); - node->AutoAssociate(); - m_queryAll = false; - } - - if( m_queryAll ) - { - // Work out which is the next group we will query. - // If we are currently on group 255, the next group will be 1. - uint8 nextGroup = groupIdx + 1; - if( !nextGroup ) - { - nextGroup = 1; - } - - if( nextGroup <= m_numGroups ) - { - // Query the next group - QueryGroup( nextGroup, 0 ); - } - else - { - // We're all done - Log::Write( LogLevel_Info, GetNodeId(), "Querying associations for node %d is complete.", GetNodeId() ); - node->AutoAssociate(); - m_queryAll = false; - } - } - - handled = true; - } - } - - return handled; -} - -//----------------------------------------------------------------------------- -// -// Request details of an association group -//----------------------------------------------------------------------------- -void Association::QueryGroup -( - uint8 _groupIdx, - uint32 const _requestFlags -) -{ - if ( IsGetSupported() ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Get Associations for group %d of node %d", _groupIdx, GetNodeId() ); - Msg* msg = new Msg( "Get Associations", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( AssociationCmd_Get ); - msg->Append( _groupIdx ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "AssociationCmd_Get Not Supported on this node"); - } - return; -} -//----------------------------------------------------------------------------- -// -// Add an association between devices -//----------------------------------------------------------------------------- -void Association::Set -( - uint8 _groupIdx, - uint8 _targetNodeId -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "Association::Set - Adding node %d to group %d of node %d", _targetNodeId, _groupIdx, GetNodeId() ); - - Msg* msg = new Msg( "Association Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( AssociationCmd_Set ); - msg->Append( _groupIdx ); - msg->Append( _targetNodeId ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); -} - -//----------------------------------------------------------------------------- -// -// Remove an association between devices -//----------------------------------------------------------------------------- -void Association::Remove -( - uint8 _groupIdx, - uint8 _targetNodeId -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "Association::Remove - Removing node %d from group %d of node %d", _targetNodeId, _groupIdx, GetNodeId() ); - - Msg* msg = new Msg( "Association Remove", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( AssociationCmd_Remove ); - msg->Append( _groupIdx ); - msg->Append( _targetNodeId ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Association.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Association.h deleted file mode 100644 index 552ca57..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Association.h +++ /dev/null @@ -1,75 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Association.h -// -// Implementation of the Z-Wave COMMAND_CLASS_ASSOCIATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Association_H -#define _Association_H - -#include -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_ASSOCIATION (0x85), a Z-Wave device command class. - */ - class Association: public CommandClass - { - friend class Group; - - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Association( _homeId, _nodeId ); } - virtual ~Association(){} - - static uint8 const StaticGetCommandClassId(){ return 0x85; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_ASSOCIATION"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - void RequestAllGroups( uint32 const _requestFlags ); - void Set( uint8 const _group, uint8 const _nodeId ); - void Remove( uint8 const _group, uint8 const _nodeId ); - - private: - Association( uint32 const _homeId, uint8 const _nodeId ); - void QueryGroup( uint8 _groupIdx, uint32 const _requestFlags ); - void AutoAssociate(); - - bool m_queryAll; // When true, once a group has been queried, we request the next one. - uint8 m_numGroups; // Number of groups supported by the device. 255 is reported by certain manufacturers and requires special handling. - vector m_pendingMembers; // Used to build a list of group members from multiple reports - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/AssociationCommandConfiguration.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/AssociationCommandConfiguration.cpp deleted file mode 100644 index 4f101e0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/AssociationCommandConfiguration.cpp +++ /dev/null @@ -1,281 +0,0 @@ -//----------------------------------------------------------------------------- -// -// AssociationCommandConfiguration.cpp -// -// Implementation of the COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "AssociationCommandConfiguration.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Group.h" -#include "../Driver.h" -#include "../platform/Log.h" -#include "../value_classes/ValueBool.h" -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueShort.h" - -using namespace OpenZWave; - -enum AssociationCommandConfigurationCmd -{ - AssociationCommandConfigurationCmd_SupportedRecordsGet = 0x01, - AssociationCommandConfigurationCmd_SupportedRecordsReport = 0x02, - AssociationCommandConfigurationCmd_Set = 0x03, - AssociationCommandConfigurationCmd_Get = 0x04, - AssociationCommandConfigurationCmd_Report = 0x05 -}; - -enum -{ - AssociationCommandConfigurationIndex_MaxCommandLength = 0, - AssociationCommandConfigurationIndex_CommandsAreValues, - AssociationCommandConfigurationIndex_CommandsAreConfigurable, - AssociationCommandConfigurationIndex_NumFreeCommands, - AssociationCommandConfigurationIndex_MaxCommands -}; - - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool AssociationCommandConfiguration::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Session ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool AssociationCommandConfiguration::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - - Msg* msg = new Msg( "AssociationCommandConfigurationCmd_SupportedRecordsGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( AssociationCommandConfigurationCmd_SupportedRecordsGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Request the command data -//----------------------------------------------------------------------------- -void AssociationCommandConfiguration::RequestCommands -( - uint8 const _groupIdx, - uint8 const _nodeId -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "AssociationCommandConfigurationCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( AssociationCommandConfigurationCmd_Get ); - msg->Append( _groupIdx ); - msg->Append( _nodeId ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } else { - Log::Write( LogLevel_Info, GetNodeId(), "AssociationCommandConfigurationCmd_Get Not Supported on this node"); - } -} -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool AssociationCommandConfiguration::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (AssociationCommandConfigurationCmd_SupportedRecordsReport == (AssociationCommandConfigurationCmd)_data[0]) - { - uint8 maxCommandLength = _data[1] >> 2; - bool commandsAreValues = ( (_data[1] & 0x02) != 0 ); - bool commandsAreConfigurable = ( (_data[1] & 0x01) != 0 ); - int16 numFreeCommands = (((int16)_data[2])<<16) | (int16)_data[3]; - int16 maxCommands = (((int16)_data[4])<<16) | (int16)_data[5]; - - Log::Write( LogLevel_Info, GetNodeId(), "Received AssociationCommandConfiguration Supported Records Report:" ); - Log::Write( LogLevel_Info, GetNodeId(), " Maximum command length = %d bytes", maxCommandLength ); - Log::Write( LogLevel_Info, GetNodeId(), " Maximum number of commands = %d", maxCommands ); - Log::Write( LogLevel_Info, GetNodeId(), " Number of free commands = %d", numFreeCommands ); - Log::Write( LogLevel_Info, GetNodeId(), " Commands are %s and are %s", commandsAreValues ? "values" : "not values", commandsAreConfigurable ? "configurable" : "not configurable" ); - - ValueBool* valueBool; - ValueByte* valueByte; - ValueShort* valueShort; - - if( (valueByte = static_cast( GetValue( _instance, AssociationCommandConfigurationIndex_MaxCommandLength ) )) ) - { - valueByte->OnValueRefreshed( maxCommandLength ); - valueByte->Release(); - } - - if( (valueBool = static_cast( GetValue( _instance, AssociationCommandConfigurationIndex_CommandsAreValues ) )) ) - { - valueBool->OnValueRefreshed( commandsAreValues ); - valueBool->Release(); - } - - if( (valueBool = static_cast( GetValue( _instance, AssociationCommandConfigurationIndex_CommandsAreConfigurable ) )) ) - { - valueBool->OnValueRefreshed( commandsAreConfigurable ); - valueBool->Release(); - } - - if( (valueShort = static_cast( GetValue( _instance, AssociationCommandConfigurationIndex_NumFreeCommands ) )) ) - { - valueShort->OnValueRefreshed( numFreeCommands ); - valueShort->Release(); - } - - if( (valueShort = static_cast( GetValue( _instance, AssociationCommandConfigurationIndex_MaxCommands ) )) ) - { - valueShort->OnValueRefreshed( maxCommands ); - valueShort->Release(); - } - return true; - } - - if (AssociationCommandConfigurationCmd_Report == (AssociationCommandConfigurationCmd)_data[0]) - { - uint8 groupIdx = _data[1]; - uint8 nodeIdx = _data[2]; - bool firstReports = ( ( _data[3] & 0x80 ) != 0 ); // True if this is the first message containing commands for this group and node. - uint8 numReports = _data[3] & 0x0f; - - Log::Write( LogLevel_Info, GetNodeId(), "Received AssociationCommandConfiguration Report from:" ); - Log::Write( LogLevel_Info, GetNodeId(), " Commands for node %d in group %d,", nodeIdx, groupIdx ); - - if( Node* node = GetNodeUnsafe() ) - { - Group* group = node->GetGroup( groupIdx ); - if( NULL == group ) - { - if( firstReports ) - { - // This is the first report message, so we should clear any existing command data - group->ClearCommands( nodeIdx ); - } - - uint8 const* start = &_data[4]; - - for( uint8 i=0; iAddCommand( nodeIdx, length, start+1 ); - start += length; - } - } - } - - return true; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void AssociationCommandConfiguration::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte ( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_MaxCommandLength, "Max Command Length", "", true, false, 0, 0 ); - node->CreateValueBool ( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_CommandsAreValues, "Commands are Values", "", true, false, false, 0 ); - node->CreateValueBool ( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_CommandsAreConfigurable, "Commands are Configurable", "", true, false, false, 0 ); - node->CreateValueShort( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_NumFreeCommands, "Free Commands", "", true, false, 0, 0 ); - node->CreateValueShort( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_MaxCommands, "Max Commands", "", true, false, 0, 0 ); - } -} - -//----------------------------------------------------------------------------- -// -// Set a command for the association -//----------------------------------------------------------------------------- -void AssociationCommandConfiguration::SetCommand -( - uint8 const _groupIdx, - uint8 const _nodeId, - uint8 const _length, - uint8 const* _data -) -{ - Msg* msg = new Msg( "AssociationCommandConfigurationCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( _length + 5 ); - msg->Append( GetCommandClassId() ); - msg->Append( AssociationCommandConfigurationCmd_Set ); - msg->Append( _groupIdx ); - msg->Append( _nodeId ); - msg->Append( _length ); - - for( uint8 i=0; i<_length; ++i ) - { - msg->Append( _data[i] ); - } - - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/AssociationCommandConfiguration.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/AssociationCommandConfiguration.h deleted file mode 100644 index dd9abe7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/AssociationCommandConfiguration.h +++ /dev/null @@ -1,70 +0,0 @@ -//----------------------------------------------------------------------------- -// -// AssociationCommandConfiguration.h -// -// Implementation of the COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _AssociationCommandConfiguration_H -#define _AssociationCommandConfiguration_H - -#include "CommandClass.h" -#include "../value_classes/ValueBool.h" -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueShort.h" - - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION (0x9b), a Z-Wave device command class. - */ - - class AssociationCommandConfiguration: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new AssociationCommandConfiguration( _homeId, _nodeId ); } - virtual ~AssociationCommandConfiguration(){} - - static uint8 const StaticGetCommandClassId(){ return 0x9b; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION"; } - - void RequestCommands( uint8 const _groupIdx, uint8 const _nodeId ); - void SetCommand( uint8 const _groupIdx, uint8 const _nodeId, uint8 const _length, uint8 const* _data ); - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - AssociationCommandConfiguration( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Basic.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Basic.cpp deleted file mode 100644 index fd2f7db..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Basic.cpp +++ /dev/null @@ -1,345 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Basic.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_BASIC -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Basic.h" -#include "Association.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../Notification.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" -#include "NoOperation.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum BasicCmd -{ - BasicCmd_Set = 0x01, - BasicCmd_Get = 0x02, - BasicCmd_Report = 0x03 -}; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Basic::Basic -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_mapping( 0 ), - m_ignoreMapping( false ), - m_setAsReport( false ) -{ -} - -//----------------------------------------------------------------------------- -// -// Read configuration. -//----------------------------------------------------------------------------- -void Basic::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - char const* str = _ccElement->Attribute("ignoremapping"); - if( str ) - { - m_ignoreMapping = !strcmp( str, "true"); - } - - int32 intVal; - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "mapping", &intVal ) ) - { - if( intVal < 256 && intVal != 0 ) - { - SetMapping( (uint8)intVal, false ); - } - } - - str = _ccElement->Attribute("setasreport"); - if( str ) - { - m_setAsReport = !strcmp( str, "true"); - } -} - -//----------------------------------------------------------------------------- -// -// Save changed configuration -//----------------------------------------------------------------------------- -void Basic::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); - - if( m_ignoreMapping ) - { - _ccElement->SetAttribute( "ignoremapping", "true" ); - } - - char str[32]; - if( m_mapping != 0 ) - { - snprintf( str, sizeof(str), "%d", m_mapping ); - _ccElement->SetAttribute( "mapping", str ); - } - - if( m_setAsReport ) - { - _ccElement->SetAttribute( "setasreport", "true" ); - } -} - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Basic::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Basic::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "BasicCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( BasicCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "BasicCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Basic::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( BasicCmd_Report == (BasicCmd)_data[0] ) - { - // Level - Log::Write( LogLevel_Info, GetNodeId(), "Received Basic report from node %d: level=%d", GetNodeId(), _data[1] ); - if( !m_ignoreMapping && m_mapping != 0 ) - { - UpdateMappedClass( _instance, m_mapping, _data[1] ); - } - else if( ValueByte* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] ); - value->Release(); - } - return true; - } - - if( BasicCmd_Set == (BasicCmd)_data[0] ) - { - if( m_setAsReport ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received Basic set from node %d: level=%d. Treating it as a Basic report.", GetNodeId(), _data[1] ); - if( !m_ignoreMapping && m_mapping != 0 ) - { - UpdateMappedClass( _instance, m_mapping, _data[1] ); - } - else if( ValueByte* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] ); - value->Release(); - } - } - else - { - // Commmand received from the node. Handle as a notification event - Log::Write( LogLevel_Info, GetNodeId(), "Received Basic set from node %d: level=%d. Sending event notification.", GetNodeId(), _data[1] ); - - Notification* notification = new Notification( Notification::Type_NodeEvent ); - notification->SetHomeNodeIdAndInstance( GetHomeId(), GetNodeId(), _instance ); - notification->SetEvent( _data[1] ); - GetDriver()->QueueNotification( notification ); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a value on the Z-Wave device -//----------------------------------------------------------------------------- -bool Basic::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_Byte == _value.GetID().GetType() ) - { - ValueByte const* value = static_cast(&_value); - - Log::Write( LogLevel_Info, GetNodeId(), "Basic::Set - Setting node %d to level %d", GetNodeId(), value->GetValue() ); - Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( BasicCmd_Set ); - msg->Append( value->GetValue() ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Basic::CreateVars -( - uint8 const _instance -) -{ - if( m_mapping == 0 ) - { - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_Basic, GetCommandClassId(), _instance, 0, "Basic", "", false, false, 0, 0 ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Helper method to set the level -//----------------------------------------------------------------------------- -void Basic::Set -( - uint8 const _level -) -{ - // This may look like a long winded way to do this, but - // it ensures that all the proper notifications get sent. - if( ValueByte* value = static_cast( GetValue( 1, 0 ) ) ) - { - value->Set( _level ); - value->Release(); - } -} - -//----------------------------------------------------------------------------- -// -// Map COMMAND_CLASS_BASIC messages to another command class -//----------------------------------------------------------------------------- -bool Basic::SetMapping -( - uint8 const _commandClassId, - bool const _doLog -) -{ - bool res = false; - - if( _commandClassId != NoOperation::StaticGetCommandClassId() ) - { - if( _doLog ) - { - char str[16]; - snprintf( str, sizeof(str), "0x%02x", _commandClassId ); - string ccstr = str; - if( Node const* node = GetNodeUnsafe() ) - { - if( CommandClass* cc = node->GetCommandClass( _commandClassId ) ) - { - ccstr = cc->GetCommandClassName(); - } - } - if( m_ignoreMapping ) - { - Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC will not be mapped to %s (ignored)", ccstr.c_str() ); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC will be mapped to %s", ccstr.c_str() ); - } - } - m_mapping = _commandClassId; - RemoveValue( 1, 0 ); - res = true; - } - - if( m_mapping == 0 && _doLog ) - { - Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC is not mapped" ); - } - return res; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Basic.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Basic.h deleted file mode 100644 index fc583d6..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Basic.h +++ /dev/null @@ -1,77 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Basic.h -// -// Implementation of the Z-Wave COMMAND_CLASS_BASIC -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Basic_H -#define _Basic_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - - /** \brief Implements COMMAND_CLASS_BASIC (0x20), a Z-Wave device command class. - */ - class Basic: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Basic( _homeId, _nodeId ); } - virtual ~Basic(){} - - static uint8 const StaticGetCommandClassId(){ return 0x20; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_BASIC"; } - - bool SetMapping( uint8 const _commandClassId, bool const _doLog = true ); // Map COMMAND_CLASS_BASIC messages to another command class - uint8 GetMapping(){ return m_mapping; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - void Set( uint8 const _level ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Basic( uint32 const _homeId, uint8 const _nodeId ); - - uint8 m_mapping; - bool m_ignoreMapping; - bool m_setAsReport; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/BasicWindowCovering.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/BasicWindowCovering.cpp deleted file mode 100644 index 550bd53..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/BasicWindowCovering.cpp +++ /dev/null @@ -1,118 +0,0 @@ -//----------------------------------------------------------------------------- -// -// BasicWindowCovering.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_BASIC_WINDOW_COVERING -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "BasicWindowCovering.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" -#include "../value_classes/ValueButton.h" - -using namespace OpenZWave; - -enum BasicWindowCoveringCmd -{ - BasicWindowCoveringCmd_StartLevelChange = 0x01, - BasicWindowCoveringCmd_StopLevelChange = 0x02 -}; - -enum -{ - BasicWindowCoveringIndex_Open = 0, - BasicWindowCoveringIndex_Close -}; - -//----------------------------------------------------------------------------- -// -// Set a value on the Z-Wave device -//----------------------------------------------------------------------------- -bool BasicWindowCovering::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_Button == _value.GetID().GetType() ) - { - ValueButton const* button = static_cast(&_value); - - uint8 action = 0x40; - if( button->GetID().GetIndex() ) // Open is index zero, so non-zero is close. - { - // Close - action = 0; - } - - if( button && button->IsPressed() ) - { - Log::Write( LogLevel_Info, GetNodeId(), "BasicWindowCovering - Start Level Change (%s)", action ? "Open" : "Close" ); - Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( BasicWindowCoveringCmd_StartLevelChange ); - msg->Append( action ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "BasicWindowCovering - Stop Level Change" ); - Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( BasicWindowCoveringCmd_StopLevelChange ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void BasicWindowCovering::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, BasicWindowCoveringIndex_Open, "Open", 0 ); - node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, BasicWindowCoveringIndex_Close, "Close", 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/BasicWindowCovering.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/BasicWindowCovering.h deleted file mode 100644 index 90e3fb2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/BasicWindowCovering.h +++ /dev/null @@ -1,64 +0,0 @@ -//----------------------------------------------------------------------------- -// -// BasicWindowCovering.h -// -// Implementation of the Z-Wave COMMAND_CLASS_BASIC_WINDOW_COVERING -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _BasicWindowCovering_H -#define _BasicWindowCovering_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueButton; - - /** \brief Implements COMMAND_CLASS_BASIC_WINDOW_COVERING (0x50), a Z-Wave device command class. - */ - class BasicWindowCovering: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new BasicWindowCovering( _homeId, _nodeId ); } - virtual ~BasicWindowCovering(){} - - static uint8 const StaticGetCommandClassId(){ return 0x50; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_BASIC_WINDOW_COVERING"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ){ return false; } - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - BasicWindowCovering( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Battery.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Battery.cpp deleted file mode 100644 index 8519ed9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Battery.cpp +++ /dev/null @@ -1,146 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Battery.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_BATTERY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Battery.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" - -using namespace OpenZWave; - -enum BatteryCmd -{ - BatteryCmd_Get = 0x02, - BatteryCmd_Report = 0x03 -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Battery::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Battery::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "BatteryCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( BatteryCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "BatteryCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Battery::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (BatteryCmd_Report == (BatteryCmd)_data[0]) - { - // We have received a battery level report from the Z-Wave device. - // Devices send 0xff instead of zero for a low battery warning. - uint8 batteryLevel = _data[1]; - if( batteryLevel == 0xff ) - { - batteryLevel = 0; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received Battery report from node %d: level=%d", GetNodeId(), batteryLevel ); - - if( ValueByte* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( batteryLevel ); - value->Release(); - } - return true; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Battery::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Battery Level", "%", true, false, 100, 0 ); - } -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Battery.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Battery.h deleted file mode 100644 index 7f550ea..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Battery.h +++ /dev/null @@ -1,65 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Battery.h -// -// Implementation of the Z-Wave COMMAND_CLASS_BATTERY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Battery_H -#define _Battery_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - - /** \brief Implements COMMAND_CLASS_BATTERY (0x80), a Z-Wave device command class. - */ - class Battery: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Battery( _homeId, _nodeId ); } - virtual ~Battery(){} - - static uint8 const StaticGetCommandClassId(){ return 0x80; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_BATTERY"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Battery( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CMakeLists.txt b/lib/ESPiLight/pilight/libs/openzwave/command_classes/CMakeLists.txt deleted file mode 100644 index 1b2bee0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -project(openzwave_command_classes) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.cpp") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CRC16Encap.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/CRC16Encap.cpp deleted file mode 100644 index 98c8a95..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CRC16Encap.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//----------------------------------------------------------------------------- -// -// CRC16Encap.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_CRC_16_ENCAP -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "CRC16Encap.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool CRC16Encap::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - return false; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CRC16Encap.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/CRC16Encap.h deleted file mode 100644 index db51ad9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CRC16Encap.h +++ /dev/null @@ -1,57 +0,0 @@ -//----------------------------------------------------------------------------- -// -// CRC16Encap.h -// -// Implementation of the Z-Wave COMMAND_CLASS_CRC_16_ENCAP -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _CRC16_ENCAP_H -#define _CRC16_ENCAP_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_CRC_16_ENCAP (0x56), a Z-Wave device command class. - */ - class CRC16Encap: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new CRC16Encap( _homeId, _nodeId ); } - virtual ~CRC16Encap(){} - - static uint8 const StaticGetCommandClassId(){ return 0x56; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CRC_16_ENCAP"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - CRC16Encap( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ClimateControlSchedule.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ClimateControlSchedule.cpp deleted file mode 100644 index d2108d8..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ClimateControlSchedule.cpp +++ /dev/null @@ -1,428 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ClimateControlSchedule.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ClimateControlSchedule.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueList.h" -#include "../value_classes/ValueSchedule.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum ClimateControlScheduleCmd -{ - ClimateControlScheduleCmd_Set = 0x01, - ClimateControlScheduleCmd_Get, - ClimateControlScheduleCmd_Report, - ClimateControlScheduleCmd_ChangedGet, - ClimateControlScheduleCmd_ChangedReport, - ClimateControlScheduleCmd_OverrideSet, - ClimateControlScheduleCmd_OverrideGet, - ClimateControlScheduleCmd_OverrideReport -}; - -enum -{ - ClimateControlScheduleIndex_OverrideState = 8, - ClimateControlScheduleIndex_OverrideSetback = 9 -}; - -static char const* c_dayNames[] = -{ - "Invalid", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sunday" -}; - -static char const* c_overrideStateNames[] = -{ - "None", - "Temporary", - "Permanent", - "Invalid" -}; - - -//----------------------------------------------------------------------------- -// -// Read the saved change-counter value -//----------------------------------------------------------------------------- -void ClimateControlSchedule::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - int intVal; - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "change_counter", &intVal ) ) - { - m_changeCounter = (uint8)intVal; - } -} - -//----------------------------------------------------------------------------- -// -// Write the change-counter value -//----------------------------------------------------------------------------- -void ClimateControlSchedule::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); - - char str[8]; - snprintf( str, 8, "%d", m_changeCounter ); - _ccElement->SetAttribute( "change_counter", str ); -} - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool ClimateControlSchedule::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Session ) - { - // See if the schedule has changed since last time - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool ClimateControlSchedule::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - // See if the schedule has changed since last time - Msg* msg = new Msg( "ClimateControlScheduleCmd_ChangedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ClimateControlScheduleCmd_ChangedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ClimateControlSchedule::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ClimateControlScheduleCmd_Report == (ClimateControlScheduleCmd)_data[0] ) - { - uint8 day = _data[1] & 0x07; - - if (day > 7) /* size of c_dayNames */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Day Value was greater than range. Setting to Invalid"); - day = 0; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received climate control schedule report for %s", c_dayNames[day] ); - - if( ValueSchedule* value = static_cast( GetValue( _instance, day ) ) ) - { - // Remove any existing data - value->ClearSwitchPoints(); - - // Parse the switch point data - for( uint8 i=2; i<29; i+=3 ) - { - uint8 setback = _data[i+2]; - if( setback == 0x7f ) - { - // Switch point is unused, so we stop parsing here - break; - } - - uint8 hours = _data[i] & 0x1f; - uint8 minutes = _data[i+1] & 0x3f; - - if( setback == 0x79 ) - { - Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Frost Protection Mode", hours, minutes, c_dayNames[day] ); - } - else if( setback == 0x7a ) - { - Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Energy Saving Mode", hours, minutes, c_dayNames[day] ); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Setback %+.1fC", hours, minutes, ((float)setback)*0.1f ); - } - - value->SetSwitchPoint( hours, minutes, setback ); - } - - if( !value->GetNumSwitchPoints() ) - { - Log::Write( LogLevel_Info, GetNodeId(), " No Switch points have been set" ); - } - - // Notify the user - value->OnValueRefreshed(); - value->Release(); - } - - return true; - } - - if( ClimateControlScheduleCmd_ChangedReport == (ClimateControlScheduleCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received climate control schedule changed report:" ); - - if( _data[1] ) - { - if( _data[1] != m_changeCounter ) - { - m_changeCounter = _data[1]; - - // The schedule has changed and is not in override mode, so request reports for each day - for( int i=1; i<=7; ++i ) - { - char str[64]; - snprintf( str, 64, "Get climate control schedule for %s", c_dayNames[i] ); - - Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( ClimateControlScheduleCmd_Get ); - msg->Append( i ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } - } - } - else - { - // Device is in override mode, so we request details of that instead - Msg* msg = new Msg( "Get climate control schedule override state", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ClimateControlScheduleCmd_OverrideGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } - return true; - } - - if( ClimateControlScheduleCmd_OverrideReport == (ClimateControlScheduleCmd)_data[0] ) - { - uint8 overrideState = _data[1] & 0x03; - if (overrideState > 3) /* size of c_overrideStateNames */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "overrideState Value was greater than range. Setting to Invalid"); - overrideState = 3; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received climate control schedule override report:" ); - Log::Write( LogLevel_Info, GetNodeId(), " Override State: %s:", c_overrideStateNames[overrideState] ); - - if( ValueList* valueList = static_cast( GetValue( _instance, ClimateControlScheduleIndex_OverrideState ) ) ) - { - valueList->OnValueRefreshed( (int)overrideState ); - valueList->Release(); - } - - uint8 setback = _data[2]; - if( overrideState ) - { - if( setback == 0x79 ) - { - Log::Write( LogLevel_Info, GetNodeId(), " Override Setback: Frost Protection Mode" ); - } - else if( setback == 0x7a ) - { - Log::Write( LogLevel_Info, GetNodeId(), " Override Setback: Energy Saving Mode" ); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), " Override Setback: %+.1fC", ((float)setback)*0.1f ); - } - } - - if( ValueByte* valueByte = static_cast( GetValue( _instance, ClimateControlScheduleIndex_OverrideSetback ) ) ) - { - valueByte->OnValueRefreshed( setback ); - valueByte->Release(); - } - - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a value in the device -//----------------------------------------------------------------------------- -bool ClimateControlSchedule::SetValue -( - Value const& _value -) -{ -// bool res = false; - uint8 instance = _value.GetID().GetInstance(); - uint8 idx = _value.GetID().GetIndex(); - - if( idx < 8 ) - { - // Set a schedule - ValueSchedule const* value = static_cast(&_value); - - char str[64]; - snprintf( str, 64, "Set the climate control schedule for %s on node %d", c_dayNames[idx], GetNodeId() ); - - Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, instance ); - msg->Append( GetNodeId() ); - msg->Append( 30 ); - msg->Append( GetCommandClassId() ); - msg->Append( ClimateControlScheduleCmd_Set ); - msg->Append( idx ); // Day of week - - for( uint8 i=0; i<9; ++i ) - { - uint8 hours; - uint8 minutes; - int8 setback; - if( value->GetSwitchPoint( i, &hours, &minutes, &setback ) ) - { - msg->Append( hours ); - msg->Append( minutes ); - msg->Append( setback ); - } - else - { - // Unused switch point - msg->Append( 0 ); - msg->Append( 0 ); - msg->Append( 0x7f ); - } - } - - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } - else - { - // Set an override - ValueList* state = static_cast( GetValue( instance, ClimateControlScheduleIndex_OverrideState ) ); - ValueByte* setback = static_cast( GetValue( instance, ClimateControlScheduleIndex_OverrideSetback ) ); - - if( state && setback ) - { - ValueList::Item const& item = state->GetItem(); - - Msg* msg = new Msg( "Set climate control schedule override state", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, instance ); - msg->Append( GetNodeId() ); - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( ClimateControlScheduleCmd_OverrideSet ); - msg->Append( (uint8)item.m_value ); - msg->Append( setback->GetValue() ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void ClimateControlSchedule::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - // Add a ValueSchedule for each day of the week. - for( uint8 i=0; i<7; ++i ) - { - node->CreateValueSchedule( ValueID::ValueGenre_User, GetCommandClassId(), _instance, i+1, c_dayNames[i+1], "", false, false, 0 ); - } - - // Add values for the override state and setback - vector items; - - ValueList::Item item; - for( uint8 i=0; i<3; ++i ) - { - item.m_label = c_overrideStateNames[i]; - item.m_value = i; - items.push_back( item ); - } - - node->CreateValueList( ValueID::ValueGenre_User, GetCommandClassId(), _instance, ClimateControlScheduleIndex_OverrideState, "Override State", "", false, false, 1, items, 0, 0 ); - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, ClimateControlScheduleIndex_OverrideSetback, "Override Setback", "", false, false, 0, 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ClimateControlSchedule.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ClimateControlSchedule.h deleted file mode 100644 index 36f0abc..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ClimateControlSchedule.h +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ClimateControlSchedule.h -// -// Implementation of the Z-Wave COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ClimateControlSchedule_H -#define _ClimateControlSchedule_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueSchedule; - class ValueList; - class ValueByte; - - /** \brief Implements COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE (0x46), a Z-Wave device command class. - */ - class ClimateControlSchedule: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ClimateControlSchedule( _homeId, _nodeId ); } - virtual ~ClimateControlSchedule(){} - - static uint8 const StaticGetCommandClassId(){ return 0x46; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - ClimateControlSchedule( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ), m_changeCounter( 0 ){} - uint8 m_changeCounter; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Clock.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Clock.cpp deleted file mode 100644 index 267e006..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Clock.cpp +++ /dev/null @@ -1,237 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Clock.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_CLOCK -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Clock.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueList.h" - -using namespace OpenZWave; - -enum ClockCmd -{ - ClockCmd_Set = 0x04, - ClockCmd_Get = 0x05, - ClockCmd_Report = 0x06 -}; - -enum -{ - ClockIndex_Day = 0, - ClockIndex_Hour, - ClockIndex_Minute -}; - -static char const* c_dayNames[] = -{ - "Invalid", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sunday" -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Clock::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Clock::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "ClockCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ClockCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ClockCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Clock::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (ClockCmd_Report == (ClockCmd)_data[0]) - { - uint8 day = _data[1] >> 5; - uint8 hour = _data[1] & 0x1f; - uint8 minute = _data[2]; - - if (day > 7) /* size of c_dayNames */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Day Value was greater than range. Setting to Invalid"); - day = 0; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received Clock report: %s %.2d:%.2d", c_dayNames[day], hour, minute ); - - - if( ValueList* dayValue = static_cast( GetValue( _instance, ClockIndex_Day ) ) ) - { - dayValue->OnValueRefreshed( day ); - dayValue->Release(); - } - if( ValueByte* hourValue = static_cast( GetValue( _instance, ClockIndex_Hour ) ) ) - { - hourValue->OnValueRefreshed( hour ); - hourValue->Release(); - } - if( ValueByte* minuteValue = static_cast( GetValue( _instance, ClockIndex_Minute ) ) ) - { - minuteValue->OnValueRefreshed( minute ); - minuteValue->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a value in the Z-Wave device -//----------------------------------------------------------------------------- -bool Clock::SetValue -( - Value const& _value -) -{ - bool ret = false; - - uint8 instance = _value.GetID().GetInstance(); - - ValueList* dayValue = static_cast( GetValue( instance, ClockIndex_Day ) ); - ValueByte* hourValue = static_cast( GetValue( instance, ClockIndex_Hour ) ); - ValueByte* minuteValue = static_cast( GetValue( instance, ClockIndex_Minute ) ); - - if( dayValue && hourValue && minuteValue ) - { - uint8 day = dayValue->GetItem().m_value; - uint8 hour = hourValue->GetValue(); - uint8 minute = minuteValue->GetValue(); - - Msg* msg = new Msg( "ClockCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, instance ); - msg->Append( GetNodeId() ); - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( ClockCmd_Set ); - msg->Append( ( day << 5 ) | hour ); - msg->Append( minute ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - ret = true; - } - - if( dayValue != NULL ) - { - dayValue->Release(); - } - if( hourValue != NULL ) - { - hourValue->Release(); - } - if( minuteValue != NULL ) - { - minuteValue->Release(); - } - return ret; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Clock::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - vector items; - for( int i=1; i<=7; ++i ) - { - ValueList::Item item; - item.m_label = c_dayNames[i]; - item.m_value = i; - items.push_back( item ); - } - - node->CreateValueList( ValueID::ValueGenre_User, GetCommandClassId(), _instance, ClockIndex_Day, "Day", "", false, false, 1, items, 0, 0 ); - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, ClockIndex_Hour, "Hour", "", false, false, 12, 0 ); - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, ClockIndex_Minute, "Minute", "", false, false, 0, 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Clock.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Clock.h deleted file mode 100644 index 4f8c1bc..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Clock.h +++ /dev/null @@ -1,67 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Clock.h -// -// Implementation of the Z-Wave COMMAND_CLASS_CLOCK -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Clock_H -#define _Clock_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - class ValueList; - - /** \brief Implements COMMAND_CLASS_CLOCK (0x81), a Z-Wave device command class. - */ - class Clock: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Clock( _homeId, _nodeId ); } - virtual ~Clock(){} - - static uint8 const StaticGetCommandClassId(){ return 0x81; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CLOCK"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Clock( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClass.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClass.cpp deleted file mode 100644 index e06a76d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClass.cpp +++ /dev/null @@ -1,805 +0,0 @@ -//----------------------------------------------------------------------------- -// -// CommandClass.cpp -// -// Base class for all Z-Wave Command Classes -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include -#include "../tinyxml.h" -#include "CommandClass.h" -#include "Basic.h" -#include "MultiInstance.h" -#include "CommandClasses.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../Manager.h" -#include "../platform/Log.h" -#include "../value_classes/ValueStore.h" - -using namespace OpenZWave; - -static uint8 const c_sizeMask = 0x07; -static uint8 const c_scaleMask = 0x18; -static uint8 const c_scaleShift = 0x03; -static uint8 const c_precisionMask = 0xe0; -static uint8 const c_precisionShift = 0x05; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -CommandClass::CommandClass -( - uint32 const _homeId, - uint8 const _nodeId -): - m_homeId( _homeId ), - m_nodeId( _nodeId ), - m_version( 1 ), - m_afterMark( false ), - m_createVars( true ), - m_overridePrecision( -1 ), - m_getSupported( true ), - m_isSecured( false ), - m_SecureSupport( true ), - m_staticRequests( 0 ), - m_sentCnt( 0 ), - m_receivedCnt( 0 ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -CommandClass::~CommandClass -( -) -{ - while( !m_endPointMap.empty() ) - { - map::iterator it = m_endPointMap.begin(); - m_endPointMap.erase( it ); - } - while ( !m_RefreshClassValues.empty() ) - { - for (unsigned int i = 0; i < m_RefreshClassValues.size(); i++) - { - RefreshValue *rcc = m_RefreshClassValues.at(i); - while(!rcc->RefreshClasses.empty()) { - delete rcc->RefreshClasses.back(); - rcc->RefreshClasses.pop_back(); - } -// for (unsigned int j = 0; j < rcc->RefreshClasses.size(); i++) -// { -// delete rcc->RefreshClasses[j]; -// } - rcc->RefreshClasses.clear(); - delete rcc; - } - m_RefreshClassValues.clear(); - } - -} - -//----------------------------------------------------------------------------- -// -// Get a pointer to our driver -//----------------------------------------------------------------------------- -Driver* CommandClass::GetDriver -( -)const -{ - return( Manager::Get()->GetDriver( m_homeId ) ); -} - -//----------------------------------------------------------------------------- -// -// Get a pointer to our node without locking the mutex -//----------------------------------------------------------------------------- -Node* CommandClass::GetNodeUnsafe -( -)const -{ - return( GetDriver()->GetNodeUnsafe( m_nodeId ) ); -} - -//----------------------------------------------------------------------------- -// -// Get a pointer to a value by its instance and index -//----------------------------------------------------------------------------- -Value* CommandClass::GetValue -( - uint8 const _instance, - uint8 const _index -) -{ - Value* value = NULL; - if( Node* node = GetNodeUnsafe() ) - { - value = node->GetValue( GetCommandClassId(), _instance, _index ); - } - return value; -} - -//----------------------------------------------------------------------------- -// -// Remove a value by its instance and index -//----------------------------------------------------------------------------- -bool CommandClass::RemoveValue -( - uint8 const _instance, - uint8 const _index -) -{ - if( Node* node = GetNodeUnsafe() ) - { - return node->RemoveValue( GetCommandClassId(), _instance, _index ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Instances as set by the MultiInstance V1 command class -//----------------------------------------------------------------------------- -void CommandClass::SetInstances -( - uint8 const _instances -) -{ - // Ensure we have a set of reported variables for each new instance - if( !m_afterMark ) - { - for( uint8 i=0; i<_instances; ++i ) - { - SetInstance( i+1 ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Instances as set by the MultiChannel (i.e. MultiInstance V2) command class -//----------------------------------------------------------------------------- -void CommandClass::SetInstance -( - uint8 const _endPoint -) -{ - if( !m_instances.IsSet( _endPoint ) ) - { - m_instances.Set( _endPoint ); - if( IsCreateVars() ) - { - CreateVars( _endPoint ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Read the saved command class data -//----------------------------------------------------------------------------- -void CommandClass::ReadXML -( - TiXmlElement const* _ccElement -) -{ - int32 intVal; - char const* str; - - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "version", &intVal ) ) - { - m_version = (uint8)intVal; - } - - uint8 instances = 1; - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "instances", &intVal ) ) - { - instances = (uint8)intVal; - } - - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "request_flags", &intVal ) ) - { - m_staticRequests = (uint8)intVal; - } - - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "override_precision", &intVal ) ) - { - m_overridePrecision = (int8)intVal; - } - - str = _ccElement->Attribute( "after_mark" ); - if( str ) - { - m_afterMark = !strcmp( str, "true" ); - } - - str = _ccElement->Attribute( "create_vars" ); - if( str ) - { - m_createVars = !strcmp( str, "true" ); - } - - // Make sure previously created values are removed if create_vars=false - if( !m_createVars ) - { - if( Node* node = GetNodeUnsafe() ) - { - node->GetValueStore()->RemoveCommandClassValues( GetCommandClassId() ); - } - } - - str = _ccElement->Attribute( "getsupported" ); - if( str ) - { - m_getSupported = !strcmp( str, "true" ); - } - - str = _ccElement->Attribute( "issecured" ); - if( str ) - { - m_isSecured = !strcmp( str, "true" ); - } - // Setting the instance count will create all the values. - SetInstances( instances ); - - // Apply any differences from the saved XML to the values - TiXmlElement const* child = _ccElement->FirstChildElement(); - while( child ) - { - str = child->Value(); - if( str ) - { - if( !strcmp( str, "Instance" ) ) - { - uint8 instance = 0; - // Add an instance to the command class - if( TIXML_SUCCESS == child->QueryIntAttribute( "index", &intVal ) ) - { - instance = (uint8)intVal; - SetInstance( instance ); - } - // See if its associated endpoint is present - if( TIXML_SUCCESS == child->QueryIntAttribute( "endpoint", &intVal ) ) - { - uint8 endpoint = (uint8)intVal; - SetEndPoint( instance, endpoint ); - } - } - else if( !strcmp( str, "Value" ) ) - { - // Apply any differences from the saved XML to the value - GetNodeUnsafe()->ReadValueFromXML( GetCommandClassId(), child ); - } - else if (!strcmp( str, "TriggerRefreshValue" ) ) - { - ReadValueRefreshXML(child); - } - } - - child = child->NextSiblingElement(); - } -} - -//----------------------------------------------------------------------------- -// -// Read the config that contains a list of Values that should be refreshed when -// we recieve u updated Value from a device. (This helps Yale Door Locks, which send a -// Alarm Report instead of DoorLock Report when the status of the Door Lock is changed -//----------------------------------------------------------------------------- -void CommandClass::ReadValueRefreshXML -( - TiXmlElement const* _ccElement -) -{ - - char const* str; - bool ok = false; - const char *genre; - RefreshValue *rcc = new RefreshValue(); - rcc->cc = GetCommandClassId(); - genre = _ccElement->Attribute( "Genre" ); - rcc->genre = Value::GetGenreEnumFromName(genre); - _ccElement->QueryIntAttribute( "Instance", (int*)&rcc->instance); - _ccElement->QueryIntAttribute( "Index", (int*)&rcc->index); - Log::Write(LogLevel_Info, GetNodeId(), "Value Refresh triggered by CommandClass: %s, Genre: %d, Instance: %d, Index: %d for:", GetCommandClassName().c_str(), rcc->genre, rcc->instance, rcc->index); - TiXmlElement const* child = _ccElement->FirstChildElement(); - while( child ) - { - str = child->Value(); - if( str ) - { - if ( !strcmp(str, "RefreshClassValue")) - { - RefreshValue *arcc = new RefreshValue(); - if (child->QueryIntAttribute( "CommandClass", (int*)&arcc->cc) != TIXML_SUCCESS) { - Log::Write(LogLevel_Warning, GetNodeId(), " Invalid XML - CommandClass Attribute is wrong type or missing"); - continue; - } - if (child->QueryIntAttribute( "RequestFlags", (int*)&arcc->genre) != TIXML_SUCCESS) { - Log::Write(LogLevel_Warning, GetNodeId(), " Invalid XML - RequestFlags Attribute is wrong type or missing"); - continue; - } - if (child->QueryIntAttribute( "Instance", (int*)&arcc->instance) != TIXML_SUCCESS) { - Log::Write(LogLevel_Warning, GetNodeId(), " Invalid XML - Instance Attribute is wrong type or missing"); - continue; - } - if (child->QueryIntAttribute( "Index", (int*)&arcc->index) != TIXML_SUCCESS) { - Log::Write(LogLevel_Warning, GetNodeId(), " Invalid XML - Index Attribute is wrong type or missing"); - continue; - } - Log::Write(LogLevel_Info, GetNodeId(), " CommandClass: %s, RequestFlags: %d, Instance: %d, Index: %d", CommandClasses::GetName(arcc->cc).c_str(), arcc->genre, arcc->instance, arcc->index); - rcc->RefreshClasses.push_back(arcc); - ok = true; - } - else - { - Log::Write(LogLevel_Warning, GetNodeId(), "Got Unhandled Child Entry in TriggerRefreshValue XML Config: %s", str); - } - } - child = child->NextSiblingElement(); - } - if (ok == true) { - m_RefreshClassValues.push_back( rcc ); - } else { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to add a RefreshClassValue from XML"); - delete rcc; - } -} - -//----------------------------------------------------------------------------- -// -// Scan our m_RefreshClassValues vector to see if we should call any other -// Command Classes to refresh their value -//----------------------------------------------------------------------------- - -bool CommandClass::CheckForRefreshValues ( - Value const* _value -) -{ - if (m_RefreshClassValues.empty()) - { - //Log::Write(LogLevel_Debug, GetNodeId(), "Bailing out of CheckForRefreshValues"); - return false; - } - Node* node = GetNodeUnsafe(); - if( node != NULL ) - { - for (uint32 i = 0; i < m_RefreshClassValues.size(); i++) - { - RefreshValue *rcc = m_RefreshClassValues.at(i); - //Log::Write(LogLevel_Debug, GetNodeId(), "Checking Value Against RefreshClassList: CommandClass %s = %s, Genre %d = %d, Instance %d = %d, Index %d = %d", CommandClasses::GetName(rcc->cc).c_str(), CommandClasses::GetName(_value->GetID().GetCommandClassId()).c_str(), rcc->genre, _value->GetID().GetGenre(), rcc->instance, _value->GetID().GetInstance(), rcc->index, _value->GetID().GetIndex()); - if ((rcc->genre == _value->GetID().GetGenre()) && (rcc->instance == _value->GetID().GetInstance()) && (rcc->index == _value->GetID().GetIndex()) ) - { - /* we got a match..... */ - for (uint32 j = 0; j < rcc->RefreshClasses.size(); j++) - { - RefreshValue *arcc = rcc->RefreshClasses.at(j); - Log::Write(LogLevel_Debug, GetNodeId(), "Requesting Refresh of Value: CommandClass: %s Genre %d, Instance %d, Index %d", CommandClasses::GetName(arcc->cc).c_str(), arcc->genre, arcc->instance, arcc->index); - if( CommandClass* cc = node->GetCommandClass( arcc->cc ) ) - { - cc->RequestValue(arcc->genre, arcc->index, arcc->instance, Driver::MsgQueue_Send); - } - } - } - } - } - else /* Driver */ - { - Log::Write(LogLevel_Warning, GetNodeId(), "Can't get Node"); - } - return true; -} - -//----------------------------------------------------------------------------- -// -// Save the static node configuration data -//----------------------------------------------------------------------------- -void CommandClass::WriteXML -( - TiXmlElement* _ccElement -) -{ - char str[32]; - - snprintf( str, sizeof(str), "%d", GetCommandClassId() ); - _ccElement->SetAttribute( "id", str ); - _ccElement->SetAttribute( "name", GetCommandClassName().c_str() ); - - snprintf( str, sizeof(str), "%d", GetVersion() ); - _ccElement->SetAttribute( "version", str ); - - if( m_staticRequests ) - { - snprintf( str, sizeof(str), "%d", m_staticRequests ); - _ccElement->SetAttribute( "request_flags", str ); - } - - if( m_overridePrecision >= 0 ) - { - snprintf( str, sizeof(str), "%d", m_overridePrecision ); - _ccElement->SetAttribute( "override_precision", str ); - } - - if( m_afterMark ) - { - _ccElement->SetAttribute( "after_mark", "true" ); - } - - if( !m_createVars ) - { - _ccElement->SetAttribute( "create_vars", "false" ); - } - - if( !m_getSupported ) - { - _ccElement->SetAttribute( "getsupported", "false" ); - } - if ( m_isSecured ) - { - _ccElement->SetAttribute( "issecured", "true" ); - } - - - // Write out the instances - for( Bitfield::Iterator it = m_instances.Begin(); it != m_instances.End(); ++ it ) - { - TiXmlElement* instanceElement = new TiXmlElement( "Instance" ); - _ccElement->LinkEndChild( instanceElement ); - - snprintf( str, sizeof(str), "%d", *it ); - instanceElement->SetAttribute( "index", str ); - - map::iterator eit = m_endPointMap.find( *it ); - if( eit != m_endPointMap.end() ) - { - snprintf( str, sizeof(str), "%d", eit->second ); - instanceElement->SetAttribute( "endpoint", str ); - } - } - - // Write out the values for this command class - ValueStore* store = GetNodeUnsafe()->GetValueStore(); - for( ValueStore::Iterator it = store->Begin(); it != store->End(); ++it ) - { - Value* value = it->second; - if( value->GetID().GetCommandClassId() == GetCommandClassId() ) - { - TiXmlElement* valueElement = new TiXmlElement( "Value" ); - _ccElement->LinkEndChild( valueElement ); - value->WriteXML( valueElement ); - } - } - // Write out the TriggerRefreshValue if it exists - for (uint32 i = 0; i < m_RefreshClassValues.size(); i++) - { - RefreshValue *rcc = m_RefreshClassValues.at(i); - TiXmlElement* RefreshElement = new TiXmlElement("TriggerRefreshValue"); - _ccElement->LinkEndChild( RefreshElement ); - RefreshElement->SetAttribute("Genre", Value::GetGenreNameFromEnum((ValueID::ValueGenre)rcc->genre)); - RefreshElement->SetAttribute("Instance", rcc->instance); - RefreshElement->SetAttribute("Index", rcc->index); - for (uint32 j = 0; j < rcc->RefreshClasses.size(); j++) - { - RefreshValue *arcc = rcc->RefreshClasses.at(j); - TiXmlElement *ClassElement = new TiXmlElement("RefreshClassValue"); - RefreshElement->LinkEndChild(ClassElement); - ClassElement->SetAttribute("CommandClass", arcc->cc); - ClassElement->SetAttribute("RequestFlags", arcc->genre); - ClassElement->SetAttribute("Instance", arcc->instance); - ClassElement->SetAttribute("Index", arcc->index); - } - } -} - -//----------------------------------------------------------------------------- -// -// Read a value from a variable length sequence of bytes -//----------------------------------------------------------------------------- -string CommandClass::ExtractValue -( - uint8 const* _data, - uint8* _scale, - uint8* _precision, - uint8 _valueOffset // = 1 -)const -{ - uint8 const size = _data[0] & c_sizeMask; - uint8 const precision = (_data[0] & c_precisionMask) >> c_precisionShift; - - if( _scale ) - { - *_scale = (_data[0] & c_scaleMask) >> c_scaleShift; - } - - if( _precision ) - { - *_precision = precision; - } - - uint32 value = 0; - uint8 i; - for( i=0; idecimal_point); - - // Copy the buffer into res - res += &numBuf[start]; - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Add a value to a message as a sequence of bytes -//----------------------------------------------------------------------------- -void CommandClass::AppendValue -( - Msg* _msg, - string const& _value, - uint8 const _scale -)const -{ - uint8 precision; - uint8 size; - int32 val = ValueToInteger( _value, &precision, &size ); - - _msg->Append( (precision<0; --i, shift-=8 ) - { - _msg->Append( (uint8)(val >> shift) ); - } -} - -//----------------------------------------------------------------------------- -// -// Get the number of bytes that would be added by a call to AppendValue -//----------------------------------------------------------------------------- -uint8 const CommandClass::GetAppendValueSize -( - string const& _value -)const -{ - uint8 size; - ValueToInteger( _value, NULL, &size ); - return size; -} - -//----------------------------------------------------------------------------- -// -// Convert a decimal string to an integer and report the precision and -// number of bytes required to store the value. -//----------------------------------------------------------------------------- -int32 CommandClass::ValueToInteger -( - string const& _value, - uint8* o_precision, - uint8* o_size -)const -{ - int32 val; - uint8 precision; - - // Find the decimal point - size_t pos = _value.find_first_of( "." ); - if( pos == string::npos ) - pos = _value.find_first_of( "," ); - - if( pos == string::npos ) - { - // No decimal point - precision = 0; - - // Convert the string to an integer - val = atol( _value.c_str() ); - } - else - { - // Remove the decimal point and convert to an integer - precision = (uint8) ((_value.size()-pos)-1); - - string str = _value.substr( 0, pos ) + _value.substr( pos+1 ); - val = atol( str.c_str() ); - } - - if ( m_overridePrecision > 0 ) - { - while ( precision < m_overridePrecision ) { - precision++; - val *= 10; - } - } - - if ( o_precision ) *o_precision = precision; - - if( o_size ) - { - // Work out the size as either 1, 2 or 4 bytes - *o_size = 4; - if( val < 0 ) - { - if( ( val & 0xffffff80 ) == 0xffffff80 ) - { - *o_size = 1; - } - else if( ( val & 0xffff8000 ) == 0xffff8000 ) - { - *o_size = 2; - } - } - else - { - if( ( val & 0xffffff00 ) == 0 ) - { - *o_size = 1; - } - else if( ( val & 0xffff0000 ) == 0 ) - { - *o_size = 2; - } - } - } - - return val; -} - -//----------------------------------------------------------------------------- -// -// Update the mapped class if there is one with BASIC level -//----------------------------------------------------------------------------- -void CommandClass::UpdateMappedClass -( - uint8 const _instance, - uint8 const _classId, - uint8 const _level -) -{ - if( _classId ) - { - if( Node* node = GetNodeUnsafe() ) - { - CommandClass* cc = node->GetCommandClass( _classId ); - if( node->GetCurrentQueryStage() == Node::QueryStage_Complete && cc != NULL ) - { - cc->SetValueBasic( _instance, _level ); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// The static data for this command class has been read from the device -//----------------------------------------------------------------------------- -void CommandClass::ClearStaticRequest -( - uint8 _request -) -{ - m_staticRequests &= ~_request; -} - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool CommandClass::RequestStateForAllInstances -( - uint32 const _requestFlags, - Driver::MsgQueue const _queue -) -{ - bool res = false; - if( m_createVars ) - { - if( Node* node = GetNodeUnsafe() ) - { - MultiInstance* multiInstance = static_cast( node->GetCommandClass( MultiInstance::StaticGetCommandClassId() ) ); - if( multiInstance != NULL ) - { - for( Bitfield::Iterator it = m_instances.Begin(); it != m_instances.End(); ++it ) - { - res |= RequestState( _requestFlags, (uint8)*it, _queue ); - } - } - else - { - res = RequestState( _requestFlags, 1, _queue ); - } - } - } - - return res; -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClass.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClass.h deleted file mode 100644 index b1cc861..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClass.h +++ /dev/null @@ -1,198 +0,0 @@ -//----------------------------------------------------------------------------- -// -// CommandClass.h -// -// Base class for all Z-Wave Command Classes -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _CommandClass_H -#define _CommandClass_H - -#include -#include -#include -#include "../Defs.h" -#include "../Bitfield.h" -#include "../Driver.h" - -namespace OpenZWave -{ - class Msg; - class Node; - class Value; - - /** \brief Base class for all Z-Wave command classes. - */ - class OPENZWAVE_EXPORT CommandClass - { - - public: - enum - { - RequestFlag_Static = 0x00000001, /**< Values that never change. */ - RequestFlag_Session = 0x00000002, /**< Values that change infrequently, and so only need to be requested at start up, or via a manual refresh. */ - RequestFlag_Dynamic = 0x00000004, /**< Values that change and will be requested if polling is enabled on the node. */ - }; - - CommandClass( uint32 const _homeId, uint8 const _nodeId ); - virtual ~CommandClass(); - - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ){ return false; } - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ) { return false; } - - virtual uint8 const GetCommandClassId()const = 0; - virtual string const GetCommandClassName()const = 0; - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ) = 0; - virtual bool SetValue( Value const& _value ){ return false; } - virtual void SetValueBasic( uint8 const _instance, uint8 const _level ){} // Class specific handling of BASIC value mapping - virtual void SetVersion( uint8 const _version ){ m_version = _version; } - - bool RequestStateForAllInstances( uint32 const _requestFlags, Driver::MsgQueue const _queue ); - bool CheckForRefreshValues(Value const* _value ); - - // The highest version number of the command class implemented by OpenZWave. We only need - // to do version gets on command classes that override this with a number greater than one. - virtual uint8 GetMaxVersion(){ return 1; } - - uint8 GetVersion()const{ return m_version; } - Bitfield const* GetInstances()const{ return &m_instances; } - uint32 GetHomeId()const{ return m_homeId; } - uint8 GetNodeId()const{ return m_nodeId; } - Driver* GetDriver()const; - Node* GetNodeUnsafe()const; - Value* GetValue( uint8 const _instance, uint8 const _index ); - bool RemoveValue( uint8 const _instance, uint8 const _index ); - uint8 GetEndPoint( uint8 const _instance ) - { - map::iterator it = m_endPointMap.find( _instance ); - return( it == m_endPointMap.end() ? 0 : it->second ); - } - uint8 GetInstance( uint8 const _endPoint ) - { - for( map::iterator it = m_endPointMap.begin(); it != m_endPointMap.end(); ++it ) - { - if( _endPoint == it->second ) - { - return it->first; - } - } - return 0; - } - - void SetInstances( uint8 const _instances ); - void SetInstance( uint8 const _endPoint ); - void SetAfterMark(){ m_afterMark = true; } - void SetEndPoint( uint8 const _instance, uint8 const _endpoint){ m_endPointMap[_instance] = _endpoint; } - bool IsAfterMark()const{ return m_afterMark; } - bool IsCreateVars()const{ return m_createVars; } - bool IsGetSupported()const{ return m_getSupported; } - bool IsSecured()const{ return m_isSecured; } - void SetSecured(){ m_isSecured = true; } - bool IsSecureSupported()const { return m_SecureSupport; } - void ClearSecureSupport() { m_SecureSupport = false; } - void SetSecureSupport() { m_SecureSupport = true; } - - // Helper methods - string ExtractValue( uint8 const* _data, uint8* _scale, uint8* _precision, uint8 _valueOffset = 1 )const; - - /** - * Append a floating-point value to a message. - * \param _msg The message to which the value should be appended. - * \param _value A string containing a decimal number to be appended. - * \param _scale A byte indicating the scale corresponding to this value (e.g., 1=F and 0=C for temperatures). - * \see Msg - */ - void AppendValue( Msg* _msg, string const& _value, uint8 const _scale )const; - uint8 const GetAppendValueSize( string const& _value )const; - int32 ValueToInteger( string const& _value, uint8* o_precision, uint8* o_size )const; - - void UpdateMappedClass( uint8 const _instance, uint8 const _classId, uint8 const _value ); // Update mapped class's value from BASIC class - - typedef struct RefreshValue { - uint8 cc; - uint8 genre; - uint8 instance; - uint8 index; - std::vector RefreshClasses; - } RefreshValue; - - protected: - virtual void CreateVars( uint8 const _instance ){} - void ReadValueRefreshXML ( TiXmlElement const* _ccElement ); - - public: - virtual void CreateVars( uint8 const _instance, uint8 const _index ){} - - private: - uint32 m_homeId; - uint8 m_nodeId; - uint8 m_version; - Bitfield m_instances; -OPENZWAVE_EXPORT_WARNINGS_OFF - map m_endPointMap; -OPENZWAVE_EXPORT_WARNINGS_ON - bool m_afterMark; // Set to true if the command class is listed after COMMAND_CLASS_MARK, and should not create any values. - bool m_createVars; // Do we want to create variables - int8 m_overridePrecision; // Override precision when writing values if >=0 - bool m_getSupported; // Get operation supported - bool m_isSecured; // is this command class secured with the Security Command Class - bool m_SecureSupport; // Does this commandclass support secure encryption (eg, the Security CC doesn't encrypt itself, so it doesn't support encryption) - std::vector m_RefreshClassValues; // what Command Class Values should we refresh ? - - //----------------------------------------------------------------------------- - // Record which items of static data have been read from the device - //----------------------------------------------------------------------------- - public: - enum StaticRequest - { - StaticRequest_Instances = 0x01, - StaticRequest_Values = 0x02, - StaticRequest_Version = 0x04 - }; - - bool HasStaticRequest( uint8 _request )const{ return( (m_staticRequests & _request) != 0 ); } - void SetStaticRequest( uint8 _request ){ m_staticRequests |= _request; } - void ClearStaticRequest( uint8 _request ); - - private: - uint8 m_staticRequests; - - //----------------------------------------------------------------------------- - // Statistics - //----------------------------------------------------------------------------- - public: - uint32 GetSentCnt()const{ return m_sentCnt; } - uint32 GetReceivedCnt()const{ return m_receivedCnt; } - void SentCntIncr(){ m_sentCnt++; } - void ReceivedCntIncr(){ m_receivedCnt++; } - - private: - uint32 m_sentCnt; // Number of messages sent from this command class. - uint32 m_receivedCnt; // Number of messages received from this commandclass. - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClasses.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClasses.cpp deleted file mode 100644 index dfccc21..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClasses.cpp +++ /dev/null @@ -1,316 +0,0 @@ -//----------------------------------------------------------------------------- -// -// CommandClasses.cpp -// -// Singleton holding methods to create each command class object -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include - -#include "CommandClasses.h" - -using namespace OpenZWave; - -#include "Alarm.h" -#include "ApplicationStatus.h" -#include "Association.h" -#include "AssociationCommandConfiguration.h" -#include "Basic.h" -#include "BasicWindowCovering.h" -#include "Battery.h" -#include "ClimateControlSchedule.h" -#include "Clock.h" -#include "Configuration.h" -#include "ControllerReplication.h" -#include "CRC16Encap.h" -#include "DoorLock.h" -#include "DoorLockLogging.h" -#include "EnergyProduction.h" -#include "Hail.h" -#include "Indicator.h" -#include "Language.h" -#include "Lock.h" -#include "ManufacturerSpecific.h" -#include "Meter.h" -#include "MeterPulse.h" -#include "MultiCmd.h" -#include "MultiInstance.h" -#include "MultiInstanceAssociation.h" -#include "NodeNaming.h" -#include "NoOperation.h" -#include "Powerlevel.h" -#include "Proprietary.h" -#include "Protection.h" -#include "SceneActivation.h" -#include "Security.h" -#include "SensorAlarm.h" -#include "SensorBinary.h" -#include "SensorMultilevel.h" -#include "SwitchAll.h" -#include "SwitchBinary.h" -#include "SwitchMultilevel.h" -#include "SwitchToggleBinary.h" -#include "SwitchToggleMultilevel.h" -#include "TimeParameters.h" -#include "ThermostatFanMode.h" -#include "ThermostatFanState.h" -#include "ThermostatMode.h" -#include "ThermostatOperatingState.h" -#include "ThermostatSetpoint.h" -#include "UserCode.h" -#include "Version.h" -#include "WakeUp.h" - -#include "../value_classes/ValueBool.h" -#include "../value_classes/ValueButton.h" -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueDecimal.h" -#include "../value_classes/ValueInt.h" -#include "../value_classes/ValueList.h" -#include "../value_classes/ValueSchedule.h" -#include "../value_classes/ValueShort.h" -#include "../value_classes/ValueString.h" - -#include "../Manager.h" -#include "../Options.h" -#include "../Utils.h" - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -CommandClasses::CommandClasses -( -) -{ - memset( m_commandClassCreators, 0, sizeof(pfnCreateCommandClass_t)*256 ); - memset( m_supportedCommandClasses, 0, sizeof(uint32)*8 ); -} - -//----------------------------------------------------------------------------- -// -// Static method to determine whether a command class is supported -//----------------------------------------------------------------------------- -bool CommandClasses::IsSupported -( - uint8 const _commandClassId -) -{ - // Test the bit representing the command class - return( (Get().m_supportedCommandClasses[_commandClassId>>5] & (1u<<(_commandClassId&0x1f))) != 0 ); -} -string CommandClasses::GetName( - uint8 const _commandClassId -) -{ - for (std::map::iterator it = Get().m_namesToIDs.begin(); it != Get().m_namesToIDs.end(); it++) { - if (it->second == _commandClassId) - return it->first; - } - return string("Unknown"); -} -//----------------------------------------------------------------------------- -// -// Static method to register a command class creator method -//----------------------------------------------------------------------------- -void CommandClasses::Register -( - uint8 const _commandClassId, - string const& _commandClassName, - pfnCreateCommandClass_t _creator -) -{ - m_commandClassCreators[_commandClassId] = _creator; - - // Set the bit representing the command class - Get().m_supportedCommandClasses[_commandClassId>>5] |= (1u<<(_commandClassId&0x1f)); - - m_namesToIDs[_commandClassName] = _commandClassId; -} - -//----------------------------------------------------------------------------- -// -// Create a command class object using the registered method -//----------------------------------------------------------------------------- -CommandClass* CommandClasses::CreateCommandClass -( - uint8 const _commandClassId, - uint32 const _homeId, - uint8 const _nodeId -) -{ - // Get a pointer to the required CommandClass's Create method - pfnCreateCommandClass_t creator = Get().m_commandClassCreators[_commandClassId]; - if( NULL == creator ) - { - return NULL; - } - - // Create an instance of the command class - return creator( _homeId, _nodeId ); -} - -//----------------------------------------------------------------------------- -// -// Register all our implemented command classes -//----------------------------------------------------------------------------- -void CommandClasses::RegisterCommandClasses -( -) -{ - CommandClasses& cc = Get(); - cc.Register( Alarm::StaticGetCommandClassId(), Alarm::StaticGetCommandClassName(), Alarm::Create ); - cc.Register( ApplicationStatus::StaticGetCommandClassId(), ApplicationStatus::StaticGetCommandClassName(), ApplicationStatus::Create ); - cc.Register( Association::StaticGetCommandClassId(), Association::StaticGetCommandClassName(), Association::Create ); - cc.Register( AssociationCommandConfiguration::StaticGetCommandClassId(), AssociationCommandConfiguration::StaticGetCommandClassName(), AssociationCommandConfiguration::Create ); - cc.Register( Basic::StaticGetCommandClassId(), Basic::StaticGetCommandClassName(), Basic::Create ); - cc.Register( BasicWindowCovering::StaticGetCommandClassId(), BasicWindowCovering::StaticGetCommandClassName(), BasicWindowCovering::Create ); - cc.Register( Battery::StaticGetCommandClassId(), Battery::StaticGetCommandClassName(), Battery::Create ); - cc.Register( ClimateControlSchedule::StaticGetCommandClassId(), ClimateControlSchedule::StaticGetCommandClassName(), ClimateControlSchedule::Create ); - cc.Register( Clock::StaticGetCommandClassId(), Clock::StaticGetCommandClassName(), Clock::Create ); - cc.Register( Configuration::StaticGetCommandClassId(), Configuration::StaticGetCommandClassName(), Configuration::Create ); - cc.Register( ControllerReplication::StaticGetCommandClassId(), ControllerReplication::StaticGetCommandClassName(), ControllerReplication::Create ); - cc.Register( CRC16Encap::StaticGetCommandClassId(), CRC16Encap::StaticGetCommandClassName(), CRC16Encap::Create ); - cc.Register( DoorLock::StaticGetCommandClassId(), DoorLock::StaticGetCommandClassName(), DoorLock::Create ); - cc.Register( DoorLockLogging::StaticGetCommandClassId(), DoorLockLogging::StaticGetCommandClassName(), DoorLockLogging::Create); - cc.Register( EnergyProduction::StaticGetCommandClassId(), EnergyProduction::StaticGetCommandClassName(), EnergyProduction::Create ); - cc.Register( Hail::StaticGetCommandClassId(), Hail::StaticGetCommandClassName(), Hail::Create ); - cc.Register( Indicator::StaticGetCommandClassId(), Indicator::StaticGetCommandClassName(), Indicator::Create ); - cc.Register( Language::StaticGetCommandClassId(), Language::StaticGetCommandClassName(), Language::Create ); - cc.Register( Lock::StaticGetCommandClassId(), Lock::StaticGetCommandClassName(), Lock::Create ); - cc.Register( ManufacturerSpecific::StaticGetCommandClassId(), ManufacturerSpecific::StaticGetCommandClassName(), ManufacturerSpecific::Create ); - cc.Register( Meter::StaticGetCommandClassId(), Meter::StaticGetCommandClassName(), Meter::Create ); - cc.Register( MeterPulse::StaticGetCommandClassId(), MeterPulse::StaticGetCommandClassName(), MeterPulse::Create ); - cc.Register( MultiCmd::StaticGetCommandClassId(), MultiCmd::StaticGetCommandClassName(), MultiCmd::Create ); - cc.Register( MultiInstance::StaticGetCommandClassId(), MultiInstance::StaticGetCommandClassName(), MultiInstance::Create ); - cc.Register( MultiInstanceAssociation::StaticGetCommandClassId(), MultiInstanceAssociation::StaticGetCommandClassName(), MultiInstanceAssociation::Create ); - cc.Register( NodeNaming::StaticGetCommandClassId(), NodeNaming::StaticGetCommandClassName(), NodeNaming::Create ); - cc.Register( NoOperation::StaticGetCommandClassId(), NoOperation::StaticGetCommandClassName(), NoOperation::Create ); - cc.Register( Powerlevel::StaticGetCommandClassId(), Powerlevel::StaticGetCommandClassName(), Powerlevel::Create ); - cc.Register( Proprietary::StaticGetCommandClassId(), Proprietary::StaticGetCommandClassName(), Proprietary::Create ); - cc.Register( Protection::StaticGetCommandClassId(), Protection::StaticGetCommandClassName(), Protection::Create ); - cc.Register( SceneActivation::StaticGetCommandClassId(), SceneActivation::StaticGetCommandClassName(), SceneActivation::Create ); - cc.Register( Security::StaticGetCommandClassId(), Security::StaticGetCommandClassName(), Security::Create); - cc.Register( SensorAlarm::StaticGetCommandClassId(), SensorAlarm::StaticGetCommandClassName(), SensorAlarm::Create ); - cc.Register( SensorBinary::StaticGetCommandClassId(), SensorBinary::StaticGetCommandClassName(), SensorBinary::Create ); - cc.Register( SensorMultilevel::StaticGetCommandClassId(), SensorMultilevel::StaticGetCommandClassName(), SensorMultilevel::Create ); - cc.Register( SwitchAll::StaticGetCommandClassId(), SwitchAll::StaticGetCommandClassName(), SwitchAll::Create ); - cc.Register( SwitchBinary::StaticGetCommandClassId(), SwitchBinary::StaticGetCommandClassName(), SwitchBinary::Create ); - cc.Register( SwitchMultilevel::StaticGetCommandClassId(), SwitchMultilevel::StaticGetCommandClassName(), SwitchMultilevel::Create ); - cc.Register( SwitchToggleBinary::StaticGetCommandClassId(), SwitchToggleBinary::StaticGetCommandClassName(), SwitchToggleBinary::Create ); - cc.Register( SwitchToggleMultilevel::StaticGetCommandClassId(), SwitchToggleMultilevel::StaticGetCommandClassName(), SwitchToggleMultilevel::Create ); - cc.Register( TimeParameters::StaticGetCommandClassId(), TimeParameters::StaticGetCommandClassName(), TimeParameters::Create); - cc.Register( ThermostatFanMode::StaticGetCommandClassId(), ThermostatFanMode::StaticGetCommandClassName(), ThermostatFanMode::Create ); - cc.Register( ThermostatFanState::StaticGetCommandClassId(), ThermostatFanState::StaticGetCommandClassName(), ThermostatFanState::Create ); - cc.Register( ThermostatMode::StaticGetCommandClassId(), ThermostatMode::StaticGetCommandClassName(), ThermostatMode::Create ); - cc.Register( ThermostatOperatingState::StaticGetCommandClassId(), ThermostatOperatingState::StaticGetCommandClassName(), ThermostatOperatingState::Create ); - cc.Register( ThermostatSetpoint::StaticGetCommandClassId(), ThermostatSetpoint::StaticGetCommandClassName(), ThermostatSetpoint::Create ); - cc.Register( UserCode::StaticGetCommandClassId(), UserCode::StaticGetCommandClassName(), UserCode::Create ); - cc.Register( Version::StaticGetCommandClassId(), Version::StaticGetCommandClassName(), Version::Create ); - cc.Register( WakeUp::StaticGetCommandClassId(), WakeUp::StaticGetCommandClassName(), WakeUp::Create ); - - // Now all the command classes have been registered, we can modify the - // supported command classes array according to the program options. - string str; - Options::Get()->GetOptionAsString( "Include", &str ); - if( str != "" ) - { - // The include list has entries, so we assume that it is a - // complete list of what should be supported. - // Any existing support is cleared first. - memset( cc.m_supportedCommandClasses, 0, sizeof(uint32)*8 ); - cc.ParseCommandClassOption( str, true ); - } - - // Apply the excluded command class option - Options::Get()->GetOptionAsString( "Exclude", &str ); - if( str != "" ) - { - cc.ParseCommandClassOption( str, false ); - } -} - -//----------------------------------------------------------------------------- -// -// Parse a comma delimited list of included/excluded command classes -//----------------------------------------------------------------------------- -void CommandClasses::ParseCommandClassOption -( - string const& _optionStr, - bool const _include -) -{ - size_t pos = 0; - size_t start = 0; - bool parsing = true; - while( parsing ) - { - string ccStr; - - pos = _optionStr.find_first_of( ",", start ); - if( string::npos == pos ) - { - ccStr = _optionStr.substr( start ); - parsing = false; - } - else - { - ccStr = _optionStr.substr( start, pos-start ); - start = pos + 1; - } - - if( ccStr != "" ) - { - uint8 ccIdx = GetCommandClassId( ccStr ); - if( _include ) - { - m_supportedCommandClasses[ccIdx>>5] |= (1u<<(ccIdx&0x1f)); - } - else - { - m_supportedCommandClasses[ccIdx>>5] &= ~(1u<<(ccIdx&0x1f)); - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Convert a command class name (e.g COMMAND_CLASS_BASIC) into its 8-bit ID -//----------------------------------------------------------------------------- -uint8 CommandClasses::GetCommandClassId -( - string const& _name -) -{ - string upperName = ToUpper( _name ); - map::iterator it = m_namesToIDs.find( upperName ); - if( it != m_namesToIDs.end() ) - { - return it->second; - } - - return 0xff; -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClasses.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClasses.h deleted file mode 100644 index fc9f886..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/CommandClasses.h +++ /dev/null @@ -1,79 +0,0 @@ -//----------------------------------------------------------------------------- -// -// CommandClasses.h -// -// Singleton holding methods to create each command class object -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _CommandClasses_H -#define _CommandClasses_H - -#include -#include -#include "../Defs.h" - -namespace OpenZWave -{ - class CommandClass; - - /** \brief Manages a map of command classes supported by a specific Z-Wave node. - */ - class CommandClasses - { - public: - typedef CommandClass* (*pfnCreateCommandClass_t)( uint32 const _homeId, uint8 const _nodeId ); - - static void RegisterCommandClasses(); - static CommandClass* CreateCommandClass( uint8 const _commandClassId, uint32 const _homeId, uint8 const _nodeId ); - - static bool IsSupported( uint8 const _commandClassId ); - static string GetName(uint8 const _commandClassId); - private: - CommandClasses(); - CommandClasses( CommandClasses const& ); // prevent copy - CommandClasses& operator = ( CommandClasses const& ); // prevent assignment - - static CommandClasses& Get() - { - static CommandClasses instance; - return instance; - } - - void Register( uint8 const _commandClassId, string const& _commandClassName, pfnCreateCommandClass_t _create ); - void ParseCommandClassOption( string const& _optionStr, bool const _include ); - uint8 GetCommandClassId( string const& _name ); - - pfnCreateCommandClass_t m_commandClassCreators[256]; - map m_namesToIDs; - - // m_supportedCommandClasses uses single bits to mark whether OpenZWave supports a command class - // Checking this is not the same as looking for non-NULL entried in m_commandClassCreators, since - // this may be modified by the program options --Include and --Ingnore to filter out support - // for unwanted command classes. - uint32 m_supportedCommandClasses[8]; - }; - -} // namespace OpenZWave - - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Configuration.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Configuration.cpp deleted file mode 100644 index bd7d49b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Configuration.cpp +++ /dev/null @@ -1,277 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Configuration.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_CONFIGURATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Configuration.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" -#include "../value_classes/ValueBool.h" -#include "../value_classes/ValueButton.h" -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueInt.h" -#include "../value_classes/ValueList.h" -#include "../value_classes/ValueShort.h" - -using namespace OpenZWave; - -enum ConfigurationCmd -{ - ConfigurationCmd_Set = 0x04, - ConfigurationCmd_Get = 0x05, - ConfigurationCmd_Report = 0x06 -}; - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Configuration::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (ConfigurationCmd_Report == (ConfigurationCmd)_data[0]) - { - // Extract the parameter index and value - uint8 parameter = _data[1]; - uint8 size = _data[2] & 0x07; - int32 paramValue = 0; - for( uint8 i=0; iGetID().GetType() ) - { - case ValueID::ValueType_Bool: - { - ValueBool* valueBool = static_cast( value ); - valueBool->OnValueRefreshed( paramValue != 0 ); - break; - } - case ValueID::ValueType_Byte: - { - ValueByte* valueByte = static_cast( value ); - valueByte->OnValueRefreshed( (uint8)paramValue ); - break; - } - case ValueID::ValueType_Short: - { - ValueShort* valueShort = static_cast( value ); - valueShort->OnValueRefreshed( (int16)paramValue ); - break; - } - case ValueID::ValueType_Int: - { - ValueInt* valueInt = static_cast( value ); - valueInt->OnValueRefreshed( paramValue ); - break; - } - case ValueID::ValueType_List: - { - ValueList* valueList = static_cast( value ); - valueList->OnValueRefreshed( paramValue ); - break; - } - default: - { - Log::Write( LogLevel_Info, GetNodeId(), "Invalid type (%d) for configuration parameter %d", value->GetID().GetType(), parameter ); - } - } - value->Release(); - } - else - { - char label[16]; - snprintf( label, 16, "Parameter #%d", parameter ); - - // Create a new value - if( Node* node = GetNodeUnsafe() ) - { - switch( size ) - { - case 1: - { - node->CreateValueByte( ValueID::ValueGenre_Config, GetCommandClassId(), _instance, parameter, label, "", false, false, (uint8)paramValue, 0 ); - break; - } - case 2: - { - node->CreateValueShort( ValueID::ValueGenre_Config, GetCommandClassId(), _instance, parameter, label, "", false, false, (int16)paramValue, 0 ); - break; - } - case 4: - { - node->CreateValueInt( ValueID::ValueGenre_Config, GetCommandClassId(), _instance, parameter, label, "", false, false, (int32)paramValue, 0 ); - break; - } - default: - { - Log::Write( LogLevel_Info, GetNodeId(), "Invalid size of %d bytes for configuration parameter %d", size, parameter ); - } - } - } - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received Configuration report: Parameter=%d, Value=%d", parameter, paramValue ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a value in the Z-Wave device -//----------------------------------------------------------------------------- -bool Configuration::SetValue -( - Value const& _value -) -{ - uint8 param = _value.GetID().GetIndex(); - switch( _value.GetID().GetType() ) - { - case ValueID::ValueType_Bool: - { - ValueBool const& valueBool = static_cast( _value ); - Set( param, (int32)valueBool.GetValue(), 1 ); - return true; - } - case ValueID::ValueType_Byte: - { - ValueByte const& valueByte = static_cast( _value ); - Set( param, (int32)valueByte.GetValue(), 1 ); - return true; - } - case ValueID::ValueType_Short: - { - ValueShort const& valueShort = static_cast( _value ); - Set( param, (int32)valueShort.GetValue(), 2 ); - return true; - } - case ValueID::ValueType_Int: - { - ValueInt const& valueInt = static_cast( _value ); - Set( param, valueInt.GetValue(), 4 ); - return true; - } - case ValueID::ValueType_List: - { - ValueList const& valueList = static_cast( _value ); - Set( param, valueList.GetItem().m_value, valueList.GetSize() ); - return true; - } - case ValueID::ValueType_Button: - { - ValueButton const& valueButton = static_cast( _value ); - Set( param, valueButton.IsPressed(), 1 ); - return true; - } - default: - { - } - } - - Log::Write( LogLevel_Info, GetNodeId(), "Configuration::Set failed (bad value or value type) - Parameter=%d", param ); - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current parameter value from the device -//----------------------------------------------------------------------------- -bool Configuration::RequestValue -( - uint32 const _requestFlags, - uint8 const _parameter, // parameter number is encoded as the Index portion of ValueID - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "ConfigurationCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( ConfigurationCmd_Get ); - msg->Append( _parameter ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ConfigurationCmd_Get Not Supported on this node"); - } - return false; -} -//----------------------------------------------------------------------------- -// -// Set the device's -//----------------------------------------------------------------------------- -void Configuration::Set -( - uint8 const _parameter, - int32 const _value, - uint8 const _size -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "Configuration::Set - Parameter=%d, Value=%d Size=%d", _parameter, _value, _size ); - - Msg* msg = new Msg( "ConfigurationCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 4 + _size ); - msg->Append( GetCommandClassId() ); - msg->Append( ConfigurationCmd_Set ); - msg->Append( _parameter ); - msg->Append( _size ); - if( _size > 2 ) - { - msg->Append( (uint8)( ( _value>>24 ) & 0xff ) ); - msg->Append( (uint8)( ( _value>>16 ) & 0xff ) ); - } - if( _size > 1 ) - { - msg->Append( (uint8)( ( _value>>8 ) & 0xff ) ); - } - msg->Append( (uint8)( _value & 0xff ) ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Configuration.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Configuration.h deleted file mode 100644 index ad38879..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Configuration.h +++ /dev/null @@ -1,67 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Configuration.h -// -// Implementation of the Z-Wave COMMAND_CLASS_CONFIGURATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Configuration_H -#define _Configuration_H - -#include -#include "CommandClass.h" - -namespace OpenZWave -{ - class Value; - - /** \brief Implements COMMAND_CLASS_CONFIGURATION (x70), a Z-Wave device command class. - */ - class Configuration: public CommandClass - { - friend class Node; - - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Configuration( _homeId, _nodeId ); } - virtual ~Configuration(){} - - static uint8 const StaticGetCommandClassId(){ return 0x70; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CONFIGURATION"; } - - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _parameter, uint8 const _index, Driver::MsgQueue const _queue ); - void Set( uint8 const _parameter, int32 const _value, uint8 const _size ); - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - private: - Configuration( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ControllerReplication.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ControllerReplication.cpp deleted file mode 100644 index 822ef17..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ControllerReplication.cpp +++ /dev/null @@ -1,326 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ControllerReplication.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_CONTROLLER_REPLICATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ControllerReplication.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueList.h" -#include "../value_classes/ValueButton.h" - -using namespace OpenZWave; - -enum ControllerReplicationCmd -{ - ControllerReplicationCmd_TransferGroup = 0x31, - ControllerReplicationCmd_TransferGroupName = 0x32, - ControllerReplicationCmd_TransferScene = 0x33, - ControllerReplicationCmd_TransferSceneName = 0x34 -}; - -enum -{ - ControllerReplicationIndex_NodeId = 0, - ControllerReplicationIndex_Function, - ControllerReplicationIndex_Replicate -}; - -static char const* c_controllerReplicationFunctionNames[] = -{ - "Groups", - "Group Names", - "Scenes", - "Scene Names", -}; - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -ControllerReplication::ControllerReplication -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_busy( false ), - m_targetNodeId( 0 ), - m_funcId( 0 ), - m_nodeId( -1 ), - m_groupCount( -1 ), - m_groupIdx( -1 ) -{ -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ControllerReplication::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - // When creating replication messages, use FUNC_ID_ZW_SEND_REPLICATION_DATA instead of FUNC_ID_ZW_SEND_DATA - // e.g. Msg* msg = new Msg( "TransferGroup", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_REPLICATION_DATA, true, false ); - - switch( _data[0] ) - { - case ControllerReplicationCmd_TransferGroup: - { - break; - } - case ControllerReplicationCmd_TransferGroupName: - { - break; - } - case ControllerReplicationCmd_TransferScene: - { - break; - } - case ControllerReplicationCmd_TransferSceneName: - { - break; - } - } - - Msg* msg = new Msg( "ControllerReplication Command Complete", GetNodeId(), REQUEST, FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE, false, false ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Command ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Set a value on the Z-Wave device -//----------------------------------------------------------------------------- -bool ControllerReplication::SetValue -( - Value const& _value -) -{ - bool res = false; - uint8 instance = _value.GetID().GetInstance(); - - switch( _value.GetID().GetIndex() ) - { - case ControllerReplicationIndex_NodeId: - { - if( ValueByte* value = static_cast( GetValue( instance, ControllerReplicationIndex_NodeId ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - res = true; - } - break; - } - case ControllerReplicationIndex_Function: - { - if( ValueList* value = static_cast( GetValue( instance, ControllerReplicationIndex_Function ) ) ) - { - ValueList::Item const& item = (static_cast( &_value))->GetItem(); - value->OnValueRefreshed( item.m_value ); - value->Release(); - res = true; - } - break; - } - case ControllerReplicationIndex_Replicate: - { - if( ValueButton* button = static_cast( GetValue( instance, ControllerReplicationIndex_Replicate ) ) ) - { - if( button->IsPressed() ) - { - res = StartReplication( instance ); - } - button->Release(); - } - break; - } - } - return res; -} - -//----------------------------------------------------------------------------- -// -// Set up the group and scene data to be sent to the other controller -//----------------------------------------------------------------------------- -bool ControllerReplication::StartReplication -( - uint8 const _instance -) -{ - if( m_busy ) - { - return false; - } - - if( ValueByte* value = static_cast( GetValue( _instance, ControllerReplicationIndex_NodeId ) ) ) - { - m_targetNodeId = value->GetValue(); - value->Release(); - } - else - { - return false; - } - - if( ValueList* value = static_cast( GetValue( _instance, ControllerReplicationIndex_Function ) ) ) - { - ValueList::Item const& item = value->GetItem(); - m_funcId = item.m_value; - value->Release(); - } - else - { - return false; - } - - // Store the Z-Wave command we should use when replication has completed. - m_nodeId = -1; - m_groupCount = -1; - m_groupIdx = -1; - m_busy = true; - - // Set up the groups and scenes to be sent - SendNextData(); - return true; -} - -//----------------------------------------------------------------------------- -// -// Send the next block of replication data -//----------------------------------------------------------------------------- -void ControllerReplication::SendNextData -( -) -{ - uint16 i = 255; - - if( !m_busy ) - { - return; - } - - while( 1 ) - { - if( m_groupIdx != -1 ) - { - m_groupIdx++; - if( m_groupIdx <= m_groupCount ) - { - break; - } - } - i = m_nodeId == -1 ? 0 : m_nodeId+1; - GetDriver()->LockNodes(); - while( i < 256 ) - { - if( GetDriver()->m_nodes[i] ) - { - m_groupCount = GetDriver()->m_nodes[i]->GetNumGroups(); - if( m_groupCount != 0 ) - { - m_groupName = GetDriver()->m_nodes[i]->GetGroupLabel( m_groupIdx ); - m_groupIdx = m_groupName.length() > 0 ? 0 : 1; - break; - } - } - i++; - } - GetDriver()->ReleaseNodes(); - m_nodeId = i; - break; - } - if( i < 255 ) - { - Msg* msg = new Msg( "Replication Send", m_targetNodeId, REQUEST, FUNC_ID_ZW_REPLICATION_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( m_targetNodeId ); - if( m_groupName.length() > 0 ) - { - msg->Append((uint8) (m_groupName.length() + 4 )); - msg->Append( GetCommandClassId() ); - msg->Append( ControllerReplicationCmd_TransferGroupName ); - msg->Append( 0 ); - msg->Append( m_groupIdx ); - for( uint8 j = 0; j < m_groupName.length(); j++ ) - { - msg->Append( m_groupName[j] ); - } - m_groupName = ""; - } - else - { - msg->Append( 5 ); - msg->Append( GetCommandClassId() ); - msg->Append( ControllerReplicationCmd_TransferGroup ); - msg->Append( 0 ); - msg->Append( m_groupIdx ); - msg->Append( m_nodeId ); - } - msg->Append( TRANSMIT_OPTION_ACK ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Command ); - } - else - { - GetDriver()->AddNodeStop( m_funcId ); - m_busy = false; - } -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void ControllerReplication::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, ControllerReplicationIndex_NodeId, "Node", "", false, false, 0, 0 ); - vector items; - - ValueList::Item item; - for( uint8 i=0; i<4; ++i ) - { - item.m_label = c_controllerReplicationFunctionNames[i]; - item.m_value = ControllerReplicationCmd_TransferGroup + i; - items.push_back( item ); - } - - node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, ControllerReplicationIndex_Function, "Functions", "", false, false, 1, items, 0, 0 ); - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, ControllerReplicationIndex_Replicate, "Replicate", 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ControllerReplication.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ControllerReplication.h deleted file mode 100644 index 047a58f..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ControllerReplication.h +++ /dev/null @@ -1,74 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ControllerReplication.h -// -// Implementation of the Z-Wave COMMAND_CLASS_CONTROLLER_REPLICATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ControllerReplication_H -#define _ControllerReplication_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_CONTROLLER_REPLICATION (0x21), a Z-Wave device command class. - */ - class ControllerReplication: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ControllerReplication( _homeId, _nodeId ); } - virtual ~ControllerReplication(){} - - static uint8 const StaticGetCommandClassId(){ return 0x21; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CONTROLLER_REPLICATION"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - void SendNextData(); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - ControllerReplication( uint32 const _homeId, uint8 const _nodeId ); - bool StartReplication( uint8 const _instance ); - - - bool m_busy; - uint8 m_targetNodeId; - uint8 m_funcId; - int m_nodeId; - int m_groupCount; - int m_groupIdx; - string m_groupName; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLock.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLock.cpp deleted file mode 100644 index 6b1404d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLock.cpp +++ /dev/null @@ -1,586 +0,0 @@ -//----------------------------------------------------------------------------- -// -// DoorLock.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_DOOR_LOCK -// -// Copyright (c) 2014 Justin Hammond -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "DoorLock.h" -#include "WakeUp.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueBool.h" -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueInt.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum DoorLockCmd -{ - DoorLockCmd_Set = 0x01, - DoorLockCmd_Get = 0x02, - DoorLockCmd_Report = 0x03, - DoorLockCmd_Configuration_Set = 0x04, - DoorLockCmd_Configuration_Get = 0x05, - DoorLockCmd_Configuration_Report= 0x06 -}; - -enum TimeOutMode -{ - DoorLockConfig_NoTimeout = 0x01, - DoorLockConfig_Timeout = 0x02 -}; - -static char const* c_TimeOutModeNames[] = -{ - "No Timeout", - "Secure Lock after Timeout" -}; - -enum DoorLockControlState -{ - DoorLockControlState_Handle1 = 0x01, - DoorLockControlState_Handle2 = 0x02, - DoorLockControlState_Handle3 = 0x04, - DoorLockControlState_Handle4 = 0x08 -}; - -enum ValueIDSystemIndexes -{ - Value_Lock = 0x00, /* Simple On/Off Mode for Lock */ - Value_Lock_Mode = 0x01, /* To Set more Complex Lock Modes (Such as timeouts etc) */ - Value_System_Config_Mode = 0x02, /* To Set/Unset if Locks should return to Secured Mode after a timeout */ - Value_System_Config_Minutes = 0x03, /* If Timeouts are enabled, how many minutes before a Lock "AutoLocks" */ - Value_System_Config_Seconds = 0x04, /* If Timeouts are enabled, how many seconds beofre a Lock "Autolocks" */ - Value_System_Config_OutsideHandles = 0x05, /* What Outside Handles are controlled via Z-Wave (BitMask 1-4) */ - Value_System_Config_InsideHandles = 0x06, /* What inside Handles are control via ZWave (BitMask 1-4) */ -}; - -enum DoorLockState -{ - DoorLockState_Unsecured = 0x00, - DoorLockState_Unsecured_Timeout = 0x01, - DoorLockState_Inside_Unsecured = 0x10, - DoorLockState_Inside_Unsecured_Timeout = 0x11, - DoorLockState_Outside_Unsecured = 0x20, - DoorLockState_Outside_Unsecured_Timeout = 0x21, - DoorLockState_Secured = 0xFF -}; - - -static char const* c_LockStateNames[] = -{ - "Unsecure", - "Unsecured with Timeout", - "Inside Handle Unsecured", - "Inside Handle Unsecured with Timeout", - "Outside Handle Unsecured", - "Outside Handle Unsecured with Timeout", - "Secured", - "Invalid" -}; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -DoorLock::DoorLock -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_timeoutsupported(0), - m_insidehandlemode(0), - m_outsidehandlemode(0), - m_timeoutmins(0xFE), - m_timeoutsecs(0xFE) -{ - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void DoorLock::ReadXML -( - TiXmlElement const* _ccElement -) -{ - int32 intVal; - - CommandClass::ReadXML( _ccElement ); - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "m_timeoutsupported", &intVal ) ) - { - m_timeoutsupported = intVal; - } - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "m_insidehandlemode", &intVal ) ) - { - m_insidehandlemode = intVal; - } - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "m_outsidehandlemode", &intVal ) ) - { - m_outsidehandlemode = intVal; - } - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "m_timeoutmins", &intVal ) ) - { - m_timeoutmins = intVal; - } - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "m_timeoutsecs", &intVal ) ) - { - m_timeoutsecs = intVal; - } -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void DoorLock::WriteXML -( - TiXmlElement* _ccElement -) -{ - char str[32]; - - CommandClass::WriteXML( _ccElement ); - snprintf( str, sizeof(str), "%d", m_timeoutsupported ); - _ccElement->SetAttribute( "m_timeoutsupported", str); - - snprintf( str, sizeof(str), "%d", m_insidehandlemode ); - _ccElement->SetAttribute( "m_insidehandlemode", str); - - snprintf( str, sizeof(str), "%d", m_outsidehandlemode ); - _ccElement->SetAttribute( "m_outsidehandlemode", str); - - snprintf( str, sizeof(str), "%d", m_timeoutmins ); - _ccElement->SetAttribute( "m_timeoutmins", str); - - snprintf( str, sizeof(str), "%d", m_timeoutsecs ); - _ccElement->SetAttribute( "m_timeoutsecs", str); - -} - - - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool DoorLock::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - requests = RequestValue( _requestFlags, Value_System_Config_Mode, _instance, _queue ); - } - - if( _requestFlags & RequestFlag_Dynamic ) - { - requests |= RequestValue( _requestFlags, Value_Lock, _instance, _queue ); - } - - return requests; -} - - - - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool DoorLock::RequestValue -( - uint32 const _requestFlags, - uint8 const _what, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( _what >= Value_System_Config_Mode) { - Msg* msg = new Msg( "DoorLockCmd_Configuration_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockCmd_Configuration_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - - } else if ((_what == Value_Lock) || (_what == Value_Lock_Mode)) { - - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "DoorLockCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "DoorLockCmd_Get Not Supported on this node"); - } - } - return false; -} - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool DoorLock::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - - if( DoorLockCmd_Report == (DoorLockCmd)_data[0] ) - { - uint8 lockState = (_data[1] == 0xFF) ? 6 : _data[1]; - if (lockState > 6) /* size of c_LockStateNames minus Invalid Entry */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "LockState Value was greater than range. Setting to Invalid"); - lockState = 7; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received DoorLock report: DoorLock is %s", c_LockStateNames[lockState] ); - - if( ValueBool* value = static_cast( GetValue( _instance, Value_Lock ) ) ) - { - value->OnValueRefreshed( lockState == 0xFF ); - value->Release(); - } - if( ValueList* value = static_cast( GetValue( _instance, Value_Lock_Mode ) ) ) - { - value->OnValueRefreshed( lockState); - value->Release(); - } - return true; - } else if (DoorLockCmd_Configuration_Report == (DoorLockCmd)_data[0] ) - { - switch (_data[1]) { - case DoorLockConfig_NoTimeout: - m_timeoutsupported = DoorLockConfig_NoTimeout; - RemoveValue(_instance, Value_System_Config_Minutes); - RemoveValue(_instance, Value_System_Config_Seconds); - m_timeoutmins = 0xFE; - m_timeoutsecs = 0xFE; - break; - case DoorLockConfig_Timeout: - /* if we have a timeout, then create the Values for the timeout config */ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_Minutes, "Timeout Minutes", "Mins", false, false, _data[3], 0 ); - node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_Seconds, "Timeout Seconds", "Secs", false, false, _data[4], 0 ); - } - m_timeoutsupported = DoorLockConfig_Timeout; - m_timeoutmins = _data[3]; - m_timeoutsecs = _data[4]; - break; - default: - Log::Write(LogLevel_Warning, GetNodeId(), "Recieved a Unsupported Door Lock Config Report %d", _data[1]); - } - - if( ValueByte* value = static_cast( GetValue( _instance, Value_System_Config_OutsideHandles ) ) ) - { - value->OnValueRefreshed( ((_data[2] & 0xF0)>>4) ); - value->Release(); - m_outsidehandlemode = ((_data[2] & 0xF0)>>4); - } - if( ValueByte* value = static_cast( GetValue( _instance, Value_System_Config_InsideHandles ) ) ) - { - value->OnValueRefreshed( (_data[2] & 0x0F) ); - value->Release(); - m_insidehandlemode = (_data[2] & 0x0F); - } - - - ClearStaticRequest( StaticRequest_Values ); - - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the lock's state -//----------------------------------------------------------------------------- -bool DoorLock::SetValue -( - Value const& _value -) -{ - uint8 instance = _value.GetID().GetInstance(); - if( (Value_Lock == _value.GetID().GetIndex()) && ValueID::ValueType_Bool == _value.GetID().GetType() ) - { - ValueBool const* value = static_cast(&_value); - - Log::Write( LogLevel_Info, GetNodeId(), "Value_Lock::Set - Requesting lock to be %s", value->GetValue() ? "Locked" : "Unlocked" ); - Msg* msg = new Msg( "DoorLockCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockCmd_Set ); - msg->Append( value->GetValue() ? 0xFF:0x00 ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - if ( (Value_Lock_Mode == _value.GetID().GetIndex()) && (ValueID::ValueType_List == _value.GetID().GetType()) ) - { - ValueList const* value = static_cast(&_value); - ValueList::Item const& item = value->GetItem(); - - - Log::Write( LogLevel_Info, GetNodeId(), "Value_Lock_Mode::Set - Requesting lock to be %s", item.m_label.c_str() ); - Msg* msg = new Msg( "DoorLockCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockCmd_Set ); - msg->Append( item.m_value ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - /* if its any of our System Messages.... */ - if ( Value_System_Config_Mode >= _value.GetID().GetIndex() ) - { - bool sendmsg = true; - switch (_value.GetID().GetIndex()) { - /* this is a List */ - case Value_System_Config_Mode: - if (ValueID::ValueType_List != _value.GetID().GetType()) { - sendmsg = false; - break; - } - if( ValueList* value = static_cast( GetValue( instance, _value.GetID().GetIndex() ) ) ) - { - ValueList::Item const& item = (static_cast( &_value))->GetItem(); - value->OnValueRefreshed( item.m_value ); - value->Release(); - } - - break; - - /* these are a int */ - case Value_System_Config_Minutes: - case Value_System_Config_Seconds: - if (ValueID::ValueType_Int != _value.GetID().GetType()) { - sendmsg = false; - break; - } - if( ValueInt* value = static_cast( GetValue( instance, _value.GetID().GetIndex() ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - break; - /* these are a byte */ - case Value_System_Config_OutsideHandles: - case Value_System_Config_InsideHandles: - if (ValueID::ValueType_Byte != _value.GetID().GetType()) { - sendmsg = false; - break; - } - if( ValueByte* value = static_cast( GetValue( instance, _value.GetID().GetIndex() ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - break; - default: - Log::Write(LogLevel_Warning, GetNodeId(), "DoorLock::SetValue - Unhandled System_Config Variable %d", _value.GetID().GetIndex()); - sendmsg = false; - break; - } - - if (sendmsg) - { - bool ok = true; - if( ValueList* value = static_cast( GetValue( instance, Value_System_Config_Mode ) ) ) { - ValueList::Item const& item = value->GetItem(); - m_timeoutsupported = item.m_value; - } else { - ok = false; - Log::Write(LogLevel_Warning, GetNodeId(), "Failed To Retrieve Value_System_Config_Mode For SetValue"); - } - uint8 control = 0; - if( ValueByte* value = static_cast( GetValue( instance, Value_System_Config_OutsideHandles ) ) ) - { - control = (value->GetValue() << 4); - m_insidehandlemode = control; - } else { - ok = false; - Log::Write(LogLevel_Warning, GetNodeId(), "Failed To Retrieve Value_System_Config_OutsideHandles For SetValue"); - } - if( ValueByte* value = static_cast( GetValue( instance, Value_System_Config_InsideHandles ) ) ) - { - control += (value->GetValue() & 0x0F); - m_outsidehandlemode = (value->GetValue() & 0x0F); - } else { - ok = false; - Log::Write(LogLevel_Warning, GetNodeId(), "Failed To Retrieve Value_System_Config_InsideHandles For SetValue"); - } - if( ValueInt* value = static_cast( GetValue( instance, Value_System_Config_Minutes ) ) ) - { - m_timeoutmins = value->GetValue(); - } else { - /* Minutes and Seconds Might Not Exist, this is fine. Set to 0xFE */ - m_timeoutmins = 0xFE; - } - if( ValueInt* value = static_cast( GetValue( instance, Value_System_Config_Seconds ) ) ) - { - m_timeoutsecs = value->GetValue(); - } else { - /* Minutes and Seconds Might Not Exist, this is fine. Set to 0xFE */ - m_timeoutsecs = 0xFE; - } - if (ok) { - Msg* msg = new Msg( "DoorLockCmd_Configuration_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 6 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockCmd_Configuration_Set ); - msg->Append( m_timeoutsupported ); - msg->Append( control ); - msg->Append( m_timeoutmins ); - msg->Append( m_timeoutsecs ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - return false; - } - - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Update class values based in BASIC mapping -//----------------------------------------------------------------------------- -void DoorLock::SetValueBasic -( - uint8 const _instance, - uint8 const _value -) -{ - - - - // Send a request for new value to synchronize it with the BASIC set/report. - // In case the device is sleeping, we set the value anyway so the BASIC set/report - // stays in sync with it. We must be careful mapping the uint8 BASIC value - // into a class specific value. - // When the device wakes up, the real requested value will be retrieved. - RequestValue( 0, DoorLockCmd_Get, _instance, Driver::MsgQueue_Send ); - if( Node* node = GetNodeUnsafe() ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - if( !wakeUp->IsAwake() ) - { - if( ValueBool* value = static_cast( GetValue( _instance, Value_Lock ) ) ) - { - value->OnValueRefreshed( _value != 0 ); - value->Release(); - } - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void DoorLock::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, Value_Lock, "Locked", "", false, false, false, 0 ); - - /* Complex Lock Option */ - { - vector items; - ValueList::Item item; - for( uint8 i=0; i<8; ++i ) - { - item.m_label = c_LockStateNames[i]; - item.m_value = (i < 6) ? i : 0xFF; - items.push_back( item ); - } - node->CreateValueList( ValueID::ValueGenre_User, GetCommandClassId(), _instance, Value_Lock_Mode, "Locked (Advanced)", "", false, false, 1, items, 0, 0 ); - - - } - - /* Timeout mode for Locks that support it */ - { - vector items; - ValueList::Item item; - for( uint8 i=0; i<2; ++i ) - { - item.m_label = c_TimeOutModeNames[i]; - item.m_value = i+1; - items.push_back( item ); - } - node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_Mode, "Timeout Mode", "", false, false, 1, items, 0, 0 ); - } - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_OutsideHandles, "Outside Handle Control", "", false, false, 0x0F, 0 ); - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_InsideHandles, "Inside Handle Control", "", false, false, 0x0F, 0 ); - - } -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLock.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLock.h deleted file mode 100644 index 1aae3f8..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLock.h +++ /dev/null @@ -1,76 +0,0 @@ -//----------------------------------------------------------------------------- -// -// DoorLock.h -// -// Implementation of the Z-Wave COMMAND_CLASS_DOOR_LOCK -// -// Copyright (c) 2014 Justin Hammond -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _DoorLock_H -#define _DoorLock_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueBool; - - /** \brief Implements COMMAND_CLASS_DOOR_LOCK (0x62), a Z-Wave device command class. - */ - class DoorLock: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new DoorLock( _homeId, _nodeId ); } - virtual ~DoorLock(){} - - static uint8 const StaticGetCommandClassId(){ return 0x62; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_DOOR_LOCK"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - virtual void SetValueBasic( uint8 const _instance, uint8 const _value ); - - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - DoorLock( uint32 const _homeId, uint8 const _nodeId ); - uint8 m_timeoutsupported; - uint8 m_insidehandlemode; - uint8 m_outsidehandlemode; - uint8 m_timeoutmins; - uint8 m_timeoutsecs; - - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLockLogging.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLockLogging.cpp deleted file mode 100644 index df0a1ce..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLockLogging.cpp +++ /dev/null @@ -1,375 +0,0 @@ -//----------------------------------------------------------------------------- -// -// DoorLockLogging.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_DOOR_LOCK_LOGGING -// -// Copyright (c) 2014 Justin Hammond -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "DoorLockLogging.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueBool.h" -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueInt.h" -#include "../value_classes/ValueString.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum DoorLockLoggingCmd -{ - DoorLockLoggingCmd_RecordSupported_Get = 0x01, - DoorLockLoggingCmd_RecordSupported_Report = 0x02, - DoorLockLoggingCmd_Record_Get = 0x03, - DoorLockLoggingCmd_Record_Report = 0x04 -}; - -enum DoorLockEventType -{ - DoorLockEventType_LockCode = 0x01, - DoorLockEventType_UnLockCode = 0x02, - DoorLockEventType_LockButton = 0x03, - DoorLockEventType_UnLockButton = 0x04, - DoorLockEventType_LockCodeOOSchedule = 0x05, - DoorLockEventType_UnLockCodeOOSchedule = 0x06, - DoorLockEventType_IllegalCode = 0x07, - DoorLockEventType_LockManual = 0x08, - DoorLockEventType_UnLockManual = 0x09, - DoorLockEventType_LockAuto = 0x0A, - DoorLockEventType_UnLockAuto = 0x0B, - DoorLockEventType_LockRemoteCode = 0x0C, - DoorLockEventType_UnLockRemoteCode = 0x0D, - DoorLockEventType_LockRemote = 0x0E, - DoorLockEventType_UnLockRemote = 0x0F, - DoorLockEventType_LockRemoteCodeOOSchedule = 0x10, - DoorLockEventType_UnLockRemoteCodeOOSchedule = 0x11, - DoorLockEventType_RemoteIllegalCode = 0x12, - DoorLockEventType_LockManual2 = 0x13, - DoorLockEventType_UnlockManual2 = 0x14, - DoorLockEventType_LockSecured = 0x15, - DoorLockEventType_LockUnsecured = 0x16, - DoorLockEventType_UserCodeAdded = 0x17, - DoorLockEventType_UserCodeDeleted = 0x18, - DoorLockEventType_AllUserCodesDeleted = 0x19, - DoorLockEventType_MasterCodeChanged = 0x1A, - DoorLockEventType_UserCodeChanged = 0x1B, - DoorLockEventType_LockReset = 0x1C, - DoorLockEventType_ConfigurationChanged = 0x1D, - DoorLockEventType_LowBattery = 0x1E, - DoorLockEventType_NewBattery = 0x1F, - DoorLockEventType_Max = 0x20 -}; - -static char const* c_DoorLockEventType[] = -{ - "Locked via Access Code", - "Unlocked via Access Code", - "Locked via Lock Button", - "Unlocked via UnLock Botton", - "Lock Attempt via Out of Schedule Access Code", - "Unlock Attemp via Out of Schedule Access Code", - "Illegal Access Code Entered", - "Manually Locked", - "Manually UnLocked", - "Auto Locked", - "Auto Unlocked", - "Locked via Remote Out of Schedule Access Code", - "Unlocked via Remote Out of Schedule Access Code", - "Locked via Remote", - "Unlocked via Remote", - "Lock Attempt via Remote Out of Schedule Access Code", - "Unlock Attempt via Remote Out of Schedule Access Code", - "Illegal Remote Access Code", - "Manually Locked (2)", - "Manually Unlocked (2)", - "Lock Secured", - "Lock Unsecured", - "User Code Added", - "User Code Deleted", - "All User Codes Deleted", - "Master Code Changed", - "User Code Changed", - "Lock Reset", - "Configuration Changed", - "Low Battery", - "New Battery Installed", - "Unknown" -}; -/* size = 31 entries */ - -enum ValueIDSystemIndexes -{ - Value_System_Config_MaxRecords = 0x00, /* Max Number of Records the Device can Hold */ - Value_GetRecordNo = 0x01, /* Current Record Number after refresh */ - Value_LogRecord = 0x02 /* Simple String Representation of the Log Record - Tab Delimited Fields */ -}; - - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -DoorLockLogging::DoorLockLogging -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_MaxRecords(0), - m_CurRecord(0) -{ - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void DoorLockLogging::ReadXML -( - TiXmlElement const* _ccElement -) -{ - int32 intVal; - - CommandClass::ReadXML( _ccElement ); - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "m_MaxRecords", &intVal ) ) - { - m_MaxRecords = intVal; - } -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void DoorLockLogging::WriteXML -( - TiXmlElement* _ccElement -) -{ - char str[32]; - - CommandClass::WriteXML( _ccElement ); - snprintf( str, sizeof(str), "%d", m_MaxRecords ); - _ccElement->SetAttribute( "m_MaxRecords", str); -} - - - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool DoorLockLogging::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - requests = RequestValue( _requestFlags, DoorLockLoggingCmd_RecordSupported_Get, _instance, _queue ); - } - - if( _requestFlags & RequestFlag_Dynamic ) - { - requests |= RequestValue( _requestFlags, DoorLockLoggingCmd_Record_Get, _instance, _queue ); - } - - return requests; -} - - - - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool DoorLockLogging::RequestValue -( - uint32 const _requestFlags, - uint8 const _what, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( _what == DoorLockLoggingCmd_RecordSupported_Get) { - Msg* msg = new Msg( "DoorLockLoggingCmd_RecordSupported_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockLoggingCmd_RecordSupported_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - - } else if (_what == DoorLockLoggingCmd_Record_Get) { - Msg* msg = new Msg( "DoorLockLoggingCmd_Record_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockLoggingCmd_Record_Get ); - msg->Append( m_CurRecord ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - return false; -} - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool DoorLockLogging::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - - if( DoorLockLoggingCmd_RecordSupported_Report == (DoorLockLoggingCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received DoorLockLoggingCmd_RecordSupported_Report: Max Records is %d ", _data[1]); - - if( ValueByte* value = static_cast( GetValue( _instance, Value_System_Config_MaxRecords ) ) ) - { - value->OnValueRefreshed( _data[1]); - value->Release(); - } - ClearStaticRequest( StaticRequest_Values ); - return true; - } else if (DoorLockLoggingCmd_Record_Report == (DoorLockLoggingCmd)_data[0] ) - { - uint8 EventType = _data[9]; - if (EventType >= DoorLockEventType_Max) - EventType = DoorLockEventType_Max; - - Log::Write (LogLevel_Info, GetNodeId(), "Recieved a DoorLockLogging Record %d which is \"%s\"", _data[1], c_DoorLockEventType[EventType-1]); - - if( ValueByte* value = static_cast( GetValue( _instance, Value_GetRecordNo ) ) ) - { - value->OnValueRefreshed( _data[1]); - value->Release(); - } - if( ValueString* value = static_cast( GetValue( _instance, Value_LogRecord ) ) ) - { - char msg[512]; - uint16 year = (_data[2] << 8) + (_data[3] & 0xFF); - uint8 month = (_data[4] & 0x0F); - uint8 day = (_data[5] & 0x1F); - uint8 hour = (_data[6] & 0x1F); - uint8 minute = (_data[7] & 0x3F); - uint8 second = (_data[8] & 0x3F); - bool valid = false; - if (((_data[6] & 0xE0) >> 5) > 0) - { - valid = true; - } - uint8 userid = (_data[10]); - uint8 usercodelength = (_data[11]); - char usercode[254]; - snprintf(usercode, sizeof(usercode), "UserCode:"); - if (usercodelength > 0) - for (int i = 0; i < usercodelength; i++ ) - { - snprintf(usercode, sizeof(usercode), "%s %d", usercode, (int)_data[12+i]); - } - - if (valid) { - snprintf(msg, sizeof(msg), "%02d/%02d/%02d %02d:%02d:%02d \tMessage: %s \tUserID: %d \t%s", (int)day, (int)month, (int)year, (int)hour, (int)minute, (int)second, c_DoorLockEventType[EventType], (int)userid, usercode); - } else - snprintf(msg, sizeof(msg), "Invalid Record"); - value->OnValueRefreshed(msg); - value->Release(); - } - return true; - - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the lock's state -//----------------------------------------------------------------------------- -bool DoorLockLogging::SetValue -( - Value const& _value -) -{ - if( (Value_GetRecordNo == _value.GetID().GetIndex()) && ValueID::ValueType_Byte == _value.GetID().GetType() ) - { - ValueByte const* value = static_cast(&_value); - - Log::Write( LogLevel_Info, GetNodeId(), "DoorLockLoggingCmd_Record_Get - Requesting Log Record %d", value->GetValue() ); - Msg* msg = new Msg( "DoorLockLoggingCmd_Record_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( DoorLockLoggingCmd_Record_Get ); - msg->Append( value->GetValue() ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - m_CurRecord = value->GetValue(); - return true; - } - return false; -} - - - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void DoorLockLogging::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, Value_System_Config_MaxRecords, "Max Number of Records", "", true, false, 0x0, 0 ); - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, Value_GetRecordNo, "Current Record Number", "", false, false, 0x0, 0 ); - node->CreateValueString( ValueID::ValueGenre_User, GetCommandClassId(), _instance, Value_LogRecord, "Log Record", "", true, false, "", 0 ); - } -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLockLogging.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLockLogging.h deleted file mode 100644 index 9661d4d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/DoorLockLogging.h +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------------- -// -// DoorLockLogging.h -// -// Implementation of the Z-Wave COMMAND_CLASS_DOOR_LOCK_LOGGING -// -// Copyright (c) 2014 Justin Hammond -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _DoorLockLogging_H -#define _DoorLockLogging_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueBool; - - /** \brief Implements COMMAND_CLASS_DOOR_LOCK_LOGGING (0x4C), a Z-Wave device command class. - */ - class DoorLockLogging: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new DoorLockLogging( _homeId, _nodeId ); } - virtual ~DoorLockLogging(){} - - static uint8 const StaticGetCommandClassId(){ return 0x4c; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_DOOR_LOCK_LOGGING"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - DoorLockLogging( uint32 const _homeId, uint8 const _nodeId ); - uint8 m_MaxRecords; - uint8 m_CurRecord; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/EnergyProduction.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/EnergyProduction.cpp deleted file mode 100644 index cb87587..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/EnergyProduction.cpp +++ /dev/null @@ -1,180 +0,0 @@ -//----------------------------------------------------------------------------- -// -// EnergyProduction.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_ENERGY_PRODUCTION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "EnergyProduction.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueDecimal.h" - -using namespace OpenZWave; - -enum EnergyProductionCmd -{ - EnergyProductionCmd_Get = 0x02, - EnergyProductionCmd_Report = 0x03 -}; - -enum -{ - EnergyProductionIndex_Instant = 0, - EnergyProductionIndex_Total, - EnergyProductionIndex_Today, - EnergyProductionIndex_Time -}; - -static char const* c_energyParameterNames[] = -{ - "Instant energy production", - "Total energy production", - "Energy production today", - "Total production time" -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool EnergyProduction::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool request = false; - if( _requestFlags & RequestFlag_Dynamic ) - { - // Request each of the production values - request |= RequestValue( _requestFlags, EnergyProductionIndex_Instant, _instance, _queue ); - request |= RequestValue( _requestFlags, EnergyProductionIndex_Total, _instance, _queue ); - request |= RequestValue( _requestFlags, EnergyProductionIndex_Today, _instance, _queue ); - request |= RequestValue( _requestFlags, EnergyProductionIndex_Time, _instance, _queue ); - } - - return request; -} - -//----------------------------------------------------------------------------- -// -// Request current production from the device -//----------------------------------------------------------------------------- -bool EnergyProduction::RequestValue -( - uint32 const _requestFlags, - uint8 const _valueEnum, // one of EnergyProductionIndex enums - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if (_valueEnum > EnergyProductionIndex_Time) - { - Log::Write (LogLevel_Warning, GetNodeId(), "RequestValue _valueEnum was greater than range. Dropping"); - return false; - } - - if ( IsGetSupported() ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Requesting the %s value", c_energyParameterNames[_valueEnum] ); - Msg* msg = new Msg( "EnergyProductionCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( EnergyProductionCmd_Get ); - msg->Append( _valueEnum ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "EnergyProductionCmd_Get Not Supported on this node"); - } - return false; -} -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool EnergyProduction::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (EnergyProductionCmd_Report == (EnergyProductionCmd)_data[0]) - { - uint8 scale; - uint8 precision = 0; - string value = ExtractValue( &_data[2], &scale, &precision ); - uint8 paramType = _data[1]; - if (paramType > 4) /* size of c_energyParameterNames minus Invalid Entry*/ - { - Log::Write (LogLevel_Warning, GetNodeId(), "paramType Value was greater than range. Dropping Message"); - return false; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received an Energy production report: %s = %s", c_energyParameterNames[_data[1]], value.c_str() ); - if( ValueDecimal* decimalValue = static_cast( GetValue( _instance, _data[1] ) ) ) - { - decimalValue->OnValueRefreshed( value ); - if( decimalValue->GetPrecision() != precision ) - { - decimalValue->SetPrecision( precision ); - } - decimalValue->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void EnergyProduction::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Instant, c_energyParameterNames[EnergyProductionIndex_Instant], "W", true, false, "0.0", 0 ); - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Total, c_energyParameterNames[EnergyProductionIndex_Total], "kWh", true, false, "0.0", 0 ); - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Today, c_energyParameterNames[EnergyProductionIndex_Today], "kWh", true, false, "0.0", 0 ); - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Time, c_energyParameterNames[EnergyProductionIndex_Time], "", true, false, "0.0", 0 ); - } -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/EnergyProduction.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/EnergyProduction.h deleted file mode 100644 index e70e6df..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/EnergyProduction.h +++ /dev/null @@ -1,65 +0,0 @@ -//----------------------------------------------------------------------------- -// -// EnergyProduction.h -// -// Implementation of the Z-Wave COMMAND_CLASS_ENERGY_PRODUCTION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _EnergyProduction_H -#define _EnergyProduction_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueDecimal; - - /** \brief Implements COMMAND_CLASS_ENERGY_PRODUCTION (0x90), a Z-Wave device command class. - */ - class EnergyProduction: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new EnergyProduction( _homeId, _nodeId ); } - virtual ~EnergyProduction(){} - - static uint8 const StaticGetCommandClassId(){ return 0x90; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_ENERGY_PRODUCTION"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _valueEnum, uint8 const _dummy, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - EnergyProduction( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Hail.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Hail.cpp deleted file mode 100644 index a3d5e35..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Hail.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Hail.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_HAIL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Hail.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -enum HailCmdEnum -{ - HailCmd_Hail = 1 -}; - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Hail::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( HailCmd_Hail == _data[0] ) - { - // We have received a hail from the Z-Wave device. - // Request an update of the dynamic values. - Log::Write( LogLevel_Info, GetNodeId(), "Received Hail command from node %d", GetNodeId() ); - if( Node* node = GetNodeUnsafe() ) - { - node->RequestDynamicValues(); - } - return true; - } - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Hail.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Hail.h deleted file mode 100644 index e19a535..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Hail.h +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Hail.h -// -// Implementation of the Z-Wave COMMAND_CLASS_HAIL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Hail_H -#define _Hail_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_HAIL (0x82), a Z-Wave device command class. - */ - class Hail: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Hail( _homeId, _nodeId ); } - virtual ~Hail(){} - - static uint8 const StaticGetCommandClassId(){ return 0x82; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_HAIL"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - Hail( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Indicator.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Indicator.cpp deleted file mode 100644 index d09b543..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Indicator.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Indicator.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_INDICATOR -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Indicator.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" - -using namespace OpenZWave; - -enum IndicatorCmd -{ - IndicatorCmd_Set = 0x01, - IndicatorCmd_Get = 0x02, - IndicatorCmd_Report = 0x03 -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Indicator::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Indicator::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "IndicatorCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( IndicatorCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "IndicatorCmd_Get Not Supported on this node"); - } - return false; -} - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Indicator::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( IndicatorCmd_Report == (IndicatorCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received an Indicator report: Indicator=%d", _data[1] ); - - if( ValueByte* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] != 0 ); - value->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the device's indicator value -//----------------------------------------------------------------------------- -bool Indicator::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_Byte == _value.GetID().GetType() ) - { - ValueByte const* value = static_cast(&_value); - - Log::Write( LogLevel_Info, GetNodeId(), "Indicator::SetValue - Setting indicator to %d", value->GetValue()); - Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( IndicatorCmd_Set ); - msg->Append( value->GetValue() ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Indicator::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Indicator", "", false, false, false, 0 ); - } -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Indicator.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Indicator.h deleted file mode 100644 index 272e98c..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Indicator.h +++ /dev/null @@ -1,66 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Indicator.h -// -// Implementation of the Z-Wave COMMAND_CLASS_INDICATOR -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Indicator_H -#define _Indicator_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - - /** \brief Implements COMMAND_CLASS_INDICATOR (0x87), a Z-Wave device command class. - */ - class Indicator: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Indicator( _homeId, _nodeId ); } - virtual ~Indicator(){} - - static uint8 const StaticGetCommandClassId(){ return 0x87; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_INDICATOR"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Indicator( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Language.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Language.cpp deleted file mode 100644 index 2047e7b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Language.cpp +++ /dev/null @@ -1,164 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Language.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_LANGUAGE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Language.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueString.h" - -using namespace OpenZWave; - -enum LanguageCmd -{ - LanguageCmd_Set = 0x01, - LanguageCmd_Get = 0x02, - LanguageCmd_Report = 0x03 -}; - -enum -{ - LanguageIndex_Language = 0, - LanguageIndex_Country -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Language::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Language::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "LanguageCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( LanguageCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "LanguageCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Language::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( LanguageCmd_Report == (LanguageCmd)_data[0] ) - { - char language[4]; - char country[3]; - - language[0] = _data[1]; - language[1] = _data[2]; - language[2] = _data[3]; - language[3] = 0; - - country[0] = _data[4]; - country[1] = _data[5]; - country[2] = 0; - - Log::Write( LogLevel_Info, GetNodeId(), "Received Language report: Language=%s, Country=%s", language, country ); - ClearStaticRequest( StaticRequest_Values ); - - if( ValueString* languageValue = static_cast( GetValue( _instance, LanguageIndex_Language ) ) ) - { - languageValue->OnValueRefreshed( language ); - languageValue->Release(); - } - if( ValueString* countryValue = static_cast( GetValue( _instance, LanguageIndex_Country ) ) ) - { - countryValue->OnValueRefreshed( country ); - countryValue->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Language::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, (uint8)LanguageIndex_Language, "Language", "", false, false, "", 0 ); - node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, (uint8)LanguageIndex_Country, "Country", "", false, false, "", 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Language.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Language.h deleted file mode 100644 index 8daead3..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Language.h +++ /dev/null @@ -1,65 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Language.h -// -// Implementation of the Z-Wave COMMAND_CLASS_LANGUAGE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Language_H -#define _Language_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueString; - - /** \brief Implements COMMAND_CLASS_LANGUAGE (0x89), a Z-Wave device command class. - */ - class Language: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Language( _homeId, _nodeId ); } - virtual ~Language(){} - - static uint8 const StaticGetCommandClassId(){ return 0x89; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_LANGUAGE"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Language( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){ SetStaticRequest( StaticRequest_Values ); } - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Lock.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Lock.cpp deleted file mode 100644 index 4afd22a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Lock.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Lock.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_LOCK -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Lock.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueBool.h" - -using namespace OpenZWave; - -enum LockCmd -{ - LockCmd_Set = 0x01, - LockCmd_Get = 0x02, - LockCmd_Report = 0x03 -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Lock::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Lock::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "LockCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( LockCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "LockCmd_Get Not Supported on this node"); - } - return false; -} - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Lock::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( LockCmd_Report == (LockCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received Lock report: Lock is %s", _data[1] ? "Locked" : "Unlocked" ); - - if( ValueBool* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] != 0 ); - value->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the lock's state -//----------------------------------------------------------------------------- -bool Lock::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_Bool == _value.GetID().GetType() ) - { - ValueBool const* value = static_cast(&_value); - - Log::Write( LogLevel_Info, GetNodeId(), "Lock::Set - Requesting lock to be %s", value->GetValue() ? "Locked" : "Unlocked" ); - Msg* msg = new Msg( "LockCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( LockCmd_Set ); - msg->Append( value->GetValue() ? 0x01:0x00 ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Lock::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Locked", "", false, false, false, 0 ); - } -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Lock.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Lock.h deleted file mode 100644 index 2a9ec94..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Lock.h +++ /dev/null @@ -1,66 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Lock.h -// -// Implementation of the Z-Wave COMMAND_CLASS_LOCK -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Lock_H -#define _Lock_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueBool; - - /** \brief Implements COMMAND_CLASS_LOCK (0x76), a Z-Wave device command class. - */ - class Lock: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Lock( _homeId, _nodeId ); } - virtual ~Lock(){} - - static uint8 const StaticGetCommandClassId(){ return 0x76; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_LOCK"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Lock( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ManufacturerSpecific.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ManufacturerSpecific.cpp deleted file mode 100644 index 0bddad9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ManufacturerSpecific.cpp +++ /dev/null @@ -1,444 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ManufacturerSpecific.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_MANUFACTURER_SPECIFIC -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ManufacturerSpecific.h" -#include "../tinyxml.h" - -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Options.h" -#include "../Manager.h" -#include "../Driver.h" -#include "../Notification.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueStore.h" -#include "../value_classes/ValueString.h" - -using namespace OpenZWave; - -enum ManufacturerSpecificCmd -{ - ManufacturerSpecificCmd_Get = 0x04, - ManufacturerSpecificCmd_Report = 0x05 -}; - -map ManufacturerSpecific::s_manufacturerMap; -map ManufacturerSpecific::s_productMap; -bool ManufacturerSpecific::s_bXmlLoaded = false; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool ManufacturerSpecific::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool ManufacturerSpecific::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "ManufacturerSpecificCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ManufacturerSpecificCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ManufacturerSpecificCmd_Get Not Supported on this node"); - } - return false; -} - -string ManufacturerSpecific::SetProductDetails -( - Node* node, - uint16 manufacturerId, - uint16 productType, - uint16 productId -) -{ - char str[64]; - - if (!s_bXmlLoaded) LoadProductXML(); - - snprintf( str, sizeof(str), "Unknown: id=%.4x", manufacturerId ); - string manufacturerName = str; - - snprintf( str, sizeof(str), "Unknown: type=%.4x, id=%.4x", productType, productId ); - string productName = str; - - string configPath = ""; - - // Try to get the real manufacturer and product names - map::iterator mit = s_manufacturerMap.find( manufacturerId ); - if( mit != s_manufacturerMap.end() ) - { - // Replace the id with the real name - manufacturerName = mit->second; - - // Get the product - map::iterator pit = s_productMap.find( Product::GetKey( manufacturerId, productType, productId ) ); - if( pit != s_productMap.end() ) - { - productName = pit->second->GetProductName(); - configPath = pit->second->GetConfigPath(); - } - } - - // Set the values into the node - - // Only set the manufacturer and product name if they are - // empty - we don't want to overwrite any user defined names. - if( node->GetManufacturerName() == "" ) - { - node->SetManufacturerName( manufacturerName ); - } - - if( node->GetProductName() == "" ) - { - node->SetProductName( productName ); - } - - snprintf( str, sizeof(str), "%.4x", manufacturerId ); - node->SetManufacturerId( str ); - - snprintf( str, sizeof(str), "%.4x", productType ); - node->SetProductType( str ); - - snprintf( str, sizeof(str), "%.4x", productId ); - node->SetProductId( str ); - - return configPath; -} - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ManufacturerSpecific::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ManufacturerSpecificCmd_Report == (ManufacturerSpecificCmd)_data[0] ) - { - - // first two bytes are manufacturer id code - uint16 manufacturerId = (((uint16)_data[1])<<8) | (uint16)_data[2]; - - // next four are product type and product id - uint16 productType = (((uint16)_data[3])<<8) | (uint16)_data[4]; - uint16 productId = (((uint16)_data[5])<<8) | (uint16)_data[6]; - - if( Node* node = GetNodeUnsafe() ) - { - // Attempt to create the config parameters - string configPath = SetProductDetails( node, manufacturerId, productType, productId); - if( configPath.size() > 0 ) - { - LoadConfigXML( node, configPath ); - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received manufacturer specific report from node %d: Manufacturer=%s, Product=%s", - GetNodeId(), node->GetManufacturerName().c_str(), node->GetProductName().c_str() ); - ClearStaticRequest( StaticRequest_Values ); - node->m_manufacturerSpecificClassReceived = true; - } - - // Notify the watchers of the name changes - Notification* notification = new Notification( Notification::Type_NodeNaming ); - notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() ); - GetDriver()->QueueNotification( notification ); - - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Load the XML that maps manufacturer and product IDs to human-readable names -//----------------------------------------------------------------------------- -bool ManufacturerSpecific::LoadProductXML -( -) -{ - s_bXmlLoaded = true; - - // Parse the Z-Wave manufacturer and product XML file. - string configPath; - Options::Get()->GetOptionAsString( "ConfigPath", &configPath ); - - string filename = configPath + "manufacturer_specific.xml"; - - TiXmlDocument* pDoc = new TiXmlDocument(); - if( !pDoc->LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) - { - delete pDoc; - Log::Write( LogLevel_Info, "Unable to load %s", filename.c_str() ); - return false; - } - - TiXmlElement const* root = pDoc->RootElement(); - - char const* str; - char* pStopChar; - - TiXmlElement const* manufacturerElement = root->FirstChildElement(); - while( manufacturerElement ) - { - str = manufacturerElement->Value(); - if( str && !strcmp( str, "Manufacturer" ) ) - { - // Read in the manufacturer attributes - str = manufacturerElement->Attribute( "id" ); - if( !str ) - { - Log::Write( LogLevel_Info, "Error in manufacturer_specific.xml at line %d - missing manufacturer id attribute", manufacturerElement->Row() ); - delete pDoc; - return false; - } - uint16 manufacturerId = (uint16)strtol( str, &pStopChar, 16 ); - - str = manufacturerElement->Attribute( "name" ); - if( !str ) - { - Log::Write( LogLevel_Info, "Error in manufacturer_specific.xml at line %d - missing manufacturer name attribute", manufacturerElement->Row() ); - delete pDoc; - return false; - } - - // Add this manufacturer to the map - s_manufacturerMap[manufacturerId] = str; - - // Parse all the products for this manufacturer - TiXmlElement const* productElement = manufacturerElement->FirstChildElement(); - while( productElement ) - { - str = productElement->Value(); - if( str && !strcmp( str, "Product" ) ) - { - str = productElement->Attribute( "type" ); - if( !str ) - { - Log::Write( LogLevel_Info, "Error in manufacturer_specific.xml at line %d - missing product type attribute", productElement->Row() ); - delete pDoc; - return false; - } - uint16 productType = (uint16)strtol( str, &pStopChar, 16 ); - - str = productElement->Attribute( "id" ); - if( !str ) - { - Log::Write( LogLevel_Info, "Error in manufacturer_specific.xml at line %d - missing product id attribute", productElement->Row() ); - delete pDoc; - return false; - } - uint16 productId = (uint16)strtol( str, &pStopChar, 16 ); - - str = productElement->Attribute( "name" ); - if( !str ) - { - Log::Write( LogLevel_Info, "Error in manufacturer_specific.xml at line %d - missing product name attribute", productElement->Row() ); - delete pDoc; - return false; - } - string productName = str; - - // Optional config path - string configPath; - str = productElement->Attribute( "config" ); - if( str ) - { - configPath = str; - } - - // Add the product to the map - Product* product = new Product( manufacturerId, productType, productId, productName, configPath ); - if ( s_productMap[product->GetKey()] != NULL ) - { - Product *c = s_productMap[product->GetKey()]; - Log::Write( LogLevel_Info, "Product name collision: %s type %x id %x manufacturerid %x, collides with %s, type %x id %x manufacturerid %x", productName.c_str(), productType, productId, manufacturerId, c->GetProductName().c_str(), c->GetProductType(), c->GetProductId(), c->GetManufacturerId()); - delete product; - } - else - { - s_productMap[product->GetKey()] = product; - } - } - - // Move on to the next product. - productElement = productElement->NextSiblingElement(); - } - } - - // Move on to the next manufacturer. - manufacturerElement = manufacturerElement->NextSiblingElement(); - } - - delete pDoc; - return true; -} - -//----------------------------------------------------------------------------- -// -// Free the XML that maps manufacturer and product IDs -//----------------------------------------------------------------------------- -void ManufacturerSpecific::UnloadProductXML -( -) -{ - if (s_bXmlLoaded) - { - map::iterator pit = s_productMap.begin(); - while( !s_productMap.empty() ) - { - delete pit->second; - s_productMap.erase( pit ); - pit = s_productMap.begin(); - } - - map::iterator mit = s_manufacturerMap.begin(); - while( !s_manufacturerMap.empty() ) - { - s_manufacturerMap.erase( mit ); - mit = s_manufacturerMap.begin(); - } - - s_bXmlLoaded = false; - } -} - -//----------------------------------------------------------------------------- -// -// Try to find and load an XML file describing the device's config params -//----------------------------------------------------------------------------- -bool ManufacturerSpecific::LoadConfigXML -( - Node* _node, - string const& _configXML -) -{ - string configPath; - Options::Get()->GetOptionAsString( "ConfigPath", &configPath ); - - string filename = configPath + _configXML; - - TiXmlDocument* doc = new TiXmlDocument(); - Log::Write( LogLevel_Info, _node->GetNodeId(), " Opening config param file %s", filename.c_str() ); - if( !doc->LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) - { - delete doc; - Log::Write( LogLevel_Info, _node->GetNodeId(), "Unable to find or load Config Param file %s", filename.c_str() ); - return false; - } - - Node::QueryStage qs = _node->GetCurrentQueryStage(); - if( qs == Node::QueryStage_ManufacturerSpecific1 ) - { - _node->ReadDeviceProtocolXML( doc->RootElement() ); - } - else - { - if( !_node->m_manufacturerSpecificClassReceived ) - { - _node->ReadDeviceProtocolXML( doc->RootElement() ); - } - _node->ReadCommandClassesXML( doc->RootElement() ); - } - - delete doc; - return true; -} - -//----------------------------------------------------------------------------- -// -// Reload previously discovered device configuration. -//----------------------------------------------------------------------------- -void ManufacturerSpecific::ReLoadConfigXML -( -) -{ - if( Node* node = GetNodeUnsafe() ) - { - if (!s_bXmlLoaded) LoadProductXML(); - - uint16 manufacturerId = (uint16)strtol( node->GetManufacturerId().c_str(), NULL, 16 ); - uint16 productType = (uint16)strtol( node->GetProductType().c_str(), NULL, 16 ); - uint16 productId = (uint16)strtol( node->GetProductId().c_str(), NULL, 16 ); - - map::iterator mit = s_manufacturerMap.find( manufacturerId ); - if( mit != s_manufacturerMap.end() ) - { - map::iterator pit = s_productMap.find( Product::GetKey( manufacturerId, productType, productId ) ); - if( pit != s_productMap.end() ) - { - string configPath = pit->second->GetConfigPath(); - if( configPath.size() > 0 ) - { - LoadConfigXML( node, configPath ); - } - } - } - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ManufacturerSpecific.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ManufacturerSpecific.h deleted file mode 100644 index d316d06..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ManufacturerSpecific.h +++ /dev/null @@ -1,116 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ManufacturerSpecific.h -// -// Implementation of the Z-Wave COMMAND_CLASS_MANUFACTURER_SPECIFIC -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ManufacturerSpecific_H -#define _ManufacturerSpecific_H - -#include -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_MANUFACTURER_SPECIFIC (0x72), a Z-Wave device command class. - */ - class ManufacturerSpecific: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ManufacturerSpecific( _homeId, _nodeId ); } - virtual ~ManufacturerSpecific(){ UnloadProductXML(); } - - static uint8 const StaticGetCommandClassId(){ return 0x72; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_MANUFACTURER_SPECIFIC"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - static string SetProductDetails( Node *_node, uint16 _manufacturerId, uint16 _productType, uint16 _productId ); - static bool LoadConfigXML( Node* _node, string const& _configXML ); - - void ReLoadConfigXML(); - - private: - ManufacturerSpecific( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){ SetStaticRequest( StaticRequest_Values ); } - static bool LoadProductXML(); - static void UnloadProductXML(); - - class Product - { - public: - Product - ( - uint16 _manufacturerId, - uint16 _productType, - uint16 _productId, - string const& _productName, - string const& _configPath - ): - m_manufacturerId( _manufacturerId ), - m_productType( _productType ), - m_productId( _productId ), - m_productName( _productName ), - m_configPath( _configPath ) - { - } - - int64 GetKey()const - { - return( GetKey( m_manufacturerId, m_productType, m_productId ) ); - } - - static int64 GetKey( uint16 _manufacturerId, uint16 _productType, uint16 _productId ) - { - int64 key = (((int64)_manufacturerId)<<32) | (((int64)_productType)<<16) | (int64)_productId; - return key; - } - - uint16 GetManufacturerId()const{ return m_manufacturerId; } - uint16 GetProductType()const{ return m_productType; } - uint16 GetProductId()const{ return m_productId; } - string GetProductName()const{ return m_productName; } - string GetConfigPath()const{ return m_configPath; } - - private: - uint16 m_manufacturerId; - uint16 m_productType; - uint16 m_productId; - string m_productName; - string m_configPath; - }; - - static map s_manufacturerMap; - static map s_productMap; - static bool s_bXmlLoaded; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Meter.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Meter.cpp deleted file mode 100644 index fda399d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Meter.cpp +++ /dev/null @@ -1,562 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Meter.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_METER -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Meter.h" -#include "MultiInstance.h" -#include "../Defs.h" -#include "../Bitfield.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueDecimal.h" -#include "../value_classes/ValueList.h" -#include "../value_classes/ValueButton.h" -#include "../value_classes/ValueInt.h" -#include "../value_classes/ValueBool.h" - -using namespace OpenZWave; - -enum MeterCmd -{ - MeterCmd_Get = 0x01, - MeterCmd_Report = 0x02, - // Version 2 - MeterCmd_SupportedGet = 0x03, - MeterCmd_SupportedReport = 0x04, - MeterCmd_Reset = 0x05 -}; - -enum MeterType -{ - MeterType_Electric = 1, - MeterType_Gas, - MeterType_Water -}; - -enum -{ - MeterIndex_Exporting = 32, - MeterIndex_Reset -}; - - -static char const* c_meterTypes[] = -{ - "Unknown", - "Electric", - "Gas", - "Water" -}; - -static char const* c_electricityUnits[] = -{ - "kWh", - "kVAh", - "W", - "pulses", - "V", - "A", - "Power Factor", - "" -}; - -static char const* c_gasUnits[] = -{ - "cubic meters", - "cubic feet", - "", - "pulses", - "", - "", - "", - "" -}; - -static char const* c_waterUnits[] = -{ - "cubic meters", - "cubic feet", - "US gallons", - "pulses", - "", - "", - "", - "" -}; - -static char const* c_electricityLabels[] = -{ - "Energy", - "Energy", - "Power", - "Count", - "Voltage", - "Current", - "Power Factor", - "Unknown" -}; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Meter::Meter -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ) -{ - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Meter::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool res = false; - if( GetVersion() > 1 ) - { - if( _requestFlags & RequestFlag_Static ) - { - Msg* msg = new Msg( "MeterCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( MeterCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - res = true; - } - } - - if( _requestFlags & RequestFlag_Dynamic ) - { - res |= RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Meter::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool res = false; - if ( !IsGetSupported()) - { - Log::Write( LogLevel_Info, GetNodeId(), "MeterCmd_Get Not Supported on this node"); - return false; - } - for( uint8 i=0; i<8; ++i ) - { - uint8 baseIndex = i<<2; - - Value* value = GetValue( _instance, baseIndex ); - if( value != NULL ) - { - value->Release(); - Msg* msg = new Msg( "MeterCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( MeterCmd_Get ); - msg->Append( (uint8)( i << 3 ) ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - res |= true; - } - } - return res; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Meter::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - bool handled = false; - if (MeterCmd_SupportedReport == (MeterCmd)_data[0]) - { - handled = HandleSupportedReport( _data, _length, _instance ); - } - else if (MeterCmd_Report == (MeterCmd)_data[0]) - { - handled = HandleReport( _data, _length, _instance ); - } - - return handled; -} - -//----------------------------------------------------------------------------- -// -// Create the values for this command class based on the reported parameters -//----------------------------------------------------------------------------- -bool Meter::HandleSupportedReport -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance -) -{ - bool canReset = ((_data[1] & 0x80) != 0); - int8 meterType = (MeterType)(_data[1] & 0x1f); - if (meterType > 4) /* size of c_meterTypes */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "meterType Value was greater than range. Dropping Message"); - return false; - } - - - ClearStaticRequest( StaticRequest_Version ); - if( Node* node = GetNodeUnsafe() ) - { - string msg; - msg = c_meterTypes[meterType]; - msg += ": "; - // Create the list of supported scales - uint8 scaleSupported = _data[2]; - if( GetVersion() == 2 ) - { - // Only four scales are allowed in version 2 - scaleSupported &= 0x0f; - } - - for( uint8 i=0; i<8; ++i ) - { - if( scaleSupported & (1<( GetValue( _instance, baseIndex ) ) ) - { - value->SetLabel( c_electricityLabels[i] ); - value->SetUnits( c_electricityUnits[i] ); - value->Release(); - } - else - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, baseIndex, c_electricityLabels[i], c_electricityUnits[i], true, false, "0.0", 0 ); - } - if( i != 0 ) - msg += ", "; - msg += c_electricityUnits[i]; - break; - } - case MeterType_Gas: - { - if( ValueDecimal* value = static_cast( GetValue( _instance, baseIndex ) ) ) - { - value->SetLabel( c_meterTypes[MeterType_Gas] ); - value->SetUnits( c_gasUnits[i] ); - value->Release(); - } - else - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, baseIndex, c_meterTypes[meterType], c_gasUnits[i], true, false, "0.0", 0 ); - } - if( i != 0 ) - msg += ", "; - msg += c_gasUnits[i]; - break; - } - case MeterType_Water: - { - if( ValueDecimal* value = static_cast( GetValue( _instance, baseIndex ) ) ) - { - value->SetLabel( c_meterTypes[MeterType_Water] ); - value->SetUnits( c_waterUnits[i] ); - value->Release(); - } - else - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, baseIndex, c_meterTypes[meterType], c_waterUnits[i], true, false, "0.0", 0 ); - } - if( i != 0 ) - msg += ", "; - msg += c_waterUnits[i]; - break; - } - default: - { - break; - } - } - } - } - - // Create the export flag - node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, MeterIndex_Exporting, "Exporting", "", true, false, false, 0 ); - - // Create the reset button - if( canReset ) - { - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, MeterIndex_Reset, "Reset", 0 ); - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received Meter supported report from node %d, %s", GetNodeId(), msg.c_str() ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Read the reported meter value -//----------------------------------------------------------------------------- -bool Meter::HandleReport -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance -) -{ - // Import or Export (only valid in version > 1) - bool exporting = false; - if( GetVersion() > 1 ) - { - exporting = ((_data[1] & 0x60) == 0x40 ); - if( ValueBool* value = static_cast( GetValue( _instance, MeterIndex_Exporting ) ) ) - { - value->OnValueRefreshed( exporting ); - value->Release(); - } - } - - // Get the value and scale - uint8 scale; - uint8 precision = 0; - string valueStr = ExtractValue( &_data[2], &scale, &precision ); - - if (scale > 7) /* size of c_electricityLabels, c_electricityUnits, c_gasUnits, c_waterUnits */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Scale was greater than range. Setting to Invalid"); - scale = 7; - } - - - if( GetVersion() == 1 ) - { - // In version 1, we don't know the scale until we get the first value report - string label; - string units; - int8 meterType = (MeterType)(_data[1] & 0x1f); - if (meterType > 4) /* size of c_meterTypes */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "meterType Value was greater than range. Dropping Message"); - return false; - } - - switch( (MeterType)(_data[1] & 0x1f) ) - { - case MeterType_Electric: - { - // Electricity Meter - label = c_electricityLabels[scale]; - units = c_electricityUnits[scale]; - break; - } - case MeterType_Gas: - { - // Gas Meter - label = c_meterTypes[MeterType_Gas]; - units = c_gasUnits[scale]; - break; - } - case MeterType_Water: - { - // Water Meter - label = c_meterTypes[MeterType_Water]; - units = c_waterUnits[scale]; - break; - } - default: - { - break; - } - } - - if( ValueDecimal* value = static_cast( GetValue( _instance, 0 ) ) ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received Meter report from node %d: %s=%s%s", GetNodeId(), label.c_str(), valueStr.c_str(), units.c_str() ); - value->SetLabel( label ); - value->SetUnits( units ); - value->OnValueRefreshed( valueStr ); - if( value->GetPrecision() != precision ) - { - value->SetPrecision( precision ); - } - value->Release(); - } - } - else - { - // Version 2 and above - uint8 baseIndex = scale << 2; - if( GetVersion() > 2 ) - { - // In version 3, an extra scale bit is stored in the meter type byte. - scale |= ((_data[1]&0x80)>>5); - baseIndex = scale << 2; - } - - if( ValueDecimal* value = static_cast( GetValue( _instance, baseIndex ) ) ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received Meter report from node %d: %s%s=%s%s", GetNodeId(), exporting ? "Exporting ": "", value->GetLabel().c_str(), valueStr.c_str(), value->GetUnits().c_str() ); - value->OnValueRefreshed( valueStr ); - if( value->GetPrecision() != precision ) - { - value->SetPrecision( precision ); - } - value->Release(); - - // Read any previous value and time delta - uint8 size = _data[2] & 0x07; - uint16 delta = (uint16)( (_data[3+size]<<8) | _data[4+size]); - - if( delta ) - { - // There is only a previous value if the time delta is non-zero - ValueDecimal* previous = static_cast( GetValue( _instance, baseIndex+1 ) ); - if( NULL == previous ) - { - // We need to create a value to hold the previous - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, baseIndex+1, "Previous Reading", value->GetUnits().c_str(), true, false, "0.0", 0 ); - previous = static_cast( GetValue( _instance, baseIndex+1 ) ); - } - } - if( previous ) - { - precision = 0; - valueStr = ExtractValue( &_data[2], &scale, &precision, 3+size ); - Log::Write( LogLevel_Info, GetNodeId(), " Previous value was %s%s, received %d seconds ago.", valueStr.c_str(), previous->GetUnits().c_str(), delta ); - previous->OnValueRefreshed( valueStr ); - if( previous->GetPrecision() != precision ) - { - previous->SetPrecision( precision ); - } - previous->Release(); - } - - // Time delta - ValueInt* interval = static_cast( GetValue( _instance, baseIndex+2 ) ); - if( NULL == interval ) - { - // We need to create a value to hold the time delta - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueInt( ValueID::ValueGenre_User, GetCommandClassId(), _instance, baseIndex+2, "Interval", "seconds", true, false, 0, 0 ); - interval = static_cast( GetValue( _instance, baseIndex+2 ) ); - } - } - if( interval ) - { - interval->OnValueRefreshed( (int32)delta ); - interval->Release(); - } - } - } - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Set the device's scale, or reset its accumulated values. -//----------------------------------------------------------------------------- -bool Meter::SetValue -( - Value const& _value -) -{ - if( MeterIndex_Reset == _value.GetID().GetIndex() ) - { - ValueButton const* button = static_cast(&_value); - if( button->IsPressed() ) - { - Msg* msg = new Msg( "MeterCmd_Reset", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( MeterCmd_Reset ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Meter::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Unknown", "", true, false, "0.0", 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Meter.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Meter.h deleted file mode 100644 index 10f061c..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Meter.h +++ /dev/null @@ -1,72 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Meter.h -// -// Implementation of the Z-Wave COMMAND_CLASS_METER -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Meter_H -#define _Meter_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueDecimal; - - /** \brief Implements COMMAND_CLASS_METER (0x32), a Z-Wave device command class. - */ - class Meter: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Meter( _homeId, _nodeId ); } - virtual ~Meter(){} - - static uint8 const StaticGetCommandClassId(){ return 0x32; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_METER"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - virtual uint8 GetMaxVersion(){ return 3; } - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Meter( uint32 const _homeId, uint8 const _nodeId ); - - bool HandleSupportedReport( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - bool HandleReport( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - }; - -} // namespace OpenZWave - - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MeterPulse.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MeterPulse.cpp deleted file mode 100644 index 0b57e5a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MeterPulse.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MeterPulse.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_METER_PULSE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "MeterPulse.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueInt.h" - -using namespace OpenZWave; - -enum MeterPulseCmd -{ - MeterPulseCmd_Get = 0x04, - MeterPulseCmd_Report = 0x05 -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool MeterPulse::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool MeterPulse::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "MeterPulseCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( MeterPulseCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "MeterPulseCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool MeterPulse::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( MeterPulseCmd_Report == (MeterPulseCmd)_data[0] ) - { - int32 count = 0; - for( uint8 i=0; i<4; ++i ) - { - count <<= 8; - count |= (uint32)_data[i+1]; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received a meter pulse count: Count=%d", count ); - if( ValueInt* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( count ); - value->Release(); - } - - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void MeterPulse::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueInt( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Count", "", true, false, 0, 0 ); - } -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MeterPulse.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MeterPulse.h deleted file mode 100644 index 2f267d2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MeterPulse.h +++ /dev/null @@ -1,65 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MeterPulse.h -// -// Implementation of the Z-Wave COMMAND_CLASS_METER_PULSE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _MeterPulse_H -#define _MeterPulse_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueInt; - - /** \brief Implements COMMAND_CLASS_METER_PULSE (0x35), a Z-Wave device command class. - */ - class MeterPulse: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new MeterPulse( _homeId, _nodeId ); } - virtual ~MeterPulse(){} - - static uint8 const StaticGetCommandClassId(){ return 0x35; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_METER_PULSE"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - MeterPulse( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiCmd.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiCmd.cpp deleted file mode 100644 index f5b2898..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiCmd.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MultiCmd.h -// -// Implementation of the Z-Wave COMMAND_CLASS_MULTI_CMD -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "MultiCmd.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool MultiCmd::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( MultiCmdCmd_Encap == (MultiCmdCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received encapsulated multi-command from node %d", GetNodeId() ); - - if( Node const* node = GetNodeUnsafe() ) - { - // Iterate over commands - uint8 base = 2; - for( uint8 i=0; i<_data[1]; ++i ) - { - uint8 length = _data[base]; - uint8 commandClassId = _data[base+1]; - - if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) - { - pCommandClass->HandleMsg( &_data[base+2], length-1 ); - } - - base += (length + 1); - } - } - - Log::Write( LogLevel_Info, GetNodeId(), "End of encapsulated multi-command from node %d", GetNodeId() ); - return true; - } - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiCmd.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiCmd.h deleted file mode 100644 index 5cbb855..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiCmd.h +++ /dev/null @@ -1,63 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MultiCmd.h -// -// Implementation of the Z-Wave COMMAND_CLASS_MULTI_CMD -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _MultiCmd_H -#define _MultiCmd_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_MULTI_CMD (0x8f), a Z-Wave device command class. - */ - class MultiCmd: public CommandClass - { - public: - enum MultiCmdCmd - { - MultiCmdCmd_Encap = 0x01 - }; - - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new MultiCmd( _homeId, _nodeId ); } - virtual ~MultiCmd(){} - - static uint8 const StaticGetCommandClassId(){ return 0x8f; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_MULTI_CMD"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - MultiCmd( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstance.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstance.cpp deleted file mode 100644 index d05b999..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstance.cpp +++ /dev/null @@ -1,676 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MultiInstance.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_MULTI_INSTANCE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "CommandClasses.h" -#include "Basic.h" -#include "MultiInstance.h" -#include "NoOperation.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -// Reduced set of Generic Device classes sorted to reduce -// the likely number of calls to MultiChannelCmd_EndPointFind. -uint8 const c_genericClass[] = -{ - 0x21, // Multilevel Sensor - 0x20, // Binary Sensor - 0x31, // Meter - 0x08, // Thermostat - 0x11, // Multilevel Switch - 0x10, // Binary Switch - 0x12, // Remote Switch - 0xa1, // Alarm Sensor - 0x16, // Ventilation - 0x30, // Pulse Meter - 0x40, // Entry Control - 0x13, // Toggle Switch - 0x03, // AV Control Point - 0x04, // Display - 0x00 // End of list -}; - -char const* c_genericClassName[] = -{ - "Multilevel Sensor", - "Binary Sensor", - "Meter", - "Thermostat", - "Multilevel Switch", - "Binary Switch", - "Remote Switch", - "Alarm Sensor", - "Ventilation", - "Pulse Meter", - "Entry Control", - "Toggle Switch", - "AV Control Point", - "Display", - "Unknown" -}; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -MultiInstance::MultiInstance -( - uint32 const _homeId, - uint8 const _nodeId -): -CommandClass( _homeId, _nodeId ), -m_numEndPoints( 0 ), -m_numEndPointsHint( 0 ), -m_endPointMap( MultiInstanceMapAll ), -m_endPointFindSupported( false ) -{ -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void MultiInstance::ReadXML -( - TiXmlElement const* _ccElement -) -{ - int32 intVal; - char const* str; - - CommandClass::ReadXML( _ccElement ); - - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "endpoints", &intVal ) ) - { - m_numEndPointsHint = (uint8)intVal; - } - - str = _ccElement->Attribute("mapping"); - if( str ) - { - if( strcmp( str, "all") == 0 ) - { - m_endPointMap = MultiInstanceMapAll; - } - else if( strcmp( str, "endpoints") == 0 ) - { - m_endPointMap = MultiInstanceMapEndPoints; - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Bad value for mapping: %s", str); - } - } - - str = _ccElement->Attribute("findsupport"); - if( str ) - { - m_endPointFindSupported = !strcmp( str, "true"); - } - str = _ccElement->Attribute("ignoreUnsolicitedMultiChnCapReport"); - if( str ) - { - m_ignoreUnsolicitedMultiChannelCapabilityReport = !strcmp( str, "true"); - } -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void MultiInstance::WriteXML -( - TiXmlElement* _ccElement -) -{ - char str[32]; - - CommandClass::WriteXML( _ccElement ); - if( m_numEndPointsHint != 0 ) - { - snprintf( str, sizeof(str), "%d", m_numEndPointsHint ); - _ccElement->SetAttribute( "endpoints", str); - } - - if( m_endPointMap == MultiInstanceMapEndPoints ) - { - _ccElement->SetAttribute( "mapping", "endpoints" ); - } - - if( m_endPointFindSupported ) - { - _ccElement->SetAttribute( "findsupport", "true" ); - } -} - -//----------------------------------------------------------------------------- -// -// Request number of instances of the specified command class from the device -//----------------------------------------------------------------------------- -bool MultiInstance::RequestInstances -( -) -{ - bool res = false; - - if( GetVersion() == 1 ) - { - if( Node* node = GetNodeUnsafe() ) - { - // MULTI_INSTANCE - char str[128]; - for( map::const_iterator it = node->m_commandClassMap.begin(); it != node->m_commandClassMap.end(); ++it ) - { - CommandClass* cc = it->second; - if( cc->GetCommandClassId() == NoOperation::StaticGetCommandClassId() ) - { - continue; - } - if( cc->HasStaticRequest( StaticRequest_Instances ) ) - { - snprintf( str, sizeof( str ), "MultiInstanceCmd_Get for %s", cc->GetCommandClassName().c_str() ); - - Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( MultiInstanceCmd_Get ); - msg->Append( cc->GetCommandClassId() ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Query ); - res = true; - } - } - } - } - else - { - // MULTI_CHANNEL - char str[128]; - snprintf( str, sizeof( str ), "MultiChannelCmd_EndPointGet for node %d", GetNodeId() ); - - Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( MultiChannelCmd_EndPointGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Query ); - res = true; - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool MultiInstance::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - bool handled = false; - Node* node = GetNodeUnsafe(); - if( node != NULL ) - { - handled = true; - switch( (MultiInstanceCmd)_data[0] ) - { - case MultiInstanceCmd_Report: - { - HandleMultiInstanceReport( _data, _length ); - break; - } - case MultiInstanceCmd_Encap: - { - HandleMultiInstanceEncap( _data, _length ); - break; - } - case MultiChannelCmd_EndPointReport: - { - HandleMultiChannelEndPointReport( _data, _length ); - break; - } - case MultiChannelCmd_CapabilityReport: - { - HandleMultiChannelCapabilityReport( _data, _length ); - break; - } - case MultiChannelCmd_EndPointFindReport: - { - HandleMultiChannelEndPointFindReport( _data, _length ); - break; - } - case MultiChannelCmd_Encap: - { - HandleMultiChannelEncap( _data, _length ); - break; - } - default: - { - handled = false; - break; - } - } - } - - return handled; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -void MultiInstance::HandleMultiInstanceReport -( - uint8 const* _data, - uint32 const _length -) -{ - if( Node* node = GetNodeUnsafe() ) - { - uint8 commandClassId = _data[1]; - uint8 instances = _data[2]; - - if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received MultiInstanceReport from node %d for %s: Number of instances = %d", GetNodeId(), pCommandClass->GetCommandClassName().c_str(), instances ); - pCommandClass->SetInstances( instances ); - pCommandClass->ClearStaticRequest( StaticRequest_Instances ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -void MultiInstance::HandleMultiInstanceEncap -( - uint8 const* _data, - uint32 const _length -) -{ - if( Node* node = GetNodeUnsafe() ) - { - uint8 instance = _data[1]; - if( GetVersion() > 1 ) - { - instance &= 0x7f; - } - uint8 commandClassId = _data[2]; - - if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received a MultiInstanceEncap from node %d, instance %d, for Command Class %s", GetNodeId(), instance, pCommandClass->GetCommandClassName().c_str() ); - pCommandClass->ReceivedCntIncr(); - pCommandClass->HandleMsg( &_data[3], _length-3, instance ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -void MultiInstance::HandleMultiChannelEndPointReport -( - uint8 const* _data, - uint32 const _length -) -{ - int len; - - if( m_numEndPoints != 0 ) - { - return; - } - - m_numEndPointsCanChange = (( _data[1] & 0x80 ) != 0 ); // Number of endpoints can change. - m_endPointsAreSameClass = (( _data[1] & 0x40 ) != 0 ); // All endpoints are the same command class. - m_numEndPoints = _data[2] & 0x7f; - if( m_numEndPointsHint != 0 ) - { - m_numEndPoints = m_numEndPointsHint; // don't use device's number - } - - len = m_numEndPoints; - if( m_endPointsAreSameClass ) // only need to check single end point - { - len = 1; - Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointReport from node %d. All %d endpoints are the same.", GetNodeId(), m_numEndPoints ); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointReport from node %d. %d endpoints are not all the same.", GetNodeId(), m_numEndPoints ); - } - - // This code assumes the endpoints are all in numeric sequential order. - // Since the end point finds do not appear to work this is the best estimate. - for( uint8 i = 1; i <= len; i++ ) - { - - // Send a single capability request to each endpoint - char str[128]; - snprintf( str, sizeof( str ), "MultiChannelCmd_CapabilityGet for endpoint %d", i ); - Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( MultiChannelCmd_CapabilityGet ); - msg->Append( i ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -void MultiInstance::HandleMultiChannelCapabilityReport -( - uint8 const* _data, - uint32 const _length -) -{ - - bool dynamic = ((_data[1] & 0x80)!=0); - - - if( Node* node = GetNodeUnsafe() ) - { - /* if you having problems with Dynamic Devices not correctly - * updating the commandclasses, see this email thread: - * https://groups.google.com/d/topic/openzwave/IwepxScRAVo/discussion - */ - if ((m_ignoreUnsolicitedMultiChannelCapabilityReport && (node->GetCurrentQueryStage() != Node::QueryStage_Instances)) - && !dynamic && m_endPointCommandClasses.size() > 0) { - Log::Write(LogLevel_Error, GetNodeId(), "Recieved a Unsolicited MultiChannelEncap when we are not in QueryState_Instances"); - return; - } - - uint8 endPoint = _data[1] & 0x7f; - - Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelCapabilityReport from node %d for endpoint %d", GetNodeId(), endPoint ); - Log::Write( LogLevel_Info, GetNodeId(), " Endpoint is%sdynamic, and is a %s", dynamic ? " " : " not ", node->GetEndPointDeviceClassLabel( _data[2], _data[3] ).c_str() ); - Log::Write( LogLevel_Info, GetNodeId(), " Command classes supported by the endpoint are:" ); - - // Store the command classes for later use - bool afterMark = false; - m_endPointCommandClasses.clear(); - uint8 numCommandClasses = _length - 5; - for( uint8 i = 0; i < numCommandClasses; ++i ) - { - uint8 commandClassId = _data[i+4]; - if( commandClassId == 0xef ) - { - afterMark = true; - continue; - } - - m_endPointCommandClasses.insert( commandClassId ); - - // Ensure the node supports this command class - CommandClass* cc = node->GetCommandClass( commandClassId ); - if( !cc ) - { - cc = node->AddCommandClass( commandClassId ); - if( cc && afterMark ) - { - cc->SetAfterMark(); - } - } - if( cc ) - { - Log::Write( LogLevel_Info, GetNodeId(), " %s", cc->GetCommandClassName().c_str() ); - } - } - - // Create internal library instances for each command class in the list - // Also set up mapping from intances to endpoints for encapsulation - Basic* basic = static_cast( node->GetCommandClass( Basic::StaticGetCommandClassId() ) ); - if( m_endPointsAreSameClass ) // Create all the same instances here - { - int len; - - if( m_endPointMap == MultiInstanceMapAll ) // Include the non-endpoint instance - { - endPoint = 0; - len = m_numEndPoints + 1; - } - else - { - endPoint = 1; - len = m_numEndPoints; - } - - // Create all the command classes for all the endpoints - for( uint8 i = 1; i <= len; i++ ) - { - for( set::iterator it = m_endPointCommandClasses.begin(); it != m_endPointCommandClasses.end(); ++it ) - { - uint8 commandClassId = *it; - CommandClass* cc = node->GetCommandClass( commandClassId ); - if( cc ) - { - cc->SetInstance( i ); - if( m_endPointMap != MultiInstanceMapAll || i != 1 ) - { - cc->SetEndPoint( i, endPoint ); - } - // If we support the BASIC command class and it is mapped to a command class - // assigned to this end point, make sure the BASIC command class is also associated - // with this end point. - if( basic != NULL && basic->GetMapping() == commandClassId ) - { - basic->SetInstance( i ); - if( m_endPointMap != MultiInstanceMapAll || i != 1 ) - { - basic->SetEndPoint( i, endPoint ); - } - } - } - } - endPoint++; - } - } - else // Endpoints are different - { - for( set::iterator it = m_endPointCommandClasses.begin(); it != m_endPointCommandClasses.end(); ++it ) - { - uint8 commandClassId = *it; - CommandClass* cc = node->GetCommandClass( commandClassId ); - if( cc ) - { - uint8 i; - // Find the next free instance of this class - for( i = 1; i <= 127; i++ ) - { - if( m_endPointMap == MultiInstanceMapAll ) // Include the non-endpoint instance - { - if( !cc->GetInstances()->IsSet( i ) ) - { - break; - } - } - // Reuse non-endpoint instances first time we see it - else if( i == 1 && cc->GetInstances()->IsSet( i ) && cc->GetEndPoint( i ) == 0 ) - { - break; - } - // Find the next free instance - else if( !cc->GetInstances()->IsSet( i ) ) - { - break; - } - } - cc->SetInstance( i ); - cc->SetEndPoint( i, endPoint ); - // If we support the BASIC command class and it is mapped to a command class - // assigned to this end point, make sure the BASIC command class is also associated - // with this end point. - if( basic != NULL && basic->GetMapping() == commandClassId ) - { - basic->SetInstance( i ); - basic->SetEndPoint( i, endPoint ); - } - } - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -void MultiInstance::HandleMultiChannelEndPointFindReport -( - uint8 const* _data, - uint32 const _length -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointFindReport from node %d", GetNodeId() ); - uint8 numEndPoints = _length - 5; - for( uint8 i=0; i::iterator it=m_endPointCommandClasses.begin(); it!=m_endPointCommandClasses.end(); ++it ) - { - uint8 commandClassId = *it; - CommandClass* cc = node->GetCommandClass( commandClassId ); - if( cc ) - { - Log::Write( LogLevel_Info, GetNodeId(), " Endpoint %d: Adding %s", endPoint, cc->GetCommandClassName().c_str() ); - cc->SetInstance( endPoint ); - } - } - } - } - else - { - // Endpoints are different, so request the capabilities - char str[128]; - snprintf( str, 128, "MultiChannelCmd_CapabilityGet for node %d, endpoint %d", GetNodeId(), endPoint ); - Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( MultiChannelCmd_CapabilityGet ); - msg->Append( endPoint ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } - } - - m_numEndPointsFound += numEndPoints; - if( !m_endPointsAreSameClass ) - { - if( _data[1] == 0 ) - { - // No more reports to follow this one, so we can continue the search. - if( m_numEndPointsFound < numEndPoints ) - { - // We have not yet found all the endpoints, so move to the next generic class request - ++m_endPointFindIndex; - if (m_endPointFindIndex <= 13) /* we are finished */ - { - if( c_genericClass[m_endPointFindIndex] > 0 ) - { - if (m_endPointFindIndex > 13) /* size of c_genericClassName minus Unknown Entry */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "m_endPointFindIndex Value was greater than range. Setting to Unknown"); - m_endPointFindIndex = 14; - } - - char str[128]; - snprintf( str, 128, "MultiChannelCmd_EndPointFind for generic device class 0x%.2x (%s)", c_genericClass[m_endPointFindIndex], c_genericClassName[m_endPointFindIndex] ); - Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( MultiChannelCmd_EndPointFind ); - msg->Append( c_genericClass[m_endPointFindIndex] ); // Generic device class - msg->Append( 0xff ); // Any specific device class - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - } - } else { - Log::Write (LogLevel_Warning, GetNodeId(), "m_endPointFindIndex is higher than range. Not Sending MultiChannelCmd_EndPointFind message"); - } - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -void MultiInstance::HandleMultiChannelEncap -( - uint8 const* _data, - uint32 const _length -) -{ - if( Node* node = GetNodeUnsafe() ) - { - uint8 endPoint = _data[1] & 0x7f; - uint8 commandClassId = _data[3]; - if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) - { - uint8 instance = pCommandClass->GetInstance( endPoint ); - if( instance == 0 ) - { - Log::Write( LogLevel_Error, GetNodeId(), "Cannot find endpoint map to instance for Command Class %s endpoint %d", pCommandClass->GetCommandClassName().c_str(), endPoint ); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received a MultiChannelEncap from node %d, endpoint %d for Command Class %s", GetNodeId(), endPoint, pCommandClass->GetCommandClassName().c_str() ); - pCommandClass->HandleMsg( &_data[4], _length-4, instance ); - } - } else { - Log::Write(LogLevel_Error, GetNodeId(), "Recieved a MultiChannelEncap for endpoint %d for Command Class %d, which we can't find", endPoint, commandClassId); - } - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstance.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstance.h deleted file mode 100644 index da7be17..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstance.h +++ /dev/null @@ -1,111 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MultiInstance.h -// -// Implementation of the Z-Wave COMMAND_CLASS_MULTI_INSTANCE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _MultiInstance_H -#define _MultiInstance_H - -#include -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_MULTI_INSTANCE (0x60), a Z-Wave device command class. - */ - class MultiInstance: public CommandClass - { - public: - enum MultiInstanceCmd - { - MultiInstanceCmd_Get = 0x04, - MultiInstanceCmd_Report = 0x05, - MultiInstanceCmd_Encap = 0x06, - - // Version 2 - MultiChannelCmd_EndPointGet = 0x07, - MultiChannelCmd_EndPointReport = 0x08, - MultiChannelCmd_CapabilityGet = 0x09, - MultiChannelCmd_CapabilityReport = 0x0a, - MultiChannelCmd_EndPointFind = 0x0b, - MultiChannelCmd_EndPointFindReport = 0x0c, - MultiChannelCmd_Encap = 0x0d - }; - - enum MultiInstanceMapping - { - MultiInstanceMapAll, - MultiInstanceMapEndPoints, - MultiInstanceMapOther - }; - - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new MultiInstance( _homeId, _nodeId ); } - virtual ~MultiInstance(){} - - static uint8 const StaticGetCommandClassId(){ return 0x60; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_MULTI_INSTANCE/CHANNEL"; } - - bool RequestInstances(); - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual uint8 GetMaxVersion(){ return 2; } - - MultiInstanceMapping GetEndPointMap(){ return m_endPointMap; } - - private: - MultiInstance( uint32 const _homeId, uint8 const _nodeId ); - - void HandleMultiInstanceReport( uint8 const* _data, uint32 const _length ); - void HandleMultiInstanceEncap( uint8 const* _data, uint32 const _length ); - void HandleMultiChannelEndPointReport( uint8 const* _data, uint32 const _length ); - void HandleMultiChannelCapabilityReport( uint8 const* _data, uint32 const _length ); - void HandleMultiChannelEndPointFindReport( uint8 const* _data, uint32 const _length ); - void HandleMultiChannelEncap( uint8 const* _data, uint32 const _length ); - - bool m_numEndPointsCanChange; - bool m_endPointsAreSameClass; - uint8 m_numEndPoints; - - // Finding endpoints - uint8 m_endPointFindIndex; - uint8 m_numEndPointsFound; - set m_endPointCommandClasses; - - // configuration - uint8 m_numEndPointsHint; // for nodes that do not report correct number of end points - MultiInstanceMapping m_endPointMap; // Determine how to map end points to value id instances - bool m_endPointFindSupported; // for nodes that (someday may) support endpointfind - bool m_ignoreUnsolicitedMultiChannelCapabilityReport; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstanceAssociation.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstanceAssociation.cpp deleted file mode 100644 index a6bd8b5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstanceAssociation.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MultiInstanceAssociation.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "MultiInstanceAssociation.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -enum MultiInstanceAssociationCmd -{ - MultiInstanceAssociationCmd_Set = 0x01, - MultiInstanceAssociationCmd_Get = 0x02, - MultiInstanceAssociationCmd_Report = 0x03, - MultiInstanceAssociationCmd_Remove = 0x04, - MultiInstanceAssociationCmd_GroupingsGet = 0x05, - MultiInstanceAssociationCmd_GroupingsReport = 0x06 -}; - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool MultiInstanceAssociation::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstanceAssociation.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstanceAssociation.h deleted file mode 100644 index 53da98e..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/MultiInstanceAssociation.h +++ /dev/null @@ -1,59 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MultiInstanceAssociation.h -// -// Implementation of the Z-Wave COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _MultiInstanceAssociation_H -#define _MultiInstanceAssociation_H - -#include -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION (0x8E), a Z-Wave device command class. - */ - class MultiInstanceAssociation: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new MultiInstanceAssociation( _homeId, _nodeId ); } - virtual ~MultiInstanceAssociation(){} - - static uint8 const StaticGetCommandClassId(){ return 0x8e; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - MultiInstanceAssociation( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NoOperation.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/NoOperation.cpp deleted file mode 100644 index 42e65df..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NoOperation.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//----------------------------------------------------------------------------- -// -// NoOperation.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_NO_OPERATION -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "NoOperation.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool NoOperation::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - // We have received a no operation from the Z-Wave device. - Log::Write( LogLevel_Info, GetNodeId(), "Received NoOperation command from node %d", GetNodeId() ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Send a No Operation message class. -//----------------------------------------------------------------------------- -void NoOperation::Set -( - bool const _route, - Driver::MsgQueue _queue // = Driver::MsgQueue_NoOp -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "NoOperation::Set - Routing=%s", _route ? "true" : "false" ); - - Msg* msg = new Msg( "NoOperation_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( 0 ); - if( _route ) - msg->Append( GetDriver()->GetTransmitOptions() ); - else - msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_NO_ROUTE ); - GetDriver()->SendMsg( msg, _queue ); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NoOperation.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/NoOperation.h deleted file mode 100644 index e5b73b2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NoOperation.h +++ /dev/null @@ -1,60 +0,0 @@ -//----------------------------------------------------------------------------- -// -// NoOperation.h -// -// Implementation of the Z-Wave COMMAND_CLASS_NO_OPERATION -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _NoOperation_H -#define _NoOperation_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_NO_OPERATION (0x00), a Z-Wave device command class. - */ - class NoOperation: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new NoOperation( _homeId, _nodeId ); } - virtual ~NoOperation(){} - - static uint8 const StaticGetCommandClassId(){ return 0x00; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_NO_OPERATION"; } - - void Set( bool const _route, Driver::MsgQueue const _queue = Driver::MsgQueue_NoOp ); - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - NoOperation( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NodeNaming.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/NodeNaming.cpp deleted file mode 100644 index f12e64b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NodeNaming.cpp +++ /dev/null @@ -1,531 +0,0 @@ -//----------------------------------------------------------------------------- -// -// NodeNaming.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_NODE_NAMING -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "NodeNaming.h" -#include "Association.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../Notification.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -enum NodeNamingCmd -{ - NodeNamingCmd_Set = 0x01, - NodeNamingCmd_Get = 0x02, - NodeNamingCmd_Report = 0x03, - NodeNamingCmd_LocationSet = 0x04, - NodeNamingCmd_LocationGet = 0x05, - NodeNamingCmd_LocationReport = 0x06 -}; - -enum StringEncoding -{ - StringEncoding_ASCII = 0, - StringEncoding_ExtendedASCII, - StringEncoding_UTF16 -}; - -// Mapping of characters 0x80 and above to Unicode. -uint16 const c_extendedAsciiToUnicode[] = -{ - 0x20ac, // 0x80 - Euro Sign - 0x0081, // 0x81 - - 0x201a, // 0x82 - Single Low-9 Quotation Mark - 0x0192, // 0x83 - Latin Small Letter F With Hook - 0x201e, // 0x84 - Double Low-9 Quotation Mark - 0x2026, // 0x85 - Horizontal Ellipsis - 0x2020, // 0x86 - Dagger - 0x2021, // 0x87 - Double Dagger - 0x02c6, // 0x88 - Modifier Letter Circumflex Accent - 0x2030, // 0x89 - Per Mille Sign - 0x0160, // 0x8a - Latin Capital Letter S With Caron - 0x2039, // 0x8b - Single Left-Pointing Angle Quotation Mark - 0x0152, // 0x8c - Latin Capital Ligature Oe - 0x008d, // 0x8d - - 0x017d, // 0x8e - Latin Capital Letter Z With Caron - 0x008f, // 0x8f - - - 0x0090, // 0x90 - - 0x2018, // 0x91 - Left Single Quotation Mark - 0x2019, // 0x92 - Right Single Quotation Mark - 0x201c, // 0x93 - Left Double Quotation Mark - 0x201d, // 0x94 - Right Double Quotation Mark - 0x2022, // 0x95 - Bullet - 0x2013, // 0x96 - En Dash - 0x2014, // 0x97 - Em Dash - 0x02dc, // 0x98 - Small Tilde - 0x2122, // 0x99 - Trade Mark Sign - 0x0161, // 0x9a - Latin Small Letter S With Caron - 0x203a, // 0x9b - Single Right-Pointing Angle Quotation Mark - 0x0153, // 0x9c - Latin Small Ligature Oe - 0x009d, // 0x9d - - 0x017e, // 0x9e - Latin Small Letter Z With Caron - 0x0178, // 0x9f - Latin Capital Letter Y With Diaeresis - - 0x00a0, // 0xa0 - No-Break Space - 0x00a1, // 0xa1 - Inverted Exclamation Mark - 0x00a2, // 0xa2 - Cent Sign - 0x00a3, // 0xa3 - Pound Sign - 0x00a4, // 0xa4 - Currency Sign - 0x00a5, // 0xa5 - Yen Sign - 0x00a6, // 0xa6 - Broken Bar - 0x00a7, // 0xa7 - Section Sign - 0x00a8, // 0xa8 - Diaeresis - 0x00a9, // 0xa9 - Copyright Sign - 0x00aa, // 0xaa - Feminine Ordinal Indicator - 0x00ab, // 0xab - Left-Pointing Double Angle Quotation Mark - 0x00ac, // 0xac - Not Sign - 0x00ad, // 0xad - Soft Hyphen - 0x00ae, // 0xae - Registered Sign - 0x00af, // 0xaf - Macron - - 0x00b0, // 0xb0 - Degree Sign - 0x00b1, // 0xb1 - Plus-Minus Sign - 0x00b2, // 0xb2 - Superscript Two - 0x00b3, // 0xb3 - Superscript Three - 0x00b4, // 0xb4 - Acute Accent - 0x00b5, // 0xb5 - Micro Sign - 0x00b6, // 0xb6 - Pilcrow Sign - 0x00b7, // 0xb7 - Middle Dot - 0x00b8, // 0xb8 - Cedilla - 0x00b9, // 0xb9 - Superscript One - 0x00ba, // 0xba - Masculine Ordinal Indicator - 0x00bb, // 0xbb - Right-Pointing Double Angle Quotation Mark - 0x00bc, // 0xbc - Vulgar Fraction One Quarter - 0x00bd, // 0xbd - Vulgar Fraction One Half - 0x00be, // 0xbe - Vulgar Fraction Three Quarters - 0x00bf, // 0xbf - Inverted Question Mark - - 0x00c0, // 0xc0 - Latin Capital Letter A With Grave - 0x00c1, // 0xc1 - Latin Capital Letter A With Acute - 0x00c2, // 0xc2 - Latin Capital Letter A With Circumflex - 0x00c3, // 0xc3 - Latin Capital Letter A With Tilde - 0x00c4, // 0xc4 - Latin Capital Letter A With Diaeresis - 0x00c5, // 0xc5 - Latin Capital Letter A With Ring Above - 0x00c6, // 0xc6 - Latin Capital Ligature Ae - 0x00c7, // 0xc7 - Latin Capital Letter C With Cedilla - 0x00c8, // 0xc8 - Latin Capital Letter E With Grave - 0x00c9, // 0xc9 - Latin Capital Letter E With Acute - 0x00ca, // 0xca - Latin Capital Letter E With Circumflex - 0x00cb, // 0xcb - Latin Capital Letter E With Diaeresis - 0x00cc, // 0xcc - Latin Capital Letter I With Grave - 0x00cd, // 0xcd - Latin Capital Letter I With Acute - 0x00ce, // 0xce - Latin Capital Letter I With Circumflex - 0x00cf, // 0xcf - Latin Capital Letter I With Diaeresis - - 0x00d0, // 0xd0 - Latin Capital Letter Eth - 0x00d1, // 0xd1 - Latin Capital Letter N With Tilde - 0x00d2, // 0xd2 - Latin Capital Letter O With Grave - 0x00d3, // 0xd3 - Latin Capital Letter O With Acute - 0x00d4, // 0xd4 - Latin Capital Letter O With Circumflex - 0x00d5, // 0xd5 - Latin Capital Letter O With Tilde - 0x00d6, // 0xd6 - Latin Capital Letter O With Diaeresis - 0x00d7, // 0xd7 - Multiplication Sign - 0x00d8, // 0xd8 - Latin Capital Letter O With Stroke - 0x00d9, // 0xd9 - Latin Capital Letter U With Grave - 0x00da, // 0xda - Latin Capital Letter U With Acute - 0x00db, // 0xdb - Latin Capital Letter U With Circumflex - 0x00dc, // 0xdc - Latin Capital Letter U With Diaeresis - 0x00dd, // 0xdd - Latin Capital Letter Y With Acute - 0x00de, // 0xde - Latin Capital Letter Thorn - 0x00df, // 0xdf - Latin Small Letter Sharp S - - 0x00e0, // 0xe0 - Latin Small Letter A With Grave - 0x00e1, // 0xe1 - Latin Small Letter A With Acute - 0x00e2, // 0xe2 - Latin Small Letter A With Circumflex - 0x00e3, // 0xe3 - Latin Small Letter A With Tilde - 0x00e4, // 0xe4 - Latin Small Letter A With Diaeresis - 0x00e5, // 0xe5 - Latin Small Letter A With Ring Above - 0x00e6, // 0xe6 - Latin Small Ligature Ae - 0x00e7, // 0xe7 - Latin Small Letter C With Cedilla - 0x00e8, // 0xe8 - Latin Small Letter E With Grave - 0x00e9, // 0xe9 - Latin Small Letter E With Acute - 0x00ea, // 0xea - Latin Small Letter E With Circumflex - 0x00eb, // 0xeb - Latin Small Letter E With Diaeresis - 0x00ec, // 0xec - Latin Small Letter I With Grave - 0x00ed, // 0xed - Latin Small Letter I With Acute - 0x00ee, // 0xee - Latin Small Letter I With Circumflex - 0x00ef, // 0xef - Latin Small Letter I With Diaeresis - - 0x00f0, // 0xf0 - Latin Small Letter Eth - 0x00f1, // 0xf1 - Latin Small Letter N With Tilde - 0x00f2, // 0xf2 - Latin Small Letter O With Grave - 0x00f3, // 0xf3 - Latin Small Letter O With Acute - 0x00f4, // 0xf4 - Latin Small Letter O With Circumflex - 0x00f5, // 0xf5 - Latin Small Letter O With Tilde - 0x00f6, // 0xf6 - Latin Small Letter O With Diaeresis - 0x00f7, // 0xf7 - Division Sign - 0x00f8, // 0xf8 - Latin Small Letter O With Stroke - 0x00f9, // 0xf9 - Latin Small Letter U With Grave - 0x00fa, // 0xfa - Latin Small Letter U With Acute - 0x00fb, // 0xfb - Latin Small Letter U With Circumflex - 0x00fc, // 0xfc - Latin Small Letter U With Diaeresis - 0x00fd, // 0xfd - Latin Small Letter Y With Acute - 0x00fe, // 0xfe - Latin Small Letter Thorn - 0x00ff // 0xff - Latin Small Letter Y With Diaeresis -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool NodeNaming::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool res = false; - if( _requestFlags & RequestFlag_Session ) - { - if( Node* node = GetNodeUnsafe() ) - { - if( node->m_nodeName == "" ) - { - // If we don't already have a user-defined name, fetch it from the device - res |= RequestValue( _requestFlags, NodeNamingCmd_Get, _instance, _queue ); - } - - if( node->m_location == "" ) - { - // If we don't already have a user-defined location, fetch it from the device - res |= RequestValue( _requestFlags, NodeNamingCmd_LocationGet, _instance, _queue ); - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool NodeNaming::RequestValue -( - uint32 const _requestFlags, - uint8 const _getTypeEnum, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - - Msg* msg; - if( _getTypeEnum == NodeNamingCmd_Get ) - { - if ( IsGetSupported() ) - { - msg = new Msg( "NodeNamingCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( NodeNamingCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "NodeNamingCmd_Get Not Supported on this node"); - } - return false; - } - - if( _getTypeEnum == NodeNamingCmd_LocationGet ) - { - // If we don't already have a user-defined name, fetch it from the device - msg = new Msg( "NodeNamingCmd_LocationGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( NodeNamingCmd_LocationGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool NodeNaming::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - bool updated = false; - if( Node* node = GetNodeUnsafe() ) - { - if( NodeNamingCmd_Report == (NodeNamingCmd)_data[0] ) - { - string name = ExtractString( _data, _length ); - if( node->m_nodeName == "" ) - { - // We only overwrite the name if it is empty - node->m_nodeName = name; - Log::Write( LogLevel_Info, GetNodeId(), "Received the name: %s.", name.c_str() ); - updated = true; - } - } - else if( NodeNamingCmd_LocationReport == (NodeNamingCmd)_data[0] ) - { - string location = ExtractString( _data, _length ); - if( node->m_location == "" ) - { - // We only overwrite the location if it is empty - node->m_location = location; - Log::Write( LogLevel_Info, GetNodeId(), "Received the location: %s.", location.c_str() ); - updated = true; - } - } - } - - if( updated ) - { - Notification* notification = new Notification( Notification::Type_NodeNaming ); - notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() ); - GetDriver()->QueueNotification( notification ); - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Set the name in the device -//----------------------------------------------------------------------------- -void NodeNaming::SetName -( - string const& _name -) -{ - size_t length = _name.size(); - if( length > 16 ) - { - length = 16; - } - - Log::Write( LogLevel_Info, GetNodeId(), "NodeNaming::Set - Naming to '%s'", _name.c_str() ); - Msg* msg = new Msg( "NodeNaming Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( (uint8)(length + 3) ); - msg->Append( GetCommandClassId() ); - msg->Append( NodeNamingCmd_Set ); - msg->Append( (uint8)StringEncoding_ASCII ); - - for( uint32 i=0; iAppend( _name[i] ); - } - - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); -} - -//----------------------------------------------------------------------------- -// -// Set the location in the device -//----------------------------------------------------------------------------- -void NodeNaming::SetLocation -( - string const& _location -) -{ - size_t length = _location.size(); - if( length > 16 ) - { - length = 16; - } - - Log::Write( LogLevel_Info, GetNodeId(), "NodeNaming::SetLocation - Setting location to '%s'", _location.c_str() ); - Msg* msg = new Msg( "NodeNaming Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( (uint8)(length + 3) ); - msg->Append( GetCommandClassId() ); - msg->Append( NodeNamingCmd_LocationSet ); - msg->Append( (uint8)StringEncoding_ASCII ); - - for( uint32 i=0; iAppend( _location[i] ); - } - - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); -} - -//----------------------------------------------------------------------------- -// -// Extract a string from the report data -//----------------------------------------------------------------------------- -string NodeNaming::ExtractString -( - uint8 const* _data, - uint32 const _length -) -{ - uint8 i; - char str[32]; - uint32 pos = 0; - - str[0] = 0; - StringEncoding encoding = (StringEncoding)( _data[1] & 0x07 ); - - if( _length >= 3 ) - { - // Get the length of the string (maximum allowed is 16 bytes) - uint8 numBytes = _length - 3; - if( numBytes > 16 ) - { - numBytes = 16; - } - - switch( encoding ) - { - case StringEncoding_ASCII: - { - // Copy data as-is - for( i=0; i= 0x80 ) - { - uint16 utf16 = c_extendedAsciiToUnicode[ch-0x80]; - pos = ConvertUFT16ToUTF8( utf16, str, pos ); - } - else - { - str[pos++] = (char)ch; - } - } - break; - } - case StringEncoding_UTF16: - { - // Convert UTF-16 characters to UTF-8 - for( i=0; i -// Convert a UTF-16 string into UTF-8 encoding. -//----------------------------------------------------------------------------- -uint32 NodeNaming::ConvertUFT16ToUTF8 -( - uint16 _utf16, - char* _buffer, - uint32 pos -) -{ - static uint16 surrogate = 0; - - if( ( surrogate != 0 ) && ( ( _utf16 & 0xdc00 ) == 0xdc00 ) ) - { - // UTF-16 surrogate character pair converts to four UTF-8 characters. - // We have the second member of the pair, so we can do the conversion now. - _buffer[pos++] = (char)( ((surrogate>>7) & 0x0007) | 0x00f0 ); - _buffer[pos++] = (char)( ((surrogate>>1) & 0x0020) | ((surrogate>>2) & 0x000f) | 0x0090 ); - _buffer[pos++] = (char)( ((_utf16>>6) & 0x000f) | ((surrogate<<4) & 0x0030) | 0x0080 ); - _buffer[pos++] = (char)( (_utf16 & 0x003f) | 0x0080 ); - } - else - { - surrogate = 0; - if( _utf16 & 0xff80 ) - { - if( _utf16 & 0xf800 ) - { - if( ( _utf16 & 0xd800 ) == 0xd800 ) - { - // UTF-16 surrogate character pair converts to four UTF-8 characters. - // We have the first member of the pair, so we store it for next time. - surrogate = _utf16; - } - else - { - // UTF-16 character can be represented by three UTF-8 characters. - _buffer[pos++] = (char)( (_utf16>>12) | 0x00e0 ); - _buffer[pos++] = (char)( ((_utf16>>6) & 0x003f) | 0x0080 ); - _buffer[pos++] = (char)( (_utf16 & 0x003f) | 0x0080 ); - } - } - else - { - // UTF-16 character can be represented by two UTF-8 characters. - _buffer[pos++] = (char)( (_utf16>>6) | 0x00c0 ); - _buffer[pos++] = (char)( (_utf16 & 0x003f) | 0x0080 ); - } - } - else - { - // UTF-16 character matches single ascii character. - _buffer[pos++] = (char)_utf16; - } - } - - return pos; -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NodeNaming.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/NodeNaming.h deleted file mode 100644 index ebf552b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/NodeNaming.h +++ /dev/null @@ -1,66 +0,0 @@ -//----------------------------------------------------------------------------- -// -// NodeNaming.h -// -// Implementation of the Z-Wave COMMAND_CLASS_NODE_NAMING -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _NodeNaming_H -#define _NodeNaming_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_NODE_NAMING (0x77), a Z-Wave device command class. - */ - class NodeNaming: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new NodeNaming( _homeId, _nodeId ); } - virtual ~NodeNaming(){} - - static uint8 const StaticGetCommandClassId(){ return 0x77; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_NODE_NAMING"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - void SetName( string const& _name ); - void SetLocation( string const& _location ); - - private: - NodeNaming( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - - string ExtractString( uint8 const* _data, uint32 const _length ); - uint32 ConvertUFT16ToUTF8( uint16 _utf16, char* _buffer, uint32 pos ); - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Powerlevel.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Powerlevel.cpp deleted file mode 100644 index f49499b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Powerlevel.cpp +++ /dev/null @@ -1,501 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Powerlevel.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_POWERLEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include - -#include "CommandClasses.h" -#include "Powerlevel.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueShort.h" -#include "../value_classes/ValueList.h" -#include "../value_classes/ValueButton.h" - -using namespace OpenZWave; - -enum PowerlevelCmd -{ - PowerlevelCmd_Set = 0x01, - PowerlevelCmd_Get = 0x02, - PowerlevelCmd_Report = 0x03, - PowerlevelCmd_TestNodeSet = 0x04, - PowerlevelCmd_TestNodeGet = 0x05, - PowerlevelCmd_TestNodeReport = 0x06 -}; - -enum -{ - PowerlevelIndex_Powerlevel = 0, - PowerlevelIndex_Timeout, - PowerlevelIndex_Set, - PowerlevelIndex_TestNode, - PowerlevelIndex_TestPowerlevel, - PowerlevelIndex_TestFrames, - PowerlevelIndex_Test, - PowerlevelIndex_Report, - PowerlevelIndex_TestStatus, - PowerlevelIndex_TestAckFrames -}; - -static char const* c_powerLevelNames[] = -{ - "Normal", - "-1dB", - "-2dB", - "-3dB", - "-4dB", - "-5dB", - "-6dB", - "-7dB", - "-8dB", - "-9dB", - "Unknown" -}; - -static char const* c_powerLevelStatusNames[] = -{ - "Failed", - "Success", - "In Progress", - "Unknown" -}; - - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Powerlevel::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Session ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Powerlevel::RequestValue -( - uint32 const _requestFlags, - uint8 const _index, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _index == 0 ) - { - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "Powerlevel_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( PowerlevelCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "Powerlevel_Get Not Supported on this node"); - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Powerlevel::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( PowerlevelCmd_Report == (PowerlevelCmd)_data[0] ) - { - PowerLevelEnum powerLevel = (PowerLevelEnum)_data[1]; - if (powerLevel > 9) /* size of c_powerLevelNames minus Unknown*/ - { - Log::Write (LogLevel_Warning, GetNodeId(), "powerLevel Value was greater than range. Setting to Invalid"); - powerLevel = (PowerLevelEnum)10; - } - uint8 timeout = _data[2]; - - Log::Write( LogLevel_Info, GetNodeId(), "Received a PowerLevel report: PowerLevel=%s, Timeout=%d", c_powerLevelNames[powerLevel], timeout ); - if( ValueList* value = static_cast( GetValue( _instance, PowerlevelIndex_Powerlevel ) ) ) - { - value->OnValueRefreshed( (int)powerLevel ); - value->Release(); - } - if( ValueByte* value = static_cast( GetValue( _instance, PowerlevelIndex_Timeout ) ) ) - { - value->OnValueRefreshed( timeout ); - value->Release(); - } - return true; - } - - if( PowerlevelCmd_TestNodeReport == (PowerlevelCmd)_data[0] ) - { - uint8 testNode = _data[1]; - PowerLevelStatusEnum status = (PowerLevelStatusEnum)_data[2]; - uint16 ackCount = (((uint16)_data[3])<<8) | (uint16)_data[4]; - - if (status > 2) /* size of c_powerLevelStatusNames minus Unknown */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "status Value was greater than range. Setting to Unknown"); - status = (PowerLevelStatusEnum)3; - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received a PowerLevel Test Node report: Test Node=%d, Status=%s, Test Frame ACK Count=%d", testNode, c_powerLevelStatusNames[status], ackCount ); - if( ValueByte* value = static_cast( GetValue( _instance, PowerlevelIndex_TestNode ) ) ) - { - value->OnValueRefreshed( testNode ); - value->Release(); - } - if( ValueList* value = static_cast( GetValue( _instance, PowerlevelIndex_TestStatus ) ) ) - { - value->OnValueRefreshed( (int)status ); - value->Release(); - } - if( ValueShort* value = static_cast( GetValue( _instance, PowerlevelIndex_TestAckFrames ) ) ) - { - value->OnValueRefreshed( (short)ackCount ); - value->Release(); - } - return true; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a value on the Z-Wave device -//----------------------------------------------------------------------------- -bool Powerlevel::SetValue -( - Value const& _value -) -{ - bool res = false; - uint8 instance = _value.GetID().GetInstance(); - - switch( _value.GetID().GetIndex() ) - { - case PowerlevelIndex_Powerlevel: - { - if( ValueList* value = static_cast( GetValue( instance, PowerlevelIndex_Powerlevel ) ) ) - { - ValueList::Item const& item = (static_cast( &_value))->GetItem(); - value->OnValueRefreshed( item.m_value ); - value->Release(); - } - res = true; - break; - } - case PowerlevelIndex_Timeout: - { - if( ValueByte* value = static_cast( GetValue( instance, PowerlevelIndex_Timeout ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - res = true; - break; - } - case PowerlevelIndex_Set: - { - // Set - if( ValueButton* button = static_cast( GetValue( instance, PowerlevelIndex_Set ) ) ) - { - if( button->IsPressed() ) - { - res = Set( instance ); - } - button->Release(); - } - break; - } - case PowerlevelIndex_TestNode: - { - if( ValueByte* value = static_cast( GetValue( instance, PowerlevelIndex_TestNode ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - res = true; - break; - } - case PowerlevelIndex_TestPowerlevel: - { - if( ValueList* value = static_cast( GetValue( instance, PowerlevelIndex_TestPowerlevel ) ) ) - { - ValueList::Item const& item = (static_cast( &_value))->GetItem(); - value->OnValueRefreshed( item.m_value ); - value->Release(); - } - res = true; - break; - } - case PowerlevelIndex_TestFrames: - { - if( ValueShort* value = static_cast( GetValue( instance, PowerlevelIndex_TestFrames ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - res = true; - break; - } - case PowerlevelIndex_Test: - { - // Test - if( ValueButton* button = static_cast( GetValue( instance, PowerlevelIndex_Test ) ) ) - { - if( button->IsPressed() ) - { - res = Test( instance ); - } - button->Release(); - } - break; - } - case PowerlevelIndex_Report: - { - // Test - if( ValueButton* button = static_cast( GetValue( instance, PowerlevelIndex_Report ) ) ) - { - if( button->IsPressed() ) - { - res = Report( instance ); - } - button->Release(); - } - break; - } - } - return res; -} - -//----------------------------------------------------------------------------- -// -// Set the transmit power of a node for a specified time -//----------------------------------------------------------------------------- -bool Powerlevel::Set -( - uint8 const _instance -) -{ - PowerLevelEnum powerLevel; - uint8 timeout; - - if( ValueList* value = static_cast( GetValue( _instance, PowerlevelIndex_Powerlevel ) ) ) - { - ValueList::Item const& item = value->GetItem(); - powerLevel = (PowerLevelEnum)item.m_value; - value->Release(); - } - else - { - return false; - } - - if( ValueByte* value = static_cast( GetValue( _instance, PowerlevelIndex_Timeout ) ) ) - { - timeout = value->GetValue(); - value->Release(); - } - else - { - return false; - } - if (powerLevel > 9) /* size of c_powerLevelNames minus Unknown */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "powerLevel Value was greater than range. Dropping"); - /* Drop it */ - return false; - } - - - Log::Write( LogLevel_Info, GetNodeId(), "Setting the power level to %s for %d seconds", c_powerLevelNames[powerLevel], timeout ); - Msg* msg = new Msg( "PowerlevelCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( PowerlevelCmd_Set ); - msg->Append( (uint8)powerLevel ); - msg->Append( timeout ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Test node to node communications -//----------------------------------------------------------------------------- -bool Powerlevel::Test -( - uint8 const _instance -) -{ - uint8 testNodeId; - PowerLevelEnum powerLevel; - uint16 numFrames; - - if( ValueByte* value = static_cast( GetValue( _instance, PowerlevelIndex_TestNode ) ) ) - { - testNodeId = value->GetValue(); - value->Release(); - } - else - { - return false; - } - - if( ValueList* value = static_cast( GetValue( _instance, PowerlevelIndex_TestPowerlevel ) ) ) - { - ValueList::Item const& item = value->GetItem(); - powerLevel = (PowerLevelEnum)item.m_value; - value->Release(); - } - else - { - return false; - } - - if( ValueShort* value = static_cast( GetValue( _instance, PowerlevelIndex_TestFrames ) ) ) - { - numFrames = value->GetValue(); - value->Release(); - } - else - { - return false; - } - if (powerLevel > 9) /* size of c_powerLevelNames minus Unknown */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "powerLevel Value was greater than range. Dropping"); - return false; - } - - - Log::Write( LogLevel_Info, GetNodeId(), "Running a Power Level Test: Target Node = %d, Power Level = %s, Number of Frames = %d", testNodeId, c_powerLevelNames[powerLevel], numFrames ); - Msg* msg = new Msg( "PowerlevelCmd_TestNodeSet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 6 ); - msg->Append( GetCommandClassId() ); - msg->Append( PowerlevelCmd_TestNodeSet ); - msg->Append( testNodeId ); - msg->Append( (uint8)powerLevel ); - msg->Append( (uint8)(numFrames >> 8) ); - msg->Append( (uint8)(numFrames & 0x00ff) ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Request test report -//----------------------------------------------------------------------------- -bool Powerlevel::Report -( - uint8 const _instance -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "Power Level Report" ); - Msg* msg = new Msg( "PowerlevelCmd_TestNodeGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 6 ); - msg->Append( GetCommandClassId() ); - msg->Append( PowerlevelCmd_TestNodeGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Powerlevel::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - vector items; - - ValueList::Item item; - for( uint8 i=0; i<10; ++i ) - { - item.m_label = c_powerLevelNames[i]; - item.m_value = i; - items.push_back( item ); - } - - node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_Powerlevel, "Powerlevel", "dB", false, false, 1, items, 0, 0 ); - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_Timeout, "Timeout", "seconds", false, false, 0, 0 ); - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_Set, "Set Powerlevel", 0 ); - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_TestNode, "Test Node", "", false, false, 0, 0 ); - node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_TestPowerlevel, "Test Powerlevel", "dB", false, false, 1, items, 0, 0 ); - node->CreateValueShort( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_TestFrames, "Frame Count", "", false, false, 0, 0 ); - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_Test, "Test", 0 ); - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_Report, "Report", 0 ); - - items.clear(); - for( uint8 i=0; i<3; ++i ) - { - item.m_label = c_powerLevelStatusNames[i]; - item.m_value = i; - items.push_back( item ); - } - node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_TestStatus, "Test Status", "", true, false, 1, items, 0, 0 ); - node->CreateValueShort( ValueID::ValueGenre_System, GetCommandClassId(), _instance, PowerlevelIndex_TestAckFrames, "Acked Frames", "", true, false, 0, 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Powerlevel.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Powerlevel.h deleted file mode 100644 index 614a20d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Powerlevel.h +++ /dev/null @@ -1,91 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Powerlevel.h -// -// Implementation of the Z-Wave COMMAND_CLASS_POWERLEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Powerlevel_H -#define _Powerlevel_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueList; - - /** \brief Implements COMMAND_CLASS_POWERLEVEL (0x73), a Z-Wave device command class. - */ - class Powerlevel: public CommandClass - { - public: - enum PowerLevelEnum - { - PowerLevel_Normal = 0, - PowerLevel_Minus1dB, - PowerLevel_Minus2dB, - PowerLevel_Minus3dB, - PowerLevel_Minus4dB, - PowerLevel_Minus5dB, - PowerLevel_Minus6dB, - PowerLevel_Minus7dB, - PowerLevel_Minus8dB, - PowerLevel_Minus9dB - }; - - enum PowerLevelStatusEnum - { - PowerLevelStatus_Failed = 0, - PowerLevelStatus_Success, - PowerLevelStatus_InProgress - }; - - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Powerlevel( _homeId, _nodeId ); } - virtual ~Powerlevel(){} - - static uint8 const StaticGetCommandClassId(){ return 0x73; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_POWERLEVEL"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Powerlevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - - bool Set( uint8 const _instance ); - bool Test( uint8 const _instance ); - bool Report( uint8 const _instance ); - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Proprietary.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Proprietary.cpp deleted file mode 100644 index 01d469c..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Proprietary.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Proprietary.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_PROPRIETARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Proprietary.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -enum ProprietaryCmd -{ - ProprietaryCmd_Set = 0x01, - ProprietaryCmd_Get = 0x02, - ProprietaryCmd_Report = 0x03 -}; - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Proprietary::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (ProprietaryCmd_Report == (ProprietaryCmd)_data[0]) - { - return true; - } - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Proprietary.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Proprietary.h deleted file mode 100644 index 8398dd5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Proprietary.h +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Proprietary.h -// -// Implementation of the Z-Wave COMMAND_CLASS_PROPRIETARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Proprietary_H -#define _Proprietary_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_PROPRIETARY (0x88), a Z-Wave device command class. - */ - class Proprietary: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Proprietary( _homeId, _nodeId ); } - virtual ~Proprietary(){} - - static uint8 const StaticGetCommandClassId(){ return 0x88; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_PROPRIETARY"; } - - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - Proprietary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Protection.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Protection.cpp deleted file mode 100644 index cd0560b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Protection.cpp +++ /dev/null @@ -1,190 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Protection.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_PROTECTION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include - -#include "CommandClasses.h" -#include "Protection.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueList.h" - -using namespace OpenZWave; - -enum ProtectionCmd -{ - ProtectionCmd_Set = 0x01, - ProtectionCmd_Get = 0x02, - ProtectionCmd_Report = 0x03 -}; - -static char const* c_protectionStateNames[] = -{ - "Unprotected", - "Protection by Sequence", - "No Operation Possible", - "Unknown" -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Protection::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Session ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Protection::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "ProtectionCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ProtectionCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ProtectionCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Protection::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (ProtectionCmd_Report == (ProtectionCmd)_data[0]) - { - int8 stateValue = _data[1]; - if (stateValue > 2) /* size of c_protectionStateNames minus Invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "State Value was greater than range. Setting to Invalid"); - stateValue = 3; - } - Log::Write( LogLevel_Info, GetNodeId(), "Received a Protection report: %s", c_protectionStateNames[_data[1]] ); - if( ValueList* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( (int)_data[1] ); - value->Release(); - } - - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the device's protection state -//----------------------------------------------------------------------------- -bool Protection::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_List == _value.GetID().GetType() ) - { - ValueList const* value = static_cast(&_value); - ValueList::Item const& item = value->GetItem(); - - Log::Write( LogLevel_Info, GetNodeId(), "Protection::Set - Setting protection state to '%s'", item.m_label.c_str() ); - Msg* msg = new Msg( "Protection Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( ProtectionCmd_Set ); - msg->Append( (uint8)item.m_value ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Protection::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - vector items; - - ValueList::Item item; - for( uint8 i=0; i<3; ++i ) - { - item.m_label = c_protectionStateNames[i]; - item.m_value = i; - items.push_back( item ); - } - - node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 0, "Protection", "", false, false, 1, items, 0, 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Protection.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Protection.h deleted file mode 100644 index 9f3048d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Protection.h +++ /dev/null @@ -1,73 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Protection.h -// -// Implementation of the Z-Wave COMMAND_CLASS_PROTECTION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Protection_H -#define _Protection_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueList; - - /** \brief Implements COMMAND_CLASS_PROTECTION (0x75), a Z-Wave device command class. - */ - class Protection: public CommandClass - { - public: - enum ProtectionEnum - { - Protection_Unprotected = 0, - Protection_Sequence, - Protection_NOP - }; - - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Protection( _homeId, _nodeId ); } - virtual ~Protection(){} - - static uint8 const StaticGetCommandClassId(){ return 0x75; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_PROTECTION"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Protection( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SceneActivation.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SceneActivation.cpp deleted file mode 100644 index 7c28cca..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SceneActivation.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SceneActivation.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SCENE_ACTIVATION -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SceneActivation.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../Notification.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -enum SceneActivationCmd -{ - SceneActivationCmd_Set = 0x01 -}; - - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SceneActivation::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( SceneActivationCmd_Set == (SceneActivationCmd)_data[0] ) - { - // Scene Activation Set received so send notification - char msg[64]; - if( _data[2] == 0 ) - snprintf( msg, sizeof(msg), "now" ); - else if( _data[2] <= 0x7F ) - snprintf( msg, sizeof(msg), "%d seconds", _data[2] ); - else if( _data[2] <= 0xFE ) - snprintf( msg, sizeof(msg), "%d minutes", _data[2] ); - else - snprintf( msg, sizeof(msg), "via configuration" ); - Log::Write( LogLevel_Info, GetNodeId(), "Received Scene Activation set from node %d: scene id=%d %s. Sending event notification.", GetNodeId(), _data[1], msg ); - Notification* notification = new Notification( Notification::Type_SceneEvent ); - notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() ); - notification->SetSceneId( _data[1] ); - GetDriver()->QueueNotification( notification ); - return true; - } - - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SceneActivation.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SceneActivation.h deleted file mode 100644 index f8a63a6..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SceneActivation.h +++ /dev/null @@ -1,64 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SceneActivation.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SCENE_ACTIVATION -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SceneActivation_H -#define _SceneActivation_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - - /** \brief Implements COMMAND_CLASS_SCENEACTIVATION (0x2B), a Z-Wave device command class. - */ - class SceneActivation: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SceneActivation( _homeId, _nodeId ); } - virtual ~SceneActivation(){} - - /** \brief Get command class ID (1 byte) identifying this command class. */ - static uint8 const StaticGetCommandClassId(){ return 0x2B; } - /** \brief Get a string containing the name of this command class. */ - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SCENE_ACTIVATION"; } - - // From CommandClass - /** \brief Get command class ID (1 byte) identifying this command class. (Inherited from CommandClass) */ - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - /** \brief Get a string containing the name of this command class. (Inherited from CommandClass) */ - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - /** \brief Handle a response to a message associated with this command class. (Inherited from CommandClass) */ - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - SceneActivation( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Security.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Security.cpp deleted file mode 100644 index f2a8eb2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Security.cpp +++ /dev/null @@ -1,1061 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Security.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_Security -// -// Copyright (c) 2011 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include - - -#include "CommandClasses.h" -#include "Security.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueBool.h" - - -using namespace OpenZWave; - - -#define UNUSED(x) (void)(x) - - -/* in order to communicate with a Secure Device, we need to send the Network Key to the - * Device with a SecurityCmd_NetworkKeySet packet containing our Network Key. - * Fairly simple right? - * - * BUT - * - * The NetworkKeySet should be done during a inclusion of the device (there is technically a timeout) - * and not at any random time. This means that when including Secure Devices, we must use the OZW AddNode - * Controller Commands, and then once the Inclusion is complete, initiate a NetworkKeySet. Including a - * Secure Device by say using the button on a Z-Stick is technically not possible, as OZW needs to send - * the Network Key right away after negotiating the SecurityScheme (before the timeout). - * - */ - -enum SecurityCmd -{ - SecurityCmd_SupportedGet = 0x02, - SecurityCmd_SupportedReport = 0x03, - SecurityCmd_SchemeGet = 0x04, - SecurityCmd_SchemeReport = 0x05, - SecurityCmd_NetworkKeySet = 0x06, - SecurityCmd_NetworkKeyVerify = 0x07, - SecurityCmd_SchemeInherit = 0x08, - SecurityCmd_NonceGet = 0x40, - SecurityCmd_NonceReport = 0x80, - SecurityCmd_MessageEncap = 0x81, - SecurityCmd_MessageEncapNonceGet = 0xc1 -}; - -enum SecurityScheme -{ - SecurityScheme_Zero = 0x00, -}; - - -uint8_t SecuritySchemes[1][16] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } -}; - -uint8_t EncryptPassword[16] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}; -uint8_t AuthPassword[16] = {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55}; - -void PrintHex(std::string prefix, uint8_t const *data, uint32 const length) { - char byteStr[16]; - std::string str; - for( uint32 i=0; iRelease(); - delete this->AuthKey; - delete this->EncryptKey; -} - -//----------------------------------------------------------------------------- -// -// Read configuration. -//----------------------------------------------------------------------------- -void Security::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); -} - -//----------------------------------------------------------------------------- -// -// Save changed configuration -//----------------------------------------------------------------------------- -void Security::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); -} - - - -void Security::SetupNetworkKey -( -) -{ -//#define TESTENC 1 - -#if TESTENC -// uint8_t iv[16] = { 0x81, 0x42, 0xd1, 0x51, 0xf1, 0x59, 0x3d, 0x70, 0xd5, 0xe3, 0x6c, 0xcb, 0x02, 0xd0, 0x3f, 0x5c, /* */ }; - uint8_t iv[16] = { 0xee, 0x2c, 0x1c, 0x0e, 0xe1, 0x54, 0xe7, 0xfa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa /* */ }; -// uint8_t pck[] = { 0x25, 0x68, 0x06, 0xc5, 0xb3, 0xee, 0x2c, 0x17, 0x26, 0x7e, 0xf0, 0x84, 0xd4, 0xc3, 0xba, 0xed, 0xe5, 0xb9, 0x55}; - uint8_t pck[] = { 0x65, 0xce, 0x5e, 0x75, 0xec, 0xe6, 0x09, 0x9b}; - /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 */ - uint8_t out[50]; - memset(&out[0], 0, 50); - this->nk = SecuritySchemes[0]; - -#endif -#if 0 - - this->nk = GetDriver->GetNetworkKey(); -#endif - if ((GetNodeUnsafe()->IsAddingNode() == true) && (m_networkkeyset == false)) { - Log::Write(LogLevel_Info, GetNodeId(), " Using Scheme0 Network Key for Key Exchange (AddingNode: %s KeySet: %s)", GetNodeUnsafe()->IsAddingNode() ? "true" : "false", m_networkkeyset ? "true" : "false" ); - this->nk = SecuritySchemes[0]; - } else { - Log::Write(LogLevel_Info, GetNodeId(), " Using Configured Network Key (AddingNode: %s KeySet: %s)", GetNodeUnsafe()->IsAddingNode() ? "true" : "false", m_networkkeyset ? "true" : "false" ); - this->nk = GetDriver()->GetNetworkKey(); - } -#ifdef DEBUG - PrintHex("Network Key", this->nk, 16); -#endif - this->AuthKey = new aes_encrypt_ctx; - this->EncryptKey = new aes_encrypt_ctx; - - if (aes_init1() == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Init AES Engine"); - return; - } - - if (aes_encrypt_key128(this->nk, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Set Initial Network Key for Encryption"); - return; - } - - if (aes_encrypt_key128(this->nk, this->AuthKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Set Initial Network Key for Authentication"); - return; - } - - uint8 tmpEncKey[32]; - uint8 tmpAuthKey[32]; - aes_mode_reset(this->EncryptKey); - aes_mode_reset(this->AuthKey); - - if (aes_ecb_encrypt(EncryptPassword, tmpEncKey, 16, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Generate Encrypted Network Key for Encryption"); - return; - } - if (aes_ecb_encrypt(AuthPassword, tmpAuthKey, 16, this->AuthKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Generate Encrypted Network Key for Authentication"); - return; - } - - - aes_mode_reset(this->EncryptKey); - aes_mode_reset(this->AuthKey); - if (aes_encrypt_key128(tmpEncKey, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to set Encrypted Network Key for Encryption"); - return; - } - if (aes_encrypt_key128(tmpAuthKey, this->AuthKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to set Encrypted Network Key for Authentication"); - return; - } - aes_mode_reset(this->EncryptKey); - aes_mode_reset(this->AuthKey); -#if TESTENC - PrintHex("Key", this->nk, 16); - PrintHex("Packet Encryption Key", tmpEncKey, 16); - PrintHex("IV", iv, 16); - PrintHex("input", pck, 19); - if (aes_ofb_decrypt(pck, out, 19, iv, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Decrypt Packet"); - return; - } - PrintHex("Pck", out, 19); - //exit(-1); - -#endif - //uint8 tmpiv[8] = { 0x16, 0xc2, 0x96, 0x60, 0x46, 0x33, 0x69, 0x04 }; - /* expected output = 0x06, 0xcc, 0xab, 0x1a, 0x86, 0x91, 0x39, 0xfd - * expected Auth = 0x64, 0x42, 0x26, 0x59, 0xf3, 0x04, 0x72, 0x16 - * plaintext packet = 0x62, 0x03, 0x00, 0x10, 0x02, 0xfe, 0xfe - */ - //this->EncryptMessage(tmpiv); - -} -bool Security::Init -( -) -{ - /* if we are adding this node, then instead to a SchemeGet Command instead - This - * will start the Network Key Exchange - */ - if (GetNodeUnsafe()->IsAddingNode()) { - Msg * msg = new Msg ("SecurityCmd_SchemeGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( SecurityCmd_SchemeGet ); - msg->Append( 0 ); - msg->Append( GetDriver()->GetTransmitOptions() ); - /* SchemeGet is unencrypted */ - GetDriver()->SendMsg(msg, Driver::MsgQueue_Security); - } else { - Msg* msg = new Msg( "SecurityCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SecurityCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - this->SendMsg( msg); - } - - return true; -} -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Security::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ -#if 0 - if( _requestFlags & RequestFlag_Static ) - { - - } - return false; -#endif - return true; -} - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Security::RequestValue -( - uint32 const _requestFlags, - uint8 const _index, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - Log::Write(LogLevel_Info, GetNodeId(), "Got a RequestValue Call"); - return true; -} - - -bool Security::HandleSupportedReport -( - uint8 const* _data, - uint32 const _length -) -{ - -#ifdef DEBUG - PrintHex("Security Classes", _data, _length); -#endif - GetNodeUnsafe()->SetSecuredClasses(_data, _length); - /* advance the Query Stage */ - GetNodeUnsafe()->QueryStageComplete(Node::QueryStage_SecurityReport); - GetNodeUnsafe()->AdvanceQueries(); - return true; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Security::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - switch( (SecurityCmd)_data[0] ) - { - case SecurityCmd_SupportedReport: - { - /* this is a list of CommandClasses that should be Encrypted. - * and it might contain new command classes that were not present in the NodeInfoFrame - * so we have to run through, mark existing Command Classes as SetSecured (so SendMsg in the Driver - * class will route the unecrypted messages to our SendMsg) and for New Command - * Classes, create them, and of course, also do a SetSecured on them. - * - * This means we must do a SecurityCmd_SupportedGet request ASAP so we dont have - * Command Classes created after the Discovery Phase is completed! - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_SupportedReport from node %d", GetNodeId() ); - HandleSupportedReport(&_data[2], _length-2); - break; - } - case SecurityCmd_SchemeReport: - { - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_SchemeReport from node %d: %d", GetNodeId(), _data[1]); - uint8 schemes = _data[1]; - if (m_schemeagreed == true) { - Log::Write(LogLevel_Warning, GetNodeId(), " Already Received a SecurityCmd_SchemeReport from the node. Ignoring"); - break; - } - if( schemes == SecurityScheme_Zero ) - { - /* We're good to go. We now should send our NetworkKey to the device if this is the first - * time we have seen it - */ - Log::Write(LogLevel_Info, GetNodeId(), " Security scheme agreed." ); - /* create the NetworkKey Packet. EncryptMessage will encrypt it for us (And request the NONCE) */ - Msg * msg = new Msg ("SecurityCmd_NetworkKeySet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 18 ); - msg->Append( GetCommandClassId() ); - msg->Append( SecurityCmd_NetworkKeySet ); - for (int i = 0; i < 16; i++) - msg->Append(GetDriver()->GetNetworkKey()[i]); - msg->Append( GetDriver()->GetTransmitOptions() ); - this->SendMsg( msg); - m_schemeagreed = true; - } - else - { - /* No common security scheme. The device should continue as an unsecured node. - * but Some Command Classes might not be present... - */ - Log::Write(LogLevel_Warning, GetNodeId(), " No common security scheme. The device will continue as an unsecured node." ); - } - break; - } - case SecurityCmd_NetworkKeySet: - { - /* we shouldn't get a NetworkKeySet from a node if we are the controller - * as we send it out to the Devices - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_NetworkKeySet from node %d", GetNodeId() ); - break; - } - case SecurityCmd_NetworkKeyVerify: - { - /* if we can decrypt this packet, then we are assured that our NetworkKeySet is successfull - * and thus should set the Flag referenced in SecurityCmd_SchemeReport - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_NetworkKeyVerify from node %d", GetNodeId() ); - /* now as for our SupportedGet */ - Msg* msg = new Msg( "SecurityCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SecurityCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - this->SendMsg( msg); - - break; - } - case SecurityCmd_SchemeInherit: - { - /* only used in a Controller Replication Type enviroment. - * - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_SchemeInherit from node %d", GetNodeId() ); - break; - } - case SecurityCmd_NonceGet: - { - /* the Device wants to send us a Encrypted Packet, and thus requesting for our latest NONCE - * - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_NonceGet from node %d", GetNodeId() ); - SendNonceReport(); - break; - } - case SecurityCmd_NonceReport: - { - /* we recieved a NONCE from a device, so assume that there is something in a queue to send - * out - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_NonceReport from node %d", GetNodeId() ); - EncryptMessage( &_data[1] ); - m_waitingForNonce = false; - break; - } - case SecurityCmd_MessageEncap: - { - /* We recieved a Encrypted single packet from the Device. Decrypt it. - * - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_MessageEncap from node %d", GetNodeId() ); - DecryptMessage( _data, _length ); - break; - } - case SecurityCmd_MessageEncapNonceGet: - { - /* we recieved a encrypted packet from the device, and the device is also asking us to send a - * new NONCE to it, hence there must be multiple packets. - */ - Log::Write(LogLevel_Info, GetNodeId(), "Received SecurityCmd_MessageEncapNonceGet from node %d", GetNodeId() ); - DecryptMessage( _data, _length ); - /* Regardless of the success/failure of Decrypting, send a new NONCE */ - SendNonceReport(); - break; - } - default: - { - return false; - } - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Queue a message to be securely sent by the Z-Wave PC Interface -//----------------------------------------------------------------------------- -void Security::SendMsg -( - Msg* _msg -) -{ - _msg->Finalize(); - - uint8* buffer = _msg->GetBuffer(); - if( _msg->GetLength() < 7 ) - { - // Message too short - assert(0); - return; - } - - if( buffer[3] != FUNC_ID_ZW_SEND_DATA ) - { - // Invalid message type - assert(0); - return; - } - - uint8 length = buffer[5]; - if( length > 28 ) - { - // Message must be split into two parts - SecurityPayload *payload1 = new SecurityPayload(); - payload1->m_length = 28; - payload1->m_part = 1; - memcpy( payload1->m_data, &buffer[6], payload1->m_length ); - payload1->logmsg = _msg->GetLogText(); - QueuePayload( payload1 ); - - SecurityPayload *payload2 = new SecurityPayload(); - payload2->m_length = length-28; - payload2->m_part = 2; - memcpy( payload2->m_data, &buffer[34], payload2->m_length ); - payload2->logmsg = _msg->GetLogText(); - QueuePayload( payload2 ); - } - else - { - // The entire message can be encapsulated as one - SecurityPayload *payload = new SecurityPayload(); - payload->m_length = length; - payload->m_part = 0; // Zero means not split into separate messages - memcpy( payload->m_data, &buffer[6], payload->m_length ); - payload->logmsg = _msg->GetLogText(); - QueuePayload( payload ); - } - delete _msg; -} - -//----------------------------------------------------------------------------- -// -// Queue data to be encapsulated by the Security Command Class, on -// receipt of a nonce value from the remote node. -//----------------------------------------------------------------------------- -void Security::QueuePayload -( - SecurityPayload *_payload -) -{ - m_queueMutex->Lock(); - m_queue.push_back( _payload ); - - if( !m_waitingForNonce ) - { - // Request a nonce from the node. Its arrival - // will trigger the sending of the first payload - RequestNonce(); - } - - m_queueMutex->Unlock(); -} - - -//----------------------------------------------------------------------------- -// -// Encrypt and send a Z-Wave message securely. -//----------------------------------------------------------------------------- -bool Security::EncryptMessage -( - uint8 const* _nonce -) -{ -#if 1 - if( m_nonceTimer.GetMilliseconds() > 10000 ) - { - // The nonce was not received within 10 seconds - // of us sending the nonce request. Send it again - RequestNonce(); - return false; - } - - // Fetch the next payload from the queue and encapsulate it - m_queueMutex->Lock(); - if( m_queue.empty() ) - { - // Nothing to do - m_queueMutex->Release(); - return false; - } - - SecurityPayload * payload = m_queue.front(); - m_queue.pop_front(); - //uint32 queueSize = m_queue.size(); - m_queueMutex->Unlock(); -#else - uint32 queueSize = m_queue.size(); - struct SecurityPayload payload; - payload.m_length = 7; - payload.m_part = 0; - uint8 tmpdata[7] = {0x62, 0x03, 0x00, 0x10, 0x02, 0xfe, 0xfe}; - for (int i = 0; i < payload.m_length; i++) - payload.m_data[i] = tmpdata[i]; -#endif - // Encapsulate the message fragment - /* MessageEncapNonceGet doesn't seem to work */ - //Msg* msg = new Msg( (queueSize>1) ? "SecurityCmd_MessageEncapNonceGet" : "SecurityCmd_MessageEncap", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - string LogMessage("SecurityCmd_MessageEncap ("); - LogMessage.append(payload->logmsg); - LogMessage.append(")"); - Msg* msg = new Msg( LogMessage, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( payload->m_length + 20 ); - msg->Append( GetCommandClassId() ); - //msg->Append( (queueSize>1) ? SecurityCmd_MessageEncapNonceGet : SecurityCmd_MessageEncap ); - msg->Append( SecurityCmd_MessageEncap ); - /* create the iv - * - */ - uint8 initializationVector[16]; - /* the first 8 bytes of a outgoing IV are random */ - for (int i = 0; i < 8; i++) { - //initializationVector[i] = (rand()%0xFF)+1; - initializationVector[i] = 0xAA; - } - /* the remaining 8 bytes are the NONCE we got from the device */ - for (int i = 0; i < 8; i++) { - initializationVector[8+i] = _nonce[i]; - } - - /* Append the first 8 bytes of the initialization vector - * to the message. The remaining 8 bytes are the NONCE we recieved from - * the node, and is ommitted from sending back to the Node. But we use the full 16 bytes to - * as the IV to encrypt out message. - */ - for(int i=0; i<8; ++i ) - { - msg->Append( initializationVector[i] ); - } - - // Append the sequence data - uint8 sequence = 0; - if( payload->m_part == 0 ) - { - sequence = 0; - } - else if( payload->m_part == 1 ) - { - sequence = (++m_sequenceCounter) & 0x0f; - sequence |= 0x10; // Sequenced, first frame - } - if( payload->m_part == 2 ) - { - sequence = m_sequenceCounter & 0x0f; - sequence |= 0x30; // Sequenced, second frame - } - /* at most, the payload will be 28 bytes + 1 byte for the Sequence. */ - uint8 plaintextmsg[32]; - plaintextmsg[0] = sequence; - for (int i = 0; i < payload->m_length; i++) - plaintextmsg[i+1] = payload->m_data[i]; - - /* Append the message payload after encrypting it with AES-OFB (key is EncryptPassword, - * full IV (16 bytes - 8 Random and 8 NONCE) and payload.m_data - */ - PrintHex("Input Packet:", plaintextmsg, payload->m_length+1); -#ifdef DEBUG - PrintHex("IV:", initializationVector, 16); -#endif - uint8 encryptedpayload[30]; - aes_mode_reset(this->EncryptKey); - if (aes_ofb_encrypt(plaintextmsg, encryptedpayload, payload->m_length+1, initializationVector, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Encrypt Packet"); - delete msg; - return false; - } -#ifdef DEBUG - PrintHex("Encrypted Output", encryptedpayload, payload->m_length+1); - - /* The Following Code attempts to Decrypt the Packet and Verify */ - - /* the first 8 bytes of a outgoing IV are random */ - for (int i = 0; i < 8; i++) { - //initializationVector[i] = (rand()%0xFF)+1; - initializationVector[i] = 0xAA; - } - /* the remaining 8 bytes are the NONCE we got from the device */ - for (int i = 0; i < 8; i++) { - initializationVector[8+i] = _nonce[i]; - } - aes_mode_reset(this->EncryptKey); - uint8 tmpoutput[16]; - if (aes_ofb_encrypt(encryptedpayload, tmpoutput, payload->m_length+1, initializationVector, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Encrypt Packet"); - delete msg; - return false; - } - - PrintHex("Decrypted output", tmpoutput, payload->m_length+1); -#endif - for(int i=0; im_length+1; ++i ) - { - msg->Append( encryptedpayload[i] ); - } - - // Append the nonce identifier :) - msg->Append(_nonce[0]); - - /* Append space for the authentication data Set with AES-CBCMAC (key is AuthPassword, - * Full IV (16 bytes - 8 random and 8 NONCE) and sequence|SrcNode|DstNode|payload.m_length|payload.m_data - * - */ - /* Regenerate IV */ - /* the first 8 bytes of a outgoing IV are random */ - for (int i = 0; i < 8; i++) { - //initializationVector[i] = (rand()%0xFF)+1; - initializationVector[i] = 0xAA; - } - /* the remaining 8 bytes are the NONCE we got from the device */ - for (int i = 0; i < 8; i++) { - initializationVector[8+i] = _nonce[i]; - } - uint8 mac[8]; - this->GenerateAuthentication(&msg->GetBuffer()[7], msg->GetLength()+2, GetDriver()->GetNodeId(), GetNodeId(), initializationVector, mac); - for(int i=0; i<8; ++i ) - { - msg->Append( mac[i] ); - } -#ifdef DEBUG - PrintHex("Auth", mac, 8); -#endif - msg->Append( GetDriver()->GetTransmitOptions() ); -#ifdef DEBUG - PrintHex("Outgoing", msg->GetBuffer(), msg->GetLength()); -#endif - GetDriver()->SendMsg(msg, Driver::MsgQueue_Security); - - /* finally, if the message we just sent is a NetworkKeySet, then we need to reset our Network Key here - * as the reply we will get back will be encrypted with the new Network key - */ - if ((this->m_networkkeyset == false) && (payload->m_data[0] == 0x98) && (payload->m_data[1] == 0x06)) { - Log::Write(LogLevel_Info, GetNodeId(), "Reseting Network Key after Inclusion"); - this->m_networkkeyset = true; - SetupNetworkKey(); - } - - delete payload; - return true; -} - -bool Security::createIVFromPacket_inbound(uint8 const* _data, uint8 *iv) { - - for (int i = 0; i < 8; i++) { - iv[i] = _data[1+i]; - } - for (int i = 0; i < 8; i++) { - iv[8+i] = this->currentNonce[i]; - } - return true; -} -bool Security::createIVFromPacket_outbound(uint8 const* _data, uint8 *iv) { - - - for (int i = 0; i < 8; i++) { - iv[i] = this->currentNonce[i]; - } - for (int i = 0; i < 8; i++) { - iv[8+i] = _data[1+i]; - } - return true; -} - - - -//----------------------------------------------------------------------------- -// -// Decrypt a security-encapsulated message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Security::DecryptMessage -( - uint8 const* _data, - uint32 const _length -) -{ - if( m_nonceTimer.GetMilliseconds() > 10000 ) - { - // The message was not received within 10 seconds - // of us sending the nonce report. - - // TBD - clear any partial message that has been stored. - - return false; - } - - uint8 iv[17]; - createIVFromPacket_inbound(_data, iv); /* first 8 bytes of Packet are the Random Value generated by the Device - * 2nd 8 bytes of the IV are our nonce we sent previously - */ - uint8 decryptpacket[32]; - memset(&decryptpacket[0], 0, 32); - uint32 encryptedpacketsize = _length-11-8; - uint8 encyptedpacket[32]; - - for (uint32 i = 0; i < 32; i++) { - if (i >= encryptedpacketsize) { - /* pad the remaining fields */ - encyptedpacket[i] = 0; - } else { - encyptedpacket[i] = _data[9+i]; - } - } -#ifdef DEBUG - Log::Write(LogLevel_Debug, GetNodeId(), "Encrypted Packet Sizes: %d (Total) %d (Payload)", _length, encryptedpacketsize); - PrintHex("IV", iv, 16); - PrintHex("Encrypted", encyptedpacket, 16); - /* 8 - IV - 2 - Command Header */ - PrintHex("Auth", &_data[8+encryptedpacketsize+2], 8); -#endif - aes_mode_reset(this->EncryptKey); -#if 0 - uint8_t iv[16] = { 0x81, 0x42, 0xd1, 0x51, 0xf1, 0x59, 0x3d, 0x70, 0xd5, 0xe3, 0x6c, 0xcb, 0x02, 0xd0, 0x3f, 0x5c, /* */ }; - uint8_t pck[] = { 0x25, 0x68, 0x06, 0xc5, 0xb3, 0xee, 0x2c, 0x17, 0x26, 0x7e, 0xf0, 0x84, 0xd4, 0xc3, 0xba, 0xed, 0xe5, 0xb9, 0x55}; - if (aes_ofb_decrypt(pck, decryptpacket, 19, iv, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Decrypt Packet"); - return false; - } - PrintHex("Pck", decryptpacket, 19); -#else - if (aes_ofb_decrypt(encyptedpacket, decryptpacket, encryptedpacketsize, iv, this->EncryptKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed to Decrypt Packet"); - if (m_queue.size() > 1) - RequestNonce(); - return false; - } - PrintHex("Decrypted", decryptpacket, encryptedpacketsize); -#endif - uint8 mac[32]; - /* we have to regenerate the IV as the ofb decryption routine will alter it. */ - createIVFromPacket_inbound(_data, iv); - - this->GenerateAuthentication(_data, _length, GetNodeId(), GetDriver()->GetNodeId(), iv, mac); - if (memcmp(&_data[8+encryptedpacketsize+2], mac, 8) != 0) { - Log::Write(LogLevel_Warning, GetNodeId(), "MAC Authentication of Packet Failed. Dropping"); - if (m_queue.size() > 1) - RequestNonce(); - return false; - } - /* XXX TODO: Check the Sequence Header Frame to see if this is the first part of a - * message, or 2nd part, or a entire message. - * - * I havn't actually seen a Z-Wave Message thats too big to fit in a encrypted message - * yet, so we will look at this if such a message actually exists! - */ - - /* if the command class is us, send it back to our HandleMessage */ - if (decryptpacket[1] == this->StaticGetCommandClassId()) { - /* drop the sequence header, and the command class when we pass through to our handler */ - this->HandleMsg(&decryptpacket[2], encryptedpacketsize-2); - } else { - /* send to the Command Class for processing.... */ - if( Node* node = GetNodeUnsafe() ) - { - uint8 commandClassId = decryptpacket[1]; - - if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received a SecurityCmd_MessageEncap from node %d for Command Class %s", GetNodeId(), pCommandClass->GetCommandClassName().c_str() ); - pCommandClass->ReceivedCntIncr(); - pCommandClass->HandleMsg( &decryptpacket[2], encryptedpacketsize-2); - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ApplicationCommandHandler - Unhandled Command Class 0x%.2x", decryptpacket[1] ); - } - } - } - if (m_queue.size() > 0) - RequestNonce(); - if (m_secured == false) { - if( ValueBool* value = static_cast( GetValue( 1, 0 ) ) ) - { - value->OnValueRefreshed( true ); - value->Release(); - } - m_secured = true; - } - return true; - -} - -//----------------------------------------------------------------------------- -// -// Generate authentication data from a security-encrypted message -//----------------------------------------------------------------------------- -bool Security::GenerateAuthentication -( - uint8 const* _data, // Starting from the command class command - uint32 const _length, - uint8 const _sendingNode, - uint8 const _receivingNode, - uint8 *iv, - uint8* _authentication // 8-byte buffer that will be filled with the authentication data -) -{ - // Build a buffer containing a 4-byte header and the encrypted - // message data, padded with zeros to a 16-byte boundary. - uint8 buffer[256]; - uint8 tmpauth[16]; - memset(buffer, 0, 256); - memset(tmpauth, 0, 16); - buffer[0] = _data[0]; // Security command class command - buffer[1] = _sendingNode; - buffer[2] = _receivingNode; - buffer[3] = _length - 19; // Subtract 19 to account for the 9 security command class bytes that come before and after the encrypted data - memcpy( &buffer[4], &_data[9], _length-19 ); // Encrypted message - - uint8 bufsize = _length - 19 + 4; /* the size of buffer */ -#ifdef DEBUG - PrintHex("Raw Auth (minus IV)", buffer, bufsize); - Log::Write(LogLevel_Debug, GetNodeId(), "Raw Auth (Minus IV) Size: %d (%d)", bufsize, bufsize+16); -#endif - - aes_mode_reset(this->AuthKey); - /* encrypt the IV with ecb */ - if (aes_ecb_encrypt(iv, tmpauth, 16, this->AuthKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed Initial ECB Encrypt of Auth Packet"); - return false; - } - - /* our temporary holding var */ - uint8 encpck[16]; - - int block = 0; - /* reset our encpck temp var */ - memset(encpck, 0, 16); - /* now xor the buffer with our encrypted IV */ - for (int i = 0; i < bufsize; i++) { - encpck[block] = buffer[i]; - block++; - /* if we hit a blocksize, then encrypt */ - if (block == 16) { - for (int j = 0; j < 16; j++) { - /* here we do our xor */ - tmpauth[j] = encpck[j] ^ tmpauth[j]; - /* and reset encpck for good measure */ - encpck[j] = 0; - } - /* reset our block counter back to 0 */ - block = 0; - aes_mode_reset(this->AuthKey); - if (aes_ecb_encrypt(tmpauth, tmpauth, 16, this->AuthKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed Subsequent (%d) ECB Encrypt of Auth Packet", i); - return false; - } - } - } - /* any left over data that isn't a full block size*/ - if (block > 0) { - for (int i= 0; i < 16; i++) { - /* encpck from block to 16 is already gauranteed to be 0 - * so its safe to xor it with out tmpmac */ - tmpauth[i] = encpck[i] ^ tmpauth[i]; - } - aes_mode_reset(this->AuthKey); - if (aes_ecb_encrypt(tmpauth, tmpauth, 16, this->AuthKey) == EXIT_FAILURE) { - Log::Write(LogLevel_Warning, GetNodeId(), "Failed Final ECB Encrypt of Auth Packet"); - return false; - } - } - /* we only care about the first 8 bytes of tmpauth as the mac */ -#ifdef DEBUG - PrintHex("Computed Auth", tmpauth, 8); -#endif - /* so only copy 8 bytes to the _authentication var */ - memcpy(_authentication, tmpauth, 8); - return true; -} - -//----------------------------------------------------------------------------- -// -// Request a nonce from the node -//----------------------------------------------------------------------------- -void Security::RequestNonce -( -) -{ - if (m_waitingForNonce == true) - return; - m_waitingForNonce = true; - - Msg* msg = new Msg( "SecurityCmd_NonceGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SecurityCmd_NonceGet ); - msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Security); - - // Reset the nonce timer. The nonce report - // must be received within 10 seconds. - m_nonceTimer.Reset(); -} - -//----------------------------------------------------------------------------- -// -// Send a nonce to the node -//----------------------------------------------------------------------------- -void Security::SendNonceReport -( -) -{ - //uint8 publicNonce[8]; - - /* this should be pretty random */ - for (int i = 0; i < 8; i++) { - //this->currentNonce[i] = (rand()%0xFF)+1; - this->currentNonce[i] = 0xAA; - } - - - Msg* msg = new Msg( "SecurityCmd_NonceReport", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 10 ); - msg->Append( GetCommandClassId() ); - msg->Append( SecurityCmd_NonceReport ); - for( int i=0; i<8; ++i ) - { - msg->Append( this->currentNonce[i] ); - } - msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Security); - - // Reset the nonce timer. The encapsulated message - // must be received within 10 seconds. - m_nonceTimer.Reset(); -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Security::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueBool( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 0, "Secured", "", true, false, false, 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Security.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Security.h deleted file mode 100644 index 2916403..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Security.h +++ /dev/null @@ -1,124 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Security.h -// -// Implementation of the Z-Wave COMMAND_CLASS_Security -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Security_H -#define _Security_H - -#include -#include "../aes/aescpp.h" -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_SECURITY (0x98), a Z-Wave device command class. - */ - - typedef struct SecurityPayload { - uint8 m_length; - uint8 m_part; - uint8 m_data[32]; - string logmsg; - } SecurityPayload; - - /* This should probably go into its own file, but its so simple... and only the Security Command Class uses it currently - */ - - class Timer { - public: - Timer() { - this->Reset(); - }; - virtual ~Timer() {}; - void Reset() { - start = clock(); - } - inline uint64 GetMilliseconds() { - return (uint64 )(((clock() - start) / (double)CLOCKS_PER_SEC) / 1000); - } - private: - clock_t start; - }; - - class Security: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Security( _homeId, _nodeId ); } - virtual ~Security(); - - static uint8 const StaticGetCommandClassId(){ return 0x98; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SECURITY"; } - bool Init(); - // From CommandClass - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - void ReadXML(TiXmlElement const* _ccElement); - void WriteXML(TiXmlElement* _ccElement); - void SendMsg( Msg* _msg ); - - protected: - void CreateVars( uint8 const _instance ); - - private: - Security( uint32 const _homeId, uint8 const _nodeId ); - bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue); - bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue); - bool HandleSupportedReport(uint8 const* _data, uint32 const _length); - void SendNonceReport(); - void RequestNonce(); - bool GenerateAuthentication( uint8 const* _data, uint32 const _length, uint8 const _sendingNode, uint8 const _receivingNode, uint8 *iv, uint8* _authentication); - bool DecryptMessage( uint8 const* _data, uint32 const _length ); - bool EncryptMessage( uint8 const* _nonce ); - void QueuePayload( SecurityPayload * _payload ); - bool createIVFromPacket_inbound(uint8 const* _data, uint8 *iv); - bool createIVFromPacket_outbound(uint8 const* _data, uint8 *iv); - void SetupNetworkKey(); - - Mutex *m_queueMutex; - list m_queue; // Messages waiting to be sent when the device wakes up - bool m_waitingForNonce; - uint8 m_sequenceCounter; - Timer m_nonceTimer; - uint8 currentNonce[8]; - bool m_networkkeyset; - - aes_encrypt_ctx *AuthKey; - aes_encrypt_ctx *EncryptKey; - uint8 *nk; - bool m_schemeagreed; - bool m_secured; - - - - - - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorAlarm.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorAlarm.cpp deleted file mode 100644 index f1ce58f..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorAlarm.cpp +++ /dev/null @@ -1,215 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SensorAlarm.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_ALARM -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SensorAlarm.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" - -using namespace OpenZWave; - -enum SensorAlarmCmd -{ - SensorAlarmCmd_Get = 0x01, - SensorAlarmCmd_Report = 0x02, - SensorAlarmCmd_SupportedGet = 0x03, - SensorAlarmCmd_SupportedReport = 0x04 -}; - -static char const* c_alarmTypeName[] = -{ - "General", - "Smoke", - "Carbon Monoxide", - "Carbon Dioxide", - "Heat", - "Flood" -}; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -SensorAlarm::SensorAlarm -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ) -{ - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Get the static thermostat setpoint details from the device -//----------------------------------------------------------------------------- -bool SensorAlarm::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - requests = RequestValue( _requestFlags, 0xff, _instance, _queue ); - } - - if( _requestFlags & RequestFlag_Dynamic ) - { - for( uint8 i=0; iRelease(); - // There is a value for this alarm type, so request it - requests |= RequestValue( _requestFlags, i, _instance, _queue ); - } - } - } - - return requests; -} - -//----------------------------------------------------------------------------- -// -// Get the sensor alarm details from the device -//----------------------------------------------------------------------------- -bool SensorAlarm::RequestValue -( - uint32 const _requestFlags, - uint8 const _alarmType, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _alarmType == 0xff ) - { - // Request the supported alarm types - Msg* msg = new Msg( "SensorAlarmCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SensorAlarmCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - else - { - // Request the alarm state - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "SensorAlarmCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( SensorAlarmCmd_Get ); - msg->Append( _alarmType ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "SensorAlarmCmd_Get Not Supported on this node"); - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SensorAlarm::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( SensorAlarmCmd_Report == (SensorAlarmCmd)_data[0] ) - { - // We have received an alarm state report from the Z-Wave device - if( ValueByte* value = static_cast( GetValue( _instance, _data[2] ) ) ) - { - uint8 sourceNodeId = _data[1]; - uint8 state = _data[3]; - // uint16 time = (((uint16)_data[4])<<8) | (uint16)_data[5]; Don't know what to do with this yet. - - value->OnValueRefreshed( state ); - value->Release(); - Log::Write( LogLevel_Info, GetNodeId(), "Received alarm state report from node %d: %s = %d", sourceNodeId, value->GetLabel().c_str(), state ); - } - - return true; - } - - if( SensorAlarmCmd_SupportedReport == (SensorAlarmCmd)_data[0] ) - { - if( Node* node = GetNodeUnsafe() ) - { - // We have received the supported alarm types from the Z-Wave device - Log::Write( LogLevel_Info, GetNodeId(), "Received supported alarm types" ); - - // Parse the data for the supported alarm types - uint8 numBytes = _data[1]; - for( uint32 i=0; iCreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, index, c_alarmTypeName[index], "", true, false, 0, 0 ); - Log::Write( LogLevel_Info, GetNodeId(), " Added alarm type: %s", c_alarmTypeName[index] ); - } - } - } - } - } - - ClearStaticRequest( StaticRequest_Values ); - return true; - } - - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorAlarm.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorAlarm.h deleted file mode 100644 index 8db5444..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorAlarm.h +++ /dev/null @@ -1,77 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SensorAlarm.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_ALARM -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SensorAlarm_H -#define _SensorAlarm_H - -#include -#include -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - - /** \brief Implements COMMAND_CLASS_SENSOR_ALARM (0x9c), a Z-Wave device command class. - */ - class SensorAlarm: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SensorAlarm( _homeId, _nodeId ); } - virtual ~SensorAlarm(){} - - static uint8 const StaticGetCommandClassId(){ return 0x9c; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SENSOR_ALARM"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _alarmType, uint8 const _dummy, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - private: - SensorAlarm( uint32 const _homeId, uint8 const _nodeId ); - - enum - { - SensorAlarm_General = 0, - SensorAlarm_Smoke, - SensorAlarm_CarbonMonoxide, - SensorAlarm_CarbonDioxide, - SensorAlarm_Heat, - SensorAlarm_Flood, - SensorAlarm_Count - }; - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorBinary.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorBinary.cpp deleted file mode 100644 index 647b009..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorBinary.cpp +++ /dev/null @@ -1,243 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SensorBinary.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_BINARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SensorBinary.h" -#include "WakeUp.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" -#include "../value_classes/ValueBool.h" -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum SensorBinaryCmd -{ - SensorBinaryCmd_Get = 0x02, - SensorBinaryCmd_Report = 0x03 -}; - -//----------------------------------------------------------------------------- -// -// Read node configuration data -//----------------------------------------------------------------------------- -void SensorBinary::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - TiXmlElement const* child = _ccElement->FirstChildElement(); - - char const* str; int index; int type; - - while( child ) - { - str = child->Value(); - - if( str ) - { - if( !strcmp( str, "SensorMap" ) ) - { - if( TIXML_SUCCESS == child->QueryIntAttribute( "index", &index ) && - TIXML_SUCCESS == child->QueryIntAttribute( "type", &type ) ) - { - m_sensorsMap[(uint8)type] = (uint8)index; - } - } - } - - child = child->NextSiblingElement(); - } -} -//----------------------------------------------------------------------------- -// -// Write node configuration data -//----------------------------------------------------------------------------- -void SensorBinary::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); - - char str[8]; - - for( map::iterator it = m_sensorsMap.begin(); it != m_sensorsMap.end(); it++ ) - { - TiXmlElement* sensorMapElement = new TiXmlElement( "SensorMap" ); - _ccElement->LinkEndChild( sensorMapElement ); - - snprintf( str, 8, "%d", it->second ); - sensorMapElement->SetAttribute( "index", str ); - - snprintf( str, 8, "%d", it->first ); - sensorMapElement->SetAttribute( "type", str ); - } -} -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool SensorBinary::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool SensorBinary::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "SensorBinaryCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SensorBinaryCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "SensorBinaryCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SensorBinary::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (SensorBinaryCmd_Report == (SensorBinaryCmd)_data[0]) - { - if( _length > 2 ) - { - uint8 index = m_sensorsMap[_data[2]]; - - Log::Write( LogLevel_Info, GetNodeId(), "Received SensorBinary report: Sensor:%d State=%s", _data[2], _data[1] ? "On" : "Off" ); - - if( ValueBool* value = static_cast( GetValue( _instance, index ) ) ) - { - value->OnValueRefreshed( _data[1] != 0 ); - value->Release(); - } - - return true; - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received SensorBinary report: State=%s", _data[1] ? "On" : "Off" ); - - if( ValueBool* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] != 0 ); - value->Release(); - } - - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Update class values based in BASIC mapping -//----------------------------------------------------------------------------- -void SensorBinary::SetValueBasic -( - uint8 const _instance, - uint8 const _value -) -{ - // Send a request for new value to synchronize it with the BASIC set/report. - // In case the device is sleeping, we set the value anyway so the BASIC set/report - // stays in sync with it. We must be careful mapping the uint8 BASIC value - // into a class specific value. - // When the device wakes up, the real requested value will be retrieved. - RequestValue( 0, 0, _instance, Driver::MsgQueue_Send ); - if( Node* node = GetNodeUnsafe() ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - if( !wakeUp->IsAwake() ) - { - if( ValueBool* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _value != 0 ); - value->Release(); - } - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void SensorBinary::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Sensor", "", true, false, false, 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorBinary.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorBinary.h deleted file mode 100644 index 5ef7e4d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorBinary.h +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SensorBinary.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_BINARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SensorBinary_H -#define _SensorBinary_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueBool; - - /** \brief Implements COMMAND_CLASS_SENSOR_BINARY (0x30), a Z-Wave device command class. - */ - class SensorBinary: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SensorBinary( _homeId, _nodeId ); } - virtual ~SensorBinary(){} - - static uint8 const StaticGetCommandClassId(){ return 0x30; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SENSOR_BINARY"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual void SetValueBasic( uint8 const _instance, uint8 const _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - SensorBinary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - map m_sensorsMap; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorMultilevel.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorMultilevel.cpp deleted file mode 100644 index 4941484..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorMultilevel.cpp +++ /dev/null @@ -1,460 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SensorMultilevel.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_MULTILEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SensorMultilevel.h" -#include "MultiInstance.h" -#include "../Defs.h" -#include "../Bitfield.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueDecimal.h" - -using namespace OpenZWave; - -enum SensorMultilevelCmd -{ - SensorMultilevelCmd_SupportedGet = 0x01, - SensorMultilevelCmd_SupportedReport = 0x02, - SensorMultilevelCmd_Get = 0x04, - SensorMultilevelCmd_Report = 0x05 -}; - -enum SensorType -{ - SensorType_Temperature = 1, - SensorType_General, - SensorType_Luminance, - SensorType_Power, - SensorType_RelativeHumidity, - SensorType_Velocity, - SensorType_Direction, - SensorType_AtmosphericPressure, - SensorType_BarometricPressure, - SensorType_SolarRadiation, - SensorType_DewPoint, - SensorType_RainRate, - SensorType_TideLevel, - SensorType_Weight, - SensorType_Voltage, - SensorType_Current, - SensorType_CO2, - SensorType_AirFlow, - SensorType_TankCapacity, - SensorType_Distance, - SensorType_AnglePosition, - SensorType_Rotation, - SensorType_WaterTemperature, - SensorType_SoilTemperature, - SensorType_SeismicIntensity, - SensorType_SeismicMagnitude, - SensorType_Ultraviolet, - SensorType_ElectricalResistivity, - SensorType_ElectricalConductivity, - SensorType_Loudness, - SensorType_Moisture, - SensorType_MaxType -}; - -static char const* c_sensorTypeNames[] = -{ - "Undefined", - "Temperature", - "General", - "Luminance", - "Power", - "Relative Humidity", - "Velocity", - "Direction", - "Atmospheric Pressure", - "Barometric Pressure", - "Solar Radiation", - "Dew Point", - "Rain Rate", - "Tide Level", - "Weight", - "Voltage", - "Current", - "CO2 Level", - "Air Flow", - "Tank Capacity", - "Distance", - "Angle Position", - "Rotation", - "Water Temperature", - "Soil Temperature", - "Seismic Intensity", - "Seismic Magnitude", - "Utraviolet", - "Electrical Resistivity", - "Electrical Conductivity", - "Loudness", - "Moisture" -}; - -static char const* c_tankCapcityUnits[] = -{ - "l", - "cbm", - "gal", - "" -}; - -static char const* c_distanceUnits[] = -{ - "m", - "cm", - "ft", - "" -}; - -static char const* c_anglePositionUnits[] = -{ - "%", - "deg N", - "deg S", - "" -}; - -static char const* c_seismicIntensityUnits[] = -{ - "mercalli", - "EU macroseismic", - "liedu", - "shindo", - "" -}; - -static char const* c_seismicMagnitudeUnits[] = -{ - "local", - "moment", - "surface wave", - "body wave", - "" -}; - -static char const* c_moistureUnits[] = -{ - "%", - "content", - "k ohms", - "water activity", - "" -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool SensorMultilevel::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool res = false; - if( GetVersion() > 4 ) - { - if( _requestFlags & RequestFlag_Static ) - { - Msg* msg = new Msg( "SensorMultilevelCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SensorMultilevelCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - res = true; - } - } - - if( _requestFlags & RequestFlag_Dynamic ) - { - res |= RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool SensorMultilevel::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool res = false; - if ( !IsGetSupported() ) { - Log::Write( LogLevel_Info, GetNodeId(), "SensorMultilevelCmd_Get Not Supported on this node"); - return false; - } - if( GetVersion() < 5 ) - { - Msg* msg = new Msg( "SensorMultilevelCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SensorMultilevelCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - res = true; - } - else - { - for( uint8 i = 1; i < SensorType_MaxType; i++ ) - { - Value* value = GetValue( _instance, i ); - if( value != NULL ) - { - value->Release(); - Msg* msg = new Msg( "SensorMultilevelCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( SensorMultilevelCmd_Get ); - msg->Append( i ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - res = true; - } - } - } - return res; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SensorMultilevel::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (SensorMultilevelCmd_SupportedReport == (SensorMultilevelCmd)_data[0]) - { - string msg = ""; - - if( Node* node = GetNodeUnsafe() ) - { - for( uint8 i = 1; i <= ( _length - 2 ); i++ ) - { - for( uint8 j = 0; j < 8; j++ ) - { - if( _data[i] & ( 1 << j ) ) - { - if( msg != "" ) - msg += ", "; - uint8 index = ( ( i - 1 ) * 8 ) + j + 1; - if (index >= SensorType_MaxType) /* max size for c_sensorTypeNames */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "SensorType Value was greater than range. Dropping"); - continue; - } - msg += c_sensorTypeNames[index]; - ValueDecimal* value = static_cast( GetValue( _instance, index ) ); - if( value == NULL) - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, index, c_sensorTypeNames[index], "", true, false, "0.0", 0 ); - } - } - } - } - } - Log::Write( LogLevel_Info, GetNodeId(), "Received SensorMultiLevel supported report from node %d: %s", GetNodeId(), msg.c_str() ); - } - else if (SensorMultilevelCmd_Report == (SensorMultilevelCmd)_data[0]) - { - uint8 scale; - uint8 precision = 0; - uint8 sensorType = _data[1]; - string valueStr = ExtractValue( &_data[2], &scale, &precision ); - - Node* node = GetNodeUnsafe(); - if( node != NULL ) - { - char const* units = ""; - switch( sensorType ) - { - case SensorType_Temperature: units = scale ? "F" : "C"; break; - case SensorType_General: units = scale ? "" : "%"; break; - case SensorType_Luminance: units = scale ? "lux" : "%"; break; - case SensorType_Power: units = scale ? "BTU/h" : "W"; break; - case SensorType_RelativeHumidity: units = scale ? "" : "%"; break; - case SensorType_Velocity: units = scale ? "mph" : "m/s"; break; - case SensorType_Direction: units = ""; break; - case SensorType_AtmosphericPressure: units = scale ? "inHg" : "kPa"; break; - case SensorType_BarometricPressure: units = scale ? "inHg" : "kPa"; break; - case SensorType_SolarRadiation: units = "W/m2"; break; - case SensorType_DewPoint: units = scale ? "F" : "C"; break; - case SensorType_RainRate: units = scale ? "in/h" : "mm/h"; break; - case SensorType_TideLevel: units = scale ? "ft" : "m"; break; - case SensorType_Weight: units = scale ? "lb" : "kg"; break; - case SensorType_Voltage: units = scale ? "mV" : "V"; break; - case SensorType_Current: units = scale ? "mA" : "A"; break; - case SensorType_CO2: units = "ppm"; break; - case SensorType_AirFlow: units = scale ? "cfm" : "m3/h"; break; - case SensorType_TankCapacity: { - if (scale > 2) /* size of c_tankCapcityUnits minus invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Scale Value for c_tankCapcityUnits was greater than range. Setting to empty"); - units = c_tankCapcityUnits[3]; /* empty entry */ - } - else - { - units = c_tankCapcityUnits[scale]; - } - } - break; - case SensorType_Distance: { - if (scale > 2) /* size of c_distanceUnits minus invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Scale Value for c_distanceUnits was greater than range. Setting to empty"); - units = c_distanceUnits[3]; /* empty entry */ - } - else - { - units = c_distanceUnits[scale]; - } - } - break; - case SensorType_AnglePosition: { - if (scale > 2) /* size of c_anglePositionUnits minus invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Scale Value for c_anglePositionUnits was greater than range. Setting to empty"); - units = c_anglePositionUnits[3]; /* empty entry */ - } - else - { - units = c_anglePositionUnits[scale]; - } - } - break; - case SensorType_Rotation: units = scale ? "hz" : "rpm"; break; - case SensorType_WaterTemperature: units = scale ? "F" : "C"; break; - case SensorType_SoilTemperature: units = scale ? "F" : "C"; break; - case SensorType_SeismicIntensity: { - if (scale > 3) /* size of c_seismicIntensityUnits minus invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Scale Value for c_seismicIntensityUnits was greater than range. Setting to empty"); - units = c_seismicIntensityUnits[4]; /* empty entry */ - } - else - { - units = c_seismicIntensityUnits[scale]; - } - } - break; - case SensorType_SeismicMagnitude: { - if (scale > 3) /* size of c_seismicMagnitudeUnits minus invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Scale Value for c_seismicMagnitudeUnits was greater than range. Setting to empty"); - units = c_seismicMagnitudeUnits[4]; /* empty entry */ - } - else - { - units = c_seismicMagnitudeUnits[scale]; - } - } - break; - case SensorType_Ultraviolet: units = ""; break; - case SensorType_ElectricalResistivity: units = "ohm"; break; - case SensorType_ElectricalConductivity: units = "siemens/m"; break; - case SensorType_Loudness: units = scale ? "dBA" : "db"; break; - case SensorType_Moisture: { - if (scale > 3) /* size of c_moistureUnits minus invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "Scale Value for c_moistureUnits was greater than range. Setting to empty"); - units = c_moistureUnits[4]; /* empty entry */ - } - else - { - units = c_moistureUnits[scale]; - } - } - break; - default: { - Log::Write (LogLevel_Warning, GetNodeId(), "sensorType Value was greater than range. Dropping"); - return false; - } - break; - - } - - ValueDecimal* value = static_cast( GetValue( _instance, sensorType ) ); - if( value == NULL) - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, sensorType, c_sensorTypeNames[sensorType], units, true, false, "0.0", 0 ); - value = static_cast( GetValue( _instance, sensorType ) ); - } - else - { - value->SetUnits(units); - } - - Log::Write( LogLevel_Info, GetNodeId(), "Received SensorMultiLevel report from node %d, instance %d, %s: value=%s%s", GetNodeId(), _instance, c_sensorTypeNames[sensorType], valueStr.c_str(), value->GetUnits().c_str() ); - if( value->GetPrecision() != precision ) - { - value->SetPrecision( precision ); - } - value->OnValueRefreshed( valueStr ); - value->Release(); - return true; - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void SensorMultilevel::CreateVars -( - uint8 const _instance -) -{ - // Don't create anything here. We do it in the report. -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorMultilevel.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorMultilevel.h deleted file mode 100644 index 4675fc0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SensorMultilevel.h +++ /dev/null @@ -1,68 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SensorMultilevel.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_MULTILEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SensorMultilevel_H -#define _SensorMultilevel_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueDecimal; - - /** \brief Implements COMMAND_CLASS_SENSOR_MULTILEVEL (0x31), a Z-Wave device command class. - */ - class SensorMultilevel: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SensorMultilevel( _homeId, _nodeId ); } - virtual ~SensorMultilevel(){} - - static uint8 const StaticGetCommandClassId(){ return 0x31; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SENSOR_MULTILEVEL"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _dummy, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - virtual uint8 GetMaxVersion(){ return 5; } - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - SensorMultilevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchAll.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchAll.cpp deleted file mode 100644 index 8b35786..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchAll.cpp +++ /dev/null @@ -1,225 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchAll.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_ALL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SwitchAll.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueList.h" - -using namespace OpenZWave; - -enum SwitchAllCmd -{ - SwitchAllCmd_Set = 0x01, - SwitchAllCmd_Get = 0x02, - SwitchAllCmd_Report = 0x03, - SwitchAllCmd_On = 0x04, - SwitchAllCmd_Off = 0x05 -}; - -static char const* c_switchAllStateName[] = -{ - "Disabled", - "Off Enabled", - "On Enabled", - "On and Off Enabled" -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool SwitchAll::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Session ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool SwitchAll::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "SwitchAllCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchAllCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "SwitchAllCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SwitchAll::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (SwitchAllCmd_Report == (SwitchAllCmd)_data[0]) - { - if( ValueList* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( (int32)_data[1] ); - value->Release(); - Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchAll report from node %d: %s", GetNodeId(), value->GetItem().m_label.c_str() ); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the device's response to SWITCH_ALL commands -//----------------------------------------------------------------------------- -bool SwitchAll::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_List == _value.GetID().GetType() ) - { - ValueList const* value = static_cast(&_value); - ValueList::Item const& item = value->GetItem(); - - Log::Write( LogLevel_Info, GetNodeId(), "SwitchAll::Set - %s on node %d", item.m_label.c_str(), GetNodeId() ); - Msg* msg = new Msg( "SwitchAllCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchAllCmd_Set ); - msg->Append( (uint8)item.m_value ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Send a command to switch all devices off -//----------------------------------------------------------------------------- -void SwitchAll::Off -( - Driver* _driver, - uint8 const _nodeId -) -{ - Log::Write( LogLevel_Info, _nodeId, "SwitchAll::Off (Node=%d)", _nodeId ); - Msg* msg = new Msg( "SwitchAllCmd_Off", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( _nodeId ); - msg->Append( 2 ); - msg->Append( StaticGetCommandClassId() ); - msg->Append( SwitchAllCmd_Off ); - msg->Append( _driver->GetTransmitOptions() ); - _driver->SendMsg( msg, Driver::MsgQueue_Send ); -} - -//----------------------------------------------------------------------------- -// -// Send a command to switch all devices on -//----------------------------------------------------------------------------- -void SwitchAll::On -( - Driver* _driver, - uint8 const _nodeId -) -{ - Log::Write( LogLevel_Info, _nodeId, "SwitchAll::On (Node=%d)", _nodeId ); - Msg* msg = new Msg( "SwitchAllCmd_On", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( _nodeId ); - msg->Append( 2 ); - msg->Append( StaticGetCommandClassId() ); - msg->Append( SwitchAllCmd_On ); - msg->Append( _driver->GetTransmitOptions() ); - _driver->SendMsg( msg, Driver::MsgQueue_Send ); -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void SwitchAll::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - vector items; - for( int i=0; i<4; ++i ) - { - ValueList::Item item; - item.m_label = c_switchAllStateName[i]; - item.m_value = (i==3) ? 0x000000ff : i; - items.push_back( item ); - } - - node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 0, "Switch All", "", false, false, 1, items, 0, 0 ); - } -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchAll.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchAll.h deleted file mode 100644 index b945470..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchAll.h +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchAll.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_ALL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SwitchAll_H -#define _SwitchAll_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueList; - - /** \brief Implements COMMAND_CLASS_SWITCH_ALL (0x27), a Z-Wave device command class. - */ - class SwitchAll: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchAll( _homeId, _nodeId ); } - virtual ~SwitchAll(){} - - static uint8 const StaticGetCommandClassId(){ return 0x27; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_ALL"; } - - static void On( Driver* _driver, uint8 const _nodeId ); - static void Off( Driver* _driver, uint8 const _nodeId ); - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - SwitchAll( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchBinary.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchBinary.cpp deleted file mode 100644 index c5ed26d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchBinary.cpp +++ /dev/null @@ -1,196 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchBinary.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_BINARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SwitchBinary.h" -#include "WakeUp.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueBool.h" - -using namespace OpenZWave; - -enum SwitchBinaryCmd -{ - SwitchBinaryCmd_Set = 0x01, - SwitchBinaryCmd_Get = 0x02, - SwitchBinaryCmd_Report = 0x03 -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool SwitchBinary::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool SwitchBinary::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "SwitchBinaryCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchBinaryCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "SwitchBinaryCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SwitchBinary::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (SwitchBinaryCmd_Report == (SwitchBinaryCmd)_data[0]) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchBinary report from node %d: level=%s", GetNodeId(), _data[1] ? "On" : "Off" ); - - if( ValueBool* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] != 0 ); - value->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the state of the switch -//----------------------------------------------------------------------------- -bool SwitchBinary::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_Bool == _value.GetID().GetType() ) - { - ValueBool const* value = static_cast(&_value); - - Log::Write( LogLevel_Info, GetNodeId(), "SwitchBinary::Set - Setting node %d to %s", GetNodeId(), value->GetValue() ? "On" : "Off" ); - Msg* msg = new Msg( "SwitchBinary Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchBinaryCmd_Set ); - msg->Append( value->GetValue() ? 0xff : 0x00 ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Update class values based in BASIC mapping -//----------------------------------------------------------------------------- -void SwitchBinary::SetValueBasic -( - uint8 const _instance, - uint8 const _value -) -{ - // Send a request for new value to synchronize it with the BASIC set/report. - // In case the device is sleeping, we set the value anyway so the BASIC set/report - // stays in sync with it. We must be careful mapping the uint8 BASIC value - // into a class specific value. - // When the device wakes up, the real requested value will be retrieved. - RequestValue( 0, 0, _instance, Driver::MsgQueue_Send ); - if( Node* node = GetNodeUnsafe() ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - if( !wakeUp->IsAwake() ) - { - if( ValueBool* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _value != 0 ); - value->Release(); - } - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void SwitchBinary::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Switch", "", false, false, false, 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchBinary.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchBinary.h deleted file mode 100644 index 9ff905b..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchBinary.h +++ /dev/null @@ -1,67 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchBinary.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_BINARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SwitchBinary_H -#define _SwitchBinary_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueBool; - - /** \brief Implements COMMAND_CLASS_SWITCH_BINARY (0x25), a Z-Wave device command class. - */ - class SwitchBinary: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchBinary( _homeId, _nodeId ); } - virtual ~SwitchBinary(){} - - static uint8 const StaticGetCommandClassId(){ return 0x25; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_BINARY"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - virtual void SetValueBasic( uint8 const _instance, uint8 const _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - SwitchBinary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchMultilevel.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchMultilevel.cpp deleted file mode 100644 index b4e910e..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchMultilevel.cpp +++ /dev/null @@ -1,631 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchMultilevel.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_MULTILEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SwitchMultilevel.h" -#include "WakeUp.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueBool.h" -#include "../value_classes/ValueButton.h" -#include "../value_classes/ValueByte.h" - -using namespace OpenZWave; - -enum SwitchMultilevelCmd -{ - SwitchMultilevelCmd_Set = 0x01, - SwitchMultilevelCmd_Get = 0x02, - SwitchMultilevelCmd_Report = 0x03, - SwitchMultilevelCmd_StartLevelChange = 0x04, - SwitchMultilevelCmd_StopLevelChange = 0x05, - SwitchMultilevelCmd_SupportedGet = 0x06, - SwitchMultilevelCmd_SupportedReport = 0x07 -}; - -enum -{ - SwitchMultilevelIndex_Level = 0, - SwitchMultilevelIndex_Bright, - SwitchMultilevelIndex_Dim, - SwitchMultilevelIndex_IgnoreStartLevel, - SwitchMultilevelIndex_StartLevel, - SwitchMultilevelIndex_Duration, - SwitchMultilevelIndex_Step, - SwitchMultilevelIndex_Inc, - SwitchMultilevelIndex_Dec -}; - -static uint8 c_directionParams[] = -{ - 0x18, - 0x58, - 0xc0, - 0xc8 -}; - -static char const* c_directionDebugLabels[] = -{ - "Up", - "Down", - "Inc", - "Dec" -}; - -static char const* c_switchLabelsPos[] = -{ - "Undefined", - "On", - "Up", - "Open", - "Clockwise", - "Right", - "Forward", - "Push" -}; - -static char const* c_switchLabelsNeg[] = -{ - "Undefined", - "Off", - "Down", - "Close", - "Counter-Clockwise", - "Left", - "Reverse", - "Pull" -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool SwitchMultilevel::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool SwitchMultilevel::RequestValue -( - uint32 const _requestFlags, - uint8 const _index, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _index == SwitchMultilevelIndex_Level ) - { - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "SwitchMultilevelCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchMultilevelCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevelCmd_Get Not Supported on this node"); - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SwitchMultilevel::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( SwitchMultilevelCmd_Report == (SwitchMultilevelCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchMultiLevel report: level=%d", _data[1] ); - - if( ValueByte* value = static_cast( GetValue( _instance, SwitchMultilevelIndex_Level ) ) ) - { - value->OnValueRefreshed( _data[1] ); - value->Release(); - } - return true; - } - - if( SwitchMultilevelCmd_SupportedReport == (SwitchMultilevelCmd)_data[0] ) - { - uint8 switchType1 = _data[1] & 0x1f; - uint8 switchType2 = _data[2] & 0x1f; - uint8 switchtype1label = switchType1; - uint8 switchtype2label = switchType2; - if (switchtype1label > 7) /* size of c_switchLabelsPos, c_switchLabelsNeg */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "switchtype1label Value was greater than range. Setting to Invalid"); - switchtype1label = 0; - } - if (switchtype2label > 7) /* sizeof c_switchLabelsPos, c_switchLabelsNeg */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "switchtype2label Value was greater than range. Setting to Invalid"); - switchtype2label = 0; - } - - - Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchMultiLevel supported report: Switch1=%s/%s, Switch2=%s/%s", c_switchLabelsPos[switchtype1label], c_switchLabelsNeg[switchtype1label], c_switchLabelsPos[switchtype2label], c_switchLabelsNeg[switchtype2label] ); - ClearStaticRequest( StaticRequest_Version ); - - // Set the labels on the values - ValueButton* button; - - if( switchType1 ) - { - if( NULL != ( button = static_cast( GetValue( _instance, SwitchMultilevelIndex_Bright ) ) ) ) - { - button->SetLabel( c_switchLabelsPos[switchtype1label] ); - button->Release(); - } - if( NULL != ( button = static_cast( GetValue( _instance, SwitchMultilevelIndex_Dim ) ) ) ) - { - button->SetLabel( c_switchLabelsNeg[switchtype1label] ); - button->Release(); - } - } - - if( switchType2 ) - { - if( NULL != ( button = static_cast( GetValue( _instance, SwitchMultilevelIndex_Inc ) ) ) ) - { - button->SetLabel( c_switchLabelsPos[switchtype2label] ); - button->Release(); - } - if( NULL != ( button = static_cast( GetValue( _instance, SwitchMultilevelIndex_Dec ) ) ) ) - { - button->SetLabel( c_switchLabelsNeg[switchtype2label] ); - button->Release(); - } - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the command class version -//----------------------------------------------------------------------------- -void SwitchMultilevel::SetVersion -( - uint8 const _version -) -{ - CommandClass::SetVersion( _version ); - - if( _version == 3 ) - { - // Request the supported switch types - Msg* msg = new Msg( "SwitchMultilevelCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchMultilevelCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - - // Set the request flag again - it will be cleared when we get a - // response to the SwitchMultilevelCmd_SupportedGet message. - SetStaticRequest( StaticRequest_Version ); - } -} - -//----------------------------------------------------------------------------- -// -// Set the level on a device -//----------------------------------------------------------------------------- -bool SwitchMultilevel::SetValue -( - Value const& _value -) -{ - bool res = false; - uint8 instance = _value.GetID().GetInstance(); - - switch( _value.GetID().GetIndex() ) - { - case SwitchMultilevelIndex_Level: - { - // Level - if( ValueByte* value = static_cast( GetValue( instance, SwitchMultilevelIndex_Level ) ) ) - { - res = SetLevel( instance, (static_cast(&_value))->GetValue() ); - value->Release(); - } - break; - } - case SwitchMultilevelIndex_Bright: - { - // Bright - if( ValueButton* button = static_cast( GetValue( instance, SwitchMultilevelIndex_Bright ) ) ) - { - if( button->IsPressed() ) - { - res = StartLevelChange( instance, SwitchMultilevelDirection_Up ); - } - else - { - res = StopLevelChange( instance ); - } - button->Release(); - } - break; - } - case SwitchMultilevelIndex_Dim: - { - // Dim - if( ValueButton* button = static_cast( GetValue( instance, SwitchMultilevelIndex_Dim ) ) ) - { - if( button->IsPressed() ) - { - res = StartLevelChange( instance, SwitchMultilevelDirection_Down ); - } - else - { - res = StopLevelChange( instance ); - } - button->Release(); - } - break; - } - case SwitchMultilevelIndex_IgnoreStartLevel: - { - if( ValueBool* value = static_cast( GetValue( instance, SwitchMultilevelIndex_IgnoreStartLevel ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - res = true; - break; - } - case SwitchMultilevelIndex_StartLevel: - { - if( ValueByte* value = static_cast( GetValue( instance, SwitchMultilevelIndex_StartLevel ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - res = true; - break; - } - case SwitchMultilevelIndex_Duration: - { - if( ValueByte* value = static_cast( GetValue( instance, SwitchMultilevelIndex_Duration ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - res = true; - break; - } - case SwitchMultilevelIndex_Step: - { - if( ValueByte* value = static_cast( GetValue( instance, SwitchMultilevelIndex_Step ) ) ) - { - value->OnValueRefreshed( (static_cast( &_value))->GetValue() ); - value->Release(); - } - res = true; - break; - } - case SwitchMultilevelIndex_Inc: - { - // Inc - if( ValueButton* button = static_cast( GetValue( instance, SwitchMultilevelIndex_Inc ) ) ) - { - if( button->IsPressed() ) - { - res = StartLevelChange( instance, SwitchMultilevelDirection_Inc ); - } - else - { - res = StopLevelChange( instance ); - } - button->Release(); - } - break; - } - case SwitchMultilevelIndex_Dec: - { - // Dec - if( ValueButton* button = static_cast( GetValue( instance, SwitchMultilevelIndex_Dec ) ) ) - { - if( button->IsPressed() ) - { - res = StartLevelChange( instance, SwitchMultilevelDirection_Dec ); - } - else - { - res = StopLevelChange( instance ); - } - button->Release(); - } - break; - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// Update class values based in BASIC mapping -//----------------------------------------------------------------------------- -void SwitchMultilevel::SetValueBasic -( - uint8 const _instance, - uint8 const _value -) -{ - // Send a request for new value to synchronize it with the BASIC set/report. - // In case the device is sleeping, we set the value anyway so the BASIC set/report - // stays in sync with it. We must be careful mapping the uint8 BASIC value - // into a class specific value. - // When the device wakes up, the real requested value will be retrieved. - RequestValue( 0, 0, _instance, Driver::MsgQueue_Send ); - if( Node* node = GetNodeUnsafe() ) - { - if( WakeUp* wakeUp = static_cast( node->GetCommandClass( WakeUp::StaticGetCommandClassId() ) ) ) - { - if( !wakeUp->IsAwake() ) - { - if( ValueByte* value = static_cast( GetValue( _instance, SwitchMultilevelIndex_Level ) ) ) - { - value->OnValueRefreshed( _value != 0 ); - value->Release(); - } - } - } - } -} - -//----------------------------------------------------------------------------- -// -// Set a new level for the switch -//----------------------------------------------------------------------------- -bool SwitchMultilevel::SetLevel -( - uint8 const _instance, - uint8 const _level -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::Set - Setting to level %d", _level ); - Msg* msg = new Msg( "SwitchMultiLevel Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - - if( ValueByte* durationValue = static_cast( GetValue( _instance, SwitchMultilevelIndex_Duration ) ) ) - { - uint8 duration = durationValue->GetValue(); - durationValue->Release(); - if( duration == 0xff ) - { - Log::Write( LogLevel_Info, GetNodeId(), " Duration: Default" ); - } - else if( duration >= 0x80 ) - { - Log::Write( LogLevel_Info, GetNodeId(), " Duration: %d minutes", duration - 0x7f ); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), " Duration: %d seconds", duration ); - } - - msg->Append( 4 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchMultilevelCmd_Set ); - msg->Append( _level ); - msg->Append( duration ); - } - else - { - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchMultilevelCmd_Set ); - msg->Append( _level ); - } - - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Start the level changing -//----------------------------------------------------------------------------- -bool SwitchMultilevel::StartLevelChange -( - uint8 const _instance, - SwitchMultilevelDirection const _direction -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::StartLevelChange - Starting a level change" ); - - uint8 length = 4; - if (_direction > 3) /* size of c_directionParams, c_directionDebugLabels */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "_direction Value was greater than range. Dropping"); - return false; - } - uint8 direction = c_directionParams[_direction]; - Log::Write( LogLevel_Info, GetNodeId(), " Direction: %s", c_directionDebugLabels[_direction] ); - - if( ValueBool* ignoreStartLevel = static_cast( GetValue( _instance, SwitchMultilevelIndex_IgnoreStartLevel ) ) ) - { - if( ignoreStartLevel->GetValue() ) - { - ignoreStartLevel->Release(); - // Set the ignore start level flag - direction |= 0x20; - } - } - Log::Write( LogLevel_Info, GetNodeId(), " Ignore Start Level: %s", (direction & 0x20) ? "True" : "False" ); - - uint8 startLevel = 0; - if( ValueByte* startLevelValue = static_cast( GetValue( _instance, SwitchMultilevelIndex_StartLevel ) ) ) - { - startLevel = startLevelValue->GetValue(); - startLevelValue->Release(); - } - Log::Write( LogLevel_Info, GetNodeId(), " Start Level: %d", startLevel ); - - uint8 duration = 0; - if( ValueByte* durationValue = static_cast( GetValue( _instance, SwitchMultilevelIndex_Duration ) ) ) - { - length = 5; - duration = durationValue->GetValue(); - durationValue->Release(); - Log::Write( LogLevel_Info, GetNodeId(), " Duration: %d", duration ); - } - - uint8 step = 0; - if( ( SwitchMultilevelDirection_Inc == _direction ) || ( SwitchMultilevelDirection_Dec == _direction ) ) - { - if( ValueByte* stepValue = static_cast( GetValue( _instance, SwitchMultilevelIndex_Step ) ) ) - { - length = 6; - step = stepValue->GetValue(); - stepValue->Release(); - Log::Write( LogLevel_Info, GetNodeId(), " Step Size: %d", step ); - } - } - - Msg* msg = new Msg( "SwitchMultilevel StartLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( length ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchMultilevelCmd_StartLevelChange ); - msg->Append( direction ); - msg->Append( startLevel ); - - if( length >= 5 ) - { - msg->Append( duration ); - } - - if( length == 6 ) - { - msg->Append( step ); - } - - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Stop the level changing -//----------------------------------------------------------------------------- -bool SwitchMultilevel::StopLevelChange -( - uint8 const _instance -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::StopLevelChange - Stopping the level change" ); - Msg* msg = new Msg( "SwitchMultilevel StopLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchMultilevelCmd_StopLevelChange ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void SwitchMultilevel::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - switch( GetVersion() ) - { - case 3: - { - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Step, "Step Size", "", false, false, 0, 0 ); - node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Inc, "Inc", 0 ); - node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Dec, "Dec", 0 ); - // Fall through to version 2 - } - case 2: - { - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, SwitchMultilevelIndex_Duration, "Dimming Duration", "", false, false, 0xff, 0 ); - // Fall through to version 1 - } - case 1: - { - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Level, "Level", "", false, false, 0, 0 ); - node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Bright, "Bright", 0 ); - node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Dim, "Dim", 0 ); - node->CreateValueBool( ValueID::ValueGenre_System, GetCommandClassId(), _instance, SwitchMultilevelIndex_IgnoreStartLevel, "Ignore Start Level", "", false, false, true, 0 ); - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, SwitchMultilevelIndex_StartLevel, "Start Level", "", false, false, 0, 0 ); - break; - } - } - } -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchMultilevel.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchMultilevel.h deleted file mode 100644 index 99cc863..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchMultilevel.h +++ /dev/null @@ -1,84 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchMultilevel.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_MULTILEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SwitchMultilevel_H -#define _SwitchMultilevel_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueBool; - class ValueButton; - class ValueByte; - - /** \brief Implements COMMAND_CLASS_SWITCH_MULTILEVEL (0x26), a Z-Wave device command class. - */ - class SwitchMultilevel: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchMultilevel( _homeId, _nodeId ); } - virtual ~SwitchMultilevel(){} - - static uint8 const StaticGetCommandClassId(){ return 0x26; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_MULTILEVEL"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - virtual void SetValueBasic( uint8 const _instance, uint8 const _value ); - virtual void SetVersion( uint8 const _version ); - - virtual uint8 GetMaxVersion(){ return 3; } - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - enum SwitchMultilevelDirection - { - SwitchMultilevelDirection_Up = 0, - SwitchMultilevelDirection_Down, - SwitchMultilevelDirection_Inc, - SwitchMultilevelDirection_Dec - }; - - SwitchMultilevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - - bool SetLevel( uint8 const _instance, uint8 const _level ); - bool StartLevelChange( uint8 const _instance, SwitchMultilevelDirection const _direction ); - bool StopLevelChange( uint8 const _instance ); - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleBinary.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleBinary.cpp deleted file mode 100644 index cedeaf8..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleBinary.cpp +++ /dev/null @@ -1,157 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchToggleBinary.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_BINARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SwitchToggleBinary.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueBool.h" - -using namespace OpenZWave; - -enum SwitchToggleBinaryCmd -{ - SwitchToggleBinaryCmd_Set = 0x01, - SwitchToggleBinaryCmd_Get = 0x02, - SwitchToggleBinaryCmd_Report = 0x03 -}; - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool SwitchToggleBinary::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool SwitchToggleBinary::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "SwitchToggleBinaryCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchToggleBinaryCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleBinaryCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SwitchToggleBinary::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( SwitchToggleBinaryCmd_Report == (SwitchToggleBinaryCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchToggleBinary report: %s", _data[1] ? "On" : "Off" ); - - if( ValueBool* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] != 0 ); - value->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Toggle the state of the switch -//----------------------------------------------------------------------------- -bool SwitchToggleBinary::SetValue -( - Value const& _value -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleBinary::Set - Toggling the state" ); - Msg* msg = new Msg( "SwitchToggleBinary Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchToggleBinaryCmd_Set ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void SwitchToggleBinary::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Toggle Switch", "", false, false, false, 0 ); - } -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleBinary.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleBinary.h deleted file mode 100644 index f3cfdf9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleBinary.h +++ /dev/null @@ -1,66 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchToggleBinary.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_BINARY -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SwitchToggleBinary_H -#define _SwitchToggleBinary_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueBool; - - /** \brief Implements COMMAND_CLASS_SWITCH_TOGGLE_BINARY (0x28), a Z-Wave device command class. - */ - class SwitchToggleBinary: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchToggleBinary( _homeId, _nodeId ); } - virtual ~SwitchToggleBinary(){} - - static uint8 const StaticGetCommandClassId(){ return 0x28; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_TOGGLE_BINARY"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - SwitchToggleBinary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleMultilevel.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleMultilevel.cpp deleted file mode 100644 index 243e531..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleMultilevel.cpp +++ /dev/null @@ -1,201 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchToggleMultilevel.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "SwitchToggleMultilevel.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" - -using namespace OpenZWave; - -enum SwitchToggleMultilevelCmd -{ - SwitchToggleMultilevelCmd_Set = 0x01, - SwitchToggleMultilevelCmd_Get = 0x02, - SwitchToggleMultilevelCmd_Report = 0x03, - SwitchToggleMultilevelCmd_StartLevelChange = 0x04, - SwitchToggleMultilevelCmd_StopLevelChange = 0x05 -}; - - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool SwitchToggleMultilevel::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool SwitchToggleMultilevel::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "SwitchToggleMultilevelCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchToggleMultilevelCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleMultilevelCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool SwitchToggleMultilevel::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( SwitchToggleMultilevelCmd_Report == (SwitchToggleMultilevelCmd)_data[0] ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchToggleMultiLevel report: level=%d", _data[1] ); - - if( ValueByte* value = static_cast( GetValue( _instance, 0 ) ) ) - { - value->OnValueRefreshed( _data[1] ); - value->Release(); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Toggle the state of the switch -//----------------------------------------------------------------------------- -bool SwitchToggleMultilevel::SetValue -( - Value const& _value -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleMultilevel::Set - Toggling the state" ); - Msg* msg = new Msg( "SwitchToggleMultilevel Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchToggleMultilevelCmd_Set ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Start the level changing -//----------------------------------------------------------------------------- -void SwitchToggleMultilevel::StartLevelChange -( - SwitchToggleMultilevelDirection const _direction, - bool const _bIgnoreStartLevel, - bool const _bRollover -) -{ - uint8 param = (uint8)_direction; - param |= ( _bIgnoreStartLevel ? 0x20 : 0x00 ); - param |= ( _bRollover ? 0x80 : 0x00 ); - - Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::StartLevelChange - Starting a level change, Direction=%d, IgnoreStartLevel=%s and rollover=%s", (_direction==SwitchToggleMultilevelDirection_Up) ? "Up" : "Down", _bIgnoreStartLevel ? "True" : "False", _bRollover ? "True" : "False" ); - Msg* msg = new Msg( "SwitchMultilevel StartLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchToggleMultilevelCmd_StartLevelChange ); - msg->Append( param ); - msg->Append( GetDriver()->GetTransmitOptions() ); -} - -//----------------------------------------------------------------------------- -// -// Stop the level changing -//----------------------------------------------------------------------------- -void SwitchToggleMultilevel::StopLevelChange -( -) -{ - Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleMultilevel::StopLevelChange - Stopping the level change" ); - Msg* msg = new Msg( "SwitchToggleMultilevel StopLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( SwitchToggleMultilevelCmd_StopLevelChange ); - msg->Append( GetDriver()->GetTransmitOptions() ); -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void SwitchToggleMultilevel::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Level", "", false, false, 0, 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleMultilevel.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleMultilevel.h deleted file mode 100644 index c6e91d3..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/SwitchToggleMultilevel.h +++ /dev/null @@ -1,75 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SwitchToggleMultilevel.h -// -// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SwitchToggleMultilevel_H -#define _SwitchToggleMultilevel_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - - /** \brief Implements COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL (0x29), a Z-Wave device command class. - */ - class SwitchToggleMultilevel: public CommandClass - { - public: - enum SwitchToggleMultilevelDirection - { - SwitchToggleMultilevelDirection_Up = 0x00, - SwitchToggleMultilevelDirection_Down = 0x40 - }; - - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchToggleMultilevel( _homeId, _nodeId ); } - virtual ~SwitchToggleMultilevel(){} - - static uint8 const StaticGetCommandClassId(){ return 0x29; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL"; } - - void StartLevelChange( SwitchToggleMultilevelDirection const _direction, bool const _bIgnoreStartLevel, bool const _bRollover ); - void StopLevelChange(); - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - SwitchToggleMultilevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanMode.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanMode.cpp deleted file mode 100644 index 0b4bb0c..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanMode.cpp +++ /dev/null @@ -1,344 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatFanMode.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_FAN_MODE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include "CommandClasses.h" -#include "ThermostatFanMode.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueList.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum ThermostatFanModeCmd -{ - ThermostatFanModeCmd_Set = 0x01, - ThermostatFanModeCmd_Get = 0x02, - ThermostatFanModeCmd_Report = 0x03, - ThermostatFanModeCmd_SupportedGet = 0x04, - ThermostatFanModeCmd_SupportedReport = 0x05 -}; - -static string const c_modeName[] = -{ - "Auto Low", - "On Low", - "Auto High", - "On High", - "Unknown 4", - "Unknown 5", - "Circulate", - "Unknown" -}; - -//----------------------------------------------------------------------------- -// -// Read the supported modes -//----------------------------------------------------------------------------- -void ThermostatFanMode::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - if( GetNodeUnsafe() ) - { - vector supportedModes; - - TiXmlElement const* supportedModesElement = _ccElement->FirstChildElement( "SupportedModes" ); - if( supportedModesElement ) - { - TiXmlElement const* modeElement = supportedModesElement->FirstChildElement(); - while( modeElement ) - { - char const* str = modeElement->Value(); - if( str && !strcmp( str, "Mode" ) ) - { - int index; - if( TIXML_SUCCESS == modeElement->QueryIntAttribute( "index", &index ) ) - { - if (index > 6) /* size of c_modeName excluding Invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "index Value in XML was greater than range. Setting to Invalid"); - index = 7; - } - ValueList::Item item; - item.m_value = index; - item.m_label = c_modeName[index]; - supportedModes.push_back( item ); - } - } - - modeElement = modeElement->NextSiblingElement(); - } - } - - if( !supportedModes.empty() ) - { - m_supportedModes = supportedModes; - ClearStaticRequest( StaticRequest_Values ); - CreateVars( 1 ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Save the supported modes -//----------------------------------------------------------------------------- -void ThermostatFanMode::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); - - if( GetNodeUnsafe() ) - { - TiXmlElement* supportedModesElement = new TiXmlElement( "SupportedModes" ); - _ccElement->LinkEndChild( supportedModesElement ); - - for( vector::iterator it = m_supportedModes.begin(); it != m_supportedModes.end(); ++it ) - { - ValueList::Item const& item = *it; - - TiXmlElement* modeElement = new TiXmlElement( "Mode" ); - supportedModesElement->LinkEndChild( modeElement ); - - char str[8]; - snprintf( str, 8, "%d", item.m_value ); - modeElement->SetAttribute( "index", str ); - modeElement->SetAttribute( "label", item.m_label.c_str() ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Get the static thermostat fan mode details from the device -//----------------------------------------------------------------------------- -bool ThermostatFanMode::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - // Request the supported modes - requests |= RequestValue( _requestFlags, ThermostatFanModeCmd_SupportedGet, _instance, _queue ); - } - - if( _requestFlags & RequestFlag_Dynamic ) - { - // Request the current fan mode - requests |= RequestValue( _requestFlags, ThermostatFanModeCmd_Get, _instance, _queue ); - } - - return requests; -} - -//----------------------------------------------------------------------------- -// -// Get the thermostat fan mode details from the device -//----------------------------------------------------------------------------- -bool ThermostatFanMode::RequestValue -( - uint32 const _requestFlags, - uint8 const _getTypeEnum, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _getTypeEnum == ThermostatFanModeCmd_SupportedGet ) - { - // Request the supported modes - Msg* msg = new Msg( "ThermostatFanModeCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatFanModeCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - - if( _getTypeEnum == ThermostatFanModeCmd_Get || _getTypeEnum == 0 ) - { - if ( IsGetSupported() ) - { - // Request the current fan mode - Msg* msg = new Msg( "ThermostatFanModeCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatFanModeCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ThermostatFanModeCmd_Get Not Supported on this node"); - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ThermostatFanMode::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ThermostatFanModeCmd_Report == (ThermostatFanModeCmd)_data[0] ) - { - uint8 mode = (int32)_data[1]; - - if( mode < m_supportedModes.size() ) - { - // We have received the thermostat mode from the Z-Wave device - if( ValueList* valueList = static_cast( GetValue( _instance, 0 ) ) ) - { - valueList->OnValueRefreshed( (int32)_data[1] ); - Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat fan mode: %s", valueList->GetItem().m_label.c_str() ); - valueList->Release(); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat fan mode: index %d", mode ); - } - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received unknown thermostat fan mode: %d", mode ); - } - return true; - } - - if( ThermostatFanModeCmd_SupportedReport == (ThermostatFanModeCmd)_data[0] ) - { - // We have received the supported thermostat fan modes from the Z-Wave device - Log::Write( LogLevel_Info, GetNodeId(), "Received supported thermostat fan modes" ); - - m_supportedModes.clear(); - for( uint32 i=1; i<_length-1; ++i ) - { - for( int32 bit=0; bit<8; ++bit ) - { - if( ( _data[i] & (1<= (sizeof(c_modeName)/sizeof(*c_modeName) -1)) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received unknown fan mode: 0x%x", item.m_value); - } - else - { - item.m_label = c_modeName[item.m_value]; - m_supportedModes.push_back( item ); - - Log::Write( LogLevel_Info, GetNodeId(), " Added fan mode: %s", c_modeName[item.m_value].c_str() ); - } - } - } - } - - ClearStaticRequest( StaticRequest_Values ); - CreateVars( _instance ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the device's thermostat fan mode -//----------------------------------------------------------------------------- -bool ThermostatFanMode::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_List == _value.GetID().GetType() ) - { - ValueList const* value = static_cast(&_value); - uint8 state = (uint8)value->GetItem().m_value; - - Msg* msg = new Msg( "ThermostatFanModeCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatFanModeCmd_Set ); - msg->Append( state ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void ThermostatFanMode::CreateVars -( - uint8 const _instance -) -{ - if( m_supportedModes.empty() ) - { - return; - } - - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueList( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Fan Mode", "", false, false, 1, m_supportedModes, m_supportedModes[0].m_value, 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanMode.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanMode.h deleted file mode 100644 index f80c677..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanMode.h +++ /dev/null @@ -1,77 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatFanMode.h -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_FAN_MODE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ThermostatFanMode_H -#define _ThermostatFanMode_H - -#include -#include -#include "CommandClass.h" -#include "../value_classes/ValueList.h" - -namespace OpenZWave -{ - class ValueList; - - /** \brief Implements COMMAND_CLASS_THERMOSTAT_FAN_MODE (0x44), a Z-Wave device command class. - */ - class ThermostatFanMode: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatFanMode( _homeId, _nodeId ); } - virtual ~ThermostatFanMode(){} - - static uint8 const StaticGetCommandClassId(){ return 0x44; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_FAN_MODE"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _getTypeEnum, uint8 const _dummy, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - ThermostatFanMode( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){ SetStaticRequest( StaticRequest_Values ); } - - vector m_supportedModes; - }; - -} // namespace OpenZWave - -#endif - - - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanState.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanState.cpp deleted file mode 100644 index b54acf7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanState.cpp +++ /dev/null @@ -1,158 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatFanState.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_FAN_STATE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ThermostatFanState.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueString.h" - -using namespace OpenZWave; - -enum ThermostatFanStateCmd -{ - ThermostatFanStateCmd_Get = 0x02, - ThermostatFanStateCmd_Report = 0x03 -}; - -static char const* c_stateName[] = -{ - "Idle", - "Running", - "Running High", - "State 03", // Undefined states. May be used in the future. - "State 04", - "State 05", - "State 06", - "State 07", - "State 08", - "State 09", - "State 10", - "State 11", - "State 12", - "State 13", - "State 14", - "State 15", -}; - -//----------------------------------------------------------------------------- -// -// Get the static thermostat mode details from the device -//----------------------------------------------------------------------------- -bool ThermostatFanState::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - // Request the current state - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Get the thermostat fan state details from the device -//----------------------------------------------------------------------------- -bool ThermostatFanState::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - // Request the current state - Msg* msg = new Msg( "ThermostatFanStateCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatFanStateCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ThermostatFanStateCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ThermostatFanState::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ThermostatFanStateCmd_Report == (ThermostatFanStateCmd)_data[0] ) - { - // We have received the thermostat fan state from the Z-Wave device - if( ValueString* valueString = static_cast( GetValue( _instance, 0 ) ) ) - { - /* No need bounds checking as the state can only be a single byte - No larger than our Char array anyway */ - uint8 state = (_data[1]&0x0f); - - valueString->OnValueRefreshed( c_stateName[state] ); - valueString->Release(); - Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat fan state: %s", valueString->GetValue().c_str() ); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void ThermostatFanState::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueString( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Fan State", "", true, false, c_stateName[0], 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanState.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanState.h deleted file mode 100644 index 104f7d2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatFanState.h +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatFanState.h -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_FAN_STATE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ThermostatFanState_H -#define _ThermostatFanState_H - -#include -#include -#include "CommandClass.h" -#include "../value_classes/ValueList.h" - -namespace OpenZWave -{ - class ValueString; - - /** \brief Implements COMMAND_CLASS_THERMOSTAT_FAN_STATE (0x45), a Z-Wave device command class. - */ - class ThermostatFanState: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatFanState( _homeId, _nodeId ); } - virtual ~ThermostatFanState(){} - - static uint8 const StaticGetCommandClassId(){ return 0x45; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_FAN_STATE"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - ThermostatFanState( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatMode.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatMode.cpp deleted file mode 100644 index 02e1260..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatMode.cpp +++ /dev/null @@ -1,395 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatMode.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_MODE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ThermostatMode.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueList.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum ThermostatModeCmd -{ - ThermostatModeCmd_Set = 0x01, - ThermostatModeCmd_Get = 0x02, - ThermostatModeCmd_Report = 0x03, - ThermostatModeCmd_SupportedGet = 0x04, - ThermostatModeCmd_SupportedReport = 0x05 -}; - -static char const* c_modeName[] = -{ - "Off", - "Heat", - "Cool", - "Auto", - "Aux Heat", - "Resume", - "Fan Only", - "Furnace", - "Dry Air", - "Moist Air", - "Auto Changeover", - "Heat Econ", - "Cool Econ", - "Away", - "Unknown" -}; - -//----------------------------------------------------------------------------- -// -// Read the supported modes -//----------------------------------------------------------------------------- -void ThermostatMode::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - if( GetNodeUnsafe() ) - { - vector supportedModes; - - TiXmlElement const* supportedModesElement = _ccElement->FirstChildElement( "SupportedModes" ); - if( supportedModesElement ) - { - TiXmlElement const* modeElement = supportedModesElement->FirstChildElement(); - while( modeElement ) - { - char const* str = modeElement->Value(); - if( str && !strcmp( str, "Mode" ) ) - { - int index; - if( TIXML_SUCCESS == modeElement->QueryIntAttribute( "index", &index ) ) - { - if (index > 13) /* size of c_modeName minus Invalid */ - { - Log::Write (LogLevel_Warning, GetNodeId(), "index Value in XML was greater than range. Setting to Invalid"); - index = 14; - } - ValueList::Item item; - item.m_value = index; - item.m_label = c_modeName[index]; - supportedModes.push_back( item ); - } - } - - modeElement = modeElement->NextSiblingElement(); - } - } - - if( !supportedModes.empty() ) - { - m_supportedModes = supportedModes; - ClearStaticRequest( StaticRequest_Values ); - CreateVars( 1 ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Save the supported modes -//----------------------------------------------------------------------------- -void ThermostatMode::WriteXML -( - TiXmlElement* _ccElement -) -{ - if( m_supportedModes.empty() ) - { - return; - } - - CommandClass::WriteXML( _ccElement ); - - if( GetNodeUnsafe() ) - { - TiXmlElement* supportedModesElement = new TiXmlElement( "SupportedModes" ); - _ccElement->LinkEndChild( supportedModesElement ); - - for( vector::iterator it = m_supportedModes.begin(); it != m_supportedModes.end(); ++it ) - { - ValueList::Item const& item = *it; - - TiXmlElement* modeElement = new TiXmlElement( "Mode" ); - supportedModesElement->LinkEndChild( modeElement ); - - char str[8]; - snprintf( str, 8, "%d", item.m_value ); - modeElement->SetAttribute( "index", str ); - modeElement->SetAttribute( "label", item.m_label.c_str() ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Get the static thermostat mode details from the device -//----------------------------------------------------------------------------- -bool ThermostatMode::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - // request supported mode list - requests |= RequestValue( _requestFlags, ThermostatModeCmd_SupportedGet, _instance, _queue ); - } - - if( _requestFlags & RequestFlag_Dynamic ) - { - // Request the current mode - requests |= RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return requests; -} - -//----------------------------------------------------------------------------- -// -// Get the static thermostat mode details from the device -//----------------------------------------------------------------------------- -bool ThermostatMode::RequestValue -( - uint32 const _requestFlags, - uint8 const _getTypeEnum, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _getTypeEnum == ThermostatModeCmd_SupportedGet ) - { - // Request the supported modes - Msg* msg = new Msg( "ThermostatModeCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatModeCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - - if( _getTypeEnum == 0 ) // get current mode - { - if ( IsGetSupported() ) - { - // Request the current mode - Msg* msg = new Msg( "ThermostatModeCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatModeCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ThermostatModeCmd_Get Not Supported on this node"); - - } - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ThermostatMode::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ThermostatModeCmd_Report == (ThermostatModeCmd)_data[0] ) - { - uint8 mode = _data[1]&0x1f; - bool validMode = false; - for (vector::iterator it = m_supportedModes.begin(); it != m_supportedModes.end(); ++it ) - { - ValueList::Item const& item = *it; - - if (item.m_value == mode) { - validMode = true; - break; - } - } - - if( validMode ) - { - // We have received the thermostat mode from the Z-Wave device - if( ValueList* valueList = static_cast( GetValue( _instance, 0 ) ) ) - { - valueList->OnValueRefreshed( mode ); - Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat mode: %s", valueList->GetItem().m_label.c_str() ); - valueList->Release(); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat mode: index %d", mode ); - } - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received unknown thermostat mode: index %d", mode ); - } - return true; - } - - if( ThermostatModeCmd_SupportedReport == (ThermostatModeCmd)_data[0] ) - { - // We have received the supported thermostat modes from the Z-Wave device - // these values are used to populate m_supportedModes which, in turn, is used to "seed" the values - // for each m_modes instance - Log::Write( LogLevel_Info, GetNodeId(), "Received supported thermostat modes" ); - - m_supportedModes.clear(); - for( uint32 i=1; i<_length-1; ++i ) - { - for( int32 bit=0; bit<8; ++bit ) - { - if( ( _data[i] & (1<= (sizeof(c_modeName)/sizeof(*c_modeName) -1)) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received unknown thermostat mode: 0x%x", item.m_value); - } - else - { - item.m_label = c_modeName[item.m_value]; - m_supportedModes.push_back( item ); - - Log::Write( LogLevel_Info, GetNodeId(), " Added mode: %s", c_modeName[item.m_value] ); - } - } - } - } - - ClearStaticRequest( StaticRequest_Values ); - CreateVars( _instance ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the device's thermostat mode -//----------------------------------------------------------------------------- -bool ThermostatMode::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_List == _value.GetID().GetType() ) - { - ValueList const* value = static_cast(&_value); - uint8 state = (uint8)value->GetItem().m_value; - - Msg* msg = new Msg( "ThermostatModeCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatModeCmd_Set ); - msg->Append( state ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void ThermostatMode::CreateVars -( - uint8 const _instance -) -{ - // There are three ways to get here...each needs to be handled differently: - // QueryStage_ProtocolInfo: - // Don't know what's supported yet, so do nothing - // QueryStage_NodeInfo: - // Need to create the instance so the values can be read from the xml file - // QueryStage_Static: - // Need to create the instance (processing SupportedReport) if it doesn't exist - // If it does, populate with the appropriate values - - if( Node* node = GetNodeUnsafe() ) - { - Node::QueryStage qs = node->GetCurrentQueryStage(); - if( qs == Node::QueryStage_ProtocolInfo ) - { - // this call is from QueryStage_ProtocolInfo, - // so just return (don't know which modes are supported yet) - return; - } - - // identify the lowest supported mode as the "default" (or default to 0 if no supported modes identified yet) - int32 defaultValue = 0; - if( !m_supportedModes.empty() ) - { - defaultValue = m_supportedModes[0].m_value; - } - - if( qs == Node::QueryStage_Static ) - { - // This instance might already have been created (in NodeInfo, in preparation for loading the values - // from zwcfg xml file). So, if the instance already exists, we delete its value and add a new one below - if( ValueList* valueList = static_cast( GetValue( _instance, 0 ) ) ) - { - node->RemoveValueList( valueList ); - valueList->Release(); - } - } - - node->CreateValueList( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Mode", "", false, false, 1, m_supportedModes, defaultValue, 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatMode.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatMode.h deleted file mode 100644 index 1eccb19..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatMode.h +++ /dev/null @@ -1,76 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatMode.h -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_MODE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ThermostatMode_H -#define _ThermostatMode_H - -#include -#include -#include "CommandClass.h" -#include "../value_classes/ValueList.h" - -namespace OpenZWave -{ - class ValueList; - - /** \brief Implements COMMAND_CLASS_THERMOSTAT_MODE (0x40), a Z-Wave device command class. - */ - class ThermostatMode: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatMode( _homeId, _nodeId ); } - virtual ~ThermostatMode(){} - - static uint8 const StaticGetCommandClassId(){ return 0x40; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_MODE"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _getTypeEnum, uint8 const _dummy, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - ThermostatMode( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){ SetStaticRequest( StaticRequest_Values ); } - - vector m_supportedModes; - }; - -} // namespace OpenZWave - -#endif - - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatOperatingState.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatOperatingState.cpp deleted file mode 100644 index e1f5083..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatOperatingState.cpp +++ /dev/null @@ -1,154 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatOperatingState.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_OPERATING_STATE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ThermostatOperatingState.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueString.h" - -using namespace OpenZWave; - -enum ThermostatOperatingStateCmd -{ - ThermostatOperatingStateCmd_Get = 0x02, - ThermostatOperatingStateCmd_Report = 0x03 -}; - -static char const* c_stateName[] = -{ - "Idle", - "Heating", - "Cooling", - "Fan Only", - "Pending Heat", - "Pending Cool", - "Vent / Economizer", - "State 07", // Undefined states. May be used in the future. - "State 08", - "State 09", - "State 10", - "State 11", - "State 12", - "State 13", - "State 14", - "State 15" -}; - -//----------------------------------------------------------------------------- -// -// Get the static thermostat mode details from the device -//----------------------------------------------------------------------------- -bool ThermostatOperatingState::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _requestFlags & RequestFlag_Dynamic ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Get a thermostat mode value from the device -//----------------------------------------------------------------------------- -bool ThermostatOperatingState::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "ThermostatOperatingStateCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatOperatingStateCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "ThermostatOperatingStateCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ThermostatOperatingState::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ThermostatOperatingStateCmd_Report == (ThermostatOperatingStateCmd)_data[0] ) - { - // We have received the thermostat operating state from the Z-Wave device - if( ValueString* valueString = static_cast( GetValue( _instance, 0 ) ) ) - { - /* no need bounds checking on c_stateName here, as it can only be 1 Byte anyway */ - valueString->OnValueRefreshed( c_stateName[_data[1]&0x0f] ); - valueString->Release(); - Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat operating state: %s", valueString->GetValue().c_str() ); - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void ThermostatOperatingState::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueString( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Operating State", "", true, false, c_stateName[0], 0 ); - } -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatOperatingState.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatOperatingState.h deleted file mode 100644 index 3cb271a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatOperatingState.h +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatOperatingState.h -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_OPERATING_STATE -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ThermostatOperatingState_H -#define _ThermostatOperatingState_H - -#include -#include -#include "CommandClass.h" -#include "../value_classes/ValueList.h" - -namespace OpenZWave -{ - class ValueString; - - /** \brief Implements COMMAND_CLASS_THERMOSTAT_OPERATING_STATE (0x42), a Z-Wave device command class. - */ - class ThermostatOperatingState: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatOperatingState( _homeId, _nodeId ); } - virtual ~ThermostatOperatingState(){} - - static uint8 const StaticGetCommandClassId(){ return 0x42; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_OPERATING_STATE"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - ThermostatOperatingState( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){} - }; - -} // namespace OpenZWave - -#endif - - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatSetpoint.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatSetpoint.cpp deleted file mode 100644 index 5c47a7e..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatSetpoint.cpp +++ /dev/null @@ -1,323 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatSetpoint.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_SETPOINT -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "ThermostatSetpoint.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueDecimal.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum ThermostatSetpointCmd -{ - ThermostatSetpointCmd_Set = 0x01, - ThermostatSetpointCmd_Get = 0x02, - ThermostatSetpointCmd_Report = 0x03, - ThermostatSetpointCmd_SupportedGet = 0x04, - ThermostatSetpointCmd_SupportedReport = 0x05 -}; - -enum -{ - ThermostatSetpoint_Unused0 = 0, - ThermostatSetpoint_Heating1, - ThermostatSetpoint_Cooling1, - ThermostatSetpoint_Unused3, - ThermostatSetpoint_Unused4, - ThermostatSetpoint_Unused5, - ThermostatSetpoint_Unused6, - ThermostatSetpoint_Furnace, - ThermostatSetpoint_DryAir, - ThermostatSetpoint_MoistAir, - ThermostatSetpoint_AutoChangeover, - ThermostatSetpoint_HeatingEcon, - ThermostatSetpoint_CoolingEcon, - ThermostatSetpoint_AwayHeating, - ThermostatSetpoint_Count -}; - -static char const* c_setpointName[] = -{ - "Unused 0", - "Heating 1", - "Cooling 1", - "Unused 3", - "Unused 4", - "Unused 5", - "Unused 6", - "Furnace", - "Dry Air", - "Moist Air", - "Auto Changeover", - "Heating Econ", - "Cooling Econ", - "Away Heating" -}; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ThermostatSetpoint::ThermostatSetpoint -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), m_setPointBase( 1 ) -{ - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Read the saved change-counter value -//----------------------------------------------------------------------------- -void ThermostatSetpoint::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - int intVal; - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "base", &intVal ) ) - { - m_setPointBase = (uint8)intVal; - } -} - -//----------------------------------------------------------------------------- -// -// Write the change-counter value -//----------------------------------------------------------------------------- -void ThermostatSetpoint::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); - - char str[8]; - snprintf( str, 8, "%d", m_setPointBase ); - _ccElement->SetAttribute( "base", str ); -} - -//----------------------------------------------------------------------------- -// -// Get the static thermostat setpoint details from the device -//----------------------------------------------------------------------------- -bool ThermostatSetpoint::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - requests |= RequestValue( _requestFlags, 0xff, _instance, _queue ); - } - - if( _requestFlags & RequestFlag_Session ) - { - for( uint8 i=0; i -// Request current state from the device -//----------------------------------------------------------------------------- -bool ThermostatSetpoint::RequestValue -( - uint32 const _requestFlags, - uint8 const _setPointIndex, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _setPointIndex == 0xff ) // check for supportedget - { - // Request the supported setpoints - Msg* msg = new Msg( "ThermostatSetpointCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatSetpointCmd_SupportedGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - if ( !IsGetSupported() ) - { - Log::Write( LogLevel_Info, GetNodeId(), "ThermostatSetpointCmd_Get Not Supported on this node"); - return false; - } - Value* value = GetValue( 1, _setPointIndex ); - if( value != NULL ) - { - value->Release(); - // Request the setpoint value - Msg* msg = new Msg( "ThermostatSetpointCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatSetpointCmd_Get ); - msg->Append( _setPointIndex ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool ThermostatSetpoint::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( ThermostatSetpointCmd_Report == (ThermostatSetpointCmd)_data[0] ) - { - // We have received a thermostat setpoint value from the Z-Wave device - if( ValueDecimal* value = static_cast( GetValue( _instance, _data[1] ) ) ) - { - uint8 scale; - uint8 precision = 0; - string temperature = ExtractValue( &_data[2], &scale, &precision ); - - value->SetUnits( scale ? "F" : "C" ); - value->OnValueRefreshed( temperature ); - if( value->GetPrecision() != precision ) - { - value->SetPrecision( precision ); - } - value->Release(); - - Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat setpoint report: Setpoint %s = %s%s", value->GetLabel().c_str(), value->GetValue().c_str(), value->GetUnits().c_str() ); - } - return true; - } - - if( ThermostatSetpointCmd_SupportedReport == (ThermostatSetpointCmd)_data[0] ) - { - if( Node* node = GetNodeUnsafe() ) - { - // We have received the supported thermostat setpoints from the Z-Wave device - Log::Write( LogLevel_Info, GetNodeId(), "Received supported thermostat setpoints" ); - - // Parse the data for the supported setpoints - for( uint32 i=1; i<_length-1; ++i ) - { - for( int32 bit=0; bit<8; ++bit ) - { - if( ( _data[i] & (1<CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, index, c_setpointName[index], "C", false, false, "0.0", 0 ); - Log::Write( LogLevel_Info, GetNodeId(), " Added setpoint: %s", c_setpointName[index] ); - } - } - } - } - } - - ClearStaticRequest( StaticRequest_Values ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a thermostat setpoint temperature -//----------------------------------------------------------------------------- -bool ThermostatSetpoint::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_Decimal == _value.GetID().GetType() ) - { - ValueDecimal const* value = static_cast(&_value); - uint8 scale = strcmp( "C", value->GetUnits().c_str() ) ? 1 : 0; - - Msg* msg = new Msg( "Set Thermostat Setpoint", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 4 + GetAppendValueSize( value->GetValue() ) ); - msg->Append( GetCommandClassId() ); - msg->Append( ThermostatSetpointCmd_Set ); - msg->Append( value->GetID().GetIndex() ); - AppendValue( msg, value->GetValue(), scale ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void ThermostatSetpoint::CreateVars -( - uint8 const _instance, - uint8 const _index -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, _index, "Setpoint", "C", false, false, "0.0", 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatSetpoint.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatSetpoint.h deleted file mode 100644 index 9249186..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/ThermostatSetpoint.h +++ /dev/null @@ -1,73 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThermostatSetpoint.h -// -// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_SETPOINT -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ThermostatSetpoint_H -#define _ThermostatSetpoint_H - -#include -#include -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueDecimal; - - /** \brief Implements COMMAND_CLASS_THERMOSTAT_SETPOINT (0x43), a Z-Wave device command class. - */ - class ThermostatSetpoint: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatSetpoint( _homeId, _nodeId ); } - virtual ~ThermostatSetpoint(){} - - static uint8 const StaticGetCommandClassId(){ return 0x43; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_SETPOINT"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _setPointIndex, uint8 const _dummy, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - public: - virtual void CreateVars( uint8 const _instance, uint8 const _index ); - - private: - ThermostatSetpoint( uint32 const _homeId, uint8 const _nodeId ); - uint8 m_setPointBase; - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/TimeParameters.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/TimeParameters.cpp deleted file mode 100644 index eae70cc..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/TimeParameters.cpp +++ /dev/null @@ -1,236 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeParameters.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_TIME_PARAMETERS -// -// Copyright (c) 2014 Justin Hammond -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include "CommandClasses.h" -#include "TimeParameters.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Node.h" -#include "../Driver.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueButton.h" -#include "../value_classes/ValueString.h" - -using namespace OpenZWave; - -enum TimeParametersCmd -{ - TimeParametersCmd_Set = 0x01, - TimeParametersCmd_Get = 0x02, - TimeParametersCmd_Report = 0x03 -}; - -enum -{ - TimeParametersIndex_Date = 0, - TimeParametersIndex_Time, - TimeParametersIndex_Set, - TimeParametersIndex_Refresh -}; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -TimeParameters::TimeParameters -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ) -{ - SetStaticRequest( StaticRequest_Values ); -} - - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool TimeParameters::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool TimeParameters::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 (not used) - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "TimeParametersCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, _instance ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( TimeParametersCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "TimeParametersCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool TimeParameters::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if (TimeParametersCmd_Report == (TimeParametersCmd)_data[0]) - { - uint16 year = (_data[1] << 8) + (_data[2] & 0xFF); - uint8 month = (_data[3] & 0x0F); - uint8 day = (_data[4] & 0x1F); - uint8 hour = (_data[5] & 0x1F); - uint8 minute = (_data[6] & 0x3F); - uint8 second = (_data[7] & 0x3F); - - Log::Write( LogLevel_Info, GetNodeId(), "Received TimeParameters report: %02d/%02d/%04d %02d:%02d:%02d", (int)day, (int)month, (int)year, (int)hour, (int)minute, (int)second); - if( ValueString* value = static_cast( GetValue( _instance, TimeParametersIndex_Date ) ) ) - { - char msg[512]; - snprintf(msg, sizeof(msg), "%02d/%02d/%04d", (int)day, (int)month, (int)year); - value->OnValueRefreshed( msg ); - value->Release(); - } - if( ValueString* value = static_cast( GetValue( _instance, TimeParametersIndex_Time ) ) ) - { - char msg[512]; - snprintf(msg, sizeof(msg), "%02d:%02d:%02d", (int)hour, (int)minute, (int)second); - value->OnValueRefreshed( msg ); - value->Release(); - } - ClearStaticRequest( StaticRequest_Values ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a value in the Z-Wave device -//----------------------------------------------------------------------------- -bool TimeParameters::SetValue -( - Value const& _value -) -{ - bool ret = false; - - uint8 instance = _value.GetID().GetInstance(); - - if ( (ValueID::ValueType_Button == _value.GetID().GetType()) && (_value.GetID().GetIndex() == TimeParametersIndex_Set) ) - { - time_t rawtime; - struct tm *timeinfo; - time(&rawtime); - timeinfo = localtime(&rawtime); - Msg* msg = new Msg( "TimeParametersCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->SetInstance( this, instance ); - msg->Append( GetNodeId() ); - msg->Append( 9 ); - msg->Append( GetCommandClassId() ); - msg->Append( TimeParametersCmd_Set ); - /* Year 1 */ - msg->Append( ((timeinfo->tm_year + 1900)>> 8) & 0xFF); - /* Year 2 */ - msg->Append( ((timeinfo->tm_year + 1900) & 0xFF)); - /* Month */ - msg->Append( (timeinfo->tm_mon & 0x0F)+1); - /* Day */ - msg->Append( (timeinfo->tm_mday & 0x1F)); - /* Hour */ - msg->Append( (timeinfo->tm_hour & 0x1F)); - /* Minute */ - msg->Append( (timeinfo->tm_min & 0x3F)); - /* Second */ - msg->Append( (timeinfo->tm_sec & 0x3F)); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - - - /* Refresh after we send updated date/time */ - SetStaticRequest( StaticRequest_Values ); - ret = RequestValue( RequestFlag_Static, 0, instance, Driver::MsgQueue_Query ); - } - if ( (ValueID::ValueType_Button == _value.GetID().GetType()) && (_value.GetID().GetIndex() == TimeParametersIndex_Refresh) ) - { - SetStaticRequest( StaticRequest_Values ); - ret = RequestValue( RequestFlag_Static, 0, instance, Driver::MsgQueue_Query ); - } - - return ret; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void TimeParameters::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, TimeParametersIndex_Date, "Date", "", true, false, "", 0 ); - node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, TimeParametersIndex_Time, "Time", "", true, false, "", 0 ); - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, TimeParametersIndex_Set, "Set Date/Time", 0); - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, TimeParametersIndex_Refresh, "Refresh Date/Time", 0); - - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/TimeParameters.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/TimeParameters.h deleted file mode 100644 index 51d10a0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/TimeParameters.h +++ /dev/null @@ -1,67 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeParameters.h -// -// Implementation of the Z-Wave COMMAND_CLASS_TIME_PARAMETERS -// -// Copyright (c) 2014 Justin Hammond -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _TimeParameters_H -#define _TimeParameters_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueByte; - class ValueList; - - /** \brief Implements COMMAND_CLASS_TIME_PARAMETERS (0x8B), a Z-Wave device command class. - */ - class TimeParameters: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new TimeParameters( _homeId, _nodeId ); } - virtual ~TimeParameters(){} - - static uint8 const StaticGetCommandClassId(){ return 0x8B; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_TIME_PARAMETERS"; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - TimeParameters( uint32 const _homeId, uint8 const _nodeId ); - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/UserCode.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/UserCode.cpp deleted file mode 100644 index 4409282..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/UserCode.cpp +++ /dev/null @@ -1,355 +0,0 @@ -//----------------------------------------------------------------------------- -// -// UserCode.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_USER_CODE -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "CommandClasses.h" -#include "UserCode.h" -#include "../Node.h" -#include "../Options.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueByte.h" -#include "../value_classes/ValueRaw.h" - -using namespace OpenZWave; - -enum UserCodeCmd -{ - UserCodeCmd_Set = 0x01, - UserCodeCmd_Get = 0x02, - UserCodeCmd_Report = 0x03, - UserNumberCmd_Get = 0x04, - UserNumberCmd_Report = 0x05 -}; - -enum -{ - UserCodeIndex_Refresh = 254, - UserCodeIndex_Count = 255 -}; - -const uint8 UserCodeLength = 10; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -UserCode::UserCode -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_queryAll( false ), - m_currentCode( 0 ), - m_userCodeCount( 0 ), - m_refreshUserCodes(false) -{ - SetStaticRequest( StaticRequest_Values ); - memset( m_userCodesStatus, 0xff, sizeof(m_userCodesStatus) ); - Options::Get()->GetOptionAsBool("RefreshAllUserCodes", &m_refreshUserCodes ); - -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void UserCode::ReadXML -( - TiXmlElement const* _ccElement -) -{ - int32 intVal; - - CommandClass::ReadXML( _ccElement ); - if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "codes", &intVal ) ) - { - m_userCodeCount = intVal; - } -} - -//----------------------------------------------------------------------------- -// -// Class specific configuration -//----------------------------------------------------------------------------- -void UserCode::WriteXML -( - TiXmlElement* _ccElement -) -{ - char str[32]; - - CommandClass::WriteXML( _ccElement ); - snprintf( str, sizeof(str), "%d", m_userCodeCount ); - _ccElement->SetAttribute( "codes", str); -} - -//----------------------------------------------------------------------------- -// -// Nothing to do for UserCode -//----------------------------------------------------------------------------- -bool UserCode::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - requests |= RequestValue( _requestFlags, UserCodeIndex_Count, _instance, _queue ); - } - - if( _requestFlags & RequestFlag_Session ) - { - if( m_userCodeCount > 0 ) - { - m_queryAll = true; - m_currentCode = 1; - requests |= RequestValue( _requestFlags, m_currentCode, _instance, _queue ); - } - } - - return requests; -} - -//----------------------------------------------------------------------------- -// -// Nothing to do for UserCode -//----------------------------------------------------------------------------- -bool UserCode::RequestValue -( - uint32 const _requestFlags, - uint8 const _userCodeIdx, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - if ( !IsGetSupported() ) - { - Log::Write( LogLevel_Info, GetNodeId(), "UserNumberCmd_Get Not Supported on this node"); - return false; - } - if( _userCodeIdx == UserCodeIndex_Count ) - { - // Get number of supported user codes. - Msg* msg = new Msg( "UserNumberCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( UserNumberCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - if (_userCodeIdx == 0) - { - Log::Write( LogLevel_Warning, GetNodeId(), "UserCodeCmd_Get with Index 0 not Supported"); - return false; - } - Msg* msg = new Msg( "UserCodeCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( UserCodeCmd_Get ); - msg->Append( _userCodeIdx ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool UserCode::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( UserNumberCmd_Report == (UserCodeCmd)_data[0] ) - { - m_userCodeCount = _data[1]; - if( m_userCodeCount > 254 ) - { - // Make space for code count. - m_userCodeCount = 254; - } - ClearStaticRequest( StaticRequest_Values ); - if( m_userCodeCount == 0 ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received User Number report from node %d: Not supported", GetNodeId() ); - } - else - { - Log::Write( LogLevel_Info, GetNodeId(), "Received User Number report from node %d: Supported Codes %d (%d)", GetNodeId(), m_userCodeCount, _data[1] ); - } - - if( ValueByte* value = static_cast( GetValue( _instance, UserCodeIndex_Count ) ) ) - { - value->OnValueRefreshed( m_userCodeCount ); - value->Release(); - } - - if( Node* node = GetNodeUnsafe() ) - { - uint8 data[UserCodeLength]; - - memset( data, 0, UserCodeLength ); - for( uint8 i = 0; i <= m_userCodeCount; i++ ) - { - char str[16]; - if (i == 0) - { - snprintf( str, sizeof(str), "Enrollment Code"); - node->CreateValueRaw( ValueID::ValueGenre_User, GetCommandClassId(), _instance, i, str, "", true, false, data, UserCodeLength, 0 ); - } - else - { - snprintf( str, sizeof(str), "Code %d:", i); - node->CreateValueRaw( ValueID::ValueGenre_User, GetCommandClassId(), _instance, i, str, "", false, false, data, UserCodeLength, 0 ); - } - } - } - return true; - } - else if( UserCodeCmd_Report == (UserCodeCmd)_data[0] ) - { - int i = _data[1]; - if( ValueRaw* value = static_cast( GetValue( _instance, i ) ) ) - { - uint8 data[UserCodeLength]; - uint8 size = _length - 4; - if( size > UserCodeLength ) - { - Log::Write( LogLevel_Warning, GetNodeId(), "User Code length %d is larger then maximum %d", size, UserCodeLength ); - size = UserCodeLength; - } - m_userCodesStatus[i] = _data[2]; - memcpy( data, &_data[3], size ); - value->OnValueRefreshed( data, size ); - value->Release(); - } - Log::Write( LogLevel_Info, GetNodeId(), "Received User Code Report from node %d for User Code %d (%s)", GetNodeId(), i, CodeStatus( _data[2] ).c_str() ); - if( m_queryAll && i == m_currentCode ) - { - - if (m_refreshUserCodes && (_data[2] != UserCode_Available)) { - if( ++i <= m_userCodeCount ) - { - m_currentCode = i; - RequestValue( 0, m_currentCode, _instance, Driver::MsgQueue_Query ); - } - else - { - m_queryAll = false; - /* we might have reset this as part of the RefreshValues Button Value */ - Options::Get()->GetOptionAsBool("RefreshAllUserCodes", &m_refreshUserCodes ); - } - } else { - Log::Write( LogLevel_Info, GetNodeId(), "Not Requesting additional UserCode Slots as RefreshAllUserCodes is false, and slot %d is available", i); - m_queryAll = false; - } - } - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set a User Code value -//----------------------------------------------------------------------------- -bool UserCode::SetValue -( - Value const& _value -) -{ - if( (ValueID::ValueType_Raw == _value.GetID().GetType()) && (_value.GetID().GetIndex() < UserCodeIndex_Refresh) ) - { - ValueRaw const* value = static_cast(&_value); - uint8* s = value->GetValue(); - uint8 len = value->GetLength(); - - if( len > UserCodeLength ) - { - return false; - } - m_userCodesStatus[value->GetID().GetIndex()] = UserCode_Occupied; - Msg* msg = new Msg( "UserCodeCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->SetInstance( this, _value.GetID().GetInstance() ); - msg->Append( GetNodeId() ); - msg->Append( 4 + len ); - msg->Append( GetCommandClassId() ); - msg->Append( UserCodeCmd_Set ); - msg->Append( value->GetID().GetIndex() ); - msg->Append( UserCode_Occupied ); - for( uint8 i = 0; i < len; i++ ) - { - msg->Append( s[i] ); - } - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - if ( (ValueID::ValueType_Button == _value.GetID().GetType()) && (_value.GetID().GetIndex() == UserCodeIndex_Refresh) ) - { - m_refreshUserCodes = true; - m_currentCode = 1; - m_queryAll = true; - RequestValue( 0, m_currentCode, _value.GetID().GetInstance(), Driver::MsgQueue_Query ); - return true; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void UserCode::CreateVars -( - uint8 const _instance - -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, UserCodeIndex_Count, "Code Count", "", true, false, 0, 0 ); - node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, UserCodeIndex_Refresh, "Refresh All UserCodes", 0); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/UserCode.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/UserCode.h deleted file mode 100644 index 2665ee2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/UserCode.h +++ /dev/null @@ -1,113 +0,0 @@ -//----------------------------------------------------------------------------- -// -// UserCode.h -// -// Implementation of the Z-Wave COMMAND_CLASS_USER_CODE -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _UserCode_H -#define _UserCode_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - /** \brief Implements COMMAND_CLASS_USER_CODE (0x63), a Z-Wave device command class. - */ - class UserCode: public CommandClass - { - public: - enum UserCodeStatus - { - UserCode_Available = 0x00, - UserCode_Occupied = 0x01, - UserCode_Reserved = 0x02, - UserCode_NotAvailable = 0xfe, - UserCode_Unset = 0xff - }; - - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new UserCode( _homeId, _nodeId ); } - virtual ~UserCode(){} - - static uint8 const StaticGetCommandClassId(){ return 0x63; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_USER_CODE"; } - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - UserCode( uint32 const _homeId, uint8 const _nodeId ); - - string CodeStatus( uint8 const _byte ) - { - switch( _byte ) - { - case UserCode_Available: - { - return "Available"; - } - case UserCode_Occupied: - { - return "Occupied"; - } - case UserCode_Reserved: - { - return "Reserved"; - } - case UserCode_NotAvailable: - { - return "Not Available"; - } - case UserCode_Unset: - { - return "Unset"; - } - default: - { - return "Unknown"; - } - } - } - - bool m_queryAll; // True while we are requesting all the user codes. - uint8 m_currentCode; - uint8 m_userCodeCount; - uint8 m_userCodesStatus[256]; - bool m_refreshUserCodes; - }; - -} // namespace OpenZWave - -#endif - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Version.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Version.cpp deleted file mode 100644 index 1d13dad..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Version.cpp +++ /dev/null @@ -1,263 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Version.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_VERSION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "Version.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -#include "../value_classes/ValueString.h" - -#include "../tinyxml.h" - -using namespace OpenZWave; - -enum VersionCmd -{ - VersionCmd_Get = 0x11, - VersionCmd_Report = 0x12, - VersionCmd_CommandClassGet = 0x13, - VersionCmd_CommandClassReport = 0x14 -}; - -enum -{ - VersionIndex_Library = 0, - VersionIndex_Protocol, - VersionIndex_Application -}; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Version::Version -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_classGetSupported( true ) -{ - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Read configuration. -//----------------------------------------------------------------------------- -void Version::ReadXML -( - TiXmlElement const* _ccElement -) -{ - CommandClass::ReadXML( _ccElement ); - - char const* str = _ccElement->Attribute("classgetsupported"); - if( str ) - { - m_classGetSupported = !strcmp( str, "true"); - } -} - -//----------------------------------------------------------------------------- -// -// Save changed configuration -//----------------------------------------------------------------------------- -void Version::WriteXML -( - TiXmlElement* _ccElement -) -{ - CommandClass::WriteXML( _ccElement ); - - if( !m_classGetSupported ) - { - _ccElement->SetAttribute( "classgetsupported", "false" ); - } -} - -//----------------------------------------------------------------------------- -// -// Request current state from the device -//----------------------------------------------------------------------------- -bool Version::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - return RequestValue( _requestFlags, 0, _instance, _queue ); - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request current value from the device -//----------------------------------------------------------------------------- -bool Version::RequestValue -( - uint32 const _requestFlags, - uint8 const _dummy1, // = 0 - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - if ( IsGetSupported() ) - { - Msg* msg = new Msg( "VersionCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( VersionCmd_Get ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } else { - Log::Write( LogLevel_Info, GetNodeId(), "VersionCmd_Get Not Supported on this node"); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool Version::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( Node* node = GetNodeUnsafe() ) - { - if( VersionCmd_Report == (VersionCmd)_data[0] ) - { - char library[8]; - char protocol[16]; - char application[16]; - - snprintf( library, sizeof(library), "%d", _data[1] ); - snprintf( protocol, sizeof(protocol), "%d.%.2d", _data[2], _data[3] ); - snprintf( application, sizeof(application), "%d.%.2d", _data[4], _data[5] ); - - Log::Write( LogLevel_Info, GetNodeId(), "Received Version report from node %d: Library=%s, Protocol=%s, Application=%s", GetNodeId(), library, protocol, application ); - ClearStaticRequest( StaticRequest_Values ); - - if( ValueString* libraryValue = static_cast( GetValue( _instance, VersionIndex_Library ) ) ) - { - libraryValue->OnValueRefreshed( library ); - libraryValue->Release(); - } - if( ValueString* protocolValue = static_cast( GetValue( _instance, VersionIndex_Protocol ) ) ) - { - protocolValue->OnValueRefreshed( protocol ); - protocolValue->Release(); - } - if( ValueString* applicationValue = static_cast( GetValue( _instance, VersionIndex_Application ) ) ) - { - applicationValue->OnValueRefreshed( application ); - applicationValue->Release(); - } - - return true; - } - - if (VersionCmd_CommandClassReport == (VersionCmd)_data[0]) - { - if( CommandClass* pCommandClass = node->GetCommandClass( _data[1] ) ) - { - Log::Write( LogLevel_Info, GetNodeId(), "Received Command Class Version report from node %d: CommandClass=%s, Version=%d", GetNodeId(), pCommandClass->GetCommandClassName().c_str(), _data[2] ); - pCommandClass->ClearStaticRequest( StaticRequest_Version ); - pCommandClass->SetVersion( _data[2] ); - } - - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Request the version of a command class used by the device -//----------------------------------------------------------------------------- -bool Version::RequestCommandClassVersion -( - CommandClass const* _commandClass -) -{ - if( m_classGetSupported ) - { - if( _commandClass->HasStaticRequest( StaticRequest_Version ) ) - { - Msg* msg = new Msg( "VersionCmd_CommandClassGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 3 ); - msg->Append( GetCommandClassId() ); - msg->Append( VersionCmd_CommandClassGet ); - msg->Append( _commandClass->GetCommandClassId() ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void Version::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, VersionIndex_Library, "Library Version", "", true, false, "Unknown", 0 ); - node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, VersionIndex_Protocol, "Protocol Version", "", true, false, "Unknown", 0 ); - node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, VersionIndex_Application, "Application Version", "", true, false, "Unknown", 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Version.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/Version.h deleted file mode 100644 index 13718e5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/Version.h +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Version.h -// -// Implementation of the Z-Wave COMMAND_CLASS_VERSION -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Version_H -#define _Version_H - -#include "CommandClass.h" - -namespace OpenZWave -{ - class ValueString; - - /** \brief Implements COMMAND_CLASS_VERSION (0x86), a Z-Wave device command class. - */ - class Version: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Version( _homeId, _nodeId ); } - virtual ~Version(){} - - static uint8 const StaticGetCommandClassId(){ return 0x86; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_VERSION"; } - - bool RequestCommandClassVersion( CommandClass const* _commandClass ); - - // From CommandClass - virtual void ReadXML( TiXmlElement const* _ccElement ); - virtual void WriteXML( TiXmlElement* _ccElement ); - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - Version( uint32 const _homeId, uint8 const _nodeId ); - - bool m_classGetSupported; - }; - -} // namespace OpenZWave - -#endif - diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/WakeUp.cpp b/lib/ESPiLight/pilight/libs/openzwave/command_classes/WakeUp.cpp deleted file mode 100644 index 4251956..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/WakeUp.cpp +++ /dev/null @@ -1,502 +0,0 @@ -//----------------------------------------------------------------------------- -// -// WakeUp.cpp -// -// Implementation of the Z-Wave COMMAND_CLASS_WAKE_UP -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "CommandClasses.h" -#include "WakeUp.h" -#include "MultiCmd.h" -#include "../Defs.h" -#include "../Msg.h" -#include "../Driver.h" -#include "../Node.h" -#include "../Notification.h" -#include "../Options.h" -#include "../platform/Log.h" -#include "../platform/Mutex.h" -#include "../value_classes/ValueInt.h" - -using namespace OpenZWave; - -enum WakeUpCmd -{ - WakeUpCmd_IntervalSet = 0x04, - WakeUpCmd_IntervalGet = 0x05, - WakeUpCmd_IntervalReport = 0x06, - WakeUpCmd_Notification = 0x07, - WakeUpCmd_NoMoreInformation = 0x08, - WakeUpCmd_IntervalCapabilitiesGet = 0x09, - WakeUpCmd_IntervalCapabilitiesReport = 0x0A -}; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -WakeUp::WakeUp -( - uint32 const _homeId, - uint8 const _nodeId -): - CommandClass( _homeId, _nodeId ), - m_mutex( new Mutex() ), - m_pollRequired( false ), - m_notification( false ) -{ - m_awake = true; - Options::Get()->GetOptionAsBool("AssumeAwake", &m_awake); - - SetStaticRequest( StaticRequest_Values ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -WakeUp::~WakeUp -( -) -{ - m_mutex->Release(); - while( !m_pendingQueue.empty() ) - { - Driver::MsgQueueItem const& item = m_pendingQueue.front(); - if( Driver::MsgQueueCmd_SendMsg == item.m_command ) - { - delete item.m_msg; - } - else if( Driver::MsgQueueCmd_Controller == item.m_command ) - { - delete item.m_cci; - } - m_pendingQueue.pop_front(); - } -} - -//----------------------------------------------------------------------------- -// -// Starts the process of requesting node state from a sleeping device -//----------------------------------------------------------------------------- -void WakeUp::Init -( -) -{ - // Request the wake up interval. When we receive the response, we - // can send a set interval message with the same interval, but with - // the target node id set to that of the controller. This will ensure - // that the controller will receive the wake-up notifications from - // the device. Once this is done, we can request the rest of the node - // state. - RequestState( CommandClass::RequestFlag_Session, 1, Driver::MsgQueue_WakeUp ); -} - -//----------------------------------------------------------------------------- -// -// Nothing to do for wakeup -//----------------------------------------------------------------------------- -bool WakeUp::RequestState -( - uint32 const _requestFlags, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - bool requests = false; - if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) ) - { - if( GetVersion() > 1 ) - { - requests |= RequestValue( _requestFlags, WakeUpCmd_IntervalCapabilitiesGet, _instance, _queue ); - } - } - if( _requestFlags & RequestFlag_Session ) - { - Node* node = GetNodeUnsafe(); - if( node != NULL && !node->IsController() ) - { - requests |= RequestValue( _requestFlags, 0, _instance, _queue ); - } - } - - return requests; -} - -//----------------------------------------------------------------------------- -// -// Nothing to do for wakeup -//----------------------------------------------------------------------------- -bool WakeUp::RequestValue -( - uint32 const _requestFlags, - uint8 const _getTypeEnum, - uint8 const _instance, - Driver::MsgQueue const _queue -) -{ - if( _instance != 1 ) - { - // This command class doesn't work with multiple instances - return false; - } - - if( _getTypeEnum == WakeUpCmd_IntervalCapabilitiesGet ) - { - Msg* msg = new Msg( "WakeUpCmd_IntervalCapabilityGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( WakeUpCmd_IntervalCapabilitiesGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - } - - - if( _getTypeEnum == 0 ) - { - // We won't get a response until the device next wakes up - Msg* msg = new Msg( "WakeUpCmd_IntervalGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( WakeUpCmd_IntervalGet ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, _queue ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Handle a message from the Z-Wave network -//----------------------------------------------------------------------------- -bool WakeUp::HandleMsg -( - uint8 const* _data, - uint32 const _length, - uint32 const _instance // = 1 -) -{ - if( WakeUpCmd_IntervalReport == (WakeUpCmd)_data[0] ) - { - if( ValueInt* value = static_cast( GetValue( _instance, 0 ) ) ) - { - // some interval reports received are validly formatted (proper checksum, etc.) but only have length - // of 3 (0x84 (classid), 0x06 (IntervalReport), 0x00). Not sure what this means - if( _length < 6 ) - { - Log::Write( LogLevel_Warning, "" ); - Log::Write( LogLevel_Warning, GetNodeId(), "Unusual response: WakeUpCmd_IntervalReport with len = %d. Ignored.", _length ); - value->Release(); - return false; - } - - uint32 interval = ((uint32)_data[1]) << 16; - interval |= (((uint32)_data[2]) << 8); - interval |= (uint32)_data[3]; - - uint8 targetNodeId = _data[4]; - - Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Interval report from node %d: Interval=%d, Target Node=%d", GetNodeId(), interval, targetNodeId ); - - value->OnValueRefreshed( (int32)interval ); - - // Ensure that the target node for wake-up notifications is the controller - // but only if node is not a listening device. Hybrid devices that can be - // powered by other then batteries shouldn't do this. - Node *node = GetNodeUnsafe(); - if( GetDriver()->GetNodeId() != targetNodeId && ((node) && (!node->IsListeningDevice())) ) - { - SetValue( *value ); - } - value->Release(); - } - return true; - } - else if( WakeUpCmd_Notification == (WakeUpCmd)_data[0] ) - { - // The device is awake. - Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Notification from node %d", GetNodeId() ); - m_notification = true; - SetAwake( true ); - return true; - } - else if( WakeUpCmd_IntervalCapabilitiesReport == (WakeUpCmd)_data[0] ) - { - uint32 mininterval = (((uint32)_data[1]) << 16) | (((uint32)_data[2]) << 8) | ((uint32)_data[3]); - uint32 maxinterval = (((uint32)_data[4]) << 16) | (((uint32)_data[5]) << 8) | ((uint32)_data[6]); - uint32 definterval = (((uint32)_data[7]) << 16) | (((uint32)_data[8]) << 8) | ((uint32)_data[9]); - uint32 stepinterval = (((uint32)_data[10]) << 16) | (((uint32)_data[11]) << 8) | ((uint32)_data[12]); - Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Interval Capability report from node %d: Min Interval=%d, Max Interval=%d, Default Interval=%d, Interval Step=%d", GetNodeId(), mininterval, maxinterval, definterval, stepinterval ); - if( ValueInt* value = static_cast( GetValue( _instance, 1 ) ) ) - { - value->OnValueRefreshed( (int32)mininterval ); - value->Release(); - } - if( ValueInt* value = static_cast( GetValue( _instance, 2 ) ) ) - { - value->OnValueRefreshed( (int32)maxinterval ); - value->Release(); - } - if( ValueInt* value = static_cast( GetValue( _instance, 3 ) ) ) - { - value->OnValueRefreshed( (int32)definterval ); - value->Release(); - } - if( ValueInt* value = static_cast( GetValue( _instance, 4 ) ) ) - { - value->OnValueRefreshed( (int32)stepinterval ); - value->Release(); - } - ClearStaticRequest( StaticRequest_Values ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the device's wakeup interval -//----------------------------------------------------------------------------- -bool WakeUp::SetValue -( - Value const& _value -) -{ - if( ValueID::ValueType_Int == _value.GetID().GetType() ) - { - ValueInt const* value = static_cast(&_value); - - Msg* msg = new Msg( "Wakeup Interval Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - - if( GetNodeUnsafe()->GetCommandClass( MultiCmd::StaticGetCommandClassId() ) ) - { - msg->Append( 10 ); - msg->Append( MultiCmd::StaticGetCommandClassId() ); - msg->Append( MultiCmd::MultiCmdCmd_Encap ); - msg->Append( 1 ); - } - - int32 interval = value->GetValue(); - - msg->Append( 6 ); // length of command bytes following - msg->Append( GetCommandClassId() ); - msg->Append( WakeUpCmd_IntervalSet ); - msg->Append( (uint8)(( interval >> 16 ) & 0xff) ); - msg->Append( (uint8)(( interval >> 8 ) & 0xff) ); - msg->Append( (uint8)( interval & 0xff ) ); - msg->Append( GetDriver()->GetNodeId() ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_WakeUp ); - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Set the command class version -//----------------------------------------------------------------------------- -void WakeUp::SetVersion -( - uint8 const _version -) -{ - CommandClass::SetVersion( _version ); - CreateVars( 1 ); -} - -//----------------------------------------------------------------------------- -// -// Set whether the device is likely to be awake -//----------------------------------------------------------------------------- -void WakeUp::SetAwake -( - bool _state -) -{ - if( m_awake != _state ) - { - m_awake = _state; - Log::Write( LogLevel_Info, GetNodeId(), " Node %d has been marked as %s", GetNodeId(), m_awake ? "awake" : "asleep" ); - Notification* notification = new Notification( Notification::Type_Notification ); - notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() ); - notification->SetNotification( m_awake ? Notification::Code_Awake : Notification::Code_Sleep ); - GetDriver()->QueueNotification( notification ); - - } - - if( m_awake ) - { - // If the device is marked for polling, request the current state - Node* node = GetNodeUnsafe(); - if( m_pollRequired ) - { - if( node != NULL ) - { - node->SetQueryStage( Node::QueryStage_Dynamic ); - } - m_pollRequired = false; - } - - // Send all pending messages - SendPending(); - } -} - -//----------------------------------------------------------------------------- -// -// Add a Z-Wave message to the queue -//----------------------------------------------------------------------------- -void WakeUp::QueueMsg -( - Driver::MsgQueueItem const& _item -) -{ - m_mutex->Lock(); - - // See if there is already a copy of this message in the queue. If so, - // we delete it. This is to prevent duplicates building up if the - // device does not wake up very often. Deleting the original and - // adding the copy to the end avoids problems with the order of - // commands such as on and off. - list::iterator it = m_pendingQueue.begin(); - while( it != m_pendingQueue.end() ) - { - Driver::MsgQueueItem const& item = *it; - if( item == _item ) - { - // Duplicate found - if( Driver::MsgQueueCmd_SendMsg == item.m_command ) - { - delete item.m_msg; - } - else if( Driver::MsgQueueCmd_Controller == item.m_command ) - { - delete item.m_cci; - } - m_pendingQueue.erase( it++ ); - } - else - { - ++it; - } - } - m_pendingQueue.push_back( _item ); - m_mutex->Unlock(); -} - -//----------------------------------------------------------------------------- -// -// The device is awake, so send all the pending messages -//----------------------------------------------------------------------------- -void WakeUp::SendPending -( -) -{ - m_awake = true; - - m_mutex->Lock(); - list::iterator it = m_pendingQueue.begin(); - while( it != m_pendingQueue.end() ) - { - Driver::MsgQueueItem const& item = *it; - if( Driver::MsgQueueCmd_SendMsg == item.m_command ) - { - GetDriver()->SendMsg( item.m_msg, Driver::MsgQueue_WakeUp ); - } - else if( Driver::MsgQueueCmd_QueryStageComplete == item.m_command ) - { - GetDriver()->SendQueryStageComplete( item.m_nodeId, item.m_queryStage ); - } else if( Driver::MsgQueueCmd_Controller == item.m_command ) - { - GetDriver()->BeginControllerCommand( item.m_cci->m_controllerCommand, item.m_cci->m_controllerCallback, item.m_cci->m_controllerCallbackContext, item.m_cci->m_highPower, item.m_cci->m_controllerCommandNode, item.m_cci->m_controllerCommandArg ); - delete item.m_cci; - } - it = m_pendingQueue.erase( it ); - } - m_mutex->Unlock(); - - // Send the device back to sleep, unless we have outstanding queries. - bool sendToSleep = m_notification; - Node* node = GetNodeUnsafe(); - if( node != NULL ) - { - if( !node->AllQueriesCompleted() ) - { - sendToSleep = false; - } - } - - if( sendToSleep ) - { - m_notification = false; - Msg* msg = new Msg( "Wakeup - No More Information (send to sleep)", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); - msg->Append( GetNodeId() ); - msg->Append( 2 ); - msg->Append( GetCommandClassId() ); - msg->Append( WakeUpCmd_NoMoreInformation ); - msg->Append( GetDriver()->GetTransmitOptions() ); - GetDriver()->SendMsg( msg, Driver::MsgQueue_WakeUp ); - } -} - -//----------------------------------------------------------------------------- -// -// Create the values managed by this command class -//----------------------------------------------------------------------------- -void WakeUp::CreateVars -( - uint8 const _instance -) -{ - if( Node* node = GetNodeUnsafe() ) - { - if( !node->IsController() ) // We don't add the interval value for controllers, because they don't appear to ever wake up on their own. - { - switch( GetVersion() ) - { - case 1: - { - node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 0, "Wake-up Interval", "Seconds", false, false, 3600, 0 ); - break; - } - case 2: - { - node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 1, "Minimum Wake-up Interval", "Seconds", true, false, 0, 0 ); - node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 2, "Maximum Wake-up Interval", "Seconds", true, false, 0, 0 ); - node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 3, "Default Wake-up Interval", "Seconds", true, false, 0, 0 ); - node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 4, "Wake-up Interval Step", "Seconds", true, false, 0, 0 ); - break; - } - } - } - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/command_classes/WakeUp.h b/lib/ESPiLight/pilight/libs/openzwave/command_classes/WakeUp.h deleted file mode 100644 index d079f99..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/command_classes/WakeUp.h +++ /dev/null @@ -1,87 +0,0 @@ -//----------------------------------------------------------------------------- -// -// WakeUp.h -// -// Implementation of the Z-Wave COMMAND_CLASS_WAKE_UP -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _WakeUp_H -#define _WakeUp_H - -#include -#include "CommandClass.h" -#include "../Driver.h" - -namespace OpenZWave -{ - class Msg; - class ValueInt; - class Mutex; - - /** \brief Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class. - */ - class WakeUp: public CommandClass - { - public: - static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new WakeUp( _homeId, _nodeId ); } - virtual ~WakeUp(); - - static uint8 const StaticGetCommandClassId(){ return 0x84; } - static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_WAKE_UP"; } - - void Init(); // Starts the process of requesting node state from a sleeping device. - void QueueMsg( Driver::MsgQueueItem const& _item ); - void SendPending(); - bool IsAwake()const{ return m_awake; } - void SetAwake( bool _state ); - void SetPollRequired(){ m_pollRequired = true; } - - // From CommandClass - virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ); - virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); } - virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); } - virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ); - virtual bool SetValue( Value const& _value ); - virtual void SetVersion( uint8 const _version ); - - virtual uint8 GetMaxVersion(){ return 2; } - - protected: - virtual void CreateVars( uint8 const _instance ); - - private: - WakeUp( uint32 const _homeId, uint8 const _nodeId ); - - Mutex* m_mutex; // Serialize access to the pending queue - list m_pendingQueue; // Messages waiting to be sent when the device wakes up - bool m_awake; - bool m_pollRequired; - bool m_notification; - }; - -} // namespace OpenZWave - -#endif - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/libudev.h b/lib/ESPiLight/pilight/libs/openzwave/libudev.h deleted file mode 100644 index 4f2f115..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/libudev.h +++ /dev/null @@ -1,207 +0,0 @@ -/*** - This file is part of systemd. - - Copyright 2008-2012 Kay Sievers - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see . -***/ - -#ifndef _LIBUDEV_H_ -#define _LIBUDEV_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * udev - library context - * - * reads the udev config and system environment - * allows custom logging - */ -struct udev; -struct udev *udev_ref(struct udev *udev); -struct udev *udev_unref(struct udev *udev); -struct udev *udev_new(void); -void udev_set_log_fn(struct udev *udev, - void (*log_fn)(struct udev *udev, - int priority, const char *file, int line, const char *fn, - const char *format, va_list args)); -int udev_get_log_priority(struct udev *udev); -void udev_set_log_priority(struct udev *udev, int priority); -void *udev_get_userdata(struct udev *udev); -void udev_set_userdata(struct udev *udev, void *userdata); - -/* - * udev_list - * - * access to libudev generated lists - */ -struct udev_list_entry; -struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry); -struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name); -const char *udev_list_entry_get_name(struct udev_list_entry *list_entry); -const char *udev_list_entry_get_value(struct udev_list_entry *list_entry); -/** - * udev_list_entry_foreach: - * @list_entry: entry to store the current position - * @first_entry: first entry to start with - * - * Helper to iterate over all entries of a list. - */ -#define udev_list_entry_foreach(list_entry, first_entry) \ - for (list_entry = first_entry; \ - list_entry != NULL; \ - list_entry = udev_list_entry_get_next(list_entry)) - -/* - * udev_device - * - * access to sysfs/kernel devices - */ -struct udev_device; -struct udev_device *udev_device_ref(struct udev_device *udev_device); -struct udev_device *udev_device_unref(struct udev_device *udev_device); -struct udev *udev_device_get_udev(struct udev_device *udev_device); -struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath); -struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum); -struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname); -struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id); -struct udev_device *udev_device_new_from_environment(struct udev *udev); -/* udev_device_get_parent_*() does not take a reference on the returned device, it is automatically unref'd with the parent */ -struct udev_device *udev_device_get_parent(struct udev_device *udev_device); -struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, - const char *subsystem, const char *devtype); -/* retrieve device properties */ -const char *udev_device_get_devpath(struct udev_device *udev_device); -const char *udev_device_get_subsystem(struct udev_device *udev_device); -const char *udev_device_get_devtype(struct udev_device *udev_device); -const char *udev_device_get_syspath(struct udev_device *udev_device); -const char *udev_device_get_sysname(struct udev_device *udev_device); -const char *udev_device_get_sysnum(struct udev_device *udev_device); -const char *udev_device_get_devnode(struct udev_device *udev_device); -int udev_device_get_is_initialized(struct udev_device *udev_device); -struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device); -struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device); -struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device); -struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device); -const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key); -const char *udev_device_get_driver(struct udev_device *udev_device); -dev_t udev_device_get_devnum(struct udev_device *udev_device); -const char *udev_device_get_action(struct udev_device *udev_device); -unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device); -unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device); -const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr); -int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value); -int udev_device_has_tag(struct udev_device *udev_device, const char *tag); - -/* - * udev_monitor - * - * access to kernel uevents and udev events - */ -struct udev_monitor; -struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor); -struct udev_monitor *udev_monitor_unref(struct udev_monitor *udev_monitor); -struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor); -/* kernel and udev generated events over netlink */ -struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name); -/* bind socket */ -int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor); -int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size); -int udev_monitor_get_fd(struct udev_monitor *udev_monitor); -struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor); -/* in-kernel socket filters to select messages that get delivered to a listener */ -int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor, - const char *subsystem, const char *devtype); -int udev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag); -int udev_monitor_filter_update(struct udev_monitor *udev_monitor); -int udev_monitor_filter_remove(struct udev_monitor *udev_monitor); - -/* - * udev_enumerate - * - * search sysfs for specific devices and provide a sorted list - */ -struct udev_enumerate; -struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate); -struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate); -struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate); -struct udev_enumerate *udev_enumerate_new(struct udev *udev); -/* device properties filter */ -int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem); -int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem); -int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); -int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); -int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value); -int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname); -int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag); -int udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent); -int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate); -int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath); -/* run enumeration with active filters */ -int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate); -int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate); -/* return device list */ -struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate); - -/* - * udev_queue - * - * access to the currently running udev events - */ -struct udev_queue; -struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue); -struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue); -struct udev *udev_queue_get_udev(struct udev_queue *udev_queue); -struct udev_queue *udev_queue_new(struct udev *udev); -unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated)); -unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated)); -int udev_queue_get_udev_is_active(struct udev_queue *udev_queue); -int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue); -int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) __attribute__ ((deprecated)); -int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue, - unsigned long long int start, unsigned long long int end) __attribute__ ((deprecated)); -int udev_queue_get_fd(struct udev_queue *udev_queue); -int udev_queue_flush(struct udev_queue *udev_queue); -struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) __attribute__ ((deprecated)); - -/* - * udev_hwdb - * - * access to the static hardware properties database - */ -struct udev_hwdb; -struct udev_hwdb *udev_hwdb_new(struct udev *udev); -struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb); -struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb); -struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags); - -/* - * udev_util - * - * udev specific utilities - */ -int udev_util_encode_string(const char *str, char *str_enc, size_t len); - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/CMakeLists.txt b/lib/ESPiLight/pilight/libs/openzwave/platform/CMakeLists.txt deleted file mode 100644 index dbc5f43..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -project(openzwave_platform) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.cpp") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") - -if(WIN32) - add_subdirectory(windows) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_windows_files} ${${PROJECT_NAME}_files} CACHE INTERNAL "") -else() - add_subdirectory(unix) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_unix_files} ${${PROJECT_NAME}_files} CACHE INTERNAL "") -endif() - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Controller.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/Controller.cpp deleted file mode 100644 index 6f6da97..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Controller.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Controller.cpp -// -// Cross-platform, hardware-abstracted controller data interface -// -// Copyright (c) 2010 Jason Frazier -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../Defs.h" -#include "../Driver.h" -#include "Controller.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Queues up the controller's initialization commands. -//----------------------------------------------------------------------------- -void Controller::PlayInitSequence -( - Driver* _driver -) -{ - _driver->SendMsg( new Msg( "FUNC_ID_ZW_GET_VERSION", 0xff, REQUEST, FUNC_ID_ZW_GET_VERSION, false ), Driver::MsgQueue_Command ); - _driver->SendMsg( new Msg( "FUNC_ID_ZW_MEMORY_GET_ID", 0xff, REQUEST, FUNC_ID_ZW_MEMORY_GET_ID, false ), Driver::MsgQueue_Command ); - _driver->SendMsg( new Msg( "FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES", 0xff, REQUEST, FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES, false ), Driver::MsgQueue_Command ); - _driver->SendMsg( new Msg( "FUNC_ID_SERIAL_API_GET_CAPABILITIES", 0xff, REQUEST, FUNC_ID_SERIAL_API_GET_CAPABILITIES, false ), Driver::MsgQueue_Command ); - _driver->SendMsg( new Msg( "FUNC_ID_ZW_GET_SUC_NODE_ID", 0xff, REQUEST, FUNC_ID_ZW_GET_SUC_NODE_ID, false ), Driver::MsgQueue_Command ); - // FUNC_ID_ZW_GET_VIRTUAL_NODES & FUNC_ID_SERIAL_API_GET_INIT_DATA has moved into the handler for FUNC_ID_SERIAL_API_GET_CAPABILITIES -} - -//----------------------------------------------------------------------------- -// -// Read from a controller -//----------------------------------------------------------------------------- -uint32 Controller::Read -( - uint8* _buffer, - uint32 _length -) -{ - // Fetch the data from the ring buffer (which is an all or nothing read) - if( Get( _buffer, _length ) ) - { - return _length; - } - - return 0; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Controller.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Controller.h deleted file mode 100644 index a1ccbc7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Controller.h +++ /dev/null @@ -1,107 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Controller.h -// -// Cross-platform, hardware-abstracted controller data interface -// -// Copyright (c) 2010 Jason Frazier -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Controller_H -#define _Controller_H - -#include -#include -#include "../Defs.h" -#include "../Driver.h" -#include "Stream.h" - -namespace OpenZWave -{ - class Driver; - - class Controller: public Stream - { - // Controller is derived from Stream rather than containing one, so that - // we can use its Wait abilities without having to duplicate them here. - // The stream is used for input. Buffering of output is handled by the OS. - - public: - /** - * Consructor. - * Creates the controller object. - */ - Controller():Stream( 2048 ){} - - /** - * Destructor. - * Destroys the controller object. - */ - virtual ~Controller(){} - - /** - * Queues a set of Z-Wave messages in the correct order needed to initialize the Controller implementation. - * @param Pointer to the driver object that will handle the messages. - * @see Driver::Init - */ - void PlayInitSequence( Driver* _driver ); - - /** - * Open a controller. - * Attempts to open a controller and initialize it with the specified paramters. - * @param _controllerName The name of the port to open. For example, ttyS1 on Linux, or \\.\COM2 in Windows. - * @see Close, Read, Write - */ - virtual bool Open( string const& _controllerName ) = 0; - - /** - * Close a controller. - * Closes the controller. - * @return True if the controller was closed successfully, or false if the controller was already closed, or an error occurred. - * @see Open - */ - virtual bool Close() = 0; - - /** - * Write to a controller. - * Attempts to write data to an open controller. - * @param _buffer Pointer to a block of memory containing the data to be written. - * @param _length Length in bytes of the data. - * @return The number of bytes written. - * @see Read, Open, Close - */ - virtual uint32 Write( uint8* _buffer, uint32 _length ) = 0; - - /** - * Read from a controller. - * Attempts to read data from an open controller. - * @param _buffer Pointer to a block of memory large enough to hold the requested data. - * @param _length Length in bytes of the data to be read. - * @return The number of bytes read. - * @see Write, Open, Close - */ - uint32 Read( uint8* _buffer, uint32 _length ); - }; - -} // namespace OpenZWave - -#endif //_Controller_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Event.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/Event.cpp deleted file mode 100644 index dae72a0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Event.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Event.cpp -// -// Cross-platform event -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../Defs.h" -#include "Event.h" - -#ifdef _WIN32 -#include "windows/EventImpl.h" // Platform-specific implementation of an event -#else -#include "unix/EventImpl.h" // Platform-specific implementation of an event -#endif - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Event::Event -( -): - m_pImpl( new EventImpl() ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Event::~Event -( -) -{ - delete m_pImpl; -} - -//----------------------------------------------------------------------------- -// -// Set the event to signalled -//----------------------------------------------------------------------------- -void Event::Set -( -) -{ - m_pImpl->Set(); - Notify(); // Notify any watchers that the event is now set -} - -//----------------------------------------------------------------------------- -// -// Set the event to not signalled -//----------------------------------------------------------------------------- -void Event::Reset -( -) -{ - m_pImpl->Reset(); -} - -//----------------------------------------------------------------------------- -// -// Test whether the event is set -//----------------------------------------------------------------------------- -bool Event::IsSignalled -( -) -{ - return m_pImpl->IsSignalled(); -} - -//----------------------------------------------------------------------------- -// -// Wait for the event to become signalled -//----------------------------------------------------------------------------- -bool Event::Wait -( - int32 const _timeout -) -{ - return m_pImpl->Wait( _timeout ); -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Event.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Event.h deleted file mode 100644 index c13211e..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Event.h +++ /dev/null @@ -1,91 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Event.h -// -// Cross-platform manual-reset event -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _Event_H -#define _Event_H - -#include "Wait.h" - -namespace OpenZWave -{ - class EventImpl; - - /** \brief Platform-independent definition of event objects. - */ - class Event: public Wait - { - friend class SerialControllerImpl; - friend class Wait; - - public: - /** - * Constructor. - * Creates a cross-platform event object equivalent to the Windows manual-reset event - */ - Event(); - - /** - * Set the event to signalled. - * \see Reset, Wait - */ - void Set(); - - /** - * Set the event to not signalled. - * \see Set, Wait - */ - void Reset(); - - protected: - /** - * Used by the Wait class to test whether the event is set. - */ - virtual bool IsSignalled(); - - /** - * Used by the Wait::Multiple method. - * returns true if the event signalled, false if it timed out - */ - bool Wait( int32 _timeout ); - - /** - * Destructor. - * Destroys the event object. - */ - ~Event(); - - private: - Event( Event const& ); // prevent copy - Event& operator = ( Event const& ); // prevent assignment - - EventImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a event. - }; - -} // namespace OpenZWave - -#endif //_Event_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/FileOps.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/FileOps.cpp deleted file mode 100644 index 79fe27d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/FileOps.cpp +++ /dev/null @@ -1,105 +0,0 @@ -//----------------------------------------------------------------------------- -// -// FileOps.cpp -// -// Cross-platform File Operations -// -// Copyright (c) 2012 Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include "FileOps.h" - -#ifdef _WIN32 -#include "windows/FileOpsImpl.h" // Platform-specific implementation of a File Operations -#else -#include "unix/FileOpsImpl.h" // Platform-specific implementation of a File Operations -#endif - -using namespace OpenZWave; - -FileOps* FileOps::s_instance = NULL; -FileOpsImpl* FileOps::m_pImpl = NULL; - -//----------------------------------------------------------------------------- -// -// Static creation of the singleton -//----------------------------------------------------------------------------- -FileOps* FileOps::Create -( -) -{ - if( s_instance == NULL ) - { - s_instance = new FileOps(); - } - return s_instance; -} - -//----------------------------------------------------------------------------- -// -// Static method to destroy the fileops singleton. -//----------------------------------------------------------------------------- -void FileOps::Destroy -( -) -{ - delete s_instance; - s_instance = NULL; -} - -//----------------------------------------------------------------------------- -// -// Static method to check for existance of a folder -//----------------------------------------------------------------------------- -bool FileOps::FolderExists -( - const string &_folderName -) -{ - if( s_instance != NULL ) - { - return s_instance->m_pImpl->FolderExists( _folderName ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -FileOps::FileOps -( -) -{ - m_pImpl = new FileOpsImpl(); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -FileOps::~FileOps -( -) -{ - delete m_pImpl; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/FileOps.h b/lib/ESPiLight/pilight/libs/openzwave/platform/FileOps.h deleted file mode 100644 index 548f8f6..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/FileOps.h +++ /dev/null @@ -1,75 +0,0 @@ -//----------------------------------------------------------------------------- -// -// FileOps.h -// -// Cross-platform File Operations -// -// Copyright (c) 2012 Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _FileOps_H -#define _FileOps_H - -#include -#include -#include "../Defs.h" - -namespace OpenZWave -{ - class FileOpsImpl; - - /** \brief Implements platform-independent File Operations. - */ - class FileOps - { - public: - /** - * Create a FileOps cross-platform singleton. - * \return a pointer to the file operations object. - * \see Destroy. - */ - static FileOps* Create(); - - /** - * Destroys the FileOps singleton. - * \see Create. - */ - static void Destroy(); - - /** - * FolderExists. Check for the existance of a folder. - * \param string. Folder name. - * \return Bool value indicating existance. - */ - static bool FolderExists( const string &_folderName ); - - private: - FileOps(); - ~FileOps(); - - static FileOpsImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of the FileOps. - static FileOps* s_instance; - }; - -} // namespace OpenZWave - -#endif //_FileOps_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Log.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/Log.cpp deleted file mode 100644 index 503476a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Log.cpp +++ /dev/null @@ -1,334 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Log.cpp -// -// Cross-platform message and error logging -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include - -#include "../Defs.h" -#include "Mutex.h" -#include "Log.h" - -#ifdef _WIN32 -#include "windows/LogImpl.h" // Platform-specific implementation of a log -#else -#include "unix/LogImpl.h" // Platform-specific implementation of a log -#endif - - -using namespace OpenZWave; - -char const *OpenZWave::LogLevelString[] = -{ - "None", /**< LogLevel_None Disable all logging */ - "Always", /**< LogLevel_Always These messages should always be shown */ - "Fatal", /**< LogLevel_Fatal A likely fatal issue in the library */ - "Error", /**< LogLevel_Error A serious issue with the library or the network */ - "Warning", /**< LogLevel_Warning A minor issue from which the library should be able to recover */ - "Alert", /**< LogLevel_Alert Something unexpected by the library about which the controlling application should be aware */ - "Info", /**< LogLevel_Info Everything's working fine...these messages provide streamlined feedback on each message */ - "Detail", /**< LogLevel_Detail Detailed information on the progress of each message */ - "Debug", /**< LogLevel_Debug Very detailed information on progress that will create a huge log file quickly - But this level (as others) can be queued and sent to the log only on an error or warning */ - "StreamDetail", /**< LogLevel_StreamDetail Will include low-level byte transfers from controller to buffer to application and back */ - "Internal" /**< LogLevel_Internal Used only within the log class (uses existing timestamp, etc.) */ -}; - - - -Log* Log::s_instance = NULL; -i_LogImpl* Log::m_pImpl = NULL; -static bool s_dologging; - -//----------------------------------------------------------------------------- -// -// Static creation of the singleton -//----------------------------------------------------------------------------- -Log* Log::Create -( - string const& _filename, - bool const _bAppend, - bool const _bConsoleOutput, - LogLevel const _saveLevel, - LogLevel const _queueLevel, - LogLevel const _dumpTrigger -) -{ - if( NULL == s_instance ) - { - s_instance = new Log( _filename, _bAppend, _bConsoleOutput, _saveLevel, _queueLevel, _dumpTrigger ); - s_dologging = true; // default logging to true so no change to what people experience now - } - - return s_instance; -} - -//----------------------------------------------------------------------------- -// -// Static creation of the singleton -//----------------------------------------------------------------------------- -/* It isn't clear this is ever called or used. If no one complains, consider - deleting this code in April 2012. -Log* Log::Create -( - i_LogImpl *LogClass -) -{ - if (NULL == s_instance ) - { - s_instance = new Log( "" ); - s_dologging = true; - } - SetLoggingClass( LogClass ); - return s_instance; -} -*/ - -//----------------------------------------------------------------------------- -// -// Static method to destroy the logging singleton. -//----------------------------------------------------------------------------- -void Log::Destroy -( -) -{ - delete s_instance; - s_instance = NULL; -} - -//----------------------------------------------------------------------------- -// -// Set log class -//----------------------------------------------------------------------------- -bool Log::SetLoggingClass -( - i_LogImpl *LogClass -) -{ - delete m_pImpl; - m_pImpl = LogClass; - return true; -} - -//----------------------------------------------------------------------------- -// -// Set flag to actually write to log or skip it (legacy version) -// If logging is enabled, the default log detail settings will be used -// Write to file/screen LogLevel_Detail -// Save in queue for errors LogLevel_Debug -// Trigger for dumping queue LogLevel_Warning -// Console output? Yes -// Append to an existing log? No (overwrite) -//----------------------------------------------------------------------------- -void Log::SetLoggingState -( - bool _dologging -) -{ - bool prevLogging = s_dologging; - s_dologging = _dologging; - - if (!prevLogging && s_dologging) Log::Write(LogLevel_Always, "Logging started\n\n"); -} - -//----------------------------------------------------------------------------- -// -// Set flag to actually write to log or skip it -//----------------------------------------------------------------------------- -void Log::SetLoggingState -( - LogLevel _saveLevel, - LogLevel _queueLevel, - LogLevel _dumpTrigger -) -{ - // parameter checking: - // _queueLevel cannot be less than or equal to _saveLevel (where lower ordinals are more severe conditions) - // _dumpTrigger cannot be greater than or equal to _queueLevel - if( _queueLevel <= _saveLevel ) - Log::Write( LogLevel_Warning, "Only lower priority messages may be queued for error-driven display." ); - if( _dumpTrigger >= _queueLevel ) - Log::Write( LogLevel_Warning, "The trigger for dumping queued messages must be a higher-priority message than the level that is queued." ); - - bool prevLogging = s_dologging; - // s_dologging is true if any messages are to be saved in file or queue - if( (_saveLevel > LogLevel_Always) || - (_queueLevel > LogLevel_Always) ) - { - s_dologging = true; - } - else - { - s_dologging = false; - } - - if( s_instance && s_dologging && s_instance->m_pImpl ) - { - s_instance->m_logMutex->Lock(); - s_instance->m_pImpl->SetLoggingState( _saveLevel, _queueLevel, _dumpTrigger ); - s_instance->m_logMutex->Unlock(); - } - - if (!prevLogging && s_dologging) Log::Write(LogLevel_Always, "Logging started\n\n"); -} - -//----------------------------------------------------------------------------- -// -// Return a flag to indicate whether logging is enabled -//----------------------------------------------------------------------------- -bool Log::GetLoggingState -( -) -{ - return s_dologging; -} - -//----------------------------------------------------------------------------- -// -// Write to the log -//----------------------------------------------------------------------------- -void Log::Write -( - LogLevel _level, - char const* _format, - ... -) -{ - if( s_instance && s_dologging && s_instance->m_pImpl ) - { - s_instance->m_logMutex->Lock(); // double locks if recursive - va_list args; - va_start( args, _format ); - s_instance->m_pImpl->Write( _level, 0, _format, args ); - va_end( args ); - s_instance->m_logMutex->Unlock(); - } -} - -//----------------------------------------------------------------------------- -// -// Write to the log -//----------------------------------------------------------------------------- -void Log::Write -( - LogLevel _level, - uint8 const _nodeId, - char const* _format, - ... -) -{ - if( s_instance && s_dologging && s_instance->m_pImpl ) - { - if( _level != LogLevel_Internal ) - s_instance->m_logMutex->Lock(); - va_list args; - va_start( args, _format ); - s_instance->m_pImpl->Write( _level, _nodeId, _format, args ); - va_end( args ); - if( _level != LogLevel_Internal ) - s_instance->m_logMutex->Unlock(); - } -} - -//----------------------------------------------------------------------------- -// -// Send queued messages to the log (and empty the queue) -//----------------------------------------------------------------------------- -void Log::QueueDump -( -) -{ - if( s_instance && s_dologging && s_instance->m_pImpl ) - { - s_instance->m_logMutex->Lock(); - s_instance->m_pImpl->QueueDump(); - s_instance->m_logMutex->Unlock(); - } -} - -//----------------------------------------------------------------------------- -// -// Empty the queued message queue -//----------------------------------------------------------------------------- -void Log::QueueClear -( -) -{ - if( s_instance && s_dologging && s_instance->m_pImpl ) - { - s_instance->m_logMutex->Lock(); - s_instance->m_pImpl->QueueClear(); - s_instance->m_logMutex->Unlock(); - } -} - -//----------------------------------------------------------------------------- -// -// Change the name of the log file (will start writing a new file) -//----------------------------------------------------------------------------- -void Log::SetLogFileName -( - const string &_filename -) -{ - if( s_instance && s_dologging && s_instance->m_pImpl ) - { - s_instance->m_logMutex->Lock(); - s_instance->m_pImpl->SetLogFileName( _filename ); - s_instance->m_logMutex->Unlock(); - } -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Log::Log -( - string const& _filename, - bool const _bAppend, - bool const _bConsoleOutput, - LogLevel const _saveLevel, - LogLevel const _queueLevel, - LogLevel const _dumpTrigger -): - m_logMutex( new Mutex() ) -{ - if (NULL == m_pImpl) - m_pImpl = new LogImpl( _filename, _bAppend, _bConsoleOutput, _saveLevel, _queueLevel, _dumpTrigger ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Log::~Log -( -) -{ - m_logMutex->Release(); - delete m_pImpl; - m_pImpl = NULL; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Log.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Log.h deleted file mode 100644 index c8f80ca..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Log.h +++ /dev/null @@ -1,187 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Log.h -// -// Cross-platform message and error logging -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _Log_H -#define _Log_H - -#include -#include -#include "../Defs.h" - - - -namespace OpenZWave -{ - class Mutex; - extern char const *LogLevelString[]; - enum LogLevel - { - LogLevel_None, /**< Disable all logging */ - LogLevel_Always, /**< These messages should always be shown */ - LogLevel_Fatal, /**< A likely fatal issue in the library */ - LogLevel_Error, /**< A serious issue with the library or the network */ - LogLevel_Warning, /**< A minor issue from which the library should be able to recover */ - LogLevel_Alert, /**< Something unexpected by the library about which the controlling application should be aware */ - LogLevel_Info, /**< Everything's working fine...these messages provide streamlined feedback on each message */ - LogLevel_Detail, /**< Detailed information on the progress of each message */ - LogLevel_Debug, /**< Very detailed information on progress that will create a huge log file quickly - But this level (as others) can be queued and sent to the log only on an error or warning */ - LogLevel_StreamDetail, /**< Will include low-level byte transfers from controller to buffer to application and back */ - LogLevel_Internal /**< Used only within the log class (uses existing timestamp, etc.) */ - }; - - class i_LogImpl - { - public: - i_LogImpl() { } ; - virtual ~i_LogImpl() { } ; - virtual void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args ) = 0; - virtual void QueueDump() = 0; - virtual void QueueClear() = 0; - virtual void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ) = 0; - virtual void SetLogFileName( const string &_filename ) = 0; - }; - - /** \brief Implements a platform-independent log...written to the console and, optionally, a file. - */ - class Log - { - public: - /** - * Create a log. - * Creates the cross-platform logging singleton. - * Any previous log will be cleared. - * \return a pointer to the logging object. - * \see Destroy, Write - */ - static Log* Create( string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger ); - - /** - * Create a log. - * Creates the cross-platform logging singleton. - * Any previous log will be cleared. - * \param LogClass a Logging Class that inherits the i_LogImpl Class to use to Log - * \return a pointer to the logging object. - * \see Destroy, Write - */ - - static Log* Create( i_LogImpl *LogClass ); - - /** - * Destroys the log. - * Destroys the logging singleton. The log can no longer - * be written to without another call to Create. - * \see Create, Write - */ - static void Destroy(); - - /** - * \brief Set the Logging Implmentation Class to replace the standard File/Console Loggin - * \param LogClass A Logging Class that inherits the i_LogImpl Class used to Log to - * \return Bool Value indicating success or failure - */ - static bool SetLoggingClass(i_LogImpl *LogClass ); - - /** - * \brief Enable or disable library logging (retained for backward compatibility) - * \param _dologging If true, logging is enabled; if false, disabled - */ - static void SetLoggingState(bool _dologging); - - /** - * \brief Enable or disable library logging. To disable, set _saveLevel and _queueLevel - * to LogLevel_None. - * \param _saveLevel LogLevel of messages to write in real-time - * \param _queueLevel LogLevel of messages to queue to be dumped in case of an error - * \param _dumpTrigger LogLevel of message that triggers a queue dump (probably LogLevel_Error or LogLevel_Warning) - */ - static void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ); - - /** - * \brief Determine whether logging is enabled or not (retained for backward compatibility) - * \param _dologging If true, logging is enabled; if false, disabled - */ - static bool GetLoggingState(); - - /** - * \brief Obtain the various logging levels. - * \param _saveLevel LogLevel of messages to write in real-time - * \param _queueLevel LogLevel of messages to queue to be dumped in case of an error - * \param _dumpTrigger LogLevel of message that triggers a queue dump (probably LogLevel_Error or LogLevel_Warning) - */ - static void GetLoggingState( LogLevel* _saveLevel, LogLevel* _queueLevel, LogLevel* _dumpTrigger ); - - /** - * \brief Change the log file name. This will start a new log file (or potentially start appending - * information to an existing one. Developers might want to use this function, together with a timer - * in the controlling application, to create timestamped log file names. - * \param _filename Name of the new (or existing) file to use for log output. - */ - static void SetLogFileName( const string &_filename ); - - /** - * Write an entry to the log. - * Writes a formatted string to the log. - * \param _level Specifies the type of log message (Error, Warning, Debug, etc.) - * \param _format. A string formatted in the same manner as used with printf etc. - * \param ... a variable number of arguments, to be included in the formatted string. - * \see Create, Destroy - */ - static void Write( LogLevel _level, char const* _format, ... ); - - /** - * Write an entry to the log. - * Writes a formatted string to the log. - * \param _level Specifies the type of log message (Error, Warning, Debug, etc.) - * \param _nodeId Node Id this entry is about. - * \param _format. A string formatted in the same manner as used with printf etc. - * \param ... a variable number of arguments, to be included in the formatted string. - * \see Create, Destroy - */ - static void Write( LogLevel _level, uint8 const _nodeId, char const* _format, ... ); - - /** - * Send the queued log messages to the log output. - */ - static void QueueDump(); - - /** - * Clear the log message queue - */ - static void QueueClear(); - - private: - Log( string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ); - ~Log(); - - static i_LogImpl* m_pImpl; /**< Pointer to an object that encapsulates the platform-specific logging implementation. */ - static Log* s_instance; - Mutex* m_logMutex; - }; -} // namespace OpenZWave - -#endif //_Log_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Mutex.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/Mutex.cpp deleted file mode 100644 index 378f1a1..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Mutex.cpp +++ /dev/null @@ -1,101 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Mutex.cpp -// -// Cross-platform mutex -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../Defs.h" -#include "Mutex.h" - -#ifdef _WIN32 -#include "windows/MutexImpl.h" // Platform-specific implementation of a mutex -#else -#include "unix/MutexImpl.h" // Platform-specific implementation of a mutex -#endif - - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Mutex::Mutex -( -): - m_pImpl( new MutexImpl() ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Mutex::~Mutex -( -) -{ - delete m_pImpl; -} - -//----------------------------------------------------------------------------- -// -// Lock the mutex -//----------------------------------------------------------------------------- -bool Mutex::Lock -( - bool const _bWait // = true; -) -{ - return m_pImpl->Lock( _bWait ); -} - -//----------------------------------------------------------------------------- -// -// Release our lock on the mutex -//----------------------------------------------------------------------------- -void Mutex::Unlock -( -) -{ - m_pImpl->Unlock(); - - if( IsSignalled() ) - { - // The mutex has no owners, so notify the watchers - Notify(); - } -} - -//----------------------------------------------------------------------------- -// -// Test whether the event is set -//----------------------------------------------------------------------------- -bool Mutex::IsSignalled -( -) -{ - return m_pImpl->IsSignalled(); -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Mutex.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Mutex.h deleted file mode 100644 index 668f0cf..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Mutex.h +++ /dev/null @@ -1,88 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Mutex.h -// -// Cross-platform mutex -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _Mutex_H -#define _Mutex_H - -#include "Wait.h" - -namespace OpenZWave -{ - class MutexImpl; - - /** \brief Implements a platform-independent mutex--for serializing access to a shared resource. - */ - class Mutex: public Wait - { - public: - /** - * Constructor. - * Creates a mutex object that can be used to serialize access to a shared resource. - */ - Mutex(); - - /** - * Lock the mutex. - * Attempts to lock the mutex. - * There must be a matching call to Release for every call to Lock. - * \param _bWait Defaults to true. Set this argument to false if the method should return - * immediately, even if the lock is not available. - * \return True if the lock was obtained. - * \see Release - */ - bool Lock( bool const _bWait = true ); - - /** - * Releases the lock on the mutex. - * There must be a matching call to Release for every call to Lock. - * \see Lock - */ - void Unlock(); - - protected: - /** - * Used by the Wait class to test whether the mutex is free. - */ - virtual bool IsSignalled(); - - /** - * Destructor. - * Destroys the mutex object. - */ - ~Mutex(); - - private: - Mutex( Mutex const& ); // prevent copy - Mutex& operator = ( Mutex const& ); // prevent assignment - - MutexImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a mutex. - }; - -} // namespace OpenZWave - -#endif //_Mutex_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Ref.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Ref.h deleted file mode 100644 index 14554d7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Ref.h +++ /dev/null @@ -1,91 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Ref.h -// -// Reference counting for objects. -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _Ref_H -#define _Ref_H - -#pragma once - -#include "../Defs.h" - -namespace OpenZWave -{ - /** - * Provides reference counting for objects. - * Any class wishing to include reference counting should be derived from Ref. - * Derived classes must declare their destructor as protected virtual. - * On construction, the reference count is set to one. Calls to AddRef increment - * the count. Calls to Release decrement the count. When the count reaches - * zero, the object is deleted. - */ - class Ref - { - public: - /** - * Initializes the RefCount to one. The object - * can only be deleted through a call to Release. - * \see AddRef, Release - */ - Ref(){ m_refs = 1; } - - /** - * Increases the reference count of the object. - * Every call to AddRef requires a matching call - * to Release before the object will be deleted. - * \see Release - */ - void AddRef(){ ++m_refs; } - - /** - * Removes a reference to an object. - * If this was the last reference to the message, the - * object is deleted. - * \see AddRef - */ - int32 Release() - { - if( 0 >= ( --m_refs ) ) - { - delete this; - return 0; - } - return m_refs; - } - - protected: - virtual ~Ref(){} - - private: - // Reference counting - int32 m_refs; - - }; // class Ref - -} // namespace OpenZWave - -#endif // _Ref_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/SerialController.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/SerialController.cpp deleted file mode 100644 index 1fb7b6d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/SerialController.cpp +++ /dev/null @@ -1,185 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SerialController.h -// -// Cross-platform serial port handler -// -// Copyright (c) 2010 Jason Frazier -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../Msg.h" -#include "Event.h" -#include "Thread.h" -#include "SerialController.h" -#include "Log.h" - -#ifdef _WIN32 -#include "windows/SerialControllerImpl.h" // Platform-specific implementation of a serial port -#else -#include "unix/SerialControllerImpl.h" // Platform-specific implementation of a serial port -#endif - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -SerialController::SerialController -( -): - m_baud ( 115200 ), - m_parity ( SerialController::Parity_None ), - m_stopBits ( SerialController::StopBits_One ), - m_bOpen( false ) -{ - m_pImpl = new SerialControllerImpl( this ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -SerialController::~SerialController -( -) -{ - delete m_pImpl; -} - -//----------------------------------------------------------------------------- -// -// Set the serial port baud rate. -// The serial port must be closed for the setting to be accepted. -//----------------------------------------------------------------------------- -bool SerialController::SetBaud -( - uint32 const _baud -) -{ - if( m_bOpen ) - { - return false; - } - - m_baud = _baud; - return true; -} - -//----------------------------------------------------------------------------- -// -// Set the serial port parity. -// The serial port must be closed for the setting to be accepted. -//----------------------------------------------------------------------------- -bool SerialController::SetParity -( - Parity const _parity -) -{ - if( m_bOpen ) - { - return false; - } - - m_parity = _parity; - return true; -} - -//----------------------------------------------------------------------------- -// -// Set the serial port stop bits. -// The serial port must be closed for the setting to be accepted. -//----------------------------------------------------------------------------- -bool SerialController::SetStopBits -( - StopBits const _stopBits -) -{ - if( m_bOpen ) - { - return false; - } - - m_stopBits = _stopBits; - return true; -} - -//----------------------------------------------------------------------------- -// -// Open and configure a serial port -//----------------------------------------------------------------------------- -bool SerialController::Open -( - string const& _serialControllerName -) -{ - if( m_bOpen ) - { - return false; - } - - m_serialControllerName = _serialControllerName; - m_bOpen = m_pImpl->Open(); - return m_bOpen; -} - -//----------------------------------------------------------------------------- -// -// Close a serial port -//----------------------------------------------------------------------------- -bool SerialController::Close -( -) -{ - if( !m_bOpen ) - { - return false; - } - - m_pImpl->Close(); - m_bOpen = false; - return true; -} - -//----------------------------------------------------------------------------- -// -// Write data to an open serial port -//----------------------------------------------------------------------------- -uint32 SerialController::Write -( - uint8* _buffer, - uint32 _length -) -{ - if( !m_bOpen ) - { - return 0; - } - - Log::Write( LogLevel_StreamDetail, " SerialController::Write (sent to controller)" ); - LogData(_buffer, _length, " Write: "); - - return( m_pImpl->Write( _buffer, _length ) ); -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/SerialController.h b/lib/ESPiLight/pilight/libs/openzwave/platform/SerialController.h deleted file mode 100644 index 5e52721..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/SerialController.h +++ /dev/null @@ -1,138 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SerialController.h -// -// Cross-platform serial port handler -// -// Copyright (c) 2010 Jason Frazier -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SerialController_H -#define _SerialController_H - -#include -#include "../Defs.h" -#include "Controller.h" - -namespace OpenZWave -{ - class Driver; - class Msg; - class SerialControllerImpl; - - class SerialController: public Controller - { - friend class SerialControllerImpl; - - public: - enum Parity - { - Parity_None = 0, - Parity_Odd, - Parity_Even, - Parity_Mark, - Parity_Space - }; - - enum StopBits - { - StopBits_One = 0, - StopBits_OneAndAHalf = 1, - StopBits_Two = 2 - }; - - /** - * Constructor. - * Creates an object that represents a serial port. - */ - SerialController(); - - /** - * Destructor. - * Destroys the serial port object. - */ - virtual ~SerialController(); - - /** - * Set the serial port baud rate. The serial port must be closed for the setting to be accepted. - * @param _baud Integer containing the expected baud-rate of the serial connection. Most Z-Wave interfaces run at 115200 baud. - * @return True if the baud value was accepted. - * @see Open, Close - */ - bool SetBaud( uint32 const _baud ); - - /** - * Set the serial port parity. The serial port must be closed for the setting to be accepted. - * @param _parity Parity enum value indicating the serial data's expected type of parity bits, if any. - * @return True if the parity value was accepted. - * @see Open, Close - */ - bool SetParity( Parity const _parity ); - - /** - * Set the serial port stop bits. The serial port must be closed for the setting to be accepted. - * @param _stopBits StopBits enum value indicating the serial data's expected number of stop-bits. - * @return True if the stop bits value was accepted. - * @see Open, Close - */ - bool SetStopBits( StopBits const _stopBits ); - - /** - * Open a serial port. - * Attempts to open a serial port and initialize it with the specified paramters. - * @param _SerialControllerName The name of the port to open. For example, ttyS1 on Linux, or \\.\COM2 in Windows. - * @return True if the port was opened and configured successfully. - * @see Close, Read, Write - */ - bool Open( string const& _SerialControllerName ); - - /** - * Close a serial port. - * Closes the serial port. - * @return True if the port was closed successfully, or false if the port was already closed, or an error occurred. - * @see Open - */ - bool Close(); - - /** - * Write to a serial port. - * Attempts to write data to an open serial port. - * @param _buffer Pointer to a block of memory containing the data to be written. - * @param _length Length in bytes of the data. - * @return The number of bytes written. - * @see Read, Open, Close - */ - uint32 Write( uint8* _buffer, uint32 _length ); - - private: - uint32 m_baud; - SerialController::Parity m_parity; - SerialController::StopBits m_stopBits; - string m_serialControllerName; - - SerialControllerImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of the serial port. - bool m_bOpen; - }; - -} // namespace OpenZWave - -#endif //_SerialController_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Stream.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/Stream.cpp deleted file mode 100644 index 7dfb8be..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Stream.cpp +++ /dev/null @@ -1,227 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Stream.h -// -// Cross-platform circular buffer with signalling -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "Stream.h" -#include "Mutex.h" -#include "Log.h" - -#include - -#include - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Stream::Stream -( - uint32 _bufferSize -): - m_bufferSize( _bufferSize ), - m_signalSize(1), - m_dataSize(0), - m_head(0), - m_tail(0), - m_mutex( new Mutex() ) -{ - m_buffer = new uint8[m_bufferSize]; -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Stream::~Stream -( -) -{ - m_mutex->Release(); - delete [] m_buffer; -} - -//----------------------------------------------------------------------------- -// -// Set the amount of data that must be in the buffer for to to be signalled -//----------------------------------------------------------------------------- -void Stream::SetSignalThreshold -( - uint32 _size -) -{ - m_signalSize = _size; - if( IsSignalled() ) - { - // We have more data than we are waiting for, so notify the watchers - Notify(); - } -} - -//----------------------------------------------------------------------------- -// -// Remove data from the buffer -//----------------------------------------------------------------------------- -bool Stream::Get -( - uint8* _buffer, - uint32 _size -) -{ - if( m_dataSize < _size ) - { - // There is not enough data in the buffer to fulfill the request - Log::Write( LogLevel_Error, "ERROR: Not enough data in stream buffer"); - return false; - } - - m_mutex->Lock(); - if( (m_tail + _size) > m_bufferSize ) - { - // We will have to wrap around - uint32 block1 = m_bufferSize - m_tail; - uint32 block2 = _size - block1; - - memcpy( _buffer, &m_buffer[m_tail], block1 ); - memcpy( &_buffer[block1], m_buffer, block2 ); - m_tail = block2; - } - else - { - // Requested data is in a contiguous block - memcpy( _buffer, &m_buffer[m_tail], _size ); - m_tail += _size; - } - - LogData( _buffer, _size, " Read (buffer->application): "); - - m_dataSize -= _size; - m_mutex->Unlock(); - return true; -} - -//----------------------------------------------------------------------------- -// -// Add data to the buffer -//----------------------------------------------------------------------------- -bool Stream::Put -( - uint8* _buffer, - uint32 _size -) -{ - if( (m_bufferSize-m_dataSize) < _size ) - { - // There is not enough space left in the buffer for the data - Log::Write( LogLevel_Error, "ERROR: Not enough space in stream buffer"); - return false; - } - - m_mutex->Lock(); - if( (m_head + _size) > m_bufferSize ) - { - // We will have to wrap around - uint32 block1 = m_bufferSize - m_head; - uint32 block2 = _size - block1; - - memcpy( &m_buffer[m_head], _buffer, block1 ); - memcpy( m_buffer, &_buffer[block1], block2 ); - m_head = block2; - LogData( m_buffer + m_head - block1, block1, " Read (controller->buffer): "); - LogData( m_buffer, block2, " Read (controller->buffer): "); - } - else - { - // There is enough space before we reach the end of the buffer - memcpy( &m_buffer[m_head], _buffer, _size ); - m_head += _size; - LogData(m_buffer+m_head-_size, _size, " Read (controller->buffer): "); - } - - m_dataSize += _size; - - if( IsSignalled() ) - { - // We now have more data than we are waiting for, so notify the watchers - Notify(); - } - - m_mutex->Unlock(); - return true; -} - -//----------------------------------------------------------------------------- -// -// Empty the data buffer -//----------------------------------------------------------------------------- -void Stream::Purge -( -) -{ - m_tail = 0; - m_head = 0; - m_dataSize = 0; -} - -//----------------------------------------------------------------------------- -// -// Test whether there is enough data to be signalled -//----------------------------------------------------------------------------- -bool Stream::IsSignalled -( -) -{ - return( m_dataSize >= m_signalSize ); -} - -//----------------------------------------------------------------------------- -// -// Format the stream buffer data for log output -//----------------------------------------------------------------------------- -void Stream::LogData -( - uint8* _buffer, - uint32 _length, - const string &_function -) -{ - if( !_length ) return; - - string str = ""; - for( uint32 i=0; i<_length; ++i ) - { - if( i ) - { - str += ", "; - } - - char byteStr[8]; - snprintf( byteStr, sizeof(byteStr), "0x%.2x", _buffer[i] ); - str += byteStr; - } - Log::Write( LogLevel_StreamDetail, "%s%s", _function.c_str(), str.c_str() ); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Stream.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Stream.h deleted file mode 100644 index e2eeb64..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Stream.h +++ /dev/null @@ -1,135 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Stream.h -// -// Cross-platform circular buffer with signalling -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _Stream_H -#define _Stream_H - -#include "../Defs.h" -#include "Wait.h" - -#include - -namespace OpenZWave -{ - class Mutex; - - /** \brief Platform-independent definition of a circular buffer. - */ - class Stream: public Wait - { - friend class Wait; - - public: - /** - * Constructor. - * Creates a cross-platform ring buffer object - */ - Stream( uint32 _bufferSize ); - - /** - * Set the number of bytes the buffer must contain before it becomes signalled. - * Once the threshold is set, the application can use Wait::Single or Wait::Multiple - * to wait until the buffer has been filled with the desired amount of data. - * \param _size the amoutn of data in bytes that the buffer must contain for it to become signalled. - * \see Wait::Single, Wait::Multiple - */ - void SetSignalThreshold( uint32 _size ); - - - /** - * Copies the requested amount of data from the stream, removing it from the stream as it does so. - * If there is insufficient data available, the method returns false, and no data is transferred. - * \param _buffer pointer to a block of memory that will be filled with the stream data. - * \param _size the amount of data in bytes to copy from the stream. - * \return true if all the requested data has been copied. False if there was not enough data in - * the stream. - * \see GetDataSize, Put - */ - bool Get( uint8* _buffer, uint32 _size ); - - /** - * Copies the requested amount of data from the buffer into the stream. - * If there is insufficient room available in the stream's circular buffer, and no data is transferred. - * \param _buffer pointer to a block of memory that will be copied into the stream. - * \param _size the amount of data in bytes to copy to the stream. - * \return true if all the requested data has been copied. False if there was not enough space in - * the stream's circular buffer. - * \see Get, GetDataSize - */ - bool Put( uint8* _buffer, uint32 _size ); - - /** - * Returns the amount of data in bytes that is stored in the stream. - * \return the number of bytes of data in the stream. - * \see Get, GetDataSize - */ - uint32 GetDataSize()const{ return m_dataSize; } - - /** - * Empties the stream bytes held in the buffer. - * This is called when the library gets out of sync with the controller and sends a "NAK" - * to the controller. - */ - void Purge(); - - protected: - /** - * Formats stream buffer data for output to the log. - * \param _buffer pointer to the stream buffer "head" location - * \param _size number of valid bytes currently in the buffer - * \param _function string containing text to display before the data - */ - void LogData( uint8* _buffer, uint32 _size, const string &_function ); - - /** - * Used by the Wait class to test whether the buffer contains sufficient data. - */ - virtual bool IsSignalled(); - - /** - * Destructor. - * Destroys the ring buffer object. - */ - ~Stream(); - - private: - Stream( Stream const& ); // prevent copy - Stream& operator = ( Stream const& ); // prevent assignment - - uint8* m_buffer; - uint32 m_bufferSize; - uint32 m_signalSize; - uint32 m_dataSize; - uint32 m_head; - uint32 m_tail; - Mutex* m_mutex; - }; - -} // namespace OpenZWave - -#endif //_Event_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Thread.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/Thread.cpp deleted file mode 100644 index 8b5cf5d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Thread.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Thread.cpp -// -// Cross-platform threads -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../Defs.h" -#include "Event.h" -#include "Thread.h" - -#ifdef _WIN32 -#include "windows/ThreadImpl.h" // Platform-specific implementation of a thread -#else -#include "unix/ThreadImpl.h" // Platform-specific implementation of a thread -#endif - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Thread::Thread -( - string const& _name -) -{ - m_exitEvent = new Event(); - m_pImpl = new ThreadImpl( this, _name ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Thread::~Thread -( -) -{ - delete m_pImpl; - m_exitEvent->Release(); -} - -//----------------------------------------------------------------------------- -// -// Start a function running on this thread -//----------------------------------------------------------------------------- -bool Thread::Start -( - pfnThreadProc_t _pfnThreadProc, - void* _context -) -{ - return( m_pImpl->Start( _pfnThreadProc, m_exitEvent, _context ) ); -} - -//----------------------------------------------------------------------------- -// -// Stop a function running on this thread -//----------------------------------------------------------------------------- -bool Thread::Stop -( -) -{ - int32 timeout = 2000; // Give the thread 2 seconds to exit - m_exitEvent->Set(); - - if( Wait::Single( this, timeout ) < 0 ) - { - // Timed out - m_pImpl->Terminate(); - return false; - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Causes the thread to sleep for the specified number of milliseconds. -//----------------------------------------------------------------------------- -void Thread::Sleep -( - uint32 _milliseconds -) -{ - return( m_pImpl->Sleep( _milliseconds ) ); -} - -//----------------------------------------------------------------------------- -// -// Test whether the event is set -//----------------------------------------------------------------------------- -bool Thread::IsSignalled -( -) -{ - return m_pImpl->IsSignalled(); -} - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Thread.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Thread.h deleted file mode 100644 index 874845f..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Thread.h +++ /dev/null @@ -1,101 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Thread.h -// -// Cross-platform threads -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _Thread_H -#define _Thread_H - -#include -#include "../Defs.h" -#include "Wait.h" - -namespace OpenZWave -{ - class ThreadImpl; - class Event; - - /** \brief Implements a platform-independent thread management class. - */ - class Thread: public Wait - { - public: - typedef void (*pfnThreadProc_t)( Event* _exitEvent, void* _context ); - - /** - * Constructor. - * Creates a thread object that can be used to serialize access to a shared resource. - */ - Thread( string const& _name ); - - /** - * Start running a function on this thread. - * Attempts to start a function running on this thread. The call will fail if another - * function is already running. - * \param _pThreadProc pointer to the function to be run. The function must take a - * single void pointer as its only argument, and return void. On entry, the pointer - * will be set to the context provided to this Start method. - * \param _context pointer allowing any relevant data to be passed to the thread function. - * \return True if the function was successfully started. - * \see Stop, IsRunning - */ - bool Start( pfnThreadProc_t _pfnThreadProc, void* _context ); - - /** - * Stop a function running on this thread. - * Attempts to stop a function running on this thread. The call will fail if no - * function is running. - * \return True if the function was successfully stopped. - * \see Start, IsRunning - */ - bool Stop(); - - /** - * Causes the thread to sleep for the specified number of milliseconds. - * \param _millisecs Number of milliseconds to sleep. - */ - void Sleep( uint32 _millisecs ); - - protected: - /** - * Used by the Wait class to test whether the thread has been completed. - */ - virtual bool IsSignalled(); - - /** - * Destructor. - * Destroys the Thread object. - */ - virtual ~Thread(); - - private: - ThreadImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a thread. - Event* m_exitEvent; - }; - -} // namespace OpenZWave - -#endif //_Thread_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/TimeStamp.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/TimeStamp.cpp deleted file mode 100644 index 7023b9d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/TimeStamp.cpp +++ /dev/null @@ -1,106 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeStamp.h -// -// Cross-platform TimeStamp -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include "../Defs.h" -#include "TimeStamp.h" - -#ifdef _WIN32 -#include "windows/TimeStampImpl.h" // Platform-specific implementation of a TimeStamp -#else -#include "unix/TimeStampImpl.h" // Platform-specific implementation of a TimeStamp -#endif - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -TimeStamp::TimeStamp -( -): - m_pImpl( new TimeStampImpl() ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -TimeStamp::~TimeStamp -( -) -{ - delete m_pImpl; -} - -//----------------------------------------------------------------------------- -// -// Sets the timestamp to now, plus an offset in milliseconds -//----------------------------------------------------------------------------- -void TimeStamp::SetTime -( - int32 _milliseconds // = 0 -) -{ - m_pImpl->SetTime( _milliseconds ); -} - -//----------------------------------------------------------------------------- -// -// Gets the difference between now and the timestamp time in milliseconds -//----------------------------------------------------------------------------- -int32 TimeStamp::TimeRemaining -( -) -{ - return m_pImpl->TimeRemaining(); -} - -//----------------------------------------------------------------------------- -// -// Return object as a string -//----------------------------------------------------------------------------- -string TimeStamp::GetAsString -( -) -{ - return m_pImpl->GetAsString(); -} -//----------------------------------------------------------------------------- -// -// Overload the subtract operator to get the difference between two -// timestamps in milliseconds -//----------------------------------------------------------------------------- -int32 TimeStamp::operator- -( - TimeStamp const& _other -) -{ - return (int32)(m_pImpl - _other.m_pImpl); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/TimeStamp.h b/lib/ESPiLight/pilight/libs/openzwave/platform/TimeStamp.h deleted file mode 100644 index 8acc647..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/TimeStamp.h +++ /dev/null @@ -1,91 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeStamp.h -// -// Cross-platform TimeStamp -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _TimeStamp_H -#define _TimeStamp_H - -#include "../Defs.h" - -namespace OpenZWave -{ - class TimeStampImpl; - - /** \brief Implements a platform-independent TimeStamp. - */ - class OPENZWAVE_EXPORT TimeStamp - { - public: - /** - * Constructor. - * Creates a TimeStamp object. - */ - TimeStamp(); - - /** - * Destructor. - * Destroys the TimeStamp object. - */ - ~TimeStamp(); - - /** - * SetTime. Sets the timestamp to now, plus the offset in milliseconds. - * \param _milliseconds optional positive or negative offset from - * now in milliseconds. Defaults to zero. - */ - void SetTime( int32 _milliseconds = 0 ); - - /** - * TimeRemaining. Gets the difference between now and the timestamp - * time in milliseconds. - * \return milliseconds remaining until we reach the timestamp. The - * return value is negative if the timestamp is in the past. - */ - int32 TimeRemaining(); - - /** - * Return as a string for output. - * \return string - */ - string GetAsString(); - - /** - * Overload the subtract operator to get the difference between - * two timestamps in milliseconds. - */ - int32 operator- ( TimeStamp const& _other ); - - private: - TimeStamp( TimeStamp const& ); // prevent copy - TimeStamp& operator = ( TimeStamp const& ); // prevent assignment - - TimeStampImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of the TimeStamp. - }; - -} // namespace OpenZWave - -#endif //_TimeStamp_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Wait.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/Wait.cpp deleted file mode 100644 index cae8b39..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Wait.cpp +++ /dev/null @@ -1,182 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Wait.cpp -// -// Base class for objects we want to be able to wait for. -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include "../Defs.h" -#include "Wait.h" -#include "Event.h" -#include "Log.h" - -#ifdef _WIN32 -#include "windows/WaitImpl.h" // Platform-specific implementation of a Wait object -#else -#include "unix/WaitImpl.h" // Platform-specific implementation of a Wait object -#endif - -using namespace OpenZWave; - -void WaitMultipleCallback( void* _context ); - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Wait::Wait -( -) -{ - m_pImpl = new WaitImpl( this ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Wait::~Wait -( -) -{ - delete m_pImpl; -} - -//----------------------------------------------------------------------------- -// -// Add a watcher to our object. -//----------------------------------------------------------------------------- -void Wait::AddWatcher -( - pfnWaitNotification_t _callback, - void* _context -) -{ - if( !_callback ) - { - assert(0); - return; - } - - // Add a ref so our object cannot disappear while being watched - AddRef(); - - // Add the watcher (platform specific code required here for thread safety) - m_pImpl->AddWatcher( _callback, _context ); -} - -//----------------------------------------------------------------------------- -// -// Remove a watcher from our object. -//----------------------------------------------------------------------------- -void Wait::RemoveWatcher -( - pfnWaitNotification_t _callback, - void* _context -) -{ - if( m_pImpl->RemoveWatcher( _callback, _context ) ) - { - Release(); - } -} - -//----------------------------------------------------------------------------- -// -// Notify all the watchers that the object has become signalled -//----------------------------------------------------------------------------- -void Wait::Notify -( -) -{ - m_pImpl->Notify(); -} - -//----------------------------------------------------------------------------- -// -// Wait for one of multiple objects to become signalled. -//----------------------------------------------------------------------------- -int32 Wait::Multiple -( - Wait** _objects, - uint32 _numObjects, - int32 _timeout // = -1 -) -{ - uint32 i; - - // Create an event that will be set when any of the objects in the list becomes signalled. - Event* waitEvent = new Event(); - - // Add a watcher to each object in the list, passing in the event as the context. - for( i=0; i<_numObjects; ++i ) - { - _objects[i]->AddWatcher( WaitMultipleCallback, waitEvent ); - } - - int32 res = -1; // Default to timeout result - string str = ""; - if( waitEvent->Wait( _timeout ) ) - { - // An object was signalled. Run through the list - // and see which one it was. - for( i=0; i<_numObjects; ++i ) - { - if( _objects[i]->IsSignalled() ) - { - if( res == -1 ) - res = (int32)i; - char buf[15]; - snprintf(buf, sizeof(buf), "%d, ", i); - str += buf; - } - } - } - //Log::Write( LogLevel_Debug, "Wait::Multiple res=%d num=%d >%s", res, _numObjects, str.c_str() ); - - // Remove the watchers - for( i=0; i<_numObjects; ++i ) - { - _objects[i]->RemoveWatcher( WaitMultipleCallback, waitEvent ); - } - - // We're done with the event now - waitEvent->Release(); - return res; -} - - -//----------------------------------------------------------------------------- -// -// Callback handler for the watchers added during WaitImpl::Multiple -//----------------------------------------------------------------------------- -void WaitMultipleCallback -( - void* _context -) -{ - Event* waitEvent = (Event*)_context; - waitEvent->Set(); -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/Wait.h b/lib/ESPiLight/pilight/libs/openzwave/platform/Wait.h deleted file mode 100644 index 6321ec3..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/Wait.h +++ /dev/null @@ -1,113 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Wait.h -// -// Cross-platform abstract base class for objects we -// want to be able to wait for. -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _Wait_H -#define _Wait_H - -#include -#include "Ref.h" - -namespace OpenZWave -{ - class WaitImpl; - - /** \brief Platform-independent definition of Wait objects. - */ - class Wait: public Ref - { - friend class WaitImpl; - friend class ThreadImpl; - - public: - enum - { - Timeout_Immediate = 0, - Timeout_Infinite = -1 - }; - - typedef void (*pfnWaitNotification_t)( void* _context ); - - /** - * Add a watcher to our object. The watcher will be triggered - * by the derived class, when it enters a certain state. - * \param _callback pointer to the function that will be called when the wait is over. - * \param _context pointer to custom data that will be sent with the callback. - */ - void AddWatcher( pfnWaitNotification_t _callback, void* _context ); - - /** - * Remove a watcher from our object. Both the _callback and _context pointers - * must match those used in a previous call to AddWatcher. - * \param _callback pointer to the function that will be called when the wait is over. - * \param _context pointer to custom data that will be sent with the callback. - */ - void RemoveWatcher( pfnWaitNotification_t _callback, void* _context ); - - /** - * Wait for a single object to become signalled. - * \param _object pointer to the object to wait on. - * \param _timeout optional maximum time to wait. Defaults to -1, which means wait forever. - * \return zero if the object was signalled, -1 if the wait timed out. - */ - static int32 Single( Wait* _object, int32 _timeout = -1 ){ return Multiple( &_object, 1, _timeout ); } - - /** - * Wait for one of multiple objects to become signalled. If more than one object is in - * a signalled state, the lowest array index will be returned. - * \param _objects array of pointers to objects to wait on. - * \param _numObjects number of objects in the array. - * \param _timeout optional maximum time to wait. Defaults to -1, which means wait forever. - * \return index into the array of the object that was signalled, -1 if the wait timed out. - */ - static int32 Multiple( Wait** _objects, uint32 _numObjects, int32 _timeout = -1 ); - - protected: - Wait(); - virtual ~Wait(); - - /** - * Notify the watchers that the object is signalled. - */ - void Notify(); - - /** - * Test whether an object is signalled. - */ - virtual bool IsSignalled() = 0; - - private: - Wait( Wait const& ); // prevent copy - Wait& operator = ( Wait const& ); // prevent assignment - - WaitImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a Wait object. - }; - -} // namespace OpenZWave - -#endif //_Wait_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/CMakeLists.txt b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/CMakeLists.txt deleted file mode 100644 index 0a79230..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -project(openzwave_platform_unix) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.cpp") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/EventImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/EventImpl.cpp deleted file mode 100644 index 67103c3..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/EventImpl.cpp +++ /dev/null @@ -1,262 +0,0 @@ -//----------------------------------------------------------------------------- -// -// EventImpl.cpp -// -// POSIX implementation of a cross-platform event -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../../Defs.h" -#include "EventImpl.h" - -#include -#include - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -EventImpl::EventImpl -( -): - m_manualReset( true ), - m_isSignaled( false ), - m_waitingThreads( 0 ) -{ - pthread_mutexattr_t ma; - pthread_mutexattr_init( &ma ); - pthread_mutexattr_settype( &ma, PTHREAD_MUTEX_ERRORCHECK ); - pthread_mutex_init( &m_lock, &ma ); - pthread_mutexattr_destroy( &ma ); - - pthread_condattr_t ca; - pthread_condattr_init( &ca ); - pthread_condattr_setpshared( &ca, PTHREAD_PROCESS_PRIVATE ); - pthread_cond_init( &m_condition, &ca ); - pthread_condattr_destroy( &ca ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -EventImpl::~EventImpl -( -) -{ - pthread_mutex_destroy( &m_lock ); - pthread_cond_destroy( &m_condition ); -} - -//----------------------------------------------------------------------------- -// -// Set the event to signalled -//----------------------------------------------------------------------------- -void EventImpl::Set -( -) -{ - int err = pthread_mutex_lock( &m_lock ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Set lock error %d (%d)\n", errno, err ); - assert( 0 ); - } - if( m_manualReset ) - { - m_isSignaled = true; - err = pthread_cond_broadcast( &m_condition ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Set cond broadcast error %d (%d)\n", errno, err ); - assert( 0 ); - } - } - else - { - if( !m_waitingThreads ) - { - m_isSignaled = true; - } - else - { - err = pthread_cond_signal( &m_condition ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Set cond signal error %d (%d)\n", errno, err ); - assert( 0 ); - } - } - } - err = pthread_mutex_unlock( &m_lock ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Set unlock error %d (%d)\n", errno, err ); - assert( 0 ); - } -} - -//----------------------------------------------------------------------------- -// -// Set the event to not signalled -//----------------------------------------------------------------------------- -void EventImpl::Reset -( -) -{ - int err = pthread_mutex_lock ( &m_lock ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Reset lock error %d (%d)\n", errno, err ); - assert( 0 ); - } - m_isSignaled = false; - err = pthread_mutex_unlock( &m_lock ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Reset unlock error %d (%d)\n", errno, err ); - assert( 0 ); - } -} - -//----------------------------------------------------------------------------- -// -// Test whether the event is set -//----------------------------------------------------------------------------- -bool EventImpl::IsSignalled -( -) -{ - return m_isSignaled; -} - -//----------------------------------------------------------------------------- -// -// Wait for the event to become signalled -//----------------------------------------------------------------------------- -bool EventImpl::Wait -( - int32 const _timeout /* milliseconds */ -) -{ - bool result = true; - - int err = pthread_mutex_lock( &m_lock ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Wait lock error %d (%d)\n", errno, err ); - assert( 0 ); - } - if( m_isSignaled ) - { - if ( !m_manualReset ) - { - m_isSignaled = false; - } - } - else - { - ++m_waitingThreads; - if( _timeout == 0 ) - { - result = m_isSignaled; - } - else if( _timeout > 0 ) - { - struct timeval now; - struct timespec abstime; - - gettimeofday(&now, NULL); - - abstime.tv_sec = now.tv_sec + (_timeout / 1000); - - // Now add the remainder of our timeout to the microseconds part of 'now' - now.tv_usec += (_timeout % 1000) * 1000; - - // Careful now! Did it wrap? - while( now.tv_usec >= ( 1000 * 1000 ) ) - { - // Yes it did so bump our seconds and subtract - now.tv_usec -= (1000 * 1000); - abstime.tv_sec++; - } - - abstime.tv_nsec = now.tv_usec * 1000; - - while( !m_isSignaled ) - { - int oldstate; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - - err = pthread_cond_timedwait( &m_condition, &m_lock, &abstime ); - - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); - - if( err == ETIMEDOUT ) - { - result = false; - break; - } - else - if( err == 0 ) - { - result = true; - } - else - { - fprintf(stderr, "EventImpl::Wait cond timedwait error %d (%d)\n", errno, err ); - assert( 0 ); - } - } - } - else - { - while( !m_isSignaled ) - { - int oldstate; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - - err = pthread_cond_wait( &m_condition, &m_lock ); - - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); - - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Wait cond wait error %d (%d)\n", errno, err ); - assert( 0 ); - } - } - } - --m_waitingThreads; - } - - err = pthread_mutex_unlock( &m_lock ); - if( err != 0 ) - { - fprintf(stderr, "EventImpl::Wait unlock error %d (%d)\n", errno, err ); - assert( 0 ); - } - return result; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/EventImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/EventImpl.h deleted file mode 100644 index 0c3859d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/EventImpl.h +++ /dev/null @@ -1,66 +0,0 @@ -//----------------------------------------------------------------------------- -// -// EventImpl.h -// -// POSIX implementation of a cross-platform event -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _EventImpl_H -#define _EventImpl_H - -#ifdef _WIN32 - #include "../../libs/pthreadw32/pthread.h" -#else - #include -#endif -#include - -namespace OpenZWave -{ - class EventImpl - { - private: - friend class Event; - friend class SocketImpl; - friend class Wait; - - EventImpl(); - ~EventImpl(); - - void Set(); - void Reset(); - - bool Wait( int32 _timeout ); // The wait method is to be used only by the Wait::Multiple method - bool IsSignalled(); - - pthread_mutex_t m_lock; - pthread_cond_t m_condition; - bool m_manualReset; - bool m_isSignaled; - unsigned int m_waitingThreads; - }; - -} // namespace OpenZWave - -#endif //_EventImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/FileOpsImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/FileOpsImpl.cpp deleted file mode 100644 index 6cf59d8..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/FileOpsImpl.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// -// FileOpsImpl.cpp -// -// Unix implementation of file operations -// -// Copyright (c) 2012, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include "FileOpsImpl.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -FileOpsImpl::FileOpsImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -FileOpsImpl::~FileOpsImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Determine if a folder exists -//----------------------------------------------------------------------------- -bool FileOpsImpl::FolderExists -( - string _folderName -) -{ - DIR *dirp = opendir( _folderName.c_str() ); - if( dirp != NULL ) - { - closedir( dirp ); - return true; - } - else - return false; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/FileOpsImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/FileOpsImpl.h deleted file mode 100644 index f7466d4..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/FileOpsImpl.h +++ /dev/null @@ -1,52 +0,0 @@ -//----------------------------------------------------------------------------- -// -// FileOpsImpl.h -// -// Unix implementation of file operations -// -// Copyright (c) 2012, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _FileOpsImpl_H -#define _FileOpsImpl_H - -#include -#include -#include "../../Defs.h" -#include "../FileOps.h" - -namespace OpenZWave -{ - class FileOpsImpl - { - friend class FileOps; - - private: - FileOpsImpl(); - ~FileOpsImpl(); - - bool FolderExists( string _filename ); - }; - -} // namespace OpenZWave - -#endif //_FileOpsImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/LogImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/LogImpl.cpp deleted file mode 100644 index 7449562..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/LogImpl.cpp +++ /dev/null @@ -1,326 +0,0 @@ -//----------------------------------------------------------------------------- -// -// LogImpl.cpp -// -// Unix implementation of message and error logging -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include -#ifdef _WIN32 - #include "../../libs/pthreadw32/pthread.h" -#else - #include -#endif -#include -#include "../../Defs.h" -#include "LogImpl.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -LogImpl::LogImpl -( - string const& _filename, - bool const _bAppendLog, - bool const _bConsoleOutput, - LogLevel const _saveLevel, - LogLevel const _queueLevel, - LogLevel const _dumpTrigger -): - m_filename( _filename ), // name of log file - m_bConsoleOutput( _bConsoleOutput ), // true to provide a copy of output to console - m_bAppendLog( _bAppendLog ), // true to append (and not overwrite) any existing log - m_saveLevel( _saveLevel ), // level of messages to log to file - m_queueLevel( _queueLevel ), // level of messages to log to queue - m_dumpTrigger( _dumpTrigger ) // dump queued messages when this level is seen -{ - if ( !m_bAppendLog ) - { - this->pFile = fopen( m_filename.c_str(), "w" ); - } else { - this->pFile = fopen( m_filename.c_str(), "a" ); - } - if( this->pFile == NULL ) - { - std::cerr << "Could Not Open OZW Log File." << std::endl; - } - setlinebuf(stdout); // To prevent buffering and lock contention issues -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -LogImpl::~LogImpl -( -) -{ - fclose( this->pFile ); -} - -//----------------------------------------------------------------------------- -// -// Write to the log -//----------------------------------------------------------------------------- -void LogImpl::Write -( - LogLevel _logLevel, - uint8 const _nodeId, - char const* _format, - va_list _args -) -{ - // create a timestamp string - string timeStr = GetTimeStampString(); - string nodeStr = GetNodeString( _nodeId ); - string loglevelStr = GetLogLevelString(_logLevel); - - // handle this message - if( (_logLevel <= m_queueLevel) || (_logLevel == LogLevel_Internal) ) // we're going to do something with this message... - { - char lineBuf[1024] = {0}; - //int lineLen = 0; - if( _format != NULL && _format[0] != '\0' ) - { - va_list saveargs; - va_copy( saveargs, _args ); - - vsnprintf( lineBuf, sizeof(lineBuf), _format, _args ); - va_end( saveargs ); - } - - // should this message be saved to file (and possibly written to console?) - if( (_logLevel <= m_saveLevel) || (_logLevel == LogLevel_Internal) ) - { - std::string outBuf; - - if ( this->pFile != NULL || m_bConsoleOutput ) - { - if( _logLevel != LogLevel_Internal ) // don't add a second timestamp to display of queued messages - { - outBuf.append(timeStr); - outBuf.append(loglevelStr); - outBuf.append(nodeStr); - outBuf.append(lineBuf); - outBuf.append("\n"); - - } - - // print message to file (and possibly screen) - if( this->pFile != NULL ) - { - fputs( outBuf.c_str(), pFile ); - } - if( m_bConsoleOutput ) - { - fputs( outBuf.c_str(), stdout ); - } - } - } - - if( _logLevel != LogLevel_Internal ) - { - char queueBuf[1024]; - string threadStr = GetThreadId(); - snprintf( queueBuf, sizeof(queueBuf), "%s%s%s", timeStr.c_str(), threadStr.c_str(), lineBuf ); - Queue( queueBuf ); - } - } - - // now check to see if the _dumpTrigger has been hit - if( (_logLevel <= m_dumpTrigger) && (_logLevel != LogLevel_Internal) && (_logLevel != LogLevel_Always) ) - QueueDump(); -} - -//----------------------------------------------------------------------------- -// -// Write to the log queue -//----------------------------------------------------------------------------- -void LogImpl::Queue -( - char const* _buffer -) -{ - string bufStr = _buffer; - m_logQueue.push_back( bufStr ); - - // rudimentary queue size management - if( m_logQueue.size() > 500 ) - { - m_logQueue.pop_front(); - } -} - -//----------------------------------------------------------------------------- -// -// Dump the LogQueue to output device -//----------------------------------------------------------------------------- -void LogImpl::QueueDump -( -) -{ - Log::Write( LogLevel_Always, "" ); - Log::Write( LogLevel_Always, "Dumping queued log messages"); - Log::Write( LogLevel_Always, "" ); - list::iterator it = m_logQueue.begin(); - while( it != m_logQueue.end() ) - { - string strTemp = *it; - Log::Write( LogLevel_Internal, strTemp.c_str() ); - it++; - } - m_logQueue.clear(); - Log::Write( LogLevel_Always, "" ); - Log::Write( LogLevel_Always, "End of queued log message dump"); - Log::Write( LogLevel_Always, "" ); -} - -//----------------------------------------------------------------------------- -// -// Clear the LogQueue -//----------------------------------------------------------------------------- -void LogImpl::QueueClear -( -) -{ - m_logQueue.clear(); -} - -//----------------------------------------------------------------------------- -// -// Sets the various log state variables -//----------------------------------------------------------------------------- -void LogImpl::SetLoggingState -( - LogLevel _saveLevel, - LogLevel _queueLevel, - LogLevel _dumpTrigger -) -{ - m_saveLevel = _saveLevel; - m_queueLevel = _queueLevel; - m_dumpTrigger = _dumpTrigger; -} - -//----------------------------------------------------------------------------- -// -// Generate a string with formatted current time -//----------------------------------------------------------------------------- -string LogImpl::GetTimeStampString -( -) -{ - struct timeval tv; - struct tm tm; - char fmt[64], buf[64], line[256]; - gettimeofday(&tv, NULL); -#ifdef _WIN32 - struct tm *tm1; - if((tm1 = gmtime(&tv.tv_sec)) != 0) { - memcpy(&tm, tm1, sizeof(struct tm)); -#else - if((gmtime_r(&tv.tv_sec, &tm)) != 0) { -#endif - strftime(fmt, sizeof(fmt), "%b %d %H:%M:%S", &tm); - snprintf(buf, sizeof(buf), "%s:%03u", fmt, (unsigned int)tv.tv_usec); - } - sprintf(line, "[%22.22s] %s: [Z-Wave]: ", buf, "pilight-daemon"); - - string str = line; - return str; -} - -//----------------------------------------------------------------------------- -// -// Generate a string with formatted node id -//----------------------------------------------------------------------------- -string LogImpl::GetNodeString -( - uint8 const _nodeId -) -{ - if( _nodeId == 0 ) - { - return ""; - } - else - if( _nodeId == 255 ) // should make distinction between broadcast and controller better for SwitchAll broadcast - { - return "contrlr, "; - } - else - { - char buf[20]; - snprintf( buf, sizeof(buf), "Node%03d, ", _nodeId ); - return buf; - } -} - -//----------------------------------------------------------------------------- -// -// Generate a string with formatted thread id -//----------------------------------------------------------------------------- -string LogImpl::GetThreadId -( -) -{ - char buf[20]; - snprintf( buf, sizeof(buf), "%08lx ", (long unsigned int)pthread_self() ); - string str = buf; - return str; -} - -//----------------------------------------------------------------------------- -// -// Provide a new log file name (applicable to future writes) -//----------------------------------------------------------------------------- -void LogImpl::SetLogFileName -( - const string &_filename -) -{ - m_filename = _filename; -} - - -//----------------------------------------------------------------------------- -// -// Provide a new log file name (applicable to future writes) -//----------------------------------------------------------------------------- -string LogImpl::GetLogLevelString -( - LogLevel _level -) -{ - if ((_level >= LogLevel_None) && (_level <= LogLevel_Internal)) { - char buf[20]; - snprintf( buf, sizeof(buf), "%s, ", LogLevelString[_level] ); - return buf; - } - else - return "Unknown, "; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/LogImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/LogImpl.h deleted file mode 100644 index 7783a7c..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/LogImpl.h +++ /dev/null @@ -1,73 +0,0 @@ -//----------------------------------------------------------------------------- -// -// LogImpl.h -// -// Unix implementation of message and error logging -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _LogImpl_H -#define _LogImpl_H - -#include -#include -#include -#include -#include -#include "../Log.h" - -namespace OpenZWave -{ - class LogImpl : public i_LogImpl - { - private: - friend class Log; - - LogImpl( string const& _filename, bool const _bAppendLog, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger ); - ~LogImpl(); - - void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args ); - void Queue( char const* _buffer ); - void QueueDump(); - void QueueClear(); - void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ); - void SetLogFileName( const string &_filename ); - - string GetTimeStampString(); - string GetNodeString( uint8 const _nodeId ); - string GetThreadId(); - string GetLogLevelString(LogLevel _level); - - string m_filename; /**< filename specified by user (default is ozw_log.txt) */ - bool m_bConsoleOutput; /**< if true, send log output to console as well as to the file */ - bool m_bAppendLog; /**< if true, the log file should be appended to any with the same name */ - list m_logQueue; /**< list of queued log messages */ - LogLevel m_saveLevel; - LogLevel m_queueLevel; - LogLevel m_dumpTrigger; - FILE* pFile; - }; - -} // namespace OpenZWave - -#endif //_LogImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/MutexImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/MutexImpl.cpp deleted file mode 100644 index 2f79de1..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/MutexImpl.cpp +++ /dev/null @@ -1,136 +0,0 @@ -//---------------------------------------------------------------------------- -// -// MutexImpl.cpp -// -// POSIX implementation of the cross-platform mutex -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../../Defs.h" -#include "../Log.h" -#include "MutexImpl.h" - -#include -#include - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -MutexImpl::MutexImpl -( -): - m_lockCount( 0 ) -{ - pthread_mutexattr_t ma; - - pthread_mutexattr_init ( &ma ); - pthread_mutexattr_settype( &ma, PTHREAD_MUTEX_RECURSIVE ); - int err = pthread_mutex_init( &m_criticalSection, &ma ); - if( err != 0 ) - { - fprintf(stderr, "MutexImpl::MutexImpl error %d (%d)\n", errno, err ); - } - pthread_mutexattr_destroy( &ma ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -MutexImpl::~MutexImpl -( -) -{ - pthread_mutex_destroy( &m_criticalSection ); -} - -//----------------------------------------------------------------------------- -// -// Lock the mutex -//----------------------------------------------------------------------------- -bool MutexImpl::Lock -( - bool const _bWait -) -{ - if( _bWait ) - { - // We will wait for the lock - int err = pthread_mutex_lock( &m_criticalSection ); - if( err == 0 ) - { - ++m_lockCount; - return true; - } - fprintf(stderr, "MutexImpl::Lock error %d (%d)\n", errno, err); - return false; - } - - // Returns immediately, even if the lock was not available. - if( pthread_mutex_trylock( &m_criticalSection ) ) - { - return false; - } - - ++m_lockCount; - return true; -} - -//----------------------------------------------------------------------------- -// -// Release our lock on the mutex -//----------------------------------------------------------------------------- -void MutexImpl::Unlock -( -) -{ - if( !m_lockCount ) - { - // No locks - we have a mismatched lock/release pair - assert(0); - } - else - { - --m_lockCount; - int err = pthread_mutex_unlock( &m_criticalSection ); - if( err != 0 ) - { - fprintf(stderr, "MutexImpl::Unlock error %d (%d)\n", errno, err); - } - } -} - -//----------------------------------------------------------------------------- -// -// Test whether the mutex is free -//----------------------------------------------------------------------------- -bool MutexImpl::IsSignalled -( -) -{ - return( 0 == m_lockCount ); -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/MutexImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/MutexImpl.h deleted file mode 100644 index 84bf95e..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/MutexImpl.h +++ /dev/null @@ -1,60 +0,0 @@ -//---------------------------------------------------------------------------- -// -// MutexImpl.h -// -// POSIX implementation of the cross-platform mutex -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _MutexImpl_H -#define _MutexImpl_H - -#include -#ifdef _WIN32 - #include "../../libs/pthreadw32/pthread.h" -#else - #include -#endif - -namespace OpenZWave -{ - class MutexImpl - { - private: - friend class Mutex; - - MutexImpl(); - ~MutexImpl(); - - bool Lock( bool const _bWait = true ); - void Unlock(); - - bool IsSignalled(); - - uint32 m_lockCount; // Keep track of the locks (there can be more than one if they occur on the same thread. - pthread_mutex_t m_criticalSection; - }; - -} // namespace OpenZWave - -#endif //_MutexIF_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/SerialControllerImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/SerialControllerImpl.cpp deleted file mode 100644 index 79538a5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/SerialControllerImpl.cpp +++ /dev/null @@ -1,373 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SerialControllerImpl.cpp -// -// POSIX implementation of a cross-platform serial port -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#ifdef _WIN32 - #include "../../libs/pthreadw32/pthread.h" -#else - #include -#endif -#include "../../Defs.h" -#include "../Thread.h" -#include "../Event.h" -#include "SerialControllerImpl.h" -#include "../Log.h" - -#ifdef __linux__ -#include "../../libudev.h" -#endif - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -SerialControllerImpl::SerialControllerImpl -( - SerialController* _owner -): - m_owner( _owner ), - m_hSerialController( -1 ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -SerialControllerImpl::~SerialControllerImpl -( -) -{ - flock(m_hSerialController, LOCK_UN); - if(m_hSerialController >= 0) - close( m_hSerialController ); -} - -//----------------------------------------------------------------------------- -// -// Open the serial port -//----------------------------------------------------------------------------- -bool SerialControllerImpl::Open -( -) -{ - // Try to init the serial port - if( !Init( 1 ) ) - { - // Failed. We bail to allow the app a chance to take over, rather than retry - // automatically. Automatic retries only occur after a successful init. - return false; - } - - // Start the read thread - m_pThread = new Thread( "SerialController" ); - m_pThread->Start( SerialReadThreadEntryPoint, this ); - - return true; -} - -//----------------------------------------------------------------------------- -// -// Close the serial port -//----------------------------------------------------------------------------- -void SerialControllerImpl::Close -( -) -{ - if( m_pThread ) - { - m_pThread->Stop(); - m_pThread->Release(); - m_pThread = NULL; - } - close( m_hSerialController ); - m_hSerialController = -1; -} - -//----------------------------------------------------------------------------- -// -// Entry point of the thread for receiving data from the serial port -//----------------------------------------------------------------------------- -void SerialControllerImpl::SerialReadThreadEntryPoint -( - Event* _exitEvent, - void* _context -) -{ - SerialControllerImpl* impl = (SerialControllerImpl*)_context; - if( impl ) - { - impl->ReadThreadProc( _exitEvent ); - } -} - -//----------------------------------------------------------------------------- -// -// Handle receiving data -//----------------------------------------------------------------------------- -void SerialControllerImpl::ReadThreadProc -( - Event* _exitEvent -) -{ - uint32 attempts = 0; - while( true ) - { - // Init must have been called successfully during Open, so we - // don't do it again until the end of the loop - if( -1 != m_hSerialController ) - { - // Enter read loop. Call will only return if - // an exit is requested or an error occurs - Read(); - - // Reset the attempts, so we get a rapid retry for temporary errors - attempts = 0; - } - - if( attempts < 25 ) - { - // Retry every 5 seconds for the first two minutes... - if( Wait::Single( _exitEvent, 5000 ) >= 0 ) - { - // Exit signalled. - break; - } - } - else - { - // ...retry every 30 seconds after that - if( Wait::Single( _exitEvent, 30000 ) >= 0 ) - { - // Exit signalled. - break; - } - } - - Init( ++attempts ); - } -} - -//----------------------------------------------------------------------------- -// -// Initialize the serial port -//----------------------------------------------------------------------------- -bool SerialControllerImpl::Init -( - uint32 const _attempts -) -{ - - string device = m_owner->m_serialControllerName; - - Log::Write( LogLevel_Info, "Trying to open serial port %s (attempt %d)", device.c_str(), _attempts ); - - m_hSerialController = open( device.c_str(), O_RDWR | O_NOCTTY, 0 ); - - if( -1 == m_hSerialController ) - { - //Error - Log::Write( LogLevel_Error, "ERROR: Cannot open serial port %s. Error code %d", device.c_str(), errno ); - goto SerialOpenFailure; - } - - if( flock( m_hSerialController, LOCK_EX | LOCK_NB) == -1 ) - { - Log::Write( LogLevel_Error, "ERROR: Cannot get exclusive lock for serial port %s. Error code %d", device.c_str(), errno ); - } - - int bits; - bits = 0; - ioctl( m_hSerialController, TIOCMSET, &bits ); - - // Configure the serial device parameters - // Build on the current configuration - struct termios tios; - - bzero( &tios, sizeof(tios) ); - tcgetattr( m_hSerialController, &tios ); - switch( m_owner->m_parity ) - { - case SerialController::Parity_None: - tios.c_iflag = IGNPAR; - break; - case SerialController::Parity_Odd: - tios.c_iflag = INPCK; - tios.c_cflag = PARENB | PARODD; - break; - default: - Log::Write( LogLevel_Error, "ERROR: Parity not supported" ); - goto SerialOpenFailure; - } - switch( m_owner->m_stopBits ) - { - case SerialController::StopBits_One: - break; // default - case SerialController::StopBits_Two: - tios.c_cflag |= CSTOPB; - break; - default: - Log::Write( LogLevel_Error, "ERROR: Stopbits not supported" ); - goto SerialOpenFailure; - } - tios.c_iflag |= IGNBRK; - tios.c_cflag |= CS8 | CREAD | CLOCAL; - tios.c_oflag = 0; - tios.c_lflag = 0; - for( int i = 0; i < NCCS; i++ ) - tios.c_cc[i] = 0; - tios.c_cc[VMIN] = 0; - tios.c_cc[VTIME] = 1; - switch( m_owner->m_baud ) - { - case 300: - cfsetspeed( &tios, B300 ); - break; - case 1200: - cfsetspeed( &tios, B1200 ); - break; - case 2400: - cfsetspeed( &tios, B2400 ); - break; - case 4800: - cfsetspeed( &tios, B4800 ); - break; - case 9600: - cfsetspeed( &tios, B9600 ); - break; - case 19200: - cfsetspeed( &tios, B19200 ); - break; - case 38400: - cfsetspeed( &tios, B38400 ); - break; - case 57600: - cfsetspeed( &tios, B57600 ); - break; -#ifdef DARWIN - case 76800: - cfsetspeed( &tios, B76800 ); - break; -#endif - case 115200: - cfsetspeed( &tios, B115200 ); - break; - case 230400: - cfsetspeed( &tios, B230400 ); - break; - default: - Log::Write( LogLevel_Error, "Baud rate not supported" ); - goto SerialOpenFailure; - } - if ( tcsetattr( m_hSerialController, TCSANOW, &tios ) == -1 ) - { - // Error. Clean up and exit - Log::Write( LogLevel_Error, "ERROR: Failed to set serial port parameters" ); - goto SerialOpenFailure; - } - - tcflush( m_hSerialController, TCIOFLUSH ); - - // Open successful - Log::Write( LogLevel_Info, "Serial port %s opened (attempt %d)", device.c_str(), _attempts ); - return true; - -SerialOpenFailure: - Log::Write( LogLevel_Error, "ERROR: Failed to open serial port %s", device.c_str() ); - if(m_hSerialController >= 0) - { - close( m_hSerialController ); - m_hSerialController = -1; - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Read data from the serial port -//----------------------------------------------------------------------------- -void SerialControllerImpl::Read -( -) -{ - uint8 buffer[256]; - - while( 1 ) - { - int32 bytesRead; - int err; - - do - { - bytesRead = read( m_hSerialController, buffer, sizeof(buffer) ); - if( bytesRead > 0 ) - m_owner->Put( buffer, bytesRead ); - } while( bytesRead > 0 ); - - do - { - struct timeval *whenp; - fd_set rds, eds; - int oldstate; - - FD_ZERO( &rds ); - FD_SET( m_hSerialController, &rds ); - FD_ZERO( &eds ); - FD_SET( m_hSerialController, &eds ); - whenp = NULL; - - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - err = select( m_hSerialController + 1, &rds, NULL, &eds, whenp ); - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); - } while( err <= 0 ); - } -} - -//----------------------------------------------------------------------------- -// -// Send data to the serial port -//----------------------------------------------------------------------------- -uint32 SerialControllerImpl::Write -( - uint8* _buffer, - uint32 _length -) -{ - if( -1 == m_hSerialController ) - { - //Error - Log::Write( LogLevel_Error, "ERROR: Serial port must be opened before writing" ); - return 0; - } - - // Write the data - uint32 bytesWritten; - bytesWritten = write( m_hSerialController, _buffer, _length); - return bytesWritten; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/SerialControllerImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/SerialControllerImpl.h deleted file mode 100644 index bbfe880..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/SerialControllerImpl.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// SerialControllerImpl.h -// -// POSIX implementation of a cross-platform serial port -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SerialControllerImpl_H -#define _SerialControllerImpl_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../Defs.h" -#include "../SerialController.h" - -namespace OpenZWave -{ - class SerialControllerImpl - { - public: - void ReadThreadProc( Event* _exitEvent ); - - private: - friend class SerialController; - - SerialControllerImpl( SerialController* _owner ); - ~SerialControllerImpl(); - - bool Open(); - void Close(); - - uint32 Write( uint8* _buffer, uint32 _length ); - - bool Init( uint32 const _attempts ); - void Read(); - - SerialController* m_owner; - int m_hSerialController; - Thread* m_pThread; - - static void SerialReadThreadEntryPoint( Event* _exitEvent, void* _content ); - }; - -} // namespace OpenZWave - -#endif //_SerialControllerImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/ThreadImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/ThreadImpl.cpp deleted file mode 100644 index af2b928..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/ThreadImpl.cpp +++ /dev/null @@ -1,183 +0,0 @@ -//---------------------------------------------------------------------------- -// -// ThreadImpl.h -// -// POSIX implementation of a cross-platform thread -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include "../../Defs.h" -#include "../Event.h" -#include "../Thread.h" -#include "ThreadImpl.h" - -#ifdef DARWIN -#define pthread_yield pthread_yield_np -#endif - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ThreadImpl::ThreadImpl -( - Thread* _owner, - string const& _tname -): - m_owner( _owner ), -// m_hThread( NULL ), /* p_thread_t isn't a pointer in Linux, so can't do this */ - m_bIsRunning( false ), - m_name( _tname ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -ThreadImpl::~ThreadImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Start a function running on this thread -//----------------------------------------------------------------------------- -bool ThreadImpl::Start -( - Thread::pfnThreadProc_t _pfnThreadProc, - Event* _exitEvent, - void* _pContext -) -{ - pthread_attr_t ta; - - pthread_attr_init( &ta ); - pthread_attr_setstacksize ( &ta, 0 ); - pthread_attr_setdetachstate ( &ta, PTHREAD_CREATE_JOINABLE ); - - // Create a thread to run the specified function - m_pfnThreadProc = _pfnThreadProc; - m_pContext = _pContext; - m_exitEvent = _exitEvent; - m_exitEvent->Reset(); - - pthread_create ( &m_hThread, &ta, ThreadImpl::ThreadProc, this ); - pthread_detach( m_hThread ); - //fprintf(stderr, "thread %s starting %08x\n", m_name.c_str(), m_hThread); - //fflush(stderr); - - pthread_attr_destroy ( &ta ); - return true; -} - -//----------------------------------------------------------------------------- -// -// End this thread -//----------------------------------------------------------------------------- -bool ThreadImpl::Terminate -( -) -{ - // void* data = NULL; - - //fprintf(stderr, "thread %s stopping %08x running %d\n", m_name.c_str(), m_hThread, m_bIsRunning ); - //fflush(stderr); - if( !m_bIsRunning ) - { - return false; - } - - // This will kill an app that doesn't catch and ignore it. - // We need to find another way to interrupt select. - // thread_kill( m_hThread, SIGALRM ); - - //m_hThread = NULL; - m_bIsRunning = false; - - // pthread_cancel( m_hThread ); - // pthread_join( m_hThread, &data ); - - return true; -} - -//----------------------------------------------------------------------------- -// -// Cause thread to sleep for the specified number of milliseconds -//----------------------------------------------------------------------------- -void ThreadImpl::Sleep -( - uint32 _millisecs -) -{ - usleep( _millisecs*1000 ); -} - -//----------------------------------------------------------------------------- -// -// Test whether the thread has completed -//----------------------------------------------------------------------------- -bool ThreadImpl::IsSignalled -( -) -{ - return !m_bIsRunning; -} - -//----------------------------------------------------------------------------- -// -// Entry point for running a function on this thread -//----------------------------------------------------------------------------- -void *ThreadImpl::ThreadProc -( - void* _pArg -) -{ - ThreadImpl* pImpl = (ThreadImpl*)_pArg; - //fprintf(stderr, "thread %s run begin %08x running %d\n", pImpl->m_name.c_str(), pImpl->m_hThread, pImpl->m_bIsRunning ); - //fflush(stderr); - pImpl->Run(); - //fprintf(stderr, "thread %s run end %08x running %d\n", pImpl->m_name.c_str(), pImpl->m_hThread, pImpl->m_bIsRunning ); - //fflush(stderr); - return 0; -} - -//----------------------------------------------------------------------------- -// -// Entry point for running a function on this thread -//----------------------------------------------------------------------------- -void ThreadImpl::Run -( -) -{ - m_bIsRunning = true; - m_pfnThreadProc( m_exitEvent, m_pContext ); - m_bIsRunning = false; - - // Let any watchers know that the thread has finished running - m_owner->Notify(); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/ThreadImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/ThreadImpl.h deleted file mode 100644 index 9d0c6bb..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/ThreadImpl.h +++ /dev/null @@ -1,71 +0,0 @@ -//---------------------------------------------------------------------------- -// -// ThreadImpl.h -// -// POSIX implementation of a cross-platform thread -// -// Copyright (c) 2010, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _ThreadImpl_H -#define _ThreadImpl_H - -#include -#include -#ifdef _WIN32 - #include "../../libs/pthreadw32/pthread.h" -#else - #include -#endif -#include - -namespace OpenZWave -{ - class Thread; - class Event; - - class ThreadImpl - { - private: - friend class Thread; - - ThreadImpl( Thread* _owner, string const& _tname ); - ~ThreadImpl(); - - bool Start( Thread::pfnThreadProc_t _pfnThreadProc, Event* _exitEvent, void* _context ); - void Sleep( uint32 _millisecs ); - bool IsSignalled(); - bool Terminate(); - - void Run(); - static void* ThreadProc( void *parg); - - Thread* m_owner; - Event* m_exitEvent; - pthread_t m_hThread; - Thread::pfnThreadProc_t m_pfnThreadProc; - void* m_pContext; - bool m_bIsRunning; - string m_name; - }; -} // namespace OpenZWave - -#endif //_ThreadImpl_H diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/TimeStampImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/TimeStampImpl.cpp deleted file mode 100644 index 5390f5a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/TimeStampImpl.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeStampImpl.cpp -// -// OSX implementation of a TimeStamp -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include -#include "../../Defs.h" -#include "TimeStampImpl.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -TimeStampImpl::TimeStampImpl -( -) -{ - SetTime(0); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -TimeStampImpl::~TimeStampImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Sets the timestamp to now, plus an offset in milliseconds -//----------------------------------------------------------------------------- -void TimeStampImpl::SetTime -( - int32 _milliseconds // = 0 -) -{ - struct timeval now; - gettimeofday(&now, NULL); - - m_stamp.tv_sec = now.tv_sec + (_milliseconds / 1000); - - // Now add the remainder of our timeout to the microseconds part of 'now' - now.tv_usec += ((_milliseconds % 1000) * 1000); - - // Careful now! Did it wrap? - if(now.tv_usec >= 1000000) - { - // Yes it did so bump our seconds and modulo - now.tv_usec %= 1000000; - m_stamp.tv_sec++; - } - - m_stamp.tv_nsec = now.tv_usec * 1000; -} - -//----------------------------------------------------------------------------- -// -// Gets the difference between now and the timestamp time in milliseconds -//----------------------------------------------------------------------------- -int32 TimeStampImpl::TimeRemaining -( -) -{ - int32 diff; - - struct timeval now; - gettimeofday(&now, NULL); - - // Seconds - diff = (int32)((m_stamp.tv_sec - now.tv_sec)*1000); - - // Milliseconds - diff += (((m_stamp.tv_nsec/1000)-now.tv_usec)/1000); - - return diff; -} - -//----------------------------------------------------------------------------- -// -// Return a string representation -//----------------------------------------------------------------------------- -string TimeStampImpl::GetAsString -( -) -{ - char str[100]; - struct tm *tm; - tm = localtime( &m_stamp.tv_sec ); - - snprintf( str, sizeof(str), "%04d-%02d-%02d %02d:%02d:%02d:%03d ", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(m_stamp.tv_nsec / (1000*1000)) ); - return str; -} - -//----------------------------------------------------------------------------- -// -// Overload the subtract operator to get the difference between two -// timestamps in milliseconds -//----------------------------------------------------------------------------- -int32 TimeStampImpl::operator- -( - TimeStampImpl const& _other -) -{ - // Seconds - int32 diff = (int32)((m_stamp.tv_sec-_other.m_stamp.tv_sec)*1000); - - // Milliseconds - diff += ((m_stamp.tv_nsec - _other.m_stamp.tv_nsec)/1000000); - - return diff; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/TimeStampImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/TimeStampImpl.h deleted file mode 100644 index 67a822d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/TimeStampImpl.h +++ /dev/null @@ -1,91 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeStampImpl.h -// -// OSX implementation of a TimeStamp -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _TimeStampImpl_H -#define _TimeStampImpl_H - -#include -#include -#include -#include "../../Defs.h" - -namespace OpenZWave -{ - /** \brief Windows implementation of a timestamp. - */ - class TimeStampImpl - { - public: - /** - * Constructor. - * Creates a TimeStampImpl object. - */ - TimeStampImpl(); - - /** - * Destructor. - * Destroys the TimeStampImpl object. - */ - ~TimeStampImpl(); - - /** - * SetTime. Sets the timestamp to now, plus the offset in milliseconds. - * \param _milliseconds positive or negative offset from - * now in milliseconds. - */ - void SetTime( int32 _milliseconds ); - - /** - * TimeRemaining. Gets the difference between now and the timestamp - * time in milliseconds. - * \return milliseconds remaining until we reach the timestamp. The - * return value is negative if the timestamp is in the past. - */ - int32 TimeRemaining(); - - /** - * Return as as string - */ - string GetAsString(); - - /** - * Overload the subtract operator to get the difference between - * two timestamps in milliseconds. - */ - int32 operator- ( TimeStampImpl const& _other ); - - private: - TimeStampImpl( TimeStampImpl const& ); // prevent copy - TimeStampImpl& operator = ( TimeStampImpl const& ); // prevent assignment - - struct timespec m_stamp; - }; - -} // namespace OpenZWave - -#endif //_TimeStampImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/WaitImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/WaitImpl.cpp deleted file mode 100644 index 3b50f4a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/WaitImpl.cpp +++ /dev/null @@ -1,160 +0,0 @@ -//----------------------------------------------------------------------------- -// -// WaitImpl.cpp -// -// POSIX implementation of an abstract base class for objects we -// want to be able to wait for. -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../../Defs.h" -#include "../Wait.h" -#include "WaitImpl.h" - -#include -#include - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -WaitImpl::WaitImpl -( - Wait* _owner -): - m_owner( _owner ) -{ - pthread_mutexattr_t ma; - pthread_mutexattr_init ( &ma ); - pthread_mutexattr_settype( &ma, PTHREAD_MUTEX_RECURSIVE ); - pthread_mutex_init( &m_criticalSection, &ma ); - pthread_mutexattr_destroy( &ma ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -WaitImpl::~WaitImpl -( -) -{ - pthread_mutex_destroy( &m_criticalSection ); -} - -//----------------------------------------------------------------------------- -// -// Add a watcher to our object. -//----------------------------------------------------------------------------- -void WaitImpl::AddWatcher -( - Wait::pfnWaitNotification_t _callback, - void* _context -) -{ - // Add the watcher to our list - Watcher watcher; - watcher.m_callback = _callback; - watcher.m_context = _context; - - if( pthread_mutex_lock( &m_criticalSection ) != 0 ) - { - fprintf(stderr, "WaitImpl::AddWatcher lock error %d\n", errno ); - assert( 0 ); - } - m_watchers.push_back( watcher ); - if( pthread_mutex_unlock( &m_criticalSection ) != 0 ) - { - fprintf(stderr, "WaitImpl::AddWatcher unlock error %d\n", errno ); - assert( 0 ); - } - - // If the object is already in a signalled state, notify the watcher immediately - if( m_owner->IsSignalled() ) - { - _callback( _context ); - } -} - -//----------------------------------------------------------------------------- -// -// Remove a watcher from our object. -//----------------------------------------------------------------------------- -bool WaitImpl::RemoveWatcher -( - Wait::pfnWaitNotification_t _callback, - void* _context -) -{ - bool res = false; - - if( pthread_mutex_lock( &m_criticalSection ) != 0 ) - { - fprintf(stderr, "WaitImpl::RemoveWatcher lock error %d\n", errno ); - assert( 0 ); - } - - for( list::iterator it=m_watchers.begin(); it!=m_watchers.end(); ++it ) - { - Watcher const& watcher = *it; - if( ( watcher.m_callback == _callback ) && ( watcher.m_context == _context ) ) - { - m_watchers.erase( it ); - res = true; - break; - } - } - - if( pthread_mutex_unlock( &m_criticalSection ) != 0 ) - { - fprintf(stderr, "WaitImpl::RemoveWatcher unlock error %d\n", errno ); - assert( 0 ); - } - return res; -} - -//----------------------------------------------------------------------------- -// -// Notify all the watchers that the object has become signalled -//----------------------------------------------------------------------------- -void WaitImpl::Notify -( -) -{ - if( pthread_mutex_lock( &m_criticalSection ) != 0 ) - { - fprintf(stderr, "WaitImpl::Notify lock error %d\n", errno ); - assert( 0 ); - } - for( list::iterator it=m_watchers.begin(); it!=m_watchers.end(); ++it ) - { - Watcher const& watcher = *it; - watcher.m_callback( watcher.m_context ); - } - if( pthread_mutex_unlock( &m_criticalSection ) != 0 ) - { - fprintf(stderr, "WaitImpl::Notify unlock error %d\n", errno ); - assert( 0 ); - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/WaitImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/unix/WaitImpl.h deleted file mode 100644 index 8734870..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/unix/WaitImpl.h +++ /dev/null @@ -1,78 +0,0 @@ -//----------------------------------------------------------------------------- -// -// WaitImpl.h -// -// POSIX implementation of a base class for objects we -// want to be able to wait for. -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _WaitImpl_H -#define _WaitImpl_H - -#include -#ifdef _WIN32 - #include "../../libs/pthreadw32/pthread.h" -#else - #include -#endif -#include -#include "../../Defs.h" -#include "../Ref.h" -#include "../Wait.h" - -namespace OpenZWave -{ - /** \brief Windows specific implementation of Wait objects. - */ - class WaitImpl - { - private: - friend class Wait; - - WaitImpl( Wait* _owner ); - virtual ~WaitImpl(); - - void AddWatcher( Wait::pfnWaitNotification_t _callback, void* _context ); - bool RemoveWatcher( Wait::pfnWaitNotification_t _callback, void* _context ); - void Notify(); - - static int32 Multiple( Wait** _objects, uint32 _numObjects, int32 _timeout = -1 ); - - WaitImpl( Wait const& ); // prevent copy - WaitImpl& operator = ( WaitImpl const& ); // prevent assignment - - struct Watcher - { - Wait::pfnWaitNotification_t m_callback; - void* m_context; - }; - - list m_watchers; - Wait* m_owner; - pthread_mutex_t m_criticalSection; - }; - -} // namespace OpenZWave - -#endif //_WaitImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/CMakeLists.txt b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/CMakeLists.txt deleted file mode 100644 index ace172d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -project(openzwave_platform_windows) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.cpp") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/EventImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/EventImpl.cpp deleted file mode 100644 index df8d4ec..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/EventImpl.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//----------------------------------------------------------------------------- -// -// EventImpl.cpp -// -// Windows implementation of a cross-platform event -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include - -#include "../../Defs.h" -#include "EventImpl.h" - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -EventImpl::EventImpl -( -) -{ - // Create a manual reset event - m_hEvent = ::CreateEvent( NULL, TRUE, FALSE, NULL ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -EventImpl::~EventImpl -( -) -{ - ::CloseHandle( m_hEvent ); -} - -//----------------------------------------------------------------------------- -// -// Set the event to signalled -//----------------------------------------------------------------------------- -void EventImpl::Set -( -) -{ - ::SetEvent( m_hEvent ); -} - -//----------------------------------------------------------------------------- -// -// Set the event to not signalled -//----------------------------------------------------------------------------- -void EventImpl::Reset -( -) -{ - ::ResetEvent( m_hEvent ); -} - -//----------------------------------------------------------------------------- -// -// Test whether the event is set -//----------------------------------------------------------------------------- -bool EventImpl::IsSignalled -( -) -{ - return( WAIT_OBJECT_0 == WaitForSingleObject( m_hEvent, 0 ) ); -} - -//----------------------------------------------------------------------------- -// -// Wait for the event to become signalled -//----------------------------------------------------------------------------- -bool EventImpl::Wait -( - int32 const _timeout -) -{ - return( WAIT_TIMEOUT != ::WaitForSingleObject( m_hEvent, (DWORD)_timeout ) ); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/EventImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/EventImpl.h deleted file mode 100644 index 0ba7ee5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/EventImpl.h +++ /dev/null @@ -1,60 +0,0 @@ -//----------------------------------------------------------------------------- -// -// EventImpl.h -// -// Windows implementation of a cross-platform event -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _EventImpl_H -#define _EventImpl_H - -#include -#include "../../Defs.h" - -namespace OpenZWave -{ - /** \brief Windows-specific implementation of the Event class. - */ - class EventImpl - { - private: - friend class Event; - friend class SocketImpl; - friend class Wait; - - EventImpl(); - ~EventImpl(); - - void Set(); - void Reset(); - - bool Wait( int32 _timeout ); // The wait method is to be used only by the Wait::Multiple method - bool IsSignalled(); - - HANDLE m_hEvent; - }; - -} // namespace OpenZWave - -#endif //_EventImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/FileOpsImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/FileOpsImpl.cpp deleted file mode 100644 index e3d56b9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/FileOpsImpl.cpp +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------------- -// -// FileOpsImpl.cpp -// -// Unix implementation of file operations -// -// Copyright (c) 2012, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include "FileOpsImpl.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -FileOpsImpl::FileOpsImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -FileOpsImpl::~FileOpsImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Determine if a folder exists -//----------------------------------------------------------------------------- -bool FileOpsImpl::FolderExists( - const string &_folderName -) -{ - int32 ftype = GetFileAttributesA(_folderName.c_str()); - if( ftype == INVALID_FILE_ATTRIBUTES ) - return false; // something is wrong with _foldername path - if( ftype & FILE_ATTRIBUTE_DIRECTORY ) - return true; - - return false; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/FileOpsImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/FileOpsImpl.h deleted file mode 100644 index 13b90d0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/FileOpsImpl.h +++ /dev/null @@ -1,52 +0,0 @@ -//----------------------------------------------------------------------------- -// -// FileOpsImpl.h -// -// Unix implementation of file operations -// -// Copyright (c) 2012, Greg Satz -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _FileOpsImpl_H -#define _FileOpsImpl_H - -#include -#include -#include "../../Defs.h" -#include "../FileOps.h" - -namespace OpenZWave -{ - class FileOpsImpl - { - friend class FileOps; - - private: - FileOpsImpl(); - ~FileOpsImpl(); - - bool FolderExists( const string &_filename ); - }; - -} // namespace OpenZWave - -#endif //_FileOpsImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/LogImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/LogImpl.cpp deleted file mode 100644 index 9d3ce62..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/LogImpl.cpp +++ /dev/null @@ -1,362 +0,0 @@ -//----------------------------------------------------------------------------- -// -// LogImpl.cpp -// -// Windows implementation of message and error logging -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include -#include -#include - -#include "../../Defs.h" -#include "LogImpl.h" - -#ifdef _WIN32 - -#define vsprintf_s vsnprintf -#define sprintf_s snprintf - -#define strcpy_s(DEST, NUM, SOURCE) strncpy(DEST, SOURCE, NUM) - -errno_t fopen_s(FILE** pFile, const char *filename, const char *mode) -{ - if (!pFile) - { - _set_errno(EINVAL); - return EINVAL; - } - - *pFile = fopen(filename, mode); - - if (!*pFile) - { - return errno; - } - - return 0; -} - -#endif - - - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -LogImpl::LogImpl -( - string const& _filename, - bool const _bAppendLog, - bool const _bConsoleOutput, - LogLevel const _saveLevel, - LogLevel const _queueLevel, - LogLevel const _dumpTrigger -): - m_filename( _filename ), // name of log file - m_bAppendLog( _bAppendLog ), // true to append (and not overwrite) any existing log - m_bConsoleOutput( _bConsoleOutput ), // true to provide a copy of output to console - m_saveLevel( _saveLevel ), // level of messages to log to file - m_queueLevel( _queueLevel ), // level of messages to log to queue - m_dumpTrigger( _dumpTrigger ) // dump queued messages when this level is seen -{ - string accessType; - - // create an adjusted file name and timestamp string - string timeStr = GetTimeStampString(); - - if ( m_bAppendLog ) - { - accessType = "a"; - } - else - { - accessType = "w"; - } - - FILE* pFile; - if( !fopen_s( &pFile, _filename.c_str(), accessType.c_str() ) ) - { - fprintf( pFile, "\nLogging started %s\n\n", timeStr.c_str() ); - fclose( pFile ); - } -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -LogImpl::~LogImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Write to the log -//----------------------------------------------------------------------------- -void LogImpl::Write -( - LogLevel _logLevel, - uint8 const _nodeId, - char const* _format, - va_list _args -) -{ - // create a timestamp string - string timeStr = GetTimeStampString(); - string nodeStr = GetNodeString( _nodeId ); - string logLevelStr = GetLogLevelString(_logLevel); - - // handle this message - if( (_logLevel <= m_queueLevel) || (_logLevel == LogLevel_Internal) ) // we're going to do something with this message... - { - char lineBuf[1024]; - if( !_format || ( _format[0] == 0 ) ) - { - strcpy_s( lineBuf, 1024, "" ); - } - else - { - vsprintf_s( lineBuf, sizeof(lineBuf), _format, _args ); - } - - // should this message be saved to file (and possibly written to console?) - if( (_logLevel <= m_saveLevel) || (_logLevel == LogLevel_Internal) ) - { - // save to file - FILE* pFile = NULL; - if( !fopen_s( &pFile, m_filename.c_str(), "a" ) || m_bConsoleOutput ) - { - if( _logLevel != LogLevel_Internal ) // don't add a second timestamp to display of queued messages - { - if( pFile != NULL ) - { - fprintf( pFile, "%s%s%s", timeStr.c_str(), logLevelStr.c_str(), nodeStr.c_str() ); - } - if( m_bConsoleOutput ) - { - printf( "%s%s%s", timeStr.c_str(), logLevelStr.c_str(), nodeStr.c_str() ); - } - } - - // print message to file (and possibly screen) - if( pFile != NULL ) - { - fprintf( pFile, "%s", lineBuf ); - fprintf( pFile, "\n" ); - fclose( pFile ); - } - if( m_bConsoleOutput ) - { - printf( "%s", lineBuf ); - printf( "\n" ); - } - - } - } - - if( _logLevel != LogLevel_Internal ) - { - char queueBuf[1024]; - string threadStr = GetThreadId(); - sprintf_s( queueBuf, sizeof(queueBuf), "%s%s%s", timeStr.c_str(), threadStr.c_str(), lineBuf ); - Queue( queueBuf ); - } - } - - // now check to see if the _dumpTrigger has been hit - if( (_logLevel <= m_dumpTrigger) && (_logLevel != LogLevel_Internal) && (_logLevel != LogLevel_Always) ) - { - QueueDump(); - } -} - -//----------------------------------------------------------------------------- -// -// Write to the log queue -//----------------------------------------------------------------------------- -void LogImpl::Queue -( - char const* _buffer -) -{ - string bufStr = _buffer; - m_logQueue.push_back( bufStr ); - - // rudimentary queue size management - if( m_logQueue.size() > 500 ) - { - m_logQueue.pop_front(); - } -} - -//----------------------------------------------------------------------------- -// -// Dump the LogQueue to output device -//----------------------------------------------------------------------------- -void LogImpl::QueueDump -( -) -{ - Log::Write( LogLevel_Internal, "\n\nDumping queued log messages\n"); - list::iterator it = m_logQueue.begin(); - while( it != m_logQueue.end() ) - { - string strTemp = *it; - Log::Write( LogLevel_Internal, strTemp.c_str() ); - ++it; - } - m_logQueue.clear(); - Log::Write( LogLevel_Internal, "\nEnd of queued log message dump\n\n"); -} - -//----------------------------------------------------------------------------- -// -// Clear the LogQueue -//----------------------------------------------------------------------------- -void LogImpl::QueueClear -( -) -{ - m_logQueue.clear(); -} - -//----------------------------------------------------------------------------- -// -// Sets the various log state variables -//----------------------------------------------------------------------------- -void LogImpl::SetLoggingState -( - LogLevel _saveLevel, - LogLevel _queueLevel, - LogLevel _dumpTrigger -) -{ - m_saveLevel = _saveLevel; - m_queueLevel = _queueLevel; - m_dumpTrigger = _dumpTrigger; -} - -//----------------------------------------------------------------------------- -// -// Generate a string with formatted current time -//----------------------------------------------------------------------------- -string LogImpl::GetTimeStampString -( -) -{ - struct timeval tv; - struct tm tm; - char fmt[64], buf[64], line[256]; - gettimeofday(&tv, NULL); -#ifdef _WIN32 - struct tm *tm1; - if((tm1 = gmtime(&tv.tv_sec)) != 0) { - memcpy(&tm, tm1, sizeof(struct tm)); -#else - if((gmtime_r(&tv.tv_sec, &tm)) != 0) { -#endif - strftime(fmt, sizeof(fmt), "%b %d %H:%M:%S", &tm); - snprintf(buf, sizeof(buf), "%s:%03u", fmt, (unsigned int)tv.tv_usec); - } - sprintf(line, "[%22.22s] %s: [Z-Wave]: ", buf, "pilight-daemon"); - - string str = line; - return str; -} - -//----------------------------------------------------------------------------- -// -// Generate a string with formatted node id -//----------------------------------------------------------------------------- -string LogImpl::GetNodeString -( - uint8 const _nodeId -) -{ - if( _nodeId == 0 ) - { - return ""; - } - else - if( _nodeId == 255 ) // should make distinction between broadcast and controller better for SwitchAll broadcast - { - return "contrlr, "; - } - else - { - char buf[20]; - snprintf( buf, sizeof(buf), "Node%03d, ", _nodeId ); - return buf; - } -} - -//----------------------------------------------------------------------------- -// -// Generate a string with formatted thread id -//----------------------------------------------------------------------------- -string LogImpl::GetThreadId -( -) -{ - char buf[20]; - DWORD dwThread = ::GetCurrentThreadId(); - sprintf_s( buf, sizeof(buf), "%04d ", dwThread ); - string str = buf; - return str; -} - -//----------------------------------------------------------------------------- -// -// Provide a new log file name (applicable to future writes) -//----------------------------------------------------------------------------- -void LogImpl::SetLogFileName -( - const string &_filename -) -{ - m_filename = _filename; -} -//----------------------------------------------------------------------------- -// -// Provide a new log file name (applicable to future writes) -//----------------------------------------------------------------------------- -string LogImpl::GetLogLevelString -( - LogLevel _level -) -{ - if ((_level >= LogLevel_None) && (_level <= LogLevel_Internal)) { - char buf[20]; - snprintf( buf, sizeof(buf), "%s, ", LogLevelString[_level] ); - return buf; - } - else - return "Unknown, "; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/LogImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/LogImpl.h deleted file mode 100644 index 3d09d51..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/LogImpl.h +++ /dev/null @@ -1,72 +0,0 @@ -//----------------------------------------------------------------------------- -// -// LogImpl.h -// -// Windows implementation of message and error logging -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _LogImpl_H -#define _LogImpl_H - -#include "../../Defs.h" -#include -#include "../Log.h" -#include - -namespace OpenZWave -{ - /** \brief Windows-specific implementation of the Log class. - */ - class LogImpl : public i_LogImpl - { - private: - friend class Log; - - LogImpl( string const& _filename, bool const _bAppendLog, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger ); - ~LogImpl(); - - void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args ); - void Queue( char const* _buffer ); - void QueueDump(); - void QueueClear(); - void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ); - void SetLogFileName( const string &_filename ); - - string GetTimeStampString(); - string GetNodeString( uint8 const _nodeId ); - string GetThreadId(); - string GetLogLevelString(LogLevel _level); - - string m_filename; /**< filename specified by user (default is ozw_log.txt) */ - bool m_bConsoleOutput; /**< if true, send log output to console as well as to the file */ - bool m_bAppendLog; /**< if true, the log file should be appended to any with the same name */ - list m_logQueue; /**< list of queued log messages */ - LogLevel m_saveLevel; - LogLevel m_queueLevel; - LogLevel m_dumpTrigger; - }; - -} // namespace OpenZWave - -#endif //_LogImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/MutexImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/MutexImpl.cpp deleted file mode 100644 index 4d8dd8a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/MutexImpl.cpp +++ /dev/null @@ -1,114 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MutexImpl.cpp -// -// Windows Implementation of the cross-platform mutex -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../../Defs.h" -#include "MutexImpl.h" - - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -MutexImpl::MutexImpl -( -): - m_lockCount( 0 ) -{ - InitializeCriticalSection( &m_criticalSection ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -MutexImpl::~MutexImpl -( -) -{ - DeleteCriticalSection( &m_criticalSection ); -} - -//----------------------------------------------------------------------------- -// -// Lock the mutex -//----------------------------------------------------------------------------- -bool MutexImpl::Lock -( - bool const _bWait // = true; -) -{ - if( _bWait ) - { - // We will wait for the lock - EnterCriticalSection( &m_criticalSection ); - ++m_lockCount; - return true; - } - - // Returns immediately, even if the lock was not available. - if( TryEnterCriticalSection( &m_criticalSection ) ) - { - ++m_lockCount; - return true; - } - - return false; -} - -//----------------------------------------------------------------------------- -// -// Release our lock on the mutex -//----------------------------------------------------------------------------- -void MutexImpl::Unlock -( -) -{ - if( !m_lockCount ) - { - // No locks - we have a mismatched lock/release pair - assert(0); - } - else - { - --m_lockCount; - LeaveCriticalSection( &m_criticalSection ); - } -} - -//----------------------------------------------------------------------------- -// -// Test whether the mutex is free -//----------------------------------------------------------------------------- -bool MutexImpl::IsSignalled -( -) -{ - return( 0 == m_lockCount ); -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/MutexImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/MutexImpl.h deleted file mode 100644 index 0f4f780..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/MutexImpl.h +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -// -// MutexImpl.h -// -// Windows Implementation of the cross-platform mutex -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _MutexImpl_H -#define _MutexImpl_H - -#include - - -namespace OpenZWave -{ - /** \brief Windows-specific implementation of the Mutex class. - */ - class MutexImpl - { - private: - friend class Mutex; - - MutexImpl(); - ~MutexImpl(); - - bool Lock( bool const _bWait = true ); - void Unlock(); - - bool IsSignalled(); - - CRITICAL_SECTION m_criticalSection; - uint32 m_lockCount; // Keep track of the locks (there can be more than one if they occur on the same thread. - }; - -} // namespace OpenZWave - -#endif //_MutexIF_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/SerialControllerImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/SerialControllerImpl.cpp deleted file mode 100644 index 8aa33ab..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/SerialControllerImpl.cpp +++ /dev/null @@ -1,410 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SerialControllerImpl.cpp -// -// Windows Implementation of the cross-platform serial port -// -// Copyright (c) 2010 Jason Frazier -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../../Defs.h" -#include "SerialControllerImpl.h" - -#include "../Log.h" - -using namespace OpenZWave; - -DWORD WINAPI SerialReadThreadEntryPoint( void* _context ); - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -SerialControllerImpl::SerialControllerImpl -( - SerialController* _owner -): - m_owner( _owner ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -SerialControllerImpl::~SerialControllerImpl -( -) -{ - CloseHandle( m_hSerialController ); -} - -//----------------------------------------------------------------------------- -// -// Open the serial port -//----------------------------------------------------------------------------- -bool SerialControllerImpl::Open -( -) -{ - // Try to init the serial port - if( !Init( 1 ) ) - { - // Failed. We bail to allow the app a chance to take over, rather than retry - // automatically. Automatic retries only occur after a successful init. - return false; - } - - // Create an event to trigger exiting the read thread - m_hExit = ::CreateEvent( NULL, TRUE, FALSE, NULL ); - - // Start the read thread - m_hThread = ::CreateThread( NULL, 0, SerialReadThreadEntryPoint, this, CREATE_SUSPENDED, NULL ); - ::ResumeThread( m_hThread ); - - return true; -} - -//----------------------------------------------------------------------------- -// -// Close the serial port -//----------------------------------------------------------------------------- -void SerialControllerImpl::Close -( -) -{ - ::SetEvent( m_hExit ); - ::WaitForSingleObject( m_hThread, INFINITE ); - - CloseHandle( m_hThread ); - m_hThread = INVALID_HANDLE_VALUE; - - CloseHandle( m_hExit ); - m_hExit = INVALID_HANDLE_VALUE; - - CloseHandle( m_hSerialController ); - m_hSerialController = INVALID_HANDLE_VALUE; -} - -//----------------------------------------------------------------------------- -// -// Entry point of the thread for receiving data from the serial port -//----------------------------------------------------------------------------- -DWORD WINAPI SerialReadThreadEntryPoint -( - void* _context -) -{ - SerialControllerImpl* impl = (SerialControllerImpl*)_context; - if( impl ) - { - impl->ReadThreadProc(); - } - - return 0; -} - -//----------------------------------------------------------------------------- -// -// Handle receiving data -//----------------------------------------------------------------------------- -void SerialControllerImpl::ReadThreadProc -( -) -{ - uint32 attempts = 0; - while( true ) - { - // Init must have been called successfully during Open, so we - // don't do it again until the end of the loop - if( INVALID_HANDLE_VALUE != m_hSerialController ) - { - // Enter read loop. Call will only return if - // an exit is requested or an error occurs - Read(); - - // Reset the attempts, so we get a rapid retry for temporary errors - attempts = 0; - } - - if( attempts < 25 ) - { - // Retry every 5 seconds for the first two minutes... - if( WAIT_OBJECT_0 == ::WaitForSingleObject( m_hExit, 5000 ) ) - { - // Exit signalled. - break; - } - } - else - { - // ...retry every 30 seconds after that - if( WAIT_OBJECT_0 == ::WaitForSingleObject( m_hExit, 30000 ) ) - { - // Exit signalled. - break; - } - } - - Init( ++attempts ); - } -} - -//----------------------------------------------------------------------------- -// -// Initialize the serial port -//----------------------------------------------------------------------------- -bool SerialControllerImpl::Init -( - uint32 const _attempts -) -{ - Log::Write( LogLevel_Info, " Trying to open serial port %s (Attempt %d)", m_owner->m_serialControllerName.c_str(), _attempts ); - - m_hSerialController = CreateFileA( m_owner->m_serialControllerName.c_str(), - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL ); - - if( INVALID_HANDLE_VALUE == m_hSerialController ) - { - //Error - Log::Write( LogLevel_Error, "ERROR: Cannot open serial port %s. Error code %d\n", m_owner->m_serialControllerName.c_str(), GetLastError() ); - goto SerialOpenFailure; - } - - // Configure the serial device parameters - // Build on the current configuration - DCB dcb; - if( !GetCommState( m_hSerialController, &dcb ) ) - { - //Error. Clean up and exit - Log::Write( LogLevel_Error, "ERROR: Failed to read serial port state" ); - goto SerialOpenFailure; - } - - // Fill in the Device Control Block - dcb.BaudRate = (DWORD)m_owner->m_baud; - dcb.ByteSize = 8; - dcb.Parity = (BYTE)m_owner->m_parity; - dcb.StopBits = (BYTE)m_owner->m_stopBits; - - if( !SetCommState( m_hSerialController, &dcb) ) - { - //Error. Clean up and exit - Log::Write( LogLevel_Error, "ERROR: Failed to set serial port state" ); - goto SerialOpenFailure; - } - - // Set the timeouts for the serial port - COMMTIMEOUTS commTimeouts; - commTimeouts.ReadIntervalTimeout = MAXDWORD; - commTimeouts.ReadTotalTimeoutConstant = 0; - commTimeouts.ReadTotalTimeoutMultiplier = 0; - commTimeouts.WriteTotalTimeoutConstant = 0; - commTimeouts.WriteTotalTimeoutMultiplier = 0; - if( !SetCommTimeouts( m_hSerialController, &commTimeouts ) ) - { - // Error. Clean up and exit - Log::Write( LogLevel_Error, "ERROR: Failed to set serial port timeouts" ); - goto SerialOpenFailure; - } - - // Set the serial port to signal when data is received - if( !SetCommMask( m_hSerialController, EV_RXCHAR ) ) - { - //Error. Clean up and exit - Log::Write( LogLevel_Info, "ERROR: Failed to set serial port mask" ); - goto SerialOpenFailure; - } - - // Clear any residual data from the serial port - PurgeComm( m_hSerialController, PURGE_RXABORT|PURGE_RXCLEAR|PURGE_TXABORT|PURGE_TXCLEAR ); - - // Open successful - Log::Write( LogLevel_Info, " Serial port %s opened (attempt %d)", m_owner->m_serialControllerName.c_str(), _attempts ); - return true; - -SerialOpenFailure: - Log::Write( LogLevel_Info, "ERROR: Failed to open serial port %s (attempt %d)", m_owner->m_serialControllerName.c_str(), _attempts ); - CloseHandle( m_hSerialController ); - m_hSerialController = INVALID_HANDLE_VALUE; - return false; -} - -//----------------------------------------------------------------------------- -// -// Read data from the serial port -//----------------------------------------------------------------------------- -void SerialControllerImpl::Read -( -) -{ - uint8 buffer[256]; - - OVERLAPPED overlapped; - memset( &overlapped, 0, sizeof(overlapped) ); - overlapped.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - - while( true ) - { - // Try to read all available data from the serial port - DWORD bytesRead = 0; - do - { - if( ::ReadFile( m_hSerialController, buffer, 256, NULL, &overlapped ) ) - { - // Read completed - GetOverlappedResult( m_hSerialController, &overlapped, &bytesRead, TRUE ); - - // Copy to the stream buffer - if( bytesRead > 0 ) - m_owner->Put( buffer, bytesRead ); - } - else - { - //Wait for the read to complete - if( ERROR_IO_PENDING == GetLastError() ) - { - // Wait for the read to complete or the - // signal that this thread should exit. - HANDLE handles[2]; - handles[0] = overlapped.hEvent; - handles[1] = m_hExit; - DWORD res = WaitForMultipleObjects( 2, handles, FALSE, INFINITE ); - - if( (WAIT_OBJECT_0+1) == res ) - { - // Exit signalled. Cancel the read. - goto exitRead; - } - - if( WAIT_TIMEOUT == res ) - { - // Timed out - should never happen - goto exitRead; - } - - // Read completed - GetOverlappedResult( m_hSerialController, &overlapped, &bytesRead, TRUE ); - - // Copy to the stream buffer - if( bytesRead > 0 ) - m_owner->Put( buffer, bytesRead ); - } - else - { - // An error has occurred - goto exitRead; - } - } - } - while( bytesRead > 0 ); - - // Clear the event - ResetEvent( overlapped.hEvent ); - - // Nothing available to read, so wait for the next rx char event - DWORD dwEvtMask; - if( !WaitCommEvent( m_hSerialController, &dwEvtMask, &overlapped ) ) - { - if( ERROR_IO_PENDING == GetLastError() ) - { - // Wait for either some data to arrive or - // the signal that this thread should exit. - HANDLE handles[2]; - handles[0] = overlapped.hEvent; - handles[1] = m_hExit; - - DWORD res = WaitForMultipleObjects( 2, handles, FALSE, INFINITE ); - - if( (WAIT_OBJECT_0+1) == res ) - { - // Exit signalled. Prevent WaitCommEvent from corrupting the - // stack by forcing it to exit. - goto exitRead; - } - - if( WAIT_TIMEOUT == res ) - { - // Timed out - should never happen - goto exitRead; - } - - GetOverlappedResult( m_hSerialController, &overlapped, &bytesRead, TRUE ); - } - } - - // Clear the event - ResetEvent( overlapped.hEvent ); - - // Loop back to the top to read the waiting data - } - -exitRead: - // Exit event has been signalled, or an error has occurred - SetCommMask( m_hSerialController, 0 ); - CancelIo( m_hSerialController ); - CloseHandle( overlapped.hEvent ); -} - -//----------------------------------------------------------------------------- -// -// Send data to the serial port -//----------------------------------------------------------------------------- -uint32 SerialControllerImpl::Write -( - uint8* _buffer, - uint32 _length -) -{ - if( INVALID_HANDLE_VALUE == m_hSerialController ) - { - //Error - Log::Write( LogLevel_Error, "ERROR: Serial port must be opened before writing\n" ); - return 0; - } - - // Write the data - OVERLAPPED overlapped; - memset( &overlapped, 0, sizeof(overlapped) ); - overlapped.hEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - - DWORD bytesWritten; - if( !::WriteFile( m_hSerialController, _buffer, _length, &bytesWritten, &overlapped ) ) - { - //Wait for the write to complete - if( ERROR_IO_PENDING == GetLastError() ) - { - GetOverlappedResult( m_hSerialController, &overlapped, &bytesWritten, TRUE ); - } - else - { - Log::Write( LogLevel_Error, "ERROR: Serial port write (0x%.8x)", GetLastError() ); - } - } - - CloseHandle( overlapped.hEvent ); - return (uint32)bytesWritten; -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/SerialControllerImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/SerialControllerImpl.h deleted file mode 100644 index 4f5658d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/SerialControllerImpl.h +++ /dev/null @@ -1,66 +0,0 @@ -//----------------------------------------------------------------------------- -// -// SerialControllerImpl.h -// -// Windows Implementation of the cross-platform serial port -// -// Copyright (c) 2010 Jason Frazier -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _SerialControllerImpl_H -#define _SerialControllerImpl_H - -#include - -#include "../../Defs.h" -#include "../SerialController.h" - -namespace OpenZWave -{ - class SerialControllerImpl - { - public: - void ReadThreadProc(); - - private: - friend class SerialController; - - SerialControllerImpl( SerialController* _owner ); - ~SerialControllerImpl(); - - bool Open(); - void Close(); - - uint32 Write( uint8* _buffer, uint32 _length ); - - bool Init( uint32 const _attempts ); - void Read(); - - SerialController* m_owner; - HANDLE m_hThread; - HANDLE m_hExit; - HANDLE m_hSerialController; - }; - -} // namespace OpenZWave - -#endif //_SerialControllerImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/ThreadImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/ThreadImpl.cpp deleted file mode 100644 index 55dc453..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/ThreadImpl.cpp +++ /dev/null @@ -1,158 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThreadImpl.cpp -// -// Windows implementation of a cross-platform thread -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../../Defs.h" -#include "../Event.h" -#include "../Thread.h" -#include "ThreadImpl.h" - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ThreadImpl::ThreadImpl -( - Thread* _owner, - string const& _name -): - m_owner( _owner ), - m_hThread( INVALID_HANDLE_VALUE ), - m_bIsRunning( false ), - m_name( _name ) -{ - -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -ThreadImpl::~ThreadImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Start a function running on this thread -//----------------------------------------------------------------------------- -bool ThreadImpl::Start -( - Thread::pfnThreadProc_t _pfnThreadProc, - Event* _exitEvent, - void* _context -) -{ - // Create a thread to run the specified function - m_pfnThreadProc = _pfnThreadProc; - m_context = _context; - m_exitEvent = _exitEvent; - m_exitEvent->Reset(); - - HANDLE hThread = ::CreateThread( NULL, 0, ThreadImpl::ThreadProc, this, CREATE_SUSPENDED, NULL ); - m_hThread = hThread; - - ::ResumeThread( hThread ); - return true; -} - -//----------------------------------------------------------------------------- -// -// Cause thread to sleep for the specified number of milliseconds -//----------------------------------------------------------------------------- -void ThreadImpl::Sleep -( - uint32 _millisecs -) -{ - ::Sleep(_millisecs); -} - -//----------------------------------------------------------------------------- -// -// Force the thread to stop -//----------------------------------------------------------------------------- -bool ThreadImpl::Terminate -( -) -{ - if( !m_bIsRunning ) - { - return false; - } - - // This can cause all sorts of trouble if the thread is holding a lock. - TerminateThread( m_hThread, 0 ); - m_hThread = INVALID_HANDLE_VALUE; - return true; -} - -//----------------------------------------------------------------------------- -// -// Test whether the thread has completed -//----------------------------------------------------------------------------- -bool ThreadImpl::IsSignalled -( -) -{ - return !m_bIsRunning; -} - -//----------------------------------------------------------------------------- -// -// Entry point for running a function on this thread -//----------------------------------------------------------------------------- -DWORD WINAPI ThreadImpl::ThreadProc -( - void* _pArg -) -{ - ThreadImpl* pImpl = (ThreadImpl*)_pArg; - pImpl->Run(); - return 0; -} - -//----------------------------------------------------------------------------- -// -// Entry point for running a function on this thread -//----------------------------------------------------------------------------- -void ThreadImpl::Run -( -) -{ - m_bIsRunning = true; - m_pfnThreadProc( m_exitEvent, m_context ); - m_bIsRunning = false; - - // Let any watchers know that the thread has finished running. - m_owner->Notify(); -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/ThreadImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/ThreadImpl.h deleted file mode 100644 index 69e93cf..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/ThreadImpl.h +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ThreadImpl.h -// -// Windows implementation of a cross-platform thread -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _ThreadImpl_H -#define _ThreadImpl_H - -#include -#include -#include "../Thread.h" - -namespace OpenZWave -{ - class Thread; - class Event; - - /** \brief Windows-specific implementation of the Thread class. - */ - class ThreadImpl - { - private: - friend class Thread; - - ThreadImpl( Thread* _owner, string const& _name ); - ~ThreadImpl(); - - bool Start( Thread::pfnThreadProc_t _pfnThreadProc, Event* _exitEvent, void* _context ); - void Sleep( uint32 _milliseconds ); - bool Terminate(); - - bool IsSignalled(); - - void Run(); - static DWORD WINAPI ThreadProc( void* _pArg ); - - Thread* m_owner; - HANDLE m_hThread; - Event* m_exitEvent; - Thread::pfnThreadProc_t m_pfnThreadProc; - void* m_context; - bool m_bIsRunning; - string m_name; - }; - -} // namespace OpenZWave - -#endif //_ThreadImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/TimeStampImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/TimeStampImpl.cpp deleted file mode 100644 index 31f4b27..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/TimeStampImpl.cpp +++ /dev/null @@ -1,114 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeStampImpl.h -// -// Cross-platform TimeStampImpl -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include -#include -#include "../../Defs.h" -#include "TimeStampImpl.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -TimeStampImpl::TimeStampImpl -( -) -{ - SetTime(0); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -TimeStampImpl::~TimeStampImpl -( -) -{ -} - -//----------------------------------------------------------------------------- -// -// Sets the timestamp to now, plus an offset in milliseconds -//----------------------------------------------------------------------------- -void TimeStampImpl::SetTime -( - int32 _milliseconds // = 0 -) -{ - int64 offset = ((int64)_milliseconds) * 10000LL; // Timestamp is stored in 100ns steps. - - GetSystemTimeAsFileTime( (FILETIME*)&m_stamp ); - m_stamp += offset; -} - -//----------------------------------------------------------------------------- -// -// Gets the difference between now and the timestamp time in milliseconds -//----------------------------------------------------------------------------- -int32 TimeStampImpl::TimeRemaining -( -) -{ - int64 now; - GetSystemTimeAsFileTime( (FILETIME*)&now ); - - return (int32)( ( m_stamp - now ) / 10000LL ); -} - -//----------------------------------------------------------------------------- -// -// Return a string representation -//----------------------------------------------------------------------------- -string TimeStampImpl::GetAsString -( -) -{ - // Convert m_stamp (FILETIME) to SYSTEMTIME for ease of use - SYSTEMTIME time; - ::FileTimeToSystemTime( (FILETIME*)m_stamp, &time ); - - char buf[100]; - sprintf_s( buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d:%03d ", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds ); - string str = buf; - return str; -} - -//----------------------------------------------------------------------------- -// -// Overload the subtract operator to get the difference between two -// timestamps in milliseconds -//----------------------------------------------------------------------------- -int32 TimeStampImpl::operator- -( - TimeStampImpl const& _other -) -{ - return (int32)( ( m_stamp - _other.m_stamp ) / 10000LL ); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/TimeStampImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/TimeStampImpl.h deleted file mode 100644 index a4dc262..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/TimeStampImpl.h +++ /dev/null @@ -1,88 +0,0 @@ -//----------------------------------------------------------------------------- -// -// TimeStampImpl.h -// -// Windows implementation of a TimeStamp -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _TimeStampImpl_H -#define _TimeStampImpl_H - -#include "../../Defs.h" - -namespace OpenZWave -{ - /** \brief Windows implementation of a timestamp. - */ - class TimeStampImpl - { - public: - /** - * Constructor. - * Creates a TimeStampImpl object. - */ - TimeStampImpl(); - - /** - * Destructor. - * Destroys the TimeStampImpl object. - */ - ~TimeStampImpl(); - - /** - * SetTime. Sets the timestamp to now, plus the offset in milliseconds. - * \param _milliseconds positive or negative offset from - * now in milliseconds. - */ - void SetTime( int32 _milliseconds ); - - /** - * TimeRemaining. Gets the difference between now and the timestamp - * time in milliseconds. - * \return milliseconds remaining until we reach the timestamp. The - * return value is negative if the timestamp is in the past. - */ - int32 TimeRemaining(); - - /** - * Return as as string - */ - string GetAsString(); - - /** - * Overload the subtract operator to get the difference between - * two timestamps in milliseconds. - */ - int32 operator- ( TimeStampImpl const& _other ); - - private: - TimeStampImpl( TimeStampImpl const& ); // prevent copy - TimeStampImpl& operator = ( TimeStampImpl const& ); // prevent assignment - - int64 m_stamp; - }; - -} // namespace OpenZWave - -#endif //_TimeStampImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/WaitImpl.cpp b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/WaitImpl.cpp deleted file mode 100644 index 05b9c85..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/WaitImpl.cpp +++ /dev/null @@ -1,134 +0,0 @@ -//----------------------------------------------------------------------------- -// -// WaitImpl.cpp -// -// Windows implementation of an abstract base class for objects we -// want to be able to wait for. -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#include "../../Defs.h" -#include "../Wait.h" -#include "WaitImpl.h" -#include "../Log.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -WaitImpl::WaitImpl -( - Wait* _owner -): - m_owner( _owner ) -{ - InitializeCriticalSection( &m_criticalSection ); -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -WaitImpl::~WaitImpl -( -) -{ - DeleteCriticalSection( &m_criticalSection ); -} - -//----------------------------------------------------------------------------- -// -// Add a watcher to our object. -//----------------------------------------------------------------------------- -void WaitImpl::AddWatcher -( - Wait::pfnWaitNotification_t _callback, - void* _context -) -{ - // Add the watcher to our list - Watcher watcher; - watcher.m_callback = _callback; - watcher.m_context = _context; - - EnterCriticalSection( &m_criticalSection ); - - m_watchers.push_back( watcher ); - - LeaveCriticalSection( &m_criticalSection ); - - // If the object is already in a signalled state, notify the watcher immediately - if( m_owner->IsSignalled() ) - { - _callback( _context ); - } - -} - -//----------------------------------------------------------------------------- -// -// Remove a watcher from our object. -//----------------------------------------------------------------------------- -bool WaitImpl::RemoveWatcher -( - Wait::pfnWaitNotification_t _callback, - void* _context -) -{ - bool res = false; - EnterCriticalSection( &m_criticalSection ); - - for( list::iterator it=m_watchers.begin(); it!=m_watchers.end(); ++it ) - { - Watcher const& watcher = *it; - if( ( watcher.m_callback == _callback ) && ( watcher.m_context == _context ) ) - { - m_watchers.erase( it ); - res = true; - break; - } - } - - LeaveCriticalSection( &m_criticalSection ); - return res; -} - -//----------------------------------------------------------------------------- -// -// Notify all the watchers that the object has become signalled -//----------------------------------------------------------------------------- -void WaitImpl::Notify -( -) -{ - EnterCriticalSection( &m_criticalSection ); - - for( list::iterator it=m_watchers.begin(); it!=m_watchers.end(); ++it ) - { - Watcher const& watcher = *it; - watcher.m_callback( watcher.m_context ); - } - - LeaveCriticalSection( &m_criticalSection ); -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/WaitImpl.h b/lib/ESPiLight/pilight/libs/openzwave/platform/windows/WaitImpl.h deleted file mode 100644 index 89fab12..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/platform/windows/WaitImpl.h +++ /dev/null @@ -1,73 +0,0 @@ -//----------------------------------------------------------------------------- -// -// WaitImpl.h -// -// Windows implementation of a base class for objects we -// want to be able to wait for. -// -// Copyright (c) 2010 Mal Lansell -// All rights reserved. -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- -#ifndef _WaitImpl_H -#define _WaitImpl_H - -#include -#include -#include "../../Defs.h" -#include "../Ref.h" -#include "../Wait.h" - -namespace OpenZWave -{ - /** \brief Windows specific implementation of Wait objects. - */ - class WaitImpl - { - private: - friend class Wait; - - WaitImpl( Wait* _owner ); - virtual ~WaitImpl(); - - void AddWatcher( Wait::pfnWaitNotification_t _callback, void* _context ); - bool RemoveWatcher( Wait::pfnWaitNotification_t _callback, void* _context ); - void Notify(); - - static int32 Multiple( Wait** _objects, uint32 _numObjects, int32 _timeout = -1 ); - - WaitImpl( Wait const& ); // prevent copy - WaitImpl& operator = ( WaitImpl const& ); // prevent assignment - - struct Watcher - { - Wait::pfnWaitNotification_t m_callback; - void* m_context; - }; - - list m_watchers; - Wait* m_owner; - CRITICAL_SECTION m_criticalSection; - }; - -} // namespace OpenZWave - -#endif //_WaitImpl_H - diff --git a/lib/ESPiLight/pilight/libs/openzwave/tinystr.cpp b/lib/ESPiLight/pilight/libs/openzwave/tinystr.cpp deleted file mode 100644 index 6812507..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/tinystr.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -/* - * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005. - */ - - -#ifndef TIXML_USE_STL - -#include "tinystr.h" - -// Error value for find primitive -const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); - - -// Null rep. -TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; - - -void TiXmlString::reserve (size_type cap) -{ - if (cap > capacity()) - { - TiXmlString tmp; - tmp.init(length(), cap); - memcpy(tmp.start(), data(), length()); - swap(tmp); - } -} - - -TiXmlString& TiXmlString::assign(const char* str, size_type len) -{ - size_type cap = capacity(); - if (len > cap || cap > 3*(len + 8)) - { - TiXmlString tmp; - tmp.init(len); - memcpy(tmp.start(), str, len); - swap(tmp); - } - else - { - memmove(start(), str, len); - set_size(len); - } - return *this; -} - - -TiXmlString& TiXmlString::append(const char* str, size_type len) -{ - size_type newsize = length() + len; - if (newsize > capacity()) - { - reserve (newsize + capacity()); - } - memmove(finish(), str, len); - set_size(newsize); - return *this; -} - - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) -{ - TiXmlString tmp; - tmp.reserve(a.length() + b.length()); - tmp += a; - tmp += b; - return tmp; -} - -TiXmlString operator + (const TiXmlString & a, const char* b) -{ - TiXmlString tmp; - TiXmlString::size_type b_len = static_cast( strlen(b) ); - tmp.reserve(a.length() + b_len); - tmp += a; - tmp.append(b, b_len); - return tmp; -} - -TiXmlString operator + (const char* a, const TiXmlString & b) -{ - TiXmlString tmp; - TiXmlString::size_type a_len = static_cast( strlen(a) ); - tmp.reserve(a_len + b.length()); - tmp.append(a, a_len); - tmp += b; - return tmp; -} - - -#endif // TIXML_USE_STL diff --git a/lib/ESPiLight/pilight/libs/openzwave/tinystr.h b/lib/ESPiLight/pilight/libs/openzwave/tinystr.h deleted file mode 100644 index 65cd96a..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/tinystr.h +++ /dev/null @@ -1,319 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -/* - * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005. - * - * - completely rewritten. compact, clean, and fast implementation. - * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems) - * - fixed reserve() to work as per specification. - * - fixed buggy compares operator==(), operator<(), and operator>() - * - fixed operator+=() to take a const ref argument, following spec. - * - added "copy" constructor with length, and most compare operators. - * - added swap(), clear(), size(), capacity(), operator+(). - */ - -#ifndef TIXML_USE_STL - -#ifndef TIXML_STRING_INCLUDED -#define TIXML_STRING_INCLUDED - -#include -#include - -/* The support for explicit isn't that universal, and it isn't really - required - it is used to check that the TiXmlString class isn't incorrectly - used. Be nice to old compilers and macro it here: -*/ -#if defined(_WIN32) && (_WIN32 >= 1200 ) - // Microsoft visual studio, version 6 and higher. - #define TIXML_EXPLICIT explicit -#elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - #define TIXML_EXPLICIT explicit -#else - #define TIXML_EXPLICIT -#endif - - -/* - TiXmlString is an emulation of a subset of the std::string template. - Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. - Only the member functions relevant to the TinyXML project have been implemented. - The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase - a string and there's no more room, we allocate a buffer twice as big as we need. -*/ -class TiXmlString -{ - public : - // The size type used - typedef size_t size_type; - - // Error value for find primitive - static const size_type npos; // = -1; - - - // TiXmlString empty constructor - TiXmlString () : rep_(&nullrep_) - { - } - - // TiXmlString copy constructor - TiXmlString ( const TiXmlString & copy) : rep_(0) - { - init(copy.length()); - memcpy(start(), copy.data(), length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) - { - init( static_cast( strlen(copy) )); - memcpy(start(), copy, length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) - { - init(len); - memcpy(start(), str, len); - } - - // TiXmlString destructor - ~TiXmlString () - { - quit(); - } - - // = operator - TiXmlString& operator = (const char * copy) - { - return assign( copy, (size_type)strlen(copy)); - } - - // = operator - TiXmlString& operator = (const TiXmlString & copy) - { - return assign(copy.start(), copy.length()); - } - - - // += operator. Maps to append - TiXmlString& operator += (const char * suffix) - { - return append(suffix, static_cast( strlen(suffix) )); - } - - // += operator. Maps to append - TiXmlString& operator += (char single) - { - return append(&single, 1); - } - - // += operator. Maps to append - TiXmlString& operator += (const TiXmlString & suffix) - { - return append(suffix.data(), suffix.length()); - } - - - // Convert a TiXmlString into a null-terminated char * - const char * c_str () const { return rep_->str; } - - // Convert a TiXmlString into a char * (need not be null terminated). - const char * data () const { return rep_->str; } - - // Return the length of a TiXmlString - size_type length () const { return rep_->size; } - - // Alias for length() - size_type size () const { return rep_->size; } - - // Checks if a TiXmlString is empty - bool empty () const { return rep_->size == 0; } - - // Return capacity of string - size_type capacity () const { return rep_->capacity; } - - - // single char extraction - const char& at (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // [] operator - char& operator [] (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // find a char in a string. Return TiXmlString::npos if not found - size_type find (char lookup) const - { - return find(lookup, 0); - } - - // find a char in a string from an offset. Return TiXmlString::npos if not found - size_type find (char tofind, size_type offset) const - { - if (offset >= length()) return npos; - - for (const char* p = c_str() + offset; *p != '\0'; ++p) - { - if (*p == tofind) return static_cast< size_type >( p - c_str() ); - } - return npos; - } - - void clear () - { - //Lee: - //The original was just too strange, though correct: - // TiXmlString().swap(*this); - //Instead use the quit & re-init: - quit(); - init(0,0); - } - - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function DOES NOT clear the content of the TiXmlString if any exists. - */ - void reserve (size_type cap); - - TiXmlString& assign (const char* str, size_type len); - - TiXmlString& append (const char* str, size_type len); - - void swap (TiXmlString& other) - { - Rep* r = rep_; - rep_ = other.rep_; - other.rep_ = r; - } - - private: - - void init(size_type sz) { init(sz, sz); } - void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } - char* start() const { return rep_->str; } - char* finish() const { return rep_->str + rep_->size; } - - struct Rep - { - size_type size, capacity; - char str[1]; - }; - - void init(size_type sz, size_type cap) - { - if (cap) - { - // Lee: the original form: - // rep_ = static_cast(operator new(sizeof(Rep) + cap)); - // doesn't work in some cases of new being overloaded. Switching - // to the normal allocation, although use an 'int' for systems - // that are overly picky about structure alignment. - const size_type bytesNeeded = sizeof(Rep) + cap; - const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); - rep_ = reinterpret_cast( new int[ intsNeeded ] ); - - rep_->str[ rep_->size = sz ] = '\0'; - rep_->capacity = cap; - } - else - { - rep_ = &nullrep_; - } - } - - void quit() - { - if (rep_ != &nullrep_) - { - // The rep_ is really an array of ints. (see the allocator, above). - // Cast it back before delete, so the compiler won't incorrectly call destructors. - delete [] ( reinterpret_cast( rep_ ) ); - } - } - - Rep * rep_; - static Rep nullrep_; - -} ; - - -inline bool operator == (const TiXmlString & a, const TiXmlString & b) -{ - return ( a.length() == b.length() ) // optimization on some platforms - && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare -} -inline bool operator < (const TiXmlString & a, const TiXmlString & b) -{ - return strcmp(a.c_str(), b.c_str()) < 0; -} - -inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } -inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } -inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } -inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } - -inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } -inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } -inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } -inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); -TiXmlString operator + (const TiXmlString & a, const char* b); -TiXmlString operator + (const char* a, const TiXmlString & b); - - -/* - TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. - Only the operators that we need for TinyXML have been developped. -*/ -class TiXmlOutStream : public TiXmlString -{ -public : - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const TiXmlString & in) - { - *this += in; - return *this; - } - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const char * in) - { - *this += in; - return *this; - } - -} ; - -#endif // TIXML_STRING_INCLUDED -#endif // TIXML_USE_STL diff --git a/lib/ESPiLight/pilight/libs/openzwave/tinyxml.cpp b/lib/ESPiLight/pilight/libs/openzwave/tinyxml.cpp deleted file mode 100644 index 16decb2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/tinyxml.cpp +++ /dev/null @@ -1,1891 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include - -#ifdef TIXML_USE_STL -#include -#include -#endif - -#include - -#include "tinyxml.h" - - -bool TiXmlBase::condenseWhiteSpace = true; - -// Microsoft compiler security -FILE* TiXmlFOpen( const char* filename, const char* mode ) -{ - #if defined(_WIN32) && (_WIN32 >= 1400 ) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filename, mode ); - if ( !err && fp ) - return fp; - return 0; - #else - return fopen( filename, mode ); - #endif -} - -void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) -{ - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); - #else - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append( buf, (int)strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } -} - - -void TiXmlNode::CopyTo( TiXmlNode* target ) const -{ - target->SetValue (value.c_str() ); - target->userData = userData; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) -{ - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); - - if ( node->Type() == TiXmlNode::DOCUMENT ) - { - delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) -{ - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - - return LinkEndChild( node ); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) -{ - if ( !afterThis || afterThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) -{ - if ( replaceThis->parent != this ) - return 0; - - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) -{ - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } -} - - -const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -void TiXmlElement::RemoveAttribute( const char * name ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING str( name ); - TiXmlAttribute* node = attributeSet.Find( str ); - #else - TiXmlAttribute* node = attributeSet.Find( name ); - #endif - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } -} - -const TiXmlElement* TiXmlNode::FirstChildElement() const -{ - const TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - const TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; -} - - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - copy.CopyTo( this ); -} - - -void TiXmlElement::operator=( const TiXmlElement& base ) -{ - ClearThis(); - base.CopyTo( this ); -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } -} - - -const char* TiXmlElement::Attribute( const char* name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); - return 0; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return &node->ValueStr(); - return 0; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, int* i ) const -{ - const char* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s ); - } - else { - *i = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const -{ - const std::string* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s->c_str() ); - } - else { - *i = 0; - } - } - return s; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, double* d ) const -{ - const char* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s ); - } - else { - *d = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const -{ - const std::string* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s->c_str() ); - } - else { - *d = 0; - } - } - return s; -} -#endif - - -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} -#endif - - -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} -#endif - - -void TiXmlElement::SetAttribute( const char * name, int val ) -{ - char buf[64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); - #else - sprintf( buf, "%d", val ); - #endif - SetAttribute( name, buf ); -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, int val ) -{ - std::ostringstream oss; - oss << val; - SetAttribute( name, oss.str() ); -} -#endif - - -void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - char buf[256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); - #else - sprintf( buf, "%f", val ); - #endif - SetAttribute( name, buf ); -} - - -void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING _name( cname ); - TIXML_STRING _value( cvalue ); - #else - const char* _name = cname; - const char* _value = cvalue; - #endif - - TiXmlAttribute* node = attributeSet.Find( _name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new (std::nothrow) TiXmlAttribute( cname, cvalue ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new (std::nothrow) TiXmlAttribute( name, _value ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} -#endif - - -void TiXmlElement::Print( FILE* cfile, int depth ) const -{ - int i; - assert( cfile ); - for ( i=0; iNext() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i", value.c_str() ); - } -} - - -void TiXmlElement::CopyTo( TiXmlElement* target ) const -{ - // superclass: - TiXmlNode::CopyTo( target ); - - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - -bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this, attributeSet.First() ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new (std::nothrow) TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -const char* TiXmlElement::GetText() const -{ - const TiXmlNode* child = this->FirstChild(); - if ( child ) { - const TiXmlText* childText = child->ToText(); - if ( childText ) { - return childText->Value(); - } - } - return 0; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); -} - -TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} - - -#ifdef TIXML_USE_STL -TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} -#endif - - -TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDocument::operator=( const TiXmlDocument& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) -{ - // See STL_STRING_BUG below. - //StringToBuffer buf( value ); - - return LoadFile( Value(), encoding ); -} - - -bool TiXmlDocument::SaveFile() const -{ - // See STL_STRING_BUG below. -// StringToBuffer buf( value ); -// -// if ( buf.buffer && SaveFile( buf.buffer ) ) -// return true; -// -// return false; - return SaveFile( Value() ); -} - -bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) -{ - // There was a really terrifying little bug here. The code: - // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same - // address as its c_str() method, and so bad things happen. Looks - // like a bug in the Microsoft STL implementation. - // Add an extra string to avoid the crash. - TIXML_STRING filename( _filename ); - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = TiXmlFOpen( value.c_str (), "rb" ); - - if ( file ) - { - bool result = LoadFile( file, encoding ); - fclose( file ); - return result; - } - else - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } -} - -bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) -{ - if ( !file ) - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length <= 0 ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve( length ); - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // - // - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while( fgets( buf, sizeof(buf), file ) ) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if ( fread( buf, length, 1, file ) != 1 ) { - delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - const char* lastPos = buf; - const char* p = buf; - - buf[length] = 0; - while( *p ) { - assert( p < (buf+length) ); - if ( *p == 0xa ) { - // Newline character. No special rules for this. Append all the characters - // since the last string, and include the newline. - data.append( lastPos, (p-lastPos+1) ); // append, include the newline - ++p; // move past the newline - lastPos = p; // and point to the new buffer (may be 0) - assert( p <= (buf+length) ); - } - else if ( *p == 0xd ) { - // Carriage return. Append what we have so far, then - // handle moving forward in the buffer. - if ( (p-lastPos) > 0 ) { - data.append( lastPos, p-lastPos ); // do not add the CR - } - data += (char)0xa; // a proper newline - - if ( *(p+1) == 0xa ) { - // Carriage return - new line sequence - p += 2; - lastPos = p; - assert( p <= (buf+length) ); - } - else { - // it was followed by something else...that is presumably characters again. - ++p; - lastPos = p; - assert( p <= (buf+length) ); - } - } - else { - ++p; - } - } - // Handle any left over characters. - if ( p-lastPos ) { - data.append( lastPos, p-lastPos ); - } - delete [] buf; - buf = 0; - - Parse( data.c_str(), 0, encoding ); - - if ( Error() ) - return false; - else - return true; -} - - -bool TiXmlDocument::SaveFile( const char * filename ) const -{ - // The old c stuff lives on... - FILE* fp = TiXmlFOpen( filename, "w" ); - if ( fp ) - { - bool result = SaveFile( fp ); - fclose( fp ); - return result; - } - return false; -} - - -bool TiXmlDocument::SaveFile( FILE* fp ) const -{ - if ( useMicrosoftBOM ) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - - fputc( TIXML_UTF_LEAD_0, fp ); - fputc( TIXML_UTF_LEAD_1, fp ); - fputc( TIXML_UTF_LEAD_2, fp ); - } - Print( fp, 0 ); - return (ferror(fp) == 0); -} - - -void TiXmlDocument::CopyTo( TiXmlDocument* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->error = error; - target->errorId = errorId; - target->errorDesc = errorDesc; - target->tabsize = tabsize; - target->errorLocation = errorLocation; - target->useMicrosoftBOM = useMicrosoftBOM; - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - TiXmlNode* clonedNode=node->Clone(); - if (clonedNode!=NULL) target->LinkEndChild( clonedNode ); - } -} - - -TiXmlNode* TiXmlDocument::Clone() const -{ - TiXmlDocument* clone = new (std::nothrow) TiXmlDocument(); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlDocument::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } -} - - -bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -const TiXmlAttribute* TiXmlAttribute::Next() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} - -/* -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} -*/ - -const TiXmlAttribute* TiXmlAttribute::Previous() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} - -/* -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} -*/ - -void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - TIXML_STRING n, v; - - EncodeString( name, &n ); - EncodeString( value, &v ); - - if (value.find ('\"') == TIXML_STRING::npos) { - if ( cfile ) { - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; - } - } - else { - if ( cfile ) { - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; - } - } -} - - -int TiXmlAttribute::QueryIntValue( int* ival ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -int TiXmlAttribute::QueryDoubleValue( double* dval ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -void TiXmlAttribute::SetIntValue( int _value ) -{ - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); -} - -void TiXmlAttribute::SetDoubleValue( double _value ) -{ - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); - #else - sprintf (buf, "%lf", _value); - #endif - SetValue (buf); -} - -int TiXmlAttribute::IntValue() const -{ - return atoi (value.c_str ()); -} - -double TiXmlAttribute::DoubleValue() const -{ - return atof (value.c_str ()); -} - - -TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlComment::operator=( const TiXmlComment& base ) -{ - Clear(); - base.CopyTo( this ); -} - - -void TiXmlComment::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlComment::CopyTo( TiXmlComment* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlComment::Clone() const -{ - TiXmlComment* clone = new (std::nothrow) TiXmlComment(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlText::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - if ( cdata ) - { - int i; - fprintf( cfile, "\n" ); - for ( i=0; i\n", value.c_str() ); // unformatted output - } - else - { - TIXML_STRING buffer; - EncodeString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); - } -} - - -void TiXmlText::CopyTo( TiXmlText* target ) const -{ - TiXmlNode::CopyTo( target ); - target->cdata = cdata; -} - - -bool TiXmlText::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new (std::nothrow) TiXmlText( "" ); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} - - -#ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} -#endif - - -TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - if ( cfile ) fprintf( cfile, "" ); - if ( str ) (*str) += "?>"; -} - - -void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->version = version; - target->encoding = encoding; - target->standalone = standalone; -} - - -bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new (std::nothrow) TiXmlDeclaration(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlUnknown::Print( FILE* cfile, int depth ) const -{ - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlUnknown::Clone() const -{ - TiXmlUnknown* clone = new (std::nothrow) TiXmlUnknown(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlAttributeSet::TiXmlAttributeSet() -{ - sentinel.next = &sentinel; - sentinel.prev = &sentinel; -} - - -TiXmlAttributeSet::~TiXmlAttributeSet() -{ - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); -} - - -void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) -{ - #ifdef TIXML_USE_STL - assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. - #else - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - #endif - - addMe->next = &sentinel; - addMe->prev = sentinel.prev; - - sentinel.prev->next = addMe; - sentinel.prev = addMe; -} - -void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) -{ - TiXmlAttribute* node; - - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. -} - - -#ifdef TIXML_USE_STL -const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} -*/ -#endif - - -const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} -*/ - -#ifdef TIXML_USE_STL -std::istream& operator>> (std::istream & in, TiXmlNode & base) -{ - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); - - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); - return in; -} -#endif - - -#ifdef TIXML_USE_STL -std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out << printer.Str(); - - return out; -} - - -std::string& operator<< (std::string& out, const TiXmlNode& base ) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out.append( printer.Str() ); - - return out; -} -#endif - - -TiXmlHandle TiXmlHandle::FirstChild() const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement() const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && iNextSibling(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild( value ); - for ( i=0; - child && iNextSibling( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && iNextSiblingElement(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement( value ); - for ( i=0; - child && iNextSiblingElement( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) -{ - DoIndent(); - buffer += "<"; - buffer += element.Value(); - - for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - buffer += " "; - attrib->Print( 0, 0, &buffer ); - } - - if ( !element.FirstChild() ) - { - buffer += " />"; - DoLineBreak(); - } - else - { - buffer += ">"; - if ( element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) - { - simpleTextPrint = true; - // no DoLineBreak()! - } - else - { - DoLineBreak(); - } - } - ++depth; - return true; -} - - -bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) -{ - --depth; - if ( !element.FirstChild() ) - { - // nothing. - } - else - { - if ( simpleTextPrint ) - { - simpleTextPrint = false; - } - else - { - DoIndent(); - } - buffer += ""; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlText& text ) -{ - if ( text.CDATA() ) - { - DoIndent(); - buffer += ""; - DoLineBreak(); - } - else if ( simpleTextPrint ) - { - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - } - else - { - DoIndent(); - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) -{ - DoIndent(); - declaration.Print( 0, 0, &buffer ); - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlComment& comment ) -{ - DoIndent(); - buffer += ""; - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) -{ - DoIndent(); - buffer += "<"; - buffer += unknown.Value(); - buffer += ">"; - DoLineBreak(); - return true; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/tinyxml.h b/lib/ESPiLight/pilight/libs/openzwave/tinyxml.h deleted file mode 100644 index 70c81c5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/tinyxml.h +++ /dev/null @@ -1,1802 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#ifndef TINYXML_INCLUDED -#define TINYXML_INCLUDED - -#ifdef _WIN32 -#pragma warning( push ) -#pragma warning( disable : 4530 ) -#pragma warning( disable : 4786 ) -#endif - -#include -#include -#include -#include -#include - -// Help out windows: -#if defined( _DEBUG ) && !defined( DEBUG ) -#define DEBUG -#endif - -#ifdef TIXML_USE_STL - #include - #include - #include - #define TIXML_STRING std::string -#else - #include "tinystr.h" - #define TIXML_STRING TiXmlString -#endif - -// Deprecated library function hell. Compilers want to use the -// new safe versions. This probably doesn't fully address the problem, -// but it gets closer. There are too many compilers for me to fully -// test. If you get compilation troubles, undefine TIXML_SAFE -#define TIXML_SAFE - -#ifdef TIXML_SAFE - #if defined(_WIN32) && (_WIN32 >= 1400 ) - // Microsoft visual studio, version 2005 and higher. - #define TIXML_SNPRINTF _snprintf_s - #define TIXML_SNSCANF _snscanf_s - #define TIXML_SSCANF sscanf_s - #elif defined(_WIN32) && (_WIN32 >= 1200 ) - // Microsoft visual studio, version 6 and higher. - //#pragma message( "Using _sn* functions." ) - #define TIXML_SNPRINTF _snprintf - #define TIXML_SNSCANF _snscanf - #define TIXML_SSCANF sscanf - #elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_SNSCANF snscanf - #define TIXML_SSCANF sscanf - #else - #define TIXML_SSCANF sscanf - #endif -#endif - -class TiXmlDocument; -class TiXmlElement; -class TiXmlComment; -class TiXmlUnknown; -class TiXmlAttribute; -class TiXmlText; -class TiXmlDeclaration; -class TiXmlParsingData; - -const int TIXML_MAJOR_VERSION = 2; -const int TIXML_MINOR_VERSION = 5; -const int TIXML_PATCH_VERSION = 3; - -/* Internal structure for tracking location of items - in the XML file. -*/ -struct TiXmlCursor -{ - TiXmlCursor() { Clear(); } - void Clear() { row = col = -1; } - - int row; // 0 based. - int col; // 0 based. -}; - - -/** - If you call the Accept() method, it requires being passed a TiXmlVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves - are simple called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its sibilings will be Visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. - - You should never change the document from a callback. - - \see TiXmlNode::Accept() -*/ -class TiXmlVisitor -{ -public: - virtual ~TiXmlVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } - /// Visit a document. - virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } - - /// Visit an element. - virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } - /// Visit an element. - virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } - - /// Visit a declaration - virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } - /// Visit a text node - virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } - /// Visit a comment node - virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } - /// Visit an unknow node - virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } -}; - -// Only used by Attribute::Query functions -enum -{ - TIXML_SUCCESS, - TIXML_NO_ATTRIBUTE, - TIXML_WRONG_TYPE -}; - - -// Used by the parsing routines. -enum TiXmlEncoding -{ - TIXML_ENCODING_UNKNOWN, - TIXML_ENCODING_UTF8, - TIXML_ENCODING_LEGACY -}; - -const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; - -/** TiXmlBase is a base class for every class in TinyXml. - It does little except to establish that TinyXml classes - can be printed and provide some utility functions. - - In XML, the document and elements can contain - other elements and other types of nodes. - - \verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - A Decleration contains: Attributes (not on tree) - \endverbatim -*/ -class TiXmlBase -{ - friend class TiXmlNode; - friend class TiXmlElement; - friend class TiXmlDocument; - -public: - TiXmlBase() : userData(0) {} - virtual ~TiXmlBase() {} - - /** All TinyXml classes can print themselves to a filestream - or the string class (TiXmlString in non-STL mode, std::string - in STL mode.) Either or both cfile and str can be null. - - This is a formatted print, and will insert - tabs and newlines. - - (For an unformatted stream, use the << operator.) - */ - virtual void Print( FILE* cfile, int depth ) const = 0; - - /** The world does not agree on whether white space should be kept or - not. In order to make everyone happy, these global, static functions - are provided to set whether or not TinyXml will condense all white space - into a single space or not. The default is to condense. Note changing this - value is not thread safe. - */ - static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } - - /// Return the current white space setting. - static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } - - /** Return the position, in the original source file, of this node or attribute. - The row and column are 1-based. (That is the first row and first column is - 1,1). If the returns values are 0 or less, then the parser does not have - a row and column value. - - Generally, the row and column value will be set when the TiXmlDocument::Load(), - TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set - when the DOM was created from operator>>. - - The values reflect the initial load. Once the DOM is modified programmatically - (by adding or changing nodes and attributes) the new values will NOT update to - reflect changes in the document. - - There is a minor performance cost to computing the row and column. Computation - can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. - - \see TiXmlDocument::SetTabSize() - */ - int Row() const { return location.row + 1; } - int Column() const { return location.col + 1; } ///< See Row() - - void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. - void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. - const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. - - // Table that returs, for a given lead byte, the total number of bytes - // in the UTF-8 sequence. - static const int utf8ByteTable[256]; - - virtual const char* Parse( const char* p, - TiXmlParsingData* data, - TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; - - /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, - or they will be transformed into entities! - */ - static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); - - enum - { - TIXML_NO_ERROR = 0, - TIXML_ERROR, - TIXML_ERROR_OPENING_FILE, - TIXML_ERROR_OUT_OF_MEMORY, - TIXML_ERROR_PARSING_ELEMENT, - TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, - TIXML_ERROR_READING_ELEMENT_VALUE, - TIXML_ERROR_READING_ATTRIBUTES, - TIXML_ERROR_PARSING_EMPTY, - TIXML_ERROR_READING_END_TAG, - TIXML_ERROR_PARSING_UNKNOWN, - TIXML_ERROR_PARSING_COMMENT, - TIXML_ERROR_PARSING_DECLARATION, - TIXML_ERROR_DOCUMENT_EMPTY, - TIXML_ERROR_EMBEDDED_NULL, - TIXML_ERROR_PARSING_CDATA, - TIXML_ERROR_DOCUMENT_TOP_ONLY, - - TIXML_ERROR_STRING_COUNT - }; - -protected: - - static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); - inline static bool IsWhiteSpace( char c ) - { - return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); - } - inline static bool IsWhiteSpace( int c ) - { - if ( c < 256 ) - return IsWhiteSpace( (char) c ); - return false; // Again, only truly correct for English/Latin...but usually works. - } - - #ifdef TIXML_USE_STL - static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); - static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); - #endif - - /* Reads an XML name into the string provided. Returns - a pointer just past the last character of the name, - or 0 if the function has an error. - */ - static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); - - /* Reads text. Returns a pointer past the given end tag. - Wickedly complex options, but it keeps the (sensitive) code in one place. - */ - static const char* ReadText( const char* in, // where to start - TIXML_STRING* text, // the string read - bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text - bool ignoreCase, // whether to ignore case in the end tag - TiXmlEncoding encoding ); // the current encoding - - // If an entity has been found, transform it into a character. - static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); - - // Get a character, while interpreting entities. - // The length can be from 0 to 4 bytes. - inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) - { - assert( p ); - if ( encoding == TIXML_ENCODING_UTF8 ) - { - *length = utf8ByteTable[ *((const unsigned char*)p) ]; - assert( *length >= 0 && *length < 5 ); - } - else - { - *length = 1; - } - - if ( *length == 1 ) - { - if ( *p == '&' ) - return GetEntity( p, _value, length, encoding ); - *_value = *p; - return p+1; - } - else if ( *length ) - { - //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), - // and the null terminator isn't needed - for( int i=0; p[i] && i<*length; ++i ) { - _value[i] = p[i]; - } - return p + (*length); - } - else - { - // Not valid text. - return 0; - } - } - - // Return true if the next characters in the stream are any of the endTag sequences. - // Ignore case only works for english, and should only be relied on when comparing - // to English words: StringEqual( p, "version", true ) is fine. - static bool StringEqual( const char* p, - const char* endTag, - bool ignoreCase, - TiXmlEncoding encoding ); - - static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; - - TiXmlCursor location; - - /// Field containing a generic user pointer - void* userData; - - // None of these methods are reliable for any language except English. - // Good for approximation, not great for accuracy. - static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); - static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); - inline static int ToLower( int v, TiXmlEncoding encoding ) - { - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( v < 128 ) return tolower( v ); - return v; - } - else - { - return tolower( v ); - } - } - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - -private: - TiXmlBase( const TiXmlBase& ); // not implemented. - void operator=( const TiXmlBase& base ); // not allowed. - - struct Entity - { - const char* str; - unsigned int strLength; - char chr; - }; - enum - { - NUM_ENTITY = 5, - MAX_ENTITY_LENGTH = 6 - - }; - static Entity entity[ NUM_ENTITY ]; - static bool condenseWhiteSpace; -}; - - -/** The parent class for everything in the Document Object Model. - (Except for attributes). - Nodes have siblings, a parent, and children. A node can be - in a document, or stand on its own. The type of a TiXmlNode - can be queried, and it can be cast to its more defined type. -*/ -class TiXmlNode : public TiXmlBase -{ - friend class TiXmlDocument; - friend class TiXmlElement; - -public: - #ifdef TIXML_USE_STL - - /** An input stream operator, for every class. Tolerant of newlines and - formatting, but doesn't expect them. - */ - friend std::istream& operator >> (std::istream& in, TiXmlNode& base); - - /** An output stream operator, for every class. Note that this outputs - without any newlines or formatting, as opposed to Print(), which - includes tabs and new lines. - - The operator<< and operator>> are not completely symmetric. Writing - a node to a stream is very well defined. You'll get a nice stream - of output, without any extra whitespace or newlines. - - But reading is not as well defined. (As it always is.) If you create - a TiXmlElement (for example) and read that from an input stream, - the text needs to define an element or junk will result. This is - true of all input streams, but it's worth keeping in mind. - - A TiXmlDocument will read nodes until it reads a root element, and - all the children of that root element. - */ - friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); - - /// Appends the XML node or attribute to a std::string. - friend std::string& operator<< (std::string& out, const TiXmlNode& base ); - - #endif - - /** The types of XML nodes supported by TinyXml. (All the - unsupported types are picked up by UNKNOWN.) - */ - enum NodeType - { - DOCUMENT, - ELEMENT, - COMMENT, - UNKNOWN, - TEXT, - DECLARATION, - TYPECOUNT - }; - - virtual ~TiXmlNode(); - - /** The meaning of 'value' changes for the specific type of - TiXmlNode. - \verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - \endverbatim - - The subclasses will wrap this function. - */ - const char *Value() const { return value.c_str (); } - - #ifdef TIXML_USE_STL - /** Return Value() as a std::string. If you only use STL, - this is more efficient than calling Value(). - Only available in STL mode. - */ - const std::string& ValueStr() const { return value; } - #endif - - const TIXML_STRING& ValueTStr() const { return value; } - - /** Changes the value of the node. Defined as: - \verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - \endverbatim - */ - void SetValue(const char * _value) { value = _value;} - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Delete all the children of this node. Does not affect 'this'. - void Clear(); - - /// One step up the DOM. - TiXmlNode* Parent() { return parent; } - const TiXmlNode* Parent() const { return parent; } - - const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild() { return firstChild; } - const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. - /// The first child of this node with the matching 'value'. Will be null if none found. - TiXmlNode* FirstChild( const char * _value ) { - // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) - // call the method, cast the return back to non-const. - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); - } - const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild() { return lastChild; } - - const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. - TiXmlNode* LastChild( const char * _value ) { - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. - #endif - - /** An alternate way to walk the children of a node. - One way to iterate over nodes is: - \verbatim - for( child = parent->FirstChild(); child; child = child->NextSibling() ) - \endverbatim - - IterateChildren does the same thing with the syntax: - \verbatim - child = 0; - while( child = parent->IterateChildren( child ) ) - \endverbatim - - IterateChildren takes the previous child as input and finds - the next one. If the previous child is null, it returns the - first. IterateChildren will return null when done. - */ - const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); - } - - /// This flavor of IterateChildren searches for children with a particular 'value' - const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - #endif - - /** Add a new node related to this. Adds a child past the LastChild. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); - - - /** Add a new node related to this. Adds a child past the LastChild. - - NOTE: the node to be added is passed by pointer, and will be - henceforth owned (and deleted) by tinyXml. This method is efficient - and avoids an extra copy, but should be used with care as it - uses a different memory model than the other insert functions. - - \sa InsertEndChild - */ - TiXmlNode* LinkEndChild( TiXmlNode* addThis ); - - /** Add a new node related to this. Adds a child before the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); - - /** Add a new node related to this. Adds a child after the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); - - /** Replace a child of this node. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); - - /// Delete a child of this node. - bool RemoveChild( TiXmlNode* removeThis ); - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling() const { return prev; } - TiXmlNode* PreviousSibling() { return prev; } - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling( const char * ) const; - TiXmlNode* PreviousSibling( const char *_prev ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Navigate to a sibling node. - const TiXmlNode* NextSibling() const { return next; } - TiXmlNode* NextSibling() { return next; } - - /// Navigate to a sibling node with the given 'value'. - const TiXmlNode* NextSibling( const char * ) const; - TiXmlNode* NextSibling( const char* _next ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement() const; - TiXmlElement* NextSiblingElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement( const char * ) const; - TiXmlElement* NextSiblingElement( const char *_next ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement() const; - TiXmlElement* FirstChildElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); - } - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement( const char * _value ) const; - TiXmlElement* FirstChildElement( const char * _value ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /** Query the type (as an enumerated value, above) of this node. - The possible types are: DOCUMENT, ELEMENT, COMMENT, - UNKNOWN, TEXT, and DECLARATION. - */ - int Type() const { return type; } - - /** Return a pointer to the Document this node lives in. - Returns null if not in a document. - */ - const TiXmlDocument* GetDocument() const; - TiXmlDocument* GetDocument() { - return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); - } - - /// Returns true if this node has no children. - bool NoChildren() const { return !firstChild; } - - virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - /** Create an exact duplicate of this node and return it. The memory must be deleted - by the caller. - */ - virtual TiXmlNode* Clone() const = 0; - - /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the TiXmlVisitor interface. - - This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - \verbatim - TiXmlPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - \endverbatim - */ - virtual bool Accept( TiXmlVisitor* visitor ) const = 0; - -protected: - TiXmlNode( NodeType _type ); - - // Copy to the allocated object. Shared functionality between Clone, Copy constructor, - // and the assignment operator. - void CopyTo( TiXmlNode* target ) const; - - #ifdef TIXML_USE_STL - // The real work of the input operator. - virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; - #endif - - // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); - - TiXmlNode* parent; - NodeType type; - - TiXmlNode* firstChild; - TiXmlNode* lastChild; - - TIXML_STRING value; - - TiXmlNode* prev; - TiXmlNode* next; - -private: - TiXmlNode( const TiXmlNode& ); // not implemented. - void operator=( const TiXmlNode& base ); // not allowed. -}; - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - \note The attributes are not TiXmlNodes, since they are not - part of the tinyXML document object model. There are other - suggested ways to look at this problem. -*/ -class TiXmlAttribute : public TiXmlBase -{ - friend class TiXmlAttributeSet; - -public: - /// Construct an empty attribute. - TiXmlAttribute() : TiXmlBase() - { - document = 0; - prev = next = 0; - } - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlAttribute( const std::string& _name, const std::string& _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - #endif - - /// Construct an attribute with a name and value. - TiXmlAttribute( const char * _name, const char * _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - - const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. - #ifdef TIXML_USE_STL - const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. - #endif - int IntValue() const; ///< Return the value of this attribute, converted to an integer. - double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - - // Get the tinyxml string representation - const TIXML_STRING& NameTStr() const { return name; } - - /** QueryIntValue examines the value string. It is an alternative to the - IntValue() method with richer error checking. - If the value is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. - - A specialized but useful call. Note that for success it returns 0, - which is the opposite of almost all other TinyXml calls. - */ - int QueryIntValue( int* _value ) const; - /// QueryDoubleValue examines the value string. See QueryIntValue(). - int QueryDoubleValue( double* _value ) const; - - void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const char* _value ) { value = _value; } ///< Set the value. - - void SetIntValue( int _value ); ///< Set the value from an integer. - void SetDoubleValue( double _value ); ///< Set the value from a double. - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetName( const std::string& _name ) { name = _name; } - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Get the next sibling attribute in the DOM. Returns null at end. - const TiXmlAttribute* Next() const; - TiXmlAttribute* Next() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); - } - - /// Get the previous sibling attribute in the DOM. Returns null at beginning. - const TiXmlAttribute* Previous() const; - TiXmlAttribute* Previous() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); - } - - bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } - bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } - bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } - - /* Attribute parsing starts: first letter of the name - returns: the next char after the value end quote - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - // Prints this Attribute to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - - // [internal use] - // Set the document pointer so the attribute can report errors. - void SetDocument( TiXmlDocument* doc ) { document = doc; } - -private: - TiXmlAttribute( const TiXmlAttribute& ); // not implemented. - void operator=( const TiXmlAttribute& base ); // not allowed. - - TiXmlDocument* document; // A pointer back to a document, for error reporting. - TIXML_STRING name; - TIXML_STRING value; - TiXmlAttribute* prev; - TiXmlAttribute* next; -}; - - -/* A class used to manage a group of attributes. - It is only used internally, both by the ELEMENT and the DECLARATION. - - The set can be changed transparent to the Element and Declaration - classes that use it, but NOT transparent to the Attribute - which has to implement a next() and previous() method. Which makes - it a bit problematic and prevents the use of STL. - - This version is implemented with circular lists because: - - I like circular lists - - it demonstrates some independence from the (typical) doubly linked list. -*/ -class TiXmlAttributeSet -{ -public: - TiXmlAttributeSet(); - ~TiXmlAttributeSet(); - - void Add( TiXmlAttribute* attribute ); - void Remove( TiXmlAttribute* attribute ); - - const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - - const TiXmlAttribute* Find( const char* _name ) const; - TiXmlAttribute* Find( const char* _name ) { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); - } - #ifdef TIXML_USE_STL - const TiXmlAttribute* Find( const std::string& _name ) const; - TiXmlAttribute* Find( const std::string& _name ) { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); - } - - #endif - -private: - //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), - //*ME: this class must be also use a hidden/disabled copy-constructor !!! - TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed - void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) - - TiXmlAttribute sentinel; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TiXmlElement : public TiXmlNode -{ -public: - /// Construct an element. - TiXmlElement (const char * in_value); - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlElement( const std::string& _value ); - #endif - - TiXmlElement( const TiXmlElement& ); - - void operator=( const TiXmlElement& base ); - - virtual ~TiXmlElement(); - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - */ - const char* Attribute( const char* name ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an integer, - the integer value will be put in the return 'i', if 'i' - is non-null. - */ - const char* Attribute( const char* name, int* i ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an double, - the double value will be put in the return 'd', if 'd' - is non-null. - */ - const char* Attribute( const char* name, double* d ) const; - - /** QueryIntAttribute examines the attribute - it is an alternative to the - Attribute() method with richer error checking. - If the attribute is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. If the attribute - does not exist, then TIXML_NO_ATTRIBUTE is returned. - */ - int QueryIntAttribute( const char* name, int* _value ) const; - /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const char* name, double* _value ) const; - /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). - int QueryFloatAttribute( const char* name, float* _value ) const { - double d; - int result = QueryDoubleAttribute( name, &d ); - if ( result == TIXML_SUCCESS ) { - *_value = (float)d; - } - return result; - } - - #ifdef TIXML_USE_STL - /** Template form of the attribute query which will try to read the - attribute into the specified type. Very easy, very powerful, but - be careful to make sure to call this with the correct type. - - NOTE: This method doesn't work correctly for 'string' types. - - \return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE - */ - template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - std::stringstream sstream( node->ValueStr() ); - sstream >> *outValue; - if ( !sstream.fail() ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; - } - /* - This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" - but template specialization is hard to get working cross-compiler. Leaving the bug for now. - - // The above will fail for std::string because the space character is used as a seperator. - // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string - template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - *outValue = node->ValueStr(); - return TIXML_SUCCESS; - } - */ - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char* name, const char * _value ); - - #ifdef TIXML_USE_STL - const std::string* Attribute( const std::string& name ) const; - const std::string* Attribute( const std::string& name, int* i ) const; - const std::string* Attribute( const std::string& name, double* d ) const; - int QueryIntAttribute( const std::string& name, int* _value ) const; - int QueryDoubleAttribute( const std::string& name, double* _value ) const; - - /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& _value ); - ///< STL std::string form. - void SetAttribute( const std::string& name, int _value ); - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char * name, int value ); - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetDoubleAttribute( const char * name, double value ); - - /** Deletes an attribute with the given name. - */ - void RemoveAttribute( const char * name ); - #ifdef TIXML_USE_STL - void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. - #endif - - const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. - TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } - const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. - TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the TiXmlText child - and accessing it directly. - - If the first child of 'this' is a TiXmlText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - \verbatim - This is text - const char* str = fooElement->GetText(); - \endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - \verbatim - This is text - \endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - \verbatim - This is text - \endverbatim - GetText() will return "This is ". - - WARNING: GetText() accesses a child node - don't become confused with the - similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are - safe type casts on the referenced node. - */ - const char* GetText() const; - - /// Creates a new Element and returns it - the returned element is a copy. - virtual TiXmlNode* Clone() const; - // Print the Element to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: next char past '<' - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - - void CopyTo( TiXmlElement* target ) const; - void ClearThis(); // like clear, but initializes 'this' object as well - - // Used to be public [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - /* [internal use] - Reads the "value" of the element -- another element, or text. - This should terminate with the current end tag. - */ - const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - -private: - - TiXmlAttributeSet attributeSet; -}; - - -/** An XML comment. -*/ -class TiXmlComment : public TiXmlNode -{ -public: - /// Constructs an empty comment. - TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} - /// Construct a comment from text. - TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { - SetValue( _value ); - } - TiXmlComment( const TiXmlComment& ); - void operator=( const TiXmlComment& base ); - - virtual ~TiXmlComment() {} - - /// Returns a copy of this Comment. - virtual TiXmlNode* Clone() const; - // Write this Comment to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlComment* target ) const; - - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif -// virtual void StreamOut( TIXML_OSTREAM * out ) const; - -private: - -}; - - -/** XML text. A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCDATA() and query it with CDATA(). -*/ -class TiXmlText : public TiXmlNode -{ - friend class TiXmlElement; -public: - /** Constructor for text element. By default, it is treated as - normal, encoded text. If you want it be output as a CDATA text - element, set the parameter _cdata to 'true' - */ - TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - cdata = false; - } - virtual ~TiXmlText() {} - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - cdata = false; - } - #endif - - TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } - void operator=( const TiXmlText& base ) { base.CopyTo( this ); } - - // Write this text object to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /// Queries whether this represents text using a CDATA section. - bool CDATA() const { return cdata; } - /// Turns on or off a CDATA representation of text. - void SetCDATA( bool _cdata ) { cdata = _cdata; } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - /// [internal use] Creates a new Element and returns it. - virtual TiXmlNode* Clone() const; - void CopyTo( TiXmlText* target ) const; - - bool Blank() const; // returns true if all white space and new lines - // [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - bool cdata; // true if this should be input and output as a CDATA style text element -}; - - -/** In correct XML the declaration is the first entry in the file. - \verbatim - - \endverbatim - - TinyXml will happily read or write files without a declaration, - however. There are 3 possible attributes to the declaration: - version, encoding, and standalone. - - Note: In this version of the code, the attributes are - handled as special cases, not generic attributes, simply - because there can only be at most 3 and they are always the same. -*/ -class TiXmlDeclaration : public TiXmlNode -{ -public: - /// Construct an empty declaration. - TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} - -#ifdef TIXML_USE_STL - /// Constructor. - TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ); -#endif - - /// Construct. - TiXmlDeclaration( const char* _version, - const char* _encoding, - const char* _standalone ); - - TiXmlDeclaration( const TiXmlDeclaration& copy ); - void operator=( const TiXmlDeclaration& copy ); - - virtual ~TiXmlDeclaration() {} - - /// Version. Will return an empty string if none was found. - const char *Version() const { return version.c_str (); } - /// Encoding. Will return an empty string if none was found. - const char *Encoding() const { return encoding.c_str (); } - /// Is this a standalone document? - const char *Standalone() const { return standalone.c_str (); } - - /// Creates a copy of this Declaration and returns it. - virtual TiXmlNode* Clone() const; - // Print this declaration to a FILE stream. - virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlDeclaration* target ) const; - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - - TIXML_STRING version; - TIXML_STRING encoding; - TIXML_STRING standalone; -}; - - -/** Any tag that tinyXml doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into TiXmlUnknowns. -*/ -class TiXmlUnknown : public TiXmlNode -{ -public: - TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} - virtual ~TiXmlUnknown() {} - - TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); } - void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } - - /// Creates a copy of this Unknown and returns it. - virtual TiXmlNode* Clone() const; - // Print this Unknown to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected: - void CopyTo( TiXmlUnknown* target ) const; - - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - -}; - - -/** Always the top level node. A document binds together all the - XML pieces. It can be saved, loaded, and printed to the screen. - The 'value' of a document node is the xml file name. -*/ -class TiXmlDocument : public TiXmlNode -{ -public: - /// Create an empty document, that has no name. - TiXmlDocument(); - /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const char * documentName ); - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlDocument( const std::string& documentName ); - #endif - - TiXmlDocument( const TiXmlDocument& copy ); - void operator=( const TiXmlDocument& copy ); - - virtual ~TiXmlDocument() {} - - /** Load a file using the current document value. - Returns true if successful. Will delete any existing - document data before loading. - */ - bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the current document value. Returns true if successful. - bool SaveFile() const; - /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const char * filename ) const; - /** Load a file using the given FILE*. Returns true if successful. Note that this method - doesn't stream - the entire object pointed at by the FILE* - will be interpreted as an XML file. TinyXML doesn't stream in XML from the current - file location. Streaming may be added in the future. - */ - bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given FILE*. Returns true if successful. - bool SaveFile( FILE* ) const; - - #ifdef TIXML_USE_STL - bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && LoadFile( f.buffer, encoding )); - return LoadFile( filename.c_str(), encoding ); - } - bool SaveFile( const std::string& filename ) const ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && SaveFile( f.buffer )); - return SaveFile( filename.c_str() ); - } - #endif - - /** Parse the given null terminated block of xml data. Passing in an encoding to this - method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml - to use that encoding, regardless of what TinyXml might otherwise try to detect. - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - - /** Get the root element -- the only top level element -- of the document. - In well formed XML, there should only be one. TinyXml is tolerant of - multiple elements at the document level. - */ - const TiXmlElement* RootElement() const { return FirstChildElement(); } - TiXmlElement* RootElement() { return FirstChildElement(); } - - /** If an error occurs, Error will be set to true. Also, - - The ErrorId() will contain the integer identifier of the error (not generally useful) - - The ErrorDesc() method will return the name of the error. (very useful) - - The ErrorRow() and ErrorCol() will return the location of the error (if known) - */ - bool Error() const { return error; } - - /// Contains a textual (english) description of the error if one occurs. - const char * ErrorDesc() const { return errorDesc.c_str (); } - - /** Generally, you probably want the error string ( ErrorDesc() ). But if you - prefer the ErrorId, this function will fetch it. - */ - int ErrorId() const { return errorId; } - - /** Returns the location (if known) of the error. The first column is column 1, - and the first row is row 1. A value of 0 means the row and column wasn't applicable - (memory errors, for example, have no row/column) or the parser lost the error. (An - error in the error reporting, in that case.) - - \see SetTabSize, Row, Column - */ - int ErrorRow() const { return errorLocation.row+1; } - int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() - - /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) - to report the correct values for row and column. It does not change the output - or input in any way. - - By calling this method, with a tab size - greater than 0, the row and column of each node and attribute is stored - when the file is loaded. Very useful for tracking the DOM back in to - the source file. - - The tab size is required for calculating the location of nodes. If not - set, the default of 4 is used. The tabsize is set per document. Setting - the tabsize to 0 disables row/column tracking. - - Note that row and column tracking is not supported when using operator>>. - - The tab size needs to be enabled before the parse or load. Correct usage: - \verbatim - TiXmlDocument doc; - doc.SetTabSize( 8 ); - doc.Load( "myfile.xml" ); - \endverbatim - - \see Row, Column - */ - void SetTabSize( int _tabsize ) { tabsize = _tabsize; } - - int TabSize() const { return tabsize; } - - /** If you have handled the error, it can be reset with this call. The error - state is automatically cleared if you Parse a new XML block. - */ - void ClearError() { error = false; - errorId = 0; - errorDesc = ""; - errorLocation.row = errorLocation.col = 0; - //errorLocation.last = 0; - } - - /** Write the document to standard out using formatted printing ("pretty print"). */ - void Print() const { Print( stdout, 0 ); } - - /* Write the document to a string using formatted printing ("pretty print"). This - will allocate a character array (new char[]) and return it as a pointer. The - calling code pust call delete[] on the return char* to avoid a memory leak. - */ - //char* PrintToMemory() const; - - /// Print this Document to a FILE stream. - virtual void Print( FILE* cfile, int depth = 0 ) const; - // [internal use] - void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - - virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - // [internal use] - virtual TiXmlNode* Clone() const; - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - void CopyTo( TiXmlDocument* target ) const; - - bool error; - int errorId; - TIXML_STRING errorDesc; - int tabsize; - TiXmlCursor errorLocation; - bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. -}; - - -/** - A TiXmlHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml - DOM structure. It is a separate utility class. - - Take an example: - \verbatim - - - - - - - \endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - \verbatim - TiXmlElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - TiXmlElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - TiXmlElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - TiXmlElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - \endverbatim - - And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity - of such code. A TiXmlHandle checks for null pointers so it is perfectly safe - and correct to use: - - \verbatim - TiXmlHandle docHandle( &document ); - TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); - if ( child2 ) - { - // do something useful - \endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - \verbatim - TiXmlHandle handleCopy = handle; - \endverbatim - - What they should not be used for is iteration: - - \verbatim - int i=0; - while ( true ) - { - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); - if ( !child ) - break; - // do something - ++i; - } - \endverbatim - - It seems reasonable, but it is in fact two embedded while loops. The Child method is - a linear walk to find the element, so this code would iterate much more than it needs - to. Instead, prefer: - - \verbatim - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); - - for( child; child; child=child->NextSiblingElement() ) - { - // do something - } - \endverbatim -*/ -class TiXmlHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } - /// Copy constructor - TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } - TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } - - /// Return a handle to the first child node. - TiXmlHandle FirstChild() const; - /// Return a handle to the first child node with the given name. - TiXmlHandle FirstChild( const char * value ) const; - /// Return a handle to the first child element. - TiXmlHandle FirstChildElement() const; - /// Return a handle to the first child element with the given name. - TiXmlHandle FirstChildElement( const char * value ) const; - - /** Return a handle to the "index" child with the given name. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( const char* value, int index ) const; - /** Return a handle to the "index" child. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( int index ) const; - /** Return a handle to the "index" child element with the given name. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( const char* value, int index ) const; - /** Return a handle to the "index" child element. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( int index ) const; - - #ifdef TIXML_USE_STL - TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } - TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } - - TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } - TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } - #endif - - /** Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* ToNode() const { return node; } - /** Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } - /** Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } - /** Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } - - /** \deprecated use ToNode. - Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* Node() const { return ToNode(); } - /** \deprecated use ToElement. - Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* Element() const { return ToElement(); } - /** \deprecated use ToText() - Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* Text() const { return ToText(); } - /** \deprecated use ToUnknown() - Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* Unknown() const { return ToUnknown(); } - -private: - TiXmlNode* node; -}; - - -/** Print to memory functionality. The TiXmlPrinter is useful when you need to: - - -# Print to memory (especially in non-STL mode) - -# Control formatting (line endings, etc.) - - When constructed, the TiXmlPrinter is in its default "pretty printing" mode. - Before calling Accept() you can call methods to control the printing - of the XML document. After TiXmlNode::Accept() is called, the printed document can - be accessed via the CStr(), Str(), and Size() methods. - - TiXmlPrinter uses the Visitor API. - \verbatim - TiXmlPrinter printer; - printer.SetIndent( "\t" ); - - doc.Accept( &printer ); - fprintf( stdout, "%s", printer.CStr() ); - \endverbatim -*/ -class TiXmlPrinter : public TiXmlVisitor -{ -public: - TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), - buffer(), indent( " " ), lineBreak( "\n" ) {} - - virtual bool VisitEnter( const TiXmlDocument& doc ); - virtual bool VisitExit( const TiXmlDocument& doc ); - - virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); - virtual bool VisitExit( const TiXmlElement& element ); - - virtual bool Visit( const TiXmlDeclaration& declaration ); - virtual bool Visit( const TiXmlText& text ); - virtual bool Visit( const TiXmlComment& comment ); - virtual bool Visit( const TiXmlUnknown& unknown ); - - /** Set the indent characters for printing. By default 4 spaces - but tab (\t) is also useful, or null/empty string for no indentation. - */ - void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } - /// Query the indention string. - const char* Indent() { return indent.c_str(); } - /** Set the line breaking string. By default set to newline (\n). - Some operating systems prefer other characters, or can be - set to the null/empty string for no indenation. - */ - void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } - /// Query the current line breaking string. - const char* LineBreak() { return lineBreak.c_str(); } - - /** Switch over to "stream printing" which is the most dense formatting without - linebreaks. Common when the XML is needed for network transmission. - */ - void SetStreamPrinting() { indent = ""; - lineBreak = ""; - } - /// Return the result. - const char* CStr() { return buffer.c_str(); } - /// Return the length of the result string. - size_t Size() { return buffer.size(); } - - #ifdef TIXML_USE_STL - /// Return the result. - const std::string& Str() { return buffer; } - #endif - -private: - void DoIndent() { - for( int i=0; i -#include -#include - -#include "tinyxml.h" - -//#define DEBUG_PARSER -#if defined( DEBUG_PARSER ) -# if defined( DEBUG ) && defined( _WIN32 ) -# include -# define TIXML_LOG OutputDebugString -# else -# define TIXML_LOG printf -# endif -#endif - -// Note tha "PutString" hardcodes the same list. This -// is less flexible than it appears. Changing the entries -// or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = -{ - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } -}; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// Including the basic of this table, which determines the #bytes in the -// sequence from the lead byte. 1 placed for invalid sequences -- -// although the result will be junk, pass it through as much as possible. -// Beware of the non-characters in UTF-8: -// ef bb bf (Microsoft "lead bytes") -// ef bf be -// ef bf bf - -const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -const int TiXmlBase::utf8ByteTable[256] = -{ - // 0 1 2 3 4 5 6 7 8 9 a b c d e f - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid -}; - - -void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) - *length = 1; - else if ( input < 0x800 ) - *length = 2; - else if ( input < 0x10000 ) - *length = 3; - else if ( input < 0x200000 ) - *length = 4; - else - { *length = 0; return; } // This code won't covert this correctly anyway. - - output += *length; - - // Scary scary fall throughs. - switch (*length) - { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - } -} - - -/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalpha( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalpha( anyByte ); -// } -} - - -/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalnum( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalnum( anyByte ); -// } -} - - -class TiXmlParsingData -{ - friend class TiXmlDocument; - public: - void Stamp( const char* now, TiXmlEncoding encoding ); - - const TiXmlCursor& Cursor() { return cursor; } - - private: - // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) - { - assert( start ); - stamp = start; - tabsize = _tabsize; - cursor.row = row; - cursor.col = col; - } - - TiXmlCursor cursor; - const char* stamp; - int tabsize; -}; - - -void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) -{ - assert( now ); - - // Do nothing if the tabsize is 0. - if ( tabsize < 1 ) - { - return; - } - - // Get the current row, column. - int row = cursor.row; - int col = cursor.col; - const char* p = stamp; - assert( p ); - - while ( p < now ) - { - // Treat p as unsigned, so we have a happy compiler. - const unsigned char* pU = (const unsigned char*)p; - - // Code contributed by Fletcher Dunn: (modified by lee) - switch (*pU) { - case 0: - // We *should* never get here, but in case we do, don't - // advance past the terminating null character, ever - return; - - case '\r': - // bump down to the next line - ++row; - col = 0; - // Eat the character - ++p; - - // Check for \r\n sequence, and treat this as a single character - if (*p == '\n') { - ++p; - } - break; - - case '\n': - // bump down to the next line - ++row; - col = 0; - - // Eat the character - ++p; - - // Check for \n\r sequence, and treat this as a single - // character. (Yes, this bizarre thing does occur still - // on some arcane platforms...) - if (*p == '\r') { - ++p; - } - break; - - case '\t': - // Eat the character - ++p; - - // Skip to next tab stop - col = (col / tabsize + 1) * tabsize; - break; - - case TIXML_UTF_LEAD_0: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( *(p+1) && *(p+2) ) - { - // In these cases, don't advance the column. These are - // 0-width spaces. - if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) - p += 3; - else - { p +=3; ++col; } // A normal character. - } - } - else - { - ++p; - ++col; - } - break; - - default: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; - if ( step == 0 ) - step = 1; // Error case from bad encoding, but handle gracefully. - p += step; - - // Just advance one column, of course. - ++col; - } - else - { - ++p; - ++col; - } - break; - } - } - cursor.row = row; - cursor.col = col; - assert( cursor.row >= -1 ); - assert( cursor.col >= -1 ); - stamp = p; - assert( stamp ); -} - - -const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) -{ - if ( !p || !*p ) - { - return 0; - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - while ( *p ) - { - const unsigned char* pU = (const unsigned char*)p; - - // Skip the stupid Microsoft UTF-8 Byte order marks - if ( *(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==TIXML_UTF_LEAD_1 - && *(pU+2)==TIXML_UTF_LEAD_2 ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbeU ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbfU ) - { - p += 3; - continue; - } - - if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. - ++p; - else - break; - } - } - else - { - while ( (*p) && ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) ) - ++p; - } - - return p; -} - -#ifdef TIXML_USE_STL -/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) -{ - for( ;; ) - { - if ( !in->good() ) return false; - - int c = in->peek(); - // At this scope, we can't get to a document. So fail silently. - if ( !IsWhiteSpace( c ) || c <= 0 ) - return true; - - *tag += (char) in->get(); - } -} - -/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) -{ - //assert( character > 0 && character < 128 ); // else it won't work in utf-8 - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - if ( c <= 0 ) // Silent failure: can't get document at this scope - return false; - - in->get(); - *tag += (char) c; - } - return false; -} -#endif - -// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The -// "assign" optimization removes over 10% of the execution time. -// -const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) -{ - // Oddly, not supported on some comilers, - //name->clear(); - // So use this: - *name = ""; - assert( p ); - - // Names start with letters or underscores. - // Of course, in unicode, tinyxml has no idea what a letter *is*. The - // algorithm is generous. - // - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) - { - const char* start = p; - while( p && *p - && ( IsAlphaNum( (unsigned char ) *p, encoding ) - || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' ) ) - { - //(*name) += *p; // expensive - ++p; - } - if ( p-start > 0 ) { - name->assign( start, p-start ); - } - return p; - } - return 0; -} - -const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) -{ - // Presume an entity, and pull it out. - TIXML_STRING ent; - int i; - *length = 0; - - if ( *(p+1) && *(p+1) == '#' && *(p+2) ) - { - unsigned long ucs = 0; - ptrdiff_t delta = 0; - unsigned mult = 1; - - if ( *(p+2) == 'x' ) - { - // Hexadecimal. - if ( !*(p+3) ) return 0; - - const char* q = p+3; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != 'x' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else if ( *q >= 'a' && *q <= 'f' ) - ucs += mult * (*q - 'a' + 10); - else if ( *q >= 'A' && *q <= 'F' ) - ucs += mult * (*q - 'A' + 10 ); - else - return 0; - mult *= 16; - --q; - } - } - else - { - // Decimal. - if ( !*(p+2) ) return 0; - - const char* q = p+2; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != '#' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else - return 0; - mult *= 10; - --q; - } - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - } - else - { - *value = (char)ucs; - *length = 1; - } - return p + delta + 1; - } - - // Now try to match it. - for( i=0; iappend( cArr, len ); - } - } - else - { - bool whitespace = false; - - // Remove leading white space: - p = SkipWhiteSpace( p, encoding ); - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) ) - { - if ( *p == '\r' || *p == '\n' ) - { - whitespace = true; - ++p; - } - else if ( IsWhiteSpace( *p ) ) - { - whitespace = true; - ++p; - } - else - { - // If we've found whitespace, add it before the - // new character. Any whitespace just becomes a space. - if ( whitespace ) - { - (*text) += ' '; - whitespace = false; - } - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - if ( len == 1 ) - (*text) += cArr[0]; // more efficient - else - text->append( cArr, len ); - } - } - } - if ( p ) - p += strlen( endTag ); - return p; -} - -#ifdef TIXML_USE_STL - -void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - // The basic issue with a document is that we don't know what we're - // streaming. Read something presumed to be a tag (and hope), then - // identify it, and call the appropriate stream method on the tag. - // - // This "pre-streaming" will never read the closing ">" so the - // sub-tag can orient itself. - - if ( !StreamTo( in, '<', tag ) ) - { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - while ( in->good() ) - { - int tagIndex = (int) tag->length(); - while ( in->good() && in->peek() != '>' ) - { - int c = in->get(); - if ( c <= 0 ) - { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - break; - } - (*tag) += (char) c; - } - - if ( in->good() ) - { - // We now have something we presume to be a node of - // some sort. Identify it, and call the node to - // continue streaming. - TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); - - if ( node ) - { - node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; - delete node; - node = 0; - - // If this is the root element, we're done. Parsing will be - // done by the >> operator. - if ( isElement ) - { - return; - } - } - else - { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - } - } - // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); -} - -#endif - -const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) -{ - ClearError(); - - // Parse away, at the document level. Since a document - // contains nothing but other tags, most of what happens - // here is skipping white space. - if ( !p || !*p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - // Note that, for a document, this needs to come - // before the while space skip, so that parsing - // starts from the pointer we are given. - location.Clear(); - if ( prevData ) - { - location.row = prevData->cursor.row; - location.col = prevData->cursor.col; - } - else - { - location.row = 0; - location.col = 0; - } - TiXmlParsingData data( p, TabSize(), location.row, location.col ); - location = data.Cursor(); - - if ( encoding == TIXML_ENCODING_UNKNOWN ) - { - // Check for the Microsoft UTF-8 lead bytes. - const unsigned char* pU = (const unsigned char*)p; - if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 - && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 - && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) - { - encoding = TIXML_ENCODING_UTF8; - useMicrosoftBOM = true; - } - } - - p = SkipWhiteSpace( p, encoding ); - if ( !p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - while ( p && *p ) - { - TiXmlNode* node = Identify( p, encoding ); - if ( node ) - { - p = node->Parse( p, &data, encoding ); - LinkEndChild( node ); - } - else - { - break; - } - - // Did we get encoding info? - if ( encoding == TIXML_ENCODING_UNKNOWN - && node->ToDeclaration() ) - { - TiXmlDeclaration* dec = node->ToDeclaration(); - const char* enc = dec->Encoding(); - assert( enc ); - - if ( *enc == 0 ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice - else - encoding = TIXML_ENCODING_LEGACY; - } - - p = SkipWhiteSpace( p, encoding ); - } - - // Was this empty? - if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; - } - - // All is well. - return p; -} - -void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - // The first error in a chain is more accurate - don't set again! - if ( error ) - return; - - assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); - error = true; - errorId = err; - errorDesc = errorString[ errorId ]; - - errorLocation.Clear(); - if ( pError && data ) - { - data->Stamp( pError, encoding ); - errorLocation = data->Cursor(); - } -} - - -TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) -{ - TiXmlNode* returnNode = 0; - - p = SkipWhiteSpace( p, encoding ); - if( !p || !*p || *p != '<' ) - { - return 0; - } - - TiXmlDocument* doc = GetDocument(); - p = SkipWhiteSpace( p, encoding ); - - if ( !p || !*p ) - { - return 0; - } - - // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: "; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // [ 1475201 ] TinyXML parses entities in comments - // Oops - ReadText doesn't work, because we don't want to parse the entities. - // p = ReadText( p, &value, false, endTag, false, encoding ); - // - // from the XML spec: - /* - [Definition: Comments may appear anywhere in a document outside other markup; in addition, - they may appear within the document type declaration at places allowed by the grammar. - They are not part of the document's character data; an XML processor MAY, but need not, - make it possible for an application to retrieve the text of comments. For compatibility, - the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity - references MUST NOT be recognized within comments. - - An example of a comment: - - - */ - - value = ""; - // Keep all the white space. - while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) - { - value.append( p, 1 ); - ++p; - } - if ( p ) - p += strlen( endTag ); - - return p; -} - - -const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; - -// int tabsize = 4; -// if ( document ) -// tabsize = document->TabSize(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - // Read the name, the '=' and the value. - const char* pErr = p; - p = ReadName( p, &name, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; - } - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p || *p != '=' ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - ++p; // skip '=' - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - const char* end; - const char SINGLE_QUOTE = '\''; - const char DOUBLE_QUOTE = '\"'; - - if ( *p == SINGLE_QUOTE ) - { - ++p; - end = "\'"; // single quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else if ( *p == DOUBLE_QUOTE ) - { - ++p; - end = "\""; // double quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else - { - // All attribute values should be in single or double quotes. - // But this is such a common error that the parser will try - // its best, even without them. - value = ""; - while ( p && *p // existence - && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace - && *p != '/' && *p != '>' ) // tag end - { - if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { - // [ 1451649 ] Attribute values with trailing quotes not handled correctly - // We did not have an opening quote but seem to have a - // closing one. Give up and throw an error. - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - value += *p; - ++p; - } - } - return p; -} - -#ifdef TIXML_USE_STL -void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->peek(); - if ( !cdata && (c == '<' ) ) - { - return; - } - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - (*tag) += (char) c; - in->get(); // "commits" the peek made above - - if ( cdata && c == '>' && tag->size() >= 3 ) { - size_t len = tag->size(); - if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { - // terminator of cdata. - return; - } - } - } -} -#endif - -const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - value = ""; - TiXmlDocument* document = GetDocument(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - - const char* const startTag = ""; - - if ( cdata || StringEqual( p, startTag, false, encoding ) ) - { - cdata = true; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // Keep all the white space, ignore the encoding, etc. - while ( p && *p - && !StringEqual( p, endTag, false, encoding ) - ) - { - value += *p; - ++p; - } - - TIXML_STRING dummy; - p = ReadText( p, &dummy, false, endTag, false, encoding ); - return p; - } - else - { - bool ignoreWhite = true; - - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p ) - return p-1; // don't truncate the '<' - return 0; - } -} - -#ifdef TIXML_USE_STL -void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c; - - if ( c == '>' ) - { - // All is well. - return; - } - } -} -#endif - -const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) -{ - p = SkipWhiteSpace( p, _encoding ); - // Find the beginning, find the end, and look for - // the stuff in-between. - TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; - } - if ( data ) - { - data->Stamp( p, _encoding ); - location = data->Cursor(); - } - p += 5; - - version = ""; - encoding = ""; - standalone = ""; - - while ( p && *p ) - { - if ( *p == '>' ) - { - ++p; - return p; - } - - p = SkipWhiteSpace( p, _encoding ); - if ( StringEqual( p, "version", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - version = attrib.Value(); - } - else if ( StringEqual( p, "encoding", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - encoding = attrib.Value(); - } - else if ( StringEqual( p, "standalone", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - standalone = attrib.Value(); - } - else - { - // Read over whatever it is. - while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) - ++p; - } - } - return 0; -} - -bool TiXmlText::Blank() const -{ - for ( unsigned i=0; i -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "../Manager.h" -#include "../Driver.h" -#include "../Node.h" -#include "../Notification.h" -#include "../Msg.h" -#include "Value.h" -#include "../platform/Log.h" -#include "../command_classes/CommandClass.h" -#include -#include "../Options.h" - -using namespace OpenZWave; - -static char const* c_genreName[] = -{ - "basic", - "user", - "config", - "system", - "invalid" -}; - -static char const* c_typeName[] = -{ - "bool", - "byte", - "decimal", - "int", - "list", - "schedule", - "short", - "string", - "button", - "raw" -}; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -Value::Value -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - ValueID::ValueType const _type, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - bool const _isSet, - uint8 const _pollIntensity -): - m_min( 0 ), - m_max( 0 ), - m_refreshTime(0), - m_verifyChanges( false ), - m_id( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, _type ), - m_label( _label ), - m_units( _units ), - m_help( "" ), - m_readOnly( _readOnly ), - m_writeOnly( _writeOnly ), - m_isSet( _isSet ), - m_affectsLength( 0 ), - m_affects(), - m_affectsAll( false ), - m_checkChange( false ), - m_pollIntensity( _pollIntensity ) -{ -} - -//----------------------------------------------------------------------------- -// -// Constructor (from XML) -//----------------------------------------------------------------------------- -Value::Value -( -): - m_min( 0 ), - m_max( 0 ), - m_refreshTime(0), - m_verifyChanges( false ), - m_readOnly( false ), - m_writeOnly( false ), - m_isSet( false ), - m_affectsLength( 0 ), - m_affects(), - m_affectsAll( false ), - m_checkChange( false ), - m_pollIntensity( 0 ) -{ -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -Value::~Value -( -) -{ - if( m_affectsLength > 0 ) - { - delete [] m_affects; - } -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void Value::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - int intVal; - - ValueID::ValueGenre genre = Value::GetGenreEnumFromName( _valueElement->Attribute( "genre" ) ); - ValueID::ValueType type = Value::GetTypeEnumFromName( _valueElement->Attribute( "type" ) ); - - uint8 instance = 1; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "instance", &intVal ) ) - { - instance = (uint8)intVal; - } - - uint8 index = 0; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "index", &intVal ) ) - { - index = (uint8)intVal; - } - - m_id = ValueID( _homeId, _nodeId, genre, _commandClassId, instance, index, type ); - - char const* label = _valueElement->Attribute( "label" ); - if( label ) - { - m_label = label; - } - - char const* units = _valueElement->Attribute( "units" ); - if( units ) - { - m_units = units; - } - - char const* readOnly = _valueElement->Attribute( "read_only" ); - if( readOnly ) - { - m_readOnly = !strcmp( readOnly, "true" ); - } - - char const* writeOnly = _valueElement->Attribute( "write_only" ); - if( writeOnly ) - { - m_writeOnly = !strcmp( writeOnly, "true" ); - } - - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "poll_intensity", &intVal ) ) - { - m_pollIntensity = (uint8)intVal; - } - - char const* affects = _valueElement->Attribute( "affects" ); - if( affects ) - { - if ( m_affectsLength != 0 ) - { - delete [] m_affects; - } - m_affectsLength = 0; - if( !strcmp( affects, "all" ) ) - { - m_affectsAll = true; - } - else - { - size_t len = strlen( affects ); - if( len > 0 ) - { - for( size_t i = 0; i < len; i++ ) - { - if( affects[i] == ',' ) - { - m_affectsLength++; - } - else if(affects[i] < '0' || affects[i] > '9') - { - Log::Write( LogLevel_Info, "Improperly formatted affects data: \"%s\"", affects); - break; - } - } - m_affectsLength++; - m_affects = new uint8[m_affectsLength]; - unsigned int j = 0; - for( int i = 0; i < m_affectsLength; i++ ) - { - m_affects[i] = atoi( &affects[j] ); - while( j < len && affects[j] != ',' ) - { - j++; - } - j++; - } - } - } - } - - char const* verifyChanges = _valueElement->Attribute( "verify_changes" ); - if( verifyChanges ) - { - m_verifyChanges = !strcmp( verifyChanges, "true" ); - } - - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "min", &intVal ) ) - { - m_min = intVal; - } - - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "max", &intVal ) ) - { - m_max = intVal; - } - - TiXmlElement const* helpElement = _valueElement->FirstChildElement(); - while( helpElement ) - { - char const* str = helpElement->Value(); - if( str && !strcmp( str, "Help" ) ) - { - str = helpElement->GetText(); - if( str ) - { - m_help = str; - } - break; - } - - helpElement = helpElement->NextSiblingElement(); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void Value::WriteXML -( - TiXmlElement* _valueElement -) -{ - char str[16]; - - _valueElement->SetAttribute( "type", GetTypeNameFromEnum(m_id.GetType()) ); - _valueElement->SetAttribute( "genre", GetGenreNameFromEnum(m_id.GetGenre()) ); - - snprintf( str, sizeof(str), "%d", m_id.GetInstance() ); - _valueElement->SetAttribute( "instance", str ); - - snprintf( str, sizeof(str), "%d", m_id.GetIndex() ); - _valueElement->SetAttribute( "index", str ); - - _valueElement->SetAttribute( "label", m_label.c_str() ); - _valueElement->SetAttribute( "units", m_units.c_str() ); - _valueElement->SetAttribute( "read_only", m_readOnly ? "true" : "false" ); - _valueElement->SetAttribute( "write_only", m_writeOnly ? "true" : "false" ); - _valueElement->SetAttribute( "verify_changes", m_verifyChanges ? "true" : "false" ); - - snprintf( str, sizeof(str), "%d", m_pollIntensity ); - _valueElement->SetAttribute( "poll_intensity", str ); - - snprintf( str, sizeof(str), "%d", m_min ); - _valueElement->SetAttribute( "min", str ); - - snprintf( str, sizeof(str), "%d", m_max ); - _valueElement->SetAttribute( "max", str ); - - if( m_affectsAll ) - { - _valueElement->SetAttribute( "affects", "all" ); - } - else if( m_affectsLength > 0 ) - { - string s; - for( int i = 0; i < m_affectsLength; i++ ) - { - snprintf( str, sizeof(str), "%d", m_affects[i] ); - s = s + str; - if( i + 1 < m_affectsLength ) - { - s = s + ","; - } - - } - _valueElement->SetAttribute( "affects", s.c_str() ); - } - - if( m_help.length() > 0 ) - { - TiXmlElement* helpElement = new TiXmlElement( "Help" ); - _valueElement->LinkEndChild( helpElement ); - - TiXmlText* textElement = new TiXmlText( m_help.c_str() ); - helpElement->LinkEndChild( textElement ); - } -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool Value::Set -( -) -{ - // nothing to do if this is a read-only value (return false to indicate an error) - if( IsReadOnly() ) - { - return false; - } - - // retrieve the driver, node and commandclass object for this value - bool res = false; - Node* node = NULL; - if( Driver* driver = Manager::Get()->GetDriver( m_id.GetHomeId() ) ) - { - node = driver->GetNodeUnsafe( m_id.GetNodeId() ); - if( node != NULL ) - { - if( CommandClass* cc = node->GetCommandClass( m_id.GetCommandClassId() ) ) - { - // flag value as set and queue a "Set Value" message for transmission to the device - res = cc->SetValue( *this ); - - if( res ) - { - if( !IsWriteOnly() ) - { - // queue a "RequestValue" message to update the value - cc->RequestValue( 0, m_id.GetIndex(), m_id.GetInstance(), Driver::MsgQueue_Send ); - } - else - { - // There is a "bug" here in that write only values - // never send a notification about the value changing. - // For sleeping devices it may not change until the - // device wakes up at some point in the future. - // So when is the right time to change it? - if( m_affectsAll ) - { - node->RequestAllConfigParams( 0 ); - } - else if( m_affectsLength > 0 ) - { - for( int i = 0; i < m_affectsLength; i++ ) - { - node->RequestConfigParam( m_affects[i] ); - } - } - } - } - } - } - } - - return res; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void Value::OnValueRefreshed -( -) -{ - if( IsWriteOnly() ) - { - return; - } - - if( Driver* driver = Manager::Get()->GetDriver( m_id.GetHomeId() ) ) - { - m_isSet = true; - - bool bSuppress; - Options::Get()->GetOptionAsBool( "SuppressValueRefresh", &bSuppress ); - if( !bSuppress ) - { - // Notify the watchers - Notification* notification = new Notification( Notification::Type_ValueRefreshed ); - notification->SetValueId( m_id ); - driver->QueueNotification( notification ); - } - } -} - - -//----------------------------------------------------------------------------- -// -// A value in a device has changed -//----------------------------------------------------------------------------- -void Value::OnValueChanged -( -) -{ - if( IsWriteOnly() ) - { - return; - } - - if( Driver* driver = Manager::Get()->GetDriver( m_id.GetHomeId() ) ) - { - m_isSet = true; - - // Notify the watchers - Notification* notification = new Notification( Notification::Type_ValueChanged ); - notification->SetValueId( m_id ); - driver->QueueNotification( notification ); - } - /* Call Back to the Command Class that this Value has changed, so we can search the - * TriggerRefreshValue vector to see if we should request any other values to be - * refreshed. - */ - Node* node = NULL; - if( Driver* driver = Manager::Get()->GetDriver( m_id.GetHomeId() ) ) - { - node = driver->GetNodeUnsafe( m_id.GetNodeId() ); - if( node != NULL ) - { - if( CommandClass* cc = node->GetCommandClass( m_id.GetCommandClassId() ) ) - { - cc->CheckForRefreshValues(this); - } - } - } - -} - -//----------------------------------------------------------------------------- -// -// Static helper to get a genre enum from a string -//----------------------------------------------------------------------------- -ValueID::ValueGenre Value::GetGenreEnumFromName -( - char const* _name -) -{ - ValueID::ValueGenre genre = ValueID::ValueGenre_System; - if( _name ) - { - for( int i=0; i<(int)ValueID::ValueGenre_Count; ++i ) - { - if( !strcmp( _name, c_genreName[i] ) ) - { - genre = (ValueID::ValueGenre)i; - break; - } - } - } - - return genre; -} - -//----------------------------------------------------------------------------- -// -// Static helper to get a genre enum as a string -//----------------------------------------------------------------------------- -char const* Value::GetGenreNameFromEnum -( - ValueID::ValueGenre _genre -) -{ - return c_genreName[_genre]; -} - -//----------------------------------------------------------------------------- -// -// Static helper to get a type enum from a string -//----------------------------------------------------------------------------- -ValueID::ValueType Value::GetTypeEnumFromName -( - char const* _name -) -{ - ValueID::ValueType type = ValueID::ValueType_Bool; - if( _name ) - { - for( int i=0; i<=(int)ValueID::ValueType_Max; ++i ) - { - if( !strcmp( _name, c_typeName[i] ) ) - { - type = (ValueID::ValueType)i; - break; - } - } - } - - return type; -} - -//----------------------------------------------------------------------------- -// -// Static helper to get a type enum as a string -//----------------------------------------------------------------------------- -char const* Value::GetTypeNameFromEnum -( - ValueID::ValueType _type -) -{ - return c_typeName[_type]; -} - -//----------------------------------------------------------------------------- -// -// Check a refreshed value -//----------------------------------------------------------------------------- -int Value::VerifyRefreshedValue -( - void* _originalValue, - void* _checkValue, - void* _newValue, - int _type, - int _length // = 0 -) -{ - // TODO: this is pretty rough code, but it's reused by each value type. It would be - // better if the actions were taken (m_value = _value, etc.) in this code rather than - // in the calling routine as a result of the return value. In particular, it's messy - // to be setting these values after the refesh or notification is sent. With some - // focus on the actual variable storage, we should be able to accomplish this with - // memory functions. It's really the strings that make things complicated(?). - // if this is the first read of a value, assume it is valid (and notify as a change) - if( !IsSet() ) - { - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Initial read of value" ); - Value::OnValueChanged(); - return 2; // confirmed change of value - } - else - { - switch( _type ) - { - case 1: // string - { - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%s, new value=%s, type=%s", ((string*)_originalValue)->c_str(), ((string*)_newValue)->c_str(), "string" ); - break; - } - case 2: // short - { - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%d, new value=%d, type=%s", *((short*)_originalValue), *((short*)_newValue), "short"); - break; - } - case 3: // int32 - { - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%d, new value=%d, type=%s", *((int32*)_originalValue), *((int32*)_newValue), "int32" ); - break; - } - case 4: // uint8 - { - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%d, new value=%d, type=%s", *((uint8*)_originalValue), *((uint8*)_newValue), "uint8" ); - break; - } - case 5: // bool - { - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%s, new value=%s, type=%s", *((bool*)_originalValue)?"true":"false", *((uint8*)_newValue)?"true":"false", "bool" ); - break; - } - case 6: // raw - { - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Refreshed Value: old value=%x, new value=%x, type=raw", _originalValue, _newValue ); - break; - } - default: - { - break; - } - } - } - m_refreshTime = time( NULL ); // update value refresh time - - // check whether changes in this value should be verified (since some devices will report values that always - // change, where confirming changes is difficult or impossible) - Log::Write( LogLevel_Detail, m_id.GetNodeId(), "Changes to this value are %sverified", m_verifyChanges ? "" : "not " ); - - if( !m_verifyChanges ) - { - // since we're not checking changes in this value, notify ValueChanged (to be on the safe side) - Value::OnValueChanged(); - return 2; // confirmed change of value - } - - // see if the value has changed (result is used whether checking change or not) - bool bOriginalEqual = false; - switch( _type ) - { - case 1: // string - bOriginalEqual = ( strcmp( ((string*)_originalValue)->c_str(), ((string*)_newValue)->c_str() ) == 0 ); - break; - case 2: // short - bOriginalEqual = ( *((short*)_originalValue) == *((short*)_newValue) ); - break; - case 3: // int32 - bOriginalEqual = ( *((int32*)_originalValue) == *((int32*)_newValue) ); - break; - case 4: // uint8 - bOriginalEqual = ( *((uint8*)_originalValue) == *((uint8*)_newValue) ); - break; - case 5: // bool - bOriginalEqual = ( *((bool*)_originalValue) == *((bool*)_newValue) ); - break; - case 6: // raw - bOriginalEqual = ( memcmp( _originalValue, _newValue, _length ) == 0 ); - break; - } - - // if this is the first refresh of the value, test to see if the value has changed - if( !IsCheckingChange() ) - { - if( bOriginalEqual ) - { - // values are the same, so signal a refresh and return - Value::OnValueRefreshed(); - return 0; // value hasn't changed - } - - // values are different, so flag this as a verification refresh and queue it - Log::Write( LogLevel_Info, m_id.GetNodeId(), "Changed value (possible)--rechecking" ); - SetCheckingChange( true ); - Manager::Get()->RefreshValue( GetID() ); - return 1; // value has changed (to be confirmed) - } - else // IsCheckingChange is true if this is the second read of a potentially changed value - { - // if the second read is the same as the first read, the value really changed - bool bCheckEqual = false; - switch( _type ) - { - case 1: // string - bCheckEqual = ( strcmp( ((string*)_checkValue)->c_str(), ((string*)_newValue)->c_str() ) == 0 ); - break; - case 2: // short - bCheckEqual = ( *((short*)_checkValue) == *((short*)_newValue) ); - break; - case 3: // int32 - bCheckEqual = ( *((int32*)_checkValue) == *((int32*)_newValue) ); - break; - case 4: // uint8 - bCheckEqual = ( *((uint8*)_checkValue) == *((uint8*)_newValue) ); - break; - case 5: // bool - bCheckEqual = ( *((bool*)_checkValue) == *((bool*)_newValue) ); - break; - case 6: - bCheckEqual = ( memcmp( _checkValue, _newValue, _length ) == 0 ); - break; - } - if( bCheckEqual ) - { - Log::Write( LogLevel_Info, m_id.GetNodeId(), "Changed value--confirmed" ); - SetCheckingChange( false ); - - // update the saved value and send notification - Value::OnValueChanged(); - return 2; - } - - // if the second read is the same as the original value, the first read is assumed to have been in error - // log this situation, but don't change the value or send a ValueChanged Notification - if( bOriginalEqual ) - { - Log::Write( LogLevel_Info, m_id.GetNodeId(), "Spurious value change was noted." ); - SetCheckingChange( false ); - Value::OnValueRefreshed(); - return 0; - } - - // the second read is different than both the original value and the checked value...retry - // keep trying until we get the same value twice - Log::Write( LogLevel_Info, m_id.GetNodeId(), "Changed value (changed again)--rechecking" ); - SetCheckingChange( true ); - - // save a temporary copy of value and re-read value from device - Manager::Get()->RefreshValue( GetID() ); - return 1; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/Value.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/Value.h deleted file mode 100644 index b28f6e3..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/Value.h +++ /dev/null @@ -1,127 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Value.h -// -// Base class for all OpenZWave Value Classes -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _Value_H -#define _Value_H - -#include -#include -#include "../Defs.h" -#include "../platform/Ref.h" -#include "ValueID.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Node; - - /** \brief Base class for values associated with a node. - */ - class Value: public Ref - { - friend class Driver; - friend class ValueStore; - - public: - Value( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, ValueID::ValueType const _type, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, bool const _isset, uint8 const _pollIntensity ); - Value(); - - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - ValueID const& GetID()const{ return m_id; } - bool IsReadOnly()const{ return m_readOnly; } - bool IsWriteOnly()const{ return m_writeOnly; } - bool IsSet()const{ return m_isSet; } - bool IsPolled()const{ return m_pollIntensity != 0; } - - string const& GetLabel()const{ return m_label; } - void SetLabel( string const& _label ){ m_label = _label; } - - string const& GetUnits()const{ return m_units; } - void SetUnits( string const& _units ){ m_units = _units; } - - string const& GetHelp()const{ return m_help; } - void SetHelp( string const& _help ){ m_help = _help; } - - uint8 const& GetPollIntensity()const{ return m_pollIntensity; } - void SetPollIntensity( uint8 const& _intensity ){ m_pollIntensity = _intensity; } - - int32 GetMin()const{ return m_min; } - int32 GetMax()const{ return m_max; } - - void SetChangeVerified( bool _verify ){ m_verifyChanges = _verify; } - - virtual string const GetAsString() const { return ""; } - virtual bool SetFromString( string const& _value ) { return false; } - - bool Set(); // For the user to change a value in a device - - // Helpers - static ValueID::ValueGenre GetGenreEnumFromName( char const* _name ); - static char const* GetGenreNameFromEnum( ValueID::ValueGenre _genre ); - static ValueID::ValueType GetTypeEnumFromName( char const* _name ); - static char const* GetTypeNameFromEnum( ValueID::ValueType _type ); - - protected: - virtual ~Value(); - -// void SetIsSet() { m_isSet = true; } // TODO: consider removing this...it's never called since m_isSet is set in ValueChanged and ValueRefreshed - bool IsCheckingChange()const{ return m_checkChange; } - void SetCheckingChange( bool _check ) { m_checkChange = _check; } - void OnValueRefreshed(); // A value in a device has been refreshed - void OnValueChanged(); // The refreshed value actually changed - int VerifyRefreshedValue( void* _originalValue, void* _checkValue, void* _newValue, int _type, int _length = 0 ); - - int32 m_min; - int32 m_max; - - time_t m_refreshTime; // time_t identifying when this value was last refreshed - bool m_verifyChanges; // if true, apparent changes are verified; otherwise, they're not - - private: - ValueID m_id; - string m_label; - string m_units; - string m_help; - bool m_readOnly; - bool m_writeOnly; - bool m_isSet; - uint8 m_affectsLength; - uint8* m_affects; - bool m_affectsAll; - bool m_checkChange; - uint8 m_pollIntensity; - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueBool.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueBool.cpp deleted file mode 100644 index 63763bc..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueBool.cpp +++ /dev/null @@ -1,161 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueBool.cpp -// -// Represents a boolean value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "ValueBool.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" -#include "../Manager.h" -#include - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueBool::ValueBool -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - bool const _value, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Bool, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_value( _value ), - m_valueCheck( false ), - m_newValue( false ) -{ -} - -bool ValueBool::SetFromString -( - string const& _value -) -{ - if ( !strcasecmp( "true", _value.c_str() ) ) { - return Set( true ); - } - else if ( !strcasecmp( "false", _value.c_str() ) ) { - return Set( false ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueBool::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - char const* str = _valueElement->Attribute( "value" ); - if( str ) - { - m_value = !strcmp( str, "True" ); - } - else - { - Log::Write( LogLevel_Info, "Missing default boolean value from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueBool::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - _valueElement->SetAttribute( "value", m_value ? "True" : "False" ); -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool ValueBool::Set -( - bool const _value -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueBool* tempValue = new ValueBool( *this ); - tempValue->m_value = _value; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueBool::OnValueRefreshed -( - bool const _value -) -{ - switch( VerifyRefreshedValue( (void*) &m_value, (void*) &m_valueCheck, (void*) &_value, 5) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - m_valueCheck = _value; - break; - case 2: // value has changed (confirmed), save _value in m_value - m_value = _value; - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueBool.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueBool.h deleted file mode 100644 index 676f3ec..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueBool.h +++ /dev/null @@ -1,74 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueBool.h -// -// Represents a boolean value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueBool_H -#define _ValueBool_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - class CommandClass; - - /** \brief Boolean value sent to/received from a node. - */ - class ValueBool: public Value - { - public: - ValueBool( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, bool const _value, uint8 const _pollIntensity ); - ValueBool(){} - virtual ~ValueBool(){} - - bool Set( bool const _value ); - void OnValueRefreshed( bool const _value ); - - // From Value - virtual string const GetAsString() const { return ( GetValue() ? "True" : "False" ); } - virtual bool SetFromString( string const& _value ); - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - bool GetValue()const{ return m_value; } - - private: - bool m_value; // the current index in the m_items vector - bool m_valueCheck; // the previous value (used for double-checking spurious value reads) - bool m_newValue; // a new value to be set on the appropriate device - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueButton.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueButton.cpp deleted file mode 100644 index deae7e2..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueButton.cpp +++ /dev/null @@ -1,120 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueButton.h -// -// Represents a write-only value that triggers activity in a device -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "ValueButton.h" -#include "../Manager.h" -#include "../Driver.h" -#include "../Node.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueButton::ValueButton -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Button, _label, "", false, true, true, _pollIntensity ), - m_pressed( false ) -{ -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueButton::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueButton::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); -} - -//----------------------------------------------------------------------------- -// -// Start an activity in a device -//----------------------------------------------------------------------------- -bool ValueButton::PressButton -( -) -{ - // Set the value in the device. - m_pressed = true; - return Value::Set(); -} - -//----------------------------------------------------------------------------- -// -// Stop an activity in a device -//----------------------------------------------------------------------------- -bool ValueButton::ReleaseButton -( -) -{ - // Set the value in the device. - m_pressed = false; - bool res = Value::Set(); - if( Driver* driver = Manager::Get()->GetDriver( GetID().GetHomeId() ) ) - { - if( Node* node = driver->GetNodeUnsafe( GetID().GetNodeId() ) ) - { - node->RequestDynamicValues(); - } - } - return res; -} - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueButton.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueButton.h deleted file mode 100644 index 33d89c6..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueButton.h +++ /dev/null @@ -1,70 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueButton.h -// -// Represents a write-only value that triggers activity in a device -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueButton_H -#define _ValueButton_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - class CommandClass; - - /** \brief Button value ???. - */ - class ValueButton: public Value - { - public: - ValueButton( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, uint8 const _pollIntensity ); - ValueButton(): m_pressed( false ){} - virtual ~ValueButton(){} - - bool PressButton(); - bool ReleaseButton(); - - // From Value - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - bool IsPressed()const{ return m_pressed; } - - private: - bool m_pressed; - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueByte.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueByte.cpp deleted file mode 100644 index 44be50f..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueByte.cpp +++ /dev/null @@ -1,186 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueByte.cpp -// -// Represents an 8-bit value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include "../tinyxml.h" -#include "ValueByte.h" -#include "../Msg.h" -#include "../platform/Log.h" -#include "../Manager.h" -#include - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueByte::ValueByte -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - uint8 const _value, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Byte, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_value( _value ), - m_valueCheck( false ), - m_newValue( false ) -{ - m_min = 0; - m_max = 255; -} - -//----------------------------------------------------------------------------- -// -// Constructor (from XML) -//----------------------------------------------------------------------------- -ValueByte::ValueByte -( -) -{ - m_min = 0; - m_max = 255; -} - -string const ValueByte::GetAsString -( -) const -{ - stringstream ss; - ss << GetValue(); - return ss.str(); -} - -bool ValueByte::SetFromString -( - string const& _value -) -{ - uint32 val = (uint32)atoi( _value.c_str() ); - if( val < 256 ) - { - return Set( (uint8)val ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueByte::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - int intVal; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "value", &intVal ) ) - { - m_value = (uint8)intVal; - } - else - { - Log::Write( LogLevel_Info, "Missing default byte value from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueByte::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - - char str[8]; - snprintf( str, sizeof(str), "%d", m_value ); - _valueElement->SetAttribute( "value", str ); -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool ValueByte::Set -( - uint8 const _value -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueByte* tempValue = new ValueByte( *this ); - tempValue->m_value = _value; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueByte::OnValueRefreshed -( - uint8 const _value -) -{ - switch( VerifyRefreshedValue( (void*) &m_value, (void*) &m_valueCheck, (void*) &_value, 4) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - m_valueCheck = _value; - break; - case 2: // value has changed (confirmed), save _value in m_value - m_value = _value; - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueByte.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueByte.h deleted file mode 100644 index f2e1dc8..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueByte.h +++ /dev/null @@ -1,73 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueByte.h -// -// Represents an 8-bit value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueByte_H -#define _ValueByte_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief Byte value sent to/received from a node. - */ - class ValueByte: public Value - { - public: - ValueByte( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _value, uint8 const _pollIntensity ); - ValueByte(); - virtual ~ValueByte(){} - - bool Set( uint8 const _value ); - void OnValueRefreshed( uint8 const _value ); - - // From Value - virtual string const GetAsString() const; - virtual bool SetFromString( string const& _value ); - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - uint8 GetValue()const{ return m_value; } - - private: - uint8 m_value; // the current value - uint8 m_valueCheck; // the previous value (used for double-checking spurious value reads) - uint8 m_newValue; // a new value to be set on the appropriate device - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueDecimal.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueDecimal.cpp deleted file mode 100644 index bc0f597..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueDecimal.cpp +++ /dev/null @@ -1,147 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueDecimal.cpp -// -// Represents a value that may have a fractional component -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "ValueDecimal.h" -#include "../Msg.h" -#include "../platform/Log.h" -#include "../Manager.h" -#include - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueDecimal::ValueDecimal -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - string const& _value, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Decimal, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_value( _value ), - m_valueCheck( "" ), - m_newValue( "" ), - m_precision( 0 ) -{ -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueDecimal::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - char const* str = _valueElement->Attribute( "value" ); - if( str ) - { - m_value = str; - } - else - { - Log::Write( LogLevel_Info, "Missing default decimal value from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueDecimal::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - _valueElement->SetAttribute( "value", m_value.c_str() ); -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool ValueDecimal::Set -( - string const& _value -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueDecimal* tempValue = new ValueDecimal( *this ); - tempValue->m_value = _value; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueDecimal::OnValueRefreshed -( - string const& _value -) -{ - switch( VerifyRefreshedValue( (void*) &m_value, (void*) &m_valueCheck, (void*) &_value, 1) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - m_valueCheck = _value; - break; - case 2: // value has changed (confirmed), save _value in m_value - m_value = _value; - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueDecimal.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueDecimal.h deleted file mode 100644 index f3e39f5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueDecimal.h +++ /dev/null @@ -1,82 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueDecimal.h -// -// Represents a value that may have a fractional component -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueDecimal_H -#define _ValueDecimal_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief Decimal value sent to/received from a node. - */ - class ValueDecimal: public Value - { - friend class EnergyProduction; - friend class Meter; - friend class SensorMultilevel; - friend class ThermostatSetpoint; - - public: - ValueDecimal( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, string const& _value, uint8 const _pollIntensity ); - ValueDecimal(): m_precision( 0 ){} - virtual ~ValueDecimal(){} - - bool Set( string const& _value ); - void OnValueRefreshed( string const& _value ); - - // From Value - virtual string const GetAsString() const { return GetValue(); } - virtual bool SetFromString( string const& _value ) { return Set( _value ); } - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - string GetValue()const{ return m_value; } - uint8 GetPrecision()const{ return m_precision; } - - private: - void SetPrecision( uint8 _precision ){ m_precision = _precision; } - - string m_value; // the current value - string m_valueCheck; // the previous value (used for double-checking spurious value reads) - string m_newValue; // a new value to be set on the appropriate device - uint8 m_precision; - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueID.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueID.h deleted file mode 100644 index 7172b00..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueID.h +++ /dev/null @@ -1,310 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueID.h -// -// Unique identifier for a Value object -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueID_H -#define _ValueID_H - -#include -#include -#include "../Defs.h" - -class TiXmlElement; - -namespace OpenZWave -{ - /** \brief Provides a unique ID for a value reported by a Z-Wave device. - * - * The ValueID is used to uniquely identify a value reported by a - * Z-Wave device. - *

- * The ID is built by packing various identifying characteristics into a single - * 32-bit number - the Z-Wave driver index, device node ID, the command class and - * command class instance that handles the value, plus an index for the value - * to distinguish it among all the other values managed by that command class - * instance. The type (bool, byte, string etc) of the value is also stored. - *

- * The packing of the ID is such that a list of Values sorted by ValueID - * will be in a sensible order for display to the user. - */ - class OPENZWAVE_EXPORT ValueID - { - friend class Manager; - friend class Driver; - friend class Node; - friend class Group; - friend class CommandClass; - friend class Value; - friend class ValueStore; - friend class Notification; - friend class ManufacturerSpecific; - - public: - /** - * Value Genres - * The classification of a value to enable low level system or configuration parameters to be filtered by the application. - * \see GetGenre - */ - enum ValueGenre - { - ValueGenre_Basic = 0, /**< The 'level' as controlled by basic commands. Usually duplicated by another command class. */ - ValueGenre_User, /**< Basic values an ordinary user would be interested in. */ - ValueGenre_Config, /**< Device-specific configuration parameters. These cannot be automatically discovered via Z-Wave, and are usually described in the user manual instead. */ - ValueGenre_System, /**< Values of significance only to users who understand the Z-Wave protocol */ - ValueGenre_Count /**< A count of the number of genres defined. Not to be used as a genre itself. */ - }; - - /** - * Value Types - * The type of data represented by the value object. - * \see GetType - */ - enum ValueType - { - ValueType_Bool = 0, /**< Boolean, true or false */ - ValueType_Byte, /**< 8-bit unsigned value */ - ValueType_Decimal, /**< Represents a non-integer value as a string, to avoid floating point accuracy issues. */ - ValueType_Int, /**< 32-bit signed value */ - ValueType_List, /**< List from which one item can be selected */ - ValueType_Schedule, /**< Complex type used with the Climate Control Schedule command class */ - ValueType_Short, /**< 16-bit signed value */ - ValueType_String, /**< Text string */ - ValueType_Button, /**< A write-only value that is the equivalent of pressing a button to send a command to a device */ - ValueType_Raw, /**< A collection of bytes */ - ValueType_Max = ValueType_Raw /**< The highest-number type defined. Not to be used as a type itself. */ - }; - - /** - * Get the Home ID of the driver that controls the node containing the value. - * \return the Home ID. - */ - uint32 GetHomeId()const{ return m_homeId; } - - /** - * Get the Home ID of the driver that controls the node containing the value. - * \return the node id. - */ - uint8 GetNodeId()const{ return( (uint8)( (m_id & 0xff000000) >> 24 ) ); } - - /** - * Get the genre of the value. The genre classifies a value to enable - * low-level system or configuration parameters to be filtered out by the application - * \return the value's genre. - * \see ValueGenre - */ - ValueGenre GetGenre()const{ return( (ValueGenre)( (m_id & 0x00c00000) >> 22 ) ); } - - /** - * Get the Z-Wave command class that created and manages this value. Knowledge of - * command classes is not required to use OpenZWave, but this information is - * exposed in case it is of interest. - * \return the value's command class. - */ - uint8 GetCommandClassId()const{ return( (uint8)( (m_id & 0x003fc000) >> 14 ) ); } - - /** - * Get the command class instance of this value. It is possible for there to be - * multiple instances of a command class, although currently it appears that - * only the SensorMultilevel command class ever does this. Knowledge of - * instances and command classes is not required to use OpenZWave, but this - * information is exposed in case it is of interest. - * \return the instance of the value's command class. - */ - uint8 GetInstance()const{ return( (uint8)( ( (m_id1 & 0xff000000) ) >> 24 ) ); } - - /** - * Get the value index. The index is used to identify one of multiple - * values created and managed by a command class. In the case of configurable - * parameters (handled by the configuration command class), the index is the - * same as the parameter ID. Knowledge of command classes is not required - * to use OpenZWave, but this information is exposed in case it is of interest. - * \return the value index within the command class. - */ - uint8 GetIndex()const{ return( (uint8)( (m_id & 0x00000ff0) >> 4 ) ); } - - /** - * Get the type of the value. The type describes the data held by the value - * and enables the user to select the correct value accessor method in the - * Manager class. - * \return the value's type. - * \see ValueType, Manager::GetValueAsBool, Manager::GetValueAsByte, Manager::GetValueAsFloat, Manager::GetValueAsInt, Manager::GetValueAsShort, Manager::GetValueAsString, Manager::GetValueListSelection. - */ - ValueType GetType()const{ return( (ValueType)( m_id & 0x0000000f ) ); } - - /** - * Get a 64Bit Integer that represents this ValueID. This Integer is not guaranteed to be valid - * across restarts of OpenZWave. - * \return a uint64 integer - */ - uint64 GetId()const{ return (uint64) ( ( (uint64)m_id1 << 32 ) | m_id );} - - // Comparison Operators - bool operator == ( ValueID const& _other )const{ return( ( m_homeId == _other.m_homeId ) && ( m_id == _other.m_id ) && ( m_id1 == _other.m_id1 ) ); } - bool operator != ( ValueID const& _other )const{ return( ( m_homeId != _other.m_homeId ) || ( m_id != _other.m_id ) || ( m_id1 != _other.m_id1 ) ); } - bool operator < ( ValueID const& _other )const - { - if( m_homeId == _other.m_homeId ) - { - if( m_id == _other.m_id ) - { - return( m_id1 < _other.m_id1 ); - } - else - { - return( m_id < _other.m_id ); - } - } - else - { - return( m_homeId < _other.m_homeId ); - } - } - bool operator > ( ValueID const& _other )const - { - if( m_homeId == _other.m_homeId ) - { - if( m_id == _other.m_id ) - { - return( m_id1 > _other.m_id1 ); - } - else - { - return( m_id > _other.m_id ); - } - } - else - { - return( m_homeId > _other.m_homeId ); - } - } - - /** - * Construct a value ID from its component parts. - * This method is public only to allow ValueIDs to be saved and recreated by the application. - * Only ValueIDs that have been reported by OpenZWave notifications should ever be used. - * \param _homeId Home ID of the PC Z-Wave Controller that manages the device. - * \param _nodeId Node ID of the device reporting the value. - * \param _genre classification of the value to enable low level system or configuration parameters to be filtered out. - * \param _commandClassId ID of command class that creates and manages this value. - * \param _instance Instance index of the command class. - * \param _valueIndex Index of the value within all the values created by the command class instance. - * \param _type Type of value (bool, byte, string etc). - * \return The ValueID. - * \see ValueID - */ - ValueID - ( - uint32 const _homeId, - uint8 const _nodeId, - ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _valueIndex, - ValueType const _type - ): - m_homeId( _homeId ) - { - m_id = (((uint32)_nodeId)<<24) - | (((uint32)_genre)<<22) - | (((uint32)_commandClassId)<<14) - | (((uint32)_valueIndex)<<4) - | ((uint32)_type); - m_id1 = (((uint32)_instance)<<24); - } - - /* construct a ValueID based on the HomeID and the unit64 returned from GetID - * \param _homeId - The HomeID - * \param id - The ID returned from ValueID::GetID - * \see ValueID::GetId - */ - ValueID - ( - uint32 _homeId, - uint64 id - ): - m_homeId(_homeId) - { - m_id = ((uint32)(id & 0xFFFFFFFF)); - m_id1 = (uint32)(id >> 32); - } - private: - // Construct a value id for use in notifications - ValueID( uint32 const _homeId, uint8 const _nodeId ): m_id1( 0 ),m_homeId( _homeId ){ m_id = ((uint32)_nodeId)<<24; } - ValueID( uint32 const _homeId, uint8 const _nodeId, uint32 const _instance ): - m_homeId( _homeId ) - { - m_id = (((uint32)_nodeId)<<24); - m_id1 = (((uint32)_instance)<<24); - } - - // Default constructor - ValueID():m_id(0),m_id1(0),m_homeId(0){} - - // Not all parts of the ValueID are necessary to uniquely identify the value. In the case of a - // Node's ValueStore, we can ignore the home ID, node ID, genre and type and still be left with - // a unique integer than can be used as a key to look up values. The two GetValueStoreKey methods - // below are helpers to enable command classes to easily access their values from the ValueStore. - - // Get the key from our own m_id - uint32 GetValueStoreKey()const - { - return ( ( m_id & 0x003ffff0 ) | ( m_id1 & 0xff000000 ) ); - } - - // Generate a key from its component parts - static uint32 GetValueStoreKey( uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex ) - { - - uint32 key = (((uint32)_instance)<<24) - | (((uint32)_commandClassId)<<14) - | (((uint32)_valueIndex)<<4); - - return key; - } - - // ID Packing: - // Bits - // 24-31: 8 bits. Node ID of device - // 22-23: 2 bits. genre of value (see ValueGenre enum). - // 14-21: 8 bits. ID of command class that created and manages this value. - // 12-13: 2 bits. Unused. - // 04-11: 8 bits. Index of value within all the value created by the command class - // instance (in configuration parameters, this is also the parameter ID). - // 00-03: 4 bits. Type of value (bool, byte, string etc). - uint32 m_id; - - // ID1 Packing: - // Bits - // 24-31 8 bits. Instance Index of the command class. - uint32 m_id1; - - // Unique PC interface identifier - uint32 m_homeId; - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueInt.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueInt.cpp deleted file mode 100644 index c04dee5..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueInt.cpp +++ /dev/null @@ -1,188 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueInt.cpp -// -// Represents a 32-bit value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include -#include "../tinyxml.h" -#include "ValueInt.h" -#include "../Msg.h" -#include "../platform/Log.h" -#include "../Manager.h" -#include - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueInt::ValueInt -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - int32 const _value, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Int, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_value( _value ), - m_valueCheck( 0 ), - m_newValue( 0 ) -{ - m_min = INT_MIN; - m_max = INT_MAX; -} - -//----------------------------------------------------------------------------- -// -// Constructor (from XML) -//----------------------------------------------------------------------------- -ValueInt::ValueInt -( -): - Value(), - m_value( 0 ), - m_valueCheck( 0 ), - m_newValue( 0 ) - -{ - m_min = INT_MIN; - m_max = INT_MAX; -} - -string const ValueInt::GetAsString -( -) const -{ - stringstream ss; - ss << GetValue(); - return ss.str(); -} - -bool ValueInt::SetFromString -( - string const& _value -) -{ - int32 val = atoi( _value.c_str() ); - return Set( val ); -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueInt::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - int intVal; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "value", &intVal ) ) - { - m_value = (int32)intVal; - } - else - { - Log::Write( LogLevel_Info, "Missing default integer value from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueInt::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - - char str[16]; - snprintf( str, sizeof(str), "%d", m_value ); - _valueElement->SetAttribute( "value", str ); -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool ValueInt::Set -( - int32 const _value -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueInt* tempValue = new ValueInt( *this ); - tempValue->m_value = _value; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueInt::OnValueRefreshed -( - int32 const _value -) -{ - switch( VerifyRefreshedValue( (void*) &m_value, (void*) &m_valueCheck, (void*) &_value, 3) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - m_valueCheck = _value; - break; - case 2: // value has changed (confirmed), save _value in m_value - m_value = _value; - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueInt.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueInt.h deleted file mode 100644 index 8090be7..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueInt.h +++ /dev/null @@ -1,70 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueInt.h -// -// Represents a 32-bit value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueInt_H -#define _ValueInt_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief Integer value sent to/received from a node. - */ - class ValueInt: public Value - { - public: - ValueInt( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, int32 const _value, uint8 const _pollIntensity ); - ValueInt(); - virtual ~ValueInt(){} - - bool Set( int32 const _value ); - void OnValueRefreshed( int32 const _value ); - - // From Value - virtual string const GetAsString() const; - virtual bool SetFromString( string const& _value ); - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - int32 GetValue()const{ return m_value; } - - private: - int32 m_value; // the current value - int32 m_valueCheck; // the previous value (used for double-checking spurious value reads) - int32 m_newValue; // a new value to be set on the appropriate device - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueList.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueList.cpp deleted file mode 100644 index 5b78d03..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueList.cpp +++ /dev/null @@ -1,358 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueList.cpp -// -// Represents a list of items -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "ValueList.h" -#include "../Msg.h" -#include "../platform/Log.h" -#include "../Manager.h" -#include - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueList::ValueList -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - vector const& _items, - int32 const _valueIdx, - uint8 const _pollIntensity, - uint8 const _size // = 4 -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_List, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_items( _items ), - m_valueIdx( _valueIdx ), - m_valueIdxCheck( 0 ), - m_newValueIdx( 0 ), - m_size( _size ) -{ -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueList::ValueList -( -): - Value(), - m_items( ), - m_valueIdx(), - m_valueIdxCheck( 0 ), - m_newValueIdx( 0 ), - m_size(0) -{ -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueList::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - // Get size of values - int intSize; - if ( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "size", &intSize ) ) - { - if( intSize == 1 || intSize == 2 || intSize == 4 ) - { - m_size = intSize; - } - else - { - Log::Write( LogLevel_Info, "Value size is invalid. Only 1, 2 & 4 supported for node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } - } - else - { - Log::Write( LogLevel_Info, "Value list size is not set, assuming 4 bytes for node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } - - // Read the items - m_items.clear(); - TiXmlElement const* itemElement = _valueElement->FirstChildElement(); - while( itemElement ) - { - char const* str = itemElement->Value(); - if( str && !strcmp( str, "Item" ) ) - { - char const* labelStr = itemElement->Attribute( "label" ); - - int value = 0; - if (itemElement->QueryIntAttribute( "value", &value ) != TIXML_SUCCESS) { - Log::Write( LogLevel_Info, "Item value %s is wrong type or does not exist in xml configuration for node %d, class 0x%02x, instance %d, index %d", labelStr, _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - continue; - } - if(( m_size == 1 && value > 255 ) || ( m_size == 2 && value > 65535) ) - { - Log::Write( LogLevel_Info, "Item value %s is incorrect size in xml configuration for node %d, class 0x%02x, instance %d, index %d", labelStr, _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } - else - { - Item item; - item.m_label = labelStr; - item.m_value = value; - - m_items.push_back( item ); - } - } - - itemElement = itemElement->NextSiblingElement(); - } - - // Set the value - bool valSet = false; - int intVal; - m_valueIdx = 0; - if ( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "value", &intVal ) ) - { - valSet = true; - intVal = GetItemIdxByValue( intVal ); - if( intVal != -1 ) - { - m_valueIdx = (int32)intVal; - } - else - { - Log::Write( LogLevel_Info, "Value is not found in xml configuration for node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } - } - - // Set the index - bool indSet = false; - int intInd = 0; - if ( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "vindex", &intInd ) ) - { - indSet = true; - if( intInd >= 0 && intInd < (int32)m_items.size() ) - { - m_valueIdx = (int32)intInd; - } - else - { - Log::Write( LogLevel_Info, "Vindex is out of range for index in xml configuration for node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } - } - if( !valSet && !indSet ) - { - Log::Write( LogLevel_Info, "Missing default list value or vindex from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueList::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - - char str[16]; - snprintf( str, sizeof(str), "%d", m_valueIdx ); - _valueElement->SetAttribute( "vindex", str ); - - snprintf( str, sizeof(str), "%d", m_size ); - _valueElement->SetAttribute( "size", str ); - - for( vector::iterator it = m_items.begin(); it != m_items.end(); ++it ) - { - TiXmlElement* pItemElement = new TiXmlElement( "Item" ); - pItemElement->SetAttribute( "label", (*it).m_label.c_str() ); - - snprintf( str, sizeof(str), "%d", (*it).m_value ); - pItemElement->SetAttribute( "value", str ); - - _valueElement->LinkEndChild( pItemElement ); - } -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device, selected by item index -//----------------------------------------------------------------------------- -bool ValueList::SetByValue -( - int32 const _value -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueList* tempValue = new ValueList( *this ); - tempValue->m_valueIdx = _value; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device, selected by item label -//----------------------------------------------------------------------------- -bool ValueList::SetByLabel -( - string const& _label -) -{ - // Ensure the value is one of the options - int index = GetItemIdxByLabel( _label ); - if( index < 0 ) - { - // Item not found - return false; - } - - return SetByValue( index ); -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueList::OnValueRefreshed -( - int32 const _value -) -{ - // Ensure the value is one of the options - int32 index = GetItemIdxByValue( _value ); - if( index < 0 ) - { - // Item not found - return; - } - - switch( VerifyRefreshedValue( (void*) &m_valueIdx, (void*) &m_valueIdxCheck, (void*) &index, 3) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - m_valueIdxCheck = index; - break; - case 2: // value has changed (confirmed), save _value in m_value - m_valueIdx = index; - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} - -//----------------------------------------------------------------------------- -// -// Get the index of an item from its label -//----------------------------------------------------------------------------- -int32 const ValueList::GetItemIdxByLabel -( - string const& _label -) -{ - for( int32 i=0; i<(int32)m_items.size(); ++i ) - { - if( _label == m_items[i].m_label ) - { - return i; - } - } - - return -1; -} - -//----------------------------------------------------------------------------- -// -// Get the index of an item from its value -//----------------------------------------------------------------------------- -int32 const ValueList::GetItemIdxByValue -( - int32 const _value -) -{ - for( int32 i=0; i<(int32)m_items.size(); ++i ) - { - if( _value == m_items[i].m_value ) - { - return i; - } - } - - return -1; -} - -//----------------------------------------------------------------------------- -// -// Fill a vector with the item labels -//----------------------------------------------------------------------------- -bool ValueList::GetItemLabels -( - vector* o_items -) -{ - if( o_items ) - { - for( vector::iterator it = m_items.begin(); it != m_items.end(); ++it ) - { - o_items->push_back( (*it).m_label ); - } - - return true; - } - - return false; -} - - - - - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueList.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueList.h deleted file mode 100644 index 3544fb6..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueList.h +++ /dev/null @@ -1,94 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueList.h -// -// Represents a list of items -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueList_H -#define _ValueList_H - -#include -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief List of values sent to/received from a node. - */ - class ValueList: public Value - { - public: - /** \brief An item (element) in the list of values. - */ - struct Item - { - string m_label; - int32 m_value; - }; - - ValueList( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, vector const& _items, int32 const _valueIdx, uint8 const _pollIntensity, uint8 const _size = 4 ); - ValueList(); - virtual ~ValueList(){} - - bool SetByLabel( string const& _label ); - bool SetByValue( int32 const _value ); - - void OnValueRefreshed( int32 const _valueIdx ); - - // From Value - virtual string const GetAsString() const { return GetItem().m_label; } - virtual bool SetFromString( string const& _value ) { return SetByLabel( _value ); } - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - Item const& GetItem()const{ return m_items[m_valueIdx]; } - Item const& GetNewItem()const{ return m_items[m_newValueIdx]; } - - int32 const GetItemIdxByLabel( string const& _label ); - int32 const GetItemIdxByValue( int32 const _value ); - - bool GetItemLabels( vector* o_items ); - - uint8 const GetSize()const{ return m_size; } - - private: - vector m_items; - int32 m_valueIdx; // the current index in the m_items vector - int32 m_valueIdxCheck; // the previous index in the m_items vector (used for double-checking spurious value reads) - int32 m_newValueIdx; // a new value to be set on the appropriate device - uint8 m_size; - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueRaw.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueRaw.cpp deleted file mode 100644 index 7941ee6..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueRaw.cpp +++ /dev/null @@ -1,285 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueRaw.cpp -// -// Represents a collection of 8-bit values -// -// Copyright (c) 2012 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "ValueRaw.h" -#include "../Msg.h" -#include "../platform/Log.h" -#include "../Manager.h" -#include - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueRaw::ValueRaw -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - uint8 const* _value, - uint8 const _length, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Raw, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_value( NULL ), - m_valueLength( _length ), - m_valueCheck ( NULL ), - m_newValue ( NULL ) -{ - m_value = new uint8[_length]; - memcpy( m_value, _value, _length ); - m_min = 0; - m_max = 0; -} - -//----------------------------------------------------------------------------- -// -// Constructor (from XML) -//----------------------------------------------------------------------------- -ValueRaw::ValueRaw -( -): - m_value( NULL ), - m_valueCheck ( NULL ), - m_newValue ( NULL ) -{ - m_valueLength = 0; - m_min = 0; - m_max = 0; -} - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -ValueRaw::~ValueRaw -( -) -{ - delete [] m_value; -} - -string const ValueRaw::GetAsString -( -) const -{ - string str = ""; - char bstr[10]; - - for( uint32 i=0; i= 256 ) - { - break; - } - if( index < m_valueLength ) - { - value[index] = (uint8)val; - } - index++; - if( ep != NULL && *ep == '\0' ) - { - break; - } - p = ep + 1; - } - - bool bRet = false; - - if ( index <= m_valueLength ) - { - bRet = Set( value, index ); - } - - delete [] value; - return bRet; -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueRaw::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - int intVal; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "length", &intVal ) ) - { - m_valueLength = (uint8)intVal; - } - m_value = new uint8[m_valueLength]; - char const* str = _valueElement->Attribute( "value" ); - if( str ) - { - uint8 index = 0; - while( 1 ) - { - char *ep = NULL; - uint32 val = (uint32)strtol( str, &ep, 16 ); - if( str == ep || val >= 256 ) - { - break; - } - if( index < m_valueLength ) - { - m_value[index] = (uint8)val; - } - index++; - if( ep != NULL && *ep == '\0' ) - { - break; - } - str = ep + 1; - } - if( index > m_valueLength ) - { - Log::Write( LogLevel_Info, "Data length mismatch for raw data. Got %d but expected %d.", index, m_valueLength ); - } - } - else - { - Log::Write( LogLevel_Info, "Missing default raw value from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueRaw::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - - _valueElement->SetAttribute( "value", GetAsString().c_str() ); - char str[8]; - snprintf( str, sizeof(str), "%d", GetLength() ); - _valueElement->SetAttribute( "length", str ); -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool ValueRaw::Set -( - uint8 const* _value, - uint8 const _length -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueRaw* tempValue = new ValueRaw( *this ); - tempValue->m_value = new uint8[_length]; - memcpy( tempValue->m_value, _value, _length ); - tempValue->m_valueLength = _length; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueRaw::OnValueRefreshed -( - uint8 const* _value, - uint8 const _length -) -{ - switch( VerifyRefreshedValue( (void*)m_value, (void*)m_valueCheck, (void*)_value, 6, _length ) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - if( m_valueCheck != NULL ) - { - delete [] m_valueCheck; - } - m_valueCheck = new uint8[_length]; - memcpy( m_valueCheck, _value, _length ); - break; - case 2: // value has changed (confirmed), save _value in m_value - if( m_value != NULL ) - { - delete [] m_value; - } - m_value = new uint8[_length]; - memcpy( m_value, _value, _length ); - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueRaw.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueRaw.h deleted file mode 100644 index f392625..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueRaw.h +++ /dev/null @@ -1,75 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueRaw.h -// -// Represents a collection of 8-bit values -// -// Copyright (c) 2013 Greg Satz -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueRaw_H -#define _ValueRaw_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief A collection of bytes sent to/received from a node. - */ - class ValueRaw: public Value - { - public: - ValueRaw( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const* _value, uint8 const _length, uint8 const _pollIntensity ); - ValueRaw(); - virtual ~ValueRaw(); - - bool Set( uint8 const* _value, uint8 const _length ); - void OnValueRefreshed( uint8 const* _value, uint8 const _length ); - - // From Value - virtual string const GetAsString() const; - virtual bool SetFromString( string const& _value ); - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - uint8* GetValue()const{ return m_value; } - uint8 GetLength()const{ return m_valueLength; } - - private: - uint8* m_value; // the current value - uint8 m_valueLength; // fixed length for this instance - uint8* m_valueCheck; // the previous value (used for double-checking spurious value reads) - uint8* m_newValue; // a new value to be set on the appropriate device - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueSchedule.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueSchedule.cpp deleted file mode 100644 index 96345a3..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueSchedule.cpp +++ /dev/null @@ -1,351 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueSchedule.cpp -// -// A one day schedule for the Climate Control Schedule command class -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include -#include "../tinyxml.h" -#include "ValueSchedule.h" -#include "../Msg.h" -#include "../platform/Log.h" - -using namespace OpenZWave; - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueSchedule::ValueSchedule -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Byte, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_numSwitchPoints( 0 ) - -{ -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueSchedule::ValueSchedule -( -): - Value(), - m_numSwitchPoints( 0 ) - -{ -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueSchedule::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - // Read in the switch points - TiXmlElement const* child = _valueElement->FirstChildElement(); - while( child ) - { - char const* str = child->Value(); - if( str ) - { - if( !strcmp( str, "SwitchPoint" ) ) - { - int intVal; - - uint8 hours = 0; - if( TIXML_SUCCESS == child->QueryIntAttribute( "hours", &intVal ) ) - { - hours = (uint8)intVal; - } - - uint8 minutes = 0; - if( TIXML_SUCCESS == child->QueryIntAttribute( "minutes", &intVal ) ) - { - minutes = (uint8)intVal; - } - - int8 setback = 0; - if( TIXML_SUCCESS == child->QueryIntAttribute( "setback", &intVal ) ) - { - setback = (int8)intVal; - } - - SetSwitchPoint( hours, minutes, setback ); - } - } - - child = child->NextSiblingElement(); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueSchedule::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - - for( uint8 i=0; iLinkEndChild( switchPointElement ); - - snprintf( str, sizeof(str), "%d", hours ); - switchPointElement->SetAttribute( "hours", str ); - - snprintf( str, sizeof(str), "%d", minutes ); - switchPointElement->SetAttribute( "minutes", str ); - - snprintf( str, sizeof(str), "%d", setback ); - switchPointElement->SetAttribute( "setback", str ); - } - } -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool ValueSchedule::Set -( -) -{ - // Set the value in the device. - // TODO this needs to be checked to make sure it works as intended - return Value::Set(); -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueSchedule::OnValueRefreshed -( -) -{ - // TODO: do schedules ever report spurious values and need rechecking like other value types? - // See, for example, ValueShort::OnValueRefreshed - Value::OnValueChanged(); -} - -//----------------------------------------------------------------------------- -// -// A value in a device has changed -//----------------------------------------------------------------------------- -bool ValueSchedule::SetSwitchPoint -( - uint8 const _hours, uint8 const _minutes, int8 const _setback -) -{ - // Find where to insert this switch point. They must be sorted by ascending time value. - uint8 i; - uint8 insertAt = 0; - - for( i=0; i _minutes ) - { - break; - } - } - else if( m_switchPoints[i].m_hours > _hours ) - { - break; - } - - ++insertAt; - } - - if( m_numSwitchPoints >= 9 ) - { - // The schedule is full - return false; - } - - // Shuffle any later switch points out of the way - for( i=m_numSwitchPoints; i>insertAt; --i ) - { - m_switchPoints[i].m_hours = m_switchPoints[i-1].m_hours; - m_switchPoints[i].m_minutes = m_switchPoints[i-1].m_minutes; - m_switchPoints[i].m_setback = m_switchPoints[i-1].m_setback; - } - - // Insert the new switch point - m_switchPoints[insertAt].m_hours = _hours; - m_switchPoints[insertAt].m_minutes = _minutes; - m_switchPoints[insertAt].m_setback = _setback; - - ++m_numSwitchPoints; - return true; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has changed -//----------------------------------------------------------------------------- -bool ValueSchedule::RemoveSwitchPoint -( - uint8 const _idx -) -{ - if( _idx >= m_numSwitchPoints ) - { - // _idx is out of range - return false; - } - - // Shuffle any later switch points down to fill the gap - for( uint8 i=_idx; i<(m_numSwitchPoints-1); ++i ) - { - m_switchPoints[i].m_hours = m_switchPoints[i+1].m_hours; - m_switchPoints[i].m_minutes = m_switchPoints[i+1].m_minutes; - m_switchPoints[i].m_setback = m_switchPoints[i+1].m_setback; - } - - --m_numSwitchPoints; - return true; -} - -//----------------------------------------------------------------------------- -// -// Get the values of a switch point -//----------------------------------------------------------------------------- -bool ValueSchedule::GetSwitchPoint -( - uint8 const _idx, - uint8* o_hours, - uint8* o_minutes, - int8* o_setback -)const -{ - if( _idx >= m_numSwitchPoints ) - { - // _idx is out of range - return false; - } - - if( o_hours ) - { - *o_hours = m_switchPoints[_idx].m_hours; - } - - if( o_minutes ) - { - *o_minutes = m_switchPoints[_idx].m_minutes; - } - - if( o_setback ) - { - *o_setback = m_switchPoints[_idx].m_setback; - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Get the index of the switch point at the specified time -//----------------------------------------------------------------------------- -bool ValueSchedule::FindSwitchPoint -( - uint8 const _hours, - uint8 const _minutes, - uint8* o_idx -)const -{ - for( uint8 i=0; i _minutes ) - { - // Gone past any possible match - return false; - } - } - else if( m_switchPoints[i].m_hours > _hours ) - { - // Gone past any possible match - return false; - } - } - - // No match found - return false; -} - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueSchedule.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueSchedule.h deleted file mode 100644 index 89ccdba..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueSchedule.h +++ /dev/null @@ -1,79 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueSchedule.h -// -// A one day schedule for the Climate Control Schedule command class -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueSchedule_H -#define _ValueSchedule_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief Schedule sent to/received from a node. - */ - class ValueSchedule: public Value - { - public: - ValueSchedule( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _pollIntensity ); - ValueSchedule(); - virtual ~ValueSchedule(){} - - bool SetSwitchPoint( uint8 const _hours, uint8 const _minutes, int8 const _setback ); - bool RemoveSwitchPoint( uint8 const _idx ); - void ClearSwitchPoints(){ m_numSwitchPoints = 0; } - bool GetSwitchPoint( uint8 const _idx, uint8* o_hours, uint8* o_minutes, int8* o_setback )const; - bool FindSwitchPoint( uint8 const _hours, uint8 const _minutes, uint8* o_idx )const; - uint8 GetNumSwitchPoints()const{ return m_numSwitchPoints; } - - bool Set(); - void OnValueRefreshed(); - - // From Value - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - private: - struct SwitchPoint - { - uint8 m_hours; - uint8 m_minutes; - int8 m_setback; - }; - - SwitchPoint m_switchPoints[9]; - uint8 m_numSwitchPoints; - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueShort.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueShort.cpp deleted file mode 100644 index be563e0..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueShort.cpp +++ /dev/null @@ -1,191 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueShort.cpp -// -// Represents a 16-bit value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include -#include -#include "../tinyxml.h" -#include "ValueShort.h" -#include "../Msg.h" -#include "../platform/Log.h" -#include "../Manager.h" -#include - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueShort::ValueShort -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - int16 const _value, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_Byte, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_value( _value ), - m_valueCheck( 0 ), - m_newValue( 0 ) -{ - m_min = SHRT_MIN; - m_max = SHRT_MAX; -} - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueShort::ValueShort -( -): - Value(), - m_value( 0 ), - m_valueCheck( 0 ), - m_newValue( 0 ) -{ - m_min = SHRT_MIN; - m_max = SHRT_MAX; -} - -string const ValueShort::GetAsString -( -) const -{ - stringstream ss; - ss << GetValue(); - return ss.str(); -} - -bool ValueShort::SetFromString -( - string const& _value -) -{ - uint32 val = (uint32)atoi( _value.c_str() ); - if( val < 32768 ) - { - return Set( (int16)val ); - } - return false; -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueShort::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - int intVal; - if( TIXML_SUCCESS == _valueElement->QueryIntAttribute( "value", &intVal ) ) - { - m_value = (int16)intVal; - } - else - { - Log::Write( LogLevel_Info, "Missing default short value from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueShort::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - - char str[16]; - snprintf( str, sizeof(str), "%d", m_value ); - _valueElement->SetAttribute( "value", str ); -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device -//----------------------------------------------------------------------------- -bool ValueShort::Set -( - int16 const _value -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueShort* tempValue = new ValueShort( *this ); - tempValue->m_value = _value; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueShort::OnValueRefreshed -( - int16 const _value -) -{ - switch( VerifyRefreshedValue( (void*) &m_value, (void*) &m_valueCheck, (void*) &_value, 2) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - m_valueCheck = _value; - break; - case 2: // value has changed (confirmed), save _value in m_value - m_value = _value; - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueShort.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueShort.h deleted file mode 100644 index 17a246d..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueShort.h +++ /dev/null @@ -1,70 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueShort.h -// -// Represents a 16-bit value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueShort_H -#define _ValueShort_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief Short value sent to/received from a node. - */ - class ValueShort: public Value - { - public: - ValueShort( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, int16 const _value, uint8 const _pollIntensity ); - ValueShort(); - virtual ~ValueShort(){} - - bool Set( int16 const _value ); - void OnValueRefreshed( int16 const _value ); - - // From Value - virtual string const GetAsString() const; - virtual bool SetFromString( string const& _value ); - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - int16 GetValue()const{ return m_value; } - - private: - int16 m_value; // the current value - int16 m_valueCheck; // the previous value (used for double-checking spurious value reads) - int16 m_newValue; // a new value to be set on the appropriate device - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueStore.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueStore.cpp deleted file mode 100644 index d7393e9..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueStore.cpp +++ /dev/null @@ -1,204 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueStore.cpp -// -// Container for Value objects -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "ValueStore.h" -#include "Value.h" -#include "../Manager.h" -#include "../Notification.h" - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Destructor -//----------------------------------------------------------------------------- -ValueStore::~ValueStore -( -) -{ - map::iterator it = m_values.begin(); - while( !m_values.empty() ) - { - ValueID const& valueId = it->second->GetID(); - RemoveValue( valueId.GetValueStoreKey() ); - it = m_values.begin(); - } -} - -//----------------------------------------------------------------------------- -// -// Add a value to the store -//----------------------------------------------------------------------------- -bool ValueStore::AddValue -( - Value* _value -) -{ - if( !_value ) - { - return false; - } - - uint32 key = _value->GetID().GetValueStoreKey(); - map::iterator it = m_values.find( key ); - if( it != m_values.end() ) - { - // There is already a value in the store with this key, so we give up. - return false; - } - - m_values[key] = _value; - _value->AddRef(); - - // Notify the watchers of the new value - if( Driver* driver = Manager::Get()->GetDriver( _value->GetID().GetHomeId() ) ) - { - Notification* notification = new Notification( Notification::Type_ValueAdded ); - notification->SetValueId( _value->GetID() ); - driver->QueueNotification( notification ); - } - - return true; -} - -//----------------------------------------------------------------------------- -// -// Remove a value from the store -//----------------------------------------------------------------------------- -bool ValueStore::RemoveValue -( - uint32 const& _key -) -{ - map::iterator it = m_values.find( _key ); - if( it != m_values.end() ) - { - Value* value = it->second; - ValueID const& valueId = value->GetID(); - - // First notify the watchers - if( Driver* driver = Manager::Get()->GetDriver( valueId.GetHomeId() ) ) - { - Notification* notification = new Notification( Notification::Type_ValueRemoved ); - notification->SetValueId( valueId ); - driver->QueueNotification( notification ); - } - - // Now release and remove the value from the store - value->Release(); - m_values.erase( it ); - - return true; - } - - // Value not found in the store - return false; -} - -////----------------------------------------------------------------------------- -//// -//// Remove a value from the store -////----------------------------------------------------------------------------- -//bool ValueStore::RemoveValue -//( -// ValueID const& _id -//) - - -//----------------------------------------------------------------------------- -// -// Remove all the values associated with a command class from the store -//----------------------------------------------------------------------------- -void ValueStore::RemoveCommandClassValues -( - uint8 const _commandClassId -) -{ - map::iterator it = m_values.begin(); - while( it != m_values.end() ) - { - Value* value = it->second; - ValueID const& valueId = value->GetID(); - if( _commandClassId == valueId.GetCommandClassId() ) - { - // The value belongs to the specified command class - - // First notify the watchers - if( Driver* driver = Manager::Get()->GetDriver( valueId.GetHomeId() ) ) - { - Notification* notification = new Notification( Notification::Type_ValueRemoved ); - notification->SetValueId( valueId ); - driver->QueueNotification( notification ); - } - - // Now release and remove the value from the store - value->Release(); - m_values.erase( it++ ); - } - else - { - ++it; - } - } -} - -//----------------------------------------------------------------------------- -// -// Get a value from the store -//----------------------------------------------------------------------------- -Value* ValueStore::GetValue -( - uint32 const& _key -)const -{ - Value* value = NULL; - - map::const_iterator it = m_values.find( _key ); - if( it != m_values.end() ) - { - value = it->second; - if( value ) - { - // Add a reference to the value. The caller must - // call Release on the value when they are done with it. - value->AddRef(); - } - } - - return value; -} - -////----------------------------------------------------------------------------- -//// -//// Get a value from the store -////----------------------------------------------------------------------------- -//Value* ValueStore::GetValue -//( -// ValueID const& _id -//)const - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueStore.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueStore.h deleted file mode 100644 index 81f0967..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueStore.h +++ /dev/null @@ -1,70 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueStore.h -// -// Container for Value objects -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueStore_H -#define _ValueStore_H - -#include -#include "../Defs.h" -#include "ValueID.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Value; - - /** \brief Container that holds all of the values associated with a given node. - */ - class ValueStore - { - public: - - typedef map::const_iterator Iterator; - - Iterator Begin(){ return m_values.begin(); } - Iterator End(){ return m_values.end(); } - - ValueStore(){} - ~ValueStore(); - - bool AddValue( Value* _value ); - bool RemoveValue( uint32 const& _key ); - Value* GetValue( uint32 const& _key )const; - - void RemoveCommandClassValues( uint8 const _commandClassId ); // Remove all the values associated with a command class - - private: - map m_values; - }; - -} // namespace OpenZWave - -#endif - - - diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueString.cpp b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueString.cpp deleted file mode 100644 index d7295fa..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueString.cpp +++ /dev/null @@ -1,145 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueStore.cpp -// -// Represents a string value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#include "../tinyxml.h" -#include "ValueString.h" -#include "../Msg.h" -#include "../platform/Log.h" -#include "../Manager.h" - -using namespace OpenZWave; - - -//----------------------------------------------------------------------------- -// -// Constructor -//----------------------------------------------------------------------------- -ValueString::ValueString -( - uint32 const _homeId, - uint8 const _nodeId, - ValueID::ValueGenre const _genre, - uint8 const _commandClassId, - uint8 const _instance, - uint8 const _index, - string const& _label, - string const& _units, - bool const _readOnly, - bool const _writeOnly, - string const& _value, - uint8 const _pollIntensity -): - Value( _homeId, _nodeId, _genre, _commandClassId, _instance, _index, ValueID::ValueType_String, _label, _units, _readOnly, _writeOnly, false, _pollIntensity ), - m_value( _value ), - m_valueCheck( "" ), - m_newValue( "" ) -{ -} - -//----------------------------------------------------------------------------- -// -// Apply settings from XML -//----------------------------------------------------------------------------- -void ValueString::ReadXML -( - uint32 const _homeId, - uint8 const _nodeId, - uint8 const _commandClassId, - TiXmlElement const* _valueElement -) -{ - Value::ReadXML( _homeId, _nodeId, _commandClassId, _valueElement ); - - char const* str = _valueElement->Attribute( "value" ); - if( str ) - { - m_value = str; - } - else - { - Log::Write( LogLevel_Alert, "Missing default string value from xml configuration: node %d, class 0x%02x, instance %d, index %d", _nodeId, _commandClassId, GetID().GetInstance(), GetID().GetIndex() ); - } -} - -//----------------------------------------------------------------------------- -// -// Write ourselves to an XML document -//----------------------------------------------------------------------------- -void ValueString::WriteXML -( - TiXmlElement* _valueElement -) -{ - Value::WriteXML( _valueElement ); - _valueElement->SetAttribute( "value", m_value.c_str() ); -} - -//----------------------------------------------------------------------------- -// -// Set a new value in the device and queue a "RequestValue" to confirm it worked -//----------------------------------------------------------------------------- -bool ValueString::Set -( - string const& _value -) -{ - // create a temporary copy of this value to be submitted to the Set() call and set its value to the function param - ValueString* tempValue = new ValueString( *this ); - tempValue->m_value = _value; - - // Set the value in the device. - bool ret = ((Value*)tempValue)->Set(); - - // clean up the temporary value - delete tempValue; - - return ret; -} - -//----------------------------------------------------------------------------- -// -// A value in a device has been refreshed -//----------------------------------------------------------------------------- -void ValueString::OnValueRefreshed -( - string const& _value -) -{ - switch( VerifyRefreshedValue( (void*) &m_value, (void*) &m_valueCheck, (void*) &_value, 1) ) - { - case 0: // value hasn't changed, nothing to do - break; - case 1: // value has changed (not confirmed yet), save _value in m_valueCheck - m_valueCheck = _value; - break; - case 2: // value has changed (confirmed), save _value in m_value - m_value = _value; - break; - case 3: // all three values are different, so wait for next refresh to try again - break; - } -} diff --git a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueString.h b/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueString.h deleted file mode 100644 index b52c5cf..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/value_classes/ValueString.h +++ /dev/null @@ -1,70 +0,0 @@ -//----------------------------------------------------------------------------- -// -// ValueString.h -// -// Represents a string value -// -// Copyright (c) 2010 Mal Lansell -// -// SOFTWARE NOTICE AND LICENSE -// -// This file is part of OpenZWave. -// -// OpenZWave is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// OpenZWave is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with OpenZWave. If not, see . -// -//----------------------------------------------------------------------------- - -#ifndef _ValueString_H -#define _ValueString_H - -#include -#include "../Defs.h" -#include "Value.h" - -class TiXmlElement; - -namespace OpenZWave -{ - class Msg; - class Node; - - /** \brief String value sent to/received from a node. - */ - class ValueString: public Value - { - public: - ValueString( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, string const& _value, uint8 const _pollIntensity ); - ValueString(){} - virtual ~ValueString(){} - - bool Set( string const& _value ); - void OnValueRefreshed( string const& _value ); - - // From Value - virtual string const GetAsString() const { return GetValue(); } - virtual bool SetFromString( string const& _value ) { return Set( _value ); } - virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement ); - virtual void WriteXML( TiXmlElement* _valueElement ); - - string GetValue()const{ return m_value; } - - private: - string m_value; // the current value - string m_valueCheck; // the previous value (used for double-checking spurious value reads) - string m_newValue; // a new value to be set on the appropriate device - }; - -} // namespace OpenZWave - -#endif diff --git a/lib/ESPiLight/pilight/libs/openzwave/vers.cpp b/lib/ESPiLight/pilight/libs/openzwave/vers.cpp deleted file mode 100644 index dcb556c..0000000 --- a/lib/ESPiLight/pilight/libs/openzwave/vers.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "Defs.h" -uint16_t ozw_vers_major = 1; -uint16_t ozw_vers_minor = 2; -uint16_t ozw_vers_revision = 919; diff --git a/lib/ESPiLight/pilight/libs/pilight/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/CMakeLists.txt deleted file mode 100644 index 0888694..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -project(pilight) - -include(../../CMakeConfig.txt) - -if(${MODULESPACK} MATCHES "OFF" OR WIN32) - set(${PROJECT_NAME}_files "" CACHE INTERNAL "") - - add_subdirectory(core) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${${PROJECT_NAME}_core_files} CACHE INTERNAL "") - - add_subdirectory(config) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${${PROJECT_NAME}_config_files} CACHE INTERNAL "") - - add_subdirectory(datatypes) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${${PROJECT_NAME}_datatypes_files} CACHE INTERNAL "") - - if(${EVENTS} MATCHES "ON") - add_subdirectory(events) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${${PROJECT_NAME}_events_files} CACHE INTERNAL "") - endif() - - add_subdirectory(protocols) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${${PROJECT_NAME}_protocols_files} CACHE INTERNAL "") - - add_subdirectory(hardware) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${${PROJECT_NAME}_hardware_files} CACHE INTERNAL "") - - add_subdirectory(lua) - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_files} ${${PROJECT_NAME}_lua_files} CACHE INTERNAL "") -else() - if(${EVENTS} MATCHES "ON") - add_subdirectory(events) - endif() - add_subdirectory(protocols) - add_subdirectory(hardware) -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/config/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/config/CMakeLists.txt deleted file mode 100644 index 07c618a..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -project(pilight_config) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/config/devices.c b/lib/ESPiLight/pilight/libs/pilight/config/devices.c deleted file mode 100644 index c4095ca..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/devices.c +++ /dev/null @@ -1,1771 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #include -#endif -#include -#include -#include - -#include "../core/threads.h" -#include "../core/common.h" -#include "../core/log.h" -#include "../core/options.h" -#include "../core/config.h" -#include "../core/ssdp.h" -#include "../core/firmware.h" -#include "../core/datetime.h" - -#include "../protocols/protocol.h" - -#include "defines.h" -#include "devices.h" -#include "gui.h" - -static pthread_mutex_t mutex_lock; -static pthread_mutexattr_t mutex_attr; - -struct config_t *config_devices; - -/* Struct to store the locations */ -static struct devices_t *devices = NULL; - -int devices_update(char *protoname, JsonNode *json, enum origin_t origin, JsonNode **out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - /* The pointer to the devices devices */ - struct devices_t *dptr = devices; - /* The pointer to the device settings */ - struct devices_settings_t *sptr = NULL; - /* The pointer to the device settings */ - struct devices_values_t *vptr = NULL; - /* The pointer to the registered protocols */ - struct protocol_t *protocol = NULL; - /* The pointer to the protocol options */ - struct options_t *opt = NULL; - /* Get the message part of the sended code */ - JsonNode *message = json_find_member(json, "message"); - /* Get the settings part of the sended code */ - JsonNode *settings = json_find_member(json, "settings"); - /* The return JSON object will all updated devices */ - JsonNode *rroot = json_mkobject(); - JsonNode *rdev = json_mkarray(); - JsonNode *rval = json_mkobject(); - - /* Temporarily char pointer */ - char *stmp = NULL; - /* Temporarily int */ - double itmp; - /* Do we need to update the devices file */ - unsigned short update = 0; - /* The new state value */ - char vstring_[255]; - double vnumber_ = -1; - int vdecimals_ = 0; - char sstring_[255]; - double snumber_ = -1; - int sdecimals_ = 0; - int stateType = 0; - int valueType = 0; - /* The UUID of this device */ - char *uuid = NULL; - - /* Make sure the character pointers are empty */ - memset(sstring_, '\0', sizeof(sstring_)); - memset(vstring_, '\0', sizeof(vstring_)); - - /* Check if the found settings matches the send code */ - unsigned int match = 0, match1 = 0, match2 = 0; - - /* Is is a valid new state / value */ - int is_valid = 1; - - /* Retrieve the used protocol */ - struct protocols_t *pnode = protocols; - while(pnode) { - protocol = pnode->listener; - if(strcmp(protocol->id, protoname) == 0) { - break; - } - pnode = pnode->next; - } - - time_t timenow = time(NULL); - struct tm gmt; - memset(&gmt, '\0', sizeof(struct tm)); -#ifdef _WIN32 - struct tm *tm; - tm = gmtime(&timenow); - memcpy(&gmt, tm, sizeof(struct tm)); -#else - gmtime_r(&timenow, &gmt); -#endif - time_t utct = datetime2ts(gmt.tm_year+1900, gmt.tm_mon+1, gmt.tm_mday, gmt.tm_hour, gmt.tm_min, gmt.tm_sec); - json_append_member(rval, "timestamp", json_mknumber((double)utct, 0)); - - json_find_string(json, "uuid", &uuid); - - if((opt = protocol->options)) { - /* Loop through all devices */ - - while(dptr) { - /* - * uuid = The UUID of the pilight instance that received the specific information. - * pilight_uuid = The UUID of the currently running pilight instance this function was called on. - * dev_uuid = The UUID of the device set by the user or the UUID of pilight instance that read the config. - * ori_uuid = The UUID of the pilight instance that parsed the config (mostly the master). - * cst_uuid = The UUID manually set the UUID of these devices - * - */ - int uuidmatch = 0; - if(uuid != NULL && dptr->dev_uuid != NULL && dptr->ori_uuid != NULL && strlen(pilight_uuid) > 0) { - if(dptr->cst_uuid == 1) { - /* If the user forced the device UUID and it matches the UUID of the recieved code */ - if(strcmp(dptr->dev_uuid, uuid) == 0) { - uuidmatch = 1; - } - } else { - uuidmatch = 1; - } - } else if(uuid == NULL || strlen(pilight_uuid) == 0) { - uuidmatch = 1; - } - if(uuidmatch == 1) { - struct protocols_t *tmp_protocols = dptr->protocols; - match = 0; - while(tmp_protocols) { - if(protocol_device_exists(protocol, tmp_protocols->name) == 0) { - match = 1; - break; - } - tmp_protocols = tmp_protocols->next; - } - - if(match == 1) { - sptr = dptr->settings; - /* Loop through all settings */ - while(sptr) { - match1 = 0; match2 = 0; - - /* Check how many id's we need to match */ - opt = protocol->options; - while(opt) { - if(opt->conftype == DEVICES_ID) { - JsonNode *jtmp = json_first_child(message); - while(jtmp) { - if(strcmp(jtmp->key, opt->name) == 0) { - match1++; - } - jtmp = jtmp->next; - } - } - opt = opt->next; - } - - /* Loop through all protocol options */ - opt = protocol->options; - while(opt) { - if(opt->conftype == DEVICES_ID && strcmp(sptr->name, "id") == 0) { - /* Check the devices id's to match a device */ - vptr = sptr->values; - while(vptr) { - if(strcmp(vptr->name, opt->name) == 0) { - if(json_find_string(message, opt->name, &stmp) == 0 && - vptr->type == JSON_STRING && - strcmp(stmp, vptr->string_) == 0) { - match2++; - } - if(json_find_number(message, opt->name, &itmp) == 0 && - vptr->type == JSON_NUMBER && - fabs(vptr->number_-itmp) < EPSILON) { - match2++; - } - } - vptr = vptr->next; - } - } - - /* Retrieve the new device state */ - if(opt->conftype == DEVICES_STATE) { - if(opt->argtype == OPTION_NO_VALUE) { - if(json_find_string(message, "state", &stmp) == 0) { - strcpy(sstring_, stmp); - stateType = JSON_STRING; - } - if(json_find_number(message, "state", &itmp) == 0) { - snumber_ = itmp; - stateType = JSON_NUMBER; - } - } else if(opt->argtype == OPTION_HAS_VALUE) { - if(json_find_string(message, opt->name, &stmp) == 0) { - strcpy(sstring_, stmp); - stateType = JSON_STRING; - } - struct JsonNode *jtmp = NULL; - if((jtmp = json_find_member(message, opt->name)) != NULL && - jtmp->tag == JSON_NUMBER) { - snumber_ = jtmp->number_; - sdecimals_ = jtmp->decimals_; - stateType = JSON_NUMBER; - } - } - } - opt = opt->next; - } - if(match1 > 0 && match2 > 0 && match1 == match2) { - break; - } - sptr = sptr->next; - } - is_valid = 1; - - /* If we matched a device, update it's state */ - if(match1 > 0 && match2 > 0 && match1 == match2) { - if(protocol->checkValues) { - is_valid = 0; - JsonNode *jcode = json_mkobject(); - sptr = dptr->settings; - while(sptr) { - opt = protocol->options; - /* Loop through all protocol options */ - while(opt) { - /* Check if there are values that can be updated */ - if(strcmp(sptr->name, opt->name) == 0 - && (opt->conftype == DEVICES_VALUE || opt->conftype == DEVICES_OPTIONAL) - && opt->argtype == OPTION_HAS_VALUE) { - memset(vstring_, '\0', sizeof(vstring_)); - vnumber_ = -1; - if(json_find_string(message, opt->name, &stmp) == 0) { - strcpy(vstring_, stmp); - valueType = JSON_STRING; - is_valid = 1; - } - struct JsonNode *jtmp = NULL; - if((jtmp = json_find_member(message, opt->name)) != NULL && - jtmp->tag == JSON_NUMBER) { - vnumber_ = jtmp->number_; - vdecimals_ = jtmp->decimals_; - valueType = JSON_NUMBER; - is_valid = 1; - } - - /* Check if the protocol settings of this device are valid to - make sure no errors occur in the config.json. */ - JsonNode *jsettings = json_first_child(settings); - while(jsettings) { - if(jsettings->tag == JSON_NUMBER) { - json_append_member(jcode, jsettings->key, json_mknumber(jsettings->number_, jsettings->decimals_)); - } else if(jsettings->tag == JSON_STRING) { - json_append_member(jcode, jsettings->key, json_mkstring(jsettings->string_)); - } - jsettings = jsettings->next; - } - if(valueType == JSON_STRING) { - json_append_member(jcode, opt->name, json_mkstring(vstring_)); - } else { - json_append_member(jcode, opt->name, json_mknumber(vnumber_, vdecimals_)); - } - } - opt = opt->next; - } - sptr = sptr->next; - } - if(protocol->checkValues(jcode) != 0) { - is_valid = 0; - } - json_delete(jcode); - } - - sptr = dptr->settings; - while(sptr) { - opt = protocol->options; - /* Loop through all protocol options */ - while(opt) { - /* Check if there are values that can be updated */ - if(strcmp(sptr->name, opt->name) == 0 - && (opt->conftype == DEVICES_VALUE || opt->conftype == DEVICES_OPTIONAL) - && opt->argtype == OPTION_HAS_VALUE) { - int upd_value = 1; - memset(vstring_, '\0', sizeof(vstring_)); - vnumber_ = -1; - vdecimals_ = 0; - struct JsonNode *jtmp = NULL; - if(json_find_string(message, opt->name, &stmp) == 0) { - strcpy(vstring_, stmp); - valueType = JSON_STRING; - } else if((jtmp = json_find_member(message, opt->name)) != NULL && - jtmp->tag == JSON_NUMBER) { - vnumber_ = jtmp->number_; - vdecimals_ = jtmp->decimals_; - valueType = JSON_NUMBER; - } else { - upd_value = 0; - } - - if(is_valid == 1 && upd_value == 1) { - if(valueType == JSON_STRING && - strlen(vstring_) > 0 && - sptr->values->type == JSON_STRING && - strcmp(sptr->values->string_, vstring_) != 0) { - if((sptr->values->string_ = REALLOC(sptr->values->string_, strlen(vstring_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(sptr->values->string_, vstring_); - sptr->values->type = JSON_STRING; - } else if(valueType == JSON_NUMBER && - sptr->values->type == JSON_NUMBER && - fabs(sptr->values->number_-vnumber_) >= EPSILON) { - sptr->values->number_ = vnumber_; - sptr->values->decimals = vdecimals_; - sptr->values->type = JSON_NUMBER; - } - if(sptr->values->type == JSON_STRING && json_find_string(rval, sptr->name, &stmp) != 0) { - json_append_member(rval, sptr->name, json_mkstring(sptr->values->string_)); - update = 1; - } else if(sptr->values->type == JSON_NUMBER && json_find_number(rval, sptr->name, &itmp) != 0) { - json_append_member(rval, sptr->name, json_mknumber(sptr->values->number_, sptr->values->decimals)); - update = 1; - } - dptr->timestamp = utct; - } - //break; - } - opt = opt->next; - } - - /* Check if we need to update the state */ - if(strcmp(sptr->name, "state") == 0) { - if((stateType == JSON_STRING && - sptr->values->type == JSON_STRING && - strcmp(sptr->values->string_, sstring_) != 0)) { - if((sptr->values->string_ = REALLOC(sptr->values->string_, strlen(sstring_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(sptr->values->string_, sstring_); - sptr->values->type = JSON_STRING; - dptr->timestamp = utct; - update = 1; - } else if((stateType == JSON_NUMBER && - sptr->values->type == JSON_NUMBER && - fabs(sptr->values->number_-snumber_) < EPSILON)) { - sptr->values->number_ = snumber_; - sptr->values->decimals = sdecimals_; - sptr->values->type = JSON_NUMBER; - dptr->timestamp = utct; - update = 1; - } - if(sptr->values->type == JSON_STRING && json_find_string(rval, sptr->name, &stmp) != 0) { - json_append_member(rval, sptr->name, json_mkstring(sptr->values->string_)); - } else if(sptr->values->type == JSON_NUMBER && json_find_number(rval, sptr->name, &itmp) != 0) { - json_append_member(rval, sptr->name, json_mknumber(sptr->values->number_, sptr->values->decimals)); - } - //break; - } - if(update == 1) { - match = 0; - struct JsonNode *jchild = json_first_child(rdev); - while(jchild) { - if(jchild->tag == JSON_STRING && strcmp(dptr->id, jchild->string_) == 0) { - match = 1; - break; - } - jchild = jchild->next; - } - if(match == 0) { - dptr->prevorigin = dptr->lastorigin; - dptr->lastorigin = origin; -#ifdef EVENTS - /* - * If the action itself it not triggering a device update, something - * else is. We therefor need to abort the running action to let - * the new state persist. - */ - if(dptr->action_thread->running == 1 && origin != ACTION) { - /* - * In case of Z-Wave, the ACTION is always followed by a RECEIVER origin due to - * its feedback feature. We do not want to abort or action in these cases. - */ - if(!((dptr->protocols->listener->hwtype == ZWAVE) && dptr->lastorigin == RECEIVER && dptr->prevorigin == ACTION) || - dptr->protocols->listener->hwtype != ZWAVE) { - event_action_thread_stop(dptr); - } - } - - /* - * We store the rule number that triggered the device change. - * The eventing library can then check if the same rule is - * triggered again so infinite loops can be prevented. - */ - if(origin == ACTION) { - if(dptr->action_thread->obj != NULL) { - dptr->prevrule = dptr->lastrule; - dptr->lastrule = dptr->action_thread->obj->rule->nr; - } - } else { - dptr->lastrule = -1; - dptr->prevrule = -1; - } -#endif - json_append_element(rdev, json_mkstring(dptr->id)); - } - } - sptr = sptr->next; - } - } - } - } - dptr = dptr->next; - } - } - - if(update == 1) { - json_append_member(rroot, "origin", json_mkstring("update")); - json_append_member(rroot, "type", json_mknumber((int)protocol->devtype, 0)); - //if(strlen(pilight_uuid) > 0 && (protocol->hwtype == SENSOR || protocol->hwtype == HWRELAY)) { - json_append_member(rroot, "uuid", json_mkstring(pilight_uuid)); - //} - json_append_member(rroot, "devices", rdev); - json_append_member(rroot, "values", rval); - - *out = rroot; - } else { - json_delete(rdev); - json_delete(rval); - json_delete(rroot); - } - - return (update == 1) ? 0 : -1; -} - -int devices_get(char *sid, struct devices_t **dev) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct devices_t *dptr = NULL; - - dptr = devices; - while(dptr) { - if(strcmp(dptr->id, sid) == 0) { - if(dev != NULL) { - *dev = dptr; - } - return 0; - } - dptr = dptr->next; - } - - return 1; -} - -int devices_valid_state(char *sid, char *state) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct devices_t *dptr = NULL; - struct protocol_t *protocol = NULL; - struct options_t *options = NULL; - struct protocols_t *tmp_protocol = NULL; - - if(devices_get(sid, &dptr) == 0) { - tmp_protocol = dptr->protocols; - while(tmp_protocol) { - protocol = tmp_protocol->listener; - if(protocol->options) { - options = protocol->options; - while(options) { - if(strcmp(options->name, state) == 0 && options->conftype == DEVICES_STATE) { - return 0; - break; - } - options = options->next; - } - } - tmp_protocol = tmp_protocol->next; - } - } - return 1; -} - -int devices_valid_value(char *sid, char *name, char *value) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct devices_t *dptr = NULL; - struct options_t *opt = NULL; - struct protocols_t *tmp_protocol = NULL; -#if !defined(__FreeBSD__) && !defined(_WIN32) - regex_t regex; - int reti = 0; - memset(®ex, '\0', sizeof(regex)); -#endif - - if(devices_get(sid, &dptr) == 0) { - tmp_protocol = dptr->protocols; - while(tmp_protocol) { - opt = tmp_protocol->listener->options; - while(opt) { - if((opt->conftype == DEVICES_VALUE || opt->conftype == DEVICES_OPTIONAL) && strcmp(name, opt->name) == 0) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - if(opt->mask != NULL) { - reti = regcomp(®ex, opt->mask, REG_EXTENDED); - if(reti) { - logprintf(LOG_ERR, "%s: could not compile %s regex", tmp_protocol->listener->id, opt->name); - exit(EXIT_FAILURE); - } - reti = regexec(®ex, value, 0, NULL, 0); - if(reti == REG_NOMATCH || reti != 0) { - regfree(®ex); - return 1; - } - regfree(®ex); - } -#endif - return 0; - } - opt = opt->next; - } - tmp_protocol = tmp_protocol->next; - } - } - return 1; -} - -struct JsonNode *devices_values(const char *media) { - /* Temporary pointer to the different structure */ - struct devices_t *tmp_devices = NULL; - struct devices_settings_t *tmp_settings = NULL; - struct devices_values_t *tmp_values = NULL; - struct gui_values_t *gui_values = NULL; - - /* Pointers to the newly created JSON object */ - struct JsonNode *jroot = json_mkarray(); - struct JsonNode *jelement = NULL; - struct JsonNode *jvalues = NULL; - struct JsonNode *jdevices = NULL; - struct options_t *opt = NULL; - - int match = 0; - - tmp_devices = devices; - - while(tmp_devices) { - match = 0; - if((gui_values = gui_media(tmp_devices->id)) != NULL) { - while(gui_values) { - if(gui_values->type == JSON_STRING) { - if(strcmp(gui_values->string_, media) == 0 || - strcmp(gui_values->string_, "all") == 0 || - strcmp(media, "all") == 0) { - match = 1; - } - } - gui_values = gui_values->next; - } - } else { - match = 1; - } - if(strcmp(media, "all") == 0) { - match = 1; - } - if(match == 1) { - jelement = json_mkobject(); - jdevices = json_mkarray(); - jvalues = json_mkobject(); - - struct protocols_t *tmp_protocols = tmp_devices->protocols; - json_append_member(jelement, "type", json_mknumber(tmp_protocols->listener->devtype, 0)); - json_append_element(jdevices, json_mkstring(tmp_devices->id)); - json_append_member(jelement, "devices", jdevices); - - json_append_member(jvalues, "timestamp", json_mknumber(tmp_devices->timestamp, 0)); - - tmp_settings = tmp_devices->settings; - while(tmp_settings) { - if(strcmp(tmp_settings->name, "state") == 0) { - tmp_values = tmp_settings->values; - if(tmp_values->type == JSON_NUMBER) { - json_append_member(jvalues, tmp_settings->name, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_member(jvalues, tmp_settings->name, json_mkstring(tmp_values->string_)); - } - } - tmp_settings = tmp_settings->next; - } - - while(tmp_protocols) { - opt = tmp_protocols->listener->options; - while(opt) { - if(opt->conftype == DEVICES_VALUE || opt->conftype == DEVICES_OPTIONAL) { - tmp_settings = tmp_devices->settings; - while(tmp_settings) { - if(strcmp(tmp_settings->name, opt->name) == 0) { - tmp_values = tmp_settings->values; - if(tmp_values->type == JSON_NUMBER) { - json_append_member(jvalues, tmp_settings->name, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_member(jvalues, tmp_settings->name, json_mkstring(tmp_values->string_)); - } - } - tmp_settings = tmp_settings->next; - } - } - opt = opt->next; - } - tmp_protocols = tmp_protocols->next; - } - json_append_member(jelement, "values", jvalues); - json_append_element(jroot, jelement); - } - tmp_devices = tmp_devices->next; - } - - return jroot; -} - -struct JsonNode *devices_sync(int level, const char *media) { - /* Temporary pointer to the different structure */ - struct devices_t *tmp_devices = NULL; - struct devices_settings_t *tmp_settings = NULL; - struct devices_values_t *tmp_values = NULL; - struct gui_values_t *gui_values = NULL; - int match = 0; - - /* Pointers to the newly created JSON object */ - struct JsonNode *jroot = json_mkobject(); - struct JsonNode *jdevice = NULL; - struct JsonNode *joptions = NULL; - struct JsonNode *jid = NULL; - struct options_t *tmp_options = NULL; - - tmp_devices = devices; - - while(tmp_devices) { - match = 0; - if((gui_values = gui_media(tmp_devices->id)) != NULL) { - while(gui_values) { - if(gui_values->type == JSON_STRING) { - if(strcmp(gui_values->string_, media) == 0 || - strcmp(gui_values->string_, "all") == 0 || - strcmp(media, "all") == 0) { - match = 1; - } - } - gui_values = gui_values->next; - } - } else { - match = 1; - } - if(strcmp(media, "all") == 0) { - match = 1; - } - if(match == 1) { - jdevice = json_mkobject(); - - struct protocols_t *tmp_protocols = tmp_devices->protocols; - struct JsonNode *jprotocols = json_mkarray(); - - if(level == CONFIG_INTERNAL || (strlen(pilight_uuid) > 0 && - (strcmp(tmp_devices->ori_uuid, pilight_uuid) == 0) && - (strcmp(tmp_devices->dev_uuid, pilight_uuid) != 0)) - || tmp_devices->cst_uuid == 1) { - json_append_member(jdevice, "uuid", json_mkstring(tmp_devices->dev_uuid)); - } - if(level == CONFIG_INTERNAL || level == CONFIG_INTERNAL) { - json_append_member(jdevice, "origin", json_mkstring(tmp_devices->ori_uuid)); - json_append_member(jdevice, "timestamp", json_mknumber((double)tmp_devices->timestamp, 0)); - } - - while(tmp_protocols) { - json_append_element(jprotocols, json_mkstring(tmp_protocols->name)); - tmp_protocols = tmp_protocols->next; - } - json_append_member(jdevice, "protocol", jprotocols); - json_append_member(jdevice, "id", json_mkarray()); - - tmp_settings = tmp_devices->settings; - while(tmp_settings) { - tmp_values = tmp_settings->values; - if(strcmp(tmp_settings->name, "id") == 0) { - jid = json_find_member(jdevice, tmp_settings->name); - JsonNode *jnid = json_mkobject(); - while(tmp_values) { - if(tmp_values->type == JSON_NUMBER) { - json_append_member(jnid, tmp_values->name, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_member(jnid, tmp_values->name, json_mkstring(tmp_values->string_)); - } - tmp_values = tmp_values->next; - } - json_append_element(jid, jnid); - } else if(!tmp_values->next) { - if(tmp_values->type == JSON_NUMBER) { - json_append_member(jdevice, tmp_settings->name, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_member(jdevice, tmp_settings->name, json_mkstring(tmp_values->string_)); - } - } else { - joptions = json_mkarray(); - while(tmp_values) { - if(tmp_values->type == JSON_NUMBER) { - json_append_element(joptions, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_element(joptions, json_mkstring(tmp_values->string_)); - } - tmp_values = tmp_values->next; - } - json_append_member(jdevice, tmp_settings->name, joptions); - } - tmp_settings = tmp_settings->next; - } - - tmp_protocols = tmp_devices->protocols; - while(tmp_protocols) { - tmp_options = tmp_protocols->listener->options; - if(tmp_options) { - while(tmp_options) { - if((level == CONFIG_INTERNAL || level == CONFIG_INTERNAL) && (tmp_options->conftype == DEVICES_SETTING) - && json_find_member(jdevice, tmp_options->name) == NULL) { - if(tmp_options->vartype == JSON_NUMBER) { - json_append_member(jdevice, tmp_options->name, json_mknumber((int)(intptr_t)tmp_options->def, 0)); - } else if(tmp_options->vartype == JSON_STRING) { - json_append_member(jdevice, tmp_options->name, json_mkstring((char *)tmp_options->def)); - } - } - tmp_options = tmp_options->next; - } - } - tmp_protocols = tmp_protocols->next; - } - json_append_member(jroot, tmp_devices->id, jdevice); - } - tmp_devices = tmp_devices->next; - } - - return jroot; -} - -/* Save the device settings to the device struct */ -static void devices_save_setting(int i, struct JsonNode *jsetting, struct devices_t *device) { - /* Struct to store the values */ - struct devices_values_t *vnode = NULL; - struct devices_settings_t *snode = NULL; - struct devices_settings_t *tmp_settings = NULL; - struct devices_values_t *tmp_values = NULL; - /* Temporary JSON pointer */ - struct JsonNode *jtmp; - - /* Variable holder for casting settings */ - char *stmp = NULL; - - /* If the JSON tag is an array, then it should be a values or id array */ - if(jsetting->tag == JSON_ARRAY) { - if(strcmp(jsetting->key, "id") == 0) { - /* Loop through the values of this values array */ - jtmp = json_first_child(jsetting); - while(jtmp) { - if((snode = MALLOC(sizeof(struct devices_settings_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(jsetting->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, jsetting->key); - snode->values = NULL; - snode->next = NULL; - if(jtmp->tag == JSON_OBJECT) { - JsonNode *jtmp1 = json_first_child(jtmp); - while(jtmp1) { - if((vnode = MALLOC(sizeof(struct devices_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((vnode->name = MALLOC(strlen(jtmp1->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->name, jtmp1->key); - vnode->next = NULL; - if(jtmp1->tag == JSON_STRING) { - if((vnode->string_ = MALLOC(strlen(jtmp1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->string_, jtmp1->string_); - vnode->type = JSON_STRING; - } else if(jtmp1->tag == JSON_NUMBER) { - vnode->number_ = jtmp1->number_; - vnode->decimals = jtmp1->decimals_; - vnode->type = JSON_NUMBER; - } - if(jtmp1->tag == JSON_NUMBER || jtmp1->tag == JSON_STRING) { - tmp_values = snode->values; - if(tmp_values) { - while(tmp_values->next != NULL) { - tmp_values = tmp_values->next; - } - tmp_values->next = vnode; - } else { - vnode->next = snode->values; - snode->values = vnode; - } - } - jtmp1 = jtmp1->next; - } - } - jtmp = jtmp->next; - - tmp_settings = device->settings; - if(tmp_settings) { - while(tmp_settings->next != NULL) { - tmp_settings = tmp_settings->next; - } - tmp_settings->next = snode; - } else { - snode->next = device->settings; - device->settings = snode; - } - } - } - } else if(jsetting->tag == JSON_OBJECT) { - if((snode = MALLOC(sizeof(struct devices_settings_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(jsetting->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, jsetting->key); - snode->values = NULL; - snode->next = NULL; - - jtmp = json_first_child(jsetting); - while(jtmp) { - if(jtmp->tag == JSON_STRING) { - if((vnode = MALLOC(sizeof(struct devices_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((vnode->name = MALLOC(strlen(jtmp->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->name, jtmp->key); - if((vnode->string_ = MALLOC(strlen(jtmp->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->string_, jtmp->string_); - vnode->type = JSON_STRING; - vnode->next = NULL; - } else if(jtmp->tag == JSON_NUMBER) { - if((vnode = MALLOC(sizeof(struct devices_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((vnode->name = MALLOC(strlen(jtmp->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->name, jtmp->key); - vnode->number_ = jtmp->number_; - vnode->decimals = jtmp->decimals_; - vnode->type = JSON_NUMBER; - vnode->next = NULL; - } - if(jtmp->tag == JSON_NUMBER || jtmp->tag == JSON_STRING) { - tmp_values = snode->values; - if(tmp_values) { - while(tmp_values->next != NULL) { - tmp_values = tmp_values->next; - } - tmp_values->next = vnode; - } else { - vnode->next = snode->values; - snode->values = vnode; - } - } - jtmp = jtmp->next; - } - - tmp_settings = device->settings; - if(tmp_settings) { - while(tmp_settings->next != NULL) { - tmp_settings = tmp_settings->next; - } - tmp_settings->next = snode; - } else { - snode->next = device->settings; - device->settings = snode; - } - - } else { - /* New device settings node */ - if((snode = MALLOC(sizeof(struct devices_settings_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(jsetting->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, jsetting->key); - snode->values = NULL; - snode->next = NULL; - - if((vnode = MALLOC(sizeof(struct devices_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - int valid = 0; - /* Cast and store the new value */ - if(jsetting->tag == JSON_STRING && json_find_string(jsetting->parent, jsetting->key, &stmp) == 0) { - if((vnode->string_ = MALLOC(strlen(stmp)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - vnode->name = NULL; - strcpy(vnode->string_, stmp); - vnode->type = JSON_STRING; - valid = 1; - } else if(jsetting->tag == JSON_NUMBER && - (jtmp = json_find_member(jsetting->parent, jsetting->key)) != NULL && - jtmp->tag == JSON_NUMBER) { - vnode->name = NULL; - vnode->number_ = jtmp->number_; - vnode->decimals = jtmp->decimals_; - vnode->type = JSON_NUMBER; - valid = 1; - } - if(valid) { - tmp_values = snode->values; - if(tmp_values) { - while(tmp_values->next != NULL) { - tmp_values = tmp_values->next; - } - tmp_values->next = vnode; - } else { - vnode->next = snode->values; - snode->values = vnode; - } - } - - tmp_settings = device->settings; - if(tmp_settings) { - while(tmp_settings->next != NULL) { - tmp_settings = tmp_settings->next; - } - tmp_settings->next = snode; - } else { - snode->next = device->settings; - device->settings = snode; - } - } -} - -static int devices_check_id(int i, JsonNode *jsetting, struct devices_t *device) { - /* Temporary options pointer */ - struct options_t *tmp_options = NULL; - /* Temporary ID array pointer */ - struct JsonNode *jid = NULL; - /* Temporary ID values pointer */ - struct JsonNode *jvalues = NULL; - /* Temporary protocols pointer */ - struct protocols_t *tmp_protocols = NULL; - - int match1 = 0, match2 = 0, match3 = 0, has_id = 0; - int valid_values = 0, nrprotocols = 0, nrids1 = 0; - unsigned short nrid = 0; - int nrids2 = 0, have_error = 0, etype = 0; - - /* Variable holders for casting */ - char ctmp[256]; - - tmp_protocols = device->protocols; - while(tmp_protocols) { - jid = json_first_child(jsetting); - has_id = 0; - nrid = 0; - match3 = 0; - nrprotocols++; - while(jid) { - nrid++; - match2 = 0; match1 = 0; nrids1 = 0; nrids2 = 0; - jvalues = json_first_child(jid); - while(jvalues) { - nrids1++; - jvalues = jvalues->next; - } - if((tmp_options = tmp_protocols->listener->options)) { - while(tmp_options) { - if(tmp_options->conftype == DEVICES_ID) { - nrids2++; - } - tmp_options = tmp_options->next; - } - } - if(nrids1 == nrids2) { - has_id = 1; - jvalues = json_first_child(jid); - while(jvalues) { - match1++; - if((tmp_options = tmp_protocols->listener->options)) { - while(tmp_options) { - if(tmp_options->conftype == DEVICES_ID && tmp_options->vartype == jvalues->tag) { - if(strcmp(tmp_options->name, jvalues->key) == 0) { - match2++; - if(jvalues->tag == JSON_NUMBER) { - sprintf(ctmp, "%.*f", jvalues->decimals_, jvalues->number_); - } else if(jvalues->tag == JSON_STRING) { - strcpy(ctmp, jvalues->string_); - } - - if(tmp_options->mask != NULL && strlen(tmp_options->mask) > 0) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - regex_t regex; - memset(®ex, '\0', sizeof(regex)); - int reti = regcomp(®ex, tmp_options->mask, REG_EXTENDED); - if(reti) { - logprintf(LOG_ERR, "%s: could not compile %s regex", tmp_protocols->listener->id, tmp_options->name); - } else { - reti = regexec(®ex, ctmp, 0, NULL, 0); - if(reti == REG_NOMATCH || reti != 0) { - match2--; - } - regfree(®ex); - } -#endif - } - } - } - tmp_options = tmp_options->next; - } - } - jvalues = jvalues->next; - } - } - jid = jid->next; - if(match2 > 0 && match1 == match2) { - match3 = 1; - } - } - if(!has_id) { - valid_values--; - } else if(tmp_protocols->listener->multipleId == 0 && nrid > 1) { - valid_values--; - etype = 1; - break; - } else if(match3) { - valid_values++; - } else { - valid_values--; - } - tmp_protocols = tmp_protocols->next; - } - if(nrprotocols != valid_values) { - if(etype == 1) { - logprintf(LOG_ERR, "protocol \"%s\" used in \"%s\" doesn't support multiple id's", tmp_protocols->listener->id, device->id); - } else { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, "id", device->id); - } - have_error = 1; - } - return have_error; -} - -static int devices_validate_settings(void) { - /* Temporary pointer to the different structure */ - struct devices_t *tmp_devices = NULL; - struct devices_settings_t *tmp_settings = NULL; - struct devices_values_t *tmp_values = NULL; - - /* Pointers to the newly created JSON object */ - struct JsonNode *jdevice = NULL; - struct JsonNode *joptions = NULL; - - int have_error = 0; - int dorder = 0; - - tmp_devices = devices; - while(tmp_devices) { - - jdevice = json_mkobject(); - struct protocols_t *tmp_protocols = tmp_devices->protocols; - while(tmp_protocols) { - /* Only continue if protocol specific settings can be validated */ - if(tmp_protocols->listener->checkValues) { - tmp_settings = tmp_devices->settings; - dorder++; - while(tmp_settings) { - tmp_values = tmp_settings->values; - /* Retrieve all protocol specific settings for this device. Also add all - device values and states so it can be validated by the protocol */ - if(strcmp(tmp_settings->name, "id") == 0) { - JsonNode *jid = json_find_member(jdevice, "id"); - if(!jid) { - jid = json_mkarray(); - json_append_member(jdevice, tmp_settings->name, jid); - } - JsonNode *jnid = json_mkobject(); - while(tmp_values) { - if(tmp_values->type == JSON_NUMBER) { - json_append_member(jnid, tmp_values->name, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_member(jnid, tmp_values->name, json_mkstring(tmp_values->string_)); - } - tmp_values = tmp_values->next; - } - json_append_element(jid, jnid); - } else { - if(!tmp_values->next) { - if(tmp_values->type == JSON_STRING) { - json_append_member(jdevice, tmp_settings->name, json_mkstring(tmp_values->string_)); - } else if(tmp_values->type == JSON_NUMBER) { - json_append_member(jdevice, tmp_settings->name, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } - } else { - joptions = json_mkarray(); - while(tmp_values) { - if(tmp_values->type == JSON_STRING) { - json_append_element(joptions, json_mkstring(tmp_values->string_)); - } else if(tmp_values->type == JSON_NUMBER) { - json_append_element(joptions, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } - tmp_values = tmp_values->next; - } - json_append_member(jdevice, tmp_settings->name, joptions); - } - } - tmp_settings = tmp_settings->next; - } - - /* Let the settings and values be validated against each other */ - if(tmp_protocols->listener->checkValues(jdevice) != 0) { - logprintf(LOG_ERR, "config device #%d, invalid", dorder); - have_error = 1; - goto clear; - } - } - tmp_protocols = tmp_protocols->next; - } - tmp_devices = tmp_devices->next; - json_delete(jdevice); - jdevice=NULL; - } - -clear: - if(jdevice) { - json_delete(jdevice); - } - return have_error; -} - -static int devices_check_state(int i, JsonNode *jsetting, struct devices_t *device) { - /* Temporary options pointer */ - struct options_t *tmp_options; - - int valid_state = 0, have_error = 0; - - /* Variable holders for casting */ - double itmp = 0; - char ctmp[256]; - char *stmp = NULL; - -#if !defined(__FreeBSD__) && !defined(_WIN32) - /* Regex variables */ - regex_t regex; - int reti = 0; - memset(®ex, '\0', sizeof(regex)); -#endif - - /* Cast the different values */ - if(jsetting->tag == JSON_NUMBER && json_find_number(jsetting->parent, jsetting->key, &itmp) == 0) { - sprintf(ctmp, "%.0f", itmp); - } else if(jsetting->tag == JSON_STRING && json_find_string(jsetting->parent, jsetting->key, &stmp) == 0) { - strcpy(ctmp, stmp); - } - - struct protocols_t *tmp_protocols = device->protocols; - while(tmp_protocols) { - /* Check if the specific device contains any options */ - if(tmp_protocols->listener->options) { - - tmp_options = tmp_protocols->listener->options; - - while(tmp_options) { - /* We are only interested in the DEVICES_STATE options */ - if(tmp_options->conftype == DEVICES_STATE && tmp_options->vartype == jsetting->tag) { - /* If an option requires an argument, then check if the - argument state values and values array are of the right - type. This is done by checking the regex mask */ - if(tmp_options->argtype == OPTION_HAS_VALUE) { - if(tmp_options->mask != NULL && strlen(tmp_options->mask) > 0) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - reti = regcomp(®ex, tmp_options->mask, REG_EXTENDED); - if(reti) { - logprintf(LOG_ERR, "%s: could not compile %s regex", tmp_protocols->listener->id, tmp_options->name); - have_error = 1; - goto clear; - } - reti = regexec(®ex, ctmp, 0, NULL, 0); - - if(reti == REG_NOMATCH || reti != 0) { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsetting->key, device->id); - have_error = 1; - regfree(®ex); - goto clear; - } - regfree(®ex); -#endif - } - } else { - /* If a protocol has DEVICES_STATE arguments, than these define - the states a protocol can take. Check if the state value - match, these protocol states */ - - if(strcmp(tmp_options->name, ctmp) == 0 && valid_state == 0) { - valid_state = 1; - } - } - } - tmp_options = tmp_options->next; - } - } - tmp_protocols = tmp_protocols->next; - } - - if(valid_state == 0) { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsetting->key, device->id); - have_error = 1; - goto clear; - } - -clear: - return have_error; -} - -static int devices_parse_elements(JsonNode *jdevices, struct devices_t *device) { - /* Temporary settings holder */ - struct devices_settings_t *tmp_settings = NULL; - /* JSON devices iterator */ - JsonNode *jsettings = NULL; - /* Temporarily options pointer */ - struct options_t *tmp_options = NULL; - /* Temporarily protocols pointer */ - struct protocols_t *tmp_protocols = NULL; - - int i = 0, have_error = 0, valid_setting = 0; - int match = 0, has_state = 0; - /* Check for any duplicate fields */ - int nrprotocol = 0, nrstate = 0; - int nruuid = 0, nrorigin = 0, nrtimestamps = 0; - - jsettings = json_first_child(jdevices); - - while(jsettings) { - i++; - /* Check for any duplicate fields */ - if(strcmp(jsettings->key, "uuid") == 0) { - nruuid++; - } - if(strcmp(jsettings->key, "origin") == 0) { - nrorigin++; - } - if(strcmp(jsettings->key, "protocol") == 0) { - nrprotocol++; - } - if(strcmp(jsettings->key, "state") == 0) { - nrstate++; - } - if(strcmp(jsettings->key, "timestamp") == 0) { - nrtimestamps++; - } - if(nrstate > 1 || nrprotocol > 1 || nruuid > 1 || nrtimestamps > 1) { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", duplicate", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - - /* Parse the state setting separately from the other settings. */ - if(strcmp(jsettings->key, "state") == 0) { - if(jsettings->tag == JSON_STRING || jsettings->tag == JSON_NUMBER) { - if(devices_check_state(i, jsettings, device) != 0) { - have_error = 1; - goto clear; - } - devices_save_setting(i, jsettings, device); - } else { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - } else if(strcmp(jsettings->key, "id") == 0) { - if(jsettings->tag == JSON_ARRAY) { - if(devices_check_id(i, jsettings, device) == EXIT_FAILURE) { - have_error = 1; - goto clear; - } - devices_save_setting(i, jsettings, device); - } else { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - } else if(strcmp(jsettings->key, "uuid") == 0) { - if(jsettings->tag == JSON_STRING) { - strcpy(device->dev_uuid, jsettings->string_); - device->cst_uuid = 1; - } else { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - } else if(strcmp(jsettings->key, "timestamp") == 0) { - if(jsettings->tag == JSON_NUMBER) { - device->timestamp = (int)jsettings->number_; - } else { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - } else if(strcmp(jsettings->key, "origin") == 0) { - if(jsettings->tag == JSON_STRING) { - strcpy(device->ori_uuid, jsettings->string_); - } else { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - /* The protocol and name settings are already saved in the device struct */ - } else if(!((strcmp(jsettings->key, "protocol") == 0 && jsettings->tag == JSON_ARRAY) - || (strcmp(jsettings->key, "uuid") == 0 && jsettings->tag == JSON_STRING) - || (strcmp(jsettings->key, "timestamp") == 0 && jsettings->tag == JSON_NUMBER)) - || ((strcmp(jsettings->key, "id") == 0) && jsettings->tag == JSON_ARRAY)) { - - /* Check for duplicate settings */ - tmp_settings = device->settings; - while(tmp_settings) { - if(strcmp(tmp_settings->name, jsettings->key) == 0) { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", duplicate", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - tmp_settings = tmp_settings->next; - } - - tmp_protocols = device->protocols; - valid_setting = 0; - while(tmp_protocols) { - /* Check if the settings are required by the protocol */ - if(tmp_protocols->listener->options) { - tmp_options = tmp_protocols->listener->options; - while(tmp_options) { - if(strcmp(jsettings->key, tmp_options->name) == 0 - && (tmp_options->conftype == DEVICES_ID - || tmp_options->conftype == DEVICES_VALUE - || tmp_options->conftype == DEVICES_SETTING - || tmp_options->conftype == DEVICES_OPTIONAL) - && (tmp_options->vartype == jsettings->tag - || tmp_options->vartype == (JSON_STRING | JSON_NUMBER))) { - valid_setting = 1; - break; - } - tmp_options = tmp_options->next; - } - } - tmp_protocols = tmp_protocols->next; - } - /* If the settings are valid, store them */ - if(valid_setting == 1) { - devices_save_setting(i, jsettings, device); - } else { - logprintf(LOG_ERR, "config device setting #%d \"%s\" of \"%s\", invalid", i, jsettings->key, device->id); - have_error = 1; - goto clear; - } - } - jsettings = jsettings->next; - } - - /* Check if required options by this protocol are missing - in the devices file */ - tmp_protocols = device->protocols; - while(tmp_protocols) { - if(tmp_protocols->listener->options) { - tmp_options = tmp_protocols->listener->options; - while(tmp_options) { - match = 0; - jsettings = json_first_child(jdevices); - while(jsettings) { - if(strcmp(jsettings->key, tmp_options->name) == 0) { - match = 1; - break; - } - jsettings = jsettings->next; - } - if(match == 0 && tmp_options->conftype == DEVICES_VALUE) { - logprintf(LOG_ERR, "config device setting \"%s\" of \"%s\", missing", tmp_options->name, device->id); - have_error = 1; - goto clear; - } - tmp_options = tmp_options->next; - } - - } - tmp_protocols = tmp_protocols->next; - } - match = 0; - jsettings = json_first_child(jdevices); - while(jsettings) { - if(strcmp(jsettings->key, "id") == 0) { - match = 1; - break; - } - jsettings = jsettings->next; - } - if(match == 0) { - logprintf(LOG_ERR, "config device setting \"id\" of \"%s\", missing", device->id); - have_error = 1; - goto clear; - } - - /* Check if this protocol requires a state setting */ - if(nrstate == 0) { - tmp_protocols = device->protocols; - while(tmp_protocols) { - if(tmp_protocols->listener->options) { - tmp_options = tmp_protocols->listener->options; - while(tmp_options) { - if(tmp_options->conftype == DEVICES_STATE) { - has_state = 1; - break; - } - tmp_options = tmp_options->next; - } - } - if(has_state == 1) { - if(nrstate == 0) { - logprintf(LOG_ERR, "config device setting \"%s\" of \"%s\", missing", "state", device->id); - have_error = 1; - goto clear; - } - } - tmp_protocols = tmp_protocols->next; - } - } - - if(strlen(pilight_uuid) > 0 && strcmp(device->dev_uuid, pilight_uuid) == 0) { - tmp_protocols = device->protocols; - while(tmp_protocols) { - if(tmp_protocols->listener->initDev && (tmp_protocols->listener->masterOnly == 0 || pilight.runmode == STANDALONE)) { - struct threadqueue_t *tmp = tmp_protocols->listener->initDev(jdevices); - if(tmp != NULL) { - device->protocol_threads = REALLOC(device->protocol_threads, (sizeof(struct threadqueue_t *)*(size_t)(device->nrthreads+1))); - device->protocol_threads[device->nrthreads] = tmp; - device->nrthreads++; - } - } - tmp_protocols = tmp_protocols->next; - } - } - -clear: - return have_error; -} - -static int devices_parse(JsonNode *root) { - /* Struct to store the devices */ - struct devices_t *dnode = NULL; - /* Temporary JSON devices */ - struct devices_t *tmp_devices = NULL; - /* Temporary protocol JSON array */ - JsonNode *jprotocol = NULL; - JsonNode *jprotocols = NULL; - /* JSON devices iterator */ - JsonNode *jdevices = NULL; - - int i = 0, have_error = 0, match = 0, x = 0; - - jdevices = json_first_child(root); - while(jdevices) { - i++; - /* Check if all fields of the devices are of the right type */ - if(jdevices->tag != JSON_OBJECT) { - logprintf(LOG_ERR, "config device device #%d \"%s\", invalid field(s)", i, jdevices->key); - have_error = 1; - goto clear; - } else { - if((jprotocols = json_find_member(jdevices, "protocol")) == NULL || jprotocols->tag != JSON_ARRAY) { - logprintf(LOG_ERR, "config device #%d \"%s\", missing protocol", i, jdevices->key); - have_error = 1; - goto clear; - } else { - for(x=0;xkey);x++) { - if(!isalnum(jdevices->key[x]) && jdevices->key[x] != '-' && jdevices->key[x] != '_') { - logprintf(LOG_ERR, "config device #%d \"%s\", not alphanumeric", i, jdevices->key); - have_error = 1; - goto clear; - } - struct protocols_t *tmp_protocols = protocols; - while(tmp_protocols) { - struct protocol_t *protocol = tmp_protocols->listener; - if(strcmp(protocol->id, jdevices->key) == 0) { - logprintf(LOG_ERR, "config device #%d \"%s\", protocol names are reserved words", i, jdevices->key); - have_error = 1; - goto clear; - } - tmp_protocols = tmp_protocols->next; - } - } - /* Check for duplicate fields */ - tmp_devices = devices; - while(tmp_devices) { - if(strcmp(tmp_devices->id, jdevices->key) == 0) { - logprintf(LOG_ERR, "config device #%d \"%s\", duplicate", i, jdevices->key); - have_error = 1; - } - tmp_devices = tmp_devices->next; - } - - if((dnode = MALLOC(sizeof(struct devices_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if(strlen(pilight_uuid) > 0) { - strcpy(dnode->dev_uuid, pilight_uuid); - strcpy(dnode->ori_uuid, pilight_uuid); - } - dnode->cst_uuid = 0; - if((dnode->id = MALLOC(strlen(jdevices->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(dnode->id, jdevices->key); - dnode->nrthreads = 0; - dnode->timestamp = 0; - dnode->protocol_threads = NULL; - dnode->settings = NULL; - dnode->next = NULL; - dnode->protocols = NULL; - -#ifdef EVENTS - event_action_thread_init(dnode); -#endif - - int ptype = -1; - /* Save both the protocol pointer and the protocol name */ - jprotocol = json_first_child(jprotocols); - while(jprotocol) { - match = 0; - struct protocols_t *tmp_protocols = protocols; - /* Pointer to the match protocol */ - struct protocol_t *protocol = NULL; - while(tmp_protocols) { - protocol = tmp_protocols->listener; - if(protocol_device_exists(protocol, jprotocol->string_) == 0 && match == 0 - && protocol->config == 1) { - if(ptype == -1) { - ptype = protocol->hwtype; - match = 1; - } - if(ptype > -1 && protocol->hwtype == ptype) { - match = 1; - } - match = 1; - break; - } - tmp_protocols = tmp_protocols->next; - } - if(match == 1 && ptype != protocol->hwtype) { - logprintf(LOG_ERR, "config device #%d \"%s\", cannot combine protocols of different hardware types", i, jdevices->key); - have_error = 1; - } - if(match == 0) { - logprintf(LOG_ERR, "config device #%d \"%s\", invalid protocol", i, jdevices->key); - have_error = 1; - } else { - struct protocols_t *pnode = MALLOC(sizeof(struct protocols_t)); - if(pnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((pnode->listener = MALLOC(sizeof(struct protocol_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memcpy(pnode->listener, protocol, sizeof(struct protocol_t)); - if((pnode->name = MALLOC(strlen(jprotocol->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(pnode->name, jprotocol->string_); - pnode->next = NULL; - tmp_protocols = dnode->protocols; - if(tmp_protocols) { - while(tmp_protocols->next != NULL) { - tmp_protocols = tmp_protocols->next; - } - tmp_protocols->next = pnode; - } else { - pnode->next = dnode->protocols; - dnode->protocols = pnode; - } - } - jprotocol = jprotocol->next; - } - - if(have_error == 0 && devices_parse_elements(jdevices, dnode) != 0) { - have_error = 1; - } - - tmp_devices = devices; - if(tmp_devices) { - while(tmp_devices->next != NULL) { - tmp_devices = tmp_devices->next; - } - tmp_devices->next = dnode; - } else { - dnode->next = devices; - devices = dnode; - } - - if(have_error) { - goto clear; - } - } - } - - jdevices = jdevices->next; - } - -clear: - return have_error; -} - -int devices_gc(void) { - int i = 0; - struct devices_t *dtmp = NULL; - struct devices_settings_t *stmp = NULL; - struct devices_values_t *vtmp = NULL; - struct protocols_t *ptmp = NULL; - - pthread_mutex_lock(&mutex_lock); - /* Free devices structure */ - while(devices) { - dtmp = devices; - -#ifdef EVENTS - event_action_thread_free(dtmp); -#endif - - while(dtmp->settings) { - stmp = dtmp->settings; - while(stmp->values) { - vtmp = stmp->values; - if(vtmp->type == JSON_STRING && vtmp->string_ != NULL) { - FREE(vtmp->string_); - } - if(vtmp->name) { - FREE(vtmp->name); - } - stmp->values = stmp->values->next; - FREE(vtmp); - } - if(stmp->values != NULL) { - FREE(stmp->values); - } - if(stmp->name) { - FREE(stmp->name); - } - dtmp->settings = dtmp->settings->next; - FREE(stmp); - } - while(dtmp->protocols) { - ptmp = dtmp->protocols; - if(ptmp->listener != NULL && ptmp->listener->threadGC != NULL) { - ptmp->listener->threadGC(); - } - if(ptmp->name != NULL) { - FREE(ptmp->name); - } - if(ptmp->listener != NULL) { - FREE(ptmp->listener); - } - dtmp->protocols = dtmp->protocols->next; - FREE(ptmp); - } - if(dtmp->nrthreads > 0) { - for(i=0;inrthreads;i++) { - thread_stop(dtmp->protocol_threads[i]->id); - } - } - if(dtmp->protocols != NULL) { - FREE(dtmp->protocols); - } - if(dtmp->settings != NULL) { - FREE(dtmp->settings); - } - if(dtmp->id != NULL) { - FREE(dtmp->id); - } - if(dtmp->protocol_threads != NULL) { - FREE(dtmp->protocol_threads); - } - devices = devices->next; - FREE(dtmp); - } - if(devices != NULL) { - FREE(devices); - } - devices = NULL; - - pthread_mutex_unlock(&mutex_lock); - logprintf(LOG_DEBUG, "garbage collected config devices library"); - - return EXIT_SUCCESS; -} - -static int devices_read(JsonNode *root) { - if(devices_parse(root) == 0 && devices_validate_settings() == 0) { - return 0; - } else { - return 1; - } -} - -void devices_init(void) { - pthread_mutexattr_init(&mutex_attr); - pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mutex_lock, &mutex_attr); - - /* Request hardware json object in main configuration */ - config_register(&config_devices, "devices"); - config_devices->readorder = 1; - config_devices->writeorder = 0; - config_devices->parse=&devices_read; - config_devices->sync=&devices_sync; - config_devices->gc=&devices_gc; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/config/devices.h b/lib/ESPiLight/pilight/libs/pilight/config/devices.h deleted file mode 100644 index a3a521e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/devices.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _DEVICES_H_ -#define _DEVICES_H_ - -#include - -typedef struct devices_settings_t devices_settings_t; -typedef struct devices_values_t devices_values_t; -typedef struct devices_t devices_t; - -#include "../core/pilight.h" -#include "../core/threads.h" -#include "../core/config.h" -#include "../protocols/protocol.h" -#include "../events/action.h" - -/* -|------------------| -| devices_t | -|------------------| -| id | -| name | -| protocols | --> protocols_t -| settings | --- -|------------------| | - | -|------------------| | -|devices_settings_t| <-- -|------------------| -| name | -| values | --- -|------------------| | - | -|------------------| | -| devices_values_t | <-- -|------------------| -| value | -| type | -|------------------| -*/ - -struct devices_values_t { - union { - char *string_; - double number_; - }; - int decimals; - char *name; - int type; - struct devices_values_t *next; -}; - -struct devices_settings_t { - char *name; - struct devices_values_t *values; - struct devices_settings_t *next; -}; - -struct devices_t { - char *id; - char dev_uuid[22]; - char ori_uuid[22]; - int cst_uuid; - int nrthreads; - time_t timestamp; -#ifdef EVENTS - int lastrule; - int prevrule; - enum origin_t lastorigin; - enum origin_t prevorigin; - struct event_action_thread_t *action_thread; -#endif - struct protocols_t *protocols; - struct devices_settings_t *settings; - struct threadqueue_t **protocol_threads; - struct devices_t *next; -}; - -extern struct config_t *config_devices; - -int devices_update(char *protoname, JsonNode *message, enum origin_t origin, JsonNode **out); -int devices_get(char *sid, struct devices_t **dev); -int devices_valid_state(char *sid, char *state); -int devices_valid_value(char *sid, char *name, char *value); -struct JsonNode *devices_values(const char *media); -void devices_init(void); -int devices_gc(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/config/gui.c b/lib/ESPiLight/pilight/libs/pilight/config/gui.c deleted file mode 100644 index 76bbd74..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/gui.c +++ /dev/null @@ -1,641 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../core/common.h" -#include "../core/json.h" -#include "../core/config.h" -#include "../core/log.h" -#include "devices.h" -#include "gui.h" - -struct config_t *config_gui; - -static pthread_mutex_t mutex_lock; -static pthread_mutexattr_t mutex_attr; - -static struct gui_elements_t *gui_elements = NULL; - -struct gui_values_t *gui_media(char *name) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct gui_elements_t *tmp_gui = NULL; - struct gui_settings_t *tmp_settings = NULL; - struct gui_values_t *tmp_values = NULL; - tmp_gui = gui_elements; - - while(tmp_gui) { - if(strcmp(tmp_gui->id, name) == 0) { - tmp_settings = tmp_gui->settings; - while(tmp_settings) { - tmp_values = tmp_settings->values; - if(strcmp(tmp_settings->name, "media") == 0) { - return tmp_values; - } - tmp_settings = tmp_settings->next; - } - break; - } - - tmp_gui = tmp_gui->next; - } - return NULL; -} - -int gui_gc(void) { - struct gui_elements_t *dtmp; - struct gui_settings_t *stmp; - struct gui_values_t *vtmp; - - pthread_mutex_lock(&mutex_lock); - /* Free devices structure */ - while(gui_elements) { - dtmp = gui_elements; - while(dtmp->settings) { - stmp = dtmp->settings; - while(stmp->values) { - vtmp = stmp->values; - if(vtmp->type == JSON_STRING && vtmp->string_ != NULL) { - FREE(vtmp->string_); - } - if(vtmp->name) { - FREE(vtmp->name); - } - stmp->values = stmp->values->next; - FREE(vtmp); - } - if(stmp->values != NULL) { - FREE(stmp->values); - } - if(stmp->name) { - FREE(stmp->name); - } - dtmp->settings = dtmp->settings->next; - FREE(stmp); - } - if(dtmp->settings != NULL) { - FREE(dtmp->settings); - } - FREE(dtmp->id); - gui_elements = gui_elements->next; - FREE(dtmp); - } - if(gui_elements != NULL) { - FREE(gui_elements); - } - gui_elements = NULL; - pthread_mutex_unlock(&mutex_lock); - - logprintf(LOG_DEBUG, "garbage collected config gui library"); - - return EXIT_SUCCESS; -} - -struct JsonNode *gui_sync(int level, const char *media) { - /* Temporary pointer to the different structure */ - struct gui_elements_t *tmp_gui = NULL; - struct gui_settings_t *tmp_settings = NULL; - struct gui_values_t *tmp_values = NULL; - struct options_t *tmp_options = NULL; - int i = 0, match = 0; - - /* Pointers to the newly created JSON object */ - struct JsonNode *jroot = json_mkobject(); - struct JsonNode *jelements = NULL; - struct JsonNode *joptions = NULL; - struct JsonNode *jarray = NULL; - - tmp_gui = gui_elements; - - while(tmp_gui) { - i++; - jelements = json_mkobject(); - if(level == 0) { - json_append_member(jelements, "type", json_mknumber(tmp_gui->device->protocols->listener->devtype, 0)); - json_append_member(jelements, "order", json_mknumber(i, 0)); - } - - tmp_settings = tmp_gui->settings; - match = 0; - while(tmp_settings) { - tmp_values = tmp_settings->values; - if(strcmp(tmp_settings->name, "group") == 0 || strcmp(tmp_settings->name, "media") == 0) { - if(!(jarray = json_find_member(jelements, tmp_settings->name))) { - jarray = json_mkarray(); - json_append_member(jelements, tmp_settings->name, jarray); - } - while(tmp_values) { - if(tmp_values->type == JSON_NUMBER) { - json_append_element(jarray, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - if(strcmp(tmp_settings->name, "media") == 0) { - if(strcmp(tmp_values->string_, media) == 0 || - strcmp(tmp_values->string_, "all") == 0 || - strcmp(media, "all") == 0) { - match = 1; - } - } - json_append_element(jarray, json_mkstring(tmp_values->string_)); - } - tmp_values = tmp_values->next; - } - } else if(!tmp_values->next) { - if(tmp_values->type == JSON_NUMBER) { - json_append_member(jelements, tmp_settings->name, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_member(jelements, tmp_settings->name, json_mkstring(tmp_values->string_)); - } - } else { - joptions = json_mkarray(); - while(tmp_values) { - if(tmp_values->type == JSON_NUMBER) { - json_append_element(joptions, json_mknumber(tmp_values->number_, tmp_values->decimals)); - } else if(tmp_values->type == JSON_STRING) { - json_append_element(joptions, json_mkstring(tmp_values->string_)); - } - tmp_values = tmp_values->next; - } - json_append_member(jelements, tmp_settings->name, joptions); - } - tmp_settings = tmp_settings->next; - } - - if(!(jarray = json_find_member(jelements, "media"))) { - if(level == 0) { - jarray = json_mkarray(); - json_append_element(jarray, json_mkstring("all")); - json_append_member(jelements, "media", jarray); - } - match = 1; - } - - struct protocols_t *tmp_protocols = tmp_gui->device->protocols; - while(tmp_protocols) { - tmp_options = tmp_protocols->listener->options; - if(tmp_options) { - while(tmp_options) { - if(level == 0 && (tmp_options->conftype == GUI_SETTING) - && json_find_member(jelements, tmp_options->name) == NULL) { - if(tmp_options->vartype == JSON_NUMBER) { - json_append_member(jelements, tmp_options->name, json_mknumber((int)(intptr_t)tmp_options->def, 0)); - } else if(tmp_options->vartype == JSON_STRING) { - json_append_member(jelements, tmp_options->name, json_mkstring((char *)tmp_options->def)); - } - } - tmp_options = tmp_options->next; - } - } - tmp_protocols = tmp_protocols->next; - } - if(match == 0) { - json_delete(jelements); - } else { - json_append_member(jroot, tmp_gui->id, jelements); - } - tmp_gui = tmp_gui->next; - } - - return jroot; -} - -/* Save the gui settings to the element struct */ -static void gui_save_setting(int i, JsonNode *jsetting, struct gui_elements_t *element) { - /* Struct to store the values */ - struct gui_values_t *vnode = NULL; - struct gui_settings_t *snode = NULL; - struct gui_settings_t *tmp_settings = NULL; - struct gui_values_t *tmp_values = NULL; - /* Temporary JSON pointer */ - struct JsonNode *jtmp; - - /* Variable holder for casting settings */ - char *stmp = NULL; - - /* If the JSON tag is an array, then it should be a values or id array */ - if(jsetting->tag == JSON_ARRAY) { - if(strcmp(jsetting->key, "group") == 0 || strcmp(jsetting->key, "media") == 0) { - /* Loop through the values of this values array */ - jtmp = json_first_child(jsetting); - if((snode = MALLOC(sizeof(struct gui_settings_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(jsetting->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, jsetting->key); - snode->values = NULL; - snode->next = NULL; - while(jtmp) { - if((vnode = MALLOC(sizeof(struct gui_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - vnode->name = NULL; - vnode->next = NULL; - if(jtmp->tag == JSON_STRING) { - if((vnode->string_ = MALLOC(strlen(jtmp->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->string_, jtmp->string_); - vnode->type = JSON_STRING; - } else if(jtmp->tag == JSON_NUMBER) { - vnode->number_ = jtmp->number_; - vnode->decimals = jtmp->decimals_; - vnode->type = JSON_NUMBER; - } - if(jtmp->tag == JSON_NUMBER || jtmp->tag == JSON_STRING) { - tmp_values = snode->values; - if(tmp_values) { - while(tmp_values->next != NULL) { - tmp_values = tmp_values->next; - } - tmp_values->next = vnode; - } else { - vnode->next = snode->values; - snode->values = vnode; - } - } - jtmp = jtmp->next; - } - tmp_settings = element->settings; - if(tmp_settings) { - while(tmp_settings->next != NULL) { - tmp_settings = tmp_settings->next; - } - tmp_settings->next = snode; - } else { - snode->next = element->settings; - element->settings = snode; - } - } - } else if(jsetting->tag == JSON_OBJECT) { - if((snode = MALLOC(sizeof(struct gui_settings_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(jsetting->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, jsetting->key); - snode->values = NULL; - snode->next = NULL; - - jtmp = json_first_child(jsetting); - while(jtmp) { - if(jtmp->tag == JSON_STRING) { - if((vnode = MALLOC(sizeof(struct gui_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((vnode->name = MALLOC(strlen(jtmp->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->name, jtmp->key); - if((vnode->string_ = MALLOC(strlen(jtmp->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->string_, jtmp->string_); - vnode->type = JSON_STRING; - vnode->next = NULL; - } else if(jtmp->tag == JSON_NUMBER) { - if((vnode = MALLOC(sizeof(struct gui_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((vnode->name = MALLOC(strlen(jtmp->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(vnode->name, jtmp->key); - vnode->number_ = jtmp->number_; - vnode->decimals = jtmp->decimals_; - vnode->type = JSON_NUMBER; - vnode->next = NULL; - } - if(jtmp->tag == JSON_NUMBER || jtmp->tag == JSON_STRING) { - tmp_values = snode->values; - if(tmp_values) { - while(tmp_values->next != NULL) { - tmp_values = tmp_values->next; - } - tmp_values->next = vnode; - } else { - vnode->next = snode->values; - snode->values = vnode; - } - } - jtmp = jtmp->next; - } - - tmp_settings = element->settings; - if(tmp_settings) { - while(tmp_settings->next != NULL) { - tmp_settings = tmp_settings->next; - } - tmp_settings->next = snode; - } else { - snode->next = element->settings; - element->settings = snode; - } - - } else { - /* New element settings node */ - if((snode = MALLOC(sizeof(struct gui_settings_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(jsetting->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, jsetting->key); - snode->values = NULL; - snode->next = NULL; - - if((vnode = MALLOC(sizeof(struct gui_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - int valid = 0; - /* Cast and store the new value */ - if(jsetting->tag == JSON_STRING && json_find_string(jsetting->parent, jsetting->key, &stmp) == 0) { - if((vnode->string_ = MALLOC(strlen(stmp)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - vnode->name = NULL; - strcpy(vnode->string_, stmp); - vnode->type = JSON_STRING; - valid = 1; - } else if(jsetting->tag == JSON_NUMBER && - (jtmp = json_find_member(jsetting->parent, jsetting->key)) != NULL && - jtmp->tag == JSON_NUMBER) { - vnode->name = NULL; - vnode->number_ = jtmp->number_; - vnode->decimals = jtmp->decimals_; - vnode->type = JSON_NUMBER; - valid = 1; - } - if(valid) { - tmp_values = snode->values; - if(tmp_values) { - while(tmp_values->next != NULL) { - tmp_values = tmp_values->next; - } - tmp_values->next = vnode; - } else { - vnode->next = snode->values; - snode->values = vnode; - } - } - - tmp_settings = element->settings; - if(tmp_settings) { - while(tmp_settings->next != NULL) { - tmp_settings = tmp_settings->next; - } - tmp_settings->next = snode; - } else { - snode->next = element->settings; - element->settings = snode; - } - } -} - -int gui_parse_elements(struct JsonNode *root, struct gui_elements_t *parent, int i) { - struct JsonNode *jsettings = NULL; - unsigned int nrgroup = 0, nrmedia = 0, nrname = 0, nrorder = 0; - int valid_setting = 0; - int have_error = 0; - - jsettings = json_first_child(root); - while(jsettings) { - if(strcmp(jsettings->key, "group") == 0) { - nrgroup++; - } else if(strcmp(jsettings->key, "media") == 0) { - nrmedia++; - } else if(strcmp(jsettings->key, "name") == 0) { - nrname++; - } else if(strcmp(jsettings->key, "order") == 0) { - nrorder++; - } - if(nrmedia > 1 || nrgroup > 1 || nrname > 1 || nrorder > 1) { - logprintf(LOG_ERR, "config gui element #%d \"%s\" of \"%s\", duplicate", i, jsettings->key, root->key); - have_error = 1; - goto clear; - } - if(strcmp(jsettings->key, "group") == 0) { - if(jsettings->tag != JSON_ARRAY) { - logprintf(LOG_ERR, "config gui element #%d \"%s\" of \"%s\", invalid", i, jsettings->key, root->key); - have_error = 1; - goto clear; - } else { - gui_save_setting(i, jsettings, parent); - } - } else if(strcmp(jsettings->key, "name") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config gui element #%d \"%s\" of \"%s\", invalid", i, jsettings->key, root->key); - have_error = 1; - goto clear; - } else { - gui_save_setting(i, jsettings, parent); - } - } else if(strcmp(jsettings->key, "media") == 0) { - if(jsettings->tag != JSON_ARRAY) { - logprintf(LOG_ERR, "config gui element #%d \"%s\" of \"%s\", invalid", i, jsettings->key, root->key); - have_error = 1; - goto clear; - } else { - struct JsonNode *jvalues = json_first_child(jsettings); - unsigned int nrvalues = 0; - unsigned int hasall = 0; - while(jvalues) { - if(jvalues->tag == JSON_STRING) { - if(strcmp(jvalues->string_, "web") != 0 && - strcmp(jvalues->string_, "mobile") != 0 && - strcmp(jvalues->string_, "desktop") != 0 && - strcmp(jvalues->string_, "all") != 0) { - logprintf(LOG_ERR, "config gui element #%d \"media\" can only contain \"web\", \"desktop\", \"mobile\", or \"all\"", i, jsettings->key, root->key); - have_error = 1; - goto clear; - break; - } else { - nrvalues++; - } - if(strcmp(jvalues->string_, "all") == 0) { - hasall = 1; - } - } else { - logprintf(LOG_ERR, "config gui element #%d \"media\" of \"%s\", invalid", i, root->key); - have_error = 1; - goto clear; - break; - } - if(hasall == 1 && nrvalues > 1) { - logprintf(LOG_ERR, "config gui element #%d \"media\" value \"all\" cannot be combined with other values", i, jsettings->key, root->key); - have_error = 1; - goto clear; - } - jvalues = jvalues->next; - } - gui_save_setting(i, jsettings, parent); - } - } else if(!((strcmp(jsettings->key, "name") == 0 && jsettings->tag == JSON_STRING) - || (strcmp(jsettings->key, "type") == 0 && jsettings->tag == JSON_NUMBER) - || (strcmp(jsettings->key, "order") == 0 && jsettings->tag == JSON_NUMBER))) { - valid_setting = 0; - /* Check if the optional settings are valid - for the protocol(s) */ - struct protocols_t *proto = parent->device->protocols; - while(proto) { - struct options_t *options = proto->listener->options; - while(options) { - if(options->conftype == GUI_SETTING && - options->vartype == jsettings->tag && - strcmp(jsettings->key, options->name) == 0) { - valid_setting = 1; - break; - } - options = options->next; - } - proto = proto->next; - } - if(valid_setting == 1) { - gui_save_setting(i, jsettings, parent); - } else { - logprintf(LOG_ERR, "config gui element #%d \"%s\" of \"%s\", invalid", i, jsettings->key, root->key); - have_error = 1; - goto clear; - } - } - - jsettings = jsettings->next; - } - if(nrgroup == 0) { - logprintf(LOG_ERR, "config gui element #%d \"%s\", missing \"group\"", i, root->key); - have_error = 1; - goto clear; - } - if(nrname == 0) { - logprintf(LOG_ERR, "config gui element #%d \"%s\", missing \"name\"", i, root->key); - have_error = 1; - goto clear; - } - -clear: - return have_error; -} - -int gui_read(struct JsonNode *root) { - struct gui_elements_t *dnode = NULL; - struct gui_elements_t *tmp_gui = NULL; - struct JsonNode *jelements = NULL; - - int i = 0, have_error = 0; - - jelements = json_first_child(root); - while(jelements) { - i++; - if(jelements->tag != JSON_OBJECT) { - logprintf(LOG_ERR, "config gui element #%d \"%s\", invalid field(s)", i, jelements->key); - have_error = 1; - goto clear; - } else { - /* Check for duplicate fields */ - tmp_gui = gui_elements; - while(tmp_gui) { - if(strcmp(tmp_gui->id, jelements->key) == 0) { - logprintf(LOG_ERR, "config gui element #%d \"%s\", duplicate", i, jelements->key); - have_error = 1; - } - tmp_gui = tmp_gui->next; - } - - if((dnode = MALLOC(sizeof(struct gui_elements_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - dnode->settings = NULL; - dnode->next = NULL; - dnode->device = NULL; - - if(devices_get(jelements->key, &dnode->device) != 0) { - logprintf(LOG_ERR, "config gui element #%d \"%s\", device not configured", i, jelements->key); - have_error = 1; - FREE(dnode); - goto clear; - } - if((dnode->id = MALLOC(strlen(jelements->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(dnode->id, jelements->key); - - if(!have_error && gui_parse_elements(jelements, dnode, i) != 0) { - have_error = 1; - } - - tmp_gui = gui_elements; - if(tmp_gui) { - while(tmp_gui->next != NULL) { - tmp_gui = tmp_gui->next; - } - tmp_gui->next = dnode; - } else { - dnode->next = gui_elements; - gui_elements = dnode; - } - - if(have_error) { - goto clear; - } - } - jelements = jelements->next; - } -clear: - return have_error; -} - -void gui_init(void) { - pthread_mutexattr_init(&mutex_attr); - pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mutex_lock, &mutex_attr); - - /* Request hardware json object in main configuration */ - config_register(&config_gui, "gui"); - config_gui->readorder = 2; - config_gui->writeorder = 2; - config_gui->parse=&gui_read; - config_gui->sync=&gui_sync; - config_gui->gc=&gui_gc; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/config/gui.h b/lib/ESPiLight/pilight/libs/pilight/config/gui.h deleted file mode 100644 index 3b63af6..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/gui.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _GUI_H_ -#define _GUI_H_ - -#include "../core/json.h" -#include "../core/config.h" - -struct gui_values_t { - union { - char *string_; - double number_; - }; - int decimals; - char *name; - int type; - struct gui_values_t *next; -}; - -struct gui_settings_t { - char *name; - struct gui_values_t *values; - struct gui_settings_t *next; -}; - -struct gui_elements_t { - char *id; - struct devices_t *device; - struct gui_settings_t *settings; - struct gui_elements_t *next; -}; - -struct config_t *config_gui; - -struct gui_values_t *gui_media(char *name); -void gui_init(void); -int gui_gc(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/config/hardware.c b/lib/ESPiLight/pilight/libs/pilight/config/hardware.c deleted file mode 100644 index 23c7f61..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/hardware.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #include - #include - #include - #include - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif -#include -#include -#include -#include - -#include "../core/threads.h" -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/log.h" -#include "../core/json.h" -#include "../core/dso.h" -#include "settings.h" -#include "hardware.h" - - -static char *hwfile = NULL; -struct hardware_t *hardware; -struct conf_hardware_t *conf_hardware; - -#include "../hardware/hardware_header.h" - -#ifndef _WIN32 -static void hardware_remove(char *name) { - struct hardware_t *currP, *prevP; - - prevP = NULL; - - for(currP = hardware; currP != NULL; prevP = currP, currP = currP->next) { - - if(strcmp(currP->id, name) == 0) { - if(prevP == NULL) { - hardware = currP->next; - } else { - prevP->next = currP->next; - } - - logprintf(LOG_DEBUG, "removed config hardware module %s", currP->id); - FREE(currP->id); - options_delete(currP->options); - FREE(currP); - - break; - } - } -} -#endif - -void hardware_register(struct hardware_t **hw) { - if((*hw = MALLOC(sizeof(struct hardware_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - (*hw)->options = NULL; - (*hw)->wait = 0; - (*hw)->stop = 0; - (*hw)->running = 0; - (*hw)->minrawlen = 0; - (*hw)->maxrawlen = 0; - (*hw)->mingaplen = 0; - (*hw)->maxgaplen = 0; - - (*hw)->init = NULL; - (*hw)->deinit = NULL; - (*hw)->receiveOOK = NULL; - (*hw)->receivePulseTrain = NULL; - (*hw)->receiveAPI = NULL; - (*hw)->sendOOK = NULL; - (*hw)->sendAPI = NULL; - (*hw)->gc = NULL; - (*hw)->settings = NULL; - - pthread_mutexattr_init(&(*hw)->attr); - pthread_mutexattr_settype(&(*hw)->attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&(*hw)->lock, &(*hw)->attr); - pthread_cond_init(&(*hw)->signal, NULL); - - (*hw)->next = hardware; - hardware = (*hw); -} - -void hardware_set_id(hardware_t *hw, const char *id) { - if((hw->id = MALLOC(strlen(id)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(hw->id, id); -} - -static int hardware_gc(void) { - struct hardware_t *htmp = hardware; - struct conf_hardware_t *ctmp = NULL; - - while(hardware) { - htmp = hardware; - htmp->stop = 1; - pthread_mutex_unlock(&htmp->lock); - pthread_cond_signal(&htmp->signal); - while(htmp->running == 1) { - usleep(10); - } - thread_stop(htmp->id); - if(htmp->deinit != NULL) { - htmp->deinit(); - } - if(htmp->gc != NULL) { - htmp->gc(); - } - FREE(htmp->id); - options_delete(htmp->options); - hardware = hardware->next; - FREE(htmp); - } - if(hardware != NULL) { - FREE(hardware); - } - - while(conf_hardware) { - ctmp = conf_hardware; - conf_hardware = conf_hardware->next; - FREE(ctmp); - } - - if(hwfile != NULL) { - FREE(hwfile); - } - - logprintf(LOG_DEBUG, "garbage collected config hardware library"); - return EXIT_SUCCESS; -} - -static JsonNode *hardware_sync(int level, const char *display) { - struct conf_hardware_t *tmp = conf_hardware; - struct JsonNode *root = json_mkobject(); - while(tmp) { - struct JsonNode *module = json_mkobject(); - struct options_t *options = tmp->hardware->options; - while(options) { - if(options->vartype == JSON_NUMBER) { - json_append_member(module, options->name, json_mknumber(options->number_, 0)); - } else if(options->vartype == JSON_STRING) { - json_append_member(module, options->name, json_mkstring(options->string_)); - } - options = options->next; - } - json_append_member(root, tmp->hardware->id, module); - tmp = tmp->next; - } - - return root; -} - -static int hardware_parse(JsonNode *root) { - struct conf_hardware_t *hnode = NULL; - struct conf_hardware_t *tmp_confhw = NULL; - struct options_t *hw_options = NULL; - struct hardware_t *tmp_hardware = NULL; - struct hardware_t *hw = NULL; - - JsonNode *jvalues = NULL; - JsonNode *jchilds = json_first_child(root); - - int i = 0, have_error = 0, match = 0; - - while(jchilds) { - i++; - /* A hardware module can only be a JSON object */ - if(jchilds->tag != JSON_OBJECT) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\", invalid format", i, jchilds->key); - have_error = 1; - goto clear; - } else { - /* Check if defined hardware module exists */ - tmp_hardware = hardware; - match = 0; - while(tmp_hardware) { - if(strcmp(tmp_hardware->id, jchilds->key) == 0) { - hw = tmp_hardware; - match = 1; - break; - } - tmp_hardware = tmp_hardware->next; - } - if(match == 0) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\" does not exist", i, jchilds->key); - have_error = 1; - goto clear; - } - - /* Check for duplicate hardware modules */ - tmp_confhw = conf_hardware; - while(tmp_confhw) { - /* Only allow one module of the same name */ - if(strcmp(tmp_confhw->hardware->id, jchilds->key) == 0) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\", duplicate", i, jchilds->key); - have_error = 1; - goto clear; - } - /* And only allow one module covering the same frequency */ - if(tmp_confhw->hardware->hwtype == hw->hwtype) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\", duplicate freq.", i, jchilds->key); - have_error = 1; - goto clear; - } - tmp_confhw = tmp_confhw->next; - } - - /* Check if all options required by the hardware module are present */ - hw_options = hw->options; - while(hw_options) { - match = 0; - jvalues = json_first_child(jchilds); - while(jvalues) { - if(jvalues->tag == JSON_NUMBER || jvalues->tag == JSON_STRING) { - if(strcmp(jvalues->key, hw_options->name) == 0 && hw_options->argtype == OPTION_HAS_VALUE) { - match = 1; - break; - } - } - jvalues = jvalues->next; - } - if(match == 0) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\", setting \"%s\" missing", i, jchilds->key, hw_options->name); - have_error = 1; - goto clear; - } else { - /* Check if setting contains a valid value */ -#if !defined(__FreeBSD__) && !defined(_WIN32) - regex_t regex; - int reti; - char *stmp = NULL; - - if(jvalues->tag == JSON_NUMBER) { - if((stmp = REALLOC(stmp, sizeof(jvalues->number_))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - sprintf(stmp, "%d", (int)jvalues->number_); - } else if(jvalues->tag == JSON_STRING) { - if((stmp = REALLOC(stmp, strlen(jvalues->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(stmp, jvalues->string_); - } - if(hw_options->mask != NULL) { - reti = regcomp(®ex, hw_options->mask, REG_EXTENDED); - if(reti) { - logprintf(LOG_ERR, "could not compile regex"); - exit(EXIT_FAILURE); - } - reti = regexec(®ex, stmp, 0, NULL, 0); - if(reti == REG_NOMATCH || reti != 0) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\", setting \"%s\" invalid", i, jchilds->key, hw_options->name); - have_error = 1; - regfree(®ex); - goto clear; - } - regfree(®ex); - } - FREE(stmp); -#endif - } - hw_options = hw_options->next; - } - - /* Check for any settings that are not valid for this hardware module */ - jvalues = json_first_child(jchilds); - while(jvalues) { - match = 0; - if(jvalues->tag == JSON_NUMBER || jvalues->tag == JSON_STRING) { - hw_options = hw->options; - while(hw_options) { - if(strcmp(jvalues->key, hw_options->name) == 0 && jvalues->tag == hw_options->vartype) { - if(hw_options->vartype == JSON_NUMBER) { - options_set_number(&hw_options, hw_options->id, jvalues->number_); - } else if(hw_options->vartype == JSON_STRING) { - options_set_string(&hw_options, hw_options->id, jvalues->string_); - } - match = 1; - break; - } - hw_options = hw_options->next; - } - if(match == 0) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\", setting \"%s\" invalid", i, jchilds->key, jvalues->key); - have_error = 1; - goto clear; - } - } - jvalues = jvalues->next; - } - - if(hw->settings != NULL) { - /* Sync all settings with the hardware module */ - jvalues = json_first_child(jchilds); - while(jvalues) { - if(hw->settings(jvalues) == EXIT_FAILURE) { - logprintf(LOG_ERR, "config hardware module #%d \"%s\", setting \"%s\" invalid", i, jchilds->key, jvalues->key); - have_error = 1; - goto clear; - } - jvalues = jvalues->next; - } - } - - if((hnode = MALLOC(sizeof(struct conf_hardware_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - hnode->hardware = hw; - hnode->next = conf_hardware; - conf_hardware = hnode; - } - jchilds = jchilds->next; - } - - if(tmp_confhw != NULL) { - FREE(tmp_confhw); - } -clear: - return have_error; -} - -void hardware_init(void) { - /* Request hardware json object in main configuration */ - config_register(&config_hardware, "hardware"); - config_hardware->readorder = 4; - config_hardware->writeorder = 4; - config_hardware->parse=&hardware_parse; - config_hardware->sync=&hardware_sync; - config_hardware->gc=&hardware_gc; - - #include "../hardware/hardware_init.h" - -#ifndef _WIN32 - void *handle = NULL; - void (*init)(void); - void (*compatibility)(struct module_t *module); - char path[PATH_MAX]; - struct module_t module; - char pilight_version[strlen(PILIGHT_VERSION)+1]; - char pilight_commit[3]; - char *hardware_root = NULL; - int check1 = 0, check2 = 0, valid = 1, hardware_root_free = 0; - strcpy(pilight_version, PILIGHT_VERSION); - - struct dirent *file = NULL; - DIR *d = NULL; - struct stat s; - - memset(pilight_commit, '\0', 3); - - if(settings_find_string("hardware-root", &hardware_root) != 0) { - /* If no hardware root was set, use the default hardware root */ - if((hardware_root = MALLOC(strlen(HARDWARE_ROOT)+2)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(hardware_root, HARDWARE_ROOT); - hardware_root_free = 1; - } - size_t len = strlen(hardware_root); - - if(hardware_root[len-1] != '/') { - strcat(hardware_root, "/"); - } - - if((d = opendir(hardware_root))) { - while((file = readdir(d)) != NULL) { - memset(path, '\0', PATH_MAX); - sprintf(path, "%s%s", hardware_root, file->d_name); - if(stat(path, &s) == 0) { - /* Check if file */ - if(S_ISREG(s.st_mode)) { - if(strstr(file->d_name, ".so") != NULL) { - valid = 1; - - if((handle = dso_load(path)) != NULL) { - init = dso_function(handle, "init"); - compatibility = dso_function(handle, "compatibility"); - if(init != NULL && compatibility != NULL ) { - compatibility(&module); - if(module.name != NULL && module.version != NULL && module.reqversion != NULL) { - char ver[strlen(module.reqversion)+1]; - strcpy(ver, module.reqversion); - - if((check1 = vercmp(ver, pilight_version)) > 0) { - valid = 0; - } - if(check1 == 0 && module.reqcommit != NULL) { - char com[strlen(module.reqcommit)+1]; - strcpy(com, module.reqcommit); - sscanf(HASH, "v%*[0-9].%*[0-9]-%[0-9]-%*[0-9a-zA-Z\n\r]", pilight_commit); - - if(strlen(pilight_commit) > 0 && (check2 = vercmp(com, pilight_commit)) > 0) { - valid = 0; - } - } - - if(valid == 1) { - char tmp[strlen(module.name)+1]; - strcpy(tmp, module.name); - hardware_remove(tmp); - init(); - logprintf(LOG_DEBUG, "loaded config hardware module %s v%s", file->d_name, module.version); - } else { - if(module.reqcommit != NULL) { - logprintf(LOG_ERR, "config hardware module %s requires at least pilight v%s (commit %s)", file->d_name, module.reqversion, module.reqcommit); - } else { - logprintf(LOG_ERR, "config hardware module %s requires at least pilight v%s", file->d_name, module.reqversion); - } - } - } else { - logprintf(LOG_ERR, "invalid module %s", file->d_name); - } - } - } - } - } - } - } - closedir(d); - } - if(hardware_root_free) { - FREE(hardware_root); - } -#endif -} diff --git a/lib/ESPiLight/pilight/libs/pilight/config/hardware.h b/lib/ESPiLight/pilight/libs/pilight/config/hardware.h deleted file mode 100644 index 1dc2173..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/hardware.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _HARDWARE_H_ -#define _HARDWARE_H_ - -typedef enum { - HWINTERNAL = -1, - NONE = 0, - RF433, - RF868, - RFIR, - ZWAVE, - SENSOR, - HWRELAY, - API -} hwtype_t; - -typedef enum { - COMNONE = 0, - COMOOK, - COMPLSTRAIN, - COMAPI -} communication_t; - -#include -#include "../core/options.h" -#include "../core/json.h" -#include "../core/config.h" -#include "defines.h" - -struct config_t *config_hardware; - -typedef struct rawcode_t { - int pulses[MAXPULSESTREAMLENGTH]; - int length; -} rawcode_t; - -typedef struct hardware_t { - char *id; - unsigned short wait; - unsigned short stop; - pthread_mutex_t lock; - pthread_cond_t signal; - pthread_mutexattr_t attr; - unsigned short running; - hwtype_t hwtype; - communication_t comtype; - struct options_t *options; - - int minrawlen; - int maxrawlen; - int mingaplen; - int maxgaplen; - - unsigned short (*init)(void); - unsigned short (*deinit)(void); - union { - int (*receiveOOK)(void); - void *(*receiveAPI)(void *param); - int (*receivePulseTrain)(struct rawcode_t *r); - }; - union { - int (*sendOOK)(int *code, int rawlen, int repeats); - int (*sendAPI)(struct JsonNode *code); - }; - int (*gc)(void); - unsigned short (*settings)(JsonNode *json); - struct hardware_t *next; -} hardware_t; - -typedef struct conf_hardware_t { - hardware_t *hardware; - struct conf_hardware_t *next; -} conf_hardware_t; - -extern struct hardware_t *hardware; -extern struct conf_hardware_t *conf_hardware; - -void hardware_init(void); -void hardware_register(struct hardware_t **hw); -void hardware_set_id(struct hardware_t *hw, const char *id); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/config/registry.c b/lib/ESPiLight/pilight/libs/pilight/config/registry.c deleted file mode 100644 index b963e7f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/registry.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/json.h" -#include "../core/log.h" -#include "registry.h" - -struct JsonNode *registry = NULL; - -static pthread_mutex_t mutex_lock; -static pthread_mutexattr_t mutex_attr; - -static int registry_get_value_recursive(struct JsonNode *root, const char *key, void **value, void **decimals, int type) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char *sub = strstr(key, "."); - char *buff = MALLOC(strlen(key)+1); - strcpy(buff, key); - if(sub != NULL) { - int pos = sub-key; - buff[pos] = '\0'; - } - struct JsonNode *member = json_find_member(root, buff); - if(member != NULL) { - if(member->tag == type) { - if(type == JSON_NUMBER) { - *value = (void *)&member->number_; - *decimals = (void *)&member->decimals_; - } else if(type == JSON_STRING) { - *value = (void *)member->string_; - } - FREE(buff); - return 0; - } else if(member->tag == JSON_OBJECT) { - if(sub != NULL) { - int pos = sub-key; - strcpy(buff, &key[pos+1]); - } - int ret = registry_get_value_recursive(member, buff, value, decimals, type); - FREE(buff); - return ret; - } - } - FREE(buff); - return -1; -} - -static int registry_set_value_recursive(struct JsonNode *root, const char *key, void *value, int decimals, int type) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char *sub = strstr(key, "."); - char *buff = MALLOC(strlen(key)+1); - strcpy(buff, key); - if(sub != NULL) { - int pos = sub-key; - buff[pos] = '\0'; - } - struct JsonNode *member = json_find_member(root, buff); - if(member != NULL) { - if(member->tag == type) { - if(type == JSON_NUMBER) { - member->number_ = *(double *)value; - member->decimals_ = decimals; - } else if(type == JSON_STRING) { - member->string_ = REALLOC(member->string_, strlen(value)+1); - strcpy(member->string_, (char *)value); - } - FREE(buff); - return 0; - } else if(member->tag == JSON_OBJECT) { - if(sub != NULL) { - int pos = sub-key; - strcpy(buff, &key[pos+1]); - } - int ret = registry_set_value_recursive(member, buff, value, decimals, type); - FREE(buff); - return ret; - } - } else if(sub != NULL) { - member = json_mkobject(); - json_append_member(root, buff, member); - int pos = sub-key; - strcpy(buff, &key[pos+1]); - int ret = registry_set_value_recursive(member, buff, value, decimals, type); - FREE(buff); - return ret; - } else { - if(type == JSON_NUMBER) { - json_append_member(root, buff, json_mknumber(*(double *)value, decimals)); - } else if(type == JSON_STRING) { - json_append_member(root, buff, json_mkstring(value)); - } - FREE(buff); - return 0; - } - FREE(buff); - return -1; -} - -static void registry_remove_empty_parent(struct JsonNode *root) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct JsonNode *parent = root->parent; - if(json_first_child(root) == NULL) { - if(parent != NULL) { - json_remove_from_parent(root); - registry_remove_empty_parent(parent); - json_delete(root); - } - } -} - -static int registry_remove_value_recursive(struct JsonNode *root, const char *key) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char *sub = strstr(key, "."); - char *buff = MALLOC(strlen(key)+1); - strcpy(buff, key); - if(sub != NULL) { - int pos = sub-key; - buff[pos] = '\0'; - } - struct JsonNode *member = json_find_member(root, buff); - if(member != NULL) { - if(sub == NULL) { - json_remove_from_parent(member); - json_delete(member); - registry_remove_empty_parent(root); - FREE(buff); - return 0; - } - if(member->tag == JSON_OBJECT) { - if(sub != NULL) { - int pos = sub-key; - strcpy(buff, &key[pos+1]); - } - int ret = registry_remove_value_recursive(member, buff); - FREE(buff); - return ret; - } - } - FREE(buff); - return -1; -} - -int registry_get_string(const char *key, char **value) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(registry == NULL) { - return -1; - } - return registry_get_value_recursive(registry, key, (void *)value, NULL, JSON_STRING); -} - -int registry_get_number(const char *key, double *value, int *decimals) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(registry == NULL) { - return -1; - } - void *p = NULL; - void *q = NULL; - int ret = registry_get_value_recursive(registry, key, &p, &q, JSON_NUMBER); - if(ret == 0) { - *value = *(double *)p; - *decimals = *(int *)q; - } - return ret; -} - -int registry_set_string(const char *key, char *value) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(registry == NULL) { - registry = json_mkobject(); - } - return registry_set_value_recursive(registry, key, (void *)value, 0, JSON_STRING); -} - -int registry_set_number(const char *key, double value, int decimals) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(registry == NULL) { - registry = json_mkobject(); - } - void *p = (void *)&value; - return registry_set_value_recursive(registry, key, p, decimals, JSON_NUMBER); -} - -int registry_remove_value(const char *key) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(registry == NULL) { - return -1; - } - return registry_remove_value_recursive(registry, key); -} - -static int registry_parse(JsonNode *root) { - if(root->tag == JSON_OBJECT) { - char *content = json_stringify(root, NULL); - registry = json_decode(content); - json_free(content); - } else { - logprintf(LOG_ERR, "config registry should be of an object type"); - return -1; - } - return 0; -} - -static JsonNode *registry_sync(int level, const char *display) { - if(registry != NULL) { - char *content = json_stringify(registry, NULL); - struct JsonNode *jret = json_decode(content); - json_free(content); - return jret; - } else { - return NULL; - } -} - -int registry_gc(void) { - pthread_mutex_lock(&mutex_lock); - if(registry != NULL) { - json_delete(registry); - } - registry = NULL; - pthread_mutex_unlock(&mutex_lock); - - logprintf(LOG_DEBUG, "garbage collected config registry library"); - return 1; -} - -void registry_init(void) { - pthread_mutexattr_init(&mutex_attr); - pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mutex_lock, &mutex_attr); - - /* Request settings json object in main configuration */ - config_register(&config_registry, "registry"); - config_registry->readorder = 5; - config_registry->writeorder = 5; - config_registry->parse=®istry_parse; - config_registry->sync=®istry_sync; - config_registry->gc=®istry_gc; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/config/registry.h b/lib/ESPiLight/pilight/libs/pilight/config/registry.h deleted file mode 100644 index a556645..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/registry.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _REGISTRY_H_ -#define _REGISTRY_H_ - -#include "../core/json.h" -#include "../core/config.h" - -struct config_t *config_registry; - -void registry_init(void); -int registry_gc(void); -int registry_get_string(const char *key, char **value); -int registry_get_number(const char *key, double *value, int *decimals); -int registry_set_string(const char *key, char *value); -int registry_set_number(const char *key, double value, int decimals); -int registry_remove_value(const char *key); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/config/rules.c b/lib/ESPiLight/pilight/libs/pilight/config/rules.c deleted file mode 100644 index 46d2834..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/rules.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/json.h" -#include "../core/log.h" -#include "../events/events.h" -#include "../events/operator.h" -#include "../events/action.h" -#include "../events/function.h" -#include "rules.h" -#include "gui.h" - -static struct rules_t *rules = NULL; - -static pthread_mutex_t mutex_lock; -static pthread_mutexattr_t mutex_attr; - -static int rules_parse(JsonNode *root) { - int have_error = 0, match = 0, x = 0; - unsigned int i = 0; - struct JsonNode *jrules = NULL; - char *rule = NULL; - double active = 1.0; - - event_function_init(); - event_operator_init(); - - if(root->tag == JSON_OBJECT) { - jrules = json_first_child(root); - while(jrules) { - i++; - if(jrules->tag == JSON_OBJECT) { - if(json_find_string(jrules, "rule", &rule) != 0) { - logprintf(LOG_ERR, "config rule #%d \"%s\", missing \"rule\"", i, jrules->key); - have_error = 1; - break; - } else { - active = 1.0; - json_find_number(jrules, "active", &active); - - struct rules_t *tmp = rules; - match = 0; - while(tmp) { - if(strcmp(tmp->name, jrules->key) == 0) { - match = 1; - break; - } - tmp = tmp->next; - } - if(match == 1) { - logprintf(LOG_ERR, "config rule #%d \"%s\" already exists", i, jrules->key); - have_error = 1; - break; - } - for(x=0;xkey);x++) { - if(!isalnum(jrules->key[x]) && jrules->key[x] != '-' && jrules->key[x] != '_') { - logprintf(LOG_ERR, "config rule #%d \"%s\", not alphanumeric", i, jrules->key); - have_error = 1; - break; - } - } - - struct rules_t *node = MALLOC(sizeof(struct rules_t)); - if(node == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - node->next = NULL; - node->values = NULL; - node->jtrigger = NULL; - node->nrdevices = 0; - node->status = 0; - node->devices = NULL; - node->actions = NULL; - node->nr = i; - if((node->name = MALLOC(strlen(jrules->key)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(node->name, jrules->key); -#ifndef WIN32 - clock_gettime(CLOCK_MONOTONIC, &node->timestamp.first); -#endif - if(event_parse_rule(rule, node, 0, 1) == -1) { - have_error = 1; - } -#ifndef WIN32 - clock_gettime(CLOCK_MONOTONIC, &node->timestamp.second); - logprintf(LOG_INFO, "rule #%d %s was parsed in %.6f seconds", node->nr, node->name, - ((double)node->timestamp.second.tv_sec + 1.0e-9*node->timestamp.second.tv_nsec) - - ((double)node->timestamp.first.tv_sec + 1.0e-9*node->timestamp.first.tv_nsec)); -#endif - node->status = 0; - if((node->rule = MALLOC(strlen(rule)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(node->rule, rule); - node->active = (unsigned short)active; - - tmp = rules; - if(tmp) { - while(tmp->next != NULL) { - tmp = tmp->next; - } - tmp->next = node; - } else { - node->next = rules; - rules = node; - } - /* - * In case of an error, we do want to - * save a pointer to our faulty rule - * so it can be properly garbage collected. - */ - if(have_error == 1) { - break; - } - } - } - jrules = jrules->next; - } - } else { - logprintf(LOG_ERR, "config rules should be placed in an object"); - have_error = 1; - } - - return have_error; -} - -static JsonNode *rules_sync(int level, const char *media) { - struct JsonNode *root = json_mkobject(); - struct JsonNode *rule = NULL; - struct rules_t *tmp = NULL; - struct gui_values_t *gui_values = NULL; - int match = 0, i = 0; - - tmp = rules; - - while(tmp) { - match = 0; - for(i=0;inrdevices;i++) { - if((gui_values = gui_media(tmp->devices[i])) != NULL) { - while(gui_values) { - if(gui_values->type == JSON_STRING) { - if(strcmp(gui_values->string_, media) == 0 || - strcmp(gui_values->string_, "all") == 0 || - strcmp(media, "all") == 0) { - match++; - } - } - gui_values = gui_values->next; - } - } - } - if(strcmp(media, "all") == 0) { - match = tmp->nrdevices; - } - if(match == tmp->nrdevices) { - rule = json_mkobject(); - json_append_member(rule, "rule", json_mkstring(tmp->rule)); - json_append_member(rule, "active", json_mknumber((double)tmp->active, 0)); - json_append_member(root, tmp->name, rule); - } - tmp = tmp->next; - } - return root; -} - -struct rules_t *rules_get(void) { - return rules; -} - -int rules_gc(void) { - struct rules_t *tmp_rules = NULL; - struct rules_values_t *tmp_values = NULL; - struct rules_actions_t *tmp_actions = NULL; - int i = 0; - - pthread_mutex_lock(&mutex_lock); - while(rules) { - tmp_rules = rules; - FREE(tmp_rules->name); - FREE(tmp_rules->rule); - events_tree_gc(tmp_rules->tree); - for(i=0;inrdevices;i++) { - FREE(tmp_rules->devices[i]); - } - while(tmp_rules->values) { - tmp_values = tmp_rules->values; - FREE(tmp_values->name); - FREE(tmp_values->device); - tmp_rules->values = tmp_rules->values->next; - FREE(tmp_values); - } - if(tmp_rules->values != NULL) { - FREE(tmp_rules->values); - } - while(tmp_rules->actions) { - tmp_actions = tmp_rules->actions; - if(tmp_actions->arguments != NULL) { - json_delete(tmp_actions->arguments); - } - tmp_rules->actions = tmp_rules->actions->next; - if(tmp_actions != NULL) { - FREE(tmp_actions); - } - } - if(tmp_rules->actions != NULL) { - FREE(tmp_rules->actions); - } - if(tmp_rules->jtrigger != NULL) { - json_delete(tmp_rules->jtrigger); - } - if(tmp_rules->devices != NULL) { - FREE(tmp_rules->devices); - } - rules = rules->next; - FREE(tmp_rules); - } - if(rules != NULL) { - FREE(rules); - } - rules = NULL; - pthread_mutex_unlock(&mutex_lock); - - logprintf(LOG_DEBUG, "garbage collected config rules library"); - return 1; -} - -void rules_init(void) { - event_action_init(); - - pthread_mutexattr_init(&mutex_attr); - pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mutex_lock, &mutex_attr); - - /* Request rules json object in main configuration */ - config_register(&config_rules, "rules"); - config_rules->readorder = 2; - config_rules->writeorder = 1; - config_rules->parse=&rules_parse; - config_rules->sync=&rules_sync; - config_rules->gc=&rules_gc; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/config/rules.h b/lib/ESPiLight/pilight/libs/pilight/config/rules.h deleted file mode 100644 index 01445b0..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/rules.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _RULES_H_ -#define _RULES_H_ - -#include "../core/json.h" -#include "../core/config.h" -#include "../events/action.h" -#include "../datatypes/stack.h" - -typedef struct rules_values_t { - char *device; - char *name; - struct devices_settings_t *settings; - struct rules_values_t *next; -} rules_values_t; - -typedef struct rules_actions_t { - void *ptr; - struct rules_t *rule; - struct JsonNode *arguments; - struct JsonNode *parsedargs; - struct event_actions_t *action; - struct rules_actions_t *next; -} rules_actions_t; - -typedef struct rules_t { - char *rule; - char *name; - char **devices; - int nrdevices; - int nr; - int status; - struct { - struct timespec first; - struct timespec second; - } timestamp; - unsigned short active; - struct JsonNode *jtrigger; - /* Arguments to be send to the action */ - struct rules_actions_t *actions; - struct rules_values_t *values; - struct tree_t *tree; - struct rules_t *next; -} rules_t; - -struct config_t *config_rules; - -void rules_init(void); -int rules_gc(void); -struct rules_t *rules_get(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/config/settings.c b/lib/ESPiLight/pilight/libs/pilight/config/settings.c deleted file mode 100644 index c3192d0..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/settings.c +++ /dev/null @@ -1,646 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 - #include - #include -#endif -#include -#include -#include - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/json.h" -#include "../core/log.h" - -#include "settings.h" - -typedef struct settings_t { - char *name; - int type; - union { - char *string_; - int number_; - }; - struct settings_t *next; -} settings_t; - -struct config_t *config_settings; - -static struct settings_t *settings = NULL; - -/* Add a string value to the settings struct */ -static void settings_add_string(const char *name, char *value) { - struct settings_t *snode = MALLOC(sizeof(struct settings_t)); - struct settings_t *tmp = NULL; - if(snode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, name); - if((snode->string_ = MALLOC(strlen(value)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->string_, value); - snode->type = JSON_STRING; - snode->next = NULL; - - tmp = settings; - if(tmp) { - while(tmp->next != NULL) { - tmp = tmp->next; - } - tmp->next = snode; - } else { - snode->next = settings; - settings = snode; - } -} - -/* Add an int value to the settings struct */ -static void settings_add_number(const char *name, int value) { - struct settings_t *tmp = NULL; - struct settings_t *snode = MALLOC(sizeof(struct settings_t)); - if(snode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((snode->name = MALLOC(strlen(name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(snode->name, name); - snode->number_ = value; - snode->type = JSON_NUMBER; - snode->next = NULL; - - tmp = settings; - if(tmp) { - while(tmp->next != NULL) { - tmp = tmp->next; - } - tmp->next = snode; - } else { - snode->next = settings; - settings = snode; - } -} - -/* Retrieve a numeric value from the settings struct */ -int settings_find_number(const char *name, int *out) { - struct settings_t *tmp_settings = settings; - - while(tmp_settings) { - if(strcmp(tmp_settings->name, name) == 0 && tmp_settings->type == JSON_NUMBER) { - *out = tmp_settings->number_; - return EXIT_SUCCESS; - } - tmp_settings = tmp_settings->next; - } - if(tmp_settings != NULL) { - FREE(tmp_settings); - } - - return EXIT_FAILURE; -} - -/* Retrieve a string value from the settings struct */ -int settings_find_string(const char *name, char **out) { - struct settings_t *tmp_settings = settings; - - while(tmp_settings) { - if(strcmp(tmp_settings->name, name) == 0 && tmp_settings->type == JSON_STRING) { - *out = tmp_settings->string_; - return EXIT_SUCCESS; - } - tmp_settings = tmp_settings->next; - } - if(tmp_settings != NULL) { - FREE(tmp_settings); - } - - return EXIT_FAILURE; -} - -static int settings_parse(JsonNode *root) { - int have_error = 0; - -#ifdef WEBSERVER - int web_port = WEBSERVER_HTTP_PORT; -#ifdef WEBSERVER_HTTPS - int web_ssl_port = WEBSERVER_HTTPS_PORT; -#endif - int own_port = -1; - - char *webgui_root = MALLOC(strlen(WEBSERVER_ROOT)+1); - if(webgui_root == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(webgui_root, WEBSERVER_ROOT); -#endif - -#if !defined(__FreeBSD__) && !defined(_WIN32) - regex_t regex; - int reti; -#endif - - struct JsonNode *jsettings = json_first_child(root); - - while(jsettings) { - if(strcmp(jsettings->key, "port") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number larger than 0", jsettings->key); - have_error = 1; - goto clear; - } else if((int)jsettings->number_ == 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number larger than 0", jsettings->key); - have_error = 1; - goto clear; - } else { -#ifdef WEBSERVER - if(strcmp(jsettings->key, "port") == 0) { - own_port = (int)jsettings->number_; - } -#endif - settings_add_number(jsettings->key, (int)jsettings->number_); - } - } else if(strcmp(jsettings->key, "firmware-gpio-reset") == 0 - || strcmp(jsettings->key, "firmware-gpio-sck") == 0 - || strcmp(jsettings->key, "firmware-gpio-mosi") == 0 - || strcmp(jsettings->key, "firmware-gpio-miso") == 0) { -#if !defined(__arm__) || !defined(__mips__) - return -1; -#endif - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number larger than 0", jsettings->key); - return -1; - } -#ifndef _WIN32 - else if(wiringXValidGPIO((int)jsettings->number_) != 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a valid GPIO number", jsettings->key); - return -1; - } -#endif - } else if(strcmp(jsettings->key, "gpio-platform") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a supported gpio platform", jsettings->key); - return -1; - } else if(jsettings->string_ == NULL) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a supported gpio platform", jsettings->key); - return -1; - } else { - if(strcmp(jsettings->string_, "none") != 0) { -#ifndef _WIN32 - if(wiringXSetup(jsettings->string_, logprintf1) != 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a supported gpio platform", jsettings->key); - return -1; - } -#endif - } - settings_add_string(jsettings->key, jsettings->string_); - } - } else if(strcmp(jsettings->key, "standalone") == 0 || - strcmp(jsettings->key, "watchdog-enable") == 0 || - strcmp(jsettings->key, "stats-enable") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->number_ < 0 || jsettings->number_ > 1) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_number(jsettings->key, (int)jsettings->number_); - } - } else if(strcmp(jsettings->key, "log-level") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number from 0 till 6", jsettings->key); - have_error = 1; - goto clear; - } else if((int)jsettings->number_ < 0 || (int)jsettings->number_ > 6) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number from 0 till 6", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_number(jsettings->key, (int)jsettings->number_); - } - } else if(strcmp(jsettings->key, "log-file") == 0 -#ifndef _WIN32 - || strcmp(jsettings->key, "pid-file") == 0 -#endif - || strcmp(jsettings->key, "pem-file") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an existing file", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->string_ == NULL) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an existing file", jsettings->key); - have_error = 1; - goto clear; - } else { - if(path_exists(jsettings->string_) != EXIT_SUCCESS) { - logprintf(LOG_ERR, "config setting \"%s\" must point to an existing folder", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_string(jsettings->key, jsettings->string_); - } - } - } else if(strcmp(jsettings->key, "whitelist") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a valid ip address", jsettings->key); - have_error = 1; - goto clear; - } else if(!jsettings->string_) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a valid ip addresses", jsettings->key); - have_error = 1; - goto clear; - } else if(strlen(jsettings->string_) > 0) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - char validate[] = "^((\\*|[0-9]|[1-9][0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\\.(\\*|[0-9]|[1-9][0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\\.(\\*|[0-9]|[1-9][0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\\.(\\*|[0-9]|[1-9][0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))(,[\\ ]|,|$))+$"; - reti = regcomp(®ex, validate, REG_EXTENDED); - if(reti) { - logprintf(LOG_ERR, "could not compile regex"); - have_error = 1; - goto clear; - } - reti = regexec(®ex, jsettings->string_, 0, NULL, 0); - if(reti == REG_NOMATCH || reti != 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain valid ip addresses", jsettings->key); - have_error = 1; - regfree(®ex); - goto clear; - } - regfree(®ex); -#endif - int l = (int)strlen(jsettings->string_)-1; - if(jsettings->string_[l] == ' ' || jsettings->string_[l] == ',') { - logprintf(LOG_ERR, "config setting \"%s\" must contain valid ip addresses", jsettings->key); - have_error = 1; - goto clear; - } - settings_add_string(jsettings->key, jsettings->string_); - } -#ifdef WEBSERVER - -#ifdef WEBSERVER_HTTPS - } else if(strcmp(jsettings->key, "webserver-https-port") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number larget than 0", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->number_ < 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number larger than 0", jsettings->key); - have_error = 1; - goto clear; - } else { - web_ssl_port = (int)jsettings->number_; - settings_add_number(jsettings->key, (int)jsettings->number_); - } -#endif - } else if(strcmp(jsettings->key, "webserver-http-port") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number larget than 0", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->number_ < 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a number larger than 0", jsettings->key); - have_error = 1; - goto clear; - } else { - web_port = (int)jsettings->number_; - settings_add_number(jsettings->key, (int)jsettings->number_); - } - } else if(strcmp(jsettings->key, "webserver-root") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a valid path", jsettings->key); - have_error = 1; - goto clear; - } else if(!jsettings->string_ || path_exists(jsettings->string_) != 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a valid path", jsettings->key); - have_error = 1; - goto clear; - } else { - if((webgui_root = REALLOC(webgui_root, strlen(jsettings->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(webgui_root, jsettings->string_); - settings_add_string(jsettings->key, jsettings->string_); - } - } else if(strcmp(jsettings->key, "webserver-enable") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->number_ < 0 || jsettings->number_ > 1) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_number(jsettings->key, (int)jsettings->number_); - } - } else if(strcmp(jsettings->key, "webserver-cache") == 0 || - strcmp(jsettings->key, "webgui-websockets") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->number_ < 0 || jsettings->number_ > 1) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_number(jsettings->key, (int)jsettings->number_); - } - } else if(strcmp(jsettings->key, "webserver-authentication") == 0 && jsettings->tag == JSON_ARRAY) { - JsonNode *jtmp = json_first_child(jsettings); - unsigned short i = 0; - while(jtmp) { - i++; - if(jtmp->tag == JSON_STRING) { - if(i == 1) { - settings_add_string("webserver-authentication-username", jtmp->string_); - } else if(i == 2) { - settings_add_string("webserver-authentication-password", jtmp->string_); - } - } else { - have_error = 1; - break; - } - if(i > 2) { - have_error = 1; - break; - } - jtmp = jtmp->next; - } - if(i != 2 || have_error == 1) { - logprintf(LOG_ERR, "config setting \"%s\" must be in the format of [ \"username\", \"password\" ]", jsettings->key); - have_error = 1; - goto clear; - } -#endif // WEBSERVER - } else if(strcmp(jsettings->key, "ntp-servers") == 0 && jsettings->tag == JSON_ARRAY) { - JsonNode *jtmp = json_first_child(jsettings); - unsigned short i = 0; - char name[25]; - while(jtmp) { - if(jtmp->tag == JSON_STRING) { - sprintf(name, "ntpserver%d", i); - settings_add_string(name, jtmp->string_); - } else { - have_error = 1; - break; - } - jtmp = jtmp->next; - i++; - } - if(have_error == 1) { - logprintf(LOG_ERR, "config setting \"%s\" must be in the format of [ \"0.eu.pool.ntp.org\", ... ]", jsettings->key); - have_error = 1; - goto clear; - } - } else if(strcmp(jsettings->key, "protocol-root") == 0 || - strcmp(jsettings->key, "hardware-root") == 0 || - strcmp(jsettings->key, "actions-root") == 0 || - strcmp(jsettings->key, "functions-root") == 0 || - strcmp(jsettings->key, "operators-root") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a valid path", jsettings->key); - have_error = 1; - goto clear; - } else if(!jsettings->string_ || path_exists(jsettings->string_) != 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a valid path", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_string(jsettings->key, jsettings->string_); - } -#ifdef EVENTS - } else if(strcmp(jsettings->key, "smtp-sender") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an e-mail address", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->string_ == NULL) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an e-mail address", jsettings->key); - have_error = 1; - goto clear; - } else if(strlen(jsettings->string_) > 0 && check_email_addr(jsettings->string_, 0, 0) < 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an e-mail address", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_string(jsettings->key, jsettings->string_); - } - } else if(strcmp(jsettings->key, "smtp-ssl") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->number_ < 0 || jsettings->number_ > 1) { - logprintf(LOG_ERR, "config setting \"%s\" must be either 0 or 1", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_number(jsettings->key, (int)jsettings->number_); - } - } else if(strcmp(jsettings->key, "smtp-user") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a user id", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->string_ == NULL) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a user id", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_string(jsettings->key, jsettings->string_); - } - } else if(strcmp(jsettings->key, "smtp-password") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a password string", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->string_ == NULL) { - logprintf(LOG_ERR, "config setting \"%s\" must contain a password string", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_string(jsettings->key, jsettings->string_); - } - } else if(strcmp(jsettings->key, "smtp-host") == 0) { - if(jsettings->tag != JSON_STRING) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an smtp host address", jsettings->key); - have_error = 1; - goto clear; - } else if(jsettings->string_ == NULL) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an smtp host address", jsettings->key); - have_error = 1; - goto clear; - } else if(strlen(jsettings->string_) > 0) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - char validate[] = "^([a-zA-Z0-9\\_\\-]){2,20}(\\.([a-zA-Z0-9\\_\\-]){2,20}){2,3}$"; - reti = regcomp(®ex, validate, REG_EXTENDED); - if(reti) { - logprintf(LOG_ERR, "could not compile regex for %s", jsettings->key); - have_error = 1; - goto clear; - } - reti = regexec(®ex, jsettings->string_, 0, NULL, 0); - if(reti == REG_NOMATCH || reti != 0) { - logprintf(LOG_ERR, "config setting \"%s\" must contain an smtp host address", jsettings->key); - have_error = 1; - regfree(®ex); - goto clear; - } - regfree(®ex); -#endif - settings_add_string(jsettings->key, jsettings->string_); - } - } else if(strcmp(jsettings->key, "smtp-port") == 0) { - if(jsettings->tag != JSON_NUMBER) { - logprintf(LOG_ERR, "config setting \"%s\" must be 25, 465 or 587", jsettings->key); - have_error = 1; - goto clear; - } else if((int)jsettings->number_ != 25 && (int)jsettings->number_ != 465 && (int)jsettings->number_ != 587) { - logprintf(LOG_ERR, "config setting \"%s\" must be 25, 465 or 587", jsettings->key); - have_error = 1; - goto clear; - } else { - settings_add_number(jsettings->key, (int)jsettings->number_); - } -#endif //EVENTS - } else { - logprintf(LOG_ERR, "config setting \"%s\" is invalid", jsettings->key); - have_error = 1; - goto clear; - } - jsettings = jsettings->next; - } - -#ifdef WEBSERVER - if(web_port == own_port) { - logprintf(LOG_ERR, "config setting \"port\" and \"webserver-http-port\" cannot be the same"); - have_error = 1; - goto clear; - } -#ifdef WEBSERVER_HTTPS - if(web_ssl_port == own_port) { - logprintf(LOG_ERR, "config setting \"port\" and \"webserver-https-port\" cannot be the same"); - have_error = 1; - goto clear; - } -#endif - -#endif -clear: -#ifdef WEBSERVER - if(webgui_root != NULL) { - FREE(webgui_root); - } -#endif - return have_error; -} - -static JsonNode *settings_sync(int level, const char *display) { - struct JsonNode *root = json_mkobject(); - struct JsonNode *ntpservers = NULL; - struct settings_t *tmp = settings; - char *username = NULL, *password = NULL; - - while(tmp) { - if(strncmp(tmp->name, "ntpserver", 9) == 0 && tmp->type == JSON_STRING) { - if(ntpservers == NULL) { - ntpservers = json_mkarray(); - } - json_append_element(ntpservers, json_mkstring(tmp->string_)); - } else { - if(json_find_member(root, "ntp-servers") == NULL && ntpservers != NULL) { - json_append_member(root, "ntp-servers", ntpservers); - } - if(strcmp(tmp->name, "webserver-authentication-username") == 0 && tmp->type == JSON_STRING) { - username = tmp->string_; - } else if(strcmp(tmp->name, "webserver-authentication-password") == 0 && tmp->type == JSON_STRING) { - password = tmp->string_; - } else if(tmp->type == JSON_NUMBER) { - json_append_member(root, tmp->name, json_mknumber((double)tmp->number_, 0)); - } else if(tmp->type == JSON_STRING) { - json_append_member(root, tmp->name, json_mkstring(tmp->string_)); - } - } - if(username != NULL && password != NULL && json_find_member(root, "webserver-authentication") == NULL) { - struct JsonNode *jarray = json_mkarray(); - json_append_element(jarray, json_mkstring(username)); - json_append_element(jarray, json_mkstring(password)); - json_append_member(root, "webserver-authentication", jarray); - } - tmp = tmp->next; - } - if(json_find_member(root, "ntp-servers") == NULL && ntpservers != NULL) { - json_append_member(root, "ntp-servers", ntpservers); - } - - return root; -} - -static int settings_gc(void) { - struct settings_t *tmp; - - while(settings) { - tmp = settings; - FREE(tmp->name); - if(tmp->type == JSON_STRING) { - FREE(tmp->string_); - } - settings = settings->next; - FREE(tmp); - } - if(settings != NULL) { - FREE(settings); - } - - - logprintf(LOG_DEBUG, "garbage collected config settings library"); - return 1; -} - -void settings_init(void) { - /* Request settings json object in main configuration */ - config_register(&config_settings, "settings"); - config_settings->readorder = 0; - config_settings->writeorder = 3; - config_settings->parse=&settings_parse; - config_settings->sync=&settings_sync; - config_settings->gc=&settings_gc; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/config/settings.h b/lib/ESPiLight/pilight/libs/pilight/config/settings.h deleted file mode 100644 index 2471414..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/config/settings.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _SETTINGS_H_ -#define _SETTINGS_H_ - -#include "../core/json.h" -#include "../core/config.h" - -struct config_t *config_settings; - -int settings_find_number(const char *name, int *out); -int settings_find_string(const char *name, char **out); -void settings_init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/core/CMakeExclude.txt deleted file mode 100644 index 5098855..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/CMakeExclude.txt +++ /dev/null @@ -1,18 +0,0 @@ -include(../../../CMakeConfig.txt) - -if(NOT WIN32) - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/strptime.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/strptime.h") -endif() - -if(${PROTOCOL_ARPING} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arp.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arp.h") -endif() - -if(${WEBSERVER} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/webserver.h") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/mongoose.h") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/webserver.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/mongoose.c") -endif() \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/core/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/core/CMakeLists.txt deleted file mode 100644 index a6148ce..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -project(pilight_core) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeExclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/core/arp.c b/lib/ESPiLight/pilight/libs/pilight/core/arp.c deleted file mode 100644 index f0ca84a..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/arp.c +++ /dev/null @@ -1,581 +0,0 @@ -/* - * The ARP Scanner (arp-scan) is Copyright (C) 2005-2013 Roy Hills, - * NTA Monitor Ltd. - * - * This file is part of arp-scan. - * - * arp-scan 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 3 of the License, or - * (at your option) any later version. - * - * arp-scan 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 arp-scan. If not, see . - * - * arp-scan -- The ARP Scanner - * - * Author: Roy Hills - * Date: 13 October 2005 - * - * Usage: - * arp-scan [options] [host...] - * - * Description: - * - * arp-scan sends the specified ARP packet to the specified hosts - * and displays any responses received. - * - * The ARP protocol is defined in RFC 826 Ethernet Address Resolution Protocol - * - * arp-scan was stripped and adapter by CurlyMo 2014 for pilight. - * - */ - -#include -#include -#include -#include -#include -#ifdef _WIN32 - #define WPCAP - #define WIN32_LEAN_AND_MEAN - #include - #include - #include - #include - #include - #include - #define MSG_NOSIGNAL 0 -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include - #ifdef __FREEBSD__ - #include - #include - #else - #include - #endif - #include - #include -#endif -#include - -#include -#include -#include -#include -#include - -#include "network.h" -#include "mem.h" -#include "log.h" -#include "arp.h" - -#define MAXLINE 255 -#define MAX_FRAME 2048 -#define PACKET_OVERHEAD 18 -#define MINIMUM_FRAME_SIZE 46 -#define ETHER_HDR_SIZE 14 -#define ARP_PKT_SIZE 28 -#define FRAMING_ETHERNET_II 0 -#define FRAMING_LLC_SNAP 1 - -typedef struct host_entry { - double timeout; - struct in_addr addr; - struct timeval last_send_time; - unsigned short num_sent; - unsigned short num_recv; - unsigned short found; - unsigned char live; - uint8_t mac[ETH_ALEN]; -} host_entry; - -typedef struct ether_hdr { - uint8_t dest_addr[ETH_ALEN]; - uint8_t src_addr[ETH_ALEN]; - uint16_t frame_type; -} ether_hdr; - -typedef struct arp_ether_ipv4 { - uint16_t ar_hrd; - uint16_t ar_pro; - uint8_t ar_hln; - uint8_t ar_pln; - uint16_t ar_op; - uint8_t ar_sha[ETH_ALEN]; - uint32_t ar_sip; - uint8_t ar_tha[ETH_ALEN]; - uint32_t ar_tip; -} arp_ether_ipv4; - -static struct host_entry **helist; -static struct host_entry **cursor; -static unsigned num_hosts = 0; -static unsigned live_count = 0; - -static void advance_cursor(void) { - if(live_count > 0) { - do { - if(cursor == (helist+(num_hosts-1))) { - cursor = helist; - } else { - cursor++; - } - } while(!(*cursor)->live); - } -} - -static void remove_host(host_entry **he) { - if((*he)->live == 1) { - (*he)->live = 0; - live_count--; - if(*he == *cursor) { - advance_cursor(); - } - } -} - -static void timeval_diff(const struct timeval *a, const struct timeval *b, struct timeval *diff) { - struct timeval temp; - - temp.tv_sec = b->tv_sec; - temp.tv_usec = b->tv_usec; - - if(a->tv_usec < temp.tv_usec) { - int nsec = (temp.tv_usec - a->tv_usec) / 1000000 + 1; - temp.tv_usec -= 1000000 * nsec; - temp.tv_sec += nsec; - } - if(a->tv_usec - temp.tv_usec > 1000000) { - int nsec = (a->tv_usec - temp.tv_usec) / 1000000; - temp.tv_usec += 1000000 * nsec; - temp.tv_sec -= nsec; - } - - diff->tv_sec = a->tv_sec - temp.tv_sec; - diff->tv_usec = a->tv_usec - temp.tv_usec; -} - - -static void marshal_arp_pkt(unsigned char *buffer, ether_hdr *frame_hdr, arp_ether_ipv4 *arp_pkt, int *buf_siz) { - unsigned char *cp; - int packet_size; - - cp = buffer; - - packet_size = sizeof(frame_hdr->dest_addr) + sizeof(frame_hdr->src_addr) + - sizeof(frame_hdr->frame_type) + - sizeof(arp_pkt->ar_hrd) + sizeof(arp_pkt->ar_pro) + - sizeof(arp_pkt->ar_hln) + sizeof(arp_pkt->ar_pln) + - sizeof(arp_pkt->ar_op) + sizeof(arp_pkt->ar_sha) + - sizeof(arp_pkt->ar_sip) + sizeof(arp_pkt->ar_tha) + - sizeof(arp_pkt->ar_tip); - - memcpy(cp, &(frame_hdr->dest_addr), sizeof(frame_hdr->dest_addr)); - cp += sizeof(frame_hdr->dest_addr); - memcpy(cp, &(frame_hdr->src_addr), sizeof(frame_hdr->src_addr)); - cp += sizeof(frame_hdr->src_addr); - - memcpy(cp, &(frame_hdr->frame_type), sizeof(frame_hdr->frame_type)); - cp += sizeof(frame_hdr->frame_type); - - memcpy(cp, &(arp_pkt->ar_hrd), sizeof(arp_pkt->ar_hrd)); - cp += sizeof(arp_pkt->ar_hrd); - memcpy(cp, &(arp_pkt->ar_pro), sizeof(arp_pkt->ar_pro)); - cp += sizeof(arp_pkt->ar_pro); - memcpy(cp, &(arp_pkt->ar_hln), sizeof(arp_pkt->ar_hln)); - cp += sizeof(arp_pkt->ar_hln); - memcpy(cp, &(arp_pkt->ar_pln), sizeof(arp_pkt->ar_pln)); - cp += sizeof(arp_pkt->ar_pln); - memcpy(cp, &(arp_pkt->ar_op), sizeof(arp_pkt->ar_op)); - cp += sizeof(arp_pkt->ar_op); - memcpy(cp, &(arp_pkt->ar_sha), sizeof(arp_pkt->ar_sha)); - cp += sizeof(arp_pkt->ar_sha); - memcpy(cp, &(arp_pkt->ar_sip), sizeof(arp_pkt->ar_sip)); - cp += sizeof(arp_pkt->ar_sip); - memcpy(cp, &(arp_pkt->ar_tha), sizeof(arp_pkt->ar_tha)); - cp += sizeof(arp_pkt->ar_tha); - memcpy(cp, &(arp_pkt->ar_tip), sizeof(arp_pkt->ar_tip)); - cp += sizeof(arp_pkt->ar_tip); - - *buf_siz = packet_size; -} - -static int unmarshal_arp_pkt(const unsigned char *buffer, size_t buf_len, ether_hdr *frame_hdr, arp_ether_ipv4 *arp_pkt, unsigned char *extra_data, size_t *extra_data_len) { - const unsigned char *cp; - int framing = FRAMING_ETHERNET_II; - cp = buffer; - - memcpy(&(frame_hdr->dest_addr), cp, sizeof(frame_hdr->dest_addr)); - cp += sizeof(frame_hdr->dest_addr); - memcpy(&(frame_hdr->src_addr), cp, sizeof(frame_hdr->src_addr)); - cp += sizeof(frame_hdr->src_addr); - - memcpy(&(frame_hdr->frame_type), cp, sizeof(frame_hdr->frame_type)); - cp += sizeof(frame_hdr->frame_type); - - if(*cp == 0xAA && *(cp+1) == 0xAA && *(cp+2) == 0x03) { - cp += 8; - framing = FRAMING_LLC_SNAP; - } - - memcpy(&(arp_pkt->ar_hrd), cp, sizeof(arp_pkt->ar_hrd)); - cp += sizeof(arp_pkt->ar_hrd); - memcpy(&(arp_pkt->ar_pro), cp, sizeof(arp_pkt->ar_pro)); - cp += sizeof(arp_pkt->ar_pro); - memcpy(&(arp_pkt->ar_hln), cp, sizeof(arp_pkt->ar_hln)); - cp += sizeof(arp_pkt->ar_hln); - memcpy(&(arp_pkt->ar_pln), cp, sizeof(arp_pkt->ar_pln)); - cp += sizeof(arp_pkt->ar_pln); - memcpy(&(arp_pkt->ar_op), cp, sizeof(arp_pkt->ar_op)); - cp += sizeof(arp_pkt->ar_op); - memcpy(&(arp_pkt->ar_sha), cp, sizeof(arp_pkt->ar_sha)); - cp += sizeof(arp_pkt->ar_sha); - memcpy(&(arp_pkt->ar_sip), cp, sizeof(arp_pkt->ar_sip)); - cp += sizeof(arp_pkt->ar_sip); - memcpy(&(arp_pkt->ar_tha), cp, sizeof(arp_pkt->ar_tha)); - cp += sizeof(arp_pkt->ar_tha); - memcpy(&(arp_pkt->ar_tip), cp, sizeof(arp_pkt->ar_tip)); - cp += sizeof(arp_pkt->ar_tip); - - return framing; -} - -void arp_add_host(const char *host_name) { - - if((helist = REALLOC(helist, ((num_hosts+1) * sizeof(struct host_entry *)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - if((helist[num_hosts] = MALLOC(sizeof(struct host_entry))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - helist[num_hosts]->addr.s_addr = inet_addr(host_name); - helist[num_hosts]->live = 1; - helist[num_hosts]->timeout = 500 * 1000; /* Convert from ms to us */ - helist[num_hosts]->num_sent = 0; - helist[num_hosts]->num_recv = 0; - helist[num_hosts]->found = 0; - helist[num_hosts]->last_send_time.tv_sec = 0; - helist[num_hosts]->last_send_time.tv_usec = 0; - num_hosts++; -} - -static int send_packet(pcap_t *pcap_handle, host_entry *he, struct timeval *last_packet_time, char source_mac[ETH_ALEN]) { - struct ether_hdr frame_hdr; - struct arp_ether_ipv4 arpei; - unsigned char buf[MAX_FRAME]; - unsigned char target_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - unsigned char arp_tha[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; - int buflen = 0; - int nsent = 0; - - memcpy(frame_hdr.dest_addr, target_mac, ETH_ALEN); - memcpy(frame_hdr.src_addr, source_mac, ETH_ALEN); - frame_hdr.frame_type = htons(0x0806); - - memset(&arpei, '\0', sizeof(arp_ether_ipv4)); - arpei.ar_hrd = htons(1); - arpei.ar_pro = htons(0x0800); - arpei.ar_hln = 6; - arpei.ar_pln = 4; - arpei.ar_op = htons(1); - memcpy(arpei.ar_sha, source_mac, ETH_ALEN); - memcpy(arpei.ar_tha, arp_tha, ETH_ALEN); - arpei.ar_sip = 0; - if(he != NULL) { - arpei.ar_tip = he->addr.s_addr; - } - - marshal_arp_pkt(buf, &frame_hdr, &arpei, &buflen); - - if(he == NULL) { - return buflen; - } - - if(he->live == 0) { - logprintf(LOG_ERR, "send_packet called on non-live host"); - return -1; - } - - gettimeofday(last_packet_time, NULL); - he->last_send_time.tv_sec = last_packet_time->tv_sec; - he->last_send_time.tv_usec = last_packet_time->tv_usec; - he->num_sent++; - - nsent = pcap_sendpacket(pcap_handle, buf, buflen); - if(nsent < 0) { - logprintf(LOG_ERR, "ERROR: failed to send packet"); - return -1; - } - - return buflen; -} - -static struct host_entry *find_host(host_entry **he, struct in_addr *addr) { - host_entry **p; - int found = 0; - - if(*he == NULL) { - return NULL; - } - - p = he; - - do { - if((*p)->addr.s_addr == addr->s_addr) { - found = 1; - } else { - if(p == helist) { - p = helist + (num_hosts-1); /* Wrap round to end */ - } else { - p--; - } - } - } while(!found && p != he); - - if(found == 1) { - return *p; - } else { - return NULL; - } -} - -static void callback(u_char *args, const struct pcap_pkthdr *header, const u_char *packet_in) { - struct arp_ether_ipv4 arpei; - struct ether_hdr frame_hdr; - size_t n = header->caplen; - struct in_addr source_ip; - struct host_entry *temp_cursor = NULL; - - if(n < ETHER_HDR_SIZE + ARP_PKT_SIZE) { - logprintf(LOG_ERR, "%d byte packet too short to decode\n", (int)n); - return; - } - - unmarshal_arp_pkt(packet_in, n, &frame_hdr, &arpei, NULL, NULL); - source_ip.s_addr = arpei.ar_sip; - temp_cursor = find_host(cursor, &source_ip); - - if(temp_cursor != NULL) { - temp_cursor->num_recv++; - if(temp_cursor->live == 1) { - temp_cursor->found = 1; - memcpy(temp_cursor->mac, arpei.ar_sha, ETH_ALEN); - } - remove_host(&temp_cursor); - } -} - -static int recvfrom_wto(long unsigned int tmo, pcap_t *pcap_handle) { -#ifdef _WIN32 - WaitForSingleObject(pcap_getevent(pcap_handle), (DWORD)tmo); -#else - fd_set readset; - struct timeval to; - int n = 0, pcap_fd = 0; - if((pcap_fd = pcap_get_selectable_fd(pcap_handle)) < 0) { - logprintf(LOG_ERR, "pcap_fileno: %s", pcap_geterr(pcap_handle)); - return -1; - } - FD_ZERO(&readset); - if(pcap_fd >= 0) - FD_SET(pcap_fd, &readset); - to.tv_sec = (__time_t)(tmo/(long unsigned int)1000000); - to.tv_usec = (__suseconds_t)(tmo - (long unsigned int)((time_t)1000000 * to.tv_sec)); - n = select(pcap_fd+1, &readset, NULL, NULL, &to); - if(n < 0) { - logprintf(LOG_ERR, "select"); - return -1; - } else if (n == 0 && pcap_fd >= 0) { - return 1; - } -#endif - if(pcap_handle != NULL) { - if((pcap_dispatch(pcap_handle, -1, callback, NULL)) == -1) { - logprintf(LOG_ERR, "pcap_dispatch: %s", pcap_geterr(pcap_handle)); - return -1; - } - return 0; - } - return -1; -} - -int arp_resolv(char *if_name, char *srcmac, char *dstmac, char **ip) { - struct timeval now, diff, last_packet_time; - pcap_t *pcap_handle = NULL; - unsigned long int loop_timediff = 0, host_timediff = 0; - unsigned long int req_interval = 0, select_timeout = 0; - unsigned long int cum_err = 0, interval = 0; - char *if_cpy = NULL, error[PCAP_ERRBUF_SIZE], *e = error; - int found = -1; - int reset_cum_err = 0, first_timeout = 1; - int i = 0; - - if((if_cpy = MALLOC(strlen(if_name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(if_cpy, if_name); - -#ifdef _WIN32 - int match = 0; - pcap_if_t *alldevs = NULL, *d = NULL; - - if(pcap_findalldevs(&alldevs, e) == -1){ - logprintf(LOG_ERR, "pcap_findalldevs: %s", e); - goto close; - } - - d = alldevs; - match = 0; - for(d=alldevs;d;d=d->next) { - if(strstr(d->name, if_cpy) != NULL) { - match = 1; - if((if_cpy = REALLOC(if_cpy, strlen(d->name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(if_cpy, d->name); - break; - } - } - if(alldevs != NULL) { - pcap_freealldevs(alldevs); - } - if(match == 0) { - logprintf(LOG_ERR, "could not full interface name for %s", if_name); - goto close; - } -#endif - - if((pcap_handle = pcap_open_live(if_cpy, 64, 0, 3, e)) == NULL) { - logprintf(LOG_ERR, "pcap_open_live: %s", e); - goto close; - } - - if((pcap_setnonblock(pcap_handle, 1, e)) < 0) { - logprintf(LOG_ERR, "pcap_setnonblock: %s", e); - goto close; - } - - live_count = num_hosts; - cursor = helist; - last_packet_time.tv_sec=0; - last_packet_time.tv_usec=0; - - interval = 10000; - - reset_cum_err = 1; - req_interval = interval; - while(live_count > 0) { - gettimeofday(&now, NULL); - timeval_diff(&now, &last_packet_time, &diff); - loop_timediff = (unsigned long int)(1000000*diff.tv_sec + diff.tv_usec); - if(loop_timediff >= (unsigned)req_interval) { - timeval_diff(&now, &((*cursor)->last_send_time), &diff); - host_timediff = (unsigned long int)(1000000*diff.tv_sec + diff.tv_usec); - if(host_timediff >= (*cursor)->timeout) { - if(reset_cum_err > 0) { - cum_err = 0; - req_interval = interval; - reset_cum_err = 0; - } else { - cum_err += loop_timediff - interval; - if(req_interval >= cum_err) { - req_interval = req_interval - cum_err; - } else { - req_interval = 0; - } - } - select_timeout = req_interval; - if((*cursor)->num_sent >= 2) { - remove_host(cursor); - if(first_timeout > 0) { - timeval_diff(&now, &((*cursor)->last_send_time), &diff); - host_timediff = (unsigned long int)(1000000*diff.tv_sec + diff.tv_usec); - while(host_timediff >= (*cursor)->timeout && live_count) { - if((*cursor)->live == 1) { - remove_host(cursor); - } else { - advance_cursor(); - } - timeval_diff(&now, &((*cursor)->last_send_time), &diff); - host_timediff = (unsigned long int)(1000000*diff.tv_sec + diff.tv_usec); - } - first_timeout=0; - } - gettimeofday(&last_packet_time, NULL); - } else { - if((*cursor)->num_sent > 0) { - (*cursor)->timeout *= 1.5; - } - if(send_packet(pcap_handle, *cursor, &last_packet_time, srcmac) == -1) { - goto close; - } - advance_cursor(); - } - } else { - select_timeout = (long unsigned int)((*cursor)->timeout - host_timediff); - reset_cum_err = 1; - } - } else { - select_timeout = req_interval - loop_timediff; - } - if(recvfrom_wto(select_timeout, pcap_handle) == -1) { - goto close; - } - } - - for(i=0;ifound == 1) { - char fmac[ETH_ALEN]; - memset(fmac, '\0', ETH_ALEN); - sprintf(fmac, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", - helist[i]->mac[0], helist[i]->mac[1], - helist[i]->mac[2], helist[i]->mac[3], - helist[i]->mac[4], helist[i]->mac[5]); - if(strcmp(fmac, dstmac) == 0) { - memset(*ip, '\0', INET_ADDRSTRLEN+1); - inet_ntop(AF_INET, (void *)&(helist[i]->addr), *ip, INET_ADDRSTRLEN+1); - found = 1; - break; - } - } - } - -close: - if(pcap_handle != NULL) { - pcap_close(pcap_handle); - } - if(if_cpy != NULL) { - FREE(if_cpy); - } - for(i=0;i. - * - * arp-scan.h -- Header file for ARP scanner - * - * Author: Roy Hills - * Date: 11 October 2005 - * - * The ARP protocol is defined in RFC 826 Ethernet Address Resolution Protocol - * - */ - -void arp_add_host(const char *host_name); -int arp_resolv(char *if_name, char *srcmac, char *dstmac, char **ip); diff --git a/lib/ESPiLight/pilight/libs/pilight/core/cast.c b/lib/ESPiLight/pilight/libs/pilight/core/cast.c deleted file mode 100644 index 0e2ba31..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/cast.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include - -#ifndef _WIN32 - #include -#endif - -#include "common.h" -#include "../events/events.h" /* rewrite */ - -int cast2bool(struct varcont_t **a) { - struct varcont_t b; - memset(&b, 0, sizeof(struct varcont_t)); - - b.type_ = JSON_BOOL; - - if((*a)->type_ == JSON_NUMBER) { - if((int)(*a)->number_ != 0) { - b.bool_ = 1; - } - } - if((*a)->type_ == JSON_STRING) { - if(strcmp((*a)->string_, "0") == 0) { - b.bool_ = 0; - } else if(strlen((*a)->string_) > 0) { - b.bool_ = 1; - } - if((*a)->free_ == 1) { - FREE((*a)->string_); - (*a)->free_ = 0; - } - } - if((*a)->type_ == JSON_BOOL) { - b.bool_ = (*a)->bool_; - } - - memcpy(*a, &b, sizeof(struct varcont_t)); - return 0; -} - -int cast2int(struct varcont_t **a) { - struct varcont_t b; - memset(&b, 0, sizeof(struct varcont_t)); - - b.type_ = JSON_NUMBER; - - if((*a)->type_ == JSON_STRING) { - b.number_ = atof((*a)->string_); - if(b.number_ != 0) { - b.decimals_ = nrDecimals((*a)->string_); - } - if((*a)->free_ == 1) { - FREE((*a)->string_); - (*a)->free_ = 0; - } - } - if((*a)->type_ == JSON_BOOL) { - if((*a)->bool_ == 0) { - b.number_ = 0; - } else { - b.number_ = 1; - } - } - if((*a)->type_ == JSON_NUMBER) { - b.number_ = (*a)->number_; - b.decimals_ = (*a)->decimals_; - } - - memcpy(*a, &b, sizeof(struct varcont_t)); - return 0; -} - -int cast2str(struct varcont_t **a) { - struct varcont_t b; - memset(&b, 0, sizeof(struct varcont_t)); - - b.type_ = JSON_STRING; - - if((*a)->type_ == JSON_BOOL) { - struct varcont_t bb, *bbb = &bb; - memcpy(&bb, *a, sizeof(struct varcont_t)); - cast2int(&bbb); - memcpy(*a, &bb, sizeof(struct varcont_t)); - } - if((*a)->type_ == JSON_NUMBER) { - int len = snprintf(NULL, 0, "%.*f", (*a)->decimals_, (*a)->number_); - if((b.string_ = MALLOC(len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(b.string_, 0, len+1); - sprintf(b.string_, "%.*f", (*a)->decimals_, (*a)->number_); - } - if((*a)->type_ == JSON_STRING) { - b.string_ = STRDUP((*a)->string_); - if((*a)->free_ == 1) { - FREE((*a)->string_); - (*a)->free_ = 0; - } - } - - memcpy(*a, &b, sizeof(struct varcont_t)); - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/cast.h b/lib/ESPiLight/pilight/libs/pilight/core/cast.h deleted file mode 100644 index 8b72df9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/cast.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _CAST_H_ -#define _CAST_H_ - -#include "common.h" -#include "../events/events.h" /* rewrite */ - -int cast2bool(struct varcont_t **); -int cast2int(struct varcont_t **); -int cast2str(struct varcont_t **); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/common.c b/lib/ESPiLight/pilight/libs/pilight/core/common.c deleted file mode 100644 index 9143acb..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/common.c +++ /dev/null @@ -1,1146 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef __FreeBSD__ - #define _GNU_SOURCE -#endif -#include -#include -#include -#include -#include -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #include - #include - #include - #include - #include - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#endif - -#include -#include -#include -#include -#include -#include -#ifndef __USE_XOPEN - #define __USE_XOPEN -#endif -#include -#include -#include - -#include "../config/settings.h" -#include "mem.h" -#include "common.h" -#include "network.h" -#include "log.h" - -char *progname = NULL; -#ifndef _WIN32 -static int procmounted = 0; -#endif - -static const char base64table[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9', '+', '/' -}; - -static pthread_mutex_t atomic_lock; -static pthread_mutexattr_t atomic_attr; - -void atomicinit(void) { - pthread_mutexattr_init(&atomic_attr); - pthread_mutexattr_settype(&atomic_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&atomic_lock, &atomic_attr); -} - -void atomiclock(void) { - pthread_mutex_lock(&atomic_lock); -} - -void atomicunlock(void) { - pthread_mutex_unlock(&atomic_lock); -} - -void array_free(char ***array, int len) { - int i = 0; - if(len > 0) { - for(i=0;i 0) { - if((*output = REALLOC(*output, sizeof(char *)*(n+1))) == NULL) { - OUT_OF_MEMORY - } - if(((*output)[n] = MALLOC((i-y)+1)) == NULL) { - OUT_OF_MEMORY - } - strncpy((*output)[n], &str[y], i-y); - (*output)[n][(i-y)] = '\0'; - n++; - } - y=i+p; - } - i++; - } - if(strlen(&str[y]) > 0) { - if((*output = REALLOC(*output, sizeof(char *)*(n+1))) == NULL) { - OUT_OF_MEMORY - } - if(((*output)[n] = MALLOC((i-y)+1)) == NULL) { - OUT_OF_MEMORY - } - strncpy((*output)[n], &str[y], i-y); - (*output)[n][(i-y)] = '\0'; - n++; - } - return n; -} - -#ifdef _WIN32 -int check_instances(const wchar_t *prog) { - HANDLE m_hStartEvent = CreateEventW(NULL, FALSE, FALSE, prog); - if(m_hStartEvent == NULL) { - CloseHandle(m_hStartEvent); - return 0; - } - - if(GetLastError() == ERROR_ALREADY_EXISTS) { - CloseHandle(m_hStartEvent); - m_hStartEvent = NULL; - return 0; - } - return -1; -} - -int setenv(const char *name, const char *value, int overwrite) { - if(name == NULL) { - errno = EINVAL; - return -1; - } - if(overwrite == 0 && getenv(name) != NULL) { - return 0; // name already defined and not allowed to overwrite. Treat as OK. - } - if(value == NULL) { - return unsetenv(name); - } - char c[strlen(name)+1+strlen(value)+1]; // one for "=" + one for term zero - strcat(c, name); - strcat(c, "="); - strcat(c, value); - return putenv(c); -} - -int unsetenv(const char *name) { - if(name == NULL) { - errno = EINVAL; - return -1; - } - char c[strlen(name)+1+1]; // one for "=" + one for term zero - strcat(c, name); - strcat(c, "="); - return putenv(c); -} - -int isrunning(const char *program) { - DWORD aiPID[1000], iCb = 1000; - DWORD iCbneeded = 0; - int iNumProc = 0, i = 0; - char szName[MAX_PATH]; - int iLenP = 0; - HANDLE hProc; - HMODULE hMod; - - iLenP = strlen(program); - if(iLenP < 1 || iLenP > MAX_PATH) - return -1; - - if(EnumProcesses(aiPID, iCb, &iCbneeded) <= 0) { - return -1; - } - - iNumProc = iCbneeded / sizeof(DWORD); - - for(i=0;i 0) { - FREE(tmp); - return pid; - } - FREE(tmp); - return -1; -} -#endif - -#ifdef __FreeBSD__ -int findproc(char *cmd, char *args, int loosely) { -#else -pid_t findproc(char *cmd, char *args, int loosely) { -#endif - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - -#ifndef _WIN32 - DIR* dir; - struct dirent* ent; - char fname[512], cmdline[1024]; - int fd = 0, ptr = 0, match = 0, i = 0, y = '\n', x = 0; - - if(procmounted == 0) { - if((dir = opendir("/proc"))) { - i = 0; - while((ent = readdir(dir)) != NULL) { - i++; - } - closedir(dir); - if(i == 2) { -#ifdef __FreeBSD__ - mount("procfs", "/proc", 0, ""); -#else - mount("proc", "/proc", "procfs", 0, ""); -#endif - if((dir = opendir("/proc"))) { - i = 0; - while((ent = readdir(dir)) != NULL) { - i++; - } - closedir(dir); - if(i == 2) { - logprintf(LOG_ERR, "/proc filesystem not properly mounted"); - return -1; - } - } - } - } else { - logprintf(LOG_ERR, "/proc filesystem not properly mounted"); - return -1; - } - procmounted = 1; - } - if((dir = opendir("/proc"))) { - while((ent = readdir(dir)) != NULL) { - if(isNumeric(ent->d_name) == 0) { - snprintf(fname, 512, "/proc/%s/cmdline", ent->d_name); - if((fd = open(fname, O_RDONLY, 0)) > -1) { - memset(cmdline, '\0', sizeof(cmdline)); - if((ptr = (int)read(fd, cmdline, sizeof(cmdline)-1)) > -1) { - i = 0, match = 0, y = '\n'; - /* Replace all NULL terminators for newlines */ - for(i=0;i 0) { - FREE(array); - } - continue; - } - if(strcmp(array[1], args) == 0) { - match++; - } - - if(match == 2) { - pid_t pid = (pid_t)atol(ent->d_name); - close(fd); - closedir(dir); - for(x=0;x 0) { - FREE(array); - } - return pid; - } - } else if(match > 0) { - pid_t pid = (pid_t)atol(ent->d_name); - close(fd); - closedir(dir); - for(x=0;x 0) { - FREE(array); - } - return pid; - } - for(x=0;x 0) { - FREE(array); - } - } - close(fd); - } - } - } - closedir(dir); - } -#endif - return -1; -} - -int isNumeric(char *s) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(s == NULL || *s == '\0' || *s == ' ') - return -1; - - char *p = NULL; - strtod(s, &p); - return (*p == '\0') ? 0 : -1; -} - -int nrDecimals(char *s) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - unsigned int b = 0, c = strlen(s), i = 0; - int a = 0; - for(i=0;ipw_uid; - } - } -#endif - return -1; -} - -int which(const char *program) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char path[1024]; - strcpy(path, getenv("PATH")); - char **array = NULL; - unsigned int n = 0, i = 0; - int found = -1; - - n = explode(path, ":", &array); - for(i=0;i 0) { - FREE(array); - } - return found; -} - -int ishex(int x) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - return(x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') || (x >= 'A' && x <= 'F'); -} - -const char *rstrstr(const char* haystack, const char* needle) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char* loc = 0; - char* found = 0; - size_t pos = 0; - - while ((found = strstr(haystack + pos, needle)) != 0) { - loc = found; - pos = (size_t)((found - haystack) + 1); - } - - return loc; -} - -void alpha_random(char *s, const int len) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - static const char alphanum[] = - "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; - int i = 0; - - for(i = 0; i < len; ++i) { - s[i] = alphanum[(unsigned int)rand() % (sizeof(alphanum) - 1)]; - } - - s[len] = 0; -} - -int urldecode(const char *s, char *dec) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char *o = NULL; - const char *end = s + strlen(s); - int c = 0; - - for(o = dec; s <= end; o++) { - c = *s++; - if(c == '+') { - c = ' '; - } else if(c == '%' && (!ishex(*s++) || !ishex(*s++) || !sscanf(s - 2, "%2x", &c))) { - return -1; - } - if(dec) { - sprintf(o, "%c", c); - } - } - - return (int)(o - dec); -} - -static char to_hex(char code) { - static char hex[] = "0123456789abcdef"; - return hex[code & 15]; -} - -char *urlencode(char *str) { - char *pstr = str, *buf = MALLOC(strlen(str) * 3 + 1), *pbuf = buf; - while(*pstr) { - if(isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~') - *pbuf++ = *pstr; - else if(*pstr == ' ') - *pbuf++ = '+'; - else - *pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15); - pstr++; - } - *pbuf = '\0'; - return buf; -} - -char *base64decode(char *src, size_t len, size_t *decsize) { - unsigned int i = 0; - unsigned int j = 0; - unsigned int l = 0; - size_t size = 0; - char *dec = NULL; - char buf[3]; - char tmp[4]; - - dec = MALLOC(0); - if(dec == NULL) { - return NULL; - } - - while(len--) { - if('=' == src[j]) { - break; - } - if(!(isalnum(src[j]) || src[j] == '+' || src[j] == '/')) { - break; - } - - tmp[i++] = src[j++]; - - if(i == 4) { - for(i = 0; i < 4; ++i) { - for(l = 0; l < 64; ++l) { - if(tmp[i] == base64table[l]) { - tmp[i] = (char)l; - break; - } - } - } - - buf[0] = (char)((tmp[0] << 2) + ((tmp[1] & 0x30) >> 4)); - buf[1] = (char)(((tmp[1] & 0xf) << 4) + ((tmp[2] & 0x3c) >> 2)); - buf[2] = (char)(((tmp[2] & 0x3) << 6) + tmp[3]); - - dec = REALLOC(dec, size + 3); - for(i = 0; i < 3; ++i) { - dec[size++] = buf[i]; - } - - i = 0; - } - } - - if(i > 0) { - for(j = i; j < 4; ++j) { - tmp[j] = '\0'; - } - - for(j = 0; j < 4; ++j) { - for(l = 0; l < 64; ++l) { - if(tmp[j] == base64table[l]) { - tmp[j] = (char)l; - break; - } - } - } - - buf[0] = (char)((tmp[0] << 2) + ((tmp[1] & 0x30) >> 4)); - buf[1] = (char)(((tmp[1] & 0xf) << 4) + ((tmp[2] & 0x3c) >> 2)); - buf[2] = (char)(((tmp[2] & 0x3) << 6) + tmp[3]); - - dec = REALLOC(dec, (size_t)(size + (size_t)(i - 1))); - for(j = 0; (j < i - 1); ++j) { - dec[size++] = buf[j]; - } - } - - dec = REALLOC(dec, size + 1); - dec[size] = '\0'; - - if(decsize != NULL) { - *decsize = size; - } - - return dec; -} - -char *base64encode(char *src, size_t len) { - unsigned int i = 0; - unsigned int j = 0; - char *enc = NULL; - size_t size = 0; - char buf[4]; - char tmp[3]; - - enc = MALLOC(0); - if(enc == NULL) { - return NULL; - } - - while(len--) { - tmp[i++] = *(src++); - - if(i == 3) { - buf[0] = (char)((tmp[0] & 0xfc) >> 2); - buf[1] = (char)(((tmp[0] & 0x03) << 4) + ((tmp[1] & 0xf0) >> 4)); - buf[2] = (char)(((tmp[1] & 0x0f) << 2) + ((tmp[2] & 0xc0) >> 6)); - buf[3] = (char)(tmp[2] & 0x3f); - - enc = REALLOC(enc, size + 4); - for(i = 0; i < 4; ++i) { - enc[size++] = base64table[(int)buf[i]]; - } - - i = 0; - } - } - - if(i > 0) { - for(j = i; j < 3; ++j) { - tmp[j] = '\0'; - } - - buf[0] = (char)((tmp[0] & 0xfc) >> 2); - buf[1] = (char)(((tmp[0] & 0x03) << 4) + ((tmp[1] & 0xf0) >> 4)); - buf[2] = (char)(((tmp[1] & 0x0f) << 2) + ((tmp[2] & 0xc0) >> 6)); - buf[3] = (char)(tmp[2] & 0x3f); - - for(j = 0; (j < i + 1); ++j) { - enc = REALLOC(enc, size+1); - enc[size++] = base64table[(int)buf[j]]; - } - - while((i++ < 3)) { - enc = REALLOC(enc, size+1); - enc[size++] = '='; - } - } - - enc = REALLOC(enc, size+1); - enc[size] = '\0'; - - return enc; -} - -void rmsubstr(char *s, const char *r) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - while((s=strstr(s, r))) { - size_t l = strlen(r); - memmove(s, s+l, 1+strlen(s+l)); - } -} - -char *hostname(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char name[255] = {'\0'}; - char *host = NULL, **array = NULL; - unsigned int n = 0, i = 0; - - gethostname(name, 254); - if(strlen(name) > 0) { - n = explode(name, ".", &array); - if(n > 0) { - if((host = MALLOC(strlen(array[0])+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(host, array[0]); - } - } - for(i=0;i 0) { - FREE(array); - } - return host; -} - -char *distroname(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char dist[32]; - memset(dist, '\0', 32); - char *distro = NULL; - -#ifdef _WIN32 - strcpy(dist, "Windows"); -#elif defined(__FreeBSD__) - strcpy(dist, "FreeBSD/0.0"); -#else - int rc = 1; - struct stat sb; - if((rc = stat("/etc/redhat-release", &sb)) == 0) { - strcpy(dist, "RedHat/0.0"); - } else if((rc = stat("/etc/SuSE-release", &sb)) == 0) { - strcpy(dist, "SuSE/0.0"); - } else if((rc = stat("/etc/mandrake-release", &sb)) == 0) { - strcpy(dist, "Mandrake/0.0"); - } else if((rc = stat("/etc/debian-release", &sb)) == 0) { - strcpy(dist, "Debian/0.0"); - } else if((rc = stat("/etc/debian_version", &sb)) == 0) { - strcpy(dist, "Debian/0.0"); - } else { - strcpy(dist, "Unknown/0.0"); - } -#endif - if(strlen(dist) > 0) { - if((distro = MALLOC(strlen(dist)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(distro, dist); - return distro; - } else { - return NULL; - } -} - -/* The UUID is either generated from the - processor serial number or from the - onboard LAN controller mac address */ -char *genuuid(char *ifname) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char mac[ETH_ALEN], *upnp_id = NULL, *p = mac; - char serial[UUID_LENGTH+1]; - - memset(serial, '\0', UUID_LENGTH+1); -#ifndef _WIN32 - char a[1024]; - FILE *fp = fopen("/proc/cpuinfo", "r"); - if(fp != NULL) { - while(!feof(fp)) { - if(fgets(a, 1024, fp) == 0) { - break; - } - if(strstr(a, "Serial") != NULL) { - sscanf(a, "Serial : %16s%*[ \n\r]", (char *)&serial); - if(strlen(serial) > 0 && - ((isNumeric(serial) == EXIT_SUCCESS && atoi(serial) > 0) || - (isNumeric(serial) == EXIT_FAILURE))) { - memmove(&serial[5], &serial[4], 16); - serial[4] = '-'; - memmove(&serial[8], &serial[7], 13); - serial[7] = '-'; - memmove(&serial[11], &serial[10], 10); - serial[10] = '-'; - memmove(&serial[14], &serial[13], 7); - serial[13] = '-'; - if((upnp_id = MALLOC(UUID_LENGTH+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(upnp_id, serial); - fclose(fp); - return upnp_id; - } - } - } - fclose(fp); - } - -#endif - if(dev2mac(ifname, &p) == 0) { - if((upnp_id = MALLOC(UUID_LENGTH+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(upnp_id, '\0', UUID_LENGTH+1); - snprintf(upnp_id, UUID_LENGTH, - "0000-%02x-%02x-%02x-%02x%02x%02x", - (unsigned char)p[0], (unsigned char)p[1], (unsigned char)p[2], - (unsigned char)p[3], (unsigned char)p[4], (unsigned char)p[5]); - return upnp_id; - } - - return NULL; -} - -/* Check if a given file exists */ -int file_exists(char *filename) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct stat sb; - return stat(filename, &sb); -} - -/* Check if a given path exists */ -int path_exists(char *fil) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct stat s; - char tmp[strlen(fil)+1]; - strcpy(tmp, fil); - - atomiclock(); - /* basename isn't thread safe */ - char *filename = basename(tmp); - atomicunlock(); - - char path[(strlen(tmp)-strlen(filename))+1]; - size_t i = (strlen(tmp)-strlen(filename)); - - memset(path, '\0', sizeof(path)); - memcpy(path, tmp, i); - snprintf(path, i, "%s", tmp); - -/* - * dir stat doens't work on windows if path has a trailing slash - */ -#ifdef _WIN32 - if(path[i-1] == '\\' || path[i-1] == '/') { - path[i-1] = '\0'; - } -#endif - - if(strcmp(filename, tmp) != 0) { - int err = stat(path, &s); - if(err == -1) { - if(ENOENT == errno) { - return EXIT_FAILURE; - } else { - return EXIT_FAILURE; - } - } else { - if(S_ISDIR(s.st_mode)) { - return EXIT_SUCCESS; - } else { - return EXIT_FAILURE; - } - } - } - return EXIT_SUCCESS; -} - -/* Copyright (C) 1995 Ian Jackson */ -/* Copyright (C) 1995 Ian Jackson */ -// 1: val > ref -// -1: val < ref -// 0: val == ref -int vercmp(char *val, char *ref) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int vc, rc; - long vl, rl; - char *vp, *rp; - char *vsep, *rsep; - - if(!val) { - strcpy(val, ""); - } - if(!ref) { - strcpy(ref, ""); - } - while(1) { - vp = val; - while(*vp && !isdigit(*vp)) { - vp++; - } - rp = ref; - while(*rp && !isdigit(*rp)) { - rp++; - } - while(1) { - vc =(val == vp) ? 0 : *val++; - rc =(ref == rp) ? 0 : *ref++; - if(!rc && !vc) { - break; - } - if(vc && !isalpha(vc)) { - vc += 256; - } - if(rc && !isalpha(rc)) { - rc += 256; - } - if(vc != rc) { - return vc - rc; - } - } - val = vp; - ref = rp; - vl = 0; - if(isdigit(*vp)) { - vl = strtol(val, (char**)&val, 10); - } - rl = 0; - if(isdigit(*rp)) { - rl = strtol(ref, (char**)&ref, 10); - } - if(vl != rl) { - return (int)(vl - rl); - } - - vc = *val; - rc = *ref; - vsep = strchr(".-", vc); - rsep = strchr(".-", rc); - - if((vsep && !rsep) || !*val) { - return 0; - } - - if((!vsep && rsep) || !*ref) { - return +1; - } - - if(!*val && !*ref) { - return 0; - } - } -} - -char *uniq_space(char *str){ - char *from = NULL, *to = NULL; - int spc=0; - to = from = str; - while(1){ - if(spc == 1 && *from == ' ' && to[-1] == ' ') { - ++from; - } else { - spc = (*from == ' ') ? 1 : 0; - *to++ = *from++; - if(!to[-1]) { - break; - } - } - } - return str; -} - -int str_replace(char *search, char *replace, char **str) { - unsigned short match = 0; - int len = (int)strlen(*str); - int nlen = 0; - int slen = (int)strlen(search); - int rlen = (int)strlen(replace); - int x = 0; - while(x < len) { - if(strncmp(&(*str)[x], search, (size_t)slen) == 0) { - match = 1; - int rpos = (x + (slen - rlen)); - if(rpos < 0) { - slen -= rpos; - rpos = 0; - } - nlen = len - (slen - rlen); - if(len < nlen) { - if(((*str) = REALLOC((*str), (size_t)nlen+1)) == NULL) { /*LCOV_EXCL_LINE*/ - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(&(*str)[len], '\0', (size_t)(nlen-len)); - } - len = nlen; - memmove(&(*str)[x], &(*str)[rpos], (size_t)(len-x)); - strncpy(&(*str)[x], replace, (size_t)rlen); - (*str)[len] = '\0'; - x += rlen-1; - } - x++; - } - if(match == 1) { - return (int)len; - } else { - return -1; - } -} - -int strnicmp(char const *a, char const *b, size_t len) { - int i = 0; - - if(a == NULL || b == NULL) { - return -1; - } - if(len == 0) { - return 0; - } - - for(;i++ str && strchr(trim_away, end[-1]) != NULL; --end) - ; - *end = '\0'; - } - return str; -} - -int checkdnsrr(const char *domain, const char *type) -{ - logprintf(LOG_STACK, "%s(%s,%s)", __FUNCTION__, domain ? domain : "(NULL)", type ? type : "(NULL)"); - return 0; // NYI. -} - -/** - * Check if an email address is valid. - * @param char* address The email address to check. Leading+trailing white spaces are accepted. - * @param bool allow_lists If true, addr is allowed to be a comma separated list of email addresses. - * @param bool check_domain_can_mail If true, check if domain exists in DNS system and accepts email. - * @return int Values < 0 indicate error. Values >= 0 indicate success. - * Where -1: syntax error, -2: DNS check for a domain failed, -8: severe internal error. - */ -int check_email_addr(const char *address, int allow_lists, int check_domain_can_mail) { - if(address == NULL) { - return -1; - } - - #define ALPHANUMERICS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - - static const char white_spaces[] = " \t"; - static const char local_valid_chars[] = ALPHANUMERICS ".!#$%&'*+-\\/=?^_`{|}~"; - static const char domain_valid_chars[] = ALPHANUMERICS ".-"; // . and - are not allowed everywhere. - - const char *at = NULL, *domain_name = NULL; - char *addr = NULL; - char **addr_list = NULL; - size_t addr_count = explode(address, ",", &addr_list), ii = 0; - int ret = -1; - for(ii = 0; ii < addr_count; ii++) { - ret = -1; // assume error - if (allow_lists == 0 && addr_count > 1) { - break; // only one address allowed. - } - addr = addr_list[ii]; - addr += strspn(addr, white_spaces); // trim left - str_trim_right(addr, white_spaces); - - // Now check addr. First some quick pre-checks: - at = strchr(addr, '@'); - if(at == NULL || strstr(addr, "..") != NULL) { - break; // no @ found or two consecutive dots found somewhere. - } - domain_name = at+1; - - if(at == addr || at[-1] == '.' || addr[0] == '.') { - break; // local part emtpy, or starts or ends with a dot. - } - if(addr+strspn(addr, local_valid_chars) < at) { - break; // local part contains invalid chars. - } - if(strchr(domain_name, '.') == NULL || strlen(domain_name) < 5) { - break; // not at least one dot in domain or domain is not at least 2 x 2 chars. - } - if(strchr(".-", domain_name[0]) != NULL || strchr(".-", domain_name[strlen(domain_name)-1]) != NULL) { - break; // domain starts or ends with a dot or dash. - } - if(strstr(domain_name, ".-") != NULL || strstr(domain_name, "-.") != NULL) { - break; // a dot delimited domain part starts or ends with a dash. - } - if(domain_name[strspn(domain_name, domain_valid_chars)] != '\0') { - break; // domain contains invalid chars. - } - - // Finally check domain name against DNS if desired: - - if(check_domain_can_mail != 0 && checkdnsrr(domain_name, "MX") < 0) { - ret = -2; - break; // domain not found or does not accept emails. - } - - ret = 0; // Address ok (and all ok if this is the last one in the list). - } - array_free(&addr_list, addr_count); - return ret; - - #undef ALPHANUMERICS -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/common.h b/lib/ESPiLight/pilight/libs/pilight/core/common.h deleted file mode 100644 index 3473d82..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/common.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _COMMON_H_ -#define _COMMON_H_ - -#ifndef _WIN32 - #include - #include - #include -#endif -#include -#include - -typedef struct varcont_t { - union { - char *string_; - double number_; - int bool_; - }; - int decimals_; - int type_; - int free_; -} varcont_t; - -#include "pilight.h" - -extern char *progname; - -#ifdef _WIN32 -#define sleep(a) Sleep(a*1000) -int check_instances(const wchar_t *prog); -int setenv(const char *name, const char *value, int overwrite); -int unsetenv(const char *name); -int isrunning(const char *program); -#endif - -void array_free(char ***array, int len); -int isrunning(const char *program); -void atomicinit(void); -void atomiclock(void); -void atomicunlock(void); -unsigned int explode(const char *str, const char *delimiter, char ***output); -int isNumeric(char *str); -int nrDecimals(char *str); -int name2uid(char const *name); -int which(const char *program); -int ishex(int x); -const char *rstrstr(const char* haystack, const char* needle); -void alpha_random(char *s, const int len); -int urldecode(const char *s, char *dec); -char *urlencode(char *str); -char *base64encode(char *src, size_t len); -char *base64decode(char *src, size_t len, size_t *decsize); -char *hostname(void); -char *distroname(void); -void rmsubstr(char *s, const char *r); -char *genuuid(char *ifname); -int file_exists(char *fil); -int path_exists(char *fil); -char *uniq_space(char *str); - -#ifdef __FreeBSD__ -int findproc(char *name, char *args, int loosely); -#else -pid_t findproc(char *name, char *args, int loosely); -#endif - -int vercmp(char *val, char *ref); -int str_replace(char *search, char *replace, char **str); -#ifndef _WIN32 -int stricmp(char const *a, char const *b); -int strnicmp(char const *a, char const *b, size_t len); -#endif -int file_get_contents(char *file, char **content); -int check_email_addr(const char *addr, int allow_lists, int check_domain_can_mail); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/config.c b/lib/ESPiLight/pilight/libs/pilight/core/config.c deleted file mode 100644 index 9d6500d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/config.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pilight.h" -#include "common.h" -#include "json.h" -#include "config.h" -#include "log.h" -#include "../config/devices.h" -#include "../config/settings.h" -#include "../config/registry.h" -#ifdef EVENTS - #include "../config/rules.h" -#endif -#include "../config/hardware.h" -#include "../config/gui.h" - -static struct config_t *config = NULL; -static pthread_mutex_t mutex_lock; -static pthread_mutexattr_t mutex_attr; - -static void sort_list(int r) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct config_t *a = NULL; - struct config_t *b = NULL; - struct config_t *c = NULL; - struct config_t *e = NULL; - struct config_t *tmp = NULL; - - while(config && e != config->next) { - c = a = config; - b = a->next; - while(a != e) { - if((r == 0 && a->writeorder > b->writeorder) || - (r == 1 && a->readorder > b->readorder)) { - if(a == config) { - tmp = b->next; - b->next = a; - a->next = tmp; - config = b; - c = b; - } else { - tmp = b->next; - b->next = a; - a->next = tmp; - c->next = b; - c = b; - } - } else { - c = a; - a = a->next; - } - b = a->next; - if(b == e) - e = a; - } - } -} - -/* The location of the config file */ -static char *configfile = NULL; - -int config_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - pthread_mutex_lock(&mutex_lock); - struct config_t *listeners; - while(config) { - listeners = config; - listeners->gc(); - FREE(config->name); - config = config->next; - FREE(listeners); - } - if(config != NULL) { - FREE(config); - } - if(configfile != NULL) { - FREE(configfile); - } - configfile = NULL; - - pthread_mutex_unlock(&mutex_lock); - logprintf(LOG_DEBUG, "garbage collected config library"); - return 1; -} - -int config_parse(JsonNode *root) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct JsonNode *jconfig = NULL; - unsigned short error = 0; - - sort_list(1); - struct config_t *listeners = config; - while(listeners) { - if((jconfig = json_find_member(root, listeners->name))) { - if(listeners->parse) { - if(listeners->parse(jconfig) == EXIT_FAILURE) { - error = 1; - break; - } - } - } - listeners = listeners->next; - } - - if(error == 1) { - config_gc(); - return EXIT_FAILURE; - } else { - return EXIT_SUCCESS; - } -} - -JsonNode *config_print(int level, const char *media) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct JsonNode *root = json_mkobject(); - - sort_list(0); - struct config_t *listeners = config; - while(listeners) { - if(listeners->sync) { - struct JsonNode *child = listeners->sync(level, media); - if(child != NULL) { - json_append_member(root, listeners->name, child); - } - } - listeners = listeners->next; - } - - return root; -} - -int config_write(int level, const char *media) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct JsonNode *root = json_mkobject(); - FILE *fp; - - sort_list(0); - struct config_t *listeners = config; - while(listeners) { - if(listeners->sync) { - struct JsonNode *child = listeners->sync(level, media); - if(child != NULL) { - json_append_member(root, listeners->name, child); - } - } - listeners = listeners->next; - } - - /* Overwrite config file with proper format */ - if((fp = fopen(configfile, "w+")) == NULL) { - logprintf(LOG_ERR, "cannot write config file: %s", configfile); - return EXIT_FAILURE; - } - fseek(fp, 0L, SEEK_SET); - char *content = NULL; - if((content = json_stringify(root, "\t")) != NULL) { - fwrite(content, sizeof(char), strlen(content), fp); - json_free(content); - json_delete(root); - } - fclose(fp); - return EXIT_SUCCESS; -} - -int config_read(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char *content = NULL; - struct JsonNode *root = NULL; - - /* Read JSON config file */ - if(file_get_contents(configfile, &content) == 0) { - /* Validate JSON and turn into JSON object */ - if(json_validate(content) == false) { - logprintf(LOG_ERR, "config is not in a valid json format"); - FREE(content); - return EXIT_FAILURE; - } - root = json_decode(content); - - if(config_parse(root) != EXIT_SUCCESS) { - FREE(content); - json_delete(root); - return EXIT_FAILURE; - } - json_delete(root); - config_write(1, "all"); - FREE(content); - } - return EXIT_SUCCESS; -} - -void config_register(config_t **listener, const char *name) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if((*listener = MALLOC(sizeof(config_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - if(((*listener)->name = MALLOC(strlen(name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy((*listener)->name, name); - (*listener)->parse = NULL; - (*listener)->sync = NULL; - (*listener)->gc = NULL; - (*listener)->next = config; - config = (*listener); -} - -int config_set_file(char *settfile) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(access(settfile, R_OK | W_OK) != -1) { - if((configfile = REALLOC(configfile, strlen(settfile)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(configfile, settfile); - } else { - logprintf(LOG_ERR, "the config file %s does not exist", settfile); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - -char *config_get_file(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - return configfile; -} - -void config_init() { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - pthread_mutexattr_init(&mutex_attr); - pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mutex_lock, &mutex_attr); - - hardware_init(); - settings_init(); - devices_init(); - gui_init(); -#ifdef EVENTS - rules_init(); -#endif - registry_init(); -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/config.h b/lib/ESPiLight/pilight/libs/pilight/core/config.h deleted file mode 100644 index 59add23..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/config.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -#include "json.h" - -#define CONFIG_INTERNAL 0 -#define CONFIG_FORWARD 1 -#define CONFIG_USER 2 - -typedef struct config_t { - char *name; - int (*parse)(JsonNode *); - int readorder; - int writeorder; - JsonNode *(*sync)(int level, const char *media); - int (*gc)(void); - struct config_t *next; -} config_t; - -int config_write(int level, const char *media); -int config_read(void); -int config_parse(struct JsonNode *root); -struct JsonNode *config_print(int level, const char *media); -int config_set_file(char *settfile); -void config_register(config_t **listener, const char *name); -int config_gc(void); -int config_set_file(char *settfile); -char *config_get_file(void); -void config_init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/datetime.c b/lib/ESPiLight/pilight/libs/pilight/core/datetime.c deleted file mode 100644 index 6423bd9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/datetime.c +++ /dev/null @@ -1,1844 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#define __USE_XOPEN -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif - -#include "json.h" -#include "common.h" -#include "log.h" -#include "mem.h" - -#define NRCOUNTRIES 408 -#define PRECISION 1 - -#ifndef min - #define min(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef max - #define max(a,b) (((a)>(b))?(a):(b)) -#endif - - -#define ERALENGTH ((unsigned long)146097 * 86400) - -#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } -#define ATOMIC_VAR_INIT(value) (value) - -#ifdef __clang__ -#define atomic_load_explicit(object, order) __c11_atomic_load(object, order) -#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \ - __c11_atomic_compare_exchange_weak(object, expected, desired, success, failure) -#define atomic_compare_exchange_weak(object, expected, desired) \ - atomic_compare_exchange_weak_explicit(object, expected, desired, memory_order_seq_cst, memory_order_seq_cst) -#else -#define atomic_load_explicit(object, order) __atomic_load_n(object, order) -#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \ - __atomic_compare_exchange_n(object, expected, desired, 1, success, failure) -#define atomic_compare_exchange_weak(object, expected, desired) \ - atomic_compare_exchange_weak_explicit(object, expected, desired, memory_order_seq_cst, memory_order_seq_cst) -#endif - -#ifndef _WIN32 -typedef enum { - memory_order_relaxed = __ATOMIC_RELAXED, - memory_order_consume = __ATOMIC_CONSUME, - memory_order_acquire = __ATOMIC_ACQUIRE, - memory_order_release = __ATOMIC_RELEASE, - memory_order_acq_rel = __ATOMIC_ACQ_REL, - memory_order_seq_cst = __ATOMIC_SEQ_CST, - -#if defined(__ATOMIC_HLE_ACQUIRE) && defined(__ATOMIC_HLE_RELEASE) - /* - * Compiler supports Hardware Lock Elision. - */ - __memory_order_hle_acquire = __ATOMIC_HLE_ACQUIRE, - __memory_order_hle_release = __ATOMIC_HLE_RELEASE -#else - /* - * Ignore Hardware Lock Elision hints. - */ - __memory_order_hle_acquire = 0, - __memory_order_hle_release = 0 -#endif -} memory_order; -#endif - -struct cached_abbreviation { - struct cached_abbreviation *next; - char abbreviation[16]; -}; - -struct lc_timezone_rule { - uint8_t year_from; // Lowest year to which this rule applies. - uint8_t year_to; // Highest year to which this rule applies. - uint32_t month : 4; // Month at which this rule starts. - uint32_t weekday : 3; // Weekday at which this rule start (7=dontcare). - uint32_t monthday : 5; // Day of the month at which this rule starts. - uint32_t minute : 11; // Minutes since 0:00 at which this rule starts. - uint32_t timebase : 2; // Which time should be compared against. -#define TIMEBASE_CUR 0 // Rule applies to the current offset. -#define TIMEBASE_STD 1 // Rule applies to the standard time. -#define TIMEBASE_UTC 2 // Rule applies to time in UTC. - uint32_t save : 4; // The amount of time in 10 minutes. - char abbreviation[6]; // Abbreviation of timezone name (e.g., CEST). -}; - -struct lc_timezone_era { - const struct lc_timezone_rule *rules; // Rules associated with this era. - uint64_t rules_count : 8; // Number of rules. - int64_t gmtoff : 18; // Offset in seconds relative to GMT. - int64_t end : 38; // Timestamp at which this era ends. - uint8_t end_save : 4; // Daylight savings at the end time. - char abbreviation_std[6]; // Abbreviation of standard time (e.g., CET). - char abbreviation_dst[6]; // Abbreviation of DST (e.g., CEST). -}; - -struct ruleset { - const struct lc_timezone_rule *rules[8]; - size_t rules_count; -}; - -struct lc_timezone { - const struct lc_timezone_era *eras; - size_t eras_count; -}; - -extern const struct lc_timezone __timezone_utc; - -#include "tzdata.h" - -static void ruleset_remove_stale(struct ruleset *ruleset, int year); -static void ruleset_get_last(struct ruleset *ruleset, int year, - const struct lc_timezone_rule **last, - const struct lc_timezone_rule **last_dst); - -struct tzdata_t { - char *timezone; - int nrcoords; - int coords[2299][2]; -} tzdata[] = {{"America/Dominica",4,{{-613,155},{-613,153},{-614,152},{-615,156}}}, - {"America/St_Vincent",15,{{-614,125},{-614,126},{-615,126},{-613,127},{-614,127},{-612,129},{-612,130},{-613,130},{-611,129},{-611,130},{-613,129},{-612,134},{-611,133},{-612,131},{-613,132}}}, - {"Australia/Lord_Howe",3,{{1591,-316},{1591,-315},{1590,-315}}}, - {"Asia/Kashgar",117,{{802,306},{799,310},{790,311},{788,313},{788,316},{784,325},{787,327},{788,324},{791,324},{793,325},{793,329},{787,337},{787,341},{790,343},{782,347},{780,353},{781,355},{772,355},{768,357},{766,359},{762,358},{759,361},{761,362},{759,367},{755,367},{754,369},{751,370},{745,370},{745,372},{751,373},{749,377},{750,378},{748,382},{749,385},{744,387},{738,386},{737,389},{738,390},{736,393},{739,396},{738,398},{739,400},{749,403},{748,405},{752,404},{756,407},{757,403},{763,405},{763,404},{769,410},{781,410},{784,414},{794,418},{797,418},{799,420},{803,421},{802,427},{803,428},{806,429},{804,430},{808,432},{803,445},{805,447},{798,449},{817,454},{820,452},{827,452},{826,450},{827,448},{818,446},{817,444},{839,440},{850,435},{833,437},{829,437},{829,435},{825,436},{826,433},{834,431},{827,429},{827,426},{830,424},{830,419},{826,417},{827,415},{826,413},{820,411},{818,408},{820,405},{820,395},{825,395},{824,369},{826,366},{825,363},{829,357},{824,357},{821,354},{820,352},{824,352},{824,350},{823,346},{820,343},{828,335},{832,327},{832,320},{825,317},{832,314},{830,308},{832,307},{831,305},{825,309},{824,306},{820,305},{820,303},{814,304},{812,300},{810,303}}}, - {"Pacific/Wallis",9,{{-1780,-143},{-1780,-144},{-1781,-144},{-1781,-143},{-1782,-143},{-1762,-132},{-1761,-133},{-1762,-134},{-1762,-133}}}, - {"Europe/Berlin",197,{{85,546},{84,546},{87,477},{67,536},{68,536},{69,536},{70,537},{69,537},{71,537},{72,537},{73,537},{77,538},{78,538},{80,538},{79,538},{143,537},{82,537},{81,537},{74,537},{76,537},{75,537},{75,538},{76,538},{85,545},{132,545},{87,545},{86,545},{87,546},{131,545},{88,545},{88,546},{86,546},{83,546},{83,547},{84,547},{86,547},{85,547},{85,548},{85,539},{84,539},{84,540},{85,540},{115,540},{114,540},{87,540},{87,541},{87,542},{74,492},{67,492},{64,495},{65,498},{61,501},{64,505},{59,511},{62,512},{61,512},{62,514},{60,518},{67,519},{68,520},{67,521},{71,522},{70,525},{67,526},{71,526},{73,533},{70,534},{80,537},{82,534},{83,536},{86,535},{85,535},{85,534},{85,537},{87,539},{93,539},{96,536},{98,535},{89,539},{88,540},{90,541},{88,542},{90,543},{86,543},{90,545},{87,547},{86,549},{84,548},{83,549},{84,550},{84,549},{88,549},{94,548},{96,549},{99,548},{100,546},{98,545},{102,545},{101,543},{103,544},{107,543},{111,544},{111,542},{108,541},{109,540},{108,539},{112,540},{115,539},{117,542},{121,542},{121,541},{122,541},{125,545},{129,544},{127,544},{124,544},{124,543},{130,544},{135,541},{137,542},{139,539},{138,538},{145,533},{141,528},{146,526},{145,524},{148,521},{146,518},{150,513},{149,510},{147,508},{143,511},{144,509},{125,504},{123,502},{122,503},{121,502},{125,499},{124,498},{127,494},{138,488},{137,485},{135,486},{133,483},{128,481},{130,479},{129,477},{131,476},{130,475},{128,477},{123,477},{113,474},{104,476},{105,474},{102,473},{102,474},{100,476},{86,478},{84,477},{86,477},{86,476},{77,475},{75,477},{76,481},{78,486},{82,490},{92,539},{142,539},{140,540},{138,540},{138,542},{97,536},{98,536},{95,537},{139,542},{139,543},{134,542},{131,543},{135,543},{85,544},{84,544},{84,545},{135,545},{133,546},{132,546},{133,547},{134,547},{137,546},{136,545},{138,543},{137,543},{133,544},{110,545},{112,545},{113,544},{131,544},{131,546}}}, - {"America/Manaus",67,{{-600,2},{-589,2},{-588,-6},{-583,-11},{-568,-20},{-568,-22},{-563,-22},{-585,-67},{-581,-73},{-584,-78},{-583,-81},{-585,-87},{-617,-87},{-619,-89},{-627,-81},{-635,-80},{-640,-84},{-641,-90},{-648,-90},{-651,-94},{-652,-92},{-658,-96},{-660,-94},{-664,-94},{-668,-98},{-676,-95},{-699,-42},{-694,-13},{-696,-5},{-701,-1},{-700,6},{-695,7},{-691,6},{-693,10},{-699,11},{-699,17},{-681,17},{-683,18},{-682,20},{-679,18},{-674,21},{-671,17},{-671,12},{-669,12},{-663,7},{-656,10},{-655,6},{-651,11},{-644,15},{-643,14},{-642,15},{-640,20},{-631,22},{-627,19},{-628,16},{-624,8},{-626,0},{-623,-6},{-625,-8},{-619,-14},{-616,-14},{-615,-7},{-611,-5},{-608,-8},{-605,-8},{-603,-7},{-603,-2}}}, - {"Asia/Jerusalem",14,{{346,318},{351,331},{354,331},{357,332},{356,324},{352,326},{350,322},{350,318},{352,318},{349,314},{355,314},{350,296},{349,295},{343,312}}}, - {"America/Phoenix",36,{{-1090,327},{-1090,313},{-1111,313},{-1148,325},{-1145,328},{-1147,333},{-1145,336},{-1145,339},{-1141,343},{-1146,349},{-1148,361},{-1141,360},{-1141,370},{-1113,370},{-1112,369},{-1114,370},{-1116,369},{-1119,364},{-1117,357},{-1113,358},{-1112,352},{-1090,352},{-1108,355},{-1110,355},{-1110,363},{-1103,364},{-1106,360},{-1101,360},{-1100,356},{-1101,357},{-1101,358},{-1102,357},{-1112,361},{-1111,361},{-1111,360},{-1113,361}}}, - {"Australia/Darwin",307,{{1358,-151},{1370,-158},{1369,-157},{1370,-156},{1371,-158},{1370,-159},{1371,-159},{1366,-158},{1367,-158},{1369,-158},{1366,-157},{1368,-157},{1357,-151},{1357,-152},{1356,-152},{1367,-156},{1368,-156},{1366,-156},{1365,-156},{1365,-155},{1366,-155},{1368,-155},{1369,-155},{1369,-156},{1296,-149},{1357,-149},{1357,-148},{1358,-149},{1292,-149},{1292,-148},{1293,-148},{1295,-148},{1296,-150},{1296,-148},{1350,-148},{1297,-148},{1363,-135},{1362,-135},{1362,-134},{1296,-146},{1297,-146},{1296,-147},{1356,-145},{1369,-144},{1369,-143},{1370,-143},{1363,-138},{1364,-138},{1362,-138},{1362,-139},{1361,-138},{1362,-137},{1366,-138},{1363,-142},{1366,-137},{1367,-137},{1367,-138},{1369,-138},{1367,-141},{1370,-142},{1368,-121},{1365,-138},{1365,-137},{1364,-137},{1369,-137},{1369,-136},{1370,-136},{1367,-136},{1362,-136},{1364,-136},{1360,-133},{1364,-133},{1361,-133},{1301,-132},{1300,-131},{1300,-132},{1366,-129},{1361,-134},{1361,-136},{1361,-135},{1305,-126},{1305,-127},{1304,-126},{1310,-126},{1309,-126},{1309,-125},{1304,-125},{1360,-123},{1361,-123},{1367,-122},{1324,-122},{1323,-122},{1354,-122},{1361,-122},{1360,-122},{1360,-121},{1310,-121},{1314,-121},{1342,-121},{1348,-121},{1349,-121},{1330,-109},{1330,-111},{1330,-110},{1329,-111},{1329,-110},{1368,-110},{1367,-110},{1328,-110},{1290,-149},{1292,-150},{1292,-151},{1291,-152},{1291,-153},{1293,-151},{1293,-149},{1296,-152},{1298,-148},{1298,-147},{1298,-145},{1295,-145},{1294,-143},{1295,-141},{1295,-142},{1297,-140},{1298,-135},{1303,-133},{1301,-130},{1303,-129},{1303,-127},{1306,-128},{1308,-127},{1306,-127},{1306,-124},{1310,-127},{1308,-124},{1310,-124},{1310,-122},{1312,-122},{1313,-120},{1315,-123},{1328,-122},{1326,-118},{1327,-116},{1325,-116},{1325,-114},{1321,-115},{1318,-113},{1320,-111},{1322,-114},{1321,-111},{1323,-113},{1323,-111},{1327,-115},{1329,-113},{1332,-117},{1335,-118},{1335,-119},{1339,-117},{1338,-119},{1341,-119},{1342,-120},{1346,-121},{1347,-120},{1353,-123},{1352,-122},{1354,-121},{1359,-120},{1356,-122},{1357,-123},{1359,-122},{1359,-124},{1360,-125},{1363,-124},{1364,-122},{1362,-122},{1366,-119},{1364,-120},{1366,-123},{1369,-122},{1370,-123},{1367,-125},{1366,-128},{1365,-128},{1367,-130},{1365,-130},{1366,-131},{1365,-133},{1363,-133},{1363,-130},{1362,-133},{1361,-131},{1359,-133},{1359,-137},{1361,-137},{1359,-142},{1354,-147},{1353,-147},{1354,-150},{1355,-152},{1355,-153},{1354,-153},{1365,-157},{1367,-157},{1366,-159},{1364,-159},{1377,-162},{1380,-165},{1380,-260},{1290,-260},{1350,-121},{1349,-120},{1350,-120},{1311,-121},{1324,-121},{1348,-120},{1311,-120},{1361,-121},{1361,-120},{1363,-120},{1362,-121},{1362,-120},{1363,-119},{1366,-118},{1367,-118},{1368,-117},{1365,-118},{1366,-117},{1364,-115},{1321,-116},{1323,-116},{1324,-116},{1361,-116},{1322,-116},{1364,-116},{1365,-115},{1361,-115},{1326,-115},{1326,-116},{1323,-115},{1325,-115},{1319,-115},{1320,-115},{1351,-119},{1351,-120},{1350,-119},{1352,-119},{1307,-118},{1362,-117},{1361,-117},{1352,-117},{1351,-117},{1326,-117},{1325,-117},{1360,-117},{1360,-116},{1333,-117},{1327,-117},{1364,-119},{1365,-119},{1360,-119},{1359,-119},{1359,-118},{1358,-120},{1356,-121},{1356,-120},{1360,-118},{1359,-117},{1361,-118},{1362,-116},{1363,-116},{1335,-116},{1334,-117},{1334,-116},{1303,-111},{1302,-115},{1303,-113},{1303,-116},{1306,-118},{1300,-118},{1301,-117},{1303,-117},{1334,-115},{1335,-115},{1367,-111},{1367,-113},{1325,-112},{1326,-110},{1326,-114},{1312,-112},{1315,-115},{1310,-119},{1305,-117},{1304,-112},{1308,-115},{1307,-114},{1309,-113},{1310,-115},{1311,-112},{1312,-114},{1313,-115},{1312,-113},{1326,-112},{1327,-112},{1329,-112},{1328,-114},{1327,-113}}}, - {"Asia/Seoul",308,{{1265,342},{1263,331},{1263,332},{1262,333},{1265,335},{1268,336},{1269,335},{1266,332},{1270,335},{1263,339},{1263,340},{1269,340},{1274,340},{1274,341},{1251,340},{1251,341},{1273,340},{1273,341},{1266,341},{1255,342},{1259,342},{1275,342},{1274,342},{1272,342},{1268,342},{1259,341},{1267,341},{1266,342},{1267,342},{1265,341},{1289,351},{1269,341},{1269,342},{1261,343},{1273,343},{1265,343},{1266,343},{1273,342},{1270,342},{1260,342},{1264,342},{1261,342},{1259,343},{1262,342},{1262,343},{1260,343},{1259,351},{1291,350},{1290,351},{1291,351},{1289,350},{1288,350},{1288,351},{1262,349},{1278,349},{1278,350},{1285,349},{1285,350},{1280,350},{1261,350},{1262,350},{1261,349},{1263,350},{1261,352},{1262,352},{1260,351},{1261,351},{1287,351},{1286,351},{1262,351},{1286,350},{1285,351},{1260,353},{1260,354},{1261,354},{1261,353},{1262,353},{1260,362},{1263,363},{1261,362},{1264,364},{1265,364},{1264,363},{1262,366},{1263,364},{1263,366},{1264,366},{1261,367},{1262,367},{1308,375},{1309,375},{1309,374},{1247,378},{1248,378},{1263,376},{1262,376},{1257,376},{1257,377},{1265,376},{1262,377},{1261,377},{1265,377},{1264,376},{1264,378},{1265,378},{1263,377},{1264,377},{1263,378},{1262,378},{1247,379},{1246,379},{1246,380},{1247,380},{1261,372},{1264,374},{1264,375},{1265,375},{1265,374},{1266,375},{1263,375},{1266,376},{1266,372},{1264,372},{1265,373},{1266,373},{1262,372},{1261,373},{1263,372},{1260,372},{1266,360},{1260,370},{1263,369},{1264,369},{1267,370},{1266,370},{1266,371},{1264,370},{1264,371},{1259,371},{1260,371},{1261,371},{1265,371},{1265,372},{1263,373},{1264,373},{1263,356},{1261,356},{1261,357},{1265,357},{1264,357},{1264,358},{1265,358},{1264,359},{1265,359},{1260,361},{1265,360},{1264,361},{1274,343},{1271,343},{1270,343},{1278,344},{1278,345},{1273,344},{1253,344},{1284,345},{1285,345},{1282,346},{1274,345},{1275,345},{1275,344},{1274,344},{1270,344},{1270,345},{1271,344},{1260,346},{1275,348},{1271,345},{1272,345},{1272,344},{1261,345},{1260,345},{1264,345},{1265,345},{1277,345},{1261,346},{1277,346},{1270,346},{1276,346},{1275,346},{1274,346},{1259,344},{1260,344},{1263,344},{1260,348},{1261,348},{1269,343},{1269,344},{1268,344},{1268,343},{1267,343},{1266,344},{1267,344},{1261,344},{1286,346},{1252,347},{1254,347},{1284,348},{1283,348},{1285,348},{1262,348},{1264,348},{1263,348},{1274,348},{1282,348},{1285,347},{1286,347},{1286,348},{1284,347},{1261,347},{1283,347},{1264,347},{1282,347},{1255,346},{1255,347},{1260,347},{1275,347},{1262,347},{1263,347},{1274,347},{1277,347},{1259,347},{1259,348},{1280,348},{1280,347},{1279,349},{1258,346},{1259,346},{1285,346},{1271,346},{1263,346},{1284,346},{1283,346},{1262,346},{1254,346},{1278,346},{1278,347},{1281,348},{1263,349},{1280,349},{1277,349},{1260,349},{1281,349},{1287,350},{1287,348},{1292,352},{1290,350},{1290,352},{1286,352},{1284,350},{1281,351},{1276,349},{1275,349},{1273,348},{1273,347},{1272,348},{1268,346},{1265,346},{1264,346},{1266,346},{1266,348},{1266,349},{1264,350},{1265,351},{1263,352},{1265,355},{1267,355},{1265,356},{1269,359},{1266,359},{1267,360},{1265,361},{1266,365},{1265,367},{1261,368},{1263,370},{1263,368},{1266,369},{1268,368},{1271,370},{1269,369},{1268,370},{1269,370},{1269,371},{1268,372},{1267,371},{1267,373},{1269,373},{1266,374},{1267,375},{1268,376},{1267,379},{1270,382},{1281,383},{1284,386},{1291,377},{1294,371},{1294,360},{1296,360}}}, - {"Africa/Gaborone",40,{{270,-238},{269,-243},{264,-246},{259,-248},{257,-255},{254,-257},{247,-258},{239,-256},{235,-253},{230,-253},{227,-260},{220,-266},{218,-267},{217,-269},{209,-268},{207,-269},{206,-265},{208,-260},{207,-255},{200,-248},{200,-220},{210,-220},{210,-183},{233,-180},{236,-185},{242,-180},{246,-181},{250,-178},{253,-178},{262,-195},{272,-201},{273,-205},{277,-205},{277,-211},{280,-216},{290,-218},{291,-220},{294,-222},{283,-226},{277,-232}}}, - {"Indian/Chagos",19,{{724,-74},{724,-73},{724,-72},{725,-74},{714,-67},{713,-67},{713,-66},{713,-64},{714,-62},{713,-62},{723,-57},{718,-54},{722,-53},{717,-53},{719,-52},{718,-52},{720,-52},{718,-53},{722,-54}}}, - {"America/Argentina/Mendoza",28,{{-702,-323},{-697,-323},{-692,-320},{-685,-322},{-680,-321},{-675,-323},{-672,-328},{-672,-334},{-668,-340},{-668,-344},{-665,-349},{-666,-360},{-683,-360},{-682,-376},{-697,-371},{-698,-368},{-704,-363},{-703,-358},{-704,-353},{-706,-353},{-704,-351},{-700,-343},{-698,-342},{-699,-337},{-697,-334},{-699,-332},{-700,-333},{-700,-329}}}, - {"Asia/Hong_Kong",20,{{1142,225},{1143,225},{1142,224},{1144,224},{1143,223},{1139,224},{1139,222},{1143,222},{1142,222},{1140,222},{1141,222},{1144,223},{1143,224},{1144,225},{1139,223},{1140,223},{1142,223},{1138,222},{1141,223},{1141,224}}}, - {"Atlantic/Reykjavik",242,{{-172,638},{-172,639},{-171,639},{-152,642},{-157,642},{-155,643},{-153,643},{-154,643},{-225,653},{-223,653},{-221,654},{-226,653},{-222,654},{-229,654},{-226,654},{-228,654},{-223,654},{-225,652},{-228,652},{-224,647},{-170,638},{-170,639},{-169,638},{-169,639},{-206,633},{-202,634},{-203,634},{-202,635},{-183,635},{-135,650},{-137,649},{-136,649},{-137,650},{-137,648},{-138,648},{-167,638},{-166,638},{-168,638},{-218,642},{-219,642},{-212,639},{-171,638},{-154,644},{-155,642},{-154,642},{-221,643},{-223,644},{-222,644},{-171,663},{-164,665},{-180,665},{-180,666},{-141,647},{-229,650},{-230,650},{-233,651},{-225,651},{-228,651},{-229,651},{-224,651},{-145,646},{-142,646},{-221,638},{-227,638},{-226,639},{-228,640},{-227,641},{-225,640},{-219,641},{-220,642},{-217,642},{-218,643},{-214,644},{-218,646},{-223,645},{-225,647},{-224,646},{-223,646},{-222,647},{-224,648},{-238,647},{-241,649},{-232,650},{-231,649},{-227,651},{-218,650},{-217,652},{-221,651},{-224,652},{-226,652},{-217,655},{-224,655},{-222,655},{-221,656},{-225,655},{-226,656},{-239,654},{-245,655},{-243,656},{-239,655},{-238,655},{-241,656},{-238,656},{-241,658},{-236,656},{-233,657},{-235,657},{-232,658},{-239,659},{-238,660},{-234,660},{-237,661},{-234,661},{-236,661},{-235,662},{-230,661},{-231,660},{-229,660},{-230,659},{-227,661},{-226,660},{-227,658},{-224,659},{-226,658},{-223,659},{-225,660},{-224,661},{-230,662},{-224,663},{-226,663},{-225,663},{-230,663},{-232,664},{-229,664},{-229,665},{-224,665},{-222,663},{-217,662},{-217,660},{-213,660},{-216,660},{-213,659},{-215,658},{-214,657},{-216,657},{-217,658},{-218,658},{-216,656},{-214,656},{-215,656},{-213,656},{-215,654},{-212,654},{-211,652},{-211,654},{-209,653},{-209,656},{-207,657},{-207,655},{-204,655},{-203,657},{-204,661},{-201,661},{-195,657},{-195,660},{-188,662},{-181,656},{-183,662},{-174,660},{-171,662},{-164,661},{-166,665},{-160,665},{-154,661},{-150,664},{-145,664},{-152,661},{-146,660},{-148,657},{-143,658},{-136,655},{-140,653},{-136,653},{-140,652},{-135,651},{-142,650},{-140,649},{-145,648},{-143,646},{-145,647},{-146,646},{-150,642},{-150,643},{-155,644},{-164,639},{-177,637},{-180,638},{-178,637},{-182,635},{-183,636},{-184,636},{-208,638},{-207,638},{-207,639},{-211,639},{-210,639},{-214,638},{-222,645},{-224,645},{-225,648},{-226,648},{-225,646},{-139,656},{-181,657},{-231,654},{-230,654},{-227,654},{-227,655},{-226,655},{-228,655},{-229,655},{-206,655},{-205,656},{-205,655},{-204,656},{-206,656},{-230,651},{-223,651},{-226,651},{-227,652},{-224,653},{-229,653},{-228,653},{-214,658},{-197,659},{-184,660},{-196,660},{-215,660},{-228,660},{-228,661},{-178,662},{-179,662}}}, - {"America/Danmarkshavn",339,{{-191,779},{-191,780},{-200,776},{-201,775},{-204,776},{-201,776},{-213,763},{-214,763},{-176,778},{-178,776},{-182,776},{-179,779},{-200,779},{-193,779},{-192,778},{-204,779},{-181,779},{-198,779},{-199,779},{-195,779},{-196,779},{-197,779},{-192,779},{-205,776},{-206,776},{-207,776},{-191,777},{-189,778},{-189,777},{-191,778},{-198,774},{-196,774},{-202,774},{-203,774},{-202,775},{-203,775},{-199,775},{-198,775},{-197,775},{-198,776},{-197,776},{-200,775},{-189,779},{-190,779},{-216,762},{-216,763},{-208,763},{-210,763},{-211,764},{-213,764},{-214,764},{-212,764},{-200,760},{-203,759},{-204,759},{-201,760},{-199,760},{-198,760},{-200,763},{-201,762},{-201,763},{-205,762},{-206,763},{-205,763},{-200,761},{-212,763},{-204,763},{-203,763},{-207,763},{-202,763},{-204,764},{-206,764},{-207,764},{-203,764},{-202,764},{-205,764},{-213,765},{-214,765},{-211,765},{-212,765},{-194,795},{-196,794},{-194,793},{-197,791},{-188,792},{-200,790},{-197,789},{-199,788},{-211,788},{-208,787},{-213,786},{-208,786},{-210,785},{-213,781},{-217,781},{-217,780},{-218,779},{-215,779},{-220,776},{-214,776},{-217,775},{-212,776},{-214,777},{-214,778},{-208,780},{-193,777},{-189,776},{-207,777},{-206,777},{-209,776},{-209,775},{-204,775},{-211,775},{-200,774},{-208,774},{-195,772},{-185,773},{-182,772},{-182,769},{-186,767},{-199,769},{-220,770},{-219,770},{-221,770},{-220,769},{-205,769},{-217,769},{-208,768},{-217,766},{-222,768},{-224,768},{-222,767},{-227,767},{-224,765},{-222,766},{-219,766},{-217,765},{-226,765},{-216,764},{-217,763},{-204,761},{-211,763},{-199,762},{-198,761},{-219,760},{-200,759},{-195,757},{-229,759},{-227,797},{-204,765},{-206,765},{-221,767},{-202,768},{-204,768},{-203,768},{-196,768},{-197,768},{-196,769},{-201,768},{-201,769},{-206,769},{-190,773},{-191,773},{-185,767},{-186,768},{-195,768},{-207,767},{-207,768},{-210,767},{-198,768},{-199,767},{-199,768},{-189,767},{-187,766},{-188,765},{-185,759},{-192,765},{-188,766},{-192,767},{-207,765},{-205,765},{-206,766},{-208,764},{-209,764},{-208,765},{-186,780},{-215,765},{-202,765},{-203,765},{-189,766},{-190,766},{-207,766},{-208,766},{-209,765},{-210,765},{-215,767},{-197,767},{-203,766},{-214,766},{-212,766},{-211,766},{-210,766},{-216,766},{-215,766},{-188,767},{-186,766},{-198,767},{-213,767},{-212,767},{-211,767},{-214,767},{-209,767},{-208,767},{-211,780},{-213,778},{-214,779},{-212,780},{-194,779},{-194,780},{-188,779},{-189,780},{-190,780},{-213,780},{-214,780},{-202,781},{-186,781},{-188,781},{-195,781},{-195,780},{-203,781},{-201,781},{-204,781},{-210,780},{-209,780},{-204,780},{-200,780},{-199,780},{-201,780},{-197,780},{-198,780},{-192,780},{-193,780},{-205,780},{-206,780},{-188,780},{-186,782},{-187,782},{-185,782},{-198,782},{-199,782},{-190,783},{-189,783},{-193,781},{-192,781},{-191,783},{-191,784},{-195,784},{-196,784},{-197,784},{-188,784},{-189,784},{-190,784},{-189,785},{-192,784},{-184,785},{-185,785},{-183,786},{-186,786},{-184,786},{-193,784},{-204,782},{-205,782},{-188,782},{-191,782},{-193,782},{-194,782},{-195,782},{-206,783},{-198,783},{-194,783},{-196,782},{-196,783},{-192,783},{-193,783},{-191,781},{-194,781},{-208,781},{-209,781},{-210,781},{-209,782},{-189,781},{-190,781},{-190,782},{-189,782},{-203,782},{-205,781},{-207,782},{-182,787},{-182,786},{-183,787},{-209,787},{-207,787},{-205,788},{-206,787},{-206,788},{-178,789},{-179,789},{-190,790},{-176,790},{-177,790},{-180,790},{-176,792},{-174,791},{-177,789},{-179,790},{-178,790},{-192,789},{-178,787},{-179,787},{-190,788},{-180,788},{-180,787},{-190,787},{-193,787},{-196,787},{-191,789},{-192,788},{-193,788},{-194,787},{-179,788},{-190,793},{-192,794},{-192,793},{-193,793},{-193,794},{-192,791},{-193,791},{-193,792},{-191,792}}}, - {"Africa/Dar_es_Salaam",114,{{393,-58},{392,-58},{398,-79},{398,-78},{399,-76},{397,-80},{396,-80},{399,-69},{404,-104},{404,-103},{403,-103},{403,-102},{396,-91},{395,-91},{395,-90},{396,-83},{397,-81},{394,-86},{395,-86},{395,-85},{393,-78},{398,-80},{395,-79},{392,-59},{392,-63},{393,-63},{393,-67},{393,-64},{394,-64},{392,-67},{392,-66},{393,-66},{394,-60},{394,-62},{395,-62},{395,-65},{392,-62},{393,-57},{400,-102},{400,-108},{385,-114},{379,-113},{378,-116},{375,-117},{370,-116},{362,-117},{358,-114},{356,-116},{350,-116},{346,-110},{345,-100},{340,-95},{339,-97},{335,-96},{324,-91},{320,-91},{314,-86},{310,-86},{302,-70},{297,-64},{293,-48},{294,-44},{298,-45},{300,-43},{304,-36},{308,-33},{308,-30},{304,-29},{305,-25},{308,-24},{309,-21},{308,-16},{305,-11},{340,-10},{377,-31},{376,-35},{392,-47},{388,-60},{388,-64},{395,-70},{393,-75},{394,-78},{394,-80},{393,-83},{396,-89},{394,-89},{396,-94},{398,-99},{397,-100},{394,-74},{397,-55},{397,-54},{398,-54},{392,-52},{391,-52},{396,-52},{396,-54},{396,-55},{399,-52},{398,-52},{397,-52},{397,-49},{399,-49},{398,-51},{399,-50},{399,-51},{391,-51},{396,-51},{392,-51},{392,-50},{397,-50},{397,-51},{398,-49},{398,-50}}}, - {"Pacific/Majuro",151,{{1699,92},{1721,59},{1694,59},{1694,60},{1697,60},{1713,71},{1656,91},{1657,91},{1716,71},{1714,71},{1688,46},{1687,46},{1686,46},{1687,47},{1691,56},{1691,57},{1681,56},{1696,58},{1695,58},{1695,59},{1696,59},{1722,59},{1697,59},{1720,60},{1719,60},{1719,61},{1696,61},{1697,61},{1718,61},{1718,60},{1717,61},{1695,62},{1717,62},{1721,60},{1719,62},{1694,63},{1718,70},{1717,70},{1716,70},{1719,71},{1700,92},{1715,71},{1718,71},{1712,71},{1711,71},{1710,71},{1710,72},{1688,73},{1687,73},{1711,72},{1716,72},{1716,73},{1686,73},{1686,74},{1685,74},{1686,75},{1689,75},{1700,90},{1689,76},{1690,76},{1683,78},{1682,77},{1682,78},{1682,81},{1712,81},{1712,82},{1682,82},{1680,82},{1711,82},{1710,82},{1674,83},{1711,83},{1710,84},{1712,85},{1712,83},{1710,86},{1712,87},{1709,88},{1709,87},{1712,88},{1711,88},{1711,89},{1710,89},{1658,89},{1662,89},{1663,89},{1709,89},{1708,89},{1662,90},{1655,92},{1701,94},{1702,94},{1702,95},{1700,95},{1698,95},{1702,96},{1610,98},{1692,98},{1693,98},{1699,95},{1693,99},{1691,99},{1690,99},{1692,99},{1660,100},{1690,100},{1695,101},{1660,102},{1659,102},{1700,102},{1709,103},{1700,103},{1700,104},{1700,105},{1699,105},{1665,111},{1663,111},{1697,111},{1664,111},{1669,111},{1668,111},{1669,112},{1663,112},{1668,112},{1699,103},{1667,112},{1698,112},{1699,112},{1675,113},{1623,113},{1675,114},{1624,114},{1671,114},{1667,115},{1653,115},{1654,115},{1656,115},{1623,116},{1624,115},{1623,115},{1656,116},{1655,116},{1621,116},{1622,116},{1622,117},{1653,117},{1701,122},{1701,123},{1690,146},{1689,146},{1690,147}}}, - {"America/Port-au-Prince",42,{{-736,185},{-737,185},{-737,186},{-738,186},{-734,182},{-736,181},{-737,181},{-738,181},{-724,198},{-726,200},{-727,200},{-730,201},{-728,201},{-724,187},{-730,182},{-736,183},{-739,180},{-745,184},{-742,187},{-729,184},{-723,185},{-723,187},{-728,190},{-727,195},{-734,196},{-734,198},{-728,199},{-723,197},{-718,197},{-717,194},{-718,193},{-716,192},{-719,190},{-717,187},{-720,186},{-717,183},{-718,180},{-721,182},{-732,190},{-728,188},{-728,187},{-733,189}}}, - {"America/Montreal",460,{{-691,579},{-690,579},{-789,513},{-638,503},{-640,503},{-690,580},{-679,584},{-698,588},{-784,589},{-779,594},{-652,599},{-653,598},{-653,599},{-619,502},{-652,600},{-640,502},{-631,502},{-631,503},{-630,502},{-711,468},{-709,470},{-708,470},{-709,469},{-707,470},{-706,470},{-703,471},{-703,472},{-704,474},{-703,474},{-705,471},{-704,472},{-699,476},{-697,477},{-697,478},{-697,479},{-698,478},{-695,480},{-694,481},{-693,481},{-693,482},{-689,484},{-688,484},{-686,485},{-685,485},{-642,485},{-691,486},{-645,604},{-645,499},{-629,497},{-617,491},{-623,491},{-631,492},{-664,501},{-670,498},{-664,502},{-663,502},{-616,501},{-616,502},{-633,502},{-634,502},{-641,502},{-638,502},{-637,502},{-663,501},{-639,502},{-635,502},{-636,502},{-632,502},{-747,450},{-743,452},{-745,453},{-744,456},{-749,456},{-758,454},{-766,455},{-766,457},{-768,459},{-770,458},{-777,462},{-787,463},{-796,474},{-795,516},{-792,516},{-793,515},{-790,515},{-790,512},{-789,512},{-789,514},{-787,515},{-790,518},{-785,523},{-786,523},{-785,525},{-789,527},{-787,528},{-789,529},{-788,530},{-790,530},{-789,534},{-791,535},{-789,535},{-792,537},{-789,538},{-791,539},{-790,540},{-792,541},{-791,542},{-794,542},{-793,542},{-795,543},{-795,546},{-798,546},{-778,553},{-767,560},{-765,564},{-766,572},{-772,580},{-770,580},{-786,587},{-785,587},{-786,588},{-784,587},{-785,588},{-786,589},{-781,592},{-777,594},{-780,594},{-777,596},{-778,597},{-775,597},{-776,598},{-773,598},{-775,599},{-773,600},{-776,601},{-774,601},{-778,604},{-774,605},{-778,606},{-775,608},{-782,608},{-777,612},{-778,615},{-777,614},{-777,615},{-776,615},{-775,615},{-780,617},{-782,621},{-781,624},{-774,626},{-755,623},{-759,622},{-757,621},{-758,622},{-753,623},{-745,621},{-747,622},{-737,625},{-729,621},{-726,621},{-728,618},{-726,618},{-726,620},{-720,617},{-721,616},{-722,616},{-723,616},{-720,616},{-719,617},{-716,616},{-719,614},{-716,614},{-716,613},{-717,613},{-718,613},{-716,612},{-715,612},{-707,610},{-701,611},{-701,609},{-699,608},{-695,611},{-694,608},{-698,605},{-696,601},{-710,601},{-697,600},{-695,599},{-696,597},{-695,597},{-697,595},{-696,594},{-698,593},{-692,593},{-695,591},{-692,592},{-691,591},{-693,589},{-693,591},{-695,589},{-697,588},{-698,591},{-702,588},{-704,587},{-699,588},{-698,586},{-694,589},{-688,589},{-684,588},{-682,585},{-683,581},{-694,578},{-694,577},{-680,586},{-679,583},{-681,581},{-679,582},{-677,585},{-677,579},{-675,583},{-669,585},{-665,584},{-667,585},{-664,589},{-659,586},{-661,584},{-661,583},{-660,583},{-658,586},{-661,588},{-658,588},{-660,589},{-653,590},{-656,591},{-657,593},{-655,591},{-656,594},{-653,592},{-653,593},{-655,595},{-650,594},{-654,595},{-655,597},{-652,598},{-651,598},{-650,598},{-650,599},{-651,601},{-649,602},{-646,602},{-649,601},{-647,599},{-649,596},{-647,594},{-644,595},{-645,593},{-643,590},{-647,591},{-649,589},{-643,589},{-641,587},{-637,589},{-635,588},{-640,587},{-641,586},{-638,585},{-644,581},{-642,580},{-641,578},{-636,577},{-639,573},{-637,572},{-639,569},{-641,567},{-639,565},{-642,564},{-639,562},{-640,561},{-634,560},{-638,559},{-637,558},{-638,555},{-633,554},{-637,553},{-634,553},{-636,549},{-638,549},{-639,548},{-637,546},{-639,546},{-644,548},{-648,547},{-651,550},{-657,547},{-659,549},{-662,550},{-668,554},{-667,547},{-674,551},{-671,547},{-673,545},{-678,544},{-676,542},{-678,540},{-673,536},{-669,534},{-670,531},{-674,531},{-672,530},{-673,529},{-668,527},{-666,530},{-664,530},{-663,526},{-664,527},{-663,524},{-665,523},{-664,522},{-663,523},{-660,521},{-657,521},{-657,520},{-655,521},{-653,518},{-647,518},{-646,516},{-643,518},{-644,520},{-642,521},{-641,527},{-636,529},{-634,527},{-641,525},{-637,523},{-637,520},{-638,520},{-571,520},{-571,516},{-579,516},{-579,515},{-584,514},{-587,515},{-589,512},{-592,512},{-591,510},{-593,510},{-596,505},{-603,504},{-613,504},{-612,503},{-617,501},{-623,503},{-637,503},{-665,503},{-665,501},{-667,502},{-667,503},{-666,504},{-666,505},{-666,506},{-666,501},{-671,498},{-674,493},{-680,493},{-683,492},{-682,491},{-686,490},{-686,489},{-691,488},{-697,481},{-699,478},{-705,474},{-707,471},{-710,470},{-713,467},{-719,467},{-722,466},{-727,462},{-716,466},{-712,468},{-705,470},{-694,480},{-667,491},{-649,492},{-642,489},{-642,487},{-645,489},{-646,488},{-644,488},{-642,486},{-653,480},{-659,482},{-667,480},{-667,481},{-674,478},{-676,480},{-684,479},{-684,476},{-691,473},{-690,474},{-692,475},{-700,467},{-703,462},{-703,459},{-707,455},{-706,454},{-708,454},{-709,452},{-713,453},{-715,450},{-650,602},{-650,603},{-648,603},{-648,604},{-645,603},{-647,604},{-646,606},{-644,604},{-649,605},{-647,605},{-649,604},{-648,605},{-721,619},{-722,619},{-647,607},{-647,606},{-648,606},{-646,607},{-699,609},{-700,609},{-699,610},{-700,610},{-715,613},{-717,614},{-718,615},{-717,615},{-716,615},{-648,607},{-715,616},{-716,617},{-722,617},{-722,618},{-720,619},{-724,619},{-724,620},{-722,620},{-723,620},{-723,621},{-724,621},{-725,620},{-730,622},{-728,622},{-729,622},{-748,622},{-731,622},{-731,623},{-756,623},{-730,623},{-645,606}}}, - {"America/Panama",132,{{-818,72},{-818,73},{-822,75},{-822,91},{-822,92},{-820,91},{-821,91},{-821,92},{-813,75},{-811,76},{-810,76},{-811,75},{-812,75},{-812,76},{-800,76},{-818,74},{-819,75},{-817,76},{-816,73},{-816,77},{-811,77},{-812,77},{-818,78},{-812,78},{-817,78},{-815,77},{-816,78},{-811,78},{-818,79},{-812,79},{-811,79},{-829,80},{-823,81},{-820,80},{-821,79},{-821,80},{-816,91},{-815,91},{-823,92},{-824,92},{-822,93},{-823,93},{-822,94},{-823,94},{-788,95},{-789,96},{-796,96},{-821,93},{-779,91},{-782,93},{-774,86},{-772,79},{-776,75},{-777,77},{-779,72},{-784,81},{-783,81},{-782,84},{-780,82},{-778,81},{-777,81},{-780,83},{-781,85},{-783,84},{-782,85},{-784,86},{-784,83},{-786,88},{-792,90},{-797,89},{-798,86},{-805,82},{-800,75},{-804,72},{-809,72},{-818,82},{-822,82},{-822,84},{-827,83},{-829,83},{-831,83},{-828,85},{-829,88},{-827,89},{-829,91},{-828,96},{-822,90},{-818,89},{-819,92},{-815,88},{-813,88},{-798,94},{-790,96},{-791,94},{-780,92},{-775,87},{-774,87},{-821,82},{-823,82},{-824,81},{-817,81},{-818,81},{-781,84},{-783,85},{-783,83},{-791,84},{-788,83},{-789,83},{-791,82},{-791,83},{-825,83},{-823,83},{-824,83},{-788,84},{-789,82},{-790,85},{-822,83},{-824,82},{-790,84},{-777,89},{-791,85},{-790,86},{-796,86},{-790,87},{-791,87},{-795,88},{-796,88},{-791,86},{-778,90},{-777,90},{-791,89},{-791,90}}}, - {"America/Sitka",402,{{-1364,578},{-1354,571},{-1340,569},{-1341,569},{-1350,565},{-1348,567},{-1351,566},{-1350,568},{-1351,567},{-1352,567},{-1353,568},{-1354,569},{-1351,569},{-1354,570},{-1351,570},{-1353,573},{-1357,574},{-1355,574},{-1356,574},{-1355,575},{-1348,573},{-1346,567},{-1347,567},{-1348,565},{-1346,565},{-1347,564},{-1346,564},{-1347,563},{-1346,563},{-1347,562},{-1307,547},{-1307,548},{-1354,576},{-1306,547},{-1321,547},{-1309,554},{-1309,555},{-1315,555},{-1315,554},{-1321,554},{-1327,555},{-1326,555},{-1318,555},{-1332,555},{-1331,555},{-1324,555},{-1323,555},{-1337,554},{-1337,555},{-1338,554},{-1336,555},{-1334,555},{-1334,556},{-1333,555},{-1310,553},{-1310,554},{-1309,553},{-1326,553},{-1316,553},{-1317,553},{-1331,554},{-1322,554},{-1334,554},{-1335,554},{-1355,576},{-1356,576},{-1333,554},{-1332,554},{-1336,554},{-1335,555},{-1335,548},{-1335,549},{-1325,549},{-1315,550},{-1316,550},{-1325,550},{-1327,550},{-1313,550},{-1328,550},{-1312,550},{-1329,551},{-1329,550},{-1312,551},{-1323,548},{-1324,548},{-1313,549},{-1320,549},{-1324,549},{-1330,548},{-1329,548},{-1323,549},{-1312,549},{-1315,549},{-1331,550},{-1332,552},{-1331,553},{-1327,547},{-1327,551},{-1328,552},{-1329,552},{-1314,552},{-1315,553},{-1330,553},{-1330,552},{-1333,553},{-1332,553},{-1335,553},{-1334,553},{-1318,553},{-1317,551},{-1319,554},{-1337,553},{-1336,552},{-1309,556},{-1337,556},{-1332,556},{-1317,555},{-1317,556},{-1336,556},{-1331,556},{-1334,557},{-1335,556},{-1336,557},{-1335,557},{-1335,558},{-1334,558},{-1337,558},{-1333,558},{-1318,558},{-1318,559},{-1317,558},{-1317,559},{-1316,559},{-1323,558},{-1323,559},{-1324,558},{-1324,559},{-1337,559},{-1334,559},{-1335,559},{-1314,560},{-1315,559},{-1333,559},{-1359,573},{-1358,573},{-1362,576},{-1357,577},{-1356,577},{-1361,576},{-1360,576},{-1363,577},{-1362,577},{-1363,578},{-1359,574},{-1355,568},{-1356,568},{-1356,569},{-1355,569},{-1354,568},{-1353,567},{-1350,567},{-1352,568},{-1353,570},{-1341,570},{-1340,571},{-1348,571},{-1328,570},{-1332,571},{-1356,572},{-1355,572},{-1355,571},{-1355,573},{-1354,572},{-1358,570},{-1357,572},{-1357,573},{-1356,571},{-1356,573},{-1349,573},{-1350,574},{-1348,574},{-1339,569},{-1338,569},{-1343,559},{-1342,559},{-1341,559},{-1343,558},{-1344,559},{-1339,558},{-1339,559},{-1338,559},{-1359,580},{-1353,577},{-1354,577},{-1349,578},{-1348,575},{-1351,575},{-1358,578},{-1358,574},{-1360,575},{-1359,576},{-1360,578},{-1350,566},{-1337,568},{-1337,567},{-1329,569},{-1341,560},{-1331,560},{-1327,560},{-1324,557},{-1326,557},{-1321,555},{-1326,556},{-1327,554},{-1323,554},{-1325,554},{-1325,553},{-1321,553},{-1323,552},{-1324,551},{-1320,553},{-1320,551},{-1323,550},{-1320,550},{-1321,549},{-1320,548},{-1321,548},{-1320,547},{-1323,547},{-1326,550},{-1325,551},{-1326,551},{-1329,553},{-1329,555},{-1329,556},{-1331,559},{-1333,562},{-1336,562},{-1336,564},{-1332,563},{-1314,559},{-1312,552},{-1313,552},{-1312,553},{-1312,554},{-1313,554},{-1314,556},{-1314,554},{-1318,554},{-1315,557},{-1317,557},{-1315,558},{-1318,566},{-1301,561},{-1300,559},{-1302,557},{-1300,553},{-1305,548},{-1306,548},{-1305,549},{-1306,550},{-1307,550},{-1308,548},{-1310,551},{-1305,553},{-1307,551},{-1311,551},{-1306,553},{-1307,555},{-1306,556},{-1309,557},{-1307,557},{-1310,558},{-1308,558},{-1308,559},{-1312,560},{-1318,557},{-1320,557},{-1320,555},{-1321,556},{-1320,558},{-1321,558},{-1319,560},{-1320,562},{-1316,562},{-1315,562},{-1319,562},{-1324,565},{-1322,567},{-1332,559},{-1332,558},{-1326,560},{-1320,560},{-1321,560},{-1333,560},{-1334,560},{-1322,560},{-1322,559},{-1320,561},{-1335,560},{-1338,560},{-1335,561},{-1336,561},{-1333,561},{-1337,561},{-1331,561},{-1330,560},{-1329,561},{-1329,560},{-1326,561},{-1325,561},{-1330,561},{-1340,564},{-1341,565},{-1341,564},{-1318,567},{-1319,566},{-1323,566},{-1323,567},{-1325,565},{-1331,565},{-1326,565},{-1325,566},{-1330,566},{-1330,565},{-1343,566},{-1342,566},{-1337,566},{-1332,567},{-1324,566},{-1331,566},{-1326,566},{-1325,567},{-1327,567},{-1329,565},{-1328,566},{-1330,568},{-1339,563},{-1340,563},{-1335,562},{-1329,562},{-1325,563},{-1324,563},{-1325,562},{-1321,561},{-1323,561},{-1324,560},{-1327,562},{-1330,562},{-1330,563},{-1331,563},{-1323,562},{-1336,563},{-1337,563},{-1337,562},{-1331,562},{-1325,564},{-1324,564},{-1337,564},{-1338,564},{-1330,564},{-1327,565},{-1326,564},{-1340,568},{-1339,568},{-1340,566},{-1339,566},{-1338,563},{-1340,561},{-1341,563},{-1343,562},{-1342,563},{-1343,563},{-1342,564},{-1340,565},{-1341,566},{-1344,568},{-1341,568},{-1342,569},{-1338,565},{-1326,567},{-1338,571},{-1331,570},{-1329,566},{-1334,568},{-1337,569},{-1340,570},{-1326,576},{-1324,574},{-1322,572},{-1324,571},{-1320,570},{-1321,569},{-1321,568},{-1324,568},{-1328,568},{-1329,570},{-1328,571},{-1335,572},{-1331,572},{-1327,574},{-1324,573}}}, - {"Asia/Ho_Chi_Minh",254,{{1049,84},{1048,84},{1085,160},{1084,160},{1085,159},{1093,133},{1094,136},{1093,136},{1091,154},{1092,154},{1092,124},{1094,125},{1093,125},{1093,126},{1094,126},{1093,127},{1094,127},{1089,105},{1089,106},{1090,105},{1088,112},{1092,118},{1092,119},{1093,118},{1093,122},{1092,122},{1094,123},{1094,124},{1091,124},{1045,101},{1045,102},{1071,104},{1061,86},{1067,87},{1065,87},{1066,87},{1066,88},{1067,88},{1045,89},{1045,90},{1035,93},{1044,96},{1044,97},{1043,97},{1046,98},{1047,98},{1040,99},{1040,100},{1048,99},{1048,100},{1049,100},{1091,100},{1068,102},{1070,105},{1070,104},{1043,103},{1046,100},{1045,100},{1039,103},{1038,104},{1040,104},{1041,100},{1082,162},{1073,172},{1078,163},{1079,163},{1079,164},{1076,166},{1065,181},{1060,188},{1058,188},{1058,193},{1059,193},{1059,194},{1059,198},{1062,200},{1077,201},{1065,202},{1066,202},{1066,206},{1075,208},{1075,207},{1071,208},{1071,207},{1074,207},{1074,208},{1058,92},{1055,91},{1051,86},{1049,86},{1047,86},{1050,88},{1048,88},{1049,98},{1051,99},{1048,102},{1046,101},{1044,104},{1049,105},{1051,107},{1051,110},{1054,108},{1058,110},{1059,109},{1062,108},{1062,111},{1059,113},{1059,117},{1060,118},{1064,117},{1064,120},{1075,123},{1076,135},{1073,141},{1076,149},{1075,150},{1077,153},{1072,157},{1075,161},{1070,163},{1068,165},{1067,165},{1066,170},{1058,177},{1055,182},{1052,183},{1051,187},{1039,193},{1041,195},{1040,197},{1047,196},{1050,200},{1046,204},{1044,204},{1046,207},{1041,210},{1037,207},{1032,209},{1028,213},{1030,217},{1028,218},{1027,217},{1021,224},{1025,228},{1030,224},{1033,228},{1035,226},{1036,228},{1040,225},{1041,228},{1043,228},{1044,227},{1047,228},{1048,231},{1053,234},{1059,229},{1062,230},{1068,228},{1066,225},{1067,220},{1070,219},{1074,216},{1078,217},{1080,215},{1074,213},{1074,210},{1072,209},{1069,210},{1069,209},{1068,210},{1066,210},{1068,207},{1065,205},{1059,200},{1058,196},{1056,190},{1059,185},{1058,184},{1059,184},{1063,181},{1064,181},{1065,177},{1066,174},{1080,163},{1082,160},{1082,161},{1083,161},{1085,157},{1089,152},{1093,139},{1092,134},{1095,129},{1094,128},{1092,126},{1093,124},{1093,119},{1091,119},{1092,117},{1090,115},{1090,114},{1073,104},{1067,105},{1068,101},{1066,100},{1067,99},{1065,98},{1065,96},{1063,96},{1062,94},{1068,208},{1073,208},{1073,209},{1072,208},{1070,208},{1070,207},{1069,208},{1068,209},{1067,209},{1071,209},{1070,209},{1078,210},{1079,210},{1076,211},{1075,211},{1078,211},{1077,209},{1077,210},{1067,210},{1071,210},{1072,210},{1076,210},{1075,210},{1075,209},{1076,209},{1074,209},{1077,212},{1073,210},{1076,212},{1070,210},{1080,212},{1077,213},{1078,213},{1077,214},{1078,214},{1079,214},{1080,214},{1079,213},{1081,215},{1079,212},{1074,211},{1074,212},{1075,213},{1077,211},{1076,213}}}, - {"Asia/Jakarta",712,{{1104,-59},{1128,-58},{1158,-71},{1006,29},{1005,29},{1042,1},{1042,2},{1029,8},{1046,8},{1115,-83},{1122,-83},{1116,-84},{1163,-70},{1162,-70},{1162,-69},{1163,-69},{1053,-67},{1052,-67},{1052,-66},{1051,-66},{1053,-65},{1054,-62},{1055,-61},{1054,-61},{1053,-61},{1106,-82},{1139,-86},{1137,-85},{1133,-85},{1133,-84},{1134,-85},{1127,-85},{1127,-84},{1117,-84},{1118,-84},{1122,-84},{1119,-83},{1114,-83},{1110,-83},{1144,-56},{1144,-55},{1145,-55},{1144,-54},{1102,-58},{1102,-57},{1103,-57},{1103,-58},{1104,-57},{1128,-59},{1106,-59},{1106,-58},{1104,-58},{1105,-58},{1105,-59},{1126,-59},{1126,-58},{1127,-57},{1127,-58},{1090,-78},{1088,-77},{1089,-77},{1132,-77},{1133,-77},{1132,-73},{1158,-72},{1159,-72},{1148,-71},{1055,-70},{1056,-70},{1058,-70},{1058,-69},{1157,-71},{1157,-70},{1156,-71},{1156,-70},{1159,-70},{1155,-70},{1153,-70},{1156,-69},{1154,-70},{1147,-72},{1137,-72},{1137,-73},{1140,-72},{1141,-72},{1139,-72},{1138,-72},{1131,-72},{1146,-72},{1145,-72},{1145,-71},{1147,-71},{1146,-71},{1126,-70},{1126,-69},{1141,-71},{1140,-71},{1139,-71},{1139,-70},{1135,-72},{1127,-72},{1127,-71},{1129,-69},{1141,-69},{1144,-72},{1143,-71},{1144,-71},{1145,-70},{1142,-70},{1144,-70},{1158,-70},{1158,-69},{1159,-69},{1104,-69},{1154,-69},{1155,-69},{1004,-32},{1005,-32},{1005,-31},{1152,-69},{1038,-51},{1007,-35},{1006,-35},{1084,-33},{1084,-32},{1003,-33},{1006,-33},{1004,-33},{1005,-33},{1076,-32},{1003,-32},{1002,-31},{1003,-31},{1075,-32},{1075,-33},{1083,-32},{1082,-32},{1062,-32},{1081,-32},{1065,-31},{1087,-26},{1086,-26},{1085,-25},{1084,-28},{1000,-28},{1000,-27},{1053,-12},{990,-18},{993,-17},{993,-19},{991,-19},{993,-18},{991,-18},{992,-19},{995,-21},{992,-15},{991,-14},{1004,-12},{1003,-12},{995,-22},{997,-24},{996,-21},{998,-23},{999,-24},{996,-20},{995,-20},{1001,-30},{1002,-30},{1002,-29},{1078,-31},{1079,-31},{1082,-31},{1083,-31},{1003,-28},{1005,-30},{1076,-31},{1076,-30},{1075,-30},{1075,-31},{1072,-30},{1071,-30},{1082,-30},{1067,-30},{1068,-29},{1069,-29},{1069,-30},{1076,-26},{1082,-27},{1080,-33},{1074,-30},{1074,-29},{1075,-29},{1076,-29},{1059,-60},{1058,-59},{1059,-59},{1057,-59},{1074,-28},{1067,-29},{1071,-29},{1070,-29},{1071,-28},{1080,-26},{1071,-24},{1079,-26},{1079,-25},{1075,-28},{1058,-24},{1001,-29},{1069,-28},{1068,-28},{1000,-25},{1002,-28},{1000,-29},{1048,-58},{1049,-58},{1052,-57},{1014,19},{1056,-17},{1058,-18},{1057,-15},{1059,-15},{1063,-24},{1068,-26},{1066,-29},{1067,-31},{1059,-28},{1058,-21},{1051,-21},{1054,-16},{1056,-15},{1055,-59},{1055,-60},{1084,-59},{1062,-59},{1061,-59},{1052,-56},{1053,-56},{1024,-55},{1024,-54},{1063,-58},{1053,-58},{1058,-58},{1055,-58},{1052,-58},{1125,-69},{1128,-73},{1127,-75},{1129,-77},{1133,-78},{1140,-76},{1144,-78},{1144,-85},{1146,-88},{1132,-83},{1107,-82},{1102,-79},{1090,-77},{1089,-76},{1084,-78},{1078,-77},{1074,-75},{1064,-74},{1065,-70},{1060,-68},{1055,-69},{1052,-68},{1054,-66},{1055,-68},{1056,-65},{1058,-65},{1060,-59},{1062,-60},{1063,-59},{1070,-61},{1070,-59},{1073,-60},{1077,-63},{1083,-62},{1087,-68},{1102,-69},{1104,-70},{1107,-65},{1109,-64},{1112,-67},{1115,-66},{1121,-69},{1022,-53},{1021,-54},{1091,21},{1089,23},{967,21},{966,21},{971,20},{971,21},{972,21},{1091,25},{1092,26},{1090,25},{1090,26},{1089,25},{1089,27},{1089,28},{972,14},{972,15},{973,15},{971,12},{973,8},{973,9},{974,8},{974,9},{1075,9},{1075,10},{1074,10},{1034,9},{1041,10},{1040,9},{1040,10},{1038,10},{1034,10},{1043,10},{1042,10},{1039,10},{1009,19},{1009,18},{1009,20},{1008,21},{1016,21},{1015,21},{1076,10},{1048,10},{1049,10},{1044,10},{1075,11},{1048,11},{1042,11},{1074,11},{1047,11},{988,17},{987,18},{988,18},{1014,17},{1014,18},{986,16},{985,16},{984,17},{986,17},{1033,10},{1034,11},{1039,11},{1038,11},{1033,11},{1041,12},{1020,16},{1025,15},{1025,12},{1021,15},{988,13},{1034,12},{1039,12},{1016,20},{1017,21},{1018,20},{1016,17},{1077,45},{980,45},{981,46},{1080,47},{1079,47},{1080,48},{951,56},{952,56},{952,55},{950,56},{951,57},{950,57},{953,58},{952,59},{954,59},{954,49},{976,52},{954,30},{972,23},{973,23},{967,22},{966,22},{972,22},{959,25},{960,25},{962,27},{957,27},{962,24},{962,23},{1063,26},{1001,26},{963,24},{965,24},{964,25},{964,26},{964,27},{958,26},{958,29},{1086,27},{1088,29},{1088,30},{1089,30},{1089,29},{1061,29},{1087,29},{1057,29},{1058,29},{1057,31},{1059,30},{1062,27},{1062,28},{1088,27},{1063,27},{1010,23},{974,23},{974,22},{975,22},{971,22},{973,22},{973,20},{1007,22},{1006,22},{1007,23},{1008,22},{1008,23},{974,24},{1059,24},{1088,31},{1084,38},{1080,39},{1079,39},{985,39},{985,40},{986,40},{982,41},{983,41},{982,42},{983,42},{1082,42},{1082,43},{1078,41},{1079,42},{1079,41},{1081,42},{1081,41},{1061,34},{1062,34},{1063,34},{1081,36},{1081,37},{1080,37},{1081,38},{1080,38},{1080,36},{1064,33},{1061,33},{1060,33},{1062,33},{1063,33},{1083,37},{1080,40},{1084,40},{1062,29},{1062,30},{1057,30},{1064,30},{1062,31},{1078,30},{1077,30},{1063,30},{1061,30},{1058,30},{1060,30},{1056,31},{1065,31},{1064,31},{1061,31},{1061,32},{1064,32},{1065,32},{1063,32},{1063,31},{1060,31},{1059,31},{1062,32},{1064,34},{1065,34},{1053,-11},{985,-6},{985,-5},{1042,-4},{989,-11},{990,-11},{988,-9},{993,-16},{992,-18},{989,-17},{986,-12},{987,-10},{1042,-11},{1042,-10},{978,-1},{979,-1},{982,-1},{982,0},{983,0},{982,1},{1043,-4},{1046,-5},{1045,-7},{1043,-7},{984,-3},{984,-2},{985,-4},{984,-6},{983,-5},{1058,-41},{1059,-49},{1053,-54},{1045,-55},{1047,-59},{1046,-59},{1037,-50},{1023,-40},{1022,-37},{1016,-32},{1009,-23},{1008,-19},{1004,-13},{1003,-9},{997,0},{991,3},{987,16},{978,23},{976,29},{969,37},{965,38},{955,46},{956,56},{964,52},{975,52},{979,49},{983,44},{981,41},{998,32},{1001,25},{1002,27},{1004,23},{1018,17},{1022,14},{1024,8},{1029,7},{1031,4},{1027,2},{1033,5},{1037,3},{1038,0},{1034,-2},{1038,-3},{1034,-5},{1034,-7},{1037,-10},{1044,-10},{1045,-19},{1049,-21},{1046,-24},{1047,-26},{1049,-23},{1056,-24},{1058,-29},{1060,-30},{1061,-32},{1058,-36},{1060,-38},{1035,-2},{1049,-1},{1044,-3},{1045,-3},{986,-3},{1041,-4},{1042,-3},{1048,-2},{1047,-1},{983,-1},{985,-1},{1045,1},{1045,0},{1046,1},{984,0},{1048,0},{1048,-1},{1047,0},{985,0},{1072,1},{986,1},{986,2},{989,1},{988,1},{1047,1},{1048,1},{1044,1},{1044,2},{1043,1},{1043,2},{1045,2},{1047,-2},{1050,-3},{1044,-2},{1046,0},{1045,3},{1044,3},{1043,3},{1046,3},{1046,4},{991,4},{1029,3},{1030,3},{1032,4},{1045,4},{1044,4},{1043,4},{1044,5},{1045,5},{1031,5},{1030,5},{1036,5},{1036,6},{1043,5},{1036,4},{1035,4},{1028,3},{993,2},{1071,6},{1070,6},{1070,7},{1037,6},{1042,5},{1042,6},{1038,6},{1038,5},{1031,6},{1030,6},{1030,7},{1041,6},{1031,7},{1043,6},{1042,7},{1076,9},{1074,9},{1046,7},{1047,7},{1037,7},{1033,6},{1032,5},{1032,7},{1033,7},{1043,7},{1035,6},{1035,7},{1036,7},{1038,7},{1028,8},{1047,8},{1048,7},{1031,8},{1034,6},{1035,8},{1042,8},{1043,8},{1044,7},{1048,8},{1045,8},{1045,7},{1040,8},{1037,8},{1039,8},{1038,8},{1034,8},{1041,8},{1037,9},{1044,8},{1047,9},{1046,9},{1038,9},{1045,9},{1044,9},{1042,9},{1041,9},{1028,10},{1025,11},{1033,9},{1035,9},{1049,9},{1048,9},{1039,9},{1043,12},{1046,12},{1045,10},{974,15},{979,10},{978,5},{971,14},{1029,11},{1031,10},{1032,8},{1026,10},{1024,13},{1024,9}}}, - {"America/Boise",29,{{-1110,424},{-1110,420},{-1170,420},{-1170,425},{-1182,424},{-1182,443},{-1180,444},{-1172,443},{-1172,445},{-1165,456},{-1168,458},{-1166,460},{-1163,459},{-1163,454},{-1162,454},{-1155,454},{-1152,456},{-1148,454},{-1147,454},{-1148,455},{-1143,455},{-1139,457},{-1135,449},{-1131,448},{-1129,444},{-1123,446},{-1115,445},{-1114,448},{-1110,445}}}, - {"Asia/Baghdad",46,{{480,300},{472,300},{466,291},{447,292},{421,311},{404,319},{392,322},{393,324},{390,323},{388,334},{410,344},{412,348},{414,365},{418,366},{428,374},{438,372},{441,373},{443,370},{448,372},{449,370},{448,368},{451,367},{450,365},{453,364},{454,360},{455,360},{458,358},{463,358},{460,357},{462,351},{459,351},{457,348},{457,345},{455,346},{454,345},{456,341},{454,340},{462,333},{461,330},{475,324},{479,318},{477,310},{480,310},{480,305},{486,299},{477,301}}}, - {"Africa/El_Aaiun",20,{{-160,236},{-160,235},{-120,260},{-120,235},{-128,234},{-131,231},{-130,213},{-169,213},{-171,208},{-170,218},{-168,222},{-165,223},{-157,239},{-160,237},{-149,247},{-145,261},{-136,267},{-132,277},{-87,277},{-87,260}}}, - {"Europe/Zagreb",162,{{163,424},{180,427},{179,427},{181,426},{178,427},{178,428},{174,428},{177,427},{173,428},{165,428},{167,429},{168,427},{168,428},{169,428},{155,421},{157,422},{158,422},{167,428},{143,446},{143,445},{144,445},{144,446},{146,445},{145,445},{146,444},{145,444},{149,445},{148,445},{150,444},{149,444},{142,446},{142,447},{143,447},{148,447},{146,447},{138,449},{137,449},{148,449},{145,450},{152,439},{153,439},{148,450},{147,449},{144,451},{146,452},{143,448},{147,448},{149,447},{148,448},{144,450},{145,446},{143,452},{154,440},{151,440},{152,440},{151,441},{150,442},{149,441},{149,442},{150,441},{151,442},{152,441},{151,443},{150,443},{147,443},{146,443},{148,442},{148,443},{147,444},{148,444},{150,445},{153,443},{147,447},{160,430},{169,429},{166,430},{172,429},{170,429},{155,431},{167,431},{165,434},{164,434},{169,433},{166,433},{164,432},{163,432},{172,431},{171,431},{162,434},{161,434},{161,435},{159,437},{158,437},{164,433},{163,434},{185,426},{185,424},{179,428},{170,430},{178,429},{157,430},{158,430},{161,430},{161,431},{163,431},{162,430},{155,437},{154,437},{157,438},{156,438},{153,438},{155,439},{152,438},{155,438},{154,438},{157,436},{156,437},{157,437},{154,439},{191,450},{189,449},{187,451},{183,451},{178,450},{165,452},{163,450},{158,452},{158,448},{161,445},{163,442},{172,435},{177,430},{176,429},{169,434},{160,435},{160,437},{158,438},{160,438},{160,439},{156,441},{150,446},{148,451},{146,453},{143,454},{139,448},{135,455},{144,455},{146,456},{148,455},{153,455},{153,457},{157,459},{156,462},{164,465},{179,458},{184,457},{189,459},{189,456},{191,455},{190,454},{194,452},{192,452}}}, - {"America/Santiago",1813,{{-682,-552},{-699,-552},{-718,-545},{-672,-558},{-671,-558},{-703,-550},{-668,-553},{-717,-544},{-692,-552},{-673,-560},{-673,-559},{-672,-560},{-670,-559},{-668,-558},{-694,-558},{-694,-557},{-695,-557},{-675,-559},{-674,-559},{-674,-558},{-672,-559},{-671,-559},{-673,-558},{-676,-559},{-676,-558},{-678,-558},{-675,-558},{-666,-553},{-666,-552},{-664,-552},{-665,-553},{-667,-553},{-710,-551},{-709,-552},{-709,-551},{-708,-551},{-701,-553},{-698,-553},{-707,-552},{-693,-553},{-692,-553},{-690,-553},{-678,-552},{-691,-553},{-694,-553},{-702,-553},{-701,-552},{-700,-553},{-697,-553},{-697,-552},{-700,-552},{-680,-553},{-679,-552},{-668,-552},{-668,-551},{-668,-550},{-702,-551},{-682,-551},{-683,-552},{-687,-552},{-688,-552},{-688,-551},{-706,-552},{-706,-551},{-684,-551},{-685,-551},{-689,-551},{-685,-552},{-683,-551},{-671,-550},{-669,-550},{-670,-550},{-668,-556},{-675,-556},{-673,-556},{-690,-556},{-689,-556},{-676,-556},{-676,-557},{-677,-557},{-727,-519},{-676,-555},{-677,-556},{-685,-556},{-675,-557},{-674,-557},{-697,-555},{-696,-555},{-681,-554},{-699,-554},{-700,-554},{-699,-553},{-696,-554},{-697,-554},{-692,-554},{-691,-554},{-698,-554},{-695,-555},{-690,-555},{-695,-554},{-690,-554},{-692,-555},{-692,-556},{-691,-556},{-691,-555},{-687,-556},{-688,-555},{-687,-555},{-686,-556},{-686,-555},{-685,-555},{-680,-556},{-680,-555},{-683,-556},{-683,-555},{-684,-555},{-693,-555},{-689,-555},{-684,-556},{-694,-555},{-670,-554},{-671,-553},{-689,-552},{-689,-553},{-723,-544},{-712,-550},{-711,-550},{-680,-549},{-672,-549},{-670,-551},{-672,-553},{-675,-552},{-678,-553},{-677,-552},{-681,-552},{-682,-550},{-684,-549},{-700,-550},{-700,-551},{-701,-551},{-701,-550},{-683,-550},{-699,-550},{-706,-550},{-704,-550},{-705,-550},{-683,-549},{-702,-542},{-703,-542},{-733,-542},{-733,-541},{-731,-542},{-731,-541},{-730,-542},{-730,-541},{-724,-542},{-728,-542},{-729,-542},{-725,-541},{-729,-541},{-728,-541},{-726,-542},{-727,-541},{-732,-541},{-732,-540},{-735,-541},{-734,-540},{-731,-539},{-730,-539},{-703,-541},{-704,-542},{-705,-541},{-703,-540},{-711,-541},{-719,-541},{-712,-541},{-712,-540},{-717,-541},{-711,-540},{-705,-540},{-730,-540},{-731,-540},{-723,-540},{-729,-540},{-723,-541},{-722,-541},{-722,-540},{-734,-539},{-729,-539},{-733,-539},{-721,-539},{-720,-539},{-722,-539},{-714,-549},{-715,-549},{-714,-550},{-713,-549},{-703,-549},{-714,-548},{-709,-548},{-713,-548},{-719,-547},{-718,-547},{-710,-547},{-710,-546},{-717,-546},{-713,-546},{-714,-547},{-713,-547},{-720,-547},{-718,-548},{-710,-548},{-712,-548},{-716,-548},{-716,-547},{-715,-547},{-711,-547},{-712,-547},{-720,-546},{-721,-547},{-717,-547},{-709,-549},{-721,-546},{-720,-545},{-719,-546},{-716,-545},{-692,-545},{-730,-545},{-731,-545},{-691,-544},{-722,-545},{-721,-545},{-713,-544},{-712,-544},{-714,-544},{-724,-545},{-724,-544},{-716,-544},{-721,-544},{-715,-544},{-719,-544},{-720,-544},{-718,-544},{-722,-544},{-696,-543},{-697,-543},{-728,-543},{-724,-543},{-716,-543},{-727,-543},{-727,-542},{-726,-543},{-723,-543},{-723,-542},{-717,-543},{-717,-542},{-722,-543},{-722,-542},{-720,-542},{-720,-543},{-699,-543},{-700,-543},{-721,-543},{-725,-543},{-721,-542},{-748,-512},{-748,-511},{-747,-511},{-725,-544},{-710,-543},{-718,-543},{-714,-543},{-715,-543},{-715,-542},{-713,-550},{-710,-550},{-707,-550},{-705,-552},{-695,-553},{-695,-552},{-685,-549},{-686,-552},{-690,-550},{-691,-551},{-682,-553},{-686,-553},{-687,-553},{-686,-554},{-680,-557},{-687,-554},{-692,-551},{-694,-552},{-693,-552},{-694,-554},{-695,-550},{-697,-549},{-691,-550},{-702,-550},{-701,-549},{-700,-549},{-708,-550},{-706,-549},{-705,-549},{-710,-549},{-702,-549},{-707,-548},{-706,-548},{-704,-549},{-707,-549},{-743,-509},{-703,-543},{-705,-542},{-719,-542},{-744,-509},{-750,-510},{-749,-510},{-749,-511},{-748,-510},{-750,-511},{-743,-516},{-711,-544},{-713,-543},{-712,-542},{-714,-541},{-716,-540},{-713,-540},{-710,-541},{-711,-543},{-725,-542},{-740,-512},{-751,-511},{-751,-512},{-750,-512},{-742,-512},{-742,-511},{-741,-511},{-744,-511},{-751,-510},{-727,-517},{-738,-514},{-747,-515},{-740,-515},{-740,-514},{-750,-514},{-744,-514},{-748,-514},{-747,-514},{-742,-514},{-745,-514},{-743,-514},{-739,-514},{-729,-519},{-738,-519},{-739,-517},{-739,-516},{-738,-517},{-744,-517},{-742,-513},{-741,-515},{-747,-513},{-746,-514},{-744,-513},{-745,-513},{-743,-513},{-746,-516},{-751,-515},{-748,-515},{-739,-515},{-749,-515},{-749,-516},{-750,-515},{-740,-516},{-747,-516},{-744,-516},{-746,-515},{-748,-516},{-745,-515},{-741,-514},{-741,-512},{-739,-513},{-741,-517},{-742,-516},{-741,-516},{-745,-512},{-747,-512},{-738,-513},{-737,-514},{-751,-513},{-737,-520},{-737,-519},{-744,-519},{-744,-520},{-745,-519},{-750,-513},{-749,-512},{-749,-513},{-744,-512},{-746,-511},{-746,-512},{-745,-511},{-743,-519},{-743,-510},{-748,-524},{-748,-523},{-749,-523},{-739,-523},{-736,-523},{-737,-523},{-738,-523},{-745,-523},{-742,-523},{-743,-523},{-744,-523},{-729,-518},{-730,-518},{-737,-518},{-736,-518},{-740,-518},{-741,-518},{-745,-518},{-746,-517},{-746,-518},{-749,-517},{-742,-518},{-735,-517},{-736,-517},{-738,-518},{-747,-518},{-747,-517},{-748,-517},{-727,-520},{-750,-520},{-742,-520},{-743,-520},{-741,-520},{-746,-520},{-739,-520},{-746,-519},{-747,-519},{-740,-519},{-739,-518},{-744,-518},{-741,-519},{-745,-517},{-738,-522},{-745,-516},{-750,-519},{-751,-518},{-750,-517},{-749,-518},{-729,-523},{-729,-522},{-745,-522},{-746,-523},{-746,-522},{-731,-521},{-732,-521},{-743,-521},{-733,-522},{-748,-522},{-744,-522},{-747,-522},{-747,-523},{-749,-522},{-743,-522},{-742,-522},{-750,-521},{-749,-521},{-740,-522},{-739,-522},{-745,-521},{-746,-521},{-748,-521},{-739,-521},{-740,-521},{-743,-517},{-742,-521},{-741,-521},{-747,-521},{-744,-521},{-731,-520},{-730,-521},{-740,-520},{-745,-520},{-747,-520},{-751,-520},{-749,-519},{-748,-519},{-748,-518},{-752,-516},{-753,-517},{-752,-513},{-739,-524},{-742,-524},{-743,-524},{-745,-524},{-746,-524},{-744,-524},{-747,-524},{-740,-524},{-741,-525},{-741,-524},{-743,-525},{-745,-525},{-736,-524},{-741,-522},{-737,-524},{-737,-537},{-737,-536},{-736,-536},{-736,-537},{-745,-472},{-741,-523},{-702,-539},{-721,-537},{-722,-537},{-734,-538},{-733,-538},{-721,-538},{-720,-538},{-725,-537},{-724,-537},{-738,-536},{-727,-536},{-732,-534},{-723,-537},{-724,-536},{-723,-536},{-728,-536},{-734,-536},{-709,-539},{-728,-539},{-744,-530},{-745,-530},{-742,-531},{-743,-533},{-742,-533},{-743,-532},{-742,-532},{-740,-527},{-739,-535},{-738,-534},{-741,-532},{-741,-533},{-744,-531},{-743,-531},{-740,-532},{-741,-531},{-740,-531},{-742,-526},{-740,-526},{-746,-529},{-746,-530},{-743,-529},{-741,-527},{-744,-526},{-742,-527},{-746,-485},{-746,-484},{-739,-534},{-718,-535},{-736,-534},{-729,-534},{-737,-534},{-734,-535},{-734,-534},{-729,-535},{-736,-535},{-738,-535},{-737,-535},{-728,-535},{-732,-535},{-729,-531},{-730,-531},{-731,-534},{-735,-536},{-735,-535},{-733,-535},{-733,-534},{-729,-537},{-727,-537},{-727,-535},{-724,-538},{-725,-540},{-728,-540},{-727,-539},{-728,-538},{-731,-538},{-733,-540},{-732,-537},{-736,-538},{-735,-537},{-731,-535},{-738,-531},{-738,-530},{-735,-530},{-734,-530},{-739,-530},{-732,-532},{-732,-531},{-718,-531},{-733,-531},{-734,-531},{-735,-531},{-723,-531},{-722,-531},{-731,-531},{-724,-531},{-719,-531},{-736,-443},{-735,-443},{-719,-532},{-737,-533},{-738,-533},{-737,-532},{-739,-532},{-738,-532},{-736,-532},{-734,-533},{-739,-533},{-725,-533},{-731,-533},{-730,-532},{-733,-532},{-739,-531},{-704,-530},{-704,-529},{-703,-529},{-706,-529},{-708,-529},{-706,-528},{-707,-529},{-726,-526},{-724,-530},{-726,-531},{-722,-532},{-726,-532},{-724,-533},{-727,-533},{-724,-535},{-725,-536},{-728,-532},{-727,-531},{-729,-530},{-730,-528},{-727,-527},{-726,-528},{-727,-529},{-724,-529},{-722,-526},{-714,-527},{-720,-531},{-747,-527},{-743,-530},{-741,-529},{-737,-531},{-736,-531},{-735,-533},{-736,-533},{-736,-530},{-736,-529},{-729,-528},{-735,-529},{-738,-529},{-736,-528},{-734,-529},{-739,-529},{-725,-528},{-737,-528},{-723,-527},{-724,-527},{-737,-527},{-737,-526},{-735,-527},{-736,-527},{-726,-527},{-725,-527},{-734,-527},{-733,-528},{-734,-528},{-735,-528},{-724,-528},{-733,-527},{-723,-539},{-716,-539},{-718,-540},{-716,-541},{-719,-540},{-719,-543},{-737,-525},{-745,-526},{-744,-525},{-707,-537},{-705,-536},{-707,-539},{-705,-543},{-709,-541},{-706,-539},{-704,-531},{-701,-529},{-704,-528},{-699,-528},{-694,-525},{-692,-527},{-688,-525},{-686,-527},{-686,-549},{-696,-548},{-697,-547},{-697,-548},{-698,-548},{-698,-547},{-699,-548},{-699,-547},{-702,-547},{-703,-548},{-704,-546},{-709,-546},{-713,-545},{-715,-546},{-716,-546},{-717,-545},{-715,-545},{-709,-545},{-708,-543},{-706,-544},{-707,-544},{-708,-546},{-703,-546},{-701,-546},{-701,-544},{-700,-544},{-702,-543},{-698,-546},{-698,-543},{-692,-544},{-694,-546},{-694,-547},{-691,-545},{-690,-545},{-700,-541},{-702,-538},{-693,-535},{-694,-534},{-702,-535},{-705,-534},{-727,-526},{-721,-526},{-723,-526},{-741,-526},{-729,-526},{-728,-526},{-723,-525},{-746,-525},{-742,-525},{-736,-525},{-740,-525},{-747,-525},{-738,-524},{-738,-527},{-739,-526},{-739,-525},{-755,-505},{-754,-504},{-753,-504},{-755,-504},{-755,-495},{-756,-495},{-756,-494},{-755,-494},{-755,-496},{-756,-496},{-754,-496},{-754,-495},{-753,-495},{-753,-496},{-754,-498},{-746,-470},{-746,-469},{-743,-468},{-744,-468},{-757,-492},{-754,-492},{-756,-492},{-753,-492},{-751,-462},{-736,-462},{-755,-466},{-752,-467},{-749,-462},{-750,-462},{-748,-461},{-737,-461},{-737,-460},{-740,-460},{-739,-461},{-739,-460},{-739,-459},{-740,-459},{-748,-459},{-738,-459},{-738,-458},{-739,-458},{-741,-459},{-741,-472},{-743,-472},{-742,-472},{-742,-471},{-744,-471},{-745,-471},{-743,-470},{-743,-471},{-752,-468},{-753,-468},{-753,-467},{-754,-467},{-736,-482},{-735,-482},{-741,-485},{-742,-485},{-742,-484},{-740,-484},{-743,-485},{-744,-486},{-743,-486},{-753,-485},{-753,-484},{-746,-486},{-745,-485},{-744,-485},{-745,-484},{-756,-484},{-743,-484},{-756,-483},{-744,-483},{-743,-483},{-743,-482},{-744,-482},{-753,-480},{-739,-480},{-753,-479},{-752,-479},{-746,-480},{-746,-479},{-745,-479},{-752,-477},{-752,-476},{-744,-477},{-744,-476},{-743,-476},{-742,-476},{-749,-477},{-749,-478},{-750,-478},{-751,-477},{-751,-479},{-750,-479},{-750,-480},{-752,-480},{-744,-478},{-742,-478},{-738,-479},{-747,-479},{-748,-478},{-742,-434},{-748,-480},{-751,-478},{-737,-479},{-754,-478},{-752,-478},{-736,-478},{-736,-479},{-739,-479},{-738,-478},{-747,-478},{-746,-478},{-737,-478},{-745,-478},{-741,-478},{-753,-477},{-754,-477},{-746,-481},{-748,-481},{-750,-481},{-751,-481},{-749,-482},{-750,-482},{-749,-483},{-748,-482},{-750,-485},{-753,-481},{-746,-482},{-745,-482},{-731,-417},{-730,-417},{-743,-434},{-745,-481},{-736,-481},{-737,-481},{-739,-481},{-738,-481},{-755,-480},{-751,-480},{-752,-481},{-747,-481},{-747,-480},{-738,-480},{-737,-480},{-740,-480},{-741,-480},{-748,-479},{-757,-491},{-756,-491},{-756,-490},{-755,-491},{-755,-488},{-756,-488},{-754,-488},{-729,-417},{-730,-427},{-730,-426},{-731,-426},{-750,-486},{-748,-484},{-748,-486},{-748,-483},{-745,-487},{-735,-371},{-736,-370},{-735,-370},{-731,-366},{-730,-366},{-891,-323},{-789,-336},{-788,-336},{-788,-337},{-790,-337},{-715,-319},{-807,-337},{-807,-338},{-808,-338},{-808,-337},{-750,-458},{-752,-485},{-753,-483},{-755,-484},{-754,-484},{-754,-483},{-754,-482},{-755,-482},{-755,-481},{-751,-484},{-751,-485},{-751,-486},{-752,-487},{-748,-476},{-725,-417},{-724,-417},{-730,-416},{-730,-415},{-734,-399},{-738,-417},{-739,-384},{-740,-384},{-740,-383},{-733,-425},{-734,-425},{-732,-425},{-731,-424},{-732,-424},{-735,-424},{-734,-424},{-733,-424},{-729,-419},{-726,-421},{-726,-420},{-725,-421},{-725,-420},{-726,-422},{-725,-422},{-732,-423},{-734,-422},{-735,-421},{-734,-421},{-733,-423},{-731,-423},{-732,-422},{-731,-419},{-732,-419},{-731,-418},{-732,-418},{-733,-418},{-736,-418},{-730,-419},{-730,-418},{-733,-417},{-712,-283},{-799,-264},{-710,-273},{-710,-272},{-716,-290},{-713,-285},{-801,-263},{-706,-234},{-707,-262},{-707,-261},{-716,-296},{-715,-296},{-715,-293},{-715,-292},{-730,-436},{-742,-435},{-736,-433},{-736,-432},{-737,-433},{-737,-432},{-734,-431},{-735,-431},{-735,-430},{-733,-430},{-736,-429},{-735,-429},{-734,-429},{-736,-431},{-735,-432},{-737,-431},{-731,-428},{-731,-427},{-728,-427},{-729,-427},{-733,-427},{-734,-426},{-732,-426},{-736,-427},{-737,-426},{-736,-426},{-729,-428},{-737,-434},{-738,-434},{-738,-433},{-735,-427},{-735,-426},{-733,-426},{-736,-425},{-737,-424},{-737,-458},{-736,-458},{-747,-458},{-741,-458},{-740,-458},{-745,-458},{-746,-458},{-744,-458},{-743,-458},{-733,-457},{-733,-456},{-749,-457},{-749,-456},{-748,-456},{-739,-418},{-739,-419},{-735,-418},{-736,-420},{-738,-425},{-737,-425},{-737,-429},{-744,-432},{-742,-429},{-742,-423},{-741,-418},{-737,-462},{-730,-454},{-738,-457},{-738,-456},{-737,-457},{-748,-457},{-741,-457},{-742,-457},{-745,-457},{-739,-457},{-742,-458},{-743,-457},{-746,-457},{-747,-457},{-745,-456},{-729,-455},{-728,-454},{-729,-454},{-736,-454},{-735,-454},{-738,-454},{-737,-454},{-741,-454},{-742,-454},{-741,-456},{-741,-455},{-736,-456},{-736,-455},{-739,-456},{-740,-457},{-740,-455},{-743,-455},{-744,-455},{-742,-456},{-742,-455},{-741,-453},{-742,-453},{-745,-455},{-744,-454},{-740,-454},{-738,-455},{-739,-454},{-739,-455},{-735,-451},{-735,-452},{-742,-452},{-743,-452},{-736,-452},{-737,-450},{-735,-450},{-734,-452},{-734,-451},{-733,-451},{-743,-451},{-744,-451},{-744,-450},{-736,-451},{-734,-450},{-746,-450},{-736,-450},{-743,-450},{-734,-453},{-733,-453},{-746,-453},{-736,-453},{-735,-453},{-737,-453},{-738,-453},{-743,-454},{-743,-453},{-745,-453},{-741,-452},{-747,-453},{-746,-452},{-744,-453},{-745,-452},{-744,-452},{-742,-450},{-751,-449},{-752,-448},{-751,-448},{-750,-449},{-748,-447},{-748,-446},{-747,-446},{-737,-448},{-738,-448},{-736,-447},{-737,-447},{-739,-446},{-737,-445},{-744,-448},{-743,-448},{-745,-448},{-744,-447},{-740,-449},{-741,-448},{-742,-448},{-739,-448},{-740,-448},{-736,-448},{-740,-447},{-739,-447},{-738,-447},{-745,-447},{-747,-447},{-746,-446},{-736,-446},{-742,-447},{-744,-446},{-733,-446},{-751,-499},{-740,-446},{-728,-444},{-729,-444},{-745,-444},{-744,-444},{-731,-446},{-732,-446},{-731,-445},{-733,-445},{-734,-445},{-739,-445},{-735,-445},{-743,-446},{-742,-445},{-741,-446},{-742,-446},{-738,-445},{-736,-445},{-732,-443},{-732,-442},{-733,-443},{-737,-443},{-731,-443},{-739,-443},{-738,-443},{-736,-442},{-738,-442},{-742,-442},{-743,-443},{-744,-443},{-743,-442},{-742,-443},{-741,-442},{-741,-443},{-737,-442},{-744,-442},{-739,-442},{-737,-441},{-733,-444},{-740,-444},{-736,-440},{-737,-439},{-736,-439},{-738,-444},{-739,-444},{-731,-444},{-737,-444},{-736,-444},{-743,-444},{-746,-445},{-742,-444},{-741,-445},{-740,-445},{-732,-444},{-730,-444},{-741,-444},{-740,-443},{-735,-449},{-746,-449},{-744,-449},{-743,-449},{-740,-450},{-742,-449},{-739,-450},{-733,-449},{-734,-449},{-737,-449},{-736,-449},{-739,-449},{-738,-450},{-733,-440},{-732,-439},{-731,-439},{-732,-440},{-738,-440},{-739,-440},{-738,-439},{-741,-440},{-741,-439},{-742,-439},{-729,-445},{-727,-445},{-730,-446},{-728,-447},{-732,-449},{-734,-448},{-732,-448},{-734,-447},{-734,-446},{-743,-441},{-743,-440},{-732,-441},{-737,-440},{-742,-440},{-730,-438},{-735,-437},{-740,-438},{-748,-436},{-747,-435},{-746,-436},{-748,-437},{-739,-439},{-738,-438},{-740,-439},{-739,-438},{-733,-441},{-739,-441},{-741,-441},{-740,-441},{-742,-441},{-744,-441},{-738,-441},{-740,-442},{-735,-442},{-735,-441},{-736,-441},{-735,-440},{-741,-508},{-741,-509},{-742,-508},{-742,-509},{-743,-508},{-750,-508},{-751,-508},{-749,-508},{-745,-508},{-744,-508},{-747,-507},{-747,-509},{-749,-509},{-748,-508},{-748,-507},{-749,-507},{-745,-505},{-747,-508},{-746,-508},{-753,-507},{-752,-507},{-752,-508},{-746,-507},{-751,-506},{-750,-507},{-751,-507},{-750,-506},{-746,-506},{-745,-509},{-734,-491},{-736,-495},{-734,-498},{-736,-503},{-731,-508},{-727,-506},{-723,-507},{-723,-510},{-724,-511},{-723,-513},{-724,-516},{-720,-519},{-720,-520},{-700,-520},{-684,-523},{-684,-524},{-692,-522},{-697,-525},{-709,-527},{-707,-528},{-709,-529},{-710,-534},{-710,-538},{-713,-539},{-725,-534},{-721,-532},{-721,-534},{-723,-534},{-718,-534},{-721,-535},{-717,-534},{-718,-533},{-717,-532},{-711,-529},{-716,-526},{-724,-525},{-729,-525},{-730,-527},{-731,-529},{-732,-529},{-733,-529},{-732,-528},{-730,-526},{-731,-526},{-731,-525},{-732,-524},{-734,-526},{-735,-525},{-736,-522},{-738,-520},{-733,-523},{-731,-523},{-727,-521},{-728,-520},{-725,-522},{-730,-525},{-726,-525},{-727,-524},{-724,-519},{-725,-518},{-727,-516},{-731,-515},{-730,-512},{-731,-512},{-733,-515},{-725,-517},{-733,-516},{-732,-519},{-733,-519},{-733,-517},{-734,-516},{-735,-520},{-734,-521},{-737,-516},{-738,-516},{-736,-516},{-738,-512},{-737,-513},{-736,-512},{-738,-511},{-737,-512},{-740,-511},{-741,-510},{-739,-509},{-738,-510},{-738,-507},{-734,-507},{-737,-506},{-736,-505},{-736,-504},{-740,-509},{-742,-506},{-741,-506},{-743,-505},{-739,-506},{-741,-504},{-740,-504},{-742,-503},{-744,-504},{-747,-502},{-744,-500},{-739,-503},{-739,-501},{-740,-500},{-738,-499},{-738,-498},{-743,-499},{-743,-498},{-740,-498},{-740,-497},{-743,-496},{-739,-496},{-739,-497},{-737,-497},{-737,-498},{-739,-495},{-741,-495},{-740,-493},{-738,-494},{-738,-493},{-739,-492},{-740,-491},{-742,-492},{-742,-495},{-743,-494},{-744,-494},{-743,-492},{-745,-490},{-743,-489},{-744,-488},{-741,-487},{-740,-486},{-740,-485},{-739,-484},{-744,-480},{-743,-480},{-741,-482},{-736,-483},{-734,-482},{-733,-482},{-733,-480},{-736,-480},{-735,-479},{-737,-476},{-739,-478},{-747,-477},{-745,-475},{-741,-476},{-745,-474},{-740,-472},{-740,-470},{-746,-468},{-744,-469},{-747,-469},{-751,-467},{-750,-465},{-755,-467},{-754,-469},{-757,-468},{-756,-466},{-747,-462},{-747,-460},{-750,-461},{-751,-459},{-745,-459},{-744,-460},{-740,-462},{-740,-465},{-738,-466},{-733,-460},{-737,-463},{-735,-458},{-731,-457},{-732,-453},{-732,-452},{-733,-452},{-727,-447},{-726,-445},{-733,-442},{-731,-441},{-729,-438},{-731,-437},{-729,-436},{-731,-434},{-727,-429},{-728,-425},{-725,-426},{-728,-423},{-724,-425},{-724,-420},{-723,-415},{-726,-417},{-729,-415},{-737,-416},{-738,-416},{-739,-411},{-737,-400},{-735,-398},{-734,-397},{-732,-394},{-735,-387},{-735,-381},{-737,-373},{-736,-372},{-734,-373},{-732,-371},{-732,-368},{-730,-367},{-728,-360},{-726,-358},{-726,-356},{-722,-351},{-720,-341},{-716,-335},{-718,-331},{-716,-330},{-714,-324},{-717,-306},{-716,-303},{-714,-302},{-713,-299},{-715,-290},{-712,-284},{-710,-277},{-709,-276},{-708,-271},{-706,-263},{-707,-258},{-705,-254},{-706,-245},{-704,-236},{-705,-235},{-706,-235},{-706,-232},{-703,-229},{-701,-214},{-704,-183},{-699,-182},{-698,-180},{-698,-177},{-695,-175},{-693,-180},{-691,-181},{-690,-189},{-684,-194},{-687,-197},{-685,-199},{-688,-201},{-688,-204},{-684,-206},{-685,-209},{-682,-213},{-679,-228},{-672,-228},{-670,-230},{-673,-240},{-684,-245},{-686,-247},{-683,-251},{-686,-254},{-684,-262},{-686,-265},{-683,-269},{-685,-272},{-688,-271},{-691,-279},{-696,-284},{-698,-291},{-700,-293},{-699,-301},{-698,-302},{-700,-304},{-702,-303},{-703,-310},{-705,-312},{-706,-316},{-704,-318},{-702,-320},{-704,-321},{-700,-329},{-700,-333},{-699,-332},{-697,-334},{-699,-337},{-698,-342},{-700,-343},{-704,-351},{-706,-353},{-704,-353},{-703,-358},{-704,-361},{-706,-361},{-707,-364},{-710,-365},{-712,-368},{-712,-379},{-708,-386},{-714,-389},{-715,-396},{-717,-396},{-716,-399},{-718,-402},{-717,-404},{-719,-407},{-717,-421},{-720,-421},{-721,-423},{-721,-429},{-717,-432},{-719,-435},{-716,-437},{-718,-438},{-717,-439},{-718,-441},{-718,-444},{-711,-445},{-713,-448},{-721,-448},{-720,-449},{-716,-450},{-713,-453},{-718,-456},{-716,-460},{-719,-461},{-716,-467},{-719,-468},{-719,-472},{-720,-472},{-725,-477},{-723,-483},{-726,-485},{-725,-488},{-731,-491},{-743,-506},{-747,-506},{-741,-505},{-745,-506},{-749,-506},{-749,-505},{-748,-506},{-743,-503},{-746,-503},{-752,-502},{-752,-503},{-750,-502},{-749,-501},{-749,-502},{-748,-502},{-747,-503},{-749,-503},{-748,-503},{-745,-504},{-747,-494},{-749,-493},{-750,-499},{-750,-504},{-751,-504},{-750,-503},{-749,-504},{-747,-505},{-751,-505},{-750,-505},{-753,-508},{-755,-508},{-754,-507},{-755,-507},{-753,-506},{-752,-500},{-752,-499},{-745,-507},{-744,-505},{-742,-507},{-744,-507},{-752,-505},{-753,-505},{-748,-505},{-747,-504},{-752,-504},{-750,-497},{-750,-496},{-749,-496},{-749,-497},{-745,-496},{-745,-495},{-744,-495},{-749,-499},{-749,-498},{-748,-498},{-755,-497},{-756,-497},{-753,-499},{-754,-497},{-756,-499},{-744,-496},{-743,-495},{-747,-501},{-748,-501},{-750,-501},{-754,-502},{-751,-502},{-753,-501},{-754,-500},{-752,-501},{-753,-500},{-751,-500},{-750,-500},{-744,-493},{-752,-493},{-752,-492},{-751,-493},{-751,-492},{-750,-488},{-747,-487},{-747,-489},{-745,-488},{-746,-490},{-746,-497},{-744,-497},{-744,-499},{-746,-499},{-745,-500},{-746,-501},{-749,-500},{-746,-500},{-748,-499},{-746,-498},{-747,-497},{-747,-496},{-749,-495},{-746,-494},{-746,-493},{-751,-496},{-753,-497},{-752,-497},{-751,-497},{-752,-496},{-752,-495},{-755,-493},{-753,-493},{-754,-494},{-753,-494},{-751,-495},{-752,-494},{-751,-494},{-750,-494},{-750,-493},{-749,-494},{-748,-491},{-749,-490},{-747,-490},{-750,-490},{-748,-488},{-749,-488},{-750,-489},{-748,-492},{-749,-492},{-753,-491},{-752,-491},{-744,-490},{-751,-489},{-745,-489},{-750,-492},{-751,-491},{-751,-490},{-749,-491},{-753,-490},{-750,-491},{-755,-485},{-754,-486},{-753,-486},{-755,-487},{-756,-487},{-756,-486},{-757,-485},{-753,-488},{-753,-489},{-755,-489},{-757,-490},{-752,-490},{-752,-488},{-753,-487},{-751,-487},{-750,-487},{-748,-487},{-749,-487}}}, - {"America/Merida",40,{{-918,186},{-916,188},{-915,188},{-917,187},{-915,187},{-914,188},{-914,221},{-896,224},{-897,224},{-897,225},{-896,225},{-898,225},{-898,226},{-897,226},{-904,208},{-903,210},{-898,213},{-882,216},{-875,215},{-875,210},{-878,207},{-894,197},{-894,178},{-910,178},{-910,180},{-915,181},{-916,180},{-920,180},{-922,182},{-922,185},{-924,185},{-925,186},{-920,187},{-919,185},{-916,184},{-913,186},{-912,188},{-908,193},{-905,200},{-883,216}}}, - {"Africa/Nouakchott",48,{{-164,196},{-164,198},{-164,199},{-164,197},{-165,196},{-165,197},{-163,197},{-117,155},{-118,149},{-121,147},{-128,152},{-135,161},{-138,161},{-143,166},{-163,165},{-165,161},{-160,180},{-162,189},{-165,194},{-164,194},{-163,195},{-162,202},{-165,207},{-165,206},{-167,207},{-168,213},{-170,208},{-170,210},{-169,213},{-130,213},{-131,231},{-128,234},{-120,235},{-120,260},{-87,260},{-87,273},{-48,250},{-66,250},{-56,165},{-53,163},{-55,155},{-93,155},{-93,157},{-94,154},{-107,154},{-109,151},{-114,156},{-164,206}}}, - {"America/Bahia_Banderas",4,{{-1052,207},{-1053,207},{-1055,208},{-1054,209}}}, - {"Australia/Perth",455,{{1141,-225},{1141,-224},{1243,-164},{1252,-144},{1235,-141},{1142,-224},{1214,-339},{1179,-352},{1131,-251},{1131,-250},{1131,-253},{1131,-252},{1136,-249},{1131,-249},{1132,-248},{1142,-225},{1145,-221},{1143,-217},{1144,-217},{1144,-216},{1147,-216},{1152,-216},{1148,-215},{1154,-215},{1157,-322},{1155,-320},{1154,-320},{1156,-320},{1140,-289},{1140,-290},{1138,-287},{1138,-285},{1137,-285},{1137,-284},{1136,-283},{1137,-266},{1138,-266},{1137,-265},{1138,-265},{1135,-264},{1140,-259},{1241,-339},{1241,-338},{1220,-339},{1219,-339},{1228,-340},{1229,-340},{1220,-340},{1129,-257},{1130,-255},{1132,-262},{1130,-258},{1139,-253},{1138,-253},{1139,-259},{1138,-259},{1138,-258},{1139,-258},{1181,-351},{1180,-351},{1180,-350},{1184,-349},{1185,-349},{1196,-344},{1235,-344},{1236,-343},{1236,-344},{1236,-342},{1221,-342},{1220,-341},{1221,-341},{1232,-341},{1222,-342},{1222,-341},{1223,-341},{1235,-340},{1217,-340},{1218,-339},{1222,-340},{1221,-340},{1216,-340},{1232,-340},{1233,-340},{1150,-215},{1154,-214},{1155,-214},{1156,-212},{1159,-210},{1158,-210},{1162,-208},{1153,-208},{1154,-207},{1155,-207},{1154,-209},{1163,-208},{1166,-207},{1155,-208},{1153,-210},{1162,-210},{1162,-209},{1159,-209},{1161,-209},{1153,-209},{1167,-207},{1165,-207},{1164,-207},{1177,-206},{1167,-206},{1165,-205},{1166,-205},{1177,-207},{1170,-206},{1171,-206},{1166,-206},{1165,-206},{1167,-205},{1156,-207},{1156,-206},{1179,-205},{1168,-205},{1155,-204},{1188,-200},{1169,-204},{1168,-204},{1171,-205},{1171,-204},{1170,-204},{1156,-204},{1189,-199},{1235,-174},{1235,-173},{1234,-173},{1233,-171},{1238,-170},{1221,-169},{1235,-166},{1235,-172},{1236,-173},{1155,-205},{1169,-205},{1234,-166},{1233,-165},{1234,-165},{1235,-165},{1231,-164},{1232,-164},{1234,-164},{1244,-163},{1233,-163},{1236,-164},{1236,-163},{1239,-164},{1239,-163},{1247,-164},{1244,-164},{1245,-164},{1242,-164},{1237,-164},{1246,-164},{1246,-163},{1233,-164},{1241,-163},{1236,-162},{1241,-162},{1240,-162},{1235,-162},{1239,-162},{1233,-162},{1234,-162},{1234,-161},{1235,-161},{1236,-161},{1238,-162},{1238,-163},{1235,-163},{1234,-163},{1237,-163},{1235,-164},{1254,-150},{1252,-150},{1253,-149},{1251,-147},{1254,-145},{1254,-147},{1256,-146},{1256,-142},{1257,-143},{1256,-147},{1257,-144},{1259,-147},{1262,-142},{1260,-139},{1262,-140},{1262,-143},{1263,-140},{1266,-139},{1264,-141},{1266,-142},{1267,-140},{1269,-140},{1267,-138},{1270,-137},{1271,-140},{1274,-139},{1282,-147},{1281,-149},{1281,-154},{1279,-156},{1278,-156},{1279,-157},{1281,-155},{1281,-152},{1283,-153},{1283,-155},{1282,-151},{1283,-150},{1285,-151},{1284,-149},{1285,-150},{1284,-148},{1290,-149},{1290,-313},{1255,-313},{1255,-326},{1242,-330},{1240,-336},{1235,-339},{1230,-339},{1220,-338},{1214,-338},{1200,-339},{1196,-341},{1192,-345},{1189,-345},{1179,-350},{1179,-351},{1173,-350},{1175,-350},{1166,-351},{1160,-348},{1157,-345},{1150,-343},{1150,-335},{1154,-336},{1157,-333},{1157,-318},{1151,-305},{1149,-291},{1142,-281},{1140,-273},{1131,-261},{1133,-262},{1133,-260},{1133,-263},{1134,-264},{1134,-260},{1136,-266},{1136,-265},{1137,-267},{1139,-263},{1136,-261},{1134,-257},{1135,-255},{1137,-259},{1137,-262},{1141,-265},{1142,-263},{1143,-259},{1134,-244},{1134,-240},{1138,-235},{1138,-229},{1137,-226},{1139,-220},{1142,-218},{1144,-225},{1146,-218},{1155,-215},{1169,-207},{1172,-206},{1173,-208},{1182,-203},{1188,-203},{1191,-200},{1196,-201},{1210,-196},{1215,-191},{1218,-185},{1224,-181},{1224,-180},{1222,-180},{1222,-173},{1225,-169},{1226,-170},{1226,-168},{1228,-168},{1227,-167},{1229,-164},{1230,-164},{1230,-166},{1231,-167},{1236,-176},{1237,-173},{1236,-170},{1239,-173},{1239,-171},{1240,-169},{1238,-169},{1235,-167},{1236,-166},{1237,-165},{1239,-165},{1240,-164},{1244,-166},{1249,-164},{1244,-161},{1245,-162},{1246,-162},{1246,-159},{1248,-158},{1248,-157},{1245,-160},{1244,-157},{1245,-155},{1247,-155},{1247,-153},{1253,-156},{1251,-154},{1251,-153},{1249,-153},{1251,-152},{1248,-152},{1251,-150},{1252,-152},{1255,-152},{1241,-161},{1238,-161},{1233,-161},{1237,-161},{1239,-161},{1233,-160},{1235,-160},{1240,-160},{1244,-160},{1246,-160},{1245,-159},{1244,-159},{1244,-158},{1245,-158},{1242,-159},{1247,-158},{1246,-158},{1279,-155},{1280,-155},{1242,-160},{1237,-159},{1237,-160},{1231,-155},{1232,-155},{1242,-153},{1244,-153},{1248,-153},{1245,-154},{1250,-154},{1243,-154},{1244,-154},{1246,-154},{1246,-155},{1250,-153},{1243,-153},{1245,-153},{1246,-152},{1247,-154},{1246,-153},{1244,-152},{1248,-150},{1247,-150},{1247,-149},{1248,-149},{1253,-144},{1245,-152},{1250,-152},{1255,-151},{1254,-151},{1249,-150},{1253,-150},{1284,-151},{1283,-149},{1284,-150},{1249,-149},{1252,-149},{1285,-149},{1251,-148},{1250,-148},{1283,-148},{1283,-147},{1254,-146},{1255,-145},{1252,-147},{1252,-146},{1253,-146},{1255,-144},{1278,-144},{1260,-144},{1250,-144},{1250,-145},{1251,-146},{1251,-145},{1253,-145},{1252,-145},{1256,-145},{1282,-148},{1282,-149},{1281,-148},{1252,-143},{1253,-143},{1260,-142},{1277,-142},{1258,-142},{1258,-143},{1263,-142},{1262,-141},{1257,-141},{1256,-141},{1255,-141},{1264,-140},{1267,-139},{1256,-139},{1257,-139},{1256,-140},{1262,-139},{1263,-139},{1266,-140},{1271,-139},{1272,-139},{1258,-139},{1258,-138},{1261,-138},{1261,-137},{1265,-139},{1257,-142},{1256,-144},{1256,-143},{1259,-144},{1260,-143},{1254,-143},{1259,-143},{1282,-152},{1281,-151},{1281,-150},{1252,-151},{1253,-151},{1250,-151},{1250,-150},{1249,-151}}}, - {"Asia/Sakhalin",84,{{1433,517},{1412,462},{1412,463},{1446,485},{1433,516},{1432,519},{1431,521},{1432,520},{1431,520},{1440,500},{1444,490},{1447,489},{1448,487},{1440,493},{1434,493},{1430,491},{1425,478},{1430,473},{1431,469},{1435,468},{1436,464},{1434,460},{1433,465},{1428,466},{1427,468},{1424,466},{1421,459},{1418,466},{1421,471},{1420,476},{1422,480},{1418,488},{1421,495},{1420,506},{1422,511},{1419,516},{1417,517},{1418,518},{1416,519},{1416,523},{1419,531},{1418,534},{1422,535},{1422,534},{1425,534},{1427,535},{1425,537},{1428,537},{1427,538},{1426,537},{1427,539},{1423,543},{1426,542},{1427,544},{1430,541},{1428,539},{1432,533},{1433,532},{1433,529},{1431,534},{1430,533},{1431,530},{1433,528},{1433,526},{1433,524},{1432,523},{1431,524},{1432,518},{1431,518},{1430,517},{1432,515},{1433,515},{1434,516},{1434,513},{1432,524},{1432,525},{1432,531},{1417,534},{1424,536},{1423,535},{1423,536},{1425,536},{1426,543},{1425,543}}}, - {"Asia/Vladivostok",511,{{1318,431},{1410,761},{1377,544},{1375,544},{1376,546},{1377,545},{1392,546},{1393,546},{1413,534},{1412,534},{1411,534},{1398,543},{1398,544},{1378,545},{1380,545},{1378,544},{1412,528},{1411,530},{1410,530},{1408,531},{1414,533},{1413,533},{1415,533},{1409,531},{1309,425},{1314,426},{1315,427},{1315,426},{1314,427},{1323,427},{1324,428},{1324,427},{1329,428},{1314,428},{1315,428},{1317,429},{1316,429},{1315,429},{1318,429},{1317,430},{1318,430},{1352,437},{1319,431},{1319,430},{1325,428},{1324,429},{1325,429},{1380,712},{1380,713},{1381,713},{1379,713},{1376,713},{1377,713},{1376,714},{1378,714},{1371,546},{1315,450},{1319,453},{1329,450},{1331,451},{1332,455},{1335,456},{1335,459},{1339,463},{1339,465},{1342,471},{1342,473},{1348,477},{1346,480},{1347,483},{1344,484},{1335,481},{1332,481},{1327,479},{1326,477},{1310,477},{1307,481},{1308,483},{1308,485},{1305,486},{1307,489},{1314,492},{1315,496},{1314,497},{1315,499},{1313,500},{1315,501},{1313,504},{1309,504},{1310,507},{1306,507},{1308,509},{1308,510},{1313,514},{1315,513},{1314,517},{1323,518},{1326,521},{1334,523},{1332,525},{1333,527},{1346,524},{1348,526},{1347,529},{1350,533},{1346,536},{1340,534},{1336,535},{1332,533},{1319,531},{1319,532},{1314,532},{1314,538},{1304,539},{1307,543},{1311,543},{1312,546},{1324,551},{1324,552},{1326,552},{1327,554},{1330,554},{1324,557},{1309,557},{1309,559},{1311,564},{1315,566},{1317,565},{1317,567},{1318,567},{1315,571},{1311,572},{1315,572},{1317,576},{1320,576},{1315,582},{1321,580},{1320,581},{1322,582},{1321,585},{1324,585},{1326,589},{1328,589},{1328,591},{1331,592},{1335,593},{1352,591},{1358,595},{1367,593},{1375,595},{1376,597},{1383,597},{1382,605},{1384,607},{1382,609},{1383,610},{1383,611},{1395,615},{1400,620},{1403,621},{1403,624},{1406,624},{1407,626},{1413,624},{1418,620},{1422,621},{1424,619},{1430,619},{1432,621},{1436,620},{1436,619},{1439,620},{1439,618},{1442,617},{1447,620},{1455,620},{1457,621},{1466,616},{1466,614},{1468,614},{1467,610},{1465,609},{1464,607},{1461,607},{1455,605},{1458,602},{1464,603},{1468,599},{1470,599},{1471,594},{1464,595},{1463,594},{1463,592},{1460,591},{1458,592},{1460,594},{1457,594},{1432,594},{1424,592},{1415,586},{1408,583},{1405,578},{1389,571},{1386,568},{1384,568},{1381,566},{1382,564},{1352,549},{1358,546},{1368,546},{1367,539},{1368,538},{1372,538},{1373,540},{1371,541},{1372,542},{1377,543},{1373,541},{1379,540},{1372,536},{1373,535},{1380,536},{1386,540},{1386,538},{1383,535},{1385,535},{1388,540},{1387,543},{1392,542},{1397,543},{1405,536},{1408,535},{1411,535},{1409,535},{1409,534},{1414,532},{1412,530},{1407,531},{1412,529},{1413,527},{1411,524},{1415,522},{1413,521},{1414,520},{1409,516},{1407,515},{1409,514},{1406,512},{1407,510},{1404,505},{1405,501},{1407,501},{1404,499},{1405,496},{1402,490},{1404,490},{1402,484},{1393,478},{1390,473},{1386,470},{1381,462},{1359,444},{1354,438},{1351,435},{1339,429},{1330,427},{1330,428},{1329,427},{1327,429},{1323,428},{1324,432},{1323,433},{1320,431},{1321,433},{1318,433},{1312,426},{1307,427},{1307,423},{1306,426},{1304,427},{1311,429},{1313,434},{1312,436},{1313,441},{1310,449},{1365,546},{1363,546},{1363,547},{1382,547},{1383,550},{1434,564},{1384,550},{1383,551},{1384,551},{1369,549},{1382,550},{1377,546},{1375,549},{1372,548},{1376,552},{1365,549},{1365,550},{1366,549},{1527,762},{1528,762},{1529,761},{1526,761},{1404,763},{1403,763},{1374,714},{1375,714},{1368,550},{1370,551},{1372,551},{1371,549},{1367,549},{1500,752},{1510,751},{1507,749},{1490,747},{1462,752},{1465,756},{1469,753},{1476,754},{1486,754},{1486,752},{1357,754},{1355,754},{1357,759},{1362,756},{1360,754},{1399,748},{1400,748},{1420,749},{1419,750},{1417,749},{1418,749},{1416,749},{1525,757},{1375,758},{1434,758},{1433,758},{1415,760},{1415,761},{1492,766},{1491,767},{1485,766},{1495,768},{1581,767},{1582,767},{1566,770},{1565,770},{1568,770},{1567,770},{1391,761},{1411,761},{1407,739},{1408,739},{1398,734},{1406,735},{1412,739},{1421,739},{1434,736},{1436,732},{1357,741},{1355,742},{1363,739},{1362,739},{1403,742},{1409,743},{1411,742},{1410,740},{1406,739},{1402,741},{1318,710},{1323,717},{1327,719},{1330,720},{1332,720},{1334,719},{1330,719},{1328,718},{1341,714},{1359,716},{1382,712},{1382,716},{1389,716},{1392,714},{1399,714},{1401,715},{1398,717},{1398,719},{1394,719},{1403,722},{1394,721},{1392,723},{1396,725},{1413,726},{1408,729},{1474,723},{1469,722},{1435,721},{1426,715},{1425,713},{1426,711},{1411,703},{1409,700},{1418,698},{1423,698},{1421,696},{1425,696},{1424,695},{1428,692},{1415,692},{1420,688},{1420,686},{1410,684},{1412,682},{1413,679},{1402,677},{1389,672},{1405,666},{1404,664},{1400,665},{1396,663},{1402,658},{1371,662},{1360,661},{1356,658},{1348,657},{1343,654},{1329,651},{1328,649},{1331,646},{1329,646},{1322,646},{1323,649},{1316,654},{1316,657},{1301,662},{1300,665},{1319,670},{1331,680},{1331,684},{1327,689},{1322,690},{1335,697},{1330,700},{1332,702},{1331,703},{1321,704},{1320,708},{1322,709},{1390,762},{1406,757},{1411,756},{1409,758},{1417,760},{1414,762},{1426,759},{1439,758},{1454,755},{1449,754},{1450,753},{1444,751},{1435,751},{1437,750},{1436,749},{1425,748},{1424,749},{1423,750},{1401,748},{1397,750},{1395,749},{1397,749},{1392,746},{1382,748},{1370,753},{1373,755},{1373,756},{1370,756},{1372,757},{1376,758},{1375,759},{1414,761},{1409,761},{1372,714},{1371,715},{1373,714},{1373,715},{1374,715},{1375,715},{1372,715},{1370,715},{1369,715},{1366,715},{1366,716},{1352,716},{1354,716},{1353,716},{1387,716},{1385,717},{1389,717},{1384,717},{1383,717},{1381,716},{1380,715},{1329,719},{1384,718},{1385,719},{1386,719}}}, - {"America/Detroit",128,{{-850,458},{-848,417},{-868,418},{-862,426},{-865,436},{-864,438},{-865,441},{-862,444},{-862,447},{-855,452},{-856,448},{-855,450},{-854,449},{-854,448},{-853,448},{-854,453},{-850,452},{-853,453},{-849,454},{-851,456},{-847,458},{-835,454},{-833,450},{-836,451},{-833,449},{-833,443},{-839,439},{-840,434},{-838,437},{-837,436},{-834,439},{-829,441},{-826,438},{-824,430},{-825,426},{-831,423},{-833,419},{-835,419},{-834,417},{-832,420},{-835,438},{-834,438},{-834,440},{-861,450},{-832,450},{-833,451},{-860,451},{-861,451},{-860,452},{-833,452},{-858,454},{-859,454},{-858,455},{-868,455},{-867,455},{-876,474},{-866,455},{-867,456},{-866,456},{-858,457},{-851,458},{-857,457},{-856,457},{-886,472},{-882,474},{-877,474},{-880,474},{-884,470},{-884,472},{-885,471},{-888,479},{-892,479},{-893,479},{-884,482},{-883,482},{-886,481},{-892,478},{-887,481},{-886,482},{-849,458},{-849,459},{-846,458},{-846,459},{-843,460},{-843,459},{-844,460},{-846,460},{-844,459},{-856,456},{-855,458},{-855,456},{-844,457},{-845,457},{-844,458},{-854,458},{-853,458},{-899,468},{-893,468},{-885,467},{-881,470},{-882,469},{-883,468},{-878,469},{-874,465},{-866,464},{-862,467},{-849,468},{-850,465},{-841,465},{-839,461},{-834,460},{-847,460},{-848,458},{-855,461},{-863,459},{-867,457},{-865,459},{-870,457},{-870,459},{-873,455},{-873,459},{-876,460},{-876,462},{-881,462},{-881,464},{-894,463},{-894,465},{-897,465}}}, - {"Asia/Qatar",19,{{516,253},{513,246},{509,255},{516,254},{524,257},{512,262},{513,262},{513,261},{516,258},{516,257},{516,252},{514,246},{509,245},{508,255},{509,256},{510,260},{512,261},{516,259},{515,255}}}, - {"Africa/Bissau",92,{{-152,109},{-165,113},{-164,113},{-159,113},{-157,110},{-156,110},{-152,111},{-161,111},{-162,110},{-163,111},{-161,112},{-159,112},{-158,112},{-158,113},{-157,113},{-157,112},{-160,110},{-160,111},{-153,110},{-152,110},{-156,111},{-160,112},{-159,111},{-162,113},{-162,112},{-163,112},{-160,119},{-161,118},{-162,118},{-162,119},{-159,118},{-163,119},{-163,120},{-154,118},{-155,119},{-154,119},{-160,118},{-156,118},{-156,119},{-159,119},{-162,114},{-158,114},{-159,114},{-163,114},{-160,114},{-161,114},{-144,115},{-147,115},{-150,110},{-151,109},{-150,112},{-154,112},{-154,114},{-155,113},{-153,116},{-151,115},{-150,116},{-152,117},{-152,118},{-154,115},{-154,117},{-156,117},{-150,120},{-160,117},{-161,119},{-164,121},{-161,123},{-165,122},{-167,123},{-157,124},{-152,127},{-137,127},{-137,123},{-140,122},{-137,120},{-137,117},{-161,113},{-160,113},{-157,114},{-157,115},{-163,115},{-162,115},{-161,115},{-160,115},{-159,115},{-164,115},{-163,116},{-155,116},{-156,115},{-156,116},{-159,116},{-160,116}}}, - {"America/Los_Angeles",210,{{-1224,379},{-1223,379},{-1227,486},{-1229,487},{-1229,488},{-1224,378},{-1186,330},{-1183,328},{-1185,329},{-1194,332},{-1195,332},{-1196,333},{-1195,333},{-1186,335},{-1184,334},{-1183,333},{-1185,333},{-1190,335},{-1204,340},{-1205,340},{-1204,341},{-1203,340},{-1200,339},{-1201,339},{-1202,340},{-1200,340},{-1194,340},{-1197,340},{-1195,340},{-1198,340},{-1199,341},{-1241,469},{-1241,470},{-1239,470},{-1229,472},{-1228,473},{-1228,472},{-1226,471},{-1226,472},{-1227,472},{-1227,471},{-1240,466},{-1239,465},{-1239,464},{-1240,464},{-1240,465},{-1227,473},{-1226,473},{-1225,473},{-1225,474},{-1225,475},{-1224,474},{-1222,475},{-1223,476},{-1222,476},{-1226,477},{-1225,477},{-1225,476},{-1226,476},{-1224,476},{-1223,480},{-1229,481},{-1225,485},{-1225,484},{-1227,481},{-1227,480},{-1224,481},{-1225,481},{-1225,482},{-1224,482},{-1226,480},{-1228,482},{-1226,484},{-1225,483},{-1227,482},{-1224,480},{-1227,485},{-1232,486},{-1228,486},{-1226,486},{-1230,486},{-1230,488},{-1226,485},{-1227,484},{-1228,484},{-1229,485},{-1229,486},{-1228,485},{-1226,487},{-1231,485},{-1232,485},{-1231,486},{-1230,485},{-1231,490},{-1230,490},{-1228,487},{-1232,487},{-1227,487},{-1230,487},{-1231,487},{-1145,456},{-1148,454},{-1152,456},{-1155,454},{-1163,454},{-1163,459},{-1166,460},{-1168,458},{-1165,456},{-1172,445},{-1172,443},{-1180,444},{-1182,443},{-1182,424},{-1170,425},{-1170,420},{-1140,420},{-1140,362},{-1142,360},{-1144,361},{-1148,361},{-1146,349},{-1141,343},{-1144,341},{-1145,336},{-1147,334},{-1147,331},{-1145,328},{-1171,325},{-1175,333},{-1181,337},{-1184,337},{-1185,340},{-1191,341},{-1196,344},{-1206,346},{-1206,351},{-1219,363},{-1219,369},{-1224,372},{-1225,378},{-1221,375},{-1224,380},{-1223,381},{-1225,381},{-1230,380},{-1230,383},{-1237,389},{-1239,398},{-1244,404},{-1241,409},{-1241,415},{-1246,428},{-1241,440},{-1239,454},{-1240,462},{-1239,462},{-1235,463},{-1241,463},{-1241,466},{-1238,464},{-1238,467},{-1241,467},{-1240,468},{-1237,470},{-1242,469},{-1247,484},{-1240,482},{-1231,482},{-1229,480},{-1228,481},{-1226,479},{-1227,478},{-1228,477},{-1229,478},{-1232,474},{-1230,473},{-1229,474},{-1231,474},{-1226,478},{-1225,478},{-1227,477},{-1227,475},{-1226,474},{-1228,474},{-1231,472},{-1231,471},{-1229,470},{-1229,471},{-1223,473},{-1224,477},{-1223,475},{-1223,478},{-1222,480},{-1224,486},{-1225,488},{-1228,490},{-1161,490},{-1160,480},{-1157,477},{-1156,475},{-1158,474},{-1153,473},{-1148,467},{-1143,466},{-1237,462},{-1236,462},{-1237,463},{-1240,463},{-1235,462}}}, - {"America/Godthab",2299,{{-534,685},{-533,685},{-526,685},{-525,685},{-536,685},{-535,685},{-529,685},{-637,761},{-636,761},{-560,726},{-228,727},{-229,727},{-267,815},{-266,815},{-610,761},{-611,761},{-524,686},{-524,687},{-531,686},{-530,687},{-533,655},{-436,598},{-435,598},{-436,599},{-435,599},{-437,599},{-433,599},{-446,599},{-446,600},{-511,687},{-513,687},{-512,687},{-514,686},{-439,598},{-441,599},{-440,600},{-226,699},{-533,690},{-512,689},{-513,689},{-534,690},{-535,690},{-232,697},{-233,696},{-236,697},{-233,698},{-512,690},{-510,693},{-510,694},{-509,694},{-541,695},{-542,695},{-544,695},{-506,696},{-507,696},{-529,688},{-530,688},{-527,688},{-526,688},{-513,688},{-518,688},{-519,688},{-520,688},{-520,689},{-519,689},{-535,686},{-518,686},{-519,686},{-531,687},{-522,687},{-514,687},{-515,687},{-529,687},{-528,687},{-527,687},{-511,686},{-512,686},{-532,686},{-528,686},{-527,686},{-520,687},{-525,687},{-526,687},{-523,687},{-550,705},{-547,704},{-550,704},{-254,711},{-253,711},{-249,713},{-252,712},{-253,712},{-252,713},{-256,711},{-255,711},{-254,712},{-521,707},{-522,707},{-278,707},{-277,707},{-516,708},{-514,708},{-513,708},{-523,709},{-522,710},{-523,710},{-275,709},{-273,709},{-278,708},{-277,709},{-519,709},{-522,709},{-516,709},{-517,708},{-254,710},{-255,710},{-256,710},{-257,711},{-253,710},{-513,698},{-505,698},{-506,699},{-504,699},{-507,699},{-508,699},{-509,699},{-507,700},{-514,706},{-514,707},{-529,700},{-520,698},{-520,697},{-518,696},{-536,692},{-543,694},{-534,694},{-536,695},{-534,696},{-538,695},{-540,695},{-540,696},{-550,697},{-544,697},{-549,698},{-548,700},{-542,699},{-548,701},{-548,702},{-544,703},{-533,702},{-512,699},{-510,699},{-512,695},{-514,697},{-514,699},{-513,700},{-512,700},{-515,699},{-515,705},{-517,705},{-516,705},{-513,705},{-517,706},{-516,706},{-282,705},{-281,705},{-262,705},{-263,705},{-264,705},{-261,705},{-515,706},{-519,706},{-519,707},{-518,707},{-257,710},{-254,709},{-253,708},{-255,708},{-253,707},{-271,709},{-300,682},{-299,682},{-297,682},{-298,681},{-537,683},{-534,683},{-535,683},{-536,683},{-531,683},{-534,684},{-532,683},{-532,684},{-531,685},{-532,685},{-527,685},{-528,685},{-529,686},{-535,684},{-536,684},{-533,684},{-530,685},{-516,685},{-518,685},{-533,686},{-517,686},{-515,685},{-515,686},{-525,686},{-526,686},{-519,687},{-521,686},{-521,687},{-523,686},{-583,750},{-583,751},{-582,751},{-582,748},{-581,748},{-663,791},{-664,792},{-663,792},{-659,792},{-633,763},{-632,763},{-631,763},{-662,791},{-661,791},{-637,762},{-623,762},{-622,762},{-621,762},{-620,762},{-626,762},{-627,762},{-625,762},{-600,758},{-601,758},{-595,758},{-594,758},{-599,759},{-598,759},{-611,760},{-612,760},{-610,760},{-617,760},{-618,760},{-617,761},{-615,761},{-615,762},{-614,761},{-616,761},{-616,762},{-623,760},{-624,760},{-624,761},{-623,761},{-609,761},{-612,761},{-613,761},{-620,761},{-621,761},{-619,762},{-618,762},{-619,761},{-671,805},{-672,805},{-670,805},{-666,806},{-668,807},{-664,806},{-666,808},{-667,808},{-635,811},{-634,811},{-630,812},{-631,813},{-630,813},{-614,813},{-613,813},{-585,817},{-583,817},{-584,817},{-237,817},{-238,818},{-236,818},{-324,818},{-325,818},{-323,818},{-445,818},{-445,819},{-444,819},{-197,817},{-196,817},{-198,817},{-180,819},{-179,819},{-190,820},{-186,818},{-191,818},{-196,821},{-178,819},{-182,821},{-177,819},{-533,823},{-528,823},{-512,820},{-532,821},{-534,822},{-523,823},{-520,823},{-518,822},{-522,822},{-514,823},{-489,826},{-484,825},{-481,825},{-483,824},{-403,826},{-404,826},{-405,826},{-223,828},{-224,828},{-222,828},{-500,828},{-499,828},{-498,828},{-502,828},{-236,828},{-237,829},{-475,828},{-474,828},{-483,829},{-476,828},{-485,829},{-406,827},{-407,827},{-476,826},{-477,826},{-462,827},{-444,824},{-451,822},{-447,821},{-450,821},{-402,827},{-403,827},{-405,827},{-442,832},{-439,832},{-440,832},{-332,831},{-333,831},{-437,833},{-434,833},{-435,832},{-425,832},{-424,833},{-420,833},{-421,832},{-417,833},{-418,833},{-413,833},{-412,833},{-393,834},{-389,833},{-397,833},{-395,834},{-406,832},{-401,832},{-402,832},{-400,830},{-406,830},{-415,832},{-399,830},{-400,832},{-394,831},{-393,831},{-406,831},{-386,831},{-387,832},{-381,832},{-382,831},{-416,832},{-417,832},{-410,832},{-413,832},{-390,832},{-389,832},{-401,833},{-407,833},{-404,834},{-287,834},{-287,835},{-286,835},{-286,834},{-243,829},{-474,829},{-470,829},{-464,828},{-468,828},{-242,829},{-534,717},{-533,717},{-528,717},{-532,715},{-457,829},{-462,829},{-470,830},{-460,829},{-468,830},{-460,831},{-449,829},{-602,755},{-586,755},{-587,755},{-583,755},{-585,755},{-587,756},{-586,756},{-585,756},{-593,757},{-592,757},{-598,758},{-602,758},{-539,712},{-536,713},{-534,711},{-537,710},{-532,713},{-524,714},{-523,713},{-530,712},{-250,713},{-518,713},{-538,714},{-539,714},{-531,714},{-531,715},{-529,715},{-530,715},{-540,717},{-535,717},{-561,730},{-554,719},{-556,718},{-558,719},{-555,719},{-560,723},{-559,723},{-560,722},{-248,724},{-248,725},{-557,724},{-558,725},{-557,725},{-241,725},{-246,725},{-247,725},{-224,724},{-223,724},{-559,721},{-560,721},{-557,721},{-558,721},{-551,723},{-550,723},{-554,724},{-555,723},{-561,722},{-558,722},{-559,722},{-550,724},{-554,722},{-557,722},{-554,723},{-556,723},{-555,724},{-556,724},{-252,724},{-561,726},{-217,727},{-217,726},{-562,726},{-246,726},{-556,725},{-561,725},{-550,725},{-550,726},{-549,726},{-548,726},{-553,725},{-554,726},{-557,726},{-558,726},{-559,726},{-553,726},{-552,726},{-551,726},{-550,727},{-564,729},{-557,729},{-556,729},{-565,730},{-562,729},{-563,729},{-549,729},{-549,730},{-548,729},{-559,729},{-561,729},{-550,729},{-560,729},{-559,730},{-558,729},{-249,730},{-557,730},{-248,730},{-249,729},{-250,730},{-563,730},{-564,730},{-562,730},{-556,730},{-564,727},{-563,727},{-562,728},{-561,728},{-562,727},{-226,724},{-220,723},{-224,721},{-240,725},{-244,726},{-245,728},{-232,728},{-219,725},{-228,724},{-224,727},{-225,727},{-552,727},{-549,727},{-552,728},{-549,728},{-230,727},{-230,728},{-229,728},{-556,728},{-557,728},{-561,727},{-558,727},{-555,728},{-560,728},{-559,728},{-558,728},{-228,728},{-547,728},{-553,728},{-553,729},{-548,728},{-250,729},{-248,729},{-249,728},{-254,728},{-563,733},{-562,734},{-562,733},{-555,729},{-554,729},{-232,732},{-231,732},{-564,732},{-563,732},{-562,732},{-557,732},{-558,732},{-556,732},{-556,733},{-555,732},{-561,733},{-557,733},{-558,733},{-555,733},{-564,733},{-558,734},{-559,733},{-565,735},{-566,735},{-561,735},{-562,735},{-203,736},{-204,736},{-570,736},{-571,736},{-565,737},{-566,737},{-562,738},{-562,737},{-564,738},{-563,738},{-565,736},{-569,737},{-570,737},{-563,737},{-569,736},{-247,736},{-248,736},{-567,736},{-564,735},{-567,735},{-566,736},{-560,736},{-559,735},{-561,736},{-568,736},{-558,735},{-560,735},{-563,734},{-191,815},{-192,815},{-562,736},{-568,738},{-200,739},{-201,739},{-203,739},{-202,739},{-561,739},{-562,739},{-568,739},{-569,739},{-567,739},{-563,739},{-564,739},{-561,740},{-560,739},{-561,738},{-570,738},{-569,738},{-567,738},{-566,738},{-566,739},{-559,738},{-566,734},{-564,734},{-563,735},{-575,748},{-574,748},{-556,734},{-553,734},{-560,734},{-561,734},{-557,735},{-555,735},{-568,741},{-569,741},{-567,741},{-566,741},{-571,742},{-570,742},{-570,743},{-572,745},{-573,745},{-569,744},{-568,744},{-573,744},{-574,744},{-572,744},{-570,744},{-571,744},{-571,745},{-188,745},{-187,745},{-565,745},{-564,745},{-563,745},{-574,745},{-574,746},{-449,600},{-448,600},{-452,600},{-568,746},{-575,745},{-578,746},{-572,746},{-571,746},{-192,746},{-189,747},{-187,746},{-569,746},{-570,746},{-574,749},{-575,749},{-580,749},{-581,749},{-209,751},{-210,751},{-581,751},{-581,750},{-183,746},{-185,746},{-186,747},{-183,747},{-577,747},{-578,747},{-572,747},{-571,747},{-574,747},{-575,747},{-576,748},{-200,750},{-202,749},{-197,749},{-201,747},{-207,748},{-205,750},{-209,740},{-210,740},{-578,740},{-570,740},{-569,740},{-568,740},{-211,740},{-212,740},{-566,740},{-567,740},{-565,740},{-579,740},{-208,740},{-208,741},{-213,731},{-212,731},{-215,731},{-225,731},{-226,731},{-561,731},{-560,731},{-230,731},{-231,731},{-227,731},{-558,731},{-559,731},{-562,731},{-456,604},{-553,730},{-552,730},{-551,730},{-555,730},{-554,730},{-237,730},{-220,729},{-219,729},{-222,728},{-219,727},{-246,730},{-555,731},{-559,732},{-560,732},{-561,732},{-175,816},{-173,816},{-182,817},{-178,817},{-250,733},{-238,732},{-229,732},{-244,730},{-257,732},{-248,734},{-236,732},{-242,733},{-245,733},{-249,733},{-252,733},{-180,796},{-181,796},{-200,798},{-196,800},{-197,800},{-194,802},{-187,801},{-133,805},{-133,806},{-135,806},{-134,806},{-167,806},{-168,806},{-169,806},{-222,810},{-223,810},{-221,810},{-194,814},{-193,814},{-192,814},{-578,816},{-577,816},{-200,816},{-199,816},{-201,816},{-198,816},{-199,817},{-192,816},{-579,816},{-580,816},{-265,815},{-264,815},{-183,750},{-189,750},{-189,753},{-180,754},{-178,753},{-182,752},{-173,751},{-176,749},{-432,600},{-431,600},{-431,601},{-431,602},{-430,602},{-430,601},{-453,601},{-452,601},{-451,601},{-450,601},{-451,600},{-450,600},{-453,600},{-443,600},{-444,599},{-445,600},{-445,599},{-435,600},{-444,600},{-444,601},{-442,600},{-441,600},{-443,601},{-449,601},{-432,602},{-455,603},{-452,602},{-431,603},{-432,604},{-457,604},{-454,603},{-455,604},{-433,604},{-432,603},{-434,604},{-431,605},{-454,605},{-453,605},{-432,605},{-462,605},{-459,605},{-457,605},{-458,605},{-458,604},{-450,604},{-450,603},{-451,603},{-451,604},{-452,604},{-453,604},{-454,604},{-453,602},{-433,600},{-434,601},{-434,600},{-435,601},{-437,601},{-441,601},{-452,603},{-454,602},{-486,610},{-486,611},{-461,606},{-462,606},{-458,606},{-458,607},{-428,607},{-427,607},{-465,606},{-465,607},{-460,606},{-459,607},{-477,607},{-469,607},{-468,607},{-463,607},{-462,607},{-467,607},{-479,607},{-466,607},{-460,607},{-477,608},{-476,607},{-466,608},{-465,608},{-527,655},{-464,607},{-481,608},{-478,608},{-483,608},{-459,608},{-460,608},{-474,608},{-473,608},{-470,608},{-472,608},{-469,608},{-463,608},{-462,608},{-476,608},{-471,608},{-464,608},{-475,608},{-460,605},{-484,609},{-427,609},{-463,610},{-427,610},{-480,610},{-480,611},{-481,611},{-482,611},{-485,611},{-487,612},{-488,612},{-484,612},{-483,612},{-483,611},{-482,610},{-481,610},{-485,610},{-484,610},{-484,611},{-425,613},{-488,613},{-489,613},{-489,612},{-490,612},{-487,613},{-486,612},{-486,613},{-426,613},{-491,614},{-425,615},{-426,615},{-491,615},{-492,615},{-423,615},{-485,613},{-488,614},{-489,614},{-464,609},{-464,610},{-478,610},{-479,610},{-423,616},{-423,617},{-422,616},{-493,617},{-493,616},{-424,617},{-494,617},{-495,617},{-491,616},{-492,616},{-492,617},{-491,617},{-422,618},{-495,618},{-494,618},{-495,619},{-495,620},{-496,620},{-423,620},{-422,621},{-421,621},{-498,621},{-497,621},{-497,620},{-496,619},{-497,619},{-494,619},{-496,618},{-493,618},{-427,626},{-426,626},{-420,627},{-419,627},{-504,627},{-504,626},{-422,619},{-421,619},{-421,618},{-499,622},{-497,622},{-496,622},{-498,622},{-421,623},{-422,623},{-499,623},{-500,623},{-422,624},{-426,624},{-427,624},{-425,624},{-422,626},{-421,625},{-422,625},{-423,626},{-426,623},{-425,623},{-422,627},{-423,627},{-421,626},{-503,626},{-503,627},{-502,627},{-505,627},{-425,626},{-424,626},{-426,627},{-422,615},{-493,615},{-424,616},{-473,609},{-472,609},{-462,609},{-512,633},{-511,633},{-471,609},{-481,609},{-480,609},{-474,609},{-428,608},{-430,609},{-426,609},{-461,609},{-470,609},{-466,609},{-465,609},{-465,610},{-504,628},{-504,629},{-508,630},{-507,630},{-416,630},{-417,630},{-417,628},{-417,629},{-416,629},{-506,629},{-505,629},{-418,629},{-517,641},{-415,630},{-511,631},{-507,632},{-507,631},{-506,632},{-409,634},{-410,634},{-514,634},{-514,635},{-515,635},{-407,636},{-407,635},{-513,635},{-513,634},{-410,635},{-409,635},{-512,635},{-511,632},{-512,632},{-411,633},{-410,633},{-412,632},{-503,632},{-411,634},{-413,633},{-411,632},{-419,634},{-417,635},{-510,631},{-509,631},{-508,631},{-415,631},{-414,631},{-413,631},{-416,631},{-518,641},{-505,631},{-506,631},{-413,632},{-412,631},{-415,632},{-406,636},{-412,637},{-406,637},{-406,638},{-405,638},{-405,637},{-517,638},{-516,638},{-518,638},{-515,639},{-517,639},{-517,640},{-518,639},{-519,640},{-516,639},{-522,640},{-521,640},{-516,640},{-516,641},{-519,641},{-518,640},{-521,642},{-520,642},{-521,641},{-520,641},{-403,643},{-403,644},{-402,644},{-404,644},{-404,643},{-521,644},{-406,642},{-407,642},{-516,643},{-516,644},{-515,644},{-522,643},{-521,643},{-411,643},{-412,643},{-517,643},{-411,642},{-412,642},{-413,643},{-414,643},{-514,643},{-516,642},{-513,643},{-520,643},{-523,650},{-409,643},{-407,644},{-407,643},{-522,644},{-519,642},{-408,643},{-410,643},{-521,646},{-508,647},{-404,646},{-522,648},{-512,647},{-511,648},{-520,648},{-520,647},{-404,648},{-524,650},{-399,649},{-399,650},{-398,650},{-390,655},{-389,655},{-522,650},{-521,650},{-401,650},{-402,650},{-404,649},{-405,650},{-517,650},{-516,650},{-400,650},{-522,649},{-405,649},{-515,649},{-518,649},{-525,651},{-524,651},{-399,651},{-398,651},{-400,651},{-523,651},{-525,650},{-404,650},{-392,655},{-406,650},{-406,651},{-405,651},{-522,645},{-521,645},{-513,645},{-511,646},{-513,644},{-508,645},{-511,642},{-513,642},{-510,645},{-507,645},{-511,645},{-408,649},{-405,648},{-406,647},{-405,646},{-405,645},{-515,636},{-514,636},{-408,636},{-409,636},{-397,652},{-396,652},{-524,652},{-525,652},{-526,652},{-395,652},{-395,653},{-394,652},{-528,653},{-526,653},{-523,653},{-522,653},{-397,653},{-398,653},{-524,653},{-523,652},{-528,654},{-529,654},{-525,654},{-527,654},{-399,653},{-398,654},{-396,653},{-527,653},{-526,655},{-532,655},{-531,655},{-528,655},{-529,655},{-391,655},{-532,654},{-393,655},{-394,655},{-526,654},{-396,654},{-397,654},{-393,654},{-507,657},{-369,657},{-368,657},{-367,657},{-532,657},{-533,657},{-362,657},{-363,657},{-508,657},{-370,657},{-373,657},{-371,657},{-371,658},{-532,658},{-362,658},{-509,657},{-367,658},{-363,658},{-370,658},{-366,658},{-534,658},{-533,659},{-533,658},{-534,659},{-365,658},{-364,658},{-369,658},{-368,659},{-536,662},{-362,659},{-531,659},{-531,658},{-379,658},{-381,658},{-382,658},{-382,659},{-381,659},{-379,659},{-372,655},{-372,656},{-370,655},{-371,655},{-378,655},{-378,656},{-367,656},{-369,656},{-370,656},{-386,656},{-385,656},{-373,656},{-380,656},{-368,656},{-388,656},{-388,655},{-396,655},{-397,655},{-529,656},{-376,662},{-358,660},{-357,660},{-359,660},{-535,660},{-531,656},{-530,657},{-528,656},{-532,656},{-392,657},{-393,657},{-372,657},{-535,659},{-534,660},{-359,659},{-360,659},{-360,660},{-356,660},{-539,661},{-355,661},{-356,661},{-537,661},{-357,661},{-537,662},{-349,663},{-350,663},{-354,662},{-356,662},{-355,662},{-536,661},{-534,661},{-536,660},{-537,663},{-538,663},{-537,664},{-537,665},{-535,665},{-536,665},{-536,666},{-534,667},{-535,666},{-536,667},{-534,668},{-535,667},{-533,667},{-338,668},{-535,668},{-528,668},{-538,669},{-336,669},{-336,670},{-539,670},{-536,668},{-339,668},{-340,668},{-339,669},{-534,669},{-535,669},{-536,669},{-340,669},{-338,669},{-529,668},{-530,668},{-531,668},{-529,669},{-532,668},{-337,670},{-335,671},{-334,671},{-540,671},{-334,672},{-333,672},{-335,672},{-336,671},{-333,673},{-333,674},{-332,674},{-325,676},{-329,676},{-328,677},{-328,676},{-332,672},{-332,673},{-334,673},{-530,677},{-322,678},{-323,678},{-326,678},{-325,678},{-521,677},{-538,678},{-539,678},{-536,679},{-534,679},{-535,679},{-513,678},{-501,677},{-500,677},{-538,677},{-537,677},{-537,678},{-536,677},{-536,680},{-320,680},{-534,680},{-533,680},{-535,680},{-538,681},{-317,681},{-318,681},{-537,682},{-538,682},{-515,682},{-516,682},{-537,681},{-526,679},{-512,679},{-511,680},{-519,681},{-514,682},{-512,681},{-520,681},{-533,681},{-516,681},{-522,681},{-520,682},{-519,682},{-523,682},{-516,683},{-515,683},{-531,681},{-535,681},{-536,681},{-532,681},{-537,680},{-538,680},{-532,680},{-538,679},{-364,659},{-365,659},{-369,659},{-375,657},{-380,657},{-377,659},{-373,658},{-375,658},{-380,659},{-384,659},{-396,651},{-522,652},{-397,651},{-398,652},{-399,652},{-418,628},{-501,628},{-501,627},{-505,628},{-425,627},{-424,628},{-423,628},{-420,628},{-535,682},{-536,682},{-318,682},{-320,682},{-317,682},{-529,682},{-528,682},{-512,682},{-513,682},{-527,682},{-526,682},{-533,682},{-534,682},{-530,682},{-525,682},{-532,682},{-531,682},{-530,683},{-533,683},{-449,602},{-448,602},{-445,605},{-445,606},{-449,603},{-448,605},{-450,605},{-446,607},{-451,607},{-455,605},{-453,606},{-453,607},{-452,607},{-452,608},{-454,607},{-456,605},{-456,606},{-453,609},{-454,610},{-457,608},{-455,610},{-453,611},{-452,612},{-454,611},{-455,612},{-456,610},{-456,611},{-459,612},{-457,613},{-458,613},{-461,612},{-458,611},{-469,609},{-467,609},{-470,610},{-479,609},{-482,608},{-477,610},{-479,612},{-482,612},{-479,613},{-485,612},{-484,613},{-485,614},{-483,613},{-483,614},{-483,615},{-485,615},{-483,616},{-490,614},{-489,615},{-486,616},{-489,618},{-488,620},{-492,619},{-488,621},{-491,621},{-490,622},{-492,620},{-495,621},{-493,621},{-494,622},{-493,622},{-493,623},{-499,624},{-496,624},{-498,624},{-498,625},{-503,625},{-499,628},{-502,629},{-497,630},{-502,630},{-506,630},{-505,630},{-501,632},{-510,632},{-502,634},{-511,634},{-510,634},{-510,635},{-512,634},{-508,635},{-511,635},{-511,636},{-506,636},{-505,636},{-511,637},{-512,636},{-513,636},{-515,637},{-513,637},{-516,637},{-513,638},{-514,638},{-512,638},{-509,639},{-514,640},{-505,642},{-514,641},{-518,642},{-509,642},{-508,642},{-511,643},{-509,644},{-504,644},{-502,644},{-509,646},{-505,647},{-501,645},{-496,643},{-501,646},{-500,647},{-502,647},{-501,648},{-506,648},{-507,650},{-509,651},{-507,652},{-510,652},{-506,647},{-512,646},{-510,648},{-512,648},{-521,647},{-516,648},{-516,649},{-513,650},{-517,649},{-519,649},{-520,650},{-520,652},{-520,653},{-514,656},{-519,656},{-517,657},{-513,658},{-506,657},{-512,658},{-520,657},{-519,655},{-524,655},{-525,657},{-526,657},{-527,658},{-528,657},{-527,659},{-523,658},{-520,660},{-517,659},{-519,660},{-517,661},{-522,660},{-523,659},{-526,660},{-529,660},{-513,668},{-503,668},{-509,669},{-507,670},{-509,670},{-531,662},{-531,663},{-530,664},{-532,665},{-529,666},{-525,665},{-524,665},{-528,666},{-533,665},{-526,667},{-530,667},{-532,667},{-528,667},{-527,668},{-524,668},{-522,668},{-525,669},{-523,669},{-524,670},{-537,669},{-532,670},{-538,670},{-534,671},{-539,672},{-521,674},{-521,673},{-515,673},{-513,672},{-512,671},{-504,672},{-516,674},{-511,674},{-532,673},{-538,672},{-538,674},{-525,677},{-529,677},{-528,678},{-524,678},{-518,676},{-513,677},{-508,675},{-502,675},{-501,675},{-509,676},{-499,677},{-510,677},{-502,679},{-508,679},{-510,678},{-506,678},{-512,678},{-514,679},{-510,679},{-510,680},{-516,679},{-517,677},{-516,680},{-530,678},{-538,675},{-535,677},{-529,680},{-522,679},{-521,679},{-521,680},{-506,679},{-501,679},{-510,682},{-512,683},{-512,684},{-508,685},{-517,684},{-525,683},{-529,683},{-526,684},{-527,684},{-528,684},{-510,686},{-507,688},{-509,689},{-511,691},{-502,690},{-507,691},{-501,692},{-505,692},{-504,693},{-511,692},{-509,693},{-509,695},{-505,694},{-502,695},{-508,695},{-508,696},{-504,696},{-508,697},{-502,698},{-503,700},{-523,701},{-546,707},{-541,708},{-530,708},{-506,703},{-507,704},{-505,705},{-508,704},{-509,705},{-508,705},{-510,706},{-507,706},{-515,707},{-507,707},{-509,709},{-520,710},{-512,710},{-509,710},{-523,711},{-515,713},{-526,712},{-523,714},{-514,715},{-529,714},{-517,717},{-527,720},{-534,718},{-533,719},{-535,720},{-539,718},{-537,716},{-541,717},{-539,716},{-555,714},{-557,716},{-556,717},{-559,717},{-546,720},{-556,720},{-549,723},{-548,725},{-547,727},{-551,727},{-546,728},{-548,730},{-557,731},{-551,732},{-551,734},{-561,737},{-558,738},{-556,739},{-564,741},{-561,743},{-573,741},{-563,743},{-567,744},{-561,744},{-568,745},{-562,745},{-570,747},{-572,748},{-568,748},{-570,749},{-579,752},{-584,753},{-584,754},{-587,754},{-581,755},{-586,757},{-584,757},{-591,757},{-592,759},{-596,759},{-622,763},{-634,764},{-638,762},{-664,791},{-649,795},{-648,796},{-651,797},{-649,798},{-651,798},{-649,799},{-651,800},{-636,801},{-640,801},{-639,803},{-641,803},{-644,801},{-670,800},{-674,802},{-674,803},{-659,807},{-652,806},{-656,807},{-636,811},{-627,807},{-633,811},{-611,811},{-609,812},{-608,815},{-614,817},{-608,819},{-590,819},{-587,817},{-565,813},{-595,820},{-586,821},{-559,823},{-551,821},{-556,823},{-545,824},{-536,821},{-535,819},{-539,817},{-537,815},{-535,815},{-536,817},{-530,818},{-529,820},{-501,816},{-496,816},{-511,819},{-495,819},{-508,822},{-512,825},{-499,825},{-464,821},{-461,819},{-452,818},{-447,818},{-442,818},{-450,820},{-443,821},{-449,822},{-447,823},{-423,822},{-439,823},{-437,824},{-458,828},{-421,828},{-422,827},{-416,825},{-417,827},{-420,827},{-418,828},{-400,824},{-397,825},{-401,825},{-399,826},{-447,829},{-451,829},{-449,830},{-441,829},{-434,829},{-450,830},{-456,831},{-429,831},{-427,833},{-418,832},{-420,831},{-395,830},{-386,828},{-385,828},{-392,830},{-373,830},{-388,831},{-370,831},{-388,832},{-387,833},{-389,834},{-378,834},{-381,835},{-377,835},{-365,834},{-370,835},{-348,836},{-339,835},{-342,836},{-303,836},{-257,833},{-319,831},{-335,832},{-325,831},{-357,829},{-353,829},{-356,828},{-340,829},{-338,829},{-340,828},{-338,827},{-337,828},{-336,829},{-317,829},{-301,831},{-253,832},{-248,830},{-259,828},{-240,829},{-238,829},{-241,828},{-234,829},{-213,826},{-226,823},{-250,822},{-301,822},{-300,821},{-328,818},{-321,817},{-314,818},{-277,820},{-245,820},{-247,818},{-263,814},{-233,817},{-233,819},{-231,820},{-213,821},{-210,819},{-210,817},{-213,815},{-229,811},{-226,811},{-240,806},{-206,814},{-198,815},{-189,816},{-195,814},{-185,815},{-171,814},{-172,815},{-167,815},{-170,816},{-169,816},{-164,816},{-165,817},{-165,818},{-156,818},{-137,818},{-113,815},{-133,810},{-143,810},{-145,810},{-141,808},{-155,806},{-173,808},{-175,807},{-174,806},{-181,806},{-195,807},{-209,806},{-202,805},{-204,804},{-194,806},{-157,804},{-169,802},{-193,803},{-205,801},{-200,801},{-205,798},{-200,797},{-195,798},{-199,798},{-197,799},{-190,801},{-172,800},{-179,797},{-190,797},{-194,796},{-193,796},{-194,795},{-227,797},{-229,759},{-195,757},{-194,757},{-196,757},{-193,754},{-196,751},{-221,757},{-214,755},{-225,755},{-214,754},{-205,751},{-212,751},{-218,750},{-221,751},{-225,752},{-206,751},{-208,749},{-206,747},{-211,747},{-197,746},{-194,747},{-193,746},{-194,745},{-190,745},{-196,742},{-202,743},{-204,744},{-212,745},{-217,744},{-221,746},{-218,744},{-208,744},{-201,742},{-211,741},{-220,742},{-219,744},{-225,743},{-220,743},{-224,742},{-222,741},{-225,741},{-220,740},{-218,739},{-219,736},{-217,737},{-219,740},{-217,741},{-205,737},{-204,735},{-206,734},{-216,735},{-225,733},{-241,737},{-228,735},{-225,736},{-223,736},{-228,736},{-241,738},{-245,737},{-245,735},{-257,740},{-247,735},{-260,732},{-274,735},{-264,732},{-277,731},{-274,731},{-274,730},{-272,731},{-261,732},{-262,728},{-267,729},{-274,729},{-264,728},{-268,727},{-263,727},{-264,726},{-255,728},{-247,727},{-249,725},{-259,724},{-263,724},{-255,722},{-255,720},{-244,723},{-245,712},{-246,713},{-251,713},{-256,715},{-269,716},{-279,720},{-287,721},{-273,717},{-285,715},{-259,715},{-254,713},{-268,709},{-279,711},{-276,709},{-284,710},{-279,709},{-283,706},{-293,705},{-263,704},{-286,701},{-274,700},{-269,703},{-263,702},{-253,704},{-254,704},{-239,701},{-221,701},{-233,699},{-229,698},{-230,698},{-234,699},{-239,698},{-236,696},{-238,695},{-243,696},{-241,694},{-248,694},{-246,693},{-247,692},{-252,693},{-250,692},{-253,691},{-253,690},{-256,691},{-255,690},{-264,687},{-278,685},{-276,685},{-280,686},{-280,684},{-292,684},{-291,683},{-294,682},{-299,684},{-301,683},{-303,683},{-300,681},{-307,683},{-308,682},{-304,681},{-310,682},{-312,682},{-309,681},{-316,681},{-316,682},{-315,682},{-320,683},{-321,685},{-323,684},{-325,686},{-324,685},{-326,685},{-321,682},{-322,682},{-325,682},{-320,681},{-322,680},{-320,679},{-332,677},{-331,676},{-334,675},{-336,674},{-337,672},{-340,670},{-339,670},{-341,668},{-343,666},{-344,668},{-345,666},{-344,665},{-346,664},{-351,664},{-353,663},{-351,662},{-358,664},{-357,663},{-358,663},{-357,662},{-358,662},{-360,661},{-361,659},{-364,661},{-370,659},{-371,661},{-373,661},{-372,659},{-375,660},{-374,659},{-371,659},{-372,658},{-378,659},{-377,660},{-378,660},{-372,663},{-379,664},{-382,663},{-377,663},{-381,661},{-380,661},{-385,660},{-382,656},{-388,657},{-394,657},{-392,656},{-397,657},{-398,655},{-402,655},{-400,653},{-401,652},{-411,651},{-410,650},{-412,649},{-407,645},{-416,643},{-406,641},{-406,640},{-408,639},{-406,639},{-415,639},{-417,638},{-408,635},{-412,635},{-413,636},{-412,634},{-414,636},{-416,635},{-412,633},{-416,634},{-417,636},{-419,635},{-419,632},{-421,632},{-422,632},{-420,630},{-423,629},{-426,628},{-432,627},{-421,624},{-430,625},{-423,623},{-425,619},{-421,620},{-424,619},{-423,618},{-428,618},{-429,618},{-426,617},{-422,617},{-431,616},{-424,615},{-429,613},{-433,613},{-427,612},{-426,612},{-432,612},{-427,611},{-426,611},{-436,611},{-428,609},{-435,609},{-435,608},{-433,607},{-432,606},{-428,606},{-429,606},{-433,605},{-436,605},{-437,607},{-441,606},{-442,606},{-438,604},{-436,603},{-433,602},{-442,602},{-440,603},{-441,604},{-447,601}}}, - {"Australia/Currie",6,{{1438,-397},{1440,-401},{1439,-401},{1438,-399},{1439,-396},{1441,-399}}}, - {"Asia/Harbin",120,{{1256,409},{1258,412},{1253,417},{1255,421},{1253,422},{1249,428},{1249,431},{1245,428},{1243,432},{1238,435},{1237,434},{1233,435},{1235,437},{1231,445},{1223,443},{1220,449},{1222,453},{1219,457},{1216,458},{1218,460},{1227,457},{1228,461},{1232,463},{1230,464},{1230,466},{1236,467},{1236,469},{1234,470},{1233,468},{1230,467},{1228,471},{1224,473},{1243,485},{1244,481},{1246,482},{1245,486},{1248,491},{1251,491},{1253,494},{1253,501},{1259,505},{1258,507},{1260,510},{1253,516},{1244,513},{1237,514},{1233,513},{1229,515},{1226,521},{1234,524},{1235,528},{1242,534},{1249,531},{1251,532},{1256,531},{1257,530},{1257,529},{1261,528},{1260,526},{1264,523},{1263,522},{1266,521},{1265,519},{1269,514},{1268,513},{1270,513},{1269,511},{1273,507},{1273,503},{1276,502},{1275,498},{1282,495},{1287,496},{1291,494},{1295,494},{1302,489},{1307,489},{1305,486},{1308,483},{1307,481},{1310,477},{1326,477},{1327,479},{1344,484},{1347,483},{1346,480},{1348,478},{1342,473},{1342,471},{1339,465},{1339,463},{1335,459},{1335,456},{1332,455},{1331,451},{1329,450},{1319,453},{1315,450},{1310,449},{1313,441},{1312,436},{1313,434},{1311,429},{1304,427},{1306,426},{1306,424},{1303,427},{1303,429},{1299,430},{1297,424},{1293,425},{1289,420},{1281,420},{1283,416},{1281,414},{1273,415},{1269,418},{1266,417},{1265,414},{1260,409}}}, - {"America/Belize",46,{{-881,163},{-882,163},{-877,167},{-883,165},{-881,168},{-882,168},{-881,169},{-880,170},{-881,171},{-880,171},{-875,174},{-875,175},{-878,175},{-878,176},{-879,181},{-880,181},{-881,175},{-882,175},{-882,176},{-881,176},{-881,177},{-880,177},{-880,176},{-880,175},{-880,178},{-880,179},{-882,177},{-879,180},{-879,182},{-876,172},{-879,172},{-883,166},{-889,159},{-892,159},{-891,179},{-888,179},{-885,185},{-883,185},{-884,183},{-881,183},{-879,173},{-878,173},{-878,172},{-881,173},{-881,174},{-878,174}}}, - {"America/Vancouver",790,{{-1233,487},{-1232,484},{-1233,486},{-1234,486},{-1234,487},{-1231,488},{-1230,488},{-1232,488},{-1232,487},{-1233,488},{-1253,489},{-1252,489},{-1252,490},{-1252,488},{-1234,488},{-1235,489},{-1235,487},{-1236,489},{-1236,490},{-1233,489},{-1234,489},{-1251,489},{-1254,490},{-1253,490},{-1305,545},{-1311,546},{-1310,546},{-1304,546},{-1304,547},{-1310,545},{-1309,545},{-1308,545},{-1308,544},{-1309,544},{-1307,544},{-1308,546},{-1309,546},{-1302,548},{-1302,547},{-1305,548},{-1304,548},{-1305,547},{-1306,548},{-1302,550},{-1301,550},{-1303,548},{-1296,550},{-1295,550},{-1295,551},{-1294,551},{-1294,552},{-1293,552},{-1293,551},{-1297,554},{-1298,553},{-1298,554},{-1298,555},{-1330,543},{-1330,542},{-1331,542},{-1295,542},{-1303,542},{-1304,543},{-1304,542},{-1305,543},{-1303,543},{-1332,539},{-1301,540},{-1302,540},{-1301,539},{-1302,539},{-1302,541},{-1307,540},{-1303,541},{-1303,540},{-1306,540},{-1287,535},{-1329,535},{-1330,535},{-1306,535},{-1304,535},{-1300,535},{-1299,535},{-1301,536},{-1302,536},{-1301,535},{-1300,536},{-1324,533},{-1325,533},{-1292,534},{-1293,534},{-1295,533},{-1295,534},{-1294,533},{-1291,534},{-1290,535},{-1289,533},{-1291,533},{-1321,537},{-1322,538},{-1321,538},{-1292,536},{-1290,537},{-1288,537},{-1289,536},{-1289,537},{-1324,536},{-1299,536},{-1329,536},{-1305,536},{-1306,536},{-1325,537},{-1324,537},{-1304,537},{-1288,538},{-1287,539},{-1287,538},{-1303,537},{-1302,538},{-1304,536},{-1291,537},{-1289,538},{-1323,538},{-1304,538},{-1303,538},{-1314,524},{-1305,538},{-1306,539},{-1307,539},{-1306,538},{-1304,540},{-1304,541},{-1305,539},{-1306,541},{-1301,541},{-1307,541},{-1308,541},{-1308,542},{-1302,542},{-1312,521},{-1316,526},{-1315,526},{-1314,526},{-1313,526},{-1291,526},{-1292,526},{-1291,525},{-1294,525},{-1314,525},{-1283,526},{-1284,525},{-1284,528},{-1283,527},{-1282,527},{-1283,528},{-1281,528},{-1285,526},{-1284,521},{-1283,521},{-1313,524},{-1313,523},{-1310,519},{-1311,520},{-1311,521},{-1309,521},{-1281,522},{-1285,522},{-1284,522},{-1283,522},{-1282,522},{-1311,523},{-1282,523},{-1285,523},{-1283,524},{-1283,523},{-1284,523},{-1280,523},{-1279,523},{-1279,522},{-1281,523},{-1284,524},{-1288,526},{-1288,527},{-1281,524},{-1287,525},{-1286,524},{-1287,523},{-1288,524},{-1280,525},{-1281,525},{-1312,524},{-1285,524},{-1283,525},{-1290,524},{-1290,525},{-1317,527},{-1317,526},{-1318,527},{-1318,528},{-1316,527},{-1316,528},{-1314,527},{-1294,527},{-1285,527},{-1285,529},{-1285,528},{-1286,525},{-1285,525},{-1288,525},{-1293,528},{-1289,526},{-1289,525},{-1321,529},{-1321,530},{-1324,530},{-1323,531},{-1326,531},{-1318,533},{-1316,530},{-1320,531},{-1319,529},{-1320,529},{-1317,528},{-1319,528},{-1310,522},{-1313,522},{-1313,521},{-1321,527},{-1320,528},{-1321,528},{-1324,529},{-1323,530},{-1322,530},{-1296,530},{-1295,530},{-1297,531},{-1296,531},{-1315,528},{-1294,528},{-1217,492},{-1294,529},{-1317,529},{-1287,529},{-1287,530},{-1315,529},{-1291,532},{-1286,531},{-1286,526},{-1288,528},{-1291,528},{-1288,530},{-1289,531},{-1290,531},{-1289,530},{-1292,529},{-1289,532},{-1318,530},{-1316,529},{-1318,529},{-1319,530},{-1218,493},{-1218,494},{-1218,496},{-1297,530},{-1292,530},{-1292,531},{-1287,532},{-1286,532},{-1298,531},{-1324,531},{-1325,531},{-1321,532},{-1293,533},{-1294,532},{-1294,534},{-1298,532},{-1294,531},{-1293,530},{-1296,532},{-1295,532},{-1320,532},{-1240,498},{-1266,497},{-1293,532},{-1292,533},{-1291,531},{-1293,531},{-1300,532},{-1301,533},{-1300,534},{-1303,534},{-1303,539},{-1278,516},{-1279,516},{-1323,536},{-1321,539},{-1321,540},{-1322,541},{-1316,542},{-1320,533},{-1326,532},{-1327,533},{-1328,533},{-1330,536},{-1328,536},{-1331,538},{-1326,541},{-1327,539},{-1323,541},{-1326,537},{-1327,537},{-1265,496},{-1266,496},{-1265,497},{-1264,497},{-1264,496},{-1241,497},{-1242,497},{-1241,498},{-1242,498},{-1261,493},{-1260,493},{-1233,494},{-1262,494},{-1261,494},{-1262,493},{-1235,494},{-1234,493},{-1234,494},{-1243,494},{-1243,495},{-1260,492},{-1259,492},{-1260,491},{-1242,495},{-1244,495},{-1218,495},{-1219,495},{-1234,495},{-1233,495},{-1240,495},{-1233,496},{-1247,495},{-1246,495},{-1248,495},{-1248,496},{-1246,498},{-1243,497},{-1241,495},{-1246,497},{-1239,492},{-1237,491},{-1238,492},{-1268,498},{-1270,498},{-1267,499},{-1268,496},{-1270,497},{-1271,498},{-1247,498},{-1247,499},{-1246,499},{-1248,499},{-1249,499},{-1248,500},{-1274,500},{-1272,500},{-1273,500},{-1275,501},{-1272,501},{-1251,504},{-1251,502},{-1250,502},{-1251,501},{-1252,501},{-1229,492},{-1230,492},{-1232,492},{-1231,492},{-1248,503},{-1248,501},{-1249,503},{-1247,503},{-1246,502},{-1250,503},{-1252,503},{-1251,503},{-1249,500},{-1250,501},{-1247,501},{-1252,500},{-1254,501},{-1253,503},{-1254,503},{-1227,492},{-1249,501},{-1250,500},{-1223,491},{-1224,491},{-1258,491},{-1232,491},{-1231,491},{-1238,491},{-1222,492},{-1220,492},{-1261,492},{-1221,492},{-1228,492},{-1259,491},{-1257,491},{-1258,492},{-1237,490},{-1236,491},{-1287,508},{-1286,508},{-1273,509},{-1275,511},{-1275,510},{-1276,511},{-1276,510},{-1278,513},{-1276,513},{-1274,513},{-1275,513},{-1277,513},{-1277,515},{-1280,516},{-1279,514},{-1281,516},{-1276,515},{-1278,515},{-1276,516},{-1281,518},{-1282,519},{-1282,520},{-1285,519},{-1284,519},{-1284,520},{-1282,518},{-1283,518},{-1280,518},{-1280,517},{-1283,519},{-1280,519},{-1280,521},{-1281,517},{-1279,509},{-1280,509},{-1268,509},{-1269,509},{-1278,509},{-1259,504},{-1253,504},{-1284,508},{-1269,505},{-1236,488},{-1236,485},{-1233,485},{-1237,483},{-1248,487},{-1247,487},{-1247,488},{-1249,487},{-1249,490},{-1248,491},{-1248,493},{-1252,491},{-1251,490},{-1255,489},{-1256,492},{-1258,494},{-1259,493},{-1259,494},{-1260,495},{-1263,495},{-1263,493},{-1266,494},{-1260,496},{-1261,497},{-1264,498},{-1265,498},{-1268,500},{-1268,499},{-1269,500},{-1269,499},{-1272,499},{-1271,500},{-1271,501},{-1273,502},{-1274,502},{-1279,501},{-1277,503},{-1280,503},{-1279,505},{-1276,505},{-1274,503},{-1275,505},{-1275,506},{-1274,506},{-1280,507},{-1276,506},{-1280,504},{-1254,504},{-1255,504},{-1277,505},{-1257,504},{-1258,504},{-1258,505},{-1260,504},{-1269,506},{-1267,506},{-1268,506},{-1265,506},{-1266,505},{-1266,506},{-1264,505},{-1267,505},{-1262,506},{-1270,506},{-1266,507},{-1267,507},{-1262,507},{-1266,508},{-1275,509},{-1275,508},{-1276,508},{-1276,509},{-1267,509},{-1268,508},{-1269,508},{-1266,509},{-1271,508},{-1267,508},{-1265,508},{-1270,508},{-1277,509},{-1277,508},{-1263,506},{-1272,506},{-1269,507},{-1263,507},{-1264,508},{-1263,508},{-1262,508},{-1283,520},{-1274,524},{-1272,524},{-1279,519},{-1278,522},{-1282,521},{-1280,522},{-1279,521},{-1281,521},{-1350,593},{-1350,596},{-1355,598},{-1363,596},{-1362,595},{-1365,595},{-1366,592},{-1375,589},{-1376,592},{-1391,600},{-1200,600},{-1200,572},{-1204,572},{-1205,575},{-1217,572},{-1219,570},{-1231,571},{-1238,569},{-1238,568},{-1236,565},{-1235,559},{-1229,556},{-1230,554},{-1226,554},{-1219,549},{-1216,548},{-1214,545},{-1208,545},{-1205,541},{-1202,541},{-1203,540},{-1197,537},{-1199,536},{-1197,534},{-1190,531},{-1189,532},{-1184,529},{-1182,524},{-1187,522},{-1181,519},{-1182,518},{-1179,517},{-1180,515},{-1172,513},{-1173,513},{-1172,510},{-1166,506},{-1167,505},{-1164,500},{-1169,498},{-1169,496},{-1167,493},{-1170,492},{-1169,490},{-1231,490},{-1221,491},{-1214,494},{-1217,493},{-1221,498},{-1219,492},{-1224,492},{-1222,493},{-1222,495},{-1226,493},{-1225,494},{-1225,495},{-1226,495},{-1233,493},{-1228,493},{-1229,494},{-1230,493},{-1231,497},{-1233,501},{-1232,497},{-1238,495},{-1238,496},{-1236,497},{-1235,497},{-1238,497},{-1237,497},{-1237,498},{-1239,498},{-1239,499},{-1240,500},{-1237,501},{-1238,502},{-1240,502},{-1238,501},{-1240,499},{-1245,498},{-1247,500},{-1247,504},{-1245,504},{-1243,505},{-1249,506},{-1248,509},{-1247,509},{-1245,508},{-1244,509},{-1243,510},{-1249,510},{-1250,511},{-1251,512},{-1250,512},{-1250,510},{-1250,508},{-1252,504},{-1253,505},{-1251,505},{-1254,506},{-1256,504},{-1254,507},{-1263,505},{-1259,506},{-1257,507},{-1255,509},{-1256,511},{-1256,508},{-1260,507},{-1260,508},{-1262,509},{-1261,510},{-1262,511},{-1261,511},{-1262,512},{-1265,510},{-1265,511},{-1265,512},{-1265,509},{-1268,510},{-1272,509},{-1274,509},{-1272,510},{-1273,510},{-1268,511},{-1267,510},{-1267,512},{-1277,511},{-1278,512},{-1275,512},{-1273,512},{-1271,513},{-1278,514},{-1272,514},{-1273,517},{-1266,516},{-1267,518},{-1267,517},{-1274,517},{-1274,518},{-1274,519},{-1275,518},{-1275,517},{-1277,517},{-1275,516},{-1277,516},{-1279,517},{-1271,523},{-1267,520},{-1270,523},{-1263,524},{-1272,523},{-1272,525},{-1270,526},{-1269,527},{-1270,528},{-1271,529},{-1270,527},{-1272,526},{-1273,524},{-1276,526},{-1275,523},{-1278,523},{-1279,524},{-1277,524},{-1279,525},{-1280,526},{-1282,524},{-1280,527},{-1279,528},{-1278,527},{-1280,528},{-1280,529},{-1284,530},{-1285,531},{-1284,531},{-1288,535},{-1285,533},{-1284,535},{-1281,534},{-1278,531},{-1275,531},{-1281,535},{-1280,535},{-1285,534},{-1288,536},{-1285,538},{-1285,543},{-1288,539},{-1290,539},{-1290,538},{-1294,536},{-1300,542},{-1298,540},{-1297,540},{-1297,539},{-1296,539},{-1299,542},{-1296,542},{-1293,543},{-1301,543},{-1302,544},{-1305,544},{-1300,543},{-1301,544},{-1300,545},{-1300,546},{-1299,546},{-1301,549},{-1302,549},{-1300,550},{-1297,550},{-1295,554},{-1295,555},{-1296,554},{-1298,556},{-1299,553},{-1301,556},{-1300,559},{-1301,561},{-1318,566},{-1319,568},{-1321,569},{-1320,570},{-1324,571},{-1322,572},{-1334,584}}}, - {"Pacific/Pago_Pago",11,{{-1695,-142},{-1694,-143},{-1695,-143},{-1708,-143},{-1707,-142},{-1706,-143},{-1708,-144},{-1705,-143},{-1696,-142},{-1697,-142},{-1711,-111}}}, - {"Asia/Magadan",266,{{1599,609},{1611,692},{1611,693},{1610,693},{1513,715},{1520,710},{1521,710},{1518,712},{1517,713},{1518,713},{1503,715},{1502,715},{1515,713},{1512,714},{1513,714},{1506,591},{1508,591},{1505,590},{1505,591},{1490,591},{1492,592},{1555,592},{1553,592},{1491,593},{1556,593},{1555,593},{1544,595},{1544,596},{1504,596},{1614,694},{1615,694},{1616,694},{1620,695},{1619,695},{1611,696},{1611,695},{1620,696},{1610,697},{1611,697},{1605,697},{1606,697},{1607,697},{1601,697},{1602,697},{1624,706},{1623,706},{1625,706},{1617,706},{1617,707},{1619,696},{1610,696},{1610,695},{1621,696},{1613,696},{1509,714},{1508,714},{1508,715},{1509,715},{1616,695},{1617,695},{1613,694},{1614,695},{1615,696},{1614,696},{1618,696},{1618,695},{1616,696},{1617,696},{1544,600},{1545,599},{1542,599},{1542,597},{1541,594},{1544,594},{1545,594},{1550,595},{1552,593},{1552,592},{1545,592},{1540,590},{1538,592},{1534,592},{1529,589},{1524,591},{1521,589},{1514,588},{1511,591},{1523,592},{1517,593},{1514,596},{1508,594},{1505,595},{1508,596},{1496,598},{1491,596},{1492,595},{1488,595},{1487,594},{1490,594},{1489,592},{1484,592},{1482,594},{1475,592},{1469,594},{1471,594},{1471,599},{1468,599},{1464,603},{1458,602},{1455,605},{1461,607},{1464,607},{1465,609},{1467,610},{1468,614},{1460,620},{1447,621},{1452,623},{1451,625},{1455,625},{1452,632},{1456,637},{1455,638},{1463,641},{1459,644},{1449,645},{1444,649},{1433,652},{1408,656},{1401,656},{1400,656},{1402,658},{1396,663},{1400,665},{1404,664},{1405,666},{1389,672},{1402,677},{1413,679},{1412,682},{1410,684},{1420,686},{1420,688},{1415,692},{1428,692},{1424,695},{1425,696},{1421,696},{1423,698},{1418,698},{1409,700},{1409,701},{1420,708},{1426,711},{1425,713},{1426,715},{1438,722},{1445,721},{1476,723},{1492,722},{1501,719},{1496,717},{1495,719},{1493,719},{1491,717},{1499,717},{1506,715},{1516,713},{1517,710},{1523,709},{1560,711},{1582,710},{1599,706},{1601,703},{1597,699},{1610,692},{1612,692},{1624,697},{1624,694},{1628,692},{1625,691},{1625,690},{1628,689},{1626,688},{1627,686},{1624,683},{1614,684},{1585,681},{1581,679},{1583,677},{1578,677},{1577,675},{1579,674},{1579,673},{1588,670},{1589,668},{1584,664},{1592,662},{1589,657},{1600,655},{1605,652},{1613,651},{1619,648},{1633,647},{1632,646},{1635,644},{1628,641},{1629,639},{1627,638},{1630,635},{1627,634},{1628,632},{1623,631},{1623,629},{1628,627},{1627,626},{1627,623},{1622,622},{1625,621},{1623,619},{1625,617},{1616,613},{1608,607},{1604,607},{1602,606},{1602,608},{1604,610},{1598,609},{1600,611},{1598,612},{1603,615},{1604,619},{1596,617},{1596,618},{1592,619},{1580,617},{1575,618},{1567,615},{1567,612},{1559,609},{1559,607},{1615,708},{1617,708},{1616,709},{1615,709},{1522,709},{1521,709},{1607,708},{1605,708},{1605,709},{1608,708},{1505,715},{1504,715},{1512,715},{1511,716},{1503,716},{1502,716},{1504,716},{1510,715},{1507,715},{1501,716},{1494,718},{1495,718},{1507,714},{1511,714},{1510,714}}}, - {"Asia/Tbilisi",29,{{426,416},{425,414},{415,415},{418,419},{415,427},{409,431},{403,432},{400,434},{401,436},{407,436},{416,432},{429,432},{438,428},{438,426},{445,428},{448,426},{452,427},{458,425},{456,422},{464,420},{463,416},{467,413},{465,411},{453,415},{448,413},{449,412},{435,411},{432,412},{428,416}}}, - {"Asia/Yerevan",31,{{450,413},{452,412},{451,411},{451,410},{454,410},{456,409},{454,407},{454,405},{460,403},{459,400},{456,400},{462,396},{466,396},{464,394},{466,392},{464,392},{465,389},{461,388},{458,396},{455,395},{451,398},{448,397},{444,400},{436,401},{435,405},{437,407},{435,411},{450,411},{452,410},{455,407},{455,406}}}, - {"Europe/Tallinn",80,{{218,583},{226,582},{225,581},{225,582},{218,584},{219,584},{233,578},{232,578},{241,582},{240,581},{240,582},{234,586},{232,585},{231,586},{232,587},{232,588},{231,588},{230,588},{240,593},{244,595},{248,594},{248,596},{254,595},{257,597},{282,594},{279,592},{275,586},{275,582},{278,579},{275,578},{273,575},{269,576},{265,575},{260,578},{253,581},{244,579},{246,583},{235,586},{235,587},{238,588},{235,588},{234,589},{237,590},{234,590},{235,592},{234,588},{230,589},{231,589},{226,586},{230,586},{233,585},{223,582},{220,579},{222,581},{220,584},{218,585},{221,584},{238,583},{233,584},{234,585},{235,585},{226,587},{224,589},{220,589},{226,591},{234,593},{239,593},{239,594},{240,594},{231,590},{233,590},{232,590},{251,596},{250,596},{258,597},{252,596},{245,595},{245,596},{246,596},{247,596}}}, - {"Pacific/Johnston",1,{{-1695,167}}}, - {"Asia/Baku",71,{{499,403},{463,418},{464,419},{467,419},{473,413},{478,412},{484,416},{485,419},{495,406},{501,406},{503,404},{504,402},{499,404},{495,402},{493,395},{494,393},{493,393},{492,390},{491,389},{492,391},{489,392},{489,384},{486,384},{480,388},{484,390},{481,392},{484,394},{480,397},{465,389},{464,392},{466,392},{464,394},{466,396},{462,396},{456,400},{459,400},{460,403},{454,405},{454,407},{456,409},{451,410},{452,412},{450,412},{453,415},{459,412},{466,411},{467,413},{463,415},{455,407},{455,406},{505,403},{505,404},{506,403},{500,403},{496,400},{495,399},{497,400},{490,392},{450,394},{448,397},{451,398},{455,395},{458,396},{461,388},{455,390},{494,398},{503,405},{504,404},{452,410},{450,411},{501,403}}}, - {"America/North_Dakota/New_Salem",7,{{-1009,470},{-1005,465},{-1010,463},{-1013,464},{-1013,466},{-1021,467},{-1021,470}}}, - {"Europe/Vilnius",28,{{211,561},{220,564},{245,563},{249,564},{251,562},{257,561},{266,557},{265,553},{269,553},{258,548},{256,543},{258,542},{255,542},{255,543},{248,541},{248,540},{236,539},{234,542},{228,544},{227,546},{229,548},{226,551},{221,550},{213,553},{210,553},{209,553},{211,557},{211,554}}}, - {"America/Indiana/Petersburg",4,{{-871,385},{-871,382},{-873,382},{-875,385}}}, - {"Asia/Tehran",199,{{514,279},{515,279},{515,278},{509,290},{509,291},{504,293},{503,293},{507,293},{508,291},{507,291},{506,292},{503,292},{569,270},{568,270},{565,270},{564,270},{564,271},{565,271},{568,271},{566,271},{566,272},{565,272},{592,255},{581,256},{582,256},{583,256},{578,257},{545,259},{544,261},{551,262},{551,263},{545,263},{571,264},{571,263},{553,263},{585,256},{584,256},{536,267},{537,267},{556,268},{559,266},{558,266},{559,267},{540,265},{539,265},{539,266},{540,266},{533,268},{532,268},{531,268},{534,268},{563,268},{563,269},{564,269},{564,268},{559,269},{563,270},{553,266},{558,268},{557,269},{556,269},{557,268},{558,269},{536,368},{536,369},{491,305},{492,305},{492,304},{490,305},{491,304},{490,304},{491,301},{492,301},{492,302},{490,302},{491,302},{489,303},{489,304},{611,315},{617,314},{618,310},{609,299},{618,286},{628,283},{628,272},{633,271},{632,266},{624,266},{623,264},{618,262},{617,253},{614,251},{606,253},{605,254},{605,253},{591,254},{586,256},{573,258},{570,270},{567,272},{556,270},{555,268},{552,268},{548,265},{543,267},{535,270},{527,273},{524,276},{510,288},{508,289},{506,295},{501,299},{501,302},{496,300},{492,303},{489,305},{489,300},{485,300},{484,302},{480,305},{480,310},{477,310},{479,318},{475,324},{461,330},{462,333},{454,340},{456,341},{454,345},{455,346},{457,345},{457,347},{459,351},{462,351},{460,356},{463,358},{458,358},{455,360},{453,360},{453,364},{451,364},{451,367},{448,368},{449,370},{447,371},{448,373},{446,374},{446,377},{442,379},{445,383},{443,384},{443,388},{440,394},{444,394},{446,398},{454,390},{462,388},{465,389},{480,397},{484,394},{481,392},{484,390},{480,388},{486,384},{489,384},{491,377},{502,374},{507,369},{518,366},{540,369},{540,368},{539,373},{547,374},{549,378},{555,381},{563,381},{565,383},{572,383},{574,379},{584,376},{588,377},{593,375},{596,371},{600,370},{604,366},{612,366},{611,360},{613,356},{611,348},{607,345},{609,343},{607,343},{605,341},{606,336},{609,335},{606,331},{609,322},{609,315},{506,294}}}, - {"America/Inuvik",4,{{-1334,683},{-1337,683},{-1338,684},{-1336,683}}}, - {"Europe/Lisbon",53,{{-79,370},{-80,370},{-78,370},{-87,384},{-88,385},{-87,385},{-87,407},{-90,389},{-75,375},{-74,372},{-85,372},{-90,370},{-87,377},{-89,385},{-88,384},{-86,384},{-87,386},{-92,384},{-93,387},{-90,386},{-89,390},{-88,390},{-88,391},{-87,391},{-91,387},{-95,388},{-94,394},{-91,396},{-86,407},{-87,409},{-88,406},{-86,411},{-88,417},{-87,417},{-89,418},{-82,421},{-81,418},{-66,420},{-66,417},{-62,416},{-69,410},{-68,404},{-70,402},{-69,400},{-70,397},{-75,397},{-70,391},{-73,384},{-71,382},{-69,382},{-91,388},{-91,389},{-90,388}}}, - {"Europe/Vatican",2,{{124,419},{125,419}}}, - {"Pacific/Chatham",25,{{-1762,-444},{-1763,-444},{-1759,-443},{-1763,-443},{-1764,-443},{-1762,-443},{-1763,-442},{-1762,-442},{-1761,-443},{-1759,-440},{-1758,-440},{-1769,-439},{-1762,-437},{-1768,-436},{-1764,-438},{-1765,-441},{-1763,-440},{-1764,-439},{-1765,-439},{-1767,-438},{-1769,-438},{-1766,-437},{-1763,-441},{-1766,-441},{-1760,-442}}}, - {"Antarctica/Macquarie",4,{{1588,-548},{1589,-545},{1590,-545},{1589,-548}}}, - {"America/Araguaina",53,{{-470,-80},{-466,-79},{-465,-81},{-465,-84},{-468,-85},{-471,-90},{-465,-95},{-467,-98},{-463,-102},{-458,-103},{-463,-108},{-462,-109},{-466,-113},{-461,-116},{-463,-118},{-461,-119},{-463,-121},{-463,-124},{-462,-125},{-462,-128},{-475,-133},{-477,-131},{-478,-133},{-482,-132},{-482,-130},{-488,-132},{-490,-126},{-494,-132},{-504,-128},{-503,-125},{-505,-128},{-506,-128},{-507,-115},{-506,-107},{-501,-93},{-493,-84},{-492,-78},{-494,-75},{-492,-73},{-492,-69},{-484,-64},{-483,-57},{-481,-56},{-484,-54},{-487,-54},{-485,-52},{-479,-52},{-475,-56},{-474,-63},{-475,-70},{-477,-72},{-475,-73},{-476,-74}}}, - {"Asia/Thimphu",17,{{920,272},{921,269},{919,268},{907,268},{904,269},{899,267},{891,268},{888,271},{894,280},{900,283},{904,282},{904,281},{911,280},{913,281},{917,280},{916,275},{920,275}}}, - {"Atlantic/Madeira",12,{{-159,301},{-159,302},{-165,325},{-165,324},{-165,326},{-164,330},{-163,331},{-164,331},{-167,327},{-169,328},{-169,326},{-173,328}}}, - {"America/Coral_Harbour",76,{{-824,639},{-825,639},{-832,640},{-828,629},{-819,629},{-820,627},{-831,622},{-837,621},{-840,624},{-835,629},{-828,630},{-827,630},{-826,630},{-862,649},{-862,650},{-817,644},{-862,641},{-815,642},{-814,642},{-836,632},{-837,632},{-857,637},{-849,660},{-851,661},{-850,661},{-848,659},{-847,659},{-848,660},{-855,659},{-851,658},{-850,656},{-853,655},{-849,652},{-845,655},{-841,652},{-834,651},{-832,649},{-818,646},{-816,641},{-820,640},{-814,641},{-809,640},{-809,641},{-805,639},{-807,639},{-801,638},{-811,634},{-825,637},{-831,640},{-829,641},{-831,642},{-837,640},{-836,638},{-843,636},{-846,633},{-854,631},{-856,632},{-856,636},{-857,638},{-872,636},{-869,639},{-864,646},{-861,649},{-861,655},{-860,658},{-845,656},{-847,658},{-846,658},{-851,657},{-850,657},{-847,655},{-846,655},{-849,657},{-850,660},{-846,656},{-852,660}}}, - {"Pacific/Funafuti",13,{{1799,-94},{1798,-94},{1791,-86},{1792,-85},{1784,-80},{1787,-75},{1787,-74},{1772,-72},{1771,-72},{1763,-63},{1773,-61},{1761,-57},{1761,-56}}}, - {"Indian/Mahe",58,{{510,-92},{512,-102},{512,-101},{477,-101},{478,-101},{465,-97},{465,-98},{477,-97},{476,-97},{475,-97},{476,-98},{510,-95},{463,-94},{462,-94},{507,-93},{563,-71},{562,-72},{528,-71},{528,-70},{527,-70},{527,-72},{528,-72},{531,-62},{530,-62},{532,-62},{530,-59},{554,-59},{533,-58},{464,-94},{465,-94},{463,-95},{462,-93},{464,-93},{463,-93},{537,-57},{532,-57},{533,-54},{533,-51},{554,-47},{559,-46},{560,-46},{553,-45},{552,-45},{552,-44},{553,-44},{555,-48},{554,-46},{555,-47},{555,-46},{559,-43},{558,-43},{557,-43},{557,-42},{557,-38},{552,-37},{559,-44},{558,-44},{556,-43}}}, - {"Australia/Adelaide",119,{{1361,-353},{1322,-321},{1332,-323},{1335,-324},{1338,-324},{1335,-323},{1336,-323},{1337,-322},{1343,-339},{1343,-340},{1369,-337},{1361,-352},{1345,-337},{1344,-338},{1348,-336},{1347,-332},{1346,-332},{1343,-327},{1378,-326},{1333,-326},{1333,-325},{1337,-325},{1337,-324},{1334,-324},{1336,-325},{1372,-360},{1367,-361},{1365,-359},{1366,-358},{1376,-356},{1376,-357},{1378,-357},{1378,-358},{1377,-358},{1379,-357},{1381,-358},{1377,-359},{1375,-361},{1365,-352},{1364,-352},{1365,-351},{1356,-350},{1360,-350},{1362,-350},{1362,-351},{1361,-349},{1360,-349},{1385,-348},{1386,-348},{1348,-347},{1348,-346},{1359,-347},{1360,-347},{1363,-347},{1364,-347},{1363,-346},{1360,-346},{1359,-346},{1373,-345},{1374,-345},{1342,-340},{1363,-345},{1350,-260},{1410,-260},{1410,-381},{1404,-379},{1398,-373},{1397,-370},{1399,-367},{1397,-363},{1389,-356},{1394,-358},{1388,-355},{1381,-356},{1384,-354},{1381,-341},{1378,-351},{1369,-353},{1368,-352},{1370,-349},{1374,-349},{1374,-341},{1380,-336},{1378,-333},{1380,-331},{1379,-330},{1379,-328},{1377,-324},{1378,-330},{1374,-331},{1372,-337},{1366,-339},{1361,-345},{1359,-345},{1358,-348},{1351,-346},{1352,-344},{1354,-346},{1355,-346},{1353,-340},{1344,-332},{1344,-331},{1343,-330},{1343,-332},{1341,-330},{1341,-327},{1342,-328},{1343,-326},{1341,-325},{1338,-325},{1339,-324},{1337,-321},{1331,-322},{1327,-319},{1322,-320},{1312,-315},{1308,-316},{1290,-317},{1290,-260}}}, - {"Africa/Freetown",49,{{-132,81},{-131,85},{-131,86},{-132,89},{-130,86},{-131,77},{-125,77},{-115,69},{-116,70},{-124,74},{-125,75},{-125,74},{-130,76},{-131,76},{-130,77},{-127,75},{-126,76},{-125,76},{-126,77},{-111,73},{-114,69},{-123,74},{-123,75},{-125,78},{-127,77},{-130,79},{-128,79},{-130,82},{-132,82},{-133,85},{-131,84},{-129,86},{-132,85},{-133,88},{-131,88},{-133,90},{-128,93},{-124,99},{-112,100},{-107,93},{-107,91},{-106,90},{-105,87},{-106,85},{-107,83},{-103,85},{-103,82},{-105,81},{-106,78}}}, - {"Atlantic/South_Georgia",47,{{-272,-595},{-273,-595},{-273,-594},{-274,-594},{-271,-594},{-266,-590},{-265,-590},{-265,-591},{-267,-590},{-262,-584},{-262,-585},{-265,-584},{-264,-584},{-265,-578},{-265,-577},{-264,-578},{-271,-567},{-272,-567},{-276,-563},{-275,-563},{-268,-571},{-267,-571},{-266,-571},{-377,-541},{-378,-541},{-370,-545},{-371,-545},{-418,-536},{-418,-537},{-382,-540},{-373,-540},{-380,-540},{-381,-540},{-358,-548},{-370,-541},{-365,-542},{-367,-543},{-365,-544},{-362,-543},{-361,-549},{-365,-545},{-374,-543},{-372,-541},{-377,-542},{-376,-540},{-380,-541},{-374,-540}}}, - {"Africa/Accra",35,{{7,58},{2,57},{-21,47},{-31,51},{-28,51},{-27,54},{-28,56},{-30,57},{-32,68},{-30,72},{-28,79},{-25,82},{-28,91},{-27,92},{-28,104},{-29,106},{-28,110},{-6,109},{-3,112},{0,111},{-1,106},{4,103},{4,96},{2,95},{6,94},{5,89},{4,87},{7,83},{6,82},{5,75},{7,73},{5,68},{8,64},{12,62},{9,58}}}, - {"America/North_Dakota/Beulah",6,{{-1013,473},{-1018,472},{-1018,470},{-1021,470},{-1022,476},{-1014,476}}}, - {"America/Jamaica",14,{{-770,179},{-771,179},{-763,180},{-762,179},{-765,178},{-768,180},{-769,178},{-772,177},{-777,179},{-781,182},{-784,183},{-782,185},{-773,185},{-769,184}}}, - {"America/Scoresbysund",48,{{-217,715},{-218,715},{-215,707},{-217,713},{-218,713},{-216,715},{-225,716},{-237,722},{-215,706},{-216,706},{-214,706},{-214,707},{-216,708},{-225,708},{-217,709},{-216,709},{-244,723},{-225,719},{-231,716},{-224,718},{-227,716},{-219,717},{-226,715},{-224,712},{-222,715},{-219,715},{-219,714},{-217,714},{-219,713},{-216,713},{-217,712},{-217,711},{-219,712},{-223,710},{-220,710},{-216,710},{-219,708},{-218,707},{-216,707},{-218,706},{-215,705},{-224,705},{-225,709},{-227,707},{-226,704},{-240,706},{-242,710},{-245,712}}}, - {"America/Swift_Current",1,{{-1078,503}}}, - {"Europe/Tirane",27,{{193,405},{203,398},{202,396},{200,397},{199,400},{195,402},{193,404},{195,404},{193,407},{195,409},{194,414},{196,416},{193,422},{197,427},{198,425},{201,426},{205,422},{206,420},{205,416},{205,412},{207,409},{210,409},{211,407},{207,401},{203,400},{204,398},{195,410}}}, - {"Asia/Ashgabat",93,{{535,396},{535,397},{526,415},{525,415},{529,408},{531,387},{530,389},{530,391},{531,391},{647,368},{644,362},{641,360},{631,359},{632,357},{631,354},{623,351},{621,354},{616,354},{612,357},{611,367},{604,366},{600,370},{596,371},{593,375},{588,377},{584,376},{574,379},{572,383},{564,382},{563,381},{555,381},{549,378},{547,374},{539,373},{538,385},{540,389},{535,393},{532,394},{532,392},{531,394},{533,397},{532,395},{535,395},{536,396},{536,395},{537,396},{534,397},{534,400},{529,400},{529,399},{528,400},{527,405},{529,410},{524,418},{530,421},{542,423},{548,420},{555,413},{570,413},{572,414},{570,414},{570,419},{574,422},{579,422},{580,425},{585,423},{581,426},{586,427},{586,428},{594,423},{600,422},{599,420},{603,418},{601,418},{601,414},{604,413},{613,411},{614,413},{619,411},{621,406},{623,404},{625,400},{654,383},{667,380},{665,373},{657,375},{655,372},{648,371},{531,397},{535,399},{530,398},{531,398},{530,399}}}, - {"America/Moncton",79,{{-668,446},{-667,447},{-668,447},{-667,446},{-669,446},{-668,448},{-667,449},{-667,450},{-670,449},{-669,449},{-669,450},{-669,448},{-670,450},{-648,467},{-649,468},{-648,468},{-650,471},{-651,471},{-651,472},{-650,472},{-650,473},{-649,473},{-648,478},{-645,479},{-645,478},{-646,478},{-647,478},{-649,478},{-645,480},{-646,479},{-662,480},{-661,480},{-667,480},{-668,480},{-668,481},{-667,481},{-670,451},{-671,451},{-638,462},{-645,462},{-646,463},{-645,463},{-646,464},{-669,451},{-668,451},{-668,450},{-664,481},{-658,479},{-656,476},{-651,478},{-654,471},{-648,471},{-649,469},{-650,468},{-647,467},{-646,462},{-638,461},{-641,461},{-645,457},{-645,458},{-645,459},{-646,460},{-648,456},{-659,452},{-661,453},{-670,452},{-673,451},{-675,453},{-674,456},{-678,457},{-678,471},{-682,474},{-689,472},{-691,473},{-684,476},{-684,479},{-681,480},{-676,480},{-674,478}}}, - {"Europe/Vaduz",3,{{95,473},{96,471},{95,471}}}, - {"Australia/Eucla",7,{{1290,-313},{1290,-317},{1283,-320},{1272,-323},{1262,-322},{1255,-326},{1255,-313}}}, - {"America/Montserrat",3,{{-622,167},{-622,168},{-621,167}}}, - {"America/Glace_Bay",13,{{-604,462},{-597,460},{-598,460},{-600,462},{-598,462},{-600,460},{-602,459},{-602,457},{-607,458},{-604,460},{-608,459},{-603,463},{-602,461}}}, - {"Atlantic/Stanley",159,{{-583,-519},{-596,-519},{-598,-519},{-612,-519},{-612,-518},{-605,-519},{-605,-518},{-587,-519},{-597,-519},{-585,-519},{-586,-519},{-611,-519},{-592,-529},{-589,-525},{-589,-524},{-590,-524},{-591,-525},{-591,-524},{-596,-523},{-595,-523},{-597,-524},{-596,-524},{-598,-524},{-598,-523},{-597,-523},{-607,-522},{-609,-522},{-605,-522},{-604,-522},{-586,-522},{-586,-521},{-597,-520},{-591,-521},{-597,-521},{-610,-520},{-583,-520},{-584,-520},{-585,-520},{-609,-520},{-609,-512},{-608,-512},{-602,-512},{-603,-512},{-584,-521},{-599,-520},{-598,-520},{-596,-520},{-587,-521},{-608,-521},{-598,-522},{-598,-521},{-597,-522},{-590,-523},{-590,-522},{-588,-522},{-589,-522},{-588,-521},{-590,-521},{-599,-521},{-599,-512},{-604,-512},{-608,-511},{-607,-511},{-609,-511},{-611,-511},{-611,-510},{-612,-511},{-613,-510},{-612,-510},{-580,-518},{-581,-518},{-582,-518},{-613,-519},{-613,-518},{-611,-518},{-609,-518},{-600,-514},{-592,-514},{-603,-520},{-605,-521},{-606,-523},{-607,-521},{-610,-521},{-605,-520},{-604,-519},{-606,-519},{-602,-518},{-606,-518},{-606,-517},{-600,-517},{-606,-513},{-601,-515},{-584,-515},{-582,-517},{-579,-514},{-577,-515},{-582,-516},{-577,-517},{-583,-517},{-584,-518},{-582,-519},{-584,-519},{-589,-518},{-586,-520},{-593,-520},{-595,-521},{-593,-524},{-596,-521},{-595,-518},{-591,-517},{-590,-518},{-590,-517},{-592,-516},{-589,-515},{-591,-515},{-589,-514},{-590,-512},{-584,-513},{-583,-515},{-585,-514},{-586,-514},{-595,-517},{-599,-513},{-598,-513},{-613,-517},{-612,-517},{-610,-518},{-596,-518},{-597,-518},{-603,-516},{-604,-516},{-605,-516},{-607,-517},{-607,-516},{-580,-516},{-581,-516},{-583,-516},{-607,-515},{-605,-515},{-605,-513},{-606,-512},{-597,-513},{-601,-514},{-602,-514},{-598,-514},{-599,-514},{-596,-514},{-597,-514},{-607,-514},{-607,-513},{-604,-514},{-603,-514},{-603,-513},{-600,-513},{-596,-513},{-595,-513},{-594,-513},{-608,-516},{-609,-516}}}, - {"Africa/Bujumbura",16,{{302,-40},{298,-45},{294,-44},{292,-31},{290,-28},{291,-26},{293,-27},{294,-28},{297,-28},{299,-27},{300,-23},{306,-24},{304,-29},{308,-30},{308,-33},{304,-36}}}, - {"Africa/Porto-Novo",27,{{27,77},{27,64},{16,62},{18,63},{16,67},{16,90},{13,95},{14,100},{8,104},{9,110},{11,110},{11,113},{14,115},{20,114},{25,120},{24,122},{28,124},{36,117},{35,113},{37,111},{39,106},{38,104},{36,104},{36,99},{31,95},{31,91},{28,91}}}, - {"America/Argentina/Rio_Gallegos",51,{{-672,-488},{-690,-516},{-692,-509},{-692,-510},{-716,-460},{-676,-460},{-674,-466},{-668,-470},{-657,-472},{-659,-478},{-658,-479},{-660,-480},{-659,-481},{-671,-487},{-676,-491},{-678,-499},{-683,-501},{-686,-499},{-684,-502},{-691,-506},{-689,-515},{-692,-517},{-684,-523},{-684,-524},{-700,-520},{-720,-520},{-720,-519},{-724,-516},{-723,-513},{-724,-511},{-723,-510},{-723,-507},{-727,-506},{-731,-508},{-736,-503},{-734,-498},{-736,-495},{-735,-492},{-731,-491},{-726,-488},{-726,-485},{-723,-483},{-725,-477},{-720,-472},{-719,-472},{-719,-468},{-716,-467},{-719,-461},{-662,-485},{-662,-483},{-661,-481}}}, - {"America/Grenada",8,{{-616,122},{-616,120},{-618,120},{-617,122},{-616,123},{-615,124},{-615,125},{-614,125}}}, - {"Asia/Novokuznetsk",41,{{886,568},{887,567},{885,566},{886,564},{891,563},{895,559},{884,553},{888,548},{884,544},{892,543},{892,541},{890,541},{893,538},{888,536},{888,534},{890,533},{891,531},{889,530},{892,528},{887,522},{884,522},{884,525},{872,526},{869,529},{871,531},{867,532},{870,535},{866,535},{861,540},{851,545},{849,554},{846,554},{848,555},{844,560},{857,562},{856,563},{862,566},{870,565},{871,567},{875,567},{878,565}}}, - {"America/Argentina/Catamarca",87,{{-636,-424},{-636,-423},{-655,-450},{-655,-449},{-657,-448},{-656,-448},{-665,-452},{-654,-451},{-659,-451},{-660,-451},{-657,-451},{-658,-451},{-656,-451},{-656,-450},{-662,-450},{-666,-451},{-669,-453},{-676,-460},{-716,-460},{-718,-456},{-713,-453},{-716,-450},{-720,-449},{-721,-448},{-713,-448},{-711,-445},{-718,-444},{-718,-441},{-717,-439},{-718,-438},{-716,-437},{-719,-435},{-717,-432},{-721,-429},{-721,-423},{-720,-421},{-717,-421},{-718,-420},{-651,-420},{-645,-422},{-646,-424},{-644,-424},{-640,-424},{-644,-422},{-638,-421},{-637,-428},{-641,-429},{-642,-426},{-646,-425},{-650,-427},{-643,-430},{-650,-432},{-653,-436},{-652,-444},{-657,-447},{-651,-300},{-664,-289},{-666,-284},{-675,-282},{-678,-284},{-679,-281},{-684,-280},{-684,-277},{-691,-278},{-688,-271},{-685,-272},{-683,-269},{-686,-265},{-684,-262},{-686,-254},{-685,-252},{-666,-253},{-665,-256},{-668,-257},{-668,-259},{-664,-264},{-662,-262},{-662,-266},{-659,-267},{-662,-273},{-660,-274},{-656,-281},{-653,-279},{-652,-279},{-651,-284},{-652,-287},{-649,-296}}}, - {"America/Indiana/Indianapolis",14,{{-852,387},{-858,386},{-860,384},{-867,384},{-867,389},{-875,389},{-877,391},{-875,394},{-875,407},{-865,409},{-865,418},{-848,418},{-848,393},{-851,393}}}, - {"America/Indiana/Tell_City",5,{{-867,378},{-868,380},{-868,382},{-866,383},{-864,381}}}, - {"America/Curacao",5,{{-686,120},{-687,120},{-690,121},{-691,123},{-692,124}}}, - {"America/Miquelon",4,{{-562,468},{-563,469},{-564,471},{-564,468}}}, - {"America/Menominee",19,{{-877,454},{-879,454},{-878,457},{-881,458},{-881,459},{-901,463},{-904,466},{-899,468},{-899,466},{-894,465},{-894,463},{-881,464},{-881,462},{-876,462},{-876,460},{-874,460},{-873,455},{-876,451},{-877,452}}}, - {"Asia/Novosibirsk",94,{{844,560},{848,555},{846,554},{849,554},{849,550},{851,549},{849,547},{851,545},{845,541},{836,541},{834,539},{832,541},{825,535},{822,537},{818,537},{817,538},{819,540},{816,539},{809,544},{795,537},{787,537},{784,535},{779,536},{781,535},{778,533},{764,541},{767,542},{769,545},{757,541},{758,547},{753,549},{754,550},{751,554},{753,555},{751,558},{754,558},{753,559},{757,561},{763,562},{761,565},{758,564},{763,567},{761,573},{756,576},{756,579},{751,581},{752,582},{751,583},{754,585},{751,586},{757,590},{756,592},{759,594},{766,596},{767,601},{769,603},{768,605},{770,605},{770,607},{771,609},{779,607},{792,608},{794,606},{807,608},{822,605},{828,609},{835,610},{843,609},{847,605},{848,604},{845,600},{847,599},{871,599},{872,597},{875,597},{879,593},{886,593},{888,590},{884,589},{879,585},{881,581},{894,579},{894,576},{891,576},{885,571},{887,571},{886,568},{878,565},{875,567},{871,567},{870,565},{862,566},{856,563},{857,562}}}, - {"Africa/Lagos",64,{{83,46},{57,45},{83,48},{76,45},{60,43},{55,48},{54,54},{45,63},{38,64},{27,64},{28,91},{31,91},{31,95},{36,99},{36,104},{38,104},{38,106},{37,111},{35,113},{37,118},{36,125},{41,130},{41,135},{45,137},{55,139},{64,136},{69,130},{78,133},{90,128},{97,128},{101,132},{107,134},{115,134},{125,131},{129,135},{136,137},{141,131},{142,124},{147,122},{146,115},{141,113},{140,113},{137,110},{135,102},{132,100},{132,96},{129,94},{128,88},{122,84},{122,80},{118,73},{118,71},{116,70},{114,65},{111,65},{106,72},{105,69},{102,69},{102,70},{88,58},{88,52},{85,47},{83,49},{83,45}}}, - {"Indian/Cocos",5,{{968,-121},{968,-122},{969,-122},{969,-121},{968,-118}}}, - {"America/Yakutat",32,{{-1393,594},{-1392,594},{-1385,592},{-1392,593},{-1393,593},{-1410,603},{-1400,602},{-1391,604},{-1392,601},{-1376,592},{-1375,589},{-1379,588},{-1382,590},{-1386,591},{-1390,594},{-1399,595},{-1395,597},{-1396,599},{-1395,600},{-1393,599},{-1393,596},{-1393,598},{-1390,598},{-1389,598},{-1395,601},{-1402,597},{-1410,598},{-1397,596},{-1398,596},{-1396,596},{-1396,597},{-1400,598}}}, - {"Europe/Volgograd",208,{{480,452},{481,452},{482,454},{491,461},{490,462},{491,462},{492,462},{491,463},{492,463},{484,609},{485,604},{488,604},{485,602},{485,597},{491,597},{490,595},{495,594},{496,592},{498,592},{498,596},{501,597},{500,598},{508,599},{511,601},{515,599},{521,603},{535,602},{537,600},{537,598},{532,593},{534,591},{539,591},{537,589},{539,588},{537,586},{538,584},{533,584},{531,585},{529,584},{522,585},{518,584},{517,582},{519,580},{519,576},{516,574},{512,575},{511,573},{513,569},{515,569},{511,565},{515,562},{513,561},{508,562},{508,564},{506,564},{505,566},{501,566},{501,568},{497,569},{497,571},{493,570},{492,573},{490,571},{483,572},{481,570},{477,571},{475,569},{467,569},{469,572},{467,573},{467,575},{475,575},{476,578},{478,579},{463,581},{466,586},{470,586},{473,589},{476,589},{472,592},{473,594},{471,594},{471,597},{469,598},{470,601},{466,601},{463,602},{467,603},{469,605},{471,606},{470,607},{472,611},{492,461},{480,455},{479,455},{479,457},{480,456},{495,459},{496,459},{488,460},{489,460},{492,460},{491,460},{491,459},{486,456},{486,457},{486,458},{485,458},{466,487},{465,484},{471,483},{472,481},{470,480},{472,478},{481,478},{484,474},{486,474},{490,468},{485,467},{492,464},{490,464},{490,461},{489,461},{487,456},{485,460},{485,457},{484,458},{484,456},{483,457},{478,457},{477,455},{477,456},{476,455},{474,457},{469,456},{472,461},{468,461},{469,462},{465,463},{470,464},{469,466},{472,467},{468,470},{465,474},{468,476},{461,475},{457,478},{457,480},{450,482},{445,481},{445,482},{443,483},{443,481},{445,480},{444,479},{441,479},{437,477},{437,474},{429,475},{425,480},{420,480},{421,484},{426,485},{427,488},{423,492},{421,492},{422,497},{415,501},{414,502},{415,506},{412,508},{419,512},{429,512},{425,517},{428,520},{428,522},{432,525},{443,523},{445,526},{451,523},{456,525},{460,524},{466,527},{471,526},{477,526},{483,528},{489,524},{492,525},{502,521},{502,520},{507,519},{508,516},{506,516},{504,513},{494,511},{494,509},{488,506},{486,506},{489,500},{487,499},{484,498},{476,504},{473,503},{473,501},{469,499},{468,496},{468,493},{470,491}}}, - {"Asia/Rangoon",532,{{980,96},{981,96},{981,97},{980,97},{979,97},{982,98},{980,98},{981,98},{985,99},{985,100},{982,99},{975,118},{974,118},{975,116},{978,125},{985,125},{985,126},{979,126},{979,125},{978,126},{982,126},{986,126},{982,127},{986,125},{986,124},{981,124},{981,125},{982,125},{983,125},{983,126},{986,123},{982,123},{982,124},{984,123},{981,123},{985,123},{985,124},{980,123},{980,124},{984,124},{978,124},{984,125},{983,123},{983,127},{980,121},{985,122},{984,122},{981,122},{982,122},{983,122},{984,121},{980,122},{981,121},{978,123},{979,122},{979,123},{986,101},{983,101},{979,101},{979,102},{983,102},{982,102},{982,103},{983,103},{980,101},{980,102},{981,101},{981,102},{982,101},{982,100},{983,100},{981,100},{980,100},{980,103},{980,104},{979,103},{979,104},{982,104},{982,105},{977,105},{979,105},{982,106},{983,106},{982,107},{983,107},{982,108},{986,109},{986,108},{980,108},{980,109},{985,109},{985,108},{982,109},{981,109},{981,108},{980,106},{980,105},{979,106},{981,106},{986,110},{987,111},{987,110},{987,109},{985,111},{983,112},{979,113},{980,113},{985,120},{986,120},{935,199},{983,113},{982,112},{986,113},{985,113},{980,114},{983,114},{982,114},{981,114},{982,113},{983,110},{986,111},{987,115},{983,116},{983,115},{985,116},{984,116},{984,118},{985,118},{981,118},{977,118},{976,118},{987,119},{987,120},{977,120},{978,120},{979,120},{981,120},{980,120},{980,119},{983,119},{982,119},{983,120},{985,119},{983,118},{980,117},{980,118},{981,116},{984,119},{976,119},{977,119},{982,118},{985,114},{985,115},{980,115},{944,183},{981,115},{979,109},{979,108},{981,110},{983,108},{984,109},{982,110},{984,110},{985,110},{977,121},{976,120},{976,121},{944,181},{945,181},{942,185},{979,121},{932,140},{934,142},{934,141},{937,148},{937,149},{977,152},{963,168},{963,169},{972,169},{977,166},{976,166},{941,180},{941,181},{939,184},{938,186},{938,187},{940,187},{967,173},{968,174},{946,176},{967,174},{968,175},{937,188},{937,187},{935,189},{936,189},{941,189},{941,188},{940,188},{939,188},{940,190},{941,190},{940,191},{935,195},{936,195},{936,194},{938,193},{937,193},{937,194},{939,193},{940,193},{941,193},{922,211},{923,210},{923,209},{924,209},{927,206},{926,207},{925,207},{926,208},{933,204},{933,203},{928,204},{927,204},{929,204},{931,204},{930,204},{931,205},{928,205},{938,195},{939,195},{935,196},{937,196},{936,196},{937,195},{938,197},{935,197},{937,197},{936,197},{937,199},{936,199},{947,163},{935,200},{927,202},{930,202},{929,202},{929,203},{931,202},{930,200},{930,199},{930,198},{929,201},{931,200},{931,201},{933,198},{932,198},{931,199},{930,201},{934,200},{933,201},{932,201},{932,200},{933,200},{933,202},{982,128},{932,202},{934,202},{934,201},{934,198},{935,198},{936,198},{938,198},{937,198},{938,199},{934,197},{983,128},{983,129},{932,203},{928,203},{950,157},{951,157},{943,159},{951,158},{951,159},{986,131},{948,158},{948,159},{945,159},{953,160},{947,160},{953,159},{952,159},{951,160},{977,155},{976,156},{952,157},{953,157},{942,164},{976,165},{977,165},{942,165},{943,165},{960,164},{959,164},{963,165},{975,165},{953,161},{983,130},{982,136},{943,160},{948,160},{948,161},{949,161},{951,161},{952,161},{952,160},{947,161},{946,160},{946,161},{945,162},{945,163},{946,162},{945,161},{951,162},{976,163},{961,163},{960,162},{959,162},{960,163},{961,164},{959,163},{944,158},{947,162},{954,161},{953,162},{954,162},{946,163},{947,164},{975,162},{974,164},{976,164},{962,165},{962,166},{963,164},{984,127},{987,128},{982,150},{986,143},{991,139},{992,133},{991,131},{994,126},{997,118},{988,107},{986,100},{985,107},{988,110},{988,117},{982,138},{982,135},{981,138},{981,142},{978,147},{977,158},{976,161},{976,160},{977,160},{977,164},{978,164},{978,163},{979,163},{974,165},{974,167},{973,171},{971,171},{966,173},{969,173},{969,170},{968,167},{964,165},{963,166},{965,166},{962,168},{964,169},{965,169},{961,168},{962,164},{958,161},{957,161},{957,163},{955,157},{953,158},{954,159},{952,158},{950,158},{951,163},{947,159},{946,159},{949,162},{948,164},{948,166},{947,165},{947,166},{947,167},{942,160},{941,187},{942,187},{943,187},{940,189},{941,194},{939,192},{935,194},{938,192},{940,194},{939,194},{940,195},{931,203},{932,204},{931,206},{930,206},{930,203},{928,202},{928,206},{925,208},{927,203},{922,212},{924,215},{927,213},{927,221},{929,219},{932,223},{931,230},{934,231},{934,237},{933,241},{942,239},{947,250},{946,252},{946,254},{952,261},{951,266},{961,272},{966,274},{971,271},{969,276},{974,279},{973,282},{976,285},{981,282},{983,275},{984,277},{987,276},{988,267},{987,261},{986,261},{987,259},{985,258},{984,256},{982,256},{981,254},{977,251},{978,248},{976,247},{975,244},{978,243},{975,239},{976,238},{981,241},{989,242},{987,240},{989,236},{989,232},{995,231},{996,229},{993,228},{994,225},{992,222},{1000,221},{1000,217},{1002,217},{1002,214},{1007,215},{1011,218},{1012,216},{1007,213},{1005,209},{1006,209},{1003,207},{1001,204},{1000,205},{997,203},{995,204},{995,201},{991,201},{989,197},{983,197},{980,198},{977,189},{978,186},{973,186},{975,183},{976,183},{977,178},{985,169},{987,163},{989,164},{988,161},{986,161},{986,154},{982,152},{986,128},{985,128},{979,128},{978,128},{982,137},{979,138},{979,139},{983,131},{985,131},{985,132},{986,132},{986,129},{982,129},{985,129},{983,132},{982,132},{978,143},{978,144},{978,141},{978,142},{977,151}}}, - {"Indian/Antananarivo",145,{{436,-213},{437,-211},{498,-171},{500,-167},{499,-169},{448,-162},{449,-162},{463,-160},{463,-159},{464,-160},{465,-160},{464,-159},{465,-159},{461,-159},{460,-158},{459,-157},{432,-221},{442,-252},{432,-222},{433,-222},{470,-155},{470,-156},{442,-204},{444,-201},{444,-200},{445,-199},{444,-199},{444,-196},{445,-196},{445,-195},{444,-198},{444,-197},{444,-193},{483,-138},{483,-137},{482,-137},{478,-136},{484,-135},{485,-135},{483,-135},{483,-134},{485,-134},{485,-133},{482,-133},{481,-133},{476,-146},{476,-145},{476,-144},{477,-141},{478,-141},{478,-140},{478,-139},{483,-132},{484,-134},{482,-134},{486,-130},{485,-130},{486,-129},{486,-128},{485,-129},{499,-129},{498,-128},{487,-128},{487,-127},{497,-127},{496,-127},{489,-126},{488,-126},{496,-126},{487,-125},{487,-124},{496,-124},{495,-124},{490,-122},{494,-122},{494,-121},{491,-121},{490,-121},{486,-204},{471,-250},{452,-256},{440,-250},{437,-243},{436,-237},{438,-235},{434,-229},{432,-223},{435,-213},{437,-213},{445,-200},{439,-176},{444,-167},{444,-162},{450,-162},{452,-159},{453,-161},{453,-160},{456,-159},{456,-161},{457,-158},{462,-157},{466,-160},{463,-158},{465,-155},{469,-152},{471,-153},{469,-156},{472,-155},{471,-151},{475,-147},{474,-151},{475,-151},{478,-143},{480,-141},{480,-144},{481,-142},{479,-136},{481,-135},{488,-134},{490,-129},{489,-125},{492,-119},{492,-121},{492,-123},{496,-128},{499,-130},{502,-149},{505,-153},{502,-160},{500,-159},{499,-154},{496,-156},{497,-161},{499,-162},{497,-167},{498,-168},{496,-168},{495,-171},{494,-182},{472,-154},{471,-155},{480,-140},{480,-139},{498,-155},{478,-142}}}, - {"America/Grand_Turk",36,{{-717,212},{-712,212},{-713,212},{-717,213},{-716,213},{-712,213},{-711,214},{-711,213},{-712,214},{-716,215},{-711,215},{-712,215},{-715,215},{-715,216},{-724,217},{-725,216},{-725,217},{-717,217},{-715,217},{-716,217},{-716,218},{-721,218},{-721,219},{-718,219},{-719,219},{-720,220},{-719,218},{-720,219},{-718,217},{-719,217},{-723,219},{-723,218},{-723,217},{-717,218},{-718,218},{-716,216}}}, - {"Asia/Khandyga",62,{{1403,624},{1403,621},{1400,620},{1396,615},{1383,611},{1383,610},{1382,609},{1384,607},{1382,605},{1382,597},{1380,598},{1376,597},{1375,595},{1367,593},{1358,595},{1351,591},{1335,593},{1328,591},{1328,589},{1324,588},{1317,593},{1319,600},{1323,603},{1325,607},{1332,609},{1330,613},{1331,615},{1329,616},{1340,618},{1349,614},{1354,616},{1351,617},{1358,622},{1353,626},{1342,628},{1339,631},{1332,631},{1332,633},{1321,637},{1328,642},{1327,646},{1331,646},{1328,649},{1329,651},{1343,654},{1348,657},{1356,658},{1360,661},{1365,662},{1402,658},{1400,656},{1404,655},{1398,654},{1394,650},{1404,645},{1400,644},{1406,640},{1405,637},{1406,636},{1397,634},{1396,632},{1396,629}}}, - {"America/North_Dakota/Center",5,{{-1010,472},{-1009,470},{-1018,470},{-1018,472},{-1011,473}}}, - {"Pacific/Guam",4,{{1446,134},{1449,137},{1450,136},{1447,132}}}, - {"Pacific/Pitcairn",5,{{-1301,-251},{-1248,-247},{-1283,-243},{-1283,-244},{-1307,-239}}}, - {"Pacific/Marquesas",29,{{-1386,-104},{-1386,-105},{-1387,-105},{-1388,-100},{-1391,-100},{-1391,-99},{-1390,-99},{-1389,-98},{-1392,-98},{-1390,-97},{-1400,-95},{-1389,-94},{-1400,-94},{-1401,-95},{-1401,-94},{-1401,-93},{-1396,-89},{-1395,-89},{-1400,-88},{-1400,-89},{-1402,-90},{-1402,-88},{-1406,-87},{-1407,-80},{-1406,-80},{-1407,-81},{-1406,-79},{-1404,-79},{-1404,-78}}}, - {"Africa/Cairo",111,{{355,238},{356,238},{354,243},{353,243},{362,236},{358,238},{357,232},{356,232},{354,244},{352,247},{352,246},{351,247},{350,250},{340,267},{340,268},{339,272},{340,272},{339,273},{340,275},{339,275},{337,275},{338,275},{339,276},{338,276},{337,278},{336,278},{336,277},{338,277},{337,276},{337,277},{315,220},{315,222},{313,220},{250,220},{250,293},{247,301},{250,308},{249,314},{251,317},{253,315},{259,316},{273,314},{274,312},{279,312},{279,311},{284,311},{291,308},{301,313},{303,313},{304,315},{310,316},{305,314},{307,314},{311,315},{316,314},{319,315},{322,313},{318,313},{321,312},{321,311},{323,311},{324,312},{326,311},{329,311},{327,310},{342,313},{349,295},{343,277},{332,286},{332,290},{327,294},{326,300},{323,296},{326,293},{329,286},{335,276},{338,272},{339,267},{351,245},{358,239},{355,239},{356,231},{352,228},{350,229},{347,223},{342,222},{340,218},{336,217},{332,220},{334,311},{333,311},{331,311},{333,312},{334,312},{335,311},{322,311},{331,312},{332,312},{322,312},{323,312},{323,313},{320,314},{321,313},{320,313},{319,313},{319,314},{308,315},{309,315},{310,315},{308,314},{320,312}}}, - {"America/Cambridge_Bay",1460,{{-1040,681},{-1064,734},{-1065,734},{-1057,730},{-1068,682},{-1142,681},{-1142,682},{-1128,681},{-983,681},{-984,681},{-987,681},{-1080,681},{-1081,681},{-1072,681},{-990,681},{-1129,681},{-1130,681},{-1139,682},{-1139,681},{-1086,681},{-1087,681},{-1068,681},{-1092,681},{-1092,682},{-1123,681},{-1123,682},{-1122,682},{-1122,681},{-1129,682},{-1127,682},{-986,682},{-984,682},{-1121,682},{-1046,682},{-1103,682},{-1088,682},{-963,682},{-964,682},{-1118,682},{-1117,682},{-1075,682},{-1087,682},{-1074,682},{-1124,682},{-1128,682},{-1120,682},{-1093,681},{-1093,682},{-1075,681},{-1076,682},{-1086,682},{-985,682},{-988,682},{-1073,682},{-1119,682},{-1098,681},{-1098,682},{-1095,683},{-1097,682},{-987,682},{-1091,682},{-1090,682},{-1147,682},{-1134,682},{-1133,682},{-1133,683},{-1132,682},{-1132,683},{-902,683},{-901,683},{-986,683},{-1076,683},{-963,683},{-1091,683},{-1044,682},{-966,682},{-1095,682},{-1067,682},{-1070,682},{-1069,682},{-1085,682},{-1072,682},{-1072,683},{-1090,683},{-1119,683},{-969,683},{-985,683},{-987,683},{-1045,682},{-1046,683},{-1045,683},{-1115,682},{-1115,683},{-1114,683},{-1049,683},{-988,683},{-989,683},{-1048,683},{-1047,683},{-1094,683},{-970,683},{-1150,680},{-1106,680},{-1105,680},{-1133,680},{-967,680},{-967,681},{-989,680},{-989,681},{-1091,680},{-1091,681},{-1100,681},{-1102,680},{-1103,681},{-1101,681},{-1085,680},{-1084,681},{-985,681},{-1043,681},{-966,681},{-1090,681},{-1089,681},{-1083,681},{-1033,681},{-1074,681},{-1085,681},{-1136,680},{-1135,680},{-1092,680},{-988,680},{-1104,680},{-1103,680},{-1093,680},{-1140,681},{-1095,681},{-986,681},{-988,681},{-991,681},{-1099,682},{-1099,681},{-1045,681},{-1113,683},{-1118,683},{-1078,683},{-1075,683},{-971,683},{-1051,683},{-1050,683},{-1000,683},{-1116,683},{-1069,683},{-1070,683},{-1070,684},{-958,683},{-1117,683},{-990,683},{-1077,683},{-1051,684},{-982,684},{-982,683},{-1052,683},{-1050,684},{-991,684},{-990,684},{-981,684},{-1089,684},{-1090,684},{-1069,684},{-1068,683},{-1053,684},{-1052,684},{-1008,684},{-1002,683},{-1001,684},{-1001,683},{-1049,684},{-898,690},{-979,684},{-980,684},{-1006,684},{-1063,684},{-1063,685},{-980,685},{-992,684},{-983,684},{-984,684},{-970,684},{-971,684},{-1113,684},{-988,684},{-977,684},{-978,684},{-1112,684},{-1061,684},{-1060,684},{-1055,684},{-1111,684},{-1078,668},{-1079,668},{-1081,668},{-1081,669},{-1080,669},{-1072,669},{-1073,669},{-1074,670},{-1073,670},{-1079,671},{-1075,669},{-1079,669},{-1078,669},{-1078,670},{-1079,670},{-1081,670},{-1080,670},{-954,672},{-953,672},{-959,673},{-960,673},{-961,673},{-956,672},{-956,673},{-955,672},{-953,673},{-1078,671},{-1077,671},{-1078,672},{-1079,672},{-1077,672},{-963,675},{-963,676},{-1075,671},{-1076,672},{-1073,671},{-960,674},{-1082,674},{-1077,673},{-961,674},{-956,675},{-1081,674},{-1080,674},{-1077,674},{-962,674},{-962,675},{-1129,677},{-1130,677},{-962,676},{-961,676},{-1084,676},{-1085,676},{-1083,676},{-1082,675},{-1082,676},{-1081,675},{-1083,675},{-961,675},{-1084,675},{-1080,677},{-1079,676},{-1081,677},{-1076,673},{-962,673},{-1079,675},{-1079,673},{-1131,677},{-1132,677},{-957,677},{-957,678},{-992,677},{-1014,677},{-1015,677},{-1022,677},{-1095,677},{-1090,677},{-1018,677},{-1138,677},{-1138,678},{-991,677},{-991,678},{-1011,677},{-1011,678},{-1119,677},{-1119,678},{-993,678},{-992,678},{-1017,678},{-1144,678},{-1143,678},{-1137,678},{-1018,678},{-1134,678},{-1091,677},{-1091,678},{-990,678},{-1116,677},{-1117,678},{-1118,678},{-1019,678},{-1093,678},{-1115,678},{-1116,678},{-1006,678},{-1090,678},{-1089,678},{-960,678},{-962,678},{-960,679},{-1012,678},{-1125,678},{-1009,678},{-1094,678},{-1092,678},{-1088,678},{-1087,678},{-1021,678},{-1022,678},{-1023,678},{-1016,678},{-961,677},{-1089,677},{-1128,677},{-1088,677},{-1004,679},{-1005,679},{-1001,679},{-1002,679},{-1003,679},{-1155,679},{-1147,679},{-1146,679},{-1145,679},{-1144,679},{-1029,679},{-1143,680},{-1142,679},{-1141,680},{-1141,679},{-1129,680},{-1128,680},{-1128,679},{-1131,679},{-1130,679},{-1031,679},{-1136,679},{-1135,679},{-1137,679},{-1143,679},{-1078,679},{-1132,679},{-1091,679},{-1092,679},{-1040,679},{-1040,680},{-1077,679},{-1129,679},{-1094,679},{-1093,679},{-1151,679},{-1149,679},{-1148,679},{-1007,679},{-1008,679},{-1079,679},{-1097,679},{-1082,679},{-1006,679},{-1083,679},{-1100,679},{-1014,679},{-1028,679},{-1138,679},{-1139,679},{-1022,679},{-1027,679},{-1086,679},{-1098,679},{-1080,679},{-1015,679},{-1099,679},{-1140,679},{-1111,679},{-1108,680},{-1109,679},{-1030,679},{-1084,679},{-1133,679},{-1081,679},{-1081,680},{-1007,678},{-1079,680},{-1078,680},{-1090,679},{-1088,679},{-1150,678},{-1151,678},{-1145,678},{-1008,678},{-1025,678},{-1026,678},{-1142,678},{-1140,678},{-1005,678},{-1146,678},{-995,678},{-1139,678},{-995,679},{-997,678},{-996,678},{-1000,679},{-998,678},{-998,679},{-997,679},{-999,679},{-1081,678},{-1096,679},{-1097,678},{-1089,679},{-1140,680},{-1137,680},{-1138,680},{-987,680},{-990,680},{-1126,680},{-1090,680},{-1029,680},{-1080,680},{-1127,680},{-1125,680},{-1124,680},{-1095,679},{-1094,680},{-1031,680},{-1032,680},{-1084,680},{-1095,680},{-1088,728},{-1087,728},{-1079,681},{-1077,681},{-1082,721},{-1084,722},{-1085,722},{-1081,722},{-1082,722},{-952,722},{-952,723},{-1006,721},{-1006,722},{-954,722},{-944,720},{-952,721},{-1081,721},{-1080,721},{-1077,721},{-1076,721},{-1077,720},{-1078,721},{-1051,725},{-1052,725},{-1084,725},{-1085,725},{-1084,726},{-1085,726},{-1091,727},{-1090,727},{-1089,727},{-1092,728},{-1093,728},{-1094,728},{-1089,728},{-1090,728},{-1005,732},{-1006,732},{-1052,726},{-1053,726},{-971,726},{-1086,726},{-1052,727},{-1053,727},{-1054,727},{-1008,728},{-1010,727},{-1011,727},{-1053,728},{-1005,729},{-1008,729},{-1052,728},{-1010,728},{-1005,728},{-1006,728},{-1004,728},{-1011,728},{-1018,730},{-1017,730},{-1010,730},{-1009,730},{-1003,731},{-1020,731},{-1019,731},{-1001,730},{-1002,730},{-1076,736},{-1079,735},{-1080,736},{-1075,736},{-1047,753},{-1041,754},{-1036,752},{-1042,750},{-1049,751},{-1089,756},{-1090,756},{-1020,755},{-1026,755},{-1028,756},{-1021,757},{-1024,758},{-1020,759},{-1069,758},{-1034,759},{-1037,758},{-1038,759},{-1033,759},{-1020,760},{-1026,758},{-1034,758},{-1029,759},{-1092,769},{-1093,769},{-1090,769},{-1037,770},{-1036,771},{-1036,770},{-1028,761},{-1023,760},{-1039,759},{-1035,760},{-1036,760},{-1034,760},{-1020,762},{-1022,763},{-1020,764},{-1021,763},{-1089,768},{-1090,768},{-1039,760},{-1045,762},{-1031,763},{-1025,762},{-1039,766},{-1034,765},{-1030,764},{-1043,763},{-1047,766},{-1094,749},{-1087,749},{-1088,750},{-1087,750},{-1088,768},{-1084,767},{-1087,766},{-1084,765},{-1086,764},{-1080,763},{-1084,761},{-1076,760},{-1080,758},{-1072,759},{-1068,757},{-1068,760},{-1063,761},{-1056,759},{-1053,757},{-1057,755},{-1056,754},{-1060,751},{-1084,749},{-1088,751},{-1100,748},{-1100,755},{-1089,755},{-1088,756},{-1100,759},{-1093,761},{-1100,762},{-1100,765},{-1093,768},{-1038,771},{-1039,771},{-1021,779},{-1020,777},{-1025,778},{-1024,779},{-1100,781},{-1096,781},{-1095,780},{-1100,779},{-1042,772},{-1040,772},{-1044,771},{-1045,771},{-1056,730},{-1057,775},{-1061,777},{-1054,777},{-1043,772},{-1052,772},{-1097,786},{-1093,786},{-1092,785},{-1094,783},{-1100,783},{-1100,787},{-1040,789},{-1039,789},{-1036,786},{-1035,786},{-1037,794},{-1029,793},{-1028,792},{-1055,793},{-1052,794},{-1051,794},{-1053,794},{-1031,782},{-1029,783},{-1028,782},{-1033,781},{-1054,729},{-1055,729},{-1052,729},{-1054,793},{-1031,793},{-1026,791},{-1027,790},{-1026,789},{-1020,791},{-1020,783},{-1047,783},{-1050,785},{-1035,785},{-1034,786},{-1040,786},{-1033,787},{-1042,788},{-1038,789},{-1041,790},{-1050,788},{-1047,790},{-1056,790},{-1041,794},{-1042,794},{-1095,728},{-1096,729},{-1095,729},{-1090,729},{-1088,729},{-1087,729},{-1082,732},{-1081,732},{-1066,732},{-1063,733},{-1062,733},{-1064,732},{-1061,732},{-1053,729},{-1058,730},{-1060,731},{-1061,731},{-1059,731},{-1023,731},{-1022,731},{-1060,732},{-1062,732},{-1063,732},{-1063,731},{-1055,730},{-1070,733},{-1074,733},{-1075,733},{-1004,687},{-1143,689},{-1144,689},{-1145,689},{-1064,689},{-989,689},{-1024,689},{-939,689},{-938,689},{-1001,689},{-900,689},{-1068,735},{-1070,735},{-1065,737},{-1054,738},{-1044,735},{-1047,732},{-1053,730},{-1064,733},{-1052,685},{-974,685},{-899,685},{-900,685},{-1110,685},{-1109,685},{-974,686},{-975,685},{-976,685},{-1060,685},{-1011,685},{-1010,685},{-981,685},{-981,686},{-977,685},{-977,686},{-1109,686},{-980,686},{-978,686},{-935,686},{-1146,688},{-1147,688},{-900,687},{-1044,689},{-990,690},{-989,690},{-937,689},{-995,689},{-995,690},{-900,690},{-899,690},{-899,689},{-996,690},{-901,690},{-944,690},{-938,690},{-937,690},{-902,690},{-1005,687},{-1001,687},{-956,687},{-947,687},{-947,688},{-946,687},{-904,688},{-905,688},{-987,688},{-1007,688},{-1008,688},{-983,688},{-1027,688},{-1028,688},{-1002,688},{-988,688},{-1026,688},{-1026,689},{-984,689},{-1008,689},{-900,688},{-1001,688},{-1002,689},{-1027,689},{-1024,688},{-1007,689},{-946,689},{-945,689},{-1006,688},{-1006,690},{-1004,691},{-1142,687},{-1140,686},{-1141,686},{-900,686},{-899,687},{-899,686},{-1054,686},{-1054,687},{-1053,687},{-1008,686},{-1009,686},{-1008,687},{-1055,687},{-1006,687},{-1002,687},{-1138,686},{-1139,686},{-1137,686},{-1057,686},{-1021,686},{-1022,686},{-1007,686},{-1106,685},{-1105,686},{-1108,686},{-1053,686},{-1059,686},{-1060,686},{-1103,686},{-979,686},{-1061,686},{-1106,686},{-1104,686},{-1051,685},{-1052,686},{-981,687},{-980,687},{-898,688},{-1018,687},{-1018,686},{-1023,687},{-1019,688},{-1017,688},{-1135,685},{-957,685},{-1123,685},{-958,685},{-1122,685},{-1061,685},{-993,685},{-994,685},{-1008,685},{-1121,685},{-992,685},{-956,685},{-1062,684},{-1007,684},{-1007,685},{-982,685},{-979,685},{-983,685},{-985,685},{-986,685},{-1009,685},{-1057,685},{-1058,685},{-991,685},{-973,685},{-1108,685},{-1107,685},{-1111,685},{-1050,685},{-1048,686},{-1044,685},{-1046,684},{-1020,643},{-1104,647},{-1116,655},{-1135,655},{-1220,685},{-1220,697},{-1210,697},{-1203,694},{-1171,689},{-1160,688},{-1163,690},{-1156,690},{-1139,684},{-1140,682},{-1150,683},{-1152,682},{-1151,680},{-1157,679},{-1152,678},{-1100,680},{-1096,677},{-1097,677},{-1088,674},{-1087,676},{-1085,673},{-1083,673},{-1083,674},{-1080,673},{-1086,672},{-1072,663},{-1077,668},{-1076,670},{-1076,671},{-1077,670},{-1076,668},{-1074,668},{-1071,668},{-1074,671},{-1071,671},{-1075,672},{-1076,675},{-1080,678},{-1076,679},{-1063,682},{-1065,682},{-1064,683},{-1057,684},{-1056,686},{-1066,685},{-1064,685},{-1065,684},{-1065,683},{-1071,683},{-1079,683},{-1084,683},{-1088,683},{-1084,686},{-1062,689},{-1056,687},{-1053,685},{-1054,685},{-1047,681},{-1045,680},{-1041,679},{-1034,682},{-1006,677},{-984,677},{-983,678},{-983,682},{-987,684},{-975,684},{-964,683},{-968,681},{-959,683},{-963,677},{-965,675},{-962,672},{-956,674},{-958,672},{-951,673},{-954,675},{-953,675},{-955,681},{-947,681},{-933,686},{-937,686},{-936,688},{-939,690},{-938,691},{-941,689},{-941,688},{-946,688},{-946,690},{-940,692},{-943,692},{-943,693},{-935,694},{-938,692},{-933,694},{-936,694},{-934,695},{-935,695},{-942,694},{-946,696},{-945,697},{-948,696},{-956,698},{-958,697},{-965,701},{-965,704},{-962,706},{-958,705},{-960,706},{-958,707},{-966,708},{-963,711},{-965,711},{-963,712},{-965,713},{-960,714},{-955,713},{-954,714},{-955,715},{-952,715},{-959,716},{-952,717},{-952,718},{-947,718},{-946,719},{-952,720},{-945,720},{-944,719},{-946,718},{-943,718},{-944,717},{-942,718},{-937,718},{-938,717},{-929,714},{-928,709},{-930,709},{-921,706},{-923,705},{-920,704},{-921,703},{-917,704},{-917,702},{-915,702},{-920,701},{-923,703},{-926,701},{-919,700},{-929,697},{-927,697},{-925,697},{-930,697},{-923,697},{-918,695},{-915,697},{-912,697},{-916,695},{-910,695},{-913,694},{-907,696},{-908,695},{-903,695},{-907,695},{-906,694},{-909,693},{-914,694},{-904,689},{-906,688},{-906,685},{-903,684},{-906,683},{-898,686},{-897,686},{-897,690},{-893,692},{-890,693},{-890,670},{-1020,670},{-899,691},{-900,691},{-901,694},{-902,694},{-901,691},{-903,691},{-902,692},{-902,691},{-901,692},{-900,692},{-904,692},{-905,692},{-902,693},{-903,692},{-904,693},{-903,693},{-901,693},{-905,696},{-904,696},{-903,694},{-904,694},{-902,695},{-901,695},{-904,695},{-905,695},{-902,696},{-903,696},{-905,701},{-906,702},{-908,702},{-907,702},{-918,704},{-919,705},{-920,705},{-921,705},{-926,707},{-926,708},{-925,708},{-925,707},{-1004,708},{-1005,708},{-1006,708},{-1036,707},{-1004,707},{-1003,708},{-1003,707},{-1035,707},{-1001,705},{-1002,705},{-1001,706},{-1007,706},{-1002,706},{-1003,706},{-1002,707},{-1032,707},{-1031,706},{-1032,706},{-1035,706},{-1034,706},{-1004,705},{-1005,705},{-1003,705},{-1007,707},{-1004,706},{-1005,707},{-1006,707},{-1033,707},{-1034,707},{-1014,702},{-1012,702},{-1011,702},{-920,703},{-1021,703},{-1021,704},{-1007,704},{-1020,704},{-1022,704},{-1001,704},{-1002,704},{-1015,703},{-1008,703},{-1009,703},{-1007,703},{-922,699},{-921,699},{-1008,700},{-1009,699},{-918,701},{-919,701},{-924,701},{-923,701},{-1009,709},{-1008,709},{-1046,711},{-1082,720},{-967,713},{-954,715},{-1044,717},{-968,717},{-969,717},{-983,717},{-964,713},{-963,713},{-965,712},{-966,712},{-966,713},{-968,713},{-989,713},{-990,713},{-989,714},{-1080,718},{-941,718},{-1074,718},{-1075,718},{-966,718},{-984,718},{-1081,719},{-940,719},{-941,719},{-941,720},{-943,720},{-942,720},{-953,719},{-955,718},{-970,717},{-970,718},{-968,718},{-955,717},{-953,718},{-954,718},{-953,717},{-1078,720},{-1081,720},{-1080,720},{-939,722},{-940,720},{-952,724},{-971,727},{-972,726},{-969,727},{-963,725},{-967,723},{-965,721},{-968,720},{-965,720},{-967,719},{-965,718},{-975,716},{-982,717},{-984,717},{-982,719},{-983,719},{-985,717},{-980,715},{-987,713},{-992,714},{-994,716},{-1018,723},{-1019,725},{-1027,728},{-1005,730},{-1002,729},{-1003,729},{-1000,729},{-1002,731},{-1006,731},{-1137,691},{-1059,691},{-1003,691},{-1000,691},{-1060,691},{-1061,691},{-999,691},{-998,691},{-961,691},{-961,692},{-1059,690},{-1058,690},{-1000,690},{-1052,691},{-1007,690},{-1150,693},{-1150,692},{-1147,692},{-1139,692},{-1140,692},{-1143,693},{-1142,693},{-1170,696},{-1171,696},{-1138,692},{-1137,692},{-1136,692},{-1031,692},{-908,692},{-907,692},{-1016,692},{-1015,692},{-1017,691},{-907,691},{-906,692},{-991,692},{-909,696},{-910,696},{-968,696},{-1002,690},{-1001,692},{-980,695},{-983,696},{-983,697},{-980,699},{-977,699},{-973,697},{-975,697},{-974,696},{-962,693},{-962,691},{-961,690},{-960,693},{-958,689},{-952,689},{-966,685},{-985,688},{-992,690},{-990,689},{-992,688},{-984,693},{-986,694},{-984,695},{-985,696},{-909,692},{-937,692},{-1016,693},{-992,693},{-957,693},{-958,693},{-938,693},{-956,693},{-907,693},{-908,693},{-910,692},{-911,693},{-910,693},{-992,692},{-993,692},{-993,693},{-994,693},{-910,697},{-1015,696},{-1015,697},{-916,697},{-974,697},{-969,697},{-968,697},{-916,696},{-912,696},{-911,697},{-955,696},{-973,696},{-921,696},{-922,696},{-911,696},{-1066,694},{-1012,695},{-1013,695},{-1014,695},{-957,694},{-1016,694},{-1017,694},{-1017,695},{-940,694},{-941,694},{-939,694},{-1016,695},{-905,693},{-1029,693},{-955,693},{-958,694},{-1012,694},{-1013,694},{-1030,694},{-1029,694},{-963,694},{-1011,694},{-1021,697},{-1022,697},{-961,695},{-961,694},{-967,696},{-962,696},{-1012,696},{-1010,695},{-1009,695},{-1029,695},{-1030,695},{-1028,695},{-968,695},{-915,695},{-919,695},{-911,695},{-909,695},{-1031,695},{-1031,696},{-906,696},{-908,696},{-922,697},{-956,695},{-958,696},{-960,694},{-953,695},{-955,694},{-954,694},{-906,695},{-1030,696},{-954,696},{-953,696},{-917,696},{-969,696},{-913,697},{-924,697},{-1019,697},{-1017,697},{-959,698},{-914,698},{-913,698},{-925,698},{-914,697},{-924,698},{-923,698},{-974,698},{-973,698},{-926,697},{-1014,698},{-917,698},{-917,699},{-918,699},{-916,699},{-973,699},{-975,700},{-973,700},{-974,699},{-914,699},{-915,699},{-972,699},{-915,698},{-918,698},{-972,698},{-916,698},{-922,698},{-923,699},{-1080,733},{-1070,732},{-1067,733},{-1056,729},{-1049,719},{-1043,716},{-1043,714},{-1045,713},{-1044,712},{-1029,705},{-1030,707},{-1028,705},{-1016,702},{-1015,701},{-1010,702},{-1009,697},{-1013,697},{-1014,699},{-1020,700},{-1021,698},{-1022,699},{-1023,698},{-1027,698},{-1025,697},{-1025,696},{-1035,697},{-1032,696},{-1031,694},{-1030,693},{-1032,692},{-1032,691},{-1023,695},{-1019,694},{-1022,694},{-1020,693},{-1022,693},{-1022,692},{-1017,692},{-1018,690},{-1029,688},{-1044,690},{-1051,689},{-1052,690},{-1049,691},{-1064,692},{-1063,694},{-1066,695},{-1074,690},{-1086,689},{-1085,689},{-1090,687},{-1132,685},{-1130,685},{-1137,688},{-1135,690},{-1134,692},{-1165,694},{-1166,696},{-1169,696},{-1172,700},{-1130,700},{-1129,698},{-1124,698},{-1123,699},{-1123,700},{-1100,700},{-1100,725},{-1098,725},{-1100,727},{-1097,727},{-1100,730},{-1090,726},{-1084,719},{-1083,717},{-1078,716},{-1078,717},{-1073,719},{-1078,723},{-1077,723},{-1079,724},{-1077,724},{-1079,725},{-1078,726},{-1082,731},{-1079,732},{-1081,733}}}, - {"Asia/Bahrain",15,{{508,256},{508,257},{508,255},{507,256},{504,262},{504,261},{508,258},{506,262},{506,263},{507,263},{507,262},{506,260},{506,258},{505,262},{506,261}}}, - {"America/Kentucky/Monticello",4,{{-848,370},{-846,368},{-850,366},{-851,369}}}, - {"Arctic/Longyearbyen",374,{{-80,712},{-80,710},{-91,709},{-83,711},{191,745},{193,745},{191,743},{188,745},{165,765},{166,765},{225,783},{224,783},{122,786},{122,785},{208,786},{250,765},{255,767},{256,767},{249,764},{217,769},{228,772},{229,772},{220,770},{219,770},{218,770},{220,772},{146,777},{147,777},{148,777},{149,776},{231,773},{232,773},{233,773},{230,773},{214,773},{225,774},{224,774},{237,778},{244,778},{241,778},{243,777},{239,776},{241,776},{227,772},{226,773},{228,775},{225,776},{209,774},{208,775},{216,779},{208,781},{228,783},{252,778},{205,782},{204,782},{207,782},{206,782},{286,788},{287,788},{288,789},{287,789},{303,790},{302,790},{301,790},{281,788},{279,789},{284,790},{297,789},{266,787},{213,786},{212,786},{212,787},{213,787},{203,786},{202,786},{146,786},{146,787},{215,786},{219,786},{222,784},{210,782},{202,785},{112,787},{119,784},{121,782},{110,785},{105,789},{110,788},{109,788},{147,787},{148,787},{115,787},{116,787},{111,788},{154,788},{153,788},{211,789},{212,789},{217,790},{216,790},{218,790},{211,790},{209,790},{212,790},{204,791},{205,791},{208,791},{201,790},{267,786},{265,787},{264,788},{270,787},{367,802},{368,801},{366,802},{332,802},{324,801},{318,801},{331,802},{179,801},{180,801},{220,801},{221,801},{254,803},{253,803},{239,803},{186,803},{212,803},{260,802},{261,802},{210,802},{188,802},{198,806},{197,806},{207,806},{206,806},{205,807},{208,807},{250,807},{204,808},{203,808},{211,807},{214,807},{213,807},{184,802},{181,803},{187,803},{188,803},{213,803},{215,804},{214,803},{248,803},{247,804},{248,804},{243,804},{241,804},{244,804},{261,804},{261,805},{262,805},{262,804},{260,805},{259,805},{241,805},{240,805},{242,805},{200,805},{201,805},{198,805},{202,805},{203,805},{178,798},{181,797},{176,796},{178,795},{177,794},{183,796},{189,794},{186,793},{189,792},{198,792},{199,790},{215,788},{190,785},{191,782},{189,782},{191,781},{184,780},{185,780},{183,779},{184,778},{183,775},{177,775},{173,771},{171,771},{173,770},{169,768},{172,767},{171,766},{164,766},{163,767},{155,769},{165,770},{152,770},{144,772},{139,775},{162,774},{163,775},{171,778},{168,779},{170,779},{140,777},{138,778},{136,781},{144,780},{142,781},{173,784},{163,785},{169,787},{154,785},{151,786},{155,786},{152,787},{153,787},{150,786},{144,787},{146,785},{144,785},{147,784},{148,784},{130,782},{129,784},{124,785},{132,785},{120,786},{119,788},{113,790},{125,789},{117,791},{121,793},{115,793},{117,792},{112,791},{109,794},{109,795},{107,795},{115,796},{112,797},{117,798},{123,797},{122,798},{125,797},{138,799},{140,798},{124,796},{135,796},{132,795},{136,795},{141,793},{138,795},{147,798},{153,796},{154,794},{158,792},{156,791},{164,789},{159,793},{156,798},{161,799},{159,799},{163,801},{169,799},{195,792},{194,792},{202,793},{212,793},{211,793},{207,793},{206,794},{200,793},{201,793},{199,792},{197,793},{198,793},{136,796},{110,797},{111,797},{108,797},{109,797},{107,797},{109,798},{107,798},{108,798},{114,798},{113,798},{113,799},{116,798},{115,799},{115,798},{114,799},{116,799},{117,799},{133,797},{134,797},{181,799},{181,800},{183,800},{184,800},{180,800},{185,800},{145,800},{144,800},{146,800},{283,801},{280,800},{277,802},{279,802},{182,800},{223,800},{223,801},{224,801},{200,794},{196,794},{197,794},{195,794},{193,796},{194,796},{197,797},{198,797},{250,802},{272,801},{270,800},{271,799},{257,796},{259,795},{258,794},{236,792},{227,793},{228,794},{201,795},{196,796},{211,795},{213,796},{205,797},{217,798},{188,797},{188,800},{189,801},{177,801},{196,801},{190,803},{196,802},{198,802},{197,803},{199,804},{194,804},{196,805},{209,802},{219,803},{216,801},{222,800},{225,800},{226,803},{223,804},{228,803},{228,805},{233,804},{231,804},{233,803},{230,802},{232,801},{244,803},{241,803},{242,804}}}, - {"Australia/Hobart",140,{{1480,-402},{1483,-423},{1482,-423},{1476,-408},{1451,-408},{1450,-408},{1449,-408},{1479,-401},{1481,-407},{1448,-407},{1483,-405},{1450,-407},{1449,-407},{1449,-406},{1447,-406},{1463,-436},{1464,-436},{1465,-436},{1460,-434},{1471,-433},{1480,-432},{1470,-431},{1471,-434},{1476,-430},{1476,-429},{1478,-430},{1478,-429},{1481,-427},{1480,-427},{1481,-426},{1482,-427},{1455,-424},{1478,-401},{1477,-401},{1478,-400},{1479,-403},{1482,-403},{1482,-402},{1483,-402},{1483,-403},{1473,-433},{1473,-435},{1471,-435},{1474,-431},{1475,-431},{1475,-430},{1482,-408},{1483,-410},{1482,-415},{1484,-422},{1482,-422},{1483,-421},{1482,-421},{1482,-420},{1481,-421},{1479,-423},{1480,-425},{1480,-429},{1476,-431},{1477,-429},{1478,-431},{1479,-430},{1474,-428},{1476,-428},{1475,-429},{1474,-429},{1473,-428},{1472,-427},{1473,-431},{1472,-433},{1470,-432},{1470,-433},{1470,-434},{1469,-434},{1470,-435},{1469,-435},{1469,-436},{1468,-436},{1466,-435},{1460,-436},{1459,-434},{1461,-434},{1462,-433},{1460,-433},{1459,-432},{1459,-433},{1458,-433},{1455,-430},{1452,-422},{1455,-425},{1456,-424},{1453,-422},{1452,-420},{1449,-417},{1446,-410},{1453,-407},{1453,-409},{1464,-412},{1468,-411},{1468,-412},{1469,-412},{1470,-413},{1471,-414},{1470,-412},{1474,-410},{1477,-408},{1479,-409},{1479,-407},{1443,-405},{1444,-405},{1480,-404},{1478,-403},{1481,-403},{1483,-400},{1483,-399},{1484,-400},{1479,-397},{1477,-397},{1480,-397},{1480,-396},{1473,-395},{1474,-395},{1473,-394},{1479,-402},{1480,-398},{1480,-403},{1477,-399},{1482,-405},{1482,-406},{1481,-406},{1481,-405},{1448,-404},{1448,-405},{1448,-406},{1447,-405},{1480,-405},{1450,-404},{1449,-405},{1449,-404},{1485,-404}}}, - {"Pacific/Galapagos",55,{{-897,-14},{-897,-13},{-896,-14},{-896,-13},{-903,-13},{-904,-12},{-904,-13},{-905,-13},{-905,-12},{-893,-7},{-894,-9},{-896,-9},{-894,-7},{-901,-8},{-900,-8},{-907,-6},{-906,-6},{-909,-10},{-908,-9},{-900,3},{-899,3},{-907,-4},{-908,6},{-907,6},{-907,5},{-905,3},{-905,4},{-904,3},{-918,14},{-920,17},{-920,16},{-903,-4},{-902,-5},{-903,-5},{-916,-3},{-914,-3},{-914,-5},{-916,-5},{-905,-3},{-906,-3},{-908,-1},{-906,-2},{-906,-4},{-908,-3},{-916,0},{-913,2},{-912,0},{-908,-7},{-912,-11},{-915,-9},{-911,-6},{-914,0},{-902,-7},{-905,-7},{-905,-5}}}, - {"Asia/Oral",33,{{474,504},{477,504},{484,498},{489,500},{486,506},{488,506},{494,509},{494,511},{504,513},{506,516},{508,516},{507,518},{516,515},{519,517},{523,518},{526,515},{534,515},{545,508},{545,505},{544,503},{546,500},{544,496},{536,495},{535,491},{528,490},{526,485},{514,487},{494,480},{465,484},{471,492},{468,493},{469,498},{473,500}}}, - {"America/Dawson_Creek",20,{{-1200,572},{-1200,538},{-1203,540},{-1202,541},{-1205,541},{-1208,545},{-1214,545},{-1216,548},{-1219,549},{-1226,554},{-1230,554},{-1229,556},{-1235,559},{-1236,565},{-1238,569},{-1229,572},{-1219,570},{-1217,572},{-1205,575},{-1204,572}}}, - {"Africa/Mbabane",9,{{318,-259},{321,-260},{321,-268},{320,-268},{320,-273},{315,-273},{310,-270},{308,-266},{313,-257}}}, - {"Asia/Aqtau",127,{{526,461},{500,450},{501,449},{502,449},{502,448},{500,449},{501,450},{503,448},{504,448},{506,448},{506,449},{507,449},{506,450},{508,449},{527,454},{525,455},{526,455},{527,455},{504,450},{503,449},{502,450},{528,457},{527,456},{527,457},{527,460},{510,469},{509,469},{516,468},{525,468},{526,468},{530,466},{529,466},{530,467},{517,467},{516,467},{517,468},{493,462},{492,463},{493,463},{492,464},{493,464},{496,461},{496,462},{560,450},{560,413},{555,413},{548,420},{542,423},{530,421},{524,418},{524,422},{527,426},{526,427},{527,427},{519,428},{516,432},{513,432},{513,435},{508,442},{503,443},{502,446},{515,445},{508,448},{512,450},{514,454},{528,453},{530,454},{529,456},{528,461},{531,464},{529,468},{528,467},{526,469},{523,467},{517,469},{518,468},{515,468},{516,469},{512,470},{502,468},{498,465},{498,464},{496,464},{496,463},{494,463},{494,465},{493,465},{492,465},{485,467},{490,468},{486,474},{484,474},{480,478},{474,478},{474,477},{470,480},{472,481},{471,482},{494,480},{514,487},{526,485},{529,491},{535,491},{536,492},{540,492},{540,488},{549,487},{549,481},{551,479},{550,472},{552,469},{563,465},{566,460},{568,452},{528,460},{530,464},{529,464},{499,465},{499,464},{528,465},{529,465},{497,462},{495,462},{495,463},{498,463},{497,463},{497,464}}}, - {"Pacific/Tongatapu",69,{{-1746,-198},{-1762,-223},{-1750,-215},{-1749,-213},{-1749,-215},{-1750,-214},{-1752,-212},{-1752,-211},{-1751,-211},{-1751,-212},{-1750,-211},{-1753,-210},{-1753,-211},{-1750,-210},{-1752,-210},{-1754,-205},{-1754,-206},{-1747,-205},{-1744,-198},{-1743,-198},{-1750,-212},{-1751,-213},{-1748,-205},{-1745,-204},{-1745,-203},{-1747,-203},{-1748,-203},{-1746,-203},{-1748,-202},{-1746,-201},{-1747,-200},{-1747,-201},{-1748,-200},{-1745,-200},{-1745,-199},{-1748,-199},{-1744,-199},{-1747,-199},{-1747,-198},{-1751,-197},{-1750,-197},{-1750,-198},{-1751,-198},{-1743,-197},{-1750,-196},{-1744,-197},{-1743,-196},{-1745,-196},{-1749,-192},{-1740,-190},{-1740,-188},{-1740,-189},{-1746,-188},{-1747,-188},{-1741,-188},{-1740,-187},{-1741,-187},{-1742,-188},{-1742,-182},{-1743,-180},{-1737,-159},{-1737,-160},{-1738,-160},{-1737,-158},{-1756,-156},{-1757,-156},{-1739,-186},{-1739,-187},{-1740,-186}}}, - {"uninhabited",1993,{{1507,-177},{-1473,-762},{-1474,-761},{-1469,-761},{-1466,-763},{-1500,-767},{-1498,-767},{-1508,-768},{-1505,-767},{-1472,-767},{-1473,-766},{-1469,-766},{-1468,-767},{-686,-678},{-1488,-767},{-1487,-767},{-1484,-767},{-1480,-767},{-1478,-766},{-1474,-767},{-1476,-767},{-1477,-766},{-1476,-766},{-1474,-766},{1668,-770},{1669,-770},{-1469,-770},{-1470,-769},{-1463,-769},{-1464,-770},{-1491,-768},{-1492,-768},{-1482,-768},{-1487,-769},{-1636,-788},{-1614,-789},{-1591,-797},{-1613,-799},{-1635,-796},{-1644,-792},{-1637,-790},{-685,-786},{-671,-784},{-655,-784},{-693,-792},{-708,-791},{1665,-774},{1662,-773},{1668,-772},{1674,-774},{1693,-776},{1684,-777},{1675,-777},{1666,-779},{1668,-777},{1660,-776},{-1500,-775},{-1499,-775},{-1503,-775},{-1501,-775},{1660,-783},{1659,-782},{1667,-783},{1662,-784},{1509,-176},{1674,-781},{1675,-782},{1673,-783},{-800,-776},{-796,-772},{-775,-770},{-768,-772},{-769,-773},{-766,-774},{-767,-777},{-757,-781},{-775,-782},{-796,-781},{-807,-778},{-1490,-775},{-1491,-775},{-1488,-775},{-1489,-775},{-1471,-773},{-1469,-772},{-1470,-773},{-1488,-774},{-1492,-774},{-1496,-773},{-1491,-773},{-1529,-774},{-1528,-774},{-1530,-774},{-1529,-773},{-1528,-773},{-1527,-773},{-1512,-773},{-1508,-772},{-1502,-774},{-1513,-773},{-1530,-773},{-1532,-773},{-1489,-773},{-1488,-772},{-1484,-771},{-1477,-772},{-1475,-774},{-1482,-775},{-1490,-773},{-1490,-772},{-1475,-772},{-1472,-772},{-1470,-772},{-1473,-773},{-1540,-771},{-1538,-772},{-1543,-772},{-1542,-771},{-1492,-770},{-1486,-769},{-1483,-770},{-1489,-771},{-1480,-771},{-1481,-771},{-1479,-771},{-1480,-772},{-1478,-771},{-1476,-771},{-1477,-771},{-1500,-769},{-1496,-769},{-1491,-771},{-1506,-770},{1681,-761},{1683,-761},{1682,-762},{1632,-757},{1631,-757},{1631,-756},{1632,-756},{1631,-758},{-1457,-756},{-1452,-757},{-1460,-756},{1637,-750},{1635,-750},{1635,-749},{1637,-749},{-1403,-747},{-1402,-748},{-1404,-748},{-1433,-755},{-1432,-755},{-1430,-755},{-1432,-756},{-1024,-744},{-1026,-744},{-1025,-744},{-1027,-744},{-1028,-744},{-1025,-745},{-1024,-745},{-1326,-743},{-1324,-743},{-1323,-745},{-1328,-745},{-1321,-741},{-1319,-741},{-1037,-742},{-1036,-742},{-1036,-741},{-1029,-743},{-1030,-743},{-1172,-743},{-1171,-743},{-1167,-742},{-1168,-743},{-1274,-746},{-1278,-744},{-1279,-742},{-1269,-744},{-1269,-746},{-933,-725},{-931,-725},{-931,-726},{-934,-726},{-1319,-743},{-1308,-743},{-1307,-744},{-1311,-746},{-1319,-745},{-1236,-738},{-1235,-737},{-1235,-738},{1668,-737},{1669,-737},{1670,-737},{1669,-738},{-1053,-741},{-1052,-741},{-1027,-741},{-1027,-740},{-1050,-740},{-1026,-740},{-1025,-740},{-1024,-741},{-1025,-741},{-1034,-741},{-1033,-741},{-1035,-741},{-1159,-739},{-1166,-742},{-1177,-742},{-1174,-740},{-1200,-737},{-1186,-738},{-1202,-743},{-1216,-743},{-1226,-742},{-1226,-741},{-1225,-741},{-1226,-740},{-1223,-738},{-1229,-737},{-1225,-736},{1698,-736},{1696,-737},{1694,-736},{1697,-734},{-1025,-736},{-1024,-736},{-1023,-735},{-1023,-736},{-783,-733},{-783,-734},{-784,-733},{-943,-726},{-944,-726},{-718,-693},{-719,-693},{1510,-174},{-780,-734},{-781,-733},{-774,-733},{-775,-734},{-720,-732},{-719,-732},{-719,-733},{-722,-733},{-1249,-732},{-1250,-732},{-1254,-732},{-1248,-733},{-1249,-734},{-1246,-735},{-1251,-737},{-1250,-737},{-1240,-736},{-1234,-740},{-1235,-741},{-1244,-741},{-1257,-738},{-1262,-734},{-1265,-736},{-1269,-734},{-1266,-731},{-1048,-731},{-1044,-732},{-1043,-733},{-1049,-731},{-1261,-730},{-1261,-731},{-1262,-730},{-1264,-730},{-1263,-730},{-939,-728},{-750,-706},{-747,-707},{-742,-705},{-737,-706},{-749,-709},{-756,-707},{1670,-707},{1669,-707},{1671,-707},{-660,-664},{-659,-664},{-607,-707},{-610,-707},{-610,-706},{-607,-705},{-606,-707},{-730,-713},{-729,-713},{-606,-709},{-604,-710},{-610,-710},{-608,-709},{1633,-704},{1634,-704},{1635,-704},{720,-704},{721,-704},{1617,-703},{1618,-702},{1618,-703},{-713,-701},{-712,-701},{-711,-701},{718,-701},{719,-702},{720,-703},{717,-702},{728,-702},{727,-702},{-996,-726},{-1003,-726},{-1004,-725},{-993,-726},{-689,-725},{-688,-725},{-600,-723},{-602,-723},{-604,-722},{-601,-722},{-981,-727},{-983,-727},{-983,-726},{-980,-726},{-611,-726},{-610,-725},{-609,-725},{-610,-726},{-946,-725},{-953,-726},{-952,-726},{-955,-722},{-956,-722},{-1002,-720},{-997,-718},{-995,-720},{-994,-719},{-988,-720},{-992,-718},{-988,-716},{-981,-718},{-985,-719},{-984,-720},{-985,-721},{-980,-721},{-980,-718},{-979,-718},{-975,-719},{-977,-720},{-974,-722},{-971,-718},{-964,-718},{-961,-719},{-971,-721},{-957,-720},{-955,-721},{-965,-722},{-954,-723},{-964,-724},{-959,-724},{-960,-725},{-985,-725},{-990,-725},{-988,-724},{-1001,-724},{-1024,-721},{-1004,-718},{-1002,-719},{-1006,-720},{-736,-732},{-739,-734},{-742,-733},{-739,-732},{-938,-729},{-942,-729},{-942,-728},{-690,-684},{-691,-684},{-755,-731},{-758,-730},{-750,-728},{-743,-731},{-746,-733},{-744,-735},{-746,-737},{-758,-734},{-762,-732},{-927,-732},{-928,-732},{-928,-731},{-964,-732},{-965,-731},{-959,-732},{-961,-731},{-925,-731},{-924,-731},{-934,-732},{-934,-731},{-933,-731},{-875,-729},{-874,-730},{-876,-729},{-919,-730},{-918,-730},{-934,-730},{-933,-730},{-961,-730},{-962,-730},{-961,-729},{-903,-731},{-904,-731},{-929,-731},{-927,-731},{-923,-731},{-920,-731},{-919,-731},{-932,-731},{-930,-731},{-928,-730},{-927,-730},{-900,-729},{-899,-728},{-895,-729},{-898,-731},{-904,-730},{-920,-730},{-958,-729},{-957,-729},{-933,-729},{-781,-726},{-772,-727},{-774,-729},{-785,-732},{-791,-730},{-783,-729},{-909,-726},{-910,-728},{-909,-729},{-913,-732},{-915,-731},{-913,-730},{-913,-728},{-917,-726},{-911,-725},{-719,-700},{-717,-700},{-716,-700},{-720,-701},{-717,-693},{-722,-691},{-706,-688},{-701,-689},{-700,-691},{-701,-692},{-697,-693},{-693,-696},{-691,-702},{-687,-703},{-684,-706},{-681,-716},{-682,-719},{-685,-720},{-684,-721},{-684,-723},{-689,-723},{-691,-725},{-696,-727},{-720,-727},{-727,-725},{-721,-722},{-707,-723},{-710,-721},{-707,-720},{-723,-716},{-725,-717},{-724,-719},{-734,-718},{-730,-719},{-736,-722},{-752,-718},{-757,-715},{-755,-713},{-748,-716},{-747,-716},{-751,-713},{-748,-712},{-735,-716},{-734,-715},{-742,-712},{-736,-711},{-724,-713},{-733,-710},{-713,-708},{-708,-710},{-707,-709},{-716,-705},{-716,-704},{-700,-702},{-719,-698},{-720,-695},{-748,-695},{-745,-698},{-747,-700},{-759,-699},{-761,-697},{385,-697},{383,-697},{384,-697},{-611,-698},{-610,-699},{-614,-699},{-613,-698},{-685,-698},{-723,-694},{-722,-694},{-726,-695},{-728,-694},{-724,-693},{-721,-695},{-676,-691},{-677,-691},{-672,-691},{-671,-691},{397,-690},{396,-690},{-622,-692},{-619,-695},{-620,-697},{-626,-692},{-683,-692},{-678,-692},{-685,-692},{-686,-692},{-685,-691},{-684,-691},{-684,-692},{-906,-687},{-905,-687},{-905,-689},{-907,-689},{-720,-687},{-721,-687},{-678,-686},{1496,-683},{1497,-683},{1498,-684},{1496,-684},{-673,-682},{-673,-681},{-672,-682},{-688,-681},{-689,-681},{-688,-678},{-687,-678},{-670,-678},{-669,-679},{-671,-679},{-674,-679},{-675,-679},{1648,-676},{1646,-676},{1645,-674},{1647,-674},{-677,-672},{-676,-672},{-678,-673},{-678,-672},{-677,-673},{-676,-673},{-678,-674},{492,-674},{491,-674},{595,-674},{594,-673},{596,-673},{-682,-676},{-683,-676},{478,-676},{477,-676},{-679,-676},{-678,-675},{-678,-676},{-671,-675},{-669,-675},{-668,-675},{-672,-675},{-651,-678},{-650,-678},{-684,-677},{-672,-677},{-671,-677},{1511,-174},{-673,-679},{-674,-678},{-671,-678},{-694,-677},{476,-675},{480,-676},{474,-676},{-648,-676},{-646,-676},{-650,-676},{-677,-676},{-673,-676},{-672,-676},{-675,-678},{-678,-677},{1626,-666},{1010,-662},{-672,-664},{-673,-664},{1105,-664},{1105,-665},{1104,-664},{-671,-663},{-670,-664},{-672,-663},{1106,-664},{1559,-174},{1558,-174},{971,-664},{973,-663},{974,-664},{972,-664},{1368,-663},{1369,-663},{-637,-663},{-669,-663},{-670,-663},{-637,-665},{1621,-663},{1622,-663},{1625,-665},{1622,-665},{509,-671},{508,-671},{-680,-667},{-677,-666},{-680,-669},{-677,-671},{-682,-673},{-680,-674},{-681,-676},{-685,-676},{-692,-676},{-685,-668},{588,-671},{589,-671},{587,-671},{586,-671},{504,-671},{503,-671},{-676,-671},{-675,-671},{-678,-670},{-677,-670},{1630,-668},{1629,-667},{1632,-668},{1631,-669},{-669,-669},{-670,-669},{-667,-669},{856,-667},{860,-668},{863,-669},{861,-670},{-668,-669},{-674,-667},{-672,-668},{-676,-669},{-675,-668},{489,-667},{489,-668},{483,-668},{485,-667},{854,-665},{855,-665},{856,-666},{854,-666},{866,-667},{868,-667},{869,-667},{865,-667},{-679,-689},{-567,-632},{-566,-631},{-566,-632},{-565,-630},{-560,-630},{-563,-632},{1509,-174},{-624,-630},{-626,-631},{-627,-631},{-623,-629},{-607,-629},{-605,-629},{-605,-630},{-608,-630},{-600,-626},{-599,-626},{-604,-625},{-604,-624},{-603,-625},{-580,-618},{-580,-619},{-592,-623},{-590,-622},{-588,-623},{-615,-628},{-614,-627},{-612,-627},{-616,-628},{-613,-626},{-612,-626},{1521,-171},{1519,-174},{-582,-619},{-577,-619},{-576,-620},{-583,-622},{-584,-621},{-586,-622},{-585,-622},{-600,-625},{-601,-624},{-596,-625},{-597,-626},{-596,-623},{-594,-624},{-597,-624},{427,-171},{427,-170},{428,-171},{1491,-170},{1492,-169},{1491,-160},{545,-159},{1236,-125},{-598,-626},{-603,-628},{-605,-627},{-604,-626},{-602,-625},{-560,-615},{-559,-615},{-555,-614},{-554,-615},{-556,-615},{-556,-614},{-558,-614},{-559,-614},{-540,-611},{-540,-613},{-542,-612},{-541,-611},{1230,-123},{1231,-123},{1229,-123},{473,-116},{473,-115},{-547,-610},{-546,-611},{-552,-612},{-554,-611},{-451,-608},{-452,-608},{-448,-606},{-460,-606},{-461,-606},{-446,-607},{-445,-607},{-444,-607},{-447,-608},{-448,-607},{-450,-607},{-451,-607},{-451,-606},{-450,-606},{737,-531},{735,-532},{733,-530},{739,-531},{726,-530},{-338,-39},{1116,165},{-457,-605},{-455,-605},{-452,-607},{-457,-607},{-456,-607},{34,-544},{35,-544},{34,-545},{736,-529},{403,-224},{403,-223},{404,-223},{404,-224},{-293,-205},{-288,-205},{-1600,-4},{-1765,2},{-1766,8},{-1625,59},{-1624,59},{-1621,59},{1144,97},{-1627,62},{-1629,62},{-1626,62},{-1624,62},{-1625,62},{-1625,65},{-1623,63},{-1628,66},{1140,100},{1144,102},{-1092,103},{1145,104},{1158,107},{1158,108},{1158,109},{1143,110},{1143,111},{1150,111},{1144,104},{1112,158},{1118,160},{1127,167},{1123,168},{1123,169},{-750,184},{-584,-638},{-589,-644},{-588,-645},{-597,-643},{-607,-647},{-611,-650},{-622,-653},{-617,-655},{-621,-656},{-624,-659},{-619,-662},{-613,-661},{-613,-659},{-610,-660},{-610,-659},{-606,-659},{-609,-663},{-611,-663},{-614,-661},{-617,-663},{-617,-665},{-629,-662},{-624,-664},{-627,-665},{-624,-666},{-626,-667},{-636,-662},{-638,-663},{-636,-664},{-639,-664},{-638,-664},{-640,-665},{-638,-666},{-641,-666},{-642,-668},{-637,-669},{-649,-670},{-650,-670},{-647,-671},{-650,-672},{-650,-673},{-656,-674},{-656,-675},{-654,-677},{-657,-679},{-653,-680},{-657,-682},{-648,-681},{-655,-683},{-650,-684},{-654,-685},{-652,-687},{-641,-688},{-640,-688},{-643,-686},{-640,-686},{-638,-685},{-629,-685},{-639,-687},{-632,-688},{-638,-690},{-633,-690},{-636,-692},{-632,-692},{-630,-694},{-624,-695},{-624,-697},{-627,-698},{-619,-702},{-625,-704},{-614,-706},{-621,-709},{-613,-708},{-614,-710},{-609,-712},{-614,-712},{-610,-714},{-616,-715},{-608,-717},{-619,-720},{-606,-720},{-611,-722},{-607,-723},{-610,-724},{-606,-724},{-614,-724},{-616,-725},{-614,-726},{-616,-727},{-605,-727},{-605,-729},{-609,-731},{-598,-729},{-599,-733},{-606,-732},{-608,-735},{-607,-737},{-610,-739},{-608,-741},{-617,-743},{-607,-743},{-607,-744},{-619,-746},{-621,-747},{-620,-749},{-628,-751},{-645,-753},{-631,-753},{-640,-756},{-699,-764},{-676,-769},{-676,-776},{-691,-781},{-715,-781},{-741,-778},{-758,-771},{-758,-766},{-810,-770},{-809,-772},{-814,-775},{-820,-771},{-832,-772},{-827,-773},{-820,-779},{-819,-780},{-824,-781},{-819,-782},{-820,-784},{-811,-787},{-814,-789},{-810,-791},{-816,-792},{-811,-795},{-803,-797},{-800,-796},{-804,-793},{-795,-793},{-773,-800},{-800,-800},{-769,-802},{-770,-803},{-762,-805},{-745,-807},{-696,-807},{-600,-802},{-590,-796},{-542,-792},{-531,-787},{-489,-777},{-464,-780},{-449,-785},{-482,-788},{-484,-789},{-445,-788},{-442,-788},{-441,-791},{-465,-793},{-460,-795},{-441,-793},{-429,-794},{-431,-797},{-430,-799},{-449,-799},{-449,-800},{-443,-802},{-459,-805},{-489,-807},{-515,-807},{-548,-800},{-584,-805},{-608,-810},{-706,-813},{-717,-814},{-721,-817},{-710,-820},{-678,-824},{-602,-824},{-590,-826},{-593,-830},{-584,-830},{-557,-824},{-516,-818},{-429,-815},{-346,-802},{-320,-801},{-318,-801},{-321,-804},{-307,-804},{-308,-803},{-301,-800},{-308,-795},{-299,-794},{-300,-793},{-339,-792},{-359,-789},{-365,-787},{-364,-783},{-356,-781},{-354,-778},{-315,-772},{-318,-771},{-314,-772},{-315,-770},{-310,-771},{-284,-764},{-289,-763},{-248,-758},{-235,-752},{-227,-746},{-184,-735},{-151,-729},{-137,-729},{-121,-726},{-114,-723},{-111,-719},{-120,-717},{-123,-714},{-116,-713},{-117,-714},{-110,-717},{-101,-711},{-105,-710},{-102,-709},{-95,-709},{-97,-710},{-90,-712},{-88,-714},{-87,-717},{-85,-718},{-74,-717},{-78,-714},{-73,-711},{-77,-709},{-70,-707},{-58,-707},{-57,-710},{-62,-713},{-60,-714},{-30,-713},{-37,-711},{-34,-709},{-35,-707},{-34,-704},{-30,-703},{-27,-704},{-32,-707},{-20,-708},{-26,-710},{-22,-715},{-10,-713},{-8,-714},{-10,-716},{-5,-717},{5,-713},{23,-709},{30,-705},{44,-703},{57,-705},{78,-702},{95,-702},{118,-706},{124,-703},{162,-702},{243,-705},{317,-696},{333,-697},{335,-696},{334,-693},{336,-692},{332,-690},{333,-688},{340,-686},{354,-691},{358,-694},{369,-696},{372,-698},{378,-697},{383,-698},{387,-701},{386,-700},{389,-700},{392,-699},{392,-697},{398,-696},{396,-695},{400,-694},{397,-693},{399,-692},{398,-690},{410,-686},{423,-683},{428,-681},{463,-677},{463,-674},{465,-673},{475,-674},{473,-675},{474,-677},{482,-676},{493,-673},{488,-673},{488,-672},{484,-671},{484,-670},{493,-668},{500,-671},{498,-673},{502,-671},{509,-672},{511,-671},{505,-671},{505,-669},{509,-668},{503,-667},{504,-664},{521,-660},{538,-658},{557,-660},{564,-664},{574,-666},{563,-668},{567,-668},{565,-669},{568,-669},{567,-670},{570,-671},{576,-670},{589,-672},{591,-673},{586,-673},{592,-675},{606,-673},{628,-677},{637,-675},{685,-679},{699,-678},{699,-681},{702,-683},{700,-685},{701,-687},{692,-690},{701,-689},{691,-691},{699,-693},{687,-693},{690,-694},{685,-696},{692,-698},{684,-699},{681,-703},{684,-704},{692,-703},{693,-708},{715,-714},{724,-709},{725,-707},{733,-704},{729,-701},{743,-697},{759,-697},{764,-694},{781,-691},{783,-688},{781,-687},{785,-686},{782,-686},{788,-685},{783,-685},{794,-682},{830,-676},{846,-671},{860,-672},{881,-667},{899,-668},{919,-665},{928,-666},{940,-665},{943,-666},{956,-665},{959,-666},{971,-665},{977,-666},{990,-664},{987,-664},{990,-663},{991,-662},{987,-657},{995,-659},{995,-657},{1000,-657},{1002,-657},{1001,-661},{1003,-662},{1008,-660},{1007,-661},{1010,-661},{1011,-661},{1007,-662},{1015,-660},{1013,-660},{1014,-659},{1030,-658},{1066,-663},{1082,-666},{1089,-669},{1093,-669},{1093,-667},{1095,-666},{1103,-666},{1102,-666},{1107,-664},{1105,-662},{1109,-660},{1132,-657},{1145,-662},{1145,-664},{1161,-664},{1177,-670},{1211,-668},{1211,-671},{1247,-667},{1261,-663},{1274,-666},{1279,-670},{1293,-670},{1296,-669},{1297,-668},{1296,-666},{1300,-662},{1295,-659},{1317,-662},{1334,-661},{1341,-662},{1347,-660},{1346,-659},{1348,-658},{1345,-656},{1345,-653},{1349,-653},{1355,-657},{1351,-660},{1361,-661},{1360,-662},{1364,-664},{1370,-663},{1401,-667},{1419,-668},{1425,-670},{1434,-669},{1438,-669},{1439,-671},{1444,-670},{1446,-672},{1453,-669},{1454,-670},{1455,-668},{1465,-668},{1468,-671},{1452,-676},{1460,-676},{1471,-679},{1485,-678},{1486,-683},{1478,-683},{1479,-684},{1491,-683},{1498,-685},{1510,-683},{1511,-686},{1514,-687},{1520,-687},{1526,-684},{1538,-683},{1547,-686},{1548,-687},{1544,-686},{1546,-687},{1545,-688},{1549,-690},{1554,-689},{1568,-692},{1571,-692},{1571,-690},{1574,-692},{1589,-693},{1597,-698},{1605,-699},{1606,-700},{1603,-701},{1610,-703},{1615,-703},{1617,-705},{1619,-703},{1619,-705},{1626,-703},{1631,-707},{1635,-707},{1637,-707},{1635,-705},{1658,-707},{1667,-707},{1668,-707},{1663,-707},{1677,-708},{1679,-709},{1678,-710},{1681,-712},{1701,-717},{1703,-715},{1701,-713},{1703,-714},{1709,-719},{1700,-721},{1698,-723},{1700,-723},{1698,-724},{1702,-724},{1702,-726},{1698,-727},{1696,-731},{1690,-732},{1692,-733},{1689,-733},{1690,-735},{1686,-734},{1684,-736},{1680,-736},{1679,-734},{1667,-736},{1665,-736},{1667,-737},{1656,-740},{1662,-741},{1647,-742},{1654,-746},{1653,-747},{1643,-746},{1638,-749},{1636,-748},{1639,-746},{1634,-745},{1631,-747},{1632,-747},{1626,-748},{1628,-750},{1624,-749},{1627,-750},{1624,-752},{1626,-753},{1642,-752},{1643,-754},{1647,-754},{1646,-756},{1627,-755},{1629,-756},{1625,-757},{1630,-758},{1627,-759},{1630,-760},{1622,-762},{1627,-763},{1626,-764},{1628,-765},{1626,-766},{1628,-766},{1625,-767},{1629,-768},{1623,-771},{1631,-771},{1634,-774},{1637,-775},{1634,-776},{1636,-777},{1634,-777},{1644,-778},{1645,-780},{1643,-781},{1633,-783},{1646,-784},{1653,-781},{1655,-782},{1652,-782},{1656,-785},{1669,-786},{1671,-787},{1661,-786},{1641,-786},{1626,-789},{1627,-789},{1625,-791},{1609,-791},{1603,-792},{1605,-794},{1600,-797},{1604,-800},{1600,-802},{1608,-805},{1597,-807},{1610,-807},{1601,-809},{1607,-810},{1603,-810},{1606,-811},{1604,-813},{1608,-813},{1605,-814},{1613,-815},{1609,-816},{1622,-817},{1623,-819},{1627,-819},{1638,-822},{1612,-824},{1617,-825},{1632,-827},{1631,-826},{1633,-826},{1632,-825},{1647,-824},{1653,-825},{1648,-827},{1663,-827},{1671,-829},{1666,-830},{1686,-832},{1678,-833},{1676,-835},{1677,-835},{1691,-834},{1716,-836},{1719,-836},{1713,-838},{1728,-838},{1735,-838},{1729,-839},{1748,-839},{1800,-844},{1800,-900},{-1800,-900},{-1800,-844},{-1783,-844},{-1791,-843},{-1670,-848},{-1659,-850},{-1629,-852},{-1618,-854},{-1605,-854},{-1610,-855},{-1582,-855},{-1586,-854},{-1584,-854},{-1515,-856},{-1515,-855},{-1503,-855},{-1483,-852},{-1393,-853},{-1374,-851},{-1461,-849},{-1511,-845},{-1530,-840},{-1532,-839},{-1528,-837},{-1529,-834},{-1542,-828},{-1542,-822},{-1549,-819},{-1550,-818},{-1549,-816},{-1534,-812},{-1459,-809},{-1452,-807},{-1479,-803},{-1511,-803},{-1520,-799},{-1532,-798},{-1540,-794},{-1576,-788},{-1577,-786},{-1568,-784},{-1570,-783},{-1568,-781},{-1579,-781},{-1583,-782},{-1579,-783},{-1585,-782},{-1580,-780},{-1582,-779},{-1577,-775},{-1580,-774},{-1579,-771},{-1567,-774},{-1559,-771},{-1531,-774},{-1537,-775},{-1535,-775},{-1524,-775},{-1521,-773},{-1494,-778},{-1490,-777},{-1496,-777},{-1487,-777},{-1485,-776},{-1486,-776},{-1477,-775},{-1475,-773},{-1469,-773},{-1460,-774},{-1458,-773},{-1462,-772},{-1459,-772},{-1460,-771},{-1453,-771},{-1462,-769},{-1455,-768},{-1469,-765},{-1487,-765},{-1495,-765},{-1494,-763},{-1485,-763},{-1487,-762},{-1483,-761},{-1456,-765},{-1454,-764},{-1464,-761},{-1460,-759},{-1441,-759},{-1442,-757},{-1427,-757},{-1426,-755},{-1418,-757},{-1415,-756},{-1405,-756},{-1399,-752},{-1374,-751},{-1367,-750},{-1372,-747},{-1360,-747},{-1355,-745},{-1343,-745},{-1344,-746},{-1342,-747},{-1342,-748},{-1340,-749},{-1327,-747},{-1297,-749},{-1261,-748},{-1187,-745},{-1178,-742},{-1170,-745},{-1158,-744},{-1155,-745},{-1147,-745},{-1146,-744},{-1149,-741},{-1140,-738},{-1136,-739},{-1142,-742},{-1132,-740},{-1131,-741},{-1136,-744},{-1130,-744},{-1128,-745},{-1130,-747},{-1127,-747},{-1128,-749},{-1112,-747},{-1117,-746},{-1113,-744},{-1116,-742},{-1113,-742},{-1103,-743},{-1099,-746},{-1092,-746},{-1090,-747},{-1093,-747},{-1088,-748},{-1083,-748},{-1082,-746},{-1073,-746},{-1072,-748},{-1066,-748},{-1069,-753},{-1067,-753},{-1053,-752},{-1053,-749},{-1050,-747},{-1031,-748},{-1033,-748},{-1021,-750},{-1020,-753},{-1004,-751},{-1017,-745},{-1009,-743},{-1005,-743},{-1005,-741},{-1010,-739},{-1020,-738},{-1004,-736},{-1000,-735},{-1000,-733},{-1010,-731},{-1027,-734},{-1032,-732},{-1035,-730},{-1031,-728},{-1022,-728},{-1021,-729},{-1022,-730},{-1018,-731},{-1007,-730},{-1000,-732},{-980,-729},{-975,-731},{-960,-733},{-944,-732},{-944,-729},{-937,-732},{-909,-733},{-895,-731},{-893,-728},{-896,-726},{-891,-726},{-881,-728},{-886,-731},{-868,-733},{-861,-732},{-858,-730},{-854,-734},{-834,-735},{-820,-739},{-808,-738},{-811,-735},{-810,-733},{-801,-734},{-803,-731},{-802,-730},{-786,-734},{-786,-736},{-766,-736},{-771,-738},{-770,-739},{-752,-737},{-740,-737},{-732,-735},{-693,-732},{-676,-728},{-669,-724},{-670,-722},{-669,-719},{-677,-714},{-674,-710},{-680,-703},{-684,-701},{-684,-697},{-689,-694},{-683,-693},{-674,-693},{-668,-690},{-675,-688},{-669,-688},{-672,-685},{-670,-683},{-672,-683},{-666,-682},{-669,-682},{-673,-680},{-668,-678},{-668,-677},{-670,-677},{-665,-675},{-676,-676},{-675,-670},{-669,-672},{-665,-673},{-666,-666},{-658,-667},{-656,-664},{-659,-663},{-657,-661},{-652,-662},{-653,-660},{-650,-659},{-645,-660},{-647,-657},{-644,-658},{-645,-656},{-641,-657},{-642,-655},{-637,-655},{-641,-654},{-641,-651},{-638,-650},{-631,-651},{-630,-650},{-633,-649},{-628,-648},{-626,-649},{-624,-649},{-627,-648},{-626,-646},{-623,-648},{-618,-645},{-616,-646},{-615,-644},{-609,-643},{-608,-641},{-610,-640},{-600,-640},{-599,-638},{-595,-639},{-594,-637},{-591,-637},{-590,-635},{-573,-632},{-571,-632},{-568,-636},{-571,-636},{-572,-635},{-574,-635},{966,-662},{963,-662},{965,-660},{970,-662},{-666,-662},{-668,-661},{1213,-667},{1218,-665},{1212,-662},{1215,-660},{1212,-659},{1213,-656},{1226,-666},{-658,-661},{1012,-661},{1013,-661},{1011,-660},{1010,-660},{-658,-660},{-658,-659},{-657,-660},{-651,-659},{-653,-659},{-651,-657},{-652,-657},{-645,-657},{-644,-657},{-653,-656},{-652,-656},{-653,-657},{-646,-656},{-644,-655},{-643,-655},{1029,-651},{1031,-652},{1035,-655},{1028,-652},{-642,-653},{-643,-653},{1003,-656},{1007,-654},{1012,-655},{1006,-657},{-656,-655},{-655,-655},{-658,-655},{-657,-655},{-656,-654},{-655,-654},{-654,-654},{-660,-659},{-659,-659},{-661,-659},{1006,-658},{1007,-658},{1006,-659},{1005,-658},{-657,-658},{-656,-658},{-658,-657},{-658,-658},{-649,-659},{-652,-659},{-653,-658},{-660,-656},{-660,-655},{-657,-657},{-659,-657},{-662,-659},{924,-657},{925,-657},{927,-657},{923,-657},{-634,-651},{-601,-650},{-600,-650},{-603,-650},{-604,-650},{-658,-650},{-605,-650},{-600,-651},{-601,-651},{-603,-651},{-602,-651},{-640,-651},{-640,-650},{-639,-650},{-622,-645},{-622,-646},{-631,-649},{-631,-648},{-629,-649},{-630,-649},{-635,-649},{-635,-648},{-632,-647},{-636,-649},{-630,-648},{-629,-648},{-621,-646},{-620,-646},{-621,-647},{-623,-646},{-622,-647},{-627,-647},{-628,-647},{-631,-647},{-621,-645},{-643,-652},{-648,-652},{-645,-652},{-642,-652},{-641,-652},{-643,-651},{-597,-651},{-596,-651},{-595,-652},{-599,-651},{-595,-651},{-569,-642},{-568,-642},{-615,-639},{-614,-639},{-610,-638},{-609,-638},{-584,-642},{-610,-642},{-617,-641},{-617,-642},{-618,-641},{-621,-641},{-620,-641},{-619,-640},{-618,-640},{-620,-640},{-577,-644},{-576,-644},{-577,-645},{-570,-645},{-573,-645},{-575,-645},{-569,-643},{-598,-645},{-597,-644},{-596,-645},{-597,-646},{-629,-644},{-628,-644},{-616,-644},{-615,-643},{-620,-633},{-622,-633},{-622,-632},{-587,-633},{-634,-644},{-632,-644},{-633,-646},{-628,-646},{-637,-648},{-643,-647},{-636,-643},{-632,-643},{-629,-643},{-630,-643},{-621,-643},{-622,-643},{-568,-643},{-566,-642},{-561,-634},{-559,-634},{-557,-634},{-560,-636},{-562,-635},{-623,-640},{-622,-642},{-621,-642},{-622,-644},{-625,-645},{-628,-645},{-625,-642},{-626,-640},{-620,-642},{-598,-636},{-599,-636},{-598,-635},{-573,-636},{-574,-636},{-547,-634},{-558,-636},{-557,-636},{-566,-636},{-564,-636},{-567,-636},{-567,-635},{-566,-635},{-591,-636},{-590,-636},{-590,-637},{-575,-636},{-576,-636},{-556,-631},{-550,-633},{-566,-634},{-575,-638},{-573,-638},{-571,-638},{-577,-638},{-607,-638},{-608,-639},{-609,-639},{-607,-637},{-608,-637},{-606,-637},{-583,-642},{-585,-641},{-582,-640},{-583,-639},{-578,-638},{-578,-641},{-575,-639},{-571,-642},{-574,-643},{-573,-644},{-580,-644},{-583,-643},{-581,-641},{-582,-638},{-583,-638},{-617,-638},{-617,-637},{-616,-638},{-579,-637},{-575,-637},{-576,-637},{-577,-637}}}, - {"Asia/Hovd",56,{{983,450},{977,438},{978,427},{964,427},{959,433},{956,440},{953,440},{954,443},{947,443},{935,450},{909,452},{907,455},{910,460},{909,463},{911,467},{909,470},{901,479},{898,478},{896,480},{890,479},{885,484},{880,485},{881,487},{877,489},{879,490},{878,492},{882,493},{881,494},{882,495},{889,495},{897,497},{896,500},{907,502},{907,505},{914,505},{918,507},{923,507},{924,509},{926,507},{930,508},{931,506},{943,506},{946,500},{970,499},{972,498},{970,494},{978,490},{991,491},{992,489},{991,483},{981,480},{983,475},{976,466},{978,462},{983,458},{984,454}}}, - {"Africa/Nairobi",62,{{413,-19},{414,-19},{414,-18},{413,-20},{394,-45},{394,-46},{397,-41},{396,-40},{397,-40},{402,-28},{408,-23},{409,-22},{409,-23},{416,-17},{410,-21},{410,-19},{409,-21},{409,-20},{408,-20},{410,-23},{408,-25},{402,-27},{401,-33},{398,-36},{398,-38},{395,-46},{392,-47},{376,-35},{377,-33},{376,-30},{339,-10},{339,1},{345,11},{348,12},{350,19},{349,25},{345,32},{345,37},{342,38},{340,42},{344,46},{359,46},{360,44},{370,44},{381,36},{385,37},{395,34},{399,39},{408,43},{412,39},{419,40},{410,28},{410,-8},{410,-22},{411,-21},{411,-20},{412,-20},{411,-22},{415,-18},{415,-17},{394,-47},{393,-47}}}, - {"Asia/Jayapura",995,{{1347,-58},{1348,-58},{1312,-11},{1343,-58},{1282,21},{1350,-15},{1305,-19},{1257,-81},{1257,-80},{1258,-80},{1258,-78},{1260,-77},{1262,-77},{1266,-76},{1268,-77},{1265,-80},{1261,-79},{1272,-81},{1271,-80},{1272,-80},{1259,-77},{1274,-76},{1273,-75},{1267,-66},{1275,-56},{1278,-54},{1362,-47},{1362,-46},{1368,-48},{1368,-49},{1367,-48},{1317,-48},{1317,-47},{1318,-47},{1365,-47},{1364,-47},{1300,-46},{1297,-46},{1297,-45},{1299,-46},{1299,-45},{1298,-45},{1317,-46},{1375,-52},{1320,-52},{1320,-51},{1375,-50},{1376,-50},{1374,-50},{1374,-49},{1371,-49},{1382,-57},{1325,-59},{1349,-60},{1349,-59},{1324,-60},{1325,-60},{1325,-58},{1326,-59},{1326,-58},{1342,-58},{1342,-59},{1347,-60},{1348,-59},{1328,-58},{1327,-60},{1326,-56},{1327,-56},{1322,-58},{1322,-57},{1328,-57},{1327,-58},{1326,-57},{1327,-57},{1323,-57},{1346,-57},{1345,-56},{1348,-56},{1345,-55},{1347,-57},{1343,-60},{1344,-58},{1348,-57},{1320,-56},{1322,-56},{1323,-56},{1330,-56},{1343,-56},{1342,-56},{1343,-57},{1328,-60},{1329,-57},{1332,-53},{1331,-56},{1328,-55},{1378,-54},{1378,-53},{1377,-54},{1377,-53},{1345,-53},{1323,-55},{1324,-55},{1327,-55},{1347,-55},{1347,-54},{1346,-54},{1347,-56},{1342,-55},{1343,-55},{1327,-54},{1345,-54},{1320,-53},{1320,-54},{1346,-53},{1401,-80},{1400,-80},{1313,-81},{1313,-80},{1389,-83},{1389,-82},{1277,-82},{1276,-82},{1364,-19},{1282,-83},{1281,-83},{1282,-82},{1307,-83},{1285,-83},{1386,-83},{1385,-83},{1385,-84},{1384,-84},{1383,-84},{1388,-84},{1386,-84},{1388,-81},{1390,-83},{1387,-82},{1288,-82},{1290,-82},{1290,-83},{1311,-81},{1312,-81},{1308,-83},{1309,-81},{1284,-82},{1273,-76},{1274,-75},{1275,-75},{1275,-76},{1281,-82},{1279,-82},{1278,-81},{1281,-81},{1287,-82},{1388,-82},{1299,-81},{1298,-82},{1286,-73},{1285,-73},{1314,-73},{1295,-79},{1295,-78},{1295,-80},{1301,-78},{1300,-78},{1311,-80},{1297,-80},{1296,-78},{1299,-78},{1298,-81},{1297,-76},{1297,-75},{1315,-69},{1389,-80},{1376,-84},{1380,-78},{1380,-77},{1381,-77},{1381,-78},{1380,-76},{1384,-74},{1388,-74},{1391,-76},{1276,-76},{1311,-78},{1311,-77},{1300,-77},{1310,-78},{1309,-77},{1310,-77},{1311,-76},{1310,-75},{1312,-75},{1311,-75},{1348,-65},{1348,-66},{1309,-76},{1309,-75},{1310,-76},{1313,-74},{1310,-74},{1312,-74},{1308,-75},{1285,-74},{1286,-74},{1313,-73},{1347,-70},{1292,-70},{1291,-70},{1317,-71},{1316,-71},{1314,-71},{1345,-71},{1320,-70},{1319,-71},{1388,-68},{1387,-69},{1387,-68},{1386,-68},{1386,-67},{1345,-69},{1387,-66},{1389,-68},{1387,-67},{1342,-65},{1346,-65},{1346,-64},{1347,-65},{1348,-64},{1345,-65},{1345,-64},{1348,-63},{1349,-63},{1343,-64},{1343,-63},{1344,-63},{1347,-64},{1344,-64},{1347,-66},{1345,-24},{1345,-23},{1347,-69},{1346,-69},{1347,-68},{1295,-68},{1295,-67},{1345,-67},{1348,-67},{1345,-68},{1315,-68},{1316,-67},{1316,-68},{1346,-67},{1338,-23},{1339,-23},{1345,-66},{1346,-66},{1342,-62},{1342,-69},{1340,-68},{1341,-64},{1341,-65},{1342,-66},{1343,-67},{1342,-64},{1396,-72},{1397,-73},{1391,-72},{1392,-72},{1314,-72},{1315,-72},{1313,-41},{1314,-42},{1346,-41},{1317,-72},{1316,-76},{1313,-79},{1313,-77},{1312,-77},{1315,-71},{1286,-72},{1285,-71},{1286,-71},{1287,-71},{1390,-72},{1335,-40},{1343,-40},{1342,-40},{1312,-39},{1320,-72},{1396,-71},{1388,-72},{1387,-72},{1387,-71},{1300,-63},{1349,-62},{1348,-62},{1349,-61},{1341,-60},{1309,-39},{1349,-39},{1349,-40},{1348,-39},{1343,-61},{1345,-59},{1317,-45},{1316,-44},{1352,-45},{1352,-44},{1335,-43},{1349,-43},{1350,-43},{1336,-43},{1333,-42},{1333,-41},{1335,-42},{1312,-41},{1312,-40},{1344,-40},{1345,-40},{1357,-29},{1341,-40},{1341,-39},{1314,-41},{1314,-40},{1315,-41},{1347,-39},{1347,-40},{1336,-34},{1335,-34},{1327,-35},{1327,-34},{1328,-34},{1308,-33},{1281,-33},{1260,-32},{1260,-33},{1276,-34},{1275,-33},{1276,-33},{1275,-32},{1282,-32},{1281,-32},{1356,-31},{1338,-31},{1338,-30},{1348,-31},{1349,-31},{1358,-29},{1357,-30},{1348,-30},{1349,-30},{1277,-32},{1277,-33},{1276,-32},{1278,-32},{1326,-32},{1325,-32},{1325,-31},{1326,-31},{1324,-31},{1280,-30},{1323,-30},{1322,-30},{1321,-30},{1279,-29},{1279,-30},{1320,-30},{1320,-29},{1280,-29},{1278,-30},{1265,-38},{1288,-37},{1288,-36},{1286,-37},{1286,-36},{1285,-36},{1284,-36},{1284,-35},{1290,-27},{1348,-27},{1349,-27},{1325,-27},{1326,-27},{1324,-26},{1280,-38},{1280,-36},{1283,-35},{1282,-37},{1281,-38},{1282,-36},{1340,-39},{1272,-39},{1272,-38},{1340,-38},{1341,-38},{1339,-37},{1339,-39},{1326,-34},{1316,-27},{1316,-26},{1317,-26},{1336,-26},{1335,-26},{1344,-26},{1344,-25},{1334,-25},{1335,-25},{1337,-25},{1338,-26},{1338,-25},{1337,-23},{1306,-23},{1306,-22},{1267,-31},{1273,-34},{1272,-37},{1267,-38},{1262,-36},{1260,-34},{1261,-31},{1287,-36},{1286,-35},{1287,-35},{1395,-21},{1363,-22},{1336,-22},{1303,-22},{1302,-22},{1305,-22},{1304,-22},{1338,-22},{1339,-22},{1282,-29},{1290,-28},{1291,-30},{1295,-28},{1300,-30},{1303,-30},{1308,-35},{1308,-39},{1299,-33},{1295,-33},{1295,-35},{1289,-33},{1289,-32},{1285,-35},{1282,-31},{1279,-36},{1281,-31},{1337,-22},{1333,-25},{1333,-24},{1336,-25},{1335,-24},{1346,-24},{1346,-23},{1340,-24},{1340,-23},{1341,-24},{1343,-25},{1338,-24},{1339,-25},{1340,-25},{1339,-24},{1278,21},{1244,-21},{1244,-20},{1243,-20},{1245,-16},{1254,-19},{1244,-17},{1251,-17},{1253,-19},{1257,-18},{1243,-18},{1243,-17},{1255,-18},{1256,-18},{1249,-17},{1250,-17},{1271,2},{1312,6},{1291,7},{1292,7},{1274,7},{1274,6},{1285,6},{1286,6},{1287,6},{1290,2},{1299,3},{1274,3},{1273,3},{1274,4},{1310,4},{1311,4},{1274,5},{1311,5},{1289,5},{1288,5},{1288,6},{1343,8},{1343,9},{1261,10},{1312,10},{1313,10},{1313,11},{1264,13},{1263,13},{1264,14},{1282,24},{1282,23},{1281,23},{1283,8},{1282,8},{1275,7},{1275,9},{1273,9},{1273,7},{1273,8},{1274,8},{1275,17},{1281,16},{1280,16},{1280,13},{1280,18},{1281,17},{1280,17},{1278,23},{1278,22},{1277,22},{1282,22},{1287,25},{1286,21},{1283,20},{1283,24},{1286,26},{1303,-2},{1304,-2},{1302,-2},{1307,-1},{1302,1},{1303,1},{1275,1},{1275,0},{1303,-1},{1302,-1},{1272,-1},{1273,-1},{1300,-1},{1301,-1},{1274,-1},{1284,-12},{1284,-11},{1293,0},{1294,0},{1295,-1},{1296,-2},{1275,-1},{1311,-1},{1311,0},{1309,0},{1272,0},{1305,0},{1274,0},{1301,0},{1296,-1},{1296,0},{1274,1},{1270,-3},{1271,-3},{1302,-3},{1312,-10},{1271,-2},{1271,1},{1272,1},{1272,2},{1301,1},{1300,2},{1301,2},{1304,-3},{1307,-3},{1308,-3},{1305,-3},{1303,-3},{1343,-39},{1342,-37},{1338,-36},{1338,-37},{1337,-37},{1337,-32},{1339,-30},{1339,-31},{1338,-29},{1337,-31},{1337,-34},{1334,-34},{1336,-36},{1334,-37},{1334,-36},{1335,-36},{1335,-35},{1333,-36},{1335,-39},{1333,-38},{1334,-39},{1329,-41},{1327,-36},{1329,-35},{1328,-33},{1327,-33},{1323,-29},{1321,-28},{1319,-28},{1322,-27},{1327,-28},{1332,-24},{1333,-27},{1334,-27},{1336,-27},{1337,-26},{1336,-28},{1338,-27},{1341,-23},{1340,-21},{1323,-23},{1320,-21},{1322,-20},{1320,-20},{1319,-19},{1321,-16},{1319,-17},{1319,-16},{1320,-16},{1320,-14},{1318,-16},{1317,-14},{1315,-15},{1316,-14},{1315,-14},{1316,-13},{1314,-15},{1314,-14},{1313,-13},{1312,-15},{1309,-14},{1312,-8},{1318,-7},{1324,-3},{1330,-4},{1334,-7},{1340,-7},{1343,-14},{1341,-17},{1342,-24},{1345,-29},{1345,-26},{1346,-25},{1347,-30},{1349,-29},{1351,-34},{1355,-34},{1359,-30},{1364,-22},{1373,-21},{1372,-18},{1378,-15},{1398,-24},{1402,-23},{1407,-25},{1407,-26},{1410,-26},{1410,-63},{1408,-66},{1410,-69},{1410,-91},{1404,-85},{1404,-84},{1405,-85},{1405,-84},{1400,-82},{1401,-81},{1401,-79},{1399,-81},{1394,-82},{1393,-80},{1389,-81},{1394,-72},{1394,-71},{1395,-72},{1395,-73},{1396,-73},{1397,-72},{1395,-71},{1393,-72},{1385,-70},{1392,-70},{1384,-63},{1382,-59},{1384,-58},{1384,-57},{1385,-58},{1383,-58},{1381,-57},{1382,-54},{1381,-55},{1379,-54},{1380,-53},{1379,-52},{1378,-52},{1379,-51},{1377,-52},{1378,-51},{1377,-51},{1376,-52},{1376,-51},{1377,-50},{1376,-49},{1375,-51},{1374,-51},{1375,-49},{1373,-50},{1373,-49},{1372,-50},{1372,-48},{1371,-50},{1371,-48},{1369,-49},{1370,-49},{1370,-48},{1369,-48},{1367,-49},{1359,-45},{1259,-20},{1260,-20},{1260,-25},{1259,-22},{1302,-21},{1305,-21},{1304,-21},{1370,-18},{1371,-19},{1338,-21},{1309,-22},{1309,-21},{1339,-21},{1303,-21},{1321,-21},{1393,-20},{1392,-20},{1347,-21},{1301,-21},{1342,-21},{1390,-19},{1372,-21},{1372,-20},{1373,-20},{1372,-19},{1371,-18},{1343,-21},{1344,-20},{1344,-22},{1348,-21},{1347,-20},{1348,-20},{1342,-20},{1304,-20},{1305,-20},{1303,-20},{1306,-20},{1387,-16},{1358,-15},{1280,-15},{1286,-15},{1353,-15},{1354,-15},{1287,-15},{1274,-15},{1352,-15},{1351,-15},{1302,-15},{1303,-15},{1342,-15},{1343,-15},{1301,-14},{1303,-14},{1289,-14},{1310,-14},{1281,-16},{1281,-15},{1317,-15},{1316,-15},{1364,-20},{1363,-19},{1373,-19},{1342,-17},{1343,-18},{1342,-19},{1253,-18},{1254,-18},{1263,-18},{1254,-20},{1276,-19},{1276,-18},{1300,-20},{1297,-19},{1304,-17},{1363,-13},{1363,-12},{1365,-13},{1365,-12},{1265,-18},{1264,-18},{1358,-18},{1297,-18},{1296,-18},{1388,-17},{1358,-17},{1366,-12},{1364,-12},{1311,-12},{1298,-12},{1366,-11},{1355,-6},{1355,-7},{1274,-12},{1274,-11},{1348,-11},{1283,-11},{1282,-11},{1282,-10},{1362,-19},{1354,-16},{1369,-18},{1302,-17},{1298,-17},{1299,-16},{1299,-17},{1284,-16},{1283,-17},{1283,-16},{1367,-12},{1366,-13},{1283,-10},{1311,-11},{1311,-10},{1312,-12},{1294,-12},{1293,-12},{1296,-12},{1310,-12},{1297,-12},{1299,-12},{1300,-12},{1298,-13},{1295,-12},{1306,-11},{1284,-10},{1283,-9},{1355,-9},{1355,-10},{1350,-10},{1349,-11},{1348,-10},{1349,-9},{1349,-10},{1313,-10},{1312,-9},{1313,-9},{1311,-9},{1273,-15},{1273,-14},{1274,-14},{1277,-13},{1281,-17},{1274,-17},{1367,-13},{1297,-13},{1296,-13},{1359,-7},{1364,-11},{1359,-12},{1357,-8},{1357,-9},{1356,-9},{1354,-6},{1310,-13},{1364,-13},{1274,-13},{1362,-13},{1362,-12},{1275,-13},{1275,-12},{1285,-6},{1303,-6},{1272,-6},{1272,-5},{1273,-5},{1273,-6},{1284,-6},{1307,-6},{1302,-6},{1283,-6},{1277,-4},{1304,-4},{1304,-5},{1306,-5},{1307,-5},{1299,-4},{1299,-5},{1298,-4},{1305,-5},{1284,-5},{1306,-4},{1281,-9},{1272,-8},{1271,-8},{1273,-8},{1281,-8},{1299,-8},{1307,-8},{1308,-8},{1303,-7},{1302,-7},{1301,-8},{1301,-7},{1306,-7},{1307,-7},{1298,-8},{1305,-8},{1273,-7},{1274,-6},{1274,-7},{1306,-6},{1276,-8},{1275,-8},{1273,-3},{1276,-3},{1277,-5},{1276,-6},{1279,-8},{1278,-9},{1277,-9},{1341,-9},{1309,-8},{1304,-9},{1307,-11},{1306,-10},{1353,-4},{1322,-4},{1322,-3},{1303,-4},{1307,-4},{1312,-4},{1313,-4},{1274,-4},{1273,-4},{1313,-3},{1271,-5},{1272,-3},{1277,-3},{1278,-4},{1302,-4},{1274,-3},{1304,-1},{1310,0},{1310,-4},{1306,-1},{1309,-4},{1305,-4},{1305,-2},{1279,0},{1284,-9},{1280,-7},{1277,3},{1275,6},{1276,9},{1274,10},{1276,18},{1280,22},{1281,22},{1278,19},{1277,9},{1279,8},{1280,11},{1282,12},{1282,14},{1287,16},{1287,11},{1287,3},{1288,3},{1289,2},{1280,5}}}, - {"Asia/Taipei",63,{{1215,226},{1215,227},{1195,236},{1167,207},{1196,236},{1200,231},{1196,237},{1195,237},{1196,238},{1202,237},{1202,238},{1182,244},{1183,244},{1184,244},{1183,245},{1184,245},{1199,260},{1200,260},{1200,259},{1220,248},{1219,248},{1199,261},{1199,262},{1200,262},{1200,261},{1200,263},{1205,264},{1216,219},{1216,220},{1215,221},{1216,221},{1215,220},{1203,223},{1204,223},{1200,232},{1201,232},{1194,232},{1196,232},{1196,233},{1201,233},{1197,232},{1197,233},{1195,234},{1193,234},{1200,234},{1200,235},{1195,235},{1197,236},{1196,235},{1203,226},{1200,230},{1201,236},{1207,246},{1210,250},{1215,253},{1219,251},{1220,250},{1218,249},{1219,245},{1216,241},{1214,231},{1210,226},{1209,219}}}, - {"Asia/Ulaanbaatar",64,{{1050,416},{1045,417},{1045,419},{1033,419},{1021,422},{1018,425},{1009,426},{995,426},{978,427},{977,438},{984,454},{983,458},{978,462},{976,466},{983,475},{981,480},{991,483},{992,489},{991,491},{978,490},{970,495},{972,498},{979,500},{983,503},{983,505},{980,507},{978,510},{980,514},{982,515},{983,517},{987,518},{989,521},{1000,518},{1021,514},{1022,513},{1023,506},{1033,502},{1041,502},{1054,505},{1067,503},{1071,500},{1080,499},{1079,497},{1085,493},{1098,492},{1108,491},{1125,495},{1124,491},{1127,478},{1122,478},{1120,474},{1116,472},{1114,465},{1115,462},{1119,461},{1119,456},{1121,452},{1117,450},{1114,443},{1120,438},{1110,433},{1102,426},{1088,424},{1075,425}}}, - {"Indian/Christmas",4,{{1057,-105},{1057,-106},{1055,-105},{1057,-104}}}, - {"America/Argentina/Salta",73,{{-652,-221},{-646,-223},{-643,-229},{-639,-220},{-628,-220},{-628,-222},{-623,-225},{-623,-244},{-634,-257},{-642,-256},{-645,-262},{-649,-263},{-657,-261},{-657,-263},{-663,-262},{-664,-264},{-668,-258},{-665,-256},{-666,-253},{-685,-252},{-683,-251},{-686,-248},{-684,-245},{-673,-240},{-672,-238},{-665,-242},{-664,-234},{-660,-235},{-660,-239},{-655,-244},{-649,-246},{-648,-245},{-646,-246},{-643,-244},{-642,-242},{-642,-235},{-644,-236},{-647,-234},{-649,-235},{-653,-226},{-634,-393},{-634,-407},{-628,-410},{-638,-412},{-649,-408},{-647,-408},{-648,-407},{-650,-407},{-652,-410},{-650,-415},{-651,-420},{-718,-420},{-719,-407},{-717,-404},{-718,-402},{-716,-399},{-717,-396},{-715,-396},{-714,-389},{-708,-386},{-712,-379},{-711,-371},{-712,-370},{-710,-365},{-707,-364},{-706,-361},{-704,-362},{-697,-371},{-682,-376},{-683,-360},{-651,-360},{-651,-350},{-634,-350}}}, - {"Australia/Broken_Hill",4,{{1410,-322},{1410,-315},{1420,-316},{1418,-323}}}, - {"Australia/Melbourne",79,{{1477,-379},{1478,-379},{1453,-383},{1453,-382},{1469,-387},{1468,-387},{1469,-386},{1466,-387},{1467,-387},{1466,-395},{1467,-395},{1470,-392},{1463,-391},{1464,-392},{1499,-376},{1499,-375},{1447,-383},{1447,-382},{1452,-385},{1453,-385},{1454,-386},{1420,-384},{1422,-384},{1423,-384},{1468,-386},{1454,-384},{1455,-384},{1462,-391},{1462,-390},{1463,-388},{1463,-389},{1465,-387},{1465,-388},{1466,-388},{1467,-388},{1464,-387},{1426,-348},{1428,-346},{1433,-348},{1434,-352},{1447,-361},{1450,-361},{1450,-359},{1451,-358},{1469,-361},{1474,-360},{1479,-360},{1482,-366},{1481,-368},{1500,-375},{1497,-375},{1498,-376},{1495,-378},{1477,-378},{1475,-381},{1479,-379},{1462,-387},{1464,-391},{1462,-388},{1459,-389},{1458,-386},{1454,-385},{1455,-382},{1452,-384},{1449,-385},{1449,-384},{1451,-382},{1449,-378},{1444,-381},{1447,-381},{1440,-385},{1436,-389},{1424,-384},{1417,-383},{1414,-384},{1410,-381},{1410,-340},{1415,-342},{1422,-342}}}, - {"America/Argentina/Tucuman",14,{{-662,-262},{-657,-263},{-657,-261},{-649,-263},{-645,-262},{-645,-267},{-651,-275},{-651,-279},{-653,-279},{-656,-281},{-660,-274},{-662,-273},{-658,-267},{-662,-266}}}, - {"America/Kentucky/Louisville",4,{{-861,380},{-863,382},{-863,384},{-854,386}}}, - {"America/Halifax",206,{{-637,445},{-638,445},{-656,434},{-600,439},{-601,439},{-601,440},{-597,440},{-664,442},{-663,443},{-628,447},{-627,447},{-627,448},{-642,445},{-643,445},{-642,446},{-629,447},{-631,447},{-635,446},{-632,447},{-633,447},{-643,444},{-636,444},{-641,445},{-639,445},{-641,444},{-638,444},{-637,444},{-642,444},{-658,435},{-657,435},{-654,435},{-653,435},{-658,436},{-655,435},{-656,435},{-653,436},{-653,437},{-661,436},{-661,437},{-660,437},{-660,436},{-662,438},{-648,439},{-646,440},{-645,441},{-643,442},{-644,442},{-642,443},{-643,443},{-644,443},{-663,442},{-662,444},{-659,437},{-660,438},{-621,449},{-621,450},{-659,438},{-602,472},{-618,474},{-617,475},{-616,476},{-617,473},{-619,473},{-620,473},{-614,478},{-615,478},{-615,476},{-619,474},{-618,472},{-620,472},{-620,474},{-614,476},{-616,475},{-613,464},{-641,465},{-641,464},{-604,464},{-632,461},{-631,461},{-624,462},{-620,450},{-643,451},{-615,452},{-616,452},{-605,462},{-607,461},{-603,463},{-604,463},{-638,465},{-638,466},{-637,466},{-639,467},{-640,467},{-640,468},{-641,468},{-626,448},{-642,450},{-642,449},{-641,450},{-642,452},{-633,454},{-649,453},{-640,460},{-632,458},{-634,458},{-633,457},{-630,457},{-631,458},{-627,458},{-625,456},{-619,459},{-620,456},{-615,457},{-613,455},{-616,455},{-615,454},{-612,454},{-610,453},{-618,453},{-617,451},{-620,451},{-619,450},{-625,448},{-625,449},{-629,448},{-636,447},{-635,445},{-639,447},{-643,446},{-646,442},{-648,438},{-651,438},{-650,437},{-654,437},{-662,441},{-659,446},{-660,446},{-644,453},{-645,453},{-643,453},{-644,451},{-624,448},{-624,449},{-623,449},{-622,449},{-620,449},{-650,453},{-650,452},{-611,452},{-612,452},{-610,454},{-641,454},{-611,455},{-610,455},{-609,455},{-626,458},{-625,458},{-611,460},{-616,460},{-638,464},{-630,464},{-620,465},{-624,464},{-626,461},{-625,460},{-628,459},{-630,461},{-629,462},{-637,462},{-641,466},{-644,467},{-640,471},{-612,456},{-608,456},{-610,456},{-609,456},{-617,456},{-617,457},{-616,457},{-625,457},{-627,457},{-608,458},{-608,457},{-633,458},{-611,458},{-612,455},{-611,456},{-602,457},{-613,456},{-615,458},{-616,461},{-611,464},{-611,466},{-606,470},{-604,470},{-605,469},{-603,469},{-606,462},{-611,459},{-610,459},{-609,459},{-612,457},{-609,458},{-609,457},{-607,458},{-616,451}}}, - {"Asia/Macau",3,{{1136,221},{1136,222},{1135,222}}}, - {"America/Ojinaga",14,{{-1065,318},{-1049,306},{-1045,296},{-1033,290},{-1034,288},{-1047,295},{-1051,304},{-1066,316},{-1080,316},{-1081,311},{-1089,312},{-1088,313},{-1082,313},{-1082,318}}}, - {"America/Nome",270,{{-1692,528},{-1692,529},{-1662,537},{-1663,538},{-1661,538},{-1662,538},{-1669,534},{-1669,535},{-1685,530},{-1684,530},{-1689,530},{-1656,542},{-1655,542},{-1654,542},{-1656,541},{-1657,542},{-1624,546},{-1680,533},{-1688,529},{-1691,528},{-1687,532},{-1684,533},{-1683,535},{-1678,535},{-1661,539},{-1660,539},{-1661,540},{-1670,536},{-1667,537},{-1672,538},{-1670,540},{-1666,540},{-1666,538},{-1664,540},{-1662,539},{-1666,537},{-1663,537},{-1667,536},{-1667,535},{-1668,536},{-1668,534},{-1675,533},{-1679,533},{-1671,535},{-1672,535},{-1670,535},{-1672,536},{-1680,539},{-1666,539},{-1665,539},{-1662,540},{-1648,542},{-1649,542},{-1649,541},{-1650,541},{-1652,541},{-1655,541},{-1622,547},{-1628,544},{-1629,544},{-1625,544},{-1624,544},{-1627,544},{-1628,545},{-1656,540},{-1655,540},{-1653,540},{-1653,541},{-1659,542},{-1658,541},{-1657,541},{-1661,541},{-1629,553},{-1628,554},{-1627,554},{-1696,565},{-1698,566},{-1695,566},{-1631,554},{-1632,554},{-1704,570},{-1649,626},{-1649,627},{-1703,571},{-1704,572},{-1701,572},{-1702,572},{-1620,586},{-1621,586},{-1622,587},{-1620,587},{-1620,592},{-1621,593},{-1620,593},{-1728,602},{-1727,602},{-1728,604},{-1731,605},{-1722,603},{-1726,603},{-1730,606},{-1731,607},{-1730,607},{-1630,553},{-1648,626},{-1649,628},{-1689,657},{-1689,658},{-1633,646},{-1681,650},{-1680,650},{-1662,645},{-1625,670},{-1624,670},{-1635,550},{-1631,547},{-1634,547},{-1646,544},{-1649,545},{-1645,549},{-1629,549},{-1623,548},{-1624,549},{-1623,550},{-1622,549},{-1624,550},{-1634,550},{-1634,551},{-1633,551},{-1628,670},{-1627,670},{-1626,670},{-1626,636},{-1627,636},{-1623,636},{-1624,635},{-1620,552},{-1620,551},{-1626,553},{-1627,552},{-1626,550},{-1626,551},{-1632,551},{-1630,549},{-1633,548},{-1634,548},{-1632,549},{-1625,554},{-1626,554},{-1620,558},{-1661,617},{-1661,618},{-1659,614},{-1660,615},{-1659,615},{-1660,619},{-1660,620},{-1659,620},{-1660,621},{-1649,625},{-1650,626},{-1620,670},{-1637,671},{-1641,676},{-1668,683},{-1663,684},{-1662,689},{-1643,689},{-1637,691},{-1632,694},{-1630,698},{-1620,703},{-1620,666},{-1625,667},{-1626,669},{-1623,669},{-1620,668},{-1688,631},{-1634,630},{-1634,631},{-1646,631},{-1635,631},{-1636,631},{-1637,631},{-1637,632},{-1644,632},{-1636,632},{-1620,647},{-1628,643},{-1631,646},{-1634,646},{-1630,645},{-1631,644},{-1637,646},{-1650,644},{-1662,646},{-1665,647},{-1664,649},{-1667,650},{-1669,652},{-1669,653},{-1669,651},{-1665,651},{-1664,653},{-1681,656},{-1655,664},{-1644,666},{-1637,666},{-1636,666},{-1639,666},{-1637,665},{-1638,663},{-1642,662},{-1620,661},{-1641,662},{-1640,662},{-1715,637},{-1710,636},{-1703,637},{-1701,636},{-1701,635},{-1687,633},{-1689,631},{-1694,632},{-1697,629},{-1705,634},{-1715,633},{-1718,634},{-1717,638},{-1642,598},{-1643,599},{-1643,600},{-1671,600},{-1675,602},{-1669,602},{-1662,604},{-1657,603},{-1657,601},{-1655,600},{-1661,597},{-1657,602},{-1620,598},{-1622,600},{-1625,601},{-1633,598},{-1641,598},{-1641,600},{-1651,604},{-1650,605},{-1654,605},{-1650,607},{-1652,610},{-1650,610},{-1653,612},{-1656,611},{-1656,613},{-1659,613},{-1658,615},{-1661,615},{-1662,616},{-1662,617},{-1658,617},{-1656,619},{-1657,621},{-1648,629},{-1631,631},{-1623,635},{-1620,635},{-1622,634},{-1620,634}}}, - {"Pacific/Wake",2,{{1666,193},{1667,193}}}, - {"Europe/Andorra",4,{{17,426},{15,424},{14,425},{15,427}}}, - {"Asia/Pyongyang",107,{{1257,378},{1258,378},{1250,378},{1257,376},{1249,385},{1248,385},{1248,386},{1251,386},{1251,377},{1252,377},{1250,379},{1262,378},{1259,378},{1254,378},{1251,378},{1252,378},{1253,378},{1253,377},{1243,399},{1242,398},{1282,400},{1303,421},{1303,422},{1244,398},{1244,399},{1244,400},{1243,400},{1245,397},{1276,397},{1246,395},{1248,395},{1247,395},{1252,395},{1251,395},{1246,396},{1247,396},{1254,395},{1254,396},{1249,396},{1249,395},{1248,396},{1281,390},{1250,386},{1250,387},{1248,394},{1246,394},{1275,392},{1276,392},{1275,394},{1274,394},{1247,394},{1270,381},{1266,378},{1264,379},{1261,377},{1261,379},{1256,380},{1257,379},{1255,379},{1252,379},{1253,381},{1247,381},{1250,382},{1249,383},{1256,387},{1253,387},{1251,389},{1254,393},{1253,395},{1248,398},{1246,398},{1243,401},{1249,405},{1260,409},{1265,414},{1267,417},{1269,418},{1273,415},{1281,414},{1283,416},{1281,420},{1289,420},{1293,425},{1297,424},{1299,430},{1303,429},{1303,427},{1305,426},{1307,423},{1304,423},{1298,418},{1297,415},{1298,414},{1297,408},{1292,407},{1283,400},{1280,401},{1279,399},{1276,398},{1276,393},{1273,394},{1274,392},{1277,391},{1284,387},{1283,384},{1281,383},{1271,383}}}, - {"America/Iqaluit",1841,{{-789,588},{-691,591},{-779,608},{-778,608},{-779,607},{-792,520},{-790,521},{-789,521},{-790,519},{-791,521},{-789,512},{-790,512},{-789,513},{-791,516},{-791,517},{-793,517},{-792,518},{-791,518},{-789,519},{-789,520},{-768,561},{-793,519},{-793,520},{-792,519},{-793,521},{-794,519},{-797,520},{-794,521},{-791,522},{-790,522},{-795,522},{-794,523},{-794,522},{-790,523},{-791,523},{-792,523},{-786,524},{-802,524},{-803,524},{-788,524},{-787,524},{-791,524},{-791,525},{-786,525},{-787,525},{-788,525},{-797,525},{-796,526},{-796,525},{-791,526},{-792,526},{-792,525},{-789,526},{-788,526},{-788,527},{-792,527},{-789,530},{-788,530},{-790,530},{-790,529},{-791,529},{-789,529},{-788,528},{-789,528},{-792,528},{-791,528},{-793,528},{-793,529},{-792,529},{-790,525},{-790,534},{-790,533},{-791,534},{-789,534},{-797,533},{-791,533},{-800,534},{-799,533},{-801,532},{-801,533},{-792,534},{-792,535},{-791,535},{-797,535},{-790,535},{-793,535},{-791,536},{-791,537},{-792,537},{-792,538},{-791,539},{-792,539},{-790,538},{-791,538},{-798,539},{-799,539},{-795,540},{-791,541},{-791,540},{-792,540},{-792,541},{-793,541},{-795,541},{-791,542},{-792,542},{-793,542},{-795,542},{-794,542},{-794,543},{-807,543},{-811,543},{-811,544},{-795,544},{-796,544},{-796,545},{-795,545},{-814,532},{-810,531},{-807,527},{-821,530},{-798,531},{-799,531},{-798,532},{-790,531},{-790,532},{-789,532},{-795,546},{-796,546},{-798,546},{-797,546},{-796,547},{-798,547},{-795,547},{-795,548},{-794,548},{-784,551},{-783,551},{-827,552},{-828,552},{-829,552},{-830,552},{-830,553},{-778,554},{-777,554},{-776,554},{-797,554},{-775,555},{-774,555},{-800,557},{-772,557},{-772,558},{-771,558},{-773,557},{-792,557},{-791,558},{-793,557},{-796,556},{-798,556},{-774,556},{-773,556},{-797,548},{-797,547},{-798,548},{-796,548},{-790,549},{-796,549},{-801,560},{-801,559},{-802,559},{-768,562},{-767,561},{-798,562},{-791,562},{-790,562},{-767,562},{-797,562},{-789,562},{-789,563},{-781,561},{-800,561},{-797,563},{-768,563},{-788,563},{-784,562},{-784,563},{-790,563},{-781,563},{-780,563},{-778,563},{-779,563},{-787,559},{-783,559},{-779,559},{-793,559},{-793,560},{-800,559},{-800,560},{-791,559},{-799,560},{-796,560},{-787,560},{-791,560},{-790,560},{-799,561},{-789,561},{-797,560},{-796,561},{-795,560},{-789,560},{-788,561},{-801,561},{-790,561},{-795,561},{-794,557},{-792,559},{-787,558},{-788,558},{-793,558},{-799,558},{-798,558},{-799,559},{-787,567},{-788,567},{-767,565},{-766,567},{-766,566},{-792,566},{-789,567},{-784,567},{-783,567},{-766,568},{-767,567},{-767,568},{-788,568},{-767,570},{-767,571},{-788,571},{-787,571},{-780,570},{-781,570},{-786,571},{-797,570},{-767,572},{-768,572},{-768,573},{-767,573},{-698,589},{-783,572},{-784,573},{-783,573},{-799,573},{-768,574},{-767,574},{-785,573},{-799,575},{-791,575},{-790,575},{-799,574},{-789,574},{-788,574},{-785,574},{-784,574},{-786,574},{-785,572},{-784,572},{-796,568},{-799,567},{-800,568},{-799,569},{-798,568},{-787,568},{-798,569},{-799,570},{-767,569},{-789,568},{-788,569},{-797,569},{-796,569},{-770,578},{-771,578},{-693,578},{-797,579},{-689,580},{-688,580},{-687,580},{-772,580},{-773,580},{-798,581},{-683,581},{-781,581},{-782,581},{-692,578},{-692,579},{-775,581},{-776,582},{-775,582},{-777,582},{-790,589},{-778,583},{-777,583},{-779,583},{-780,583},{-781,584},{-808,584},{-782,584},{-783,585},{-785,585},{-785,586},{-786,586},{-784,585},{-784,586},{-787,586},{-786,587},{-787,587},{-683,587},{-789,587},{-788,587},{-786,588},{-787,588},{-790,588},{-789,589},{-697,588},{-697,589},{-785,587},{-697,587},{-788,588},{-806,590},{-689,590},{-690,590},{-691,590},{-695,590},{-787,589},{-787,590},{-693,590},{-784,590},{-785,590},{-694,589},{-694,590},{-783,590},{-806,591},{-783,591},{-782,592},{-806,592},{-806,593},{-688,593},{-692,593},{-781,593},{-781,592},{-804,593},{-785,593},{-693,593},{-693,594},{-695,594},{-696,594},{-806,594},{-807,595},{-806,595},{-805,595},{-804,595},{-778,595},{-803,595},{-803,596},{-778,596},{-806,596},{-806,597},{-805,597},{-805,596},{-804,597},{-803,594},{-778,594},{-805,594},{-805,591},{-782,591},{-788,589},{-693,589},{-784,589},{-785,589},{-786,589},{-786,590},{-786,575},{-787,575},{-798,574},{-798,575},{-769,575},{-769,576},{-798,576},{-797,575},{-796,575},{-785,575},{-775,598},{-803,598},{-802,598},{-800,598},{-799,598},{-774,599},{-775,599},{-799,599},{-800,599},{-801,598},{-699,600},{-700,600},{-702,600},{-776,600},{-698,600},{-697,600},{-775,600},{-696,601},{-777,604},{-683,605},{-680,606},{-680,603},{-684,602},{-776,603},{-696,603},{-777,602},{-776,602},{-697,599},{-696,599},{-798,600},{-798,599},{-696,607},{-695,607},{-777,607},{-778,607},{-694,608},{-693,609},{-694,609},{-700,609},{-701,609},{-698,609},{-701,610},{-694,610},{-697,611},{-778,615},{-776,615},{-695,610},{-787,607},{-786,608},{-783,608},{-781,608},{-782,608},{-780,608},{-778,606},{-777,606},{-779,606},{-778,616},{-779,617},{-778,617},{-800,617},{-779,616},{-680,622},{-793,621},{-793,622},{-776,597},{-777,597},{-802,597},{-696,597},{-778,597},{-767,563},{-795,564},{-796,563},{-800,563},{-797,564},{-795,565},{-801,562},{-778,564},{-781,564},{-780,564},{-767,564},{-775,564},{-788,564},{-787,564},{-787,562},{-791,563},{-791,561},{-795,559},{-798,559},{-795,563},{-795,566},{-794,564},{-794,562},{-793,566},{-796,564},{-779,564},{-777,564},{-781,565},{-766,565},{-780,565},{-781,566},{-796,566},{-788,566},{-791,565},{-791,566},{-793,567},{-792,567},{-795,568},{-788,565},{-772,674},{-773,674},{-736,680},{-735,680},{-792,681},{-791,681},{-742,681},{-734,680},{-733,678},{-743,678},{-748,680},{-743,682},{-823,682},{-733,683},{-732,683},{-788,682},{-750,682},{-741,682},{-742,682},{-762,683},{-751,680},{-751,675},{-756,673},{-767,672},{-773,677},{-770,681},{-742,683},{-743,683},{-790,682},{-792,683},{-788,683},{-789,682},{-787,682},{-786,683},{-785,682},{-786,682},{-817,684},{-816,684},{-748,683},{-791,684},{-791,685},{-792,685},{-738,683},{-828,663},{-829,663},{-833,664},{-832,664},{-830,664},{-829,664},{-836,664},{-836,665},{-840,666},{-846,663},{-845,663},{-833,663},{-841,662},{-843,663},{-815,670},{-814,670},{-846,670},{-848,670},{-817,669},{-817,670},{-840,667},{-840,668},{-845,668},{-844,668},{-845,669},{-846,669},{-849,669},{-850,669},{-847,670},{-738,685},{-739,685},{-738,686},{-745,685},{-745,686},{-741,685},{-742,685},{-744,685},{-740,685},{-744,684},{-741,683},{-787,686},{-787,685},{-790,685},{-789,687},{-785,686},{-681,686},{-680,686},{-750,687},{-739,686},{-740,686},{-739,687},{-738,687},{-741,644},{-742,644},{-831,656},{-745,655},{-743,655},{-748,686},{-749,686},{-748,687},{-740,687},{-756,644},{-738,644},{-738,645},{-739,644},{-739,645},{-751,644},{-751,645},{-743,645},{-742,645},{-733,645},{-781,645},{-757,645},{-758,645},{-744,645},{-735,645},{-734,645},{-737,645},{-755,645},{-745,645},{-746,645},{-755,644},{-744,644},{-757,644},{-741,645},{-737,644},{-757,646},{-732,646},{-736,646},{-743,646},{-740,646},{-741,646},{-741,647},{-748,648},{-747,648},{-747,647},{-748,647},{-758,653},{-759,653},{-758,654},{-745,654},{-744,654},{-752,654},{-746,654},{-771,655},{-772,655},{-765,655},{-742,655},{-836,659},{-680,659},{-681,659},{-682,659},{-683,659},{-843,659},{-843,660},{-842,660},{-842,659},{-680,660},{-836,660},{-835,660},{-836,661},{-837,661},{-837,662},{-835,661},{-845,661},{-845,662},{-847,662},{-848,662},{-846,661},{-843,662},{-842,662},{-846,662},{-838,661},{-838,662},{-835,656},{-834,656},{-835,657},{-839,657},{-838,657},{-840,657},{-680,658},{-841,658},{-730,796},{-835,658},{-832,658},{-834,658},{-840,661},{-838,658},{-832,657},{-838,656},{-837,658},{-758,646},{-745,646},{-744,646},{-830,663},{-830,662},{-847,669},{-841,667},{-842,666},{-845,664},{-849,662},{-788,761},{-792,759},{-789,758},{-798,759},{-833,807},{-799,755},{-804,755},{-796,755},{-795,754},{-796,753},{-795,753},{-804,750},{-793,749},{-801,748},{-802,746},{-818,745},{-829,745},{-831,747},{-830,748},{-835,749},{-833,748},{-836,745},{-850,745},{-850,757},{-823,758},{-746,794},{-747,794},{-761,790},{-762,790},{-760,790},{-759,791},{-760,791},{-850,793},{-849,793},{-838,791},{-839,791},{-840,791},{-824,807},{-822,808},{-794,809},{-793,809},{-819,825},{-682,827},{-681,827},{-735,829},{-736,829},{-784,829},{-785,829},{-781,829},{-783,829},{-713,829},{-714,830},{-712,829},{-788,769},{-788,770},{-787,770},{-787,769},{-803,772},{-803,773},{-802,772},{-848,774},{-847,774},{-850,776},{-849,775},{-848,775},{-850,775},{-779,778},{-779,777},{-776,778},{-778,778},{-780,778},{-815,774},{-814,774},{-816,774},{-817,775},{-816,775},{-764,779},{-763,779},{-768,779},{-769,779},{-767,779},{-826,780},{-850,783},{-745,788},{-744,788},{-741,787},{-747,787},{-757,789},{-756,789},{-845,789},{-844,789},{-849,790},{-816,762},{-815,762},{-813,761},{-814,762},{-812,762},{-850,764},{-849,764},{-844,763},{-850,763},{-841,765},{-839,764},{-841,764},{-842,765},{-839,765},{-799,762},{-798,762},{-737,830},{-738,830},{-739,830},{-800,829},{-781,828},{-778,829},{-759,826},{-762,825},{-763,824},{-755,826},{-775,830},{-745,830},{-726,827},{-725,827},{-716,831},{-718,830},{-709,829},{-716,830},{-703,831},{-680,830},{-680,827},{-687,826},{-680,816},{-693,817},{-684,815},{-688,815},{-680,815},{-680,814},{-702,812},{-696,812},{-700,811},{-680,813},{-680,808},{-696,804},{-702,803},{-703,805},{-706,805},{-708,805},{-704,804},{-705,803},{-699,803},{-701,802},{-724,802},{-719,801},{-723,801},{-705,801},{-714,799},{-709,799},{-715,797},{-727,797},{-731,798},{-742,799},{-749,798},{-733,798},{-731,795},{-749,795},{-750,794},{-771,795},{-759,793},{-774,794},{-772,793},{-781,794},{-745,792},{-748,792},{-744,791},{-778,792},{-761,791},{-776,790},{-779,789},{-757,790},{-762,789},{-748,788},{-749,788},{-748,786},{-746,786},{-761,785},{-750,783},{-755,782},{-769,782},{-756,781},{-759,780},{-784,779},{-781,777},{-777,776},{-783,774},{-800,773},{-818,774},{-811,773},{-822,773},{-818,772},{-793,772},{-790,771},{-794,769},{-787,768},{-781,770},{-777,768},{-778,766},{-784,765},{-788,766},{-793,763},{-811,761},{-808,764},{-821,765},{-820,766},{-825,767},{-821,766},{-822,765},{-821,764},{-828,764},{-833,767},{-832,764},{-837,764},{-841,766},{-845,764},{-850,766},{-850,774},{-835,773},{-838,775},{-832,776},{-823,781},{-828,780},{-837,775},{-850,782},{-848,783},{-850,789},{-823,786},{-822,786},{-833,788},{-817,788},{-816,790},{-825,789},{-847,790},{-845,791},{-835,790},{-843,792},{-845,794},{-850,795},{-850,803},{-837,802},{-816,796},{-807,796},{-798,797},{-815,797},{-816,800},{-832,803},{-781,806},{-780,806},{-800,806},{-765,809},{-790,809},{-785,812},{-768,814},{-769,815},{-788,811},{-786,811},{-789,811},{-795,812},{-791,811},{-800,808},{-830,805},{-832,806},{-818,808},{-836,807},{-831,808},{-832,808},{-838,807},{-837,806},{-838,805},{-850,805},{-850,810},{-824,812},{-850,811},{-850,813},{-847,813},{-850,819},{-848,819},{-850,820},{-846,819},{-850,825},{-832,823},{-834,822},{-829,821},{-831,821},{-819,820},{-830,822},{-827,823},{-792,818},{-799,820},{-798,820},{-827,824},{-815,825},{-824,826},{-822,827},{-806,825},{-816,828},{-799,826},{-800,827},{-798,827},{-792,827},{-785,827},{-804,829},{-736,830},{-735,830},{-741,831},{-743,831},{-744,831},{-740,831},{-850,688},{-847,687},{-849,689},{-850,690},{-847,689},{-845,690},{-850,691},{-850,698},{-849,699},{-822,696},{-827,696},{-824,695},{-832,696},{-832,695},{-822,694},{-824,694},{-821,693},{-822,692},{-813,692},{-812,691},{-820,689},{-813,689},{-812,686},{-819,684},{-822,685},{-826,684},{-820,683},{-825,683},{-822,683},{-822,681},{-820,682},{-822,680},{-821,679},{-812,675},{-819,670},{-821,667},{-835,663},{-838,667},{-839,667},{-839,668},{-839,669},{-843,670},{-849,671},{-850,670},{-748,685},{-749,684},{-748,684},{-754,685},{-753,687},{-680,687},{-683,688},{-685,688},{-681,688},{-752,688},{-751,687},{-685,687},{-848,688},{-849,688},{-746,688},{-745,688},{-750,689},{-748,689},{-749,689},{-756,691},{-811,690},{-849,690},{-849,691},{-848,691},{-817,694},{-818,694},{-756,692},{-785,694},{-782,693},{-788,689},{-794,689},{-681,692},{-680,692},{-801,694},{-802,694},{-815,694},{-814,693},{-819,694},{-680,695},{-681,696},{-683,696},{-680,697},{-828,697},{-827,697},{-825,695},{-825,696},{-821,696},{-820,696},{-803,695},{-822,695},{-808,695},{-808,696},{-823,696},{-824,696},{-820,697},{-822,697},{-821,697},{-823,697},{-824,697},{-773,697},{-775,697},{-823,695},{-823,694},{-821,694},{-802,695},{-820,694},{-685,702},{-686,702},{-779,702},{-681,703},{-767,693},{-769,691},{-774,693},{-771,695},{-766,694},{-815,695},{-817,695},{-816,695},{-847,699},{-846,699},{-817,699},{-814,699},{-815,699},{-799,699},{-800,700},{-782,700},{-783,700},{-782,699},{-820,699},{-781,698},{-781,699},{-780,699},{-824,698},{-686,701},{-687,701},{-683,701},{-684,701},{-714,701},{-714,702},{-685,701},{-781,702},{-782,702},{-782,703},{-781,703},{-785,703},{-780,702},{-684,702},{-786,703},{-786,704},{-684,704},{-795,704},{-795,705},{-791,705},{-791,706},{-790,706},{-721,708},{-849,711},{-850,711},{-850,712},{-849,712},{-848,711},{-850,714},{-849,714},{-848,713},{-850,713},{-848,714},{-736,714},{-735,714},{-735,715},{-720,710},{-719,711},{-713,710},{-719,708},{-722,709},{-711,711},{-710,712},{-713,711},{-712,711},{-685,703},{-687,703},{-830,700},{-809,700},{-801,700},{-730,638},{-780,700},{-779,700},{-768,697},{-784,696},{-782,698},{-779,696},{-789,695},{-800,697},{-793,697},{-801,696},{-800,695},{-808,697},{-769,698},{-770,698},{-784,697},{-774,697},{-774,698},{-823,698},{-793,698},{-825,698},{-826,698},{-831,698},{-833,698},{-830,698},{-836,698},{-836,697},{-839,698},{-838,698},{-835,698},{-829,698},{-827,698},{-807,698},{-773,698},{-827,699},{-846,717},{-744,717},{-745,717},{-748,717},{-747,717},{-735,716},{-804,721},{-805,721},{-806,721},{-806,722},{-805,722},{-747,722},{-746,722},{-748,722},{-750,722},{-730,637},{-789,723},{-790,723},{-791,724},{-790,724},{-787,724},{-804,726},{-850,738},{-848,737},{-850,737},{-809,737},{-810,737},{-774,728},{-775,728},{-842,731},{-843,731},{-761,729},{-782,729},{-796,728},{-800,729},{-801,732},{-809,733},{-808,735},{-807,735},{-809,736},{-808,738},{-806,738},{-786,736},{-781,737},{-767,733},{-800,725},{-801,725},{-799,725},{-729,637},{-730,715},{-728,714},{-731,713},{-734,715},{-728,717},{-727,717},{-726,716},{-730,716},{-732,717},{-733,716},{-734,716},{-733,717},{-718,637},{-721,637},{-731,637},{-728,637},{-727,637},{-725,638},{-726,638},{-727,638},{-728,638},{-727,639},{-723,638},{-724,637},{-725,637},{-726,637},{-723,637},{-724,638},{-729,638},{-730,639},{-729,639},{-728,639},{-723,639},{-722,639},{-727,640},{-726,639},{-729,640},{-728,640},{-780,640},{-735,642},{-736,642},{-775,640},{-776,640},{-779,640},{-777,640},{-730,640},{-736,640},{-778,640},{-730,641},{-731,641},{-733,641},{-737,641},{-736,641},{-738,641},{-735,641},{-732,641},{-760,643},{-718,635},{-734,641},{-731,640},{-735,640},{-732,640},{-772,643},{-772,642},{-765,643},{-766,643},{-763,642},{-763,643},{-738,642},{-738,643},{-771,643},{-767,643},{-762,643},{-761,643},{-745,644},{-758,643},{-747,643},{-746,643},{-753,643},{-754,643},{-748,643},{-749,643},{-748,644},{-734,643},{-735,643},{-735,644},{-743,643},{-744,643},{-745,643},{-736,643},{-740,643},{-739,643},{-752,643},{-734,642},{-757,643},{-737,643},{-756,643},{-766,642},{-767,642},{-755,643},{-739,642},{-731,642},{-740,642},{-737,642},{-732,642},{-732,643},{-741,642},{-729,642},{-765,642},{-765,641},{-766,641},{-739,641},{-740,641},{-729,641},{-730,642},{-733,642},{-759,644},{-758,644},{-743,644},{-779,644},{-760,644},{-749,644},{-746,644},{-750,644},{-752,644},{-781,624},{-780,624},{-777,625},{-778,625},{-780,625},{-779,625},{-803,620},{-800,624},{-796,624},{-793,623},{-797,616},{-781,626},{-779,626},{-695,626},{-778,626},{-776,626},{-696,627},{-695,627},{-709,627},{-700,627},{-701,626},{-700,626},{-700,625},{-706,625},{-701,625},{-740,626},{-746,627},{-739,626},{-742,626},{-697,628},{-703,627},{-703,628},{-702,628},{-698,628},{-710,628},{-711,628},{-709,628},{-710,630},{-711,629},{-712,629},{-710,629},{-712,630},{-713,630},{-715,630},{-714,630},{-711,630},{-715,631},{-716,631},{-718,633},{-719,633},{-681,633},{-682,633},{-720,633},{-709,631},{-681,632},{-718,632},{-680,632},{-680,633},{-714,631},{-707,627},{-707,628},{-705,628},{-702,626},{-707,626},{-704,628},{-706,628},{-706,629},{-707,629},{-708,629},{-708,628},{-709,629},{-681,636},{-682,636},{-713,635},{-723,636},{-724,636},{-775,636},{-725,636},{-722,636},{-721,636},{-717,636},{-683,636},{-718,636},{-719,636},{-728,636},{-687,636},{-688,636},{-717,635},{-716,635},{-716,636},{-720,636},{-687,637},{-686,636},{-717,637},{-720,637},{-715,635},{-685,635},{-686,635},{-721,635},{-723,635},{-720,635},{-718,634},{-722,635},{-779,635},{-777,634},{-775,632},{-780,631},{-785,634},{-682,634},{-786,634},{-785,635},{-784,635},{-680,634},{-778,635},{-681,634},{-681,635},{-680,635},{-719,634},{-721,634},{-767,635},{-684,634},{-684,635},{-773,636},{-774,636},{-770,637},{-766,634},{-770,634},{-775,637},{-774,637},{-716,637},{-715,637},{-773,637},{-772,637},{-726,636},{-845,733},{-846,734},{-836,734},{-840,735},{-829,737},{-814,737},{-812,735},{-812,733},{-806,732},{-806,729},{-802,727},{-809,725},{-805,725},{-809,722},{-811,721},{-808,720},{-809,719},{-803,721},{-802,722},{-803,723},{-798,725},{-794,724},{-796,723},{-793,724},{-792,720},{-785,719},{-789,720},{-788,722},{-777,717},{-789,722},{-786,724},{-780,722},{-776,722},{-785,725},{-776,728},{-752,725},{-753,724},{-749,722},{-755,721},{-752,721},{-756,720},{-758,717},{-761,717},{-755,720},{-750,721},{-743,721},{-741,720},{-742,718},{-753,717},{-749,717},{-754,715},{-746,717},{-751,715},{-747,714},{-751,712},{-750,712},{-746,714},{-747,715},{-741,717},{-742,716},{-741,715},{-739,718},{-736,718},{-740,715},{-743,714},{-740,714},{-742,712},{-738,715},{-736,716},{-734,714},{-737,713},{-739,710},{-734,713},{-730,713},{-732,712},{-734,710},{-733,710},{-726,717},{-715,715},{-711,713},{-715,711},{-720,711},{-728,708},{-722,708},{-725,706},{-712,709},{-712,710},{-709,711},{-706,711},{-705,709},{-708,707},{-716,706},{-720,704},{-717,704},{-718,703},{-717,703},{-715,706},{-712,705},{-715,700},{-710,706},{-699,709},{-698,709},{-704,706},{-704,705},{-706,705},{-703,705},{-700,706},{-694,708},{-683,705},{-686,705},{-688,703},{-696,702},{-702,700},{-698,700},{-701,700},{-705,698},{-696,701},{-694,698},{-698,698},{-700,697},{-700,696},{-697,698},{-686,699},{-680,703},{-680,698},{-700,695},{-687,696},{-680,693},{-690,694},{-693,693},{-682,693},{-690,692},{-685,692},{-691,691},{-689,691},{-690,690},{-681,691},{-680,690},{-683,690},{-686,690},{-680,689},{-685,689},{-680,688},{-686,688},{-690,689},{-694,689},{-687,687},{-689,686},{-680,685},{-684,661},{-682,658},{-681,654},{-680,655},{-680,636},{-690,637},{-688,623},{-688,625},{-688,626},{-689,624},{-692,624},{-692,626},{-693,625},{-694,628},{-699,629},{-697,627},{-699,628},{-702,627},{-709,630},{-708,631},{-709,632},{-713,632},{-717,633},{-717,634},{-716,634},{-712,636},{-715,636},{-719,639},{-722,638},{-722,637},{-722,640},{-723,640},{-726,640},{-728,642},{-731,646},{-733,647},{-734,646},{-739,646},{-740,645},{-741,643},{-740,644},{-742,646},{-740,647},{-744,647},{-745,648},{-746,649},{-750,648},{-747,645},{-759,646},{-780,644},{-783,647},{-780,650},{-773,652},{-775,653},{-773,654},{-774,655},{-760,653},{-752,653},{-751,654},{-747,654},{-745,653},{-741,655},{-735,654},{-736,657},{-745,662},{-730,667},{-728,670},{-722,673},{-724,673},{-724,675},{-727,677},{-726,678},{-729,679},{-730,682},{-735,683},{-733,684},{-732,684},{-736,682},{-740,684},{-737,687},{-742,687},{-747,687},{-744,688},{-748,688},{-750,688},{-747,689},{-755,690},{-756,689},{-766,687},{-765,689},{-766,690},{-767,696},{-764,697},{-762,695},{-762,697},{-772,696},{-767,698},{-770,699},{-770,700},{-776,698},{-777,702},{-784,702},{-784,703},{-784,704},{-787,705},{-789,707},{-790,707},{-789,706},{-792,704},{-793,704},{-793,705},{-792,706},{-794,706},{-794,705},{-796,705},{-796,704},{-789,703},{-787,701},{-788,699},{-817,701},{-809,697},{-822,701},{-822,702},{-821,702},{-830,703},{-821,698},{-850,701},{-849,709},{-848,709},{-848,712},{-846,712},{-845,715},{-846,716},{-845,716},{-844,717},{-850,717},{-850,723},{-844,721},{-850,729},{-845,729},{-850,730},{-850,731},{-841,731},{-850,732},{-850,734},{-843,732}}}, - {"Asia/Yakutsk",514,{{1291,725},{1290,725},{1289,726},{1289,725},{1197,731},{1197,732},{1203,732},{1202,732},{1292,725},{1295,727},{1293,727},{1294,728},{1293,728},{1293,726},{1292,726},{1291,726},{1290,726},{1300,715},{1300,716},{1299,716},{1288,719},{1286,719},{1286,720},{1289,719},{1287,720},{1293,720},{1289,720},{1290,719},{1288,720},{1292,720},{1291,721},{1292,721},{1290,720},{1295,725},{1294,725},{1293,725},{1296,725},{1296,726},{1295,728},{1227,729},{1226,729},{1225,730},{1226,730},{1224,730},{1223,730},{1204,730},{1203,730},{1222,730},{1221,730},{1220,730},{1202,730},{1201,730},{1222,731},{1205,730},{1229,730},{1229,731},{1205,731},{1193,731},{1194,731},{1196,731},{1196,730},{1195,731},{1197,730},{1198,731},{1199,730},{1198,730},{1200,731},{1203,731},{1204,731},{1227,731},{1226,731},{1200,730},{1202,731},{1228,731},{1225,731},{1224,731},{1199,731},{1201,731},{1201,732},{1285,733},{1286,733},{1287,733},{1198,732},{1200,732},{1199,732},{1196,732},{1205,741},{1112,743},{1111,743},{1129,746},{1129,747},{1130,747},{1130,746},{1162,743},{1161,743},{1131,742},{1127,741},{1115,743},{1120,744},{1121,746},{1134,744},{1160,743},{1159,743},{1161,744},{1162,744},{1309,557},{1324,557},{1330,554},{1314,547},{1311,543},{1305,541},{1304,539},{1314,537},{1314,532},{1329,532},{1336,535},{1340,534},{1346,536},{1350,533},{1347,529},{1348,526},{1346,524},{1333,527},{1333,522},{1328,522},{1323,518},{1314,517},{1315,514},{1311,512},{1306,507},{1310,507},{1309,504},{1313,504},{1315,501},{1313,500},{1315,499},{1314,497},{1315,494},{1310,490},{1302,489},{1295,494},{1291,493},{1287,495},{1288,496},{1278,496},{1275,498},{1276,502},{1273,503},{1273,507},{1269,511},{1270,513},{1268,513},{1269,514},{1265,519},{1266,521},{1263,522},{1264,523},{1260,526},{1261,528},{1257,529},{1257,530},{1256,531},{1251,532},{1249,531},{1235,536},{1209,533},{1200,528},{1201,526},{1207,525},{1206,523},{1208,522},{1207,520},{1201,517},{1193,506},{1191,504},{1194,503},{1193,501},{1186,499},{1179,495},{1162,500},{1154,499},{1150,502},{1143,503},{1135,500},{1128,495},{1114,494},{1108,491},{1086,493},{1080,496},{1078,502},{1087,505},{1081,508},{1086,511},{1084,513},{1086,515},{1094,513},{1100,516},{1107,515},{1121,523},{1124,522},{1125,523},{1136,525},{1143,530},{1138,534},{1138,536},{1150,540},{1157,544},{1167,545},{1169,548},{1168,551},{1164,554},{1159,554},{1158,561},{1157,563},{1158,564},{1154,567},{1157,570},{1168,567},{1173,569},{1176,568},{1177,570},{1176,572},{1178,573},{1174,573},{1171,578},{1174,579},{1174,581},{1176,582},{1175,583},{1182,584},{1187,582},{1191,582},{1191,585},{1188,586},{1189,588},{1187,591},{1189,593},{1188,594},{1183,596},{1179,594},{1172,595},{1171,596},{1172,598},{1171,599},{1173,600},{1166,604},{1157,605},{1147,602},{1142,597},{1136,596},{1135,593},{1126,591},{1125,589},{1124,591},{1126,593},{1123,593},{1123,595},{1116,592},{1107,593},{1102,590},{1098,590},{1095,593},{1093,593},{1098,600},{1097,602},{1101,606},{1100,607},{1103,607},{1102,608},{1105,611},{1098,613},{1099,615},{1096,618},{1100,623},{1093,625},{1096,628},{1095,629},{1094,633},{1090,636},{1081,636},{1083,638},{1088,639},{1085,643},{1079,642},{1057,646},{1059,649},{1062,649},{1060,650},{1070,655},{1064,657},{1065,660},{1061,662},{1061,664},{1063,665},{1062,668},{1055,670},{1068,673},{1069,689},{1061,694},{1065,696},{1079,697},{1082,699},{1092,698},{1095,700},{1093,702},{1103,704},{1101,706},{1126,711},{1127,712},{1120,714},{1120,721},{1111,724},{1113,725},{1106,728},{1109,730},{1102,734},{1111,736},{1108,737},{1113,739},{1128,737},{1130,738},{1128,740},{1135,736},{1132,734},{1135,733},{1135,732},{1141,734},{1135,735},{1156,737},{1187,736},{1190,735},{1185,734},{1184,732},{1228,730},{1232,729},{1237,731},{1235,732},{1238,732},{1234,734},{1235,734},{1233,734},{1233,735},{1235,736},{1234,737},{1240,736},{1244,738},{1258,734},{1263,736},{1265,734},{1270,734},{1271,735},{1279,735},{1278,734},{1295,730},{1296,729},{1294,729},{1292,730},{1291,730},{1292,727},{1295,726},{1288,725},{1295,724},{1296,723},{1294,723},{1296,722},{1294,722},{1296,721},{1285,720},{1290,717},{1293,718},{1291,720},{1296,717},{1289,716},{1292,716},{1295,713},{1304,709},{1309,710},{1311,707},{1318,710},{1321,710},{1322,709},{1320,708},{1321,704},{1331,703},{1332,702},{1330,700},{1335,697},{1322,690},{1327,689},{1331,684},{1331,680},{1319,670},{1300,665},{1301,662},{1316,657},{1316,654},{1323,649},{1322,646},{1327,646},{1328,642},{1321,637},{1332,633},{1332,631},{1339,631},{1342,628},{1353,626},{1358,622},{1351,617},{1354,616},{1349,614},{1340,618},{1329,616},{1331,615},{1330,613},{1332,609},{1325,607},{1317,597},{1318,592},{1321,591},{1324,588},{1325,588},{1326,586},{1324,585},{1321,585},{1322,583},{1320,582},{1321,580},{1315,582},{1320,576},{1317,576},{1315,572},{1311,572},{1315,571},{1318,567},{1317,567},{1317,565},{1315,566},{1311,564},{1309,559},{1136,733},{1137,733},{1138,733},{1139,733},{1234,732},{1233,732},{1233,733},{1188,733},{1187,733},{1188,734},{1137,734},{1138,734},{1283,734},{1281,734},{1282,734},{1187,734},{1232,734},{1266,734},{1280,734},{1276,735},{1253,736},{1233,736},{1232,736},{1256,736},{1232,735},{1257,735},{1258,735},{1267,734},{1267,735},{1278,735},{1277,735},{1264,734},{1279,734},{1280,735},{1269,734},{1269,735},{1235,737},{1248,737},{1240,738},{1239,738},{1237,737},{1236,737},{1246,738},{1238,737},{1243,738},{1240,737},{1248,739},{1238,738},{1241,738},{1239,737},{1252,737},{1241,737},{1258,736},{1259,737},{1259,735},{1257,736},{1234,736},{1257,737},{1150,736},{1151,736},{1254,736},{1238,736},{1239,736},{1233,739},{1232,739},{1232,740},{1233,740},{1245,739},{1246,739},{1232,738},{1231,739},{1243,739},{1249,739},{1250,739},{1244,739}}}, - {"America/Fortaleza",175,{{-439,-26},{-439,-25},{-457,-13},{-457,-12},{-456,-12},{-447,-33},{-448,-33},{-447,-32},{-446,-31},{-446,-32},{-447,-30},{-446,-30},{-446,-29},{-445,-29},{-447,-29},{-442,-28},{-402,-28},{-441,-28},{-446,-28},{-445,-27},{-445,-30},{-443,-28},{-422,-28},{-420,-27},{-423,-27},{-424,-27},{-421,-27},{-445,-26},{-437,-25},{-445,-25},{-445,-24},{-444,-25},{-439,-24},{-438,-25},{-434,-24},{-438,-24},{-435,-24},{-435,-25},{-438,-26},{-436,-25},{-350,-65},{-348,-75},{-351,-74},{-355,-75},{-356,-77},{-359,-78},{-364,-78},{-369,-83},{-371,-80},{-373,-80},{-372,-76},{-370,-75},{-372,-73},{-382,-79},{-387,-76},{-391,-79},{-397,-74},{-407,-74},{-406,-81},{-415,-89},{-417,-90},{-418,-93},{-423,-93},{-426,-96},{-435,-93},{-438,-94},{-437,-99},{-439,-104},{-451,-109},{-453,-108},{-456,-103},{-463,-102},{-467,-98},{-465,-95},{-471,-90},{-468,-85},{-465,-84},{-465,-81},{-466,-79},{-470,-80},{-476,-74},{-475,-73},{-477,-72},{-475,-70},{-474,-63},{-475,-55},{-483,-52},{-488,-54},{-476,-46},{-471,-39},{-466,-29},{-467,-27},{-464,-25},{-462,-19},{-463,-17},{-460,-11},{-460,-13},{-458,-12},{-458,-13},{-457,-11},{-457,-15},{-456,-13},{-455,-14},{-454,-13},{-456,-15},{-455,-15},{-453,-13},{-453,-18},{-452,-15},{-450,-16},{-449,-14},{-450,-17},{-448,-16},{-448,-18},{-447,-17},{-445,-18},{-445,-20},{-446,-20},{-448,-23},{-446,-24},{-445,-21},{-444,-23},{-447,-26},{-448,-32},{-444,-29},{-443,-25},{-440,-24},{-442,-29},{-436,-26},{-435,-26},{-434,-23},{-422,-27},{-414,-29},{-400,-29},{-385,-37},{-371,-49},{-367,-51},{-355,-52},{-444,-24},{-436,-24},{-437,-24},{-436,-23},{-446,-22},{-446,-21},{-437,-23},{-444,-21},{-444,-20},{-446,-19},{-447,-18},{-446,-18},{-448,-17},{-453,-16},{-454,-15},{-453,-15},{-448,-15},{-450,-15},{-451,-15},{-455,-13},{-454,-14},{-450,-13},{-449,-13},{-450,-14},{-451,-14},{-451,-13},{-448,-14},{-453,-17},{-452,-17},{-447,-16},{-459,-12},{-455,-12},{-458,-11},{-459,-11},{-456,-14},{-457,-14},{-456,-11}}}, - {"America/Kralendijk",10,{{-683,121},{-683,122},{-630,175},{-629,175},{-632,176},{-632,177},{-684,123},{-682,122},{-682,120},{-684,122}}}, - {"America/Yellowknife",705,{{-1239,694},{-1338,694},{-1338,696},{-1275,701},{-1275,702},{-1115,703},{-1353,687},{-1357,689},{-1358,689},{-1360,689},{-1359,689},{-1360,690},{-1359,690},{-1358,690},{-1356,693},{-1356,694},{-1361,690},{-1361,691},{-1310,691},{-1362,691},{-1363,691},{-1310,692},{-1363,692},{-1361,692},{-1360,691},{-1360,692},{-1362,692},{-1357,693},{-1338,693},{-1339,693},{-1341,693},{-1340,693},{-1355,694},{-1354,694},{-1353,693},{-1238,694},{-1315,693},{-1315,694},{-1314,694},{-1240,694},{-1340,694},{-1339,694},{-1353,694},{-1309,694},{-1308,694},{-1308,695},{-1353,695},{-1352,695},{-1319,695},{-1351,695},{-1306,694},{-1307,694},{-1355,695},{-1354,695},{-1357,695},{-1358,695},{-1256,695},{-1347,695},{-1348,695},{-1309,695},{-1313,695},{-1254,695},{-1336,695},{-1335,695},{-1355,696},{-1356,696},{-1354,696},{-1353,696},{-1349,697},{-1350,697},{-1348,697},{-1347,697},{-1289,697},{-1290,697},{-1342,697},{-1343,697},{-1291,697},{-1305,697},{-1305,698},{-1320,698},{-1323,698},{-1322,698},{-1344,698},{-1343,698},{-1319,698},{-1318,699},{-1317,699},{-1315,699},{-1311,700},{-1344,697},{-1345,697},{-1254,696},{-1340,696},{-1339,696},{-1310,695},{-1311,696},{-1314,696},{-1314,695},{-1307,696},{-1308,696},{-1342,696},{-1309,701},{-1299,701},{-1305,701},{-1304,701},{-1306,701},{-1307,701},{-1301,701},{-1302,701},{-1303,701},{-1298,703},{-1297,703},{-1298,702},{-1299,702},{-1243,736},{-1242,736},{-1241,736},{-1154,715},{-1257,720},{-1257,721},{-1192,715},{-1192,716},{-1191,716},{-1117,724},{-1118,723},{-1117,723},{-1118,724},{-1113,724},{-1112,724},{-1115,724},{-1114,724},{-1253,725},{-1100,725},{-1102,726},{-1101,726},{-1250,726},{-1252,725},{-1251,725},{-1112,725},{-1252,728},{-1112,727},{-1111,727},{-1140,727},{-1141,727},{-1180,728},{-1181,728},{-1100,730},{-1100,727},{-1102,727},{-1102,728},{-1107,730},{-1104,726},{-1105,726},{-1106,726},{-1251,726},{-1252,726},{-1103,726},{-1111,726},{-1142,726},{-1100,726},{-1103,727},{-1101,727},{-1149,706},{-1177,707},{-1178,707},{-1171,714},{-1160,714},{-1161,714},{-1163,714},{-1162,714},{-1175,715},{-1163,706},{-1164,706},{-1177,706},{-1111,752},{-1110,752},{-1140,754},{-1160,756},{-1159,756},{-1153,756},{-1153,757},{-1118,751},{-1117,751},{-1209,767},{-1211,767},{-1212,767},{-1208,767},{-1143,769},{-1137,769},{-1134,768},{-1148,768},{-1161,776},{-1160,776},{-1159,776},{-1158,777},{-1157,777},{-1156,778},{-1156,777},{-1145,777},{-1146,778},{-1104,778},{-1106,778},{-1107,778},{-1136,778},{-1133,776},{-1133,777},{-1132,776},{-1133,771},{-1132,771},{-1135,771},{-1137,772},{-1136,771},{-1139,771},{-1138,772},{-1182,774},{-1173,774},{-1173,775},{-1171,775},{-1172,775},{-1154,775},{-1225,758},{-1216,760},{-1211,758},{-1210,759},{-1208,759},{-1210,757},{-1213,758},{-1100,759},{-1118,758},{-1119,759},{-1115,759},{-1116,759},{-1120,758},{-1121,758},{-1119,758},{-1190,756},{-1194,756},{-1186,759},{-1174,761},{-1182,756},{-1125,705},{-1124,705},{-1229,760},{-1230,760},{-1227,761},{-1227,760},{-1228,761},{-1226,760},{-1140,763},{-1141,763},{-1229,763},{-1230,763},{-1230,764},{-1100,765},{-1100,762},{-1104,764},{-1105,764},{-1187,765},{-1188,765},{-1164,776},{-1153,773},{-1164,771},{-1157,769},{-1163,769},{-1159,767},{-1170,766},{-1169,763},{-1173,763},{-1180,764},{-1179,767},{-1177,768},{-1178,768},{-1184,767},{-1183,766},{-1189,765},{-1185,763},{-1189,763},{-1189,762},{-1190,761},{-1196,763},{-1195,762},{-1197,762},{-1195,761},{-1198,761},{-1195,760},{-1199,758},{-1205,758},{-1204,760},{-1207,760},{-1207,762},{-1210,761},{-1209,760},{-1219,760},{-1223,759},{-1227,759},{-1224,761},{-1225,762},{-1230,761},{-1224,764},{-1215,764},{-1205,768},{-1192,773},{-1170,773},{-1172,773},{-1166,774},{-1134,782},{-1135,782},{-1135,783},{-1139,783},{-1140,783},{-1142,783},{-1136,783},{-1137,783},{-1138,783},{-1239,697},{-1240,697},{-1244,699},{-1243,699},{-1283,699},{-1284,699},{-1284,700},{-1249,700},{-1248,700},{-1252,700},{-1251,700},{-1253,697},{-1254,697},{-1100,787},{-1100,783},{-1103,783},{-1133,783},{-1107,788},{-1122,786},{-1121,786},{-1134,783},{-1142,780},{-1135,778},{-1143,777},{-1151,780},{-1246,701},{-1247,701},{-1251,701},{-1250,702},{-1251,702},{-1278,702},{-1279,702},{-1126,702},{-1126,703},{-1129,703},{-1131,703},{-1130,703},{-1128,702},{-1127,703},{-1127,702},{-1250,701},{-1117,780},{-1100,781},{-1100,779},{-1109,779},{-1100,778},{-1102,775},{-1120,773},{-1132,775},{-1131,776},{-1133,778},{-1132,779},{-1130,781},{-1114,781},{-1198,741},{-1191,742},{-1190,741},{-1191,740},{-1190,740},{-1187,742},{-1174,742},{-1153,735},{-1191,726},{-1193,724},{-1202,722},{-1206,715},{-1217,715},{-1228,711},{-1232,711},{-1241,717},{-1248,718},{-1251,719},{-1253,720},{-1249,720},{-1252,720},{-1258,720},{-1260,720},{-1256,721},{-1258,721},{-1249,726},{-1251,729},{-1244,729},{-1249,731},{-1237,737},{-1242,739},{-1245,743},{-1248,743},{-1215,746},{-1196,742},{-1246,737},{-1247,737},{-1245,737},{-1244,739},{-1245,739},{-1189,740},{-1246,741},{-1197,741},{-1196,741},{-1246,742},{-1247,742},{-1195,742},{-1246,743},{-1247,743},{-1250,743},{-1251,743},{-1249,743},{-1146,765},{-1141,765},{-1139,762},{-1124,762},{-1125,761},{-1124,760},{-1117,759},{-1122,758},{-1114,758},{-1116,758},{-1112,755},{-1100,755},{-1100,748},{-1116,745},{-1132,744},{-1144,747},{-1128,750},{-1117,750},{-1109,752},{-1124,751},{-1123,752},{-1126,753},{-1128,751},{-1139,751},{-1138,753},{-1134,754},{-1140,755},{-1141,752},{-1144,753},{-1146,753},{-1143,752},{-1143,751},{-1150,750},{-1152,752},{-1157,750},{-1162,751},{-1160,751},{-1162,752},{-1177,752},{-1172,755},{-1160,755},{-1151,757},{-1172,756},{-1169,758},{-1148,759},{-1167,759},{-1164,760},{-1167,760},{-1166,761},{-1162,762},{-1148,762},{-1159,763},{-1200,678},{-1135,655},{-1116,655},{-1104,647},{-1020,643},{-1020,600},{-1240,600},{-1242,605},{-1246,607},{-1245,608},{-1246,610},{-1253,608},{-1259,609},{-1268,608},{-1269,611},{-1271,611},{-1270,612},{-1272,615},{-1278,616},{-1285,621},{-1293,622},{-1293,624},{-1292,625},{-1295,626},{-1298,629},{-1296,631},{-1302,632},{-1298,635},{-1303,637},{-1301,639},{-1309,640},{-1312,644},{-1319,644},{-1317,645},{-1326,648},{-1323,651},{-1328,652},{-1322,656},{-1326,659},{-1323,660},{-1336,660},{-1336,663},{-1338,663},{-1336,666},{-1341,670},{-1338,670},{-1361,670},{-1362,676},{-1364,677},{-1364,689},{-1351,687},{-1356,691},{-1359,693},{-1356,692},{-1351,693},{-1345,694},{-1344,695},{-1346,695},{-1344,696},{-1341,695},{-1337,695},{-1342,693},{-1330,694},{-1329,697},{-1326,696},{-1323,697},{-1327,697},{-1326,697},{-1320,697},{-1314,699},{-1314,700},{-1312,698},{-1309,700},{-1310,700},{-1310,701},{-1304,702},{-1300,700},{-1294,701},{-1310,696},{-1320,695},{-1320,692},{-1319,693},{-1318,693},{-1317,694},{-1320,694},{-1319,694},{-1316,693},{-1314,693},{-1312,694},{-1313,693},{-1312,693},{-1313,696},{-1311,694},{-1311,693},{-1311,695},{-1312,696},{-1310,694},{-1309,693},{-1310,693},{-1309,691},{-1303,697},{-1289,700},{-1292,697},{-1282,699},{-1283,701},{-1278,701},{-1281,701},{-1274,701},{-1273,702},{-1282,704},{-1280,706},{-1272,703},{-1268,700},{-1270,699},{-1268,699},{-1263,695},{-1254,693},{-1253,694},{-1255,694},{-1251,694},{-1256,694},{-1251,695},{-1255,696},{-1248,697},{-1253,698},{-1246,700},{-1244,700},{-1247,702},{-1243,700},{-1245,700},{-1244,698},{-1245,697},{-1245,694},{-1244,693},{-1234,694},{-1230,698},{-1210,697},{-1220,697},{-1220,685},{-1334,683},{-1336,683},{-1338,684},{-1337,683},{-1117,703},{-1116,703},{-1126,705},{-1166,705},{-1167,705},{-1165,705},{-1282,705},{-1281,705},{-1155,706},{-1154,706},{-1173,706},{-1174,706},{-1173,705},{-1158,706},{-1157,706},{-1161,706},{-1160,706},{-1169,705},{-1155,705},{-1156,705},{-1161,705},{-1162,705},{-1163,705},{-1164,705},{-1168,705},{-1157,705},{-1156,706},{-1158,705},{-1118,703},{-1119,703},{-1283,706},{-1282,706},{-1281,706},{-1283,705},{-1167,706},{-1172,705},{-1168,706},{-1171,705},{-1159,706},{-1159,705},{-1132,703},{-1128,703},{-1133,703},{-1120,703},{-1123,704},{-1153,706},{-1153,733},{-1145,734},{-1140,732},{-1139,728},{-1146,726},{-1134,727},{-1136,728},{-1130,730},{-1114,725},{-1119,723},{-1116,723},{-1113,723},{-1111,723},{-1107,726},{-1100,724},{-1100,700},{-1123,700},{-1123,699},{-1124,698},{-1129,698},{-1130,700},{-1172,700},{-1169,697},{-1170,697},{-1174,700},{-1145,703},{-1125,702},{-1114,703},{-1138,707},{-1176,706},{-1184,710},{-1150,715},{-1182,714},{-1183,715},{-1177,715},{-1180,716},{-1177,717},{-1189,716},{-1191,717},{-1186,722},{-1181,722},{-1185,724},{-1184,725},{-1173,729}}}, - {"Europe/Jersey",4,{{-20,492},{-22,492},{-23,493},{-21,493}}}, - {"Asia/Ust-Nera",130,{{1460,434},{1462,434},{1459,434},{1459,435},{1461,434},{1463,436},{1463,437},{1464,436},{1461,435},{1462,435},{1470,446},{1470,447},{1509,465},{1507,467},{1508,467},{1467,437},{1468,437},{1468,438},{1466,438},{1469,438},{1489,454},{1479,450},{1477,450},{1472,446},{1469,445},{1472,447},{1471,448},{1479,452},{1479,454},{1481,452},{1487,455},{1489,455},{1500,458},{1494,456},{1502,462},{1506,462},{1508,464},{1508,465},{1458,440},{1455,437},{1454,437},{1461,445},{1466,445},{1518,468},{1517,469},{1523,472},{1520,469},{1525,473},{1524,474},{1525,474},{1528,475},{1529,475},{1531,478},{1531,477},{1530,477},{1530,478},{1533,481},{1532,483},{1533,483},{1532,480},{1532,481},{1540,487},{1541,489},{1542,489},{1542,488},{1535,490},{1546,491},{1545,491},{1545,492},{1539,490},{1540,490},{1540,489},{1539,489},{1548,494},{1546,493},{1548,496},{1549,496},{1545,498},{1544,497},{1544,498},{1550,502},{1557,509},{1555,508},{1555,509},{1556,509},{1463,641},{1455,638},{1456,637},{1452,632},{1455,625},{1451,625},{1452,623},{1447,621},{1445,619},{1440,617},{1439,620},{1436,619},{1436,620},{1432,621},{1430,619},{1424,619},{1422,621},{1416,621},{1413,624},{1407,626},{1406,624},{1403,624},{1396,629},{1397,634},{1406,636},{1405,637},{1406,640},{1400,644},{1404,645},{1394,650},{1400,655},{1408,656},{1443,649},{1449,645},{1457,645},{1554,500},{1552,501},{1552,503},{1556,504},{1561,508},{1562,505},{1564,506},{1563,506},{1562,507},{1565,509}}}, - {"Africa/Asmara",142,{{402,151},{405,150},{431,127},{401,152},{400,152},{413,152},{413,153},{402,152},{403,152},{401,153},{402,153},{411,154},{407,154},{406,150},{402,150},{405,151},{403,150},{403,151},{404,150},{401,151},{429,128},{430,128},{429,129},{428,129},{430,129},{430,130},{428,130},{429,130},{426,132},{422,136},{421,137},{409,147},{409,148},{419,139},{420,139},{408,147},{408,148},{407,149},{408,149},{397,155},{398,154},{407,155},{408,155},{404,155},{403,155},{412,146},{417,139},{424,132},{425,132},{428,128},{427,124},{424,125},{408,142},{402,145},{396,146},{393,144},{391,146},{385,144},{379,149},{376,141},{373,144},{370,143},{365,143},{364,152},{370,163},{370,171},{374,170},{375,173},{383,176},{386,180},{389,174},{392,161},{397,151},{398,151},{399,155},{398,155},{409,155},{400,155},{410,156},{408,157},{407,157},{399,157},{406,157},{405,157},{405,158},{401,158},{407,158},{404,158},{397,159},{396,159},{402,159},{403,159},{401,159},{401,160},{400,159},{400,160},{396,160},{399,159},{406,159},{403,158},{399,158},{406,158},{405,159},{404,159},{403,160},{399,160},{399,161},{395,161},{395,160},{394,162},{398,161},{400,161},{400,162},{401,161},{402,161},{402,160},{402,162},{406,156},{402,163},{398,163},{397,163},{396,164},{396,163},{395,163},{401,165},{402,165},{391,166},{392,166},{393,166},{399,163},{399,164},{401,162},{407,156},{405,156},{408,156},{406,155},{402,157},{402,156},{404,156},{400,156},{401,156},{400,157}}}, - {"Asia/Irkutsk",184,{{1157,570},{1154,566},{1158,564},{1157,563},{1158,561},{1159,554},{1164,554},{1168,551},{1169,548},{1167,545},{1157,544},{1150,540},{1138,536},{1138,534},{1143,530},{1136,525},{1125,523},{1124,522},{1121,523},{1107,515},{1100,516},{1094,513},{1086,515},{1084,513},{1086,511},{1081,508},{1087,505},{1080,503},{1077,500},{1071,500},{1068,503},{1054,505},{1041,502},{1029,503},{1023,506},{1022,513},{1021,514},{1000,518},{986,523},{986,524},{989,527},{989,529},{992,529},{990,530},{991,531},{983,531},{983,532},{976,534},{973,536},{969,537},{966,536},{957,543},{961,546},{966,545},{967,549},{966,550},{969,553},{968,558},{971,561},{974,560},{976,562},{976,564},{979,564},{978,568},{975,568},{976,570},{973,570},{979,578},{990,577},{994,578},{997,581},{1000,581},{1004,575},{1007,574},{1010,575},{1008,579},{1010,579},{1011,581},{1025,587},{1024,591},{1025,592},{1033,593},{1034,590},{1040,588},{1039,587},{1042,588},{1044,586},{1048,587},{1048,589},{1054,591},{1052,595},{1050,595},{1048,597},{1055,598},{1055,603},{1047,604},{1045,608},{1046,609},{1046,611},{1050,612},{1048,613},{1058,616},{1059,617},{1059,618},{1064,620},{1064,622},{1063,623},{1068,626},{1065,627},{1061,631},{1067,634},{1065,635},{1068,638},{1067,640},{1076,639},{1077,640},{1083,640},{1082,642},{1080,642},{1084,643},{1088,639},{1083,638},{1081,636},{1090,636},{1094,634},{1095,629},{1097,628},{1093,625},{1100,623},{1096,618},{1099,615},{1098,613},{1105,611},{1103,607},{1100,607},{1101,606},{1097,602},{1098,600},{1095,596},{1093,595},{1096,591},{1102,590},{1107,593},{1116,592},{1123,595},{1123,593},{1126,593},{1124,591},{1125,589},{1126,591},{1135,593},{1136,596},{1142,597},{1147,602},{1157,605},{1166,604},{1173,600},{1171,599},{1172,598},{1171,596},{1172,595},{1179,594},{1183,596},{1189,593},{1187,592},{1189,588},{1188,586},{1191,585},{1191,582},{1186,582},{1182,584},{1177,584},{1175,583},{1176,582},{1174,581},{1174,579},{1171,578},{1174,573},{1178,573},{1176,572},{1177,570},{1176,568},{1173,569},{1168,567}}}, - {"America/Tegucigalpa",45,{{-876,132},{-877,133},{-876,133},{-876,134},{-875,133},{-875,134},{-874,134},{-870,161},{-869,161},{-862,164},{-864,164},{-866,163},{-861,164},{-839,174},{-840,174},{-859,164},{-860,164},{-858,165},{-859,165},{-868,137},{-867,133},{-869,133},{-870,130},{-873,130},{-873,131},{-878,134},{-878,139},{-885,139},{-893,144},{-892,146},{-892,151},{-880,159},{-864,158},{-859,159},{-860,160},{-843,158},{-832,150},{-845,146},{-849,148},{-852,146},{-852,143},{-858,140},{-857,138},{-860,141},{-863,138}}}, - {"Europe/Zaporozhye",32,{{342,475},{349,475},{348,481},{352,481},{360,481},{361,478},{366,478},{367,476},{372,475},{369,472},{371,470},{368,466},{366,468},{364,467},{362,465},{361,465},{362,466},{359,467},{355,464},{352,461},{350,461},{352,462},{354,464},{352,465},{351,463},{350,465},{348,465},{346,467},{348,469},{346,470},{345,473},{343,473}}}, - {"Asia/Dhaka",245,{{906,235},{906,236},{923,206},{923,207},{924,207},{906,232},{905,231},{905,232},{906,233},{907,233},{907,234},{902,234},{903,234},{905,234},{904,234},{905,233},{906,234},{902,232},{901,233},{903,233},{902,233},{904,233},{905,235},{904,236},{905,236},{907,235},{907,236},{892,240},{891,240},{898,237},{898,238},{899,237},{897,239},{892,239},{893,239},{894,239},{897,238},{896,238},{895,238},{902,238},{901,238},{901,239},{902,235},{907,237},{906,237},{901,236},{903,237},{907,220},{907,221},{905,220},{905,221},{908,236},{904,237},{902,237},{920,216},{920,217},{890,219},{891,219},{891,217},{891,218},{904,218},{905,218},{892,217},{893,217},{893,216},{894,217},{919,215},{919,217},{920,215},{919,216},{919,218},{904,217},{918,217},{918,219},{919,219},{898,218},{911,221},{896,218},{896,217},{893,218},{894,219},{898,219},{897,219},{896,219},{895,219},{895,220},{899,222},{899,223},{918,223},{918,222},{903,223},{903,224},{910,222},{905,222},{906,222},{908,222},{909,222},{906,223},{910,223},{912,224},{906,224},{907,224},{906,225},{910,224},{912,223},{911,222},{910,225},{911,225},{915,224},{914,224},{914,227},{915,225},{912,225},{907,225},{906,226},{910,226},{913,226},{912,226},{911,226},{911,227},{905,227},{905,228},{906,228},{913,227},{908,227},{906,221},{908,228},{909,228},{910,227},{913,228},{912,227},{906,227},{903,218},{905,219},{900,218},{900,220},{901,220},{901,219},{900,219},{899,219},{904,220},{908,221},{906,220},{906,219},{907,219},{903,219},{904,219},{902,219},{903,220},{904,221},{903,221},{910,221},{909,221},{905,226},{907,228},{909,224},{903,227},{900,225},{901,226},{900,226},{900,227},{898,222},{897,218},{889,230},{890,232},{887,233},{888,235},{886,236},{888,240},{887,243},{881,245},{880,247},{881,249},{883,249},{884,252},{889,252},{890,253},{888,255},{885,255},{881,258},{882,261},{885,264},{883,265},{884,266},{887,264},{887,263},{890,262},{889,264},{891,264},{894,260},{896,260},{897,262},{899,259},{899,253},{904,251},{921,252},{925,249},{923,248},{919,241},{918,242},{914,241},{912,237},{913,231},{914,233},{916,229},{918,231},{920,237},{923,237},{927,213},{924,215},{922,213},{920,212},{919,224},{920,224},{921,224},{921,225},{920,225},{914,228},{915,229},{913,229},{907,229},{906,231},{908,237},{902,239},{899,240},{900,238},{900,237},{897,240},{893,240},{903,231},{904,223},{901,218},{903,222},{903,225},{904,228},{906,229},{903,230},{904,230},{904,229},{903,229},{906,230},{907,230},{905,229},{905,230},{904,231}}}, - {"Pacific/Fiji",197,{{-1795,-174},{-1787,-207},{-1782,-198},{-1787,-206},{1797,-191},{1798,-191},{1798,-192},{1797,-192},{-1784,-192},{1782,-191},{-1798,-189},{-1798,-190},{-1799,-190},{-1790,-190},{-1790,-189},{-1789,-189},{-1789,-190},{-1788,-190},{-1785,-190},{1781,-192},{-1784,-191},{-1786,-191},{-1785,-192},{-1786,-192},{-1786,-188},{-1786,-189},{-1787,-188},{1785,-188},{1785,-189},{-1786,-187},{-1785,-187},{-1785,-186},{1799,-186},{1799,-187},{1798,-186},{-1785,-184},{-1784,-184},{1776,-185},{1777,-186},{-1784,-190},{-1784,-189},{-1787,-182},{-1788,-183},{-1788,-182},{1786,-181},{1785,-181},{1784,-189},{1785,-190},{1780,-191},{1782,-190},{-1785,-189},{-1787,-183},{-1790,-180},{-1791,-180},{1794,-178},{1794,-179},{1794,-181},{1793,-181},{1792,-180},{1793,-179},{1786,-179},{1774,-178},{1785,-182},{1791,-178},{1792,-178},{-1793,-177},{-1793,-178},{1772,-178},{-1788,-177},{1787,-177},{1788,-178},{1787,-178},{1772,-177},{1771,-177},{1793,-177},{1793,-176},{1771,-176},{1787,-176},{-1787,-175},{1773,-175},{1788,-177},{1788,-176},{1790,-176},{1790,-177},{1781,-184},{1782,-184},{1780,-184},{-1793,-184},{1791,-171},{1773,-171},{1772,-172},{-1789,-172},{-1790,-172},{1769,-172},{1769,-171},{1786,-166},{1800,-166},{1799,-167},{1799,-166},{1787,-166},{1800,-165},{-1800,-165},{-1799,-164},{-1799,-165},{-1797,-165},{1791,-164},{1793,-164},{1793,-163},{1794,-163},{1794,-164},{1796,-163},{1796,-162},{1791,-162},{-1792,-161},{-1791,-161},{-1795,-159},{-1800,-157},{-1799,-157},{-1799,-158},{1771,-125},{1770,-125},{1798,-162},{1797,-162},{1799,-162},{-1800,-161},{-1799,-161},{-1800,-162},{1800,-170},{1799,-170},{1800,-168},{-1800,-170},{-1800,-168},{-1799,-167},{-1798,-168},{1784,-168},{-1797,-167},{-1791,-173},{-1792,-173},{-1792,-172},{-1795,-173},{-1795,-172},{1783,-174},{1786,-176},{1785,-180},{1784,-182},{1779,-183},{1773,-181},{1773,-179},{1775,-175},{-1798,-167},{-1797,-168},{1775,-169},{1790,-169},{1774,-170},{1773,-170},{1773,-169},{1774,-169},{1791,-168},{1783,-168},{1776,-167},{1775,-168},{1774,-168},{-1793,-170},{1789,-166},{1789,-165},{1800,-161},{1795,-167},{1799,-165},{1799,-168},{1793,-168},{1792,-167},{1791,-169},{1789,-168},{1787,-170},{1785,-168},{1782,-173},{-1788,-173},{1790,-174},{1790,-175},{-1792,-174},{-1791,-174},{-1791,-175},{-1792,-175},{1789,-174},{-1790,-173},{-1789,-173},{-1790,-174},{1788,-174},{1771,-174},{1772,-174},{-1789,-174},{1771,-173},{1772,-173},{1794,-172},{1794,-173},{1794,-174},{1781,-173}}}, - {"Europe/Athens",480,{{267,363},{268,363},{238,378},{257,349},{241,348},{240,349},{241,349},{262,353},{262,354},{262,350},{262,349},{261,350},{246,350},{259,352},{263,352},{263,353},{264,353},{271,354},{271,356},{272,358},{272,355},{262,359},{296,361},{296,362},{277,362},{233,359},{233,358},{264,361},{272,359},{268,359},{295,362},{269,354},{270,354},{269,353},{268,354},{269,355},{239,355},{252,355},{252,354},{278,365},{278,366},{279,366},{272,366},{271,366},{231,362},{229,362},{229,364},{231,363},{252,362},{252,363},{275,362},{276,362},{278,363},{277,363},{282,365},{281,361},{278,359},{258,363},{236,356},{237,355},{237,357},{238,355},{242,356},{241,355},{243,354},{250,354},{258,353},{258,351},{247,349},{247,351},{244,352},{236,352},{273,365},{259,363},{275,364},{267,364},{274,364},{273,364},{271,371},{271,373},{272,369},{271,369},{271,370},{272,370},{271,367},{272,367},{268,376},{194,398},{194,399},{196,399},{195,398},{240,391},{239,391},{241,391},{235,391},{236,392},{238,391},{237,391},{202,391},{202,392},{203,391},{229,375},{231,392},{241,390},{201,392},{201,393},{232,392},{235,392},{234,392},{239,392},{240,392},{240,393},{258,392},{242,395},{250,395},{250,396},{251,395},{241,393},{241,394},{243,393},{243,394},{242,394},{252,399},{237,401},{238,402},{233,377},{240,403},{239,403},{239,404},{251,400},{256,405},{257,404},{254,405},{247,408},{248,407},{246,406},{246,408},{251,410},{199,397},{198,397},{201,394},{196,398},{254,400},{253,398},{253,399},{250,398},{233,378},{232,378},{234,377},{235,377},{234,378},{236,378},{264,376},{265,376},{266,376},{265,375},{266,375},{235,375},{235,376},{247,376},{240,376},{239,376},{239,377},{240,377},{264,377},{262,376},{260,375},{261,376},{213,384},{213,383},{211,383},{211,384},{265,365},{264,365},{264,366},{265,366},{250,377},{252,376},{253,376},{252,375},{244,376},{243,375},{243,377},{268,377},{266,377},{271,378},{269,376},{241,377},{241,378},{242,377},{263,385},{260,384},{258,386},{262,386},{260,382},{259,383},{242,382},{243,380},{241,382},{231,386},{231,387},{207,387},{208,387},{205,381},{204,383},{204,382},{203,382},{206,385},{208,381},{212,383},{230,382},{207,383},{207,385},{211,385},{210,385},{208,385},{214,383},{221,384},{210,384},{210,377},{208,377},{206,379},{207,379},{250,378},{249,377},{247,380},{250,379},{245,379},{236,379},{235,379},{234,380},{235,380},{242,380},{207,386},{208,386},{242,386},{209,385},{209,386},{210,387},{250,366},{245,381},{246,382},{245,380},{242,381},{241,384},{237,384},{232,388},{228,389},{233,390},{236,388},{242,387},{243,382},{262,385},{255,386},{255,385},{256,385},{256,386},{246,387},{246,388},{206,388},{207,389},{207,388},{205,386},{245,388},{244,388},{243,388},{244,389},{231,390},{245,390},{247,388},{263,390},{261,391},{263,392},{260,391},{259,393},{263,394},{266,390},{265,391},{265,390},{230,365},{229,365},{257,368},{258,368},{257,366},{261,365},{261,366},{262,365},{262,366},{270,366},{263,366},{270,365},{263,365},{254,364},{254,363},{254,365},{255,364},{253,364},{253,365},{258,364},{259,364},{257,364},{218,367},{217,368},{217,367},{219,367},{247,367},{246,368},{247,368},{242,368},{243,368},{239,368},{239,369},{255,368},{254,368},{255,369},{257,369},{245,368},{259,369},{262,369},{247,369},{256,369},{216,371},{216,370},{215,371},{257,371},{232,372},{269,371},{268,371},{268,372},{269,372},{245,372},{245,371},{244,371},{258,371},{210,373},{210,372},{231,372},{231,373},{232,373},{246,373},{233,373},{256,374},{268,373},{267,373},{266,373},{265,374},{266,374},{234,373},{235,374},{236,374},{235,373},{267,374},{268,374},{244,373},{244,374},{244,375},{245,374},{253,374},{252,374},{217,369},{217,370},{251,370},{250,369},{250,370},{260,369},{261,369},{269,369},{235,369},{256,370},{247,370},{246,370},{248,370},{263,370},{251,369},{251,371},{270,369},{270,370},{269,370},{264,370},{265,370},{254,369},{253,371},{255,372},{256,371},{252,370},{249,366},{248,367},{251,366},{251,367},{252,367},{254,366},{253,368},{254,367},{243,366},{244,368},{245,367},{274,369},{270,367},{269,367},{269,375},{270,375},{270,374},{230,374},{255,375},{255,374},{239,375},{254,375},{253,375},{249,374},{249,375},{250,374},{232,380},{230,379},{231,375},{227,376},{232,365},{226,368},{225,364},{221,370},{219,370},{217,374},{211,379},{214,382},{216,381},{219,383},{229,379},{232,382},{227,384},{226,383},{224,384},{215,383},{213,385},{211,386},{208,390},{212,389},{211,390},{207,390},{200,397},{202,396},{204,398},{203,400},{207,401},{208,404},{210,406},{210,409},{216,409},{221,412},{227,411},{228,413},{243,416},{253,412},{261,414},{261,417},{266,416},{266,414},{263,413},{264,410},{261,407},{237,408},{240,405},{244,402},{237,404},{240,399},{234,403},{234,402},{238,399},{234,400},{233,402},{228,405},{230,406},{226,405},{226,400},{232,391},{231,391},{229,394},{228,392},{225,389},{233,386},{233,385},{236,380}}}, - {"Pacific/Tarawa",68,{{1768,-27},{1768,-26},{1760,-25},{1756,-20},{1755,-20},{1756,-19},{1755,-18},{1751,-15},{1751,-16},{1750,-15},{1750,-14},{1749,-14},{1748,-13},{1742,-5},{1729,13},{1729,14},{1760,-14},{1759,-13},{1747,-12},{1747,-11},{1748,-12},{1695,-9},{1695,-8},{1696,-9},{1745,-8},{1744,-6},{1745,-7},{1743,-6},{1743,-5},{1730,13},{1735,2},{1736,2},{1734,2},{1734,3},{1736,1},{1739,3},{1738,3},{1739,4},{1738,4},{1739,5},{1738,5},{1765,-14},{1764,-13},{1730,9},{1730,8},{1730,10},{1732,14},{1731,14},{1730,15},{1730,16},{1730,17},{1731,18},{1729,19},{1728,19},{1733,20},{1733,21},{1728,30},{1728,31},{1729,31},{1727,31},{1730,32},{1729,20},{1727,33},{1727,32},{1730,33},{1730,34},{1731,10},{1731,9}}}, - {"America/Resolute",14,{{-963,753},{-951,747},{-953,756},{-944,756},{-937,754},{-935,753},{-936,752},{-934,749},{-934,747},{-947,746},{-966,750},{-965,752},{-958,754},{-961,754}}}, - {"Africa/Brazzaville",63,{{112,-40},{113,-37},{115,-35},{119,-37},{120,-34},{119,-32},{121,-30},{116,-28},{116,-23},{118,-25},{120,-23},{125,-24},{124,-19},{127,-19},{130,-23},{135,-24},{138,-21},{139,-24},{141,-25},{144,-19},{145,-6},{139,-2},{139,2},{141,5},{144,6},{145,9},{143,13},{140,14},{132,12},{133,22},{146,22},{149,20},{158,19},{161,17},{161,22},{165,28},{166,35},{175,37},{182,35},{185,36},{186,32},{181,22},{181,15},{179,10},{180,4},{178,1},{177,-5},{173,-10},{168,-13},{162,-22},{162,-33},{159,-39},{156,-40},{147,-49},{144,-49},{144,-43},{140,-45},{137,-44},{137,-47},{134,-49},{128,-44},{120,-50},{117,-45}}}, - {"Africa/Libreville",48,{{88,-9},{94,8},{139,-1},{139,-2},{145,-7},{145,-17},{141,-25},{139,-24},{138,-21},{135,-24},{130,-23},{128,-19},{124,-19},{125,-24},{120,-23},{118,-25},{116,-23},{116,-28},{121,-30},{119,-32},{120,-34},{119,-37},{115,-35},{113,-37},{112,-40},{96,-24},{87,-6},{88,-8},{93,-5},{94,4},{95,1},{97,1},{99,2},{95,3},{93,5},{95,7},{96,5},{97,11},{100,9},{113,10},{114,23},{133,23},{132,12},{138,14},{143,13},{145,8},{139,3},{96,3}}}, - {"Atlantic/St_Helena",18,{{-100,-403},{-99,-403},{-99,-404},{-125,-374},{-127,-373},{-126,-373},{-123,-371},{-122,-371},{-123,-372},{-124,-371},{-57,-159},{-56,-160},{-57,-160},{-58,-160},{-143,-79},{-143,-80},{-144,-80},{-144,-79}}}, - {"Europe/Samara",81,{{501,545},{509,543},{510,546},{514,547},{519,545},{521,543},{524,545},{525,544},{522,543},{525,541},{521,535},{522,531},{517,529},{517,527},{515,527},{514,521},{508,518},{507,519},{502,520},{502,521},{497,523},{496,524},{495,523},{492,525},{489,524},{487,526},{484,527},{486,529},{482,530},{479,534},{484,535},{483,537},{486,537},{485,538},{500,538},{500,540},{502,540},{503,543},{544,564},{540,560},{533,559},{532,559},{536,562},{533,563},{533,561},{531,561},{529,564},{531,565},{528,565},{530,564},{526,563},{528,562},{527,560},{522,561},{522,559},{514,559},{517,561},{514,561},{511,565},{515,569},{513,569},{511,574},{519,576},{519,580},{517,582},{520,585},{538,584},{541,580},{542,577},{540,576},{543,575},{541,573},{543,573},{543,571},{544,570},{541,570},{540,567},{538,568},{538,566},{541,567},{540,566}}}, - {"America/Adak",152,{{-1789,514},{-1789,513},{-1790,513},{-1790,514},{-1783,515},{-1790,516},{-1791,516},{-1791,513},{-1790,512},{-1791,512},{-1789,516},{-1788,516},{-1787,515},{-1788,515},{-1788,518},{-1787,518},{-1789,518},{-1786,516},{-1787,516},{1796,520},{1798,519},{1795,519},{1795,520},{1795,514},{1792,514},{1786,516},{1789,516},{-1761,518},{-1765,517},{-1781,519},{-1778,518},{-1776,519},{-1779,516},{-1781,517},{-1779,518},{-1782,519},{-1766,517},{-1766,520},{-1764,517},{-1770,516},{-1769,518},{-1767,518},{-1768,520},{-1771,519},{-1771,517},{-1777,517},{-1772,518},{-1768,518},{-1764,518},{-1764,519},{-1763,519},{-1763,517},{1784,519},{1785,520},{1786,520},{1785,519},{-1755,522},{-1725,522},{-1726,524},{-1723,523},{-1751,522},{-1759,520},{-1713,524},{-1713,525},{-1712,525},{-1712,524},{-1712,526},{-1711,526},{1741,527},{1742,527},{1740,527},{-1708,525},{-1707,527},{-1706,527},{-1706,526},{-1700,529},{-1701,529},{-1698,531},{-1697,531},{-1698,530},{-1697,529},{-1697,530},{-1701,527},{-1702,527},{-1702,528},{-1701,528},{1739,528},{1739,527},{-1700,528},{-1699,529},{-1697,528},{1733,529},{1734,528},{1729,527},{1725,529},{1760,523},{1759,523},{1759,524},{1760,524},{1734,524},{1738,525},{1737,524},{1782,518},{1783,518},{1784,518},{-1760,518},{-1762,518},{-1762,519},{-1760,519},{-1761,519},{-1762,520},{-1757,519},{-1758,519},{-1759,519},{-1758,520},{-1760,520},{-1757,520},{-1756,520},{-1761,520},{1783,520},{1784,520},{1783,519},{1782,520},{1781,520},{1776,520},{1777,520},{1777,519},{1776,521},{1776,519},{1772,519},{1775,520},{-1754,520},{-1755,520},{-1760,521},{-1762,521},{-1761,521},{-1740,521},{-1735,522},{-1730,521},{-1735,520},{-1745,520},{-1744,520},{-1750,520},{-1751,520},{-1753,520},{-1745,521},{-1742,523},{-1745,523},{-1743,524},{-1740,523},{-1742,522},{-1741,521}}}, - {"America/Argentina/Jujuy",25,{{-672,-228},{-667,-222},{-663,-221},{-662,-218},{-658,-221},{-652,-221},{-653,-226},{-652,-229},{-650,-230},{-649,-235},{-647,-234},{-644,-236},{-642,-235},{-642,-242},{-646,-246},{-648,-245},{-649,-246},{-655,-244},{-660,-239},{-660,-235},{-663,-234},{-665,-242},{-669,-241},{-672,-238},{-670,-230}}}, - {"Africa/Sao_Tome",8,{{74,17},{74,16},{73,16},{65,0},{65,3},{67,4},{68,2},{73,14}}}, - {"Europe/Bratislava",26,{{171,481},{168,484},{170,488},{177,489},{186,495},{191,494},{195,496},{198,494},{198,492},{201,492},{203,494},{209,493},{216,494},{226,491},{221,484},{217,484},{215,486},{205,485},{203,483},{199,481},{196,482},{195,481},{188,480},{189,478},{187,478},{178,477}}}, - {"America/Lima",126,{{-769,-123},{-772,-121},{-765,-139},{-765,-138},{-764,-138},{-764,-137},{-762,-143},{-753,-153},{-785,-94},{-784,-94},{-785,-93},{-787,-90},{-786,-91},{-812,-52},{-808,-65},{-809,-64},{-808,-64},{-807,-70},{-807,-69},{-795,-78},{-777,-120},{-777,-119},{-773,-121},{-766,-128},{-769,-124},{-696,-173},{-695,-175},{-698,-177},{-698,-181},{-704,-183},{-714,-177},{-715,-173},{-752,-154},{-763,-142},{-764,-139},{-763,-139},{-762,-134},{-768,-123},{-773,-115},{-777,-113},{-777,-109},{-782,-101},{-788,-86},{-795,-77},{-797,-71},{-800,-67},{-811,-60},{-811,-58},{-808,-58},{-808,-55},{-811,-50},{-813,-47},{-813,-45},{-808,-37},{-802,-34},{-802,-39},{-805,-41},{-803,-42},{-804,-44},{-801,-43},{-798,-45},{-796,-44},{-793,-50},{-790,-50},{-786,-45},{-783,-34},{-781,-35},{-782,-34},{-778,-30},{-766,-26},{-755,-15},{-754,-10},{-752,-10},{-752,-5},{-756,-3},{-756,-1},{-752,0},{-748,-2},{-744,-6},{-743,-10},{-736,-13},{-735,-17},{-731,-18},{-732,-23},{-729,-25},{-721,-25},{-717,-21},{-714,-24},{-708,-22},{-700,-27},{-707,-38},{-702,-39},{-700,-44},{-706,-41},{-709,-44},{-719,-45},{-728,-51},{-732,-60},{-731,-65},{-737,-68},{-737,-73},{-740,-74},{-740,-75},{-737,-78},{-738,-79},{-735,-83},{-729,-90},{-732,-94},{-724,-95},{-722,-100},{-712,-100},{-705,-94},{-706,-110},{-696,-109},{-687,-125},{-690,-129},{-689,-135},{-691,-137},{-688,-142},{-694,-148},{-691,-153},{-694,-156},{-692,-161},{-688,-163},{-779,-115},{-778,-115}}}, - {"America/Toronto",278,{{-893,481},{-876,487},{-876,488},{-875,488},{-875,487},{-827,417},{-827,418},{-826,418},{-892,481},{-815,523},{-823,531},{-822,531},{-876,560},{-876,561},{-875,560},{-882,489},{-881,489},{-880,489},{-817,460},{-818,460},{-817,461},{-816,461},{-816,460},{-815,461},{-847,466},{-847,467},{-845,469},{-844,469},{-847,473},{-848,473},{-858,473},{-858,474},{-848,474},{-849,474},{-849,475},{-858,477},{-859,477},{-856,477},{-857,477},{-894,481},{-860,481},{-861,481},{-892,482},{-891,482},{-893,482},{-890,482},{-886,483},{-886,484},{-887,484},{-885,484},{-885,485},{-884,485},{-889,485},{-888,485},{-883,485},{-883,486},{-882,486},{-881,487},{-881,486},{-864,487},{-866,487},{-874,488},{-878,488},{-880,487},{-879,487},{-870,487},{-870,486},{-871,486},{-871,487},{-877,488},{-876,489},{-794,436},{-775,439},{-803,426},{-802,426},{-766,439},{-777,440},{-767,441},{-768,441},{-766,442},{-763,442},{-764,442},{-762,442},{-764,443},{-763,443},{-762,443},{-764,441},{-765,441},{-765,442},{-760,443},{-760,444},{-759,444},{-758,444},{-813,447},{-802,449},{-798,448},{-810,448},{-802,448},{-810,449},{-809,448},{-809,449},{-801,448},{-801,449},{-798,449},{-799,448},{-799,449},{-814,449},{-814,450},{-800,450},{-801,451},{-800,451},{-801,452},{-800,452},{-801,453},{-817,453},{-818,453},{-816,453},{-802,453},{-803,453},{-803,454},{-818,454},{-804,455},{-818,455},{-817,455},{-805,455},{-800,449},{-816,455},{-816,456},{-804,456},{-806,456},{-829,456},{-829,457},{-830,457},{-815,458},{-831,458},{-816,459},{-808,459},{-809,459},{-830,458},{-829,458},{-817,459},{-818,459},{-810,459},{-810,460},{-811,459},{-819,459},{-819,460},{-815,455},{-815,456},{-814,456},{-750,456},{-744,456},{-745,453},{-743,452},{-753,449},{-770,440},{-770,442},{-773,442},{-776,441},{-776,443},{-778,443},{-771,442},{-771,440},{-770,439},{-769,439},{-771,438},{-789,439},{-798,433},{-791,433},{-789,429},{-802,428},{-804,426},{-801,425},{-813,426},{-818,422},{-824,421},{-825,419},{-831,420},{-831,423},{-825,426},{-824,430},{-817,434},{-818,441},{-813,446},{-817,452},{-813,452},{-812,449},{-810,450},{-811,447},{-809,446},{-806,447},{-801,445},{-800,447},{-797,447},{-797,448},{-799,451},{-802,452},{-804,454},{-807,459},{-818,457},{-817,458},{-816,458},{-819,455},{-820,456},{-821,455},{-835,459},{-836,461},{-839,461},{-841,465},{-846,465},{-844,467},{-846,467},{-846,468},{-848,470},{-846,473},{-850,476},{-848,479},{-859,480},{-864,488},{-873,488},{-884,490},{-881,488},{-883,488},{-885,488},{-888,483},{-889,483},{-888,486},{-894,485},{-894,483},{-893,484},{-892,483},{-896,480},{-900,480},{-900,482},{-910,485},{-910,492},{-900,495},{-900,508},{-905,510},{-908,512},{-908,515},{-900,520},{-900,528},{-890,528},{-890,530},{-885,534},{-885,536},{-890,540},{-900,540},{-900,562},{-889,569},{-880,565},{-859,556},{-851,553},{-839,553},{-823,551},{-822,548},{-825,542},{-821,538},{-821,533},{-823,529},{-816,524},{-814,521},{-807,518},{-804,513},{-798,512},{-795,515},{-796,474},{-794,471},{-787,463},{-777,462},{-770,458},{-768,459},{-766,457},{-767,456},{-764,455},{-761,455},{-758,454}}}, - {"America/New_York",621,{{-816,246},{-817,246},{-818,246},{-813,247},{-813,248},{-751,199},{-752,199},{-751,200},{-752,200},{-820,245},{-819,245},{-829,246},{-821,246},{-818,245},{-816,247},{-814,246},{-814,247},{-815,246},{-817,247},{-812,247},{-815,247},{-809,248},{-815,248},{-808,248},{-816,248},{-814,248},{-807,248},{-807,249},{-806,249},{-811,247},{-813,246},{-810,247},{-827,277},{-826,277},{-826,279},{-825,279},{-824,279},{-828,280},{-828,281},{-821,269},{-822,269},{-826,273},{-827,274},{-827,275},{-828,276},{-827,276},{-829,282},{-828,282},{-827,287},{-827,288},{-826,289},{-827,289},{-831,291},{-830,292},{-830,291},{-826,288},{-831,292},{-832,293},{-849,297},{-851,297},{-851,296},{-852,297},{-850,296},{-847,298},{-846,298},{-844,300},{-843,301},{-843,300},{-842,301},{-792,333},{-792,334},{-793,333},{-802,325},{-802,326},{-804,325},{-799,328},{-798,328},{-797,328},{-794,330},{-794,331},{-793,331},{-796,329},{-797,329},{-811,318},{-811,319},{-805,324},{-806,324},{-806,323},{-804,324},{-805,323},{-807,323},{-808,323},{-806,250},{-807,250},{-808,250},{-805,250},{-804,251},{-807,251},{-806,251},{-805,251},{-806,252},{-805,252},{-810,252},{-809,252},{-810,253},{-811,253},{-809,253},{-812,253},{-811,254},{-802,254},{-803,254},{-802,253},{-802,255},{-802,257},{-801,257},{-813,257},{-814,257},{-814,258},{-815,258},{-801,258},{-801,259},{-815,259},{-818,260},{-817,260},{-819,264},{-817,259},{-817,258},{-816,259},{-821,265},{-821,266},{-822,265},{-820,265},{-821,264},{-822,266},{-822,267},{-823,268},{-823,267},{-745,393},{-744,394},{-763,353},{-764,353},{-757,360},{-756,358},{-757,359},{-756,359},{-759,365},{-758,363},{-759,363},{-743,395},{-743,396},{-675,445},{-676,445},{-743,394},{-745,394},{-748,390},{-748,391},{-747,391},{-756,396},{-756,395},{-744,395},{-751,383},{-761,394},{-761,395},{-736,406},{-735,406},{-734,406},{-738,406},{-679,444},{-679,445},{-681,444},{-682,444},{-733,406},{-741,398},{-741,397},{-740,407},{-709,423},{-710,423},{-764,439},{-763,440},{-764,440},{-764,441},{-763,441},{-670,449},{-670,448},{-673,446},{-675,446},{-676,444},{-678,445},{-678,444},{-677,446},{-677,445},{-683,441},{-683,442},{-682,443},{-683,443},{-688,438},{-688,439},{-687,439},{-686,441},{-687,441},{-684,441},{-685,441},{-686,440},{-687,440},{-689,440},{-688,441},{-689,441},{-702,435},{-703,435},{-702,436},{-702,437},{-693,438},{-696,438},{-689,438},{-699,438},{-697,438},{-697,439},{-701,437},{-700,437},{-701,438},{-702,438},{-700,438},{-689,439},{-763,439},{-693,439},{-691,439},{-691,440},{-694,439},{-694,440},{-693,440},{-762,440},{-688,440},{-763,442},{-687,443},{-761,443},{-762,442},{-760,443},{-759,444},{-758,444},{-684,444},{-689,444},{-689,445},{-689,442},{-688,442},{-690,441},{-684,442},{-685,442},{-684,443},{-685,443},{-690,442},{-690,443},{-689,443},{-688,443},{-703,413},{-687,442},{-686,442},{-686,443},{-685,444},{-726,408},{-725,408},{-728,408},{-738,408},{-738,409},{-725,410},{-737,410},{-739,408},{-729,407},{-730,407},{-731,407},{-700,412},{-701,412},{-702,413},{-701,414},{-704,416},{-707,415},{-708,416},{-713,416},{-713,417},{-714,416},{-714,417},{-716,412},{-708,413},{-705,414},{-710,414},{-709,414},{-708,414},{-708,415},{-709,415},{-705,413},{-706,413},{-706,415},{-714,415},{-713,415},{-712,417},{-712,415},{-720,410},{-719,411},{-725,409},{-723,410},{-724,410},{-724,411},{-723,411},{-721,411},{-722,412},{-720,413},{-719,413},{-828,417},{-739,405},{-740,406},{-735,409},{-732,409},{-726,409},{-828,416},{-827,415},{-827,416},{-700,419},{-702,420},{-759,366},{-760,366},{-753,379},{-761,380},{-760,380},{-760,379},{-761,379},{-757,376},{-756,376},{-756,377},{-760,378},{-754,379},{-753,380},{-752,380},{-759,373},{-759,374},{-758,373},{-757,374},{-757,373},{-770,347},{-757,375},{-763,375},{-756,375},{-758,374},{-759,371},{-760,371},{-760,367},{-759,367},{-768,372},{-767,372},{-758,372},{-759,372},{-765,381},{-760,381},{-761,381},{-767,381},{-768,382},{-767,382},{-761,382},{-760,382},{-762,382},{-762,383},{-762,389},{-761,389},{-762,390},{-780,339},{-780,340},{-779,339},{-779,341},{-780,338},{-778,342},{-772,346},{-771,346},{-763,349},{-762,349},{-762,350},{-761,350},{-763,350},{-765,346},{-766,346},{-767,347},{-766,347},{-765,347},{-780,341},{-849,309},{-851,312},{-851,318},{-849,323},{-852,329},{-856,350},{-854,350},{-851,356},{-847,359},{-849,362},{-847,364},{-848,366},{-846,369},{-851,373},{-854,372},{-856,375},{-861,374},{-863,376},{-862,378},{-865,380},{-864,382},{-860,380},{-854,385},{-854,387},{-848,388},{-848,389},{-851,389},{-851,393},{-848,393},{-848,417},{-834,417},{-829,415},{-831,415},{-831,414},{-825,414},{-817,415},{-791,426},{-789,428},{-791,433},{-785,434},{-768,433},{-762,435},{-761,440},{-762,441},{-750,450},{-715,450},{-713,453},{-709,452},{-703,459},{-703,462},{-700,467},{-692,475},{-689,472},{-683,474},{-678,471},{-678,457},{-674,456},{-675,453},{-671,452},{-672,446},{-676,447},{-679,446},{-680,445},{-681,443},{-683,445},{-685,445},{-688,444},{-688,445},{-691,444},{-692,439},{-698,437},{-700,439},{-703,437},{-704,436},{-708,429},{-708,427},{-706,426},{-711,423},{-708,423},{-706,420},{-707,420},{-703,417},{-700,418},{-703,421},{-701,420},{-699,418},{-699,417},{-700,415},{-700,417},{-702,417},{-706,418},{-714,418},{-715,414},{-730,413},{-743,405},{-740,404},{-741,400},{-749,389},{-750,389},{-749,392},{-751,392},{-754,391},{-751,388},{-751,386},{-753,386},{-751,384},{-752,384},{-758,375},{-760,373},{-758,376},{-759,376},{-756,380},{-759,379},{-758,381},{-759,383},{-759,382},{-760,383},{-760,384},{-763,385},{-761,385},{-763,386},{-761,386},{-760,386},{-762,387},{-761,388},{-762,388},{-763,387},{-763,388},{-764,387},{-763,389},{-763,390},{-764,388},{-761,390},{-761,392},{-763,391},{-759,396},{-762,393},{-762,395},{-763,394},{-763,393},{-764,394},{-764,392},{-765,393},{-766,393},{-764,390},{-766,391},{-765,389},{-766,390},{-763,380},{-769,383},{-770,385},{-772,384},{-772,386},{-773,384},{-772,383},{-770,384},{-770,382},{-762,379},{-764,376},{-765,376},{-766,378},{-769,380},{-766,376},{-763,376},{-764,375},{-763,373},{-765,372},{-768,375},{-763,371},{-763,370},{-766,372},{-769,372},{-764,369},{-760,369},{-755,358},{-760,365},{-758,361},{-761,363},{-761,361},{-767,360},{-761,360},{-760,356},{-758,360},{-757,356},{-762,353},{-766,355},{-766,354},{-769,354},{-765,353},{-769,350},{-771,347},{-768,347},{-775,345},{-780,342},{-788,338},{-792,332},{-800,326},{-805,325},{-808,325},{-807,322},{-812,317},{-811,316},{-812,316},{-812,315},{-815,310},{-812,297},{-806,286},{-806,281},{-800,268},{-804,252},{-804,253},{-811,252},{-819,265},{-818,267},{-820,270},{-823,270},{-822,268},{-824,278},{-827,280},{-829,279},{-826,287},{-828,292},{-834,297},{-840,301},{-842,302},{-845,300},{-844,299},{-854,297},{-854,300},{-850,298},{-852,301},{-849,307},{-758,352},{-760,351},{-761,351},{-756,352},{-755,353},{-755,354},{-755,352},{-757,352}}}, - {"Pacific/Honolulu",48,{{-1579,213},{-1577,213},{-1580,214},{-1558,200},{-1559,203},{-1552,200},{-1548,195},{-1557,189},{-1559,191},{-1561,197},{-1565,206},{-1566,206},{-1565,205},{-1567,205},{-1567,206},{-1570,209},{-1568,209},{-1568,208},{-1570,208},{-1572,212},{-1570,212},{-1567,212},{-1573,211},{-1566,210},{-1562,209},{-1560,207},{-1564,206},{-1567,209},{-1565,210},{-1605,217},{-1606,217},{-1601,220},{-1619,231},{-1647,236},{-1663,239},{-1717,258},{-1740,261},{-1602,219},{-1602,218},{-1603,218},{-1594,222},{-1593,221},{-1594,219},{-1598,220},{-1580,217},{-1577,215},{-1581,213},{-1583,216}}}, - {"Asia/Samarkand",82,{{682,389},{681,385},{684,382},{679,375},{678,372},{665,373},{666,375},{665,376},{666,380},{654,383},{625,400},{623,404},{621,406},{619,411},{614,413},{613,411},{604,413},{601,414},{601,418},{603,418},{599,420},{600,422},{594,423},{586,428},{586,427},{581,426},{585,423},{580,425},{579,422},{574,422},{570,419},{570,414},{572,414},{570,413},{560,413},{560,450},{586,456},{582,449},{582,444},{585,441},{595,440},{594,438},{603,441},{607,446},{620,435},{634,437},{645,436},{651,438},{657,433},{658,429},{661,430},{660,419},{665,419},{666,413},{668,412},{666,411},{668,408},{666,405},{669,405},{669,401},{675,399},{673,397},{675,393},{674,392},{588,443},{589,443},{588,441},{588,442},{591,447},{591,446},{590,444},{591,448},{590,446},{588,444},{588,446},{589,449},{589,448},{592,450},{590,448},{589,454},{594,452},{592,448}}}, - {"America/Port_of_Spain",13,{{-618,107},{-617,107},{-616,107},{-608,112},{-607,113},{-605,113},{-608,111},{-610,101},{-612,101},{-619,100},{-615,103},{-615,106},{-609,108}}}, - {"Africa/Johannesburg",101,{{378,-468},{379,-469},{376,-469},{377,-468},{379,-466},{380,-466},{380,-467},{379,-467},{184,-338},{181,-334},{182,-317},{236,-340},{234,-341},{223,-341},{217,-344},{208,-344},{209,-345},{205,-345},{200,-348},{193,-346},{194,-345},{191,-343},{188,-344},{188,-341},{185,-341},{185,-344},{184,-343},{183,-340},{185,-339},{184,-337},{178,-328},{183,-326},{183,-319},{173,-303},{165,-286},{167,-285},{169,-281},{171,-280},{174,-283},{174,-287},{182,-289},{192,-290},{196,-285},{200,-284},{200,-248},{207,-255},{208,-260},{206,-265},{207,-269},{209,-268},{217,-269},{226,-262},{230,-253},{235,-253},{239,-256},{247,-258},{254,-257},{257,-255},{259,-248},{264,-246},{269,-243},{270,-236},{277,-232},{283,-226},{289,-225},{290,-222},{296,-221},{303,-224},{313,-224},{316,-235},{320,-243},{320,-260},{313,-257},{308,-264},{308,-268},{312,-272},{315,-273},{320,-273},{320,-268},{329,-269},{324,-285},{314,-292},{300,-313},{279,-330},{265,-338},{257,-338},{257,-340},{250,-340},{248,-341},{248,-342},{274,-303},{281,-307},{284,-301},{292,-299},{292,-297},{295,-294},{293,-291},{287,-286},{278,-289},{274,-295},{270,-296}}}, - {"Pacific/Port_Moresby",556,{{1506,-102},{1506,-27},{1535,-116},{1533,-114},{1537,-115},{1538,-116},{1533,-115},{1521,-113},{1521,-112},{1541,-113},{1542,-113},{1543,-114},{1540,-114},{1534,-113},{1535,-113},{1540,-113},{1528,-112},{1528,-111},{1432,-83},{1531,-112},{1530,-112},{1531,-111},{1529,-112},{1531,-113},{1532,-113},{1533,-113},{1523,-111},{1525,-111},{1527,-111},{1528,-110},{1511,-110},{1510,-110},{1524,-111},{1525,-110},{1526,-111},{1529,-111},{1530,-109},{1530,-108},{1525,-108},{1522,-108},{1519,-108},{1524,-108},{1504,-108},{1518,-107},{1517,-108},{1513,-108},{1513,-107},{1503,-107},{1512,-107},{1498,-105},{1499,-105},{1501,-105},{1521,-104},{1494,-104},{1514,-104},{1537,-93},{1531,-92},{1528,-92},{1511,-103},{1510,-103},{1519,-103},{1519,-102},{1509,-100},{1502,-107},{1507,-107},{1504,-107},{1512,-106},{1509,-107},{1506,-106},{1507,-106},{1513,-106},{1511,-107},{1509,-106},{1510,-106},{1511,-106},{1510,-107},{1508,-106},{1508,-107},{1508,-105},{1528,-106},{1529,-107},{1527,-107},{1525,-106},{1524,-107},{1523,-107},{1514,-106},{1475,-77},{1473,-74},{1438,-75},{1438,-76},{1437,-76},{1447,-76},{1446,-77},{1472,-74},{1471,-71},{1471,-70},{1431,-92},{1430,-92},{1420,-92},{1502,-92},{1524,-91},{1524,-90},{1432,-91},{1433,-91},{1433,-86},{1434,-86},{1471,-95},{1470,-95},{1508,-93},{1507,-93},{1520,-93},{1519,-93},{1509,-93},{1509,-92},{1527,-92},{1525,-90},{1530,-92},{1530,-93},{1508,-92},{1525,-96},{1524,-96},{1508,-98},{1442,-78},{1442,-77},{1443,-78},{1435,-88},{1434,-88},{1434,-87},{1435,-87},{1510,-96},{1510,-97},{1510,-100},{1508,-97},{1511,-100},{1513,-100},{1512,-102},{1509,-97},{1509,-98},{1504,-96},{1504,-94},{1508,-94},{1520,-94},{1521,-94},{1504,-95},{1510,-95},{1462,-82},{1461,-82},{1503,-95},{1501,-94},{1524,-89},{1520,-90},{1519,-89},{1511,-89},{1512,-89},{1511,-88},{1519,-88},{1517,-87},{1513,-87},{1513,-86},{1514,-86},{1510,-87},{1510,-88},{1511,-86},{1510,-85},{1511,-84},{1512,-86},{1509,-85},{1510,-86},{1509,-86},{1476,-77},{1423,-82},{1454,-79},{1452,-78},{1452,-79},{1450,-78},{1438,-78},{1439,-78},{1439,-77},{1440,-78},{1444,-77},{1444,-78},{1443,-77},{1443,-76},{1431,-85},{1432,-85},{1429,-84},{1430,-84},{1431,-84},{1422,-82},{1424,-83},{1425,-83},{1429,-83},{1431,-83},{1434,-90},{1435,-90},{1465,-88},{1433,-85},{1508,-86},{1434,-85},{1436,-86},{1436,-87},{1432,-84},{1503,-85},{1438,-85},{1437,-84},{1437,-85},{1436,-85},{1509,-84},{1508,-83},{1509,-83},{1506,-83},{1436,-81},{1437,-81},{1437,-82},{1436,-82},{1435,-80},{1435,-81},{1434,-79},{1433,-84},{1435,-84},{1435,-83},{1437,-83},{1433,-83},{1434,-83},{1434,-84},{1557,-62},{1556,-62},{1546,-54},{1546,-53},{1545,-53},{1441,-32},{1441,-33},{1425,-31},{1424,-31},{1544,-31},{1527,-30},{1450,-40},{1547,-54},{1551,-55},{1555,-62},{1558,-64},{1560,-67},{1559,-68},{1556,-69},{1552,-66},{1552,-63},{1547,-59},{1551,-56},{1547,-56},{1546,-55},{1547,-55},{1571,-48},{1595,-46},{1547,-33},{1432,-32},{1433,-32},{1525,-31},{1526,-30},{1526,-32},{1525,-32},{1507,-30},{1527,-29},{1510,-30},{1508,-30},{1509,-29},{1527,-28},{1526,-28},{1520,-29},{1519,-29},{1520,-28},{1521,-30},{1519,-28},{1519,-27},{1507,-28},{1445,-40},{1445,-39},{1442,-38},{1547,-34},{1547,-35},{1448,-36},{1446,-36},{1532,-35},{1532,-34},{1446,-35},{1434,-34},{1435,-34},{1436,-34},{1435,-33},{1442,-34},{1476,-21},{1477,-21},{1478,-20},{1478,-21},{1444,-34},{1533,-34},{1468,-24},{1476,-23},{1475,-23},{1505,-25},{1504,-24},{1501,-24},{1503,-23},{1503,-24},{1474,-24},{1473,-24},{1464,-21},{1469,-19},{1428,-18},{1428,-17},{1429,-17},{1429,-18},{1500,-17},{1499,-17},{1500,-16},{1474,-20},{1474,-21},{1473,-21},{1473,-20},{1466,-19},{1466,-20},{1472,-20},{1496,-16},{1497,-16},{1440,-15},{1431,-15},{1430,-15},{1445,-14},{1442,-14},{1441,-13},{1442,-13},{1450,-16},{1450,-15},{1451,-15},{1496,-15},{1497,-15},{1451,-16},{1444,-12},{1444,-11},{1445,-11},{1495,-14},{1496,-13},{1440,-17},{1440,-16},{1482,-22},{1472,-22},{1478,-22},{1477,-22},{1477,-24},{1479,-23},{1478,-23},{1466,-22},{1455,-9},{1456,-9},{1443,-12},{1442,-12},{1507,-27},{1507,-26},{1497,-26},{1505,-27},{1504,-27},{1505,-26},{1506,-26},{1520,-27},{1520,-26},{1508,-26},{1473,-26},{1473,-25},{1489,-60},{1500,-25},{1502,-24},{1504,-25},{1502,-27},{1545,-52},{1546,-50},{1547,-52},{1545,-51},{1555,-48},{1541,-44},{1524,-42},{1525,-42},{1519,-42},{1524,-41},{1522,-43},{1522,-42},{1462,-48},{1463,-48},{1528,-48},{1529,-48},{1528,-47},{1495,-47},{1494,-47},{1495,-46},{1459,-47},{1459,-46},{1460,-45},{1461,-47},{1542,-45},{1542,-46},{1493,-46},{1494,-46},{1491,-46},{1491,-45},{1537,-41},{1536,-41},{1536,-40},{1537,-40},{1480,-60},{1480,-59},{1450,-41},{1451,-40},{1451,-41},{1521,-41},{1508,-28},{1520,-32},{1526,-38},{1528,-39},{1531,-43},{1523,-36},{1498,-63},{1503,-63},{1501,-63},{1500,-106},{1500,-105},{1501,-104},{1488,-101},{1484,-102},{1482,-100},{1480,-102},{1479,-100},{1477,-101},{1473,-95},{1469,-93},{1470,-91},{1466,-90},{1466,-88},{1463,-83},{1458,-79},{1449,-78},{1449,-76},{1448,-76},{1448,-77},{1446,-75},{1445,-75},{1445,-74},{1445,-77},{1445,-76},{1444,-76},{1444,-75},{1445,-78},{1441,-78},{1436,-75},{1437,-74},{1436,-74},{1436,-73},{1435,-73},{1439,-80},{1438,-79},{1433,-78},{1432,-78},{1430,-83},{1427,-83},{1424,-82},{1425,-84},{1426,-93},{1422,-91},{1423,-90},{1422,-89},{1421,-89},{1422,-92},{1420,-90},{1411,-92},{1410,-69},{1408,-66},{1410,-63},{1410,-26},{1425,-32},{1441,-38},{1445,-38},{1453,-44},{1458,-48},{1458,-55},{1476,-61},{1479,-66},{1469,-67},{1472,-75},{1477,-79},{1481,-81},{1482,-86},{1484,-87},{1486,-91},{1493,-90},{1492,-95},{1501,-97},{1497,-98},{1499,-100},{1506,-103},{1509,-102},{1506,-104},{1503,-103},{1505,-54},{1505,-53},{1499,-63},{1504,-63},{1496,-63},{1495,-63},{1495,-62},{1500,-63},{1490,-61},{1490,-62},{1489,-62},{1489,-61},{1479,-59},{1480,-58},{1481,-56},{1478,-55},{1494,-55},{1481,-54},{1480,-54},{1517,-56},{1458,-52},{1470,-51},{1469,-51},{1458,-51},{1511,-49},{1512,-49},{1512,-50},{1514,-49},{1476,-53},{1501,-53},{1493,-61},{1490,-60},{1484,-57},{1483,-55},{1499,-55},{1501,-50},{1501,-55},{1509,-55},{1513,-49},{1517,-49},{1515,-42},{1519,-43},{1522,-41},{1524,-43},{1523,-49},{1519,-50},{1521,-54},{1518,-56},{1515,-55},{1515,-57},{1512,-60},{1470,-54},{1471,-52},{1472,-54},{1471,-54},{1491,-49},{1492,-49}}}, - {"America/Bahia",96,{{-387,-130},{-386,-128},{-387,-128},{-385,-128},{-385,-127},{-386,-127},{-387,-127},{-387,-181},{-387,-180},{-393,-180},{-392,-180},{-391,-179},{-392,-179},{-392,-178},{-391,-176},{-390,-176},{-390,-156},{-390,-155},{-389,-156},{-390,-139},{-391,-139},{-389,-138},{-456,-150},{-461,-152},{-459,-144},{-463,-139},{-461,-130},{-462,-128},{-462,-125},{-463,-123},{-463,-121},{-461,-119},{-463,-118},{-461,-116},{-466,-113},{-462,-107},{-456,-103},{-453,-108},{-448,-109},{-446,-106},{-439,-104},{-437,-99},{-438,-94},{-435,-93},{-426,-96},{-423,-93},{-418,-93},{-414,-87},{-409,-88},{-409,-92},{-407,-92},{-408,-95},{-406,-95},{-394,-85},{-386,-90},{-385,-88},{-385,-90},{-383,-90},{-378,-101},{-378,-107},{-382,-107},{-382,-109},{-378,-115},{-374,-115},{-380,-126},{-385,-130},{-387,-126},{-388,-130},{-387,-129},{-386,-130},{-390,-133},{-389,-136},{-389,-139},{-391,-147},{-389,-159},{-392,-172},{-391,-177},{-397,-183},{-402,-180},{-402,-178},{-406,-174},{-405,-169},{-402,-168},{-403,-166},{-399,-162},{-402,-158},{-409,-157},{-413,-158},{-414,-155},{-418,-151},{-421,-152},{-432,-146},{-437,-147},{-439,-146},{-438,-143},{-442,-142}}}, - {"Europe/Zurich",27,{{62,463},{60,462},{62,464},{61,466},{71,473},{69,474},{70,475},{86,476},{84,477},{86,478},{96,475},{95,471},{101,468},{105,469},{105,465},{101,465},{101,462},{93,465},{90,458},{88,461},{85,463},{84,465},{79,459},{72,459},{68,462},{68,464},{87,477}}}, - {"America/St_Barthelemy",2,{{-628,179},{-629,179}}}, - {"Asia/Nicosia",11,{{330,346},{324,348},{323,351},{329,351},{329,354},{336,354},{346,357},{339,353},{341,350},{337,350},{336,348}}}, - {"Europe/Kaliningrad",18,{{196,545},{199,546},{197,545},{210,553},{209,552},{205,550},{212,549},{212,552},{214,553},{221,550},{226,551},{229,548},{227,546},{228,544},{198,544},{204,547},{200,550},{204,550}}}, - {"America/Anguilla",8,{{-630,183},{-629,183},{-634,186},{-632,182},{-631,182},{-630,182},{-633,183},{-632,183}}}, - {"Europe/Ljubljana",21,{{160,468},{163,468},{166,465},{163,465},{163,464},{156,462},{157,459},{153,457},{154,455},{148,455},{146,456},{144,455},{136,455},{139,456},{135,460},{137,462},{134,463},{137,465},{146,464},{150,467},{160,467}}}, - {"Asia/Yekaterinburg",547,{{709,664},{791,675},{790,675},{728,726},{778,675},{779,675},{780,675},{787,675},{786,675},{786,676},{787,676},{790,676},{789,676},{788,676},{674,688},{672,688},{671,688},{673,688},{657,691},{672,694},{673,694},{756,734},{754,734},{756,735},{761,735},{767,734},{765,735},{760,735},{764,735},{766,734},{718,730},{718,731},{717,731},{716,731},{715,731},{715,732},{764,731},{762,732},{761,732},{767,731},{760,731},{759,732},{760,732},{700,730},{700,734},{704,735},{712,734},{716,732},{670,694},{672,693},{676,695},{670,695},{674,696},{666,706},{665,706},{674,707},{673,707},{667,710},{667,711},{668,711},{665,708},{666,709},{666,710},{769,722},{756,722},{757,722},{772,722},{773,722},{770,722},{786,723},{756,725},{757,725},{780,723},{784,724},{784,723},{783,724},{727,727},{728,727},{729,726},{729,727},{770,723},{772,724},{776,726},{783,725},{778,723},{768,723},{698,729},{748,729},{747,728},{747,729},{746,729},{747,730},{746,728},{741,730},{743,731},{747,731},{749,730},{722,663},{723,663},{724,663},{722,664},{704,663},{704,664},{600,520},{600,519},{605,518},{604,516},{615,514},{617,513},{615,508},{606,507},{601,509},{598,506},{595,505},{586,508},{583,512},{578,511},{577,509},{575,509},{572,511},{568,511},{567,510},{564,511},{561,507},{557,506},{551,509},{547,509},{547,506},{545,505},{545,508},{534,515},{526,515},{523,518},{519,517},{517,515},{513,515},{514,517},{508,518},{514,521},{515,527},{517,527},{517,529},{522,531},{521,535},{525,541},{522,543},{530,543},{531,542},{529,542},{531,541},{535,540},{533,544},{536,549},{531,551},{536,552},{542,556},{540,559},{536,559},{544,563},{540,566},{541,567},{539,566},{538,568},{540,567},{541,570},{544,570},{543,571},{543,573},{541,573},{543,575},{540,576},{542,577},{541,580},{538,582},{539,583},{537,586},{539,588},{537,589},{539,591},{534,592},{532,593},{537,600},{535,602},{523,602},{523,604},{518,606},{519,609},{523,608},{529,611},{534,610},{533,609},{536,609},{538,608},{539,610},{550,609},{553,611},{563,612},{564,614},{567,615},{588,615},{593,617},{594,621},{597,625},{594,627},{595,629},{592,631},{596,639},{599,641},{596,642},{596,645},{595,645},{597,648},{602,651},{606,649},{619,657},{628,659},{629,661},{633,662},{632,663},{634,665},{651,669},{652,672},{661,675},{658,676},{662,677},{660,678},{661,679},{653,680},{653,682},{657,686},{653,688},{645,689},{645,690},{649,693},{662,691},{664,690},{666,689},{656,691},{664,689},{678,684},{682,684},{683,681},{686,683},{691,688},{681,692},{680,693},{682,695},{670,697},{669,696},{668,696},{670,700},{674,700},{671,702},{670,711},{670,713},{684,718},{689,727},{693,729},{716,729},{728,725},{726,725},{728,723},{723,717},{718,715},{726,711},{726,710},{728,709},{728,704},{724,703},{727,698},{725,696},{727,695},{725,694},{726,693},{725,691},{726,689},{736,685},{731,682},{732,679},{731,677},{726,676},{724,673},{721,673},{722,671},{721,671},{719,671},{721,670},{718,669},{714,670},{715,669},{705,667},{699,669},{688,669},{691,669},{689,668},{692,668},{692,666},{723,662},{723,665},{739,670},{739,673},{747,677},{748,680},{743,684},{745,687},{761,690},{766,690},{766,688},{773,685},{771,683},{773,682},{772,681},{773,679},{770,678},{777,676},{776,673},{785,676},{788,674},{792,673},{793,673},{794,673},{794,672},{796,672},{800,671},{789,674},{795,673},{775,677},{776,679},{775,681},{781,683},{778,685},{776,689},{760,693},{748,691},{738,692},{739,694},{735,698},{738,699},{737,701},{743,706},{736,712},{730,714},{735,716},{735,718},{750,722},{751,724},{748,728},{750,729},{755,727},{753,727},{755,725},{757,723},{752,718},{755,715},{752,714},{758,712},{778,711},{784,709},{783,712},{763,716},{760,719},{769,721},{776,718},{781,719},{782,720},{780,721},{774,721},{781,724},{803,719},{800,718},{801,717},{794,716},{791,714},{806,711},{807,708},{806,707},{808,707},{806,705},{808,704},{802,704},{793,701},{793,700},{789,699},{791,697},{790,697},{795,697},{799,693},{810,692},{816,693},{817,694},{819,693},{818,693},{818,692},{825,692},{823,691},{826,688},{830,687},{825,686},{827,685},{827,683},{824,682},{824,679},{817,679},{824,675},{822,674},{824,673},{821,672},{832,668},{833,667},{831,666},{831,665},{835,662},{833,661},{835,658},{840,658},{845,655},{846,653},{843,649},{859,648},{858,645},{860,643},{860,641},{850,636},{857,634},{855,631},{856,630},{844,622},{847,618},{860,615},{856,614},{857,613},{840,608},{835,610},{831,610},{822,605},{807,608},{794,606},{792,608},{779,607},{771,609},{770,607},{770,605},{768,605},{769,603},{767,601},{766,596},{759,594},{756,592},{757,590},{742,581},{712,581},{713,584},{709,585},{704,579},{707,576},{704,574},{707,572},{711,573},{717,568},{711,567},{711,566},{708,565},{709,564},{708,563},{709,560},{705,559},{708,559},{705,557},{708,556},{703,552},{690,555},{690,553},{688,554},{687,552},{682,552},{683,551},{681,549},{655,547},{652,545},{652,543},{632,542},{626,539},{624,541},{619,539},{613,541},{613,539},{610,539},{612,538},{609,536},{616,536},{613,535},{612,533},{621,530},{610,530},{607,527},{611,523},{701,664},{700,664},{710,664},{708,664},{707,664},{716,667},{716,669},{717,669},{778,674},{779,674},{777,674},{777,675},{696,668},{697,668},{695,668},{715,668},{698,668},{691,668},{694,668},{714,669},{706,667},{707,667},{694,667},{695,667},{700,667},{699,667},{701,667},{693,667},{714,666},{713,666},{694,666},{693,666},{712,665},{698,665},{697,665},{696,666},{700,665},{711,665},{711,666},{710,665},{712,666},{701,666},{700,666},{710,666},{704,666},{703,666},{702,667},{701,665},{702,665},{696,667},{713,667}}}, - {"Africa/Kampala",28,{{313,-10},{304,-11},{299,-15},{298,-13},{296,-14},{297,1},{300,5},{300,8},{313,21},{307,25},{309,35},{312,38},{315,37},{318,38},{322,35},{324,37},{330,39},{335,37},{340,42},{342,38},{345,37},{345,32},{349,25},{350,19},{348,12},{345,11},{339,1},{339,-10}}}, - {"America/Rio_Branco",21,{{-737,-72},{-738,-71},{-726,-76},{-704,-82},{-666,-99},{-674,-104},{-677,-107},{-680,-107},{-686,-111},{-694,-109},{-706,-110},{-705,-94},{-712,-100},{-722,-100},{-724,-95},{-732,-94},{-729,-90},{-735,-83},{-738,-79},{-737,-78},{-740,-76}}}, - {"Africa/Bamako",81,{{-45,127},{-44,123},{-46,121},{-54,118},{-52,114},{-55,111},{-55,104},{-62,102},{-63,107},{-64,106},{-66,107},{-67,104},{-69,104},{-70,102},{-76,105},{-79,102},{-83,105},{-83,110},{-87,110},{-84,114},{-89,116},{-88,120},{-90,124},{-94,125},{-93,122},{-97,120},{-103,122},{-107,119},{-109,122},{-112,120},{-115,121},{-114,130},{-116,134},{-118,133},{-120,136},{-120,142},{-122,145},{-122,148},{-118,149},{-117,155},{-115,156},{-109,151},{-107,154},{-94,154},{-93,157},{-93,155},{-55,155},{-53,163},{-56,165},{-66,250},{-48,250},{12,211},{12,207},{16,206},{18,203},{22,203},{24,201},{32,198},{33,194},{31,192},{33,190},{42,191},{42,170},{41,169},{39,157},{35,153},{13,153},{7,149},{-7,151},{-17,145},{-20,145},{-20,142},{-25,143},{-28,141},{-29,137},{-33,137},{-32,133},{-34,132},{-40,135},{-44,131},{-42,127}}}, - {"America/Goose_Bay",502,{{-563,537},{-565,536},{-565,537},{-564,538},{-563,538},{-568,537},{-568,538},{-566,537},{-566,538},{-569,537},{-570,538},{-570,539},{-569,539},{-565,539},{-566,539},{-569,538},{-569,545},{-569,547},{-606,558},{-606,559},{-611,558},{-611,559},{-607,559},{-609,559},{-610,559},{-608,559},{-603,557},{-603,558},{-602,558},{-602,557},{-604,558},{-603,555},{-601,555},{-600,555},{-602,555},{-601,556},{-604,556},{-603,556},{-602,556},{-604,557},{-606,557},{-601,557},{-607,560},{-606,560},{-612,560},{-613,560},{-608,560},{-610,560},{-611,560},{-614,560},{-609,561},{-609,560},{-608,561},{-612,561},{-610,561},{-613,561},{-614,561},{-599,554},{-598,554},{-599,555},{-600,554},{-601,554},{-598,555},{-600,537},{-571,537},{-571,536},{-572,537},{-570,537},{-572,545},{-571,545},{-598,551},{-588,551},{-588,552},{-587,552},{-565,538},{-564,537},{-589,539},{-589,540},{-588,540},{-572,541},{-571,541},{-571,542},{-574,541},{-574,542},{-573,542},{-575,542},{-582,543},{-584,541},{-585,541},{-571,538},{-571,539},{-578,543},{-580,543},{-579,543},{-578,544},{-577,543},{-572,544},{-574,544},{-573,546},{-573,545},{-572,546},{-571,546},{-578,547},{-579,547},{-578,548},{-584,548},{-586,548},{-574,545},{-573,543},{-581,543},{-579,549},{-581,549},{-580,549},{-597,549},{-597,550},{-586,550},{-589,549},{-588,549},{-586,549},{-603,550},{-586,551},{-604,552},{-589,552},{-590,552},{-597,552},{-592,551},{-594,551},{-593,551},{-588,550},{-582,550},{-587,550},{-587,549},{-583,550},{-589,550},{-603,552},{-592,552},{-603,553},{-593,553},{-594,553},{-595,553},{-596,552},{-596,553},{-600,552},{-600,553},{-597,553},{-596,554},{-597,554},{-599,553},{-601,553},{-603,554},{-604,553},{-602,553},{-602,554},{-593,552},{-587,548},{-583,549},{-584,549},{-585,549},{-582,549},{-644,603},{-645,603},{-611,562},{-608,562},{-612,562},{-609,562},{-613,562},{-571,520},{-638,520},{-637,520},{-637,523},{-641,525},{-634,527},{-636,529},{-641,527},{-642,521},{-644,520},{-643,518},{-646,516},{-647,518},{-653,518},{-655,521},{-657,520},{-657,521},{-660,521},{-663,523},{-664,522},{-665,523},{-663,524},{-664,527},{-663,526},{-664,530},{-666,530},{-668,527},{-673,529},{-672,530},{-674,531},{-670,531},{-669,534},{-673,536},{-678,540},{-676,542},{-678,544},{-673,545},{-671,547},{-674,551},{-667,547},{-668,554},{-662,550},{-659,549},{-657,547},{-651,550},{-648,547},{-644,548},{-639,546},{-637,546},{-639,548},{-638,549},{-636,549},{-634,553},{-637,553},{-633,554},{-638,555},{-637,558},{-638,559},{-634,560},{-640,561},{-639,562},{-642,564},{-639,565},{-641,567},{-639,569},{-637,572},{-639,573},{-636,577},{-641,578},{-642,580},{-644,581},{-638,585},{-641,586},{-640,587},{-635,588},{-637,589},{-641,587},{-643,589},{-649,589},{-647,591},{-643,590},{-645,593},{-644,595},{-647,594},{-649,596},{-647,599},{-649,601},{-646,601},{-649,603},{-644,602},{-646,603},{-647,603},{-644,601},{-647,600},{-644,600},{-646,600},{-645,599},{-642,600},{-643,599},{-641,599},{-642,598},{-639,598},{-643,598},{-639,597},{-641,596},{-641,595},{-640,596},{-637,595},{-641,594},{-634,592},{-636,591},{-640,591},{-641,590},{-639,590},{-633,591},{-631,590},{-633,589},{-631,589},{-629,588},{-629,587},{-631,587},{-629,586},{-635,585},{-633,585},{-636,583},{-631,585},{-632,584},{-626,585},{-627,584},{-626,583},{-629,583},{-630,582},{-627,583},{-626,582},{-631,582},{-633,580},{-625,582},{-625,580},{-623,580},{-626,580},{-627,580},{-627,579},{-621,580},{-619,579},{-622,578},{-619,576},{-626,575},{-618,574},{-620,573},{-614,571},{-613,570},{-619,568},{-617,566},{-625,568},{-623,568},{-621,568},{-626,569},{-626,568},{-617,565},{-621,565},{-619,565},{-622,565},{-616,563},{-621,563},{-621,562},{-615,561},{-615,560},{-607,558},{-609,557},{-607,555},{-605,558},{-605,556},{-605,553},{-607,550},{-603,551},{-601,552},{-599,552},{-598,553},{-600,551},{-594,552},{-599,547},{-591,552},{-594,550},{-589,551},{-590,550},{-590,549},{-591,548},{-584,547},{-580,548},{-579,548},{-582,547},{-577,545},{-575,545},{-576,544},{-596,540},{-584,542},{-586,540},{-601,538},{-602,535},{-600,534},{-608,532},{-602,533},{-598,535},{-599,535},{-591,537},{-578,541},{-572,538},{-574,536},{-575,536},{-573,535},{-575,534},{-575,530},{-571,528},{-610,562},{-615,562},{-616,562},{-607,563},{-614,562},{-619,563},{-608,563},{-609,563},{-610,563},{-613,563},{-614,563},{-617,562},{-611,563},{-612,563},{-615,563},{-610,564},{-611,564},{-614,564},{-618,564},{-613,564},{-612,564},{-621,564},{-609,564},{-609,565},{-611,565},{-614,566},{-612,565},{-611,566},{-613,565},{-612,566},{-619,564},{-615,564},{-616,564},{-617,564},{-616,566},{-615,565},{-618,563},{-613,566},{-609,567},{-609,568},{-610,567},{-610,568},{-612,568},{-613,568},{-617,568},{-614,567},{-614,568},{-613,567},{-612,567},{-613,571},{-615,572},{-614,572},{-635,594},{-615,573},{-618,572},{-619,572},{-619,573},{-617,573},{-618,573},{-617,574},{-616,574},{-616,573},{-623,575},{-622,575},{-621,575},{-613,576},{-614,576},{-616,576},{-617,575},{-617,576},{-618,576},{-620,575},{-615,575},{-614,575},{-616,575},{-618,575},{-615,574},{-614,574},{-637,594},{-619,574},{-613,569},{-611,568},{-611,569},{-618,577},{-620,577},{-619,577},{-642,599},{-643,601},{-642,601},{-617,577},{-618,578},{-619,578},{-617,578},{-617,579},{-620,579},{-622,580},{-622,581},{-625,581},{-624,581},{-621,582},{-625,583},{-625,584},{-624,584},{-630,585},{-629,585},{-627,585},{-628,585},{-628,586},{-627,586},{-643,602},{-642,602},{-644,604},{-626,584},{-615,566},{-609,566},{-610,566},{-618,566},{-620,566},{-621,567},{-611,567},{-616,568},{-615,568},{-617,567}}}, - {"Africa/Conakry",94,{{-134,93},{-133,91},{-133,92},{-138,95},{-138,94},{-137,95},{-146,108},{-149,109},{-150,110},{-150,108},{-151,109},{-149,108},{-148,109},{-149,110},{-147,110},{-141,101},{-140,101},{-87,76},{-88,73},{-91,72},{-93,74},{-95,74},{-93,77},{-95,84},{-98,85},{-101,84},{-104,85},{-107,83},{-105,87},{-106,90},{-107,91},{-107,93},{-112,100},{-124,99},{-128,93},{-133,90},{-133,93},{-136,96},{-136,98},{-138,98},{-137,99},{-140,102},{-141,100},{-145,102},{-145,105},{-147,105},{-145,108},{-147,106},{-147,108},{-147,107},{-149,111},{-148,114},{-143,117},{-137,117},{-137,120},{-140,122},{-137,123},{-137,127},{-131,126},{-131,125},{-129,125},{-124,123},{-115,124},{-115,122},{-113,120},{-109,122},{-107,119},{-103,122},{-97,120},{-93,122},{-94,125},{-90,124},{-88,120},{-89,116},{-84,114},{-87,110},{-83,110},{-83,105},{-80,103},{-82,99},{-81,95},{-78,94},{-79,92},{-77,91},{-80,88},{-78,88},{-76,84},{-82,85},{-82,82},{-80,82},{-79,80},{-81,80},{-82,76},{-87,77}}}, - {"America/Chihuahua",29,{{-1034,288},{-1040,279},{-1036,267},{-1042,268},{-1046,264},{-1051,265},{-1053,265},{-1060,268},{-1062,264},{-1065,264},{-1064,261},{-1065,258},{-1071,256},{-1074,261},{-1078,262},{-1080,269},{-1086,271},{-1087,275},{-1091,282},{-1091,283},{-1086,283},{-1087,294},{-1086,300},{-1088,311},{-1081,311},{-1080,316},{-1066,316},{-1051,304},{-1047,295}}}, - {"Europe/Warsaw",65,{{144,539},{144,538},{142,539},{148,540},{146,538},{147,539},{147,540},{235,502},{227,496},{227,492},{229,490},{216,494},{209,493},{203,494},{201,492},{198,492},{198,494},{195,496},{190,494},{186,499},{179,500},{176,501},{178,502},{177,503},{174,503},{169,504},{170,502},{166,501},{162,504},{164,506},{163,507},{154,508},{152,510},{148,509},{150,513},{146,518},{148,521},{145,524},{146,526},{141,528},{145,533},{143,537},{146,536},{180,548},{183,548},{188,547},{184,547},{188,544},{197,545},{192,543},{194,542},{198,544},{230,544},{235,541},{240,529},{239,527},{235,526},{232,523},{237,521},{235,517},{236,513},{242,509},{240,508},{241,506},{240,504}}}, - {"Pacific/Palau",19,{{1312,30},{1323,43},{1320,47},{1341,69},{1342,69},{1343,70},{1342,70},{1344,71},{1343,72},{1344,72},{1343,73},{1344,73},{1345,76},{1346,77},{1345,73},{1345,74},{1347,81},{1347,80},{1344,74}}}, - {"Europe/Mariehamn",72,{{203,603},{209,599},{210,599},{210,600},{211,602},{193,602},{196,602},{209,602},{194,602},{204,602},{197,602},{205,602},{203,602},{207,602},{208,602},{209,600},{203,600},{200,600},{200,601},{209,604},{201,600},{204,600},{205,600},{208,600},{206,601},{206,600},{207,600},{211,601},{207,601},{205,601},{203,601},{208,601},{204,601},{211,603},{211,604},{204,603},{209,603},{206,602},{202,604},{202,605},{211,605},{210,605},{209,605},{211,606},{210,606},{210,604},{210,602},{210,603},{207,603},{195,602},{195,603},{208,603},{196,601},{196,603},{197,603},{198,603},{198,604},{203,604},{197,604},{196,604},{200,604},{208,604},{201,604},{199,602},{202,601},{202,600},{198,601},{198,602},{199,604},{199,603},{205,603},{206,604}}}, - {"Africa/Windhoek",46,{{152,-270},{152,-271},{150,-264},{152,-266},{151,-266},{149,-263},{149,-264},{200,-274},{200,-284},{196,-285},{191,-290},{174,-287},{174,-283},{171,-280},{169,-281},{168,-284},{165,-286},{157,-280},{149,-251},{145,-241},{145,-225},{134,-209},{126,-192},{120,-185},{117,-178},{118,-173},{121,-171},{126,-172},{131,-170},{135,-170},{140,-174},{184,-174},{189,-178},{203,-179},{208,-180},{242,-175},{250,-176},{253,-178},{250,-178},{246,-181},{242,-180},{236,-185},{233,-180},{210,-183},{210,-220},{200,-220}}}, - {"America/La_Paz",75,{{-623,-210},{-626,-223},{-628,-220},{-639,-220},{-643,-229},{-646,-222},{-658,-221},{-662,-218},{-663,-221},{-667,-222},{-672,-228},{-679,-228},{-682,-213},{-685,-209},{-684,-206},{-688,-204},{-688,-201},{-685,-199},{-687,-197},{-684,-194},{-690,-189},{-691,-181},{-693,-180},{-695,-174},{-696,-173},{-688,-163},{-692,-161},{-694,-156},{-691,-153},{-694,-148},{-688,-142},{-691,-137},{-689,-135},{-690,-129},{-687,-125},{-696,-110},{-686,-111},{-680,-107},{-677,-107},{-666,-99},{-658,-97},{-656,-98},{-654,-97},{-653,-102},{-654,-105},{-653,-110},{-654,-113},{-650,-120},{-645,-122},{-643,-125},{-637,-125},{-633,-127},{-631,-127},{-628,-130},{-621,-131},{-618,-135},{-611,-135},{-605,-138},{-603,-151},{-606,-151},{-602,-155},{-602,-163},{-583,-163},{-585,-167},{-584,-172},{-578,-176},{-575,-182},{-581,-198},{-579,-200},{-582,-202},{-582,-198},{-591,-193},{-600,-193},{-617,-196},{-623,-206}}}, - {"America/Recife",33,{{-351,-89},{-351,-88},{-387,-76},{-381,-78},{-372,-73},{-370,-75},{-372,-76},{-373,-80},{-371,-80},{-370,-83},{-364,-78},{-359,-78},{-353,-74},{-348,-76},{-348,-79},{-360,-89},{-364,-92},{-369,-94},{-378,-89},{-382,-93},{-385,-88},{-386,-90},{-394,-85},{-406,-95},{-408,-95},{-407,-92},{-409,-92},{-409,-88},{-414,-87},{-406,-81},{-407,-74},{-396,-74},{-391,-79}}}, - {"America/Mexico_City",94,{{-973,211},{-972,214},{-972,215},{-973,215},{-929,152},{-930,152},{-930,153},{-948,163},{-948,164},{-949,163},{-949,164},{-1057,204},{-972,210},{-1016,176},{-1017,177},{-1016,177},{-961,192},{-960,192},{-941,161},{-940,160},{-947,162},{-946,163},{-951,163},{-951,162},{-949,162},{-948,162},{-952,162},{-954,160},{-965,156},{-978,160},{-988,165},{-997,167},{-1011,173},{-1020,180},{-1022,179},{-1035,183},{-1040,189},{-1050,193},{-1053,206},{-1051,209},{-1048,210},{-1043,207},{-1042,212},{-1040,213},{-1042,215},{-1041,218},{-1044,221},{-1041,234},{-1038,237},{-1039,241},{-1033,245},{-1025,245},{-1027,251},{-1023,252},{-1018,250},{-1016,248},{-1012,248},{-1009,246},{-1004,237},{-1004,232},{-1001,232},{-999,230},{-1000,228},{-994,227},{-992,224},{-989,223},{-982,225},{-978,223},{-973,216},{-974,212},{-972,207},{-964,199},{-963,193},{-959,189},{-948,185},{-945,181},{-925,186},{-924,185},{-922,185},{-922,182},{-919,180},{-915,181},{-910,180},{-910,173},{-914,172},{-904,164},{-904,161},{-917,161},{-922,153},{-921,151},{-922,145},{-939,160},{-939,161},{-944,163}}}, - {"America/Chicago",432,{{-892,301},{-895,301},{-896,302},{-890,302},{-889,302},{-891,302},{-892,302},{-895,302},{-897,301},{-896,301},{-897,302},{-894,301},{-889,304},{-888,304},{-865,304},{-905,469},{-904,469},{-880,305},{-881,305},{-880,306},{-880,307},{-881,303},{-875,303},{-886,303},{-866,304},{-867,304},{-872,303},{-873,303},{-884,304},{-883,303},{-882,303},{-883,304},{-886,304},{-879,307},{-879,306},{-880,308},{-879,308},{-856,301},{-857,301},{-881,302},{-884,302},{-885,302},{-887,302},{-886,302},{-888,302},{-883,302},{-882,302},{-873,452},{-874,452},{-873,450},{-872,452},{-870,453},{-873,448},{-869,453},{-868,454},{-869,454},{-905,470},{-904,471},{-904,470},{-906,470},{-907,470},{-906,471},{-907,471},{-909,470},{-908,470},{-896,480},{-908,468},{-907,469},{-907,468},{-908,467},{-906,469},{-906,468},{-910,470},{-908,469},{-939,299},{-939,300},{-939,298},{-940,298},{-938,300},{-855,300},{-894,300},{-888,300},{-889,300},{-889,301},{-892,300},{-893,300},{-889,298},{-889,299},{-934,298},{-893,298},{-893,299},{-933,298},{-895,298},{-890,298},{-894,299},{-894,298},{-892,298},{-892,299},{-888,299},{-888,298},{-895,300},{-897,300},{-898,301},{-976,269},{-975,269},{-975,268},{-975,270},{-975,271},{-974,271},{-972,278},{-971,278},{-974,268},{-973,263},{-974,263},{-973,264},{-974,264},{-975,264},{-972,264},{-974,265},{-973,265},{-973,266},{-973,267},{-974,267},{-971,279},{-971,280},{-966,283},{-966,284},{-968,281},{-968,282},{-964,284},{-964,283},{-965,284},{-970,279},{-970,280},{-970,278},{-969,281},{-972,261},{-974,269},{-974,272},{-973,277},{-903,291},{-952,291},{-951,291},{-904,290},{-905,291},{-907,291},{-906,291},{-908,292},{-908,291},{-907,292},{-903,292},{-906,292},{-904,291},{-909,291},{-907,290},{-908,290},{-952,290},{-909,290},{-910,291},{-899,293},{-901,293},{-900,292},{-900,293},{-898,293},{-893,293},{-894,293},{-898,294},{-893,294},{-892,295},{-901,294},{-900,294},{-899,294},{-899,295},{-900,295},{-891,295},{-891,296},{-890,296},{-914,295},{-897,296},{-895,295},{-897,295},{-896,295},{-896,296},{-913,294},{-913,295},{-901,295},{-950,296},{-950,297},{-894,297},{-894,296},{-889,297},{-896,297},{-893,297},{-895,297},{-921,297},{-922,297},{-904,292},{-904,293},{-919,296},{-918,296},{-917,296},{-920,296},{-914,296},{-895,296},{-895,294},{-910,292},{-911,292},{-909,292},{-905,293},{-906,293},{-950,292},{-949,293},{-947,293},{-905,292},{-910,293},{-913,293},{-912,294},{-913,292},{-914,293},{-912,293},{-948,293},{-878,385},{-875,385},{-873,382},{-868,382},{-868,379},{-866,379},{-865,380},{-862,378},{-863,376},{-861,374},{-856,375},{-854,372},{-851,373},{-848,370},{-851,369},{-850,366},{-848,366},{-847,364},{-849,362},{-847,359},{-851,356},{-854,350},{-856,350},{-852,329},{-849,323},{-851,318},{-851,312},{-849,307},{-851,302},{-850,298},{-854,300},{-857,302},{-856,302},{-856,303},{-858,303},{-861,304},{-862,305},{-869,304},{-870,306},{-871,304},{-872,306},{-872,304},{-874,303},{-873,304},{-874,305},{-876,303},{-880,302},{-877,303},{-890,305},{-894,304},{-894,302},{-902,304},{-904,302},{-901,300},{-899,300},{-897,299},{-896,300},{-896,298},{-898,296},{-890,292},{-894,289},{-895,292},{-902,296},{-901,292},{-902,291},{-902,292},{-909,293},{-912,296},{-914,297},{-916,295},{-916,297},{-919,297},{-918,298},{-922,298},{-923,295},{-933,301},{-934,299},{-938,297},{-937,300},{-948,294},{-945,296},{-948,295},{-947,298},{-951,296},{-952,292},{-953,289},{-960,287},{-962,286},{-961,288},{-964,286},{-964,287},{-964,288},{-965,286},{-966,288},{-966,286},{-967,283},{-968,285},{-972,281},{-970,281},{-974,278},{-972,277},{-974,273},{-976,273},{-977,274},{-978,275},{-977,273},{-978,273},{-976,268},{-971,260},{-974,258},{-977,260},{-982,261},{-991,264},{-995,270},{-995,276},{-1003,283},{-1007,291},{-1014,298},{-1023,299},{-1027,297},{-1029,292},{-1031,290},{-1042,294},{-1045,297},{-1050,306},{-1049,320},{-1031,320},{-1030,370},{-1020,370},{-1020,377},{-1015,377},{-1016,387},{-1014,396},{-1020,396},{-1020,400},{-1013,400},{-1012,410},{-1014,417},{-1008,417},{-1007,421},{-1009,430},{-1012,430},{-1012,438},{-1011,438},{-1010,442},{-1006,442},{-1004,444},{-1006,445},{-1007,448},{-1004,449},{-1003,452},{-1005,455},{-1003,457},{-1004,459},{-1013,459},{-1013,461},{-1005,465},{-1008,467},{-1010,473},{-1013,473},{-1014,476},{-1025,475},{-1030,477},{-1036,475},{-1040,480},{-1040,490},{-952,490},{-952,494},{-948,493},{-947,488},{-945,487},{-938,485},{-930,486},{-926,485},{-927,485},{-925,484},{-924,482},{-921,484},{-916,480},{-909,482},{-908,481},{-895,480},{-907,476},{-921,468},{-918,467},{-909,466},{-907,467},{-901,463},{-881,459},{-881,458},{-878,457},{-879,454},{-877,454},{-877,452},{-876,451},{-878,449},{-880,445},{-876,449},{-879,432},{-877,428},{-878,423},{-874,417},{-865,418},{-865,416},{-869,412},{-869,409},{-871,407},{-875,407},{-875,394},{-877,391},{-875,387}}}, - {"Asia/Amman",19,{{373,312},{380,305},{377,303},{375,300},{368,299},{361,292},{350,294},{352,304},{355,311},{356,327},{359,327},{361,325},{368,323},{388,334},{390,323},{393,324},{393,322},{390,320},{370,315}}}, - {"America/Tijuana",10,{{-1168,318},{-1147,327},{-1148,325},{-1164,324},{-1165,317},{-1167,317},{-1166,318},{-1171,325},{-1172,324},{-1173,324}}}, - {"America/Metlakatla",8,{{-1316,550},{-1316,551},{-1315,551},{-1316,553},{-1314,552},{-1314,550},{-1316,552},{-1313,552}}}, - {"Pacific/Midway",3,{{-1774,282},{-1773,282},{-1783,284}}}, - {"Europe/Simferopol",32,{{348,462},{350,457},{355,453},{358,455},{366,454},{365,454},{364,451},{355,451},{351,448},{347,448},{341,444},{338,444},{335,445},{334,446},{335,446},{335,451},{330,453},{331,454},{333,455},{329,454},{325,454},{332,458},{337,459},{336,462},{341,461},{342,463},{343,461},{343,462},{345,462},{345,460},{346,462},{335,459}}}, - {"Europe/Budapest",34,{{208,463},{206,461},{196,462},{184,457},{179,458},{173,459},{165,465},{163,468},{161,469},{165,470},{164,474},{167,475},{164,477},{171,477},{170,479},{172,480},{178,477},{187,478},{189,478},{188,480},{195,481},{196,482},{199,481},{203,483},{205,485},{208,486},{215,486},{218,483},{223,484},{226,481},{228,481},{228,478},{220,475},{212,463}}}, - {"Pacific/Apia",11,{{-1714,-141},{-1717,-140},{-1719,-140},{-1721,-139},{-1718,-138},{-1714,-140},{-1721,-138},{-1722,-138},{-1725,-138},{-1728,-135},{-1723,-134}}}, - {"America/Paramaribo",30,{{-543,52},{-545,49},{-544,40},{-540,36},{-544,23},{-547,23},{-549,26},{-554,24},{-559,25},{-561,23},{-559,20},{-560,18},{-567,20},{-572,28},{-573,34},{-577,34},{-581,41},{-579,49},{-572,52},{-573,53},{-571,60},{-571,58},{-569,60},{-559,58},{-558,60},{-551,59},{-550,60},{-540,58},{-540,55},{-552,59}}}, - {"Africa/Malabo",17,{{56,-14},{56,-15},{89,35},{87,32},{84,33},{87,38},{89,37},{93,9},{95,10},{113,17},{113,10},{99,9},{93,12},{98,19},{98,23},{100,22},{113,22}}}, - {"Asia/Riyadh",286,{{423,166},{424,166},{418,167},{419,167},{419,166},{420,166},{352,278},{426,159},{424,161},{423,161},{424,162},{425,163},{424,163},{423,163},{422,163},{420,163},{423,164},{424,164},{425,164},{428,164},{419,164},{421,165},{420,165},{421,166},{426,167},{425,167},{416,167},{417,167},{422,168},{422,164},{391,213},{390,220},{389,219},{390,219},{389,220},{401,199},{401,200},{402,202},{404,200},{401,202},{400,203},{401,203},{395,203},{397,203},{400,202},{396,205},{396,206},{395,208},{409,194},{408,194},{408,195},{407,196},{407,195},{408,196},{406,196},{407,197},{408,197},{406,197},{406,198},{405,198},{390,221},{390,222},{391,223},{389,224},{409,193},{409,191},{409,190},{414,178},{415,181},{415,182},{412,184},{411,185},{411,186},{410,186},{412,188},{412,189},{411,191},{418,171},{417,171},{419,171},{424,170},{417,170},{416,170},{417,169},{418,170},{419,170},{416,181},{420,168},{424,168},{382,239},{352,277},{418,169},{420,167},{421,168},{422,166},{417,168},{418,168},{424,169},{416,169},{416,168},{420,169},{419,168},{409,195},{374,245},{384,235},{382,235},{384,237},{380,238},{379,238},{383,238},{351,278},{382,240},{381,240},{374,244},{360,267},{361,267},{360,268},{359,268},{361,265},{361,266},{360,266},{365,261},{364,262},{365,262},{358,269},{359,269},{358,271},{357,271},{357,272},{354,276},{353,277},{346,279},{345,279},{345,280},{347,280},{347,281},{351,281},{354,277},{351,279},{347,279},{349,279},{352,279},{352,280},{353,278},{353,279},{351,280},{348,281},{350,280},{350,281},{371,250},{371,249},{369,252},{372,249},{372,250},{370,253},{368,253},{366,258},{367,257},{368,257},{366,257},{365,257},{365,258},{366,259},{367,256},{367,254},{366,255},{366,256},{367,255},{365,256},{371,254},{370,254},{369,254},{368,254},{368,255},{370,255},{369,255},{369,256},{368,256},{370,256},{390,227},{366,260},{386,234},{385,235},{385,234},{386,232},{387,233},{387,232},{386,233},{388,229},{389,230},{389,229},{388,231},{388,230},{388,232},{387,231},{389,226},{432,173},{432,167},{427,167},{424,172},{423,174},{418,179},{413,186},{397,204},{392,211},{391,218},{391,217},{390,218},{391,224},{384,238},{379,242},{372,248},{373,249},{372,252},{367,260},{346,281},{350,294},{361,292},{368,299},{375,300},{377,303},{380,305},{370,315},{392,322},{404,319},{421,311},{447,292},{475,290},{477,285},{484,285},{489,278},{489,276},{493,275},{493,274},{492,274},{491,274},{494,271},{496,272},{497,270},{500,268},{502,266},{502,263},{502,260},{500,262},{500,260},{505,254},{508,247},{511,245},{515,246},{513,243},{516,242},{526,229},{552,227},{557,220},{550,200},{520,190},{488,183},{463,156},{463,163},{461,165},{444,174},{439,173},{433,176},{385,236},{384,236},{504,255},{503,256},{498,277},{488,278},{488,277},{487,282},{486,282},{502,265},{502,264},{501,265},{500,266},{501,266},{496,271},{495,271},{495,272},{494,272},{495,273},{495,274},{497,273},{493,272},{494,273}}}, - {"Africa/Ndjamena",59,{{199,91},{189,89},{191,87},{186,81},{177,80},{168,75},{166,79},{158,74},{155,75},{156,78},{152,86},{145,90},{140,96},{142,100},{157,100},{151,105},{150,111},{151,118},{148,126},{146,128},{145,131},{141,131},{136,137},{135,144},{137,146},{144,157},{155,169},{157,198},{160,203},{152,215},{150,230},{160,235},{240,195},{240,157},{231,157},{229,156},{229,151},{227,149},{227,147},{224,145},{226,142},{221,138},{223,133},{218,128},{219,126},{222,128},{225,126},{225,120},{226,120},{226,116},{229,114},{230,111},{229,109},{225,110},{218,108},{217,103},{210,97},{208,94},{204,92}}}, - {"Asia/Choibalsan",43,{{1167,463},{1163,460},{1162,457},{1157,454},{1146,454},{1136,448},{1121,451},{1119,456},{1119,460},{1115,462},{1114,465},{1116,472},{1120,474},{1122,478},{1127,478},{1124,491},{1125,495},{1131,496},{1132,498},{1143,503},{1150,502},{1154,499},{1162,500},{1167,498},{1158,485},{1158,483},{1155,482},{1155,480},{1159,477},{1163,479},{1168,479},{1174,476},{1178,480},{1185,480},{1199,472},{1197,472},{1199,467},{1195,464},{1193,467},{1185,468},{1178,465},{1174,466},{1174,463}}}, - {"America/Antigua",10,{{-623,169},{-624,169},{-617,171},{-617,176},{-619,176},{-619,177},{-618,172},{-617,170},{-619,170},{-617,172}}}, - {"Europe/Istanbul",205,{{283,368},{282,368},{276,370},{264,384},{294,362},{305,362},{297,361},{298,361},{299,362},{298,362},{304,362},{338,362},{271,376},{272,376},{274,370},{275,370},{274,372},{275,367},{278,365},{279,365},{278,366},{278,367},{279,367},{279,366},{280,367},{289,367},{290,367},{291,367},{281,367},{284,368},{275,371},{275,372},{260,398},{261,398},{261,399},{257,401},{258,402},{260,402},{260,401},{270,406},{262,401},{262,403},{268,406},{261,406},{260,407},{264,410},{263,413},{266,414},{266,416},{263,418},{266,420},{273,421},{276,419},{280,420},{280,418},{282,415},{291,412},{288,410},{285,411},{275,410},{281,405},{277,405},{276,405},{275,405},{275,406},{285,405},{285,406},{286,406},{276,406},{275,407},{277,406},{291,409},{291,408},{292,409},{290,409},{265,384},{263,384},{264,385},{267,385},{268,385},{268,384},{269,384},{269,385},{267,387},{268,386},{367,368},{366,365},{367,363},{364,362},{362,358},{359,359},{358,363},{362,366},{360,369},{353,365},{347,368},{340,362},{339,363},{337,361},{328,360},{324,362},{320,365},{310,369},{306,368},{302,363},{291,364},{289,368},{288,366},{285,369},{280,366},{281,368},{277,367},{274,367},{280,368},{280,369},{283,371},{273,370},{273,371},{276,373},{275,373},{274,374},{272,374},{270,377},{272,377},{273,380},{262,383},{264,387},{267,383},{267,384},{272,385},{270,384},{271,389},{268,389},{269,391},{266,393},{270,396},{261,395},{268,404},{273,405},{278,403},{279,404},{278,405},{280,405},{280,404},{291,404},{292,404},{288,405},{299,407},{293,408},{290,410},{292,412},{312,411},{314,413},{326,418},{333,420},{347,419},{349,421},{352,420},{351,419},{353,417},{360,417},{364,413},{368,414},{375,410},{377,411},{384,409},{394,411},{402,409},{415,415},{425,414},{428,416},{437,409},{437,407},{435,405},{437,401},{444,400},{448,397},{446,398},{444,394},{440,394},{443,388},{443,384},{445,383},{442,379},{446,378},{446,374},{448,373},{448,371},{446,372},{443,370},{441,373},{438,372},{428,374},{426,371},{424,371},{422,373},{416,371},{408,371},{392,367},{383,369},{375,366},{371,366},{266,394},{267,394},{268,394}}}, - {"Africa/Blantyre",39,{{349,-135},{359,-149},{358,-152},{358,-160},{354,-161},{351,-166},{353,-171},{351,-171},{352,-168},{344,-163},{343,-159},{346,-153},{345,-146},{344,-144},{337,-146},{333,-140},{332,-139},{330,-140},{327,-136},{330,-132},{330,-127},{335,-124},{333,-121},{332,-114},{334,-112},{332,-109},{337,-106},{333,-101},{332,-96},{330,-96},{330,-94},{339,-97},{340,-95},{345,-100},{346,-110},{350,-116},{346,-116},{344,-123},{345,-134}}}, - {"Australia/Sydney",108,{{1516,-331},{1512,-335},{1512,-336},{1522,-328},{1522,-327},{1520,-327},{1521,-327},{1502,-363},{1502,-362},{1508,-351},{1507,-351},{1505,-352},{1503,-357},{1501,-357},{1502,-357},{1501,-356},{1502,-356},{1502,-358},{1501,-359},{1501,-363},{1499,-369},{1500,-373},{1500,-375},{1481,-368},{1482,-366},{1479,-360},{1474,-360},{1469,-361},{1451,-358},{1450,-359},{1450,-361},{1447,-361},{1434,-352},{1433,-348},{1428,-346},{1425,-348},{1424,-343},{1420,-341},{1415,-342},{1410,-341},{1410,-322},{1418,-323},{1420,-316},{1410,-315},{1410,-290},{1490,-290},{1495,-286},{1503,-285},{1510,-287},{1514,-292},{1516,-289},{1520,-289},{1520,-285},{1525,-283},{1531,-284},{1532,-283},{1534,-283},{1535,-282},{1536,-282},{1536,-289},{1534,-294},{1533,-294},{1534,-295},{1530,-307},{1531,-309},{1529,-315},{1525,-322},{1524,-322},{1525,-323},{1526,-322},{1525,-325},{1520,-325},{1519,-327},{1519,-328},{1521,-328},{1518,-329},{1518,-328},{1517,-328},{1517,-329},{1515,-331},{1517,-331},{1514,-335},{1513,-336},{1513,-334},{1512,-334},{1511,-335},{1510,-334},{1509,-334},{1509,-335},{1511,-336},{1511,-337},{1512,-337},{1513,-338},{1512,-338},{1511,-338},{1513,-339},{1510,-340},{1512,-340},{1508,-345},{1509,-346},{1508,-349},{1507,-349},{1506,-349},{1508,-350},{1523,-326},{1530,-308},{1530,-309},{1535,-283}}}, - {"Asia/Dushanbe",80,{{694,372},{692,371},{689,373},{680,369},{678,371},{679,375},{684,382},{681,385},{682,389},{677,390},{674,393},{675,393},{674,395},{677,397},{685,395},{688,400},{689,399},{688,401},{690,401},{685,401},{693,402},{692,405},{694,408},{697,406},{704,410},{708,407},{704,404},{706,402},{710,402},{705,399},{706,400},{700,402},{695,401},{695,399},{694,400},{693,398},{694,395},{705,396},{709,394},{715,396},{716,395},{718,394},{718,393},{720,394},{722,392},{725,394},{737,395},{736,393},{738,390},{737,389},{738,386},{741,385},{741,387},{744,387},{749,385},{748,382},{750,378},{749,377},{751,374},{749,372},{744,374},{737,372},{736,373},{738,374},{733,375},{727,370},{717,367},{714,371},{716,379},{712,379},{714,383},{710,385},{707,384},{702,379},{703,377},{702,375},{695,376},{694,374},{707,399},{706,398}}}, - {"Europe/Belgrade",41,{{214,450},{216,449},{214,448},{221,445},{225,447},{228,446},{225,445},{227,442},{224,438},{225,435},{230,431},{224,428},{226,425},{225,423},{214,423},{212,421},{211,422},{206,419},{205,422},{202,423},{200,427},{203,429},{192,435},{195,436},{192,440},{196,441},{191,444},{194,449},{190,449},{192,450},{191,451},{194,452},{190,454},{191,455},{189,456},{189,459},{196,462},{202,462},{208,458},{208,455},{215,452}}}, - {"Asia/Karachi",159,{{664,255},{664,256},{662,255},{662,256},{663,256},{681,238},{682,238},{681,237},{680,237},{674,240},{674,241},{673,244},{674,244},{673,248},{672,248},{666,249},{639,251},{638,251},{641,254},{665,255},{673,245},{674,245},{672,245},{672,246},{673,246},{674,246},{671,247},{672,247},{673,247},{674,247},{671,248},{702,279},{696,272},{695,268},{702,266},{701,259},{703,257},{707,257},{707,254},{711,247},{710,244},{711,244},{708,242},{706,242},{706,244},{700,242},{688,243},{687,240},{680,239},{680,238},{679,240},{677,238},{674,239},{674,242},{673,243},{674,243},{675,243},{675,248},{667,248},{667,252},{666,254},{665,256},{661,255},{665,254},{648,253},{647,252},{640,255},{641,253},{636,254},{635,252},{626,253},{624,251},{622,252},{617,250},{618,252},{616,252},{618,262},{623,264},{624,266},{632,266},{633,271},{628,272},{628,283},{618,286},{609,299},{625,294},{636,295},{641,294},{644,295},{651,295},{663,299},{664,309},{667,312},{678,313},{676,315},{682,318},{685,317},{684,318},{686,318},{689,316},{693,319},{692,325},{695,327},{695,330},{703,333},{699,340},{705,339},{711,341},{712,344},{710,346},{717,352},{715,357},{712,361},{722,368},{731,369},{741,368},{747,371},{749,369},{751,370},{754,369},{755,367},{759,366},{761,362},{759,361},{762,358},{766,359},{768,357},{772,355},{778,355},{770,349},{767,349},{767,348},{757,345},{744,348},{740,347},{738,344},{740,343},{739,340},{743,340},{740,337},{742,335},{740,332},{745,327},{747,328},{747,325},{751,325},{754,322},{745,318},{746,315},{745,312},{747,311},{739,305},{740,302},{734,299},{729,290},{724,288},{719,280},{709,277},{705,280}}}, - {"Europe/Luxembourg",7,{{62,495},{58,495},{59,497},{57,499},{60,502},{65,498},{64,495}}}, - {"Europe/Podgorica",20,{{188,423},{189,423},{189,435},{192,435},{196,432},{203,429},{200,427},{201,427},{200,425},{198,425},{197,427},{196,426},{193,422},{194,419},{185,424},{187,424},{188,425},{184,425},{187,433},{191,433}}}, - {"Australia/Lindeman",8,{{1490,-204},{1491,-204},{1491,-205},{1490,-205},{1489,-204},{1489,-203},{1489,-201},{1489,-200}}}, - {"Africa/Bangui",61,{{245,51},{234,46},{229,48},{225,42},{223,41},{206,44},{198,51},{194,51},{185,43},{186,35},{185,37},{182,35},{175,37},{167,35},{162,22},{160,30},{152,37},{151,40},{152,41},{151,43},{147,46},{147,52},{145,53},{146,59},{144,60},{148,63},{155,75},{160,75},{166,79},{168,75},{177,80},{186,81},{191,87},{189,89},{204,92},{217,102},{218,108},{225,110},{229,109},{237,99},{237,93},{234,90},{236,90},{235,87},{243,87},{242,83},{249,82},{252,79},{252,75},{264,67},{263,65},{265,62},{265,61},{272,58},{275,50},{271,52},{269,50},{265,50},{255,54},{251,49},{247,49}}}, - {"Asia/Aden",84,{{533,121},{532,121},{523,122},{521,122},{524,122},{545,125},{538,123},{533,125},{535,127},{531,121},{530,121},{530,122},{531,122},{434,126},{434,127},{432,133},{447,127},{418,156},{419,155},{418,155},{420,152},{421,152},{421,151},{422,151},{422,150},{421,150},{425,155},{424,155},{423,157},{425,157},{425,156},{426,156},{424,157},{426,157},{430,145},{429,145},{429,146},{427,139},{427,140},{427,136},{427,137},{428,137},{451,129},{451,128},{446,128},{443,126},{435,127},{429,149},{428,152},{426,152},{427,154},{428,153},{427,157},{428,160},{428,164},{433,168},{431,169},{433,173},{433,176},{439,173},{444,174},{463,163},{463,156},{488,183},{520,190},{531,167},{523,163},{522,156},{493,146},{487,140},{480,140},{474,136},{467,134},{457,133},{485,140},{483,140},{428,138},{428,139},{428,141},{428,140},{426,154},{426,153},{426,155},{426,158}}}, - {"Pacific/Chuuk",40,{{1518,73},{1537,53},{1538,55},{1536,56},{1493,67},{1519,71},{1519,72},{1520,72},{1519,73},{1439,73},{1438,73},{1439,74},{1517,74},{1517,73},{1518,74},{1516,74},{1516,73},{1470,74},{1519,74},{1519,75},{1518,75},{1476,81},{1517,84},{1519,86},{1520,86},{1497,86},{1514,86},{1504,86},{1522,86},{1523,87},{1503,87},{1503,88},{1501,90},{1381,96},{1382,96},{1381,94},{1381,95},{1405,98},{1397,99},{1398,100}}}, - {"Asia/Brunei",12,{{1141,46},{1144,47},{1149,50},{1151,50},{1148,47},{1149,44},{1147,40},{1152,49},{1153,47},{1153,43},{1151,44},{1150,48}}}, - {"Indian/Comoro",13,{{437,-124},{436,-124},{445,-121},{445,-124},{442,-122},{444,-122},{433,-114},{434,-114},{435,-119},{432,-118},{437,-123},{438,-123},{439,-124}}}, - {"America/Asuncion",42,{{-547,-262},{-548,-267},{-554,-270},{-557,-274},{-561,-273},{-564,-276},{-566,-274},{-569,-276},{-580,-273},{-586,-273},{-586,-271},{-582,-266},{-582,-262},{-578,-260},{-578,-257},{-576,-256},{-577,-253},{-591,-246},{-600,-240},{-610,-238},{-620,-230},{-623,-225},{-626,-223},{-623,-211},{-623,-206},{-617,-196},{-600,-193},{-591,-193},{-582,-198},{-582,-202},{-578,-210},{-580,-221},{-568,-223},{-564,-221},{-562,-223},{-559,-223},{-556,-227},{-557,-230},{-555,-232},{-554,-240},{-547,-238},{-543,-241}}}, - {"Europe/Prague",35,{{150,490},{150,488},{148,488},{147,486},{141,486},{127,494},{124,498},{125,499},{121,503},{123,502},{125,504},{144,509},{143,511},{148,508},{152,510},{154,508},{163,507},{164,506},{162,504},{166,501},{170,502},{169,504},{174,503},{177,503},{178,502},{176,502},{178,500},{186,499},{189,495},{182,493},{177,489},{171,488},{169,486},{165,488},{161,487}}}, - {"America/Cayman",9,{{-813,193},{-814,193},{-814,194},{-811,194},{-800,197},{-801,197},{-799,197},{-797,198},{-798,197}}}, - {"Pacific/Pohnpei",15,{{1572,58},{1571,58},{1607,62},{1598,67},{1580,67},{1579,67},{1580,68},{1584,69},{1583,69},{1583,70},{1578,71},{1582,70},{1583,68},{1582,68},{1581,69}}}, - {"America/Atikokan",12,{{-900,480},{-908,481},{-909,482},{-916,480},{-920,483},{-920,484},{-923,485},{-918,487},{-918,490},{-910,490},{-910,485},{-900,482}}}, - {"America/Pangnirtung",882,{{-659,591},{-661,584},{-670,584},{-670,585},{-675,584},{-675,583},{-677,583},{-676,584},{-679,585},{-667,585},{-667,586},{-673,586},{-665,587},{-665,588},{-663,589},{-663,588},{-660,589},{-661,590},{-659,590},{-661,588},{-661,589},{-656,590},{-656,591},{-655,591},{-657,591},{-658,592},{-656,592},{-658,591},{-658,590},{-658,593},{-654,593},{-656,593},{-657,593},{-655,594},{-656,594},{-655,595},{-680,606},{-678,605},{-680,603},{-656,595},{-654,594},{-674,621},{-675,621},{-655,616},{-650,614},{-649,614},{-649,613},{-648,613},{-647,614},{-648,618},{-649,618},{-662,619},{-652,617},{-653,618},{-652,618},{-659,618},{-659,617},{-653,617},{-658,618},{-658,617},{-657,618},{-656,617},{-660,621},{-659,621},{-657,617},{-658,619},{-654,617},{-648,617},{-655,617},{-648,614},{-647,617},{-651,617},{-641,625},{-642,625},{-666,619},{-653,619},{-649,619},{-650,619},{-658,620},{-672,621},{-660,620},{-669,620},{-659,620},{-661,620},{-667,620},{-650,618},{-652,619},{-679,621},{-673,621},{-680,622},{-661,622},{-661,623},{-643,624},{-650,625},{-644,624},{-643,625},{-647,624},{-647,623},{-646,624},{-647,625},{-645,626},{-649,625},{-676,621},{-675,622},{-646,642},{-647,642},{-648,642},{-645,643},{-646,643},{-659,622},{-658,621},{-679,622},{-678,622},{-648,625},{-651,625},{-644,625},{-643,626},{-643,639},{-642,637},{-642,638},{-644,638},{-643,637},{-644,637},{-643,638},{-641,638},{-642,639},{-644,640},{-643,640},{-642,640},{-644,639},{-641,639},{-648,641},{-649,642},{-651,642},{-648,643},{-647,643},{-645,642},{-650,644},{-649,643},{-650,642},{-651,643},{-648,644},{-647,644},{-651,644},{-645,638},{-646,638},{-645,639},{-650,641},{-651,641},{-649,641},{-649,640},{-648,640},{-646,641},{-647,641},{-645,641},{-644,641},{-652,642},{-650,645},{-652,645},{-651,645},{-653,645},{-653,646},{-651,646},{-652,646},{-650,646},{-649,646},{-655,647},{-652,647},{-653,647},{-654,647},{-655,648},{-654,646},{-657,645},{-654,648},{-638,628},{-639,628},{-649,626},{-649,627},{-670,627},{-669,627},{-655,628},{-637,629},{-646,628},{-647,629},{-648,628},{-648,629},{-647,628},{-664,628},{-663,628},{-657,629},{-658,629},{-651,629},{-668,629},{-665,630},{-667,629},{-666,629},{-665,629},{-664,629},{-650,629},{-659,629},{-660,629},{-661,629},{-645,632},{-646,632},{-647,632},{-648,633},{-670,632},{-680,632},{-679,632},{-677,632},{-671,632},{-678,632},{-639,634},{-640,634},{-680,634},{-680,635},{-675,635},{-675,634},{-676,634},{-650,634},{-651,634},{-679,634},{-641,635},{-666,630},{-642,633},{-644,634},{-645,636},{-640,633},{-650,636},{-649,635},{-648,634},{-651,636},{-677,636},{-676,636},{-640,635},{-676,635},{-643,636},{-641,637},{-640,636},{-639,636},{-642,635},{-642,636},{-668,630},{-641,636},{-646,633},{-679,633},{-678,633},{-674,633},{-675,633},{-680,633},{-660,630},{-651,630},{-669,630},{-675,630},{-670,630},{-677,631},{-678,631},{-671,631},{-669,631},{-670,631},{-648,626},{-679,631},{-680,630},{-676,631},{-678,630},{-678,629},{-676,629},{-674,630},{-670,626},{-666,626},{-663,623},{-662,623},{-661,621},{-662,621},{-659,619},{-640,637},{-648,638},{-634,669},{-635,669},{-614,665},{-615,665},{-677,664},{-678,664},{-671,665},{-672,665},{-668,664},{-669,664},{-670,665},{-669,665},{-668,665},{-624,669},{-624,670},{-623,670},{-632,670},{-620,670},{-619,670},{-627,670},{-626,670},{-632,671},{-630,671},{-631,671},{-628,671},{-626,672},{-625,672},{-631,670},{-625,670},{-625,671},{-624,671},{-631,669},{-630,670},{-674,663},{-622,671},{-623,671},{-621,671},{-629,671},{-628,670},{-624,672},{-639,673},{-640,673},{-634,673},{-639,674},{-638,674},{-637,673},{-636,674},{-637,674},{-639,675},{-640,676},{-639,676},{-637,675},{-640,675},{-649,678},{-650,678},{-649,679},{-648,679},{-647,679},{-654,679},{-659,680},{-660,680},{-652,680},{-653,680},{-653,681},{-661,682},{-662,682},{-668,682},{-667,682},{-666,682},{-662,681},{-655,681},{-656,681},{-657,682},{-656,682},{-661,680},{-662,680},{-654,680},{-655,680},{-654,681},{-659,682},{-658,681},{-657,680},{-658,680},{-621,660},{-621,661},{-620,661},{-668,685},{-672,661},{-669,661},{-670,661},{-671,661},{-673,662},{-672,662},{-662,661},{-663,661},{-663,662},{-623,662},{-675,662},{-676,662},{-676,663},{-671,662},{-618,663},{-617,663},{-621,662},{-621,663},{-620,663},{-664,662},{-672,663},{-673,663},{-671,663},{-677,663},{-675,663},{-676,664},{-675,664},{-669,663},{-670,663},{-671,664},{-670,664},{-672,664},{-667,663},{-668,663},{-666,663},{-662,662},{-622,662},{-624,662},{-623,663},{-629,655},{-630,656},{-626,656},{-626,657},{-625,655},{-625,656},{-624,656},{-628,655},{-629,656},{-628,656},{-623,659},{-658,658},{-658,659},{-679,659},{-680,659},{-677,659},{-657,659},{-673,659},{-676,659},{-680,660},{-622,659},{-622,660},{-671,660},{-669,659},{-670,660},{-669,660},{-621,658},{-622,658},{-621,659},{-674,659},{-659,659},{-671,659},{-672,659},{-672,660},{-673,657},{-672,657},{-623,656},{-625,657},{-621,657},{-623,657},{-677,657},{-678,657},{-622,657},{-680,658},{-675,658},{-674,658},{-673,658},{-678,658},{-675,657},{-676,658},{-677,658},{-674,657},{-658,657},{-659,657},{-659,658},{-676,657},{-672,658},{-679,658},{-656,658},{-656,659},{-655,659},{-655,658},{-673,686},{-674,686},{-679,686},{-678,686},{-670,686},{-669,686},{-677,687},{-674,687},{-679,687},{-680,688},{-676,687},{-676,688},{-675,688},{-675,687},{-674,688},{-678,688},{-677,688},{-679,688},{-677,689},{-675,689},{-678,689},{-676,689},{-679,689},{-680,689},{-676,690},{-676,691},{-675,691},{-675,695},{-677,695},{-673,696},{-676,695},{-677,696},{-678,691},{-679,691},{-680,695},{-672,695},{-666,692},{-677,692},{-680,693},{-675,690},{-680,691},{-677,690},{-680,690},{-676,686},{-680,686},{-677,686},{-672,700},{-673,700},{-680,703},{-674,701},{-671,697},{-680,698},{-680,813},{-651,815},{-645,815},{-680,808},{-680,815},{-671,816},{-667,815},{-680,814},{-678,827},{-679,827},{-680,827},{-677,827},{-673,827},{-671,828},{-672,827},{-646,829},{-644,829},{-645,829},{-673,828},{-672,828},{-680,830},{-671,830},{-664,829},{-650,817},{-648,817},{-652,817},{-666,816},{-669,816},{-663,816},{-667,683},{-665,683},{-666,683},{-667,684},{-668,684},{-666,684},{-658,829},{-655,828},{-652,828},{-654,828},{-648,829},{-645,828},{-635,828},{-640,827},{-630,826},{-634,824},{-623,825},{-624,825},{-611,823},{-644,817},{-680,816},{-678,696},{-679,695},{-680,697},{-678,697},{-677,697},{-664,682},{-662,683},{-663,681},{-661,683},{-668,683},{-669,683},{-670,683},{-663,683},{-664,683},{-670,685},{-669,685},{-669,684},{-670,684},{-679,685},{-678,685},{-667,685},{-667,686},{-666,686},{-674,685},{-671,685},{-672,685},{-673,685},{-675,685},{-675,686},{-671,686},{-634,649},{-634,650},{-633,649},{-634,652},{-667,652},{-668,653},{-667,653},{-630,653},{-631,653},{-632,653},{-633,652},{-633,653},{-667,649},{-667,650},{-666,649},{-662,650},{-666,651},{-667,651},{-666,650},{-640,650},{-640,651},{-639,651},{-639,650},{-669,651},{-669,652},{-644,651},{-644,652},{-642,652},{-666,652},{-670,652},{-651,652},{-650,652},{-671,653},{-672,653},{-670,653},{-669,653},{-668,652},{-669,654},{-664,649},{-663,649},{-661,649},{-662,649},{-680,655},{-673,655},{-675,655},{-670,654},{-674,653},{-672,652},{-671,650},{-669,650},{-668,650},{-667,647},{-664,647},{-663,646},{-662,647},{-660,648},{-660,647},{-658,646},{-659,649},{-657,648},{-657,647},{-653,644},{-652,643},{-656,643},{-657,643},{-650,640},{-652,640},{-647,640},{-646,640},{-650,638},{-645,637},{-647,637},{-645,634},{-646,634},{-647,634},{-645,633},{-648,635},{-651,638},{-653,638},{-649,632},{-650,633},{-651,633},{-651,632},{-648,631},{-650,631},{-646,629},{-653,630},{-652,626},{-654,627},{-652,628},{-653,628},{-653,629},{-657,630},{-658,630},{-661,630},{-662,632},{-665,631},{-665,632},{-667,633},{-665,634},{-668,633},{-668,631},{-669,633},{-669,634},{-671,633},{-676,637},{-679,638},{-677,634},{-680,636},{-633,654},{-634,653},{-668,654},{-648,654},{-649,654},{-670,655},{-669,655},{-632,654},{-635,654},{-636,654},{-668,655},{-633,655},{-680,656},{-679,656},{-674,655},{-672,656},{-673,656},{-655,655},{-656,656},{-655,656},{-635,656},{-634,656},{-671,656},{-631,656},{-632,656},{-672,655},{-671,655},{-630,655},{-656,655},{-632,655},{-631,655},{-680,657},{-680,685},{-679,684},{-676,685},{-676,684},{-674,684},{-678,683},{-679,683},{-676,682},{-670,680},{-667,681},{-667,679},{-666,681},{-665,681},{-663,680},{-664,679},{-665,678},{-668,679},{-664,678},{-661,679},{-659,679},{-660,676},{-656,678},{-653,676},{-647,680},{-651,679},{-652,678},{-652,677},{-652,676},{-645,678},{-643,677},{-644,677},{-646,677},{-646,676},{-645,675},{-648,674},{-642,673},{-648,672},{-646,671},{-647,670},{-634,672},{-638,670},{-638,669},{-631,673},{-630,672},{-633,671},{-636,668},{-638,668},{-634,667},{-633,669},{-629,666},{-628,669},{-623,667},{-620,671},{-621,669},{-618,670},{-617,669},{-618,669},{-619,669},{-620,669},{-616,669},{-618,668},{-613,666},{-620,667},{-622,666},{-618,666},{-616,665},{-620,664},{-616,664},{-615,663},{-626,664},{-627,664},{-627,662},{-628,663},{-629,663},{-619,660},{-623,660},{-629,661},{-630,661},{-624,660},{-623,658},{-628,659},{-628,658},{-627,656},{-629,657},{-635,659},{-633,657},{-637,657},{-633,656},{-637,656},{-634,654},{-635,655},{-637,655},{-635,652},{-633,651},{-635,650},{-636,650},{-635,649},{-638,650},{-637,650},{-638,652},{-641,650},{-643,651},{-641,652},{-642,654},{-646,651},{-647,651},{-646,652},{-649,653},{-647,653},{-644,654},{-644,655},{-652,654},{-647,656},{-653,656},{-648,657},{-655,657},{-653,659},{-647,660},{-648,660},{-648,662},{-644,663},{-643,663},{-647,663},{-648,661},{-660,660},{-655,662},{-655,664},{-660,661},{-661,663},{-665,662},{-664,664},{-667,665},{-667,666},{-672,667},{-668,666},{-675,667},{-679,666},{-673,665},{-674,664},{-680,665},{-678,662},{-677,662},{-677,661},{-678,659}}}, - {"Pacific/Norfolk",4,{{1679,-291},{1680,-291},{1680,-290},{1679,-290}}}, - {"Africa/Dakar",49,{{-175,147},{-175,146},{-168,139},{-167,138},{-166,138},{-168,131},{-158,132},{-158,133},{-153,134},{-151,136},{-144,132},{-138,134},{-140,136},{-143,135},{-151,138},{-155,136},{-166,136},{-166,137},{-165,139},{-167,140},{-168,138},{-172,146},{-171,149},{-169,152},{-163,165},{-144,167},{-138,161},{-134,161},{-132,156},{-122,147},{-122,144},{-119,139},{-121,137},{-118,133},{-116,134},{-114,130},{-114,125},{-124,123},{-129,125},{-131,125},{-131,126},{-152,127},{-157,124},{-167,123},{-168,125},{-164,126},{-168,126},{-167,136},{-167,137}}}, - {"Indian/Kerguelen",107,{{697,-495},{698,-495},{695,-492},{694,-492},{697,-492},{691,-495},{691,-496},{703,-495},{689,-500},{695,-500},{695,-499},{688,-498},{696,-492},{697,-491},{696,-490},{697,-490},{690,-490},{695,-490},{687,-488},{688,-486},{688,-485},{688,-484},{522,-464},{523,-464},{521,-464},{503,-461},{502,-461},{504,-464},{517,-464},{518,-464},{519,-464},{517,-465},{504,-460},{505,-460},{775,-387},{776,-387},{775,-379},{775,-378},{776,-378},{687,-486},{686,-487},{686,-486},{693,-490},{694,-489},{692,-491},{692,-490},{688,-490},{688,-489},{696,-489},{695,-489},{696,-488},{695,-487},{692,-487},{692,-489},{691,-490},{694,-488},{687,-497},{698,-497},{697,-497},{698,-496},{694,-496},{697,-496},{692,-496},{693,-496},{700,-496},{699,-495},{702,-495},{701,-495},{700,-495},{700,-494},{689,-494},{704,-494},{688,-493},{688,-494},{687,-493},{699,-494},{698,-494},{693,-492},{697,-493},{703,-491},{706,-492},{703,-494},{696,-494},{701,-496},{703,-496},{703,-497},{702,-497},{699,-497},{695,-496},{693,-495},{692,-495},{691,-497},{688,-497},{689,-495},{689,-493},{688,-492},{689,-491},{687,-491},{689,-490},{689,-487},{691,-487},{690,-488},{689,-489},{691,-488},{692,-488},{690,-491},{695,-491}}}, - {"Europe/Rome",228,{{122,453},{150,384},{149,384},{126,355},{125,355},{128,359},{129,359},{120,367},{119,368},{121,368},{124,378},{124,379},{125,379},{132,387},{152,388},{85,391},{83,391},{82,392},{83,392},{96,391},{96,392},{123,379},{123,380},{121,380},{120,380},{121,379},{150,385},{149,385},{144,385},{143,385},{146,386},{145,386},{151,386},{151,387},{148,386},{149,386},{155,421},{111,422},{111,423},{179,400},{179,401},{172,404},{171,405},{172,405},{142,405},{142,406},{143,406},{143,405},{139,407},{139,408},{140,407},{140,408},{97,400},{95,391},{91,392},{89,389},{86,389},{84,390},{84,395},{86,399},{84,399},{85,403},{83,406},{82,406},{82,410},{85,408},{92,413},{95,412},{95,410},{96,410},{97,410},{95,409},{97,408},{98,405},{96,403},{134,408},{97,409},{130,409},{129,409},{128,409},{129,410},{125,455},{125,456},{157,383},{151,375},{153,370},{151,367},{145,368},{143,370},{138,371},{132,375},{127,376},{127,382},{129,380},{133,382},{137,380},{124,380},{83,411},{94,413},{93,413},{93,412},{94,412},{131,410},{130,410},{98,440},{98,441},{99,441},{99,440},{98,430},{98,431},{99,434},{123,448},{136,457},{135,457},{134,457},{133,457},{132,457},{126,455},{126,456},{122,454},{124,454},{123,455},{124,455},{123,453},{123,454},{123,452},{103,423},{103,424},{166,401},{165,397},{172,394},{172,390},{166,388},{166,384},{161,379},{157,379},{156,382},{159,384},{158,386},{162,389},{157,400},{153,400},{149,402},{150,404},{148,407},{145,407},{137,413},{130,412},{116,423},{111,424},{112,425},{111,426},{107,429},{105,429},{105,433},{100,441},{87,444},{81,439},{75,438},{77,442},{70,442},{68,445},{71,447},{70,448},{66,451},{71,452},{72,454},{68,458},{79,459},{84,465},{85,463},{88,461},{90,458},{93,465},{95,465},{95,463},{99,464},{101,462},{101,465},{105,465},{105,469},{110,468},{112,470},{122,471},{121,469},{124,467},{137,465},{134,463},{137,462},{135,460},{136,460},{136,458},{139,456},{135,458},{131,458},{131,456},{121,454},{124,450},{125,450},{123,444},{127,440},{136,436},{140,427},{147,421},{155,419},{153,419},{161,419},{162,418},{159,416},{160,415},{180,406},{185,401},{183,398},{180,399},{179,403},{124,419},{125,419},{124,440},{125,439},{125,440},{102,427},{101,428},{104,429},{104,427},{109,423},{109,424},{101,426},{100,426}}}, - {"America/Argentina/Buenos_Aires",67,{{-584,-343},{-584,-342},{-582,-342},{-583,-342},{-584,-340},{-623,-390},{-623,-389},{-622,-389},{-623,-388},{-621,-390},{-620,-391},{-620,-390},{-624,-388},{-585,-345},{-585,-344},{-585,-343},{-622,-390},{-622,-405},{-622,-404},{-621,-404},{-624,-403},{-623,-403},{-624,-402},{-621,-402},{-621,-401},{-623,-400},{-622,-399},{-621,-399},{-623,-393},{-623,-399},{-620,-392},{-620,-393},{-622,-392},{-621,-393},{-621,-392},{-619,-391},{-619,-392},{-600,-335},{-586,-341},{-586,-343},{-575,-351},{-571,-354},{-574,-357},{-574,-360},{-569,-364},{-567,-363},{-567,-369},{-574,-377},{-576,-381},{-582,-384},{-611,-390},{-619,-390},{-622,-388},{-620,-394},{-621,-394},{-622,-393},{-621,-398},{-625,-403},{-622,-406},{-623,-409},{-628,-410},{-634,-407},{-634,-344},{-617,-344},{-609,-336},{-605,-336},{-603,-333}}}, - {"America/Edmonton",33,{{-1141,490},{-1157,490},{-1163,495},{-1167,495},{-1167,499},{-1164,500},{-1167,505},{-1166,506},{-1172,510},{-1173,513},{-1172,513},{-1180,515},{-1179,517},{-1182,518},{-1181,519},{-1187,522},{-1182,524},{-1184,529},{-1189,532},{-1192,532},{-1199,535},{-1197,536},{-1200,538},{-1200,600},{-1100,600},{-1100,536},{-1096,536},{-1088,530},{-1089,528},{-1092,529},{-1094,527},{-1100,527},{-1100,490}}}, - {"America/Barbados",4,{{-596,133},{-594,132},{-595,130},{-596,131}}}, - {"America/Santo_Domingo",38,{{-716,175},{-687,181},{-688,182},{-686,181},{-715,176},{-715,175},{-716,176},{-708,183},{-690,183},{-690,184},{-709,183},{-711,183},{-711,181},{-714,176},{-717,178},{-717,183},{-720,186},{-717,187},{-719,189},{-716,192},{-718,193},{-717,199},{-710,199},{-703,196},{-700,197},{-697,193},{-692,193},{-692,192},{-696,192},{-696,191},{-688,190},{-683,186},{-686,182},{-699,185},{-702,182},{-706,182},{-707,184},{-692,190}}}, - {"Asia/Kuwait",24,{{481,299},{484,294},{483,294},{483,295},{479,294},{479,293},{481,292},{484,285},{477,285},{475,290},{466,291},{471,300},{474,301},{480,300},{482,295},{477,294},{480,294},{481,298},{480,298},{482,300},{484,298},{482,296},{480,299},{481,300}}}, - {"Asia/Bishkek",70,{{748,405},{749,403},{739,400},{739,395},{725,394},{722,392},{720,394},{718,393},{718,394},{716,395},{715,396},{708,394},{705,396},{694,395},{693,398},{694,400},{695,399},{695,401},{700,402},{706,400},{705,399},{711,403},{717,401},{722,405},{724,404},{724,406},{726,405},{731,408},{722,410},{722,412},{719,412},{719,413},{717,416},{714,411},{708,412},{707,415},{702,415},{713,422},{709,423},{713,428},{719,428},{735,424},{736,430},{743,432},{752,428},{757,428},{759,430},{785,429},{792,428},{795,425},{799,424},{803,422},{803,421},{799,420},{797,418},{794,418},{784,414},{782,411},{769,410},{763,404},{763,405},{757,403},{756,407},{752,404},{711,400},{711,399},{712,399},{710,402},{707,399},{706,398}}}, - {"Europe/Moscow",1428,{{477,439},{476,440},{479,440},{478,439},{469,444},{475,444},{475,445},{470,445},{468,445},{470,447},{366,452},{366,453},{365,453},{473,448},{473,449},{475,451},{475,452},{383,468},{384,468},{270,601},{270,600},{272,599},{272,598},{379,640},{368,641},{368,640},{363,641},{367,641},{367,642},{366,642},{364,643},{365,643},{362,643},{363,643},{358,644},{357,644},{350,645},{349,645},{353,644},{352,644},{355,644},{354,644},{356,644},{359,643},{358,643},{360,643},{359,644},{361,643},{348,645},{396,645},{396,646},{405,646},{402,646},{403,646},{350,646},{350,647},{403,647},{401,646},{284,606},{285,606},{404,646},{402,647},{400,646},{357,646},{356,646},{302,600},{278,600},{279,600},{297,600},{296,600},{298,600},{284,600},{280,600},{281,600},{287,603},{286,603},{285,603},{278,604},{278,605},{284,604},{285,604},{284,605},{277,605},{279,605},{285,607},{286,607},{287,607},{287,608},{288,607},{287,604},{287,605},{287,606},{286,606},{286,605},{356,647},{355,647},{400,647},{398,647},{401,647},{403,648},{402,648},{401,648},{350,648},{349,648},{404,647},{348,647},{404,648},{351,647},{351,648},{399,647},{400,648},{352,649},{351,649},{348,651},{347,651},{360,650},{359,650},{348,650},{350,650},{350,649},{351,650},{352,650},{356,650},{356,649},{357,650},{402,650},{349,649},{403,649},{402,649},{368,652},{345,653},{349,656},{350,657},{350,658},{349,657},{349,658},{322,671},{321,671},{323,671},{405,678},{414,671},{326,670},{327,671},{324,671},{441,679},{396,681},{395,681},{532,681},{532,682},{542,682},{541,681},{541,682},{539,682},{535,683},{535,682},{539,683},{541,683},{542,683},{339,662},{360,652},{361,652},{363,652},{359,651},{347,658},{340,663},{338,663},{339,663},{337,663},{335,663},{334,663},{336,663},{338,664},{337,664},{334,665},{407,665},{344,666},{343,666},{331,665},{330,665},{332,666},{334,666},{335,665},{331,666},{425,667},{424,668},{426,667},{329,668},{330,667},{329,667},{466,668},{327,670},{325,670},{355,651},{358,652},{347,652},{585,702},{584,702},{584,704},{587,704},{587,705},{566,705},{567,705},{573,705},{563,705},{564,705},{524,721},{523,721},{526,715},{527,715},{531,715},{524,722},{525,722},{536,709},{535,709},{540,711},{539,711},{536,711},{535,711},{536,712},{534,712},{534,713},{534,711},{528,711},{526,713},{522,713},{527,714},{533,712},{531,710},{532,709},{532,713},{531,713},{526,714},{525,714},{530,714},{532,714},{533,713},{531,714},{533,714},{585,758},{586,758},{595,746},{568,747},{567,747},{592,759},{590,759},{593,759},{589,759},{588,759},{607,760},{608,760},{606,760},{587,744},{591,744},{590,743},{590,744},{593,745},{592,745},{594,745},{593,746},{593,744},{592,744},{594,744},{586,744},{546,736},{546,737},{580,738},{580,739},{583,740},{582,740},{583,741},{584,741},{553,742},{588,743},{587,743},{586,741},{586,742},{555,722},{555,723},{526,723},{525,723},{526,724},{527,724},{556,724},{528,725},{529,725},{527,726},{526,726},{533,729},{532,729},{531,731},{540,734},{541,734},{572,705},{562,706},{563,706},{557,706},{574,706},{575,706},{573,706},{566,706},{567,706},{561,706},{560,706},{559,706},{565,705},{574,705},{568,706},{570,706},{569,705},{571,706},{556,706},{555,706},{555,707},{545,733},{549,734},{565,732},{558,731},{564,730},{563,730},{555,729},{562,729},{561,728},{555,728},{559,727},{556,727},{556,725},{554,726},{552,726},{551,726},{551,724},{555,724},{553,723},{556,722},{553,721},{554,719},{551,719},{555,719},{562,712},{576,707},{567,707},{565,707},{562,707},{558,707},{554,707},{553,707},{552,705},{545,708},{544,707},{548,706},{535,708},{533,709},{537,708},{538,709},{540,710},{538,711},{541,711},{542,711},{535,712},{535,715},{530,715},{529,714},{525,717},{525,715},{523,716},{522,715},{523,715},{519,715},{514,718},{516,721},{525,721},{526,721},{524,723},{526,722},{527,723},{528,724},{527,725},{533,726},{537,726},{524,727},{526,728},{529,729},{534,729},{536,729},{531,729},{534,730},{534,732},{586,798},{587,798},{600,799},{599,799},{601,799},{586,800},{587,800},{590,799},{583,799},{492,800},{491,800},{493,800},{636,807},{637,807},{544,806},{543,806},{588,806},{585,806},{589,806},{580,806},{579,806},{577,806},{581,806},{573,806},{575,806},{567,805},{566,805},{564,805},{485,808},{488,807},{476,808},{473,807},{474,806},{463,804},{449,806},{472,808},{566,807},{570,807},{554,807},{560,808},{550,807},{540,808},{551,807},{590,808},{585,807},{578,808},{583,809},{601,809},{600,802},{599,802},{602,801},{601,801},{494,801},{495,801},{497,801},{591,801},{593,801},{516,803},{515,803},{543,811},{542,811},{542,802},{541,803},{544,803},{544,802},{525,802},{522,802},{533,804},{539,802},{550,803},{554,803},{556,803},{552,802},{589,803},{588,803},{540,803},{539,803},{526,803},{524,803},{523,803},{527,803},{506,800},{510,801},{514,799},{501,800},{600,800},{594,799},{588,800},{596,801},{503,801},{502,801},{550,805},{551,805},{546,805},{549,805},{500,802},{504,802},{500,800},{495,802},{570,803},{572,803},{571,801},{558,801},{562,802},{559,803},{529,801},{528,801},{581,801},{579,801},{573,802},{573,803},{570,804},{593,803},{582,803},{585,802},{580,802},{611,803},{612,803},{603,803},{602,803},{601,803},{602,804},{549,804},{548,804},{546,804},{562,804},{563,804},{558,804},{559,804},{550,804},{553,804},{551,804},{534,806},{536,805},{531,806},{587,816},{588,816},{544,804},{541,806},{541,805},{545,805},{539,804},{538,806},{600,808},{619,809},{622,808},{621,806},{611,804},{593,805},{596,808},{603,808},{600,813},{605,813},{606,813},{598,813},{557,813},{558,814},{546,812},{575,812},{574,812},{546,813},{545,813},{542,813},{544,813},{582,812},{583,812},{588,814},{587,814},{584,815},{583,815},{582,815},{568,815},{589,817},{588,817},{594,818},{582,817},{579,818},{588,819},{620,816},{619,816},{618,816},{623,815},{621,815},{583,816},{584,816},{638,816},{630,816},{622,817},{633,817},{589,816},{592,814},{594,813},{585,813},{589,814},{593,814},{549,814},{548,814},{550,814},{578,815},{586,814},{570,815},{631,809},{630,809},{632,809},{650,812},{653,811},{654,810},{652,810},{654,809},{632,806},{625,808},{581,809},{580,809},{580,810},{582,810},{615,811},{610,809},{600,810},{617,811},{567,808},{561,808},{544,810},{561,810},{572,807},{566,810},{561,811},{575,808},{495,806},{497,807},{490,807},{509,809},{510,809},{502,807},{518,807},{497,805},{498,804},{496,804},{488,804},{485,803},{491,802},{483,801},{477,801},{482,802},{478,802},{480,802},{472,802},{467,803},{481,803},{476,804},{484,804},{474,805},{581,810},{579,810},{588,810},{585,809},{509,811},{504,810},{504,811},{510,811},{586,810},{585,811},{588,811},{584,811},{582,811},{581,811},{586,811},{594,812},{598,812},{590,812},{591,812},{571,811},{569,811},{577,812},{581,812},{558,813},{566,813},{564,814},{566,814},{580,813},{565,812},{555,813},{596,760},{595,760},{597,761},{597,760},{600,759},{605,761},{608,761},{605,760},{611,761},{612,761},{609,761},{612,763},{625,762},{647,763},{646,764},{655,766},{660,765},{658,767},{676,770},{685,770},{691,767},{683,762},{638,756},{636,757},{614,752},{613,753},{608,750},{600,750},{607,749},{602,749},{603,747},{595,748},{599,747},{598,746},{591,747},{592,746},{583,746},{587,742},{581,741},{575,742},{575,741},{572,741},{578,739},{579,738},{577,737},{575,738},{566,739},{573,738},{576,736},{564,737},{572,735},{567,733},{567,732},{561,733},{561,734},{559,734},{558,735},{560,733},{542,733},{547,736},{560,736},{551,737},{554,738},{542,736},{536,737},{550,739},{546,740},{550,742},{564,740},{551,742},{558,743},{553,744},{554,744},{559,744},{562,745},{555,746},{558,747},{570,747},{559,748},{567,749},{559,750},{560,751},{558,751},{559,752},{566,751},{570,753},{567,753},{570,754},{579,753},{576,755},{583,756},{579,756},{581,757},{593,760},{595,761},{590,761},{591,761},{600,761},{599,761},{605,762},{601,761},{626,762},{629,762},{630,762},{611,763},{610,763},{613,763},{615,763},{614,763},{469,447},{467,444},{472,442},{475,438},{475,436},{475,430},{485,419},{484,416},{478,412},{473,413},{467,419},{466,418},{456,422},{458,425},{452,427},{449,427},{448,426},{445,428},{439,426},{429,432},{416,432},{407,436},{401,436},{400,434},{388,443},{366,451},{370,453},{368,454},{367,453},{375,454},{379,460},{381,460},{383,463},{379,464},{377,467},{386,467},{384,467},{385,469},{393,470},{392,473},{382,471},{383,475},{388,477},{389,479},{398,478},{400,483},{397,486},{398,488},{401,489},{397,490},{402,492},{401,495},{402,496},{383,501},{380,499},{375,504},{366,502},{361,505},{356,504},{354,506},{354,511},{352,511},{351,512},{343,513},{343,515},{341,517},{345,518},{338,524},{324,523},{323,521},{318,521},{316,523},{316,528},{313,530},{314,532},{322,531},{328,535},{325,536},{325,537},{318,538},{319,540},{313,543},{311,545},{312,547},{308,548},{310,551},{308,553},{310,556},{303,559},{295,557},{294,558},{294,560},{287,560},{282,562},{282,563},{280,568},{277,568},{279,573},{273,575},{275,578},{278,579},{275,582},{274,585},{275,589},{282,594},{280,598},{284,597},{285,598},{290,598},{291,600},{302,599},{303,600},{299,602},{291,602},{286,604},{282,605},{309,623},{316,629},{312,632},{300,638},{306,641},{301,644},{301,648},{298,648},{296,650},{299,651},{296,653},{299,656},{297,656},{301,657},{301,658},{290,669},{300,677},{293,681},{287,682},{285,685},{288,689},{284,689},{301,695},{301,697},{305,695},{309,696},{308,698},{314,697},{313,696},{318,697},{317,698},{321,698},{319,699},{320,700},{331,697},{329,696},{321,697},{320,695},{325,695},{322,694},{331,694},{328,693},{329,693},{335,694},{332,693},{334,693},{335,692},{333,692},{330,691},{336,691},{336,693},{357,692},{357,690},{358,692},{378,686},{384,683},{388,682},{386,683},{386,684},{397,680},{398,680},{398,682},{405,677},{410,677},{411,673},{412,668},{400,663},{387,661},{345,665},{344,667},{341,667},{342,667},{342,668},{339,667},{336,668},{335,667},{328,670},{330,671},{324,672},{319,671},{324,669},{327,667},{333,666},{328,666},{332,665},{329,665},{330,663},{341,662},{348,659},{346,658},{348,656},{347,654},{343,654},{347,650},{347,647},{353,643},{363,640},{374,638},{381,640},{379,642},{380,643},{378,644},{372,644},{365,647},{364,649},{368,650},{368,651},{370,652},{384,648},{380,648},{381,647},{380,646},{405,645},{407,647},{405,648},{405,647},{406,647},{404,649},{397,653},{398,656},{415,661},{423,665},{426,664},{425,664},{433,664},{437,662},{433,661},{433,660},{438,662},{442,659},{441,662},{446,667},{444,668},{445,669},{444,671},{438,673},{442,677},{441,678},{443,679},{442,680},{444,680},{442,683},{433,687},{440,685},{452,685},{455,685},{460,684},{459,684},{465,681},{467,678},{453,677},{453,676},{448,673},{456,672},{460,668},{469,668},{476,669},{479,674},{479,676},{491,676},{487,677},{488,678},{486,679},{492,679},{508,684},{522,686},{521,685},{524,683},{528,685},{523,686},{537,689},{542,690},{546,690},{536,689},{540,688},{537,686},{540,684},{533,683},{531,681},{540,680},{545,683},{548,681},{550,682},{549,683},{554,685},{561,686},{573,685},{578,687},{572,687},{589,690},{593,690},{590,689},{595,687},{592,687},{591,684},{598,684},{599,684},{598,686},{599,687},{604,687},{609,689},{610,689},{609,688},{611,688},{612,688},{602,696},{608,696},{607,697},{609,699},{634,696},{649,693},{645,689},{653,688},{657,686},{653,682},{653,680},{661,679},{660,678},{662,677},{658,676},{661,675},{652,672},{651,669},{634,665},{632,663},{633,662},{629,661},{628,659},{619,657},{606,649},{602,651},{597,648},{595,645},{596,645},{596,642},{599,641},{596,639},{592,631},{595,629},{594,627},{597,625},{594,621},{593,617},{588,615},{567,615},{564,614},{563,612},{553,611},{550,609},{539,610},{538,608},{536,609},{533,609},{534,610},{529,611},{523,608},{519,609},{518,606},{523,604},{523,602},{520,603},{515,599},{511,601},{508,599},{500,598},{497,592},{495,592},{495,594},{490,595},{491,597},{485,597},{485,602},{488,604},{485,604},{484,609},{480,609},{480,610},{472,611},{470,607},{471,606},{469,605},{467,603},{463,602},{466,601},{470,601},{469,598},{471,597},{471,594},{473,594},{472,592},{476,589},{473,589},{470,586},{466,586},{463,581},{478,579},{476,578},{475,575},{467,575},{467,573},{469,572},{467,569},{475,569},{477,571},{481,570},{483,572},{490,571},{492,573},{493,570},{497,571},{497,569},{501,568},{501,566},{505,566},{506,564},{509,564},{508,562},{513,561},{516,561},{514,559},{522,559},{522,561},{527,560},{528,562},{526,563},{529,565},{531,565},{529,564},{530,561},{533,561},{533,563},{536,562},{532,559},{539,559},{542,557},{536,552},{531,551},{536,549},{533,544},{534,540},{531,541},{529,542},{531,542},{530,543},{529,543},{524,545},{521,543},{519,545},{514,547},{510,546},{509,543},{501,545},{503,543},{502,540},{500,540},{500,538},{485,538},{486,537},{483,537},{484,535},{479,534},{482,530},{486,529},{484,528},{474,526},{466,527},{460,524},{456,525},{451,523},{445,526},{443,523},{432,525},{428,522},{428,520},{425,517},{429,512},{419,512},{412,508},{415,506},{414,502},{415,501},{422,497},{421,492},{423,492},{427,488},{426,485},{421,484},{420,480},{425,480},{429,475},{431,476},{432,474},{437,474},{437,477},{441,479},{444,479},{445,480},{443,481},{443,483},{445,482},{445,481},{450,482},{457,480},{458,477},{463,474},{468,476},{465,474},{468,470},{472,467},{469,466},{470,464},{465,463},{469,462},{468,461},{472,461},{469,456},{474,457},{476,455},{472,448},{464,683},{543,683},{540,683},{463,683},{462,683},{385,683},{463,684},{538,683},{538,684},{539,684},{524,685},{523,685},{571,687},{496,687},{495,687},{494,687},{461,684},{384,684},{385,684},{462,684},{509,684},{511,685},{515,685},{610,688},{491,687},{492,687},{487,687},{377,687},{595,690},{594,691},{348,692},{347,692},{348,693},{364,691},{363,691},{330,694},{332,694},{329,695},{327,695},{326,695},{593,691},{592,692},{589,693},{587,693},{587,694},{592,693},{335,693},{344,693},{342,693},{340,694},{341,694},{586,694},{585,695},{586,695},{553,689},{554,689},{548,689},{499,690},{499,689},{500,689},{501,690},{501,689},{546,689},{547,690},{547,689},{500,690},{550,689},{549,689},{552,689},{488,687},{484,687},{485,687},{375,688},{484,688},{374,688},{373,688},{483,688},{544,688},{542,688},{543,688},{495,688},{486,687},{595,689},{556,689},{555,689},{557,689},{500,691},{497,689},{482,689},{483,693},{489,695},{494,695},{501,693},{502,692},{503,691},{503,692},{316,698},{612,698},{612,699},{613,698},{595,699},{594,699},{606,697},{594,698},{595,698},{600,701},{606,698},{596,697},{597,698},{590,699},{592,699},{591,699},{588,702},{585,703},{591,705},{606,696},{607,696}}}, - {"Asia/Manila",915,{{1257,96},{1236,110},{1236,111},{1232,110},{1208,112},{1250,125},{1252,126},{1255,122},{1254,116},{1256,114},{1255,112},{1257,112},{1258,110},{1257,111},{1252,111},{1250,113},{1248,115},{1250,118},{1244,122},{1243,126},{1194,46},{1194,48},{1194,47},{1198,48},{1199,48},{1200,50},{1200,49},{1199,49},{1195,49},{1195,48},{1195,46},{1195,47},{1194,49},{1198,49},{1202,50},{1203,51},{1203,52},{1199,51},{1202,51},{1200,51},{1201,50},{1197,50},{1198,50},{1198,51},{1207,52},{1206,52},{1203,54},{1204,54},{1253,54},{1254,54},{1206,53},{1205,52},{1200,52},{1202,53},{1199,52},{1204,52},{1204,53},{1199,53},{1200,53},{1203,53},{1202,54},{1202,52},{1209,55},{1209,56},{1255,55},{1255,54},{1206,54},{1202,55},{1206,55},{1207,55},{1207,54},{1205,55},{1204,55},{1266,77},{1224,75},{1231,76},{1235,76},{1223,72},{1228,73},{1229,73},{1258,73},{1223,73},{1240,73},{1241,74},{1229,74},{1228,74},{1205,61},{1210,61},{1209,61},{1204,62},{1205,62},{1204,61},{1181,62},{1211,62},{1210,62},{1218,61},{1206,61},{1218,62},{1209,62},{1208,62},{1181,63},{1206,64},{1206,62},{1205,63},{1207,64},{1208,64},{1220,63},{1219,63},{1207,63},{1206,63},{1208,63},{1209,63},{1220,64},{1218,65},{1215,66},{1216,66},{1217,66},{1218,66},{1217,67},{1216,67},{1224,67},{1214,68},{1215,67},{1214,67},{1215,68},{1263,68},{1216,68},{1224,68},{1221,69},{1220,69},{1216,69},{1257,69},{1257,70},{1222,69},{1223,69},{1219,67},{1220,68},{1220,67},{1223,67},{1222,65},{1218,64},{1221,67},{1223,66},{1184,70},{1185,70},{1258,69},{1257,71},{1257,72},{1258,71},{1222,70},{1223,70},{1266,56},{1203,56},{1210,57},{1204,57},{1204,58},{1197,58},{1212,58},{1211,58},{1208,58},{1211,57},{1209,57},{1208,57},{1209,58},{1200,59},{1216,60},{1216,59},{1201,59},{1201,60},{1219,60},{1219,61},{1218,60},{1217,60},{1183,61},{1217,61},{1204,60},{1213,60},{1214,60},{1215,60},{1212,61},{1213,61},{1214,61},{1215,61},{1199,59},{1211,59},{1212,59},{1214,59},{1213,59},{1209,59},{1208,55},{1208,56},{1170,80},{1171,81},{1170,78},{1169,79},{1170,81},{1172,81},{1171,82},{1172,82},{1170,82},{1188,99},{1189,99},{1188,101},{1260,99},{1260,100},{1260,98},{1259,99},{1224,99},{1238,98},{1238,99},{1246,99},{1234,99},{1256,99},{1255,99},{1239,99},{1239,100},{1251,99},{1251,100},{1192,101},{1240,100},{1256,100},{1255,100},{1251,102},{1252,101},{1253,99},{1251,101},{1255,101},{1245,101},{1246,101},{1246,102},{1245,100},{1193,101},{1192,102},{1242,102},{1241,102},{1243,102},{1244,102},{1193,102},{1239,102},{1239,103},{1240,102},{1241,103},{1195,103},{1194,103},{1243,103},{1245,102},{1244,103},{1189,103},{1190,103},{1260,108},{1259,108},{1258,109},{1240,103},{1256,104},{1226,104},{1172,78},{1244,61},{1241,64},{1239,68},{1242,74},{1237,78},{1234,78},{1233,76},{1235,74},{1231,75},{1231,78},{1230,75},{1229,77},{1227,78},{1219,70},{1219,71},{1222,80},{1229,81},{1230,85},{1233,85},{1234,87},{1238,84},{1239,82},{1237,80},{1242,82},{1244,86},{1248,85},{1248,90},{1251,88},{1252,91},{1255,90},{1254,98},{1260,95},{1260,92},{1262,93},{1262,91},{1263,88},{1261,86},{1264,85},{1264,79},{1266,73},{1263,69},{1262,69},{1262,63},{1259,74},{1254,67},{1257,61},{1254,56},{1252,58},{1252,61},{1250,59},{1184,78},{1264,83},{1173,82},{1264,84},{1263,89},{1172,83},{1173,83},{1256,97},{1239,118},{1172,84},{1236,86},{1232,88},{1234,89},{1182,89},{1183,89},{1181,91},{1233,91},{1247,91},{1247,93},{1248,91},{1179,93},{1184,92},{1184,93},{1185,92},{1208,93},{1261,94},{1260,94},{1186,94},{1186,95},{1261,97},{1262,97},{1260,97},{1261,96},{1262,96},{1256,98},{1257,97},{1257,98},{1258,96},{1237,92},{1236,91},{1235,92},{1236,93},{1180,93},{1255,98},{1257,99},{1259,94},{1239,95},{1210,96},{1213,97},{1212,96},{1238,95},{1237,96},{1239,96},{1213,96},{1259,96},{1259,98},{1261,100},{1262,98},{1243,101},{1246,100},{1246,97},{1249,116},{1202,120},{1199,116},{1233,116},{1234,116},{1232,116},{1217,116},{1255,116},{1255,117},{1228,116},{1200,116},{1199,117},{1200,117},{1201,117},{1248,117},{1248,116},{1249,117},{1230,117},{1247,120},{1247,119},{1230,118},{1201,118},{1248,118},{1243,118},{1247,118},{1201,119},{1255,119},{1203,118},{1203,119},{1215,118},{1214,118},{1214,119},{1231,118},{1231,119},{1213,119},{1200,119},{1203,120},{1202,119},{1237,119},{1241,119},{1244,119},{1244,120},{1246,119},{1245,119},{1236,119},{1216,119},{1215,120},{1243,120},{1243,119},{1202,117},{1247,117},{1200,118},{1202,118},{1199,120},{1198,120},{1198,121},{1198,122},{1256,120},{1256,121},{1242,120},{1242,121},{1220,121},{1220,122},{1236,120},{1235,120},{1204,120},{1220,120},{1219,121},{1199,121},{1216,121},{1199,122},{1219,119},{1219,120},{1200,120},{1198,119},{1201,120},{1216,120},{1214,121},{1214,120},{1202,122},{1201,122},{1202,121},{1203,121},{1203,122},{1232,122},{1233,122},{1214,122},{1204,122},{1177,151},{1177,152},{1199,155},{1198,157},{1198,158},{1201,161},{1200,163},{1200,162},{1199,163},{1199,164},{1200,164},{1204,175},{1221,186},{1222,185},{1221,185},{1222,149},{1220,149},{1178,151},{1221,149},{1222,150},{1218,142},{1218,143},{1219,143},{1206,144},{1230,144},{1230,145},{1228,145},{1218,189},{1212,190},{1229,144},{1229,145},{1216,147},{1223,147},{1224,147},{1205,148},{1206,148},{1222,147},{1221,148},{1222,148},{1220,144},{1228,144},{1231,141},{1229,142},{1220,148},{1218,150},{1220,150},{1220,146},{1218,149},{1213,189},{1212,189},{1212,192},{1212,191},{1215,193},{1214,193},{1213,194},{1215,194},{1215,195},{1219,195},{1220,196},{1220,195},{1221,200},{1222,200},{1218,203},{1219,207},{1218,207},{1218,208},{1219,208},{1219,203},{1218,204},{1220,205},{1220,204},{1219,209},{1220,211},{1219,211},{1213,188},{1215,189},{1231,140},{1219,189},{1219,190},{1220,190},{1219,188},{1239,129},{1238,128},{1220,128},{1221,128},{1220,129},{1217,129},{1217,130},{1221,129},{1220,130},{1221,130},{1219,130},{1229,132},{1229,131},{1236,127},{1233,127},{1229,130},{1233,129},{1239,138},{1238,138},{1233,138},{1227,138},{1236,140},{1240,140},{1203,138},{1200,139},{1203,137},{1201,138},{1201,139},{1238,139},{1239,139},{1236,139},{1237,139},{1218,139},{1217,139},{1238,140},{1236,136},{1209,136},{1208,137},{1204,136},{1241,132},{1242,132},{1240,133},{1241,133},{1240,132},{1218,132},{1219,132},{1238,133},{1239,133},{1239,132},{1227,133},{1227,134},{1238,134},{1221,134},{1241,140},{1232,140},{1220,141},{1219,142},{1222,140},{1221,140},{1199,124},{1240,124},{1241,124},{1240,123},{1242,135},{1240,137},{1242,141},{1244,138},{1210,135},{1209,135},{1211,135},{1210,136},{1211,136},{1222,135},{1220,132},{1218,133},{1219,136},{1221,135},{1243,139},{1243,140},{1244,140},{1239,140},{1235,140},{1233,141},{1199,123},{1241,123},{1210,122},{1238,123},{1239,122},{1211,122},{1211,123},{1204,123},{1214,123},{1213,123},{1203,123},{1215,124},{1214,124},{1203,124},{1232,123},{1232,124},{1233,124},{1237,120},{1235,122},{1232,126},{1241,117},{1220,124},{1220,126},{1222,127},{1190,104},{1190,105},{1226,125},{1227,124},{1226,123},{1224,124},{1200,125},{1241,125},{1241,126},{1251,125},{1251,126},{1244,125},{1244,126},{1245,126},{1245,125},{1249,126},{1243,124},{1242,125},{1242,124},{1223,125},{1222,126},{1223,126},{1237,124},{1236,126},{1191,104},{1250,127},{1250,126},{1251,127},{1244,127},{1204,127},{1192,105},{1191,105},{1192,106},{1191,106},{1258,107},{1257,108},{1207,131},{1203,134},{1203,135},{1216,131},{1212,122},{1231,137},{1234,139},{1236,137},{1235,136},{1238,131},{1242,131},{1240,130},{1237,128},{1233,130},{1232,134},{1225,140},{1224,140},{1226,132},{1224,135},{1218,140},{1213,136},{1210,138},{1209,137},{1209,139},{1207,139},{1207,138},{1206,142},{1210,145},{1209,147},{1206,149},{1205,144},{1202,147},{1203,148},{1201,148},{1198,163},{1199,162},{1202,160},{1204,162},{1203,166},{1205,174},{1203,177},{1206,185},{1208,186},{1212,186},{1219,183},{1223,184},{1221,178},{1222,174},{1225,171},{1225,169},{1222,163},{1221,161},{1221,163},{1216,159},{1216,157},{1214,153},{1217,147},{1217,142},{1219,140},{1222,139},{1223,140},{1222,141},{1222,142},{1223,142},{1223,141},{1225,143},{1256,102},{1256,105},{1255,104},{1255,105},{1252,104},{1252,105},{1234,104},{1234,105},{1227,104},{1227,105},{1247,105},{1193,107},{1200,105},{1200,106},{1198,104},{1197,105},{1198,107},{1245,107},{1245,106},{1244,106},{1244,107},{1243,106},{1243,107},{1227,107},{1225,104},{1226,107},{1199,106},{1199,107},{1202,107},{1203,107},{1203,106},{1196,109},{1196,107},{1197,107},{1211,108},{1208,107},{1209,107},{1245,108},{1246,108},{1196,108},{1210,108},{1193,109},{1211,109},{1212,109},{1210,109},{1197,109},{1197,110},{1196,110},{1207,110},{1212,110},{1256,110},{1257,110},{1193,110},{1197,111},{1250,104},{1250,100},{1248,102},{1248,108},{1246,110},{1245,109},{1244,109},{1243,116},{1245,113},{1245,115},{1246,113},{1250,114},{1250,107},{1253,104},{1208,110},{1210,110},{1209,110},{1244,110},{1193,111},{1256,111},{1194,111},{1196,111},{1237,111},{1196,113},{1195,109},{1193,103},{1192,100},{1187,99},{1188,97},{1185,93},{1176,90},{1181,93},{1188,100},{1193,105},{1192,108},{1192,110},{1195,107},{1195,114},{1194,112},{1193,112},{1196,112},{1197,113},{1197,112},{1194,113},{1193,113},{1197,114},{1194,114},{1197,115},{1196,114},{1239,112},{1233,104},{1231,96},{1233,93},{1230,90},{1224,98},{1229,101},{1228,105},{1230,109},{1235,109},{1238,112},{1231,111},{1232,112},{1232,111},{1210,111},{1209,112},{1210,112},{1234,100},{1241,113},{1240,104},{1236,101},{1233,94},{1192,111},{1195,112},{1211,112},{1256,112},{1256,113},{1251,113},{1237,112},{1237,113},{1231,112},{1231,113},{1232,113},{1209,113},{1207,113},{1239,113},{1239,114},{1207,114},{1241,115},{1199,115},{1208,115},{1232,115},{1219,115},{1201,114},{1220,114},{1233,114},{1233,115},{1202,114},{1208,114},{1232,114},{1209,114},{1198,115},{1198,114},{1202,115},{1229,115},{1198,116},{1244,117},{1245,117},{1246,115},{1244,115},{1226,115},{1229,114},{1228,110},{1227,108},{1220,104},{1221,117},{1218,118}}}, - {"Indian/Mauritius",15,{{595,-168},{596,-168},{596,-167},{573,-204},{635,-197},{633,-197},{576,-200},{578,-202},{577,-204},{573,-205},{577,-200},{566,-104},{566,-105},{565,-103},{565,-104}}}, - {"America/Aruba",4,{{-700,126},{-699,125},{-699,124},{-701,126}}}, - {"Australia/Brisbane",414,{{1481,-200},{1481,-199},{1482,-200},{1476,-197},{1485,-201},{1483,-200},{1485,-200},{1486,-200},{1484,-200},{1488,-202},{1486,-202},{1486,-201},{1490,-202},{1489,-202},{1489,-201},{1490,-201},{1475,-197},{1476,-196},{1475,-195},{1428,-99},{1468,-192},{1468,-191},{1469,-191},{1469,-192},{1466,-190},{1465,-188},{1465,-189},{1465,-187},{1465,-186},{1465,-185},{1466,-187},{1466,-188},{1467,-188},{1462,-184},{1461,-184},{1461,-182},{1463,-182},{1463,-185},{1462,-185},{1462,-182},{1461,-180},{1462,-180},{1461,-179},{1462,-179},{1460,-172},{1394,-171},{1396,-171},{1409,-171},{1427,-107},{1426,-107},{1426,-106},{1427,-106},{1422,-106},{1423,-105},{1424,-104},{1422,-105},{1423,-106},{1421,-106},{1425,-102},{1422,-101},{1421,-102},{1421,-101},{1425,-103},{1422,-102},{1422,-103},{1423,-103},{1423,-101},{1423,-102},{1429,-100},{1429,-101},{1428,-100},{1435,-100},{1436,-100},{1438,-100},{1422,-100},{1422,-99},{1441,-99},{1440,-99},{1429,-98},{1429,-99},{1426,-98},{1434,-97},{1434,-98},{1438,-96},{1423,-96},{1416,-95},{1425,-94},{1428,-94},{1427,-94},{1426,-94},{1422,-92},{1423,-92},{1423,-93},{1421,-93},{1421,-92},{1420,-92},{1421,-104},{1392,-170},{1393,-171},{1391,-170},{1395,-170},{1393,-170},{1460,-169},{1391,-169},{1390,-169},{1391,-168},{1398,-165},{1397,-165},{1393,-163},{1455,-163},{1454,-151},{1455,-149},{1392,-167},{1398,-167},{1395,-167},{1394,-167},{1399,-167},{1394,-166},{1393,-167},{1392,-166},{1393,-165},{1396,-164},{1455,-147},{1454,-147},{1455,-146},{1453,-147},{1453,-146},{1449,-146},{1450,-145},{1448,-145},{1448,-144},{1443,-142},{1442,-142},{1442,-141},{1449,-145},{1445,-141},{1443,-141},{1417,-134},{1416,-134},{1436,-132},{1434,-128},{1434,-126},{1435,-126},{1434,-123},{1431,-122},{1433,-120},{1421,-110},{1427,-110},{1427,-109},{1426,-109},{1424,-108},{1424,-109},{1422,-107},{1422,-108},{1426,-108},{1424,-107},{1423,-107},{1421,-107},{1534,-278},{1534,-279},{1534,-277},{1533,-275},{1534,-275},{1533,-276},{1534,-276},{1533,-277},{1532,-274},{1531,-269},{1531,-268},{1532,-271},{1531,-270},{1533,-274},{1532,-273},{1533,-273},{1534,-273},{1534,-272},{1535,-270},{1534,-274},{1531,-258},{1530,-259},{1529,-256},{1530,-253},{1529,-253},{1529,-255},{1530,-255},{1530,-256},{1524,-247},{1524,-248},{1522,-247},{1522,-246},{1515,-241},{1532,-250},{1531,-248},{1533,-247},{1534,-250},{1530,-258},{1530,-252},{1535,-274},{1535,-277},{1516,-240},{1512,-238},{1512,-239},{1513,-239},{1509,-236},{1509,-237},{1510,-236},{1517,-235},{1507,-236},{1507,-235},{1508,-236},{1509,-235},{1508,-235},{1514,-239},{1513,-238},{1512,-234},{1511,-234},{1517,-233},{1510,-232},{1511,-232},{1509,-231},{1509,-232},{1500,-226},{1506,-225},{1497,-225},{1500,-225},{1498,-224},{1499,-225},{1499,-223},{1496,-221},{1507,-221},{1500,-221},{1499,-222},{1504,-223},{1505,-222},{1505,-223},{1507,-220},{1496,-219},{1497,-219},{1501,-219},{1495,-218},{1495,-207},{1506,-223},{1505,-224},{1503,-223},{1503,-222},{1499,-221},{1497,-224},{1503,-224},{1512,-237},{1510,-235},{1512,-235},{1511,-235},{1504,-220},{1496,-220},{1498,-220},{1499,-220},{1501,-220},{1502,-220},{1503,-218},{1503,-217},{1504,-217},{1497,-217},{1498,-218},{1497,-220},{1495,-216},{1498,-217},{1498,-216},{1503,-215},{1502,-215},{1499,-215},{1497,-215},{1497,-214},{1498,-214},{1497,-213},{1499,-210},{1498,-210},{1502,-217},{1502,-216},{1494,-209},{1495,-209},{1496,-209},{1489,-209},{1489,-208},{1492,-208},{1493,-208},{1492,-207},{1491,-207},{1491,-206},{1494,-208},{1496,-208},{1489,-206},{1491,-205},{1487,-205},{1487,-204},{1491,-204},{1490,-205},{1488,-203},{1489,-203},{1489,-204},{1488,-204},{1491,-203},{1490,-204},{1517,-240},{1517,-241},{1514,-240},{1514,-241},{1515,-240},{1490,-203},{1506,-227},{1508,-225},{1507,-226},{1508,-233},{1506,-235},{1504,-233},{1518,-240},{1525,-248},{1526,-252},{1528,-255},{1530,-254},{1529,-257},{1530,-260},{1532,-259},{1530,-264},{1532,-268},{1530,-273},{1533,-279},{1536,-282},{1531,-284},{1525,-283},{1520,-285},{1520,-289},{1516,-289},{1514,-292},{1510,-287},{1503,-285},{1495,-286},{1490,-290},{1410,-290},{1410,-260},{1380,-260},{1380,-165},{1392,-173},{1400,-177},{1408,-175},{1413,-165},{1416,-152},{1417,-153},{1417,-152},{1416,-142},{1415,-139},{1417,-135},{1418,-134},{1417,-133},{1416,-130},{1418,-127},{1419,-129},{1420,-127},{1418,-126},{1420,-126},{1417,-124},{1416,-126},{1419,-120},{1419,-122},{1419,-123},{1420,-120},{1420,-121},{1421,-120},{1421,-117},{1425,-108},{1425,-110},{1428,-111},{1429,-118},{1432,-120},{1431,-123},{1434,-129},{1435,-128},{1435,-137},{1438,-144},{1439,-145},{1445,-142},{1447,-146},{1454,-150},{1452,-155},{1455,-161},{1454,-164},{1458,-170},{1459,-172},{1461,-177},{1460,-182},{1463,-189},{1468,-193},{1470,-192},{1471,-194},{1474,-194},{1474,-193},{1477,-198},{1478,-197},{1479,-199},{1483,-202},{1489,-205},{1487,-207},{1492,-211},{1491,-211},{1492,-213},{1493,-213},{1493,-215},{1495,-215},{1494,-218},{1496,-223},{1495,-223},{1496,-225},{1496,-226},{1500,-227},{1501,-227}}}, - {"Asia/Tokyo",694,{{1347,339},{1317,339},{1322,339},{1238,240},{1238,241},{1239,242},{1415,242},{1415,243},{1540,243},{1240,242},{1237,243},{1237,244},{1422,266},{1421,266},{1230,244},{1230,245},{1312,245},{1247,247},{1247,246},{1238,245},{1241,243},{1240,243},{1242,243},{1241,244},{1243,246},{1239,243},{1238,244},{1239,244},{1253,247},{1252,247},{1252,249},{1253,249},{1413,254},{1413,255},{1413,248},{1255,247},{1253,248},{1252,248},{1251,248},{1235,258},{1312,258},{1312,259},{1313,259},{1313,258},{1246,259},{1237,259},{1313,260},{1267,264},{1268,264},{1268,263},{1269,263},{1269,264},{1272,263},{1271,264},{1272,264},{1280,264},{1280,263},{1272,262},{1273,262},{1279,262},{1279,263},{1280,262},{1274,262},{1275,262},{1422,265},{1421,265},{1280,269},{1279,269},{1280,270},{1279,270},{1422,267},{1421,267},{1272,266},{1278,267},{1280,267},{1279,266},{1278,266},{1280,266},{1274,261},{1282,279},{1293,280},{1292,280},{1300,283},{1299,283},{1300,284},{1292,283},{1291,280},{1292,281},{1283,267},{1278,264},{1277,261},{1277,264},{1279,267},{1281,267},{1283,269},{1422,271},{1422,272},{1287,274},{1286,273},{1285,274},{1422,275},{1422,276},{1421,277},{1290,278},{1289,277},{1289,279},{1293,281},{1292,282},{1294,282},{1294,281},{1291,282},{1297,285},{1290,288},{1292,291},{1292,292},{1293,292},{1296,294},{1296,295},{1297,296},{1297,297},{1295,297},{1299,298},{1298,298},{1298,299},{1299,299},{1296,299},{1295,299},{1299,300},{1300,300},{1305,302},{1304,304},{1307,304},{1306,303},{1302,304},{1302,305},{1303,304},{1403,305},{1284,320},{1309,303},{1309,305},{1311,308},{1310,304},{1308,307},{1309,308},{1309,307},{1299,308},{1300,308},{1303,308},{1304,308},{1422,270},{1280,271},{1284,270},{1284,271},{1318,327},{1298,326},{1298,327},{1398,324},{1398,325},{1305,325},{1289,326},{1298,325},{1302,324},{1304,324},{1303,324},{1303,323},{1304,323},{1301,323},{1302,323},{1302,322},{1304,325},{1301,325},{1286,327},{1286,326},{1288,326},{1305,326},{1317,326},{1304,326},{1289,327},{1287,328},{1289,328},{1288,328},{1290,328},{1289,329},{1290,329},{1319,327},{1326,328},{1325,328},{1326,327},{1325,327},{1300,327},{1300,328},{1290,327},{1319,328},{1296,329},{1290,330},{1398,330},{1398,331},{1398,332},{1399,331},{1397,331},{1290,332},{1291,332},{1291,333},{1292,333},{1320,333},{1319,333},{1324,334},{1323,334},{1297,334},{1324,329},{1325,329},{1302,329},{1302,330},{1321,329},{1321,330},{1296,330},{1319,330},{1320,330},{1292,330},{1293,330},{1294,330},{1325,332},{1324,332},{1291,328},{1320,331},{1296,331},{1323,331},{1324,331},{1295,331},{1323,332},{1320,332},{1296,332},{1370,345},{1370,346},{1294,332},{1294,333},{1296,334},{1295,333},{1295,312},{1307,313},{1302,313},{1302,314},{1314,315},{1297,316},{1297,317},{1298,318},{1315,318},{1301,322},{1302,321},{1301,321},{1299,318},{1298,319},{1299,319},{1300,322},{1300,324},{1300,325},{1302,325},{1369,378},{1369,379},{1382,378},{1383,380},{1382,381},{1385,383},{1385,379},{1415,382},{1415,383},{1416,383},{1414,383},{1411,383},{1412,384},{1412,383},{1415,385},{1415,384},{1392,384},{1392,385},{1393,385},{1416,388},{1416,389},{1396,392},{1395,392},{1390,410},{1398,413},{1398,414},{1395,421},{1394,422},{1396,422},{1454,433},{1455,433},{1456,432},{1449,429},{1449,430},{1451,430},{1451,431},{1452,436},{1453,436},{1412,451},{1411,452},{1412,453},{1413,452},{1413,444},{1414,444},{1410,453},{1410,454},{1410,455},{1411,454},{1394,415},{1393,415},{1425,450},{1434,443},{1443,441},{1444,440},{1448,439},{1453,443},{1451,438},{1454,436},{1453,433},{1452,433},{1455,432},{1457,434},{1458,434},{1450,430},{1449,431},{1448,429},{1443,430},{1439,429},{1434,424},{1432,419},{1418,426},{1414,426},{1410,423},{1407,426},{1405,426},{1403,422},{1412,418},{1406,418},{1404,415},{1401,414},{1401,419},{1398,423},{1398,426},{1405,430},{1403,433},{1412,431},{1414,433},{1413,437},{1416,439},{1418,446},{1416,452},{1416,455},{1420,455},{1311,348},{1312,348},{1318,348},{1343,347},{1353,347},{1397,355},{1398,355},{1392,350},{1368,351},{1368,350},{1369,351},{1369,350},{1398,356},{1401,356},{1331,356},{1354,357},{1331,360},{1330,360},{1333,362},{1332,362},{1332,363},{1333,363},{1369,371},{1369,372},{1371,372},{1371,371},{1319,372},{1331,361},{1332,361},{1354,345},{1354,346},{1330,361},{1313,344},{1341,344},{1338,344},{1393,345},{1314,345},{1335,344},{1342,345},{1341,345},{1335,345},{1340,344},{1340,345},{1369,345},{1343,344},{1344,346},{1313,345},{1367,345},{1342,346},{1345,347},{1345,346},{1346,346},{1346,347},{1394,347},{1394,348},{1352,347},{1349,347},{1342,347},{1348,347},{1358,334},{1358,335},{1359,335},{1295,334},{1295,335},{1296,335},{1294,334},{1298,336},{1297,336},{1299,335},{1299,336},{1301,336},{1300,336},{1296,337},{1303,336},{1345,336},{1303,337},{1302,337},{1325,337},{1317,337},{1316,337},{1300,335},{1297,335},{1298,335},{1298,334},{1346,341},{1347,338},{1343,336},{1342,332},{1337,335},{1333,334},{1330,329},{1330,327},{1327,329},{1324,330},{1325,331},{1326,332},{1324,333},{1324,335},{1327,337},{1329,341},{1331,339},{1335,340},{1337,341},{1336,343},{1346,342},{1307,339},{1310,340},{1311,336},{1317,335},{1315,333},{1318,331},{1319,329},{1313,314},{1311,315},{1310,313},{1311,313},{1307,310},{1308,313},{1306,316},{1308,317},{1306,317},{1305,315},{1306,312},{1301,314},{1303,315},{1305,323},{1307,326},{1306,328},{1304,331},{1302,332},{1301,328},{1303,329},{1304,327},{1302,326},{1302,328},{1299,327},{1297,326},{1297,331},{1298,329},{1299,328},{1299,333},{1300,334},{1304,336},{1305,339},{1308,341},{1294,343},{1294,344},{1292,342},{1292,343},{1293,343},{1292,341},{1301,342},{1334,343},{1335,343},{1309,343},{1309,344},{1295,347},{1295,346},{1293,346},{1335,341},{1363,342},{1348,342},{1330,341},{1328,341},{1332,341},{1324,341},{1324,342},{1328,342},{1326,342},{1333,342},{1332,344},{1333,344},{1336,344},{1331,344},{1337,343},{1337,344},{1333,343},{1331,341},{1330,342},{1329,342},{1323,342},{1324,343},{1325,343},{1325,341},{1327,342},{1331,342},{1391,342},{1392,342},{1332,342},{1332,343},{1323,343},{1331,343},{1329,343},{1324,340},{1317,340},{1318,340},{1330,343},{1328,343},{1393,344},{1393,343},{1392,343},{1350,343},{1351,343},{1350,346},{1347,342},{1348,344},{1322,338},{1322,337},{1321,337},{1297,337},{1297,339},{1298,338},{1320,338},{1304,338},{1324,338},{1323,338},{1396,339},{1396,338},{1300,339},{1304,339},{1325,339},{1326,339},{1308,340},{1351,340},{1325,340},{1334,340},{1323,340},{1327,339},{1327,340},{1309,340},{1324,339},{1323,339},{1319,340},{1318,339},{1316,340},{1326,340},{1348,338},{1348,339},{1325,338},{1321,338},{1321,339},{1320,339},{1322,340},{1395,340},{1395,341},{1396,341},{1325,342},{1326,341},{1344,356},{1352,358},{1353,354},{1355,356},{1357,355},{1360,358},{1360,357},{1361,357},{1360,360},{1367,367},{1368,374},{1374,375},{1370,369},{1372,367},{1386,374},{1388,378},{1394,381},{1398,389},{1401,397},{1400,399},{1397,399},{1400,402},{1399,406},{1403,408},{1403,413},{1406,412},{1407,408},{1409,410},{1411,409},{1412,413},{1408,411},{1409,415},{1413,414},{1415,414},{1415,406},{1418,402},{1420,396},{1421,396},{1420,395},{1421,395},{1419,393},{1420,393},{1419,391},{1416,390},{1417,389},{1415,387},{1411,384},{1409,380},{1410,370},{1408,369},{1406,363},{1409,357},{1405,356},{1404,352},{1399,349},{1398,350},{1399,350},{1398,353},{1398,357},{1396,355},{1397,351},{1395,353},{1392,352},{1391,349},{1388,346},{1388,350},{1389,350},{1388,351},{1384,349},{1382,346},{1376,347},{1374,348},{1370,348},{1370,349},{1369,347},{1367,351},{1365,346},{1369,344},{1369,343},{1364,342},{1351,339},{1352,341},{1355,346},{1347,348},{1339,344},{1324,344},{1322,342},{1317,341},{1312,339},{1310,341},{1309,339},{1310,344},{1314,344},{1326,353},{1326,354},{1334,355}}}, - {"Pacific/Kiritimati",18,{{-1518,-114},{-1502,-100},{-1502,-99},{-1558,-56},{-1559,-56},{-1550,-40},{-1549,-40},{-1594,38},{-1593,38},{-1594,39},{-1593,39},{-1608,47},{-1607,47},{-1575,19},{-1575,20},{-1572,17},{-1574,18},{-1574,20}}}, - {"Asia/Qyzylorda",141,{{593,453},{594,452},{589,454},{589,455},{593,456},{592,453},{592,455},{593,455},{592,454},{678,523},{677,522},{680,520},{678,515},{680,510},{677,508},{681,504},{676,502},{661,490},{655,488},{648,489},{647,487},{644,487},{646,485},{642,485},{643,483},{640,482},{638,485},{631,487},{631,489},{628,488},{623,492},{625,493},{623,495},{625,495},{626,499},{629,500},{624,507},{622,507},{624,509},{622,511},{604,517},{605,518},{600,519},{600,520},{611,523},{607,527},{610,530},{621,530},{612,533},{613,535},{616,535},{609,536},{612,538},{610,540},{613,539},{614,541},{616,540},{624,541},{626,539},{632,542},{652,543},{652,545},{659,547},{661,546},{662,543},{661,542},{664,541},{660,540},{662,538},{661,535},{663,535},{663,532},{664,532},{661,531},{664,529},{661,528},{660,524},{666,524},{665,523},{673,522},{673,524},{675,524},{660,429},{658,429},{657,433},{651,438},{645,436},{634,437},{620,435},{607,446},{610,448},{606,458},{608,460},{608,461},{612,463},{614,466},{609,464},{608,467},{606,468},{608,466},{604,465},{603,467},{600,464},{607,464},{608,462},{598,461},{598,463},{595,463},{597,460},{595,458},{592,458},{594,460},{588,459},{586,456},{586,458},{601,469},{604,469},{604,473},{610,472},{614,478},{621,478},{629,471},{627,470},{631,471},{651,465},{656,462},{671,462},{674,458},{672,453},{675,452},{675,444},{681,440},{677,434},{678,432},{662,424},{661,424},{661,430},{600,457},{602,457},{597,456},{598,457}}}, - {"Asia/Aqtobe",62,{{545,505},{547,506},{547,509},{551,509},{557,506},{561,507},{562,509},{565,511},{567,510},{568,511},{572,511},{575,509},{577,509},{578,511},{583,512},{586,508},{595,505},{598,506},{601,509},{605,507},{614,508},{616,512},{619,513},{624,509},{622,507},{624,507},{629,500},{626,499},{625,495},{623,495},{625,493},{623,492},{628,488},{631,489},{631,487},{638,485},{643,479},{629,471},{619,478},{614,478},{610,472},{604,473},{604,469},{601,469},{590,460},{587,459},{586,456},{568,452},{566,460},{563,465},{554,467},{550,472},{551,479},{549,481},{549,487},{540,488},{540,492},{536,492},{536,495},{545,496},{546,500},{544,503}}}, - {"America/Eirunepe",17,{{-676,-95},{-704,-82},{-726,-76},{-738,-71},{-736,-68},{-731,-65},{-732,-60},{-730,-57},{-729,-52},{-719,-45},{-709,-44},{-706,-41},{-703,-41},{-702,-44},{-701,-43},{-700,-44},{-699,-42}}}, - {"Europe/Isle_of_Man",5,{{-48,541},{-48,540},{-44,543},{-44,542},{-45,544}}}, - {"America/Blanc-Sablon",90,{{-579,513},{-599,503},{-598,503},{-595,505},{-577,513},{-577,514},{-594,505},{-594,506},{-578,513},{-578,514},{-596,503},{-597,503},{-602,502},{-602,503},{-598,504},{-616,502},{-613,502},{-611,502},{-609,502},{-608,502},{-603,502},{-600,502},{-605,502},{-601,502},{-604,502},{-592,506},{-591,506},{-593,505},{-593,506},{-588,510},{-596,505},{-603,503},{-609,503},{-610,503},{-610,502},{-612,502},{-617,501},{-618,501},{-612,503},{-613,504},{-603,504},{-588,508},{-589,508},{-589,509},{-589,510},{-586,510},{-587,510},{-586,511},{-588,511},{-587,511},{-585,511},{-584,512},{-584,511},{-585,512},{-586,512},{-571,514},{-572,514},{-579,514},{-582,512},{-582,513},{-576,514},{-577,515},{-573,514},{-573,515},{-571,516},{-577,516},{-584,513},{-583,512},{-583,513},{-585,513},{-591,507},{-580,513},{-583,514},{-587,512},{-584,515},{-596,507},{-596,506},{-593,507},{-591,508},{-592,507},{-587,514},{-590,510},{-590,507},{-590,509},{-594,507},{-594,509},{-591,510},{-592,512},{-589,512},{-589,514}}}, - {"America/Montevideo",42,{{-549,-350},{-550,-350},{-559,-350},{-559,-349},{-584,-340},{-575,-345},{-576,-345},{-564,-348},{-582,-331},{-581,-330},{-581,-329},{-580,-329},{-581,-331},{-560,-349},{-563,-349},{-572,-345},{-579,-345},{-584,-339},{-584,-332},{-582,-319},{-580,-317},{-581,-315},{-578,-309},{-579,-305},{-576,-302},{-574,-303},{-571,-301},{-568,-301},{-560,-308},{-560,-311},{-556,-309},{-552,-313},{-546,-314},{-537,-321},{-536,-324},{-531,-327},{-535,-332},{-535,-337},{-534,-338},{-535,-341},{-541,-347},{-555,-347}}}, - {"Asia/Tashkent",54,{{687,401},{690,401},{688,401},{689,399},{688,400},{685,395},{677,397},{674,395},{673,397},{675,399},{669,401},{669,405},{666,405},{668,408},{666,411},{668,412},{680,412},{686,409},{692,414},{700,418},{704,421},{706,420},{711,423},{713,422},{702,415},{707,415},{708,412},{714,411},{717,416},{719,413},{719,412},{722,412},{722,410},{731,408},{726,405},{724,406},{724,404},{722,405},{717,401},{712,403},{706,402},{703,405},{708,407},{704,410},{697,406},{694,408},{692,405},{693,402},{685,401},{711,400},{710,400},{710,402},{712,399},{711,399}}}, - {"America/Argentina/La_Rioja",21,{{-680,-300},{-683,-297},{-690,-296},{-689,-289},{-696,-284},{-691,-278},{-684,-277},{-684,-280},{-679,-281},{-678,-284},{-675,-282},{-665,-284},{-664,-289},{-658,-292},{-651,-301},{-654,-301},{-658,-311},{-658,-319},{-667,-319},{-670,-315},{-672,-307}}}, - {"Pacific/Kosrae",3,{{1630,53},{1629,53},{1630,54}}}, - {"America/Indiana/Winamac",4,{{-865,412},{-865,409},{-869,409},{-869,412}}}, - {"Africa/Mogadishu",63,{{423,-7},{423,-6},{425,-4},{426,-4},{419,-12},{419,-11},{420,-11},{420,-10},{421,-10},{421,-9},{422,-8},{423,-8},{435,114},{433,114},{434,115},{435,115},{429,0},{421,-8},{420,-7},{420,-9},{419,-9},{418,-11},{417,-12},{418,-12},{416,-17},{410,-8},{410,28},{421,42},{428,43},{431,46},{438,49},{450,49},{480,80},{470,80},{440,90},{433,96},{427,106},{433,115},{440,107},{446,104},{450,104},{458,109},{464,107},{474,112},{480,111},{485,113},{494,113},{503,116},{508,120},{513,118},{511,113},{512,106},{510,104},{512,104},{514,104},{509,103},{508,94},{501,82},{498,80},{490,60},{480,45},{460,24},{446,16}}}, - {"Asia/Phnom_Penh",65,{{1033,105},{1033,106},{1034,106},{1035,106},{1029,99},{1030,99},{1031,103},{1030,104},{1038,104},{1043,104},{1036,105},{1037,105},{1038,105},{1035,105},{1033,108},{1033,107},{1032,107},{1030,112},{1030,114},{1030,113},{1031,110},{1030,110},{1031,109},{1032,108},{1058,116},{1059,113},{1062,111},{1062,108},{1059,109},{1058,110},{1054,108},{1051,110},{1051,107},{1045,104},{1039,107},{1037,109},{1036,112},{1034,109},{1031,115},{1027,122},{1028,125},{1025,127},{1023,136},{1026,136},{1030,142},{1036,144},{1048,144},{1051,142},{1052,143},{1054,141},{1056,142},{1061,139},{1062,141},{1060,144},{1065,146},{1070,143},{1076,147},{1073,141},{1076,135},{1075,123},{1064,120},{1064,117},{1060,118},{1031,114},{1030,115}}}, - {"Africa/Banjul",17,{{-139,135},{-138,134},{-142,132},{-151,136},{-153,134},{-158,133},{-158,132},{-168,131},{-168,133},{-167,135},{-165,133},{-156,134},{-164,133},{-166,136},{-155,136},{-151,138},{-143,135}}}, - {"Pacific/Efate",119,{{1693,-190},{1690,-189},{1690,-186},{1693,-188},{1699,-202},{1698,-202},{1698,-201},{1702,-195},{1695,-195},{1694,-196},{1693,-193},{1694,-193},{1696,-193},{1696,-192},{1682,-176},{1681,-176},{1683,-178},{1684,-175},{1685,-175},{1683,-174},{1684,-174},{1683,-175},{1684,-178},{1682,-177},{1686,-177},{1682,-175},{1684,-173},{1684,-172},{1684,-171},{1684,-170},{1683,-171},{1686,-170},{1685,-169},{1686,-169},{1682,-164},{1680,-163},{1679,-162},{1682,-161},{1683,-163},{1678,-165},{1682,-165},{1683,-164},{1672,-157},{1673,-157},{1674,-160},{1673,-159},{1683,-168},{1682,-168},{1682,-166},{1685,-168},{1675,-166},{1678,-166},{1683,-165},{1684,-165},{1672,-159},{1681,-150},{1682,-152},{1682,-154},{1681,-149},{1672,-153},{1672,-154},{1681,-144},{1680,-144},{1675,-143},{1674,-143},{1674,-142},{1676,-142},{1677,-138},{1677,-137},{1676,-137},{1677,-136},{1675,-136},{1673,-135},{1674,-135},{1674,-136},{1667,-134},{1667,-135},{1666,-133},{1666,-134},{1676,-138},{1676,-139},{1675,-137},{1675,-139},{1674,-138},{1677,-133},{1676,-133},{1676,-132},{1677,-132},{1666,-132},{1666,-131},{1665,-132},{1671,-151},{1671,-150},{1671,-149},{1672,-150},{1672,-158},{1671,-157},{1672,-156},{1669,-156},{1670,-156},{1682,-160},{1681,-157},{1682,-155},{1683,-159},{1678,-155},{1678,-153},{1680,-153},{1679,-155},{1672,-155},{1673,-154},{1671,-156},{1673,-155},{1673,-156},{1668,-150},{1669,-153},{1670,-149},{1668,-157},{1665,-148},{1666,-146}}}, - {"America/Creston",7,{{-1157,490},{-1170,491},{-1167,493},{-1169,498},{-1166,497},{-1167,495},{-1163,495}}}, - {"Europe/Brussels",25,{{30,508},{26,508},{25,511},{32,513},{39,512},{45,515},{50,515},{52,513},{58,512},{57,508},{63,506},{62,505},{64,503},{60,502},{57,499},{59,496},{55,495},{49,498},{49,502},{42,500},{42,503},{37,503},{36,505},{33,505},{33,507}}}, - {"Asia/Gaza",4,{{345,316},{345,315},{343,312},{342,313}}}, - {"America/Managua",42,{{-830,123},{-831,121},{-831,122},{-830,122},{-850,110},{-856,112},{-858,111},{-877,130},{-876,131},{-874,129},{-870,130},{-869,133},{-867,133},{-868,138},{-863,138},{-860,141},{-857,138},{-858,140},{-852,143},{-852,146},{-849,148},{-845,146},{-835,150},{-832,150},{-833,148},{-832,143},{-836,134},{-835,124},{-837,122},{-836,116},{-839,114},{-837,108},{-842,108},{-847,111},{-826,143},{-828,143},{-828,144},{-827,144},{-829,144},{-827,145},{-827,146},{-826,145}}}, - {"Africa/Niamey",52,{{46,137},{41,135},{41,130},{36,125},{36,117},{28,124},{24,122},{24,119},{21,124},{23,124},{21,127},{16,126},{10,131},{10,134},{13,134},{6,137},{4,140},{2,145},{2,150},{10,150},{13,153},{35,153},{39,157},{41,169},{42,170},{42,191},{58,194},{74,208},{120,235},{135,232},{142,226},{150,230},{152,215},{160,203},{157,198},{155,169},{144,157},{137,146},{135,145},{136,137},{129,135},{125,131},{115,134},{107,134},{101,132},{97,128},{90,128},{78,133},{69,130},{64,136},{55,139},{53,137}}}, - {"Europe/Monaco",3,{{74,437},{74,438},{75,438}}}, - {"Africa/Ouagadougou",51,{{-7,110},{-28,110},{-29,106},{-28,104},{-28,94},{-32,99},{-39,99},{-43,96},{-45,97},{-47,97},{-52,103},{-55,104},{-55,111},{-52,114},{-54,118},{-46,121},{-44,123},{-45,127},{-42,128},{-44,131},{-40,135},{-34,132},{-32,133},{-33,137},{-29,137},{-28,141},{-25,143},{-21,142},{-20,145},{-17,145},{-7,151},{-3,151},{2,150},{2,145},{4,140},{6,137},{13,134},{10,134},{10,131},{16,126},{20,127},{22,126},{23,124},{21,124},{24,119},{20,114},{14,114},{11,113},{11,110},{5,109},{-3,112}}}, - {"Atlantic/Bermuda",5,{{-647,324},{-647,323},{-648,323},{-649,322},{-649,323}}}, - {"America/Indiana/Knox",4,{{-865,414},{-865,412},{-869,412},{-867,414}}}, - {"America/El_Salvador",14,{{-879,134},{-878,134},{-877,132},{-878,132},{-877,133},{-878,133},{-896,135},{-901,138},{-894,144},{-885,139},{-881,140},{-877,138},{-879,131},{-885,132}}}, - {"Pacific/Easter",4,{{-1093,-271},{-1092,-271},{-1095,-272},{-1094,-271}}}, - {"Atlantic/Canary",35,{{-180,278},{-180,276},{-182,277},{-182,278},{-155,281},{-154,282},{-154,279},{-157,278},{-158,280},{-173,280},{-173,282},{-171,281},{-163,286},{-161,285},{-167,280},{-169,283},{-180,288},{-177,287},{-178,284},{-180,287},{-137,291},{-135,292},{-135,293},{-135,294},{-138,285},{-139,282},{-145,281},{-142,282},{-140,287},{-138,287},{-138,288},{-134,292},{-135,290},{-139,289},{-138,291}}}, - {"Asia/Bangkok",256,{{992,65},{992,66},{993,66},{999,67},{998,67},{994,66},{1021,63},{1020,63},{995,70},{998,68},{995,68},{996,68},{997,68},{1014,69},{997,69},{997,70},{1001,65},{993,65},{995,66},{996,66},{996,67},{997,65},{998,66},{983,75},{984,76},{991,72},{996,71},{992,74},{991,75},{994,72},{994,73},{995,73},{996,73},{993,73},{992,73},{993,74},{995,74},{991,76},{992,76},{985,80},{985,81},{987,81},{976,86},{976,85},{986,82},{986,83},{985,82},{985,83},{986,81},{976,87},{978,88},{978,90},{978,91},{983,89},{983,90},{982,90},{983,92},{983,91},{993,92},{983,93},{988,77},{988,78},{984,77},{985,77},{985,78},{984,78},{995,108},{995,109},{991,77},{990,76},{985,79},{984,80},{991,79},{984,79},{990,79},{990,78},{989,78},{986,80},{986,79},{983,78},{983,79},{983,82},{984,81},{985,99},{998,101},{999,101},{987,101},{987,102},{993,102},{993,103},{993,104},{994,104},{1024,118},{1025,118},{1025,119},{1024,119},{1023,119},{1025,120},{1000,122},{1023,120},{1023,122},{1024,121},{1022,123},{1010,125},{996,111},{995,111},{1025,116},{1025,117},{1026,118},{1026,116},{1007,129},{1007,130},{1008,129},{1018,126},{1014,125},{1014,126},{1015,126},{1008,127},{1009,126},{1010,126},{1008,131},{1008,132},{1000,94},{993,93},{993,94},{979,94},{999,94},{997,94},{978,94},{978,95},{979,95},{1000,93},{999,93},{998,93},{1017,66},{1021,62},{1019,59},{1018,57},{1016,59},{1014,59},{1011,56},{1010,58},{1011,63},{1009,62},{1008,64},{1004,65},{1003,67},{1001,64},{998,71},{996,74},{993,77},{991,78},{990,77},{991,80},{988,80},{986,84},{982,86},{988,107},{997,118},{994,126},{991,131},{992,133},{991,139},{986,143},{982,151},{983,153},{986,154},{986,161},{988,161},{989,164},{987,163},{985,169},{978,177},{976,183},{975,183},{973,186},{978,186},{977,189},{980,198},{983,197},{989,197},{991,201},{995,201},{995,204},{997,203},{1000,205},{1001,203},{1003,204},{1006,202},{1004,198},{1005,195},{1013,196},{1012,194},{1014,190},{1011,184},{1012,181},{1010,176},{1012,175},{1021,182},{1027,178},{1030,180},{1033,184},{1040,183},{1048,174},{1048,165},{1056,157},{1055,153},{1056,150},{1055,146},{1051,142},{1048,144},{1036,144},{1030,142},{1026,136},{1023,136},{1025,127},{1028,124},{1027,122},{1029,118},{1029,116},{1026,122},{1026,120},{1018,127},{1010,135},{1003,135},{1000,133},{1001,130},{1000,127},{996,113},{992,105},{991,103},{992,102},{991,98},{992,93},{1000,86},{1002,84},{1005,73},{1010,69},{1015,69},{983,95},{984,95},{1000,96},{1001,95},{999,96},{997,95},{985,96},{997,96},{997,97},{1000,98},{1001,98},{1001,97},{1000,97},{984,97},{984,98},{985,98},{997,98}}}, - {"Asia/Vientiane",72,{{1063,145},{1060,144},{1062,141},{1061,139},{1052,143},{1055,146},{1056,150},{1055,153},{1056,157},{1048,165},{1048,174},{1040,183},{1033,184},{1030,180},{1027,178},{1021,182},{1012,175},{1010,176},{1012,181},{1011,184},{1014,190},{1012,194},{1013,196},{1005,195},{1004,198},{1006,202},{1003,204},{1002,202},{1001,204},{1003,207},{1006,209},{1005,209},{1007,213},{1012,216},{1013,212},{1018,211},{1018,218},{1015,222},{1017,225},{1021,224},{1027,217},{1028,218},{1030,216},{1028,213},{1032,209},{1037,207},{1041,210},{1046,207},{1044,204},{1046,204},{1050,200},{1047,196},{1040,197},{1041,195},{1039,193},{1051,187},{1052,183},{1055,182},{1058,177},{1066,170},{1067,165},{1068,165},{1070,163},{1075,161},{1072,157},{1077,153},{1075,150},{1076,149},{1075,145},{1073,146},{1069,143},{1065,146}}}, - {"Europe/Bucharest",42,{{296,449},{296,448},{295,448},{282,455},{287,452},{293,454},{297,453},{291,448},{286,443},{286,437},{270,442},{261,440},{256,436},{242,437},{229,439},{230,441},{225,445},{227,446},{224,447},{221,445},{214,448},{216,449},{214,450},{215,452},{208,455},{208,458},{203,461},{212,463},{220,475},{232,481},{239,479},{246,480},{249,477},{262,480},{263,482},{267,483},{270,481},{276,473},{281,470},{283,464},{281,462},{281,456}}}, - {"Africa/Lusaka",70,{{289,-159},{288,-165},{278,-170},{270,-180},{267,-181},{262,-179},{260,-180},{257,-178},{254,-179},{247,-175},{234,-176},{221,-165},{220,-162},{220,-130},{240,-130},{239,-128},{241,-124},{241,-109},{244,-111},{243,-114},{244,-115},{254,-112},{253,-116},{260,-119},{269,-120},{270,-116},{272,-116},{276,-123},{279,-122},{284,-125},{290,-134},{296,-132},{296,-134},{298,-135},{298,-122},{295,-122},{295,-125},{291,-124},{284,-118},{284,-115},{287,-107},{286,-102},{287,-98},{285,-94},{284,-93},{289,-88},{289,-85},{308,-82},{311,-86},{314,-86},{320,-91},{330,-94},{330,-96},{332,-96},{334,-99},{333,-101},{337,-106},{332,-109},{334,-112},{332,-114},{333,-121},{335,-124},{330,-127},{330,-132},{327,-136},{330,-140},{332,-140},{302,-150},{304,-156},{296,-156}}}, - {"Asia/Kathmandu",43,{{851,283},{856,283},{860,279},{862,282},{864,279},{867,281},{871,278},{882,279},{880,271},{882,268},{881,264},{873,264},{871,266},{867,264},{863,266},{859,266},{856,269},{852,268},{846,270},{846,273},{842,275},{839,274},{834,275},{833,273},{828,275},{827,277},{819,279},{801,289},{803,291},{804,298},{809,302},{812,300},{814,304},{816,304},{822,303},{822,301},{832,296},{835,292},{842,292},{841,289},{844,287},{849,286},{851,287}}}, - {"Africa/Harare",37,{{311,-223},{294,-222},{291,-220},{290,-218},{280,-216},{277,-211},{277,-205},{273,-205},{272,-201},{262,-195},{253,-178},{267,-181},{270,-180},{278,-170},{288,-165},{289,-159},{296,-156},{304,-156},{304,-160},{312,-160},{319,-164},{330,-167},{328,-169},{330,-173},{329,-180},{331,-184},{329,-185},{329,-188},{327,-189},{329,-191},{328,-195},{331,-198},{330,-200},{325,-206},{324,-211},{325,-213},{314,-224}}}, - {"America/Denver",97,{{-1101,358},{-1101,357},{-1102,357},{-1129,444},{-1131,448},{-1135,449},{-1139,457},{-1143,455},{-1146,456},{-1146,458},{-1144,459},{-1145,461},{-1143,466},{-1148,467},{-1153,473},{-1158,474},{-1156,475},{-1157,477},{-1160,480},{-1161,490},{-1040,490},{-1040,480},{-1038,478},{-1037,476},{-1035,475},{-1030,477},{-1025,475},{-1023,476},{-1021,467},{-1013,466},{-1013,464},{-1010,464},{-1013,459},{-1004,459},{-1003,457},{-1005,455},{-1003,454},{-1003,450},{-1005,448},{-1007,448},{-1004,444},{-1006,442},{-1010,442},{-1011,438},{-1012,438},{-1012,430},{-1009,430},{-1007,421},{-1008,417},{-1014,417},{-1012,410},{-1013,400},{-1020,400},{-1020,396},{-1014,396},{-1016,387},{-1015,377},{-1020,377},{-1020,370},{-1030,370},{-1031,320},{-1049,320},{-1049,307},{-1054,309},{-1065,318},{-1082,318},{-1082,313},{-1090,313},{-1090,352},{-1112,352},{-1113,358},{-1117,357},{-1119,364},{-1116,369},{-1114,370},{-1113,369},{-1112,369},{-1113,370},{-1141,370},{-1140,420},{-1110,420},{-1110,445},{-1114,448},{-1115,445},{-1123,446},{-1108,364},{-1110,363},{-1110,355},{-1103,355},{-1100,356},{-1101,360},{-1106,360},{-1103,364},{-1111,361},{-1112,362},{-1113,361},{-1111,360}}}, - {"America/Guadeloupe",20,{{-610,163},{-611,163},{-610,164},{-630,181},{-616,158},{-616,159},{-613,160},{-612,159},{-613,159},{-611,162},{-617,163},{-616,161},{-617,159},{-618,163},{-616,163},{-616,164},{-615,164},{-615,165},{-612,163},{-615,162}}}, - {"Africa/Lome",24,{{14,62},{11,62},{5,68},{7,73},{5,75},{6,82},{7,83},{4,87},{5,89},{6,94},{2,95},{4,96},{4,103},{-1,106},{0,111},{-1,111},{5,109},{9,110},{8,104},{14,100},{13,95},{16,90},{16,67},{18,63}}}, - {"Indian/Reunion",4,{{553,-209},{557,-209},{558,-213},{553,-213}}}, - {"Europe/Kiev",168,{{377,471},{323,465},{298,454},{298,455},{329,460},{328,460},{326,461},{331,460},{322,461},{321,462},{320,462},{350,462},{349,462},{350,463},{317,463},{319,462},{317,462},{316,463},{315,463},{315,464},{318,463},{317,464},{318,464},{390,479},{383,476},{382,473},{383,473},{382,472},{382,471},{381,470},{376,471},{373,469},{370,469},{371,470},{369,472},{372,475},{367,476},{366,478},{361,478},{360,481},{348,481},{349,475},{342,475},{343,473},{345,473},{346,470},{348,468},{346,467},{351,463},{346,462},{346,460},{344,460},{345,462},{343,462},{343,461},{342,463},{341,461},{336,462},{335,460},{332,461},{332,462},{320,465},{315,465},{315,466},{324,465},{320,466},{320,469},{319,466},{314,466},{315,467},{316,468},{316,469},{314,468},{308,465},{305,461},{302,459},{297,456},{299,457},{296,458},{297,452},{293,454},{287,452},{282,455},{285,455},{285,457},{290,460},{289,465},{292,466},{293,464},{294,465},{296,464},{301,464},{299,465},{300,468},{296,470},{296,474},{294,473},{291,475},{293,478},{292,480},{286,482},{285,481},{284,482},{276,485},{267,484},{268,483},{263,482},{262,480},{249,477},{246,480},{245,483},{241,484},{241,485},{239,485},{238,486},{229,489},{227,495},{237,504},{241,505},{240,508},{242,509},{237,513},{236,516},{242,517},{244,519},{272,518},{273,516},{277,516},{277,515},{283,517},{288,514},{292,516},{293,514},{302,515},{306,513},{307,513},{305,516},{309,521},{320,520},{324,521},{324,523},{329,522},{338,524},{345,518},{341,517},{343,515},{343,513},{351,512},{352,511},{354,511},{354,506},{356,504},{361,505},{366,502},{375,504},{380,499},{383,501},{398,496},{401,496},{402,492},{397,490},{401,489},{398,488},{397,486},{399,486},{399,483},{400,482},{397,478}}}, - {"Europe/Vienna",48,{{95,475},{100,476},{102,474},{102,473},{105,474},{104,476},{113,474},{123,477},{128,477},{130,475},{131,476},{129,477},{130,479},{128,481},{133,483},{135,486},{137,485},{138,488},{143,485},{147,486},{148,488},{150,488},{150,490},{161,487},{169,487},{168,484},{172,480},{170,479},{171,477},{164,477},{167,475},{164,474},{165,470},{160,468},{160,467},{150,467},{146,464},{124,467},{121,469},{122,471},{112,470},{110,468},{105,469},{104,470},{101,468},{96,471},{95,473},{97,474}}}, - {"America/Argentina/Cordoba",76,{{-629,-344},{-634,-344},{-634,-350},{-651,-350},{-651,-332},{-649,-326},{-649,-323},{-652,-323},{-653,-321},{-658,-319},{-658,-311},{-654,-301},{-649,-299},{-649,-296},{-652,-287},{-651,-284},{-652,-279},{-650,-278},{-651,-275},{-645,-267},{-645,-262},{-642,-256},{-634,-257},{-623,-244},{-623,-225},{-620,-230},{-610,-238},{-600,-240},{-591,-246},{-577,-253},{-576,-256},{-578,-257},{-578,-260},{-582,-262},{-582,-266},{-586,-271},{-586,-273},{-580,-273},{-569,-276},{-566,-274},{-564,-276},{-561,-273},{-557,-274},{-554,-270},{-548,-267},{-546,-256},{-544,-257},{-541,-255},{-541,-256},{-539,-256},{-536,-263},{-538,-271},{-542,-273},{-543,-274},{-548,-275},{-550,-279},{-558,-282},{-557,-284},{-559,-284},{-579,-305},{-578,-309},{-581,-315},{-580,-317},{-582,-319},{-581,-330},{-584,-331},{-585,-335},{-584,-340},{-596,-337},{-603,-333},{-605,-336},{-609,-336},{-617,-344},{-585,-339},{-583,-331},{-582,-331}}}, - {"America/Nassau",261,{{-757,235},{-767,244},{-767,245},{-771,264},{-770,264},{-788,266},{-788,267},{-758,224},{-753,236},{-760,237},{-761,237},{-756,234},{-736,211},{-733,211},{-730,213},{-732,210},{-737,209},{-730,215},{-729,215},{-730,214},{-731,215},{-739,217},{-738,217},{-743,221},{-727,223},{-758,223},{-742,223},{-741,224},{-757,222},{-758,222},{-757,223},{-731,224},{-731,225},{-728,223},{-758,225},{-736,231},{-737,231},{-738,231},{-755,234},{-756,235},{-760,234},{-760,235},{-758,235},{-759,235},{-757,234},{-739,227},{-738,225},{-740,224},{-743,222},{-739,225},{-740,226},{-740,227},{-742,225},{-743,225},{-735,226},{-736,226},{-742,227},{-744,225},{-744,226},{-743,227},{-743,226},{-743,228},{-741,227},{-752,232},{-758,234},{-760,236},{-777,237},{-759,229},{-757,230},{-750,231},{-749,230},{-748,229},{-751,233},{-753,237},{-752,235},{-804,237},{-778,238},{-762,238},{-805,239},{-805,240},{-803,240},{-804,240},{-768,245},{-768,246},{-759,246},{-758,246},{-745,240},{-746,239},{-745,241},{-744,241},{-763,239},{-763,240},{-772,240},{-777,240},{-778,240},{-777,241},{-751,238},{-751,239},{-778,239},{-762,239},{-776,238},{-777,239},{-775,238},{-775,239},{-761,238},{-777,238},{-760,246},{-785,247},{-785,246},{-784,246},{-784,247},{-778,244},{-781,252},{-781,253},{-768,247},{-777,247},{-777,246},{-773,251},{-782,251},{-763,248},{-768,248},{-779,249},{-779,250},{-780,250},{-776,250},{-774,251},{-773,250},{-774,250},{-771,251},{-772,251},{-780,271},{-766,243},{-766,244},{-779,244},{-779,243},{-777,243},{-778,243},{-777,244},{-776,242},{-779,241},{-765,242},{-776,269},{-764,241},{-764,242},{-754,241},{-755,241},{-754,243},{-758,247},{-756,246},{-753,241},{-779,242},{-780,242},{-778,242},{-765,243},{-780,243},{-776,237},{-778,237},{-777,256},{-793,256},{-777,257},{-778,257},{-793,257},{-792,257},{-793,258},{-773,264},{-772,264},{-779,248},{-777,245},{-781,245},{-782,249},{-782,252},{-780,252},{-748,237},{-748,236},{-749,237},{-762,237},{-783,272},{-779,258},{-771,263},{-773,263},{-772,263},{-775,261},{-776,262},{-775,262},{-776,263},{-775,263},{-775,269},{-776,270},{-777,270},{-777,271},{-782,270},{-782,269},{-781,271},{-773,265},{-772,265},{-773,267},{-773,266},{-770,266},{-772,258},{-773,260},{-774,260},{-772,261},{-771,265},{-770,265},{-771,267},{-771,266},{-789,267},{-774,266},{-778,266},{-779,266},{-774,267},{-772,267},{-783,267},{-785,267},{-784,268},{-784,267},{-785,268},{-783,268},{-773,268},{-779,268},{-787,266},{-774,265},{-778,265},{-772,266},{-779,265},{-779,267},{-774,268},{-779,269},{-777,269},{-775,268},{-786,269},{-778,269},{-780,269},{-761,250},{-764,253},{-768,254},{-767,256},{-761,251},{-761,246},{-762,248},{-780,267},{-787,265},{-789,266},{-790,267},{-788,265},{-786,268},{-780,268},{-769,253},{-769,254},{-778,255},{-766,255},{-777,255},{-769,255},{-768,255},{-768,253},{-779,254},{-778,254},{-793,255},{-768,256},{-767,255},{-766,256}}}, - {"Asia/Kuching",161,{{1098,19},{1163,64},{1188,44},{1187,44},{1113,26},{1113,28},{1114,23},{1113,24},{1114,27},{1114,28},{1113,14},{1103,17},{1101,17},{1102,18},{1151,52},{1153,53},{1152,53},{1152,54},{1153,54},{1191,54},{1191,55},{1156,57},{1157,57},{1157,58},{1179,58},{1181,58},{1160,58},{1160,59},{1181,59},{1179,42},{1177,42},{1176,42},{1177,43},{1186,42},{1189,43},{1186,44},{1183,43},{1189,45},{1190,46},{1189,46},{1186,45},{1187,45},{1188,45},{1185,45},{1185,46},{1186,46},{1183,47},{1185,47},{1188,46},{1187,46},{1183,48},{1183,50},{1184,50},{1183,49},{1184,47},{1184,48},{1177,62},{1177,63},{1173,71},{1170,71},{1171,71},{1173,73},{1173,72},{1169,72},{1169,73},{1170,74},{1170,72},{1171,72},{1172,71},{1172,72},{1173,74},{1171,73},{1152,49},{1155,51},{1156,52},{1154,54},{1156,56},{1159,56},{1167,70},{1169,68},{1168,66},{1171,70},{1173,66},{1177,64},{1176,59},{1180,60},{1179,57},{1183,58},{1193,53},{1191,51},{1186,49},{1181,49},{1185,43},{1180,42},{1176,44},{1172,44},{1162,44},{1161,43},{1159,44},{1156,39},{1156,32},{1151,28},{1152,25},{1148,23},{1149,19},{1147,19},{1146,14},{1140,14},{1137,12},{1130,14},{1130,16},{1125,16},{1118,10},{1112,11},{1106,9},{1097,16},{1095,19},{1096,21},{1099,17},{1103,18},{1107,16},{1107,14},{1108,16},{1111,14},{1113,13},{1110,16},{1112,17},{1112,21},{1113,21},{1112,22},{1112,24},{1115,23},{1130,32},{1139,42},{1140,46},{1143,45},{1146,40},{1149,44},{1148,47},{1150,49},{1151,44},{1153,43},{1177,59},{1177,60},{1161,61},{1180,61},{1156,62},{1176,62},{1160,60},{1161,60},{1177,61},{1174,66},{1163,67},{1173,68},{1175,69},{1172,70},{1173,70},{1174,67},{1175,68},{1175,67},{1164,67}}}, - {"America/Guyana",57,{{-585,67},{-586,67},{-586,66},{-575,63},{-572,61},{-573,53},{-572,52},{-579,48},{-578,46},{-581,40},{-577,34},{-573,34},{-572,28},{-567,20},{-565,19},{-573,20},{-575,17},{-580,17},{-580,15},{-583,16},{-585,13},{-588,12},{-598,19},{-597,23},{-599,24},{-600,29},{-598,36},{-595,39},{-597,42},{-597,44},{-602,45},{-600,51},{-602,53},{-607,52},{-614,60},{-611,62},{-612,67},{-607,68},{-603,71},{-606,72},{-607,75},{-598,83},{-600,86},{-591,80},{-585,74},{-586,64},{-583,69},{-580,68},{-585,70},{-585,71},{-585,69},{-584,70},{-583,70},{-584,69},{-586,68},{-586,69},{-585,68}}}, - {"Pacific/Enderbury",13,{{-1745,-47},{-1722,-45},{-1713,-45},{-1712,-44},{-1712,-45},{-1721,-45},{-1707,-37},{-1741,-36},{-1711,-31},{-1715,-36},{-1716,-28},{-1717,-28},{-1716,-29}}}, - {"Atlantic/Azores",34,{{-251,369},{-252,369},{-252,370},{-251,370},{-254,377},{-253,379},{-251,378},{-257,377},{-259,379},{-258,379},{-284,386},{-281,384},{-280,384},{-285,385},{-279,390},{-280,390},{-281,391},{-280,391},{-312,395},{-312,394},{-313,395},{-311,397},{-288,386},{-287,386},{-286,385},{-288,385},{-281,387},{-280,387},{-278,385},{-283,388},{-271,388},{-271,386},{-274,387},{-273,388}}}, - {"America/Winnipeg",52,{{-921,484},{-924,482},{-925,484},{-927,485},{-926,485},{-930,486},{-938,485},{-946,487},{-948,493},{-952,494},{-952,490},{-1014,490},{-1018,541},{-1025,545},{-1025,548},{-1019,551},{-1020,600},{-948,600},{-947,594},{-948,594},{-948,591},{-950,591},{-946,589},{-944,587},{-932,588},{-928,580},{-928,578},{-924,574},{-927,569},{-910,573},{-890,568},{-900,562},{-900,540},{-890,540},{-885,536},{-885,534},{-890,530},{-890,528},{-900,528},{-900,520},{-908,515},{-908,512},{-900,508},{-900,495},{-910,492},{-910,490},{-918,490},{-918,487},{-923,485},{-920,484},{-928,579},{-927,578}}}, - {"Europe/Dublin",175,{{-106,520},{-106,521},{-105,521},{-60,535},{-102,534},{-61,534},{-62,534},{-99,534},{-101,535},{-102,535},{-100,536},{-103,536},{-102,536},{-101,537},{-100,537},{-96,538},{-100,538},{-99,538},{-101,538},{-72,554},{-97,538},{-96,539},{-99,539},{-100,539},{-102,541},{-102,542},{-91,542},{-92,542},{-86,543},{-87,544},{-86,544},{-84,550},{-85,550},{-100,540},{-103,540},{-102,540},{-99,540},{-86,550},{-75,551},{-75,550},{-82,552},{-84,551},{-83,553},{-82,553},{-99,523},{-85,551},{-95,514},{-95,515},{-96,515},{-94,515},{-102,516},{-95,517},{-98,516},{-99,516},{-102,517},{-103,517},{-99,518},{-93,515},{-83,519},{-82,519},{-83,518},{-104,519},{-103,519},{-66,521},{-95,526},{-91,526},{-90,526},{-90,527},{-91,527},{-104,518},{-89,527},{-95,528},{-95,531},{-95,530},{-96,531},{-97,531},{-98,531},{-91,531},{-91,532},{-90,532},{-97,532},{-98,532},{-97,533},{-98,533},{-99,533},{-96,533},{-96,532},{-100,533},{-66,540},{-61,540},{-64,540},{-62,538},{-63,537},{-61,536},{-62,535},{-60,530},{-64,523},{-65,524},{-64,522},{-68,523},{-69,521},{-69,522},{-70,523},{-70,521},{-76,521},{-76,520},{-79,520},{-81,518},{-84,519},{-86,517},{-85,516},{-98,515},{-95,518},{-96,519},{-101,517},{-98,522},{-104,521},{-105,522},{-97,523},{-100,524},{-96,526},{-95,525},{-88,526},{-88,527},{-87,527},{-86,527},{-89,528},{-90,528},{-92,526},{-99,526},{-93,531},{-89,531},{-89,532},{-100,535},{-97,536},{-95,538},{-98,539},{-98,541},{-100,541},{-100,542},{-101,541},{-101,543},{-93,543},{-91,541},{-91,543},{-87,543},{-86,542},{-85,542},{-81,547},{-85,546},{-88,547},{-84,548},{-86,548},{-83,548},{-83,549},{-85,549},{-83,552},{-79,551},{-78,553},{-78,552},{-77,551},{-76,553},{-77,550},{-75,553},{-73,553},{-74,554},{-69,552},{-74,550},{-75,547},{-79,547},{-77,546},{-82,545},{-76,541},{-73,541},{-70,544}}}, - {"America/Argentina/Ushuaia",30,{{-642,-547},{-642,-546},{-641,-546},{-643,-547},{-642,-548},{-643,-548},{-675,-549},{-674,-549},{-685,-549},{-642,-549},{-683,-549},{-640,-548},{-646,-549},{-648,-548},{-638,-547},{-686,-549},{-686,-527},{-683,-530},{-682,-531},{-684,-530},{-685,-533},{-681,-533},{-677,-538},{-673,-541},{-660,-546},{-651,-547},{-653,-549},{-660,-549},{-664,-551},{-683,-548}}}, - {"Asia/Colombo",36,{{798,79},{798,80},{798,83},{798,82},{798,84},{798,85},{812,85},{799,90},{799,89},{798,90},{797,91},{799,91},{817,65},{806,59},{801,62},{797,81},{797,82},{797,83},{802,95},{800,98},{802,98},{808,93},{812,86},{814,85},{819,73},{800,93},{801,93},{800,95},{797,96},{797,95},{798,96},{800,96},{799,96},{799,97},{799,98},{798,97}}}, - {"Asia/Krasnoyarsk",1323,{{809,724},{808,724},{807,724},{811,723},{810,723},{811,724},{811,722},{1054,728},{1055,728},{1057,728},{1058,728},{1057,729},{936,811},{935,811},{795,728},{790,727},{786,728},{791,731},{792,731},{793,731},{795,729},{1059,729},{1060,729},{1060,730},{1084,731},{1083,732},{1084,732},{804,732},{803,732},{1058,729},{1058,730},{1083,731},{806,732},{805,732},{788,732},{790,732},{793,732},{794,732},{803,734},{806,734},{805,734},{802,734},{801,735},{802,735},{805,736},{804,736},{1067,736},{1068,736},{1063,736},{1064,736},{847,738},{846,738},{847,739},{866,739},{1093,735},{803,735},{805,735},{1092,735},{867,739},{869,739},{868,739},{865,739},{867,740},{864,739},{863,740},{869,740},{868,740},{843,740},{842,740},{839,740},{844,740},{866,740},{849,740},{848,740},{842,696},{843,696},{844,696},{843,697},{836,697},{822,701},{831,701},{837,697},{835,697},{835,698},{838,697},{833,699},{834,699},{832,699},{831,700},{833,700},{835,699},{829,701},{827,707},{826,707},{834,700},{832,700},{832,703},{832,704},{835,704},{836,704},{833,704},{822,703},{829,702},{823,703},{822,704},{828,702},{831,702},{824,702},{823,702},{830,702},{830,703},{824,703},{826,702},{825,702},{825,708},{824,708},{833,708},{827,708},{826,708},{835,706},{836,706},{823,707},{824,707},{824,706},{831,706},{833,707},{832,707},{835,707},{825,707},{832,708},{834,704},{837,704},{822,705},{827,702},{829,704},{823,704},{828,704},{827,704},{827,705},{826,705},{837,705},{836,705},{823,706},{821,705},{831,704},{831,705},{833,705},{829,741},{830,741},{946,764},{945,764},{835,705},{834,705},{825,706},{833,706},{834,706},{832,705},{830,706},{829,707},{831,708},{829,706},{828,709},{830,708},{830,709},{833,709},{824,709},{825,709},{827,709},{830,710},{832,709},{824,710},{823,709},{829,709},{828,710},{829,710},{831,709},{825,710},{827,710},{826,710},{823,710},{1113,739},{1097,737},{1095,738},{1100,740},{1110,739},{1112,740},{1116,740},{864,741},{863,741},{824,740},{823,740},{873,740},{872,740},{873,741},{865,740},{867,741},{866,741},{868,741},{827,740},{825,741},{824,741},{828,741},{848,741},{836,741},{833,741},{853,742},{856,743},{855,743},{865,741},{852,741},{857,741},{854,741},{856,741},{854,742},{850,743},{852,743},{851,743},{853,743},{874,744},{873,744},{852,744},{851,744},{1104,745},{853,744},{849,744},{850,745},{850,744},{843,744},{856,744},{854,744},{843,745},{844,744},{842,745},{849,743},{1005,786},{1004,786},{998,779},{997,779},{795,745},{793,745},{792,746},{796,746},{857,747},{842,746},{842,747},{843,747},{843,746},{851,748},{852,749},{863,749},{864,749},{869,749},{868,749},{857,749},{856,749},{855,749},{882,752},{883,752},{881,753},{821,751},{821,752},{822,752},{863,750},{864,750},{866,747},{865,748},{868,748},{866,748},{855,747},{854,747},{856,748},{853,748},{852,748},{860,748},{859,748},{864,748},{1004,780},{1005,780},{1029,781},{858,748},{857,748},{859,749},{860,749},{867,749},{866,750},{872,749},{870,748},{869,748},{1137,754},{895,755},{895,756},{896,755},{897,755},{892,755},{893,755},{902,756},{899,756},{898,756},{880,756},{879,756},{881,757},{888,757},{891,757},{892,757},{887,757},{886,757},{918,757},{919,758},{928,758},{818,758},{817,758},{1137,759},{1136,759},{933,758},{933,759},{934,759},{927,758},{928,759},{930,758},{927,760},{926,760},{924,760},{923,760},{827,759},{826,759},{965,764},{966,764},{824,759},{819,759},{817,759},{820,760},{922,759},{921,759},{831,759},{829,760},{825,759},{823,760},{826,760},{833,759},{821,753},{863,753},{862,753},{823,753},{820,753},{820,752},{816,753},{818,752},{820,751},{817,752},{817,754},{821,754},{819,755},{864,753},{865,753},{818,754},{822,754},{820,755},{821,755},{823,755},{852,745},{853,746},{857,745},{1030,781},{932,811},{933,811},{1063,775},{1062,776},{859,745},{860,745},{860,746},{863,745},{848,744},{846,744},{845,745},{847,745},{846,745},{862,746},{861,746},{856,746},{857,746},{851,745},{850,746},{851,746},{848,745},{849,746},{938,782},{937,782},{936,782},{1069,782},{1066,784},{1065,784},{1066,783},{1067,784},{987,786},{988,787},{988,786},{979,787},{979,788},{980,788},{987,787},{978,788},{988,785},{987,785},{1068,783},{1063,782},{1061,782},{1048,783},{1049,783},{1075,780},{1076,781},{1064,781},{1077,781},{1029,782},{1021,782},{1032,782},{1031,782},{768,795},{761,796},{776,795},{775,795},{912,795},{911,795},{910,795},{909,795},{906,796},{909,796},{914,795},{929,796},{1001,796},{1002,796},{912,796},{911,796},{1001,797},{1002,797},{1004,797},{1000,796},{917,795},{918,794},{915,795},{916,794},{929,790},{927,791},{923,791},{924,791},{919,794},{924,794},{926,794},{923,794},{929,794},{927,794},{931,794},{930,794},{928,794},{925,794},{925,795},{986,788},{987,788},{1033,792},{1034,792},{1035,792},{1017,792},{1016,792},{1035,791},{1034,791},{968,790},{969,790},{999,792},{998,792},{998,793},{1000,793},{1000,794},{1001,795},{1002,794},{1001,794},{980,806},{915,804},{914,804},{927,805},{928,805},{974,802},{975,803},{975,802},{916,803},{981,807},{981,808},{795,808},{788,808},{786,808},{800,809},{1028,781},{1016,782},{1001,779},{995,780},{1006,786},{1007,788},{1013,787},{1009,788},{1011,790},{1017,790},{1015,791},{1013,791},{1014,792},{1019,793},{1023,792},{1022,793},{1025,794},{1032,793},{1024,788},{1028,788},{1030,790},{1039,792},{1047,789},{1045,788},{1041,789},{1053,787},{1054,785},{1008,788},{1050,789},{1049,789},{1048,789},{1042,790},{1044,790},{1043,790},{1033,791},{925,807},{926,807},{909,810},{902,811},{901,811},{911,812},{917,811},{969,801},{981,800},{979,800},{980,799},{965,797},{977,798},{972,797},{972,796},{983,798},{981,799},{985,799},{985,800},{987,801},{1001,798},{1002,798},{999,797},{1000,797},{998,796},{999,795},{992,793},{1000,789},{984,788},{956,791},{951,790},{944,792},{944,795},{939,794},{940,795},{937,796},{939,796},{935,795},{934,795},{932,795},{930,796},{947,798},{943,799},{950,801},{979,799},{978,799},{973,797},{968,797},{983,799},{982,799},{983,800},{944,799},{982,800},{945,800},{946,800},{984,800},{968,801},{980,801},{981,801},{917,801},{918,801},{951,801},{952,801},{914,800},{910,801},{939,799},{932,798},{935,798},{931,797},{918,796},{913,797},{924,798},{912,799},{914,799},{912,800},{940,800},{943,800},{944,800},{927,800},{926,800},{928,800},{949,801},{960,801},{961,801},{956,762},{957,762},{951,761},{950,762},{953,762},{952,761},{956,813},{980,807},{967,807},{972,806},{971,805},{973,802},{938,800},{922,801},{930,801},{922,803},{934,802},{933,803},{915,803},{928,803},{920,804},{929,805},{934,808},{933,809},{932,809},{967,536},{969,537},{983,532},{983,531},{989,532},{992,530},{988,528},{989,527},{986,524},{986,523},{989,521},{987,518},{983,517},{978,510},{980,507},{983,505},{983,503},{973,498},{966,500},{946,500},{943,506},{931,506},{930,508},{926,507},{924,509},{923,507},{918,507},{914,505},{907,505},{907,502},{896,499},{893,503},{895,505},{899,505},{891,511},{890,514},{887,516},{884,513},{879,515},{881,518},{878,518},{881,521},{887,522},{892,528},{889,530},{891,531},{890,533},{888,534},{888,536},{893,538},{890,541},{892,543},{889,544},{886,543},{884,544},{888,548},{884,553},{894,559},{891,563},{885,566},{887,567},{886,568},{887,571},{885,571},{891,576},{894,576},{894,579},{880,582},{879,585},{884,589},{888,590},{886,593},{879,593},{875,597},{872,597},{871,599},{845,600},{848,604},{843,609},{860,615},{847,618},{844,622},{856,630},{855,631},{857,634},{850,636},{860,641},{860,643},{858,645},{859,648},{843,649},{846,653},{845,655},{840,658},{835,658},{833,661},{835,662},{831,665},{831,666},{833,667},{832,668},{821,672},{824,673},{822,674},{824,675},{817,679},{824,679},{824,682},{827,683},{827,685},{825,686},{830,687},{826,688},{823,691},{825,692},{818,692},{818,693},{819,693},{817,694},{816,693},{810,692},{799,693},{795,697},{790,697},{791,697},{789,699},{793,700},{793,701},{802,704},{808,704},{806,705},{808,707},{806,707},{807,708},{806,711},{791,714},{794,716},{801,717},{800,718},{803,719},{789,721},{784,724},{806,721},{817,717},{833,717},{830,715},{830,714},{822,713},{823,711},{822,710},{821,706},{819,704},{818,702},{821,703},{820,703},{823,701},{827,701},{830,700},{827,700},{843,695},{846,696},{838,705},{834,710},{832,711},{837,716},{833,718},{827,719},{823,721},{825,721},{820,723},{808,725},{809,726},{807,727},{809,728},{808,730},{808,732},{803,733},{807,734},{871,738},{872,739},{875,741},{869,741},{867,742},{859,744},{863,743},{861,744},{865,745},{867,744},{870,744},{867,743},{870,743},{872,744},{858,747},{861,748},{870,746},{868,747},{874,749},{872,750},{878,750},{869,751},{882,751},{889,754},{891,754},{891,753},{892,754},{887,754},{898,754},{903,756},{917,756},{917,757},{921,757},{942,759},{928,760},{933,761},{935,761},{934,760},{948,761},{946,762},{963,761},{956,759},{957,758},{964,760},{967,760},{965,759},{979,760},{976,760},{989,763},{996,761},{998,761},{989,765},{1011,765},{1013,767},{1010,768},{1014,771},{1033,776},{1041,777},{1059,776},{1063,774},{1042,771},{1059,771},{1055,770},{1069,770},{1075,769},{1064,766},{1066,765},{1077,765},{1083,768},{1112,768},{1123,765},{1120,764},{1119,763},{1119,762},{1124,765},{1128,763},{1125,762},{1129,761},{1126,761},{1134,761},{1130,762},{1133,763},{1139,759},{1135,755},{1134,756},{1136,757},{1133,757},{1130,757},{1131,757},{1126,758},{1122,759},{1128,757},{1126,757},{1129,756},{1128,755},{1134,755},{1137,755},{1135,754},{1136,753},{1130,750},{1121,749},{1118,747},{1102,745},{1104,744},{1101,743},{1102,744},{1098,743},{1097,743},{1096,743},{1094,743},{1099,743},{1083,738},{1084,738},{1082,737},{1061,736},{1071,735},{1068,733},{1061,733},{1053,728},{1060,728},{1064,732},{1081,732},{1082,731},{1085,731},{1086,733},{1082,733},{1108,737},{1112,736},{1102,734},{1109,730},{1106,729},{1107,727},{1113,725},{1111,724},{1120,721},{1120,714},{1127,712},{1123,710},{1101,706},{1103,704},{1093,702},{1095,700},{1092,698},{1082,699},{1079,697},{1065,696},{1061,694},{1069,689},{1068,673},{1055,670},{1062,668},{1063,665},{1061,664},{1061,662},{1065,660},{1064,657},{1070,655},{1060,650},{1062,649},{1059,649},{1057,646},{1062,644},{1066,645},{1073,642},{1082,642},{1083,640},{1077,640},{1076,639},{1067,640},{1068,638},{1065,635},{1067,634},{1061,631},{1065,627},{1068,626},{1063,623},{1064,622},{1064,620},{1059,618},{1059,617},{1058,616},{1048,613},{1050,612},{1046,611},{1046,609},{1045,608},{1046,604},{1055,602},{1055,598},{1048,597},{1050,595},{1052,595},{1054,591},{1048,589},{1049,587},{1044,586},{1042,588},{1039,587},{1039,589},{1036,589},{1032,592},{1033,593},{1030,593},{1024,591},{1025,587},{1008,579},{1009,574},{1004,575},{1000,581},{997,581},{994,578},{990,577},{979,578},{973,570},{976,570},{975,568},{978,568},{979,564},{976,564},{976,562},{974,560},{971,561},{968,558},{969,553},{966,550},{967,549},{966,545},{961,546},{957,543},{968,760},{974,761},{972,760},{919,760},{918,760},{918,761},{919,761},{921,761},{937,761},{965,761},{1135,761},{1136,761},{941,761},{941,762},{939,762},{995,762},{994,762},{955,762},{991,762},{981,762},{982,762},{969,764},{968,764},{951,764},{984,763},{983,763},{959,763},{967,763},{965,763},{963,762},{965,762},{950,763},{949,762},{944,762},{948,762},{968,762},{967,762},{969,763},{968,763},{971,763},{1131,763},{1132,763},{947,763},{948,763},{953,763},{954,763},{966,763},{964,763},{961,763},{962,763},{1129,763},{1129,764},{1130,763},{953,765},{952,765},{954,765},{955,765},{1128,765},{944,765},{943,766},{939,766},{945,766},{947,766},{946,766},{955,766},{1127,765},{1127,766},{956,765},{957,766},{957,765},{960,765},{961,766},{1122,766},{1118,766},{1119,767},{1119,766},{962,765},{962,766},{963,766},{965,766},{966,766},{960,766},{956,766},{951,766},{974,764},{949,764},{948,764},{952,764},{1127,764},{1125,764},{1128,764},{1134,764},{1135,763},{1132,764},{1133,764},{950,764},{950,765},{951,765},{956,764},{955,764},{1131,765},{1130,765},{1132,765},{966,765},{954,764},{1126,764},{1120,766},{1123,766},{1126,766},{1125,766},{1124,766},{1114,767},{1113,768},{1111,768},{945,768},{946,768},{1108,768},{1109,768},{1099,767},{948,768},{954,767},{953,767},{952,767},{951,767},{975,767},{972,767},{977,768},{949,767},{950,767},{958,768},{957,768},{979,767},{978,768},{980,768},{979,768},{951,769},{952,769},{978,769},{969,768},{969,769},{965,768},{965,769},{966,769},{968,769},{967,769},{958,769},{957,769},{959,769},{1081,770},{1082,770},{952,770},{953,771},{953,770},{1080,770},{1079,770},{1013,770},{962,770},{963,770},{1003,770},{1004,770},{1044,771},{1001,771},{1079,769},{1080,769},{899,770},{898,770},{1005,769},{1004,769},{961,769},{964,769},{963,769},{960,769},{1006,772},{1005,772},{1058,772},{1058,773},{1060,773},{1059,772},{907,773},{906,773},{1072,773},{1071,773},{963,772},{965,772},{964,772},{1003,772},{1004,772},{1076,773},{1076,774},{1077,774},{824,775},{823,775},{827,775},{822,775},{1022,774},{1021,774},{1023,774},{1075,774},{1065,774},{1067,775},{1070,775},{1067,774},{920,776},{919,776},{921,776},{1013,777},{1012,777},{1014,777},{1044,777},{1045,777},{1040,777},{1017,776},{1016,776},{1015,776},{1025,775},{1026,775},{1064,775},{1078,773},{1074,772},{1072,772},{908,773},{1061,773},{1064,773},{1063,773},{1065,773},{890,770},{889,770},{887,770},{887,771},{888,771},{890,771},{891,770},{1045,771},{1043,771},{976,766},{973,766},{973,767},{975,766},{959,770},{966,771},{900,771},{901,771},{902,771},{899,771},{895,772},{892,772},{894,773},{897,773},{1002,771},{1060,772},{1058,771},{1057,772},{972,768},{973,768},{976,768},{959,768},{974,768},{975,768},{976,769},{944,766},{959,766},{962,767},{965,767},{948,767},{948,766},{945,767},{946,767},{966,767},{944,767},{950,766},{954,766},{952,766},{955,767},{959,767},{958,766},{947,767},{981,767},{980,767},{960,767},{961,767},{958,767},{957,767},{956,767}}}, - {"Asia/Shanghai",778,{{1141,220},{1133,223},{1134,223},{1138,225},{1139,225},{1148,225},{1137,219},{1137,220},{1134,222},{1131,218},{1131,219},{1132,219},{1140,219},{1141,219},{1133,219},{1133,220},{1132,220},{1142,220},{1138,220},{1136,228},{1136,229},{1135,231},{1135,229},{1135,230},{1135,228},{1171,234},{1170,234},{1169,234},{1171,235},{1168,234},{1177,235},{1171,236},{1170,236},{1170,235},{1169,235},{1137,221},{1139,221},{1134,221},{1135,221},{1138,221},{1140,221},{1136,221},{1143,221},{1143,220},{1139,220},{1140,220},{1134,220},{1133,221},{1138,222},{1133,222},{1135,222},{1146,224},{1147,224},{1146,225},{1130,224},{1130,225},{1131,224},{1138,224},{1136,224},{1137,224},{1136,226},{1147,226},{1146,226},{1146,227},{1151,228},{1137,228},{1135,227},{1134,227},{1135,226},{1177,238},{1181,243},{1182,243},{1182,244},{1180,244},{1179,244},{1176,237},{1175,237},{1174,237},{1174,238},{1173,236},{1169,236},{1196,257},{1181,244},{1181,245},{1205,272},{1205,271},{1207,270},{1205,270},{1222,289},{1217,288},{1217,289},{1218,287},{1219,287},{1216,287},{1217,287},{1219,288},{1218,288},{1216,282},{1217,283},{1216,284},{1217,284},{1219,284},{1218,284},{1218,286},{1196,254},{1195,254},{1216,285},{1219,285},{1217,285},{1206,273},{1206,274},{1211,275},{1211,274},{1206,272},{1212,276},{1211,278},{1212,279},{1212,278},{1214,280},{1214,281},{1215,281},{1212,280},{1211,280},{1211,279},{1208,276},{1208,277},{1210,277},{1209,277},{1203,269},{1209,279},{1208,280},{1209,280},{1210,280},{1207,280},{1210,278},{1210,279},{1213,281},{1212,282},{1211,282},{1212,283},{1211,283},{1212,284},{1195,256},{1197,256},{1197,257},{1196,256},{1212,281},{1211,281},{1197,258},{1196,261},{1197,261},{1196,262},{1197,262},{1197,264},{1199,264},{1200,265},{1201,265},{1195,253},{1197,253},{1198,253},{1197,254},{1198,254},{1197,255},{1196,255},{1199,256},{1194,256},{1198,257},{1202,265},{1200,266},{1198,266},{1202,266},{1201,266},{1203,267},{1204,267},{1201,267},{1197,267},{1196,267},{1199,267},{1198,267},{1204,266},{1203,266},{1197,266},{1200,267},{1196,268},{1201,268},{1202,268},{1202,269},{1206,379},{1206,380},{1184,245},{1184,246},{1183,245},{1183,246},{1188,248},{1188,249},{1195,250},{1194,250},{1194,251},{1190,250},{1191,250},{1191,251},{1192,251},{1181,246},{1182,245},{1182,246},{1182,247},{1190,252},{1196,252},{1195,252},{1194,252},{1193,253},{1194,253},{1193,255},{1193,254},{1193,256},{1192,393},{1192,394},{1204,269},{1203,270},{1204,270},{1204,271},{1229,304},{1228,307},{1218,313},{1218,314},{1219,314},{1217,314},{1202,358},{1209,359},{1219,319},{1218,319},{1205,320},{1205,321},{1204,320},{1208,320},{1206,320},{1206,321},{1207,320},{1216,314},{1216,315},{1214,316},{1213,316},{1212,317},{1212,318},{1215,318},{1214,318},{1218,315},{1211,318},{1210,318},{1195,347},{1194,348},{1195,348},{1238,398},{1237,397},{1237,398},{1238,397},{1236,398},{1218,409},{1208,383},{1209,383},{1209,384},{1208,384},{1210,364},{1209,364},{1209,366},{1216,367},{1215,367},{1216,368},{1203,361},{1216,375},{1216,374},{1222,375},{1215,376},{1215,375},{1204,378},{1205,378},{1207,379},{1208,379},{1207,380},{1209,380},{1206,381},{1207,382},{1208,382},{1188,382},{1228,390},{1228,391},{1229,390},{1229,391},{1227,390},{1232,390},{1232,391},{1231,391},{1218,389},{1185,389},{1186,390},{1188,390},{1188,391},{1187,390},{1186,391},{1189,391},{1224,392},{1223,391},{1223,392},{1216,392},{1190,392},{1212,391},{1223,393},{1224,393},{1217,393},{1215,393},{1216,393},{1215,394},{1217,394},{1218,394},{1193,394},{1214,392},{1215,392},{1226,392},{1228,392},{1191,392},{1191,393},{1226,393},{1225,393},{1227,393},{1227,392},{1225,392},{1231,394},{1206,404},{1208,405},{1193,395},{1231,395},{1230,395},{1215,395},{1213,395},{1212,395},{1215,396},{1230,396},{1216,291},{1216,292},{1217,291},{1218,291},{1219,291},{1215,291},{1085,297},{1084,298},{1085,299},{1086,302},{1084,305},{1091,306},{1093,305},{1102,310},{1101,314},{1096,317},{1095,323},{1096,326},{1100,326},{1102,327},{1094,332},{1096,333},{1102,332},{1105,333},{1107,331},{1110,333},{1110,336},{1106,339},{1106,342},{1104,343},{1105,344},{1103,347},{1106,356},{1104,370},{1107,373},{1108,377},{1106,377},{1105,382},{1109,385},{1112,393},{1111,394},{1113,394},{1114,396},{1119,396},{1123,403},{1128,402},{1130,404},{1135,403},{1141,405},{1141,408},{1138,411},{1140,412},{1139,414},{1142,415},{1142,418},{1145,421},{1148,422},{1146,423},{1144,422},{1143,422},{1140,420},{1134,422},{1131,420},{1126,424},{1121,425},{1118,429},{1112,434},{1120,438},{1114,443},{1116,447},{1120,451},{1136,448},{1145,454},{1157,454},{1162,457},{1166,463},{1174,463},{1174,466},{1178,465},{1183,468},{1190,468},{1194,466},{1195,464},{1199,468},{1197,472},{1199,472},{1198,473},{1195,473},{1191,477},{1185,480},{1178,480},{1174,476},{1168,479},{1162,479},{1159,477},{1155,480},{1155,482},{1158,483},{1158,485},{1167,498},{1179,495},{1186,499},{1193,501},{1194,503},{1191,504},{1201,517},{1206,519},{1208,522},{1206,523},{1207,525},{1201,526},{1200,528},{1208,533},{1233,536},{1242,534},{1235,528},{1234,524},{1226,521},{1229,515},{1233,513},{1237,514},{1244,513},{1253,516},{1260,510},{1258,507},{1259,505},{1253,501},{1253,494},{1251,491},{1248,491},{1245,486},{1246,482},{1244,481},{1243,485},{1224,473},{1228,471},{1230,467},{1233,468},{1234,470},{1236,469},{1236,467},{1230,466},{1230,464},{1232,463},{1228,461},{1227,457},{1218,460},{1216,458},{1219,457},{1222,453},{1220,449},{1223,443},{1231,445},{1235,437},{1233,435},{1237,434},{1238,435},{1243,432},{1245,428},{1249,431},{1249,428},{1253,422},{1255,421},{1253,418},{1258,412},{1256,409},{1257,408},{1249,405},{1242,398},{1237,399},{1234,397},{1233,398},{1233,397},{1222,393},{1221,391},{1218,390},{1219,389},{1217,391},{1216,389},{1217,389},{1212,387},{1211,389},{1219,394},{1213,394},{1216,395},{1215,398},{1219,400},{1223,405},{1218,410},{1216,408},{1212,409},{1204,402},{1194,398},{1183,390},{1179,392},{1175,387},{1180,381},{1185,380},{1191,377},{1189,373},{1193,372},{1198,372},{1198,374},{1203,376},{1202,377},{1207,378},{1221,376},{1222,374},{1227,374},{1224,370},{1226,370},{1225,369},{1222,368},{1222,370},{1214,369},{1214,367},{1208,366},{1210,365},{1207,364},{1207,361},{1203,360},{1203,363},{1201,362},{1199,356},{1196,356},{1192,349},{1192,348},{1198,344},{1203,343},{1202,341},{1205,338},{1204,337},{1208,330},{1208,326},{1214,324},{1213,322},{1217,320},{1219,318},{1203,319},{1207,318},{1217,313},{1219,310},{1210,306},{1209,304},{1203,303},{1205,303},{1206,301},{1207,301},{1213,303},{1217,300},{1221,299},{1214,295},{1215,294},{1220,296},{1220,292},{1218,292},{1218,294},{1217,292},{1217,293},{1214,291},{1215,290},{1216,290},{1215,289},{1214,287},{1216,283},{1214,283},{1206,280},{1208,279},{1206,276},{1207,275},{1200,269},{1199,265},{1199,266},{1198,269},{1198,264},{1196,265},{1197,263},{1200,264},{1197,260},{1195,255},{1194,255},{1191,254},{1191,253},{1190,253},{1189,253},{1190,251},{1188,251},{1187,248},{1187,249},{1187,250},{1186,248},{1187,246},{1184,247},{1180,246},{1178,239},{1178,241},{1176,241},{1177,240},{1176,239},{1174,240},{1175,238},{1172,236},{1169,237},{1165,234},{1168,232},{1166,232},{1165,229},{1158,227},{1156,229},{1156,227},{1152,228},{1153,229},{1149,225},{1148,228},{1145,227},{1145,224},{1144,226},{1138,228},{1137,227},{1134,231},{1133,228},{1133,224},{1131,225},{1130,221},{1127,226},{1123,228},{1122,235},{1118,234},{1116,232},{1114,233},{1116,238},{1119,240},{1119,242},{1121,244},{1120,248},{1114,247},{1114,251},{1110,249},{1115,259},{1112,259},{1113,263},{1106,263},{1103,260},{1100,262},{1097,259},{1095,260},{1095,263},{1093,263},{1094,266},{1093,267},{1095,268},{1095,271},{1088,271},{1095,276},{1093,278},{1093,286},{1092,286},{1093,291},{1091,294},{1089,293},{1089,296},{1086,299},{1224,300},{1223,301},{1228,301},{1227,302},{1226,302},{1224,298},{1223,299},{1225,299},{1224,299},{1223,298},{1223,300},{1219,292},{1220,291},{1221,292},{1218,293},{1220,294},{1220,293},{1222,295},{1220,295},{1216,295},{1217,295},{1217,296},{1222,296},{1221,296},{1222,294},{1222,298},{1222,297},{1223,297},{1220,297},{1220,298},{1219,297},{1219,298},{1221,298},{1219,300},{1218,300},{1218,301},{1219,301},{1221,300},{1220,301},{1222,301},{1221,302},{1222,302},{1220,302},{1219,299},{1220,300},{1220,299},{1222,299},{1222,300},{1219,302},{1228,308},{1227,308},{1227,309},{1224,307},{1224,308},{1226,308},{1227,307},{1225,307},{1226,306},{1226,307},{1223,306},{1225,306},{1225,308},{1225,302},{1219,303},{1225,304},{1224,304},{1223,304},{1223,305},{1221,303},{1220,303},{1224,303},{1223,302},{1223,303},{1224,302},{1222,303},{1224,306},{1221,306},{1220,306},{1216,306}}}, - {"Pacific/Kwajalein",15,{{1668,93},{1669,93},{1676,90},{1675,91},{1673,91},{1674,91},{1672,91},{1673,93},{1677,87},{1677,88},{1676,88},{1677,89},{1678,89},{1671,93},{1675,94}}}, - {"America/St_Johns",398,{{-536,493},{-550,494},{-539,488},{-538,488},{-582,491},{-536,491},{-537,490},{-583,491},{-584,491},{-537,489},{-538,489},{-538,490},{-584,492},{-535,492},{-583,492},{-535,493},{-551,493},{-552,493},{-552,494},{-550,493},{-547,494},{-548,494},{-551,494},{-557,494},{-553,494},{-549,494},{-542,494},{-542,495},{-544,494},{-544,495},{-550,495},{-549,495},{-554,495},{-548,495},{-542,478},{-541,478},{-536,480},{-528,481},{-528,482},{-535,482},{-537,485},{-592,486},{-537,488},{-542,474},{-536,481},{-539,481},{-540,482},{-536,486},{-538,487},{-539,487},{-538,486},{-537,486},{-537,487},{-536,487},{-536,488},{-536,489},{-539,489},{-558,468},{-558,469},{-537,470},{-537,471},{-552,470},{-536,471},{-536,472},{-528,472},{-528,473},{-559,473},{-560,473},{-548,473},{-548,472},{-550,473},{-549,473},{-558,474},{-546,473},{-547,473},{-549,474},{-548,474},{-530,475},{-530,476},{-590,476},{-560,476},{-554,476},{-560,477},{-538,478},{-560,478},{-559,478},{-559,477},{-542,476},{-550,476},{-574,476},{-543,476},{-529,477},{-529,476},{-577,476},{-578,476},{-575,476},{-561,476},{-562,476},{-552,476},{-553,476},{-583,477},{-580,477},{-559,476},{-561,477},{-562,477},{-543,477},{-542,477},{-540,474},{-539,474},{-547,474},{-557,474},{-541,475},{-562,475},{-574,475},{-544,475},{-542,475},{-559,475},{-557,475},{-556,475},{-573,475},{-554,475},{-543,475},{-541,477},{-543,474},{-544,474},{-558,478},{-553,520},{-554,519},{-554,520},{-557,524},{-558,524},{-558,523},{-557,523},{-560,525},{-558,525},{-559,526},{-558,526},{-559,525},{-562,525},{-561,525},{-561,526},{-557,525},{-557,526},{-560,526},{-558,527},{-559,527},{-560,527},{-559,528},{-560,528},{-558,528},{-559,520},{-558,520},{-557,522},{-556,522},{-556,523},{-559,536},{-559,537},{-563,537},{-560,537},{-558,529},{-559,529},{-559,530},{-558,530},{-557,531},{-558,531},{-557,532},{-557,533},{-558,533},{-558,534},{-559,534},{-560,535},{-561,535},{-562,535},{-559,535},{-560,536},{-558,535},{-557,535},{-557,495},{-547,495},{-555,495},{-546,495},{-551,495},{-556,495},{-557,496},{-554,516},{-556,513},{-560,514},{-561,513},{-557,511},{-561,507},{-561,509},{-563,509},{-567,501},{-566,501},{-569,498},{-568,497},{-569,495},{-562,502},{-561,501},{-562,499},{-560,500},{-555,500},{-561,497},{-562,496},{-559,497},{-562,494},{-558,495},{-556,494},{-555,494},{-554,493},{-553,493},{-553,495},{-552,495},{-554,490},{-551,492},{-549,493},{-548,493},{-545,496},{-545,493},{-541,495},{-536,490},{-542,488},{-541,487},{-540,486},{-542,484},{-538,485},{-539,484},{-536,485},{-537,484},{-535,486},{-533,485},{-530,487},{-532,483},{-537,481},{-539,480},{-539,479},{-540,479},{-537,475},{-533,480},{-529,481},{-533,476},{-531,474},{-528,478},{-526,475},{-531,467},{-534,468},{-536,466},{-535,469},{-537,468},{-535,470},{-534,472},{-542,468},{-540,472},{-539,473},{-540,473},{-538,474},{-541,479},{-543,479},{-545,474},{-544,476},{-553,469},{-560,470},{-547,477},{-551,476},{-550,478},{-549,478},{-551,477},{-555,477},{-556,474},{-556,476},{-558,475},{-557,476},{-559,474},{-560,475},{-556,477},{-557,478},{-557,479},{-558,480},{-562,479},{-563,476},{-563,478},{-564,476},{-566,477},{-565,476},{-569,475},{-572,477},{-572,476},{-573,477},{-573,478},{-579,477},{-584,477},{-583,478},{-585,476},{-593,476},{-593,478},{-592,478},{-594,479},{-583,485},{-592,485},{-588,488},{-590,486},{-587,486},{-581,490},{-579,490},{-579,491},{-579,492},{-581,492},{-583,493},{-580,496},{-579,494},{-577,495},{-580,497},{-578,499},{-578,498},{-577,498},{-577,500},{-576,500},{-574,506},{-572,506},{-574,507},{-569,509},{-571,510},{-569,510},{-566,514},{-559,516},{-559,515},{-539,495},{-556,496},{-543,495},{-543,496},{-538,496},{-546,497},{-545,497},{-548,497},{-547,497},{-567,497},{-532,497},{-532,498},{-559,498},{-568,498},{-557,502},{-558,502},{-573,506},{-559,502},{-556,507},{-556,508},{-555,508},{-555,507},{-572,508},{-559,495},{-558,496},{-548,496},{-547,496},{-550,496},{-539,496},{-546,496},{-549,496},{-559,496},{-559,512},{-560,512},{-544,496},{-544,497},{-558,497},{-541,497},{-540,496},{-543,497},{-556,509},{-556,510},{-555,510},{-569,511},{-568,511},{-568,512},{-557,512},{-558,512},{-560,513},{-555,515},{-554,515},{-559,513},{-556,516},{-555,516},{-558,516},{-573,535},{-571,536},{-563,536},{-559,533},{-562,530},{-562,528},{-565,526},{-556,524},{-561,524},{-562,524},{-558,522},{-557,521},{-571,514},{-571,528},{-575,530},{-575,534},{-573,508}}}, - {"Africa/Kigali",17,{{300,-23},{299,-27},{297,-28},{294,-28},{291,-26},{290,-27},{289,-25},{292,-21},{291,-19},{294,-15},{298,-13},{299,-15},{300,-14},{305,-11},{308,-16},{309,-23},{301,-24}}}, - {"Europe/Chisinau",30,{{300,465},{301,464},{296,464},{294,465},{293,464},{292,466},{289,465},{290,460},{285,457},{285,455},{282,455},{281,460},{283,466},{281,470},{276,473},{270,481},{266,483},{268,483},{267,484},{276,485},{284,482},{285,481},{286,482},{292,480},{293,478},{291,475},{294,473},{296,474},{296,470},{300,468}}}, - {"America/Noronha",3,{{-324,-38},{-324,-39},{-325,-39}}}, - {"Africa/Luanda",71,{{118,-168},{117,-166},{117,-165},{126,-61},{126,-60},{127,-60},{128,-60},{128,-44},{131,-46},{125,-51},{125,-57},{122,-58},{120,-50},{129,-60},{129,-59},{130,-60},{131,-90},{131,-89},{223,-106},{222,-109},{223,-112},{226,-110},{231,-111},{234,-109},{240,-110},{241,-124},{239,-128},{240,-130},{220,-130},{220,-162},{221,-165},{234,-176},{208,-180},{203,-179},{189,-178},{184,-174},{140,-174},{135,-170},{131,-170},{126,-172},{121,-171},{118,-173},{117,-159},{122,-152},{125,-134},{130,-130},{129,-128},{137,-122},{139,-110},{130,-91},{134,-87},{134,-84},{128,-70},{123,-61},{130,-59},{165,-59},{167,-62},{170,-72},{176,-81},{185,-79},{194,-80},{195,-70},{206,-69},{205,-73},{218,-73},{217,-79},{220,-85},{218,-94},{222,-99},{132,-88},{133,-88}}}, - {"Europe/Guernsey",7,{{-25,495},{-25,494},{-27,494},{-26,495},{-22,497},{-24,495},{-24,494}}}, - {"Europe/Paris",202,{{93,413},{92,413},{93,414},{94,430},{96,422},{92,414},{88,416},{89,417},{87,418},{88,419},{86,419},{87,421},{86,422},{87,423},{85,424},{87,426},{93,427},{-12,447},{-6,450},{-7,451},{-7,452},{-7,453},{-11,460},{-12,460},{-12,459},{-12,458},{-14,460},{-15,462},{-13,462},{-13,461},{-16,462},{53,433},{71,435},{70,435},{46,434},{58,431},{62,430},{64,430},{65,431},{65,430},{-50,484},{-29,476},{-28,476},{-51,485},{-50,485},{-49,480},{-42,479},{-42,478},{-34,476},{-35,476},{-45,483},{-49,483},{-48,484},{-49,484},{-39,487},{-40,487},{-36,488},{-32,489},{-30,489},{-30,488},{-18,489},{-31,473},{-32,473},{-32,474},{-29,473},{-30,474},{-29,474},{-23,467},{-24,467},{-22,470},{-22,469},{-23,470},{42,435},{40,436},{32,432},{30,430},{32,424},{27,423},{20,424},{17,426},{7,429},{7,427},{0,427},{-13,431},{-14,431},{-14,433},{-18,434},{-14,437},{-13,446},{-10,447},{-12,448},{-11,455},{-11,456},{-8,455},{-12,457},{-10,457},{-10,459},{-12,462},{-11,463},{-18,465},{-21,468},{-20,470},{-22,471},{-20,473},{-25,473},{-25,475},{-28,475},{-29,475},{-27,475},{-27,476},{-30,477},{-31,475},{-31,477},{-32,476},{-34,477},{-33,477},{-33,478},{-39,478},{-41,480},{-44,478},{-44,480},{-47,480},{-43,481},{-46,482},{-46,483},{-42,483},{-43,484},{-48,483},{-48,485},{-36,487},{-35,488},{-31,489},{-27,485},{-23,487},{-22,486},{-18,487},{-14,486},{-16,488},{-15,492},{-18,494},{-19,497},{-13,497},{-11,493},{-2,493},{4,494},{1,495},{2,497},{17,502},{15,503},{16,509},{25,511},{28,507},{31,508},{33,505},{36,505},{37,503},{42,503},{42,500},{49,502},{49,498},{55,495},{63,495},{65,494},{67,492},{74,492},{82,490},{78,486},{76,481},{76,476},{74,474},{70,475},{69,474},{71,473},{64,469},{60,462},{62,462},{65,465},{68,464},{68,462},{70,460},{68,458},{72,454},{71,452},{66,451},{70,448},{71,447},{68,445},{70,442},{77,442},{75,438},{67,434},{66,432},{54,432},{53,434},{48,433},{48,434},{47,434},{48,435},{47,435},{47,436},{20,425},{19,425}}}, - {"Africa/Abidjan",49,{{-61,50},{-62,49},{-75,44},{-76,49},{-74,53},{-74,58},{-78,60},{-79,63},{-86,65},{-83,70},{-85,76},{-82,75},{-81,80},{-79,80},{-80,82},{-82,82},{-82,85},{-76,84},{-78,88},{-80,88},{-77,91},{-79,92},{-78,94},{-81,95},{-82,100},{-76,105},{-70,102},{-69,104},{-67,104},{-66,107},{-64,106},{-63,107},{-62,102},{-57,105},{-52,103},{-50,99},{-44,96},{-39,99},{-32,99},{-28,94},{-27,95},{-28,91},{-25,83},{-28,79},{-33,66},{-30,57},{-28,56},{-27,51},{-40,52}}}, - {"America/Tortola",15,{{-646,183},{-646,184},{-645,184},{-648,184},{-648,185},{-647,184},{-644,187},{-643,188},{-643,187},{-644,185},{-643,185},{-644,184},{-645,185},{-646,185},{-647,185}}}, - {"Europe/Malta",6,{{145,359},{146,358},{144,358},{143,360},{143,361},{142,360}}}, - {"Europe/London",565,{{-64,499},{-63,499},{-47,516},{-32,541},{-32,540},{-33,541},{-57,544},{-56,544},{-55,547},{-56,545},{-57,545},{-74,549},{-70,552},{-61,552},{-57,548},{-59,546},{-56,547},{-54,545},{-55,543},{-57,546},{-58,543},{-61,540},{-63,542},{-63,541},{-66,540},{-70,544},{-73,541},{-76,541},{-82,545},{-77,546},{-79,547},{-75,547},{-74,550},{-73,551},{-73,550},{-51,553},{-51,552},{-56,553},{-62,553},{-63,553},{-51,555},{-52,556},{-52,554},{-54,556},{-53,557},{-61,556},{-62,556},{-57,556},{-58,556},{-18,557},{-19,557},{-63,560},{-62,560},{-72,575},{-63,557},{-63,558},{-65,557},{-61,559},{-60,557},{-63,556},{-57,557},{-49,557},{-50,557},{-49,558},{-52,558},{-51,558},{-52,559},{-50,558},{-26,562},{-58,560},{-60,558},{-61,558},{-57,562},{6,514},{-62,561},{-61,561},{-56,561},{-55,562},{-64,500},{-63,500},{-9,508},{-10,508},{-11,507},{-13,506},{-16,507},{-13,508},{-20,507},{-47,512},{7,514},{9,514},{8,514},{-53,517},{9,518},{10,518},{-53,519},{-54,519},{8,517},{7,517},{13,519},{12,519},{-48,528},{-48,527},{-6,537},{-5,537},{-46,533},{-44,534},{-40,533},{-43,531},{-46,532},{-47,533},{5,515},{6,515},{-58,562},{-56,562},{-58,563},{-55,564},{-56,564},{-64,564},{-64,563},{-56,563},{-68,565},{-69,564},{-70,565},{-68,566},{-67,565},{-54,565},{-54,566},{-67,566},{-77,568},{-76,568},{-58,568},{-59,568},{-63,568},{-62,568},{-76,569},{-65,567},{-66,566},{-59,567},{-60,567},{-61,565},{-64,565},{-63,565},{-62,564},{-63,564},{-73,572},{-59,573},{-58,573},{-60,573},{-72,573},{-65,573},{-58,574},{-74,574},{-72,574},{-58,572},{-58,571},{-73,571},{-63,571},{-63,569},{-65,570},{-64,571},{-62,565},{-63,566},{-61,567},{-57,564},{-63,563},{-60,564},{-60,565},{-56,565},{-55,566},{-55,565},{-60,566},{-75,569},{-61,569},{-62,569},{-74,569},{-74,570},{-76,570},{-73,570},{-75,571},{-75,570},{-74,571},{-65,571},{-66,570},{-66,571},{-62,572},{-73,574},{-74,572},{-72,571},{-86,578},{-87,578},{-85,579},{-14,601},{-29,588},{-30,587},{-30,588},{-32,588},{-31,588},{-32,589},{-30,589},{-31,587},{-26,590},{-27,589},{-61,591},{-62,591},{-58,591},{-44,591},{-28,591},{-28,590},{-29,590},{-29,591},{-30,591},{-29,594},{-29,593},{-26,592},{-28,592},{-27,592},{-27,591},{-28,593},{-12,605},{-26,593},{-24,593},{-30,593},{-30,594},{-29,592},{-17,595},{-16,596},{-16,595},{-24,594},{-25,594},{-26,591},{-25,591},{-30,592},{-31,592},{-11,601},{-10,602},{-10,601},{-13,601},{-12,602},{-11,602},{-16,602},{-15,603},{-17,603},{-10,603},{-9,604},{-11,604},{-10,604},{-14,603},{-8,606},{-9,606},{-10,606},{-8,608},{-8,607},{-10,607},{-9,607},{-9,608},{-8,604},{-12,604},{-11,605},{-13,605},{-14,605},{-14,604},{-16,605},{-13,606},{-11,607},{-10,605},{-12,600},{-14,600},{-13,600},{-21,601},{-21,602},{-29,589},{-33,589},{-54,580},{-13,604},{-13,599},{-14,599},{-13,603},{-15,601},{-15,604},{-33,588},{-34,589},{-77,575},{-76,575},{-32,592},{-31,590},{-34,590},{-27,516},{-34,514},{-38,516},{-43,516},{-41,517},{-43,518},{-49,516},{-51,517},{-49,517},{-51,519},{-42,523},{-39,526},{-41,526},{-39,528},{-42,528},{-41,529},{-42,532},{-33,534},{-33,533},{-31,532},{-32,534},{-30,534},{-29,533},{-28,533},{-27,533},{-31,536},{-28,537},{-31,538},{-30,539},{-29,539},{-29,540},{-28,542},{-31,542},{-36,545},{-34,549},{-31,550},{-36,550},{-36,549},{-40,548},{-41,549},{-41,548},{-42,549},{-45,549},{-44,547},{-49,549},{-50,548},{-49,546},{-52,549},{-51,550},{-50,549},{-50,551},{-46,555},{-49,559},{-45,559},{-49,560},{-48,562},{-49,562},{-50,559},{-51,560},{-51,559},{-52,560},{-53,559},{-53,560},{-49,563},{-54,560},{-53,558},{-56,554},{-55,554},{-58,553},{-55,558},{-54,559},{-57,558},{-55,563},{-57,563},{-52,566},{-53,567},{-50,567},{-52,567},{-51,568},{-52,569},{-53,569},{-57,565},{-55,567},{-62,567},{-57,568},{-57,569},{-59,569},{-58,570},{-56,570},{-55,570},{-57,571},{-55,571},{-54,571},{-57,572},{-54,573},{-55,573},{-57,573},{-55,574},{-54,574},{-58,576},{-56,575},{-55,575},{-57,577},{-58,579},{-52,578},{-54,579},{-51,578},{-55,581},{-52,582},{-53,582},{-54,582},{-54,583},{-49,582},{-52,584},{-50,584},{-51,585},{-50,586},{-47,586},{-48,584},{-44,586},{-45,584},{-30,586},{-31,584},{-41,580},{-40,579},{-44,579},{-41,578},{-38,579},{-45,575},{-33,577},{-18,576},{-18,575},{-20,574},{-21,571},{-26,567},{-24,567},{-25,566},{-34,564},{-28,565},{-29,564},{-26,563},{-34,560},{-37,560},{-38,561},{-39,561},{-31,559},{-27,561},{-21,559},{-16,556},{-16,552},{-12,547},{-12,546},{-6,545},{-1,541},{-2,540},{1,537},{1,536},{-3,537},{-7,537},{2,535},{3,531},{0,529},{4,528},{5,530},{13,529},{17,526},{16,521},{13,520},{11,520},{11,519},{12,518},{10,519},{9,517},{8,516},{9,516},{5,516},{3,514},{14,514},{14,512},{10,509},{-8,507},{-15,509},{-19,506},{-21,506},{-24,506},{-25,505},{-28,507},{-35,507},{-37,502},{-42,504},{-42,503},{-50,502},{-52,500},{-55,501},{-57,501},{-46,508},{-45,510},{-41,511},{-42,512},{-30,512},{-30,514},{-27,515},{-24,518},{-73,575},{-60,575},{-60,574},{-61,573},{-61,574},{-65,576},{-66,576},{-71,576},{-72,576},{-67,575},{-66,575},{-74,575},{-74,576},{-55,580},{-76,583},{-67,574},{-66,574},{-63,575},{-64,576},{-63,577},{-61,576},{-62,573},{-56,573},{-60,570},{-63,572},{-64,574},{-71,575},{-60,576},{-73,577},{-70,577},{-71,577},{-75,576},{-74,577},{-52,579},{-53,580},{-54,581},{-71,581},{-69,582},{-71,580},{-72,580},{-67,580},{-64,580},{-65,580},{-43,586},{-70,582},{-52,583},{-53,583},{-69,583},{-58,577},{-71,578},{-72,578},{-72,577},{-56,579},{-56,578},{-55,579},{-64,579},{-67,579},{-66,579},{-70,579},{-71,579},{-63,579},{-64,582},{-66,581},{-64,581},{-66,580},{-65,579},{-67,581},{-67,578},{-68,579},{-69,580},{-69,581},{-67,582},{-68,583},{-62,585},{-62,583},{-61,583}}}, - {"Pacific/Guadalcanal",261,{{1688,-123},{1622,-108},{1659,-108},{1660,-108},{1660,-107},{1659,-107},{1615,-105},{1605,-119},{1603,-116},{1599,-115},{1604,-117},{1606,-118},{1668,-117},{1668,-116},{1670,-117},{1669,-117},{1670,-116},{1598,-113},{1665,-113},{1664,-113},{1665,-112},{1624,-109},{1625,-109},{1657,-104},{1658,-104},{1614,-104},{1614,-103},{1662,-103},{1662,-102},{1657,-107},{1657,-106},{1625,-108},{1658,-106},{1660,-106},{1658,-108},{1657,-101},{1673,-100},{1619,-101},{1672,-100},{1672,-99},{1671,-99},{1671,-98},{1608,-98},{1620,-97},{1620,-98},{1620,-99},{1619,-97},{1609,-98},{1663,-102},{1617,-102},{1618,-103},{1617,-103},{1620,-103},{1620,-102},{1613,-101},{1621,-104},{1624,-108},{1616,-106},{1615,-103},{1613,-103},{1619,-102},{1662,-101},{1591,-90},{1592,-90},{1600,-90},{1607,-90},{1600,-89},{1601,-89},{1601,-90},{1608,-90},{1608,-89},{1607,-89},{1627,-84},{1583,-88},{1581,-88},{1581,-87},{1582,-88},{1582,-87},{1576,-88},{1575,-87},{1574,-87},{1576,-87},{1592,-91},{1610,-87},{1611,-88},{1610,-88},{1603,-92},{1613,-92},{1602,-92},{1588,-90},{1587,-90},{1612,-90},{1593,-90},{1590,-90},{1591,-92},{1591,-91},{1598,-91},{1594,-91},{1593,-91},{1604,-91},{1604,-92},{1603,-91},{1602,-91},{1601,-91},{1603,-90},{1590,-91},{1602,-90},{1615,-96},{1613,-96},{1613,-95},{1612,-95},{1608,-95},{1606,-95},{1615,-98},{1614,-97},{1613,-93},{1616,-96},{1600,-98},{1597,-97},{1596,-93},{1604,-94},{1608,-99},{1606,-99},{1614,-95},{1614,-94},{1612,-94},{1611,-94},{1611,-93},{1603,-93},{1604,-93},{1565,-83},{1571,-83},{1572,-83},{1574,-83},{1573,-83},{1575,-83},{1602,-83},{1602,-82},{1565,-82},{1578,-83},{1578,-82},{1570,-82},{1571,-82},{1593,-82},{1608,-83},{1572,-82},{1571,-81},{1577,-82},{1576,-82},{1583,-75},{1583,-74},{1555,-74},{1556,-74},{1582,-74},{1581,-74},{1555,-73},{1606,-83},{1576,-73},{1556,-71},{1557,-71},{1559,-69},{1558,-71},{1557,-70},{1559,-71},{1560,-70},{1558,-70},{1559,-70},{1576,-74},{1572,-73},{1572,-74},{1571,-74},{1571,-73},{1579,-75},{1580,-74},{1580,-75},{1582,-75},{1578,-75},{1577,-75},{1577,-74},{1578,-74},{1575,-74},{1574,-74},{1595,-55},{1597,-55},{1594,-51},{1594,-54},{1594,-55},{1560,-69},{1561,-68},{1561,-69},{1560,-68},{1564,-67},{1566,-67},{1570,-73},{1561,-67},{1596,-81},{1595,-81},{1568,-80},{1568,-81},{1590,-81},{1576,-81},{1576,-80},{1569,-81},{1566,-81},{1566,-82},{1565,-79},{1566,-80},{1606,-79},{1566,-78},{1586,-77},{1567,-80},{1565,-78},{1570,-80},{1570,-79},{1572,-79},{1565,-77},{1566,-76},{1568,-77},{1585,-77},{1587,-75},{1585,-76},{1584,-77},{1584,-76},{1588,-76},{1587,-76},{1583,-76},{1584,-75},{1573,-84},{1573,-87},{1572,-86},{1573,-85},{1599,-85},{1599,-86},{1582,-86},{1580,-88},{1579,-87},{1580,-85},{1581,-86},{1582,-85},{1598,-85},{1579,-84},{1579,-83},{1581,-85},{1576,-84},{1596,-84},{1597,-85},{1597,-86},{1595,-85},{1580,-84},{1598,-84},{1575,-84},{1614,-96},{1608,-91},{1607,-83},{1610,-86},{1609,-88},{1575,-79},{1579,-85},{1578,-87},{1599,-84},{1589,-80}}}, - {"Pacific/Gambier",15,{{-1356,-215},{-1362,-220},{-1355,-215},{-1350,-231},{-1349,-231},{-1364,-215},{-1364,-214},{-1366,-213},{-1365,-213},{-1365,-214},{-1367,-213},{-1368,-213},{-1349,-232},{-1351,-232},{-1351,-231}}}, - {"America/Thule",117,{{-718,774},{-713,774},{-726,774},{-723,775},{-710,774},{-701,774},{-731,767},{-730,767},{-733,767},{-732,767},{-669,776},{-666,776},{-668,776},{-729,781},{-661,775},{-662,774},{-663,775},{-662,775},{-666,775},{-665,775},{-667,775},{-729,784},{-728,784},{-669,791},{-673,791},{-674,791},{-667,792},{-666,792},{-670,791},{-670,792},{-703,768},{-702,768},{-728,774},{-651,760},{-652,760},{-650,760},{-658,760},{-657,760},{-687,761},{-641,761},{-640,761},{-637,761},{-660,761},{-659,760},{-661,761},{-649,761},{-658,761},{-659,761},{-700,764},{-702,764},{-699,764},{-700,766},{-701,766},{-695,766},{-697,765},{-692,767},{-693,767},{-726,767},{-725,767},{-729,767},{-728,767},{-638,762},{-641,762},{-641,763},{-643,764},{-644,762},{-647,763},{-646,761},{-655,760},{-655,762},{-657,763},{-662,763},{-664,761},{-669,763},{-673,762},{-665,759},{-685,761},{-684,762},{-696,764},{-679,767},{-701,768},{-699,770},{-706,768},{-710,769},{-707,769},{-714,770},{-702,772},{-681,772},{-691,773},{-683,774},{-662,773},{-666,774},{-660,775},{-670,777},{-678,775},{-684,775},{-687,777},{-688,777},{-686,775},{-702,776},{-703,776},{-695,777},{-707,777},{-702,778},{-703,779},{-713,778},{-714,778},{-712,779},{-722,779},{-723,780},{-723,781},{-730,782},{-727,782},{-726,785},{-693,788},{-686,790},{-664,791}}}, - {"America/Rankin_Inlet",1245,{{-852,688},{-886,567},{-886,568},{-887,568},{-906,572},{-907,572},{-908,573},{-909,573},{-929,582},{-930,584},{-931,584},{-945,588},{-950,590},{-948,591},{-948,590},{-949,591},{-948,593},{-947,594},{-948,597},{-936,588},{-937,588},{-938,588},{-933,588},{-948,598},{-947,598},{-880,642},{-899,641},{-897,641},{-898,641},{-886,640},{-895,640},{-871,650},{-869,652},{-883,654},{-882,654},{-890,654},{-891,654},{-884,654},{-884,655},{-885,655},{-890,657},{-892,658},{-899,658},{-900,658},{-897,659},{-897,658},{-896,659},{-850,662},{-851,662},{-853,663},{-859,665},{-867,665},{-863,665},{-851,669},{-850,669},{-871,672},{-872,672},{-872,673},{-874,673},{-866,674},{-874,672},{-873,672},{-865,675},{-866,676},{-866,677},{-863,680},{-860,680},{-860,681},{-876,681},{-877,682},{-872,683},{-858,684},{-857,684},{-867,683},{-864,682},{-863,679},{-865,677},{-869,679},{-868,680},{-869,681},{-853,688},{-851,688},{-854,688},{-850,688},{-852,689},{-850,689},{-925,636},{-925,635},{-916,636},{-902,636},{-903,636},{-915,636},{-904,636},{-905,636},{-906,636},{-907,636},{-913,636},{-907,635},{-911,636},{-912,636},{-914,635},{-914,637},{-901,637},{-921,637},{-900,637},{-900,638},{-928,638},{-935,639},{-930,639},{-931,639},{-899,639},{-900,639},{-901,639},{-929,638},{-929,639},{-928,639},{-915,637},{-937,639},{-936,639},{-893,639},{-933,639},{-932,639},{-894,639},{-936,640},{-935,640},{-900,640},{-896,639},{-896,640},{-890,640},{-891,640},{-893,640},{-894,640},{-892,640},{-895,639},{-874,711},{-898,640},{-899,640},{-897,640},{-938,612},{-939,612},{-940,611},{-941,611},{-940,612},{-941,612},{-941,613},{-942,614},{-943,614},{-937,614},{-938,614},{-939,615},{-939,614},{-938,615},{-932,618},{-933,618},{-934,618},{-929,618},{-930,618},{-927,618},{-927,619},{-936,619},{-935,619},{-935,618},{-929,620},{-928,620},{-925,620},{-931,620},{-930,620},{-929,621},{-927,620},{-927,621},{-926,620},{-928,619},{-930,619},{-931,619},{-933,619},{-931,618},{-929,619},{-932,619},{-923,628},{-922,627},{-931,622},{-932,622},{-925,622},{-929,622},{-927,622},{-927,623},{-928,623},{-921,624},{-926,625},{-926,624},{-921,623},{-922,623},{-924,625},{-925,625},{-926,626},{-922,626},{-910,627},{-919,627},{-920,627},{-917,627},{-916,627},{-918,627},{-923,627},{-922,628},{-911,627},{-913,627},{-912,627},{-912,628},{-913,628},{-921,629},{-921,628},{-907,630},{-906,631},{-918,628},{-919,628},{-920,628},{-906,632},{-906,633},{-907,633},{-905,634},{-906,634},{-909,634},{-908,634},{-910,635},{-911,635},{-913,635},{-912,635},{-918,626},{-916,626},{-917,626},{-930,621},{-931,621},{-925,621},{-906,635},{-853,699},{-854,699},{-860,720},{-861,720},{-853,712},{-853,713},{-857,722},{-858,722},{-867,702},{-868,702},{-869,700},{-872,700},{-874,701},{-864,700},{-869,701},{-873,702},{-874,702},{-872,702},{-870,704},{-875,710},{-872,710},{-876,710},{-876,711},{-851,712},{-852,712},{-869,702},{-854,712},{-850,712},{-855,697},{-854,697},{-850,698},{-1006,732},{-1005,732},{-969,732},{-970,732},{-971,733},{-972,733},{-957,735},{-957,734},{-970,733},{-982,730},{-981,731},{-980,731},{-957,730},{-981,730},{-980,730},{-956,726},{-970,727},{-970,728},{-969,727},{-965,728},{-964,726},{-958,729},{-956,728},{-969,728},{-967,729},{-966,728},{-958,730},{-959,730},{-967,731},{-965,730},{-971,730},{-992,742},{-991,742},{-988,743},{-985,743},{-986,743},{-1010,736},{-1011,737},{-1012,737},{-993,738},{-992,738},{-1008,739},{-1007,739},{-1011,738},{-900,741},{-899,740},{-903,740},{-902,741},{-952,740},{-953,740},{-972,739},{-973,739},{-990,740},{-980,741},{-976,741},{-984,739},{-994,739},{-876,756},{-877,756},{-875,756},{-885,747},{-886,747},{-962,747},{-961,747},{-974,739},{-969,737},{-977,735},{-972,735},{-971,734},{-985,730},{-973,730},{-1001,732},{-1003,734},{-1009,733},{-1016,735},{-1009,736},{-1005,735},{-1005,736},{-1005,739},{-1000,738},{-998,739},{-1003,739},{-1001,739},{-991,737},{-973,735},{-974,735},{-1007,736},{-956,736},{-957,736},{-963,748},{-964,748},{-983,747},{-983,748},{-981,747},{-886,748},{-885,748},{-1020,760},{-1020,759},{-1009,755},{-1008,755},{-1014,755},{-1015,755},{-1012,755},{-1013,755},{-1011,755},{-1007,755},{-1006,755},{-1005,755},{-1007,756},{-1010,756},{-1003,756},{-1001,756},{-965,758},{-965,757},{-967,757},{-964,758},{-955,757},{-954,757},{-973,755},{-972,755},{-1000,756},{-969,756},{-968,757},{-1000,757},{-999,757},{-998,757},{-986,750},{-985,750},{-977,750},{-976,750},{-971,752},{-972,753},{-973,753},{-971,753},{-975,753},{-976,753},{-976,754},{-1006,754},{-965,754},{-1004,755},{-1003,755},{-964,755},{-976,755},{-964,756},{-965,755},{-967,754},{-966,754},{-968,754},{-970,755},{-963,757},{-959,756},{-961,755},{-963,758},{-947,760},{-944,760},{-943,758},{-948,758},{-949,759},{-958,759},{-959,760},{-957,760},{-976,760},{-1001,760},{-1002,760},{-904,761},{-903,761},{-905,761},{-948,760},{-948,761},{-947,761},{-950,760},{-951,761},{-949,761},{-1004,762},{-1003,762},{-970,762},{-969,762},{-973,746},{-974,745},{-978,745},{-974,746},{-917,815},{-919,815},{-920,816},{-916,816},{-906,816},{-905,816},{-957,746},{-955,746},{-952,745},{-958,746},{-959,771},{-958,772},{-957,772},{-958,771},{-1018,782},{-1017,782},{-1016,782},{-1012,790},{-1013,790},{-1015,791},{-1014,791},{-970,781},{-913,772},{-909,773},{-907,772},{-909,771},{-873,772},{-874,772},{-952,772},{-953,772},{-954,772},{-959,772},{-960,772},{-855,774},{-855,775},{-854,775},{-850,775},{-852,775},{-850,776},{-937,774},{-938,774},{-936,774},{-964,776},{-900,772},{-910,773},{-912,774},{-912,776},{-902,776},{-896,773},{-856,777},{-853,778},{-852,778},{-1020,779},{-1013,778},{-1009,777},{-1020,777},{-967,778},{-968,778},{-952,778},{-953,778},{-950,775},{-963,776},{-955,778},{-931,777},{-954,778},{-931,793},{-932,793},{-947,793},{-948,793},{-946,793},{-945,793},{-954,793},{-953,793},{-954,794},{-976,794},{-977,794},{-1001,801},{-1002,801},{-893,818},{-894,819},{-895,819},{-893,819},{-906,819},{-907,819},{-905,819},{-898,819},{-899,819},{-998,801},{-989,801},{-986,798},{-989,797},{-1002,799},{-1002,800},{-992,802},{-994,801},{-994,802},{-976,796},{-977,796},{-975,796},{-972,796},{-971,796},{-947,797},{-963,798},{-965,798},{-966,798},{-850,796},{-864,798},{-864,799},{-862,800},{-865,800},{-867,802},{-864,803},{-850,803},{-964,798},{-949,801},{-948,801},{-885,801},{-887,802},{-885,802},{-963,805},{-962,805},{-953,808},{-954,808},{-950,807},{-952,806},{-961,807},{-952,807},{-953,809},{-954,809},{-944,810},{-945,810},{-916,815},{-920,815},{-918,815},{-891,819},{-892,819},{-893,820},{-892,820},{-850,819},{-851,820},{-850,820},{-866,821},{-869,822},{-857,822},{-854,823},{-859,824},{-850,825},{-850,811},{-861,810},{-873,806},{-895,809},{-858,811},{-860,811},{-850,813},{-850,810},{-850,805},{-859,805},{-856,806},{-868,806},{-857,810},{-943,810},{-942,810},{-944,811},{-943,811},{-936,812},{-937,812},{-851,810},{-869,811},{-870,811},{-868,811},{-884,764},{-885,764},{-887,765},{-888,765},{-986,766},{-985,767},{-989,767},{-977,765},{-978,763},{-975,761},{-976,759},{-979,757},{-973,757},{-973,754},{-977,756},{-977,755},{-980,755},{-978,754},{-981,753},{-976,751},{-981,752},{-980,750},{-999,750},{-1004,750},{-1005,752},{-1000,752},{-1008,754},{-1000,755},{-997,757},{-1020,755},{-1012,757},{-1016,759},{-1014,760},{-1019,761},{-1016,762},{-1020,762},{-1020,764},{-1013,764},{-1011,763},{-1011,762},{-999,759},{-996,759},{-1002,761},{-997,761},{-994,762},{-1000,763},{-1010,765},{-997,766},{-991,764},{-988,765},{-990,766},{-897,810},{-903,812},{-889,812},{-900,813},{-888,815},{-873,815},{-883,816},{-904,814},{-909,814},{-895,816},{-903,817},{-914,815},{-889,818},{-888,819},{-891,820},{-881,821},{-868,819},{-872,820},{-863,820},{-854,818},{-858,820},{-852,820},{-944,792},{-943,792},{-946,792},{-850,781},{-850,782},{-998,784},{-997,784},{-945,783},{-943,782},{-947,783},{-946,783},{-980,782},{-881,784},{-882,783},{-884,783},{-882,784},{-959,785},{-984,788},{-985,788},{-863,790},{-858,791},{-852,790},{-865,789},{-850,783},{-855,781},{-863,781},{-859,783},{-860,783},{-867,781},{-875,781},{-871,782},{-875,782},{-875,784},{-868,788},{-852,789},{-850,789},{-853,777},{-857,779},{-975,763},{-1010,763},{-1009,763},{-1008,763},{-1007,763},{-1006,763},{-1007,764},{-1006,764},{-952,763},{-953,763},{-962,763},{-962,764},{-980,765},{-981,766},{-978,765},{-980,766},{-964,766},{-852,690},{-950,783},{-954,782},{-949,781},{-951,779},{-971,778},{-970,779},{-978,780},{-969,781},{-979,782},{-978,782},{-984,785},{-980,785},{-975,788},{-948,784},{-1020,791},{-1010,789},{-1012,788},{-1004,788},{-999,787},{-1000,786},{-995,786},{-999,784},{-989,781},{-991,780},{-990,779},{-1003,778},{-1006,779},{-1010,782},{-1020,783},{-900,785},{-894,782},{-902,783},{-904,783},{-904,781},{-921,782},{-930,785},{-916,785},{-933,786},{-938,788},{-930,788},{-943,790},{-934,792},{-907,792},{-927,793},{-920,793},{-926,794},{-922,794},{-924,795},{-939,793},{-943,793},{-938,794},{-944,794},{-952,793},{-952,794},{-957,794},{-958,795},{-943,797},{-959,796},{-966,799},{-962,799},{-967,800},{-964,800},{-968,801},{-944,800},{-941,802},{-953,801},{-957,802},{-953,802},{-952,802},{-967,803},{-954,803},{-961,805},{-959,805},{-960,806},{-938,805},{-947,807},{-941,807},{-956,808},{-949,811},{-939,810},{-931,811},{-931,812},{-944,812},{-933,814},{-918,812},{-919,811},{-906,806},{-908,806},{-892,805},{-890,804},{-893,804},{-891,803},{-893,803},{-888,801},{-882,801},{-887,803},{-886,804},{-877,804},{-876,802},{-881,801},{-869,799},{-871,796},{-874,796},{-873,795},{-867,797},{-860,795},{-857,796},{-850,793},{-853,792},{-870,790},{-870,789},{-876,786},{-880,788},{-879,790},{-882,790},{-882,788},{-881,787},{-884,787},{-879,786},{-882,785},{-886,786},{-888,786},{-885,784},{-888,781},{-900,786},{-891,763},{-892,763},{-972,766},{-971,766},{-960,765},{-959,765},{-971,765},{-972,765},{-894,764},{-896,764},{-895,765},{-913,765},{-914,765},{-905,765},{-904,765},{-850,745},{-885,745},{-897,745},{-910,747},{-908,749},{-912,747},{-911,746},{-919,747},{-923,751},{-920,751},{-925,752},{-924,755},{-920,756},{-922,757},{-921,758},{-927,760},{-931,764},{-954,762},{-948,763},{-961,765},{-958,765},{-956,766},{-970,767},{-963,768},{-969,770},{-957,771},{-937,769},{-932,767},{-933,765},{-937,764},{-936,764},{-931,766},{-910,767},{-916,765},{-893,763},{-892,762},{-905,762},{-901,761},{-913,762},{-902,761},{-911,760},{-910,760},{-899,760},{-897,759},{-898,758},{-892,758},{-893,756},{-896,756},{-889,754},{-887,755},{-889,756},{-888,757},{-883,755},{-874,755},{-873,756},{-863,754},{-865,754},{-850,757},{-1018,766},{-1017,766},{-993,766},{-994,766},{-992,766},{-1004,767},{-1003,767},{-1009,767},{-991,767},{-992,767},{-990,767},{-989,766},{-997,767},{-1012,768},{-1013,768},{-1000,768},{-996,768},{-994,767},{-1001,767},{-1000,767},{-1002,767},{-974,770},{-971,770},{-975,770},{-952,770},{-900,768},{-897,767},{-899,766},{-897,765},{-901,765},{-906,767},{-967,767},{-965,766},{-966,766},{-972,769},{-943,769},{-944,769},{-942,769},{-967,768},{-968,768},{-971,768},{-972,768},{-970,768},{-969,769},{-970,769},{-850,717},{-853,717},{-855,721},{-855,723},{-850,723},{-857,723},{-856,722},{-861,723},{-862,723},{-859,723},{-858,723},{-860,723},{-850,724},{-851,724},{-850,766},{-850,763},{-852,763},{-865,765},{-867,763},{-871,764},{-875,765},{-874,764},{-883,764},{-886,767},{-885,765},{-886,764},{-887,764},{-886,766},{-889,764},{-897,766},{-894,767},{-895,768},{-890,770},{-887,770},{-884,771},{-885,771},{-866,772},{-872,772},{-869,773},{-872,773},{-868,773},{-877,774},{-877,775},{-882,777},{-881,778},{-882,779},{-873,779},{-862,778},{-857,775},{-858,774},{-850,774},{-955,726},{-850,701},{-862,701},{-866,704},{-863,705},{-864,705},{-867,704},{-866,703},{-870,705},{-872,704},{-870,703},{-878,702},{-888,705},{-894,709},{-892,710},{-895,711},{-870,710},{-878,713},{-899,714},{-900,716},{-898,718},{-901,719},{-896,722},{-899,722},{-899,724},{-895,727},{-896,728},{-892,728},{-894,728},{-891,732},{-880,736},{-865,739},{-850,738},{-850,737},{-861,733},{-867,727},{-862,724},{-865,722},{-864,720},{-855,715},{-850,714},{-850,713},{-868,710},{-851,711},{-850,711},{-850,732},{-852,732},{-850,734},{-855,725},{-856,725},{-855,726},{-857,726},{-857,729},{-850,729},{-953,726},{-954,726},{-897,726},{-897,727},{-896,727},{-943,727},{-942,727},{-859,727},{-859,728},{-941,727},{-850,730},{-851,730},{-855,730},{-851,731},{-950,737},{-949,737},{-954,738},{-854,689},{-902,640},{-901,638},{-907,637},{-909,636},{-914,638},{-922,637},{-934,640},{-941,640},{-937,640},{-933,638},{-926,635},{-917,637},{-907,634},{-914,628},{-924,628},{-927,626},{-923,624},{-927,625},{-928,624},{-926,623},{-931,623},{-932,620},{-933,620},{-935,621},{-935,620},{-938,620},{-939,620},{-933,617},{-942,613},{-943,613},{-940,614},{-941,614},{-938,613},{-942,611},{-947,605},{-948,600},{-1020,600},{-1020,670},{-890,670},{-890,693},{-879,687},{-878,683},{-879,682},{-882,682},{-882,684},{-884,683},{-883,681},{-884,680},{-881,677},{-873,673},{-875,671},{-872,671},{-869,672},{-870,674},{-865,673},{-859,681},{-856,687},{-850,670},{-852,669},{-850,663},{-852,663},{-854,666},{-866,663},{-859,662},{-864,659},{-865,657},{-873,653},{-880,653},{-888,656},{-884,656},{-898,660},{-900,659},{-904,659},{-902,659},{-915,660},{-910,658},{-911,659},{-890,653},{-869,651},{-879,643},{-882,643},{-881,641},{-887,641},{-888,641},{-888,640},{-892,641},{-898,642},{-900,642},{-901,641},{-851,689},{-851,690},{-850,690},{-853,689},{-853,690},{-853,691},{-951,738},{-935,742},{-926,741},{-923,739},{-916,740},{-902,739},{-915,732},{-913,732},{-921,728},{-943,728},{-937,727},{-938,726},{-935,725},{-939,722},{-952,724},{-951,725},{-956,731},{-958,731},{-955,732},{-957,737},{-946,737},{-854,690},{-850,691},{-851,691},{-851,692},{-854,691},{-855,691},{-852,691},{-850,692},{-854,693},{-853,693},{-855,694},{-853,694},{-855,695},{-853,696},{-855,698},{-852,698},{-856,698},{-855,699}}}, - {"America/Regina",17,{{-1050,490},{-1100,490},{-1100,527},{-1094,527},{-1092,529},{-1089,528},{-1088,530},{-1096,536},{-1100,536},{-1100,600},{-1020,600},{-1019,551},{-1025,548},{-1025,545},{-1018,541},{-1014,490},{-1078,503}}}, - {"America/Indiana/Vincennes",7,{{-877,384},{-875,387},{-875,389},{-867,389},{-867,382},{-871,382},{-871,385}}}, - {"America/Santarem",53,{{-530,0},{-526,-4},{-524,-11},{-521,-12},{-518,-12},{-519,-15},{-523,-17},{-520,-28},{-518,-32},{-519,-35},{-522,-32},{-526,-38},{-527,-45},{-529,-50},{-524,-63},{-520,-67},{-526,-72},{-529,-82},{-528,-85},{-521,-89},{-520,-93},{-522,-96},{-525,-96},{-526,-97},{-568,-94},{-576,-88},{-576,-82},{-585,-67},{-563,-22},{-567,-22},{-571,-18},{-577,-16},{-587,-6},{-590,13},{-588,12},{-585,13},{-583,16},{-580,15},{-580,17},{-575,17},{-573,20},{-560,18},{-559,20},{-561,23},{-560,25},{-554,24},{-549,26},{-547,24},{-547,18},{-544,18},{-534,13},{-534,9},{-531,7}}}, - {"Africa/Djibouti",14,{{432,114},{430,110},{426,111},{418,110},{418,117},{424,124},{427,124},{431,127},{434,124},{434,120},{425,116},{426,115},{431,116},{432,117}}}, - {"Pacific/Tahiti",289,{{-1462,-158},{-1506,-177},{-1506,-176},{-1476,-239},{-1477,-239},{-1477,-238},{-1513,-225},{-1514,-224},{-1547,-218},{-1406,-216},{-1406,-217},{-1407,-217},{-1443,-276},{-1443,-277},{-1444,-276},{-1476,-238},{-1494,-234},{-1495,-234},{-1528,-226},{-1529,-227},{-1529,-226},{-1385,-208},{-1385,-209},{-1431,-207},{-1433,-206},{-1391,-208},{-1392,-208},{-1435,-204},{-1436,-204},{-1450,-199},{-1449,-199},{-1404,-196},{-1387,-194},{-1404,-197},{-1392,-193},{-1392,-194},{-1393,-194},{-1388,-193},{-1412,-192},{-1413,-192},{-1407,-192},{-1407,-191},{-1454,-175},{-1455,-175},{-1418,-187},{-1392,-186},{-1365,-185},{-1363,-185},{-1363,-186},{-1422,-183},{-1421,-183},{-1421,-182},{-1408,-184},{-1407,-184},{-1408,-183},{-1371,-183},{-1370,-183},{-1370,-184},{-1422,-181},{-1424,-181},{-1424,-180},{-1422,-180},{-1481,-179},{-1406,-177},{-1406,-178},{-1408,-179},{-1431,-178},{-1431,-179},{-1408,-178},{-1407,-177},{-1422,-182},{-1410,-181},{-1409,-181},{-1408,-182},{-1388,-188},{-1418,-188},{-1434,-175},{-1435,-175},{-1435,-174},{-1455,-174},{-1415,-174},{-1384,-173},{-1384,-174},{-1426,-173},{-1443,-172},{-1383,-173},{-1385,-174},{-1456,-173},{-1456,-174},{-1414,-174},{-1415,-173},{-1414,-173},{-1455,-173},{-1385,-173},{-1444,-171},{-1443,-171},{-1496,-170},{-1495,-170},{-1431,-170},{-1446,-170},{-1447,-170},{-1454,-174},{-1446,-169},{-1419,-168},{-1540,-168},{-1514,-169},{-1447,-168},{-1443,-168},{-1450,-168},{-1514,-168},{-1515,-169},{-1515,-168},{-1430,-164},{-1539,-168},{-1449,-168},{-1428,-167},{-1429,-167},{-1429,-168},{-1510,-168},{-1509,-168},{-1451,-167},{-1451,-168},{-1510,-167},{-1429,-166},{-1428,-166},{-1438,-166},{-1437,-166},{-1442,-166},{-1436,-166},{-1442,-167},{-1546,-166},{-1546,-165},{-1547,-165},{-1438,-165},{-1454,-165},{-1518,-165},{-1515,-166},{-1452,-167},{-1441,-167},{-1440,-168},{-1453,-167},{-1454,-167},{-1515,-167},{-1444,-164},{-1432,-164},{-1431,-164},{-1435,-166},{-1434,-166},{-1434,-167},{-1433,-169},{-1432,-169},{-1448,-169},{-1491,-178},{-1496,-177},{-1496,-176},{-1493,-175},{-1426,-176},{-1425,-176},{-1426,-175},{-1499,-175},{-1498,-175},{-1498,-176},{-1427,-175},{-1409,-158},{-1518,-164},{-1517,-164},{-1517,-165},{-1522,-164},{-1523,-165},{-1523,-164},{-1443,-164},{-1455,-164},{-1455,-163},{-1431,-163},{-1518,-163},{-1518,-162},{-1424,-162},{-1425,-162},{-1432,-163},{-1424,-161},{-1425,-163},{-1448,-162},{-1401,-160},{-1402,-160},{-1452,-159},{-1452,-160},{-1459,-159},{-1459,-160},{-1457,-160},{-1456,-160},{-1456,-161},{-1450,-162},{-1463,-162},{-1464,-162},{-1464,-161},{-1449,-161},{-1448,-161},{-1450,-161},{-1458,-161},{-1457,-161},{-1425,-161},{-1408,-158},{-1460,-158},{-1424,-159},{-1424,-160},{-1423,-159},{-1423,-160},{-1546,-158},{-1545,-158},{-1446,-158},{-1447,-157},{-1446,-157},{-1469,-157},{-1469,-156},{-1455,-156},{-1462,-154},{-1462,-153},{-1464,-153},{-1462,-155},{-1455,-154},{-1454,-155},{-1455,-155},{-1483,-158},{-1482,-159},{-1483,-159},{-1451,-158},{-1452,-158},{-1451,-159},{-1465,-158},{-1463,-153},{-1472,-153},{-1466,-152},{-1466,-153},{-1477,-152},{-1478,-152},{-1468,-152},{-1483,-151},{-1482,-151},{-1474,-152},{-1473,-152},{-1479,-151},{-1476,-150},{-1475,-151},{-1474,-151},{-1472,-152},{-1445,-150},{-1446,-150},{-1477,-149},{-1477,-150},{-1481,-149},{-1480,-149},{-1478,-149},{-1479,-149},{-1487,-149},{-1388,-148},{-1486,-149},{-1480,-150},{-1474,-153},{-1475,-153},{-1452,-146},{-1451,-146},{-1464,-146},{-1464,-145},{-1451,-145},{-1462,-145},{-1450,-145},{-1463,-144},{-1462,-144},{-1450,-144},{-1460,-144},{-1460,-145},{-1459,-144},{-1461,-144},{-1449,-145},{-1459,-143},{-1458,-143},{-1458,-144},{-1412,-142},{-1413,-142},{-1414,-141},{-1412,-141},{-1449,-144},{-1452,-147},{-1453,-147},{-1440,-165},{-1439,-165},{-1442,-165},{-1454,-164},{-1453,-165}}}, - {"Europe/San_Marino",3,{{125,439},{124,439},{125,440}}}, - {"America/Argentina/San_Luis",13,{{-658,-319},{-653,-321},{-652,-323},{-649,-323},{-649,-325},{-651,-332},{-651,-360},{-666,-360},{-665,-349},{-668,-344},{-668,-340},{-672,-334},{-674,-319}}}, - {"Africa/Ceuta",5,{{-24,352},{-30,353},{-29,353},{-54,359},{-53,359}}}, - {"Asia/Singapore",9,{{1037,12},{1038,12},{1038,13},{1040,14},{1039,14},{1037,13},{1041,14},{1036,13},{1038,15}}}, - {"America/Campo_Grande",40,{{-531,-180},{-530,-184},{-528,-184},{-529,-187},{-525,-187},{-509,-194},{-510,-202},{-516,-206},{-521,-217},{-524,-221},{-536,-229},{-537,-233},{-540,-234},{-541,-240},{-543,-241},{-547,-238},{-554,-240},{-557,-230},{-556,-227},{-559,-223},{-562,-223},{-564,-221},{-568,-223},{-580,-220},{-578,-210},{-582,-202},{-579,-200},{-581,-198},{-575,-182},{-577,-177},{-575,-180},{-571,-178},{-568,-173},{-561,-172},{-552,-177},{-546,-175},{-544,-177},{-541,-176},{-537,-173},{-540,-179}}}, - {"Africa/Tunis",64,{{111,334},{108,335},{109,336},{108,337},{109,337},{107,337},{107,339},{111,338},{110,346},{110,347},{111,347},{112,347},{113,348},{112,348},{89,375},{90,375},{109,371},{108,371},{98,372},{112,323},{103,317},{101,315},{103,308},{99,304},{96,302},{91,321},{84,325},{81,331},{77,333},{75,340},{83,346},{85,352},{83,353},{83,358},{84,364},{82,365},{92,372},{98,373},{99,373},{98,371},{103,372},{101,371},{104,367},{111,371},{111,368},{108,365},{105,364},{105,361},{107,358},{110,356},{112,352},{107,347},{101,343},{100,340},{104,336},{111,336},{113,333},{111,333},{112,332},{116,332},{115,327},{116,325},{110,357},{110,358}}}, - {"Europe/Copenhagen",191,{{105,550},{121,549},{121,550},{107,550},{107,549},{150,550},{147,551},{148,553},{152,551},{110,548},{110,549},{118,549},{118,550},{122,548},{120,546},{105,549},{114,550},{113,550},{104,548},{103,549},{102,550},{105,548},{106,549},{117,549},{119,547},{115,546},{112,548},{112,550},{111,549},{111,548},{115,549},{120,549},{120,550},{116,549},{114,549},{104,550},{115,550},{116,550},{119,550},{128,556},{127,556},{128,557},{117,562},{118,562},{110,572},{109,573},{112,573},{111,573},{116,567},{115,567},{117,567},{108,561},{83,555},{108,555},{105,555},{97,555},{126,556},{125,556},{126,557},{102,556},{121,557},{118,558},{119,558},{83,560},{103,557},{102,558},{103,558},{113,558},{101,558},{100,558},{101,559},{106,559},{107,559},{106,558},{105,560},{112,559},{111,559},{108,559},{104,559},{104,560},{85,552},{86,552},{86,551},{85,551},{96,551},{95,551},{117,552},{114,552},{115,552},{112,552},{98,550},{100,550},{101,549},{108,548},{107,547},{106,548},{110,552},{103,550},{123,550},{122,551},{126,550},{106,550},{106,551},{96,554},{97,553},{96,553},{95,553},{97,552},{94,550},{97,550},{98,548},{87,549},{86,554},{81,556},{81,560},{82,558},{84,559},{82,561},{82,566},{86,566},{82,568},{86,571},{94,572},{100,576},{107,577},{104,576},{106,572},{103,570},{103,567},{102,567},{110,564},{107,561},{104,562},{105,563},{103,562},{99,559},{100,557},{95,557},{99,556},{95,555},{101,551},{117,551},{112,551},{111,552},{122,550},{101,550},{107,551},{103,551},{102,551},{123,554},{125,553},{120,552},{116,551},{111,553},{112,554},{112,556},{109,557},{111,557},{115,559},{113,560},{118,560},{117,557},{118,557},{119,559},{121,558},{120,557},{119,557},{120,559},{119,560},{125,561},{122,555},{86,553},{85,553},{110,553},{99,552},{99,553},{98,553},{84,554},{84,555},{85,554},{97,554},{106,556},{107,556},{107,555},{106,555},{105,554},{109,553},{100,551},{103,556},{104,556},{105,556}}}, - {"Asia/Pontianak",110,{{1091,-1},{1142,-34},{1080,2},{1086,1},{1089,5},{1088,5},{1089,7},{1087,7},{1087,8},{1088,8},{1092,17},{1093,18},{1093,17},{1088,7},{1091,-13},{1092,-13},{1092,-12},{1093,-12},{1096,-13},{1094,-13},{1095,-10},{1098,-10},{1098,-11},{1093,-7},{1094,-7},{1093,-6},{1091,-2},{1134,-33},{1134,-32},{1102,-29},{1101,-29},{1101,-27},{1101,-28},{1100,-27},{1101,-26},{1101,-24},{1093,-17},{1087,-17},{1088,-17},{1091,-17},{1094,-17},{1092,-16},{1087,-16},{1088,-16},{1094,-15},{1090,-15},{1101,-14},{1092,-14},{1100,-14},{1093,-15},{1089,-16},{1089,-15},{1156,-15},{1154,-15},{1153,-20},{1146,-30},{1144,-35},{1141,-33},{1136,-35},{1136,-32},{1133,-33},{1130,-29},{1130,-31},{1126,-34},{1122,-33},{1119,-36},{1118,-35},{1118,-30},{1117,-28},{1115,-30},{1114,-29},{1107,-31},{1105,-29},{1103,-30},{1101,-20},{1099,-18},{1099,-12},{1100,-11},{1097,-9},{1093,-9},{1095,-7},{1096,-8},{1096,-7},{1091,-5},{1092,-2},{1092,1},{1089,3},{1090,15},{1093,19},{1096,21},{1095,19},{1097,16},{1106,9},{1112,11},{1118,10},{1125,16},{1130,16},{1130,14},{1137,12},{1141,15},{1137,6},{1144,5},{1149,7},{1151,4},{1149,3},{1149,-1},{1153,-1},{1152,-3},{1154,-8},{1158,-12}}}, - {"Asia/Dubai",82,{{524,241},{525,241},{533,241},{530,241},{530,242},{540,241},{540,242},{520,242},{541,242},{531,242},{534,242},{535,242},{515,244},{516,244},{538,241},{536,242},{538,243},{517,243},{526,243},{527,243},{531,244},{543,244},{542,243},{542,244},{543,243},{537,243},{532,243},{534,243},{533,243},{531,243},{536,243},{545,244},{517,245},{534,245},{545,245},{544,244},{534,244},{529,252},{529,251},{542,252},{558,257},{559,257},{550,259},{560,258},{556,255},{556,256},{557,256},{554,254},{555,255},{555,254},{558,247},{558,242},{560,241},{555,240},{556,238},{551,226},{526,229},{516,241},{519,239},{526,242},{536,240},{542,242},{541,243},{544,242},{547,248},{553,252},{562,261},{564,250},{561,247},{559,250},{523,245},{543,245},{544,245},{517,246},{546,246},{545,246},{526,248},{529,249},{546,247},{547,247},{548,248},{531,249}}}, - {"Africa/Khartoum",129,{{385,182},{385,181},{362,226},{362,227},{384,182},{384,181},{383,182},{377,187},{375,187},{376,187},{380,188},{381,188},{382,188},{374,191},{374,190},{374,189},{375,188},{377,188},{376,192},{378,192},{377,192},{372,208},{373,208},{371,211},{372,211},{369,221},{357,127},{351,117},{350,109},{348,107},{346,109},{343,106},{343,102},{341,95},{339,95},{339,102},{331,107},{332,122},{327,122},{327,120},{321,120},{323,117},{325,111},{312,98},{308,97},{299,103},{295,101},{295,98},{289,97},{287,93},{280,93},{279,96},{266,95},{263,97},{258,104},{251,103},{246,89},{241,87},{235,87},{236,90},{234,90},{237,93},{237,99},{229,109},{230,113},{226,116},{226,120},{225,120},{225,126},{222,128},{219,126},{218,128},{223,133},{221,138},{226,142},{224,145},{227,147},{227,149},{229,151},{229,156},{231,157},{240,157},{240,200},{250,200},{250,220},{313,220},{315,222},{314,220},{332,220},{336,217},{340,218},{342,222},{347,223},{350,229},{352,228},{356,231},{358,228},{368,222},{370,214},{373,211},{371,212},{372,196},{386,180},{383,176},{375,173},{374,170},{370,171},{370,163},{364,152},{365,138},{362,127},{368,221},{366,223},{367,223},{367,222},{366,224},{365,224},{364,226},{363,226},{364,227},{363,227},{361,227},{363,228},{362,228},{357,229},{363,229},{362,229},{361,228},{360,227}}}, - {"Europe/Helsinki",400,{{207,632},{207,633},{266,604},{265,604},{214,616},{216,616},{215,616},{214,617},{215,617},{276,604},{275,604},{275,605},{208,631},{209,630},{208,630},{230,598},{229,598},{210,606},{210,607},{214,612},{213,612},{215,612},{215,613},{212,609},{212,610},{210,608},{215,614},{214,615},{213,615},{237,642},{236,642},{244,647},{253,650},{249,650},{248,649},{246,650},{248,651},{251,650},{251,651},{252,653},{253,653},{253,654},{254,651},{253,651},{252,651},{249,654},{248,654},{250,654},{243,657},{242,658},{241,658},{250,656},{246,656},{246,657},{245,657},{249,656},{226,637},{225,638},{226,638},{228,639},{227,639},{233,639},{232,639},{232,640},{235,641},{237,641},{227,637},{228,637},{227,638},{228,638},{211,625},{211,626},{211,627},{210,627},{212,624},{213,624},{212,623},{213,621},{213,623},{216,617},{215,618},{214,618},{214,619},{213,618},{213,619},{211,628},{212,628},{211,629},{212,629},{214,629},{214,630},{213,630},{214,631},{212,630},{211,630},{216,631},{213,631},{215,631},{220,632},{215,632},{214,632},{222,633},{223,633},{270,604},{217,634},{216,634},{223,634},{222,634},{220,633},{221,633},{212,633},{212,634},{220,634},{221,634},{213,634},{212,632},{214,633},{213,632},{211,633},{213,633},{216,633},{217,633},{219,633},{218,633},{212,604},{213,604},{221,632},{214,634},{211,634},{218,634},{218,635},{221,635},{224,636},{224,635},{225,635},{274,604},{271,604},{269,604},{257,604},{264,604},{263,604},{218,604},{219,604},{267,604},{217,604},{216,604},{215,604},{261,604},{214,604},{262,604},{221,604},{222,604},{223,604},{225,604},{224,604},{220,604},{225,598},{225,599},{213,609},{212,608},{213,607},{214,608},{214,607},{213,608},{211,608},{212,605},{270,605},{271,605},{274,605},{273,605},{268,604},{216,605},{269,605},{218,605},{219,605},{268,605},{212,606},{218,606},{217,606},{213,606},{215,606},{214,606},{216,598},{217,598},{223,598},{224,598},{214,605},{217,605},{215,605},{213,605},{236,598},{224,599},{217,599},{236,599},{226,599},{230,599},{234,599},{222,599},{221,599},{222,598},{223,599},{233,599},{229,599},{238,599},{239,599},{237,599},{238,600},{227,599},{226,600},{223,600},{218,599},{218,600},{224,600},{225,600},{235,599},{231,599},{213,602},{212,602},{255,602},{254,602},{251,602},{221,602},{215,601},{215,602},{253,602},{259,602},{219,602},{222,602},{223,602},{220,603},{250,602},{214,602},{217,602},{216,602},{273,603},{271,603},{272,603},{266,603},{267,603},{212,603},{260,603},{261,603},{262,603},{230,603},{218,603},{215,603},{216,603},{213,603},{223,603},{219,603},{214,603},{217,603},{260,602},{256,602},{258,602},{257,602},{220,602},{224,602},{252,602},{225,602},{255,603},{258,603},{259,603},{252,603},{218,602},{222,603},{221,603},{256,603},{224,603},{225,603},{239,600},{240,600},{246,601},{228,600},{212,601},{213,601},{214,601},{228,601},{229,601},{247,601},{251,601},{224,601},{221,601},{223,601},{222,601},{219,601},{220,601},{218,601},{217,601},{216,601},{230,601},{212,600},{213,600},{243,600},{244,600},{227,600},{219,600},{242,600},{241,600},{229,600},{230,600},{250,601},{249,602},{249,601},{226,602},{211,603},{268,603},{264,603},{263,603},{265,605},{265,603},{248,602},{245,601},{243,601},{235,600},{232,598},{232,600},{233,601},{229,602},{227,604},{219,607},{215,607},{214,609},{213,611},{216,612},{215,615},{217,616},{213,620},{215,622},{212,626},{217,631},{215,633},{224,633},{222,635},{224,634},{223,635},{223,636},{229,637},{230,638},{231,639},{234,639},{234,641},{236,640},{245,648},{253,648},{252,650},{255,650},{253,655},{245,658},{239,661},{237,663},{236,664},{240,668},{236,672},{238,674},{234,675},{237,680},{228,684},{220,685},{206,691},{211,690},{210,692},{216,693},{224,687},{232,686},{240,688},{249,686},{251,688},{257,689},{259,697},{265,699},{280,701},{284,698},{291,697},{293,695},{288,692},{289,691},{284,689},{288,689},{285,685},{287,682},{293,681},{300,677},{290,669},{301,658},{301,657},{297,656},{299,656},{296,653},{299,651},{296,650},{298,648},{301,648},{301,644},{306,641},{300,638},{312,632},{316,629},{309,623},{277,605}}}, - {"America/Whitehorse",67,{{-1366,689},{-1365,689},{-1373,690},{-1372,690},{-1386,693},{-1389,694},{-1372,689},{-1364,689},{-1364,677},{-1362,676},{-1361,670},{-1338,670},{-1341,670},{-1336,666},{-1338,663},{-1336,663},{-1336,660},{-1323,660},{-1326,659},{-1322,656},{-1328,652},{-1323,651},{-1326,648},{-1317,645},{-1319,644},{-1312,644},{-1309,640},{-1301,639},{-1303,637},{-1298,635},{-1302,632},{-1296,631},{-1298,629},{-1295,626},{-1292,625},{-1293,624},{-1293,622},{-1285,621},{-1278,616},{-1272,615},{-1270,612},{-1271,611},{-1269,611},{-1268,608},{-1259,609},{-1253,608},{-1246,610},{-1245,608},{-1246,607},{-1242,605},{-1240,600},{-1391,600},{-1392,601},{-1391,604},{-1400,602},{-1410,603},{-1410,696},{-1398,696},{-1395,640},{-1394,641},{-1395,696},{-1393,695},{-1394,695},{-1391,695},{-1393,696},{-1391,696},{-1389,696}}}, - {"America/Maceio",18,{{-372,-112},{-364,-105},{-369,-107},{-374,-115},{-378,-115},{-382,-109},{-382,-107},{-378,-107},{-378,-101},{-380,-97},{-380,-95},{-382,-94},{-382,-93},{-378,-89},{-369,-94},{-364,-92},{-360,-89},{-352,-89}}}, - {"Africa/Douala",69,{{96,36},{85,47},{144,61},{146,59},{145,53},{147,52},{147,46},{151,43},{152,41},{151,40},{152,37},{161,29},{161,17},{146,22},{117,23},{114,23},{114,22},{99,22},{98,25},{100,31},{95,38},{97,39},{97,41},{94,39},{92,39},{86,47},{87,45},{85,45},{88,52},{88,58},{95,64},{97,65},{98,68},{102,70},{102,69},{105,69},{106,72},{111,65},{114,65},{116,70},{118,71},{118,73},{122,80},{122,84},{128,88},{129,94},{132,96},{132,100},{135,102},{137,110},{140,113},{141,113},{146,115},{147,122},{142,124},{141,131},{145,131},{146,128},{148,126},{151,118},{150,111},{151,105},{157,100},{142,100},{140,97},{145,90},{152,86},{156,78},{148,63}}}, - {"Asia/Kuala_Lumpur",93,{{1040,15},{1034,13},{1033,15},{1023,21},{1041,23},{1041,22},{1045,25},{1045,24},{1043,26},{1041,29},{1035,35},{1037,48},{1037,49},{1033,52},{1006,40},{1005,40},{1005,42},{1006,42},{1005,43},{1012,29},{1012,30},{1013,30},{1013,29},{1013,31},{1012,31},{1040,24},{1040,25},{1039,25},{1038,25},{1042,28},{1041,28},{1042,29},{1038,26},{1038,27},{1039,27},{989,57},{997,63},{999,63},{999,64},{996,64},{999,65},{997,62},{998,62},{1022,62},{998,63},{999,62},{1002,52},{1004,53},{1036,27},{1040,23},{1043,14},{1041,14},{1040,16},{1040,14},{1037,15},{1035,13},{1033,16},{1013,28},{1013,32},{1007,39},{1008,40},{1006,43},{1007,47},{1004,51},{1002,67},{1004,65},{1007,65},{1009,62},{1011,63},{1010,58},{1011,56},{1016,59},{1018,57},{1021,62},{1024,62},{1031,54},{1034,48},{1035,43},{1033,37},{1034,29},{1031,56},{1003,53},{1002,53},{1002,55},{1004,54},{1030,57},{1003,57},{1003,58},{1030,58},{1029,58},{1003,59},{1028,59},{1027,59}}}, - {"America/Martinique",8,{{-610,148},{-609,146},{-609,148},{-609,144},{-611,145},{-610,146},{-612,148},{-609,147}}}, - {"America/Sao_Paulo",232,{{-511,-305},{-512,-305},{-497,-293},{-508,-311},{-521,-322},{-520,-319},{-521,-318},{-519,-319},{-512,-315},{-512,-311},{-507,-308},{-507,-304},{-506,-305},{-506,-302},{-509,-304},{-513,-300},{-513,-303},{-511,-304},{-513,-305},{-513,-308},{-514,-306},{-514,-311},{-519,-313},{-520,-317},{-522,-317},{-521,-320},{-523,-321},{-527,-332},{-534,-338},{-535,-337},{-535,-332},{-531,-327},{-536,-324},{-537,-321},{-546,-314},{-552,-313},{-556,-308},{-560,-311},{-560,-308},{-568,-301},{-571,-301},{-574,-303},{-576,-302},{-559,-284},{-557,-284},{-558,-282},{-550,-279},{-548,-275},{-543,-274},{-542,-273},{-538,-272},{-537,-270},{-538,-266},{-536,-263},{-538,-260},{-538,-257},{-541,-255},{-544,-257},{-546,-256},{-543,-244},{-543,-241},{-541,-239},{-540,-234},{-537,-233},{-536,-229},{-525,-222},{-521,-217},{-516,-206},{-510,-202},{-509,-195},{-525,-187},{-529,-187},{-528,-184},{-530,-184},{-532,-173},{-524,-161},{-522,-159},{-519,-158},{-516,-152},{-511,-149},{-509,-137},{-504,-125},{-503,-125},{-504,-128},{-494,-132},{-490,-126},{-488,-132},{-482,-130},{-482,-132},{-478,-133},{-477,-131},{-475,-133},{-462,-128},{-461,-130},{-463,-139},{-459,-144},{-461,-152},{-442,-142},{-438,-143},{-439,-146},{-437,-147},{-432,-146},{-421,-152},{-418,-151},{-414,-155},{-413,-158},{-408,-157},{-399,-160},{-399,-163},{-403,-166},{-402,-168},{-405,-169},{-406,-174},{-402,-178},{-402,-180},{-397,-183},{-397,-194},{-410,-213},{-411,-215},{-410,-220},{-420,-225},{-419,-228},{-420,-230},{-430,-230},{-431,-227},{-433,-228},{-432,-228},{-432,-230},{-435,-231},{-440,-231},{-436,-231},{-438,-229},{-442,-231},{-444,-229},{-447,-232},{-445,-233},{-451,-234},{-454,-236},{-454,-238},{-459,-238},{-469,-243},{-479,-250},{-482,-255},{-481,-253},{-483,-254},{-484,-252},{-485,-255},{-487,-254},{-483,-256},{-486,-262},{-487,-262},{-488,-261},{-488,-262},{-487,-264},{-485,-262},{-487,-267},{-486,-271},{-485,-271},{-486,-273},{-486,-282},{-488,-286},{-494,-289},{-522,-320},{-506,-304},{-506,-303},{-507,-303},{-484,-275},{-483,-273},{-484,-274},{-483,-274},{-484,-273},{-487,-284},{-487,-285},{-486,-284},{-487,-283},{-486,-281},{-485,-279},{-485,-277},{-485,-278},{-485,-275},{-486,-278},{-486,-275},{-485,-272},{-410,-216},{-420,-229},{-439,-230},{-439,-229},{-443,-229},{-419,-229},{-431,-228},{-418,-228},{-451,-236},{-451,-235},{-450,-235},{-449,-234},{-448,-234},{-446,-232},{-443,-232},{-444,-232},{-441,-232},{-446,-231},{-445,-231},{-444,-230},{-444,-231},{-443,-230},{-445,-230},{-470,-244},{-467,-242},{-457,-241},{-484,-253},{-483,-253},{-479,-251},{-478,-251},{-451,-238},{-453,-236},{-453,-240},{-455,-239},{-453,-237},{-452,-238},{-463,-241},{-462,-240},{-452,-236},{-487,-266},{-486,-265},{-487,-263},{-484,-255},{-482,-254},{-483,-255},{-484,-254},{-484,-256},{-486,-255},{-488,-263}}}, - {"America/Dawson",2,{{-1395,640},{-1394,641}}}, - {"Africa/Kinshasa",93,{{129,-59},{127,-60},{128,-60},{129,-60},{124,-60},{125,-60},{126,-60},{150,-46},{156,-40},{159,-39},{162,-33},{162,-22},{168,-13},{173,-10},{177,-6},{178,1},{180,4},{179,10},{181,15},{181,22},{186,32},{185,43},{188,44},{191,49},{197,51},{203,48},{206,44},{217,43},{225,41},{229,39},{235,38},{234,36},{232,37},{226,34},{228,33},{228,30},{231,31},{230,26},{234,25},{237,22},{230,22},{228,20},{226,21},{223,15},{226,14},{230,4},{234,-2},{230,-4},{235,-4},{236,-6},{234,-8},{239,-13},{243,-14},{244,-18},{238,-18},{237,-20},{232,-21},{226,-18},{225,-20},{222,-19},{223,-25},{221,-23},{218,-25},{215,-23},{214,-25},{210,-25},{207,-33},{207,-42},{203,-44},{200,-43},{202,-57},{197,-62},{200,-70},{195,-70},{194,-80},{185,-79},{175,-81},{170,-72},{167,-62},{165,-59},{130,-59},{125,-61},{122,-58},{125,-57},{125,-51},{131,-46},{134,-49},{137,-47},{137,-44},{140,-45},{144,-43},{144,-49},{146,-49}}}, - {"Europe/Riga",30,{{221,576},{226,578},{226,576},{231,574},{233,571},{238,570},{244,573},{244,579},{253,581},{260,578},{265,575},{269,576},{276,575},{279,573},{277,568},{280,568},{282,563},{276,558},{271,559},{266,557},{257,561},{251,562},{249,564},{245,563},{220,564},{211,561},{211,568},{214,570},{214,573},{217,576}}}, - {"Africa/Tripoli",51,{{250,270},{250,200},{240,200},{240,195},{160,235},{142,226},{135,232},{120,235},{116,242},{114,242},{110,245},{102,246},{100,249},{100,253},{94,262},{99,266},{98,273},{100,279},{98,294},{94,302},{99,303},{102,307},{103,311},{101,315},{103,317},{115,324},{116,332},{123,328},{134,329},{152,324},{157,314},{178,309},{191,303},{196,304},{201,308},{202,312},{199,318},{202,323},{211,328},{222,329},{231,326},{231,323},{233,322},{250,319},{250,318},{251,317},{251,316},{249,314},{250,308},{247,301},{250,293}}}, - {"Europe/Madrid",137,{{-30,359},{-30,360},{-56,360},{-69,371},{-69,372},{-8,377},{-7,377},{-8,378},{-7,378},{43,398},{38,399},{38,400},{42,401},{23,396},{16,390},{29,391},{29,392},{30,392},{30,391},{-5,382},{16,387},{14,386},{14,387},{14,388},{15,388},{12,390},{12,389},{16,391},{20,425},{20,424},{19,425},{-88,419},{-89,422},{-89,423},{-89,424},{-90,425},{-88,425},{-89,425},{-89,426},{31,398},{35,397},{31,393},{27,396},{25,395},{28,399},{32,400},{-9,377},{-7,376},{-13,376},{-18,373},{-21,367},{-24,368},{-27,367},{-44,367},{-46,365},{-52,364},{-55,361},{-60,362},{-64,367},{-63,368},{-63,369},{-62,369},{-61,371},{-64,368},{-68,373},{-70,373},{-74,372},{-75,376},{-69,382},{-71,382},{-73,384},{-70,391},{-75,397},{-70,397},{-69,400},{-70,402},{-68,404},{-69,410},{-62,416},{-66,417},{-66,420},{-81,418},{-82,421},{-89,419},{-89,421},{-88,421},{-88,422},{-86,423},{-87,424},{-87,427},{-89,428},{-91,427},{-93,431},{-88,433},{-83,434},{-82,433},{-82,434},{-82,435},{-83,435},{-83,436},{-77,438},{-70,435},{-62,436},{-61,435},{-58,437},{-45,434},{-36,435},{-30,433},{-28,435},{-23,433},{-18,434},{-14,433},{-14,431},{-8,430},{-6,428},{7,427},{7,429},{14,427},{15,424},{27,423},{30,425},{33,423},{30,422},{32,420},{29,417},{21,413},{10,410},{7,408},{9,407},{8,407},{7,407},{6,407},{5,406},{-3,395},{-1,390},{2,387},{-5,383}}}, - {"America/Nipigon",2,{{-882,490},{-884,490}}}, - {"Pacific/Fakaofo",5,{{-1712,-94},{-1712,-93},{-1718,-92},{-1719,-92},{-1725,-86}}}, - {"Europe/Skopje",11,{{224,423},{229,420},{230,417},{230,414},{228,413},{227,411},{221,412},{216,409},{207,409},{205,415},{208,421}}}, - {"America/St_Thomas",13,{{-647,177},{-649,177},{-646,178},{-651,183},{-651,184},{-649,184},{-648,183},{-650,183},{-649,183},{-647,184},{-647,183},{-648,184},{-650,184}}}, - {"Africa/Maseru",12,{{284,-302},{281,-307},{278,-306},{274,-303},{274,-302},{270,-296},{274,-295},{278,-289},{287,-286},{295,-294},{292,-297},{292,-299}}}, - {"Europe/Sofia",34,{{279,428},{279,427},{275,425},{277,424},{280,420},{276,419},{273,421},{266,420},{264,417},{261,417},{261,414},{253,412},{243,416},{230,413},{230,417},{229,420},{224,423},{226,425},{224,428},{228,429},{230,432},{225,435},{224,438},{227,442},{230,441},{229,439},{230,438},{254,436},{263,440},{273,441},{286,437},{285,434},{282,434},{279,432}}}, - {"America/Porto_Velho",40,{{-600,-119},{-598,-124},{-604,-134},{-608,-137},{-611,-135},{-618,-135},{-621,-131},{-628,-130},{-631,-127},{-633,-127},{-637,-125},{-643,-125},{-645,-122},{-650,-120},{-654,-113},{-654,-97},{-656,-98},{-658,-97},{-666,-99},{-668,-98},{-664,-94},{-660,-94},{-658,-96},{-652,-92},{-651,-94},{-648,-90},{-641,-90},{-640,-84},{-635,-80},{-629,-80},{-621,-88},{-619,-89},{-617,-87},{-615,-89},{-616,-93},{-615,-96},{-615,-110},{-600,-111},{-599,-114},{-601,-117}}}, - {"America/St_Kitts",6,{{-626,171},{-626,172},{-625,171},{-628,173},{-628,174},{-627,172}}}, - {"Africa/Casablanca",46,{{-98,315},{-58,298},{-65,296},{-72,296},{-87,287},{-87,277},{-132,277},{-129,280},{-122,281},{-123,280},{-115,283},{-102,293},{-96,302},{-96,304},{-99,306},{-98,314},{-93,322},{-93,326},{-85,333},{-68,340},{-59,358},{-54,359},{-51,354},{-44,352},{-37,353},{-33,352},{-30,355},{-29,351},{-27,351},{-29,353},{-22,351},{-17,348},{-18,346},{-17,345},{-17,333},{-14,327},{-10,325},{-13,323},{-12,321},{-29,321},{-28,318},{-37,316},{-38,312},{-36,309},{-48,306},{-51,300}}}, - {"Asia/Hebron",9,{{352,317},{350,319},{350,322},{352,326},{356,324},{356,318},{355,315},{349,313},{350,316}}}, - {"Asia/Dili",18,{{1245,-92},{1243,-95},{1242,-94},{1241,-94},{1273,-84},{1255,-83},{1255,-82},{1256,-81},{1256,-83},{1251,-87},{1270,-83},{1265,-90},{1251,-94},{1250,-92},{1252,-91},{1249,-90},{1251,-88},{1253,-88}}}, - {"America/Argentina/San_Juan",27,{{-699,-300},{-700,-293},{-698,-291},{-696,-284},{-695,-284},{-689,-289},{-690,-296},{-683,-297},{-676,-303},{-671,-309},{-670,-315},{-667,-319},{-674,-319},{-674,-324},{-680,-321},{-685,-322},{-692,-320},{-697,-323},{-703,-323},{-704,-320},{-702,-320},{-705,-316},{-705,-312},{-703,-310},{-702,-303},{-700,-304},{-698,-302}}}, - {"Asia/Almaty",158,{{709,423},{706,420},{704,421},{700,418},{692,414},{686,409},{680,412},{666,413},{665,419},{660,419},{660,424},{678,432},{677,434},{681,440},{675,444},{675,452},{672,453},{674,458},{672,461},{656,462},{651,465},{631,471},{627,470},{643,479},{640,482},{643,483},{642,485},{646,485},{644,487},{647,487},{648,489},{655,488},{661,490},{676,502},{681,504},{677,508},{680,510},{678,515},{680,520},{677,522},{678,523},{675,524},{673,524},{673,522},{665,523},{666,524},{660,524},{661,528},{664,530},{661,530},{664,532},{663,532},{663,535},{661,535},{662,538},{660,540},{664,541},{661,542},{662,543},{661,546},{681,549},{683,551},{682,552},{687,552},{688,554},{690,553},{690,555},{702,551},{708,553},{710,551},{709,549},{713,547},{712,544},{710,543},{711,541},{717,541},{718,542},{722,541},{721,544},{725,541},{724,541},{725,539},{727,539},{725,540},{726,541},{733,540},{738,541},{737,539},{735,539},{733,537},{734,534},{739,536},{744,535},{745,537},{750,538},{755,540},{754,541},{769,545},{767,542},{764,541},{779,533},{801,508},{805,510},{804,512},{807,513},{811,512},{811,509},{814,510},{815,508},{825,507},{827,509},{834,510},{840,508},{843,502},{850,501},{853,496},{862,495},{868,498},{866,496},{870,493},{873,492},{873,491},{867,490},{868,488},{866,485},{857,484},{855,479},{857,472},{855,471},{848,468},{847,470},{840,470},{830,472},{823,456},{826,454},{825,451},{820,452},{817,454},{798,449},{805,447},{803,445},{808,432},{804,430},{806,429},{803,428},{802,422},{799,424},{795,425},{792,428},{785,429},{759,430},{757,428},{752,428},{743,432},{736,430},{735,424},{719,428},{713,428}}}, - {"Europe/Sarajevo",23,{{158,450},{158,452},{163,450},{165,452},{169,452},{178,450},{187,451},{188,449},{194,449},{191,444},{196,441},{192,440},{195,436},{189,435},{191,433},{187,433},{185,426},{176,429},{177,430},{172,435},{162,442},{161,445},{158,448}}}, - {"America/Boa_Vista",46,{{-600,51},{-602,45},{-597,44},{-597,42},{-595,39},{-599,36},{-600,27},{-597,23},{-597,18},{-590,13},{-589,2},{-601,2},{-604,-5},{-603,-7},{-607,-9},{-609,-6},{-612,-5},{-615,-7},{-616,-14},{-619,-14},{-625,-8},{-623,-6},{-626,0},{-624,8},{-628,16},{-627,19},{-633,22},{-634,24},{-640,25},{-642,36},{-648,43},{-646,42},{-641,42},{-640,39},{-635,39},{-634,40},{-629,36},{-627,37},{-628,40},{-625,42},{-619,41},{-613,45},{-610,45},{-606,50},{-607,52},{-602,53}}}, - {"Africa/Addis_Ababa",55,{{450,50},{435,48},{431,46},{428,43},{421,42},{418,39},{412,39},{408,43},{399,39},{395,34},{385,37},{381,36},{370,44},{360,45},{358,48},{359,53},{353,53},{350,59},{349,66},{342,70},{339,75},{330,78},{330,79},{332,84},{338,84},{341,86},{341,96},{343,102},{343,106},{346,109},{348,107},{350,109},{351,117},{357,127},{362,127},{366,143},{370,143},{373,144},{376,141},{379,149},{385,144},{391,146},{393,144},{396,146},{408,142},{424,125},{418,117},{418,110},{426,111},{430,110},{427,106},{435,94},{440,90},{470,80},{480,80}}}, - {"Indian/Mayotte",7,{{452,-128},{453,-128},{451,-127},{452,-130},{451,-130},{450,-126},{450,-127}}}, - {"Africa/Lubumbashi",120,{{294,-50},{297,-64},{302,-70},{308,-82},{289,-85},{289,-88},{284,-93},{285,-94},{287,-98},{286,-102},{287,-107},{284,-116},{284,-118},{290,-124},{295,-125},{295,-122},{298,-122},{298,-135},{296,-134},{296,-132},{290,-134},{284,-125},{279,-122},{276,-123},{272,-116},{270,-116},{269,-120},{260,-119},{253,-116},{254,-112},{244,-115},{243,-114},{244,-111},{241,-109},{231,-111},{226,-110},{223,-112},{222,-109},{223,-108},{223,-104},{222,-99},{218,-94},{220,-85},{217,-79},{218,-73},{205,-73},{206,-69},{200,-70},{197,-62},{202,-57},{200,-43},{203,-44},{207,-42},{207,-33},{210,-25},{214,-25},{215,-23},{218,-25},{221,-23},{223,-25},{222,-19},{225,-20},{226,-18},{232,-21},{237,-20},{238,-18},{244,-18},{243,-14},{239,-13},{234,-8},{236,-6},{235,-4},{230,-4},{234,-2},{230,4},{226,14},{223,15},{226,21},{228,20},{230,22},{237,22},{234,25},{230,26},{231,31},{228,30},{228,33},{226,33},{232,37},{234,36},{235,38},{229,39},{225,41},{229,48},{234,46},{244,51},{247,49},{251,49},{255,54},{265,50},{271,52},{284,43},{288,46},{292,43},{295,47},{296,46},{302,39},{305,39},{306,36},{308,37},{309,35},{307,25},{313,21},{300,8},{300,5},{297,1},{296,-14},{293,-16},{292,-21},{289,-24},{292,-31}}}, - {"Atlantic/Cape_Verde",43,{{-247,148},{-248,149},{-247,149},{-245,150},{-243,150},{-243,148},{-245,149},{-247,150},{-246,150},{-237,150},{-238,151},{-238,153},{-234,150},{-232,153},{-231,152},{-232,151},{-233,152},{-228,162},{-227,161},{-229,160},{-229,162},{-247,167},{-247,166},{-229,169},{-229,167},{-229,166},{-230,168},{-243,166},{-241,166},{-240,166},{-243,165},{-244,166},{-246,166},{-250,169},{-249,169},{-249,168},{-251,168},{-250,171},{-252,169},{-253,169},{-253,171},{-248,168},{-247,168}}}, - {"America/Lower_Princes",3,{{-631,181},{-630,181},{-630,180}}}, - {"Europe/Oslo",1433,{{47,607},{48,607},{76,580},{74,580},{73,580},{77,580},{70,580},{75,580},{72,580},{70,581},{69,581},{80,581},{82,581},{83,582},{85,582},{84,583},{84,582},{67,582},{66,582},{65,582},{91,586},{93,587},{59,584},{59,585},{60,585},{60,584},{90,586},{89,585},{88,584},{88,585},{87,584},{49,593},{51,594},{52,594},{51,596},{52,596},{51,597},{51,598},{52,597},{52,598},{54,591},{111,591},{52,593},{53,591},{52,591},{54,592},{54,593},{55,592},{55,593},{96,589},{97,589},{55,589},{58,590},{58,589},{95,589},{94,589},{96,588},{95,588},{110,590},{111,590},{109,590},{109,591},{98,590},{97,590},{101,590},{57,590},{60,589},{60,590},{59,590},{110,591},{97,591},{58,591},{56,590},{56,591},{57,591},{105,591},{108,591},{52,608},{59,591},{104,591},{105,592},{104,592},{59,592},{103,591},{103,592},{60,592},{58,592},{108,592},{106,592},{61,592},{107,592},{60,593},{61,593},{58,593},{59,593},{107,593},{57,593},{108,593},{56,594},{57,594},{56,593},{105,594},{60,595},{61,595},{104,595},{103,595},{106,597},{105,597},{57,597},{53,597},{54,597},{56,597},{57,598},{52,616},{51,616},{48,616},{121,665},{58,598},{47,613},{50,612},{50,613},{49,613},{48,613},{48,614},{49,614},{53,614},{54,614},{50,614},{51,613},{51,614},{50,615},{49,615},{51,615},{52,615},{47,616},{49,616},{53,616},{50,616},{48,617},{49,617},{53,618},{52,619},{51,619},{50,620},{52,620},{53,620},{53,619},{50,619},{52,618},{49,618},{48,618},{50,618},{48,619},{49,619},{53,621},{48,606},{47,608},{47,612},{48,612},{48,611},{49,612},{51,612},{47,611},{47,610},{51,611},{50,611},{64,628},{64,627},{63,627},{65,628},{66,628},{68,629},{69,629},{70,629},{78,630},{79,630},{74,631},{74,630},{75,631},{71,628},{72,628},{84,629},{67,628},{68,628},{72,627},{71,627},{67,627},{73,627},{74,627},{65,627},{69,628},{77,631},{77,630},{79,631},{76,631},{80,631},{78,631},{79,632},{80,632},{82,632},{82,633},{85,631},{86,631},{81,632},{83,635},{82,635},{81,635},{80,633},{81,633},{79,633},{79,634},{78,634},{82,634},{54,622},{53,622},{55,622},{62,626},{61,626},{62,625},{61,625},{60,625},{59,622},{59,623},{63,626},{62,627},{57,622},{56,622},{55,623},{58,623},{54,623},{57,623},{56,623},{58,624},{59,624},{61,624},{57,624},{56,624},{55,624},{59,625},{66,626},{65,626},{63,624},{64,624},{67,625},{65,624},{63,625},{64,625},{66,625},{65,625},{73,626},{69,627},{66,627},{49,604},{49,605},{48,605},{49,606},{52,602},{52,603},{50,603},{51,604},{50,604},{49,603},{51,603},{50,605},{52,605},{53,604},{53,605},{52,606},{108,599},{106,599},{105,599},{51,599},{52,599},{56,599},{53,599},{57,599},{59,600},{60,600},{58,599},{52,600},{51,600},{50,600},{53,600},{55,600},{56,601},{57,600},{54,600},{54,601},{52,601},{53,601},{51,601},{60,601},{59,601},{61,602},{61,601},{53,602},{50,601},{54,602},{51,602},{50,602},{51,607},{48,609},{48,610},{49,610},{49,609},{56,598},{55,599},{55,598},{54,598},{55,605},{56,607},{57,607},{57,605},{50,606},{51,606},{49,607},{50,607},{53,608},{48,608},{50,608},{50,609},{50,610},{49,611},{51,610},{49,608},{86,637},{86,638},{84,637},{87,639},{86,639},{91,640},{89,637},{89,638},{88,638},{91,637},{90,637},{87,638},{114,644},{113,644},{113,645},{112,645},{107,645},{108,645},{107,646},{115,646},{108,646},{109,645},{109,646},{129,665},{111,637},{110,637},{111,638},{112,638},{99,639},{100,639},{98,639},{97,639},{94,638},{95,638},{92,640},{100,641},{99,640},{98,640},{99,641},{100,640},{102,642},{100,642},{101,642},{103,642},{102,643},{103,643},{104,643},{104,644},{129,666},{114,647},{113,646},{112,647},{113,647},{111,647},{112,648},{118,648},{117,648},{116,648},{113,648},{115,648},{114,649},{107,649},{108,649},{115,650},{111,650},{110,650},{109,650},{114,650},{108,650},{110,648},{112,649},{113,649},{108,648},{107,648},{110,649},{111,649},{131,666},{130,666},{117,651},{117,650},{116,650},{118,657},{117,657},{131,668},{132,667},{131,667},{129,667},{130,667},{134,668},{135,668},{132,668},{133,668},{136,668},{134,669},{133,669},{132,669},{130,665},{120,665},{128,665},{127,666},{128,666},{126,666},{137,669},{136,669},{135,669},{129,670},{128,670},{136,670},{136,671},{138,671},{139,671},{147,672},{146,672},{142,670},{140,671},{143,672},{140,672},{138,672},{142,672},{140,670},{139,670},{137,671},{187,700},{186,700},{139,673},{140,673},{144,673},{143,673},{125,657},{124,657},{123,657},{121,658},{121,657},{120,657},{121,656},{122,656},{119,656},{118,656},{119,657},{120,658},{123,658},{122,658},{125,658},{124,658},{121,659},{123,660},{122,660},{124,660},{122,659},{123,659},{126,659},{126,658},{126,664},{125,664},{125,659},{124,659},{121,661},{120,661},{123,661},{127,661},{127,662},{128,662},{128,661},{123,663},{123,662},{122,663},{125,661},{124,661},{124,662},{126,663},{124,664},{123,664},{125,663},{131,664},{130,664},{129,664},{128,664},{130,662},{129,662},{129,663},{132,663},{130,663},{121,660},{128,660},{129,660},{125,660},{126,661},{126,660},{120,660},{126,662},{124,652},{123,652},{123,653},{122,654},{120,655},{120,654},{121,654},{121,655},{122,655},{123,655},{125,651},{124,651},{123,651},{116,651},{118,651},{115,651},{143,686},{174,691},{174,692},{171,695},{171,694},{178,696},{179,696},{180,696},{178,689},{177,689},{174,690},{176,691},{175,690},{165,690},{165,691},{188,695},{187,695},{188,696},{189,696},{188,697},{182,697},{181,696},{181,697},{183,697},{182,698},{181,698},{204,697},{203,697},{190,697},{189,697},{184,698},{158,686},{171,688},{172,688},{168,687},{170,689},{167,687},{166,687},{162,688},{161,688},{148,688},{147,688},{149,688},{148,689},{150,689},{149,689},{153,689},{160,689},{160,688},{169,690},{166,690},{164,690},{172,689},{174,689},{175,689},{167,689},{167,690},{163,689},{163,690},{166,689},{165,689},{157,690},{154,689},{158,693},{162,693},{298,699},{220,698},{186,698},{185,699},{188,700},{192,701},{197,700},{191,698},{187,699},{181,694},{179,693},{179,692},{168,691},{172,692},{169,692},{172,694},{169,694},{175,694},{173,695},{172,695},{174,695},{176,695},{177,695},{175,696},{176,696},{178,695},{180,695},{311,704},{253,711},{253,712},{254,711},{302,698},{301,698},{301,699},{300,699},{300,698},{297,698},{184,696},{186,697},{183,698},{187,697},{187,696},{207,699},{207,698},{205,698},{206,699},{186,699},{218,699},{217,699},{216,699},{185,700},{298,701},{198,700},{197,699},{194,698},{195,699},{207,700},{206,700},{200,700},{199,700},{189,702},{189,701},{188,702},{209,700},{211,700},{208,699},{185,701},{217,700},{215,700},{216,700},{210,700},{210,701},{213,700},{212,700},{213,701},{194,701},{193,701},{188,701},{198,703},{266,704},{279,707},{252,703},{214,703},{213,703},{214,704},{215,703},{288,701},{287,701},{251,702},{190,702},{233,701},{232,701},{202,702},{200,702},{199,702},{201,702},{187,701},{190,701},{214,701},{209,701},{208,701},{208,702},{196,701},{195,701},{194,702},{207,702},{204,701},{204,702},{200,701},{201,701},{197,701},{195,702},{191,702},{252,702},{250,702},{197,702},{197,703},{251,703},{203,703},{202,703},{254,703},{253,703},{229,703},{230,703},{223,703},{228,704},{217,704},{218,704},{217,703},{259,708},{258,708},{272,708},{231,708},{230,708},{231,709},{242,709},{237,709},{253,709},{245,709},{243,709},{260,711},{259,711},{240,711},{242,711},{241,710},{240,710},{239,711},{259,710},{258,710},{242,710},{240,709},{239,710},{244,709},{247,710},{246,710},{245,710},{250,710},{249,710},{250,711},{255,710},{257,711},{255,712},{257,712},{261,711},{262,710},{248,711},{248,710},{246,711},{247,711},{253,705},{235,707},{234,707},{268,705},{267,705},{252,705},{251,705},{269,705},{270,706},{269,706},{234,706},{233,706},{237,705},{236,706},{237,707},{241,706},{147,676},{146,676},{148,676},{132,680},{235,704},{232,703},{231,704},{236,705},{259,707},{258,707},{229,707},{229,708},{152,676},{151,676},{151,677},{150,676},{126,676},{127,677},{147,678},{146,678},{146,677},{128,678},{128,677},{148,679},{149,679},{150,679},{162,680},{161,681},{162,681},{130,679},{131,681},{155,680},{154,680},{233,708},{235,708},{227,705},{221,705},{223,706},{219,706},{225,707},{227,706},{228,707},{227,708},{230,707},{232,707},{145,674},{146,674},{144,674},{142,674},{139,674},{119,675},{120,675},{121,675},{140,674},{151,680},{153,679},{152,679},{153,680},{152,680},{159,680},{156,680},{157,680},{164,682},{163,682},{161,682},{160,682},{142,682},{148,682},{147,682},{138,683},{139,683},{153,683},{150,683},{149,682},{149,683},{158,682},{158,681},{157,681},{155,681},{163,681},{163,680},{162,683},{161,683},{160,683},{161,684},{150,684},{152,685},{151,685},{106,636},{84,636},{133,682},{135,682},{134,680},{143,683},{137,681},{135,681},{137,683},{170,685},{169,685},{150,686},{149,686},{147,685},{146,686},{147,686},{86,636},{85,636},{94,636},{93,636},{150,687},{152,687},{144,687},{145,688},{151,688},{151,690},{154,688},{153,688},{154,687},{148,686},{149,684},{148,684},{162,685},{165,685},{164,684},{159,684},{158,684},{164,686},{161,686},{159,685},{157,683},{153,684},{156,685},{155,685},{154,685},{152,686},{156,686},{155,687},{157,687},{155,688},{157,688},{155,689},{156,690},{158,687},{157,685},{163,687},{163,688},{166,688},{166,686},{84,635},{145,683},{144,684},{85,633},{85,632},{83,632},{84,632},{83,633},{86,632},{84,633},{86,633},{87,633},{94,635},{92,635},{92,636},{91,635},{87,636},{91,636},{90,636},{92,637},{90,634},{90,635},{83,634},{89,634},{89,635},{81,581},{82,583},{71,580},{71,581},{68,581},{69,582},{66,581},{69,583},{64,583},{55,587},{57,589},{62,588},{63,588},{61,590},{67,591},{63,590},{61,589},{66,593},{66,596},{63,595},{64,596},{63,597},{62,595},{60,594},{59,594},{59,595},{54,594},{52,595},{55,597},{55,595},{58,596},{64,599},{60,598},{63,601},{64,604},{67,604},{66,602},{65,601},{71,605},{62,605},{62,603},{60,603},{58,600},{58,602},{56,602},{58,604},{52,604},{54,604},{58,607},{55,606},{56,609},{51,608},{51,609},{53,610},{55,610},{60,611},{64,610},{66,612},{70,611},{70,610},{69,609},{68,609},{71,609},{75,611},{74,611},{77,612},{73,613},{76,615},{73,614},{73,612},{67,613},{67,614},{65,611},{61,612},{52,611},{53,612},{56,614},{52,614},{55,615},{54,616},{50,617},{52,617},{51,618},{54,619},{58,619},{57,618},{56,618},{60,618},{59,617},{62,618},{61,618},{65,618},{68,619},{64,618},{57,619},{59,619},{55,619},{54,620},{51,622},{55,620},{56,621},{54,621},{57,621},{59,620},{60,621},{61,621},{63,621},{66,621},{67,622},{70,623},{69,621},{72,621},{70,621},{74,623},{69,625},{71,625},{72,626},{76,625},{78,626},{76,626},{74,626},{81,627},{70,627},{73,630},{74,629},{80,630},{82,628},{85,627},{81,631},{83,629},{87,628},{86,630},{84,630},{85,630},{83,630},{82,631},{90,632},{92,634},{91,633},{95,634},{97,637},{100,634},{99,633},{103,633},{101,634},{102,635},{108,634},{109,636},{106,635},{107,636},{115,638},{111,639},{115,640},{112,640},{114,641},{113,641},{106,638},{110,639},{109,637},{101,635},{98,637},{101,638},{95,637},{102,639},{101,640},{107,644},{105,644},{108,644},{106,645},{110,646},{112,644},{112,643},{117,645},{114,645},{118,646},{114,646},{117,649},{122,650},{116,649},{114,648},{122,652},{121,651},{130,653},{124,653},{124,654},{120,652},{123,656},{125,654},{128,655},{124,656},{126,657},{126,656},{128,656},{127,658},{127,659},{132,658},{130,661},{135,662},{136,661},{138,661},{136,662},{138,662},{142,663},{136,663},{132,665},{133,664},{137,666},{132,666},{134,666},{136,667},{140,668},{135,670},{145,672},{155,671},{154,673},{150,673},{152,673},{151,675},{146,675},{149,675},{154,675},{156,674},{157,673},{158,674},{155,675},{159,676},{153,675},{155,676},{153,677},{156,678},{158,677},{159,677},{154,679},{152,677},{148,677},{152,678},{148,678},{159,679},{160,680},{153,681},{156,682},{156,681},{162,679},{165,678},{165,679},{167,681},{166,682},{168,682},{163,684},{172,684},{173,682},{173,684},{179,684},{175,685},{175,686},{170,687},{177,687},{178,687},{175,688},{179,689},{182,692},{180,692},{182,695},{184,695},{185,692},{186,694},{190,693},{184,694},{190,694},{193,693},{192,692},{196,692},{194,694},{190,695},{192,695},{191,697},{197,698},{197,695},{195,694},{197,694},{197,696},{200,696},{201,696},{198,697},{203,700},{204,696},{199,693},{206,695},{209,695},{205,696},{211,698},{213,699},{214,700},{220,697},{221,697},{219,698},{220,699},{219,700},{221,700},{218,700},{220,701},{221,701},{217,701},{212,702},{215,702},{218,701},{218,703},{219,703},{222,701},{226,701},{223,702},{224,703},{230,702},{228,701},{224,701},{223,700},{229,701},{230,701},{231,700},{231,699},{230,699},{235,700},{231,701},{234,701},{232,702},{235,702},{233,703},{239,705},{243,705},{241,705},{243,707},{247,706},{242,708},{246,708},{252,708},{254,709},{253,710},{256,709},{254,708},{259,709},{250,705},{249,702},{250,700},{266,710},{267,709},{267,708},{263,707},{266,707},{265,704},{271,705},{273,706},{271,707},{277,708},{271,709},{273,709},{273,710},{276,710},{275,711},{276,711},{285,710},{282,708},{278,708},{281,707},{276,706},{283,707},{278,705},{279,704},{285,705},{284,705},{286,707},{285,707},{290,709},{294,708},{292,707},{301,707},{303,706},{300,705},{306,705},{302,701},{287,702},{286,702},{297,700},{294,699},{297,699},{295,697},{301,697},{302,699},{304,698},{303,697},{305,698},{309,697},{308,695},{301,695},{293,693},{290,690},{288,691},{293,695},{291,697},{284,698},{280,701},{276,701},{265,699},{259,697},{257,693},{258,690},{251,688},{249,686},{240,688},{232,686},{224,687},{216,693},{213,693},{210,692},{211,690},{201,691},{203,688},{200,686},{203,685},{200,684},{184,686},{181,685},{182,682},{179,680},{173,681},{167,679},{165,676},{161,674},{164,672},{164,670},{154,665},{155,663},{145,661},{146,658},{145,653},{136,646},{141,645},{141,642},{140,640},{129,641},{121,636},{122,635},{120,633},{122,630},{121,626},{123,623},{121,617},{129,614},{127,611},{122,610},{126,604},{124,600},{119,598},{119,597},{117,596},{118,592},{117,589},{115,589},{112,592},{106,598},{107,599},{107,597},{106,595},{104,597},{103,598},{102,597},{105,593},{98,591},{95,591},{93,589},{91,588},{92,587},{83,637},{88,636},{88,637},{87,637},{85,637},{95,636},{96,637},{93,637},{94,637}}}, - {"Africa/Monrovia",25,{{-76,48},{-75,44},{-84,47},{-93,51},{-100,59},{-114,67},{-115,69},{-106,78},{-106,80},{-103,82},{-103,85},{-98,86},{-95,84},{-93,77},{-95,74},{-92,74},{-91,72},{-88,73},{-86,77},{-83,70},{-86,65},{-79,63},{-78,60},{-74,58},{-74,53}}}, - {"Asia/Muscat",64,{{561,176},{556,175},{558,175},{559,175},{563,175},{564,175},{560,175},{561,175},{587,235},{563,263},{563,264},{564,264},{561,261},{562,263},{562,262},{563,262},{564,262},{565,264},{562,256},{586,202},{586,203},{589,207},{590,205},{588,205},{587,204},{587,205},{582,206},{587,207},{583,205},{583,206},{564,180},{554,178},{552,175},{553,172},{550,170},{541,170},{531,167},{520,190},{550,200},{557,220},{552,227},{552,230},{556,238},{555,240},{560,241},{558,242},{558,249},{560,250},{561,247},{564,250},{566,245},{572,239},{588,235},{593,228},{598,224},{593,214},{589,211},{585,204},{582,204},{578,202},{577,197},{578,190},{568,188},{587,208}}}, - {"America/Thunder_Bay",6,{{-891,484},{-892,484},{-892,483},{-892,485},{-894,483},{-894,485}}}, - {"America/Juneau",192,{{-1359,585},{-1359,586},{-1360,585},{-1338,585},{-1361,585},{-1349,586},{-1350,585},{-1349,585},{-1358,585},{-1376,586},{-1362,586},{-1362,587},{-1360,587},{-1361,588},{-1362,588},{-1361,586},{-1359,589},{-1358,589},{-1368,589},{-1369,589},{-1365,589},{-1366,589},{-1353,590},{-1353,589},{-1365,588},{-1364,588},{-1366,588},{-1334,577},{-1335,577},{-1338,574},{-1346,575},{-1336,575},{-1345,575},{-1343,572},{-1342,572},{-1335,572},{-1340,573},{-1341,573},{-1335,573},{-1337,573},{-1337,574},{-1338,573},{-1364,578},{-1363,580},{-1360,578},{-1363,578},{-1366,579},{-1365,581},{-1364,582},{-1354,583},{-1355,583},{-1365,583},{-1364,583},{-1361,583},{-1360,583},{-1363,582},{-1351,582},{-1350,582},{-1360,582},{-1363,583},{-1349,584},{-1347,582},{-1342,582},{-1338,576},{-1343,581},{-1343,578},{-1339,576},{-1339,575},{-1341,575},{-1339,574},{-1342,574},{-1341,572},{-1346,570},{-1346,572},{-1344,573},{-1346,574},{-1343,573},{-1344,575},{-1343,576},{-1347,576},{-1336,578},{-1335,580},{-1336,580},{-1335,581},{-1341,581},{-1340,578},{-1342,578},{-1342,579},{-1341,578},{-1341,579},{-1343,580},{-1346,583},{-1347,583},{-1350,580},{-1349,578},{-1350,579},{-1352,579},{-1351,578},{-1359,580},{-1364,581},{-1363,581},{-1362,581},{-1361,581},{-1362,582},{-1358,583},{-1355,582},{-1358,580},{-1354,581},{-1343,582},{-1346,582},{-1345,583},{-1356,583},{-1357,583},{-1357,584},{-1347,584},{-1348,584},{-1375,589},{-1368,592},{-1366,592},{-1365,595},{-1362,595},{-1363,596},{-1355,598},{-1350,596},{-1350,593},{-1334,584},{-1324,573},{-1327,574},{-1331,572},{-1336,572},{-1330,574},{-1334,574},{-1333,574},{-1335,574},{-1334,576},{-1336,577},{-1331,575},{-1329,575},{-1332,576},{-1331,577},{-1336,579},{-1331,579},{-1337,578},{-1338,579},{-1337,579},{-1334,581},{-1337,580},{-1337,581},{-1339,580},{-1340,581},{-1340,584},{-1337,585},{-1341,584},{-1341,582},{-1350,587},{-1349,587},{-1349,590},{-1353,592},{-1351,592},{-1353,595},{-1354,593},{-1357,595},{-1357,594},{-1353,591},{-1355,592},{-1356,593},{-1351,586},{-1350,583},{-1355,585},{-1355,584},{-1359,584},{-1358,586},{-1360,589},{-1362,591},{-1365,590},{-1367,590},{-1367,589},{-1371,591},{-1370,589},{-1371,588},{-1363,587},{-1365,586},{-1360,584},{-1362,583},{-1365,585},{-1366,584},{-1366,583},{-1366,582},{-1369,583},{-1368,584},{-1371,584},{-1379,588}}}, - {"Pacific/Rarotonga",32,{{-1630,-135},{-1632,-134},{-1631,-134},{-1654,-116},{-1658,-109},{-1658,-110},{-1659,-109},{-1579,-219},{-1580,-219},{-1598,-212},{-1597,-212},{-1597,-213},{-1573,-202},{-1573,-201},{-1581,-200},{-1583,-198},{-1577,-198},{-1577,-199},{-1589,-193},{-1589,-192},{-1597,-189},{-1598,-189},{-1598,-188},{-1610,-104},{-1609,-104},{-1611,-100},{-1579,-91},{-1579,-90},{-1580,-91},{-1581,-90},{-1580,-90},{-1580,-89}}}, - {"Atlantic/Faroe",42,{{-69,615},{-70,616},{-67,614},{-67,616},{-68,617},{-67,617},{-75,621},{-76,621},{-77,621},{-74,621},{-68,618},{-69,618},{-69,619},{-66,618},{-67,618},{-63,623},{-63,624},{-64,622},{-64,623},{-63,622},{-65,623},{-66,622},{-68,624},{-67,622},{-66,623},{-67,623},{-67,624},{-66,624},{-69,620},{-66,620},{-67,620},{-70,620},{-72,620},{-71,621},{-68,620},{-73,622},{-72,623},{-71,623},{-69,622},{-68,623},{-66,621},{-67,621}}}, - {"America/Cayenne",25,{{-519,48},{-522,49},{-535,56},{-529,54},{-519,45},{-519,47},{-518,46},{-516,42},{-523,31},{-526,25},{-529,22},{-538,24},{-541,21},{-543,22},{-545,23},{-542,28},{-542,31},{-540,36},{-544,40},{-545,49},{-539,57},{-523,50},{-522,50},{-524,50},{-527,52}}}, - {"America/Cuiaba",56,{{-514,-150},{-516,-152},{-519,-158},{-522,-159},{-527,-167},{-530,-169},{-532,-175},{-531,-180},{-540,-179},{-537,-173},{-541,-176},{-544,-177},{-546,-175},{-552,-177},{-561,-172},{-568,-173},{-571,-178},{-575,-180},{-578,-175},{-580,-175},{-584,-172},{-585,-167},{-583,-163},{-602,-163},{-602,-155},{-606,-151},{-603,-151},{-603,-146},{-605,-142},{-604,-140},{-608,-137},{-604,-134},{-598,-124},{-601,-118},{-599,-114},{-600,-111},{-604,-110},{-615,-110},{-615,-96},{-616,-93},{-615,-89},{-616,-88},{-585,-87},{-583,-81},{-584,-78},{-581,-73},{-576,-82},{-576,-88},{-568,-94},{-502,-98},{-506,-107},{-507,-115},{-507,-126},{-505,-129},{-509,-137},{-511,-149}}}, - {"Africa/Maputo",175,{{330,-261},{329,-260},{330,-260},{327,-259},{327,-258},{355,-222},{355,-221},{354,-220},{355,-218},{355,-219},{408,-149},{408,-148},{354,-219},{354,-239},{354,-238},{347,-197},{346,-197},{357,-191},{347,-198},{348,-197},{360,-189},{361,-189},{350,-208},{350,-207},{347,-205},{347,-206},{349,-207},{349,-206},{346,-205},{348,-199},{348,-198},{355,-217},{353,-216},{354,-217},{355,-215},{369,-180},{391,-171},{391,-170},{391,-169},{406,-154},{407,-151},{407,-150},{408,-145},{406,-126},{406,-125},{405,-123},{406,-122},{406,-123},{406,-124},{405,-124},{406,-120},{406,-118},{406,-114},{407,-112},{407,-110},{406,-110},{406,-109},{407,-109},{407,-108},{406,-108},{406,-112},{399,-163},{400,-163},{399,-164},{398,-163},{364,-187},{365,-186},{368,-182},{363,-189},{362,-188},{331,-254},{328,-256},{328,-259},{327,-257},{326,-260},{325,-259},{324,-260},{327,-261},{327,-263},{327,-264},{327,-262},{329,-263},{329,-269},{321,-268},{321,-260},{319,-258},{320,-243},{316,-235},{313,-224},{325,-213},{324,-211},{325,-206},{330,-200},{331,-198},{328,-195},{329,-191},{327,-189},{329,-188},{329,-185},{331,-184},{329,-180},{330,-173},{328,-169},{330,-167},{319,-164},{312,-160},{304,-160},{302,-150},{332,-140},{337,-146},{344,-144},{345,-146},{346,-153},{343,-159},{344,-163},{352,-168},{351,-171},{353,-171},{351,-166},{354,-161},{358,-160},{358,-152},{359,-149},{351,-137},{345,-134},{344,-123},{346,-116},{355,-116},{358,-114},{362,-117},{370,-116},{375,-117},{378,-116},{379,-113},{385,-114},{389,-112},{392,-112},{405,-105},{406,-107},{405,-108},{404,-113},{405,-120},{404,-126},{406,-128},{404,-130},{406,-130},{405,-135},{406,-136},{405,-142},{407,-143},{406,-146},{406,-149},{408,-150},{405,-152},{406,-152},{407,-153},{400,-162},{387,-170},{382,-173},{381,-172},{381,-173},{359,-190},{349,-199},{351,-210},{350,-211},{351,-213},{351,-212},{353,-222},{355,-223},{356,-229},{353,-237},{353,-240},{355,-238},{355,-241},{351,-246}}}, - {"Asia/Anadyr",262,{{-1741,670},{-1742,670},{-1728,670},{-1728,671},{-1691,657},{-1691,658},{-1690,658},{-1777,654},{-1784,654},{-1786,654},{-1787,655},{-1725,646},{-1727,646},{-1725,647},{-1725,648},{-1723,648},{-1721,648},{-1726,647},{-1726,649},{-1725,649},{-1722,655},{-1774,655},{-1772,655},{-1773,655},{-1747,670},{-1747,671},{-1743,664},{-1744,664},{-1744,665},{-1730,670},{-1717,670},{-1713,666},{-1697,661},{-1706,659},{-1705,658},{-1706,656},{-1715,658},{-1710,656},{-1711,655},{-1721,655},{-1717,655},{-1722,656},{-1723,657},{-1727,657},{-1729,657},{-1724,656},{-1723,654},{-1722,653},{-1721,651},{-1732,648},{-1729,648},{-1727,648},{-1731,647},{-1728,647},{-1730,646},{-1722,644},{-1730,645},{-1728,644},{-1728,643},{-1731,642},{-1734,643},{-1732,644},{-1733,646},{-1733,644},{-1736,643},{-1742,647},{-1754,648},{-1759,650},{-1757,651},{-1760,655},{-1769,656},{-1775,655},{-1785,655},{-1784,657},{-1789,659},{-1789,660},{-1785,661},{-1785,664},{-1788,662},{-1791,662},{-1790,664},{-1794,663},{-1792,662},{-1793,661},{-1797,662},{-1798,659},{-1793,655},{-1797,651},{-1800,650},{-1800,690},{-1753,677},{-1753,676},{-1748,674},{-1747,672},{-1749,673},{-1749,671},{-1747,667},{-1750,667},{-1744,663},{-1740,665},{-1739,663},{-1740,663},{-1738,663},{-1737,664},{-1743,665},{-1739,667},{-1740,670},{-1746,671},{-1748,672},{-1748,673},{-1747,673},{-1746,674},{-1746,675},{-1756,714},{-1758,714},{-1755,714},{1800,715},{1800,710},{1787,708},{1786,710},{1797,715},{1798,715},{-1791,716},{-1793,716},{-1794,716},{-1800,715},{-1785,716},{-1775,712},{-1779,710},{-1796,709},{-1800,710},{-1783,715},{-1786,716},{-1788,716},{-1787,716},{-1795,716},{-1796,716},{-1789,716},{-1792,716},{1775,649},{1771,647},{1761,649},{1758,648},{1752,647},{1757,647},{1762,649},{1765,647},{1762,646},{1766,647},{1768,645},{1775,647},{1775,644},{1779,642},{1783,642},{1781,642},{1783,643},{1782,644},{1787,640},{1789,634},{1795,631},{1793,630},{1796,628},{1796,626},{1791,625},{1791,623},{1781,625},{1770,625},{1745,618},{1743,621},{1741,621},{1741,624},{1737,625},{1728,623},{1720,625},{1703,623},{1700,625},{1701,627},{1684,631},{1696,637},{1694,640},{1689,640},{1685,643},{1677,643},{1672,646},{1659,646},{1657,647},{1653,649},{1649,647},{1642,649},{1635,649},{1630,647},{1628,647},{1618,648},{1613,651},{1605,652},{1600,655},{1589,657},{1592,662},{1584,664},{1589,668},{1588,670},{1579,673},{1579,674},{1577,675},{1578,677},{1583,677},{1581,679},{1585,681},{1614,684},{1624,683},{1627,686},{1626,688},{1628,689},{1625,690},{1625,691},{1628,692},{1623,695},{1626,697},{1640,697},{1646,696},{1670,695},{1678,698},{1683,695},{1683,692},{1693,691},{1695,688},{1697,688},{1711,691},{1707,696},{1702,696},{1706,698},{1706,701},{1731,698},{1735,699},{1738,698},{1761,699},{1788,694},{1800,690},{1800,650},{1795,648},{1786,646},{1788,646},{1776,647},{1774,648},{1682,696},{1683,696},{1701,697},{1702,697},{1700,697},{1702,698},{1703,698},{1693,699},{1692,699},{1691,699},{1681,696},{1681,697},{1687,700},{1685,700},{1694,699},{1695,698},{1692,696},{1686,700}}}, - {"Asia/Kabul",83,{{632,295},{625,294},{609,299},{618,310},{617,314},{609,315},{609,322},{606,331},{609,335},{606,336},{605,341},{607,343},{609,343},{607,345},{610,346},{613,356},{616,354},{621,354},{623,351},{627,353},{631,354},{632,357},{631,359},{641,360},{644,362},{648,371},{655,372},{658,375},{663,373},{670,374},{673,372},{678,372},{680,369},{689,373},{693,371},{695,372},{694,374},{695,376},{702,375},{703,377},{702,379},{707,384},{710,385},{714,383},{712,379},{716,379},{714,371},{717,367},{727,370},{733,375},{738,374},{736,373},{737,372},{742,374},{749,373},{745,372},{746,370},{741,368},{722,368},{712,361},{715,357},{717,352},{710,346},{712,344},{711,341},{699,340},{703,333},{695,330},{695,327},{692,325},{693,319},{690,316},{682,318},{676,315},{678,313},{667,312},{664,309},{662,301},{664,300},{662,299},{651,295},{644,295},{641,294}}}, - {"America/Santa_Isabel",51,{{-1145,301},{-1145,300},{-1161,305},{-1131,291},{-1136,296},{-1144,298},{-1144,299},{-1144,300},{-1135,290},{-1135,291},{-1132,293},{-1131,290},{-1135,293},{-1154,281},{-1156,283},{-1129,287},{-1128,287},{-1128,286},{-1130,287},{-1152,280},{-1153,284},{-1152,282},{-1155,283},{-1130,288},{-1184,289},{-1130,289},{-1184,292},{-1183,290},{-1183,289},{-1184,291},{-1148,325},{-1150,320},{-1148,317},{-1149,312},{-1147,309},{-1147,302},{-1136,293},{-1135,289},{-1134,289},{-1131,285},{-1128,284},{-1128,280},{-1142,280},{-1141,285},{-1150,294},{-1157,298},{-1161,308},{-1163,310},{-1164,312},{-1167,315},{-1164,324}}}, - {"Asia/Damascus",37,{{375,327},{368,323},{361,325},{359,327},{356,327},{356,333},{361,336},{359,336},{361,338},{364,338},{363,339},{366,342},{366,344},{363,345},{365,346},{360,346},{360,353},{357,356},{358,359},{360,359},{362,358},{364,362},{367,362},{366,365},{367,368},{371,366},{383,369},{392,367},{408,371},{423,372},{424,371},{419,366},{414,365},{413,364},{414,356},{412,348},{410,344}}}, - {"Pacific/Noumea",91,{{1661,-221},{1675,-227},{1675,-226},{1721,-224},{1674,-227},{1689,-226},{1690,-226},{1676,-227},{1674,-225},{1713,-224},{1713,-223},{1676,-212},{1676,-211},{1678,-211},{1648,-212},{1647,-211},{1673,-211},{1670,-209},{1672,-208},{1670,-207},{1673,-207},{1673,-209},{1675,-211},{1645,-209},{1679,-216},{1678,-216},{1678,-214},{1681,-214},{1681,-216},{1650,-214},{1676,-213},{1677,-214},{1677,-213},{1660,-221},{1660,-220},{1659,-220},{1661,-219},{1661,-220},{1658,-218},{1657,-218},{1664,-217},{1668,-225},{1668,-224},{1666,-223},{1665,-223},{1664,-223},{1664,-222},{1663,-222},{1639,-202},{1639,-201},{1640,-201},{1639,-200},{1583,-199},{1637,-198},{1636,-197},{1636,-196},{1637,-197},{1582,-196},{1636,-195},{1583,-196},{1638,-200},{1638,-201},{1582,-195},{1583,-195},{1599,-193},{1599,-192},{1599,-191},{1600,-192},{1590,-192},{1586,-191},{1665,-207},{1664,-207},{1650,-213},{1644,-208},{1652,-208},{1656,-213},{1669,-221},{1670,-223},{1666,-204},{1667,-205},{1665,-204},{1661,-204},{1662,-204},{1641,-203},{1643,-203},{1642,-203},{1643,-202},{1640,-202},{1642,-201},{1642,-202},{1640,-200}}}, - {"America/Anchorage",828,{{-1463,702},{-1464,702},{-1595,551},{-1457,606},{-1458,606},{-1482,606},{-1481,606},{-1595,548},{-1596,548},{-1598,548},{-1597,548},{-1593,549},{-1592,549},{-1602,550},{-1619,550},{-1600,549},{-1601,549},{-1600,550},{-1593,550},{-1595,549},{-1595,550},{-1593,551},{-1594,551},{-1620,552},{-1620,551},{-1619,551},{-1598,550},{-1599,550},{-1598,551},{-1597,551},{-1616,551},{-1615,551},{-1617,551},{-1618,551},{-1619,552},{-1618,552},{-1596,552},{-1597,552},{-1503,611},{-1502,612},{-1502,611},{-1470,610},{-1471,610},{-1613,641},{-1610,662},{-1618,662},{-1617,670},{-1468,609},{-1471,609},{-1449,604},{-1449,605},{-1450,604},{-1483,605},{-1481,607},{-1483,607},{-1482,608},{-1479,608},{-1478,608},{-1467,608},{-1468,608},{-1477,608},{-1478,607},{-1477,607},{-1474,607},{-1475,606},{-1475,607},{-1473,607},{-1474,606},{-1467,607},{-1479,607},{-1480,607},{-1474,605},{-1473,605},{-1476,605},{-1461,702},{-1460,702},{-1459,702},{-1476,606},{-1459,604},{-1460,604},{-1457,604},{-1456,604},{-1460,605},{-1480,605},{-1479,605},{-1477,605},{-1460,606},{-1461,605},{-1463,605},{-1467,609},{-1481,608},{-1481,609},{-1479,609},{-1469,608},{-1476,609},{-1474,609},{-1475,609},{-1473,702},{-1472,702},{-1462,702},{-1472,609},{-1473,609},{-1416,698},{-1414,697},{-1419,698},{-1420,698},{-1421,699},{-1423,699},{-1421,698},{-1422,698},{-1444,700},{-1443,700},{-1442,701},{-1455,701},{-1430,701},{-1429,701},{-1431,701},{-1443,701},{-1441,701},{-1432,701},{-1459,701},{-1433,701},{-1433,702},{-1432,702},{-1434,701},{-1435,701},{-1436,701},{-1436,702},{-1439,701},{-1440,701},{-1438,701},{-1457,701},{-1456,701},{-1458,701},{-1437,701},{-1465,702},{-1466,702},{-1470,703},{-1471,703},{-1480,703},{-1479,703},{-1478,703},{-1475,704},{-1511,704},{-1512,704},{-1504,704},{-1503,704},{-1510,704},{-1510,705},{-1488,705},{-1479,705},{-1480,705},{-1483,705},{-1484,705},{-1489,705},{-1490,705},{-1487,704},{-1488,704},{-1504,705},{-1503,705},{-1489,704},{-1486,704},{-1501,705},{-1493,705},{-1492,705},{-1502,706},{-1501,706},{-1494,705},{-1496,706},{-1495,706},{-1498,706},{-1499,706},{-1497,706},{-1519,706},{-1520,706},{-1524,706},{-1523,706},{-1553,708},{-1554,708},{-1584,708},{-1585,708},{-1556,708},{-1556,709},{-1591,709},{-1589,709},{-1588,709},{-1529,709},{-1531,709},{-1587,709},{-1528,709},{-1557,709},{-1557,710},{-1556,710},{-1549,711},{-1550,711},{-1551,712},{-1552,712},{-1555,712},{-1556,712},{-1554,712},{-1551,711},{-1559,713},{-1560,713},{-1561,713},{-1562,713},{-1557,712},{-1558,712},{-1505,704},{-1505,705},{-1517,705},{-1491,705},{-1601,553},{-1600,553},{-1601,555},{-1600,555},{-1616,555},{-1617,555},{-1601,554},{-1602,554},{-1603,554},{-1600,551},{-1601,552},{-1598,553},{-1602,549},{-1601,550},{-1602,551},{-1595,553},{-1596,550},{-1613,552},{-1614,552},{-1616,552},{-1617,552},{-1615,553},{-1562,574},{-1525,586},{-1526,586},{-1603,552},{-1604,553},{-1605,553},{-1608,554},{-1605,554},{-1605,552},{-1608,551},{-1595,557},{-1556,558},{-1557,558},{-1556,559},{-1555,558},{-1589,558},{-1594,557},{-1594,558},{-1593,558},{-1609,559},{-1608,559},{-1611,560},{-1610,560},{-1593,557},{-1595,558},{-1595,559},{-1538,574},{-1539,575},{-1538,575},{-1540,576},{-1540,577},{-1539,577},{-1588,559},{-1587,558},{-1591,558},{-1592,558},{-1591,559},{-1608,560},{-1609,560},{-1566,560},{-1567,561},{-1566,561},{-1577,563},{-1586,563},{-1578,563},{-1579,563},{-1578,564},{-1577,565},{-1540,566},{-1539,565},{-1544,565},{-1542,566},{-1545,565},{-1548,564},{-1545,566},{-1544,566},{-1534,577},{-1533,577},{-1494,599},{-1570,565},{-1571,565},{-1573,565},{-1571,566},{-1581,561},{-1582,561},{-1581,562},{-1568,561},{-1568,562},{-1567,560},{-1568,560},{-1604,555},{-1574,566},{-1542,567},{-1541,567},{-1539,567},{-1540,567},{-1568,568},{-1569,568},{-1588,569},{-1587,569},{-1567,570},{-1565,570},{-1563,573},{-1563,574},{-1523,577},{-1523,578},{-1522,578},{-1531,571},{-1533,570},{-1533,571},{-1534,571},{-1533,572},{-1530,572},{-1529,572},{-1529,571},{-1536,569},{-1535,569},{-1541,569},{-1542,570},{-1541,570},{-1542,569},{-1538,567},{-1574,567},{-1574,568},{-1575,582},{-1519,582},{-1518,583},{-1518,582},{-1543,583},{-1545,581},{-1524,585},{-1528,583},{-1529,583},{-1542,583},{-1522,584},{-1523,584},{-1527,584},{-1527,585},{-1540,585},{-1523,574},{-1536,579},{-1536,578},{-1535,577},{-1535,576},{-1535,578},{-1532,577},{-1532,579},{-1530,578},{-1533,580},{-1528,579},{-1529,578},{-1529,577},{-1526,579},{-1526,577},{-1524,577},{-1525,576},{-1522,576},{-1524,574},{-1530,575},{-1531,574},{-1526,574},{-1532,574},{-1529,573},{-1535,572},{-1535,571},{-1537,571},{-1538,571},{-1536,570},{-1541,568},{-1538,570},{-1540,570},{-1538,572},{-1543,568},{-1546,572},{-1548,573},{-1542,577},{-1541,575},{-1539,574},{-1538,573},{-1536,573},{-1539,576},{-1537,575},{-1536,576},{-1533,579},{-1532,578},{-1535,579},{-1535,580},{-1527,579},{-1525,579},{-1524,580},{-1523,579},{-1524,579},{-1531,579},{-1531,580},{-1530,579},{-1530,580},{-1525,580},{-1524,578},{-1529,580},{-1534,581},{-1533,581},{-1604,587},{-1602,588},{-1602,589},{-1520,589},{-1521,589},{-1527,581},{-1532,582},{-1529,582},{-1531,583},{-1528,582},{-1529,584},{-1524,583},{-1521,584},{-1521,582},{-1520,583},{-1523,583},{-1524,582},{-1523,581},{-1526,581},{-1526,582},{-1529,579},{-1527,580},{-1522,589},{-1603,586},{-1603,587},{-1602,587},{-1521,590},{-1522,590},{-1584,590},{-1585,590},{-1534,590},{-1540,591},{-1541,591},{-1537,591},{-1538,591},{-1517,591},{-1516,591},{-1515,591},{-1514,591},{-1518,591},{-1519,591},{-1519,592},{-1518,592},{-1541,592},{-1620,593},{-1464,594},{-1463,595},{-1463,594},{-1515,595},{-1512,596},{-1513,596},{-1520,593},{-1504,593},{-1504,594},{-1508,593},{-1507,594},{-1506,594},{-1507,593},{-1535,593},{-1535,594},{-1533,594},{-1534,593},{-1536,594},{-1503,595},{-1496,596},{-1496,597},{-1497,596},{-1499,597},{-1497,597},{-1480,600},{-1480,601},{-1526,601},{-1526,602},{-1442,601},{-1443,601},{-1444,601},{-1444,602},{-1480,602},{-1453,602},{-1453,603},{-1454,603},{-1450,602},{-1451,602},{-1449,602},{-1448,602},{-1452,602},{-1452,603},{-1479,602},{-1479,603},{-1495,598},{-1442,600},{-1444,599},{-1446,598},{-1494,598},{-1474,599},{-1497,599},{-1493,599},{-1482,600},{-1481,600},{-1482,599},{-1483,599},{-1444,600},{-1479,601},{-1478,601},{-1479,600},{-1481,599},{-1521,603},{-1520,605},{-1518,605},{-1520,604},{-1477,600},{-1472,604},{-1469,603},{-1475,599},{-1479,598},{-1481,601},{-1481,602},{-1483,600},{-1498,596},{-1498,597},{-1523,589},{-1524,589},{-1570,589},{-1570,590},{-1480,604},{-1480,603},{-1482,603},{-1481,604},{-1526,585},{-1524,586},{-1523,586},{-1525,585},{-1609,587},{-1607,588},{-1609,586},{-1611,585},{-1612,587},{-1527,586},{-1588,586},{-1536,586},{-1600,586},{-1474,603},{-1475,602},{-1475,603},{-1473,603},{-1451,603},{-1478,602},{-1477,603},{-1478,605},{-1452,604},{-1451,604},{-1455,603},{-1456,603},{-1464,604},{-1461,604},{-1466,602},{-1467,603},{-1465,604},{-1467,604},{-1466,605},{-1458,604},{-1494,600},{-1496,598},{-1495,597},{-1497,600},{-1499,599},{-1498,598},{-1500,598},{-1501,597},{-1501,596},{-1502,596},{-1504,595},{-1502,597},{-1505,595},{-1505,596},{-1507,595},{-1510,592},{-1510,593},{-1516,592},{-1520,592},{-1519,594},{-1509,598},{-1514,596},{-1519,597},{-1512,605},{-1514,607},{-1504,610},{-1490,608},{-1501,612},{-1493,615},{-1495,615},{-1500,612},{-1507,613},{-1515,610},{-1518,608},{-1517,607},{-1519,608},{-1523,605},{-1522,604},{-1527,602},{-1527,599},{-1532,599},{-1530,598},{-1532,596},{-1534,596},{-1533,597},{-1535,598},{-1535,596},{-1537,596},{-1536,596},{-1539,595},{-1537,594},{-1541,593},{-1543,591},{-1542,590},{-1533,588},{-1541,585},{-1540,584},{-1544,583},{-1541,583},{-1543,582},{-1542,581},{-1545,582},{-1546,580},{-1550,580},{-1553,577},{-1556,578},{-1557,575},{-1560,576},{-1560,574},{-1565,573},{-1566,571},{-1566,570},{-1568,570},{-1572,568},{-1574,569},{-1576,567},{-1575,566},{-1578,567},{-1581,565},{-1578,566},{-1579,565},{-1584,565},{-1587,563},{-1585,561},{-1584,560},{-1586,560},{-1585,562},{-1586,562},{-1587,559},{-1588,560},{-1596,556},{-1597,556},{-1596,558},{-1598,559},{-1604,557},{-1605,555},{-1606,556},{-1608,555},{-1607,555},{-1609,555},{-1612,554},{-1615,554},{-1614,556},{-1616,556},{-1620,558},{-1618,559},{-1614,560},{-1614,559},{-1610,559},{-1608,557},{-1607,557},{-1603,558},{-1606,559},{-1603,563},{-1589,569},{-1590,568},{-1587,568},{-1587,570},{-1584,573},{-1578,575},{-1576,575},{-1577,576},{-1576,581},{-1574,582},{-1575,584},{-1570,587},{-1569,590},{-1582,586},{-1586,588},{-1583,590},{-1584,591},{-1589,587},{-1587,585},{-1589,584},{-1596,588},{-1596,590},{-1599,588},{-1603,589},{-1603,591},{-1617,586},{-1620,586},{-1618,588},{-1620,592},{-1620,594},{-1617,595},{-1620,598},{-1620,634},{-1611,635},{-1608,638},{-1610,642},{-1615,644},{-1614,645},{-1608,646},{-1609,648},{-1612,649},{-1620,647},{-1620,661},{-1615,663},{-1615,664},{-1619,663},{-1619,665},{-1620,666},{-1616,664},{-1612,665},{-1619,667},{-1615,670},{-1620,670},{-1620,703},{-1608,704},{-1593,709},{-1579,709},{-1575,710},{-1568,713},{-1565,714},{-1564,714},{-1566,713},{-1555,711},{-1561,710},{-1559,709},{-1561,709},{-1559,708},{-1560,708},{-1555,709},{-1546,710},{-1548,709},{-1542,708},{-1532,709},{-1523,708},{-1525,706},{-1521,706},{-1526,706},{-1518,705},{-1517,706},{-1520,704},{-1507,705},{-1508,705},{-1495,705},{-1450,700},{-1410,696},{-1410,598},{-1414,599},{-1415,599},{-1412,600},{-1414,601},{-1415,601},{-1414,600},{-1417,599},{-1428,601},{-1439,600},{-1443,600},{-1440,600},{-1442,602},{-1449,603},{-1447,605},{-1455,604},{-1453,604},{-1454,605},{-1456,607},{-1463,606},{-1460,607},{-1461,608},{-1465,607},{-1466,608},{-1465,610},{-1466,611},{-1463,611},{-1462,611},{-1470,609},{-1472,610},{-1474,610},{-1475,610},{-1475,612},{-1477,610},{-1476,608},{-1477,613},{-1483,610},{-1484,608},{-1485,608},{-1487,608},{-1486,607},{-1487,607},{-1484,606},{-1484,607},{-1485,605},{-1483,604},{-1485,602},{-1483,602},{-1484,599},{-1486,600},{-1486,599},{-1491,600},{-1490,601},{-1494,601}}}, - {"Asia/Kolkata",516,{{735,159},{932,82},{931,82},{931,84},{931,83},{936,84},{929,88},{928,88},{937,72},{939,72},{938,67},{937,70},{937,73},{936,74},{937,74},{936,80},{936,81},{934,80},{935,79},{933,79},{935,80},{936,79},{930,84},{930,85},{936,86},{936,85},{932,83},{935,82},{726,105},{726,106},{924,105},{924,108},{925,109},{926,106},{722,108},{722,109},{737,108},{789,92},{791,92},{736,101},{723,101},{737,101},{792,92},{730,83},{731,83},{730,82},{786,91},{788,92},{927,91},{927,92},{928,93},{928,91},{721,112},{926,109},{723,109},{922,110},{927,110},{727,111},{927,113},{927,112},{728,112},{728,113},{719,124},{943,134},{931,136},{931,137},{930,136},{930,137},{823,166},{741,149},{734,159},{738,154},{742,147},{741,147},{741,148},{740,148},{735,160},{745,140},{743,140},{745,141},{744,143},{929,136},{730,115},{926,114},{926,115},{927,114},{926,113},{722,116},{928,117},{727,117},{931,118},{926,116},{925,116},{923,115},{922,115},{922,116},{923,116},{931,121},{939,123},{938,123},{927,128},{927,127},{927,129},{928,129},{747,132},{927,130},{929,129},{929,130},{930,129},{930,130},{927,131},{930,121},{929,122},{930,122},{929,123},{929,124},{930,123},{930,124},{927,125},{931,122},{931,123},{930,118},{930,120},{928,119},{927,120},{928,120},{927,119},{926,119},{926,120},{930,119},{929,120},{931,119},{696,224},{931,120},{930,133},{930,131},{930,125},{927,115},{925,118},{927,123},{928,134},{931,134},{929,135},{747,133},{747,134},{695,224},{694,224},{693,224},{705,230},{705,231},{682,236},{684,236},{685,236},{683,236},{685,237},{683,239},{682,238},{682,239},{686,237},{686,238},{691,224},{691,225},{694,225},{693,225},{699,225},{700,226},{700,225},{699,226},{697,227},{696,228},{704,230},{704,229},{703,229},{704,231},{725,222},{727,222},{724,222},{728,188},{729,188},{729,190},{731,190},{730,190},{728,187},{835,179},{803,134},{802,125},{798,118},{799,103},{793,103},{789,95},{791,93},{793,93},{794,92},{790,93},{784,91},{782,89},{781,84},{776,81},{773,81},{765,89},{757,114},{752,121},{744,144},{735,161},{732,173},{733,173},{729,187},{731,188},{729,189},{730,192},{728,189},{728,193},{729,193},{728,194},{727,198},{730,208},{728,208},{729,210},{727,210},{728,212},{726,211},{727,213},{726,214},{731,217},{725,217},{728,220},{725,219},{726,222},{728,222},{726,223},{724,221},{724,223},{721,212},{710,207},{706,208},{689,223},{692,223},{702,226},{692,228},{684,234},{687,238},{688,238},{688,239},{684,237},{683,237},{682,237},{684,240},{687,240},{688,243},{700,242},{706,244},{707,242},{711,244},{710,244},{711,247},{707,254},{707,257},{703,257},{701,259},{702,266},{695,267},{696,272},{704,280},{706,280},{709,277},{719,280},{724,288},{729,290},{734,299},{740,302},{739,305},{747,311},{745,312},{746,315},{745,318},{754,322},{751,325},{747,325},{747,328},{745,327},{740,332},{742,335},{740,337},{743,340},{739,340},{740,343},{738,344},{740,347},{744,348},{757,345},{767,348},{767,349},{770,349},{778,355},{781,355},{780,353},{782,347},{790,343},{787,341},{787,337},{793,329},{793,325},{791,324},{788,324},{787,327},{784,325},{788,316},{788,313},{790,311},{799,310},{802,306},{811,302},{804,297},{801,288},{812,284},{819,279},{827,277},{828,275},{833,273},{834,275},{839,274},{842,275},{846,273},{846,270},{852,268},{856,269},{859,266},{863,266},{867,264},{871,266},{873,264},{879,265},{880,264},{882,268},{880,271},{881,279},{886,281},{889,278},{888,275},{889,273},{888,271},{891,268},{899,267},{904,269},{907,268},{919,268},{921,269},{921,273},{920,275},{916,275},{917,278},{925,279},{927,280},{927,281},{932,284},{933,287},{939,288},{940,290},{947,293},{953,291},{961,295},{963,292},{964,293},{961,291},{962,289},{965,291},{966,288},{963,284},{971,284},{974,282},{974,279},{969,276},{972,271},{967,274},{962,273},{951,266},{952,261},{946,254},{946,252},{947,250},{942,239},{933,241},{934,231},{931,230},{932,223},{929,219},{927,222},{926,220},{923,237},{920,237},{918,231},{916,229},{914,233},{913,231},{912,236},{914,241},{918,242},{919,241},{920,244},{921,244},{923,248},{925,249},{924,250},{921,252},{904,251},{899,253},{899,259},{897,262},{896,260},{894,260},{891,264},{889,264},{891,263},{890,262},{887,263},{887,264},{884,266},{883,265},{885,264},{882,261},{881,258},{885,255},{888,255},{890,253},{889,252},{884,252},{883,249},{881,249},{880,247},{881,245},{887,243},{888,240},{886,236},{888,235},{887,233},{890,232},{889,230},{891,222},{890,219},{891,216},{889,218},{889,216},{887,217},{888,220},{886,221},{884,216},{884,220},{884,218},{883,218},{883,219},{883,216},{882,222},{880,222},{882,221},{878,217},{869,213},{868,211},{871,207},{864,200},{856,197},{850,193},{841,183},{823,170},{817,163},{813,163},{809,157},{807,159},{803,157},{800,151},{727,195},{867,203},{868,204},{868,205},{729,207},{729,206},{728,207},{729,208},{727,211},{726,213},{888,216},{889,215},{724,216},{723,216},{726,210},{883,217},{886,216},{886,217},{885,217},{881,217},{881,216},{881,218},{882,217},{884,217},{886,218},{882,215},{882,216},{885,216},{885,215},{887,216},{885,218},{728,210},{728,209},{729,217},{887,220},{887,219},{886,220},{726,216},{728,216},{881,220},{726,217},{726,218},{882,218},{886,219},{885,219},{881,219},{882,219}}}, - {"Pacific/Niue",4,{{-1699,-190},{-1698,-190},{-1698,-191},{-1699,-192}}}, - {"Asia/Kamchatka",190,{{1595,532},{1573,512},{1565,519},{1565,520},{1680,545},{1677,547},{1674,549},{1681,545},{1667,547},{1659,552},{1657,553},{1662,553},{1662,552},{1666,549},{1622,605},{1628,608},{1633,609},{1633,608},{1725,611},{1630,615},{1626,616},{1625,616},{1627,616},{1635,623},{1625,578},{1624,578},{1634,586},{1639,590},{1637,590},{1646,592},{1648,590},{1647,589},{1642,588},{1635,585},{1604,595},{1605,595},{1647,596},{1628,573},{1628,568},{1632,568},{1634,562},{1631,560},{1626,562},{1621,561},{1617,554},{1621,548},{1617,545},{1609,546},{1600,542},{1598,538},{1600,535},{1598,534},{1600,531},{1598,533},{1587,529},{1586,530},{1584,530},{1586,529},{1585,528},{1586,526},{1584,526},{1586,523},{1579,516},{1567,509},{1568,511},{1565,513},{1566,519},{1567,519},{1562,528},{1556,550},{1557,560},{1560,567},{1570,574},{1569,578},{1575,578},{1577,580},{1582,580},{1591,584},{1597,589},{1599,591},{1619,602},{1621,605},{1630,608},{1638,608},{1635,610},{1640,613},{1638,615},{1641,617},{1642,623},{1652,625},{1645,627},{1633,625},{1631,624},{1634,623},{1631,622},{1632,621},{1630,618},{1633,617},{1628,617},{1626,617},{1628,616},{1625,617},{1623,619},{1625,621},{1622,622},{1627,623},{1627,626},{1628,627},{1623,629},{1623,631},{1628,632},{1627,634},{1630,635},{1627,638},{1629,639},{1628,641},{1635,644},{1632,646},{1633,647},{1631,648},{1642,649},{1649,647},{1652,649},{1657,648},{1659,646},{1672,646},{1677,643},{1685,643},{1689,640},{1694,640},{1696,637},{1684,631},{1701,627},{1700,625},{1703,623},{1709,622},{1720,625},{1728,623},{1737,625},{1741,625},{1741,621},{1745,620},{1745,618},{1740,618},{1741,618},{1738,616},{1735,617},{1733,614},{1727,614},{1729,613},{1727,613},{1728,613},{1722,611},{1725,610},{1720,611},{1722,610},{1721,608},{1707,604},{1703,599},{1694,605},{1684,606},{1671,604},{1663,598},{1661,598},{1664,604},{1663,605},{1650,601},{1652,600},{1649,598},{1645,601},{1642,599},{1641,599},{1643,600},{1635,599},{1634,596},{1632,596},{1633,596},{1632,595},{1634,593},{1631,592},{1633,591},{1632,591},{1630,592},{1631,590},{1624,587},{1620,581},{1622,578},{1627,579},{1633,577},{1565,572}}}, - {"Europe/Stockholm",526,{{203,636},{203,637},{185,629},{175,587},{128,559},{127,559},{161,563},{148,560},{149,560},{158,560},{158,561},{150,561},{154,561},{152,561},{157,561},{155,561},{156,561},{156,562},{157,562},{155,562},{154,562},{122,571},{165,568},{164,568},{165,569},{165,570},{166,570},{163,586},{164,586},{166,571},{167,571},{126,564},{125,564},{126,565},{193,583},{192,583},{192,584},{193,584},{170,582},{170,583},{114,581},{114,582},{168,581},{169,581},{115,582},{169,582},{116,582},{115,583},{169,583},{114,583},{118,583},{116,583},{117,583},{168,583},{192,597},{112,583},{113,583},{113,584},{112,584},{169,584},{168,584},{116,584},{167,584},{170,584},{169,585},{112,585},{112,586},{113,585},{170,585},{113,586},{110,589},{111,590},{112,587},{111,587},{111,588},{112,588},{111,589},{112,589},{118,576},{119,576},{188,573},{180,573},{185,571},{181,573},{190,574},{166,576},{116,577},{117,577},{116,578},{117,578},{118,578},{117,579},{116,579},{167,567},{164,562},{164,565},{171,574},{120,573},{119,573},{119,574},{120,574},{121,573},{122,572},{165,572},{165,571},{166,572},{166,573},{167,575},{167,574},{167,576},{117,576},{115,580},{115,581},{118,581},{117,581},{116,581},{117,580},{118,580},{191,578},{190,578},{166,578},{167,578},{167,577},{166,579},{168,580},{182,569},{183,571},{181,575},{187,579},{190,579},{188,576},{189,574},{118,577},{189,577},{190,577},{167,580},{167,579},{168,579},{168,578},{191,580},{194,580},{192,579},{118,582},{192,598},{191,597},{191,598},{191,596},{190,596},{190,597},{190,598},{173,611},{173,612},{172,614},{184,605},{177,606},{176,606},{176,607},{175,607},{185,603},{184,603},{186,603},{184,604},{191,599},{188,601},{186,602},{188,602},{187,602},{185,602},{184,602},{187,603},{173,607},{174,607},{175,608},{173,609},{172,610},{173,610},{173,608},{174,608},{213,649},{212,649},{216,650},{215,650},{194,634},{194,635},{208,636},{199,635},{195,635},{196,635},{195,634},{208,637},{209,637},{209,636},{210,638},{209,638},{202,637},{206,638},{206,637},{239,658},{238,658},{241,658},{232,658},{235,658},{234,658},{238,656},{237,656},{240,656},{242,657},{241,657},{229,657},{228,657},{235,657},{238,657},{237,657},{237,658},{240,657},{230,656},{230,657},{231,657},{236,657},{232,657},{233,657},{234,657},{233,658},{217,651},{217,652},{216,651},{220,652},{219,652},{218,652},{219,653},{220,653},{218,653},{221,654},{226,654},{226,655},{225,654},{224,654},{223,654},{223,655},{220,654},{228,655},{227,655},{221,655},{228,656},{220,655},{225,655},{223,656},{227,656},{222,654},{222,655},{224,655},{222,656},{215,653},{215,654},{216,654},{219,654},{217,653},{217,654},{218,654},{219,655},{228,659},{227,659},{224,658},{226,658},{228,658},{227,658},{225,658},{224,656},{225,656},{226,656},{224,657},{223,657},{225,657},{226,657},{227,657},{174,615},{174,616},{175,615},{173,616},{172,616},{175,617},{176,617},{171,616},{175,619},{175,620},{182,628},{183,628},{180,628},{179,629},{186,630},{187,630},{183,629},{186,631},{185,630},{185,631},{187,631},{188,631},{187,632},{176,632},{177,632},{189,632},{188,633},{192,633},{189,633},{188,632},{177,622},{178,622},{178,624},{177,624},{174,624},{174,625},{175,624},{176,624},{175,625},{179,626},{180,626},{181,626},{180,627},{181,627},{182,627},{188,595},{188,596},{187,596},{189,596},{189,597},{188,597},{190,599},{189,598},{186,591},{183,591},{184,591},{182,591},{185,590},{186,590},{180,590},{182,589},{183,590},{184,590},{180,589},{182,590},{181,590},{177,590},{176,590},{185,591},{171,587},{179,587},{179,588},{175,588},{173,587},{174,588},{181,589},{177,588},{177,589},{176,589},{176,588},{178,588},{178,589},{177,591},{124,563},{128,562},{129,564},{129,566},{124,569},{121,575},{119,583},{117,584},{116,585},{115,584},{115,585},{114,585},{113,591},{115,589},{117,589},{118,592},{117,596},{119,597},{119,598},{124,600},{126,604},{122,610},{127,611},{129,614},{121,617},{123,623},{121,626},{122,630},{120,633},{122,635},{121,636},{127,640},{132,641},{140,640},{141,642},{141,645},{136,646},{145,653},{146,658},{145,661},{155,663},{154,665},{164,670},{162,675},{164,675},{167,679},{173,681},{179,680},{182,682},{181,685},{200,684},{203,685},{200,686},{203,688},{201,691},{208,690},{220,685},{231,683},{237,680},{234,675},{238,674},{236,672},{240,668},{237,663},{242,658},{231,659},{223,659},{221,656},{220,656},{217,658},{218,657},{214,654},{213,654},{214,651},{210,648},{216,644},{211,642},{207,638},{205,638},{204,637},{203,638},{200,637},{197,634},{194,636},{193,635},{190,632},{187,633},{182,630},{181,628},{178,631},{173,625},{174,623},{175,622},{173,619},{175,616},{171,617},{170,616},{172,615},{171,615},{173,613},{171,613},{171,609},{172,607},{177,605},{180,606},{182,603},{183,603},{186,601},{187,601},{188,600},{188,599},{187,598},{182,594},{183,594},{180,594},{185,592},{179,589},{177,592},{171,588},{169,586},{164,587},{162,586},{163,585},{166,583},{166,582},{165,579},{164,579},{165,577},{165,576},{165,573},{161,562},{159,561},{147,562},{145,561},{142,559},{144,556},{142,554},{134,553},{128,554},{131,557},{182,593},{181,594},{190,594},{189,594},{188,594},{184,594},{187,594},{186,594},{185,594},{186,595},{187,595},{185,595},{187,591},{188,592},{188,591},{186,592},{187,592},{189,592},{190,593},{189,593},{187,593},{185,593},{188,593},{184,592},{184,593},{183,593},{186,593},{189,595}}}, - {"America/Havana",287,{{-806,231},{-806,232},{-788,215},{-793,210},{-793,211},{-772,199},{-772,203},{-772,204},{-779,206},{-784,206},{-778,205},{-776,205},{-778,206},{-785,206},{-786,206},{-787,207},{-786,207},{-783,206},{-783,205},{-784,205},{-782,206},{-774,206},{-781,206},{-783,207},{-781,207},{-749,207},{-796,215},{-794,211},{-788,214},{-782,208},{-790,209},{-790,208},{-791,209},{-792,210},{-789,208},{-783,208},{-786,208},{-788,208},{-787,208},{-788,207},{-777,207},{-784,207},{-778,221},{-785,207},{-782,207},{-785,208},{-790,210},{-790,211},{-789,211},{-785,213},{-787,211},{-777,221},{-778,222},{-788,216},{-822,215},{-822,216},{-831,216},{-824,216},{-825,216},{-823,216},{-830,216},{-811,217},{-825,217},{-824,217},{-826,217},{-815,216},{-814,217},{-816,216},{-819,216},{-819,217},{-818,217},{-817,216},{-820,216},{-821,216},{-820,217},{-815,217},{-818,216},{-776,218},{-774,218},{-775,218},{-776,219},{-777,219},{-808,232},{-799,217},{-821,217},{-778,219},{-844,224},{-845,224},{-844,225},{-843,225},{-810,232},{-809,232},{-810,233},{-796,235},{-795,235},{-796,236},{-809,233},{-805,232},{-807,232},{-802,231},{-803,231},{-804,231},{-807,231},{-805,231},{-802,232},{-812,232},{-811,232},{-813,231},{-803,232},{-804,232},{-809,231},{-808,231},{-810,231},{-843,226},{-842,226},{-788,227},{-789,227},{-839,228},{-838,228},{-790,226},{-791,226},{-796,228},{-795,227},{-790,227},{-795,226},{-791,227},{-794,227},{-794,226},{-827,226},{-827,227},{-825,226},{-825,227},{-797,228},{-837,228},{-836,229},{-835,229},{-797,229},{-833,229},{-834,229},{-799,229},{-798,229},{-793,226},{-792,226},{-829,221},{-828,222},{-798,230},{-799,230},{-800,230},{-804,230},{-801,230},{-803,230},{-802,230},{-820,222},{-781,222},{-816,222},{-803,229},{-801,231},{-812,231},{-811,231},{-836,220},{-835,220},{-781,221},{-819,222},{-779,222},{-784,222},{-784,223},{-783,223},{-783,222},{-779,221},{-780,221},{-817,222},{-817,221},{-812,221},{-813,221},{-819,221},{-818,221},{-818,222},{-780,222},{-782,221},{-782,222},{-815,221},{-815,222},{-816,221},{-777,222},{-779,223},{-832,218},{-832,219},{-833,220},{-834,220},{-834,219},{-829,219},{-827,219},{-826,216},{-831,215},{-832,216},{-831,218},{-747,206},{-741,202},{-751,199},{-758,200},{-777,198},{-771,204},{-773,207},{-781,208},{-785,210},{-787,216},{-792,215},{-798,217},{-805,221},{-811,221},{-812,223},{-822,224},{-816,225},{-819,227},{-828,227},{-834,222},{-839,222},{-840,219},{-845,218},{-845,219},{-850,219},{-843,220},{-844,222},{-832,230},{-822,232},{-811,230},{-799,228},{-794,224},{-779,219},{-779,220},{-778,220},{-776,221},{-777,218},{-773,216},{-761,211},{-757,211},{-756,208},{-780,220},{-826,220},{-827,220},{-817,220},{-816,220},{-812,220},{-813,220},{-829,220},{-828,221},{-814,221},{-814,220},{-826,218},{-825,218},{-826,219},{-818,219},{-780,223},{-780,224},{-779,224},{-781,224},{-783,224},{-782,223},{-784,224},{-781,225},{-782,225},{-782,224},{-785,224},{-786,224},{-786,225},{-783,225},{-828,223},{-821,224},{-825,224},{-793,224},{-823,225},{-825,225},{-787,225},{-791,225},{-788,225},{-789,225},{-790,225},{-792,224},{-793,225},{-785,225},{-784,226},{-824,225},{-787,226},{-786,226},{-795,225},{-792,225},{-826,226}}}, - {"Pacific/Auckland",304,{{1788,-496},{1666,-460},{1661,-511},{1692,-525},{1692,-526},{1690,-525},{1691,-525},{1662,-509},{1661,-509},{1659,-509},{1659,-508},{1663,-505},{1662,-505},{1662,-507},{1661,-507},{1662,-508},{1660,-506},{1788,-497},{1787,-497},{1666,-480},{1665,-480},{1791,-477},{1790,-477},{1674,-472},{1674,-471},{1677,-470},{1677,-469},{1677,-472},{1676,-472},{1686,-468},{1685,-468},{1685,-467},{1681,-469},{1682,-469},{1682,-468},{1676,-468},{1676,-467},{1677,-468},{1674,-473},{1666,-458},{1668,-458},{1668,-457},{1669,-457},{1668,-456},{1666,-457},{1665,-457},{1667,-458},{1676,-473},{1677,-467},{1680,-469},{1679,-470},{1682,-471},{1669,-453},{1669,-452},{1670,-451},{1670,-453},{1715,-419},{1715,-418},{1727,-436},{1678,-465},{1678,-464},{1679,-464},{1666,-461},{1667,-461},{1665,-461},{1665,-460},{1665,-458},{1666,-456},{1667,-457},{1664,-457},{1665,-456},{1684,-466},{1685,-466},{1669,-466},{1779,-393},{1772,-375},{1763,-373},{1762,-373},{1761,-369},{1761,-370},{1770,-379},{1770,-378},{1764,-376},{1759,-371},{1759,-370},{1760,-370},{1759,-366},{1759,-367},{1749,-367},{1751,-369},{1752,-369},{1757,-369},{1749,-368},{1748,-368},{1752,-368},{1750,-368},{1747,-360},{1747,-359},{1752,-367},{1754,-368},{1754,-367},{1754,-361},{1754,-360},{1751,-360},{1751,-359},{1748,-359},{1747,-355},{1747,-354},{1745,-357},{1742,-352},{1741,-352},{1721,-342},{1721,-341},{-1786,-305},{-1784,-302},{-1780,-292},{-1779,-293},{-1780,-293},{1739,-350},{1740,-350},{1738,-350},{1758,-366},{1757,-366},{1749,-366},{1748,-365},{1758,-364},{1751,-362},{1750,-362},{1753,-362},{1749,-364},{1748,-364},{1754,-362},{1755,-363},{1754,-363},{1755,-361},{1732,-413},{1740,-412},{1731,-413},{1691,-467},{1683,-466},{1682,-465},{1684,-465},{1683,-464},{1683,-465},{1681,-463},{1677,-461},{1667,-462},{1669,-459},{1668,-459},{1664,-459},{1670,-457},{1670,-456},{1667,-456},{1669,-455},{1670,-455},{1667,-454},{1668,-454},{1669,-454},{1668,-453},{1672,-455},{1672,-453},{1672,-452},{1673,-450},{1671,-450},{1673,-448},{1674,-450},{1674,-448},{1675,-449},{1675,-447},{1677,-446},{1678,-446},{1679,-447},{1678,-445},{1684,-440},{1688,-440},{1708,-429},{1711,-426},{1717,-417},{1721,-414},{1721,-409},{1726,-405},{1729,-405},{1730,-405},{1730,-406},{1728,-405},{1727,-407},{1731,-409},{1730,-411},{1738,-409},{1739,-410},{1740,-409},{1738,-410},{1738,-411},{1739,-411},{1737,-413},{1741,-412},{1739,-412},{1740,-411},{1740,-410},{1743,-410},{1742,-412},{1739,-413},{1743,-412},{1740,-414},{1743,-417},{1733,-429},{1727,-432},{1728,-436},{1730,-437},{1731,-438},{1724,-439},{1713,-443},{1712,-449},{1706,-457},{1707,-458},{1705,-459},{1707,-459},{1702,-460},{1696,-466},{1734,-412},{1734,-411},{1748,-411},{1744,-411},{1744,-412},{1743,-411},{1731,-410},{1741,-409},{1749,-409},{1749,-408},{1741,-410},{1764,-407},{1760,-412},{1754,-416},{1749,-414},{1749,-412},{1746,-413},{1752,-407},{1752,-402},{1749,-399},{1739,-395},{1737,-393},{1745,-389},{1748,-380},{1748,-373},{1742,-365},{1744,-366},{1744,-363},{1744,-364},{1743,-364},{1743,-363},{1745,-362},{1744,-362},{1744,-361},{1743,-362},{1743,-361},{1742,-361},{1742,-363},{1740,-361},{1740,-364},{1730,-352},{1732,-350},{1727,-344},{1730,-344},{1730,-346},{1733,-350},{1734,-348},{1734,-350},{1741,-351},{1740,-351},{1740,-352},{1741,-353},{1743,-352},{1746,-359},{1745,-360},{1747,-364},{1748,-370},{1750,-369},{1753,-370},{1753,-372},{1756,-372},{1754,-365},{1756,-368},{1758,-367},{1757,-368},{1758,-369},{1760,-375},{1766,-378},{1773,-380},{1780,-375},{1786,-377},{1783,-380},{1783,-385},{1779,-387},{1780,-391},{1779,-391},{1777,-391},{1770,-392},{1769,-394},{1771,-396},{1770,-398},{1740,-408},{1738,-408},{1740,-407},{1739,-409}}}, - {"America/Matamoros",28,{{-986,259},{-993,263},{-995,267},{-997,269},{-998,274},{-1005,281},{-1009,289},{-1016,295},{-1025,295},{-1026,291},{-1031,287},{-1034,288},{-1033,290},{-1029,292},{-1027,297},{-1023,299},{-1014,298},{-1007,291},{-1003,283},{-995,276},{-995,270},{-991,264},{-982,261},{-977,260},{-974,258},{-971,259},{-972,256},{-974,256}}}, - {"America/Rainy_River",2,{{-945,487},{-946,487}}}, - {"Asia/Omsk",134,{{750,585},{754,585},{751,583},{752,582},{751,581},{756,579},{756,576},{761,573},{763,567},{758,564},{761,565},{763,562},{757,561},{753,559},{754,558},{751,558},{753,555},{751,554},{754,550},{753,549},{758,547},{757,541},{745,537},{744,535},{739,536},{734,534},{733,537},{735,539},{737,539},{738,541},{733,540},{726,541},{725,540},{727,539},{725,539},{724,541},{725,541},{721,544},{722,541},{718,542},{717,541},{711,541},{710,543},{712,544},{713,546},{709,549},{710,551},{708,553},{703,552},{708,556},{705,557},{708,559},{705,559},{709,560},{708,563},{709,564},{708,565},{711,566},{711,567},{717,568},{711,573},{707,572},{704,574},{707,576},{704,579},{709,585},{713,584},{712,581},{729,580},{731,581},{742,581},{884,522},{878,518},{881,518},{879,515},{884,513},{887,516},{890,514},{891,511},{899,505},{895,505},{893,502},{895,502},{897,498},{889,495},{882,495},{881,493},{874,491},{866,496},{868,498},{862,495},{853,496},{850,501},{843,502},{840,508},{834,510},{827,509},{825,507},{815,508},{814,510},{811,509},{811,512},{807,513},{804,512},{805,510},{801,508},{791,520},{778,533},{781,535},{779,536},{784,535},{787,537},{795,537},{809,544},{816,539},{819,540},{817,538},{818,537},{822,537},{825,535},{832,541},{834,539},{836,541},{845,541},{852,545},{854,542},{861,540},{866,535},{870,535},{867,532},{871,531},{869,529},{872,526},{884,525}}}, - {"Africa/Algiers",85,{{-11,357},{-9,358},{94,300},{98,294},{100,279},{98,273},{99,266},{94,262},{100,253},{100,249},{102,246},{110,245},{114,242},{116,242},{120,235},{74,208},{58,194},{33,190},{31,192},{33,194},{32,198},{24,201},{22,203},{18,203},{16,206},{12,207},{12,211},{0,219},{-87,273},{-87,287},{-82,290},{-71,296},{-65,296},{-51,300},{-48,306},{-36,309},{-38,312},{-37,316},{-28,318},{-29,321},{-12,321},{-13,323},{-10,325},{-15,330},{-15,331},{-17,333},{-16,336},{-17,337},{-17,345},{-18,346},{-17,348},{-22,351},{-14,353},{-8,358},{-6,357},{-4,359},{-1,358},{2,361},{9,365},{25,366},{30,368},{48,369},{53,366},{64,371},{69,369},{72,369},{72,371},{79,368},{86,369},{87,368},{82,365},{84,364},{83,358},{83,353},{85,352},{83,347},{76,342},{75,338},{77,333},{81,331},{83,328},{84,325},{91,320},{96,302},{94,302}}}, - {"America/Guayaquil",89,{{-802,-34},{-803,-34},{-803,-33},{-804,-32},{-801,-33},{-800,-33},{-801,-34},{-802,-33},{-800,-32},{-810,-13},{-811,-13},{-809,-16},{-790,12},{-788,14},{-789,14},{-800,4},{-801,4},{-801,5},{-802,-27},{-801,-27},{-799,-27},{-784,-38},{-786,-45},{-790,-50},{-793,-50},{-796,-44},{-798,-45},{-801,-43},{-804,-45},{-803,-42},{-805,-41},{-802,-39},{-802,-35},{-799,-32},{-797,-25},{-798,-23},{-799,-26},{-799,-24},{-800,-25},{-799,-23},{-800,-23},{-803,-26},{-803,-27},{-810,-22},{-807,-20},{-808,-16},{-807,-14},{-809,-11},{-806,-9},{-804,-6},{-804,-7},{-803,-7},{-805,-4},{-800,1},{-801,8},{-792,11},{-780,8},{-777,8},{-774,4},{-766,2},{-763,4},{-753,-1},{-756,-1},{-756,-3},{-752,-5},{-752,-10},{-754,-9},{-755,-15},{-761,-21},{-766,-26},{-778,-30},{-782,-34},{-781,-35},{-783,-34},{-800,-28},{-801,-29},{-801,-30},{-803,-31},{-804,-30},{-803,-30},{-802,-26},{-800,-27},{-800,-26},{-801,-26},{-798,-26},{-797,-26},{-798,-27},{-798,-25},{-798,-24}}}, - {"Indian/Maldives",141,{{732,-6},{731,-6},{734,-3},{732,-7},{731,-7},{732,2},{731,2},{734,3},{730,3},{735,3},{735,4},{730,4},{730,5},{735,5},{729,5},{734,6},{731,7},{732,7},{734,7},{734,8},{733,18},{735,18},{734,18},{735,19},{733,19},{732,19},{736,19},{733,20},{736,20},{735,20},{735,21},{736,21},{730,22},{731,22},{732,22},{729,23},{730,23},{733,23},{729,24},{734,24},{733,25},{729,27},{730,27},{730,28},{734,28},{730,29},{729,29},{728,29},{735,29},{736,29},{730,30},{736,30},{729,31},{730,31},{730,32},{730,33},{735,35},{728,35},{729,35},{729,36},{728,36},{734,37},{727,37},{734,39},{734,38},{735,39},{727,40},{729,40},{727,41},{735,41},{729,41},{735,42},{729,42},{730,43},{733,43},{734,43},{736,44},{730,44},{737,44},{734,46},{735,46},{736,46},{729,49},{734,50},{730,49},{729,50},{730,51},{731,51},{731,52},{731,53},{736,53},{733,54},{736,54},{734,54},{735,55},{730,55},{733,55},{734,55},{730,56},{733,57},{734,57},{734,58},{730,58},{735,59},{730,59},{731,58},{730,53},{734,59},{734,60},{732,60},{730,60},{731,60},{733,61},{732,61},{733,62},{732,62},{730,63},{732,63},{729,63},{732,64},{727,64},{731,63},{729,64},{730,65},{729,66},{730,66},{729,67},{731,67},{730,67},{732,68},{732,67},{731,68},{730,69},{730,68},{732,70},{732,69},{729,70},{730,70},{728,71},{729,71},{731,69}}}, - {"Asia/Makassar",831,{{1177,-84},{1170,36},{1171,36},{1173,36},{1226,-108},{1227,-108},{1228,-108},{1228,-110},{1229,-110},{1229,-107},{1230,-109},{1229,-109},{1216,-106},{1215,-106},{1220,-105},{1219,-106},{1217,-106},{1219,-104},{1234,-105},{1234,-107},{1228,-109},{1236,-100},{1201,-103},{1202,-103},{1233,-103},{1234,-103},{1234,-102},{1194,-88},{1194,-87},{1234,-101},{1235,-102},{1199,-93},{1208,-100},{1207,-102},{1205,-103},{1202,-102},{1197,-98},{1192,-98},{1189,-96},{1192,-94},{1155,-88},{1159,-88},{1159,-87},{1160,-88},{1217,-73},{1218,-73},{1218,-72},{1217,-72},{1180,-72},{1250,-90},{1252,-91},{1250,-92},{1251,-94},{1247,-99},{1244,-102},{1235,-104},{1238,-101},{1236,-99},{1238,-95},{1240,-93},{1243,-95},{1245,-92},{1215,-89},{1203,-89},{1152,-87},{1198,-86},{1182,-86},{1178,-86},{1190,-86},{1191,-86},{1182,-87},{1195,-87},{1197,-86},{1179,-86},{1180,-86},{1181,-86},{1161,-89},{1160,-89},{1181,-73},{1156,-88},{1154,-87},{1156,-87},{1168,-88},{1198,-88},{1196,-88},{1197,-88},{1198,-87},{1155,-87},{1160,-87},{1196,-86},{1167,-87},{1192,-87},{1193,-87},{1196,-87},{1192,-68},{1210,-68},{1183,-67},{1180,-87},{1196,-85},{1194,-84},{1243,-83},{1244,-83},{1168,-84},{1161,-84},{1161,-83},{1160,-84},{1160,-83},{1167,-83},{1168,-83},{1168,-85},{1168,-86},{1243,-85},{1178,-85},{1177,-86},{1177,-85},{1170,-84},{1169,-85},{1169,-84},{1239,-84},{1198,-84},{1199,-84},{1229,-86},{1230,-84},{1232,-84},{1230,-85},{1198,-85},{1194,-85},{1192,-86},{1197,-85},{1176,-85},{1199,-85},{1224,-85},{1223,-84},{1224,-84},{1223,-85},{1228,-85},{1196,-84},{1193,-84},{1193,-85},{1238,-84},{1225,-84},{1171,-84},{1210,-84},{1200,-84},{1223,-83},{1202,-84},{1201,-83},{1202,-83},{1217,-84},{1217,-83},{1218,-83},{1236,-78},{1175,-76},{1174,-76},{1180,-75},{1173,-75},{1174,-75},{1175,-75},{1217,-75},{1218,-75},{1179,-75},{1179,-74},{1178,-74},{1221,-74},{1176,-74},{1218,-74},{1217,-74},{1177,-74},{1175,-74},{1175,-73},{1212,-74},{1211,-74},{1211,-73},{1208,-73},{1210,-73},{1172,-75},{1184,-72},{1182,-71},{1183,-71},{1206,-71},{1180,-71},{1180,-70},{1222,-69},{1189,-69},{1208,-71},{1206,-70},{1205,-71},{1205,-70},{1204,-67},{1204,-66},{1189,-66},{1188,-66},{1210,-65},{1209,-65},{1190,-69},{1191,-69},{1191,-68},{1208,-68},{1208,-69},{1246,-61},{1240,-60},{1240,-59},{1241,-60},{1205,-58},{1205,-57},{1239,-58},{1240,-58},{1239,-57},{1204,-65},{1211,-65},{1211,-64},{1227,-62},{1204,-62},{1204,-61},{1206,-61},{1205,-65},{1247,16},{1247,17},{1166,-89},{1158,-88},{1161,-88},{1164,-82},{1167,-84},{1165,-88},{1183,-86},{1177,-82},{1179,-81},{1183,-84},{1186,-83},{1186,-86},{1188,-83},{1190,-83},{1191,-88},{1187,-87},{1189,-88},{1189,-89},{1184,-89},{1184,-88},{1184,-87},{1184,-86},{1179,-89},{1170,-91},{1167,-90},{1176,-84},{1146,-81},{1152,-81},{1157,-84},{1151,-88},{1150,-86},{1145,-83},{1144,-81},{1248,16},{1251,-83},{1244,-85},{1243,-84},{1245,-81},{1251,-81},{1204,-82},{1215,-86},{1220,-84},{1223,-86},{1229,-83},{1229,-82},{1227,-82},{1228,-81},{1230,-81},{1230,-83},{1228,-84},{1228,-86},{1225,-87},{1210,-90},{1206,-88},{1199,-89},{1239,-82},{1235,-86},{1232,-85},{1235,-83},{1234,-83},{1235,-82},{1235,-84},{1236,-82},{1243,-82},{1241,-85},{1240,-83},{1241,-84},{1254,21},{1253,21},{1233,-83},{1233,-84},{1231,-82},{1175,-84},{1175,-82},{1244,-82},{1241,-82},{1240,-82},{1174,-81},{1174,-82},{1178,-81},{1177,-81},{1145,-81},{1191,-83},{1190,-82},{1191,-81},{1191,-82},{1145,-34},{1210,-27},{1189,-26},{1189,-27},{1190,-25},{1191,-24},{1254,23},{1253,23},{1250,17},{1254,24},{1255,24},{1251,18},{1250,18},{1189,18},{1248,18},{1188,20},{1185,22},{1186,21},{1185,21},{1251,19},{1181,23},{1186,22},{1186,23},{1180,24},{1253,24},{1182,23},{1182,24},{1247,9},{1249,10},{1247,8},{1246,8},{1209,14},{1185,14},{1184,14},{1253,15},{1253,16},{1253,14},{1252,14},{1248,17},{1247,18},{1252,18},{1251,17},{1255,31},{1255,32},{1256,33},{1256,34},{1257,35},{1256,35},{1256,36},{1255,34},{1256,38},{1268,37},{1268,38},{1268,39},{1256,46},{1271,46},{1271,47},{1255,47},{1271,48},{1267,38},{1267,39},{1266,40},{1269,45},{1269,43},{1267,40},{1267,45},{1254,26},{1254,27},{1255,27},{1255,26},{1254,28},{1252,28},{1252,27},{1176,30},{1175,31},{1254,31},{1176,32},{1255,33},{1254,32},{1176,31},{1176,35},{1177,35},{1176,36},{1174,34},{1175,34},{1174,35},{1175,35},{1176,33},{1176,34},{1177,34},{1175,33},{1174,36},{1254,39},{1176,41},{1177,41},{1177,40},{1176,40},{1179,42},{1179,40},{1177,42},{1175,41},{1177,36},{1175,36},{1178,35},{1178,36},{1179,35},{1254,37},{1167,-23},{1164,-22},{1164,-21},{1165,-21},{1242,-18},{1241,-18},{1241,-17},{1240,-19},{1240,-18},{1235,-8},{1234,-8},{1175,-8},{1173,-8},{1218,-7},{1175,-7},{1176,-7},{1227,-6},{1175,-6},{1216,-6},{1176,-6},{1175,-5},{1175,-4},{1218,-4},{1222,-3},{1220,-3},{1221,-3},{1222,-2},{1221,-2},{1220,-2},{1231,-22},{1232,-22},{1239,-21},{1236,-21},{1235,-21},{1239,-20},{1219,-4},{1221,-4},{1219,-3},{1223,-3},{1224,-4},{1219,-5},{1176,-5},{1226,-5},{1225,-5},{1217,-6},{1237,-22},{1234,-21},{1238,-21},{1237,-21},{1235,-20},{1235,-19},{1238,-19},{1237,-19},{1237,-20},{1236,-19},{1238,-20},{1214,-19},{1217,-19},{1215,-19},{1167,-11},{1167,-12},{1232,-13},{1233,-13},{1233,-12},{1230,-14},{1231,-14},{1214,-18},{1233,-18},{1232,-18},{1234,-19},{1219,-17},{1228,-16},{1235,-16},{1235,-15},{1230,-17},{1231,-17},{1236,-16},{1236,-17},{1235,-17},{1231,-19},{1231,-18},{1235,-18},{1233,-17},{1234,-17},{1236,-15},{1228,-15},{1180,9},{1202,10},{1236,-13},{1233,-14},{1232,-16},{1231,-16},{1229,-16},{1229,-12},{1232,-12},{1232,-14},{1174,-9},{1175,-9},{1173,-9},{1216,-1},{1216,-2},{1175,1},{1176,1},{1196,1},{1179,11},{1179,10},{1204,10},{1207,10},{1204,11},{1206,11},{1229,9},{1228,9},{1223,5},{1224,5},{1217,5},{1199,5},{1180,8},{1180,7},{1225,5},{1220,10},{1220,11},{1188,11},{1207,12},{1171,-50},{1156,-49},{1157,-49},{1222,-50},{1228,-50},{1185,-50},{1223,-49},{1194,-49},{1157,-47},{1158,-47},{1163,-38},{1231,-36},{1230,-36},{1232,-35},{1232,-36},{1211,-39},{1210,-39},{1210,-38},{1204,-57},{1204,-56},{1223,-36},{1223,-35},{1224,-36},{1231,-43},{1229,-41},{1230,-40},{1233,-41},{1162,-41},{1215,-42},{1214,-42},{1214,-41},{1215,-41},{1160,-41},{1162,-40},{1213,-41},{1211,-40},{1228,-40},{1226,-40},{1162,-32},{1163,-39},{1161,-41},{1160,-36},{1220,-49},{1221,-49},{1231,-48},{1230,-48},{1221,-48},{1158,-48},{1159,-47},{1232,-48},{1230,-47},{1231,-47},{1224,-47},{1224,-46},{1215,-47},{1195,-47},{1194,-47},{1189,-47},{1190,-47},{1223,-47},{1204,-47},{1232,-46},{1158,-44},{1223,-46},{1227,-46},{1225,-57},{1225,-56},{1227,-45},{1230,-35},{1231,-35},{1224,-33},{1160,-34},{1160,-35},{1163,-36},{1164,-34},{1164,-37},{1194,-35},{1224,-35},{1224,-34},{1225,-35},{1163,-35},{1163,-34},{1161,-34},{1161,-30},{1162,-30},{1161,-29},{1162,-29},{1162,-31},{1226,-31},{1225,-31},{1224,-31},{1224,-30},{1223,-30},{1202,-30},{1166,-23},{1165,-26},{1163,-25},{1164,-26},{1163,-30},{1161,-28},{1163,-31},{1146,-42},{1145,-33},{1144,-35},{1145,-31},{1153,-21},{1154,-15},{1156,-15},{1158,-12},{1154,-8},{1153,0},{1149,-1},{1149,3},{1151,4},{1149,8},{1144,5},{1137,6},{1141,15},{1146,14},{1147,19},{1149,19},{1148,23},{1152,25},{1151,28},{1153,31},{1155,31},{1156,34},{1156,39},{1159,44},{1161,43},{1162,44},{1172,44},{1176,42},{1174,41},{1178,37},{1175,37},{1172,36},{1172,35},{1173,32},{1177,28},{1176,28},{1178,20},{1178,18},{1190,10},{1188,8},{1184,8},{1177,8},{1175,2},{1176,-4},{1174,-7},{1176,-8},{1169,-13},{1168,-14},{1162,-18},{1164,-18},{1163,-21},{1224,-32},{1223,-33},{1222,-34},{1222,-36},{1227,-39},{1225,-40},{1227,-42},{1228,-41},{1229,-44},{1227,-43},{1226,-44},{1221,-45},{1216,-41},{1209,-35},{1211,-32},{1211,-26},{1207,-26},{1204,-33},{1203,-41},{1205,-47},{1203,-51},{1205,-56},{1203,-55},{1198,-57},{1194,-56},{1194,-53},{1196,-40},{1189,-36},{1188,-31},{1189,-29},{1188,-28},{1191,-25},{1191,-22},{1193,-19},{1193,-12},{1197,-6},{1199,-9},{1198,-1},{1196,0},{1198,2},{1199,2},{1200,7},{1203,10},{1206,8},{1208,10},{1208,13},{1215,13},{1216,11},{1224,10},{1228,8},{1230,10},{1239,8},{1246,12},{1245,14},{1248,15},{1252,17},{1252,15},{1245,4},{1236,3},{1233,3},{1231,5},{1218,4},{1215,6},{1211,4},{1205,5},{1201,2},{1201,-6},{1203,-9},{1205,-10},{1207,-14},{1211,-14},{1216,-8},{1219,-10},{1222,-8},{1230,-7},{1227,-7},{1231,-6},{1234,-7},{1233,-10},{1231,-8},{1228,-9},{1224,-15},{1213,-18},{1223,-29},{1222,-30},{1225,-32},{1239,-56},{1238,-56},{1238,-55},{1239,-55},{1185,-55},{1193,-55},{1236,-54},{1244,-53},{1243,-53},{1235,-54},{1235,-53},{1236,-53},{1179,-53},{1179,-52},{1179,-54},{1180,-54},{1218,-54},{1218,-53},{1217,-53},{1227,-53},{1227,-52},{1221,-53},{1171,-51},{1146,-51},{1170,-51},{1170,-50},{1177,-52},{1218,-51},{1182,-51},{1181,-51},{1204,-51},{1193,-51},{1179,-51},{1192,-54},{1226,-54},{1184,-54},{1192,-55},{1186,-55},{1221,-55},{1225,-55},{1237,-55},{1220,-55},{1219,-51},{1221,-52},{1229,-45},{1231,-44},{1229,-52},{1232,-53},{1227,-57},{1226,-55},{1228,-52},{1227,-50},{1225,-53},{1223,-54},{1224,-51}}}, - {"America/Monterrey",90,{{-977,250},{-976,250},{-977,249},{-977,248},{-976,246},{-977,245},{-977,246},{-1027,251},{-1025,245},{-1033,245},{-1039,241},{-1038,237},{-1041,234},{-1043,223},{-1048,227},{-1050,225},{-1049,229},{-1057,233},{-1060,242},{-1062,244},{-1065,243},{-1071,253},{-1071,256},{-1065,258},{-1064,261},{-1065,264},{-1062,264},{-1060,268},{-1053,265},{-1051,265},{-1046,264},{-1042,268},{-1036,267},{-1040,279},{-1034,288},{-1029,288},{-1026,291},{-1025,295},{-1016,295},{-1009,289},{-1005,281},{-998,274},{-997,269},{-995,267},{-992,262},{-975,256},{-972,256},{-975,250},{-974,254},{-975,255},{-976,253},{-977,254},{-978,254},{-978,250},{-976,249},{-978,248},{-978,246},{-979,245},{-977,244},{-978,240},{-977,243},{-978,223},{-982,225},{-989,223},{-992,224},{-994,227},{-1000,228},{-999,230},{-1001,232},{-1004,232},{-1004,237},{-1008,246},{-1012,248},{-1016,248},{-1018,250},{-1023,252},{-977,241},{-978,241},{-977,242},{-978,242},{-978,245},{-977,247},{-976,247},{-976,248},{-975,254},{-975,251},{-975,252},{-977,252},{-977,253},{-975,253}}}, - {"Europe/Amsterdam",89,{{42,514},{39,512},{34,513},{35,514},{41,514},{37,516},{37,517},{39,517},{39,518},{38,517},{41,517},{44,517},{43,517},{40,518},{43,518},{40,517},{50,533},{51,533},{49,532},{52,533},{52,534},{56,534},{55,534},{56,535},{60,535},{57,534},{54,531},{48,530},{47,530},{49,531},{66,535},{66,536},{65,535},{64,535},{65,536},{61,534},{61,535},{62,535},{63,535},{49,524},{60,517},{62,514},{61,512},{62,512},{59,511},{61,509},{60,508},{57,508},{58,512},{52,513},{50,515},{45,515},{44,514},{34,515},{38,516},{43,515},{40,516},{42,516},{41,516},{43,516},{45,517},{46,517},{41,518},{40,520},{46,525},{54,522},{58,524},{59,526},{56,527},{57,528},{54,529},{56,533},{67,535},{72,532},{71,526},{67,526},{71,524},{67,521},{68,520},{61,519},{51,525},{56,524},{54,523},{51,524},{57,526},{59,525},{53,527},{50,526},{50,524}}}, - {"America/St_Lucia",4,{{-609,141},{-609,139},{-609,137},{-611,139}}}, - {"Europe/Uzhgorod",12,{{229,490},{239,485},{241,485},{241,484},{243,484},{246,481},{242,479},{232,481},{229,480},{228,481},{221,484},{226,491}}}, - {"America/Indiana/Marengo",4,{{-864,381},{-867,383},{-867,384},{-863,384}}}, - {"Pacific/Saipan",32,{{1452,142},{1453,142},{1451,141},{1456,149},{1456,148},{1455,148},{1455,149},{1457,150},{1456,151},{1458,151},{1457,152},{1458,153},{1458,152},{1461,160},{1457,164},{1457,163},{1456,164},{1458,167},{1459,169},{1458,169},{1458,173},{1459,173},{1458,176},{1458,181},{1457,180},{1458,182},{1457,188},{1457,187},{1456,188},{1454,197},{1452,200},{1449,205}}}, - {"America/Bogota",172,{{-789,18},{-784,25},{-785,25},{-784,26},{-788,18},{-787,18},{-783,27},{-783,26},{-780,26},{-780,27},{-778,27},{-778,28},{-789,15},{-789,16},{-790,16},{-817,125},{-817,126},{-814,134},{-814,133},{-742,113},{-762,94},{-759,94},{-759,97},{-759,98},{-758,102},{-758,98},{-757,102},{-756,103},{-756,104},{-755,104},{-755,103},{-775,61},{-775,62},{-774,54},{-774,51},{-774,52},{-778,71},{-769,82},{-770,82},{-769,85},{-816,40},{-774,34},{-772,37},{-771,37},{-774,39},{-773,40},{-772,40},{-773,41},{-775,41},{-774,41},{-772,38},{-771,38},{-694,-10},{-694,-13},{-699,-42},{-703,-38},{-707,-38},{-700,-28},{-703,-25},{-706,-25},{-710,-22},{-714,-24},{-717,-21},{-721,-25},{-729,-25},{-732,-23},{-731,-18},{-735,-17},{-736,-13},{-743,-10},{-744,-6},{-748,-2},{-756,0},{-763,4},{-766,2},{-774,4},{-777,8},{-780,8},{-786,18},{-787,22},{-782,27},{-778,26},{-776,28},{-777,29},{-777,31},{-770,39},{-773,38},{-772,41},{-773,47},{-774,55},{-775,55},{-772,58},{-773,66},{-779,72},{-777,77},{-776,75},{-772,79},{-774,86},{-768,81},{-769,79},{-768,79},{-768,84},{-769,86},{-763,89},{-761,93},{-756,94},{-756,96},{-757,97},{-755,102},{-757,101},{-753,108},{-749,111},{-743,110},{-741,114},{-733,113},{-722,119},{-722,122},{-719,122},{-717,125},{-712,123},{-711,120},{-720,117},{-722,112},{-725,111},{-729,105},{-729,98},{-734,92},{-730,93},{-729,91},{-728,91},{-727,86},{-724,84},{-724,74},{-722,74},{-720,70},{-701,70},{-694,61},{-678,63},{-676,62},{-674,60},{-679,53},{-679,45},{-676,38},{-673,34},{-679,29},{-679,28},{-676,28},{-672,24},{-669,12},{-671,12},{-671,17},{-674,21},{-679,18},{-682,20},{-683,18},{-681,17},{-699,17},{-699,11},{-693,11},{-691,9},{-692,6},{-695,7},{-700,6},{-701,-1},{-696,-5},{-782,29},{-782,30},{-775,33},{-775,42},{-774,42},{-774,43},{-775,43}}}, - {"America/Indiana/Vevay",4,{{-849,388},{-852,387},{-852,389},{-848,389}}}, - {"America/Guatemala",26,{{-903,138},{-902,138},{-913,139},{-918,142},{-922,145},{-921,151},{-922,153},{-917,161},{-904,161},{-904,164},{-914,172},{-910,173},{-910,178},{-891,178},{-892,159},{-888,159},{-886,157},{-885,158},{-886,160},{-882,157},{-892,151},{-892,146},{-896,144},{-895,142},{-900,139},{-901,137}}}, - {"America/Puerto_Rico",20,{{-665,179},{-679,181},{-678,181},{-656,181},{-655,182},{-653,181},{-654,181},{-656,183},{-652,183},{-653,183},{-660,184},{-656,184},{-656,182},{-659,180},{-672,180},{-673,184},{-671,185},{-675,184},{-653,184},{-662,185}}}, - {"America/Marigot",3,{{-630,181},{-631,181},{-632,181}}}, - {"Africa/Juba",68,{{350,60},{353,53},{359,53},{358,48},{359,46},{344,46},{335,37},{330,39},{324,37},{322,35},{318,38},{315,37},{312,38},{309,35},{308,37},{306,36},{305,39},{302,39},{296,47},{295,47},{292,43},{288,46},{284,43},{278,46},{278,48},{273,52},{272,58},{265,61},{265,62},{263,65},{264,66},{252,75},{253,78},{249,82},{242,83},{242,87},{246,89},{248,98},{251,103},{258,104},{263,97},{266,95},{279,96},{280,93},{287,93},{289,97},{295,98},{295,101},{299,103},{308,97},{312,98},{325,111},{323,117},{321,120},{327,120},{327,122},{332,122},{331,107},{339,101},{339,95},{341,95},{341,86},{338,84},{332,84},{330,79},{339,75},{342,70},{350,65}}}, - {"America/Costa_Rica",60,{{-870,56},{-871,55},{-839,87},{-836,89},{-836,90},{-859,108},{-859,109},{-851,95},{-847,96},{-849,98},{-850,97},{-851,96},{-853,98},{-857,99},{-858,102},{-858,105},{-856,106},{-860,109},{-857,109},{-856,112},{-849,109},{-847,111},{-844,110},{-839,107},{-837,108},{-837,109},{-833,102},{-826,95},{-829,96},{-829,95},{-829,91},{-827,89},{-829,88},{-828,85},{-831,83},{-829,83},{-829,81},{-829,80},{-831,84},{-832,86},{-835,87},{-833,84},{-836,85},{-837,86},{-835,89},{-843,95},{-845,95},{-847,100},{-848,100},{-851,102},{-852,102},{-853,103},{-854,103},{-852,100},{-849,99},{-848,98},{-851,101},{-852,101},{-851,100},{-850,100}}}, - {"America/Caracas",202,{{-609,86},{-608,86},{-606,86},{-607,86},{-606,87},{-607,88},{-606,88},{-607,89},{-607,91},{-607,92},{-610,86},{-607,87},{-608,87},{-609,87},{-608,88},{-609,88},{-609,89},{-608,89},{-610,88},{-667,119},{-669,119},{-667,120},{-610,89},{-608,90},{-608,91},{-609,90},{-608,92},{-609,92},{-608,93},{-718,92},{-718,94},{-612,96},{-613,96},{-614,97},{-618,98},{-676,120},{-677,120},{-668,119},{-666,119},{-623,98},{-622,100},{-616,98},{-616,99},{-610,96},{-610,92},{-600,86},{-598,83},{-607,75},{-606,72},{-603,71},{-607,68},{-612,67},{-611,62},{-614,60},{-606,50},{-610,45},{-613,45},{-615,43},{-627,40},{-627,37},{-629,36},{-634,40},{-635,39},{-640,39},{-641,42},{-646,42},{-648,43},{-645,39},{-642,36},{-640,25},{-634,24},{-633,23},{-640,20},{-642,15},{-643,14},{-644,15},{-651,11},{-655,6},{-656,10},{-663,7},{-669,12},{-672,24},{-676,28},{-679,28},{-673,34},{-676,38},{-679,45},{-679,53},{-676,55},{-675,62},{-678,63},{-694,61},{-701,70},{-720,70},{-722,74},{-725,75},{-724,83},{-727,86},{-728,91},{-729,91},{-730,93},{-732,92},{-734,92},{-729,98},{-729,105},{-725,111},{-722,112},{-720,117},{-713,119},{-720,116},{-716,107},{-721,98},{-720,94},{-717,94},{-717,91},{-712,92},{-711,93},{-710,97},{-716,108},{-714,108},{-715,110},{-700,114},{-701,116},{-700,115},{-700,117},{-702,116},{-703,119},{-700,122},{-696,115},{-688,114},{-684,112},{-681,105},{-662,106},{-658,102},{-651,100},{-642,105},{-638,104},{-636,105},{-643,107},{-619,108},{-623,105},{-627,106},{-629,105},{-625,102},{-623,99},{-624,99},{-624,100},{-623,100},{-622,101},{-649,101},{-619,106},{-645,102},{-646,103},{-645,103},{-647,103},{-646,102},{-648,103},{-650,102},{-649,102},{-658,103},{-659,102},{-659,103},{-716,110},{-637,112},{-631,114},{-644,117},{-668,117},{-669,118},{-667,118},{-644,118},{-717,110},{-639,107},{-640,108},{-639,108},{-645,104},{-644,103},{-644,104},{-715,106},{-679,105},{-683,108},{-642,108},{-641,108},{-716,109},{-715,109},{-654,109},{-653,110},{-652,109},{-653,109},{-654,110},{-682,108},{-643,111},{-640,110},{-639,112},{-638,110},{-641,109},{-644,110},{-666,118},{-661,118},{-662,118},{-646,118},{-646,119},{-661,119}}}, - {"Pacific/Nauru",1,{{1669,-5}}}, - {"Europe/Minsk",61,{{300,515},{293,514},{291,516},{288,514},{283,517},{277,515},{277,516},{273,516},{272,518},{253,520},{244,519},{242,517},{237,517},{236,515},{235,517},{237,521},{232,523},{235,526},{239,527},{239,532},{235,540},{248,540},{248,541},{255,543},{255,542},{258,542},{256,543},{258,548},{269,553},{265,553},{266,557},{271,559},{276,558},{281,562},{294,560},{294,558},{295,557},{300,559},{305,558},{310,556},{308,553},{310,551},{308,548},{312,547},{311,545},{313,543},{319,540},{318,538},{325,537},{325,536},{328,535},{322,531},{314,532},{313,530},{316,528},{316,523},{318,521},{309,521},{305,516},{307,513},{306,513}}}, - {"America/Belem",244,{{-503,-18},{-502,-18},{-493,-20},{-493,-19},{-492,-19},{-498,-19},{-497,-19},{-492,-18},{-504,-19},{-504,-18},{-503,-19},{-493,-21},{-494,-20},{-498,-18},{-497,-18},{-501,-18},{-500,-18},{-495,-18},{-496,-18},{-496,-17},{-500,-17},{-501,-17},{-489,-17},{-494,-17},{-494,-16},{-492,-16},{-491,-16},{-489,-16},{-489,-15},{-485,-14},{-485,-13},{-485,-15},{-484,-15},{-483,-15},{-490,-16},{-495,-17},{-493,-17},{-492,-17},{-493,-16},{-485,-12},{-461,-12},{-461,-11},{-462,-10},{-462,-11},{-465,-9},{-464,-9},{-466,-9},{-466,-8},{-464,-10},{-463,-10},{-465,-10},{-496,2},{-497,2},{-496,3},{-496,4},{-499,13},{-499,12},{-502,19},{-505,20},{-505,21},{-504,22},{-503,19},{-504,18},{-505,23},{-503,7},{-503,8},{-501,8},{-502,9},{-501,9},{-500,9},{-500,10},{-499,10},{-500,8},{-501,7},{-502,8},{-502,7},{-507,1},{-509,1},{-503,6},{-506,3},{-502,3},{-502,2},{-501,3},{-504,2},{-505,2},{-504,6},{-503,3},{-501,6},{-500,5},{-507,0},{-502,6},{-514,-4},{-512,-1},{-512,-3},{-514,-5},{-506,-1},{-508,-4},{-510,-6},{-511,-7},{-507,-6},{-507,-3},{-504,-1},{-484,-3},{-485,-9},{-494,-22},{-486,-13},{-485,-16},{-485,-11},{-483,-11},{-482,-8},{-479,-6},{-477,-5},{-476,-7},{-476,-6},{-474,-8},{-475,-6},{-473,-6},{-472,-8},{-471,-7},{-471,-9},{-468,-7},{-467,-9},{-466,-10},{-463,-11},{-462,-9},{-463,-17},{-462,-18},{-463,-21},{-467,-27},{-466,-29},{-471,-39},{-476,-46},{-488,-54},{-484,-54},{-481,-56},{-483,-58},{-482,-59},{-487,-67},{-492,-69},{-492,-73},{-494,-75},{-492,-78},{-493,-84},{-501,-93},{-502,-98},{-526,-97},{-525,-96},{-522,-96},{-520,-93},{-521,-89},{-528,-85},{-529,-79},{-526,-72},{-520,-67},{-524,-63},{-529,-50},{-527,-45},{-526,-38},{-522,-32},{-519,-35},{-518,-32},{-520,-28},{-523,-17},{-519,-15},{-518,-12},{-521,-12},{-525,-9},{-526,-4},{-530,0},{-531,7},{-534,9},{-534,13},{-544,18},{-547,18},{-548,20},{-548,25},{-543,22},{-541,21},{-538,24},{-529,22},{-515,42},{-515,44},{-512,41},{-512,38},{-511,39},{-511,33},{-507,21},{-505,18},{-500,17},{-499,14},{-501,12},{-499,11},{-505,7},{-506,4},{-486,-12},{-486,-10},{-468,-8},{-467,-8},{-467,-10},{-469,-8},{-469,-7},{-472,-7},{-480,-7},{-474,-7},{-475,-7},{-487,-2},{-487,-1},{-488,-2},{-489,-2},{-489,-1},{-490,-2},{-490,-1},{-490,0},{-493,-1},{-494,-1},{-491,-1},{-492,-1},{-498,0},{-495,1},{-493,0},{-497,-1},{-508,-6},{-513,-5},{-512,-5},{-512,-4},{-511,-3},{-511,-2},{-505,-2},{-505,-1},{-513,-4},{-513,-3},{-511,-4},{-511,-1},{-506,0},{-500,0},{-502,-1},{-502,0},{-509,-1},{-509,0},{-508,0},{-504,0},{-503,0},{-506,2},{-504,1}}}, - {"America/Cancun",51,{{-875,197},{-868,206},{-867,206},{-870,203},{-869,206},{-868,212},{-868,213},{-867,212},{-868,215},{-876,194},{-875,196},{-877,196},{-877,197},{-875,193},{-875,194},{-873,188},{-881,188},{-879,182},{-879,183},{-874,184},{-874,185},{-882,186},{-873,185},{-873,186},{-873,184},{-874,187},{-874,186},{-872,186},{-872,187},{-873,187},{-875,215},{-870,216},{-867,211},{-874,202},{-875,198},{-877,195},{-874,196},{-877,193},{-876,192},{-878,182},{-881,185},{-881,189},{-883,185},{-885,185},{-888,179},{-890,180},{-891,178},{-894,178},{-894,197},{-878,207},{-875,210}}}, - {"America/Hermosillo",45,{{-1125,293},{-1124,293},{-1123,292},{-1122,290},{-1123,287},{-1126,289},{-1125,292},{-1132,310},{-1139,316},{-1140,316},{-1095,267},{-1099,270},{-1100,271},{-1105,273},{-1106,273},{-1106,274},{-1108,279},{-1114,280},{-1123,284},{-1126,287},{-1125,287},{-1150,319},{-1150,322},{-1148,325},{-1111,313},{-1088,313},{-1086,300},{-1087,294},{-1086,283},{-1091,283},{-1091,282},{-1087,275},{-1085,268},{-1093,263},{-1094,267},{-1098,268},{-1106,276},{-1105,279},{-1111,279},{-1122,293},{-1131,307},{-1130,312},{-1136,313},{-1140,317},{-1142,315}}}, - {"Asia/Chongqing",321,{{1098,183},{1089,184},{1106,191},{1106,192},{1105,187},{1105,191},{1094,182},{1113,200},{1105,200},{1106,199},{1107,202},{1109,200},{1110,196},{1108,196},{1105,192},{1105,188},{1104,187},{1101,184},{1098,184},{1096,182},{1087,185},{1086,193},{1093,197},{1092,197},{1093,199},{1095,198},{1097,200},{1100,199},{1104,201},{1106,200},{1101,200},{1102,200},{1125,219},{1128,220},{1130,218},{1130,219},{1122,215},{1122,216},{1128,216},{1129,216},{1121,216},{1121,217},{1126,216},{1127,216},{1125,216},{1126,217},{1127,217},{1124,217},{1125,217},{1129,218},{1128,217},{1096,215},{1098,215},{1097,215},{1081,215},{1082,215},{1088,218},{1120,218},{1119,218},{1089,217},{1091,216},{1090,216},{1083,216},{1084,217},{1118,216},{1118,217},{1120,216},{1083,217},{1088,217},{1100,219},{1096,217},{1095,215},{1092,214},{1091,217},{1089,216},{1089,218},{1087,216},{1085,219},{1085,216},{1084,218},{1082,216},{1074,216},{1070,219},{1067,220},{1066,225},{1068,228},{1062,230},{1059,229},{1053,234},{1048,231},{1047,228},{1044,227},{1043,228},{1041,228},{1040,225},{1036,228},{1035,226},{1033,228},{1031,224},{1025,228},{1023,224},{1017,225},{1015,222},{1018,218},{1018,212},{1013,212},{1011,218},{1007,215},{1002,214},{1002,217},{1000,217},{1000,221},{992,222},{994,225},{993,228},{996,229},{995,231},{989,232},{989,236},{987,240},{989,242},{981,241},{976,238},{975,239},{978,242},{977,244},{975,244},{976,247},{978,248},{978,253},{987,259},{986,261},{987,261},{988,266},{987,276},{984,277},{983,275},{981,282},{983,284},{984,281},{987,282},{987,290},{989,288},{990,292},{991,292},{990,308},{986,313},{989,314},{984,318},{982,324},{974,327},{974,330},{978,334},{975,335},{974,338},{977,340},{978,339},{984,339},{984,341},{987,340},{990,342},{988,347},{991,345},{993,347},{990,350},{993,351},{992,353},{993,357},{989,362},{993,367},{992,371},{995,371},{995,375},{997,377},{994,380},{998,381},{993,383},{989,383},{989,384},{982,387},{974,391},{976,393},{976,397},{970,398},{969,396},{966,398},{970,408},{975,407},{982,410},{976,414},{978,417},{971,428},{995,426},{1009,426},{1018,425},{1021,422},{1033,419},{1045,419},{1045,417},{1050,416},{1075,425},{1088,424},{1102,426},{1112,434},{1118,429},{1121,425},{1126,424},{1130,420},{1134,422},{1141,420},{1141,421},{1145,421},{1144,422},{1146,423},{1148,422},{1142,418},{1142,415},{1139,414},{1140,412},{1138,411},{1141,408},{1141,405},{1135,403},{1130,404},{1128,402},{1123,403},{1119,396},{1114,396},{1113,394},{1111,394},{1112,393},{1109,385},{1105,382},{1108,377},{1106,377},{1107,373},{1104,370},{1106,356},{1103,347},{1105,344},{1104,343},{1106,342},{1106,339},{1110,336},{1110,333},{1107,331},{1105,333},{1095,332},{1094,332},{1098,331},{1098,329},{1101,328},{1102,326},{1096,326},{1095,323},{1096,317},{1101,314},{1102,310},{1093,305},{1091,306},{1084,305},{1086,302},{1085,299},{1084,299},{1084,298},{1085,297},{1086,299},{1089,296},{1089,293},{1091,294},{1093,291},{1092,286},{1093,286},{1093,278},{1095,276},{1088,271},{1095,271},{1095,268},{1093,267},{1094,266},{1093,263},{1095,263},{1095,260},{1097,259},{1100,262},{1103,260},{1106,263},{1113,263},{1112,259},{1115,259},{1110,249},{1114,251},{1114,247},{1120,248},{1121,244},{1119,242},{1119,240},{1116,238},{1114,233},{1116,232},{1118,234},{1123,235},{1123,228},{1127,226},{1130,220},{1129,219},{1126,218},{1124,221},{1119,219},{1119,217},{1117,218},{1115,215},{1113,221},{1117,225},{1114,224},{1111,227},{1107,226},{1108,223},{1106,222},{1103,222},{1104,219}}}, - {"Asia/Beirut",15,{{359,334},{356,333},{355,331},{351,331},{357,343},{360,347},{365,346},{363,345},{366,344},{366,342},{363,339},{364,338},{360,338},{359,336},{361,336}}}, - {"Europe/Gibraltar",4,{{-53,361},{-54,361},{-54,362},{-53,362}}}, - {"Asia/Urumqi",241,{{1091,210},{1091,211},{1112,214},{1106,213},{1102,210},{1104,211},{1104,212},{1106,211},{1106,212},{1105,211},{1106,214},{1108,214},{1105,203},{1106,204},{1104,206},{1104,207},{1103,207},{1105,206},{1105,207},{1092,209},{1106,209},{1105,209},{1106,210},{1098,208},{1097,208},{1103,211},{982,282},{976,285},{973,282},{971,284},{963,284},{966,288},{965,291},{962,289},{961,291},{964,293},{961,295},{953,291},{947,293},{944,292},{939,288},{933,286},{932,284},{927,281},{927,279},{920,277},{917,278},{917,279},{913,281},{910,280},{899,283},{894,280},{890,273},{888,274},{888,280},{886,281},{879,278},{871,278},{867,281},{864,279},{862,282},{860,279},{856,283},{851,283},{851,287},{849,286},{842,289},{842,292},{839,293},{836,292},{832,296},{822,301},{820,305},{824,306},{826,309},{831,305},{832,307},{830,309},{833,313},{832,314},{825,317},{832,320},{832,327},{828,335},{820,343},{823,346},{824,350},{824,352},{820,352},{821,354},{824,357},{829,357},{825,363},{826,366},{824,369},{825,395},{820,395},{820,405},{818,408},{820,411},{826,413},{827,415},{826,417},{830,419},{830,424},{827,426},{827,429},{834,431},{826,433},{825,436},{829,435},{829,437},{833,437},{850,435},{839,440},{817,444},{818,446},{827,448},{826,450},{827,452},{826,454},{823,456},{830,472},{840,470},{847,470},{848,468},{855,471},{857,472},{855,479},{857,484},{866,485},{869,491},{878,492},{879,490},{877,489},{881,487},{880,487},{880,485},{885,484},{890,479},{896,480},{898,478},{901,479},{909,470},{911,467},{909,463},{910,460},{907,455},{909,452},{935,450},{947,443},{954,443},{953,440},{956,440},{959,433},{964,427},{971,428},{978,417},{976,414},{982,410},{975,407},{970,408},{966,398},{969,396},{970,398},{976,397},{976,393},{974,391},{982,387},{989,384},{989,383},{993,383},{998,381},{994,380},{997,377},{995,375},{995,371},{992,371},{993,367},{989,362},{993,357},{992,353},{993,351},{990,350},{993,347},{991,345},{988,347},{990,342},{987,340},{984,341},{984,339},{978,339},{977,340},{974,338},{975,335},{978,334},{974,330},{974,327},{982,324},{984,318},{989,314},{986,313},{990,307},{991,292},{990,292},{989,288},{987,290},{987,282},{984,281},{983,284},{1114,216},{1113,214},{1110,215},{1108,215},{1105,214},{1104,214},{1104,215},{1103,214},{1102,211},{1102,209},{1104,208},{1105,204},{1103,202},{1099,202},{1099,204},{1100,204},{1098,205},{1097,209},{1098,213},{1100,215},{1098,215},{1097,216},{1100,219},{1104,219},{1103,222},{1108,223},{1108,226},{1111,227},{1114,224},{1117,225},{1113,221}}}, - {"America/Mazatlan",171,{{-1144,271},{-1121,272},{-1121,273},{-1120,272},{-1120,274},{-1120,275},{-1148,184},{-1147,184},{-1148,183},{-1110,188},{-1109,188},{-1110,187},{-1111,188},{-1121,190},{-1108,193},{-1066,217},{-1065,216},{-1065,215},{-1066,216},{-1067,217},{-1067,218},{-1059,219},{-1063,213},{-1062,213},{-1063,215},{-1065,214},{-1080,248},{-1081,248},{-1080,250},{-1081,250},{-1081,249},{-1080,249},{-1081,251},{-1082,250},{-1083,251},{-1082,251},{-1084,251},{-1084,252},{-1083,252},{-1082,252},{-1152,279},{-1142,277},{-1142,278},{-1142,279},{-1106,248},{-1106,249},{-1104,246},{-1121,249},{-1122,250},{-1121,253},{-1122,248},{-1121,247},{-1121,245},{-1123,248},{-1121,250},{-1107,252},{-1107,250},{-1107,251},{-1105,249},{-1050,230},{-1049,228},{-1050,225},{-1048,227},{-1046,225},{-1043,225},{-1044,221},{-1041,218},{-1042,215},{-1039,214},{-1042,212},{-1043,207},{-1047,210},{-1052,207},{-1054,209},{-1052,211},{-1052,215},{-1057,220},{-1058,226},{-1070,239},{-1080,247},{-1088,254},{-1087,255},{-1088,256},{-1089,255},{-1094,256},{-1094,259},{-1093,263},{-1084,270},{-1080,269},{-1078,262},{-1074,261},{-1071,257},{-1071,252},{-1069,248},{-1065,243},{-1062,244},{-1060,242},{-1057,233},{-1098,241},{-1099,242},{-1099,244},{-1098,242},{-1088,255},{-1117,244},{-1117,243},{-1120,245},{-1119,245},{-1104,245},{-1103,245},{-1103,244},{-1104,244},{-1115,243},{-1116,244},{-1090,254},{-1121,252},{-1107,253},{-1121,255},{-1142,280},{-1128,280},{-1122,272},{-1120,271},{-1120,270},{-1118,266},{-1118,269},{-1114,265},{-1113,258},{-1107,248},{-1107,246},{-1106,243},{-1103,242},{-1102,244},{-1095,236},{-1095,231},{-1100,229},{-1103,236},{-1116,246},{-1118,245},{-1120,248},{-1121,259},{-1132,268},{-1131,269},{-1132,270},{-1133,268},{-1136,267},{-1138,270},{-1144,272},{-1145,274},{-1151,278},{-1143,279},{-1141,276},{-1139,277},{-1141,277},{-1121,256},{-1108,256},{-1108,257},{-1112,258},{-1112,260},{-1111,261},{-1121,257},{-1110,256},{-1111,257},{-1110,257},{-1113,261},{-1131,266},{-1114,266},{-1131,267},{-1133,267},{-1132,267},{-1132,269},{-1119,271},{-1119,270}}} -}; - -struct tzoffsets_t { - char *name; - double time; - double dst; -} tzoffsets[] = { - { "Africa/Abidjan", 0, 0 }, - { "Africa/Accra", 0, 0 }, - { "Africa/Addis_Ababa", 3, 3 }, - { "Africa/Algiers", 1, 1 }, - { "Africa/Asmara", 3, 3 }, - { "Africa/Asmera", 3, 3 }, - { "Africa/Bamako", 0, 0 }, - { "Africa/Bangui", 1, 1 }, - { "Africa/Banjul", 0, 0 }, - { "Africa/Bissau", 0, 0 }, - { "Africa/Blantyre", 2, 2 }, - { "Africa/Brazzaville", 1, 1 }, - { "Africa/Bujumbura", 2, 2 }, - { "Africa/Cairo", 2, 2 }, - { "Africa/Casablanca", 0, 1 }, - { "Africa/Ceuta", 1, 2 }, - { "Africa/Conakry", 0, 0 }, - { "Africa/Dakar", 0, 0 }, - { "Africa/Dar_es_Salaam", 3, 3 }, - { "Africa/Djibouti", 3, 3 }, - { "Africa/Douala", 1, 1 }, - { "Africa/El_Aaiun", 0, 1 }, - { "Africa/Freetown", 0, 0 }, - { "Africa/Gaborone", 2, 2 }, - { "Africa/Harare", 2, 2 }, - { "Africa/Johannesburg", 2, 2 }, - { "Africa/Juba", 3, 3 }, - { "Africa/Kampala", 3, 3 }, - { "Africa/Khartoum", 3, 3 }, - { "Africa/Kigali", 2, 2 }, - { "Africa/Kinshasa", 1, 1 }, - { "Africa/Lagos", 1, 1 }, - { "Africa/Libreville", 1, 1 }, - { "Africa/Lome", 0, 0 }, - { "Africa/Luanda", 1, 1 }, - { "Africa/Lubumbashi", 2, 2 }, - { "Africa/Lusaka", 2, 2 }, - { "Africa/Malabo", 1, 1 }, - { "Africa/Maputo", 2, 2 }, - { "Africa/Maseru", 2, 2 }, - { "Africa/Mbabane", 2, 2 }, - { "Africa/Mogadishu", 3, 3 }, - { "Africa/Monrovia", 0, 0 }, - { "Africa/Nairobi", 3, 3 }, - { "Africa/Ndjamena", 1, 1 }, - { "Africa/Niamey", 1, 1 }, - { "Africa/Nouakchott", 0, 0 }, - { "Africa/Ouagadougou", 0, 0 }, - { "Africa/Porto-Novo", 1, 1 }, - { "Africa/Sao_Tome", 0, 0 }, - { "Africa/Timbuktu", 0, 0 }, - { "Africa/Tripoli", 2, 2 }, - { "Africa/Tunis", 1, 1 }, - { "Africa/Windhoek", 1, 2 }, - { "America/Adak", -10, -9 }, - { "America/Anchorage", -9, -8 }, - { "America/Anguilla", -4, -4 }, - { "America/Antigua", -4, -4 }, - { "America/Araguaina", -3, -3 }, - { "America/Argentina/Buenos_Aires", -3, -3 }, - { "America/Argentina/Catamarca", -3, -3 }, - { "America/Argentina/ComodRivadavia", -3, -3 }, - { "America/Argentina/Cordoba", -3, -3 }, - { "America/Argentina/Jujuy", -3, -3 }, - { "America/Argentina/La_Rioja", -3, -3 }, - { "America/Argentina/Mendoza", -3, -3 }, - { "America/Argentina/Rio_Gallegos", -3, -3 }, - { "America/Argentina/Salta", -3, -3 }, - { "America/Argentina/San_Juan", -3, -3 }, - { "America/Argentina/San_Luis", -3, -3 }, - { "America/Argentina/Tucuman", -3, -3 }, - { "America/Argentina/Ushuaia", -3, -3 }, - { "America/Aruba", -4, -4 }, - { "America/Asuncion", -4, -3 }, - { "America/Atikokan", -5, -5 }, - { "America/Atka", -10, -9 }, - { "America/Bahia", -3, -3 }, - { "America/Bahia_Banderas", -6, -5 }, - { "America/Barbados", -4, -4 }, - { "America/Belem", -3, -3 }, - { "America/Belize", -6, -6 }, - { "America/Blanc-Sablon", -4, -4 }, - { "America/Boa_Vista", -4, -4 }, - { "America/Bogota", -5, -5 }, - { "America/Boise", -7, -6 }, - { "America/Buenos_Aires", -3, -3 }, - { "America/Cambridge_Bay", -7, -6 }, - { "America/Campo_Grande", -4, -3 }, - { "America/Cancun", -5, -5 }, - { "America/Caracas", -4, -4 }, - { "America/Catamarca", -3, -3 }, - { "America/Cayenne", -3, -3 }, - { "America/Cayman", -5, -5 }, - { "America/Chicago", -6, -5 }, - { "America/Chihuahua", -7, -6 }, - { "America/Coral_Harbour", -5, -5 }, - { "America/Cordoba", -3, -3 }, - { "America/Costa_Rica", -6, -6 }, - { "America/Creston", -7, -7 }, - { "America/Cuiaba", -4, -3 }, - { "America/Curacao", -4, -4 }, - { "America/Danmarkshavn", 0, 0 }, - { "America/Dawson", -8, -7 }, - { "America/Dawson_Creek", -7, -7 }, - { "America/Denver", -7, -6 }, - { "America/Detroit", -5, -4 }, - { "America/Dominica", -4, -4 }, - { "America/Edmonton", -7, -6 }, - { "America/Eirunepe", -5, -5 }, - { "America/El_Salvador", -6, -6 }, - { "America/Ensenada", -8, -7 }, - { "America/Fort_Nelson", -7, -7 }, - { "America/Fort_Wayne", -5, -4 }, - { "America/Fortaleza", -3, -3 }, - { "America/Glace_Bay", -4, -3 }, - { "America/Godthab", -3, -2 }, - { "America/Goose_Bay", -4, -3 }, - { "America/Grand_Turk", -4, -4 }, - { "America/Grenada", -4, -4 }, - { "America/Guadeloupe", -4, -4 }, - { "America/Guatemala", -6, -6 }, - { "America/Guayaquil", -5, -5 }, - { "America/Guyana", -4, -4 }, - { "America/Halifax", -4, -3 }, - { "America/Havana", -5, -4 }, - { "America/Hermosillo", -7, -7 }, - { "America/Indiana/Indianapolis", -5, -4 }, - { "America/Indiana/Knox", -6, -5 }, - { "America/Indiana/Marengo", -5, -4 }, - { "America/Indiana/Petersburg", -5, -4 }, - { "America/Indiana/Tell_City", -6, -5 }, - { "America/Indiana/Vevay", -5, -4 }, - { "America/Indiana/Vincennes", -5, -4 }, - { "America/Indiana/Winamac", -5, -4 }, - { "America/Indianapolis", -5, -4 }, - { "America/Inuvik", -7, -6 }, - { "America/Iqaluit", -5, -4 }, - { "America/Jamaica", -5, -5 }, - { "America/Jujuy", -3, -3 }, - { "America/Juneau", -9, -8 }, - { "America/Kentucky/Louisville", -5, -4 }, - { "America/Kentucky/Monticello", -5, -4 }, - { "America/Knox_IN", -6, -5 }, - { "America/Kralendijk", -4, -4 }, - { "America/La_Paz", -4, -4 }, - { "America/Lima", -5, -5 }, - { "America/Los_Angeles", -8, -7 }, - { "America/Louisville", -5, -4 }, - { "America/Lower_Princes", -4, -4 }, - { "America/Maceio", -3, -3 }, - { "America/Managua", -6, -6 }, - { "America/Manaus", -4, -4 }, - { "America/Marigot", -4, -4 }, - { "America/Martinique", -4, -4 }, - { "America/Matamoros", -6, -5 }, - { "America/Mazatlan", -7, -6 }, - { "America/Mendoza", -3, -3 }, - { "America/Menominee", -6, -5 }, - { "America/Merida", -6, -5 }, - { "America/Metlakatla", -9, -8 }, - { "America/Mexico_City", -6, -5 }, - { "America/Miquelon", -3, -2 }, - { "America/Moncton", -4, -3 }, - { "America/Monterrey", -6, -5 }, - { "America/Montevideo", -3, -3 }, - { "America/Montreal", -5, -4 }, - { "America/Montserrat", -4, -4 }, - { "America/Nassau", -5, -4 }, - { "America/New_York", -5, -4 }, - { "America/Nipigon", -5, -4 }, - { "America/Nome", -9, -8 }, - { "America/Noronha", -2, -2 }, - { "America/North_Dakota/Beulah", -6, -5 }, - { "America/North_Dakota/Center", -6, -5 }, - { "America/North_Dakota/New_Salem", -6, -5 }, - { "America/Ojinaga", -7, -6 }, - { "America/Panama", -5, -5 }, - { "America/Pangnirtung", -5, -4 }, - { "America/Paramaribo", -3, -3 }, - { "America/Phoenix", -7, -7 }, - { "America/Port_of_Spain", -4, -4 }, - { "America/Port-au-Prince", -5, -5 }, - { "America/Porto_Acre", -5, -5 }, - { "America/Porto_Velho", -4, -4 }, - { "America/Puerto_Rico", -4, -4 }, - { "America/Rainy_River", -6, -5 }, - { "America/Rankin_Inlet", -6, -5 }, - { "America/Recife", -3, -3 }, - { "America/Regina", -6, -6 }, - { "America/Resolute", -6, -5 }, - { "America/Rio_Branco", -5, -5 }, - { "America/Rosario", -3, -3 }, - { "America/Santa_Isabel", -8, -7 }, - { "America/Santarem", -3, -3 }, - { "America/Santiago", -4, -3 }, - { "America/Santo_Domingo", -4, -4 }, - { "America/Sao_Paulo", -3, -2 }, - { "America/Scoresbysund", -1, 0 }, - { "America/Shiprock", -7, -6 }, - { "America/Sitka", -9, -8 }, - { "America/St_Barthelemy", -4, -4 }, - { "America/St_Johns", -3.5, -2.5 }, - { "America/St_Kitts", -4, -4 }, - { "America/St_Lucia", -4, -4 }, - { "America/St_Thomas", -4, -4 }, - { "America/St_Vincent", -4, -4 }, - { "America/Swift_Current", -6, -6 }, - { "America/Tegucigalpa", -6, -6 }, - { "America/Thule", -4, -3 }, - { "America/Thunder_Bay", -5, -4 }, - { "America/Tijuana", -8, -7 }, - { "America/Toronto", -5, -4 }, - { "America/Tortola", -4, -4 }, - { "America/Vancouver", -8, -7 }, - { "America/Virgin", -4, -4 }, - { "America/Whitehorse", -8, -7 }, - { "America/Winnipeg", -6, -5 }, - { "America/Yakutat", -9, -8 }, - { "America/Yellowknife", -7, -6 }, - { "Antarctica/Casey", 8, 8 }, - { "Antarctica/Davis", 7, 7 }, - { "Antarctica/DumontDUrville", 10, 10 }, - { "Antarctica/Macquarie", 11, 11 }, - { "Antarctica/Mawson", 5, 5 }, - { "Antarctica/McMurdo", 12, 13 }, - { "Antarctica/Palmer", -4, -3 }, - { "Antarctica/Rothera", -3, -3 }, - { "Antarctica/South_Pole", 12, 13 }, - { "Antarctica/Syowa", 3, 3 }, - { "Antarctica/Troll", 0, 2 }, - { "Antarctica/Vostok", 6, 6 }, - { "Arctic/Longyearbyen", 1, 2 }, - { "Asia/Aden", 3, 3 }, - { "Asia/Almaty", 6, 6 }, - { "Asia/Amman", 2, 3 }, - { "Asia/Anadyr", 12, 12 }, - { "Asia/Aqtau", 5, 5 }, - { "Asia/Aqtobe", 5, 5 }, - { "Asia/Ashgabat", 5, 5 }, - { "Asia/Ashkhabad", 5, 5 }, - { "Asia/Baghdad", 3, 3 }, - { "Asia/Bahrain", 3, 3 }, - { "Asia/Baku", 4, 4 }, - { "Asia/Bangkok", 7, 7 }, - { "Asia/Barnaul", 7, 7 }, - { "Asia/Beirut", 2, 3 }, - { "Asia/Bishkek", 6, 6 }, - { "Asia/Brunei", 8, 8 }, - { "Asia/Calcutta", 5.5, 5.5 }, - { "Asia/Chita", 9, 9 }, - { "Asia/Choibalsan", 8, 9 }, - { "Asia/Chongqing", 8, 8 }, - { "Asia/Chungking", 8, 8 }, - { "Asia/Colombo", 5.5, 5.5 }, - { "Asia/Dacca", 6, 6 }, - { "Asia/Damascus", 2, 3 }, - { "Asia/Dhaka", 6, 6 }, - { "Asia/Dili", 9, 9 }, - { "Asia/Dubai", 4, 4 }, - { "Asia/Dushanbe", 5, 5 }, - { "Asia/Gaza", 2, 3 }, - { "Asia/Harbin", 8, 8 }, - { "Asia/Hebron", 2, 3 }, - { "Asia/Ho_Chi_Minh", 7, 7 }, - { "Asia/Hong_Kong", 8, 8 }, - { "Asia/Hovd", 7, 8 }, - { "Asia/Irkutsk", 8, 8 }, - { "Asia/Istanbul", 2, 3 }, - { "Asia/Jakarta", 7, 7 }, - { "Asia/Jayapura", 9, 9 }, - { "Asia/Jerusalem", 2, 3 }, - { "Asia/Kabul", 4.5, 4.5 }, - { "Asia/Kamchatka", 12, 12 }, - { "Asia/Karachi", 5, 5 }, - { "Asia/Kashgar", 6, 6 }, - { "Asia/Kathmandu", 5.75, 5.75 }, - { "Asia/Katmandu", 5.75, 5.75 }, - { "Asia/Khandyga", 9, 9 }, - { "Asia/Kolkata", 5.5, 5.5 }, - { "Asia/Krasnoyarsk", 7, 7 }, - { "Asia/Kuala_Lumpur", 8, 8 }, - { "Asia/Kuching", 8, 8 }, - { "Asia/Kuwait", 3, 3 }, - { "Asia/Macao", 8, 8 }, - { "Asia/Macau", 8, 8 }, - { "Asia/Magadan", 11, 11 }, - { "Asia/Makassar", 8, 8 }, - { "Asia/Manila", 8, 8 }, - { "Asia/Muscat", 4, 4 }, - { "Asia/Nicosia", 2, 3 }, - { "Asia/Novokuznetsk", 7, 7 }, - { "Asia/Novosibirsk", 7, 7 }, - { "Asia/Omsk", 6, 6 }, - { "Asia/Oral", 5, 5 }, - { "Asia/Phnom_Penh", 7, 7 }, - { "Asia/Pontianak", 7, 7 }, - { "Asia/Pyongyang", 8.5, 8.5 }, - { "Asia/Qatar", 3, 3 }, - { "Asia/Qyzylorda", 6, 6 }, - { "Asia/Rangoon", 6.5, 6.5 }, - { "Asia/Riyadh", 3, 3 }, - { "Asia/Saigon", 7, 7 }, - { "Asia/Sakhalin", 11, 11 }, - { "Asia/Samarkand", 5, 5 }, - { "Asia/Seoul", 9, 9 }, - { "Asia/Shanghai", 8, 8 }, - { "Asia/Singapore", 8, 8 }, - { "Asia/Srednekolymsk", 11, 11 }, - { "Asia/Taipei", 8, 8 }, - { "Asia/Tashkent", 5, 5 }, - { "Asia/Tbilisi", 4, 4 }, - { "Asia/Tehran", 3.5, 4.5 }, - { "Asia/Tel_Aviv", 2, 3 }, - { "Asia/Thimbu", 6, 6 }, - { "Asia/Thimphu", 6, 6 }, - { "Asia/Tokyo", 9, 9 }, - { "Asia/Tomsk", 7, 7 }, - { "Asia/Ujung_Pandang", 8, 8 }, - { "Asia/Ulaanbaatar", 8, 9 }, - { "Asia/Ulan_Bator", 8, 9 }, - { "Asia/Urumqi", 6, 6 }, - { "Asia/Ust-Nera", 10, 10 }, - { "Asia/Vientiane", 7, 7 }, - { "Asia/Vladivostok", 10, 10 }, - { "Asia/Yakutsk", 9, 9 }, - { "Asia/Yekaterinburg", 5, 5 }, - { "Asia/Yerevan", 4, 4 }, - { "Atlantic/Azores", -1, 0 }, - { "Atlantic/Bermuda", -4, -3 }, - { "Atlantic/Canary", 0, 1 }, - { "Atlantic/Cape_Verde", -1, -1 }, - { "Atlantic/Faeroe", 0, 1 }, - { "Atlantic/Faroe", 0, 1 }, - { "Atlantic/Jan_Mayen", 1, 2 }, - { "Atlantic/Madeira", 0, 1 }, - { "Atlantic/Reykjavik", 0, 0 }, - { "Atlantic/South_Georgia", -2, -2 }, - { "Atlantic/St_Helena", 0, 0 }, - { "Atlantic/Stanley", -3, -3 }, - { "Australia/ACT", 10, 11 }, - { "Australia/Adelaide", 9.5, 10.5 }, - { "Australia/Brisbane", 10, 10 }, - { "Australia/Broken_Hill", 9.5, 10.5 }, - { "Australia/Canberra", 10, 11 }, - { "Australia/Currie", 10, 11 }, - { "Australia/Darwin", 9.5, 9.5 }, - { "Australia/Eucla", 8.75, 8.75 }, - { "Australia/Hobart", 10, 11 }, - { "Australia/LHI", 10.5, 11 }, - { "Australia/Lindeman", 10, 10 }, - { "Australia/Lord_Howe", 10.5, 11 }, - { "Australia/Melbourne", 10, 11 }, - { "Australia/North", 9.5, 9.5 }, - { "Australia/NSW", 10, 11 }, - { "Australia/Perth", 8, 8 }, - { "Australia/Queensland", 10, 10 }, - { "Australia/South", 9.5, 10.5 }, - { "Australia/Sydney", 10, 11 }, - { "Australia/Tasmania", 10, 11 }, - { "Australia/Victoria", 10, 11 }, - { "Australia/West", 8, 8 }, - { "Australia/Yancowinna", 9.5, 10.5 }, - { "Brazil/Acre", -5, -5 }, - { "Brazil/DeNoronha", -2, -2 }, - { "Brazil/East", -3, -2 }, - { "Brazil/West", -4, -4 }, - { "Canada/Atlantic", -4, -3 }, - { "Canada/Central", -6, -5 }, - { "Canada/Eastern", -5, -4 }, - { "Canada/East-Saskatchewan", -6, -6 }, - { "Canada/Mountain", -7, -6 }, - { "Canada/Newfoundland", -3.5, -2.5 }, - { "Canada/Pacific", -8, -7 }, - { "Canada/Saskatchewan", -6, -6 }, - { "Canada/Yukon", -8, -7 }, - { "CET", 1, 2 }, - { "Chile/Continental", -4, -3 }, - { "Chile/EasterIsland", -6, -5 }, - { "CST6CDT", -6, -5 }, - { "Cuba", -5, -4 }, - { "EET", 2, 3 }, - { "Egypt", 2, 2 }, - { "Eire", 0, 1 }, - { "EST", -5, -5 }, - { "EST5EDT", -5, -4 }, - { "Etc/GMT", 0, 0 }, - { "Etc/GMT0", 0, 0 }, - { "Etc/GMT+0", 0, 0 }, - { "Etc/GMT+1", -1, -1 }, - { "Etc/GMT+10", -10, -10 }, - { "Etc/GMT+11", -11, -11 }, - { "Etc/GMT+12", -12, -12 }, - { "Etc/GMT+2", -2, -2 }, - { "Etc/GMT+3", -3, -3 }, - { "Etc/GMT+4", -4, -4 }, - { "Etc/GMT+5", -5, -5 }, - { "Etc/GMT+6", -6, -6 }, - { "Etc/GMT+7", -7, -7 }, - { "Etc/GMT+8", -8, -8 }, - { "Etc/GMT+9", -9, -9 }, - { "Etc/GMT0", 0, 0 }, - { "Etc/GMT-0", 0, 0 }, - { "Etc/GMT-1", 1, 1 }, - { "Etc/GMT-10", 10, 10 }, - { "Etc/GMT-11", 11, 11 }, - { "Etc/GMT-12", 12, 12 }, - { "Etc/GMT-13", 13, 13 }, - { "Etc/GMT-14", 14, 14 }, - { "Etc/GMT-2", 2, 2 }, - { "Etc/GMT-3", 3, 3 }, - { "Etc/GMT-4", 4, 4 }, - { "Etc/GMT-5", 5, 5 }, - { "Etc/GMT-6", 6, 6 }, - { "Etc/GMT-7", 7, 7 }, - { "Etc/GMT-8", 8, 8 }, - { "Etc/GMT-9", 9, 9 }, - { "Etc/Greenwich", 0, 0 }, - { "Etc/UCT", 0, 0 }, - { "Etc/Universal", 0, 0 }, - { "Etc/UTC", 0, 0 }, - { "Etc/Zulu", 0, 0 }, - { "Europe/Amsterdam", 1, 2 }, - { "Europe/Andorra", 1, 2 }, - { "Europe/Astrakhan", 4, 4 }, - { "Europe/Athens", 2, 3 }, - { "Europe/Belfast", 0, 1 }, - { "Europe/Belgrade", 1, 2 }, - { "Europe/Berlin", 1, 2 }, - { "Europe/Bratislava", 1, 2 }, - { "Europe/Brussels", 1, 2 }, - { "Europe/Bucharest", 2, 3 }, - { "Europe/Budapest", 1, 2 }, - { "Europe/Busingen", 1, 2 }, - { "Europe/Chisinau", 2, 3 }, - { "Europe/Copenhagen", 1, 2 }, - { "Europe/Dublin", 0, 1 }, - { "Europe/Gibraltar", 1, 2 }, - { "Europe/Guernsey", 0, 1 }, - { "Europe/Helsinki", 2, 3 }, - { "Europe/Isle_of_Man", 0, 1 }, - { "Europe/Istanbul", 2, 3 }, - { "Europe/Jersey", 0, 1 }, - { "Europe/Kaliningrad", 2, 2 }, - { "Europe/Kiev", 2, 3 }, - { "Europe/Kirov", 3, 3 }, - { "Europe/Lisbon", 0, 1 }, - { "Europe/Ljubljana", 1, 2 }, - { "Europe/London", 0, 1 }, - { "Europe/Luxembourg", 1, 2 }, - { "Europe/Madrid", 1, 2 }, - { "Europe/Malta", 1, 2 }, - { "Europe/Mariehamn", 2, 3 }, - { "Europe/Minsk", 3, 3 }, - { "Europe/Monaco", 1, 2 }, - { "Europe/Moscow", 3, 3 }, - { "Europe/Nicosia", 2, 3 }, - { "Europe/Oslo", 1, 2 }, - { "Europe/Paris", 1, 2 }, - { "Europe/Podgorica", 1, 2 }, - { "Europe/Prague", 1, 2 }, - { "Europe/Riga", 2, 3 }, - { "Europe/Rome", 1, 2 }, - { "Europe/Samara", 4, 4 }, - { "Europe/San_Marino", 1, 2 }, - { "Europe/Sarajevo", 1, 2 }, - { "Europe/Simferopol", 3, 3 }, - { "Europe/Skopje", 1, 2 }, - { "Europe/Sofia", 2, 3 }, - { "Europe/Stockholm", 1, 2 }, - { "Europe/Tallinn", 2, 3 }, - { "Europe/Tirane", 1, 2 }, - { "Europe/Tiraspol", 2, 3 }, - { "Europe/Ulyanovsk", 4, 4 }, - { "Europe/Uzhgorod", 2, 3 }, - { "Europe/Vaduz", 1, 2 }, - { "Europe/Vatican", 1, 2 }, - { "Europe/Vienna", 1, 2 }, - { "Europe/Vilnius", 2, 3 }, - { "Europe/Volgograd", 3, 3 }, - { "Europe/Warsaw", 1, 2 }, - { "Europe/Zagreb", 1, 2 }, - { "Europe/Zaporozhye", 2, 3 }, - { "Europe/Zurich", 1, 2 }, - { "GB", 0, 1 }, - { "GB-Eire", 0, 1 }, - { "GMT", 0, 0 }, - { "GMT+0", 0, 0 }, - { "GMT0", 0, 0 }, - { "GMT-0", 0, 0 }, - { "Greenwich", 0, 0 }, - { "Hongkong", 8, 8 }, - { "HST", -10, -10 }, - { "Iceland", 0, 0 }, - { "Indian/Antananarivo", 3, 3 }, - { "Indian/Chagos", 6, 6 }, - { "Indian/Christmas", 7, 7 }, - { "Indian/Cocos", 6.5, 6.5 }, - { "Indian/Comoro", 3, 3 }, - { "Indian/Kerguelen", 5, 5 }, - { "Indian/Mahe", 4, 4 }, - { "Indian/Maldives", 5, 5 }, - { "Indian/Mauritius", 4, 4 }, - { "Indian/Mayotte", 3, 3 }, - { "Indian/Reunion", 4, 4 }, - { "Iran", 3.5, 4.5 }, - { "Israel", 2, 3 }, - { "Jamaica", -5, -5 }, - { "Japan", 9, 9 }, - { "Kwajalein", 12, 12 }, - { "Libya", 2, 2 }, - { "MET", 1, 2 }, - { "Mexico/BajaNorte", -8, -7 }, - { "Mexico/BajaSur", -7, -6 }, - { "Mexico/General", -6, -5 }, - { "MST", -7, -7 }, - { "MST7MDT", -7, -6 }, - { "Navajo", -7, -6 }, - { "NZ", 12, 13 }, - { "NZ-CHAT", 12.75, 13.75 }, - { "Pacific/Apia", 13, 14 }, - { "Pacific/Auckland", 12, 13 }, - { "Pacific/Bougainville", 11, 11 }, - { "Pacific/Chatham", 12.75, 13.75 }, - { "Pacific/Chuuk", 10, 10 }, - { "Pacific/Easter", -6, -5 }, - { "Pacific/Efate", 11, 11 }, - { "Pacific/Enderbury", 13, 13 }, - { "Pacific/Fakaofo", 13, 13 }, - { "Pacific/Fiji", 12, 13 }, - { "Pacific/Funafuti", 12, 12 }, - { "Pacific/Galapagos", -6, -6 }, - { "Pacific/Gambier", -9, -9 }, - { "Pacific/Guadalcanal", 11, 11 }, - { "Pacific/Guam", 10, 10 }, - { "Pacific/Honolulu", -10, -10 }, - { "Pacific/Johnston", -10, -10 }, - { "Pacific/Kiritimati", 14, 14 }, - { "Pacific/Kosrae", 11, 11 }, - { "Pacific/Kwajalein", 12, 12 }, - { "Pacific/Majuro", 12, 12 }, - { "Pacific/Marquesas", -9.5, -9.5 }, - { "Pacific/Midway", -11, -11 }, - { "Pacific/Nauru", 12, 12 }, - { "Pacific/Niue", -11, -11 }, - { "Pacific/Norfolk", 11, 11 }, - { "Pacific/Noumea", 11, 11 }, - { "Pacific/Pago_Pago", -11, -11 }, - { "Pacific/Palau", 9, 9 }, - { "Pacific/Pitcairn", -8, -8 }, - { "Pacific/Pohnpei", 11, 11 }, - { "Pacific/Ponape", 11, 11 }, - { "Pacific/Port_Moresby", 10, 10 }, - { "Pacific/Rarotonga", -10, -10 }, - { "Pacific/Saipan", 10, 10 }, - { "Pacific/Samoa", -11, -11 }, - { "Pacific/Tahiti", -10, -10 }, - { "Pacific/Tarawa", 12, 12 }, - { "Pacific/Tongatapu", 13, 13 }, - { "Pacific/Truk", 10, 10 }, - { "Pacific/Wake", 12, 12 }, - { "Pacific/Wallis", 12, 12 }, - { "Pacific/Yap", 10, 10 }, - { "Poland", 1, 2 }, - { "Portugal", 0, 1 }, - { "PRC", 8, 8 }, - { "PST8PDT", -8, -7 }, - { "ROC", 8, 8 }, - { "ROK", 9, 9 }, - { "Singapore", 8, 8 }, - { "Turkey", 2, 3 }, - { "UCT", 0, 0 }, - { "Universal", 0, 0 }, - { "US/Alaska", -9, -8 }, - { "US/Aleutian", -10, -9 }, - { "US/Arizona", -7, -7 }, - { "US/Central", -6, -5 }, - { "US/Eastern", -5, -4 }, - { "US/East-Indiana", -5, -4 }, - { "US/Hawaii", -10, -10 }, - { "US/Indiana-Starke", -6, -5 }, - { "US/Michigan", -5, -4 }, - { "US/Mountain", -7, -6 }, - { "US/Pacific", -8, -7 }, - { "US/Pacific-New", -8, -7 }, - { "US/Samoa", -11, -11 }, - { "UTC", 0, 0 }, - { "WET", 0, 1 }, - { "W-SU", 3, 3 }, - { "Zulu", 0, 0 }, -}; - -/* - Extra checks for gracefull (early) - stopping of pilight -*/ -static int searchingtz = 0; -static uv_mutex_t mutex_lock; -// static pthread_mutexattr_t mutex_attr; -static unsigned short mutex_init = 0; - -void datetime_init(void) { - // pthread_mutexattr_init(&mutex_attr); - // pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - // pthread_mutex_init(&mutex_lock, &mutex_attr); - uv_mutex_init(&mutex_lock); - mutex_init = 1; -} - -int datetime_gc(void) { - while(searchingtz > 0) { -#ifdef _WIN32 - SleepEx(10, TRUE); -#else - usleep(10); -#endif - } - logprintf(LOG_DEBUG, "garbage collected datetime library"); - return EXIT_SUCCESS; -} - -char *coord2tz(double longitude, double latitude) { -/* - Extra checks for graceful (early) - stopping of pilight -*/ - if(mutex_init == 1) { - uv_mutex_lock(&mutex_lock); - } - searchingtz++; - int i = 0, a = 0, margin = 1, inside = 0; - int nrtz = sizeof(tzdata)/sizeof(tzdata[0]); - char *tz = NULL; - - margin *= (int)pow(10, PRECISION); - int y = (int)round(latitude*(int)pow(10, PRECISION)); - int x = (int)round(longitude*(int)pow(10, PRECISION)); - - while(!inside && margin < (5*(int)pow(10, PRECISION))) { - for(i=0;i 0) { - int p1x = 0; - int p1y = 0; - for(a=0;a round(x)) - &&(round(p2y)-margin < round(y) && round(p2y)+margin > round(y))) { - int xinters = 0; - if(y > min(p1y, p2y)) { - if(y <= max(p1y, p2y)) { - if(x <= max(p1x, p2x)) { - if(p1y != p2y) { - xinters = (y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x; - } - if(p1x == p2x || x <= xinters) { - tz = tzdata[i].timezone; - inside = 1; - break; - } - } - } - } - p1x = p2x; - p1y = p2y; - } - } - if(inside == 1) { - break; - } - } - } - margin /= (int)pow(10, PRECISION); - margin++; - margin *= (int)pow(10, PRECISION); - } - - searchingtz--; - if(mutex_init == 1) { - uv_mutex_unlock(&mutex_lock); - } - return tz; -} - -static int is_leap(int year) { - return ((year % 400 == 0 || year % 100 != 0) && (year % 4 == 0)); -} - -static const char *get_months(time_t year) { - static const char leap[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - static const char common[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - return is_leap(year) ? leap : common; -} - -static void ruleset_add(struct ruleset *ruleset, const struct lc_timezone_rule *rule) { - assert(ruleset->rules_count < (sizeof(ruleset->rules)/sizeof(ruleset->rules[0]))); - - size_t newslot = ruleset->rules_count++; - while(newslot > 0 && - (rule->month < ruleset->rules[newslot-1]->month || - (rule->month == ruleset->rules[newslot-1]->month && - rule->monthday < ruleset->rules[newslot-1]->monthday))) { - - assert((rule->month != ruleset->rules[newslot-1]->month || - rule->monthday != ruleset->rules[newslot-1]->monthday)); - - ruleset->rules[newslot] = ruleset->rules[newslot-1]; - --newslot; - } - ruleset->rules[newslot] = rule; -} - - -static void ruleset_fill_with_year(struct ruleset *ruleset, const struct lc_timezone_rule **rules, - size_t *rules_count, int year, const struct lc_timezone_rule **last, - const struct lc_timezone_rule **last_dst) { - /* - * Step 1: Determine the set of rules of the previous year, so we can - * obtain the offset at the end of that year. - */ - int last_year = 0; - while(*rules_count > 0 && (*rules)->year_from < year) { - const struct lc_timezone_rule *rule = (*rules)++; - if(last_year != rule->year_from) { - ruleset_remove_stale(ruleset, rule->year_from); - } - ruleset_add(ruleset, rule); - ruleset_get_last(ruleset, year, last, last_dst); - --*rules_count; - } - - /* - * Step 2: Determine the set of rules that apply to the current year. - */ - ruleset_remove_stale(ruleset, year); - while(*rules_count > 0 && (*rules)->year_from == year) { - ruleset_add(ruleset, (*rules)++); - --*rules_count; - } -} - -static void ruleset_get_last(struct ruleset *ruleset, int year, - const struct lc_timezone_rule **last, - const struct lc_timezone_rule **last_dst) { - ssize_t i = 0; - assert(ruleset->rules_count > 0); - - *last = ruleset->rules[ruleset->rules_count-1]; - - if((*last)->save > 0) { - *last_dst = *last; - } - - for(i = ruleset->rules_count-2; (*last)->year_to < year-1 && i >= 0; --i) { - const struct lc_timezone_rule *rule = ruleset->rules[i]; - if((*last)->year_to < rule->year_to) { - *last = rule; - if((*last)->save > 0) { - *last_dst = *last; - } - } - } -} - -static int rule_is_greater_than(const struct lc_timezone_rule *rule, - const struct tm *tm, int offset) { - - /* - * Apply the offset to the time and obtain the time of day in seconds. - */ - int seconds = tm->tm_sec + tm->tm_min * 60 + tm->tm_hour * 3600 + offset; - int monthday = tm->tm_mday + seconds / 86400; - int weekday = tm->tm_wday + seconds / 86400; - - seconds %= 86400; - if(seconds < 0) { - seconds += 86400; - --weekday; - --monthday; - } - - /* - * Normalize the month. - */ - int month = tm->tm_mon; - if(monthday < 1) { - /* - * Time went back into last year. - */ - if(month == 0) { - return 1; - } - monthday += get_months(tm->tm_year)[month-1]; - --month; - } else { - int monthlen = get_months(tm->tm_year)[month]; - if(monthday > monthlen) { - monthday -= monthlen; - ++month; - } - } - - /* - * Compare months. - */ - if(rule->month != month) { - return rule->month > month; - } - - /* - * When rule->weekday is between 0 and 6, we only want to apply the - * rule on the first occurrence of the weekday on or after the day - * of the month. More concretely, if weekday == 3 and monthday == - * 15, the rule only takes effect on the first Wednesday on or after - * the 15th of that month. - */ - int monthdaydelta = 0; - if(rule->weekday != 7) { - monthdaydelta = ((int)rule->weekday - weekday + monthday - (int)rule->monthday) % 7; - if(monthdaydelta < 0) { - monthdaydelta += 7; - } - } - - /* - * Compare day of the month and time. - */ - return (rule->monthday + monthdaydelta) * 86400 + rule->minute * 60 > monthday * 86400 + seconds; -} - -static void ruleset_remove_stale(struct ruleset *ruleset, int year) { - size_t i = 0; - size_t old_rules_count = ruleset->rules_count; - ruleset->rules_count = 0; - - for(i=0; irules[i]->year_to == UINT8_MAX || ruleset->rules[i]->year_to >= year) { - ruleset->rules[ruleset->rules_count++] = ruleset->rules[i]; - } - } -} - -static const struct lc_timezone_rule *determine_applicable_rule( - const struct lc_timezone_rule *rules, size_t rules_count, - const struct tm *std, int gmtoff) { - /* - * Start out by picking the first standard time rule as a fallback. It - * may be the case that the code below obtains no matching rule, for - * example if the timestamp is lower than any of the starting times of - * the rules. - * - * This rule has no influence on the time computation, but at least - * ensures that we have a proper timezone abbreviation. - */ - static const struct lc_timezone_rule nomatch = { 0 }; - // memset(&nomatch, 0, sizeof(nomatch)); - const struct lc_timezone_rule *match = &nomatch; - size_t i = 0; - for(i=0; itm_year, &match, &unused); - - /* - * Determine whether there is a rule for the current year that matches - * the time more accurately than the one matching the start of the - * year. - */ - for(i=0; itimebase) { - case TIMEBASE_CUR: - offset = match->save * 600; - break; - case TIMEBASE_UTC: - offset = -gmtoff; - break; - } - - if(rule_is_greater_than(rule, std, offset)) { - break; - } - match = rule; - } - return match; -} - -// static const char *compute_combined_zone_abbreviation(const char *era, const char *rule) { - // /* - // * Perform expansion. - // */ - // char abbreviation[sizeof(((struct cached_abbreviation *)0)->abbreviation)]; - // snprintf(abbreviation, sizeof(abbreviation), era, rule); - - // /* - // * See if there's already a copy of this string in the stringpool. - // */ - // struct cached_abbreviation *ca = NULL; - // static _Atomic(struct cached_abbreviation *) table = ATOMIC_VAR_INIT(NULL); - // struct cached_abbreviation *first = atomic_load_explicit(&table, memory_order_relaxed); - - // for(ca = first; ca != NULL; ca = ca->next) { - // if(strcmp(abbreviation, ca->abbreviation) == 0) { - // return ca->abbreviation; - // } - // } - - // /* - // * Allocate a copy to be stored in the stringpool. - // */ - // struct cached_abbreviation *ca_new = MALLOC(sizeof(*ca_new)); - // if(ca_new == NULL) { - // return ""; - // } - // strncpy(ca_new->abbreviation, abbreviation, sizeof(ca_new->abbreviation)); - - // for(;;) { - // struct cached_abbreviation *ca = NULL; - // /* - // * Store the new entry in the global list. The list is lockless, so - // * perform a compare-and-exchange. - // */ - // ca_new->next = first; - - // if(atomic_compare_exchange_weak(&table, &first, ca_new)) { - // char *a = ca_new->abbreviation; - // FREE(ca_new); - // return a; - // } - - // /* - // * Compare-and-exchange failed. See if an entry for the same - // * abbreviation got created in the meantime. - // */ - // for(ca = first; ca != ca_new->next; ca = ca->next) { - // if(strcmp(abbreviation, ca->abbreviation) == 0) { - // FREE(ca_new); - // return ca->abbreviation; - // } - // } - // } -// } - -static const short *get_months_cumulative(time_t year) { - static const short leap[13] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }; - static const short common[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; - return is_leap(year) ? leap : common; -} - -// static const char *compute_zone_abbreviation(const struct lc_timezone_era *era, - // const struct lc_timezone_rule *rule) { - - // /* - // * If the timezone already provides explicit abbreviations for - // * standard time and daylight saving time, use those directly. - // */ - // if(*era->abbreviation_dst != '\0') { - // return rule->save == 0 ? era->abbreviation_std : era->abbreviation_dst; - // } - - // /* - // * If the era abbreviation contains %s, expand it with the - // * abbreviation of the rule. Keep track of the result in a string - // * pool, so we don't leak memory. - // */ - // if(strchr(era->abbreviation_std, '%') != NULL) { - // return compute_combined_zone_abbreviation(era->abbreviation_std, rule->abbreviation); - // } - - // /* - // * Era abbreviation does not contain %s. Use the abbreviation of the - // * era or the rule, preferring the latter if three or more characters. - // */ - // return rule->abbreviation[0] != '\0' && rule->abbreviation[1] != '\0' && rule->abbreviation[2] != '\0' - // ? rule->abbreviation - // : era->abbreviation_std; -// } - -int __localtime_utc(time_t timer, struct tm *tm) { - - /* - * The calendar repeats every 146097 days (400 years). Normalize the - * timer to lie within this range. This ensures that the timestamp is - * positive, simplifying the arithmetic below. - */ - time_t era = timer / ERALENGTH; - - timer %= ERALENGTH; - if(timer < 0) { - timer += ERALENGTH; - --era; - } - - /* - * Compute time within the day. - */ - unsigned int seconds = (unsigned int)timer % 86400; - *tm = (struct tm){.tm_sec = seconds % 60}; - uint_fast16_t minutes = seconds / 60; - tm->tm_min = minutes % 60; - tm->tm_hour = minutes / 60; - - /* - * Compute weekday. Day 0 is a Thursday. - */ - unsigned int days = (unsigned int)timer / 86400; - tm->tm_wday = (days + 4) % 7; - - /* - * Apply leap days, so that every year becomes exactly 366 days long. - * First add the three leap days at the boundaries of the centuries. - * After that we can add up to three leap days per 1461 days. - */ - days += ((int)days - 11323) / 36524; - days += days / 1461 + (days + 731) / 1461 + (days + 1096) / 1461; - tm->tm_yday = days % 366; - - /* - * Compute the year. - */ - uint_fast16_t local_year = days / 366 + 70; - time_t year = era * 400 + local_year; - - /* - * Compute month and day within month. - */ - const short *months = get_months_cumulative(local_year); - while(tm->tm_yday >= months[tm->tm_mon + 1]) { - ++tm->tm_mon; - } - tm->tm_mday = tm->tm_yday - months[tm->tm_mon] + 1; - - /* - * Determine whether the result fits in "struct tm". If it does not, - * still return a structure, but set the year to INT_MIN or INT_MAX. - */ - if(year < INT_MIN) { - tm->tm_year = INT_MIN; - return EOVERFLOW; - } else if (year > INT_MAX) { - tm->tm_year = INT_MAX; - return EOVERFLOW; - } else { - tm->tm_year = year; - return 0; - } -} - -int localtime_l(time_t t, struct tm *result, char *timezone) { - size_t i = 0; - int x = 0; - /* - * Require tv_nsec to be in bounds, like other functions that accept - */ - if(t < 0) { - return EINVAL; - } - - const char *timezone_name = timezone_names; - do { - if(strcmp(timezone, timezone_name) == 0) { - break; - } - ++x; - timezone_name += strlen(timezone_name) + 1; - } while(*timezone_name != '\0'); - - /* - * Obtain the last era from the timezone that does not end before the - * provided timestamp. - */ - const struct lc_timezone *tz = &timezones[x]; - const struct lc_timezone_era *era = &tz->eras[0]; - time_t era_start = 0; - for(i=1; ieras_count; ++i) { - if(era->end > t) { - break; - } - era_start = era->end + era->gmtoff + era->end_save * 600; - era = &tz->eras[i]; - } - - int error = 0; - if(era->rules_count > 0) { - /* - * Timezone has daylight saving time rules. First compute the - * standard time and use that to compute the actual offset. If the - * timestamp is close to the start of the era and the UTC offset got - * decreased, make sure that the timestamp used for matching is set - * to the start of the era. This ensures that we match the proper - * DST rules. - */ - time_t timer_std = t + era->gmtoff; - - struct tm std; - __localtime_utc(timer_std > era_start ? timer_std : era_start, &std); - - /* - * Obtain applicable daylight saving time rule and recompute. - */ - const struct lc_timezone_rule *rule = determine_applicable_rule(era->rules, era->rules_count, &std, era->gmtoff); - int gmtoff = era->gmtoff + rule->save * 600; - - error = __localtime_utc(t + gmtoff, result); - - result->tm_isdst = rule->save > 0; - -#ifndef _WIN32 - result->tm_gmtoff = gmtoff; - // result->tm_zone = compute_zone_abbreviation(era, rule); -#endif - } else { - /* - * Timezone has no daylight saving time rules. Compute local time - * with timezone offset directly. - */ - error = __localtime_utc(t + era->gmtoff, result); -#ifndef _WIN32 - result->tm_gmtoff = era->gmtoff; - // static const struct lc_timezone_rule rule = {}; - // result->tm_zone = compute_zone_abbreviation(era, &rule); -#endif - } - - return error; -} - -static int dayofweek(int y, int m, int d) { - static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; - y -= m < 3; - return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7; -} - -void datefix(int *year, int *month, int *day, int *hour, int *minute, int *second, int *weekday) { - int months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - int i = 0; - - if(((*year % 4) == 0 && (*year % 100) != 0) || (*year % 400) == 0) { - months[1] = 29; - } - while(*second >= 60) { - *minute += 1; - *second -= 60; - } - while(*second < 0) { - *minute -= 1; - *second = 60 + *second; - } - while(*minute >= 60) { - *hour += 1; - *minute -= 60; - } - while(*minute < 0) { - *hour -= 1; - *minute = 60 + *minute; - } - while(*hour > 23) { - *day += 1; - *hour -= 24; - } - while(*hour < 0) { - *day -= 1; - *hour = 24 + *hour; - } - while(*day <= 0 || *month > 12 || *month <= 0 || *day > months[*month-1]) { - if(*month > 0 && *month < 13) { - if(*day > months[*month-1]) { - i = months[*month-1]; - *month += 1; - *day -= i; - } else if(*day <= 0) { - *month -= 1; - if(*month <= 0) { - *day = months[11 + *month] + *day; - } else { - *day = months[*month-1] + *day; - } - } - } - while(*month > 12 || *month <= 0) { - if(*month > 12) { - *year += 1; - *month -= 12; - } else if(*month < 0) { - *year -= 1; - *month = 12 + *month; - } else { - *year -= 1; - *month = 12; - } - if(((*year % 4) == 0 && (*year % 100) != 0) || (*year % 400) == 0) { - months[1] = 29; - } else { - months[1] = 28; - } - } - } - - *weekday = dayofweek(*year, *month, *day); -} - -time_t datetime2ts(int year, int month, int day, int hour, int minutes, int seconds) { - int smin = 60, shour = (smin*60), sday = (shour*24); - int i = 0; - time_t t = 0; - if(year < 1970) { - return -1; - } - if(month < 1 || month > 12) { - return -1; - } - if(day < 1) { - return -1; - } - if((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) && - day > 31) { - return -1; - } - if((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) { - return -1; - } - if(month == 2) { - if(day > 28) { - if(((year % 400) == 0 || (year % 100) == 0 || (year % 4) == 0) && day > 29) { - return -1; - } else { - return -1; - } - } - } - if(hour < 0 || hour > 23) { - return -1; - } - if(minutes < 0 || minutes > 59) { - return -1; - } - if(seconds < 0 || seconds > 59) { - return -1; - } - - for(i=1970;i 11) { t += 30*sday; } - if(month > 10) { t += 31*sday; } - if(month > 9) { t += 30*sday; } - if(month > 8) { t += 31*sday; } - if(month > 7) { t += 31*sday; } - if(month > 6) { t += 30*sday; } - if(month > 5) { t += 31*sday; } - if(month > 4) { t += 30*sday; } - if(month > 3) { t += 31*sday; } - if(month > 2) { if(is_leap(year) == 1) { t += 29*sday; } else { t += 28*sday; } } - if(month > 1) { t += 31*sday; } - - t += (hour*shour); - t += (minutes*smin); - t += (seconds); - - t -= 86400; - - return t; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/datetime.h b/lib/ESPiLight/pilight/libs/pilight/core/datetime.h deleted file mode 100644 index 4b01d98..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/datetime.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _DATETIME_H_ -#define _DATETIME_H_ - -int datetime_gc(void); -char *coord2tz(double, double); -time_t datetime2ts(int, int, int, int, int, int); -int tzoffset(char *, char *, double *); -int isdst(time_t, char *); -void datefix(int *, int *, int *, int *, int *, int *, int *); -void datetime_init(void); -int localtime_l(time_t, struct tm *, char *); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/dso.c b/lib/ESPiLight/pilight/libs/pilight/core/dso.c deleted file mode 100644 index 7f3d4ea..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/dso.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#ifndef _WIN32 - #include -#endif - -#include "common.h" -#include "mem.h" -#include "log.h" -#include "dso.h" - -void *dso_load(char *object) { -#ifndef _WIN32 - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - void *handle = NULL; - int match = 0; - struct dso_t *tmp = dso; - while(tmp) { - if(strcmp(tmp->name, object) == 0) { - match = 1; - break; - } - tmp = tmp->next; - } - if(match) { - return NULL; - } - -#if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT) - if(!(handle = dlopen(object, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT))) { -#elif defined(RTLD_DEEPBIND) - if(!(handle = dlopen(object, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND))) { -#else - if(!(handle = dlopen(object, RTLD_LAZY))) { -#endif - atomiclock(); - logprintf(LOG_ERR, dlerror()); - atomicunlock(); - return NULL; - } else { - struct dso_t *node = MALLOC(sizeof(struct dso_t)); - if(!node) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - node->handle = handle; - if((node->name = MALLOC(strlen(object)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(node->name, object); - node->next = dso; - dso = node; - return handle; - } -#else - logprintf(LOG_ERR, "dynamic loading not implemented on Windows"); - return NULL; -#endif -} - -int dso_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct dso_t *tmp = NULL; - while(dso) { - tmp = dso; -#ifndef _WIN32 - dlclose(tmp->handle); -#endif - FREE(tmp->name); - dso = dso->next; - FREE(tmp); - } - if(dso != NULL) { - FREE(dso); - } - - logprintf(LOG_DEBUG, "garbage collected dso library"); - return 0; -} - -void *dso_function(void *handle, const char *name) { -#ifndef _WIN32 - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - void *init = (void *)dlsym(handle, name); - char *error = NULL; - atomiclock(); - if((error = dlerror()) != NULL) { - logprintf(LOG_ERR, error); - atomicunlock(); - return 0; - } else { - atomicunlock(); - return init; - } -#else - return 0; -#endif -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/eventpool.c b/lib/ESPiLight/pilight/libs/pilight/core/eventpool.c deleted file mode 100644 index 77108a9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/eventpool.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - Copyright (C) 2015 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include "eventpool.h" - -#include -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #include - #include - #include - #include - struct pollfd { - int fd; - short events; - short revents; - }; - #define POLLIN 0x0001 - #define POLLPRI 0x0002 - #define POLLOUT 0x0004 -#else - #include - #include - #include - #include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include "log.h" -#include "../../libuv/uv.h" -#include "mem.h" -#include "network.h" - -static uv_async_t *async_req = NULL; - -struct eventqueue_t { - int reason; - void *(*done)(void *); - void *data; - struct eventqueue_t *next; -} eventqueue_t; - -#ifdef _WIN32 -static volatile long nrlisteners[REASON_END] = {0}; -#else -static int nrlisteners[REASON_END] = {0}; -#endif -static struct eventqueue_t *eventqueue = NULL; - -static int threads = EVENTPOOL_NO_THREADS; -static uv_mutex_t listeners_lock; -// static pthread_mutexattr_t listeners_attr; -static int lockinit = 0; -static int eventpoolinit = 0; -static ssize_t zero = 0; -static ssize_t one = 1; - -static struct eventpool_listener_t *eventpool_listeners = NULL; - -static struct reasons_t { - int number; - char *reason; - int priority; -} reasons[REASON_END+1] = { - { REASON_SEND_CODE, "REASON_SEND_CODE", 0 }, - { REASON_CONTROL_DEVICE, "REASON_CONTROL_DEVICE", 0 }, - { REASON_CODE_SENT, "REASON_CODE_SENT", 0 }, - { REASON_SOCKET_SEND, "REASON_CODE_SEND_FAIL", 0 }, - { REASON_SOCKET_SEND, "REASON_CODE_SEND_SUCCESS", 0 }, - { REASON_CODE_RECEIVED, "REASON_CODE_RECEIVED", 0 }, - { REASON_RECEIVED_PULSETRAIN, "REASON_RECEIVED_PULSETRAIN", 0 }, - { REASON_BROADCAST, "REASON_BROADCAST", 0 }, - { REASON_BROADCAST_CORE, "REASON_BROADCAST_CORE", 0 }, - { REASON_FORWARD, "REASON_FORWARD", 0 }, - { REASON_CONFIG_UPDATE, "REASON_CONFIG_UPDATE", 0 }, - { REASON_CONFIG_UPDATED, "REASON_CONFIG_UPDATED", 0 }, - { REASON_SOCKET_RECEIVED, "REASON_SOCKET_RECEIVED", 0 }, - { REASON_SOCKET_DISCONNECTED, "REASON_SOCKET_DISCONNECTED", 0 }, - { REASON_SOCKET_CONNECTED, "REASON_SOCKET_CONNECTED", 0 }, - { REASON_SOCKET_SEND, "REASON_SOCKET_SEND", 0 }, - { REASON_SSDP_RECEIVED, "REASON_SSDP_RECEIVED", 0 }, - { REASON_SSDP_RECEIVED_FREE, "REASON_SSDP_RECEIVED_FREE", 0 }, - { REASON_SSDP_DISCONNECTED, "REASON_SSDP_DISCONNECTED", 0 }, - { REASON_SSDP_CONNECTED, "REASON_SSDP_CONNECTED", 0 }, - { REASON_WEBSERVER_CONNECTED, "REASON_WEBSERVER_CONNECTED", 0 }, - { REASON_DEVICE_ADDED, "REASON_DEVICE_ADDED", 0 }, - { REASON_DEVICE_ADAPT, "REASON_DEVICE_ADAPT", 0 }, - { REASON_ADHOC_MODE, "REASON_ADHOC_MODE", 0 }, - { REASON_ADHOC_CONNECTED, "REASON_ADHOC_CONNECTED", 0 }, - { REASON_ADHOC_CONFIG_RECEIVED, "REASON_ADHOC_CONFIG_RECEIVED", 0 }, - { REASON_ADHOC_DATA_RECEIVED, "REASON_ADHOC_DATA_RECEIVED", 0 }, - { REASON_ADHOC_UPDATE_RECEIVED, "REASON_ADHOC_UPDATE_RECEIVED", 0 }, - { REASON_ADHOC_DISCONNECTED, "REASON_ADHOC_DISCONNECTED", 0 }, - { REASON_SEND_BEGIN, "REASON_SEND_BEGIN", 0 }, - { REASON_SEND_END, "REASON_SEND_END", 0 }, - { REASON_ARP_FOUND_DEVICE, "REASON_ARP_FOUND_DEVICE", 0 }, - { REASON_ARP_LOST_DEVICE, "REASON_ARP_LOST_DEVICE", 0 }, - { REASON_ARP_CHANGED_DEVICE, "REASON_ARP_CHANGED_DEVICE", 0 }, - { REASON_LOG, "REASON_LOG", 0 }, - { REASON_END, "REASON_END", 0 } -}; - -static void fib_free(uv_work_t *req, int status) { - FREE(req->data); - FREE(req); -} - -static void fib(uv_work_t *req) { - struct threadpool_data_t *data = req->data; - - data->func(data->reason, data->userdata); - - int x = 0; - if(data->ref != NULL) { - x = uv_sem_trywait(data->ref); - } - if((data->ref == NULL) || (x == UV__EAGAIN)) { - if(data->done != NULL && data->reason != REASON_END) { - data->done(data->userdata); - } - if(data->ref != NULL) { - FREE(data->ref); - } - } - // FREE(req->data); -} - -void eventpool_callback(int reason, void *(*func)(int, void *)) { - if(lockinit == 1) { - uv_mutex_lock(&listeners_lock); - } - struct eventpool_listener_t *node = MALLOC(sizeof(struct eventpool_listener_t)); - if(node == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->func = func; - node->reason = reason; - node->next = NULL; - - node->next = eventpool_listeners; - eventpool_listeners = node; - -#ifdef _WIN32 - InterlockedIncrement(&nrlisteners[reason]); -#else - __sync_add_and_fetch(&nrlisteners[reason], 1); -#endif - - if(lockinit == 1) { - uv_mutex_unlock(&listeners_lock); - } -} - -void eventpool_trigger(int reason, void *(*done)(void *), void *data) { - if(eventpoolinit == 0) { - return; - } - -#ifdef _WIN32 - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); -#else - struct sched_param sched; - memset(&sched, 0, sizeof(sched)); - sched.sched_priority = 80; - pthread_setschedparam(pthread_self(), SCHED_RR, &sched); -#endif - int eventqueue_size = 0; - - struct eventqueue_t *node = MALLOC(sizeof(struct eventqueue_t)); - if(node == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, 0, sizeof(struct eventqueue_t)); - node->reason = reason; - node->done = done; - node->data = data; - - uv_mutex_lock(&listeners_lock); - struct eventqueue_t *tmp = eventqueue; - if(tmp != NULL) { - while(tmp->next != NULL) { - eventqueue_size++; - tmp = tmp->next; - } - tmp->next = node; - node = tmp; - } else { - node->next = eventqueue; - eventqueue = node; - } - - /* - * If the eventqueue size is above - * 50 entries then there must be a bug - * at the trigger side. - */ - assert(eventqueue_size < 50); - - uv_mutex_unlock(&listeners_lock); - - uv_async_send(async_req); -} - -static void eventpool_execute(uv_async_t *handle) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct threadpool_tasks_t **node = NULL; - int nrlisteners1[REASON_END] = {0}; - int nr1 = 0, nrnodes = 16, nrnodes1 = 0, i = 0; - - if((node = MALLOC(sizeof(struct threadpool_tasks_t *)*nrnodes)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - uv_mutex_lock(&listeners_lock); - - struct eventqueue_t *queue = NULL; - while(eventqueue) { - queue = eventqueue; - uv_sem_t *ref = NULL; - -#ifdef _WIN32 - if((nr1 = InterlockedExchangeAdd(&nrlisteners[queue->reason], 0)) == 0) { -#else - if((nr1 = __sync_add_and_fetch(&nrlisteners[queue->reason], 0)) == 0) { -#endif - if(queue->done != NULL) { - queue->done((void *)queue->data); - } - } else { - if(threads == EVENTPOOL_THREADED) { - if((ref = MALLOC(sizeof(uv_sem_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - uv_sem_init(ref, nr1-1); - } - - struct eventpool_listener_t *listeners = eventpool_listeners; - if(listeners == NULL) { - if(queue->done != NULL) { - queue->done((void *)queue->data); - } - } - - while(listeners) { - if(listeners->reason == queue->reason) { - if(nrnodes1 == nrnodes) { - nrnodes *= 2; - /*LCOV_EXCL_START*/ - if((node = REALLOC(node, sizeof(struct threadpool_tasks_t *)*nrnodes)) == NULL) { - OUT_OF_MEMORY - } - /*LCOV_EXCL_STOP*/ - } - if((node[nrnodes1] = MALLOC(sizeof(struct threadpool_tasks_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node[nrnodes1]->func = listeners->func; - node[nrnodes1]->userdata = queue->data; - node[nrnodes1]->done = queue->done; - node[nrnodes1]->ref = ref; - node[nrnodes1]->reason = listeners->reason; - nrnodes1++; - if(threads == EVENTPOOL_THREADED) { - nrlisteners1[queue->reason]++; - } - } - listeners = listeners->next; - } - } - eventqueue = eventqueue->next; - FREE(queue); - } - uv_mutex_unlock(&listeners_lock); - - if(nrnodes1 > 0) { - for(i=0;ireason]++; - node[i]->func(node[i]->reason, node[i]->userdata); - -#ifdef _WIN32 - if(nrlisteners1[node[i]->reason] == InterlockedExchangeAdd(&nrlisteners[node[i]->reason], 0)) { -#else - if(nrlisteners1[node[i]->reason] == __sync_add_and_fetch(&nrlisteners[node[i]->reason], 0)) { -#endif - if(node[i]->done != NULL) { - node[i]->done((void *)node[i]->userdata); - } - nrlisteners1[node[i]->reason] = 0; - } - } else { - struct threadpool_data_t *tpdata = NULL; - tpdata = MALLOC(sizeof(struct threadpool_data_t)); - if(tpdata == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - tpdata->userdata = node[i]->userdata; - tpdata->func = node[i]->func; - tpdata->done = node[i]->done; - tpdata->ref = node[i]->ref; - tpdata->reason = node[i]->reason; - tpdata->priority = reasons[node[i]->reason].priority; - - uv_work_t *tp_work_req = MALLOC(sizeof(uv_work_t)); - if(tp_work_req == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - tp_work_req->data = tpdata; - if(uv_queue_work(uv_default_loop(), tp_work_req, reasons[node[i]->reason].reason, fib, fib_free) < 0) { - if(node[i]->done != NULL) { - node[i]->done((void *)node[i]->userdata); - } - FREE(tpdata); - FREE(node[i]->ref); - } - } - FREE(node[i]); - } - } - for(i=0;idata != NULL && eventqueue->done != NULL) { - eventqueue->done(eventqueue->data); - } - eventqueue = eventqueue->next; - FREE(queue); - } - struct eventpool_listener_t *listeners = NULL; - while(eventpool_listeners) { - listeners = eventpool_listeners; - eventpool_listeners = eventpool_listeners->next; - FREE(listeners); - } - if(eventpool_listeners != NULL) { - FREE(eventpool_listeners); - } - threads = EVENTPOOL_NO_THREADS; - - int i = 0; - for(i=0;ilock); - if(n > 0 && n <= io->len) { - memmove(io->buf, io->buf + n, io->len - n); - io->len -= n; - io->buf[io->len] = 0; - } - uv_mutex_unlock(&io->lock); -} - -static void eventpool_update_poll(uv_poll_t *req) { - struct uv_custom_poll_t *custom_poll_data = NULL; - struct iobuf_t *send_io = NULL; - int action = 0, r = 0; - - custom_poll_data = req->data; - if(custom_poll_data == NULL || uv_is_closing((uv_handle_t *)req)) { - return; - } - - send_io = &custom_poll_data->send_iobuf; - - if(custom_poll_data->doread == 1) { - action |= UV_READABLE; - } - - if(custom_poll_data->dowrite == 1) { - action |= UV_WRITABLE; - } - - if(custom_poll_data->doclose == 1 && send_io->len == 0) { - custom_poll_data->doclose = 2; - if(custom_poll_data->close_cb != NULL) { - custom_poll_data->close_cb(req); - } - if(!uv_is_closing((uv_handle_t *)req)) { - uv_poll_stop(req); - } - } else if(custom_poll_data->action != action && action > 0) { - uv_poll_start(req, action, uv_custom_poll_cb); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_poll_start: %s", uv_strerror(r)); - return; - /*LCOV_EXCL_STOP*/ - } - custom_poll_data->action = action; - } -} - -size_t iobuf_append(struct iobuf_t *io, const void *buf, int len) { - char *p = NULL; - - uv_mutex_lock(&io->lock); - assert(io != NULL); - assert(io->len <= io->size); - - if(len <= 0) { - } else if(io->len + len <= io->size) { - memcpy(io->buf + io->len, buf, len); - io->len += len; - } else if((p = REALLOC(io->buf, io->len + len + 1)) != NULL) { - io->buf = p; - memcpy(io->buf + io->len, buf, len); - io->len += len; - io->size = io->len; - } else { - len = 0; - } - uv_mutex_unlock(&io->lock); - - return len; -} - -/*LCOV_EXCL_START*/ -static void my_debug(void *ctx, int level, const char *file, int line, const char *str) { - printf("%s:%04d: %s", file, line, str ); -} -/*LCOV_EXCL_STOP*/ - -void uv_custom_poll_cb(uv_poll_t *req, int status, int events) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = NULL; - struct iobuf_t *send_io = NULL; - char buffer[BUFFER_SIZE]; - uv_os_fd_t fd = 0; - long int fromlen = 0; - int r = 0, n = 0; - - custom_poll_data = req->data; - if(custom_poll_data == NULL) { - uv_poll_stop(req); - return; - } - - /* - * Status == -9: Socket is unreachable - * Events == 0: Client-end got disconnected - */ - r = uv_fileno((uv_handle_t *)req, &fd); - if(status < 0 || events == 0) { - logprintf(LOG_ERR, "uv_custom_poll_cb: %s", uv_strerror(status)); - if(custom_poll_data->close_cb != NULL) { - custom_poll_data->close_cb(req); - } - if(!uv_is_closing((uv_handle_t *)req)) { - uv_poll_stop(req); - } - if(fd > 0) { - close(fd); - } - return; - } - - custom_poll_data->started = 1; - - send_io = &custom_poll_data->send_iobuf; - - memset(&buffer, 0, BUFFER_SIZE); - - if(uv_is_closing((uv_handle_t *)req)) { - return; - } - - r = uv_fileno((uv_handle_t *)req, &fd); - if(r != 0) { - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); - return; - } - - if(custom_poll_data->is_ssl == 1 && custom_poll_data->ssl.init == 0) { - custom_poll_data->ssl.init = 1; - struct mbedtls_ssl_config *ssl_conf = &ssl_client_conf; - if(custom_poll_data->is_server == 1) { - custom_poll_data->ssl.handshake = 1; - ssl_conf = &ssl_server_conf; - } - if((r = mbedtls_ssl_setup(&custom_poll_data->ssl.ctx, ssl_conf)) < 0) { - mbedtls_strerror(r, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_ERR, "mbedtls_ssl_setup: %s", buffer); - FREE(req); - return; - } - - if((r = mbedtls_ssl_session_reset(&custom_poll_data->ssl.ctx)) < 0) { - mbedtls_strerror(r, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_ERR, "mbedtls_ssl_session_reset: %s", buffer); - FREE(req); - return; - } - // mbedtls_debug_set_threshold(2); - mbedtls_ssl_set_bio(&custom_poll_data->ssl.ctx, &fd, mbedtls_net_send, mbedtls_net_recv, NULL); - mbedtls_ssl_conf_dbg(ssl_conf, my_debug, stdout); - } - - if(custom_poll_data->is_ssl == 1 && custom_poll_data->ssl.handshake == 0) { - n = mbedtls_ssl_handshake(&custom_poll_data->ssl.ctx); - if(n == MBEDTLS_ERR_SSL_WANT_READ) { - custom_poll_data->doread = 1; - custom_poll_data->dowrite = 0; - goto end; - } else if(n == MBEDTLS_ERR_SSL_WANT_WRITE) { - /*LCOV_EXCL_START*/ - custom_poll_data->dowrite = 1; - custom_poll_data->doread = 0; - goto end; - /*LCOV_EXCL_STOP*/ - } - if(n == MBEDTLS_ERR_SSL_WANT_READ || n == MBEDTLS_ERR_SSL_WANT_WRITE) { - } else if(n < 0) { - /*LCOV_EXCL_START*/ - mbedtls_strerror(n, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_NOTICE, "mbedtls_ssl_handshake: %s", buffer); - uv_poll_stop(req); - return; - /*LCOV_EXCL_STOP*/ - } else { - custom_poll_data->ssl.handshake = 1; - } - custom_poll_data->dowrite = 1; - goto end; - } - - if(events & UV_WRITABLE) { - if(send_io->len > 0) { - if(custom_poll_data->is_ssl == 1) { - n = mbedtls_ssl_write(&custom_poll_data->ssl.ctx, (unsigned char *)send_io->buf, send_io->len); - if(n == MBEDTLS_ERR_SSL_WANT_READ) { - /*LCOV_EXCL_START*/ - custom_poll_data->doread = 1; - custom_poll_data->dowrite = 0; - goto end; - /*LCOV_EXCL_STOP*/ - } else if(n == MBEDTLS_ERR_SSL_WANT_WRITE) { - /*LCOV_EXCL_START*/ - custom_poll_data->dowrite = 1; - custom_poll_data->doread = 0; - goto end; - /*LCOV_EXCL_STOP*/ - } - if(n == MBEDTLS_ERR_SSL_WANT_READ || n == MBEDTLS_ERR_SSL_WANT_WRITE) { - } else if(n < 0) { - /*LCOV_EXCL_START*/ - mbedtls_strerror(n, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_NOTICE, "mbedtls_ssl_handshake: %s", buffer); - uv_poll_stop(req); - return; - /*LCOV_EXCL_STOP*/ - } - } else { - n = (int)send((unsigned int)fd, send_io->buf, send_io->len, 0); - } - if(n > 0) { - iobuf_remove(send_io, n); - if(send_io->len > 0) { - custom_poll_data->dowrite = 1; - } else { - custom_poll_data->dowrite = 0; - if(custom_poll_data->doclose == 1 && send_io->len == 0) { - custom_poll_data->doread = 0; - goto end; - } else { - custom_poll_data->dowrite = 0; - if(custom_poll_data->write_cb != NULL) { - custom_poll_data->write_cb(req); - } - } - } - } else if(n == 0) { - } else if(custom_poll_data->is_ssl == 0 && n < 0 && errno != EAGAIN && errno != EINTR) { - if(errno == ECONNRESET) { - uv_poll_stop(req); - return; - } else { - uv_poll_stop(req); - return; - } - } - } else { - custom_poll_data->dowrite = 0; - if(custom_poll_data->doclose == 1 && send_io->len == 0) { - custom_poll_data->doread = 0; - goto end; - } else { - custom_poll_data->dowrite = 0; - if(custom_poll_data->write_cb != NULL) { - custom_poll_data->write_cb(req); - } - } - } - } - - if(send_io->len > 0) { - custom_poll_data->dowrite = 1; - } - - if(events & UV_READABLE) { - if(custom_poll_data->is_ssl == 1) { - n = mbedtls_ssl_read(&custom_poll_data->ssl.ctx, (unsigned char *)buffer, BUFFER_SIZE); - if(n == MBEDTLS_ERR_SSL_WANT_READ) { - custom_poll_data->doread = 1; - custom_poll_data->dowrite = 0; - goto end; - } else if(n == MBEDTLS_ERR_SSL_WANT_WRITE) { - /*LCOV_EXCL_START*/ - custom_poll_data->dowrite = 1; - custom_poll_data->doread = 0; - goto end; - /*LCOV_EXCL_STOP*/ - } else if(n == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { - custom_poll_data->doread = 0; - if(custom_poll_data->read_cb != NULL) { - custom_poll_data->read_cb(req, &custom_poll_data->recv_iobuf.len, custom_poll_data->recv_iobuf.buf); - } - } - if(n == MBEDTLS_ERR_SSL_WANT_READ || n == MBEDTLS_ERR_SSL_WANT_WRITE) { - } else if(n < 0) { - if(n == MBEDTLS_ERR_NET_RECV_FAILED) { - /* - * FIXME: New client not yet accepted - */ - if(custom_poll_data->read_cb != NULL) { - one = 1; - custom_poll_data->read_cb(req, &one, NULL); - } - } else if(n != MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { - mbedtls_strerror(n, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_NOTICE, "mbedtls_ssl_handshake: %s", buffer); - uv_poll_stop(req); - } - return; - } - } else { - if(custom_poll_data->custom_recv == 0) { - if(custom_poll_data->is_udp == 1) { - n = (int)recv((unsigned int)fd, buffer, BUFFER_SIZE, 0); - } else { -#ifdef _WIN32 - n = recvfrom((SOCKET)fd, buffer, BUFFER_SIZE, 0, NULL, (socklen_t *)&fromlen); -#else - n = recvfrom(fd, buffer, BUFFER_SIZE, 0, NULL, (socklen_t *)&fromlen); -#endif - } - } - } - - if(custom_poll_data->custom_recv == 0) { - if(n > 0) { - iobuf_append(&custom_poll_data->recv_iobuf, buffer, n); - custom_poll_data->doread = 0; - if(custom_poll_data->read_cb != NULL) { - custom_poll_data->read_cb(req, &custom_poll_data->recv_iobuf.len, custom_poll_data->recv_iobuf.buf); - } - } else if(n < 0 && errno != EINTR) { -#ifdef _WIN32 - switch(WSAGetLastError()) { - case WSAENOTCONN: - if(custom_poll_data->read_cb != NULL) { - one = 1; - custom_poll_data->read_cb(req, &one, NULL); - } - break; - case WSAEWOULDBLOCK: -#else - switch(errno) { - case ENOTCONN: - if(custom_poll_data->read_cb != NULL) { - one = 1; - custom_poll_data->read_cb(req, &one, NULL); - } - break; -#if defined EAGAIN - case EAGAIN: -#endif -#if defined EWOULDBLOCK && EWOULDBLOCK != EAGAIN - case EWOULDBLOCK: -#endif -#endif - custom_poll_data->doread = 1; - break; - default: - break; - } - /* - * Client was disconnected - */ - } else if(n == 0) { - custom_poll_data->doclose = 1; - custom_poll_data->doread = 0; - goto end; - } - } else { - custom_poll_data->doread = 0; - if(custom_poll_data->read_cb != NULL) { - zero = 0; - custom_poll_data->read_cb(req, &zero, NULL); - } - } - } - -end: - eventpool_update_poll(req); -} - -static void iobuf_free(struct iobuf_t *iobuf) { - if(iobuf != NULL) { - uv_mutex_lock(&iobuf->lock); - if(iobuf->buf != NULL) { - FREE(iobuf->buf); - } - iobuf->len = iobuf->size = 0; - } - uv_mutex_unlock(&iobuf->lock); -} - -void uv_custom_poll_free(struct uv_custom_poll_t *data) { - if(data->is_ssl == 1) { - mbedtls_ssl_free(&data->ssl.ctx); - } - if(data->send_iobuf.size > 0) { - iobuf_free(&data->send_iobuf); - } - if(data->recv_iobuf.size > 0) { - iobuf_free(&data->recv_iobuf); - } - - FREE(data); -} - -static void iobuf_init(struct iobuf_t *iobuf, size_t initial_size) { - iobuf->len = iobuf->size = 0; - iobuf->buf = NULL; - uv_mutex_init(&iobuf->lock); -} - -void uv_custom_poll_init(struct uv_custom_poll_t **custom_poll, uv_poll_t *poll, void *data) { - if((*custom_poll = MALLOC(sizeof(struct uv_custom_poll_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(*custom_poll, '\0', sizeof(struct uv_custom_poll_t)); - iobuf_init(&(*custom_poll)->send_iobuf, 0); - iobuf_init(&(*custom_poll)->recv_iobuf, 0); - - poll->data = *custom_poll; - (*custom_poll)->data = data; -} - -int uv_custom_close(uv_poll_t *req) { - struct uv_custom_poll_t *custom_poll_data = req->data; - struct iobuf_t *send_io = NULL; - - if(uv_is_closing((uv_handle_t *)req)) { - return -1; - } - - if(custom_poll_data != NULL) { - custom_poll_data->doclose = 1; - } - - send_io = &custom_poll_data->send_iobuf; - - if(custom_poll_data->doclose == 1 && send_io->len == 0) { - custom_poll_data->doclose = 2; - if(custom_poll_data->close_cb != NULL) { - custom_poll_data->close_cb(req); - } - if(!uv_is_closing((uv_handle_t *)req)) { - uv_poll_stop(req); - } - } else if(send_io->len > 0) { - uv_custom_write(req); - } - - return 0; -} - -int uv_custom_read(uv_poll_t *req) { - struct uv_custom_poll_t *custom_poll_data = req->data; - - if(uv_is_closing((uv_handle_t *)req)) { - return -1; - } - - if(custom_poll_data != NULL) { - custom_poll_data->doread = 1; - } - - // if(custom_poll_data->started == 0) { - eventpool_update_poll(req); - // } - return 0; -} - -int uv_custom_write(uv_poll_t *req) { - struct uv_custom_poll_t *custom_poll_data = req->data; - - if(uv_is_closing((uv_handle_t *)req)) { - return -1; - } - - if(custom_poll_data != NULL) { - custom_poll_data->dowrite = 1; - } - - // if(custom_poll_data->started == 0) { - eventpool_update_poll(req); - // } - return 0; -} - -void eventpool_init(enum eventpool_threads_t t) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - if(eventpoolinit == 1) { - return; - } - eventpoolinit = 1; - threads = t; - - if((async_req = MALLOC(sizeof(uv_async_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - uv_async_init(uv_default_loop(), async_req, eventpool_execute); - - if(lockinit == 0) { - lockinit = 1; - // pthread_mutexattr_init(&listeners_attr); - // pthread_mutexattr_settype(&listeners_attr, PTHREAD_MUTEX_RECURSIVE); - // pthread_mutex_init(&listeners_lock, &listeners_attr); - uv_mutex_init(&listeners_lock); - } -} - -enum eventpool_threads_t eventpool_threaded(void) { - return threads; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/eventpool.h b/lib/ESPiLight/pilight/libs/pilight/core/eventpool.h deleted file mode 100644 index 73d411a..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/eventpool.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2015 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _EVENTPOOL_H_ -#define _EVENTPOOL_H_ - -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #include - #include - #define MSG_NOSIGNAL 0 -#else - #include - #include -#endif -#include -#include -#include - -#include "../../libuv/uv.h" -#include "eventpool_structs.h" - -enum eventpool_threads_t { - EVENTPOOL_NO_THREADS, - EVENTPOOL_THREADED -} eventpool_threads_t; - -#define EVENTPOOL_STAGE_SOCKET 0 -#define EVENTPOOL_STAGE_CONNECT 1 -#define EVENTPOOL_STAGE_CONNECTING 2 -#define EVENTPOOL_STAGE_CONNECTED 3 -#define EVENTPOOL_STAGE_BIND 4 -#define EVENTPOOL_STAGE_LISTEN 5 -#define EVENTPOOL_STAGE_LISTENING 6 -#define EVENTPOOL_STAGE_READ 7 -#define EVENTPOOL_STAGE_WRITE 8 -#define EVENTPOOL_STAGE_DISCONNECTED 9 -#define EVENTPOOL_STAGE_DISCONNECT 10 - -#define EVENTPOOL_TYPE_SOCKET_CLIENT 0 -#define EVENTPOOL_TYPE_SOCKET_SERVER 1 -#define EVENTPOOL_TYPE_SOCKET_SSL_CLIENT 2 -#define EVENTPOOL_TYPE_SOCKET_SSL_SERVER 3 -#define EVENTPOOL_TYPE_IO 4 - -#define EV_SOCKET_SUCCESS 0 -#define EV_SOCKET_FAILED 1 -#define EV_CONNECT_SUCCESS 2 -#define EV_CONNECT_FAILED 3 -#define EV_BIND_SUCCESS 4 -#define EV_BIND_FAILED 5 -#define EV_LISTEN_SUCCESS 6 -#define EV_LISTEN_FAILED 7 -#define EV_READ 8 -#define EV_WRITE 9 -#define EV_HIGHPRI 10 -#define EV_IDLE 11 -#define EV_DISCONNECTED 12 -// #define EV_POLL 13 - -#define REASON_SEND_CODE 0 -#define REASON_CONTROL_DEVICE 1 -#define REASON_CODE_SENT 2 -#define REASON_CODE_SEND_FAIL 3 -#define REASON_CODE_SEND_SUCCESS 4 -#define REASON_CODE_RECEIVED 5 -#define REASON_RECEIVED_PULSETRAIN 6 -#define REASON_BROADCAST 7 -#define REASON_BROADCAST_CORE 8 -#define REASON_FORWARD 9 -#define REASON_CONFIG_UPDATE 10 -#define REASON_CONFIG_UPDATED 11 -#define REASON_SOCKET_RECEIVED 12 -#define REASON_SOCKET_DISCONNECTED 13 -#define REASON_SOCKET_CONNECTED 14 -#define REASON_SOCKET_SEND 15 -#define REASON_SSDP_RECEIVED 16 -#define REASON_SSDP_RECEIVED_FREE 17 -#define REASON_SSDP_DISCONNECTED 18 -#define REASON_SSDP_CONNECTED 19 -#define REASON_WEBSERVER_CONNECTED 20 -#define REASON_DEVICE_ADDED 21 -#define REASON_DEVICE_ADAPT 22 -#define REASON_ADHOC_MODE 23 -#define REASON_ADHOC_CONNECTED 24 -#define REASON_ADHOC_CONFIG_RECEIVED 25 -#define REASON_ADHOC_DATA_RECEIVED 26 -#define REASON_ADHOC_UPDATE_RECEIVED 27 -#define REASON_ADHOC_DISCONNECTED 28 -#define REASON_SEND_BEGIN 29 -#define REASON_SEND_END 30 -#define REASON_ARP_FOUND_DEVICE 31 -#define REASON_ARP_LOST_DEVICE 32 -#define REASON_ARP_CHANGED_DEVICE 33 -#define REASON_LOG 34 -#define REASON_END 35 - -typedef struct threadpool_data_t { - int reason; - int priority; - char name[255]; - uv_sem_t *ref; - void *userdata; - void *(*func)(int, void *); - void *(*done)(void *); -} threadpool_data_t; - -typedef struct threadpool_tasks_t { - unsigned long id; - char *name; - void *(*func)(int, void *); - void *(*done)(void *); - uv_sem_t *ref; - int priority; - int reason; - - struct { - struct timespec first; - struct timespec second; - } timestamp; - - void *userdata; - - struct threadpool_tasks_t *next; -} threadpool_tasks_t; - -typedef struct eventpool_listener_t { - void *(*func)(int, void *); - void *userdata; - int reason; - struct eventpool_listener_t *next; -} eventpool_listener_t; - -typedef struct iobuf_t { - char *buf; - ssize_t len; - ssize_t size; - uv_mutex_t lock; -} iobuf_t; - -struct uv_custom_poll_t { - int is_ssl; - int is_server; - int is_udp; - int custom_recv; - int doread; - int dowrite; - int doclose; - int started; - int action; - uv_timer_t *timer_req; - uv_poll_t *poll_req; - - void *data; - - void (*write_cb)(uv_poll_t *); - void (*close_cb)(uv_poll_t *); - void (*read_cb)(uv_poll_t *, ssize_t *, char *); - - struct { - int init; - int handshake; - mbedtls_ssl_context ctx; - } ssl; - - struct iobuf_t recv_iobuf; - struct iobuf_t send_iobuf; -} uv_custom_poll_t; - -void eventpool_callback(int, void *(*)(int, void *)); -void eventpool_trigger(int, void *(*)(void *), void *); -void eventpool_init(enum eventpool_threads_t); -int eventpool_gc(void); - -void iobuf_remove(struct iobuf_t *, size_t); -size_t iobuf_append(struct iobuf_t *, const void *, int); - -void uv_custom_poll_init(struct uv_custom_poll_t **, uv_poll_t *, void *); -void uv_custom_poll_free(struct uv_custom_poll_t *); -void uv_custom_poll_cb(uv_poll_t *, int, int); -int uv_custom_read(uv_poll_t *); -int uv_custom_write(uv_poll_t *); -int uv_custom_close(uv_poll_t *); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/eventpool_structs.h b/lib/ESPiLight/pilight/libs/pilight/core/eventpool_structs.h deleted file mode 100644 index 3a25d05..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/eventpool_structs.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright (C) 2015 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _EVENTPOOL_STRUCTS_H_ -#define _EVENTPOOL_STRUCTS_H_ - -#include "defines.h" -#include "eventpool_structs.h" - -typedef struct reason_log_t { - char *buffer; -} reason_log_t; - -typedef struct reason_ssdp_received_t { - char name[17]; - char uuid[UUID_LENGTH+1]; - char ip[INET_ADDRSTRLEN+1]; - int port; -} reason_ssdp_received_t; - -typedef struct reason_received_pulsetrain_t { - int length; - int pulses[MAXPULSESTREAMLENGTH+1]; - char *hardware; -} reason_received_pulsetrain_t; - -typedef struct reason_code_received_t { - char message[1025]; - char origin[256]; - char *protocol; - char *uuid; - - int repeat; -} reason_code_received_t; - -typedef struct reason_code_sent_t { - char message[1025]; - char protocol[256]; - char origin[256]; - char uuid[UUID_LENGTH+1]; - - int type; - int repeat; -} reason_code_sent_t; - -typedef struct reason_code_sent_fail_t { - char message[1025]; - char uuid[UUID_LENGTH+1]; -} reason_code_sent_failed_t; - -typedef struct reason_code_sent_success_t { - char message[1025]; - char uuid[UUID_LENGTH+1]; -} reason_code_sent_success_t; - -typedef struct reason_socket_disconnected_t { - int fd; -} reason_socket_disconnected_t; - -typedef struct reason_socket_connected_t { - int fd; -} reason_socket_connected_t; - -typedef struct reason_ssdp_disconnected_t { - int fd; -} reason_ssdp_disconnected_t; - -typedef struct reason_webserver_connected_t { - int fd; -} reason_webserver_connected_t; - -typedef struct reason_socket_received_t { - int fd; - char *buffer; - char type[256]; - int endpoint; -} reason_socket_received_t; - -typedef struct reason_socket_send_t { - int fd; - char *buffer; - char type[256]; -} reason_socket_send_t; - -typedef struct reason_send_code_t { - int origin; - char message[1025]; - int rawlen; - int txrpt; - int pulses[MAXPULSESTREAMLENGTH+1]; - char protocol[256]; - int hwtype; - char uuid[UUID_LENGTH+1]; -} reason_send_code_t; - -typedef struct reason_config_update_t { - char origin[256]; - int type; - time_t timestamp; - int nrdev; - char devices[256][256]; - int nrval; - struct { - char name[256]; - union { - char string_[256]; - double number_; - }; - int decimals; - int type; - } values[256]; - char *uuid; -} reason_config_update_t; - -#define reason_config_updated_t reason_config_update_t - -typedef struct reason_control_device_t { - char *dev; - char *state; - struct JsonNode *values; -} reason_control_device_t; - -typedef struct reason_arp_device_t { - char mac[18]; - char ip[INET_ADDRSTRLEN]; -} reason_arp_device_t; - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/fcache.c b/lib/ESPiLight/pilight/libs/pilight/core/fcache.c deleted file mode 100644 index 36f9250..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/fcache.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include - -#include "fcache.h" -#include "common.h" -#include "mem.h" -#include "log.h" -#include "gc.h" - -int fcache_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct fcache_t *tmp = fcache; - while(fcache) { - tmp = fcache; - FREE(tmp->name); - FREE(tmp->bytes); - fcache = fcache->next; - FREE(tmp); - } - if(fcache != NULL) { - FREE(fcache); - } - - logprintf(LOG_DEBUG, "garbage collected fcache library"); - return 1; -} - -void fcache_remove_node(struct fcache_t **cache, char *name) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct fcache_t *currP, *prevP; - - prevP = NULL; - - for(currP = *cache; currP != NULL; prevP = currP, currP = currP->next) { - - if(strcmp(currP->name, name) == 0) { - if(prevP == NULL) { - *cache = currP->next; - } else { - prevP->next = currP->next; - } - - FREE(currP->name); - FREE(currP->bytes); - FREE(currP); - - break; - } - } -} - -int fcache_rm(char *filename) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - fcache_remove_node(&fcache, filename); - logprintf(LOG_DEBUG, "removed %s from cache", filename); - return 1; -} - -int fcache_add(char *filename) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - size_t filesize = 0; - FILE *fp = NULL; - - logprintf(LOG_NOTICE, "caching %s", filename); - -/* - * dir stat doens't work on Windows if path has a trailing slash - */ -#ifdef _WIN32 - size_t i = strlen(filename); - if(filename[i-1] == '\\' || filename[i-1] == '/') { - filename[i-1] = '\0'; - } -#endif - - if((fp = fopen(filename, "rb")) == NULL) { - logprintf(LOG_NOTICE, "failed to open %s", filename); - return -1; - } else { - struct fcache_t *node = MALLOC(sizeof(struct fcache_t)); - if(node == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - fseek(fp, 0, SEEK_END); - filesize = (size_t)ftell(fp); - fseek(fp, 0, SEEK_SET); - if((node->bytes = MALLOC(filesize + 1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(node->bytes, '\0', filesize + 1); - if(fread(node->bytes, 1, filesize, fp) != filesize) { - logprintf(LOG_NOTICE, "error reading %s", filename); - FREE(node->bytes); - FREE(node); - fclose(fp); - return -1; - } - node->size = (int)filesize; - if((node->name = MALLOC(strlen(filename)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(node->name, filename); - node->next = fcache; - fcache = node; - fclose(fp); - return 0; - } - fclose(fp); - return -1; -} - -short fcache_get_size(char *filename, int *out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct fcache_t *ftmp = fcache; - while(ftmp) { - if(strcmp(ftmp->name, filename) == 0) { - *out = ftmp->size; - return 0; - } - ftmp = ftmp->next; - } - return -1; -} - -unsigned char *fcache_get_bytes(char *filename) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct fcache_t *ftmp = fcache; - while(ftmp) { - if(strcmp(ftmp->name, filename) == 0) { - return ftmp->bytes; - } - ftmp = ftmp->next; - } - return NULL; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/fcache.h b/lib/ESPiLight/pilight/libs/pilight/core/fcache.h deleted file mode 100644 index 147d45c..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/fcache.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2013 CurlyMo - -This file is part of Splash - Linux GUI Framebuffer Splash. - -Splash 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 3 of the License, or (at your option) any later -version. - -Splash 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 Splash. If not, see -*/ - -#ifndef _FCACHE_H_ -#define _FCACHE_H_ - -typedef struct fcache_t { - char *name; - int size; - unsigned char *bytes; - struct fcache_t *next; -} fcaches_t; - -struct fcache_t *fcache; - -int fcache_gc(void); -int fcache_add(char *filename); -int fcache_rm(char *filename); -short fcache_get_size(char *filename, int *out); -unsigned char *fcache_get_bytes(char *filename); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/firmware.c b/lib/ESPiLight/pilight/libs/pilight/core/firmware.c deleted file mode 100644 index 77ef2c9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/firmware.c +++ /dev/null @@ -1,1260 +0,0 @@ -/* - * avrdude - A Downloader/Uploader for AVR device programmers - * Copyright (C) 2000-2005 Brian S. Dean - * Copyright 2007-2009 Joerg Wunsch - * - * 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 of the License, 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 - */ - -/* $Id: main.c 916 2010-01-15 16:36:13Z joerg_wunsch $ */ - -/* - * Code to program an Atmel AVR device through one of the supported - * programmers. - * - * For parallel port connected programmers, the pin definitions can be - * changed via a config file. See the config file for instructions on - * how to add a programmer definition. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #define STRICT - #define WIN32_LEAN_AND_MEAN - #include -#else - #include -#endif - -#include "../../avrdude/avr.h" -#include "../../avrdude/arduino.h" -#ifndef _WIN32 - #include "../../avrdude/avrgpio.h" -#endif -#include "../../avrdude/fileio.h" -#include "../../avrdude/avrpart.h" -#include "../../avrdude/avrconfig.h" -#include "../../avrdude/avrupd.h" -#include "../../avrdude/safemode.h" -#include "../config/settings.h" -#include "firmware.h" -#include "pilight.h" -#include "common.h" -#include "log.h" - -/* - -pgm_bits: pgm_enable -read_bits: memory signature - read -chip_erase: chip_erase -writepage_bits: memory flash - writepage -... -*/ - -#ifdef _WIN32 - static int baudrate = 57600; -#else - static int baudrate = B57600; -#endif -static int mptype = FW_MP_UNKNOWN; -static char comport[255]; - -static void firmware_atmega328p(struct avrpart **p) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char pgm_bits[] = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 x x x x x x x x x x x x x x x x"; - char read_bits[] = "0 0 1 1 0 0 0 0 0 0 0 x x x x x x x x x x x a1 a0 o o o o o o o o"; - char erase_bits[] = "1 0 1 0 1 1 0 0 1 0 0 x x x x x x x x x x x x x x x x x x x x x"; - char writepage_bits[] = "0 1 0 0 1 1 0 0 0 0 a13 a12 a11 a10 a9 a8 a7 a6 x x x x x x x x x x x x x x"; - char readlo_bits[] = "0 0 1 0 0 0 0 0 0 0 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char readhigh_bits[] = "0 0 1 0 1 0 0 0 0 0 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char loadpagelo_bits[] = "0 1 0 0 0 0 0 0 0 0 0 x x x x x x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - char loadpagehigh_bits[] = "0 1 0 0 1 0 0 0 0 0 0 x x x x x x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - char lfuseread_bits[] = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x o o o o o o o o"; - char lfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0 x x x x x x x x i i i i i i i i"; - char hfuseread_bits[] = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 x x x x x x x x o o o o o o o o"; - char hfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 x x x x x x x x i i i i i i i i"; - - *p = avr_new_part(); - strcpy((*p)->id, "m328p"); - strcpy((*p)->desc, "ATmega328P"); - - (*p)->signature[0] = 0x1e; - (*p)->signature[1] = 0x95; - (*p)->signature[2] = 0x0f; - - (*p)->op[AVR_OP_PGM_ENABLE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_PGM_ENABLE], pgm_bits); - - (*p)->op[AVR_OP_CHIP_ERASE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_CHIP_ERASE], erase_bits); - - (*p)->sigmem = avr_new_memtype(); - strcpy((*p)->sigmem->desc, "signature"); - (*p)->sigmem->size = 3; - (*p)->sigmem->buf = MALLOC((size_t)(*p)->sigmem->size+(size_t)1); - (*p)->sigmem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->sigmem->op[AVR_OP_READ], read_bits); - - (*p)->flashmem = avr_new_memtype(); - strcpy((*p)->flashmem->desc, "flash"); - - (*p)->flashmem->paged = 1; - (*p)->flashmem->size = 32768; - (*p)->flashmem->page_size = 128; - (*p)->flashmem->num_pages = 256; - (*p)->flashmem->min_write_delay = 4500; - (*p)->flashmem->max_write_delay = 4500; - (*p)->flashmem->readback[0] = 0xff; - (*p)->flashmem->readback[1] = 0xff; - - (*p)->flashmem->op[AVR_OP_WRITEPAGE] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_WRITEPAGE], writepage_bits); - - (*p)->flashmem->op[AVR_OP_READ_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_LO], readlo_bits); - - (*p)->flashmem->op[AVR_OP_READ_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_HI], readhigh_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_LO], loadpagelo_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_HI], loadpagehigh_bits); - - (*p)->lfusemem = avr_new_memtype(); - strcpy((*p)->lfusemem->desc, "lfuse"); - - (*p)->lfusemem->size = 1; - (*p)->lfusemem->buf = MALLOC((size_t)(*p)->lfusemem->size+(size_t)1); - - (*p)->lfusemem->min_write_delay = 4500; - (*p)->lfusemem->max_write_delay = 4500; - - (*p)->lfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_READ], lfuseread_bits); - - (*p)->lfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_WRITE], lfusewrite_bits); - - (*p)->hfusemem = avr_new_memtype(); - strcpy((*p)->hfusemem->desc, "hfuse"); - - (*p)->hfusemem->size = 1; - (*p)->hfusemem->buf = MALLOC((size_t)(*p)->hfusemem->size+(size_t)1); - - (*p)->hfusemem->min_write_delay = 4500; - (*p)->hfusemem->max_write_delay = 4500; - - (*p)->hfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_READ], hfuseread_bits); - - (*p)->hfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_WRITE], hfusewrite_bits); -} - -// static void firmware_atmega32u4(struct avrpart **p) { - // logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - // char pgm_bits[] = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 x x x x x x x x x x x x x x x x"; - // char read_bits[] = "0 0 1 1 0 0 0 0 x x x x x x x x x x x x x x a1 a0 o o o o o o o o"; - // char erase_bits[] = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 x x x x x x x x x x x x x x x x"; - // char writepage_bits[] = "0 1 0 0 1 1 0 0 a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 x x x x x x x x x x x x x x"; - // char readlo_bits[] = "0 0 1 0 0 0 0 0 0 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - // char readhigh_bits[] = "0 0 1 0 1 0 0 0 0 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - // char loadpagelo_bits[] = "0 1 0 0 0 0 0 0 x x x x x x x x x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - // char loadpagehigh_bits[] = "0 1 0 0 1 0 0 0 0 0 0 x x x x x x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - // char lfuseread_bits[] = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x o o o o o o o o"; - // char lfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0 x x x x x x x x i i i i i i i i"; - // char hfuseread_bits[] = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 x x x x x x x x o o o o o o o o"; - // char hfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 x x x x x x x x i i i i i i i i"; - - // *p = avr_new_part(); - // strcpy((*p)->id, "m32u4"); - // strcpy((*p)->desc, "ATmega32U4"); - - // (*p)->signature[0] = 0x1e; - // (*p)->signature[1] = 0x95; - // (*p)->signature[2] = 0x87; - - // (*p)->op[AVR_OP_PGM_ENABLE] = avr_new_opcode(); - // parse_cmdbits((*p)->op[AVR_OP_PGM_ENABLE], pgm_bits); - - // (*p)->op[AVR_OP_CHIP_ERASE] = avr_new_opcode(); - // parse_cmdbits((*p)->op[AVR_OP_CHIP_ERASE], erase_bits); - - // (*p)->sigmem = avr_new_memtype(); - // strcpy((*p)->sigmem->desc, "signature"); - // (*p)->sigmem->size = 3; - // (*p)->sigmem->buf = MALLOC((size_t)(*p)->sigmem->size+(size_t)1); - // (*p)->sigmem->op[AVR_OP_READ] = avr_new_opcode(); - // parse_cmdbits((*p)->sigmem->op[AVR_OP_READ], read_bits); - - // (*p)->flashmem = avr_new_memtype(); - // strcpy((*p)->flashmem->desc, "flash"); - - // (*p)->flashmem->paged = 1; - // (*p)->flashmem->size = 32768; - // (*p)->flashmem->page_size = 128; - // (*p)->flashmem->num_pages = 256; - // (*p)->flashmem->min_write_delay = 4500; - // (*p)->flashmem->max_write_delay = 4500; - // (*p)->flashmem->readback[0] = 0x00; - // (*p)->flashmem->readback[1] = 0x00; - - // (*p)->flashmem->op[AVR_OP_WRITEPAGE] = avr_new_opcode(); - // parse_cmdbits((*p)->flashmem->op[AVR_OP_WRITEPAGE], writepage_bits); - - // (*p)->flashmem->op[AVR_OP_READ_LO] = avr_new_opcode(); - // parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_LO], readlo_bits); - - // (*p)->flashmem->op[AVR_OP_READ_HI] = avr_new_opcode(); - // parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_HI], readhigh_bits); - - // (*p)->flashmem->op[AVR_OP_LOADPAGE_LO] = avr_new_opcode(); - // parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_LO], loadpagelo_bits); - - // (*p)->flashmem->op[AVR_OP_LOADPAGE_HI] = avr_new_opcode(); - // parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_HI], loadpagehigh_bits); - - // (*p)->lfusemem = avr_new_memtype(); - // strcpy((*p)->lfusemem->desc, "lfuse"); - - // (*p)->lfusemem->size = 1; - // (*p)->lfusemem->buf = MALLOC((size_t)(*p)->lfusemem->size+(size_t)1); - - // (*p)->lfusemem->min_write_delay = 9000; - // (*p)->lfusemem->max_write_delay = 9000; - - // (*p)->lfusemem->op[AVR_OP_READ] = avr_new_opcode(); - // parse_cmdbits((*p)->lfusemem->op[AVR_OP_READ], lfuseread_bits); - - // (*p)->lfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - // parse_cmdbits((*p)->lfusemem->op[AVR_OP_WRITE], lfusewrite_bits); - - // (*p)->hfusemem = avr_new_memtype(); - // strcpy((*p)->hfusemem->desc, "hfuse"); - - // (*p)->hfusemem->size = 1; - // (*p)->hfusemem->buf = MALLOC((size_t)(*p)->hfusemem->size+(size_t)1); - - // (*p)->hfusemem->min_write_delay = 9000; - // (*p)->hfusemem->max_write_delay = 9000; - - // (*p)->hfusemem->op[AVR_OP_READ] = avr_new_opcode(); - // parse_cmdbits((*p)->hfusemem->op[AVR_OP_READ], hfuseread_bits); - - // (*p)->hfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - // parse_cmdbits((*p)->hfusemem->op[AVR_OP_WRITE], hfusewrite_bits); -// } - -static void firmware_attiny25(struct avrpart **p) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char pgm_bits[] = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 x x x x x x x x x x x x x x x x"; - char read_bits[] = "0 0 1 1 0 0 0 0 0 0 0 x x x x x x x x x x x a1 a0 o o o o o o o o"; - char erase_bits[] = "1 0 1 0 1 1 0 0 1 0 0 x x x x x x x x x x x x x x x x x x x x x"; - char writepage_bits[] = "0 1 0 0 1 1 0 0 0 0 0 0 0 0 a9 a8 a7 a6 a5 a4 x x x x x x x x x x x x"; - char readlo_bits[] = "0 0 1 0 0 0 0 0 0 0 0 0 0 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char readhigh_bits[] = "0 0 1 0 1 0 0 0 0 0 0 0 0 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char loadpagelo_bits[] = "0 1 0 0 0 0 0 0 0 0 0 x x x x x x x x x a3 a2 a1 a0 i i i i i i i i"; - char loadpagehigh_bits[] = "0 1 0 0 1 0 0 0 0 0 0 x x x x x x x x x a3 a2 a1 a0 i i i i i i i i"; - char lfuseread_bits[] = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x o o o o o o o o"; - char lfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0 x x x x x x x x i i i i i i i i"; - char hfuseread_bits[] = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 x x x x x x x x o o o o o o o o"; - char hfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 x x x x x x x x i i i i i i i i"; - - *p = avr_new_part(); - strcpy((*p)->id, "t25"); - strcpy((*p)->desc, "ATtiny25"); - - (*p)->signature[0] = 0x1e; - (*p)->signature[1] = 0x91; - (*p)->signature[2] = 0x08; - - (*p)->op[AVR_OP_PGM_ENABLE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_PGM_ENABLE], pgm_bits); - - (*p)->op[AVR_OP_CHIP_ERASE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_CHIP_ERASE], erase_bits); - - (*p)->sigmem = avr_new_memtype(); - strcpy((*p)->sigmem->desc, "signature"); - (*p)->sigmem->size = 3; - (*p)->sigmem->buf = MALLOC((size_t)(*p)->sigmem->size+(size_t)1); - (*p)->sigmem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->sigmem->op[AVR_OP_READ], read_bits); - - (*p)->flashmem = avr_new_memtype(); - strcpy((*p)->flashmem->desc, "flash"); - - (*p)->flashmem->paged = 1; - (*p)->flashmem->size = 2048; - (*p)->flashmem->page_size = 32; - (*p)->flashmem->num_pages = 64; - (*p)->flashmem->min_write_delay = 4500; - (*p)->flashmem->max_write_delay = 4500; - (*p)->flashmem->readback[0] = 0xff; - (*p)->flashmem->readback[1] = 0xff; - - (*p)->flashmem->op[AVR_OP_WRITEPAGE] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_WRITEPAGE], writepage_bits); - - (*p)->flashmem->op[AVR_OP_READ_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_LO], readlo_bits); - - (*p)->flashmem->op[AVR_OP_READ_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_HI], readhigh_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_LO], loadpagelo_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_HI], loadpagehigh_bits); - - (*p)->lfusemem = avr_new_memtype(); - strcpy((*p)->lfusemem->desc, "lfuse"); - - (*p)->lfusemem->size = 1; - (*p)->lfusemem->buf = MALLOC((size_t)(*p)->lfusemem->size+(size_t)1); - - (*p)->lfusemem->min_write_delay = 9000; - (*p)->lfusemem->max_write_delay = 9000; - - (*p)->lfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_READ], lfuseread_bits); - - (*p)->lfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_WRITE], lfusewrite_bits); - - (*p)->hfusemem = avr_new_memtype(); - strcpy((*p)->hfusemem->desc, "hfuse"); - - (*p)->hfusemem->size = 1; - (*p)->hfusemem->buf = MALLOC((size_t)(*p)->hfusemem->size+(size_t)1); - - (*p)->hfusemem->min_write_delay = 9000; - (*p)->hfusemem->max_write_delay = 9000; - - (*p)->hfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_READ], hfuseread_bits); - - (*p)->hfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_WRITE], hfusewrite_bits); -} - -static void firmware_attiny45(struct avrpart **p) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char pgm_bits[] = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 x x x x x x x x x x x x x x x x"; - char read_bits[] = "0 0 1 1 0 0 0 0 0 0 0 x x x x x x x x x x x a1 a0 o o o o o o o o"; - char erase_bits[] = "1 0 1 0 1 1 0 0 1 0 0 x x x x x x x x x x x x x x x x x x x x x"; - char writepage_bits[] = "0 1 0 0 1 1 0 0 0 0 0 0 0 a10 a9 a8 a7 a6 a5 x x x x x x x x x x x x x"; - char readlo_bits[] = "0 0 1 0 0 0 0 0 0 0 0 0 0 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char readhigh_bits[] = "0 0 1 0 1 0 0 0 0 0 0 0 0 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char loadpagelo_bits[] = "0 1 0 0 0 0 0 0 0 0 0 x x x x x x x x a4 a3 a2 a1 a0 i i i i i i i i"; - char loadpagehigh_bits[] = "0 1 0 0 1 0 0 0 0 0 0 x x x x x x x x a4 a3 a2 a1 a0 i i i i i i i i"; - char lfuseread_bits[] = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x o o o o o o o o"; - char lfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0 x x x x x x x x i i i i i i i i"; - char hfuseread_bits[] = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 x x x x x x x x o o o o o o o o"; - char hfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 x x x x x x x x i i i i i i i i"; - - *p = avr_new_part(); - strcpy((*p)->id, "t45"); - strcpy((*p)->desc, "ATtiny45"); - - (*p)->signature[0] = 0x1e; - (*p)->signature[1] = 0x92; - (*p)->signature[2] = 0x06; - - (*p)->op[AVR_OP_PGM_ENABLE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_PGM_ENABLE], pgm_bits); - - (*p)->op[AVR_OP_CHIP_ERASE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_CHIP_ERASE], erase_bits); - - (*p)->sigmem = avr_new_memtype(); - strcpy((*p)->sigmem->desc, "signature"); - (*p)->sigmem->size = 3; - (*p)->sigmem->buf = MALLOC((size_t)(*p)->sigmem->size+(size_t)1); - (*p)->sigmem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->sigmem->op[AVR_OP_READ], read_bits); - - (*p)->flashmem = avr_new_memtype(); - strcpy((*p)->flashmem->desc, "flash"); - - (*p)->flashmem->paged = 1; - (*p)->flashmem->size = 4096; - (*p)->flashmem->page_size = 64; - (*p)->flashmem->num_pages = 64; - (*p)->flashmem->min_write_delay = 4500; - (*p)->flashmem->max_write_delay = 4500; - (*p)->flashmem->readback[0] = 0xff; - (*p)->flashmem->readback[1] = 0xff; - - (*p)->flashmem->op[AVR_OP_WRITEPAGE] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_WRITEPAGE], writepage_bits); - - (*p)->flashmem->op[AVR_OP_READ_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_LO], readlo_bits); - - (*p)->flashmem->op[AVR_OP_READ_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_HI], readhigh_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_LO], loadpagelo_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_HI], loadpagehigh_bits); - - (*p)->lfusemem = avr_new_memtype(); - strcpy((*p)->lfusemem->desc, "lfuse"); - - (*p)->lfusemem->size = 1; - (*p)->lfusemem->buf = MALLOC((size_t)(*p)->lfusemem->size+(size_t)1); - - (*p)->lfusemem->min_write_delay = 9000; - (*p)->lfusemem->max_write_delay = 9000; - - (*p)->lfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_READ], lfuseread_bits); - - (*p)->lfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_WRITE], lfusewrite_bits); - - (*p)->hfusemem = avr_new_memtype(); - strcpy((*p)->hfusemem->desc, "hfuse"); - - (*p)->hfusemem->size = 1; - (*p)->hfusemem->buf = MALLOC((size_t)(*p)->hfusemem->size+(size_t)1); - - (*p)->hfusemem->min_write_delay = 9000; - (*p)->hfusemem->max_write_delay = 9000; - - (*p)->hfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_READ], hfuseread_bits); - - (*p)->hfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_WRITE], hfusewrite_bits); -} - -static void firmware_attiny85(struct avrpart **p) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char pgm_bits[] = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 x x x x x x x x x x x x x x x x"; - char read_bits[] = "0 0 1 1 0 0 0 0 0 0 0 x x x x x x x x x x x a1 a0 o o o o o o o o"; - char erase_bits[] = "1 0 1 0 1 1 0 0 1 0 0 x x x x x x x x x x x x x x x x x x x x x"; - char writepage_bits[] = "0 1 0 0 1 1 0 0 0 0 0 0 a11 a10 a9 a8 a7 a6 a5 x x x x x x x x x x x x x"; - char readlo_bits[] = "0 0 1 0 0 0 0 0 0 0 0 0 0 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char readhigh_bits[] = "0 0 1 0 1 0 0 0 0 0 0 0 0 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - char loadpagelo_bits[] = "0 1 0 0 0 0 0 0 0 0 0 x x x x x x x x a4 a3 a2 a1 a0 i i i i i i i i"; - char loadpagehigh_bits[] = "0 1 0 0 1 0 0 0 0 0 0 x x x x x x x x a4 a3 a2 a1 a0 i i i i i i i i"; - char lfuseread_bits[] = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 x x x x x x x x o o o o o o o o"; - char lfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0 x x x x x x x x i i i i i i i i"; - char hfuseread_bits[] = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 x x x x x x x x o o o o o o o o"; - char hfusewrite_bits[] = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 x x x x x x x x i i i i i i i i"; - - *p = avr_new_part(); - strcpy((*p)->id, "t85"); - strcpy((*p)->desc, "ATtiny85"); - - (*p)->signature[0] = 0x1e; - (*p)->signature[1] = 0x93; - (*p)->signature[2] = 0x0b; - - (*p)->op[AVR_OP_PGM_ENABLE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_PGM_ENABLE], pgm_bits); - - (*p)->op[AVR_OP_CHIP_ERASE] = avr_new_opcode(); - parse_cmdbits((*p)->op[AVR_OP_CHIP_ERASE], erase_bits); - - (*p)->sigmem = avr_new_memtype(); - strcpy((*p)->sigmem->desc, "signature"); - (*p)->sigmem->size = 3; - (*p)->sigmem->buf = MALLOC((size_t)(*p)->sigmem->size+(size_t)1); - (*p)->sigmem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->sigmem->op[AVR_OP_READ], read_bits); - - (*p)->flashmem = avr_new_memtype(); - strcpy((*p)->flashmem->desc, "flash"); - - (*p)->flashmem->paged = 1; - (*p)->flashmem->size = 8192; - (*p)->flashmem->page_size = 64; - (*p)->flashmem->num_pages = 128; - (*p)->flashmem->min_write_delay = 4500; - (*p)->flashmem->max_write_delay = 4500; - (*p)->flashmem->readback[0] = 0xff; - (*p)->flashmem->readback[1] = 0xff; - - (*p)->flashmem->op[AVR_OP_WRITEPAGE] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_WRITEPAGE], writepage_bits); - - (*p)->flashmem->op[AVR_OP_READ_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_LO], readlo_bits); - - (*p)->flashmem->op[AVR_OP_READ_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_READ_HI], readhigh_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_LO] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_LO], loadpagelo_bits); - - (*p)->flashmem->op[AVR_OP_LOADPAGE_HI] = avr_new_opcode(); - parse_cmdbits((*p)->flashmem->op[AVR_OP_LOADPAGE_HI], loadpagehigh_bits); - - (*p)->lfusemem = avr_new_memtype(); - strcpy((*p)->lfusemem->desc, "lfuse"); - - (*p)->lfusemem->size = 1; - (*p)->lfusemem->buf = MALLOC((size_t)(*p)->lfusemem->size+(size_t)1); - - (*p)->lfusemem->min_write_delay = 9000; - (*p)->lfusemem->max_write_delay = 9000; - - (*p)->lfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_READ], lfuseread_bits); - - (*p)->lfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->lfusemem->op[AVR_OP_WRITE], lfusewrite_bits); - - (*p)->hfusemem = avr_new_memtype(); - strcpy((*p)->hfusemem->desc, "hfuse"); - - (*p)->hfusemem->size = 1; - (*p)->hfusemem->buf = MALLOC((size_t)(*p)->hfusemem->size+(size_t)1); - - (*p)->hfusemem->min_write_delay = 9000; - (*p)->hfusemem->max_write_delay = 9000; - - (*p)->hfusemem->op[AVR_OP_READ] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_READ], hfuseread_bits); - - (*p)->hfusemem->op[AVR_OP_WRITE] = avr_new_opcode(); - parse_cmdbits((*p)->hfusemem->op[AVR_OP_WRITE], hfusewrite_bits); -} - -static void firmware_init_pgm(PROGRAMMER **pgm) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - *pgm = pgm_new(); -#ifndef _WIN32 - if(strlen(comport) == 0) { - gpio_initpgm(*pgm); - (*pgm)->pinno[3] = FIRMWARE_GPIO_RESET; - (*pgm)->pinno[4] = FIRMWARE_GPIO_SCK; - (*pgm)->pinno[5] = FIRMWARE_GPIO_MOSI; - (*pgm)->pinno[6] = FIRMWARE_GPIO_MISO; - // (*pgm)->ispdelay = 50; - - settings_find_number("firmware-gpio-reset", (int *)&(*pgm)->pinno[3]); - settings_find_number("firmware-gpio-sck", (int *)&(*pgm)->pinno[4]); - settings_find_number("firmware-gpio-mosi", (int *)&(*pgm)->pinno[5]); - settings_find_number("firmware-gpio-miso", (int *)&(*pgm)->pinno[6]); - } else { -#endif - arduino_initpgm(*pgm); -#ifdef _WIN32 - (*pgm)->baudrate = baudrate; -#else - (*pgm)->baudrate = baudrate; - } -#endif - if((*pgm)->setup) { - (*pgm)->setup(*pgm); - } -} - -static void firmware_process(int percent, double etime, char *hdr) { - static char hashes[51]; - static char *header; - static int last = 0; - int i = 0; - hashes[50] = 0; - memset (hashes, ' ', 50); - for(i=0; iopen(pgm, comport) < 0) { - exitrc = FW_PROG_OP_FAIL; - pgm->ppidata = 0; /* clear all bits at exit */ - goto main_exit; - } - - exitrc = 0; - - /* - * enable the programmer - */ - pgm->enable(pgm); - - /* - * initialize the chip in preperation for accepting commands - */ - init_ok = (pgm->initialize(pgm, *p) >= 0); - - if(!init_ok) { - exitrc = FW_INIT_FAIL; - goto main_exit; - } - - logprintf(LOG_INFO, "AVR device initialized and ready to accept instructions"); - - /* - * Let's read the signature bytes to make sure there is at least a - * chip on the other end that is responding correctly. A check - * against 0xffffff / 0x000000 should ensure that the signature bytes - * are valid. - */ - int attempt = 0; - int waittime = 10000; /* 10 ms */ - -sig_again: - usleep(waittime); - if(init_ok) { - if(avr_signature(pgm, *p) != 0) { - exitrc = FW_RD_SIG_FAIL; - goto main_exit; - } - } - - sig = (*p)->sigmem; - - if(sig != NULL) { - int ff = 1, zz = 1; - - for(i=0; isize; i++) { - if(sig->buf[i] != 0xff) - ff = 0; - if(sig->buf[i] != 0x00) - zz = 0; - } - - if(ff == 1 || zz == 1) { - if(++attempt < 3) { - waittime *= 5; - goto sig_again; - } - exitrc = FW_INV_SIG_FAIL; - goto main_exit; - } - } - - logprintf(LOG_INFO, "AVR device signature = 0x%02x 0x%02x 0x%02x", sig->buf[0], sig->buf[1], sig->buf[2]); - - if(sig->size != 3 || - sig->buf[0] != (*p)->signature[0] || - sig->buf[1] != (*p)->signature[1] || - sig->buf[2] != (*p)->signature[2]) { - exitrc = FW_MATCH_SIG_FAIL; - goto main_exit; - } - -main_exit: - pgm->close(pgm); - - FREE(pgm); - - for(i=0;iop[i] != NULL) { - FREE((*p)->op[i]); - } - } - - for(i=0;isigmem->op[i] != NULL) { - FREE((*p)->sigmem->op[i]); - } - } - if((*p)->sigmem->buf != NULL) { - FREE((*p)->sigmem->buf); - } - FREE((*p)->sigmem); - - for(i=0;iflashmem->op[i] != NULL) { - FREE((*p)->flashmem->op[i]); - } - } - if((*p)->flashmem->buf != NULL) { - FREE((*p)->flashmem->buf); - } - - FREE((*p)->flashmem); - - for(i=0;ihfusemem->op[i] != NULL) { - FREE((*p)->hfusemem->op[i]); - } - } - if((*p)->hfusemem->buf != NULL) { - FREE((*p)->hfusemem->buf); - } - FREE((*p)->hfusemem); - - for(i=0;ilfusemem->op[i] != NULL) { - FREE((*p)->lfusemem->op[i]); - } - } - if((*p)->lfusemem->buf != NULL) { - FREE((*p)->lfusemem->buf); - } - FREE((*p)->lfusemem); - - FREE(*p); - - return exitrc; -} - -static int firmware_write(char *filename, struct avrpart **p) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int exitrc = 0, i = 0, erase = 1, nowrite = 0, verify = 1; - int safemode = 1, init_ok = 0; - unsigned char safemode_lfuse = 0xff, safemode_hfuse = 0xff; - unsigned char safemode_efuse = 0xff, safemode_fuse = 0xff; - int fuses_specified = 0, fuses_AVRUPDd = 0; - struct avrpart *v = NULL; - AVRMEM *sig = NULL; - AVRUPD *wfile = NULL; - AVRUPD *vfile = NULL; - AVRUPD *wlfuse = NULL; - AVRUPD *vlfuse = NULL; - AVRUPD *whfuse = NULL; - AVRUPD *vhfuse = NULL; - PROGRAMMER *pgm = NULL; - char lfuse[] = "lfuse:w:0xe1:m"; - char hfuse[] = "lfuse:w:0xe1:m"; - - avr_set_update_progress(firmware_process); - - wfile = parse_op(filename); - if(verify && wfile->op == DEVICE_WRITE) { - vfile = dup_AVRUPD(wfile); - vfile->op = DEVICE_VERIFY; - } - - if(mptype != FW_MP_ATMEL328P && mptype != FW_MP_UNKNOWN) { - wlfuse = parse_op(lfuse); - if(verify && wlfuse->op == DEVICE_WRITE) { - vlfuse = dup_AVRUPD(wlfuse); - vlfuse->op = DEVICE_VERIFY; - } - - whfuse = parse_op(hfuse); - if(verify && whfuse->op == DEVICE_WRITE) { - vhfuse = dup_AVRUPD(whfuse); - vhfuse->op = DEVICE_VERIFY; - } - } - - firmware_init_pgm(&pgm); - - /* - * set up seperate instances of the avr part, one for use in - * programming, one for use in verifying. These are separate - * because they need separate flash and eeprom buffer space - */ - v = avr_dup_part(*p); - - if(pgm->open(pgm, comport) < 0) { - exitrc = FW_INIT_FAIL; - pgm->ppidata = 0; /* clear all bits at exit */ - goto main_exit; - } - - exitrc = 0; - - /* - * enable the programmer - */ - pgm->enable(pgm); - - /* - * initialize the chip in preperation for accepting commands - */ - init_ok = (pgm->initialize(pgm, *p) >= 0); - - if(!init_ok) { - exitrc = FW_INIT_FAIL; - goto main_exit; - } - - logprintf(LOG_INFO, "AVR device initialized and ready to accept instructions"); - - /* - * Let's read the signature bytes to make sure there is at least a - * chip on the other end that is responding correctly. A check - * against 0xffffff / 0x000000 should ensure that the signature bytes - * are valid. - */ - if(init_ok) { - if(avr_signature(pgm, *p) != 0) { - exitrc = FW_RD_SIG_FAIL; - goto main_exit; - } - } - - sig = (*p)->sigmem; - - if(sig != NULL) { - int ff = 1, zz = 1; - - for(i=0; isize; i++) { - if(sig->buf[i] != 0xff) - ff = 0; - if(sig->buf[i] != 0x00) - zz = 0; - } - - if(ff == 1 || zz == 1) { - exitrc = FW_INV_SIG_FAIL; - goto main_exit; - } - } - - logprintf(LOG_INFO, "AVR device signature = 0x%02x 0x%02x 0x%02x", sig->buf[0], sig->buf[1], sig->buf[2]); - - if(sig->size != 3 || - sig->buf[0] != (*p)->signature[0] || - sig->buf[1] != (*p)->signature[1] || - sig->buf[2] != (*p)->signature[2]) { - exitrc = FW_MATCH_SIG_FAIL; - goto main_exit; - } - - if(init_ok && safemode == 1) { - /* If safemode is enabled, go ahead and read the current low, high, - and extended fuse bytes as needed */ - int rc = safemode_readfuses(&safemode_lfuse, &safemode_hfuse, - &safemode_efuse, &safemode_fuse, pgm, *p); - - if(rc != 0) { - if(rc == -5) { - logprintf(LOG_ERR, "AVR fuse reading not support by programmer. Safemode disabled."); - safemode = 0; - } else { - logprintf(LOG_ERR, "To protect your AVR the programming will be aborted"); - exitrc = 1; - goto main_exit; - } - } else { - safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); - } - } - - logprintf(LOG_INFO, "AVR FLASH memory has been specified, an erase cycle will be performed"); - - if(init_ok && erase) { - logprintf(LOG_INFO, "AVR chip being erased"); - - if(avr_chip_erase(pgm, *p)) { - exitrc = FW_ERASE_FAIL; - goto main_exit; - } - } - - /* Write high and low fuses to microprocessor - First low and then high */ - if(mptype != FW_MP_ATMEL328P && mptype != FW_MP_UNKNOWN) { - if(do_op(pgm, v, wlfuse, nowrite, verify)) { - exitrc = FW_WRITE_FAIL; - goto main_exit; - } - if(do_op(pgm, v, vlfuse, nowrite, verify)) { - exitrc = FW_VERIFY_FAIL; - goto main_exit; - } - - if(do_op(pgm, v, whfuse, nowrite, verify)) { - exitrc = FW_WRITE_FAIL; - goto main_exit; - } - if(do_op(pgm, v, vhfuse, nowrite, verify)) { - exitrc = FW_VERIFY_FAIL; - goto main_exit; - } - } - - /* Write hex file to microprocessor */ - if(do_op(pgm, v, wfile, nowrite, verify)) { - exitrc = FW_WRITE_FAIL; - goto main_exit; - } - if(do_op(pgm, v, vfile, nowrite, verify)) { - exitrc = FW_VERIFY_FAIL; - goto main_exit; - } - - /* Right before we exit programming mode, which will make the fuse - bits active, check to make sure they are still correct */ - if(safemode == 1) { - /* If safemode is enabled, go ahead and read the current low, - * high, and extended fuse bytes as needed */ - unsigned char safemodeafter_lfuse = 0xff; - unsigned char safemodeafter_hfuse = 0xff; - unsigned char safemodeafter_efuse = 0xff; - unsigned char safemodeafter_fuse = 0xff; - unsigned char failures = 0; - - //Restore the default fuse values - safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); - - /* Try reading back fuses, make sure they are reliable to read back */ - if(safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse, - &safemodeafter_efuse, &safemodeafter_fuse, pgm, *p) != 0) { - /* Uh-oh.. try once more to read back fuses */ - if(safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse, - &safemodeafter_efuse, &safemodeafter_fuse, pgm, *p) != 0) { - logprintf(LOG_ERR, "Sorry, reading back AVR fuses was unreliable. Giving Up."); - exitrc = FW_RD_FUSE_FAIL; - goto main_exit; - } - } - - /* Now check what fuses are against what they should be */ - if(safemodeafter_fuse != safemode_fuse) { - fuses_AVRUPDd = 1; - logprintf(LOG_ERR, "AVR fuse changed! Was %x, and is now %x", safemode_fuse, safemodeafter_fuse); - - /* Ask user - should we change them */ - /* Enough chit-chat, time to program some fuses and check them */ - if(safemode_writefuse(safemode_fuse, "fuse", pgm, *p, 10) == 0) { - logprintf(LOG_ERR, "AVR fuse is now rescued"); - } else { - logprintf(LOG_ERR, "AVR fuse could NOT be changed"); - failures++; - } - } - - /* Now check what fuses are against what they should be */ - if(safemodeafter_lfuse != safemode_lfuse) { - fuses_AVRUPDd = 1; - logprintf(LOG_ERR, "AVR lfuse changed! Was %x, and is now %x", safemode_lfuse, safemodeafter_lfuse); - - /* Ask user - should we change them */ - /* Enough chit-chat, time to program some fuses and check them */ - if(safemode_writefuse(safemode_lfuse, "lfuse", pgm, *p, 10) == 0) { - logprintf(LOG_ERR, "AVR lfuse is now rescued"); - } else { - logprintf(LOG_ERR, "AVR lfuse could NOT be changed"); - failures++; - } - } - - /* Now check what fuses are against what they should be */ - if(safemodeafter_hfuse != safemode_hfuse) { - fuses_AVRUPDd = 1; - logprintf(LOG_ERR, "AVR hfuse changed! Was %x, and is now %x", safemode_hfuse, safemodeafter_hfuse); - - /* Ask user - should we change them */ - /* Enough chit-chat, time to program some fuses and check them */ - if(safemode_writefuse(safemode_hfuse, "hfuse", pgm, *p, 10) == 0) { - logprintf(LOG_ERR, "AVR hfuse is now rescued"); - } else { - logprintf(LOG_ERR, "AVR hfuse could NOT be changed"); - failures++; - } - } - - /* Now check what fuses are against what they should be */ - if(safemodeafter_efuse != safemode_efuse) { - fuses_AVRUPDd = 1; - logprintf(LOG_ERR, "AVR efuse changed! Was %x, and is now %x", safemode_efuse, safemodeafter_efuse); - - /* Ask user - should we change them */ - /* Enough chit-chat, time to program some fuses and check them */ - if(safemode_writefuse(safemode_efuse, "efuse", pgm, *p, 10) == 0) { - logprintf(LOG_ERR, "AVR efuse is now rescued"); - } else { - logprintf(LOG_ERR, "AVR efuse could NOT be changed"); - failures++; - } - } - - if(failures == 0) { - logprintf(LOG_INFO, "AVR fuses OK"); - } else { - logprintf(LOG_INFO, "AVR fuses not recovered"); - } - - if(fuses_AVRUPDd && fuses_specified) { - exitrc = 1; - } - } - -main_exit: - pgm->close(pgm); - - FREE(pgm); - - FREE(wfile->memtype); - FREE(wfile->filename); - FREE(wfile); - - if(vfile != NULL) { - FREE(vfile->memtype); - FREE(vfile->filename); - FREE(vfile); - } - - if(mptype != FW_MP_ATMEL328P && mptype != FW_MP_UNKNOWN) { - FREE(whfuse->memtype); - FREE(whfuse->filename); - FREE(whfuse); - - if(vhfuse != NULL) { - FREE(vhfuse->memtype); - FREE(vhfuse->filename); - FREE(vhfuse); - } - - FREE(wlfuse->memtype); - FREE(wlfuse->filename); - FREE(wlfuse); - - if(vlfuse != NULL) { - FREE(vlfuse->memtype); - FREE(vlfuse->filename); - FREE(vlfuse); - } - } - - for(i=0;iop[i] != NULL) { - FREE((*p)->op[i]); - } - } - - for(i=0;isigmem->op[i] != NULL) { - FREE((*p)->sigmem->op[i]); - } - } - if((*p)->sigmem->buf != NULL) { - FREE((*p)->sigmem->buf); - } - FREE((*p)->sigmem); - - for(i=0;iflashmem->op[i] != NULL) { - FREE((*p)->flashmem->op[i]); - } - } - if((*p)->flashmem->buf != NULL) { - FREE((*p)->flashmem->buf); - } - FREE((*p)->flashmem); - - for(i=0;ihfusemem->op[i] != NULL) { - FREE((*p)->hfusemem->op[i]); - } - } - if((*p)->hfusemem->buf != NULL) { - FREE((*p)->hfusemem->buf); - } - FREE((*p)->hfusemem); - - for(i=0;ilfusemem->op[i] != NULL) { - FREE((*p)->lfusemem->op[i]); - } - } - if((*p)->lfusemem->buf != NULL) { - FREE((*p)->lfusemem->buf); - } - FREE((*p)->lfusemem); - - FREE(v->flashmem->buf); - FREE(v->flashmem); - FREE(v->sigmem->buf); - FREE(v->sigmem); - FREE(v->lfusemem->buf); - FREE(v->lfusemem); - FREE(v->hfusemem->buf); - FREE(v->hfusemem); - - FREE(*p); - FREE(v); - - logprintf(LOG_INFO, "Finished updating firmware"); - - return exitrc; -} - -int firmware_getmp(char *port) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(port != NULL) { - strncpy(comport, port, 255); - } else { - memset(comport, '\0', 255); - } - - struct avrpart *p = NULL; - unsigned int match = 0; - - logprintf(LOG_INFO, "Indentifying microprocessor"); - /* - mptype = FW_MP_ATMEL32U4; - firmware_atmega32u4(&p); - if(!match && firmware_identifymp(&p) != 0) { - logprintf(LOG_INFO, "Not an ATMega32u4"); - mptype = FW_MP_ATMEL328P; - firmware_atmega328p(&p); - match = 0; - } else { - return mptype; - }*/ - mptype = FW_MP_ATMEL328P; - baudrate = 115200; - firmware_atmega328p(&p); - logprintf(LOG_INFO, "Checking for an ATMega328P @%d", baudrate); - if(!match && firmware_identifymp(&p) != 0) { - logprintf(LOG_INFO, "Not an ATMega328P"); - mptype = FW_MP_ATMEL328P; - match = 0; - firmware_atmega328p(&p); - } else { - return mptype; - } - baudrate = 57600; - logprintf(LOG_INFO, "Checking for an ATMega328P @%d", baudrate); - if(!match && firmware_identifymp(&p) != 0) { - logprintf(LOG_INFO, "Not an ATMega328P"); - mptype = FW_MP_ATTINY25; - match = 0; - firmware_attiny25(&p); - } else { - return mptype; - } - logprintf(LOG_INFO, "Checking for an ATTiny25 @%d", baudrate); - if(!match && firmware_identifymp(&p) != 0) { - logprintf(LOG_INFO, "Not an ATTiny45"); - mptype = FW_MP_ATTINY45; - match = 0; - firmware_attiny45(&p); - } else { - return mptype; - } - logprintf(LOG_INFO, "Checking for an ATTiny45 @%d", baudrate); - if(!match && firmware_identifymp(&p) != 0) { - logprintf(LOG_INFO, "Not an ATTiny85"); - mptype = FW_MP_ATTINY85; - match = 0; - firmware_attiny85(&p); - } else { - return mptype; - } - logprintf(LOG_INFO, "Checking for an ATTiny85 @%d", baudrate); - if(!match && firmware_identifymp(&p) != 0) { - mptype = FW_MP_UNKNOWN; - logprintf(LOG_ERR, "AVR unknown"); - return -1; - } else { - return mptype; - } - return -1; -} - -int firmware_update(char *fwfile, char *port) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(port != NULL) { - strncpy(comport, port, 255); - } else { - memset(comport, '\0', 255); - } - - struct avrpart *p = NULL; - if(fmt_autodetect(fwfile) != FMT_IHEX) { - logprintf(LOG_ERR, "Trying to write an invalid firmware file"); - return -1; - } else { - switch(mptype) { - case FW_MP_ATMEL328P: - logprintf(LOG_INFO, "Firmware running on an ATmega328P"); - firmware_atmega328p(&p); - break; - case FW_MP_ATTINY25: - logprintf(LOG_INFO, "Firmware running on an ATTiny25"); - firmware_attiny25(&p); - break; - case FW_MP_ATTINY45: - logprintf(LOG_INFO, "Firmware running on an ATTiny45"); - firmware_attiny45(&p); - break; - case FW_MP_ATTINY85: - logprintf(LOG_INFO, "Firmware running on an ATTiny85"); - firmware_attiny85(&p); - break; - default: - logprintf(LOG_INFO, "First run firmware_getmp"); - return -1; - break; - } - - int ret = firmware_write(fwfile, &p); - mptype = FW_MP_UNKNOWN; - return ret; - } -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/firmware.h b/lib/ESPiLight/pilight/libs/pilight/core/firmware.h deleted file mode 100644 index d19e744..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/firmware.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _FIRMWARE_H_ -#define _FIRMWARE_H_ - -typedef struct firmware_t { - double lpf; - double hpf; - double version; -} firmware_t; -struct firmware_t firmware; - -typedef enum { - FW_PROG_OP_FAIL = 1, - FW_INIT_FAIL, - FW_RD_SIG_FAIL, - FW_INV_SIG_FAIL, - FW_MATCH_SIG_FAIL, - FW_ERASE_FAIL, - FW_WRITE_FAIL, - FW_VERIFY_FAIL, - FW_RD_FUSE_FAIL, - FW_INV_FUSE_FAIL -} exitrc_t; - -typedef enum { - FW_MP_UNKNOWN, - FW_MP_ATTINY25, - FW_MP_ATTINY45, - FW_MP_ATTINY85, - FW_MP_ATMEL328P, - FW_MP_ATMEL32U4 -} mptype_t; - -int firmware_update(char *fwfile, char *comport); -int firmware_getmp(char *comport); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/gc.c b/lib/ESPiLight/pilight/libs/pilight/core/gc.c deleted file mode 100644 index 1a6bfde..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/gc.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #include -#else - #include - #define UNW_LOCAL_ONLY - #ifndef __mips__ - #include - #endif -#endif -#include - -#include "pilight.h" -#include "gc.h" -#include "json.h" -#include "log.h" -#include "mem.h" -#include "common.h" -#include "config.h" - -static unsigned short gc_enable = 1; -static int (*gc)(void) = NULL; - -void gc_handler(int sig) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); -#if !defined(_WIN32) && !defined(__mips__) - char name[256]; - unw_cursor_t cursor; unw_context_t uc; - unw_word_t ip, sp, offp; -#endif - - switch(sig) { - case SIGSEGV: -#ifndef _WIN32 - case SIGBUS: -#endif - case SIGILL: - case SIGABRT: - case SIGFPE: { -#if !defined(_WIN32) && !defined(__mips__) - log_shell_disable(); - void *stack[50]; - int n = backtrace(stack, 50); - printf("-- STACKTRACE (%d FRAMES) --\n", n); - logerror("-- STACKTRACE (%d FRAMES) --", n); - - unw_getcontext(&uc); - unw_init_local(&cursor, &uc); - - while(unw_step(&cursor) > 0) { - name[0] = '\0'; - unw_get_proc_name(&cursor, name, 256, &offp); - unw_get_reg(&cursor, UNW_REG_IP, &ip); - unw_get_reg(&cursor, UNW_REG_SP, &sp); - - printf("%-30s ip = %10p, sp = %10p\n", name, (void *)ip, (void *)sp); - logerror("%-30s ip = %10p, sp = %10p", name, (void *)ip, (void *)sp); - } -#endif - } - break; - default:; - } - if(sig == SIGSEGV) { - fprintf(stderr, "segmentation fault\n"); - exit(EXIT_FAILURE); -#ifndef _WIN32 - } else if(sig == SIGBUS) { - fprintf(stderr, "buserror\n"); - exit(EXIT_FAILURE); -#endif - } -#ifdef _WIN32 - if(((sig == SIGINT || sig == SIGTERM) && gc_enable == 1) || - (!(sig == SIGINT || sig == SIGTERM) && gc_enable == 0)) { -#else - if(((sig == SIGINT || sig == SIGTERM || sig == SIGTSTP) && gc_enable == 1) || - (!(sig == SIGINT || sig == SIGTERM || sig == SIGTSTP) && gc_enable == 0)) { -#endif - if(sig == SIGINT) { - logprintf(LOG_DEBUG, "received interrupt signal, stopping pilight..."); - } else if(sig == SIGTERM) { - logprintf(LOG_DEBUG, "received terminate signal, stopping pilight..."); - } else { - logprintf(LOG_DEBUG, "received stop signal, stopping pilight..."); - } - if(config_get_file() != NULL && gc_enable == 1) { - gc_enable = 0; - if(pilight.runmode == STANDALONE) { - config_write(1, "all"); - } - } - gc_enable = 0; - gc_run(); - } -} - -/* Add function to gc */ -void gc_attach(int (*fp)(void)) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - if(gc != NULL) { - logprintf(LOG_ERR, "multiple calls to gc_attach", __FUNCTION__); - } - gc = fp; -} - -void gc_clear(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - gc = NULL; -} - -/* Run the GC manually */ -int gc_run(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(gc != NULL) { - if(gc() == 0) { - return EXIT_SUCCESS; - } else { - return EXIT_FAILURE; - } - } else { - return EXIT_SUCCESS; - } -} - -/* Initialize the catch all gc */ -void gc_catch(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - -#ifdef _WIN32 - // signal(SIGABRT, gc_handler); - // signal(SIGFPE, gc_handler); - // signal(SIGILL, gc_handler); - // signal(SIGINT, gc_handler); - // signal(SIGSEGV, gc_handler); - // signal(SIGTERM, gc_handler); -#else - struct sigaction act; - memset(&act, 0, sizeof(act)); - act.sa_handler = gc_handler; - sigemptyset(&act.sa_mask); - sigaction(SIGINT, &act, NULL); - sigaction(SIGQUIT, &act, NULL); - sigaction(SIGTERM, &act, NULL); - - sigaction(SIGABRT, &act, NULL); - sigaction(SIGTSTP, &act, NULL); - - sigaction(SIGBUS, &act, NULL); - sigaction(SIGILL, &act, NULL); - sigaction(SIGSEGV, &act, NULL); - sigaction(SIGFPE, &act, NULL); -#endif -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/gc.h b/lib/ESPiLight/pilight/libs/pilight/core/gc.h deleted file mode 100644 index c3a75eb..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/gc.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _GC_H_ -#define _GC_H_ - -typedef struct collectors_t { - int (*listener)(void); - struct collectors_t *next; -} collectors_t; - -void gc_handler(int signal); -void gc_attach(int (*fp)(void)); -void gc_catch(void); -int gc_run(void); -void gc_clear(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/http.c b/lib/ESPiLight/pilight/libs/pilight/core/http.c deleted file mode 100644 index aef9958..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/http.c +++ /dev/null @@ -1,815 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #include - #include - #define MSG_NOSIGNAL 0 -#else - #include - #include - #include - #include - #include - #include - #include - #include -#endif -#include -#include - -#include "../../libuv/uv.h" -#include "pilight.h" -#include "socket.h" -#include "log.h" -#include "network.h" -#include "webserver.h" -#include "ssl.h" - -#define USERAGENT "pilight" -#define HTTP_POST 1 -#define HTTP_GET 0 - -#define STEP_WRITE 0 -#define STEP_READ 1 - -typedef struct http_clients_t { - uv_poll_t *req; - int fd; - struct uv_custom_poll_t *data; - struct http_clients_t *next; -} http_clients_t; - -#ifdef _WIN32 - static uv_mutex_t http_lock; -#else - static pthread_mutex_t http_lock; - static pthread_mutexattr_t http_attr; -#endif - -struct http_clients_t *http_clients = NULL; -static int http_lock_init = 0; - -typedef struct request_t { - char *host; - char *uri; - char *query_string; - char *auth64; - int port; - int is_ssl; - int status_code; - int reading; - void *userdata; - - int steps; - int request_method; - - char *content; - char mimetype[255]; - int chunked; - int chunksize; - int chunkread; - int gotheader; - size_t content_len; - size_t bytes_read; - - void (*callback)(int code, char *data, int size, char *type, void *userdata); -} request_t; - -int done = 0; - -static void http_client_close(uv_poll_t *req); - -static void free_request(struct request_t *request) { - if(request->host != NULL) { - FREE(request->host); - } - if(request->uri != NULL) { - FREE(request->uri); - } - if(request->content != NULL) { - FREE(request->content); - } - if(request->auth64 != NULL) { - FREE(request->auth64); - } - FREE(request); -} - -int http_gc(void) { - struct http_clients_t *node = NULL; - -#ifdef _WIN32 - uv_mutex_lock(&http_lock); -#else - pthread_mutex_lock(&http_lock); -#endif - while(http_clients) { - node = http_clients; - - if(http_clients->fd > -1) { -#ifdef _WIN32 - shutdown(http_clients->fd, SD_BOTH); - closesocket(http_clients->fd); -#else - shutdown(http_clients->fd, SHUT_RDWR); - close(http_clients->fd); -#endif - } - - struct uv_custom_poll_t *custom_poll_data = http_clients->data; - struct request_t *request = custom_poll_data->data; - if(request != NULL) { - free_request(request); - } - - if(custom_poll_data != NULL) { - uv_custom_poll_free(custom_poll_data); - } - - http_clients = http_clients->next; - FREE(node); - } - -#ifdef _WIN32 - uv_mutex_unlock(&http_lock); -#else - pthread_mutex_unlock(&http_lock); -#endif - - logprintf(LOG_DEBUG, "garbage collected http library"); - return 1; -} - -static void http_client_add(uv_poll_t *req, struct uv_custom_poll_t *data) { -#ifdef _WIN32 - uv_mutex_lock(&http_lock); -#else - pthread_mutex_lock(&http_lock); -#endif - - int fd = -1, r = 0; - - if((r = uv_fileno((uv_handle_t *)req, (uv_os_fd_t *)&fd)) != 0) { - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); /*LCOV_EXCL_LINE*/ - } - - struct http_clients_t *node = MALLOC(sizeof(struct http_clients_t)); - if(node == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->req = req; - node->data = data; - node->fd = fd; - - node->next = http_clients; - http_clients = node; -#ifdef _WIN32 - uv_mutex_unlock(&http_lock); -#else - pthread_mutex_unlock(&http_lock); -#endif -} - -static void http_client_remove(uv_poll_t *req) { -#ifdef _WIN32 - uv_mutex_lock(&http_lock); -#else - pthread_mutex_lock(&http_lock); -#endif - struct http_clients_t *currP, *prevP; - - prevP = NULL; - - for(currP = http_clients; currP != NULL; prevP = currP, currP = currP->next) { - if(currP->req == req) { - if(prevP == NULL) { - http_clients = currP->next; - } else { - prevP->next = currP->next; - } - - FREE(currP); - break; - } - } -#ifdef _WIN32 - uv_mutex_unlock(&http_lock); -#else - pthread_mutex_unlock(&http_lock); -#endif -} - -static int prepare_request(struct request_t **request, int method, char *url, const char *contype, char *post, void (*callback)(int, char *, int, char *, void *), void *userdata) { - char *tok = NULL, *auth = NULL; - int plen = 0, len = 0, tlen = 0; - - if(((*request) = MALLOC(sizeof(struct request_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset((*request), 0, sizeof(struct request_t)); - - /* Check which port we need to use based on the http(s) protocol */ - if(strncmp(url, "http://", 7) == 0) { - (*request)->port = 80; - plen = 8; - (*request)->is_ssl = 0; - } else if(strncmp(url, "https://", 8) == 0) { - (*request)->port = 443; - (*request)->is_ssl = 1; - plen = 9; - if(ssl_client_init_status() == -1) { - logprintf(LOG_ERR, "HTTPS URL's require a properly initialized SSL library"); - return -1; - } - } else { - logprintf(LOG_ERR, "A URL should start with either http:// or https://"); - FREE((*request)); - return -1; - } - - /* Split the url into a host and page part */ - len = strlen(url); - if((tok = strstr(&url[plen], "/"))) { - tlen = (size_t)(tok-url)-plen+1; - if(((*request)->host = MALLOC(tlen+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy((*request)->host, &url[plen-1], tlen); - (*request)->host[tlen] = '\0'; - if(((*request)->uri = MALLOC(len-tlen)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy((*request)->uri, &url[tlen+(plen-1)], (len-tlen)-1); - } else { - tlen = strlen(url)-(plen-1); - if(((*request)->host = MALLOC(tlen+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy((*request)->host, &url[(plen-1)], tlen); - (*request)->host[tlen] = '\0'; - if(((*request)->uri = MALLOC(2)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy((*request)->uri, "/", 1); - } - if((tok = strstr((*request)->host, "@"))) { - size_t pglen = strlen((*request)->uri); - tlen = (size_t)(tok-(*request)->host); - if((auth = MALLOC(tlen+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy(auth, &(*request)->host[0], tlen); - auth[tlen] = '\0'; - strncpy(&(*request)->host[0], &url[plen+tlen], len-(plen+tlen+pglen)); - (*request)->host[len-(plen+tlen+pglen)] = '\0'; - (*request)->auth64 = base64encode(auth, strlen(auth)); - FREE(auth); - } - if(method == HTTP_POST) { - strncpy((*request)->mimetype, contype, sizeof((*request)->mimetype)); - if(((*request)->content = REALLOC((*request)->content, strlen(post)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy((*request)->content, post); - (*request)->content_len = strlen(post); - } - - len = strlen((*request)->host); - int i = 0; - while(i < len) { - if((tok = strstr(&(*request)->host[i], ":"))) { - size_t pglen = strlen((*request)->host); - tlen = (size_t)(tok-(*request)->host)+1; - if((*request)->host[tlen] == ':') { - i = tlen; - while(i < len && (*request)->host[i++] == ':'); - continue; - } - if(isNumeric(&(*request)->host[tlen]) == 0) { - (*request)->port = atoi(&(*request)->host[tlen]); - } else { - logprintf(LOG_ERR, "A custom URL port must be numeric"); - FREE((*request)->host); - FREE((*request)->uri); - FREE((*request)); - return -1; - } - if(pglen == tlen) { - logprintf(LOG_ERR, "A custom URL port is missing"); - FREE((*request)->host); - FREE((*request)->uri); - FREE((*request)); - return -1; - } - (*request)->host[tlen-1] = '\0'; - break; - } - i++; - } - len = strlen((*request)->host)-1; - if((*request)->host[0] == '[') { - memmove(&(*request)->host[0], &(*request)->host[1], len); - (*request)->host[len] = '\0'; - } - if((*request)->host[len-1] == ']') { - (*request)->host[len-1] = '\0'; - } - - (*request)->userdata = userdata; - (*request)->callback = callback; - (*request)->request_method = method; - - return 0; -} - -static void append_to_header(char **header, char *data, ...) { - va_list ap, apcpy; - int pos = 0, bytes = 0; - if(*header != NULL) { - pos = strlen(*header); - } - // va_copy(apcpy, ap); - va_start(apcpy, data); -#ifdef _WIN32 - bytes = _vscprintf(data, apcpy); -#else - bytes = vsnprintf(NULL, 0, data, apcpy); -#endif - if(bytes == -1) { - /* - * FIXME - */ - // fprintf(stderr, "ERROR: improperly formatted logprintf message %s\n", data); - } else { - va_end(apcpy); - if((*header = REALLOC(*header, pos+bytes+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - va_start(ap, data); - vsprintf(&(*header)[pos], data, ap); - va_end(ap); - } -} - -static void process_chunk(char **buf, ssize_t *size, struct request_t *request) { - char *p = NULL; - int pos = 0, toread = 0; - - while(1) { - toread = *size; - if(strncmp(*buf, "0\r\n\r\n", 5) == 0) { - request->reading = 0; - break; - } - - if(request->chunksize == request->chunkread) { - if((p = strstr(*buf, "\r\n")) != NULL) { - pos = p-*buf; - (*buf)[pos+1] = '\0'; - request->chunksize = strtoul(*buf, NULL, 16); - memmove(&(*buf)[0], &(*buf)[pos+2], toread-(pos+2)); - toread -= (pos+2); - *size -= (pos+2); - (*buf)[toread] = '\0'; - } - } - - if((request->chunksize-request->chunkread) < *size) { - toread = request->chunksize-request->chunkread; - } - - if((request->content = REALLOC(request->content, request->bytes_read+toread+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - /* - * Prevent uninitialised values in valgrind - */ - memset(&request->content[request->bytes_read], 0, toread+1); - memcpy(&request->content[request->bytes_read], *buf, toread); - request->bytes_read += toread; - request->chunkread += toread; - - memmove(&(*buf)[0], &(*buf)[toread], *size-toread); - - *size -= toread; - (*buf)[*size] = '\0'; - - if(request->chunkread <= request->chunksize) { - if(strncmp(*buf, "\r\n", 2) == 0) { - memmove(&(*buf)[0], &(*buf)[2], *size-2); - *size -= 2; - toread -= 2; - (*buf)[*size] = '\0'; - } - if(request->chunkread == request->chunksize) { - request->chunksize = 0; - request->chunkread = 0; - } - } - - if(request->chunksize == 0 && strstr(*buf, "\r\n") == NULL) { - break; - } else if(*size > 0 && strncmp(*buf, "0\r\n\r\n", 5) != 0) { - request->reading = 1; - } else { - break; - } - } -} - -static void close_cb(uv_handle_t *handle) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - FREE(handle); -} - -static void http_client_close(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct request_t *request = custom_poll_data->data; - int fd = -1, r = 0; - - if((r = uv_fileno((uv_handle_t *)req, (uv_os_fd_t *)&fd)) != 0) { - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); /*LCOV_EXCL_LINE*/ - } - - if(fd > -1) { -#ifdef _WIN32 - shutdown(fd, SD_BOTH); - closesocket(fd); -#else - shutdown(fd, SHUT_RDWR); - close(fd); -#endif - } - - http_client_remove(req); - - if(!uv_is_closing((uv_handle_t *)req)) { - uv_poll_stop(req); - uv_close((uv_handle_t *)req, close_cb); - } - - if(request != NULL) { - free_request(request); - custom_poll_data->data = NULL; - } - - if(custom_poll_data != NULL) { - uv_custom_poll_free(custom_poll_data); - req->data = NULL; - } -} - -static void poll_close_cb(uv_poll_t *req) { - http_client_close(req); -} - -static void read_cb(uv_poll_t *req, ssize_t *nread, char *buf) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct request_t *request = custom_poll_data->data; - char *header = NULL, *p = NULL; - const char *a = NULL, *b = NULL; - int pos = 0; - - if(*nread > 0) { - buf[*nread] = '\0'; - } - - /* - * FIXME: Use io read buf instead of new buffer - */ - if(*nread > 0) { - if(request->gotheader == 0 && (p = strstr(buf, "\r\n\r\n")) != NULL) { - pos = p-buf; - if((header = MALLOC(pos+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy(header, buf, pos); - header[pos] = '\0'; - request->gotheader = 1; - *nread -= pos+4; - memmove(buf, &buf[pos+4], *nread); - buf[*nread] = '\0'; - - struct connection_t c; - char *location = NULL; - const char *p = location; - http_parse_request(header, &c); - if(c.status_code == 301 && (p = http_get_header(&c, "Location")) != NULL) { - if(request->callback != NULL) { - request->callback(c.status_code, location, strlen(location), NULL, request->userdata); - } - FREE(header); - return; - } - request->status_code = c.status_code; - if((a = http_get_header(&c, "Content-Type")) != NULL || (b = http_get_header(&c, "Content-type")) != NULL) { - int len = 0, i = 0; - if(a != NULL) { - strcpy(request->mimetype, http_get_header(&c, "Content-Type")); - } else if(b != NULL) { - strcpy(request->mimetype, http_get_header(&c, "Content-type")); - } - len = strlen(request->mimetype); - for(i=0;imimetype[i] == ';') { - request->mimetype[i] = '\0'; - break; - } - } - } - if(http_get_header(&c, "Content-Length") != NULL) { - request->content_len = atoi(http_get_header(&c, "Content-Length")); - } - if(http_get_header(&c, "Transfer-Encoding") != NULL) { - if(strcmp(http_get_header(&c, "Transfer-Encoding"), "chunked") == 0) { - request->chunked = 1; - } - } - FREE(header); - if(*nread == 0) { - if(request->callback != NULL) { - request->callback(request->status_code, "", request->content_len, request->mimetype, request->userdata); - goto close; - } - } - } - if(request->chunked == 1) { - process_chunk(&buf, &(*nread), request); - } else if(*nread > 0) { - if((request->content = REALLOC(request->content, request->bytes_read+(*nread)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - /* - * Prevent uninitialised values in valgrind - */ - memset(&request->content[request->bytes_read], 0, *nread+1); - memcpy(&request->content[request->bytes_read], buf, *nread); - request->bytes_read += *nread; - *nread = 0; - } - - if(strcmp(buf, "0\r\n\r\n") == 0) { - request->reading = 0; - request->chunked = 0; - request->content[request->bytes_read] = '\0'; - request->content_len = request->bytes_read; - } - - if(request->chunked == 1 || request->bytes_read < request->content_len) { - request->reading = 1; - } else if(request->content != NULL) { - request->content[request->content_len] = '\0'; - if(request->callback != NULL) { - request->callback(request->status_code, request->content, request->content_len, request->mimetype, request->userdata); - goto close; - } - } - } - - if(request->reading == 1) { - uv_custom_read(req); - return; - } - -close: - uv_custom_close(req); -} - -static void write_cb(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct request_t *request = custom_poll_data->data; - char *header = NULL; - - switch(request->steps) { - case STEP_WRITE: { - if(request->request_method == HTTP_POST) { - append_to_header(&header, "POST %s HTTP/1.0\r\n", request->uri); - append_to_header(&header, "Host: %s\r\n", request->host); - if(request->auth64 != NULL) { - append_to_header(&header, "Authorization: Basic %s\r\n", request->auth64); - } - append_to_header(&header, "User-Agent: %s\r\n", USERAGENT); - append_to_header(&header, "Content-Type: %s\r\n", request->mimetype); - append_to_header(&header, "Content-Length: %lu\r\n\r\n", request->content_len); - append_to_header(&header, "%s", request->content); - } else if(request->request_method == HTTP_GET) { - append_to_header(&header, "GET %s HTTP/1.1\r\n", request->uri); - append_to_header(&header, "Host: %s\r\n", request->host); - if(request->auth64 != NULL) { - append_to_header(&header, "Authorization: Basic %s\r\n", request->auth64); - } - append_to_header(&header, "User-Agent: %s\r\n", USERAGENT); - append_to_header(&header, "Connection: close\r\n\r\n"); - } - iobuf_append(&custom_poll_data->send_iobuf, (void *)header, strlen(header)); - - uv_custom_write(req); - FREE(header); - request->steps = STEP_READ; - } break; - case STEP_READ: - uv_custom_read(req); - return; - break; - } -} - -char *http_process(int type, char *url, const char *conttype, char *post, void (*callback)(int, char *, int, char *, void *), void *userdata) { - struct request_t *request = NULL; - struct uv_custom_poll_t *custom_poll_data = NULL; - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - char *ip = NULL; - int r = 0, sockfd = 0; - - if(http_lock_init == 0) { - http_lock_init = 1; -#ifdef _WIN32 - uv_mutex_init(&http_lock); -#else - pthread_mutexattr_init(&http_attr); - pthread_mutexattr_settype(&http_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&http_lock, &http_attr); -#endif - } - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "WSAStartup"); - exit(EXIT_FAILURE); - } -#endif - - memset(&addr4, 0, sizeof(addr4)); - memset(&addr6, 0, sizeof(addr6)); - if(prepare_request(&request, type, url, conttype, post, callback, userdata) == 0) { - int inet = host2ip(request->host, &ip); - switch(inet) { - case AF_INET: { - memset(&addr4, '\0', sizeof(struct sockaddr_in)); - r = uv_ip4_addr(ip, request->port, &addr4); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_ip4_addr: %s", uv_strerror(r)); - goto freeuv; - /*LCOV_EXCL_END*/ - } - } break; - case AF_INET6: { - memset(&addr6, '\0', sizeof(struct sockaddr_in6)); - r = uv_ip6_addr(ip, request->port, &addr6); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_ip6_addr: %s", uv_strerror(r)); - goto freeuv; - /*LCOV_EXCL_END*/ - } - } break; - default: { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "host2ip"); - goto freeuv; - /*LCOV_EXCL_END*/ - } break; - } - FREE(ip); - - /* - * Partly bypass libuv in case of ssl connections - */ - if((sockfd = socket(inet, SOCK_STREAM, 0)) < 0){ - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "socket: %s", strerror(errno)); - goto freeuv; - /*LCOV_EXCL_STOP*/ - } - -#ifdef _WIN32 - unsigned long on = 1; - ioctlsocket(sockfd, FIONBIO, &on); -#else - long arg = fcntl(sockfd, F_GETFL, NULL); - fcntl(sockfd, F_SETFL, arg | O_NONBLOCK); -#endif - - switch(inet) { - case AF_INET: { - r = connect(sockfd, (struct sockaddr *)&addr4, sizeof(addr4)); - } break; - case AF_INET6: { - r = connect(sockfd, (struct sockaddr *)&addr6, sizeof(addr6)); - } break; - default: { - } break; - } - - if(r < 0) { -#ifdef _WIN32 - if(!(WSAGetLastError() == WSAEWOULDBLOCK || WSAGetLastError() == WSAEISCONN)) { -#else - if(!(errno == EINPROGRESS || errno == EISCONN)) { -#endif - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "connect: %s", strerror(errno)); - goto freeuv; - /*LCOV_EXCL_STOP*/ - } - } - - uv_poll_t *poll_req = NULL; - if((poll_req = MALLOC(sizeof(uv_poll_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - uv_custom_poll_init(&custom_poll_data, poll_req, (void *)request); - custom_poll_data->is_ssl = request->is_ssl; - custom_poll_data->write_cb = write_cb; - custom_poll_data->read_cb = read_cb; - custom_poll_data->close_cb = poll_close_cb; - - r = uv_poll_init_socket(uv_default_loop(), poll_req, sockfd); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_poll_init_socket: %s", uv_strerror(r)); - FREE(poll_req); - goto freeuv; - /*LCOV_EXCL_STOP*/ - } - - http_client_add(poll_req, custom_poll_data); - request->steps = STEP_WRITE; - uv_custom_write(poll_req); - } - - return NULL; - -freeuv: - request->callback(404, NULL, 0, 0, request->userdata); - FREE(request->uri); - FREE(request->host); - FREE(request); - - if(sockfd > 0) { -#ifdef _WIN32 - closesocket(sockfd); -#else - close(sockfd); -#endif - } - return NULL; -} - -char *http_get_content(char *url, void (*callback)(int, char *, int, char *, void *), void *userdata) { - return http_process(HTTP_GET, url, NULL, NULL, callback, userdata); -} - -char *http_post_content(char *url, const char *conttype, char *post, void (*callback)(int, char *, int, char *, void *), void *userdata) { - return http_process(HTTP_POST, url, conttype, post, callback, userdata); -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/http.h b/lib/ESPiLight/pilight/libs/pilight/core/http.h deleted file mode 100644 index 10e8776..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/http.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _HTTP_H_ -#define _HTTP_H_ - -char *http_post_content(char *url, const char *contype, char *post, void (*callback)(int, char *, int, char *, void *), void *userdata); -char *http_get_content(char *url, void (*callback)(int, char *, int, char *, void *), void *userdata); -int http_gc(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/i2c-dev.h b/lib/ESPiLight/pilight/libs/pilight/core/i2c-dev.h deleted file mode 100644 index 39f0fd5..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/i2c-dev.h +++ /dev/null @@ -1,335 +0,0 @@ -/* - i2c-dev.h - i2c-bus driver, char device interface - - Copyright (C) 1995-97 Simon G. Vogl - Copyright (C) 1998-99 Frodo Looijaard - - 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 of the License, 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., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301 USA. -*/ - -/* $Id: i2c-dev.h 5894 2010-12-12 13:22:29Z khali $ */ - -#ifndef LIB_I2CDEV_H -#define LIB_I2CDEV_H - -#include -#include - - -/* -- i2c.h -- */ - - -/* - * I2C Message - used for pure i2c transaction, also from /dev interface - */ -struct i2c_msg { - __u16 addr; /* slave address */ - unsigned short flags; -#define I2C_M_TEN 0x10 /* we have a ten bit chip address */ -#define I2C_M_RD 0x01 -#define I2C_M_NOSTART 0x4000 -#define I2C_M_REV_DIR_ADDR 0x2000 -#define I2C_M_IGNORE_NAK 0x1000 -#define I2C_M_NO_RD_ACK 0x0800 - short len; /* msg length */ - char *buf; /* pointer to msg data */ -}; - -/* To determine what functionality is present */ - -#define I2C_FUNC_I2C 0x00000001 -#define I2C_FUNC_10BIT_ADDR 0x00000002 -#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ -#define I2C_FUNC_SMBUS_PEC 0x00000008 -#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ -#define I2C_FUNC_SMBUS_QUICK 0x00010000 -#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 -#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 -#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 -#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 -#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 -#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 -#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 -#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 -#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 -#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ -#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ - -#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ - I2C_FUNC_SMBUS_WRITE_BYTE) -#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ - I2C_FUNC_SMBUS_WRITE_BYTE_DATA) -#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ - I2C_FUNC_SMBUS_WRITE_WORD_DATA) -#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ - I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) -#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) - -/* Old name, for compatibility */ -#define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC - -/* - * Data for SMBus Messages - */ -#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ -#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */ -union i2c_smbus_data { - __u8 byte; - __u16 word; - __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ - /* and one more for PEC */ -}; - -/* smbus_access read or write markers */ -#define I2C_SMBUS_READ 1 -#define I2C_SMBUS_WRITE 0 - -/* SMBus transaction types (size parameter in the above functions) - Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ -#define I2C_SMBUS_QUICK 0 -#define I2C_SMBUS_BYTE 1 -#define I2C_SMBUS_BYTE_DATA 2 -#define I2C_SMBUS_WORD_DATA 3 -#define I2C_SMBUS_PROC_CALL 4 -#define I2C_SMBUS_BLOCK_DATA 5 -#define I2C_SMBUS_I2C_BLOCK_BROKEN 6 -#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ -#define I2C_SMBUS_I2C_BLOCK_DATA 8 - - -/* ----- commands for the ioctl like i2c_command call: - * note that additional calls are defined in the algorithm and hw - * dependent layers - these can be listed here, or see the - * corresponding header files. - */ - /* -> bit-adapter specific ioctls */ -#define I2C_RETRIES 0x0701 /* number of times a device address */ - /* should be polled when not */ - /* acknowledging */ -#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ - - -/* this is for i2c-dev.c */ -#define I2C_SLAVE 0x0703 /* Change slave address */ - /* Attn.: Slave address is 7 or 10 bits */ -#define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ - /* Attn.: Slave address is 7 or 10 bits */ - /* This changes the address, even if it */ - /* is already taken! */ -#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ - -#define I2C_FUNCS 0x0705 /* Get the adapter functionality */ -#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ -#define I2C_PEC 0x0708 /* != 0 for SMBus PEC */ - -#define I2C_SMBUS 0x0720 /* SMBus-level access */ - -/* -- i2c.h -- */ - - -/* Note: 10-bit addresses are NOT supported! */ - -/* This is the structure as used in the I2C_SMBUS ioctl call */ -struct i2c_smbus_ioctl_data { - char read_write; - __u8 command; - int size; - union i2c_smbus_data *data; -}; - -/* This is the structure as used in the I2C_RDWR ioctl call */ -struct i2c_rdwr_ioctl_data { - struct i2c_msg *msgs; /* pointers to i2c_msgs */ - int nmsgs; /* number of i2c_msgs */ -}; - - -static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, - int size, union i2c_smbus_data *data) -{ - struct i2c_smbus_ioctl_data args; - - args.read_write = read_write; - args.command = command; - args.size = size; - args.data = data; - return ioctl(file,I2C_SMBUS,&args); -} - - -static inline __s32 i2c_smbus_write_quick(int file, __u8 value) -{ - return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL); -} - -static inline __s32 i2c_smbus_read_byte(int file) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data)) - return -1; - else - return 0x0FF & data.byte; -} - -static inline __s32 i2c_smbus_write_byte(int file, __u8 value) -{ - return i2c_smbus_access(file,I2C_SMBUS_WRITE,value, - I2C_SMBUS_BYTE,NULL); -} - -static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_BYTE_DATA,&data)) - return -1; - else - return 0x0FF & data.byte; -} - -static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command, - __u8 value) -{ - union i2c_smbus_data data; - data.byte = value; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BYTE_DATA, &data); -} - -static inline __s32 i2c_smbus_read_word_data(int file, __u8 command) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_WORD_DATA,&data)) - return -1; - else - return 0x0FFFF & data.word; -} - -static inline __s32 i2c_smbus_write_word_data(int file, __u8 command, - __u16 value) -{ - union i2c_smbus_data data; - data.word = value; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_WORD_DATA, &data); -} - -static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value) -{ - union i2c_smbus_data data; - data.word = value; - if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_PROC_CALL,&data)) - return -1; - else - return 0x0FFFF & data.word; -} - - -/* Returns the number of read bytes */ -static inline __s32 i2c_smbus_read_block_data(int file, __u8 command, - __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_BLOCK_DATA,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - -static inline __s32 i2c_smbus_write_block_data(int file, __u8 command, - __u8 length, const __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BLOCK_DATA, &data); -} - -/* Returns the number of read bytes */ -/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you - ask for less than 32 bytes, your code will only work with kernels - 2.6.23 and later. */ -static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, - __u8 length, __u8 *values) -{ - union i2c_smbus_data data; - int i; - - if (length > 32) - length = 32; - data.block[0] = length; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN : - I2C_SMBUS_I2C_BLOCK_DATA,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - -static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, - __u8 length, - const __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_I2C_BLOCK_BROKEN, &data); -} - -/* Returns the number of read bytes */ -static inline __s32 i2c_smbus_block_process_call(int file, __u8 command, - __u8 length, __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BLOCK_PROC_CALL,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - - -#endif /* LIB_I2CDEV_H */ diff --git a/lib/ESPiLight/pilight/libs/pilight/core/irq.c b/lib/ESPiLight/pilight/libs/pilight/core/irq.c deleted file mode 100644 index aeab55b..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/irq.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#endif - -#include "irq.h" -#include "gc.h" -#include "log.h" -#include "mem.h" - -typedef struct timestamp_t { - unsigned long first; - unsigned long second; -} timestamp_t; - -timestamp_t timestamp; - -/* Attaches an interrupt handler to a specific GPIO pin - Whenever an rising, falling or changing interrupt occurs - the function given as the last argument will be called */ -int irq_read(int gpio) { -#ifndef _WIN32 - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int x = waitForInterrupt(gpio, 1000); - if(x > 0) { - struct timeval tv; - gettimeofday(&tv, NULL); - timestamp.first = timestamp.second; - timestamp.second = 1000000 * (unsigned int)tv.tv_sec + (unsigned int)tv.tv_usec; - return (int)timestamp.second-(int)timestamp.first; - } - return x; -#else - return -1; -#endif -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/irq.h b/lib/ESPiLight/pilight/libs/pilight/core/irq.h deleted file mode 100644 index 84d6431..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/irq.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _IRQ_H_ -#define _IRQ_H_ - -int irq_read(int gpio); -void irq_interrupt(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/log.c b/lib/ESPiLight/pilight/libs/pilight/core/log.c deleted file mode 100644 index 086e65f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/log.c +++ /dev/null @@ -1,519 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include - -#include "pilight.h" -#include "common.h" -#include "gc.h" -#include "log.h" - -struct logqueue_t { - char *line; - struct logqueue_t *next; -} logqueue_t; - -static pthread_mutex_t logqueue_lock; -static pthread_cond_t logqueue_signal; -static pthread_mutexattr_t logqueue_attr; - -static struct logqueue_t *logqueue; -static struct logqueue_t *logqueue_head; -static unsigned int logqueue_number = 0; -static unsigned int loop = 1; -static unsigned int stop = 0; -static unsigned int pthinitialized = 0; -static unsigned int pthactive = 0; -static unsigned int pthfree = 0; -static pthread_t pth; - -static char *logfile = NULL; -static int filelog = 1; -static int shelllog = 0; -static int loglevel = LOG_DEBUG; - -void logwrite(char *line) { - struct stat sb; - FILE *lf = NULL; - if(logfile != NULL) { - if((stat(logfile, &sb)) == 0) { - if(sb.st_nlink != 0 && sb.st_size > LOG_MAX_SIZE) { - if(lf != NULL) { - fclose(lf); - } - char tmp[strlen(logfile)+5]; - strcpy(tmp, logfile); - strcat(tmp, ".old"); - rename(logfile, tmp); - } - } - if((lf = fopen(logfile, "a")) == NULL) { - filelog = 0; - } else { - fwrite(line, sizeof(char), strlen(line), lf); - fflush(lf); - fclose(lf); - lf = NULL; - } - } -} - -int log_gc(void) { - if(shelllog == 1) { - fprintf(stderr, "DEBUG: garbage collected log library\n"); - } - - stop = 1; - loop = 0; - - if(pthinitialized == 1) { - pthread_mutex_unlock(&logqueue_lock); - pthread_cond_signal(&logqueue_signal); - } - - /* Flush log queue to pilight.err file */ - if(pthactive == 0) { - struct logqueue_t *tmp; - while(logqueue) { - tmp = logqueue; - if(tmp->line != NULL) { - if(filelog == 1 && logfile != NULL) { - logwrite(tmp->line); - } else { - /* [ Datetime ] Progname: */ - /* 24 + 14 + 2 */ - size_t pos = 24+strlen(progname)+3; - size_t len = strlen(tmp->line); - memmove(&tmp->line[0], &tmp->line[pos], len-pos); - /* Remove newline */ - tmp->line[(len-pos)-1] = '\0'; - logerror(tmp->line); - } - FREE(tmp->line); - } - logqueue = logqueue->next; - FREE(tmp); - logqueue_number--; - } - if(logqueue != NULL) { - FREE(logqueue); - } - if(pthfree == 1) { - pthread_join(pth, NULL); - } - } else { - /* Flush log queue by log thread */ - while(logqueue_number > 0) { - usleep(10); - } - while(pthactive > 0) { - usleep(10); - } - pthread_join(pth, NULL); - } - if(logfile != NULL) { - FREE(logfile); - } - return 1; -} - -/* - * A compatible logprint for wiringX - */ -void logprintf1(int prio, char *file, int line, const char *format_str, ...) { - va_list args; - va_start(args, format_str); - logprintf(prio, format_str, args); - va_end(args); -} - -void logprintf(int prio, const char *format_str, ...) { - struct timeval tv; - struct tm tm; - va_list ap, apcpy; - char fmt[64], buf[64], *line = MALLOC(128); - int save_errno = -1, pos = 0, bytes = 0; - - memset(&tm, '\0', sizeof(struct tm)); - - if(line == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - save_errno = errno; - - memset(line, '\0', 128); - memset(buf, '\0', 64); - - if(loglevel >= prio) { - gettimeofday(&tv, NULL); -#ifdef _WIN32 - struct tm *tm1; - if((tm1 = gmtime(&tv.tv_sec)) != 0) { - memcpy(&tm, tm1, sizeof(struct tm)); -#else - if((gmtime_r(&tv.tv_sec, &tm)) != 0) { -#endif - strftime(fmt, sizeof(fmt), "%b %d %H:%M:%S", &tm); - snprintf(buf, sizeof(buf), "%s:%03u", fmt, (unsigned int)tv.tv_usec); - } - pos += sprintf(line, "[%22.22s] %s: ", buf, progname); - - switch(prio) { - case LOG_WARNING: - pos += sprintf(&line[pos], "WARNING: "); - break; - case LOG_ERR: - pos += sprintf(&line[pos], "ERROR: "); - break; - case LOG_INFO: - pos += sprintf(&line[pos], "INFO: "); - break; - case LOG_NOTICE: - pos += sprintf(&line[pos], "NOTICE: "); - break; - case LOG_DEBUG: - pos += sprintf(&line[pos], "DEBUG: "); - break; - case LOG_STACK: - pos += sprintf(&line[pos], "STACK: "); - break; - default: - break; - } - - va_copy(apcpy, ap); - va_start(apcpy, format_str); -#ifdef _WIN32 - bytes = _vscprintf(format_str, apcpy); -#else - bytes = vsnprintf(NULL, 0, format_str, apcpy); -#endif - if(bytes == -1) { - fprintf(stderr, "ERROR: unproperly formatted logprintf message %s\n", format_str); - } else { - va_end(apcpy); - if((line = REALLOC(line, (size_t)bytes+(size_t)pos+3)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - va_start(ap, format_str); - pos += vsprintf(&line[pos], format_str, ap); - va_end(ap); - } - line[pos++]='\n'; - line[pos++]='\0'; - } - if(shelllog == 1) { - fprintf(stderr, "%s", line); - } -#ifdef _WIN32 - if(prio == LOG_ERR && strstr(progname, "daemon") != NULL && pilight.running == 0) { - MessageBox(NULL, line, "pilight :: error", MB_OK); - } -#endif - if(stop == 0 && pos > 0) { - if(prio < LOG_DEBUG) { - if(pthinitialized == 1) { - pthread_mutex_lock(&logqueue_lock); - } - if(logqueue_number < 1024) { - struct logqueue_t *node = MALLOC(sizeof(logqueue_t)); - if(node == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((node->line = MALLOC((size_t)pos+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(node->line, '\0', (size_t)pos+1); - strcpy(node->line, line); - node->next = NULL; - - if(logqueue_number == 0) { - logqueue = node; - logqueue_head = node; - } else { - logqueue_head->next = node; - logqueue_head = node; - } - - logqueue_number++; - } else { - fprintf(stderr, "log queue full\n"); - } - if(pthinitialized == 1) { - pthread_mutex_unlock(&logqueue_lock); - pthread_cond_signal(&logqueue_signal); - } - } - } - FREE(line); - errno = save_errno; -} - -void *logloop(void *param) { - pth = pthread_self(); - - pthactive = 1; - pthfree = 1; - - pthread_mutex_lock(&logqueue_lock); - while(loop) { - if(logqueue_number > 0) { - pthread_mutex_lock(&logqueue_lock); - - logwrite(logqueue->line); - - struct logqueue_t *tmp = logqueue; - FREE(tmp->line); - logqueue = logqueue->next; - FREE(tmp); - logqueue_number--; - pthread_mutex_unlock(&logqueue_lock); - } else { - pthread_cond_wait(&logqueue_signal, &logqueue_lock); - } - } - - pthactive = 0; - return (void *)NULL; -} - -void logperror(int prio, const char *s) { - // int save_errno = errno; - // if(logging == 0) - // return; - - // if(s != NULL) { - // logprintf(prio, "%s: %s", s, strerror(errno)); - // } else { - // logprintf(prio, "%s", strerror(errno)); - // } - // errno = save_errno; -} - -void log_file_enable(void) { - filelog = 1; - if(pthinitialized == 0) { - pthread_mutexattr_init(&logqueue_attr); - pthread_mutexattr_settype(&logqueue_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&logqueue_lock, &logqueue_attr); - pthread_cond_init(&logqueue_signal, NULL); - pthinitialized = 1; - } -} - -void log_file_disable(void) { - filelog = 0; -} - -void log_shell_enable(void) { - shelllog = 1; -} - -void log_shell_disable(void) { - shelllog = 0; -} - -int log_file_set(char *log) { - struct stat s; - struct stat sb; - char *logpath = NULL; - FILE *lf = NULL; - - atomiclock(); - /* basename isn't thread safe */ - char *filename = basename(log); - atomicunlock(); - - size_t i = (strlen(log)-strlen(filename)); - if((logpath = REALLOC(logpath, i+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(logpath, '\0', i+1); - strncpy(logpath, log, i); - -/* - * dir stat doens't work on windows if path has a trailing slash - */ -#ifdef _WIN32 - if(logpath[i-1] == '\\' || logpath[i-1] == '/') { - logpath[i-1] = '\0'; - } -#endif - - if(strcmp(filename, log) != 0) { - int err = stat(logpath, &s); - if(err == -1) { - if(ENOENT == errno) { - logprintf(LOG_ERR, "the log folder %s does not exist", logpath); - FREE(logpath); - return EXIT_FAILURE; - } else { - logprintf(LOG_ERR, "failed to run stat on log folder %s", logpath); - FREE(logpath); - return EXIT_FAILURE; - } - } else { - if(S_ISDIR(s.st_mode)) { - if((logfile = REALLOC(logfile, strlen(log)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(logfile, log); - } else { - logprintf(LOG_ERR, "the log folder %s does not exist", logpath); - FREE(logpath); - return EXIT_FAILURE; - } - } - } else { - if((logfile = REALLOC(logfile, strlen(log)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(logfile, log); - } - - char tmp[strlen(logfile)+5]; - strcpy(tmp, logfile); - strcat(tmp, ".old"); - - if((stat(tmp, &sb)) == 0) { - if(sb.st_nlink > 0) { - if((stat(logfile, &sb)) == 0) { - if(sb.st_nlink > 0) { - remove(tmp); - rename(logfile, tmp); - } - } - } - } - - if(lf == NULL && filelog == 1) { - if((lf = fopen(logfile, "a")) == NULL) { - filelog = 0; - shelllog = 1; - logprintf(LOG_ERR, "could not open logfile %s", logfile); - FREE(logpath); - FREE(logfile); - exit(EXIT_FAILURE); - } else { - fclose(lf); - lf = NULL; - } - } - - FREE(logpath); - return EXIT_SUCCESS; -} - -void log_level_set(int level) { - loglevel = level; -} - -int log_level_get(void) { - return loglevel; -} - -void logerror(const char *format_str, ...) { - char line[1024]; - va_list ap; - struct stat sb; - FILE *f = NULL; - char fmt[64], buf[64]; - struct timeval tv; - struct tm tm; - char date[128]; -#ifdef _WIN32 - const char *errpath = "c:/ProgramData/pilight/pilight.err"; -#else - const char *errpath = "/var/log/pilight.err"; -#endif - memset(line, '\0', 1024); - memset(&ap, '\0', sizeof(va_list)); - memset(&sb, '\0', sizeof(struct stat)); - memset(&tv, '\0', sizeof(struct timeval)); - memset(date, '\0', 128); - memset(&tm, '\0', sizeof(struct tm)); - - gettimeofday(&tv, NULL); -#ifdef _WIN32 - if((localtime(&tv.tv_sec)) != 0) { -#else - if((localtime_r(&tv.tv_sec, &tm)) != 0) { -#endif - strftime(fmt, sizeof(fmt), "%b %d %H:%M:%S", &tm); - snprintf(buf, sizeof(buf), "%s:%03u", fmt, (unsigned int)tv.tv_usec); - } - - sprintf(date, "[%22.22s] %s: ", buf, progname); - strcat(line, date); - va_start(ap, format_str); - vsprintf(&line[strlen(line)], format_str, ap); - strcat(line, "\n"); - - if((stat(errpath, &sb)) >= 0) { - if((f = fopen(errpath, "a")) == NULL) { - return; - } - } else { - if(sb.st_nlink == 0) { - if(!(f = fopen(errpath, "a"))) { - return; - } - } - if(sb.st_size > LOG_MAX_SIZE) { - if(f != NULL) { - fclose(f); - } - char tmp[strlen(errpath)+5]; - strcpy(tmp, errpath); - strcat(tmp, ".old"); - rename(errpath, tmp); - if((f = fopen(errpath, "a")) == NULL) { - return; - } - } - } - if(f != NULL) { - fwrite(line, sizeof(char), strlen(line), f); - fflush(f); - fclose(f); - f = NULL; - } - va_end(ap); -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/log.h b/lib/ESPiLight/pilight/libs/pilight/core/log.h deleted file mode 100644 index c2a2fb1..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/log.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _LOG_H_ -#define _LOG_H_ - -#ifdef _WIN32 - #define LOG_EMERG 0 - #define LOG_ALERT 1 - #define LOG_CRIT 2 - #define LOG_ERR 3 - #define LOG_WARNING 4 - #define LOG_NOTICE 5 - #define LOG_INFO 6 - #define LOG_DEBUG 7 -#else - #include -#endif - -#define LOG_STACK 255 - -void logprintf1(int prio, char *file, int line, const char *format_str, ...); -void logprintf(int prio, const char *format_str, ...); -void logperror(int prio, const char *s); -void *logloop(void *param); -void log_file_enable(void); -void log_file_disable(void); -void log_shell_enable(void); -void log_shell_disable(void); -int log_file_set(char *file); -void log_level_set(int level); -int log_level_get(void); -int log_gc(void); -void logerror(const char *format_str, ...); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/mail.c b/lib/ESPiLight/pilight/libs/pilight/core/mail.c deleted file mode 100644 index 0d900eb..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/mail.c +++ /dev/null @@ -1,695 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #include - #include - #define MSG_NOSIGNAL 0 -#else - #include - #include - #include - #include - #include - #include - #include -#endif -#include - -#include "ssl.h" -#include "eventpool.h" -#include "../../libuv/uv.h" - -#include "network.h" -#include "log.h" -#include "mail.h" - -#define USERAGENT "pilight" - -#define UNSUPPORTED 0 -#define AUTHPLAIN 1 -#define STARTTLS 2 - -#define SMTP_STEP_RECV_WELCOME 0 -#define SMTP_STEP_SEND_HELLO 1 -#define SMTP_STEP_RECV_HELLO 2 -#define SMTP_STEP_SEND_STARTTLS 3 -#define SMTP_STEP_RECV_STARTTLS 4 -#define SMTP_STEP_SEND_AUTH 5 -#define SMTP_STEP_RECV_AUTH 6 -#define SMTP_STEP_SEND_FROM 7 -#define SMTP_STEP_RECV_FROM 8 -#define SMTP_STEP_SEND_TO 9 -#define SMTP_STEP_RECV_TO 10 -#define SMTP_STEP_SEND_DATA 11 -#define SMTP_STEP_RECV_DATA 12 -#define SMTP_STEP_SEND_BODY 13 -#define SMTP_STEP_RECV_BODY 14 -#define SMTP_STEP_SEND_RESET 15 -#define SMTP_STEP_RECV_RESET 16 -#define SMTP_STEP_SEND_QUIT 17 -#define SMTP_STEP_RECV_QUIT 18 -#define SMTP_STEP_END 99 - -typedef struct request_t { - const char *host; - const char *login; - const char *pass; - unsigned short port; - - char *content; - int content_len; - int step; - int authtype; - int reading; - int sending; - int bytes_read; - void (*callback)(int, struct mail_t *); - - struct mail_t *mail; - - mbedtls_ssl_context ssl; -} request_t; - -static void close_cb(uv_handle_t *handle) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - FREE(handle); -} - -static void abort_cb(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct request_t *request = custom_poll_data->data; - int fd = -1, r = 0; - - if((r = uv_fileno((uv_handle_t *)req, (uv_os_fd_t *)&fd)) != 0) { - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); /*LCOV_EXCL_LINE*/ - } - - if(request != NULL && request->callback != NULL) { - request->callback(-1, request->mail); - } - - if(fd > -1) { -#ifdef _WIN32 - shutdown(fd, SD_BOTH); - closesocket(fd); -#else - shutdown(fd, SHUT_RDWR); - close(fd); -#endif - } - - uv_poll_stop(req); - if(!uv_is_closing((uv_handle_t *)req)) { - uv_close((uv_handle_t *)req, close_cb); - } - - if(custom_poll_data != NULL) { - uv_custom_poll_free(custom_poll_data); - } - - if(request != NULL) { - FREE(request); - } -} - -static void custom_close_cb(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - abort_cb(req); -} - -static void read_cb(uv_poll_t *req, ssize_t *nread, char *buf) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct request_t *request = custom_poll_data->data; - char buffer[BUFFER_SIZE], testme[256], ch = 0; - int val = 0, n = 0; - memset(&buffer, '\0', BUFFER_SIZE); - - if(*nread == -1) { - /* - * We are disconnected - */ - abort_cb(req); - return; - } - - if(*nread > 0) { - buf[*nread-1] = '\0'; - } - - switch(request->step) { - case SMTP_STEP_RECV_WELCOME: { - if(strncmp(buf, "220", 3) != 0) { - uv_custom_close(req); - return; - } - request->bytes_read = 0; - *nread = 0; - request->step = SMTP_STEP_SEND_HELLO; - uv_custom_write(req); - } break; - case SMTP_STEP_RECV_HELLO: { - char **array = NULL; - int i = 0; - n = explode(buf, "\r\n", &array); - for(i=0;iauthtype = AUTHPLAIN; - } - } - if(strncmp(testme, "STARTTLS", 8) == 0) { - request->authtype = STARTTLS; - } - } - - if(val == 501 && ch == 32) { - array_free(&array, n); - uv_custom_close(req); - logprintf(LOG_NOTICE, "SMTP: EHLO error"); - return; - } - if(val == 250 && ch == 32) { - request->reading = 0; - request->bytes_read = 0; - if(request->authtype == UNSUPPORTED) { - logprintf(LOG_NOTICE, "SMTP: no supported authentication method"); - array_free(&array, n); - uv_custom_close(req); - return; - } - if(request->authtype == STARTTLS) { - request->step = SMTP_STEP_SEND_STARTTLS; - } else { - request->step = SMTP_STEP_SEND_AUTH; - } - uv_custom_write(req); - break; - } - } - array_free(&array, n); - if(request->reading == 1) { - uv_custom_read(req); - return; - } - *nread = 0; - } break; - case SMTP_STEP_RECV_AUTH: { - if(strncmp(buf, "235", 3) == 0) { - request->step = SMTP_STEP_SEND_FROM; - } - if(strncmp(buf, "451", 3) == 0) { - logprintf(LOG_NOTICE, "SMTP: protocol violation while authenticating"); - uv_custom_close(req); - return; - } - if(strncmp(buf, "501", 3) == 0) { - logprintf(LOG_NOTICE, "SMTP: improperly base64 encoded user/password"); - uv_custom_close(req); - return; - } - if(strncmp(buf, "535", 3) == 0) { - logprintf(LOG_NOTICE, "SMTP: authentication failed: wrong user/password"); - uv_custom_close(req); - return; - } - *nread = 0; - request->step = SMTP_STEP_SEND_FROM; - uv_custom_write(req); - } break; - case SMTP_STEP_RECV_FROM: { - if(strncmp(buf, "250", 3) != 0) { - uv_custom_close(req); - return; - } - request->bytes_read = 0; - *nread = 0; - request->step = SMTP_STEP_SEND_TO; - uv_custom_write(req); - } break; - case SMTP_STEP_RECV_TO: { - if(strncmp(buf, "250", 3) != 0) { - uv_custom_close(req); - return; - } - request->bytes_read = 0; - *nread = 0; - request->step = SMTP_STEP_SEND_DATA; - uv_custom_write(req); - } break; - case SMTP_STEP_RECV_DATA: { - if(strncmp(buf, "354", 3) != 0) { - uv_custom_close(req); - return; - } - request->bytes_read = 0; - *nread = 0; - request->step = SMTP_STEP_SEND_BODY; - uv_custom_write(req); - } break; - case SMTP_STEP_RECV_BODY: { - if(strncmp(buf, "250", 3) != 0) { - uv_custom_close(req); - return; - } - request->bytes_read = 0; - *nread = 0; - request->step = SMTP_STEP_SEND_RESET; - uv_custom_write(req); - } break; - case SMTP_STEP_RECV_RESET: { - if(strncmp(buf, "250", 3) != 0) { - uv_custom_close(req); - return; - } - request->bytes_read = 0; - *nread = 0; - request->step = SMTP_STEP_SEND_QUIT; - uv_custom_write(req); - } break; - case SMTP_STEP_RECV_QUIT: { - logprintf(LOG_INFO, "SMTP: successfully send mail"); - if(request->callback != NULL) { - request->callback(0, request->mail); - } - request->callback = NULL; - uv_custom_close(req); - // if(!uv_is_closing((uv_handle_t *)req)) { - // uv_close((uv_handle_t *)req, close_cb); - // } - // uv_custom_poll_free(custom_poll_data); - // FREE(request); - return; - } break; - case SMTP_STEP_RECV_STARTTLS: { - if(strncmp(buf, "220", 3) == 0) { - custom_poll_data->is_ssl = 1; - - request->bytes_read = 0; - *nread = 0; - request->step = SMTP_STEP_SEND_HELLO; - uv_custom_write(req); - } - } break; - } -} - -static void push_data(uv_poll_t *req, int step) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct request_t *request = custom_poll_data->data; - - iobuf_append(&custom_poll_data->send_iobuf, (void *)request->content, request->content_len); - - if(request->content != NULL) { - FREE(request->content); - } - request->content_len = 0; - request->step = step; - request->reading = 1; - - uv_custom_write(req); - uv_custom_read(req); -} - -static void write_cb(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct request_t *request = custom_poll_data->data; - - switch(request->step) { - case SMTP_STEP_RECV_WELCOME: { - push_data(req, SMTP_STEP_RECV_WELCOME); - } break; - case SMTP_STEP_SEND_HELLO: { - request->content_len = strlen("EHLO \r\n")+strlen(USERAGENT)+1; - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - request->content_len = (size_t)snprintf(request->content, request->content_len, "EHLO %s\r\n", USERAGENT); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - - push_data(req, SMTP_STEP_RECV_HELLO); - } break; - case SMTP_STEP_SEND_AUTH: { - request->content_len = strlen(request->login)+strlen(request->pass)+2; - char *authstr = MALLOC(request->content_len), *hash = NULL; - if(authstr == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(authstr, '\0', request->content_len); - strncpy(&authstr[1], request->login, strlen(request->login)); - strncpy(&authstr[2+strlen(request->login)], request->pass, request->content_len-strlen(request->login)-2); - hash = base64encode(authstr, request->content_len); - FREE(authstr); - - request->content_len = strlen("AUTH PLAIN \r\n")+strlen(hash)+1; - if((request->content = REALLOC(request->content, request->content_len+4)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(request->content, '\0', request->content_len); - request->content_len = snprintf(request->content, request->content_len, "AUTH PLAIN %s\r\n", hash); - FREE(hash); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: AUTH PLAIN XXX\n"); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_AUTH); - } break; - case SMTP_STEP_SEND_FROM: { - request->content_len = strlen("MAIL FROM: <>\r\n")+strlen(request->mail->from)+1; - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - request->content_len = (size_t)snprintf(request->content, request->content_len, "MAIL FROM: <%s>\r\n", request->mail->from); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_FROM); - } break; - case SMTP_STEP_SEND_TO: { - request->content_len = strlen("RCPT TO: <>\r\n")+strlen(request->mail->to)+1; - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - request->content_len = (size_t)snprintf(request->content, request->content_len, "RCPT TO: <%s>\r\n", request->mail->to); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_TO); - } break; - case SMTP_STEP_SEND_DATA: { - request->content_len = strlen("DATA\r\n"); - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy(request->content, "DATA\r\n", request->content_len); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_DATA); - } break; - case SMTP_STEP_SEND_BODY: { - request->content_len = 255; - request->content_len += strlen(request->mail->to); - request->content_len += strlen(request->mail->from); - request->content_len += strlen(request->mail->subject); - request->content_len += strlen(request->mail->message); - - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - request->content_len = (size_t)snprintf(request->content, request->content_len, - "Subject: %s\r\n" - "From: <%s>\r\n" - "To: <%s>\r\n" - "Content-Type: text/plain\r\n" - "Mime-Version: 1.0\r\n" - "X-Mailer: Emoticode smtp_send\r\n" - "Content-Transfer-Encoding: 7bit\r\n\r\n" - "%s" - "\r\n.\r\n", - request->mail->subject, request->mail->from, request->mail->to, request->mail->message); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_BODY); - } break; - case SMTP_STEP_SEND_RESET: { - request->content_len = strlen("RSET\r\n"); - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy(request->content, "RSET\r\n", request->content_len); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_RESET); - } break; - case SMTP_STEP_SEND_QUIT: { - request->content_len = strlen("QUIT\r\n"); - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy(request->content, "QUIT\r\n", request->content_len); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_QUIT); - } break; - case SMTP_STEP_SEND_STARTTLS: { - request->content_len = strlen("STARTTLS\r\n"); - if((request->content = REALLOC(request->content, request->content_len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy(request->content, "STARTTLS\r\n", request->content_len); - /*LCOV_EXCL_START*/ - if(pilight.debuglevel >= 2) { - fprintf(stderr, "SMTP: %s\n", request->content); - } - /*LCOV_EXCL_STOP*/ - push_data(req, SMTP_STEP_RECV_STARTTLS); - } break; - } -} - -int sendmail(char *host, char *login, char *pass, unsigned short port, int is_ssl, struct mail_t *mail, void (*callback)(int, struct mail_t *)) { - struct request_t *request = NULL; - struct uv_custom_poll_t *custom_poll_data = NULL; - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - char *ip = NULL; - int type = 0, sockfd = 0, r = 0; - - if(mail->from == NULL) { - logprintf(LOG_ERR, "SMTP: sender not set"); - return -1; - } - if(mail->subject == NULL) { - logprintf(LOG_ERR, "SMTP: subject not set"); - return -1; - } - if(mail->message == NULL) { - logprintf(LOG_ERR, "SMTP: message not set"); - return -1; - } - if(mail->to == NULL) { - logprintf(LOG_ERR, "SMTP: recipient not set"); - return -1; - } - if(strcmp(mail->message, ".") == 0) { - logprintf(LOG_ERR, "SMTP: message cannot be a single ."); - return -1; - } - - if((request = MALLOC(sizeof(struct request_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(request, 0, sizeof(struct request_t)); - request->host = host; - request->login = login; - request->pass = pass; - request->port = port; - request->mail = mail; - request->authtype = UNSUPPORTED; - request->callback = callback; - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "WSAStartup"); - exit(EXIT_FAILURE); - } -#endif - - type = host2ip(host, &ip); - switch(type) { - case AF_INET: { - memset(&addr4, '\0', sizeof(struct sockaddr_in)); - r = uv_ip4_addr(ip, port, &addr4); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_ip4_addr: %s", uv_strerror(r)); - goto free; - /*LCOV_EXCL_END*/ - } - } break; - case AF_INET6: { - memset(&addr6, '\0', sizeof(struct sockaddr_in6)); - r = uv_ip6_addr(ip, port, &addr6); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_ip6_addr: %s", uv_strerror(r)); - goto free; - /*LCOV_EXCL_END*/ - } - } break; - default: { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "host2ip"); - goto free; - /*LCOV_EXCL_END*/ - } break; - } - FREE(ip); - - if((sockfd = socket(type, SOCK_STREAM, 0)) < 0){ - logprintf(LOG_ERR, "socket: %s", strerror(errno)); /*LCOV_EXCL_LINE*/ - goto free; - } - -#ifdef _WIN32 - unsigned long on = 1; - ioctlsocket(sockfd, FIONBIO, &on); -#else - long arg = fcntl(sockfd, F_GETFL, NULL); - fcntl(sockfd, F_SETFL, arg | O_NONBLOCK); -#endif - - switch(type) { - case AF_INET: { - r = connect(sockfd, (struct sockaddr *)&addr4, sizeof(addr4)); - } break; - case AF_INET6: { - r = connect(sockfd, (struct sockaddr *)&addr6, sizeof(addr6)); - } break; - default: { - } break; - } - if(r < 0) { -#ifdef _WIN32 - if(!(WSAGetLastError() == WSAEWOULDBLOCK || WSAGetLastError() == WSAEISCONN)) { -#else - if(!(errno == EINPROGRESS || errno == EISCONN)) { -#endif - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "connect: %s", strerror(errno)); - goto free; - /*LCOV_EXCL_STOP*/ - } - } - - uv_poll_t *poll_req = NULL; - if((poll_req = MALLOC(sizeof(uv_poll_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - uv_custom_poll_init(&custom_poll_data, poll_req, (void *)request); - - custom_poll_data->is_ssl = is_ssl; - - if(custom_poll_data->is_ssl == 1 && ssl_client_init_status() == -1) { - logprintf(LOG_ERR, "secure e-mails require a properly initialized SSL library"); - abort_cb(poll_req); - return -1; - } - custom_poll_data->write_cb = write_cb; - custom_poll_data->read_cb = read_cb; - custom_poll_data->close_cb = custom_close_cb; - - r = uv_poll_init_socket(uv_default_loop(), poll_req, sockfd); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_poll_init_socket: %s", uv_strerror(r)); - FREE(poll_req); - goto free; - /*LCOV_EXCL_STOP*/ - } - - request->step = SMTP_STEP_RECV_WELCOME; - uv_custom_write(poll_req); - - return 0; - -free: - if(request != NULL && request->callback != NULL) { - request->callback(-1, request->mail); - } - FREE(request); - if(custom_poll_data != NULL) { - uv_custom_poll_free(custom_poll_data); - } - if(sockfd > 0) { -#ifdef _WIN32 - closesocket(sockfd); -#else - close(sockfd); -#endif - } - return -1; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/mail.h b/lib/ESPiLight/pilight/libs/pilight/core/mail.h deleted file mode 100644 index 41504d9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/mail.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _MAIL_H_ -#define _MAIL_H_ - -typedef struct mail_t { - char *from; - char *to; - char *subject; - char *message; -} mail_t; - -int sendmail(char *, char *, char *, unsigned short, int, struct mail_t *, void (*)(int, struct mail_t *)); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/mem.c b/lib/ESPiLight/pilight/libs/pilight/core/mem.c deleted file mode 100644 index f3016cb..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/mem.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - Copyright (C) 2013 - 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifdef _MSC_VER - #define _CRT_SECURE_NO_DEPRECATE - #define _CRT_SECURE_NO_WARNINGS -#endif - -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include - #include -#else - #include - #define strdup(a) _strdup(a) -#endif - -#include "mem.h" - -static unsigned short memdbg = 0; -static int lockinit = 0; -static unsigned long openallocs = 0; -static unsigned long totalnrallocs = 0; -#ifdef _WIN32 - HANDLE lock; -#else - static pthread_mutex_t lock; - static pthread_mutexattr_t attr; -#endif - -struct mallocs_t { - void *p; - unsigned long size; - int line; - char file[255]; - struct mallocs_t *next; -} mallocs_t; - -static struct mallocs_t *mallocs = NULL; - -void memtrack(void) { - memdbg = 1; - - if(lockinit == 0) { - lockinit = 1; -#ifdef _WIN32 - lock = CreateMutex(NULL, FALSE, NULL); -#else - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - } -} - -int xfree(void) { - if(memdbg == 1) { -#ifdef _WIN32 - DWORD dwWaitResult = WaitForSingleObject(lock, INFINITE); -#else - pthread_mutex_lock(&lock); -#endif - unsigned long totalsize = 0; - struct mallocs_t *tmp; - while(mallocs) { - tmp = mallocs; - totalsize += mallocs->size; - fprintf(stderr, "WARNING: unfreed pointer (%p) in %s at line #%d\n", mallocs->p, tmp->file, tmp->line); - free(mallocs->p); - mallocs = mallocs->next; - free(tmp); - } - free(mallocs); -#ifdef _WIN32 - ReleaseMutex(lock); -#else - pthread_mutex_unlock(&lock); -#endif - - /*fprintf(stderr, "%s: leaked %lu bytes from pilight libraries and programs.\n", - (totalsize > 0) ? "ERROR" : "NOTICE", totalsize); - fprintf(stderr, "NOTICE: memory allocations total: %lu, still open: %lu\n", totalnrallocs, openallocs);*/ - totalnrallocs = 0; - memdbg = 2; - } - return openallocs; -} - -void *__malloc(unsigned long a, const char *file, int line) { - if(memdbg == 1) { - struct mallocs_t *node = malloc(sizeof(mallocs_t)); - if((node->p = malloc(a)) == NULL) { - fprintf(stderr, "out of memory in %s at line #%d\n", file, line); - free(node); - xfree(); - exit(EXIT_FAILURE); - } -#ifdef _WIN32 - InterlockedIncrement(&openallocs); - InterlockedIncrement(&totalnrallocs); -#else - __sync_add_and_fetch(&openallocs, 1); - __sync_add_and_fetch(&totalnrallocs, 1); -#endif - node->size = a; - node->line = line; - strcpy(node->file, file); - -#ifdef _WIN32 - DWORD dwWaitResult = WaitForSingleObject(lock, INFINITE); -#else - pthread_mutex_lock(&lock); -#endif - node->next = mallocs; - mallocs = node; -#ifdef _WIN32 - ReleaseMutex(lock); -#else - pthread_mutex_unlock(&lock); -#endif - - return node->p; - } else { - return malloc(a); - } -} - -char *___strdup(char *a, const char *file, int line) { - char *d = __malloc(strlen(a) + 1, file, line); - if(d == NULL) { - return NULL; - } - strcpy(d, a); - return d; -} - -void *__realloc(void *a, unsigned long b, const char *file, int line) { - if(memdbg == 1) { - if(a == NULL) { - return __malloc(b, file, line); - } else { -#ifdef _WIN32 - DWORD dwWaitResult = WaitForSingleObject(lock, INFINITE); -#else - pthread_mutex_lock(&lock); -#endif - struct mallocs_t *tmp = mallocs; - while(tmp) { - if(tmp->p == a) { - tmp->line = line; - strcpy(tmp->file, file); - tmp->size = b; - if((a = realloc(a, b)) == NULL) { - fprintf(stderr, "out of memory in %s at line #%d\n", file, line); -#ifdef _WIN32 - ReleaseMutex(lock); -#else - pthread_mutex_unlock(&lock); -#endif - xfree(); - exit(EXIT_FAILURE); - } - tmp->p = a; - break; - } - tmp = tmp->next; - } -#ifdef _WIN32 - ReleaseMutex(lock); -#else - pthread_mutex_unlock(&lock); -#endif - if(tmp == NULL) { - fprintf(stderr, "ERROR: calling realloc on an unknown pointer in %s at line #%d\n", file, line); - return __malloc(b, file, line); - } else if(tmp != NULL && tmp->p != NULL) { - return a; - } else { - return __malloc(b, file, line); - } - } - } else { - return realloc(a, b); - } -} - -void *__calloc(unsigned long a, unsigned long b, const char *file, int line) { - if(memdbg == 1) { - struct mallocs_t *node = malloc(sizeof(mallocs_t)); - if((node->p = malloc(a*b)) == NULL) { - fprintf(stderr, "out of memory in %s at line #%d\n", file, line); - free(node); - xfree(); - exit(EXIT_FAILURE); - } -#ifdef _WIN32 - InterlockedIncrement(&openallocs); - InterlockedIncrement(&totalnrallocs); -#else - __sync_add_and_fetch(&openallocs, 1); - __sync_add_and_fetch(&totalnrallocs, 1); -#endif - memset(node->p, '\0', a*b); - node->size = a*b; - node->line = line; - strcpy(node->file, file); - -#ifdef _WIN32 - DWORD dwWaitResult = WaitForSingleObject(lock, INFINITE); -#else - pthread_mutex_lock(&lock); -#endif - node->next = mallocs; - mallocs = node; -#ifdef _WIN32 - ReleaseMutex(lock); -#else - pthread_mutex_unlock(&lock); -#endif - - return node->p; - } else { - return calloc(a, b); - } -} - -void __free(void *a, const char *file, int line) { - if(memdbg == 2) { - fprintf(stderr, "WARNING: calling free after xfree was called in %s at line #%d\n", file, line); - } - if(memdbg == 1) { - if(a == NULL) { - fprintf(stderr, "WARNING: calling free on already freed pointer in %s at line #%d\n", file, line); - } else { -#ifdef _WIN32 - DWORD dwWaitResult = WaitForSingleObject(lock, INFINITE); -#else - pthread_mutex_lock(&lock); -#endif - struct mallocs_t *currP, *prevP; - int match = 0; - - prevP = NULL; - - for(currP = mallocs; currP != NULL; prevP = currP, currP = currP->next) { - if(currP->p == a) { - match = 1; - if(prevP == NULL) { - mallocs = currP->next; - } else { - prevP->next = currP->next; - } - free(currP->p); - free(currP); - - break; - } - } -#ifdef _WIN32 - ReleaseMutex(lock); - InterlockedDecrement(&openallocs); -#else - __sync_add_and_fetch(&openallocs, -1); - pthread_mutex_unlock(&lock); -#endif - - if(match == 0) { - fprintf(stderr, "ERROR: trying to free an unknown pointer in %s at line #%d\n", file, line); - free(a); - } - } - } else { - free(a); - } -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/network.c b/lib/ESPiLight/pilight/libs/pilight/core/network.c deleted file mode 100644 index fa0c993..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/network.c +++ /dev/null @@ -1,681 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef __FreeBSD__ - #define _GNU_SOURCE -#endif -#include -#include -#include -#include -#include -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #include - #include - #include - #include - #include - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#endif -#include -#include -#include -#include -#include -#include -#ifndef __USE_XOPEN - #define __USE_XOPEN -#endif -#include -#include -#include -#ifdef __FreeBSD__ - #include -#endif - -#include "../config/settings.h" -#include "mem.h" -#include "network.h" -#include "log.h" - -static unsigned int ***whitelist_cache = NULL; -static unsigned int whitelist_number; - -int inetdevs(char ***array) { - unsigned int nrdevs = 0, i = 0, match = 0; - -#ifdef _WIN32 - IP_ADAPTER_INFO *pAdapter = NULL; - ULONG buflen = sizeof(IP_ADAPTER_INFO); - IP_ADAPTER_INFO *pAdapterInfo = (IP_ADAPTER_INFO *)MALLOC(buflen); - - if(GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) { - FREE(pAdapterInfo); - pAdapterInfo = MALLOC(buflen); - } - - if(GetAdaptersInfo(pAdapterInfo, &buflen) == NO_ERROR) { - for(pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) { - match = 0; - - for(i=0;iAdapterName) == 0) { - match = 1; - break; - } - } - if(match == 0 && strcmp(pAdapter->IpAddressList.IpAddress.String, "0.0.0.0") != 0) { - if((*array = REALLOC(*array, sizeof(char *)*(nrdevs+1))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if(((*array)[nrdevs] = MALLOC(strlen(pAdapter->AdapterName)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy((*array)[nrdevs], pAdapter->AdapterName); - nrdevs++; - } - } - } - if(pAdapterInfo != NULL) { - FREE(pAdapterInfo); - } -#else - int family = 0, s = 0; - char host[NI_MAXHOST]; - struct ifaddrs *ifaddr = NULL, *ifa = NULL; - -#ifdef __FreeBSD__ - if(rep_getifaddrs(&ifaddr) == -1) { - logprintf(LOG_ERR, "could not get network adapter information"); - exit(EXIT_FAILURE); - } -#else - if(getifaddrs(&ifaddr) == -1) { - perror("getifaddrs"); - exit(EXIT_FAILURE); - } -#endif - - for(ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { - if(ifa->ifa_addr == NULL) { - continue; - } - - family = ifa->ifa_addr->sa_family; - - if((strstr(ifa->ifa_name, "lo") == NULL && strstr(ifa->ifa_name, "vbox") == NULL - && strstr(ifa->ifa_name, "dummy") == NULL) && (family == AF_INET || family == AF_INET6)) { - memset(host, '\0', NI_MAXHOST); - - s = getnameinfo(ifa->ifa_addr, - (family == AF_INET) ? sizeof(struct sockaddr_in) : - sizeof(struct sockaddr_in6), - host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); - if(s != 0) { - logprintf(LOG_ERR, "getnameinfo() failed: %s", gai_strerror(s)); - exit(EXIT_FAILURE); - } - if(strlen(host) > 0) { - match = 0; - for(i=0;iifa_name) == 0) { - match = 1; - break; - } - } - if(match == 0) { - if((*array = REALLOC(*array, sizeof(char *)*(nrdevs+1))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if(((*array)[nrdevs] = MALLOC(strlen(ifa->ifa_name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy((*array)[nrdevs], ifa->ifa_name); - nrdevs++; - } - } - } - } - -#ifdef __FreeBSD__ - rep_freeifaddrs(ifaddr); -#else - freeifaddrs(ifaddr); -#endif - -#endif // _WIN32 - return (int)nrdevs; -} - -int dev2mac(char *ifname, char **mac) { - memset(*mac, 0, ETH_ALEN); - -#ifdef _WIN32 - int i = 0; - - IP_ADAPTER_INFO *pAdapter = NULL; - ULONG buflen = sizeof(IP_ADAPTER_INFO); - IP_ADAPTER_INFO *pAdapterInfo = malloc(buflen); - - if(GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) { - free(pAdapterInfo); - pAdapterInfo = malloc(buflen); - } - - if(GetAdaptersInfo(pAdapterInfo, &buflen) == NO_ERROR) { - for(pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) { - if(strcmp(ifname, pAdapter->AdapterName) == 0) { - for(i = 0; i < pAdapter->AddressLength; i++) { - memcpy(*mac, pAdapter->Address, ETH_ALEN); - free(pAdapterInfo); - return 0; - } - break; - } - } - } - free(pAdapterInfo); -#endif - -#ifdef linux - int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); - struct ifreq s; - - if(fd < 0) { - logprintf(LOG_ERR, "could not open new socket"); - return -1; - } - - memset(&s, '\0', sizeof(struct ifreq)); - strcpy(s.ifr_name, ifname); - if(ioctl(fd, SIOCGIFHWADDR, &s) == 0) { - memcpy(*mac, s.ifr_addr.sa_data, ETH_ALEN); - close(fd); - return 0; - } else { - logprintf(LOG_ERR, "ioctl SIOCGIFHWADDR failed"); - } - close(fd); -#endif - -#ifdef __FreeBSD__ - struct ifaddrs *ifap = NULL, *ifaptr = NULL; - - if(getifaddrs(&ifap) == 0) { - for(ifaptr = ifap; ifaptr != NULL; ifaptr = (ifaptr)->ifa_next) { - if(strcmp((ifaptr)->ifa_name, ifname) == 0 && (((ifaptr)->ifa_addr)->sa_family == AF_LINK)) { - memcpy(*mac, (unsigned char *)LLADDR((struct sockaddr_dl *)(ifaptr)->ifa_addr), ETH_ALEN); - freeifaddrs(ifap); - return 0; - } - } - } -#endif - - return -1; -} - -#ifdef __FreeBSD__ -int dev2ip(char *dev, char **ip, __sa_family_t type) { -#else -int dev2ip(char *dev, char **ip, sa_family_t type) { -#endif - -#ifdef _WIN32 - IP_ADAPTER_INFO *pAdapter = NULL; - ULONG buflen = sizeof(IP_ADAPTER_INFO); - IP_ADAPTER_INFO *pAdapterInfo = MALLOC(buflen); - - if(GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) { - FREE(pAdapterInfo); - pAdapterInfo = MALLOC(buflen); - } - - if(GetAdaptersInfo(pAdapterInfo, &buflen) == NO_ERROR) { - for(pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) { - if(strcmp(dev, pAdapter->AdapterName) == 0) { - strcpy(*ip, pAdapter->IpAddressList.IpAddress.String); - break; - } - } - } - if(pAdapterInfo != NULL) { - FREE(pAdapterInfo); - } -#else - struct ifaddrs *ifaddr, *ifa; - char host[NI_MAXHOST]; - int family, s, n; - - if(getifaddrs(&ifaddr) == -1) { - perror("getifaddrs"); - exit(EXIT_FAILURE); - } - - /* Walk through linked list, maintaining head pointer so we can free list later */ - for(ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { - if(ifa->ifa_addr == NULL) - continue; - family = ifa->ifa_addr->sa_family; - if(strcmp(ifa->ifa_name, dev) == 0 && family == type) { - s = getnameinfo(ifa->ifa_addr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); - if(s != 0) { - printf("getnameinfo() failed: %s\n", gai_strerror(s)); - exit(EXIT_FAILURE); - } - strcpy(*ip, host); - } - } - - freeifaddrs(ifaddr); -#endif - - return 0; -} - -int host2ip(char *host, char **ip) { - int rv = 0; - struct addrinfo hints, *servinfo, *p; - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "WSAStartup"); - exit(EXIT_FAILURE); - } -#endif - - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_INET6; - hints.ai_socktype = SOCK_STREAM; - - if((rv = getaddrinfo(host, NULL , NULL, &servinfo)) != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_NOTICE, "getaddrinfo: %s, %s", host, gai_strerror(rv)); - return -1; - /*LCOV_EXCL_STOP*/ - } - - for(p = servinfo; p != NULL; p = p->ai_next) { - if(p->ai_family == AF_INET6) { - if((*ip = MALLOC(INET6_ADDRSTRLEN+1)) == NULL) { - OUT_OF_MEMORY - } - struct sockaddr_in6 *h = NULL; - memcpy(&h, &p->ai_addr, sizeof(struct sockaddr_in6 *)); - memset(*ip, '\0', INET6_ADDRSTRLEN+1); - uv_inet_ntop(p->ai_family, (void *)&(h->sin6_addr), *ip, INET6_ADDRSTRLEN+1); - } else if(p->ai_family == AF_INET) { - if((*ip = MALLOC(INET_ADDRSTRLEN+1)) == NULL) { - OUT_OF_MEMORY - } - struct sockaddr_in *h = NULL; - memcpy(&h, &p->ai_addr, sizeof(struct sockaddr_in *)); - memset(*ip, '\0', INET_ADDRSTRLEN+1); - uv_inet_ntop(p->ai_family, (void *)&(h->sin_addr), *ip, INET_ADDRSTRLEN+1); - } - if(*ip != NULL && strlen(*ip) > 0) { - int r = p->ai_family; - freeaddrinfo(servinfo); - return r; - } - } - - freeaddrinfo(servinfo); - return -1; -} - -#ifdef _WIN32 -const char *inet_ntop(int af, const void *src, char *dst, int cnt) { - struct sockaddr_in srcaddr; - - memset(&srcaddr, 0, sizeof(struct sockaddr_in)); - memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr)); - - srcaddr.sin_family = af; - if(WSAAddressToString((struct sockaddr *)&srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD)&cnt) != 0) { - DWORD rv = WSAGetLastError(); - printf("WSAAddressToString() : %d\n", (int)rv); - return NULL; - } - return dst; -} - -int inet_pton(int af, const char *src, void *dst) { - struct sockaddr_storage ss; - int size = sizeof(ss); - char src_copy[INET6_ADDRSTRLEN+1]; - - ZeroMemory(&ss, sizeof(ss)); - /* stupid non-const API */ - strncpy(src_copy, src, INET6_ADDRSTRLEN+1); - src_copy[INET6_ADDRSTRLEN] = 0; - - if(WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) { - switch(af) { - case AF_INET: - *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr; - return 1; - case AF_INET6: - *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr; - return 1; - default: - return 0; - } - } - return 0; -} -#endif - -#ifdef __FreeBSD__ -struct sockaddr *sockaddr_dup(struct sockaddr *sa) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr *ret; - socklen_t socklen; -#ifdef HAVE_SOCKADDR_SA_LEN - socklen = sa->sa_len; -#else - socklen = sizeof(struct sockaddr_storage); -#endif - if((ret = CALLOC(1, socklen)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if (ret == NULL) - return NULL; - memcpy(ret, sa, socklen); - return ret; -} - -int rep_getifaddrs(struct ifaddrs **ifap) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct ifconf ifc; - char buff[8192]; - int fd = 0, i = 0, n = 0; - struct ifreq ifr, *ifrp = NULL; - struct ifaddrs *curif = NULL, *ifa = NULL; - struct ifaddrs *lastif = NULL; - - memset(buff, 0, 8192); - - *ifap = NULL; - - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - return -1; - } - - memset(&ifc, 0, sizeof(struct ifconf)); - memset(&ifr, 0, sizeof(struct ifreq)); - - ifc.ifc_len = sizeof(buff); - ifc.ifc_buf = buff; - - if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { - close(fd); - return -1; - } - -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif -#ifdef __FreeBSD__ -#define ifreq_size(i) max(sizeof(struct ifreq),\ - sizeof((i).ifr_name)+(i).ifr_addr.sa_len) -#else -#define ifreq_size(i) sizeof(struct ifreq) -#endif - - n = ifc.ifc_len; - - for (i = 0; i < n; i+= (int)ifreq_size(*ifrp) ) { - int match = 0; - ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i); - for(ifa = *ifap; ifa != NULL; ifa = ifa->ifa_next) { - if(strcmp(ifrp->ifr_name, ifa->ifa_name) == 0) { - match = 1; - break; - } - } - if(match == 1) { - continue; - } - curif = CALLOC(1, sizeof(struct ifaddrs)); - if(curif == NULL) { - freeifaddrs(*ifap); - close(fd); - return -1; - } - - curif->ifa_name = MALLOC(IFNAMSIZ+1); - if(curif->ifa_name == NULL) { - FREE(curif); - freeifaddrs(*ifap); - close(fd); - return -1; - } - memset(curif->ifa_name, 0, IFNAMSIZ+1); - strncpy(curif->ifa_name, ifrp->ifr_name, IFNAMSIZ); - strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); - - curif->ifa_flags = (unsigned int)ifr.ifr_flags; - curif->ifa_dstaddr = NULL; - curif->ifa_data = NULL; - curif->ifa_next = NULL; - - curif->ifa_addr = NULL; - if(ioctl(fd, SIOCGIFADDR, &ifr) != -1) { - curif->ifa_addr = sockaddr_dup(&ifr.ifr_addr); - if (curif->ifa_addr == NULL) { - FREE(curif->ifa_name); - FREE(curif); - freeifaddrs(*ifap); - close(fd); - return -1; - } - } - - curif->ifa_netmask = NULL; - if (ioctl(fd, SIOCGIFNETMASK, &ifr) != -1) { - curif->ifa_netmask = sockaddr_dup(&ifr.ifr_addr); - if (curif->ifa_netmask == NULL) { - if (curif->ifa_addr != NULL) { - FREE(curif->ifa_addr); - } - FREE(curif->ifa_name); - FREE(curif); - freeifaddrs(*ifap); - close(fd); - return -1; - } - } - - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = curif; - } - lastif = curif; - } - - close(fd); - - return 0; -} - -void rep_freeifaddrs(struct ifaddrs *ifaddr) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct ifaddrs *ifa; - while(ifaddr) { - ifa = ifaddr; - FREE(ifa->ifa_name); - FREE(ifa->ifa_addr); - FREE(ifa->ifa_netmask); - ifaddr = ifaddr->ifa_next; - FREE(ifa); - } - FREE(ifaddr); -} -#endif - -int whitelist_check(char *ip) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char *whitelist = NULL; - unsigned int client[4] = {0}; - int x = 0, i = 0, error = 1; - unsigned int n = 0; - char **array = NULL; - char wip[16] = {'\0'}; - - /* Check if there are any whitelisted ip address */ - if(settings_find_string("whitelist", &whitelist) != 0) { - return 0; - } - - if(strlen(whitelist) == 0) { - return 0; - } - - /* Explode ip address to a 4 elements int array */ - n = explode(ip, ".", &array); - x = 0; - for(x=0;x 0) { - FREE(array); - } - - - if(whitelist_cache == NULL) { - char *tmp = whitelist; - x = 0; - /* Loop through all whitelised ip addresses */ - while(*tmp != '\0') { - /* Remove any comma's and spaces */ - while(*tmp == ',' || *tmp == ' ') { - tmp++; - } - /* Save ip address in temporary char array */ - wip[x] = *tmp; - x++; - tmp++; - - /* Each ip address is either terminated by a comma or EOL delimiter */ - if(*tmp == '\0' || *tmp == ',') { - x = 0; - if((whitelist_cache = REALLOC(whitelist_cache, (sizeof(unsigned int ***)*(whitelist_number+1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((whitelist_cache[whitelist_number] = MALLOC(sizeof(unsigned int **)*2)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - /* Lower boundary */ - if((whitelist_cache[whitelist_number][0] = MALLOC(sizeof(unsigned int *)*4)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - /* Upper boundary */ - if((whitelist_cache[whitelist_number][1] = MALLOC(sizeof(unsigned int *)*4)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - /* Turn the whitelist ip address into a upper and lower boundary. - If the ip address doesn't contain a wildcard, then the upper - and lower boundary are the same. If the ip address does contain - a wildcard, then this lower boundary number will be 0 and the - upper boundary number 255. */ - i = 0; - n = explode(wip, ".", &array); - for(i=0;i 0) { - FREE(array); - } - memset(wip, '\0', 16); - whitelist_number++; - } - } - } - - for(x=0;x= wlower && nip <= wupper) || (nip == 2130706433)) { - error = 0; - } - } - - return error; -} - -void whitelist_free(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int i = 0; - if(whitelist_cache) { - for(i=0;i -*/ - -#ifndef _NETWORK_H_ -#define _NETWORK_H_ - -#ifndef _WIN32 - #include - #include - #include -#endif -#include -#include - -#include "pilight.h" - -#ifndef ETH_ALEN -#define ETH_ALEN 6 -#endif - -#ifdef _WIN32 -#define sa_family_t uint16_t -int inet_pton(int af, const char *src, void *dst); -const char *inet_ntop(int af, const void *src, char *dst, int cnt); -#endif - -int inetdevs(char ***array); -int dev2mac(char *ifname, char **mac); -#ifdef __FreeBSD__ -int dev2ip(char *dev, char **ip, __sa_family_t type); -#else -int dev2ip(char *dev, char **ip, sa_family_t type); -#endif -int host2ip(char *host, char **ip); -int whitelist_check(char *ip); -void whitelist_free(void); - -#ifdef __FreeBSD__ -struct sockaddr *sockaddr_dup(struct sockaddr *sa); -int rep_getifaddrs(struct ifaddrs **ifap); -void rep_freeifaddrs(struct ifaddrs *ifap); -#endif - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/ntp.c b/lib/ESPiLight/pilight/libs/pilight/core/ntp.c deleted file mode 100644 index 6fd428f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/ntp.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - Copyright (C) 2014 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #include - #include - #define MSG_NOSIGNAL 0 -#else - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include - #include - #include - #include - #include - #include -#endif -#include -#include -#include - -#include "../../libuv/uv.h" -#include "network.h" -#include "ntp.h" -#include "socket.h" -#include "pilight.h" -#include "eventpool.h" -#include "common.h" -#include "log.h" -#ifdef PILIGHT_REWRITE - #include "../storage/storage.h" -#else - #include "../config/settings.h" -#endif - -typedef struct l_fp { - union { - unsigned int Xl_ui; - int Xl_i; - } Ul_i; - union { - unsigned int Xl_uf; - int Xl_f; - } Ul_f; -} l_fp; - -typedef struct pkt { - int li_vn_mode; - int rootdelay; - int rootdispersion; - int refid; - struct l_fp ref; - struct l_fp org; - struct l_fp rec; - /* Make sure the pkg is 48 bits */ - double tmp; -} pkt; - -typedef struct data_t { - void (*callback)(int, time_t); - uv_udp_t *stream; - uv_timer_t *timer; -} data_t; - -static int nr = 0; -static int started = 0; -static int synced = 1; -static int init = 0; -static int diff = 0; -static uv_timer_t *timer_req = NULL; - -static void close_cb(uv_handle_t *handle) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - FREE(handle); -} - -static void ntp_timeout(uv_timer_t *param) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct data_t *data = param->data; - void (*callback)(int, time_t) = data->callback; - if(callback != NULL) { - callback(-1, 0); - } - - if(!uv_is_closing((uv_handle_t *)param)) { - uv_close((uv_handle_t *)param, close_cb); - } - if(!uv_is_closing((uv_handle_t *)data->stream)) { - uv_close((uv_handle_t *)data->stream, close_cb); - } - if(data != NULL) { - FREE(data); - } - - logprintf(LOG_INFO, "could not sync with ntp server: %s", ntp_servers.server[nr].host); -} - -static void restart(uv_timer_t *req) { - nr = 0; - ntpsync(); -} - -static void on_read(uv_udp_t *stream, ssize_t len, const uv_buf_t *buf, const struct sockaddr *addr, unsigned int port) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct pkt msg; - struct data_t *data = stream->data; - - if(len == 48) { - memcpy(&msg, buf->base, 48); - - if(msg.refid != 0) { - (msg.rec).Ul_i.Xl_ui = ntohl((msg.rec).Ul_i.Xl_ui); - (msg.rec).Ul_f.Xl_f = (int)ntohl((unsigned int)(msg.rec).Ul_f.Xl_f); - - unsigned int adj = 2208988800u; - unsigned long ntptime = (time_t)(msg.rec.Ul_i.Xl_ui - adj); - diff = (int)(time(NULL) - ntptime); - - synced = 0; - if(data->callback != NULL) { - data->callback(0, (time_t)(msg.rec.Ul_i.Xl_ui - adj)); - } - logprintf(LOG_INFO, "time offset found of %d seconds", diff); - uv_timer_start(timer_req, restart, 86400*1000, 0); - - if(!uv_is_closing((uv_handle_t *)stream)) { - uv_close((uv_handle_t *)stream, close_cb); - } - if(!uv_is_closing((uv_handle_t *)data->timer)) { - uv_close((uv_handle_t *)data->timer, close_cb); - } - if(data != NULL) { - FREE(data); - } - } - free(buf->base); - return; - } -} - -static void alloc(uv_handle_t *handle, size_t len, uv_buf_t *buf) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - buf->len = len; - buf->base = malloc(len); - memset(buf->base, 0, len); -} - -static void on_send(uv_udp_send_t *req, int status) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - FREE(req); -} - -static void loop(uv_timer_t *req) { - /* - * Make sure we are called from the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - if(uv_thread_equal(&pth_main_id, &pth_cur_id) == 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "ntpsync can only be started from the main thread"); - return; - /*LCOV_EXCL_STOP*/ - } - - if(init == 0) { - if((timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - uv_timer_init(uv_default_loop(), timer_req); - init = 1; - } - - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - struct data_t *data = NULL; - uv_udp_t *client_req = NULL; - uv_udp_send_t *send_req = NULL; - uv_timer_t *timeout_req = NULL; - char *ip = NULL; - char buffer[BUFFER_SIZE]; - int r = 0, type = 0; - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "WSAStartup"); - exit(EXIT_FAILURE); - } -#endif - - type = host2ip(ntp_servers.server[nr].host, &ip); - switch(type) { - case AF_INET: { - memset(&addr4, '\0', sizeof(struct sockaddr_in)); - r = uv_ip4_addr(ip, ntp_servers.server[nr].port, &addr4); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_ip4_addr: %s", uv_strerror(r)); - FREE(ip); - return; - /*LCOV_EXCL_END*/ - } - } break; - case AF_INET6: { - memset(&addr6, '\0', sizeof(struct sockaddr_in6)); - r = uv_ip6_addr(ip, ntp_servers.server[nr].port, &addr6); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_ip6_addr: %s", uv_strerror(r)); - FREE(ip); - return; - /*LCOV_EXCL_END*/ - } - } break; - default: { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "host2ip"); - FREE(ip); - /*LCOV_EXCL_END*/ - } break; - } - FREE(ip); - - if((client_req = MALLOC(sizeof(uv_udp_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - r = uv_udp_init(uv_default_loop(), client_req); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_udp_init: %s", uv_strerror(r)); - FREE(client_req); - return; - /*LCOV_EXCL_STOP*/ - } - - if((send_req = MALLOC(sizeof(uv_udp_send_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - if((timeout_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - if((data = MALLOC(sizeof(struct data_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - memset(data, 0, sizeof(struct data_t)); - data->callback = ntp_servers.callback; - data->stream = client_req; - data->timer = timeout_req; - - struct pkt msg; - memset(&msg, '\0', sizeof(struct pkt)); - msg.li_vn_mode = 227; - - memcpy(&buffer, &msg, sizeof(struct pkt)); - uv_buf_t buf = uv_buf_init(buffer, sizeof(struct pkt)); - - client_req->data = data; - - switch(type) { - case AF_INET: { - r = uv_udp_send(send_req, client_req, &buf, 1, (const struct sockaddr *)&addr4, on_send); - } break; - case AF_INET6: { - r = uv_udp_send(send_req, client_req, &buf, 1, (const struct sockaddr *)&addr6, on_send); - } break; - default: { - } break; - } - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_udp_send: %s", uv_strerror(r)); - FREE(send_req); - FREE(client_req); - return; - /*LCOV_EXCL_STOP*/ - } - - timeout_req->data = data; - - uv_timer_init(uv_default_loop(), timeout_req); - uv_timer_start(timeout_req, ntp_timeout, 1000, 0); - - r = uv_udp_recv_start(client_req, alloc, on_read); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_udp_recv_start: %s", uv_strerror(r)); - FREE(send_req); - FREE(client_req); - return; - /*LCOV_EXCL_STOP*/ - } - logprintf(LOG_DEBUG, "syncing with ntp-server %s", ntp_servers.server[nr].host); - - if(nr+1 < ntp_servers.nrservers) { - uv_timer_start(timer_req, loop, 1.5*1000, 0); - nr++; - } else { - nr = 0; - uv_timer_start(timer_req, loop, 10*1000, 0); - } - - return; -} - -void ntpsync(void) { - if(started == 1) { - return; - } - started = 1; - loop(NULL); -} - -void ntp_gc(void) { - nr = 0; - started = 0; - synced = 1; - init = 0; - diff = 0; -} - -int getntpdiff(void) { - return diff; -} - -int isntpsynced(void) { - return synced; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/ntp.h b/lib/ESPiLight/pilight/libs/pilight/core/ntp.h deleted file mode 100644 index 6670f22..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/ntp.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (C) 2014 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _NTP_H_ -#define _NTP_H_ - -#include "../../libuv/uv.h" - -typedef struct ntp_servers_t { - struct { - char host[255]; - int port; - } server[10]; - int nrservers; - void (*callback)(int, time_t); -} ntp_servers_t; - -struct ntp_servers_t ntp_servers; - -void ntpsync(void); -void ntp_gc(void); -int getntpdiff(void); -int isntpsynced(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/options.c b/lib/ESPiLight/pilight/libs/pilight/core/options.c deleted file mode 100644 index 335ca11..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/options.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _WIN32 - #include -#endif -#include -#include -#include - -#include "log.h" -#include "common.h" -#include "mem.h" -#include "options.h" -#include "json.h" - -static int getOptPos = 0; -static char *longarg = NULL; -static char *shortarg = NULL; -static char *gctmp = NULL; - -int options_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - FREE(longarg); - FREE(shortarg); - if(gctmp != NULL) { - FREE(gctmp); - } - - logprintf(LOG_DEBUG, "garbage collected options library"); - return EXIT_SUCCESS; -} - -/* Add a value to the specific struct id */ -void options_set_string(struct options_t **opt, int id, const char *val) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - while(temp) { - if(temp->id == id && temp->id > 0) { - if((temp->string_ = REALLOC(temp->string_, strlen(val)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - temp->vartype = JSON_STRING; - strcpy(temp->string_, val); - break; - } - temp = temp->next; - } -} - -/* Add a value to the specific struct id */ -void options_set_number(struct options_t **opt, int id, double val) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - while(temp) { - if(temp->id == id && temp->id > 0) { - temp->number_ = val; - temp->vartype = JSON_NUMBER; - break; - } - temp = temp->next; - } -} - -/* Get a certain option value identified by the id */ -int options_get_string(struct options_t **opt, int id, char **out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - *out = NULL; - while(temp) { - if(temp->id == id && temp->id > 0) { - if(temp->string_ && temp->vartype == JSON_STRING) { - *out = temp->string_; - return 0; - } else { - return 1; - } - } - temp = temp->next; - } - - return 1; -} - -/* Get a certain option value identified by the id */ -int options_get_number(struct options_t **opt, int id, double *out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - *out = 0; - while(temp) { - if(temp->id == id && temp->id > 0) { - if(temp->vartype == JSON_NUMBER) { - *out = temp->number_; - } - return 0; - } - temp = temp->next; - } - - return 1; -} - -/* Get a certain option argument type identified by the id */ -int options_get_argtype(struct options_t **opt, int id, int *out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - *out = 0; - while(temp) { - if(temp->id == id && temp->id > 0) { - if(temp->argtype != 0) { - *out = temp->argtype; - return 0; - } else { - return 1; - } - } - temp = temp->next; - } - - return 1; -} - -/* Get a certain option argument type identified by the id */ -int options_get_conftype(struct options_t **opt, int id, int *out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - *out = 0; - while(temp) { - if(temp->id == id && temp->id > 0) { - if(temp->argtype != 0) { - *out = temp->conftype; - return 0; - } else { - return 1; - } - } - temp = temp->next; - } - - return 1; -} - -/* Get a certain option name identified by the id */ -int options_get_name(struct options_t **opt, int id, char **out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - *out = NULL; - while(temp) { - if(temp->id == id && temp->id > 0) { - if(temp->name) { - *out = temp->name; - return 0; - } else { - return 1; - } - } - temp = temp->next; - } - - return 1; -} - -/* Get a certain regex mask identified by the name */ -int options_get_mask(struct options_t **opt, int id, char **out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - *out = NULL; - while(temp) { - if(temp->id == id && temp->id > 0) { - if(temp->mask) { - *out = temp->mask; - return 0; - } else { - return 1; - } - } - temp = temp->next; - } - - return 1; -} - -/* Get a certain option id identified by the name */ -int options_get_id(struct options_t **opt, char *name, int *out) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = *opt; - *out = 0; - while(temp) { - if(temp->name) { - if(strcmp(temp->name, name) == 0) { - if(temp->id > 0) { - *out = temp->id; - return 0; - } else { - return 1; - } - } - } - temp = temp->next; - } - - return 1; -} - -/* Parse all CLI arguments */ -int options_parse(struct options_t **opt, int argc, char **argv, int error_check, char **optarg) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int c = 0; - int itmp = 0; -#if !defined(__FreeBSD__) && !defined(_WIN32) - char *mask; - regex_t regex; - int reti; -#endif - - char *ctmp = NULL; - - /* If have read all arguments, exit and reset */ - if(getOptPos>=(argc-1)) { - getOptPos=0; - if(*optarg) { - FREE(*optarg); - *optarg = NULL; - } - return -1; - } else { - getOptPos++; - /* Reserve enough memory to store all variables */ - if((longarg = REALLOC(longarg, 4)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((shortarg = REALLOC(shortarg, 2)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((*optarg = REALLOC(*optarg, 4)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - /* The memory to null */ - memset(*optarg, '\0', 4); - memset(shortarg, '\0', 2); - memset(longarg, '\0', 4); - - /* Check if the CLI character contains an equals to (=) sign. - If it does, we have probably encountered a long argument */ - if(strchr(argv[getOptPos],'=')) { - /* Copy all characters until the equals to sign. - This will probably be the name of the argument */ - if((longarg = REALLOC(longarg, strcspn(argv[getOptPos],"=")+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(longarg, '\0', strcspn(argv[getOptPos],"=")+1); - memcpy(longarg, &argv[getOptPos][0], strcspn(argv[getOptPos],"=")); - - /* Then copy everything after the equals sign. - This will probably be the value of the argument */ - size_t i = strlen(&argv[getOptPos][strcspn(argv[getOptPos],"=")+1]); - if((*optarg = REALLOC(*optarg, i+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(*optarg, '\0', i+1); - memcpy(*optarg, &argv[getOptPos][strcspn(argv[getOptPos],"=")+1], i); - } else { - /* If the argument does not contain a equals sign. - Store the argument to check later if it's a long argument */ - if((longarg = REALLOC(longarg, strlen(argv[getOptPos])+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(longarg, argv[getOptPos]); - } - - /* A short argument only contains of two characters. - So only store the first two characters */ - if((shortarg = REALLOC(shortarg, strlen(argv[getOptPos])+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(shortarg, '\0', 3); - strncpy(shortarg, argv[getOptPos], 2); - - /* Check if the short argument and the long argument are equal, - then we probably encountered a short argument. Only store the - identifier character. If there are more CLI characters - after the current one, store it as the CLI value. However, only - do this if the first character of the argument doesn't contain*/ - if(strcmp(longarg, shortarg) == 0 && (getOptPos+1) 0) { - if(error_check == 1) { - if(strcmp(longarg,shortarg) == 0) { - if(shortarg[0] == '-') { - logprintf(LOG_ERR, "invalid option -- '-%c'", c); - } else { - logprintf(LOG_ERR, "invalid option -- '%s'", longarg); - } - } else { - logprintf(LOG_ERR, "invalid option -- '%s'", longarg); - } - goto gc; - } else { - return 0; - } - /* Check if an argument cannot have an argument that was set */ - } else if(strlen(*optarg) != 0 && options_get_argtype(opt, c, &itmp) == 0 && itmp == 1) { - if(error_check == 1) { - if(strcmp(longarg,shortarg) == 0) { - logprintf(LOG_ERR, "option '-%c' doesn't take an argument", c); - } else { - logprintf(LOG_ERR, "option '%s' doesn't take an argument", longarg); - } - goto gc; - } else { - return 0; - } - /* Check if an argument required a value that wasn't set */ - } else if(strlen(*optarg) == 0 && options_get_argtype(opt, c, &itmp) == 0 && itmp == 2) { - if(error_check == 1) { - if(strcmp(longarg, shortarg) == 0) { - logprintf(LOG_ERR, "option '-%c' requires an argument", c); - } else { - logprintf(LOG_ERR, "option '%s' requires an argument", longarg); - } - goto gc; - } else { - return 0; - } - /* Check if we have a valid argument */ - } else if(c == 0) { - if(error_check == 1) { - if(shortarg[0] == '-' && strstr(shortarg, longarg) != 0) { - logprintf(LOG_ERR, "invalid option -- '-%c'", c); - } else { - logprintf(LOG_ERR, "invalid option -- '%s'", longarg); - } - goto gc; - } else { - return 0; - } - } else { - /* If the argument didn't have a value, set it to 1 */ - if(strlen(*optarg) == 0) { - options_set_string(opt, c, "1"); - } else { -#if !defined(__FreeBSD__) && !defined(_WIN32) - if(error_check != 2) { - /* If the argument has a regex mask, check if it passes */ - if(options_get_mask(opt, c, &mask) == 0) { - reti = regcomp(®ex, mask, REG_EXTENDED); - if(reti) { - logprintf(LOG_ERR, "could not compile regex"); - goto gc; - } - reti = regexec(®ex, *optarg, 0, NULL, 0); - if(reti == REG_NOMATCH || reti != 0) { - if(error_check == 1) { - if(shortarg[0] == '-') { - logprintf(LOG_ERR, "invalid format -- '-%c'", c); - } else { - logprintf(LOG_ERR, "invalid format -- '%s'", longarg); - } - logprintf(LOG_ERR, "requires %s", mask); - } - regfree(®ex); - goto gc; - } - regfree(®ex); - } - } -#endif - options_set_string(opt, c, *optarg); - } - return c; - } - } - -gc: - getOptPos=0; - FREE(*optarg); - - return -2; -} - -/* Add a new option to the options struct */ -void options_add(struct options_t **opt, int id, const char *name, int argtype, int conftype, int vartype, void *def, const char *mask) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - char *ctmp = NULL; - char *nname = MALLOC(strlen(name)+1); - int sid = 0; - if(!nname) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(nname, name); - int itmp = 0; - if(!(argtype >= 0 && argtype <= 3)) { - logprintf(LOG_CRIT, "tying to add an invalid option type"); - FREE(nname); - exit(EXIT_FAILURE); - } else if(!(conftype >= 0 && conftype <= NROPTIONTYPES)) { - logprintf(LOG_CRIT, "trying to add an option of an invalid type"); - FREE(nname); - exit(EXIT_FAILURE); - } else if(!name) { - logprintf(LOG_CRIT, "trying to add an option without name"); - FREE(nname); - exit(EXIT_FAILURE); - } else if(id != 0 && options_get_name(opt, id, &ctmp) == 0) { - logprintf(LOG_CRIT, "duplicate option id: %c", id); - FREE(nname); - exit(EXIT_FAILURE); - } else if(options_get_id(opt, nname, &sid) == 0 && - ((options_get_conftype(opt, sid, &itmp) == 0 && itmp == conftype) || - (options_get_conftype(opt, sid, &itmp) != 0))) { - logprintf(LOG_CRIT, "duplicate option name: %s", name); - FREE(nname); - exit(EXIT_FAILURE); - } else { - struct options_t *optnode = MALLOC(sizeof(struct options_t)); - if(!optnode) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - optnode->id = id; - if((optnode->name = MALLOC(strlen(name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(optnode->name, name); - optnode->argtype = argtype; - optnode->conftype = conftype; - optnode->vartype = vartype; - optnode->def = def; - optnode->string_ = NULL; - if(mask) { - if((optnode->mask = MALLOC(strlen(mask)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(optnode->mask, mask); - } else { - optnode->mask = NULL; - } - optnode->next = *opt; - *opt = optnode; - FREE(nname); - } -} - -/* Merge two options structs */ -void options_merge(struct options_t **a, struct options_t **b) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *temp = NULL; - temp = *b; - while(temp) { - struct options_t *optnode = MALLOC(sizeof(struct options_t)); - if(!optnode) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - optnode->id = temp->id; - if(temp->name) { - if((optnode->name = MALLOC(strlen(temp->name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(optnode->name, '\0', strlen(temp->name)+1); - strcpy(optnode->name, temp->name); - } else { - optnode->name = NULL; - } - if(temp->string_) { - if((optnode->string_ = MALLOC(strlen(temp->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - optnode->vartype = JSON_STRING; - strcpy(optnode->string_, temp->string_); - } else { - optnode->string_ = NULL; - } - if(temp->mask) { - if((optnode->mask = MALLOC(strlen(temp->mask)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(optnode->mask, temp->mask); - } else { - optnode->mask = NULL; - } - optnode->argtype = temp->argtype; - optnode->conftype = temp->conftype; - optnode->vartype = temp->vartype; - optnode->def = temp->def; - optnode->next = *a; - *a = optnode; - temp = temp->next; - } -} - -void options_delete(struct options_t *options) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct options_t *tmp; - while(options) { - tmp = options; - if(tmp->mask) { - FREE(tmp->mask); - } - if(tmp->vartype == JSON_STRING && tmp->string_) { - FREE(tmp->string_); - } - FREE(tmp->name); - options = options->next; - FREE(tmp); - } - if(options != NULL) { - FREE(options); - } - - logprintf(LOG_DEBUG, "freed options struct"); -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/options.h b/lib/ESPiLight/pilight/libs/pilight/core/options.h deleted file mode 100644 index ce67744..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/options.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _OPTIONS_H_ -#define _OPTIONS_H_ - -#define OPTION_NO_VALUE 1 -#define OPTION_HAS_VALUE 2 -#define OPTION_OPT_VALUE 3 - -#define DEVICES_ID 1 -#define DEVICES_STATE 2 -#define DEVICES_VALUE 3 -#define DEVICES_SETTING 4 -#define DEVICES_OPTIONAL 5 -#define GUI_SETTING 6 -#define NROPTIONTYPES 6 - - -typedef struct options_t { - int id; - char *name; - union { - char *string_; - double number_; - }; - char *mask; - void *def; - int argtype; - int conftype; - int vartype; - struct options_t *next; -} options_t; - -int options_gc(void); -void options_set_string(struct options_t **options, int id, const char *val); -void options_set_number(struct options_t **options, int id, double val); -int options_get_string(struct options_t **options, int id, char **out); -int options_get_number(struct options_t **options, int id, double *out); -int options_get_argtype(struct options_t **options, int id, int *out); -int options_get_name(struct options_t **options, int id, char **out); -int options_get_id(struct options_t **options, char *name, int *out); -int options_get_mask(struct options_t **options, int id, char **out); -int options_parse(struct options_t **options, int argc, char **argv, int error_check, char **optarg); -void options_add(struct options_t **options, int id, const char *name, int argtype, int conftype, int vartype, void *def, const char *mask); -void options_merge(struct options_t **a, struct options_t **b); -void options_delete(struct options_t *options); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/pilight.c b/lib/ESPiLight/pilight/libs/pilight/core/pilight.c deleted file mode 100644 index 56f4918..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/pilight.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include "pilight.h" - -struct pilight_t pilight; -char pilight_uuid[UUID_LENGTH]; -const uv_thread_t pth_main_id; diff --git a/lib/ESPiLight/pilight/libs/pilight/core/pilight.h b/lib/ESPiLight/pilight/libs/pilight/core/pilight.h deleted file mode 100644 index 2553350..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/pilight.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _PILIGHT_H_ -#define _PILIGHT_H_ - -typedef enum runmode_t { - STANDALONE, - ADHOC -} runmode_t; - -typedef enum process_t { - PROCESS_DAEMON, - PROCESS_CLIENT -} process_t; - -#ifdef PILIGHT_REWRITE -typedef enum origin_t { - ORIGIN_RECEIVER = 0, - ORIGIN_SENDER, - ORIGIN_CONTROLLER, - ORIGIN_MASTER, - ORIGIN_NODE, - ORIGIN_FW, - ORIGIN_STATS, - ORIGIN_ACTION, - ORIGIN_RULE, - ORIGIN_PROTOCOL, - ORIGIN_HARDWARE, - ORIGIN_CONFIG, - ORIGIN_WEBSERVER, - ORIGIN_SSDP, - ORIGIN_ADHOC -} origin_t; -#else -typedef enum origin_t { - RECEIVER = 0, - SENDER, - MASTER, - NODE, - FW, - STATS, - ACTION, - RULE, - PROTOCOL, - HARDWARE -} origin_t; - -#define ORIGIN_WEBSERVER 12 -#define ORIGIN_SENDER 1 -#define ORIGIN_MASTER 1 - -#endif - -#include "../../libuv/uv.h" - -#include "defines.h" -#include "eventpool.h" -#include "json.h" -#include "mem.h" - -#ifdef PILIGHT_REWRITE -#include "../storage/storage.h" -#else -#include "../config/devices.h" -#endif - -#include -#include -#include -#if MBEDTLS_VERSION_MAJOR <= 2 && \ - MBEDTLS_VERSION_MINOR <= 3 - #include -#else - #include -#endif -#include -#include -#include -#include -#include - -mbedtls_entropy_context ssl_entropy; -mbedtls_ctr_drbg_context ssl_ctr_drbg; -mbedtls_pk_context ssl_pk_key; -mbedtls_x509_crt ssl_server_crt; -mbedtls_ssl_cache_context ssl_cache; -struct mbedtls_ssl_config ssl_client_conf; -struct mbedtls_ssl_config ssl_server_conf; - -struct pilight_t { - // void (*broadcast)(char *name, struct JsonNode *message, enum origin_t origin); -#ifdef PILIGHT_REWRITE - int (*send)(JsonNode *, enum origin_t); - int (*control)(char *, char *, struct JsonNode *, enum origin_t); - void (*receive)(struct JsonNode *, int); - int (*socket)(char *, char *, char **); -#else - void (*broadcast)(char *name, JsonNode *message, enum origin_t origin); - int (*send)(JsonNode *json, enum origin_t origin); - int (*control)(struct devices_t *dev, char *state, JsonNode *values, enum origin_t origin); - void (*receive)(struct JsonNode *code, int hwtype); -#endif - - runmode_t runmode; - /* pilight actually runs in this stage and the configuration is fully validated */ - int running; - int debuglevel; - process_t process; -} pilight_t; - -extern struct pilight_t pilight; -extern const uv_thread_t pth_main_id; -extern char pilight_uuid[UUID_LENGTH]; - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/ping.c b/lib/ESPiLight/pilight/libs/pilight/core/ping.c deleted file mode 100644 index ee2b5de..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/ping.c +++ /dev/null @@ -1,331 +0,0 @@ -/* - * icmpquery.c - send and receive ICMP queries for address mask - * and current time. - * - * Version 1.0.3 - * - * Copyright 1998, 1999, 2000 David G. Andersen - * - * http://www.angio.net/ - * - * All rights reserved. - * This information is subject to change without notice and does not - * represent a commitment on the part of David G. Andersen. - * - * 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. The name of David G. Andersen may not - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 DAVID G. ANDERSEN 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. - * - * - * - * Verified to work on: - * FreeBSD (2.x, 3.x) - * Linux 2.0.x, 2.2.0-pre1 - * NetBSD 1.3 - * - * Should work on Solaris and other platforms with BSD-ish stacks. - * - * If you compile it somewhere else, or it doesn't work somewhere, - * please let me know. - * - * Compilation: gcc icmpquery.c -o icmpquery - * - * One usage note: In order to receive accurate time information, - * the time on your computer must be correct; the - * ICMP timestamp reply is a relative time figure. - */ - - -/* Some portions of this code are taken from FreeBSD's ping source. - * Those portions are subject to the BSD copyright, which is appended - * at the end of this file. Namely, in_cksum. - */ - -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN - #include - #include - #include - #define MSG_NOSIGNAL 0 -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#endif -#include -#include -#include - -#include "common.h" -#include "network.h" -#include "log.h" -#include "mem.h" - -#ifdef _WIN32 - typedef unsigned char u_int8_t; - typedef unsigned short u_int16_t; - typedef unsigned int u_int32_t; - - #define ICMP_ECHO 8 - #define ICMP_ECHOREPLY 0 - - struct icmp_ra_addr { - u_int32_t ira_addr; - u_int32_t ira_preference; - }; - - struct ip { - u_char ip_hl:4, /* header length */ - ip_v:4; /* version */ - u_char ip_tos; /* type of service */ - short ip_len; /* total length */ - u_short ip_id; /* identification */ - short ip_off; /* fragment offset field */ - #define IP_DF 0x4000 /* dont fragment flag */ - #define IP_MF 0x2000 /* more fragments flag */ - u_char ip_ttl; /* time to live */ - u_char ip_p; /* protocol */ - u_short ip_sum; /* checksum */ - struct in_addr ip_src,ip_dst; /* source and dest address */ - }; - - struct icmp - { - u_int8_t icmp_type; /* type of message, see below */ - u_int8_t icmp_code; /* type sub code */ - u_int16_t icmp_cksum; /* ones complement checksum of struct */ - union - { - u_char ih_pptr; /* ICMP_PARAMPROB */ - struct in_addr ih_gwaddr; /* gateway address */ - struct ih_idseq /* echo datagram */ - { - u_int16_t icd_id; - u_int16_t icd_seq; - } ih_idseq; - u_int32_t ih_void; - - /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ - struct ih_pmtu - { - u_int16_t ipm_void; - u_int16_t ipm_nextmtu; - } ih_pmtu; - - struct ih_rtradv - { - u_int8_t irt_num_addrs; - u_int8_t irt_wpa; - u_int16_t irt_lifetime; - } ih_rtradv; - } icmp_hun; - #define icmp_pptr icmp_hun.ih_pptr - #define icmp_gwaddr icmp_hun.ih_gwaddr - #define icmp_id icmp_hun.ih_idseq.icd_id - #define icmp_seq icmp_hun.ih_idseq.icd_seq - #define icmp_void icmp_hun.ih_void - #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void - #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu - #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs - #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa - #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime - union - { - struct - { - u_int32_t its_otime; - u_int32_t its_rtime; - u_int32_t its_ttime; - } id_ts; - struct - { - struct ip idi_ip; - /* options and then 64 bits of data */ - } id_ip; - struct icmp_ra_addr id_radv; - u_int32_t id_mask; - u_int8_t id_data[1]; - } icmp_dun; - #define icmp_otime icmp_dun.id_ts.its_otime - #define icmp_rtime icmp_dun.id_ts.its_rtime - #define icmp_ttime icmp_dun.id_ts.its_ttime - #define icmp_ip icmp_dun.id_ip.idi_ip - #define icmp_radv icmp_dun.id_radv - #define icmp_mask icmp_dun.id_mask - #define icmp_data icmp_dun.id_data - }; -#endif - -/* - * in_cksum -- - * Checksum routine for Internet Protocol family headers (C Version) - * From FreeBSD's ping.c - */ -static int in_cksum(int *addr, int len) { - register int nleft = len; - register int *w = addr; - register int sum = 0; - int answer = 0; - - /* - * Our algorithm is simple, using a 32 bit accumulator (sum), we add - * sequential 16 bit words to it, and at the end, fold back all the - * carry bits from the top 16 bits into the lower 16 bits. - */ - while(nleft > 1) { - sum += *w++; - nleft -= 2; - } - - /* mop up an odd byte, if necessary */ - if(nleft == 1) { - *(u_char *)(&answer) = *(u_char *)w ; - sum += answer; - } - - /* add back carry outs from top 16 bits to low 16 bits */ - sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ - sum += (sum >> 16); /* add carry */ - answer = ~sum; /* truncate to 16 bits */ - return answer; -} - -static int initpacket(char *buf) { - struct ip *ip = (struct ip *)buf; - struct icmp *icmp = (struct icmp *)(ip + 1); - int icmplen = 20; - struct in_addr fromaddr; - fromaddr.s_addr = 0; - - ip->ip_src = fromaddr; - ip->ip_v = 4; - ip->ip_hl = sizeof *ip >> 2; - ip->ip_tos = 0; - ip->ip_id = htons(4321); - ip->ip_ttl = 255; - ip->ip_p = 1; - ip->ip_sum = 0; - - icmp->icmp_seq = 1; - icmp->icmp_cksum = 0; - icmp->icmp_type = ICMP_ECHO; - icmp->icmp_code = 0; - - gettimeofday((struct timeval *)(icmp+8), NULL); - memset(icmp+12, '\0', 8); - ip->ip_len = sizeof(struct ip) + icmplen; - return icmplen; -} - -int ping(char *addr) { - char buf[1500], buf1[INET_ADDRSTRLEN+1]; - struct ip *ip = (struct ip *)buf; - struct icmp *icmp = (struct icmp *)(ip + 1); - struct sockaddr_in dst; - int icmplen = 0; - int sockfd = 0, on = 1; - long int fromlen = 0; - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "could not initialize new socket"); - exit(EXIT_FAILURE); - } -#endif - - if((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) { - logperror(LOG_DEBUG, "socket"); - return -1; - } - - if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, (const char *)&on, sizeof(on)) < 0) { - logperror(LOG_DEBUG, "IP_HDRINCL"); - close(sockfd); - return -1; - } - -#ifndef _WIN32 - struct timeval tv; - tv.tv_sec = 1; - tv.tv_usec = 0; - - if(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)) < 0) { -#else - int timeout = 1000; - if(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(struct timeval)) < 0) { -#endif - logperror(LOG_DEBUG, "SO_RCVTIMEO"); - close(sockfd); - return -1; - } - - memset(buf, '\0', 1500); - icmplen = initpacket(buf); - dst.sin_family = AF_INET; - - ip->ip_dst.s_addr = inet_addr(addr); - dst.sin_addr.s_addr = inet_addr(addr); - dst.sin_port = htons(0); - icmp->icmp_cksum = 0; - icmp->icmp_cksum = in_cksum((int *)icmp, icmplen); - if(sendto(sockfd, buf, ip->ip_len, 0, (struct sockaddr *)&dst, sizeof(dst)) < 0) { - logperror(LOG_DEBUG, "sendto"); - close(sockfd); - return -1; - } - - memset(buf, '\0', sizeof(buf)); - if((recvfrom(sockfd, buf, sizeof(buf), 0, NULL, (socklen_t *)&fromlen)) < 0) { - logperror(LOG_DEBUG, "recvfrom"); - close(sockfd); - return -1; - } - - icmp = (struct icmp *)(buf + (ip->ip_hl << 2)); - memset(&buf1, '\0', INET_ADDRSTRLEN+1); - inet_ntop(AF_INET, (void *)&(ip->ip_src), buf1, INET_ADDRSTRLEN+1); - if(!((icmp->icmp_type == ICMP_ECHOREPLY || icmp->icmp_type == ICMP_ECHO) && strcmp(buf1, addr) == 0)) { - logprintf(LOG_DEBUG, "unexpected status reply: %d code: %d at: %s from: %s",icmp->icmp_type, icmp->icmp_code, buf1, addr); - close(sockfd); - return -1; - } - - close(sockfd); - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/ping.h b/lib/ESPiLight/pilight/libs/pilight/core/ping.h deleted file mode 100644 index 6e7cc6b..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/ping.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * icmpquery.c - send and receive ICMP queries for address mask - * and current time. - * - * Version 1.0.3 - * - * Copyright 1998, 1999, 2000 David G. Andersen - * - * http://www.angio.net/ - * - * All rights reserved. - * This information is subject to change without notice and does not - * represent a commitment on the part of David G. Andersen. - * - * 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. The name of David G. Andersen may not - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 DAVID G. ANDERSEN 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. - * - * - * - * Verified to work on: - * FreeBSD (2.x, 3.x) - * Linux 2.0.x, 2.2.0-pre1 - * NetBSD 1.3 - * - * Should work on Solaris and other platforms with BSD-ish stacks. - * - * If you compile it somewhere else, or it doesn't work somewhere, - * please let me know. - * - * Compilation: gcc icmpquery.c -o icmpquery - * - * One usage note: In order to receive accurate time information, - * the time on your computer must be correct; the - * ICMP timestamp reply is a relative time figure. - */ - - -/* Some portions of this code are taken from FreeBSD's ping source. - * Those portions are subject to the BSD copyright, which is appended - * at the end of this file. Namely, in_cksum. - */ - -#ifndef _LIBPROC_H_ -#define _LIBPROC_H_ - -int ping(char *addr); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/proc.c b/lib/ESPiLight/pilight/libs/pilight/core/proc.c deleted file mode 100644 index 34fdd56..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/proc.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifdef __FreeBSD__ - #define _WITH_GETLINE -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #include -#endif -#include -#include -#include - -#include "proc.h" -#include "log.h" -#include "mem.h" - -/* RAM usage */ -#ifndef _WIN32 - static unsigned long totalram = 0; -#endif -static unsigned short initialized = 0; - -/* Mounting proc subsystem */ -#ifdef __FreeBSD__ - static unsigned short mountproc = 1; -#endif - -double getCPUUsage(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - static struct cpu_usage_t cpu_usage; - if(!initialized) { - memset(&cpu_usage, '\0', sizeof(struct cpu_usage_t)); - cpu_usage.cpu_old = 0; - cpu_usage.cpu_per = 0; - cpu_usage.cpu_new = 0; - cpu_usage.sec_start = 0; - cpu_usage.sec_stop = 0; - cpu_usage.sec_diff = 0; - memset(&cpu_usage.ts, '\0', sizeof(struct timespec)); - cpu_usage.starts = 0; - initialized = 1; - } -#ifdef _WIN32 - FILETIME createTime; - FILETIME exitTime; - FILETIME kernelTime; - FILETIME userTime; - if(GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime) != -1) { - SYSTEMTIME userSystemTime; - if(FileTimeToSystemTime(&userTime, &userSystemTime) != -1) { - cpu_usage.cpu_new = ((double)userSystemTime.wHour * 3600.0 + (double)userSystemTime.wMinute * 60.0 + - (double)userSystemTime.wSecond + (double)userSystemTime.wMilliseconds / 1000.0); - double a = (cpu_usage.cpu_new - cpu_usage.cpu_old); - cpu_usage.cpu_old = cpu_usage.cpu_new; - return a; - } - } - return 0.0; -#else - clock_gettime(CLOCK_REALTIME, &cpu_usage.ts); - cpu_usage.sec_stop = cpu_usage.ts.tv_sec + cpu_usage.ts.tv_nsec / 1e9; - - cpu_usage.sec_diff = cpu_usage.sec_stop - cpu_usage.sec_start; - - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cpu_usage.ts); - cpu_usage.cpu_new = (cpu_usage.ts.tv_sec + (cpu_usage.ts.tv_nsec / 1e9)); - double a = ((cpu_usage.cpu_new-cpu_usage.cpu_old) / cpu_usage.sec_diff * 100.0); - cpu_usage.cpu_old = cpu_usage.cpu_new; - - clock_gettime(CLOCK_REALTIME, &cpu_usage.ts); - cpu_usage.sec_start = cpu_usage.ts.tv_sec + cpu_usage.ts.tv_nsec / 1e9; - - return a; -#endif -} - -void getThreadCPUUsage(pthread_t pth, struct cpu_usage_t *cpu_usage) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); -#ifdef _WIN32 - FILETIME createTime; - FILETIME exitTime; - FILETIME kernelTime; - FILETIME userTime; - if(GetThreadTimes(pthread_gethandle(pth), &createTime, &exitTime, &kernelTime, &userTime) != -1) { - SYSTEMTIME userSystemTime; - if(FileTimeToSystemTime(&userTime, &userSystemTime) != -1) { - cpu_usage->cpu_new = ((double)userSystemTime.wHour * 3600.0 + (double)userSystemTime.wMinute * 60.0 + - (double)userSystemTime.wSecond + (double)userSystemTime.wMilliseconds / 1000.0); - if(cpu_usage->cpu_per > 100) { - cpu_usage->cpu_per = (cpu_usage->cpu_new - cpu_usage->cpu_old); - } - cpu_usage->cpu_old = cpu_usage->cpu_new; - } - } - cpu_usage->cpu_per = 0; -#else - clockid_t cid; - memset(&cid, '\0', sizeof(cid)); - - clock_gettime(CLOCK_REALTIME, &cpu_usage->ts); - cpu_usage->sec_stop = cpu_usage->ts.tv_sec + cpu_usage->ts.tv_nsec / 1e9; - - cpu_usage->sec_diff = cpu_usage->sec_stop - cpu_usage->sec_start; - - pthread_getcpuclockid(pth, &cid); - clock_gettime(cid, &cpu_usage->ts); - - cpu_usage->cpu_new = (cpu_usage->ts.tv_sec + (cpu_usage->ts.tv_nsec / 1e9)); - cpu_usage->cpu_per = ((cpu_usage->cpu_new-cpu_usage->cpu_old) / cpu_usage->sec_diff * 100.0); - if(cpu_usage->cpu_per > 100) { - cpu_usage->cpu_per = 0; - } - cpu_usage->cpu_old = cpu_usage->cpu_new; - - clock_gettime(CLOCK_REALTIME, &cpu_usage->ts); - cpu_usage->sec_start = cpu_usage->ts.tv_sec + cpu_usage->ts.tv_nsec / 1e9; -#endif -} - -double getRAMUsage(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - -#ifndef _WIN32 - #if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) - if(totalram == 0) { - totalram = (size_t)sysconf(_SC_PHYS_PAGES)*(size_t)sysconf(_SC_PAGESIZE); - } - #endif - - #ifdef __FreeBSD__ - static char statusfile[] = "/compat/proc/self/status"; - static char memfile[] = "/compat/proc/meminfo"; - #else - static char statusfile[] = "/proc/self/status"; - static char memfile[] = "/proc/meminfo"; - #endif - unsigned long VmRSS = 0, value = 0, total = 0; - size_t len = 0; - ssize_t rd = 0; - char units[32], title[32], *line = NULL; - FILE *fp = NULL; - - memset(title, '\0', 32); - memset(units, '\0', 32); - - if((fp = fopen(statusfile, "r")) != NULL) { - while((rd = getline(&line, &len, fp)) != -1) { - if(strstr(line, "VmRSS:") != NULL) { - if(sscanf(line, "%31s %lu %s\n", title, &value, units) > 0) { - VmRSS = value * 1024; - } - if(line != NULL) { - free(line); - line = NULL; - } - break; - } - } - if(line != NULL) { - free(line); - line = NULL; - } - fclose(fp); - } - #ifdef __FreeBSD__ - if(mountproc == 1) { - DIR* dir; - if(!(dir = opendir("/compat"))) { - mkdir("/compat", 0755); - } else { - closedir(dir); - } - if(!(dir = opendir("/compat/proc"))) { - mkdir("/compat/proc", 0755); - } else { - closedir(dir); - } - if(!(dir = opendir("/compat/proc/self"))) { - system("mount -t linprocfs none /compat/proc 2>/dev/null 1>/dev/null"); - mountproc = 0; - } else { - closedir(dir); - } - } - #endif - - if((fp = fopen(memfile, "r")) != NULL) { - while((rd = getline(&line, &len, fp)) != -1) { - if(strstr(line, "MemTotal:") != NULL) { - if(sscanf(line, "%31s %lu %s\n", title, &value, units) > 0) { - total = value * 1024; - } - if(line != NULL) { - free(line); - line = NULL; - } - break; - } - } - if(line != NULL) { - free(line); - line = NULL; - } - fclose(fp); - } - if(VmRSS > 0 && total > 0) { - return ((double)VmRSS*100)/(double)total; - } else { - return 0.0; - } -#else - return 0.0; -#endif -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/proc.h b/lib/ESPiLight/pilight/libs/pilight/core/proc.h deleted file mode 100644 index eb2e51f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/proc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROC_H_ -#define _PROC_H_ - -#include - -/* CPU usage */ -typedef struct cpu_usage_t { - double sec_start; - double sec_stop; - double sec_diff; - double cpu_old; - double cpu_new; - double cpu_per; - struct timespec ts; - clock_t starts; -} cpu_usage_t; - -double getCPUUsage(void); -double getRAMUsage(void); -void getThreadCPUUsage(pthread_t pth, struct cpu_usage_t *cpu_usage); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/sha256cache.c b/lib/ESPiLight/pilight/libs/pilight/core/sha256cache.c deleted file mode 100644 index 9341ea9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/sha256cache.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include - -#include "sha256cache.h" -#include "common.h" -#include "mem.h" -#include "log.h" -#include "gc.h" - -int sha256cache_gc(void) { - struct sha256cache_t *tmp = sha256cache; - while(sha256cache) { - tmp = sha256cache; - FREE(tmp->name); - sha256cache = sha256cache->next; - FREE(tmp); - } - if(sha256cache != NULL) { - FREE(sha256cache); - } - - logprintf(LOG_DEBUG, "garbage collected sha256cache library"); - return 1; -} - -void sha256cache_remove_node(struct sha256cache_t **cache, char *name) { - struct sha256cache_t *currP, *prevP; - - prevP = NULL; - - for(currP = *cache; currP != NULL; prevP = currP, currP = currP->next) { - - if(strcmp(currP->name, name) == 0) { - if(prevP == NULL) { - *cache = currP->next; - } else { - prevP->next = currP->next; - } - - FREE(currP->name); - FREE(currP); - - break; - } - } -} - -int sha256cache_rm(char *name) { - sha256cache_remove_node(&sha256cache, name); - - logprintf(LOG_DEBUG, "removed %s from cache", name); - return 0; -} - -int sha256cache_add(char *name) { - logprintf(LOG_INFO, "cached new sha256 hash"); - - unsigned char output[33]; - char *password = NULL; - int i = 0, x = 0, len = 65; - mbedtls_sha256_context ctx; - - if(strlen(name) < 64) { - len = 65; - } else { - len = strlen(name)+1; - } - - if((password = MALLOC(len)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strncpy(password, name, len); - - struct sha256cache_t *node = MALLOC(sizeof(struct sha256cache_t)); - if(node == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - if((node->name = MALLOC(strlen(name)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->name, name); - - for(i=0;ihash[i], "%02x", output[i/2]); - } - - node->next = sha256cache; - sha256cache = node; - FREE(password); - return 0; -} - -char *sha256cache_get_hash(char *name) { - struct sha256cache_t *ftmp = sha256cache; - while(ftmp) { - if(strcmp(ftmp->name, name) == 0) { - return ftmp->hash; - } - ftmp = ftmp->next; - } - return NULL; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/sha256cache.h b/lib/ESPiLight/pilight/libs/pilight/core/sha256cache.h deleted file mode 100644 index 39da55d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/sha256cache.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include - -typedef struct sha256cache_t { - char *name; - char hash[65]; - struct sha256cache_t *next; -} sha256cache_t; - -struct sha256cache_t *sha256cache; - -int sha256cache_gc(void); -void sha256cache_remove_node(struct sha256cache_t **sha256cache, char *name); -int sha256cache_rm(char *name); -int sha256cache_add(char *name); -char *sha256cache_get_hash(char *name); diff --git a/lib/ESPiLight/pilight/libs/pilight/core/socket.c b/lib/ESPiLight/pilight/libs/pilight/core/socket.c deleted file mode 100644 index 4035bd5..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/socket.c +++ /dev/null @@ -1,646 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #if _WIN32_WINNT < 0x0501 - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #include - #include - #define MSG_NOSIGNAL 0 - #ifndef EINPROGRESS - #define EINPROGRESS WSAEINPROGRESS - #endif -#else - #include - #include - #include - #include - #include - #include -#endif - -#include "pilight.h" -#include "network.h" -#include "log.h" -#include "gc.h" -#include "socket.h" -#include "../config/settings.h" - -static char recvBuff[BUFFER_SIZE]; -static char *waitMessage = NULL; -static unsigned short socket_loop = 1; -static unsigned int socket_port = 0; -static int socket_loopback = 0; -static int socket_server = 0; -static int socket_clients[MAX_CLIENTS]; - -int socket_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int x = 0; - - socket_loop = 0; - /* Wakeup all our select statement so the socket_wait and - socket_read functions can actually close and the - all threads using sockets can end gracefully */ - - for(x=1;x 0) { - send(socket_clients[x], "1", 1, MSG_NOSIGNAL); - } - } - - if(socket_loopback > 0) { - send(socket_loopback, "1", 1, MSG_NOSIGNAL); - socket_close(socket_loopback); - } - - if(waitMessage != NULL) { - FREE(waitMessage); - } - - logprintf(LOG_DEBUG, "garbage collected socket library"); - return EXIT_SUCCESS; -} - -/* Start the socket server */ -int socket_start(unsigned short port) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr_in address; - int addrlen = sizeof(address); - int opt = 1; - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "could not initialize new socket"); - exit(EXIT_FAILURE); - } -#endif - - memset(&address, '\0', sizeof(struct sockaddr_in)); - memset(socket_clients, 0, sizeof(socket_clients)); - - //create a master socket - if((socket_server = socket(AF_INET, SOCK_STREAM, 0)) == 0) { - logprintf(LOG_ERR, "could not create new socket"); - exit(EXIT_FAILURE); - } - - //set master socket to allow multiple connections , this is just a good habit, it will work without this - if(setsockopt(socket_server, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0 ) { - logprintf(LOG_ERR, "could not set proper socket options"); - exit(EXIT_FAILURE); - } - - //type of socket created - address.sin_family = AF_INET; - address.sin_addr.s_addr = INADDR_ANY; - if(port <= 0) { - address.sin_port = 0; - } else { - address.sin_port = htons(port); - } - - //bind the socket to localhost - if(bind(socket_server, (struct sockaddr *)&address, sizeof(address)) < 0) { - logprintf(LOG_ERR, "cannot bind to socket port %d, address already in use?", address); - exit(EXIT_FAILURE); - } - - int x = 0; - //try to specify maximum of 3 pending connections for the master socket - if((x = listen(socket_server, 3)) < 0) { - logprintf(LOG_ERR, "failed to listen to socket"); - exit(EXIT_FAILURE); - } - - static struct linger linger = { 0, 0 }; -#ifdef _WIN32 - unsigned int lsize = sizeof(struct linger); -#else - socklen_t lsize = sizeof(struct linger); -#endif - setsockopt(socket_server, SOL_SOCKET, SO_LINGER, (void *)&linger, lsize); - - if(getsockname(socket_server, (struct sockaddr *)&address, (socklen_t *)&addrlen) == -1) - perror("getsockname"); - else - socket_port = ntohs(address.sin_port); - - /* Make a loopback socket we can close when pilight needs to be stopped - or else the select statement will wait forever for an activity */ - char localhost[16] = "127.0.0.1"; - socket_loopback = socket_connect(localhost, (unsigned short)socket_port); - socket_clients[0] = socket_loopback; - logprintf(LOG_INFO, "daemon listening to port: %d", socket_port); - - return 0; -} - -int socket_timeout_connect(int sockfd, struct sockaddr *serv_addr, int sec) { - struct timeval tv; - fd_set fdset; - int valopt; - socklen_t lon = 0; - -#ifdef _WIN32 - unsigned long on = 1; - unsigned long off = 0; - ioctlsocket(sockfd, FIONBIO, &on); -#else - long arg = fcntl(sockfd, F_GETFL, NULL); - fcntl(sockfd, F_SETFL, arg | O_NONBLOCK); -#endif - - if(connect(sockfd, serv_addr, sizeof(struct sockaddr)) < 0) { - if(errno == EINPROGRESS) { - tv.tv_sec = sec; - tv.tv_usec = 0; - FD_ZERO(&fdset); - FD_SET(sockfd, &fdset); - if(select(sockfd+1, NULL, &fdset, NULL, &tv) > 0) { - lon = sizeof(int); - getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon); - if(valopt > 0) { - return -3; - } - } else { - return -2; - } - } else { - return -1; - } - } - -#ifdef _WIN32 - ioctlsocket(sockfd, FIONBIO, &off); -#else - arg = fcntl(sockfd, F_GETFL, NULL); - fcntl(sockfd, F_SETFL, arg & ~O_NONBLOCK); -#endif - - return 0; -} - -unsigned int socket_get_port(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - return socket_port; -} - -int socket_get_fd(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - return socket_server; -} - -int socket_get_clients(int i) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - return socket_clients[i]; -} - -int socket_connect(char *address, unsigned short port) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr_in serv_addr; - int sockfd; - fd_set fdset; - struct timeval tv; - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "could not initialize new socket"); - exit(EXIT_FAILURE); - } -#endif - - /* Try to open a new socket */ - if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - logprintf(LOG_ERR, "could not create socket"); - return -1; - } - - /* Clear the server address */ - memset(&serv_addr, '\0', sizeof(serv_addr)); - - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons(port); - inet_pton(AF_INET, address, &serv_addr.sin_addr); - - /* Connect to the server */ - if(connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != -1) { -#ifdef _WIN32 - unsigned long on = 1; - ioctlsocket(sockfd, FIONBIO, &on); -#else - fcntl(sockfd, F_SETFL, O_NONBLOCK); -#endif - - FD_ZERO(&fdset); - FD_SET((long unsigned int)sockfd, &fdset); - tv.tv_sec = 3; - tv.tv_usec = 0; - - if(select(sockfd+1, NULL, &fdset, NULL, &tv) == 1) { - int error = -1; - socklen_t len = sizeof(error); - -#ifdef _WIN32 - if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (char *)&error, &len) != SOCKET_ERROR) { - if(error == 0) { - return sockfd; - } else { - return -1; - } - } else { - return -1; - } -#else - getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len); - - if(error == 0) { - return sockfd; - } else { - close(sockfd); - return -1; - } -#endif - } else { - close(sockfd); - return -1; - } - } else { - close(sockfd); - return -1; - } -} - -void socket_close(int sockfd) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - int i = 0; - struct sockaddr_in address; - int addrlen = sizeof(address); - char buf[INET_ADDRSTRLEN+1]; - - if(sockfd > 0) { - if(getpeername(sockfd, (struct sockaddr*)&address, (socklen_t*)&addrlen) == 0) { - memset(&buf, '\0', INET_ADDRSTRLEN+1); - inet_ntop(AF_INET, (void *)&(address.sin_addr), buf, INET_ADDRSTRLEN+1); - logprintf(LOG_DEBUG, "client disconnected, ip %s, port %d", buf, ntohs(address.sin_port)); - } - - for(i=0;i 0 && sockfd > 0) { - - va_start(ap, msg); -#ifdef _WIN32 - n = _vscprintf(msg, ap); -#else - n = vsnprintf(NULL, 0, msg, ap); -#endif - if(n == -1) { - logprintf(LOG_ERR, "improperly formatted string: %s", msg); - return -1; - } - n += (int)len; - va_end(ap); - - if((sendBuff = MALLOC((size_t)n)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(sendBuff, '\0', (size_t)n); - - va_start(ap, msg); - vsprintf(sendBuff, msg, ap); - va_end(ap); - - memcpy(&sendBuff[n-len], EOSS, (size_t)len); - - while(ptr < n) { - if((n-ptr) < BUFFER_SIZE) { - x = (n-ptr); - } else { - x = BUFFER_SIZE; - } - if((bytes = (int)send(sockfd, &sendBuff[ptr], (size_t)x, MSG_NOSIGNAL)) == -1) { - /* Change the delimiter into regular newlines */ - sendBuff[n-(len-1)] = '\0'; - sendBuff[n-(len)] = '\n'; - logprintf(LOG_DEBUG, "socket write failed: %s", sendBuff); - FREE(sendBuff); - return -1; - } - ptr += bytes; - } - - if(strncmp(&sendBuff[0], "BEAT", 4) != 0) { - /* Change the delimiter into regular newlines */ - sendBuff[n-(len-1)] = '\0'; - sendBuff[n-(len)] = '\n'; - logprintf(LOG_DEBUG, "socket write succeeded: %s", sendBuff); - } - FREE(sendBuff); - } - return n; -} - -void socket_rm_client(int i, struct socket_callback_t *socket_callback) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr_in address; - int addrlen = sizeof(address); - int sd = socket_clients[i]; - char buf[INET_ADDRSTRLEN+1]; - - //Somebody disconnected, get his details and print - getpeername(sd, (struct sockaddr*)&address, (socklen_t*)&addrlen); - memset(&buf, '\0', INET_ADDRSTRLEN+1); - inet_ntop(AF_INET, (void *)&(address.sin_addr), buf, INET_ADDRSTRLEN+1); - logprintf(LOG_DEBUG, "client disconnected, ip %s, port %d", buf, ntohs(address.sin_port)); - if(socket_callback->client_disconnected_callback) - socket_callback->client_disconnected_callback(i); - //Close the socket and mark as 0 in list for reuse - shutdown(sd, 2); - close(sd); - socket_clients[i] = 0; -} - -int socket_read(int sockfd, char **message, time_t timeout) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct timeval tv; - int bytes = 0; - size_t msglen = 0; - int ptr = 0, n = 0, len = (int)strlen(EOSS); - fd_set fdsread; -#ifdef _WIN32 - unsigned long on = 1; - ioctlsocket(sockfd, FIONBIO, &on); -#else - fcntl(sockfd, F_SETFL, O_NONBLOCK); -#endif - - if(timeout > 0) { - tv.tv_sec = timeout; - tv.tv_usec = 0; - } - - while(socket_loop && sockfd > 0) { - FD_ZERO(&fdsread); - FD_SET((unsigned long)sockfd, &fdsread); - - do { - if(timeout > 0) { - n = select(sockfd+1, &fdsread, NULL, NULL, &tv); - } else { - n = select(sockfd+1, &fdsread, NULL, NULL, 0); - } - } while(n == -1 && errno == EINTR && socket_loop); - if(timeout > 0 && n == 0) { - return 1; - } - /* Immediatly stop loop if the select was waken up by the garbage collector */ - if(socket_loop == 0) { - break; - } - if(n == -1) { - return -1; - } else if(n > 0) { - if(FD_ISSET((unsigned long)sockfd, &fdsread)) { - bytes = (int)recv(sockfd, recvBuff, BUFFER_SIZE, 0); - - if(bytes <= 0) { - return -1; - } else { - ptr+=bytes; - if((*message = REALLOC(*message, (size_t)ptr+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(&(*message)[(ptr-bytes)], '\0', (size_t)bytes+1); - memcpy(&(*message)[(ptr-bytes)], recvBuff, (size_t)bytes); - msglen = strlen(*message); - } - if(*message && msglen > 0) { - /* When a stream is larger then the buffer size, it has to contain - the pilight delimiter to know when the stream ends. If the stream - is shorter then the buffer size, we know we received the full stream */ - int l = 0; - if(((l = strncmp(&(*message)[ptr-(len)], EOSS, (unsigned int)(len))) == 0) || ptr < BUFFER_SIZE) { - /* If the socket contains buffered TCP messages, separate them by - changing the delimiters into newlines */ - if(ptr > msglen) { - int i = 0; - for(i=0;i 0) - FD_SET((unsigned long)sd, &readfds); - - //highest file descriptor number, need it for the select function - if(sd > max_sd) - max_sd = sd; - } - //wait for an activity on one of the sockets, timeout is NULL, so wait indefinitely - activity = select(max_sd + 1, &readfds, NULL, NULL, NULL); - } while(activity == -1 && errno == EINTR && socket_loop); - - /* Immediatly stop loop if the select was waken up by the garbage collector */ - if(socket_loop == 0) { - break; - } - //If something happened on the master socket, then its an incoming connection - if(FD_ISSET((unsigned long)socket_get_fd(), &readfds)) { - if((socket_client = accept(socket_get_fd(), (struct sockaddr *)&address, (socklen_t *)&addrlen)) < 0) { - logprintf(LOG_ERR, "failed to accept client"); - exit(EXIT_FAILURE); - } - memset(&buf, '\0', INET_ADDRSTRLEN+1); - inet_ntop(AF_INET, (void *)&(address.sin_addr), buf, INET_ADDRSTRLEN+1); - if(whitelist_check(buf) != 0) { - logprintf(LOG_INFO, "rejected client, ip: %s, port: %d", buf, ntohs(address.sin_port)); - shutdown(socket_client, 2); - close(socket_client); - } else { - //inform user of socket number - used in send and receive commands - logprintf(LOG_INFO, "new client, ip: %s, port: %d", buf, ntohs(address.sin_port)); - logprintf(LOG_DEBUG, "client fd: %d", socket_client); - //send new connection accept message - //socket_write(socket_client, "{\"message\":\"accept connection\"}"); - - static struct linger linger = { 0, 0 }; - socklen_t lsize = sizeof(struct linger); - setsockopt(socket_client, SOL_SOCKET, SO_LINGER, (void *)&linger, lsize); -#ifdef _WIN32 - int flags = ioctlsocket(socket_client, FIONBIO, &on); -#else - int flags = fcntl(socket_client, F_GETFL, 0); -#endif - if(flags != -1) { -#ifdef _WIN32 - ioctlsocket(socket_client, FIONBIO, &on); -#else - fcntl(socket_client, F_SETFL, flags | O_NONBLOCK); -#endif - } - - //add new socket to array of sockets - for(i=0;iclient_connected_callback) - socket_callback->client_connected_callback(i); - logprintf(LOG_DEBUG, "client id: %d", i); - break; - } - } - } - } - - //else its some IO operation on some other socket :) - for(i=1;iclient_data_callback) { - size_t l = strlen(waitMessage); - if(l > 0) { - if(strstr(waitMessage, "\n") != NULL) { - char **array = NULL; - unsigned int n = explode(waitMessage, "\n", &array), q = 0; - for(q=0;qclient_data_callback(i, array[q]); - } - array_free(&array, n); - } else { - socket_callback->client_data_callback(i, waitMessage); - } - } - } - } else { - socket_rm_client(i, socket_callback); - i--; - } - } - } - } - -#ifdef _WIN32 - return 0; -#else - return NULL; -#endif -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/socket.h b/lib/ESPiLight/pilight/libs/pilight/core/socket.h deleted file mode 100644 index 7820a36..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/socket.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _SOCKETS_H_ -#define _SOCKETS_H_ - -#include - -typedef struct socket_callback_t { - void (*client_connected_callback)(int); - void (*client_disconnected_callback)(int); - void (*client_data_callback)(int, char*); -} socket_callback_t; - -/* Start the socket server */ -int socket_start(unsigned short port); -int socket_connect(char *address, unsigned short port); -int socket_timeout_connect(int sockfd, struct sockaddr *serv_addr, int usec); -void socket_close(int i); -int socket_write(int sockfd, const char *msg, ...); -int socket_read(int sockfd, char **out, time_t timeout); -void *socket_wait(void *param); -int socket_gc(void); -unsigned int socket_get_port(void); -int socket_get_fd(void); -int socket_get_clients(int i); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/ssdp.c b/lib/ESPiLight/pilight/libs/pilight/core/ssdp.c deleted file mode 100644 index 373a111..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/ssdp.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#ifdef _WIN32 - #include - #include - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include -#endif -#include -#include -#include -#include -#include - -#include "pilight.h" -#include "network.h" -#include "socket.h" -#include "log.h" -#include "gc.h" -#include "ssdp.h" - -static int ssdp_socket = 0; -static int ssdp_loop = 1; - -int ssdp_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr_in addr; - int sockfd = 0; - - ssdp_loop = 0; -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(MAKEWORD(2,2),&wsa) != 0) { - logprintf(LOG_ERR, "could not initialize new socket"); - exit(EXIT_FAILURE); - } -#endif - - /* Make a loopback socket we can close when pilight needs to be stopped - or else the select statement will wait forever for an activity */ - if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) { - /* Wakeup our recvfrom statement so the ssdp_wait function can - actually close and the thread can end gracefully */ - addr.sin_family = AF_INET; - addr.sin_port = htons(1900); - addr.sin_addr.s_addr = inet_addr("239.255.255.250"); - sendto(sockfd, "1", 1, 0, (struct sockaddr *)&addr, sizeof(addr)); - } - - logprintf(LOG_DEBUG, "garbage collected ssdp library"); - return EXIT_SUCCESS; -} - -int ssdp_start(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr_in addr; - struct ip_mreq mreq; - int opt = 1; - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(MAKEWORD(2, 2), &wsa) != 0) { - logprintf(LOG_ERR, "could not initialize new socket"); - exit(EXIT_FAILURE); - } -#endif - - if((ssdp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - logprintf(LOG_ERR, "could not create ssdp socket"); - return -1; - } - - memset((char *)&addr, '\0', sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = htonl(INADDR_ANY); - addr.sin_port = htons(1900); - - if(setsockopt(ssdp_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int)) == -1) { - perror("setsockopt"); - return 0; - } - - mreq.imr_multiaddr.s_addr = inet_addr("239.255.255.250"); - mreq.imr_interface.s_addr = htonl(INADDR_ANY); - - if(setsockopt(ssdp_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq)) < 0) { - logprintf(LOG_ERR, "cannot bind to the ssdp multicast network"); - return 0; - } - - if(bind(ssdp_socket, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - perror("bind"); - return 0; - } - - return -1; -} - -int ssdp_seek(struct ssdp_list_t **ssdp_list) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct sockaddr_in addr; - char message[BUFFER_SIZE] = {'\0'}; - char header[BUFFER_SIZE] = {'\0'}; - int sock, match = 0; - int timeout = 1; - ssize_t len = 0; - socklen_t addrlen = sizeof(addr); - unsigned short int nip[4], port = 0; - -#ifndef _WIN32 - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = timeout*100000; -#else - WSADATA wsa; - - timeout *= 1000; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "could not initialize new socket"); - return -1; - } -#endif - - if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0){ - logprintf(LOG_ERR, "could not create ssdp socket"); - goto end; - } - - memset((void *)&addr, '\0', sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons(1900); - addr.sin_addr.s_addr = inet_addr("239.255.255.250"); - -#ifdef _WIN32 - setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(struct timeval)); -#else - setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)); -#endif - - strcpy(header, "M-SEARCH * HTTP/1.1\r\n" - "Host:239.255.255.250:1900\r\n" - "ST:urn:schemas-upnp-org:service:pilight:1\r\n" - "Man:\"ssdp:discover\"\r\n" - "MX:3\r\n\r\n"); - - if((len = sendto(sock, header, BUFFER_SIZE, 0, (struct sockaddr *)&addr, sizeof(addr))) >= 0) { - logprintf(LOG_DEBUG, "ssdp sent search"); - } - - int x = 0; - while(ssdp_loop) { - memset(message, '\0', BUFFER_SIZE); - if((x = recvfrom(sock, message, sizeof(message), 0, (struct sockaddr *)&addr, &addrlen)) < 1) { - //perror("read"); - goto end; - } - - if(strstr(message, "pilight") > 0) { - char **array = NULL; - unsigned int n = explode(message, "\r\n", &array), q = 0; - for(q=0;q 0) { - match = 1; - } - } - array_free(&array, n); - if(match == 1) { - struct ssdp_list_t *node = MALLOC(sizeof(struct ssdp_list_t)); - if(node == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - sprintf(node->ip, "%hu.%hu.%hu.%hu", nip[0], nip[1], nip[2], nip[3]); - node->ip[16] = '\0'; - node->port = port; - node->next = *ssdp_list; - *ssdp_list = node; - } - } - } - goto end; - -end: - if(sock > 0) { - close(sock); - } - struct ssdp_list_t *ptr = *ssdp_list, *next = NULL, *prev = NULL; - if(match == 1) { - while(ptr) { - next = ptr->next; - ptr->next = prev; - prev = ptr; - ptr = next; - } - if(ptr != NULL) { - FREE(ptr); - } - if(next != NULL) { - FREE(next); - } - *ssdp_list = prev; - - return 0; - } else { - return -1; - } -} - -void ssdp_free(struct ssdp_list_t *ssdp_list) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct ssdp_list_t *tmp = NULL; - while(ssdp_list) { - tmp = ssdp_list; - ssdp_list = ssdp_list->next; - FREE(tmp); - } - if(ssdp_list != NULL) { - FREE(ssdp_list); - } -} - -void *ssdp_wait(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct timeval tv; - struct sockaddr_in addr; - char **devs = NULL, message[BUFFER_SIZE], **header = NULL, *id = NULL; - char host[INET_ADDRSTRLEN+1], *p = host, *distro = distroname(), *hname = hostname(); - int nrdevs = 0, nrheader = 0, x = 0, n = 0; - ssize_t len = 0; - socklen_t addrlen = sizeof(addr); - fd_set fdsread; - - if(distro == NULL) { - logprintf(LOG_ERR, "failed to determine the distribution"); - exit(EXIT_FAILURE); - } - - if((nrdevs = inetdevs(&devs)) > 0) { - for(x=0;x 0) { - if(FD_ISSET(ssdp_socket, &fdsread)) { - memset(message, '\0', BUFFER_SIZE); - if(recvfrom(ssdp_socket, message, sizeof(message), 0, (struct sockaddr *)&addr, &addrlen) < 1) { - //perror("read"); - break; - } - - if(strstr(message, "M-SEARCH * HTTP/1.1") > 0 && strstr(message, "urn:schemas-upnp-org:service:pilight:1") > 0) { - for(x=0;x 0) { - if((len = sendto(ssdp_socket, header[x], BUFFER_SIZE, 0, (struct sockaddr *)&addr, sizeof(addr))) >= 0) { - logprintf(LOG_DEBUG, "ssdp sent notify"); - } - } - } - } - } - } - } - -clear: - for(x=0;x -*/ - -#ifndef _SSDP_H_ -#define _SSDP_H_ - -#ifndef _WIN32 - #include -#endif - -typedef struct ssdp_list_t { - char ip[17]; - unsigned short port; - struct ssdp_list_t *next; -} ssdp_list_t; - -int ssdp_gc(void); -int ssdp_start(void); -int ssdp_seek(struct ssdp_list_t **ssdp_list); -void ssdp_free(struct ssdp_list_t *ssdp_list); -void *ssdp_wait(void* param); -void ssdp_close(int ssdp_socket); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/ssl.c b/lib/ESPiLight/pilight/libs/pilight/core/ssl.c deleted file mode 100644 index e2a916d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/ssl.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2015 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include - -#include "pilight.h" -#include "ssl.h" -#include "mem.h" -#include "log.h" - -#include "../config/settings.h" - -static int client_success = 0; -static int server_success = 0; - -int ssl_client_init_status(void) { - return client_success; -} - -int ssl_server_init_status(void) { - return server_success; -} - -void ssl_init(void) { - char *pemfile = NULL, buffer[BUFFER_SIZE]; - int ret = 0, pem_free = 0; - -#ifdef PILIGHT_REWRITE - if(settings_select_string(ORIGIN_WEBSERVER, "pem-file", &pemfile) != 0) { -#else - if(settings_find_string("pem-file", &pemfile) != 0) { -#endif - if((pemfile = REALLOC(pemfile, strlen(PEM_FILE)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(pemfile, PEM_FILE); - pem_free = 1; - } - if(file_exists(pemfile) != 0) { - logprintf(LOG_NOTICE, "pemfile does not exists: %s", pemfile); - server_success = -1; - } - - if(server_success == 0) { - mbedtls_ssl_config_init(&ssl_server_conf); - } - - mbedtls_ssl_config_init(&ssl_client_conf); - mbedtls_entropy_init(&ssl_entropy); - mbedtls_ctr_drbg_init(&ssl_ctr_drbg); - mbedtls_ssl_cache_init(&ssl_cache); - - if((ret = mbedtls_ssl_config_defaults(&ssl_client_conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT)) != 0) { - /*LCOV_EXCL_START*/ - mbedtls_strerror(ret, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_ERR, "mbedtls_ctr_drbg_seed failed: %s", buffer); - client_success = -1; - /*LCOV_EXCL_STOP*/ - } - - if((ret = mbedtls_ssl_config_defaults(&ssl_server_conf, MBEDTLS_SSL_IS_SERVER, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT)) != 0) { - mbedtls_strerror(ret, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_ERR, "mbedtls_ssl_config_defaults failed: %s", buffer); - server_success = -1; - } - - if(client_success == 0 && server_success == 0) { - if((ret = mbedtls_ctr_drbg_seed(&ssl_ctr_drbg, mbedtls_entropy_func, &ssl_entropy, (const unsigned char *)"pilight", strlen("pilight"))) != 0) { - /*LCOV_EXCL_START*/ - mbedtls_strerror(ret, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_ERR, "mbedtls_ctr_drbg_seed failed: %s", buffer); - server_success = -1; - client_success = -1; - /*LCOV_EXCL_STOP*/ - } - } - - mbedtls_ssl_conf_rng(&ssl_client_conf, mbedtls_ctr_drbg_random, &ssl_ctr_drbg); - mbedtls_ssl_conf_rng(&ssl_server_conf, mbedtls_ctr_drbg_random, &ssl_ctr_drbg); - mbedtls_ssl_conf_authmode(&ssl_client_conf, MBEDTLS_SSL_VERIFY_NONE); - mbedtls_ssl_conf_session_cache(&ssl_server_conf, &ssl_cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set); - mbedtls_ssl_conf_session_cache(&ssl_client_conf, &ssl_cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set); - - memset(&ssl_server_crt, 0, sizeof(mbedtls_x509_crt)); - mbedtls_x509_crt_init(&ssl_server_crt); - - if(server_success == 0) { - if((ret = mbedtls_x509_crt_parse_file(&ssl_server_crt, pemfile)) != 0) { - mbedtls_strerror(ret, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_NOTICE, "mbedtls_x509_crt_parse_file failed: %s", buffer); - server_success = -1; - } - } - - mbedtls_pk_init(&ssl_pk_key); - if(server_success == 0) { - if((ret = mbedtls_pk_parse_keyfile(&ssl_pk_key, pemfile, NULL)) != 0) { - mbedtls_strerror(ret, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_NOTICE, "mbedtls_pk_parse_keyfile failed: %s", buffer); - server_success = -1; - } - } - - mbedtls_ssl_conf_ca_chain(&ssl_server_conf, ssl_server_crt.next, NULL); - - if(server_success == 0) { - if((ret = mbedtls_ssl_conf_own_cert(&ssl_server_conf, &ssl_server_crt, &ssl_pk_key)) != 0) { - /*LCOV_EXCL_START*/ - mbedtls_strerror(ret, (char *)&buffer, BUFFER_SIZE); - logprintf(LOG_ERR, "mbedtls_ssl_conf_own_cert failed: %s", buffer); - server_success = -1; - /*LCOV_EXCL_STOP*/ - } - } - - if(pem_free == 1) { - FREE(pemfile); - } -} - -void ssl_gc(void) { - client_success = 0; - server_success = 0; - - mbedtls_entropy_free(&ssl_entropy); - mbedtls_ssl_config_free(&ssl_server_conf); - mbedtls_ssl_config_free(&ssl_client_conf); - mbedtls_x509_crt_free(&ssl_server_crt); - mbedtls_pk_free(&ssl_pk_key); - mbedtls_ssl_cache_free(&ssl_cache); -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/ssl.h b/lib/ESPiLight/pilight/libs/pilight/core/ssl.h deleted file mode 100644 index 2ebd98e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/ssl.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _SSL_H_ -#define _SSL_H_ - -#include -#include -#include -#if MBEDTLS_VERSION_MAJOR <= 2 && \ - MBEDTLS_VERSION_MINOR <= 3 - #include -#else - #include -#endif -#include -#include -#include -#include -#include -#include -#include - -mbedtls_entropy_context ssl_entropy; -mbedtls_ctr_drbg_context ssl_ctr_drbg; -mbedtls_pk_context ssl_pk_key; -mbedtls_x509_crt ssl_server_crt; -mbedtls_ssl_cache_context ssl_cache; -struct mbedtls_ssl_config ssl_client_conf; -struct mbedtls_ssl_config ssl_server_conf; - -int ssl_client_init_status(void); -int ssl_server_init_status(void); -void ssl_init(void); -void ssl_gc(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/strptime.c b/lib/ESPiLight/pilight/libs/pilight/core/strptime.c deleted file mode 100644 index 30a9e2c..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/strptime.c +++ /dev/null @@ -1,558 +0,0 @@ -/*- - * Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code was contributed to The NetBSD Foundation by Klaus Klein. - * Heavily optimised by David Laight - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 -#include -#undef __XSI_VISIBLE -#include - -#if defined(_WIN32) && !defined(__MINGW32__) - #define strncasecmp(x,y,z) _strnicmp(x,y,z) -#endif - -/* - * We do not implement alternate representations. However, we always - * check whether a given modifier is allowed for a certain conversion. - */ -#define ALT_E 0x01 -#define ALT_O 0x02 -#define LEGAL_ALT(x) { if (alt_format & ~(x)) return NULL; } - -static char gmt[] = { "GMT" }; -#ifdef TM_ZONE -static char utc[] = { "UTC" }; -#endif - -/* RFC-822/RFC-2822 */ -static const char * const nast[5] = { - "EST", "CST", "MST", "PST", "\0\0\0" -}; -static const char * const nadt[5] = { - "EDT", "CDT", "MDT", "PDT", "\0\0\0" -}; - -#define TM_YEAR_BASE 1900 - -static const char *day[7] = { - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" -}; -static const char *abday[7] = { - "Sun","Mon","Tue","Wed","Thu","Fri","Sat" -}; -static const char *mon[12] = { - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December" -}; -static const char *abmon[12] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; -static const char *am_pm[2] = { - "AM", "PM" -}; - -static const unsigned char *conv_num (const unsigned char *, int *, - unsigned int, unsigned int); -static const unsigned char *find_string (const unsigned char *, int *, const char * const *, - const char * const *, int); - - -const char * -strptime (const char *buf, const char *fmt, struct tm *tm) -{ - unsigned char c; - const unsigned char *bp, *ep; - int alt_format, i, split_year = 0, neg = 0, offs; - const char *new_fmt; - - bp = (const unsigned char *)buf; - - while (bp != NULL && (c = *fmt++) != '\0') { - /* Clear 'alternate' modifier prior to new conversion. */ - alt_format = 0; - i = 0; - - /* Eat up white-space. */ - if (isspace(c)) { - while (isspace(*bp)) - bp++; - continue; - } - - if (c != '%') - goto literal; - - -again: - switch (c = *fmt++) { - case '%': /* "%%" is converted to "%". */ -literal: - if (c != *bp++) - return NULL; - LEGAL_ALT(0); - continue; - - /* - * "Alternative" modifiers. Just set the appropriate flag - * and start over again. - */ - case 'E': /* "%E?" alternative conversion modifier. */ - LEGAL_ALT(0); - alt_format |= ALT_E; - goto again; - - case 'O': /* "%O?" alternative conversion modifier. */ - LEGAL_ALT(0); - alt_format |= ALT_O; - goto again; - - /* - * "Complex" conversion rules, implemented through recursion. - */ - case 'c': /* Date and time, using the locale's format. */ - new_fmt = "%x %X"; - goto recurse; - - case 'D': /* The date as "%m/%d/%y". */ - new_fmt = "%m/%d/%y"; - LEGAL_ALT(0); - goto recurse; - - case 'F': /* The date as "%Y-%m-%d". */ - new_fmt = "%Y-%m-%d"; - LEGAL_ALT(0); - goto recurse; - - case 'R': /* The time as "%H:%M". */ - new_fmt = "%H:%M"; - LEGAL_ALT(0); - goto recurse; - - case 'r': /* The time in 12-hour clock representation. */ - new_fmt = "%I:%M:%S %p"; - LEGAL_ALT(0); - goto recurse; - - case 'T': /* The time as "%H:%M:%S". */ - new_fmt = "%H:%M:%S"; - LEGAL_ALT(0); - goto recurse; - - case 'X': /* The time, using the locale's format. */ - new_fmt = "%H:%M:%S"; - goto recurse; - - case 'x': /* The date, using the locale's format. */ - new_fmt = "%m/%d/%y"; - recurse: - bp = (const unsigned char *)strptime((const char *)bp, new_fmt, tm); - LEGAL_ALT(ALT_E); - continue; - - /* - * "Elementary" conversion rules. - */ - case 'A': /* The day of week, using the locale's form. */ - case 'a': - bp = find_string(bp, &tm->tm_wday, day, abday, 7); - LEGAL_ALT(0); - continue; - - case 'B': /* The month, using the locale's form. */ - case 'b': - case 'h': - bp = find_string(bp, &tm->tm_mon, mon, abmon, 12); - LEGAL_ALT(0); - continue; - - case 'C': /* The century number. */ - i = 20; - bp = conv_num(bp, &i, 0, 99); - - i = i * 100 - TM_YEAR_BASE; - if (split_year) - i += tm->tm_year % 100; - split_year = 1; - tm->tm_year = i; - LEGAL_ALT(ALT_E); - continue; - - case 'd': /* The day of month. */ - case 'e': - bp = conv_num(bp, &tm->tm_mday, 1, 31); - LEGAL_ALT(ALT_O); - continue; - - case 'k': /* The hour (24-hour clock representation). */ - LEGAL_ALT(0); - /* FALLTHROUGH */ - case 'H': - bp = conv_num(bp, &tm->tm_hour, 0, 23); - LEGAL_ALT(ALT_O); - continue; - - case 'l': /* The hour (12-hour clock representation). */ - LEGAL_ALT(0); - /* FALLTHROUGH */ - case 'I': - bp = conv_num(bp, &tm->tm_hour, 1, 12); - if (tm->tm_hour == 12) - tm->tm_hour = 0; - LEGAL_ALT(ALT_O); - continue; - - case 'j': /* The day of year. */ - i = 1; - bp = conv_num(bp, &i, 1, 366); - tm->tm_yday = i - 1; - LEGAL_ALT(0); - continue; - - case 'M': /* The minute. */ - bp = conv_num(bp, &tm->tm_min, 0, 59); - LEGAL_ALT(ALT_O); - continue; - - case 'm': /* The month. */ - i = 1; - bp = conv_num(bp, &i, 1, 12); - tm->tm_mon = i - 1; - LEGAL_ALT(ALT_O); - continue; - - case 'p': /* The locale's equivalent of AM/PM. */ - bp = find_string(bp, &i, am_pm, NULL, 2); - if (tm->tm_hour > 11) - return NULL; - tm->tm_hour += i * 12; - LEGAL_ALT(0); - continue; - - case 'S': /* The seconds. */ - bp = conv_num(bp, &tm->tm_sec, 0, 61); - LEGAL_ALT(ALT_O); - continue; - - case 'U': /* The week of year, beginning on sunday. */ - case 'W': /* The week of year, beginning on monday. */ - /* - * XXX This is bogus, as we can not assume any valid - * information present in the tm structure at this - * point to calculate a real value, so just check the - * range for now. - */ - bp = conv_num(bp, &i, 0, 53); - LEGAL_ALT(ALT_O); - continue; - - case 'w': /* The day of week, beginning on sunday. */ - bp = conv_num(bp, &tm->tm_wday, 0, 6); - LEGAL_ALT(ALT_O); - continue; - - case 'u': /* The day of week, monday = 1. */ - bp = conv_num(bp, &i, 1, 7); - tm->tm_wday = i % 7; - LEGAL_ALT(ALT_O); - continue; - - case 'g': - /* The year corresponding to the ISO week - * number but without the century. - */ - bp = conv_num(bp, &i, 0, 99); - continue; - - case 'G': - /* The year corresponding to the ISO week - * number with century. - */ - do - bp++; - while (isdigit(*bp)); - continue; - - case 'V': /* The ISO 8601:1988 week number as decimal */ - bp = conv_num(bp, &i, 0, 53); - continue; - - case 'Y': /* The year. */ - i = TM_YEAR_BASE; /* just for data sanity... */ - bp = conv_num(bp, &i, 0, 9999); - tm->tm_year = i - TM_YEAR_BASE; - LEGAL_ALT(ALT_E); - continue; - - case 'y': /* The year within 100 years of the epoch. */ - /* LEGAL_ALT(ALT_E | ALT_O); */ - bp = conv_num(bp, &i, 0, 99); - - if (split_year) - /* preserve century */ - i += (tm->tm_year / 100) * 100; - else { - split_year = 1; - if (i <= 68) - i = i + 2000 - TM_YEAR_BASE; - else - i = i + 1900 - TM_YEAR_BASE; - } - tm->tm_year = i; - continue; - - case 'Z': - if (strncmp((const char *)bp, gmt, 3) == 0) { - tm->tm_isdst = 0; -#ifdef TM_GMTOFF - tm->TM_GMTOFF = 0; -#endif -#ifdef TM_ZONE - tm->TM_ZONE = gmt; -#endif - bp += 3; - } else { -#if defined(_TM_DEFINED) && !defined(_WIN32_WCE) - _tzset(); - ep = find_string(bp, &i, - (const char * const *)tzname, - NULL, 2); - if (ep != NULL) { - tm->tm_isdst = i; -#ifdef TM_GMTOFF - tm->TM_GMTOFF = -(timezone); -#endif -#ifdef TM_ZONE - tm->TM_ZONE = tzname[i]; -#endif - } - bp = ep; -#endif - } - continue; - - case 'z': - /* - * We recognize all ISO 8601 formats: - * Z = Zulu time/UTC - * [+-]hhmm - * [+-]hh:mm - * [+-]hh - * We recognize all RFC-822/RFC-2822 formats: - * UT|GMT - * North American : UTC offsets - * E[DS]T = Eastern : -4 | -5 - * C[DS]T = Central : -5 | -6 - * M[DS]T = Mountain: -6 | -7 - * P[DS]T = Pacific : -7 | -8 - * Military - * [A-IL-M] = -1 ... -9 (J not used) - * [N-Y] = +1 ... +12 - */ - while (isspace(*bp)) - bp++; - - switch (*bp++) { - case 'G': - if (*bp++ != 'M') - return NULL; - /*FALLTHROUGH*/ - case 'U': - if (*bp++ != 'T') - return NULL; - /*FALLTHROUGH*/ - case 'Z': - tm->tm_isdst = 0; -#ifdef TM_GMTOFF - tm->TM_GMTOFF = 0; -#endif -#ifdef TM_ZONE - tm->TM_ZONE = utc; -#endif - continue; - case '+': - neg = 0; - break; - case '-': - neg = 1; - break; - default: - --bp; - ep = find_string(bp, &i, nast, NULL, 4); - if (ep != NULL) { -#ifdef TM_GMTOFF - tm->TM_GMTOFF = -5 - i; -#endif -#ifdef TM_ZONE - tm->TM_ZONE = __UNCONST(nast[i]); -#endif - bp = ep; - continue; - } - ep = find_string(bp, &i, nadt, NULL, 4); - if (ep != NULL) { - tm->tm_isdst = 1; -#ifdef TM_GMTOFF - tm->TM_GMTOFF = -4 - i; -#endif -#ifdef TM_ZONE - tm->TM_ZONE = __UNCONST(nadt[i]); -#endif - bp = ep; - continue; - } - - if ((*bp >= 'A' && *bp <= 'I') || - (*bp >= 'L' && *bp <= 'Y')) { -#ifdef TM_GMTOFF - /* Argh! No 'J'! */ - if (*bp >= 'A' && *bp <= 'I') - tm->TM_GMTOFF = - ('A' - 1) - (int)*bp; - else if (*bp >= 'L' && *bp <= 'M') - tm->TM_GMTOFF = 'A' - (int)*bp; - else if (*bp >= 'N' && *bp <= 'Y') - tm->TM_GMTOFF = (int)*bp - 'M'; -#endif -#ifdef TM_ZONE - tm->TM_ZONE = NULL; /* XXX */ -#endif - bp++; - continue; - } - return NULL; - } - offs = 0; - for (i = 0; i < 4; ) { - if (isdigit(*bp)) { - offs = offs * 10 + (*bp++ - '0'); - i++; - continue; - } - if (i == 2 && *bp == ':') { - bp++; - continue; - } - break; - } - switch (i) { - case 2: - offs *= 100; - break; - case 4: - i = offs % 100; - if (i >= 60) - return NULL; - /* Convert minutes into decimal */ - offs = (offs / 100) * 100 + (i * 50) / 30; - break; - default: - return NULL; - } - if (neg) - offs = -offs; - tm->tm_isdst = 0; /* XXX */ -#ifdef TM_GMTOFF - tm->TM_GMTOFF = offs; -#endif -#ifdef TM_ZONE - tm->TM_ZONE = NULL; /* XXX */ -#endif - continue; - - /* - * Miscellaneous conversions. - */ - case 'n': /* Any kind of white-space. */ - case 't': - while (isspace(*bp)) - bp++; - LEGAL_ALT(0); - continue; - - - default: /* Unknown/unsupported conversion. */ - return NULL; - } - } - - return ((const char *)bp); -} - - -static const unsigned char * -conv_num (const unsigned char *buf, int *dest, - unsigned int llim, unsigned int ulim) -{ - unsigned int result = 0; - unsigned char ch; - - /* The limit also determines the number of valid digits. */ - unsigned int rulim = ulim; - - ch = *buf; - if (ch < '0' || ch > '9') - return NULL; - - do { - result *= 10; - result += ch - '0'; - rulim /= 10; - ch = *++buf; - } while ((result * 10 <= ulim) && rulim && ch >= '0' && ch <= '9'); - - if (result < llim || result > ulim) - return NULL; - - *dest = result; - return buf; -} - -static const unsigned char * -find_string (const unsigned char *bp, int *tgt, const char * const *n1, - const char * const *n2, int c) -{ - int i; - unsigned int len; - - /* check full name - then abbreviated ones */ - for (; n1 != NULL; n1 = n2, n2 = NULL) { - for (i = 0; i < c; i++, n1++) { - len = strlen(*n1); - if (strncasecmp(*n1, (const char *)bp, len) == 0) { - *tgt = i; - return bp + len; - } - } - } - - /* Nothing matched */ - return NULL; -} - diff --git a/lib/ESPiLight/pilight/libs/pilight/core/strptime.h b/lib/ESPiLight/pilight/libs/pilight/core/strptime.h deleted file mode 100644 index c17216e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/strptime.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _STRPTIME_H_ -#define _STRPTIME_H_ - -char *strptime(const char *s, const char *format, struct tm *tm); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/threads.c b/lib/ESPiLight/pilight/libs/pilight/core/threads.c deleted file mode 100644 index 29a7095..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/threads.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include -#include - -#include "threads.h" -#include "common.h" -#include "log.h" -#include "mem.h" - -static unsigned short thread_loop = 1; -static unsigned short thread_running = 0; -static unsigned int threads_initialized = 0; - -static pthread_mutex_t threadqueue_lock; -static pthread_cond_t threadqueue_signal; -static pthread_mutexattr_t threadqueue_attr; - -static int threadqueue_number = 0; -static struct threadqueue_t *threadqueue; -static int threads_loop_running = 0; -static int thread_started = 0; -static pthread_t pth; - -struct threadqueue_t *threads_register(const char *id, void *(*function)(void *param), void *param, int force) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(threads_initialized == 1) { - pthread_mutex_lock(&threadqueue_lock); - } - - struct threadqueue_t *tnode = MALLOC(sizeof(struct threadqueue_t)); - if(tnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - struct timeval tcurrent; - memset(&tcurrent, '\0', sizeof(struct timeval)); - gettimeofday(&tcurrent, NULL); - - tnode->ts = 1000000 * (unsigned int)tcurrent.tv_sec + (unsigned int)tcurrent.tv_usec; - tnode->function = function; - tnode->running = 0; - tnode->force = force; - if((tnode->id = MALLOC(strlen(id)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(tnode->id, id); - tnode->param = param; - memset(&tnode->pth, '\0', sizeof(pthread_t)); - tnode->next = NULL; - - memset(&tnode->cpu_usage, '\0', sizeof(struct cpu_usage_t)); - tnode->cpu_usage.cpu_old = 0; - tnode->cpu_usage.cpu_per = 0; - tnode->cpu_usage.cpu_new = 0; - tnode->cpu_usage.sec_start = 0; - tnode->cpu_usage.sec_stop = 0; - tnode->cpu_usage.sec_diff = 0; - memset(&tnode->cpu_usage.ts, '\0', sizeof(struct timespec)); - tnode->cpu_usage.starts = 0; - - struct threadqueue_t *tmp = threadqueue; - if(tmp) { - while(tmp->next != NULL) { - tmp = tmp->next; - } - tmp->next = tnode; - } else { - tnode->next = tmp; - threadqueue = tnode; - } - threadqueue_number++; - - if(threads_initialized == 1) { - pthread_mutex_unlock(&threadqueue_lock); - pthread_cond_signal(&threadqueue_signal); - } - - return tnode; -} - -void threads_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - -#ifndef _WIN32 - sigset_t new, old; - sigemptyset(&new); - sigaddset(&new, SIGINT); - sigaddset(&new, SIGQUIT); - sigaddset(&new, SIGTERM); - pthread_sigmask(SIG_BLOCK, &new, &old); -#endif - pthread_create(thread, attr, start_routine, arg); -#ifndef _WIN32 - pthread_sigmask(SIG_SETMASK, &old, NULL); -#endif -} - -void thread_signal(char *id, int s) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct threadqueue_t *tmp_threads = threadqueue; - while(tmp_threads) { - if(strcmp(tmp_threads->id, id) == 0) { - pthread_kill(tmp_threads->pth, s); - break; - } - tmp_threads = tmp_threads->next; - } -} - -static void *threads_loop(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct threadqueue_t *tmp_threads = NULL; - - pthread_mutex_lock(&threadqueue_lock); - threads_loop_running = 1; - while(thread_loop) { - if(threadqueue_number > 0) { - pthread_mutex_lock(&threadqueue_lock); - - logprintf(LOG_STACK, "%s::unlocked", __FUNCTION__); - - tmp_threads = threadqueue; - while(tmp_threads) { - if(tmp_threads->running == 0) { - break; - } - tmp_threads = tmp_threads->next; - } - threads_create(&tmp_threads->pth, NULL, tmp_threads->function, (void *)tmp_threads->param); - thread_running++; - tmp_threads->running = 1; - if(thread_running == 1) { - logprintf(LOG_DEBUG, "new thread %s, %d thread running", tmp_threads->id, thread_running); - } else { - logprintf(LOG_DEBUG, "new thread %s, %d threads running", tmp_threads->id, thread_running); - } - - threadqueue_number--; - pthread_mutex_unlock(&threadqueue_lock); - } else { - pthread_cond_wait(&threadqueue_signal, &threadqueue_lock); - } - } - threads_loop_running = 0; - return (void *)NULL; -} - -void threads_start() { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(threads_initialized == 0) { - pthread_mutexattr_init(&threadqueue_attr); - pthread_mutexattr_settype(&threadqueue_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&threadqueue_lock, &threadqueue_attr); - pthread_cond_init(&threadqueue_signal, NULL); - threads_initialized = 1; - } - - threads_create(&pth, NULL, &threads_loop, (void *)NULL); - thread_started = 1; -} - -void thread_stop(char *id) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - if(threads_initialized == 1) { - pthread_mutex_lock(&threadqueue_lock); - } - - struct threadqueue_t *currP, *prevP; - - prevP = NULL; - - for(currP = threadqueue; currP != NULL; prevP = currP, currP = currP->next) { - - if(strcmp(currP->id, id) == 0) { - if(prevP == NULL) { - threadqueue = currP->next; - } else { - prevP->next = currP->next; - } - - if(currP->running == 1) { - thread_running--; - logprintf(LOG_DEBUG, "stopping thread %s", currP->id); - if(currP->force == 1) { - pthread_cancel(currP->pth); - } - pthread_join(currP->pth, NULL); - if(thread_running == 1) { - logprintf(LOG_DEBUG, "stopped thread %s, %d thread running", currP->id, thread_running); - } else { - logprintf(LOG_DEBUG, "stopped thread %s, %d threads running", currP->id, thread_running); - } - } - - FREE(currP->id); - FREE(currP); - - break; - } - } - if(threads_initialized == 1) { - pthread_mutex_unlock(&threadqueue_lock); - } -} - -void threads_cpu_usage(int print) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(print == 1) { - logprintf(LOG_INFO, "----- Thread Profiling -----"); - } - struct threadqueue_t *tmp_threads = threadqueue; - while(tmp_threads) { - if(tmp_threads->running == 1) { - getThreadCPUUsage(tmp_threads->pth, &tmp_threads->cpu_usage); - if(print) { - if(tmp_threads->cpu_usage.cpu_per > 0) { - logprintf(LOG_INFO, "- thread %s: %f%%", tmp_threads->id, tmp_threads->cpu_usage.cpu_per); - } else { - logprintf(LOG_INFO, "- thread %s: 0.000000%%", tmp_threads->id); - } - } - } - tmp_threads = tmp_threads->next; - } - if(print == 1) { - logprintf(LOG_INFO, "----- Thread Profiling -----"); - } -} - -int threads_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - thread_loop = 0; - - if(threads_initialized == 1) { - pthread_mutex_unlock(&threadqueue_lock); - pthread_cond_signal(&threadqueue_signal); - } - - struct threadqueue_t *tmp_threads = threadqueue; - while(tmp_threads) { - if(tmp_threads->running == 1) { - tmp_threads->running = 0; - thread_running--; - - logprintf(LOG_DEBUG, "stopping %s thread", tmp_threads->id); - if(tmp_threads->force == 1) { - pthread_cancel(tmp_threads->pth); - } - pthread_join(tmp_threads->pth, NULL); - if(thread_running == 1) { - logprintf(LOG_DEBUG, "stopped thread %s, %d thread running", tmp_threads->id, thread_running); - } else { - logprintf(LOG_DEBUG, "stopped thread %s, %d threads running", tmp_threads->id, thread_running); - } - } - usleep(10000); - tmp_threads = tmp_threads->next; - } - - struct threadqueue_t *ttmp = NULL; - while(threadqueue) { - ttmp = threadqueue; - FREE(ttmp->id); - threadqueue = threadqueue->next; - FREE(ttmp); - } - if(threadqueue != NULL) { - FREE(threadqueue); - } - - while(threads_loop_running > 0) { - usleep(10); - } - if(thread_started == 1) { - pthread_join(pth, NULL); - } - - logprintf(LOG_DEBUG, "garbage collected threads library"); - return EXIT_SUCCESS; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/threads.h b/lib/ESPiLight/pilight/libs/pilight/core/threads.h deleted file mode 100644 index efc1181..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/threads.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _THREADS_H_ -#define _THREADS_H_ - -#ifdef _WIN32 - #include "windows.h" -#endif -#include -#include "proc.h" - -struct threadqueue_t { - unsigned int ts; - pthread_t pth; -#ifdef _WIN32 - HANDLE handle; -#endif - int force; - char *id; - void *param; - unsigned int running; - struct cpu_usage_t cpu_usage; - void *(*function)(void *param); - struct threadqueue_t *next; -} threadqueue_t; - -struct threadqueue_t *threads_register(const char *id, void *(*function)(void* param), void *param, int force); -void threads_create(pthread_t *pth, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); -void threads_start(void); -void thread_stop(char *id); -void threads_cpu_usage(int print); -int threads_gc(void); -void thread_signal(char *id, int signal); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/tzdata.h b/lib/ESPiLight/pilight/libs/pilight/core/tzdata.h deleted file mode 100644 index 5115236..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/tzdata.h +++ /dev/null @@ -1,6195 +0,0 @@ -// Copyright (c) 2016 Nuxi, https://nuxi.nl/ -// -// This file is distributed under a 2-clause BSD license. -// See the LICENSE file for details. - -// The IANA "tzdata" time zone database, version 2017b. -// This file has been generated by gen_tzdata.py. - -// Updated on 2017-08-20 09:45:56.065070 - -static const struct lc_timezone_rule rules_020[] = { - {0, 255, 0, 7, 1, 0, TIMEBASE_CUR, 2, "\0"}, -}; -static const struct lc_timezone_rule rules_030[] = { - {0, 255, 0, 7, 1, 0, TIMEBASE_CUR, 3, "\0"}, -}; -static const struct lc_timezone_rule rules_100[] = { - {0, 255, 0, 7, 1, 0, TIMEBASE_CUR, 6, "\0"}, -}; -static const struct lc_timezone_rule rules_AN[] = { - {71, 85, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {72, 72, 1, 7, 27, 120, TIMEBASE_STD, 0, "S\0"}, - {73, 81, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {82, 82, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {83, 85, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {86, 89, 2, 0, 15, 120, TIMEBASE_STD, 0, "S\0"}, - {86, 86, 9, 7, 19, 120, TIMEBASE_STD, 6, "D\0"}, - {87, 99, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {90, 95, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {96, 105, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {100, 100, 7, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {101, 107, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {106, 106, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {107, 107, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {108, 255, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {108, 255, 9, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_AQ[] = { - {71, 71, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {72, 72, 1, 0, 22, 120, TIMEBASE_STD, 0, "S\0"}, - {89, 91, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {90, 92, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_AS[] = { - {71, 85, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {72, 72, 1, 7, 27, 120, TIMEBASE_STD, 0, "S\0"}, - {73, 85, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {86, 90, 2, 0, 15, 120, TIMEBASE_STD, 0, "S\0"}, - {86, 86, 9, 7, 19, 120, TIMEBASE_STD, 6, "D\0"}, - {87, 107, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {91, 91, 2, 7, 3, 120, TIMEBASE_STD, 0, "S\0"}, - {92, 92, 2, 7, 22, 120, TIMEBASE_STD, 0, "S\0"}, - {93, 93, 2, 7, 7, 120, TIMEBASE_STD, 0, "S\0"}, - {94, 94, 2, 7, 20, 120, TIMEBASE_STD, 0, "S\0"}, - {95, 105, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {106, 106, 3, 7, 2, 120, TIMEBASE_STD, 0, "S\0"}, - {107, 107, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {108, 255, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {108, 255, 9, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_AT[] = { - {67, 67, 9, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, - {68, 68, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {68, 85, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {69, 71, 2, 0, 8, 120, TIMEBASE_STD, 0, "S\0"}, - {72, 72, 1, 0, 22, 120, TIMEBASE_STD, 0, "S\0"}, - {73, 81, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {82, 83, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {84, 86, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {86, 86, 9, 0, 15, 120, TIMEBASE_STD, 6, "D\0"}, - {87, 90, 2, 0, 15, 120, TIMEBASE_STD, 0, "S\0"}, - {87, 87, 9, 0, 22, 120, TIMEBASE_STD, 6, "D\0"}, - {88, 90, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {91, 105, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {91, 99, 9, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, - {100, 100, 7, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {101, 255, 9, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, - {106, 106, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {107, 107, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {108, 255, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_AV[] = { - {71, 85, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {72, 72, 1, 0, 22, 120, TIMEBASE_STD, 0, "S\0"}, - {73, 85, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {86, 90, 2, 0, 15, 120, TIMEBASE_STD, 0, "S\0"}, - {86, 87, 9, 0, 15, 120, TIMEBASE_STD, 6, "D\0"}, - {88, 99, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {91, 94, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {95, 105, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {100, 100, 7, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {101, 107, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {106, 106, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {107, 107, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {108, 255, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {108, 255, 9, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_AW[] = { - {74, 74, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {75, 75, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {83, 83, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {84, 84, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {91, 91, 10, 7, 17, 120, TIMEBASE_STD, 6, "D\0"}, - {92, 92, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {106, 106, 11, 7, 3, 120, TIMEBASE_STD, 6, "D\0"}, - {107, 109, 2, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {107, 108, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_Albania[] = { - {40, 40, 5, 7, 16, 0, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 10, 7, 2, 180, TIMEBASE_CUR, 0, "\0"}, - {43, 43, 2, 7, 29, 120, TIMEBASE_CUR, 6, "S\0"}, - {43, 43, 3, 7, 10, 180, TIMEBASE_CUR, 0, "\0"}, - {74, 74, 4, 7, 4, 0, TIMEBASE_CUR, 6, "S\0"}, - {74, 74, 9, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {75, 75, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {75, 75, 9, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {76, 76, 4, 7, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {76, 76, 9, 7, 3, 0, TIMEBASE_CUR, 0, "\0"}, - {77, 77, 4, 7, 8, 0, TIMEBASE_CUR, 6, "S\0"}, - {77, 77, 9, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 4, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {79, 79, 4, 7, 5, 0, TIMEBASE_CUR, 6, "S\0"}, - {79, 79, 8, 7, 30, 0, TIMEBASE_CUR, 0, "\0"}, - {80, 80, 4, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {80, 80, 9, 7, 4, 0, TIMEBASE_CUR, 0, "\0"}, - {81, 81, 3, 7, 26, 0, TIMEBASE_CUR, 6, "S\0"}, - {81, 81, 8, 7, 27, 0, TIMEBASE_CUR, 0, "\0"}, - {82, 82, 4, 7, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {82, 82, 9, 7, 3, 0, TIMEBASE_CUR, 0, "\0"}, - {83, 83, 3, 7, 18, 0, TIMEBASE_CUR, 6, "S\0"}, - {83, 83, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {84, 84, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Algeria[] = { - {16, 16, 5, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {16, 19, 9, 0, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {17, 17, 2, 7, 24, 1380, TIMEBASE_STD, 6, "S\0"}, - {18, 18, 2, 7, 9, 1380, TIMEBASE_STD, 6, "S\0"}, - {19, 19, 2, 7, 1, 1380, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 1, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 9, 7, 23, 1380, TIMEBASE_STD, 0, "\0"}, - {21, 21, 2, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {21, 21, 5, 7, 21, 1380, TIMEBASE_STD, 0, "\0"}, - {39, 39, 8, 7, 11, 1380, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 10, 7, 19, 60, TIMEBASE_CUR, 0, "\0"}, - {44, 45, 3, 1, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {44, 44, 9, 7, 8, 120, TIMEBASE_CUR, 0, "\0"}, - {45, 45, 8, 7, 16, 60, TIMEBASE_CUR, 0, "\0"}, - {71, 71, 3, 7, 25, 1380, TIMEBASE_STD, 6, "S\0"}, - {71, 71, 8, 7, 26, 1380, TIMEBASE_STD, 0, "\0"}, - {77, 77, 4, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {77, 77, 9, 7, 21, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 2, 7, 24, 60, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 8, 7, 22, 180, TIMEBASE_CUR, 0, "\0"}, - {80, 80, 3, 7, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {80, 80, 9, 7, 31, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Arg[] = { - {30, 30, 11, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {31, 31, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {31, 31, 9, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {32, 40, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {32, 39, 10, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {40, 40, 6, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {41, 41, 5, 7, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {41, 41, 9, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {43, 43, 7, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {43, 43, 9, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {46, 46, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {46, 46, 9, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {63, 63, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {63, 63, 11, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {64, 66, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {64, 66, 9, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {67, 67, 3, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {67, 68, 9, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {68, 69, 3, 0, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {74, 74, 0, 7, 23, 0, TIMEBASE_CUR, 6, "S\0"}, - {74, 74, 4, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {88, 88, 11, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {89, 93, 2, 0, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {89, 92, 9, 0, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {99, 99, 9, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {100, 100, 2, 7, 3, 0, TIMEBASE_CUR, 0, "\0"}, - {107, 107, 11, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {108, 109, 2, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {108, 108, 9, 0, 15, 0, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Aus[] = { - {17, 17, 0, 7, 1, 1, TIMEBASE_CUR, 6, "D\0"}, - {17, 17, 2, 7, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 0, 7, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {42, 42, 2, 7, 29, 120, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 8, 7, 27, 120, TIMEBASE_CUR, 6, "D\0"}, - {43, 44, 2, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {43, 43, 9, 7, 3, 120, TIMEBASE_CUR, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_Austria[] = { - {20, 20, 3, 7, 5, 120, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 8, 7, 13, 120, TIMEBASE_STD, 0, "\0"}, - {46, 46, 3, 7, 14, 120, TIMEBASE_STD, 6, "S\0"}, - {46, 48, 9, 0, 1, 120, TIMEBASE_STD, 0, "\0"}, - {47, 47, 3, 7, 6, 120, TIMEBASE_STD, 6, "S\0"}, - {48, 48, 3, 7, 18, 120, TIMEBASE_STD, 6, "S\0"}, - {80, 80, 3, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {80, 80, 8, 7, 28, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Azer[] = { - {97, 115, 2, 0, 25, 240, TIMEBASE_CUR, 6, "S\0"}, - {97, 115, 9, 0, 25, 300, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Bahamas[] = { - {64, 75, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {64, 75, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Barb[] = { - {77, 77, 5, 7, 12, 120, TIMEBASE_CUR, 6, "D\0"}, - {77, 78, 9, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {78, 80, 3, 0, 15, 120, TIMEBASE_CUR, 6, "D\0"}, - {79, 79, 8, 7, 30, 120, TIMEBASE_CUR, 0, "S\0"}, - {80, 80, 8, 7, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Belgium[] = { - {18, 18, 2, 7, 9, 0, TIMEBASE_STD, 6, "S\0"}, - {18, 19, 9, 6, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {19, 19, 2, 7, 1, 1380, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 1, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 9, 7, 23, 1380, TIMEBASE_STD, 0, "\0"}, - {21, 21, 2, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {21, 21, 9, 7, 25, 1380, TIMEBASE_STD, 0, "\0"}, - {22, 22, 2, 7, 25, 1380, TIMEBASE_STD, 6, "S\0"}, - {22, 27, 9, 6, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {23, 23, 3, 7, 21, 1380, TIMEBASE_STD, 6, "S\0"}, - {24, 24, 2, 7, 29, 1380, TIMEBASE_STD, 6, "S\0"}, - {25, 25, 3, 7, 4, 1380, TIMEBASE_STD, 6, "S\0"}, - {26, 26, 3, 7, 17, 1380, TIMEBASE_STD, 6, "S\0"}, - {27, 27, 3, 7, 9, 1380, TIMEBASE_STD, 6, "S\0"}, - {28, 28, 3, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {28, 38, 9, 0, 2, 120, TIMEBASE_STD, 0, "\0"}, - {29, 29, 3, 7, 21, 120, TIMEBASE_STD, 6, "S\0"}, - {30, 30, 3, 7, 13, 120, TIMEBASE_STD, 6, "S\0"}, - {31, 31, 3, 7, 19, 120, TIMEBASE_STD, 6, "S\0"}, - {32, 32, 3, 7, 3, 120, TIMEBASE_STD, 6, "S\0"}, - {33, 33, 2, 7, 26, 120, TIMEBASE_STD, 6, "S\0"}, - {34, 34, 3, 7, 8, 120, TIMEBASE_STD, 6, "S\0"}, - {35, 35, 2, 7, 31, 120, TIMEBASE_STD, 6, "S\0"}, - {36, 36, 3, 7, 19, 120, TIMEBASE_STD, 6, "S\0"}, - {37, 37, 3, 7, 4, 120, TIMEBASE_STD, 6, "S\0"}, - {38, 38, 2, 7, 27, 120, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 3, 7, 16, 120, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 10, 7, 19, 120, TIMEBASE_STD, 0, "\0"}, - {40, 40, 1, 7, 25, 120, TIMEBASE_STD, 6, "S\0"}, - {44, 44, 8, 7, 17, 120, TIMEBASE_STD, 0, "\0"}, - {45, 45, 3, 7, 2, 120, TIMEBASE_STD, 6, "S\0"}, - {45, 45, 8, 7, 16, 120, TIMEBASE_STD, 0, "\0"}, - {46, 46, 4, 7, 19, 120, TIMEBASE_STD, 6, "S\0"}, - {46, 46, 9, 7, 7, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Belize[] = { - {18, 42, 9, 0, 2, 0, TIMEBASE_CUR, 3, "-0530\0"}, - {19, 43, 1, 0, 9, 0, TIMEBASE_CUR, 0, "CST\0"}, - {73, 73, 11, 7, 5, 0, TIMEBASE_CUR, 6, "CDT\0"}, - {74, 74, 1, 7, 9, 0, TIMEBASE_CUR, 0, "CST\0"}, - {82, 82, 11, 7, 18, 0, TIMEBASE_CUR, 6, "CDT\0"}, - {83, 83, 1, 7, 12, 0, TIMEBASE_CUR, 0, "CST\0"}, -}; -static const struct lc_timezone_rule rules_Brazil[] = { - {31, 31, 9, 7, 3, 660, TIMEBASE_CUR, 6, "S\0"}, - {32, 33, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {32, 32, 9, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {49, 52, 11, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {50, 50, 3, 7, 16, 60, TIMEBASE_CUR, 0, "\0"}, - {51, 52, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {53, 53, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {63, 63, 11, 7, 9, 0, TIMEBASE_CUR, 6, "S\0"}, - {64, 64, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {65, 65, 0, 7, 31, 0, TIMEBASE_CUR, 6, "S\0"}, - {65, 65, 2, 7, 31, 0, TIMEBASE_CUR, 0, "\0"}, - {65, 65, 11, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {66, 68, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {66, 67, 10, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {85, 85, 10, 7, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {86, 86, 2, 7, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {86, 86, 9, 7, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {87, 87, 1, 7, 14, 0, TIMEBASE_CUR, 0, "\0"}, - {87, 87, 9, 7, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {88, 88, 1, 7, 7, 0, TIMEBASE_CUR, 0, "\0"}, - {88, 88, 9, 7, 16, 0, TIMEBASE_CUR, 6, "S\0"}, - {89, 89, 0, 7, 29, 0, TIMEBASE_CUR, 0, "\0"}, - {89, 89, 9, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {90, 90, 1, 7, 11, 0, TIMEBASE_CUR, 0, "\0"}, - {90, 90, 9, 7, 21, 0, TIMEBASE_CUR, 6, "S\0"}, - {91, 91, 1, 7, 17, 0, TIMEBASE_CUR, 0, "\0"}, - {91, 91, 9, 7, 20, 0, TIMEBASE_CUR, 6, "S\0"}, - {92, 92, 1, 7, 9, 0, TIMEBASE_CUR, 0, "\0"}, - {92, 92, 9, 7, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 93, 0, 7, 31, 0, TIMEBASE_CUR, 0, "\0"}, - {93, 95, 9, 0, 11, 0, TIMEBASE_CUR, 6, "S\0"}, - {94, 95, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {96, 96, 1, 7, 11, 0, TIMEBASE_CUR, 0, "\0"}, - {96, 96, 9, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {97, 97, 1, 7, 16, 0, TIMEBASE_CUR, 0, "\0"}, - {97, 97, 9, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {98, 98, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {98, 98, 9, 7, 11, 0, TIMEBASE_CUR, 6, "S\0"}, - {99, 99, 1, 7, 21, 0, TIMEBASE_CUR, 0, "\0"}, - {99, 99, 9, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {100, 100, 1, 7, 27, 0, TIMEBASE_CUR, 0, "\0"}, - {100, 101, 9, 0, 8, 0, TIMEBASE_CUR, 6, "S\0"}, - {101, 106, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {102, 102, 10, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {103, 103, 9, 7, 19, 0, TIMEBASE_CUR, 6, "S\0"}, - {104, 104, 10, 7, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {105, 105, 9, 7, 16, 0, TIMEBASE_CUR, 6, "S\0"}, - {106, 106, 10, 7, 5, 0, TIMEBASE_CUR, 6, "S\0"}, - {107, 107, 1, 7, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {107, 107, 9, 0, 8, 0, TIMEBASE_CUR, 6, "S\0"}, - {108, 111, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {108, 255, 9, 0, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {112, 112, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {113, 114, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {115, 115, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {116, 122, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {123, 123, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {124, 125, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {126, 126, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {127, 133, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {134, 134, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {135, 136, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {137, 137, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {138, 255, 1, 0, 15, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Bulg[] = { - {79, 79, 2, 7, 31, 1380, TIMEBASE_CUR, 6, "S\0"}, - {79, 79, 9, 7, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {80, 82, 3, 6, 1, 1380, TIMEBASE_CUR, 6, "S\0"}, - {80, 80, 8, 7, 29, 60, TIMEBASE_CUR, 0, "\0"}, - {81, 81, 8, 7, 27, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_CA[] = { - {48, 48, 2, 7, 14, 121, TIMEBASE_CUR, 6, "D\0"}, - {49, 49, 0, 7, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {50, 66, 3, 0, 24, 60, TIMEBASE_CUR, 6, "D\0"}, - {50, 61, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {62, 66, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_CO[] = { - {92, 92, 4, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 93, 3, 7, 4, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_CR[] = { - {79, 80, 1, 0, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {79, 80, 5, 0, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {91, 92, 0, 6, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {91, 91, 6, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {92, 92, 2, 7, 15, 0, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_C_Eur[] = { - {16, 16, 3, 7, 30, 1380, TIMEBASE_CUR, 6, "S\0"}, - {16, 16, 9, 7, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {17, 18, 3, 1, 15, 120, TIMEBASE_STD, 6, "S\0"}, - {17, 18, 8, 1, 15, 120, TIMEBASE_STD, 0, "\0"}, - {40, 40, 3, 7, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {42, 42, 10, 7, 2, 120, TIMEBASE_STD, 0, "\0"}, - {43, 43, 2, 7, 29, 120, TIMEBASE_STD, 6, "S\0"}, - {43, 43, 9, 7, 4, 120, TIMEBASE_STD, 0, "\0"}, - {44, 45, 3, 1, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {44, 44, 9, 7, 2, 120, TIMEBASE_STD, 0, "\0"}, - {45, 45, 8, 7, 16, 120, TIMEBASE_STD, 0, "\0"}, - {77, 80, 3, 0, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {77, 77, 8, 0, 24, 120, TIMEBASE_STD, 0, "\0"}, - {78, 78, 9, 7, 1, 120, TIMEBASE_STD, 0, "\0"}, - {79, 95, 8, 0, 24, 120, TIMEBASE_STD, 0, "\0"}, - {81, 255, 2, 0, 25, 120, TIMEBASE_STD, 6, "S\0"}, - {96, 255, 9, 0, 25, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Canada[] = { - {18, 18, 3, 7, 14, 120, TIMEBASE_CUR, 6, "D\0"}, - {18, 18, 9, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 1, 7, 9, 120, TIMEBASE_CUR, 6, "W\0"}, - {45, 45, 7, 7, 14, 1380, TIMEBASE_UTC, 6, "P\0"}, - {45, 45, 8, 7, 30, 120, TIMEBASE_CUR, 0, "S\0"}, - {74, 86, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {74, 106, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {87, 106, 3, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {107, 255, 2, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {107, 255, 10, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Chatham[] = { - {74, 74, 10, 0, 1, 165, TIMEBASE_STD, 6, "D\0"}, - {75, 75, 1, 0, 22, 165, TIMEBASE_STD, 0, "S\0"}, - {75, 88, 9, 0, 25, 165, TIMEBASE_STD, 6, "D\0"}, - {76, 89, 2, 0, 1, 165, TIMEBASE_STD, 0, "S\0"}, - {89, 89, 9, 0, 8, 165, TIMEBASE_STD, 6, "D\0"}, - {90, 107, 2, 0, 15, 165, TIMEBASE_STD, 0, "S\0"}, - {90, 106, 9, 0, 1, 165, TIMEBASE_STD, 6, "D\0"}, - {107, 255, 8, 0, 24, 165, TIMEBASE_STD, 6, "D\0"}, - {108, 255, 3, 0, 1, 165, TIMEBASE_STD, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Chicago[] = { - {20, 20, 5, 7, 13, 120, TIMEBASE_CUR, 6, "D\0"}, - {20, 21, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {21, 21, 2, 0, 25, 120, TIMEBASE_CUR, 6, "D\0"}, - {22, 66, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {22, 54, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {55, 66, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Chile[] = { - {27, 31, 8, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {28, 32, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {68, 68, 10, 7, 3, 240, TIMEBASE_UTC, 6, "S\0"}, - {69, 69, 2, 7, 30, 180, TIMEBASE_UTC, 0, "\0"}, - {69, 69, 10, 7, 23, 240, TIMEBASE_UTC, 6, "S\0"}, - {70, 70, 2, 7, 29, 180, TIMEBASE_UTC, 0, "\0"}, - {70, 72, 9, 0, 9, 240, TIMEBASE_UTC, 6, "S\0"}, - {71, 71, 2, 7, 14, 180, TIMEBASE_UTC, 0, "\0"}, - {72, 86, 2, 0, 9, 180, TIMEBASE_UTC, 0, "\0"}, - {73, 73, 8, 7, 30, 240, TIMEBASE_UTC, 6, "S\0"}, - {74, 87, 9, 0, 9, 240, TIMEBASE_UTC, 6, "S\0"}, - {87, 87, 3, 7, 12, 180, TIMEBASE_UTC, 0, "\0"}, - {88, 90, 2, 0, 9, 180, TIMEBASE_UTC, 0, "\0"}, - {88, 89, 9, 0, 9, 240, TIMEBASE_UTC, 6, "S\0"}, - {90, 90, 8, 7, 16, 240, TIMEBASE_UTC, 6, "S\0"}, - {91, 96, 2, 0, 9, 180, TIMEBASE_UTC, 0, "\0"}, - {91, 97, 9, 0, 9, 240, TIMEBASE_UTC, 6, "S\0"}, - {97, 97, 2, 7, 30, 180, TIMEBASE_UTC, 0, "\0"}, - {98, 98, 2, 0, 9, 180, TIMEBASE_UTC, 0, "\0"}, - {98, 98, 8, 7, 27, 240, TIMEBASE_UTC, 6, "S\0"}, - {99, 99, 3, 7, 4, 180, TIMEBASE_UTC, 0, "\0"}, - {99, 110, 9, 0, 9, 240, TIMEBASE_UTC, 6, "S\0"}, - {100, 107, 2, 0, 9, 180, TIMEBASE_UTC, 0, "\0"}, - {108, 108, 2, 7, 30, 180, TIMEBASE_UTC, 0, "\0"}, - {109, 109, 2, 0, 9, 180, TIMEBASE_UTC, 0, "\0"}, - {110, 110, 3, 0, 1, 180, TIMEBASE_UTC, 0, "\0"}, - {111, 111, 4, 0, 2, 180, TIMEBASE_UTC, 0, "\0"}, - {111, 111, 7, 0, 16, 240, TIMEBASE_UTC, 6, "S\0"}, - {112, 114, 3, 0, 23, 180, TIMEBASE_UTC, 0, "\0"}, - {112, 114, 8, 0, 2, 240, TIMEBASE_UTC, 6, "S\0"}, - {116, 255, 4, 0, 9, 180, TIMEBASE_UTC, 0, "\0"}, - {116, 255, 7, 0, 9, 240, TIMEBASE_UTC, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Cook[] = { - {78, 78, 10, 7, 12, 0, TIMEBASE_CUR, 3, "HS\0"}, - {79, 91, 2, 0, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {79, 90, 9, 0, 25, 0, TIMEBASE_CUR, 3, "HS\0"}, -}; -static const struct lc_timezone_rule rules_Cuba[] = { - {28, 28, 5, 7, 10, 0, TIMEBASE_CUR, 6, "D\0"}, - {28, 28, 9, 7, 10, 0, TIMEBASE_CUR, 0, "S\0"}, - {40, 42, 5, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {40, 42, 8, 0, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {45, 46, 5, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {45, 46, 8, 0, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {65, 65, 5, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {65, 65, 8, 7, 30, 0, TIMEBASE_CUR, 0, "S\0"}, - {66, 66, 4, 7, 29, 0, TIMEBASE_CUR, 6, "D\0"}, - {66, 66, 9, 7, 2, 0, TIMEBASE_CUR, 0, "S\0"}, - {67, 67, 3, 7, 8, 0, TIMEBASE_CUR, 6, "D\0"}, - {67, 68, 8, 0, 8, 0, TIMEBASE_CUR, 0, "S\0"}, - {68, 68, 3, 7, 14, 0, TIMEBASE_CUR, 6, "D\0"}, - {69, 77, 3, 0, 24, 0, TIMEBASE_CUR, 6, "D\0"}, - {69, 71, 9, 0, 25, 0, TIMEBASE_CUR, 0, "S\0"}, - {72, 74, 9, 7, 8, 0, TIMEBASE_CUR, 0, "S\0"}, - {75, 77, 9, 0, 25, 0, TIMEBASE_CUR, 0, "S\0"}, - {78, 78, 4, 7, 7, 0, TIMEBASE_CUR, 6, "D\0"}, - {78, 90, 9, 0, 8, 0, TIMEBASE_CUR, 0, "S\0"}, - {79, 80, 2, 0, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {81, 85, 4, 0, 5, 0, TIMEBASE_CUR, 6, "D\0"}, - {86, 89, 2, 0, 14, 0, TIMEBASE_CUR, 6, "D\0"}, - {90, 97, 3, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {91, 95, 9, 0, 8, 0, TIMEBASE_STD, 0, "S\0"}, - {96, 96, 9, 7, 6, 0, TIMEBASE_STD, 0, "S\0"}, - {97, 97, 9, 7, 12, 0, TIMEBASE_STD, 0, "S\0"}, - {98, 99, 2, 0, 25, 0, TIMEBASE_STD, 6, "D\0"}, - {98, 103, 9, 0, 25, 0, TIMEBASE_STD, 0, "S\0"}, - {100, 103, 3, 0, 1, 0, TIMEBASE_STD, 6, "D\0"}, - {104, 104, 2, 0, 25, 0, TIMEBASE_STD, 6, "D\0"}, - {106, 110, 9, 0, 25, 0, TIMEBASE_STD, 0, "S\0"}, - {107, 107, 2, 0, 8, 0, TIMEBASE_STD, 6, "D\0"}, - {108, 108, 2, 0, 15, 0, TIMEBASE_STD, 6, "D\0"}, - {109, 110, 2, 0, 8, 0, TIMEBASE_STD, 6, "D\0"}, - {111, 111, 2, 0, 15, 0, TIMEBASE_STD, 6, "D\0"}, - {111, 111, 10, 7, 13, 0, TIMEBASE_STD, 0, "S\0"}, - {112, 112, 3, 7, 1, 0, TIMEBASE_STD, 6, "D\0"}, - {112, 255, 10, 0, 1, 0, TIMEBASE_STD, 0, "S\0"}, - {113, 255, 2, 0, 8, 0, TIMEBASE_STD, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_Cyprus[] = { - {75, 75, 3, 7, 13, 0, TIMEBASE_CUR, 6, "S\0"}, - {75, 75, 9, 7, 12, 0, TIMEBASE_CUR, 0, "\0"}, - {76, 76, 4, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {76, 76, 9, 7, 11, 0, TIMEBASE_CUR, 0, "\0"}, - {77, 80, 3, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {77, 77, 8, 7, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 9, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {79, 97, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {81, 98, 2, 0, 25, 0, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Czech[] = { - {45, 45, 3, 7, 8, 120, TIMEBASE_STD, 6, "S\0"}, - {45, 45, 10, 7, 18, 120, TIMEBASE_STD, 0, "\0"}, - {46, 46, 4, 7, 6, 120, TIMEBASE_STD, 6, "S\0"}, - {46, 49, 9, 0, 1, 120, TIMEBASE_STD, 0, "\0"}, - {47, 47, 3, 7, 20, 120, TIMEBASE_STD, 6, "S\0"}, - {48, 48, 3, 7, 18, 120, TIMEBASE_STD, 6, "S\0"}, - {49, 49, 3, 7, 9, 120, TIMEBASE_STD, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_DR[] = { - {66, 66, 9, 7, 30, 0, TIMEBASE_CUR, 6, "EDT\0"}, - {67, 67, 1, 7, 28, 0, TIMEBASE_CUR, 0, "EST\0"}, - {69, 73, 9, 0, 25, 0, TIMEBASE_CUR, 3, "-0430\0"}, - {70, 70, 1, 7, 21, 0, TIMEBASE_CUR, 0, "EST\0"}, - {71, 71, 0, 7, 20, 0, TIMEBASE_CUR, 0, "EST\0"}, - {72, 74, 0, 7, 21, 0, TIMEBASE_CUR, 0, "EST\0"}, -}; -static const struct lc_timezone_rule rules_Denmark[] = { - {16, 16, 4, 7, 14, 1380, TIMEBASE_CUR, 6, "S\0"}, - {16, 16, 8, 7, 30, 1380, TIMEBASE_CUR, 0, "\0"}, - {40, 40, 4, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 3, 7, 2, 120, TIMEBASE_STD, 6, "S\0"}, - {45, 45, 7, 7, 15, 120, TIMEBASE_STD, 0, "\0"}, - {46, 46, 4, 7, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {46, 46, 8, 7, 1, 120, TIMEBASE_STD, 0, "\0"}, - {47, 47, 4, 7, 4, 120, TIMEBASE_STD, 6, "S\0"}, - {47, 47, 7, 7, 10, 120, TIMEBASE_STD, 0, "\0"}, - {48, 48, 4, 7, 9, 120, TIMEBASE_STD, 6, "S\0"}, - {48, 48, 7, 7, 8, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Denver[] = { - {20, 21, 2, 0, 25, 120, TIMEBASE_CUR, 6, "D\0"}, - {20, 20, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {21, 21, 4, 7, 22, 120, TIMEBASE_CUR, 0, "S\0"}, - {65, 66, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {65, 66, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Detroit[] = { - {48, 48, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {48, 48, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {67, 67, 5, 7, 14, 120, TIMEBASE_CUR, 6, "D\0"}, - {67, 67, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Dhaka[] = { - {109, 109, 5, 7, 19, 1380, TIMEBASE_CUR, 6, "S\0"}, - {109, 109, 11, 7, 31, 1440, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_EU[] = { - {77, 80, 3, 0, 1, 60, TIMEBASE_UTC, 6, "S\0"}, - {77, 77, 8, 0, 24, 60, TIMEBASE_UTC, 0, "\0"}, - {78, 78, 9, 7, 1, 60, TIMEBASE_UTC, 0, "\0"}, - {79, 95, 8, 0, 24, 60, TIMEBASE_UTC, 0, "\0"}, - {81, 255, 2, 0, 25, 60, TIMEBASE_UTC, 6, "S\0"}, - {96, 255, 9, 0, 25, 60, TIMEBASE_UTC, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_EUAsia[] = { - {79, 95, 8, 0, 24, 60, TIMEBASE_UTC, 0, "\0"}, - {81, 255, 2, 0, 25, 60, TIMEBASE_UTC, 6, "S\0"}, - {96, 255, 9, 0, 25, 60, TIMEBASE_UTC, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_E_Eur[] = { - {77, 80, 3, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {77, 77, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {79, 95, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {81, 255, 2, 0, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {96, 255, 9, 0, 25, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_E_EurAsia[] = { - {79, 95, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {81, 255, 2, 0, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {96, 255, 9, 0, 25, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Ecuador[] = { - {92, 92, 10, 7, 28, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 93, 1, 7, 5, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Edm[] = { - {18, 19, 3, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {18, 18, 9, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {19, 19, 4, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {20, 23, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {20, 20, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {21, 23, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 1, 7, 9, 120, TIMEBASE_CUR, 6, "W\0"}, - {45, 45, 7, 7, 14, 1380, TIMEBASE_UTC, 6, "P\0"}, - {45, 45, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {47, 47, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {47, 47, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {67, 67, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {67, 67, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {69, 69, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {69, 69, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {72, 86, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {72, 106, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Egypt[] = { - {40, 40, 6, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {40, 40, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {41, 41, 3, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {41, 41, 8, 7, 16, 0, TIMEBASE_CUR, 0, "\0"}, - {42, 44, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 9, 7, 27, 0, TIMEBASE_CUR, 0, "\0"}, - {43, 45, 10, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {45, 45, 3, 7, 16, 0, TIMEBASE_CUR, 6, "S\0"}, - {57, 57, 4, 7, 10, 0, TIMEBASE_CUR, 6, "S\0"}, - {57, 58, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {58, 58, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {59, 81, 4, 7, 1, 60, TIMEBASE_CUR, 6, "S\0"}, - {59, 65, 8, 7, 30, 180, TIMEBASE_CUR, 0, "\0"}, - {66, 94, 9, 7, 1, 180, TIMEBASE_CUR, 0, "\0"}, - {82, 82, 6, 7, 25, 60, TIMEBASE_CUR, 6, "S\0"}, - {83, 83, 6, 7, 12, 60, TIMEBASE_CUR, 6, "S\0"}, - {84, 88, 4, 7, 1, 60, TIMEBASE_CUR, 6, "S\0"}, - {89, 89, 4, 7, 6, 60, TIMEBASE_CUR, 6, "S\0"}, - {90, 94, 4, 7, 1, 60, TIMEBASE_CUR, 6, "S\0"}, - {95, 110, 3, 5, 24, 0, TIMEBASE_STD, 6, "S\0"}, - {95, 105, 8, 4, 24, 1440, TIMEBASE_CUR, 0, "\0"}, - {106, 106, 8, 7, 21, 1440, TIMEBASE_CUR, 0, "\0"}, - {107, 107, 8, 4, 1, 1440, TIMEBASE_CUR, 0, "\0"}, - {108, 108, 7, 4, 25, 1440, TIMEBASE_CUR, 0, "\0"}, - {109, 109, 7, 7, 20, 1440, TIMEBASE_CUR, 0, "\0"}, - {110, 110, 7, 7, 10, 1440, TIMEBASE_CUR, 0, "\0"}, - {110, 110, 8, 7, 9, 1440, TIMEBASE_CUR, 6, "S\0"}, - {110, 110, 8, 4, 24, 1440, TIMEBASE_CUR, 0, "\0"}, - {114, 114, 4, 7, 15, 1440, TIMEBASE_CUR, 6, "S\0"}, - {114, 114, 5, 7, 26, 1440, TIMEBASE_CUR, 0, "\0"}, - {114, 114, 6, 7, 31, 1440, TIMEBASE_CUR, 6, "S\0"}, - {114, 114, 8, 4, 24, 1440, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_EgyptAsia[] = { - {57, 57, 4, 7, 10, 0, TIMEBASE_CUR, 6, "S\0"}, - {57, 58, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {58, 58, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {59, 67, 4, 7, 1, 60, TIMEBASE_CUR, 6, "S\0"}, - {59, 65, 8, 7, 30, 180, TIMEBASE_CUR, 0, "\0"}, - {66, 66, 9, 7, 1, 180, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Falk[] = { - {37, 38, 8, 0, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {38, 42, 2, 0, 19, 0, TIMEBASE_CUR, 0, "\0"}, - {39, 39, 9, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {40, 42, 8, 0, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 11, 7, 31, 1440, TIMEBASE_CUR, 0, "\0"}, - {83, 83, 8, 0, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {84, 85, 3, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {84, 84, 8, 7, 16, 0, TIMEBASE_CUR, 6, "S\0"}, - {85, 100, 8, 0, 9, 0, TIMEBASE_CUR, 6, "S\0"}, - {86, 100, 3, 0, 16, 0, TIMEBASE_CUR, 0, "\0"}, - {101, 110, 3, 0, 15, 120, TIMEBASE_CUR, 0, "\0"}, - {101, 110, 8, 0, 1, 120, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Fiji[] = { - {98, 99, 10, 0, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {99, 100, 1, 0, 22, 180, TIMEBASE_CUR, 0, "\0"}, - {109, 109, 10, 7, 29, 120, TIMEBASE_CUR, 6, "S\0"}, - {110, 110, 2, 0, 25, 180, TIMEBASE_CUR, 0, "\0"}, - {110, 113, 9, 0, 21, 120, TIMEBASE_CUR, 6, "S\0"}, - {111, 111, 2, 0, 1, 180, TIMEBASE_CUR, 0, "\0"}, - {112, 113, 0, 0, 18, 180, TIMEBASE_CUR, 0, "\0"}, - {114, 114, 0, 0, 18, 120, TIMEBASE_CUR, 0, "\0"}, - {114, 255, 10, 0, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {115, 255, 0, 0, 15, 180, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Finland[] = { - {42, 42, 3, 7, 2, 1440, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 9, 7, 4, 60, TIMEBASE_CUR, 0, "\0"}, - {81, 82, 2, 0, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {81, 82, 8, 0, 24, 180, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_France[] = { - {16, 16, 5, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {16, 19, 9, 0, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {17, 17, 2, 7, 24, 1380, TIMEBASE_STD, 6, "S\0"}, - {18, 18, 2, 7, 9, 1380, TIMEBASE_STD, 6, "S\0"}, - {19, 19, 2, 7, 1, 1380, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 1, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 9, 7, 23, 1380, TIMEBASE_STD, 0, "\0"}, - {21, 21, 2, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {21, 21, 9, 7, 25, 1380, TIMEBASE_STD, 0, "\0"}, - {22, 22, 2, 7, 25, 1380, TIMEBASE_STD, 6, "S\0"}, - {22, 38, 9, 6, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {23, 23, 4, 7, 26, 1380, TIMEBASE_STD, 6, "S\0"}, - {24, 24, 2, 7, 29, 1380, TIMEBASE_STD, 6, "S\0"}, - {25, 25, 3, 7, 4, 1380, TIMEBASE_STD, 6, "S\0"}, - {26, 26, 3, 7, 17, 1380, TIMEBASE_STD, 6, "S\0"}, - {27, 27, 3, 7, 9, 1380, TIMEBASE_STD, 6, "S\0"}, - {28, 28, 3, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {29, 29, 3, 7, 20, 1380, TIMEBASE_STD, 6, "S\0"}, - {30, 30, 3, 7, 12, 1380, TIMEBASE_STD, 6, "S\0"}, - {31, 31, 3, 7, 18, 1380, TIMEBASE_STD, 6, "S\0"}, - {32, 32, 3, 7, 2, 1380, TIMEBASE_STD, 6, "S\0"}, - {33, 33, 2, 7, 25, 1380, TIMEBASE_STD, 6, "S\0"}, - {34, 34, 3, 7, 7, 1380, TIMEBASE_STD, 6, "S\0"}, - {35, 35, 2, 7, 30, 1380, TIMEBASE_STD, 6, "S\0"}, - {36, 36, 3, 7, 18, 1380, TIMEBASE_STD, 6, "S\0"}, - {37, 37, 3, 7, 3, 1380, TIMEBASE_STD, 6, "S\0"}, - {38, 38, 2, 7, 26, 1380, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 3, 7, 15, 1380, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 10, 7, 18, 1380, TIMEBASE_STD, 0, "\0"}, - {40, 40, 1, 7, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {41, 41, 4, 7, 5, 0, TIMEBASE_CUR, 12, "M\0"}, - {41, 41, 9, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 2, 7, 9, 0, TIMEBASE_CUR, 12, "M\0"}, - {42, 42, 10, 7, 2, 180, TIMEBASE_CUR, 6, "S\0"}, - {43, 43, 2, 7, 29, 120, TIMEBASE_CUR, 12, "M\0"}, - {43, 43, 9, 7, 4, 180, TIMEBASE_CUR, 6, "S\0"}, - {44, 44, 3, 7, 3, 120, TIMEBASE_CUR, 12, "M\0"}, - {44, 44, 9, 7, 8, 60, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 3, 7, 2, 120, TIMEBASE_CUR, 12, "M\0"}, - {45, 45, 8, 7, 16, 180, TIMEBASE_CUR, 0, "\0"}, - {76, 76, 2, 7, 28, 60, TIMEBASE_CUR, 6, "S\0"}, - {76, 76, 8, 7, 26, 60, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_GB_Eire[] = { - {16, 16, 4, 7, 21, 120, TIMEBASE_STD, 6, "BST\0"}, - {16, 16, 9, 7, 1, 120, TIMEBASE_STD, 0, "GMT\0"}, - {17, 17, 3, 7, 8, 120, TIMEBASE_STD, 6, "BST\0"}, - {17, 17, 8, 7, 17, 120, TIMEBASE_STD, 0, "GMT\0"}, - {18, 18, 2, 7, 24, 120, TIMEBASE_STD, 6, "BST\0"}, - {18, 18, 8, 7, 30, 120, TIMEBASE_STD, 0, "GMT\0"}, - {19, 19, 2, 7, 30, 120, TIMEBASE_STD, 6, "BST\0"}, - {19, 19, 8, 7, 29, 120, TIMEBASE_STD, 0, "GMT\0"}, - {20, 20, 2, 7, 28, 120, TIMEBASE_STD, 6, "BST\0"}, - {20, 20, 9, 7, 25, 120, TIMEBASE_STD, 0, "GMT\0"}, - {21, 21, 3, 7, 3, 120, TIMEBASE_STD, 6, "BST\0"}, - {21, 21, 9, 7, 3, 120, TIMEBASE_STD, 0, "GMT\0"}, - {22, 22, 2, 7, 26, 120, TIMEBASE_STD, 6, "BST\0"}, - {22, 22, 9, 7, 8, 120, TIMEBASE_STD, 0, "GMT\0"}, - {23, 23, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {23, 24, 8, 0, 16, 120, TIMEBASE_STD, 0, "GMT\0"}, - {24, 24, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {25, 26, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {25, 38, 9, 0, 2, 120, TIMEBASE_STD, 0, "GMT\0"}, - {27, 27, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {28, 29, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {30, 30, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {31, 32, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {33, 33, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {34, 34, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {35, 35, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {36, 37, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {38, 38, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {39, 39, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {39, 39, 10, 0, 16, 120, TIMEBASE_STD, 0, "GMT\0"}, - {40, 40, 1, 0, 23, 120, TIMEBASE_STD, 6, "BST\0"}, - {41, 41, 4, 0, 2, 60, TIMEBASE_STD, 12, "BDST\0"}, - {41, 43, 7, 0, 9, 60, TIMEBASE_STD, 6, "BST\0"}, - {42, 44, 3, 0, 2, 60, TIMEBASE_STD, 12, "BDST\0"}, - {44, 44, 8, 0, 16, 60, TIMEBASE_STD, 6, "BST\0"}, - {45, 45, 3, 1, 2, 60, TIMEBASE_STD, 12, "BDST\0"}, - {45, 45, 6, 0, 9, 60, TIMEBASE_STD, 6, "BST\0"}, - {45, 46, 9, 0, 2, 120, TIMEBASE_STD, 0, "GMT\0"}, - {46, 46, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {47, 47, 2, 7, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {47, 47, 3, 7, 13, 60, TIMEBASE_STD, 12, "BDST\0"}, - {47, 47, 7, 7, 10, 60, TIMEBASE_STD, 6, "BST\0"}, - {47, 47, 10, 7, 2, 120, TIMEBASE_STD, 0, "GMT\0"}, - {48, 48, 2, 7, 14, 120, TIMEBASE_STD, 6, "BST\0"}, - {48, 48, 9, 7, 31, 120, TIMEBASE_STD, 0, "GMT\0"}, - {49, 49, 3, 7, 3, 120, TIMEBASE_STD, 6, "BST\0"}, - {49, 49, 9, 7, 30, 120, TIMEBASE_STD, 0, "GMT\0"}, - {50, 52, 3, 0, 14, 120, TIMEBASE_STD, 6, "BST\0"}, - {50, 52, 9, 0, 21, 120, TIMEBASE_STD, 0, "GMT\0"}, - {53, 53, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {53, 60, 9, 0, 2, 120, TIMEBASE_STD, 0, "GMT\0"}, - {54, 54, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {55, 56, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {57, 57, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {58, 59, 3, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {60, 60, 3, 0, 9, 120, TIMEBASE_STD, 6, "BST\0"}, - {61, 63, 2, 0, 25, 120, TIMEBASE_STD, 6, "BST\0"}, - {61, 68, 9, 0, 23, 120, TIMEBASE_STD, 0, "GMT\0"}, - {64, 67, 2, 0, 19, 120, TIMEBASE_STD, 6, "BST\0"}, - {68, 68, 1, 7, 18, 120, TIMEBASE_STD, 6, "BST\0"}, - {72, 80, 2, 0, 16, 120, TIMEBASE_STD, 6, "BST\0"}, - {72, 80, 9, 0, 23, 120, TIMEBASE_STD, 0, "GMT\0"}, - {81, 95, 2, 0, 25, 60, TIMEBASE_UTC, 6, "BST\0"}, - {81, 89, 9, 0, 23, 60, TIMEBASE_UTC, 0, "GMT\0"}, - {90, 95, 9, 0, 22, 60, TIMEBASE_UTC, 0, "GMT\0"}, -}; -static const struct lc_timezone_rule rules_Germany[] = { - {46, 46, 3, 7, 14, 120, TIMEBASE_STD, 6, "S\0"}, - {46, 46, 9, 7, 7, 120, TIMEBASE_STD, 0, "\0"}, - {47, 47, 3, 7, 6, 180, TIMEBASE_STD, 6, "S\0"}, - {47, 47, 4, 7, 11, 120, TIMEBASE_STD, 12, "M\0"}, - {47, 47, 5, 7, 29, 180, TIMEBASE_CUR, 6, "S\0"}, - {47, 49, 9, 0, 1, 120, TIMEBASE_STD, 0, "\0"}, - {48, 48, 3, 7, 18, 120, TIMEBASE_STD, 6, "S\0"}, - {49, 49, 3, 7, 10, 120, TIMEBASE_STD, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Ghana[] = { - {20, 42, 8, 7, 1, 0, TIMEBASE_CUR, 2, "GHST\0"}, - {20, 42, 11, 7, 31, 0, TIMEBASE_CUR, 0, "GMT\0"}, -}; -static const struct lc_timezone_rule rules_Greece[] = { - {32, 32, 6, 7, 7, 0, TIMEBASE_CUR, 6, "S\0"}, - {32, 32, 8, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {41, 41, 3, 7, 7, 0, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 10, 7, 2, 180, TIMEBASE_CUR, 0, "\0"}, - {43, 43, 2, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {43, 43, 9, 7, 4, 0, TIMEBASE_CUR, 0, "\0"}, - {52, 52, 6, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {52, 52, 10, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {75, 75, 3, 7, 12, 0, TIMEBASE_STD, 6, "S\0"}, - {75, 75, 10, 7, 26, 0, TIMEBASE_STD, 0, "\0"}, - {76, 76, 3, 7, 11, 120, TIMEBASE_STD, 6, "S\0"}, - {76, 76, 9, 7, 10, 120, TIMEBASE_STD, 0, "\0"}, - {77, 78, 3, 0, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {77, 77, 8, 7, 26, 120, TIMEBASE_STD, 0, "\0"}, - {78, 78, 8, 7, 24, 240, TIMEBASE_CUR, 0, "\0"}, - {79, 79, 3, 7, 1, 540, TIMEBASE_CUR, 6, "S\0"}, - {79, 79, 8, 7, 29, 120, TIMEBASE_CUR, 0, "\0"}, - {80, 80, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {80, 80, 8, 7, 28, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Guat[] = { - {73, 73, 10, 7, 25, 0, TIMEBASE_CUR, 6, "D\0"}, - {74, 74, 1, 7, 24, 0, TIMEBASE_CUR, 0, "S\0"}, - {83, 83, 4, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {83, 83, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {91, 91, 2, 7, 23, 0, TIMEBASE_CUR, 6, "D\0"}, - {91, 91, 8, 7, 7, 0, TIMEBASE_CUR, 0, "S\0"}, - {106, 106, 3, 7, 30, 0, TIMEBASE_CUR, 6, "D\0"}, - {106, 106, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_HK[] = { - {41, 41, 3, 7, 1, 210, TIMEBASE_CUR, 6, "S\0"}, - {41, 41, 8, 7, 30, 210, TIMEBASE_CUR, 0, "\0"}, - {46, 46, 3, 7, 20, 210, TIMEBASE_CUR, 6, "S\0"}, - {46, 46, 11, 7, 1, 210, TIMEBASE_CUR, 0, "\0"}, - {47, 47, 3, 7, 13, 210, TIMEBASE_CUR, 6, "S\0"}, - {47, 47, 11, 7, 30, 210, TIMEBASE_CUR, 0, "\0"}, - {48, 48, 4, 7, 2, 210, TIMEBASE_CUR, 6, "S\0"}, - {48, 51, 9, 0, 25, 210, TIMEBASE_CUR, 0, "\0"}, - {49, 53, 3, 0, 1, 210, TIMEBASE_CUR, 6, "S\0"}, - {52, 52, 9, 7, 25, 210, TIMEBASE_CUR, 0, "\0"}, - {53, 53, 10, 7, 1, 210, TIMEBASE_CUR, 0, "\0"}, - {54, 64, 2, 0, 18, 210, TIMEBASE_CUR, 6, "S\0"}, - {54, 54, 9, 7, 31, 210, TIMEBASE_CUR, 0, "\0"}, - {55, 64, 10, 0, 1, 210, TIMEBASE_CUR, 0, "\0"}, - {65, 76, 3, 0, 16, 210, TIMEBASE_CUR, 6, "S\0"}, - {65, 76, 9, 0, 16, 210, TIMEBASE_CUR, 0, "\0"}, - {73, 73, 11, 7, 30, 210, TIMEBASE_CUR, 6, "S\0"}, - {79, 79, 4, 0, 8, 210, TIMEBASE_CUR, 6, "S\0"}, - {79, 79, 9, 0, 16, 210, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Haiti[] = { - {83, 83, 4, 7, 8, 0, TIMEBASE_CUR, 6, "D\0"}, - {83, 87, 9, 0, 25, 0, TIMEBASE_CUR, 0, "S\0"}, - {84, 87, 3, 0, 24, 0, TIMEBASE_CUR, 6, "D\0"}, - {88, 97, 3, 0, 1, 60, TIMEBASE_STD, 6, "D\0"}, - {88, 97, 9, 0, 25, 60, TIMEBASE_STD, 0, "S\0"}, - {105, 106, 3, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {105, 106, 9, 0, 25, 0, TIMEBASE_CUR, 0, "S\0"}, - {112, 115, 2, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {112, 115, 10, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {117, 255, 2, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {117, 255, 10, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Halifax[] = { - {16, 16, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {16, 16, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {20, 20, 4, 7, 9, 0, TIMEBASE_CUR, 6, "D\0"}, - {20, 20, 7, 7, 29, 0, TIMEBASE_CUR, 0, "S\0"}, - {21, 21, 4, 7, 6, 0, TIMEBASE_CUR, 6, "D\0"}, - {21, 22, 8, 7, 5, 0, TIMEBASE_CUR, 0, "S\0"}, - {22, 22, 3, 7, 30, 0, TIMEBASE_CUR, 6, "D\0"}, - {23, 25, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {23, 23, 8, 7, 4, 0, TIMEBASE_CUR, 0, "S\0"}, - {24, 24, 8, 7, 15, 0, TIMEBASE_CUR, 0, "S\0"}, - {25, 25, 8, 7, 28, 0, TIMEBASE_CUR, 0, "S\0"}, - {26, 26, 4, 7, 16, 0, TIMEBASE_CUR, 6, "D\0"}, - {26, 26, 8, 7, 13, 0, TIMEBASE_CUR, 0, "S\0"}, - {27, 27, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {27, 27, 8, 7, 26, 0, TIMEBASE_CUR, 0, "S\0"}, - {28, 31, 4, 0, 8, 0, TIMEBASE_CUR, 6, "D\0"}, - {28, 28, 8, 7, 9, 0, TIMEBASE_CUR, 0, "S\0"}, - {29, 29, 8, 7, 3, 0, TIMEBASE_CUR, 0, "S\0"}, - {30, 30, 8, 7, 15, 0, TIMEBASE_CUR, 0, "S\0"}, - {31, 32, 8, 1, 24, 0, TIMEBASE_CUR, 0, "S\0"}, - {32, 32, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {33, 33, 3, 7, 30, 0, TIMEBASE_CUR, 6, "D\0"}, - {33, 33, 9, 7, 2, 0, TIMEBASE_CUR, 0, "S\0"}, - {34, 34, 4, 7, 20, 0, TIMEBASE_CUR, 6, "D\0"}, - {34, 34, 8, 7, 16, 0, TIMEBASE_CUR, 0, "S\0"}, - {35, 35, 5, 7, 2, 0, TIMEBASE_CUR, 6, "D\0"}, - {35, 35, 8, 7, 30, 0, TIMEBASE_CUR, 0, "S\0"}, - {36, 36, 5, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {36, 36, 8, 7, 14, 0, TIMEBASE_CUR, 0, "S\0"}, - {37, 38, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {37, 41, 8, 1, 24, 0, TIMEBASE_CUR, 0, "S\0"}, - {39, 39, 4, 7, 28, 0, TIMEBASE_CUR, 6, "D\0"}, - {40, 41, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {46, 49, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 49, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {51, 54, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {51, 54, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {56, 59, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {56, 59, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {62, 73, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {62, 73, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Holiday[] = { - {92, 93, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {93, 94, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Hond[] = { - {87, 88, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {87, 88, 8, 0, 24, 0, TIMEBASE_CUR, 0, "S\0"}, - {106, 106, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {106, 106, 7, 1, 1, 0, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Hungary[] = { - {18, 18, 3, 7, 1, 180, TIMEBASE_CUR, 6, "S\0"}, - {18, 18, 8, 7, 16, 180, TIMEBASE_CUR, 0, "\0"}, - {19, 19, 3, 7, 15, 180, TIMEBASE_CUR, 6, "S\0"}, - {19, 19, 10, 7, 24, 180, TIMEBASE_CUR, 0, "\0"}, - {45, 45, 4, 7, 1, 1380, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 10, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {46, 46, 2, 7, 31, 120, TIMEBASE_STD, 6, "S\0"}, - {46, 49, 9, 0, 1, 120, TIMEBASE_STD, 0, "\0"}, - {47, 49, 3, 0, 4, 120, TIMEBASE_STD, 6, "S\0"}, - {50, 50, 3, 7, 17, 120, TIMEBASE_STD, 6, "S\0"}, - {50, 50, 9, 7, 23, 120, TIMEBASE_STD, 0, "\0"}, - {54, 55, 4, 7, 23, 0, TIMEBASE_CUR, 6, "S\0"}, - {54, 55, 9, 7, 3, 0, TIMEBASE_CUR, 0, "\0"}, - {56, 56, 5, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {56, 56, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {57, 57, 5, 0, 1, 60, TIMEBASE_CUR, 6, "S\0"}, - {57, 57, 8, 0, 24, 180, TIMEBASE_CUR, 0, "\0"}, - {80, 80, 3, 7, 6, 60, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Iceland[] = { - {17, 19, 1, 7, 19, 1380, TIMEBASE_CUR, 6, "S\0"}, - {17, 17, 9, 7, 21, 60, TIMEBASE_CUR, 0, "\0"}, - {18, 19, 10, 7, 16, 60, TIMEBASE_CUR, 0, "\0"}, - {21, 21, 2, 7, 19, 1380, TIMEBASE_CUR, 6, "S\0"}, - {21, 21, 5, 7, 23, 60, TIMEBASE_CUR, 0, "\0"}, - {39, 39, 3, 7, 29, 1380, TIMEBASE_CUR, 6, "S\0"}, - {39, 39, 9, 7, 29, 120, TIMEBASE_CUR, 0, "\0"}, - {40, 40, 1, 7, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {40, 41, 10, 0, 2, 60, TIMEBASE_STD, 0, "\0"}, - {41, 42, 2, 0, 2, 60, TIMEBASE_STD, 6, "S\0"}, - {42, 48, 9, 0, 22, 60, TIMEBASE_STD, 0, "\0"}, - {43, 46, 2, 0, 1, 60, TIMEBASE_STD, 6, "S\0"}, - {47, 67, 3, 0, 1, 60, TIMEBASE_STD, 6, "S\0"}, - {49, 49, 9, 7, 30, 60, TIMEBASE_STD, 0, "\0"}, - {50, 66, 9, 0, 22, 60, TIMEBASE_STD, 0, "\0"}, - {67, 67, 9, 7, 29, 60, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Indianapolis[] = { - {41, 41, 5, 7, 22, 120, TIMEBASE_CUR, 6, "D\0"}, - {41, 54, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {46, 54, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_Iran[] = { - {78, 80, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {78, 78, 9, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {79, 79, 8, 7, 19, 0, TIMEBASE_CUR, 0, "S\0"}, - {80, 80, 8, 7, 23, 0, TIMEBASE_CUR, 0, "S\0"}, - {91, 91, 4, 7, 3, 0, TIMEBASE_CUR, 6, "D\0"}, - {91, 95, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {92, 95, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {96, 96, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {96, 96, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {97, 99, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {97, 99, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {100, 100, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {100, 100, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {101, 103, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {101, 103, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {104, 104, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {104, 104, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {105, 105, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {105, 105, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {108, 108, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {108, 108, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {109, 111, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {109, 111, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {112, 112, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {112, 112, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {113, 115, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {113, 115, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {116, 116, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {116, 116, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {117, 119, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {117, 119, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {120, 120, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {120, 120, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {121, 123, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {121, 123, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {124, 124, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {124, 124, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {125, 127, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {125, 127, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {128, 129, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {128, 129, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {130, 131, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {130, 131, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {132, 133, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {132, 133, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, - {134, 135, 2, 7, 22, 0, TIMEBASE_CUR, 6, "D\0"}, - {134, 135, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {136, 255, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {136, 255, 8, 7, 21, 0, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Iraq[] = { - {82, 82, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {82, 84, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {83, 83, 2, 7, 31, 0, TIMEBASE_CUR, 6, "D\0"}, - {84, 85, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {85, 90, 8, 0, 24, 60, TIMEBASE_STD, 0, "S\0"}, - {86, 90, 2, 0, 25, 60, TIMEBASE_STD, 6, "D\0"}, - {91, 107, 3, 7, 1, 180, TIMEBASE_STD, 6, "D\0"}, - {91, 107, 9, 7, 1, 180, TIMEBASE_STD, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Italy[] = { - {16, 16, 5, 7, 3, 1440, TIMEBASE_CUR, 6, "S\0"}, - {16, 17, 8, 7, 30, 1440, TIMEBASE_CUR, 0, "\0"}, - {17, 17, 2, 7, 31, 1440, TIMEBASE_CUR, 6, "S\0"}, - {18, 18, 2, 7, 9, 1440, TIMEBASE_CUR, 6, "S\0"}, - {18, 18, 9, 7, 6, 1440, TIMEBASE_CUR, 0, "\0"}, - {19, 19, 2, 7, 1, 1440, TIMEBASE_CUR, 6, "S\0"}, - {19, 19, 9, 7, 4, 1440, TIMEBASE_CUR, 0, "\0"}, - {20, 20, 2, 7, 20, 1440, TIMEBASE_CUR, 6, "S\0"}, - {20, 20, 8, 7, 18, 1440, TIMEBASE_CUR, 0, "\0"}, - {40, 40, 5, 7, 14, 1440, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 10, 7, 2, 120, TIMEBASE_STD, 0, "\0"}, - {43, 43, 2, 7, 29, 120, TIMEBASE_STD, 6, "S\0"}, - {43, 43, 9, 7, 4, 120, TIMEBASE_STD, 0, "\0"}, - {44, 44, 3, 7, 2, 120, TIMEBASE_STD, 6, "S\0"}, - {44, 44, 8, 7, 17, 120, TIMEBASE_STD, 0, "\0"}, - {45, 45, 3, 7, 2, 120, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 8, 7, 15, 60, TIMEBASE_CUR, 0, "\0"}, - {46, 46, 2, 7, 17, 120, TIMEBASE_STD, 6, "S\0"}, - {46, 46, 9, 7, 6, 120, TIMEBASE_STD, 0, "\0"}, - {47, 47, 2, 7, 16, 0, TIMEBASE_STD, 6, "S\0"}, - {47, 47, 9, 7, 5, 0, TIMEBASE_STD, 0, "\0"}, - {48, 48, 1, 7, 29, 120, TIMEBASE_STD, 6, "S\0"}, - {48, 48, 9, 7, 3, 120, TIMEBASE_STD, 0, "\0"}, - {66, 68, 4, 0, 22, 0, TIMEBASE_STD, 6, "S\0"}, - {66, 66, 8, 7, 24, 1440, TIMEBASE_CUR, 0, "\0"}, - {67, 69, 8, 0, 22, 0, TIMEBASE_STD, 0, "\0"}, - {69, 69, 5, 7, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {70, 70, 4, 7, 31, 0, TIMEBASE_STD, 6, "S\0"}, - {70, 70, 8, 0, 24, 0, TIMEBASE_STD, 0, "\0"}, - {71, 72, 4, 0, 22, 0, TIMEBASE_STD, 6, "S\0"}, - {71, 71, 8, 0, 24, 0, TIMEBASE_STD, 0, "\0"}, - {72, 72, 9, 7, 1, 0, TIMEBASE_STD, 0, "\0"}, - {73, 73, 5, 7, 3, 0, TIMEBASE_STD, 6, "S\0"}, - {73, 74, 8, 0, 24, 0, TIMEBASE_STD, 0, "\0"}, - {74, 74, 4, 7, 26, 0, TIMEBASE_STD, 6, "S\0"}, - {75, 75, 5, 7, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {75, 77, 8, 0, 24, 0, TIMEBASE_STD, 0, "\0"}, - {76, 76, 4, 7, 30, 0, TIMEBASE_STD, 6, "S\0"}, - {77, 79, 4, 0, 22, 0, TIMEBASE_STD, 6, "S\0"}, - {78, 78, 9, 7, 1, 0, TIMEBASE_STD, 0, "\0"}, - {79, 79, 8, 7, 30, 0, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Japan[] = { - {48, 48, 4, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {48, 51, 8, 6, 8, 120, TIMEBASE_CUR, 0, "S\0"}, - {49, 49, 3, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {50, 51, 4, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_Jordan[] = { - {73, 73, 5, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {73, 75, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {74, 77, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {76, 76, 10, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {77, 77, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 3, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 8, 7, 30, 0, TIMEBASE_CUR, 0, "\0"}, - {85, 85, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {85, 85, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {86, 88, 3, 5, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {86, 90, 9, 5, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {89, 89, 4, 7, 8, 0, TIMEBASE_CUR, 6, "S\0"}, - {90, 90, 3, 7, 27, 0, TIMEBASE_CUR, 6, "S\0"}, - {91, 91, 3, 7, 17, 0, TIMEBASE_CUR, 6, "S\0"}, - {91, 91, 8, 7, 27, 0, TIMEBASE_CUR, 0, "\0"}, - {92, 92, 3, 7, 10, 0, TIMEBASE_CUR, 6, "S\0"}, - {92, 93, 9, 5, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {93, 98, 3, 5, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {94, 94, 8, 5, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {95, 98, 8, 5, 15, 0, TIMEBASE_STD, 0, "\0"}, - {99, 99, 6, 7, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {99, 102, 8, 5, 24, 0, TIMEBASE_STD, 0, "\0"}, - {100, 101, 2, 4, 25, 0, TIMEBASE_STD, 6, "S\0"}, - {102, 112, 2, 4, 25, 1440, TIMEBASE_CUR, 6, "S\0"}, - {103, 103, 9, 7, 24, 0, TIMEBASE_STD, 0, "\0"}, - {104, 104, 9, 7, 15, 0, TIMEBASE_STD, 0, "\0"}, - {105, 105, 8, 5, 24, 0, TIMEBASE_STD, 0, "\0"}, - {106, 111, 9, 5, 25, 0, TIMEBASE_STD, 0, "\0"}, - {113, 113, 11, 7, 20, 0, TIMEBASE_CUR, 0, "\0"}, - {114, 255, 2, 4, 25, 1440, TIMEBASE_CUR, 6, "S\0"}, - {114, 255, 9, 5, 25, 0, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Kyrgyz[] = { - {92, 96, 3, 0, 7, 0, TIMEBASE_STD, 6, "S\0"}, - {92, 96, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {97, 105, 2, 0, 25, 150, TIMEBASE_CUR, 6, "S\0"}, - {97, 104, 9, 0, 25, 150, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_LH[] = { - {81, 84, 9, 0, 25, 120, TIMEBASE_CUR, 6, "D\0"}, - {82, 85, 2, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {85, 85, 9, 0, 25, 120, TIMEBASE_CUR, 3, "D\0"}, - {86, 89, 2, 0, 15, 120, TIMEBASE_CUR, 0, "S\0"}, - {86, 86, 9, 7, 19, 120, TIMEBASE_CUR, 3, "D\0"}, - {87, 99, 9, 0, 25, 120, TIMEBASE_CUR, 3, "D\0"}, - {90, 95, 2, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {96, 105, 2, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {100, 100, 7, 0, 25, 120, TIMEBASE_CUR, 3, "D\0"}, - {101, 107, 9, 0, 25, 120, TIMEBASE_CUR, 3, "D\0"}, - {106, 106, 3, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {107, 107, 2, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {108, 255, 3, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {108, 255, 9, 0, 1, 120, TIMEBASE_CUR, 3, "D\0"}, -}; -static const struct lc_timezone_rule rules_Latvia[] = { - {89, 96, 2, 0, 25, 120, TIMEBASE_STD, 6, "S\0"}, - {89, 96, 8, 0, 24, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Lebanon[] = { - {20, 20, 2, 7, 28, 0, TIMEBASE_CUR, 6, "S\0"}, - {20, 20, 9, 7, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {21, 21, 3, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {21, 21, 9, 7, 3, 0, TIMEBASE_CUR, 0, "\0"}, - {22, 22, 2, 7, 26, 0, TIMEBASE_CUR, 6, "S\0"}, - {22, 22, 9, 7, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {23, 23, 3, 7, 22, 0, TIMEBASE_CUR, 6, "S\0"}, - {23, 23, 8, 7, 16, 0, TIMEBASE_CUR, 0, "\0"}, - {57, 61, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {57, 61, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {72, 72, 5, 7, 22, 0, TIMEBASE_CUR, 6, "S\0"}, - {72, 77, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {73, 77, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 3, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 8, 7, 30, 0, TIMEBASE_CUR, 0, "\0"}, - {84, 87, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {84, 91, 9, 7, 16, 0, TIMEBASE_CUR, 0, "\0"}, - {88, 88, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {89, 89, 4, 7, 10, 0, TIMEBASE_CUR, 6, "S\0"}, - {90, 92, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {92, 92, 9, 7, 4, 0, TIMEBASE_CUR, 0, "\0"}, - {93, 255, 2, 0, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 98, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {99, 255, 9, 0, 25, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Libya[] = { - {51, 51, 9, 7, 14, 120, TIMEBASE_CUR, 6, "S\0"}, - {51, 51, 11, 7, 31, 1440, TIMEBASE_CUR, 0, "\0"}, - {53, 53, 9, 7, 9, 120, TIMEBASE_CUR, 6, "S\0"}, - {53, 53, 11, 7, 31, 1440, TIMEBASE_CUR, 0, "\0"}, - {55, 55, 8, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {55, 55, 11, 7, 31, 1440, TIMEBASE_CUR, 0, "\0"}, - {82, 84, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {82, 85, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {85, 85, 3, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {86, 86, 3, 7, 4, 0, TIMEBASE_CUR, 6, "S\0"}, - {86, 86, 9, 7, 3, 0, TIMEBASE_CUR, 0, "\0"}, - {87, 89, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {87, 89, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {97, 97, 3, 7, 4, 0, TIMEBASE_CUR, 6, "S\0"}, - {97, 97, 9, 7, 4, 0, TIMEBASE_CUR, 0, "\0"}, - {113, 113, 2, 5, 25, 60, TIMEBASE_CUR, 6, "S\0"}, - {113, 113, 9, 5, 25, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Louisville[] = { - {21, 21, 4, 7, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {21, 21, 8, 7, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {41, 61, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {41, 41, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {46, 46, 5, 7, 2, 120, TIMEBASE_CUR, 0, "S\0"}, - {50, 55, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {56, 60, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Lux[] = { - {16, 16, 4, 7, 14, 1380, TIMEBASE_CUR, 6, "S\0"}, - {16, 16, 9, 7, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {17, 17, 3, 7, 28, 1380, TIMEBASE_CUR, 6, "S\0"}, - {17, 17, 8, 7, 17, 60, TIMEBASE_CUR, 0, "\0"}, - {18, 18, 3, 1, 15, 120, TIMEBASE_STD, 6, "S\0"}, - {18, 18, 8, 1, 15, 120, TIMEBASE_STD, 0, "\0"}, - {19, 19, 2, 7, 1, 1380, TIMEBASE_CUR, 6, "S\0"}, - {19, 19, 9, 7, 5, 180, TIMEBASE_CUR, 0, "\0"}, - {20, 20, 1, 7, 14, 1380, TIMEBASE_CUR, 6, "S\0"}, - {20, 20, 9, 7, 24, 120, TIMEBASE_CUR, 0, "\0"}, - {21, 21, 2, 7, 14, 1380, TIMEBASE_CUR, 6, "S\0"}, - {21, 21, 9, 7, 26, 120, TIMEBASE_CUR, 0, "\0"}, - {22, 22, 2, 7, 25, 1380, TIMEBASE_CUR, 6, "S\0"}, - {22, 22, 9, 0, 2, 60, TIMEBASE_CUR, 0, "\0"}, - {23, 23, 3, 7, 21, 1380, TIMEBASE_CUR, 6, "S\0"}, - {23, 23, 9, 0, 2, 120, TIMEBASE_CUR, 0, "\0"}, - {24, 24, 2, 7, 29, 1380, TIMEBASE_CUR, 6, "S\0"}, - {24, 28, 9, 0, 2, 60, TIMEBASE_CUR, 0, "\0"}, - {25, 25, 3, 7, 5, 1380, TIMEBASE_CUR, 6, "S\0"}, - {26, 26, 3, 7, 17, 1380, TIMEBASE_CUR, 6, "S\0"}, - {27, 27, 3, 7, 9, 1380, TIMEBASE_CUR, 6, "S\0"}, - {28, 28, 3, 7, 14, 1380, TIMEBASE_CUR, 6, "S\0"}, - {29, 29, 3, 7, 20, 1380, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Macau[] = { - {61, 62, 2, 0, 16, 210, TIMEBASE_CUR, 6, "D\0"}, - {61, 64, 10, 0, 1, 210, TIMEBASE_CUR, 0, "S\0"}, - {63, 63, 2, 0, 16, 0, TIMEBASE_CUR, 6, "D\0"}, - {64, 64, 2, 0, 16, 210, TIMEBASE_CUR, 6, "D\0"}, - {65, 65, 2, 0, 16, 0, TIMEBASE_CUR, 6, "D\0"}, - {65, 65, 9, 7, 31, 0, TIMEBASE_CUR, 0, "S\0"}, - {66, 71, 3, 0, 16, 210, TIMEBASE_CUR, 6, "D\0"}, - {66, 71, 9, 0, 16, 210, TIMEBASE_CUR, 0, "S\0"}, - {72, 74, 3, 0, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {72, 73, 9, 0, 15, 0, TIMEBASE_CUR, 0, "S\0"}, - {74, 77, 9, 0, 15, 210, TIMEBASE_CUR, 0, "S\0"}, - {75, 77, 3, 0, 15, 210, TIMEBASE_CUR, 6, "D\0"}, - {78, 80, 3, 0, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {78, 80, 9, 0, 15, 0, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Malta[] = { - {73, 73, 2, 7, 31, 0, TIMEBASE_STD, 6, "S\0"}, - {73, 73, 8, 7, 29, 0, TIMEBASE_STD, 0, "\0"}, - {74, 74, 3, 7, 21, 0, TIMEBASE_STD, 6, "S\0"}, - {74, 74, 8, 7, 16, 0, TIMEBASE_STD, 0, "\0"}, - {75, 79, 3, 0, 15, 120, TIMEBASE_CUR, 6, "S\0"}, - {75, 80, 8, 0, 15, 120, TIMEBASE_CUR, 0, "\0"}, - {80, 80, 2, 7, 31, 120, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Marengo[] = { - {51, 51, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {51, 51, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {54, 60, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {54, 60, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Mauritius[] = { - {82, 82, 9, 7, 10, 0, TIMEBASE_CUR, 6, "S\0"}, - {83, 83, 2, 7, 21, 0, TIMEBASE_CUR, 0, "\0"}, - {108, 108, 9, 0, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {109, 109, 2, 0, 25, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Menominee[] = { - {46, 46, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {66, 66, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {66, 66, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Mexico[] = { - {39, 39, 1, 7, 5, 0, TIMEBASE_CUR, 6, "D\0"}, - {39, 39, 5, 7, 25, 0, TIMEBASE_CUR, 0, "S\0"}, - {40, 40, 11, 7, 9, 0, TIMEBASE_CUR, 6, "D\0"}, - {41, 41, 3, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {43, 43, 11, 7, 16, 0, TIMEBASE_CUR, 6, "W\0"}, - {44, 44, 4, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {50, 50, 1, 7, 12, 0, TIMEBASE_CUR, 6, "D\0"}, - {50, 50, 6, 7, 30, 0, TIMEBASE_CUR, 0, "S\0"}, - {96, 100, 3, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {96, 100, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {101, 101, 4, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {101, 101, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {102, 255, 3, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {102, 255, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Moldova[] = { - {97, 255, 2, 0, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {97, 255, 9, 0, 25, 180, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Moncton[] = { - {33, 35, 5, 0, 8, 60, TIMEBASE_CUR, 6, "D\0"}, - {33, 35, 8, 0, 8, 60, TIMEBASE_CUR, 0, "S\0"}, - {36, 38, 5, 0, 1, 60, TIMEBASE_CUR, 6, "D\0"}, - {36, 38, 8, 0, 1, 60, TIMEBASE_CUR, 0, "S\0"}, - {39, 39, 4, 7, 27, 60, TIMEBASE_CUR, 6, "D\0"}, - {39, 41, 8, 6, 21, 60, TIMEBASE_CUR, 0, "S\0"}, - {40, 40, 4, 7, 19, 60, TIMEBASE_CUR, 6, "D\0"}, - {41, 41, 4, 7, 4, 60, TIMEBASE_CUR, 6, "D\0"}, - {46, 72, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 56, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {57, 72, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {93, 106, 3, 0, 1, 1, TIMEBASE_CUR, 6, "D\0"}, - {93, 106, 9, 0, 25, 1, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Mongol[] = { - {83, 84, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {83, 83, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {84, 98, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {85, 98, 2, 0, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {101, 101, 3, 6, 24, 120, TIMEBASE_CUR, 6, "S\0"}, - {101, 106, 8, 6, 24, 120, TIMEBASE_CUR, 0, "\0"}, - {102, 106, 2, 6, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {115, 116, 2, 6, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {115, 116, 8, 6, 24, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Morocco[] = { - {39, 39, 8, 7, 12, 0, TIMEBASE_CUR, 6, "S\0"}, - {39, 39, 10, 7, 19, 0, TIMEBASE_CUR, 0, "\0"}, - {40, 40, 1, 7, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 10, 7, 18, 0, TIMEBASE_CUR, 0, "\0"}, - {50, 50, 5, 7, 11, 0, TIMEBASE_CUR, 6, "S\0"}, - {50, 50, 9, 7, 29, 0, TIMEBASE_CUR, 0, "\0"}, - {67, 67, 5, 7, 3, 720, TIMEBASE_CUR, 6, "S\0"}, - {67, 67, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {74, 74, 5, 7, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {74, 74, 8, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {76, 77, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {76, 76, 7, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {77, 77, 8, 7, 28, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 7, 7, 4, 0, TIMEBASE_CUR, 0, "\0"}, - {108, 108, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {108, 108, 8, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {109, 109, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {109, 109, 7, 7, 21, 0, TIMEBASE_CUR, 0, "\0"}, - {110, 110, 4, 7, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {110, 110, 7, 7, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {111, 111, 3, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {111, 111, 6, 7, 31, 0, TIMEBASE_CUR, 0, "\0"}, - {112, 113, 3, 0, 24, 120, TIMEBASE_CUR, 6, "S\0"}, - {112, 112, 6, 7, 20, 180, TIMEBASE_CUR, 0, "\0"}, - {112, 112, 7, 7, 20, 120, TIMEBASE_CUR, 6, "S\0"}, - {112, 112, 8, 7, 30, 180, TIMEBASE_CUR, 0, "\0"}, - {113, 113, 6, 7, 7, 180, TIMEBASE_CUR, 0, "\0"}, - {113, 113, 7, 7, 10, 120, TIMEBASE_CUR, 6, "S\0"}, - {113, 255, 9, 0, 25, 180, TIMEBASE_CUR, 0, "\0"}, - {114, 121, 2, 0, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {114, 114, 5, 7, 28, 180, TIMEBASE_CUR, 0, "\0"}, - {114, 114, 7, 7, 2, 120, TIMEBASE_CUR, 6, "S\0"}, - {115, 115, 5, 7, 14, 180, TIMEBASE_CUR, 0, "\0"}, - {115, 115, 6, 7, 19, 120, TIMEBASE_CUR, 6, "S\0"}, - {116, 116, 5, 7, 5, 180, TIMEBASE_CUR, 0, "\0"}, - {116, 116, 6, 7, 10, 120, TIMEBASE_CUR, 6, "S\0"}, - {117, 117, 4, 7, 21, 180, TIMEBASE_CUR, 0, "\0"}, - {117, 117, 6, 7, 2, 120, TIMEBASE_CUR, 6, "S\0"}, - {118, 118, 4, 7, 13, 180, TIMEBASE_CUR, 0, "\0"}, - {118, 118, 5, 7, 17, 120, TIMEBASE_CUR, 6, "S\0"}, - {119, 119, 4, 7, 5, 180, TIMEBASE_CUR, 0, "\0"}, - {119, 119, 5, 7, 9, 120, TIMEBASE_CUR, 6, "S\0"}, - {120, 120, 3, 7, 19, 180, TIMEBASE_CUR, 0, "\0"}, - {120, 120, 4, 7, 24, 120, TIMEBASE_CUR, 6, "S\0"}, - {121, 121, 3, 7, 11, 180, TIMEBASE_CUR, 0, "\0"}, - {121, 121, 4, 7, 16, 120, TIMEBASE_CUR, 6, "S\0"}, - {122, 122, 4, 7, 8, 120, TIMEBASE_CUR, 6, "S\0"}, - {123, 123, 3, 7, 23, 120, TIMEBASE_CUR, 6, "S\0"}, - {124, 124, 3, 7, 14, 120, TIMEBASE_CUR, 6, "S\0"}, - {125, 125, 3, 7, 6, 120, TIMEBASE_CUR, 6, "S\0"}, - {126, 255, 2, 0, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {136, 136, 9, 7, 19, 180, TIMEBASE_CUR, 0, "\0"}, - {137, 137, 9, 7, 4, 180, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_NBorneo[] = { - {35, 41, 8, 7, 14, 0, TIMEBASE_CUR, 2, "TS\0"}, - {35, 41, 11, 7, 14, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_NC[] = { - {77, 78, 11, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 79, 1, 7, 27, 0, TIMEBASE_CUR, 0, "\0"}, - {96, 96, 11, 7, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {97, 97, 2, 7, 2, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_NT_YK[] = { - {18, 18, 3, 7, 14, 120, TIMEBASE_CUR, 6, "D\0"}, - {18, 18, 9, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {19, 19, 4, 7, 25, 120, TIMEBASE_CUR, 6, "D\0"}, - {19, 19, 10, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 1, 7, 9, 120, TIMEBASE_CUR, 6, "W\0"}, - {45, 45, 7, 7, 14, 1380, TIMEBASE_UTC, 6, "P\0"}, - {45, 45, 8, 7, 30, 120, TIMEBASE_CUR, 0, "S\0"}, - {65, 65, 3, 0, 24, 0, TIMEBASE_CUR, 12, "DD\0"}, - {65, 65, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {80, 86, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {80, 106, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {87, 106, 3, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_NYC[] = { - {20, 20, 2, 0, 25, 120, TIMEBASE_CUR, 6, "D\0"}, - {20, 20, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {21, 66, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {21, 54, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {55, 66, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_NZ[] = { - {27, 27, 10, 7, 6, 120, TIMEBASE_CUR, 6, "S\0"}, - {28, 28, 2, 7, 4, 120, TIMEBASE_CUR, 0, "M\0"}, - {28, 33, 9, 0, 8, 120, TIMEBASE_CUR, 3, "S\0"}, - {29, 33, 2, 0, 15, 120, TIMEBASE_CUR, 0, "M\0"}, - {34, 40, 3, 0, 24, 120, TIMEBASE_CUR, 0, "M\0"}, - {34, 40, 8, 0, 24, 120, TIMEBASE_CUR, 3, "S\0"}, - {45, 45, 11, 7, 31, 1440, TIMEBASE_CUR, 0, "S\0"}, - {74, 74, 10, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, - {75, 75, 1, 0, 22, 120, TIMEBASE_STD, 0, "S\0"}, - {75, 88, 9, 0, 25, 120, TIMEBASE_STD, 6, "D\0"}, - {76, 89, 2, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, - {89, 89, 9, 0, 8, 120, TIMEBASE_STD, 6, "D\0"}, - {90, 107, 2, 0, 15, 120, TIMEBASE_STD, 0, "S\0"}, - {90, 106, 9, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, - {107, 255, 8, 0, 24, 120, TIMEBASE_STD, 6, "D\0"}, - {108, 255, 3, 0, 1, 120, TIMEBASE_STD, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Namibia[] = { - {94, 255, 8, 0, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {95, 255, 3, 0, 1, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Neth[] = { - {16, 16, 4, 7, 1, 0, TIMEBASE_CUR, 6, "NST\0"}, - {16, 16, 9, 7, 1, 0, TIMEBASE_CUR, 0, "AMT\0"}, - {17, 17, 3, 7, 16, 120, TIMEBASE_STD, 6, "NST\0"}, - {17, 17, 8, 7, 17, 120, TIMEBASE_STD, 0, "AMT\0"}, - {18, 21, 3, 1, 1, 120, TIMEBASE_STD, 6, "NST\0"}, - {18, 21, 8, 1, 24, 120, TIMEBASE_STD, 0, "AMT\0"}, - {22, 22, 2, 0, 25, 120, TIMEBASE_STD, 6, "NST\0"}, - {22, 36, 9, 0, 2, 120, TIMEBASE_STD, 0, "AMT\0"}, - {23, 23, 5, 5, 1, 120, TIMEBASE_STD, 6, "NST\0"}, - {24, 24, 2, 0, 25, 120, TIMEBASE_STD, 6, "NST\0"}, - {25, 25, 5, 5, 1, 120, TIMEBASE_STD, 6, "NST\0"}, - {26, 31, 4, 7, 15, 120, TIMEBASE_STD, 6, "NST\0"}, - {32, 32, 4, 7, 22, 120, TIMEBASE_STD, 6, "NST\0"}, - {33, 36, 4, 7, 15, 120, TIMEBASE_STD, 6, "NST\0"}, - {37, 37, 4, 7, 22, 120, TIMEBASE_STD, 6, "NST\0"}, - {37, 37, 6, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {37, 39, 9, 0, 2, 120, TIMEBASE_STD, 0, "\0"}, - {38, 39, 4, 7, 15, 120, TIMEBASE_STD, 6, "S\0"}, - {45, 45, 3, 7, 2, 120, TIMEBASE_STD, 6, "S\0"}, - {45, 45, 8, 7, 16, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Nic[] = { - {79, 80, 2, 0, 16, 0, TIMEBASE_CUR, 6, "D\0"}, - {79, 80, 5, 1, 23, 0, TIMEBASE_CUR, 0, "S\0"}, - {105, 105, 3, 7, 10, 0, TIMEBASE_CUR, 6, "D\0"}, - {105, 105, 9, 0, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {106, 106, 3, 7, 30, 120, TIMEBASE_CUR, 6, "D\0"}, - {106, 106, 9, 0, 1, 60, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Norway[] = { - {16, 16, 4, 7, 22, 60, TIMEBASE_CUR, 6, "S\0"}, - {16, 16, 8, 7, 30, 0, TIMEBASE_CUR, 0, "\0"}, - {45, 45, 3, 7, 2, 120, TIMEBASE_STD, 6, "S\0"}, - {45, 45, 9, 7, 1, 120, TIMEBASE_STD, 0, "\0"}, - {59, 64, 2, 0, 15, 120, TIMEBASE_STD, 6, "S\0"}, - {59, 65, 8, 0, 15, 120, TIMEBASE_STD, 0, "\0"}, - {65, 65, 3, 7, 25, 120, TIMEBASE_STD, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_PRC[] = { - {86, 86, 4, 7, 4, 0, TIMEBASE_CUR, 6, "D\0"}, - {86, 91, 8, 0, 11, 0, TIMEBASE_CUR, 0, "S\0"}, - {87, 91, 3, 0, 10, 0, TIMEBASE_CUR, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_Pakistan[] = { - {102, 102, 3, 0, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {102, 102, 9, 0, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {108, 108, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {108, 109, 10, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {109, 109, 3, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Palestine[] = { - {99, 105, 3, 5, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {99, 103, 9, 5, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {104, 104, 9, 7, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {105, 105, 9, 7, 4, 120, TIMEBASE_CUR, 0, "\0"}, - {106, 107, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {106, 106, 8, 7, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {107, 107, 8, 4, 8, 120, TIMEBASE_CUR, 0, "\0"}, - {108, 109, 2, 5, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {108, 108, 8, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {109, 109, 8, 5, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {110, 110, 2, 7, 26, 0, TIMEBASE_CUR, 6, "S\0"}, - {110, 110, 7, 7, 11, 0, TIMEBASE_CUR, 0, "\0"}, - {111, 111, 3, 7, 1, 1, TIMEBASE_CUR, 6, "S\0"}, - {111, 111, 7, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {111, 111, 7, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {111, 111, 8, 7, 30, 0, TIMEBASE_CUR, 0, "\0"}, - {112, 114, 2, 4, 25, 1440, TIMEBASE_CUR, 6, "S\0"}, - {112, 112, 8, 7, 21, 60, TIMEBASE_CUR, 0, "\0"}, - {113, 113, 8, 5, 21, 0, TIMEBASE_CUR, 0, "\0"}, - {114, 115, 9, 5, 21, 0, TIMEBASE_CUR, 0, "\0"}, - {115, 115, 2, 5, 25, 1440, TIMEBASE_CUR, 6, "S\0"}, - {116, 255, 2, 6, 25, 60, TIMEBASE_CUR, 6, "S\0"}, - {116, 255, 9, 6, 25, 60, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Para[] = { - {75, 78, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {75, 88, 9, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {79, 91, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {89, 89, 9, 7, 22, 0, TIMEBASE_CUR, 6, "S\0"}, - {90, 90, 9, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {91, 91, 9, 7, 6, 0, TIMEBASE_CUR, 6, "S\0"}, - {92, 92, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {92, 92, 9, 7, 5, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 93, 2, 7, 31, 0, TIMEBASE_CUR, 0, "\0"}, - {93, 95, 9, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {94, 95, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {96, 96, 2, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {96, 101, 9, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {97, 97, 1, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {98, 101, 2, 0, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {102, 104, 3, 0, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {102, 103, 8, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {104, 109, 9, 0, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {105, 109, 2, 0, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {110, 112, 3, 0, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {110, 255, 9, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {113, 255, 2, 0, 22, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Perry[] = { - {46, 46, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {53, 54, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {53, 59, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {55, 55, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {56, 63, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {60, 60, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {61, 61, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {62, 63, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Peru[] = { - {37, 37, 11, 7, 31, 1440, TIMEBASE_CUR, 6, "S\0"}, - {38, 38, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {38, 39, 8, 0, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {39, 40, 2, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {85, 86, 11, 7, 31, 1440, TIMEBASE_CUR, 6, "S\0"}, - {86, 87, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {89, 89, 11, 7, 31, 1440, TIMEBASE_CUR, 6, "S\0"}, - {90, 90, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {93, 93, 11, 7, 31, 1440, TIMEBASE_CUR, 6, "S\0"}, - {94, 94, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Phil[] = { - {36, 36, 10, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {37, 37, 1, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {54, 54, 3, 7, 12, 0, TIMEBASE_CUR, 6, "S\0"}, - {54, 54, 6, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 2, 7, 22, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 8, 7, 21, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Pike[] = { - {55, 55, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {55, 60, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {56, 64, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {61, 64, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Poland[] = { - {18, 19, 8, 7, 16, 120, TIMEBASE_STD, 0, "\0"}, - {19, 19, 3, 7, 15, 120, TIMEBASE_STD, 6, "S\0"}, - {44, 44, 3, 7, 3, 120, TIMEBASE_STD, 6, "S\0"}, - {44, 44, 9, 7, 4, 120, TIMEBASE_CUR, 0, "\0"}, - {45, 45, 3, 7, 29, 0, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 10, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {46, 46, 3, 7, 14, 0, TIMEBASE_STD, 6, "S\0"}, - {46, 46, 9, 7, 7, 120, TIMEBASE_STD, 0, "\0"}, - {47, 47, 4, 7, 4, 120, TIMEBASE_STD, 6, "S\0"}, - {47, 49, 9, 0, 1, 120, TIMEBASE_STD, 0, "\0"}, - {48, 48, 3, 7, 18, 120, TIMEBASE_STD, 6, "S\0"}, - {49, 49, 3, 7, 10, 120, TIMEBASE_STD, 6, "S\0"}, - {57, 57, 5, 7, 2, 60, TIMEBASE_STD, 6, "S\0"}, - {57, 58, 8, 0, 24, 60, TIMEBASE_STD, 0, "\0"}, - {58, 58, 2, 7, 30, 60, TIMEBASE_STD, 6, "S\0"}, - {59, 59, 4, 7, 31, 60, TIMEBASE_STD, 6, "S\0"}, - {59, 61, 9, 0, 1, 60, TIMEBASE_STD, 0, "\0"}, - {60, 60, 3, 7, 3, 60, TIMEBASE_STD, 6, "S\0"}, - {61, 64, 4, 0, 25, 60, TIMEBASE_STD, 6, "S\0"}, - {62, 64, 8, 0, 24, 60, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Port[] = { - {16, 16, 5, 7, 17, 1380, TIMEBASE_CUR, 6, "S\0"}, - {16, 16, 10, 7, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {17, 17, 1, 7, 28, 1380, TIMEBASE_STD, 6, "S\0"}, - {17, 21, 9, 7, 14, 1380, TIMEBASE_STD, 0, "\0"}, - {18, 18, 2, 7, 1, 1380, TIMEBASE_STD, 6, "S\0"}, - {19, 19, 1, 7, 28, 1380, TIMEBASE_STD, 6, "S\0"}, - {20, 20, 1, 7, 29, 1380, TIMEBASE_STD, 6, "S\0"}, - {21, 21, 1, 7, 28, 1380, TIMEBASE_STD, 6, "S\0"}, - {24, 24, 3, 7, 16, 1380, TIMEBASE_STD, 6, "S\0"}, - {24, 24, 9, 7, 14, 1380, TIMEBASE_STD, 0, "\0"}, - {26, 26, 3, 7, 17, 1380, TIMEBASE_STD, 6, "S\0"}, - {26, 29, 9, 6, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {27, 27, 3, 7, 9, 1380, TIMEBASE_STD, 6, "S\0"}, - {28, 28, 3, 7, 14, 1380, TIMEBASE_STD, 6, "S\0"}, - {29, 29, 3, 7, 20, 1380, TIMEBASE_STD, 6, "S\0"}, - {31, 31, 3, 7, 18, 1380, TIMEBASE_STD, 6, "S\0"}, - {31, 32, 9, 6, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {32, 32, 3, 7, 2, 1380, TIMEBASE_STD, 6, "S\0"}, - {34, 34, 3, 7, 7, 1380, TIMEBASE_STD, 6, "S\0"}, - {34, 38, 9, 6, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {35, 35, 2, 7, 30, 1380, TIMEBASE_STD, 6, "S\0"}, - {36, 36, 3, 7, 18, 1380, TIMEBASE_STD, 6, "S\0"}, - {37, 37, 3, 7, 3, 1380, TIMEBASE_STD, 6, "S\0"}, - {38, 38, 2, 7, 26, 1380, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 3, 7, 15, 1380, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 10, 7, 18, 1380, TIMEBASE_STD, 0, "\0"}, - {40, 40, 1, 7, 24, 1380, TIMEBASE_STD, 6, "S\0"}, - {40, 41, 9, 7, 5, 1380, TIMEBASE_STD, 0, "\0"}, - {41, 41, 3, 7, 5, 1380, TIMEBASE_STD, 6, "S\0"}, - {42, 45, 2, 6, 8, 1380, TIMEBASE_STD, 6, "S\0"}, - {42, 42, 3, 7, 25, 1320, TIMEBASE_STD, 12, "M\0"}, - {42, 42, 7, 7, 15, 1320, TIMEBASE_STD, 6, "S\0"}, - {42, 45, 9, 6, 24, 1380, TIMEBASE_STD, 0, "\0"}, - {43, 43, 3, 7, 17, 1320, TIMEBASE_STD, 12, "M\0"}, - {43, 45, 7, 6, 25, 1320, TIMEBASE_STD, 6, "S\0"}, - {44, 45, 3, 6, 21, 1320, TIMEBASE_STD, 12, "M\0"}, - {46, 46, 3, 6, 1, 1380, TIMEBASE_STD, 6, "S\0"}, - {46, 46, 9, 6, 1, 1380, TIMEBASE_STD, 0, "\0"}, - {47, 49, 3, 0, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {47, 49, 9, 0, 1, 120, TIMEBASE_STD, 0, "\0"}, - {51, 65, 3, 0, 1, 120, TIMEBASE_STD, 6, "S\0"}, - {51, 65, 9, 0, 1, 120, TIMEBASE_STD, 0, "\0"}, - {77, 77, 2, 7, 27, 0, TIMEBASE_STD, 6, "S\0"}, - {77, 77, 8, 7, 25, 0, TIMEBASE_STD, 0, "\0"}, - {78, 79, 3, 0, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {78, 78, 9, 7, 1, 0, TIMEBASE_STD, 0, "\0"}, - {79, 82, 8, 0, 24, 60, TIMEBASE_STD, 0, "\0"}, - {80, 80, 2, 0, 25, 0, TIMEBASE_STD, 6, "S\0"}, - {81, 82, 2, 0, 25, 60, TIMEBASE_STD, 6, "S\0"}, - {83, 83, 2, 0, 25, 120, TIMEBASE_STD, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Pulaski[] = { - {46, 60, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 54, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {55, 56, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {57, 60, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_ROK[] = { - {48, 48, 5, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {48, 48, 8, 7, 13, 0, TIMEBASE_CUR, 0, "S\0"}, - {49, 49, 3, 7, 3, 0, TIMEBASE_CUR, 6, "D\0"}, - {49, 51, 8, 0, 8, 0, TIMEBASE_CUR, 0, "S\0"}, - {50, 50, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {51, 51, 4, 7, 6, 0, TIMEBASE_CUR, 6, "D\0"}, - {55, 55, 4, 7, 5, 0, TIMEBASE_CUR, 6, "D\0"}, - {55, 55, 8, 7, 9, 0, TIMEBASE_CUR, 0, "S\0"}, - {56, 56, 4, 7, 20, 0, TIMEBASE_CUR, 6, "D\0"}, - {56, 56, 8, 7, 30, 0, TIMEBASE_CUR, 0, "S\0"}, - {57, 60, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {57, 60, 8, 0, 18, 0, TIMEBASE_CUR, 0, "S\0"}, - {87, 88, 4, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {87, 88, 9, 0, 8, 180, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Regina[] = { - {18, 18, 3, 7, 14, 120, TIMEBASE_CUR, 6, "D\0"}, - {18, 18, 9, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {30, 34, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {30, 34, 9, 0, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {37, 41, 3, 0, 8, 0, TIMEBASE_CUR, 6, "D\0"}, - {37, 37, 9, 0, 8, 0, TIMEBASE_CUR, 0, "S\0"}, - {38, 38, 9, 0, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {39, 41, 9, 0, 8, 0, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 1, 7, 9, 120, TIMEBASE_CUR, 6, "W\0"}, - {45, 45, 7, 7, 14, 1380, TIMEBASE_UTC, 6, "P\0"}, - {45, 45, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {46, 46, 3, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 9, 0, 8, 120, TIMEBASE_CUR, 0, "S\0"}, - {47, 57, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {47, 57, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {59, 59, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {59, 59, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Romania[] = { - {32, 32, 4, 7, 21, 0, TIMEBASE_STD, 6, "S\0"}, - {32, 39, 9, 0, 1, 0, TIMEBASE_STD, 0, "\0"}, - {33, 39, 3, 0, 2, 0, TIMEBASE_STD, 6, "S\0"}, - {79, 79, 4, 7, 27, 0, TIMEBASE_CUR, 6, "S\0"}, - {79, 79, 8, 0, 24, 0, TIMEBASE_CUR, 0, "\0"}, - {80, 80, 3, 7, 5, 1380, TIMEBASE_CUR, 6, "S\0"}, - {80, 80, 8, 0, 24, 60, TIMEBASE_CUR, 0, "\0"}, - {91, 93, 2, 0, 25, 0, TIMEBASE_STD, 6, "S\0"}, - {91, 93, 8, 0, 24, 0, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Russia[] = { - {17, 17, 6, 7, 1, 1380, TIMEBASE_CUR, 6, "MST\0"}, - {17, 17, 11, 7, 28, 0, TIMEBASE_CUR, 0, "MMT\0"}, - {18, 18, 4, 7, 31, 1320, TIMEBASE_CUR, 12, "MDST\0"}, - {18, 18, 8, 7, 16, 60, TIMEBASE_CUR, 6, "MST\0"}, - {19, 19, 4, 7, 31, 1380, TIMEBASE_CUR, 12, "MDST\0"}, - {19, 19, 6, 7, 1, 0, TIMEBASE_UTC, 6, "MSD\0"}, - {19, 19, 7, 7, 16, 0, TIMEBASE_CUR, 0, "MSK\0"}, - {21, 21, 1, 7, 14, 1380, TIMEBASE_CUR, 6, "MSD\0"}, - {21, 21, 2, 7, 20, 1380, TIMEBASE_CUR, 12, "+05\0"}, - {21, 21, 8, 7, 1, 0, TIMEBASE_CUR, 6, "MSD\0"}, - {21, 21, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {81, 84, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {81, 83, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {84, 95, 8, 0, 24, 120, TIMEBASE_STD, 0, "\0"}, - {85, 110, 2, 0, 25, 120, TIMEBASE_STD, 6, "S\0"}, - {96, 110, 9, 0, 25, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_RussiaAsia[] = { - {81, 84, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {81, 83, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {84, 95, 8, 0, 24, 120, TIMEBASE_STD, 0, "\0"}, - {85, 111, 2, 0, 25, 120, TIMEBASE_STD, 6, "S\0"}, - {96, 111, 9, 0, 25, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_SA[] = { - {42, 43, 8, 0, 15, 120, TIMEBASE_CUR, 6, "\0"}, - {43, 44, 2, 0, 15, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Salv[] = { - {87, 88, 4, 0, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {87, 88, 8, 0, 24, 0, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_SanLuis[] = { - {107, 108, 9, 0, 8, 0, TIMEBASE_CUR, 6, "S\0"}, - {108, 109, 2, 0, 8, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Shang[] = { - {40, 40, 5, 7, 3, 0, TIMEBASE_CUR, 6, "D\0"}, - {40, 41, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {41, 41, 2, 7, 16, 0, TIMEBASE_CUR, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_SovietZone[] = { - {45, 45, 4, 7, 24, 120, TIMEBASE_CUR, 12, "M\0"}, - {45, 45, 8, 7, 24, 180, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 10, 7, 18, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Spain[] = { - {18, 18, 3, 7, 15, 1380, TIMEBASE_CUR, 6, "S\0"}, - {18, 19, 9, 7, 6, 1440, TIMEBASE_STD, 0, "\0"}, - {19, 19, 3, 7, 6, 1380, TIMEBASE_CUR, 6, "S\0"}, - {24, 24, 3, 7, 16, 1380, TIMEBASE_CUR, 6, "S\0"}, - {24, 24, 9, 7, 4, 1440, TIMEBASE_STD, 0, "\0"}, - {26, 26, 3, 7, 17, 1380, TIMEBASE_CUR, 6, "S\0"}, - {26, 29, 9, 6, 1, 1440, TIMEBASE_STD, 0, "\0"}, - {27, 27, 3, 7, 9, 1380, TIMEBASE_CUR, 6, "S\0"}, - {28, 28, 3, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {29, 29, 3, 7, 20, 1380, TIMEBASE_CUR, 6, "S\0"}, - {37, 37, 5, 7, 16, 1380, TIMEBASE_CUR, 6, "S\0"}, - {37, 37, 9, 7, 2, 1440, TIMEBASE_STD, 0, "\0"}, - {38, 38, 3, 7, 2, 1380, TIMEBASE_CUR, 6, "S\0"}, - {38, 38, 3, 7, 30, 1380, TIMEBASE_CUR, 12, "M\0"}, - {38, 38, 9, 7, 2, 1440, TIMEBASE_CUR, 6, "S\0"}, - {39, 39, 9, 7, 7, 1440, TIMEBASE_STD, 0, "\0"}, - {42, 42, 4, 7, 2, 1380, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 8, 7, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {43, 46, 3, 6, 13, 1380, TIMEBASE_CUR, 6, "S\0"}, - {43, 44, 9, 0, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {45, 46, 8, 0, 24, 60, TIMEBASE_CUR, 0, "\0"}, - {49, 49, 3, 7, 30, 1380, TIMEBASE_CUR, 6, "S\0"}, - {49, 49, 9, 7, 2, 60, TIMEBASE_CUR, 0, "\0"}, - {74, 75, 3, 6, 12, 1380, TIMEBASE_CUR, 6, "S\0"}, - {74, 75, 9, 0, 1, 60, TIMEBASE_CUR, 0, "\0"}, - {76, 76, 2, 7, 27, 1380, TIMEBASE_CUR, 6, "S\0"}, - {76, 77, 8, 0, 24, 60, TIMEBASE_CUR, 0, "\0"}, - {77, 77, 3, 7, 2, 1380, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 3, 7, 2, 120, TIMEBASE_STD, 6, "S\0"}, - {78, 78, 9, 7, 1, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_SpainAfrica[] = { - {67, 67, 5, 7, 3, 720, TIMEBASE_CUR, 6, "S\0"}, - {67, 67, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {74, 74, 5, 7, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {74, 74, 8, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {76, 77, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {76, 76, 7, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {77, 77, 8, 7, 28, 0, TIMEBASE_CUR, 0, "\0"}, - {78, 78, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 7, 7, 4, 0, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_StJohns[] = { - {17, 17, 3, 7, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {17, 17, 8, 7, 17, 120, TIMEBASE_CUR, 0, "S\0"}, - {19, 19, 4, 7, 5, 1380, TIMEBASE_CUR, 6, "D\0"}, - {19, 19, 7, 7, 12, 1380, TIMEBASE_CUR, 0, "S\0"}, - {20, 35, 4, 0, 1, 1380, TIMEBASE_CUR, 6, "D\0"}, - {20, 35, 9, 0, 25, 1380, TIMEBASE_CUR, 0, "S\0"}, - {36, 41, 4, 1, 9, 0, TIMEBASE_CUR, 6, "D\0"}, - {36, 41, 9, 1, 2, 0, TIMEBASE_CUR, 0, "S\0"}, - {46, 50, 4, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 50, 9, 0, 2, 120, TIMEBASE_CUR, 0, "S\0"}, - {51, 86, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {51, 59, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {60, 86, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {87, 87, 3, 0, 1, 1, TIMEBASE_CUR, 6, "D\0"}, - {87, 106, 9, 0, 25, 1, TIMEBASE_CUR, 0, "S\0"}, - {88, 88, 3, 0, 1, 1, TIMEBASE_CUR, 12, "DD\0"}, - {89, 106, 3, 0, 1, 1, TIMEBASE_CUR, 6, "D\0"}, - {107, 111, 2, 0, 8, 1, TIMEBASE_CUR, 6, "D\0"}, - {107, 110, 10, 0, 1, 1, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Starke[] = { - {47, 61, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {47, 54, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {55, 56, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {57, 58, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {59, 61, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Sudan[] = { - {70, 70, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {70, 85, 9, 7, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {71, 71, 3, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {72, 85, 3, 0, 24, 0, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Swift[] = { - {57, 57, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {57, 57, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {59, 61, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {59, 59, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {60, 61, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Swiss[] = { - {41, 42, 4, 1, 1, 60, TIMEBASE_CUR, 6, "S\0"}, - {41, 42, 9, 1, 1, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Syria[] = { - {20, 23, 3, 0, 15, 120, TIMEBASE_CUR, 6, "S\0"}, - {20, 23, 9, 0, 1, 120, TIMEBASE_CUR, 0, "\0"}, - {62, 62, 3, 7, 29, 120, TIMEBASE_CUR, 6, "S\0"}, - {62, 62, 9, 7, 1, 120, TIMEBASE_CUR, 0, "\0"}, - {63, 65, 4, 7, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {63, 63, 8, 7, 30, 120, TIMEBASE_CUR, 0, "\0"}, - {64, 64, 9, 7, 1, 120, TIMEBASE_CUR, 0, "\0"}, - {65, 65, 8, 7, 30, 120, TIMEBASE_CUR, 0, "\0"}, - {66, 66, 3, 7, 24, 120, TIMEBASE_CUR, 6, "S\0"}, - {66, 76, 9, 7, 1, 120, TIMEBASE_CUR, 0, "\0"}, - {67, 78, 4, 7, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {77, 78, 8, 7, 1, 120, TIMEBASE_CUR, 0, "\0"}, - {83, 84, 3, 7, 9, 120, TIMEBASE_CUR, 6, "S\0"}, - {83, 84, 9, 7, 1, 120, TIMEBASE_CUR, 0, "\0"}, - {86, 86, 1, 7, 16, 120, TIMEBASE_CUR, 6, "S\0"}, - {86, 86, 9, 7, 9, 120, TIMEBASE_CUR, 0, "\0"}, - {87, 87, 2, 7, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {87, 88, 9, 7, 31, 120, TIMEBASE_CUR, 0, "\0"}, - {88, 88, 2, 7, 15, 120, TIMEBASE_CUR, 6, "S\0"}, - {89, 89, 2, 7, 31, 120, TIMEBASE_CUR, 6, "S\0"}, - {89, 89, 9, 7, 1, 120, TIMEBASE_CUR, 0, "\0"}, - {90, 90, 3, 7, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {90, 90, 8, 7, 30, 120, TIMEBASE_CUR, 0, "\0"}, - {91, 91, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {91, 92, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {92, 92, 3, 7, 8, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 93, 2, 7, 26, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 93, 8, 7, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {94, 96, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {94, 105, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {97, 98, 2, 1, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {99, 106, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {106, 106, 8, 7, 22, 0, TIMEBASE_CUR, 0, "\0"}, - {107, 107, 2, 5, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {107, 107, 10, 5, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {108, 108, 3, 5, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {108, 108, 10, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {109, 109, 2, 5, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {109, 255, 9, 5, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {110, 111, 3, 5, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {112, 255, 2, 5, 25, 0, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Taiwan[] = { - {46, 46, 4, 7, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {47, 47, 3, 7, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {47, 47, 10, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {48, 51, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {48, 51, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {52, 52, 2, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {52, 54, 10, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {53, 59, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {55, 61, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {60, 61, 5, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {74, 75, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {74, 75, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {79, 79, 6, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {79, 79, 9, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Thule[] = { - {91, 92, 2, 0, 25, 120, TIMEBASE_CUR, 6, "D\0"}, - {91, 92, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {93, 106, 3, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {93, 106, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {107, 255, 2, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {107, 255, 10, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Tonga[] = { - {99, 99, 9, 7, 7, 120, TIMEBASE_STD, 6, "S\0"}, - {100, 100, 2, 7, 19, 120, TIMEBASE_STD, 0, "\0"}, - {100, 101, 10, 0, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {101, 102, 0, 0, 25, 120, TIMEBASE_CUR, 0, "\0"}, - {116, 255, 10, 0, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {117, 255, 0, 0, 15, 180, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Toronto[] = { - {19, 19, 2, 7, 30, 1410, TIMEBASE_CUR, 6, "D\0"}, - {19, 19, 9, 7, 26, 0, TIMEBASE_CUR, 0, "S\0"}, - {20, 20, 4, 7, 2, 120, TIMEBASE_CUR, 6, "D\0"}, - {20, 20, 8, 7, 26, 0, TIMEBASE_CUR, 0, "S\0"}, - {21, 21, 4, 7, 15, 120, TIMEBASE_CUR, 6, "D\0"}, - {21, 21, 8, 7, 15, 120, TIMEBASE_CUR, 0, "S\0"}, - {22, 23, 4, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {22, 26, 8, 0, 15, 120, TIMEBASE_CUR, 0, "S\0"}, - {24, 27, 4, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {27, 32, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {28, 31, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {32, 32, 4, 7, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {33, 40, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {33, 33, 9, 7, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {34, 39, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {45, 46, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {46, 46, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {47, 49, 3, 0, 24, 0, TIMEBASE_CUR, 6, "D\0"}, - {47, 48, 8, 0, 24, 0, TIMEBASE_CUR, 0, "S\0"}, - {49, 49, 10, 0, 24, 0, TIMEBASE_CUR, 0, "S\0"}, - {50, 73, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {50, 50, 10, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {51, 56, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {57, 73, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Troll[] = { - {104, 255, 9, 0, 25, 60, TIMEBASE_UTC, 0, "+00\0"}, - {105, 255, 2, 0, 25, 60, TIMEBASE_UTC, 12, "+02\0"}, -}; -static const struct lc_timezone_rule rules_Tunisia[] = { - {39, 39, 3, 7, 15, 1380, TIMEBASE_STD, 6, "S\0"}, - {39, 39, 10, 7, 18, 1380, TIMEBASE_STD, 0, "\0"}, - {40, 40, 1, 7, 25, 1380, TIMEBASE_STD, 6, "S\0"}, - {41, 41, 9, 7, 6, 0, TIMEBASE_CUR, 0, "\0"}, - {42, 42, 2, 7, 9, 0, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 10, 7, 2, 180, TIMEBASE_CUR, 0, "\0"}, - {43, 43, 2, 7, 29, 120, TIMEBASE_CUR, 6, "S\0"}, - {43, 43, 3, 7, 17, 120, TIMEBASE_CUR, 0, "\0"}, - {43, 43, 3, 7, 25, 120, TIMEBASE_CUR, 6, "S\0"}, - {43, 43, 9, 7, 4, 120, TIMEBASE_CUR, 0, "\0"}, - {44, 45, 3, 1, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {44, 44, 9, 7, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {45, 45, 8, 7, 16, 0, TIMEBASE_CUR, 0, "\0"}, - {77, 77, 3, 7, 30, 0, TIMEBASE_STD, 6, "S\0"}, - {77, 77, 8, 7, 24, 0, TIMEBASE_STD, 0, "\0"}, - {78, 78, 4, 7, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {78, 78, 9, 7, 1, 0, TIMEBASE_STD, 0, "\0"}, - {88, 88, 5, 7, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {88, 90, 8, 0, 24, 0, TIMEBASE_STD, 0, "\0"}, - {89, 89, 2, 7, 26, 0, TIMEBASE_STD, 6, "S\0"}, - {90, 90, 4, 7, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {105, 105, 4, 7, 1, 0, TIMEBASE_STD, 6, "S\0"}, - {105, 105, 8, 7, 30, 60, TIMEBASE_STD, 0, "\0"}, - {106, 108, 2, 0, 25, 120, TIMEBASE_STD, 6, "S\0"}, - {106, 108, 9, 0, 25, 120, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Turkey[] = { - {16, 16, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {16, 16, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {20, 20, 2, 7, 28, 0, TIMEBASE_CUR, 6, "S\0"}, - {20, 20, 9, 7, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {21, 21, 3, 7, 3, 0, TIMEBASE_CUR, 6, "S\0"}, - {21, 21, 9, 7, 3, 0, TIMEBASE_CUR, 0, "\0"}, - {22, 22, 2, 7, 26, 0, TIMEBASE_CUR, 6, "S\0"}, - {22, 22, 9, 7, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {24, 24, 4, 7, 13, 0, TIMEBASE_CUR, 6, "S\0"}, - {24, 25, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {25, 25, 4, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {40, 40, 5, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {40, 40, 9, 7, 5, 0, TIMEBASE_CUR, 0, "\0"}, - {40, 40, 11, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {41, 41, 8, 7, 21, 0, TIMEBASE_CUR, 0, "\0"}, - {42, 42, 3, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {42, 42, 10, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {45, 45, 3, 7, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {45, 45, 9, 7, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {46, 46, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {46, 46, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {47, 48, 3, 0, 16, 0, TIMEBASE_CUR, 6, "S\0"}, - {47, 50, 9, 0, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {49, 49, 3, 7, 10, 0, TIMEBASE_CUR, 6, "S\0"}, - {50, 50, 3, 7, 19, 0, TIMEBASE_CUR, 6, "S\0"}, - {51, 51, 3, 7, 22, 0, TIMEBASE_CUR, 6, "S\0"}, - {51, 51, 9, 7, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {62, 62, 6, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {62, 62, 9, 7, 8, 0, TIMEBASE_CUR, 0, "\0"}, - {64, 64, 4, 7, 15, 0, TIMEBASE_CUR, 6, "S\0"}, - {64, 64, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {70, 72, 4, 0, 2, 0, TIMEBASE_CUR, 6, "S\0"}, - {70, 72, 9, 0, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {73, 73, 5, 7, 3, 60, TIMEBASE_CUR, 6, "S\0"}, - {73, 73, 10, 7, 4, 180, TIMEBASE_CUR, 0, "\0"}, - {74, 74, 2, 7, 31, 120, TIMEBASE_CUR, 6, "S\0"}, - {74, 74, 10, 7, 3, 300, TIMEBASE_CUR, 0, "\0"}, - {75, 75, 2, 7, 30, 0, TIMEBASE_CUR, 6, "S\0"}, - {75, 76, 9, 0, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {76, 76, 5, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {77, 78, 3, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {77, 77, 9, 7, 16, 0, TIMEBASE_CUR, 0, "\0"}, - {79, 80, 3, 0, 1, 180, TIMEBASE_CUR, 6, "S\0"}, - {79, 82, 9, 1, 11, 0, TIMEBASE_CUR, 0, "\0"}, - {81, 82, 2, 0, 25, 180, TIMEBASE_CUR, 6, "S\0"}, - {83, 83, 6, 7, 31, 0, TIMEBASE_CUR, 6, "S\0"}, - {83, 83, 9, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {85, 85, 3, 7, 20, 0, TIMEBASE_CUR, 6, "S\0"}, - {85, 85, 8, 7, 28, 0, TIMEBASE_CUR, 0, "\0"}, - {86, 93, 2, 0, 25, 60, TIMEBASE_STD, 6, "S\0"}, - {86, 95, 8, 0, 24, 60, TIMEBASE_STD, 0, "\0"}, - {94, 94, 2, 7, 20, 60, TIMEBASE_STD, 6, "S\0"}, - {95, 106, 2, 0, 25, 60, TIMEBASE_STD, 6, "S\0"}, - {96, 106, 9, 0, 25, 60, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_US[] = { - {18, 19, 2, 0, 25, 120, TIMEBASE_CUR, 6, "D\0"}, - {18, 19, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 1, 7, 9, 120, TIMEBASE_CUR, 6, "W\0"}, - {45, 45, 7, 7, 14, 1380, TIMEBASE_UTC, 6, "P\0"}, - {45, 45, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {67, 73, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {67, 106, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {74, 74, 0, 7, 6, 120, TIMEBASE_CUR, 6, "D\0"}, - {75, 75, 1, 7, 23, 120, TIMEBASE_CUR, 6, "D\0"}, - {76, 86, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {87, 106, 3, 0, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {107, 255, 2, 0, 8, 120, TIMEBASE_CUR, 6, "D\0"}, - {107, 255, 10, 0, 1, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Uruguay[] = { - {23, 23, 9, 7, 2, 0, TIMEBASE_CUR, 3, "HS\0"}, - {24, 26, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {24, 25, 9, 7, 1, 0, TIMEBASE_CUR, 3, "HS\0"}, - {33, 35, 9, 0, 25, 0, TIMEBASE_CUR, 3, "HS\0"}, - {34, 36, 2, 6, 25, 1410, TIMEBASE_STD, 0, "\0"}, - {36, 36, 10, 7, 1, 0, TIMEBASE_CUR, 3, "HS\0"}, - {37, 41, 2, 0, 25, 0, TIMEBASE_CUR, 0, "\0"}, - {37, 40, 9, 0, 25, 0, TIMEBASE_CUR, 3, "HS\0"}, - {41, 41, 7, 7, 1, 0, TIMEBASE_CUR, 3, "HS\0"}, - {41, 41, 11, 7, 31, 1440, TIMEBASE_CUR, 0, "\0"}, - {42, 42, 11, 7, 14, 0, TIMEBASE_CUR, 6, "S\0"}, - {43, 43, 2, 7, 14, 0, TIMEBASE_CUR, 0, "\0"}, - {59, 59, 4, 7, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {59, 59, 10, 7, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {60, 60, 0, 7, 17, 0, TIMEBASE_CUR, 6, "S\0"}, - {60, 60, 2, 7, 6, 0, TIMEBASE_CUR, 0, "\0"}, - {65, 67, 3, 0, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {65, 65, 8, 7, 26, 0, TIMEBASE_CUR, 0, "\0"}, - {66, 67, 9, 7, 31, 0, TIMEBASE_CUR, 0, "\0"}, - {68, 70, 4, 7, 27, 0, TIMEBASE_CUR, 3, "HS\0"}, - {68, 70, 11, 7, 2, 0, TIMEBASE_CUR, 0, "\0"}, - {72, 72, 3, 7, 24, 0, TIMEBASE_CUR, 6, "S\0"}, - {72, 72, 7, 7, 15, 0, TIMEBASE_CUR, 0, "\0"}, - {74, 74, 2, 7, 10, 0, TIMEBASE_CUR, 3, "HS\0"}, - {74, 74, 11, 7, 22, 0, TIMEBASE_CUR, 6, "S\0"}, - {76, 76, 9, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {77, 77, 11, 7, 4, 0, TIMEBASE_CUR, 6, "S\0"}, - {78, 78, 3, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {79, 79, 9, 7, 1, 0, TIMEBASE_CUR, 6, "S\0"}, - {80, 80, 4, 7, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {87, 87, 11, 7, 14, 0, TIMEBASE_CUR, 6, "S\0"}, - {88, 88, 2, 7, 14, 0, TIMEBASE_CUR, 0, "\0"}, - {88, 88, 11, 7, 11, 0, TIMEBASE_CUR, 6, "S\0"}, - {89, 89, 2, 7, 12, 0, TIMEBASE_CUR, 0, "\0"}, - {89, 89, 9, 7, 29, 0, TIMEBASE_CUR, 6, "S\0"}, - {90, 92, 2, 0, 1, 0, TIMEBASE_CUR, 0, "\0"}, - {90, 91, 9, 0, 21, 0, TIMEBASE_CUR, 6, "S\0"}, - {92, 92, 9, 7, 18, 0, TIMEBASE_CUR, 6, "S\0"}, - {93, 93, 1, 7, 28, 0, TIMEBASE_CUR, 0, "\0"}, - {104, 104, 8, 7, 19, 0, TIMEBASE_CUR, 6, "S\0"}, - {105, 105, 2, 7, 27, 120, TIMEBASE_CUR, 0, "\0"}, - {105, 105, 9, 7, 9, 120, TIMEBASE_CUR, 6, "S\0"}, - {106, 106, 2, 7, 12, 120, TIMEBASE_CUR, 0, "\0"}, - {106, 114, 9, 0, 1, 120, TIMEBASE_CUR, 6, "S\0"}, - {107, 115, 2, 0, 8, 120, TIMEBASE_CUR, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Vanc[] = { - {18, 18, 3, 7, 14, 120, TIMEBASE_CUR, 6, "D\0"}, - {18, 18, 9, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 1, 7, 9, 120, TIMEBASE_CUR, 6, "W\0"}, - {45, 45, 7, 7, 14, 1380, TIMEBASE_UTC, 6, "P\0"}, - {45, 45, 8, 7, 30, 120, TIMEBASE_CUR, 0, "S\0"}, - {46, 86, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 9, 7, 13, 120, TIMEBASE_CUR, 0, "S\0"}, - {47, 61, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {62, 106, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_Vanuatu[] = { - {83, 83, 8, 7, 25, 0, TIMEBASE_CUR, 6, "S\0"}, - {84, 91, 2, 0, 23, 0, TIMEBASE_CUR, 0, "\0"}, - {84, 84, 9, 7, 23, 0, TIMEBASE_CUR, 6, "S\0"}, - {85, 91, 8, 0, 23, 0, TIMEBASE_CUR, 6, "S\0"}, - {92, 93, 0, 0, 23, 0, TIMEBASE_CUR, 0, "\0"}, - {92, 92, 9, 0, 23, 0, TIMEBASE_CUR, 6, "S\0"}, -}; -static const struct lc_timezone_rule rules_Vincennes[] = { - {46, 46, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {53, 54, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {53, 59, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {55, 55, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {56, 63, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {60, 60, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {61, 61, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {62, 63, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_rule rules_WS[] = { - {110, 110, 8, 0, 24, 0, TIMEBASE_CUR, 6, "D\0"}, - {111, 111, 3, 6, 1, 240, TIMEBASE_CUR, 0, "S\0"}, - {111, 111, 8, 6, 24, 180, TIMEBASE_CUR, 6, "D\0"}, - {112, 255, 3, 0, 1, 240, TIMEBASE_CUR, 0, "S\0"}, - {112, 255, 8, 0, 24, 180, TIMEBASE_CUR, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_W_Eur[] = { - {77, 80, 3, 0, 1, 60, TIMEBASE_STD, 6, "S\0"}, - {77, 77, 8, 0, 24, 60, TIMEBASE_STD, 0, "\0"}, - {78, 78, 9, 7, 1, 60, TIMEBASE_STD, 0, "\0"}, - {79, 95, 8, 0, 24, 60, TIMEBASE_STD, 0, "\0"}, - {81, 255, 2, 0, 25, 60, TIMEBASE_STD, 6, "S\0"}, - {96, 255, 9, 0, 25, 60, TIMEBASE_STD, 0, "\0"}, -}; -static const struct lc_timezone_rule rules_Winn[] = { - {16, 16, 3, 7, 23, 0, TIMEBASE_CUR, 6, "D\0"}, - {16, 16, 8, 7, 17, 0, TIMEBASE_CUR, 0, "S\0"}, - {18, 18, 3, 7, 14, 120, TIMEBASE_CUR, 6, "D\0"}, - {18, 18, 9, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {37, 37, 4, 7, 16, 120, TIMEBASE_CUR, 6, "D\0"}, - {37, 37, 8, 7, 26, 120, TIMEBASE_CUR, 0, "S\0"}, - {42, 42, 1, 7, 9, 120, TIMEBASE_CUR, 6, "W\0"}, - {45, 45, 7, 7, 14, 1380, TIMEBASE_UTC, 6, "P\0"}, - {45, 45, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {46, 46, 4, 7, 12, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 9, 7, 13, 120, TIMEBASE_CUR, 0, "S\0"}, - {47, 49, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {47, 49, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {50, 50, 4, 7, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {50, 50, 8, 7, 30, 120, TIMEBASE_CUR, 0, "S\0"}, - {51, 60, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {51, 58, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {59, 59, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, - {60, 60, 8, 0, 24, 120, TIMEBASE_CUR, 0, "S\0"}, - {63, 63, 3, 0, 24, 120, TIMEBASE_CUR, 6, "D\0"}, - {63, 63, 8, 7, 22, 120, TIMEBASE_CUR, 0, "S\0"}, - {66, 86, 3, 0, 24, 120, TIMEBASE_STD, 6, "D\0"}, - {66, 105, 9, 0, 25, 120, TIMEBASE_STD, 0, "S\0"}, - {87, 105, 3, 0, 1, 120, TIMEBASE_STD, 6, "D\0"}, -}; -static const struct lc_timezone_rule rules_Zion[] = { - {40, 40, 5, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {42, 44, 10, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {43, 43, 3, 7, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {44, 44, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {45, 45, 3, 7, 16, 0, TIMEBASE_CUR, 6, "D\0"}, - {45, 45, 10, 7, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {46, 46, 3, 7, 16, 120, TIMEBASE_CUR, 6, "D\0"}, - {46, 46, 10, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {48, 48, 4, 7, 23, 0, TIMEBASE_CUR, 12, "DD\0"}, - {48, 48, 8, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {48, 49, 10, 7, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {49, 49, 4, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {50, 50, 3, 7, 16, 0, TIMEBASE_CUR, 6, "D\0"}, - {50, 50, 8, 7, 15, 180, TIMEBASE_CUR, 0, "S\0"}, - {51, 51, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {51, 51, 10, 7, 11, 180, TIMEBASE_CUR, 0, "S\0"}, - {52, 52, 3, 7, 20, 120, TIMEBASE_CUR, 6, "D\0"}, - {52, 52, 9, 7, 19, 180, TIMEBASE_CUR, 0, "S\0"}, - {53, 53, 3, 7, 12, 120, TIMEBASE_CUR, 6, "D\0"}, - {53, 53, 8, 7, 13, 180, TIMEBASE_CUR, 0, "S\0"}, - {54, 54, 5, 7, 13, 0, TIMEBASE_CUR, 6, "D\0"}, - {54, 54, 8, 7, 12, 0, TIMEBASE_CUR, 0, "S\0"}, - {55, 55, 5, 7, 11, 120, TIMEBASE_CUR, 6, "D\0"}, - {55, 55, 8, 7, 11, 0, TIMEBASE_CUR, 0, "S\0"}, - {56, 56, 5, 7, 3, 0, TIMEBASE_CUR, 6, "D\0"}, - {56, 56, 8, 7, 30, 180, TIMEBASE_CUR, 0, "S\0"}, - {57, 57, 3, 7, 29, 120, TIMEBASE_CUR, 6, "D\0"}, - {57, 57, 8, 7, 22, 0, TIMEBASE_CUR, 0, "S\0"}, - {74, 74, 6, 7, 7, 0, TIMEBASE_CUR, 6, "D\0"}, - {74, 74, 9, 7, 13, 0, TIMEBASE_CUR, 0, "S\0"}, - {75, 75, 3, 7, 20, 0, TIMEBASE_CUR, 6, "D\0"}, - {75, 75, 7, 7, 31, 0, TIMEBASE_CUR, 0, "S\0"}, - {85, 85, 3, 7, 14, 0, TIMEBASE_CUR, 6, "D\0"}, - {85, 85, 8, 7, 15, 0, TIMEBASE_CUR, 0, "S\0"}, - {86, 86, 4, 7, 18, 0, TIMEBASE_CUR, 6, "D\0"}, - {86, 86, 8, 7, 7, 0, TIMEBASE_CUR, 0, "S\0"}, - {87, 87, 3, 7, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {87, 87, 8, 7, 13, 0, TIMEBASE_CUR, 0, "S\0"}, - {88, 88, 3, 7, 10, 0, TIMEBASE_CUR, 6, "D\0"}, - {88, 88, 8, 7, 4, 0, TIMEBASE_CUR, 0, "S\0"}, - {89, 89, 3, 7, 30, 0, TIMEBASE_CUR, 6, "D\0"}, - {89, 89, 8, 7, 3, 0, TIMEBASE_CUR, 0, "S\0"}, - {90, 90, 2, 7, 25, 0, TIMEBASE_CUR, 6, "D\0"}, - {90, 90, 7, 7, 26, 0, TIMEBASE_CUR, 0, "S\0"}, - {91, 91, 2, 7, 24, 0, TIMEBASE_CUR, 6, "D\0"}, - {91, 91, 8, 7, 1, 0, TIMEBASE_CUR, 0, "S\0"}, - {92, 92, 2, 7, 29, 0, TIMEBASE_CUR, 6, "D\0"}, - {92, 92, 8, 7, 6, 0, TIMEBASE_CUR, 0, "S\0"}, - {93, 93, 3, 7, 2, 0, TIMEBASE_CUR, 6, "D\0"}, - {93, 93, 8, 7, 5, 0, TIMEBASE_CUR, 0, "S\0"}, - {94, 94, 3, 7, 1, 0, TIMEBASE_CUR, 6, "D\0"}, - {94, 94, 7, 7, 28, 0, TIMEBASE_CUR, 0, "S\0"}, - {95, 95, 2, 7, 31, 0, TIMEBASE_CUR, 6, "D\0"}, - {95, 95, 8, 7, 3, 0, TIMEBASE_CUR, 0, "S\0"}, - {96, 96, 2, 7, 15, 0, TIMEBASE_CUR, 6, "D\0"}, - {96, 96, 8, 7, 16, 0, TIMEBASE_CUR, 0, "S\0"}, - {97, 97, 2, 7, 21, 0, TIMEBASE_CUR, 6, "D\0"}, - {97, 97, 8, 7, 14, 0, TIMEBASE_CUR, 0, "S\0"}, - {98, 98, 2, 7, 20, 0, TIMEBASE_CUR, 6, "D\0"}, - {98, 98, 8, 7, 6, 0, TIMEBASE_CUR, 0, "S\0"}, - {99, 99, 3, 7, 2, 120, TIMEBASE_CUR, 6, "D\0"}, - {99, 99, 8, 7, 3, 120, TIMEBASE_CUR, 0, "S\0"}, - {100, 100, 3, 7, 14, 120, TIMEBASE_CUR, 6, "D\0"}, - {100, 100, 9, 7, 6, 60, TIMEBASE_CUR, 0, "S\0"}, - {101, 101, 3, 7, 9, 60, TIMEBASE_CUR, 6, "D\0"}, - {101, 101, 8, 7, 24, 60, TIMEBASE_CUR, 0, "S\0"}, - {102, 102, 2, 7, 29, 60, TIMEBASE_CUR, 6, "D\0"}, - {102, 102, 9, 7, 7, 60, TIMEBASE_CUR, 0, "S\0"}, - {103, 103, 2, 7, 28, 60, TIMEBASE_CUR, 6, "D\0"}, - {103, 103, 9, 7, 3, 60, TIMEBASE_CUR, 0, "S\0"}, - {104, 104, 3, 7, 7, 60, TIMEBASE_CUR, 6, "D\0"}, - {104, 104, 8, 7, 22, 60, TIMEBASE_CUR, 0, "S\0"}, - {105, 105, 3, 7, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {105, 105, 9, 7, 9, 120, TIMEBASE_CUR, 0, "S\0"}, - {106, 110, 2, 5, 26, 120, TIMEBASE_CUR, 6, "D\0"}, - {106, 106, 9, 7, 1, 120, TIMEBASE_CUR, 0, "S\0"}, - {107, 107, 8, 7, 16, 120, TIMEBASE_CUR, 0, "S\0"}, - {108, 108, 9, 7, 5, 120, TIMEBASE_CUR, 0, "S\0"}, - {109, 109, 8, 7, 27, 120, TIMEBASE_CUR, 0, "S\0"}, - {110, 110, 8, 7, 12, 120, TIMEBASE_CUR, 0, "S\0"}, - {111, 111, 3, 7, 1, 120, TIMEBASE_CUR, 6, "D\0"}, - {111, 111, 9, 7, 2, 120, TIMEBASE_CUR, 0, "S\0"}, - {112, 112, 2, 5, 26, 120, TIMEBASE_CUR, 6, "D\0"}, - {112, 112, 8, 7, 23, 120, TIMEBASE_CUR, 0, "S\0"}, - {113, 255, 2, 5, 23, 120, TIMEBASE_CUR, 6, "D\0"}, - {113, 255, 9, 0, 25, 120, TIMEBASE_CUR, 0, "S\0"}, -}; -static const struct lc_timezone_era eras_Africa_Abidjan[] = { - {NULL, 0, -968, -1830383032LL, 0, "LMT\0", "\0"}, - {NULL, 0, 0, 0, 0, "GMT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Accra[] = { - {NULL, 0, -52, -1640995148LL, 0, "LMT\0", "\0"}, - {rules_Ghana, 2, 0, 0, 0, "GMT\0", "+0020\0"}, -}; -static const struct lc_timezone_era eras_Africa_Algiers[] = { - {NULL, 0, 732, -2486679072LL, 0, "LMT\0", "\0"}, - {NULL, 0, 561, -1855958961LL, 0, "PMT\0", "\0"}, - {rules_Algeria, 22, 0, -942012000LL, 0, "WE%sT\0", "\0"}, - {rules_Algeria, 22, 3600, -733280400LL, 0, "CE%sT\0", "\0"}, - {NULL, 0, 0, -439430400LL, 0, "WET\0", "\0"}, - {NULL, 0, 3600, -212029200LL, 0, "CET\0", "\0"}, - {rules_Algeria, 22, 0, 246236400LL, 6, "WE%sT\0", "\0"}, - {rules_Algeria, 22, 3600, 309740400LL, 0, "CE%sT\0", "\0"}, - {rules_Algeria, 22, 0, 357523200LL, 0, "WE%sT\0", "\0"}, - {NULL, 0, 3600, 0, 0, "CET\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Bissau[] = { - {NULL, 0, -3740, -1830380260LL, 0, "LMT\0", "\0"}, - {NULL, 0, -3600, 157770000LL, 0, "-01\0", "\0"}, - {NULL, 0, 0, 0, 0, "GMT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Cairo[] = { - {NULL, 0, 7509, -2185409109LL, 0, "LMT\0", "\0"}, - {rules_Egypt, 32, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Casablanca[] = { - {NULL, 0, -1820, -1773012580LL, 0, "LMT\0", "\0"}, - {rules_Morocco, 54, 0, 448243200LL, 0, "WE%sT\0", "\0"}, - {NULL, 0, 3600, 504918000LL, 0, "CET\0", "\0"}, - {rules_Morocco, 54, 0, 0, 0, "WE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Ceuta[] = { - {NULL, 0, -1276, -2177452800LL, 0, "LMT\0", "\0"}, - {NULL, 0, 0, -1630112400LL, 0, "WET\0", "\0"}, - {rules_100, 1, 0, -1616810400LL, 6, "WEST\0", "\0"}, - {NULL, 0, 0, -1451692800LL, 0, "WET\0", "\0"}, - {rules_Spain, 30, 0, -1293840000LL, 0, "WE%sT\0", "\0"}, - {rules_SpainAfrica, 9, 0, 448243200LL, 0, "WE%sT\0", "\0"}, - {NULL, 0, 3600, 504918000LL, 0, "CET\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_El_Aaiun[] = { - {NULL, 0, -3168, -1136070432LL, 0, "LMT\0", "\0"}, - {NULL, 0, -3600, 198291600LL, 0, "-01\0", "\0"}, - {rules_Morocco, 54, 0, 0, 0, "WE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Johannesburg[] = { - {NULL, 0, 6720, -2458173120LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5400, -2109288600LL, 0, "SAST\0", "\0"}, - {rules_SA, 2, 7200, 0, 0, "SAST\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Khartoum[] = { - {NULL, 0, 7808, -1230775808LL, 0, "LMT\0", "\0"}, - {rules_Sudan, 4, 7200, 947930400LL, 0, "CA%sT\0", "\0"}, - {NULL, 0, 10800, 0, 0, "EAT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Lagos[] = { - {NULL, 0, 816, -1588464816LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3600, 0, 0, "WAT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Maputo[] = { - {NULL, 0, 7820, -2109291020LL, 0, "LMT\0", "\0"}, - {NULL, 0, 7200, 0, 0, "CAT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Monrovia[] = { - {NULL, 0, -2588, -2776979812LL, 0, "LMT\0", "\0"}, - {NULL, 0, -2588, -1604359012LL, 0, "MMT\0", "\0"}, - {NULL, 0, -2670, 63593070LL, 0, "MMT\0", "\0"}, - {NULL, 0, 0, 0, 0, "GMT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Nairobi[] = { - {NULL, 0, 8836, -1309746436LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1262314800LL, 0, "EAT\0", "\0"}, - {NULL, 0, 9000, -946780200LL, 0, "+0230\0", "\0"}, - {NULL, 0, 9900, -315629100LL, 0, "+0245\0", "\0"}, - {NULL, 0, 10800, 0, 0, "EAT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Ndjamena[] = { - {NULL, 0, 3612, -1830387612LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3600, 308703600LL, 0, "WAT\0", "\0"}, - {rules_100, 1, 3600, 321314400LL, 6, "WAST\0", "\0"}, - {NULL, 0, 3600, 0, 0, "WAT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Tripoli[] = { - {NULL, 0, 3164, -1577926364LL, 0, "LMT\0", "\0"}, - {rules_Libya, 17, 3600, -347158800LL, 0, "CE%sT\0", "\0"}, - {NULL, 0, 7200, 378684000LL, 0, "EET\0", "\0"}, - {rules_Libya, 17, 3600, 641775600LL, 0, "CE%sT\0", "\0"}, - {NULL, 0, 7200, 844034400LL, 0, "EET\0", "\0"}, - {rules_Libya, 17, 3600, 875916000LL, 6, "CE%sT\0", "\0"}, - {NULL, 0, 7200, 1352505600LL, 0, "EET\0", "\0"}, - {rules_Libya, 17, 3600, 1382659200LL, 6, "CE%sT\0", "\0"}, - {NULL, 0, 7200, 0, 0, "EET\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Tunis[] = { - {NULL, 0, 2444, -2797202444LL, 0, "LMT\0", "\0"}, - {NULL, 0, 561, -1855958961LL, 0, "PMT\0", "\0"}, - {rules_Tunisia, 25, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Africa_Windhoek[] = { - {NULL, 0, 4104, -2458170504LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5400, -2109288600LL, 0, "+0130\0", "\0"}, - {NULL, 0, 7200, -860976000LL, 0, "SAST\0", "\0"}, - {rules_100, 1, 7200, -845254800LL, 6, "SAST\0", "\0"}, - {NULL, 0, 7200, 637970400LL, 0, "SAST\0", "\0"}, - {NULL, 0, 7200, 765324000LL, 0, "CAT\0", "\0"}, - {rules_Namibia, 2, 3600, 0, 0, "WA%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Adak[] = { - {NULL, 0, 44001, -3225356001LL, 0, "LMT\0", "\0"}, - {NULL, 0, -42398, -2188944802LL, 0, "LMT\0", "\0"}, - {NULL, 0, -39600, -883573200LL, 0, "NST\0", "\0"}, - {rules_US, 13, -39600, -757342800LL, 0, "N%sT\0", "\0"}, - {NULL, 0, -39600, -86878800LL, 0, "NST\0", "\0"}, - {NULL, 0, -39600, -31496400LL, 0, "BST\0", "\0"}, - {rules_US, 13, -39600, 436363200LL, 6, "B%sT\0", "\0"}, - {rules_US, 13, -36000, 439034400LL, 0, "AH%sT\0", "\0"}, - {rules_US, 13, -36000, 0, 0, "H%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Anchorage[] = { - {NULL, 0, 50424, -3225362424LL, 0, "LMT\0", "\0"}, - {NULL, 0, -35976, -2188951224LL, 0, "LMT\0", "\0"}, - {NULL, 0, -36000, -883576800LL, 0, "AST\0", "\0"}, - {rules_US, 13, -36000, -86882400LL, 0, "A%sT\0", "\0"}, - {NULL, 0, -36000, -31500000LL, 0, "AHST\0", "\0"}, - {rules_US, 13, -36000, 436359600LL, 6, "AH%sT\0", "\0"}, - {rules_US, 13, -32400, 439030800LL, 0, "Y%sT\0", "\0"}, - {rules_US, 13, -32400, 0, 0, "AK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Araguaina[] = { - {NULL, 0, -11568, -1767214032LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -10800, 653540400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 811047600LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 1064372400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 1350788400LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 1378004400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Buenos_Aires[] = { - {NULL, 0, -14028, -2372097972LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 0, 0, "-03\0", "-02\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Catamarca[] = { - {NULL, 0, -15788, -2372096212LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 667965600LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 687931200LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 1086058800LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1087704000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Cordoba[] = { - {NULL, 0, -15408, -2372096592LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 667965600LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 687931200LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 0, 0, "-03\0", "-02\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Jujuy[] = { - {NULL, 0, -15672, -2372096328LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 636516000LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 657086400LL, 0, "-04\0", "\0"}, - {rules_100, 1, -14400, 669178800LL, 6, "-03\0", "\0"}, - {NULL, 0, -14400, 686721600LL, 0, "-04\0", "\0"}, - {rules_100, 1, -10800, 694231200LL, 6, "-02\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_La_Rioja[] = { - {NULL, 0, -16044, -2372095956LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 667792800LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 673588800LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 1086058800LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1087704000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Mendoza[] = { - {NULL, 0, -16516, -2372095484LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 636516000LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 655963200LL, 0, "-04\0", "\0"}, - {rules_100, 1, -14400, 667796400LL, 6, "-03\0", "\0"}, - {NULL, 0, -14400, 687499200LL, 0, "-04\0", "\0"}, - {rules_100, 1, -14400, 699418800LL, 6, "-03\0", "\0"}, - {NULL, 0, -14400, 719380800LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 1085281200LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1096171200LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Rio_Gallegos[] = { - {NULL, 0, -16612, -2372095388LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 1086058800LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1087704000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Salta[] = { - {NULL, 0, -15700, -2372096300LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 667965600LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 687931200LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_San_Juan[] = { - {NULL, 0, -16444, -2372095556LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 667792800LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 673588800LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 1085972400LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1090728000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_San_Luis[] = { - {NULL, 0, -15924, -2372096076LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 631159200LL, 6, "-03\0", "-02\0"}, - {rules_100, 1, -10800, 637380000LL, 6, "-02\0", "\0"}, - {NULL, 0, -14400, 655963200LL, 0, "-04\0", "\0"}, - {rules_100, 1, -14400, 667796400LL, 6, "-03\0", "\0"}, - {NULL, 0, -14400, 675748800LL, 0, "-04\0", "\0"}, - {NULL, 0, -10800, 938919600LL, 0, "-03\0", "\0"}, - {rules_100, 1, -14400, 952052400LL, 6, "-03\0", "\0"}, - {NULL, 0, -10800, 1085972400LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1090728000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 1200880800LL, 6, "-03\0", "-02\0"}, - {rules_SanLuis, 2, -14400, 1255233600LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Tucuman[] = { - {NULL, 0, -15652, -2372096348LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 667965600LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -14400, 687931200LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 1086058800LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1087099200LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 0, 0, "-03\0", "-02\0"}, -}; -static const struct lc_timezone_era eras_America_Argentina_Ushuaia[] = { - {NULL, 0, -16392, -2372095608LL, 0, "LMT\0", "\0"}, - {NULL, 0, -15408, -1567453392LL, 0, "CMT\0", "\0"}, - {NULL, 0, -14400, -1233432000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 938919600LL, 0, "-03\0", "-02\0"}, - {rules_Arg, 29, -14400, 952052400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 1085886000LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 1087704000LL, 0, "-04\0", "\0"}, - {rules_Arg, 29, -10800, 1224298800LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Asuncion[] = { - {NULL, 0, -13840, -2524507760LL, 0, "LMT\0", "\0"}, - {NULL, 0, -13840, -1206389360LL, 0, "AMT\0", "\0"}, - {NULL, 0, -14400, 86760000LL, 0, "-04\0", "\0"}, - {NULL, 0, -10800, 134017200LL, 0, "-03\0", "\0"}, - {rules_Para, 22, -14400, 0, 0, "-04\0", "-03\0"}, -}; -static const struct lc_timezone_era eras_America_Atikokan[] = { - {NULL, 0, -21988, -2366733212LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -21600, -923248800LL, 0, "C%sT\0", "\0"}, - {rules_100, 1, -21600, -880214400LL, 6, "CDT\0", "\0"}, - {rules_Canada, 10, -21600, -765392400LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, 0, 0, "EST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Bahia[] = { - {NULL, 0, -9244, -1767216356LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -10800, 1064372400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 1318734000LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 1350788400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Bahia_Banderas[] = { - {NULL, 0, -25260, -1514739600LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1343066400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1234807200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1220292000LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1207159200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1191344400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -873828000LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -661539600LL, 0, "MST\0", "\0"}, - {NULL, 0, -28800, 28800LL, 0, "PST\0", "\0"}, - {rules_Mexico, 14, -25200, 1270371600LL, 0, "M%sT\0", "\0"}, - {rules_Mexico, 14, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Barbados[] = { - {NULL, 0, -14309, -1451678491LL, 0, "LMT\0", "\0"}, - {NULL, 0, -14309, -1199217691LL, 0, "BMT\0", "\0"}, - {rules_Barb, 5, -14400, 0, 0, "A%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Belem[] = { - {NULL, 0, -11636, -1767213964LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -10800, 590036400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Belize[] = { - {NULL, 0, -21168, -1822500432LL, 0, "LMT\0", "\0"}, - {rules_Belize, 6, -21600, 0, 0, "%s\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Blanc_Sablon[] = { - {NULL, 0, -13708, -2713896692LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -14400, 14400LL, 0, "A%sT\0", "\0"}, - {NULL, 0, -14400, 0, 0, "AST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Boa_Vista[] = { - {NULL, 0, -14560, -1767211040LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -14400, 590040000LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -14400, 938664000LL, 0, "-04\0", "\0"}, - {rules_Brazil, 64, -14400, 971578800LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -14400, 0, 0, "-04\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Bogota[] = { - {NULL, 0, -17776, -2707671824LL, 0, "LMT\0", "\0"}, - {NULL, 0, -17776, -1739041424LL, 0, "BMT\0", "\0"}, - {rules_CO, 2, -18000, 0, 0, "-05\0", "-04\0"}, -}; -static const struct lc_timezone_era eras_America_Boise[] = { - {NULL, 0, -27889, -2717640000LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -28800, -1471788000LL, 0, "P%sT\0", "\0"}, - {rules_US, 13, -25200, 126255600LL, 0, "M%sT\0", "\0"}, - {NULL, 0, -25200, 129114000LL, 0, "MST\0", "\0"}, - {rules_US, 13, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Cambridge_Bay[] = { - {NULL, 0, 0, -1577923200LL, 0, "-00\0", "\0"}, - {rules_NT_YK, 12, -25200, 941356800LL, 6, "M%sT\0", "\0"}, - {rules_Canada, 10, -21600, 972802800LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, 973400400LL, 0, "EST\0", "\0"}, - {NULL, 0, -21600, 986115600LL, 0, "CST\0", "\0"}, - {rules_Canada, 10, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Campo_Grande[] = { - {NULL, 0, -13108, -1767212492LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -14400, 0, 0, "-04\0", "-03\0"}, -}; -static const struct lc_timezone_era eras_America_Cancun[] = { - {NULL, 0, -20824, -1514743200LL, 0, "LMT\0", "\0"}, - {NULL, 0, -21600, 377935200LL, 0, "CST\0", "\0"}, - {rules_Mexico, 14, -18000, 902037600LL, 6, "E%sT\0", "\0"}, - {rules_Mexico, 14, -21600, 1422777600LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, 0, 0, "EST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Caracas[] = { - {NULL, 0, -16064, -2524505536LL, 0, "LMT\0", "\0"}, - {NULL, 0, -16060, -1826739140LL, 0, "CMT\0", "\0"}, - {NULL, 0, -16200, -157750200LL, 0, "-0430\0", "\0"}, - {NULL, 0, -14400, 1197183600LL, 0, "-04\0", "\0"}, - {NULL, 0, -16200, 1462086000LL, 0, "-0430\0", "\0"}, - {NULL, 0, -14400, 0, 0, "-04\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Cayenne[] = { - {NULL, 0, -12560, -1846269040LL, 0, "LMT\0", "\0"}, - {NULL, 0, -14400, -71092800LL, 0, "-04\0", "\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Chicago[] = { - {NULL, 0, -21036, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -1577901600LL, 0, "C%sT\0", "\0"}, - {rules_Chicago, 6, -21600, -1067788800LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -1045414800LL, 0, "EST\0", "\0"}, - {rules_Chicago, 6, -21600, -883591200LL, 0, "C%sT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {rules_Chicago, 6, -21600, -94672800LL, 0, "C%sT\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Chihuahua[] = { - {NULL, 0, -25460, -1514739600LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1343066400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1234807200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1220292000LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1207159200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1191344400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, 820476000LL, 0, "CST\0", "\0"}, - {rules_Mexico, 14, -21600, 883634400LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -21600, 891766800LL, 0, "CST\0", "\0"}, - {rules_Mexico, 14, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Costa_Rica[] = { - {NULL, 0, -20173, -2524501427LL, 0, "LMT\0", "\0"}, - {NULL, 0, -20173, -1545071027LL, 0, "SJMT\0", "\0"}, - {rules_CR, 5, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Creston[] = { - {NULL, 0, -27964, -2713882436LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1680454800LL, 0, "MST\0", "\0"}, - {NULL, 0, -28800, -1627833600LL, 0, "PST\0", "\0"}, - {NULL, 0, -25200, 0, 0, "MST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Cuiaba[] = { - {NULL, 0, -13460, -1767212140LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -14400, 1064376000LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -14400, 1096603200LL, 0, "-04\0", "\0"}, - {rules_Brazil, 64, -14400, 0, 0, "-04\0", "-03\0"}, -}; -static const struct lc_timezone_era eras_America_Curacao[] = { - {NULL, 0, -16547, -1826738653LL, 0, "LMT\0", "\0"}, - {NULL, 0, -16200, -157750200LL, 0, "-0430\0", "\0"}, - {NULL, 0, -14400, 0, 0, "AST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Danmarkshavn[] = { - {NULL, 0, -4480, -1686091520LL, 0, "LMT\0", "\0"}, - {NULL, 0, -10800, 323845200LL, 0, "-03\0", "\0"}, - {rules_EU, 6, -10800, 820465200LL, 0, "-03\0", "-02\0"}, - {NULL, 0, 0, 0, 0, "GMT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Dawson[] = { - {NULL, 0, -33460, -2188996940LL, 0, "LMT\0", "\0"}, - {rules_NT_YK, 12, -32400, 120646800LL, 0, "Y%sT\0", "\0"}, - {rules_NT_YK, 12, -28800, 315561600LL, 0, "P%sT\0", "\0"}, - {rules_Canada, 10, -28800, 0, 0, "P%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Dawson_Creek[] = { - {NULL, 0, -28856, -2713881544LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -28800, -725817600LL, 0, "P%sT\0", "\0"}, - {rules_Vanc, 9, -28800, 84013200LL, 6, "P%sT\0", "\0"}, - {NULL, 0, -25200, 0, 0, "MST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Denver[] = { - {NULL, 0, -25196, -2717643600LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -25200, -1577898000LL, 0, "M%sT\0", "\0"}, - {rules_Denver, 5, -25200, -883587600LL, 0, "M%sT\0", "\0"}, - {rules_US, 13, -25200, -757357200LL, 0, "M%sT\0", "\0"}, - {rules_Denver, 5, -25200, -94669200LL, 0, "M%sT\0", "\0"}, - {rules_US, 13, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Detroit[] = { - {NULL, 0, -19931, -2051202469LL, 0, "LMT\0", "\0"}, - {NULL, 0, -21600, -1724083200LL, 0, "CST\0", "\0"}, - {NULL, 0, -18000, -883594800LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, -757364400LL, 0, "E%sT\0", "\0"}, - {rules_Detroit, 4, -18000, 94712400LL, 0, "E%sT\0", "\0"}, - {rules_US, 13, -18000, 157784400LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 167814000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Edmonton[] = { - {NULL, 0, -27232, -1998663968LL, 0, "LMT\0", "\0"}, - {rules_Edm, 17, -25200, 536482800LL, 0, "M%sT\0", "\0"}, - {rules_Canada, 10, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Eirunepe[] = { - {NULL, 0, -16768, -1767208832LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -18000, 590043600LL, 0, "-05\0", "-04\0"}, - {NULL, 0, -18000, 749192400LL, 0, "-05\0", "\0"}, - {rules_Brazil, 64, -18000, 780210000LL, 0, "-05\0", "-04\0"}, - {NULL, 0, -18000, 1214283600LL, 0, "-05\0", "\0"}, - {NULL, 0, -14400, 1384056000LL, 0, "-04\0", "\0"}, - {NULL, 0, -18000, 0, 0, "-05\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_El_Salvador[] = { - {NULL, 0, -21408, -1546279392LL, 0, "LMT\0", "\0"}, - {rules_Salv, 2, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Fort_Nelson[] = { - {NULL, 0, -29447, -2713880953LL, 0, "LMT\0", "\0"}, - {rules_Vanc, 9, -28800, -757353600LL, 0, "P%sT\0", "\0"}, - {NULL, 0, -28800, -725817600LL, 0, "PST\0", "\0"}, - {rules_Vanc, 9, -28800, 536486400LL, 0, "P%sT\0", "\0"}, - {rules_Canada, 10, -28800, 1425808800LL, 0, "P%sT\0", "\0"}, - {NULL, 0, -25200, 0, 0, "MST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Fortaleza[] = { - {NULL, 0, -9240, -1767216360LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -10800, 653540400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 938660400LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 972180000LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -10800, 1000350000LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 1033441200LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Glace_Bay[] = { - {NULL, 0, -14388, -2131646412LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -14400, -536443200LL, 0, "A%sT\0", "\0"}, - {rules_Halifax, 41, -14400, -504907200LL, 0, "A%sT\0", "\0"}, - {NULL, 0, -14400, 63086400LL, 0, "AST\0", "\0"}, - {rules_Halifax, 41, -14400, 126244800LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, 0, 0, "A%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Godthab[] = { - {NULL, 0, -12416, -1686083584LL, 0, "LMT\0", "\0"}, - {NULL, 0, -10800, 323845200LL, 0, "-03\0", "\0"}, - {rules_EU, 6, -10800, 0, 0, "-03\0", "-02\0"}, -}; -static const struct lc_timezone_era eras_America_Goose_Bay[] = { - {NULL, 0, -14500, -2713895900LL, 0, "LMT\0", "\0"}, - {NULL, 0, -12652, -1640982548LL, 0, "NST\0", "\0"}, - {rules_Canada, 10, -12652, -1609446548LL, 0, "N%sT\0", "\0"}, - {NULL, 0, -12652, -1096921748LL, 0, "NST\0", "\0"}, - {NULL, 0, -12600, -1072989000LL, 0, "NST\0", "\0"}, - {rules_StJohns, 19, -12600, -872368200LL, 0, "N%sT\0", "\0"}, - {rules_Canada, 10, -12600, -757369800LL, 0, "N%sT\0", "\0"}, - {rules_StJohns, 19, -12600, -119903400LL, 0, "N%sT\0", "\0"}, - {rules_StJohns, 19, -14400, 1320116400LL, 6, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, 0, 0, "A%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Grand_Turk[] = { - {NULL, 0, -17072, -2524504528LL, 0, "LMT\0", "\0"}, - {NULL, 0, -18431, -1827687169LL, 0, "KMT\0", "\0"}, - {NULL, 0, -18000, 284014800LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 1446357600LL, 6, "E%sT\0", "\0"}, - {NULL, 0, -14400, 0, 0, "AST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Guatemala[] = { - {NULL, 0, -21724, -1617040676LL, 0, "LMT\0", "\0"}, - {rules_Guat, 8, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Guayaquil[] = { - {NULL, 0, -19160, -2524502440LL, 0, "LMT\0", "\0"}, - {NULL, 0, -18840, -1230749160LL, 0, "QMT\0", "\0"}, - {rules_Ecuador, 2, -18000, 0, 0, "-05\0", "-04\0"}, -}; -static const struct lc_timezone_era eras_America_Guyana[] = { - {NULL, 0, -13960, -1730578040LL, 0, "LMT\0", "\0"}, - {NULL, 0, -13500, 176010300LL, 0, "-0345\0", "\0"}, - {NULL, 0, -10800, 662698800LL, 0, "-03\0", "\0"}, - {NULL, 0, -14400, 0, 0, "-04\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Halifax[] = { - {NULL, 0, -15264, -2131645536LL, 0, "LMT\0", "\0"}, - {rules_Halifax, 41, -14400, -1640980800LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, -1609444800LL, 0, "A%sT\0", "\0"}, - {rules_Halifax, 41, -14400, -880221600LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, -757368000LL, 0, "A%sT\0", "\0"}, - {rules_Halifax, 41, -14400, 126244800LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, 0, 0, "A%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Havana[] = { - {NULL, 0, -19768, -2524501832LL, 0, "LMT\0", "\0"}, - {NULL, 0, -19776, -1402813824LL, 0, "HMT\0", "\0"}, - {rules_Cuba, 39, -18000, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Hermosillo[] = { - {NULL, 0, -26632, -1514739600LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1343066400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1234807200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1220292000LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1207159200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1191344400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -873828000LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -661539600LL, 0, "MST\0", "\0"}, - {NULL, 0, -28800, 28800LL, 0, "PST\0", "\0"}, - {rules_Mexico, 14, -25200, 915174000LL, 0, "M%sT\0", "\0"}, - {NULL, 0, -25200, 0, 0, "MST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Indianapolis[] = { - {NULL, 0, -20678, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -1577901600LL, 0, "C%sT\0", "\0"}, - {rules_Indianapolis, 3, -21600, -883591200LL, 0, "C%sT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {rules_Indianapolis, 3, -21600, -463593600LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -386787600LL, 0, "EST\0", "\0"}, - {NULL, 0, -21600, -368640000LL, 0, "CST\0", "\0"}, - {NULL, 0, -18000, -31518000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 31554000LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 1136091600LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Knox[] = { - {NULL, 0, -20790, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -725824800LL, 0, "C%sT\0", "\0"}, - {rules_Starke, 5, -21600, -242236800LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -195066000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 688546800LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, 1143961200LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Marengo[] = { - {NULL, 0, -20723, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -599594400LL, 0, "C%sT\0", "\0"}, - {rules_Marengo, 4, -21600, -273686400LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -31518000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 126687600LL, 0, "E%sT\0", "\0"}, - {rules_100, 1, -21600, 152089200LL, 6, "CDT\0", "\0"}, - {rules_US, 13, -18000, 189320400LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 1136091600LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Petersburg[] = { - {NULL, 0, -20947, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -473364000LL, 0, "C%sT\0", "\0"}, - {rules_Pike, 4, -21600, -147888000LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -100112400LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 247042800LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, 1143961200LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 1194159600LL, 6, "C%sT\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Tell_City[] = { - {NULL, 0, -20823, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {rules_Perry, 9, -21600, -179337600LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -31518000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 31554000LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 1143961200LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Vevay[] = { - {NULL, 0, -20416, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -495043200LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -31518000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 94712400LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 1136091600LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Vincennes[] = { - {NULL, 0, -21007, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {rules_Vincennes, 9, -21600, -179337600LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -31518000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 31554000LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 1143961200LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 1194159600LL, 6, "C%sT\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Indiana_Winamac[] = { - {NULL, 0, -20785, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {rules_Pulaski, 4, -21600, -273686400LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, -31518000LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 31554000LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 1143961200LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 1173600000LL, 0, "C%sT\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Inuvik[] = { - {NULL, 0, 0, -536457600LL, 0, "-00\0", "\0"}, - {rules_NT_YK, 12, -28800, 294228000LL, 0, "P%sT\0", "\0"}, - {rules_NT_YK, 12, -25200, 315558000LL, 0, "M%sT\0", "\0"}, - {rules_Canada, 10, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Iqaluit[] = { - {NULL, 0, 0, -865296000LL, 0, "-00\0", "\0"}, - {rules_NT_YK, 12, -18000, 941349600LL, 6, "E%sT\0", "\0"}, - {rules_Canada, 10, -21600, 972802800LL, 6, "C%sT\0", "\0"}, - {rules_Canada, 10, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Jamaica[] = { - {NULL, 0, -18431, -2524503169LL, 0, "LMT\0", "\0"}, - {NULL, 0, -18431, -1827687169LL, 0, "KMT\0", "\0"}, - {NULL, 0, -18000, 126248400LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 441781200LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 0, 0, "EST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Juneau[] = { - {NULL, 0, 54139, -3225366139LL, 0, "LMT\0", "\0"}, - {NULL, 0, -32261, -2188954939LL, 0, "LMT\0", "\0"}, - {NULL, 0, -28800, -883584000LL, 0, "PST\0", "\0"}, - {rules_US, 13, -28800, -757353600LL, 0, "P%sT\0", "\0"}, - {NULL, 0, -28800, -31507200LL, 0, "PST\0", "\0"}, - {rules_US, 13, -28800, 325677600LL, 0, "P%sT\0", "\0"}, - {rules_US, 13, -32400, 341402400LL, 6, "Y%sT\0", "\0"}, - {rules_US, 13, -28800, 436352400LL, 6, "P%sT\0", "\0"}, - {rules_US, 13, -32400, 439030800LL, 0, "Y%sT\0", "\0"}, - {rules_US, 13, -32400, 0, 0, "AK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Kentucky_Louisville[] = { - {NULL, 0, -20582, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -1546279200LL, 0, "C%sT\0", "\0"}, - {rules_Louisville, 7, -21600, -883594800LL, 6, "C%sT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {rules_Louisville, 7, -21600, -266432400LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, -63140400LL, 0, "EST\0", "\0"}, - {rules_US, 13, -18000, 126687600LL, 0, "E%sT\0", "\0"}, - {rules_100, 1, -21600, 152089200LL, 6, "CDT\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Kentucky_Monticello[] = { - {NULL, 0, -20364, -2717647200LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -21600, -63136800LL, 0, "CST\0", "\0"}, - {rules_US, 13, -21600, 972802800LL, 6, "C%sT\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_La_Paz[] = { - {NULL, 0, -16356, -2524505244LL, 0, "LMT\0", "\0"}, - {NULL, 0, -16356, -1205954844LL, 0, "CMT\0", "\0"}, - {rules_100, 1, -16356, -1192307244LL, 6, "BOST\0", "\0"}, - {NULL, 0, -14400, 0, 0, "-04\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Lima[] = { - {NULL, 0, -18492, -2524503108LL, 0, "LMT\0", "\0"}, - {NULL, 0, -18516, -1938538284LL, 0, "LMT\0", "\0"}, - {rules_Peru, 10, -18000, 0, 0, "-05\0", "-04\0"}, -}; -static const struct lc_timezone_era eras_America_Los_Angeles[] = { - {NULL, 0, -28378, -2717640000LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -28800, -757353600LL, 0, "P%sT\0", "\0"}, - {rules_CA, 5, -28800, -94665600LL, 0, "P%sT\0", "\0"}, - {rules_US, 13, -28800, 0, 0, "P%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Maceio[] = { - {NULL, 0, -8572, -1767217028LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -10800, 653540400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 813553200LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 841806000LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 938660400LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 972180000LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -10800, 1000350000LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 1033441200LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Managua[] = { - {NULL, 0, -20708, -2524500892LL, 0, "LMT\0", "\0"}, - {NULL, 0, -20712, -1121105688LL, 0, "MMT\0", "\0"}, - {NULL, 0, -21600, 105084000LL, 0, "CST\0", "\0"}, - {NULL, 0, -18000, 161758800LL, 0, "EST\0", "\0"}, - {rules_Nic, 6, -21600, 694260000LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, 717310800LL, 0, "EST\0", "\0"}, - {NULL, 0, -21600, 725868000LL, 0, "CST\0", "\0"}, - {NULL, 0, -18000, 852094800LL, 0, "EST\0", "\0"}, - {rules_Nic, 6, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Manaus[] = { - {NULL, 0, -14404, -1767211196LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -14400, 590040000LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -14400, 749188800LL, 0, "-04\0", "\0"}, - {rules_Brazil, 64, -14400, 780206400LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -14400, 0, 0, "-04\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Martinique[] = { - {NULL, 0, -14660, -2524506940LL, 0, "LMT\0", "\0"}, - {NULL, 0, -14660, -1851537340LL, 0, "FFMT\0", "\0"}, - {NULL, 0, -14400, 323841600LL, 0, "AST\0", "\0"}, - {rules_100, 1, -14400, 338958000LL, 6, "ADT\0", "\0"}, - {NULL, 0, -14400, 0, 0, "AST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Matamoros[] = { - {NULL, 0, -24000, -1514743200LL, 0, "LMT\0", "\0"}, - {NULL, 0, -21600, 568015200LL, 0, "CST\0", "\0"}, - {rules_US, 13, -21600, 599637600LL, 0, "C%sT\0", "\0"}, - {rules_Mexico, 14, -21600, 1262325600LL, 0, "C%sT\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Mazatlan[] = { - {NULL, 0, -25540, -1514739600LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1343066400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1234807200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1220292000LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1207159200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1191344400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -873828000LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -661539600LL, 0, "MST\0", "\0"}, - {NULL, 0, -28800, 28800LL, 0, "PST\0", "\0"}, - {rules_Mexico, 14, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Menominee[] = { - {NULL, 0, -21027, -2659759773LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -21600, -757360800LL, 0, "C%sT\0", "\0"}, - {rules_Menominee, 4, -21600, -21484800LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -18000, 104914800LL, 0, "EST\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Merida[] = { - {NULL, 0, -21508, -1514743200LL, 0, "LMT\0", "\0"}, - {NULL, 0, -21600, 377935200LL, 0, "CST\0", "\0"}, - {NULL, 0, -18000, 407653200LL, 0, "EST\0", "\0"}, - {rules_Mexico, 14, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Metlakatla[] = { - {NULL, 0, 54822, -3225366822LL, 0, "LMT\0", "\0"}, - {NULL, 0, -31578, -2188955622LL, 0, "LMT\0", "\0"}, - {NULL, 0, -28800, -883584000LL, 0, "PST\0", "\0"}, - {rules_US, 13, -28800, -757353600LL, 0, "P%sT\0", "\0"}, - {NULL, 0, -28800, -31507200LL, 0, "PST\0", "\0"}, - {rules_US, 13, -28800, 436352400LL, 6, "P%sT\0", "\0"}, - {NULL, 0, -28800, 1446372000LL, 0, "PST\0", "\0"}, - {rules_US, 13, -32400, 0, 0, "AK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Mexico_City[] = { - {NULL, 0, -23796, -1514739600LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1343066400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1234807200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1220292000LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1207159200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1191344400LL, 0, "MST\0", "\0"}, - {rules_Mexico, 14, -21600, 1001833200LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -21600, 1014184800LL, 0, "CST\0", "\0"}, - {rules_Mexico, 14, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Miquelon[] = { - {NULL, 0, -13480, -1850328920LL, 0, "LMT\0", "\0"}, - {NULL, 0, -14400, 326001600LL, 0, "AST\0", "\0"}, - {NULL, 0, -10800, 536468400LL, 0, "-03\0", "\0"}, - {rules_Canada, 10, -10800, 0, 0, "-03\0", "-02\0"}, -}; -static const struct lc_timezone_era eras_America_Moncton[] = { - {NULL, 0, -15548, -2715882052LL, 0, "LMT\0", "\0"}, - {NULL, 0, -18000, -2131642800LL, 0, "EST\0", "\0"}, - {rules_Canada, 10, -14400, -1167595200LL, 0, "A%sT\0", "\0"}, - {rules_Moncton, 13, -14400, -883598400LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, -757368000LL, 0, "A%sT\0", "\0"}, - {rules_Moncton, 13, -14400, 94708800LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, 725860800LL, 0, "A%sT\0", "\0"}, - {rules_Moncton, 13, -14400, 1167624000LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -14400, 0, 0, "A%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Monterrey[] = { - {NULL, 0, -24076, -1514743200LL, 0, "LMT\0", "\0"}, - {NULL, 0, -21600, 568015200LL, 0, "CST\0", "\0"}, - {rules_US, 13, -21600, 599637600LL, 0, "C%sT\0", "\0"}, - {rules_Mexico, 14, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Montevideo[] = { - {NULL, 0, -13484, -2256668116LL, 0, "LMT\0", "\0"}, - {NULL, 0, -13484, -1567455316LL, 0, "MMT\0", "\0"}, - {rules_Uruguay, 45, -12600, -853619400LL, 0, "-0330\0", "-03\0"}, - {rules_Uruguay, 45, -10800, -63147600LL, 0, "-03\0", "-02\0"}, - {rules_Uruguay, 45, -10800, 31546800LL, 0, "-03\0", "-0230\0"}, - {rules_Uruguay, 45, -10800, 126237600LL, 6, "-03\0", "-02\0"}, - {rules_Uruguay, 45, -10800, 156911400LL, 3, "-03\0", "-0230\0"}, - {rules_Uruguay, 45, -10800, 0, 0, "-03\0", "-02\0"}, -}; -static const struct lc_timezone_era eras_America_Nassau[] = { - {NULL, 0, -18570, -1825095030LL, 0, "LMT\0", "\0"}, - {rules_Bahamas, 2, -18000, 189320400LL, 0, "E%sT\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_New_York[] = { - {NULL, 0, -17762, -2717650800LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -18000, -1577905200LL, 0, "E%sT\0", "\0"}, - {rules_NYC, 5, -18000, -883594800LL, 0, "E%sT\0", "\0"}, - {rules_US, 13, -18000, -757364400LL, 0, "E%sT\0", "\0"}, - {rules_NYC, 5, -18000, -94676400LL, 0, "E%sT\0", "\0"}, - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Nipigon[] = { - {NULL, 0, -21184, -2366734016LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -18000, -923252400LL, 0, "E%sT\0", "\0"}, - {rules_100, 1, -18000, -880218000LL, 6, "EDT\0", "\0"}, - {rules_Canada, 10, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Nome[] = { - {NULL, 0, 46701, -3225358701LL, 0, "LMT\0", "\0"}, - {NULL, 0, -39698, -2188947502LL, 0, "LMT\0", "\0"}, - {NULL, 0, -39600, -883573200LL, 0, "NST\0", "\0"}, - {rules_US, 13, -39600, -757342800LL, 0, "N%sT\0", "\0"}, - {NULL, 0, -39600, -86878800LL, 0, "NST\0", "\0"}, - {NULL, 0, -39600, -31496400LL, 0, "BST\0", "\0"}, - {rules_US, 13, -39600, 436363200LL, 6, "B%sT\0", "\0"}, - {rules_US, 13, -32400, 439030800LL, 0, "Y%sT\0", "\0"}, - {rules_US, 13, -32400, 0, 0, "AK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Noronha[] = { - {NULL, 0, -7780, -1767217820LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -7200, 653536800LL, 0, "-02\0", "-01\0"}, - {NULL, 0, -7200, 938656800LL, 0, "-02\0", "\0"}, - {rules_Brazil, 64, -7200, 971571600LL, 6, "-02\0", "-01\0"}, - {NULL, 0, -7200, 1000346400LL, 0, "-02\0", "\0"}, - {rules_Brazil, 64, -7200, 1033437600LL, 0, "-02\0", "-01\0"}, - {NULL, 0, -7200, 0, 0, "-02\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_North_Dakota_Beulah[] = { - {NULL, 0, -24427, -2717643600LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -25200, 1289116800LL, 6, "M%sT\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_North_Dakota_Center[] = { - {NULL, 0, -24312, -2717643600LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -25200, 720000000LL, 6, "M%sT\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_North_Dakota_New_Salem[] = { - {NULL, 0, -24339, -2717643600LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -25200, 1067155200LL, 6, "M%sT\0", "\0"}, - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Ojinaga[] = { - {NULL, 0, -25060, -1514739600LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1343066400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1234807200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1220292000LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, -1207159200LL, 0, "CST\0", "\0"}, - {NULL, 0, -25200, -1191344400LL, 0, "MST\0", "\0"}, - {NULL, 0, -21600, 820476000LL, 0, "CST\0", "\0"}, - {rules_Mexico, 14, -21600, 883634400LL, 0, "C%sT\0", "\0"}, - {NULL, 0, -21600, 891766800LL, 0, "CST\0", "\0"}, - {rules_Mexico, 14, -25200, 1262329200LL, 0, "M%sT\0", "\0"}, - {rules_US, 13, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Panama[] = { - {NULL, 0, -19088, -2524502512LL, 0, "LMT\0", "\0"}, - {NULL, 0, -19176, -1946918424LL, 0, "CMT\0", "\0"}, - {NULL, 0, -18000, 0, 0, "EST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Pangnirtung[] = { - {NULL, 0, 0, -1546300800LL, 0, "-00\0", "\0"}, - {rules_NT_YK, 12, -14400, 796802400LL, 0, "A%sT\0", "\0"}, - {rules_Canada, 10, -18000, 941349600LL, 6, "E%sT\0", "\0"}, - {rules_Canada, 10, -21600, 972802800LL, 6, "C%sT\0", "\0"}, - {rules_Canada, 10, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Paramaribo[] = { - {NULL, 0, -13240, -1861906760LL, 0, "LMT\0", "\0"}, - {NULL, 0, -13252, -1104524348LL, 0, "PMT\0", "\0"}, - {NULL, 0, -13236, -765317964LL, 0, "PMT\0", "\0"}, - {NULL, 0, -12600, 465449400LL, 0, "-0330\0", "\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Phoenix[] = { - {NULL, 0, -26898, -2717643600LL, 0, "LMT\0", "\0"}, - {rules_US, 13, -25200, -820519140LL, 6, "M%sT\0", "\0"}, - {NULL, 0, -25200, -812653140LL, 0, "MST\0", "\0"}, - {rules_US, 13, -25200, -796845540LL, 6, "M%sT\0", "\0"}, - {NULL, 0, -25200, -94669200LL, 0, "MST\0", "\0"}, - {rules_US, 13, -25200, -56221200LL, 0, "M%sT\0", "\0"}, - {NULL, 0, -25200, 0, 0, "MST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Port_au_Prince[] = { - {NULL, 0, -17360, -2524504240LL, 0, "LMT\0", "\0"}, - {NULL, 0, -17340, -1670483460LL, 0, "PPMT\0", "\0"}, - {rules_Haiti, 11, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Port_of_Spain[] = { - {NULL, 0, -14764, -1825098836LL, 0, "LMT\0", "\0"}, - {NULL, 0, -14400, 0, 0, "AST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Porto_Velho[] = { - {NULL, 0, -15336, -1767210264LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -14400, 590040000LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -14400, 0, 0, "-04\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Puerto_Rico[] = { - {NULL, 0, -15865, -2233035335LL, 0, "LMT\0", "\0"}, - {NULL, 0, -14400, -873057600LL, 0, "AST\0", "\0"}, - {rules_US, 13, -14400, -757368000LL, 0, "A%sT\0", "\0"}, - {NULL, 0, -14400, 0, 0, "AST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Punta_Arenas[] = { - {NULL, 0, -17020, -2524504580LL, 0, "LMT\0", "\0"}, - {NULL, 0, -16966, -1892661434LL, 0, "SMT\0", "\0"}, - {NULL, 0, -18000, -1688410800LL, 0, "-05\0", "\0"}, - {NULL, 0, -16966, -1619205434LL, 0, "SMT\0", "\0"}, - {NULL, 0, -14400, -1593806400LL, 0, "-04\0", "\0"}, - {NULL, 0, -16966, -1335986234LL, 0, "SMT\0", "\0"}, - {rules_Chile, 32, -18000, -1178132400LL, 0, "-05\0", "-04\0"}, - {NULL, 0, -14400, -870552000LL, 0, "-04\0", "\0"}, - {NULL, 0, -18000, -865278000LL, 0, "-05\0", "\0"}, - {NULL, 0, -14400, -718056000LL, 0, "-04\0", "\0"}, - {NULL, 0, -18000, -713649600LL, 0, "-05\0", "\0"}, - {rules_Chile, 32, -14400, 1480820400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Rainy_River[] = { - {NULL, 0, -22696, -2366732504LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -21600, -923248800LL, 0, "C%sT\0", "\0"}, - {rules_100, 1, -21600, -880214400LL, 6, "CDT\0", "\0"}, - {rules_Canada, 10, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Rankin_Inlet[] = { - {NULL, 0, 0, -410227200LL, 0, "-00\0", "\0"}, - {rules_NT_YK, 12, -21600, 972802800LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, 986112000LL, 0, "EST\0", "\0"}, - {rules_Canada, 10, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Recife[] = { - {NULL, 0, -8376, -1767217224LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -10800, 653540400LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 938660400LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 971575200LL, 6, "-03\0", "-02\0"}, - {NULL, 0, -10800, 1000350000LL, 0, "-03\0", "\0"}, - {rules_Brazil, 64, -10800, 1033441200LL, 0, "-03\0", "-02\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Regina[] = { - {NULL, 0, -25116, -2030202084LL, 0, "LMT\0", "\0"}, - {rules_Regina, 17, -25200, -305737200LL, 0, "M%sT\0", "\0"}, - {NULL, 0, -21600, 0, 0, "CST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Resolute[] = { - {NULL, 0, 0, -704937600LL, 0, "-00\0", "\0"}, - {rules_NT_YK, 12, -21600, 972802800LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, 986112000LL, 0, "EST\0", "\0"}, - {rules_Canada, 10, -21600, 1162105200LL, 6, "C%sT\0", "\0"}, - {NULL, 0, -18000, 1173600000LL, 0, "EST\0", "\0"}, - {rules_Canada, 10, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Rio_Branco[] = { - {NULL, 0, -16272, -1767209328LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -18000, 590043600LL, 0, "-05\0", "-04\0"}, - {NULL, 0, -18000, 1214283600LL, 0, "-05\0", "\0"}, - {NULL, 0, -14400, 1384056000LL, 0, "-04\0", "\0"}, - {NULL, 0, -18000, 0, 0, "-05\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Santarem[] = { - {NULL, 0, -13128, -1767212472LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -14400, 590040000LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -14400, 1214280000LL, 0, "-04\0", "\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Santiago[] = { - {NULL, 0, -16966, -2524504634LL, 0, "LMT\0", "\0"}, - {NULL, 0, -16966, -1892661434LL, 0, "SMT\0", "\0"}, - {NULL, 0, -18000, -1688410800LL, 0, "-05\0", "\0"}, - {NULL, 0, -16966, -1619205434LL, 0, "SMT\0", "\0"}, - {NULL, 0, -14400, -1593806400LL, 0, "-04\0", "\0"}, - {NULL, 0, -16966, -1335986234LL, 0, "SMT\0", "\0"}, - {rules_Chile, 32, -18000, -1178132400LL, 0, "-05\0", "-04\0"}, - {NULL, 0, -14400, -870552000LL, 0, "-04\0", "\0"}, - {NULL, 0, -18000, -865278000LL, 0, "-05\0", "\0"}, - {NULL, 0, -14400, -740520000LL, 0, "-04\0", "\0"}, - {rules_100, 1, -14400, -736376400LL, 6, "-03\0", "\0"}, - {NULL, 0, -14400, -718056000LL, 0, "-04\0", "\0"}, - {NULL, 0, -18000, -713649600LL, 0, "-05\0", "\0"}, - {rules_Chile, 32, -14400, 0, 6, "-04\0", "-03\0"}, -}; -static const struct lc_timezone_era eras_America_Santo_Domingo[] = { - {NULL, 0, -16776, -2524504824LL, 0, "LMT\0", "\0"}, - {NULL, 0, -16800, -1159773600LL, 0, "SDMT\0", "\0"}, - {rules_DR, 6, -18000, 152082000LL, 0, "%s\0", "\0"}, - {NULL, 0, -14400, 972799200LL, 0, "AST\0", "\0"}, - {rules_US, 13, -18000, 975823200LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -14400, 0, 0, "AST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Sao_Paulo[] = { - {NULL, 0, -11188, -1767214412LL, 0, "LMT\0", "\0"}, - {rules_Brazil, 64, -10800, -195426000LL, 0, "-03\0", "-02\0"}, - {rules_100, 1, -10800, -189381600LL, 6, "-02\0", "\0"}, - {rules_Brazil, 64, -10800, 0, 0, "-03\0", "-02\0"}, -}; -static const struct lc_timezone_era eras_America_Scoresbysund[] = { - {NULL, 0, -5272, -1686090728LL, 0, "LMT\0", "\0"}, - {NULL, 0, -7200, 323841600LL, 0, "-02\0", "\0"}, - {rules_C_Eur, 17, -7200, 354679200LL, 0, "-02\0", "-01\0"}, - {rules_EU, 6, -3600, 0, 0, "-01\0", "+00\0"}, -}; -static const struct lc_timezone_era eras_America_Sitka[] = { - {NULL, 0, 53927, -3225365927LL, 0, "LMT\0", "\0"}, - {NULL, 0, -32473, -2188954727LL, 0, "LMT\0", "\0"}, - {NULL, 0, -28800, -883584000LL, 0, "PST\0", "\0"}, - {rules_US, 13, -28800, -757353600LL, 0, "P%sT\0", "\0"}, - {NULL, 0, -28800, -31507200LL, 0, "PST\0", "\0"}, - {rules_US, 13, -28800, 436352400LL, 6, "P%sT\0", "\0"}, - {rules_US, 13, -32400, 439030800LL, 0, "Y%sT\0", "\0"}, - {rules_US, 13, -32400, 0, 0, "AK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_St_Johns[] = { - {NULL, 0, -12652, -2713897748LL, 0, "LMT\0", "\0"}, - {rules_StJohns, 19, -12652, -1640982548LL, 0, "N%sT\0", "\0"}, - {rules_Canada, 10, -12652, -1609446548LL, 0, "N%sT\0", "\0"}, - {rules_StJohns, 19, -12652, -1096921748LL, 0, "N%sT\0", "\0"}, - {rules_StJohns, 19, -12600, -872368200LL, 0, "N%sT\0", "\0"}, - {rules_Canada, 10, -12600, -757369800LL, 0, "N%sT\0", "\0"}, - {rules_StJohns, 19, -12600, 1320114600LL, 6, "N%sT\0", "\0"}, - {rules_Canada, 10, -12600, 0, 0, "N%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Swift_Current[] = { - {NULL, 0, -25880, -2030201320LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -25200, -747241200LL, 0, "M%sT\0", "\0"}, - {rules_Regina, 17, -25200, -631126800LL, 0, "M%sT\0", "\0"}, - {rules_Swift, 5, -25200, 73472400LL, 0, "M%sT\0", "\0"}, - {NULL, 0, -21600, 0, 0, "CST\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Tegucigalpa[] = { - {NULL, 0, -20932, -1538503868LL, 0, "LMT\0", "\0"}, - {rules_Hond, 4, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Thule[] = { - {NULL, 0, -16508, -1686079492LL, 0, "LMT\0", "\0"}, - {rules_Thule, 6, -14400, 0, 0, "A%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Thunder_Bay[] = { - {NULL, 0, -21420, -2366733780LL, 0, "LMT\0", "\0"}, - {NULL, 0, -21600, -1893434400LL, 0, "CST\0", "\0"}, - {NULL, 0, -18000, -883594800LL, 0, "EST\0", "\0"}, - {rules_Canada, 10, -18000, 18000LL, 0, "E%sT\0", "\0"}, - {rules_Toronto, 24, -18000, 94712400LL, 0, "E%sT\0", "\0"}, - {NULL, 0, -18000, 126248400LL, 0, "EST\0", "\0"}, - {rules_Canada, 10, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Tijuana[] = { - {NULL, 0, -28084, -1514736000LL, 0, "LMT\0", "\0"}, - {NULL, 0, -25200, -1451667600LL, 0, "MST\0", "\0"}, - {NULL, 0, -28800, -1343062800LL, 0, "PST\0", "\0"}, - {NULL, 0, -25200, -1234803600LL, 0, "MST\0", "\0"}, - {NULL, 0, -28800, -1222963200LL, 0, "PST\0", "\0"}, - {rules_100, 1, -28800, -1207242000LL, 6, "PDT\0", "\0"}, - {NULL, 0, -28800, -873820800LL, 0, "PST\0", "\0"}, - {rules_100, 1, -28800, -769395600LL, 6, "PWT\0", "\0"}, - {rules_100, 1, -28800, -761677200LL, 6, "PPT\0", "\0"}, - {NULL, 0, -28800, -686073600LL, 0, "PST\0", "\0"}, - {rules_100, 1, -28800, -661539600LL, 6, "PDT\0", "\0"}, - {NULL, 0, -28800, -504892800LL, 0, "PST\0", "\0"}, - {rules_CA, 5, -28800, -283968000LL, 0, "P%sT\0", "\0"}, - {NULL, 0, -28800, 189331200LL, 0, "PST\0", "\0"}, - {rules_US, 13, -28800, 820483200LL, 0, "P%sT\0", "\0"}, - {rules_Mexico, 14, -28800, 978336000LL, 0, "P%sT\0", "\0"}, - {rules_US, 13, -28800, 1014192000LL, 0, "P%sT\0", "\0"}, - {rules_Mexico, 14, -28800, 1262332800LL, 0, "P%sT\0", "\0"}, - {rules_US, 13, -28800, 0, 0, "P%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Toronto[] = { - {NULL, 0, -19052, -2366736148LL, 0, "LMT\0", "\0"}, - {rules_Canada, 10, -18000, -1609441200LL, 0, "E%sT\0", "\0"}, - {rules_Toronto, 24, -18000, -880218000LL, 6, "E%sT\0", "\0"}, - {rules_Canada, 10, -18000, -757364400LL, 0, "E%sT\0", "\0"}, - {rules_Toronto, 24, -18000, 126248400LL, 0, "E%sT\0", "\0"}, - {rules_Canada, 10, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Vancouver[] = { - {NULL, 0, -29548, -2713880852LL, 0, "LMT\0", "\0"}, - {rules_Vanc, 9, -28800, 536486400LL, 0, "P%sT\0", "\0"}, - {rules_Canada, 10, -28800, 0, 0, "P%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Whitehorse[] = { - {NULL, 0, -32412, -2188997988LL, 0, "LMT\0", "\0"}, - {rules_NT_YK, 12, -32400, -81961200LL, 0, "Y%sT\0", "\0"}, - {rules_NT_YK, 12, -28800, 315561600LL, 0, "P%sT\0", "\0"}, - {rules_Canada, 10, -28800, 0, 0, "P%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Winnipeg[] = { - {NULL, 0, -23316, -2602258284LL, 0, "LMT\0", "\0"}, - {rules_Winn, 24, -21600, 1136095200LL, 0, "C%sT\0", "\0"}, - {rules_Canada, 10, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Yakutat[] = { - {NULL, 0, 52865, -3225364865LL, 0, "LMT\0", "\0"}, - {NULL, 0, -33535, -2188953665LL, 0, "LMT\0", "\0"}, - {NULL, 0, -32400, -883580400LL, 0, "YST\0", "\0"}, - {rules_US, 13, -32400, -757350000LL, 0, "Y%sT\0", "\0"}, - {NULL, 0, -32400, -31503600LL, 0, "YST\0", "\0"}, - {rules_US, 13, -32400, 439030800LL, 0, "Y%sT\0", "\0"}, - {rules_US, 13, -32400, 0, 0, "AK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_America_Yellowknife[] = { - {NULL, 0, 0, -1104537600LL, 0, "-00\0", "\0"}, - {rules_NT_YK, 12, -25200, 315558000LL, 0, "M%sT\0", "\0"}, - {rules_Canada, 10, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Casey[] = { - {NULL, 0, 0, -31536000LL, 0, "-00\0", "\0"}, - {NULL, 0, 28800, 1255802400LL, 0, "+08\0", "\0"}, - {NULL, 0, 39600, 1267714800LL, 0, "+11\0", "\0"}, - {NULL, 0, 28800, 1319738400LL, 0, "+08\0", "\0"}, - {NULL, 0, 39600, 1329843600LL, 0, "+11\0", "\0"}, - {NULL, 0, 28800, 1477065600LL, 0, "+08\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Davis[] = { - {NULL, 0, 0, -409190400LL, 0, "-00\0", "\0"}, - {NULL, 0, 25200, -163062000LL, 0, "+07\0", "\0"}, - {NULL, 0, 0, -28857600LL, 0, "-00\0", "\0"}, - {NULL, 0, 25200, 1255806000LL, 0, "+07\0", "\0"}, - {NULL, 0, 18000, 1268251200LL, 0, "+05\0", "\0"}, - {NULL, 0, 25200, 1319742000LL, 0, "+07\0", "\0"}, - {NULL, 0, 18000, 1329854400LL, 0, "+05\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_DumontDUrville[] = { - {NULL, 0, 0, -725846400LL, 0, "-00\0", "\0"}, - {NULL, 0, 36000, -566992800LL, 0, "+10\0", "\0"}, - {NULL, 0, 0, -415497600LL, 0, "-00\0", "\0"}, - {NULL, 0, 36000, 0, 0, "+10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Macquarie[] = { - {NULL, 0, 0, -2214259200LL, 0, "-00\0", "\0"}, - {NULL, 0, 36000, -1680508800LL, 0, "AEST\0", "\0"}, - {rules_100, 1, 36000, -1669892400LL, 6, "AEDT\0", "\0"}, - {rules_Aus, 7, 36000, -1601719200LL, 0, "AE%sT\0", "\0"}, - {NULL, 0, 0, -687052800LL, 0, "-00\0", "\0"}, - {rules_Aus, 7, 36000, -94730400LL, 0, "AE%sT\0", "\0"}, - {rules_AT, 19, 36000, 1270310400LL, 6, "AE%sT\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Mawson[] = { - {NULL, 0, 0, -501206400LL, 0, "-00\0", "\0"}, - {NULL, 0, 21600, 1255809600LL, 0, "+06\0", "\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Palmer[] = { - {NULL, 0, 0, -157766400LL, 0, "-00\0", "\0"}, - {rules_Arg, 29, -14400, -7588800LL, 0, "-04\0", "-03\0"}, - {rules_Arg, 29, -10800, 389070000LL, 0, "-03\0", "-02\0"}, - {rules_Chile, 32, -14400, 1480820400LL, 6, "-04\0", "-03\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Rothera[] = { - {NULL, 0, 0, 218246400LL, 0, "-00\0", "\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Syowa[] = { - {NULL, 0, 0, -407808000LL, 0, "-00\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Troll[] = { - {NULL, 0, 0, 1108166400LL, 0, "-00\0", "\0"}, - {rules_Troll, 2, 0, 0, 0, "%s\0", "\0"}, -}; -static const struct lc_timezone_era eras_Antarctica_Vostok[] = { - {NULL, 0, 0, -380073600LL, 0, "-00\0", "\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Almaty[] = { - {NULL, 0, 18468, -1441170468LL, 0, "LMT\0", "\0"}, - {NULL, 0, 18000, -1247547600LL, 0, "+05\0", "\0"}, - {rules_RussiaAsia, 5, 21600, 670363200LL, 0, "+06\0", "+07\0"}, - {rules_RussiaAsia, 5, 18000, 695768400LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 21600, 1099166400LL, 6, "+06\0", "+07\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Amman[] = { - {NULL, 0, 8624, -1230776624LL, 0, "LMT\0", "\0"}, - {rules_Jordan, 31, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Anadyr[] = { - {NULL, 0, 42596, -1441194596LL, 0, "LMT\0", "\0"}, - {NULL, 0, 43200, -1247572800LL, 0, "+12\0", "\0"}, - {rules_Russia, 16, 46800, 386420400LL, 0, "+13\0", "+14\0"}, - {rules_Russia, 16, 43200, 670341600LL, 0, "+12\0", "+13\0"}, - {rules_Russia, 16, 39600, 695746800LL, 0, "+11\0", "+12\0"}, - {rules_Russia, 16, 43200, 1269698400LL, 0, "+12\0", "+13\0"}, - {rules_Russia, 16, 39600, 1301151600LL, 0, "+11\0", "+12\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Aqtau[] = { - {NULL, 0, 12064, -1441164064LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, -1247544000LL, 0, "+04\0", "\0"}, - {NULL, 0, 18000, 370724400LL, 0, "+05\0", "\0"}, - {NULL, 0, 21600, 386445600LL, 0, "+06\0", "\0"}, - {rules_RussiaAsia, 5, 18000, 670366800LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 695772000LL, 0, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 18000, 780440400LL, 6, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 1099173600LL, 6, "+04\0", "+05\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Aqtobe[] = { - {NULL, 0, 13720, -1441165720LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, -1247544000LL, 0, "+04\0", "\0"}, - {NULL, 0, 18000, 354913200LL, 0, "+05\0", "\0"}, - {rules_100, 1, 18000, 370720800LL, 6, "+06\0", "\0"}, - {NULL, 0, 21600, 386445600LL, 0, "+06\0", "\0"}, - {rules_RussiaAsia, 5, 18000, 670366800LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 695772000LL, 0, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 18000, 1099170000LL, 6, "+05\0", "+06\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Ashgabat[] = { - {NULL, 0, 14012, -1441166012LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, -1247544000LL, 0, "+04\0", "\0"}, - {rules_RussiaAsia, 5, 18000, 670366800LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 695772000LL, 0, "+04\0", "+05\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Atyrau[] = { - {NULL, 0, 12464, -1441164464LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {NULL, 0, 18000, 370724400LL, 0, "+05\0", "\0"}, - {NULL, 0, 21600, 386445600LL, 0, "+06\0", "\0"}, - {rules_RussiaAsia, 5, 18000, 670366800LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 695772000LL, 0, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 18000, 922568400LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 1099173600LL, 6, "+04\0", "+05\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Baghdad[] = { - {NULL, 0, 10660, -2524532260LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10656, -1641005856LL, 0, "BMT\0", "\0"}, - {NULL, 0, 10800, 389048400LL, 0, "+03\0", "\0"}, - {rules_Iraq, 8, 10800, 0, 0, "+03\0", "+04\0"}, -}; -static const struct lc_timezone_era eras_Asia_Baku[] = { - {NULL, 0, 11964, -1441163964LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -405140400LL, 0, "+03\0", "\0"}, - {rules_RussiaAsia, 5, 14400, 670370400LL, 0, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 10800, 717548400LL, 6, "+03\0", "+04\0"}, - {NULL, 0, 14400, 820440000LL, 0, "+04\0", "\0"}, - {rules_EUAsia, 3, 14400, 852062400LL, 0, "+04\0", "+05\0"}, - {rules_Azer, 2, 14400, 0, 0, "+04\0", "+05\0"}, -}; -static const struct lc_timezone_era eras_Asia_Bangkok[] = { - {NULL, 0, 24124, -2840164924LL, 0, "LMT\0", "\0"}, - {NULL, 0, 24124, -1570084924LL, 0, "BMT\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Barnaul[] = { - {NULL, 0, 20100, -1579844100LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21600, -1247551200LL, 0, "+06\0", "\0"}, - {rules_Russia, 16, 25200, 670359600LL, 0, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 695764800LL, 0, "+06\0", "+07\0"}, - {rules_Russia, 16, 25200, 801590400LL, 6, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 1301169600LL, 0, "+06\0", "+07\0"}, - {NULL, 0, 25200, 1414263600LL, 0, "+07\0", "\0"}, - {NULL, 0, 21600, 1459022400LL, 0, "+06\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Beirut[] = { - {NULL, 0, 8520, -2840149320LL, 0, "LMT\0", "\0"}, - {rules_Lebanon, 24, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Bishkek[] = { - {NULL, 0, 17904, -1441169904LL, 0, "LMT\0", "\0"}, - {NULL, 0, 18000, -1247547600LL, 0, "+05\0", "\0"}, - {rules_RussiaAsia, 5, 21600, 670363200LL, 0, "+06\0", "+07\0"}, - {rules_RussiaAsia, 5, 18000, 683582400LL, 6, "+05\0", "+06\0"}, - {rules_Kyrgyz, 4, 18000, 1123783200LL, 6, "+05\0", "+06\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Brunei[] = { - {NULL, 0, 27580, -1383464380LL, 0, "LMT\0", "\0"}, - {NULL, 0, 27000, -1167636600LL, 0, "+0730\0", "\0"}, - {NULL, 0, 28800, 0, 0, "+08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Chita[] = { - {NULL, 0, 27232, -1579419232LL, 0, "LMT\0", "\0"}, - {NULL, 0, 28800, -1247558400LL, 0, "+08\0", "\0"}, - {rules_Russia, 16, 32400, 670352400LL, 0, "+09\0", "+10\0"}, - {rules_Russia, 16, 28800, 695757600LL, 0, "+08\0", "+09\0"}, - {rules_Russia, 16, 32400, 1301158800LL, 0, "+09\0", "+10\0"}, - {NULL, 0, 36000, 1414252800LL, 0, "+10\0", "\0"}, - {NULL, 0, 28800, 1459015200LL, 0, "+08\0", "\0"}, - {NULL, 0, 32400, 0, 0, "+09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Choibalsan[] = { - {NULL, 0, 27480, -2032933080LL, 0, "LMT\0", "\0"}, - {NULL, 0, 25200, 252435600LL, 0, "+07\0", "\0"}, - {NULL, 0, 28800, 417974400LL, 0, "+08\0", "\0"}, - {rules_Mongol, 9, 32400, 1206889200LL, 0, "+09\0", "+10\0"}, - {rules_Mongol, 9, 28800, 0, 0, "+08\0", "+09\0"}, -}; -static const struct lc_timezone_era eras_Asia_Colombo[] = { - {NULL, 0, 19164, -2840159964LL, 0, "LMT\0", "\0"}, - {NULL, 0, 19172, -2019705572LL, 0, "MMT\0", "\0"}, - {NULL, 0, 19800, -883287000LL, 0, "+0530\0", "\0"}, - {rules_030, 1, 19800, -862639200LL, 3, "+06\0", "\0"}, - {rules_100, 1, 19800, -764051400LL, 6, "+0630\0", "\0"}, - {NULL, 0, 19800, 832962600LL, 0, "+0530\0", "\0"}, - {NULL, 0, 23400, 846266400LL, 0, "+0630\0", "\0"}, - {NULL, 0, 21600, 1145039400LL, 0, "+06\0", "\0"}, - {NULL, 0, 19800, 0, 0, "+0530\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Damascus[] = { - {NULL, 0, 8712, -1577931912LL, 0, "LMT\0", "\0"}, - {rules_Syria, 41, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Dhaka[] = { - {NULL, 0, 21700, -2524543300LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21200, -891582800LL, 0, "HMT\0", "\0"}, - {NULL, 0, 23400, -872058600LL, 0, "+0630\0", "\0"}, - {NULL, 0, 19800, -862637400LL, 0, "+0530\0", "\0"}, - {NULL, 0, 23400, -576138600LL, 0, "+0630\0", "\0"}, - {NULL, 0, 21600, 1230746400LL, 0, "+06\0", "\0"}, - {rules_Dhaka, 2, 21600, 0, 0, "+06\0", "+07\0"}, -}; -static const struct lc_timezone_era eras_Asia_Dili[] = { - {NULL, 0, 30140, -1830414140LL, 0, "LMT\0", "\0"}, - {NULL, 0, 28800, -879152400LL, 0, "+08\0", "\0"}, - {NULL, 0, 32400, 199897200LL, 0, "+09\0", "\0"}, - {NULL, 0, 28800, 969120000LL, 0, "+08\0", "\0"}, - {NULL, 0, 32400, 0, 0, "+09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Dubai[] = { - {NULL, 0, 13272, -1577936472LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Dushanbe[] = { - {NULL, 0, 16512, -1441168512LL, 0, "LMT\0", "\0"}, - {NULL, 0, 18000, -1247547600LL, 0, "+05\0", "\0"}, - {rules_RussiaAsia, 5, 21600, 670363200LL, 0, "+06\0", "+07\0"}, - {rules_100, 1, 18000, 684363600LL, 6, "+05\0", "+06\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Famagusta[] = { - {NULL, 0, 8148, -1518920148LL, 0, "LMT\0", "\0"}, - {rules_Cyprus, 9, 7200, 904597200LL, 6, "EE%sT\0", "\0"}, - {rules_EUAsia, 3, 7200, 1473282000LL, 6, "EE%sT\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Gaza[] = { - {NULL, 0, 8272, -2185409872LL, 0, "LMT\0", "\0"}, - {rules_Zion, 86, 7200, -682653600LL, 0, "EET\0", "EEST\0"}, - {rules_EgyptAsia, 6, 7200, -81313200LL, 6, "EE%sT\0", "\0"}, - {rules_Zion, 86, 7200, 820447200LL, 0, "I%sT\0", "\0"}, - {rules_Jordan, 31, 7200, 915141600LL, 0, "EE%sT\0", "\0"}, - {rules_Palestine, 23, 7200, 1219957200LL, 6, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 1220220000LL, 0, "EET\0", "\0"}, - {rules_Palestine, 23, 7200, 1262296800LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 1269640860LL, 0, "EET\0", "\0"}, - {rules_Palestine, 23, 7200, 1312146000LL, 6, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 1325368800LL, 0, "EET\0", "\0"}, - {rules_Palestine, 23, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Hebron[] = { - {NULL, 0, 8423, -2185410023LL, 0, "LMT\0", "\0"}, - {rules_Zion, 86, 7200, -682653600LL, 0, "EET\0", "EEST\0"}, - {rules_EgyptAsia, 6, 7200, -81313200LL, 6, "EE%sT\0", "\0"}, - {rules_Zion, 86, 7200, 820447200LL, 0, "I%sT\0", "\0"}, - {rules_Jordan, 31, 7200, 915141600LL, 0, "EE%sT\0", "\0"}, - {rules_Palestine, 23, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Ho_Chi_Minh[] = { - {NULL, 0, 25600, -2004073600LL, 0, "LMT\0", "\0"}, - {NULL, 0, 25590, -1851577590LL, 0, "PLMT\0", "\0"}, - {NULL, 0, 25200, -852105600LL, 0, "+07\0", "\0"}, - {NULL, 0, 28800, -782643600LL, 0, "+08\0", "\0"}, - {NULL, 0, 32400, -767869200LL, 0, "+09\0", "\0"}, - {NULL, 0, 25200, -718095600LL, 0, "+07\0", "\0"}, - {NULL, 0, 28800, -457776000LL, 0, "+08\0", "\0"}, - {NULL, 0, 25200, -315648000LL, 0, "+07\0", "\0"}, - {NULL, 0, 28800, 171820800LL, 0, "+08\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Hong_Kong[] = { - {NULL, 0, 27402, -2056693002LL, 0, "LMT\0", "\0"}, - {rules_HK, 19, 28800, -884246400LL, 0, "HK%sT\0", "\0"}, - {NULL, 0, 32400, -766746000LL, 0, "JST\0", "\0"}, - {rules_HK, 19, 28800, 0, 0, "HK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Hovd[] = { - {NULL, 0, 21996, -2032927596LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21600, 252439200LL, 0, "+06\0", "\0"}, - {rules_Mongol, 9, 25200, 0, 0, "+07\0", "+08\0"}, -}; -static const struct lc_timezone_era eras_Asia_Irkutsk[] = { - {NULL, 0, 25025, -2840165825LL, 0, "LMT\0", "\0"}, - {NULL, 0, 25025, -1575874625LL, 0, "IMT\0", "\0"}, - {NULL, 0, 25200, -1247554800LL, 0, "+07\0", "\0"}, - {rules_Russia, 16, 28800, 670356000LL, 0, "+08\0", "+09\0"}, - {rules_Russia, 16, 25200, 695761200LL, 0, "+07\0", "+08\0"}, - {rules_Russia, 16, 28800, 1301162400LL, 0, "+08\0", "+09\0"}, - {NULL, 0, 32400, 1414256400LL, 0, "+09\0", "\0"}, - {NULL, 0, 28800, 0, 0, "+08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Jakarta[] = { - {NULL, 0, 25632, -3231299232LL, 0, "LMT\0", "\0"}, - {NULL, 0, 25632, -1451719200LL, 0, "BMT\0", "\0"}, - {NULL, 0, 26400, -1172906400LL, 0, "+0720\0", "\0"}, - {NULL, 0, 27000, -876641400LL, 0, "+0730\0", "\0"}, - {NULL, 0, 32400, -766054800LL, 0, "+09\0", "\0"}, - {NULL, 0, 27000, -683883000LL, 0, "+0730\0", "\0"}, - {NULL, 0, 28800, -620812800LL, 0, "+08\0", "\0"}, - {NULL, 0, 27000, -189415800LL, 0, "+0730\0", "\0"}, - {NULL, 0, 25200, 0, 0, "WIB\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Jayapura[] = { - {NULL, 0, 33768, -1172913768LL, 0, "LMT\0", "\0"}, - {NULL, 0, 32400, -799491600LL, 0, "+09\0", "\0"}, - {NULL, 0, 34200, -189423000LL, 0, "+0930\0", "\0"}, - {NULL, 0, 32400, 0, 0, "WIT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Jerusalem[] = { - {NULL, 0, 8454, -2840149254LL, 0, "LMT\0", "\0"}, - {NULL, 0, 8440, -1641003640LL, 0, "JMT\0", "\0"}, - {rules_Zion, 86, 7200, 0, 0, "I%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Kabul[] = { - {NULL, 0, 16608, -2524538208LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, -788932800LL, 0, "+04\0", "\0"}, - {NULL, 0, 16200, 0, 0, "+0430\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Kamchatka[] = { - {NULL, 0, 38076, -1487759676LL, 0, "LMT\0", "\0"}, - {NULL, 0, 39600, -1247569200LL, 0, "+11\0", "\0"}, - {rules_Russia, 16, 43200, 670341600LL, 0, "+12\0", "+13\0"}, - {rules_Russia, 16, 39600, 695746800LL, 0, "+11\0", "+12\0"}, - {rules_Russia, 16, 43200, 1269698400LL, 0, "+12\0", "+13\0"}, - {rules_Russia, 16, 39600, 1301151600LL, 0, "+11\0", "+12\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Karachi[] = { - {NULL, 0, 16092, -1988166492LL, 0, "LMT\0", "\0"}, - {NULL, 0, 19800, -862637400LL, 0, "+0530\0", "\0"}, - {rules_100, 1, 19800, -764145000LL, 6, "+0630\0", "\0"}, - {NULL, 0, 19800, -576135000LL, 0, "+0530\0", "\0"}, - {NULL, 0, 18000, 38775600LL, 0, "+05\0", "\0"}, - {rules_Pakistan, 5, 18000, 0, 0, "PK%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Kathmandu[] = { - {NULL, 0, 20476, -1577943676LL, 0, "LMT\0", "\0"}, - {NULL, 0, 19800, 504901800LL, 0, "+0530\0", "\0"}, - {NULL, 0, 20700, 0, 0, "+0545\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Khandyga[] = { - {NULL, 0, 32533, -1579424533LL, 0, "LMT\0", "\0"}, - {NULL, 0, 28800, -1247558400LL, 0, "+08\0", "\0"}, - {rules_Russia, 16, 32400, 670352400LL, 0, "+09\0", "+10\0"}, - {rules_Russia, 16, 28800, 695757600LL, 0, "+08\0", "+09\0"}, - {rules_Russia, 16, 32400, 1072882800LL, 0, "+09\0", "+10\0"}, - {rules_Russia, 16, 36000, 1301155200LL, 0, "+10\0", "+11\0"}, - {NULL, 0, 39600, 1315832400LL, 0, "+11\0", "\0"}, - {NULL, 0, 36000, 1414252800LL, 0, "+10\0", "\0"}, - {NULL, 0, 32400, 0, 0, "+09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Kolkata[] = { - {NULL, 0, 21208, -2840162008LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21200, -891582800LL, 0, "HMT\0", "\0"}, - {NULL, 0, 23400, -872058600LL, 0, "+0630\0", "\0"}, - {NULL, 0, 19800, -862637400LL, 0, "IST\0", "\0"}, - {rules_100, 1, 19800, -764145000LL, 6, "+0630\0", "\0"}, - {NULL, 0, 19800, 0, 0, "IST\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Krasnoyarsk[] = { - {NULL, 0, 22286, -1577513486LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21600, -1247551200LL, 0, "+06\0", "\0"}, - {rules_Russia, 16, 25200, 670359600LL, 0, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 695764800LL, 0, "+06\0", "+07\0"}, - {rules_Russia, 16, 25200, 1301166000LL, 0, "+07\0", "+08\0"}, - {NULL, 0, 28800, 1414260000LL, 0, "+08\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Kuala_Lumpur[] = { - {NULL, 0, 24406, -2177477206LL, 0, "LMT\0", "\0"}, - {NULL, 0, 24925, -2038200925LL, 0, "SMT\0", "\0"}, - {NULL, 0, 25200, -1167634800LL, 0, "+07\0", "\0"}, - {rules_020, 1, 25200, -1073028000LL, 2, "+0720\0", "\0"}, - {NULL, 0, 26400, -894180000LL, 0, "+0720\0", "\0"}, - {NULL, 0, 27000, -879665400LL, 0, "+0730\0", "\0"}, - {NULL, 0, 32400, -767005200LL, 0, "+09\0", "\0"}, - {NULL, 0, 27000, 378664200LL, 0, "+0730\0", "\0"}, - {NULL, 0, 28800, 0, 0, "+08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Kuching[] = { - {NULL, 0, 26480, -1383463280LL, 0, "LMT\0", "\0"}, - {NULL, 0, 27000, -1167636600LL, 0, "+0730\0", "\0"}, - {rules_NBorneo, 2, 28800, -879667200LL, 0, "+08\0", "+0820\0"}, - {NULL, 0, 32400, -767005200LL, 0, "+09\0", "\0"}, - {NULL, 0, 28800, 0, 0, "+08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Macau[] = { - {NULL, 0, 27260, -1830411260LL, 0, "LMT\0", "\0"}, - {rules_Macau, 14, 28800, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Magadan[] = { - {NULL, 0, 36192, -1441188192LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, -1247565600LL, 0, "+10\0", "\0"}, - {rules_Russia, 16, 39600, 670345200LL, 0, "+11\0", "+12\0"}, - {rules_Russia, 16, 36000, 695750400LL, 0, "+10\0", "+11\0"}, - {rules_Russia, 16, 39600, 1301151600LL, 0, "+11\0", "+12\0"}, - {NULL, 0, 43200, 1414245600LL, 0, "+12\0", "\0"}, - {NULL, 0, 36000, 1461427200LL, 0, "+10\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Makassar[] = { - {NULL, 0, 28656, -1577951856LL, 0, "LMT\0", "\0"}, - {NULL, 0, 28656, -1172908656LL, 0, "MMT\0", "\0"}, - {NULL, 0, 28800, -880272000LL, 0, "+08\0", "\0"}, - {NULL, 0, 32400, -766054800LL, 0, "+09\0", "\0"}, - {NULL, 0, 28800, 0, 0, "WITA\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Manila[] = { - {NULL, 0, -57360, -3944621040LL, 0, "LMT\0", "\0"}, - {NULL, 0, 29040, -2229321840LL, 0, "LMT\0", "\0"}, - {rules_Phil, 6, 28800, -873273600LL, 0, "+08\0", "+09\0"}, - {NULL, 0, 32400, -794221200LL, 0, "+09\0", "\0"}, - {rules_Phil, 6, 28800, 0, 0, "+08\0", "+09\0"}, -}; -static const struct lc_timezone_era eras_Asia_Nicosia[] = { - {NULL, 0, 8008, -1518920008LL, 0, "LMT\0", "\0"}, - {rules_Cyprus, 9, 7200, 904597200LL, 6, "EE%sT\0", "\0"}, - {rules_EUAsia, 3, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Novokuznetsk[] = { - {NULL, 0, 20928, -1441259328LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21600, -1247551200LL, 0, "+06\0", "\0"}, - {rules_Russia, 16, 25200, 670359600LL, 0, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 695764800LL, 0, "+06\0", "+07\0"}, - {rules_Russia, 16, 25200, 1269716400LL, 0, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 1301169600LL, 0, "+06\0", "+07\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Novosibirsk[] = { - {NULL, 0, 19900, -1579476700LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21600, -1247551200LL, 0, "+06\0", "\0"}, - {rules_Russia, 16, 25200, 670359600LL, 0, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 695764800LL, 0, "+06\0", "+07\0"}, - {rules_Russia, 16, 25200, 738086400LL, 6, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 1301169600LL, 0, "+06\0", "+07\0"}, - {NULL, 0, 25200, 1414263600LL, 0, "+07\0", "\0"}, - {NULL, 0, 21600, 1469304000LL, 0, "+06\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Omsk[] = { - {NULL, 0, 17610, -1582088010LL, 0, "LMT\0", "\0"}, - {NULL, 0, 18000, -1247547600LL, 0, "+05\0", "\0"}, - {rules_Russia, 16, 21600, 670363200LL, 0, "+06\0", "+07\0"}, - {rules_Russia, 16, 18000, 695768400LL, 0, "+05\0", "+06\0"}, - {rules_Russia, 16, 21600, 1301169600LL, 0, "+06\0", "+07\0"}, - {NULL, 0, 25200, 1414263600LL, 0, "+07\0", "\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Oral[] = { - {NULL, 0, 12324, -1441164324LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {NULL, 0, 18000, 354913200LL, 0, "+05\0", "\0"}, - {rules_100, 1, 18000, 370720800LL, 6, "+06\0", "\0"}, - {NULL, 0, 21600, 386445600LL, 0, "+06\0", "\0"}, - {rules_RussiaAsia, 5, 18000, 606862800LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 695772000LL, 0, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 18000, 701816400LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 1099173600LL, 6, "+04\0", "+05\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Pontianak[] = { - {NULL, 0, 26240, -1946186240LL, 0, "LMT\0", "\0"}, - {NULL, 0, 26240, -1172906240LL, 0, "PMT\0", "\0"}, - {NULL, 0, 27000, -881220600LL, 0, "+0730\0", "\0"}, - {NULL, 0, 32400, -766054800LL, 0, "+09\0", "\0"}, - {NULL, 0, 27000, -683883000LL, 0, "+0730\0", "\0"}, - {NULL, 0, 28800, -620812800LL, 0, "+08\0", "\0"}, - {NULL, 0, 27000, -189415800LL, 0, "+0730\0", "\0"}, - {NULL, 0, 28800, 567964800LL, 0, "WITA\0", "\0"}, - {NULL, 0, 25200, 0, 0, "WIB\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Pyongyang[] = { - {NULL, 0, 30180, -1948782180LL, 0, "LMT\0", "\0"}, - {NULL, 0, 30600, -1830414600LL, 0, "KST\0", "\0"}, - {NULL, 0, 32400, -768646800LL, 0, "JST\0", "\0"}, - {NULL, 0, 32400, 1439564400LL, 0, "KST\0", "\0"}, - {NULL, 0, 30600, 0, 0, "KST\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Qatar[] = { - {NULL, 0, 12368, -1577935568LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, 76190400LL, 0, "+04\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Qyzylorda[] = { - {NULL, 0, 15712, -1441167712LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, -1247544000LL, 0, "+04\0", "\0"}, - {NULL, 0, 18000, 354913200LL, 0, "+05\0", "\0"}, - {rules_100, 1, 18000, 370720800LL, 6, "+06\0", "\0"}, - {NULL, 0, 21600, 386445600LL, 0, "+06\0", "\0"}, - {rules_RussiaAsia, 5, 18000, 670366800LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 14400, 686095200LL, 6, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 18000, 695768400LL, 0, "+05\0", "+06\0"}, - {rules_RussiaAsia, 5, 21600, 701812800LL, 0, "+06\0", "+07\0"}, - {rules_RussiaAsia, 5, 18000, 1099170000LL, 6, "+05\0", "+06\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Riyadh[] = { - {NULL, 0, 11212, -719636812LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Sakhalin[] = { - {NULL, 0, 34248, -2031039048LL, 0, "LMT\0", "\0"}, - {NULL, 0, 32400, -768560400LL, 0, "+09\0", "\0"}, - {rules_Russia, 16, 39600, 670345200LL, 0, "+11\0", "+12\0"}, - {rules_Russia, 16, 36000, 695750400LL, 0, "+10\0", "+11\0"}, - {rules_Russia, 16, 39600, 859647600LL, 0, "+11\0", "+12\0"}, - {rules_Russia, 16, 36000, 1301155200LL, 0, "+10\0", "+11\0"}, - {NULL, 0, 39600, 1414249200LL, 0, "+11\0", "\0"}, - {NULL, 0, 36000, 1459008000LL, 0, "+10\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Samarkand[] = { - {NULL, 0, 16073, -1441168073LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, -1247544000LL, 0, "+04\0", "\0"}, - {NULL, 0, 18000, 354913200LL, 0, "+05\0", "\0"}, - {rules_100, 1, 18000, 370720800LL, 6, "+06\0", "\0"}, - {NULL, 0, 21600, 386445600LL, 0, "+06\0", "\0"}, - {rules_RussiaAsia, 5, 18000, 694206000LL, 0, "+05\0", "+06\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Seoul[] = { - {NULL, 0, 30472, -1948782472LL, 0, "LMT\0", "\0"}, - {NULL, 0, 30600, -1830414600LL, 0, "KST\0", "\0"}, - {NULL, 0, 32400, -767350800LL, 0, "JST\0", "\0"}, - {NULL, 0, 32400, -498128400LL, 0, "KST\0", "\0"}, - {rules_ROK, 14, 30600, -264933000LL, 0, "K%sT\0", "\0"}, - {rules_ROK, 14, 32400, 0, 0, "K%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Shanghai[] = { - {NULL, 0, 29143, -2177481943LL, 0, "LMT\0", "\0"}, - {rules_Shang, 3, 28800, -662716800LL, 0, "C%sT\0", "\0"}, - {rules_PRC, 3, 28800, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Singapore[] = { - {NULL, 0, 24925, -2177477725LL, 0, "LMT\0", "\0"}, - {NULL, 0, 24925, -2038200925LL, 0, "SMT\0", "\0"}, - {NULL, 0, 25200, -1167634800LL, 0, "+07\0", "\0"}, - {rules_020, 1, 25200, -1073028000LL, 2, "+0720\0", "\0"}, - {NULL, 0, 26400, -894180000LL, 0, "+0720\0", "\0"}, - {NULL, 0, 27000, -879665400LL, 0, "+0730\0", "\0"}, - {NULL, 0, 32400, -767005200LL, 0, "+09\0", "\0"}, - {NULL, 0, 27000, 378664200LL, 0, "+0730\0", "\0"}, - {NULL, 0, 28800, 0, 0, "+08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Srednekolymsk[] = { - {NULL, 0, 36892, -1441188892LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, -1247565600LL, 0, "+10\0", "\0"}, - {rules_Russia, 16, 39600, 670345200LL, 0, "+11\0", "+12\0"}, - {rules_Russia, 16, 36000, 695750400LL, 0, "+10\0", "+11\0"}, - {rules_Russia, 16, 39600, 1301151600LL, 0, "+11\0", "+12\0"}, - {NULL, 0, 43200, 1414245600LL, 0, "+12\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Taipei[] = { - {NULL, 0, 29160, -2335248360LL, 0, "LMT\0", "\0"}, - {NULL, 0, 28800, -1017820800LL, 0, "CST\0", "\0"}, - {NULL, 0, 32400, -766224000LL, 0, "JST\0", "\0"}, - {rules_Taiwan, 15, 28800, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Tashkent[] = { - {NULL, 0, 16631, -1441168631LL, 0, "LMT\0", "\0"}, - {NULL, 0, 18000, -1247547600LL, 0, "+05\0", "\0"}, - {rules_RussiaAsia, 5, 21600, 670363200LL, 0, "+06\0", "+07\0"}, - {rules_RussiaAsia, 5, 18000, 694206000LL, 0, "+05\0", "+06\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Tbilisi[] = { - {NULL, 0, 10751, -2840151551LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10751, -1441162751LL, 0, "TBMT\0", "\0"}, - {NULL, 0, 10800, -405140400LL, 0, "+03\0", "\0"}, - {rules_RussiaAsia, 5, 14400, 670370400LL, 0, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 10800, 694213200LL, 0, "+03\0", "+04\0"}, - {rules_E_EurAsia, 3, 10800, 780436800LL, 6, "+03\0", "+04\0"}, - {rules_E_EurAsia, 3, 14400, 846356400LL, 6, "+04\0", "+05\0"}, - {rules_100, 1, 14400, 859662000LL, 6, "+05\0", "\0"}, - {rules_E_EurAsia, 3, 14400, 1088276400LL, 6, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 10800, 1111878000LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Tehran[] = { - {NULL, 0, 12344, -1704165944LL, 0, "LMT\0", "\0"}, - {NULL, 0, 12344, -757394744LL, 0, "TMT\0", "\0"}, - {NULL, 0, 12600, 247177800LL, 0, "+0330\0", "\0"}, - {rules_Iran, 49, 14400, 283982400LL, 0, "+04\0", "+05\0"}, - {rules_Iran, 49, 12600, 0, 0, "+0330\0", "+0430\0"}, -}; -static const struct lc_timezone_era eras_Asia_Thimphu[] = { - {NULL, 0, 21516, -706341516LL, 0, "LMT\0", "\0"}, - {NULL, 0, 19800, 560025000LL, 0, "+0530\0", "\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Tokyo[] = { - {NULL, 0, 33539, -2587712400LL, 0, "LMT\0", "\0"}, - {rules_Japan, 4, 32400, 0, 0, "J%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Tomsk[] = { - {NULL, 0, 20391, -1578807591LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21600, -1247551200LL, 0, "+06\0", "\0"}, - {rules_Russia, 16, 25200, 670359600LL, 0, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 695764800LL, 0, "+06\0", "+07\0"}, - {rules_Russia, 16, 25200, 1020193200LL, 6, "+07\0", "+08\0"}, - {rules_Russia, 16, 21600, 1301169600LL, 0, "+06\0", "+07\0"}, - {NULL, 0, 25200, 1414263600LL, 0, "+07\0", "\0"}, - {NULL, 0, 21600, 1464465600LL, 0, "+06\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Ulaanbaatar[] = { - {NULL, 0, 25652, -2032931252LL, 0, "LMT\0", "\0"}, - {NULL, 0, 25200, 252435600LL, 0, "+07\0", "\0"}, - {rules_Mongol, 9, 28800, 0, 0, "+08\0", "+09\0"}, -}; -static const struct lc_timezone_era eras_Asia_Urumqi[] = { - {NULL, 0, 21020, -1325483420LL, 0, "LMT\0", "\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Ust_Nera[] = { - {NULL, 0, 34374, -1579426374LL, 0, "LMT\0", "\0"}, - {NULL, 0, 28800, -1247558400LL, 0, "+08\0", "\0"}, - {rules_Russia, 16, 32400, 354898800LL, 0, "+09\0", "+10\0"}, - {rules_Russia, 16, 39600, 670345200LL, 0, "+11\0", "+12\0"}, - {rules_Russia, 16, 36000, 695750400LL, 0, "+10\0", "+11\0"}, - {rules_Russia, 16, 39600, 1301151600LL, 0, "+11\0", "+12\0"}, - {NULL, 0, 43200, 1315828800LL, 0, "+12\0", "\0"}, - {NULL, 0, 39600, 1414249200LL, 0, "+11\0", "\0"}, - {NULL, 0, 36000, 0, 0, "+10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Vladivostok[] = { - {NULL, 0, 31651, -1487321251LL, 0, "LMT\0", "\0"}, - {NULL, 0, 32400, -1247562000LL, 0, "+09\0", "\0"}, - {rules_Russia, 16, 36000, 670348800LL, 0, "+10\0", "+11\0"}, - {rules_Russia, 16, 32400, 695754000LL, 0, "+09\0", "+10\0"}, - {rules_Russia, 16, 36000, 1301155200LL, 0, "+10\0", "+11\0"}, - {NULL, 0, 39600, 1414249200LL, 0, "+11\0", "\0"}, - {NULL, 0, 36000, 0, 0, "+10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Yakutsk[] = { - {NULL, 0, 31138, -1579423138LL, 0, "LMT\0", "\0"}, - {NULL, 0, 28800, -1247558400LL, 0, "+08\0", "\0"}, - {rules_Russia, 16, 32400, 670352400LL, 0, "+09\0", "+10\0"}, - {rules_Russia, 16, 28800, 695757600LL, 0, "+08\0", "+09\0"}, - {rules_Russia, 16, 32400, 1301158800LL, 0, "+09\0", "+10\0"}, - {NULL, 0, 36000, 1414252800LL, 0, "+10\0", "\0"}, - {NULL, 0, 32400, 0, 0, "+09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Yangon[] = { - {NULL, 0, 23080, -2840163880LL, 0, "LMT\0", "\0"}, - {NULL, 0, 23080, -1577946280LL, 0, "RMT\0", "\0"}, - {NULL, 0, 23400, -873268200LL, 0, "+0630\0", "\0"}, - {NULL, 0, 32400, -778410000LL, 0, "+09\0", "\0"}, - {NULL, 0, 23400, 0, 0, "+0630\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Yekaterinburg[] = { - {NULL, 0, 14553, -1688270553LL, 0, "LMT\0", "\0"}, - {NULL, 0, 13505, -1592610305LL, 0, "PMT\0", "\0"}, - {NULL, 0, 14400, -1247544000LL, 0, "+04\0", "\0"}, - {rules_Russia, 16, 18000, 670366800LL, 0, "+05\0", "+06\0"}, - {rules_Russia, 16, 14400, 695772000LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 18000, 1301173200LL, 0, "+05\0", "+06\0"}, - {NULL, 0, 21600, 1414267200LL, 0, "+06\0", "\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Asia_Yerevan[] = { - {NULL, 0, 10680, -1441162680LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -405140400LL, 0, "+03\0", "\0"}, - {rules_RussiaAsia, 5, 14400, 670370400LL, 0, "+04\0", "+05\0"}, - {rules_RussiaAsia, 5, 10800, 811897200LL, 6, "+03\0", "+04\0"}, - {NULL, 0, 14400, 852062400LL, 0, "+04\0", "\0"}, - {rules_RussiaAsia, 5, 14400, 0, 0, "+04\0", "+05\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Azores[] = { - {NULL, 0, -6160, -2713904240LL, 0, "LMT\0", "\0"}, - {NULL, 0, -6872, -1830377128LL, 0, "HMT\0", "\0"}, - {rules_Port, 50, -7200, -873676800LL, 6, "-02\0", "-01\0"}, - {rules_Port, 50, -7200, -864000000LL, 12, "+00\0", "\0"}, - {rules_Port, 50, -7200, -842832000LL, 6, "-02\0", "-01\0"}, - {rules_Port, 50, -7200, -831340800LL, 12, "+00\0", "\0"}, - {rules_Port, 50, -7200, -810777600LL, 6, "-02\0", "-01\0"}, - {rules_Port, 50, -7200, -799891200LL, 12, "+00\0", "\0"}, - {rules_Port, 50, -7200, -779328000LL, 6, "-02\0", "-01\0"}, - {rules_Port, 50, -7200, -768441600LL, 12, "+00\0", "\0"}, - {rules_Port, 50, -7200, -118267200LL, 0, "-02\0", "-01\0"}, - {rules_Port, 50, -3600, 433303200LL, 6, "-01\0", "+00\0"}, - {rules_W_Eur, 6, -3600, 717559200LL, 6, "-01\0", "+00\0"}, - {rules_EU, 6, 0, 733280400LL, 0, "WE%sT\0", "\0"}, - {rules_EU, 6, -3600, 0, 0, "-01\0", "+00\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Bermuda[] = { - {NULL, 0, -15558, -1262281242LL, 0, "LMT\0", "\0"}, - {NULL, 0, -14400, 136360800LL, 0, "AST\0", "\0"}, - {rules_Canada, 10, -14400, 189316800LL, 0, "A%sT\0", "\0"}, - {rules_US, 13, -14400, 0, 0, "A%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Canary[] = { - {NULL, 0, -3696, -1509663504LL, 0, "LMT\0", "\0"}, - {NULL, 0, -3600, -733874400LL, 0, "-01\0", "\0"}, - {NULL, 0, 0, 323827200LL, 0, "WET\0", "\0"}, - {rules_100, 1, 0, 338950800LL, 6, "WEST\0", "\0"}, - {rules_EU, 6, 0, 0, 0, "WE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Cape_Verde[] = { - {NULL, 0, -5644, -1988144756LL, 0, "LMT\0", "\0"}, - {NULL, 0, -7200, -862610400LL, 0, "-02\0", "\0"}, - {rules_100, 1, -7200, -764118000LL, 6, "-01\0", "\0"}, - {NULL, 0, -7200, 186120000LL, 0, "-02\0", "\0"}, - {NULL, 0, -3600, 0, 0, "-01\0", "\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Faroe[] = { - {NULL, 0, -1624, -1955748776LL, 0, "LMT\0", "\0"}, - {NULL, 0, 0, 347155200LL, 0, "WET\0", "\0"}, - {rules_EU, 6, 0, 0, 0, "WE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Madeira[] = { - {NULL, 0, -4056, -2713906344LL, 0, "LMT\0", "\0"}, - {NULL, 0, -4056, -1830379944LL, 0, "FMT\0", "\0"}, - {rules_Port, 50, -3600, -873680400LL, 6, "-01\0", "+00\0"}, - {rules_Port, 50, -3600, -864003600LL, 12, "+01\0", "\0"}, - {rules_Port, 50, -3600, -842835600LL, 6, "-01\0", "+00\0"}, - {rules_Port, 50, -3600, -831344400LL, 12, "+01\0", "\0"}, - {rules_Port, 50, -3600, -810781200LL, 6, "-01\0", "+00\0"}, - {rules_Port, 50, -3600, -799894800LL, 12, "+01\0", "\0"}, - {rules_Port, 50, -3600, -779331600LL, 6, "-01\0", "+00\0"}, - {rules_Port, 50, -3600, -768445200LL, 12, "+01\0", "\0"}, - {rules_Port, 50, -3600, -118270800LL, 0, "-01\0", "+00\0"}, - {rules_Port, 50, 0, 433299600LL, 6, "WE%sT\0", "\0"}, - {rules_EU, 6, 0, 0, 0, "WE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Reykjavik[] = { - {NULL, 0, -5280, -1956609120LL, 0, "LMT\0", "\0"}, - {rules_Iceland, 16, -3600, -54770400LL, 0, "-01\0", "+00\0"}, - {NULL, 0, 0, 0, 0, "GMT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_South_Georgia[] = { - {NULL, 0, -8768, -2524512832LL, 0, "LMT\0", "\0"}, - {NULL, 0, -7200, 0, 0, "-02\0", "\0"}, -}; -static const struct lc_timezone_era eras_Atlantic_Stanley[] = { - {NULL, 0, -13884, -2524507716LL, 0, "LMT\0", "\0"}, - {NULL, 0, -13884, -1824235716LL, 0, "SMT\0", "\0"}, - {rules_Falk, 12, -14400, 420609600LL, 0, "-04\0", "-03\0"}, - {rules_Falk, 12, -10800, 495601200LL, 0, "-03\0", "-02\0"}, - {rules_Falk, 12, -14400, 1283666400LL, 0, "-04\0", "-03\0"}, - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Adelaide[] = { - {NULL, 0, 33260, -2364110060LL, 0, "LMT\0", "\0"}, - {NULL, 0, 32400, -2230189200LL, 0, "ACST\0", "\0"}, - {rules_Aus, 7, 34200, 31501800LL, 0, "AC%sT\0", "\0"}, - {rules_AS, 15, 34200, 0, 0, "AC%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Brisbane[] = { - {NULL, 0, 36728, -2366791928LL, 0, "LMT\0", "\0"}, - {rules_Aus, 7, 36000, 31500000LL, 0, "AE%sT\0", "\0"}, - {rules_AQ, 4, 36000, 0, 0, "AE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Broken_Hill[] = { - {NULL, 0, 33948, -2364110748LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, -2314951200LL, 0, "AEST\0", "\0"}, - {NULL, 0, 32400, -2230189200LL, 0, "ACST\0", "\0"}, - {rules_Aus, 7, 34200, 31501800LL, 0, "AC%sT\0", "\0"}, - {rules_AN, 16, 34200, 946647000LL, 6, "AC%sT\0", "\0"}, - {rules_AS, 15, 34200, 0, 0, "AC%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Currie[] = { - {NULL, 0, 34528, -2345794528LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, -1680508800LL, 0, "AEST\0", "\0"}, - {rules_100, 1, 36000, -1669892400LL, 6, "AEDT\0", "\0"}, - {rules_Aus, 7, 36000, 47138400LL, 0, "AE%sT\0", "\0"}, - {rules_AT, 19, 36000, 0, 6, "AE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Darwin[] = { - {NULL, 0, 31400, -2364108200LL, 0, "LMT\0", "\0"}, - {NULL, 0, 32400, -2230189200LL, 0, "ACST\0", "\0"}, - {rules_Aus, 7, 34200, 0, 0, "AC%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Eucla[] = { - {NULL, 0, 30928, -2337928528LL, 0, "LMT\0", "\0"}, - {rules_Aus, 7, 31500, -836469900LL, 0, "+0845\0", "+0945\0"}, - {rules_AW, 9, 31500, 0, 0, "+0845\0", "+0945\0"}, -}; -static const struct lc_timezone_era eras_Australia_Hobart[] = { - {NULL, 0, 35356, -2345795356LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, -1680508800LL, 0, "AEST\0", "\0"}, - {rules_100, 1, 36000, -1669892400LL, 6, "AEDT\0", "\0"}, - {rules_Aus, 7, 36000, -94730400LL, 0, "AE%sT\0", "\0"}, - {rules_AT, 19, 36000, 0, 6, "AE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Lindeman[] = { - {NULL, 0, 35756, -2366790956LL, 0, "LMT\0", "\0"}, - {rules_Aus, 7, 36000, 31500000LL, 0, "AE%sT\0", "\0"}, - {rules_AQ, 4, 36000, 709912800LL, 0, "AE%sT\0", "\0"}, - {rules_Holiday, 2, 36000, 0, 0, "AE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Lord_Howe[] = { - {NULL, 0, 38180, -2364114980LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, 352216800LL, 0, "AEST\0", "\0"}, - {rules_LH, 14, 37800, 488986200LL, 0, "+1030\0", "+1130\0"}, - {rules_LH, 14, 37800, 0, 0, "+1030\0", "+11\0"}, -}; -static const struct lc_timezone_era eras_Australia_Melbourne[] = { - {NULL, 0, 34792, -2364111592LL, 0, "LMT\0", "\0"}, - {rules_Aus, 7, 36000, 31500000LL, 0, "AE%sT\0", "\0"}, - {rules_AV, 14, 36000, 0, 0, "AE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Perth[] = { - {NULL, 0, 27804, -2337925404LL, 0, "LMT\0", "\0"}, - {rules_Aus, 7, 28800, -836467200LL, 0, "AW%sT\0", "\0"}, - {rules_AW, 9, 28800, 0, 0, "AW%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Australia_Sydney[] = { - {NULL, 0, 36292, -2364113092LL, 0, "LMT\0", "\0"}, - {rules_Aus, 7, 36000, 31500000LL, 0, "AE%sT\0", "\0"}, - {rules_AN, 16, 36000, 0, 0, "AE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_CET[] = { - {rules_C_Eur, 17, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_CST6CDT[] = { - {rules_US, 13, -21600, 0, 0, "C%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_EET[] = { - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_EST[] = { - {NULL, 0, -18000, 0, 0, "EST\0", "\0"}, -}; -static const struct lc_timezone_era eras_EST5EDT[] = { - {rules_US, 13, -18000, 0, 0, "E%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT[] = { - {NULL, 0, 0, 0, 0, "GMT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT1[] = { - {NULL, 0, -3600, 0, 0, "-01\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT10[] = { - {NULL, 0, -36000, 0, 0, "-10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT11[] = { - {NULL, 0, -39600, 0, 0, "-11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT12[] = { - {NULL, 0, -43200, 0, 0, "-12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT2[] = { - {NULL, 0, -7200, 0, 0, "-02\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT3[] = { - {NULL, 0, -10800, 0, 0, "-03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT4[] = { - {NULL, 0, -14400, 0, 0, "-04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT5[] = { - {NULL, 0, -18000, 0, 0, "-05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT6[] = { - {NULL, 0, -21600, 0, 0, "-06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT7[] = { - {NULL, 0, -25200, 0, 0, "-07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT8[] = { - {NULL, 0, -28800, 0, 0, "-08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT9[] = { - {NULL, 0, -32400, 0, 0, "-09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_1[] = { - {NULL, 0, 3600, 0, 0, "+01\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_10[] = { - {NULL, 0, 36000, 0, 0, "+10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_11[] = { - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_12[] = { - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_13[] = { - {NULL, 0, 46800, 0, 0, "+13\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_14[] = { - {NULL, 0, 50400, 0, 0, "+14\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_2[] = { - {NULL, 0, 7200, 0, 0, "+02\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_3[] = { - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_4[] = { - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_5[] = { - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_6[] = { - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_7[] = { - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_8[] = { - {NULL, 0, 28800, 0, 0, "+08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_GMT_9[] = { - {NULL, 0, 32400, 0, 0, "+09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_UCT[] = { - {NULL, 0, 0, 0, 0, "UCT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Etc_UTC[] = { - {NULL, 0, 0, 0, 0, "UTC\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Amsterdam[] = { - {NULL, 0, 1172, -4260212372LL, 0, "LMT\0", "\0"}, - {rules_Neth, 20, 1172, -1025745572LL, 6, "%s\0", "\0"}, - {rules_Neth, 20, 1200, -935022000LL, 0, "+0020\0", "+0120\0"}, - {rules_C_Eur, 17, 3600, -781052400LL, 0, "CE%sT\0", "\0"}, - {rules_Neth, 20, 3600, 220921200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Andorra[] = { - {NULL, 0, 364, -2177453164LL, 0, "LMT\0", "\0"}, - {NULL, 0, 0, -733881600LL, 0, "WET\0", "\0"}, - {NULL, 0, 3600, 481078800LL, 0, "CET\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Astrakhan[] = { - {NULL, 0, 11532, -1441249932LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {rules_Russia, 16, 14400, 606866400LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 701820000LL, 0, "+04\0", "\0"}, - {rules_Russia, 16, 10800, 1301180400LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 1414274400LL, 0, "+04\0", "\0"}, - {NULL, 0, 10800, 1459033200LL, 0, "+03\0", "\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Athens[] = { - {NULL, 0, 5692, -2344642492LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5692, -1686101632LL, 0, "AMT\0", "\0"}, - {rules_Greece, 19, 7200, -904878000LL, 6, "EE%sT\0", "\0"}, - {rules_Greece, 19, 3600, -812422800LL, 0, "CE%sT\0", "\0"}, - {rules_Greece, 19, 7200, 347148000LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Belgrade[] = { - {NULL, 0, 4920, -2713915320LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3600, -905824800LL, 0, "CET\0", "\0"}, - {rules_C_Eur, 17, 3600, -788922000LL, 0, "CE%sT\0", "\0"}, - {NULL, 0, 3600, -777942000LL, 0, "CET\0", "\0"}, - {rules_100, 1, 3600, -766623600LL, 6, "CEST\0", "\0"}, - {NULL, 0, 3600, 407199600LL, 0, "CET\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Berlin[] = { - {NULL, 0, 3208, -2422054408LL, 0, "LMT\0", "\0"}, - {rules_C_Eur, 17, 3600, -776563200LL, 6, "CE%sT\0", "\0"}, - {rules_SovietZone, 3, 3600, -757386000LL, 0, "CE%sT\0", "\0"}, - {rules_Germany, 8, 3600, 315529200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Brussels[] = { - {NULL, 0, 1050, -2840141850LL, 0, "LMT\0", "\0"}, - {NULL, 0, 1050, -2450953050LL, 0, "BMT\0", "\0"}, - {NULL, 0, 0, -1740355200LL, 0, "WET\0", "\0"}, - {NULL, 0, 3600, -1693702800LL, 0, "CET\0", "\0"}, - {rules_C_Eur, 17, 3600, -1613826000LL, 0, "CE%sT\0", "\0"}, - {rules_Belgium, 34, 0, -934668000LL, 6, "WE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -799293600LL, 6, "CE%sT\0", "\0"}, - {rules_Belgium, 34, 3600, 220921200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Bucharest[] = { - {NULL, 0, 6264, -2469404664LL, 0, "LMT\0", "\0"}, - {NULL, 0, 6264, -1213148664LL, 0, "BMT\0", "\0"}, - {rules_Romania, 9, 7200, 354672000LL, 0, "EE%sT\0", "\0"}, - {rules_C_Eur, 17, 7200, 662680800LL, 0, "EE%sT\0", "\0"}, - {rules_Romania, 9, 7200, 757375200LL, 0, "EE%sT\0", "\0"}, - {rules_E_Eur, 6, 7200, 852069600LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Budapest[] = { - {NULL, 0, 4580, -2500938980LL, 0, "LMT\0", "\0"}, - {rules_C_Eur, 17, 3600, -1640998800LL, 0, "CE%sT\0", "\0"}, - {rules_Hungary, 18, 3600, -906771600LL, 0, "CE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -788922000LL, 0, "CE%sT\0", "\0"}, - {rules_Hungary, 18, 3600, 338950800LL, 6, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Chisinau[] = { - {NULL, 0, 6920, -2840147720LL, 0, "LMT\0", "\0"}, - {NULL, 0, 6900, -1637114100LL, 0, "CMT\0", "\0"}, - {NULL, 0, 6264, -1213148664LL, 0, "BMT\0", "\0"}, - {rules_Romania, 9, 7200, -927165600LL, 0, "EE%sT\0", "\0"}, - {rules_100, 1, 7200, -898138800LL, 6, "EEST\0", "\0"}, - {rules_C_Eur, 17, 3600, -800157600LL, 6, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 641944800LL, 6, "MSK\0", "MSD\0"}, - {rules_Russia, 16, 7200, 694216800LL, 0, "EE%sT\0", "\0"}, - {rules_E_Eur, 6, 7200, 852069600LL, 0, "EE%sT\0", "\0"}, - {rules_Moldova, 2, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Copenhagen[] = { - {NULL, 0, 3020, -2524524620LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3020, -2398294220LL, 0, "CMT\0", "\0"}, - {rules_Denmark, 11, 3600, -857257200LL, 6, "CE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -781052400LL, 0, "CE%sT\0", "\0"}, - {rules_Denmark, 11, 3600, 315529200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Dublin[] = { - {NULL, 0, -1500, -2821649700LL, 0, "LMT\0", "\0"}, - {NULL, 0, -1521, -1691962479LL, 0, "DMT\0", "\0"}, - {rules_100, 1, -1521, -1680471279LL, 6, "IST\0", "\0"}, - {rules_GB_Eire, 65, 0, -1517011200LL, 0, "%s\0", "\0"}, - {rules_GB_Eire, 65, 0, -942012000LL, 0, "GMT\0", "IST\0"}, - {rules_100, 1, 0, -733359600LL, 6, "IST\0", "\0"}, - {NULL, 0, 0, -719445600LL, 0, "GMT\0", "\0"}, - {rules_100, 1, 0, -699490800LL, 6, "IST\0", "\0"}, - {NULL, 0, 0, -684972000LL, 0, "GMT\0", "\0"}, - {rules_GB_Eire, 65, 0, -37242000LL, 6, "GMT\0", "IST\0"}, - {NULL, 0, 3600, 57722400LL, 0, "IST\0", "\0"}, - {rules_GB_Eire, 65, 0, 820454400LL, 0, "GMT\0", "IST\0"}, - {rules_EU, 6, 0, 0, 0, "GMT\0", "IST\0"}, -}; -static const struct lc_timezone_era eras_Europe_Gibraltar[] = { - {NULL, 0, -1284, -2821649916LL, 0, "LMT\0", "\0"}, - {rules_GB_Eire, 65, 0, -401320800LL, 0, "%s\0", "\0"}, - {NULL, 0, 3600, 378687600LL, 0, "CET\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Helsinki[] = { - {NULL, 0, 5989, -2890258789LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5989, -1535938789LL, 0, "HMT\0", "\0"}, - {rules_Finland, 4, 7200, 410220000LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Istanbul[] = { - {NULL, 0, 6952, -2840147752LL, 0, "LMT\0", "\0"}, - {NULL, 0, 7016, -1869875816LL, 0, "IMT\0", "\0"}, - {rules_Turkey, 54, 7200, 277246800LL, 6, "EE%sT\0", "\0"}, - {rules_Turkey, 54, 10800, 482792400LL, 0, "+03\0", "+04\0"}, - {rules_Turkey, 54, 7200, 1167602400LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 1301187600LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 1301274000LL, 0, "EET\0", "\0"}, - {rules_EU, 6, 7200, 1396141200LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 1396227600LL, 0, "EET\0", "\0"}, - {rules_EU, 6, 7200, 1445734800LL, 6, "EE%sT\0", "\0"}, - {rules_100, 1, 7200, 1446944400LL, 6, "EEST\0", "\0"}, - {rules_EU, 6, 7200, 1473195600LL, 6, "EE%sT\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Kaliningrad[] = { - {NULL, 0, 4920, -2422056120LL, 0, "LMT\0", "\0"}, - {rules_C_Eur, 17, 3600, -788922000LL, 0, "CE%sT\0", "\0"}, - {rules_Poland, 20, 7200, -757389600LL, 0, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 606870000LL, 0, "MSK\0", "MSD\0"}, - {rules_Russia, 16, 7200, 1301184000LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 10800, 1414278000LL, 0, "+03\0", "\0"}, - {NULL, 0, 7200, 0, 0, "EET\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Kiev[] = { - {NULL, 0, 7324, -2840148124LL, 0, "LMT\0", "\0"}, - {NULL, 0, 7324, -1441159324LL, 0, "KMT\0", "\0"}, - {NULL, 0, 7200, -1247536800LL, 0, "EET\0", "\0"}, - {NULL, 0, 10800, -892522800LL, 0, "MSK\0", "\0"}, - {rules_C_Eur, 17, 3600, -825382800LL, 0, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 646783200LL, 6, "MSK\0", "MSD\0"}, - {rules_100, 1, 7200, 686102400LL, 6, "EEST\0", "\0"}, - {rules_E_Eur, 6, 7200, 788911200LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Kirov[] = { - {NULL, 0, 11928, -1593820800LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {rules_Russia, 16, 14400, 606866400LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 701820000LL, 0, "+04\0", "\0"}, - {rules_Russia, 16, 10800, 1301180400LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 1414274400LL, 0, "+04\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Lisbon[] = { - {NULL, 0, -2205, -2713908195LL, 0, "LMT\0", "\0"}, - {NULL, 0, -2205, -1830381795LL, 0, "LMT\0", "\0"}, - {rules_Port, 50, 0, -118274400LL, 0, "WE%sT\0", "\0"}, - {NULL, 0, 3600, 212544000LL, 0, "CET\0", "\0"}, - {rules_Port, 50, 0, 433299600LL, 6, "WE%sT\0", "\0"}, - {rules_W_Eur, 6, 0, 717555600LL, 6, "WE%sT\0", "\0"}, - {rules_EU, 6, 3600, 828234000LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 0, 0, 0, "WE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_London[] = { - {NULL, 0, -75, -3852662325LL, 0, "LMT\0", "\0"}, - {rules_GB_Eire, 65, 0, -37242000LL, 6, "%s\0", "\0"}, - {NULL, 0, 3600, 57722400LL, 0, "BST\0", "\0"}, - {rules_GB_Eire, 65, 0, 820454400LL, 0, "%s\0", "\0"}, - {rules_EU, 6, 0, 0, 0, "GMT\0", "BST\0"}, -}; -static const struct lc_timezone_era eras_Europe_Luxembourg[] = { - {NULL, 0, 1476, -2069713476LL, 0, "LMT\0", "\0"}, - {rules_Lux, 23, 3600, -1612659600LL, 0, "CE%sT\0", "\0"}, - {rules_Lux, 23, 0, -1269813600LL, 6, "WE%sT\0", "\0"}, - {rules_Belgium, 34, 0, -935186400LL, 6, "WE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -797986800LL, 6, "WE%sT\0", "\0"}, - {rules_Belgium, 34, 3600, 220921200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Madrid[] = { - {NULL, 0, -884, -2177452800LL, 0, "LMT\0", "\0"}, - {rules_Spain, 30, 0, -940208400LL, 0, "WE%sT\0", "\0"}, - {rules_Spain, 30, 3600, 283993200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Malta[] = { - {NULL, 0, 3484, -2403478684LL, 0, "LMT\0", "\0"}, - {rules_Italy, 41, 3600, 102380400LL, 0, "CE%sT\0", "\0"}, - {rules_Malta, 7, 3600, 347151600LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Minsk[] = { - {NULL, 0, 6616, -2840147416LL, 0, "LMT\0", "\0"}, - {NULL, 0, 6600, -1441158600LL, 0, "MMT\0", "\0"}, - {NULL, 0, 7200, -1247536800LL, 0, "EET\0", "\0"}, - {NULL, 0, 10800, -899780400LL, 0, "MSK\0", "\0"}, - {rules_C_Eur, 17, 3600, -804650400LL, 6, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 631141200LL, 0, "MSK\0", "MSD\0"}, - {NULL, 0, 10800, 670374000LL, 0, "MSK\0", "\0"}, - {rules_Russia, 16, 7200, 1301184000LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Monaco[] = { - {NULL, 0, 1772, -2486680172LL, 0, "LMT\0", "\0"}, - {NULL, 0, 561, -1855958961LL, 0, "PMT\0", "\0"}, - {rules_France, 42, 0, -766623600LL, 12, "WE%sT\0", "\0"}, - {rules_France, 42, 3600, 220921200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Moscow[] = { - {NULL, 0, 9017, -2840149817LL, 0, "LMT\0", "\0"}, - {NULL, 0, 9017, -1688265017LL, 0, "MMT\0", "\0"}, - {rules_Russia, 16, 9079, -1593820800LL, 12, "%s\0", "\0"}, - {rules_Russia, 16, 10800, -1522728000LL, 6, "%s\0", "\0"}, - {rules_Russia, 16, 10800, -1491188400LL, 0, "MSK\0", "MSD\0"}, - {NULL, 0, 7200, -1247536800LL, 0, "EET\0", "\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "MSK\0", "MSD\0"}, - {rules_Russia, 16, 7200, 695779200LL, 0, "EE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 1301180400LL, 0, "MSK\0", "MSD\0"}, - {NULL, 0, 14400, 1414274400LL, 0, "MSK\0", "\0"}, - {NULL, 0, 10800, 0, 0, "MSK\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Oslo[] = { - {NULL, 0, 2580, -2366757780LL, 0, "LMT\0", "\0"}, - {rules_Norway, 7, 3600, -927511200LL, 0, "CE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -781052400LL, 0, "CE%sT\0", "\0"}, - {rules_Norway, 7, 3600, 315529200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Paris[] = { - {NULL, 0, 561, -2486678901LL, 0, "LMT\0", "\0"}, - {NULL, 0, 561, -1855958901LL, 0, "PMT\0", "\0"}, - {rules_France, 42, 0, -932436000LL, 6, "WE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -800071200LL, 6, "CE%sT\0", "\0"}, - {rules_France, 42, 0, -766623600LL, 12, "WE%sT\0", "\0"}, - {rules_France, 42, 3600, 220921200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Prague[] = { - {NULL, 0, 3464, -3786829064LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3464, -2469401864LL, 0, "PMT\0", "\0"}, - {rules_C_Eur, 17, 3600, -798073200LL, 6, "CE%sT\0", "\0"}, - {rules_Czech, 7, 3600, 283993200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Riga[] = { - {NULL, 0, 5794, -2840146594LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5794, -1632008194LL, 0, "RMT\0", "\0"}, - {rules_100, 1, 5794, -1618702594LL, 6, "LST\0", "\0"}, - {NULL, 0, 5794, -1601681794LL, 0, "RMT\0", "\0"}, - {rules_100, 1, 5794, -1597275394LL, 6, "LST\0", "\0"}, - {NULL, 0, 5794, -1377308194LL, 0, "RMT\0", "\0"}, - {NULL, 0, 7200, -928029600LL, 0, "EET\0", "\0"}, - {NULL, 0, 10800, -899521200LL, 0, "MSK\0", "\0"}, - {rules_C_Eur, 17, 3600, -795834000LL, 0, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 606870000LL, 0, "MSK\0", "MSD\0"}, - {rules_100, 1, 7200, 622598400LL, 6, "EEST\0", "\0"}, - {rules_Latvia, 2, 7200, 853797600LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 951775200LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 978386400LL, 0, "EET\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Rome[] = { - {NULL, 0, 2996, -3259097396LL, 0, "LMT\0", "\0"}, - {NULL, 0, 2996, -2403565200LL, 0, "RMT\0", "\0"}, - {rules_Italy, 41, 3600, -830311200LL, 6, "CE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -807156000LL, 6, "CE%sT\0", "\0"}, - {rules_Italy, 41, 3600, 315529200LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Samara[] = { - {NULL, 0, 12020, -1593820800LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {NULL, 0, 14400, -1102305600LL, 0, "+04\0", "\0"}, - {rules_Russia, 16, 14400, 606866400LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "+03\0", "+04\0"}, - {rules_Russia, 16, 7200, 686102400LL, 6, "+02\0", "+03\0"}, - {NULL, 0, 10800, 687916800LL, 0, "+03\0", "\0"}, - {rules_Russia, 16, 14400, 1269727200LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 10800, 1301180400LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Saratov[] = { - {NULL, 0, 11058, -1593820800LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {rules_Russia, 16, 14400, 575416800LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 701820000LL, 0, "+04\0", "\0"}, - {rules_Russia, 16, 10800, 1301180400LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 1414274400LL, 0, "+04\0", "\0"}, - {NULL, 0, 10800, 1480806000LL, 0, "+03\0", "\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Simferopol[] = { - {NULL, 0, 8184, -2840148984LL, 0, "LMT\0", "\0"}, - {NULL, 0, 8160, -1441160160LL, 0, "SMT\0", "\0"}, - {NULL, 0, 7200, -1247536800LL, 0, "EET\0", "\0"}, - {NULL, 0, 10800, -888894000LL, 0, "MSK\0", "\0"}, - {rules_C_Eur, 17, 3600, -811648800LL, 6, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 631141200LL, 0, "MSK\0", "MSD\0"}, - {NULL, 0, 10800, 646786800LL, 0, "MSK\0", "\0"}, - {NULL, 0, 7200, 694216800LL, 0, "EET\0", "\0"}, - {rules_E_Eur, 6, 7200, 767739600LL, 6, "EE%sT\0", "\0"}, - {rules_E_Eur, 6, 10800, 828219600LL, 0, "MSK\0", "MSD\0"}, - {rules_100, 1, 10800, 846374400LL, 6, "MSD\0", "\0"}, - {rules_Russia, 16, 10800, 852066000LL, 0, "MSK\0", "MSD\0"}, - {NULL, 0, 10800, 859683600LL, 0, "MSK\0", "\0"}, - {rules_EU, 6, 7200, 1396137600LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 14400, 1414274400LL, 0, "MSK\0", "\0"}, - {NULL, 0, 10800, 0, 0, "MSK\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Sofia[] = { - {NULL, 0, 5596, -2840146396LL, 0, "LMT\0", "\0"}, - {NULL, 0, 7016, -2369527016LL, 0, "IMT\0", "\0"}, - {NULL, 0, 7200, -857257200LL, 0, "EET\0", "\0"}, - {rules_C_Eur, 17, 3600, -788922000LL, 0, "CE%sT\0", "\0"}, - {NULL, 0, 3600, -781048800LL, 0, "CET\0", "\0"}, - {NULL, 0, 7200, 291762000LL, 0, "EET\0", "\0"}, - {rules_Bulg, 5, 7200, 401846400LL, 6, "EE%sT\0", "\0"}, - {rules_C_Eur, 17, 7200, 662680800LL, 0, "EE%sT\0", "\0"}, - {rules_E_Eur, 6, 7200, 852069600LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Stockholm[] = { - {NULL, 0, 4332, -2871681132LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3614, -2208992414LL, 0, "SET\0", "\0"}, - {NULL, 0, 3600, -1692496800LL, 0, "CET\0", "\0"}, - {rules_100, 1, 3600, -1680483600LL, 6, "CEST\0", "\0"}, - {NULL, 0, 3600, 315529200LL, 0, "CET\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Tallinn[] = { - {NULL, 0, 5940, -2840146740LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5940, -1638322740LL, 0, "TMT\0", "\0"}, - {rules_C_Eur, 17, 3600, -1593824400LL, 0, "CE%sT\0", "\0"}, - {NULL, 0, 5940, -1535938740LL, 0, "TMT\0", "\0"}, - {NULL, 0, 7200, -927943200LL, 0, "EET\0", "\0"}, - {NULL, 0, 10800, -892954800LL, 0, "MSK\0", "\0"}, - {rules_C_Eur, 17, 3600, -797652000LL, 6, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 606870000LL, 0, "MSK\0", "MSD\0"}, - {rules_100, 1, 7200, 622598400LL, 6, "EEST\0", "\0"}, - {rules_C_Eur, 17, 7200, 906411600LL, 6, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 941331600LL, 6, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 1014242400LL, 0, "EET\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Tirane[] = { - {NULL, 0, 4760, -1767230360LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3600, -932346000LL, 0, "CET\0", "\0"}, - {rules_Albania, 25, 3600, 457480800LL, 6, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Ulyanovsk[] = { - {NULL, 0, 11616, -1593820800LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {rules_Russia, 16, 14400, 606866400LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "+03\0", "+04\0"}, - {rules_Russia, 16, 7200, 695779200LL, 0, "+02\0", "+03\0"}, - {rules_Russia, 16, 10800, 1301180400LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 1414274400LL, 0, "+04\0", "\0"}, - {NULL, 0, 10800, 1459033200LL, 0, "+03\0", "\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Uzhgorod[] = { - {NULL, 0, 5352, -2500939752LL, 0, "LMT\0", "\0"}, - {NULL, 0, 3600, -946774800LL, 0, "CET\0", "\0"}, - {rules_C_Eur, 17, 3600, -796874400LL, 6, "CE%sT\0", "\0"}, - {rules_100, 1, 3600, -794714400LL, 6, "CEST\0", "\0"}, - {NULL, 0, 3600, -773456400LL, 0, "CET\0", "\0"}, - {rules_Russia, 16, 10800, 631141200LL, 0, "MSK\0", "MSD\0"}, - {NULL, 0, 10800, 646786800LL, 0, "MSK\0", "\0"}, - {NULL, 0, 3600, 670384800LL, 0, "CET\0", "\0"}, - {NULL, 0, 7200, 694216800LL, 0, "EET\0", "\0"}, - {rules_E_Eur, 6, 7200, 788911200LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Vienna[] = { - {NULL, 0, 3921, -2422055121LL, 0, "LMT\0", "\0"}, - {rules_C_Eur, 17, 3600, -1577926800LL, 0, "CE%sT\0", "\0"}, - {rules_Austria, 8, 3600, -938905200LL, 0, "CE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -781052400LL, 0, "CE%sT\0", "\0"}, - {rules_100, 1, 3600, -780188400LL, 6, "CEST\0", "\0"}, - {NULL, 0, 3600, -757386000LL, 0, "CET\0", "\0"}, - {rules_Austria, 8, 3600, 347151600LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Vilnius[] = { - {NULL, 0, 6076, -2840146876LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5040, -1672536240LL, 0, "WMT\0", "\0"}, - {NULL, 0, 5736, -1585100136LL, 0, "KMT\0", "\0"}, - {NULL, 0, 3600, -1561251600LL, 0, "CET\0", "\0"}, - {NULL, 0, 7200, -1553565600LL, 0, "EET\0", "\0"}, - {NULL, 0, 3600, -928198800LL, 0, "CET\0", "\0"}, - {NULL, 0, 10800, -900126000LL, 0, "MSK\0", "\0"}, - {rules_C_Eur, 17, 3600, -802144800LL, 6, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 606870000LL, 0, "MSK\0", "MSD\0"}, - {rules_Russia, 16, 7200, 686102400LL, 6, "EE%sT\0", "\0"}, - {rules_C_Eur, 17, 7200, 883605600LL, 0, "EE%sT\0", "\0"}, - {NULL, 0, 7200, 891133200LL, 0, "EET\0", "\0"}, - {rules_EU, 6, 3600, 941331600LL, 6, "CE%sT\0", "\0"}, - {NULL, 0, 7200, 1041372000LL, 0, "EET\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Volgograd[] = { - {NULL, 0, 10660, -1577761060LL, 0, "LMT\0", "\0"}, - {NULL, 0, 10800, -1247540400LL, 0, "+03\0", "\0"}, - {NULL, 0, 14400, -256881600LL, 0, "+04\0", "\0"}, - {rules_Russia, 16, 14400, 575416800LL, 0, "+04\0", "+05\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 701820000LL, 0, "+04\0", "\0"}, - {rules_Russia, 16, 10800, 1301180400LL, 0, "+03\0", "+04\0"}, - {NULL, 0, 14400, 1414274400LL, 0, "+04\0", "\0"}, - {NULL, 0, 10800, 0, 0, "+03\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Warsaw[] = { - {NULL, 0, 5040, -2840145840LL, 0, "LMT\0", "\0"}, - {NULL, 0, 5040, -1717032240LL, 0, "WMT\0", "\0"}, - {rules_C_Eur, 17, 3600, -1618700400LL, 6, "CE%sT\0", "\0"}, - {rules_Poland, 20, 7200, -1501725600LL, 0, "EE%sT\0", "\0"}, - {rules_Poland, 20, 3600, -931734000LL, 0, "CE%sT\0", "\0"}, - {rules_C_Eur, 17, 3600, -796874400LL, 6, "CE%sT\0", "\0"}, - {rules_Poland, 20, 3600, 220921200LL, 0, "CE%sT\0", "\0"}, - {rules_W_Eur, 6, 3600, 567990000LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Zaporozhye[] = { - {NULL, 0, 8440, -2840149240LL, 0, "LMT\0", "\0"}, - {NULL, 0, 8400, -1441160400LL, 0, "+0220\0", "\0"}, - {NULL, 0, 7200, -1247536800LL, 0, "EET\0", "\0"}, - {NULL, 0, 10800, -894769200LL, 0, "MSK\0", "\0"}, - {rules_C_Eur, 17, 3600, -826419600LL, 0, "CE%sT\0", "\0"}, - {rules_Russia, 16, 10800, 670374000LL, 0, "MSK\0", "MSD\0"}, - {rules_E_Eur, 6, 7200, 788911200LL, 0, "EE%sT\0", "\0"}, - {rules_EU, 6, 7200, 0, 0, "EE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Europe_Zurich[] = { - {NULL, 0, 2048, -3675198848LL, 0, "LMT\0", "\0"}, - {NULL, 0, 1786, -2385246586LL, 0, "BMT\0", "\0"}, - {rules_Swiss, 2, 3600, 347151600LL, 0, "CE%sT\0", "\0"}, - {rules_EU, 6, 3600, 0, 0, "CE%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_HST[] = { - {NULL, 0, -36000, 0, 0, "HST\0", "\0"}, -}; -static const struct lc_timezone_era eras_Indian_Chagos[] = { - {NULL, 0, 17380, -1988167780LL, 0, "LMT\0", "\0"}, - {NULL, 0, 18000, 820436400LL, 0, "+05\0", "\0"}, - {NULL, 0, 21600, 0, 0, "+06\0", "\0"}, -}; -static const struct lc_timezone_era eras_Indian_Christmas[] = { - {NULL, 0, 25372, -2364102172LL, 0, "LMT\0", "\0"}, - {NULL, 0, 25200, 0, 0, "+07\0", "\0"}, -}; -static const struct lc_timezone_era eras_Indian_Cocos[] = { - {NULL, 0, 23260, -2209012060LL, 0, "LMT\0", "\0"}, - {NULL, 0, 23400, 0, 0, "+0630\0", "\0"}, -}; -static const struct lc_timezone_era eras_Indian_Kerguelen[] = { - {NULL, 0, 0, -631152000LL, 0, "-00\0", "\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Indian_Mahe[] = { - {NULL, 0, 13308, -2006653308LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_Indian_Maldives[] = { - {NULL, 0, 17640, -2840158440LL, 0, "LMT\0", "\0"}, - {NULL, 0, 17640, -315636840LL, 0, "MMT\0", "\0"}, - {NULL, 0, 18000, 0, 0, "+05\0", "\0"}, -}; -static const struct lc_timezone_era eras_Indian_Mauritius[] = { - {NULL, 0, 13800, -1988164200LL, 0, "LMT\0", "\0"}, - {rules_Mauritius, 4, 14400, 0, 0, "+04\0", "+05\0"}, -}; -static const struct lc_timezone_era eras_Indian_Reunion[] = { - {NULL, 0, 13312, -1848886912LL, 0, "LMT\0", "\0"}, - {NULL, 0, 14400, 0, 0, "+04\0", "\0"}, -}; -static const struct lc_timezone_era eras_MET[] = { - {rules_C_Eur, 17, 3600, 0, 0, "ME%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_MST[] = { - {NULL, 0, -25200, 0, 0, "MST\0", "\0"}, -}; -static const struct lc_timezone_era eras_MST7MDT[] = { - {rules_US, 13, -25200, 0, 0, "M%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_PST8PDT[] = { - {rules_US, 13, -28800, 0, 0, "P%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Apia[] = { - {NULL, 0, 45184, -2855737984LL, 0, "LMT\0", "\0"}, - {NULL, 0, -41216, -1861878784LL, 0, "LMT\0", "\0"}, - {NULL, 0, -41400, -631110600LL, 0, "-1130\0", "\0"}, - {rules_WS, 5, -39600, 1325239200LL, 6, "-11\0", "-10\0"}, - {rules_WS, 5, 46800, 0, 0, "+13\0", "+14\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Auckland[] = { - {NULL, 0, 41944, -3192435544LL, 0, "LMT\0", "\0"}, - {rules_NZ, 16, 41400, -757425600LL, 3, "NZ%sT\0", "\0"}, - {rules_NZ, 16, 43200, 0, 0, "NZ%sT\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Bougainville[] = { - {NULL, 0, 37336, -2840178136LL, 0, "LMT\0", "\0"}, - {NULL, 0, 35312, -2366790512LL, 0, "PMMT\0", "\0"}, - {NULL, 0, 36000, -868010400LL, 0, "+10\0", "\0"}, - {NULL, 0, 32400, -768906000LL, 0, "+09\0", "\0"}, - {NULL, 0, 36000, 1419696000LL, 0, "+10\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Chatham[] = { - {NULL, 0, 44028, -3192437628LL, 0, "LMT\0", "\0"}, - {NULL, 0, 44100, -757426500LL, 0, "+1215\0", "\0"}, - {rules_Chatham, 9, 45900, 0, 0, "+1245\0", "+1345\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Chuuk[] = { - {NULL, 0, 36428, -2177489228LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, 0, 0, "+10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Easter[] = { - {NULL, 0, -26248, -2524495352LL, 0, "LMT\0", "\0"}, - {NULL, 0, -26248, -1178124152LL, 0, "EMT\0", "\0"}, - {rules_Chile, 32, -25200, 384922800LL, 6, "-07\0", "-06\0"}, - {rules_Chile, 32, -21600, 0, 6, "-06\0", "-05\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Efate[] = { - {NULL, 0, 40396, -1829387596LL, 0, "LMT\0", "\0"}, - {rules_Vanuatu, 6, 39600, 0, 0, "+11\0", "+12\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Enderbury[] = { - {NULL, 0, -41060, -2177411740LL, 0, "LMT\0", "\0"}, - {NULL, 0, -43200, 307627200LL, 0, "-12\0", "\0"}, - {NULL, 0, -39600, 788958000LL, 0, "-11\0", "\0"}, - {NULL, 0, 46800, 0, 0, "+13\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Fakaofo[] = { - {NULL, 0, -41096, -2177411704LL, 0, "LMT\0", "\0"}, - {NULL, 0, -39600, 1325242800LL, 0, "-11\0", "\0"}, - {NULL, 0, 46800, 0, 0, "+13\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Fiji[] = { - {NULL, 0, 42944, -1709985344LL, 0, "LMT\0", "\0"}, - {rules_Fiji, 10, 43200, 0, 0, "+12\0", "+13\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Funafuti[] = { - {NULL, 0, 43012, -2177495812LL, 0, "LMT\0", "\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Galapagos[] = { - {NULL, 0, -21504, -1230746496LL, 0, "LMT\0", "\0"}, - {NULL, 0, -18000, 504939600LL, 0, "-05\0", "\0"}, - {rules_Ecuador, 2, -21600, 0, 0, "-06\0", "-05\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Gambier[] = { - {NULL, 0, -32388, -1806678012LL, 0, "LMT\0", "\0"}, - {NULL, 0, -32400, 0, 0, "-09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Guadalcanal[] = { - {NULL, 0, 38388, -1806748788LL, 0, "LMT\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Guam[] = { - {NULL, 0, -51660, -3944626740LL, 0, "LMT\0", "\0"}, - {NULL, 0, 34740, -2177487540LL, 0, "LMT\0", "\0"}, - {NULL, 0, 36000, 977493600LL, 0, "GST\0", "\0"}, - {NULL, 0, 36000, 0, 0, "ChST\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Honolulu[] = { - {NULL, 0, -37886, -2334101314LL, 0, "LMT\0", "\0"}, - {NULL, 0, -37800, -1157283000LL, 0, "HST\0", "\0"}, - {rules_100, 1, -37800, -1155436200LL, 6, "HDT\0", "\0"}, - {NULL, 0, -37800, -880198200LL, 0, "HST\0", "\0"}, - {rules_100, 1, -37800, -765376200LL, 6, "HDT\0", "\0"}, - {NULL, 0, -37800, -712150200LL, 0, "HST\0", "\0"}, - {NULL, 0, -36000, 0, 0, "HST\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Kiritimati[] = { - {NULL, 0, -37760, -2177415040LL, 0, "LMT\0", "\0"}, - {NULL, 0, -38400, 307622400LL, 0, "-1040\0", "\0"}, - {NULL, 0, -36000, 788954400LL, 0, "-10\0", "\0"}, - {NULL, 0, 50400, 0, 0, "+14\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Kosrae[] = { - {NULL, 0, 39116, -2177491916LL, 0, "LMT\0", "\0"}, - {NULL, 0, 39600, -7988400LL, 0, "+11\0", "\0"}, - {NULL, 0, 43200, 915105600LL, 0, "+12\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Kwajalein[] = { - {NULL, 0, 40160, -2177492960LL, 0, "LMT\0", "\0"}, - {NULL, 0, 39600, -7988400LL, 0, "+11\0", "\0"}, - {NULL, 0, -43200, 745848000LL, 0, "-12\0", "\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Majuro[] = { - {NULL, 0, 41088, -2177493888LL, 0, "LMT\0", "\0"}, - {NULL, 0, 39600, -7988400LL, 0, "+11\0", "\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Marquesas[] = { - {NULL, 0, -33480, -1806676920LL, 0, "LMT\0", "\0"}, - {NULL, 0, -34200, 0, 0, "-0930\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Nauru[] = { - {NULL, 0, 40060, -1545131260LL, 0, "LMT\0", "\0"}, - {NULL, 0, 41400, -877347000LL, 0, "+1130\0", "\0"}, - {NULL, 0, 32400, -800960400LL, 0, "+09\0", "\0"}, - {NULL, 0, 41400, 294323400LL, 0, "+1130\0", "\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Niue[] = { - {NULL, 0, -40780, -2177412020LL, 0, "LMT\0", "\0"}, - {NULL, 0, -40800, -599575200LL, 0, "-1120\0", "\0"}, - {NULL, 0, -41400, 276089400LL, 0, "-1130\0", "\0"}, - {NULL, 0, -39600, 0, 0, "-11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Norfolk[] = { - {NULL, 0, 40312, -2177493112LL, 0, "LMT\0", "\0"}, - {NULL, 0, 40320, -599656320LL, 0, "+1112\0", "\0"}, - {NULL, 0, 41400, 152029800LL, 0, "+1130\0", "\0"}, - {rules_100, 1, 41400, 162912600LL, 6, "+1230\0", "\0"}, - {NULL, 0, 41400, 1443882600LL, 0, "+1130\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Noumea[] = { - {NULL, 0, 39948, -1829387148LL, 0, "LMT\0", "\0"}, - {rules_NC, 4, 39600, 0, 0, "+11\0", "+12\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Pago_Pago[] = { - {NULL, 0, 45432, -2855738232LL, 0, "LMT\0", "\0"}, - {NULL, 0, -40968, -1861879032LL, 0, "LMT\0", "\0"}, - {NULL, 0, -39600, 0, 0, "SST\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Palau[] = { - {NULL, 0, 32276, -2177485076LL, 0, "LMT\0", "\0"}, - {NULL, 0, 32400, 0, 0, "+09\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Pitcairn[] = { - {NULL, 0, -31220, -2177421580LL, 0, "LMT\0", "\0"}, - {NULL, 0, -30600, 893665800LL, 0, "-0830\0", "\0"}, - {NULL, 0, -28800, 0, 0, "-08\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Pohnpei[] = { - {NULL, 0, 37972, -2177490772LL, 0, "LMT\0", "\0"}, - {NULL, 0, 39600, 0, 0, "+11\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Port_Moresby[] = { - {NULL, 0, 35320, -2840176120LL, 0, "LMT\0", "\0"}, - {NULL, 0, 35312, -2366790512LL, 0, "PMMT\0", "\0"}, - {NULL, 0, 36000, 0, 0, "+10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Rarotonga[] = { - {NULL, 0, -38344, -2177414456LL, 0, "LMT\0", "\0"}, - {NULL, 0, -37800, 279714600LL, 0, "-1030\0", "\0"}, - {rules_Cook, 3, -36000, 0, 0, "-10\0", "-0930\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Tahiti[] = { - {NULL, 0, -35896, -1806674504LL, 0, "LMT\0", "\0"}, - {NULL, 0, -36000, 0, 0, "-10\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Tarawa[] = { - {NULL, 0, 41524, -2177494324LL, 0, "LMT\0", "\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Tongatapu[] = { - {NULL, 0, 44360, -2177497160LL, 0, "LMT\0", "\0"}, - {NULL, 0, 44400, -915193200LL, 0, "+1220\0", "\0"}, - {NULL, 0, 46800, 915102000LL, 0, "+13\0", "\0"}, - {rules_Tonga, 6, 46800, 0, 0, "+13\0", "+14\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Wake[] = { - {NULL, 0, 39988, -2177492788LL, 0, "LMT\0", "\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_Pacific_Wallis[] = { - {NULL, 0, 44120, -2177496920LL, 0, "LMT\0", "\0"}, - {NULL, 0, 43200, 0, 0, "+12\0", "\0"}, -}; -static const struct lc_timezone_era eras_WET[] = { - {rules_EU, 6, 0, 0, 0, "WE%sT\0", "\0"}, -}; -static const char timezone_names[] = - "Africa/Abidjan\0" - "Africa/Accra\0" - "Africa/Addis_Ababa\0" - "Africa/Algiers\0" - "Africa/Asmara\0" - "Africa/Asmera\0" - "Africa/Bamako\0" - "Africa/Bangui\0" - "Africa/Banjul\0" - "Africa/Bissau\0" - "Africa/Blantyre\0" - "Africa/Brazzaville\0" - "Africa/Bujumbura\0" - "Africa/Cairo\0" - "Africa/Casablanca\0" - "Africa/Ceuta\0" - "Africa/Conakry\0" - "Africa/Dakar\0" - "Africa/Dar_es_Salaam\0" - "Africa/Djibouti\0" - "Africa/Douala\0" - "Africa/El_Aaiun\0" - "Africa/Freetown\0" - "Africa/Gaborone\0" - "Africa/Harare\0" - "Africa/Johannesburg\0" - "Africa/Juba\0" - "Africa/Kampala\0" - "Africa/Khartoum\0" - "Africa/Kigali\0" - "Africa/Kinshasa\0" - "Africa/Lagos\0" - "Africa/Libreville\0" - "Africa/Lome\0" - "Africa/Luanda\0" - "Africa/Lubumbashi\0" - "Africa/Lusaka\0" - "Africa/Malabo\0" - "Africa/Maputo\0" - "Africa/Maseru\0" - "Africa/Mbabane\0" - "Africa/Mogadishu\0" - "Africa/Monrovia\0" - "Africa/Nairobi\0" - "Africa/Ndjamena\0" - "Africa/Niamey\0" - "Africa/Nouakchott\0" - "Africa/Ouagadougou\0" - "Africa/Porto-Novo\0" - "Africa/Sao_Tome\0" - "Africa/Timbuktu\0" - "Africa/Tripoli\0" - "Africa/Tunis\0" - "Africa/Windhoek\0" - "America/Adak\0" - "America/Anchorage\0" - "America/Anguilla\0" - "America/Antigua\0" - "America/Araguaina\0" - "America/Argentina/Buenos_Aires\0" - "America/Argentina/Catamarca\0" - "America/Argentina/ComodRivadavia\0" - "America/Argentina/Cordoba\0" - "America/Argentina/Jujuy\0" - "America/Argentina/La_Rioja\0" - "America/Argentina/Mendoza\0" - "America/Argentina/Rio_Gallegos\0" - "America/Argentina/Salta\0" - "America/Argentina/San_Juan\0" - "America/Argentina/San_Luis\0" - "America/Argentina/Tucuman\0" - "America/Argentina/Ushuaia\0" - "America/Aruba\0" - "America/Asuncion\0" - "America/Atikokan\0" - "America/Atka\0" - "America/Bahia\0" - "America/Bahia_Banderas\0" - "America/Barbados\0" - "America/Belem\0" - "America/Belize\0" - "America/Blanc-Sablon\0" - "America/Boa_Vista\0" - "America/Bogota\0" - "America/Boise\0" - "America/Buenos_Aires\0" - "America/Cambridge_Bay\0" - "America/Campo_Grande\0" - "America/Cancun\0" - "America/Caracas\0" - "America/Catamarca\0" - "America/Cayenne\0" - "America/Cayman\0" - "America/Chicago\0" - "America/Chihuahua\0" - "America/Coral_Harbour\0" - "America/Cordoba\0" - "America/Costa_Rica\0" - "America/Creston\0" - "America/Cuiaba\0" - "America/Curacao\0" - "America/Danmarkshavn\0" - "America/Dawson\0" - "America/Dawson_Creek\0" - "America/Denver\0" - "America/Detroit\0" - "America/Dominica\0" - "America/Edmonton\0" - "America/Eirunepe\0" - "America/El_Salvador\0" - "America/Ensenada\0" - "America/Fort_Nelson\0" - "America/Fort_Wayne\0" - "America/Fortaleza\0" - "America/Glace_Bay\0" - "America/Godthab\0" - "America/Goose_Bay\0" - "America/Grand_Turk\0" - "America/Grenada\0" - "America/Guadeloupe\0" - "America/Guatemala\0" - "America/Guayaquil\0" - "America/Guyana\0" - "America/Halifax\0" - "America/Havana\0" - "America/Hermosillo\0" - "America/Indiana/Indianapolis\0" - "America/Indiana/Knox\0" - "America/Indiana/Marengo\0" - "America/Indiana/Petersburg\0" - "America/Indiana/Tell_City\0" - "America/Indiana/Vevay\0" - "America/Indiana/Vincennes\0" - "America/Indiana/Winamac\0" - "America/Indianapolis\0" - "America/Inuvik\0" - "America/Iqaluit\0" - "America/Jamaica\0" - "America/Jujuy\0" - "America/Juneau\0" - "America/Kentucky/Louisville\0" - "America/Kentucky/Monticello\0" - "America/Knox_IN\0" - "America/Kralendijk\0" - "America/La_Paz\0" - "America/Lima\0" - "America/Los_Angeles\0" - "America/Louisville\0" - "America/Lower_Princes\0" - "America/Maceio\0" - "America/Managua\0" - "America/Manaus\0" - "America/Marigot\0" - "America/Martinique\0" - "America/Matamoros\0" - "America/Mazatlan\0" - "America/Mendoza\0" - "America/Menominee\0" - "America/Merida\0" - "America/Metlakatla\0" - "America/Mexico_City\0" - "America/Miquelon\0" - "America/Moncton\0" - "America/Monterrey\0" - "America/Montevideo\0" - "America/Montreal\0" - "America/Montserrat\0" - "America/Nassau\0" - "America/New_York\0" - "America/Nipigon\0" - "America/Nome\0" - "America/Noronha\0" - "America/North_Dakota/Beulah\0" - "America/North_Dakota/Center\0" - "America/North_Dakota/New_Salem\0" - "America/Ojinaga\0" - "America/Panama\0" - "America/Pangnirtung\0" - "America/Paramaribo\0" - "America/Phoenix\0" - "America/Port-au-Prince\0" - "America/Port_of_Spain\0" - "America/Porto_Acre\0" - "America/Porto_Velho\0" - "America/Puerto_Rico\0" - "America/Punta_Arenas\0" - "America/Rainy_River\0" - "America/Rankin_Inlet\0" - "America/Recife\0" - "America/Regina\0" - "America/Resolute\0" - "America/Rio_Branco\0" - "America/Rosario\0" - "America/Santa_Isabel\0" - "America/Santarem\0" - "America/Santiago\0" - "America/Santo_Domingo\0" - "America/Sao_Paulo\0" - "America/Scoresbysund\0" - "America/Shiprock\0" - "America/Sitka\0" - "America/St_Barthelemy\0" - "America/St_Johns\0" - "America/St_Kitts\0" - "America/St_Lucia\0" - "America/St_Thomas\0" - "America/St_Vincent\0" - "America/Swift_Current\0" - "America/Tegucigalpa\0" - "America/Thule\0" - "America/Thunder_Bay\0" - "America/Tijuana\0" - "America/Toronto\0" - "America/Tortola\0" - "America/Vancouver\0" - "America/Virgin\0" - "America/Whitehorse\0" - "America/Winnipeg\0" - "America/Yakutat\0" - "America/Yellowknife\0" - "Antarctica/Casey\0" - "Antarctica/Davis\0" - "Antarctica/DumontDUrville\0" - "Antarctica/Macquarie\0" - "Antarctica/Mawson\0" - "Antarctica/McMurdo\0" - "Antarctica/Palmer\0" - "Antarctica/Rothera\0" - "Antarctica/South_Pole\0" - "Antarctica/Syowa\0" - "Antarctica/Troll\0" - "Antarctica/Vostok\0" - "Arctic/Longyearbyen\0" - "Asia/Aden\0" - "Asia/Almaty\0" - "Asia/Amman\0" - "Asia/Anadyr\0" - "Asia/Aqtau\0" - "Asia/Aqtobe\0" - "Asia/Ashgabat\0" - "Asia/Ashkhabad\0" - "Asia/Atyrau\0" - "Asia/Baghdad\0" - "Asia/Bahrain\0" - "Asia/Baku\0" - "Asia/Bangkok\0" - "Asia/Barnaul\0" - "Asia/Beirut\0" - "Asia/Bishkek\0" - "Asia/Brunei\0" - "Asia/Calcutta\0" - "Asia/Chita\0" - "Asia/Choibalsan\0" - "Asia/Chongqing\0" - "Asia/Chungking\0" - "Asia/Colombo\0" - "Asia/Dacca\0" - "Asia/Damascus\0" - "Asia/Dhaka\0" - "Asia/Dili\0" - "Asia/Dubai\0" - "Asia/Dushanbe\0" - "Asia/Famagusta\0" - "Asia/Gaza\0" - "Asia/Harbin\0" - "Asia/Hebron\0" - "Asia/Ho_Chi_Minh\0" - "Asia/Hong_Kong\0" - "Asia/Hovd\0" - "Asia/Irkutsk\0" - "Asia/Istanbul\0" - "Asia/Jakarta\0" - "Asia/Jayapura\0" - "Asia/Jerusalem\0" - "Asia/Kabul\0" - "Asia/Kamchatka\0" - "Asia/Karachi\0" - "Asia/Kashgar\0" - "Asia/Kathmandu\0" - "Asia/Katmandu\0" - "Asia/Khandyga\0" - "Asia/Kolkata\0" - "Asia/Krasnoyarsk\0" - "Asia/Kuala_Lumpur\0" - "Asia/Kuching\0" - "Asia/Kuwait\0" - "Asia/Macao\0" - "Asia/Macau\0" - "Asia/Magadan\0" - "Asia/Makassar\0" - "Asia/Manila\0" - "Asia/Muscat\0" - "Asia/Nicosia\0" - "Asia/Novokuznetsk\0" - "Asia/Novosibirsk\0" - "Asia/Omsk\0" - "Asia/Oral\0" - "Asia/Phnom_Penh\0" - "Asia/Pontianak\0" - "Asia/Pyongyang\0" - "Asia/Qatar\0" - "Asia/Qyzylorda\0" - "Asia/Rangoon\0" - "Asia/Riyadh\0" - "Asia/Saigon\0" - "Asia/Sakhalin\0" - "Asia/Samarkand\0" - "Asia/Seoul\0" - "Asia/Shanghai\0" - "Asia/Singapore\0" - "Asia/Srednekolymsk\0" - "Asia/Taipei\0" - "Asia/Tashkent\0" - "Asia/Tbilisi\0" - "Asia/Tehran\0" - "Asia/Tel_Aviv\0" - "Asia/Thimbu\0" - "Asia/Thimphu\0" - "Asia/Tokyo\0" - "Asia/Tomsk\0" - "Asia/Ujung_Pandang\0" - "Asia/Ulaanbaatar\0" - "Asia/Ulan_Bator\0" - "Asia/Urumqi\0" - "Asia/Ust-Nera\0" - "Asia/Vientiane\0" - "Asia/Vladivostok\0" - "Asia/Yakutsk\0" - "Asia/Yangon\0" - "Asia/Yekaterinburg\0" - "Asia/Yerevan\0" - "Atlantic/Azores\0" - "Atlantic/Bermuda\0" - "Atlantic/Canary\0" - "Atlantic/Cape_Verde\0" - "Atlantic/Faeroe\0" - "Atlantic/Faroe\0" - "Atlantic/Jan_Mayen\0" - "Atlantic/Madeira\0" - "Atlantic/Reykjavik\0" - "Atlantic/South_Georgia\0" - "Atlantic/St_Helena\0" - "Atlantic/Stanley\0" - "Australia/ACT\0" - "Australia/Adelaide\0" - "Australia/Brisbane\0" - "Australia/Broken_Hill\0" - "Australia/Canberra\0" - "Australia/Currie\0" - "Australia/Darwin\0" - "Australia/Eucla\0" - "Australia/Hobart\0" - "Australia/LHI\0" - "Australia/Lindeman\0" - "Australia/Lord_Howe\0" - "Australia/Melbourne\0" - "Australia/NSW\0" - "Australia/North\0" - "Australia/Perth\0" - "Australia/Queensland\0" - "Australia/South\0" - "Australia/Sydney\0" - "Australia/Tasmania\0" - "Australia/Victoria\0" - "Australia/West\0" - "Australia/Yancowinna\0" - "Brazil/Acre\0" - "Brazil/DeNoronha\0" - "Brazil/East\0" - "Brazil/West\0" - "CET\0" - "CST6CDT\0" - "Canada/Atlantic\0" - "Canada/Central\0" - "Canada/East-Saskatchewan\0" - "Canada/Eastern\0" - "Canada/Mountain\0" - "Canada/Newfoundland\0" - "Canada/Pacific\0" - "Canada/Saskatchewan\0" - "Canada/Yukon\0" - "Chile/Continental\0" - "Chile/EasterIsland\0" - "Cuba\0" - "EET\0" - "EST\0" - "EST5EDT\0" - "Egypt\0" - "Eire\0" - "Etc/GMT\0" - "Etc/GMT+0\0" - "Etc/GMT+1\0" - "Etc/GMT+10\0" - "Etc/GMT+11\0" - "Etc/GMT+12\0" - "Etc/GMT+2\0" - "Etc/GMT+3\0" - "Etc/GMT+4\0" - "Etc/GMT+5\0" - "Etc/GMT+6\0" - "Etc/GMT+7\0" - "Etc/GMT+8\0" - "Etc/GMT+9\0" - "Etc/GMT-0\0" - "Etc/GMT-1\0" - "Etc/GMT-10\0" - "Etc/GMT-11\0" - "Etc/GMT-12\0" - "Etc/GMT-13\0" - "Etc/GMT-14\0" - "Etc/GMT-2\0" - "Etc/GMT-3\0" - "Etc/GMT-4\0" - "Etc/GMT-5\0" - "Etc/GMT-6\0" - "Etc/GMT-7\0" - "Etc/GMT-8\0" - "Etc/GMT-9\0" - "Etc/GMT0\0" - "Etc/Greenwich\0" - "Etc/UCT\0" - "Etc/UTC\0" - "Etc/Universal\0" - "Etc/Zulu\0" - "Europe/Amsterdam\0" - "Europe/Andorra\0" - "Europe/Astrakhan\0" - "Europe/Athens\0" - "Europe/Belfast\0" - "Europe/Belgrade\0" - "Europe/Berlin\0" - "Europe/Bratislava\0" - "Europe/Brussels\0" - "Europe/Bucharest\0" - "Europe/Budapest\0" - "Europe/Busingen\0" - "Europe/Chisinau\0" - "Europe/Copenhagen\0" - "Europe/Dublin\0" - "Europe/Gibraltar\0" - "Europe/Guernsey\0" - "Europe/Helsinki\0" - "Europe/Isle_of_Man\0" - "Europe/Istanbul\0" - "Europe/Jersey\0" - "Europe/Kaliningrad\0" - "Europe/Kiev\0" - "Europe/Kirov\0" - "Europe/Lisbon\0" - "Europe/Ljubljana\0" - "Europe/London\0" - "Europe/Luxembourg\0" - "Europe/Madrid\0" - "Europe/Malta\0" - "Europe/Mariehamn\0" - "Europe/Minsk\0" - "Europe/Monaco\0" - "Europe/Moscow\0" - "Europe/Nicosia\0" - "Europe/Oslo\0" - "Europe/Paris\0" - "Europe/Podgorica\0" - "Europe/Prague\0" - "Europe/Riga\0" - "Europe/Rome\0" - "Europe/Samara\0" - "Europe/San_Marino\0" - "Europe/Sarajevo\0" - "Europe/Saratov\0" - "Europe/Simferopol\0" - "Europe/Skopje\0" - "Europe/Sofia\0" - "Europe/Stockholm\0" - "Europe/Tallinn\0" - "Europe/Tirane\0" - "Europe/Tiraspol\0" - "Europe/Ulyanovsk\0" - "Europe/Uzhgorod\0" - "Europe/Vaduz\0" - "Europe/Vatican\0" - "Europe/Vienna\0" - "Europe/Vilnius\0" - "Europe/Volgograd\0" - "Europe/Warsaw\0" - "Europe/Zagreb\0" - "Europe/Zaporozhye\0" - "Europe/Zurich\0" - "GB\0" - "GB-Eire\0" - "GMT\0" - "GMT+0\0" - "GMT-0\0" - "GMT0\0" - "Greenwich\0" - "HST\0" - "Hongkong\0" - "Iceland\0" - "Indian/Antananarivo\0" - "Indian/Chagos\0" - "Indian/Christmas\0" - "Indian/Cocos\0" - "Indian/Comoro\0" - "Indian/Kerguelen\0" - "Indian/Mahe\0" - "Indian/Maldives\0" - "Indian/Mauritius\0" - "Indian/Mayotte\0" - "Indian/Reunion\0" - "Iran\0" - "Israel\0" - "Jamaica\0" - "Japan\0" - "Kwajalein\0" - "Libya\0" - "MET\0" - "MST\0" - "MST7MDT\0" - "Mexico/BajaNorte\0" - "Mexico/BajaSur\0" - "Mexico/General\0" - "NZ\0" - "NZ-CHAT\0" - "Navajo\0" - "PRC\0" - "PST8PDT\0" - "Pacific/Apia\0" - "Pacific/Auckland\0" - "Pacific/Bougainville\0" - "Pacific/Chatham\0" - "Pacific/Chuuk\0" - "Pacific/Easter\0" - "Pacific/Efate\0" - "Pacific/Enderbury\0" - "Pacific/Fakaofo\0" - "Pacific/Fiji\0" - "Pacific/Funafuti\0" - "Pacific/Galapagos\0" - "Pacific/Gambier\0" - "Pacific/Guadalcanal\0" - "Pacific/Guam\0" - "Pacific/Honolulu\0" - "Pacific/Johnston\0" - "Pacific/Kiritimati\0" - "Pacific/Kosrae\0" - "Pacific/Kwajalein\0" - "Pacific/Majuro\0" - "Pacific/Marquesas\0" - "Pacific/Midway\0" - "Pacific/Nauru\0" - "Pacific/Niue\0" - "Pacific/Norfolk\0" - "Pacific/Noumea\0" - "Pacific/Pago_Pago\0" - "Pacific/Palau\0" - "Pacific/Pitcairn\0" - "Pacific/Pohnpei\0" - "Pacific/Ponape\0" - "Pacific/Port_Moresby\0" - "Pacific/Rarotonga\0" - "Pacific/Saipan\0" - "Pacific/Samoa\0" - "Pacific/Tahiti\0" - "Pacific/Tarawa\0" - "Pacific/Tongatapu\0" - "Pacific/Truk\0" - "Pacific/Wake\0" - "Pacific/Wallis\0" - "Pacific/Yap\0" - "Poland\0" - "Portugal\0" - "ROC\0" - "ROK\0" - "Singapore\0" - "Turkey\0" - "UCT\0" - "US/Alaska\0" - "US/Aleutian\0" - "US/Arizona\0" - "US/Central\0" - "US/East-Indiana\0" - "US/Eastern\0" - "US/Hawaii\0" - "US/Indiana-Starke\0" - "US/Michigan\0" - "US/Mountain\0" - "US/Pacific\0" - "US/Pacific-New\0" - "US/Samoa\0" - "UTC\0" - "Universal\0" - "W-SU\0" - "WET\0" - "Zulu\0" -; -static const struct lc_timezone timezones[] = { - {eras_Africa_Abidjan, 2}, - {eras_Africa_Accra, 2}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Algiers, 10}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Bissau, 3}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Cairo, 2}, - {eras_Africa_Casablanca, 4}, - {eras_Africa_Ceuta, 8}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Lagos, 2}, - {eras_Africa_El_Aaiun, 3}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Johannesburg, 3}, - {eras_Africa_Khartoum, 3}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Khartoum, 3}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Maputo, 2}, - {eras_Africa_Johannesburg, 3}, - {eras_Africa_Johannesburg, 3}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Monrovia, 4}, - {eras_Africa_Nairobi, 5}, - {eras_Africa_Ndjamena, 4}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Lagos, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Africa_Tripoli, 9}, - {eras_Africa_Tunis, 3}, - {eras_Africa_Windhoek, 7}, - {eras_America_Adak, 9}, - {eras_America_Anchorage, 8}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Araguaina, 7}, - {eras_America_Argentina_Buenos_Aires, 7}, - {eras_America_Argentina_Catamarca, 12}, - {eras_America_Argentina_Catamarca, 12}, - {eras_America_Argentina_Cordoba, 9}, - {eras_America_Argentina_Jujuy, 13}, - {eras_America_Argentina_La_Rioja, 12}, - {eras_America_Argentina_Mendoza, 16}, - {eras_America_Argentina_Rio_Gallegos, 10}, - {eras_America_Argentina_Salta, 10}, - {eras_America_Argentina_San_Juan, 12}, - {eras_America_Argentina_San_Luis, 16}, - {eras_America_Argentina_Tucuman, 11}, - {eras_America_Argentina_Ushuaia, 10}, - {eras_America_Curacao, 3}, - {eras_America_Asuncion, 5}, - {eras_America_Atikokan, 5}, - {eras_America_Adak, 9}, - {eras_America_Bahia, 5}, - {eras_America_Bahia_Banderas, 11}, - {eras_America_Barbados, 3}, - {eras_America_Belem, 3}, - {eras_America_Belize, 2}, - {eras_America_Blanc_Sablon, 3}, - {eras_America_Boa_Vista, 5}, - {eras_America_Bogota, 3}, - {eras_America_Boise, 5}, - {eras_America_Argentina_Buenos_Aires, 7}, - {eras_America_Cambridge_Bay, 6}, - {eras_America_Campo_Grande, 2}, - {eras_America_Cancun, 5}, - {eras_America_Caracas, 6}, - {eras_America_Argentina_Catamarca, 12}, - {eras_America_Cayenne, 3}, - {eras_America_Panama, 3}, - {eras_America_Chicago, 8}, - {eras_America_Chihuahua, 10}, - {eras_America_Atikokan, 5}, - {eras_America_Argentina_Cordoba, 9}, - {eras_America_Costa_Rica, 3}, - {eras_America_Creston, 4}, - {eras_America_Cuiaba, 4}, - {eras_America_Curacao, 3}, - {eras_America_Danmarkshavn, 4}, - {eras_America_Dawson, 4}, - {eras_America_Dawson_Creek, 4}, - {eras_America_Denver, 6}, - {eras_America_Detroit, 8}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Edmonton, 3}, - {eras_America_Eirunepe, 7}, - {eras_America_El_Salvador, 2}, - {eras_America_Tijuana, 19}, - {eras_America_Fort_Nelson, 6}, - {eras_America_Indiana_Indianapolis, 11}, - {eras_America_Fortaleza, 7}, - {eras_America_Glace_Bay, 6}, - {eras_America_Godthab, 3}, - {eras_America_Goose_Bay, 10}, - {eras_America_Grand_Turk, 5}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Guatemala, 2}, - {eras_America_Guayaquil, 3}, - {eras_America_Guyana, 4}, - {eras_America_Halifax, 7}, - {eras_America_Havana, 3}, - {eras_America_Hermosillo, 11}, - {eras_America_Indiana_Indianapolis, 11}, - {eras_America_Indiana_Knox, 7}, - {eras_America_Indiana_Marengo, 9}, - {eras_America_Indiana_Petersburg, 8}, - {eras_America_Indiana_Tell_City, 7}, - {eras_America_Indiana_Vevay, 6}, - {eras_America_Indiana_Vincennes, 8}, - {eras_America_Indiana_Winamac, 8}, - {eras_America_Indiana_Indianapolis, 11}, - {eras_America_Inuvik, 4}, - {eras_America_Iqaluit, 4}, - {eras_America_Jamaica, 5}, - {eras_America_Argentina_Jujuy, 13}, - {eras_America_Juneau, 10}, - {eras_America_Kentucky_Louisville, 9}, - {eras_America_Kentucky_Monticello, 5}, - {eras_America_Indiana_Knox, 7}, - {eras_America_Curacao, 3}, - {eras_America_La_Paz, 4}, - {eras_America_Lima, 3}, - {eras_America_Los_Angeles, 4}, - {eras_America_Kentucky_Louisville, 9}, - {eras_America_Curacao, 3}, - {eras_America_Maceio, 9}, - {eras_America_Managua, 9}, - {eras_America_Manaus, 5}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Martinique, 5}, - {eras_America_Matamoros, 5}, - {eras_America_Mazatlan, 10}, - {eras_America_Argentina_Mendoza, 16}, - {eras_America_Menominee, 5}, - {eras_America_Merida, 4}, - {eras_America_Metlakatla, 8}, - {eras_America_Mexico_City, 9}, - {eras_America_Miquelon, 4}, - {eras_America_Moncton, 9}, - {eras_America_Monterrey, 4}, - {eras_America_Montevideo, 8}, - {eras_America_Toronto, 6}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Nassau, 3}, - {eras_America_New_York, 6}, - {eras_America_Nipigon, 4}, - {eras_America_Nome, 9}, - {eras_America_Noronha, 7}, - {eras_America_North_Dakota_Beulah, 3}, - {eras_America_North_Dakota_Center, 3}, - {eras_America_North_Dakota_New_Salem, 3}, - {eras_America_Ojinaga, 11}, - {eras_America_Panama, 3}, - {eras_America_Pangnirtung, 5}, - {eras_America_Paramaribo, 5}, - {eras_America_Phoenix, 7}, - {eras_America_Port_au_Prince, 3}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Rio_Branco, 5}, - {eras_America_Porto_Velho, 3}, - {eras_America_Puerto_Rico, 4}, - {eras_America_Punta_Arenas, 13}, - {eras_America_Rainy_River, 4}, - {eras_America_Rankin_Inlet, 4}, - {eras_America_Recife, 7}, - {eras_America_Regina, 3}, - {eras_America_Resolute, 6}, - {eras_America_Rio_Branco, 5}, - {eras_America_Argentina_Cordoba, 9}, - {eras_America_Tijuana, 19}, - {eras_America_Santarem, 4}, - {eras_America_Santiago, 14}, - {eras_America_Santo_Domingo, 6}, - {eras_America_Sao_Paulo, 4}, - {eras_America_Scoresbysund, 4}, - {eras_America_Denver, 6}, - {eras_America_Sitka, 8}, - {eras_America_Port_of_Spain, 2}, - {eras_America_St_Johns, 8}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Swift_Current, 5}, - {eras_America_Tegucigalpa, 2}, - {eras_America_Thule, 2}, - {eras_America_Thunder_Bay, 7}, - {eras_America_Tijuana, 19}, - {eras_America_Toronto, 6}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Vancouver, 3}, - {eras_America_Port_of_Spain, 2}, - {eras_America_Whitehorse, 4}, - {eras_America_Winnipeg, 3}, - {eras_America_Yakutat, 7}, - {eras_America_Yellowknife, 3}, - {eras_Antarctica_Casey, 7}, - {eras_Antarctica_Davis, 8}, - {eras_Antarctica_DumontDUrville, 4}, - {eras_Antarctica_Macquarie, 8}, - {eras_Antarctica_Mawson, 3}, - {eras_Pacific_Auckland, 3}, - {eras_Antarctica_Palmer, 5}, - {eras_Antarctica_Rothera, 2}, - {eras_Pacific_Auckland, 3}, - {eras_Antarctica_Syowa, 2}, - {eras_Antarctica_Troll, 2}, - {eras_Antarctica_Vostok, 2}, - {eras_Europe_Oslo, 5}, - {eras_Asia_Riyadh, 2}, - {eras_Asia_Almaty, 6}, - {eras_Asia_Amman, 2}, - {eras_Asia_Anadyr, 8}, - {eras_Asia_Aqtau, 9}, - {eras_Asia_Aqtobe, 9}, - {eras_Asia_Ashgabat, 5}, - {eras_Asia_Ashgabat, 5}, - {eras_Asia_Atyrau, 9}, - {eras_Asia_Baghdad, 4}, - {eras_Asia_Qatar, 3}, - {eras_Asia_Baku, 7}, - {eras_Asia_Bangkok, 3}, - {eras_Asia_Barnaul, 9}, - {eras_Asia_Beirut, 2}, - {eras_Asia_Bishkek, 6}, - {eras_Asia_Brunei, 3}, - {eras_Asia_Kolkata, 6}, - {eras_Asia_Chita, 8}, - {eras_Asia_Choibalsan, 5}, - {eras_Asia_Shanghai, 3}, - {eras_Asia_Shanghai, 3}, - {eras_Asia_Colombo, 9}, - {eras_Asia_Dhaka, 7}, - {eras_Asia_Damascus, 2}, - {eras_Asia_Dhaka, 7}, - {eras_Asia_Dili, 5}, - {eras_Asia_Dubai, 2}, - {eras_Asia_Dushanbe, 5}, - {eras_Asia_Famagusta, 4}, - {eras_Asia_Gaza, 12}, - {eras_Asia_Shanghai, 3}, - {eras_Asia_Hebron, 6}, - {eras_Asia_Ho_Chi_Minh, 10}, - {eras_Asia_Hong_Kong, 4}, - {eras_Asia_Hovd, 3}, - {eras_Asia_Irkutsk, 8}, - {eras_Europe_Istanbul, 13}, - {eras_Asia_Jakarta, 9}, - {eras_Asia_Jayapura, 4}, - {eras_Asia_Jerusalem, 3}, - {eras_Asia_Kabul, 3}, - {eras_Asia_Kamchatka, 7}, - {eras_Asia_Karachi, 6}, - {eras_Asia_Urumqi, 2}, - {eras_Asia_Kathmandu, 3}, - {eras_Asia_Kathmandu, 3}, - {eras_Asia_Khandyga, 9}, - {eras_Asia_Kolkata, 6}, - {eras_Asia_Krasnoyarsk, 7}, - {eras_Asia_Kuala_Lumpur, 9}, - {eras_Asia_Kuching, 5}, - {eras_Asia_Riyadh, 2}, - {eras_Asia_Macau, 2}, - {eras_Asia_Macau, 2}, - {eras_Asia_Magadan, 8}, - {eras_Asia_Makassar, 5}, - {eras_Asia_Manila, 5}, - {eras_Asia_Dubai, 2}, - {eras_Asia_Nicosia, 3}, - {eras_Asia_Novokuznetsk, 7}, - {eras_Asia_Novosibirsk, 9}, - {eras_Asia_Omsk, 7}, - {eras_Asia_Oral, 10}, - {eras_Asia_Bangkok, 3}, - {eras_Asia_Pontianak, 9}, - {eras_Asia_Pyongyang, 5}, - {eras_Asia_Qatar, 3}, - {eras_Asia_Qyzylorda, 11}, - {eras_Asia_Yangon, 5}, - {eras_Asia_Riyadh, 2}, - {eras_Asia_Ho_Chi_Minh, 10}, - {eras_Asia_Sakhalin, 9}, - {eras_Asia_Samarkand, 7}, - {eras_Asia_Seoul, 6}, - {eras_Asia_Shanghai, 3}, - {eras_Asia_Singapore, 9}, - {eras_Asia_Srednekolymsk, 7}, - {eras_Asia_Taipei, 4}, - {eras_Asia_Tashkent, 5}, - {eras_Asia_Tbilisi, 11}, - {eras_Asia_Tehran, 5}, - {eras_Asia_Jerusalem, 3}, - {eras_Asia_Thimphu, 3}, - {eras_Asia_Thimphu, 3}, - {eras_Asia_Tokyo, 2}, - {eras_Asia_Tomsk, 9}, - {eras_Asia_Makassar, 5}, - {eras_Asia_Ulaanbaatar, 3}, - {eras_Asia_Ulaanbaatar, 3}, - {eras_Asia_Urumqi, 2}, - {eras_Asia_Ust_Nera, 9}, - {eras_Asia_Bangkok, 3}, - {eras_Asia_Vladivostok, 7}, - {eras_Asia_Yakutsk, 7}, - {eras_Asia_Yangon, 5}, - {eras_Asia_Yekaterinburg, 8}, - {eras_Asia_Yerevan, 6}, - {eras_Atlantic_Azores, 15}, - {eras_Atlantic_Bermuda, 4}, - {eras_Atlantic_Canary, 5}, - {eras_Atlantic_Cape_Verde, 5}, - {eras_Atlantic_Faroe, 3}, - {eras_Atlantic_Faroe, 3}, - {eras_Europe_Oslo, 5}, - {eras_Atlantic_Madeira, 13}, - {eras_Atlantic_Reykjavik, 3}, - {eras_Atlantic_South_Georgia, 2}, - {eras_Africa_Abidjan, 2}, - {eras_Atlantic_Stanley, 6}, - {eras_Australia_Sydney, 3}, - {eras_Australia_Adelaide, 4}, - {eras_Australia_Brisbane, 3}, - {eras_Australia_Broken_Hill, 6}, - {eras_Australia_Sydney, 3}, - {eras_Australia_Currie, 5}, - {eras_Australia_Darwin, 3}, - {eras_Australia_Eucla, 3}, - {eras_Australia_Hobart, 5}, - {eras_Australia_Lord_Howe, 4}, - {eras_Australia_Lindeman, 4}, - {eras_Australia_Lord_Howe, 4}, - {eras_Australia_Melbourne, 3}, - {eras_Australia_Sydney, 3}, - {eras_Australia_Darwin, 3}, - {eras_Australia_Perth, 3}, - {eras_Australia_Brisbane, 3}, - {eras_Australia_Adelaide, 4}, - {eras_Australia_Sydney, 3}, - {eras_Australia_Hobart, 5}, - {eras_Australia_Melbourne, 3}, - {eras_Australia_Perth, 3}, - {eras_Australia_Broken_Hill, 6}, - {eras_America_Rio_Branco, 5}, - {eras_America_Noronha, 7}, - {eras_America_Sao_Paulo, 4}, - {eras_America_Manaus, 5}, - {eras_CET, 1}, - {eras_CST6CDT, 1}, - {eras_America_Halifax, 7}, - {eras_America_Winnipeg, 3}, - {eras_America_Regina, 3}, - {eras_America_Toronto, 6}, - {eras_America_Edmonton, 3}, - {eras_America_St_Johns, 8}, - {eras_America_Vancouver, 3}, - {eras_America_Regina, 3}, - {eras_America_Whitehorse, 4}, - {eras_America_Santiago, 14}, - {eras_Pacific_Easter, 4}, - {eras_America_Havana, 3}, - {eras_EET, 1}, - {eras_EST, 1}, - {eras_EST5EDT, 1}, - {eras_Africa_Cairo, 2}, - {eras_Europe_Dublin, 13}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT1, 1}, - {eras_Etc_GMT10, 1}, - {eras_Etc_GMT11, 1}, - {eras_Etc_GMT12, 1}, - {eras_Etc_GMT2, 1}, - {eras_Etc_GMT3, 1}, - {eras_Etc_GMT4, 1}, - {eras_Etc_GMT5, 1}, - {eras_Etc_GMT6, 1}, - {eras_Etc_GMT7, 1}, - {eras_Etc_GMT8, 1}, - {eras_Etc_GMT9, 1}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT_1, 1}, - {eras_Etc_GMT_10, 1}, - {eras_Etc_GMT_11, 1}, - {eras_Etc_GMT_12, 1}, - {eras_Etc_GMT_13, 1}, - {eras_Etc_GMT_14, 1}, - {eras_Etc_GMT_2, 1}, - {eras_Etc_GMT_3, 1}, - {eras_Etc_GMT_4, 1}, - {eras_Etc_GMT_5, 1}, - {eras_Etc_GMT_6, 1}, - {eras_Etc_GMT_7, 1}, - {eras_Etc_GMT_8, 1}, - {eras_Etc_GMT_9, 1}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT, 1}, - {eras_Etc_UCT, 1}, - {eras_Etc_UTC, 1}, - {eras_Etc_UTC, 1}, - {eras_Etc_UTC, 1}, - {eras_Europe_Amsterdam, 6}, - {eras_Europe_Andorra, 4}, - {eras_Europe_Astrakhan, 9}, - {eras_Europe_Athens, 6}, - {eras_Europe_London, 5}, - {eras_Europe_Belgrade, 7}, - {eras_Europe_Berlin, 5}, - {eras_Europe_Prague, 5}, - {eras_Europe_Brussels, 9}, - {eras_Europe_Bucharest, 7}, - {eras_Europe_Budapest, 6}, - {eras_Europe_Zurich, 4}, - {eras_Europe_Chisinau, 10}, - {eras_Europe_Copenhagen, 6}, - {eras_Europe_Dublin, 13}, - {eras_Europe_Gibraltar, 4}, - {eras_Europe_London, 5}, - {eras_Europe_Helsinki, 4}, - {eras_Europe_London, 5}, - {eras_Europe_Istanbul, 13}, - {eras_Europe_London, 5}, - {eras_Europe_Kaliningrad, 7}, - {eras_Europe_Kiev, 9}, - {eras_Europe_Kirov, 8}, - {eras_Europe_Lisbon, 8}, - {eras_Europe_Belgrade, 7}, - {eras_Europe_London, 5}, - {eras_Europe_Luxembourg, 7}, - {eras_Europe_Madrid, 4}, - {eras_Europe_Malta, 4}, - {eras_Europe_Helsinki, 4}, - {eras_Europe_Minsk, 9}, - {eras_Europe_Monaco, 5}, - {eras_Europe_Moscow, 11}, - {eras_Asia_Nicosia, 3}, - {eras_Europe_Oslo, 5}, - {eras_Europe_Paris, 7}, - {eras_Europe_Belgrade, 7}, - {eras_Europe_Prague, 5}, - {eras_Europe_Riga, 15}, - {eras_Europe_Rome, 6}, - {eras_Europe_Samara, 10}, - {eras_Europe_Rome, 6}, - {eras_Europe_Belgrade, 7}, - {eras_Europe_Saratov, 9}, - {eras_Europe_Simferopol, 16}, - {eras_Europe_Belgrade, 7}, - {eras_Europe_Sofia, 10}, - {eras_Europe_Stockholm, 6}, - {eras_Europe_Tallinn, 13}, - {eras_Europe_Tirane, 4}, - {eras_Europe_Chisinau, 10}, - {eras_Europe_Ulyanovsk, 9}, - {eras_Europe_Uzhgorod, 11}, - {eras_Europe_Zurich, 4}, - {eras_Europe_Rome, 6}, - {eras_Europe_Vienna, 8}, - {eras_Europe_Vilnius, 15}, - {eras_Europe_Volgograd, 9}, - {eras_Europe_Warsaw, 9}, - {eras_Europe_Belgrade, 7}, - {eras_Europe_Zaporozhye, 8}, - {eras_Europe_Zurich, 4}, - {eras_Europe_London, 5}, - {eras_Europe_London, 5}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT, 1}, - {eras_Etc_GMT, 1}, - {eras_HST, 1}, - {eras_Asia_Hong_Kong, 4}, - {eras_Atlantic_Reykjavik, 3}, - {eras_Africa_Nairobi, 5}, - {eras_Indian_Chagos, 3}, - {eras_Indian_Christmas, 2}, - {eras_Indian_Cocos, 2}, - {eras_Africa_Nairobi, 5}, - {eras_Indian_Kerguelen, 2}, - {eras_Indian_Mahe, 2}, - {eras_Indian_Maldives, 3}, - {eras_Indian_Mauritius, 2}, - {eras_Africa_Nairobi, 5}, - {eras_Indian_Reunion, 2}, - {eras_Asia_Tehran, 5}, - {eras_Asia_Jerusalem, 3}, - {eras_America_Jamaica, 5}, - {eras_Asia_Tokyo, 2}, - {eras_Pacific_Kwajalein, 4}, - {eras_Africa_Tripoli, 9}, - {eras_MET, 1}, - {eras_MST, 1}, - {eras_MST7MDT, 1}, - {eras_America_Tijuana, 19}, - {eras_America_Mazatlan, 10}, - {eras_America_Mexico_City, 9}, - {eras_Pacific_Auckland, 3}, - {eras_Pacific_Chatham, 3}, - {eras_America_Denver, 6}, - {eras_Asia_Shanghai, 3}, - {eras_PST8PDT, 1}, - {eras_Pacific_Apia, 5}, - {eras_Pacific_Auckland, 3}, - {eras_Pacific_Bougainville, 6}, - {eras_Pacific_Chatham, 3}, - {eras_Pacific_Chuuk, 2}, - {eras_Pacific_Easter, 4}, - {eras_Pacific_Efate, 2}, - {eras_Pacific_Enderbury, 4}, - {eras_Pacific_Fakaofo, 3}, - {eras_Pacific_Fiji, 2}, - {eras_Pacific_Funafuti, 2}, - {eras_Pacific_Galapagos, 3}, - {eras_Pacific_Gambier, 2}, - {eras_Pacific_Guadalcanal, 2}, - {eras_Pacific_Guam, 4}, - {eras_Pacific_Honolulu, 7}, - {eras_Pacific_Honolulu, 7}, - {eras_Pacific_Kiritimati, 4}, - {eras_Pacific_Kosrae, 4}, - {eras_Pacific_Kwajalein, 4}, - {eras_Pacific_Majuro, 3}, - {eras_Pacific_Marquesas, 2}, - {eras_Pacific_Pago_Pago, 3}, - {eras_Pacific_Nauru, 5}, - {eras_Pacific_Niue, 4}, - {eras_Pacific_Norfolk, 6}, - {eras_Pacific_Noumea, 2}, - {eras_Pacific_Pago_Pago, 3}, - {eras_Pacific_Palau, 2}, - {eras_Pacific_Pitcairn, 3}, - {eras_Pacific_Pohnpei, 2}, - {eras_Pacific_Pohnpei, 2}, - {eras_Pacific_Port_Moresby, 3}, - {eras_Pacific_Rarotonga, 3}, - {eras_Pacific_Guam, 4}, - {eras_Pacific_Pago_Pago, 3}, - {eras_Pacific_Tahiti, 2}, - {eras_Pacific_Tarawa, 2}, - {eras_Pacific_Tongatapu, 4}, - {eras_Pacific_Chuuk, 2}, - {eras_Pacific_Wake, 2}, - {eras_Pacific_Wallis, 2}, - {eras_Pacific_Chuuk, 2}, - {eras_Europe_Warsaw, 9}, - {eras_Europe_Lisbon, 8}, - {eras_Asia_Taipei, 4}, - {eras_Asia_Seoul, 6}, - {eras_Asia_Singapore, 9}, - {eras_Europe_Istanbul, 13}, - {eras_Etc_UCT, 1}, - {eras_America_Anchorage, 8}, - {eras_America_Adak, 9}, - {eras_America_Phoenix, 7}, - {eras_America_Chicago, 8}, - {eras_America_Indiana_Indianapolis, 11}, - {eras_America_New_York, 6}, - {eras_Pacific_Honolulu, 7}, - {eras_America_Indiana_Knox, 7}, - {eras_America_Detroit, 8}, - {eras_America_Denver, 6}, - {eras_America_Los_Angeles, 4}, - {eras_America_Los_Angeles, 4}, - {eras_Pacific_Pago_Pago, 3}, - {eras_Etc_UTC, 1}, - {eras_Etc_UTC, 1}, - {eras_Europe_Moscow, 11}, - {eras_WET, 1}, - {eras_Etc_UTC, 1}, -}; diff --git a/lib/ESPiLight/pilight/libs/pilight/core/update.h b/lib/ESPiLight/pilight/libs/pilight/core/update.h deleted file mode 100644 index f594a14..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/update.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _UPDATE_H_ -#define _UPDATE_H_ - -int update_gc(void); -char *update_package_version(char *mirror); -int update_available(void); -char *update_latests_version(void); -void *update_poll(void *param); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/core/webserver.c b/lib/ESPiLight/pilight/libs/pilight/core/webserver.c deleted file mode 100644 index eb28382..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/webserver.c +++ /dev/null @@ -1,2034 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -/* - * This webserver contains various code originally written by Sergey Lyubka - * (from Cesenta) for Mongoose (https://github.com/cesanta/mongoose). - * The code was either copied, adapted and/or stripped so it could be integrated - * with the pilight eventpool and mbed TLS SSL library. - * - * The following functions are therefor licensed under GPLv2. - * - * send_websocket_handshake_if_requested - * send_websocket_handshake - * http_parse_request - * _urldecode - * parse_http_headers - * remove_double_dots_and_double_slashes - * is_valid_http_method - * *skip - * websocket_write - * authorize_input - * http_get_header - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 -#else - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include - #include - #define __USE_UNIX98 - #include - #include - #include -#endif - -#ifdef PILIGHT_REWRITE - #include "../storage/storage.h" -#else - #include "../config/devices.h" - #include "../config/settings.h" - #include "../config/registry.h" -#endif - -#include "eventpool.h" -#include "sha256cache.h" -#include "pilight.h" -#include "network.h" -#include "gc.h" -#include "log.h" -#include "json.h" -#include "webserver.h" -#include "socket.h" -#include "ssdp.h" -#include "common.h" - -#include - -#ifdef WEBSERVER_HTTPS -#include -#include -#include -#if MBEDTLS_VERSION_MAJOR <= 2 && \ - MBEDTLS_VERSION_MINOR <= 3 - #include -#else - #include -#endif -#include -#include -#include -#include -#include - -#include "ssl.h" - -static int https_port = WEBSERVER_HTTPS_PORT; -#endif - -static uv_poll_t *poll_http_req = NULL; -static uv_poll_t *poll_https_req = NULL; -static uv_async_t *async_req = NULL; - -static int http_port = WEBSERVER_HTTP_PORT; -static int websockets = WEBGUI_WEBSOCKETS; -static int cache = 1; -static char *authentication_username = NULL; -static char *authentication_password = NULL; -static unsigned short loop = 1; -static char *root = NULL; -static unsigned short root_free = 0; - -typedef struct broadcast_list_t { - char *out; - ssize_t len; - int fd; - - struct broadcast_list_t *next; -} broadcast_list_t; - -static struct broadcast_list_t *broadcast_list = NULL; - -enum mg_result { - MG_FALSE, - MG_TRUE, - MG_MORE -}; - -enum { - WEBSOCKET_OPCODE_CONTINUATION = 0x0, - WEBSOCKET_OPCODE_TEXT = 0x1, - WEBSOCKET_OPCODE_BINARY = 0x2, - WEBSOCKET_OPCODE_CONNECTION_CLOSE = 0x8, - WEBSOCKET_OPCODE_PING = 0x9, - WEBSOCKET_OPCODE_PONG = 0xa -}; - -typedef struct webserver_clients_t { - uv_poll_t *req; - int is_websocket; - - struct webserver_clients_t *next; -} webserver_clients_t; - -typedef struct fcache_t { - char *name; - unsigned long size; - unsigned char *bytes; - struct fcache_t *next; -} fcaches_t; - -static struct fcache_t *fcache; - -#ifdef _WIN32 - static uv_mutex_t webserver_lock; -#else - static pthread_mutex_t webserver_lock; - static pthread_mutexattr_t webserver_attr; -#endif -static int lock_init = 0; -static struct webserver_clients_t *webserver_clients = NULL; - -static void poll_close_cb(uv_poll_t *req); - -static void *reason_socket_received_free(void *param) { - struct reason_socket_received_t *data = param; - FREE(data->buffer); - FREE(data); - return NULL; -} - -static void *reason_webserver_connected_free(void *param) { - struct reason_webserver_connected_t *data = param; - FREE(data); - return NULL; -} - -int webserver_gc(void) { - struct webserver_clients_t *node = NULL; - - loop = 0; - - if(root_free == 1) { - FREE(root); - } - -#ifdef _WIN32 - uv_mutex_lock(&webserver_lock); -#else - pthread_mutex_lock(&webserver_lock); -#endif - { - while(webserver_clients) { - node = webserver_clients->next; - poll_close_cb(webserver_clients->req); - webserver_clients = node; - } - } - - { - struct broadcast_list_t *tmp = NULL; - while(broadcast_list) { - tmp = broadcast_list; - broadcast_list = broadcast_list->next; - FREE(tmp); - } - } -#ifdef _WIN32 - uv_mutex_unlock(&webserver_lock); -#else - pthread_mutex_unlock(&webserver_lock); -#endif - - { - struct fcache_t *tmp = fcache; - while(fcache) { - tmp = fcache; - FREE(tmp->name); - FREE(tmp->bytes); - fcache = fcache->next; - FREE(tmp); - } - } - - if(poll_http_req != NULL) { - poll_close_cb(poll_http_req); - } - if(poll_https_req != NULL) { - poll_close_cb(poll_https_req); - } - - authentication_username = NULL; - authentication_password = NULL; - - sha256cache_gc(); - logprintf(LOG_DEBUG, "garbage collected webserver library"); - return 1; -} - -void webserver_create_header(char **p, const char *message, char *mimetype, unsigned long len) { - *p += sprintf((char *)*p, - "HTTP/1.0 %s\r\n" - "Server: pilight\r\n" - "Keep-Alive: timeout=15, max=100\r\n" - "Content-Type: %s\r\n", - message, mimetype); - *p += sprintf((char *)*p, - "Content-Length: %lu\r\n\r\n", - len); -} - -static void create_404_header(const char *in, char **p) { - char mimetype[] = "text/html"; - webserver_create_header(p, "404 Not Found", mimetype, (unsigned long)(202+strlen((const char *)in))); - *p += sprintf((char *)*p, "\x0d\x0a" - "\x0d\x0a" - "404 Not Found\x0d\x0a" - "\x0d\x0a" - "

Not Found

\x0d\x0a" - "

The requested URL %s was not found on this server.

\x0d\x0a" - "", - (const char *)in); -} - -const char *http_get_header(struct connection_t *conn, const char *s) { - int i = 0; - - for(i = 0; i < conn->num_headers; i++) { - if(strcmp(s, conn->http_headers[i].name) == 0) { - return conn->http_headers[i].value; - } - } - - return NULL; -} - -void send_auth_request(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - char *a = "HTTP/1.1 401 Unauthorized\r\n" - "WWW-Authenticate: Basic realm=\"pilight\"\r\n\r\n"; - conn->status_code = 401; - - iobuf_append(&custom_poll_data->send_iobuf, a, strlen(a)); - uv_custom_write(req); -} - -int authorize_input(uv_poll_t *req, char *username, char *password) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - const char *hdr = NULL; - char **array = NULL, *decoded = NULL; - int n = 0; - - if(conn == NULL) { - return MG_FALSE; - } - - if((hdr = http_get_header(conn, "Authorization")) == NULL || - (strncmp(hdr, "Basic ", 6) != 0 && - strncmp(hdr, "basic ", 6) != 0)) { - return MG_FALSE; - } - - char *user = MALLOC(strlen(hdr)+1); - if(user == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(user, &hdr[6]); - - if((decoded = base64decode(user, strlen(user), NULL)) == NULL) { - FREE(user); - return MG_FALSE; - } - - if((n = explode(decoded, ":", &array)) == 2) { - if(strlen(array[1]) < 64) { - if((array[1] = REALLOC(array[1], 65)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - } - - if(sha256cache_get_hash(array[1]) == NULL) { - sha256cache_add(array[1]); - } - - if(strcmp(sha256cache_get_hash(array[1]), password) == 0 && strcmp(array[0], username) == 0) { - array_free(&array, n); - FREE(user); - FREE(decoded); - return MG_TRUE; - } - } - FREE(user); - FREE(decoded); - array_free(&array, n); - - return MG_FALSE; -} - -static int auth_handler(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - if(authentication_username != NULL && authentication_password != NULL) { - return authorize_input(req, authentication_username, authentication_password); - } else { - return MG_TRUE; - } -} - -size_t websocket_write(uv_poll_t *req, int opcode, const char *data, unsigned long long data_len) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - unsigned char *copy = NULL; - size_t copy_len = 0; - int index = 2; - - if((copy = REALLOC(copy, data_len + 10)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(copy, '\0', data_len + 10); - - copy[0] = 0x80 + (opcode & 0x0f); - if(data_len <= 125) { - copy[1] = data_len; - } else if(data_len < 65535) { - copy[1] = 126; - copy[2] = (data_len >> 8) & 255; - copy[3] = (data_len) & 255; - index = 4; - } else { - copy[1] = 127; - copy[2] = (data_len >> 56) & 255; - copy[3] = (data_len >> 48) & 255; - copy[4] = (data_len >> 40) & 255; - copy[5] = (data_len >> 32) & 255; - copy[6] = (data_len >> 24) & 255; - copy[7] = (data_len >> 16) & 255; - copy[8] = (data_len >> 8) & 255; - copy[9] = (data_len) & 255; - index = 10; - } - if(data != NULL) { - memcpy(©[index], data, data_len); - } - copy_len = data_len + index; - - if(copy_len > 0) { - iobuf_append(&custom_poll_data->send_iobuf, (char *)copy, copy_len); - uv_custom_write(req); - } - - FREE(copy); - return data_len; -} - -static void *webserver_send(int reason, void *param) { - struct reason_socket_send_t *data = param; - struct connection_t c; - memset(&c, 0, sizeof(struct connection_t)); - - if(strcmp(data->type, "websocket") == 0) { -#ifdef _WIN32 - uv_mutex_lock(&webserver_lock); -#else - pthread_mutex_lock(&webserver_lock); -#endif - struct broadcast_list_t *node = MALLOC(sizeof(struct broadcast_list_t)); - if(node == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, 0, sizeof(struct broadcast_list_t)); - node->fd = data->fd; - if((node->out = STRDUP(data->buffer)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->len = strlen(data->buffer); - - struct broadcast_list_t *tmp = broadcast_list; - if(tmp != NULL) { - while(tmp->next != NULL) { - tmp = tmp->next; - } - tmp->next = node; - node = tmp; - } else { - node->next = broadcast_list; - broadcast_list = node; - } - -#ifdef _WIN32 - uv_mutex_unlock(&webserver_lock); -#else - pthread_mutex_unlock(&webserver_lock); -#endif - uv_async_send(async_req); - } - - return NULL; -} - -static void write_chunk(uv_poll_t *req, char *buf, int len) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - - char chunk_size[50]; - int n = snprintf(chunk_size, sizeof(chunk_size), "%X\r\n", len); - - iobuf_append(&custom_poll_data->send_iobuf, chunk_size, n); - iobuf_append(&custom_poll_data->send_iobuf, buf, len); - iobuf_append(&custom_poll_data->send_iobuf, "\r\n", 2); -} - -static size_t send_data(uv_poll_t *req, char *mimetype, void *data, unsigned long data_len) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - char header[1024], *p = header; - memset(header, '\0', 1024); - - webserver_create_header(&p, "200 OK", mimetype, data_len); - iobuf_append(&custom_poll_data->send_iobuf, header, (int)(p-header)); - iobuf_append(&custom_poll_data->send_iobuf, data, (int)data_len); - - return 0; -} - -static size_t send_chunked_data(uv_poll_t *req, void *data, unsigned long data_len) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - - if(conn->flags == 0) { - char a[255], *p = a; - memset(p, '\0', 255); - int i = snprintf(p, 255, - "HTTP/1.1 200 OK\r\nKeep-Alive: timeout=15, max=100\r\n"\ - "Content-Type: %s\r\nTransfer-Encoding: chunked\r\n\r\n", - conn->mimetype - ); - - iobuf_append(&custom_poll_data->send_iobuf, p, i); - conn->flags = 1; - } - write_chunk(req, data, data_len); - - return 0; -} - -static int parse_rest(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - - char **array = NULL, **array1 = NULL; - struct JsonNode *jobject = json_mkobject(); - struct JsonNode *jcode = json_mkobject(); - struct JsonNode *jvalues = json_mkobject(); - int a = 0, b = 0, c = 0, has_protocol = 0; - - if(strcmp(conn->request_method, "POST") == 0) { - conn->query_string = conn->content; - } - if(strcmp(conn->request_method, "GET") == 0 && conn->query_string == NULL) { - conn->query_string = conn->content; - } - if(conn->query_string != NULL) { -#ifdef PILIGHT_REWRITE - char *dev = NULL; -#else - struct devices_t *dev = NULL; -#endif - int len = urldecode(conn->query_string, NULL); - if(len == -1) { - char *z = "{\"message\":\"failed\",\"error\":\"cannot decode url\"}"; - send_data(req, "application/json", z, strlen(z)); - return MG_TRUE; - } - - char *decoded = MALLOC(len+1); - if(decoded == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - if(urldecode(conn->query_string, decoded) == -1) { - char *z = "{\"message\":\"failed\",\"error\":\"cannot decode url\"}"; - send_data(req, "application/json", z, strlen(z)); - FREE(decoded); - return MG_TRUE; - } - - char state[16], *p = NULL; - a = explode((char *)decoded, "&", &array), b = 0, c = 0; - memset(state, 0, 16); - - if(a > 1) { - int type = 0; //0 = SEND, 1 = CONTROL, 2 = REGISTRY - json_append_member(jobject, "code", jcode); - - if(strcmp(conn->uri, "/send") == 0) { - type = 0; - json_append_member(jobject, "action", json_mkstring("send")); - } else if(strcmp(conn->uri, "/control") == 0) { - type = 1; - json_append_member(jobject, "action", json_mkstring("control")); - } else if(strcmp(conn->uri, "/registry") == 0) { - type = 2; - json_append_member(jobject, "action", json_mkstring("registry")); - } - - for(b=0;b 0) { - p = state; - } - if(pilight.control(dev, p, json_first_child(jvalues), ORIGIN_WEBSERVER) == 0) { - char *z = "{\"message\":\"success\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } - } - } - } else if(type == 2) { - struct JsonNode *value = NULL; - char *type = NULL; - char *key = NULL; - char *sval = NULL; - double nval = 0.0; - int dec = 0; - if(json_find_string(jcode, "type", &type) != 0) { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } else { - if(strcmp(type, "set") == 0) { - if(json_find_string(jcode, "key", &key) != 0) { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } else if((value = json_find_member(jcode, "value")) == NULL) { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } else { - if(value->tag == JSON_NUMBER) { - if(registry_set_number(key, value->number_, value->decimals_) == 0) { - char *z = "{\"message\":\"success\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } - } else if(value->tag == JSON_STRING) { - if(registry_set_string(key, value->string_) == 0) { - char *z = "{\"message\":\"success\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } - } else { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } - } - } else if(strcmp(type, "remove") == 0) { - if(json_find_string(jcode, "key", &key) != 0) { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } else { - if(registry_remove_value(key) == 0) { - char *z = "{\"message\":\"success\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } else { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } - } - } else if(strcmp(type, "get") == 0) { - if(json_find_string(jcode, "key", &key) != 0) { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } else { - if(registry_get_number(key, &nval, &dec) == 0) { - struct JsonNode *jsend = json_mkobject(); - json_append_member(jsend, "message", json_mkstring("registry")); - json_append_member(jsend, "value", json_mknumber(nval, dec)); - json_append_member(jsend, "key", json_mkstring(key)); - char *output = json_stringify(jsend, NULL); - send_data(req, "application/json", output, strlen(output)); - json_free(output); - json_delete(jsend); - goto clear; - } else if(registry_get_string(key, &sval) == 0) { - struct JsonNode *jsend = json_mkobject(); - json_append_member(jsend, "message", json_mkstring("registry")); - json_append_member(jsend, "value", json_mkstring(sval)); - json_append_member(jsend, "key", json_mkstring(key)); - char *output = json_stringify(jsend, NULL); - send_data(req, "application/json", output, strlen(output)); - json_free(output); - json_delete(jsend); - goto clear; - } else { - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - goto clear; - } - } - } - } - } - json_delete(jvalues); - json_delete(jobject); - } - FREE(decoded); - array_free(&array, a); - } - char *z = "{\"message\":\"failed\"}"; - send_data(req, "application/json", z, strlen(z)); - return MG_TRUE; - -clear: - array_free(&array1, c); - array_free(&array, a); - json_delete(jvalues); - json_delete(jobject); - - return MG_TRUE; -} - -static void close_cb(uv_handle_t *handle) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - FREE(handle); -} - -static int file_read_cb(int fd, uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - struct timeval timeout; - fd_set readset; - char buffer[WEBSERVER_CHUNK_SIZE]; - - memset(&buffer, '\0', WEBSERVER_CHUNK_SIZE); - memset(&readset, 0, sizeof(fd_set)); - - FD_SET(fd, &readset); - - timeout.tv_sec = 0; - timeout.tv_usec = 1000; - - int ret = select(fd+1, &readset, NULL, NULL, &timeout); - if(ret >= 0 && errno == EINTR) { - conn->fd = -1; - close(fd); - return -1; - } else if((ret == -1 && errno == EINTR) || ret == 0) { - return 0; - } - - int bytes = read(fd, buffer, WEBSERVER_CHUNK_SIZE); - - if(bytes > 0) { - send_chunked_data(req, &buffer, bytes); - if(bytes < WEBSERVER_CHUNK_SIZE) { - iobuf_append(&custom_poll_data->send_iobuf, "0\r\n\r\n", 5); - uv_custom_close(req); - } - uv_custom_write(req); - - return 0; - } else if(bytes == 0) { - if(conn->flags == 1) { - iobuf_append(&custom_poll_data->send_iobuf, "0\r\n\r\n", 5); - uv_custom_close(req); - } - return 0; - } else if(bytes < 0) { - logprintf(LOG_ERR, "read: %s", strerror(errno)); - conn->fd = -1; - close(fd); - return -1; - } - return 0; -} - -static int request_handler(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - - char *ext = NULL; - char buffer[4096], *p = buffer; - - memset(buffer, '\0', 4096); - - if(conn->is_websocket == 0) { - if(conn->uri != NULL && strlen(conn->uri) > 0) { - if(strcmp(conn->uri, "/send") == 0 || strcmp(conn->uri, "/control") == 0 || strcmp(conn->uri, "/registry") == 0) { - return parse_rest(req); - } else if(strcmp(conn->uri, "/config") == 0) { - char media[15]; - int internal = CONFIG_USER; - strcpy(media, "web"); - if(conn->query_string != NULL) { - sscanf(conn->query_string, "media=%14s%*[ \n\r]", media); - if(strstr(conn->query_string, "internal") != NULL) { - internal = CONFIG_INTERNAL; - } - } - struct JsonNode *jsend = config_print(internal, media); - if(jsend != NULL) { - char *output = json_stringify(jsend, NULL); - send_data(req, "application/json", output, strlen(output)); - json_delete(jsend); - json_free(output); - } - jsend = NULL; - return MG_TRUE; - } else if(strcmp(conn->uri, "/values") == 0) { - char media[15]; - strcpy(media, "web"); - if(conn->query_string != NULL) { - sscanf(conn->query_string, "media=%14s%*[ \n\r]", media); - } -#ifdef PILIGHT_REWRITE - struct JsonNode *jsend = values_print(media); -#else - JsonNode *jsend = devices_values(media); -#endif - if(jsend != NULL) { - char *output = json_stringify(jsend, NULL); - send_data(req, "application/json", output, strlen(output)); - json_delete(jsend); - json_free(output); - } - jsend = NULL; - return MG_TRUE; - } else if(strstr(conn->uri, "/") != NULL && strcmp(&conn->uri[(rstrstr(conn->uri, "/")-conn->uri)], "/") == 0) { - char indexes[2][11] = {"index.html","index.htm"}; - - unsigned q = 0; - /* Check if the root is terminated by a slash. If not, then add it */ - for(q=0;q<(sizeof(indexes)/sizeof(indexes[0]));q++) { - size_t l = strlen(root)+strlen(conn->uri)+strlen(indexes[q])+4; - if((conn->request = REALLOC(conn->request, l)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(conn->request, '\0', l); - if(root[strlen(root)-1] == '/') { -#ifdef __FreeBSD__ - sprintf(conn->request, "%s/%s%s", root, conn->uri, indexes[q]); -#else - sprintf(conn->request, "%s%s%s", root, conn->uri, indexes[q]); -#endif - } else { - sprintf(conn->request, "%s/%s%s", root, conn->uri, indexes[q]); - } - if(access(conn->request, F_OK) == 0) { - break; - } - } - } else if(root != NULL && conn->uri != NULL) { - size_t wlen = strlen(root)+strlen(conn->uri)+2; - if((conn->request = MALLOC(wlen)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(conn->request, '\0', wlen); - /* If a file was requested add it to the webserver path to create the absolute path */ - if(root[strlen(root)-1] == '/') { - if(conn->uri[0] == '/') - sprintf(conn->request, "%s%s", root, conn->uri); - else - sprintf(conn->request, "%s/%s", root, conn->uri); - } else { - if(conn->uri[0] == '/') - sprintf(conn->request, "%s/%s", root, conn->uri); - else - sprintf(conn->request, "%s/%s", root, conn->uri); - } - } - if(conn->request == NULL) { - return MG_FALSE; - } - - char *dot = NULL; - /* Retrieve the extension of the requested file and create a mimetype accordingly */ - dot = strrchr(conn->request, '.'); - if(dot == NULL || dot == conn->request) { - strcpy(conn->mimetype, "text/plain"); - } else { - if((ext = REALLOC(ext, strlen(dot)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(ext, '\0', strlen(dot)+1); - strcpy(ext, dot+1); - - if(strcmp(ext, "html") == 0) { - strcpy(conn->mimetype, "text/html"); - } else if(strcmp(ext, "xml") == 0) { - strcpy(conn->mimetype, "text/xml"); - } else if(strcmp(ext, "png") == 0) { - strcpy(conn->mimetype, "image/png"); - } else if(strcmp(ext, "gif") == 0) { - strcpy(conn->mimetype, "image/gif"); - } else if(strcmp(ext, "ico") == 0) { - strcpy(conn->mimetype, "image/x-icon"); - } else if(strcmp(ext, "jpg") == 0) { - strcpy(conn->mimetype, "image/jpg"); - } else if(strcmp(ext, "css") == 0) { - strcpy(conn->mimetype, "text/css"); - } else if(strcmp(ext, "js") == 0) { - strcpy(conn->mimetype, "text/javascript"); - } else if(strcmp(ext, "php") == 0) { - strcpy(conn->mimetype, "application/x-httpd-php"); - } else { - strcpy(conn->mimetype, "text/plain"); - } - } - FREE(ext); - - memset(buffer, '\0', 4096); - p = buffer; - - if(access(conn->request, F_OK) != 0) { - goto filenotfound; - } - - const char *cl = NULL; - if((cl = http_get_header(conn, "Content-Length"))) { - if(atoi(cl) > MAX_UPLOAD_FILESIZE) { - char line[1024] = {'\0'}; - sprintf(line, "Webserver Warning: POST Content-Length of %d bytes exceeds the limit of %d bytes in Unknown on line 0", MAX_UPLOAD_FILESIZE, atoi(cl)); - webserver_create_header(&p, "200 OK", "text/plain", strlen(line)); - iobuf_append(&custom_poll_data->send_iobuf, buffer, (int)(p-buffer)); - iobuf_append(&custom_poll_data->send_iobuf, line, (int)strlen(line)); - - FREE(conn->request); - conn->request = NULL; - return MG_TRUE; - } - } - - int match = 0; - if(cache == 1) { - struct fcache_t *tmp = fcache; - while(tmp) { - if(strcmp(tmp->name, conn->request) == 0) { - match = 1; - break; - } - tmp = tmp->next; - } - if(match == 1) { - send_chunked_data(req, tmp->bytes, tmp->size); - iobuf_append(&custom_poll_data->send_iobuf, "0\r\n\r\n", 5); - return MG_TRUE; - } - } - if(match == 0) { - if((conn->file_fd = open(conn->request, O_RDONLY)) < 0) { - logprintf(LOG_ERR, "open: %s", strerror(errno)); - goto filenotfound; - } -#ifdef _WIN32 - unsigned long on = 1; - ioctlsocket(conn->file_fd, FIONBIO, &on); -#else - long arg = fcntl(conn->file_fd, F_GETFL, NULL); - fcntl(conn->file_fd, F_SETFL, arg | O_NONBLOCK); -#endif - - if(file_read_cb(conn->file_fd, req) == 0) { - return MG_MORE; - } else { - return MG_TRUE; - } - } - - return MG_MORE; - } - } else if(websockets == WEBGUI_WEBSOCKETS) { - char *input = MALLOC(conn->content_len+1); - if(input == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(input, '\0', conn->content_len+1); - - strncpy(input, conn->content, conn->content_len); - input[conn->content_len] = '\0'; - - if(json_validate(input) == true) { - struct reason_socket_received_t *data = MALLOC(sizeof(struct reason_socket_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - data->fd = conn->fd; - if((data->buffer = MALLOC(strlen(input)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(data->buffer, input); - strcpy(data->type, "websocket"); - - eventpool_trigger(REASON_SOCKET_RECEIVED, reason_socket_received_free, data); - } - FREE(input); - return MG_TRUE; - } - -filenotfound: - logprintf(LOG_WARNING, "(webserver) could not read %s", conn->request); - create_404_header(conn->uri, &p); - FREE(conn->request); - - iobuf_append(&custom_poll_data->send_iobuf, buffer, (int)(p-buffer)); - - return MG_TRUE; -} - -static void webserver_process(uv_async_t *handle) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - -#ifdef _WIN32 - uv_mutex_lock(&webserver_lock); -#else - pthread_mutex_lock(&webserver_lock); -#endif - - struct webserver_clients_t *clients = webserver_clients; - struct broadcast_list_t *tmp = NULL; - while(broadcast_list) { - tmp = broadcast_list; - - while(clients) { - if(tmp->fd > 0) { - int fd = 0, r = 0; - - if((r = uv_fileno((uv_handle_t *)clients->req, (uv_os_fd_t *)&fd)) != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); - continue; - /*LCOV_EXCL_STOP*/ - } - - if(fd == tmp->fd) { - websocket_write(clients->req, WEBSOCKET_OPCODE_TEXT, tmp->out, tmp->len); - } - } else if(clients->is_websocket == 1) { - websocket_write(clients->req, 1, tmp->out, tmp->len); - } - clients = clients->next; - } - if(tmp->len > 0) { - FREE(tmp->out); - } - broadcast_list = broadcast_list->next; - FREE(tmp); - } - if(broadcast_list != NULL) { - uv_async_send(async_req); - } -#ifdef _WIN32 - uv_mutex_unlock(&webserver_lock); -#else - pthread_mutex_unlock(&webserver_lock); -#endif -} - -static void *broadcast(int reason, void *param) { - if(loop == 0) { - return NULL; - } - -#ifdef _WIN32 - uv_mutex_lock(&webserver_lock); -#else - pthread_mutex_lock(&webserver_lock); -#endif - struct broadcast_list_t *node = MALLOC(sizeof(struct broadcast_list_t)); - if(node == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, 0, sizeof(struct broadcast_list_t)); - if((node->out = MALLOC(1024)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - int i = 0; - switch(reason) { - case REASON_CONFIG_UPDATE: { - struct reason_config_update_t *data = param; - node->len += snprintf(node->out, 1024, - "{\"origin\":\"update\",\"type\":%d,\"devices\":[", - data->type - ); - for(i=0;inrdev;i++) { - node->len += snprintf(&node->out[node->len], 1024-node->len, "\"%s\",", data->devices[i]); - } - node->len += snprintf(&node->out[node->len-1], 1024-node->len, "],\"values\":{"); - node->len -= 1; - for(i=0;inrval;i++) { - if(data->values[i].type == JSON_NUMBER) { - node->len += snprintf(&node->out[node->len], 1024-node->len, - "\"%s\":%.*f,", - data->values[i].name, data->values[i].decimals, data->values[i].number_ - ); - } else if(data->values[i].type == JSON_STRING) { - node->len += snprintf(&node->out[node->len], 1024-node->len, - "\"%s\":\"%s\",", - data->values[i].name, data->values[i].string_ - ); - } - } - node->len += snprintf(&node->out[node->len-1], 1024-node->len, "}}"); - node->len -= 1; - } break; - case REASON_BROADCAST_CORE: - strncpy(node->out, (char *)param, 1024); - node->len = strlen(node->out); - break; - default: - FREE(node); - return NULL; - } - - struct broadcast_list_t *tmp = broadcast_list; - if(tmp != NULL) { - while(tmp->next != NULL) { - tmp = tmp->next; - } - tmp->next = node; - node = tmp; - } else { - node->next = broadcast_list; - broadcast_list = node; - } - -#ifdef _WIN32 - uv_mutex_unlock(&webserver_lock); -#else - pthread_mutex_unlock(&webserver_lock); -#endif - uv_async_send(async_req); - - return NULL; -} - -static char *skip(char **buf, const char *delimiters) { - char *p, *begin_word, *end_word, *end_delimiters; - - begin_word = *buf; - end_word = begin_word + strcspn(begin_word, delimiters); - end_delimiters = end_word + strspn(end_word, delimiters); - - for(p = end_word; p < end_delimiters; p++) { - *p = '\0'; - } - - *buf = end_delimiters; - - return begin_word; -} - -static int is_valid_http_method(const char *s) { - return !strcmp(s, "GET") || !strcmp(s, "POST") || !strcmp(s, "HEAD") || - !strcmp(s, "CONNECT") || !strcmp(s, "PUT") || !strcmp(s, "DELETE") || - !strcmp(s, "OPTIONS") || !strcmp(s, "PROPFIND") || !strcmp(s, "MKCOL"); -} - -static void remove_double_dots_and_double_slashes(char *s) { - char *p = s; - - while(*s != '\0') { - *p++ = *s++; - if(s[-1] == '/' || s[-1] == '\\') { - // Skip all following slashes, backslashes and double-dots - while(s[0] != '\0') { - if(s[0] == '/' || s[0] == '\\') { - s++; - } else if(s[0] == '.' && s[1] == '.') { - s += 2; - } else { - break; - } - } - } - } - *p = '\0'; -} - -static void parse_http_headers(char **buf, struct connection_t *c) { - size_t i; - c->num_headers = 0; - for(i = 0; i < 1024; i++) { - c->http_headers[i].name = skip(buf, ": "); - c->http_headers[i].value = skip(buf, "\r\n"); - if(c->http_headers[i].name[0] == '\0') - break; - c->num_headers = i + 1; - } -} - -static int _urldecode(const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded) { - int i, j, a, b; - -#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W') - - for(i = j = 0; i < src_len && j < dst_len - 1; i++, j++) { - if(src[i] == '%' && i < src_len - 2 && - isxdigit(*(const unsigned char *)(src + i + 1)) && - isxdigit(*(const unsigned char *)(src + i + 2))) { - a = tolower(*(const unsigned char *)(src + i + 1)); - b = tolower(*(const unsigned char *)(src + i + 2)); - dst[j] = (char)((HEXTOI(a) << 4) | HEXTOI(b)); - i += 2; - } else if(is_form_url_encoded && src[i] == '+') { - dst[j] = ' '; - } else { - dst[j] = src[i]; - } - } - - dst[j] = '\0'; // Null-terminate the destination - - return i >= src_len ? j : -1; -} - -int http_parse_request(char *buffer, struct connection_t *c) { - int is_request = 0, n = 0; - - while(*buffer != '\0' && isspace(*(unsigned char *)buffer)) { - buffer++; - } - - c->request_method = skip(&buffer, " "); - c->uri = skip(&buffer, " "); - c->http_version = skip(&buffer, "\r\n"); - - is_request = is_valid_http_method(c->request_method); - if((is_request && memcmp(c->http_version, "HTTP/", 5) != 0) || - (!is_request && memcmp(c->request_method, "HTTP/", 5) != 0)) { - } else { - if(is_request == 1) { - c->http_version += 5; - } else { - c->status_code = atoi(c->uri); - } - parse_http_headers(&buffer, c); - - if((c->query_string = strchr(c->uri, '?')) != NULL) { - *(char *)c->query_string++ = '\0'; - } - n = (int)strlen(c->uri); - _urldecode(c->uri, n, (char *)c->uri, n + 1, 0); - - if(*c->uri == '/' || *c->uri == '.') { - remove_double_dots_and_double_slashes((char *)c->uri); - } - } - - return 0; -} - -static void webserver_client_add(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - -#ifdef _WIN32 - uv_mutex_lock(&webserver_lock); -#else - pthread_mutex_lock(&webserver_lock); -#endif - struct webserver_clients_t *node = MALLOC(sizeof(struct webserver_clients_t)); - if(node == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->req = req; - node->is_websocket = 0; - - node->next = webserver_clients; - webserver_clients = node; -#ifdef _WIN32 - uv_mutex_unlock(&webserver_lock); -#else - pthread_mutex_unlock(&webserver_lock); -#endif -} - -static void webserver_client_remove(uv_poll_t *req) { -#ifdef _WIN32 - uv_mutex_lock(&webserver_lock); -#else - pthread_mutex_lock(&webserver_lock); -#endif - struct webserver_clients_t *currP, *prevP; - - prevP = NULL; - - for(currP = webserver_clients; currP != NULL; prevP = currP, currP = currP->next) { - if(currP->req == req) { - if(prevP == NULL) { - webserver_clients = currP->next; - } else { - prevP->next = currP->next; - } - - FREE(currP); - break; - } - } -#ifdef _WIN32 - uv_mutex_unlock(&webserver_lock); -#else - pthread_mutex_unlock(&webserver_lock); -#endif -} - -static void send_websocket_handshake(uv_poll_t *req, const char *key) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - unsigned char sha[20]; - char buf[500], *b64_sha = NULL, *p = (char *)sha; - mbedtls_sha1_context ctx; - - memset(&sha, '\0', 20); - - snprintf(buf, sizeof(buf), "%s%s", key, magic); - mbedtls_sha1_init(&ctx); - mbedtls_sha1_starts(&ctx); - mbedtls_sha1_update(&ctx, (unsigned char *)buf, strlen(buf)); - mbedtls_sha1_finish(&ctx, sha); - b64_sha = base64encode(p, 20); - int i = sprintf(buf, - "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" - "Connection: Upgrade\r\n" - "Upgrade: websocket\r\n" - "Sec-WebSocket-Accept: %s\r\n\r\n", b64_sha); - - iobuf_append(&custom_poll_data->send_iobuf, buf, i); - uv_custom_write(req); - mbedtls_sha1_free(&ctx); - FREE(b64_sha); -} - -static void send_websocket_handshake_if_requested(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - - const char *ver = http_get_header(conn, "Sec-WebSocket-Version"); - const char *key = http_get_header(conn, "Sec-WebSocket-Key"); - if(ver != NULL && key != NULL) { - conn->is_websocket = 1; - - struct webserver_clients_t *tmp = webserver_clients; - while(tmp) { - if(tmp->req == req) { - tmp->is_websocket = 1; - break; - } - tmp = tmp->next; - } - send_websocket_handshake(req, key); - } -} - -int websocket_read(uv_poll_t *req, unsigned char *buf, ssize_t buf_len) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - - unsigned int i = 0, j = 0; - unsigned char mask[4]; - unsigned int packet_length = 0; - unsigned int length_code = 0; - int index_first_mask = 0; - int index_first_data_byte = 0; - int opcode = buf[0] & 0xF; - - memset(&mask, '\0', 4); - length_code = ((unsigned char)buf[1]) & 0x7F; - index_first_mask = 2; - if(length_code == 126) { - index_first_mask = 4; - } else if(length_code == 127) { - index_first_mask = 10; - } - memcpy(mask, &buf[index_first_mask], 4); - index_first_data_byte = index_first_mask + 4; - packet_length = buf_len - index_first_data_byte; - for(i = index_first_data_byte, j = 0; i < buf_len; i++, j++) { - buf[j] = buf[i] ^ mask[j % 4]; - } - buf[packet_length] = '\0'; - - switch(opcode) { - case WEBSOCKET_OPCODE_PONG: { - struct timeval tv; - gettimeofday(&tv, NULL); - conn->ping = 1000000 * (unsigned int)tv.tv_sec + (unsigned int)tv.tv_usec; - } break; - case WEBSOCKET_OPCODE_PING: { - websocket_write(req, WEBSOCKET_OPCODE_PONG, NULL, 0); - } break; - case WEBSOCKET_OPCODE_CONNECTION_CLOSE: - websocket_write(req, WEBSOCKET_OPCODE_CONNECTION_CLOSE, NULL, 0); - return -1; - break; - case WEBSOCKET_OPCODE_TEXT: - conn->content_len = packet_length; - conn->content = (char *)buf; - return 0; - break; - } - - return packet_length; -} - -// static void *adhoc_mode(int reason, void *param) { - // if(https_server != NULL) { - // eventpool_fd_remove(https_server); - // logprintf(LOG_INFO, "shut down secure webserver due to adhoc mode"); - // https_server = NULL; - // } - // if(http_server != NULL) { - // eventpool_fd_remove(http_server); - // logprintf(LOG_INFO, "shut down regular webserver due to adhoc mode"); - // http_server = NULL; - // } - - // return NULL; -// } - -// void *webserver_restart(int reason, void *param) { - // if(https_server != NULL) { - // eventpool_fd_remove(https_server); - // https_server = NULL; - // } - // if(http_server != NULL) { - // eventpool_fd_remove(http_server); - // http_server = NULL; - // } - -// #ifdef WEBSERVER_HTTPS - // if(https_port > 0) { - // if(ssl_server_init_status() == 0) { - // https_server = eventpool_socket_add("webserver https", NULL, https_port, AF_INET, SOCK_STREAM, 0, EVENTPOOL_TYPE_SOCKET_SERVER, server_callback, client_send, NULL); - // } else { - // logprintf(LOG_NOTICE, "could not initialize mbedtls library, secure webserver not started"); - // } - // } -// #endif - - // if(http_port > 0) { - // http_server = eventpool_socket_add("webserver http", NULL, http_port, AF_INET, SOCK_STREAM, 0, EVENTPOOL_TYPE_SOCKET_SERVER, server_callback, client_send, NULL); - // } - - // return NULL; -// } - -static void poll_close_cb(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *conn = custom_poll_data->data; - int fd = -1, r = 0; - - if((r = uv_fileno((uv_handle_t *)req, (uv_os_fd_t *)&fd)) != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); - /*LCOV_EXCL_STOP*/ - } - - if(conn != NULL && conn->is_websocket == 1) { - websocket_write(req, WEBSOCKET_OPCODE_CONNECTION_CLOSE, NULL, 0); - } - - if(fd > -1) { -#ifdef _WIN32 - shutdown(fd, SD_BOTH); - closesocket(fd); -#else - shutdown(fd, SHUT_RDWR); - close(fd); -#endif - } - - if(conn != NULL) { - if(conn->fd > 0) { -#ifdef _WIN32 - closesocket(conn->fd); -#else - close(conn->fd); -#endif - conn->fd = -1; - } - if(conn->request != NULL) { - FREE(conn->request); - } - } - - webserver_client_remove(req); - - if(!uv_is_closing((uv_handle_t *)req)) { - uv_close((uv_handle_t *)req, close_cb); - } - - if(custom_poll_data->data != NULL) { - FREE(custom_poll_data->data); - } - - if(req->data != NULL) { - uv_custom_poll_free(custom_poll_data); - req->data = NULL; - } - -} - -static void client_write_cb(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *c = (struct connection_t *)custom_poll_data->data; - - if(c->file_fd >= 0) { - if(file_read_cb(c->file_fd, req) != 0) { - uv_custom_close(req); - } - } -} - -static void client_read_cb(uv_poll_t *req, ssize_t *nread, char *buf) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct uv_custom_poll_t *custom_poll_data = req->data; - struct connection_t *c = (struct connection_t *)custom_poll_data->data; - int is_websocket = 0; - - if(c != NULL && c->is_websocket == 1) { - is_websocket = 1; - } - - if(*nread > 0 && is_websocket == 0) { - buf[*nread-1] = '\0'; - } - - if(*nread > 0) { - if(c->is_websocket == 0) { - http_parse_request(buf, c); - send_websocket_handshake_if_requested(req); - - if(auth_handler(req) == MG_FALSE) { - send_auth_request(req); - uv_custom_close(req); - return; - } - } else { - unsigned char *p = (unsigned char *)buf; - if(websocket_read(req, p, *nread) == -1) { - uv_custom_close(req); - return; - } - } - int x = request_handler(req); - if(x == MG_TRUE) { - if(c->is_websocket == 1) { - uv_custom_read(req); - *nread = 0; - return; - } - - uv_custom_close(req); - return; - } - } -} - -static void server_read_cb(uv_poll_t *req, ssize_t *nread, char *buf) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct sockaddr_in servaddr; - struct uv_custom_poll_t *server_poll_data = req->data; - struct uv_custom_poll_t *custom_poll_data = NULL; - socklen_t socklen = sizeof(servaddr); - char buffer[BUFFER_SIZE]; - int client = 0, r = 0, fd = 0; - - memset(buffer, '\0', BUFFER_SIZE); - - if((r = uv_fileno((uv_handle_t *)req, (uv_os_fd_t *)&fd)) != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); - return; - /*LCOV_EXCL_STOP*/ - } - - if((client = accept(fd, (struct sockaddr *)&servaddr, (socklen_t *)&socklen)) < 0) { - logprintf(LOG_NOTICE, "accept: %s", strerror(errno)); - return; - } - - memset(&buffer, '\0', INET_ADDRSTRLEN+1); - uv_inet_ntop(AF_INET, (void *)&(servaddr.sin_addr), buffer, INET_ADDRSTRLEN+1); - - if(whitelist_check(buffer) != 0) { - logprintf(LOG_INFO, "rejected client, ip: %s, port: %d", buffer, ntohs(servaddr.sin_port)); -#ifdef _WIN32 - closesocket(client); -#else - close(client); -#endif - return; - } else { - logprintf(LOG_DEBUG, "new client, ip: %s, port: %d", buffer, ntohs(servaddr.sin_port)); - logprintf(LOG_DEBUG, "client fd: %d", client); - } - - struct reason_webserver_connected_t *data = MALLOC(sizeof(struct reason_webserver_connected_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - data->fd = client; - - eventpool_trigger(REASON_WEBSERVER_CONNECTED, reason_webserver_connected_free, data); - -#ifdef _WIN32 - unsigned long on = 1; - ioctlsocket(client, FIONBIO, &on); -#else - long arg = fcntl(client, F_GETFL, NULL); - fcntl(client, F_SETFL, arg | O_NONBLOCK); -#endif - - uv_poll_t *poll_req = NULL; - if((poll_req = MALLOC(sizeof(uv_poll_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - uv_custom_poll_init(&custom_poll_data, poll_req, NULL); - custom_poll_data->read_cb = client_read_cb; - custom_poll_data->write_cb = client_write_cb; - custom_poll_data->close_cb = poll_close_cb; - - r = uv_poll_init_socket(uv_default_loop(), poll_req, client); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_poll_init_socket: %s", uv_strerror(r)); -#ifdef _WIN32 - closesocket(fd); -#else - close(fd); -#endif - if(custom_poll_data != NULL) { - uv_custom_poll_free(custom_poll_data); - poll_req->data = NULL; - } - FREE(poll_req); - return; - /*LCOV_EXCL_STOP*/ - } - - struct connection_t *c = MALLOC(sizeof(struct connection_t)); - if(c == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(c, 0, sizeof(struct connection_t)); - - custom_poll_data->data = (void *)c; - custom_poll_data->is_server = 0; - c->request = NULL; - c->is_websocket = 0; - c->fd = client; - c->flags = 0; - c->ping = 0; - c->file_fd = -1; -#ifdef WEBSERVER_HTTPS - c->is_ssl = custom_poll_data->is_ssl = server_poll_data->is_ssl; - custom_poll_data->is_server = 1; -#endif - - webserver_client_add(poll_req); - uv_custom_read(req); - uv_custom_read(poll_req); -} - -static void server_write_cb(uv_poll_t *req) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct sockaddr_in servaddr; - socklen_t socklen = sizeof(servaddr); - int r = 0, fd = 0; - - if((r = uv_fileno((uv_handle_t *)req, (uv_os_fd_t *)&fd)) != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_fileno: %s", uv_strerror(r)); - return; - /*LCOV_EXCL_STOP*/ - } - - static struct linger linger = { 0, 0 }; -#ifdef _WIN32 - unsigned int lsize = sizeof(struct linger); -#else - socklen_t lsize = sizeof(struct linger); -#endif - setsockopt(fd, SOL_SOCKET, SO_LINGER, (void *)&linger, lsize); - - if(getsockname(fd, (struct sockaddr *)&servaddr, (socklen_t *)&socklen) == -1) { - logprintf(LOG_ERR, "getsockname"); /*LCOV_EXCL_LINE*/ - } else { -#ifdef WEBSERVER_HTTPS - if(ntohs(servaddr.sin_port) == https_port) { - logprintf(LOG_INFO, "secured webserver started on port: %d (fd %d)", https_port, fd); - } else { -#endif - logprintf(LOG_INFO, "regular webserver started on port: %d (fd %d)", ntohs(servaddr.sin_port), fd); -#ifdef WEBSERVER_HTTPS - } -#endif - } - - uv_custom_read(req); -} - -static int webserver_init(int port, int is_ssl) { - /* - * Make sure we execute in the main thread - */ - const uv_thread_t pth_cur_id = uv_thread_self(); - assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); - - struct sockaddr_in addr; - struct uv_custom_poll_t *custom_poll_data = NULL; - int r = 0, sockfd = 0, socklen = sizeof(addr); - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "WSAStartup"); - exit(EXIT_FAILURE); - } -#endif - - if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "socket: %s", strerror(errno)); - return -1; - /*LCOV_EXCL_STOP*/ - } - - unsigned long on = 1; - - if((r = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(int))) < 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "setsockopt: %s", strerror(errno)); -#ifdef _WIN32 - closesocket(sockfd); -#else - close(sockfd); -#endif - return -1; - /*LCOV_EXCL_STOP*/ - } - - memset((char *)&addr, '\0', sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = htonl(INADDR_ANY); - addr.sin_port = htons(port); - - if((r = bind(sockfd, (struct sockaddr *)&addr, sizeof(addr))) < 0) { - int x = 0; - if((x = getpeername(sockfd, (struct sockaddr *)&addr, (socklen_t *)&socklen)) == 0) { - logprintf(LOG_ERR, "cannot bind to webserver port %d, address already in use?", ntohs(addr.sin_port)); - } else { - logprintf(LOG_ERR, "cannot bind to webserver port, address already in use?"); - } -#ifdef _WIN32 - closesocket(sockfd); -#else - close(sockfd); -#endif - return -1; - } - - if((listen(sockfd, 0)) < 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "listen: %s", strerror(errno)); -#ifdef _WIN32 - closesocket(sockfd); -#else - close(sockfd); -#endif - return -1; - /*LCOV_EXCL_STOP*/ - } - - uv_poll_t *poll_req = NULL; - - if(is_ssl == 1) { - if((poll_https_req = MALLOC(sizeof(uv_poll_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - poll_req = poll_https_req; - } else { - if((poll_http_req = MALLOC(sizeof(uv_poll_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - poll_req = poll_http_req; - } - uv_custom_poll_init(&custom_poll_data, poll_req, NULL); - custom_poll_data->is_ssl = is_ssl; - custom_poll_data->is_server = 1; - - custom_poll_data->write_cb = server_write_cb; - custom_poll_data->read_cb = server_read_cb; - - r = uv_poll_init_socket(uv_default_loop(), poll_req, sockfd); - if(r != 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "uv_poll_init_socket: %s", uv_strerror(r)); -#ifdef _WIN32 - closesocket(sockfd); -#else - close(sockfd); -#endif - if(custom_poll_data != NULL) { - uv_custom_poll_free(custom_poll_data); - poll_req->data = NULL; - }; - FREE(poll_req); - return -1; - /*LCOV_EXCL_STOP*/ - } - - server_write_cb(poll_req); - - return 0; -} - -int webserver_start(void) { - const uv_thread_t pth_cur_id = uv_thread_self(); - if(uv_thread_equal(&pth_main_id, &pth_cur_id) == 0) { - /*LCOV_EXCL_START*/ - logprintf(LOG_ERR, "webserver_start can only be started from the main thread"); - return -1; - /*LCOV_EXCL_STOP*/ - } - - if((async_req = MALLOC(sizeof(uv_async_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - uv_async_init(uv_default_loop(), async_req, webserver_process); - - // double itmp = 0.0; - // int webserver_enabled = 0; - loop = 1; - - if(lock_init == 0) { - lock_init = 1; -#ifdef _WIN32 - uv_mutex_init(&webserver_lock); -#else - pthread_mutexattr_init(&webserver_attr); - pthread_mutexattr_settype(&webserver_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&webserver_lock, &webserver_attr); -#endif - } - -#ifdef PILIGHT_REWRITE - if(settings_select_number(ORIGIN_WEBSERVER, "webserver-http-port", &itmp) == 0) { http_port = (int)itmp; } - if(settings_select_number(ORIGIN_WEBSERVER, "webgui-websockets", &itmp) == 0) { websockets = (int)itmp; } - if(settings_select_number(ORIGIN_WEBSERVER, "webserver-cache", &itmp) == 0) { cache = (int)itmp; } - if(settings_select_number(ORIGIN_WEBSERVER, "webserver-enable", &itmp) == 0) { webserver_enabled = (int)itmp; } -#ifdef WEBSERVER_HTTPS - if(settings_select_number(ORIGIN_WEBSERVER, "webserver-https-port", &itmp) == 0) { https_port = (int)itmp; } -#endif - - if(settings_select_string(ORIGIN_WEBSERVER, "webserver-root", &root) != 0) { - /*LCOV_EXCL_START*/ - if((root = MALLOC(strlen(WEBSERVER_ROOT)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(root, WEBSERVER_ROOT); - root_free = 1; - /*LCOV_EXCL_STOP*/ - } - - settings_select_string_element(ORIGIN_WEBSERVER, "webserver-authentication", 0, &authentication_username); - settings_select_string_element(ORIGIN_WEBSERVER, "webserver-authentication", 1, &authentication_password); -#else - /* Check on what port the webserver needs to run */ - settings_find_number("webserver-http-port", &http_port); - -#ifdef WEBSERVER_HTTPS - settings_find_number("webserver-https-port", &https_port); -#endif - - if(settings_find_string("webserver-root", &root) != 0) { - /* If no webserver port was set, use the default webserver port */ - if((root = MALLOC(strlen(WEBSERVER_ROOT)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(root, WEBSERVER_ROOT); - root_free = 1; - } - settings_find_number("webgui-websockets", &websockets); - - /* Do we turn on webserver caching. This means that all requested files are - loaded into the memory so they aren't read from the FS anymore */ - settings_find_number("webserver-cache", &cache); - settings_find_string("webserver-authentication-password", &authentication_password); - settings_find_string("webserver-authentication-username", &authentication_username); - -#endif - - eventpool_callback(REASON_CONFIG_UPDATE, broadcast); - eventpool_callback(REASON_BROADCAST_CORE, broadcast); - // eventpool_callback(REASON_ADHOC_CONNECTED, adhoc_mode); - // eventpool_callback(REASON_ADHOC_DISCONNECTED, webserver_restart); - eventpool_callback(REASON_SOCKET_SEND, webserver_send); - -#ifdef WEBSERVER_HTTPS - if(https_port > 0 /*&& webserver_enabled == 1*/) { - if(ssl_server_init_status() == 0) { - webserver_init(https_port, 1); - } else { - logprintf(LOG_NOTICE, "could not initialize mbedtls library, secure webserver not started"); - } - } -#endif - - if(http_port > 0 /*&& webserver_enabled == 1*/) { - webserver_init(http_port, 0); - } - - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/core/webserver.h b/lib/ESPiLight/pilight/libs/pilight/core/webserver.h deleted file mode 100644 index 3590642..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/core/webserver.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _WEBSERVER_H_ -#define _WEBSERVER_H_ - -#ifdef WEBSERVER_HTTPS -#include -#endif - -#include "../libs/libuv/uv.h" - -typedef struct connection_t { - int fd; - char *request; - const char *request_method; - const char *uri; - const char *http_version; - const char *query_string; - - int num_headers; - struct headers { - const char *name; - const char *value; - } http_headers[30]; - - char *content; - size_t content_len; - char mimetype[255]; - - int is_websocket; - int ping; - int status_code; - void *connection_param; - void *callback_param; - unsigned int flags; - unsigned short timer; - - int file_fd; - - char buffer[WEBSERVER_CHUNK_SIZE]; - -#ifdef WEBSERVER_HTTPS - int is_ssl; - int handshake; - mbedtls_ssl_context ssl; -#endif -} connection_t; - -int webserver_gc(void); -int webserver_start(void); -void *webserver_broadcast(void *); -void webserver_create_header(char **, const char *, char *, unsigned long); -int http_parse_request(char *, struct connection_t *); -const char *http_get_header(struct connection_t *, const char *); -void *webserver_clientize(void *param); - -#endif \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/datatypes/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/datatypes/CMakeLists.txt deleted file mode 100644 index 3ca9035..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/datatypes/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -project(pilight_datatypes) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/datatypes/stack.c b/lib/ESPiLight/pilight/libs/pilight/datatypes/stack.c deleted file mode 100644 index ab6efaa..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/datatypes/stack.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include - -#include "../core/mem.h" -#include "stack.h" - -void dt_stack_free(struct stack_dt *stack, void (*func)(void *node)) { - int i = 0; - for(i=0;itop;i++) { - if(func != NULL) { - func(stack->list[i]); - } - } - if(stack->size > 0) { - FREE(stack->list); - } - FREE(stack); -} - -void dt_stack_push(struct stack_dt *stack, size_t size, void *item) { - if(stack->size == 0 || stack->size <= stack->top) { - if((stack->list = REALLOC(stack->list, size*(stack->size+12))) == NULL) { - OUT_OF_MEMORY - } - stack->size += 12; - } - stack->list[stack->top++] = item; -} - -int dt_stack_top(struct stack_dt *stack) { - return stack->top; -} - -void dt_stack_insert(struct stack_dt *stack, size_t size, int pos, void *item) { - int i = stack->top; - while(i >= pos) { - stack->list[i] = stack->list[i-1]; - i--; - } - if(stack->size == 0 || stack->size <= stack->top) { - if((stack->list = REALLOC(stack->list, size*(stack->size+12))) == NULL) { - printf("out of memory\n"); - exit(-1); - } - stack->size += 12; - } - stack->top++; - stack->list[pos] = item; -} - -void *dt_stack_pop(struct stack_dt *stack, int i) { - if(stack->top <= 0) { - return NULL; - } else if(i == -1) { - return stack->list[--stack->top]; - } else if(i < stack->top) { - int x = 0; - char *out = stack->list[i]; - for(x=i;xtop-1;x++) { - stack->list[x] = stack->list[x+1]; - } - stack->top--; - return out; - } - return NULL; -} - -void *dt_stack_peek(struct stack_dt *stack, int i) { - if(stack->top <= 0) { - return NULL; - } else if(i == -1) { - return stack->list[stack->top-1]; - } else if(i < stack->top) { - return stack->list[i]; - } else { - return NULL; - } -} \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/datatypes/stack.h b/lib/ESPiLight/pilight/libs/pilight/datatypes/stack.h deleted file mode 100644 index 6518c55..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/datatypes/stack.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _DATATYPES_STACK_T_ -#define _DATATYPES_STACK_T_ - -typedef struct stack_dt { - void **list; - int size; - int top; - int type; -} stack_dt; - -void dt_stack_free(struct stack_dt *, void (*)(void *)); -void dt_stack_push(struct stack_dt *, size_t, void *); -int dt_stack_top(struct stack_dt *); -void dt_stack_insert(struct stack_dt *, size_t, int, void *); -void *dt_stack_pop(struct stack_dt *, int); -void *dt_stack_peek(struct stack_dt *, int); - -#endif \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/events/CMakeLists.txt deleted file mode 100644 index eb94090..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -project(pilight_events) - -add_subdirectory(actions) -add_subdirectory(functions) -add_subdirectory(operators) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files - ${pilight_event_actions_files} - ${${PROJECT_NAME}_sources} - ${${PROJECT_NAME}_headers} -CACHE INTERNAL "") \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/action.c b/lib/ESPiLight/pilight/libs/pilight/events/action.c deleted file mode 100644 index 413edc3..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/action.c +++ /dev/null @@ -1,364 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #include -#endif - -#include "../core/threads.h" -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/options.h" -#include "../core/dso.h" -#include "../core/log.h" -#include "../config/settings.h" - -#include "action.h" -#include "actions/action_header.h" - -#ifndef _WIN32 -void event_action_remove(char *name) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct event_actions_t *currP, *prevP; - - prevP = NULL; - - for(currP = event_actions; currP != NULL; prevP = currP, currP = currP->next) { - - if(strcmp(currP->name, name) == 0) { - if(prevP == NULL) { - event_actions = currP->next; - } else { - prevP->next = currP->next; - } - - logprintf(LOG_DEBUG, "removed event action %s", currP->name); - FREE(currP->name); - FREE(currP); - - break; - } - } -} -#endif - -void event_action_init(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - #include "actions/action_init.h" - -#ifndef _WIN32 - void *handle = NULL; - void (*init)(void); - void (*compatibility)(struct module_t *module); - char path[PATH_MAX]; - struct module_t module; - char pilight_version[strlen(PILIGHT_VERSION)+1]; - char pilight_commit[3]; - char *action_root = NULL; - int check1 = 0, check2 = 0, valid = 1, action_root_free = 0; - strcpy(pilight_version, PILIGHT_VERSION); - - struct dirent *file = NULL; - DIR *d = NULL; - struct stat s; - - memset(pilight_commit, '\0', 3); - - if(settings_find_string("actions-root", &action_root) != 0) { - /* If no action root was set, use the default action root */ - if((action_root = MALLOC(strlen(ACTION_ROOT)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(action_root, ACTION_ROOT); - action_root_free = 1; - } - size_t len = strlen(action_root); - if(action_root[len-1] != '/') { - strcat(action_root, "/"); - } - - if((d = opendir(action_root))) { - while((file = readdir(d)) != NULL) { - memset(path, '\0', PATH_MAX); - sprintf(path, "%s%s", action_root, file->d_name); - if(stat(path, &s) == 0) { - /* Check if file */ - if(S_ISREG(s.st_mode)) { - if(strstr(file->d_name, ".so") != NULL) { - valid = 1; - - if((handle = dso_load(path)) != NULL) { - init = dso_function(handle, "init"); - compatibility = dso_function(handle, "compatibility"); - if(init && compatibility) { - compatibility(&module); - if(module.name != NULL && module.version != NULL && module.reqversion != NULL) { - char ver[strlen(module.reqversion)+1]; - strcpy(ver, module.reqversion); - - if((check1 = vercmp(ver, pilight_version)) > 0) { - valid = 0; - } - - if(check1 == 0 && module.reqcommit != NULL) { - char com[strlen(module.reqcommit)+1]; - strcpy(com, module.reqcommit); - sscanf(HASH, "v%*[0-9].%*[0-9]-%[0-9]-%*[0-9a-zA-Z\n\r]", pilight_commit); - - if(strlen(pilight_commit) > 0 && (check2 = vercmp(com, pilight_commit)) > 0) { - valid = 0; - } - } - if(valid == 1) { - char tmp[strlen(module.name)+1]; - strcpy(tmp, module.name); - event_action_remove(tmp); - init(); - logprintf(LOG_DEBUG, "loaded event action %s v%s", file->d_name, module.version); - } else { - if(module.reqcommit != NULL) { - logprintf(LOG_ERR, "event action %s requires at least pilight v%s (commit %s)", file->d_name, module.reqversion, module.reqcommit); - } else { - logprintf(LOG_ERR, "event action %s requires at least pilight v%s", file->d_name, module.reqversion); - } - } - } else { - logprintf(LOG_ERR, "invalid module %s", file->d_name); - } - } - } - } - } - } - } - closedir(d); - } - if(action_root_free) { - FREE(action_root); - } -#endif -} - -void event_action_register(struct event_actions_t **act, const char *name) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if((*act = MALLOC(sizeof(struct event_actions_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if(((*act)->name = MALLOC(strlen(name)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy((*act)->name, name); - - (*act)->options = NULL; - (*act)->run = NULL; - (*act)->nrthreads = 0; - (*act)->checkArguments = NULL; - - (*act)->next = event_actions; - event_actions = (*act); -} - -int event_action_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct event_actions_t *tmp_action = NULL; - while(event_actions) { - tmp_action = event_actions; - if(tmp_action->nrthreads > 0) { - logprintf(LOG_DEBUG, "waiting for \"%s\" threads to finish", tmp_action->name); - } - FREE(tmp_action->name); - options_delete(tmp_action->options); - event_actions = event_actions->next; - FREE(tmp_action); - } - if(event_actions != NULL) { - FREE(event_actions); - } - - logprintf(LOG_DEBUG, "garbage collected event action library"); - return 0; -} - -void event_action_thread_init(struct devices_t *dev) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if((dev->action_thread = MALLOC(sizeof(struct event_action_thread_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - pthread_mutexattr_init(&dev->action_thread->attr); - pthread_mutexattr_settype(&dev->action_thread->attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&dev->action_thread->mutex, &dev->action_thread->attr); - pthread_cond_init(&dev->action_thread->cond, NULL); - dev->action_thread->running = 0; - dev->action_thread->obj = NULL; - dev->action_thread->action = NULL; - dev->action_thread->loop = 0; - dev->action_thread->initialized = 0; - memset(&dev->action_thread->pth, '\0', sizeof(pthread_t)); -} - -void event_action_thread_start(struct devices_t *dev, char *name, void *(*func)(void *), struct rules_actions_t *obj) { - struct event_action_thread_t *thread = dev->action_thread; - - if(thread->running == 1) { - logprintf(LOG_DEBUG, "aborting previous \"%s\" action for device \"%s\"", thread->action, dev->id); - } - - thread->loop = 0; - - pthread_mutex_unlock(&thread->mutex); - pthread_cond_signal(&thread->cond); - - while(thread->running > 0) { - usleep(10); - } - - if(thread->initialized == 1) { - pthread_join(thread->pth, NULL); - thread->initialized = 0; - } - - // if(thread->param != NULL) { - // json_delete(thread->param); - // thread->param = NULL; - // } - - // if(param != NULL) { - // char *json = json_stringify(param, NULL); - // thread->param = json_decode(json); - // json_free(json); - // } - - thread->obj = obj; - thread->device = dev; - thread->loop = 1; - thread->action = REALLOC(thread->action, strlen(name)+1); - strcpy(thread->action, name); - - thread->initialized = 1; - threads_create(&thread->pth, NULL, func, (void *)thread); -} - -int event_action_thread_wait(struct devices_t *dev, int interval) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct timeval tp; - struct timespec ts; - - pthread_mutex_unlock(&dev->action_thread->mutex); - - gettimeofday(&tp, NULL); - ts.tv_sec = tp.tv_sec; - ts.tv_nsec = tp.tv_usec * 1000; - ts.tv_sec += interval; - - pthread_mutex_lock(&dev->action_thread->mutex); - - return pthread_cond_timedwait(&dev->action_thread->cond, &dev->action_thread->mutex, &ts); -} - -void event_action_thread_stop(struct devices_t *dev) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct event_action_thread_t *thread = NULL; - - if(dev != NULL) { - thread = dev->action_thread; - if(thread->running == 1) { - logprintf(LOG_DEBUG, "aborting running \"%s\" action for device \"%s\"", thread->action, dev->id); - - thread->loop = 0; - pthread_mutex_unlock(&thread->mutex); - pthread_cond_signal(&thread->cond); - - while(thread->running > 0) { - usleep(10); - } - } - if(thread->initialized == 1) { - pthread_join(thread->pth, NULL); - thread->initialized = 0; - } - } -} - -void event_action_thread_free(struct devices_t *dev) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct event_action_thread_t *thread = NULL; - - if(dev != NULL && dev->action_thread != NULL) { - thread = dev->action_thread; - if(thread->running == 1) { - logprintf(LOG_DEBUG, "aborting running \"%s\" action for device \"%s\"", thread->action, dev->id); - - thread->loop = 0; - pthread_mutex_unlock(&thread->mutex); - pthread_cond_signal(&thread->cond); - while(thread->running > 0) { - usleep(10); - } - } - if(thread->action != NULL) { - FREE(thread->action); - } - // if(thread->param != NULL) { - // json_delete(thread->param); - // thread->param = NULL; - // } - if(thread->initialized == 1) { - pthread_join(thread->pth, NULL); - thread->initialized = 0; - } - FREE(dev->action_thread); - } -} - -void event_action_started(struct event_action_thread_t *thread) { - logprintf(LOG_INFO, "started \"%s\" action for device \"%s\"", thread->action, thread->device->id); - pthread_mutex_lock(&thread->mutex); - thread->running = 1; - pthread_mutex_unlock(&thread->mutex); -} - -void event_action_stopped(struct event_action_thread_t *thread) { - logprintf(LOG_INFO, "stopped \"%s\" action for device \"%s\"", thread->action, thread->device->id); - pthread_mutex_lock(&thread->mutex); - thread->running = 0; - pthread_mutex_unlock(&thread->mutex); -} diff --git a/lib/ESPiLight/pilight/libs/pilight/events/action.h b/lib/ESPiLight/pilight/libs/pilight/events/action.h deleted file mode 100644 index 946d933..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/action.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _ACTION_H_ -#define _ACTION_H_ - -typedef struct event_action_thread_t event_action_thread_t; -typedef struct event_actions_t event_actions_t; -typedef struct rules_actions_t rules_actions_t; - -#include "../core/json.h" -#include "../core/common.h" -#include "../config/devices.h" -#include "../config/rules.h" - -struct event_actions_t { - char *name; - int nrthreads; - int (*run)(struct rules_actions_t *obj); - int (*checkArguments)(struct rules_actions_t *obj); - struct options_t *options; - - struct event_actions_t *next; -}; - -struct event_action_thread_t { - int running; - int loop; - int initialized; - char *action; - pthread_t pth; - pthread_mutex_t mutex; - pthread_cond_t cond; - pthread_mutexattr_t attr; - struct rules_actions_t *obj; - struct devices_t *device; -}; - -struct event_actions_t *event_actions; - -void event_action_init(void); -void event_action_register(struct event_actions_t **act, const char *name); -int event_action_gc(void); -void event_action_thread_init(struct devices_t *dev); -int event_action_thread_wait(struct devices_t *dev, int interval); -void event_action_thread_start(struct devices_t *dev, char *name, void *(*func)(void *), struct rules_actions_t *obj); -void event_action_thread_stop(struct devices_t *dev); -void event_action_thread_free(struct devices_t *dev); -void event_action_stopped(struct event_action_thread_t *thread); -void event_action_started(struct event_action_thread_t *thread); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/events/actions/CMakeInclude.txt deleted file mode 100644 index cb68b99..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/action_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/action_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(ACTION_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/action_header.h.in ${PROJECT_SOURCE_DIR}/action_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE action_result - OUTPUT_VARIABLE action_init) - -set(inits) -foreach(init ${action_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(ACTION_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/action_init.h.in ${PROJECT_SOURCE_DIR}/action_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/events/actions/CMakeLists.txt deleted file mode 100644 index e2d9a0e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -project(pilight_event_actions) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -if(${MODULESPACK} MATCHES "OFF" OR WIN32) - include(CMakeInclude.txt) - - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") -else() - foreach(file ${${PROJECT_NAME}_sources}) - get_filename_component(name ${file} NAME_WE) - add_library(${name}_module MODULE ${file}) - target_link_libraries(${name}_module ${CMAKE_THREAD_LIBS_INIT}) - target_link_libraries(${name}_module m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${name}_module execinfo) - endif() - target_link_libraries(${name}_module ${CMAKE_DL_LIBS}) - set_target_properties(${name}_module PROPERTIES OUTPUT_NAME ${name}) - string(REPLACE "_" "-" debname ${name}) - install(FILES ${CMAKE_BINARY_DIR}/libs/pilight/events/actions/lib${name}.so DESTINATION lib/pilight/actions RENAME ${name}.so COMPONENT pilight-action-${debname}) - endforeach() -endif() \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/action_header.h.in b/lib/ESPiLight/pilight/libs/pilight/events/actions/action_header.h.in deleted file mode 100644 index cea98b6..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/action_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@ACTION_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/action_init.h.in b/lib/ESPiLight/pilight/libs/pilight/events/actions/action_init.h.in deleted file mode 100644 index 1eea6b2..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/action_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@ACTION_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/dim.c b/lib/ESPiLight/pilight/libs/pilight/events/actions/dim.c deleted file mode 100644 index 865abd4..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/dim.c +++ /dev/null @@ -1,878 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/options.h" -#include "../../config/devices.h" -#include "../../core/log.h" -#include "../../core/dso.h" -#include "../action.h" -#include "../events.h" -#include "dim.h" - -#define DECREASING 0 -#define INCREASING 1 - -static struct units_t { - char name[255]; - int id; -} units[] = { - { "MILLISECOND", 1 }, - { "SECOND", 2 }, - { "MINUTE", 3 }, - { "HOUR", 4 }, - { "DAY", 5 } -}; - -static int checkArguments(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jfor = NULL; - struct JsonNode *jafter = NULL; - struct JsonNode *jfrom = NULL; - struct JsonNode *jin = NULL; - struct JsonNode *javalues = NULL; - struct JsonNode *jbvalues = NULL; - struct JsonNode *jcvalues = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jevalues = NULL; - struct JsonNode *jfvalues = NULL; - struct JsonNode *jachild = NULL; - struct JsonNode *jbchild = NULL; - struct JsonNode *jcchild = NULL; - struct JsonNode *jdchild = NULL; - struct JsonNode *jechild = NULL; - struct JsonNode *jfchild = NULL; - char **array = NULL; - double nr1 = 0.0, nr2 = 0.0, nr3 = 0.0, nr4 = 0.0, nr5 = 0.0, nr6 = 0.0; - double dimfrom = 0.0, dimto = 0.0; - int nrvalues = 0, l = 0, i = 0, match = 0; - int nrunits = (sizeof(units)/sizeof(units[0])); - - if(obj == NULL) { - /* Internal error */ - return -1; - } - - if(obj->arguments == NULL) { - /* Internal error */ - return -1; - } - - jdevice = json_find_member(obj->arguments, "DEVICE"); - jto = json_find_member(obj->arguments, "TO"); - jfor = json_find_member(obj->arguments, "FOR"); - jin = json_find_member(obj->arguments, "IN"); - jafter = json_find_member(obj->arguments, "AFTER"); - jfrom = json_find_member(obj->arguments, "FROM"); - - if(jdevice == NULL) { - logprintf(LOG_ERR, "dim action is missing a \"DEVICE ...\" statement"); - return -1; - } - - if(jto == NULL) { - logprintf(LOG_ERR, "dim action is missing a \"TO ...\" statement"); - return -1; - } - - json_find_number(jdevice, "order", &nr1); - json_find_number(jto, "order", &nr2); - if((int)nr1 != 1 || (int)nr2 != 2) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ...\""); - return -1; - } - - if(jfor != NULL) { - json_find_number(jfor, "order", &nr3); - if(nr3 < nr2) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ... FOR ...\""); - return -1; - } - } - - if(jafter != NULL) { - json_find_number(jafter, "order", &nr4); - if(nr4 < nr2) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ... AFTER ...\""); - return -1; - } - } - - if(jin != NULL) { - json_find_number(jin, "order", &nr6); - if(nr6 < nr2) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ... FROM ... IN ...\""); - return -1; - } - } - - if(jfrom != NULL) { - json_find_number(jfrom, "order", &nr5); - if(nr5 < nr2) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ... FROM ... IN ...\""); - return -1; - } - if(jin == NULL) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ... FROM ... IN ...\""); - return -1; - } - } else if(jin != NULL) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ... FROM ... IN ...\""); - return -1; - } - - if((javalues = json_find_member(jto, "value")) != NULL) { - jachild = json_first_child(javalues); - while(jachild) { - nrvalues++; - jachild = jachild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "dim actions are formatted as \"dim DEVICE ... TO ...\""); - return -1; - } - - nrvalues = 0; - if(jfor != NULL) { - if((jcvalues = json_find_member(jfor, "value")) != NULL) { - jcchild = json_first_child(jcvalues); - while(jcchild) { - nrvalues++; - if(jcchild->tag == JSON_STRING) { - l = explode(jcchild->string_, " ", &array); - if(l == 2) { - match = 0; - for(i=0;i 0) { - array_free(&array, l); - } - return -1; - } - } - jcchild = jcchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "dim action \"FOR\" only takes one argument"); - return -1; - } - } - - nrvalues = 0; - if(jafter != NULL) { - if((jdvalues = json_find_member(jafter, "value")) != NULL) { - jdchild = json_first_child(jdvalues); - while(jdchild) { - nrvalues++; - if(jdchild->tag == JSON_STRING) { - l = explode(jdchild->string_, " ", &array); - if(l == 2) { - match = 0; - for(i=0;i 0) { - array_free(&array, l); - } - return -1; - } - } - jdchild = jdchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "dim action \"AFTER\" only takes one argument"); - return -1; - } - } - - nrvalues = 0; - if(jfrom != NULL) { - if((jevalues = json_find_member(jfrom, "value")) != NULL) { - jechild = json_first_child(jevalues); - while(jechild) { - nrvalues++; - jechild = jechild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "dim action \"FROM\" only takes one argument"); - return -1; - } - } - - nrvalues = 0; - if(jin != NULL) { - if((jfvalues = json_find_member(jin, "value")) != NULL) { - jfchild = json_first_child(jfvalues); - while(jfchild) { - nrvalues++; - if(jfchild->tag == JSON_STRING) { - l = explode(jfchild->string_, " ", &array); - if(l == 2) { - match = 0; - for(i=0;i 0) { - array_free(&array, l); - } - return -1; - } - } - jfchild = jfchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "dim action \"IN\" only takes one argument"); - return -1; - } - } - - if((jbvalues = json_find_member(jdevice, "value")) != NULL) { - jbchild = json_first_child(jbvalues); - while(jbchild) { - if(jbchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jbchild->string_, &dev) == 0) { - if((javalues = json_find_member(jto, "value")) != NULL) { - jachild = json_first_child(javalues); - while(jachild) { - match = 0; - if(jachild->tag == JSON_NUMBER) { - dimto = jachild->number_; - match = 1; - } - if(match == 1) { - struct protocols_t *tmp_protocols = dev->protocols; - if(tmp_protocols->listener->devtype == DIMMER) { - struct devices_settings_t *tmp_settings = dev->settings; - int match1 = 0, match2 = 0; - while(tmp_settings) { - if(strcmp(tmp_settings->name, "dimlevel-maximum") == 0) { - if(tmp_settings->values->type == JSON_NUMBER && - (int)tmp_settings->values->number_ < (int)dimto) { - logprintf(LOG_ERR, "device \"%s\" can't be set to dimlevel \"%d\"", jbchild->string_, (int)dimto); - return -1; - } - match1 = 1; - } - if(strcmp(tmp_settings->name, "dimlevel-minimum") == 0) { - if(tmp_settings->values->type == JSON_NUMBER && - (int)tmp_settings->values->number_ > (int)dimto) { - logprintf(LOG_ERR, "device \"%s\" can't be set to dimlevel \"%d\"", jbchild->string_, (int)dimto); - return -1; - } - match2 = 1; - } - tmp_settings = tmp_settings->next; - } - if(match1 == 0 || match2 == 0) { - while(tmp_protocols) { - struct options_t *opt = tmp_protocols->listener->options; - while(opt) { - if(match1 == 0 && strcmp(opt->name, "dimlevel-maximum") == 0 && - opt->vartype == JSON_NUMBER && (int)(intptr_t)opt->def < (int)dimto) { - logprintf(LOG_ERR, "device \"%s\" can't be set to dimlevel \"%d\"", jbchild->string_, (int)dimto); - return -1; - } - if(match2 == 0 && strcmp(opt->name, "dimlevel-minimum") == 0 && - opt->vartype == JSON_NUMBER && (int)(intptr_t)opt->def > (int)dimto) { - logprintf(LOG_ERR, "device \"%s\" can't be set to dimlevel \"%d\"", jbchild->string_, (int)dimto); - return -1; - } - opt = opt->next; - } - tmp_protocols = tmp_protocols->next; - } - } - } else { - logprintf(LOG_ERR, "device \"%s\" doesn't support dimming", jbchild->string_); - return -1; - } - } else { - logprintf(LOG_ERR, "internal error 1 in dim action", jbchild->string_); - return -1; - } - jachild = jachild->next; - } - } else { - logprintf(LOG_ERR, "internal error 2 in dim action", jbchild->string_); - return -1; - } - - if((jevalues = json_find_member(jfrom, "value")) != NULL) { - jechild = json_first_child(jevalues); - while(jechild) { - match = 0; - if(jechild->tag == JSON_NUMBER) { - dimfrom = jechild->number_; - match = 1; - } - if(match == 1) { - struct protocols_t *tmp_protocols = dev->protocols; - if(tmp_protocols->listener->devtype == DIMMER) { - struct devices_settings_t *tmp_settings = dev->settings; - int match1 = 0, match2 = 0; - while(tmp_settings) { - if(strcmp(tmp_settings->name, "dimlevel-maximum") == 0) { - if(tmp_settings->values->type == JSON_NUMBER && - (int)tmp_settings->values->number_ < (int)dimfrom) { - logprintf(LOG_ERR, "device \"%s\" dimlevel can't be set to \"%d\"", jbchild->string_, (int)dimfrom); - return -1; - } - match1 = 1; - } - if(strcmp(tmp_settings->name, "dimlevel-minimum") == 0) { - if(tmp_settings->values->type == JSON_NUMBER && - (int)tmp_settings->values->number_ > (int)dimfrom) { - logprintf(LOG_ERR, "device \"%s\" dimlevel can't be set to \"%d\"", jbchild->string_, (int)dimfrom); - return -1; - } - match2 = 1; - } - tmp_settings = tmp_settings->next; - } - if(match1 == 0 || match2 == 0) { - while(tmp_protocols) { - struct options_t *opt = tmp_protocols->listener->options; - while(opt) { - if(match1 == 0 && strcmp(opt->name, "dimlevel-maximum") == 0 && - opt->vartype == JSON_NUMBER && (int)(intptr_t)opt->def < (int)dimfrom) { - logprintf(LOG_ERR, "device \"%s\" dimlevel can't be set to \"%d\"", jbchild->string_, (int)dimfrom); - return -1; - } - if(match2 == 0 && strcmp(opt->name, "dimlevel-minimum") == 0 && - opt->vartype == JSON_NUMBER && (int)(intptr_t)opt->def > (int)dimfrom) { - logprintf(LOG_ERR, "device \"%s\" dimlevel can't be set to \"%d\"", jbchild->string_, (int)dimfrom); - return -1; - } - opt = opt->next; - } - tmp_protocols = tmp_protocols->next; - } - } - } else { - logprintf(LOG_ERR, "device \"%s\" doesn't support dimming", jbchild->string_); - return -1; - } - } else { - logprintf(LOG_ERR, "device \"%s\" doesn't exists", jbchild->string_); - return -1; - } - jechild = jechild->next; - } - } - } else { - logprintf(LOG_ERR, "internal error 3 in dim action", jbchild->string_); - return -1; - } - } else { - logprintf(LOG_ERR, "internal error 4 in dim action", jbchild->string_); - return -1; - } - jbchild = jbchild->next; - } - } else { - logprintf(LOG_ERR, "internal error 5 in dim action", jbchild->string_); - return -1; - } - return 0; -} - -static void *thread(void *param) { - struct event_action_thread_t *pth = (struct event_action_thread_t *)param; - struct JsonNode *json = pth->obj->arguments; - struct JsonNode *jedimlevel = NULL; - struct JsonNode *jsdimlevel = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jafter = NULL; - struct JsonNode *jfor = NULL; - struct JsonNode *jfrom = NULL; - struct JsonNode *jin = NULL; - struct JsonNode *javalues = NULL; - struct JsonNode *jcvalues = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jevalues = NULL; - struct JsonNode *jfvalues = NULL; - struct JsonNode *jaseconds = NULL; - struct JsonNode *jiseconds = NULL; - struct JsonNode *jvalues = NULL; - char *old_state = NULL, **array = NULL; - double dimlevel = 0.0, old_dimlevel = 0.0, new_dimlevel = 0.0, cur_dimlevel = 0.0; - int seconds_after = 0, seconds_for = 0, seconds_in = 0, has_in = 0, dimdiff = 0; - int type_for = 0, type_after = 0, type_in = 0; - int direction = 0, interval = 0, timer = 0; - int l = 0, i = 0, nrunits = (sizeof(units)/sizeof(units[0])); - char state[3]; - - event_action_started(pth); - - if((jfor = json_find_member(json, "FOR")) != NULL) { - if((jcvalues = json_find_member(jfor, "value")) != NULL) { - jaseconds = json_find_element(jcvalues, 0); - if(jaseconds != NULL) { - if(jaseconds->tag == JSON_STRING) { - l = explode(jaseconds->string_, " ", &array); - if(l == 2) { - for(i=0;i 0) { - array_free(&array, l); - } - } - } - } - } - - if((jafter = json_find_member(json, "AFTER")) != NULL) { - if((jdvalues = json_find_member(jafter, "value")) != NULL) { - jaseconds = json_find_element(jdvalues, 0); - if(jaseconds != NULL) { - if(jaseconds->tag == JSON_STRING) { - l = explode(jaseconds->string_, " ", &array); - if(l == 2) { - for(i=0;i 0) { - array_free(&array, l); - } - } - } - } - } - - if((jin = json_find_member(json, "IN")) != NULL) { - if((jfvalues = json_find_member(jin, "value")) != NULL) { - jiseconds = json_find_element(jfvalues, 0); - if(jiseconds != NULL) { - if(jiseconds->tag == JSON_STRING) { - l = explode(jiseconds->string_, " ", &array); - if(l == 2) { - for(i=0;i 0) { - array_free(&array, l); - } - } - } - } - } - - switch(type_for) { - case 3: - seconds_for *= 60; - break; - case 4: - seconds_for *= (60*60); - break; - case 5: - seconds_for *= (60*60*24); - break; - } - - switch(type_after) { - case 3: - seconds_after *= 60; - break; - case 4: - seconds_after *= (60*60); - break; - case 5: - seconds_after *= (60*60*24); - break; - } - - switch(type_in) { - case 3: - seconds_in *= 60; - break; - case 4: - seconds_in *= (60*60); - break; - case 5: - seconds_in *= (60*60*24); - break; - } - - if(pilight.debuglevel == 1) { - fprintf(stderr, "action dim: for %d:%d, after %d:%d, in: %d:%d\n", seconds_for, type_for, seconds_after, type_after, seconds_in, type_in); - } - /* Store current state and dimlevel */ - struct devices_t *tmp = pth->device; - int match1 = 0, match2 = 0; - while(tmp) { - struct devices_settings_t *opt = tmp->settings; - while(opt) { - if(strcmp(opt->name, "state") == 0) { - if(opt->values->type == JSON_STRING) { - if((old_state = MALLOC(strlen(opt->values->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(old_state, opt->values->string_); - match1 = 1; - } - } - if(strcmp(opt->name, "dimlevel") == 0) { - if(opt->values->type == JSON_NUMBER) { - cur_dimlevel = opt->values->number_; - match2 = 1; - } - } - if(match1 == 1 && match2 == 1) { - break; - } - opt = opt->next; - } - if(match1 == 1 && match2 == 1) { - break; - } - tmp = tmp->next; - } - if(match1 == 0) { - logprintf(LOG_NOTICE, "could not store old state of \"%s\"", pth->device->id); - } - if(match2 == 0) { - logprintf(LOG_NOTICE, "could not store old dimlevel of \"%s\"", pth->device->id); - } - - if((jfrom = json_find_member(json, "FROM")) != NULL) { - if((jevalues = json_find_member(jfrom, "value")) != NULL) { - jsdimlevel = json_find_element(jevalues, 0); - if(jsdimlevel != NULL) { - if(jsdimlevel->tag == JSON_NUMBER) { - old_dimlevel = (int)jsdimlevel->number_; - } - } - } - } - - if((jto = json_find_member(json, "TO")) != NULL) { - if((javalues = json_find_member(jto, "value")) != NULL) { - jedimlevel = json_find_element(javalues, 0); - if(jedimlevel != NULL) { - if(jedimlevel->tag == JSON_NUMBER) { - new_dimlevel = (int)jedimlevel->number_; - dimlevel = (int)jedimlevel->number_; - strcpy(state, "on"); - } - } - } - } - - if(pilight.debuglevel == 1) { - fprintf(stderr, "action dim: old %d, new %d, direction %d\n", (int)old_dimlevel, (int)new_dimlevel, direction); - } - - if(has_in == 1) { - if(old_dimlevel < new_dimlevel) { - direction = INCREASING; - dimdiff = (int)(new_dimlevel - old_dimlevel); - interval = (int)(seconds_in / dimdiff); - } else if(old_dimlevel > new_dimlevel) { - direction = DECREASING; - dimdiff = (int)(old_dimlevel - new_dimlevel); - interval = (int)(seconds_in / dimdiff); - } else { - dimdiff = 0; - interval = 0; - } - } - - /* - * We'll switch from first dimlevel to second dimlevel after X seconds - * and switch back after X seconds. - */ - if(has_in == 0) { - if(old_state == NULL || ((strcmp(old_state, "on") != 0 || (int)cur_dimlevel != (int)new_dimlevel))) { - timer = 0; - while(pth->loop == 1) { - if(timer == seconds_after) { - jvalues = json_mkobject(); - json_append_member(jvalues, "dimlevel", json_mknumber(dimlevel, 0)); - if(pilight.control != NULL) { - pilight.control(pth->device, state, json_first_child(jvalues), ACTION); - } - json_delete(jvalues); - break; - } - timer++; - if(type_after > 1) { - sleep(1); - } else { - usleep(1000); - } - } - - /* - * We only need to restore the state if it was actually changed - */ - if(seconds_for > 0 && old_state != NULL && (strcmp(old_state, "on") != 0 || (int)cur_dimlevel != (int)new_dimlevel)) { - timer = 0; - while(pth->loop == 1) { - if(seconds_for == timer) { - jvalues = json_mkobject(); - json_append_member(jvalues, "dimlevel", json_mknumber(cur_dimlevel, 0)); - if(pilight.control != NULL) { - if(strcmp(old_state, "off") == 0) { - pilight.control(pth->device, state, json_first_child(jvalues), ACTION); - pilight.control(pth->device, old_state, NULL, ACTION); - } else { - pilight.control(pth->device, old_state, json_first_child(jvalues), ACTION); - } - } - json_delete(jvalues); - break; - } - timer++; - if(type_for > 1) { - sleep(1); - } else { - usleep(1000); - } - } - } - } - /* We'll gently start increasing / decreasing the dimlevel after X seconds in X seconds. */ - } else if(interval > 0) { - timer = 0; - while(pth->loop == 1) { - if(timer == seconds_after) { - break; - } - timer++; - if(type_after > 1) { - sleep(1); - } else { - usleep(1000); - } - } - if(direction == INCREASING) { - for(i=(int)old_dimlevel;i<=(int)new_dimlevel;i++) { - timer = 0; - while(pth->loop == 1) { - if(interval == timer || i == (int)old_dimlevel) { - jvalues = json_mkobject(); - json_append_member(jvalues, "dimlevel", json_mknumber(i, 0)); - if(pilight.control != NULL) { - pilight.control(pth->device, state, json_first_child(jvalues), ACTION); - } - json_delete(jvalues); - break; - } - timer++; - if(type_in > 1) { - sleep(1); - } else { - usleep(1000); - } - } - } - } else { - for(i=(int)old_dimlevel;i>=(int)new_dimlevel;i--) { - timer = 0; - while(pth->loop == 1) { - if(interval == timer || i == (int)old_dimlevel) { - jvalues = json_mkobject(); - json_append_member(jvalues, "dimlevel", json_mknumber(i, 0)); - if(pilight.control != NULL) { - pilight.control(pth->device, state, json_first_child(jvalues), ACTION); - } - json_delete(jvalues); - break; - } - timer++; - if(type_in > 1) { - sleep(1); - } else { - usleep(1000); - } - } - } - } - /* - * We only need to restore the state if it was actually changed - */ - if(seconds_for > 0 && old_state != NULL && - (strcmp(old_state, "on") != 0 || (int)cur_dimlevel != (int)new_dimlevel)) { - timer = 0; - while(pth->loop == 1) { - if(timer == seconds_for) { - jvalues = json_mkobject(); - json_append_member(jvalues, "dimlevel", json_mknumber(cur_dimlevel, 0)); - if(pilight.control != NULL) { - if(strcmp(old_state, "off") == 0) { - pilight.control(pth->device, state, json_first_child(jvalues), ACTION); - pilight.control(pth->device, old_state, NULL, ACTION); - } else { - pilight.control(pth->device, old_state, json_first_child(jvalues), ACTION); - } - } - json_delete(jvalues); - break; - } - timer++; - if(type_for > 1) { - sleep(1); - } else { - usleep(1000); - } - } - } - } - - if(old_state != NULL) { - FREE(old_state); - } - - event_action_stopped(pth); - - return (void *)NULL; -} - -static int run(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jbvalues = NULL; - struct JsonNode *jbchild = NULL; - - if((jdevice = json_find_member(obj->arguments, "DEVICE")) != NULL && - (jto = json_find_member(obj->arguments, "TO")) != NULL) { - if((jbvalues = json_find_member(jdevice, "value")) != NULL) { - jbchild = json_first_child(jbvalues); - while(jbchild) { - if(jbchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jbchild->string_, &dev) == 0) { - event_action_thread_start(dev, action_dim->name, thread, obj); - } - } - jbchild = jbchild->next; - } - } - } - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void actionDimInit(void) { - event_action_register(&action_dim, "dim"); - - options_add(&action_dim->options, 'a', "DEVICE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_dim->options, 'b', "TO", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&action_dim->options, 'c', "FROM", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&action_dim->options, 'd', "FOR", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_dim->options, 'e', "AFTER", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_dim->options, 'f', "IN", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - action_dim->run = &run; - action_dim->checkArguments = &checkArguments; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "dim"; - module->version = "3.5"; - module->reqversion = "6.0"; - module->reqcommit = "152"; -} - -void init(void) { - actionDimInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/dim.h b/lib/ESPiLight/pilight/libs/pilight/events/actions/dim.h deleted file mode 100644 index a682c46..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/dim.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _EVENT_ACTION_DIM_H_ -#define _EVENT_ACTION_DIM_H_ - -#include "../action.h" - -struct event_actions_t *action_dim; - -void actionDimInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/label.c b/lib/ESPiLight/pilight/libs/pilight/events/actions/label.c deleted file mode 100644 index eb31416..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/label.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include - -#include "../action.h" -#include "../events.h" -#include "../../core/options.h" -#include "../../config/devices.h" -#include "../../core/log.h" -#include "../../core/dso.h" -#include "../../core/pilight.h" -#include "label.h" - -static struct units_t { - char name[255]; - int id; -} units[] = { - { "MILLISECOND", 1 }, - { "SECOND", 2 }, - { "MINUTE", 3 }, - { "HOUR", 4 }, - { "DAY", 5 } -}; - -static int checkArguments(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jfor = NULL; - struct JsonNode *jafter = NULL; - struct JsonNode *jcolor = NULL; - struct JsonNode *javalues = NULL; - struct JsonNode *jbvalues = NULL; - struct JsonNode *jcvalues = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jevalues = NULL; - struct JsonNode *jachild = NULL; - struct JsonNode *jbchild = NULL; - struct JsonNode *jcchild = NULL; - struct JsonNode *jdchild = NULL; - struct JsonNode *jechild = NULL; - char **array = NULL; - double nr1 = 0.0, nr2 = 0.0, nr3 = 0.0, nr4 = 0.0, nr5 = 0.0; - int nrvalues = 0, l = 0, i = 0, match = 0; - int nrunits = (sizeof(units)/sizeof(units[0])); - - if(obj == NULL) { - /* Internal error */ - return -1; - } - - if(obj->arguments == NULL) { - /* Internal error */ - return -1; - } - - jdevice = json_find_member(obj->arguments, "DEVICE"); - jto = json_find_member(obj->arguments, "TO"); - jfor = json_find_member(obj->arguments, "FOR"); - jafter = json_find_member(obj->arguments, "AFTER"); - jcolor = json_find_member(obj->arguments, "COLOR"); - - if(jdevice == NULL) { - logprintf(LOG_ERR, "label action is missing a \"DEVICE\""); - return -1; - } - - if(jto == NULL) { - logprintf(LOG_ERR, "label action is missing a \"TO ...\" statement"); - return -1; - } - - json_find_number(jdevice, "order", &nr1); - json_find_number(jto, "order", &nr2); - - if(jcolor != NULL) { - json_find_number(jcolor, "order", &nr5); - } - - if(jfor != NULL) { - json_find_number(jfor, "order", &nr3); - if(nr3 < nr2) { - logprintf(LOG_ERR, "label actions are formatted as \"label DEVICE ... TO ... FOR ...\""); - return -1; - } else if(nr5 > 0 && nr3 < nr5) { - logprintf(LOG_ERR, "label actions are formatted as \"label DEVICE ... TO ... COLOR ... FOR ...\""); - return -1; - } - } - - if(jafter != NULL) { - json_find_number(jafter, "order", &nr4); - if(nr4 < nr2) { - logprintf(LOG_ERR, "label actions are formatted as \"label DEVICE ... TO ... AFTER ...\""); - return -1; - } else if(nr5 > 0 && nr4 < nr5) { - logprintf(LOG_ERR, "label actions are formatted as \"label DEVICE ... TO ... COLOR ... AFTER ...\""); - return -1; - } - } - - if((int)nr1 != 1 || (int)nr2 != 2) { - logprintf(LOG_ERR, "label actions are formatted as \"label DEVICE ... TO ...\""); - return -1; - } - if(nr5 > 0 && nr5 != 3) { - logprintf(LOG_ERR, "label actions are formatted as \"label DEVICE ... TO ... COLOR ...\""); - return -1; - } - - nrvalues = 0; - if((javalues = json_find_member(jto, "value")) != NULL) { - jachild = json_first_child(javalues); - while(jachild) { - nrvalues++; - jachild = jachild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "label action \"TO\" only takes one argument"); - return -1; - } - - nrvalues = 0; - if(jfor != NULL) { - if((jcvalues = json_find_member(jfor, "value")) != NULL) { - jcchild = json_first_child(jcvalues); - while(jcchild) { - nrvalues++; - if(jcchild->tag == JSON_STRING) { - l = explode(jcchild->string_, " ", &array); - if(l == 2) { - match = 0; - for(i=0;i 0) { - array_free(&array, l); - } - return -1; - } - } - jcchild = jcchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "label action \"FOR\" only takes one argument"); - return -1; - } - } - - nrvalues = 0; - if(jafter != NULL) { - if((jdvalues = json_find_member(jafter, "value")) != NULL) { - jdchild = json_first_child(jdvalues); - while(jdchild) { - nrvalues++; - if(jdchild->tag == JSON_STRING) { - l = explode(jdchild->string_, " ", &array); - if(l == 2) { - match = 0; - for(i=0;i 0) { - array_free(&array, l); - } - return -1; - } - } - jdchild = jdchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "label action \"AFTER\" only takes one argument"); - return -1; - } - } - - nrvalues = 0; - if(jcolor != NULL) { - if((jevalues = json_find_member(jcolor, "value")) != NULL) { - jechild = json_first_child(jevalues); - while(jechild) { - nrvalues++; - jechild = jechild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "label action \"COLOR\" only takes one argument"); - return -1; - } - } - - if((jbvalues = json_find_member(jdevice, "value")) != NULL) { - jbchild = json_first_child(jbvalues); - while(jbchild) { - if(jbchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jbchild->string_, &dev) == 0) { - struct protocols_t *protocols = dev->protocols; - int match = 0; - while(protocols) { - if(protocols->listener->devtype == LABEL) { - match = 1; - break; - } - protocols = protocols->next; - } - if(match == 0) { - logprintf(LOG_ERR, "the label action only works with the label devices"); - return -1; - } - } else { - logprintf(LOG_ERR, "device \"%s\" doesn't exists", jbchild->string_); - return -1; - } - } else { - return -1; - } - jbchild = jbchild->next; - } - } - return 0; -} - -static void *thread(void *param) { - struct event_action_thread_t *pth = (struct event_action_thread_t *)param; - struct JsonNode *json = pth->obj->arguments; - struct JsonNode *jto = NULL; - struct JsonNode *jafter = NULL; - struct JsonNode *jfor = NULL; - struct JsonNode *jcolor = NULL; - struct JsonNode *javalues = NULL; - struct JsonNode *jcvalues = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jevalues = NULL; - struct JsonNode *jlabel = NULL; - struct JsonNode *jaseconds = NULL; - struct JsonNode *jvalues = NULL; - char *new_label = NULL, *old_label = NULL, *label = NULL, **array = NULL; - char *new_color = NULL, *old_color = NULL, *color = NULL; - int seconds_after = 0, type_after = 0, free_label = 0; - int l = 0, i = 0, nrunits = (sizeof(units)/sizeof(units[0])); - int seconds_for = 0, type_for = 0, timer = 0; - - event_action_started(pth); - - if((jcolor = json_find_member(json, "COLOR")) != NULL) { - if((jevalues = json_find_member(jcolor, "value")) != NULL) { - jcolor = json_find_element(jevalues, 0); - if(jcolor != NULL && jcolor->tag == JSON_STRING) { - color = jcolor->string_; - if((new_color = MALLOC(strlen(color)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(new_color, color); - } - } - } - - if((jfor = json_find_member(json, "FOR")) != NULL) { - if((jcvalues = json_find_member(jfor, "value")) != NULL) { - jaseconds = json_find_element(jcvalues, 0); - if(jaseconds != NULL) { - if(jaseconds->tag == JSON_STRING) { - l = explode(jaseconds->string_, " ", &array); - if(l == 2) { - for(i=0;i 0) { - array_free(&array, l); - } - } - } - } - } - - if((jafter = json_find_member(json, "AFTER")) != NULL) { - if((jdvalues = json_find_member(jafter, "value")) != NULL) { - jaseconds = json_find_element(jdvalues, 0); - if(jaseconds != NULL) { - if(jaseconds->tag == JSON_STRING) { - l = explode(jaseconds->string_, " ", &array); - if(l == 2) { - for(i=0;i 0) { - array_free(&array, l); - } - } - } - } - } - - switch(type_for) { - case 3: - seconds_for *= 60; - break; - case 4: - seconds_for *= (60*60); - break; - case 5: - seconds_for *= (60*60*24); - break; - } - - switch(type_after) { - case 3: - seconds_after *= 60; - break; - case 4: - seconds_after *= (60*60); - break; - case 5: - seconds_after *= (60*60*24); - break; - } - - /* Store current label */ - struct devices_t *tmp = pth->device; - int match1 = 0, match2 = 0; - while(tmp) { - struct devices_settings_t *opt = tmp->settings; - while(opt) { - if(strcmp(opt->name, "label") == 0) { - if(opt->values->type == JSON_STRING) { - if((old_label = MALLOC(strlen(opt->values->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(old_label, opt->values->string_); - match1 = 1; - } - } - if(strcmp(opt->name, "color") == 0) { - if(opt->values->type == JSON_STRING) { - if((old_color = MALLOC(strlen(opt->values->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(old_color, opt->values->string_); - match2 = 1; - } - } - opt = opt->next; - } - if(match1 == 1 && match2 == 1) { - break; - } - tmp = tmp->next; - } - if(match1 == 0) { - logprintf(LOG_NOTICE, "could not store old label of \"%s\"", pth->device->id); - } - if(match2 == 0) { - logprintf(LOG_NOTICE, "could not store old color of \"%s\"", pth->device->id); - } - - timer = 0; - while(pth->loop == 1) { - if(timer == seconds_after) { - if((jto = json_find_member(json, "TO")) != NULL) { - if((javalues = json_find_member(jto, "value")) != NULL) { - jlabel = json_find_element(javalues, 0); - if(jlabel != NULL) { - if(jlabel->tag == JSON_STRING) { - label = jlabel->string_; - } else if(jlabel->tag == JSON_NUMBER) { - int l = snprintf(NULL, 0, "%.*f", jlabel->decimals_, jlabel->number_); - if((label = MALLOC(l+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(label, '\0', l); - free_label = 1; - snprintf(label, l + 1, "%.*f", jlabel->decimals_, jlabel->number_); - label[l] = '\0'; - } - if((new_label = MALLOC(strlen(label)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(new_label, label); - /* - * We're not switching when current label or is the same as - * the old label or old color. - */ - if(old_label == NULL || strcmp(old_label, new_label) != 0 || - (old_color != NULL && new_color != NULL && strcmp(old_color, new_color) != 0)) { - if(pilight.control != NULL) { - jvalues = json_mkobject(); - if(color != NULL) { - json_append_member(jvalues, "color", json_mkstring(color)); - } - json_append_member(jvalues, "label", json_mkstring(label)); - pilight.control(pth->device, NULL, json_first_child(jvalues), ACTION); - json_delete(jvalues); - break; - } - } - } - } - } - break; - } - timer++; - if(type_after > 1) { - sleep(1); - } else { - usleep(1000); - } - } - - /* - * We only need to restore the label if it was actually changed - */ - if(seconds_for > 0 && ((old_label != NULL && new_label != NULL && strcmp(old_label, new_label) != 0) || - (old_color != NULL && new_color != NULL && strcmp(old_color, new_color) != 0))) { - timer = 0; - while(pth->loop == 1) { - if(seconds_for == timer) { - if(pilight.control != NULL) { - jvalues = json_mkobject(); - if(old_color != NULL) { - json_append_member(jvalues, "color", json_mkstring(old_color)); - } - json_append_member(jvalues, "label", json_mkstring(old_label)); - pilight.control(pth->device, NULL, json_first_child(jvalues), ACTION); - json_delete(jvalues); - break; - } - break; - } - timer++; - if(type_for > 1) { - sleep(1); - } else { - usleep(1000); - } - } - } - - if(free_label == 1) { - FREE(label); - } - - if(old_label != NULL) { - FREE(old_label); - } - - if(new_label != NULL) { - FREE(new_label); - } - - if(old_color != NULL) { - FREE(old_color); - } - - if(new_color != NULL) { - FREE(new_color); - } - - event_action_stopped(pth); - - return (void *)NULL; -} - -static int run(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jbvalues = NULL; - struct JsonNode *jbchild = NULL; - - if((jdevice = json_find_member(obj->arguments, "DEVICE")) != NULL && - (jto = json_find_member(obj->arguments, "TO")) != NULL) { - if((jbvalues = json_find_member(jdevice, "value")) != NULL) { - jbchild = json_first_child(jbvalues); - while(jbchild) { - if(jbchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jbchild->string_, &dev) == 0) { - event_action_thread_start(dev, action_label->name, thread, obj); - } - } - jbchild = jbchild->next; - } - } - } - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void actionLabelInit(void) { - event_action_register(&action_label, "label"); - - options_add(&action_label->options, 'a', "DEVICE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_label->options, 'b', "TO", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING | JSON_NUMBER, NULL, NULL); - options_add(&action_label->options, 'c', "AFTER", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_label->options, 'd', "FOR", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_label->options, 'e', "COLOR", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - action_label->run = &run; - action_label->checkArguments = &checkArguments; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "label"; - module->version = "2.2"; - module->reqversion = "6.0"; - module->reqcommit = "152"; -} - -void init(void) { - actionLabelInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/label.h b/lib/ESPiLight/pilight/libs/pilight/events/actions/label.h deleted file mode 100644 index 6b9efd0..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/label.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _EVENT_ACTION_LABEL_H_ -#define _EVENT_ACTION_LABEL_H_ - -#include "../action.h" - -struct event_actions_t *action_label; - -void actionLabelInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushbullet.c b/lib/ESPiLight/pilight/libs/pilight/events/actions/pushbullet.c deleted file mode 100644 index e371083..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushbullet.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - Copyright (C) 2013 - 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/threads.h" -#include "../action.h" -#include "../../core/options.h" -#include "../../config/devices.h" -#include "../../core/log.h" -#include "../../core/dso.h" -#include "../../core/pilight.h" -#include "../../core/http.h" -#include "pushbullet.h" - -static int checkArguments(struct rules_actions_t *obj) { - struct JsonNode *jtitle = NULL; - struct JsonNode *jbody = NULL; - struct JsonNode *jtype = NULL; - struct JsonNode *jtoken = NULL; - struct JsonNode *jvalues = NULL; - struct JsonNode *jchild = NULL; - int nrvalues = 0; - - jtitle = json_find_member(obj->arguments, "TITLE"); - jbody = json_find_member(obj->arguments, "BODY"); - jtoken = json_find_member(obj->arguments, "TOKEN"); - jtype = json_find_member(obj->arguments, "TYPE"); - - if(jtitle == NULL) { - logprintf(LOG_ERR, "pushbullet action is missing a \"TITLE\""); - return -1; - } - if(jbody == NULL) { - logprintf(LOG_ERR, "pushbullet action is missing a \"BODY\""); - return -1; - } - if(jtype == NULL) { - logprintf(LOG_ERR, "pushbullet action is missing a \"TYPE\""); - return -1; - } - if(jtoken == NULL) { - logprintf(LOG_ERR, "pushbullet action is missing a \"TOKEN\""); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jtitle, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushbullet action \"TITLE\" only takes one argument"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jbody, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushbullet action \"BODY\" only takes one argument"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jtoken, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushbullet action \"TOKEN\" only takes one argument"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jtype, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushbullet action \"TYPE\" only takes one argument"); - return -1; - } - return 0; -} - -static void callback(int code, char *data, int size, char *type, void *userdata) { - if(code == 200) { - logprintf(LOG_DEBUG, "pushbullet action succeeded with message: %s", data); - } else { - logprintf(LOG_NOTICE, "pushbullet action failed (%d) with message: %s", code, data); - } -} - -static void *thread(void *param) { - struct rules_actions_t *pth = (struct rules_actions_t *)param; - // struct rules_t *obj = pth->obj; - struct JsonNode *arguments = pth->arguments; - struct JsonNode *jtitle = NULL; - struct JsonNode *jbody = NULL; - struct JsonNode *jtype = NULL; - struct JsonNode *jtoken = NULL; - struct JsonNode *jvalues1 = NULL; - struct JsonNode *jvalues2 = NULL; - struct JsonNode *jvalues3 = NULL; - struct JsonNode *jvalues4 = NULL; - struct JsonNode *jval1 = NULL; - struct JsonNode *jval2 = NULL; - struct JsonNode *jval3 = NULL; - struct JsonNode *jval4 = NULL; - - char url[1024]; - - action_pushbullet->nrthreads++; - - jtitle = json_find_member(arguments, "TITLE"); - jbody = json_find_member(arguments, "BODY"); - jtoken = json_find_member(arguments, "TOKEN"); - jtype = json_find_member(arguments, "TYPE"); - - if(jtitle != NULL && jbody != NULL && jtoken != NULL && jtype != NULL) { - jvalues1 = json_find_member(jtitle, "value"); - jvalues2 = json_find_member(jbody, "value"); - jvalues3 = json_find_member(jtoken, "value"); - jvalues4 = json_find_member(jtype, "value"); - if(jvalues1 != NULL && jvalues2 != NULL && jvalues3 != NULL && jvalues4 != NULL) { - jval1 = json_find_element(jvalues1, 0); - jval2 = json_find_element(jvalues2, 0); - jval3 = json_find_element(jvalues3, 0); - jval4 = json_find_element(jvalues4, 0); - if(jval1 != NULL && jval2 != NULL && jval3 != NULL && jval4 != NULL && - jval1->tag == JSON_STRING && jval2->tag == JSON_STRING && - jval3->tag == JSON_STRING && jval4->tag == JSON_STRING) { - snprintf(url, 1024, "https://%s@api.pushbullet.com/v2/pushes", jval3->string_); - - struct JsonNode *code = json_mkobject(); - json_append_member(code, "type", json_mkstring(jval4->string_)); - json_append_member(code, "title", json_mkstring(jval1->string_)); - json_append_member(code, "body", json_mkstring(jval2->string_)); - - char *content = json_stringify(code, "\t"); - json_delete(code); - - http_post_content(url, "application/json", content, callback, NULL); - - json_free(content); - } - } - } - - - action_pushbullet->nrthreads--; - - return (void *)NULL; -} - -static int run(struct rules_actions_t *obj) { - pthread_t pth; - threads_create(&pth, NULL, thread, (void *)obj); - pthread_detach(pth); - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void actionPushbulletInit(void) { - event_action_register(&action_pushbullet, "pushbullet"); - - options_add(&action_pushbullet->options, 'a', "TITLE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_pushbullet->options, 'b', "BODY", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_pushbullet->options, 'c', "TOKEN", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_pushbullet->options, 'd', "TYPE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - action_pushbullet->run = &run; - action_pushbullet->checkArguments = &checkArguments; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "pushbullet"; - module->version = "2.2"; - module->reqversion = "5.0"; - module->reqcommit = "87"; -} - -void init(void) { - actionPushbulletInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushbullet.h b/lib/ESPiLight/pilight/libs/pilight/events/actions/pushbullet.h deleted file mode 100644 index 55c6a2c..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushbullet.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _EVENT_ACTION_PUSHBULLET_H_ -#define _EVENT_ACTION_PUSHBULLET_H_ - -#include "../action.h" - -struct event_actions_t *action_pushbullet; - -void actionPushbulletInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushover.c b/lib/ESPiLight/pilight/libs/pilight/events/actions/pushover.c deleted file mode 100644 index a7fff06..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushover.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/threads.h" -#include "../action.h" -#include "../../core/options.h" -#include "../../config/devices.h" -#include "../../core/log.h" -#include "../../core/dso.h" -#include "../../core/pilight.h" -#include "../../core/http.h" -#include "../../core/common.h" -#include "pushover.h" - -static int checkArguments(struct rules_actions_t *obj) { - struct JsonNode *jtitle = NULL; - struct JsonNode *jmessage = NULL; - struct JsonNode *juser = NULL; - struct JsonNode *jtoken = NULL; - struct JsonNode *jvalues = NULL; - struct JsonNode *jchild = NULL; - int nrvalues = 0; - - jtitle = json_find_member(obj->arguments, "TITLE"); - jmessage = json_find_member(obj->arguments, "MESSAGE"); - jtoken = json_find_member(obj->arguments, "TOKEN"); - juser = json_find_member(obj->arguments, "USER"); - - if(jtitle == NULL) { - logprintf(LOG_ERR, "pushover action is missing a \"TITLE\""); - return -1; - } - if(jmessage == NULL) { - logprintf(LOG_ERR, "pushover action is missing a \"MESSAGE\""); - return -1; - } - if(juser == NULL) { - logprintf(LOG_ERR, "pushover action is missing a \"USER\""); - return -1; - } - if(jtoken == NULL) { - logprintf(LOG_ERR, "pushover action is missing a \"TOKEN\""); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jtitle, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushover action \"TITLE\" only takes one argument"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jmessage, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushover action \"MESSAGE\" only takes one argument"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jtoken, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushover action \"TOKEN\" only takes one argument"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(juser, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "pushover action \"USER\" only takes one argument"); - return -1; - } - return 0; -} - -static void callback(int code, char *data, int size, char *type, void *userdata) { - if(code == 200) { - logprintf(LOG_DEBUG, "pushover action succeeded with message: %s", data); - } else { - logprintf(LOG_NOTICE, "pushover action failed (%d) with message: %s", code, data); - } -} - -static void *thread(void *param) { - struct rules_actions_t *pth = (struct rules_actions_t *)param; - // struct rules_t *obj = pth->obj; - struct JsonNode *arguments = pth->arguments; - struct JsonNode *jtitle = NULL; - struct JsonNode *jmessage = NULL; - struct JsonNode *juser = NULL; - struct JsonNode *jtoken = NULL; - struct JsonNode *jvalues1 = NULL; - struct JsonNode *jvalues2 = NULL; - struct JsonNode *jvalues3 = NULL; - struct JsonNode *jvalues4 = NULL; - struct JsonNode *jval1 = NULL; - struct JsonNode *jval2 = NULL; - struct JsonNode *jval3 = NULL; - struct JsonNode *jval4 = NULL; - - action_pushover->nrthreads++; - - char url[1024]; - - jtitle = json_find_member(arguments, "TITLE"); - jmessage = json_find_member(arguments, "MESSAGE"); - jtoken = json_find_member(arguments, "TOKEN"); - juser = json_find_member(arguments, "USER"); - - if(jtitle != NULL && jmessage != NULL && jtoken != NULL && juser != NULL) { - jvalues1 = json_find_member(jtitle, "value"); - jvalues2 = json_find_member(jmessage, "value"); - jvalues3 = json_find_member(jtoken, "value"); - jvalues4 = json_find_member(juser, "value"); - if(jvalues1 != NULL && jvalues2 != NULL && jvalues3 != NULL && jvalues4 != NULL) { - jval1 = json_find_element(jvalues1, 0); - jval2 = json_find_element(jvalues2, 0); - jval3 = json_find_element(jvalues3, 0); - jval4 = json_find_element(jvalues4, 0); - if(jval1 != NULL && jval2 != NULL && jval3 != NULL && jval4 != NULL && - jval1->tag == JSON_STRING && jval2->tag == JSON_STRING && - jval3->tag == JSON_STRING && jval4->tag == JSON_STRING) { - strcpy(url, "https://api.pushover.net/1/messages.json"); - char *message = urlencode(jval2->string_); - char *token = urlencode(jval3->string_); - char *user = urlencode(jval4->string_); - char *title = urlencode(jval1->string_); - size_t l = strlen(message)+strlen(token); - l += strlen(user)+strlen(title); - l += strlen("token=")+strlen("&user="); - l += strlen("&message=")+strlen("&title="); - char content[l+2]; - sprintf(content, "token=%s&user=%s&title=%s&message=%s", token, user, title, message); - - http_post_content(url, "application/x-www-form-urlencoded", content, callback, NULL); - - FREE(message); - FREE(token); - FREE(user); - FREE(title); - } - } - } - - action_pushover->nrthreads--; - - return (void *)NULL; -} - -static int run(struct rules_actions_t *obj) { - pthread_t pth; - threads_create(&pth, NULL, thread, (void *)obj); - pthread_detach(pth); - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void actionPushoverInit(void) { - event_action_register(&action_pushover, "pushover"); - - options_add(&action_pushover->options, 'a', "TITLE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_pushover->options, 'b', "MESSAGE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_pushover->options, 'c', "TOKEN", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_pushover->options, 'd', "USER", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - action_pushover->run = &run; - action_pushover->checkArguments = &checkArguments; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "pushover"; - module->version = "2.3"; - module->reqversion = "5.0"; - module->reqcommit = "87"; -} - -void init(void) { - actionPushoverInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushover.h b/lib/ESPiLight/pilight/libs/pilight/events/actions/pushover.h deleted file mode 100644 index ecb1f86..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/pushover.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _EVENT_ACTION_PUSHOVER_H_ -#define _EVENT_ACTION_PUSHOVER_H_ - -#include "../action.h" - -struct event_actions_t *action_pushover; - -void actionPushoverInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/sendmail.c b/lib/ESPiLight/pilight/libs/pilight/events/actions/sendmail.c deleted file mode 100644 index d7e67aa..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/sendmail.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo & Niek - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/threads.h" -#include "../action.h" -#include "../../core/options.h" -#include "../../config/devices.h" -#include "../../core/dso.h" -#include "../../core/pilight.h" -#include "../../core/http.h" -#include "../../core/common.h" -#include "../../config/settings.h" -#include "../../core/log.h" -#include "../../core/mail.h" -#include "sendmail.h" - -//check arguments and settings -static int checkArguments(struct rules_actions_t *obj) { - struct JsonNode *jsubject = NULL; - struct JsonNode *jmessage = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jvalues = NULL; - struct JsonNode *jval = NULL; - struct JsonNode *jchild = NULL; - char *stmp = NULL; - int nrvalues = 0, itmp = 0; - jsubject = json_find_member(obj->arguments, "SUBJECT"); - jmessage = json_find_member(obj->arguments, "MESSAGE"); - jto = json_find_member(obj->arguments, "TO"); - - if(jsubject == NULL) { - logprintf(LOG_ERR, "sendmail action is missing a \"SUBJECT\""); - return -1; - } - if(jmessage == NULL) { - logprintf(LOG_ERR, "sendmail action is missing a \"MESSAGE\""); - return -1; - } - if(jto == NULL) { - logprintf(LOG_ERR, "sendmail action is missing a \"TO\""); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jsubject, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues > 1) { - logprintf(LOG_ERR, "sendmail action \"SUBJECT\" only takes one argument"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jmessage, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "sendmail action \"MESSAGE\" only takes one argument"); - return -1; - } - jval = json_find_element(jvalues, 0); - if(jval->tag == JSON_STRING && strcmp(jval->string_, ".") == 0) { - logprintf(LOG_ERR, "sendmail action \"MESSAGE\" cannot be a single dot"); - return -1; - } - nrvalues = 0; - if((jvalues = json_find_member(jto, "value")) != NULL) { - jchild = json_first_child(jvalues); - while(jchild) { - nrvalues++; - jchild = jchild->next; - } - } - if(nrvalues > 1) { - logprintf(LOG_ERR, "sendmail action \"TO\" only takes one argument"); - return -1; - } - jval = json_find_element(jvalues, 0); - if(jval->tag != JSON_STRING || jval->string_ == NULL) { - logprintf(LOG_ERR, "sendmail action \"TO\" must contain an e-mail address"); - return -1; - } else if(strlen(jval->string_) > 0 && check_email_addr(jval->string_, 0, 0) < 0) { - logprintf(LOG_ERR, "sendmail action \"TO\" must contain an e-mail address"); - return -1; - } - // Check if mandatory settings are present in config - if(settings_find_string("smtp-host", &stmp) != EXIT_SUCCESS) { - logprintf(LOG_ERR, "Sendmail: setting \"smtp-host\" is missing in config"); - return -1; - } - if(settings_find_number("smtp-port", &itmp) != EXIT_SUCCESS) { - logprintf(LOG_ERR, "Sendmail: setting \"smtp-port\" is missing in config"); - return -1; - } - if(settings_find_string("smtp-user", &stmp) != EXIT_SUCCESS) { - logprintf(LOG_ERR, "Sendmail: setting \"smtp-user\" is missing in config"); - return -1; - } - if(settings_find_string("smtp-password", &stmp) != EXIT_SUCCESS) { - logprintf(LOG_ERR, "Sendmail: setting \"smtp-password\" is missing in config"); - return -1; - } - if(settings_find_string("smtp-sender", &stmp) != EXIT_SUCCESS) { - logprintf(LOG_ERR, "Sendmail: setting \"smtp-sender\" is missing in config"); - return -1; - } - return 0; -} - -static void callback(int status, struct mail_t *mail) { - if(status == 0) { - logprintf(LOG_INFO, "successfully sent sendmail action message with subject \"%s\" to %s", mail->subject, mail->to); - } else { - logprintf(LOG_NOTICE, "failed to send sendmail action message with subject \"%s\" to %s", mail->subject, mail->to); - } - FREE(mail->from); - FREE(mail->to); - FREE(mail->message); - FREE(mail->subject); - FREE(mail); -} - -static void *thread(void *param) { - struct rules_actions_t *pth = (struct rules_actions_t *)param; - struct JsonNode *arguments = pth->arguments; - struct JsonNode *jsubject = NULL; - struct JsonNode *jmessage = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jvalues1 = NULL; - struct JsonNode *jvalues2 = NULL; - struct JsonNode *jvalues3 = NULL; - struct JsonNode *jval1 = NULL; - struct JsonNode *jval2 = NULL; - struct JsonNode *jval3 = NULL; - - action_sendmail->nrthreads++; - - struct mail_t *mail = MALLOC(sizeof(struct mail_t)); - char *shost = NULL, *suser = NULL; - char *spassword = NULL, *sfrom = NULL; - int sport = 0, ssl = 0; - - if(mail == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - jmessage = json_find_member(arguments, "MESSAGE"); - jsubject = json_find_member(arguments, "SUBJECT"); - jto = json_find_member(arguments, "TO"); - - if(jsubject != NULL && jmessage != NULL && jto != NULL) { - jvalues1 = json_find_member(jsubject, "value"); - jvalues2 = json_find_member(jmessage, "value"); - jvalues3 = json_find_member(jto, "value"); - if(jvalues1 != NULL && jvalues2 != NULL && jvalues3 != NULL) { - jval1 = json_find_element(jvalues1, 0); - jval2 = json_find_element(jvalues2, 0); - jval3 = json_find_element(jvalues3, 0); - if(jval1 != NULL && jval2 != NULL && jval3 != NULL && - jval1->tag == JSON_STRING && jval2->tag == JSON_STRING && jval3->tag == JSON_STRING) { - - //smtp settings - settings_find_string("smtp-sender", &sfrom); - settings_find_string("smtp-host", &shost); - settings_find_number("smtp-port", &sport); - settings_find_string("smtp-user", &suser); - settings_find_string("smtp-password", &spassword); - settings_find_number("smtp-ssl", &ssl); - - if((mail->from = STRDUP(sfrom)) == NULL) { - OUT_OF_MEMORY - } - if((mail->subject = STRDUP(jval1->string_)) == NULL) { - OUT_OF_MEMORY - } - if((mail->message = STRDUP(jval2->string_)) == NULL) { - OUT_OF_MEMORY - } - if((mail->to = STRDUP(jval3->string_)) == NULL) { - OUT_OF_MEMORY - } - - if(sendmail(shost, suser, spassword, sport, ssl, mail, callback) != 0) { - callback(-1, mail); - } - } - } - } - - action_sendmail->nrthreads--; - - return (void *)NULL; -} - -static int run(struct rules_actions_t *obj) { - pthread_t pth; - threads_create(&pth, NULL, thread, (void *)obj); - pthread_detach(pth); - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void actionSendmailInit(void) { - event_action_register(&action_sendmail, "sendmail"); - - options_add(&action_sendmail->options, 'a', "SUBJECT", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_sendmail->options, 'b', "MESSAGE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_sendmail->options, 'c', "TO", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - action_sendmail->run = &run; - action_sendmail->checkArguments = &checkArguments; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "sendmail"; - module->version = "1.1"; - module->reqversion = "6.0"; - module->reqcommit = "152"; -} - -void init(void) { - actionSendmailInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/sendmail.h b/lib/ESPiLight/pilight/libs/pilight/events/actions/sendmail.h deleted file mode 100644 index 72241b2..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/sendmail.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo & Niek - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _EVENT_ACTION_SENDMAIL_H_ -#define _EVENT_ACTION_SENDMAIL_H_ - -#include "../action.h" - -struct event_actions_t *action_sendmail; - -void actionSendmailInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/switch.c b/lib/ESPiLight/pilight/libs/pilight/events/actions/switch.c deleted file mode 100644 index 49b9572..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/switch.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include - -#include "../action.h" -#include "../events.h" -#include "../../core/options.h" -#include "../../config/devices.h" -#include "../../core/log.h" -#include "../../core/dso.h" -#include "../../core/pilight.h" -#include "switch.h" - -static struct units_t { - char name[255]; - int id; -} units[] = { - { "MILLISECOND", 1 }, - { "SECOND", 2 }, - { "MINUTE", 3 }, - { "HOUR", 4 }, - { "DAY", 5 } -}; - -static int checkArguments(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jfor = NULL; - struct JsonNode *jafter = NULL; - struct JsonNode *javalues = NULL; - struct JsonNode *jbvalues = NULL; - struct JsonNode *jcvalues = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jachild = NULL; - struct JsonNode *jbchild = NULL; - struct JsonNode *jcchild = NULL; - struct JsonNode *jdchild = NULL; - char *state = NULL, **array = NULL; - double nr1 = 0.0, nr2 = 0.0, nr3 = 0.0, nr4 = 0.0; - int nrvalues = 0, l = 0, i = 0, match = 0; - int nrunits = (sizeof(units)/sizeof(units[0])); - - jdevice = json_find_member(obj->arguments, "DEVICE"); - jto = json_find_member(obj->arguments, "TO"); - jfor = json_find_member(obj->arguments, "FOR"); - jafter = json_find_member(obj->arguments, "AFTER"); - - if(jdevice == NULL) { - logprintf(LOG_ERR, "switch action is missing a \"DEVICE\" statement"); - return -1; - } - - if(jto == NULL) { - logprintf(LOG_ERR, "switch action is missing a \"TO ...\" statement"); - return -1; - } - - json_find_number(jdevice, "order", &nr1); - json_find_number(jto, "order", &nr2); - - if(jfor != NULL) { - json_find_number(jfor, "order", &nr3); - if(nr3 < nr2) { - logprintf(LOG_ERR, "switch actions are formatted as \"switch DEVICE ... TO ... FOR ...\""); - return -1; - } - } - - if(jafter != NULL) { - json_find_number(jafter, "order", &nr4); - if(nr4 < nr2) { - logprintf(LOG_ERR, "switch actions are formatted as \"switch DEVICE ... TO ... AFTER ...\""); - return -1; - } - } - - if((int)nr1 != 1 || (int)nr2 != 2) { - logprintf(LOG_ERR, "switch actions are formatted as \"switch DEVICE ... TO ...\""); - return -1; - } - - nrvalues = 0; - if((javalues = json_find_member(jto, "value")) != NULL) { - jachild = json_first_child(javalues); - while(jachild) { - nrvalues++; - jachild = jachild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "switch action \"TO\" only takes one argument"); - return -1; - } - - nrvalues = 0; - if(jfor != NULL) { - if((jcvalues = json_find_member(jfor, "value")) != NULL) { - jcchild = json_first_child(jcvalues); - while(jcchild) { - nrvalues++; - if(jcchild->tag == JSON_STRING) { - l = explode(jcchild->string_, " ", &array); - if(l == 2) { - match = 0; - for(i=0;i 0) { - array_free(&array, l); - } - return -1; - } - } - jcchild = jcchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "switch action \"FOR\" only takes one argument"); - return -1; - } - } - - nrvalues = 0; - if(jafter != NULL) { - if((jdvalues = json_find_member(jafter, "value")) != NULL) { - jdchild = json_first_child(jdvalues); - while(jdchild) { - nrvalues++; - if(jdchild->tag == JSON_STRING) { - l = explode(jdchild->string_, " ", &array); - if(l == 2) { - match = 0; - for(i=0;i 0) { - array_free(&array, l); - } - return -1; - } - array_free(&array, l); - } - jdchild = jdchild->next; - } - } - if(nrvalues != 1) { - logprintf(LOG_ERR, "switch action \"AFTER\" only takes one argument"); - return -1; - } - } - - if((jbvalues = json_find_member(jdevice, "value")) != NULL) { - jbchild = json_first_child(jbvalues); - while(jbchild) { - if(jbchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jbchild->string_, &dev) == 0) { - if((javalues = json_find_member(jto, "value")) != NULL) { - jachild = json_first_child(javalues); - while(jachild) { - if(jachild->tag == JSON_STRING) { - state = jachild->string_; - struct protocols_t *tmp = dev->protocols; - int match1 = 0; - while(tmp) { - struct options_t *opt = tmp->listener->options; - while(opt) { - if(opt->conftype == DEVICES_STATE) { - if(strcmp(opt->name, state) == 0) { - match1 = 1; - break; - } - } - opt = opt->next; - } - tmp = tmp->next; - } - if(match1 == 0) { - logprintf(LOG_ERR, "device \"%s\" can't be set to state \"%s\"", jbchild->string_, state); - return -1; - } - } else { - return -1; - } - jachild = jachild->next; - } - } else { - return -1; - } - } else { - logprintf(LOG_ERR, "device \"%s\" doesn't exists", jbchild->string_); - return -1; - } - } else { - return -1; - } - jbchild = jbchild->next; - } - } - return 0; -} - -static void *thread(void *param) { - struct event_action_thread_t *pth = (struct event_action_thread_t *)param; - struct JsonNode *json = pth->obj->arguments; - struct JsonNode *jto = NULL; - struct JsonNode *jafter = NULL; - struct JsonNode *jfor = NULL; - struct JsonNode *javalues = NULL; - struct JsonNode *jcvalues = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jstate = NULL; - struct JsonNode *jaseconds = NULL; - char *new_state = NULL, *old_state = NULL, *state = NULL, **array = NULL; - int seconds_after = 0, type_after = 0; - int l = 0, i = 0, nrunits = (sizeof(units)/sizeof(units[0])); - int seconds_for = 0, type_for = 0, timer = 0; - - event_action_started(pth); - - if((jfor = json_find_member(json, "FOR")) != NULL) { - if((jcvalues = json_find_member(jfor, "value")) != NULL) { - jaseconds = json_find_element(jcvalues, 0); - if(jaseconds != NULL) { - if(jaseconds->tag == JSON_STRING) { - l = explode(jaseconds->string_, " ", &array); - if(l == 2) { - for(i=0;i 0) { - array_free(&array, l); - } - } - } - } - } - - if((jafter = json_find_member(json, "AFTER")) != NULL) { - if((jdvalues = json_find_member(jafter, "value")) != NULL) { - jaseconds = json_find_element(jdvalues, 0); - if(jaseconds != NULL) { - if(jaseconds->tag == JSON_STRING) { - l = explode(jaseconds->string_, " ", &array); - if(l == 2) { - for(i=0;i 0) { - array_free(&array, l); - } - } - } - } - } - - switch(type_for) { - case 3: - seconds_for *= 60; - break; - case 4: - seconds_for *= (60*60); - break; - case 5: - seconds_for *= (60*60*24); - break; - } - - switch(type_after) { - case 3: - seconds_after *= 60; - break; - case 4: - seconds_after *= (60*60); - break; - case 5: - seconds_after *= (60*60*24); - break; - } - - /* Store current state */ - struct devices_t *tmp = pth->device; - int match = 0; - while(tmp) { - struct devices_settings_t *opt = tmp->settings; - while(opt) { - if(strcmp(opt->name, "state") == 0) { - if(opt->values->type == JSON_STRING) { - if((old_state = MALLOC(strlen(opt->values->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(old_state, opt->values->string_); - match = 1; - } - break; - } - opt = opt->next; - } - if(match == 1) { - break; - } - tmp = tmp->next; - } - if(match == 0) { - logprintf(LOG_NOTICE, "could not store old state of \"%s\"\n", pth->device->id); - } - - timer = 0; - while(pth->loop == 1) { - if(timer == seconds_after) { - if((jto = json_find_member(json, "TO")) != NULL) { - if((javalues = json_find_member(jto, "value")) != NULL) { - jstate = json_find_element(javalues, 0); - if(jstate != NULL && jstate->tag == JSON_STRING) { - state = jstate->string_; - if((new_state = MALLOC(strlen(state)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(new_state, state); - /* - * We're not switching when current state is the same as - * the old state. - */ - if(old_state == NULL || strcmp(old_state, new_state) != 0) { - if(pilight.control != NULL) { - pilight.control(pth->device, new_state, NULL, ACTION); - } - } - } - } - } - break; - } - timer++; - if(type_after > 1) { - sleep(1); - } else { - usleep(1000); - } - } - - /* - * We only need to restore the state if it was actually changed - */ - if(seconds_for > 0 && old_state != NULL && new_state != NULL && strcmp(old_state, new_state) != 0) { - timer = 0; - while(pth->loop == 1) { - if(seconds_for == timer) { - if(pilight.control != NULL) { - pilight.control(pth->device, old_state, NULL, ACTION); - } - break; - } - timer++; - if(type_for > 1) { - sleep(1); - } else { - usleep(1000); - } - } - } - - if(old_state != NULL) { - FREE(old_state); - } - - if(new_state != NULL) { - FREE(new_state); - } - - event_action_stopped(pth); - - return (void *)NULL; -} - -static int run(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jto = NULL; - struct JsonNode *jbvalues = NULL; - struct JsonNode *jbchild = NULL; - - if((jdevice = json_find_member(obj->arguments, "DEVICE")) != NULL && - (jto = json_find_member(obj->arguments, "TO")) != NULL) { - if((jbvalues = json_find_member(jdevice, "value")) != NULL) { - jbchild = json_first_child(jbvalues); - while(jbchild) { - if(jbchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jbchild->string_, &dev) == 0) { - event_action_thread_start(dev, action_switch->name, thread, obj); - } - } - jbchild = jbchild->next; - } - } - } - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void actionSwitchInit(void) { - event_action_register(&action_switch, "switch"); - - options_add(&action_switch->options, 'a', "DEVICE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_switch->options, 'b', "TO", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_switch->options, 'c', "AFTER", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_switch->options, 'd', "FOR", OPTION_OPT_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - action_switch->run = &run; - action_switch->checkArguments = &checkArguments; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "switch"; - module->version = "3.2"; - module->reqversion = "6.0"; - module->reqcommit = "152"; -} - -void init(void) { - actionSwitchInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/switch.h b/lib/ESPiLight/pilight/libs/pilight/events/actions/switch.h deleted file mode 100644 index c8017c2..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/switch.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _EVENT_ACTION_SWITCH_H_ -#define _EVENT_ACTION_SWITCH_H_ - -#include "../action.h" - -struct event_actions_t *action_switch; - -void actionSwitchInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/toggle.c b/lib/ESPiLight/pilight/libs/pilight/events/actions/toggle.c deleted file mode 100644 index 7f3d5a2..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/toggle.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../action.h" -#include "../../core/options.h" -#include "../../config/devices.h" -#include "../../core/log.h" -#include "../../core/dso.h" -#include "../../core/pilight.h" -#include "toggle.h" - -static int checkArguments(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jbetween = NULL; - struct JsonNode *jsvalues = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jschild = NULL; - struct JsonNode *jdchild = NULL; - double nr1 = 0.0, nr2 = 0.0; - int nrvalues = 0; - jdevice = json_find_member(obj->arguments, "DEVICE"); - jbetween = json_find_member(obj->arguments, "BETWEEN"); - - if(jdevice == NULL) { - logprintf(LOG_ERR, "toggle action is missing a \"DEVICE\""); - return -1; - } - if(jbetween == NULL && jbetween->tag != JSON_ARRAY) { - logprintf(LOG_ERR, "toggle action is missing a \"BETWEEN ... AND ...\" statement"); - return -1; - } - json_find_number(jdevice, "order", &nr1); - json_find_number(jbetween, "order", &nr2); - if((int)nr1 != 1 || (int)nr2 != 2) { - logprintf(LOG_ERR, "toggle actions are formatted as \"toggle DEVICE ... BETWEEN ... AND ...\""); - return -1; - } - if((jsvalues = json_find_member(jbetween, "value")) != NULL) { - jschild = json_first_child(jsvalues); - while(jschild) { - nrvalues++; - jschild = jschild->next; - } - } - if(nrvalues != 2) { - logprintf(LOG_ERR, "toggle actions are formatted as \"toggle DEVICE ... BETWEEN ... AND ...\""); - return -1; - } - if((jdvalues = json_find_member(jdevice, "value")) != NULL) { - jdchild = json_first_child(jdvalues); - while(jdchild) { - if(jdchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jdchild->string_, &dev) == 0) { - if((jsvalues = json_find_member(jbetween, "value")) != NULL) { - jschild = json_first_child(jsvalues); - while(jschild) { - if(jschild->tag == JSON_STRING) { - struct protocols_t *tmp = dev->protocols; - int match1 = 0; - while(tmp) { - struct options_t *opt = tmp->listener->options; - while(opt) { - if(opt->conftype == DEVICES_STATE) { - if(strcmp(opt->name, jschild->string_) == 0) { - match1 = 1; - break; - } - } - opt = opt->next; - } - tmp = tmp->next; - } - if(match1 == 0) { - logprintf(LOG_ERR, "device \"%s\" can't be set to state \"%s\"", jdchild->string_, jschild->string_); - return -1; - } - } else { - return -1; - } - jschild = jschild->next; - } - } - } else { - logprintf(LOG_ERR, "device \"%s\" doesn't exists", jdchild->string_); - return -1; - } - } else { - return -1; - } - jdchild = jdchild->next; - } - } else { - return -1; - } - return 0; -} - -static void *thread(void *param) { - struct event_action_thread_t *pth = (struct event_action_thread_t *)param; - // struct rules_t *obj = pth->obj; - struct JsonNode *json = pth->obj->arguments; - struct devices_settings_t *tmp_settings = pth->device->settings; - struct JsonNode *jbetween = NULL; - struct JsonNode *jsvalues = NULL; - struct JsonNode *jstate1 = NULL; - struct JsonNode *jstate2 = NULL; - char *cstate = NULL, *state1 = NULL, *state2 = NULL; - - event_action_started(pth); - - while(tmp_settings) { - if(strcmp(tmp_settings->name, "state") == 0) { - if(tmp_settings->values->type == JSON_STRING) { - cstate = tmp_settings->values->string_; - break; - } - } - tmp_settings = tmp_settings->next; - } - - if((jbetween = json_find_member(json, "BETWEEN")) != NULL) { - if((jsvalues = json_find_member(jbetween, "value")) != NULL) { - jstate1 = json_find_element(jsvalues, 0); - jstate2 = json_find_element(jsvalues, 1); - if(jstate1 != NULL && jstate2 != NULL && - jstate1->tag == JSON_STRING && jstate2->tag == JSON_STRING) { - state1 = jstate1->string_; - state2 = jstate2->string_; - - if(pilight.control != NULL) { - if(strcmp(state1, cstate) == 0) { - pilight.control(pth->device, state2, NULL, ACTION); - } else if(strcmp(state2, cstate) == 0) { - pilight.control(pth->device, state1, NULL, ACTION); - } - } - } - } - } - - event_action_stopped(pth); - - return (void *)NULL; -} - -static int run(struct rules_actions_t *obj) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jbetween = NULL; - struct JsonNode *jdvalues = NULL; - struct JsonNode *jdchild = NULL; - - if((jdevice = json_find_member(obj->arguments, "DEVICE")) != NULL && - (jbetween = json_find_member(obj->arguments, "BETWEEN")) != NULL) { - if((jdvalues = json_find_member(jdevice, "value")) != NULL) { - jdchild = json_first_child(jdvalues); - while(jdchild) { - if(jdchild->tag == JSON_STRING) { - struct devices_t *dev = NULL; - if(devices_get(jdchild->string_, &dev) == 0) { - event_action_thread_start(dev, action_toggle->name, thread, obj); - } - } - jdchild = jdchild->next; - } - } - } - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void actionToggleInit(void) { - event_action_register(&action_toggle, "toggle"); - - options_add(&action_toggle->options, 'a', "DEVICE", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&action_toggle->options, 'b', "BETWEEN", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - action_toggle->run = &run; - action_toggle->checkArguments = &checkArguments; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "toggle"; - module->version = "2.1"; - module->reqversion = "6.0"; - module->reqcommit = "58"; -} - -void init(void) { - actionToggleInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/actions/toggle.h b/lib/ESPiLight/pilight/libs/pilight/events/actions/toggle.h deleted file mode 100644 index 611b35e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/actions/toggle.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _EVENT_ACTION_TOGGLE_H_ -#define _EVENT_ACTION_TOGGLE_H_ - -#include "../action.h" - -struct event_actions_t *action_toggle; - -void actionToggleInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/events.c b/lib/ESPiLight/pilight/libs/pilight/events/events.c deleted file mode 100644 index 74ba705..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/events.c +++ /dev/null @@ -1,2204 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/config.h" -#include "../core/log.h" -#include "../core/cast.h" -#include "../core/options.h" -#include "../core/json.h" -#include "../core/ssdp.h" -#include "../core/socket.h" -#include "../datatypes/stack.h" - -#include "../lua/lua.h" - -#include "../protocols/protocol.h" - -#include "../config/rules.h" -#include "../config/settings.h" -#include "../config/devices.h" - -#include "events.h" - -#include "operator.h" -#include "function.h" -#include "action.h" - -typedef struct lexer_t { - int pos; - int ppos; - int len; - char *current_char; - struct token_t *current_token; - char *text; -} lexer_t; - -typedef struct token_t { - int type; - int pos; - char *value; -} token_t; - -typedef struct tree_t { - struct token_t *token; - struct tree_t **child; - int nrchildren; -} tree_t; - -// static struct token_string { - // char *name; -// } token_string[] = { - // { "TOPERATOR" }, - // { "TFUNCTION" }, - // { "TSTRING" }, - // { "TINTEGER" }, - // { "TEOF" }, - // { "LPAREN" }, - // { "RPAREN" }, - // { "TCOMMA" }, - // { "TIF" }, - // { "TELSE" }, - // { "TTHEN" }, - // { "TEND" }, - // { "TACTION" } -// }; - -typedef enum { - TOPERATOR = 0, - TFUNCTION = 1, - TSTRING = 2, - TINTEGER = 3, - TEOF = 4, - LPAREN = 5, - RPAREN = 6, - TCOMMA = 7, - TIF = 8, - TELSE = 9, - TTHEN = 10, - TEND = 11, - TACTION = 12 -} token_types; - -#define ORIGIN_RULE RULE -#define ORIGIN_ACTION ACTION - -static unsigned short loop = 1; -static char *dummy = "a"; -static char true_[2]; -static char false_[2]; -static char dot_[2]; - -static char *recvBuff = NULL; -static int sockfd = 0; - -static pthread_mutex_t events_lock; -static pthread_cond_t events_signal; -static pthread_mutexattr_t events_attr; -static unsigned short eventslock_init = 0; - -typedef struct eventsqueue_t { - struct JsonNode *jconfig; - struct eventsqueue_t *next; -} eventsqueue_t; - -static struct eventsqueue_t *eventsqueue; -static struct eventsqueue_t *eventsqueue_head; -static int eventsqueue_number = 0; -static int running = 0; - -static int get_precedence(char *symbol) { - struct plua_module_t *modules = plua_get_modules(); - int len = 0, x = 0; - while(modules) { - if(modules->type == OPERATOR) { - len = strlen(modules->name); - if(strnicmp(symbol, modules->name, len) == 0) { - event_operator_associativity(modules->name, &x); - return x; - } - } - modules = modules->next; - } - return -1; -} - -static int get_associativity(char *symbol) { - struct plua_module_t *modules = plua_get_modules(); - int len = 0, x = 0; - while(modules) { - if(modules->type == OPERATOR) { - len = strlen(modules->name); - if(strnicmp(symbol, modules->name, len) == 0) { - event_operator_precedence(modules->name, &x); - return x; - } - } - modules = modules->next; - } - return -1; -} - -struct event_actions_t *get_action(char *symbol, int size) { - struct event_actions_t *tmp_actions = NULL; - int len = 0; - - tmp_actions = event_actions; - while(tmp_actions) { - len = strlen(tmp_actions->name); - if((size == -1 && strnicmp(symbol, tmp_actions->name, len) == 0) || - (size == len && strnicmp(symbol, tmp_actions->name, len) == 0)) { - return tmp_actions; - } - tmp_actions = tmp_actions->next; - } - return NULL; -} - -static int is_function(char *symbol, int size) { - struct plua_module_t *modules = plua_get_modules(); - int len = 0; - while(modules) { - if(modules->type == FUNCTION) { - len = strlen(modules->name); - if((size == -1 && strnicmp(symbol, modules->name, len) == 0) || - (size == len && strnicmp(symbol, modules->name, len) == 0)) { - return len; - } - } - modules = modules->next; - } - return -1; -} - -static int is_operator(char *symbol, int size) { - struct plua_module_t *modules = plua_get_modules(); - int len = 0; - - while(modules) { - if(modules->type == OPERATOR) { - len = strlen(modules->name); - if((size == -1 && strnicmp(symbol, modules->name, len) == 0) || - (size == len && strnicmp(symbol, modules->name, len) == 0)) { - return len; - } - } - modules = modules->next; - } - return -1; -} - -void events_tree_gc(struct tree_t *tree) { - int i = 0; - if(tree == NULL) { - return; - } - for(i=0;inrchildren;i++) { - events_tree_gc(tree->child[i]); - } - if(tree->token != NULL) { - FREE(tree->token->value); - FREE(tree->token); - } - if(tree->nrchildren > 0) { - FREE(tree->child); - } - FREE(tree); -} - -int events_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - loop = 0; - - if(eventslock_init == 1) { - pthread_mutex_unlock(&events_lock); - pthread_cond_signal(&events_signal); - } - - while(running == 1) { - usleep(10); - } - - event_operator_gc(); - event_action_gc(); - event_function_gc(); - logprintf(LOG_DEBUG, "garbage collected events library"); - return 1; -} - -static int print_error(struct lexer_t *lexer, struct tree_t *p, struct tree_t *node, struct token_t *token, int err, char *expected, int pos, int trunc) { - char *p_elipses = "..."; - char *s_elipses = "..."; - char *s_tmp = ""; - char *p_tmp = ""; - int length = lexer->ppos+25; - - trunc -= 15; - - if(trunc < 0) { - trunc = 0; - } - - if(err == -1) { - while(trunc > 0 && lexer->text[trunc] != ' ') { - trunc--; - } - if(trunc > 0) { - p_tmp = p_elipses; - } - if(length < strlen(&lexer->text[trunc])) { - while(length < strlen(&lexer->text[trunc]) && lexer->text[length+trunc] != ' ') { - length++; - } - s_tmp = s_elipses; - } - if(expected != NULL) { - logprintf(LOG_ERR, - "\n%s%.*s %s\n%*s^ unexpected symbol, expected %s", - p_tmp, length, &lexer->text[trunc], s_tmp, pos+strlen(p_tmp)-trunc, " ", expected); - } else { - logprintf(LOG_ERR, - "\n%s%.*s %s\n%*s^ unexpected symbol", - p_tmp, length, &lexer->text[trunc], s_tmp, pos+strlen(p_tmp)-trunc, " "); - } - err = -2; - } - if(node != NULL) { - events_tree_gc(node); - node = NULL; - } - if(lexer->current_token != NULL) { - FREE(lexer->current_token->value); - FREE(lexer->current_token); - } - if(token != NULL) { - FREE(token->value); - FREE(token); - } - if(p != NULL) { - events_tree_gc(p); - } - - return err; -} - -/* - * TESTME: Check if right devices are cached. - */ -void event_cache_device(struct rules_t *obj, char *device) { - int exists = 0; - int o = 0; - - if(obj != NULL) { - for(o=0;onrdevices;o++) { - if(strcmp(obj->devices[o], device) == 0) { - exists = 1; - break; - } - } - if(exists == 0) { - /* Store all devices that are present in this rule */ - if((obj->devices = REALLOC(obj->devices, sizeof(char *)*(unsigned int)(obj->nrdevices+1))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - if((obj->devices[obj->nrdevices] = MALLOC(strlen(device)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(obj->devices[obj->nrdevices], device); - obj->nrdevices++; - } - } -} - -/* - * This functions checks if the defined event variable - * is part of one of devices in the config. If it is, - * replace the variable with the actual value - * - * Return codes: - * -1: An error was found and abort rule parsing - * 0: Found variable and filled varcont - * 1: Did not find variable and did not fill varcont - */ -int event_lookup_variable(char *var, struct rules_t *obj, struct varcont_t *varcont, unsigned short validate, enum origin_t origin) { - int recvtype = 0; - // int cached = 0; - if(strcmp(true_, "1") != 0) { - strcpy(true_, "1"); - } - if(strcmp(dot_, ".") != 0) { - strcpy(dot_, "."); - } - if(strcmp(false_, "0") != 0) { - strcpy(false_, "0"); - } - if(strcmp(var, "1") == 0 || strcmp(var, "0") == 0 || - strcmp(var, "true") == 0 || - strcmp(var, "false") == 0) { - if(strcmp(var, "true") == 0) { - varcont->number_ = 1; - } else if(strcmp(var, "false") == 0) { - varcont->number_ = 0; - } else { - varcont->number_ = atof(var); - } - varcont->decimals_ = 0; - varcont->type_ = JSON_NUMBER; - - return 0; - } - - int len = (int)strlen(var); - int i = 0; - int nrdots = 0; - for(i=0;istring_ = dot_; - array_free(&array, n); - varcont->type_ = JSON_STRING; - return 0; - } - - char *device = array[0]; - char *name = array[1]; - - recvtype = 0; - struct protocols_t *tmp_protocols = protocols; -#ifdef PILIGHT_REWRITE - if(devices_select(ORIGIN_MASTER, device, NULL) == 0) { - recvtype = 1; - } -#else - struct devices_t *dev = NULL; - if(devices_get(device, &dev) == 0) { - recvtype = 1; - } -#endif - if(recvtype == 0) { - while(tmp_protocols) { - if(strcmp(tmp_protocols->listener->id, device) == 0) { - recvtype = 2; - break; - } - tmp_protocols = tmp_protocols->next; - } - } - - unsigned int match1 = 0, match2 = 0, has_state = 0; - - if(recvtype == 2) { - if(validate == 1) { - if(origin == ORIGIN_RULE) { - event_cache_device(obj, device); - } - if(strcmp(name, "repeats") != 0 && strcmp(name, "uuid") != 0) { - struct options_t *options = tmp_protocols->listener->options; - while(options) { - if(options->conftype == DEVICES_STATE) { - has_state = 1; - } - if(strcmp(options->name, name) == 0) { - match2 = 1; - if(options->vartype == JSON_NUMBER) { - varcont->number_ = 0; - varcont->decimals_ = 0; - varcont->type_ = JSON_NUMBER; - } - if(options->vartype == JSON_STRING) { - varcont->string_ = dummy; - varcont->type_ = JSON_STRING; - } - } - options = options->next; - } - if(match2 == 0 && ((!(strcmp(name, "state") == 0 && has_state == 1)) || (strcmp(name, "state") != 0))) { - logprintf(LOG_ERR, "rule #%d invalid: protocol \"%s\" has no field \"%s\"", obj->nr, device, name); - varcont->string_ = NULL; - varcont->number_ = 0; - varcont->decimals_ = 0; - array_free(&array, n); - return -1; - } - } else if(!(strcmp(name, "repeats") == 0 || strcmp(name, "uuid") == 0)) { - logprintf(LOG_ERR, "rule #%d invalid: protocol \"%s\" has no field \"%s\"", obj->nr, device, name); - varcont->string_ = NULL; - varcont->number_ = 0; - varcont->decimals_ = 0; - array_free(&array, n); - return -1; - } - } - struct JsonNode *jmessage = NULL, *jnode = NULL; - if(obj->jtrigger != NULL) { - if(((jnode = json_find_member(obj->jtrigger, name)) != NULL) || - ((jmessage = json_find_member(obj->jtrigger, "message")) != NULL && - (jnode = json_find_member(jmessage, name)) != NULL)) { - if(jnode->tag == JSON_STRING) { - varcont->string_ = jnode->string_; - varcont->type_ = JSON_STRING; - array_free(&array, n); - return 0; - } else if(jnode->tag == JSON_NUMBER) { - varcont->number_ = jnode->number_; - varcont->decimals_ = jnode->decimals_; - varcont->type_ = JSON_NUMBER; - array_free(&array, n); - return 0; - } - } - } - array_free(&array, n); - return 0; - } else if(recvtype == 1) { - if(validate == 1) { - if(origin == ORIGIN_RULE) { - event_cache_device(obj, device); - } -#ifdef PILIGHT_REWRITE - struct protocol_t *tmp = NULL; - i = 0; - - while(devices_select_protocol(ORIGIN_MASTER, device, i++, &tmp) == 0) { - struct options_t *opt = tmp->options; - while(opt) { - if(opt->conftype == DEVICES_STATE && strcmp("state", name) == 0) { - match1 = 1; - match2 = 1; - break; - } else if(strcmp(opt->name, name) == 0) { - match1 = 1; - if(opt->conftype == DEVICES_VALUE || opt->conftype == DEVICES_STATE || opt->conftype == DEVICES_SETTING) { - match2 = 1; - break; - } - } - opt = opt->next; - } - } -#else - struct protocols_t *tmp = dev->protocols; - while(tmp) { - struct options_t *opt = tmp->listener->options; - while(opt) { - if(opt->conftype == DEVICES_STATE && strcmp("state", name) == 0) { - match1 = 1; - match2 = 1; - break; - } else if(strcmp(opt->name, name) == 0) { - match1 = 1; - if(opt->conftype == DEVICES_VALUE || opt->conftype == DEVICES_STATE || opt->conftype == DEVICES_SETTING) { - match2 = 1; - break; - } - } - opt = opt->next; - } - tmp = tmp->next; - } -#endif - if(match1 == 0) { - logprintf(LOG_ERR, "rule #%d invalid: device \"%s\" has no variable \"%s\"", obj->nr, device, name); - } else if(match2 == 0) { - logprintf(LOG_ERR, "rule #%d invalid: variable \"%s\" of device \"%s\" cannot be used in event rules", obj->nr, name, device); - } - if(match1 == 0 || match2 == 0) { - varcont->string_ = NULL; - varcont->number_ = 0; - varcont->decimals_ = 0; - array_free(&array, n); - return -1; - } - } - struct varcont_t val; - i = 0; - -#ifdef PILIGHT_REWRITE - char *setting = NULL; - while(devices_select_settings(ORIGIN_MASTER, device, i++, &setting, &val) == 0) { - if(strcmp(setting, name) == 0) { - if(val.type_ == JSON_STRING) { - /* Cache values for faster future lookup */ - // if(obj != NULL) { - // event_store_val_ptr(obj, device, name, tmp_settings); - // } - varcont->string_ = val.string_; - varcont->type_ = JSON_STRING; - array_free(&array, n); - return 0; - } else if(val.type_ == JSON_NUMBER) { - /* Cache values for faster future lookup */ - // if(obj != NULL) { - // event_store_val_ptr(obj, device, name, tmp_settings); - // } - varcont->number_ = val.number_; - varcont->decimals_ = val.decimals_; - varcont->type_ = JSON_NUMBER; - array_free(&array, n); - return 0; - } - } - } -#else - struct devices_settings_t *tmp_settings = dev->settings; - while(tmp_settings) { - if(strcmp(tmp_settings->name, name) == 0) { - val.type_ = tmp_settings->values->type; - if(val.type_ == JSON_STRING) { - /* Cache values for faster future lookup */ - // if(obj != NULL) { - // event_store_val_ptr(obj, device, name, tmp_settings); - // } - varcont->string_ = tmp_settings->values->string_; - varcont->type_ = JSON_STRING; - array_free(&array, n); - return 0; - } else if(val.type_ == JSON_NUMBER) { - /* Cache values for faster future lookup */ - // if(obj != NULL) { - // event_store_val_ptr(obj, device, name, tmp_settings); - // } - varcont->number_ = tmp_settings->values->number_; - varcont->decimals_ = tmp_settings->values->decimals; - varcont->type_ = JSON_NUMBER; - array_free(&array, n); - return 0; - } - } - tmp_settings = tmp_settings->next; - } -#endif - logprintf(LOG_ERR, "rule #%d invalid: device \"%s\" has no variable \"%s\"", obj->nr, device, name); - varcont->string_ = NULL; - varcont->number_ = 0; - varcont->decimals_ = 0; - array_free(&array, n); - return -1; - } - /* - * '21.00' comparison should be allowed and not be seen as config device - */ - /*else { - logprintf(LOG_ERR, "rule #%d invalid: device \"%s\" does not exist in the config", obj->nr, device); - varcont->string_ = NULL; - varcont->number_ = 0; - varcont->decimals_ = 0; - array_free(&array, n); - return -1; - }*/ - array_free(&array, n); - } else if(nrdots > 2) { - logprintf(LOG_ERR, "rule #%d invalid: variable \"%s\" is invalid", obj->nr, var); - varcont->string_ = NULL; - varcont->number_ = 0; - varcont->decimals_ = 0; - return -1; - } - - if(isNumeric(var) == 0) { - varcont->number_ = atof(var); - varcont->decimals_ = nrDecimals(var); - varcont->type_ = JSON_NUMBER; - } else { - if((varcont->string_ = STRDUP(var)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - varcont->free_ = 1; - varcont->type_ = JSON_STRING; - } - return 0; -} - - -static int lexer_parse_integer(struct lexer_t *lexer, struct stack_dt *t) { - if(isdigit(lexer->current_char[0])) { - while(lexer->pos <= lexer->len && isdigit(lexer->current_char[0])) { - dt_stack_push(t, sizeof(char *), lexer->current_char); - lexer->current_char = &lexer->text[lexer->pos++]; - } - return 0; - } else { - return -1; - } -} - -static int lexer_parse_quoted_string(struct lexer_t *lexer, struct stack_dt *t) { - int x = lexer->current_char[0]; - if(lexer->pos < lexer->len) { - lexer->current_char = &lexer->text[lexer->pos++]; - - while(lexer->pos < lexer->len) { - if(lexer->pos > 0 && strnicmp(&lexer->text[lexer->pos-1], "\\'", 2) == 0) { - /* - * Skip escape - */ - lexer->current_char = &lexer->text[lexer->pos++]; - dt_stack_push(t, sizeof(char *), lexer->current_char); - lexer->current_char = &lexer->text[lexer->pos++]; - continue; - } - if(lexer->pos > 0 && strnicmp(&lexer->text[lexer->pos-1], "\\\"", 2) == 0) { - /* - * Skip escape - */ - lexer->current_char = &lexer->text[lexer->pos++]; - dt_stack_push(t, sizeof(char *), lexer->current_char); - lexer->current_char = &lexer->text[lexer->pos++]; - continue; - } - if(lexer->current_char[0] == x) { - break; - } - dt_stack_push(t, sizeof(char *), lexer->current_char); - lexer->current_char = &lexer->text[lexer->pos++]; - } - if(lexer->current_char[0] != '"' && lexer->current_char[0] != '\'') { - dt_stack_free(t, NULL); - return print_error(lexer, NULL, NULL, NULL, -1, "a ending quote", lexer->pos, lexer->ppos-1); - } else if(lexer->pos <= lexer->len) { - lexer->current_char = &lexer->text[lexer->pos++]; - return 0; - } else { - return -1; - } - } - return -1; -} - -static int lexer_parse_string(struct lexer_t *lexer, struct stack_dt *t) { - while(lexer->pos <= lexer->len && - lexer->current_char[0] != ' ' && - lexer->current_char[0] != ',' && - lexer->current_char[0] != ')') { - dt_stack_push(t, sizeof(char *), lexer->current_char); - lexer->current_char = &lexer->text[lexer->pos++]; - } - return 0; -} - -static int lexer_parse_space(struct lexer_t *lexer) { - while(lexer->pos <= lexer->len && lexer->current_char[0] == ' ') { - lexer->current_char = &lexer->text[lexer->pos++]; - } - return 0; -} - -static char *stack_to_char(struct stack_dt *stack) { - char *c = NULL; - char *str = MALLOC(dt_stack_top(stack)+1); - int i = 0; - - if(str == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - while((c = dt_stack_pop(stack, 0)) != NULL) { - str[i++] = c[0]; - } - str[i] = '\0'; - dt_stack_free(stack, NULL); - return str; -} - -static char *min(char *numbers[], int n){ - char *m = NULL; - int i = 0; - - for(i=0;i numbers[i]) { - m = numbers[i]; - } - } - - return m; -} - -static int lexer_next_token(struct lexer_t *lexer) { - struct stack_dt *t = MALLOC(sizeof(struct stack_dt)); - int type = TEOF, ret = 0; - - if(t == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - memset(t, 0, sizeof(struct stack_dt)); - - while(lexer->pos <= lexer->len) { - lexer->ppos = lexer->pos; - if(lexer->current_char[0] == ' ') { - if(lexer_parse_space(lexer) == -1) { - return -1; - } - } - - int x = 0; - if(lexer->current_char[0] == '\'' || lexer->current_char[0] == '"') { - ret = lexer_parse_quoted_string(lexer, t); - type = TSTRING; - } else if(isdigit(lexer->current_char[0])) { - ret = lexer_parse_integer(lexer, t); - type = TINTEGER; - } else if(strnicmp(lexer->current_char, "if", 2) == 0) { - dt_stack_push(t, sizeof(char *), &lexer->current_char[0]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[1]); - type = TIF; - lexer->pos += 2; - lexer->current_char = &lexer->text[lexer->pos-1]; - } else if(strnicmp(lexer->current_char, "else", 4) == 0) { - dt_stack_push(t, sizeof(char *), &lexer->current_char[0]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[1]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[2]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[3]); - type = TELSE; - lexer->pos += 4; - lexer->current_char = &lexer->text[lexer->pos-1]; - } else if(strnicmp(lexer->current_char, "then", 4) == 0) { - dt_stack_push(t, sizeof(char *), &lexer->current_char[0]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[1]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[2]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[3]); - type = TTHEN; - lexer->pos += 4; - lexer->current_char = &lexer->text[lexer->pos-1]; - } else if(strnicmp(lexer->current_char, "end", 3) == 0) { - dt_stack_push(t, sizeof(char *), &lexer->current_char[0]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[1]); - dt_stack_push(t, sizeof(char *), &lexer->current_char[2]); - type = TEND; - lexer->pos += 3; - lexer->current_char = &lexer->text[lexer->pos-1]; - } else if(lexer->current_char[0] == ',') { - dt_stack_push(t, sizeof(char *), lexer->current_char); - type = TCOMMA; - lexer->current_char = &lexer->text[lexer->pos++]; - } else if(lexer->current_char[0] == '(') { - dt_stack_push(t, sizeof(char *), lexer->current_char); - type = LPAREN; - lexer->current_char = &lexer->text[lexer->pos++]; - } else if(lexer->current_char[0] == ')') { - dt_stack_push(t, sizeof(char *), lexer->current_char); - type = RPAREN; - lexer->current_char = &lexer->text[lexer->pos++]; - } else { - char *pos[3] = { NULL }, *m = NULL; - int len = lexer->len-(lexer->pos-1), len1 = 0; - pos[0] = strstr(lexer->current_char, " "); - pos[1] = strstr(lexer->current_char, "("); - pos[2] = strstr(lexer->current_char, ","); - if((m = min(pos, 3)) != NULL) { - len = m-lexer->current_char; - } - struct event_actions_t *action = NULL; - if((len1 = is_function(lexer->current_char, len)) > 0) { - for(x=0;xcurrent_char[x]); - } - type = TFUNCTION; - lexer->current_char = &lexer->text[lexer->pos+(len1-1)]; - lexer->pos += len1; - } else if((len1 = is_operator(lexer->current_char, len)) > 0) { - for(x=0;xcurrent_char[x]); - } - type = TOPERATOR; - lexer->current_char = &lexer->text[lexer->pos+(len1-1)]; - lexer->pos += len1; - } else if((action = get_action(lexer->current_char, len)) != NULL) { - len1 = strlen(action->name); - for(x=0;xcurrent_char[x]); - } - type = TACTION; - lexer->current_char = &lexer->text[lexer->pos+(len1-1)]; - lexer->pos += len1; - } - } - if(type == TEOF) { - ret = lexer_parse_string(lexer, t); - type = TSTRING; - } - if(type != TEOF && ret == 0) { - if((lexer->current_token = MALLOC(sizeof(struct token_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - lexer->current_token->value = stack_to_char(t); - lexer->current_token->type = type; - lexer->current_token->pos = lexer->pos; - return 0; - } else { - return ret; - } - } - if(t != NULL) { - FREE(t); - } - - lexer->current_token = NULL; - return 0; -} - -static struct tree_t *ast_parent(struct token_t *token) { - struct tree_t *tree = MALLOC(sizeof(struct tree_t)); - if(tree == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - tree->child = NULL; - tree->nrchildren = 0; - tree->token = token; - return tree; -} - -static struct tree_t *ast_child(struct tree_t *p, struct tree_t *c) { - if((p->child = REALLOC(p->child, sizeof(struct tree_t)*(p->nrchildren+1))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - p->child[p->nrchildren] = c; - p->nrchildren++; - return p; -} - -static int lexer_peek(struct lexer_t *lexer, int skip, int type, char *val) { - int pos = lexer->pos, i = 0, ret = -1; - struct token_t *tmp = lexer->current_token; - char *c = lexer->current_char; - - if(skip > 0) { - for(i=0;icurrent_token != NULL) { - FREE(lexer->current_token->value); - FREE(lexer->current_token); - } - } - } - - if(type == TEOF && lexer->current_token == NULL) { - goto good; - } else if(lexer->current_token != NULL && lexer->current_token->type == type) { - if(val != NULL) { - if(stricmp(lexer->current_token->value, val) == 0) { - goto good; - } else { - ret = -1; - goto bad; - } - } else { - goto good; - } - } else { - ret = -1; - goto bad; - } - -good: - if(skip > 0 && lexer->current_token != NULL) { - FREE(lexer->current_token->value); - FREE(lexer->current_token); - } - lexer->pos = pos; - lexer->current_token = tmp; - lexer->current_char = c; - return 0; -bad: - if(skip > 0 && lexer->current_token != NULL) { - FREE(lexer->current_token->value); - FREE(lexer->current_token); - } - lexer->pos = pos; - lexer->current_token = tmp; - lexer->current_char = c; - - return ret; -} - -static int lexer_eat(struct lexer_t *lexer, int type, struct token_t **token_out) { - struct token_t *token = lexer->current_token; - int ret = -1; - - if((type == TEOF && lexer->current_token == NULL) || - (lexer->current_token != NULL && lexer->current_token->type == type)) { - if((ret = lexer_next_token(lexer)) < 0) { - *token_out = NULL; - return ret; - } - } else { - if(lexer->current_token != NULL) { - FREE(lexer->current_token->value); - FREE(lexer->current_token); - } - *token_out = NULL; - return -1; - } - *token_out = token; - return 0; -} - -static int lexer_expr(struct lexer_t *lexer, struct tree_t *tree, struct tree_t **tree_out); -static int lexer_term(struct lexer_t *lexer, struct tree_t *tree, int precedence, struct tree_t **tree_out); - -static int lexer_factor(struct lexer_t *lexer, struct tree_t *tree_in, struct tree_t **tree_out) { - struct token_t *token = lexer->current_token; - struct token_t *token_ret = NULL; - char *expected = NULL; - int pos = 0, err = -2; - - if(token != NULL) { - switch(token->type) { - case TSTRING: { - if((err = lexer_eat(lexer, TSTRING, &token_ret)) < 0) { - goto error; - } - *tree_out = ast_parent(token); - return 0; - } break; - case TINTEGER: { - if((err = lexer_eat(lexer, TINTEGER, &token_ret)) < 0) { - goto error; - } - *tree_out = ast_parent(token); - return 0; - } break; - case LPAREN: { - if((err = lexer_eat(lexer, LPAREN, &token_ret)) < 0) { - goto error; - } - FREE(token_ret->value); - FREE(token_ret); - if((err = lexer_expr(lexer, tree_in, tree_out)) < 0) { - goto error; - } - pos = (*tree_out)->token->pos+1; - if((err = lexer_eat(lexer, RPAREN, &token_ret)) < 0) { - char *tmp = "a closing parenthesis"; - expected = tmp; - pos += 1; - goto error; - } - FREE(token_ret->value); - FREE(token_ret); - return 0; - } break; - } - } - - *tree_out = NULL; - return -1; - -error: - return print_error(lexer, NULL, *tree_out, token_ret, err, expected, pos, lexer->ppos-1); -} - -static int lexer_parse_function(struct lexer_t *lexer, struct tree_t *tree_in, struct tree_t **tree_out) { - struct tree_t *node = NULL; - struct token_t *token = lexer->current_token, *token_ret = NULL; - struct tree_t *p = ast_parent(token); - char *expected = NULL; - int pos = 0, err = -1; - - if((err = lexer_eat(lexer, TFUNCTION, &token_ret)) < 0) { - *tree_out = NULL; - return err; - } - if((err = lexer_eat(lexer, LPAREN, &token_ret)) < 0) { - *tree_out = NULL; - return err; - } - FREE(token_ret->value); - FREE(token_ret); - - if((err = lexer_term(lexer, tree_in, 0, &node)) == 0) { - ast_child(p, node); - } else { - events_tree_gc(p); - *tree_out = NULL; - return err; - } - pos = node->token->pos+1; - while(1) { - if((err = lexer_eat(lexer, TCOMMA, &token_ret)) < 0) { - char *tmp = "a comma or closing parenthesis"; - pos -= strlen(node->token->value); - lexer->ppos -= 2; - expected = tmp; - events_tree_gc(p); - err = -1; - goto error; - } - FREE(token_ret->value); - FREE(token_ret); - if(lexer_term(lexer, tree_in, 0, &node) == 0) { - ast_child(p, node); - } - if(lexer_peek(lexer, 0, RPAREN, NULL) == 0) { - break; - } - pos = node->token->pos+1; - } - - if(lexer->current_token == NULL) { - char *tmp = "a closing parenthesis"; - expected = tmp; - err = -1; - goto error; - } - - if((err = lexer_eat(lexer, RPAREN, &token_ret)) < 0) { - char *tmp = "a closing parenthesis"; - expected = tmp; - pos = lexer->pos; - err = -1; - goto error; - } - FREE(token_ret->value); - FREE(token_ret); - - *tree_out = p; - return 0; - -error: - return print_error(lexer, NULL, NULL, NULL, err, expected, pos, lexer->ppos-1); -} - -static void print_ast(struct tree_t *tree); - -static int lexer_parse_action(struct lexer_t *lexer, struct tree_t *tree_in, struct tree_t **tree_out) { - struct event_actions_t *action = NULL; - struct options_t *options = NULL; - struct tree_t *node = NULL; - struct tree_t *p = NULL; - struct tree_t *p1 = NULL; - struct tree_t *tree_ret = NULL; - struct token_t *token = lexer->current_token, *token_ret = NULL; - char *expected = NULL; - int len = strlen(token->value), match = 0, pos = 0, err = -1; - - p = ast_parent(token); - - action = get_action(token->value, len); - if(action != NULL) { - if((err = lexer_eat(lexer, TACTION, &token_ret)) < 0) { - *tree_out = NULL; - return -1; - } - /* - * In case we enter a recursive action action, we - * want to be able to free the string leading to - * that situation. E.g.: - * - * ... THEN switch DEVICE switch - * - * We want to be able to free the 'DEVICE' string. - */ - if(lexer_peek(lexer, 0, TSTRING, NULL) < 0) { - if(lexer_peek(lexer, 0, TACTION, NULL) == 0) { - char *tmp = "a string but got an action"; - expected = tmp; - } else { - char *tmp = "an action argument"; - expected = tmp; - } - pos = token->pos; - err = -1; - goto error; - } - while(1) { - pos = lexer->pos; - if(lexer_peek(lexer, 0, TEOF, NULL) == 0 || - lexer_peek(lexer, 0, TELSE, NULL) == 0 || - lexer_peek(lexer, 0, TEND, NULL) == 0) { - break; - } - if(lexer_peek(lexer, 0, TACTION, NULL) == 0) { - if(lexer_term(lexer, tree_in, 0, &tree_ret) == 0) { - ast_child(p, tree_ret); - } - break; - } - if((err = lexer_eat(lexer, TSTRING, &token_ret)) < 0) { - char *tmp = "an action argument"; - if(token_ret != NULL) { - pos -= strlen(token_ret->value)+1; - } - lexer->ppos -= lexer->ppos-pos; - expected = tmp; - goto error; - } else { - match = 0; - options = action->options; - while(options != NULL) { - if(stricmp(token_ret->value, options->name) == 0) { - match = 1; - break; - } - options = options->next; - } - if(match == 0) { - char *tmp = "an action argument"; - pos -= strlen(token_ret->value)+1; - lexer->ppos -= lexer->ppos-pos; - expected = tmp; - FREE(token_ret->value); - FREE(token_ret); - err = -1; - goto error; - } - p1 = ast_parent(token_ret); - ast_child(p, p1); - /* - * In case we a arguments is combined like this - * THEN switch BETWEEN on AND off - */ - if(lexer_peek(lexer, 1, TOPERATOR, "and") == 0) { - while(lexer_peek(lexer, 1, TOPERATOR, "and") == 0) { - if(lexer_peek(lexer, 0, TINTEGER, NULL) == 0) { - if((err = lexer_eat(lexer, TINTEGER, &token_ret)) < 0) { - char *tmp = "a string, number or function"; - expected = tmp; - err = -1; - goto error; - } - ast_child(p1, ast_parent(token_ret)); - } else if(lexer_peek(lexer, 0, TSTRING, NULL) == 0) { - if((err = lexer_eat(lexer, TSTRING, &token_ret)) < 0) { - char *tmp = "a string, number or function"; - expected = tmp; - err = -1; - goto error; - } - ast_child(p1, ast_parent(token_ret)); - } - if((err = lexer_eat(lexer, TOPERATOR, &token_ret)) < 0) { - char *tmp = "an 'and' operator"; - expected = tmp; - err = -1; - goto error; - } - FREE(token_ret->value); - FREE(token_ret); - } - if(lexer_peek(lexer, 0, TINTEGER, NULL) == 0) { - if((err = lexer_eat(lexer, TINTEGER, &token_ret)) < 0) { - char *tmp = "a string, number or function"; - expected = tmp; - goto error; - } - ast_child(p1, ast_parent(token_ret)); - } else if(lexer_peek(lexer, 0, TSTRING, NULL) == 0) { - if((err = lexer_eat(lexer, TSTRING, &token_ret)) < 0) { - char *tmp = "a string, number or function"; - expected = tmp; - err = -1; - goto error; - } - ast_child(p1, ast_parent(token_ret)); - } - } else { - if(lexer_peek(lexer, 0, TACTION, NULL) == 0) { - char *tmp = "a string, number, or function, got an action"; - expected = tmp; - lexer->ppos -= strlen(lexer->current_token->value)+1; - err = -1; - goto error; - } - if((err = lexer_term(lexer, tree_in, 0, &node)) < 0) { - char *tmp = "a string, number or function"; - expected = tmp; - goto error; - } - ast_child(p1, node); - } - } - } - } else { - *tree_out = NULL; - return -1; - } - - *tree_out = p; - return 0; - -error: - return print_error(lexer, p, NULL, NULL, err, expected, pos, lexer->ppos-1); -} - -static int lexer_parse_if(struct lexer_t *lexer, struct tree_t *tree, struct tree_t **tree_out) { - struct tree_t *node = NULL; - struct token_t *token = lexer->current_token, *token_ret = NULL; - struct tree_t *p = ast_parent(token); - char *expected = NULL; - int pos = 0, err = -1; - - if((err = lexer_eat(lexer, TIF, &token_ret)) < 0) { - *tree_out = NULL; - return -1; - } - if((err = lexer_term(lexer, tree, 0, &node)) == 0) { - ast_child(p, node); - } else { - char *tmp = "a condition"; - expected = tmp; - pos = lexer->pos; - goto error; - } - - token = lexer->current_token; - pos = token->pos; - - if((err = lexer_eat(lexer, TTHEN, &token_ret)) < 0) { - char *tmp = "a condition"; - expected = tmp; - err = -1; - goto error; - } - pos = token->pos; - FREE(token->value); - FREE(token); - if(lexer_peek(lexer, 0, TACTION, NULL) < 0 && lexer_peek(lexer, 0, TIF, NULL) < 0) { - if((err = lexer_peek(lexer, 0, TACTION, NULL)) < 0) { - char *tmp = "an action"; - expected = tmp; - err = -1; - goto error; - } - } - if((err = lexer_term(lexer, tree, 0, &node)) == 0) { - ast_child(p, node); - } else { - char *tmp = "an action"; - expected = tmp; - goto error; - } - if(lexer_peek(lexer, 0, TELSE, NULL) == 0) { - token = lexer->current_token; - if((err = lexer_eat(lexer, TELSE, &token_ret)) < 0) { - *tree_out = NULL; - return -1; - } - FREE(token->value); - FREE(token); - if(lexer_term(lexer, tree, 0, &node) == 0) { - ast_child(p, node); - } - if(lexer_peek(lexer, 0, TACTION, NULL) < 0 && lexer_peek(lexer, 0, TIF, NULL) < 0 && - lexer_peek(lexer, 0, TEND, NULL) < 0 && lexer_peek(lexer, 0, TEOF, NULL) < 0) { - if((err = lexer_peek(lexer, 0, TACTION, NULL)) < 0) { - char *tmp = "an action"; - expected = tmp; - err = -1; - goto error; - } - } - } - if(lexer_peek(lexer, 0, TEND, NULL) == 0) { - token = lexer->current_token; - if((err = lexer_eat(lexer, TEND, &token_ret)) < 0) { - *tree_out = NULL; - return -1; - } - FREE(token->value); - FREE(token); - } else if(lexer_peek(lexer, 0, TEOF, NULL) == 0) { - if((err = lexer_eat(lexer, TEOF, &token_ret)) < 0) { - *tree_out = NULL; - return -1; - } - } else { - token = lexer->current_token; - if((err = lexer_eat(lexer, TEND, &token_ret)) < 0) { - *tree_out = NULL; - return -1; - } - FREE(token->value); - FREE(token); - } - - *tree_out = p; - return 0; - -error: - return print_error(lexer, p, NULL, NULL, err, expected, pos, lexer->ppos-1); -} - -/* - * Always annoying when you reinvented an already existing - * algorithm without knowing it :) - * - * An implementation of precedence climbing - */ -static int lexer_term(struct lexer_t *lexer, struct tree_t *tree_in, int precedence, struct tree_t **tree_out) { - struct token_t *token = NULL, *token_ret = NULL; - struct tree_t *node = NULL, *tree_ret = NULL; - struct tree_t *p = NULL; - char *expected = NULL; - int pos = 0, err = -1; - - int match = 0, x = 0; - struct plua_module_t *modules = plua_get_modules(); - while(modules) { - if(modules->type == OPERATOR) { - event_operator_associativity(modules->name, &x); - if(x > precedence) { - match = 1; - break; - } - } - modules = modules->next; - } - - if(match == 0) { - if((err = lexer_factor(lexer, tree_in, &tree_ret)) < 0) { - *tree_out = NULL; - return err; - } else { - *tree_out = tree_ret; - return 0; - } - } - - err = lexer_term(lexer, tree_in, precedence+1, &node); - if(lexer->current_token != NULL) { - switch(lexer->current_token->type) { - case TIF: { - if((err = lexer_parse_if(lexer, tree_in, &tree_ret)) < 0) { - *tree_out = NULL; - char *tmp = "an action"; - expected = tmp; - pos = lexer->pos; - goto error; - } - *tree_out = tree_ret; - return 0; - } break; - case TACTION: { - if(node != NULL) { - if(node->token->value != NULL) { - FREE(node->token->value); - } - if(node->token != NULL) { - FREE(node->token); - } - FREE(node); - node = NULL; - } - if((err = lexer_parse_action(lexer, tree_in, &tree_ret)) < 0) { - *tree_out = NULL; - goto error; - } - *tree_out = tree_ret; - return 0; - } break; - case TFUNCTION: { - if((err = lexer_parse_function(lexer, tree_in, &tree_ret)) < 0) { - *tree_out = NULL; - char *tmp = "an action"; - expected = tmp; - pos = lexer->pos; - goto error; - } - if(lexer_peek(lexer, 0, TFUNCTION, NULL) == 0) { - *tree_out = NULL; - char *tmp = "an operator"; - expected = tmp; - pos = lexer->pos-strlen(lexer->current_token->value)-1; - events_tree_gc(tree_ret); - err = -1; - goto error; - } - if(node != NULL) { - ast_child(node, tree_ret); - *tree_out = node; - } else { - *tree_out = tree_ret; - } - return 0; - } break; - case TOPERATOR: { - int tpos = lexer->ppos; - int z = get_precedence(lexer->current_token->value); - int y = get_associativity(lexer->current_token->value); - if((z == precedence && y == 1) || z > precedence) { - if(lexer->current_token->type == TEOF) { - *tree_out = node; - goto error; - } - token = lexer->current_token; - if((err = lexer_eat(lexer, TOPERATOR, &token_ret)) < 0) { - *tree_out = NULL; - return -1; - } - if(z == -1) { - if((err = lexer_term(lexer, tree_in, precedence, &tree_ret)) < 0) { - char *tmp = "an operand"; - expected = tmp; - lexer->ppos = tpos; - pos = token->pos; - goto error; - } - if(tree_ret->token->type == TACTION) { - char *tmp = "an operand, got an action"; - expected = tmp; - lexer->ppos = tpos; - pos = token->pos; - err = -1; - events_tree_gc(tree_ret); - goto error; - } - p = ast_parent(token); - ast_child(p, node); - ast_child(p, tree_ret); - *tree_out = p; - return 0; - } else { - if((err = lexer_term(lexer, tree_in, precedence+1, &tree_ret)) < 0) { - char *tmp = "an operand"; - expected = tmp; - pos = token->pos; - lexer->ppos = tpos; - goto error; - } - if(tree_ret->token->type == TACTION) { - char *tmp = "an operand, got an action"; - expected = tmp; - pos = token->pos; - lexer->ppos = tpos; - err = -1; - events_tree_gc(tree_ret); - goto error; - } - p = ast_parent(token); - ast_child(p, node); - ast_child(p, tree_ret); - *tree_out = p; - return 0; - } - } - } break; - } - } - - if((*tree_out = node) == NULL) { - return err; - } - return 0; - -error: - return print_error(lexer, p, node, token, err, expected, pos, lexer->ppos-1); -} - -static int lexer_expr(struct lexer_t *lexer, struct tree_t *tree, struct tree_t **out) { - return lexer_term(lexer, tree, 0, out); -} - -static int lexer_parse(struct lexer_t *lexer, struct tree_t **tree_out) { - struct tree_t *tree = MALLOC(sizeof(struct tree_t)); - int err = -1; - - if(tree == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(tree, 0, sizeof(struct tree_t)); - - if((err = lexer_expr(lexer, tree, tree_out)) < 0) { - if(err == -1) { - err = print_error(lexer, tree, NULL, NULL, err, NULL, lexer->pos+1, lexer->ppos-1); - } else { - events_tree_gc(tree); - } - return err; - } else { - if(lexer->current_token != NULL && lexer->current_token->type != TEOF) { - FREE(tree); - return -1; - } - - FREE(tree); - } - return 0; -} - -static void print_ast(struct tree_t *tree) { - int i = 0; - if(tree == NULL) { - return; - } - for(i=0;inrchildren;i++) { - if(tree->child[i]->token != NULL) { - printf("\"%p\" [label=\"%s\"];\n", tree->token->value, tree->token->value); - printf("\"%p\" [label=\"%s\"];\n", tree->child[i]->token->value, tree->child[i]->token->value); - printf("\"%p\" -> ", tree->token->value); - printf("\"%p\";\n", tree->child[i]->token->value); - } - print_ast(tree->child[i]); - } - - if(tree->nrchildren == 0 && tree->token != NULL) { - printf("\"%p\" [label=\"%s\"];\n", tree->token->value, tree->token->value); - printf("\"%p\";\n", tree->token->value); - } -} - -static int interpret(struct tree_t *tree, struct rules_t *obj, unsigned short validate, struct varcont_t *v); - -static void varcont_free(struct varcont_t *v) { - if(v->free_ == 1) { - if(v->type_ == JSON_STRING) { - FREE(v->string_); - } - v->free_ = 0; - } -} - -static int run_function(struct tree_t *tree, struct rules_t *obj, unsigned short validate, struct varcont_t *v) { - struct event_function_args_t *args = NULL; - struct varcont_t v_res, v1; - int i = 0; - - for(i=0;inrchildren;i++) { - memset(&v_res, '\0', sizeof(struct varcont_t)); - memset(&v1, '\0', sizeof(struct varcont_t)); - - if(interpret(tree->child[i], obj, validate, &v_res) == -1) { - v = NULL; - return -1; - } - if(v_res.type_ == JSON_STRING) { - if(event_lookup_variable(v_res.string_, obj, &v1, validate, ORIGIN_RULE) == -1) { - varcont_free(&v1); - varcont_free(&v_res); - return -1; - } else { - args = event_function_add_argument(&v1, args); - varcont_free(&v1); - varcont_free(&v_res); - } - } else { - args = event_function_add_argument(&v_res, args); - } - } - - memset(&v_res, '\0', sizeof(struct varcont_t)); - if(event_function_callback(tree->token->value, args, v) == -1) { - return -1; - } - - return 0; -} - -static int run_action(struct tree_t *tree, struct rules_t *obj, unsigned short validate, struct varcont_t *v_out) { - struct JsonNode *jobject = json_mkobject(); - struct JsonNode *jparam = NULL; - struct JsonNode *jvalues = NULL; - struct varcont_t v_res, v_res1, v1; - struct rules_actions_t *node = NULL; - struct event_actions_t *action = NULL; - char *key = NULL; - int i = 0, x = 0, match = 0; - - action = get_action(tree->token->value, strlen(tree->token->value)); - - for(i=0;inrchildren;i++) { - if(tree->child[i]->token->type == TACTION) { - if(interpret(tree->child[i], obj, validate, &v_res) == -1) { - v_out = NULL; - return -1; - } - continue; - } - memset(&v_res1, '\0', sizeof(struct varcont_t)); - memset(&v_res, '\0', sizeof(struct varcont_t)); - memset(&v1, '\0', sizeof(struct varcont_t)); - - jparam = json_mkobject(); - jvalues = json_mkarray(); - json_append_member(jparam, "order", json_mknumber(i+1, 0)); - json_append_member(jparam, "value", jvalues); - if(interpret(tree->child[i], obj, validate, &v_res) == -1) { - v_out = NULL; - return -1; - } - key = v_res.string_; - - for(x=0;xchild[i]->nrchildren;x++) { - if(interpret(tree->child[i]->child[x], obj, validate, &v_res1) == -1) { - v_out = NULL; - return -1; - } - - switch(v_res1.type_) { - case JSON_STRING: { - if(event_lookup_variable(v_res1.string_, obj, &v1, validate, ORIGIN_RULE) == -1) { - varcont_free(&v1); - varcont_free(&v_res); - varcont_free(&v_res1); - v_out = NULL; - return -1; - } else { - switch(v1.type_) { - case JSON_NUMBER: { - json_append_element(jvalues, json_mknumber(v1.number_, v1.decimals_)); - } break; - case JSON_STRING: { - json_append_element(jvalues, json_mkstring(v1.string_)); - } break; - case JSON_BOOL: { - json_append_element(jvalues, json_mkbool(v1.bool_)); - } break; - } - varcont_free(&v1); - } - } break; - case JSON_NUMBER: { - json_append_element(jvalues, json_mknumber(v_res1.number_, v_res1.decimals_)); - } break; - case JSON_BOOL: { - json_append_element(jvalues, json_mkbool(v_res1.bool_)); - } break; - } - varcont_free(&v_res1); - } - json_append_member(jobject, key, jparam); - varcont_free(&v_res); - } - - node = obj->actions; - while(node) { - if(node->ptr == tree) { - match = 1; - break; - } - node = node->next; - } - if(match == 0) { - if((node = MALLOC(sizeof(struct rules_actions_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->ptr = tree; - node->rule = obj; - node->arguments = NULL; - node->next = obj->actions; - obj->actions = node; - } - - if(node->arguments != NULL) { - json_delete(node->arguments); - node->arguments = NULL; - } - - node->arguments = jobject; - if(action != NULL) { - if(validate == 1) { - if(action->checkArguments != NULL) { - if(action->checkArguments(node) == -1) { - return -1; - } - } - } else { - if(action->run != NULL) { - if(action->run(node) == -1) { - return -1; - } - } - } - } - - v_out->bool_ = 1; - v_out->type_ = JSON_BOOL; - return 0; -} - -static int interpret(struct tree_t *tree, struct rules_t *obj, unsigned short validate, struct varcont_t *v_out) { - struct varcont_t v_res; - memset(&v_res, 0, sizeof(struct varcont_t)); - if(tree == NULL) { - return -1; - } - - switch(tree->token->type) { - case TACTION: { - if(run_action(tree, obj, validate, v_out) == -1) { - return -1; - } - return 0; - } break; - case TFUNCTION: { - if(run_function(tree, obj, validate, v_out) == -1) { - return -1; - } - return 0; - } break; - case TSTRING: { - v_out->string_ = tree->token->value; - v_out->type_ = JSON_STRING; - return 0; - } break; - case TINTEGER: { - v_out->number_ = atof(tree->token->value); - v_out->decimals_ = nrDecimals(tree->token->value); - v_out->type_ = JSON_NUMBER; - return 0; - } break; - case TIF: { - if(interpret(tree->child[0], obj, validate, &v_res) == -1) { - varcont_free(&v_res); - return -1; - } else { - if(v_res.type_ != JSON_BOOL) { - logprintf(LOG_ERR, "If condition did not result in a boolean expression"); - return -1; - } - if(v_res.bool_ == 1) { - varcont_free(&v_res); - if(interpret(tree->child[1], obj, validate, &v_res) == -1) { - varcont_free(&v_res); - return -1; - } - memcpy(v_out, &v_res, sizeof(struct varcont_t)); - varcont_free(&v_res); - return 0; - } else if(tree->nrchildren == 3) { - varcont_free(&v_res); - if(interpret(tree->child[2], obj, validate, &v_res) == -1) { - varcont_free(&v_res); - return -1; - } - memcpy(v_out, &v_res, sizeof(struct varcont_t)); - varcont_free(&v_res); - return 0; - } else { - v_out->bool_ = 1; - v_out->type_ = JSON_BOOL; - varcont_free(&v_res); - return 0; - } - } - varcont_free(&v_res); - return -1; - } break; - case TOPERATOR: { - struct varcont_t v1, v2, v3, v4; - - memset(&v1, '\0', sizeof(struct varcont_t)); - memset(&v2, '\0', sizeof(struct varcont_t)); - memset(&v3, '\0', sizeof(struct varcont_t)); - memset(&v4, '\0', sizeof(struct varcont_t)); - - if(event_operator_exists(tree->token->value) == 0) { - if(interpret(tree->child[0], obj, validate, &v1) == -1) { - varcont_free(&v1); - return -1; - } - if(interpret(tree->child[1], obj, validate, &v2) == -1) { - varcont_free(&v2); - return -1; - } - if(v1.type_ == JSON_STRING) { - if(event_lookup_variable(v1.string_, obj, &v3, validate, ORIGIN_RULE) == -1) { - varcont_free(&v1); - return -1; - } else { - varcont_free(&v1); - switch(v3.type_) { - case JSON_STRING: { - if((v1.string_ = STRDUP(v3.string_)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - v1.free_ = 1; - v1.type_ = JSON_STRING; - } break; - case JSON_NUMBER: { - v1.number_ = v3.number_; - v1.decimals_ = v3.decimals_; - v1.type_ = JSON_NUMBER; - } break; - case JSON_BOOL: { - v1.bool_ = v3.bool_; - v1.type_ = JSON_BOOL; - } break; - } - varcont_free(&v3); - } - } - if(v2.type_ == JSON_STRING) { - if(event_lookup_variable(v2.string_, obj, &v4, validate, ORIGIN_RULE) == -1) { - varcont_free(&v2); - return -1; - } else { - varcont_free(&v2); - switch(v4.type_) { - case JSON_STRING: { - if((v2.string_ = STRDUP(v4.string_)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - v2.free_ = 1; - v2.type_ = JSON_STRING; - } break; - case JSON_NUMBER: { - v2.number_ = v4.number_; - v2.decimals_ = v4.decimals_; - v2.type_ = JSON_NUMBER; - } break; - case JSON_BOOL: { - v2.bool_ = v4.bool_; - v2.type_ = JSON_BOOL; - } break; - } - varcont_free(&v4); - } - } - if(event_operator_callback(tree->token->value, &v1, &v2, v_out) != 0) { - logprintf(LOG_ERR, "rule #%d: an unexpected error occurred while parsing", obj->nr); - varcont_free(&v1); - varcont_free(&v2); - return -1; - } - varcont_free(&v1); - varcont_free(&v2); - return 0; - } else { - return -1; - } - } break; - } - - v_out->bool_ = 0; - v_out->type_ = JSON_BOOL; - return 0; -} - -int event_parse_rule(char *rule, struct rules_t *obj, int depth, unsigned short validate) { - struct varcont_t v_res; - - if(validate == 1) { - struct lexer_t *lexer = MALLOC(sizeof(struct lexer_t)); - if(lexer == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(lexer, 0, sizeof(struct lexer_t)); - - if((lexer->text = STRDUP(rule)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - lexer->pos = 0; - lexer->len = strlen(lexer->text); - lexer->current_char = &lexer->text[lexer->pos++]; - - if(lexer_next_token(lexer) == -1) { - FREE(lexer->text); - FREE(lexer); - return -1; - } - if(lexer_parse(lexer, &obj->tree) == -1) { - FREE(lexer->text); - FREE(lexer); - return -1; - } - if(pilight.debuglevel >= 1) { - logprintf(LOG_DEBUG, "%s", lexer->text); - print_ast(obj->tree); - } - FREE(lexer->text); - FREE(lexer); - } - - if(interpret(obj->tree, obj, validate, &v_res) == -1) { - return -1; - } - if(v_res.type_ == JSON_BOOL) { - return v_res.bool_; - } - return -1; -} - -void *events_loop(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(eventslock_init == 0) { - pthread_mutexattr_init(&events_attr); - pthread_mutexattr_settype(&events_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&events_lock, &events_attr); - pthread_cond_init(&events_signal, NULL); - eventslock_init = 1; - } - - struct devices_t *dev = NULL; - struct JsonNode *jdevices = NULL, *jchilds = NULL; - struct rules_t *tmp_rules = NULL; - char *str = NULL, *origin = NULL, *protocol = NULL; - unsigned short match = 0; - unsigned int i = 0; - - pthread_mutex_lock(&events_lock); - while(loop) { - if(eventsqueue_number > 0) { - pthread_mutex_lock(&events_lock); - - logprintf(LOG_STACK, "%s::unlocked", __FUNCTION__); - - running = 1; - - jdevices = json_find_member(eventsqueue->jconfig, "devices"); - tmp_rules = rules_get(); - while(tmp_rules) { - if(tmp_rules->active == 1) { - if(eventsqueue->jconfig != NULL) { - char *conf = json_stringify(eventsqueue->jconfig, NULL); - tmp_rules->jtrigger = json_decode(conf); - json_free(conf); - } - - match = 0; - if((str = MALLOC(strlen(tmp_rules->rule)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(str, tmp_rules->rule); - if(json_find_string(eventsqueue->jconfig, "origin", &origin) == 0 && - json_find_string(eventsqueue->jconfig, "protocol", &protocol) == 0) { - if(strcmp(origin, "sender") == 0 || strcmp(origin, "receiver") == 0) { - for(i=0;inrdevices;i++) { - if(strcmp(tmp_rules->devices[i], protocol) == 0) { - match = 1; - break; - } - } - } - } - /* Only run those events that affect the updates devices */ - if(jdevices != NULL && match == 0) { - jchilds = json_first_child(jdevices); - while(jchilds) { - for(i=0;inrdevices;i++) { - if(jchilds->tag == JSON_STRING && - strcmp(jchilds->string_, tmp_rules->devices[i]) == 0) { - if(devices_get(jchilds->string_, &dev) == 0) { - if(dev->lastrule == tmp_rules->nr && - tmp_rules->nr == dev->prevrule && - dev->lastrule == dev->prevrule) { - logprintf(LOG_ERR, "skipped rule #%d because of an infinite loop triggered by device %s", tmp_rules->nr, jchilds->string_); - } else { - match = 1; - } - } else { - match = 1; - } - break; - } - } - jchilds = jchilds->next; - } - } - if(match == 1 && tmp_rules->status == 0) { -#ifndef WIN32 - clock_gettime(CLOCK_MONOTONIC, &tmp_rules->timestamp.first); -#endif - if(event_parse_rule(str, tmp_rules, 0, 0) == 0) { - if(tmp_rules->status == 1) { - logprintf(LOG_INFO, "executed rule: %s", tmp_rules->name); - } - } -#ifndef WIN32 - clock_gettime(CLOCK_MONOTONIC, &tmp_rules->timestamp.second); - logprintf(LOG_DEBUG, "rule #%d %s was parsed in %.6f seconds", tmp_rules->nr, tmp_rules->name, - ((double)tmp_rules->timestamp.second.tv_sec + 1.0e-9*tmp_rules->timestamp.second.tv_nsec) - - ((double)tmp_rules->timestamp.first.tv_sec + 1.0e-9*tmp_rules->timestamp.first.tv_nsec)); -#endif - tmp_rules->status = 0; - } - FREE(str); - if(tmp_rules->jtrigger != NULL) { - json_delete(tmp_rules->jtrigger); - tmp_rules->jtrigger = NULL; - } - } - tmp_rules = tmp_rules->next; - } - struct eventsqueue_t *tmp = eventsqueue; - json_delete(tmp->jconfig); - eventsqueue = eventsqueue->next; - FREE(tmp); - eventsqueue_number--; - pthread_mutex_unlock(&events_lock); - } else { - running = 0; - pthread_cond_wait(&events_signal, &events_lock); - } - } - return (void *)NULL; -} - -int events_running(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - return (running == 1) ? 0 : -1; -} -static void events_queue(char *message) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(eventslock_init == 1) { - pthread_mutex_lock(&events_lock); - } - if(eventsqueue_number < 1024) { - struct eventsqueue_t *enode = MALLOC(sizeof(eventsqueue_t)); - if(enode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - enode->jconfig = json_decode(message); - - if(eventsqueue_number == 0) { - eventsqueue = enode; - eventsqueue_head = enode; - } else { - eventsqueue_head->next = enode; - eventsqueue_head = enode; - } - - eventsqueue_number++; - } else { - logprintf(LOG_ERR, "event queue full"); - } - if(eventslock_init == 1) { - pthread_mutex_unlock(&events_lock); - pthread_cond_signal(&events_signal); - } -} - -void *events_clientize(void *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct JsonNode *jclient = NULL; - struct JsonNode *joptions = NULL; - struct ssdp_list_t *ssdp_list = NULL; - char *out = NULL; - int standalone = 0; - int client_loop = 0; - settings_find_number("standalone", &standalone); - - while(loop) { - - if(client_loop == 1) { - sleep(1); - } - client_loop = 1; - - ssdp_list = NULL; - if(ssdp_seek(&ssdp_list) == -1 || standalone == 1) { - logprintf(LOG_NOTICE, "no pilight ssdp connections found"); - char server[16] = "127.0.0.1"; - if((sockfd = socket_connect(server, (unsigned short)socket_get_port())) == -1) { - logprintf(LOG_ERR, "could not connect to pilight-daemon"); - continue; - } - } else { - if((sockfd = socket_connect(ssdp_list->ip, ssdp_list->port)) == -1) { - logprintf(LOG_ERR, "could not connect to pilight-daemon"); - continue; - } - } - - if(ssdp_list != NULL) { - ssdp_free(ssdp_list); - } - - jclient = json_mkobject(); - joptions = json_mkobject(); - json_append_member(jclient, "action", json_mkstring("identify")); - json_append_member(joptions, "config", json_mknumber(1, 0)); - json_append_member(joptions, "receiver", json_mknumber(1, 0)); - json_append_member(jclient, "options", joptions); - json_append_member(jclient, "media", json_mkstring("all")); - out = json_stringify(jclient, NULL); - if(socket_write(sockfd, out) != (strlen(out)+strlen(EOSS))) { - json_free(out); - json_delete(jclient); - continue; - } - json_free(out); - json_delete(jclient); - - if(socket_read(sockfd, &recvBuff, 0) != 0 - || strcmp(recvBuff, "{\"status\":\"success\"}") != 0) { - continue; - } - - while(client_loop) { - if(sockfd <= 0) { - break; - } - if(loop == 0) { - client_loop = 0; - break; - } - - int z = socket_read(sockfd, &recvBuff, 1); - if(z == -1) { - sockfd = 0; - break; - } else if(z == 1) { - continue; - } - - char **array = NULL; - unsigned int n = explode(recvBuff, "\n", &array), i = 0; - for(i=0;i 0) { - socket_close(sockfd); - } - return (void *)NULL; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/events/events.h b/lib/ESPiLight/pilight/libs/pilight/events/events.h deleted file mode 100644 index af14af0..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/events.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _EVENTS_H_ -#define _EVENTS_H_ - -#include "../config/rules.h" -#include "../core/common.h" - -void events_tree_gc(struct tree_t *tree); -void event_cache_device(struct rules_t *obj, char *device); -int event_lookup_variable(char *var, struct rules_t *obj, struct varcont_t *varcont, unsigned short validate, enum origin_t origin); -int event_parse_rule(char *rule, struct rules_t *obj, int depth, unsigned short validate); -void *events_clientize(void *param); -int events_gc(void); -void event_init(void); -void *events_loop(void *param); -int events_running(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/function.c b/lib/ESPiLight/pilight/libs/pilight/events/function.c deleted file mode 100644 index 93abe90..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/function.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #include -#endif - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/options.h" -#include "../core/dso.h" -#include "../core/log.h" -#include "../lua/lua.h" -#include "../config/settings.h" - -#include "function.h" - -static int init = 0; - -void event_function_init(void) { - if(init == 1) { - return; - } - init = 1; - plua_init(); - - char path[PATH_MAX]; - char *f = STRDUP(__FILE__); - struct dirent *file = NULL; - DIR *d = NULL; - struct stat s; - char *functions_root = FUNCTION_ROOT; - - if(f == NULL) { - OUT_OF_MEMORY - } - -#ifdef PILIGHT_REWRITE - settings_select_string(ORIGIN_MASTER, "functions-root", &functions_root); -#else - settings_find_string("functions-root", &functions_root); -#endif - - if((d = opendir(functions_root))) { - while((file = readdir(d)) != NULL) { - memset(path, '\0', PATH_MAX); - sprintf(path, "%s%s", functions_root, file->d_name); - if(stat(path, &s) == 0) { - /* Check if file */ - if(S_ISREG(s.st_mode)) { - if(strstr(file->d_name, ".lua") != NULL) { - plua_module_load(path, FUNCTION); - } - } - } - } - } - closedir(d); - FREE(f); -} - -static int plua_function_module_run(struct lua_State *L, char *file, struct event_function_args_t *args, struct varcont_t *v) { -#if LUA_VERSION_NUM <= 502 - lua_getfield(L, -1, "run"); - if(strcmp(lua_typename(L, lua_type(L, -1)), "function") != 0) { -#else - if(lua_getfield(L, -1, "run") == 0) { -#endif - logprintf(LOG_ERR, "%s: run function missing", file); - return 0; - } - - int nrargs = 0; - struct event_function_args_t *tmp1 = NULL; - while(args) { - tmp1 = args; - nrargs++; - switch(tmp1->var.type_) { - case JSON_NUMBER: { - char *tmp = NULL; - int len = snprintf(NULL, 0, "%.*f", tmp1->var.decimals_, tmp1->var.number_); - if((tmp = MALLOC(len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(tmp, 0, len+1); - sprintf(tmp, "%.*f", tmp1->var.decimals_, tmp1->var.number_); - lua_pushstring(L, tmp); - FREE(tmp); - } break; - case JSON_STRING: - lua_pushstring(L, tmp1->var.string_); - FREE(tmp1->var.string_); - break; - case JSON_BOOL: - lua_pushboolean(L, tmp1->var.bool_); - break; - } - args = args->next; - FREE(tmp1); - } - args = NULL; - - if(lua_pcall(L, nrargs, 1, 0) == LUA_ERRRUN) { - if(strcmp(lua_typename(L, lua_type(L, -1)), "nil") == 0) { - logprintf(LOG_ERR, "%s: syntax error", file); - return 0; - } - if(strcmp(lua_typename(L, lua_type(L, -1)), "string") == 0) { - logprintf(LOG_ERR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return 0; - } - } - - if(lua_isstring(L, -1) == 0 && - lua_isnumber(L, -1) == 0 && - lua_isboolean(L, -1) == 0) { - logprintf(LOG_ERR, "%s: the run function returned %s, string, number or boolean expected", file, lua_typename(L, lua_type(L, -1))); - return 0; - } - - if(lua_isnumber(L, -1) == 1) { - char *p = (char *)lua_tostring(L, -1); - v->number_ = atof(p); - v->decimals_ = nrDecimals(p); - v->type_ = JSON_NUMBER; - } else if(lua_isstring(L, -1) == 1) { - int l = strlen(lua_tostring(L, -1)); - if((v->string_ = REALLOC(v->string_, l+1)) == NULL) { - OUT_OF_MEMORY - } - strcpy(v->string_, lua_tostring(L, -1)); - v->type_ = JSON_STRING; - v->free_ = 1; - } else if(lua_isboolean(L, -1) == 1) { - v->bool_ = (int)lua_toboolean(L, -1); - v->type_ = JSON_BOOL; - } - - lua_pop(L, 1); - - return 1; -} - -int event_function_exists(char *module) { - return plua_module_exists(module, FUNCTION); -} - -struct event_function_args_t *event_function_add_argument(struct varcont_t *var, struct event_function_args_t *head) { - struct event_function_args_t *node = MALLOC(sizeof(struct event_function_args_t)); - if(node == NULL) { - OUT_OF_MEMORY - } - memset(node, 0, sizeof(struct event_function_args_t)); - switch(var->type_) { - case JSON_NUMBER: { - node->var.type_ = JSON_NUMBER; - node->var.number_ = var->number_; - node->var.decimals_ = var->decimals_; - } break; - case JSON_STRING: { - node->var.type_ = JSON_STRING; - if((node->var.string_ = STRDUP(var->string_)) == NULL) { - OUT_OF_MEMORY - } - } break; - case JSON_BOOL: { - node->var.type_ = JSON_BOOL; - node->var.bool_ = var->bool_; - } break; - } - if(head != NULL) { - struct event_function_args_t *tmp = head; - while(tmp->next != NULL) { - tmp = tmp->next; - } - tmp->next = node; - node = tmp; - } else { - node->next = head; - head = node; - } - return head; -} - -void event_function_free_argument(struct event_function_args_t *args) { - struct event_function_args_t *tmp1 = NULL; - while(args) { - tmp1 = args; - switch(tmp1->var.type_) { - case JSON_STRING: - FREE(tmp1->var.string_); - break; - } - args = args->next; - FREE(tmp1); - } -} - -int event_function_callback(char *module, struct event_function_args_t *args, struct varcont_t *v) { - struct lua_state_t *state = plua_get_free_state(); - struct lua_State *L = NULL; - - if(state == NULL) { - return -1; - } - if((L = state->L) == NULL) { - uv_mutex_unlock(&state->lock); - return -1; - } - - char name[255], *p = name; - memset(name, '\0', 255); - - sprintf(p, "function.%s", module); - - lua_getglobal(L, name); - if(lua_isnil(L, -1) != 0) { - event_function_free_argument(args); - uv_mutex_unlock(&state->lock); - return -1; - } - if(lua_istable(L, -1) != 0) { - char *file = NULL; - struct plua_module_t *tmp = plua_get_modules(); - while(tmp) { - if(strcmp(module, tmp->name) == 0) { - file = tmp->file; - state->module = tmp; - break; - } - tmp = tmp->next; - } - if(file != NULL) { - if(plua_function_module_run(L, file, args, v) == 0) { - lua_pop(L, -1); - uv_mutex_unlock(&state->lock); - return -1; - } - } else { - event_function_free_argument(args); - uv_mutex_unlock(&state->lock); - return -1; - } - } - lua_pop(L, -1); - - uv_mutex_unlock(&state->lock); - - return 0; -} - -int event_function_gc(void) { - init = 0; - logprintf(LOG_DEBUG, "garbage collected event function library"); - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/events/function.h b/lib/ESPiLight/pilight/libs/pilight/events/function.h deleted file mode 100644 index d4cd32e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/function.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _FUNCTION_H_ -#define _FUNCTION_H_ - -#include "../core/common.h" - -#include "events.h" /* rewrite */ - -struct event_function_args_t { - struct varcont_t var; - struct event_function_args_t *next; -} event_function_args_t; - -void event_function_init(void); -int event_function_callback(char *, struct event_function_args_t *, struct varcont_t *v); -struct event_function_args_t *event_function_add_argument(struct varcont_t *, struct event_function_args_t *); -void event_function_free_argument(struct event_function_args_t *); -int event_function_exists(char *); -int event_function_gc(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/functions/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/events/functions/CMakeLists.txt deleted file mode 100644 index 83ae99d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/functions/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB functions "${PROJECT_SOURCE_DIR}/functions/*.lua") -if(WIN32) - install(FILES ${functions} DESTINATION functions/ COMPONENT pilight) -else() - install(FILES ${functions} DESTINATION lib/pilight/functions/ COMPONENT pilight) -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/events/functions/date_add.lua b/lib/ESPiLight/pilight/libs/pilight/events/functions/date_add.lua deleted file mode 100644 index 7851ac1..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/functions/date_add.lua +++ /dev/null @@ -1,80 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -local function split(s, delimiter) - result = {}; - for match in (s..delimiter):gmatch("(.-)"..delimiter) do - table.insert(result, match); - end - return result; -end - -local function tablelength(T) - local count = 0 - for _ in pairs(T) do count = count + 1 end - return count -end - -function M.run(a, b, c) - local tm = nil; - local e = nil; - - if c ~= nil then - error("DATE_ADD requires two arguments"); - return nil; - elseif a ~= nil and b ~= nil then - tm = pilight.getdevice(a); - if tm == nil then - tm = pilight.strptime("%Y-%m-%d %H:%M:%S", a); - end - array = split(b, ' '); - if tablelength(array) ~= 2 then - error(string.format("DATE_ADD got an invalid unit \"%s\"", b)); - end - number = array[1]; - unit = array[2]; - else - error("DATE_ADD requires two arguments"); - return nil; - end - - if tonumber(number) == nil then - error(string.format("DATE_ADD unit parameter must be numeric, \"%s\" given", type(number))); - return nil; - end - - if unit == 'YEAR' then - tm['year'] = tm['year'] + number; - elseif unit == 'MONTH' then - tm['month'] = tm['month'] + number; - elseif unit == 'DAY' then - tm['day'] = tm['day'] + number; - elseif unit == 'HOUR' then - tm['hour'] = tm['hour'] + number; - elseif unit == 'MINUTE' then - tm['min'] = tm['min'] + number; - elseif unit == 'SECOND' then - tm['sec'] = tm['sec'] + number; - else - error(string.format("DATE_ADD does not accept \"%s\" as a unit", unit)); - return nil; - end - local t = os.time(tm); - return os.date("%Y-%m-%d %H:%M:%S", t); -end - -function M.info() - return { - name = "DATE_ADD", - version = "2.0", - reqversion = "7.0", - reqcommit = "94" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/functions/date_format.lua b/lib/ESPiLight/pilight/libs/pilight/events/functions/date_format.lua deleted file mode 100644 index 9f6f5e9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/functions/date_format.lua +++ /dev/null @@ -1,43 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b, c, d) - local tm = nil; - local e = nil; - - if d ~= nil then - error("DATE_FORMAT requires no more than three arguments"); - return nil; - elseif a ~= nil and b ~= nil and c ~= nil then - e = c; - tm = pilight.strptime(b, a); - elseif a ~= nil and b ~= nil then - e = b; - tm = pilight.getdevice(a); - if tm == nil then - error(string.format("DATE_FORMAT device \"%s\" is not a datetime protocol", a)); - end - else - error("DATE_FORMAT requires at least two arguments"); - return nil; - end - local t = os.time(tm); - return os.date(e, t); -end - - -function M.info() - return { - name = "DATE_FORMAT", - version = "1.0", - reqversion = "6.0", - reqcommit = "94" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/functions/random.lua b/lib/ESPiLight/pilight/libs/pilight/events/functions/random.lua deleted file mode 100644 index 69b698f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/functions/random.lua +++ /dev/null @@ -1,33 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b, c) - if (a == nil or b == nil) or c ~= nil then - error("RANDOM requires two arguments"); - end - if tonumber(a) == nil then - error(string.format("RANDOM argument #1 expected number, \"%s\" given", type(a))); - end - if tonumber(b) == nil then - error(string.format("RANDOM argument #2 expected number, \"%s\" given", type(b))); - end - - return pilight.random(a, b); -end - - -function M.info() - return { - name = "RANDOM", - version = "2.1", - reqversion = "7.0", - reqcommit = "94" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operator.c b/lib/ESPiLight/pilight/libs/pilight/events/operator.c deleted file mode 100644 index 9c0118b..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operator.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #include - #include -#endif - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/dso.h" -#include "../core/log.h" -#include "../config/settings.h" -#include "../lua/lua.h" - -#include "operator.h" - -static int init = 0; - -void event_operator_init(void) { - if(init == 1) { - return; - } - init = 1; - plua_init(); - - char path[PATH_MAX]; - char *f = STRDUP(__FILE__); - struct dirent *file = NULL; - DIR *d = NULL; - struct stat s; - char *operator_root = OPERATOR_ROOT; - - if(f == NULL) { - OUT_OF_MEMORY - } - -#ifdef PILIGHT_REWRITE - settings_select_string(ORIGIN_MASTER, "operators-root", &operator_root); -#else - settings_find_string("operators-root", &operator_root); -#endif - - if((d = opendir(operator_root))) { - while((file = readdir(d)) != NULL) { - memset(path, '\0', PATH_MAX); - sprintf(path, "%s%s", operator_root, file->d_name); - if(stat(path, &s) == 0) { - /* Check if file */ - if(S_ISREG(s.st_mode)) { - if(strstr(file->d_name, ".lua") != NULL) { - plua_module_load(path, OPERATOR); - } - } - } - } - } - closedir(d); - FREE(f); -} - -static int plua_operator_precedence_run(struct lua_State *L, char *file, int *ret) { -#if LUA_VERSION_NUM <= 502 - lua_getfield(L, -1, "precedence"); - if(strcmp(lua_typename(L, lua_type(L, -1)), "function") != 0) { -#else - if(lua_getfield(L, -1, "precedence") == 0) { -#endif - logprintf(LOG_ERR, "%s: precedence function missing", file); - return 0; - } - - if(lua_pcall(L, 0, 1, 0) == LUA_ERRRUN) { - if(strcmp(lua_typename(L, lua_type(L, -1)), "nil") == 0) { - logprintf(LOG_ERR, "%s: syntax error", file); - return 0; - } - if(strcmp(lua_typename(L, lua_type(L, -1)), "string") == 0) { - logprintf(LOG_ERR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return 0; - } - } - - if(lua_isnumber(L, -1) == 0) { - logprintf(LOG_ERR, "%s: the precedence function returned %s, number expected", file, lua_typename(L, lua_type(L, -1))); - return 0; - } - - *ret = lua_tonumber(L, -1); - - lua_pop(L, 1); - - return 1; -} - -static int plua_operator_associativity_run(struct lua_State *L, char *file, int *ret) { -#if LUA_VERSION_NUM <= 502 - lua_getfield(L, -1, "associativity"); - if(strcmp(lua_typename(L, lua_type(L, -1)), "function") != 0) { -#else - if(lua_getfield(L, -1, "associativity") == 0) { -#endif - logprintf(LOG_ERR, "%s: associativity function missing", file); - return 0; - } - - if(lua_pcall(L, 0, 1, 0) == LUA_ERRRUN) { - if(strcmp(lua_typename(L, lua_type(L, -1)), "nil") == 0) { - logprintf(LOG_ERR, "%s: syntax error", file); - return 0; - } - if(strcmp(lua_typename(L, lua_type(L, -1)), "string") == 0) { - logprintf(LOG_ERR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return 0; - } - } - - if(lua_isnumber(L, -1) == 0) { - logprintf(LOG_ERR, "%s: the associativity function returned %s, number expected", file, lua_typename(L, lua_type(L, -1))); - return 0; - } - - *ret = lua_tonumber(L, -1); - - lua_pop(L, 1); - - return 1; -} - -static int plua_operator_module_run(struct lua_State *L, char *file, struct varcont_t *a, struct varcont_t *b, struct varcont_t *v) { -#if LUA_VERSION_NUM <= 502 - lua_getfield(L, -1, "run"); - if(strcmp(lua_typename(L, lua_type(L, -1)), "function") != 0) { -#else - if(lua_getfield(L, -1, "run") == 0) { -#endif - logprintf(LOG_ERR, "%s: run function missing", file); - return 0; - } - - switch(a->type_) { - case JSON_NUMBER: { - lua_pushnumber(L, a->number_); - } break; - case JSON_STRING: - lua_pushstring(L, a->string_); - break; - case JSON_BOOL: - lua_pushboolean(L, a->bool_); - break; - } - switch(b->type_) { - case JSON_NUMBER: { - lua_pushnumber(L, b->number_); - } break; - case JSON_STRING: - lua_pushstring(L, b->string_); - break; - case JSON_BOOL: - lua_pushboolean(L, b->bool_); - break; - } - - if(lua_pcall(L, 2, 1, 0) == LUA_ERRRUN) { - if(strcmp(lua_typename(L, lua_type(L, -1)), "nil") == 0) { - logprintf(LOG_ERR, "%s: syntax error", file); - return 0; - } - if(strcmp(lua_typename(L, lua_type(L, -1)), "string") == 0) { - logprintf(LOG_ERR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return 0; - } - } - - if(lua_isstring(L, -1) == 0 && - lua_isnumber(L, -1) == 0 && - lua_isboolean(L, -1) == 0) { - logprintf(LOG_ERR, "%s: the run function returned %s, string, number or boolean expected", file, lua_typename(L, lua_type(L, -1))); - return 0; - } - - if(lua_isnumber(L, -1) == 1) { - char *p = (char *)lua_tostring(L, -1); - v->number_ = atof(p); - v->decimals_ = nrDecimals(p); - v->type_ = JSON_NUMBER; - } else if(lua_isstring(L, -1) == 1) { - int l = strlen(lua_tostring(L, -1)); - if((v->string_ = REALLOC(v->string_, l+1)) == NULL) { - OUT_OF_MEMORY - } - strcpy(v->string_, lua_tostring(L, -1)); - v->type_ = JSON_STRING; - v->free_ = 1; - } else if(lua_isboolean(L, -1) == 1) { - v->bool_ = (int)lua_toboolean(L, -1); - v->type_ = JSON_BOOL; - } - - lua_pop(L, 1); - - return 1; -} - -int event_operator_exists(char *module) { - return plua_module_exists(module, OPERATOR); -} - -int event_operator_precedence(char *module, int *ret) { - struct lua_state_t *state = plua_get_free_state(); - struct lua_State *L = NULL; - - if(state == NULL) { - return -1; - } - - if((L = state->L) == NULL) { - uv_mutex_unlock(&state->lock); - return -1; - } - - char name[255], *p = name; - memset(name, '\0', 255); - - sprintf(p, "operator.%s", module); - - lua_getglobal(L, name); - if(lua_isnil(L, -1) != 0) { - uv_mutex_unlock(&state->lock); - return -1; - } - if(lua_istable(L, -1) != 0) { - char *file = NULL; - struct plua_module_t *tmp = plua_get_modules(); - while(tmp) { - if(strcmp(module, tmp->name) == 0) { - file = tmp->file; - state->module = tmp; - break; - } - tmp = tmp->next; - } - if(plua_operator_precedence_run(L, file, ret) == 0) { - lua_pop(L, -1); - uv_mutex_unlock(&state->lock); - return -1; - } - } - lua_pop(L, -1); - - uv_mutex_unlock(&state->lock); - - return 0; -} - -int event_operator_associativity(char *module, int *ret) { - struct lua_state_t *state = plua_get_free_state(); - struct lua_State *L = NULL; - - if(state == NULL) { - return -1; - } - - if((L = state->L) == NULL) { - uv_mutex_unlock(&state->lock); - return -1; - } - - char name[255], *p = name; - memset(name, '\0', 255); - - sprintf(p, "operator.%s", module); - - lua_getglobal(L, name); - if(lua_isnil(L, -1) != 0) { - uv_mutex_unlock(&state->lock); - return -1; - } - if(lua_istable(L, -1) != 0) { - char *file = NULL; - struct plua_module_t *tmp = plua_get_modules(); - while(tmp) { - if(strcmp(module, tmp->name) == 0) { - file = tmp->file; - state->module = tmp; - break; - } - tmp = tmp->next; - } - if(plua_operator_associativity_run(L, file, ret) == 0) { - lua_pop(L, -1); - uv_mutex_unlock(&state->lock); - return -1; - } - } - lua_pop(L, -1); - - uv_mutex_unlock(&state->lock); - - return 0; -} - -int event_operator_callback(char *module, struct varcont_t *a, struct varcont_t *b, struct varcont_t *v) { - struct lua_state_t *state = plua_get_free_state(); - struct lua_State *L = NULL; - - if(state == NULL) { - return -1; - } - - if((L = state->L) == NULL) { - uv_mutex_unlock(&state->lock); - return -1; - } - - char name[255], *p = name; - memset(name, '\0', 255); - - sprintf(p, "operator.%s", module); - - lua_getglobal(L, name); - if(lua_isnil(L, -1) != 0) { - uv_mutex_unlock(&state->lock); - return -1; - } - if(lua_istable(L, -1) != 0) { - char *file = NULL; - struct plua_module_t *tmp = plua_get_modules(); - while(tmp) { - if(strcmp(module, tmp->name) == 0) { - file = tmp->file; - state->module = tmp; - break; - } - tmp = tmp->next; - } - if(plua_operator_module_run(L, file, a, b, v) == 0) { - lua_pop(L, -1); - uv_mutex_unlock(&state->lock); - return -1; - } - } - lua_pop(L, -1); - - uv_mutex_unlock(&state->lock); - - return 0; -} - -int event_operator_gc(void) { - init = 0; - logprintf(LOG_DEBUG, "garbage collected event operator library"); - return 0; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operator.h b/lib/ESPiLight/pilight/libs/pilight/events/operator.h deleted file mode 100644 index 20b2f5f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operator.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _EVENT_OPERATOR_H_ -#define _EVENT_OPERATOR_H_ - -#include "../core/common.h" - -#include "events.h" /* rewrite */ - -void event_operator_init(void); -int event_operator_callback(char *, struct varcont_t *, struct varcont_t *, struct varcont_t *v); -int event_operator_associativity(char *, int *); -int event_operator_precedence(char *, int *); -int event_operator_exists(char *); -int event_operator_gc(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/events/operators/CMakeLists.txt deleted file mode 100644 index 9061200..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB operators "${PROJECT_SOURCE_DIR}/operators/*.lua") -if(WIN32) - install(FILES ${operators} DESTINATION operators/ COMPONENT pilight) -else() - install(FILES ${operators} DESTINATION lib/pilight/operators/ COMPONENT pilight) -endif() \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/and.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/and.lua deleted file mode 100644 index b9f8b2d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/and.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if pilight.toboolean(a) == true and pilight.toboolean(b) == true then - return true; - else - return false; - end -end - -function M.associativity() - return 20; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "AND", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/concat.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/concat.lua deleted file mode 100644 index b9b9211..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/concat.lua +++ /dev/null @@ -1,30 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - return a .. b; -end - -function M.associativity() - return 40; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = ".", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/divide.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/divide.lua deleted file mode 100644 index 27a9754..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/divide.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if pilight.tonumber(a) == 0 or pilight.tonumber(b) == 0 then - return 0; - else - return (pilight.tonumber(a) / pilight.tonumber(b)); - end -end - -function M.associativity() - return 70; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "/", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/eq.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/eq.lua deleted file mode 100644 index 571370a..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/eq.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if a == b then - return true; - else - return false; - end -end - -function M.associativity() - return 30; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "==", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/ge.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/ge.lua deleted file mode 100644 index a414062..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/ge.lua +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if tonumber(a) == nil or tonumber(b) == nil then - if a >= b then - return true; - else - return false; - end - else - if pilight.tonumber(a) >= pilight.tonumber(b) then - return true; - else - return false; - end - end -end - -function M.associativity() - return 30; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = ">=", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/gt.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/gt.lua deleted file mode 100644 index cd9fcea..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/gt.lua +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if tonumber(a) == nil or tonumber(b) == nil then - if a > b then - return true; - else - return false; - end - else - if pilight.tonumber(a) > pilight.tonumber(b) then - return true; - else - return false; - end - end -end - -function M.associativity() - return 30; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = ">", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/intdivide.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/intdivide.lua deleted file mode 100644 index 50c7ad8..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/intdivide.lua +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if pilight.tonumber(a) == 0 or pilight.tonumber(b) == 0 then - return 0; - else - aa = pilight.tonumber(a); - bb = pilight.tonumber(b); - if aa < 0 then - return -math.floor(-aa / bb); - else - return math.floor(aa / bb); - end - end -end - -function M.associativity() - return 70; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "\\", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/le.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/le.lua deleted file mode 100644 index 36d565c..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/le.lua +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if tonumber(a) == nil or tonumber(b) == nil then - if a <= b then - return true; - else - return false; - end - else - if pilight.tonumber(a) <= pilight.tonumber(b) then - return true; - else - return false; - end - end -end - -function M.associativity() - return 30; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "<=", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/lt.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/lt.lua deleted file mode 100644 index cb384ba..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/lt.lua +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if tonumber(a) == nil or tonumber(b) == nil then - if a < b then - return true; - else - return false; - end - else - if pilight.tonumber(a) < pilight.tonumber(b) then - return true; - else - return false; - end - end -end - -function M.associativity() - return 30; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "<", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/minus.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/minus.lua deleted file mode 100644 index a73c869..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/minus.lua +++ /dev/null @@ -1,30 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - return pilight.tonumber(a) - pilight.tonumber(b); -end - -function M.associativity() - return 60; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "-", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/modulus.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/modulus.lua deleted file mode 100644 index d89bcea..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/modulus.lua +++ /dev/null @@ -1,37 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if pilight.tonumber(a) == 0 or pilight.tonumber(b) == 0 then - return 0; - else - aa = pilight.tonumber(a); - bb = pilight.tonumber(b); - - return (aa - bb * math.floor(aa / bb)); - end -end - -function M.associativity() - return 70; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "%", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/multiply.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/multiply.lua deleted file mode 100644 index 4f1f2cc..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/multiply.lua +++ /dev/null @@ -1,30 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - return pilight.tonumber(a) * pilight.tonumber(b); -end - -function M.associativity() - return 70; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "*", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/ne.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/ne.lua deleted file mode 100644 index da14d51..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/ne.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if a ~= b then - return true; - else - return false; - end -end - -function M.associativity() - return 30; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "!=", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/or.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/or.lua deleted file mode 100644 index ca3a458..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/or.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - if pilight.toboolean(a) == true or pilight.toboolean(b) == true then - return true; - else - return false; - end -end - -function M.associativity() - return 10; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "OR", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/events/operators/plus.lua b/lib/ESPiLight/pilight/libs/pilight/events/operators/plus.lua deleted file mode 100644 index 4946353..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/events/operators/plus.lua +++ /dev/null @@ -1,30 +0,0 @@ --- Copyright (C) 2013 - 2016 CurlyMo - --- This Source Code Form is subject to the terms of the Mozilla Public --- License, v. 2.0. If a copy of the MPL was not distributed with this --- file, You can obtain one at http://mozilla.org/MPL/2.0/. - -local M = {} - -function M.run(a, b) - return pilight.tonumber(a) + pilight.tonumber(b); -end - -function M.associativity() - return 60; -end - -function M.precedence() - return 1; -end - -function M.info() - return { - name = "+", - version = "1.0", - reqversion = "5.0", - reqcommit = "87" - } -end - -return M; \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/433gpio.c b/lib/ESPiLight/pilight/libs/pilight/hardware/433gpio.c deleted file mode 100644 index f2780c1..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/433gpio.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include - -#include "../../libuv/uv.h" -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/dso.h" -#include "../core/log.h" -#include "../core/json.h" -#include "../core/eventpool.h" -#ifdef PILIGHT_REWRITE -#include "hardware.h" -#else -#include "../config/hardware.h" -#include "../config/settings.h" -#endif -#include "433gpio.h" - -static int gpio_433_in = -1; -static int gpio_433_out = -1; -static int pollpri = UV_PRIORITIZED; - -#if defined(__arm__) || defined(__mips__) || defined(PILIGHT_UNITTEST) -typedef struct timestamp_t { - unsigned long first; - unsigned long second; -} timestamp_t; - -typedef struct data_t { - int rbuffer[1024]; - int rptr; -} data_t; - -static struct data_t data; -static struct timestamp_t timestamp; - -static void *reason_received_pulsetrain_free(void *param) { - struct reason_received_pulsetrain_t *data = param; - FREE(data); - return NULL; -} - -static void *reason_send_code_success_free(void *param) { - struct reason_send_code_success_free *data = param; - FREE(data); - return NULL; -} - -static void poll_cb(uv_poll_t *req, int status, int events) { - int duration = 0; - int fd = req->io_watcher.fd; - - if(events & pollpri) { - uint8_t c = 0; - - (void)read(fd, &c, 1); - lseek(fd, 0, SEEK_SET); - - struct timeval tv; - gettimeofday(&tv, NULL); - timestamp.first = timestamp.second; - timestamp.second = 1000000 * (unsigned int)tv.tv_sec + (unsigned int)tv.tv_usec; - - duration = (int)((int)timestamp.second-(int)timestamp.first); - - if(duration > 0) { - data.rbuffer[data.rptr++] = duration; - if(data.rptr > MAXPULSESTREAMLENGTH-1) { - data.rptr = 0; - } - if(duration > gpio433->mingaplen) { - /* Let's do a little filtering here as well */ - if(data.rptr >= gpio433->minrawlen && data.rptr <= gpio433->maxrawlen) { - struct reason_received_pulsetrain_t *data1 = MALLOC(sizeof(struct reason_received_pulsetrain_t)); - if(data1 == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - data1->length = data.rptr; - memcpy(data1->pulses, data.rbuffer, data.rptr*sizeof(int)); - data1->hardware = gpio433->id; - - eventpool_trigger(REASON_RECEIVED_PULSETRAIN, reason_received_pulsetrain_free, data1); - } - data.rptr = 0; - } - } - }; - if(events & UV_DISCONNECT) { - FREE(req); /*LCOV_EXCL_LINE*/ - } - return; -} - -static void *gpio433Send(int reason, void *param) { - struct reason_send_code_t *data1 = param; - int *code = data1->pulses; - int rawlen = data1->rawlen; - int repeats = data1->txrpt; - - int r = 0, x = 0; - if(gpio_433_out >= 0) { - for(r=0;rmessage, data1->message); - strcpy(data2->uuid, data1->uuid); - eventpool_trigger(REASON_CODE_SEND_SUCCESS, reason_send_code_success_free, data2); - return NULL; -} -#endif - -static unsigned short int gpio433HwInit(void) { -#if defined(__arm__) || defined(__mips__) || defined(PILIGHT_UNITTEST) - - /* Make sure the pilight sender gets - the highest priority available */ -#ifdef _WIN32 - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); -#else - struct sched_param sched; - memset(&sched, 0, sizeof(sched)); - sched.sched_priority = 80; - pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched); -#endif - - uv_poll_t *poll_req = NULL; - char *platform = GPIO_PLATFORM; - -#ifdef PILIGHT_REWRITE - if(settings_select_string(ORIGIN_MASTER, "gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "no gpio-platform configured"); - return EXIT_FAILURE; - } - if(wiringXSetup(platform, _logprintf) < 0) { - return EXIT_FAILURE; - } -#else - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "no gpio-platform configured"); - return EXIT_FAILURE; - } - if(wiringXSetup(platform, logprintf1) < 0) { - return EXIT_FAILURE; - } -#endif - if(gpio_433_out >= 0) { - if(wiringXValidGPIO(gpio_433_out) != 0) { - logprintf(LOG_ERR, "invalid sender pin: %d", gpio_433_out); - return EXIT_FAILURE; - } - pinMode(gpio_433_out, PINMODE_OUTPUT); - } - if(gpio_433_in >= 0) { - if(wiringXValidGPIO(gpio_433_in) != 0) { - logprintf(LOG_ERR, "invalid receiver pin: %d", gpio_433_in); - return EXIT_FAILURE; - } - if(wiringXISR(gpio_433_in, ISR_MODE_BOTH) < 0) { - logprintf(LOG_ERR, "unable to register interrupt for pin %d", gpio_433_in); - return EXIT_FAILURE; - } - } - if(gpio_433_in >= 0) { - if((poll_req = MALLOC(sizeof(uv_poll_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - int fd = wiringXSelectableFd(gpio_433_in); - memset(data.rbuffer, '\0', sizeof(data.rbuffer)); - data.rptr = 0; - - uv_poll_init(uv_default_loop(), poll_req, fd); - -#ifdef PILIGHT_UNITTEST - char *dev = getenv("PILIGHT_433GPIO_READ"); - if(dev == NULL) { - pollpri = UV_PRIORITIZED; /*LCOV_EXCL_LINE*/ - } else { - pollpri = UV_READABLE; - } -#endif - uv_poll_start(poll_req, pollpri, poll_cb); - } - - eventpool_callback(REASON_SEND_CODE, gpio433Send); - - return EXIT_SUCCESS; -#else - logprintf(LOG_ERR, "the 433gpio module is not supported on this hardware", gpio_433_in); - return EXIT_FAILURE; -#endif -} - -static unsigned short gpio433Settings(struct JsonNode *json) { - if(strcmp(json->key, "receiver") == 0) { - if(json->tag == JSON_NUMBER) { - gpio_433_in = (int)json->number_; - } else { - return EXIT_FAILURE; - } - } - if(strcmp(json->key, "sender") == 0) { - if(json->tag == JSON_NUMBER) { - gpio_433_out = (int)json->number_; - } else { - return EXIT_FAILURE; - } - } - if(gpio_433_out > -1 && gpio_433_in > -1 && gpio_433_in == gpio_433_out) { - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void gpio433Init(void) { - hardware_register(&gpio433); - hardware_set_id(gpio433, "433gpio"); - - options_add(&gpio433->options, 'r', "receiver", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9-]+$"); - options_add(&gpio433->options, 's', "sender", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9-]+$"); - - gpio433->minrawlen = 1000; - gpio433->maxrawlen = 0; - gpio433->mingaplen = 5100; - gpio433->maxgaplen = 10000; - - gpio433->hwtype=RF433; - gpio433->comtype=COMOOK; - gpio433->init=&gpio433HwInit; - gpio433->settings=&gpio433Settings; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "433gpio"; - module->version = "2.0"; - module->reqversion = "8.0"; - module->reqcommit = NULL; -} - -void init(void) { - gpio433Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/433gpio.h b/lib/ESPiLight/pilight/libs/pilight/hardware/433gpio.h deleted file mode 100644 index fb97816..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/433gpio.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _HARDWARE_GPIO_433_H_ -#define _HARDWARE_GPIO_433_H_ - -#include "../config/hardware.h" - -struct hardware_t *gpio433; -void gpio433Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/433lirc.c b/lib/ESPiLight/pilight/libs/pilight/hardware/433lirc.c deleted file mode 100644 index bb5661d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/433lirc.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/dso.h" -#include "../core/log.h" -#include "../core/json.h" -#include "../core/gc.h" -#include "../config/hardware.h" -#include "433lirc.h" - -#define FREQ433 433920 -#define FREQ38 38000 - -static int lirc_433_initialized = 0; -static int lirc_433_setfreq = 0; -static int lirc_433_fd = 0; -static char *lirc_433_socket = NULL; - -static unsigned short lirc433HwInit(void) { - unsigned int freq = 0; - int fd = 0, i = 0, count = 0; - int c = 0; - - if(strcmp(lirc_433_socket, "/var/lirc/lircd") == 0) { - logprintf(LOG_ERR, "refusing to connect to lircd socket"); - return EXIT_FAILURE; - } - - if(lirc_433_initialized == 0) { - if((lirc_433_fd = open(lirc_433_socket, O_RDWR)) < 0) { - logprintf(LOG_ERR, "could not open %s", lirc_433_socket); - return EXIT_FAILURE; - } else { - /* Only set the frequency once */ - if(lirc_433_setfreq == 0) { - freq = FREQ433; - /* Set the lirc_rpi frequency to 433.92Mhz */ - if(ioctl(lirc_433_fd, _IOW('i', 0x00000013, unsigned long), &freq) == -1) { - logprintf(LOG_ERR, "could not set lirc_rpi send frequency"); - exit(EXIT_FAILURE); - } - fd = open(lirc_433_socket, O_RDWR); - ioctl(fd, FIONREAD, &count); - for(i=0; i 0) { - /* Restore the lirc_rpi frequency to its default value */ - if(ioctl(lirc_433_fd, _IOW('i', 0x00000013, unsigned long), &freq) == -1) { - logprintf(LOG_ERR, "could not restore default freq of the lirc_rpi lirc"); - exit(EXIT_FAILURE); - } else { - logprintf(LOG_DEBUG, "default freq of the lirc_rpi lirc set"); - } - - close(lirc_433_fd); - lirc_433_fd = 0; - } - - logprintf(LOG_DEBUG, "deinitialized lirc_rpi lirc"); - lirc_433_initialized = 0; - } - - return EXIT_SUCCESS; -} - -static int lirc433Send(int *code, int rawlen, int repeats) { - /* Create a single code with all repeats included */ - int code_len = (rawlen*repeats)+1; - size_t send_len = (size_t)(code_len * (int)sizeof(int)); - int longCode[code_len], i = 0, x = 0; - size_t y = 0; - ssize_t n = 0; - memset(longCode, 0, send_len); - - for(i=0;i 0) { - (void)read(lirc_433_fd, &data, sizeof(data)); - lseek(lirc_433_fd, 0, SEEK_SET); - return (data & 0x00FFFFFF); - } else { - return -1; - } -} - -static unsigned short lirc433Settings(JsonNode *json) { - if(strcmp(json->key, "socket") == 0) { - if(json->tag == JSON_STRING) { - if((lirc_433_socket = MALLOC(strlen(json->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lirc_433_socket, json->string_); - } else { - return EXIT_FAILURE; - } - } - return EXIT_SUCCESS; -} - - -static int lirc433gc(void) { - if(lirc_433_socket != NULL) { - FREE(lirc_433_socket); - } - - return 1; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void lirc433Init(void) { - - hardware_register(&lirc433); - hardware_set_id(lirc433, "433lirc"); - - options_add(&lirc433->options, 's', "socket", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, "^/dev/([a-z]+)[0-9]+$"); - - lirc433->minrawlen = 1000; - lirc433->maxrawlen = 0; - lirc433->mingaplen = 5100; - lirc433->maxgaplen = 10000; - - lirc433->hwtype=RF433; - lirc433->comtype=COMOOK; - lirc433->init=&lirc433HwInit; - lirc433->deinit=&lirc433HwDeinit; - lirc433->sendOOK=&lirc433Send; - lirc433->receiveOOK=&lirc433Receive; - lirc433->settings=&lirc433Settings; - lirc433->gc=&lirc433gc; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "433lirc"; - module->version = "1.4"; - module->reqversion = "7.0"; - module->reqcommit = "10"; -} - -void init(void) { - lirc433Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/433lirc.h b/lib/ESPiLight/pilight/libs/pilight/hardware/433lirc.h deleted file mode 100644 index 935a5b4..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/433lirc.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _HARDWARE_LIRC_433_H_ -#define _HARDWARE_LIRC_433_H_ - -#include "../config/hardware.h" - -struct hardware_t *lirc433; -void lirc433Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/433nano.c b/lib/ESPiLight/pilight/libs/pilight/hardware/433nano.c deleted file mode 100644 index 00fcf02..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/433nano.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - Copyright (C) 2013 - 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 - #define STRICT - #define WIN32_LEAN_AND_MEAN - #include -#else - #include -#endif - -#include "../core/pilight.h" -#include "../core/json.h" -#include "../core/log.h" -#include "../core/dso.h" -#include "../core/firmware.h" -#include "../config/registry.h" -#include "../config/hardware.h" -#include "433nano.h" - -typedef struct timestamp_t { - unsigned long first; - unsigned long second; -} timestamp_t; - -timestamp_t timestamp; - -/* What is the minimum rawlenth to consider a pulse stream valid */ -static int minrawlen = 1000; -/* What is the maximum rawlenth to consider a pulse stream valid */ -static int maxrawlen = 0; -/* What is the minimum rawlenth to consider a pulse stream valid */ -static int maxgaplen = 5100; -/* What is the maximum rawlenth to consider a pulse stream valid */ -static int mingaplen = 10000; - -#ifdef _WIN32 -static HANDLE serial_433_fd; -#else -static int serial_433_fd = 0; -static int nano_433_initialized = 0; -#endif - -static char com[255]; -static unsigned short loop = 1; -static unsigned short running = 0; -static unsigned short threads = 0; -static unsigned short sendSync = 0; -static pthread_t pth; - -void *syncFW(void *param) { - - threads++; - -#ifdef _WIN32 - DWORD n; -#else - int n; -#endif - char send[MAXPULSESTREAMLENGTH+1]; - int len = 0; - - memset(&send, '\0', sizeof(send)); - - struct protocols_t *tmp = protocols; - while(tmp) { - if(tmp->listener->hwtype == RF433) { - if(tmp->listener->maxrawlen > maxrawlen) { - maxrawlen = tmp->listener->maxrawlen; - } - if(tmp->listener->minrawlen > 0 && tmp->listener->minrawlen < minrawlen) { - minrawlen = tmp->listener->minrawlen; - } - if(tmp->listener->maxgaplen > maxgaplen) { - maxgaplen = tmp->listener->maxgaplen; - } - if(tmp->listener->mingaplen > 0 && tmp->listener->mingaplen < mingaplen) { - mingaplen = tmp->listener->mingaplen; - } - } - tmp = tmp->next; - } - - /* Let's wait for Nano to accept instructions */ - while(sendSync == 0 && loop == 1) { - usleep(10); - } - - len = sprintf(send, "s:%d,%d,%d,%d@", minrawlen, maxrawlen, mingaplen, maxgaplen); - -#ifdef _WIN32 - WriteFile(serial_433_fd, &send, len, &n, NULL); -#else - n = write(serial_433_fd, send, len); -#endif - - if(n != len) { - logprintf(LOG_NOTICE, "could not sync FW values"); - } - - threads--; - - return NULL; -} - -#ifndef _WIN32 -/* http://stackoverflow.com/a/6947758 */ -static int serial_interface_attribs(int fd, speed_t speed, tcflag_t parity) { - struct termios tty; - - memset(&tty, 0, sizeof tty); - if(tcgetattr(fd, &tty) != 0) { - logprintf(LOG_ERR, "error %d from tcgetattr", errno); - return -1; - } - - cfsetospeed(&tty, speed); - cfsetispeed(&tty, speed); - - tty.c_cflag = (tty.c_cflag & (unsigned int)~CSIZE) | CS8; // 8-bit chars - tty.c_iflag &= (unsigned int)~IGNBRK; - tty.c_lflag = 0; - tty.c_oflag = 0; - tty.c_cc[VMIN] = 0; - tty.c_cc[VTIME] = 5; - tty.c_iflag &= ~((unsigned int)IXON | (unsigned int)IXOFF | (unsigned int)IXANY); - tty.c_cflag |= ((unsigned int)CLOCAL | (unsigned int)CREAD); - tty.c_cflag &= ~((unsigned int)PARENB | (unsigned int)PARODD); - tty.c_cflag |= parity; - tty.c_cflag &= (unsigned int)~CSTOPB; - tty.c_cflag &= (unsigned int)~CRTSCTS; - - if(tcsetattr(fd, TCSANOW, &tty) != 0) { - logprintf(LOG_ERR, "error %d from tcsetattr", errno); - return -1; - } - return 0; -} -#endif - -static unsigned short int nano433HwInit(void) { -#ifdef _WIN32 - COMMTIMEOUTS timeouts; - DCB port; - char tmp[255]; - memset(tmp, '\0', 255); - - snprintf(tmp, 255, "\\\\.\\%s", com); - - if((int)(serial_433_fd = CreateFile(tmp, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL)) < 0) { - logprintf(LOG_NOTICE, "cannot open port %s", com); - return EXIT_FAILURE; - } - logprintf(LOG_INFO, "connected to port %s", com); - - memset(&port, '\0', sizeof(port)); - - port.DCBlength = sizeof(port); - if(GetCommState(serial_433_fd, &port) == FALSE) { - logprintf(LOG_ERR, "cannot get comm state for port %s", com); - return EXIT_FAILURE; - } - - if(BuildCommDCB("baud=57600 parity=n data=8 stop=1", &port) == FALSE) { - logprintf(LOG_ERR, "cannot build comm DCB for port %s", com); - return EXIT_FAILURE; - } - - if(SetCommState(serial_433_fd, &port) == FALSE) { - logprintf(LOG_ERR, "cannot set port settings for port %s", com); - return EXIT_FAILURE; - } - - timeouts.ReadIntervalTimeout = 1000; - timeouts.ReadTotalTimeoutMultiplier = 1000; - timeouts.ReadTotalTimeoutConstant = 1000; - timeouts.WriteTotalTimeoutMultiplier = 1000; - timeouts.WriteTotalTimeoutConstant = 1000; - - if(SetCommTimeouts(serial_433_fd, &timeouts) == FALSE) { - logprintf(LOG_ERR, "error setting port %s time-outs.", com); - return EXIT_FAILURE; - } -#else - if((serial_433_fd = open(com, O_RDWR | O_SYNC)) >= 0) { - serial_interface_attribs(serial_433_fd, B57600, 0); - nano_433_initialized = 1; - } else { - logprintf(LOG_NOTICE, "could not open port %s", com); - return EXIT_FAILURE; - } -#endif - - pthread_create(&pth, NULL, &syncFW, (void *)NULL); - pthread_detach(pth); - - return EXIT_SUCCESS; -} - -static unsigned short nano433HwDeinit(void) { - loop = 0; - while(running > 0 && threads > 0) { - usleep(10); - } -#ifdef _WIN32 - CloseHandle(serial_433_fd); -#else - if(nano_433_initialized == 1) { - close(serial_433_fd); - nano_433_initialized = 0; - } -#endif - return EXIT_SUCCESS; -} - -static int nano433Send(int *code, int rawlen, int repeats) { - unsigned int i = 0, x = 0, y = 0, len = 0, nrpulses = 0; - int pulses[10], match = 0; - char c[16], send[MAXPULSESTREAMLENGTH+1]; -#ifdef _WIN32 - DWORD n; -#else - int n = 0; -#endif - - memset(send, 0, MAXPULSESTREAMLENGTH); - strncpy(&send[0], "c:", 2); - len += 2; - - for(i=0;ilength = 0; - memset(r->pulses, 0, MAXPULSESTREAMLENGTH); - - running = 1; - - while(loop) { -#ifdef _WIN32 - if(WriteFile(serial_433_fd, "ping", 0, &n, NULL) == 0) { - logprintf(LOG_INFO, "lost connection to %s", com); - CloseHandle(serial_433_fd); - r->length = -1; - return -1; - } - ReadFile(serial_433_fd, c, 1, &n, NULL); -#else - n = read(serial_433_fd, c, 1); -#endif - if(n > 0) { - if(c[0] == '\n') { - sendSync = 1; - break; - } else { - if(c[0] == 'v') { - startv = 1; - start = 1; - bytes = 0; - } - if(c[0] == 'c') { - start = 1; - bytes = 0; - } - if(c[0] == 'p') { - startp = bytes+2; - buffer[bytes-1] = '\0'; - } - if(c[0] == '@') { - buffer[bytes] = '\0'; - if(startv == 1) { - start = 0; - startv = 0; - char **array = NULL; - int c = explode(&buffer[2], ",", &array); - if(c == 7) { - if(!(minrawlen == atoi(array[0]) && maxrawlen == atoi(array[1]) && - mingaplen == atoi(array[2]) && maxgaplen == atoi(array[3]))) { - logprintf(LOG_WARNING, "could not sync FW values"); - } - firmware.version = atof(array[4]); - firmware.lpf = atof(array[5]); - firmware.hpf = atof(array[6]); - - if(firmware.version > 0 && firmware.lpf > 0 && firmware.hpf > 0) { - registry_set_number("pilight.firmware.version", firmware.version, 0); - registry_set_number("pilight.firmware.lpf", firmware.lpf, 0); - registry_set_number("pilight.firmware.hpf", firmware.hpf, 0); - - struct JsonNode *jmessage = json_mkobject(); - struct JsonNode *jcode = json_mkobject(); - json_append_member(jcode, "version", json_mknumber(firmware.version, 0)); - json_append_member(jcode, "lpf", json_mknumber(firmware.lpf, 0)); - json_append_member(jcode, "hpf", json_mknumber(firmware.hpf, 0)); - json_append_member(jmessage, "values", jcode); - json_append_member(jmessage, "origin", json_mkstring("core")); - json_append_member(jmessage, "type", json_mknumber(FIRMWARE, 0)); - char pname[17]; - strcpy(pname, "pilight-firmware"); - if(pilight.broadcast != NULL) { - pilight.broadcast(pname, jmessage, FW); - } - json_delete(jmessage); - jmessage = NULL; - } - } - array_free(&array, c); - } else { - x = strlen(&buffer[startp]); - s = startp; - nrpulses = 0; - for(y = startp; y < startp + (int)x; y++) { - if(buffer[y] == ',') { - buffer[y] = '\0'; - pulses[nrpulses++] = atoi(&buffer[s]); - s = y+1; - } - } - pulses[nrpulses++] = atoi(&buffer[s]); - x = strlen(&buffer[2]); - for(y = 2; y < 2 + x; y++) { - r->pulses[r->length++] = pulses[0]; - r->pulses[r->length++] = pulses[buffer[y] - '0']; - } - bytes = 0; - return 0; - } - } - if(start == 1) { - buffer[bytes++] = c[0]; - } - } - } - } - - running = 0; - - return -1; -} - -static unsigned short nano433Settings(JsonNode *json) { - if(strcmp(json->key, "comport") == 0) { - if(json->tag == JSON_STRING) { - strcpy(com, json->string_); - return EXIT_SUCCESS; - } - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void nano433Init(void) { - hardware_register(&nano433); - hardware_set_id(nano433, "433nano"); - - options_add(&nano433->options, 'p', "comport", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - nano433->hwtype=RF433; - nano433->comtype=COMPLSTRAIN; - nano433->init=&nano433HwInit; - nano433->deinit=&nano433HwDeinit; - nano433->sendOOK=&nano433Send; - nano433->receivePulseTrain=&nano433Receive; - nano433->settings=&nano433Settings; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "433nano"; - module->version = "1.2"; - module->reqversion = "7.0"; - module->reqcommit = "10"; -} - -void init(void) { - nano433Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/433nano.h b/lib/ESPiLight/pilight/libs/pilight/hardware/433nano.h deleted file mode 100644 index 5c3e185..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/433nano.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _HARDWARE_NANO_433_H_ -#define _HARDWARE_NANO_433_H_ - -#include "../config/hardware.h" - -struct hardware_t *nano433; -void nano433Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeExclude.txt deleted file mode 100644 index b9adc6f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeExclude.txt +++ /dev/null @@ -1,16 +0,0 @@ -include(../../../CMakeConfig.txt) - -if(${HARDWARE_433_GPIO} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/433gpio.h") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/433gpio.c") -endif() - -if(${HARDWARE_433_LIRC} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/433module.h") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/433module.c") -endif() - -if(${HARDWARE_433_NANO} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/433nano.h") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/433nano.c") -endif() \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeInclude.txt deleted file mode 100644 index 674005b..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/hardware_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/hardware_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE ${PROJECT_SOURCE_DIR} " #include \"../hardware" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(HARDWARE_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/hardware_header.h.in ${PROJECT_SOURCE_DIR}/hardware_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE hardware_result - OUTPUT_VARIABLE hardware_init) - -set(inits) -foreach(init ${hardware_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(HARDWARE_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/hardware_init.h.in ${PROJECT_SOURCE_DIR}/hardware_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeLists.txt deleted file mode 100644 index a78f0f3..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -project(pilight_hardware) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c" "${PROJECT_SOURCE_DIR}/*.cpp") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -if(${MODULESPACK} MATCHES "OFF" OR WIN32) - include(CMakeExclude.txt) - - if(WIN32) - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/433gpio.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/433gpio.h") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/433lirc.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/433lirc.h") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/IRgpio.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/IRgpio.h") - endif() - - if(${ZWAVE} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/zwave.cpp") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/zwave.h") - endif() - - include(CMakeInclude.txt) - - set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") -else() - foreach(file ${${PROJECT_NAME}_sources}) - get_filename_component(name ${file} NAME_WE) - add_library(${name}_module MODULE ${file}) - target_link_libraries(${name}_module ${CMAKE_THREAD_LIBS_INIT}) - target_link_libraries(${name}_module m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${name}_module execinfo) - endif() - target_link_libraries(${name}_module ${CMAKE_DL_LIBS}) - set_target_properties(${name}_module PROPERTIES OUTPUT_NAME ${name}) - string(REPLACE "_" "-" debname ${name}) - install(FILES ${CMAKE_BINARY_DIR}/libs/pilight/hardware/lib${name}.so DESTINATION lib/pilight/hardware RENAME ${name}.so COMPONENT pilight-hardware-${debname}) - endforeach() -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/hardware_header.h.in b/lib/ESPiLight/pilight/libs/pilight/hardware/hardware_header.h.in deleted file mode 100644 index 60bf414..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/hardware_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@HARDWARE_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/hardware_init.h.in b/lib/ESPiLight/pilight/libs/pilight/hardware/hardware_init.h.in deleted file mode 100644 index cbbe9d5..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/hardware_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@HARDWARE_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/none.c b/lib/ESPiLight/pilight/libs/pilight/hardware/none.c deleted file mode 100644 index db95eea..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/none.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../core/common.h" -#include "../core/dso.h" -#include "../config/hardware.h" -#include "none.h" - -static int noneSend(int *code, int rawlen, int repeats) { - sleep(1); - return EXIT_SUCCESS; -} - -static int noneReceive(void) { - sleep(1); - return EXIT_SUCCESS; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void noneInit(void) { - hardware_register(&none); - hardware_set_id(none, "none"); - none->hwtype=NONE; - none->comtype=COMNONE; - none->receiveOOK=&noneReceive; - none->sendOOK=&noneSend; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "none"; - module->version = "1.0"; - module->reqversion = "5.0"; - module->reqcommit = NULL; -} - -void init(void) { - noneInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/none.h b/lib/ESPiLight/pilight/libs/pilight/hardware/none.h deleted file mode 100644 index 5d5d1b0..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/none.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _HARDWARE_NONE_H_ -#define _HARDWARE_NONE_H_ - -#include "../config/hardware.h" - -struct hardware_t *none; -void noneInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/zwave.cpp b/lib/ESPiLight/pilight/libs/pilight/hardware/zwave.cpp deleted file mode 100644 index 4dece63..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/zwave.cpp +++ /dev/null @@ -1,705 +0,0 @@ -/* - Copyright (C) 2013 - 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see - - Big thanks to the Domoticz developers for inspiration. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 - #define STRICT - #define WIN32_LEAN_AND_MEAN - #include -#else - #include -#endif - -extern "C" { - -#include "../config/hardware.h" -#include "../core/pilight.h" -#include "../core/json.h" -#include "../core/log.h" -#include "../core/json.h" -#include "../core/dso.h" -#include "../config/settings.h" -#include "zwave.h" - -} - -#include "../../openzwave/Options.h" -#include "../../openzwave/Manager.h" -#include "../../openzwave/Notification.h" -#include "../../openzwave/Node.h" -#include "../../openzwave/Driver.h" -#include "../../openzwave/platform/Log.h" -#include "../../openzwave/value_classes/Value.h" - -static uint32 gHomeId = 0; - -#define DRIVER_STATUS_INIT_SUCCESS 0 -#define DRIVER_STATUS_INIT_FAILED 1 -#define DRIVER_STATUS_NODES_QUERIED 2 -#define DRIVER_STATUS_NODES_QUERIED_SOME_DEAD 3 - -static pthread_mutex_t init_lock; -static pthread_cond_t init_signal; -static pthread_mutexattr_t init_attr; - -static pthread_mutex_t values_lock; -static pthread_mutexattr_t values_attr; - -static unsigned short init_lock_init = 0; -static unsigned short values_lock_init = 0; - -static int pending_command = 0; -static unsigned short driver_status = -1; -static char com[255]; -static int threads = 0; -static int isinit = 0; - -#ifdef _WIN32 -static unsigned short nrports = 16; -static char comports[16][10]={"COM1", "COM2", "COM3", "COM4", - "COM5", "COM6", "COM7", "COM8", - "COM9", "COM10", "COM11", "COM12", - "COM13", "COM14", "COM15", "COM16"}; -#else -static unsigned short nrports = 44; -static char comports[44][16]={"/dev/ttyS0","/dev/ttyS1","/dev/ttyS2","/dev/ttyS3","/dev/ttyS4","/dev/ttyS5", - "/dev/ttyS6","/dev/ttyS7","/dev/ttyS8","/dev/ttyS9","/dev/ttyS10","/dev/ttyS11", - "/dev/ttyS12","/dev/ttyS13","/dev/ttyS14","/dev/ttyS15","/dev/ttyUSB0", - "/dev/ttyUSB1","/dev/ttyUSB2","/dev/ttyUSB3","/dev/ttyUSB4","/dev/ttyUSB5", - "/dev/ttyAMA0","/dev/ttyAMA1","/dev/ttyACM0","/dev/ttyACM1", - "/dev/rfcomm0","/dev/rfcomm1","/dev/ircomm0","/dev/ircomm1", - "/dev/cuau0","/dev/cuau1","/dev/cuau2","/dev/cuau3", - "/dev/cuaU0","/dev/cuaU1","/dev/cuaU2","/dev/cuaU3", - "/dev/ttymxc0", "/dev/ttymxc1", "/dev/ttymxc2", - "/dev/ttymxc3", "/dev/ttymxc4", "/dev/ttymxc5"}; -#endif - -void UpdateNodeValue(int nodeId, OpenZWave::ValueID const v) { - pthread_mutex_lock(&values_lock); - struct JsonNode *json = json_mkobject(); - struct JsonNode *jcode = json_mkobject(); - struct zwave_values_t *tmp = NULL; - int match = 0; - std::string label = OpenZWave::Manager::Get()->GetValueLabel(v); - - tmp = zwave_values; - while(tmp) { - if(tmp->nodeId == nodeId && tmp->valueId == v.GetIndex()) { - match = 1; - break; - } - tmp = tmp->next; - } - - if(match == 0) { - if((tmp = (struct zwave_values_t *)MALLOC(sizeof(struct zwave_values_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - tmp->nodeId = nodeId; - tmp->cmdId = v.GetCommandClassId(); - tmp->valueId = v.GetIndex(); - tmp->instance = v.GetInstance(); - tmp->genre = v.GetGenre(); - tmp->valueType = v.GetType(); - if((tmp->label = (char *)MALLOC(strlen(label.c_str())+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(tmp->label, label.c_str()); - tmp->next = NULL; - } - - json_append_member(json, "message", jcode); - json_append_member(json, "origin", json_mkstring("receiver")); - json_append_member(jcode, "homeId", json_mknumber(gHomeId, 0)); - json_append_member(jcode, "nodeId", json_mknumber(nodeId, 0)); - json_append_member(jcode, "cmdId", json_mknumber(v.GetCommandClassId(), 0)); - json_append_member(jcode, "label", json_mkstring(label.c_str())); - - std::string str; - OpenZWave::Manager::Get()->GetValueAsString(v, &str); - - switch(v.GetType()) { - case OpenZWave::ValueID::ValueType_Button: - case OpenZWave::ValueID::ValueType_Bool: - if(strcmp(str.c_str(), "False") == 0) { - tmp->number_ = 0; - json_append_member(jcode, "value", json_mknumber(0, 0)); - } else if(strcmp(str.c_str(), "True") == 0) { - tmp->number_ = 1; - json_append_member(jcode, "value", json_mknumber(1, 0)); - } - break; - case OpenZWave::ValueID::ValueType_String: - case OpenZWave::ValueID::ValueType_Raw: - json_append_member(jcode, "value", json_mkstring(str.c_str())); - break; - case OpenZWave::ValueID::ValueType_Byte: - case OpenZWave::ValueID::ValueType_Decimal: - case OpenZWave::ValueID::ValueType_Int: - case OpenZWave::ValueID::ValueType_Short: - json_append_member(jcode, "value", json_mknumber(atoi(str.c_str()), 0)); - break; - case OpenZWave::ValueID::ValueType_List: { - struct JsonNode *jvalues = json_mkarray(); - std::vector values; - OpenZWave::Manager::Get()->GetValueListSelection(v, &str); - OpenZWave::Manager::Get()->GetValueListItems(v, &values); - for(std::vector::iterator it = values.begin(); it != values.end(); ++it) { - std::string t = *it; - json_append_element(jvalues, json_mkstring(t.c_str())); - } - json_append_member(jcode, "value", json_mkstring(str.c_str())); - json_append_member(jcode, "values", jvalues); - } break; - case OpenZWave::ValueID::ValueType_Schedule: - default: - break; - } - - if(pilight.receive != NULL) { - pilight.receive(json, ZWAVE); - } - - if(match == 0) { - tmp->next = zwave_values; - zwave_values = tmp; - } - - OpenZWave::Manager::Get()->SetChangeVerified(v, true); - json_delete(json); - pthread_mutex_unlock(&values_lock); -} - -void DeleteNodeValue(int nodeId, OpenZWave::ValueID const v) { - pthread_mutex_lock(&values_lock); - struct zwave_values_t *currP, *prevP; - - prevP = NULL; - - for(currP = zwave_values; currP != NULL; prevP = currP, currP = currP->next) { - - if(currP->nodeId == nodeId && currP->valueId == v.GetIndex()) { - if(prevP == NULL) { - zwave_values = currP->next; - } else { - prevP->next = currP->next; - } - - FREE(currP); - - break; - } - } - pthread_mutex_unlock(&values_lock); -} - -void OnNotification(OpenZWave::Notification const *_notification, void *_context) { - switch(_notification->GetType()) { - case OpenZWave::Notification::Type_ValueAdded: { - OpenZWave::ValueID v = _notification->GetValueID(); - UpdateNodeValue(_notification->GetNodeId(), v); - if(pilight.debuglevel == 1) { - printf("z-wave value added\n"); - } - } break; - case OpenZWave::Notification::Type_ValueRemoved: { - OpenZWave::ValueID v = _notification->GetValueID(); - DeleteNodeValue(_notification->GetNodeId(), v); - if(pilight.debuglevel == 1) { - printf("z-wave value removed\n"); - } - } break; - case OpenZWave::Notification::Type_ValueChanged: { - OpenZWave::ValueID v = _notification->GetValueID(); - UpdateNodeValue(_notification->GetNodeId(), v); - if(pilight.debuglevel == 1) { - printf("z-wave value changed\n"); - } - } break; - case OpenZWave::Notification::Type_Group: - case OpenZWave::Notification::Type_NodeNew: - break; - case OpenZWave::Notification::Type_NodeAdded: { - /* Add new node to the nodes list */ - if(pilight.debuglevel == 1) { - printf("z-wave node added\n"); - } - } break; - case OpenZWave::Notification::Type_NodeRemoved: { - // Remove a node from our list - if(pilight.debuglevel == 1) { - printf("z-wave node removed\n"); - } - } break; - case OpenZWave::Notification::Type_NodeProtocolInfo: - case OpenZWave::Notification::Type_NodeNaming: - case OpenZWave::Notification::Type_NodeEvent: - case OpenZWave::Notification::Type_PollingDisabled: - case OpenZWave::Notification::Type_PollingEnabled: - case OpenZWave::Notification::Type_SceneEvent: - case OpenZWave::Notification::Type_CreateButton: - case OpenZWave::Notification::Type_DeleteButton: - case OpenZWave::Notification::Type_ButtonOn: - case OpenZWave::Notification::Type_ButtonOff: - break; - case OpenZWave::Notification::Type_DriverReady: - gHomeId = _notification->GetHomeId(); - logprintf(LOG_INFO, "[Z-Wave] homeID is %lu", gHomeId); - if(pilight.debuglevel == 1) { - printf("z-wave driver ready\n"); - } - driver_status = DRIVER_STATUS_INIT_SUCCESS; - pthread_cond_signal(&init_signal); - break; - case OpenZWave::Notification::Type_DriverFailed: - if(pilight.debuglevel == 1) { - printf("z-wave driver failed\n"); - } - driver_status = DRIVER_STATUS_INIT_FAILED; - pthread_cond_signal(&init_signal); - break; - case OpenZWave::Notification::Type_DriverReset: - break; - case OpenZWave::Notification::Type_EssentialNodeQueriesComplete: - case OpenZWave::Notification::Type_NodeQueriesComplete: - case OpenZWave::Notification::Type_AwakeNodesQueried: - break; - case OpenZWave::Notification::Type_AllNodesQueriedSomeDead: - if(pilight.debuglevel == 1) { - printf("z-wave all nodes partially queried\n"); - } - driver_status = DRIVER_STATUS_NODES_QUERIED_SOME_DEAD; - pthread_cond_signal(&init_signal); - break; - case OpenZWave::Notification::Type_AllNodesQueried: - if(pilight.debuglevel == 1) { - printf("z-wave all nodes queried\n"); - } - /* Nodes are ready to take instructions */ - driver_status = DRIVER_STATUS_NODES_QUERIED; - pthread_cond_signal(&init_signal); - break; - case OpenZWave::Notification::Type_Notification: { - if(pilight.debuglevel == 1) { - printf("z-wave all notification\n"); - } - switch(_notification->GetNotification()) { - case OpenZWave::Notification::Code_MsgComplete: - if(pilight.debuglevel == 1) { - printf("- MsgComplete\n"); - } - break; - case OpenZWave::Notification::Code_Timeout: - /* No connection could be made with the z-wave module */ - if(pilight.debuglevel == 1) { - printf("- Timeout\n"); - } - break; - case OpenZWave::Notification::Code_NoOperation: - if(pilight.debuglevel == 1) { - printf("- NoOperation\n"); - } - break; - case OpenZWave::Notification::Code_Awake: - if(pilight.debuglevel == 1) { - printf("- Awake\n"); - } - break; - case OpenZWave::Notification::Code_Sleep: - if(pilight.debuglevel == 1) { - printf("- Sleep\n"); - } - break; - case OpenZWave::Notification::Code_Dead: - if(pilight.debuglevel == 1) { - printf("- Dead\n"); - } - break; - case OpenZWave::Notification::Code_Alive: - if(pilight.debuglevel == 1) { - printf("- Alive\n"); - } - break; - default: - // logprintf(LOG_DEBUG, "- %d\n", _notification->GetNotification()); - break; - } - } break; - case OpenZWave::Notification::Type_DriverRemoved: - if(pilight.debuglevel == 1) { - printf("z-wave driver removed\n"); - } - default: - break; - } -} - -static unsigned short zwaveHwInit(void) { - char *logfile = NULL; - int free_log_file = 0; - if(settings_find_string("log-file", &logfile) != 0) { - if((logfile = (char *)MALLOC(strlen(LOG_FILE)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - free_log_file = 1; - } - - char *logpath = NULL; - atomiclock(); - /* basename isn't thread safe */ - char *filename = basename(logfile); - atomicunlock(); - - pthread_mutexattr_init(&init_attr); - pthread_mutexattr_settype(&init_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&init_lock, &init_attr); - pthread_cond_init(&init_signal, NULL); - init_lock_init = 1; - - pthread_mutexattr_init(&values_attr); - pthread_mutexattr_settype(&values_attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&values_lock, &values_attr); - values_lock_init = 1; - - pthread_mutex_lock(&init_lock); - - size_t i = (strlen(logfile)-strlen(filename)); - if((logpath = (char *)REALLOC(logpath, i+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - memset(logpath, '\0', i+1); - strncpy(logpath, logfile, i); - - OpenZWave::Options::Create(logpath, logpath, "--SaveConfiguration=true"); - OpenZWave::Options::Get()->AddOptionString("UserPath", logpath, false); - OpenZWave::Options::Get()->AddOptionString("logFilename", filename, false); - - FREE(logpath); - if(free_log_file == 1) { - FREE(logfile); - } - - OpenZWave::Options::Get()->AddOptionBool("logging", true); - if(pilight.debuglevel == 1) { - OpenZWave::Options::Get()->AddOptionInt("SaveLogLevel", OpenZWave::LogLevel_Info); - } else { - OpenZWave::Options::Get()->AddOptionInt("SaveLogLevel", OpenZWave::LogLevel_Warning); - } - OpenZWave::Options::Get()->AddOptionInt("PollInterval", 500); - OpenZWave::Options::Get()->AddOptionBool("IntervalBetweenPolls", true); - OpenZWave::Options::Get()->AddOptionBool("AppendLogFile", true); - OpenZWave::Options::Get()->AddOptionBool("ConsoleOutput", true); - OpenZWave::Options::Get()->AddOptionBool("NotifyTransactions", true); - OpenZWave::Options::Get()->Lock(); - OpenZWave::Manager::Create(); - OpenZWave::Manager::Get()->AddWatcher(OnNotification, NULL); - OpenZWave::Manager::Get()->AddDriver(com); - isinit = 1; - - pthread_cond_wait(&init_signal, &init_lock); - - if(driver_status == DRIVER_STATUS_INIT_SUCCESS) { - logprintf(LOG_INFO, "[Z-Wave]: z-wave initialized, querying all nodes"); - return EXIT_SUCCESS; - } - return EXIT_FAILURE; -} - -static unsigned short zwaveHwDeinit(void) { - pthread_mutex_unlock(&init_lock); - pthread_cond_signal(&init_signal); - - logprintf(LOG_NOTICE, "[Z-Wave]: closing and freeing z-wave modules, please wait..."); - if(isinit == 1) { - OpenZWave::Manager::Get()->RemoveWatcher(OnNotification, NULL); - sleep(1); - OpenZWave::Manager::Get()->RemoveDriver(com); - OpenZWave::Manager::Destroy(); - OpenZWave::Options::Destroy(); - } - - struct zwave_values_t *tmp = NULL; - while(zwave_values) { - tmp = zwave_values; - FREE(tmp->label); - zwave_values = zwave_values->next; - FREE(tmp); - } - if(zwave_values != NULL) { - FREE(zwave_values); - } - - while(threads > 0) { - usleep(10); - } - - return EXIT_SUCCESS; -} - -static OpenZWave::ValueID::ValueGenre getGenreFromEnum(int genre) { - switch(genre) { - default: - case OpenZWave::ValueID::ValueGenre_Basic: - return OpenZWave::ValueID::ValueGenre_Basic; - break; - case OpenZWave::ValueID::ValueGenre_User: - return OpenZWave::ValueID::ValueGenre_User; - break; - case OpenZWave::ValueID::ValueGenre_Config: - return OpenZWave::ValueID::ValueGenre_Config; - break; - case OpenZWave::ValueID::ValueGenre_System: - return OpenZWave::ValueID::ValueGenre_System; - break; - case OpenZWave::ValueID::ValueGenre_Count: - return OpenZWave::ValueID::ValueGenre_Count; - break; - } -} - -static OpenZWave::ValueID::ValueType getValueTypeFromEnum(int type) { - switch(type) { - default: - case OpenZWave::ValueID::ValueType_Bool: - return OpenZWave::ValueID::ValueType_Bool; - break; - case OpenZWave::ValueID::ValueType_Byte: - return OpenZWave::ValueID::ValueType_Byte; - break; - case OpenZWave::ValueID::ValueType_Decimal: - return OpenZWave::ValueID::ValueType_Decimal; - break; - case OpenZWave::ValueID::ValueType_Int: - return OpenZWave::ValueID::ValueType_Int; - break; - case OpenZWave::ValueID::ValueType_List: - return OpenZWave::ValueID::ValueType_List; - break; - case OpenZWave::ValueID::ValueType_Schedule: - return OpenZWave::ValueID::ValueType_Schedule; - break; - case OpenZWave::ValueID::ValueType_Short: - return OpenZWave::ValueID::ValueType_Short; - break; - case OpenZWave::ValueID::ValueType_String: - return OpenZWave::ValueID::ValueType_String; - break; - case OpenZWave::ValueID::ValueType_Button: - return OpenZWave::ValueID::ValueType_Button; - break; - case OpenZWave::ValueID::ValueType_Raw: - return OpenZWave::ValueID::ValueType_Raw; - break; - } -} - -void zwaveSetValue(int nodeId, int cmdId, char *label, char *value) { - pthread_mutex_lock(&values_lock); - struct zwave_values_t *tmp = zwave_values; - std::string v = value; - - while(tmp) { - if(tmp->nodeId == nodeId && tmp->cmdId == cmdId && - ((label != NULL && tmp->label != NULL && strcmp(tmp->label, label) == 0) - || label == NULL)) { - OpenZWave::ValueID vID(gHomeId, tmp->nodeId, getGenreFromEnum(tmp->genre), tmp->cmdId, tmp->instance, tmp->valueId, getValueTypeFromEnum(tmp->valueType)); - OpenZWave::Manager::Get()->SetValue(vID, v); - } - tmp = tmp->next; - } - pthread_mutex_unlock(&values_lock); -} - -static int zwaveSend(struct JsonNode *code) { - return EXIT_SUCCESS; -} - -static void OnDeviceStatusUpdate(OpenZWave::Driver::ControllerState cs, OpenZWave::Driver::ControllerError err, void *_context) { - switch(cs) { - case OpenZWave::Driver::ControllerState_Normal: - pending_command = 0; - logprintf(LOG_INFO, "[Z-Wave]: No Command in progress"); - break; - case OpenZWave::Driver::ControllerState_Starting: - logprintf(LOG_INFO, "[Z-Wave]: Starting controller command"); - break; - case OpenZWave::Driver::ControllerState_Cancel: - logprintf(LOG_INFO, "[Z-Wave]: The command was canceled"); - pending_command = 0; - break; - case OpenZWave::Driver::ControllerState_Error: - logprintf(LOG_INFO, "[Z-Wave]: Command invocation had error(s) and was aborted"); - pending_command = 0; - break; - case OpenZWave::Driver::ControllerState_Waiting: - logprintf(LOG_INFO, "[Z-Wave]: Controller is waiting for a user action"); - pending_command = 1; - break; - case OpenZWave::Driver::ControllerState_Sleeping: - logprintf(LOG_INFO, "[Z-Wave]: Controller command is on a sleep queue wait for device"); - break; - case OpenZWave::Driver::ControllerState_InProgress: - logprintf(LOG_INFO, "[Z-Wave]: The controller is communicating with the other device to carry out the command"); - break; - case OpenZWave::Driver::ControllerState_Completed: - logprintf(LOG_INFO, "[Z-Wave]: The command has completed successfully"); - pending_command = 0; - break; - case OpenZWave::Driver::ControllerState_Failed: - logprintf(LOG_INFO, "[Z-Wave]: The command has failed"); - pending_command = 0; - break; - case OpenZWave::Driver::ControllerState_NodeOK: - logprintf(LOG_INFO, "[Z-Wave]: Used only with ControllerCommand_HasNodeFailed to indicate that the controller thinks the node is OK"); - break; - case OpenZWave::Driver::ControllerState_NodeFailed: - logprintf(LOG_INFO, "[Z-Wave]: Used only with ControllerCommand_HasNodeFailed to indicate that the controller thinks the node has failed"); - break; - default: - logprintf(LOG_INFO, "[Z-Wave]: Unknown Device Response!"); - pending_command = 0; - break; - } -} - -void zwaveStartInclusion(void) { - if(pending_command == 0) { - // OpenZWave::Manager::Get()->AddNode(gHomeId); - OpenZWave::Manager::Get()->BeginControllerCommand(gHomeId, OpenZWave::Driver::ControllerCommand_AddDevice, OnDeviceStatusUpdate, NULL, true); - } -} - -void zwaveStartExclusion(void) { - if(pending_command == 0) { - // OpenZWave::Manager::Get()->RemoveNode(gHomeId); - OpenZWave::Manager::Get()->BeginControllerCommand(gHomeId, OpenZWave::Driver::ControllerCommand_RemoveDevice, OnDeviceStatusUpdate, NULL, true); - } -} - -void zwaveStopCommand(void) { - if(pending_command == 1) { - OpenZWave::Manager::Get()->CancelControllerCommand(gHomeId); - } -} - -void zwaveSoftReset(void) { - OpenZWave::Manager::Get()->SoftReset(gHomeId); -} - -void zwaveHardReset(void) { - // OpenZWave::Manager::Get()->ResetController(gHomeId); -} - -void zwaveGetConfigParam(int nodeId, int paramId) { - OpenZWave::Manager::Get()->RequestConfigParam(gHomeId, nodeId, paramId); -} - -void zwaveSetConfigParam(int nodeId, int paramId, int valueId, int len) { - OpenZWave::Manager::Get()->SetConfigParam(gHomeId, nodeId, paramId, valueId, len); -} - -static void *zwaveReceive(void *param) { - threads++; - - while(init_lock_init == 0 && zwave->stop == 0) { - usleep(10); - } - - sleep(1); - - if(zwave->stop == 0) { - pthread_cond_wait(&init_signal, &init_lock); - - if(driver_status == DRIVER_STATUS_NODES_QUERIED) { - logprintf(LOG_INFO, "[Z-Wave]: all nodes queried"); - } else if(driver_status == DRIVER_STATUS_NODES_QUERIED_SOME_DEAD) { - logprintf(LOG_INFO, "[Z-Wave]: nodes partially queried"); - } - - while(zwave->stop == 0) { - sleep(3); - } - } - threads--; - return (void *)NULL; -} - -static unsigned short zwaveSettings(JsonNode *json) { - int i = 0; - if(strcmp(json->key, "comport") == 0) { - if(json->tag == JSON_STRING) { - for(i=0;istring_) == 0) { - strcpy(com, json->string_); - return EXIT_SUCCESS; - } - } - } - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void zwaveInit(void) { - hardware_register(&zwave); - hardware_set_id(zwave, "zwave"); - - options_add(&zwave->options, 'p', "comport", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - zwave->hwtype=ZWAVE; - zwave->comtype=COMAPI; - zwave->init=&zwaveHwInit; - zwave->deinit=&zwaveHwDeinit; - zwave->sendAPI=&zwaveSend; - zwave->receiveAPI=&zwaveReceive; - zwave->settings=&zwaveSettings; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "zwave"; - module->version = "1.0"; - module->reqversion = "6.0"; - module->reqcommit = "40"; -} - -void init(void) { - zwaveInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/hardware/zwave.h b/lib/ESPiLight/pilight/libs/pilight/hardware/zwave.h deleted file mode 100644 index d1ca1d3..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/hardware/zwave.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _HARDWARE_ZWAVE_H_ -#define _HARDWARE_ZWAVE_H_ - -#include "../config/hardware.h" - -#define COMMAND_CLASS_SWITCH_BINARY 0x25 -#define COMMAND_CLASS_SWITCH_MULTILEVEL 0x26 -#define COMMAND_CLASS_SWITCH_ALL 0x27 -#define COMMAND_CLASS_CONFIGURATION 0x70 -#define COMMAND_CLASS_POWERLEVEL 0x73 - -typedef struct zwave_values_t { - int nodeId; - int cmdId; - int valueId; - union { - int number_; - char *string_; - }; - int valueType; - int instance; - int genre; - char *label; - struct zwave_values_t *next; -} zwave_values_t; - -struct zwave_values_t *zwave_values; - -struct hardware_t *zwave; -void zwaveInit(void); -unsigned long long zwaveGetValueId(int nodeId, int cmdId); -void zwaveSetValue(int nodeId, int cmdId, char *label, char *value); -void zwaveStartInclusion(void); -void zwaveStartExclusion(void); -void zwaveStopCommand(void); -void zwaveSoftReset(void); -void zwaveGetConfigParam(int nodeId, int paramId); -void zwaveSetConfigParam(int nodeId, int paramId, int valueId, int len); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/lua/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/lua/CMakeLists.txt deleted file mode 100644 index a680a57..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/lua/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -project(pilight_lua) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/lua/lua.c b/lib/ESPiLight/pilight/libs/pilight/lua/lua.c deleted file mode 100644 index 4b59e3b..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/lua/lua.c +++ /dev/null @@ -1,722 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 - #include - #include - #include -#endif - -#include "lua.h" -#include "lualibrary.h" - -#include "../core/log.h" -#include "../core/json.h" -#include "../core/mem.h" -#include "../core/common.h" - -#define NRLUASTATES 5 - -static int init = 0; -struct lua_state_t lua_state[NRLUASTATES]; -struct plua_module_t *modules = NULL; - -/* LCOV_EXCL_START */ -void plua_stack_dump(lua_State *L) { - int i = 0; - int top = lua_gettop(L); - for(i = 1; i <= top; i++) { /* repeat for each level */ - int t = lua_type(L, i); - switch(t) { - case LUA_TSTRING: /* strings */ - printf("%d: '%s'", i, lua_tostring(L, i)); - break; - case LUA_TBOOLEAN: /* booleans */ - printf("%d: %s", i, lua_toboolean(L, i) ? "true" : "false"); - break; - case LUA_TNUMBER: /* numbers */ - printf("%d: %g", i, lua_tonumber(L, i)); - break; - default: /* other values */ - printf("%d: %s", i, lua_typename(L, t)); - break; - } - printf(" "); /* put a separator */ - } - printf("\n"); /* end the listing */ -} -/* LCOV_EXCL_STOP */ - -static void plua_metatable_free(struct plua_metatable_t *table) { - int x = 0; - for(x=0;xnrvar;x++) { - if(table->table[x].val.type_ == LUA_TSTRING) { - FREE(table->table[x].val.string_); - } - if(table->table[x].key.type_ == LUA_TSTRING) { - FREE(table->table[x].key.string_); - } - } - if(table->nrvar > 0) { - FREE(table->table); - } - FREE(table); -} - -void plua_metatable_clone(struct plua_metatable_t **src, struct plua_metatable_t **dst) { - int i = 0; - struct plua_metatable_t *a = *src; - - if((*dst) != NULL) { - plua_metatable_free((*dst)); - } - if(((*dst) = MALLOC(sizeof(struct plua_metatable_t))) == NULL) { - OUT_OF_MEMORY - } - memset((*dst), 0, sizeof(struct plua_metatable_t)); - if(((*dst)->table = MALLOC(sizeof(*a->table)*(a->nrvar))) == NULL) { - OUT_OF_MEMORY - } - memset((*dst)->table, 0, sizeof(*a->table)*(a->nrvar)); - for(i=0;inrvar;i++) { - (*dst)->table[i].key.type_ = a->table[i].key.type_; - (*dst)->table[i].val.type_ = a->table[i].val.type_; - - if(a->table[i].key.type_ == LUA_TSTRING) { - if(((*dst)->table[i].key.string_ = STRDUP(a->table[i].key.string_)) == NULL) { - OUT_OF_MEMORY - } - } - if(a->table[i].key.type_ == LUA_TNUMBER) { - (*dst)->table[i].key.number_ = a->table[i].key.number_; - } - - if(a->table[i].val.type_ == LUA_TSTRING) { - if(((*dst)->table[i].val.string_ = STRDUP(a->table[i].val.string_)) == NULL) { - OUT_OF_MEMORY - } - } - if(a->table[i].val.type_ == LUA_TNUMBER) { - (*dst)->table[i].val.number_ = a->table[i].val.number_; - } - } - (*dst)->nrvar = a->nrvar; -} - -int plua_metatable_pairs(lua_State *L) { - logprintf(LOG_NOTICE, "pilight lua metatables do not support pairs"); - return 0; -} - -int plua_metatable_get(lua_State *L) { - struct plua_metatable_t *node = NULL; - char buf[128] = { '\0' }, *p = buf; - char *error = "string or number expected, got %s"; - int x = 0; - - sprintf(p, error, lua_typename(L, lua_type(L, -1))); - - luaL_argcheck(L, - (lua_isstring(L, -1) || lua_isnumber(L, -1)), - 1, buf); - - struct lua_state_t *state = plua_get_current_state(L); - - node = state->table; - for(x=0;xnrvar;x++) { - if((lua_isnumber(L, -1) == 1 && node->table[x].key.type_ == LUA_TNUMBER && node->table[x].key.number_ == (int)lua_tonumber(L, -1)) || - (lua_isstring(L, -1) == 1 && node->table[x].key.type_ == LUA_TSTRING && strcmp(node->table[x].key.string_, lua_tostring(L, -1)) == 0)) { - if(node->table[x].val.type_ == LUA_TNUMBER) { - lua_pushnumber(L, node->table[x].val.number_); - } - if(node->table[x].val.type_ == LUA_TSTRING) { - lua_pushstring(L, node->table[x].val.string_); - } - return 1; - } - } - - return 0; -} - -int plua_metatable_set(lua_State *L) { - struct plua_metatable_t *node = NULL; - char buf[128] = { '\0' }, *p = buf; - char *error = "string or number expected, got %s"; - int match = 0, x = 0; - - sprintf(p, error, lua_typename(L, lua_type(L, -1))); - - luaL_argcheck(L, - (lua_isstring(L, -1) || lua_isnumber(L, -1)), - 1, buf); - - sprintf(p, error, lua_typename(L, lua_type(L, -1))); - - luaL_argcheck(L, - (lua_isstring(L, -2) || lua_isnumber(L, -2)), - 1, buf); - - struct lua_state_t *state = plua_get_current_state(L); - - node = state->table; - for(x=0;xnrvar;x++) { - if((lua_isnumber(L, -2) == 1 && node->table[x].key.type_ == LUA_TNUMBER && node->table[x].key.number_ == (int)lua_tonumber(L, -1)) || - (lua_isstring(L, -2) == 1 && node->table[x].key.type_ == LUA_TSTRING && strcmp(node->table[x].key.string_, lua_tostring(L, -1)) == 0)) { - match = 1; - if(lua_isnumber(L, -1) == 1) { - node->table[x].val.number_ = lua_tonumber(L, -1); - node->table[x].val.type_ = LUA_TNUMBER; - } - if(lua_isstring(L, -1) == 1) { - node->table[x].val.string_ = STRDUP((char *)lua_tostring(L, -1)); - node->table[x].val.type_ = LUA_TSTRING; - } - break; - } - } - - if(node != NULL) { - if(match == 0) { - int idx = node->nrvar; - if((node->table = REALLOC(node->table, sizeof(*node->table)*(idx+1))) == NULL) { - OUT_OF_MEMORY - } - if(lua_isnumber(L, -1) == 1) { - node->table[idx].val.number_ = lua_tonumber(L, -1); - node->table[idx].val.type_ = LUA_TNUMBER; - } - if(lua_isstring(L, -1) == 1) { - node->table[idx].val.string_ = STRDUP((char *)lua_tostring(L, -1)); - node->table[idx].val.type_ = LUA_TSTRING; - } - if(lua_isnumber(L, -2) == 1) { - node->table[idx].key.number_ = lua_tonumber(L, -2); - node->table[idx].key.type_ = LUA_TNUMBER; - } - if(lua_isstring(L, -2) == 1) { - node->table[idx].key.string_ = STRDUP((char *)lua_tostring(L, -2)); - node->table[idx].key.type_ = LUA_TSTRING; - } - node->nrvar++; - } - } - return 1; -} - -int plua_metatable_gc(lua_State *L){ - return 1; -} - -struct lua_state_t *plua_get_free_state(void) { - int i = 0; - for(i=0;i key -2 => table - */ - lua_pushstring(L, key); - - if(lua_istable(L, -2) == 0) { - /* - * Remove the key from the stack again - * - * stack now contains: -1 => table - */ - lua_pop(L, 1); - return 0; - } - - /* - * Replace the key at -1 with it value in table -2 - * - * stack now contains: -1 => value -2 => table - */ - lua_gettable(L, -2); - - /* - * Check if the first element is a number - */ - if(lua_isstring(L, -1) == 0) { - /* - * Remove the value from the stack again - * - * stack now contains: -1 => table - */ - lua_pop(L, 1); - return 0; - } - - *ret = lua_tostring(L, -1); - - /* - * stack now contains: -1 => table - */ - lua_pop(L, 1); - return 1; -} - -// static int plua_get_table_double_by_key(struct lua_State *L, const char *key, double *ret) { - // /* - // * Push the key we want to retrieve on the stack - // * - // * stack now contains: -1 => key -2 => table - // */ - // lua_pushstring(L, key); - - // /* - // * Replace the key at -1 with it value in table -2 - // * - // * stack now contains: -1 => value -2 => table - // */ - // if(lua_istable(L, -2) == 0) { - // /* - // * Remove the key from the stack again - // * - // * stack now contains: -1 => table - // */ - // lua_pop(L, 1); - // return 0; - // } - // /* - // * Replace the key at -1 with it value in table -2 - // * - // * stack now contains: -1 => value -2 => table - // */ - // lua_gettable(L, -2); - - // /* - // * Check if the first element is a number - // */ - // if(lua_isnumber(L, -1) == 0) { - // /* - // * Remove the value from the stack again - // * - // * stack now contains: -1 => table - // */ - // lua_pop(L, 1); - // return 0; - // } - - // *ret = lua_tonumber(L, -1); - - // /* - // * stack now contains: -1 => table - // */ - // lua_pop(L, 1); - - // return 1; -// } - -static int plua_table_has_keys(lua_State *L, char **keys, int number) { - if(lua_istable(L, -1) == 0) { - return 0; - } - - int i = 0; - /* - * Push another reference to the table on top of the stack (so we know - * where it is), and this function can work for negative, positive and - * pseudo indices. - * - * stack now contains: -1 => table -2 => table - */ - lua_pushvalue(L, -1); - - /* - * stack now contains: -1 => nil -2 => table -3 => table - */ - lua_pushnil(L); - - int match = 0, nrkeys = 0; - while(lua_next(L, -2)) { - nrkeys++; - - /* - * stack now contains: -1 => value -2 => key -3 => table - * - * copy the key so that lua_tostring does not modify the original - * - * stack now contains: -1 => key -2 => value; -3 => key -4 => table -5 => table - */ - lua_pushvalue(L, -2); - - const char *k = lua_tostring(L, -1); // key - - for(i=0;i key -2 => table -3 => table - */ - lua_pop(L, 2); - } - /* - * After the last lua_next call stack now contains: - * -1 => table -2 => table - */ - if(match != number || nrkeys != number) { - return 0; - } - - /* - * Remove duplicated table from stack - * - * stack now contains -1 => table - */ - lua_pop(L, 1); - - return 1; -} - -static int plua_module_init(struct lua_State *L, char *file, struct plua_module_t *mod) { - /* - * Function info is at top of stack - * - * stack now contains -1 => function - */ -#if LUA_VERSION_NUM <= 502 - lua_getfield(L, -1, "info"); - if(strcmp(lua_typename(L, lua_type(L, -1)), "function") != 0) { -#else - if(lua_getfield(L, -1, "info") == 0) { -#endif - logprintf(LOG_ERR, "%s: info function missing", file); - return 0; - } - - char *type = NULL; - switch(mod->type) { - case FUNCTION: { - type = STRDUP("event function"); - } break; - case OPERATOR: { - type = STRDUP("event operator"); - } break; - } - if(type == NULL) { - OUT_OF_MEMORY - } - - /* - * Returned table (first argument) is at top of stack - * - * stack now contains -1 => function - */ - if(lua_pcall(L, 0, 1, 0) == LUA_ERRRUN) { - if(strcmp(lua_typename(L, lua_type(L, -1)), "string") == 0) { - logprintf(LOG_ERR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return 0; - } - } - - if(lua_istable(L, -1) == 0) { - logprintf(LOG_ERR, "%s: the info function returned %s, table expected", file, lua_typename(L, lua_type(L, -1))); - FREE(type); - return 0; - } - - char *keys[12] = {"name", "version", "reqversion", "reqcommit"}; - if(plua_table_has_keys(L, keys, 4) == 0) { - logprintf(LOG_ERR, "%s: the info table has invalid keys", file); - FREE(type); - return 0; - } - - const char *name = NULL, *version = NULL, *reqversion = NULL, *reqcommit = NULL; - if(plua_get_table_string_by_key(L, "name", &name) == 0) { - logprintf(LOG_ERR, "%s: the info table 'name' key is missing or invalid", file); - FREE(type); - return 0; - } - - if(plua_get_table_string_by_key(L, "version", &version) == 0) { - logprintf(LOG_ERR, "%s: the info table 'version' key is missing or invalid", file); - FREE(type); - return 0; - } - - if(plua_get_table_string_by_key(L, "reqversion", &reqversion) == 0) { - logprintf(LOG_ERR, "%s: the info table 'reqversion' key is missing or invalid", file); - FREE(type); - return 0; - } - if(plua_get_table_string_by_key(L, "reqcommit", &reqcommit) == 0) { - logprintf(LOG_ERR, "%s: the info table 'reqcommit' key is missing or invalid", file); - FREE(type); - return 0; - } - - strcpy(mod->name, name); - strcpy(mod->version, version); - strcpy(mod->reqversion, reqversion); - strcpy(mod->reqcommit, reqcommit); - - char pilight_version[strlen(PILIGHT_VERSION)+1]; - char pilight_commit[3], *v = (char *)reqversion, *r = (char *)reqcommit; - int valid = 1, check = 1; - - memset(&pilight_commit, 0, sizeof(pilight_commit)); - - strcpy(pilight_version, PILIGHT_VERSION); - - if((check = vercmp(v, pilight_version)) > 0) { - valid = 0; - } - - if(check == 0 && strlen(mod->reqcommit) > 0) { - sscanf(HASH, "v%*[0-9].%*[0-9]-%[0-9]-%*[0-9a-zA-Z\n\r]", pilight_commit); - - if(strlen(pilight_commit) > 0 && (vercmp(r, pilight_commit)) > 0) { - valid = 0; - } - } - if(valid == 1) { - logprintf(LOG_DEBUG, "loaded %s %s v%s", type, file, version); - } else { - if(strlen(mod->reqcommit) > 0) { - logprintf(LOG_ERR, "%s %s requires at least pilight v%s (commit %s)", type, file, mod->reqversion, mod->reqcommit); - } else { - logprintf(LOG_ERR, "%s %s requires at least pilight v%s", type, file, mod->reqversion); - } - /* - * Pop function from stack - * - * The stack now contains: nothing - */ - lua_pop(L, 1); - FREE(type); - return 0; - } - - /* - * Pop function from stack - * - * The stack now contains: nothing - */ - lua_pop(L, 1); - FREE(type); - return 1; -} - -static int plua_writer(lua_State *L, const void* p, size_t sz, void* ud) { - struct plua_module_t *module = ud; - if((module->bytecode = REALLOC(module->bytecode, module->size+sz)) == NULL) { - OUT_OF_MEMORY - } - memcpy(module->bytecode, p, sz); - module->size += sz; - return 0; -} - -void plua_module_load(char *file, int type) { - struct plua_module_t *module = MALLOC(sizeof(struct plua_module_t)); - lua_State *L = lua_state[0].L; - char name[255] = { '\0' }, *p = name; - int i = 0; - if(module == NULL) { - OUT_OF_MEMORY - } - memset(module, 0, sizeof(struct plua_module_t)); - - if(luaL_loadfile(L, file) != 0) { - logprintf(LOG_ERR, "cannot load lua file: %s", file); - lua_pop(L, 1); - FREE(module); - return; - } - strcpy(module->file, file); - if(lua_dump(L, plua_writer, module) != 0) { - logprintf(LOG_ERR, "cannot dump lua file: %s", file); - lua_pop(L, 1); - FREE(module->bytecode); - FREE(module); - return; - } - - lua_pcall(L, 0, LUA_MULTRET, 0); - - if(lua_istable(L, -1) == 0) { - logprintf(LOG_ERR, "%s: does not return a table", file); - lua_pop(L, 1); - FREE(module->bytecode); - FREE(module); - return; - } - - module->type = type; - strcpy(module->file, file); - if(plua_module_init(L, file, module) != 0) { - memset(p, '\0', sizeof(name)); - switch(module->type) { - case OPERATOR: - sprintf(p, "operator.%s", module->name); - break; - case FUNCTION: - sprintf(p, "function.%s", module->name); - break; - } - - module->next = modules; - modules = module; - } else { - FREE(module->bytecode); - FREE(module); - return; - } - lua_setglobal(L, name); - - for(i=1;ibytecode, module->size, module->name); - } - lua_pcall(L, 0, LUA_MULTRET, 0); - lua_setglobal(L, name); -} - -struct plua_module_t *plua_get_modules(void) { - return modules; -} - -// static void *plua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) { - // if(nsize == 0) { - // if(ptr != NULL) { - // FREE(ptr); - // } - // return 0; - // } else { - // return REALLOC(ptr, nsize); - // } -// } - -void plua_init(void) { - if(init == 1) { - return; - } - init = 1; - - int i = 0; - for(i=0;iL) == NULL) { - uv_mutex_unlock(&state->lock); - return 1; - } - - char name[255], *p = name; - memset(name, '\0', 255); - - switch(type) { - case OPERATOR: { - sprintf(p, "operator.%s", module); - } break; - case FUNCTION: - sprintf(p, "function.%s", module); - break; - } - - lua_getglobal(L, name); - if(lua_isnil(L, -1) != 0) { - lua_pop(L, -1); - return -1; - } - if(lua_istable(L, -1) == 0) { - lua_pop(L, -1); - return -1; - } - lua_pop(L, -1); - - uv_mutex_unlock(&state->lock); - return 0; -} - -int plua_gc(void) { - struct plua_module_t *tmp = NULL; - while(modules) { - tmp = modules; - FREE(tmp->bytecode); - modules = modules->next; - FREE(tmp); - } - int i = 0; - for(i=0;i -#include -#include - -#include "../libs/pilight/core/common.h" - -#define OPERATOR 1 -#define FUNCTION 2 - -typedef struct plua_metatable_t { - struct { - struct varcont_t val; - struct varcont_t key; - } *table; - int nrvar; - int idx; -} plua_metatable_t; - -typedef struct plua_module_t { - char name[255]; - char file[PATH_MAX]; - char version[12]; - char reqversion[12]; - char reqcommit[12]; - void *bytecode; - int size; - int type; - - struct plua_module_t *next; -} plua_module_t; - -typedef struct lua_state_t { - lua_State *L; - uv_mutex_t lock; - struct plua_module_t *module; - struct plua_metatable_t *table; - int idx; -} lua_state_t; - -int plua_metatable_set(lua_State *L); -int plua_metatable_get(lua_State *L); -int plua_metatable_gc(lua_State *L); -int plua_metatable_pairs(lua_State *L); -void plua_stack_dump(lua_State *L); -void plua_module_load(char *, int); -int plua_module_exists(char *, int); -void plua_metatable_clone(struct plua_metatable_t **, struct plua_metatable_t **); -struct lua_state_t *plua_get_free_state(void); -struct lua_state_t *plua_get_current_state(lua_State *L); -struct plua_module_t *plua_get_modules(void); -void plua_init(void); -int plua_gc(void); - -#endif \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/lua/lualibrary.c b/lib/ESPiLight/pilight/libs/pilight/lua/lualibrary.c deleted file mode 100644 index e4d16a4..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/lua/lualibrary.c +++ /dev/null @@ -1,623 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 - #include - #include - #include - #include - #include -#endif - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/strptime.h" -#include "../core/datetime.h" -#include "../core/dso.h" -#include "../core/log.h" -#include "../core/cast.h" -#include "../protocols/protocol.h" -#ifdef PILIGHT_REWRITE -#include "../storage/storage.h" -#else -#include "../config/devices.h" -#endif -#include "lua.h" - -typedef struct lua_thread_t { - lua_state_t *state; - char *callback; -} lua_thread_t; - -static int plua_toboolean(struct lua_State *L) { - char buf[128] = { '\0' }, *p = buf; - char *error = "string, number, or boolean expected, got %s"; - sprintf(p, error, lua_typename(L, lua_type(L, 1))); - - luaL_argcheck(L, - (lua_isstring(L, 1) || lua_isnumber(L, 1) || lua_isboolean(L, 1)), - 1, buf); - - switch(lua_type(L, 1)) { - case LUA_TSTRING: { - const char *str = lua_tostring(L, 1); - if(strcmp(str, "0") == 0 || strlen(str) == 0) { - lua_pop(L, -1); - lua_pushboolean(L, 0); - } else { - lua_pop(L, -1); - lua_pushboolean(L, 1); - } - } break; - case LUA_TNUMBER: { - int num = (int)lua_tonumber(L, 1); - lua_pop(L, -1); - lua_pushboolean(L, num); - } break; - case LUA_TBOOLEAN: { - // int b = lua_toboolean(L, 1); - // lua_pop(L, -1); - // lua_pushboolean(L, b); - } break; - } - - return 1; -} - -static int plua_tonumber(struct lua_State *L) { - char buf[128] = { '\0' }, *p = buf; - char *error = "string, number, or boolean expected, got %s"; - sprintf(p, error, lua_typename(L, lua_type(L, 1))); - - luaL_argcheck(L, - (lua_isstring(L, 1) || lua_isnumber(L, 1) || lua_isboolean(L, 1)), - 1, buf); - - switch(lua_type(L, 1)) { - case LUA_TSTRING: { - const char *str = lua_tostring(L, 1); - float num = atof(str); - lua_pop(L, -1); - lua_pushnumber(L, num); - } break; - case LUA_TNUMBER: { - // float num = lua_tonumber(L, 1); - // lua_pop(L, -1); - // lua_pushnumber(L, num); - } break; - case LUA_TBOOLEAN: { - int b = lua_toboolean(L, 1); - lua_pop(L, -1); - if(b == 0) { - lua_pushnumber(L, 0); - } else { - lua_pushnumber(L, 1); - } - } break; - } - - return 1; -} - -static int plua_tostring(struct lua_State *L) { - char buf[128] = { '\0' }, *p = buf; - char *error = "string, number, or boolean expected, got %s"; - sprintf(p, error, lua_typename(L, lua_type(L, 1))); - - luaL_argcheck(L, - (lua_isstring(L, 1) || lua_isnumber(L, 1) || lua_isboolean(L, 1)), - 1, buf); - - switch(lua_type(L, 1)) { - case LUA_TSTRING: { - // const char *str = lua_tostring(L, 1); - // lua_pop(L, -1); - // lua_pushstring(L, str); - } break; - case LUA_TNUMBER: { - float num = lua_tonumber(L, 1); - lua_pop(L, -1); - - char *tmp = NULL; - int len = snprintf(NULL, 0, "%.6f", num); - if((tmp = MALLOC(len+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(tmp, 0, len+1); - sprintf(tmp, "%.6f", num); - lua_pushstring(L, tmp); - FREE(tmp); - } break; - case LUA_TBOOLEAN: { - int b = lua_toboolean(L, 1); - lua_pop(L, -1); - if(b == 0) { - lua_pushstring(L, "0"); - } else { - lua_pushstring(L, "1"); - } - } break; - } - - return 1; -} - -static void datetime2table(struct lua_State *L, char *device) { - struct varcont_t val; - struct tm tm; - memset(&tm, 0, sizeof(struct tm)); -#ifdef PILIGHT_REWRITE - char *setting = NULL; - int i = 0; - while(devices_select_settings(ORIGIN_RULE, device, i++, &setting, &val) == 0) { - if(strcmp(setting, "year") == 0) { - tm.tm_year = val.number_-1900; - } - if(strcmp(setting, "month") == 0) { - tm.tm_mon = val.number_-1; - } - if(strcmp(setting, "day") == 0) { - tm.tm_mday = val.number_; - } - if(strcmp(setting, "hour") == 0) { - tm.tm_hour = val.number_; - } - if(strcmp(setting, "minute") == 0) { - tm.tm_min = val.number_; - } - if(strcmp(setting, "second") == 0) { - tm.tm_sec = val.number_; - } - if(strcmp(setting, "weekday") == 0) { - tm.tm_wday = val.number_-1; - } - if(strcmp(setting, "dst") == 0) { - tm.tm_isdst = val.number_; - } - } -#else - struct devices_t *dev = NULL; - if(devices_get(device, &dev) == 0) { - struct devices_settings_t *tmp_settings = dev->settings; - while(tmp_settings) { - val.type_ = tmp_settings->values->type; - if(val.type_ == JSON_STRING) { - val.string_ = tmp_settings->values->string_; - } else if(val.type_ == JSON_NUMBER) { - val.number_ = tmp_settings->values->number_; - val.decimals_ = tmp_settings->values->decimals; - } - if(strcmp(tmp_settings->name, "year") == 0) { - tm.tm_year = val.number_-1900; - } - if(strcmp(tmp_settings->name, "month") == 0) { - tm.tm_mon = val.number_-1; - } - if(strcmp(tmp_settings->name, "day") == 0) { - tm.tm_mday = val.number_; - } - if(strcmp(tmp_settings->name, "hour") == 0) { - tm.tm_hour = val.number_; - } - if(strcmp(tmp_settings->name, "minute") == 0) { - tm.tm_min = val.number_; - } - if(strcmp(tmp_settings->name, "second") == 0) { - tm.tm_sec = val.number_; - } - if(strcmp(tmp_settings->name, "weekday") == 0) { - tm.tm_wday = val.number_-1; - } - if(strcmp(tmp_settings->name, "dst") == 0) { - tm.tm_isdst = val.number_; - } - tmp_settings = tmp_settings->next; - } - } -#endif -int year = tm.tm_year+1900; - int month = tm.tm_mon+1; - int day = tm.tm_mday; - int hour = tm.tm_hour; - int minute = tm.tm_min; - int second = tm.tm_sec; - int weekday = tm.tm_wday; - - datefix(&year, &month, &day, &hour, &minute, &second, &weekday); - - lua_createtable(L, 0, 2); - - lua_pushstring(L, "type"); - lua_pushnumber(L, DATETIME); - lua_settable(L, -3); - - lua_pushstring(L, "year"); - lua_pushnumber(L, year); - lua_settable(L, -3); - - lua_pushstring(L, "month"); - lua_pushnumber(L, month); - lua_settable(L, -3); - - lua_pushstring(L, "day"); - lua_pushnumber(L, day); - lua_settable(L, -3); - - lua_pushstring(L, "hour"); - lua_pushnumber(L, hour); - lua_settable(L, -3); - - lua_pushstring(L, "min"); - lua_pushnumber(L, minute); - lua_settable(L, -3); - - lua_pushstring(L, "sec"); - lua_pushnumber(L, second); - lua_settable(L, -3); - - lua_pushstring(L, "weekday"); - lua_pushnumber(L, weekday); - lua_settable(L, -3); -} - -static int plua_getdevice(struct lua_State *L) { - if(lua_gettop(L) != 1) { - luaL_error(L, "pilight.plua_getdevice requires 1 arguments, %d given", lua_gettop(L)); - return 0; - } - char buf[128] = { '\0' }, *p = buf; - char *error = "string expected, got %s"; - sprintf(p, error, lua_typename(L, lua_type(L, 1))); - - luaL_argcheck(L, - (lua_isstring(L, 1)), - 1, buf); - - const char *device = NULL; - if(lua_type(L, -1) == LUA_TSTRING) { - device = lua_tostring(L, -1); - lua_pop(L, 1); - } - char *d = (char *)device; - -#ifdef PILIGHT_REWRITE - if(devices_select(ORIGIN_RULE, d, NULL) == 0) { - struct protocol_t *protocol = NULL; - if(devices_select_protocol(ORIGIN_RULE, d, 0, &protocol) == 0) { - if(protocol->devtype == DATETIME) { - datetime2table(L, d); - } - } -#else - struct devices_t *dev = NULL; - if(devices_get(d, &dev) == 0) { - struct protocols_t *tmp = dev->protocols; - while(tmp) { - if(tmp->listener->devtype == DATETIME) { - datetime2table(L, d); - } - tmp = tmp->next; - } -#endif - } else { - // luaL_error(L, "device \"%s\" does not exist", d); - return 0; - } - - return 1; -} - -static int plua_strptime(struct lua_State *L) { - if(lua_gettop(L) != 2) { - luaL_error(L, "pilight.strptime requires 2 arguments, %d given", lua_gettop(L)); - return 0; - } - char buf[128] = { '\0' }, *p = buf; - char *error = "string expected, got %s"; - sprintf(p, error, lua_typename(L, lua_type(L, 1))); - - luaL_argcheck(L, - (lua_isstring(L, 1)), - 1, buf); - - sprintf(p, error, lua_typename(L, lua_type(L, 2))); - luaL_argcheck(L, - (lua_isstring(L, 2)), - 2, buf); - - const char *datetime = NULL; - const char *format = NULL; - if(lua_type(L, -1) == LUA_TSTRING) { - datetime = lua_tostring(L, -1); - lua_pop(L, 1); - } - if(lua_type(L, -1) == LUA_TSTRING) { - format = lua_tostring(L, -1); - lua_pop(L, 1); - } - - struct tm tm; - memset(&tm, 0, sizeof(struct tm)); - if(strptime(datetime, format, &tm) == NULL) { - luaL_error(L, "pilight.strptime is unable to parse \"%s\" as \"%s\" ", datetime, format); - return 0; - } - - int year = tm.tm_year+1900; - int month = tm.tm_mon+1; - int day = tm.tm_mday; - int hour = tm.tm_hour; - int minute = tm.tm_min; - int second = tm.tm_sec; - int weekday = tm.tm_wday; - - datefix(&year, &month, &day, &hour, &minute, &second, &weekday); - - lua_createtable(L, 0, 2); - - lua_pushstring(L, "year"); - lua_pushnumber(L, year); - lua_settable(L, -3); - - lua_pushstring(L, "month"); - lua_pushnumber(L, month); - lua_settable(L, -3); - - lua_pushstring(L, "day"); - lua_pushnumber(L, day); - lua_settable(L, -3); - - lua_pushstring(L, "hour"); - lua_pushnumber(L, hour); - lua_settable(L, -3); - - lua_pushstring(L, "min"); - lua_pushnumber(L, minute); - lua_settable(L, -3); - - lua_pushstring(L, "sec"); - lua_pushnumber(L, second); - lua_settable(L, -3); - - lua_pushstring(L, "weekday"); - lua_pushnumber(L, weekday); - lua_settable(L, -3); - - return 1; -} - -static int plua_random(struct lua_State *L) { - if(lua_gettop(L) != 2) { - luaL_error(L, "pilight.random requires 2 arguments, %d given", lua_gettop(L)); - return 0; - } - char buf[128] = { '\0' }, *p = buf; - char *error = "number expected, got %s"; - sprintf(p, error, lua_typename(L, lua_type(L, 1))); - - luaL_argcheck(L, - (lua_isnumber(L, 1)), - 1, buf); - - sprintf(p, error, lua_typename(L, lua_type(L, 2))); - luaL_argcheck(L, - (lua_isnumber(L, 2)), - 2, buf); - - int min = 0, max = 0; - if(lua_type(L, -1) == LUA_TNUMBER || lua_type(L, -1) == LUA_TSTRING) { - max = (int)lua_tonumber(L, -1); - lua_pop(L, 1); - } - if(lua_type(L, -1) == LUA_TNUMBER || lua_type(L, -1) == LUA_TSTRING) { - min = (int)lua_tonumber(L, -1); - lua_pop(L, 1); - } - - struct timeval t1; - gettimeofday(&t1, NULL); - srand(t1.tv_usec * t1.tv_sec); - - int r = rand() / (RAND_MAX + 1.0) * (max - min + 1) + min; - - lua_pushnumber(L, r); - - return 1; -} - -static void thread_free(uv_work_t *req, int status) { - struct lua_thread_t *thread = req->data; - FREE(thread->callback); - FREE(req->data); - FREE(req); -} - -static void thread_callback(uv_work_t *req) { - struct lua_thread_t *thread = req->data; - struct lua_state_t *state = thread->state; - - char name[255], *p = name; - memset(name, '\0', 255); - - switch(state->module->type) { - case FUNCTION: { - sprintf(p, "function.%s", state->module->name); - } break; - case OPERATOR: { - sprintf(p, "operator.%s", state->module->name); - } break; - } - - lua_getglobal(state->L, name); - if(lua_isnil(state->L, -1) != 0) { - logprintf(LOG_ERR, "cannot find %s lua module", name); - return; - } - -#if LUA_VERSION_NUM <= 502 - lua_getfield(state->L, -1, thread->callback); - if(strcmp(lua_typename(state->L, lua_type(state->L, -1)), "function") != 0) { -#else - if(lua_getfield(state->L, -1, thread->callback) == 0) { -#endif - logprintf(LOG_ERR, "%s: thread callback %s does not exist", state->module->file, thread->callback); - return; - } - - lua_newtable(state->L); - lua_createtable(state->L, 0, 1); - lua_pushcfunction(state->L, plua_metatable_get); - lua_setfield(state->L, -2, "__index"); - lua_pushcfunction(state->L, plua_metatable_set); - lua_setfield(state->L, -2, "__newindex"); - lua_pushcfunction(state->L, plua_metatable_gc); - lua_setfield(state->L, -2, "__gc"); - lua_pushcfunction(state->L, plua_metatable_pairs); - lua_setfield(state->L, -2, "__pairs"); - lua_setmetatable(state->L, -2); - - if(lua_pcall(state->L, 1, 0, 0) == LUA_ERRRUN) { - if(strcmp(lua_typename(state->L, lua_type(state->L, -1)), "string") == 0) { - logprintf(LOG_ERR, "%s", lua_tostring(state->L, -1)); - lua_pop(state->L, 1); - return; - } - } - - uv_mutex_unlock(&state->lock); -} - -static int plua_thread(struct lua_State *L) { - if(lua_gettop(L) != 1) { - luaL_error(L, "pilight.devices_select_string_setting requires at least 1 argument, %d given", lua_gettop(L)); - return 0; - } - - const char *func = NULL; - char buf[128] = { '\0' }, *p = buf; - char *error = "string expected, got %s"; - - sprintf(p, error, lua_typename(L, lua_type(L, 1))); - - luaL_argcheck(L, - (lua_isstring(L, 1)), - 1, buf); - - if(lua_type(L, -1) == LUA_TSTRING) { - func = lua_tostring(L, -1); - lua_pop(L, 1); - } - - char name[255]; - memset(name, '\0', 255); - - p = name; - - struct lua_state_t *state = plua_get_current_state(L); - if(state == NULL) { - return 1; - } - - switch(state->module->type) { - case FUNCTION: { - sprintf(p, "function.%s", state->module->name); - } break; - case OPERATOR: { - sprintf(p, "operator.%s", state->module->name); - } break; - } - - lua_getglobal(L, name); - if(lua_isnil(L, -1) != 0) { - logprintf(LOG_ERR, "cannot find %s lua module"); - return 1; - } - -#if LUA_VERSION_NUM <= 502 - lua_getfield(L, -1, func); - if(strcmp(lua_typename(L, lua_type(L, -1)), "function") != 0) { -#else - if(lua_getfield(L, -1, func) == 0) { -#endif - logprintf(LOG_ERR, "%s: thread callback %s does not exist", state->module->file, func); - return 1; - } - - struct lua_state_t *new_state = plua_get_free_state(); - new_state->module = state->module; - - plua_metatable_clone(&state->table, &new_state->table); - - uv_work_t *tp_work_req = MALLOC(sizeof(uv_work_t)); - if(tp_work_req == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - struct lua_thread_t *lua_thread = MALLOC(sizeof(struct lua_thread_t)); - if(lua_thread == NULL) { - OUT_OF_MEMORY - } - lua_thread->state = new_state; - if((lua_thread->callback = STRDUP((char *)func)) == NULL) { - OUT_OF_MEMORY - } - tp_work_req->data = lua_thread; - char *pthname = "lua thread on state #%d"; - memset(buf, 0, sizeof(buf)); - p = buf; - sprintf(p, pthname, new_state->idx); - - if(uv_queue_work(uv_default_loop(), tp_work_req, buf, thread_callback, thread_free) < 0) { - FREE(lua_thread->callback); - FREE(lua_thread); - FREE(tp_work_req); - - uv_mutex_unlock(&new_state->lock); - } - - return 1; -} - -static struct lua_libs { - char *name; - int (*func)(struct lua_State *); -} pilightlib[] = { - {"toboolean", plua_toboolean}, - {"tonumber", plua_tonumber}, - {"tostring", plua_tostring}, - {"strptime", plua_strptime}, - {"getdevice", plua_getdevice}, - {"random", plua_random}, - {"thread", plua_thread}, - {NULL, NULL} -}; - -void plua_register_library(struct lua_State *L) { - int i = 0; - /* - * Register pilight lua library - */ - lua_newtable(L); - while(pilightlib[i].name != NULL) { - lua_pushcfunction(L, pilightlib[i].func); - lua_setfield(L, -2, pilightlib[i].name); - i++; - } - lua_pushvalue(L, -1); - lua_setglobal(L, "pilight"); -} \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/lua/lualibrary.h b/lib/ESPiLight/pilight/libs/pilight/lua/lualibrary.h deleted file mode 100644 index 78f631c..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/lua/lualibrary.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#ifndef _PLUA_LIBRARY_H_ -#define _PLUA_LIBRARY_H_ - -#include "lua.h" - -void plua_register_library(struct lua_State *); - -#endif \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeExclude.txt deleted file mode 100644 index b6ec939..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeExclude.txt +++ /dev/null @@ -1,257 +0,0 @@ -include(../../../../CMakeConfig.txt) - -if(${PROTOCOL_ALECTO_WSD17} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/alecto_wsd17.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/alecto_wsd17.h") -endif() - -if(${PROTOCOL_ALECTO_WX500} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/alecto_wx500.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/alecto_wx500.h") -endif() - -if(${PROTOCOL_COGEX_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_KAKU_SWITCH_OLD} MATCHES "OFF" - AND ${PROTOCOL_BYEBYESTANDBY_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_DUWI_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_PROMAX_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_INTERTECHNO_OLD} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_switch_old.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_switch_old.h") -endif() - -if(${PROTOCOL_RSL366} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/rsl366.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/rsl366.h") -endif() - -if(${PROTOCOL_DAYCOM} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/daycom.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/daycom.h") -endif() - -if(${PROTOCOL_KAKU_SCREEN_OLD} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_screen_old.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_screen_old.h") -endif() - -if(${PROTOCOL_KAKU_DUSK} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_dusk.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_dusk.h") -endif() - -if(${PROTOCOL_KAKU_MOTION} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_motion.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_motion.h") -endif() - -if(${PROTOCOL_KAKU_DIMMER} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_dimmer.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_dimmer.h") -endif() - -if(${PROTOCOL_KAKU_SCREEN} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_screen.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_screen.h") -endif() - -if(${PROTOCOL_KAKU_CONTACT} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_contact.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_contact.h") -endif() - -if(${PROTOCOL_COCO_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_DIO_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_NEXA_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_KAKU_SWITCH} MATCHES "OFF" - AND ${PROTOCOL_INTERTECHNO_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arctech_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arctech_switch.h") -endif() - -if(${PROTOCOL_ELRO_SWITCH} MATCHES "OFF" AND ${PROTOCOL_BRENNENSTUHL_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/elro_300_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/elro_400_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/elro_800_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/elro_300_switch.h") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/elro_400_switch.h") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/elro_800_switch.h") -endif() - -if(${PROTOCOL_ELRO_CONTACT} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/elro_800_contact.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/elro_800_contact.h") -endif() - -if(${PROTOCOL_EURODOMEST_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/eurodomest_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/eurodomest_switch.h") -endif() - -if(${PROTOCOL_IMPULS} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/impuls.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/impuls.h") -endif() - -if(${PROTOCOL_SELECTREMOTE} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/selectremote.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/selectremote.h") -endif() - -if(${PROTOCOL_EHOME} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/ehome.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/ehome.h") -endif() - -if(${PROTOCOL_RAW} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/raw.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/raw.h") -endif() - -if(${PROTOCOL_REV} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/rev_v1.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/rev_v2.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/rev_v3.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/rev_v1.h") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/rev_v2.h") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/rev_v3.h") -endif() - -if(${PROTOCOL_CLARUS} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/clarus.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/clarus.h") -endif() - -if(${PROTOCOL_CONRAD_RSL_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/conrad_rsl_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/conrad_rsl_switch.h") -endif() - -if(${PROTOCOL_CONRAD_WEATHER} MATCHES "OFF" - AND ${PROTOCOL_TFA} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/tfa.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/tfa30.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/tfa.h") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/tfa30.h") -endif() - -if(${PROTOCOL_CONRAD_RSL_CONTACT} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/conrad_rsl_contact.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/conrad_rsl_contact.h") -endif() - -if(${PROTOCOL_POLLIN_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/pollin.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/pollin.h") -endif() - -if(${PROTOCOL_QUIGG_GT7000} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/quigg_gt7000.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/quigg_gt7000.h") -endif() - -if(${PROTOCOL_MUMBI_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/mumbi.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/mumbi.h") -endif() - -if(${PROTOCOL_SILVERCREST} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/silvercrest.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/silvercrest.h") -endif() - -if(${PROTOCOL_CLEVERWATTS} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/cleverwatts.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/cleverwatts.h") -endif() - -if(${PROTOCOL_ALECTO_WS1700} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/alecto_ws1700.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/alecto_ws1700.h") -endif() - -if(${PROTOCOL_AURIOL} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/auriol.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/auriol.h") -endif() - -if(${PROTOCOL_TEKNIHALL} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/teknihall.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/teknihall.h") -endif() - -if(${PROTOCOL_X10} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/x10.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/x10.h") -endif() - -if(${PROTOCOL_EV1527} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/ev1527.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/ev1527.h") -endif() - -if(${PROTOCOL_BEAMISH_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/beamish_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/beamish_switch.h") -endif() - -if(${PROTOCOL_QUIGG_SCREEN} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/quigg_screen.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/quigg_screen.h") -endif() - -if(${PROTOCOL_NINJABLOCKS_WEATHER} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/ninjablocks_weather.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/ninjablocks_weather.h") -endif() - -if(${PROTOCOL_TECHLICO} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/techlico_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/techlico_switch.h") -endif() - -if(${PROTOCOL_SC2262} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/sc2262.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/sc2262.h") -endif() - -if(${PROTOCOL_RC101} MATCHES "OFF" AND - ${PROTOCOL_RC102} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/rc101.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/rc101.h") -endif() - -if(${PROTOCOL_QUIGG_GT1000} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/quigg_gt1000.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/quigg_gt1000.h") -endif() - -if(${PROTOCOL_LOGILINK_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/logilink_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/logilink_switch.h") -endif() - -if(${PROTOCOL_HEITECH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/heitech.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/heitech.h") -endif() - -if(${PROTOCOL_HEITECH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/heitech.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/heitech.h") -endif() - -if(${PROTOCOL_SECUDO_SMOKE} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/secudo_smoke.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/secudo_smoke.h") -endif() - -if(${PROTOCOL_TCM} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/tcm.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/tcm.h") -endif() - -if(${PROTOCOL_LIVOLO_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/livolo_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/livolo_switch.h") -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeInclude.txt deleted file mode 100644 index 496cba9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE protocol_result - OUTPUT_VARIABLE protocol_init) - -set(inits) -foreach(init ${protocol_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeLists.txt deleted file mode 100644 index 2bebfdc..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(pilight_protocols_433.92) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeExclude.txt) -include(CMakeInclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/protocol_header.h.in deleted file mode 100644 index da97564..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/protocol_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/protocol_init.h.in deleted file mode 100644 index 40bdc9d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/433.92/protocol_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeExclude.txt deleted file mode 100644 index 23336f5..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeExclude.txt +++ /dev/null @@ -1,41 +0,0 @@ -include(../../../../CMakeConfig.txt) - -if(${PROTOCOL_CPU_TEMP} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/cpu_temp.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/cpu_temp.h") -endif() - -if(${PROTOCOL_WUNDERGROUND} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/wunderground.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/wunderground.h") -endif() - -if(${PROTOCOL_OPENWEATHERMAP} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/openweathermap.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/openweathermap.h") -endif() - -if(${PROTOCOL_SUNRISESET} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/sunriseset.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/sunriseset.h") -endif() - -if(${PROTOCOL_PROGRAM} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/program.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/program.h") -endif() - -if(${PROTOCOL_DATETIME} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/datetime.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/datetime.h") -endif() - -if(${PROTOCOL_XBMC} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/xbmc.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/xbmc.h") -endif() - -if(${PROTOCOL_LIRC} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/lirc.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/lirc.h") -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeInclude.txt deleted file mode 100644 index 496cba9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE protocol_result - OUTPUT_VARIABLE protocol_init) - -set(inits) -foreach(init ${protocol_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeLists.txt deleted file mode 100644 index 590aae9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(pilight_protocols_api) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeExclude.txt) -include(CMakeInclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/cpu_temp.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/cpu_temp.c deleted file mode 100644 index 11adc49..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/cpu_temp.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "cpu_temp.h" - -#ifndef _WIN32 -#ifdef PILIGHT_DEVELOPMENT -static unsigned short loop = 1; -static unsigned short threads = 0; -static char cpu_path[] = "/sys/class/thermal/thermal_zone0/temp"; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct stat st; - - FILE *fp = NULL; - double itmp = 0; - int *id = MALLOC(sizeof(int)); - char *content = NULL; - int nrloops = 0, nrid = 0, y = 0, interval = 0; - double temp_offset = 0.0; - size_t bytes = 0; - - threads++; - - if(id == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_number(jchild, "id", &itmp) == 0) { - id = REALLOC(id, (sizeof(int)*(size_t)(nrid+1))); - id[nrid] = (int)round(itmp); - nrid++; - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - for(y=0;ymessage = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "id", json_mknumber(id[y], 0)); - json_append_member(code, "temperature", json_mknumber((temp/1000), 3)); - - json_append_member(cpuTemp->message, "message", code); - json_append_member(cpuTemp->message, "origin", json_mkstring("receiver")); - json_append_member(cpuTemp->message, "protocol", json_mkstring(cpuTemp->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(cpuTemp->id, cpuTemp->message, PROTOCOL); - } - json_delete(cpuTemp->message); - cpuTemp->message = NULL; - } - } else { - logprintf(LOG_NOTICE, "CPU sysfs \"%s\" does not exist", cpu_path); - } - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - FREE(id); - threads--; - return (void *)NULL; -} -#else - -static char cpu_path[PATH_MAX] = "/sys/class/thermal/thermal_zone0/temp"; - -typedef struct data_t { - char *name; - int id; - int interval; - uv_timer_t *timer_req; - double temp_offset; - struct data_t *next; -} data_t; - -static struct data_t *data = NULL; - -#ifdef PILIGHT_REWRITE -static void *reason_code_received_free(void *param) { - struct reason_code_received_t *data = param; - FREE(data); - return NULL; -} -#endif - -static void *thread(void *param) { - uv_timer_t *timer_req = param; - struct data_t *settings = timer_req->data; - FILE *fp = NULL; - struct stat st; - char *content = NULL; - size_t bytes = 0; - - if((fp = fopen(cpu_path, "rb"))) { - fstat(fileno(fp), &st); - bytes = (size_t)st.st_size; - if((content = REALLOC(content, bytes+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(content, '\0', bytes+1); - - if(fread(content, sizeof(char), bytes, fp) == -1) { - logprintf(LOG_NOTICE, "cannot read file: %s", cpu_path); - fclose(fp); - return NULL; - } else { - fclose(fp); - double temp = atof(content)+settings->temp_offset; - FREE(content); - -#ifdef PILIGHT_DEVELOPMENT - struct reason_code_received_t *data = MALLOC(sizeof(struct reason_code_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - snprintf(data->message, 1024, "{\"id\":%d,\"temperature\":%.3f}", settings->id, (temp/1000)); - strcpy(data->origin, "receiver"); - data->protocol = cpuTemp->id; - if(strlen(pilight_uuid) > 0) { - data->uuid = pilight_uuid; - } else { - data->uuid = NULL; - } - data->repeat = 1; - eventpool_trigger(REASON_CODE_RECEIVED, reason_code_received_free, data); -#else - char message[1024]; - snprintf(message, 1024, - "{\"origin\":\"receiver\",\"protocol\":\"%s\",\"message\":"\ - "{\"id\":%d,\"temperature\":%.3f}"\ - "}", - cpuTemp->id, settings->id, (temp/1000) - ); - - cpuTemp->message = json_decode(message); - - if(pilight.broadcast != NULL) { - pilight.broadcast(cpuTemp->id, cpuTemp->message, PROTOCOL); - } - json_delete(cpuTemp->message); - cpuTemp->message = NULL; -#endif - } - } else { - logprintf(LOG_NOTICE, "CPU sysfs \"%s\" does not exists", cpu_path); - } - - return (void *)NULL; -} -#endif - -static struct threadqueue_t *initDev(struct JsonNode *jdevice) { -#ifdef PILIGHT_DEVELOPMENT - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(cpuTemp, json); - return threads_register("cpu_temp", &thread, (void *)node, 0); -#else -#ifdef PILIGHT_REWRITE - struct JsonNode *jdevice = NULL; -#endif - struct JsonNode *jprotocols = NULL; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct data_t *node = NULL; - FILE *fp = NULL; - double itmp = 0; - int match = 0; - -#ifdef PILIGHT_REWRITE - if(param == NULL) { - return NULL; - } - - if((jdevice = json_first_child(param)) == NULL) { - return NULL; - } -#endif - if((jprotocols = json_find_member(jdevice, "protocol")) != NULL) { - jchild = json_first_child(jprotocols); - while(jchild) { - if(strcmp(cpuTemp->id, jchild->string_) == 0) { - match = 1; - break; - } - jchild = jchild->next; - } - } - - if(match == 0) { - return NULL; - } - - if(!(fp = fopen(cpu_path, "rb"))) { - logprintf(LOG_NOTICE, "CPU sysfs \"%s\" does not exists", cpu_path); - return NULL; - } else { - fclose(fp); - } - - if((node = MALLOC(sizeof(struct data_t)))== NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, '\0', sizeof(struct data_t)); - node->interval = 10; - node->temp_offset = 0; - - if((jid = json_find_member(jdevice, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_number(jchild, "id", &itmp) == 0) { - node->id = (int)round(itmp); - } - jchild = jchild->next; - } - } - - if(json_find_number(jdevice, "poll-interval", &itmp) == 0) - node->interval = (int)round(itmp); - json_find_number(jdevice, "temperature-offset", &node->temp_offset); - - if((node->name = MALLOC(strlen(jdevice->key)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->name, jdevice->key); - node->timer_req = NULL; - node->next = data; - data = node; - - if((node->timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->timer_req->data = node; - uv_timer_init(uv_default_loop(), node->timer_req); - assert(node->interval > 0); - uv_timer_start(node->timer_req, (void (*)(uv_timer_t *))thread, node->interval*1000, node->interval*1000); - - return NULL; -#endif -} - -static void threadGC(void) { -#ifdef PILIGHT_DEVELOPMENT - loop = 0; - protocol_thread_stop(cpuTemp); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(cpuTemp); -#else - struct data_t *tmp = NULL; - while(data) { - tmp = data; -#ifndef PILIGHT_REWRITE - uv_timer_stop(data->timer_req); -#endif - FREE(tmp->name); - data = data->next; - FREE(tmp); - } - if(data != NULL) { - FREE(data); - } -#endif -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void cpuTempInit(void) { -#ifndef _WIN32 - #ifdef PILIGHT_DEVELOPMENT - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); - #endif -#endif - - protocol_register(&cpuTemp); - protocol_set_id(cpuTemp, "cpu_temp"); - protocol_device_add(cpuTemp, "cpu_temp", "CPU temperature sensor"); - cpuTemp->devtype = WEATHER; - cpuTemp->hwtype = SENSOR; - - options_add(&cpuTemp->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,5}$"); - options_add(&cpuTemp->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "[0-9]"); - - // options_add(&cpuTemp->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&cpuTemp->options, 0, "temperature-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&cpuTemp->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&cpuTemp->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&cpuTemp->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "[0-9]"); - -#ifndef _WIN32 - cpuTemp->initDev=&initDev; - cpuTemp->threadGC=&threadGC; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "cpu_temp"; - module->version = "1.6"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - cpuTempInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/cpu_temp.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/cpu_temp.h deleted file mode 100644 index 9e92bd4..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/cpu_temp.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_CPU_TEMP_H_ -#define _PROTOCOL_CPU_TEMP_H_ - -#include "../protocol.h" - -struct protocol_t *cpuTemp; -void cpuTempInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/datetime.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/datetime.c deleted file mode 100644 index d4d2f9e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/datetime.c +++ /dev/null @@ -1,474 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #include - #include - #define MSG_NOSIGNAL 0 -#else - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include - #include - #include - #include - #include - #include -#endif -#include -#include -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/socket.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/ntp.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "../../core/datetime.h" -#include "datetime.h" - -#ifdef PILIGHT_DEVELOPMENT -static unsigned short loop = 1; -static unsigned short threads = 0; -static char *format = NULL; - -static pthread_mutex_t lock; - -static void *thread(void *param) { - char UTC[] = "UTC"; - struct protocol_threads_t *thread = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)thread->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct tm tm; - char *tz = NULL; - time_t t; - int counter = 0; - double longitude = 0.0, latitude = 0.0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - jchild1 = json_first_child(jchild); - while(jchild1) { - if(strcmp(jchild1->key, "longitude") == 0) { - longitude = jchild1->number_; - } - if(strcmp(jchild1->key, "latitude") == 0) { - latitude = jchild1->number_; - } - jchild1 = jchild1->next; - } - jchild = jchild->next; - } - } - - if((tz = coord2tz(longitude, latitude)) == NULL) { - logprintf(LOG_INFO, "datetime #%d, could not determine timezone", threads); - tz = UTC; - } else { - logprintf(LOG_INFO, "datetime #%d %.6f:%.6f seems to be in timezone: %s", threads, longitude, latitude, tz); - } - - t = time(NULL); - if(isntpsynced() == 0) { - t -= getntpdiff(); - } - - while(loop) { - pthread_mutex_lock(&lock); - t = time(NULL); - t -= getntpdiff(); - - /* Get UTC time */ - if(localtime_l(t, &tm, tz) == 0) { - int year = tm.tm_year+1900; - int month = tm.tm_mon+1; - int day = tm.tm_mday; - int hour = tm.tm_hour; - int minute = tm.tm_min; - int second = tm.tm_sec; - int weekday = tm.tm_wday+1; - int dst = tm.tm_isdst; - - datetime->message = json_mkobject(); - - JsonNode *code = json_mkobject(); - json_append_member(code, "longitude", json_mknumber(longitude, 6)); - json_append_member(code, "latitude", json_mknumber(latitude, 6)); - json_append_member(code, "year", json_mknumber(year, 0)); - json_append_member(code, "month", json_mknumber(month, 0)); - json_append_member(code, "day", json_mknumber(day, 0)); - json_append_member(code, "weekday", json_mknumber(weekday, 0)); - json_append_member(code, "hour", json_mknumber(hour, 0)); - json_append_member(code, "minute", json_mknumber(minute, 0)); - json_append_member(code, "second", json_mknumber(second, 0)); - json_append_member(code, "dst", json_mknumber(dst, 0)); - - json_append_member(datetime->message, "message", code); - json_append_member(datetime->message, "origin", json_mkstring("receiver")); - json_append_member(datetime->message, "protocol", json_mkstring(datetime->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(datetime->id, datetime->message, PROTOCOL); - } - - json_delete(datetime->message); - datetime->message = NULL; - counter++; - } - pthread_mutex_unlock(&lock); - sleep(1); - } - pthread_mutex_unlock(&lock); - - threads--; - return (void *)NULL; -} -#else - -static char UTC[] = "UTC"; -static char *format = NULL; -static int time_override = -1; - -typedef struct data_t { - char *name; - int id; - int interval; - uv_timer_t *timer_req; - - double longitude; - double latitude; - - char *tz; - - struct data_t *next; -} data_t; - -static struct data_t *data = NULL; - -#ifdef PILIGHT_REWRITE -static void *reason_code_received_free(void *param) { - struct reason_code_received_t *data = param; - FREE(data); - return NULL; -} - -static void *adaptDevice(int reason, void *param) { - struct JsonNode *jdevice = NULL; - struct JsonNode *jtime = NULL; - - if(param == NULL) { - return NULL; - } - - if((jdevice = json_first_child(param)) == NULL) { - return NULL; - } - - if(strcmp(jdevice->key, "datetime") != 0) { - return NULL; - } - - if((jtime = json_find_member(jdevice, "time-override")) != NULL) { - if(jtime->tag == JSON_NUMBER) { - time_override = jtime->number_; - } - } - - return NULL; -} -#endif - -static void *thread(void *param) { - uv_timer_t *timer_req = param; - struct data_t *settings = timer_req->data; - struct tm tm; - time_t t; - - if(time_override > -1) { - t = time_override; - } else { - t = time(NULL); - if(isntpsynced() == 0) { - t -= getntpdiff(); - } - } - - /* Get UTC time */ - if(localtime_l(t, &tm, settings->tz) == 0) { - int year = tm.tm_year+1900; - int month = tm.tm_mon+1; - int day = tm.tm_mday; - int hour = tm.tm_hour; - int minute = tm.tm_min; - int second = tm.tm_sec; - int weekday = tm.tm_wday+1; - int dst = tm.tm_isdst; - -#ifdef PILIGHT_REWRITE - struct reason_code_received_t *data = MALLOC(sizeof(struct reason_code_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - snprintf(data->message, 1024, - "{\"longitude\":%.6f,\"latitude\":%.6f,\"year\":%d,\"month\":%d,\"day\":%d,\"weekday\":%d,\"hour\":%d,\"minute\":%d,\"second\":%d,\"dst\":%d}", - settings->longitude, settings->latitude, year, month, day, weekday, hour, minute, second, dst - ); - strncpy(data->origin, "receiver", 255); - data->protocol = datetime->id; - if(strlen(pilight_uuid) > 0) { - data->uuid = pilight_uuid; - } else { - data->uuid = NULL; - } - data->repeat = 1; - eventpool_trigger(REASON_CODE_RECEIVED, reason_code_received_free, data); -#else - char message[1024]; - snprintf(message, 1024, - "{\"origin\":\"receiver\",\"protocol\":\"%s\",\"message\":"\ - "{\"longitude\":%.6f,\"latitude\":%.6f,\"year\":%d,\"month\":%d,\"day\":%d,\"weekday\":%d,\"hour\":%d,\"minute\":%d,\"second\":%d,\"dst\":%d}"\ - "}", - datetime->id, settings->longitude, settings->latitude, year, month, day, weekday, hour, minute, second, dst - ); - - datetime->message = json_decode(message); - - if(pilight.broadcast != NULL) { - pilight.broadcast(datetime->id, datetime->message, PROTOCOL); - } - json_delete(datetime->message); - datetime->message = NULL; -#endif - } - - return (void *)NULL; -} -#endif -static struct threadqueue_t *initDev(JsonNode *jdevice) { -#ifdef PILIGHT_DEVELOPMENT - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(datetime, json); - return threads_register("datetime", &thread, (void *)node, 0); -#else -#ifdef PILIGHT_REWRITE - struct JsonNode *jdevice = NULL; -#endif - struct JsonNode *jprotocols = NULL; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct data_t *node = NULL; - int match = 0; - -#ifdef PILIGHT_REWRITE - if(param == NULL) { - return NULL; - } -#endif - - if(!(datetime->masterOnly == 0 || pilight.runmode == STANDALONE)) { - return NULL; - } - -#ifdef PILIGHT_REWRITE - if((jdevice = json_first_child(param)) == NULL) { - return NULL; - } -#endif - if((jprotocols = json_find_member(jdevice, "protocol")) != NULL) { - jchild = json_first_child(jprotocols); - while(jchild) { - if(strcmp(datetime->id, jchild->string_) == 0) { - match = 1; - break; - } - jchild = jchild->next; - } - } - - if(match == 0) { - return NULL; - } - - if((node = MALLOC(sizeof(struct data_t)))== NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, '\0', sizeof(struct data_t)); - node->interval = 1; - - if((jid = json_find_member(jdevice, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - jchild1 = json_first_child(jchild); - while(jchild1) { - if(strcmp(jchild1->key, "longitude") == 0) { - node->longitude = jchild1->number_; - } - if(strcmp(jchild1->key, "latitude") == 0) { - node->latitude = jchild1->number_; - } - jchild1 = jchild1->next; - } - jchild = jchild->next; - } - } - - if((node->tz = coord2tz(node->longitude, node->latitude)) == NULL) { - logprintf(LOG_INFO, "datetime %s, could not determine timezone, defaulting to UTC", jdevice->key); - node->tz = UTC; - } else { - logprintf(LOG_INFO, "datetime %s %.6f:%.6f seems to be in timezone: %s", jdevice->key, node->longitude, node->latitude, node->tz); - } - - if((node->name = MALLOC(strlen(jdevice->key)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->name, jdevice->key); - - node->next = data; - node->timer_req = NULL; - data = node; - - if((node->timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->timer_req->data = node; - uv_timer_init(uv_default_loop(), node->timer_req); - - assert(node->interval > 0); - uv_timer_start(node->timer_req, (void (*)(uv_timer_t *))thread, node->interval*1000, node->interval*1000); -#endif - return NULL; -} - -static void threadGC(void) { -#ifdef PILIGHT_DEVELOPMENT - loop = 0; - - protocol_thread_stop(datetime); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(datetime); -#else - struct data_t *tmp = data; - while(tmp) { -#ifndef PILIGHT_REWRITE - uv_timer_stop(tmp->timer_req); -#endif - tmp = tmp->next; - } -#endif -} - -static void gc(void) { -#ifndef PILIGHT_DEVELOPMENT - struct data_t *tmp = NULL; - while(data) { - tmp = data; -#ifndef PILIGHT_REWRITE - uv_timer_stop(tmp->timer_req); -#endif - FREE(tmp->name); - data = data->next; - FREE(tmp); - } - if(data != NULL) { - FREE(data); - } -#endif - FREE(format); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void datetimeInit(void) { - - if((format = MALLOC(20)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(format, 0, 20); - strncpy(format, "HH:mm:ss YYYY-MM-DD", 19); - - protocol_register(&datetime); - protocol_set_id(datetime, "datetime"); - protocol_device_add(datetime, "datetime", "Date and Time protocol"); - datetime->devtype = DATETIME; - datetime->hwtype = API; - datetime->multipleId = 0; - datetime->masterOnly = 1; - - options_add(&datetime->options, 'o', "longitude", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&datetime->options, 'a', "latitude", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&datetime->options, 'y', "year", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&datetime->options, 'm', "month", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&datetime->options, 'd', "day", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&datetime->options, 'w', "weekday", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&datetime->options, 'h', "hour", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&datetime->options, 'i', "minute", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&datetime->options, 's', "second", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&datetime->options, 'z', "dst", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - - options_add(&datetime->options, 0, "show-datetime", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - options_add(&datetime->options, 0, "format", OPTION_HAS_VALUE, GUI_SETTING, JSON_STRING, (void *)format, NULL); - - datetime->initDev=&initDev; - datetime->threadGC=&threadGC; - datetime->gc=&gc; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "datetime"; - module->version = "2.6"; - module->reqversion = "6.0"; - module->reqcommit = "115"; -} - -void init(void) { - datetimeInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/datetime.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/datetime.h deleted file mode 100644 index 1c6f1f6..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/datetime.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_DATETIME_H_ -#define _PROTOCOL_DATETIME_H_ - -#include "../protocol.h" - -struct protocol_t *datetime; -void datetimeInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/lirc.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/lirc.c deleted file mode 100644 index 30b0bb9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/lirc.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #include - #include - #define MSG_NOSIGNAL 0 -#else - #include - #include - #include - #include - #include - #include - #include -#endif -#include -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/socket.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "lirc.h" - -#ifndef _WIN32 -static char socket_path[BUFFER_SIZE]; -static int sockfd = -1; - -static unsigned short loop = 1; -static unsigned short threads = 0; -static unsigned short initialized = 0; - - -// Windows -// #define UNIX_PATH_MAX 108 - -// struct sockaddr_un { - // uint16_t sun_family; - // char sun_path[UNIX_PATH_MAX]; -// }; - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct sockaddr_un addr; - struct timeval timeout; - - int nrloops = 0, n = -1, bytes = 0, retry = 0; - char recvBuff[BUFFER_SIZE]; - fd_set fdsread; - timeout.tv_sec = 1; - timeout.tv_usec = 0; - - /* Clear the server address */ - memset(&addr, '\0', sizeof(addr)); - memset(&recvBuff, '\0', BUFFER_SIZE); - - threads++; - - while(loop) { - if(sockfd > -1) { - close(sockfd); - sockfd = -1; - } - - if(path_exists(socket_path) == EXIT_SUCCESS) { - /* Try to open a new socket */ - if((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - logprintf(LOG_NOTICE, "could not create Lirc socket"); - break; - } - - addr.sun_family=AF_UNIX; - strcpy(addr.sun_path, socket_path); - - retry = 0; - /* Connect to the server */ - switch(socket_timeout_connect(sockfd, (struct sockaddr *)&addr, 3)) { - case -1: - logprintf(LOG_NOTICE, "could not connect to Lirc socket @%s", socket_path); - protocol_thread_wait(node, 3, &nrloops); - retry = 1; - break; - case -2: - logprintf(LOG_NOTICE, "Lirc socket timeout @%s", socket_path); - protocol_thread_wait(node, 3, &nrloops); - retry = 1; - break; - case -3: - logprintf(LOG_NOTICE, "Error in Lirc socket connection @%s", socket_path); - protocol_thread_wait(node, 3, &nrloops); - retry = 1; - break; - default: - break; - } - if(retry == 1) { - continue; - } - - while(loop) { - FD_ZERO(&fdsread); - FD_SET((unsigned long)sockfd, &fdsread); - - do { - n = select(sockfd+1, &fdsread, NULL, NULL, &timeout); - } while(n == -1 && errno == EINTR && loop); - - if(loop == 0) { - break; - } - - if(path_exists(socket_path) == EXIT_FAILURE) { - break; - } - - if(n == -1) { - break; - } else if(n == 0) { - usleep(100000); - } else if(n > 0) { - if(FD_ISSET((unsigned long)sockfd, &fdsread)) { - bytes = (int)recv(sockfd, recvBuff, BUFFER_SIZE, 0); - if(bytes <= 0) { - break; - } else { - char **nlarray = NULL; - unsigned int e = explode(recvBuff, "\n", &nlarray), t = 0; - for(t=0;t= 3) { - char **array = NULL; - unsigned int q = explode(nlarray[t], " ", &array); - if(q == 4) { - char *code1 = array[0]; - char *rep = array[1]; - char *btn = array[2]; - char *remote = array[3]; - char *y = NULL; - if((y = strstr(remote, "\n")) != NULL) { - size_t pos = (size_t)(y-remote); - remote[pos] = '\0'; - } - int r = strtol(rep, NULL, 16); - lirc->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "code", json_mkstring(code1)); - json_append_member(code, "repeat", json_mknumber(r, 0)); - json_append_member(code, "button", json_mkstring(btn)); - json_append_member(code, "remote", json_mkstring(remote)); - - json_append_member(lirc->message, "message", code); - json_append_member(lirc->message, "origin", json_mkstring("receiver")); - json_append_member(lirc->message, "protocol", json_mkstring(lirc->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(lirc->id, lirc->message, PROTOCOL); - } - json_delete(lirc->message); - lirc->message = NULL; - } - array_free(&array, q); - } - } - array_free(&nlarray, t); - memset(recvBuff, '\0', BUFFER_SIZE); - } - } - } - } - } else { - sleep(1); - } - } - - if(sockfd > -1) { - close(sockfd); - sockfd = -1; - } - - threads--; - return (void *)NULL; -} - -struct threadqueue_t *initDev(JsonNode *jdevice) { - loop = 1; - - if(initialized == 0) { - initialized = 1; - struct protocol_threads_t *node = protocol_thread_init(lirc, NULL); - return threads_register("lirc", &thread, (void *)node, 0); - } else { - return NULL; - } -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(lirc); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(lirc); - initialized = 0; -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void lircInit(void) { - protocol_register(&lirc); - protocol_set_id(lirc, "lirc"); - protocol_device_add(lirc, "lirc", "Lirc API"); - lirc->devtype = LIRC; - lirc->hwtype = API; - - options_add(&lirc->options, 'c', "code", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&lirc->options, 'a', "repeat", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "[0-9]"); - options_add(&lirc->options, 'b', "button", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&lirc->options, 'r', "remote", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, NULL); - -#ifndef _WIN32 - lirc->initDev=&initDev; - lirc->threadGC=&threadGC; - - memset(socket_path, '\0', BUFFER_SIZE); - strcpy(socket_path, "/dev/lircd"); -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "lirc"; - module->version = "1.10"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - lircInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/lirc.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/lirc.h deleted file mode 100644 index c55288d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/lirc.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_LIRC_H_ -#define _PROTOCOL_LIRC_H_ - -#include "../protocol.h" - -struct protocol_t *lirc; -void lircInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/openweathermap.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/openweathermap.c deleted file mode 100644 index 48e6009..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/openweathermap.c +++ /dev/null @@ -1,946 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include - -#ifndef PILIGHT_DEVELOPMENT -#include -#endif - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/datetime.h" // Full path because we also have a datetime protocol -#include "../../core/log.h" -#include "../../core/http.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "openweathermap.h" - -#define INTERVAL 600 - -#ifdef PILIGHT_DEVELOPMENT -typedef struct settings_t { - char *country; - char *location; - protocol_threads_t *thread; - time_t update; - int ointerval; - int interval; - - struct settings_t *next; -} settings_t; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static struct settings_t *settings; -static unsigned short loop = 1; -static unsigned short threads = 0; - -static void callback(int code, char *data, int size, char *type, void *userdata) { - struct JsonNode *jdata = NULL; - struct JsonNode *jmain = NULL; - struct JsonNode *jsys = NULL; - struct JsonNode *node = NULL; - double temp = 0, sunrise = 0, sunset = 0, humi = 0; - struct settings_t *wnode = userdata; - - time_t timenow = 0; - struct tm tm; - - if(code == 200) { - if(strstr(type, "application/json") != NULL) { - if(json_validate(data) == true) { - if((jdata = json_decode(data)) != NULL) { - if((jmain = json_find_member(jdata, "main")) != NULL - && (jsys = json_find_member(jdata, "sys")) != NULL) { - if((node = json_find_member(jmain, "temp")) == NULL) { - printf("api.openweathermap.org json has no temp key"); - } else if(json_find_number(jmain, "humidity", &humi) != 0) { - printf("api.openweathermap.org json has no humidity key"); - } else if(json_find_number(jsys, "sunrise", &sunrise) != 0) { - printf("api.openweathermap.org json has no sunrise key"); - } else if(json_find_number(jsys, "sunset", &sunset) != 0) { - printf("api.openweathermap.org json has no sunset key"); - } else { - if(node->tag != JSON_NUMBER) { - printf("api.openweathermap.org json has no temp key"); - } else { - temp = node->number_-273.15; - - timenow = time(NULL); - struct tm current; - memset(¤t, '\0', sizeof(struct tm)); - #ifdef _WIN32 - localtime(&timenow); - #else - localtime_r(&timenow, ¤t); - #endif - - int month = current.tm_mon+1; - int mday = current.tm_mday; - int year = current.tm_year+1900; - - time_t midnight = (datetime2ts(year, month, mday, 23, 59, 59)+1); - - openweathermap->message = json_mkobject(); - - JsonNode *code = json_mkobject(); - - json_append_member(code, "location", json_mkstring(wnode->location)); - json_append_member(code, "country", json_mkstring(wnode->country)); - json_append_member(code, "temperature", json_mknumber(temp, 2)); - json_append_member(code, "humidity", json_mknumber(humi, 2)); - json_append_member(code, "update", json_mknumber(0, 0)); - - time_t a = (time_t)sunrise; - memset(&tm, '\0', sizeof(struct tm)); - #ifdef _WIN32 - localtime(&a); - #else - localtime_r(&a, &tm); - #endif - json_append_member(code, "sunrise", json_mknumber((double)((tm.tm_hour*100)+tm.tm_min)/100, 2)); - - a = (time_t)sunset; - memset(&tm, '\0', sizeof(struct tm)); - #ifdef _WIN32 - localtime(&a); - #else - localtime_r(&a, &tm); - #endif - json_append_member(code, "sunset", json_mknumber((double)((tm.tm_hour*100)+tm.tm_min)/100, 2)); - if(timenow > (int)round(sunrise) && timenow < (int)round(sunset)) { - json_append_member(code, "sun", json_mkstring("rise")); - } else { - json_append_member(code, "sun", json_mkstring("set")); - } - - json_append_member(openweathermap->message, "message", code); - json_append_member(openweathermap->message, "origin", json_mkstring("receiver")); - json_append_member(openweathermap->message, "protocol", json_mkstring(openweathermap->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(openweathermap->id, openweathermap->message, PROTOCOL); - } - json_delete(openweathermap->message); - openweathermap->message = NULL; - - /* Send message when sun rises */ - if((int)round(sunrise) > timenow) { - if(((int)round(sunrise)-timenow) < wnode->ointerval) { - wnode->interval = (int)((int)round(sunrise)-timenow); - } - /* Send message when sun sets */ - } else if((int)round(sunset) > timenow) { - if(((int)round(sunset)-timenow) < wnode->ointerval) { - wnode->interval = (int)((int)round(sunset)-timenow); - } - /* Update all values when a new day arrives */ - } else { - if((midnight-timenow) < wnode->ointerval) { - wnode->interval = (int)(midnight-timenow); - } - } - - wnode->update = time(NULL); - } - } - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org json has no current_observation key"); - } - json_delete(jdata); - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org json could not be parsed"); - } - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "could not reach api.openweathermap.org"); - } - // if(data) { - // FREE(data); - // } -} - -static void *openweathermapParse(void *param) { - struct protocol_threads_t *thread = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)thread->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct settings_t *wnode = MALLOC(sizeof(struct settings_t)); - - wnode->ointerval = 86400; - wnode->interval = 86400; - - int event = 0; - int firstrun = 1, nrloops = 0, timeout = 0; - double itmp = 0.0; - - char url[1024]; - - threads++; - - if(wnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - int has_country = 0, has_location = 0; - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - has_country = 0, has_location = 0; - jchild1 = json_first_child(jchild); - - while(jchild1) { - if(strcmp(jchild1->key, "location") == 0) { - has_location = 1; - if((wnode->location = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(wnode->location, jchild1->string_); - } - if(strcmp(jchild1->key, "country") == 0) { - has_country = 1; - if((wnode->country = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(wnode->country, jchild1->string_); - } - jchild1 = jchild1->next; - } - if(has_country == 1 && has_location == 1) { - wnode->thread = thread; - wnode->next = settings; - settings = wnode; - } else { - if(has_country == 1) { - FREE(wnode->country); - } - if(has_location == 1) { - FREE(wnode->location); - } - FREE(wnode); - wnode = NULL; - } - jchild = jchild->next; - } - } - - if(wnode == NULL) { - return 0; - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - wnode->interval = (int)round(itmp); - wnode->ointerval = wnode->interval; - - while(loop) { - event = protocol_thread_wait(thread, INTERVAL, &nrloops); - pthread_mutex_lock(&lock); - if(loop == 0) { - break; - } - timeout += INTERVAL; - if(timeout >= wnode->interval || event != ETIMEDOUT || firstrun == 1) { - timeout = 0; - wnode->interval = wnode->ointerval; - - sprintf(url, "http://api.openweathermap.org/data/2.5/weather?q=%s,%s&APPID=8db24c4ac56251371c7ea87fd3115493", wnode->location, wnode->country); - http_get_content(url, callback, wnode); - } else { - openweathermap->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "location", json_mkstring(wnode->location)); - json_append_member(code, "country", json_mkstring(wnode->country)); - json_append_member(code, "update", json_mknumber(1, 0)); - json_append_member(openweathermap->message, "message", code); - json_append_member(openweathermap->message, "origin", json_mkstring("receiver")); - json_append_member(openweathermap->message, "protocol", json_mkstring(openweathermap->id)); - if(pilight.broadcast != NULL) { - pilight.broadcast(openweathermap->id, openweathermap->message, PROTOCOL); - } - json_delete(openweathermap->message); - openweathermap->message = NULL; - } - firstrun = 0; - - pthread_mutex_unlock(&lock); - } - pthread_mutex_unlock(&lock); - - threads--; - return (void *)NULL; -} -#else -static int min_interval = INTERVAL; -static int time_override = -1; -static char url[1024] = "http://api.openweathermap.org/data/2.5/weather?q=%s,%s&APPID=%s"; - -typedef struct data_t { - char *name; - char *country; - char *location; - char *api; - uv_timer_t *enable_timer_req; - uv_timer_t *update_timer_req; - - int interval; - double temp_offset; - - time_t update; - struct data_t *next; -} data_t; - -static struct data_t *data = NULL; - -static void *update(void *param); -static void *enable(void *param); - -#ifdef PILIGHT_REWRITE -static void *reason_code_received_free(void *param) { - struct reason_code_received_t *data = param; - FREE(data); - return NULL; -} -#endif - -static void callback(int code, char *data, int size, char *type, void *userdata) { - struct JsonNode *jdata = NULL; - struct JsonNode *jmain = NULL; - struct JsonNode *jsys = NULL; - struct JsonNode *node = NULL; - struct data_t *settings = userdata; - time_t timenow = 0; - struct tm tm_rise, tm_set; - double sunset = 0.0, sunrise = 0.0, temp = 0.0, humi = 0.0; - - memset(&tm_rise, 0, sizeof(struct tm)); - memset(&tm_set, 0, sizeof(struct tm)); - - if(code == 200) { - if(strstr(type, "application/json") != NULL) { - if(json_validate(data) == true) { - if((jdata = json_decode(data)) != NULL) { - if((jmain = json_find_member(jdata, "main")) != NULL - && (jsys = json_find_member(jdata, "sys")) != NULL) { - if((node = json_find_member(jmain, "temp")) == NULL) { - logprintf(LOG_NOTICE, "api.openweathermap.org json has no temp key"); - } else if(json_find_number(jmain, "humidity", &humi) != 0) { - logprintf(LOG_NOTICE, "api.openweathermap.org json has no humidity key"); - } else if(json_find_number(jsys, "sunrise", &sunrise) != 0) { - logprintf(LOG_NOTICE, "api.openweathermap.org json has no sunrise key"); - } else if(json_find_number(jsys, "sunset", &sunset) != 0) { - logprintf(LOG_NOTICE, "api.openweathermap.org json has no sunset key"); - } else { - if(node->tag != JSON_NUMBER) { - logprintf(LOG_NOTICE, "api.openweathermap.org json has no temp key"); - } else { - temp = node->number_-273.15; - - if(time_override > -1) { - timenow = time_override; - } else { - timenow = time(NULL); - } - - struct tm current; - memset(¤t, '\0', sizeof(struct tm)); -#ifdef _WIN32 - struct tm *tmp = gmtime(&timenow); - memcpy(¤t, tmp, sizeof(struct tm)); -#else - gmtime_r(&timenow, ¤t); -#endif - - int month = current.tm_mon+1; - int mday = current.tm_mday; - int year = current.tm_year+1900; - - time_t midnight = (datetime2ts(year, month, mday, 23, 59, 59)+1); - - char *_sun = NULL; - - time_t a = (time_t)sunrise; - memset(&tm_rise, '\0', sizeof(struct tm)); -#ifdef _WIN32 - tmp = gmtime(&a); - memcpy(&tm_rise, tmp, sizeof(struct tm)); -#else - gmtime_r(&a, &tm_rise); -#endif - a = (time_t)sunset; - memset(&tm_set, '\0', sizeof(struct tm)); -#ifdef _WIN32 - tmp = gmtime(&a); - memcpy(&tm_set, tmp, sizeof(struct tm)); -#else - gmtime_r(&a, &tm_set); -#endif - if(timenow > (int)round(sunrise) && timenow < (int)round(sunset)) { - _sun = "rise"; - } else { - _sun = "set"; - } - -#ifdef PILIGHT_REWRITE - struct reason_code_received_t *data = MALLOC(sizeof(struct reason_code_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - }; - snprintf(data->message, 1024, - "{\"api\":\"%s\",\"location\":\"%s\",\"country\":\"%s\",\"temperature\":%.2f,\"humidity\":%.2f,\"update\":0,\"sunrise\":%.2f,\"sunset\":%.2f,\"sun\":\"%s\"}", - settings->api, settings->location, settings->country, temp, humi, ((double)((tm_rise.tm_hour*100)+tm_rise.tm_min)/100), ((double)((tm_set.tm_hour*100)+tm_set.tm_min)/100), _sun - ); - strncpy(data->origin, "receiver", 255); - data->protocol = openweathermap->id; - if(strlen(pilight_uuid) > 0) { - data->uuid = pilight_uuid; - } else { - data->uuid = NULL; - } - data->repeat = 1; - - eventpool_trigger(REASON_CODE_RECEIVED, reason_code_received_free, data); -#else - char message[1024]; - snprintf(message, 1024, - "{\"origin\":\"receiver\",\"protocol\":\"%s\",\"message\":"\ - "{\"location\":\"%s\",\"country\":\"%s\",\"temperature\":%.2f,\"humidity\":%.2f,\"update\":0,\"sunrise\":%.2f,\"sunset\":%.2f,\"sun\":\"%s\"}"\ - "}", - openweathermap->id, settings->location, settings->country, temp, humi, ((double)((tm_rise.tm_hour*100)+tm_rise.tm_min)/100), ((double)((tm_set.tm_hour*100)+tm_set.tm_min)/100), _sun - ); - - openweathermap->message = json_decode(message); - - if(pilight.broadcast != NULL) { - pilight.broadcast(openweathermap->id, openweathermap->message, PROTOCOL); - } - json_delete(openweathermap->message); - openweathermap->message = NULL; -#endif - /* Send message when sun rises */ - if((int)round(sunrise) > timenow) { - if(((int)round(sunrise)-timenow) < settings->interval) { - settings->interval = (int)((int)round(sunrise)-timenow); - } - /* Send message when sun sets */ - } else if((int)round(sunset) > timenow) { - if(((int)round(sunset)-timenow) < settings->interval) { - settings->interval = (int)((int)round(sunset)-timenow); - } - /* Update all values when a new day arrives */ - } else { - if((midnight-timenow) < settings->interval) { - settings->interval = (int)(midnight-timenow); - } - } - - if(time_override > -1) { - settings->update = time_override; - } else { - settings->update = time(NULL); - } - - /* - * Update all values on next event as described above - */ - assert(settings->interval > 0); - uv_timer_start(settings->update_timer_req, (void (*)(uv_timer_t *))update, settings->interval*1000, 0); - /* - * Allow updating the values customly after INTERVAL seconds - */ - assert(min_interval > 0); - uv_timer_start(settings->enable_timer_req, (void (*)(uv_timer_t *))enable, min_interval*1000, 0); - } - } - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org json has no current_observation key"); - } - json_delete(jdata); - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org json could not be parsed"); - } - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "api.openweathermap.org response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "could not reach api.openweathermap.org"); - } - return; -} - -static void thread_free(uv_work_t *req, int status) { - FREE(req); -} - -static void thread(uv_work_t *req) { - struct data_t *settings = req->data; - char parsed[1024]; - char *enc = urlencode(settings->location); - - memset(parsed, '\0', 1024); - snprintf(parsed, 1024, url, enc, settings->country, settings->api); - FREE(enc); - - http_get_content(parsed, callback, settings); - return; -} - -static void *update(void *param) { - uv_timer_t *timer_req = param; - struct data_t *settings = timer_req->data; - - uv_work_t *work_req = NULL; - if((work_req = MALLOC(sizeof(uv_work_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - work_req->data = settings; - uv_queue_work(uv_default_loop(), work_req, "openweathermap", thread, thread_free); - if(time_override > -1) { - settings->update = time_override; - } else { - settings->update = time(NULL); - } - return NULL; -} - -static void *enable(void *param) { - uv_timer_t *timer_req = param; - struct data_t *settings = timer_req->data; - -#ifdef PILIGHT_REWRITE - struct reason_code_received_t *data = MALLOC(sizeof(struct reason_code_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - }; - snprintf(data->message, 1024, - "{\"api\":\"%s\",\"location\":\"%s\",\"country\":\"%s\",\"update\":1}", - settings->api, settings->location, settings->country - ); - strncpy(data->origin, "receiver", 255); - data->protocol = openweathermap->id; - if(strlen(pilight_uuid) > 0) { - data->uuid = pilight_uuid; - } else { - data->uuid = NULL; - } - data->repeat = 1; - eventpool_trigger(REASON_CODE_RECEIVED, reason_code_received_free, data); -#else - char message[1024]; - snprintf(message, 1024, - "{\"origin\":\"receiver\",\"protocol\":\"%s\",\"message\":"\ - "{\"location\":\"%s\",\"country\":\"%s\",\"update\":1}"\ - "}", - openweathermap->id, settings->location, settings->country - ); - - openweathermap->message = json_decode(message); - - if(pilight.broadcast != NULL) { - pilight.broadcast(openweathermap->id, openweathermap->message, PROTOCOL); - } - json_delete(openweathermap->message); - openweathermap->message = NULL; -#endif - return NULL; -} -#endif - -static struct threadqueue_t *initDev(struct JsonNode *jdevice) { -#ifdef PILIGHT_DEVELOPMENT - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(openweathermap, json); - return threads_register("openweathermap", &openweathermapParse, (void *)node, 0); -#else -#ifdef PILIGHT_REWRITE - struct JsonNode *jdevice = NULL; -#endif - struct JsonNode *jprotocols = NULL; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct data_t *node = NULL; - double itmp = 0; - int match = 0; - -#ifdef PILIGHT_REWRITE - if(param == NULL) { - return NULL; - } -#endif - - if(!(openweathermap->masterOnly == 0 || pilight.runmode == STANDALONE)) { - return NULL; - } - -#ifdef PILIGHT_REWRITE - if((jdevice = json_first_child(param)) == NULL) { - return NULL; - } -#endif - - if((jprotocols = json_find_member(jdevice, "protocol")) != NULL) { - jchild = json_first_child(jprotocols); - while(jchild) { - if(strcmp(openweathermap->id, jchild->string_) == 0) { - match = 1; - break; - } - jchild = jchild->next; - } - } - - if(match == 0) { - return NULL; - } - - if((node = MALLOC(sizeof(struct data_t)))== NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, '\0', sizeof(struct data_t)); - - node->interval = min_interval; - node->country = NULL; - node->location = NULL; - node->update = 0; - node->temp_offset = 0; - - int has_country = 0, has_location = 0, has_api = 0; - if((jid = json_find_member(jdevice, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - has_country = 0, has_location = 0, has_api = 0; - jchild1 = json_first_child(jchild); - - while(jchild1) { - if(strcmp(jchild1->key, "api") == 0) { - has_api = 1; - if((node->api = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->api, jchild1->string_); - } - if(strcmp(jchild1->key, "location") == 0) { - has_location = 1; - if((node->location = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->location, jchild1->string_); - } - if(strcmp(jchild1->key, "country") == 0) { - has_country = 1; - if((node->country = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->country, jchild1->string_); - } - jchild1 = jchild1->next; - } - if(has_country == 1 && has_location == 1 && has_api == 1) { - node->next = data; - data = node; - } else { - if(has_country == 1) { - FREE(node->country); - } - if(has_location == 1) { - FREE(node->location); - } - FREE(node); - node = NULL; - } - jchild = jchild->next; - } - } - - if(node == NULL) { - return NULL; - } - if(json_find_number(jdevice, "poll-interval", &itmp) == 0) - node->interval = (int)round(itmp); - json_find_number(jdevice, "temperature-offset", &node->temp_offset); - - if((node->name = MALLOC(strlen(jdevice->key)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->name, jdevice->key); - - if((node->enable_timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - if((node->update_timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - node->enable_timer_req->data = node; - node->update_timer_req->data = node; - - uv_timer_init(uv_default_loop(), node->enable_timer_req); - uv_timer_init(uv_default_loop(), node->update_timer_req); - - assert(node->interval > 0); - uv_timer_start(node->enable_timer_req, (void (*)(uv_timer_t *))enable, node->interval*1000, 0); - /* - * Do an update when this device is added after 3 seconds - * to make sure pilight is actually running. - */ - uv_timer_start(node->update_timer_req, (void (*)(uv_timer_t *))update, 3000, 0); - return NULL; -#endif -} - -static int checkValues(JsonNode *code) { - double interval = INTERVAL; - - json_find_number(code, "poll-interval", &interval); - - if((int)round(interval) < INTERVAL) { - logprintf(LOG_ERR, "openweathermap poll-interval cannot be lower than %d", INTERVAL); - return 1; - } - - return 0; -} - -static int createCode(JsonNode *code) { -#ifdef PILIGHT_DEVELOPMENT - struct settings_t *wtmp = settings; - char *country = NULL; - char *location = NULL; - double itmp = 0; - time_t currenttime = 0; - - if(json_find_number(code, "min-interval", &itmp) == 0) { - logprintf(LOG_ERR, "you can't override the min-interval setting"); - return EXIT_FAILURE; - } - - if(json_find_string(code, "country", &country) == 0 && - json_find_string(code, "location", &location) == 0 && - json_find_number(code, "update", &itmp) == 0) { - currenttime = time(NULL); - while(wtmp) { - if(strcmp(wtmp->country, country) == 0 - && strcmp(wtmp->location, location) == 0) { - if((currenttime-wtmp->update) > INTERVAL) { - pthread_mutex_unlock(&wtmp->thread->mutex); - pthread_cond_signal(&wtmp->thread->cond); - wtmp->update = time(NULL); - } - } - wtmp = wtmp->next; - } - } else { - logprintf(LOG_ERR, "openweathermap: insufficient number of arguments"); - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -#else - struct data_t *tmp = data; - char *country = NULL; - char *location = NULL; - char *api = NULL; - double itmp = 0; - - if(json_find_number(code, "min-interval", &itmp) == 0) { - logprintf(LOG_ERR, "you can't override the min-interval setting"); - return EXIT_FAILURE; - } - - if(json_find_string(code, "country", &country) == 0 && - json_find_string(code, "location", &location) == 0 && - json_find_string(code, "api", &api) == 0 && - json_find_number(code, "update", &itmp) == 0) { - - time_t currenttime = time(NULL); - if(time_override > -1) { - currenttime = time_override; - } - - while(tmp) { - if(strcmp(tmp->country, country) == 0 - && strcmp(tmp->location, location) == 0 - && strcmp(tmp->api, api) == 0) { - if((currenttime-tmp->update) > min_interval) { - - uv_work_t *work_req = NULL; - if((work_req = MALLOC(sizeof(uv_work_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - work_req->data = tmp; - uv_queue_work(uv_default_loop(), work_req, "openweathermap", thread, thread_free); - - if(time_override > -1) { - tmp->update = time_override; - } else { - tmp->update = time(NULL); - } - } - } - tmp = tmp->next; - } - } else { - logprintf(LOG_ERR, "openweathermap: insufficient number of arguments"); - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -#endif -} - -static void threadGC(void) { -#ifdef PILIGHT_DEVELOPMENT - loop = 0; - protocol_thread_stop(openweathermap); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(openweathermap); - - - struct settings_t *wtmp = NULL; - while(settings) { - wtmp = settings; - FREE(settings->country); - FREE(settings->location); - settings = settings->next; - FREE(wtmp); - } - if(settings != NULL) { - FREE(settings); - } -#else - struct data_t *tmp = NULL; - while(data) { - tmp = data; -#ifndef PILIGHT_REWRITE - uv_timer_stop(tmp->update_timer_req); - uv_timer_stop(tmp->enable_timer_req); -#endif - FREE(tmp->country); - FREE(tmp->location); - FREE(tmp->name); - FREE(tmp->api); - data = data->next; - FREE(tmp); - } - if(data != NULL) { - FREE(data); - } -#endif -} - -static void printHelp(void) { - printf("\t -c --country=country\t\tupdate an entry with this country\n"); - printf("\t -l --location=location\t\tupdate an entry with this location\n"); - printf("\t -a --api=api\t\t\tupdate an entry with this api code\n"); - printf("\t -u --update\t\t\tupdate the defined weather entry\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void openweathermapInit(void) { -#ifdef PILIGHT_DEVELOPMENT - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - - protocol_register(&openweathermap); - protocol_set_id(openweathermap, "openweathermap"); - protocol_device_add(openweathermap, "openweathermap", "Open Weather Map API"); - openweathermap->devtype = WEATHER; - openweathermap->hwtype = API; - openweathermap->multipleId = 0; - openweathermap->masterOnly = 1; - - options_add(&openweathermap->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,5}$"); - options_add(&openweathermap->options, 'h', "humidity", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,5}$"); - options_add(&openweathermap->options, 'l', "location", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^([a-zA-Z-]|[[:space:]])+$"); - options_add(&openweathermap->options, 'c', "country", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[a-zA-Z]+$"); - options_add(&openweathermap->options, 'a', "api", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[a-zA-Z0-9]+$"); - options_add(&openweathermap->options, 'x', "sunrise", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&openweathermap->options, 'y', "sunset", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&openweathermap->options, 's', "sun", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&openweathermap->options, 'u', "update", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - - // options_add(&openweathermap->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&openweathermap->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&openweathermap->options, 0, "humidity-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&openweathermap->options, 0, "sunriseset-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&openweathermap->options, 0, "show-humidity", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&openweathermap->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&openweathermap->options, 0, "show-sunriseset", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&openweathermap->options, 0, "show-update", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&openweathermap->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)86400, "[0-9]"); - - openweathermap->createCode=&createCode; - openweathermap->initDev=&initDev; - openweathermap->checkValues=&checkValues; - openweathermap->threadGC=&threadGC; - openweathermap->printHelp=&printHelp; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "openweathermap"; - module->version = "1.12"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - openweathermapInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/openweathermap.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/openweathermap.h deleted file mode 100644 index 55c8095..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/openweathermap.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_OPENWEATHERMAP_H_ -#define _PROTOCOL_OPENWEATHERMAP_H_ - -#include "../protocol.h" - -struct protocol_t *openweathermap; -void openweathermapInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/program.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/program.c deleted file mode 100644 index 31e5527..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/program.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "program.h" - -#ifndef _WIN32 -static unsigned short loop = 1; -static unsigned short threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -typedef struct settings_t { - char *name; - char *arguments; - char *program; - char *start; - char *stop; - int wait; - int currentstate; - int laststate; - pthread_t pth; - int hasthread; - protocol_threads_t *thread; - struct settings_t *next; -} settings_t; - -static struct settings_t *settings = NULL; - -static void *thread(void *param) { - struct protocol_threads_t *pnode = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)pnode->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - char *prog = NULL, *args = NULL, *stopcmd = NULL, *startcmd = NULL; - - int interval = 1, nrloops = 0; - int pid = 0; - double itmp = 0; - - threads++; - - json_find_string(json, "program", &prog); - json_find_string(json, "arguments", &args); - json_find_string(json, "stop-command", &stopcmd); - json_find_string(json, "start-command", &startcmd); - - struct settings_t *lnode = MALLOC(sizeof(struct settings_t)); - lnode->wait = 0; - lnode->hasthread = 0; - memset(&lnode->pth, '\0', sizeof(pthread_t)); - - if(args != NULL && strlen(args) > 0) { - if((lnode->arguments = MALLOC(strlen(args)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lnode->arguments, args); - } else { - lnode->arguments = NULL; - } - - if(prog != NULL) { - if((lnode->program = MALLOC(strlen(prog)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lnode->program, prog); - } else { - lnode->program = NULL; - } - - if(stopcmd != NULL) { - if((lnode->stop = MALLOC(strlen(stopcmd)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lnode->stop, stopcmd); - } else { - lnode->stop = NULL; - } - - if(startcmd != NULL) { - if((lnode->start = MALLOC(strlen(startcmd)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lnode->start, startcmd); - } else { - lnode->start = NULL; - } - - lnode->name = NULL; - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - jchild1 = json_first_child(jchild); - while(jchild1) { - if(strcmp(jchild1->key, "name") == 0) { - if((lnode->name = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lnode->name, jchild1->string_); - } - jchild1 = jchild1->next; - } - jchild = jchild->next; - } - } - - lnode->thread = pnode; - lnode->laststate = -1; - - lnode->next = settings; - settings = lnode; - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - - while(loop) { - if(protocol_thread_wait(pnode, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - if(lnode->wait == 0) { - struct JsonNode *message = json_mkobject(); - - JsonNode *code = json_mkobject(); - json_append_member(code, "name", json_mkstring(lnode->name)); - - if((pid = (int)findproc(lnode->program, lnode->arguments, 0)) > 0) { - lnode->currentstate = 1; - json_append_member(code, "state", json_mkstring("running")); - json_append_member(code, "pid", json_mknumber((int)pid, 0)); - } else { - lnode->currentstate = 0; - json_append_member(code, "state", json_mkstring("stopped")); - json_append_member(code, "pid", json_mknumber(0, 0)); - } - json_append_member(message, "message", code); - json_append_member(message, "origin", json_mkstring("receiver")); - json_append_member(message, "protocol", json_mkstring(program->id)); - - if(lnode->currentstate != lnode->laststate) { - lnode->laststate = lnode->currentstate; - if(pilight.broadcast != NULL) { - pilight.broadcast(program->id, message, PROTOCOL); - } - } - json_delete(message); - message = NULL; - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - threads--; - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(program, json); - return threads_register("program", &thread, (void *)node, 0); -} - -static void *execute(void *param) { - struct settings_t *p = (struct settings_t *)param; - int pid = 0; - int result = 0; - - if((pid = (int)findproc(p->program, p->arguments, 0)) > 0) { - result = system(p->stop); - } else { - result = system(p->start); - } - - /* Check of the user wanted to stop pilight */ - if(WIFSIGNALED(result)) { - int ppid = 0; - /* Find the pilight daemon pid */ - if((ppid = (int)findproc(progname, NULL, 0)) > 0) { - /* Send a sigint to ourself */ - kill(ppid, SIGINT); - } - } - - p->wait = 0; - memset(&p->pth, '\0', sizeof(pthread_t)); - p->hasthread = 0; - p->laststate = -1; - - pthread_mutex_unlock(&p->thread->mutex); - pthread_cond_signal(&p->thread->cond); - - return NULL; -} - -static int createCode(JsonNode *code) { - char *name = NULL; - double itmp = -1; - int state = -1; - int pid = 0; - - if(json_find_string(code, "name", &name) == 0) { - if(strstr(progname, "daemon") != NULL) { - struct settings_t *tmp = settings; - while(tmp) { - if(strcmp(tmp->name, name) == 0) { - if(tmp->wait == 0) { - if(tmp->name != NULL && tmp->stop != NULL && tmp->start != NULL) { - - if(json_find_number(code, "running", &itmp) == 0) - state = 1; - else if(json_find_number(code, "stopped", &itmp) == 0) - state = 0; - - if((pid = (int)findproc(tmp->program, tmp->arguments, 0)) > 0 && state == 1) { - logprintf(LOG_INFO, "program \"%s\" already running", tmp->name); - } else if(pid == -1 && state == 0) { - logprintf(LOG_INFO, "program \"%s\" already stopped", tmp->name); - break; - } else { - if(state > -1) { - program->message = json_mkobject(); - JsonNode *code1 = json_mkobject(); - json_append_member(code1, "name", json_mkstring(name)); - - if(state == 1) { - json_append_member(code1, "state", json_mkstring("running")); - } else { - json_append_member(code1, "state", json_mkstring("stopped")); - } - - json_append_member(program->message, "message", code1); - json_append_member(program->message, "origin", json_mkstring("receiver")); - json_append_member(program->message, "protocol", json_mkstring(program->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(program->id, program->message, PROTOCOL); - } - json_delete(program->message); - program->message = NULL; - } - - tmp->wait = 1; - threads_create(&tmp->pth, NULL, execute, (void *)tmp); - tmp->hasthread = 1; - pthread_detach(tmp->pth); - - program->message = json_mkobject(); - json_append_member(program->message, "name", json_mkstring(name)); - json_append_member(program->message, "state", json_mkstring("pending")); - } - } else { - logprintf(LOG_NOTICE, "program \"%s\" cannot be controlled", tmp->name); - } - } else { - logprintf(LOG_NOTICE, "please wait for program \"%s\" to finish it's state change", tmp->name); - } - break; - } - tmp = tmp->next; - } - } else { - program->message = json_mkobject(); - - if(json_find_number(code, "running", &itmp) == 0) - json_append_member(program->message, "state", json_mkstring("running")); - else if(json_find_number(code, "stopped", &itmp) == 0) - json_append_member(program->message, "state", json_mkstring("stopped")); - - json_append_member(program->message, "name", json_mkstring(name)); - json_append_member(program->message, "state", json_mkstring("pending")); - } - } else { - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(program); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(program); - - struct settings_t *tmp; - while(settings) { - tmp = settings; - if(tmp->stop) FREE(tmp->stop); - if(tmp->start) FREE(tmp->start); - if(tmp->name) FREE(tmp->name); - if(tmp->arguments) FREE(tmp->arguments); - if(tmp->program) FREE(tmp->program); - if(tmp->hasthread > 0) pthread_cancel(tmp->pth); - settings = settings->next; - FREE(tmp); - } - if(settings != NULL) { - FREE(settings); - } -} - -static void printHelp(void) { - printf("\t -t --running\t\t\tstart the program\n"); - printf("\t -f --stopped\t\t\tstop the program\n"); - printf("\t -n --name=name\t\t\tname of the program\n"); -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void programInit(void) { -#ifndef _WIN32 - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - - protocol_register(&program); - protocol_set_id(program, "program"); - protocol_device_add(program, "program", "Start / Stop / State of a program"); - program->devtype = PENDINGSW; - program->hwtype = API; - program->multipleId = 0; - - options_add(&program->options, 'n', "name", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, NULL); - options_add(&program->options, 'x', "start-command", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&program->options, 'y', "stop-command", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&program->options, 'p', "program", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&program->options, 'i', "pid", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&program->options, 'a', "arguments", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&program->options, 't', "running", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&program->options, 'd', "pending", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&program->options, 'f', "stopped", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - - options_add(&program->options, 0, "readonly", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - options_add(&program->options, 0, "confirm", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - options_add(&program->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - -#ifndef _WIN32 - program->createCode=&createCode; - program->printHelp=&printHelp; - program->initDev=&initDev; - program->threadGC=&threadGC; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "program"; - module->version = "1.6"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - programInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/program.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/program.h deleted file mode 100644 index 07bc65d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/program.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_PROGRAM_H_ -#define _PROTOCOL_PROGRAM_H_ - -#include "../protocol.h" - -struct protocol_t *program; -void programInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/API/protocol_header.h.in deleted file mode 100644 index da97564..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/protocol_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/API/protocol_init.h.in deleted file mode 100644 index 40bdc9d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/protocol_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/sunriseset.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/sunriseset.c deleted file mode 100644 index 10ce26f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/sunriseset.c +++ /dev/null @@ -1,615 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __USE_XOPEN - #define __USE_XOPEN -#endif -#include -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/ntp.h" -#include "../../core/dso.h" -#include "../../core/datetime.h" // Full path because we also have a datetime protocol -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "sunriseset.h" - -#define PI 3.1415926 -#define PIX 57.29578049044297 // 180 / PI -#define ZENITH 90.83333333333333 - -#ifdef PILIGHT_DEVELOPMENT -static unsigned short loop = 1; -static unsigned short threads = 0; - -static double calculate(int year, int month, int day, double lon, double lat, int rising) { - int N = (int)((floor(275 * month / 9)) - ((floor((month + 9) / 12)) * - ((1 + floor((year - 4 * floor(year / 4) + 2) / 3)))) + (int)day - 30); - - double lngHour = lon / 15.0; - double T = 0; - - if(rising) { - T = N + ((6 - lngHour) / 24); - } else { - T = N + ((18 - lngHour) / 24); - } - - double M = (0.9856 * T) - 3.289; - double M1 = M * PI / 180; - double L = fmod((M + (1.916 * sin(M1)) + (0.020 * sin(2 * M1)) + 282.634), 360.0); - double L1 = L * PI / 180; - double L2 = lat * PI / 180; - double SD = 0.39782 * sin(L1); - double CH = (cos(ZENITH * PI / 180)-(SD * sin(L2))) / (cos((PIX * asin((SD))) * PI / 180) * cos(L2)); - - if(CH > 1) { - return -1; - } else if(CH < -1) { - return -1; - } - - double RA = fmod((PIX * atan((0.91764 * tan(L1)))), 360); - double MQ = (RA + (((floor(L / 90)) * 90) - ((floor(RA / 90)) * 90))) / 15; - double A; - double B; - if(rising == 0) { - A = 0.06571; - B = 6.595; - } else { - A = 0.06571; - B = 6.618; - } - - double t = ((rising ? 360 - PIX * acos(CH) : PIX * acos(CH)) / 15) + MQ - (A * T) - B; - double UT = fmod((t - lngHour) + 24.0, 24.0); - double min = (round(60*fmod(UT, 1))/100); - - if(min >= 0.60) { - min -= 0.60; - } - - double hour = UT-min; - - return ((round(hour)+min))*100; -} - -static void *thread(void *param) { - struct protocol_threads_t *thread = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)thread->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - double longitude = 0, latitude = 0; - char UTC[] = "UTC", *tz = NULL; - - time_t timenow = 0; - struct tm tm, tm_utc; - int nrloops = 0, risetime = 0, settime = 0, hournow = 0, firstrun = 0; - int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, offset = 0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - jchild1 = json_first_child(jchild); - while(jchild1) { - if(strcmp(jchild1->key, "longitude") == 0) { - longitude = jchild1->number_; - } - if(strcmp(jchild1->key, "latitude") == 0) { - latitude = jchild1->number_; - } - jchild1 = jchild1->next; - } - jchild = jchild->next; - } - } - - if((tz = coord2tz(longitude, latitude)) == NULL) { - logprintf(LOG_DEBUG, "could not determine timezone"); - tz = UTC; - } else { - logprintf(LOG_DEBUG, "%.6f:%.6f seems to be in timezone: %s", longitude, latitude, tz); - } - - timenow = time(NULL); - if(isntpsynced() == 0) { - timenow -= getntpdiff(); - } - - while(loop) { - protocol_thread_wait(thread, 1, &nrloops); - timenow = time(NULL); - if(isntpsynced() == 0) { - timenow -= getntpdiff(); - } - - - if(localtime_l(timenow, &tm, tz) == 0) { - year = tm.tm_year+1900; - month = tm.tm_mon+1; - day = tm.tm_mday; - hour = tm.tm_hour; - minute = tm.tm_min; - second = tm.tm_sec; - - if(localtime_l(timenow, &tm_utc, UTC) == 0) { - offset = tm.tm_hour-tm_utc.tm_hour; - } - - hournow = (hour*100)+minute; - if(((hournow == 0 || hournow == risetime || hournow == settime) && second == 0) - || (settime == 0 && risetime == 0)) { - - if(settime == 0 && risetime == 0) { - firstrun = 1; - } - - sunriseset->message = json_mkobject(); - JsonNode *code = json_mkobject(); - risetime = (int)calculate(year, month, day, longitude, latitude, 1)+(offset*100); - settime = (int)calculate(year, month, day, longitude, latitude, 0)+(offset*100); - - json_append_member(code, "longitude", json_mknumber(longitude, 6)); - json_append_member(code, "latitude", json_mknumber(latitude, 6)); - - /* Only communicate the sun state change when they actually occur, - and only communicate the new times when the day changes */ - if(hournow != 0 || firstrun == 1) { - if(hournow >= risetime && hournow < settime) { - json_append_member(code, "sun", json_mkstring("rise")); - } else { - json_append_member(code, "sun", json_mkstring("set")); - } - } - if(hournow == 0 || firstrun == 1) { - json_append_member(code, "sunrise", json_mknumber(((double)risetime/100), 2)); - json_append_member(code, "sunset", json_mknumber(((double)settime/100), 2)); - } - - json_append_member(sunriseset->message, "message", code); - json_append_member(sunriseset->message, "origin", json_mkstring("receiver")); - json_append_member(sunriseset->message, "protocol", json_mkstring(sunriseset->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(sunriseset->id, sunriseset->message, PROTOCOL); - } - json_delete(sunriseset->message); - sunriseset->message = NULL; - firstrun = 0; - } - } - } - - threads--; - return (void *)NULL; -} -#else -static int time_override = -1; - -typedef struct data_t { - char *name; - int interval; - int target_offset; - uv_timer_t *timer_req; - - double longitude; - double latitude; - - char *tz; - - struct data_t *next; -} data_t; - -static struct data_t *data = NULL; -static char UTC[] = "UTC"; - -#ifdef PILIGHT_REWRITE -static void *reason_code_received_free(void *param) { - struct reason_code_received_t *data = param; - FREE(data); - return NULL; -} -#endif - -static double calculate(int year, int month, int day, double lon, double lat, int rising) { - int N = (int)((floor(275 * month / 9)) - ((floor((month + 9) / 12)) * - ((1 + floor((year - 4 * floor(year / 4) + 2) / 3)))) + (int)day - 30); - - double lngHour = lon / 15.0; - double T = 0; - - if(rising) { - T = N + ((6 - lngHour) / 24); - } else { - T = N + ((18 - lngHour) / 24); - } - - double M = (0.9856 * T) - 3.289; - double M1 = M * PI / 180; - double L = fmod((M + (1.916 * sin(M1)) + (0.020 * sin(2 * M1)) + 282.634), 360.0); - double L1 = L * PI / 180; - double L2 = lat * PI / 180; - double SD = 0.39782 * sin(L1); - double CH = (cos(ZENITH * PI / 180)-(SD * sin(L2))) / (cos((PIX * asin((SD))) * PI / 180) * cos(L2)); - - if(CH > 1) { - return -1; - } else if(CH < -1) { - return -1; - } - - double RA = fmod((PIX * atan((0.91764 * tan(L1)))), 360); - double MQ = (RA + (((floor(L / 90)) * 90) - ((floor(RA / 90)) * 90))) / 15; - double A; - double B; - if(rising == 0) { - A = 0.06571; - B = 6.595; - } else { - A = 0.06571; - B = 6.618; - } - - double t = ((rising ? 360 - PIX * acos(CH) : PIX * acos(CH)) / 15) + MQ - (A * T) - B; - double UT = fmod((t - lngHour) + 24.0, 24.0); - double min = (round(60*fmod(UT, 1))/100); - - if(min >= 0.60) { - min -= 0.60; - } - - double hour = UT-min; - - return ((round(hour)+min))*100; -} - -#undef min -static unsigned long min(unsigned long a, unsigned long b, unsigned long c) { - unsigned long m = a; - if(m > b) { - m = b; - } - if(m > c) { - return c; - } - return m; -} - -static void *thread(void *param) { - uv_timer_t *task = param; - struct data_t *settings = task->data; - struct tm tm; - struct tm rise; - struct tm set; - struct tm midnight; - time_t t; - int risetime = 0, settime = 0, hournow = 0; - - if(time_override > -1) { - t = time_override; - } else { - t = time(NULL); - if(isntpsynced() == 0) { - t -= getntpdiff(); - } - } - - if(localtime_l(t, &tm, settings->tz) == 0) { - int year = tm.tm_year+1900; - int month = tm.tm_mon+1; - int day = tm.tm_mday; - int hour = tm.tm_hour; - int minute = tm.tm_min; - - risetime = (int)calculate(year, month, day, settings->longitude, settings->latitude, 1); - settime = (int)calculate(year, month, day, settings->longitude, settings->latitude, 0); - - t = datetime2ts(year, month, day, risetime / 100, risetime % 100, 0); - localtime_l(t, &rise, settings->tz); - risetime = ((rise.tm_hour*100)+rise.tm_min); - - t = datetime2ts(year, month, day, settime / 100, settime % 100, 0); - localtime_l(t, &set, settings->tz); - settime = ((set.tm_hour*100)+set.tm_min); - - memcpy(&midnight, &tm, sizeof(struct tm)); - midnight.tm_hour = 23; - midnight.tm_min = 59; - midnight.tm_sec = 59; - - unsigned long tset = mktime(&set); - unsigned long trise = mktime(&rise); - unsigned long tmidnight = mktime(&midnight); - unsigned long tnow = mktime(&tm); - - /* To make sure we are always calculating ahead */ - if(tset < tnow) { - tset += 86400; - } - if(trise < tnow) { - trise += 86400; - } - if(tmidnight < tnow) { - tmidnight += 86400; - } - - unsigned long time2set = tset-tnow; - unsigned long time2rise = trise-tnow; - unsigned long time2midnight = (tmidnight+1)-tnow; - - char *_sun = NULL; - hournow = (hour*100)+minute; - - if(hournow >= risetime && hournow < settime) { - _sun = "rise"; - } else { - _sun = "set"; - } - -#ifdef PILIGHT_REWRITE - struct reason_code_received_t *data = MALLOC(sizeof(struct reason_code_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - snprintf(data->message, 1024, - "{\"longitude\":%.6f,\"latitude\":%.6f,\"sun\":\"%s\",\"sunrise\":%.2f,\"sunset\":%.2f}", - settings->longitude, settings->latitude, _sun, (rise.tm_hour+(double)rise.tm_min/100), ((set.tm_hour+(double)set.tm_min/100)) - ); - strncpy(data->origin, "receiver", 255); - data->protocol = sunriseset->id; - if(strlen(pilight_uuid) > 0) { - data->uuid = pilight_uuid; - } else { - data->uuid = NULL; - } - data->repeat = 1; - eventpool_trigger(REASON_CODE_RECEIVED, reason_code_received_free, data); -#else - char message[1024]; - snprintf(message, 1024, - "{\"origin\":\"receiver\",\"protocol\":\"%s\",\"message\":"\ - "{\"longitude\":%.6f,\"latitude\":%.6f,\"sun\":\"%s\",\"sunrise\":%.2f,\"sunset\":%.2f}"\ - "}", - sunriseset->id, settings->longitude, settings->latitude, _sun, (rise.tm_hour+(double)rise.tm_min/100), ((set.tm_hour+(double)set.tm_min/100)) - ); - - sunriseset->message = json_decode(message); - - if(pilight.broadcast != NULL) { - pilight.broadcast(sunriseset->id, sunriseset->message, PROTOCOL); - } - json_delete(sunriseset->message); - sunriseset->message = NULL; -#endif - unsigned long next = 0; - if((next = min(time2set, time2rise, time2midnight)) == 0) { - if(time2set == 0) { - next = time2midnight; - } - if(time2rise == 0) { - next = time2set; - } - if(time2midnight == 0) { - next = time2rise; - } - } - assert(next > 0); - uv_timer_start(settings->timer_req, (void (*)(uv_timer_t *))thread, next*1000, 0); - } - - return (void *)NULL; -} -#endif - -static struct threadqueue_t *initDev(JsonNode *jdevice) { -#ifdef PILIGHT_DEVELOPMENT - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(sunriseset, json); - return threads_register("sunriseset", &thread, (void *)node, 0); -#else -#ifdef PILIGHT_REWRITE - struct JsonNode *jdevice = NULL; -#endif - struct JsonNode *jprotocols = NULL; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct data_t *node = NULL; - int match = 0; - -#ifdef PILIGHT_REWRITE - if(param == NULL) { - return NULL; - } -#endif - - if(!(sunriseset->masterOnly == 0 || pilight.runmode == STANDALONE)) { - return NULL; - } - -#ifdef PILIGHT_REWRITE - if((jdevice = json_first_child(param)) == NULL) { - return NULL; - } -#endif - - if((jprotocols = json_find_member(jdevice, "protocol")) != NULL) { - jchild = json_first_child(jprotocols); - while(jchild) { - if(strcmp(sunriseset->id, jchild->string_) == 0) { - match = 1; - break; - } - jchild = jchild->next; - } - } - if(match == 0) { - return NULL; - } - - if((node = MALLOC(sizeof(struct data_t)))== NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, '\0', sizeof(struct data_t)); - - if((jid = json_find_member(jdevice, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - jchild1 = json_first_child(jchild); - while(jchild1) { - if(strcmp(jchild1->key, "longitude") == 0) { - node->longitude = jchild1->number_; - } - if(strcmp(jchild1->key, "latitude") == 0) { - node->latitude = jchild1->number_; - } - jchild1 = jchild1->next; - } - jchild = jchild->next; - } - } - - if((node->tz = coord2tz(node->longitude, node->latitude)) == NULL) { - logprintf(LOG_INFO, "sunriseset %s, could not determine timezone, defaulting to UTC", jdevice->key); - node->tz = UTC; - } else { - logprintf(LOG_INFO, "sunriseset %s %.6f:%.6f seems to be in timezone: %s", jdevice->key, node->longitude, node->latitude, node->tz); - } - - if((node->name = MALLOC(strlen(jdevice->key)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->name, jdevice->key); - - node->next = data; - data = node; - - if((node->timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - node->timer_req->data = node; - - uv_timer_init(uv_default_loop(), node->timer_req); - - uv_timer_start(node->timer_req, (void (*)(uv_timer_t *))thread, 1, 0); - - return NULL; -#endif -} - -static void threadGC(void) { -#ifdef PILIGHT_DEVELOPMENT - loop = 0; - protocol_thread_stop(sunriseset); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(sunriseset); -#else - struct data_t *tmp = NULL; - while(data) { - tmp = data; -#ifndef PILIGHT_REWRITE - uv_timer_stop(tmp->timer_req); -#endif - FREE(tmp->name); - data = data->next; - FREE(tmp); - } - if(data != NULL) { - FREE(data); - } -#endif -} - -static int checkValues(JsonNode *code) { - char *sun = NULL; - - if(json_find_string(code, "sun", &sun) == 0) { - if(strcmp(sun, "rise") != 0 && strcmp(sun, "set") != 0) { - return 1; - } - } - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void sunRiseSetInit(void) { - - protocol_register(&sunriseset); - protocol_set_id(sunriseset, "sunriseset"); - protocol_device_add(sunriseset, "sunriseset", "Sunrise / Sunset Calculator"); - sunriseset->devtype = WEATHER; - sunriseset->hwtype = API; - sunriseset->multipleId = 0; -#if PILIGHT_V >= 6 - sunriseset->masterOnly = 1; -#endif - - options_add(&sunriseset->options, 'o', "longitude", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&sunriseset->options, 'a', "latitude", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&sunriseset->options, 'u', "sunrise", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&sunriseset->options, 'd', "sunset", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&sunriseset->options, 's', "sun", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - // options_add(&sunriseset->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&sunriseset->options, 0, "sunriseset-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&sunriseset->options, 0, "show-sunriseset", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - - sunriseset->initDev=&initDev; - sunriseset->threadGC=&threadGC; - sunriseset->checkValues=&checkValues; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "sunriseset"; - module->version = "2.6"; - module->reqversion = "6.0"; - module->reqcommit = "115"; -} - -void init(void) { - sunRiseSetInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/sunriseset.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/sunriseset.h deleted file mode 100644 index 59bd1df..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/sunriseset.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_SUNRISESET_H_ -#define _PROTOCOL_SUNRISESET_H_ - -#include "../protocol.h" - -struct protocol_t *sunriseset; -void sunRiseSetInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/wunderground.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/wunderground.c deleted file mode 100644 index 93ba12e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/wunderground.c +++ /dev/null @@ -1,1073 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/datetime.h" // Full path because we also have a datetime protocol -#include "../../core/log.h" -#include "../../core/http.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "wunderground.h" - -#define INTERVAL 900 - -#ifdef PILIGHT_DEVELOPMENT -typedef struct settings_t { - char *api; - char *country; - char *location; - - struct JsonNode *node; - - char *stmp; - int interval; - int ointerval; - - time_t update; - protocol_threads_t *thread; - struct settings_t *next; -} settings_t; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static struct settings_t *settings; -static unsigned short loop = 1; -static unsigned short threads = 0; - -static void callback1(int code, char *data, int size, char *type, void *userdata) { - struct settings_t *wnode = userdata; - - struct JsonNode *jdata1 = NULL; - struct JsonNode *jsun = NULL; - struct JsonNode *jsunr = NULL; - struct JsonNode *jsuns = NULL; - - char *shour = NULL, *smin = NULL; - char *rhour = NULL, *rmin = NULL; - - int humi = 0, temp = 0; - - if(code == 200) { - if(strcmp(type, "application/json") == 0) { - if(json_validate(data) == true) { - if((jdata1 = json_decode(data)) != NULL) { - if((jsun = json_find_member(jdata1, "sun_phase")) != NULL) { - if((jsunr = json_find_member(jsun, "sunrise")) != NULL - && (jsuns = json_find_member(jsun, "sunset")) != NULL) { - if(json_find_string(jsuns, "hour", &shour) != 0) { - printf("api.wunderground.com json has no sunset hour key"); - } else if(json_find_string(jsuns, "minute", &smin) != 0) { - printf("api.wunderground.com json has no sunset minute key"); - } else if(json_find_string(jsunr, "hour", &rhour) != 0) { - printf("api.wunderground.com json has no sunrise hour key"); - } else if(json_find_string(jsunr, "minute", &rmin) != 0) { - printf("api.wunderground.com json has no sunrise minute key"); - } else { - temp = wnode->node->number_; - sscanf(wnode->stmp, "%d%%", &humi); - - time_t timenow; - timenow = time(NULL); - - struct tm current; - memset(¤t, '\0', sizeof(struct tm)); - /* - * Retrieving the current day is fine with - * the UTC timezone, because we don't do - * anything with the hours, minutes or seconds. - * We just need to know what day, month, and year - * we are in. - */ -#ifdef _WIN32 - struct tm *ptm; - ptm = gmtime(&timenow); - memcpy(¤t, ptm, sizeof(struct tm)); -#else - gmtime_r(&timenow, ¤t); -#endif - int month = current.tm_mon+1; - int mday = current.tm_mday; - int year = current.tm_year+1900; - - time_t midnight = (datetime2ts(year, month, mday, 23, 59, 59)+1); - time_t sunset = 0; - time_t sunrise = 0; - - wunderground->message = json_mkobject(); - - JsonNode *code = json_mkobject(); - - json_append_member(code, "api", json_mkstring(wnode->api)); - json_append_member(code, "location", json_mkstring(wnode->location)); - json_append_member(code, "country", json_mkstring(wnode->country)); - json_append_member(code, "temperature", json_mknumber((double)temp, 2)); - json_append_member(code, "humidity", json_mknumber((double)humi, 0)); - json_append_member(code, "update", json_mknumber(0, 0)); - sunrise = datetime2ts(year, month, mday, atoi(rhour), atoi(rmin), 0); - json_append_member(code, "sunrise", json_mknumber((double)((atoi(rhour)*100)+atoi(rmin))/100, 2)); - sunset = datetime2ts(year, month, mday, atoi(shour), atoi(smin), 0); - json_append_member(code, "sunset", json_mknumber((double)((atoi(shour)*100)+atoi(smin))/100, 2)); - if(timenow > sunrise && timenow < sunset) { - json_append_member(code, "sun", json_mkstring("rise")); - } else { - json_append_member(code, "sun", json_mkstring("set")); - } - - json_append_member(wunderground->message, "message", code); - json_append_member(wunderground->message, "origin", json_mkstring("receiver")); - json_append_member(wunderground->message, "protocol", json_mkstring(wunderground->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(wunderground->id, wunderground->message, PROTOCOL); - } - json_delete(wunderground->message); - wunderground->message = NULL; - /* Send message when sun rises */ - if(sunrise > timenow) { - if((sunrise-timenow) < wnode->ointerval) { - wnode->interval = (int)(sunrise-timenow); - } - /* Send message when sun sets */ - } else if(sunset > timenow) { - if((sunset-timenow) < wnode->ointerval) { - wnode->interval = (int)(sunset-timenow); - } - /* Update all values when a new day arrives */ - } else { - if((midnight-timenow) < wnode->ointerval) { - wnode->interval = (int)(midnight-timenow); - } - } - - wnode->update = time(NULL); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sunset and/or sunrise key"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sun_phase key"); - } - json_delete(jdata1); - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json could not be parsed"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "could not reach api.wundergrond.com"); - } -} - -static void callback(int code, char *data, int size, char *type, void *userdata) { - struct settings_t *wnode = userdata; - char url[1024]; - - struct JsonNode *jdata = NULL; - struct JsonNode *jobs = NULL; - // double temp = 0; - - if(code == 200) { - if(strstr(type, "application/json") != NULL) { - if(json_validate(data) == true) { - if((jdata = json_decode(data)) != NULL) { - if((jobs = json_find_member(jdata, "current_observation")) != NULL) { - if((wnode->node = json_find_member(jobs, "temp_c")) == NULL) { - printf("api.wunderground.com json has no temp_c key"); - } else if(json_find_string(jobs, "relative_humidity", &wnode->stmp) != 0) { - printf("api.wunderground.com json has no relative_humidity key"); - } else { - if(wnode->node->tag != JSON_NUMBER) { - printf("api.wunderground.com json has no temp_c key"); - } else { - sprintf(url, "http://api.wunderground.com/api/%s/astronomy/q/%s/%s.json", wnode->api, wnode->country, wnode->location); - http_get_content(url, callback1, wnode); - } - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json has no current_observation key"); - } - json_delete(jdata); - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json could not be parsed"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "could not reach api.wundergrond.com"); - } -} - -static void *thread(void *param) { - struct protocol_threads_t *thread = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)thread->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct settings_t *wnode = MALLOC(sizeof(struct settings_t)); - - wnode->interval = 86400; - wnode->ointerval = 86400; - wnode->stmp = NULL; - - int event = 0; - int firstrun = 1, nrloops = 0, timeout = 0; - - char url[1024]; - double itmp = -1; - - if(wnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - threads++; - - int has_country = 0, has_api = 0, has_location = 0; - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - has_country = 0, has_api = 0, has_location = 0; - jchild1 = json_first_child(jchild); - - while(jchild1) { - if(strcmp(jchild1->key, "api") == 0) { - has_api = 1; - if((wnode->api = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(wnode->api, jchild1->string_); - } - if(strcmp(jchild1->key, "location") == 0) { - has_location = 1; - if((wnode->location = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(wnode->location, jchild1->string_); - } - if(strcmp(jchild1->key, "country") == 0) { - has_country = 1; - if((wnode->country = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(wnode->country, jchild1->string_); - } - jchild1 = jchild1->next; - } - if(has_country == 1 && has_api == 1 && has_location == 1) { - wnode->thread = thread; - wnode->next = settings; - settings = wnode; - } else { - if(has_country == 1) { - FREE(wnode->country); - } - if(has_location == 1) { - FREE(wnode->location); - } - if(has_api == 1) { - FREE(wnode->api); - } - FREE(wnode); - wnode = NULL; - } - jchild = jchild->next; - } - } - - if(!wnode) { - return 0; - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - wnode->interval = (int)round(itmp); - wnode->ointerval = wnode->interval; - - while(loop) { - event = protocol_thread_wait(thread, INTERVAL, &nrloops); - pthread_mutex_lock(&lock); - if(loop == 0) { - break; - } - timeout += INTERVAL; - if(timeout >= wnode->interval || event != ETIMEDOUT || firstrun == 1) { - timeout = 0; - wnode->interval = wnode->ointerval; - - sprintf(url, "http://api.wunderground.com/api/%s/geolookup/conditions/q/%s/%s.json", wnode->api, wnode->country, wnode->location); - http_get_content(url, callback, wnode); - } else { - wunderground->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "api", json_mkstring(wnode->api)); - json_append_member(code, "location", json_mkstring(wnode->location)); - json_append_member(code, "country", json_mkstring(wnode->country)); - json_append_member(code, "update", json_mknumber(1, 0)); - json_append_member(wunderground->message, "message", code); - json_append_member(wunderground->message, "origin", json_mkstring("receiver")); - json_append_member(wunderground->message, "protocol", json_mkstring(wunderground->id)); - if(pilight.broadcast != NULL) { - pilight.broadcast(wunderground->id, wunderground->message, PROTOCOL); - } - json_delete(wunderground->message); - wunderground->message = NULL; - } - firstrun = 0; - pthread_mutex_unlock(&lock); - } - pthread_mutex_unlock(&lock); - - threads--; - return (void *)NULL; -} -#else -static int min_interval = INTERVAL; -static int time_override = -1; -static char url[2][1024] = { - "http://api.wunderground.com/api/%s/geolookup/conditions/q/%s/%s.json", - "http://api.wunderground.com/api/%s/astronomy/q/%s/%s.json" -}; - -typedef struct data_t { - char *country; - char *location; - char *key; - char *api; - char tz[128]; - uv_timer_t *enable_timer_req; - uv_timer_t *update_timer_req; - - double temp; - int humi; - - int interval; - double temp_offset; - - unsigned long sunrisesetid; - unsigned long updateid; - unsigned long initid; - - time_t update; - struct data_t *next; -} data_t; - -static struct data_t *data = NULL; - -static void *update(void *param); -static void *enable(void *param); - -#ifdef PILIGHT_REWRITE -static void *reason_code_received_free(void *param) { - struct reason_code_received_t *data = param; - FREE(data); - return NULL; -} -#endif - -static void callback2(int code, char *data, int size, char *type, void *userdata) { - struct data_t *settings = userdata; - struct JsonNode *jdata = NULL; - struct JsonNode *jsun = NULL; - struct JsonNode *jsunr = NULL; - struct JsonNode *jsuns = NULL; - char *shour = NULL, *smin = NULL; - char *rhour = NULL, *rmin = NULL; - struct tm tm; - - memset(&tm, 0, sizeof(struct tm)); - - if(code == 200) { - if(strstr(type, "application/json") != NULL) { - if(json_validate(data) == true) { - if((jdata = json_decode(data)) != NULL) { - if((jsun = json_find_member(jdata, "sun_phase")) != NULL) { - if((jsunr = json_find_member(jsun, "sunrise")) != NULL - && (jsuns = json_find_member(jsun, "sunset")) != NULL) { - if(json_find_string(jsuns, "hour", &shour) != 0) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sunset hour key"); - } else if(json_find_string(jsuns, "minute", &smin) != 0) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sunset minute key"); - } else if(json_find_string(jsunr, "hour", &rhour) != 0) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sunrise hour key"); - } else if(json_find_string(jsunr, "minute", &rmin) != 0) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sunrise minute key"); - } else { - - time_t timenow; - if(time_override > -1) { - timenow = time_override; - } else { - timenow = time(NULL); - } - - struct tm current; - memset(¤t, '\0', sizeof(struct tm)); - /* - * Retrieving the current day is fine with - * the UTC timezone, because we don't do - * anything with the hours, minutes or seconds. - * We just need to know what day, month, and year - * we are in. - */ -#ifdef _WIN32 - struct tm *ptm; - ptm = gmtime(&timenow); - memcpy(¤t, ptm, sizeof(struct tm)); -#else - gmtime_r(&timenow, ¤t); -#endif - - int month = current.tm_mon+1; - int mday = current.tm_mday; - int year = current.tm_year+1900; - char *_sun = NULL; - - time_t midnight = (datetime2ts(year, month, mday, 23, 59, 59)+1); - time_t sunset = datetime2ts(year, month, mday, atoi(shour), atoi(smin), 0); - time_t sunrise = datetime2ts(year, month, mday, atoi(rhour), atoi(rmin), 0); - - if(timenow > sunrise && timenow < sunset) { - _sun = "rise"; - } else { - _sun = "set"; - } - -#ifdef PILIGHT_REWRITE - struct reason_code_received_t *data = MALLOC(sizeof(struct reason_code_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - snprintf(data->message, 1024, - "{\"api\":\"%s\",\"location\":\"%s\",\"country\":\"%s\",\"temperature\":%.2f,\"humidity\":%d,\"update\":0,\"sunrise\":%.2f,\"sunset\":%.2f,\"sun\":\"%s\"}", - settings->api, settings->location, settings->country, settings->temp, settings->humi, - ((double)((atoi(rhour)*100)+atoi(rmin))/100), ((double)((atoi(shour)*100)+atoi(smin))/100), _sun - ); - strncpy(data->origin, "receiver", 255); - data->protocol = wunderground->id; - if(strlen(pilight_uuid) > 0) { - data->uuid = pilight_uuid; - } else { - data->uuid = NULL; - } - data->repeat = 1; - eventpool_trigger(REASON_CODE_RECEIVED, reason_code_received_free, data); -#else - char message[1024]; - snprintf(message, 1024, - "{\"origin\":\"receiver\",\"protocol\":\"%s\",\"message\":"\ - "{\"api\":\"%s\",\"location\":\"%s\",\"country\":\"%s\",\"temperature\":%.2f,\"humidity\":%d,\"update\":0,\"sunrise\":%.2f,\"sunset\":%.2f,\"sun\":\"%s\"}"\ - "}", - wunderground->id, settings->api, settings->location, settings->country, settings->temp, settings->humi, - ((double)((atoi(rhour)*100)+atoi(rmin))/100), ((double)((atoi(shour)*100)+atoi(smin))/100), _sun - ); - - wunderground->message = json_decode(message); - - if(pilight.broadcast != NULL) { - pilight.broadcast(wunderground->id, wunderground->message, PROTOCOL); - } - json_delete(wunderground->message); - wunderground->message = NULL; -#endif - /* Send message when sun rises */ - if(sunrise > timenow) { - if((sunrise-timenow) < settings->interval) { - settings->interval = (int)(sunrise-timenow); - } - /* Send message when sun sets */ - } else if(sunset > timenow) { - if((sunset-timenow) < settings->interval) { - settings->interval = (int)(sunset-timenow); - } - /* Update all values when a new day arrives */ - } else { - if((midnight-timenow) < settings->interval) { - settings->interval = (int)(midnight-timenow); - } - } - - if(time_override > -1) { - settings->update = time_override; - } else { - settings->update = time(NULL); - } - - /* - * Update all values on next event as described above - */ - assert(settings->interval > 0); - uv_timer_start(settings->update_timer_req, (void (*)(uv_timer_t *))update, settings->interval*1000, 0); - /* - * Allow updating the values customly after INTERVAL seconds - */ - assert(min_interval > 0); - uv_timer_start(settings->enable_timer_req, (void (*)(uv_timer_t *))enable, min_interval*1000, 0); - - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sunset and/or sunrise key"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json has no sun_phase key"); - } - json_delete(jdata); - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json could not be parsed"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "could not reach api.wunderground.com"); - } - return; -} - -static void callback1(int code, char *data, int size, char *type, void *userdata) { - struct data_t *settings = userdata; - struct JsonNode *jdata = NULL; - struct JsonNode *jobs = NULL; - struct JsonNode *jloc = NULL; - struct JsonNode *node = NULL; - char *stmp = NULL; - - if(code == 200) { - if(strstr(type, "application/json") != NULL) { - if(json_validate(data) == true) { - if((jdata = json_decode(data)) != NULL) { - if((jloc = json_find_member(jdata, "location")) != NULL) { - if((node = json_find_member(jloc, "tz_long")) == NULL) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no tz_long key"); - } else { - if(node->tag != JSON_STRING) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no tz_long key"); - } else { - strcpy(settings->tz, node->string_); - if((jobs = json_find_member(jdata, "current_observation")) != NULL) { - if((node = json_find_member(jobs, "temp_c")) == NULL) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no temp_c key"); - } else if(json_find_string(jobs, "relative_humidity", &stmp) != 0) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no relative_humidity key"); - } else { - if(node->tag != JSON_NUMBER) { - logprintf(LOG_NOTICE, "api.wunderground.com json has no temp_c key"); - } else { - settings->temp = node->number_; - sscanf(stmp, "%d%%", &settings->humi); - - char parsed[1024]; - char *enc = urlencode(settings->location); - memset(parsed, '\0', 1024); - snprintf(parsed, 1024, url[1], settings->api, settings->country, enc); - FREE(enc); - - http_get_content(parsed, callback2, userdata); - } - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json has no current_observation key"); - } - } - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json has no location key"); - } - json_delete(jdata); - } else { - logprintf(LOG_NOTICE, "api.wunderground.com json could not be parsed"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "api.wunderground.com response was not in a valid json format"); - } - } else { - logprintf(LOG_NOTICE, "could not reach api.wunderground.com"); - } - return; -} - -static void thread_free(uv_work_t *req, int status) { - FREE(req); -} - -static void thread(uv_work_t *req) { - struct data_t *settings = req->data; - char parsed[1024]; - char *enc = urlencode(settings->location); - - memset(parsed, '\0', 1024); - snprintf(parsed, 1024, url[0], settings->api, settings->country, enc); - FREE(enc); - - http_get_content(parsed, callback1, settings); - - return; -} - -static void *update(void *param) { - uv_timer_t *timer_req = param; - struct data_t *settings = timer_req->data; - - uv_work_t *work_req = NULL; - if((work_req = MALLOC(sizeof(uv_work_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - work_req->data = settings; - uv_queue_work(uv_default_loop(), work_req, "wunderground", thread, thread_free); - if(time_override > -1) { - settings->update = time_override; - } else { - settings->update = time(NULL); - } - return NULL; -} - -static void *enable(void *param) { - uv_timer_t *timer_req = param; - struct data_t *settings = timer_req->data; - -#ifdef PILIGHT_REWRITE - struct reason_code_received_t *data = MALLOC(sizeof(struct reason_code_received_t)); - if(data == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - }; - snprintf(data->message, 1024, - "{\"api\":\"%s\",\"location\":\"%s\",\"country\":\"%s\",\"update\":1}", - settings->api, settings->location, settings->country - ); - strncpy(data->origin, "receiver", 255); - data->protocol = wunderground->id; - if(strlen(pilight_uuid) > 0) { - data->uuid = pilight_uuid; - } else { - data->uuid = NULL; - } - data->repeat = 1; - eventpool_trigger(REASON_CODE_RECEIVED, reason_code_received_free, data); -#else - char message[1024]; - snprintf(message, 1024, - "{\"origin\":\"receiver\",\"protocol\":\"%s\",\"message\":"\ - "{\"api\":\"%s\",\"location\":\"%s\",\"country\":\"%s\",\"update\":1}"\ - "}", - wunderground->id, settings->api, settings->location, settings->country - ); - - wunderground->message = json_decode(message); - - if(pilight.broadcast != NULL) { - pilight.broadcast(wunderground->id, wunderground->message, PROTOCOL); - } - json_delete(wunderground->message); - wunderground->message = NULL; -#endif - return NULL; -} -#endif - -static struct threadqueue_t *initDev(struct JsonNode *jdevice) { -#ifdef PILIGHT_DEVELOPMENT - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(wunderground, json); - return threads_register("wunderground", &thread, (void *)node, 0); -#else -#ifdef PILIGHT_REWRITE - struct JsonNode *jdevice = NULL; -#endif - struct JsonNode *jprotocols = NULL; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct data_t *node = NULL; - double itmp = 0; - int match = 0; - -#ifdef PILIGHT_REWRITE - if(param == NULL) { - return NULL; - } -#endif - - if(!(wunderground->masterOnly == 0 || pilight.runmode == STANDALONE)) { - return NULL; - } -#ifdef PILIGHT_REWRITE - if((jdevice = json_first_child(param)) == NULL) { - return NULL; - } -#endif - if((jprotocols = json_find_member(jdevice, "protocol")) != NULL) { - jchild = json_first_child(jprotocols); - while(jchild) { - if(strcmp(wunderground->id, jchild->string_) == 0) { - match = 1; - break; - } - jchild = jchild->next; - } - } - - if(match == 0) { - return NULL; - } - - if((node = MALLOC(sizeof(struct data_t)))== NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - memset(node, '\0', sizeof(struct data_t)); - - node->interval = INTERVAL; - node->country = NULL; - node->location = NULL; - node->update = 0; - node->temp_offset = 0; - - int has_country = 0, has_location = 0, has_api = 0; - if((jid = json_find_member(jdevice, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - has_country = 0, has_location = 0; - jchild1 = json_first_child(jchild); - - while(jchild1) { - if(strcmp(jchild1->key, "api") == 0) { - has_api = 1; - if((node->api = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->api, jchild1->string_); - } - if(strcmp(jchild1->key, "location") == 0) { - has_location = 1; - if((node->location = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->location, jchild1->string_); - } - if(strcmp(jchild1->key, "country") == 0) { - has_country = 1; - if((node->country = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->country, jchild1->string_); - } - jchild1 = jchild1->next; - } - if(has_country == 1 && has_location == 1 && has_api == 1) { - node->next = data; - data = node; - } else { - if(has_country == 1) { - FREE(node->country); - } - if(has_location == 1) { - FREE(node->location); - } - FREE(node); - node = NULL; - } - jchild = jchild->next; - } - } - - if(node == NULL) { - return NULL; - } - if(json_find_number(jdevice, "poll-interval", &itmp) == 0) - node->interval = (int)round(itmp); - json_find_number(jdevice, "temperature-offset", &node->temp_offset); - - if((node->key = MALLOC(strlen(jdevice->key)+1)) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - strcpy(node->key, jdevice->key); - node->temp = 0.0; - node->humi = 0; - - if((node->enable_timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - if((node->update_timer_req = MALLOC(sizeof(uv_timer_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - - node->enable_timer_req->data = node; - node->update_timer_req->data = node; - - uv_timer_init(uv_default_loop(), node->enable_timer_req); - uv_timer_init(uv_default_loop(), node->update_timer_req); - - assert(node->interval > 0); - uv_timer_start(node->enable_timer_req, (void (*)(uv_timer_t *))enable, node->interval*1000, 0); - /* - * Do an update when this device is added after 3 seconds - * to make sure pilight is actually running. - */ - uv_timer_start(node->update_timer_req, (void (*)(uv_timer_t *))update, 3000, 0); -#endif - return NULL; -} - -static int checkValues(JsonNode *code) { - double interval = INTERVAL; - - json_find_number(code, "poll-interval", &interval); - - if((int)round(interval) < INTERVAL) { - logprintf(LOG_ERR, "wunderground poll-interval cannot be lower than %d", INTERVAL); - return 1; - } - - return 0; -} - -static int createCode(JsonNode *code) { -#ifdef PILIGHT_DEVELOPMENT - struct settings_t *wtmp = settings; - char *country = NULL; - char *location = NULL; - char *api = NULL; - double itmp = 0; - time_t currenttime = 0; - - if(json_find_number(code, "min-interval", &itmp) == 0) { - logprintf(LOG_ERR, "you can't override the min-interval setting"); - return EXIT_FAILURE; - } - - if(json_find_string(code, "country", &country) == 0 && - json_find_string(code, "location", &location) == 0 && - json_find_string(code, "api", &api) == 0 && - json_find_number(code, "update", &itmp) == 0) { - - while(wtmp) { - if(strcmp(wtmp->country, country) == 0 - && strcmp(wtmp->location, location) == 0 - && strcmp(wtmp->api, api) == 0) { - if((currenttime-wtmp->update) > INTERVAL) { - pthread_mutex_unlock(&wtmp->thread->mutex); - pthread_cond_signal(&wtmp->thread->cond); - wtmp->update = time(NULL); - } - } - wtmp = wtmp->next; - } - } else { - logprintf(LOG_ERR, "wunderground: insufficient number of arguments"); - return EXIT_FAILURE; - } -#else - struct data_t *tmp = data; - char *country = NULL; - char *location = NULL; - char *api = NULL; - double itmp = 0; - - if(json_find_number(code, "min-interval", &itmp) == 0) { - logprintf(LOG_ERR, "you can't override the min-interval setting"); - return EXIT_FAILURE; - } - - if(json_find_string(code, "country", &country) == 0 && - json_find_string(code, "location", &location) == 0 && - json_find_string(code, "api", &api) == 0 && - json_find_number(code, "update", &itmp) == 0) { - - while(tmp) { - if(strcmp(tmp->country, country) == 0 - && strcmp(tmp->location, location) == 0 - && strcmp(tmp->api, api) == 0) { - - time_t currenttime = time(NULL); - if(time_override > -1) { - currenttime = time_override; - } - - if((currenttime-tmp->update) > INTERVAL) { - uv_work_t *work_req = NULL; - if((work_req = MALLOC(sizeof(uv_work_t))) == NULL) { - OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ - } - work_req->data = tmp; - uv_queue_work(uv_default_loop(), work_req, "wunderground", thread, thread_free); - - if(time_override > -1) { - tmp->update = time_override; - } else { - tmp->update = time(NULL); - } - } - } - tmp = tmp->next; - } - } else { - logprintf(LOG_ERR, "wunderground: insufficient number of arguments"); - return EXIT_FAILURE; - } -#endif - return EXIT_SUCCESS; -} - -static void threadGC(void) { -#ifdef PILIGHT_DEVELOPMENT - loop = 0; - protocol_thread_stop(wunderground); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(wunderground); - - struct settings_t *wtmp = NULL; - while(settings) { - wtmp = settings; - FREE(settings->api); - FREE(settings->country); - FREE(settings->location); - settings = settings->next; - FREE(wtmp); - } - if(settings != NULL) { - FREE(settings); - } -#else - struct data_t *tmp = NULL; - while(data) { - tmp = data; -#ifndef PILIGHT_REWRITE - uv_timer_stop(tmp->enable_timer_req); - uv_timer_stop(tmp->update_timer_req); -#endif - FREE(tmp->api); - FREE(tmp->country); - FREE(tmp->location); - FREE(tmp->key); - data = data->next; - FREE(tmp); - } - if(data != NULL) { - FREE(data); - } -#endif -} - -static void printHelp(void) { - printf("\t -c --country=country\t\tupdate an entry with this country\n"); - printf("\t -l --location=location\t\tupdate an entry with this location\n"); - printf("\t -a --api=api\t\t\tupdate an entry with this api code\n"); - printf("\t -u --update\t\t\tupdate the defined weather entry\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void wundergroundInit(void) { -#ifdef PILIGHT_DEVELOPMENT - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - protocol_register(&wunderground); - protocol_set_id(wunderground, "wunderground"); - protocol_device_add(wunderground, "wunderground", "Weather Underground API"); - wunderground->devtype = WEATHER; - wunderground->hwtype = API; - wunderground->multipleId = 0; - wunderground->masterOnly = 1; - - options_add(&wunderground->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,5}$"); - options_add(&wunderground->options, 'h', "humidity", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,5}$"); - options_add(&wunderground->options, 'a', "api", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[a-z0-9]+$"); - options_add(&wunderground->options, 'l', "location", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[a-z_]+$"); - options_add(&wunderground->options, 'c', "country", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[a-z]+$"); - options_add(&wunderground->options, 'x', "sunrise", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&wunderground->options, 'y', "sunset", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{3,4}$"); - options_add(&wunderground->options, 's', "sun", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&wunderground->options, 'u', "update", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - - // options_add(&wunderground->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&wunderground->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&wunderground->options, 0, "humidity-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&wunderground->options, 0, "sunriseset-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&wunderground->options, 0, "show-humidity", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&wunderground->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&wunderground->options, 0, "show-sunriseset", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&wunderground->options, 0, "show-update", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&wunderground->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)86400, "[0-9]"); - - wunderground->createCode=&createCode; - wunderground->initDev=&initDev; - wunderground->checkValues=&checkValues; - wunderground->threadGC=&threadGC; - wunderground->printHelp=&printHelp; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "wunderground"; - module->version = "1.13"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - wundergroundInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/wunderground.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/wunderground.h deleted file mode 100644 index a72b078..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/wunderground.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_WUNDERGROUND_H_ -#define _PROTOCOL_WUNDERGROUND_H_ - -#include "../protocol.h" - -struct protocol_t *wunderground; -void wundergroundInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/xbmc.c b/lib/ESPiLight/pilight/libs/pilight/protocols/API/xbmc.c deleted file mode 100644 index d6b7493..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/xbmc.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #include - #include - #define MSG_NOSIGNAL 0 -#else - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include - #include - #include - #include - #include - #include -#endif -#include -#include -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/network.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/socket.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "xbmc.h" - -typedef struct data_t { - char *server; - int port; - int sockfd; - struct data_t *next; -} data_t; - -static pthread_mutex_t xbmclock; -static pthread_mutexattr_t xbmcattr; - -static struct data_t *data; -static unsigned short loop = 1; -static unsigned short threads = 0; - -static void createMessage(char *server, int port, char *action, char *media) { - xbmc->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "action", json_mkstring(action)); - json_append_member(code, "media", json_mkstring(media)); - json_append_member(code, "server", json_mkstring(server)); - json_append_member(code, "port", json_mknumber(port, 0)); - - json_append_member(xbmc->message, "message", code); - json_append_member(xbmc->message, "origin", json_mkstring("receiver")); - json_append_member(xbmc->message, "protocol", json_mkstring(xbmc->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(xbmc->id, xbmc->message, PROTOCOL); - } - json_delete(xbmc->message); - xbmc->message = NULL; -} - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - struct sockaddr_in serv_addr; - struct data_t *xnode = MALLOC(sizeof(struct data_t)); - - char recvBuff[BUFFER_SIZE], action[10], media[15]; - char *m = NULL, *t = NULL; - char shut[] = "shutdown"; - char home[] = "home"; - char none[] = "none"; - int nrloops = 0, bytes = 0, n = 0, has_server = 0; - int has_port = 0, reset = 1, maxfd = 0, retry = 0; - fd_set fdsread; - struct timeval timeout; - timeout.tv_sec = 1; - timeout.tv_usec = 0; - - if(xnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - /* Clear the server address */ - memset(&serv_addr, '\0', sizeof(serv_addr)); - memset(&recvBuff, '\0', BUFFER_SIZE); - memset(&action, '\0', 10); - memset(&media, '\0', 15); - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - jchild1 = json_first_child(jchild); - - while(jchild1) { - if(strcmp(jchild1->key, "server") == 0) { - if((xnode->server = MALLOC(strlen(jchild1->string_)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(xnode->server, jchild1->string_); - has_server = 1; - } - if(strcmp(jchild1->key, "port") == 0) { - xnode->port = (int)round(jchild1->number_); - has_port = 1; - } - jchild1 = jchild1->next; - } - if(has_server == 1 && has_port == 1) { - xnode->sockfd = -1; - xnode->next = data; - data = xnode; - } else { - if(has_server == 1) { - FREE(xnode->server); - } - FREE(xnode); - xnode = NULL; - } - jchild = jchild->next; - } - } - - if(xnode == NULL) { - return (void *)NULL;; - } - -#ifdef _WIN32 - WSADATA wsa; - - if(WSAStartup(0x202, &wsa) != 0) { - logprintf(LOG_ERR, "could not initialize new socket"); - return (void *)NULL; - } -#endif - - while(loop) { - - if(reset == 1) { - createMessage(xnode->server, xnode->port, shut, none); - reset = 0; - } - - if(xnode->sockfd > -1) { - close(xnode->sockfd); - xnode->sockfd = -1; - } - - /* Try to open a new socket */ - if((xnode->sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - logprintf(LOG_NOTICE, "could not create XBMC/Kodi socket"); - break; - } - - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons((unsigned short)xnode->port); - - inet_pton(AF_INET, xnode->server, &serv_addr.sin_addr); - - retry = 0; - /* Connect to the server */ - switch(socket_timeout_connect(xnode->sockfd, (struct sockaddr *)&serv_addr, 3)) { - case -1: - logprintf(LOG_NOTICE, "could not connect to XBMC/Kodi server @%s", xnode->server); - protocol_thread_wait(node, 3, &nrloops); - retry = 1; - break; - case -2: - logprintf(LOG_NOTICE, "XBMC/Kodi connection timeout @%s", xnode->server); - protocol_thread_wait(node, 3, &nrloops); - retry = 1; - break; - case -3: - logprintf(LOG_NOTICE, "Error in XBMC/Kodi socket connection @%s", xnode->server); - protocol_thread_wait(node, 3, &nrloops); - retry = 1; - break; - default: - createMessage(xnode->server, xnode->port, home, none); - reset = 1; - break; - } - if(retry == 1) { - continue; - } - - struct data_t *xtmp = data; - while(xtmp) { - if(xtmp->sockfd > -1) { - if(maxfd < xtmp->sockfd) { - maxfd = xtmp->sockfd; - } - } - xtmp = xtmp->next; - } - - while(loop) { - pthread_mutex_lock(&xbmclock); - FD_ZERO(&fdsread); - FD_SET((unsigned long)xnode->sockfd, &fdsread); - - do { - n = select(maxfd+1, &fdsread, NULL, NULL, &timeout); - } while(n == -1 && errno == EINTR && loop); - - if(loop == 0) { - pthread_mutex_unlock(&xbmclock); - break; - } - - if(n == -1) { - pthread_mutex_unlock(&xbmclock); - break; - } else if(n == 0) { - usleep(100000); - } else if(n > 0) { - if(FD_ISSET((unsigned long)xnode->sockfd, &fdsread)) { - bytes = (int)recv(xnode->sockfd, recvBuff, BUFFER_SIZE, 0); - if(bytes <= 0) { - pthread_mutex_unlock(&xbmclock); - break; - } else { - if(json_validate(recvBuff) == true) { - JsonNode *joutput = json_decode(recvBuff); - JsonNode *params = NULL; - JsonNode *data = NULL; - JsonNode *item = NULL; - - if(json_find_string(joutput, "method", &m) == 0) { - if(strcmp(m, "GUI.OnScreensaverActivated") == 0) { - strcpy(media, "screensaver"); - strcpy(action, "active"); - } else if(strcmp(m, "GUI.OnScreensaverDeactivated") == 0) { - strcpy(media, "screensaver"); - strcpy(action, "inactive"); - } else { - if((params = json_find_member(joutput, "params")) != NULL) { - if((data = json_find_member(params, "data")) != NULL) { - if((item = json_find_member(data, "item")) != NULL) { - if(json_find_string(item, "type", &t) == 0) { - xbmc->message = json_mkobject(); - - strcpy(media, t); - if(strcmp(m, "Player.OnPlay") == 0) { - strcpy(action, "play"); - } else if(strcmp(m, "Player.OnStop") == 0) { - strcpy(action, home); - strcpy(media, none); - } else if(strcmp(m, "Player.OnPause") == 0) { - strcpy(action, "pause"); - } - } - } - } - } - } - if(strlen(media) > 0 && strlen(action) > 0) { - createMessage(xnode->server, xnode->port, action, media); - reset = 1; - } - } - json_delete(joutput); - } - memset(recvBuff, '\0', BUFFER_SIZE); - memset(&action, '\0', 10); - memset(&media, '\0', 15); - } - } - } - pthread_mutex_unlock(&xbmclock); - } - } - pthread_mutex_unlock(&xbmclock); - - threads--; - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(xbmc, json); - return threads_register("xbmc", &thread, (void *)node, 0); -} - -static void threadGC(void) { - loop = 0; - struct data_t *xtmp = NULL; - - while(data) { - xtmp = data; - if(xtmp->sockfd > -1) { - close(xtmp->sockfd); - xtmp->sockfd = -1; - } - FREE(xtmp->server); - data = data->next; - FREE(xtmp); - } - - protocol_thread_stop(xbmc); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(xbmc); -} - -static int checkValues(JsonNode *code) { - char *action = NULL; - char *media = NULL; - - if(json_find_string(code, "action", &action) == 0 && - json_find_string(code, "media", &media) == 0) { - if(strcmp(media, "none") == 0) { - if(!(strcmp(action, "shutdown") == 0 || strcmp(action, "home") == 0)) { - return 1; - } else { - return 0; - } - } else if(strcmp(media, "episode") == 0 - || strcmp(media, "movie") == 0 - || strcmp(media, "movies") == 0 - || strcmp(media, "song") == 0) { - if(!(strcmp(action, "play") == 0 || strcmp(action, "pause") == 0)) { - return 1; - } else { - return 0; - } - } else if(strcmp(media, "screensaver") == 0) { - if(!(strcmp(action, "active") == 0 || strcmp(action, "inactive") == 0)) { - return 1; - } else { - return 0; - } - } else { - return 1; - } - } else { - return 1; - } - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void xbmcInit(void) { - pthread_mutexattr_init(&xbmcattr); - pthread_mutexattr_settype(&xbmcattr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&xbmclock, &xbmcattr); - - protocol_register(&xbmc); - protocol_set_id(xbmc, "xbmc"); - protocol_device_add(xbmc, "xbmc", "XBMC API"); - protocol_device_add(xbmc, "kodi", "Kodi API"); - xbmc->devtype = XBMC; - xbmc->hwtype = API; - xbmc->multipleId = 0; - - options_add(&xbmc->options, 'a', "action", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&xbmc->options, 'm', "media", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&xbmc->options, 's', "server", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, NULL); - options_add(&xbmc->options, 'p', "port", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - - options_add(&xbmc->options, 0, "show-media", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&xbmc->options, 0, "show-action", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - - xbmc->initDev=&initDev; - xbmc->threadGC=&threadGC; - xbmc->checkValues=&checkValues; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "xbmc"; - module->version = "1.8"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - xbmcInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/API/xbmc.h b/lib/ESPiLight/pilight/libs/pilight/protocols/API/xbmc.h deleted file mode 100644 index 9f63ccf..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/API/xbmc.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_XBMC_H_ -#define _PROTOCOL_XBMC_H_ - -#include "../protocol.h" - -struct protocol_t *xbmc; -void xbmcInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeExclude.txt deleted file mode 100644 index b06943b..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeExclude.txt +++ /dev/null @@ -1,12 +0,0 @@ -include(../../../CMakeConfig.txt) - -if(${ZWAVE} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_headers_includes "${PROJECT_SOURCE_DIR}/zwave/protocol_header.h") - list(REMOVE_ITEM ${PROJECT_NAME}_init_includes "${PROJECT_SOURCE_DIR}/zwave/protocol_init.h") -endif() - -if(${IR} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_headers_includes "${PROJECT_SOURCE_DIR}/IR/protocol_header.h") - list(REMOVE_ITEM ${PROJECT_NAME}_init_includes "${PROJECT_SOURCE_DIR}/IR/protocol_init.h") -endif() - \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeInclude.txt deleted file mode 100644 index 52bf32a..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeInclude.txt +++ /dev/null @@ -1,21 +0,0 @@ -set(headers) -foreach(header ${${PROJECT_NAME}_headers_includes}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -set(inits) -foreach(init ${${PROJECT_NAME}_init_includes}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" init1 ${init}) - string(REPLACE ".h" ".h\"!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" "\n" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeLists.txt deleted file mode 100644 index 391c18e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -project(pilight_protocols) - -add_subdirectory(433.92) -add_subdirectory(API) -add_subdirectory(GPIO) -add_subdirectory(generic) -add_subdirectory(network) -if(${ZWAVE} MATCHES "ON") - add_subdirectory(zwave) -endif() -if(${IR} MATCHES "ON") - add_subdirectory(IR) -endif() -add_subdirectory(core) - -file(REMOVE_RECURSE "protocol_header.h") -file(REMOVE "protocol_header.h") -file(REMOVE_RECURSE "protocol_init.h") -file(REMOVE "protocol_init.h") - -file(GLOB_RECURSE ${PROJECT_NAME}_headers_includes "protocol_header.h") -file(GLOB_RECURSE ${PROJECT_NAME}_init_includes "protocol_init.h") - -include(CMakeExclude.txt) -include(CMakeInclude.txt) - -if(${MODULESPACK} MATCHES "OFF" OR WIN32) - file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") - file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - - set(${PROJECT_NAME}_files - ${pilight_protocols_433.92_files} - ${pilight_protocols_ir_files} - ${pilight_protocols_api_files} - ${pilight_protocols_zwave_files} - ${pilight_protocols_generic_files} - ${pilight_protocols_network_files} - ${pilight_protocols_gpio_files} - ${pilight_protocols_core_files} - ${${PROJECT_NAME}_sources} - ${${PROJECT_NAME}_headers} - CACHE INTERNAL "") -else() - set(${PROJECT_NAME}_files - ${pilight_protocols_433.92_files} - ${pilight_protocols_ir_files} - ${pilight_protocols_api_files} - ${pilight_protocols_zwave_files} - ${pilight_protocols_generic_files} - ${pilight_protocols_network_files} - ${pilight_protocols_gpio_files} - ${pilight_protocols_core_files} - ) - - foreach(file ${${PROJECT_NAME}_files}) - get_filename_component(name ${file} NAME_WE) - get_filename_component(ext ${file} EXT) - if(${ext} MATCHES ".c") - add_library(${name}_module MODULE ${file}) - target_link_libraries(${name}_module ${CMAKE_THREAD_LIBS_INIT}) - target_link_libraries(${name}_module m) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_link_libraries(${name}_module execinfo) - endif() - target_link_libraries(${name}_module ${CMAKE_DL_LIBS}) - set_target_properties(${name}_module PROPERTIES OUTPUT_NAME ${name}) - string(REPLACE "_" "-" debname ${name}) - install(FILES ${CMAKE_BINARY_DIR}/libs/pilight/protocols/lib${name}.so DESTINATION lib/pilight/protocols RENAME ${name}.so COMPONENT pilight-protocol-${debname}) - endif() - endforeach() -endif() \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeExclude.txt deleted file mode 100644 index d603cce..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeExclude.txt +++ /dev/null @@ -1,44 +0,0 @@ -include(../../../../CMakeConfig.txt) - -if(${PROTOCOL_BMP180} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/bmp180.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/bmp180.h") -endif() - -if(${PROTOCOL_DHT11} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/dht11.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/dht11.h") -endif() - -if(${PROTOCOL_DHT22} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/dht22.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/dht22.h") -endif() - -if(${PROTOCOL_DS18B20} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/ds18b20.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/ds18b20.h") -endif() - -if(${PROTOCOL_DS18S20} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/ds18s20.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/ds18s20.h") -endif() - -if(${PROTOCOL_GPIO_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/gpio_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/gpio_switch.h") -endif() - -if(${PROTOCOL_LM75} MATCHES "OFF" - AND ${PROTOCOL_LM76} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/lm75.c") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/lm76.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/lm75.h") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/lm76.h") -endif() - -if(${PROTOCOL_RELAY} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/relay.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/relay.h") -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeInclude.txt deleted file mode 100644 index 496cba9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE protocol_result - OUTPUT_VARIABLE protocol_init) - -set(inits) -foreach(init ${protocol_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeLists.txt deleted file mode 100644 index 9e2584c..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(pilight_protocols_gpio) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeExclude.txt) -include(CMakeInclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/bmp180.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/bmp180.c deleted file mode 100644 index dece272..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/bmp180.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo & hstroh - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/threads.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "../../core/json.h" -#include "../../config/settings.h" -#include "../protocol.h" -#include "bmp180.h" - -#if !defined(__FreeBSD__) && !defined(_WIN32) - -typedef struct settings_t { - char **id; - int nrid; - char path[PATH_MAX]; - int *fd; - // calibration values (stored in each BMP180/085) - short *ac1; - short *ac2; - short *ac3; - unsigned short *ac4; - unsigned short *ac5; - unsigned short *ac6; - short *b1; - short *b2; - short *mb; - short *mc; - short *md; -} settings_t; - -static unsigned short loop = 1; -static int threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -// helper function with built-in result conversion -static int readReg16(int fd, int reg) { - int res = wiringXI2CReadReg16(fd, reg); - // convert result to 16 bits and swap bytes - return ((res << 8) & 0xFF00) | ((res >> 8) & 0xFF); -} - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *) param; - struct JsonNode *json = (struct JsonNode *) node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct settings_t *bmp180data = MALLOC(sizeof(struct settings_t)); - int y = 0, interval = 10, nrloops = 0; - char *stmp = NULL; - double itmp = -1, temp_offset = 0, pressure_offset = 0; - unsigned char oversampling = 1; - - if(bmp180data == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - bmp180data->nrid = 0; - bmp180data->id = NULL; - bmp180data->fd = 0; - bmp180data->ac1 = 0; - bmp180data->ac2 = 0; - bmp180data->ac3 = 0; - bmp180data->ac4 = 0; - bmp180data->ac5 = 0; - bmp180data->ac6 = 0; - bmp180data->b1 = 0; - bmp180data->b2 = 0; - bmp180data->mb = 0; - bmp180data->mc = 0; - bmp180data->md = 0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_string(jchild, "id", &stmp) == 0) { - if((bmp180data->id = REALLOC(bmp180data->id, (sizeof(char *) * (size_t)(bmp180data->nrid + 1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((bmp180data->id[bmp180data->nrid] = MALLOC(strlen(stmp) + 1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(bmp180data->id[bmp180data->nrid], stmp); - bmp180data->nrid++; - } - if(json_find_string(jchild, "i2c-path", &stmp) == 0) { - strcpy(bmp180data->path, stmp); - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int) round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - json_find_number(json, "pressure-offset", &pressure_offset); - if(json_find_number(json, "oversampling", &itmp) == 0) { - oversampling = (unsigned char) itmp; - } - - // resize the memory blocks pointed to by the different pointers - size_t sz = (size_t) (bmp180data->nrid + 1); - unsigned long int sizeShort = sizeof(short) * sz; - unsigned long int sizeUShort = sizeof(unsigned short) * sz; - bmp180data->fd = REALLOC(bmp180data->fd, (sizeof(int) * sz)); - bmp180data->ac1 = REALLOC(bmp180data->ac1, sizeShort); - bmp180data->ac2 = REALLOC(bmp180data->ac2, sizeShort); - bmp180data->ac3 = REALLOC(bmp180data->ac3, sizeShort); - bmp180data->ac4 = REALLOC(bmp180data->ac4, sizeUShort); - bmp180data->ac5 = REALLOC(bmp180data->ac5, sizeUShort); - bmp180data->ac6 = REALLOC(bmp180data->ac6, sizeUShort); - bmp180data->b1 = REALLOC(bmp180data->b1, sizeShort); - bmp180data->b2 = REALLOC(bmp180data->b2, sizeShort); - bmp180data->mb = REALLOC(bmp180data->mb, sizeShort); - bmp180data->mc = REALLOC(bmp180data->mc, sizeShort); - bmp180data->md = REALLOC(bmp180data->md, sizeShort); - if(bmp180data->ac1 == NULL || bmp180data->ac2 == NULL || bmp180data->ac3 == NULL || bmp180data->ac4 == NULL || - bmp180data->ac5 == NULL || bmp180data->ac6 == NULL || bmp180data->b1 == NULL || bmp180data->b2 == NULL || - bmp180data->mb == NULL || bmp180data->mc == NULL || bmp180data->md == NULL || bmp180data->fd == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - for(y = 0; y < bmp180data->nrid; y++) { - // setup i2c - bmp180data->fd[y] = wiringXI2CSetup(bmp180data->path, (int)strtol(bmp180data->id[y], NULL, 16)); - if(bmp180data->fd[y] > 0) { - // read 0xD0 to check chip id: must equal 0x55 for BMP085/180 - int id = wiringXI2CReadReg8(bmp180data->fd[y], 0xD0); - if(id != 0x55) { - logprintf(LOG_ERR, "wrong device detected"); - exit(EXIT_FAILURE); - } - - // read 0xD1 to check chip version: must equal 0x01 for BMP085 or 0x02 for BMP180 - int version = wiringXI2CReadReg8(bmp180data->fd[y], 0xD1); - if(version != 0x01 && version != 0x02) { - logprintf(LOG_ERR, "wrong device detected"); - exit(EXIT_FAILURE); - } - - // read calibration coefficients from register addresses - bmp180data->ac1[y] = (short) readReg16(bmp180data->fd[y], 0xAA); - bmp180data->ac2[y] = (short) readReg16(bmp180data->fd[y], 0xAC); - bmp180data->ac3[y] = (short) readReg16(bmp180data->fd[y], 0xAE); - bmp180data->ac4[y] = (unsigned short) readReg16(bmp180data->fd[y], 0xB0); - bmp180data->ac5[y] = (unsigned short) readReg16(bmp180data->fd[y], 0xB2); - bmp180data->ac6[y] = (unsigned short) readReg16(bmp180data->fd[y], 0xB4); - bmp180data->b1[y] = (short) readReg16(bmp180data->fd[y], 0xB6); - bmp180data->b2[y] = (short) readReg16(bmp180data->fd[y], 0xB8); - bmp180data->mb[y] = (short) readReg16(bmp180data->fd[y], 0xBA); - bmp180data->mc[y] = (short) readReg16(bmp180data->fd[y], 0xBC); - bmp180data->md[y] = (short) readReg16(bmp180data->fd[y], 0xBE); - - // check communication: no result must equal 0 or 0xFFFF (=65535) - if (bmp180data->ac1[y] == 0 || bmp180data->ac1[y] == 0xFFFF || - bmp180data->ac2[y] == 0 || bmp180data->ac2[y] == 0xFFFF || - bmp180data->ac3[y] == 0 || bmp180data->ac3[y] == 0xFFFF || - bmp180data->ac4[y] == 0 || bmp180data->ac4[y] == 0xFFFF || - bmp180data->ac5[y] == 0 || bmp180data->ac5[y] == 0xFFFF || - bmp180data->ac6[y] == 0 || bmp180data->ac6[y] == 0xFFFF || - bmp180data->b1[y] == 0 || bmp180data->b1[y] == 0xFFFF || - bmp180data->b2[y] == 0 || bmp180data->b2[y] == 0xFFFF || - bmp180data->mb[y] == 0 || bmp180data->mb[y] == 0xFFFF || - bmp180data->mc[y] == 0 || bmp180data->mc[y] == 0xFFFF || - bmp180data->md[y] == 0 || bmp180data->md[y] == 0xFFFF) { - logprintf(LOG_ERR, "data communication error"); - exit(EXIT_FAILURE); - } - } - } - - while (loop) { - if (protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - for (y = 0; y < bmp180data->nrid; y++) { - if (bmp180data->fd[y] > 0) { - // uncompensated temperature value - unsigned short ut = 0; - - // write 0x2E into Register 0xF4 to request a temperature reading. - wiringXI2CWriteReg8(bmp180data->fd[y], 0xF4, 0x2E); - - // wait at least 4.5ms: we suspend execution for 5000 microseconds. - usleep(5000); - - // read the two byte result from address 0xF6. - ut = (unsigned short) readReg16(bmp180data->fd[y], 0xF6); - - // calculate temperature (in units of 0.1 deg C) given uncompensated value - int x1, x2; - x1 = (((int) ut - (int) bmp180data->ac6[y])) * (int) bmp180data->ac5[y] >> 15; - x2 = ((int) bmp180data->mc[y] << 11) / (x1 + bmp180data->md[y]); - int b5 = x1 + x2; - int temp = ((b5 + 8) >> 4); - - // uncompensated pressure value - unsigned int up = 0; - - // write 0x34+(BMP085_OVERSAMPLING_SETTING<<6) into register 0xF4 - // request a pressure reading with specified oversampling setting - wiringXI2CWriteReg8(bmp180data->fd[y], 0xF4, - 0x34 + (oversampling << 6)); - - // wait for conversion, delay time dependent on oversampling setting - unsigned int delay = (unsigned int) ((2 + (3 << oversampling)) * 1000); - usleep(delay); - - // read the three byte result (block data): 0xF6 = MSB, 0xF7 = LSB and 0xF8 = XLSB - int msb = wiringXI2CReadReg8(bmp180data->fd[y], 0xF6); - int lsb = wiringXI2CReadReg8(bmp180data->fd[y], 0xF7); - int xlsb = wiringXI2CReadReg8(bmp180data->fd[y], 0xF8); - up = (((unsigned int) msb << 16) | ((unsigned int) lsb << 8) | (unsigned int) xlsb) - >> (8 - oversampling); - - // calculate pressure (in Pa) given uncompensated value - int x3, b3, b6, pressure; - unsigned int b4, b7; - - // calculate B6 - b6 = b5 - 4000; - - // calculate B3 - x1 = (bmp180data->b2[y] * (b6 * b6) >> 12) >> 11; - x2 = (bmp180data->ac2[y] * b6) >> 11; - x3 = x1 + x2; - b3 = (((bmp180data->ac1[y] * 4 + x3) << oversampling) + 2) >> 2; - - // calculate B4 - x1 = (bmp180data->ac3[y] * b6) >> 13; - x2 = (bmp180data->b1[y] * ((b6 * b6) >> 12)) >> 16; - x3 = ((x1 + x2) + 2) >> 2; - b4 = (bmp180data->ac4[y] * (unsigned int) (x3 + 32768)) >> 15; - - // calculate B7 - b7 = ((up - (unsigned int) b3) * ((unsigned int) 50000 >> oversampling)); - - // calculate pressure in Pa - pressure = b7 < 0x80000000 ? (int) ((b7 << 1) / b4) : (int) ((b7 / b4) << 1); - x1 = (pressure >> 8) * (pressure >> 8); - x1 = (x1 * 3038) >> 16; - x2 = (-7357 * pressure) >> 16; - pressure += (x1 + x2 + 3791) >> 4; - - bmp180->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "id", json_mkstring(bmp180data->id[y])); - json_append_member(code, "temperature", json_mknumber(((double) temp / 10) + temp_offset, 1)); // in deg C - json_append_member(code, "pressure", json_mknumber(((double) pressure / 100) + pressure_offset, 1)); // in hPa - - json_append_member(bmp180->message, "message", code); - json_append_member(bmp180->message, "origin", json_mkstring("receiver")); - json_append_member(bmp180->message, "protocol", json_mkstring(bmp180->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(bmp180->id, bmp180->message, PROTOCOL); - } - json_delete(bmp180->message); - bmp180->message = NULL; - } else { - logprintf(LOG_NOTICE, "error connecting to bmp180"); - logprintf(LOG_DEBUG, "(probably i2c bus error from wiringXI2CSetup)"); - logprintf(LOG_DEBUG, "(maybe wrong id? use i2cdetect to find out)"); - protocol_thread_wait(node, 1, &nrloops); - } - } - pthread_mutex_unlock(&lock); - } - } - - if (bmp180data->id) { - for (y = 0; y < bmp180data->nrid; y++) { - FREE(bmp180data->id[y]); - } - FREE(bmp180data->id); - } - if (bmp180data->ac1) { - FREE(bmp180data->ac1); - } - if (bmp180data->ac2) { - FREE(bmp180data->ac2); - } - if (bmp180data->ac3) { - FREE(bmp180data->ac3); - } - if (bmp180data->ac4) { - FREE(bmp180data->ac4); - } - if (bmp180data->ac5) { - FREE(bmp180data->ac5); - } - if (bmp180data->ac6) { - FREE(bmp180data->ac6); - } - if (bmp180data->b1) { - FREE(bmp180data->b1); - } - if (bmp180data->b2) { - FREE(bmp180data->b2); - } - if (bmp180data->mb) { - FREE(bmp180data->mb); - } - if (bmp180data->mc) { - FREE(bmp180data->mc); - } - if (bmp180data->md) { - FREE(bmp180data->md); - } - if (bmp180data->fd) { - for (y = 0; y < bmp180data->nrid; y++) { - if (bmp180data->fd[y] > 0) { - close(bmp180data->fd[y]); - } - } - FREE(bmp180data->fd); - } - FREE(bmp180data); - threads--; - - return (void *) NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "gpio_switch: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(bmp180, json); - return threads_register("bmp180", &thread, (void *) node, 0); - } else { - return NULL; - } -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(bmp180); - while (threads > 0) { - usleep(10); - } - protocol_thread_free(bmp180); -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void bmp180Init(void) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - - protocol_register(&bmp180); - protocol_set_id(bmp180, "bmp180"); - protocol_device_add(bmp180, "bmp180", "I2C Barometric Pressure and Temperature Sensor"); - protocol_device_add(bmp180, "bmp085", "I2C Barometric Pressure and Temperature Sensor"); - bmp180->devtype = WEATHER; - bmp180->hwtype = SENSOR; - - options_add(&bmp180->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "0x[0-9a-f]{2}"); - options_add(&bmp180->options, 'o', "oversampling", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *) 1, "^[0123]$"); - options_add(&bmp180->options, 'p', "pressure", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, (void *) 0, "^[0-9]{1,3}$"); - options_add(&bmp180->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, (void *) 0, "^[0-9]{1,3}$"); - options_add(&bmp180->options, 'd', "i2c-path", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^/dev/i2c-[0-9]{1,2}$"); - - options_add(&bmp180->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *) 10, "[0-9]"); - options_add(&bmp180->options, 0, "pressure-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *) 0, "[0-9]"); - options_add(&bmp180->options, 0, "temperature-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *) 0, "[0-9]"); - options_add(&bmp180->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *) 1, "[0-9]"); - options_add(&bmp180->options, 0, "humidity-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *) 1, "[0-9]"); - options_add(&bmp180->options, 0, "pressure-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *) 1, "[0-9]"); - options_add(&bmp180->options, 0, "show-pressure", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *) 1, "^[10]{1}$"); - options_add(&bmp180->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *) 1, "^[10]{1}$"); - -#if !defined(__FreeBSD__) && !defined(_WIN32) - bmp180->initDev = &initDev; - bmp180->threadGC = &threadGC; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "bmp180"; - module->version = "2.2"; - module->reqversion = "7.0"; - module->reqcommit = "186"; -} - -void init(void) { - bmp180Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/bmp180.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/bmp180.h deleted file mode 100644 index ae746a4..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/bmp180.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo & hstroh - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_BMP180_H_ -#define _PROTOCOL_BMP180_H_ - -#include "../protocol.h" - -struct protocol_t *bmp180; -void bmp180Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht11.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht11.c deleted file mode 100644 index 8515882..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht11.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/threads.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "../../core/json.h" -#include "../../config/settings.h" -#include "../protocol.h" -#include "dht11.h" - -#define MAXTIMINGS 100 - -#if !defined(__FreeBSD__) && !defined(_WIN32) - -static unsigned short loop = 1; -static unsigned short threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static uint8_t sizecvt(const int read_value) { - /* digitalRead() and friends from wiringx are defined as returning a value - < 256. However, they are returned as int() types. This is a safety function */ - if(read_value > 255 || read_value < 0) { - logprintf(LOG_NOTICE, "invalid data from wiringX library"); - return -1; - } - - return (uint8_t)read_value; -} - -static void *dht11Parse(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - int *id = 0; - int nrid = 0, y = 0, interval = 10, nrloops = 0, x = 0; - double temp_offset = 0.0, humi_offset = 0.0, itmp = 0.0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_number(jchild, "gpio", &itmp) == 0) { - id = REALLOC(id, (sizeof(int)*(size_t)(nrid+1))); - id[nrid] = (int)round(itmp); - nrid++; - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - json_find_number(json, "humidity-offset", &humi_offset); - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - for(y=0;y= 4) && (i%2 == 0)) { - - // shove each bit into the storage bytes - dht11_dat[(int)((double)j/8)] <<= 1; - if(counter > 16) - dht11_dat[(int)((double)j/8)] |= 1; - j++; - } - } - - // check we read 40 bits (8bit x 5 ) + verify checksum in the last byte - // print it out if data is good - if((j >= 40) && (dht11_dat[4] == ((dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF))) { - got_correct_date = 1; - - double h = dht11_dat[0]; - double t = dht11_dat[2]; - t += temp_offset; - h += humi_offset; - - dht11->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "gpio", json_mknumber(id[y], 0)); - json_append_member(code, "temperature", json_mknumber(t, 1)); - json_append_member(code, "humidity", json_mknumber(h, 1)); - - json_append_member(dht11->message, "message", code); - json_append_member(dht11->message, "origin", json_mkstring("receiver")); - json_append_member(dht11->message, "protocol", json_mkstring(dht11->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(dht11->id, dht11->message, PROTOCOL); - } - json_delete(dht11->message); - dht11->message = NULL; - } else { - logprintf(LOG_DEBUG, "dht11 data checksum was wrong"); - tries--; - protocol_thread_wait(node, 1, &nrloops); - } - } - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - FREE(id); - threads--; - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "gpio_switch: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(dht11, json); - return threads_register("dht11", &dht11Parse, (void *)node, 0); - } else { - return NULL; - } -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(dht11); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(dht11); -} - -static int checkValues(JsonNode *code) { - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - double itmp = -1; - - /* Validate GPIO number */ - if((jid = json_find_member(code, "id")) != NULL) { - if((jchild = json_find_element(jid, 0)) != NULL) { - if(json_find_number(jchild, "gpio", &itmp) == 0) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "dht11: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - int gpio = (int)itmp; - if(wiringXValidGPIO(gpio) != 0) { - logprintf(LOG_ERR, "dht11: invalid gpio range"); - return -1; - } - } - } - } - } - - return 0; -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void dht11Init(void) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - - protocol_register(&dht11); - protocol_set_id(dht11, "dht11"); - protocol_device_add(dht11, "dht11", "1-wire Temperature and Humidity Sensor"); - dht11->devtype = WEATHER; - dht11->hwtype = SENSOR; - - options_add(&dht11->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,3}$"); - options_add(&dht11->options, 'h', "humidity", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,3}$"); - options_add(&dht11->options, 'g', "gpio", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - - // options_add(&dht11->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&dht11->options, 0, "temperature-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&dht11->options, 0, "humidity-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&dht11->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&dht11->options, 0, "humidity-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&dht11->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&dht11->options, 0, "show-humidity", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&dht11->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "[0-9]"); - -#if !defined(__FreeBSD__) && !defined(_WIN32) - dht11->initDev=&initDev; - dht11->threadGC=&threadGC; - dht11->checkValues=&checkValues; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "dht11"; - module->version = "2.5"; - module->reqversion = "7.0"; - module->reqcommit = "186"; -} - -void init(void) { - dht11Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht11.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht11.h deleted file mode 100644 index 43067e7..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht11.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_DHT11_H_ -#define _PROTOCOL_DHT11_H_ - -#include "../protocol.h" - -struct protocol_t *dht11; -void dht11Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht22.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht22.c deleted file mode 100644 index 9921b6f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht22.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/threads.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "../../core/json.h" -#include "../../config/settings.h" -#include "../protocol.h" -#include "dht22.h" - -#define MAXTIMINGS 100 - -#if !defined(__FreeBSD__) && !defined(_WIN32) - -static unsigned short loop = 1; -static unsigned short threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static uint8_t sizecvt(const int read_value) { - /* digitalRead() and friends from wiringx are defined as returning a value - < 256. However, they are returned as int() types. This is a safety function */ - if(read_value > 255 || read_value < 0) { - logprintf(LOG_NOTICE, "invalid data from wiringX library"); - return -1; - } - - return (uint8_t)read_value; -} - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - int *id = 0; - int nrid = 0, y = 0, interval = 10, nrloops = 0, x = 0; - double temp_offset = 0.0, humi_offset = 0.0, itmp = 0.0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_number(jchild, "gpio", &itmp) == 0) { - id = REALLOC(id, (sizeof(int)*(size_t)(nrid+1))); - id[nrid] = (int)round(itmp); - nrid++; - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - json_find_number(json, "humidity-offset", &humi_offset); - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - for(y=0;y= 4) && (i%2 == 0)) { - // shove each bit into the storage bytes - dht22_dat[(int)((double)j/8)] <<= 1; - if(counter > 16) - dht22_dat[(int)((double)j/8)] |= 1; - j++; - } - } - - // check we read 40 bits (8bit x 5 ) + verify checksum in the last byte - // print it out if data is good - if((j >= 40) && (dht22_dat[4] == ((dht22_dat[0] + dht22_dat[1] + dht22_dat[2] + dht22_dat[3]) & 0xFF))) { - got_correct_date = 1; - - double h = dht22_dat[0] * 256 + dht22_dat[1]; - double t = (dht22_dat[2] & 0x7F)* 256 + dht22_dat[3]; - t += temp_offset; - h += humi_offset; - - if((dht22_dat[2] & 0x80) != 0) - t *= -1; - - dht22->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "gpio", json_mknumber(id[y], 0)); - json_append_member(code, "temperature", json_mknumber(t/10, 1)); - json_append_member(code, "humidity", json_mknumber(h/10, 1)); - - json_append_member(dht22->message, "message", code); - json_append_member(dht22->message, "origin", json_mkstring("receiver")); - json_append_member(dht22->message, "protocol", json_mkstring(dht22->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(dht22->id, dht22->message, PROTOCOL); - } - json_delete(dht22->message); - dht22->message = NULL; - } else { - logprintf(LOG_DEBUG, "dht22 data checksum was wrong"); - tries--; - protocol_thread_wait(node, 1, &nrloops); - } - } - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - FREE(id); - threads--; - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "dht22: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(dht22, json); - return threads_register("dht22", &thread, (void *)node, 0); - } else { - return NULL; - } -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(dht22); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(dht22); -} - -static int checkValues(JsonNode *code) { - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - double itmp = -1; - - /* Validate GPIO number */ - if((jid = json_find_member(code, "id")) != NULL) { - if((jchild = json_find_element(jid, 0)) != NULL) { - if(json_find_number(jchild, "gpio", &itmp) == 0) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "dht22: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - int gpio = (int)itmp; - if(wiringXValidGPIO(gpio) != 0) { - logprintf(LOG_ERR, "dht22: invalid gpio range"); - return -1; - } - } - } - } - } - - return 0; -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void dht22Init(void) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - - protocol_register(&dht22); - protocol_set_id(dht22, "dht22"); - protocol_device_add(dht22, "dht22", "1-wire Temperature and Humidity Sensor"); - protocol_device_add(dht22, "am2302", "1-wire Temperature and Humidity Sensor"); - dht22->devtype = WEATHER; - dht22->hwtype = SENSOR; - - options_add(&dht22->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,3}$"); - options_add(&dht22->options, 'h', "humidity", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,3}$"); - options_add(&dht22->options, 'g', "gpio", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - - // options_add(&dht22->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&dht22->options, 0, "temperature-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&dht22->options, 0, "humidity-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&dht22->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&dht22->options, 0, "humidity-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&dht22->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&dht22->options, 0, "show-humidity", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&dht22->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "[0-9]"); - -#if !defined(__FreeBSD__) && !defined(_WIN32) - dht22->initDev=&initDev; - dht22->threadGC=&threadGC; - dht22->checkValues=&checkValues; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "dht22"; - module->version = "2.5"; - module->reqversion = "7.0"; - module->reqcommit = "186"; -} - -void init(void) { - dht22Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht22.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht22.h deleted file mode 100644 index 8804ea9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/dht22.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_DHT22_H_ -#define _PROTOCOL_DHT22_H_ - -#include "../protocol.h" - -struct protocol_t *dht22; -void dht22Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18b20.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18b20.c deleted file mode 100644 index a00e147..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18b20.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "ds18b20.h" - -static unsigned short loop = 1; -static unsigned short threads = 0; -static char source_path[21]; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static void *ds18b20Parse(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - -#ifndef _WIN32 - struct dirent *file = NULL; - struct stat st; - - DIR *d = NULL; - FILE *fp = NULL; - char crcVar[5]; - int w1valid = 0; - double w1temp = 0.0; - size_t bytes = 0; -#endif - char **id = NULL, *stmp = NULL, *content = NULL; - char *ds18b20_sensor = NULL; - int nrid = 0, interval = 10, nrloops = 0, y = 0; - double temp_offset = 0.0, itmp = 0.0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_string(jchild, "id", &stmp) == 0) { - if((id = REALLOC(id, (sizeof(char *)*(size_t)(nrid+1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((id[nrid] = MALLOC(strlen(stmp)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(id[nrid], stmp); - nrid++; - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { -#ifndef _WIN32 - pthread_mutex_lock(&lock); - for(y=0;yd_type == DT_REG) { - if(strcmp(file->d_name, "w1_slave") == 0) { - size_t w1slavelen = strlen(ds18b20_sensor)+10; - char ds18b20_w1slave[w1slavelen]; - memset(ds18b20_w1slave, '\0', w1slavelen); - strncpy(ds18b20_w1slave, ds18b20_sensor, strlen(ds18b20_sensor)); - strcat(ds18b20_w1slave, "w1_slave"); - - if(!(fp = fopen(ds18b20_w1slave, "rb"))) { - logprintf(LOG_ERR, "cannot read w1 file: %s", ds18b20_w1slave); - break; - } - - fstat(fileno(fp), &st); - bytes = (size_t)st.st_size; - - if((content = REALLOC(content, bytes+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - fclose(fp); - break; - } - memset(content, '\0', bytes+1); - - if(fread(content, sizeof(char), bytes, fp) == -1) { - logprintf(LOG_ERR, "cannot read config file: %s", ds18b20_w1slave); - fclose(fp); - break; - } - fclose(fp); - w1valid = 0; - - char **array = NULL; - unsigned int n = explode(content, "\n", &array); - if(n > 0) { - sscanf(array[0], "%*x %*x %*x %*x %*x %*x %*x %*x %*x : crc=%*x %s", crcVar); - if(strncmp(crcVar, "YES", 3) == 0 && n > 1) { - w1valid = 1; - sscanf(array[1], "%*x %*x %*x %*x %*x %*x %*x %*x %*x t=%lf", &w1temp); - w1temp = (w1temp/1000)+temp_offset; - } - } - array_free(&array, n); - - if(w1valid) { - ds18b20->message = json_mkobject(); - - JsonNode *code = json_mkobject(); - - json_append_member(code, "id", json_mkstring(id[y])); - json_append_member(code, "temperature", json_mknumber(w1temp, 3)); - - json_append_member(ds18b20->message, "message", code); - json_append_member(ds18b20->message, "origin", json_mkstring("receiver")); - json_append_member(ds18b20->message, "protocol", json_mkstring(ds18b20->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(ds18b20->id, ds18b20->message, PROTOCOL); - } - json_delete(ds18b20->message); - ds18b20->message = NULL; - } - } - } - } - closedir(d); - } else { - logprintf(LOG_ERR, "1-wire device %s does not exist", ds18b20_sensor); - } - } -#endif - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - if(ds18b20_sensor) { - FREE(ds18b20_sensor); - } - if(content) { - FREE(content); - } - for(y=0;y 0) { - usleep(10); - } - protocol_thread_free(ds18b20); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void ds18b20Init(void) { - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); - - protocol_register(&ds18b20); - protocol_set_id(ds18b20, "ds18b20"); - protocol_device_add(ds18b20, "ds18b20", "1-wire Temperature Sensor"); - ds18b20->devtype = WEATHER; - ds18b20->hwtype = SENSOR; - - options_add(&ds18b20->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,5}$"); - options_add(&ds18b20->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[a-z0-9]{12}$"); - - // options_add(&ds18b20->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&ds18b20->options, 0, "temperature-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&ds18b20->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&ds18b20->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&ds18b20->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "[0-9]"); - - memset(source_path, '\0', 21); - strcpy(source_path, "/sys/bus/w1/devices/"); - - ds18b20->initDev=&initDev; - ds18b20->threadGC=&threadGC; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "ds18b20"; - module->version = "2.0"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - ds18b20Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18b20.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18b20.h deleted file mode 100644 index 836e9a9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18b20.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_DS18B20_H_ -#define _PROTOCOL_DS18B20_H_ - -#include "../protocol.h" - -struct protocol_t *ds18b20; -void ds18b20Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18s20.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18s20.c deleted file mode 100644 index db21171..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18s20.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif - -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "ds18s20.h" - -static unsigned short loop = 1; -static unsigned short threads = 0; -static char source_path[21]; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - -#ifndef _WIN32 - struct dirent *file = NULL; - struct stat st; - - DIR *d = NULL; - FILE *fp = NULL; - char crcVar[5]; - int w1valid = 0; - double w1temp = 0.0; - size_t bytes = 0; -#endif - char **id = NULL, *stmp = NULL, *content = NULL; - char *ds18s20_sensor = NULL; - int nrid = 0, interval = 10, nrloops = 0, y = 0; - double temp_offset = 0.0, itmp = 0.0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_string(jchild, "id", &stmp) == 0) { - if((id = REALLOC(id, (sizeof(char *)*(size_t)(nrid+1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((id[nrid] = MALLOC(strlen(stmp)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(id[nrid], stmp); - nrid++; - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { -#ifndef _WIN32 - pthread_mutex_lock(&lock); - for(y=0;yd_type == DT_REG) { - if(strcmp(file->d_name, "w1_slave") == 0) { - size_t w1slavelen = strlen(ds18s20_sensor)+10; - char ds18s20_w1slave[w1slavelen]; - memset(ds18s20_w1slave, '\0', w1slavelen); - strncpy(ds18s20_w1slave, ds18s20_sensor, strlen(ds18s20_sensor)); - strcat(ds18s20_w1slave, "w1_slave"); - - if(!(fp = fopen(ds18s20_w1slave, "rb"))) { - logprintf(LOG_ERR, "cannot read w1 file: %s", ds18s20_w1slave); - break; - } - - fstat(fileno(fp), &st); - bytes = (size_t)st.st_size; - - if(!(content = REALLOC(content, bytes+1))) { - fprintf(stderr, "out of memory\n"); - fclose(fp); - break; - } - memset(content, '\0', bytes+1); - - if(fread(content, sizeof(char), bytes, fp) == -1) { - logprintf(LOG_ERR, "cannot read config file: %s", ds18s20_w1slave); - fclose(fp); - break; - } - fclose(fp); - w1valid = 0; - - char **array = NULL; - unsigned int n = explode(content, "\n", &array); - if(n > 0) { - sscanf(array[0], "%*x %*x %*x %*x %*x %*x %*x %*x %*x : crc=%*x %s", crcVar); - if(strncmp(crcVar, "YES", 3) == 0 && n > 1) { - w1valid = 1; - sscanf(array[1], "%*x %*x %*x %*x %*x %*x %*x %*x %*x t=%lf", &w1temp); - w1temp = (w1temp/1000)+temp_offset; - } - } - array_free(&array, n); - - if(w1valid) { - ds18s20->message = json_mkobject(); - - JsonNode *code = json_mkobject(); - - json_append_member(code, "id", json_mkstring(id[y])); - json_append_member(code, "temperature", json_mknumber(w1temp, 1)); - - json_append_member(ds18s20->message, "message", code); - json_append_member(ds18s20->message, "origin", json_mkstring("receiver")); - json_append_member(ds18s20->message, "protocol", json_mkstring(ds18s20->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(ds18s20->id, ds18s20->message, PROTOCOL); - } - json_delete(ds18s20->message); - ds18s20->message = NULL; - } - } - } - } - closedir(d); - } else { - logprintf(LOG_ERR, "1-wire device %s does not exist", ds18s20_sensor); - } - } -#endif - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - if(ds18s20_sensor) { - FREE(ds18s20_sensor); - } - if(content) { - FREE(content); - } - for(y=0;y 0) { - usleep(10); - } - protocol_thread_free(ds18s20); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void ds18s20Init(void) { - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); - - protocol_register(&ds18s20); - protocol_set_id(ds18s20, "ds18s20"); - protocol_device_add(ds18s20, "ds18s20", "1-wire Temperature Sensor"); - ds18s20->devtype = WEATHER; - ds18s20->hwtype = SENSOR; - - options_add(&ds18s20->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,5}$"); - options_add(&ds18s20->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[a-z0-9]{12}$"); - - // options_add(&ds18s20->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&ds18s20->options, 0, "temperature-offset", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&ds18s20->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&ds18s20->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&ds18s20->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "[0-9]"); - - memset(source_path, '\0', 21); - strcpy(source_path, "/sys/bus/w1/devices/"); - - ds18s20->initDev=&initDev; - ds18s20->threadGC=&theadGC; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "ds18s20"; - module->version = "2.0"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - ds18s20Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18s20.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18s20.h deleted file mode 100644 index 6a353f2..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/ds18s20.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_DS18S20_H_ -#define _PROTOCOL_DS18S20_H_ - -#include "../protocol.h" - -struct protocol_t *ds18s20; -void ds18s20Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/gpio_switch.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/gpio_switch.c deleted file mode 100644 index 15245c4..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/gpio_switch.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#endif - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/irq.h" -#include "../../core/gc.h" -#include "../../config/settings.h" -#include "../protocol.h" -#include "gpio_switch.h" - -#if !defined(__FreeBSD__) && !defined(_WIN32) - -static unsigned short loop = 1; -static int threads = 0; - -static void createMessage(int gpio, int state) { - gpio_switch->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "gpio", json_mknumber(gpio, 0)); - if(state) { - json_append_member(code, "state", json_mkstring("on")); - } else { - json_append_member(code, "state", json_mkstring("off")); - } - - json_append_member(gpio_switch->message, "message", code); - json_append_member(gpio_switch->message, "origin", json_mkstring("receiver")); - json_append_member(gpio_switch->message, "protocol", json_mkstring(gpio_switch->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(gpio_switch->id, gpio_switch->message, PROTOCOL); - } - json_delete(gpio_switch->message); - gpio_switch->message = NULL; -} - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - int id = 0, state = 0, nstate = 0; - double itmp = 0.0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - if(json_find_number(jchild, "gpio", &itmp) == 0) { - id = (int)round(itmp); - if(wiringXISR(id, ISR_MODE_BOTH) < 0) { - threads--; - return NULL; - } - state = digitalRead(id); - } - } - - createMessage(id, state); - - while(loop) { - irq_read(id); - nstate = digitalRead(id); - if(nstate != state) { - state = nstate; - createMessage(id, state); - usleep(100000); - } - } - - threads--; - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "gpio_switch: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(gpio_switch, json); - return threads_register("gpio_switch", &thread, (void *)node, 0); - } else { - return NULL; - } -} - -static int checkValues(struct JsonNode *jvalues) { - double readonly = 0.0; - - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "gpio_switch: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - struct JsonNode *jid = NULL; - if((jid = json_find_member(jvalues, "id"))) { - struct JsonNode *jchild = NULL; - struct JsonNode *jchild1 = NULL; - - jchild = json_first_child(jid); - while(jchild) { - jchild1 = json_first_child(jchild); - while(jchild1) { - if(strcmp(jchild1->key, "gpio") == 0) { - if(wiringXValidGPIO((int)round(jchild1->number_)) != 0) { - return -1; - } - } - jchild1 = jchild1->next; - } - jchild = jchild->next; - } - } - } - - if(json_find_number(jvalues, "readonly", &readonly) == 0) { - if((int)readonly != 1) { - return -1; - } - } - - return 0; -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(gpio_switch); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(gpio_switch); -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void gpioSwitchInit(void) { - - protocol_register(&gpio_switch); - protocol_set_id(gpio_switch, "gpio_switch"); - protocol_device_add(gpio_switch, "gpio_switch", "GPIO as a switch"); - gpio_switch->devtype = SWITCH; - gpio_switch->hwtype = SENSOR; - - options_add(&gpio_switch->options, 't', "on", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&gpio_switch->options, 'f', "off", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&gpio_switch->options, 'g', "gpio", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^([0-9]{1}|1[0-9]|20)$"); - - options_add(&gpio_switch->options, 0, "readonly", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&gpio_switch->options, 0, "confirm", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - -#if !defined(__FreeBSD__) && !defined(_WIN32) - gpio_switch->initDev=&initDev; - gpio_switch->threadGC=&threadGC; - gpio_switch->checkValues=&checkValues; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "gpio_switch"; - module->version = "2.4"; - module->reqversion = "7.0"; - module->reqcommit = "186"; -} - -void init(void) { - gpioSwitchInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/gpio_switch.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/gpio_switch.h deleted file mode 100644 index 432f9fa..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/gpio_switch.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_GPIO_SWITCH_H_ -#define _PROTOCOL_GPIO_SWITCH_H_ - -#include "../protocol.h" - -struct protocol_t *gpio_switch; -void gpioSwitchInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm75.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm75.c deleted file mode 100644 index 5c21623..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm75.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/threads.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "../../core/json.h" -#include "../../config/settings.h" -#include "../protocol.h" -#include "lm75.h" - -#if !defined(__FreeBSD__) && !defined(_WIN32) -typedef struct settings_t { - char **id; - char path[PATH_MAX]; - int nrid; - int *fd; -} settings_t; - -static unsigned short loop = 1; -static int threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct settings_t *lm75data = MALLOC(sizeof(struct settings_t)); - int y = 0, interval = 10, nrloops = 0; - char *stmp = NULL; - double itmp = -1, temp_offset = 0.0; - - if(lm75data == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - lm75data->nrid = 0; - lm75data->id = NULL; - lm75data->fd = 0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_string(jchild, "id", &stmp) == 0) { - if((lm75data->id = REALLOC(lm75data->id, (sizeof(char *)*(size_t)(lm75data->nrid+1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((lm75data->id[lm75data->nrid] = MALLOC(strlen(stmp)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lm75data->id[lm75data->nrid], stmp); - lm75data->nrid++; - } - if(json_find_string(jchild, "i2c-path", &stmp) == 0) { - strcpy(lm75data->path, stmp); - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - - if((lm75data->fd = REALLOC(lm75data->fd, (sizeof(int)*(size_t)(lm75data->nrid+1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - for(y=0;ynrid;y++) { - lm75data->fd[y] = wiringXI2CSetup(lm75data->path, (int)strtol(lm75data->id[y], NULL, 16)); - } - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - for(y=0;ynrid;y++) { - if(lm75data->fd[y] > 0) { - int raw = wiringXI2CReadReg16(lm75data->fd[y], 0x00); - float temp = ((float)((raw&0x00ff)+((raw>>15)?0:0.5))*10); - - lm75->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "id", json_mkstring(lm75data->id[y])); - json_append_member(code, "temperature", json_mknumber((temp+temp_offset)/10, 1)); - - json_append_member(lm75->message, "message", code); - json_append_member(lm75->message, "origin", json_mkstring("receiver")); - json_append_member(lm75->message, "protocol", json_mkstring(lm75->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(lm75->id, lm75->message, PROTOCOL); - } - json_delete(lm75->message); - lm75->message = NULL; - } else { - logprintf(LOG_NOTICE, "error connecting to lm75"); - logprintf(LOG_DEBUG, "(probably i2c bus error from wiringXI2CSetup)"); - logprintf(LOG_DEBUG, "(maybe wrong id? use i2cdetect to find out)"); - protocol_thread_wait(node, 1, &nrloops); - } - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - if(lm75data->id) { - for(y=0;ynrid;y++) { - FREE(lm75data->id[y]); - } - FREE(lm75data->id); - } - if(lm75data->fd) { - for(y=0;ynrid;y++) { - if(lm75data->fd[y] > 0) { - close(lm75data->fd[y]); - } - } - FREE(lm75data->fd); - } - FREE(lm75data); - threads--; - - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "lm75: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(lm75, json); - return threads_register("lm75", &thread, (void *)node, 0); - } else { - return NULL; - } -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(lm75); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(lm75); -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void lm75Init(void) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - - protocol_register(&lm75); - protocol_set_id(lm75, "lm75"); - protocol_device_add(lm75, "lm75", "TI I2C Temperature Sensor"); - lm75->devtype = WEATHER; - lm75->hwtype = SENSOR; - - options_add(&lm75->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,3}$"); - options_add(&lm75->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "0x[0-9a-f]{2}"); - options_add(&lm75->options, 'd', "i2c-path", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^/dev/i2c-[0-9]{1,2}$"); - - // options_add(&lm75->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&lm75->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "[0-9]"); - options_add(&lm75->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - -#if !defined(__FreeBSD__) && !defined(_WIN32) - lm75->initDev=&initDev; - lm75->threadGC=&threadGC; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "lm75"; - module->version = "2.2"; - module->reqversion = "7.0"; - module->reqcommit = "186"; -} - -void init(void) { - lm75Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm75.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm75.h deleted file mode 100644 index b3be4e4..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm75.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_LM75_H_ -#define _PROTOCOL_LM75_H_ - -#include "../protocol.h" - -struct protocol_t *lm75; -void lm75Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm76.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm76.c deleted file mode 100644 index bdfa01a..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm76.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif - #include -#endif -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/threads.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "../../core/json.h" -#include "../../config/settings.h" -#include "../protocol.h" -#include "lm76.h" - -#if !defined(__FreeBSD__) && !defined(_WIN32) -typedef struct settings_t { - char **id; - char path[PATH_MAX]; - int nrid; - int *fd; -} settings_t; - -static unsigned short loop = 1; -static int threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - struct settings_t *lm76data = MALLOC(sizeof(struct settings_t)); - int y = 0, interval = 10, nrloops = 0; - char *stmp = NULL; - double itmp = -1, temp_offset = 0; - - if(lm76data == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - lm76data->nrid = 0; - lm76data->id = NULL; - lm76data->fd = 0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_string(jchild, "id", &stmp) == 0) { - if((lm76data->id = REALLOC(lm76data->id, (sizeof(char *)*(size_t)(lm76data->nrid+1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((lm76data->id[lm76data->nrid] = MALLOC(strlen(stmp)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(lm76data->id[lm76data->nrid], stmp); - lm76data->nrid++; - } - if(json_find_string(jchild, "i2c-path", &stmp) == 0) { - strcpy(lm76data->path, stmp); - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - json_find_number(json, "temperature-offset", &temp_offset); - - if((lm76data->fd = REALLOC(lm76data->fd, (sizeof(int)*(size_t)(lm76data->nrid+1)))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - for(y=0;ynrid;y++) { - lm76data->fd[y] = wiringXI2CSetup(lm76data->path, (int)strtol(lm76data->id[y], NULL, 16)); - } - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - for(y=0;ynrid;y++) { - if(lm76data->fd[y] > 0) { - int raw = wiringXI2CReadReg16(lm76data->fd[y], 0x00); - float temp = ((float)((raw&0x00ff)+((raw>>12)*0.0625))); - - lm76->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "id", json_mkstring(lm76data->id[y])); - json_append_member(code, "temperature", json_mknumber(temp+temp_offset, 3)); - - json_append_member(lm76->message, "message", code); - json_append_member(lm76->message, "origin", json_mkstring("receiver")); - json_append_member(lm76->message, "protocol", json_mkstring(lm76->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(lm76->id, lm76->message, PROTOCOL); - } - json_delete(lm76->message); - lm76->message = NULL; - } else { - logprintf(LOG_NOTICE, "error connecting to lm76"); - logprintf(LOG_DEBUG, "(probably i2c bus error from wiringXI2CSetup)"); - logprintf(LOG_DEBUG, "(maybe wrong id? use i2cdetect to find out)"); - protocol_thread_wait(node, 1, &nrloops); - } - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - if(lm76data->id) { - for(y=0;ynrid;y++) { - FREE(lm76data->id[y]); - } - FREE(lm76data->id); - } - if(lm76data->fd) { - for(y=0;ynrid;y++) { - if(lm76data->fd[y] > 0) { - close(lm76data->fd[y]); - } - } - FREE(lm76data->fd); - } - FREE(lm76data); - threads--; - - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "lm75: no gpio-platform configured"); - exit(EXIT_FAILURE); - } - if(wiringXSetup(platform, logprintf1) == 0) { - loop = 1; - - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(lm76, json); - return threads_register("lm76", &thread, (void *)node, 0); - } else { - return NULL; - } -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(lm76); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(lm76); -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void lm76Init(void) { -#if !defined(__FreeBSD__) && !defined(_WIN32) - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); -#endif - - protocol_register(&lm76); - protocol_set_id(lm76, "lm76"); - protocol_device_add(lm76, "lm76", "TI I2C Temperature Sensor"); - lm76->devtype = WEATHER; - lm76->hwtype = SENSOR; - - options_add(&lm76->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[0-9]{1,3}$"); - options_add(&lm76->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "0x[0-9a-f]{2}"); - options_add(&lm76->options, 'd', "i2c-path", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^/dev/i2c-[0-9]{1,2}$"); - - // options_add(&lm76->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&lm76->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)3, "[0-9]"); - options_add(&lm76->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - -#if !defined(__FreeBSD__) && !defined(_WIN32) - lm76->initDev=&initDev; - lm76->threadGC=&threadGC; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "lm76"; - module->version = "2.1"; - module->reqversion = "7.0"; - module->reqcommit = "186"; -} - -void init(void) { - lm76Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm76.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm76.h deleted file mode 100644 index 7b96394..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/lm76.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_LM76_H_ -#define _PROTOCOL_LM76_H_ - -#include "../protocol.h" - -struct protocol_t *lm76; -void lm76Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/protocol_header.h.in deleted file mode 100644 index da97564..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/protocol_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/protocol_init.h.in deleted file mode 100644 index 40bdc9d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/protocol_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/relay.c b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/relay.c deleted file mode 100644 index 541b27c..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/relay.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#endif - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../core/gc.h" -#include "../../config/settings.h" -#include "../protocol.h" -#include "relay.h" - -#include "defines.h" - -static char *state = NULL; -#if !defined(__FreeBSD__) && !defined(_WIN32) - -static void createMessage(int gpio, int state) { - relay->message = json_mkobject(); - json_append_member(relay->message, "gpio", json_mknumber(gpio, 0)); - if(state == 1) - json_append_member(relay->message, "state", json_mkstring("on")); - else - json_append_member(relay->message, "state", json_mkstring("off")); -} - -static int createCode(JsonNode *code) { - int free_def = 0; - int gpio = -1; - int state = -1; - double itmp = -1; - char *def = NULL; - int have_error = 0; - - relay->rawlen = 0; - if(json_find_string(code, "default-state", &def) != 0) { - if((def = MALLOC(4)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(def, "off"); - free_def = 1; - } - - if(json_find_number(code, "gpio", &itmp) == 0) - gpio = (int)round(itmp); - if(json_find_number(code, "off", &itmp) == 0) - state=0; - else if(json_find_number(code, "on", &itmp) == 0) - state=1; - - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0) { - logprintf(LOG_ERR, "relay: no gpio-platform configured"); - have_error = 1; - goto clear; - } else if(strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "relay: no gpio-platform configured"); - have_error = 1; - goto clear; - } - - if(gpio == -1 || state == -1) { - logprintf(LOG_ERR, "relay: insufficient number of arguments"); - have_error = 1; - goto clear; - } else if(wiringXSetup(platform, logprintf1) < 0) { - logprintf(LOG_ERR, "unable to setup wiringX") ; - have_error = 1; - goto clear; - } else { - if(wiringXValidGPIO(gpio) != 0) { - logprintf(LOG_ERR, "relay: invalid gpio range"); - have_error = 1; - goto clear; - } else { - if(strstr(progname, "daemon") != NULL) { - pinMode(gpio, PINMODE_OUTPUT); - if(strcmp(def, "off") == 0) { - if(state == 1) { - digitalWrite(gpio, LOW); - } else if(state == 0) { - digitalWrite(gpio, HIGH); - } - } else { - if(state == 0) { - digitalWrite(gpio, LOW); - } else if(state == 1) { - digitalWrite(gpio, HIGH); - } - } - } else { - wiringXGC(); - } - createMessage(gpio, state); - goto clear; - } - } - -clear: - if(free_def == 1) { - FREE(def); - } - if(have_error) { - return EXIT_FAILURE; - } else { - return EXIT_SUCCESS; - } -} - -static void printHelp(void) { - printf("\t -t --on\t\t\tturn the relay on\n"); - printf("\t -f --off\t\t\tturn the relay off\n"); - printf("\t -g --gpio=gpio\t\t\tthe gpio the relay is connected to\n"); -} - -static int checkValues(JsonNode *code) { - char *def = NULL; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - int free_def = 0; - double itmp = -1; - - if(json_find_string(code, "default-state", &def) != 0) { - if((def = MALLOC(4)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(def, "off"); - free_def = 1; - } - if(strcmp(def, "on") != 0 && strcmp(def, "off") != 0) { - if(free_def == 1) { - FREE(def); - } - return 1; - } - - /* Get current relay state and validate GPIO number */ - if((jid = json_find_member(code, "id")) != NULL) { - if((jchild = json_find_element(jid, 0)) != NULL) { - if(json_find_number(jchild, "gpio", &itmp) == 0) { - int gpio = (int)itmp; - int state = -1; - char *platform = GPIO_PLATFORM; - if(settings_find_string("gpio-platform", &platform) != 0 || strcmp(platform, "none") == 0) { - logprintf(LOG_ERR, "relay: no gpio-platform configured"); - return -1; - } else if(wiringXSetup(platform, logprintf1) < 0) { - logprintf(LOG_ERR, "unable to setup wiringX") ; - return -1; - } else if(wiringXValidGPIO(gpio) != 0) { - logprintf(LOG_ERR, "relay: invalid gpio range"); - return -1; - } else { - pinMode(gpio, PINMODE_INPUT); - state = digitalRead(gpio); - if(strcmp(def, "on") == 0) { - state ^= 1; - } - - relay->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "gpio", json_mknumber(gpio, 0)); - if(state == 1) { - json_append_member(code, "state", json_mkstring("on")); - } else { - json_append_member(code, "state", json_mkstring("off")); - } - - json_append_member(relay->message, "message", code); - json_append_member(relay->message, "origin", json_mkstring("sender")); - json_append_member(relay->message, "protocol", json_mkstring(relay->id)); - if(pilight.broadcast != NULL) { - pilight.broadcast(relay->id, relay->message, PROTOCOL); - } - json_delete(relay->message); - relay->message = NULL; - } - } - } - } - - if(free_def == 1) { - FREE(def); - } - return 0; -} - -static void gc(void) { - FREE(state); -} -#endif - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void relayInit(void) { - - protocol_register(&relay); - protocol_set_id(relay, "relay"); - protocol_device_add(relay, "relay", "GPIO Connected Relays"); - relay->devtype = RELAY; - relay->hwtype = HWRELAY; - relay->multipleId = 0; - - options_add(&relay->options, 't', "on", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&relay->options, 'f', "off", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&relay->options, 'g', "gpio", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "[0-9]"); - - state = MALLOC(4); - strcpy(state, "off"); - options_add(&relay->options, 0, "default-state", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_STRING, (void *)state, NULL); - options_add(&relay->options, 0, "readonly", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - options_add(&relay->options, 0, "confirm", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - -#if !defined(__FreeBSD__) && !defined(_WIN32) - relay->checkValues=&checkValues; - relay->createCode=&createCode; - relay->printHelp=&printHelp; - relay->gc=&gc; -#endif -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "relay"; - module->version = "3.4"; - module->reqversion = "7.0"; - module->reqcommit = "186"; -} - -void init(void) { - relayInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/relay.h b/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/relay.h deleted file mode 100644 index 1685e1a..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/GPIO/relay.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_RELAY_H_ -#define _PROTOCOL_RELAY_H_ - -#include "../protocol.h" - -struct protocol_t *relay; -void relayInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/core/CMakeInclude.txt deleted file mode 100644 index 496cba9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE protocol_result - OUTPUT_VARIABLE protocol_init) - -set(inits) -foreach(init ${protocol_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/core/CMakeLists.txt deleted file mode 100644 index d92a1f5..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -project(pilight_protocols_core) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeInclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v2.c b/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v2.c deleted file mode 100644 index e28c8c5..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v2.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "pilight_firmware_v2.h" - -#define PULSE_MULTIPLIER 4 -#define MIN_PULSE_LENGTH 175 -#define MAX_PULSE_LENGTH 225 -#define AVG_PULSE_LENGTH 183 -#define RAW_LENGTH 196 - -static int validate(void) { - if(pilight_firmware_v2->rawlen == RAW_LENGTH) { - if(pilight_firmware_v2->raw[pilight_firmware_v2->rawlen-1] >= (MIN_PULSE_LENGTH*PULSE_DIV) && - pilight_firmware_v2->raw[pilight_firmware_v2->rawlen-1] <= (MAX_PULSE_LENGTH*PULSE_DIV) && - pilight_firmware_v2->raw[1] > AVG_PULSE_LENGTH*PULSE_MULTIPLIER) { - return 0; - } - } - - return -1; -} - -static void createMessage(int version, int high, int low) { - pilight_firmware_v2->message = json_mkobject(); - json_append_member(pilight_firmware_v2->message, "version", json_mknumber(version, 2)); - json_append_member(pilight_firmware_v2->message, "lpf", json_mknumber(high*10, 0)); - json_append_member(pilight_firmware_v2->message, "hpf", json_mknumber(low*10, 0)); -} - -static void parseCode(void) { - int i = 0, x = 0, binary[RAW_LENGTH/4]; - - for(i=0;irawlen;i+=4) { - if(pilight_firmware_v2->raw[i+3] < 100) { - pilight_firmware_v2->raw[i+3]*=10; - } - if(pilight_firmware_v2->raw[i+3] > AVG_PULSE_LENGTH*(PULSE_MULTIPLIER/2)) { - binary[x++] = 1; - } else { - binary[x++] = 0; - } - } - - int version = binToDec(binary, 0, 15); - int high = binToDec(binary, 16, 31); - int low = binToDec(binary, 32, 47); - createMessage(version, high, low); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void pilightFirmwareV2Init(void) { - - protocol_register(&pilight_firmware_v2); - protocol_set_id(pilight_firmware_v2, "pilight_firmware"); - protocol_device_add(pilight_firmware_v2, "pilight_firmware", "pilight filter firmware"); - pilight_firmware_v2->devtype = FIRMWARE; - pilight_firmware_v2->hwtype = HWINTERNAL; - pilight_firmware_v2->minrawlen = RAW_LENGTH; - pilight_firmware_v2->maxrawlen = RAW_LENGTH; - pilight_firmware_v2->maxgaplen = MAX_PULSE_LENGTH*PULSE_DIV; - pilight_firmware_v2->mingaplen = MIN_PULSE_LENGTH*PULSE_DIV; - - options_add(&pilight_firmware_v2->options, 'v', "version", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^[0-9]+$"); - options_add(&pilight_firmware_v2->options, 'l', "lpf", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^[0-9]+$"); - options_add(&pilight_firmware_v2->options, 'h', "hpf", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^[0-9]+$"); - - pilight_firmware_v2->parseCode=&parseCode; - pilight_firmware_v2->validate=&validate; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "pilight_firmware"; - module->version = "2.0"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - pilightFirmwareV2Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v2.h b/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v2.h deleted file mode 100644 index 28f5773..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v2.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_PILIGHT_FIRMWARE_V2_H_ -#define _PROTOCOL_PILIGHT_FIRMWARE_V2_H_ - -struct protocol_t *pilight_firmware_v2; -void pilightFirmwareV2Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v3.c b/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v3.c deleted file mode 100644 index 53e1a43..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v3.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "pilight_firmware_v3.h" - -#define PULSE_MULTIPLIER 4 -#define MIN_PULSE_LENGTH 205 -#define MAX_PULSE_LENGTH 245 -#define AVG_PULSE_LENGTH 225 -#define RAW_LENGTH 212 - -static int validate(void) { - if(pilight_firmware_v3->rawlen == RAW_LENGTH) { - if(pilight_firmware_v3->raw[pilight_firmware_v3->rawlen-1] >= (MIN_PULSE_LENGTH*PULSE_DIV) && - pilight_firmware_v3->raw[pilight_firmware_v3->rawlen-1] <= (MAX_PULSE_LENGTH*PULSE_DIV) && - pilight_firmware_v3->raw[1] > AVG_PULSE_LENGTH*PULSE_MULTIPLIER) { - return 0; - } - } - - return -1; -} - -static void createMessage(int version, int high, int low) { - pilight_firmware_v3->message = json_mkobject(); - json_append_member(pilight_firmware_v3->message, "version", json_mknumber(version, 2)); - json_append_member(pilight_firmware_v3->message, "lpf", json_mknumber(high*10, 0)); - json_append_member(pilight_firmware_v3->message, "hpf", json_mknumber(low*10, 0)); -} - -static void parseCode(void) { - int i = 0, x = 0, binary[RAW_LENGTH/4]; - - for(i=0;irawlen;i+=4) { - if(pilight_firmware_v3->raw[i+3] < 100) { - pilight_firmware_v3->raw[i+3]*=10; - } - if(pilight_firmware_v3->raw[i+3] > AVG_PULSE_LENGTH*(PULSE_MULTIPLIER/2)) { - binary[x++] = 1; - } else { - binary[x++] = 0; - } - } - - int version = binToDec(binary, 0, 15); - int high = binToDec(binary, 16, 31); - int low = binToDec(binary, 32, 47); - int chk = binToDec(binary, 48, 51); - int lpf = low; - int hpf = high; - int ver = version; - - while(hpf > 10) { - hpf /= 10; - } - while(lpf > 10) { - lpf /= 10; - } - while(ver > 10) { - ver /= 10; - } - - if((((ver&0xf)+(lpf&0xf)+(hpf&0xf))&0xf) == chk) { - createMessage(version, high, low); - } -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void pilightFirmwareV3Init(void) { - - protocol_register(&pilight_firmware_v3); - protocol_set_id(pilight_firmware_v3, "pilight_firmware"); - protocol_device_add(pilight_firmware_v3, "pilight_firmware", "pilight filter firmware"); - pilight_firmware_v3->devtype = FIRMWARE; - pilight_firmware_v3->hwtype = HWINTERNAL; - pilight_firmware_v3->minrawlen = RAW_LENGTH; - pilight_firmware_v3->maxrawlen = RAW_LENGTH; - pilight_firmware_v3->maxgaplen = MAX_PULSE_LENGTH*PULSE_DIV; - pilight_firmware_v3->mingaplen = MIN_PULSE_LENGTH*PULSE_DIV; - - options_add(&pilight_firmware_v3->options, 'v', "version", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^[0-9]+$"); - options_add(&pilight_firmware_v3->options, 'l', "lpf", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^[0-9]+$"); - options_add(&pilight_firmware_v3->options, 'h', "hpf", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^[0-9]+$"); - - pilight_firmware_v3->parseCode=&parseCode; - pilight_firmware_v3->validate=&validate; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "pilight_firmware"; - module->version = "2.0"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - pilightFirmwareV3Init(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v3.h b/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v3.h deleted file mode 100644 index 646da97..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/pilight_firmware_v3.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_PILIGHT_FIRMWARE_V3_H_ -#define _PROTOCOL_PILIGHT_FIRMWARE_V3_H_ - -#include "../protocol.h" - -struct protocol_t *pilight_firmware_v3; -void pilightFirmwareV3Init(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/core/protocol_header.h.in deleted file mode 100644 index da97564..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/protocol_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/core/protocol_init.h.in deleted file mode 100644 index 40bdc9d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/protocol_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/raw.c b/lib/ESPiLight/pilight/libs/pilight/protocols/core/raw.c deleted file mode 100644 index 0320fa3..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/raw.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "raw.h" - -static int createCode(JsonNode *code) { - char *rcode = NULL; - double repeats = 10; - char **array = NULL; - unsigned int i = 0, n = 0; - - if(json_find_string(code, "code", &rcode) != 0) { - logprintf(LOG_ERR, "raw: insufficient number of arguments"); - return EXIT_FAILURE; - } - - json_find_number(code, "repeats", &repeats); - - n = explode(rcode, " ", &array); - for(i=0;iraw[i]=atoi(array[i]); - } - array_free(&array, n); - - raw->rawlen=(int)i; - raw->txrpt = repeats; - - return EXIT_SUCCESS; -} - -static void printHelp(void) { - printf("\t -c --code=\"raw\"\t\traw code devided by spaces\n\t\t\t\t\t(just like the output of debug)\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void rawInit(void) { - - protocol_register(&raw); - protocol_set_id(raw, "raw"); - protocol_device_add(raw, "raw", "Raw Codes"); - raw->devtype = RAW; - raw->hwtype = RF433; - raw->config = 0; - - options_add(&raw->options, 'c', "code", OPTION_HAS_VALUE, 0, JSON_STRING, NULL, NULL); - options_add(&raw->options, 'r', "repeats", OPTION_OPT_VALUE, 0, JSON_NUMBER, NULL, NULL); - - raw->createCode=&createCode; - raw->printHelp=&printHelp; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "raw"; - module->version = "1.5"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - rawInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/core/raw.h b/lib/ESPiLight/pilight/libs/pilight/protocols/core/raw.h deleted file mode 100644 index 3a0a254..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/core/raw.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_RAW_H_ -#define _PROTOCOL_RAW_H_ - -#include "../protocol.h" - -struct protocol_t *raw; -void rawInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeExclude.txt deleted file mode 100644 index c0a2177..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeExclude.txt +++ /dev/null @@ -1,26 +0,0 @@ -include(../../../../CMakeConfig.txt) - -if(${PROTOCOL_GENERIC_DIMMER} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/generic_dimmer.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/generic_dimmer.h") -endif() - -if(${PROTOCOL_GENERIC_SWITCH} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/generic_switch.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/generic_switch.h") -endif() - -if(${PROTOCOL_GENERIC_SCREEN} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/generic_screen.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/generic_screen.h") -endif() - -if(${PROTOCOL_GENERIC_WEATHER} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/generic_weather.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/generic_weather.h") -endif() - -if(${PROTOCOL_GENERIC_WEBCAM} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/generic_webcam.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/generic_webcam.h") -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeInclude.txt deleted file mode 100644 index 496cba9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE protocol_result - OUTPUT_VARIABLE protocol_init) - -set(inits) -foreach(init ${protocol_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeLists.txt deleted file mode 100644 index f0de2d3..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(pilight_protocols_generic) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeExclude.txt) -include(CMakeInclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_dimmer.c b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_dimmer.c deleted file mode 100644 index 465ceb8..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_dimmer.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright (C) 2013 - 2016 CurlyMo - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "generic_dimmer.h" - -static void createMessage(int id, int state, int dimlevel) { - generic_dimmer->message = json_mkobject(); - json_append_member(generic_dimmer->message, "id", json_mknumber(id, 0)); - if(dimlevel >= 0) { - state = 1; - json_append_member(generic_dimmer->message, "dimlevel", json_mknumber(dimlevel, 0)); - } - if(state == 1) { - json_append_member(generic_dimmer->message, "state", json_mkstring("on")); - } else { - json_append_member(generic_dimmer->message, "state", json_mkstring("off")); - } -} - -/* -static int checkValues(struct JsonNode *code) { - int dimlevel = -1; - int max = 15; - int min = 0; - double itmp = -1; - - if(json_find_number(code, "dimlevel-maximum", &itmp) == 0) - max = (int)round(itmp); - if(json_find_number(code, "dimlevel-minimum", &itmp) == 0) - min = (int)round(itmp); - if(json_find_number(code, "dimlevel", &itmp) == 0) - dimlevel = (int)round(itmp); - - if(min > max) { - return 1; - } - - if(dimlevel != -1) { - if(dimlevel < min || dimlevel > max) { - return 1; - } else { - return 0; - } - } - return 0; -} -*/ - -static int createCode(struct JsonNode *code) { - int id = -1; - int state = -1; - int dimlevel = -1; - /* - int max = -1; - int min = -1; - */ - double itmp = -1; - - /* - if(json_find_number(code, "dimlevel-maximum", &itmp) == 0) - max = (int)round(itmp); - if(json_find_number(code, "dimlevel-minimum", &itmp) == 0) - min = (int)round(itmp); - */ - - if(json_find_number(code, "id", &itmp) == 0) - id = (int)round(itmp); - if(json_find_number(code, "dimlevel", &itmp) == 0) - dimlevel = (int)round(itmp); - if(json_find_number(code, "off", &itmp) == 0) - state=0; - else if(json_find_number(code, "on", &itmp) == 0) - state=1; - - if(id == -1 || (dimlevel == -1 && state == -1)) { - logprintf(LOG_ERR, "generic_dimmer: insufficient number of arguments"); - return EXIT_FAILURE; - /* - } else if(dimlevel != -1 && ((max != -1 && dimlevel > max) || (min != -1 && dimlevel < min))) { - logprintf(LOG_ERR, "generic_dimmer: invalid dimlevel range"); - return EXIT_FAILURE; - */ - } else if(dimlevel >= 0 && state == 0) { - logprintf(LOG_ERR, "generic_dimmer: dimlevel and state cannot be combined"); - return EXIT_FAILURE; - } else { - if(dimlevel >= 0) { - state = -1; - } - createMessage(id, state, dimlevel); - } - return EXIT_SUCCESS; - -} - -static void printHelp(void) { - printf("\t -t --on\t\t\tsend an on signal\n"); - printf("\t -f --off\t\t\tsend an off signal\n"); - printf("\t -i --id=id\t\t\tcontrol a device with this id\n"); - printf("\t -d --dimlevel=dimlevel\t\tsend a specific dimlevel\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void genericDimmerInit(void) { - - protocol_register(&generic_dimmer); - protocol_set_id(generic_dimmer, "generic_dimmer"); - protocol_device_add(generic_dimmer, "generic_dimmer", "Generic Dimmers"); - generic_dimmer->devtype = DIMMER; - - options_add(&generic_dimmer->options, 'd', "dimlevel", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^([0-9]{1,})$"); - options_add(&generic_dimmer->options, 't', "on", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&generic_dimmer->options, 'f', "off", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&generic_dimmer->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^([0-9]{1,})$"); - - options_add(&generic_dimmer->options, 0, "dimlevel-minimum", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^([0-9]{1}|[1][0-5])$"); - options_add(&generic_dimmer->options, 0, "dimlevel-maximum", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)15, "^([0-9]{1}|[1][0-5])$"); - - options_add(&generic_dimmer->options, 0, "readonly", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - options_add(&generic_dimmer->options, 0, "confirm", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - - generic_dimmer->printHelp=&printHelp; - generic_dimmer->createCode=&createCode; - /* - generic_dimmer->checkValues=&checkValues; - */ -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "generic_dimmer"; - module->version = "2.0"; - module->reqversion = "7.0"; - module->reqcommit = "94"; -} - -void init(void) { - genericDimmerInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_dimmer.h b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_dimmer.h deleted file mode 100644 index 6901501..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_dimmer.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_GENERIC_DIMMER_H_ -#define _PROTOCOL_GENERIC_DIMMER_H_ - -#include "../protocol.h" - -struct protocol_t *generic_dimmer; -void genericDimmerInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_label.c b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_label.c deleted file mode 100644 index 8ae98e9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_label.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "generic_label.h" - -static void createMessage(int id, char *label, char *color) { - generic_label->message = json_mkobject(); - json_append_member(generic_label->message, "id", json_mknumber(id, 0)); - json_append_member(generic_label->message, "label", json_mkstring(label)); - json_append_member(generic_label->message, "color", json_mkstring(color)); -} - -static int createCode(JsonNode *code) { - int id = -1, free_label = 0; - char *label = NULL; - char *color = "black"; - double itmp = 0; - - if(json_find_number(code, "id", &itmp) == 0) - id = (int)round(itmp); - - json_find_string(code, "label", &label); - if(json_find_number(code, "label", &itmp) == 0) { - if((label = MALLOC(BUFFER_SIZE)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - free_label = 1; - snprintf(label, BUFFER_SIZE, "%d", (int)itmp); - } - json_find_string(code, "color", &color); - - if(id == -1 || label == NULL) { - logprintf(LOG_ERR, "generic_label: insufficient number of arguments"); - return EXIT_FAILURE; - } else { - createMessage(id, label, color); - } - if(free_label) { - FREE(label); - } - - return EXIT_SUCCESS; - -} - -static void printHelp(void) { - printf("\t -i --id=id\t\t\tcontrol a device with this id\n"); - printf("\t -l --label=label\t\tset this label\n"); - printf("\t -c --color=color\t\tset label color\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void genericLabelInit(void) { - - protocol_register(&generic_label); - protocol_set_id(generic_label, "generic_label"); - protocol_device_add(generic_label, "generic_label", "Generic Label"); - generic_label->devtype = LABEL; - - options_add(&generic_label->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^([0-9]{1,})$"); - options_add(&generic_label->options, 'l', "label", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING | JSON_NUMBER, NULL, NULL); - options_add(&generic_label->options, 'c', "color", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - - generic_label->printHelp=&printHelp; - generic_label->createCode=&createCode; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "generic_label"; - module->version = "1.2"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - genericLabelInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_label.h b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_label.h deleted file mode 100644 index 7de6f5b..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_label.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_GENERIC_LABEL_H_ -#define _PROTOCOL_GENERIC_LABEL_H_ - -#include "../protocol.h" - -struct protocol_t *generic_label; -void genericLabelInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_screen.c b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_screen.c deleted file mode 100644 index a089cd1..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_screen.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "generic_screen.h" - -static void createMessage(int id, int state) { - generic_screen->message = json_mkobject(); - json_append_member(generic_screen->message, "id", json_mknumber(id, 1)); - if(state == 1) { - json_append_member(generic_screen->message, "state", json_mkstring("up")); - } else { - json_append_member(generic_screen->message, "state", json_mkstring("down")); - } -} - -static int createCode(JsonNode *code) { - int id = -1; - int state = -1; - double itmp = 0; - - if(json_find_number(code, "id", &itmp) == 0) - id = (int)round(itmp); - if(json_find_number(code, "down", &itmp) == 0) - state=0; - else if(json_find_number(code, "up", &itmp) == 0) - state=1; - - if(id == -1 || state == -1) { - logprintf(LOG_ERR, "generic_screen: insufficient number of arguments"); - return EXIT_FAILURE; - } else { - createMessage(id, state); - } - - return EXIT_SUCCESS; -} - -static void printHelp(void) { - printf("\t -t --up\t\t\tsend an up signal\n"); - printf("\t -f --down\t\t\tsend an down signal\n"); - printf("\t -i --id=id\t\t\tcontrol a device with this id\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void genericScreenInit(void) { - - protocol_register(&generic_screen); - protocol_set_id(generic_screen, "generic_screen"); - protocol_device_add(generic_screen, "generic_screen", "Generic Screens"); - generic_screen->devtype = SCREEN; - - options_add(&generic_screen->options, 't', "up", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&generic_screen->options, 'f', "down", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&generic_screen->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^([0-9]{1,})$"); - - options_add(&generic_screen->options, 0, "readonly", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - options_add(&generic_screen->options, 0, "confirm", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - - generic_screen->printHelp=&printHelp; - generic_screen->createCode=&createCode; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "generic_screen"; - module->version = "1.3"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - genericScreenInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_screen.h b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_screen.h deleted file mode 100644 index 1cb309f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_screen.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_GENERIC_SCREEN_H_ -#define _PROTOCOL_GENERIC_SCREEN_H_ - -#include "../protocol.h" - -struct protocol_t *generic_screen; -void genericScreenInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_switch.c b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_switch.c deleted file mode 100644 index 02d0ac0..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_switch.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "generic_switch.h" - -static void createMessage(int id, int state) { - generic_switch->message = json_mkobject(); - json_append_member(generic_switch->message, "id", json_mknumber(id, 0)); - if(state == 1) { - json_append_member(generic_switch->message, "state", json_mkstring("on")); - } else { - json_append_member(generic_switch->message, "state", json_mkstring("off")); - } -} - -static int createCode(JsonNode *code) { - int id = -1; - int state = -1; - double itmp = 0; - - if(json_find_number(code, "id", &itmp) == 0) - id = (int)round(itmp); - if(json_find_number(code, "off", &itmp) == 0) - state=0; - else if(json_find_number(code, "on", &itmp) == 0) - state=1; - - if(id == -1 || state == -1) { - logprintf(LOG_ERR, "generic_switch: insufficient number of arguments"); - return EXIT_FAILURE; - } else { - createMessage(id, state); - } - - return EXIT_SUCCESS; - -} - -static void printHelp(void) { - printf("\t -t --on\t\t\tsend an on signal\n"); - printf("\t -f --off\t\t\tsend an off signal\n"); - printf("\t -i --id=id\t\t\tcontrol a device with this id\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void genericSwitchInit(void) { - - protocol_register(&generic_switch); - protocol_set_id(generic_switch, "generic_switch"); - protocol_device_add(generic_switch, "generic_switch", "Generic Switches"); - generic_switch->devtype = SWITCH; - - options_add(&generic_switch->options, 't', "on", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&generic_switch->options, 'f', "off", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&generic_switch->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^([0-9]{1,})$"); - - options_add(&generic_switch->options, 0, "readonly", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - options_add(&generic_switch->options, 0, "confirm", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "^[10]{1}$"); - - generic_switch->printHelp=&printHelp; - generic_switch->createCode=&createCode; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "generic_switch"; - module->version = "1.3"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - genericSwitchInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_switch.h b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_switch.h deleted file mode 100644 index d713f8e..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_switch.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_GENERIC_SWITCH_H_ -#define _PROTOCOL_GENERIC_SWITCH_H_ - -#include "../protocol.h" - -struct protocol_t *generic_switch; -void genericSwitchInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_weather.c b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_weather.c deleted file mode 100644 index 6e73122..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_weather.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "generic_weather.h" - -static void createMessage(int id, double temperature, double humidity, int battery) { - generic_weather->message = json_mkobject(); - json_append_member(generic_weather->message, "id", json_mknumber(id, 0)); - if(temperature > -998.0) { - json_append_member(generic_weather->message, "temperature", json_mknumber(temperature, 2)); - } - if(humidity > -1.0) { - json_append_member(generic_weather->message, "humidity", json_mknumber(humidity, 2)); - } - if(battery > -1) { - json_append_member(generic_weather->message, "battery", json_mknumber(battery, 0)); - } -} - -static int createCode(JsonNode *code) { - double itmp = 0; - int id = -999; - double temp = -999.0; - double humi = -1.0; - int batt = -1; - - if(json_find_number(code, "id", &itmp) == 0) - id = (int)round(itmp); - if(json_find_number(code, "temperature", &itmp) == 0) - temp = itmp; - if(json_find_number(code, "humidity", &itmp) == 0) - humi = itmp; - if(json_find_number(code, "battery", &itmp) == 0) - batt = (int)round(itmp); - - if(id == -999 && temp < -998.0 && humi < 0.0 && batt == -1) { - logprintf(LOG_ERR, "generic_weather: insufficient number of arguments"); - return EXIT_FAILURE; - } else { - createMessage(id, temp, humi, batt); - } - return EXIT_SUCCESS; -} - -static void printHelp(void) { - printf("\t -t --temperature=temperature\tset the temperature\n"); - printf("\t -h --humidity=humidity\t\tset the humidity\n"); - printf("\t -b --battery=battery\t\tset the battery level\n"); - printf("\t -i --id=id\t\t\tcontrol a device with this id\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void genericWeatherInit(void) { - - protocol_register(&generic_weather); - protocol_set_id(generic_weather, "generic_weather"); - protocol_device_add(generic_weather, "generic_weather", "Generic Weather Stations"); - generic_weather->devtype = WEATHER; - - options_add(&generic_weather->options, 'h', "humidity", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "[0-9]"); - options_add(&generic_weather->options, 't', "temperature", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "[0-9]"); - options_add(&generic_weather->options, 'b', "battery", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, "^[01]$"); - options_add(&generic_weather->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "[0-9]"); - - // options_add(&generic_weather->options, 0, "decimals", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&generic_weather->options, 0, "temperature-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&generic_weather->options, 0, "humidity-decimals", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)2, "[0-9]"); - options_add(&generic_weather->options, 0, "show-humidity", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&generic_weather->options, 0, "show-temperature", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&generic_weather->options, 0, "show-battery", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - - generic_weather->printHelp=&printHelp; - generic_weather->createCode=&createCode; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "generic_weather"; - module->version = "1.22"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - genericWeatherInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_weather.h b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_weather.h deleted file mode 100644 index ecfa872..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_weather.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_GENERIC_WEATHER_H_ -#define _PROTOCOL_GENERIC_WEATHER_H_ - -#include "../protocol.h" - -struct protocol_t *generic_weather; -void genericWeatherInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_webcam.c b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_webcam.c deleted file mode 100644 index 4770a60..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_webcam.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo & 1000io - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include - -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/binary.h" -#include "../../core/gc.h" -#include "generic_webcam.h" - -static int checkValues(JsonNode *code) { - int height = 300; - double itmp = -1; - - if(json_find_number(code, "gui-image-height", &itmp) == 0) - height = (int)round(itmp); - - if(height <= 0) { - logprintf(LOG_ERR, "Generic webcam gui-image-height cannot <= 0"); - return 1; - } - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void genericWebcamInit(void) { - - protocol_register(&generic_webcam); - protocol_set_id(generic_webcam, "generic_webcam"); - protocol_device_add(generic_webcam, "generic_webcam", "Generic webcam"); - generic_webcam->devtype = WEBCAM; - generic_webcam->multipleId = 0; - - options_add(&generic_webcam->options, 'u', "url", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&generic_webcam->options, 'i', "id", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, "^([0-9]{1,})$"); - - options_add(&generic_webcam->options, 0, "image-width", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)0, "[0-9]"); - options_add(&generic_webcam->options, 0, "image-height", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)300, "[0-9]"); - options_add(&generic_webcam->options, 0, "show-webcam", OPTION_HAS_VALUE, GUI_SETTING, JSON_NUMBER, (void *)1, "^[10]{1}$"); - options_add(&generic_webcam->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "^[10]{2}$"); - - generic_webcam->checkValues=checkValues; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "generic_webcam"; - module->version = "1.3"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - genericWebcamInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_webcam.h b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_webcam.h deleted file mode 100644 index 23b8e06..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/generic_webcam.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_GENERIC_WEBCAM_H_ -#define _PROTOCOL_GENERIC_WEBCAM_H_ - -#include "../protocol.h" - -struct protocol_t *generic_webcam; -void genericWebcamInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/protocol_header.h.in deleted file mode 100644 index da97564..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/protocol_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/generic/protocol_init.h.in deleted file mode 100644 index 40bdc9d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/generic/protocol_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeExclude.txt deleted file mode 100644 index 9d50cfc..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeExclude.txt +++ /dev/null @@ -1,11 +0,0 @@ -include(../../../../CMakeConfig.txt) - -if(${PROTOCOL_PING} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/ping.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/ping.h") -endif() - -if(${PROTOCOL_ARPING} MATCHES "OFF") - list(REMOVE_ITEM ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/arping.c") - list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/arping.h") -endif() diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeInclude.txt deleted file mode 100644 index 496cba9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE protocol_result - OUTPUT_VARIABLE protocol_init) - -set(inits) -foreach(init ${protocol_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeLists.txt deleted file mode 100644 index f32902d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(pilight_protocols_network) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeExclude.txt) -include(CMakeInclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/arping.c b/lib/ESPiLight/pilight/libs/pilight/protocols/network/arping.c deleted file mode 100644 index 5b368ed..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/arping.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #define WPCAP - #include - #include - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include -#endif -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/arp.h" -#include "../../core/network.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "arping.h" - -static unsigned short loop = 1; -static unsigned short threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -#define CONNECTED 1 -#define DISCONNECTED 0 -#define INTERVAL 5 - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - char *dstmac = NULL, srcmac[ETH_ALEN], *a = srcmac; - char *tmpip[INET_ADDRSTRLEN+1], dstip[INET_ADDRSTRLEN+1]; - char ip[INET_ADDRSTRLEN+1], *p = ip, **devs = NULL; - double itmp = 0.0; - int state = 0, nrloops = 0, interval = INTERVAL, i = 0, srcip[4], nrdevs = 0; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_string(jchild, "mac", &dstmac) == 0) { - break; - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - - memset(dstip, '\0', INET_ADDRSTRLEN+1); - memset(tmpip, '\0', INET_ADDRSTRLEN+1); - - for(i=0;imessage = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "mac", json_mkstring(dstmac)); - json_append_member(code, "ip", json_mkstring(ip)); - json_append_member(code, "state", json_mkstring("connected")); - - json_append_member(arping->message, "message", code); - json_append_member(arping->message, "origin", json_mkstring("receiver")); - json_append_member(arping->message, "protocol", json_mkstring(arping->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(arping->id, arping->message, PROTOCOL); - } - json_delete(arping->message); - arping->message = NULL; - } - } else if(state == CONNECTED) { - state = DISCONNECTED; - - arping->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "mac", json_mkstring(dstmac)); - json_append_member(code, "ip", json_mkstring("0.0.0.0")); - json_append_member(code, "state", json_mkstring("disconnected")); - - json_append_member(arping->message, "message", code); - json_append_member(arping->message, "origin", json_mkstring("receiver")); - json_append_member(arping->message, "protocol", json_mkstring(arping->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(arping->id, arping->message, PROTOCOL); - } - json_delete(arping->message); - arping->message = NULL; - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - array_free(&devs, nrdevs); - - threads--; - - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(arping, json); - return threads_register("arping", &thread, (void *)node, 0); -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(arping); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(arping); -} - -static int checkValues(JsonNode *code) { - double interval = INTERVAL; - - json_find_number(code, "poll-interval", &interval); - - if((int)round(interval) < INTERVAL) { - logprintf(LOG_ERR, "arping poll-interval cannot be lower than %d", INTERVAL); - return 1; - } - - return 0; -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void arpingInit(void) { - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); - - protocol_register(&arping); - protocol_set_id(arping, "arping"); - protocol_device_add(arping, "arping", "Ping network devices"); - arping->devtype = PING; - arping->hwtype = API; - arping->multipleId = 0; - arping->masterOnly = 1; - - options_add(&arping->options, 'c', "connected", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&arping->options, 'd', "disconnected", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&arping->options, 'm', "mac", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}$"); - options_add(&arping->options, 'i', "ip", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_STRING, NULL, "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); - - options_add(&arping->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "[0-9]"); - - arping->initDev=&initDev; - arping->threadGC=&threadGC; - arping->checkValues=&checkValues; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "arping"; - module->version = "2.2"; - module->reqversion = "6.0"; - module->reqcommit = "158"; -} - -void init(void) { - arpingInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/arping.h b/lib/ESPiLight/pilight/libs/pilight/protocols/network/arping.h deleted file mode 100644 index 0eb9228..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/arping.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_ARPING_H_ -#define _PROTOCOL_ARPING_H_ - -#include "../protocol.h" - -struct protocol_t *arping; -void arpingInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/ping.c b/lib/ESPiLight/pilight/libs/pilight/protocols/network/ping.c deleted file mode 100644 index b07acac..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/ping.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include - -#include "../../core/threads.h" -#include "../../core/pilight.h" -#include "../../core/ping.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../protocol.h" -#include "../../core/json.h" -#include "../../core/gc.h" -#include "ping.h" - -static unsigned short loop = 1; -static unsigned short threads = 0; - -static pthread_mutex_t lock; -static pthread_mutexattr_t attr; - -#define CONNECTED 1 -#define DISCONNECTED 0 - -static void *thread(void *param) { - struct protocol_threads_t *node = (struct protocol_threads_t *)param; - struct JsonNode *json = (struct JsonNode *)node->param; - struct JsonNode *jid = NULL; - struct JsonNode *jchild = NULL; - char *ip = NULL; - char *pstate = NULL; - double itmp = 0.0; - int state = 0, nrloops = 0, interval = 1; - - threads++; - - if((jid = json_find_member(json, "id"))) { - jchild = json_first_child(jid); - while(jchild) { - if(json_find_string(jchild, "ip", &ip) == 0) { - break; - } - jchild = jchild->next; - } - } - - if(json_find_number(json, "poll-interval", &itmp) == 0) - interval = (int)round(itmp); - - if(json_find_string(json, "state", &pstate) == 0) { - if(strcmp(pstate,"connected") == 0) state = CONNECTED; - if(strcmp(pstate,"disconnected") == 0) state = DISCONNECTED; - } - - while(loop) { - if(protocol_thread_wait(node, interval, &nrloops) == ETIMEDOUT) { - pthread_mutex_lock(&lock); - if(ping(ip) == 0) { - if(state == DISCONNECTED) { - state = CONNECTED; - pping->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "ip", json_mkstring(ip)); - json_append_member(code, "state", json_mkstring("connected")); - - json_append_member(pping->message, "message", code); - json_append_member(pping->message, "origin", json_mkstring("receiver")); - json_append_member(pping->message, "protocol", json_mkstring(pping->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(pping->id, pping->message, PROTOCOL); - } - json_delete(pping->message); - pping->message = NULL; - } - } else if(state == CONNECTED) { - state = DISCONNECTED; - - pping->message = json_mkobject(); - JsonNode *code = json_mkobject(); - json_append_member(code, "ip", json_mkstring(ip)); - json_append_member(code, "state", json_mkstring("disconnected")); - - json_append_member(pping->message, "message", code); - json_append_member(pping->message, "origin", json_mkstring("receiver")); - json_append_member(pping->message, "protocol", json_mkstring(pping->id)); - - if(pilight.broadcast != NULL) { - pilight.broadcast(pping->id, pping->message, PROTOCOL); - } - json_delete(pping->message); - pping->message = NULL; - } - pthread_mutex_unlock(&lock); - } - } - pthread_mutex_unlock(&lock); - - threads--; - return (void *)NULL; -} - -static struct threadqueue_t *initDev(JsonNode *jdevice) { - loop = 1; - char *output = json_stringify(jdevice, NULL); - JsonNode *json = json_decode(output); - json_free(output); - - struct protocol_threads_t *node = protocol_thread_init(pping, json); - return threads_register("ping", &thread, (void *)node, 0); -} - -static void threadGC(void) { - loop = 0; - protocol_thread_stop(pping); - while(threads > 0) { - usleep(10); - } - protocol_thread_free(pping); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void pingInit(void) { - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock, &attr); - - protocol_register(&pping); - protocol_set_id(pping, "ping"); - protocol_device_add(pping, "ping", "Ping network devices"); - pping->devtype = PING; - pping->hwtype = API; - pping->multipleId = 0; - pping->masterOnly = 1; - - options_add(&pping->options, 'c', "connected", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&pping->options, 'd', "disconnected", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&pping->options, 'i', "ip", OPTION_HAS_VALUE, DEVICES_ID, JSON_STRING, NULL, "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); - - options_add(&pping->options, 0, "poll-interval", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)10, "[0-9]"); - - pping->initDev=&initDev; - pping->threadGC=&threadGC; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "ping"; - module->version = "2.0"; - module->reqversion = "6.0"; - module->reqcommit = "84"; -} - -void init(void) { - pingInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/ping.h b/lib/ESPiLight/pilight/libs/pilight/protocols/network/ping.h deleted file mode 100644 index 7aa4058..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/ping.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_PING_H_ -#define _PROTOCOL_PING_H_ - -#include "../protocol.h" - -struct protocol_t *pping; -void pingInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/network/protocol_header.h.in deleted file mode 100644 index da97564..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/protocol_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/network/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/network/protocol_init.h.in deleted file mode 100644 index 40bdc9d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/network/protocol_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol.c b/lib/ESPiLight/pilight/libs/pilight/protocols/protocol.c deleted file mode 100644 index fdda325..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - Copyright (C) 2013 - 2014 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 - #ifdef __mips__ - #define __USE_UNIX98 - #endif -#endif -#include - -#include "../core/pilight.h" -#include "../core/common.h" -#include "../core/dso.h" -#include "../core/options.h" -#include "../core/log.h" - -#include "../config/settings.h" - -#include "protocol.h" -#include "protocol_header.h" - -struct protocols_t *protocols; - -#ifndef _WIN32 -void protocol_remove(char *name) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct protocols_t *currP, *prevP; - - prevP = NULL; - - for(currP = protocols; currP != NULL; prevP = currP, currP = currP->next) { - - if(strcmp(currP->listener->id, name) == 0) { - if(prevP == NULL) { - protocols = currP->next; - } else { - prevP->next = currP->next; - } - - struct protocol_devices_t *dtmp; - logprintf(LOG_DEBUG, "removed protocol %s", currP->listener->id); - if(currP->listener->threadGC) { - currP->listener->threadGC(); - logprintf(LOG_DEBUG, "stopped protocol threads"); - } - if(currP->listener->gc) { - currP->listener->gc(); - logprintf(LOG_DEBUG, "ran garbage collector"); - } - FREE(currP->listener->id); - options_delete(currP->listener->options); - if(currP->listener->devices) { - while(currP->listener->devices) { - dtmp = currP->listener->devices; - FREE(dtmp->id); - FREE(dtmp->desc); - currP->listener->devices = currP->listener->devices->next; - FREE(dtmp); - } - } - FREE(currP->listener->devices); - FREE(currP->listener); - FREE(currP); - - break; - } - } -} -#endif - -void protocol_init(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - #include "protocol_init.h" - -#ifndef _WIN32 - void *handle = NULL; - void (*init)(void); - void (*compatibility)(struct module_t *module); - char path[PATH_MAX]; - struct module_t module; - char pilight_version[strlen(PILIGHT_VERSION)+1]; - char pilight_commit[3]; - char *protocol_root = NULL; - int check1 = 0, check2 = 0, valid = 1, protocol_root_free = 0; - strcpy(pilight_version, PILIGHT_VERSION); - - struct dirent *file = NULL; - DIR *d = NULL; - struct stat s; - - memset(pilight_commit, '\0', 3); - - if(settings_find_string("protocol-root", &protocol_root) != 0) { - /* If no protocol root was set, use the default protocol root */ - if((protocol_root = MALLOC(strlen(PROTOCOL_ROOT)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(protocol_root, PROTOCOL_ROOT); - protocol_root_free = 1; - } - size_t len = strlen(protocol_root); - if(protocol_root[len-1] != '/') { - strcat(protocol_root, "/"); - } - - if((d = opendir(protocol_root))) { - while((file = readdir(d)) != NULL) { - memset(path, '\0', PATH_MAX); - sprintf(path, "%s%s", protocol_root, file->d_name); - if(stat(path, &s) == 0) { - /* Check if file */ - if(S_ISREG(s.st_mode)) { - if(strstr(file->d_name, ".so") != NULL) { - valid = 1; - if((handle = dso_load(path)) != NULL) { - - init = dso_function(handle, "init"); - compatibility = dso_function(handle, "compatibility"); - if(init != NULL && compatibility != NULL) { - compatibility(&module); - if(module.name != NULL && module.version != NULL && module.reqversion != NULL) { - char ver[strlen(module.reqversion)+1]; - strcpy(ver, module.reqversion); - - if((check1 = vercmp(ver, pilight_version)) > 0) { - valid = 0; - } - - if(check1 == 0 && module.reqcommit != NULL) { - char com[strlen(module.reqcommit)+1]; - strcpy(com, module.reqcommit); - sscanf(HASH, "v%*[0-9].%*[0-9]-%[0-9]-%*[0-9a-zA-Z\n\r]", pilight_commit); - - if(strlen(pilight_commit) > 0 && (check2 = vercmp(com, pilight_commit)) > 0) { - valid = 0; - } - } - if(valid == 1) { - char tmp[strlen(module.name)+1]; - strcpy(tmp, module.name); - protocol_remove(tmp); - init(); - logprintf(LOG_DEBUG, "loaded protocol %s v%s", file->d_name, module.version); - } else { - if(module.reqcommit != NULL) { - logprintf(LOG_ERR, "protocol %s requires at least pilight v%s (commit %s)", file->d_name, module.reqversion, module.reqcommit); - } else { - logprintf(LOG_ERR, "protocol %s requires at least pilight v%s", file->d_name, module.reqversion); - } - } - } else { - logprintf(LOG_ERR, "invalid module %s", file->d_name); - } - } - } - } - } - } else { - perror("stat"); - } - } - closedir(d); - } - if(protocol_root_free) { - FREE(protocol_root); - } -#endif -} - -void protocol_register(protocol_t **proto) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if((*proto = MALLOC(sizeof(struct protocol_t))) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - (*proto)->options = NULL; - (*proto)->devices = NULL; - - (*proto)->rawlen = 0; - (*proto)->minrawlen = 0; - (*proto)->maxrawlen = 0; - (*proto)->mingaplen = 0; - (*proto)->maxgaplen = 0; - (*proto)->txrpt = 10; - (*proto)->rxrpt = 1; - (*proto)->hwtype = NONE; - (*proto)->multipleId = 1; - (*proto)->config = 1; - (*proto)->masterOnly = 0; - (*proto)->parseCode = NULL; - (*proto)->parseCommand = NULL; - (*proto)->createCode = NULL; - (*proto)->checkValues = NULL; - (*proto)->initDev = NULL; - (*proto)->printHelp = NULL; - (*proto)->threadGC = NULL; - (*proto)->gc = NULL; - (*proto)->message = NULL; - (*proto)->threads = NULL; - - (*proto)->repeats = 0; - (*proto)->first = 0; - (*proto)->second = 0; - - (*proto)->raw = NULL; - - struct protocols_t *pnode = MALLOC(sizeof(struct protocols_t)); - if(pnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - pnode->listener = *proto; - pnode->next = protocols; - protocols = pnode; -} - -struct protocol_threads_t *protocol_thread_init(protocol_t *proto, struct JsonNode *param) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct protocol_threads_t *node = MALLOC(sizeof(struct protocol_threads_t)); - if(node == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - - node->param = param; - pthread_mutexattr_init(&node->attr); - pthread_mutexattr_settype(&node->attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&node->mutex, &node->attr); - pthread_cond_init(&node->cond, NULL); - node->next = proto->threads; - proto->threads = node; - - return node; -} - -int protocol_thread_wait(struct protocol_threads_t *node, int interval, int *nrloops) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct timeval tp; - struct timespec ts; - - pthread_mutex_unlock(&node->mutex); - - gettimeofday(&tp, NULL); - ts.tv_sec = tp.tv_sec; - ts.tv_nsec = tp.tv_usec * 1000; - - if(*nrloops == 0) { - ts.tv_sec += 1; - *nrloops = 1; - } else { - ts.tv_sec += interval; - } - - pthread_mutex_lock(&node->mutex); - - return pthread_cond_timedwait(&node->cond, &node->mutex, &ts); -} - -void protocol_thread_stop(protocol_t *proto) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(proto != NULL && proto->threads != NULL ) { - struct protocol_threads_t *tmp = proto->threads; - while(tmp) { - pthread_mutex_unlock(&tmp->mutex); - pthread_cond_signal(&tmp->cond); - tmp = tmp->next; - } - } -} - -void protocol_thread_free(protocol_t *proto) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if(proto != NULL && proto->threads != NULL) { - struct protocol_threads_t *tmp; - while(proto->threads) { - tmp = proto->threads; - if(proto->threads->param != NULL) { - json_delete(proto->threads->param); - } - proto->threads = proto->threads->next; - FREE(tmp); - } - if(proto->threads != NULL) { - FREE(proto->threads); - } - } -} - -void protocol_set_id(protocol_t *proto, const char *id) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - if((proto->id = MALLOC(strlen(id)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(proto->id, id); -} - -void protocol_device_add(protocol_t *proto, const char *id, const char *desc) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct protocol_devices_t *dnode = MALLOC(sizeof(struct protocol_devices_t)); - if(dnode == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - if((dnode->id = MALLOC(strlen(id)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(dnode->id, id); - if((dnode->desc = MALLOC(strlen(desc)+1)) == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(dnode->desc, desc); - dnode->next = proto->devices; - proto->devices = dnode; -} - -int protocol_device_exists(protocol_t *proto, const char *id) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct protocol_devices_t *temp = proto->devices; - - while(temp) { - if(strcmp(temp->id, id) == 0) { - return 0; - } - temp = temp->next; - } - if(temp != NULL) { - FREE(temp); - } - - return 1; -} - -int protocol_gc(void) { - logprintf(LOG_STACK, "%s(...)", __FUNCTION__); - - struct protocols_t *ptmp; - struct protocol_devices_t *dtmp; - - while(protocols) { - ptmp = protocols; - logprintf(LOG_DEBUG, "protocol %s", ptmp->listener->id); - if(ptmp->listener->threadGC != NULL) { - ptmp->listener->threadGC(); - logprintf(LOG_DEBUG, "stopped protocol threads"); - } - if(ptmp->listener->gc) { - ptmp->listener->gc(); - logprintf(LOG_DEBUG, "ran garbage collector"); - } - FREE(ptmp->listener->id); - options_delete(ptmp->listener->options); - if(ptmp->listener->devices) { - while(ptmp->listener->devices) { - dtmp = ptmp->listener->devices; - FREE(dtmp->id); - FREE(dtmp->desc); - ptmp->listener->devices = ptmp->listener->devices->next; - if(dtmp != NULL) { - FREE(dtmp); - } - } - } - if(ptmp->listener->devices != NULL) { - FREE(ptmp->listener->devices); - } - FREE(ptmp->listener); - protocols = protocols->next; - FREE(ptmp); - } - if(protocols != NULL) { - FREE(protocols); - } - - logprintf(LOG_DEBUG, "garbage collected protocol library"); - return EXIT_SUCCESS; -} diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol.h b/lib/ESPiLight/pilight/libs/pilight/protocols/protocol.h deleted file mode 100644 index 511bffb..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright (C) 2013 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_H_ -#define _PROTOCOL_H_ - -#ifndef _WIN32 - #ifdef __mips__ - #ifndef __USE_UNIX98 - #define __USE_UNIX98 - #endif - #endif -#endif -#include - -#include "defines.h" -#include "../core/options.h" -#include "../core/threads.h" -#include "../core/json.h" - -#include "../config/devices.h" -#include "../config/hardware.h" - -typedef enum { - FIRMWARE = -2, - PROCESS = -1, - RAW = 0, - SWITCH, - DIMMER, - WEATHER, - RELAY, - SCREEN, - CONTACT, - PENDINGSW, - DATETIME, - XBMC, - LIRC, - WEBCAM, - MOTION, - DUSK, - PING, - LABEL, - ALARM -} devtype_t; - -typedef struct protocol_devices_t { - char *id; - char *desc; - struct protocol_devices_t *next; -} protocol_devices_t; - -typedef struct protocol_threads_t { - pthread_mutex_t mutex; - pthread_cond_t cond; - pthread_mutexattr_t attr; - JsonNode *param; - struct protocol_threads_t *next; -} protocol_threads_t; - -typedef struct protocol_t { - char *id; - int rawlen; - int minrawlen; - int maxrawlen; - int mingaplen; - int maxgaplen; - short txrpt; - short rxrpt; - short multipleId; - short config; - short masterOnly; - struct options_t *options; - struct JsonNode *message; - - int repeats; - unsigned long first; - unsigned long second; - - int *raw; - - hwtype_t hwtype; - devtype_t devtype; - struct protocol_devices_t *devices; - struct protocol_threads_t *threads; - - union { - void (*parseCode)(void); - void (*parseCommand)(struct JsonNode *code); - }; - int (*validate)(void); - int (*createCode)(JsonNode *code); - int (*checkValues)(JsonNode *code); - struct threadqueue_t *(*initDev)(JsonNode *device); - void (*printHelp)(void); - void (*gc)(void); - void (*threadGC)(void); -} protocol_t; - -typedef struct protocols_t { - struct protocol_t *listener; - char *name; - struct protocols_t *next; -} protocols_; - -extern struct protocols_t *protocols; - -void protocol_init(void); -struct protocol_threads_t *protocol_thread_init(protocol_t *proto, struct JsonNode *param); -int protocol_thread_wait(struct protocol_threads_t *node, int interval, int *nrloops); -void protocol_thread_free(protocol_t *proto); -void protocol_thread_stop(protocol_t *proto); -void protocol_set_id(protocol_t *proto, const char *id); -void protocol_plslen_add(protocol_t *proto, int plslen); -void protocol_register(protocol_t **proto); -void protocol_device_add(protocol_t *proto, const char *id, const char *desc); -int protocol_device_exists(protocol_t *proto, const char *id); -int protocol_gc(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/protocol_header.h.in deleted file mode 100644 index 3740f78..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol_header.h.in +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PROTOCOL_HEADERS -#define PROTOCOL_HEADERS - -@PROTOCOL_HEADERS@ - -#endif \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/protocol_init.h.in deleted file mode 100644 index 2c2fa69..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/protocol_init.h.in +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PROTOCOL_INIT -#define PROTOCOL_INIT - -@PROTOCOL_INIT@ - -#endif \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeExclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeExclude.txt deleted file mode 100644 index e69de29..0000000 diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeInclude.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeInclude.txt deleted file mode 100644 index 496cba9..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeInclude.txt +++ /dev/null @@ -1,30 +0,0 @@ -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_init.h") -list(REMOVE_ITEM ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/protocol_header.h") - -set(headers) -foreach(header ${${PROJECT_NAME}_headers}) - string(REPLACE "${PROJECT_SOURCE_DIR}/" " #include \"" header1 ${header}) - string(REPLACE ".h" ".h\"!" header2 ${header1}) - list(APPEND headers ${header2}) -endforeach(header) - -string(REPLACE "!" "\n" header4 ${headers}) -set(PROTOCOL_HEADERS ${header4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_header.h.in ${PROJECT_SOURCE_DIR}/protocol_header.h) - -execute_process( -COMMAND grep -h "void .*Init(void)" ${${PROJECT_NAME}_sources} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE protocol_result - OUTPUT_VARIABLE protocol_init) - -set(inits) -foreach(init ${protocol_init}) - string(REPLACE "void " " " init1 ${init}) - string(REPLACE "(void) {" "()!" init2 ${init1}) - list(APPEND inits ${init2}) -endforeach(init) - -string(REPLACE "!" ";" init4 ${inits}) -set(PROTOCOL_INIT ${init4}) -configure_file(${PROJECT_SOURCE_DIR}/protocol_init.h.in ${PROJECT_SOURCE_DIR}/protocol_init.h) diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeLists.txt b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeLists.txt deleted file mode 100644 index 9cc403f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(pilight_protocols_zwave) - -file(GLOB ${PROJECT_NAME}_sources "${PROJECT_SOURCE_DIR}/*.c") -file(GLOB ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/*.h") - -include(CMakeExclude.txt) -include(CMakeInclude.txt) - -set(${PROJECT_NAME}_files ${${PROJECT_NAME}_sources} ${${PROJECT_NAME}_headers} CACHE INTERNAL "") diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/protocol_header.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/protocol_header.h.in deleted file mode 100644 index da97564..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/protocol_header.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_HEADERS@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/protocol_init.h.in b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/protocol_init.h.in deleted file mode 100644 index 40bdc9d..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/protocol_init.h.in +++ /dev/null @@ -1 +0,0 @@ -@PROTOCOL_INIT@ \ No newline at end of file diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_ctrl.c b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_ctrl.c deleted file mode 100644 index 37a23ca..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_ctrl.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -# -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../hardware/zwave.h" -#include "../protocol.h" -#include "zwave_ctrl.h" - -static void createCommandMessage(int state) { - zwave_ctrl->message = json_mkobject(); - if(state == 1) { - json_append_member(zwave_ctrl->message, "command", json_mkstring("inclusion")); - } else if(state == 0) { - json_append_member(zwave_ctrl->message, "command", json_mkstring("exclusion")); - } else if(state == 2) { - json_append_member(zwave_ctrl->message, "command", json_mkstring("stop")); - } else if(state == 3) { - json_append_member(zwave_ctrl->message, "command", json_mkstring("soft-reset")); - } -} - -static void createParameterMessage(int nodeid, int parameter, int value) { - zwave_ctrl->message = json_mkobject(); - json_append_member(zwave_ctrl->message, "nodeid", json_mknumber(nodeid, 0)); - json_append_member(zwave_ctrl->message, "parameter", json_mknumber(parameter, 0)); - if(value >= 0) { - json_append_member(zwave_ctrl->message, "value", json_mknumber(value, 0)); - } -} - -static int createCode(struct JsonNode *code) { - printf("%s\n", json_stringify(code, "\t")); - int state = -1; - int parameter = -1; - int value = -1; - int nodeid = -1; - double itmp = 0.0; - - if(json_find_number(code, "inclusion", &itmp) == 0) - state=1; - else if(json_find_number(code, "exclusion", &itmp) == 0) - state=0; - else if(json_find_number(code, "stop", &itmp) == 0) - state=2; - else if(json_find_number(code, "soft-reset", &itmp) == 0) - state=3; - - if(json_find_number(code, "parameter", &itmp) == 0) - parameter = (int)itmp; - if(json_find_number(code, "nodeid", &itmp) == 0) - nodeid = (int)itmp; - if(json_find_number(code, "value", &itmp) == 0) - value = (int)itmp; - - if(parameter >= 0 && nodeid == -1) { - logprintf(LOG_ERR, "zwave_ctrl: parameter needs a nodeid"); - return EXIT_FAILURE; - } - if(nodeid >= 0 && parameter == -1) { - logprintf(LOG_ERR, "zwave_ctrl: nodeid needs a parameter"); - return EXIT_FAILURE; - } - if(value >= 0 && (parameter == -1 || nodeid == -1)) { - logprintf(LOG_ERR, "zwave_ctrl: value needs a parameter and nodeid"); - return EXIT_FAILURE; - } - if(state > -1 && (parameter > -1 || nodeid > -1)) { - logprintf(LOG_ERR, "zwave_ctrl: state and parameter and node cannot be combined"); - return EXIT_FAILURE; - } - - if(strstr(progname, "daemon") != NULL) { - if(parameter >= 0 && nodeid >= 0) { - if(value >= 0) { - int x = snprintf(NULL, 0, "%d", value); - zwaveSetConfigParam(nodeid, parameter, value, x); - } else { - zwaveGetConfigParam(nodeid, parameter); - } - } - if(state == 1) { - zwaveStartInclusion(); - } else if(state == 0) { - zwaveStartExclusion(); - } else if(state == 2) { - zwaveStopCommand(); - } else if(state == 3) { - zwaveSoftReset(); - } - } - if(parameter >= 0 && nodeid >= 0) { - createParameterMessage(nodeid, parameter, value); - } else if(state > 0) { - createCommandMessage(state); - } - - return EXIT_SUCCESS; -} - -static void printHelp(void) { - printf("\t -i --inclusion\t\t\tsend an inclusion command\n"); - printf("\t -e --exclusion\t\t\tsend an exclusion command\n"); - printf("\t -s --stop\t\t\tstop previous command\n"); - printf("\t -r --soft-reset\t\tsend a soft-reset command\n"); - printf("\t -c --parameter\t\tset or retrieve parameter\n"); - printf("\t -v --value=X\t\tset parameter to this value\n"); - printf("\t -n --nodeid=X\t\tset parameter to this value\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void zwaveCtrlInit(void) { - - protocol_register(&zwave_ctrl); - protocol_set_id(zwave_ctrl, "zwave_ctrl"); - protocol_device_add(zwave_ctrl, "zwave_ctrl", "Z-Wave Controller"); - zwave_ctrl->devtype = SWITCH; - zwave_ctrl->hwtype = ZWAVE; - zwave_ctrl->config = 0; - - options_add(&zwave_ctrl->options, 'i', "inclusion", OPTION_NO_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&zwave_ctrl->options, 'e', "exclusion", OPTION_NO_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&zwave_ctrl->options, 's', "stop", OPTION_NO_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&zwave_ctrl->options, 'r', "soft-reset", OPTION_NO_VALUE, DEVICES_VALUE, JSON_STRING, NULL, NULL); - options_add(&zwave_ctrl->options, 'c', "parameter", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&zwave_ctrl->options, 'v', "value", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - options_add(&zwave_ctrl->options, 'n', "nodeid", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - - zwave_ctrl->createCode=&createCode; - zwave_ctrl->printHelp=&printHelp; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "zwave_ctrl"; - module->version = "1.0"; - module->reqversion = "7.0"; - module->reqcommit = "10"; -} - -void init(void) { - zwaveCtrlInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_ctrl.h b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_ctrl.h deleted file mode 100644 index eb58721..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_ctrl.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_ZWAVE_CTRL_H_ -#define _PROTOCOL_ZWAVE_CTRL_H_ - -#include "../protocol.h" - -struct protocol_t *zwave_ctrl; -void zwaveCtrlInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_dimmer.c b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_dimmer.c deleted file mode 100644 index f2b4010..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_dimmer.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -# -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../hardware/zwave.h" -#include "../protocol.h" -#include "zwave_dimmer.h" - -static void createDimMessage(unsigned int homeId, int nodeId, int dimlevel) { - zwave_dimmer->message = json_mkobject(); - json_append_member(zwave_dimmer->message, "homeId", json_mknumber(homeId, 0)); - json_append_member(zwave_dimmer->message, "nodeId", json_mknumber(nodeId, 0)); - if(dimlevel > 0) { - json_append_member(zwave_dimmer->message, "state", json_mkstring("on")); - } else { - json_append_member(zwave_dimmer->message, "state", json_mkstring("off")); - } - json_append_member(zwave_dimmer->message, "dimlevel", json_mknumber(dimlevel, 0)); -} - -static void createConfigMessage(unsigned int homeId, int nodeId, char *label, int value) { - zwave_dimmer->message = json_mkobject(); - json_append_member(zwave_dimmer->message, "homeId", json_mknumber(homeId, 0)); - json_append_member(zwave_dimmer->message, "nodeId", json_mknumber(nodeId, 0)); - json_append_member(zwave_dimmer->message, "label", json_mkstring(label)); - json_append_member(zwave_dimmer->message, "value", json_mknumber(value, 0)); -} - -static void parseCommand(struct JsonNode *code) { - struct JsonNode *message = NULL; - char *label = NULL; - double itmp = 0.0; - int nodeId = 0, value = 0, cmdId = 0; - unsigned int homeId = 0; - - if((message = json_find_member(code, "message")) != NULL) { - if(json_find_number(message, "nodeId", &itmp) == 0) { - nodeId = (int)round(itmp); - } else { - return; - } - if(json_find_number(message, "homeId", &itmp) == 0) { - homeId = (unsigned int)round(itmp); - } else { - return; - } - if(json_find_number(message, "cmdId", &itmp) == 0) { - cmdId = (int)round(itmp); - } else { - return; - } - if(json_find_number(message, "value", &itmp) == 0) { - value = (int)round(itmp); - } else { - return; - } - json_find_string(message, "label", &label); - } - - if(cmdId == COMMAND_CLASS_SWITCH_MULTILEVEL) { - createDimMessage(homeId, nodeId, value); - } - if(cmdId == COMMAND_CLASS_CONFIGURATION && label != NULL) { - createConfigMessage(homeId, nodeId, label, value); - } -} - -static int createCode(struct JsonNode *code) { - char out[255]; - unsigned int homeId = 0; - int nodeId = 0; - int dimlevel = -1; - char state = 0; - double itmp = 0.0; - - if(json_find_number(code, "homeId", &itmp) == 0) - homeId = (unsigned int)round(itmp); - if(json_find_number(code, "nodeId", &itmp) == 0) - nodeId = (int)round(itmp); - if(json_find_number(code, "dimlevel", &itmp) == 0) - dimlevel = (int)round(itmp); - - if(json_find_number(code, "off", &itmp) == 0) - state=0; - else if(json_find_number(code, "on", &itmp) == 0) - state=1; - - if(dimlevel > -1) { - state = 1; - if(dimlevel > 100) { - dimlevel = 99; - } - } else if(state == 0) { - dimlevel = 0; - } else if(state == 1) { - dimlevel = 255; - } - - if(dimlevel > -1) { - snprintf(out, 255, "%d", dimlevel); - zwaveSetValue(nodeId, COMMAND_CLASS_SWITCH_MULTILEVEL, "Level", out); - createDimMessage(homeId, nodeId, dimlevel); - } - - return EXIT_SUCCESS; -} - -static void printHelp(void) { - printf("\t -t --on\t\t\tsend an on signal\n"); - printf("\t -f --off\t\t\tsend an off signal\n"); - printf("\t -h --homeid=id\t\t\tcontrol a device with this home id\n"); - printf("\t -i --unitid=id\t\t\tcontrol a device with this unit id\n"); - printf("\t -d --dimlevel=dimlevel\t\tsend a specific dimlevel\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void zwaveDimmerInit(void) { - - protocol_register(&zwave_dimmer); - protocol_set_id(zwave_dimmer, "zwave_dimmer"); - protocol_device_add(zwave_dimmer, "zwave_dimmer", "Z-Wave Dimmers"); - zwave_dimmer->devtype = DIMMER; - zwave_dimmer->hwtype = ZWAVE; - - options_add(&zwave_dimmer->options, 'h', "homeId", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&zwave_dimmer->options, 'i', "nodeId", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&zwave_dimmer->options, 't', "on", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&zwave_dimmer->options, 'f', "off", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&zwave_dimmer->options, 'd', "dimlevel", OPTION_HAS_VALUE, DEVICES_VALUE, JSON_NUMBER, NULL, NULL); - - options_add(&zwave_dimmer->options, 0, "dimlevel-minimum", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)0, NULL); - options_add(&zwave_dimmer->options, 0, "dimlevel-maximum", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_NUMBER, (void *)99, NULL); - - zwave_dimmer->createCode=&createCode; - zwave_dimmer->parseCommand=&parseCommand; - zwave_dimmer->printHelp=&printHelp; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "zwave_dimmer"; - module->version = "1.0"; - module->reqversion = "7.0"; - module->reqcommit = "10"; -} - -void init(void) { - zwaveDimmerInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_dimmer.h b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_dimmer.h deleted file mode 100644 index 455623f..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_dimmer.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_ZWAVE_DIMMER_H_ -#define _PROTOCOL_ZWAVE_DIMMER_H_ - -#include "../protocol.h" - -struct protocol_t *zwave_dimmer; -void zwaveDimmerInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_switch.c b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_switch.c deleted file mode 100644 index 726ddb0..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_switch.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#include -#include -#include -#include -# -#include "../../core/pilight.h" -#include "../../core/common.h" -#include "../../core/dso.h" -#include "../../core/log.h" -#include "../../hardware/zwave.h" -#include "../protocol.h" -#include "zwave_switch.h" - -static void createStateMessage(unsigned int homeId, int nodeId, int state) { - zwave_switch->message = json_mkobject(); - json_append_member(zwave_switch->message, "homeId", json_mknumber(homeId, 0)); - json_append_member(zwave_switch->message, "nodeId", json_mknumber(nodeId, 0)); - if(state == 1) { - json_append_member(zwave_switch->message, "state", json_mkstring("on")); - } else { - json_append_member(zwave_switch->message, "state", json_mkstring("off")); - } -} - -static void createConfigMessage(unsigned int homeId, int nodeId, char *label, int value) { - zwave_switch->message = json_mkobject(); - json_append_member(zwave_switch->message, "homeId", json_mknumber(homeId, 0)); - json_append_member(zwave_switch->message, "nodeId", json_mknumber(nodeId, 0)); - json_append_member(zwave_switch->message, "label", json_mkstring(label)); - json_append_member(zwave_switch->message, "value", json_mknumber(value, 0)); -} - -static void parseCommand(struct JsonNode *code) { - struct JsonNode *message = NULL; - char *label = NULL; - double itmp = 0.0; - int nodeId = 0, value = 0, cmdId = 0; - unsigned int homeId = 0; - - if((message = json_find_member(code, "message")) != NULL) { - if(json_find_number(message, "nodeId", &itmp) == 0) { - nodeId = (int)round(itmp); - } else { - return; - } - if(json_find_number(message, "homeId", &itmp) == 0) { - homeId = (unsigned int)round(itmp); - } else { - return; - } - if(json_find_number(message, "cmdId", &itmp) == 0) { - cmdId = (int)round(itmp); - } else { - return; - } - if(json_find_number(message, "value", &itmp) == 0) { - value = (int)round(itmp); - } else { - return; - } - json_find_string(message, "label", &label); - } - if(cmdId == COMMAND_CLASS_SWITCH_BINARY) { - createStateMessage(homeId, nodeId, value); - } - if(cmdId == COMMAND_CLASS_CONFIGURATION && label != NULL) { - createConfigMessage(homeId, nodeId, label, value); - } -} - -static int createCode(struct JsonNode *code) { - unsigned int homeId = 0; - int nodeId = 0; - char state = 0; - double itmp = 0.0; - - if(json_find_number(code, "homeId", &itmp) == 0) - homeId = (unsigned int)round(itmp); - if(json_find_number(code, "nodeId", &itmp) == 0) - nodeId = (int)round(itmp); - - if(json_find_number(code, "off", &itmp) == 0) - state=0; - else if(json_find_number(code, "on", &itmp) == 0) - state=1; - - if(state == 0) { - zwaveSetValue(nodeId, COMMAND_CLASS_SWITCH_BINARY, NULL, "false"); - } else { - zwaveSetValue(nodeId, COMMAND_CLASS_SWITCH_BINARY, NULL, "true"); - } - - createStateMessage(homeId, nodeId, state); - - return EXIT_SUCCESS; -} - -static void printHelp(void) { - printf("\t -t --on\t\t\tsend an on signal\n"); - printf("\t -f --off\t\t\tsend an off signal\n"); - printf("\t -h --homeid=id\t\t\tcontrol a device with this home id\n"); - printf("\t -i --unitid=id\t\t\tcontrol a device with this unit id\n"); -} - -#if !defined(MODULE) && !defined(_WIN32) -__attribute__((weak)) -#endif -void zwaveSwitchInit(void) { - - protocol_register(&zwave_switch); - protocol_set_id(zwave_switch, "zwave_switch"); - protocol_device_add(zwave_switch, "zwave_switch", "Z-Wave Switches"); - zwave_switch->devtype = SWITCH; - zwave_switch->hwtype = ZWAVE; - - options_add(&zwave_switch->options, 'h', "homeId", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&zwave_switch->options, 'i', "nodeId", OPTION_HAS_VALUE, DEVICES_ID, JSON_NUMBER, NULL, NULL); - options_add(&zwave_switch->options, 't', "on", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - options_add(&zwave_switch->options, 'f', "off", OPTION_NO_VALUE, DEVICES_STATE, JSON_STRING, NULL, NULL); - - zwave_switch->createCode=&createCode; - zwave_switch->parseCommand=&parseCommand; - zwave_switch->printHelp=&printHelp; -} - -#if defined(MODULE) && !defined(_WIN32) -void compatibility(struct module_t *module) { - module->name = "zwave_switch"; - module->version = "1.0"; - module->reqversion = "7.0"; - module->reqcommit = "10"; -} - -void init(void) { - zwaveSwitchInit(); -} -#endif diff --git a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_switch.h b/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_switch.h deleted file mode 100644 index 9c1ef46..0000000 --- a/lib/ESPiLight/pilight/libs/pilight/protocols/zwave/zwave_switch.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2015 CurlyMo - - This file is part of pilight. - - pilight 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 3 of the License, or (at your option) any later - version. - - pilight 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 pilight. If not, see -*/ - -#ifndef _PROTOCOL_ZWAVE_SWITCH_H_ -#define _PROTOCOL_ZWAVE_SWITCH_H_ - -#include "../protocol.h" - -struct protocol_t *zwave_switch; -void zwaveSwitchInit(void); - -#endif diff --git a/lib/ESPiLight/pilight/libs/webgui/ajax-loader.gif b/lib/ESPiLight/pilight/libs/webgui/ajax-loader.gif deleted file mode 100644 index ef4243a..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/ajax-loader.gif and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-ipad.png b/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-ipad.png deleted file mode 100644 index babd565..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-ipad.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone-retina-display-hr.png b/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone-retina-display-hr.png deleted file mode 100644 index 2bae318..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone-retina-display-hr.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone-retina-display.png b/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone-retina-display.png deleted file mode 100644 index 4dd0887..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone-retina-display.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone.png b/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone.png deleted file mode 100644 index c678b49..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/apple-touch-icon-iphone.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/battery_green.png b/lib/ESPiLight/pilight/libs/webgui/battery_green.png deleted file mode 100644 index 0c9631a..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/battery_green.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/battery_red.png b/lib/ESPiLight/pilight/libs/webgui/battery_red.png deleted file mode 100644 index 304e14d..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/battery_red.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/episode.png b/lib/ESPiLight/pilight/libs/webgui/episode.png deleted file mode 100644 index b7f734d..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/episode.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/favicon.ico b/lib/ESPiLight/pilight/libs/webgui/favicon.ico deleted file mode 100644 index d071c8c..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/favicon.ico and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/home.png b/lib/ESPiLight/pilight/libs/webgui/home.png deleted file mode 100644 index 439dfa2..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/home.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/humi.png b/lib/ESPiLight/pilight/libs/webgui/humi.png deleted file mode 100644 index 96bf2a1..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/humi.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/illuminance.png b/lib/ESPiLight/pilight/libs/webgui/illuminance.png deleted file mode 100644 index ba0392d..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/illuminance.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/images/ajax-loader.gif b/lib/ESPiLight/pilight/libs/webgui/images/ajax-loader.gif deleted file mode 100644 index 57f5624..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/images/ajax-loader.gif and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/images/icons-18-white.png b/lib/ESPiLight/pilight/libs/webgui/images/icons-18-white.png deleted file mode 100644 index 3419b81..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/images/icons-18-white.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/images/icons-36-white.png b/lib/ESPiLight/pilight/libs/webgui/images/icons-36-white.png deleted file mode 100644 index 12455c9..0000000 Binary files a/lib/ESPiLight/pilight/libs/webgui/images/icons-36-white.png and /dev/null differ diff --git a/lib/ESPiLight/pilight/libs/webgui/index.html b/lib/ESPiLight/pilight/libs/webgui/index.html deleted file mode 100644 index e35892f..0000000 --- a/lib/ESPiLight/pilight/libs/webgui/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - -pilight webgui - - - - - - - - - - - - - - - - - - -
- -
-
-
-
- - diff --git a/lib/ESPiLight/pilight/libs/webgui/jquery-2.1.4.min.js b/lib/ESPiLight/pilight/libs/webgui/jquery-2.1.4.min.js deleted file mode 100644 index 49990d6..0000000 --- a/lib/ESPiLight/pilight/libs/webgui/jquery-2.1.4.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b="length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){ -return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,ba=/<([\w:]+)/,ca=/<|&#?\w+;/,da=/<(?:script|style|link)/i,ea=/checked\s*(?:[^=]|=\s*.checked.)/i,fa=/^$|\/(?:java|ecma)script/i,ga=/^true\/(.*)/,ha=/^\s*\s*$/g,ia={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ia.optgroup=ia.option,ia.tbody=ia.tfoot=ia.colgroup=ia.caption=ia.thead,ia.th=ia.td;function ja(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function ka(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function la(a){var b=ga.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function ma(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function na(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function oa(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pa(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=oa(h),f=oa(a),d=0,e=f.length;e>d;d++)pa(f[d],g[d]);if(b)if(c)for(f=f||oa(a),g=g||oa(h),d=0,e=f.length;e>d;d++)na(f[d],g[d]);else na(a,h);return g=oa(h,"script"),g.length>0&&ma(g,!i&&oa(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(ca.test(e)){f=f||k.appendChild(b.createElement("div")),g=(ba.exec(e)||["",""])[1].toLowerCase(),h=ia[g]||ia._default,f.innerHTML=h[1]+e.replace(aa,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=oa(k.appendChild(e),"script"),i&&ma(f),c)){j=0;while(e=f[j++])fa.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(oa(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&ma(oa(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(oa(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!da.test(a)&&!ia[(ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(aa,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(oa(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(oa(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&ea.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(oa(c,"script"),ka),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,oa(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,la),j=0;g>j;j++)h=f[j],fa.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(ha,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qa,ra={};function sa(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function ta(a){var b=l,c=ra[a];return c||(c=sa(a,b),"none"!==c&&c||(qa=(qa||n("