本文整理汇总了C++中ISC_LINK_INIT函数的典型用法代码示例。如果您正苦于以下问题:C++ ISC_LINK_INIT函数的具体用法?C++ ISC_LINK_INIT怎么用?C++ ISC_LINK_INIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ISC_LINK_INIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup_entropy
void
setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) {
isc_result_t result;
isc_entropysource_t *source = NULL;
entropysource_t *elt;
int usekeyboard = ISC_ENTROPY_KEYBOARDMAYBE;
REQUIRE(ectx != NULL);
if (*ectx == NULL) {
result = isc_entropy_create(mctx, ectx);
if (result != ISC_R_SUCCESS)
fatal("could not create entropy object");
ISC_LIST_INIT(sources);
}
if (randomfile != NULL && strcmp(randomfile, "keyboard") == 0) {
usekeyboard = ISC_ENTROPY_KEYBOARDYES;
randomfile = NULL;
}
result = isc_entropy_usebestsource(*ectx, &source, randomfile,
usekeyboard);
if (result != ISC_R_SUCCESS)
fatal("could not initialize entropy source: %s",
isc_result_totext(result));
if (source != NULL) {
elt = isc_mem_get(mctx, sizeof(*elt));
if (elt == NULL)
fatal("out of memory");
elt->source = source;
elt->mctx = mctx;
ISC_LINK_INIT(elt, link);
ISC_LIST_APPEND(sources, elt, link);
}
}
示例2: tostruct_in_nsap_ptr
static inline isc_result_t
tostruct_in_nsap_ptr(ARGS_TOSTRUCT) {
isc_region_t region;
dns_rdata_in_nsap_ptr_t *nsap_ptr = target;
dns_name_t name;
REQUIRE(rdata->type == dns_rdatatype_nsap_ptr);
REQUIRE(rdata->rdclass == dns_rdataclass_in);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
nsap_ptr->common.rdclass = rdata->rdclass;
nsap_ptr->common.rdtype = rdata->type;
ISC_LINK_INIT(&nsap_ptr->common, link);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, ®ion);
dns_name_fromregion(&name, ®ion);
dns_name_init(&nsap_ptr->owner, NULL);
RETERR(name_duporclone(&name, mctx, &nsap_ptr->owner));
nsap_ptr->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例3: tostruct_x25
static inline isc_result_t
tostruct_x25(ARGS_TOSTRUCT) {
dns_rdata_x25_t *x25 = target;
isc_region_t r;
REQUIRE(rdata->type == dns_rdatatype_x25);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
x25->common.rdclass = rdata->rdclass;
x25->common.rdtype = rdata->type;
ISC_LINK_INIT(&x25->common, link);
dns_rdata_toregion(rdata, &r);
x25->x25_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
x25->x25 = mem_maybedup(mctx, r.base, x25->x25_len);
if (x25->x25 == NULL)
return (ISC_R_NOMEMORY);
x25->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例4: tostruct_in_aaaa
static inline isc_result_t tostruct_in_aaaa (ARGS_TOSTRUCT)
{
dns_rdata_in_aaaa_t *aaaa = target;
isc_region_t r;
REQUIRE (rdata->type == 28);
REQUIRE (rdata->rdclass == 1);
REQUIRE (target != NULL);
REQUIRE (rdata->length == 16);
UNUSED (mctx);
aaaa->common.rdclass = rdata->rdclass;
aaaa->common.rdtype = rdata->type;
ISC_LINK_INIT (&aaaa->common, link);
dns_rdata_toregion (rdata, &r);
INSIST (r.length == 16);
memcpy (aaaa->in6_addr.s6_addr, r.base, 16);
return (ISC_R_SUCCESS);
}
示例5: tostruct_in_dhcid
static inline isc_result_t
tostruct_in_dhcid(ARGS_TOSTRUCT) {
dns_rdata_in_dhcid_t *dhcid = target;
isc_region_t region;
REQUIRE(rdata->type == 49);
REQUIRE(rdata->rdclass == 1);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
dhcid->common.rdclass = rdata->rdclass;
dhcid->common.rdtype = rdata->type;
ISC_LINK_INIT(&dhcid->common, link);
dns_rdata_toregion(rdata, ®ion);
dhcid->dhcid = mem_maybedup(mctx, region.base, region.length);
if (dhcid->dhcid == NULL)
return (ISC_R_NOMEMORY);
dhcid->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例6: tostruct_in_nsap
static inline isc_result_t
tostruct_in_nsap(ARGS_TOSTRUCT) {
dns_rdata_in_nsap_t *nsap = target;
isc_region_t r;
REQUIRE(rdata->type == 22);
REQUIRE(rdata->rdclass == 1);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
nsap->common.rdclass = rdata->rdclass;
nsap->common.rdtype = rdata->type;
ISC_LINK_INIT(&nsap->common, link);
dns_rdata_toregion(rdata, &r);
nsap->nsap_len = r.length;
nsap->nsap = mem_maybedup(mctx, r.base, r.length);
if (nsap->nsap == NULL)
return (ISC_R_NOMEMORY);
nsap->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例7: controlkeylist_fromcfg
static isc_result_t
controlkeylist_fromcfg(const cfg_obj_t *keylist, isc_mem_t *mctx,
controlkeylist_t *keyids)
{
const cfg_listelt_t *element;
char *newstr = NULL;
const char *str;
const cfg_obj_t *obj;
controlkey_t *key;
for (element = cfg_list_first(keylist);
element != NULL;
element = cfg_list_next(element))
{
obj = cfg_listelt_value(element);
str = cfg_obj_asstring(obj);
newstr = isc_mem_strdup(mctx, str);
if (newstr == NULL)
goto cleanup;
key = isc_mem_get(mctx, sizeof(*key));
if (key == NULL)
goto cleanup;
key->keyname = newstr;
key->secret.base = NULL;
key->secret.length = 0;
ISC_LINK_INIT(key, link);
ISC_LIST_APPEND(*keyids, key, link);
newstr = NULL;
}
return (ISC_R_SUCCESS);
cleanup:
if (newstr != NULL)
isc_mem_free(mctx, newstr);
free_controlkeylist(keyids, mctx);
return (ISC_R_NOMEMORY);
}
示例8: dns_db_register
isc_result_t
dns_db_register(const char *name, dns_dbcreatefunc_t create, void *driverarg,
isc_mem_t *mctx, dns_dbimplementation_t **dbimp)
{
dns_dbimplementation_t *imp;
REQUIRE(name != NULL);
REQUIRE(dbimp != NULL && *dbimp == NULL);
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
RWLOCK(&implock, isc_rwlocktype_write);
imp = impfind(name);
if (imp != NULL) {
RWUNLOCK(&implock, isc_rwlocktype_write);
return (ISC_R_EXISTS);
}
imp = isc_mem_get(mctx, sizeof(dns_dbimplementation_t));
if (imp == NULL) {
RWUNLOCK(&implock, isc_rwlocktype_write);
return (ISC_R_NOMEMORY);
}
imp->name = name;
imp->create = create;
imp->mctx = NULL;
imp->driverarg = driverarg;
isc_mem_attach(mctx, &imp->mctx);
ISC_LINK_INIT(imp, link);
ISC_LIST_APPEND(implementations, imp, link);
RWUNLOCK(&implock, isc_rwlocktype_write);
*dbimp = imp;
return (ISC_R_SUCCESS);
}
示例9: tostruct_md
static inline isc_result_t tostruct_md (ARGS_TOSTRUCT)
{
dns_rdata_md_t *md = target;
isc_region_t r;
dns_name_t name;
REQUIRE (rdata->type == 3);
REQUIRE (target != NULL);
REQUIRE (rdata->length != 0);
md->common.rdclass = rdata->rdclass;
md->common.rdtype = rdata->type;
ISC_LINK_INIT (&md->common, link);
dns_name_init (&name, NULL);
dns_rdata_toregion (rdata, &r);
dns_name_fromregion (&name, &r);
dns_name_init (&md->md, NULL);
RETERR (name_duporclone (&name, mctx, &md->md));
md->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例10: tostruct_isdn
static inline isc_result_t
tostruct_isdn(ARGS_TOSTRUCT) {
dns_rdata_isdn_t *isdn = target;
isc_region_t r;
REQUIRE(rdata->type == 20);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
isdn->common.rdclass = rdata->rdclass;
isdn->common.rdtype = rdata->type;
ISC_LINK_INIT(&isdn->common, link);
dns_rdata_toregion(rdata, &r);
isdn->isdn_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
isdn->isdn = mem_maybedup(mctx, r.base, isdn->isdn_len);
if (isdn->isdn == NULL)
return (ISC_R_NOMEMORY);
isc_region_consume(&r, isdn->isdn_len);
isdn->subaddress_len = uint8_fromregion(&r);
isc_region_consume(&r, 1);
isdn->subaddress = mem_maybedup(mctx, r.base, isdn->subaddress_len);
if (isdn->subaddress == NULL)
goto cleanup;
isdn->mctx = mctx;
return (ISC_R_SUCCESS);
cleanup:
if (mctx != NULL && isdn->isdn != NULL)
isc_mem_free(mctx, isdn->isdn);
return (ISC_R_NOMEMORY);
}
示例11: tostruct_lp
static inline isc_result_t
tostruct_lp(ARGS_TOSTRUCT) {
isc_region_t region;
dns_rdata_lp_t *lp = target;
dns_name_t name;
REQUIRE(rdata->type == dns_rdatatype_lp);
REQUIRE(target != NULL);
REQUIRE(rdata->length != 0);
lp->common.rdclass = rdata->rdclass;
lp->common.rdtype = rdata->type;
ISC_LINK_INIT(&lp->common, link);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, ®ion);
lp->pref = uint16_fromregion(®ion);
isc_region_consume(®ion, 2);
dns_name_fromregion(&name, ®ion);
dns_name_init(&lp->lp, NULL);
RETERR(name_duporclone(&name, mctx, &lp->lp));
lp->mctx = mctx;
return (ISC_R_SUCCESS);
}
示例12: listener_create
static isc_result_t
listener_create(isc_mem_t *mctx, ns_lwresd_t *lwresd,
ns_lwreslistener_t **listenerp)
{
ns_lwreslistener_t *listener;
isc_result_t result;
REQUIRE(listenerp != NULL && *listenerp == NULL);
listener = isc_mem_get(mctx, sizeof(ns_lwreslistener_t));
if (listener == NULL)
return (ISC_R_NOMEMORY);
result = isc_mutex_init(&listener->lock);
if (result != ISC_R_SUCCESS) {
isc_mem_put(mctx, listener, sizeof(ns_lwreslistener_t));
return (result);
}
listener->magic = LWRESLISTENER_MAGIC;
listener->refs = 1;
listener->sock = NULL;
listener->manager = NULL;
ns_lwdmanager_attach(lwresd, &listener->manager);
listener->mctx = NULL;
isc_mem_attach(mctx, &listener->mctx);
ISC_LINK_INIT(listener, link);
ISC_LIST_INIT(listener->cmgrs);
*listenerp = listener;
return (ISC_R_SUCCESS);
}
示例13: main
int
main(int argc, char *argv[]) {
int i, ch, error;
struct addrinfo hints, *res;
isc_result_t result;
isc_sockaddr_t sa;
isc_sockaddrlist_t servers;
isc_taskmgr_t *taskmgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
isc_timermgr_t *timermgr = NULL;
while ((ch = getopt(argc, argv, "c:dhv")) != -1) {
switch (ch) {
case 'c':
cacheserver = optarg;
break;
case 'd':
debug_mode = ISC_TRUE;
break;
case 'h':
usage();
break;
case 'v':
verbose_level++;
break;
default:
usage();
break;
}
}
argc -= optind;
argv += optind;
/* Common set up */
isc_lib_register();
result = dns_lib_init();
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "dns_lib_init failed: %d\n", result);
exit(1);
}
result = ctxs_init(&mctx, &actx, &taskmgr, &socketmgr,
&timermgr);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "ctx create failed: %d\n", result);
exit(1);
}
isc_app_ctxstart(actx);
result = dns_client_createx(mctx, actx, taskmgr, socketmgr,
timermgr, 0, &client);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "dns_client_createx failed: %d\n", result);
exit(1);
}
/* Set local cache server */
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
error = getaddrinfo(cacheserver, "53", &hints, &res);
if (error != 0) {
fprintf(stderr, "failed to convert server name (%s): %s\n",
cacheserver, gai_strerror(error));
exit(1);
}
if (res->ai_addrlen > sizeof(sa.type)) {
fprintf(stderr,
"assumption failure: addrlen is too long: %ld\n",
(long)res->ai_addrlen);
exit(1);
}
memcpy(&sa.type.sa, res->ai_addr, res->ai_addrlen);
sa.length = res->ai_addrlen;
freeaddrinfo(res);
ISC_LINK_INIT(&sa, link);
ISC_LIST_INIT(servers);
ISC_LIST_APPEND(servers, &sa, link);
result = dns_client_setservers(client, dns_rdataclass_in, NULL,
&servers);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "failed to set server: %d\n", result);
exit(1);
}
/* Create the main task */
probe_task = NULL;
result = isc_task_create(taskmgr, 0, &probe_task);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "failed to create task: %d\n", result);
exit(1);
}
/* Open input file */
if (argc == 0)
fp = stdin;
else {
//.........这里部分代码省略.........
示例14: ns_interface_create
static isc_result_t
ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
const char *name, ns_interface_t **ifpret)
{
ns_interface_t *ifp;
isc_result_t result;
int disp;
REQUIRE(NS_INTERFACEMGR_VALID(mgr));
ifp = isc_mem_get(mgr->mctx, sizeof(*ifp));
if (ifp == NULL)
return (ISC_R_NOMEMORY);
ifp->mgr = NULL;
ifp->generation = mgr->generation;
ifp->addr = *addr;
ifp->flags = 0;
strncpy(ifp->name, name, sizeof(ifp->name));
ifp->name[sizeof(ifp->name)-1] = '\0';
ifp->clientmgr = NULL;
result = isc_mutex_init(&ifp->lock);
if (result != ISC_R_SUCCESS)
goto lock_create_failure;
result = ns_clientmgr_create(mgr->mctx, mgr->taskmgr,
ns_g_timermgr,
&ifp->clientmgr);
if (result != ISC_R_SUCCESS) {
isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_ERROR,
"ns_clientmgr_create() failed: %s",
isc_result_totext(result));
goto clientmgr_create_failure;
}
for (disp = 0; disp < MAX_UDP_DISPATCH; disp++)
ifp->udpdispatch[disp] = NULL;
ifp->tcpsocket = NULL;
/*
* Create a single TCP client object. It will replace itself
* with a new one as soon as it gets a connection, so the actual
* connections will be handled in parallel even though there is
* only one client initially.
*/
ifp->ntcptarget = 1;
ifp->ntcpcurrent = 0;
ifp->nudpdispatch = 0;
ISC_LINK_INIT(ifp, link);
ns_interfacemgr_attach(mgr, &ifp->mgr);
ISC_LIST_APPEND(mgr->interfaces, ifp, link);
ifp->references = 1;
ifp->magic = IFACE_MAGIC;
*ifpret = ifp;
return (ISC_R_SUCCESS);
clientmgr_create_failure:
DESTROYLOCK(&ifp->lock);
lock_create_failure:
ifp->magic = 0;
isc_mem_put(mgr->mctx, ifp, sizeof(*ifp));
return (ISC_R_UNEXPECTED);
}
示例15: isc__timer_create
ISC_TIMERFUNC_SCOPE isc_result_t
isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
isc_time_t *expires, isc_interval_t *interval,
isc_task_t *task, isc_taskaction_t action, const void *arg,
isc_timer_t **timerp)
{
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
isc__timer_t *timer;
isc_result_t result;
isc_time_t now;
/*
* Create a new 'type' timer managed by 'manager'. The timers
* parameters are specified by 'expires' and 'interval'. Events
* will be posted to 'task' and when dispatched 'action' will be
* called with 'arg' as the arg value. The new timer is returned
* in 'timerp'.
*/
REQUIRE(VALID_MANAGER(manager));
REQUIRE(task != NULL);
REQUIRE(action != NULL);
if (expires == NULL)
expires = isc_time_epoch;
if (interval == NULL)
interval = isc_interval_zero;
REQUIRE(type == isc_timertype_inactive ||
!(isc_time_isepoch(expires) && isc_interval_iszero(interval)));
REQUIRE(timerp != NULL && *timerp == NULL);
REQUIRE(type != isc_timertype_limited ||
!(isc_time_isepoch(expires) || isc_interval_iszero(interval)));
/*
* Get current time.
*/
if (type != isc_timertype_inactive) {
TIME_NOW(&now);
} else {
/*
* We don't have to do this, but it keeps the compiler from
* complaining about "now" possibly being used without being
* set, even though it will never actually happen.
*/
isc_time_settoepoch(&now);
}
timer = isc_mem_get(manager->mctx, sizeof(*timer));
if (timer == NULL)
return (ISC_R_NOMEMORY);
timer->manager = manager;
timer->references = 1;
if (type == isc_timertype_once && !isc_interval_iszero(interval)) {
result = isc_time_add(&now, interval, &timer->idle);
if (result != ISC_R_SUCCESS) {
isc_mem_put(manager->mctx, timer, sizeof(*timer));
return (result);
}
} else
isc_time_settoepoch(&timer->idle);
timer->type = type;
timer->expires = *expires;
timer->interval = *interval;
timer->task = NULL;
isc_task_attach(task, &timer->task);
timer->action = action;
/*
* Removing the const attribute from "arg" is the best of two
* evils here. If the timer->arg member is made const, then
* it affects a great many recipients of the timer event
* which did not pass in an "arg" that was truly const.
* Changing isc_timer_create() to not have "arg" prototyped as const,
* though, can cause compilers warnings for calls that *do*
* have a truly const arg. The caller will have to carefully
* keep track of whether arg started as a true const.
*/
DE_CONST(arg, timer->arg);
timer->index = 0;
result = isc_mutex_init(&timer->lock);
if (result != ISC_R_SUCCESS) {
isc_task_detach(&timer->task);
isc_mem_put(manager->mctx, timer, sizeof(*timer));
return (result);
}
ISC_LINK_INIT(timer, link);
timer->common.impmagic = TIMER_MAGIC;
timer->common.magic = ISCAPI_TIMER_MAGIC;
timer->common.methods = (isc_timermethods_t *)&timermethods;
LOCK(&manager->lock);
/*
* Note we don't have to lock the timer like we normally would because
* there are no external references to it yet.
*/
if (type != isc_timertype_inactive)
//.........这里部分代码省略.........