serv_calendar.c: basically reformatting for modern standards
authorArt Cancro <ajc@citadel.org>
Thu, 4 Jan 2024 22:44:14 +0000 (17:44 -0500)
committerArt Cancro <ajc@citadel.org>
Thu, 4 Jan 2024 22:44:14 +0000 (17:44 -0500)
When I wrote this stuff I had a 109 column screen.  Now our standard
is 132 columns.  Also we are seeking and destroying any place where
spaces were used as indentation.  Our code is indented with tabs, the
way God intended.

citadel/server/modules/calendar/serv_calendar.c

index 35bc404eabe4301b638d34c0bc28796b88962cef..643212968f3976a3d02e5296eafbd39e87edaecc 100644 (file)
@@ -181,9 +181,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                // Hunt for attendees, removing ones that aren't us.
                // (Actually, remove them all, cloning our own one so we can
                // re-insert it later)
-               while (attendee = icalcomponent_get_first_property(vevent,
-                   ICAL_ATTENDEE_PROPERTY), (attendee != NULL)
-               ) {
+               while (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY), (attendee != NULL)) {
                        ch = icalproperty_get_attendee(attendee);
                        if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
                                safestrncpy(attendee_string, ch + 7, sizeof (attendee_string));
@@ -307,8 +305,9 @@ void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
                }
        }
 
-       if (  (strcasecmp(cbtype, "text/calendar"))
-          && (strcasecmp(cbtype, "application/ics")) ) {
+       if (    (strcasecmp(cbtype, "text/calendar"))
+               && (strcasecmp(cbtype, "application/ics"))
+       ) {
                return;
        }
 
@@ -327,8 +326,8 @@ void ical_respond(long msgnum, char *partnum, char *action) {
        struct ical_respond_data ird;
 
        if (
-          (strcasecmp(action, "accept"))
-          && (strcasecmp(action, "decline"))
+               (strcasecmp(action, "accept"))
+               && (strcasecmp(action, "decline"))
        ) {
                cprintf("%d Action must be 'accept' or 'decline'\n", ERROR + ILLEGAL_VALUE);
                return;
@@ -384,15 +383,13 @@ void ical_respond(long msgnum, char *partnum, char *action) {
 }
 
 
-/*
- * Figure out the UID of the calendar event being referred to in a
- * REPLY object.  This function is recursive.
- */
+// Figure out the UID of the calendar event being referred to in a
+// REPLY object.  This function is recursive.
 void ical_learn_uid_of_reply(char *uidbuf, icalcomponent *cal) {
        icalcomponent *subcomponent;
        icalproperty *p;
 
-       /* If this object is a REPLY, then extract the UID. */
+       // If this object is a REPLY, then extract the UID.
        if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
                p = icalcomponent_get_first_property(cal, ICAL_UID_PROPERTY);
                if (p != NULL) {
@@ -400,22 +397,20 @@ void ical_learn_uid_of_reply(char *uidbuf, icalcomponent *cal) {
                }
        }
 
-       /* Otherwise, recurse through any VEVENT subcomponents.  We do NOT want the
-        * UID of the reply; we want the UID of the invitation being replied to.
-        */
+       // Otherwise, recurse through any VEVENT subcomponents.  We do NOT want the
+       // UID of the reply; we want the UID of the invitation being replied to.
        for (subcomponent = icalcomponent_get_first_component(cal, ICAL_VEVENT_COMPONENT);
-           subcomponent != NULL;
-           subcomponent = icalcomponent_get_next_component(cal, ICAL_VEVENT_COMPONENT) ) {
+               subcomponent != NULL;
+               subcomponent = icalcomponent_get_next_component(cal, ICAL_VEVENT_COMPONENT)
+       ) {
                ical_learn_uid_of_reply(uidbuf, subcomponent);
        }
 }
 
 
-/*
- * ical_update_my_calendar_with_reply() refers to this callback function; when we
- * locate the message containing the calendar event we're replying to, this function
- * gets called.  It basically just sticks the message number in a supplied buffer.
- */
+// ical_update_my_calendar_with_reply() refers to this callback function; when we
+// locate the message containing the calendar event we're replying to, this function
+// gets called.  It basically just sticks the message number in a supplied buffer.
 void ical_hunt_for_event_to_update(long msgnum, void *data) {
        long *msgnumptr;
 
@@ -428,19 +423,18 @@ struct original_event_container {
        icalcomponent *c;
 };
 
-/*
- * Callback function for mime parser that hunts for calendar content types
- * and turns them into calendar objects (called by ical_update_my_calendar_with_reply()
- * to fetch the object being updated)
- */
+// Callback function for mime parser that hunts for calendar content types
+// and turns them into calendar objects (called by ical_update_my_calendar_with_reply()
+// to fetch the object being updated)
 void ical_locate_original_event(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
                char *cbid, void *cbuserdata) {
 
        struct original_event_container *oec = NULL;
 
-       if (  (strcasecmp(cbtype, "text/calendar"))
-          && (strcasecmp(cbtype, "application/ics")) ) {
+       if (    (strcasecmp(cbtype, "text/calendar"))
+               && (strcasecmp(cbtype, "application/ics"))
+       ) {
                return;
        }
        oec = (struct original_event_container *) cbuserdata;
@@ -451,16 +445,13 @@ void ical_locate_original_event(char *name, char *filename, char *partnum, char
 }
 
 
-/*
- * Merge updated attendee information from a REPLY into an existing event.
- */
+// Merge updated attendee information from a REPLY into an existing event.
 void ical_merge_attendee_reply(icalcomponent *event, icalcomponent *reply) {
        icalcomponent *c;
        icalproperty *e_attendee, *r_attendee;
 
-       /* First things first.  If we're not looking at a VEVENT component,
-        * recurse through subcomponents until we find one.
-        */
+       // First things first.  If we're not looking at a VEVENT component,
+       // recurse through subcomponents until we find one.
        if (icalcomponent_isa(event) != ICAL_VEVENT_COMPONENT) {
                for (c = icalcomponent_get_first_component(event, ICAL_VEVENT_COMPONENT);
                    c != NULL;
@@ -470,8 +461,7 @@ void ical_merge_attendee_reply(icalcomponent *event, icalcomponent *reply) {
                return;
        }
 
-       /* Now do the same thing with the reply.
-        */
+       // Now do the same thing with the reply.
        if (icalcomponent_isa(reply) != ICAL_VEVENT_COMPONENT) {
                for (c = icalcomponent_get_first_component(reply, ICAL_VEVENT_COMPONENT);
                    c != NULL;
@@ -481,12 +471,11 @@ void ical_merge_attendee_reply(icalcomponent *event, icalcomponent *reply) {
                return;
        }
 
-       /* Clone the reply, because we're going to rip its guts out. */
+       // Clone the reply, because we're going to rip its guts out.
        reply = icalcomponent_new_clone(reply);
 
-       /* At this point we're looking at the correct subcomponents.
-        * Iterate through the attendees looking for a match.
-        */
+       // At this point we're looking at the correct subcomponents.
+       // Iterate through the attendees looking for a match.
 STARTOVER:
        for (e_attendee = icalcomponent_get_first_property(event, ICAL_ATTENDEE_PROPERTY);
            e_attendee != NULL;
@@ -496,8 +485,7 @@ STARTOVER:
                    r_attendee != NULL;
                    r_attendee = icalcomponent_get_next_property(reply, ICAL_ATTENDEE_PROPERTY)) {
 
-                       /* Check to see if these two attendees match...
-                        */
+                       // Check to see if these two attendees match...
                        const char *e, *r;
                        e = icalproperty_get_attendee(e_attendee);
                        r = icalproperty_get_attendee(r_attendee);
@@ -505,42 +493,38 @@ STARTOVER:
                        if ((e != NULL) && 
                            (r != NULL) && 
                            !strcasecmp(e, r)) {
-                               /* ...and if they do, remove the attendee from the event
-                                * and replace it with the attendee from the reply.  (The
-                                * reply's copy will have the same address, but an updated
-                                * status.)
-                                */
+                               // ...and if they do, remove the attendee from the event
+                               // and replace it with the attendee from the reply.  (The
+                               // reply's copy will have the same address, but an updated
+                               // status.)
                                icalcomponent_remove_property(event, e_attendee);
                                icalproperty_free(e_attendee);
                                icalcomponent_remove_property(reply, r_attendee);
                                icalcomponent_add_property(event, r_attendee);
 
-                               /* Since we diddled both sets of attendees, we have to start
-                                * the iteration over again.  This will not create an infinite
-                                * loop because we removed the attendee from the reply.  (That's
-                                * why we cloned the reply, and that's what we mean by "ripping
-                                * its guts out.")
-                                */
+                               // Since we diddled both sets of attendees, we have to start
+                               // the iteration over again.  This will not create an infinite
+                               // loop because we removed the attendee from the reply.  (That's
+                               // why we cloned the reply, and that's what we mean by "ripping
+                               // its guts out.")
                                goto STARTOVER;
                        }
        
                }
        }
 
-       /* Free the *clone* of the reply. */
+       // Free the *clone* of the reply.
        icalcomponent_free(reply);
 }
 
 
-/*
- * Handle an incoming RSVP (object with method==ICAL_METHOD_REPLY) for a
- * calendar event.  The object has already been deserialized for us; all
- * we have to do here is hunt for the event in our calendar, merge in the
- * updated attendee status, and save it again.
- *
- * This function returns 0 on success, 1 if the event was not found in the
- * user's calendar, or 2 if an internal error occurred.
- */
+// Handle an incoming RSVP (object with method==ICAL_METHOD_REPLY) for a
+// calendar event.  The object has already been deserialized for us; all
+// we have to do here is hunt for the event in our calendar, merge in the
+// updated attendee status, and save it again.
+//
+// This function returns 0 on success, 1 if the event was not found in the
+// user's calendar, or 2 if an internal error occurred.
 int ical_update_my_calendar_with_reply(icalcomponent *cal) {
        char uid[SIZ];
        char hold_rm[ROOMNAMELEN];
@@ -552,12 +536,12 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
        char roomname[ROOMNAMELEN];
        char *message_text = NULL;
 
-       /* Figure out just what event it is we're dealing with */
+       // Figure out just what event it is we're dealing with
        strcpy(uid, "--==<< InVaLiD uId >>==--");
        ical_learn_uid_of_reply(uid, cal);
        syslog(LOG_DEBUG, "calendar: UID of event being replied to is <%s>", uid);
 
-       strcpy(hold_rm, CC->room.QRname);       /* save current room */
+       strcpy(hold_rm, CC->room.QRname);       // save current room
 
        if (CtdlGetRoom(&CC->room, USERCALENDARROOM) != 0) {
                CtdlGetRoom(&CC->room, hold_rm);
@@ -565,37 +549,34 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
                return(2);
        }
 
-       /*
-        * Look in the EUID index for a message with
-        * the Citadel EUID set to the value we're looking for.  Since
-        * Citadel always sets the message EUID to the iCalendar UID of
-        * the event, this will work.
-        */
+       // Look in the EUID index for a message with
+       // the Citadel EUID set to the value we're looking for.  Since
+       // Citadel always sets the message EUID to the iCalendar UID of
+       // the event, this will work.
        msgnum_being_replaced = CtdlLocateMessageByEuid(uid, &CC->room);
 
-       CtdlGetRoom(&CC->room, hold_rm);        /* return to saved room */
+       CtdlGetRoom(&CC->room, hold_rm);        // return to saved room
 
        syslog(LOG_DEBUG, "calendar: msgnum_being_replaced == %ld", msgnum_being_replaced);
        if (msgnum_being_replaced == 0) {
-               return(1);                      /* no calendar event found */
+               return(1);                      // no calendar event found
        }
 
-       /* Now we know the ID of the message containing the event being updated.
-        * We don't actually have to delete it; that'll get taken care of by the
-        * server when we save another event with the same UID.  This just gives
-        * us the ability to load the event into memory so we can diddle the
-        * attendees.
-        */
+       // Now we know the ID of the message containing the event being updated.
+       // We don't actually have to delete it; that'll get taken care of by the
+       // server when we save another event with the same UID.  This just gives
+       // us the ability to load the event into memory so we can diddle the attendees.
        msg = CtdlFetchMessage(msgnum_being_replaced, 1);
        if (msg == NULL) {
-               return(2);                      /* internal error */
+               return(2);                      // internal error
        }
        oec.c = NULL;
-       mime_parser(CM_RANGE(msg, eMesageText),
-                   *ical_locate_original_event,        /* callback function */
-                   NULL, NULL,
-                   &oec,                               /* user data */
-                   0
+       mime_parser(
+               CM_RANGE(msg, eMesageText),
+               *ical_locate_original_event,    // callback function
+               NULL, NULL,
+               &oec,                           // user data
+               0
        );
        CM_Free(msg);
 
@@ -605,12 +586,12 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
                return(2);
        }
 
-       /* Merge the attendee's updated status into the event */
+       // Merge the attendee's updated status into the event
        ical_merge_attendee_reply(original_event, cal);
 
-       /* Serialize it */
+       // Serialize it
        serialized_event = icalcomponent_as_ical_string_r(original_event);
-       icalcomponent_free(original_event);     /* Don't need this anymore. */
+       icalcomponent_free(original_event);     // Don't need this anymore.
        if (serialized_event == NULL) return(2);
 
        CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);
@@ -623,16 +604,18 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
                );
 
                msg = CtdlMakeMessage(&CC->user,
-                       "",                     /* No recipient */
-                       "",                     /* No recipient */
+                       "",                     // No recipient
+                       "",                     // No recipient
                        roomname,
-                       0, FMT_RFC822,
+                       0,
+                       FMT_RFC822,
                        "",
                        "",
-                       "",             /* no subject */
+                       "",                     // no subject
                        NULL,
                        message_text,
-                       NULL);
+                       NULL
+               );
        
                if (msg != NULL) {
                        CIT_ICAL->avoid_sending_invitations = 1;
@@ -646,23 +629,19 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
 }
 
 
-/*
- * Handle an incoming RSVP for an event.  (This is the server subcommand part; it
- * simply extracts the calendar object from the message, deserializes it, and
- * passes it up to ical_update_my_calendar_with_reply() for processing.
- */
+// Handle an incoming RSVP for an event.  (This is the server subcommand part; it
+// simply extracts the calendar object from the message, deserializes it, and
+// passes it up to ical_update_my_calendar_with_reply() for processing.
 void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
        struct CtdlMessage *msg = NULL;
        struct ical_respond_data ird;
        int ret;
 
        if (
-          (strcasecmp(action, "update"))
-          && (strcasecmp(action, "ignore"))
+               (strcasecmp(action, "update"))
+               && (strcasecmp(action, "ignore"))
        ) {
-               cprintf("%d Action must be 'update' or 'ignore'\n",
-                       ERROR + ILLEGAL_VALUE
-               );
+               cprintf("%d Action must be 'update' or 'ignore'\n", ERROR + ILLEGAL_VALUE);
                return;
        }
 
@@ -677,48 +656,43 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
 
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, partnum);
-       mime_parser(CM_RANGE(msg, eMesageText),
-                   *ical_locate_part,          /* callback function */
-                   NULL, NULL,
-                   (void *) &ird,                      /* user data */
-                   0
-               );
+       mime_parser(
+               CM_RANGE(msg, eMesageText),
+               *ical_locate_part,                      // callback function
+               NULL,
+               NULL,
+               (void *) &ird,                          // user data
+               0
+       );
 
-       /* We're done with the incoming message, because we now have a
-        * calendar object in memory.
-        */
+       // We're done with the incoming message, because we now have a
+       // calendar object in memory.
        CM_Free(msg);
 
-       /*
-        * Here is the real meat of this function.  Handle the event.
-        */
+       // Here is the real meat of this function.  Handle the event.
        if (ird.cal != NULL) {
-               /* Update the user's calendar if necessary */
+               // Update the user's calendar if necessary
                if (!strcasecmp(action, "update")) {
                        ret = ical_update_my_calendar_with_reply(ird.cal);
                        if (ret == 0) {
-                               cprintf("%d Your calendar has been updated with this reply.\n",
-                                       CIT_OK);
+                               cprintf("%d Your calendar has been updated with this reply.\n", CIT_OK);
                        }
                        else if (ret == 1) {
-                               cprintf("%d This event does not exist in your calendar.\n",
-                                       ERROR + FILE_NOT_FOUND);
+                               cprintf("%d This event does not exist in your calendar.\n", ERROR + FILE_NOT_FOUND);
                        }
                        else {
-                               cprintf("%d An internal error occurred.\n",
-                                       ERROR + INTERNAL_ERROR);
+                               cprintf("%d An internal error occurred.\n", ERROR + INTERNAL_ERROR);
                        }
                }
                else {
                        cprintf("%d This reply has been ignored.\n", CIT_OK);
                }
 
-               /* Now that we've processed this message, we don't need it
-                * anymore.  So delete it.  (Don't do this anymore.)
-               CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
-                */
+               // Now that we've processed this message, we don't need it
+               // anymore.  So delete it.  (Don't do this anymore.)
+               // CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
 
-               /* Free the memory we allocated and return a response. */
+               // Free the memory we allocated and return a response.
                icalcomponent_free(ird.cal);
                ird.cal = NULL;
                return;
@@ -728,13 +702,11 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
                return;
        }
 
-       /* should never get here */
+       // should never get here
 }
 
 
-/*
- * Search for a property in both the top level and in a VEVENT subcomponent
- */
+// Search for a property in both the top level and in a VEVENT subcomponent
 icalproperty *ical_ctdl_get_subprop(
                icalcomponent *cal,
                icalproperty_kind which_prop
@@ -744,8 +716,7 @@ icalproperty *ical_ctdl_get_subprop(
 
        p = icalcomponent_get_first_property(cal, which_prop);
        if (p == NULL) {
-               c = icalcomponent_get_first_component(cal,
-                                                       ICAL_VEVENT_COMPONENT);
+               c = icalcomponent_get_first_component(cal, ICAL_VEVENT_COMPONENT);
                if (c != NULL) {
                        p = icalcomponent_get_first_property(c, which_prop);
                }
@@ -754,11 +725,9 @@ icalproperty *ical_ctdl_get_subprop(
 }
 
 
-/*
- * Check to see if two events overlap.  Returns nonzero if they do.
- * (This function is used in both Citadel and WebCit.  If you change it in
- * one place, change it in the other.  Better yet, put it in a library.)
- */
+// Check to see if two events overlap.  Returns nonzero if they do.
+// (This function is used in both Citadel and WebCit.  If you change it in
+// one place, change it in the other.  Better yet, put it in a library.)
 int ical_ctdl_is_overlap(
                        struct icaltimetype t1start,
                        struct icaltimetype t1end,
@@ -768,19 +737,20 @@ int ical_ctdl_is_overlap(
        if (icaltime_is_null_time(t1start)) return(0);
        if (icaltime_is_null_time(t2start)) return(0);
 
-       /* if either event lacks end time, assume end = start */
-       if (icaltime_is_null_time(t1end))
+       // if either event lacks end time, assume end = start
+       if (icaltime_is_null_time(t1end)) {
                memcpy(&t1end, &t1start, sizeof(struct icaltimetype));
+       }
        else {
                if (t1end.is_date && icaltime_compare(t1start, t1end)) {
-                        /*
-                         * the end date is non-inclusive so adjust it by one
-                         * day because our test is inclusive, note that a day is
-                         * not too much because we are talking about all day
-                         * events
-                        * if start = end we assume that nevertheless the whole
-                        * day is meant
-                         */
+
+                       // the end date is non-inclusive so adjust it by one
+                       // day because our test is inclusive, note that a day is
+                       // not too much because we are talking about all day
+                       // events
+                       // if start = end we assume that nevertheless the whole
+                       // day is meant
+
                        icaltime_adjust(&t1end, -1, 0, 0, 0);   
                }
        }
@@ -844,17 +814,17 @@ int ical_conflicts_phase6(struct icaltimetype t1start,
 {
        int conflict_reported = 0;
 
-       /* debugging cruft *
-       time_t tt;
-       tt = icaltime_as_timet_with_zone(t1start, t1start.zone);
-       syslog(LOG_DEBUG, "PROPOSED START: %s", ctime(&tt));
-       tt = icaltime_as_timet_with_zone(t1end, t1end.zone);
-       syslog(LOG_DEBUG, "  PROPOSED END: %s", ctime(&tt));
-       tt = icaltime_as_timet_with_zone(t2start, t2start.zone);
-       syslog(LOG_DEBUG, "EXISTING START: %s", ctime(&tt));
-       tt = icaltime_as_timet_with_zone(t2end, t2end.zone);
-       syslog(LOG_DEBUG, "  EXISTING END: %s", ctime(&tt));
-       * debugging cruft */
+       //      debugging cruft
+       //      time_t tt;
+       //      tt = icaltime_as_timet_with_zone(t1start, t1start.zone);
+       //      syslog(LOG_DEBUG, "PROPOSED START: %s", ctime(&tt));
+       //      tt = icaltime_as_timet_with_zone(t1end, t1end.zone);
+       //      syslog(LOG_DEBUG, "  PROPOSED END: %s", ctime(&tt));
+       //      tt = icaltime_as_timet_with_zone(t2start, t2start.zone);
+       //      syslog(LOG_DEBUG, "EXISTING START: %s", ctime(&tt));
+       //      tt = icaltime_as_timet_with_zone(t2end, t2end.zone);
+       //      syslog(LOG_DEBUG, "  EXISTING END: %s", ctime(&tt));
+       //      debugging cruft
 
        /* compare and output */
 
@@ -875,13 +845,11 @@ int ical_conflicts_phase6(struct icaltimetype t1start,
 }
 
 
-/*
- * Phase 5 of "hunt for conflicts"
- * Called by ical_conflicts_phase4()
- *
- * We have the proposed event boiled down to start and end times.
- * Now check it against an existing event. 
- */
+// Phase 5 of "hunt for conflicts"
+// Called by ical_conflicts_phase4()
+//
+// We have the proposed event boiled down to start and end times.
+// Now check it against an existing event. 
 void ical_conflicts_phase5(struct icaltimetype t1start,
                        struct icaltimetype t1end,
                        icalcomponent *existing_event,
@@ -933,9 +901,7 @@ void ical_conflicts_phase5(struct icaltimetype t1start,
                }
                else {
                        t2end.zone = icalcomponent_get_timezone(existing_event,
-                               icalparameter_get_tzid(
-                                       icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER)
-                               )
+                               icalparameter_get_tzid(icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER))
                        );
                        if (!t2end.zone) {
                                t2end.zone = get_default_icaltimezone();
@@ -1106,10 +1072,11 @@ void ical_hunt_for_conflicts_backend(long msgnum, void *data) {
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, "_HUNT_");
        mime_parser(CM_RANGE(msg, eMesageText),
-                   *ical_locate_part,          /* callback function */
-                   NULL, NULL,
-                   (void *) &ird,                      /* user data */
-                   0
+               *ical_locate_part,              // callback function
+               NULL,
+               NULL,
+               (void *) &ird,                  // user data
+               0
        );
        CM_Free(msg);
 
@@ -1598,19 +1565,17 @@ void ical_getics_backend(long msgnum, void *data) {
 }
 
 
-/*
- * Retrieve all of the calendar items in the current room, and output them
- * as a single icalendar object.
- */
-void ical_getics(void)
-{
+// Retrieve all of the calendar items in the current room, and output them
+// as a single icalendar object.
+void ical_getics(void) {
        icalcomponent *encaps = NULL;
        char *ser = NULL;
 
-       if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
-          &&(CC->room.QRdefaultview != VIEW_TASKS) ) {
+       if (    (CC->room.QRdefaultview != VIEW_CALENDAR)
+               &&(CC->room.QRdefaultview != VIEW_TASKS)
+       ) {
                cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
-               return;         /* Not an iCalendar-centric room */
+               return;         /* This room does not contain a calendar. */
        }
 
        encaps = icalcomponent_new_vcalendar();
@@ -1647,13 +1612,10 @@ void ical_getics(void)
 }
 
 
-/*
- * Helper callback function for ical_putics() to discover which TZID's we need.
- * Simply put the tzid name string into a hash table.  After the callbacks are
- * done we'll go through them and attach the ones that we have.
- */
-void ical_putics_grabtzids(icalparameter *param, void *data)
-{
+// Helper callback function for ical_putics() to discover which TZID's we need.
+// Simply put the tzid name string into a hash table.  After the callbacks are
+// done we'll go through them and attach the ones that we have.
+void ical_putics_grabtzids(icalparameter *param, void *data) {
        const char *tzid = icalparameter_get_tzid(param);
        HashList *keys = (HashList *) data;
        
@@ -1663,12 +1625,9 @@ void ical_putics_grabtzids(icalparameter *param, void *data)
 }
 
 
-/*
- * Delete all of the calendar items in the current room, and replace them
- * with calendar items from a client-supplied data stream.
- */
-void ical_putics(void)
-{
+// Delete all of the calendar items in the current room, and replace them
+// with calendar items from a client-supplied data stream.
+void ical_putics(void) {
        char *calstream = NULL;
        icalcomponent *cal;
        icalcomponent *c;
@@ -1679,14 +1638,15 @@ void ical_putics(void)
        const char *Key;
        long len;
 
-       /* Only allow this operation if we're in a room containing a calendar or tasks view */
-       if ( (CC->room.QRdefaultview != VIEW_CALENDAR)
-          &&(CC->room.QRdefaultview != VIEW_TASKS) ) {
+       // Only allow this operation if we're in a room containing a calendar or tasks view
+       if (    (CC->room.QRdefaultview != VIEW_CALENDAR)
+               && (CC->room.QRdefaultview != VIEW_TASKS)
+       ) {
                cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
                return;
        }
 
-       /* Only allow this operation if we have permission to overwrite the existing calendar */
+       // Only allow this operation if we have permission to overwrite the existing calendar
        if (!CtdlDoIHavePermissionToDeleteMessagesFromThisRoom()) {
                cprintf("%d Permission denied.\n", ERROR+HIGHER_ACCESS_REQUIRED);
                return;
@@ -1721,8 +1681,9 @@ void ical_putics(void)
         */
        else {
                for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
-                   (c != NULL);
-                   c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
+                       (c != NULL);
+                       c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)
+               ) {
 
                        /* Non-VTIMEZONE components each get written as individual messages.
                         * But we also need to attach the relevant VTIMEZONE components to them.
@@ -1782,8 +1743,7 @@ void ical_putics(void)
 /*
  * All Citadel calendar commands from the client come through here.
  */
-void cmd_ical(char *argbuf)
-{
+void cmd_ical(char *argbuf) {
        char subcmd[64];
        long msgnum;
        char partnum[256];
@@ -1853,8 +1813,7 @@ void cmd_ical(char *argbuf)
 /*
  * We don't know if the calendar room exists so we just create it at login
  */
-void ical_CtdlCreateRoom(void)
-{
+void ical_CtdlCreateRoom(void) {
        struct ctdlroom qr;
        struct visit vbuf;
 
@@ -2316,8 +2275,7 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
  * If the message is being saved, we also set various message header fields
  * using data found in the iCalendar object.
  */
-int ical_obj_beforesave(struct CtdlMessage *msg, struct recptypes *recp)
-{
+int ical_obj_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
        /* First determine if this is a calendar or tasks room */
        if (  (CC->room.QRdefaultview != VIEW_CALENDAR)
           && (CC->room.QRdefaultview != VIEW_TASKS)
@@ -2383,8 +2341,7 @@ void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
  * (This will start back end tasks such as automatic generation of invitations,
  * if such actions are appropriate.)
  */
-int ical_obj_aftersave(struct CtdlMessage *msg, struct recptypes *recp)
-{
+int ical_obj_aftersave(struct CtdlMessage *msg, struct recptypes *recp) {
        char roomname[ROOMNAMELEN];
 
        /*