#include "html.h"
#include "compose.h"
#include "addressbook.h"
+#include "headers_display.h"
+#include "prefs_display_headers.h"
#define FONT_LOAD(font, s) \
{ \
result = TRUE;
}
}
-
+
+ /* we now have at least the address. now see if this is <bracketed>; in this
+ * case we also scan for the informative part. we could make this a useful
+ * function because it tries to parse out an email address backwards. :) */
if (result) {
- /* we now have at least the address. now see if this is <bracketed>; in this
- * case we also scan for the informative part. we could make this a useful
- * function because it tries to parse out an email address backwards. :) */
if ( ((bp_ - 1 > start) && *(bp_ - 1) == '<') && (*ep_ == '>')) {
+
+ /* the informative part of the email address (describing the name
+ * of the email address owner) may contain quoted parts. the
+ * closure stack stores the last encountered quotes. */
char closure_stack[128];
char *ptr = closure_stack;
#define FULL_STACK() ((ptr - closure_stack) >= sizeof closure_stack)
ep_++;
- /* scan for the informative part */
+ /* scan for the informative part. */
+
for (bp_ -= 2; bp_ >= start; bp_--) {
/* if closure on the stack keep scanning */
if (PEEK_STACK() == *bp_) {
PUSH_STACK(*bp_);
}
else {
+ /* if nothing in the closure stack, do the special conditions
+ * the following if..else expression simply checks whether
+ * a token is acceptable. if not acceptable, the clause
+ * should terminate the loop with a 'break' */
if (!PEEK_STACK()) {
- /* if nothing in the closure stack, do the special conditions
- * the following if..else expression simply checks whether
- * a token is acceptable. if not acceptable, the clause
- * should terminate the loop with a 'break' */
if ( *bp_ == '-'
&& (((bp_ - 1) >= start) && isalnum(*(bp_ - 1)))
&& (((bp_ + 1) < ep_) && isalnum(*(bp_ + 1))) ) {
H_ORGANIZATION = 11,
};
+static gboolean hdrequal(char * hdr1, char * hdr2)
+{
+ int len1;
+ int len2;
+
+ len1 = strlen(hdr1);
+ len2 = strlen(hdr2);
+ if (hdr1[len1 - 1] == ':')
+ len1--;
+ if (hdr2[len2 - 1] == ':')
+ len2--;
+ if (len1 != len2)
+ return 0;
+ return (strncasecmp(hdr1, hdr2, len1) == 0);
+}
+
static GPtrArray *textview_scan_header(TextView *textview, FILE *fp)
{
+ /*
static HeaderEntry hentry[] = {{"Date:", NULL, FALSE},
{"From:", NULL, TRUE},
{"To:", NULL, FALSE},
{"User-Agent:", NULL, TRUE},
{"Organization:", NULL, TRUE},
{NULL, NULL, FALSE}};
+ */
gchar buf[BUFFSIZE], tmp[BUFFSIZE];
gint hnum;
HeaderEntry *hp;
GPtrArray *headers;
+ GSList * l;
+
+ int i;
+ GPtrArray *sorted_headers;
g_return_val_if_fail(fp != NULL, NULL);
headers = g_ptr_array_new();
+ /*
while ((hnum = procheader_get_one_field(buf, sizeof(buf), fp, hentry))
!= -1) {
Header *header;
g_ptr_array_add(headers, header);
}
+ */
+ // while (procheader_get_unfolded_line(buf, sizeof(buf), fp) != NULL) {
+ while (procheader_get_one_field(buf, sizeof(buf), fp, NULL) != -1) {
+ gchar * p;
+ Header *header;
+
+ if (*buf == ':') continue;
+ for (p = buf; *p && *p != ' '; p++) {
+ if (*p == ':') {
+ header = g_new(Header, 1);
+ header->name = g_strndup(buf, p - buf + 1);
+ p++;
+ /* while (*p == ' ' || *p == '\t') p++; */
+ conv_unmime_header(tmp, sizeof(tmp), p, NULL);
+ header->body = g_strdup(tmp);
+
+ g_ptr_array_add(headers, header);
+ break;
+ }
+ }
+ }
+
+ sorted_headers = g_ptr_array_new();
+ for(l = prefs_display_headers.headers_list ; l != NULL ;
+ l = g_slist_next(l)) {
+ HeaderDisplayProp * dp = (HeaderDisplayProp *) l->data;
+ for(i = 0 ; i < headers->len ; i++) {
+ Header * header = g_ptr_array_index(headers, i);
+ if (hdrequal(header->name, dp->name)) {
+ if (dp->hidden) {
+ g_ptr_array_remove_index(headers, i);
+ g_free(header->body);
+ g_free(header->name);
+ g_free(header);
+ i--;
+ }
+ else {
+ g_ptr_array_add(sorted_headers,
+ header);
+ g_ptr_array_remove_index(headers, i);
+ i--;
+ }
+ }
+ }
+ }
+
+ if (prefs_display_headers.show_other_headers) {
+ for(i = 0 ; i < headers->len ; i++) {
+ Header * header = g_ptr_array_index(headers, i);
+ g_ptr_array_add(sorted_headers, header);
+ }
+ }
- return headers;
+ g_ptr_array_free(headers, TRUE);
+
+ return sorted_headers;
}
static void textview_show_header(TextView *textview, GPtrArray *headers)