Implemented the NNTP DATE command.
authorArt Cancro <ajc@uncensored.citadel.org>
Wed, 5 Mar 2014 19:37:01 +0000 (14:37 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Wed, 5 Mar 2014 19:37:01 +0000 (14:37 -0500)
citadel/modules/nntp/serv_nntp.c

index 198261005328147f5f2e03695377f99c9ab74425..f32ce1d733a095a2088cb1a6675dd6c8b563a86d 100644 (file)
@@ -531,6 +531,25 @@ void nntp_help(void) {
 }
 
 
+//
+// Implement DATE command.
+//
+void nntp_date(void) {
+       time_t now;
+       struct tm nowLocal;
+       struct tm nowUtc;
+       char tsFromUtc[32];
+
+       now = time(NULL);
+       localtime_r(&now, &nowLocal);
+       gmtime_r(&now, &nowUtc);
+
+       strftime(tsFromUtc, sizeof(tsFromUtc), "%Y%m%d%H%M%S", &nowUtc);
+
+       cprintf("111 %s\r\n", tsFromUtc);
+}
+
+
 //
 // back end for the LISTGROUP command , called for each message number
 //
@@ -949,6 +968,10 @@ void nntp_command_loop(void)
                nntp_help();
        }
 
+       else if (!strcasecmp(cmdname, "date")) {
+               nntp_date();
+       }
+
        else if (!strcasecmp(cmdname, "capabilities")) {
                nntp_capabilities();
        }