18#include "vcardstructuredimpl.h"
21#include "icalerror_p.h"
31 struct vcardstructuredtype_impl *st;
38 memset(st, 0,
sizeof(
struct vcardstructuredtype_impl));
47 memset((
void *)st->field, 0, num_fields *
sizeof(
vcardstrarray *));
48 st->num_alloc = num_fields;
56 for (
size_t i = 0; i < st->num_fields; i++) {
67 struct vcardstructuredtype_impl *st = vcardstructured_alloc(num_fields);
73 st->num_fields = num_fields;
79 struct vcardstructuredtype_impl *st = vcardstructured_alloc(0);
97 if (*
str ==
',' || field->num_elements || strlen(dequoted_str)) {
108 }
while (*
str++ !=
'\0' && cnt++ < max_chars);
115 icalerror_check_arg_rv((st != NULL),
"st");
122 icalerror_check_arg_rv((st != NULL),
"st");
123 icalerror_check_arg_rv((st->refcount > 0),
"st->refcount > 0");
127 if (st->refcount != 0) {
131 vcardstructured_free(st);
136 icalerror_check_arg_rz((st != NULL),
"st");
138 struct vcardstructuredtype_impl *clone_st = vcardstructured_alloc(st->num_fields);
144 clone_st->num_fields = st->num_fields;
145 for (
size_t i = 0; i < st->num_fields; i++) {
154 icalerror_check_arg_rz((st != NULL),
"st");
155 return st->num_fields;
161 icalerror_check_arg_rv((st != NULL),
"st");
163 if (num_fields > st->num_alloc) {
164 size_t new_alloc = ((num_fields + 7) / 8) * 8;
171 if (st->num_fields && st->field) {
172 memcpy((
void *)new_field, (
void *)st->field, st->num_fields *
sizeof(
vcardstrarray *));
174 memset((
void *)(new_field + st->num_alloc), 0,
178 st->field = new_field;
179 st->num_alloc = new_alloc;
182 for (
size_t i = num_fields; i < st->num_fields; i++) {
187 st->num_fields = num_fields;
193 icalerror_check_arg_rz((st != NULL),
"st");
194 icalerror_check_arg_rz((st->num_fields > position),
"position");
196 return st->field[position];
203 icalerror_check_arg_rv((st != NULL),
"st");
205 if (position >= st->num_fields) {
213 st->field[position] = field;
void icalerror_set_errno(icalerrorenum x)
Sets the icalerrno to a given error.
#define icalerrno
Access the current icalerrno value.
size_t icallimit_get(icallimits_kind kind)
Defines the interface for getting/setting internal library limits.
@ ICAL_LIMIT_PARSE_SEARCH
void icalmemory_free_buffer(void *buf)
Releases a buffer.
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Common memory management routines.
#define vcardstrarray_clone(array)
#define vcardstrarray_new(increment_size)
#define vcardstrarray_append(array, elem)
#define vcardstrarray_free(array)
icalstrarray vcardstrarray
void vcardstructured_set_field_at(vcardstructuredtype *st, size_t position, vcardstrarray *field)
Sets the field at the given position in a vcardstructuredtype.
vcardstrarray * vcardstructured_field_at(const vcardstructuredtype *st, size_t position)
Returns the field at the given position in a vcardstructuredtype.
void vcardstructured_ref(vcardstructuredtype *st)
Increments the reference count of the vcardstructuredtype.
vcardstructuredtype * vcardstructured_new_from_string(const char *str)
Creates a new instance of vcardstructuredtype from a string.
void vcardstructured_set_num_fields(vcardstructuredtype *st, size_t num_fields)
Sets the number of fields in a vcardstructuredtype.
vcardstructuredtype * vcardstructured_clone(const vcardstructuredtype *st)
Clones a vcardstructuredtype.
void vcardstructured_unref(vcardstructuredtype *st)
Decrements the reference count of the vcardstructuredtype.
size_t vcardstructured_num_fields(const vcardstructuredtype *st)
Returns the number of fields in a vcardstructuredtype.
vcardstructuredtype * vcardstructured_new(size_t num_fields)
Creates a new instance of vcardstructuredtype.
Defines the data structure representing vCard structured values.
struct vcardstructuredtype_impl vcardstructuredtype
Represents a decoded, structured text value.
char * vcardvalue_strdup_and_dequote_text(const char **str, const char *sep)
Defines the data structure representing vCard values.