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

Implements the data structure for iCalendar attachments. More...

Go to the source code of this file.

Functions

unsigned char * icalattach_get_data (icalattach *attach)
 Returns the data of the icalattach object.
bool icalattach_get_is_url (const icalattach *attach)
 Determines if attach is an URL.
const char * icalattach_get_url (icalattach *attach)
 Returns the URL of the icalattach object.
icalattachicalattach_new_from_data (const char *data, icalattach_free_fn_t free_fn, void *free_fn_data)
 Creates new icalattach object from data.
icalattachicalattach_new_from_url (const char *url)
 Creates new icalattach object from a URL.
void icalattach_ref (icalattach *attach)
 Increments reference count of the icalattach.
void icalattach_unref (icalattach *attach)
 Decrements reference count of the icalattach.

Detailed Description

Implements the data structure for iCalendar attachments.

Definition in file icalattach.c.

Function Documentation

◆ icalattach_get_data()

unsigned char * icalattach_get_data ( icalattach * attach)

Returns the data of the icalattach object.

Parameters
attachThe object from which to return the data
Returns
The data of the object
See also
icalattach_get_is_url()

Returns the URL of the icalattach object.

Error handling
Returns NULL and set icalerrno to ICAL_BADARG_ERROR if attach is NULL. Undefined behaviour if the object is a URL (check with icalattach_get_is_url()).
Ownership
The string returned is owned by libical and must not be freed by the caller.

Definition at line 130 of file icalattach.c.

◆ icalattach_get_is_url()

bool icalattach_get_is_url ( const icalattach * attach)

Determines if attach is an URL.

Parameters
attachthe icalattach object to check
See also
icalattach_get_url()

Errors if attach is NULL.

Usage
// creates new
icalattach *attach = icalattach_new_from_url("http://example.com");
// checks if it is a URL
assert(icalattach_get_is_url(attach));
// release it
void icalattach_unref(icalattach *attach)
Decrements reference count of the icalattach.
Definition icalattach.c:95
icalattach * icalattach_new_from_url(const char *url)
Creates new icalattach object from a URL.
Definition icalattach.c:25
bool icalattach_get_is_url(const icalattach *attach)
Determines if attach is an URL.
Definition icalattach.c:115
struct icalattach_impl icalattach
An iCal attach object representing a link to a document object.
Definition icalattach.h:36
Returns
true if the specified icalattach is a URL; false otherwise.

Definition at line 115 of file icalattach.c.

◆ icalattach_get_url()

const char * icalattach_get_url ( icalattach * attach)

Returns the URL of the icalattach object.

Parameters
attachThe object from which to return the URL
Returns
The URL of the object
See also
icalattach_get_is_url()

Returns the URL of the icalattach object.

Error handling
Returns NULL and set icalerrno to ICAL_BADARG_ERROR if attach is NULL. Undefined behaviour if the object is not a URL (check with icalattach_get_is_url()).
Ownership
The string returned is owned by libical and must not be freed by the caller.
Usage
// creates new
icalattach *attach = icalattach_new_from_url("http://example.com");
// checks it
assert(icalattach_get_is_url(attach));
assert(0 == strcmp(icalattach_get_url(attach), "http://example.com"));
// release it
const char * icalattach_get_url(icalattach *attach)
Returns the URL of the icalattach object.
Definition icalattach.c:122

Definition at line 122 of file icalattach.c.

◆ icalattach_new_from_data()

icalattach * icalattach_new_from_data ( const char * data,
icalattach_free_fn_t free_fn,
void * free_fn_data )

Creates new icalattach object from data.

Parameters
dataThe data to create the icalattach from
free_fnThe function to free the data
free_fn_dataData to pass to the free_fn
Returns
An icalattach object with the given data
See also
icalattach_unref()
Error handling
If url is NULL, it returns NULL and sets icalerrno to ICAL_BADARG_ERROR. If there was an error allocating memory, it returns NULL and sets errno to ENOMEM.
Ownership
The returned icalattach object is owned by the caller of the function. icalattach objects are reference counted, which means that after use, icalattach_unref() needs to be called to signal that they are not used anymore.

Definition at line 56 of file icalattach.c.

◆ icalattach_new_from_url()

icalattach * icalattach_new_from_url ( const char * url)

Creates new icalattach object from a URL.

Parameters
urlThe URL to create the object from
Returns
An icalattach object with the given URL as association
See also
icalattach_unref()
Error handling
If url is NULL, it returns NULL and sets icalerrno to ICAL_BADARG_ERROR. If there was an error allocating memory, it returns NULL and sets errno to ENOMEM.
Ownership
The returned icalattach object is owned by the caller of the function. icalattach objects are reference counted, which means that after use, icalattach_unref() needs to be called to signal that they are not used anymore.
Usage
// creates new
icalattach *attach = icalattach_new_from_url("http://example.com");
// checks it
assert(icalattach_get_is_url(attach));
assert(0 == strcmp(icalattach_get_url(attach), "http://example.com"));
// release it

Definition at line 25 of file icalattach.c.

◆ icalattach_ref()

void icalattach_ref ( icalattach * attach)

Increments reference count of the icalattach.

Parameters
attachThe object to increase the reference count of
See also
icalattach_unref()
Error handling
If attach is NULL, or the reference count is smaller than 0, it sets icalerrno to ICAL_BADARG_ERROR.
Ownership
By increasing the refcount of attach, you are signaling that you are using it, and it is the owner's responsibility to call icalattach_unref() after it's no longer used.

Definition at line 87 of file icalattach.c.

◆ icalattach_unref()

void icalattach_unref ( icalattach * attach)

Decrements reference count of the icalattach.

Parameters
attachThe object to decrease the reference count of
See also
icalattach_ref()

Decreases the reference count of attach. If this was the last user of the object, it is freed.

Error handling
If attach is NULL, or the reference count is smaller than 0, it sets icalerrno to ICAL_BADARG_ERROR.
Ownership
Calling this function releases the icalattach back to the library, and it must not be used afterwards.
Usage
// creates new
icalattach *attach = icalattach_new_from_url("http://example.com");
// release it

Definition at line 95 of file icalattach.c.