dyndb.c revision f503aa345b451f94875a5bab637223bcbbd93b6d
/*
* Copyright (C) 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <config.h>
#if HAVE_DLFCN_H
#include <dlfcn.h>
#include <windows.h>
#endif
#include <string.h>
} while (0)
typedef struct dyndb_implementation dyndb_implementation_t;
struct dyndb_implementation {
void *handle;
char *name;
void *inst;
};
/*
* List of dyndb implementations. Locked by dyndb_lock.
*
* These are stored here so they can be cleaned up on shutdown.
* (The order in which they are stored is not important.)
*/
/* Locks dyndb_implementations. */
static isc_mutex_t dyndb_lock;
static void
dyndb_initialize(void) {
}
static dyndb_implementation_t *
return (imp);
return (NULL);
}
#if HAVE_DLFCN_H
static isc_result_t
const char *symbol_name, void **symbolp)
{
const char *errmsg;
void *symbol;
errmsg = "returned function pointer is NULL";
"failed to lookup symbol %s in "
"dyndb module '%s': %s",
return (ISC_R_FAILURE);
}
dlerror();
return (ISC_R_SUCCESS);
}
static isc_result_t
{
"loading DynDB instance '%s' driver '%s'",
#ifdef RTLD_DEEPBIND
flags |= RTLD_DEEPBIND;
#endif
/* Clear dlerror */
dlerror();
(void **)&version_func));
{
"driver API version mismatch: %d/%d",
}
(void **)®ister_func));
(void **)&destroy_func));
if (result != ISC_R_SUCCESS)
"failed to dynamically load instance '%s' "
return (result);
}
static void
}
static isc_result_t
const char *symbol_name, void **symbolp)
{
void *symbol;
int errstatus = GetLastError();
"failed to lookup symbol %s in "
"dyndb module '%s': %d",
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
{
int version;
"loading DynDB instance '%s' driver '%s'",
(void **)&version_func));
{
"driver API version mismatch: %d/%d",
}
(void **)®ister_func));
(void **)&destroy_func));
if (result != ISC_R_SUCCESS)
"failed to dynamically load instance '%s' "
return (result);
}
static void
}
#else /* HAVE_DLFCN_H || _WIN32 */
static isc_result_t
{
"dynamic database support is not implemented");
return (ISC_R_NOTIMPLEMENTED);
}
static void
{
}
#endif /* HAVE_DLFCN_H */
const dns_dyndbctx_t *dctx)
{
LOCK(&dyndb_lock);
/* duplicate instance names are not allowed */
if (result != ISC_R_SUCCESS)
if (implementation != NULL)
UNLOCK(&dyndb_lock);
return (result);
}
void
LOCK(&dyndb_lock);
}
UNLOCK(&dyndb_lock);
}
{
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
void
}