|
|
1.1 ! root 1: #ifndef lint ! 2: static char *sccsid = "@(#)ahbs.c 1.2 (Berkeley) 3/5/86"; ! 3: #endif ! 4: ! 5: #include "common.h" ! 6: ! 7: 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: char c; ! 27: int method; ! 28: register FILE *fp; /* For Message-ID retrieval only */ ! 29: ! 30: if (argc > 2) { ! 31: printf("%d %s requires 0 or 1 argument.\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: printf("%d 0 %s Article retrieved, %s.\r\n", ! 53: OK_ARTICLE + method, argv[1], verbage[method]); ! 54: spew(fp, method); ! 55: (void) fclose(fp); ! 56: return; ! 57: } ! 58: ! 59: /* Else we're trying to read */ ! 60: ! 61: if (!canread) { ! 62: printf("%d You only have permission to transfer, sorry.\r\n", ! 63: ERR_ACCESS); ! 64: (void) fflush(stdout); ! 65: return; ! 66: } ! 67: ! 68: if (!ingroup) { ! 69: printf("%d You are not currently in a newsgroup.\r\n", ! 70: ERR_NCING); ! 71: (void) fflush(stdout); ! 72: return; ! 73: } ! 74: ! 75: if (argc == 1) { ! 76: if (art_ptr < 0 || art_ptr >= num_arts) { ! 77: printf("%d No article is currently selected.\r\n", ! 78: ERR_NOCRNT); ! 79: (void) fflush(stdout); ! 80: return; ! 81: } ! 82: (void) sprintf(artbuf, "%d", art_array[art_ptr]); ! 83: } else ! 84: (void) strcpy(artbuf, argv[1]); ! 85: ! 86: if (!valid_art(artbuf)) { ! 87: printf("%d Invalid article number: %s.\r\n", ! 88: ERR_NOARTIG, artbuf); ! 89: (void) fflush(stdout); ! 90: return; ! 91: } ! 92: ! 93: while (open_valid_art(artbuf, art_id) == NULL) { ! 94: if (argc > 1) { ! 95: printf("%d Invalid article number: %s.\r\n", ! 96: ERR_NOARTIG, artbuf); ! 97: (void) fflush(stdout); ! 98: return; ! 99: } else { ! 100: if (++art_ptr >= num_arts) { ! 101: printf("%d Invalid article number.\r\n", ! 102: ERR_NOARTIG); ! 103: (void) fflush(stdout); ! 104: return; ! 105: } ! 106: (void) sprintf(artbuf, "%d", art_array[art_ptr]); ! 107: } ! 108: } ! 109: ! 110: printf("%d %s %s Article retrieved; %s.\r\n", ! 111: OK_ARTICLE + method, artbuf, art_id, verbage[method]); ! 112: ! 113: spew(art_fp, method); ! 114: ! 115: if (argc > 1) ! 116: art_ptr = findart(artbuf); ! 117: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.