summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icalparser.c
authorzautrix <zautrix>2004-06-29 11:59:46 (UTC)
committer zautrix <zautrix>2004-06-29 11:59:46 (UTC)
commitda43dbdc6c82453228f34766fc74585615cba938 (patch) (side-by-side diff)
tree16576932cea08bf117b2d0320b0d5f66ee8ad093 /libical/src/libical/icalparser.c
parent627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff)
downloadkdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip
kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz
kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2
New lib ical.Some minor changes as well.
Diffstat (limited to 'libical/src/libical/icalparser.c') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icalparser.c365
1 files changed, 179 insertions, 186 deletions
diff --git a/libical/src/libical/icalparser.c b/libical/src/libical/icalparser.c
index b5824d5..5c4296b 100644
--- a/libical/src/libical/icalparser.c
+++ b/libical/src/libical/icalparser.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C -*-
+/* -*- Mode: C; tab-width: 4; c-basic-offset: 8; -*-
======================================================================
FILE: icalparser.c
CREATOR: eric 04 August 1999
@@ -38,9 +38,7 @@
#endif
-#include "icalparser.h"
#include "pvl.h"
-#include "icalmemory.h"
#include "icalerror.h"
#include "icalvalue.h"
#include "icalderivedparameter.h"
@@ -52,13 +50,28 @@
#include <stdio.h> /* For FILE and fgets and sprintf */
#include <stdlib.h> /* for free */
-int snprintf(char *str, size_t n, char const *fmt, ...);
+#include "icalmemory.h"
+#include "icalparser.h"
+
+#ifdef HAVE_WCTYPE_H
+# include <wctype.h>
+/* Some systems have an imcomplete implementation on wctype (FreeBSD,
+ * Darwin). Cope with that. */
+# ifndef HAVE_ISWSPACE
+# define iswspace isspace
+# endif
+#else
+# ifndef HAVE_ISWSPACE
+# define iswspace isspace
+# endif
+#endif
-extern icalvalue* icalparser_yy_value;
-void set_parser_value_state(icalvalue_kind kind);
-int ical_yyparse(void);
+#ifdef WIN32
+#define snprintf _snprintf
+#define strcasecmp stricmp
+#endif
-char* icalparser_get_next_char(char c, char *str);
+char* icalparser_get_next_char(char c, char *str, int qm);
char* icalparser_get_next_parameter(char* line,char** end);
char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind);
char* icalparser_get_prop_name(char* line, char** end);
@@ -81,7 +94,7 @@ struct icalparser_impl
pvl_list components;
void *line_gen_data;
-
+
};
@@ -100,6 +113,7 @@ icalparser* icalparser_new(void)
impl->state = ICALPARSER_SUCCESS;
impl->tmp_buf_size = TMP_BUF_SIZE;
impl->buffer_full = 0;
+ impl->continuation_line = 0;
impl->lineno = 0;
impl->continuation_line = 0;
memset(impl->temp,0, TMP_BUF_SIZE);
@@ -110,27 +124,24 @@ icalparser* icalparser_new(void)
void icalparser_free(icalparser* parser)
{
- struct icalparser_impl* impl = (struct icalparser_impl*)parser;
icalcomponent *c;
- if (impl->root_component != 0){
- icalcomponent_free(impl->root_component);
+ if (parser->root_component != 0){
+ icalcomponent_free(parser->root_component);
}
- while( (c=pvl_pop(impl->components)) != 0){
+ while( (c=pvl_pop(parser->components)) != 0){
icalcomponent_free(c);
}
- pvl_free(impl->components);
+ pvl_free(parser->components);
- free(impl);
+ free(parser);
}
void icalparser_set_gen_data(icalparser* parser, void* data)
{
- struct icalparser_impl* impl = (struct icalparser_impl*)parser;
-
- impl->line_gen_data = data;
+ parser->line_gen_data = data;
}
@@ -140,37 +151,38 @@ icalvalue* icalvalue_new_From_string_with_error(icalvalue_kind kind,
-char* icalparser_get_next_char(char c, char *str)
+char* icalparser_get_next_char(char c, char *str, int qm)
{
int quote_mode = 0;
char* p;
-
for(p=str; *p!=0; p++){
-
- if ( quote_mode == 0 && *p=='"' && *(p-1) != '\\' ){
- quote_mode =1;
- continue;
- }
-
- if ( quote_mode == 1 && *p=='"' && *(p-1) != '\\' ){
- quote_mode =0;
- continue;
- }
-
- if (quote_mode == 0 && *p== c && *(p-1) != '\\' ){
- return p;
- }
+ if (qm == 1) {
+ if ( quote_mode == 0 && *p=='"' && *(p-1) != '\\' ){
+ quote_mode =1;
+ continue;
+ }
+
+ if ( quote_mode == 1 && *p=='"' && *(p-1) != '\\' ){
+ quote_mode =0;
+ continue;
+ }
+ }
+
+ if (quote_mode == 0 && *p== c && *(p-1) != '\\' ){
+ return p;
+ }
}
return 0;
}
-/* make a new tmp buffer out of a substring */
-char* make_segment(char* start, char* end)
+
+/** make a new tmp buffer out of a substring */
+static char* make_segment(char* start, char* end)
{
- char *buf;
+ char *buf, *tmp;
size_t size = (size_t)end - (size_t)start;
buf = icalmemory_tmp_buffer(size+1);
@@ -178,64 +190,17 @@ char* make_segment(char* start, char* end)
strncpy(buf,start,size);
*(buf+size) = 0;
+
+ tmp = (buf+size);
+ while ( *tmp == '\0' || iswspace(*tmp) )
+ {
+ *tmp = 0;
+ tmp--;
+ }
return buf;
-
}
-const char* input_buffer;
-const char* input_buffer_p;
-//#define min(a,b) ((a) < (b) ? (a) : (b))
-
-int icalparser_flex_input(char* buf, int max_size)
-{
- int n = max_size; // = min(max_size,strlen(input_buffer_p));
- if ( n < ((int )strlen(input_buffer_p)) )
- n = strlen(input_buffer_p);
- if (n > 0){
- memcpy(buf, input_buffer_p, n);
- input_buffer_p += n;
- return n;
- } else {
- return 0;
- }
-}
-
-void icalparser_clear_flex_input(void)
-{
- input_buffer_p = input_buffer+strlen(input_buffer);
-}
-
-/* Call the flex/bison parser to parse a complex value */
-
-icalvalue* icalparser_parse_value(icalvalue_kind kind,
- const char* str, icalproperty** error)
-{
- int r;
- input_buffer_p = input_buffer = str;
-
- set_parser_value_state(kind);
- icalparser_yy_value = 0;
-
- r = ical_yyparse();
-
- /* Error. Parse failed */
- if( icalparser_yy_value == 0 || r != 0){
-
- if(icalparser_yy_value !=0){
- icalvalue_free(icalparser_yy_value);
- icalparser_yy_value = 0;
- }
-
- return 0;
- }
-
- if (error != 0){
- *error = 0;
- }
-
- return icalparser_yy_value;
-}
char* icalparser_get_prop_name(char* line, char** end)
{
@@ -243,8 +208,8 @@ char* icalparser_get_prop_name(char* line, char** end)
char* v;
char *str;
- p = icalparser_get_next_char(';',line);
- v = icalparser_get_next_char(':',line);
+ p = icalparser_get_next_char(';',line,1);
+ v = icalparser_get_next_char(':',line,1);
if (p== 0 && v == 0) {
return 0;
}
@@ -262,13 +227,13 @@ char* icalparser_get_prop_name(char* line, char** end)
return str;
}
+
char* icalparser_get_param_name(char* line, char **end)
{
-
char* next;
char *str;
- next = icalparser_get_next_char('=',line);
+ next = icalparser_get_next_char('=',line,1);
if (next == 0) {
return 0;
@@ -276,17 +241,26 @@ char* icalparser_get_param_name(char* line, char **end)
str = make_segment(line,next);
*end = next+1;
+ if (**end == '"') {
+ *end = *end+1;
+ next = icalparser_get_next_char('"',*end,0);
+ if (next == 0) {
+ return 0;
+ }
+
+ *end = make_segment(*end,next);
+ }
+
return str;
-
}
+
char* icalparser_get_next_paramvalue(char* line, char **end)
{
-
char* next;
char *str;
- next = icalparser_get_next_char(',',line);
+ next = icalparser_get_next_char(',',line,1);
if (next == 0){
next = (char*)(size_t)line+(size_t)strlen(line);\
@@ -299,10 +273,11 @@ char* icalparser_get_next_paramvalue(char* line, char **end)
*end = next+1;
return str;
}
-
}
-/* A property may have multiple values, if the values are seperated by
+
+/**
+ A property may have multiple values, if the values are seperated by
commas in the content line. This routine will look for the next
comma after line and will set the next place to start searching in
end. */
@@ -318,7 +293,7 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
p = line;
while(1){
- next = icalparser_get_next_char(',',p);
+ next = icalparser_get_next_char(',',p,1);
/* Unforunately, RFC2445 says that for the RECUR value, COMMA
can both seperate digits in a list, and it can seperate
@@ -340,6 +315,15 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
continue;
}
}
+ /* ignore all , for query value. select dtstart, dtend etc ... */
+ else if( kind == ICAL_QUERY_VALUE) {
+ if ( next != 0) {
+ p = next+1;
+ continue;
+ }
+ else
+ break;
+ }
/* If the comma is preceeded by a '\', then it is a literal and
not a value seperator*/
@@ -379,14 +363,14 @@ char* icalparser_get_next_parameter(char* line,char** end)
char *v;
char *str;
- v = icalparser_get_next_char(':',line);
- next = icalparser_get_next_char(';', line);
+ v = icalparser_get_next_char(':',line,1);
+ next = icalparser_get_next_char(';', line,1);
/* There is no ';' or, it is after the ':' that marks the beginning of
the value */
if (next == 0 || next > v) {
- next = icalparser_get_next_char(':', line);
+ next = icalparser_get_next_char(':', line,1);
}
if (next != 0) {
@@ -399,23 +383,23 @@ char* icalparser_get_next_parameter(char* line,char** end)
}
}
-/* Get a single property line, from the property name through the
- final new line, and include any continuation lines */
+/**
+ * Get a single property line, from the property name through the
+ * final new line, and include any continuation lines
+ */
char* icalparser_get_line(icalparser *parser,
char* (*line_gen_func)(char *s, size_t size, void *d))
{
char *line;
char *line_p;
- struct icalparser_impl* impl = (struct icalparser_impl*)parser;
- size_t buf_size = impl->tmp_buf_size;
-
+ size_t buf_size = parser->tmp_buf_size;
line_p = line = icalmemory_new_buffer(buf_size);
line[0] = '\0';
/* Read lines by calling line_gen_func and putting the data into
- impl->temp. If the line is a continuation line ( begins with a
+ parser->temp. If the line is a continuation line ( begins with a
space after a newline ) then append the data onto line and read
again. Otherwise, exit the loop. */
@@ -429,23 +413,23 @@ char* icalparser_get_line(icalparser *parser,
/* The tmp buffer is not clear, so transfer the data in it to the
output. This may be left over from a previous call */
- if (impl->temp[0] != '\0' ) {
+ if (parser->temp[0] != '\0' ) {
/* If the last position in the temp buffer is occupied,
mark the buffer as full. The means we will do another
read later, because the line is not finished */
- if (impl->temp[impl->tmp_buf_size-1] == 0 &&
- impl->temp[impl->tmp_buf_size-2] != '\n'&&
- impl->temp[impl->tmp_buf_size-2] != 0 ){
- impl->buffer_full = 1;
+ if (parser->temp[parser->tmp_buf_size-1] == 0 &&
+ parser->temp[parser->tmp_buf_size-2] != '\n'&&
+ parser->temp[parser->tmp_buf_size-2] != 0 ){
+ parser->buffer_full = 1;
} else {
- impl->buffer_full = 0;
+ parser->buffer_full = 0;
}
/* Copy the temp to the output and clear the temp buffer. */
- if(impl->continuation_line==1){
+ if(parser->continuation_line==1){
/* back up the pointer to erase the continuation characters */
- impl->continuation_line = 0;
+ parser->continuation_line = 0;
line_p--;
if ( *(line_p-1) == '\r'){
@@ -454,24 +438,24 @@ char* icalparser_get_line(icalparser *parser,
/* copy one space up to eliminate the leading space*/
icalmemory_append_string(&line,&line_p,&buf_size,
- impl->temp+1);
+ parser->temp+1);
} else {
- icalmemory_append_string(&line,&line_p,&buf_size,impl->temp);
+ icalmemory_append_string(&line,&line_p,&buf_size,parser->temp);
}
- impl->temp[0] = '\0' ;
+ parser->temp[0] = '\0' ;
}
- impl->temp[impl->tmp_buf_size-1] = 1; /* Mark end of buffer */
+ parser->temp[parser->tmp_buf_size-1] = 1; /* Mark end of buffer */
/****** Here is where the routine gets string data ******************/
- if ((*line_gen_func)(impl->temp,impl->tmp_buf_size,impl->line_gen_data)
+ if ((*line_gen_func)(parser->temp,parser->tmp_buf_size,parser->line_gen_data)
==0){/* Get more data */
/* If the first position is clear, it means we didn't get
any more data from the last call to line_ge_func*/
- if (impl->temp[0] == '\0'){
+ if (parser->temp[0] == '\0'){
if(line[0] != '\0'){
/* There is data in the output, so fall trhough and process it*/
@@ -490,12 +474,11 @@ char* icalparser_get_line(icalparser *parser,
begins with a ' ', then the buffer holds a continuation
line, so keep reading. */
- if ( line_p > line+1 && *(line_p-1) == '\n'
- && (impl->temp[0] == ' ' || impl->temp[0] == '\t') ) {
+ if ( line_p > line+1 && *(line_p-1) == '\n' && parser->temp[0] == ' ') {
- impl->continuation_line = 1;
+ parser->continuation_line = 1;
- } else if ( impl->buffer_full == 1 ) {
+ } else if ( parser->buffer_full == 1 ) {
/* The buffer was filled on the last read, so read again */
@@ -519,11 +502,17 @@ char* icalparser_get_line(icalparser *parser,
*(line_p) = '\0';
}
+ while ( (*line_p == '\0' || iswspace(*line_p)) && line_p > line )
+ {
+ *line_p = '\0';
+ line_p--;
+ }
+
return line;
}
-void insert_error(icalcomponent* comp, char* text,
+static void insert_error(icalcomponent* comp, char* text,
char* message, icalparameter_xlicerrortype type)
{
char temp[1024];
@@ -542,7 +531,8 @@ void insert_error(icalcomponent* comp, char* text,
0));
}
-int line_is_blank(char* line){
+
+static int line_is_blank(char* line){
int i=0;
for(i=0; *(line+i)!=0; i++){
@@ -564,8 +554,8 @@ icalcomponent* icalparser_parse(icalparser *parser,
char* line;
icalcomponent *c=0;
icalcomponent *root=0;
- struct icalparser_impl *impl = (struct icalparser_impl*)parser;
icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR);
+ int cont;
icalerror_check_arg_rz((parser !=0),"parser");
@@ -580,8 +570,8 @@ icalcomponent* icalparser_parse(icalparser *parser,
/* This is bad news... assert? */
}
- assert(impl->root_component == 0);
- assert(pvl_count(impl->components) ==0);
+ assert(parser->root_component == 0);
+ assert(pvl_count(parser->components) ==0);
if (root == 0){
/* Just one component */
@@ -606,10 +596,12 @@ icalcomponent* icalparser_parse(icalparser *parser,
c = 0;
}
+ cont = 0;
if(line != 0){
free(line);
+ cont = 1;
}
- } while ( line != 0);
+ } while ( cont );
icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
@@ -621,7 +613,6 @@ icalcomponent* icalparser_parse(icalparser *parser,
icalcomponent* icalparser_add_line(icalparser* parser,
char* line)
{
- char *p;
char *str;
char *end;
int vcount = 0;
@@ -631,13 +622,12 @@ icalcomponent* icalparser_add_line(icalparser* parser,
icalvalue_kind value_kind = ICAL_NO_VALUE;
- struct icalparser_impl *impl = (struct icalparser_impl*)parser;
icalerror_check_arg_rz((parser != 0),"parser");
if (line == 0)
{
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
return 0;
}
@@ -655,7 +645,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
if (str == 0 || strlen(str) == 0 ){
/* Could not get a property name */
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
+ icalcomponent *tail = pvl_data(pvl_tail(parser->components));
if (tail){
insert_error(tail,line,
@@ -663,7 +653,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
}
tail = 0;
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
return 0;
}
@@ -673,17 +663,22 @@ icalcomponent* icalparser_add_line(icalparser* parser,
/* If the property name is BEGIN or END, we are actually
starting or ending a new component */
+
if(strcmp(str,"BEGIN") == 0){
icalcomponent *c;
icalcomponent_kind comp_kind;
- impl->level++;
+
+ parser->level++;
str = icalparser_get_next_value(end,&end, value_kind);
comp_kind = icalenum_string_to_component_kind(str);
+
if (comp_kind == ICAL_NO_COMPONENT){
+
+
c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);
insert_error(c,str,"Parse error in component name",
ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
@@ -697,48 +692,48 @@ icalcomponent* icalparser_add_line(icalparser* parser,
ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
}
- pvl_push(impl->components,c);
+ pvl_push(parser->components,c);
- impl->state = ICALPARSER_BEGIN_COMP;
+ parser->state = ICALPARSER_BEGIN_COMP;
return 0;
} else if (strcmp(str,"END") == 0 ) {
icalcomponent* tail;
- impl->level--;
+ parser->level--;
str = icalparser_get_next_value(end,&end, value_kind);
/* Pop last component off of list and add it to the second-to-last*/
- impl->root_component = pvl_pop(impl->components);
+ parser->root_component = pvl_pop(parser->components);
- tail = pvl_data(pvl_tail(impl->components));
+ tail = pvl_data(pvl_tail(parser->components));
if(tail != 0){
- icalcomponent_add_component(tail,impl->root_component);
+ icalcomponent_add_component(tail,parser->root_component);
}
tail = 0;
/* Return the component if we are back to the 0th level */
- if (impl->level == 0){
+ if (parser->level == 0){
icalcomponent *rtrn;
- if(pvl_count(impl->components) != 0){
+ if(pvl_count(parser->components) != 0){
/* There are still components on the stack -- this means
that one of them did not have a proper "END" */
- pvl_push(impl->components,impl->root_component);
- icalparser_clean(parser); /* may reset impl->root_component*/
+ pvl_push(parser->components,parser->root_component);
+ icalparser_clean(parser); /* may reset parser->root_component*/
}
- assert(pvl_count(impl->components) == 0);
+ assert(pvl_count(parser->components) == 0);
- impl->state = ICALPARSER_SUCCESS;
- rtrn = impl->root_component;
- impl->root_component = 0;
+ parser->state = ICALPARSER_SUCCESS;
+ rtrn = parser->root_component;
+ parser->root_component = 0;
return rtrn;
} else {
- impl->state = ICALPARSER_END_COMP;
+ parser->state = ICALPARSER_END_COMP;
return 0;
}
}
@@ -747,8 +742,8 @@ icalcomponent* icalparser_add_line(icalparser* parser,
/* There is no point in continuing if we have not seen a
component yet */
- if(pvl_data(pvl_tail(impl->components)) == 0){
- impl->state = ICALPARSER_ERROR;
+ if(pvl_data(pvl_tail(parser->components)) == 0){
+ parser->state = ICALPARSER_ERROR;
return 0;
}
@@ -767,7 +762,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
prop = icalproperty_new(prop_kind);
if (prop != 0){
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
+ icalcomponent *tail = pvl_data(pvl_tail(parser->components));
if(prop_kind==ICAL_X_PROPERTY){
icalproperty_set_x_name(prop,str);
@@ -780,13 +775,13 @@ icalcomponent* icalparser_add_line(icalparser* parser,
value_kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop));
} else {
- icalcomponent* tail = pvl_data(pvl_tail(impl->components));
+ icalcomponent* tail = pvl_data(pvl_tail(parser->components));
insert_error(tail,str,"Parse error in property name",
ICAL_XLICERRORTYPE_PROPERTYPARSEERROR);
tail = 0;
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
return 0;
}
@@ -796,7 +791,6 @@ icalcomponent* icalparser_add_line(icalparser* parser,
/* Now, add any parameters to the last property */
- p = 0;
while(1) {
if (*(end-1) == ':'){
@@ -814,7 +808,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
icalparameter *param = 0;
icalparameter_kind kind;
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
+ icalcomponent *tail = pvl_data(pvl_tail(parser->components));
name = icalparser_get_param_name(str,&pvalue);
@@ -845,7 +839,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
insert_error(tail, str, "Cant parse parameter name",
ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
tail = 0;
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
return 0;
}
@@ -855,7 +849,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
tail = 0;
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
continue;
}
@@ -885,7 +879,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
icalparameter_free(param);
tail = 0;
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
return 0;
}
}
@@ -919,7 +913,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
if (vcount > 0){
/* Actually, only clone after the second value */
icalproperty* clone = icalproperty_new_clone(prop);
- icalcomponent* tail = pvl_data(pvl_tail(impl->components));
+ icalcomponent* tail = pvl_data(pvl_tail(parser->components));
icalcomponent_add_property(tail, clone);
prop = clone;
@@ -933,7 +927,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
char temp[200]; /* HACK */
icalproperty_kind prop_kind = icalproperty_isa(prop);
- icalcomponent* tail = pvl_data(pvl_tail(impl->components));
+ icalcomponent* tail = pvl_data(pvl_tail(parser->components));
sprintf(temp,"Cant parse as %s value in %s property. Removing entire property",
icalvalue_kind_to_string(value_kind),
@@ -947,7 +941,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
icalproperty_free(prop);
prop = 0;
tail = 0;
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
return 0;
} else {
@@ -961,7 +955,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
char temp[200]; /* HACK */
icalproperty_kind prop_kind = icalproperty_isa(prop);
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
+ icalcomponent *tail = pvl_data(pvl_tail(parser->components));
sprintf(temp,"No value for %s property. Removing entire property",
icalproperty_kind_to_string(prop_kind));
@@ -974,7 +968,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
icalproperty_free(prop);
prop = 0;
tail = 0;
- impl->state = ICALPARSER_ERROR;
+ parser->state = ICALPARSER_ERROR;
return 0;
} else {
@@ -987,14 +981,14 @@ icalcomponent* icalparser_add_line(icalparser* parser,
* End of component parsing.
*****************************************************************/
- if (pvl_data(pvl_tail(impl->components)) == 0 &&
- impl->level == 0){
+ if (pvl_data(pvl_tail(parser->components)) == 0 &&
+ parser->level == 0){
/* HACK. Does this clause ever get executed? */
- impl->state = ICALPARSER_SUCCESS;
+ parser->state = ICALPARSER_SUCCESS;
assert(0);
- return impl->root_component;
+ return parser->root_component;
} else {
- impl->state = ICALPARSER_IN_PROGRESS;
+ parser->state = ICALPARSER_IN_PROGRESS;
return 0;
}
@@ -1002,14 +996,12 @@ icalcomponent* icalparser_add_line(icalparser* parser,
icalparser_state icalparser_get_state(icalparser* parser)
{
- struct icalparser_impl* impl = (struct icalparser_impl*) parser;
- return impl->state;
+ return parser->state;
}
icalcomponent* icalparser_clean(icalparser* parser)
{
- struct icalparser_impl* impl = (struct icalparser_impl*) parser;
icalcomponent *tail;
icalerror_check_arg_rz((parser != 0 ),"parser");
@@ -1017,27 +1009,27 @@ icalcomponent* icalparser_clean(icalparser* parser)
/* We won't get a clean exit if some components did not have an
"END" tag. Clear off any component that may be left in the list */
- while((tail=pvl_data(pvl_tail(impl->components))) != 0){
+ while((tail=pvl_data(pvl_tail(parser->components))) != 0){
insert_error(tail," ",
"Missing END tag for this component. Closing component at end of input.",
ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
- impl->root_component = pvl_pop(impl->components);
- tail=pvl_data(pvl_tail(impl->components));
+ parser->root_component = pvl_pop(parser->components);
+ tail=pvl_data(pvl_tail(parser->components));
if(tail != 0){
- if(icalcomponent_get_parent(impl->root_component)!=0){
+ if(icalcomponent_get_parent(parser->root_component)!=0){
icalerror_warn("icalparser_clean is trying to attach a component for the second time");
} else {
- icalcomponent_add_component(tail,impl->root_component);
+ icalcomponent_add_component(tail,parser->root_component);
}
}
}
- return impl->root_component;
+ return parser->root_component;
}
@@ -1046,7 +1038,8 @@ struct slg_data {
const char* str;
};
-char* string_line_generator(char *out, size_t buf_size, void *d)
+
+char* icalparser_string_line_generator(char *out, size_t buf_size, void *d)
{
char *n;
size_t size;
@@ -1100,7 +1093,7 @@ icalcomponent* icalparser_parse_string(const char* str)
icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL);
- c = icalparser_parse(p,string_line_generator);
+ c = icalparser_parse(p,icalparser_string_line_generator);
icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);