|
|
1.1 ! root 1: #ifndef lint ! 2: static char *sccsid = "@(#)ahbs.c 1.7 (Berkeley) 7/17/87"; ! 3: #endif ! 4: ! 5: #include "common.h" ! 6: ! 7: static char *verbage[] = { ! 8: "head and body follow", ! 9: "head follows", ! 10: "body follows", ! 11: "request text separately" ! 12: }; ! 13: ! 14: /* ! 15: * {ARTICLE,HEAD,BODY,STAT} <messageid>|articlenum ! 16: * ! 17: * Retrieve article, head, body, or stat, depending on the ! 18: * command we were invoked with. ! 19: */ ! 20: ! 21: ahbs(argc, argv) ! 22: int argc; ! 23: char *argv[]; ! 24: { ! 25: char artbuf[MAX_STRLEN], art_id[MAX_STRLEN]; ! 26: register char c; ! 27: int method; ! 28: register FILE *fp; /* For Message-ID retrieval only */ ! 29: ! 30: if (argc > 2) { ! 31: printf("%d Usage: %s <message-id>|article_number.\r\n", argv[0], ! 32: ERR_CMDSYN); ! 33: (void) fflush(stdout); ! 34: return; ! 35: } ! 36: ! 37: if ((c = *argv[0]) == 'a' || c == 'A') ! 38: method = ARTICLE; ! 39: else if ((c == 's' || c == 'S')) ! 40: method = STAT; ! 41: else ! 42: method = ((c == 'h' || c == 'H') ? HEAD : BODY); ! 43: ! 44: if (argc == 2 && *argv[1] == '<') { /* Message ID */ ! 45: fp = openartbyid(argv[1]); ! 46: if (fp == NULL) { ! 47: printf("%d No article by message-id %s, sorry.\r\n", ! 48: ERR_NOART, argv[1]); ! 49: (void) fflush(stdout); ! 50: return; ! 51: } ! 52: if (check_ngperm(fp) == 0) { ! 53: printf("%d Can't give that to you, sorry.\r\n", ! 54: ERR_ACCESS); ! 55: (void) fflush(stdout); ! 56: (void) fclose(fp); ! 57: return; ! 58: } ! 59: printf("%d 0 %s Article retrieved, %s.\r\n", ! 60: OK_ARTICLE + method, argv[1], verbage[method]); ! 61: spew(fp, method); ! 62: (void) fclose(fp); ! 63: #ifdef LOG ! 64: if (nn_told) ! 65: nn_took++; ! 66: #endif ! 67: return; ! 68: } ! 69: ! 70: /* Else we're trying to read */ ! 71: ! 72: if (!canread) { ! 73: printf("%d You only have permission to transfer, sorry.\r\n", ! 74: ERR_ACCESS); ! 75: (void) fflush(stdout); ! 76: return; ! 77: } ! 78: ! 79: if (!ingroup) { ! 80: printf("%d You are not currently in a newsgroup.\r\n", ! 81: ERR_NCING); ! 82: (void) fflush(stdout); ! 83: return; ! 84: } ! 85: ! 86: if (argc == 1) { ! 87: if (art_ptr < 0 || art_ptr >= num_arts) { ! 88: printf("%d No article is currently selected.\r\n", ! 89: ERR_NOCRNT); ! 90: (void) fflush(stdout); ! 91: return; ! 92: } ! 93: (void) sprintf(artbuf, "%d", art_array[art_ptr]); ! 94: } else ! 95: (void) strcpy(artbuf, argv[1]); ! 96: ! 97: if (!valid_art(artbuf)) { ! 98: printf("%d Invalid article number: %s.\r\n", ! 99: ERR_NOARTIG, artbuf); ! 100: (void) fflush(stdout); ! 101: return; ! 102: } ! 103: ! 104: while (open_valid_art(artbuf, art_id) == NULL) { ! 105: if (argc > 1) { ! 106: printf("%d Invalid article number: %s.\r\n", ! 107: ERR_NOARTIG, artbuf); ! 108: (void) fflush(stdout); ! 109: return; ! 110: } else { ! 111: if (++art_ptr >= num_arts) { ! 112: printf("%d Invalid article number.\r\n", ! 113: ERR_NOARTIG); ! 114: (void) fflush(stdout); ! 115: return; ! 116: } ! 117: (void) sprintf(artbuf, "%d", art_array[art_ptr]); ! 118: } ! 119: } ! 120: ! 121: printf("%d %s %s Article retrieved; %s.\r\n", ! 122: OK_ARTICLE + method, artbuf, art_id, verbage[method]); ! 123: ! 124: spew(art_fp, method); ! 125: ! 126: if (argc > 1) ! 127: art_ptr = findart(artbuf); ! 128: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.