/* * 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 * */ #define OS2 #include #include #include #include #include #include #include #include #include "config.h" #include "globals.h" #include "nntp.h" #include "changi.h" /* * NEWGROUPS date time ["GMT"] [] * * Display new newsgroups since a given date and time, but only * for those in . */ void newgroups(PNEWSCLIENT pnc, int argc, char *argv[]) { char line[NNTP_STRLEN]; register char *cp, *temp; int i; long date; register FILE *date_fp; char *reqlist[2]; if (argc < 3) { so_printf(pnc -> s, "%d Usage: NEWGROUPS yymmdd hhmmss [\"GMT\"] " "[].\r\n", ERR_CMDSYN); lprintf("%s: Syntax error in newgroups command", pnc->remotehost); return; } date_fp = xopen(cfg.active_times, "r"); if (date_fp == NULL) { lperror(cfg.active_times); so_printf(pnc -> s, "%d Can't open active.times file.\r\n", ERR_FAULT); return; } if (strlen(argv[1]) != 6 || strlen(argv[2]) != 6) { so_printf(pnc -> s, "%d Date/time must be in form YYMMDD HHMMSS.\r\n", ERR_CMDSYN); fclose(date_fp); lprintf("%s: Date format error in newgroups command", pnc->remotehost); return; } strcpy(line, argv[1]); /* yymmdd */ strcat(line, argv[2]); /* hhmmss */ date = dtol(line); if (date < 0) { so_printf(pnc -> s, "%d Invalid date specification.\r\n", ERR_CMDSYN); fclose(date_fp); lprintf("%s: Date format error in newgroups command", pnc->remotehost); return; } argc -= 3; argv += 3; if (argc > 0 && !stricmp(*argv, "GMT")) { /* We store stuff in GMT */ ++argv; /* anyway, so this is */ --argc; /* a "noop" */ } else /* But that means not GMT */ date = local_to_gmt(date); /* is a definite "op" */ if (argc > 0) { pnc->distcount = get_distlist(&pnc->dist_list, *argv); if (pnc->distcount < 0) { so_printf(pnc -> s, "%d Bad distribution list: %s\r\n", ERR_CMDSYN, *argv); lprintf("%s: Bad distribution list in newgroups command", pnc->remotehost); fclose(date_fp); return; } } so_printf(pnc -> s, "%d New newsgroups since %s follow.\r\n", OK_NEWGROUPS, line); while (fgets(line, sizeof(line), date_fp) != NULL) { if ((cp = strchr(line, '\n')) != NULL) *cp = '\0'; if ((cp = strchr(line, ' ')) != NULL) *cp = '\0'; if (atol(cp + 1) < date) continue; if (pnc->distcount == 0) { reqlist[0] = line; reqlist[1] = NULL; if (pnc->ngpermcount) { if (ngmatch(s1strneql, 1, pnc->ngpermlist, pnc->ngpermcount, reqlist, 1) == 0) { continue; } } if(so_puts(pnc -> s, line) == -1) break; if(so_puts(pnc -> s, "\r\n") == -1) break; } else { int fbreak = 0; temp = line; cp = strchr(temp, '.'); if (cp == NULL) continue; *cp = '\0'; for (i = 0; i < pnc->distcount; ++i) if (strcmp(temp, pnc->dist_list[i]) == 0) { *cp = '.'; if(so_puts(pnc -> s, temp) == -1) { fbreak = 1; break; } if(so_puts(pnc -> s, "\r\n") == -1) fbreak = 1; break; } if(fbreak) break; } } so_puts(pnc -> s, ".\r\n"); fclose(date_fp); }