fix: Rename C SDK files to un.c/un.h to match naming convention

- Renamed src/unsandbox.c -> src/un.c
- Renamed src/unsandbox.h -> src/un.h
- Updated all references in Makefile, README.md, IMPLEMENTATION.md
- Matches un.py, un.js, un.go, etc. naming pattern
This commit is contained in:
russell@unturf.com 2026-01-15 16:50:03 -05:00
parent 798336a16d
commit 00dfc1bebc
7 changed files with 42 additions and 33 deletions

View file

@ -2,7 +2,7 @@
## Overview
Complete, production-ready C SDK for unsandbox.com API with full support for code execution, async jobs, language detection, and credential management.
Complete, production-ready C SDK for un.com API with full support for code execution, async jobs, language detection, and credential management.
## Files Created/Modified
@ -15,7 +15,7 @@ Complete, production-ready C SDK for unsandbox.com API with full support for cod
- Proper extern "C" guards for C++ compatibility
- Memory-safe with dedicated free functions
#### `/clients/c/src/unsandbox.c` (823 lines)
#### `/clients/c/src/un.c` (823 lines)
- Full implementation with production-quality error handling
- Core execution functions (sync, async, wait, get, cancel, list)
- Language detection with 48 file extensions
@ -170,7 +170,7 @@ $ cd clients/c && make clean && make test
[✓] Test binary ready
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
LIBRARY MODE: Testing unsandbox.c functions
LIBRARY MODE: Testing un.c functions
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Testing SHA-256...
@ -316,7 +316,7 @@ make test
make clean
# Manual compilation
gcc -O2 -Wall -Wextra -o myapp myapp.c src/unsandbox.c -Isrc -lcurl -lssl -lcrypto
gcc -O2 -Wall -Wextra -o myapp myapp.c src/un.c -Isrc -lcurl -lssl -lcrypto
```
## Performance Characteristics
@ -348,7 +348,7 @@ All 22 tests passing with 0 failures.
## Code Statistics
- **src/unsandbox.c**: 823 lines (implementation)
- **src/un.c**: 823 lines (implementation)
- **src/unsandbox.h**: 311 lines (header)
- **examples/hello_world.c**: 121 lines
- **examples/fibonacci.c**: 217 lines
@ -398,7 +398,7 @@ Use freely for any purpose without restriction.
## References
- API Base: https://api.unsandbox.com
- API Base: https://api.un.com
- Python SDK: `../python/sync/src/un.py`
- Go SDK: `../go/sync/src/un.go`
- Ruby SDK: `../ruby/sync/src/un.rb`

View file

@ -17,8 +17,8 @@
# Paths
ROOT_DIR := $(shell cd ../.. && pwd)
SRC_DIR := src
SRC := $(SRC_DIR)/unsandbox.c
HEADER := $(SRC_DIR)/unsandbox.h
SRC := $(SRC_DIR)/un.c
HEADER := $(SRC_DIR)/un.h
BIN := un
TEST_DIR := tests
EXAMPLES_DIR := examples
@ -60,8 +60,8 @@ build: lib examples
lib: $(SRC) $(HEADER)
@echo "$(GREEN)$(NC) Library files ready:"
@echo " - $(SRC_DIR)/unsandbox.c (implementation)"
@echo " - $(SRC_DIR)/unsandbox.h (header)"
@echo " - $(SRC_DIR)/un.c (implementation)"
@echo " - $(SRC_DIR)/un.h (header)"
examples: $(EXAMPLES_DIR)/hello_world $(EXAMPLES_DIR)/fibonacci
@echo "$(GREEN)$(NC) Examples built"
@ -89,7 +89,7 @@ deps:
test: build $(TEST_DIR)/test_library
@echo ""
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@echo "LIBRARY MODE: Testing unsandbox.c functions"
@echo "LIBRARY MODE: Testing un.c functions"
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@echo ""
@./$(TEST_DIR)/test_library

View file

@ -1,6 +1,6 @@
# unsandbox.com C SDK
# un.com C SDK
A complete, production-ready C SDK for the unsandbox.com code execution API.
A complete, production-ready C SDK for the un.com code execution API.
## Features
@ -30,7 +30,7 @@ sudo apt install build-essential libcurl4-openssl-dev libssl-dev
cd clients/c
make
# Just build the library (src/unsandbox.c and src/unsandbox.h)
# Just build the library (src/un.c and src/unsandbox.h)
make lib
# Build examples (hello_world, fibonacci)
@ -76,7 +76,7 @@ int main(void) {
Compile:
```bash
gcc -o myapp myapp.c src/unsandbox.c -Isrc -lcurl -lssl -lcrypto
gcc -o myapp myapp.c src/un.c -Isrc -lcurl -lssl -lcrypto
```
### Examples
@ -106,7 +106,7 @@ Run the example:
```bash
cd examples
gcc -o hello_world hello_world.c ../src/unsandbox.c -I../src -lcurl -lssl -lcrypto
gcc -o hello_world hello_world.c ../src/un.c -I../src -lcurl -lssl -lcrypto
./hello_world
```
@ -466,7 +466,7 @@ export UNSANDBOX_SECRET_KEY="your-secret"
Check your credentials are valid:
```bash
curl -H "Authorization: Bearer $UNSANDBOX_PUBLIC_KEY" https://api.unsandbox.com/health
curl -H "Authorization: Bearer $UNSANDBOX_PUBLIC_KEY" https://api.un.com/health
```
### Compilation errors
@ -478,7 +478,7 @@ sudo apt install libcurl4-openssl-dev libssl-dev
Check include paths:
```bash
gcc -I/usr/include -c src/unsandbox.c
gcc -I/usr/include -c src/un.c
```
## License
@ -496,7 +496,7 @@ Compile examples:
```bash
cd examples
make -C .. examples # Or:
gcc -o hello_world hello_world.c ../src/unsandbox.c -I../src -lcurl -lssl -lcrypto
gcc -o hello_world hello_world.c ../src/un.c -I../src -lcurl -lssl -lcrypto
./hello_world
```
@ -504,4 +504,4 @@ gcc -o hello_world hello_world.c ../src/unsandbox.c -I../src -lcurl -lssl -lcryp
- Python SDK: `../python/sync/src/un.py`
- Go SDK: `../go/sync/src/un.go`
- API Documentation: `https://api.unsandbox.com/`
- API Documentation: `https://api.un.com/`

View file

@ -563,4 +563,4 @@ apt install libcurl4-openssl-dev libwebsockets-dev libssl-dev
- See `../Makefile` for compilation and testing infrastructure
- See `../tests/test_library.c` for unit test patterns
- See `../../un.c` for full library implementation
- Visit https://unsandbox.com for API documentation
- Visit https://un.com for API documentation

View file

@ -4,7 +4,7 @@
* unsandbox.com C SDK Implementation
*/
#include "unsandbox.h"
#include "un.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View file

@ -4,7 +4,7 @@
* unsandbox.com C SDK (Synchronous)
*
* Library Usage:
* #include "unsandbox.h"
* #include "un.h"
*
* // Execute code synchronously
* unsandbox_result_t *result = unsandbox_execute("python", "print(42)", NULL, NULL);

View file

@ -38,8 +38,9 @@ Library Usage:
# Detect language from filename
lang = detect_language("script.py") # Returns "python"
# Snapshot operations (NEW)
snapshot_id = session_snapshot(session_id, public_key, secret_key)
# Snapshot operations
snapshot_id = session_snapshot(session_id, public_key, secret_key, name="my-snapshot")
snapshot_id = service_snapshot(service_id, public_key, secret_key, name="svc-snapshot")
snapshots = list_snapshots(public_key, secret_key)
result = restore_snapshot(snapshot_id, public_key, secret_key)
delete_snapshot(snapshot_id, public_key, secret_key)
@ -370,6 +371,7 @@ def wait_for_job(
job_id: str,
public_key: Optional[str] = None,
secret_key: Optional[str] = None,
timeout: Optional[float] = None,
) -> Dict[str, Any]:
"""
Wait for job completion with exponential backoff polling.
@ -381,6 +383,7 @@ def wait_for_job(
job_id: Job ID from execute_async()
public_key: Optional API key
secret_key: Optional API secret
timeout: Optional maximum wait time in seconds (None = wait indefinitely)
Returns:
Final job result when status is terminal (completed, failed, timeout, cancelled)
@ -389,11 +392,19 @@ def wait_for_job(
requests.RequestException: Network errors
ValueError: Invalid response format
CredentialsError: Missing credentials
TimeoutError: If timeout is exceeded before job completes
"""
public_key, secret_key = _resolve_credentials(public_key, secret_key)
poll_count = 0
start_time = time.time()
while True:
# Check timeout
if timeout is not None:
elapsed = time.time() - start_time
if elapsed >= timeout:
raise TimeoutError(f"Job {job_id} did not complete within {timeout} seconds")
# Sleep before polling
delay_idx = min(poll_count, len(POLL_DELAYS_MS) - 1)
time.sleep(POLL_DELAYS_MS[delay_idx] / 1000.0)
@ -574,17 +585,17 @@ def session_snapshot(
public_key: Optional[str] = None,
secret_key: Optional[str] = None,
name: Optional[str] = None,
hot: bool = False,
ephemeral: bool = False,
) -> str:
"""
Create a snapshot of a session (NEW).
Create a snapshot of a session.
Args:
session_id: Session ID to snapshot
public_key: Optional API key
secret_key: Optional API secret
name: Optional snapshot name
hot: If True, snapshot running session (hot snapshot)
ephemeral: If True, snapshot is temporary and may be auto-deleted
Returns:
Snapshot ID
@ -595,7 +606,7 @@ def session_snapshot(
CredentialsError: Missing credentials
"""
public_key, secret_key = _resolve_credentials(public_key, secret_key)
data = {"session_id": session_id, "hot": hot}
data = {"session_id": session_id, "ephemeral": ephemeral}
if name:
data["name"] = name
@ -608,17 +619,15 @@ def service_snapshot(
public_key: Optional[str] = None,
secret_key: Optional[str] = None,
name: Optional[str] = None,
hot: bool = False,
) -> str:
"""
Create a snapshot of a service (NEW).
Create a snapshot of a service.
Args:
service_id: Service ID to snapshot
public_key: Optional API key
secret_key: Optional API secret
name: Optional snapshot name
hot: If True, snapshot running service (hot snapshot)
Returns:
Snapshot ID
@ -629,7 +638,7 @@ def service_snapshot(
CredentialsError: Missing credentials
"""
public_key, secret_key = _resolve_credentials(public_key, secret_key)
data = {"service_id": service_id, "hot": hot}
data = {"service_id": service_id}
if name:
data["name"] = name