![]() |
Container are used for manage array, dict entry, variant and struct data.
Modules | |
array | |
Module for manage EasyDbus Array. | |
dict_entry | |
Module for manage EasyDbus Dict Entry. | |
struct | |
Module for manage EasyDbus Struct. | |
variant | |
Module for manage EasyDbus Variant. | |
Data Structures | |
struct | EasyDbus_container |
EasyDbus_container object. Used for marshalled data as array, dict_entry, variant and structs. More... | |
Functions | |
int | easydbus_container_add_signature_to_empty_container (EasyDbus_container *container,...) |
Add signature to container (array or struct). | |
EasyDbus_container * | easydbus_container_create_skeleton (enum el_type type) |
Create container object. | |
void | easydbus_container_free (EasyDbus_container *container) |
Free container. | |
enum el_type | easydbus_container_get_elem_type (const EasyDbus_container *container) |
Get type of elements on container object. | |
unsigned int | easydbus_container_get_nel (const EasyDbus_container *container) |
Get number of element on container. | |
enum el_type | easydbus_container_get_type (const EasyDbus_container *container) |
Get type of container object. |
int easydbus_container_add_signature_to_empty_container | ( | EasyDbus_container * | container, | |
... | ||||
) |
Add signature to container (array or struct).
This is needed only for empty array or empty struct. If a signature is inserted to an array with at least one element signature inserted is ignored.
container | pointer to struct EasyDbus_container that container an empty array or struct. | |
... | list of elem type. Last type MUST be EASYDBUS_ELTYPE_INVALID. EASYDBUS_ELTYPE_DICT_ENTRY must be after a EASYDBUS_ELTYPE_ARRAY entry. |
0 ok
Definition at line 266 of file container.c.
References easydbus_add_elem_to_stack(), EASYDBUS_ELTYPE_INVALID, easydbus_free_elem_from_stack(), easydbus_manage_list_signature(), EASYDBUS_SIGNATURE_NORMAL, EasyDbusDebug, easydbus_signature_elem_stack::next, and EasyDbus_container::signature.
Referenced by easydbus_get_marshal_data_from_array().
00267 { 00268 va_list ap; 00269 enum el_type elem = EASYDBUS_ELTYPE_INVALID; 00270 struct easydbus_signature_elem_stack *list_elem; 00271 struct easydbus_signature_elem_stack *tmp_elem; 00272 char *signature = NULL; 00273 int i = 0; 00274 00275 if (container == NULL) 00276 return -1; 00277 00278 list_elem = tmp_elem = NULL; 00279 va_start (ap, container); 00280 00281 /* recover data from input params list */ 00282 elem = va_arg (ap, enum el_type); 00283 00284 while (elem != EASYDBUS_ELTYPE_INVALID) { 00285 EasyDbusDebug ("elem %d", elem); 00286 i++; 00287 list_elem = easydbus_add_elem_to_stack (elem, list_elem); 00288 elem = va_arg (ap, enum el_type); 00289 } 00290 00291 va_end (ap); 00292 00293 while (list_elem != NULL) { 00294 if (easydbus_manage_list_signature (list_elem, &signature, 00295 EASYDBUS_SIGNATURE_NORMAL)) 00296 goto error; 00297 tmp_elem = list_elem->next; 00298 easydbus_free_elem_from_stack (list_elem); 00299 list_elem = tmp_elem; 00300 } 00301 00302 container->signature = signature; 00303 EasyDbusDebug ("signature added = %s\n", container->signature); 00304 EasyDbusDebug ("Elements founded = %d", i); 00305 00306 return 0; 00307 error: 00308 EasyDbusDebug ("Error on create signature for" " empty container"); 00309 if (signature != NULL) 00310 free (signature); 00311 while (list_elem != NULL) { 00312 tmp_elem = list_elem; 00313 list_elem = list_elem->next; 00314 easydbus_free_elem_from_stack (tmp_elem); 00315 } 00316 return -1; 00317 }
EasyDbus_container* easydbus_container_create_skeleton | ( | enum el_type | type | ) |
Create container object.
type | container type. This value can be one of these flags: EASYDBUS_ELTYPE_ARRAY, EASYDBUS_ELTYPE_STRUCT, EASYDBUS_DICT_ENTRY, EASYDBUS_ELTYPE_VARIANT. |
pointer to a new container object.
Definition at line 216 of file container.c.
References EasyDbus_container::container_type, EASYDBUS_ELTYPE_ARRAY, EASYDBUS_ELTYPE_DICT_ENTRY, EASYDBUS_ELTYPE_INVALID, EASYDBUS_ELTYPE_STRUCT, EASYDBUS_ELTYPE_VARIANT, EasyDbus_container::elem_type, EasyDbus_container::p_data, and EasyDbus_container::signature.
Referenced by easydbus_dict_entry_build_container(), easydbus_get_marshal_data_from_array(), easydbus_struct_build_elem(), and easydbus_variant_build_elem().
00217 { 00218 struct EasyDbus_container *container = NULL; 00219 00220 switch (type) { 00221 case EASYDBUS_ELTYPE_VARIANT: 00222 case EASYDBUS_ELTYPE_ARRAY: 00223 case EASYDBUS_ELTYPE_STRUCT: 00224 case EASYDBUS_ELTYPE_DICT_ENTRY: 00225 container = (struct EasyDbus_container *) 00226 malloc (sizeof (struct EasyDbus_container)); 00227 break; 00228 default: 00229 return NULL; 00230 break; 00231 } 00232 00233 if (container != NULL) { 00234 memset (container, 0, sizeof (struct EasyDbus_container)); 00235 container->container_type = type; 00236 container->elem_type = EASYDBUS_ELTYPE_INVALID; 00237 container->p_data = NULL; 00238 container->signature = NULL; 00239 } 00240 00241 return container; 00242 }
void easydbus_container_free | ( | EasyDbus_container * | container | ) |
Free container.
container | container that must be free. |
Definition at line 58 of file container.c.
References EasyDbus_container::container_type, easydbus_elem_free(), EASYDBUS_ELTYPE_ARRAY, EASYDBUS_ELTYPE_BOOLEAN, EASYDBUS_ELTYPE_BYTE, EASYDBUS_ELTYPE_DICT_ENTRY, EASYDBUS_ELTYPE_DOUBLE, EASYDBUS_ELTYPE_INT16, EASYDBUS_ELTYPE_INT32, EASYDBUS_ELTYPE_INT64, EASYDBUS_ELTYPE_INVALID, EASYDBUS_ELTYPE_OBJECT_PATH, EASYDBUS_ELTYPE_SIGNATURE, EASYDBUS_ELTYPE_STRING, EASYDBUS_ELTYPE_STRUCT, EASYDBUS_ELTYPE_UINT16, EASYDBUS_ELTYPE_UINT32, EASYDBUS_ELTYPE_UINT64, EASYDBUS_ELTYPE_VARIANT, EasyDbusDebug, EasyDbus_container::elem_type, free_array_from_container(), EasyDbus_container::nel, EasyDbus_elem::next, EasyDbus_container::p_data, and EasyDbus_container::signature.
Referenced by easydbus_dict_entry_build_container(), easydbus_elem_free(), easydbus_get_marshal_data_from_array(), easydbus_struct_build_elem(), easydbus_variant_build_elem(), and free_array_from_container().
00059 { 00060 unsigned int i = 0; 00061 char **temp, **p_char; 00062 struct EasyDbus_elem *el, *el2; 00063 00064 if (container == NULL) 00065 return; 00066 00067 el = el2 = NULL; 00068 temp = p_char = NULL; 00069 00070 switch (container->container_type) { 00071 case EASYDBUS_ELTYPE_ARRAY: 00072 switch (container->elem_type) { 00073 case EASYDBUS_ELTYPE_STRING: 00074 case EASYDBUS_ELTYPE_OBJECT_PATH: 00075 case EASYDBUS_ELTYPE_SIGNATURE: 00076 /* see if use p_data instead of temp */ 00077 p_char = (char **) container->p_data; 00078 temp = p_char; 00079 for (i = 0; i < container->nel; i++) { 00080 p_char++; 00081 free (*temp); 00082 temp = p_char; 00083 } 00084 free (container->p_data); 00085 break; 00086 case EASYDBUS_ELTYPE_INT16: 00087 case EASYDBUS_ELTYPE_UINT16: 00088 case EASYDBUS_ELTYPE_INT32: 00089 case EASYDBUS_ELTYPE_UINT32: 00090 case EASYDBUS_ELTYPE_INT64: 00091 case EASYDBUS_ELTYPE_UINT64: 00092 case EASYDBUS_ELTYPE_BYTE: 00093 case EASYDBUS_ELTYPE_BOOLEAN: 00094 case EASYDBUS_ELTYPE_DOUBLE: 00095 free (container->p_data); 00096 break; 00097 case EASYDBUS_ELTYPE_VARIANT: 00098 el = el2 = (struct EasyDbus_elem *) container->p_data; 00099 while (el != NULL) { 00100 el = el2->next; 00101 EasyDbusDebug ("Free of variant element on array"); 00102 easydbus_elem_free (el2); 00103 } 00104 break; 00105 case EASYDBUS_ELTYPE_ARRAY: 00106 el = el2 = (struct EasyDbus_elem *) container->p_data; 00107 for (i = 0; i < container->nel; i++) { 00108 el2++; 00109 free_array_from_container (el); 00110 el = el2; 00111 } 00112 free (container->p_data); 00113 break; 00114 case EASYDBUS_ELTYPE_STRUCT: 00115 el = el2 = (struct EasyDbus_elem *) container->p_data; 00116 i = 1; 00117 while (el != NULL) { 00118 el = el2->next; 00119 easydbus_elem_free (el2); 00120 EasyDbusDebug ("Free of struct element %d", i++); 00121 } 00122 break; 00123 case EASYDBUS_ELTYPE_INVALID: 00124 EasyDbusDebug ("Error or empty array"); 00125 break; 00126 case EASYDBUS_ELTYPE_DICT_ENTRY: 00127 el = (struct EasyDbus_elem *) container->p_data; 00128 if (el != NULL) { 00129 if (el->next != NULL) 00130 easydbus_elem_free (el->next); 00131 easydbus_elem_free (el); 00132 } 00133 break; 00134 } 00135 break; 00136 case EASYDBUS_ELTYPE_VARIANT: 00137 switch (container->elem_type) { 00138 case EASYDBUS_ELTYPE_STRING: 00139 case EASYDBUS_ELTYPE_OBJECT_PATH: 00140 case EASYDBUS_ELTYPE_INT16: 00141 case EASYDBUS_ELTYPE_UINT16: 00142 case EASYDBUS_ELTYPE_INT32: 00143 case EASYDBUS_ELTYPE_UINT32: 00144 case EASYDBUS_ELTYPE_INT64: 00145 case EASYDBUS_ELTYPE_UINT64: 00146 case EASYDBUS_ELTYPE_BYTE: 00147 case EASYDBUS_ELTYPE_BOOLEAN: 00148 case EASYDBUS_ELTYPE_DOUBLE: 00149 case EASYDBUS_ELTYPE_SIGNATURE: 00150 free (container->p_data); 00151 break; 00152 case EASYDBUS_ELTYPE_VARIANT: 00153 case EASYDBUS_ELTYPE_ARRAY: 00154 case EASYDBUS_ELTYPE_STRUCT: 00155 case EASYDBUS_ELTYPE_DICT_ENTRY: 00156 case EASYDBUS_ELTYPE_INVALID: 00157 EasyDbusDebug ("Error"); 00158 break; 00159 } 00160 EasyDbusDebug ("Free of variant container"); 00161 break; 00162 case EASYDBUS_ELTYPE_STRUCT: 00163 el = el2 = (struct EasyDbus_elem *) container->p_data; 00164 i = 1; 00165 while (el != NULL) { 00166 el = el2->next; 00167 easydbus_elem_free (el2); 00168 el2 = el; 00169 EasyDbusDebug ("Free of struct element %d", i++); 00170 } 00171 break; 00172 case EASYDBUS_ELTYPE_DICT_ENTRY: 00173 el = (struct EasyDbus_elem *) container->p_data; 00174 if (el != NULL) { 00175 if (el->next != NULL) 00176 easydbus_elem_free (el->next); 00177 easydbus_elem_free (el); 00178 } 00179 break; 00180 default: 00181 break; 00182 } 00183 if (container->signature != NULL) 00184 free (container->signature); 00185 free (container); 00186 }
enum el_type easydbus_container_get_elem_type | ( | const EasyDbus_container * | container | ) | [inline] |
Get type of elements on container object.
container | container object pointer |
type of container elements.
Definition at line 343 of file container.c.
References EASYDBUS_ELTYPE_INVALID, and EasyDbus_container::elem_type.
00344 { 00345 if (container == NULL) 00346 return EASYDBUS_ELTYPE_INVALID; 00347 return container->elem_type; 00348 }
unsigned int easydbus_container_get_nel | ( | const EasyDbus_container * | container | ) | [inline] |
Get number of element on container.
container | EasyDbus_container object pointer |
number of element on container.
Definition at line 357 of file container.c.
References EasyDbus_container::nel.
00358 { 00359 if (container == NULL) 00360 return -1; 00361 return container->nel; 00362 }
enum el_type easydbus_container_get_type | ( | const EasyDbus_container * | container | ) | [inline] |
Get type of container object.
container | container object pointer |
container type (EASYDBUS_ELTYPE_ARRAY || EASYDBUS_ELTYPE_STRUCT || EASYDBUS_ELTYPE_VARIANT || EASYDBUS_ELTYPE_DICT_ENTRY)
Definition at line 328 of file container.c.
References EasyDbus_container::container_type, and EASYDBUS_ELTYPE_INVALID.
00329 { 00330 if (container == NULL) 00331 return EASYDBUS_ELTYPE_INVALID; 00332 return container->container_type; 00333 }