1 
2 #ifndef EL__PROTOCOL_NNTP_CONNECTION_H
3 #define EL__PROTOCOL_NNTP_CONNECTION_H
4 
5 #include "protocol/nntp/codes.h"
6 #include "protocol/protocol.h"
7 #include "util/string.h"
8 
9 /* An NNTP target is a mapping from a given URI which in short form tells what
10  * the URI describes. Using the following tokens:
11  *
12  *	<group>			the name of the newsgroup
13  *	<message-id>		<unique>@<full_domain_name>
14  *	<article-number>	a numeric id of the article within the group
15  *	<article-range>		<start-number>-<end-number>
16  *
17  * The nntp:// URI syntax is resolved like this:
18  *
19  *	nntp://<server>/			 - NNTP_TARGET_GROUPS
20  *	nntp://<server>/<message-id>		 - NNTP_TARGET_MESSAGE_ID
21  *	nntp://<server>/<group>			 - NNTP_TARGET_GROUP
22  *	nntp://<server>/<group>/		 - NNTP_TARGET_GROUP
23  *	nntp://<server>/<group>/<article-number> - NNTP_TARGET_ARTICLE_NUMBER
24  *	nntp://<server>/<group>/<article-range>  - NNTP_TARGET_ARTICLE_RANGE
25  *	nntp://<server>/<group>/<message-id>	 - NNTP_TARGET_GROUP_MESSAGE_ID
26  */
27 
28 /* NNTP targets */
29 enum nntp_target {
30 	NNTP_TARGET_GROUPS,		/* List groups available */
31 	NNTP_TARGET_MESSAGE_ID,		/* Get <message-id> */
32 	NNTP_TARGET_GROUP,		/* List messages in <group> */
33 	NNTP_TARGET_ARTICLE_NUMBER,	/* Get <article-number> from <group> */
34 	NNTP_TARGET_ARTICLE_RANGE,	/* Get <article-range> from <group> */
35 	NNTP_TARGET_GROUP_MESSAGE_ID,	/* Get <message-id> from <group> */
36 	NNTP_TARGET_QUIT,		/* Special target for shutting down */
37 };
38 
39 /* NNTP command identifiers */
40 enum nntp_command {
41 	NNTP_COMMAND_NONE,		/* No command currently in progress */
42 	NNTP_COMMAND_QUIT,		/* QUIT */
43 	NNTP_COMMAND_GROUP,		/* GROUP <group> */
44 	NNTP_COMMAND_ARTICLE_NUMBER,	/* ARTICLE <article-number> */
45 	NNTP_COMMAND_ARTICLE_MESSAGE_ID,/* ARTICLE <message-id> */
46 	NNTP_COMMAND_LIST_NEWSGROUPS,	/* LIST NEWSGROUP */
47 	NNTP_COMMAND_LIST_ARTICLES,	/* XOVER or HEAD for each article */
48 };
49 
50 /* This stores info about an active NNTP connection */
51 struct nntp_connection_info {
52 	/* The target denotes what is the purpose of the connection. What
53 	 * should be requested from the server. */
54 	enum nntp_target target;
55 
56 	/* There's quite a few callbacks involved in requesting the target so
57 	 * to figure out whazzup the ``id'' of the current running command is
58 	 * saved. */
59 	enum nntp_command command;
60 
61 	/* The current NNTP status or response code received from the server */
62 	enum nntp_code code;
63 
64 	/* Strings pointing into the connection URI. They caches info useful
65 	 * for requesting the target. */
66 
67 	/* The <group> or undefined if target is NNTP_TARGET_GROUPS */
68 	struct string group;
69 
70 	/* Can contain either <message-id>, <article-number> or <article-range>
71 	 * or undefined if target is NTTP_TARGET_{GROUP,GROUPS}. */
72 	/* For <article-range> it contains start and end numbers as well as the
73 	 * separating '-'. */
74 	struct string message;
75 
76 	/* State for getting articles in a <group> or an <article-range> */
77 	long current_article, end_article, articles;
78 
79 	/* When listing articles in a <group> using the XOVER command is
80 	 * preferred however not all news servers support XOVER so ... */
81 	unsigned int xover_unsupported:1;
82 };
83 
84 #ifdef CONFIG_NNTP
85 extern protocol_handler_T nntp_protocol_handler;
86 extern protocol_handler_T news_protocol_handler;
87 #else
88 #define nntp_protocol_handler NULL
89 #define news_protocol_handler NULL
90 #endif
91 
92 #endif
93