summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_binbuf.c
blob: d392686c333150977305e470ce548293a0838c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>
#include <string.h>

#include "eina_private.h"
#include "eina_strbuf_common.h"
#include "eina_binbuf.h"

/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/

/**
 * @cond LOCAL
 */

#ifdef _STRBUF_DATA_TYPE
# undef _STRBUF_DATA_TYPE
#endif

#ifdef _STRBUF_CSIZE
# undef _STRBUF_CSIZE
#endif

#ifdef _STRBUF_STRUCT_NAME
# undef _STRBUF_STRUCT_NAME
#endif

#ifdef _STRBUF_MAGIC
# undef _STRBUF_MAGIC
#endif

#ifdef _STRBUF_MAGIC_STR
# undef _STRBUF_MAGIC_STR
#endif

#ifdef _FUNC_EXPAND
# undef _FUNC_EXPAND
#endif


#define _STRBUF_DATA_TYPE         unsigned char
#define _STRBUF_CSIZE             sizeof(_STRBUF_DATA_TYPE)
#define _STRBUF_STRUCT_NAME       Eina_Binbuf
#define _STRBUF_MAGIC             EINA_MAGIC_BINBUF
#define _STRBUF_MAGIC_STR         __BINBUF_MAGIC_STR
static const char __BINBUF_MAGIC_STR[] = "Eina Binbuf";

#define _FUNC_EXPAND(y) eina_binbuf_ ## y

#include "eina_binbuf_template_c.x"

EAPI Eina_Binbuf *
eina_binbuf_manage_new(const unsigned char *str, size_t length, Eina_Bool ro)
{
   Eina_Binbuf *buf;

   if (ro)
     buf = eina_strbuf_common_manage_ro_new(_STRBUF_CSIZE, (void *) str, length);
   else
     buf = eina_strbuf_common_manage_new(_STRBUF_CSIZE, (void *) str, length);
   EINA_MAGIC_SET(buf, _STRBUF_MAGIC);
   return buf;
}

/**
 * @endcond
 */