summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Bellis <ray@isc.org>2015-10-21 14:50:39 +0200
committerRay Bellis <ray@isc.org>2015-10-21 14:50:39 +0200
commitf723a72af74d06600a76f00cdf6da68a3cdbb6b6 (patch)
tree5309fe16230256b15f007a03943150c177eb3c66
parent7252f4981485170cb36993540270eedfd6a83439 (diff)
downloadldns-f723a72af74d06600a76f00cdf6da68a3cdbb6b6.tar.gz
yet more const goodness
-rw-r--r--buffer.c4
-rw-r--r--dname.c2
-rw-r--r--duration.c6
-rw-r--r--higher.c14
-rw-r--r--ldns/buffer.h34
-rw-r--r--ldns/dane.h2
-rw-r--r--ldns/dname.h5
-rw-r--r--ldns/duration.h6
-rw-r--r--ldns/higher.h8
-rw-r--r--ldns/rdata.h2
-rw-r--r--ldns/rr.h4
-rw-r--r--rdata.c4
-rw-r--r--rr.c10
13 files changed, 51 insertions, 50 deletions
diff --git a/buffer.c b/buffer.c
index fc6c17e7..e008831f 100644
--- a/buffer.c
+++ b/buffer.c
@@ -38,7 +38,7 @@ ldns_buffer_new(size_t capacity)
}
void
-ldns_buffer_new_frm_data(ldns_buffer *buffer, void *data, size_t size)
+ldns_buffer_new_frm_data(ldns_buffer *buffer, const void *data, size_t size)
{
assert(data != NULL);
@@ -165,7 +165,7 @@ ldns_bgetc(ldns_buffer *buffer)
}
void
-ldns_buffer_copy(ldns_buffer* result, ldns_buffer* from)
+ldns_buffer_copy(ldns_buffer* result, const ldns_buffer* from)
{
size_t tocopy = ldns_buffer_limit(from);
diff --git a/dname.c b/dname.c
index 55aba5d6..6701ba7d 100644
--- a/dname.c
+++ b/dname.c
@@ -87,7 +87,7 @@ ldns_dname_cat_clone(const ldns_rdf *rd1, const ldns_rdf *rd2)
}
ldns_status
-ldns_dname_cat(ldns_rdf *rd1, ldns_rdf *rd2)
+ldns_dname_cat(ldns_rdf *rd1, const ldns_rdf *rd2)
{
uint16_t left_size;
uint16_t size;
diff --git a/duration.c b/duration.c
index 6d0a388c..1abeb125 100644
--- a/duration.c
+++ b/duration.c
@@ -75,7 +75,7 @@ ldns_duration_create(void)
*
*/
int
-ldns_duration_compare(ldns_duration_type* d1, ldns_duration_type* d2)
+ldns_duration_compare(const ldns_duration_type* d1, const ldns_duration_type* d2)
{
if (!d1 && !d2) {
return 0;
@@ -213,7 +213,7 @@ digits_in_number(time_t duration)
*
*/
char*
-ldns_duration2string(ldns_duration_type* duration)
+ldns_duration2string(const ldns_duration_type* duration)
{
char* str = NULL, *num = NULL;
size_t count = 2;
@@ -316,7 +316,7 @@ ldns_duration2string(ldns_duration_type* duration)
*
*/
time_t
-ldns_duration2time(ldns_duration_type* duration)
+ldns_duration2time(const ldns_duration_type* duration)
{
time_t period = 0;
diff --git a/higher.c b/higher.c
index fa0e3d70..e3077aee 100644
--- a/higher.c
+++ b/higher.c
@@ -21,8 +21,8 @@
#endif /* HAVE_SSL */
ldns_rr_list *
-ldns_get_rr_list_addr_by_name(ldns_resolver *res, ldns_rdf *name, ldns_rr_class c,
- uint16_t flags)
+ldns_get_rr_list_addr_by_name(ldns_resolver *res, const ldns_rdf *name,
+ ldns_rr_class c, uint16_t flags)
{
ldns_pkt *pkt;
ldns_rr_list *aaaa;
@@ -104,8 +104,8 @@ ldns_get_rr_list_addr_by_name(ldns_resolver *res, ldns_rdf *name, ldns_rr_class
}
ldns_rr_list *
-ldns_get_rr_list_name_by_addr(ldns_resolver *res, ldns_rdf *addr, ldns_rr_class c,
- uint16_t flags)
+ldns_get_rr_list_name_by_addr(ldns_resolver *res, const ldns_rdf *addr,
+ ldns_rr_class c, uint16_t flags)
{
ldns_pkt *pkt;
ldns_rr_list *names;
@@ -262,8 +262,8 @@ ldns_get_rr_list_hosts_frm_file(char *filename)
}
uint16_t
-ldns_getaddrinfo(ldns_resolver *res, ldns_rdf *node, ldns_rr_class c,
- ldns_rr_list **ret)
+ldns_getaddrinfo(ldns_resolver *res, const ldns_rdf *node,
+ ldns_rr_class c, ldns_rr_list **ret)
{
ldns_rdf_type t;
uint16_t names_found;
@@ -302,7 +302,7 @@ ldns_getaddrinfo(ldns_resolver *res, ldns_rdf *node, ldns_rr_class c,
}
bool
-ldns_nsec_type_check(ldns_rr *nsec, ldns_rr_type t)
+ldns_nsec_type_check(const ldns_rr *nsec, ldns_rr_type t)
{
switch (ldns_rr_get_type(nsec)) {
case LDNS_RR_TYPE_NSEC : if (ldns_rr_rd_count(nsec) < 2) {
diff --git a/ldns/buffer.h b/ldns/buffer.h
index 68e7747e..f49a550b 100644
--- a/ldns/buffer.h
+++ b/ldns/buffer.h
@@ -74,12 +74,12 @@ typedef struct ldns_struct_buffer ldns_buffer;
#ifdef NDEBUG
INLINE void
-ldns_buffer_invariant(ldns_buffer *ATTR_UNUSED(buffer))
+ldns_buffer_invariant(const ldns_buffer *ATTR_UNUSED(buffer))
{
}
#else
INLINE void
-ldns_buffer_invariant(ldns_buffer *buffer)
+ldns_buffer_invariant(const ldns_buffer *buffer)
{
assert(buffer != NULL);
assert(buffer->_position <= buffer->_limit);
@@ -105,7 +105,7 @@ ldns_buffer *ldns_buffer_new(size_t capacity);
* \param[in] data the data to encapsulate in the buffer
* \param[in] size the size of the data
*/
-void ldns_buffer_new_frm_data(ldns_buffer *buffer, void *data, size_t size);
+void ldns_buffer_new_frm_data(ldns_buffer *buffer, const void *data, size_t size);
/**
* clears the buffer and make it ready for writing. The buffer's limit
@@ -156,7 +156,7 @@ INLINE void ldns_buffer_rewind(ldns_buffer *buffer)
* \return the current position
*/
INLINE size_t
-ldns_buffer_position(ldns_buffer *buffer)
+ldns_buffer_position(const ldns_buffer *buffer)
{
return buffer->_position;
}
@@ -194,7 +194,7 @@ ldns_buffer_skip(ldns_buffer *buffer, ssize_t count)
* \return the size
*/
INLINE size_t
-ldns_buffer_limit(ldns_buffer *buffer)
+ldns_buffer_limit(const ldns_buffer *buffer)
{
return buffer->_limit;
}
@@ -220,7 +220,7 @@ ldns_buffer_set_limit(ldns_buffer *buffer, size_t limit)
* \return the number of bytes
*/
INLINE size_t
-ldns_buffer_capacity(ldns_buffer *buffer)
+ldns_buffer_capacity(const ldns_buffer *buffer)
{
return buffer->_capacity;
}
@@ -279,7 +279,7 @@ ldns_buffer_begin(const ldns_buffer *buffer)
* \return the pointer
*/
INLINE uint8_t *
-ldns_buffer_end(ldns_buffer *buffer)
+ldns_buffer_end(const ldns_buffer *buffer)
{
return ldns_buffer_at(buffer, buffer->_limit);
}
@@ -290,7 +290,7 @@ ldns_buffer_end(ldns_buffer *buffer)
* \return the pointer
*/
INLINE uint8_t *
-ldns_buffer_current(ldns_buffer *buffer)
+ldns_buffer_current(const ldns_buffer *buffer)
{
return ldns_buffer_at(buffer, buffer->_position);
}
@@ -303,7 +303,7 @@ ldns_buffer_current(ldns_buffer *buffer)
* \return number of bytes
*/
INLINE size_t
-ldns_buffer_remaining_at(ldns_buffer *buffer, size_t at)
+ldns_buffer_remaining_at(const ldns_buffer *buffer, size_t at)
{
ldns_buffer_invariant(buffer);
assert(at <= buffer->_limit);
@@ -317,7 +317,7 @@ ldns_buffer_remaining_at(ldns_buffer *buffer, size_t at)
* \return the number of bytes
*/
INLINE size_t
-ldns_buffer_remaining(ldns_buffer *buffer)
+ldns_buffer_remaining(const ldns_buffer *buffer)
{
return ldns_buffer_remaining_at(buffer, buffer->_position);
}
@@ -332,7 +332,7 @@ ldns_buffer_remaining(ldns_buffer *buffer)
* \return true or false (as int?)
*/
INLINE int
-ldns_buffer_available_at(ldns_buffer *buffer, size_t at, size_t count)
+ldns_buffer_available_at(const ldns_buffer *buffer, size_t at, size_t count)
{
return count <= ldns_buffer_remaining_at(buffer, at);
}
@@ -344,7 +344,7 @@ ldns_buffer_available_at(ldns_buffer *buffer, size_t at, size_t count)
* \return true or false (as int?)
*/
INLINE int
-ldns_buffer_available(ldns_buffer *buffer, size_t count)
+ldns_buffer_available(const ldns_buffer *buffer, size_t count)
{
return ldns_buffer_available_at(buffer, buffer->_position, count);
}
@@ -482,7 +482,7 @@ ldns_buffer_write_u32(ldns_buffer *buffer, uint32_t data)
* \param[in] count the length of the data to copy
*/
INLINE void
-ldns_buffer_read_at(ldns_buffer *buffer, size_t at, void *data, size_t count)
+ldns_buffer_read_at(const ldns_buffer *buffer, size_t at, void *data, size_t count)
{
assert(ldns_buffer_available_at(buffer, at, count));
memcpy(data, buffer->_data + at, count);
@@ -508,7 +508,7 @@ ldns_buffer_read(ldns_buffer *buffer, void *data, size_t count)
* \return 1 byte integer
*/
INLINE uint8_t
-ldns_buffer_read_u8_at(ldns_buffer *buffer, size_t at)
+ldns_buffer_read_u8_at(const ldns_buffer *buffer, size_t at)
{
assert(ldns_buffer_available_at(buffer, at, sizeof(uint8_t)));
return buffer->_data[at];
@@ -585,7 +585,7 @@ ldns_buffer_read_u32(ldns_buffer *buffer)
* \return the status
*/
INLINE ldns_status
-ldns_buffer_status(ldns_buffer *buffer)
+ldns_buffer_status(const ldns_buffer *buffer)
{
return buffer->_status;
}
@@ -596,7 +596,7 @@ ldns_buffer_status(ldns_buffer *buffer)
* \return true or false
*/
INLINE bool
-ldns_buffer_status_ok(ldns_buffer *buffer)
+ldns_buffer_status_ok(const ldns_buffer *buffer)
{
if (buffer) {
return ldns_buffer_status(buffer) == LDNS_STATUS_OK;
@@ -636,7 +636,7 @@ void *ldns_buffer_export(ldns_buffer *buffer);
* \param[out] *result resulting buffer which is copied to.
* \param[in] *from what to copy to result.
*/
-void ldns_buffer_copy(ldns_buffer* result, ldns_buffer* from);
+void ldns_buffer_copy(ldns_buffer* result, const ldns_buffer* from);
#ifdef __cplusplus
}
diff --git a/ldns/dane.h b/ldns/dane.h
index b72ad1c2..727d9bff 100644
--- a/ldns/dane.h
+++ b/ldns/dane.h
@@ -123,7 +123,7 @@ typedef enum ldns_enum_dane_transport ldns_dane_transport;
* \param[out] tlsa_owner The created dname.
* \param[in] name The dname that should be prefixed.
* \param[in] port The service port number for wich the name should be created.
- * \param[in] transport The transport for wich the name should be created.
+ * \param[in] transport The transport for which the name should be created.
* \return LDNS_STATUS_OK on success or an error code otherwise.
*/
ldns_status ldns_dane_create_tlsa_owner(ldns_rdf** tlsa_owner,
diff --git a/ldns/dname.h b/ldns/dname.h
index cefc07da..494ef285 100644
--- a/ldns/dname.h
+++ b/ldns/dname.h
@@ -62,7 +62,7 @@ ldns_rdf *ldns_dname_cat_clone(const ldns_rdf *rd1, const ldns_rdf *rd2);
* \param[in] rd2 the rightside
* \return LDNS_STATUS_OK on success
*/
-ldns_status ldns_dname_cat(ldns_rdf *rd1, ldns_rdf *rd2);
+ldns_status ldns_dname_cat(ldns_rdf *rd1, const ldns_rdf *rd2);
/**
* Returns a clone of the given dname with the labels
@@ -108,7 +108,8 @@ uint8_t ldns_dname_label_count(const ldns_rdf *r);
ldns_rdf *ldns_dname_new_frm_str(const char *str);
/**
- * Create a new dname rdf from a string
+ * Create a new dname rdf from a string. The data pointer
+ * is stored in the rdf, not a copy of the data
* \param[in] s the size of the new dname
* \param[in] *data pointer to the actual data
*
diff --git a/ldns/duration.h b/ldns/duration.h
index f12edc42..e6282ac2 100644
--- a/ldns/duration.h
+++ b/ldns/duration.h
@@ -73,7 +73,7 @@ ldns_duration_type* ldns_duration_create(void);
* \return int 0 if equal, -1 if d1 < d2, 1 if d2 < d1
*
*/
-int ldns_duration_compare(ldns_duration_type* d1, ldns_duration_type* d2);
+int ldns_duration_compare(const ldns_duration_type* d1, const ldns_duration_type* d2);
/**
* Create a duration from string.
@@ -89,7 +89,7 @@ ldns_duration_type* ldns_duration_create_from_string(const char* str);
* \return char* string-format duration
*
*/
-char* ldns_duration2string(ldns_duration_type* duration);
+char* ldns_duration2string(const ldns_duration_type* duration);
/**
* Convert a duration to a time.
@@ -97,7 +97,7 @@ char* ldns_duration2string(ldns_duration_type* duration);
* \return time_t time-format duration
*
*/
-time_t ldns_duration2time(ldns_duration_type* duration);
+time_t ldns_duration2time(const ldns_duration_type* duration);
/**
* Clean up duration.
diff --git a/ldns/higher.h b/ldns/higher.h
index 597e1343..59c28020 100644
--- a/ldns/higher.h
+++ b/ldns/higher.h
@@ -34,7 +34,7 @@ extern "C" {
* \param[in] c the class to use
* \param[in] flags give some optional flags to the query
*/
-ldns_rr_list *ldns_get_rr_list_addr_by_name(ldns_resolver *r, ldns_rdf *name, ldns_rr_class c, uint16_t flags);
+ldns_rr_list *ldns_get_rr_list_addr_by_name(ldns_resolver *r, const ldns_rdf *name, ldns_rr_class c, uint16_t flags);
/**
* ask the resolver about the address
@@ -44,7 +44,7 @@ ldns_rr_list *ldns_get_rr_list_addr_by_name(ldns_resolver *r, ldns_rdf *name, ld
* \param[in] c the class to use
* \param[in] flags give some optional flags to the query
*/
-ldns_rr_list *ldns_get_rr_list_name_by_addr(ldns_resolver *r, ldns_rdf *addr, ldns_rr_class c, uint16_t flags);
+ldns_rr_list *ldns_get_rr_list_name_by_addr(ldns_resolver *r, const ldns_rdf *addr, ldns_rr_class c, uint16_t flags);
/**
* wade through fp (a /etc/hosts like file)
@@ -86,7 +86,7 @@ ldns_rr_list *ldns_get_rr_list_hosts_frm_file(char *filename);
* \param[out] list put the found RR's in this list
* \return the number of RR found.
*/
-uint16_t ldns_getaddrinfo(ldns_resolver *res, ldns_rdf *node, ldns_rr_class c, ldns_rr_list **list);
+uint16_t ldns_getaddrinfo(ldns_resolver *res, const ldns_rdf *node, ldns_rr_class c, ldns_rr_list **list);
/**
* Check if t is enumerated in the nsec type rdata
@@ -94,7 +94,7 @@ uint16_t ldns_getaddrinfo(ldns_resolver *res, ldns_rdf *node, ldns_rr_class c, l
* \param[in] t the type to check for
* \return true when t is found, otherwise return false
*/
-bool ldns_nsec_type_check(ldns_rr *nsec, ldns_rr_type t);
+bool ldns_nsec_type_check(const ldns_rr *nsec, ldns_rr_type t);
/**
* Print a number of rdf's of the RR. The rdfnum-list must
diff --git a/ldns/rdata.h b/ldns/rdata.h
index 22665b19..981dd94a 100644
--- a/ldns/rdata.h
+++ b/ldns/rdata.h
@@ -351,7 +351,7 @@ ldns_rdf *ldns_native2rdf_int16_data(size_t size, uint8_t *data);
* \param[in] *rd rdf to be reversed
* \return the reversed rdf (a newly created rdf)
*/
-ldns_rdf *ldns_rdf_address_reverse(ldns_rdf *rd);
+ldns_rdf *ldns_rdf_address_reverse(const ldns_rdf *rd);
/**
* returns the native uint8_t representation from the rdf.
diff --git a/ldns/rr.h b/ldns/rr.h
index c3e70c4f..8196c020 100644
--- a/ldns/rr.h
+++ b/ldns/rr.h
@@ -412,7 +412,7 @@ void ldns_rr_free(ldns_rr *rr);
* \return a status msg describing an error or LDNS_STATUS_OK
*/
ldns_status ldns_rr_new_frm_str(ldns_rr **n, const char *str,
- uint32_t default_ttl, ldns_rdf *origin,
+ uint32_t default_ttl, const ldns_rdf *origin,
ldns_rdf **prev);
/**
@@ -429,7 +429,7 @@ ldns_status ldns_rr_new_frm_str(ldns_rr **n, const char *str,
* \return a status msg describing an error or LDNS_STATUS_OK
*/
ldns_status ldns_rr_new_question_frm_str(ldns_rr **n, const char *str,
- ldns_rdf *origin, ldns_rdf **prev);
+ const ldns_rdf *origin, ldns_rdf **prev);
/**
* creates a new rr from a file containing a string.
diff --git a/rdata.c b/rdata.c
index 6eb0096e..3bc4b391 100644
--- a/rdata.c
+++ b/rdata.c
@@ -410,7 +410,7 @@ ldns_rdf_new_frm_fp_l(ldns_rdf **rdf, ldns_rdf_type type, FILE *fp, int *line_nr
}
ldns_rdf *
-ldns_rdf_address_reverse(ldns_rdf *rd)
+ldns_rdf_address_reverse(const ldns_rdf *rd)
{
uint8_t buf_4[LDNS_IP4ADDRLEN];
uint8_t buf_6[LDNS_IP6ADDRLEN * 2];
@@ -475,7 +475,7 @@ ldns_rdf_address_reverse(ldns_rdf *rd)
/* some foo magic to reverse the nibbles ... */
for (nbit = 127; nbit >= 0; nbit = nbit - 4) {
- /* calculate octett (8 bit) */
+ /* calculate octet (8 bit) */
octet = ( ((unsigned int) nbit) & 0x78) >> 3;
/* calculate nibble */
nnibble = ( ((unsigned int) nbit) & 0x04) >> 2;
diff --git a/rr.c b/rr.c
index c73df3db..6d0c32e8 100644
--- a/rr.c
+++ b/rr.c
@@ -111,8 +111,8 @@ ldns_rdf_type_maybe_quoted(ldns_rdf_type rdf_type)
*/
static ldns_status
ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str,
- uint32_t default_ttl, ldns_rdf *origin,
- ldns_rdf **prev, bool question)
+ uint32_t default_ttl, const ldns_rdf *origin,
+ ldns_rdf **prev, bool question)
{
ldns_rr *new;
const ldns_rr_descriptor *desc;
@@ -647,8 +647,8 @@ error:
ldns_status
ldns_rr_new_frm_str(ldns_rr **newrr, const char *str,
- uint32_t default_ttl, ldns_rdf *origin,
- ldns_rdf **prev)
+ uint32_t default_ttl, const ldns_rdf *origin,
+ ldns_rdf **prev)
{
return ldns_rr_new_frm_str_internal(newrr,
str,
@@ -660,7 +660,7 @@ ldns_rr_new_frm_str(ldns_rr **newrr, const char *str,
ldns_status
ldns_rr_new_question_frm_str(ldns_rr **newrr, const char *str,
- ldns_rdf *origin, ldns_rdf **prev)
+ const ldns_rdf *origin, ldns_rdf **prev)
{
return ldns_rr_new_frm_str_internal(newrr,
str,