*/
/**
- * @page email_parse
+ * @page email_parse Miscellaneous email parsing routines
*
* Miscellaneous email parsing routines
*/
/**
* mutt_matches_ignore - Does the string match the ignore list
+ * @param s String to check
+ * @retval true If string matches
*
- * checks Ignore and UnIgnore using mutt_list_match
+ * Checks Ignore and UnIgnore using mutt_list_match
*/
bool mutt_matches_ignore(const char *s)
{
return mutt_list_match(s, &Ignore) && !mutt_list_match(s, &UnIgnore);
}
+/**
+ * mutt_check_mime_type - Check a MIME type string
+ * @param s String to check
+ * @retval num MIME type, e.g. #TYPETEXT
+ */
int mutt_check_mime_type(const char *s)
{
if (mutt_str_strcasecmp("text", s) == 0)
/**
* mutt_extract_message_id - Find a message-id
+ * @param s String to parse
+ * @param saveptr Save result here
+ * @retval ptr First character after message-id
+ * @retval NULL No more message ids
*
- * extract the first substring that looks like a message-id.
- * call back with NULL for more (like strtok).
+ * Extract the first substring that looks like a message-id.
+ * Call back with NULL for more (like strtok).
*/
char *mutt_extract_message_id(const char *s, const char **saveptr)
{
return NULL;
}
+/**
+ * mutt_check_encoding - Check the encoding type
+ * @param c String to check
+ * @retval num Encoding type, e.g. #ENCQUOTEDPRINTABLE
+ */
int mutt_check_encoding(const char *c)
{
if (mutt_str_strncasecmp("7bit", c, sizeof("7bit") - 1) == 0)
return ENCOTHER;
}
+/**
+ * parse_parameters - Parse a list of Parameters
+ * @param param Parameter list for the results
+ * @param s String to parse
+ */
static void parse_parameters(struct ParameterList *param, const char *s)
{
struct Parameter *new = NULL;
rfc2231_decode_parameters(param);
}
+/**
+ * parse_content_disposition - Parse a content disposition
+ * @param s String to parse
+ * @param ct Body to save the result
+ *
+ * e.g. parse a string "inline" and set #DISPINLINE.
+ */
static void parse_content_disposition(const char *s, struct Body *ct)
{
struct ParameterList parms;
ct->language = mutt_str_strdup(s);
}
+/**
+ * mutt_parse_content_type - Parse a content type
+ * @param s String to parse
+ * @param ct Body to save the result
+ *
+ * e.g. parse a string "inline" and set #DISPINLINE.
+ */
void mutt_parse_content_type(char *s, struct Body *ct)
{
FREE(&ct->subtype);
}
}
+/**
+ * mutt_rfc822_parse_line - Parse an email header
+ * @param e Envelope of the email
+ * @param hdr Header of the email
+ * @param line Header field, e.g. 'to'
+ * @param p Header value, e.g. 'john@example.com'
+ * @param user_hdrs If true, save into the Envelope's userhdrs
+ * @param weed If true, perform header weeding (filtering)
+ * @param do_2047 If true, perform RFC2047 decoding of the field
+ * @retval 1 If the field is recognised
+ * @retval 0 If not
+ *
+ * Process a line from an email header. Each line that is recognised is parsed
+ * and the information put in the Envelope or Header.
+ */
int mutt_rfc822_parse_line(struct Envelope *e, struct Header *hdr, char *line,
char *p, short user_hdrs, short weed, short do_2047)
{
{
if (hdr)
{
- /*
- * HACK - neomutt has, for a very short time, produced negative
- * Lines header values. Ignore them.
- */
+ /* HACK - neomutt has, for a very short time, produced negative
+ * Lines header values. Ignore them.
+ */
if (mutt_str_atoi(p, &hdr->lines) < 0 || hdr->lines < 0)
hdr->lines = 0;
}
/**
* mutt_rfc822_read_line - Read a header line from a file
+ * @param f File to read from
+ * @param line Buffer to store the result
+ * @param linelen Length of buffer
+ * @retval ptr Line read from file
*
* Reads an arbitrarily long header field, and looks ahead for continuation
* lines. ``line'' must point to a dynamically allocated string; it is
(mutt_str_strcasecmp(subtype, "news") == 0));
}
+/**
+ * mutt_parse_part - Parse a MIME part
+ * @param fp File to read from
+ * @param b Body to store the results in
+ */
void mutt_parse_part(FILE *fp, struct Body *b)
{
char *bound = NULL;
break;
}
#endif
-
- /*
- * Consistency checking - catch
+ /* Consistency checking - catch
* bad attachment end boundaries
*/
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Yet another MIME encoding for header data. This time, it's parameters,
- * specified in RFC2231, and modeled after the encoding used in URLs.
+/**
+ * @page email_rfc2231 RFC2231 MIME Charset routines
+ *
+ * RFC2231 MIME Charset routines
+ *
+ * Yet another MIME encoding for header data. This time, it's parameters,
+ * specified in RFC2231, and modelled after the encoding used in URLs.
*
* Additionally, continuations and encoding are mixed in an, errrm, interesting
* manner.
struct Rfc2231Parameter *next;
};
+/**
+ * purge_empty_parameters - Remove any ill-formed Parameters from a list
+ * @param p Parameter List to check
+ */
static void purge_empty_parameters(struct ParameterList *p)
{
struct Parameter *np, *tmp;
}
}
+/**
+ * rfc2231_get_charset - Get the charset from an RFC2231 header
+ * @param value Header string
+ * @param charset Buffer for the result
+ * @param chslen Length of buffer
+ * @retval ptr First character after charset
+ */
static char *rfc2231_get_charset(char *value, char *charset, size_t chslen)
{
char *t = strchr(value, '\'');
return (t + 1);
}
+/**
+ * rfc2231_decode_one - Decode one percent-encoded character
+ * @param[out] dest Where to save the result
+ * @param[in] src Source string
+ */
static void rfc2231_decode_one(char *dest, char *src)
{
char *d = NULL;
*d = '\0';
}
+/**
+ * rfc2231_new_parameter - Create a new Rfc2231Parameter
+ * @retval ptr Newly allocated Rfc2231Parameter
+ */
static struct Rfc2231Parameter *rfc2231_new_parameter(void)
{
return mutt_mem_calloc(1, sizeof(struct Rfc2231Parameter));
}
/**
- * rfc2231_list_insert - insert parameter into an ordered list
+ * rfc2231_list_insert - Insert parameter into an ordered list
+ * @param list List to insert into
+ * @param par Paramter to insert
*
* Primary sorting key: attribute
* Secondary sorting key: index
*last = par;
}
+/**
+ * rfc2231_free_parameter - Free an Rfc2231Parameter
+ * @param p Rfc2231Parameter to free
+ */
static void rfc2231_free_parameter(struct Rfc2231Parameter **p)
{
if (*p)
}
/**
- * rfc2231_join_continuations - process continuation parameters
+ * rfc2231_join_continuations - Process continuation parameters
+ * @param p Parameter List for the results
+ * @param par Continuation Parameter
*/
static void rfc2231_join_continuations(struct ParameterList *p, struct Rfc2231Parameter *par)
{
}
}
+/**
+ * rfc2231_decode_parameters - Decode a Parameter list
+ * @param p List to decode
+ */
void rfc2231_decode_parameters(struct ParameterList *p)
{
struct Rfc2231Parameter *conthead = NULL;
purge_empty_parameters(p);
}
+/**
+ * rfc2231_encode_string - Encode a string to be suitable for an RFC2231 header
+ * @param pd String to encode
+ * @retval 1 If string was encoded
+ * @retval 0 If no
+ *
+ * The string is encoded in-place.
+ */
int rfc2231_encode_string(char **pd)
{
int ext = 0, encode = 0;
char *charset = NULL, *s = NULL, *t = NULL, *e = NULL, *d = NULL;
size_t slen, dlen = 0;
- /*
- * A shortcut to detect pure 7bit data.
- *
- * This should prevent the worst when character set handling
- * is flawed.
+ /* A shortcut to detect pure 7bit data.
+ * This should prevent the worst when character set handling is flawed.
*/
for (s = *pd; *s; s++)
#include "url.h"
#include "mime.h"
+/**
+ * UrlMap - Constants for URL protocols, e.g. 'imap://'
+ */
static const struct Mapping UrlMap[] = {
{ "file", U_FILE }, { "imap", U_IMAP }, { "imaps", U_IMAPS },
{ "pop", U_POP }, { "pops", U_POPS }, { "news", U_NNTP },
{ "smtp", U_SMTP }, { "smtps", U_SMTPS }, { NULL, U_UNKNOWN },
};
+/**
+ * url_pct_decode - Decode a percent-encoded string
+ * @param s String to decode
+ * @retval 0 Success
+ * @retval -1 Error
+ *
+ * e.g. turn "hello%20world" into "hello world"
+ * The string is decoded in-place.
+ */
int url_pct_decode(char *s)
{
char *d = NULL;
return 0;
}
+/**
+ * url_check_scheme - Check the protocol of a URL
+ * @param s String to check
+ * @retval num Url type, e.g. #U_IMAPS
+ */
enum UrlScheme url_check_scheme(const char *s)
{
char sbuf[STRING];
return (enum UrlScheme) i;
}
+/**
+ * parse_query_string - Parse a URL query string
+ * @param u Url to store the results
+ * @param src String to parse
+ * @retval 0 Success
+ * @retval -1 Error
+ */
static int parse_query_string(struct Url *u, char *src)
{
struct UrlQueryString *qs = NULL;
return -1;
}
+/**
+ * url_free - Free the contents of a URL
+ * @param u Url to empty
+ *
+ * @note The Url itself is not freed
+ */
void url_free(struct Url *u)
{
struct UrlQueryString *np = STAILQ_FIRST(&u->query_strings), *next = NULL;
STAILQ_INIT(&u->query_strings);
}
+/**
+ * url_pct_encode - Percent-encode a string
+ * @param dst Buffer for the result
+ * @param l Length of buffer
+ * @param src String to encode
+ *
+ * e.g. turn "hello world" into "hello%20world"
+ */
void url_pct_encode(char *dst, size_t l, const char *src)
{
static const char *alph = "0123456789ABCDEF";
}
/**
- * url_tostring - output the URL string for a given Url object
+ * url_tostring - Output the URL string for a given Url object
+ * @param u Url to turn into a string
+ * @param dest Buffer for the result
+ * @param len Length of buffer
+ * @param flags Flags, e.g. #U_DECODE_PASSWD
+ * @retval 0 Success
+ * @retval -1 Error
*/
int url_tostring(struct Url *u, char *dest, size_t len, int flags)
{