Skip to content

Latest commit

 

History

History
243 lines (170 loc) · 5.42 KB

File metadata and controls

243 lines (170 loc) · 5.42 KB

Omi CLI for C89 (omi.c)

Other CLI Versions: CLI_PYTHON3.md | CLI_HAXE5.md | CLI_CSHARP.md | CLI_BASH.md | CLI_BAT.md | CLI_AMIGASHELL.md | CLI_LUA.md

Overview

The C89 CLI is a portable, single-file C implementation designed for retro and modern platforms. It can compile on AmigaOS, Windows, macOS, BSD, and Linux using standard C89 toolchains.

Key properties:

  • C89 compatible - works with classic compilers
  • Cross-platform - AmigaOS, Windows, macOS, BSD, Linux
  • SQLite storage - same database schema as other CLIs
  • Internal or external HTTP - controlled by USE_INTERNAL_HTTP
  • SHA256 built-in - no external hash tool required

Requirements

  • C89 compiler (gcc, clang, vbcc, SAS/C, MSVC)
  • SQLite3 development headers and library
  • curl executable (for external HTTP mode)
  • Optional: libcurl development headers (for internal HTTP mode)

Build Instructions

Linux / BSD

gcc -std=c89 -O2 -o omi omi.c -lsqlite3

Enable internal HTTP with libcurl:

gcc -std=c89 -O2 -o omi omi.c -lsqlite3 -lcurl -DUSE_LIBCURL

macOS

clang -std=c89 -O2 -o omi omi.c -lsqlite3

With libcurl:

clang -std=c89 -O2 -o omi omi.c -lsqlite3 -lcurl -DUSE_LIBCURL

Windows (MinGW)

gcc -std=c89 -O2 -o omi.exe omi.c -lsqlite3

With libcurl:

gcc -std=c89 -O2 -o omi.exe omi.c -lsqlite3 -lcurl -DUSE_LIBCURL

Windows (MSVC)

cl /O2 omi.c sqlite3.lib

With libcurl (if installed):

cl /O2 omi.c sqlite3.lib libcurl.lib /DUSE_LIBCURL

AmigaOS (vbcc)

vc -O2 -o omi omi.c -lsqlite3

AmigaOS (gcc / GeekGadgets)

gcc -O2 -o omi omi.c -lsqlite3

Note: libcurl is optional. If not compiled with -DUSE_LIBCURL, Omi uses external curl based on settings.

Configuration

Create settings.txt in the repository root:

SQLITE=sqlite3
CURL=curl
USERNAME=user
PASSWORD=pass
REPOS=https://omi.example.com
API_ENABLED=1
API_RATE_LIMIT=60
API_RATE_LIMIT_WINDOW=60
USE_INTERNAL_HTTP=1
HTTP_TIMEOUT=30

Internal vs External HTTP

Omi supports two modes for push/pull:

  • Internal HTTP (USE_INTERNAL_HTTP=1)

    • Uses libcurl if compiled with -DUSE_LIBCURL
    • No external curl dependency
    • Recommended for embedded and restricted systems
  • External HTTP (USE_INTERNAL_HTTP=0)

    • Uses external curl executable
    • Works without libcurl development headers
    • Useful for compatibility or debugging

If internal HTTP is enabled but libcurl is not compiled in, Omi falls back to external curl automatically.

Quick Reference

Command Description
omi init Initialize new repository
omi add <file> Stage a single file
omi add --all Stage all files
omi commit -m "msg" Create a commit
omi push Push to remote (OTP if enabled)
omi pull Pull from remote (OTP if enabled)
omi status Show staging status
omi log Show commit history

Common Workflows

Initialize and Commit

omi init
omi add --all
omi commit -m "Initial commit"

Push and Pull

omi push
omi pull

Status and Log

omi status
omi log

2FA / OTP

If OTP is enabled for the user in phpusers.txt, Omi prompts for a 6-digit code during push and pull.

Enter OTP code (6 digits): 123456

Platform Notes

AmigaOS

  • Use AmiSSL for HTTPS when using external curl
  • If curl is not available, compile with libcurl (if supported in your toolchain)
  • Keep repo.omi on a filesystem with long filename support

Windows

  • Use omi.exe and ensure curl.exe is in PATH
  • SQLite library must be available to the compiler and linker

BSD

  • Install sqlite3 and libcurl from ports/pkg
pkg install sqlite3 curl

Troubleshooting

"Error: Database file repo.omi not found"

Run init first:

omi init

"Internal HTTP failed, falling back to curl"

This means the binary was compiled without libcurl. Either:

  1. Rebuild with libcurl:
gcc -std=c89 -O2 -o omi omi.c -lsqlite3 -lcurl -DUSE_LIBCURL
  1. Or set external curl explicitly:
USE_INTERNAL_HTTP=0

"Error: Failed to push"

  • Check credentials in settings.txt
  • Ensure REPOS points to your server URL
  • Verify curl works: curl --version

See Also

Notes

  • C89 implementation uses a built-in SHA256 to avoid external hash dependencies
  • If you need SSL certificate customization, prefer external curl
  • For very large repositories, increase OS file descriptor limits

Last Updated: February 10, 2026
Omi Version: 1.0
CLI Version: C89