1: /*
   2:  * berknews - send news article via Berknet
   3:  *
   4:  * Synopsis:
   5:  *	berknews [-o] [-n newsgroup] host_net_command machine remote_rnews
   6:  */
   7: 
   8: #ifdef SCCSID
   9: static char *SccsId = "@(#)berknews.c	2.5	4/16/85";
  10: #endif /* SCCSID */
  11: 
  12: #include <stdio.h>
  13: #include <ctype.h>
  14: #ifndef USG
  15: #include <whoami.h>
  16: struct utsname {
  17:     char    Sysname[9];
  18:     char    nodename[33];
  19:     char    release[9];
  20:     char    version[9];
  21: };
  22: #else /* USG */
  23: #include <sys/utsname.h>
  24: #endif /* USG */
  25: 
  26: 
  27: struct network {
  28:     char *uucpname;
  29:     char *berkname;
  30: } berknet[] = {
  31: /*	UUCP Net Name	BerkNet Name
  32: 	-------------	------------	*/
  33:     "ucbvax",   "CSVAX",
  34:     "populi",   "G",
  35:     "ucbarpa",  "ARPAVAX",
  36:     "ucbcfo-c", "C",
  37:     "ucbopt",   "ESVAX",
  38:     "ucbcad",   "ucbcad",
  39:     "ucbcory",  "Cory",
  40:     "ucb",      "C70",
  41:     "ucbmathstat",  "MathStat",
  42:     "ucbonyx",  "Onyx",
  43:     "ucbkim",   "Kim",
  44:     "ucbcfo-a", "A",
  45:     "ucbcfo-b", "B",
  46:     "ucbcfo-d", "D",
  47:     "ucbcfo-e", "E",
  48:     "ucbcfo-f", "F",
  49:     "ucbingvax",    "IngVAX",
  50:     "ucbingres",    "Ingres",
  51:     "ucbeecs40",    "EECS40",
  52:     "ucbvlsi",  "VLSI",
  53:     "ucbsrc",   "SRC",
  54:     "ucbimage", "Image",
  55:     '\0',       '\0'
  56: };
  57: 
  58: char *index();
  59: char buffer[BUFSIZ];
  60: int linecount;
  61: 
  62: FILE *popen();
  63: main(argc, argv)
  64: int argc;
  65: char **argv;
  66: {
  67:     FILE *out;
  68:     char sender[BUFSIZ],newsgroup[100];
  69:     char *punct;
  70:     char sysn[20];
  71:     int sysnl;
  72:     struct utsname ubuf;
  73: 
  74:     if (argc < 4) {
  75:         fprintf(stderr, "Too few arguments.\n");
  76:         exit(1);
  77:     }
  78: 
  79: #ifdef debug
  80:     printf("%s - -m%s %s\n", argv[1], argv[2], argv[3]);
  81:     sprintf(buffer, "cat");
  82: #else
  83:     sprintf(buffer, "%s - -m%s %s", argv[1], argv[2], argv[3]);
  84: #endif
  85:     out = popen(buffer, "w");
  86:     uname(&ubuf);
  87:     strcpy(sysn, ubuf.nodename);
  88:     strcat(sysn, "!");
  89:     sysnl = strlen(sysn);
  90: 
  91:     while (fgets(buffer, sizeof buffer, stdin)) {
  92:         if (fromline()) {
  93:             punct = index(buffer, '!');
  94:             if (punct == NULL)
  95:                 printf("Bad from line: '%s'\n", buffer);
  96:             else {
  97:                 *punct = ':';   /* berknet mail delimiter */
  98:                 if (!strncmp("From: ", buffer, 6))
  99:                     punct = &buffer[6];
 100:                 else if (!strncmp("From ",buffer,5))
 101:                     punct = &buffer[5];
 102:                 else
 103:                     punct = buffer;
 104:                 fiddle(punct);
 105:             }
 106:         }
 107:         fputs(buffer, out);
 108:     }
 109:     pclose(out);
 110:     exit(0);
 111: }
 112: 
 113: fromline() {
 114:     if (!linecount && (!strncmp("From: ", buffer, 6) || !strncmp("From ", buffer, 5)))
 115:         return ++linecount;
 116:     return 0;
 117: }
 118: 
 119: /*
 120:  * make sure the host name is a correct berknet address, since the
 121:  * internal names are not the berknet host names.
 122:  */
 123: fiddle(buf)
 124: char *buf;
 125: {
 126:     char uucpname[100];
 127:     register struct network *netptr;
 128:     char *rest;
 129: 
 130:     strcpy(uucpname, buf);
 131:     rest = index(uucpname, ':');
 132:     *rest++ = 0;
 133: #ifdef debug
 134:     printf("uucpname = '%s', buf = '%s', rest = '%s'\n", uucpname, buf, rest);
 135: #endif
 136:     for (netptr = &berknet[0]; strcmp(netptr->uucpname, uucpname) && netptr->uucpname; netptr++)
 137:         ;
 138:     if (netptr->uucpname)
 139:         sprintf(buf, "%s:%s", netptr->berkname, rest);
 140:     else
 141:         sprintf(buf, "UNKNOWN:%s", rest);
 142: }

Defined functions

fiddle defined in line 123; used 1 times
fromline defined in line 113; used 1 times
  • in line 92
main defined in line 63; used 1 times

Defined variables

SccsId defined in line 9; never used
berknet defined in line 30; used 1 times
buffer defined in line 59; used 15 times
linecount defined in line 60; used 2 times

Defined struct's

network defined in line 27; used 2 times
  • in line 127(2)
utsname defined in line 16; used 2 times
  • in line 72(2)
Last modified: 1986-01-20
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 779
Valid CSS Valid XHTML 1.0 Strict