|
|
1.1 ! root 1: /* ! 2: * sendnews - send news article by mail. ! 3: */ ! 4: ! 5: #ifdef SCCSID ! 6: static char *SccsId = "@(#)sendnews.c 2.13 9/24/87"; ! 7: #endif /* SCCSID */ ! 8: ! 9: #include <stdio.h> ! 10: #include <ctype.h> ! 11: #include "defs.h" ! 12: ! 13: char buffer[BUFSIZ]; ! 14: ! 15: int linecount, oflag = 0, aflag = 0, bflag = 0, toflag = 0; ! 16: ! 17: extern FILE *popen(); ! 18: ! 19: /* ARGSUSED */ ! 20: main(argc, argv) ! 21: char **argv; ! 22: { ! 23: register FILE *out; ! 24: char newsgroup[BUFSIZ]; ! 25: ! 26: while (**(++argv) == '-') { ! 27: if (*++*argv == 'o') ! 28: oflag++; ! 29: else if (**argv == 'a') ! 30: aflag++; ! 31: else if (**argv == 'b') ! 32: bflag++; ! 33: else if (**argv == 'n') ! 34: strcpy(newsgroup, *(++argv)); ! 35: } ! 36: if (aflag && bflag) { ! 37: fprintf(stderr, "'-a' and '-b' options mutually exclusive.\n"); ! 38: exit(1); ! 39: } ! 40: ! 41: #ifdef DEBUG ! 42: printf("/bin/mail %s\n", *argv); ! 43: sprintf(buffer, "cat"); ! 44: #else ! 45: #ifdef SENDMAIL ! 46: (void) sprintf(buffer, "%s -i -odq %s", SENDMAIL, *argv); ! 47: #else /* !SENDMAIL */ ! 48: #ifdef M_XENIX ! 49: (void) sprintf(buffer, "/usr/bin/mail %s", *argv); ! 50: #else /* XENIX is not quite Unix.... */ ! 51: (void) sprintf(buffer, "/bin/mail %s", *argv); ! 52: #endif /* !M_XENIX */ ! 53: #endif /* !SENDMAIL */ ! 54: #endif ! 55: if ((out = popen(buffer, "w")) == NULL) { ! 56: perror(buffer); ! 57: exit(1); ! 58: } ! 59: ! 60: /* Standard mail prelude to make the formatters happy */ ! 61: fprintf(out, "Subject: network news article\n"); ! 62: fprintf(out, "To: %s\n\n", *argv); ! 63: ! 64: while (fgets(buffer, sizeof buffer, stdin)) { ! 65: if (*newsgroup && ngline()) { ! 66: if (oflag) ! 67: sprintf(buffer, "%s\n", newsgroup); ! 68: else ! 69: sprintf(buffer, "Newsgroups: %s\n", newsgroup); ! 70: } ! 71: putc('N', out); ! 72: fputs(buffer, out); ! 73: if (ferror(out)) ! 74: exit(1); ! 75: } ! 76: pclose(out); ! 77: exit(0); ! 78: } ! 79: ! 80: ngline() ! 81: { ! 82: if (oflag) ! 83: return linecount == 2; ! 84: if (!toflag && (!strncmp("Newsgroups: ", buffer, 12) || ! 85: !strncmp("To: ",buffer, 4))) ! 86: return ++toflag; ! 87: return 0; ! 88: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.