]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/nntp/serv_nntp.c
Global warming is a socialist communist scam.
[citadel.git] / citadel / modules / nntp / serv_nntp.c
index 78043d3fa12eb5f8a85b7a45709e57b545be2e67..3473b49e391e749540fb38b90a50f54302e8474c 100644 (file)
@@ -1,5 +1,5 @@
 //
-// NNTP server module FIXME THIS IS NOT FINISHED
+// NNTP server module (RFC 3977)
 //
 // Copyright (c) 2014 by the citadel.org team
 //
@@ -960,15 +960,58 @@ void nntp_last_next(const char *cmd) {
 }
 
 
+//
+// back end for the XOVER command , called for each message number
+//
+void nntp_xover_backend(long msgnum, void *userdata) {
+
+       struct listgroup_range *lr = (struct listgroup_range *)userdata;
+
+       // check range if supplied
+       if (msgnum < lr->lo) return;
+       if ((lr->hi != 0) && (msgnum > lr->hi)) return;
+
+       cprintf("FIXME %ld FIXME\r\n", msgnum);         // FIXME need to actually show the overview data
+}
+
+
+//
 //
 // XOVER is used by some clients, even if we don't offer it
 //
 void nntp_xover(const char *cmd) {
        if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
 
-       // citnntp *nntpstate = (citnntp *) CC->session_specific_data;
+       citnntp *nntpstate = (citnntp *) CC->session_specific_data;
+       char range[256];
+       struct listgroup_range lr;
+
+       extract_token(range, cmd, 1, ' ', sizeof range);
+       lr.lo = atol(range);
+       if (lr.lo <= 0) {
+               lr.lo = nntpstate->current_article_number;
+               lr.hi = nntpstate->current_article_number;
+       }
+       else {
+               char *dash = strchr(range, '-');
+               if (dash != NULL) {
+                       ++dash;
+                       lr.hi = atol(dash);
+                       if (lr.hi == 0) {
+                               lr.hi = LONG_MAX;
+                       }
+                       if (lr.hi < lr.lo) {
+                               lr.hi = lr.lo;
+                       }
+               }
+               else {
+                       lr.hi = lr.lo;
+               }
+       }
 
-       cprintf("500 not implemented yet FIXME\r\n");
+       cprintf("224 Overview information follows\r\n");
+       CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, nntp_xover_backend, &lr);
+       cprintf(".\r\n");
 }