Merge Trond
[m6w6/libmemcached] / libmemcached / memcached_string.h
1 /*
2 * Summary: String structure used for libmemcached.
3 *
4 * Copy: See Copyright for the status of this software.
5 *
6 * Author: Brian Aker
7 */
8
9 #ifndef __MEMCACHED_STRING_H__
10 #define __MEMCACHED_STRING_H__
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 struct memcached_string_st {
17 memcached_st *root;
18 char *end;
19 char *string;
20 size_t current_size;
21 size_t block_size;
22 bool is_allocated;
23 };
24
25 #define memcached_string_length(A) (size_t)((A)->end - (A)->string)
26 #define memcached_string_set_length(A, B) (A)->end= (A)->string + B
27 #define memcached_string_size(A) (A)->current_size
28 #define memcached_string_value(A) (A)->string
29
30 LIBMEMCACHED_API
31 memcached_string_st *memcached_string_create(memcached_st *ptr,
32 memcached_string_st *string,
33 size_t initial_size);
34 LIBMEMCACHED_API
35 memcached_return memcached_string_check(memcached_string_st *string, size_t need);
36 LIBMEMCACHED_API
37 char *memcached_string_c_copy(memcached_string_st *string);
38 LIBMEMCACHED_API
39 memcached_return memcached_string_append_character(memcached_string_st *string,
40 char character);
41 LIBMEMCACHED_API
42 memcached_return memcached_string_append(memcached_string_st *string,
43 const char *value, size_t length);
44 LIBMEMCACHED_API
45 memcached_return memcached_string_reset(memcached_string_st *string);
46 LIBMEMCACHED_API
47 void memcached_string_free(memcached_string_st *string);
48
49 #ifdef __cplusplus
50 }
51 #endif
52
53 #endif /* __MEMCACHED_STRING_H__ */