]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/buffer.h
2 * No copyright is claimed. This code is in the public domain; do with
5 #ifndef UTIL_LINUX_BUFFER
6 #define UTIL_LINUX_BUFFER
11 char *begin
; /* begin of the data */
12 char *end
; /* current end of data */
14 size_t sz
; /* allocated space for data */
17 char *encoded
; /* encoded data (from mbs_safe_encode_to_buffer)) */
18 size_t encoded_sz
; /* space allocated for encoded data */
20 char **ptrs
; /* saved pointers */
21 size_t nptrs
; /* number of saved pointers */
24 #define UL_INIT_BUFFER { .begin = NULL }
26 void ul_buffer_reset_data(struct ul_buffer
*buf
);
27 void ul_buffer_free_data(struct ul_buffer
*buf
);
28 int ul_buffer_is_empty(struct ul_buffer
*buf
);
29 void ul_buffer_set_chunksize(struct ul_buffer
*buf
, size_t sz
);
30 void ul_buffer_refer_string(struct ul_buffer
*buf
, char *str
);
31 int ul_buffer_alloc_data(struct ul_buffer
*buf
, size_t sz
);
32 int ul_buffer_append_data(struct ul_buffer
*buf
, const char *data
, size_t sz
);
33 int ul_buffer_append_string(struct ul_buffer
*buf
, const char *str
);
34 int ul_buffer_append_ntimes(struct ul_buffer
*buf
, size_t n
, const char *str
);
35 int ul_buffer_set_data(struct ul_buffer
*buf
, const char *data
, size_t sz
);
37 char *ul_buffer_get_data(struct ul_buffer
*buf
, size_t *sz
, size_t *width
);
38 char *ul_buffer_get_safe_data(struct ul_buffer
*buf
, size_t *sz
, size_t *width
, const char *safechars
);
40 size_t ul_buffer_get_bufsiz(struct ul_buffer
*buf
);
42 int ul_buffer_save_pointer(struct ul_buffer
*buf
, unsigned short ptr_idx
);
43 char *ul_buffer_get_pointer(struct ul_buffer
*buf
, unsigned short ptr_idx
);
44 size_t ul_buffer_get_pointer_length(struct ul_buffer
*buf
, unsigned short ptr_idx
);
45 size_t ul_buffer_get_safe_pointer_width(struct ul_buffer
*buf
, unsigned short ptr_idx
);
48 #endif /* UTIL_LINUX_BUFFER */