caldav-utils.c File Reference

#include "caldav-utils.h"
#include "md5.h"
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

Defines

#define MAX_TOKENS   2
 Find a specific HTTP header from last request.
#define ELEM_HREF   "href>"
 Fetch a URL from a XML element.
#define ELEM_ETAG   "getetag"
 Fetch the etag element from XML.

Functions

void dump (const char *text, FILE *stream, unsigned char *ptr, size_t size, char nohex)
 This function is burrowed from the libcurl documentation.
int my_trace (CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp)
 This function is burrowed from the libcurl documentation.
static void * myrealloc (void *ptr, size_t size)
 This function is burrowed from the libcurl documentation.
size_t WriteMemoryCallback (void *ptr, size_t size, size_t nmemb, void *data)
 This function is burrowed from the libcurl documentation.
size_t WriteHeaderCallback (void *ptr, size_t size, size_t nmemb, void *data)
 This function is burrowed from the libcurl documentation.
void init_caldav_settings (caldav_settings *settings)
 Initialize caldav settings structure.
void free_caldav_settings (caldav_settings *settings)
 Free momory assigned to caldav settings structure.
void parse_url (caldav_settings *settings, const char *url)
 Parse URL.
gchar * get_response_header (const char *header, gchar *headers, gboolean lowcase)
 Find a specific HTTP header from last request.
static gchar * parse_caldav_report_wrap (char *report, const char *element, const char *type, gboolean wrap, gboolean recursive)
 Parse response from CalDAV server.
gchar * parse_caldav_report (char *report, const char *element, const char *type)
 Parse response from CalDAV server.
gchar * get_caldav_datetime (time_t *time)
 Convert a time_t variable to CalDAV DateTime.
gchar * random_file_name (gchar *text)
 Create a random text string, using MD5.
gchar * verify_uid (gchar *object)
 Does the event contain a UID element or not.
gchar * get_url (gchar *text)
 Fetch a URL from a XML element.
gchar * get_tag (const gchar *tag, gchar *text)
 Fetch any element from XML.
gchar * get_etag (gchar *text)
 Fetch the etag element from XML.
gchar * get_host (gchar *url)
 Fetch host from URL.

Variables

static const char * VCAL_HEAD
static const char * VCAL_FOOT = "END:VCALENDAR"

Define Documentation

#define ELEM_ETAG   "getetag"

Fetch the etag element from XML.

Parameters:
text String
Returns:
etag

#define ELEM_HREF   "href>"

Fetch a URL from a XML element.

Parameters:
text String
Returns:
URL

#define MAX_TOKENS   2

Find a specific HTTP header from last request.

Parameters:
header HTTP header to search for
headers String of HTTP headers from last request
lowcase Should string be returned in all lower case.
Returns:
The header found or NULL


Function Documentation

void dump ( const char *  text,
FILE *  stream,
unsigned char *  ptr,
size_t  size,
char  nohex 
)

This function is burrowed from the libcurl documentation.

Parameters:
text 
stream 
ptr 
size 
nohex 

void free_caldav_settings ( caldav_settings settings  ) 

Free momory assigned to caldav settings structure.

Parameters:
settings 
See also:
caldav_settings

gchar* get_caldav_datetime ( time_t *  time  ) 

Convert a time_t variable to CalDAV DateTime.

Parameters:
time a specific date and time
Returns:
the CalDAV DateTime

gchar* get_etag ( gchar *  text  ) 

Fetch the etag element from XML.

Parameters:
text String
Returns:
etag

gchar* get_host ( gchar *  url  ) 

Fetch host from URL.

Parameters:
url URL
Returns:
host

gchar* get_response_header ( const char *  header,
gchar *  headers,
gboolean  lowcase 
)

Find a specific HTTP header from last request.

Parameters:
header HTTP header to search for
headers String of HTTP headers from last request
lowcase Should string be returned in all lower case.
Returns:
The header found or NULL

gchar* get_tag ( const gchar *  tag,
gchar *  text 
)

Fetch any element from XML.

Parameters:
text String
tag The element to look for
Returns:
element

gchar* get_url ( gchar *  text  ) 

Fetch a URL from a XML element.

Parameters:
text String
Returns:
URL

void init_caldav_settings ( caldav_settings settings  ) 

Initialize caldav settings structure.

Parameters:
settings 
See also:
caldav_settings

int my_trace ( CURL *  handle,
curl_infotype  type,
unsigned char *  data,
size_t  size,
void *  userp 
)

This function is burrowed from the libcurl documentation.

Parameters:
handle 
type 
data 
size 
userp 
Returns:

static void* myrealloc ( void *  ptr,
size_t  size 
) [static]

This function is burrowed from the libcurl documentation.

Parameters:
ptr 
size 
Returns:
void* to memory region

gchar* parse_caldav_report ( char *  report,
const char *  element,
const char *  type 
)

Parse response from CalDAV server.

Parameters:
report Response from server
element XML element to find
type VCalendar element to find
Returns:
the parsed result

static gchar* parse_caldav_report_wrap ( char *  report,
const char *  element,
const char *  type,
gboolean  wrap,
gboolean  recursive 
) [static]

Parse response from CalDAV server.

Internal function.

Parameters:
report Response from server
element XML element to find
type VCalendar element to find
wrap Is this the final parsing or just a part
recursive Stop after first match or not
Returns:
the parsed result

void parse_url ( caldav_settings settings,
const char *  url 
)

Parse URL.

Parameters:
settings 
See also:
caldav_settings
Parameters:
url String containing URL to collection

gchar* random_file_name ( gchar *  text  ) 

Create a random text string, using MD5.

See also:
caldav_md5_hex_digest()
Parameters:
text some text to randomize
Returns:
MD5 hash of text

gchar* verify_uid ( gchar *  object  ) 

Does the event contain a UID element or not.

If not add it.

Parameters:
object A specific event
Returns:
event, eventually added UID

size_t WriteHeaderCallback ( void *  ptr,
size_t  size,
size_t  nmemb,
void *  data 
)

This function is burrowed from the libcurl documentation.

Parameters:
ptr 
size 
nmemb 
data 
Returns:
number of written bytes

size_t WriteMemoryCallback ( void *  ptr,
size_t  size,
size_t  nmemb,
void *  data 
)

This function is burrowed from the libcurl documentation.

Parameters:
ptr 
size 
nmemb 
data 
Returns:
number of written bytes


Variable Documentation

const char* VCAL_FOOT = "END:VCALENDAR" [static]

const char* VCAL_HEAD [static]

Initial value:

"BEGIN:VCALENDAR\r\n"
"PRODID:-//CalDAV Calendar//NONSGML libcaldav//EN\r\n"
"VERSION:2.0\r\n"


Generated on Tue Apr 8 00:29:58 2008 for libcaldav-0.3.0 by  doxygen 1.5.5