[getdns-api] Capability and version checking

Phil Pennock getdns-api-phil
Tue Jan 29 04:47:44 CET 2013


On 2013-01-28 at 19:05 -0800, Paul Hoffman wrote:
> On Jan 28, 2013, at 6:36 PM, Phil Pennock <getdns-api-phil at spodhuis.org> wrote:
> 
> > On 2013-01-28 at 17:36 -0800, Paul Hoffman wrote:
> >> On Jan 28, 2013, at 5:08 PM, Phil Pennock <getdns-api-phil at spodhuis.org> wrote:
> >>> I'm not seeing guaranteed compile-time constants for detecting
> >>> compile-vs-runtime differences?
> >> 
> >> Please say more about these differences.
> > 
> > % exim -d --version
> > Library version: SQLite: Compile: 3.7.14
> >                         Runtime: 3.7.14.1
> > 
> > More generally, you're currently documenting an API, not an ABI.  A
> > release change could move something to be a macro around a function with
> > a different name and the API would be preserved.
> 
> Exactly right. See "implementation_string" in Section 3.5. Do you need
> something more than that? If so, please specify.

Yes: something which doesn't involve the application _calling_ code to
get the current version, but which permits the compiled application to
contain an identifier which is static.

This is normally done with a CPP macro.

Examples of the code used in Exim right now are below; there's a couple
more, but they're not substantively different.  The last couple shown
demonstrate how we export Exim's compile time version for lookups built
as dynamically loadable modules, which should only be used by OS
packagers when permitting one package to be used with various other
libraries without making them hard package dependencies: nothing breaks,
if the ABI didn't change, but we don't guarantee module lookups to be
portable between releases and they _should_ be replaced each time.

This is the sort of thing which makes it easier to figure out what has
gone wrong when things go wrong.

Regards,
-Phil

----------------------------8< cut here >8------------------------------
void
auth_cyrus_sasl_version_report(FILE *f)
{
  const char *implementation, *version;
  sasl_version_info(&implementation, &version, NULL, NULL, NULL, NULL);
  fprintf(f, "Library version: Cyrus SASL: Compile: %d.%d.%d\n"
             "                             Runtime: %s [%s]\n",
          SASL_VERSION_MAJOR, SASL_VERSION_MINOR, SASL_VERSION_STEP,
          version, implementation);
}
----------------------------8< cut here >8------------------------------

----------------------------8< cut here >8------------------------------
void
auth_gsasl_version_report(FILE *f)
{
  const char *runtime;
  runtime = gsasl_check_version(NULL);
  fprintf(f, "Library version: GNU SASL: Compile: %s\n"
             "                           Runtime: %s\n",
          GSASL_VERSION, runtime);
}
----------------------------8< cut here >8------------------------------

----------------------------8< cut here >8------------------------------
#ifndef PCRE_PRERELEASE
#define PCRE_PRERELEASE
#endif
#define QUOTE(X) #X
#define EXPAND_AND_QUOTE(X) QUOTE(X)
  fprintf(f, "Library version: PCRE: Compile: %d.%d%s\n"
             "                       Runtime: %s\n",
          PCRE_MAJOR, PCRE_MINOR,
          EXPAND_AND_QUOTE(PCRE_PRERELEASE) "",
          pcre_version());
----------------------------8< cut here >8------------------------------

----------------------------8< cut here >8------------------------------
void
mysql_version_report(FILE *f)
{
fprintf(f, "Library version: MySQL: Compile: %s [%s]\n"
           "                        Runtime: %s\n",
        MYSQL_SERVER_VERSION, MYSQL_COMPILATION_COMMENT,
        mysql_get_client_info());
#ifdef DYNLOOKUP
fprintf(f, "                        Exim version %s\n", EXIM_VERSION_STR);
#endif
}
----------------------------8< cut here >8------------------------------

----------------------------8< cut here >8------------------------------
void
sqlite_version_report(FILE *f)
{
fprintf(f, "Library version: SQLite: Compile: %s\n"
           "                         Runtime: %s\n",
        SQLITE_VERSION, sqlite3_libversion());
#ifdef DYNLOOKUP
fprintf(f, "                         Exim version %s\n", EXIM_VERSION_STR);
#endif
}
----------------------------8< cut here >8------------------------------



More information about the spec mailing list