1: /*
   2:  * sendnews - send news article by mail.
   3:  */
   4: 
   5: #ifdef SCCSID
   6: static char *SccsId = "@(#)sendnews.c	2.10	4/16/85";
   7: #endif /* SCCSID */
   8: 
   9: #include <stdio.h>
  10: #include <ctype.h>
  11: #ifndef USG
  12: struct utsname {
  13:     char    Sysname[9];
  14:     char    nodename[33];
  15:     char    release[9];
  16:     char    version[9];
  17: };
  18: #else /* USG */
  19: #include <sys/utsname.h>
  20: #endif /* USG */
  21: 
  22: #define eq(a,b) (strcmp(a,b) == 0)
  23: #define LNLEN   7           /* strlen("ucbvax!") */
  24: 
  25: char *index();
  26: char buffer[BUFSIZ];
  27: int linecount, oflag = 0, aflag = 0, bflag = 0, toflag = 0;
  28: 
  29: FILE *popen();
  30: /* ARGSUSED */
  31: main(argc, argv)
  32: char **argv;
  33: {
  34:     FILE *out;
  35:     char newsgroup[100];
  36:     char sysn[20];
  37:     struct utsname ubuf;
  38: 
  39:     while (**(++argv) == '-') {
  40:         if (*++*argv == 'o')
  41:             oflag++;
  42:         else if (**argv == 'a')
  43:             aflag++;
  44:         else if (**argv == 'b')
  45:             bflag++;
  46:         else if (**argv == 'n')
  47:             strcpy(newsgroup, *(++argv));
  48:     }
  49:     if (aflag && bflag) {
  50:         fprintf(stderr, "'-a' and '-b' options mutually exclusive.\n");
  51:         exit(1);
  52:     }
  53: 
  54: #ifdef debug
  55:     printf("/bin/mail %s\n", *argv);
  56:     sprintf(buffer, "cat");
  57: #else
  58:     sprintf(buffer, "/bin/mail %s", *argv);
  59: #endif
  60:     out = popen(buffer, "w");
  61:     uname(&ubuf);
  62:     strcpy(sysn, ubuf.nodename);
  63:     strcat(sysn, "!");
  64: 
  65:     /* Standard mail prelude to make the formatters happy */
  66:     fprintf(out, "To: %s\n", *argv);
  67:     fprintf(out, "Subject: network news article\n");
  68:     fprintf(out, "\n");
  69: 
  70:     while (fgets(buffer, sizeof buffer, stdin)) {
  71:         if (*newsgroup && ngline()) {
  72:             if (oflag)
  73:                 sprintf(buffer, "%s\n", newsgroup);
  74:             else
  75:                 sprintf(buffer, "Newsgroups: %s\n", newsgroup);
  76:         }
  77:         putc('N', out);
  78:         fputs(buffer, out);
  79:     }
  80:     pclose(out);
  81:     exit(0);
  82: }
  83: 
  84: ngline()
  85: {
  86:     if (oflag)
  87:         return linecount == 2;
  88:     if (!toflag && (!strncmp("Newsgroups: ", buffer, 12) ||
  89:         !strncmp("To: ",buffer, 4)))
  90:         return ++toflag;
  91:     return 0;
  92: }

Defined functions

main defined in line 31; never used
ngline defined in line 84; used 1 times
  • in line 71

Defined variables

SccsId defined in line 6; never used
buffer defined in line 26; used 10 times
linecount defined in line 27; used 1 times
  • in line 87
oflag defined in line 27; used 3 times

Defined struct's

utsname defined in line 12; used 2 times
  • in line 37(2)

Defined macros

LNLEN defined in line 23; never used
eq defined in line 22; never used
Last modified: 1986-01-20
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1243
Valid CSS Valid XHTML 1.0 Strict