diff options
| author | Riley Beckett <rbeckettvt@gmail.com> | 2026-07-22 22:30:54 -0400 |
|---|---|---|
| committer | Riley Beckett <rbeckettvt@gmail.com> | 2026-07-22 22:30:54 -0400 |
| commit | a682c2cdc499bdecab81e41200f4a28b08600bfb (patch) | |
| tree | 8189e862dc63a150daa7afffebe1a2eebe91435c /snag | |
| parent | f253f5e3d606702688deecea2162f1c5289d277c (diff) | |
make configure posix shell instead of bash
Diffstat (limited to 'snag')
| -rwxr-xr-x | snag/configure | 18 | ||||
| -rw-r--r-- | snag/src/download_db.c | 8 | ||||
| -rw-r--r-- | snag/src/util.c | 14 | ||||
| -rw-r--r-- | snag/src/util.h | 3 |
4 files changed, 10 insertions, 33 deletions
diff --git a/snag/configure b/snag/configure index 3048f71..d5493e1 100755 --- a/snag/configure +++ b/snag/configure @@ -1,16 +1,8 @@ -#!/bin/bash +#!/bin/sh bin="snag" libs="libcurl libcrypto" builddir="build" -PREFIX="/usr" - -while [ "$1" ]; do - case "$1" in - -*) exit 1 ;; - esac - shift -done CFLAGS=${CFLAGS:-""} @@ -29,7 +21,7 @@ write 'rule link' write ' description = LD $out' write ' command = gcc $libs $in -o $out' for target in $(echo "debug release"); do - eval write "cflags_$target = \$CFLAGS_${target^^} $(pkg-config --cflags $libs)" + eval write "cflags_$target = \$CFLAGS_$(echo $target | tr 'a-z' 'A-Z') $(pkg-config --cflags $libs)" write "rule cc-$target" write ' deps = gcc' @@ -38,11 +30,11 @@ for target in $(echo "debug release"); do write " command = gcc -MD -MF \$out.d \$cflags_$target -c \$in -o \$out" files="$(find . -name '*.c')" - sedstr=$(printf 's,^\./\(.*\)\.c$,%s\/%s\/\\1.o,g' ${builddir} ${target}) - ofiles=$(echo "$files" | sed ${sedstr}) + sedstr=$(printf 's,^\./src/\(.*\)\.c$,%s\/%s\/\\1.o,g' $builddir $target) + ofiles=$(echo "$files" | sed $sedstr) for f in $files; do - of=$(echo $f | sed ${sedstr}) + of=$(echo $f | sed $sedstr) write "build $of: cc-$target $f" done write "build $builddir/$target/$bin: link $(echo $ofiles)" diff --git a/snag/src/download_db.c b/snag/src/download_db.c index 819474e..6261627 100644 --- a/snag/src/download_db.c +++ b/snag/src/download_db.c @@ -30,7 +30,7 @@ static size_t curl_write_cb(char* ptr, size_t size, size_t nmemb, void* usrdata) } bool download_package(package_info_t* pkg) { - + if (curl == NULL) { // initialize curl if it isn't already CURLcode result = curl_global_init(CURL_GLOBAL_ALL); @@ -68,7 +68,7 @@ bool download_package(package_info_t* pkg) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, download_file); CURLcode result = curl_easy_perform(curl); if(result != CURLE_OK) { - log("failed to download package with curl: %s", curl_easy_strerror(result)); + print("failed to download package with curl: %s", curl_easy_strerror(result)); return false; } @@ -90,12 +90,12 @@ bool download_package(package_info_t* pkg) { print("checksum verified for %s: %s\n", pkg->attrs.id, hash_hex); return true; } else { - log("FAIL: bad checksum for %s: %s\n", pkg->attrs.id, hash_hex); + print("FAIL: bad checksum for %s: %s\n", pkg->attrs.id, hash_hex); return false; } } else { // todo(jqj): not sure if we will allow packages without hashes yet - log("WARNING: could not verify checksum for %s download because none was provided\n", pkg->attrs.id); + print("WARNING: could not verify checksum for %s download because none was provided\n", pkg->attrs.id); return true; } diff --git a/snag/src/util.c b/snag/src/util.c index 79c4b17..df1a8fd 100644 --- a/snag/src/util.c +++ b/snag/src/util.c @@ -6,18 +6,6 @@ #include "util.h" #if !DEBUG -void log(const char* format, ...) { -#else -void _log(int line, const char* file, const char* format, ...) { - fprintf(stderr, "%s:%d: info: ", file, line); -#endif - va_list args; - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); -} - -#if !DEBUG void die(const char* format, ...) { #else void _die(int line, const char* file, const char* format, ...) { @@ -34,7 +22,7 @@ void _die(int line, const char* file, const char* format, ...) { #if !DEBUG void* emalloc(size_t size, char* alloc_reason) { void* d = malloc(size); - if (d == NULL) _die("failed to allocate '%s': %s", alloc_reason, strerror(errno)); + if (d == NULL) die("failed to allocate '%s': %s", alloc_reason, strerror(errno)); return d; } #else diff --git a/snag/src/util.h b/snag/src/util.h index 081b570..1300ace 100644 --- a/snag/src/util.h +++ b/snag/src/util.h @@ -6,12 +6,9 @@ // utility for errors #if !DEBUG - void log(const char* format, ...) __attribute__((format(printf, 1, 2))); void die(const char* format, ...) __attribute__((format(printf, 1, 2))); void* emalloc(size_t size, char* alloc_reason); #else - #define log(fmt, ...) _log(__LINE__, __FILE__, fmt, ##__VA_ARGS__) - void _log(int line, const char* file, const char* format, ...) __attribute__((format(printf, 3, 4))); #define die(fmt, ...) _die(__LINE__, __FILE__, fmt, ##__VA_ARGS__) void _die(int line, const char* file, const char* format, ...) __attribute__((format(printf, 3, 4))); |
