bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mailutils] Unfolding header value


From: Sam Roberts
Subject: Re: [bug-mailutils] Unfolding header value
Date: Thu, 3 Jul 2003 21:49:32 -0400
User-agent: Mutt/1.4i

Quoteing address@hidden, on Wed, Jul 02, 2003 at 11:46:49AM -0400:
> In general, what is the best policy?
> 
> (1) in this case:
> 
>  Received: from hub.ott.qnx.com (address@hidden [192.168.2.2]) by 
> smtp.ott.qnx.com (8.8.8/8.6.12) with ESMTP id LAA10830 for <address@hidden>; 
> Fri, 13 Sep 2002 11:56:09 -0400
>  Received: from luna.pizzashack.org (h52544c185a20.ne.client2.attbi.com 
> [24.147.42.69])
>         by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id LAA15686
>         for <address@hidden>; Fri, 13 Sep 2002 11:55:21 -0400
>  Received: (from address@hidden)
>         by luna.pizzashack.org (8.11.6/8.11.2) id g8DFuj220932;
>         Fri, 13 Sep 2002 11:56:45 -0400
> 
> What should header_get_value return ?

I'd say header_get_value() should take an index, and get the value of
the indexed field.

IMAPd used to have a bug where all the values of all Received fields
were concatenated into one value. This bug actually originated in
header_get_field() concatenating fields. 

I guess no IMAP clients actuall do a fetch of the Received field, so
noone really cares, and the interesting fields aren't allowed to have
duplicates (to, subject, resent-from, date).

> (2) header_get_value() is also used in imap4d etc ... to return header field 
> values.
>     If we fold and collapse headers, how to unfold and unduplicate(see the 
> "Received:" case)
> 
> (3) maybe an approach is to add new methods/API to header_t to handle the 
> cases.


I started to work on the header_get functions, and bogged down (the
changes went deep). Note it allows getting of complete fields with all
the folded white space and field names intact (this what IMAP would
call), and what users might want - getting unfolded values. I think I
have some implementation, but I can't really see, I don't have CVS
access working right now, and I'm going on vacation.

/* Version 2 APIs. */

/* Get count of fields by name, NULL means any name/all fields. */
extern int header_get_count_2  __P ((header_t, const char* name, size_t* 
count));

/* Get name of field by index into all the fields. */
extern int header_get_name_2   __P ((header_t, size_t index, char *, size_t, 
size_t *));
extern int header_aget_name_2  __P ((header_t, size_t index, char **));

/*
Get value of field by index into fields with this name, a NULL name
means by index into all the fields.
*/
extern int header_get_value_2  __P ((header_t, const char* name,
      size_t index, char *, size_t, size_t *));
extern int header_aget_value_2 __P ((header_t, const char* name,
      size_t index, char **));

/*
Get a header field ("Name: value"), complete with new lines. If name is
NULL, it means any field. If index is 0, get all the fields with the
specified name. For example, a NULL name and 0 index would get the
entire header.
*/
extern int header_get_field_2  __P ((header_t, const char*
      name, size_t index, char *, size_t, size_t *));
extern int header_aget_field_2 __P ((header_t, const char*
      name, size_t index, char **));


I also don't think mailutils has great apis for adding headers, or any
way to delete headers, so I was going to do this:

/*
Set field values.

name must always be provided.

A 0 index means prepend a field with this name and value to the header,
value must not be NULL.

A positive index identifies an existing field by name and index. It's value
will be rewritten to the value provided, or it will be deleted if the value
is NULL.

A -1 index means append a field with this name and value to the header,
value must not be NULL.
*/
extern int header_set_value_2  __P((header_t, const char* name, size_t index, 
const char* value));



Cheers,
Sam


Attachment: header.h
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]