1ldns(3)                    Library Functions Manual                    ldns(3)
2
3
4

NAME

6       ldns_buffer, ldns_buffer_new, ldns_buffer_new_frm_data, ldns_buf‐
7       fer_clear, ldns_buffer_printf, ldns_buffer_free, ldns_buffer_copy,
8       ldns_buffer_export, ldns_buffer_export2str, ldns_buffer2str - buffers
9
10

SYNOPSIS

12       #include <stdint.h>
13       #include <stdbool.h>
14
15       #include <ldns/ldns.h>
16
17       ldns_buffer* ldns_buffer_new(size_t capacity);
18
19       void ldns_buffer_new_frm_data(ldns_buffer *buffer, const void *data,
20       size_t size);
21
22       void ldns_buffer_clear(ldns_buffer *buffer);
23
24       int ldns_buffer_printf(ldns_buffer *buffer, const char *format, ...);
25
26       void ldns_buffer_free(ldns_buffer *buffer);
27
28       void ldns_buffer_copy(ldns_buffer* result, const ldns_buffer* from);
29
30       void* ldns_buffer_export(ldns_buffer *buffer);
31
32       char* ldns_buffer_export2str(ldns_buffer *buffer);
33
34       char* ldns_buffer2str(ldns_buffer *buffer);
35

DESCRIPTION

37       ldns_buffer
38              implementation of buffers to ease operations
39
40              ldns_buffers can contain arbitrary information, per octet. You
41              can write
42              to the current end of a buffer, read from the current position,
43              and
44              access any data within it.
45
46              Example use of buffers is in the source code of \ref host2str.c
47              struct ldns_struct_buffer
48              {
49                   The current position used for reading/writing:
50                   size_t   _position;
51
52                   The read/write limit:
53                   size_t   _limit;
54
55                   The amount of data the buffer can contain:
56                   size_t   _capacity;
57
58                   The data contained in the buffer:
59                   uint8_t *_data;
60
61                   If the buffer is fixed it cannot be resized:
62                   unsigned _fixed : 1;
63
64                   /** The current state of the buffer. If writing to the buf‐
65              fer fails
66                    * for any reason, this value is changed. This way, you can
67              perform
68                    * multiple writes in sequence and check for success after‐
69              wards. */
70                   ldns_status _status;
71              };
72              typedef struct ldns_struct_buffer ldns_buffer;
73
74       ldns_buffer_new() creates a new buffer with the specified capacity.
75
76              capacity: the size (in bytes) to allocate for the buffer
77              Returns the created buffer
78
79       ldns_buffer_new_frm_data() creates a buffer with the specified data.
80              The data IS copied and MEMORY allocations are done.  The buffer
81              is not fixed and can be resized using buffer_reserve().
82
83              buffer: pointer to the buffer to put the data in
84              data: the data to encapsulate in the buffer
85              size: the size of the data
86
87       ldns_buffer_clear() clears the buffer and make it ready for writing.
88              The buffer's limit is set to the capacity and the position is
89              set to 0.
90              buffer: the buffer to clear
91
92       ldns_buffer_printf() prints to the buffer, increasing the capacity if
93              required using buffer_reserve(). The buffer's position is set to
94              the terminating '\\0' Returns the number of characters written
95              (not including the terminating '\\0') or -1 on failure.
96
97       ldns_buffer_free() frees the buffer.
98              *buffer: the buffer to be freed
99              Returns void
100
101       ldns_buffer_copy() Copy contents of the from buffer to the result buf‐
102              fer and then flips the result buffer. Data will be silently
103              truncated if the result buffer is too small.
104              *result: resulting buffer which is copied to.
105              *from: what to copy to result.
106
107       ldns_buffer_export() Makes the buffer fixed and returns a pointer to
108              the data.  The caller is responsible for free'ing the result.
109              *buffer: the buffer to be exported
110              Returns void
111
112       ldns_buffer_export2str() Exports and returns the data in the buffer as
113              a null terminated char * string. The returned string must be
114              freed by the caller.  The buffer must be in write modus and may
115              thus not have been flipped.  The buffer is fixed after this
116              function returns.
117
118              buffer: buffer containing char * data
119              Returns null terminated char * data, or NULL on error
120
121       ldns_buffer2str() Returns a copy of the data in the buffer as a null
122              terminated char * string. The returned string must be freed by
123              the caller.  The buffer must be in write modus and may thus not
124              have been flipped.
125
126              buffer: buffer containing char * data
127              Returns null terminated char * data, or NULL on error
128

AUTHOR

130       The ldns team at NLnet Labs. Which consists out of Jelte Jansen and
131       Miek Gieben.
132
133

REPORTING BUGS

135       Please report bugs to ldns-team@nlnetlabs.nl or in our bugzilla at
136       http://www.nlnetlabs.nl/bugs/index.html
137
138
140       Copyright (c) 2004 - 2006 NLnet Labs.
141
142       Licensed under the BSD License. There is NO warranty; not even for MER‐
143       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
144
145

SEE ALSO

147       ldns_buffer_flip, ldns_buffer_rewind, ldns_buffer_position, ldns_buf‐
148       fer_set_position, ldns_buffer_skip, ldns_buffer_limit, ldns_buf‐
149       fer_set_limit, ldns_buffer_capacity, ldns_buffer_set_capacity,
150       ldns_buffer_reserve, ldns_buffer_at, ldns_buffer_begin, ldns_buf‐
151       fer_end, ldns_buffer_current, ldns_buffer_remaining_at, ldns_buf‐
152       fer_remaining, ldns_buffer_available_at, ldns_buffer_available,
153       ldns_buffer_status, ldns_buffer_status_ok, ldns_buffer_write_at,
154       ldns_buffer_write, ldns_buffer_write_string_at, ldns_buf‐
155       fer_write_string, ldns_buffer_write_u8_at, ldns_buffer_write_u8,
156       ldns_buffer_write_u16_at, ldns_buffer_write_u16, ldns_buffer_read_at,
157       ldns_buffer_read, ldns_buffer_read_u8_at, ldns_buffer_read_u8,
158       ldns_buffer_read_u16_at, ldns_buffer_read_u16, ldns_buffer_read_u32_at,
159       ldns_buffer_read_u32, ldns_buffer_write_u32, ldns_buffer_write_u32_at.
160       And perldoc Net::DNS, RFC1034, RFC1035, RFC4033, RFC4034  and RFC4035.
161

REMARKS

163       This manpage was automatically generated from the ldns source code by
164       use of Doxygen and some perl.
165
166
167
168                                  30 May 2006                          ldns(3)
Impressum