*
* Utility functions for the IMAP module.
*
- * Note: most of the UTF7 and UTF8 handling in here was stolen from Evolution.
+ * Note: most of the UTF7 and UTF8 handling in here was lifted from Evolution.
*
*/
/* IMAP has certain special requirements in its character set, which means we
* have to do a fair bit of work to convert Citadel's UTF8 strings to IMAP
- * strings. The next two routines (and their data tables) do that. */
+ * strings. The next two routines (and their data tables) do that.
+ */
static char *utf7_alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
string_append_c(out, '-');
}
-/* Convert from a Citadel name to an IMAP-safe name. Returns the end of the destination. */
-
+/* Convert from a Citadel name to an IMAP-safe name. Returns the end
+ * of the destination.
+ */
static char* toimap(char* destp, char* destend, char* src)
{
struct string dest;
*destp = 0;
string_init(&dest, destp, destend-destp);
- lprintf(CTDL_DEBUG, "toimap %s\r\n", src);
+ /* lprintf(CTDL_DEBUG, "toimap %s\r\n", src); */
for (;;)
{
if (state == 1)
utf7_closeb64(&dest, v, i);
- lprintf(CTDL_DEBUG, " -> %s\r\n", destp);
+ /* lprintf(CTDL_DEBUG, " -> %s\r\n", destp); */
return string_end(&dest);
}
*destp = 0;
string_init(&dest, destp, destend-destp);
- lprintf(CTDL_DEBUG, "fromimap %s\r\n", src);
+ /* lprintf(CTDL_DEBUG, "fromimap %s\r\n", src); */
do {
c = *p++;
}
} while (c != '\0');
- lprintf(CTDL_DEBUG, " -> %s\r\n", destp);
+ /* lprintf(CTDL_DEBUG, " -> %s\r\n", destp); */
return string_end(&dest);
}
int imap_roomname(char *rbuf, int bufsize, char *foldername)
{
int levels;
- char floorname[SIZ];
- char roomname[SIZ];
+ char floorname[256];
+ char roomname[ROOMNAMELEN];
int i;
struct floor *fl;
int ret = (-1);
{
/* Extract the main room name. */
- extract_token(floorname, rbuf, 0, FDELIM);
+ extract_token(floorname, rbuf, 0, FDELIM, sizeof floorname);
strcpy(roomname, &rbuf[strlen(floorname)+1]);
/* Try and find it on any floor. */
{
/* Got it! */
- strcpy(rbuf, roomname);
+ safestrncpy(rbuf, roomname, bufsize);
ret = i;
goto exit;
}
}
}
- /* Meh. It's either not a multi-level room name, or else we couldn't find it. */
-
+ /* Meh. It's either not a multi-level room name, or else we
+ * couldn't find it.
+ */
ret = (0 | IR_MAILBOX);
exit:
* a Unix timestamp.
*/
int imap_datecmp(char *datestr, time_t msgtime) {
- char daystr[SIZ];
- char monthstr[SIZ];
- char yearstr[SIZ];
+ char daystr[256];
+ char monthstr[256];
+ char yearstr[256];
int i;
int day, month, year;
int msgday, msgmonth, msgyear;
if (datestr == NULL) return(0);
/* Expecting a date in the form dd-Mmm-yyyy */
- extract_token(daystr, datestr, 0, '-');
- extract_token(monthstr, datestr, 1, '-');
- extract_token(yearstr, datestr, 2, '-');
+ extract_token(daystr, datestr, 0, '-', sizeof daystr);
+ extract_token(monthstr, datestr, 1, '-', sizeof monthstr);
+ extract_token(yearstr, datestr, 2, '-', sizeof yearstr);
day = atoi(daystr);
year = atoi(yearstr);