Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-mail/message-tokenize.h @ 1000:0fbafade2d85 HEAD
If auth/login process died unexpectedly, the exit status or killing signal
wasn't logged.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 21 Jan 2003 09:58:49 +0200 |
parents | 8028c4dcf38f |
children | 60646878858e |
rev | line source |
---|---|
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 #ifndef __MESSAGE_TOKENIZE_H |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 #define __MESSAGE_TOKENIZE_H |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #define IS_TOKEN_STRING(token) \ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 ((token) == TOKEN_ATOM || (token) == TOKEN_QSTRING || \ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 (token) == TOKEN_COMMENT || (token) == TOKEN_DLITERAL) |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 enum message_token { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 TOKEN_ATOM = 'A', |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 TOKEN_QSTRING = '"', |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 TOKEN_COMMENT = '(', |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 TOKEN_DLITERAL = '[', |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 /* RFC822 specials: |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 '<', '>', '@', ',', ';', ':', '\' |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 '.' (not included in RFC2045 -> optional) |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 RFC2045 tspecials: |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 '/', '?', '=' */ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 TOKEN_LAST = 0 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 }; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 struct message_tokenizer; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 /* Parsing is aborted if returns FALSE. There's two kinds of errors: |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 missing_char == '\0': unexpected character at str[pos] |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 missing_char != '\0': missing character */ |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
921
diff
changeset
|
32 typedef int (*message_tokenize_error_callback_t)(const unsigned char *str, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
921
diff
changeset
|
33 size_t pos, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
921
diff
changeset
|
34 char missing_char, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
921
diff
changeset
|
35 void *context); |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
953
diff
changeset
|
37 /* Initialize message tokenizer. data is parsed until \0 is found, or size |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
953
diff
changeset
|
38 bytes has been parsed, so it's possible to give (size_t)-1 as size |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
953
diff
changeset
|
39 if the string is \0 terminated. */ |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 struct message_tokenizer * |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 message_tokenize_init(const unsigned char *data, size_t size, |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
921
diff
changeset
|
42 message_tokenize_error_callback_t error_cb, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
921
diff
changeset
|
43 void *error_context); |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 void message_tokenize_deinit(struct message_tokenizer *tok); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 /* Specify whether comments should be silently skipped (default yes). */ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 void message_tokenize_skip_comments(struct message_tokenizer *tok, int set); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 /* Specify whether '.' should be treated as a separate token (default yes). */ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 void message_tokenize_dot_token(struct message_tokenizer *tok, int set); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
51 /* Parse the next token and return it. */ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 enum message_token message_tokenize_next(struct message_tokenizer *tok); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 /* Return the current token. */ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 enum message_token message_tokenize_get(const struct message_tokenizer *tok); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 |
921
b9875966b09d
Added message_tokenize_get_parse_position()
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
57 /* Return position in string where we're currently parsing. */ |
b9875966b09d
Added message_tokenize_get_parse_position()
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
58 size_t message_tokenize_get_parse_position(const struct message_tokenizer *tok); |
b9875966b09d
Added message_tokenize_get_parse_position()
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
59 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 /* - not including enclosing "", () or [] |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
61 - '\' isn't expanded |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 - [CR+]LF+LWSP (continued header) isn't removed */ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 const unsigned char * |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 message_tokenize_get_value(const struct message_tokenizer *tok, size_t *len); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 /* Read tokens as a string, all quoted strings will be unquoted. |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 Reads until stop_token is found. */ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 void message_tokenize_get_string(struct message_tokenizer *tok, |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 string_t *str, string_t *comments, |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 const enum message_token *stop_tokens); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 #endif |