/* * 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" #ifdef LOG int ih_accepted; int ih_rejected; int ih_failed; #endif /* * IHAVE * * Accept an article for transferral if we haven't seen it before. */ void ihave(PNEWSCLIENT pnc, int argc, char *argv[]) { int retcode; char *cp; FILE *fp; if (!pnc -> canxfer) { so_printf(pnc -> s, "%d You do not have transfer permission\r\n", ERR_GOODBYE); lprintf("%s: Illegal transfer access", pnc->remotehost); return; } if (argc != 2) { so_printf(pnc -> s, "%d Usage: IHAVE .\r\n", ERR_CMDSYN); lprintf("%s: Syntax error in ihave command", pnc->remotehost); return; } if(gethistart(cfg.historyfile, argv[1], NULL)) { so_printf(pnc -> s, "%d Got it.\r\n", ERR_GOTIT); return; } if((fp = _popen(cfg.rnewscall, "wb")) != NULL) { char *line = malloc(BUFSIZ); so_printf(pnc -> s, "%d Ok\r\n", CONT_XFER); 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 fprintf(fp, "%s\n", line); } if((retcode = _pclose(fp)) != 0) { lprintf("%s returned %d", cfg.rnewscall, retcode); so_printf(pnc -> s, "%d Transfer failed.\r\n", ERR_XFERFAIL); } else so_printf(pnc -> s, "%d Thanks.\r\n", OK_XFERED); free(line); } else { so_printf(pnc -> s, "%d Failed to run %s.\r\n", ERR_XFERFAIL, cfg.rnewscall); lprintf("Failed to run %s", cfg.rnewscall); } }