From e8d78a26da0c6a3144b2b08bee989564a516b951 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 19 Apr 2024 09:19:12 +0200 Subject: lib: introduce socket library Introduce a new socket module which provides bindings for the BSD sockets API to ucode scripts. Example usage: import * as socket from 'socket'; let sk = socket.create(socket.AF_INET, socket.SOCK_STREAM); sk.connect("192.168.1.1", 80); sk.send("GET / HTTP/1.0\r\n\r\n"); print(sk.recv(4096)); sk.close(); Signed-off-by: Jo-Philipp Wich --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index ade8aac..084c441 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ option(RESOLV_SUPPORT "NS resolve plugin support" ON) option(STRUCT_SUPPORT "Struct plugin support" ON) option(ULOOP_SUPPORT "Uloop plugin support" ${DEFAULT_ULOOP_SUPPORT}) option(LOG_SUPPORT "Log plugin support" ON) +option(SOCKET_SUPPORT "Socket plugin support" ON) set(LIB_SEARCH_PATH "${CMAKE_INSTALL_PREFIX}/lib/ucode/*.so:${CMAKE_INSTALL_PREFIX}/share/ucode/*.uc:./*.so:./*.uc" CACHE STRING "Default library search path") string(REPLACE ":" "\", \"" LIB_SEARCH_DEFINE "${LIB_SEARCH_PATH}") @@ -266,6 +267,13 @@ if(LOG_SUPPORT) endif() endif() +if(SOCKET_SUPPORT) + set(LIBRARIES ${LIBRARIES} socket_lib) + add_library(socket_lib MODULE lib/socket.c) + set_target_properties(socket_lib PROPERTIES OUTPUT_NAME socket PREFIX "") + target_link_options(socket_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS}) +endif() + if(UNIT_TESTING) enable_testing() add_definitions(-DUNIT_TESTING) -- cgit v1.2.3