diff options
Diffstat (limited to 'almamater.c')
-rw-r--r-- | almamater.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/almamater.c b/almamater.c index 9dfe506..fe86901 100644 --- a/almamater.c +++ b/almamater.c @@ -6,7 +6,6 @@ #include <stdlib.h> #include <pthread.h> #include <sys/time.h> -#include <sys/sysinfo.h> #include <curl/curl.h> #include "skein.h" @@ -15,6 +14,32 @@ #define STR_MAX 64 #define DOMAIN "columbia.edu" + +#ifdef __linux__ +#include <sys/sysinfo.h> +#else +#include <sys/sysctl.h> +static inline int get_nprocs() +{ + int nproc; + int mib[4]; + size_t len = sizeof(nproc); + + mib[0] = CTL_HW; + mib[1] = HW_AVAILCPU; + sysctl(mib, 2, &nproc, &len, NULL, 0); + + if (nproc < 1) { + mib[1] = HW_NCPU; + sysctl(mib, 2, &nproc, &len, NULL, 0); + if (nproc < 1) + nproc = 1; + } + + return nproc; +} +#endif + static const uint8_t xkcd_hash[] = { 0x5b, 0x4d, 0xa9, 0x5f, 0x5f, 0xa0, 0x82, 0x80, 0xfc, 0x98, 0x79, 0xdf, 0x44, 0xf4, 0x18, 0xc8, 0xf9, 0xf1, 0x2b, 0xa4, 0x24, 0xb7, 0x75, 0x7d, @@ -98,7 +123,7 @@ static void submit_to_xkcd(uint8_t *str, size_t len, unsigned long score) printf("[-] Could not init curl.\n"); goto unlock_mutex; } - escaped_str = curl_easy_escape(curl, str, len); + escaped_str = curl_easy_escape(curl, (char *)str, len); if (!escaped_str) { printf("[-] Could not escape string.\n"); goto free_curl; |