|
|
1.1 ! root 1: #ifndef lint ! 2: static char *sccsid = "@(#)group.c 1.10 (Berkeley) 7/17/87"; ! 3: #endif ! 4: ! 5: #include "common.h" ! 6: ! 7: /* ! 8: * GROUP newsgroup ! 9: * ! 10: * Change the current group to the specified newsgroup. ! 11: * We also change our current directory to that newsgroup if ! 12: * a spool directory for it exists. ! 13: * If the newsgroup specified is invalid, the old newsgroup ! 14: * remains selected. ! 15: */ ! 16: ! 17: group(argc, argv) ! 18: int argc; ! 19: char *argv[]; ! 20: { ! 21: char temp_dir[256]; ! 22: int high_msg, low_msg; ! 23: char *cp; ! 24: char *reqlist[2]; ! 25: ! 26: if (argc != 2) { ! 27: printf("%d Usage: GROUP newsgroup.\r\n", ERR_CMDSYN); ! 28: (void) fflush(stdout); ! 29: return; ! 30: } ! 31: ! 32: if (!canread) { ! 33: printf("%d You only have permission to transfer, sorry.\r\n", ! 34: ERR_ACCESS); ! 35: (void) fflush(stdout); ! 36: return; ! 37: } ! 38: ! 39: if (index(argv[1], '/') != (char *) NULL) { ! 40: printf("%d Invalid group name.\r\n", ERR_NOGROUP); ! 41: (void) fflush(stdout); ! 42: return; ! 43: } ! 44: ! 45: if (find_group(argv[1], num_groups, &low_msg, &high_msg) < 0) { ! 46: printf("%d Invalid group name.\r\n", ERR_NOGROUP); ! 47: (void) fflush(stdout); ! 48: return; ! 49: } ! 50: ! 51: reqlist[0] = argv[1]; ! 52: reqlist[1] = NULL; ! 53: ! 54: if (ngpermcount) { ! 55: if (ngmatch(strneql, ALLBUT, ! 56: ngpermlist, ngpermcount, reqlist, 1) == 0) { ! 57: printf("%d You're not allowed to read %s, sorry.\r\n", ! 58: ERR_ACCESS, argv[1]); ! 59: (void) fflush(stdout); ! 60: return; ! 61: } ! 62: } ! 63: ! 64: close_crnt(); ! 65: (void) chdir(spooldir); ! 66: ! 67: #ifdef LOG ! 68: syslog(LOG_INFO, "%s group %s", hostname, argv[1]); ! 69: #endif ! 70: ! 71: while ((cp = index(argv[1], '.')) != (char *) NULL) ! 72: *cp = '/'; ! 73: ! 74: (void) strcpy(temp_dir, spooldir); ! 75: (void) strcat(temp_dir, "/"); ! 76: (void) strcat(temp_dir, argv[1]); ! 77: ! 78: /* ! 79: * (void) because a group can be in the active file ! 80: * but not have a spool directory. Just leave us ! 81: * chdired to base spool directory if this fails. ! 82: */ ! 83: (void) chdir(temp_dir); ! 84: ! 85: #ifdef LOG ! 86: ++grps_acsd; ! 87: #endif ! 88: ! 89: num_arts = scan_dir(low_msg, high_msg); ! 90: art_ptr = 0; ! 91: ! 92: ingroup = 1; ! 93: ! 94: while ((cp = index(argv[1], '/')) != (char *) NULL) ! 95: *cp = '.'; ! 96: ! 97: printf("%d %d %d %d %s\r\n", ! 98: OK_GROUP, ! 99: num_arts, ! 100: (num_arts > 0 ? art_array[0] : 0), ! 101: (num_arts > 0 ? art_array[num_arts-1] : 0), ! 102: argv[1]); ! 103: (void) fflush(stdout); ! 104: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.