diff --git a/docs/libcurl/curl_version_info.3 b/docs/libcurl/curl_version_info.3 index 83becb608..cc14c0e59 100644 --- a/docs/libcurl/curl_version_info.3 +++ b/docs/libcurl/curl_version_info.3 @@ -2,17 +2,23 @@ .\" nroff -man [file] .\" $Id$ .\" -.TH curl_version_info 3 "25 Sep 2002" "libcurl 7.10" "libcurl Manual" +.TH curl_version_info 3 "30 Sep 2002" "libcurl 7.10" "libcurl Manual" .SH NAME curl_version_info - returns run-time libcurl version info .SH SYNOPSIS .B #include .sp -.BI "curl_version_info_data *curl_version_info( );" +.BI "curl_version_info_data *curl_version_info( CURLversion "type ");" .ad .SH DESCRIPTION Returns a pointer to a filled in struct with information about various -run-time features in libcurl. +run-time features in libcurl. \fItype\fP should be set to the version of this +functionality by the time you write your program. This way, libcurl will +always return a proper struct that your program understands, while programs in +the future might get an different struct. CURLVERSION_NOW will be the most +recent one for the library you have installed: + + data = curl_version_info(CURLVERSION_NOW); Applications should use this information to judge if things are possible to do or not, instead of using compile-time checks, as dynamic/DLL libraries can be @@ -22,6 +28,7 @@ The curl_version_info_data struct looks like this .nf typedef struct { + CURLversion age; /* 0 - this kind of struct */ const char *version; /* human readable string */ unsigned int version_num; /* numeric representation */ const char *host; /* human readable string */ @@ -33,6 +40,11 @@ typedef struct { } curl_version_info_data; .fi +\fIage\fP describes what kind of struct this is. It is always 0 now. In a +future libcurl, if this struct changes, this age counter may be increased, and +then the struct for number 1 will look different (except for this first struct +field). + \fIversion\fP is just an ascii string for the libcurl version. \fIversion_num\fP is a 6 digit hexadecimal number created like this: <2 digits diff --git a/include/curl/curl.h b/include/curl/curl.h index e5ba70379..43534cea5 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -688,7 +688,8 @@ int curl_formparse(char *, struct curl_httppost **, #undef CFINIT #endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) +#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ + defined(__HP_aCC) #define CFINIT(name) CURLFORM_ ## name #else /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ @@ -916,7 +917,20 @@ CURLcode curl_share_destroy (curl_share *); * Structures for querying information about the curl library at runtime. */ +typedef enum { + CURLVERSION_FIRST, + CURLVERSION_LAST /* never actually use this */ +} CURLversion; + +/* The 'CURLVERSION_NOW' is the symbolic name meant to be used by + basicly all programs ever, that want to get version information. It is + meant to be a built-in version number for what kind of struct the caller + expects. If the struct ever changes, we redfine the NOW to another enum + from above. */ +#define CURLVERSION_NOW CURLVERSION_FIRST + typedef struct { + CURLversion age; /* age of the returned struct */ const char *version; /* LIBCURL_VERSION */ unsigned int version_num; /* LIBCURL_VERSION_NUM */ const char *host; /* OS/host/cpu/machine when configured */ @@ -925,7 +939,7 @@ typedef struct { long ssl_version_num; /* number */ const char *libz_version; /* human readable string */ /* protocols is terminated by an entry with a NULL protoname */ - const char *protocols[1]; + const char **protocols; } curl_version_info_data; #define CURL_VERSION_IPV6 (1<<0) @@ -934,7 +948,7 @@ typedef struct { #define CURL_VERSION_LIBZ (1<<3) /* returns a pointer to a static copy of the version info struct */ -curl_version_info_data *curl_version_info(void); +curl_version_info_data *curl_version_info(CURLversion); #ifdef __cplusplus } diff --git a/lib/version.c b/lib/version.c index 33cea4619..41a71bfcc 100644 --- a/lib/version.c +++ b/lib/version.c @@ -122,39 +122,40 @@ char *curl_version(void) static const char *protocols[] = { #ifndef CURL_DISABLE_FTP - { "ftp" }, + "ftp", #endif #ifndef CURL_DISABLE_GOPHER - { "gopher" }, + "gopher", #endif #ifndef CURL_DISABLE_TELNET - { "telnet" }, + "telnet", #endif #ifndef CURL_DISABLE_DICT - { "dict" }, + "dict", #endif #ifndef CURL_DISABLE_LDAP - { "ldap" }, + "ldap", #endif #ifndef CURL_DISABLE_HTTP - { "http" }, + "http", #endif #ifndef CURL_DISABLE_FILE - { "file" }, + "file", #endif #ifdef USE_SSLEAY #ifndef CURL_DISABLE_HTTP - { "https" }, + "https", #endif #ifndef CURL_DISABLE_FTP - { "ftps" }, + "ftps", #endif #endif - { NULL } + NULL }; static curl_version_info_data version_info = { + CURLVERSION_FIRST, LIBCURL_VERSION, LIBCURL_VERSION_NUM, OS, /* as found by configure or set by hand at build-time */ @@ -178,7 +179,7 @@ static curl_version_info_data version_info = { protocols }; -curl_version_info_data *curl_version_info(void) +curl_version_info_data *curl_version_info(CURLversion stamp) { #ifdef USE_SSLEAY static char ssl_buffer[80]; @@ -194,6 +195,7 @@ curl_version_info_data *curl_version_info(void) version_info.libz_version = zlibVersion(); /* libz left NULL if non-existing */ #endif + (void)stamp; /* avoid compiler warnings, we don't use this */ return &version_info; }