当前位置: 首页>>代码示例>>C++>>正文


C++ dns_result_totext函数代码示例

本文整理汇总了C++中dns_result_totext函数的典型用法代码示例。如果您正苦于以下问题:C++ dns_result_totext函数的具体用法?C++ dns_result_totext怎么用?C++ dns_result_totext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dns_result_totext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: print_name

static void print_name (dns_name_t * name)
{
    isc_result_t result;

    isc_buffer_t source;

    isc_region_t r;

    char s[1000];

    isc_buffer_init (&source, s, sizeof (s));
    if (dns_name_countlabels (name) > 0)
        result = dns_name_totext (name, ISC_FALSE, &source);
    else
        result = ISC_R_SUCCESS;
    if (result == ISC_R_SUCCESS)
    {
        isc_buffer_usedregion (&source, &r);
        if (r.length > 0)
            printf ("%.*s\n", (int) r.length, r.base);
        else
            printf ("<empty text name>\n");
    }
    else
        printf ("error: %s\n", dns_result_totext (result));
}
开发者ID:274914765,项目名称:C,代码行数:26,代码来源:name_test.c

示例2: t1_add

/*
 * Adapted from the original rbt_test.c.
 */
static int
t1_add(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, isc_result_t *dns_result) {
	int		nprobs;
	dns_name_t	*dns_name;

	nprobs = 0;
	if (name && dns_result) {
		if (create_name(name, mctx, &dns_name) == 0) {
			if (T_debug)
				t_info("dns_rbt_addname succeeded\n");
			*dns_result = dns_rbt_addname(rbt, dns_name, dns_name);
			if (*dns_result != ISC_R_SUCCESS) {
				delete_name(dns_name, mctx);
				t_info("dns_rbt_addname failed %s\n",
				       dns_result_totext(*dns_result));
				++nprobs;
			}
		} else {
			++nprobs;
		}
	} else {
		++nprobs;
	}
	return(nprobs);
}
开发者ID:pombredanne,项目名称:NetBSD,代码行数:28,代码来源:t_rbt.c

示例3: main

int
main(int argc, char **argv) {
	char *file;
	isc_mem_t *mctx = NULL;
	isc_result_t result;
	isc_log_t *lctx = NULL;

	if (argc != 2) {
		printf("usage: %s journal\n", argv[0]);
		return(1);
	}

	file = argv[1];

	isc__mem_register();
	RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
	RUNTIME_CHECK(setup_logging(mctx, stderr, &lctx) == ISC_R_SUCCESS);

	result = dns_journal_print(mctx, file, stdout);
	if (result == DNS_R_NOJOURNAL)
		fprintf(stderr, "%s\n", dns_result_totext(result));
	isc_log_destroy(&lctx);
	isc_mem_detach(&mctx);
	return(result != ISC_R_SUCCESS ? 1 : 0);
}
开发者ID:jhbsz,项目名称:netbsd,代码行数:25,代码来源:named-journalprint.c

示例4: t_namechk

static int
t_namechk(isc_result_t dns_result, dns_fixedname_t *dns_name, char *exp_name,
	  dns_fixedname_t *dns_origin, char *exp_origin,
	  isc_result_t exp_result)
{
	int	nfails;

	nfails = 0;

	if (fixedname_cmp(dns_name, exp_name)) {
		t_info("\texpected name of %s, got %s\n",
				exp_name, fixedname_totext(dns_name));
		++nfails;
	}
	if (exp_origin != NULL) {
		t_info("checking for DNS_R_NEWORIGIN\n");
		if (dns_result == exp_result) {
			if (fixedname_cmp(dns_origin, exp_origin)) {
				t_info("\torigin %s, expected %s\n",
				       fixedname_totext(dns_origin),
				       exp_origin);
				++nfails;
			}
		} else {
			t_info("\tgot %s\n", dns_result_totext(dns_result));
			++nfails;
		}
	}
	return(nfails);
}
开发者ID:pombredanne,项目名称:NetBSD,代码行数:30,代码来源:t_rbt.c

示例5: dumpmessage

static void
dumpmessage(dns_message_t *msg) {
	isc_buffer_t outbuf;
	unsigned char *output;
	int len = TEMP_BUFFER_SZ;
	isc_result_t result;

	for (;;) {
		output = isc_mem_get(msg->mctx, len);
		if (output == NULL)
			return;

		isc_buffer_init(&outbuf, output, len);
		result = dns_message_totext(msg, &dns_master_style_debug,
					    0, &outbuf);
		if (result == ISC_R_NOSPACE) {
			isc_mem_put(msg->mctx, output, len);
			len *= 2;
			continue;
		}

		if (result == ISC_R_SUCCESS)
			tkey_log("%.*s",
				 (int)isc_buffer_usedlength(&outbuf),
				 (char *)isc_buffer_base(&outbuf));
		else
			tkey_log("Warning: dns_message_totext: %s",
				 dns_result_totext(result));
		break;
	}

	if (output != NULL)
		isc_mem_put(msg->mctx, output, len);
}
开发者ID:chris-wood,项目名称:bind-prime,代码行数:34,代码来源:tkey.c

示例6: add_test_data

/*
 * Load test data into the RBT.
 */
static void
add_test_data(isc_mem_t *mymctx, dns_rbt_t *rbt) {
	char buffer[1024];
	isc_buffer_t b;
	isc_result_t result;
	dns_fixedname_t fname;
	dns_name_t *name;
	dns_compress_t cctx;
	rbt_testdata_t *testdatap = testdata;

	dns_compress_init(&cctx, -1, mymctx);

	while (testdatap->name != NULL && testdatap->data.data != NULL) {
		memmove(buffer, testdatap->name, testdatap->name_len);

		isc_buffer_init(&b, buffer, testdatap->name_len);
		isc_buffer_add(&b, testdatap->name_len);
		dns_fixedname_init(&fname);
		name = dns_fixedname_name(&fname);
		result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
		if (result != ISC_R_SUCCESS) {
			testdatap++;
			continue;
		}

		if (name != NULL) {
			result = dns_rbt_addname(rbt, name, &testdatap->data);
			ATF_CHECK_STREQ(dns_result_totext(result), "success");
		}
		testdatap++;
	}

	dns_compress_invalidate(&cctx);
}
开发者ID:NZRS,项目名称:bind9-collab,代码行数:37,代码来源:rbt_serialize_test.c

示例7: iterate

static void
iterate(dns_rbt_t *rbt, isc_boolean_t forward) {
	dns_name_t foundname, *origin;
	dns_rbtnodechain_t chain;
	dns_fixedname_t fixedorigin;
	isc_result_t result;
	isc_result_t (*move)(dns_rbtnodechain_t *chain, dns_name_t *name,
			     dns_name_t *origin);

	dns_rbtnodechain_init(&chain, mctx);

	dns_name_init(&foundname, NULL);
	dns_fixedname_init(&fixedorigin);
	origin = dns_fixedname_name(&fixedorigin);

	if (forward) {
		printf("iterating forward\n" );
		move = dns_rbtnodechain_next;

		result = dns_rbtnodechain_first(&chain, rbt, &foundname,
						origin);

	} else {
		printf("iterating backward\n" );
		move = dns_rbtnodechain_prev;

		result = dns_rbtnodechain_last(&chain, rbt, &foundname,
					       origin);
	}

	if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN)
		printf("start not found!\n");

	else {
		for (;;) {
			if (result == DNS_R_NEWORIGIN) {
				printf("  new origin: ");
				print_name(origin);
				printf("\n");
			}

			if (result == ISC_R_SUCCESS ||
			    result == DNS_R_NEWORIGIN) {
				print_name(&foundname);
				printf("\n");

			} else {
				if (result != ISC_R_NOMORE)
				       printf("UNEXEPCTED ITERATION ERROR: %s",
					      dns_result_totext(result));
				break;
			}

			result = move(&chain, &foundname, origin);
		}
	}
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:57,代码来源:rbt_test.c

示例8: printf

static dns_name_t *create_name (char *s)
{
    int length;

    isc_result_t result;

    isc_buffer_t source, target;

    static dns_name_t *name;

    if (s == NULL || *s == '\0')
    {
        printf ("missing name argument\n");
        return (NULL);
    }

    length = strlen (s);

    isc_buffer_init (&source, s, length);
    isc_buffer_add (&source, length);

    /*
     * It isn't really necessary in this program to create individual
     * memory spaces for each name structure and its associated character
     * string.  It is done here to provide a relatively easy way to test
     * the callback from dns_rbt_deletename that is supposed to free the
     * data associated with a node.
     *
     * The buffer for the actual name will immediately follow the
     * name structure.
     */
    name = isc_mem_get (mctx, sizeof (*name) + DNSNAMELEN);
    if (name == NULL)
    {
        printf ("out of memory!\n");
        return (NULL);
    }

    dns_name_init (name, NULL);
    isc_buffer_init (&target, name + 1, DNSNAMELEN);

    result = dns_name_fromtext (name, &source, dns_rootname, 0, &target);

    if (result != ISC_R_SUCCESS)
    {
        printf ("dns_name_fromtext(%s) failed: %s\n", s, dns_result_totext (result));
        return (NULL);
    }

    return (name);
}
开发者ID:274914765,项目名称:C,代码行数:51,代码来源:rbt_test.c

示例9: main

int
main(int argc, char *argv[]) {
	isc_result_t result;
	dns_name_t origin;
	isc_buffer_t source;
	isc_buffer_t target;
	unsigned char name_buf[255];
	dns_rdatacallbacks_t callbacks;

	UNUSED(argc);

	RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);

	if (argv[1]) {
		isc_buffer_init(&source, argv[1], strlen(argv[1]));
		isc_buffer_add(&source, strlen(argv[1]));
		isc_buffer_setactive(&source, strlen(argv[1]));
		isc_buffer_init(&target, name_buf, 255);
		dns_name_init(&origin, NULL);
		result = dns_name_fromtext(&origin, &source, dns_rootname,
					   0, &target);
		if (result != ISC_R_SUCCESS) {
			fprintf(stdout, "dns_name_fromtext: %s\n",
				dns_result_totext(result));
			exit(1);
		}

		dns_rdatacallbacks_init_stdio(&callbacks);
		callbacks.add = print_dataset;

		result = dns_master_loadfile(argv[1], &origin, &origin,
					     dns_rdataclass_in, 0,
					     &callbacks, mctx);
		fprintf(stdout, "dns_master_loadfile: %s\n",
			dns_result_totext(result));
	}
	return (0);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:38,代码来源:master_test.c

示例10: create_name

static int
create_name(char *s, isc_mem_t *mctx, dns_name_t **dns_name) {
	int		nfails;
	int		length;
	isc_result_t	result;
	isc_buffer_t	source;
	isc_buffer_t	target;
	dns_name_t	*name;

	nfails = 0;

	if (s && *s) {

		length = strlen(s);

		isc_buffer_init(&source, s, length);
		isc_buffer_add(&source, length);

		/*
		 * The buffer for the actual name will immediately follow the
		 * name structure.
		 */
		name = isc_mem_get(mctx, sizeof(*name) + DNSNAMELEN);
		if (name == NULL) {
			t_info("isc_mem_get failed\n");
			++nfails;
		} else {

			dns_name_init(name, NULL);
			isc_buffer_init(&target, name + 1, DNSNAMELEN);

			result = dns_name_fromtext(name, &source, dns_rootname,
						   0, &target);

			if (result != ISC_R_SUCCESS) {
				++nfails;
				t_info("dns_name_fromtext(%s) failed %s\n",
				       s, dns_result_totext(result));
				 isc_mem_put(mctx, name,
					     sizeof(*name) + DNSNAMELEN);
			} else
				*dns_name = name;
		}
	} else {
		++nfails;
		t_info("create_name: empty name\n");
	}

	return(nfails);
}
开发者ID:pombredanne,项目名称:NetBSD,代码行数:50,代码来源:t_rbt.c

示例11: _dns_tkey_dumpmessage

static void _dns_tkey_dumpmessage (dns_message_t * msg)
{
    isc_buffer_t outbuf;

    unsigned char output[4096];

    isc_result_t result;

    isc_buffer_init (&outbuf, output, sizeof (output));
    result = dns_message_totext (msg, &dns_master_style_debug, 0, &outbuf);
    if (result != ISC_R_SUCCESS)
        fprintf (stderr, "Warning: dns_message_totext returned: %s\n", dns_result_totext (result));
    fprintf (stderr, "%.*s\n", (int) isc_buffer_usedlength (&outbuf), (char *) isc_buffer_base (&outbuf));
}
开发者ID:274914765,项目名称:C,代码行数:14,代码来源:tkey.c

示例12: process_answer

static void
process_answer(isc_task_t *task, isc_event_t *event) {
	struct query_trans *trans = event->ev_arg;
	dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
	dns_name_t *name;
	dns_rdataset_t *rdataset;
	isc_result_t result;

	REQUIRE(task == query_task);
	REQUIRE(trans->inuse == ISC_TRUE);
	REQUIRE(outstanding_queries > 0);

	printf("answer[%2d]\n", trans->id);

	if (rev->result != ISC_R_SUCCESS)
		printf("  failed: %d(%s)\n", rev->result,
		       dns_result_totext(rev->result));

	for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
	     name = ISC_LIST_NEXT(name, link)) {
		for (rdataset = ISC_LIST_HEAD(name->list);
		     rdataset != NULL;
		     rdataset = ISC_LIST_NEXT(rdataset, link)) {
			(void)printdata(rdataset, name);
		}
	}

	dns_client_freeresanswer(client, &rev->answerlist);
	dns_client_destroyrestrans(&trans->xid);

	isc_event_free(&event);

	trans->inuse = ISC_FALSE;
	dns_fixedname_invalidate(&trans->fixedname);
	trans->qname = NULL;
	outstanding_queries--;

	result = dispatch_query(trans);
#if 0				/* for cancel test */
	if (result == ISC_R_SUCCESS) {
		static int count = 0;

		if ((++count) % 10 == 0)
			dns_client_cancelresolve(trans->xid);
	}
#endif
	if (result == ISC_R_NOMORE && outstanding_queries == 0)
		isc_app_ctxshutdown(query_actx);
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:49,代码来源:sample-async.c

示例13: print_data

static isc_result_t
print_data(void *data) {
	isc_result_t	dns_result;
	isc_buffer_t	target;
	char		*buffer[DNSNAMELEN];

	isc_buffer_init(&target, buffer, sizeof(buffer));

	dns_result = dns_name_totext(data, ISC_FALSE, &target);
	if (dns_result != ISC_R_SUCCESS) {
		t_info("dns_name_totext failed %s\n",
				dns_result_totext(dns_result));
	}
	return(dns_result);
}
开发者ID:pombredanne,项目名称:NetBSD,代码行数:15,代码来源:t_rbt.c

示例14: print_rdataset

static void
print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
	isc_buffer_t text;
	char t[1000];
	isc_result_t result;
	isc_region_t r;

	isc_buffer_init(&text, t, sizeof(t));
	result = dns_rdataset_totext(rdataset, name, ISC_FALSE, ISC_FALSE,
				     &text);
	isc_buffer_usedregion(&text, &r);
	if (result == ISC_R_SUCCESS)
		printf("%.*s", (int)r.length, (char *)r.base);
	else
		printf("%s\n", dns_result_totext(result));
}
开发者ID:pombredanne,项目名称:NetBSD,代码行数:16,代码来源:zone_test.c

示例15: t1_add_callback

static isc_result_t
t1_add_callback(void *arg, dns_name_t *owner, dns_rdataset_t *dataset) {
	char buf[BIGBUFLEN];
	isc_buffer_t target;
	isc_result_t result;

	UNUSED(arg);

	isc_buffer_init(&target, buf, BIGBUFLEN);
	result = dns_rdataset_totext(dataset, owner, ISC_FALSE, ISC_FALSE,
				     &target);
	if (result != ISC_R_SUCCESS)
		t_info("dns_rdataset_totext: %s\n", dns_result_totext(result));

	return(result);
}
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:16,代码来源:t_master.c


注:本文中的dns_result_totext函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。