/* * This OS/2 port was hacked by Harald Kipp from the * * Network News Transfer Protocol server * * Phil Lapsley * University of California, Berkeley * Stan Barber * Baylor College of Medicine * * Bug reports related to THIS modified version should be sent to * * harald@os2point.ping.de * harald@sesam.com * Fido: 2:2448/434 * */ #include #include #include #include #include #include #include #include #include #include "config.h" #include "globals.h" #include "nntp.h" #include "changi.h" /* * POST * * Post an article to a set of newsgroups. */ void post(PNEWSCLIENT pnc, int argc, char *argv[]) { int retcode; int fBanner = 0; char *cp; FILE *fp; if (!pnc -> canpost) { so_printf(pnc -> s, "%d Sorry, you're not allowed to post.\r\n", ERR_NOPOST); lprintf("%s: Illegal posting access", pnc->remotehost); return; } if((fp = _popen(cfg.inewscall, "wb")) != NULL) { char *line = malloc(BUFSIZ); so_printf(pnc -> s, "%d Ok\r\n", CONT_POST); for (;;) { if (recv_line(pnc -> s, line) <= 0) break; if ((cp = strchr(line, '\r')) != NULL) *cp = '\0'; else if ((cp = strchr(line, '\n')) != NULL) *cp = '\0'; if (line[0] == '.') { if (line[1] == '\0') break; fprintf(fp, "%s\n", line + 1); } else { if (line[0] == '\0' && !fBanner) { fBanner = 1; fprintf(fp, "X-NNTPDaemon: changi %s for OS/2\n", version); } fprintf(fp, "%s\n", line); } } if((retcode = _pclose(fp)) != 0) { lprintf("%s returned %d", cfg.inewscall, retcode); so_printf(pnc -> s, "%d Post failed\r\n", ERR_POSTFAIL); } else so_printf(pnc -> s, "%d Article posted successfully.\r\n", OK_POSTED); free(line); } else { so_printf(pnc -> s, "%d Failed to run %s.\r\n", ERR_POSTFAIL, cfg.inewscall); lprintf("Failed to run %s", cfg.inewscall); } if(argc && argv); }