18#include "icalattachimpl.h"
19#include "icalerror_p.h"
30 icalerror_check_arg_rz((url != NULL),
"url");
45 attach->u.url.url = url_copy;
50static void attach_data_free(
char *data,
void *free_fn_data)
52 _unused(free_fn_data);
61 icalerror_check_arg_rz((data != NULL),
"data");
75 free_fn = attach_data_free;
80 attach->u.data.data = (
char *)data;
81 attach->u.data.free_fn = free_fn;
82 attach->u.data.free_fn_data = free_fn_data;
89 icalerror_check_arg_rv((attach != NULL),
"attach");
90 icalerror_check_arg_rv((attach->refcount > 0),
"attach->refcount > 0");
97 icalerror_check_arg_rv((attach != NULL),
"attach");
98 icalerror_check_arg_rv((attach->refcount > 0),
"attach->refcount > 0");
102 if (attach->refcount != 0) {
106 if (attach->is_url) {
108 }
else if (attach->u.data.free_fn) {
109 (*attach->u.data.free_fn)(attach->u.data.data, attach->u.data.free_fn_data);
117 icalerror_check_arg_rz((attach != NULL),
"attach");
119 return attach->is_url;
124 icalerror_check_arg_rz((attach != NULL),
"attach");
125 icalerror_check_arg_rz((attach->is_url),
"attach->is_url");
127 return attach->u.url.url;
132 icalerror_check_arg_rz((attach != NULL),
"attach");
133 icalerror_check_arg_rz((!attach->is_url),
"!attach->is_url");
135 return (
unsigned char *)attach->u.data.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.
void icalattach_unref(icalattach *attach)
Decrements reference count of the icalattach.
void icalattach_ref(icalattach *attach)
Increments reference count of the icalattach.
unsigned char * icalattach_get_data(icalattach *attach)
Returns the data of the icalattach object.
const char * icalattach_get_url(icalattach *attach)
Returns the URL of the icalattach object.
icalattach * icalattach_new_from_url(const char *url)
Creates new icalattach object from a URL.
bool icalattach_get_is_url(const icalattach *attach)
Determines if attach is an URL.
struct icalattach_impl icalattach
An iCal attach object representing a link to a document object.
void(* icalattach_free_fn_t)(char *data, void *user_data)
void icalmemory_free_buffer(void *buf)
Releases a buffer.
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Common memory management routines.