--- nntp.c 2001/08/01 07:04:13 1.1
+++ nntp.c 2001/08/02 14:58:39 1.2
@@ -55,6 +55,7 @@
nntp_t *nntp_create(int rfd, int wfd, nntp_io_t *io)
{
nntp_t *nntp;
+ char line[NNTP_LINE_MAXLEN];
if ((nntp = (nntp_t *)malloc(sizeof(nntp_t))) == NULL)
return NULL;
@@ -76,6 +77,40 @@
return nntp;
}
+#if 0 //FIXME
+nntp_rc_t nntp_init(nntp_t *nntp)
+{
+ nntp_rc_t rc;
+
+ /* RFC0977 2.4.3. General Responses
+ * In general, 1xx codes may be ignored or displayed as desired; code 200
+ * or 201 is sent upon initial connection to the NNTP server depending
+ * upon posting permission; code 400 will be sent when the NNTP server
+ * discontinues service (by operator request, for example); and 5xx codes
+ * indicate that the command could not be performed for some unusual
+ * reason.
+ *
+ * 1xx text
+ * 200 server ready - posting allowed
+ * 201 server ready - no posting allowed
+ * 400 service discontinued
+ * 500 command not recognized
+ * 501 command syntax error
+ * 502 access restriction or permission denied
+ * 503 program fault - command not performed
+ */
+
+ do {
+ if ((rc = nntp_readline(nntp, line, sizeof(line))) != NNTP_OK)
+ return rc;
+ while (line[0] == '1');
+ if (strncmp(line, "200", 3) == 0)
+ return NNTP_OK;
+
+ return NNTP_ERR_INIT;
+}
+#endif
+
void nntp_destroy(nntp_t *nntp)
{
if (nntp != NULL)
@@ -156,6 +191,46 @@
return rc;
fprintf(stderr, "READ:<%s>\n", line);
+#if 0 //FIXME
+ allservers = x; /* total number of servers specified */
+ deliveries = 0; /* counts successful deliveries */
+ for (i=0; i < allservers; i++) {
+ if (post() == NNTP_OK) {
+ /* check if this server accepts at least one of the newsgroups
+ > GROUP
+ < 211 yes, group exists
+ < 411 no, group doesn't exist
+ */
+
+ /* check if this server already knows that artice
+ > STAT <message-id>
+ < 223 yes, article already known
+ < 430 no, i don't know the article, yet
+ */
+
+ /* post the article
+ > POST
+ < 340 gimme that thing
+ > From: ...
+ > Subject: ...
+ > Newsgroups: ...
+ > Message-ID: <...>
+ > [additional headers]
+ >
+ > [body with dots escaped]
+ > .
+ < 240 ok, thank you
+ < 441 duplicate (ok for us)
+ */
+ }
+ }
+ if (((mode == DELIVERYMODE_MANY) || (mode == DELIVERYMODE_ONCE)) && (deliveries >= 1))
+ rc = NNTP_OK;
+ else if ((mode == DELIVERYMODE_ALL) && (deliveries == allservers))
+ rc = NNTP_OK
+ else
+ rc = NNTP_ERR_POST;
+#endif
return rc;
}
|