1 /*
2  * libEtPan! -- a mail stuff library
3  *
4  * Copyright (C) 2001, 2005 - 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 AUTHORS 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 AUTHORS 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: newsnntp_types.h,v 1.15 2006/12/13 18:31:32 hoa Exp $
34  */
35 
36 #ifndef NEWSNNTP_TYPES_H
37 
38 #define NEWSNNTP_TYPES_H
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include <libetpan/libetpan-config.h>
45 #include <libetpan/clist.h>
46 
47 #include <libetpan/mailstream.h>
48 #include <libetpan/mmapstring.h>
49 
50 enum {
51   NEWSNNTP_NO_ERROR = 0,
52   NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_USERNAME=1, /* DEPRECATED, use ERROR instead */
53   NEWSNNTP_ERROR_REQUEST_AUTHORIZATION_USERNAME=1,
54   NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD,
55   NEWSNNTP_ERROR_STREAM,
56   NEWSNNTP_ERROR_UNEXPECTED,
57   NEWSNNTP_ERROR_NO_NEWSGROUP_SELECTED,
58   NEWSNNTP_ERROR_NO_ARTICLE_SELECTED,
59   NEWSNNTP_ERROR_INVALID_ARTICLE_NUMBER,
60   NEWSNNTP_ERROR_ARTICLE_NOT_FOUND,
61   NEWSNNTP_ERROR_UNEXPECTED_RESPONSE,
62   NEWSNNTP_ERROR_INVALID_RESPONSE,
63   NEWSNNTP_ERROR_NO_SUCH_NEWS_GROUP,
64   NEWSNNTP_ERROR_POSTING_NOT_ALLOWED,
65   NEWSNNTP_ERROR_POSTING_FAILED,
66   NEWSNNTP_ERROR_PROGRAM_ERROR,
67   NEWSNNTP_ERROR_NO_PERMISSION,
68   NEWSNNTP_ERROR_COMMAND_NOT_UNDERSTOOD,
69   NEWSNNTP_ERROR_COMMAND_NOT_SUPPORTED,
70   NEWSNNTP_ERROR_CONNECTION_REFUSED,
71   NEWSNNTP_ERROR_MEMORY,
72   NEWSNNTP_ERROR_AUTHENTICATION_REJECTED,
73   NEWSNNTP_ERROR_BAD_STATE,
74   NEWSNNTP_ERROR_SSL,
75   NEWSNNTP_ERROR_AUTHENTICATION_OUT_OF_SEQUENCE,
76 };
77 
78 typedef struct newsnntp newsnntp;
79 
80 struct newsnntp
81 {
82   mailstream * nntp_stream;
83 
84   int nntp_readonly;
85 
86   size_t nntp_progr_rate;
87   progress_function * nntp_progr_fun;
88 
89   MMAPString * nntp_stream_buffer;
90   MMAPString * nntp_response_buffer;
91 
92   char * nntp_response;
93 
94   time_t nntp_timeout;
95 
96   void (* nntp_logger)(newsnntp * session, int log_type, const char * str, size_t size, void * context);
97   void * nntp_logger_context;
98 
99   mailprogress_function * nntp_progress_fun;
100   void * nntp_progress_context;
101 };
102 
103 struct newsnntp_group_info
104 {
105   char * grp_name;
106   uint32_t grp_first;
107   uint32_t grp_last;
108   uint32_t grp_count;
109   char grp_type;
110 };
111 
112 struct newsnntp_group_time {
113   char * grp_name;
114   time_t grp_date;
115   char * grp_email;
116 };
117 
118 struct newsnntp_distrib_value_meaning {
119   char * dst_value;
120   char * dst_meaning;
121 };
122 
123 struct newsnntp_distrib_default_value {
124   uint32_t dst_weight;
125   char * dst_group_pattern;
126   char * dst_value;
127 };
128 
129 struct newsnntp_group_description {
130   char * grp_name;
131   char * grp_description;
132 };
133 
134 struct newsnntp_xhdr_resp_item {
135   uint32_t hdr_article;
136   char * hdr_value;
137 };
138 
139 struct newsnntp_xover_resp_item {
140   uint32_t ovr_article;
141   char * ovr_subject;
142   char * ovr_author;
143   char * ovr_date;
144   char * ovr_message_id;
145   char * ovr_references;
146   size_t ovr_size;
147   uint32_t ovr_line_count;
148   clist * ovr_others;
149 };
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif
156