At 11:50 AM 8/9/98 -0700, Mark J. Miller wrote:
Well now that biff works, (at one level) it doesn't (at the next one).
My comsat daemon expects a call in the form of
user(_at_)mailbox-offset
while procmail delivers in the form of
user(_at_)offset:mailbox
I've changed the : seperator to a - (fairly easy), but now I need to
rearrange offset and mailbox in the call. Here's the (probably) relevant
code snippet:
addr.sin_port=htons((short)s); /* network order */
cat(tgetenv(lgname),"@"); /* should always fit in buf */
if(lasttell>=0) /* was it a file? */
ultstr(0,(unsigned long)lasttell,buf2),catlim(buf2); /* yep */
catlim(COMSATxtrsep); /* custom seperator */
if(lasttell>=0&&!strchr(dirsep,*lstfolder)) /* relative filename? */
catlim(tgetenv(maildir)),catlim(MCDIRSEP_); /* prepend curdir */
catlim(lstfolder);s=socket(AF_INET,SOCK_DGRAM,UDP_protocolno);
sendto(s,buf,strlen(buf),0,(const void*)&addr,sizeof(addr));rclose(s);
yell("Notified comsat:",buf);
Somehow I have to get buf in the form of user(_at_)mailbox-offset(_dot_) Any
ideas?
Well, since you're going to change the source... try this....
if you leave the colon in, then just before sendto:
mangle(buf);
and here's my version of mangle:
/* change uuu(_at_)xxx:mmm to uuu(_at_)mmm-xxx */
void mangle(char *buf)
{
char *p, *pat=NULL, *pcolon=NULL;
for(p=buf+1; *p; p++) {
if (*p=='@') pat=p;
else if (*p == ':') pcolon = p;
}
if (!pat || !pcolon || pat > pcolon) return; /* not expected input */
if (!(p=malloc(strlen(pat)))) return;
strcpy(p,pcolon+1);
strcat(p,"-");
strncat(p,pat+1,pcolon-pat-1);
strcpy(pat+1,p);
free(p);
}
Howzat? (Note, untested and could well contain typos.)
Note, I've assumed that buf is done with after the yell(); if not,
a little more work needed.
Note 2: may be doable more simply by rearranging calls in the sequence
you quoted, but since I don't know what they do, I left them alone
on the theory that what I wrote is less likely to break something.
Cheers,
Stan