char *curl_version(void) { static char version[200]; char *ptr=version; size_t len; size_t left = sizeof(version); strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION ); ptr=strchr(ptr, '\0'); left -= strlen(ptr); len = Curl_ssl_version(ptr, left); left -= len; ptr += len; #ifdef HAVE_LIBZ len = snprintf(ptr, left, " zlib/%s", zlibVersion()); left -= len; ptr += len; #endif #ifdef USE_ARES /* this function is only present in c-ares, not in the original ares */ len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL)); left -= len; ptr += len; #endif #ifdef USE_LIBIDN if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) { len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL)); left -= len; ptr += len; } #endif return version; }
char *curl_version(void) { static char version[200]; char *ptr=version; size_t len; size_t left = sizeof(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 = snprintf(ptr, left, " zlib/%s", zlibVersion()); left -= len; ptr += len; #endif #ifdef USE_ARES /* this function is only present in c-ares, not in the original ares */ len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL)); left -= len; ptr += len; #endif #ifdef USE_LIBIDN if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) { len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL)); left -= len; ptr += len; } #endif #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) #ifdef _LIBICONV_VERSION len = snprintf(ptr, left, " iconv/%d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255); #else /* version unknown */ len = snprintf(ptr, left, " iconv"); #endif /* _LIBICONV_VERSION */ left -= len; ptr += len; #endif #ifdef USE_LIBSSH2 len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION); left -= len; ptr += len; #endif return version; }
curl_version_info_data *curl_version_info(CURLversion stamp) { #ifdef USE_SSL static char ssl_buffer[80]; 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_LIBIDN /* This returns a version string if we use the given version or later, otherwise it returns NULL */ version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION); if(version_info.libidn) version_info.features |= CURL_VERSION_IDN; #endif (void)stamp; /* avoid compiler warnings, we don't use this */ return &version_info; }
void utf8_version_report(FILE *f) { fprintf(f, "Library version: IDN: Compile: %s\n" " Runtime: %s\n", STRINGPREP_VERSION, stringprep_check_version(NULL)); }
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 }
curl_version_info_data *curl_version_info(CURLversion stamp) { #ifdef USE_LIBSSH2 static char ssh_buffer[80]; #endif #ifdef USE_SSL static char ssl_buffer[80]; 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_LIBIDN /* This returns a version string if we use the given version or later, otherwise it returns NULL */ version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_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 */ return &version_info; }
char *curl_version(void) { static char version[200]; char *ptr = version; size_t len; size_t left = sizeof(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 = snprintf(ptr, left, " zlib/%s", zlibVersion()); left -= len; ptr += len; #endif #ifdef USE_ARES /* this function is only present in c-ares, not in the original ares */ len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL)); left -= len; ptr += len; #endif #ifdef USE_LIBIDN if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) { len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL)); left -= len; ptr += len; } #endif #ifdef USE_WIN32_IDN len = snprintf(ptr, left, " WinIDN"); left -= len; ptr += len; #endif #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS) #ifdef _LIBICONV_VERSION len = snprintf(ptr, left, " iconv/%d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255); #else /* version unknown */ len = snprintf(ptr, left, " iconv"); #endif /* _LIBICONV_VERSION */ left -= len; ptr += len; #endif #ifdef USE_LIBSSH2 len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_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'; snprintf(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 snprintf() returned left -= len; ptr += len; */ } #endif return version; }
void doit (void) { char *p; int rc; size_t i; if (!stringprep_check_version (STRINGPREP_VERSION)) fail ("stringprep_check_version() failed\n"); for (i = 0; i < sizeof (strprep) / sizeof (strprep[0]); i++) { if (debug) printf ("STRINGPREP entry %d\n", i); if (debug) { printf ("flags: %d\n", strprep[i].flags); printf ("in: "); escapeprint (strprep[i].in, strlen (strprep[i].in)); hexprint (strprep[i].in, strlen (strprep[i].in)); binprint (strprep[i].in, strlen (strprep[i].in)); } { uint32_t *l; char *x; l = stringprep_utf8_to_ucs4 (strprep[i].in, -1, NULL); x = stringprep_ucs4_to_utf8 (l, -1, NULL, NULL); free (l); if (strcmp (strprep[i].in, x) != 0) { fail ("bad UTF-8 in entry %d\n", i); if (debug) { puts ("expected:"); escapeprint (strprep[i].in, strlen (strprep[i].in)); hexprint (strprep[i].in, strlen (strprep[i].in)); puts ("computed:"); escapeprint (x, strlen (x)); hexprint (x, strlen (x)); } } free (x); } rc = stringprep_profile (strprep[i].in, &p, strprep[i].profile ? strprep[i].profile : "Nameprep", strprep[i].flags); if (rc != strprep[i].rc) { fail ("stringprep() entry %d failed: %d\n", i, rc); if (debug) printf ("FATAL\n"); if (rc == STRINGPREP_OK) free (p); continue; } if (debug && rc == STRINGPREP_OK) { printf ("out: "); escapeprint (p, strlen (p)); hexprint (p, strlen (p)); binprint (p, strlen (p)); printf ("expected out: "); escapeprint (strprep[i].out, strlen (strprep[i].out)); hexprint (strprep[i].out, strlen (strprep[i].out)); binprint (strprep[i].out, strlen (strprep[i].out)); } else if (debug) printf ("returned %d expected %d\n", rc, strprep[i].rc); if (rc == STRINGPREP_OK) { if (strlen (strprep[i].out) != strlen (p) || memcmp (strprep[i].out, p, strlen (p)) != 0) { fail ("stringprep() entry %d failed\n", i); if (debug) printf ("ERROR\n"); } else if (debug) printf ("OK\n\n"); free (p); } else if (debug) printf ("OK\n\n"); } #if 0 { char p[20]; memset (p, 0, 10); stringprep_unichar_to_utf8 (0x00DF, p); hexprint (p, strlen (p)); puts (""); } #endif }
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"); }