Xref: utzoo news.software.b:1594 news.config:886 Path: utzoo!attcan!uunet!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: news.software.b,news.config Subject: Re: Solution to news dup site names Message-ID: <1365@ficc.uu.net> Date: 25 Aug 88 15:57:54 GMT References: <1445@datapg.MN.ORG> <20246@tut.cis.ohio-state.edu> <2530@plus5.UUCP> <1360@ficc.uu.net> Distribution: na Organization: SCADA Lines: 80 I just rewrote the replyname function in funcs2.c to do a better job of hacking the mailpaths file. This is only useful for people who have INTERNET defined, and of course it's missing all the special code that the Sun people put in to handle .OZ... It also makes the assumption that the first element of the path is the site name, but that seems safe. ----/*SNIP SNIP */---- char * replyname(hptr) struct hbuf *hptr; { register char *name; register char *ptr; static char user[PATHLEN], path[PATHLEN]; static char buf[PATHLEN], fmt[PATHLEN]; FILE *mfd; int found; /* Figure out where to send mail */ if (hptr->replyto[0]) name = hptr->replyto; else if (hptr->from[0]) name = hptr->from; else { /* Should never happen */ name = strchr(hptr->path, '!'); if(!name) name = hptr->path; } /* Remove (User name @ Organisation) */ strcpy(buf, name); name = buf; if(ptr = index(name, ' ')) *ptr = 0; /* break it up into path/site and name */ if(ptr = index(name, '@')) { strncpy(user, name, ptr-name); user[ptr-name] = 0; strcpy(path, ptr+1); } else if(ptr = rindex(name, '!')) { strcpy(user, ptr+1); strncpy(path, name, ptr-name); path[ptr-name] = 0; } else /* A local */ return name; sprintf(buf, "%s/mailpaths", LIB); mfd = xfopen(buf, "r"); /* Should probably do an fopen, and just return path if not found. This would make INTERNET unnecessary */ /* If all else fails, fall back on the path */ name = strchr(hptr->path, '!'); if(!name) name = hptr->path; /* Look for my path */ while(fgets(buf, sizeof buf, mfd)) { if(PREFIX(buf, path)) { sscanf(buf, "%*s %s", fmt); sprintf(buf, fmt, user); name = buf; break; } else if(PREFIX(buf, "internet")) { /* Should be last entry */ sscanf(buf, "%*s %s", fmt); strcat(path, "!"); strcat(path, user); sprintf(buf, fmt, path); name = buf; break; } } return name; } -- Peter da Silva `-_-' Ferranti International Controls Corporation. "Have you hugged U your wolf today?" peter@ficc.uu.net