diff options
author | Alain Magloire <alainm@gnu.org> | 2004-06-29 05:27:38 +0000 |
---|---|---|
committer | Alain Magloire <alainm@gnu.org> | 2004-06-29 05:27:38 +0000 |
commit | bbd4ad3ed95a04cda63edcde8c56874530c33cd6 (patch) | |
tree | 9661fb92089585a0dc3932a3106bd7f54aec4991 /include | |
parent | 97c62c3306780d1e1f1a0ef57791a1a6534e8d22 (diff) | |
download | mailutils-bbd4ad3ed95a04cda63edcde8c56874530c33cd6.tar.gz mailutils-bbd4ad3ed95a04cda63edcde8c56874530c33cd6.tar.bz2 |
mailutils/nntp.h mailutils/sys/nntp.h
new declarations.
Diffstat (limited to 'include')
-rw-r--r-- | include/mailutils/nntp.h | 83 | ||||
-rw-r--r-- | include/mailutils/sys/nntp.h | 115 |
2 files changed, 157 insertions, 41 deletions
diff --git a/include/mailutils/nntp.h b/include/mailutils/nntp.h index 9dfede4f5..4b2ff027a 100644 --- a/include/mailutils/nntp.h +++ b/include/mailutils/nntp.h | |||
@@ -48,36 +48,111 @@ extern int mu_nntp_stls (mu_nntp_t nntp); | |||
48 | extern int mu_nntp_mode_reader (mu_nntp_t nntp); | 48 | extern int mu_nntp_mode_reader (mu_nntp_t nntp); |
49 | 49 | ||
50 | /* A list is return with the multi-line answer. It is the responsability of | 50 | /* A list is return with the multi-line answer. It is the responsability of |
51 | the caller to call list_destroy() to dipose of the list. */ | 51 | the caller to call list_destroy() to dispose of the list. */ |
52 | extern int mu_nntp_list_extensions (mu_nntp_t nntp, list_t *plist); | 52 | extern int mu_nntp_list_extensions (mu_nntp_t nntp, list_t *plist); |
53 | 53 | ||
54 | extern int mu_nntp_quit (mu_nntp_t nntp); | 54 | extern int mu_nntp_quit (mu_nntp_t nntp); |
55 | 55 | ||
56 | /* The argument name is allocated with malloc(3). The caller is responsable to call free(3) */ | ||
56 | extern int mu_nntp_group (mu_nntp_t nntp, const char *group, unsigned long *total, unsigned long *first, | 57 | extern int mu_nntp_group (mu_nntp_t nntp, const char *group, unsigned long *total, unsigned long *first, |
57 | unsigned long *last, char **name); | 58 | unsigned long *last, char **name); |
58 | 59 | ||
60 | /* The argument mid is allocated with malloc(3). The caller is responsable to call free(3) */ | ||
59 | extern int mu_nntp_last (mu_nntp_t nntp, unsigned long *number, char **mid); | 61 | extern int mu_nntp_last (mu_nntp_t nntp, unsigned long *number, char **mid); |
60 | extern int mu_nntp_next (mu_nntp_t nntp, unsigned long *number, char **mid); | 62 | extern int mu_nntp_next (mu_nntp_t nntp, unsigned long *number, char **mid); |
61 | 63 | ||
64 | /* The argument mid is allocated with malloc(3). The caller is responsable to call free(3). | ||
65 | The caller must call stream_destoy() when done, no other commands are permitted until the stream is destroyed. */ | ||
62 | extern int mu_nntp_article (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream); | 66 | extern int mu_nntp_article (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream); |
63 | extern int mu_nntp_article_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid, stream_t *stream); | 67 | extern int mu_nntp_article_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid, stream_t *stream); |
64 | |||
65 | extern int mu_nntp_head (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream); | 68 | extern int mu_nntp_head (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream); |
66 | extern int mu_nntp_head_id (mu_nntp_t nntp, const char *name, unsigned long *pnum, char **mid, stream_t *stream); | 69 | extern int mu_nntp_head_id (mu_nntp_t nntp, const char *name, unsigned long *pnum, char **mid, stream_t *stream); |
67 | |||
68 | extern int mu_nntp_body (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream); | 70 | extern int mu_nntp_body (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid, stream_t *stream); |
69 | extern int mu_nntp_body_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid, stream_t *stream); | 71 | extern int mu_nntp_body_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid, stream_t *stream); |
70 | 72 | ||
73 | /* The argument mid is allocated with malloc(3). The caller is responsable to call free(3) */ | ||
71 | extern int mu_nntp_stat (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid); | 74 | extern int mu_nntp_stat (mu_nntp_t nntp, unsigned long number, unsigned long *pnum, char **mid); |
72 | extern int mu_nntp_stat_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid); | 75 | extern int mu_nntp_stat_id (mu_nntp_t nntp, const char *id, unsigned long *pnum, char **mid); |
73 | 76 | ||
74 | extern int mu_nntp_date (mu_nntp_t nntp, unsigned int *year, unsigned int *month, unsigned int *day, | 77 | extern int mu_nntp_date (mu_nntp_t nntp, unsigned int *year, unsigned int *month, unsigned int *day, |
75 | unsigned int *hour, unsigned int *minute, unsigned int *second); | 78 | unsigned int *hour, unsigned int *minute, unsigned int *second); |
76 | 79 | ||
80 | /* The caller must call stream_destoy() when done, no other commands are permitted until the stream is destroyed. */ | ||
81 | extern int mu_nntp_help (mu_nntp_t nntp, stream_t *stream); | ||
82 | |||
83 | |||
84 | /* A list is return with the multi-line answer. It is the responsability of | ||
85 | the caller to call list_destroy() to dispose of the list. */ | ||
86 | extern int mu_nntp_newgroups (mu_nntp_t nntp, unsigned int year, unsigned int month, unsigned int day, | ||
87 | unsigned int hour, unsigned int minute, unsigned int second, int is_gmt, list_t *plist); | ||
88 | /* A list is return with the multi-line answer. It is the responsability of | ||
89 | the caller to call list_destroy() to dispose of the list. */ | ||
90 | extern int mu_nntp_newnews (mu_nntp_t nntp, const char *wildmat, unsigned int year, unsigned int month, unsigned int day, | ||
91 | unsigned int hour, unsigned int minute, unsigned int second, int is_gmt, list_t *plist); | ||
92 | |||
93 | extern int mu_nntp_post (mu_nntp_t nntp, stream_t stream); | ||
94 | extern int mu_nntp_ihave (mu_nntp_t nntp, const char *mid, stream_t stream); | ||
95 | |||
96 | |||
97 | /* A list is return with the multi-line answer. It is the responsability of | ||
98 | the caller to call list_destroy() to dispose of the list. */ | ||
99 | extern int mu_nntp_list_active (mu_nntp_t nntp, const char *wildmat, list_t *plist); | ||
100 | extern int mu_nntp_list_active_times (mu_nntp_t nntp, const char *wildmat, list_t *plist); | ||
101 | extern int mu_nntp_list_distributions (mu_nntp_t nntp, const char *wildmat, list_t *plist); | ||
102 | extern int mu_nntp_list_distrib_pats (mu_nntp_t nntp, list_t *plist); | ||
103 | extern int mu_nntp_list_newsgroups (mu_nntp_t nntp, const char *wildmat, list_t *plist); | ||
104 | |||
105 | |||
106 | /* Parse the list active response. | ||
107 | "group high low status" | ||
108 | group: is the name of the group | ||
109 | high: high wather mark | ||
110 | low: low water mark | ||
111 | status: current status | ||
112 | 'y': posting is permitted | ||
113 | 'm': posting is not permitted | ||
114 | 'm': postings will be moderated | ||
115 | |||
116 | The argument group is allocated with malloc(3). The caller is responsable to call free(3). | ||
117 | */ | ||
118 | extern int mu_nntp_parse_list_active (const char *buffer, char **group, unsigned long *high, unsigned long *low, char *status); | ||
119 | extern int mu_nntp_parse_newgroups (const char *buffer, char **group, unsigned long *high, unsigned long *low, char *status); | ||
120 | /* Parse the list active.times response. | ||
121 | "group time creator" | ||
122 | group: is the name of the group | ||
123 | time: measure in seconds since Jan 1 1970 | ||
124 | creator: entity taht created the newsgroup | ||
125 | |||
126 | The argument group/creator is allocated with malloc(3). The caller is responsable to call free(3). | ||
127 | */ | ||
128 | extern int mu_nntp_parse_list_active_times (const char *buffer, char **group, unsigned long *time, char **creator); | ||
129 | /* Parse the list distributions response. | ||
130 | "key value" | ||
131 | key: field key. | ||
132 | value: short explaination of key | ||
133 | |||
134 | The argument key/value is allocated with malloc(3). The caller is responsable to call free(3). | ||
135 | */ | ||
136 | extern int mu_nntp_parse_list_distributions (const char *buffer, char **key, char **value); | ||
137 | /* Parse the list distributions response. | ||
138 | "weight:wildmat:distrib" | ||
139 | weight: | ||
140 | wildmat: | ||
141 | distrib: | ||
142 | |||
143 | The argument wildmat/distrib is allocated with malloc(3). The caller is responsable to call free(3). | ||
144 | */ | ||
145 | extern int mu_nntp_parse_list_distrib_pats (const char *buffer, unsigned long *weight, char **wildmat, char **distrib); | ||
146 | /* Parse the list distributions response. | ||
147 | "group description" | ||
148 | |||
149 | The argument group/description is allocated with malloc(3). The caller is responsable to call free(3). | ||
150 | */ | ||
151 | extern int mu_nntp_parse_list_newsgroups (const char *buffer, char **group, char **description); | ||
77 | 152 | ||
78 | /* Reads the multi-line response of the server, nread will be 0 when the termination octets | 153 | /* Reads the multi-line response of the server, nread will be 0 when the termination octets |
79 | are detected. Clients should not use this function unless they are sending direct command. */ | 154 | are detected. Clients should not use this function unless they are sending direct command. */ |
80 | extern int mu_nntp_readline (mu_nntp_t nntp, char *buffer, size_t buflen, size_t *nread); | 155 | extern int mu_nntp_readline (mu_nntp_t nntp, char *buffer, size_t buflen, size_t *nread); |
81 | 156 | ||
82 | /* Returns the last command acknowledge. If the server supports RESP-CODE, the message | 157 | /* Returns the last command acknowledge. If the server supports RESP-CODE, the message |
83 | could be retrieve, but it is up the caller to do the parsing. */ | 158 | could be retrieve, but it is up the caller to do the parsing. */ |
diff --git a/include/mailutils/sys/nntp.h b/include/mailutils/sys/nntp.h index 74c451dd3..ba3da718f 100644 --- a/include/mailutils/sys/nntp.h +++ b/include/mailutils/sys/nntp.h | |||
@@ -32,45 +32,72 @@ extern "C" { | |||
32 | 32 | ||
33 | /* Response codes. */ | 33 | /* Response codes. */ |
34 | 34 | ||
35 | #define MU_NNTP_RESP_CODE_SERVER_DATE 111 | 35 | #define MU_NNTP_RESP_CODE_HELP_FOLLOW 100 |
36 | 36 | #define MU_NNTP_RESP_CODE_SERVER_DATE 111 | |
37 | #define MU_NNTP_RESP_CODE_POSTING_ALLOWED 200 | 37 | |
38 | #define MU_NNTP_RESP_CODE_POSTING_PROHIBITED 201 | 38 | #define MU_NNTP_RESP_CODE_POSTING_ALLOWED 200 |
39 | #define MU_NNTP_RESP_CODE_LIST_FOLLOW 202 | 39 | #define MU_NNTP_RESP_CODE_POSTING_PROHIBITED 201 |
40 | 40 | #define MU_NNTP_RESP_CODE_EXTENSIONS_FOLLOW 202 | |
41 | #define MU_NNTP_RESP_CODE_CLOSING 205 | 41 | |
42 | #define MU_NNTP_RESP_CODE_GROUP_SELECTED 211 | 42 | #define MU_NNTP_RESP_CODE_CLOSING 205 |
43 | 43 | #define MU_NNTP_RESP_CODE_GROUP_SELECTED 211 | |
44 | #define MU_NNTP_RESP_CODE_ARTICLE_FOLLOW 220 | 44 | |
45 | #define MU_NNTP_RESP_CODE_HEAD_FOLLOW 221 | 45 | #define MU_NNTP_RESP_CODE_LIST_FOLLOW 215 |
46 | #define MU_NNTP_RESP_CODE_BODY_FOLLOW 222 | 46 | |
47 | #define MU_NNTP_RESP_CODE_ARTICLE_FOUND 223 | 47 | #define MU_NNTP_RESP_CODE_ARTICLE_FOLLOW 220 |
48 | 48 | #define MU_NNTP_RESP_CODE_HEAD_FOLLOW 221 | |
49 | #define MU_NNTP_RESP_CODE_TEMP_UNAVAILABLE 400 | 49 | #define MU_NNTP_RESP_CODE_BODY_FOLLOW 222 |
50 | #define MU_NNTP_RESP_CODE_NO_EXTENSION 402 | 50 | #define MU_NNTP_RESP_CODE_ARTICLE_FOUND 223 |
51 | #define MU_NNTP_RESP_CODE_NO_ARTICLE_WITH_MID 430 | 51 | |
52 | #define MU_NNTP_RESP_CODE_NO_GROUP_SELECTED 412 | 52 | #define MU_NNTP_RESP_CODE_NEWNEWS_FOLLOW 230 |
53 | #define MU_NNTP_RESP_CODE_NUMBER_INVALID 420 | 53 | #define MU_NNTP_RESP_CODE_NEWGROUPS_FOLLOW 231 |
54 | #define MU_NNTP_RESP_CODE_NO_ARTICLE 422 | 54 | #define MU_NNTP_RESP_CODE_TRANSFER_OK 235 |
55 | #define MU_NNTP_RESP_CODE_NO_ARTICLE_IN_RANGE 423 | 55 | |
56 | #define MU_NNTP_RESP_CODE_PERM_UNAVAILABLE 502 | 56 | #define MU_NNTP_RESP_CODE_ARTICLE_RECEIVED 240 |
57 | |||
58 | #define MU_NNTP_RESP_CODE_TRANSFER_ARTICLE 335 | ||
59 | #define MU_NNTP_RESP_CODE_SEND_ARTICLE 340 | ||
60 | |||
61 | #define MU_NNTP_RESP_CODE_TEMP_UNAVAILABLE 400 | ||
62 | #define MU_NNTP_RESP_CODE_NO_EXTENSION 402 | ||
63 | #define MU_NNTP_RESP_CODE_NO_ARTICLE_WITH_MID 430 | ||
64 | #define MU_NNTP_RESP_CODE_NO_GROUP_SELECTED 412 | ||
65 | #define MU_NNTP_RESP_CODE_NUMBER_INVALID 420 | ||
66 | #define MU_NNTP_RESP_CODE_NO_ARTICLE 422 | ||
67 | #define MU_NNTP_RESP_CODE_NO_ARTICLE_IN_RANGE 423 | ||
68 | #define MU_NNTP_RESP_CODE_ARTICLE_NOT_WANTED 435 | ||
69 | #define MU_NNTP_RESP_CODE_TRANSFER_NOT_POSSIBLE 436 | ||
70 | #define MU_NNTP_RESP_CODE_TRANSFER_REJECTED 437 | ||
71 | #define MU_NNTP_RESP_CODE_POSTING_NOT_PERMITTED 440 | ||
72 | #define MU_NNTP_RESP_CODE_POSTING_FAILED 441 | ||
73 | #define MU_NNTP_RESP_CODE_PERM_UNAVAILABLE 502 | ||
57 | 74 | ||
58 | enum mu_nntp_state | 75 | enum mu_nntp_state |
59 | { | 76 | { |
60 | MU_NNTP_NO_STATE, | 77 | MU_NNTP_NO_STATE, |
61 | MU_NNTP_CONNECT, MU_NNTP_GREETINGS, | 78 | MU_NNTP_CONNECT, MU_NNTP_GREETINGS, |
62 | MU_NNTP_MODE_READER, MU_NNTP_MODE_READER_ACK, | 79 | MU_NNTP_MODE_READER, MU_NNTP_MODE_READER_ACK, |
63 | MU_NNTP_LIST_EXTENSIONS, MU_NNTP_LIST_EXTENSIONS_ACK, MU_NNTP_LIST_EXTENSIONS_RX, | 80 | MU_NNTP_LIST_EXTENSIONS, MU_NNTP_LIST_EXTENSIONS_ACK, MU_NNTP_LIST_EXTENSIONS_RX, |
64 | MU_NNTP_QUIT, MU_NNTP_QUIT_ACK, | 81 | MU_NNTP_LIST_ACTIVE, MU_NNTP_LIST_ACTIVE_ACK, MU_NNTP_LIST_ACTIV |