Back to index

lightning-sunbird  0.9+nobinonly
Functions
icalattach.c File Reference
#include "icaltypes.h"
#include "icalerror.h"
#include "icalmemory.h"
#include "icalattachimpl.h"
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <assert.h>

Go to the source code of this file.

Functions

icalattach * icalattach_new_from_url (const char *url)
icalattach * icalattach_new_from_data (unsigned char *data, icalattach_free_fn_t free_fn, void *free_fn_data)
void icalattach_ref (icalattach *attach)
void icalattach_unref (icalattach *attach)
int icalattach_get_is_url (icalattach *attach)
const char * icalattach_get_url (icalattach *attach)
unsigned char * icalattach_get_data (icalattach *attach)

Function Documentation

unsigned char* icalattach_get_data ( icalattach *  attach)

Definition at line 133 of file icalattach.c.

{
    icalerror_check_arg_rz ((attach != NULL), "attach");
    icalerror_check_arg_rz ((!attach->is_url), "!attach->is_url");

    return attach->u.data.data;
}
int icalattach_get_is_url ( icalattach *  attach)

Definition at line 116 of file icalattach.c.

{
    icalerror_check_arg_rz ((attach != NULL), "attach");

    return attach->is_url ? 1 : 0;
}

Here is the caller graph for this function:

const char* icalattach_get_url ( icalattach *  attach)

Definition at line 124 of file icalattach.c.

{
    icalerror_check_arg_rz ((attach != NULL), "attach");
    icalerror_check_arg_rz ((attach->is_url), "attach->is_url");

    return attach->u.url.url;
}

Here is the caller graph for this function:

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

Definition at line 66 of file icalattach.c.

{
    icalattach *attach;

    icalerror_check_arg_rz ((data != NULL), "data");

    if ((attach = malloc (sizeof (icalattach))) == NULL) {
       errno = ENOMEM;
       return NULL;
    }

    attach->refcount = 1;
    attach->is_url = 0;
    attach->u.data.data = data;
    attach->u.data.free_fn = free_fn;
    attach->u.data.free_fn_data = free_fn_data;

    return attach;
}
icalattach* icalattach_new_from_url ( const char *  url)

Definition at line 40 of file icalattach.c.

{
    icalattach *attach;
    char *url_copy;

    icalerror_check_arg_rz ((url != NULL), "url");

    if ((attach = malloc (sizeof (icalattach))) == NULL) {
       errno = ENOMEM;
       return NULL;
    }

    if ((url_copy = strdup (url)) == NULL) {
       free (attach);
       errno = ENOMEM;
       return NULL;
    }

    attach->refcount = 1;
    attach->is_url = 1;
    attach->u.url.url = url_copy;

    return attach;
}

Here is the caller graph for this function:

void icalattach_ref ( icalattach *  attach)

Definition at line 88 of file icalattach.c.

{
    icalerror_check_arg_rv ((attach != NULL), "attach");
    icalerror_check_arg_rv ((attach->refcount > 0), "attach->refcount > 0");

    attach->refcount++;
}

Here is the caller graph for this function:

void icalattach_unref ( icalattach *  attach)

Definition at line 97 of file icalattach.c.

{
    icalerror_check_arg_rv ((attach != NULL), "attach");
    icalerror_check_arg_rv ((attach->refcount > 0), "attach->refcount > 0");

    attach->refcount--;

    if (attach->refcount != 0)
       return;

    if (attach->is_url)
       free (attach->u.url.url);
    else if (attach->u.data.free_fn)
       (* attach->u.data.free_fn) (attach->u.data.data, attach->u.data.free_fn_data);

    free (attach);
}

Here is the caller graph for this function: