
#include <ical.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>

int main(int argC, char* argV[])
{
    icalproperty * myIcalProp = NULL;

    char defaultTest[] = 
            "ATTENDEE;RSVP=TRUE;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RECEIVED-SEQUENCE=6;RECEIVED-DTSTAMP=20091102T102902Z:mailto:fred@example.com";
    char * testString = defaultTest;

    if (argC > 1)
        testString = argV[1];

    printf("Original Property:\n%s\n", testString);

    myIcalProp = icalproperty_new_from_string(testString);
    printf("Round Tripped Property (no special config calls) :\n%s\n", icalproperty_as_ical_string(myIcalProp));

#ifdef LIBICAL_UNKNOWN_HANDLING
    ical_set_unknown_token_handling_setting(ICAL_ASSUME_IANA_TOKEN);
    myIcalProp = icalproperty_new_from_string(testString);
    printf("Round Tripped Property (unknown_token_handling = ICAL_ASSUME_IANA_TOKEN) :\n%s\n", icalproperty_as_ical_string(myIcalProp));

    ical_set_unknown_token_handling_setting(ICAL_DISCARD_TOKEN);
    myIcalProp = icalproperty_new_from_string(testString);
    printf("Round Tripped Property (unknown_token_handling = ICAL_DISCARD_TOKEN) :\n%s\n", icalproperty_as_ical_string(myIcalProp));

    ical_set_unknown_token_handling_setting(ICAL_TREAT_AS_ERROR);
    myIcalProp = icalproperty_new_from_string(testString);
    printf("Round Tripped Property (unknown_token_handling = ICAL_TREAT_AS_ERROR) :\n%s\n", icalproperty_as_ical_string(myIcalProp));
#endif /* LIBICAL_UNKNOWN_HANDLING */

    exit(0);
}

