curl_version_info_data *curl_version_info(CURLversion stamp) { static bool initialized; #ifdef USE_LIBSSH2 static char ssh_buffer[80]; #endif #ifdef USE_SSL static char ssl_buffer[80]; #endif if(initialized) return &version_info; #ifdef USE_SSL Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer)); version_info.ssl_version = ssl_buffer; #endif #ifdef HAVE_LIBZ version_info.libz_version = zlibVersion(); /* libz left NULL if non-existing */ #endif #ifdef USE_ARES { int aresnum; version_info.ares = ares_version(&aresnum); version_info.ares_num = aresnum; } #endif #ifdef USE_LIBIDN2 /* This returns a version string if we use the given version or later, otherwise it returns NULL */ version_info.libidn = idn2_check_version(IDN2_VERSION); if(version_info.libidn) version_info.features |= CURL_VERSION_IDN; #elif defined(USE_WIN32_IDN) version_info.features |= CURL_VERSION_IDN; #endif #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) #ifdef _LIBICONV_VERSION version_info.iconv_ver_num = _LIBICONV_VERSION; #else /* version unknown */ version_info.iconv_ver_num = -1; #endif /* _LIBICONV_VERSION */ #endif #ifdef USE_LIBSSH2 snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION); version_info.libssh_version = ssh_buffer; #endif (void)stamp; /* avoid compiler warnings, we don't use this */ initialized = true; return &version_info; }
void utf8_version_report(FILE *f) { #ifdef SUPPORT_I18N_2008 fprintf(f, "Library version: IDN2: Compile: %s\n" " Runtime: %s\n", IDN2_VERSION, idn2_check_version(NULL)); fprintf(f, "Library version: Stringprep: Compile: %s\n" " Runtime: %s\n", STRINGPREP_VERSION, stringprep_check_version(NULL)); #else fprintf(f, "Library version: IDN: Compile: %s\n" " Runtime: %s\n", STRINGPREP_VERSION, stringprep_check_version(NULL)); #endif }
char *curl_version(void) { static bool initialized; static char version[200]; char *ptr = version; size_t len; size_t left = sizeof(version); if(initialized) return version; strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION); len = strlen(ptr); left -= len; ptr += len; if(left > 1) { len = Curl_ssl_version(ptr + 1, left - 1); if(len > 0) { *ptr = ' '; left -= ++len; ptr += len; } } #ifdef HAVE_LIBZ len = msnprintf(ptr, left, " zlib/%s", zlibVersion()); left -= len; ptr += len; #endif #ifdef HAVE_BROTLI len = msnprintf(ptr, left, "%s", " brotli/"); left -= len; ptr += len; len = brotli_version(ptr, left); left -= len; ptr += len; #endif #ifdef USE_ARES /* this function is only present in c-ares, not in the original ares */ len = msnprintf(ptr, left, " c-ares/%s", ares_version(NULL)); left -= len; ptr += len; #endif #ifdef USE_LIBIDN2 if(idn2_check_version(IDN2_VERSION)) { len = msnprintf(ptr, left, " libidn2/%s", idn2_check_version(NULL)); left -= len; ptr += len; } #endif #ifdef USE_LIBPSL len = msnprintf(ptr, left, " libpsl/%s", psl_get_version()); left -= len; ptr += len; #endif #ifdef USE_WIN32_IDN len = msnprintf(ptr, left, " WinIDN"); left -= len; ptr += len; #endif #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) #ifdef _LIBICONV_VERSION len = msnprintf(ptr, left, " iconv/%d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255); #else /* version unknown */ len = msnprintf(ptr, left, " iconv"); #endif /* _LIBICONV_VERSION */ left -= len; ptr += len; #endif #ifdef USE_LIBSSH2 len = msnprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION); left -= len; ptr += len; #endif #ifdef USE_LIBSSH len = msnprintf(ptr, left, " libssh/%s", CURL_LIBSSH_VERSION); left -= len; ptr += len; #endif #ifdef USE_NGHTTP2 len = Curl_http2_ver(ptr, left); left -= len; ptr += len; #endif #ifdef USE_LIBRTMP { char suff[2]; if(RTMP_LIB_VERSION & 0xff) { suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1; suff[1] = '\0'; } else suff[0] = '\0'; msnprintf(ptr, left, " librtmp/%d.%d%s", RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff, suff); /* If another lib version is added below this one, this code would also have to do: len = what msnprintf() returned left -= len; ptr += len; */ } #endif /* Silent scan-build even if librtmp is not enabled. */ (void) left; (void) ptr; initialized = true; return version; }
static void _print_psl_entries_dafsa(FILE *fpout, const _psl_vector_t *v) { FILE *fp; int it; #ifdef BUILTIN_GENERATOR_LIBICU do { UVersionInfo version_info; char version[U_MAX_VERSION_STRING_LENGTH]; u_getVersion(version_info); u_versionToString(version_info, version); fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libicu/%s) */\n", version); } while (0); #elif defined(BUILTIN_GENERATOR_LIBIDN2) fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libidn2/%s) */\n", idn2_check_version(NULL)); #elif defined(BUILTIN_GENERATOR_LIBIDN) fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libidn/%s) */\n", stringprep_check_version(NULL)); #else fprintf(fpout, "/* automatically generated by psl2c (punycode generated internally) */\n"); #endif if ((fp = fopen("in.tmp", "w"))) { for (it = 0; it < v->cur; it++) { _psl_entry_t *e = _vector_get(v, it); unsigned char *s = (unsigned char *)e->label_buf; /* search for non-ASCII label and skip it */ while (*s && *s < 128) s++; if (*s) continue; fprintf(fp, "%s, %X\n", e->label_buf, (int) (e->flags & 0x0F)); } fclose(fp); } if ((it = system(MAKE_DAFSA " in.tmp out.tmp"))) fprintf(stderr, "Failed to execute " MAKE_DAFSA "\n"); if ((fp = fopen("out.tmp", "r"))) { char buf[256]; while (fgets(buf, sizeof(buf), fp)) fputs(buf, fpout); fclose(fp); } unlink("in.tmp"); unlink("out.tmp"); }
static void _print_psl_entries(FILE *fpout, const _psl_vector_t *v, const char *varname) { int it; #ifdef BUILTIN_GENERATOR_LIBICU do { UVersionInfo version_info; char version[U_MAX_VERSION_STRING_LENGTH]; u_getVersion(version_info); u_versionToString(version_info, version); fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libicu/%s) */\n", version); } while (0); #elif defined(BUILTIN_GENERATOR_LIBIDN2) fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libidn2/%s) */\n", idn2_check_version(NULL)); #elif defined(BUILTIN_GENERATOR_LIBIDN) fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libidn/%s) */\n", stringprep_check_version(NULL)); #else fprintf(fpout, "/* automatically generated by psl2c (without punycode support) */\n"); #endif fprintf(fpout, "static _psl_entry_t %s[] = {\n", varname); for (it = 0; it < v->cur; it++) { _psl_entry_t *e = _vector_get(v, it); fprintf(fpout, "\t{ \"%s\", NULL, %hd, %d, %d },\n", e->label_buf, e->length, (int) e->nlabels, (int) e->flags); } fprintf(fpout, "};\n"); }