1.7.0
+ * Added ldns_rdf.data_as_bytearray(). The method returns a bytearray object
+ containing rdf data.
* Changed the behaviour of ldns_resolver.trusted_key() in order to prevent
memory corrupotion and leaks.
* Fixed memory leaks when destroying ldns_resolver.
set_error()
+#if not error_detected:
+if True:
+ method_name = "ldns_rdf.data_as_bytearray()"
+ rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.")
+ try:
+ ret = rdf.data_as_bytearray()
+ if not isinstance(ret, bytearray):
+ set_error()
+ if len(ret) != 12:
+ set_error()
+ except:
+ set_error()
+
+
#if not error_detected:
if True:
method_name = "ldns_rdf.dname_compare()"
%}
+%inline
+%{
+ /*!
+ * @brief Returns the rdf data organised into a list of bytes.
+ */
+ PyObject * ldns_rdf_data_as_bytearray(const ldns_rdf *rdf)
+ {
+ Py_ssize_t len;
+ uint8_t *data;
+
+ assert(rdf != NULL);
+
+ len = ldns_rdf_size(rdf);
+ data = ldns_rdf_data(rdf);
+
+ return PyByteArray_FromStringAndSize((char *) data, len);
+ }
+%}
+
+
/* ========================================================================= */
/* Encapsulating Python code. */
/* ========================================================================= */
#parameters: const ldns_rdf *,
#retvals: uint8_t *
+ def data_as_bytearray(self):
+ """
+ Returns the data of the rdf as a bytearray.
+
+ :return: (bytearray) Bytearray containing the rdf data.
+ """
+ return _ldns.ldns_rdf_data_as_bytearray(self)
+ #parameters: const ldns_rdf *,
+ #retvals: bytearray
+
def get_type(self):
"""
Returns the type of the rdf.