+ struct CtdlMessage *msg = NULL;
+ struct ical_respond_data ird;
+
+ syslog(LOG_DEBUG, "calendar_report: calendar_report_backend(%ld)", msgnum);
+
+ // Look for the calendar event...
+ msg = CtdlFetchMessage(msgnum, 1);
+ if (msg == NULL) return;
+ memset(&ird, 0, sizeof ird);
+ strcpy(ird.desired_partnum, "_HUNT_");
+ mime_parser(
+ CM_RANGE(msg, eMessageText),
+ *ical_locate_part, // This callback function extracts a vcalendar item from the message.
+ NULL,
+ NULL,
+ (void *) &ird, // Give it this place to put the vcalendar object.
+ 0
+ );
+ CM_Free(msg);
+ if (ird.cal == NULL) return; // If there was no calendar item in this message, do nothing else.
+
+
+ char *ser = icalcomponent_as_ical_string_r(ird.cal);
+ if (ser) {
+ size_t len = strlen(ser);
+ client_write(ser, len);
+ if ( (len>0) && (ser[len-1] != '\n') ) {
+ syslog(LOG_DEBUG, "last char was %d", ser[len]);
+ client_write(HKEY("\n"));
+ }
+ free(ser);
+ }
+
+
+ icalcomponent_free(ird.cal); // Return the memory we got from the callback.