From 904a5734375869ffb504ed8cde6b68cafadb6d64 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 4 Mar 1999 02:48:47 +0000 Subject: [PATCH] C++ compatibility --- bin/tests/wire_test.c | 20 ++++++++++---------- lib/dns/include/dns/callbacks.h | 7 +++++++ lib/dns/include/dns/cert.h | 6 ++++++ lib/dns/include/dns/compress.h | 5 +++++ lib/dns/include/dns/master.h | 5 +++++ lib/dns/include/dns/name.h | 4 ++++ lib/dns/include/dns/rbt.h | 6 ++++++ lib/dns/include/dns/rcode.h | 6 ++++++ lib/dns/include/dns/rdata.h | 5 +++++ lib/dns/include/dns/rdataclass.h | 6 ++++++ lib/dns/include/dns/rdatalist.h | 8 +++++++- lib/dns/include/dns/rdataset.h | 7 ++++++- lib/dns/include/dns/rdataslab.h | 5 +++++ lib/dns/include/dns/rdatatype.h | 6 ++++++ lib/dns/include/dns/result.h | 6 ++++++ lib/dns/include/dns/secalg.h | 6 ++++++ lib/dns/include/dns/types.h | 9 +++++++-- lib/dns/master.c | 19 ++++++++++--------- lib/dns/rdatalist.c | 2 +- lib/dns/rdataset.c | 10 +++++----- 20 files changed, 119 insertions(+), 29 deletions(-) diff --git a/bin/tests/wire_test.c b/bin/tests/wire_test.c index 9f1d8f599f..a15cbc021e 100644 --- a/bin/tests/wire_test.c +++ b/bin/tests/wire_test.c @@ -158,7 +158,7 @@ static void getquestions(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, isc_buffer_t *target) { - unsigned int type, class; + unsigned int type, rdclass; dns_name_t *name, *curr; dns_rdatalist_t *rdatalist; isc_region_t r; @@ -188,11 +188,11 @@ getquestions(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, if (name != curr) ISC_LIST_APPEND(*section, name, link); type = getshort(source); - class = getshort(source); + rdclass = getshort(source); for (rdatalist = ISC_LIST_HEAD(name->list); rdatalist != NULL; rdatalist = ISC_LIST_NEXT(rdatalist, link)) { - if (rdatalist->class == class && + if (rdatalist->rdclass == rdclass && rdatalist->type == type) break; } @@ -202,7 +202,7 @@ getquestions(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, exit(1); } rdatalist = &lists[rlcount++]; - rdatalist->class = class; + rdatalist->rdclass = rdclass; rdatalist->type = type; rdatalist->ttl = 0; ISC_LIST_INIT(rdatalist->rdata); @@ -216,7 +216,7 @@ static void getsection(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, isc_buffer_t *target) { - unsigned int type, class, ttl, rdlength; + unsigned int type, rdclass, ttl, rdlength; isc_region_t r; dns_name_t *name, *curr; dns_rdata_t *rdata; @@ -247,7 +247,7 @@ getsection(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, if (name != curr) ISC_LIST_APPEND(*section, name, link); type = getshort(source); - class = getshort(source); + rdclass = getshort(source); ttl = getshort(source); ttl *= 65536; ttl += getshort(source); @@ -264,7 +264,7 @@ getsection(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, } rdata = &rdatas[rdcount++]; dns_decompress_localinit(&dctx, name, source); - result = dns_rdata_fromwire(rdata, class, type, + result = dns_rdata_fromwire(rdata, rdclass, type, source, &dctx, ISC_FALSE, target); dns_decompress_localinvalidate(&dctx); @@ -275,7 +275,7 @@ getsection(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, for (rdatalist = ISC_LIST_HEAD(name->list); rdatalist != NULL; rdatalist = ISC_LIST_NEXT(rdatalist, link)) { - if (rdatalist->class == class && + if (rdatalist->rdclass == rdclass && rdatalist->type == type) break; } @@ -285,7 +285,7 @@ getsection(isc_buffer_t *source, dns_namelist_t *section, unsigned int count, exit(1); } rdatalist = &lists[rlcount++]; - rdatalist->class = class; + rdatalist->rdclass = rdclass; rdatalist->type = type; rdatalist->ttl = ttl; ISC_LIST_INIT(rdatalist->rdata); @@ -396,7 +396,7 @@ printquestions(dns_namelist_t *section) { printf("%.*s, class = ", (int)target.used, (char *)target.base); isc_buffer_clear(&target); - result = dns_rdataclass_totext(rdatalist->class, + result = dns_rdataclass_totext(rdatalist->rdclass, &target); if (result != DNS_R_SUCCESS) { printf("%s\n", dns_result_totext(result)); diff --git a/lib/dns/include/dns/callbacks.h b/lib/dns/include/dns/callbacks.h index e7b4c4fe3b..3c8923a8bb 100644 --- a/lib/dns/include/dns/callbacks.h +++ b/lib/dns/include/dns/callbacks.h @@ -23,8 +23,13 @@ ***/ #include + +#include + #include #include + +ISC_LANG_BEGINDECLS /*** *** Types @@ -60,4 +65,6 @@ void dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks); * 'callbacks' is a valid dns_rdatacallbacks_t, */ +ISC_LANG_ENDDECLS + #endif /* DNS_CALLBACKS_H */ diff --git a/lib/dns/include/dns/cert.h b/lib/dns/include/dns/cert.h index 307beb14f3..7b622015f3 100644 --- a/lib/dns/include/dns/cert.h +++ b/lib/dns/include/dns/cert.h @@ -18,8 +18,12 @@ #ifndef DNS_CERT_H #define DNS_CERT_H 1 +#include + #include +ISC_LANG_BEGINDECLS + dns_result_t dns_cert_fromtext(dns_cert_t *certp, isc_textregion_t *source); /* * Convert the text 'source' refers to into a certificate type. @@ -52,4 +56,6 @@ dns_result_t dns_cert_totext(dns_cert_t cert, isc_buffer_t *target); * DNS_R_NOSPACE target buffer is too small */ +ISC_LANG_ENDDECLS + #endif /* DNS_CERT_H */ diff --git a/lib/dns/include/dns/compress.h b/lib/dns/include/dns/compress.h index 7f4a1c7f68..2142ce7bd6 100644 --- a/lib/dns/include/dns/compress.h +++ b/lib/dns/include/dns/compress.h @@ -19,10 +19,13 @@ #define DNS_COMPRESS_H 1 #include +#include #include #include +ISC_LANG_BEGINDECLS + #define DNS_COMPRESS_NONE 0x00 /* no compression */ #define DNS_COMPRESS_GLOBAL14 0x01 /* "normal" compression. */ #define DNS_COMPRESS_GLOBAL16 0x02 /* 16-bit global comp. */ @@ -311,4 +314,6 @@ dns_decompress_strict(dns_decompress_t *dctx); * 'dctx' to be initalised */ +ISC_LANG_ENDDECLS + #endif /* DNS_COMPRESS_H */ diff --git a/lib/dns/include/dns/master.h b/lib/dns/include/dns/master.h index d76223ed23..bc9daa2cbe 100644 --- a/lib/dns/include/dns/master.h +++ b/lib/dns/include/dns/master.h @@ -22,6 +22,7 @@ *** Imports ***/ +#include #include #include @@ -31,6 +32,8 @@ #include #include +ISC_LANG_BEGINDECLS + /*** *** Function ***/ @@ -78,4 +81,6 @@ dns_result_t dns_master_load(char *master_file, * Any error code from callbacks->commit(). */ +ISC_LANG_ENDDECLS + #endif /* DNS_MASTER_H */ diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index fe2b644606..fdab29dec8 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -74,10 +74,12 @@ #include #include +#include #include #include +ISC_LANG_BEGINDECLS /***** ***** Labels @@ -680,4 +682,6 @@ dns_result_t dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, * DNS_R_NOSPACE */ +ISC_LANG_ENDDECLS + #endif /* DNS_NAME_H */ diff --git a/lib/dns/include/dns/rbt.h b/lib/dns/include/dns/rbt.h index e828bfbecd..b56fc94917 100644 --- a/lib/dns/include/dns/rbt.h +++ b/lib/dns/include/dns/rbt.h @@ -17,12 +17,16 @@ #ifndef DNS_RBT_H #define DNS_RBT_H 1 + +#include #include #include #include #include +ISC_LANG_BEGINDECLS + /* * This is the structure that is used for each node in the red/black * tree of trees. NOTE WELL: the implementation manages this as a variable @@ -162,4 +166,6 @@ dns_result_t dns_rbt_create(isc_mem_t *mctx, void (*deleter)(void *, void *), void *arg, dns_rbt_t **rbtp); void dns_rbt_destroy(dns_rbt_t **rbtp); +ISC_LANG_ENDDECLS + #endif diff --git a/lib/dns/include/dns/rcode.h b/lib/dns/include/dns/rcode.h index ec70d73e45..74d9de7974 100644 --- a/lib/dns/include/dns/rcode.h +++ b/lib/dns/include/dns/rcode.h @@ -18,8 +18,12 @@ #ifndef DNS_RCODE_H #define DNS_RCODE_H 1 +#include + #include +ISC_LANG_BEGINDECLS + dns_result_t dns_rcode_fromtext(dns_rcode_t *rcodep, isc_textregion_t *source); /* * Convert the text 'source' refers to into a DNS error value. @@ -52,4 +56,6 @@ dns_result_t dns_rcode_totext(dns_rcode_t rcode, isc_buffer_t *target); * DNS_R_NOSPACE target buffer is too small */ +ISC_LANG_ENDDECLS + #endif /* DNS_RCODE_H */ diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h index 3f247b4ae1..21e20be0da 100644 --- a/lib/dns/include/dns/rdata.h +++ b/lib/dns/include/dns/rdata.h @@ -91,6 +91,7 @@ *** Imports ***/ +#include #include #include @@ -98,6 +99,8 @@ #include #include +ISC_LANG_BEGINDECLS + /***** ***** RData ***** @@ -373,4 +376,6 @@ dns_result_t dns_rdata_tostruct(dns_rdata_t *rdata, void *target); * Success */ +ISC_LANG_ENDDECLS + #endif /* DNS_RDATA_H */ diff --git a/lib/dns/include/dns/rdataclass.h b/lib/dns/include/dns/rdataclass.h index f93a915ace..bdd619be82 100644 --- a/lib/dns/include/dns/rdataclass.h +++ b/lib/dns/include/dns/rdataclass.h @@ -18,8 +18,12 @@ #ifndef DNS_RDATACLASS_H #define DNS_RDATACLASS_H 1 +#include + #include +ISC_LANG_BEGINDECLS + dns_result_t dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source); /* @@ -55,4 +59,6 @@ dns_result_t dns_rdataclass_totext(dns_rdataclass_t class, * DNS_R_NOSPACE target buffer is too small */ +ISC_LANG_ENDDECLS + #endif /* DNS_RDATACLASS_H */ diff --git a/lib/dns/include/dns/rdatalist.h b/lib/dns/include/dns/rdatalist.h index 4f25fc5467..ef746cb976 100644 --- a/lib/dns/include/dns/rdatalist.h +++ b/lib/dns/include/dns/rdatalist.h @@ -43,14 +43,18 @@ * None. */ +#include + #include #include +ISC_LANG_BEGINDECLS + /* * Clients may use this type directly. */ struct dns_rdatalist { - dns_rdataclass_t class; + dns_rdataclass_t rdclass; dns_rdatatype_t type; dns_ttl_t ttl; ISC_LIST(dns_rdata_t) rdata; @@ -83,4 +87,6 @@ dns_rdatalist_tordataset(dns_rdatalist_t *rdatalist, * DNS_R_SUCCESS */ +ISC_LANG_ENDDECLS + #endif /* DNS_RDATALIST_H */ diff --git a/lib/dns/include/dns/rdataset.h b/lib/dns/include/dns/rdataset.h index a7b2ed45f2..731027c284 100644 --- a/lib/dns/include/dns/rdataset.h +++ b/lib/dns/include/dns/rdataset.h @@ -52,10 +52,13 @@ #include #include +#include #include #include +ISC_LANG_BEGINDECLS + typedef struct dns_rdatasetmethods { dns_result_t (*disassociate)(dns_rdataset_t *rdataset); dns_result_t (*first)(dns_rdataset_t *rdataset); @@ -84,7 +87,7 @@ struct dns_rdataset { * Leaning towards the latter, since they are not frequently required * once you have the rdataset. */ - dns_rdataclass_t class; + dns_rdataclass_t rdclass; dns_rdatatype_t type; dns_ttl_t ttl; /* @@ -241,4 +244,6 @@ dns_rdataset_towire(dns_rdataset_t *rdataset, * dns_name_towire(). */ +ISC_LANG_ENDDECLS + #endif /* DNS_RDATASET_H */ diff --git a/lib/dns/include/dns/rdataslab.h b/lib/dns/include/dns/rdataslab.h index 8e81c3aabe..704cc71156 100644 --- a/lib/dns/include/dns/rdataslab.h +++ b/lib/dns/include/dns/rdataslab.h @@ -48,10 +48,13 @@ ***/ #include +#include #include #include +ISC_LANG_BEGINDECLS + /*** *** Functions ***/ @@ -89,4 +92,6 @@ dns_rdataslab_size(unsigned char *slab, unsigned int reservelen); * The number of bytes in the slab, including the reservelen. */ +ISC_LANG_ENDDECLS + #endif /* DNS_RDATADLAB_H */ diff --git a/lib/dns/include/dns/rdatatype.h b/lib/dns/include/dns/rdatatype.h index 91be8888e1..ff149eaa7a 100644 --- a/lib/dns/include/dns/rdatatype.h +++ b/lib/dns/include/dns/rdatatype.h @@ -18,8 +18,12 @@ #ifndef DNS_RDATATYPE_H #define DNS_RDATATYPE_H 1 +#include + #include +ISC_LANG_BEGINDECLS + dns_result_t dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source); /* @@ -55,4 +59,6 @@ dns_result_t dns_rdatatype_totext(dns_rdatatype_t type, * DNS_R_NOSPACE target buffer is too small */ +ISC_LANG_ENDDECLS + #endif /* DNS_RDATATYPE_H */ diff --git a/lib/dns/include/dns/result.h b/lib/dns/include/dns/result.h index b03e2cc1fc..f687cd3bb0 100644 --- a/lib/dns/include/dns/result.h +++ b/lib/dns/include/dns/result.h @@ -18,6 +18,10 @@ #ifndef DNS_RESULT_H #define DNS_RESULT_H 1 +#include + +ISC_LANG_BEGINDECLS + typedef unsigned int dns_result_t; #define DNS_R_SUCCESS 0 @@ -58,4 +62,6 @@ typedef unsigned int dns_result_t; char * dns_result_totext(dns_result_t); +ISC_LANG_ENDDECLS + #endif /* DNS_RESULT_H */ diff --git a/lib/dns/include/dns/secalg.h b/lib/dns/include/dns/secalg.h index 41ea809c2b..e382354547 100644 --- a/lib/dns/include/dns/secalg.h +++ b/lib/dns/include/dns/secalg.h @@ -18,8 +18,12 @@ #ifndef DNS_SECALG_H #define DNS_SECALG_H 1 +#include + #include +ISC_LANG_BEGINDECLS + dns_result_t dns_secalg_fromtext(dns_secalg_t *secalgp, isc_textregion_t *source); /* @@ -54,4 +58,6 @@ dns_result_t dns_secalg_totext(dns_secalg_t secalg, isc_buffer_t *target); * DNS_R_NOSPACE target buffer is too small */ +ISC_LANG_ENDDECLS + #endif /* DNS_SECALG_H */ diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index 3446b1e45a..e2621d68b5 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -26,10 +26,13 @@ * include the appropriate .h file too. */ +#include #include #include #include +ISC_LANG_BEGINDECLS + typedef isc_region_t dns_label_t; typedef struct dns_name dns_name_t; typedef ISC_LIST(dns_name_t) dns_namelist_t; @@ -75,14 +78,14 @@ enum { dns_rdatatype_none = 0, TYPEENUM dns_rdatatype_any = 255 -} ; +}; #include enum { CLASSENUM dns_rdataclass_none = 0 /* dns_rdataclass_any = 255 TSIG is class ANY specific */ -} ; +}; enum { /* standard rcodes */ @@ -104,4 +107,6 @@ enum { dns_rcode_badmode = 19 }; +ISC_LANG_ENDDECLS + #endif /* DNS_TYPES_H */ diff --git a/lib/dns/master.c b/lib/dns/master.c index a65adaa340..4c16e27300 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: master.c,v 1.11 1999/02/10 05:25:36 marka Exp $ */ + /* $Id: master.c,v 1.12 1999/03/04 02:47:18 halley Exp $ */ #include @@ -91,7 +91,7 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, dns_rdataclass_t zclass, int *soacount, int *nscount, dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx) { - dns_rdataclass_t class; + dns_rdataclass_t rdclass; dns_rdatatype_t type; isc_uint32_t ttl = 0; isc_uint32_t default_ttl = 0; @@ -376,7 +376,7 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, } type = 0; - class = 0; + rdclass = 0; GETTOKEN(lex, ISC_LEXOPT_NUMBER, &token, ISC_FALSE); @@ -409,7 +409,8 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, goto cleanup; } - if (dns_rdataclass_fromtext(&class, &token.value.as_textregion) + if (dns_rdataclass_fromtext(&rdclass, + &token.value.as_textregion) == DNS_R_SUCCESS) GETTOKEN(lex, 0, &token, ISC_FALSE); @@ -425,7 +426,7 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, if (result != DNS_R_SUCCESS) goto cleanup; - if (class != 0 && class != zclass) { + if (rdclass != 0 && rdclass != zclass) { char buf1[32]; char buf2[32]; unsigned int len1, len2; @@ -434,7 +435,7 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, isc_buffer_init(&buffer, buf1, sizeof buf1, ISC_BUFFERTYPE_TEXT); - result = dns_rdataclass_totext(class, &buffer); + result = dns_rdataclass_totext(rdclass, &buffer); if (result != DNS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "dns_rdataclass_totext() failed: %s", @@ -446,7 +447,7 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, len1 = region.length; isc_buffer_init(&buffer, buf2, sizeof buf2, ISC_BUFFERTYPE_TEXT); - result = dns_rdataclass_totext(class, &buffer); + result = dns_rdataclass_totext(rdclass, &buffer); if (result != DNS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "dns_rdataclass_totext() failed: %s", @@ -506,7 +507,7 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, } this = &rdatalist[rdlcount++]; this->type = type; - this->class = zclass; + this->rdclass = zclass; this->ttl = ttl; ISC_LIST_INIT(this->rdata); ISC_LINK_INIT(this, link); @@ -534,7 +535,7 @@ dns_master_load(char *master_file, dns_name_t *top, dns_name_t *origin, rdata_size += 512; rdata = new_rdata; } - result = dns_rdata_fromtext(&rdata[rdcount], class, type, + result = dns_rdata_fromtext(&rdata[rdcount], rdclass, type, lex, &origin_name, ISC_FALSE, &target, callbacks); if (result != DNS_R_SUCCESS) diff --git a/lib/dns/rdatalist.c b/lib/dns/rdatalist.c index 6525024bb2..721e9f8caa 100644 --- a/lib/dns/rdatalist.c +++ b/lib/dns/rdatalist.c @@ -48,7 +48,7 @@ dns_rdatalist_tordataset(dns_rdatalist_t *rdatalist, REQUIRE(rdataset->methods == NULL); rdataset->methods = &methods; - rdataset->class = rdatalist->class; + rdataset->rdclass = rdatalist->rdclass; rdataset->type = rdatalist->type; rdataset->ttl = rdatalist->ttl; rdataset->private1 = rdatalist; diff --git a/lib/dns/rdataset.c b/lib/dns/rdataset.c index 2eb681be10..4ef8ac9f33 100644 --- a/lib/dns/rdataset.c +++ b/lib/dns/rdataset.c @@ -40,7 +40,7 @@ dns_rdataset_init(dns_rdataset_t *rdataset) { rdataset->magic = DNS_RDATASET_MAGIC; rdataset->methods = NULL; ISC_LINK_INIT(rdataset, link); - rdataset->class = 0; + rdataset->rdclass = 0; rdataset->type = 0; rdataset->ttl = 0; rdataset->private1 = NULL; @@ -62,7 +62,7 @@ dns_rdataset_invalidate(dns_rdataset_t *rdataset) { rdataset->magic = 0; ISC_LINK_INIT(rdataset, link); - rdataset->class = 0; + rdataset->rdclass = 0; rdataset->type = 0; rdataset->ttl = 0; rdataset->private1 = NULL; @@ -84,7 +84,7 @@ dns_rdataset_disassociate(dns_rdataset_t *rdataset) { (rdataset->methods->disassociate)(rdataset); rdataset->methods = NULL; ISC_LINK_INIT(rdataset, link); - rdataset->class = 0; + rdataset->rdclass = 0; rdataset->type = 0; rdataset->ttl = 0; rdataset->private1 = NULL; @@ -212,7 +212,7 @@ dns_rdataset_totext(dns_rdataset_t *rdataset, return (DNS_R_NOSPACE); memcpy(r.base, ttl, length); isc_buffer_add(target, length); - result = dns_rdataclass_totext(rdataset->class, target); + result = dns_rdataclass_totext(rdataset->rdclass, target); if (result != DNS_R_SUCCESS) return (result); isc_buffer_available(target, &r); @@ -312,7 +312,7 @@ dns_rdataset_towire(dns_rdataset_t *rdataset, return (DNS_R_NOSPACE); } isc_buffer_putuint16(target, rdataset->type); - isc_buffer_putuint16(target, rdataset->class); + isc_buffer_putuint16(target, rdataset->rdclass); isc_buffer_putuint32(target, rdataset->ttl); /*