summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icalparser.c
Unidiff
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,2 +1,2 @@
1/* -*- Mode: C -*- 1/* -*- Mode: C; tab-width: 4; c-basic-offset: 8; -*-
2 ====================================================================== 2 ======================================================================
@@ -40,5 +40,3 @@
40 40
41#include "icalparser.h"
42#include "pvl.h" 41#include "pvl.h"
43#include "icalmemory.h"
44#include "icalerror.h" 42#include "icalerror.h"
@@ -54,9 +52,24 @@
54 52
55int snprintf(char *str, size_t n, char const *fmt, ...); 53#include "icalmemory.h"
54#include "icalparser.h"
55
56#ifdef HAVE_WCTYPE_H
57# include <wctype.h>
58/* Some systems have an imcomplete implementation on wctype (FreeBSD,
59 * Darwin). Cope with that. */
60# ifndef HAVE_ISWSPACE
61# define iswspace isspace
62# endif
63#else
64# ifndef HAVE_ISWSPACE
65# define iswspace isspace
66# endif
67#endif
56 68
57extern icalvalue* icalparser_yy_value; 69#ifdef WIN32
58void set_parser_value_state(icalvalue_kind kind); 70#define snprintf _snprintf
59int ical_yyparse(void); 71#define strcasecmp stricmp
72#endif
60 73
61char* icalparser_get_next_char(char c, char *str); 74char* icalparser_get_next_char(char c, char *str, int qm);
62char* icalparser_get_next_parameter(char* line,char** end); 75char* icalparser_get_next_parameter(char* line,char** end);
@@ -83,3 +96,3 @@ struct icalparser_impl
83 void *line_gen_data; 96 void *line_gen_data;
84 97
85}; 98};
@@ -102,2 +115,3 @@ icalparser* icalparser_new(void)
102 impl->buffer_full = 0; 115 impl->buffer_full = 0;
116 impl->continuation_line = 0;
103 impl->lineno = 0; 117 impl->lineno = 0;
@@ -112,10 +126,9 @@ void icalparser_free(icalparser* parser)
112{ 126{
113 struct icalparser_impl* impl = (struct icalparser_impl*)parser;
114 icalcomponent *c; 127 icalcomponent *c;
115 128
116 if (impl->root_component != 0){ 129 if (parser->root_component != 0){
117 icalcomponent_free(impl->root_component); 130 icalcomponent_free(parser->root_component);
118 } 131 }
119 132
120 while( (c=pvl_pop(impl->components)) != 0){ 133 while( (c=pvl_pop(parser->components)) != 0){
121 icalcomponent_free(c); 134 icalcomponent_free(c);
@@ -123,5 +136,5 @@ void icalparser_free(icalparser* parser)
123 136
124 pvl_free(impl->components); 137 pvl_free(parser->components);
125 138
126 free(impl); 139 free(parser);
127} 140}
@@ -130,5 +143,3 @@ void icalparser_set_gen_data(icalparser* parser, void* data)
130{ 143{
131 struct icalparser_impl* impl = (struct icalparser_impl*)parser; 144 parser->line_gen_data = data;
132
133 impl->line_gen_data = data;
134} 145}
@@ -142,3 +153,3 @@ icalvalue* icalvalue_new_From_string_with_error(icalvalue_kind kind,
142 153
143char* icalparser_get_next_char(char c, char *str) 154char* icalparser_get_next_char(char c, char *str, int qm)
144{ 155{
@@ -146,19 +157,19 @@ char* icalparser_get_next_char(char c, char *str)
146 char* p; 157 char* p;
147
148 158
149 for(p=str; *p!=0; p++){ 159 for(p=str; *p!=0; p++){
150 160 if (qm == 1) {
151 if ( quote_mode == 0 && *p=='"' && *(p-1) != '\\' ){ 161 if ( quote_mode == 0 && *p=='"' && *(p-1) != '\\' ){
152 quote_mode =1; 162 quote_mode =1;
153 continue; 163 continue;
154 } 164 }
155 165
156 if ( quote_mode == 1 && *p=='"' && *(p-1) != '\\' ){ 166 if ( quote_mode == 1 && *p=='"' && *(p-1) != '\\' ){
157 quote_mode =0; 167 quote_mode =0;
158 continue; 168 continue;
159 } 169 }
160 170 }
161 if (quote_mode == 0 && *p== c && *(p-1) != '\\' ){ 171
162 return p; 172 if (quote_mode == 0 && *p== c && *(p-1) != '\\' ){
163 } 173 return p;
174 }
164 175
@@ -169,6 +180,7 @@ char* icalparser_get_next_char(char c, char *str)
169 180
170/* make a new tmp buffer out of a substring */ 181
171char* make_segment(char* start, char* end) 182/** make a new tmp buffer out of a substring */
183static char* make_segment(char* start, char* end)
172{ 184{
173 char *buf; 185 char *buf, *tmp;
174 size_t size = (size_t)end - (size_t)start; 186 size_t size = (size_t)end - (size_t)start;
@@ -180,60 +192,13 @@ char* make_segment(char* start, char* end)
180 *(buf+size) = 0; 192 *(buf+size) = 0;
193
194 tmp = (buf+size);
195 while ( *tmp == '\0' || iswspace(*tmp) )
196 {
197 *tmp = 0;
198 tmp--;
199 }
181 200
182 return buf; 201 return buf;
183
184} 202}
185 203
186const char* input_buffer;
187const char* input_buffer_p;
188//#define min(a,b) ((a) < (b) ? (a) : (b))
189
190int icalparser_flex_input(char* buf, int max_size)
191{
192 int n = max_size; // = min(max_size,strlen(input_buffer_p));
193 if ( n < ((int )strlen(input_buffer_p)) )
194 n = strlen(input_buffer_p);
195 if (n > 0){
196 memcpy(buf, input_buffer_p, n);
197 input_buffer_p += n;
198 return n;
199 } else {
200 return 0;
201 }
202}
203
204void icalparser_clear_flex_input(void)
205{
206 input_buffer_p = input_buffer+strlen(input_buffer);
207}
208
209/* Call the flex/bison parser to parse a complex value */
210
211icalvalue* icalparser_parse_value(icalvalue_kind kind,
212 const char* str, icalproperty** error)
213{
214 int r;
215 input_buffer_p = input_buffer = str;
216
217 set_parser_value_state(kind);
218 icalparser_yy_value = 0;
219
220 r = ical_yyparse();
221
222 /* Error. Parse failed */
223 if( icalparser_yy_value == 0 || r != 0){
224
225 if(icalparser_yy_value !=0){
226 icalvalue_free(icalparser_yy_value);
227 icalparser_yy_value = 0;
228 }
229
230 return 0;
231 }
232
233 if (error != 0){
234 *error = 0;
235 }
236
237 return icalparser_yy_value;
238}
239 204
@@ -245,4 +210,4 @@ char* icalparser_get_prop_name(char* line, char** end)
245 210
246 p = icalparser_get_next_char(';',line); 211 p = icalparser_get_next_char(';',line,1);
247 v = icalparser_get_next_char(':',line); 212 v = icalparser_get_next_char(':',line,1);
248 if (p== 0 && v == 0) { 213 if (p== 0 && v == 0) {
@@ -264,5 +229,5 @@ char* icalparser_get_prop_name(char* line, char** end)
264 229
230
265char* icalparser_get_param_name(char* line, char **end) 231char* icalparser_get_param_name(char* line, char **end)
266{ 232{
267
268 char* next; 233 char* next;
@@ -270,3 +235,3 @@ char* icalparser_get_param_name(char* line, char **end)
270 235
271 next = icalparser_get_next_char('=',line); 236 next = icalparser_get_next_char('=',line,1);
272 237
@@ -278,9 +243,18 @@ char* icalparser_get_param_name(char* line, char **end)
278 *end = next+1; 243 *end = next+1;
244 if (**end == '"') {
245 *end = *end+1;
246 next = icalparser_get_next_char('"',*end,0);
247 if (next == 0) {
248 return 0;
249 }
250
251 *end = make_segment(*end,next);
252 }
253
279 return str; 254 return str;
280
281} 255}
282 256
257
283char* icalparser_get_next_paramvalue(char* line, char **end) 258char* icalparser_get_next_paramvalue(char* line, char **end)
284{ 259{
285
286 char* next; 260 char* next;
@@ -288,3 +262,3 @@ char* icalparser_get_next_paramvalue(char* line, char **end)
288 262
289 next = icalparser_get_next_char(',',line); 263 next = icalparser_get_next_char(',',line,1);
290 264
@@ -301,6 +275,7 @@ char* icalparser_get_next_paramvalue(char* line, char **end)
301 } 275 }
302
303} 276}
304 277
305/* A property may have multiple values, if the values are seperated by 278
279/**
280 A property may have multiple values, if the values are seperated by
306 commas in the content line. This routine will look for the next 281 commas in the content line. This routine will look for the next
@@ -320,3 +295,3 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
320 295
321 next = icalparser_get_next_char(',',p); 296 next = icalparser_get_next_char(',',p,1);
322 297
@@ -342,2 +317,11 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
342 } 317 }
318 /* ignore all , for query value. select dtstart, dtend etc ... */
319 else if( kind == ICAL_QUERY_VALUE) {
320 if ( next != 0) {
321 p = next+1;
322 continue;
323 }
324 else
325 break;
326 }
343 327
@@ -381,4 +365,4 @@ char* icalparser_get_next_parameter(char* line,char** end)
381 365
382 v = icalparser_get_next_char(':',line); 366 v = icalparser_get_next_char(':',line,1);
383 next = icalparser_get_next_char(';', line); 367 next = icalparser_get_next_char(';', line,1);
384 368
@@ -388,3 +372,3 @@ char* icalparser_get_next_parameter(char* line,char** end)
388 if (next == 0 || next > v) { 372 if (next == 0 || next > v) {
389 next = icalparser_get_next_char(':', line); 373 next = icalparser_get_next_char(':', line,1);
390 } 374 }
@@ -401,5 +385,7 @@ char* icalparser_get_next_parameter(char* line,char** end)
401 385
402/* Get a single property line, from the property name through the
403 final new line, and include any continuation lines */
404 386
387/**
388 * Get a single property line, from the property name through the
389 * final new line, and include any continuation lines
390 */
405char* icalparser_get_line(icalparser *parser, 391char* icalparser_get_line(icalparser *parser,
@@ -409,5 +395,3 @@ char* icalparser_get_line(icalparser *parser,
409 char *line_p; 395 char *line_p;
410 struct icalparser_impl* impl = (struct icalparser_impl*)parser; 396 size_t buf_size = parser->tmp_buf_size;
411 size_t buf_size = impl->tmp_buf_size;
412
413 397
@@ -417,3 +401,3 @@ char* icalparser_get_line(icalparser *parser,
417 /* Read lines by calling line_gen_func and putting the data into 401 /* Read lines by calling line_gen_func and putting the data into
418 impl->temp. If the line is a continuation line ( begins with a 402 parser->temp. If the line is a continuation line ( begins with a
419 space after a newline ) then append the data onto line and read 403 space after a newline ) then append the data onto line and read
@@ -431,3 +415,3 @@ char* icalparser_get_line(icalparser *parser,
431 output. This may be left over from a previous call */ 415 output. This may be left over from a previous call */
432 if (impl->temp[0] != '\0' ) { 416 if (parser->temp[0] != '\0' ) {
433 417
@@ -436,8 +420,8 @@ char* icalparser_get_line(icalparser *parser,
436 read later, because the line is not finished */ 420 read later, because the line is not finished */
437 if (impl->temp[impl->tmp_buf_size-1] == 0 && 421 if (parser->temp[parser->tmp_buf_size-1] == 0 &&
438 impl->temp[impl->tmp_buf_size-2] != '\n'&& 422 parser->temp[parser->tmp_buf_size-2] != '\n'&&
439 impl->temp[impl->tmp_buf_size-2] != 0 ){ 423 parser->temp[parser->tmp_buf_size-2] != 0 ){
440 impl->buffer_full = 1; 424 parser->buffer_full = 1;
441 } else { 425 } else {
442 impl->buffer_full = 0; 426 parser->buffer_full = 0;
443 } 427 }
@@ -445,5 +429,5 @@ char* icalparser_get_line(icalparser *parser,
445 /* Copy the temp to the output and clear the temp buffer. */ 429 /* Copy the temp to the output and clear the temp buffer. */
446 if(impl->continuation_line==1){ 430 if(parser->continuation_line==1){
447 /* back up the pointer to erase the continuation characters */ 431 /* back up the pointer to erase the continuation characters */
448 impl->continuation_line = 0; 432 parser->continuation_line = 0;
449 line_p--; 433 line_p--;
@@ -456,15 +440,15 @@ char* icalparser_get_line(icalparser *parser,
456 icalmemory_append_string(&line,&line_p,&buf_size, 440 icalmemory_append_string(&line,&line_p,&buf_size,
457 impl->temp+1); 441 parser->temp+1);
458 442
459 } else { 443 } else {
460 icalmemory_append_string(&line,&line_p,&buf_size,impl->temp); 444 icalmemory_append_string(&line,&line_p,&buf_size,parser->temp);
461 } 445 }
462 446
463 impl->temp[0] = '\0' ; 447 parser->temp[0] = '\0' ;
464 } 448 }
465 449
466 impl->temp[impl->tmp_buf_size-1] = 1; /* Mark end of buffer */ 450 parser->temp[parser->tmp_buf_size-1] = 1; /* Mark end of buffer */
467 451
468 /****** Here is where the routine gets string data ******************/ 452 /****** Here is where the routine gets string data ******************/
469 if ((*line_gen_func)(impl->temp,impl->tmp_buf_size,impl->line_gen_data) 453 if ((*line_gen_func)(parser->temp,parser->tmp_buf_size,parser->line_gen_data)
470 ==0){/* Get more data */ 454 ==0){/* Get more data */
@@ -473,3 +457,3 @@ char* icalparser_get_line(icalparser *parser,
473 any more data from the last call to line_ge_func*/ 457 any more data from the last call to line_ge_func*/
474 if (impl->temp[0] == '\0'){ 458 if (parser->temp[0] == '\0'){
475 459
@@ -492,8 +476,7 @@ char* icalparser_get_line(icalparser *parser,
492 476
493 if ( line_p > line+1 && *(line_p-1) == '\n' 477 if ( line_p > line+1 && *(line_p-1) == '\n' && parser->temp[0] == ' ') {
494 && (impl->temp[0] == ' ' || impl->temp[0] == '\t') ) {
495 478
496 impl->continuation_line = 1; 479 parser->continuation_line = 1;
497 480
498 } else if ( impl->buffer_full == 1 ) { 481 } else if ( parser->buffer_full == 1 ) {
499 482
@@ -521,2 +504,8 @@ char* icalparser_get_line(icalparser *parser,
521 504
505 while ( (*line_p == '\0' || iswspace(*line_p)) && line_p > line )
506 {
507 *line_p = '\0';
508 line_p--;
509 }
510
522 return line; 511 return line;
@@ -525,3 +514,3 @@ char* icalparser_get_line(icalparser *parser,
525 514
526void insert_error(icalcomponent* comp, char* text, 515static void insert_error(icalcomponent* comp, char* text,
527 char* message, icalparameter_xlicerrortype type) 516 char* message, icalparameter_xlicerrortype type)
@@ -544,3 +533,4 @@ void insert_error(icalcomponent* comp, char* text,
544 533
545int line_is_blank(char* line){ 534
535static int line_is_blank(char* line){
546 int i=0; 536 int i=0;
@@ -566,4 +556,4 @@ icalcomponent* icalparser_parse(icalparser *parser,
566 icalcomponent *root=0; 556 icalcomponent *root=0;
567 struct icalparser_impl *impl = (struct icalparser_impl*)parser;
568 icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); 557 icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR);
558 int cont;
569 559
@@ -582,4 +572,4 @@ icalcomponent* icalparser_parse(icalparser *parser,
582 572
583 assert(impl->root_component == 0); 573 assert(parser->root_component == 0);
584 assert(pvl_count(impl->components) ==0); 574 assert(pvl_count(parser->components) ==0);
585 575
@@ -608,6 +598,8 @@ icalcomponent* icalparser_parse(icalparser *parser,
608 } 598 }
599 cont = 0;
609 if(line != 0){ 600 if(line != 0){
610 free(line); 601 free(line);
602 cont = 1;
611 } 603 }
612 } while ( line != 0); 604 } while ( cont );
613 605
@@ -623,3 +615,2 @@ icalcomponent* icalparser_add_line(icalparser* parser,
623{ 615{
624 char *p;
625 char *str; 616 char *str;
@@ -633,3 +624,2 @@ icalcomponent* icalparser_add_line(icalparser* parser,
633 624
634 struct icalparser_impl *impl = (struct icalparser_impl*)parser;
635 icalerror_check_arg_rz((parser != 0),"parser"); 625 icalerror_check_arg_rz((parser != 0),"parser");
@@ -639,3 +629,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
639 { 629 {
640 impl->state = ICALPARSER_ERROR; 630 parser->state = ICALPARSER_ERROR;
641 return 0; 631 return 0;
@@ -657,3 +647,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
657 /* Could not get a property name */ 647 /* Could not get a property name */
658 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 648 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
659 649
@@ -665,3 +655,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
665 tail = 0; 655 tail = 0;
666 impl->state = ICALPARSER_ERROR; 656 parser->state = ICALPARSER_ERROR;
667 return 0; 657 return 0;
@@ -675,2 +665,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
675 665
666
676 if(strcmp(str,"BEGIN") == 0){ 667 if(strcmp(str,"BEGIN") == 0){
@@ -679,3 +670,4 @@ icalcomponent* icalparser_add_line(icalparser* parser,
679 670
680 impl->level++; 671
672 parser->level++;
681 str = icalparser_get_next_value(end,&end, value_kind); 673 str = icalparser_get_next_value(end,&end, value_kind);
@@ -685,3 +677,6 @@ icalcomponent* icalparser_add_line(icalparser* parser,
685 677
678
686 if (comp_kind == ICAL_NO_COMPONENT){ 679 if (comp_kind == ICAL_NO_COMPONENT){
680
681
687 c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT); 682 c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);
@@ -699,5 +694,5 @@ icalcomponent* icalparser_add_line(icalparser* parser,
699 694
700 pvl_push(impl->components,c); 695 pvl_push(parser->components,c);
701 696
702 impl->state = ICALPARSER_BEGIN_COMP; 697 parser->state = ICALPARSER_BEGIN_COMP;
703 return 0; 698 return 0;
@@ -707,3 +702,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
707 702
708 impl->level--; 703 parser->level--;
709 str = icalparser_get_next_value(end,&end, value_kind); 704 str = icalparser_get_next_value(end,&end, value_kind);
@@ -711,8 +706,8 @@ icalcomponent* icalparser_add_line(icalparser* parser,
711 /* Pop last component off of list and add it to the second-to-last*/ 706 /* Pop last component off of list and add it to the second-to-last*/
712 impl->root_component = pvl_pop(impl->components); 707 parser->root_component = pvl_pop(parser->components);
713 708
714 tail = pvl_data(pvl_tail(impl->components)); 709 tail = pvl_data(pvl_tail(parser->components));
715 710
716 if(tail != 0){ 711 if(tail != 0){
717 icalcomponent_add_component(tail,impl->root_component); 712 icalcomponent_add_component(tail,parser->root_component);
718 } 713 }
@@ -722,17 +717,17 @@ icalcomponent* icalparser_add_line(icalparser* parser,
722 /* Return the component if we are back to the 0th level */ 717 /* Return the component if we are back to the 0th level */
723 if (impl->level == 0){ 718 if (parser->level == 0){
724 icalcomponent *rtrn; 719 icalcomponent *rtrn;
725 720
726 if(pvl_count(impl->components) != 0){ 721 if(pvl_count(parser->components) != 0){
727 /* There are still components on the stack -- this means 722 /* There are still components on the stack -- this means
728 that one of them did not have a proper "END" */ 723 that one of them did not have a proper "END" */
729 pvl_push(impl->components,impl->root_component); 724 pvl_push(parser->components,parser->root_component);
730 icalparser_clean(parser); /* may reset impl->root_component*/ 725 icalparser_clean(parser); /* may reset parser->root_component*/
731 } 726 }
732 727
733 assert(pvl_count(impl->components) == 0); 728 assert(pvl_count(parser->components) == 0);
734 729
735 impl->state = ICALPARSER_SUCCESS; 730 parser->state = ICALPARSER_SUCCESS;
736 rtrn = impl->root_component; 731 rtrn = parser->root_component;
737 impl->root_component = 0; 732 parser->root_component = 0;
738 return rtrn; 733 return rtrn;
@@ -740,3 +735,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
740 } else { 735 } else {
741 impl->state = ICALPARSER_END_COMP; 736 parser->state = ICALPARSER_END_COMP;
742 return 0; 737 return 0;
@@ -749,4 +744,4 @@ icalcomponent* icalparser_add_line(icalparser* parser,
749 744
750 if(pvl_data(pvl_tail(impl->components)) == 0){ 745 if(pvl_data(pvl_tail(parser->components)) == 0){
751 impl->state = ICALPARSER_ERROR; 746 parser->state = ICALPARSER_ERROR;
752 return 0; 747 return 0;
@@ -769,3 +764,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
769 if (prop != 0){ 764 if (prop != 0){
770 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 765 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
771 766
@@ -782,3 +777,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
782 } else { 777 } else {
783 icalcomponent* tail = pvl_data(pvl_tail(impl->components)); 778 icalcomponent* tail = pvl_data(pvl_tail(parser->components));
784 779
@@ -788,3 +783,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
788 tail = 0; 783 tail = 0;
789 impl->state = ICALPARSER_ERROR; 784 parser->state = ICALPARSER_ERROR;
790 return 0; 785 return 0;
@@ -798,3 +793,2 @@ icalcomponent* icalparser_add_line(icalparser* parser,
798 793
799 p = 0;
800 while(1) { 794 while(1) {
@@ -816,3 +810,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
816 icalparameter_kind kind; 810 icalparameter_kind kind;
817 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 811 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
818 812
@@ -847,3 +841,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
847 tail = 0; 841 tail = 0;
848 impl->state = ICALPARSER_ERROR; 842 parser->state = ICALPARSER_ERROR;
849 return 0; 843 return 0;
@@ -857,3 +851,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
857 tail = 0; 851 tail = 0;
858 impl->state = ICALPARSER_ERROR; 852 parser->state = ICALPARSER_ERROR;
859 continue; 853 continue;
@@ -887,3 +881,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
887 tail = 0; 881 tail = 0;
888 impl->state = ICALPARSER_ERROR; 882 parser->state = ICALPARSER_ERROR;
889 return 0; 883 return 0;
@@ -921,3 +915,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
921 icalproperty* clone = icalproperty_new_clone(prop); 915 icalproperty* clone = icalproperty_new_clone(prop);
922 icalcomponent* tail = pvl_data(pvl_tail(impl->components)); 916 icalcomponent* tail = pvl_data(pvl_tail(parser->components));
923 917
@@ -935,3 +929,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
935 icalproperty_kind prop_kind = icalproperty_isa(prop); 929 icalproperty_kind prop_kind = icalproperty_isa(prop);
936 icalcomponent* tail = pvl_data(pvl_tail(impl->components)); 930 icalcomponent* tail = pvl_data(pvl_tail(parser->components));
937 931
@@ -949,3 +943,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
949 tail = 0; 943 tail = 0;
950 impl->state = ICALPARSER_ERROR; 944 parser->state = ICALPARSER_ERROR;
951 return 0; 945 return 0;
@@ -963,3 +957,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
963 icalproperty_kind prop_kind = icalproperty_isa(prop); 957 icalproperty_kind prop_kind = icalproperty_isa(prop);
964 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 958 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
965 959
@@ -976,3 +970,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
976 tail = 0; 970 tail = 0;
977 impl->state = ICALPARSER_ERROR; 971 parser->state = ICALPARSER_ERROR;
978 return 0; 972 return 0;
@@ -989,10 +983,10 @@ icalcomponent* icalparser_add_line(icalparser* parser,
989 983
990 if (pvl_data(pvl_tail(impl->components)) == 0 && 984 if (pvl_data(pvl_tail(parser->components)) == 0 &&
991 impl->level == 0){ 985 parser->level == 0){
992 /* HACK. Does this clause ever get executed? */ 986 /* HACK. Does this clause ever get executed? */
993 impl->state = ICALPARSER_SUCCESS; 987 parser->state = ICALPARSER_SUCCESS;
994 assert(0); 988 assert(0);
995 return impl->root_component; 989 return parser->root_component;
996 } else { 990 } else {
997 impl->state = ICALPARSER_IN_PROGRESS; 991 parser->state = ICALPARSER_IN_PROGRESS;
998 return 0; 992 return 0;
@@ -1004,4 +998,3 @@ icalparser_state icalparser_get_state(icalparser* parser)
1004{ 998{
1005 struct icalparser_impl* impl = (struct icalparser_impl*) parser; 999 return parser->state;
1006 return impl->state;
1007 1000
@@ -1011,3 +1004,2 @@ icalcomponent* icalparser_clean(icalparser* parser)
1011{ 1004{
1012 struct icalparser_impl* impl = (struct icalparser_impl*) parser;
1013 icalcomponent *tail; 1005 icalcomponent *tail;
@@ -1019,3 +1011,3 @@ icalcomponent* icalparser_clean(icalparser* parser)
1019 1011
1020 while((tail=pvl_data(pvl_tail(impl->components))) != 0){ 1012 while((tail=pvl_data(pvl_tail(parser->components))) != 0){
1021 1013
@@ -1026,10 +1018,10 @@ icalcomponent* icalparser_clean(icalparser* parser)
1026 1018
1027 impl->root_component = pvl_pop(impl->components); 1019 parser->root_component = pvl_pop(parser->components);
1028 tail=pvl_data(pvl_tail(impl->components)); 1020 tail=pvl_data(pvl_tail(parser->components));
1029 1021
1030 if(tail != 0){ 1022 if(tail != 0){
1031 if(icalcomponent_get_parent(impl->root_component)!=0){ 1023 if(icalcomponent_get_parent(parser->root_component)!=0){
1032 icalerror_warn("icalparser_clean is trying to attach a component for the second time"); 1024 icalerror_warn("icalparser_clean is trying to attach a component for the second time");
1033 } else { 1025 } else {
1034 icalcomponent_add_component(tail,impl->root_component); 1026 icalcomponent_add_component(tail,parser->root_component);
1035 } 1027 }
@@ -1039,3 +1031,3 @@ icalcomponent* icalparser_clean(icalparser* parser)
1039 1031
1040 return impl->root_component; 1032 return parser->root_component;
1041 1033
@@ -1048,3 +1040,4 @@ struct slg_data {
1048 1040
1049char* string_line_generator(char *out, size_t buf_size, void *d) 1041
1042char* icalparser_string_line_generator(char *out, size_t buf_size, void *d)
1050{ 1043{
@@ -1102,3 +1095,3 @@ icalcomponent* icalparser_parse_string(const char* str)
1102 1095
1103 c = icalparser_parse(p,string_line_generator); 1096 c = icalparser_parse(p,icalparser_string_line_generator);
1104 1097