void component_errors(icalcomponent *comp) { int errors; icalproperty *p; /* presume that we just got this component from the parser */ errors = icalcomponent_count_errors(comp); printf("This component has %d parsing errors\n", errors); /* Print out all of the parsing errors. This is not strictly correct, because it does not descend into any sub-components, as icalcomponent_count_errors() does. */ for(p = icalcomponent_get_first_property(comp,ICAL_XLICERROR_PROPERTY); p != 0; p = icalcomponent_get_next_property(comp,ICAL_XLICERROR_PROPERTY)) { printf("-- The error is %s:\n",icalproperty_get_xlicerror(p)); } /* Check the component for iTIP compilance, and add more X-LIC-ERROR properties if it is non-compilant. */ icalrestriction_check(comp); /* Count the new errors. */ if(errors != icalcomponent_count_errors(comp)){ printf(" -- The component also has iTIP restriction errors \n"); } /* Since there are iTIP restriction errors, it may be impossible to process this component as an iTIP request. In this case, the X-LIC-ERROR proeprties should be expressed as REQUEST-STATUS properties in the reply. This following routine makes this conversion */ icalcomponent_convert_errors(comp); }
const char *get_icalcomponent_errstr(icalcomponent *ical) { icalcomponent *comp; for (comp = icalcomponent_get_first_component(ical, ICAL_ANY_COMPONENT); comp; comp = icalcomponent_get_next_component(ical, ICAL_ANY_COMPONENT)) { icalproperty *prop; for (prop = icalcomponent_get_first_property(comp, ICAL_ANY_PROPERTY); prop; prop = icalcomponent_get_next_property(comp, ICAL_ANY_PROPERTY)) { if (icalproperty_isa(prop) == ICAL_XLICERROR_PROPERTY) { const char *errstr = icalproperty_get_xlicerror(prop); char propname[256]; if (!errstr) return "Unknown iCal parsing error"; /* Check if this is an empty property error */ if (sscanf(errstr, "No value for %s property", propname) == 1) { /* Empty LOCATION is OK */ if (!strcasecmp(propname, "LOCATION")) continue; if (!strcasecmp(propname, "COMMENT")) continue; if (!strcasecmp(propname, "DESCRIPTION")) continue; } else { /* Ignore unknown property errors */ if (!strncmp(errstr, "Parse error in property name", 28)) continue; } return errstr; } } } return NULL; }