[tin 1.7.x] LIST MOTD

Urs Janßen <[email protected]>
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
the patch below adds LIST MOTD support

--- nntplib.c	2005-04-19 13:42:47.000000000 +0200
+++ nntplib.c	2005-04-27 13:41:51.000000000 +0200
@@ -66,6 +66,7 @@
 	static int server_init(char *machine, const char *cservice, int port, char *text, size_t mlen);
 	static void check_extensions(void);
 	static void close_server(void);
+	static void list_motd(void);
 #	ifdef INET6
 		static int get_tcp6_socket(char *machine, unsigned short port);
 #	else
@@ -1372,6 +1373,15 @@
 	}
 #	endif /* 0 */
 
+	if (!is_reconnect && !batch_mode) {
+		/*
+		 * TODO: if "LIST MOTD" makes it into CAPABILITIES use something
+		 * like
+		 * 	if (have_list_motd || have_list_extensions == NO)
+		 */
+		list_motd();
+	}
+
 	is_reconnect = TRUE;
 
 #endif /* NNTP_ABLE */
@@ -1597,4 +1607,42 @@
 #	endif /* DEBUG */
 	return respcode;
 }
+
+
+static void
+list_motd(
+	void)
+{
+	char *ptr;
+	char buf[NNTP_STRLEN];
+	int i, l = 0;
+
+	buf[0] = '\0';
+	i = new_nntp_command("LIST MOTD", OK_MOTD, buf, sizeof(buf));
+
+	switch (i) {
+	case OK_MOTD: /* ok */
+#	ifdef HAVE_COLOR
+		fcol(tinrc.col_message);
+#	endif /* HAVE_COLOR */
+		while ((ptr = tin_fgets(FAKE_NNTP_FP, FALSE)) != NULL) {
+#	ifdef DEBUG
+			debug_nntp("<<<", ptr);
+#	endif /* DEBUG */
+
+			/* TODO: use some sort of pager? */
+			my_printf("MOTD: %s\n", ptr);
+			l++;
+		}
+#	ifdef HAVE_COLOR
+        fcol(tinrc.col_normal);
+#	endif /* HAVE_COLOR */
+		sleep(l);
+		break;
+
+	default:
+		/* common response codes are 500, 501, 503 */
+		break;
+	}
+}
 #endif /* NNTP_ABLE */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.