include/mail_parser.h
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- EP_HasContent
1 /***************************************
2 $Revision: 1.16 $
3
4 Email Parser module (ep) - wrapping functions to parse email,
5 calling MM and PA. Header file.
6
7 Status: NOT REVUED, TESTED
8
9 ******************/ /******************
10 Filename : mail_parser.h
11 Authors : filippo@ripe.net
12 OSs Tested : Solaris 7
13 ******************/ /******************
14 Copyright (c) 2000 RIPE NCC
15
16 All Rights Reserved
17
18 Permission to use, copy, modify, and distribute this software and its
19 documentation for any purpose and without fee is hereby granted,
20 provided that the above copyright notice appear in all copies and that
21 both that copyright notice and this permission notice appear in
22 supporting documentation, and that the name of the author not be
23 used in advertising or publicity pertaining to distribution of the
24 software without specific, written prior permission.
25
26 THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
27 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
28 AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
29 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
30 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
31 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 ***************************************/
33
34 #ifndef MAIL_PARSER_H
35 #define MAIL_PARSER_H
36
37 /* FP: interface file for EP module */
38
39 #define LINE_LENGTH 1024
40 #define STRING_LENGTH 255
41 #define FILENAME_LENGTH 1024
42
43 #define ERRSTRING strerror (errno)
44
45 #include "gpg.h"
46
47 /* FP : global objects used as and interface with gnuPG */
48
49 /* Pointer to a node of the parsing results tree */
50 typedef struct EPNode *EPNodePtr;
51
52 /* Whole container for a detailed description of a parsed mail message */
53
54 typedef struct MailHeader_Field *Mail_Header_FieldPtr;
55 typedef struct MailHeader_Field {
56 char* field;
57 Mail_Header_FieldPtr next;
58 } Mail_Header_Field;
59
60 typedef struct Mail_Descr {
61 Mail_Header_Field *from;
62 Mail_Header_Field *subject;
63 Mail_Header_Field *date;
64 Mail_Header_Field *message_id;
65 Mail_Header_Field *reply_to;
66 Mail_Header_Field *cc;
67 Mail_Header_Field *content_type;
68 EPNodePtr tree;
69 } EP_Mail_Descr;
70
71 typedef EP_Mail_Descr *EP_Mail_DescrPtr;
72
73 typedef short t_MM_type;
74 typedef unsigned int u32;
75
76 /* The actual node describing a stage of the parsing process */
77 typedef struct EPNode {
78 int nodeID;
79 short isValidPGPSignature;
80 t_MM_type MIMEContentType;
81 char *strMIMEContentType;
82 u32 keyID;
83 char *file;
84 EPNodePtr inner;
85 EPNodePtr next;
86 } EP_mail_node;
87
88 #define EP_HasContent(node) (node->inner == NULL ? 1 : 0)
/* [<][>][^][v][top][bottom][index][help] */
89
90 typedef enum {
91 vS_IS_VALID = 0,
92 vS_IS_NOT_PGP,
93 vS_KO,
94 vS_CRC_ERROR,
95 vS_NO_PUBLIC_KEY,
96 vS_NO_OPENPGP_DATA,
97 vS_NO_IN_FILES,
98 vS_NO_OUT_FILES,
99 vS_TO_BE_PGPVERIFIED,
100 vS_UNABLE_TO_WRITE_FILE,
101 vS_UNMATCHED_PGP_DELIMITERS
102 } verifySignatureRCs;
103
104 /* Tokens are leaves of the parsing tree and thir related
105 informations, Such as: list of keys and deepest level MIME type */
106
107 typedef struct EP_Token *EPTokenPtr;
108 typedef struct EP_TokenKeys *EPTokenKeysPtr;
109
110 typedef struct EP_Token {
111 t_MM_type MIMEContentType;
112 char *file;
113 EPTokenKeysPtr keys;
114 EPTokenPtr next;
115 EPTokenPtr prev;
116 } EPToken;
117
118 typedef struct EP_TokenKeys {
119 short isValidPGPSignature;
120 u32 keyID;
121 EPTokenKeysPtr next;
122 } EPTokenKeys;
123
124
125 #ifdef __cplusplus
126 extern "C" {
127 #endif
128
129 EP_Mail_DescrPtr EP_ParseMail( const char *inputFile,
130 const char *outputPath,
131 const char *keyRing,
132 const char *gpgcmd);
133 EPNodePtr EP_ParseText( const char *inputFile,
134 const char *outputPath,
135 const char *keyRing,
136 const char *gpgcmd);
137 EPNodePtr EP_MIMEParse( const EPNodePtr p);
138 EPNodePtr EP_InitializeRootNode( const char *inputFile );
139 EPNodePtr EP_InitializeNode( const char *inputFile,
140 const int nodeID );
141 EPNodePtr EP_DefineNewNode( const int nodeID,
142 const short isValidPGPSignature,
143 const t_MM_type MIMEContentType,
144 const char *strMIMEContentType,
145 const u32 keyID);
146 void EP_TreeCleanUp( const EPNodePtr ptr);
147 void EP_MailDescrCleanUp( const EP_Mail_DescrPtr ptr);
148 void EP_BuildFilename( const EPNodePtr ptr);
149 void EP_ShowTree( const EPNodePtr p);
150 EPTokenPtr EP_GetTokens(const EPNodePtr p, const EPTokenPtr prev,
151 EPTokenKeysPtr keysList);
152 void EP_PrintTokens(EPTokenPtr head);
153 void EP_CleanTokens(const EPTokenPtr head);
154
155 #ifdef __cplusplus
156 }
157 #endif
158
159 #endif