main.cpp
1 // Test multiple nix dependencies 2 // Uses: zlib, openssl, curl (curl depends on both) 3 4 #include <curl/curl.h> 5 #include <openssl/sha.h> 6 #include <stdio.h> 7 #include <string.h> 8 #include <zlib.h> 9 10 // Callback for curl - just count bytes 11 // cppcheck-suppress unusedFunction ; referenced by curl via function pointer 12 static size_t write_callback(void *contents, size_t size, size_t nmemb, 13 void *userp) { 14 size_t *total = (size_t *)userp; 15 *total += size * nmemb; 16 return size * nmemb; 17 } 18 19 int main(void) { 20 printf("=== Multi-dependency test ===\n\n"); 21 22 // 1. zlib: compress something 23 printf("1. zlib %s\n", zlibVersion()); 24 const char *input = "Hello from multi-dep test!"; 25 char compressed[256]; 26 uLongf comp_len = sizeof(compressed); 27 if (compress((Bytef *)compressed, &comp_len, (const Bytef *)input, 28 strlen(input) + 1) == Z_OK) { 29 printf(" Compressed %zu -> %lu bytes\n", strlen(input) + 1, comp_len); 30 } 31 32 // 2. openssl: hash something 33 printf("\n2. OpenSSL %s\n", OPENSSL_VERSION_TEXT); 34 unsigned char hash[SHA256_DIGEST_LENGTH]; 35 SHA256((const unsigned char *)input, strlen(input), hash); 36 printf(" SHA256: "); 37 for (int i = 0; i < 8; i++) 38 printf("%02x", hash[i]); 39 printf("...\n"); 40 41 // 3. curl: check version (don't actually fetch) 42 printf("\n3. curl %s\n", curl_version()); 43 curl_global_init(CURL_GLOBAL_DEFAULT); 44 CURL *curl = curl_easy_init(); 45 if (curl) { 46 printf(" curl_easy_init() OK\n"); 47 curl_easy_cleanup(curl); 48 } 49 curl_global_cleanup(); 50 51 printf("\n=== All dependencies working ===\n"); 52 return 0; 53 }