gih900@UUNET.UU.NET (Geoff Huston) (09/25/89)
Jamie (and net-readers),
>In order to not-redistribute, this test in sys_remote_send() needs to succeed,
>
> if (f && !f->to_names) return;
>
>ie f->to_names must be 0 for the distfile entry for the system in question.
>There doesn't seem to be any way to come out of scannet() with ->to_names == 0.
>
>I *think* that one could set up a news.distribution line such as
>
>scubed nonexistentnode
>
>and get away with it, but I like the following fix better. It allows
>news.distribution lines with empty to-lists, ie
>
>scubed
>
>We store the result of the sscanf, and allow either 1 or 2 strings on the
>distribution line. Then we init the *tmp struct, and only take apart the
>to-list if it was there. How doe this look to you?
I have re-worked Jamie's suggested code to be a little more flexible. In
particular is will work with input lines for the form:
scubed
koala wombat emu, potoroo
i.e. the requirement for strict comma delimited lists is relaxed slightly:..
Geoff Huston
gih900@csc.anu.oz.au
NEWSDIST.C:
scannet()
static
scannet(s)
char *s;
{
char node[NODE_SIZE],
tolist[IO_SIZE],
*cp1,
*cp2;
int n;
sys_filter_t *fmp, *f1;
dist_entry_t *tmp, *t1 = distfile;
cp1 = s; /* s is compressed, stripped string */
while (isgraph(*cp1)) cp1++; /* scan accross node word */
if (!*cp1) cp1 = 0;
else *cp1++ = '\0'; /* and null terminate node word */
strcpy(node,s);
if (!strlen(node)) return; /* handle the case of the string " " */
tmp = malloc(sizeof *tmp);
strcpy((tmp->from_name = malloc(strlen(node) + 1)),node);
tmp->to_names = 0;
if (cp1) { /* now handle following words */
while (cp2 = strchr(cp1,' ')) *cp2 = ','; /* convert ' ' -> ',' */
strcpy(tolist,cp1);
cp1 = tolist;
do {
if (cp2 = strchr(cp1,',')) *cp2++ = '\0';
if (strlen(cp1)) {
fmp = malloc(sizeof *fmp);
strcpy((fmp->sys_filtnam = malloc(strlen(cp1) + 1)),cp1);
fmp->sys_fnext = 0;
if (!tmp->to_names) tmp->to_names = f1 = fmp;
else {
f1->sys_fnext = fmp;
f1 = fmp;
}
}
cp1 = cp2;
} while (cp1);
}
tmp->next = 0;
if (!distfile) distfile = tmp;
else {
while (t1->next) t1 = t1->next;
t1->next = tmp;
}
}