libweed  0.6.0
 All Data Structures Files Functions Variables Typedefs Macros
weed.h
Go to the documentation of this file.
1 /* WEED is free software; you can redistribute it and/or
2  modify it under the terms of the GNU Lesser General Public
3  License as published by the Free Software Foundation; either
4  version 3 of the License, or (at your option) any later version.
5 
6  Weed is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9  Lesser General Public License for more details.
10 
11  You should have received a copy of the GNU Lesser General Public
12  License along with this source code; if not, write to the Free Software
13  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
14 
15 
16  Weed is developed by:
17 
18  Gabriel "Salsaman" Finch - http://lives.sourceforge.net
19 
20  mainly based on LiViDO, which is developed by:
21 
22 
23  Niels Elburg - http://veejay.sf.net
24 
25  Gabriel "Salsaman" Finch - http://lives.sourceforge.net
26 
27  Denis "Jaromil" Rojo - http://freej.dyne.org
28 
29  Tom Schouten - http://zwizwa.fartit.com
30 
31  Andraz Tori - http://cvs.cinelerra.org
32 
33  reviewed with suggestions and contributions from:
34 
35  Silvano "Kysucix" Galliani - http://freej.dyne.org
36 
37  Kentaro Fukuchi - http://megaui.net/fukuchi
38 
39  Jun Iio - http://www.malib.net
40 
41  Carlo Prelz - http://www2.fluido.as:8080/
42 
43 */
44 
45 /* (C) Gabriel "Salsaman" Finch, 2005 - 2007 */
46 
47 #ifndef __WEED_H__
48 #define __WEED_H__
49 
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif /* __cplusplus */
54 
55 #define __need_size_t
56 #define __need_NULL
57 #include <stddef.h>
58 #include <inttypes.h>
59 
60 #define WEED_TRUE 1
61 #define WEED_FALSE 0
62 
63 /* Leaf flags */
64 #define WEED_LEAF_READONLY_PLUGIN (1<<0)
65 #define WEED_LEAF_READONLY_HOST (1<<1)
66 
67 /* Weed errors */
68 /* Core errors */
69 #define WEED_NO_ERROR 0
70 #define WEED_ERROR_MEMORY_ALLOCATION 1
71 #define WEED_ERROR_LEAF_READONLY 2
72 #define WEED_ERROR_NOSUCH_ELEMENT 3
73 #define WEED_ERROR_NOSUCH_LEAF 4
74 #define WEED_ERROR_WRONG_SEED_TYPE 5
75 
76 /* Seed types */
77 /* Fundamental seeds */
78 #define WEED_SEED_INT 1
79 #define WEED_SEED_DOUBLE 2
80 #define WEED_SEED_BOOLEAN 3
81 #define WEED_SEED_STRING 4
82 #define WEED_SEED_INT64 5
83 
84 /* Pointer seeds */
85 #define WEED_SEED_VOIDPTR 65
86 #define WEED_SEED_PLANTPTR 66
87 
88 // these function types are fixed, and must be defined in the host
89 typedef void *(*weed_malloc_f)(size_t size);
90 typedef void (*weed_free_f)(void *ptr);
91 typedef void *(*weed_memset_f)(void *s, int c, size_t n);
92 typedef void *(*weed_memcpy_f)(void *dest, const void *src, size_t n);
93 
94 #ifndef HAVE_WEED_PLANT_T
95 #define HAVE_WEED_PLANT_T
96 
97 typedef struct weed_leaf weed_leaf_t;
98 typedef struct weed_data weed_data_t;
99 typedef weed_leaf_t weed_plant_t;
100 typedef size_t weed_size_t; // may be set to uint32_t or uint64_t
101 
102 /* private data - these fields must NOT be accessed directly ! */
103 struct weed_leaf {
104  const char *key;
107  weed_data_t **data;
108  int flags;
109  weed_leaf_t *next;
110 };
111 
112 struct weed_data {
113  weed_size_t size;
114  void *value;
115 };
116 
117 #endif
118 
119 typedef int64_t weed_timecode_t;
120 
122 typedef int (*weed_default_getter_f)(weed_plant_t *plant, const char *key, int idx, void *value);
123 
124 /* host and plugin functions, may be changed depending on API level */
125 typedef weed_plant_t *(*weed_plant_new_f)(int plant_type);
126 typedef char **(*weed_plant_list_leaves_f)(weed_plant_t *plant);
127 typedef int (*weed_leaf_set_f)(weed_plant_t *plant, const char *key, int seed_type, int num_elems, void *value);
128 typedef int (*weed_leaf_get_f)(weed_plant_t *plant, const char *key, int idx, void *value);
129 typedef int (*weed_leaf_num_elements_f)(weed_plant_t *plant, const char *key);
130 typedef size_t (*weed_leaf_element_size_f)(weed_plant_t *plant, const char *key, int idx);
131 typedef int (*weed_leaf_seed_type_f)(weed_plant_t *plant, const char *key);
132 typedef int (*weed_leaf_get_flags_f)(weed_plant_t *plant, const char *key);
133 
134 #ifdef __cplusplus
135 }
136 #endif /* __cplusplus */
137 
138 #endif // #ifndef __WEED_H__
int num_elements
Definition: weed.h:106
weed_data_t ** data
Definition: weed.h:107
int seed_type
Definition: weed.h:105
void(* weed_free_f)(void *ptr)
Definition: weed.h:90
Definition: weed.h:112
int(* weed_leaf_set_f)(weed_plant_t *plant, const char *key, int seed_type, int num_elems, void *value)
Definition: weed.h:127
weed_size_t size
Definition: weed.h:113
weed_leaf_t * next
Definition: weed.h:109
int(* weed_leaf_num_elements_f)(weed_plant_t *plant, const char *key)
Definition: weed.h:129
int(* weed_leaf_get_flags_f)(weed_plant_t *plant, const char *key)
Definition: weed.h:132
size_t weed_size_t
Definition: weed.h:100
int(* weed_leaf_seed_type_f)(weed_plant_t *plant, const char *key)
Definition: weed.h:131
weed_leaf_t weed_plant_t
Definition: weed.h:99
int flags
Definition: weed.h:108
const char * key
Definition: weed.h:104
Definition: weed.h:103
size_t(* weed_leaf_element_size_f)(weed_plant_t *plant, const char *key, int idx)
Definition: weed.h:130
int64_t weed_timecode_t
Definition: weed.h:119
int(* weed_leaf_get_f)(weed_plant_t *plant, const char *key, int idx, void *value)
Definition: weed.h:128
int(* weed_default_getter_f)(weed_plant_t *plant, const char *key, int idx, void *value)
Definition: weed.h:122
void * value
Definition: weed.h:114