tin  2.4.4
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.4.4.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

nntplib.h
Go to the documentation of this file.
1 /*
2  * Project : tin - a Usenet reader
3  * Module : nntplib.h
4  * Author : I.Lea
5  * Created : 1991-04-01
6  * Updated : 2018-02-10
7  * Notes : nntp.h 1.5.11/1.6 with extensions for tin
8  *
9  * Copyright (c) 1991-2020 Iain Lea <iain@bricbrac.de>
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  *
16  * 1. Redistributions of source code must retain the above copyright notice,
17  * this list of conditions and the following disclaimer.
18  *
19  * 2. Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  *
23  * 3. Neither the name of the copyright holder nor the names of its
24  * contributors may be used to endorse or promote products derived from
25  * this software without specific prior written permission.
26  *
27  * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 
41 #ifndef NNTPLIB_H
42 #define NNTPLIB_H 1
43 
44 #ifndef NNTP_SERVER_FILE
45 # define NNTP_SERVER_FILE "/etc/nntpserver"
46 #endif /* !NNTP_SERVER_FILE */
47 
48 #define NNTP_TCP_NAME "nntp"
49 #define NNTP_TCP_PORT "119"
50 
51 /*
52  * # times to try and reconnect to server after timeout
53  */
54 #define NNTP_TRY_RECONNECT 2
55 
56 /*
57  * @(#)Header: nntp.h,v 1.81 92/03/12 02:08:31 sob Exp $
58  *
59  * First digit:
60  *
61  * 1xx Informative message
62  * 2xx Command ok
63  * 3xx Command ok so far, continue
64  * 4xx Command was correct, but couldn't be performed
65  * for some specified reason.
66  * 5xx Command unimplemented, incorrect, or a
67  * program error has occurred.
68  *
69  * Second digit:
70  *
71  * x0x Connection, setup, miscellaneous
72  * x1x Newsgroup selection
73  * x2x Article selection
74  * x3x Distribution
75  * x4x Posting
76  */
77 #if 0 /* unused */
78 # define CHAR_INF '1'
79 # define CHAR_OK '2'
80 # define CHAR_CONT '3'
81 # define CHAR_ERR '4'
82 # define CHAR_FATAL '5'
83 #endif /* 0 */
84 
85 /* TODO: cleanup against RFC 2980, RFC 3977, RFC 4643, RFC 6048, RFC 8054 */
86 #define INF_HELP 100 /* Help text on way */
87 #define INF_CAPABILITIES 101 /* Capability list follows */
88 #define INF_DATE 111 /* yyyymmddhhmmss Server date and time */
89 
90 #define OK_CANPOST 200 /* Hello; you can post */
91 #define OK_NOPOST 201 /* Hello; you can't post */
92 #define OK_EXTENSIONS 202 /* extensions supported follow */
93 #define OK_GOODBYE 205 /* Closing connection */
94 #define OK_COMPRESS 206 /* Compression active */
95 #define OK_GROUP 211 /* Group selected */
96 #define OK_GROUPS 215 /* Newsgroups follow */
97 #define OK_MOTD 215 /* News motd follows */
98 
99 #define OK_ARTICLE 220 /* Article (head & body) follows */
100 #define OK_HEAD 221 /* Head follows */
101 #define OK_XHDR 221 /* headers follow */
102 #define OK_XPAT 221 /* headers follow */
103 #define OK_BODY 222 /* Body follows */
104 #define OK_NOTEXT 223 /* No text sent -- stat, next, last */
105 #define OK_XOVER 224 /* .overview data follows */
106 #define OK_HDR 225 /* headers follow */
107 #define OK_NEWNEWS 230 /* New articles by message-id follow */
108 #define OK_NEWGROUPS 231 /* New newsgroups follow */
109 #define OK_XFERED 235 /* Article transferred successfully */
110 #define OK_POSTED 240 /* Article posted successfully */
111 #define OK_AUTHSYS 280 /* Authorization system ok */
112 #define OK_AUTH 281 /* Authorization (user/pass) ok */
113 #define OK_BIN 282 /* binary data follows */
114 #define OK_LIST 282 /* list follows */
115 #define OK_AUTH_SASL 283 /* authentication accepted (with success data) */
116 
117 #define CONT_XFER 335 /* Continue to send article */
118 #define CONT_POST 340 /* Continue to post article */
119 #define NEED_AUTHINFO 380 /* authorization is required */
120 #define NEED_AUTHDATA 381 /* <type> authorization data required */
121 #define NEED_AUTHDATA_SASL 383 /* continue with SASL exchange */
122 
123 #define ERR_GOODBYE 400 /* Have to hang up for some reason */
124 #define ERR_STATE 401 /* The client must change the state of the connection */
125 #define ERR_COMPRESS 403 /* Unable to activate compression */
126 #define ERR_NOGROUP 411 /* No such newsgroup */
127 #define ERR_NCING 412 /* Not currently in newsgroup */
128 
129 #define ERR_NOCRNT 420 /* No current article selected */
130 #define ERR_NONEXT 421 /* No next article in this group */
131 #define ERR_NOPREV 422 /* No previous article in this group */
132 #define ERR_NOARTIG 423 /* No such article in this group */
133 #define ERR_NOART 430 /* No such article at all */
134 #define ERR_GOTIT 435 /* Already got that article, don't send */
135 #define ERR_XFERFAIL 436 /* Transfer failed */
136 #define ERR_XFERRJCT 437 /* Article rejected, don't resend */
137 #define ERR_NOPOST 440 /* Posting not allowed */
138 #define ERR_POSTFAIL 441 /* Posting failed */
139 #define ERR_NOAUTH 480 /* authorization required for command */
140 #define ERR_AUTHFAIL 481 /* Authentication failed/rejected */
141 #define ERR_AUTHSEQ 482 /* Authentication commands issued out of sequence or SASL protocol error */
142 #define ERR_ENCRYPT 483 /* encrpytion required */
143 
144 #define ERR_COMMAND 500 /* Command not recognized */
145 #define ERR_CMDSYN 501 /* Command syntax error */
146 #define ERR_ACCESS 502 /* Access to server denied */
147 #define ERR_FAULT 503 /* Program fault, command not performed */
148 #define ERR_MOTD 503 /* No news motd file */
149 #define ERR_COMPRESS_ALG 503 /* Compression algorithm not supported */
150 #define ERR_AUTHBAD 580 /* Authorization Failed */
151 
152 /*
153  * RFC 977 defines this; don't change it.
154  */
155 #define NNTP_STRLEN 512
156 /*
157  * RFC 3977 3.1
158  */
159 #define NNTP_GRPLEN 497
160 
161 /*
162  * OVERVIEW.FMT field types
163  */
165 
166 /*
167  * CAPABILITIES
168  * remember to update init.c and nntplib.c:check_extensions() if you change
169  * t_capabilities
170  */
172 
175  SASL_PLAIN = 1 << 0,
176  SASL_CRAM_MD5 = 1 << 1,
177  SASL_DIGEST_MD5 = 1 << 2,
178  SASL_GSSAPI = 1 << 3,
179  SASL_EXTERNAL = 1 << 4,
180  SASL_OTP = 1 << 5,
181  SASL_NTLM = 1 << 6,
182  SASL_LOGIN = 1 << 7
183 };
185 
187  enum extension_type type; /* NONE, CAPABILITIES, BROKEN */
188  unsigned int version; /* CAPABILITIES version */
189  t_bool mode_reader:1; /* MODE-READER: "MODE READER" */
190  t_bool reader:1; /* READER: "ARTICLE", "BODY", "DATE", "GROUP", "LAST", "LISTGROUP", "NEWGROUPS", "NEXT" */
191  t_bool post:1; /* POST */
192  t_bool list_active:1; /* LIST ACTIVE */
193  t_bool list_active_times:1; /* LIST ACTIVE.TIMES, optional */
194  t_bool list_distrib_pats:1; /* LIST DISTRIB.PATS, optional */
195  t_bool list_headers:1; /* LIST HEADERS */
196  char *headers_range; /* list of headers by range */
197  char *headers_id; /* list of headers by id */
198  t_bool list_newsgroups:1; /* LIST NEWSGROUPS */
199  t_bool list_overview_fmt:1; /* LIST OVERVIEW.FMT */
200  t_bool list_motd:1; /* LIST MOTD, "private" extension */
201  t_bool list_subscriptions:1; /* LIST SUBSCRIPTIONS, "private" extension, RFC 2980 */
202  t_bool list_distributions:1; /* LIST DISTRIBUTIONS, "private" extension, RFC 2980 */
203  t_bool list_moderators:1; /* LIST MODERATORS, "private" extension */
204  t_bool list_counts:1; /* LIST COUNTS, "private" extension */
205  t_bool xpat:1; /* XPAT, "private" extension, RFC 2980 */
206  t_bool hdr:1; /* HDR: "HDR", "LIST HEADERS" */
207  const char *hdr_cmd; /* [X]HDR */
208  t_bool over:1; /* OVER: "OVER", "LIST OVERVIEW.FMT" */
209  t_bool over_msgid:1; /* OVER: "OVER mid" */
210  const char *over_cmd; /* [X]OVER */
211  t_bool newnews:1; /* NEWNEWS */
212  char *implementation; /* IMPLEMENTATION */
213  t_bool starttls:1; /* STARTTLS */
214  t_bool authinfo_user:1; /* AUTHINFO USER/PASS */
215  t_bool authinfo_sasl:1; /* AUTHINFO SASL */
216  t_bool authinfo_state:1; /* AUTHINFO not supported in current state */
217  enum sasl_types sasl; /* SASL_NONE, SASL_PLAIN, SASL_CRAM_MD5, SASL_DIGEST_MD5, SASL_GSSAPI, SASL_EXTERNAL, SASL_OTP, SASL_NTLM, SASL_LOGIN */
218  t_bool compress:1; /* COMPRESS */
219  enum c_algorithms compress_algorithm; /* COMPRESS_NONE, COMPRESS_DEFLATE */
220 #if 0
221  t_bool streaming:1; /* STREAMING: "MODE STREAM", "CHECK", "TAKETHIS" */
222  t_bool ihave:1; /* IHAVE: "IHAVE" */
223 #endif /* 0 */
224  t_bool broken_listgroup:1; /* LISTGROUP doesn't select newsgroup */
225 };
226 
227 #endif /* !NNTPLIB_H */
SASL_LOGIN
@ SASL_LOGIN
Definition: nntplib.h:182
t_capabilities::compress
t_bool compress
Definition: nntplib.h:218
t_capabilities::headers_range
char * headers_range
Definition: nntplib.h:196
CAPABILITIES
@ CAPABILITIES
Definition: nntplib.h:171
BROKEN
@ BROKEN
Definition: nntplib.h:171
t_capabilities::authinfo_state
t_bool authinfo_state
Definition: nntplib.h:216
t_capabilities::over_cmd
const char * over_cmd
Definition: nntplib.h:210
t_capabilities::list_active
t_bool list_active
Definition: nntplib.h:192
t_capabilities::type
enum extension_type type
Definition: nntplib.h:187
t_capabilities::list_motd
t_bool list_motd
Definition: nntplib.h:200
OVER_T_FSTRING
@ OVER_T_FSTRING
Definition: nntplib.h:164
t_capabilities::newnews
t_bool newnews
Definition: nntplib.h:211
t_capabilities::headers_id
char * headers_id
Definition: nntplib.h:197
t_capabilities::list_distributions
t_bool list_distributions
Definition: nntplib.h:202
t_capabilities
Definition: nntplib.h:186
t_capabilities::list_counts
t_bool list_counts
Definition: nntplib.h:204
t_capabilities::broken_listgroup
t_bool broken_listgroup
Definition: nntplib.h:224
sasl_types
sasl_types
Definition: nntplib.h:173
SASL_OTP
@ SASL_OTP
Definition: nntplib.h:180
t_capabilities::over
t_bool over
Definition: nntplib.h:208
COMPRESS_DEFLATE
@ COMPRESS_DEFLATE
Definition: nntplib.h:184
t_capabilities::sasl
enum sasl_types sasl
Definition: nntplib.h:217
t_capabilities::hdr_cmd
const char * hdr_cmd
Definition: nntplib.h:207
COMPRESS_NONE
@ COMPRESS_NONE
Definition: nntplib.h:184
OVER_T_STRING
@ OVER_T_STRING
Definition: nntplib.h:164
SASL_EXTERNAL
@ SASL_EXTERNAL
Definition: nntplib.h:179
SASL_DIGEST_MD5
@ SASL_DIGEST_MD5
Definition: nntplib.h:177
SASL_PLAIN
@ SASL_PLAIN
Definition: nntplib.h:175
NONE
@ NONE
Definition: nntplib.h:171
t_capabilities::version
unsigned int version
Definition: nntplib.h:188
t_capabilities::authinfo_user
t_bool authinfo_user
Definition: nntplib.h:214
t_capabilities::list_headers
t_bool list_headers
Definition: nntplib.h:195
c_algorithms
c_algorithms
Definition: nntplib.h:184
OVER_T_INT
@ OVER_T_INT
Definition: nntplib.h:164
SASL_NONE
@ SASL_NONE
Definition: nntplib.h:174
t_capabilities::list_moderators
t_bool list_moderators
Definition: nntplib.h:203
f_type
f_type
Definition: nntplib.h:164
t_capabilities::list_overview_fmt
t_bool list_overview_fmt
Definition: nntplib.h:199
t_capabilities::over_msgid
t_bool over_msgid
Definition: nntplib.h:209
t_capabilities::starttls
t_bool starttls
Definition: nntplib.h:213
t_capabilities::implementation
char * implementation
Definition: nntplib.h:212
SASL_NTLM
@ SASL_NTLM
Definition: nntplib.h:181
t_capabilities::xpat
t_bool xpat
Definition: nntplib.h:205
OVER_T_ERROR
@ OVER_T_ERROR
Definition: nntplib.h:164
t_capabilities::list_subscriptions
t_bool list_subscriptions
Definition: nntplib.h:201
t_capabilities::compress_algorithm
enum c_algorithms compress_algorithm
Definition: nntplib.h:219
t_capabilities::list_distrib_pats
t_bool list_distrib_pats
Definition: nntplib.h:194
t_bool
unsigned t_bool
Definition: bool.h:77
t_capabilities::authinfo_sasl
t_bool authinfo_sasl
Definition: nntplib.h:215
SASL_GSSAPI
@ SASL_GSSAPI
Definition: nntplib.h:178
SASL_CRAM_MD5
@ SASL_CRAM_MD5
Definition: nntplib.h:176
t_capabilities::list_newsgroups
t_bool list_newsgroups
Definition: nntplib.h:198
t_capabilities::hdr
t_bool hdr
Definition: nntplib.h:206
t_capabilities::list_active_times
t_bool list_active_times
Definition: nntplib.h:193
t_capabilities::post
t_bool post
Definition: nntplib.h:191
t_capabilities::reader
t_bool reader
Definition: nntplib.h:190
t_capabilities::mode_reader
t_bool mode_reader
Definition: nntplib.h:189
extension_type
extension_type
Definition: nntplib.h:171