Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
icalparameter.c File Reference

Implements the data structure representing iCalendar parameters. More...

Go to the source code of this file.

Functions

char * icalparameter_as_ical_string (icalparameter *param)
 Converts icalparameter into a string representation.
char * icalparameter_as_ical_string_r (icalparameter *param)
 Converts icalparameter into a string representation according to RFC5445/RFC6868.
icalparameter * icalparameter_clone (const icalparameter *old)
 Creates new icalparameter as a clone of the given one.
void icalparameter_decode_value (char *value)
void icalparameter_free (icalparameter *param)
 Frees an icalparameter object.
const char * icalparameter_get_iana_name (const icalparameter *param)
 Returns the IANA name of param.
const char * icalparameter_get_iana_value (const icalparameter *param)
 Returns the IANA value of param.
icalproperty * icalparameter_get_parent (const icalparameter *param)
const char * icalparameter_get_xname (const icalparameter *param)
 Returns the X-name of param.
const char * icalparameter_get_xvalue (const icalparameter *param)
 Returns the X-value of param.
bool icalparameter_has_same_name (const icalparameter *param1, const icalparameter *param2)
 Determines if two parameters have the same name.
bool icalparameter_is_multivalued (const icalparameter *param)
icalparameter_kind icalparameter_isa (const icalparameter *parameter)
bool icalparameter_isa_parameter (void *parameter)
icalparameter * icalparameter_new (icalparameter_kind kind)
 Creates new icalparameter object.
icalparameter * icalparameter_new_from_string (const char *str)
 Creates new icalparameter object from string.
void icalparameter_set_iana_name (icalparameter *param, const char *v)
 Sets the IANA name of param to v.
void icalparameter_set_iana_value (icalparameter *param, const char *v)
 Sets the IANA value of param to v.
void icalparameter_set_parent (icalparameter *param, icalproperty *property)
void icalparameter_set_xname (icalparameter *param, const char *v)
 Sets the X-name of param to v.
void icalparameter_set_xvalue (icalparameter *param, const char *v)
 Sets the X-value of param to v.

Detailed Description

Implements the data structure representing iCalendar parameters.

Definition in file icalparameter.c.

Function Documentation

◆ icalparameter_as_ical_string()

char * icalparameter_as_ical_string ( icalparameter * parameter)

Converts icalparameter into a string representation.

Parameters
parameterThe icalparameter to convert
Returns
A string representing the parameter according to RFC5445/RFC6868.
See also
icalparameter_as_ical_string_r()
Error handling
If there is any error, the method returns NULL. Furthermore, if parameter is NULL, it also sets icalerrno to ICAL_BADARG_ERROR. If it doesn't recognize the kind of the parameter, it sets icalerrno it ICAL_BADARG_ERROR. If the parameter is otherwise malformed, it sets icalerrno to ICAL_MALFORMEDDATA_ERROR.
Ownership
Strings returned by this method are owned by libical, they must not be freed and they may be reclaimed with the next call into the library. A version of this function, which returns strings that are not owned by libical, is icalparameter_as_ical_string_r().
Usage
icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR");
if(param) {
printf("%s\n", icalparameter_as_ical_string(param));
}
void icalparameter_free(icalparameter *param)
Frees an icalparameter object.
icalparameter * icalparameter_new_from_string(const char *str)
Creates new icalparameter object from string.
char * icalparameter_as_ical_string(icalparameter *param)
Converts icalparameter into a string representation.

Definition at line 180 of file icalparameter.c.

◆ icalparameter_as_ical_string_r()

char * icalparameter_as_ical_string_r ( icalparameter * parameter)

Converts icalparameter into a string representation according to RFC5445/RFC6868.

Parameters
parameterThe icalparameter to convert
Returns
A string representing the parameter
See also
icalparameter_as_ical_string()
Error handling
If there is any error, the method returns NULL. Furthermore, if parameter is NULL, it also sets icalerrno to ICAL_BADARG_ERROR. If it doesn't recognize the kind of the parameter, it sets icalerrno to ICAL_BADARG_ERROR. If the parameter is otherwise malformed, it sets icalerrno to ICAL_MALFORMEDDATA_ERROR.
Ownership
Strings returned by this method are owned by the caller, thus they need to be manually icalmemory_free_buffer()d after use. A version of this function which returns strings that do not need to be freed manually is icalparameter_as_ical_string().
Usage
icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR");
if(param) {
char *str = icalparameter_as_ical_string(param);
printf("%s\n", str);
}
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition icalmemory.c:353

Definition at line 198 of file icalparameter.c.

◆ icalparameter_clone()

icalparameter * icalparameter_clone ( const icalparameter * old)

Creates new icalparameter as a clone of the given one.

Parameters
oldThe existing, non-NULL parameter to clone.
Returns
An icalparameter that is a clone of the given one.
Error handling
If old is NULL, it returns NULL and sets icalerrno to ICAL_BADARG_ERROR. If there was an internal error cloning the data, it returns NULL without reporting any error in icalerrno.
Ownership
Objects created by this method are owned by the caller and must be released with the icalparameter_free() method.
Usage
// create an icalparameter
icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR");
// clone the parameter
icalparameter *clone = icalparameter_clone(param);
if(clone) {
// use clone ...
}
// release parameters
icalparameter_free(param);
icalparameter_free(clone);
Since
4.0

Definition at line 87 of file icalparameter.c.

◆ icalparameter_decode_value()

void icalparameter_decode_value ( char * value)

Decode the specified char string as a parameter value per RFC6868.

Parameters
valueis a pointer to the char string to decode.

value will contain the decoded value on return. No error checking is performed.

Since
4.0

Definition at line 418 of file icalparameter.c.

◆ icalparameter_free()

void icalparameter_free ( icalparameter * parameter)

Frees an icalparameter object.

Parameters
parameterThe icalparameter to free

This method needs to be used on all parameter objects returned from any of the _new() methods including icalparameter_new(), icalparameter_new_from_string() and icalparameter_new_from_value_string() and on cloned parameter objects returned by icalparameter_clone() when these object are not needed anymore and to be released.

Usage
icalparameter *param = icalparameter_new();
if(param) {
// use param...
}
// after use, release it
icalparameter * icalparameter_new(icalparameter_kind kind)
Creates new icalparameter object.

Definition at line 59 of file icalparameter.c.

◆ icalparameter_get_iana_name()

const char * icalparameter_get_iana_name ( const icalparameter * param)

Returns the IANA name of param.

Parameters
paramThe icalparameter whose IANA name is to be returned
Returns
A string representing the IANA name of param
See also
icalparameter_set_iana_name()
Error handling
Returns NULL and sets icalerrno to ICAL_BADARG_ERROR when a NULL is passed instead of an icalparameter.
Ownership
The string that is returned stays owned by libical and must not be freed by the caller.
Usage
// creates new parameter
icalparameter *param = icalparameter_new();
// sets iana name
icalparameter_set_iana_name(param, "X-TEST");
// compare iana name
assert(0 == strcmp(icalparameter_get_iana_name(param), "X-TEST"));
void icalparameter_set_iana_name(icalparameter *param, const char *v)
Sets the IANA name of param to v.
const char * icalparameter_get_iana_name(const icalparameter *param)
Returns the IANA name of param.

Definition at line 359 of file icalparameter.c.

◆ icalparameter_get_iana_value()

const char * icalparameter_get_iana_value ( const icalparameter * param)

Returns the IANA value of param.

Parameters
paramThe icalparameter whose value is to be returned
Returns
A string representing the value of param
See also
icalparameter_set_iana_value()
Error handling
Returns NULL and sets icalerrno to ICAL_BADARG_ERROR when a NULL is passed instead of an icalparameter.
Ownership
The string that is returned stays owned by libical and must not be freed by the caller.
Usage
// create new parameter
icalparameter *param = icalparameter_new_from_string("ROLE=ATTENDEE");
// set role to chair
// check that it worked
assert(0 == strcmp(icalparameter_get_iana_value(param), "SUCCESS"));
// release memory
const char * icalparameter_get_iana_value(const icalparameter *param)
Returns the IANA value of param.
void icalparameter_set_iana_value(icalparameter *param, const char *v)
Sets the IANA value of param to v.

Definition at line 349 of file icalparameter.c.

◆ icalparameter_get_parent()

icalproperty * icalparameter_get_parent ( const icalparameter * param)

Gets the parent icalproperty of an icalparameter.

Parameters
parama pointer to the icalparameter
Returns
the parent icalproperty for the specified icalparameter.
Since
3.0

Definition at line 371 of file icalparameter.c.

◆ icalparameter_get_xname()

const char * icalparameter_get_xname ( const icalparameter * param)

Returns the X-name of param.

Parameters
paramThe icalparameter whose X-name is to be returned
Returns
A string representing the X-name of param
See also
icalparameter_set_xname()
Error handling
Returns NULL and sets icalerrno to ICAL_BADARG_ERROR when a NULL is passed instead of an icalparameter.
Ownership
The string that is returned stays owned by libical and must not be freed by the caller.
Usage
// creates new parameter
icalparameter *param = icalparameter_new();
// sets xname
icalparameter_set_xname(param, "X-TEST");
// compare xname
assert(0 == strcmp(icalparameter_get_xname(param), "X-TEST"));
void icalparameter_set_xname(icalparameter *param, const char *v)
Sets the X-name of param to v.
const char * icalparameter_get_xname(const icalparameter *param)
Returns the X-name of param.

Definition at line 317 of file icalparameter.c.

◆ icalparameter_get_xvalue()

const char * icalparameter_get_xvalue ( const icalparameter * param)

Returns the X-value of param.

Parameters
paramThe icalparameter whose X-value is to be returned
Returns
A string representing the X-value of param
See also
icalparameter_set_xvalue()
Error handling
Returns NULL and sets icalerrno to ICAL_BADARG_ERROR when a NULL is passed instead of an icalparameter.
Ownership
The string that is returned stays owned by libical and must not be freed by the caller.
Usage
// create new parameter
icalparameter *param = icalparameter_new_from_string("X-TEST=FAIL");
// set test to success
icalparameter_set_xvalue(param, "SUCCESS");
// check that it worked
assert(0 == strcmp(icalparameter_get_xvalue(param), "SUCCESS"));
// release memory
const char * icalparameter_get_xvalue(const icalparameter *param)
Returns the X-value of param.
void icalparameter_set_xvalue(icalparameter *param, const char *v)
Sets the X-value of param to v.

Definition at line 337 of file icalparameter.c.

◆ icalparameter_has_same_name()

bool icalparameter_has_same_name ( const icalparameter * param1,
const icalparameter * param2 )

Determines if two parameters have the same name.

Parameters
param1First parameter to compare
param2Second parameter to compare
Returns
true if they have the same name, false otherwise.
Error handling
If either of param1 or param2 are NULL, it returns 0 and sets icalerrno to ICAL_BADARG_ERROR.
Ownership
Does not take ownership of either icalparameter.
Example
// create two parameters
icalparameter *param1 = icalparameter_new_from_string("ROLE=CHAIR");
icalparameter *param2 = icalparameter_new_from_string("EMAIL=mailto@example.com");
// compare parameter names for equality
assert(icalparameter_has_same_name(param1, param2) == 0);
// release memory
bool icalparameter_has_same_name(const icalparameter *param1, const icalparameter *param2)
Determines if two parameters have the same name.

Definition at line 378 of file icalparameter.c.

◆ icalparameter_is_multivalued()

bool icalparameter_is_multivalued ( const icalparameter * param)

Return if the specified parameter is multivalued.

Parameters
paramis a pointer to the icalparameter.
Returns
true if the specified parameter is multivalued; false otherwise.
Since
4.0

Definition at line 411 of file icalparameter.c.

◆ icalparameter_isa()

icalparameter_kind icalparameter_isa ( const icalparameter * parameter)

Returns the icalparameter_kind of parameter.

Parameters
parameterThe icalparameter whose kind to determine
Returns
The icalparameter_kind of the parameter

Error handling Returns ICAL_NO_PARAMETER when passed NULL.

Usage

// create parameter
icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR");
// check what type of parameter this is
assert(icalparameter_isa(param) == ICAL_ROLE_PARAMETER);
// release memory
icalparameter_kind icalparameter_isa(const icalparameter *parameter)

Definition at line 280 of file icalparameter.c.

◆ icalparameter_isa_parameter()

bool icalparameter_isa_parameter ( void * param)

Determines if the given param is an icalparameter

Parameters
paramThe libical-originated object to check
Returns
true if the object is an icalparameter, false otherwise.
Note
This function expects to be given an object originating from libical - if this function is passed anything that is not from libical, its behavior is undefined.

Error handling When given a NULL object, it returns 0.

Usage

// create parameter
icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR");
// check if it's a parameter
// release memory
bool icalparameter_isa_parameter(void *parameter)

Definition at line 289 of file icalparameter.c.

◆ icalparameter_new()

icalparameter * icalparameter_new ( icalparameter_kind kind)

Creates new icalparameter object.

Parameters
kindThe kind of icalparameter to create.
Returns
An icalparameter with the given kind.
Error handling
If there was an internal error regarding memory allocation, it returns NULL and sets icalerrno to ICAL_NEWFAILED_ERROR.
Ownership
Objects created by this method are owned by the caller and must be released with the icalparameter_free() method.
Usage
// create new parameter
icalparameter *parameter = icalparameter_new();
if(parameter) {
// use parameter ...
}
// release parameter
icalparameter_free(parameter);

Definition at line 52 of file icalparameter.c.

◆ icalparameter_new_from_string()

icalparameter * icalparameter_new_from_string ( const char * str)

Creates new icalparameter object from string.

Parameters
strThe string from which to create the icalparameter, in the form "PARAMNAME=VALUE"
Returns
An icalparameter that corresponds to the given string.
Error handling
If there was an internal error copying data, it returns NULL and sets icalerrno to ICAL_NEWFAILED_ERROR. If str was NULL, it returns NULL and sets icalerrno to ICAL_BADARG_ERROR. If str was malformed, it returns NULL and sets icalerrno to ICAL_MALFORMEDDATA_ERROR.
Ownership
Objects created by this method are owned by the caller and must be released with the icalparameter_free() method.
Usage
icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR");
if(param) {
// use param ...
}

Definition at line 131 of file icalparameter.c.

◆ icalparameter_set_iana_name()

void icalparameter_set_iana_name ( icalparameter * param,
const char * v )

Sets the IANA name of param to v.

Parameters
paramThe icalparameter to change
vThe IANA name to set param to
See also
icalparameter_get_iana_name()
Error handling
If either param or v are NULL, it sets :calerrno to ICAL_BARARG_ERROR. If there is an error acquiring memory, it sets errno to ENOMEM.
Ownership
The passed string v stays in the ownership of the caller - libical creates a copy of it.
Usage
// creates new parameter
icalparameter *param = icalparameter_new();
// sets iana name
// compare iana name
assert(0 == strcmp(icalparameter_get_iana_name(param), "X-TEST"));

Definition at line 354 of file icalparameter.c.

◆ icalparameter_set_iana_value()

void icalparameter_set_iana_value ( icalparameter * param,
const char * v )

Sets the IANA value of param to v.

Parameters
paramThe icalparameter to change
vThe IANA value to set param to
See also
icalparameter_get_iana_value()
Error handling
If either param or v are NULL, it sets icalerrno to ICAL_BARARG_ERROR. If there is an error acquiring memory, it sets errno to ENOMEM.
Ownership
The passed string v stays in the ownership of the caller - libical creates a copy of it.
Usage
// create new parameter
icalparameter *param = icalparameter_new_from_string("ROLE=ATTENDEE");
// set role to chair
// check that it worked
assert(0 == strcmp(icalparameter_get_iana_value(param), "SUCCESS"));
// release memory

Definition at line 344 of file icalparameter.c.

◆ icalparameter_set_parent()

void icalparameter_set_parent ( icalparameter * param,
icalproperty * property )

Sets the parent icalproperty for the specified icalparameter.

Parameters
parama pointer to a valid icalparameter
propertya pointer to a presumably valid icalproperty to use
Since
3.0

Definition at line 364 of file icalparameter.c.

◆ icalparameter_set_xname()

void icalparameter_set_xname ( icalparameter * param,
const char * v )

Sets the X-name of param to v.

Parameters
paramThe icalparameter to change
vThe X-name to set param to
See also
icalparameter_get_xname()
Error handling
If either param or v are NULL, it sets icalerrno to ICAL_BARARG_ERROR. If there is an error acquiring memory, it sets errno to ENOMEM.
Ownership
The passed string v stays in the ownership of the caller - libical creates a copy of it.
Usage
// creates new parameter
icalparameter *param = icalparameter_new();
// sets xname
icalparameter_set_xname(param, "X-TEST");
// compare xname
assert(0 == strcmp(icalparameter_get_xname(param), "X-TEST"));

Definition at line 304 of file icalparameter.c.

◆ icalparameter_set_xvalue()

void icalparameter_set_xvalue ( icalparameter * param,
const char * v )

Sets the X-value of param to v.

Parameters
paramThe icalparameter to change
vThe X-value to set param to
See also
icalparameter_get_xvalue()
Error handling
If either param or v are NULL, it sets icalerrno to ICAL_BARARG_ERROR. If there is an error acquiring memory, it sets errno to ENOMEM.
Ownership
The passed string v stays in the ownership of the caller - libical creates a copy of it.
Usage
// create new parameter
icalparameter *param = icalparameter_new_from_string("X-TEST=FAIL");
// set test to success
icalparameter_set_xvalue(param, "SUCCESS");
// check that it worked
assert(0 == strcmp(icalparameter_get_xvalue(param), "SUCCESS"));
// release memory

Definition at line 324 of file icalparameter.c.