1: #include "parms.h"
   2: #include "structs.h"
   3: #include "newsgate.h"
   4: 
   5: #ifdef  RCSIDENT
   6: static char rcsid[] = "$Header: parsepath.c,v 1.7.0.2 85/03/18 20:57:00 notes Rel $";
   7: #endif	RCSIDENT
   8: 
   9: /*
  10:  *	Parse the supplied path and from lines to determine the
  11:  *	address of the sender.  Look at the "from" line first
  12:  *	to see if it contains a pure domain-style address. If so,
  13:  *	use that for origsys and authname. Otherwise, fall into
  14:  *	intuiting it from the "newspath" argument.
  15:  *
  16:  *	newsinput calls this with header.path and header.from as
  17:  *	args.  nfmail calls it with from and (null) as args.
  18:  *
  19:  *
  20:  * fromsys:	contains system that sent us the article.
  21:  *		this helps us avoid sending unnecessary copies
  22:  *		of the article over the net.
  23:  *
  24:  * origsys:	contains the system name of the author.  Note
  25:  *		that for mailing lists gatewayed to news, this
  26:  *		is not the same as the host in the article-ID.
  27:  *
  28:  *	Thanks to Lou Salkind for this code.
  29:  */
  30: 
  31: char    fromsys[SYSSZ + 1];             /* gave it to us */
  32: char    origsys[SYSSZ + 1];             /* started here */
  33: char    authname[NAMESZ + 1];               /* author */
  34: 
  35: parsepath (newspath, fromline)
  36: char   *newspath;
  37: char   *fromline;
  38: {
  39:     register int    i,
  40:                     j,
  41:                     c;
  42:     register char  *p,
  43:                    *q;
  44:     char    line[CMDLEN];
  45:     int     gotname = 0;                /* not yet */
  46: 
  47:     if (fromline != (char *) NULL && fromline[0] != '\0')
  48:     {                           /* pure domain exists */
  49:     strcpy (line, fromline);            /* hackable copy */
  50:     if ((p = index (line, '<')) != (char *) NULL)   /* get it */
  51:     {
  52:         if ((q = index (p, '>')) == (char *) NULL)  /* malformed */
  53:         goto usepath;
  54:         *q = '\0';                  /* truncate */
  55:         p++;                    /* skip the < */
  56:     }
  57:     else
  58:     {
  59:         p = line;                   /* from start */
  60:         while (*p == ' ' || *p == '\t')
  61:         p++;                    /* skip leading trash */
  62:         q = p;
  63:         while (*q != '\0' && *q != ' ' && *q != '\n' && *q != '\t')
  64:         q++;                    /* on to the next */
  65:         *q = '\0';                  /* zap trailing crap */
  66:     }
  67:     if ((p = index (line, '@')) == (char *) NULL)
  68:         goto usepath;
  69:     *p++ = '\0';                    /* split them */
  70:     strncpy (authname, line, NAMESZ);
  71:     authname[NAMESZ - 1] = '\0';            /* truncate */
  72:     strncpy (origsys, p, HOMESYSSZ);
  73:     origsys[HOMESYSSZ - 1] = '\0';          /* truncate */
  74: #ifdef  notdef
  75:     /*
  76: 	 * (no longer.....)
  77: 	 * strip the domain part of the address
  78: 	 */
  79:     if ((p = index (origsys, '.')) != (char *) NULL)/* find it */
  80:         *p = '\0';                  /* and zap it */
  81: #endif	notdef
  82:     /*
  83: 	 * check to see we got something
  84: 	 */
  85:     if (strlen (authname) > 0)          /* system could be null */
  86:         gotname++;                  /* mark as plucked */
  87:     }
  88:     /*
  89:      * Determine user and the real originating system.
  90:      * Tuned for B news 2.10
  91:      */
  92: usepath:                        /* fall through from above */
  93:     strcpy (line, newspath);
  94:     for (i = 0; line[i]; i++)               /* find string end */
  95:     if (line[i] == ' ' || line[i] == '\t' || line[i] == '\n')
  96:     {
  97:         line[i] = '\0';
  98:         break;
  99:     }
 100:     i--;
 101: 
 102:     /*
 103:      * Try and parse an author if we don't already have one
 104:      */
 105:     if (!gotname)
 106:     {
 107:     for (j = i; j > 0; j--)             /* find delimiter */
 108:         if (line[j] == '@' || line[j] == '!' || line[j] == ':')
 109:         break;
 110:     if (j <= 0)
 111:     {                       /* user */
 112:         for (i = 0; i < (NAMESZ - 1); i++)
 113:         {
 114:         if ((c = line[i]) == '\0')
 115:             break;
 116:         authname[i] = c;
 117:         }
 118:         authname[i] = '\0';
 119:     }
 120:     else
 121:         if (line[j] == '@')
 122:         {                       /* user@host */
 123:         int     atcount = j;
 124: 
 125:         line[atcount] = '\0';           /* drop uucp route */
 126:         for (i = atcount - 1; i > 0; i--)
 127:         {
 128:             if (line[i] == '!' || line[i] == ':')
 129:             {
 130:             i++;
 131:             break;
 132:             }
 133:         }
 134:         j = i;                  /* copy user */
 135:         for (i = 0; i < (NAMESZ - 1); i++)
 136:         {
 137:             if ((c = line[j + i]) == '\0')
 138:             break;
 139:             authname[i] = c;
 140:         }
 141:         authname[i] = '\0';
 142:         j = atcount + 1;            /* copy origsys */
 143:         for (i = 0; i < (SYSSZ - 1); i++)
 144:         {
 145:             if ((c = line[j + i]) == '\0')
 146:             break;
 147: #ifdef  notdef
 148:             /*
 149: 		     * (no longer needed....)
 150: 		     * TEMPORARY KLUDGE...
 151: 		     * throw out domain part until host
 152: 		     * name length increased
 153: 		     */
 154:             if (c == '.')
 155:             break;
 156: #endif	notdef
 157:             origsys[i] = c;
 158:         }
 159:         origsys[i] = '\0';
 160:         }
 161:         else
 162:         {                       /* host!user */
 163:         int     delim = j;
 164:         char    sepchar = line[delim];      /* save delimiter */
 165: 
 166:         line[delim] = '\0';         /* drop uucp route */
 167:         for (i = delim - 1; i > 0; i--)
 168:         {
 169:             if (line[i] == '!' || line[i] == ':')
 170:             {
 171:             i++;
 172:             break;
 173:             }
 174:         }
 175:         j = i;                  /* copy host */
 176:         for (i = 0; i < (NAMESZ - 1); i++)
 177:         {
 178:             if ((c = line[j + i]) == '\0')
 179:             break;
 180:             origsys[i] = c;
 181:         }
 182:         origsys[i] = '\0';
 183: #ifdef  FULLDOMAIN
 184:         /*
 185: 		 * if the delimiter was a !, we can place the site in
 186: 		 * the "UUCP" domain.
 187: 		 *
 188: 		 * Exception:  if the site name contains "." [as it will once
 189: 		 * the USENIX/UUCP project gets going], we don't want to
 190: 		 * add a domain since it is probably already there.
 191: 		 */
 192:         if (sepchar == '!')         /* some UUCP site */
 193:         {
 194:             if (index (origsys, '.') == (char *) NULL)
 195:             {
 196:             strcat (origsys, ".UUCP");
 197:             }
 198:             else
 199:             {
 200:             /*
 201: 			 * already contains full domain spec
 202: 			 */
 203:             }
 204:         }
 205:         else
 206:         {
 207:             /*
 208: 		     * a BERKnet site. Don't have a handy domain for them.
 209: 		     */
 210:         }
 211: #endif	FULLDOMAIN
 212:         j = delim + 1;              /* copy user */
 213:         for (i = 0; i < (SYSSZ - 1); i++)
 214:         {
 215:             if ((c = line[j + i]) == '\0')
 216:             break;
 217:             authname[i] = c;
 218:         }
 219:         authname[i] = '\0';
 220:         }
 221:     }                           /* of if !gotname */
 222: 
 223:     /*
 224:      * get fromsys, which is the first host in path
 225:      */
 226: 
 227:     if (p = index (line, '!'))
 228:     {
 229:     *p = '\0';
 230:     strncpy (fromsys, line, SYSSZ - 1);
 231:     }
 232:     else
 233:     strcpy (fromsys, origsys);
 234: }

Defined functions

Defined variables

authname defined in line 33; used 14 times
fromsys defined in line 31; used 14 times
origsys defined in line 32; used 18 times
rcsid defined in line 6; never used
Last modified: 1985-10-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 697
Valid CSS Valid XHTML 1.0 Strict