1999-03-05 22:55:54 -05:00
|
|
|
/*
|
2018-02-23 03:53:12 -05:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-07-31 21:33:37 -04:00
|
|
|
*
|
2016-06-27 00:56:38 -04:00
|
|
|
* 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
|
2020-09-14 19:50:58 -04:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 03:53:12 -05:00
|
|
|
*
|
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
|
* information regarding copyright ownership.
|
1999-03-05 22:55:54 -05:00
|
|
|
*/
|
|
|
|
|
|
1999-01-27 18:17:57 -05:00
|
|
|
#include <stdlib.h>
|
2000-11-10 00:34:16 -05:00
|
|
|
#include <string.h>
|
1999-01-27 18:17:57 -05:00
|
|
|
|
|
|
|
|
#include <isc/buffer.h>
|
2000-05-08 10:38:29 -04:00
|
|
|
#include <isc/mem.h>
|
2015-05-23 08:21:51 -04:00
|
|
|
#include <isc/print.h>
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-26 20:03:12 -04:00
|
|
|
#include <isc/util.h>
|
1999-01-27 18:17:57 -05:00
|
|
|
|
2000-05-08 10:38:29 -04:00
|
|
|
#include <dns/callbacks.h>
|
1999-01-27 18:17:57 -05:00
|
|
|
#include <dns/master.h>
|
|
|
|
|
#include <dns/name.h>
|
|
|
|
|
#include <dns/rdataset.h>
|
|
|
|
|
#include <dns/result.h>
|
|
|
|
|
|
|
|
|
|
isc_mem_t *mctx;
|
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-26 20:03:12 -04:00
|
|
|
static isc_result_t
|
2020-02-14 00:35:17 -05:00
|
|
|
print_dataset(void *arg, const dns_name_t *owner, dns_rdataset_t *dataset) {
|
|
|
|
|
char buf[64 * 1024];
|
1999-01-27 18:17:57 -05:00
|
|
|
isc_buffer_t target;
|
1999-12-22 19:09:04 -05:00
|
|
|
isc_result_t result;
|
2000-07-31 21:33:37 -04:00
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-26 20:03:12 -04:00
|
|
|
UNUSED(arg);
|
1999-01-28 00:03:25 -05:00
|
|
|
|
2020-02-12 09:33:32 -05:00
|
|
|
isc_buffer_init(&target, buf, 64 * 1024);
|
|
|
|
|
result = dns_rdataset_totext(dataset, owner, false, false, &target);
|
2020-02-13 16:28:07 -05:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
1999-01-27 18:17:57 -05:00
|
|
|
fprintf(stdout, "%.*s\n", (int)target.used,
|
2020-02-12 09:33:32 -05:00
|
|
|
(char *)target.base);
|
2020-02-13 16:28:07 -05:00
|
|
|
} else {
|
1999-01-27 18:17:57 -05:00
|
|
|
fprintf(stdout, "dns_rdataset_totext: %s\n",
|
|
|
|
|
dns_result_totext(result));
|
2020-02-13 16:28:07 -05:00
|
|
|
}
|
1999-01-27 18:17:57 -05:00
|
|
|
|
2000-04-06 18:03:35 -04:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-27 18:17:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2020-02-14 00:35:17 -05:00
|
|
|
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];
|
1999-02-09 03:02:21 -05:00
|
|
|
dns_rdatacallbacks_t callbacks;
|
1999-01-27 18:17:57 -05:00
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-26 20:03:12 -04:00
|
|
|
UNUSED(argc);
|
1999-01-27 18:17:57 -05:00
|
|
|
|
2019-09-05 12:40:57 -04:00
|
|
|
isc_mem_create(&mctx);
|
1999-01-27 18:17:57 -05:00
|
|
|
|
|
|
|
|
if (argv[1]) {
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-26 20:03:12 -04:00
|
|
|
isc_buffer_init(&source, argv[1], strlen(argv[1]));
|
1999-01-27 18:17:57 -05:00
|
|
|
isc_buffer_add(&source, strlen(argv[1]));
|
|
|
|
|
isc_buffer_setactive(&source, strlen(argv[1]));
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-26 20:03:12 -04:00
|
|
|
isc_buffer_init(&target, name_buf, 255);
|
1999-01-27 18:17:57 -05:00
|
|
|
dns_name_init(&origin, NULL);
|
2020-02-12 09:33:32 -05:00
|
|
|
result = dns_name_fromtext(&origin, &source, dns_rootname, 0,
|
|
|
|
|
&target);
|
2000-04-06 18:03:35 -04:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-01-27 18:17:57 -05:00
|
|
|
fprintf(stdout, "dns_name_fromtext: %s\n",
|
|
|
|
|
dns_result_totext(result));
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
2000-07-31 21:33:37 -04:00
|
|
|
|
2000-01-21 20:38:58 -05:00
|
|
|
dns_rdatacallbacks_init_stdio(&callbacks);
|
1999-07-30 19:33:15 -04:00
|
|
|
callbacks.add = print_dataset;
|
2000-07-31 21:33:37 -04:00
|
|
|
|
2020-02-12 09:33:32 -05:00
|
|
|
result = dns_master_loadfile(
|
|
|
|
|
argv[1], &origin, &origin, dns_rdataclass_in, 0, 0,
|
|
|
|
|
&callbacks, NULL, NULL, mctx, dns_masterformat_text, 0);
|
1999-08-05 18:12:38 -04:00
|
|
|
fprintf(stdout, "dns_master_loadfile: %s\n",
|
1999-01-27 18:17:57 -05:00
|
|
|
dns_result_totext(result));
|
|
|
|
|
}
|
2000-02-01 20:09:56 -05:00
|
|
|
return (0);
|
1999-01-27 18:17:57 -05:00
|
|
|
}
|