[ldns-users] python wrapper for ldns_rr_new_frm_fp_l

Bedrich Kosata bedrich.kosata at nic.cz
Thu May 5 08:33:49 UTC 2011

Hi everybody,

after working with the python wrapper around ldns_rr_new_frm_fp_l, I 
would like to propose a few changes.

The C version of the ldns_rr_new_frm_fp_l function stores the state of 
zone file parsing in 3 different variables - origin, prev(ious owner) 
and (default) ttl. Due to pointer and pointer to pointer usage, these 
are automatically updated by calls to ldns_rr_new_frm_fp_l and the only 
thing the programmer has to take care of it not to touch these.

However, in Python this is not possible and the wrapper goes around this 
problem by returning the new values of origin, prev and ttl as part of 
the result of the function. It is then left to the programmer to send 
these updated values back to the subsequent calls of 
ldns.ldns_rr_new_frm_fp_l_. I attach a script that shows how to do this 
and I would suggest putting it into the examples directory as reference.

I also added a convenience function (a generator) into the python 
interface, so that the context is managed automatically and the 
programmer does not have to take care of it. It is part of the patch I 
attach. There is also a demo script for this function attached.

Another change that I made in the patch is that I removed the 5th 
argument, which indicated whether the result should contain line number. 
As the value of this argument influenced the number and order of items 
in the returned tuple, which I do not consider a good design, I removed 
it and changed the result, so that it always contains the number of 
lines parsed in this step and the format of the result is always the same.

Please let me know if these changes are acceptable or if there is 
something else needed.

With best regards


Bedrich Kosata
CZ.NIC Labs <http://labs.nic.cz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldns_rr_new_frm_fp_l_iter.patch
Type: text/x-patch
Size: 5063 bytes
Desc: not available
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20110505/16207ac6/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldns_rr_iter_frm_fp_l.demo.py
Type: text/x-python
Size: 212 bytes
Desc: not available
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20110505/16207ac6/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldns_rr_new_frm_fp_l.demo.py
Type: text/x-python
Size: 1210 bytes
Desc: not available
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20110505/16207ac6/attachment-0001.py>

More information about the ldns-users mailing list