24#include "icalparameterimpl.h"
25#include "icalerror_p.h"
32LIBICAL_ICAL_EXPORT
struct icalparameter_impl *icalparameter_new_impl(icalparameter_kind kind)
34 struct icalparameter_impl *v;
36 if ((v = (
struct icalparameter_impl *)
icalmemory_new_buffer(
sizeof(
struct icalparameter_impl))) == 0) {
41 memset(v, 0,
sizeof(
struct icalparameter_impl));
43 strcpy(v->id,
"para");
54 struct icalparameter_impl *v = icalparameter_new_impl(kind);
56 return (icalparameter *)v;
64 if (param->parent != 0) {
68 if (param->string != 0) {
70 }
else if (param->values != 0) {
71 if (param->value_kind == ICAL_TEXT_VALUE) {
80 memset(param, 0,
sizeof(icalparameter));
89 struct icalparameter_impl *clone;
91 icalerror_check_arg_rz((old != 0),
"param");
93 clone = icalparameter_new_impl(old->kind);
99 memcpy(clone, old,
sizeof(
struct icalparameter_impl));
101 if (old->string != 0) {
103 if (clone->string == 0) {
110 if (old->x_name != 0) {
112 if (clone->x_name == 0) {
119 if (old->values != 0) {
121 if (clone->values == 0) {
135 icalparameter_kind kind;
136 icalparameter *param;
138 icalerror_check_arg_rz(str != 0,
"str");
147 eq = strchr(cpy,
'=');
161 if (kind == ICAL_NO_PARAMETER) {
169 if (kind == ICAL_X_PARAMETER) {
171 }
else if (kind == ICAL_IANA_PARAMETER) {
200 size_t buf_size = 1024;
203 const char *kind_string;
205 icalerror_check_arg_rz((param != 0),
"parameter");
214 if (param->kind == ICAL_X_PARAMETER) {
216 }
else if (param->kind == ICAL_IANA_PARAMETER) {
221 if (param->kind == ICAL_NO_PARAMETER ||
222 param->kind == ICAL_ANY_PARAMETER || kind_string == 0) {
234 if (param->kind == ICAL_GAP_PARAMETER) {
239 }
else if (param->string != 0) {
241 }
else if (param->data != 0) {
242 const char *str = icalparameter_enum_to_string(param->data);
245 }
else if (param->values != 0) {
247 const char *sep =
"";
249 for (i = 0; i < param->values->num_elements; i++) {
252 if (param->value_kind == ICAL_TEXT_VALUE) {
264 const char *str = icalparameter_enum_to_string(elem->
val);
282 if (parameter == 0) {
283 return ICAL_NO_PARAMETER;
286 return parameter->kind;
291 const struct icalparameter_impl *impl = (
struct icalparameter_impl *)parameter;
293 if (parameter == 0) {
297 if (strcmp(impl->id,
"para") == 0) {
306 icalerror_check_arg_rv((param != 0),
"param");
307 icalerror_check_arg_rv((v != 0),
"v");
312 if (param->x_name == 0) {
319 icalerror_check_arg_rz((param != 0),
"param");
321 return param->x_name;
326 icalerror_check_arg_rv((param != 0),
"param");
327 icalerror_check_arg_rv((v != 0),
"v");
332 if (param->string == 0) {
339 icalerror_check_arg_rz((param != 0),
"param");
341 return param->string;
366 icalerror_check_arg_rv((param != 0),
"param");
368 param->parent = property;
373 icalerror_check_arg_rz((param != 0),
"param");
375 return param->parent;
380 icalparameter_kind kind1;
381 icalparameter_kind kind2;
385 icalerror_check_arg_rz((param1 != 0),
"param1");
386 icalerror_check_arg_rz((param2 != 0),
"param2");
391 if (kind1 != kind2) {
395 if (kind1 == ICAL_X_PARAMETER) {
398 if (strcasecmp(name1, name2) != 0) {
401 }
else if (kind1 == ICAL_IANA_PARAMETER) {
404 if (strcasecmp(name1, name2) != 0) {
413 icalerror_check_arg_rz((param != 0),
"param");
415 return param->is_multivalued;
422 for (in = out = value; *in; in++, out++) {
423 int found_escaped_char = 0;
429 found_escaped_char = 1;
433 found_escaped_char = 1;
438 found_escaped_char = 1;
445 if (found_escaped_char) {
char * icaldurationtype_as_ical_string_r(struct icaldurationtype d)
void icalenumarray_free(icalenumarray *array)
Frees this array's memory and all its elements.
icalenumarray * icalenumarray_clone(icalenumarray *array)
Clones the array and all its elements.
const icalenumarray_element * icalenumarray_element_at(icalenumarray *array, size_t position)
Accesses an element stored in the array.
void icalerror_set_errno(icalerrorenum x)
Sets the icalerrno to a given error.
@ ICAL_MALFORMEDDATA_ERROR
void icalmemory_free_buffer(void *buf)
Releases a buffer.
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Appends a string to a buffer.
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
void icalmemory_append_encoded_string(char **buf, char **pos, size_t *buf_size, const char *string)
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Common memory management routines.
bool icalparameter_isa_parameter(void *parameter)
icalproperty * icalparameter_get_parent(const icalparameter *param)
void icalparameter_free(icalparameter *param)
Frees an icalparameter object.
const char * icalparameter_get_xvalue(const icalparameter *param)
Returns the X-value of param.
icalparameter * icalparameter_new(icalparameter_kind kind)
Creates new icalparameter object.
bool icalparameter_is_multivalued(const icalparameter *param)
void icalparameter_set_xname(icalparameter *param, const char *v)
Sets the X-name of param to v.
char * icalparameter_as_ical_string_r(icalparameter *param)
Converts icalparameter into a string representation according to RFC5445/RFC6868.
icalparameter * icalparameter_new_from_string(const char *str)
Creates new icalparameter object from string.
const char * icalparameter_get_xname(const icalparameter *param)
Returns the X-name of param.
icalparameter_kind icalparameter_isa(const icalparameter *parameter)
icalparameter * icalparameter_clone(const icalparameter *old)
Creates new icalparameter as a clone of the given one.
bool icalparameter_has_same_name(const icalparameter *param1, const icalparameter *param2)
Determines if two parameters have the same name.
void icalparameter_decode_value(char *value)
void icalparameter_set_iana_name(icalparameter *param, const char *v)
Sets the IANA name of param to v.
void icalparameter_set_xvalue(icalparameter *param, const char *v)
Sets the X-value of param to v.
const char * icalparameter_get_iana_value(const icalparameter *param)
Returns the IANA value of param.
void icalparameter_set_parent(icalparameter *param, icalproperty *property)
const char * icalparameter_get_iana_name(const icalparameter *param)
Returns the IANA name of param.
void icalparameter_set_iana_value(icalparameter *param, const char *v)
Sets the IANA value of param to v.
char * icalparameter_as_ical_string(icalparameter *param)
Converts icalparameter into a string representation.
Defines the data structure representing iCalendar parameters.
icalparameter_kind icalparameter_string_to_kind(const char *string)
Returns the icalparameter_kind for a given string.
icalvalue_kind icalparameter_kind_value_kind(const icalparameter_kind kind, int *is_multivalued)
const char * icalparameter_kind_to_string(icalparameter_kind kind)
Returns a string representing the given icalparameter_kind.
icalparameter * icalparameter_new_from_value_string(icalparameter_kind kind, const char *value)
Creates new icalparameter of a given kind with a given value.
const char * icalstrarray_element_at(icalstrarray *array, size_t position)
Accesses a string stored in the array.
icalstrarray * icalstrarray_clone(icalstrarray *array)
Clones the array and all its elements.
void icalstrarray_free(icalstrarray *array)
Frees this array's memory and all its elements.