| 1 |
#include <zlib.h> |
| 2 |
#include <stdbool.h> |
| 3 |
#include <stdio.h> |
| 4 |
#include <string.h> |
| 5 |
|
| 6 |
static bool check_version(const char *zlib_ver, const char *found_zlib) { |
| 7 |
if (zlib_ver == found_zlib) |
| 8 |
return true; |
| 9 |
|
| 10 |
if (strcmp(zlib_ver, found_zlib) == 0) |
| 11 |
return true; |
| 12 |
|
| 13 |
#ifdef ZLIBNG_VERSION |
| 14 |
const char *ptr = strstr(zlib_ver, found_zlib); |
| 15 |
|
| 16 |
// If the needle isn't found or the needle isn't at the start, fail. |
| 17 |
if (ptr == NULL || ptr != zlib_ver) |
| 18 |
return false; |
| 19 |
|
| 20 |
/* In zlib-ng, ZLIB_VERSION is of the form X.Y.Z.zlib-ng. This will move the |
| 21 |
* pointer to the start of the suffix, .zlib-ng. We know that at this point |
| 22 |
* that FOUND_ZLIB is the start of ZLIB_VERSION, so compare the rest. |
| 23 |
*/ |
| 24 |
ptr += strlen(found_zlib); |
| 25 |
if (strcmp(ptr, ".zlib-ng") == 0) |
| 26 |
return true; |
| 27 |
#endif |
| 28 |
|
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
int main(void) { |
| 33 |
void * something = deflate; |
| 34 |
if (!check_version(ZLIB_VERSION, FOUND_ZLIB)) { |
| 35 |
printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION); |
| 36 |
#ifdef ZLIBNG_VERSION |
| 37 |
puts("Note that in the case of zlib-ng, a version suffix of .zlib-ng is expected"); |
| 38 |
#endif |
| 39 |
return 2; |
| 40 |
} |
| 41 |
if(something != 0) |
| 42 |
return 0; |
| 43 |
printf("Couldn't find 'deflate'\n"); |
| 44 |
return 1; |
| 45 |
} |