本文整理汇总了C++中REQUIRE函数 的典型用法代码示例。如果您正苦于以下问题:C++ REQUIRE函数的具体用法?C++ REQUIRE怎么用?C++ REQUIRE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了REQUIRE函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: internal_current6
static isc_result_t
internal_current6(isc_interfaceiter_t *iter) {
struct LIFREQ *ifrp;
struct LIFREQ lifreq;
int family;
char strbuf[ISC_STRERRORSIZE];
int fd;
REQUIRE(VALID_IFITER(iter));
if (iter->result6 != ISC_R_SUCCESS)
return (iter->result6);
REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
memset(&lifreq, 0, sizeof(lifreq));
memmove(&lifreq, ifrp, sizeof(lifreq));
family = lifreq.lifr_addr.ss_family;
#ifdef ISC_PLATFORM_HAVEIPV6
if (family != AF_INET && family != AF_INET6)
#else
if (family != AF_INET)
#endif
return (ISC_R_IGNORE);
memset(&iter->current, 0, sizeof(iter->current));
iter->current.af = family;
INSIST(sizeof(lifreq.lifr_name) <= sizeof(iter->current.name));
memset(iter->current.name, 0, sizeof(iter->current.name));
memmove(iter->current.name, lifreq.lifr_name, sizeof(lifreq.lifr_name));
get_addr(family, &iter->current.address,
(struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
/*
* If the interface does not have a address ignore it.
*/
switch (family) {
case AF_INET:
if (iter->current.address.type.in.s_addr == htonl(INADDR_ANY))
return (ISC_R_IGNORE);
break;
case AF_INET6:
if (memcmp(&iter->current.address.type.in6, &in6addr_any,
sizeof(in6addr_any)) == 0)
return (ISC_R_IGNORE);
break;
}
/*
* Get interface flags.
*/
iter->current.flags = 0;
if (family == AF_INET6)
fd = iter->socket6;
else
fd = iter->socket;
/*
* Ignore the HP/UX warning about "integer overflow during
* conversion. It comes from its own macro definition,
* and is really hard to shut up.
*/
if (ioctl(fd, SIOCGLIFFLAGS, (char *) &lifreq) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"%s: getting interface flags: %s",
lifreq.lifr_name, strbuf);
return (ISC_R_IGNORE);
}
if ((lifreq.lifr_flags & IFF_UP) != 0)
iter->current.flags |= INTERFACE_F_UP;
#ifdef IFF_POINTOPOINT
if ((lifreq.lifr_flags & IFF_POINTOPOINT) != 0)
iter->current.flags |= INTERFACE_F_POINTTOPOINT;
#endif
if ((lifreq.lifr_flags & IFF_LOOPBACK) != 0)
iter->current.flags |= INTERFACE_F_LOOPBACK;
#ifdef IFF_POINTOPOINT
/*
* If the interface is point-to-point, get the destination address.
*/
if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
/*
* Ignore the HP/UX warning about "integer overflow during
* conversion. It comes from its own macro definition,
* and is really hard to shut up.
*/
if (ioctl(fd, SIOCGLIFDSTADDR, (char *)&lifreq)
< 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
//.........这里部分代码省略.........
开发者ID:enukane, 项目名称:netbsd-src, 代码行数:101, 代码来源:ifiter_ioctl.c
示例2: isc_taskmgr_setmode
void
isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode) {
REQUIRE(ISCAPI_TASKMGR_VALID(manager));
manager->methods->setmode(manager, mode);
}
开发者ID:gosudream, 项目名称:netbsd-src, 代码行数:6, 代码来源:task_api.c
示例3: lwres_getnamebyaddr
/*% Used to perform reverse lookups. */
lwres_result_t
lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype,
lwres_uint16_t addrlen, const unsigned char *addr,
lwres_gnbaresponse_t **structp)
{
lwres_gnbarequest_t request;
lwres_gnbaresponse_t *response;
int ret;
int recvlen;
lwres_buffer_t b_in, b_out;
lwres_lwpacket_t pkt;
lwres_uint32_t serial;
char *buffer;
REQUIRE(ctx != NULL);
REQUIRE(addrtype != 0);
REQUIRE(addrlen != 0);
REQUIRE(addr != NULL);
REQUIRE(structp != NULL && *structp == NULL);
b_in.base = NULL;
b_out.base = NULL;
response = NULL;
buffer = NULL;
serial = lwres_context_nextserial(ctx);
buffer = CTXMALLOC(LWRES_RECVLENGTH);
if (buffer == NULL) {
ret = LWRES_R_NOMEMORY;
goto out;
}
/*
* Set up our request and render it to a buffer.
*/
request.flags = 0;
request.addr.family = addrtype;
request.addr.length = addrlen;
memmove(request.addr.address, addr, addrlen);
pkt.pktflags = 0;
pkt.serial = serial;
pkt.result = 0;
pkt.recvlength = LWRES_RECVLENGTH;
again:
ret = lwres_gnbarequest_render(ctx, &request, &pkt, &b_out);
if (ret != LWRES_R_SUCCESS)
goto out;
ret = lwres_context_sendrecv(ctx, b_out.base, b_out.length, buffer,
LWRES_RECVLENGTH, &recvlen);
if (ret != LWRES_R_SUCCESS)
goto out;
lwres_buffer_init(&b_in, buffer, recvlen);
b_in.used = recvlen;
/*
* Parse the packet header.
*/
ret = lwres_lwpacket_parseheader(&b_in, &pkt);
if (ret != LWRES_R_SUCCESS)
goto out;
/*
* Sanity check.
*/
if (pkt.serial != serial)
goto again;
if (pkt.opcode != LWRES_OPCODE_GETNAMEBYADDR)
goto again;
/*
* Free what we've transmitted
*/
CTXFREE(b_out.base, b_out.length);
b_out.base = NULL;
b_out.length = 0;
if (pkt.result != LWRES_R_SUCCESS) {
ret = pkt.result;
goto out;
}
/*
* Parse the response.
*/
ret = lwres_gnbaresponse_parse(ctx, &b_in, &pkt, &response);
if (ret != LWRES_R_SUCCESS)
goto out;
response->base = buffer;
response->baselen = LWRES_RECVLENGTH;
buffer = NULL; /* don't free this below */
*structp = response;
return (LWRES_R_SUCCESS);
out:
if (b_out.base != NULL)
//.........这里部分代码省略.........
开发者ID:crossbuild, 项目名称:bind, 代码行数:101, 代码来源:lwresutil.c
示例4: isc_interfaceiter_create
isc_result_t
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
isc_interfaceiter_t *iter;
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
REQUIRE(mctx != NULL);
REQUIRE(iterp != NULL);
REQUIRE(*iterp == NULL);
iter = isc_mem_get(mctx, sizeof(*iter));
if (iter == NULL)
return (ISC_R_NOMEMORY);
iter->mctx = mctx;
iter->mode = 4;
iter->buf = NULL;
iter->pos = (unsigned int) -1;
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
iter->buf6 = NULL;
iter->pos6 = (unsigned int) -1;
iter->result6 = ISC_R_NOMORE;
iter->socket6 = -1;
iter->first6 = ISC_FALSE;
#endif
/*
* Get the interface configuration, allocating more memory if
* necessary.
*/
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
result = isc_net_probeipv6();
if (result == ISC_R_SUCCESS) {
/*
* Create an unbound datagram socket to do the SIOCGLIFCONF
* ioctl on. HP/UX requires an AF_INET6 socket for
* SIOCGLIFCONF to get IPv6 addresses.
*/
if ((iter->socket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_IFITERIOCTL,
ISC_MSG_MAKESCANSOCKET,
"making interface "
"scan socket: %s"),
strbuf);
result = ISC_R_UNEXPECTED;
goto socket6_failure;
}
result = iter->result6 = getbuf6(iter);
if (result != ISC_R_NOTIMPLEMENTED && result != ISC_R_SUCCESS)
goto ioctl6_failure;
}
#endif
if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_IFITERIOCTL,
ISC_MSG_MAKESCANSOCKET,
"making interface "
"scan socket: %s"),
strbuf);
result = ISC_R_UNEXPECTED;
goto socket_failure;
}
result = getbuf4(iter);
if (result != ISC_R_SUCCESS)
goto ioctl_failure;
/*
* A newly created iterator has an undefined position
* until isc_interfaceiter_first() is called.
*/
#ifdef HAVE_TRUCLUSTER
iter->clua_context = -1;
iter->clua_done = ISC_TRUE;
#endif
#ifdef __linux
iter->proc = fopen("/proc/net/if_inet6", "r");
iter->valid = ISC_R_FAILURE;
#endif
iter->result = ISC_R_FAILURE;
iter->magic = IFITER_MAGIC;
*iterp = iter;
return (ISC_R_SUCCESS);
ioctl_failure:
if (iter->buf != NULL)
isc_mem_put(mctx, iter->buf, iter->bufsize);
(void) close(iter->socket);
socket_failure:
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
if (iter->buf6 != NULL)
isc_mem_put(mctx, iter->buf6, iter->bufsize6);
ioctl6_failure:
//.........这里部分代码省略.........
开发者ID:enukane, 项目名称:netbsd-src, 代码行数:101, 代码来源:ifiter_ioctl.c
示例5: dns_view_create
isc_result_t
dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
const char *name, dns_view_t **viewp)
{
dns_view_t *view;
isc_result_t result;
/*
* Create a view.
*/
REQUIRE(name != NULL);
REQUIRE(viewp != NULL && *viewp == NULL);
view = isc_mem_get(mctx, sizeof(*view));
if (view == NULL)
return (ISC_R_NOMEMORY);
view->mctx = NULL;
isc_mem_attach(mctx, &view->mctx);
view->name = isc_mem_strdup(mctx, name);
if (view->name == NULL) {
result = ISC_R_NOMEMORY;
goto cleanup_view;
}
result = isc_mutex_init(&view->lock);
if (result != ISC_R_SUCCESS)
goto cleanup_name;
view->zonetable = NULL;
if (isc_bind9) {
result = dns_zt_create(mctx, rdclass, &view->zonetable);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"dns_zt_create() failed: %s",
isc_result_totext(result));
result = ISC_R_UNEXPECTED;
goto cleanup_mutex;
}
}
view->secroots_priv = NULL;
view->fwdtable = NULL;
result = dns_fwdtable_create(mctx, &view->fwdtable);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"dns_fwdtable_create() failed: %s",
isc_result_totext(result));
result = ISC_R_UNEXPECTED;
goto cleanup_zt;
}
view->acache = NULL;
view->cache = NULL;
view->cachedb = NULL;
ISC_LIST_INIT(view->dlz_searched);
ISC_LIST_INIT(view->dlz_unsearched);
view->hints = NULL;
view->resolver = NULL;
view->adb = NULL;
view->requestmgr = NULL;
view->rdclass = rdclass;
view->frozen = ISC_FALSE;
view->task = NULL;
result = isc_refcount_init(&view->references, 1);
if (result != ISC_R_SUCCESS)
goto cleanup_fwdtable;
view->weakrefs = 0;
view->attributes = (DNS_VIEWATTR_RESSHUTDOWN|DNS_VIEWATTR_ADBSHUTDOWN|
DNS_VIEWATTR_REQSHUTDOWN);
view->statickeys = NULL;
view->dynamickeys = NULL;
view->matchclients = NULL;
view->matchdestinations = NULL;
view->matchrecursiveonly = ISC_FALSE;
result = dns_tsigkeyring_create(view->mctx, &view->dynamickeys);
if (result != ISC_R_SUCCESS)
goto cleanup_references;
view->peers = NULL;
view->order = NULL;
view->delonly = NULL;
view->rootdelonly = ISC_FALSE;
view->rootexclude = NULL;
view->adbstats = NULL;
view->resstats = NULL;
view->resquerystats = NULL;
view->cacheshared = ISC_FALSE;
ISC_LIST_INIT(view->dns64);
view->dns64cnt = 0;
/*
* Initialize configuration data with default values.
*/
view->recursion = ISC_TRUE;
view->auth_nxdomain = ISC_FALSE; /* Was true in BIND 8 */
view->additionalfromcache = ISC_TRUE;
view->additionalfromauth = ISC_TRUE;
view->enablednssec = ISC_TRUE;
view->enablevalidation = ISC_TRUE;
view->acceptexpired = ISC_FALSE;
view->minimalresponses = ISC_FALSE;
//.........这里部分代码省略.........
开发者ID:SvenDowideit, 项目名称:clearlinux, 代码行数:101, 代码来源:view.c
示例6: check_serialization_result
void check_serialization_result(const char (&expected)[size], const reply* r)
{
mock_stream i;
serialize(r, i);
REQUIRE(std::equal(begin(i.input_buffer), end(i.input_buffer), begin(expected), end(expected)));
}
开发者ID:summerlight, 项目名称:redis-cpp, 代码行数:6, 代码来源:parser_test.cpp
示例7: TEST_CASE
TEST_CASE("Test req const, ref and copy handling", "[request]")
{
served::uri uri;
uri.set_URI("/base/path?id=1");
served::request req;
req.set_destination(uri);
req.set_HTTP_version("HTTP/1.1");
req.set_source("127.0.0.1");
req.set_header("header1", "header one");
req.set_body("hello world");
auto test_copy = [](served::request r)
{
REQUIRE( r.url().URI() == "/base/path?id=1" );
REQUIRE( r.source() == "127.0.0.1" );
REQUIRE( r.header("header1") == "header one" );
REQUIRE( r.body() == "hello world" );
served::uri uri2;
uri2.set_URI("/foo/bar?id=2");
r.set_destination(uri2);
r.set_source("192.168.0.45");
r.set_header("header1", "new header one");
r.set_body("hello second world");
REQUIRE( r.url().URI() == "/foo/bar?id=2" );
REQUIRE( r.source() == "192.168.0.45" );
REQUIRE( r.header("header1") == "new header one" );
开发者ID:datasift, 项目名称:served, 代码行数:30, 代码来源:request.test.cpp
示例8: fromtext_keydata
static inline isc_result_t
fromtext_keydata(ARGS_FROMTEXT) {
isc_result_t result;
isc_token_t token;
dns_secalg_t alg;
dns_secproto_t proto;
dns_keyflags_t flags;
isc_uint32_t refresh, addhd, removehd;
REQUIRE(type == 65533);
UNUSED(type);
UNUSED(rdclass);
UNUSED(origin);
UNUSED(options);
UNUSED(callbacks);
/* refresh timer */
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &refresh));
RETERR(uint32_tobuffer(refresh, target));
/* add hold-down */
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &addhd));
RETERR(uint32_tobuffer(addhd, target));
/* remove hold-down */
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &removehd));
RETERR(uint32_tobuffer(removehd, target));
/* flags */
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
RETTOK(dns_keyflags_fromtext(&flags, &token.value.as_textregion));
RETERR(uint16_tobuffer(flags, target));
/* protocol */
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
RETTOK(dns_secproto_fromtext(&proto, &token.value.as_textregion));
RETERR(mem_tobuffer(target, &proto, 1));
/* algorithm */
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion));
RETERR(mem_tobuffer(target, &alg, 1));
/* No Key? */
if ((flags & 0xc000) == 0xc000)
return (ISC_R_SUCCESS);
result = isc_base64_tobuffer(lexer, target, -1);
if (result != ISC_R_SUCCESS)
return (result);
/* Ensure there's at least enough data to compute a key ID for MD5 */
if (alg == DST_ALG_RSAMD5 && isc_buffer_usedlength(target) < 19)
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
}
开发者ID:enukane, 项目名称:netbsd-src, 代码行数:67, 代码来源:keydata_65533.c
示例9: lookup_find
static void
lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event) {
isc_result_t result;
isc_boolean_t want_restart;
isc_boolean_t send_event;
dns_name_t *name, *fname, *prefix;
dns_fixedname_t foundname, fixed;
dns_rdata_t rdata = DNS_RDATA_INIT;
unsigned int nlabels;
int order;
dns_namereln_t namereln;
dns_rdata_cname_t cname;
dns_rdata_dname_t dname;
REQUIRE(VALID_LOOKUP(lookup));
LOCK(&lookup->lock);
result = ISC_R_SUCCESS;
name = dns_fixedname_name(&lookup->name);
do {
lookup->restarts++;
want_restart = ISC_FALSE;
send_event = ISC_TRUE;
if (event == NULL && !lookup->canceled) {
dns_fixedname_init(&foundname);
fname = dns_fixedname_name(&foundname);
INSIST(!dns_rdataset_isassociated(&lookup->rdataset));
INSIST(!dns_rdataset_isassociated
(&lookup->sigrdataset));
/*
* If we have restarted then clear the old node. */
if (lookup->event->node != NULL) {
INSIST(lookup->event->db != NULL);
dns_db_detachnode(lookup->event->db,
&lookup->event->node);
}
if (lookup->event->db != NULL)
dns_db_detach(&lookup->event->db);
result = view_find(lookup, fname);
if (result == ISC_R_NOTFOUND) {
/*
* We don't know anything about the name.
* Launch a fetch.
*/
if (lookup->event->node != NULL) {
INSIST(lookup->event->db != NULL);
dns_db_detachnode(lookup->event->db,
&lookup->event->node);
}
if (lookup->event->db != NULL)
dns_db_detach(&lookup->event->db);
result = start_fetch(lookup);
if (result == ISC_R_SUCCESS)
send_event = ISC_FALSE;
goto done;
}
} else if (event != NULL) {
result = event->result;
fname = dns_fixedname_name(&event->foundname);
dns_resolver_destroyfetch(&lookup->fetch);
INSIST(event->rdataset == &lookup->rdataset);
INSIST(event->sigrdataset == &lookup->sigrdataset);
} else
fname = NULL; /* Silence compiler warning. */
/*
* If we've been canceled, forget about the result.
*/
if (lookup->canceled)
result = ISC_R_CANCELED;
switch (result) {
case ISC_R_SUCCESS:
result = build_event(lookup);
if (event == NULL)
break;
if (event->db != NULL)
dns_db_attach(event->db, &lookup->event->db);
if (event->node != NULL)
dns_db_attachnode(lookup->event->db,
event->node,
&lookup->event->node);
break;
case DNS_R_CNAME:
/*
* Copy the CNAME's target into the lookup's
* query name and start over.
*/
result = dns_rdataset_first(&lookup->rdataset);
if (result != ISC_R_SUCCESS)
break;
dns_rdataset_current(&lookup->rdataset, &rdata);
result = dns_rdata_tostruct(&rdata, &cname, NULL);
dns_rdata_reset(&rdata);
if (result != ISC_R_SUCCESS)
break;
result = dns_name_copy(&cname.cname, name, NULL);
//.........这里部分代码省略.........
开发者ID:each, 项目名称:bind9-collab, 代码行数:101, 代码来源:lookup.c
示例10: isc_interfaceiter_create
isc_result_t
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
char strbuf[ISC_STRERRORSIZE];
isc_interfaceiter_t *iter;
isc_result_t result;
int error;
unsigned long bytesReturned = 0;
REQUIRE(mctx != NULL);
REQUIRE(iterp != NULL);
REQUIRE(*iterp == NULL);
iter = isc_mem_get(mctx, sizeof(*iter));
if (iter == NULL)
return (ISC_R_NOMEMORY);
InitSockets();
iter->mctx = mctx;
iter->buf4 = NULL;
iter->buf6 = NULL;
iter->pos4 = NULL;
iter->pos6 = 0;
iter->buf6size = 0;
iter->buf4size = 0;
iter->result = ISC_R_FAILURE;
iter->numIF = 0;
iter->v4IF = 0;
/*
* Create an unbound datagram socket to do the
* SIO_GET_INTERFACE_LIST WSAIoctl on.
*/
if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
error = WSAGetLastError();
if (error == WSAEAFNOSUPPORT)
goto inet6_only;
isc__strerror(error, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"making interface scan socket: %s",
strbuf);
result = ISC_R_UNEXPECTED;
goto socket_failure;
}
/*
* Get the interface configuration, allocating more memory if
* necessary.
*/
iter->buf4size = IFCONF_SIZE_INITIAL*sizeof(INTERFACE_INFO);
for (;;) {
iter->buf4 = isc_mem_get(mctx, iter->buf4size);
if (iter->buf4 == NULL) {
result = ISC_R_NOMEMORY;
goto alloc_failure;
}
if (WSAIoctl(iter->socket, SIO_GET_INTERFACE_LIST,
0, 0, iter->buf4, iter->buf4size,
&bytesReturned, 0, 0) == SOCKET_ERROR)
{
error = WSAGetLastError();
if (error != WSAEFAULT && error != WSAENOBUFS) {
errno = error;
isc__strerror(error, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"get interface configuration: %s",
strbuf);
result = ISC_R_UNEXPECTED;
goto ioctl_failure;
}
/*
* EINVAL. Retry with a bigger buffer.
*/
} else {
/*
* The WSAIoctl succeeded.
* If the number of the returned bytes is the same
* as the buffer size, we will grow it just in
* case and retry.
*/
if (bytesReturned > 0 &&
(bytesReturned < iter->buf4size))
break;
}
if (iter->buf4size >= IFCONF_SIZE_MAX*sizeof(INTERFACE_INFO)) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"get interface configuration: "
"maximum buffer size exceeded");
result = ISC_R_UNEXPECTED;
goto ioctl_failure;
}
isc_mem_put(mctx, iter->buf4, iter->buf4size);
iter->buf4size += IFCONF_SIZE_INCREMENT *
sizeof(INTERFACE_INFO);
}
/*
//.........这里部分代码省略.........
开发者ID:OPSF, 项目名称:uClinux, 代码行数:101, 代码来源:interfaceiter.c
示例11: REQUIRE
void CKLDualInferenceMethod::check_dual_inference(CLikelihoodModel* mod) const
{
CDualVariationalGaussianLikelihood * lik=dynamic_cast<CDualVariationalGaussianLikelihood *>(mod);
REQUIRE(lik,
"The provided likelihood model is not a variational dual Likelihood model.\n");
}
开发者ID:DrahmA, 项目名称:shogun, 代码行数:6, 代码来源:KLDualInferenceMethod.cpp
示例12: internal_current
static isc_result_t
internal_current(isc_interfaceiter_t *iter) {
BOOL ifNamed = FALSE;
unsigned long flags;
REQUIRE(VALID_IFITER(iter));
REQUIRE(iter->numIF >= 0);
memset(&iter->current, 0, sizeof(iter->current));
iter->current.af = AF_INET;
isc_netaddr_fromsockaddr(&iter->current.address,
(isc_sockaddr_t *)&(iter->IFData.iiAddress));
/*
* Get interface flags.
*/
iter->current.flags = 0;
flags = iter->IFData.iiFlags;
if ((flags & IFF_UP) != 0)
iter->current.flags |= INTERFACE_F_UP;
if ((flags & IFF_BROADCAST) != 0)
iter->current.flags |= INTERFACE_F_BROADCAST;
if ((flags & IFF_MULTICAST) != 0)
iter->current.flags |= INTERFACE_F_MULTICAST;
if ((flags & IFF_POINTTOPOINT) != 0) {
iter->current.flags |= INTERFACE_F_POINTTOPOINT;
snprintf(iter->current.name, sizeof(iter->current.name),
"PPP %d", iter->numIF);
ifNamed = TRUE;
}
if ((flags & IFF_LOOPBACK) != 0) {
iter->current.flags |= INTERFACE_F_LOOPBACK;
snprintf(iter->current.name, sizeof(iter->current.name),
"v4loop %d", iter->numIF);
ifNamed = TRUE;
}
/*
* If the interface is point-to-point, get the destination address.
*/
if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0)
isc_netaddr_fromsockaddr(&iter->current.dstaddress,
(isc_sockaddr_t *)&(iter->IFData.iiBroadcastAddress));
/*
* Get the network mask.
*/
isc_netaddr_fromsockaddr(&iter->current.netmask,
(isc_sockaddr_t *)&(iter->IFData.iiNetmask));
/*
* If the interface is broadcast, get the broadcast address,
* based on the unicast address and network mask.
*/
if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0)
get_broadcastaddr(&iter->current.broadcast,
&iter->current.address,
&iter->current.netmask);
if (ifNamed == FALSE)
snprintf(iter->current.name, sizeof(iter->current.name),
"IPv4 %d", iter->numIF);
return (ISC_R_SUCCESS);
}
开发者ID:jaredmcneill, 项目名称:netbsd-src, 代码行数:72, 代码来源:interfaceiter.c
示例13: totext_keydata
static inline isc_result_t
totext_keydata(ARGS_TOTEXT) {
isc_region_t sr;
char buf[sizeof("64000")];
unsigned int flags;
unsigned char algorithm;
unsigned long when;
char algbuf[DNS_NAME_FORMATSIZE];
const char *keyinfo;
REQUIRE(rdata->type == 65533);
if ((tctx->flags & DNS_STYLEFLAG_KEYDATA) == 0 || rdata->length < 16)
return (unknown_totext(rdata, tctx, target));
dns_rdata_toregion(rdata, &sr);
/* refresh timer */
when = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(when, target));
RETERR(str_totext(" ", target));
/* add hold-down */
when = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(when, target));
RETERR(str_totext(" ", target));
/* remove hold-down */
when = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
RETERR(dns_time32_totext(when, target));
RETERR(str_totext(" ", target));
/* flags */
flags = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%u", flags);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
if ((flags & DNS_KEYFLAG_KSK) != 0) {
if (flags & DNS_KEYFLAG_REVOKE)
keyinfo = "revoked KSK";
else
keyinfo = "KSK";
} else
keyinfo = "ZSK";
/* protocol */
sprintf(buf, "%u", sr.base[0]);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/* algorithm */
algorithm = sr.base[0];
sprintf(buf, "%u", algorithm);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
/* No Key? */
if ((flags & 0xc000) == 0xc000)
return (ISC_R_SUCCESS);
/* key */
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
RETERR(str_totext(tctx->linebreak, target));
if (tctx->width == 0) /* No splitting */
RETERR(isc_base64_totext(&sr, 60, "", target));
else
RETERR(isc_base64_totext(&sr, tctx->width - 2,
tctx->linebreak, target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0)
RETERR(str_totext(tctx->linebreak, target));
else if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" ", target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(")", target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
isc_region_t tmpr;
RETERR(str_totext(" ; ", target));
RETERR(str_totext(keyinfo, target));
dns_secalg_format((dns_secalg_t) algorithm, algbuf,
sizeof(algbuf));
RETERR(str_totext("; alg = ", target));
RETERR(str_totext(algbuf, target));
RETERR(str_totext("; key id = ", target));
dns_rdata_toregion(rdata, &tmpr);
/* Skip over refresh, addhd, and removehd */
isc_region_consume(&tmpr, 12);
sprintf(buf, "%u", dst_region_computeid(&tmpr, algorithm));
RETERR(str_totext(buf, target));
}
return (ISC_R_SUCCESS);
//.........这里部分代码省略.........
开发者ID:enukane, 项目名称:netbsd-src, 代码行数:101, 代码来源:keydata_65533.c
示例14: internal_current6
static isc_result_t
internal_current6(isc_interfaceiter_t *iter) {
BOOL ifNamed = FALSE;
struct sockaddr_in6 *psa6;
BOOL localhostSeen;
int i;
REQUIRE(VALID_IFITER(iter));
REQUIRE(iter->pos6 >= 0);
REQUIRE(iter->buf6 != 0);
memset(&iter->current, 0, sizeof(iter->current));
iter->current.af = AF_INET6;
/*
* synthesize localhost ::1 before returning the rest, if ::1
* is not on the list.
*/
if (iter->pos6 >= (unsigned)iter->buf6->iAddressCount) {
localhostSeen = FALSE;
for (i = 0; i < iter->buf6->iAddressCount; i++) {
psa6 = (struct sockaddr_in6 *)
iter->buf6->Address[i].lpSockaddr;
if (!memcmp(&iter->loop__1, &psa6->sin6_addr,
sizeof(iter->loop__1))) {
localhostSeen = TRUE;
break;
}
}
if (localhostSeen)
iter->pos6 = iter->buf6->iAddressCount - 1;
}
if (iter->pos6 < (unsigned)iter->buf6->iAddressCount) {
isc_netaddr_fromsockaddr(&iter->current.address,
(isc_sockaddr_t *)iter->buf6->Address[iter->pos6].lpSockaddr);
} else {
iter->current.address.family = AF_INET6;
memcpy(&iter->current.address.type.in6, &iter->loop__1,
sizeof(iter->current.address.type.in6));
}
/*
* Get interface flags.
*/
iter->current.flags = INTERFACE_F_UP | INTERFACE_F_MULTICAST;
if (!memcmp(&iter->current.address.type.in6, &iter->loop__1,
sizeof(iter->current.address.type.in6)) ||
!memcmp(&iter->current.address.type.in6, &iter->loopfe80__1,
sizeof(iter->current.address.type.in6))) {
iter->current.flags |= INTERFACE_F_LOOPBACK;
snprintf(iter->current.name, sizeof(iter->current.name),
"v6loop %d",
iter->buf6->iAddressCount - iter->pos6);
ifNamed = TRUE;
}
if (ifNamed == FALSE)
snprintf(iter->current.name, sizeof(iter->current.name),
"IPv6 %d",
iter->buf6->iAddressCount - iter->pos6);
memset(iter->current.netmask.type.in6.s6_addr, 0xff,
sizeof(iter->current.netmask.type.in6.s6_addr));
iter->current.netmask.family = AF_INET6;
return (ISC_R_SUCCESS);
}
开发者ID:jaredmcneill, 项目名称:netbsd-src, 代码行数:70, 代码来源:interfaceiter.c
示例15: SG_DEBUG
SGVector<complex128_t> CCGMShiftedFamilySolver::solve_shifted_weighted(
CLinearOperator<float64_t>* A, SGVector<float64_t> b,
SGVector<complex128_t> shifts, SGVector<complex128_t> weights)
{
SG_DEBUG("Entering\n");
// sanity check
REQUIRE(A, "Operator is NULL!\n");
REQUIRE(A->get_dimension()==b.vlen, "Dimension mismatch! [%d vs %d]\n",
A->get_dimension(), b.vlen);
REQUIRE(shifts.vector,"Shifts are not initialized!\n");
REQUIRE(weights.vector,"Weights are not initialized!\n");
REQUIRE(shifts.vlen==weights.vlen, "Number of shifts and number of "
"weights are not equal! [%d vs %d]\n", shifts.vlen, weights.vlen);
// the solution matrix, one column per shift, initial guess 0 for all
MatrixXcd x_sh=MatrixXcd::Zero(b.vlen, shifts.vlen);
MatrixXcd p_sh=MatrixXcd::Zero(b.vlen, shifts.vlen);
// non-shifted direction
SGVector<float64_t> p_(b.vlen);
// the rest of the part hinges on eigen3 for computing norms
Map<VectorXd> b_map(b.vector, b.vlen);
Map<VectorXd> p(p_.vector, p_.vlen);
// residual r_i=b-Ax_i, here x_0=[0], so r_0=b
VectorXd r=b_map;
// initial direction is same as residual
p=r;
p_sh=r.replicate(1, shifts.vlen).cast<complex128_t>();
// non shifted initializers
float64_t r_norm2=r.dot(r);
float64_t beta_old=1.0;
float64_t alpha=1.0;
// shifted quantities
SGVector<complex128_t> alpha_sh(shifts.vlen);
SGVector<complex128_t> beta_sh(shifts.vlen);
SGVector<complex128_t> zeta_sh_old(shifts.vlen);
SGVector<complex128_t> zeta_sh_cur(shifts.vlen);
SGVector<complex128_t> zeta_sh_new(shifts.vlen);
// shifted initializers
zeta_sh_old.set_const(1.0);
zeta_sh_cur.set_const(1.0);
// the iterator for this iterative solver
IterativeSolverIterator<float64_t> it(r, m_max_iteration_limit,
m_relative_tolerence, m_absolute_tolerence);
// start the timer
CTime time;
time.start();
// set the residuals to zero
if (m_store_residuals)
m_residuals.set_const(0.0);
// CG iteration begins
for (it.begin(r); !it.end(r); ++it)
{
SG_DEBUG("CG iteration %d, residual norm %f\n",
it.get_iter_info().iteration_count,
it.get_iter_info().residual_norm);
if (m_store_residuals)
{
m_residuals[it.get_iter_info().iteration_count]
=it.get_iter_info().residual_norm;
}
// apply linear operator to the direction vector
SGVector<float64_t> Ap_=A->apply(p_);
Map<VectorXd> Ap(Ap_.vector, Ap_.vlen);
// compute p^{T}Ap, if zero, failure
float64_t p_dot_Ap=p.dot(Ap);
if (p_dot_Ap==0.0)
break;
// compute the beta parameter of CG_M
float64_t beta=-r_norm2/p_dot_Ap;
// compute the zeta-shifted parameter of CG_M
compute_zeta_sh_new(zeta_sh_old, zeta_sh_cur, shifts, beta_old, beta,
alpha, zeta_sh_new);
// compute beta-shifted parameter of CG_M
compute_beta_sh(zeta_sh_new, zeta_sh_cur, beta, beta_sh);
// update the solution vector and residual
for (index_t i=0; i<shifts.vlen; ++i)
x_sh.col(i)-=beta_sh[i]*p_sh.col(i);
// r_{i}=r_{i-1}+\beta_{i}Ap
r+=beta*Ap;
//.........这里部分代码省略.........
开发者ID:JackieXie168, 项目名称:shogun, 代码行数:101, 代码来源:CGMShiftedFamilySolver.cpp
示例16: isc_commandline_parse
/*!
* getopt --
* Parse argc/argv argument vector.
*/
int
isc_commandline_parse(int argc, char * const *argv, const char *options) {
static char *place = ENDOPT;
char *option; /* Index into *options of option. */
REQUIRE(argc >= 0 && argv != NULL && options != NULL);
/*
* Update scanning pointer, either because a reset was requested or
* the previous argv was finished.
*/
if (isc_commandline_reset || *place == '\0') {
isc_commandline_reset = ISC_FALSE;
if (isc_commandline_progname == NULL)
isc_commandline_progname = argv[0];
if (isc_commandline_index >= argc ||
*(place = argv[isc_commandline_index]) != '-') {
/*
* Index out of range or points to non-option.
*/
place = ENDOPT;
return (-1);
}
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
/*
* Found '--' to signal end of options. Advance
* index to next argv, the first non-option.
*/
isc_commandline_index++;
place = ENDOPT;
return (-1);
}
}
isc_commandline_option = *place++;
option = strchr(options, isc_commandline_option);
/*
* Ensure valid option has been passed as specified by options string.
* '-:' is never a valid command line option because it could not
* distinguish ':' from the argument specifier in the options string.
*/
if (isc_commandline_option == ':' || option == NULL) {
if (*place == '\0')
isc_commandline_index++;
if (isc_commandline_errprint && *options != ':')
fprintf(stderr, "%s: %s -- %c\n",
isc_commandline_progname,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_COMMANDLINE,
ISC_MSG_ILLEGALOPT,
"illegal option"),
isc_commandline_option);
return (BADOPT);
}
if (*++option != ':') {
/*
* Option does not take an argument.
*/
isc_commandline_argument = NULL;
/*
* Skip to next argv if at the end of the current argv.
*/
if (*place == '\0')
++isc_commandline_index;
} else {
/*
* Option needs an argument.
*/
if (*place != '\0')
/*
* Option is in this argv, -D1 style.
*/
isc_commandline_argument = place;
else if (argc > ++isc_commandline_index)
/*
* Option is next argv, -D 1 style.
*/
isc_commandline_argument = argv[isc_commandline_index];
else {
/*
* Argument needed, but no more argv.
*/
place = ENDOPT;
/*
//.........这里部分代码省略.........
开发者ID:OPSF, 项目名称:uClinux, 代码行数:101, 代码来源:commandline.c
示例17: dst__privstruct_parse
isc_result_t
dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
isc_mem_t *mctx, dst_private_t *priv)
{
int n = 0, major, minor, check;
isc_buffer_t b;
isc_token_t token;
unsigned char *data = NULL;
unsigned int opt = ISC_LEXOPT_EOL;
isc_stdtime_t when;
isc_result_t ret;
isc_boolean_t external = ISC_FALSE;
REQUIRE(priv != NULL);
priv->nelements = 0;
memset(priv->elements, 0, sizeof(priv->elements));
#define NEXTTOKEN(lex, opt, token) \
do { \
ret = isc_lex_gettoken(lex, opt, token); \
if (ret != ISC_R_SUCCESS) \
goto fail; \
} while (/*CONSTCOND*/0)
#define READLINE(lex, opt, token) \
do { \
ret = isc_lex_gettoken(lex, opt, token); \
if (ret == ISC_R_EOF) \
break; \
else if (ret != ISC_R_SUCCESS) \
goto fail; \
} while ((*token).type != isc_tokentype_eol)
/*
* Read the description line.
*/
NEXTTOKEN(lex, opt, &token);
if (token.type != isc_tokentype_string ||
strcmp(DST_AS_STR(token), PRIVATE_KEY_STR) != 0)
{
ret = DST_R_INVALIDPRIVATEKEY;
goto fail;
}
NEXTTOKEN(lex, opt, &token);
if (token.type != isc_tokentype_string ||
(DST_AS_STR(token))[0] != 'v')
{
ret = DST_R_INVALIDPRIVATEKEY;
goto fail;
}
if (sscanf(DST_AS_STR(token), "v%d.%d", &major, &minor) != 2)
{
ret = DST_R_INVALIDPRIVATEKEY;
goto fail;
}
if (major > DST_MAJOR_VERSION) {
ret = DST_R_INVALIDPRIVATEKEY;
goto fail;
}
/*
* Store the private key format version number
*/
dst_key_setprivateformat(key, major, minor);
READLINE(lex, opt, &token);
/*
* Read the algorithm line.
*/
NEXTTOKEN(lex, opt, &token);
if (token.type != isc_tokentype_string ||
strcmp(DST_AS_STR(token), ALGORITHM_STR) != 0)
{
ret = DST_R_INVALIDPRIVATEKEY;
goto fail;
}
NEXTTOKEN(lex, opt | ISC_LEXOPT_NUMBER, &token);
if (token.type != isc_tokentype_number ||
token.value.as_ulong != (unsigned long) dst_key_alg(key))
{
ret = DST_R_INVALIDPRIVATEKEY;
goto fail;
}
READLINE(lex, opt, &token);
/*
* Read the key data.
*/
for (n = 0; n < MAXFIELDS; n++) {
int tag;
isc_region_t r;
do {
ret = isc_lex_gettoken(lex, opt, &token);
if (ret == ISC_R_EOF)
//.........这里部分代码省略.........
开发者ID:ajinkya93, 项目名称:netbsd-src, 代码行数:101, 代码来源:dst_parse.c
示例18: totext_key
static inline isc_result_t
totext_key(ARGS_TOTEXT) {
isc_region_t sr;
char buf[sizeof("64000")];
unsigned int flags;
unsigned char algorithm;
char namebuf[DNS_NAME_FORMATSIZE];
REQUIRE(rdata->type == dns_rdatatype_key);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, &sr);
/* flags */
flags = uint16_fromregion(&sr);
isc_region_consume(&sr, 2);
sprintf(buf, "%u", flags);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/* protocol */
sprintf(buf, "%u", sr.base[0]);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
/* algorithm */
algorithm = sr.base[0];
sprintf(buf, "%u", algorithm);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
/* No Key? */
if ((flags & 0xc000) == 0xc000)
return (ISC_R_SUCCESS);
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0 &&
algorithm == DNS_KEYALG_PRIVATEDNS) {
dns_name_t name;
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &sr);
dns_name_format(&name, namebuf, sizeof(namebuf));
} else
namebuf[0] = 0;
/* key */
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" (", target));
RETERR(str_totext(tctx->linebreak, target));
if (tctx->width == 0) /* No splitting */
RETERR(isc_base64_totext(&sr, 60, "", target));
else
RETERR(isc_base64_totext(&sr, tctx->width - 2,
tctx->linebreak, target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0)
RETERR(str_totext(tctx->linebreak, target));
else if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(" ", target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
RETERR(str_totext(")", target));
if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
isc_region_t tmpr;
RETERR(str_totext(" ; key id = ", target));
dns_rdata_toregion(rdata, &tmpr);
sprintf(buf, "%u", dst_region_computeid(&tmpr, algorithm));
RETERR(str_totext(buf, target));
if (algorithm == DNS_KEYALG_PRIVATEDNS) {
RETERR(str_totext(tctx->linebreak, target));
RETERR(str_totext("; alg = ", target));
RETERR(str_totext(namebuf, target));
}
}
return (ISC_R_SUCCESS);
}
开发者ID:chris-wood, 项目名称:bind-prime, 代码行数:78, 代码来源:key_25.c
示例19: dst__privstruct_writefile
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19287| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:10021| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8344| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8714| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8658| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9688| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8647| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:8014| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8683| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7550| 2022-11-06
请发表评论