summaryrefslogtreecommitdiffabout
authorAlain Magloire <alainm@gnu.org>2004-06-21 03:22:17 (GMT)
committer Alain Magloire <alainm@gnu.org>2004-06-21 03:22:17 (GMT)
commit631effe4bb766bb5174fb5bf5f64208f06ea88ec (patch) (side-by-side diff)
tree268cb87d184f0e7abf07863a5e44f232a325b203
parent8bc0b928960a6d2bd6fce525b43836e5eaaff77f (diff)
downloadmailutils-631effe4bb766bb5174fb5bf5f64208f06ea88ec.tar.gz
mailutils-631effe4bb766bb5174fb5bf5f64208f06ea88ec.tar.bz2
new Macros and declarations.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/mailutils/nntp.h53
-rw-r--r--include/mailutils/sys/nntp.h53
2 files changed, 82 insertions, 24 deletions
diff --git a/include/mailutils/nntp.h b/include/mailutils/nntp.h
index 18eeeda..9dfede4 100644
--- a/include/mailutils/nntp.h
+++ b/include/mailutils/nntp.h
@@ -28,36 +28,51 @@ extern "C" {
struct _mu_nntp;
typedef struct _mu_nntp* mu_nntp_t;
-extern int mu_nntp_create (mu_nntp_t *nntp);
-extern void mu_nntp_destroy (mu_nntp_t *nntp);
+extern int mu_nntp_create (mu_nntp_t *nntp);
+extern void mu_nntp_destroy (mu_nntp_t *nntp);
-extern int mu_nntp_set_carrier (mu_nntp_t nntp, stream_t carrier);
-extern int mu_nntp_get_carrier (mu_nntp_t nntp, stream_t *pcarrier);
+extern int mu_nntp_set_carrier (mu_nntp_t nntp, stream_t carrier);
+extern int mu_nntp_get_carrier (mu_nntp_t nntp, stream_t *pcarrier);
-extern int mu_nntp_connect (mu_nntp_t nntp);
-extern int mu_nntp_disconnect (mu_nntp_t nntp);
+extern int mu_nntp_connect (mu_nntp_t nntp);
+extern int mu_nntp_disconnect (mu_nntp_t nntp);
-extern int mu_nntp_set_timeout (mu_nntp_t nntp, int timeout);
-extern int mu_nntp_get_timeout (mu_nntp_t nntp, int *timeout);
+extern int mu_nntp_set_timeout (mu_nntp_t nntp, int timeout);
+extern int mu_nntp_get_timeout (mu_nntp_t nntp, int *timeout);
-extern int mu_nntp_set_debug (mu_nntp_t nntp, mu_debug_t debug);
+extern int mu_nntp_set_debug (mu_nntp_t nntp, mu_debug_t debug);
-extern int mu_nntp_stls (mu_nntp_t nntp);
+extern int mu_nntp_stls (mu_nntp_t nntp);
-extern int mu_nntp_article (mu_nntp_t nntp, unsigned long num, unsigned long *pnum, char **mid, stream_t *stream);
-extern int mu_nntp_article_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid, stream_t *stream);
+extern int mu_nntp_mode_reader (mu_nntp_t nntp);
-extern int mu_nntp_head (mu_nntp_t nntp, unsigned long num, unsigned long *pnum, char **mid, stream_t *stream);
-extern int mu_nntp_head_id (mu_nntp_t nntp, const char *name, unsigned long *pnum, char **mid, stream_t *stream);
+/* A list is return with the multi-line answer. It is the responsability of
+ the caller to call list_destroy() to dipose of the list. */
+extern int mu_nntp_list_extensions (mu_nntp_t nntp, list_t *plist);
-extern int mu_nntp_body (mu_nntp_t nntp, unsigned long num, unsigned long *pnum, char **mid, stream_t *stream);
-extern int mu_nntp_body_id (mu_nntp_t nntp, const char *name, unsigned long *pnum, char **mid, stream_t *stream);
+extern int mu_nntp_quit (mu_nntp_t nntp);
-extern int mu_nntp_stat (mu_nntp_t nntp, unsigned long num, char **id);
-extern int mu_nntp_stat_id (mu_nntp_t nntp, const char *name, char **id);
+extern int mu_nntp_group (mu_nntp_t nntp, const char *group, unsigned long *total, unsigned long *first,
+ unsigned long *last, char **name);
-extern int mu_nntp_group (mu_nntp_t nntp, const char *group, long *total, long *first, long *last, char **name);
+extern int mu_nntp_last (mu_nntp_t nntp, unsigned long *number, char **mid);
+extern int mu_nntp_next (mu_nntp_t nntp, unsigned long *number, char **mid);
+
+extern int mu_nntp_article (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream);
+extern int mu_nntp_article_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid, stream_t *stream);
+
+extern int mu_nntp_head (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream);
+extern int mu_nntp_head_id (mu_nntp_t nntp, const char *name, unsigned long *pnum, char **mid, stream_t *stream);
+
+extern int mu_nntp_body (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream);
+extern int mu_nntp_body_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid, stream_t *stream);
+
+extern int mu_nntp_stat (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid);
+extern int mu_nntp_stat_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid);
+
+extern int mu_nntp_date (mu_nntp_t nntp, unsigned int *year, unsigned int *month, unsigned int *day,
+ unsigned int *hour, unsigned int *minute, unsigned int *second);
/* Reads the multi-line response of the server, nread will be 0 when the termination octets
diff --git a/include/mailutils/sys/nntp.h b/include/mailutils/sys/nntp.h
index 705e71f..74c451d 100644
--- a/include/mailutils/sys/nntp.h
+++ b/include/mailutils/sys/nntp.h
@@ -30,15 +30,46 @@
extern "C" {
#endif
+/* Response codes. */
+
+#define MU_NNTP_RESP_CODE_SERVER_DATE 111
+
+#define MU_NNTP_RESP_CODE_POSTING_ALLOWED 200
+#define MU_NNTP_RESP_CODE_POSTING_PROHIBITED 201
+#define MU_NNTP_RESP_CODE_LIST_FOLLOW 202
+
+#define MU_NNTP_RESP_CODE_CLOSING 205
+#define MU_NNTP_RESP_CODE_GROUP_SELECTED 211
+
+#define MU_NNTP_RESP_CODE_ARTICLE_FOLLOW 220
+#define MU_NNTP_RESP_CODE_HEAD_FOLLOW 221
+#define MU_NNTP_RESP_CODE_BODY_FOLLOW 222
+#define MU_NNTP_RESP_CODE_ARTICLE_FOUND 223
+
+#define MU_NNTP_RESP_CODE_TEMP_UNAVAILABLE 400
+#define MU_NNTP_RESP_CODE_NO_EXTENSION 402
+#define MU_NNTP_RESP_CODE_NO_ARTICLE_WITH_MID 430
+#define MU_NNTP_RESP_CODE_NO_GROUP_SELECTED 412
+#define MU_NNTP_RESP_CODE_NUMBER_INVALID 420
+#define MU_NNTP_RESP_CODE_NO_ARTICLE 422
+#define MU_NNTP_RESP_CODE_NO_ARTICLE_IN_RANGE 423
+#define MU_NNTP_RESP_CODE_PERM_UNAVAILABLE 502
+
enum mu_nntp_state
{
MU_NNTP_NO_STATE,
MU_NNTP_CONNECT, MU_NNTP_GREETINGS,
+ MU_NNTP_MODE_READER, MU_NNTP_MODE_READER_ACK,
+ MU_NNTP_LIST_EXTENSIONS, MU_NNTP_LIST_EXTENSIONS_ACK, MU_NNTP_LIST_EXTENSIONS_RX,
+ MU_NNTP_QUIT, MU_NNTP_QUIT_ACK,
+ MU_NNTP_GROUP, MU_NNTP_GROUP_ACK,
+ MU_NNTP_LAST, MU_NNTP_LAST_ACK,
+ MU_NNTP_NEXT, MU_NNTP_NEXT_ACK,
MU_NNTP_ARTICLE, MU_NNTP_ARTICLE_ACK, MU_NNTP_ARTICLE_RX,
MU_NNTP_HEAD, MU_NNTP_HEAD_ACK, MU_NNTP_HEAD_RX,
MU_NNTP_BODY, MU_NNTP_BODY_ACK, MU_NNTP_BODY_RX,
MU_NNTP_STAT, MU_NNTP_STAT_ACK,
- MU_NNTP_STLS, MU_NNTP_STLS_ACK, MU_NNTP_STLS_CONNECT,
+ MU_NNTP_DATE, MU_NNTP_DATE_ACK,
MU_NNTP_DONE, MU_NNTP_UNKNOWN, MU_NNTP_ERROR
};
@@ -79,8 +110,9 @@ struct _mu_nntp
extern int mu_nntp_debug_cmd (mu_nntp_t);
extern int mu_nntp_debug_ack (mu_nntp_t);
-extern int mu_nntp_stream_create (mu_nntp_t pop3, stream_t *pstream);
+extern int mu_nntp_stream_create (mu_nntp_t nntp, stream_t *pstream);
extern int mu_nntp_carrier_is_ready (stream_t carrier, int flag, int timeout);
+extern int mu_nntp_parse_article (mu_nntp_t nntp, int code, unsigned long *pnum, char **mid);
/* Check for non recoverable error.
The error is consider not recoverable if not part of the signal set:
@@ -118,12 +150,23 @@ do \
} \
while (0)
-/* Check if we got "2xx". In NNTP protocol and ack of "2xx" means the command was successfull.
+/* Check if we got the rigth. In NNTP protocol and ack of "2xx" means the command was completed.
*/
-#define MU_NNTP_CHECK_OK(nntp) \
+#define MU_NNTP_CHECK_CODE(nntp, code) \
+do \
+ { \
+ if (mu_nntp_response_code (nntp) == code) \
+ { \
+ nntp->state = MU_NNTP_NO_STATE; \
+ return EACCES; \
+ } \
+ } \
+while (0)
+
+#define MU_NNTP_CHECK_CODE2(nntp, code1, code2) \
do \
{ \
- if (nntp->ack.buf[0] != '2') \
+ if (mu_nntp_response_code (nntp) == code1 || mu_nntp_response_code (nntp) == code2) \
{ \
nntp->state = MU_NNTP_NO_STATE; \
return EACCES; \

Return to:

Send suggestions and report system problems to the System administrator.