parse822.h
5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Library Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/**
* Parses syntatic elements defined in RFC 822.
*/
#ifndef _MAILUTILS_PARSE822_H
#define _MAILUTILS_PARSE822_H
#include <mailutils/address.h>
#include <mailutils/mutil.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /*__P */
#ifdef __cplusplus
extern "C" {
#endif
/**
* Reads an RFC822 defined lexical token from an input. All names are
* as close as possible to those used in the extended BNF of the RFC.
*/
/* From RFC 822, 3.3 Lexical Tokens */
extern int parse822_is_char __P ((char c));
extern int parse822_is_digit __P ((char c));
extern int parse822_is_ctl __P ((char c));
extern int parse822_is_space __P ((char c));
extern int parse822_is_htab __P ((char c));
extern int parse822_is_lwsp_char __P ((char c));
extern int parse822_is_special __P ((char c));
extern int parse822_is_atom_char __P ((char c));
extern int parse822_is_q_text __P ((char c));
extern int parse822_is_d_text __P ((char c));
extern int parse822_is_smtp_q __P ((char c));
extern int parse822_skip_crlf __P ((const char** p, const char* e));
extern int parse822_skip_lwsp_char __P ((const char** p, const char* e));
extern int parse822_skip_lwsp __P ((const char** p, const char* e));
extern int parse822_skip_comments __P ((const char** p, const char* e));
extern int parse822_digits __P ((const char** p, const char* e, int min, int max, int* digits));
extern int parse822_special __P ((const char** p, const char* e, char c));
extern int parse822_comment __P ((const char** p, const char* e, char** comment));
extern int parse822_atom __P ((const char** p, const char* e, char** atom));
extern int parse822_quoted_pair __P ((const char** p, const char* e, char** qpair));
extern int parse822_quoted_string __P ((const char** p, const char* e, char** qstr));
extern int parse822_word __P ((const char** p, const char* e, char** word));
extern int parse822_phrase __P ((const char** p, const char* e, char** phrase));
extern int parse822_d_text __P ((const char** p, const char* e, char** dtext));
/* From RFC 822, 6.1 Address Specification Syntax */
extern int parse822_address_list __P ((address_t* a, const char* s));
extern int parse822_mail_box __P ((const char** p, const char* e, address_t* a));
extern int parse822_group __P ((const char** p, const char* e, address_t* a));
extern int parse822_address __P ((const char** p, const char* e, address_t* a));
extern int parse822_route_addr __P ((const char** p, const char* e, address_t* a));
extern int parse822_route __P ((const char** p, const char* e, char** route));
extern int parse822_addr_spec __P ((const char** p, const char* e, address_t* a));
extern int parse822_unix_mbox __P ((const char** p, const char* e, address_t* a));
extern int parse822_local_part __P ((const char** p, const char* e, char** local_part));
extern int parse822_domain __P ((const char** p, const char* e, char** domain));
extern int parse822_sub_domain __P ((const char** p, const char* e, char** sub_domain));
extern int parse822_domain_ref __P ((const char** p, const char* e, char** domain_ref));
extern int parse822_domain_literal __P ((const char** p, const char* e, char** domain_literal));
/* RFC 822 Quoting Functions
* Various elements must be quoted if then contain non-safe characters. What
* characters are allowed depend on the element. The following functions will
* allocate a quoted version of the raw element, it may not actually be
* quoted if no unsafe characters were in the raw string.
*/
extern int parse822_quote_string __P ((char** quoted, const char* raw));
extern int parse822_quote_local_part __P ((char** quoted, const char* raw));
extern int parse822_field_body __P ((const char** p, const char *e, char** fieldbody));
extern int parse822_field_name __P ((const char** p, const char *e, char** fieldname));
/***** From RFC 822, 5.1 Date and Time Specification Syntax *****/
extern int parse822_day __P ((const char** p, const char* e, int* day));
extern int parse822_date __P ((const char** p, const char* e, int* day, int* mon, int* year));
extern int parse822_time __P ((const char** p, const char* e, int* h, int* m, int* s, int* tz, const char** tzname));
extern int parse822_date_time __P ((const char** p, const char* e, struct tm* tm, mu_timezone* tz));
#ifdef __cplusplus
}
#endif
#endif /* _MAILUTILS_PARSE822_H */