|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include "string.h" ! 3: ! 4: ! 5: /* ! 6: * convert domain to `bang' format. ! 7: * @x,@y:d%c%b@a -> x!y!a!b!c!d ! 8: * d%c%b@a -> a!b!c!d ! 9: * c!d%b@a -> a!b!uucp!c!d ! 10: */ ! 11: extern char * ! 12: convertaddr(from) ! 13: char *from; ! 14: { ! 15: static string *buf; ! 16: char *sp, *ep; ! 17: int end; ! 18: int elems=0; ! 19: ! 20: if(!buf) ! 21: buf = s_new(); ! 22: s_restart(buf); ! 23: ! 24: /* ! 25: * parse leading @a,@b,@c: ! 26: */ ! 27: while(*from=='@'){ ! 28: /* find end of string */ ! 29: for(ep= ++from; *ep!=':' && *ep!=',' && *ep!='\0'; ep++) ! 30: ; ! 31: end = *ep; ! 32: *ep = '\0'; ! 33: s_append(buf, from); ! 34: s_append(buf, "!"); ! 35: elems++; ! 36: from = end ? ep+1 : ep; ! 37: } ! 38: ! 39: /* ! 40: * parse the rest (whatever it may be) ! 41: */ ! 42: for (sp = from + strlen(from); sp >= from; sp--) { ! 43: if (*sp == '@') { ! 44: /* hack to get rid of forwarding crap */ ! 45: s_append(buf, sp+1); ! 46: s_append(buf, "!"); ! 47: elems++; ! 48: *sp = '\0'; ! 49: } ! 50: } ! 51: ! 52: /* ! 53: * if the from address was a '!' format address, remember that ! 54: */ ! 55: if(elems && (sp=strchr(from, '!')) && (ep=strchr(from, '.')) && ep<sp) ! 56: s_append(buf, "uucp!"); ! 57: s_append(buf, from); ! 58: ! 59: return s_to_c(buf); ! 60: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.