strcpy(CC->cs_clientname, "NNTP session");
CC->cs_flags |= CS_STEALTH;
- /* CC->session_specific_data = malloc(sizeof(citnntp));
- memset(NNTP, 0, sizeof(citnntp));
- */
+ CC->session_specific_data = malloc(sizeof(citnntp));
+ citnntp *nntpstate = (citnntp *) CC->session_specific_data;
+ memset(nntpstate, 0, sizeof(citnntp));
if (CC->nologin==1) {
cprintf("451 Too many connections are already open; please try again later.\r\n");
// At this point we know the message number of the "article" being requested.
// We have an awesome API call that does all the heavy lifting for us.
+ char *fetched_message_id = NULL;
CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
int fetch = CtdlOutputMsg(requested_msgnum,
MT_RFC822, // output in RFC822 format ... sort of
NULL, // teh whole thing, not just a section
0, // no flags yet ... maybe new ones for Path: etc ?
NULL,
- NULL
+ NULL,
+ &fetched_message_id // extract the message ID from the message as we go...
);
StrBuf *msgtext = CC->redirect_buffer;
CC->redirect_buffer = NULL;
}
if (acmd == ARTICLE) {
- cprintf("220 %ld <FIXME@FIXME>\r\n", requested_msgnum);
+ cprintf("220 %ld <%s>\r\n", requested_msgnum, fetched_message_id);
}
if (acmd == HEAD) {
- cprintf("221 %ld <FIXME@FIXME>\r\n", requested_msgnum);
+ cprintf("221 %ld <%s>\r\n", requested_msgnum, fetched_message_id);
}
if (acmd == BODY) {
- cprintf("222 %ld <FIXME@FIXME>\r\n", requested_msgnum);
+ cprintf("222 %ld <%s>\r\n", requested_msgnum, fetched_message_id);
}
if (acmd == STAT) {
- cprintf("223 %ld <FIXME@FIXME>\r\n", requested_msgnum);
+ cprintf("223 %ld <%s>\r\n", requested_msgnum, fetched_message_id);
FreeStrBuf(&msgtext);
return;
}
client_write(SKEY(msgtext));
cprintf(".\r\n"); // this protocol uses a dot terminator
FreeStrBuf(&msgtext);
+ if (fetched_message_id) free(fetched_message_id);
}
if (CC->h_command_function != nntp_command_loop) return;
syslog(LOG_DEBUG, "Performing NNTP cleanup hook\n");
+ citnntp *nntpstate = (citnntp *) CC->session_specific_data;
+ if (nntpstate != NULL) {
+ free(nntpstate);
+ nntpstate = NULL;
+ }
}
const char *CitadelServiceNNTP="NNTP";