1 /*
2  * libEtPan! -- a mail stuff library
3  *
4  * Copyright (C) 2001, 2002 - DINH Viet Hoa
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the libEtPan! project nor the names of its
16  *    contributors may be used to endorse or promote products derived
17  *    from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 /*
33  * $Id$
34  */
35 
36 #ifndef MAILIMF_WRITE_H
37 
38 #define MAILIMF_WRITE_H
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include <stdio.h>
45 #include "mailimf_types.h"
46 
47 /*
48   mailimf_string_write writes a string to a given stream
49 
50   @param f is the stream
51   @param col (* col) is the column number where we will start to
52     write the text, the ending column will be stored in (* col)
53   @param str is the string to write
54 */
55 
56 int mailimf_string_write(FILE * f, int * col,
57     const char * str, size_t length);
58 
59 
60 /*
61   mailimf_fields_write writes the fields to a given stream
62 
63   @param f is the stream
64   @param col (* col) is the column number where we will start to
65     write the text, the ending column will be stored in (* col)
66   @param fields is the fields to write
67 */
68 
69 int mailimf_fields_write(FILE * f, int * col,
70     struct mailimf_fields * fields);
71 
72 
73 /*
74   mailimf_envelope_fields_write writes only some fields to a given stream
75 
76   @param f is the stream
77   @param col (* col) is the column number where we will start to
78     write the text, the ending column will be stored in (* col)
79   @param fields is the fields to write
80 */
81 
82 int mailimf_envelope_fields_write(FILE * f, int * col,
83     struct mailimf_fields * fields);
84 
85 
86 /*
87   mailimf_field_write writes a field to a given stream
88 
89   @param f is the stream
90   @param col (* col) is the column number where we will start to
91     write the text, the ending column will be stored in (* col)
92   @param field is the field to write
93 */
94 
95 int mailimf_field_write(FILE * f, int * col,
96     struct mailimf_field * field);
97 
98 /*
99   mailimf_quoted_string_write writes a string that is quoted
100   to a given stream
101 
102   @param f is the stream
103   @param col (* col) is the column number where we will start to
104     write the text, the ending column will be stored in (* col)
105   @param string is the string to quote and write
106 */
107 
108 int mailimf_quoted_string_write(FILE * f, int * col,
109     const char * string, size_t len);
110 
111 int mailimf_address_list_write(FILE * f, int * col,
112     struct mailimf_address_list * addr_list);
113 
114 int mailimf_mailbox_list_write(FILE * f, int * col,
115     struct mailimf_mailbox_list * mb_list);
116 
117 /*
118   mailimf_header_string_write writes a header value and fold the header
119     if needed.
120 
121   @param f is the stream
122   @param col (* col) is the column number where we will start to
123     write the text, the ending column will be stored in (* col)
124   @param str is the string to write
125 */
126 
127 int mailimf_header_string_write(FILE * f, int * col,
128     const char * str, size_t length);
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif
135