More libical update work, now without import tricks. bug 394902

This commit is contained in:
mvl%exedo.nl 2007-12-10 14:34:25 +00:00
Родитель b4298fb0d2
Коммит 3525c97c8b
10 изменённых файлов: 3002 добавлений и 8 удалений

Просмотреть файл

@ -238,7 +238,7 @@ Fixed more memory leaks.
Version 0.18a 10 June 00 ( cvs tag libical-0-18a )
-----------------------------------------------
Did the final tweaks to stow.c, a program to receive and store iMIP
Did the final tweaks to stow.c, a program to recieve and store iMIP
messages.

Просмотреть файл

@ -2,4 +2,3 @@
.libs
*.lo
*.la
ical.h

Просмотреть файл

@ -0,0 +1,385 @@
/* -*- Mode: C -*-
======================================================================
FILE: icalderivedparameters.{c,h}
CREATOR: eric 09 May 1999
$Id: icalparameter.c,v 1.13 2007/04/30 13:57:48 artcancro Exp $
$Locker: $
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
The original code is icalderivedparameters.{c,h}
Contributions from:
Graham Davison (g.m.davison@computer.org)
======================================================================*/
/*#line 29 "icalparameter.c.in"*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "icalparameter.h"
#include "icalproperty.h"
#include "icalerror.h"
#include "icalmemory.h"
#include "icalparameterimpl.h"
#include <stdlib.h> /* for malloc() */
#include <errno.h>
#include <string.h> /* for memset() */
/* In icalderivedparameter */
icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val);
struct icalparameter_impl* icalparameter_new_impl(icalparameter_kind kind)
{
struct icalparameter_impl* v;
if ( ( v = (struct icalparameter_impl*)
malloc(sizeof(struct icalparameter_impl))) == 0) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
return 0;
}
strcpy(v->id,"para");
v->kind = kind;
v->size = 0;
v->string = 0;
v->x_name = 0;
v->parent = 0;
v->data = 0;
return v;
}
icalparameter*
icalparameter_new (icalparameter_kind kind)
{
struct icalparameter_impl* v = icalparameter_new_impl(kind);
return (icalparameter*) v;
}
void
icalparameter_free (icalparameter* param)
{
/* HACK. This always triggers, even when parameter is non-zero
icalerror_check_arg_rv((parameter==0),"parameter");*/
#ifdef ICAL_FREE_ON_LIST_IS_ERROR
icalerror_assert( (param->parent ==0),"Tried to free a parameter that is still attached to a component. ");
#else
if(param->parent !=0){
return;
}
#endif
if (param->string != 0){
free ((void*)param->string);
}
if (param->x_name != 0){
free ((void*)param->x_name);
}
memset(param,0,sizeof(param));
param->parent = 0;
param->id[0] = 'X';
free(param);
}
icalparameter*
icalparameter_new_clone(icalparameter* old)
{
struct icalparameter_impl *new;
new = icalparameter_new_impl(old->kind);
icalerror_check_arg_rz((old!=0),"param");
if (new == 0){
return 0;
}
memcpy(new,old,sizeof(struct icalparameter_impl));
if (old->string != 0){
new->string = icalmemory_strdup(old->string);
if (new->string == 0){
icalparameter_free(new);
return 0;
}
}
if (old->x_name != 0){
new->x_name = icalmemory_strdup(old->x_name);
if (new->x_name == 0){
icalparameter_free(new);
return 0;
}
}
return new;
}
icalparameter* icalparameter_new_from_string(const char *str)
{
char* eq;
char* cpy;
icalparameter_kind kind;
icalparameter *param;
icalerror_check_arg_rz(str != 0,"str");
cpy = icalmemory_strdup(str);
if (cpy == 0){
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
return 0;
}
eq = strchr(cpy,'=');
if(eq == 0){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
}
*eq = '\0';
eq++;
kind = icalparameter_string_to_kind(cpy);
if(kind == ICAL_NO_PARAMETER){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
}
param = icalparameter_new_from_value_string(kind,eq);
if(kind == ICAL_X_PARAMETER){
icalparameter_set_xname(param,cpy);
}
free(cpy);
return param;
}
/**
* Return a string representation of the parameter according to RFC2445.
*
* param = param-name "=" param-value
* param-name = iana-token / x-token
* param-value = paramtext /quoted-string
* paramtext = *SAFE-SHARE
* quoted-string= DQUOTE *QSAFE-CHARE DQUOTE
* QSAFE-CHAR = any character except CTLs and DQUOTE
* SAFE-CHAR = any character except CTLs, DQUOTE. ";", ":", ","
*/
char*
icalparameter_as_ical_string (icalparameter* param)
{
size_t buf_size = 1024;
char* buf;
char* buf_ptr;
char *out_buf;
const char *kind_string;
icalerror_check_arg_rz( (param!=0), "parameter");
/* Create new buffer that we can append names, parameters and a
value to, and reallocate as needed. Later, this buffer will be
copied to a icalmemory_tmp_buffer, which is managed internally
by libical, so it can be given to the caller without fear of
the caller forgetting to free it */
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
if(param->kind == ICAL_X_PARAMETER) {
icalmemory_append_string(&buf, &buf_ptr, &buf_size,
icalparameter_get_xname(param));
} else {
kind_string = icalparameter_kind_to_string(param->kind);
if (param->kind == ICAL_NO_PARAMETER ||
param->kind == ICAL_ANY_PARAMETER ||
kind_string == 0)
{
icalerror_set_errno(ICAL_BADARG_ERROR);
return 0;
}
/* Put the parameter name into the string */
icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
}
icalmemory_append_string(&buf, &buf_ptr, &buf_size, "=");
if(param->string !=0){
int qm = 0;
/* Encapsulate the property in quotes if necessary */
if (strpbrk(param->string, ";:,") != 0) {
icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"');
qm = 1;
}
icalmemory_append_string(&buf, &buf_ptr, &buf_size, param->string);
if (qm == 1) {
icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"');
}
} else if (param->data != 0){
const char* str = icalparameter_enum_to_string(param->data);
icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
} else {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
}
/* Now, copy the buffer to a tmp_buffer, which is safe to give to
the caller without worring about de-allocating it. */
out_buf = icalmemory_tmp_buffer(strlen(buf)+1);
strcpy(out_buf, buf);
icalmemory_free_buffer(buf);
return out_buf;
}
int
icalparameter_is_valid (icalparameter* parameter);
icalparameter_kind
icalparameter_isa (icalparameter* parameter)
{
if(parameter == 0){
return ICAL_NO_PARAMETER;
}
return parameter->kind;
}
int
icalparameter_isa_parameter (void* parameter)
{
struct icalparameter_impl *impl = (struct icalparameter_impl *)parameter;
if (parameter == 0){
return 0;
}
if (strcmp(impl->id,"para") == 0) {
return 1;
} else {
return 0;
}
}
void
icalparameter_set_xname (icalparameter* param, const char* v)
{
icalerror_check_arg_rv( (param!=0),"param");
icalerror_check_arg_rv( (v!=0),"v");
if (param->x_name != 0){
free((void*)param->x_name);
}
param->x_name = icalmemory_strdup(v);
if (param->x_name == 0){
errno = ENOMEM;
}
}
const char*
icalparameter_get_xname (icalparameter* param)
{
icalerror_check_arg_rz( (param!=0),"param");
return param->x_name;
}
void
icalparameter_set_xvalue (icalparameter* param, const char* v)
{
icalerror_check_arg_rv( (param!=0),"param");
icalerror_check_arg_rv( (v!=0),"v");
if (param->string != 0){
free((void*)param->string);
}
param->string = icalmemory_strdup(v);
if (param->string == 0){
errno = ENOMEM;
}
}
const char*
icalparameter_get_xvalue (icalparameter* param)
{
icalerror_check_arg_rz( (param!=0),"param");
return param->string;
}
void icalparameter_set_parent(icalparameter* param,
icalproperty* property)
{
icalerror_check_arg_rv( (param!=0),"param");
param->parent = property;
}
icalproperty* icalparameter_get_parent(icalparameter* param)
{
icalerror_check_arg_rz( (param!=0),"param");
return param->parent;
}
/* Everything below this line is machine generated. Do not edit. */
/* ALTREP */

Просмотреть файл

@ -0,0 +1,69 @@
/* -*- Mode: C -*- */
/*======================================================================
FILE: icalparam.h
CREATOR: eric 20 March 1999
$Id: icalparameter.h,v 1.4 2007/04/30 13:57:48 artcancro Exp $
$Locker: $
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
The original code is icalparam.h
======================================================================*/
#ifndef ICALPARAM_H
#define ICALPARAM_H
#include "icalderivedparameter.h"
/* Declared in icalderivedparameter.h */
/*typedef struct icalparameter_impl icalparameter;*/
icalparameter* icalparameter_new(icalparameter_kind kind);
icalparameter* icalparameter_new_clone(icalparameter* p);
/* Create from string of form "PARAMNAME=VALUE" */
icalparameter* icalparameter_new_from_string(const char* value);
/* Create from just the value, the part after the "=" */
icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind, const char* value);
void icalparameter_free(icalparameter* parameter);
char* icalparameter_as_ical_string(icalparameter* parameter);
int icalparameter_is_valid(icalparameter* parameter);
icalparameter_kind icalparameter_isa(icalparameter* parameter);
int icalparameter_isa_parameter(void* param);
/* Acess the name of an X parameer */
void icalparameter_set_xname (icalparameter* param, const char* v);
const char* icalparameter_get_xname(icalparameter* param);
void icalparameter_set_xvalue (icalparameter* param, const char* v);
const char* icalparameter_get_xvalue(icalparameter* param);
/* Convert enumerations */
const char* icalparameter_kind_to_string(icalparameter_kind kind);
icalparameter_kind icalparameter_string_to_kind(const char* string);
#endif

Просмотреть файл

@ -979,7 +979,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
case ICAL_RESOURCES_PROPERTY:
case ICAL_RDATE_PROPERTY:
case ICAL_EXDATE_PROPERTY:
str = icalparser_get_next_value(end,&end, value_kind);
str = parser_get_next_value(end,&end, value_kind);
break;
default:
str = icalparser_get_value(end, &end, value_kind);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,134 @@
/* -*- Mode: C -*- */
/*======================================================================
FILE: icalproperty.h
CREATOR: eric 20 March 1999
$Id: icalproperty.h,v 1.19 2007/04/30 13:57:48 artcancro Exp $
$Locker: $
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
The original code is icalparam.h
======================================================================*/
#ifndef ICALPROPERTY_H
#define ICALPROPERTY_H
#include <time.h>
#include <stdarg.h> /* for va_... */
#include "icalderivedparameter.h"
#include "icalvalue.h"
#include "icalrecur.h"
/* Actually in icalderivedproperty.h:
typedef struct icalproperty_impl icalproperty; */
#include "icalderivedproperty.h" /* To get icalproperty_kind enumerations */
icalproperty* icalproperty_new(icalproperty_kind kind);
icalproperty* icalproperty_new_clone(icalproperty * prop);
icalproperty* icalproperty_new_from_string(const char* str);
const char* icalproperty_as_ical_string(icalproperty* prop);
void icalproperty_free(icalproperty* prop);
icalproperty_kind icalproperty_isa(icalproperty* property);
int icalproperty_isa_property(void* property);
void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args);
void icalproperty_add_parameter(icalproperty* prop,icalparameter* parameter);
void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter);
void icalproperty_set_parameter_from_string(icalproperty* prop,
const char* name, const char* value);
const char* icalproperty_get_parameter_as_string(icalproperty* prop,
const char* name);
void icalproperty_remove_parameter(icalproperty* prop,
icalparameter_kind kind);
void icalproperty_remove_parameter_by_kind(icalproperty* prop,
icalparameter_kind kind);
void icalproperty_remove_parameter_by_name(icalproperty* prop,
const char *name);
void icalproperty_remove_parameter_by_ref(icalproperty* prop,
icalparameter *param);
int icalproperty_count_parameters(const icalproperty* prop);
/* Iterate through the parameters */
icalparameter* icalproperty_get_first_parameter(icalproperty* prop,
icalparameter_kind kind);
icalparameter* icalproperty_get_next_parameter(icalproperty* prop,
icalparameter_kind kind);
/* Access the value of the property */
void icalproperty_set_value(icalproperty* prop, icalvalue* value);
void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind);
icalvalue* icalproperty_get_value(const icalproperty* prop);
const char* icalproperty_get_value_as_string(const icalproperty* prop);
/* Deal with X properties */
void icalproperty_set_x_name(icalproperty* prop, const char* name);
const char* icalproperty_get_x_name(icalproperty* prop);
/** Return the name of the property -- the type name converted to a
* string, or the value of _get_x_name if the type is and X
* property
*/
const char* icalproperty_get_property_name (const icalproperty* prop);
icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
/* Convert kinds to string and get default value type */
icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind);
icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind);
const char* icalproperty_kind_to_string(icalproperty_kind kind);
icalproperty_kind icalproperty_string_to_kind(const char* string);
/** Check validity of a specific icalproperty_kind **/
int icalproperty_kind_is_valid(const icalproperty_kind kind);
icalproperty_method icalproperty_string_to_method(const char* str);
const char* icalproperty_method_to_string(icalproperty_method method);
const char* icalproperty_enum_to_string(int e);
int icalproperty_string_to_enum(const char* str);
int icalproperty_kind_and_string_to_enum(const int kind, const char* str);
const char* icalproperty_status_to_string(icalproperty_status);
icalproperty_status icalproperty_string_to_status(const char* string);
int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e);
#endif /*ICALPROPERTY_H*/

Просмотреть файл

@ -420,7 +420,6 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
}
} else if (strcasecmp(name,"WKST") == 0){
parser.rt.week_start = icalrecur_string_to_weekday(value);
sort_bydayrules(parser.rt.by_day,parser.rt.week_start);
} else if (strcasecmp(name,"BYSECOND") == 0){
icalrecur_add_byrules(&parser,parser.rt.by_second,
ICAL_BY_SECOND_SIZE,value);
@ -1604,10 +1603,6 @@ static int next_weekday_by_week(icalrecur_iterator* impl)
return 1;
}
/* this call to 'sort_bydayrules' assures that the occurrences for
weekly recurrences will be generated in a strict linear order. */
sort_bydayrules(BYDAYPTR,impl->rule.week_start);
/* If we get here, we need to step to tne next day */
for (;;) {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,88 @@
/* -*- Mode: C -*- */
/*======================================================================
FILE: icalvalue.h
CREATOR: eric 20 March 1999
$Id: icalvalue.h,v 1.8 2007/04/30 13:57:48 artcancro Exp $
$Locker: $
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
The original code is icalvalue.h
======================================================================*/
#ifndef ICALVALUE_H
#define ICALVALUE_H
#include <time.h>
#include "icalenums.h"
#include "icaltypes.h"
#include "icalrecur.h"
#include "icalduration.h"
#include "icalperiod.h"
#include "icalderivedproperty.h" /* For icalproperty_method, etc. */
#include "icalderivedparameter.h"
#include "icalderivedvalue.h"
/* Defined in icalderivedvalue.h */
/*typedef struct icalvalue_impl icalvalue;*/
icalvalue* icalvalue_new(icalvalue_kind kind);
icalvalue* icalvalue_new_clone(const icalvalue* value);
icalvalue* icalvalue_new_from_string(icalvalue_kind kind, const char* str);
void icalvalue_free(icalvalue* value);
int icalvalue_is_valid(const icalvalue* value);
const char* icalvalue_as_ical_string(const icalvalue* value);
icalvalue_kind icalvalue_isa(const icalvalue* value);
int icalvalue_isa_value(void*);
icalparameter_xliccomparetype icalvalue_compare(const icalvalue* a, const icalvalue *b);
/* Special, non autogenerated value accessors */
icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value);
icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
struct icaltriggertype icalvalue_get_trigger(const icalvalue* value);
icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
void icalvalue_set_datetimeperiod(icalvalue* value,
struct icaldatetimeperiodtype v);
struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value);
/* Convert enumerations */
icalvalue_kind icalvalue_string_to_kind(const char* str);
const char* icalvalue_kind_to_string(const icalvalue_kind kind);
/** Check validity of a specific icalvalue_kind **/
int icalvalue_kind_is_valid(const icalvalue_kind kind);
/** Encode a character string in ical format, esacpe certain characters, etc. */
int icalvalue_encode_ical_string(const char *szText, char *szEncText, int MaxBufferLen);
#endif /*ICALVALUE_H*/