diff options
Diffstat (limited to 'snag/src')
| -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 |
3 files changed, 5 insertions, 20 deletions
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))); |
