From f9097a0562ea8b40d40a19059578a9280b945de4 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Mon, 18 May 2026 12:41:08 -0300 Subject: cleanup root --- config-unix.sexp | 4 - config.sexp | 5 - config/config-unix.sexp | 4 + config/config.sexp | 5 + config/http_demo_commands.sexp | 4 + http_demo_commands.sexp | 4 - run_tcp.ps1 | 175 ----------------------------- run_tree.ps1 | 38 ------- shared/librelational_engine/CMakeLists.txt | 11 -- shared/librelational_engine/library.cpp | 23 ---- shared/librelational_engine/library.h | 8 -- 11 files changed, 13 insertions(+), 268 deletions(-) delete mode 100644 config-unix.sexp delete mode 100644 config.sexp create mode 100644 config/config-unix.sexp create mode 100644 config/config.sexp create mode 100644 config/http_demo_commands.sexp delete mode 100644 http_demo_commands.sexp delete mode 100644 run_tcp.ps1 delete mode 100644 run_tree.ps1 delete mode 100644 shared/librelational_engine/CMakeLists.txt delete mode 100644 shared/librelational_engine/library.cpp delete mode 100644 shared/librelational_engine/library.h diff --git a/config-unix.sexp b/config-unix.sexp deleted file mode 100644 index 7598840..0000000 --- a/config-unix.sexp +++ /dev/null @@ -1,4 +0,0 @@ -(server - (storage (memory)) - (transport (tcp - (path "/tmp/sakura.sock")))) diff --git a/config.sexp b/config.sexp deleted file mode 100644 index 67a48a5..0000000 --- a/config.sexp +++ /dev/null @@ -1,5 +0,0 @@ -(server - (nt (sqlite "/tmp/sakura.db")) - (transport (tcp - (address "127.0.0.1") - (port 7777)))) diff --git a/config/config-unix.sexp b/config/config-unix.sexp new file mode 100644 index 0000000..7598840 --- /dev/null +++ b/config/config-unix.sexp @@ -0,0 +1,4 @@ +(server + (storage (memory)) + (transport (tcp + (path "/tmp/sakura.sock")))) diff --git a/config/config.sexp b/config/config.sexp new file mode 100644 index 0000000..67a48a5 --- /dev/null +++ b/config/config.sexp @@ -0,0 +1,5 @@ +(server + (nt (sqlite "/tmp/sakura.db")) + (transport (tcp + (address "127.0.0.1") + (port 7777)))) diff --git a/config/http_demo_commands.sexp b/config/http_demo_commands.sexp new file mode 100644 index 0000000..680831f --- /dev/null +++ b/config/http_demo_commands.sexp @@ -0,0 +1,4 @@ +(prl (LoadLibrary "C:/Users/mague/source/repos/_build/default/plugin/lib/plugin.cmxs")) +(prl (DefineFunctionPredicate ((name "http.get") (schema (("url" "string") ("status_code" "string") ("body" "string"))) (symbol "http.get") (purity Pure) (cardinality ConstrainedFinite)))) +(drl (Select (Const (("url" (Str "https://example.com")))) (Base "public:http.get"))) +(drl (Join (url) (Const (("url" (Str "https://json.org/example.html")))) (Base "public:http.get"))) diff --git a/http_demo_commands.sexp b/http_demo_commands.sexp deleted file mode 100644 index 680831f..0000000 --- a/http_demo_commands.sexp +++ /dev/null @@ -1,4 +0,0 @@ -(prl (LoadLibrary "C:/Users/mague/source/repos/_build/default/plugin/lib/plugin.cmxs")) -(prl (DefineFunctionPredicate ((name "http.get") (schema (("url" "string") ("status_code" "string") ("body" "string"))) (symbol "http.get") (purity Pure) (cardinality ConstrainedFinite)))) -(drl (Select (Const (("url" (Str "https://example.com")))) (Base "public:http.get"))) -(drl (Join (url) (Const (("url" (Str "https://json.org/example.html")))) (Base "public:http.get"))) diff --git a/run_tcp.ps1 b/run_tcp.ps1 deleted file mode 100644 index 175fc26..0000000 --- a/run_tcp.ps1 +++ /dev/null @@ -1,175 +0,0 @@ -param( - [string]$ConfigPath = ".\config.sexp", - [string]$ServerHost = "127.0.0.1", - [int]$Port = 7777, - [string[]]$Command, - [string]$CommandsPath, - [switch]$UseExistingServer, - [switch]$UseLocalServer, - [switch]$SkipBuild, - [switch]$NoInteractive -) - -$ErrorActionPreference = "Stop" - -function Invoke-Build { - Write-Host "Building Sakura..." - dune build - if (-not $?) { - throw "Build failed." - } -} - -function Start-SakuraServer { - param( - [string]$Config, - [string]$WorkingDirectory, - [switch]$UseOpam - ) - - Write-Host "Starting Sakura server with config $Config ..." - $filePath = "dune" - $serverArgs = @("exec", "sakura-server", "--", $Config) - if ($UseOpam) { - $filePath = "opam" - $serverArgs = @("exec", "--", "sakura-server", $Config) - } - - $proc = Start-Process -FilePath $filePath ` - -ArgumentList $serverArgs ` - -WorkingDirectory $WorkingDirectory ` - -PassThru - - return $proc -} - -function Wait-ForTcp { - param( - [string]$TargetHost, - [int]$TargetPort, - [int]$TimeoutSeconds = 20 - ) - - $deadline = (Get-Date).AddSeconds($TimeoutSeconds) - while ((Get-Date) -lt $deadline) { - $client = $null - try { - $client = [System.Net.Sockets.TcpClient]::new() - $async = $client.BeginConnect($TargetHost, $TargetPort, $null, $null) - if ($async.AsyncWaitHandle.WaitOne(250)) { - $client.EndConnect($async) - $client.Close() - return - } - $client.Close() - } catch { - if ($null -ne $client) { - $client.Close() - } - Start-Sleep -Milliseconds 250 - } - } - - throw "Timed out waiting for TCP server at $TargetHost`:$TargetPort" -} - -function Connect-Tcp { - param( - [string]$TargetHost, - [int]$TargetPort - ) - - $client = [System.Net.Sockets.TcpClient]::new($TargetHost, $TargetPort) - $stream = $client.GetStream() - $writer = [System.IO.StreamWriter]::new($stream) - $writer.AutoFlush = $true - $reader = [System.IO.StreamReader]::new($stream) - - return @{ - Client = $client - Writer = $writer - Reader = $reader - } -} - -function Send-Command { - param( - [System.IO.StreamWriter]$Writer, - [System.IO.StreamReader]$Reader, - [string]$Line - ) - - $Writer.WriteLine($Line) - $response = $Reader.ReadLine() - if ($null -eq $response) { - throw "Connection closed by server." - } - - Write-Host "< $response" -} - -$repoRoot = $PSScriptRoot -$serverProcess = $null - -try { - if (-not $SkipBuild) { - Invoke-Build - } - - if (-not $UseExistingServer) { - if ($UseLocalServer) { - Write-Host "Server mode: local dune exec sakura-server" - } else { - Write-Host "Server mode: opam-installed sakura-server" - } - $serverProcess = Start-SakuraServer -Config $ConfigPath -WorkingDirectory $repoRoot -UseOpam:(-not $UseLocalServer) - Wait-ForTcp -TargetHost $ServerHost -TargetPort $Port - Write-Host "Server is ready on $ServerHost`:$Port" - } - - $conn = Connect-Tcp -TargetHost $ServerHost -TargetPort $Port - $writer = $conn.Writer - $reader = $conn.Reader - - $commandsToSend = @() - if ($null -ne $Command -and $Command.Count -gt 0) { - $commandsToSend += $Command - } - if (-not [string]::IsNullOrWhiteSpace($CommandsPath)) { - $fileCommands = Get-Content -Path $CommandsPath | - Where-Object { -not [string]::IsNullOrWhiteSpace($_) } - $commandsToSend += $fileCommands - } - - if ($commandsToSend.Count -gt 0) { - foreach ($cmd in $commandsToSend) { - Write-Host "> $cmd" - Send-Command -Writer $writer -Reader $reader -Line $cmd - } - } - - if (-not $NoInteractive) { - Write-Host "Interactive mode. Type :quit to exit." - while ($true) { - $line = Read-Host ">" - if ($line -eq ":quit") { - break - } - if ([string]::IsNullOrWhiteSpace($line)) { - continue - } - - Send-Command -Writer $writer -Reader $reader -Line $line - } - } - - $writer.Dispose() - $reader.Dispose() - $conn.Client.Close() -} -finally { - if ($null -ne $serverProcess -and -not $serverProcess.HasExited) { - Write-Host "Stopping Sakura server (PID $($serverProcess.Id))" - Stop-Process -Id $serverProcess.Id -Force - } -} diff --git a/run_tree.ps1 b/run_tree.ps1 deleted file mode 100644 index 7f74bac..0000000 --- a/run_tree.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -param( - [switch]$NoRun -) - -$ErrorActionPreference = "Stop" - -$repoRoot = $PSScriptRoot -$projectName = Split-Path -Leaf $repoRoot - -Push-Location $repoRoot -try { - (& opam env) -split '\r?\n' | ForEach-Object { - if ($_ -ne "") { - Invoke-Expression $_ - } - } - - dune build shared/shabptree/sakura_shabptree.dll bin/tree.exe - - $dll = @( - Get-ChildItem -Path $repoRoot -Filter sakura_shabptree.dll -Recurse -ErrorAction SilentlyContinue - Get-ChildItem -Path (Join-Path $repoRoot "..") -Filter sakura_shabptree.dll -Recurse -ErrorAction SilentlyContinue | - Where-Object { $_.FullName -like "*\_build\*\$projectName\shared\shabptree\sakura_shabptree.dll" } - ) | Select-Object -First 1 - - if ($null -eq $dll) { - throw "Could not find built sakura_shabptree.dll" - } - - $env:SAKURA_BPLUSTREE_DLL = $dll.FullName - - if (-not $NoRun) { - dune exec bin/tree.exe - } -} -finally { - Pop-Location -} diff --git a/shared/librelational_engine/CMakeLists.txt b/shared/librelational_engine/CMakeLists.txt deleted file mode 100644 index 22c8444..0000000 --- a/shared/librelational_engine/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.29) -project(relational_engine) - -include_directories($ENV{LIBRESSL_INCLUDE_PATH}) - -add_library(relational_engine SHARED library.cpp) - -target_link_libraries(relational_engine - $ENV{LIBRESSL_LIB_PATH}/libssl.$ENV{OS_LIB_EXTENSION} - $ENV{LIBRESSL_LIB_PATH}/libcrypto.$ENV{OS_LIB_EXTENSION} -) \ No newline at end of file diff --git a/shared/librelational_engine/library.cpp b/shared/librelational_engine/library.cpp deleted file mode 100644 index a9b4c81..0000000 --- a/shared/librelational_engine/library.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -extern "C" { -#include "library.h" - - extern void compute_hash(char* computed_hash, const char *content) { - unsigned char hash[SHA256_DIGEST_LENGTH]; - SHA256_CTX sha256; - SHA256_Init(&sha256); - SHA256_Update(&sha256, content, std::strlen(content)); - SHA256_Final(hash, &sha256); - std::stringstream ss; - for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) - ss << std::hex << std::setw(2) << std::setfill('0') << static_cast(hash[i]); - std::memcpy(computed_hash, ss.str().c_str(), HASH_SIZE); - } -} diff --git a/shared/librelational_engine/library.h b/shared/librelational_engine/library.h deleted file mode 100644 index cae22cb..0000000 --- a/shared/librelational_engine/library.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef RELATIONAL_ENGINE_LIBRARY_H -#define RELATIONAL_ENGINE_LIBRARY_H - -#define HASH_SIZE 64 - -extern void compute_hash(char*, const char*); - -#endif //RELATIONAL_ENGINE_LIBRARY_H -- cgit v1.2.3