/*----------------------------------------------------------------------------*/
+/*
+ * qsort() compatible function to compare two longs in descending order.
+ */
+int longcmp_r(const void *s1, const void *s2) {
+ long l1;
+ long l2;
+
+ l1 = *(long *)GetSearchPayload(s1);
+ l2 = *(long *)GetSearchPayload(s2);
+
+ if (l1 > l2) return(-1);
+ if (l1 < l2) return(+1);
+ return(0);
+}
+
+/*
+ * qsort() compatible function to compare two longs in descending order.
+ */
+int qlongcmp_r(const void *s1, const void *s2) {
+ long l1 = (long) s1;
+ long l2 = (long) s2;
+
+ if (l1 > l2) return(-1);
+ if (l1 < l2) return(+1);
+ return(0);
+}
+
+
+/*
+ * qsort() compatible function to compare two message summary structs by ascending subject.
+ */
+int summcmp_subj(const void *s1, const void *s2) {
+ message_summary *summ1;
+ message_summary *summ2;
+
+ summ1 = (message_summary *)GetSearchPayload(s1);
+ summ2 = (message_summary *)GetSearchPayload(s2);
+ return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
+}
+
+/*
+ * qsort() compatible function to compare two message summary structs by descending subject.
+ */
+int summcmp_rsubj(const void *s1, const void *s2) {
+ message_summary *summ1;
+ message_summary *summ2;
+
+ summ1 = (message_summary *)GetSearchPayload(s1);
+ summ2 = (message_summary *)GetSearchPayload(s2);
+ return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
+}
+
+/*
+ * qsort() compatible function to compare two message summary structs by ascending sender.
+ */
+int summcmp_sender(const void *s1, const void *s2) {
+ message_summary *summ1;
+ message_summary *summ2;
+
+ summ1 = (message_summary *)GetSearchPayload(s1);
+ summ2 = (message_summary *)GetSearchPayload(s2);
+ return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
+}
+
+/*
+ * qsort() compatible function to compare two message summary structs by descending sender.
+ */
+int summcmp_rsender(const void *s1, const void *s2) {
+ message_summary *summ1;
+ message_summary *summ2;
+
+ summ1 = (message_summary *)GetSearchPayload(s1);
+ summ2 = (message_summary *)GetSearchPayload(s2);
+ return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
+}
+
+/*
+ * qsort() compatible function to compare two message summary structs by ascending date.
+ */
+int summcmp_date(const void *s1, const void *s2) {
+ message_summary *summ1;
+ message_summary *summ2;
+
+ summ1 = (message_summary *)GetSearchPayload(s1);
+ summ2 = (message_summary *)GetSearchPayload(s2);
+
+ if (summ1->date < summ2->date) return -1;
+ else if (summ1->date > summ2->date) return +1;
+ else return 0;
+}
+
+/*
+ * qsort() compatible function to compare two message summary structs by descending date.
+ */
+int summcmp_rdate(const void *s1, const void *s2) {
+ message_summary *summ1;
+ message_summary *summ2;
+
+ summ1 = (message_summary *)GetSearchPayload(s1);
+ summ2 = (message_summary *)GetSearchPayload(s2);
+
+ if (summ1->date < summ2->date) return +1;
+ else if (summ1->date > summ2->date) return -1;
+ else return 0;
+}
+
+/*----------------------------------------------------------------------------*/
+
+
+
void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
if (Msg->AttachLinks == NULL)
Msg->AttachLinks = NewHash(1,NULL);
Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
- if (strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) {
+ if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) &&
+ (StrLength(Mime->FileName) > 0)) {
FlushStrBuf(Mime->ContentType);
StrBufAppendBufPlain(Mime->ContentType,
GuessMimeByFilename(SKEY(Mime->FileName)),
StrBuf *cs = NULL;
const char *ptr, *pte;
const char *BufPtr = NULL;
- StrBuf *Line = NewStrBuf();
- StrBuf *Line1 = NewStrBuf();
- StrBuf *Line2 = NewStrBuf();
- StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
+ StrBuf *Line;
+ StrBuf *Line1;
+ StrBuf *Line2;
+ StrBuf *Target;
+
int ConvertIt = 1;
int bn = 0;
int bq = 0;
cs = FoundCharset;
else if (StrLength(WC->DefaultCharset) > 0)
cs = WC->DefaultCharset;
- if (cs == 0) {
+ if (cs == NULL) {
ConvertIt = 0;
}
else {
}
}
#endif
+ Line = NewStrBuf();
+ Line1 = NewStrBuf();
+ Line2 = NewStrBuf();
+ Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
while ((n = StrBufSipLine(Line, Mime->Data, &BufPtr), n >= 0) && !done)
{
}
+void servcmd_do_search(char *buf, long bufsize)
+{
+ snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
+}
+
+void servcmd_headers(char *buf, long bufsize)
+{
+ snprintf(buf, bufsize, "MSGS ALL");
+}
+
+void servcmd_readfwd(char *buf, long bufsize)
+{
+ snprintf(buf, bufsize, "MSGS ALL");
+}
+
+void servcmd_readnew(char *buf, long bufsize)
+{
+ snprintf(buf, bufsize, "MSGS NEW");
+}
+
+void servcmd_readold(char *buf, long bufsize)
+{
+ snprintf(buf, bufsize, "MSGS OLD");
+}
+
+
+readloop_struct rlid[] = {
+ { {HKEY("do_search")}, servcmd_do_search},
+ { {HKEY("headers")}, servcmd_headers},
+ { {HKEY("readfwd")}, servcmd_readfwd},
+ { {HKEY("readnew")}, servcmd_readnew},
+ { {HKEY("readold")}, servcmd_readold}
+};
+
+
+
+
+
InitModule_MSGRENDERERS
(void)
{
+ RegisterSortFunc(HKEY("date"),
+ NULL, 0,
+ summcmp_date,
+ summcmp_rdate,
+ CTX_MAILSUM);
+ RegisterSortFunc(HKEY("subject"),
+ NULL, 0,
+ summcmp_subj,
+ summcmp_rsubj,
+ CTX_MAILSUM);
+ RegisterSortFunc(HKEY("sender"),
+ NULL, 0,
+ summcmp_sender,
+ summcmp_rsender,
+ CTX_MAILSUM);
+
RegisterNamespace("MAIL:SUMM:DATESTR", 0, 0, tmplput_MAIL_SUMM_DATE_STR, CTX_MAILSUM);
RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, CTX_MAILSUM);
RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, CTX_MAILSUM);