[dovecot-cvs] dovecot/src/lib-mail message-content-parser.c,1.4,1.5 rfc822-address.c,1.6,1.7 rfc822-date.c,1.9,1.10 rfc822-tokenize.c,1.7,1.8 rfc822-tokenize.h,1.8,1.9
cras at procontrol.fi
cras at procontrol.fi
Sat Jan 4 15:22:33 EET 2003
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c,1.25,1.26
- Next message: [dovecot-cvs] dovecot/src/lib imem.c,1.5,1.6 imem.h,1.5,1.6 istream-data.c,1.1,1.2 istream.h,1.1,1.2 str.c,1.5,1.6 str.h,1.1,1.2 strescape.c,1.1,1.2 strescape.h,1.1,1.2 strfuncs.c,1.26,1.27 strfuncs.h,1.14,1.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-mail
In directory danu:/tmp/cvs-serv11895/lib-mail
Modified Files:
message-content-parser.c rfc822-address.c rfc822-date.c
rfc822-tokenize.c rfc822-tokenize.h
Log Message:
Rfc822 tokenizer cleanups
Index: message-content-parser.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-content-parser.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- message-content-parser.c 3 Jan 2003 15:57:12 -0000 1.4
+++ message-content-parser.c 4 Jan 2003 13:22:29 -0000 1.5
@@ -24,7 +24,7 @@
str = t_str_new(256);
/* first ';' separates the parameters */
- (void)rfc822_tokenize_get_string(ctx, str, NULL, stop_tokens);
+ rfc822_tokenize_get_string(ctx, str, NULL, stop_tokens);
if (func != NULL)
func(str_c(str), str_len(str), context);
@@ -33,21 +33,17 @@
if (param_func != NULL && rfc822_tokenize_get(ctx) == ';') {
/* parse the parameters */
- while (rfc822_tokenize_next(ctx)) {
- token = rfc822_tokenize_get(ctx);
-
+ while ((token = rfc822_tokenize_next(ctx)) != TOKEN_LAST) {
/* <token> "=" <token> | <quoted-string> */
if (token != TOKEN_ATOM)
continue;
key = rfc822_tokenize_get_value(ctx, &key_len);
- (void)rfc822_tokenize_next(ctx);
- if (rfc822_tokenize_get(ctx) != '=')
+ if (rfc822_tokenize_next(ctx) != '=')
continue;
- (void)rfc822_tokenize_next(ctx);
- token = rfc822_tokenize_get(ctx);
+ token = rfc822_tokenize_next(ctx);
if (token != TOKEN_ATOM && token != TOKEN_QSTRING)
continue;
Index: rfc822-address.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/rfc822-address.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- rfc822-address.c 3 Jan 2003 15:57:12 -0000 1.6
+++ rfc822-address.c 4 Jan 2003 13:22:29 -0000 1.7
@@ -82,8 +82,8 @@
} else {
len = 0;
}
- (void)rfc822_tokenize_get_string(ctx, next_phrase, comment,
- stop_tokens);
+ rfc822_tokenize_get_string(ctx, next_phrase, comment,
+ stop_tokens);
if (next_phrase == name && len > 0 && len == str_len(name)) {
/* nothing appeneded, remove the space */
@@ -152,18 +152,18 @@
}
/* mailbox */
- (void)rfc822_tokenize_get_string(ctx,
- mailbox, NULL, stop_tokens_addr_mailbox);
+ rfc822_tokenize_get_string(ctx, mailbox, NULL,
+ stop_tokens_addr_mailbox);
if (rfc822_tokenize_get(ctx) == '@' &&
str_len(mailbox) == 0) {
/* route is given */
- (void)rfc822_tokenize_get_string(ctx,
+ rfc822_tokenize_get_string(ctx,
route, NULL, stop_tokens_addr_route);
if (rfc822_tokenize_get(ctx) == ':') {
/* mailbox comes next */
- (void)rfc822_tokenize_get_string(ctx,
+ rfc822_tokenize_get_string(ctx,
mailbox, NULL,
stop_tokens_addr_mailbox);
}
@@ -171,7 +171,7 @@
if (rfc822_tokenize_get(ctx) == '@') {
/* domain */
- (void)rfc822_tokenize_get_string(ctx,
+ rfc822_tokenize_get_string(ctx,
domain, NULL, stop_tokens_addr_domain);
}
Index: rfc822-date.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/rfc822-date.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- rfc822-date.c 3 Jan 2003 15:57:12 -0000 1.9
+++ rfc822-date.c 4 Jan 2003 13:22:29 -0000 1.10
@@ -91,9 +91,7 @@
{
Rfc822Token token;
- (void)rfc822_tokenize_next(ctx);
-
- token = rfc822_tokenize_get(ctx);
+ token = rfc822_tokenize_next(ctx);
if (token == 'A')
*value = rfc822_tokenize_get_value(ctx, value_len);
return token;
Index: rfc822-tokenize.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/rfc822-tokenize.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rfc822-tokenize.c 3 Jan 2003 15:57:12 -0000 1.7
+++ rfc822-tokenize.c 4 Jan 2003 13:22:29 -0000 1.8
@@ -25,15 +25,19 @@
#define PARSE_ERROR() \
STMT_START { \
if (ctx->error_func != NULL && \
- !ctx->error_func(data, i, '\0', ctx->error_context)) \
- return FALSE; \
+ !ctx->error_func(data, i, '\0', ctx->error_context)) { \
+ ctx->token = TOKEN_LAST; \
+ return TOKEN_LAST; \
+ } \
} STMT_END
#define PARSE_ERROR_MISSING(c) \
STMT_START { \
if (ctx->error_func != NULL && \
- !ctx->error_func(data, i, c, ctx->error_context)) \
- return FALSE; \
+ !ctx->error_func(data, i, c, ctx->error_context)) { \
+ ctx->token = TOKEN_LAST; \
+ return TOKEN_LAST; \
+ } \
} STMT_END
@@ -72,14 +76,14 @@
ctx->dot_token = set;
}
-int rfc822_tokenize_next(Rfc822TokenizeContext *ctx)
+Rfc822Token rfc822_tokenize_next(Rfc822TokenizeContext *ctx)
{
int token, level, last_atom;
const char *data;
size_t i, size;
if (ctx->token == TOKEN_LAST)
- return FALSE;
+ return TOKEN_LAST;
data = ctx->data;
size = ctx->size;
@@ -259,11 +263,11 @@
if (ctx->token == TOKEN_LAST && ctx->in_bracket &&
ctx->error_func != NULL) {
- if (!ctx->error_func(data, i, '>', ctx->error_context))
- return FALSE;
+ if (ctx->error_func(data, i, '>', ctx->error_context))
+ ctx->token = TOKEN_LAST;
}
- return TRUE;
+ return ctx->token;
}
Rfc822Token rfc822_tokenize_get(const Rfc822TokenizeContext *ctx)
@@ -280,9 +284,9 @@
return ctx->data + ctx->token_pos;
}
-int rfc822_tokenize_get_string(Rfc822TokenizeContext *ctx,
- String *str, String *comments,
- const Rfc822Token *stop_tokens)
+void rfc822_tokenize_get_string(Rfc822TokenizeContext *ctx,
+ String *str, String *comments,
+ const Rfc822Token *stop_tokens)
{
Rfc822Token token;
const char *value;
@@ -290,14 +294,10 @@
int i, token_str, last_str;
last_str = FALSE;
- while (rfc822_tokenize_next(ctx)) {
- token = rfc822_tokenize_get(ctx);
- if (token == TOKEN_LAST)
- return TRUE;
-
+ while ((token = rfc822_tokenize_next(ctx)) != TOKEN_LAST) {
for (i = 0; stop_tokens[i] != TOKEN_LAST; i++)
if (token == stop_tokens[i])
- return TRUE;
+ return;
if (token == TOKEN_COMMENT) {
/* handle comment specially */
@@ -341,6 +341,4 @@
last_str = token_str;
}
-
- return FALSE;
}
Index: rfc822-tokenize.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/rfc822-tokenize.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- rfc822-tokenize.h 3 Jan 2003 15:57:12 -0000 1.8
+++ rfc822-tokenize.h 4 Jan 2003 13:22:29 -0000 1.9
@@ -45,13 +45,10 @@
/* Specify whether '.' should be treated as a separate token (default yes). */
void rfc822_tokenize_dot_token(Rfc822TokenizeContext *ctx, int set);
-/* Parse the next token. Returns FALSE if parsing error occured and error
- function wanted to abort. It's not required to check the return value,
- rfc822_tokenize_get() will return TOKEN_LAST after errors. Returns FALSE
- also when last token was already read. */
-int rfc822_tokenize_next(Rfc822TokenizeContext *ctx);
+/* Parse the next token and return it. */
+Rfc822Token rfc822_tokenize_next(Rfc822TokenizeContext *ctx);
-/* Return the next token. */
+/* Return the current token. */
Rfc822Token rfc822_tokenize_get(const Rfc822TokenizeContext *ctx);
/* - not including enclosing "", () or []
@@ -60,11 +57,10 @@
const char *rfc822_tokenize_get_value(const Rfc822TokenizeContext *ctx,
size_t *len);
-/* Return tokens as a string, all quoted strings will be unquoted.
- Reads until stop_token is found. Returns FALSE if rfc822_tokenize_next()
- failed. */
-int rfc822_tokenize_get_string(Rfc822TokenizeContext *ctx,
- String *str, String *comments,
- const Rfc822Token *stop_tokens);
+/* Read tokens as a string, all quoted strings will be unquoted.
+ Reads until stop_token is found. */
+void rfc822_tokenize_get_string(Rfc822TokenizeContext *ctx,
+ String *str, String *comments,
+ const Rfc822Token *stop_tokens);
#endif
- Previous message: [dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c,1.25,1.26
- Next message: [dovecot-cvs] dovecot/src/lib imem.c,1.5,1.6 imem.h,1.5,1.6 istream-data.c,1.1,1.2 istream.h,1.1,1.2 str.c,1.5,1.6 str.h,1.1,1.2 strescape.c,1.1,1.2 strescape.h,1.1,1.2 strfuncs.c,1.26,1.27 strfuncs.h,1.14,1.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list