.TH rewritehost 3 .SH NAME rewritehost \- make syntactic changes to host names .SH SYNTAX .B #include int \fBrewritehost\fP(&\fIout\fR,\fIbuf\fR,\fIlen\fR,&\fIrules\fR); .br int \fBrewritehost_addr\fP(&\fIout\fR,\fIbuf\fR,\fIlen\fR,&\fIrules\fR); .br int \fBrewritehost_list\fP(&\fIout\fR,\fIbuf\fR,\fIlen\fR,&\fIrules\fR); stralloc \fIrules\fR; .br stralloc \fIout\fR; .br char *\fIbuf\fR; .br unsigned int \fIlen\fR; .SH DESCRIPTION .B rewritehost reads a host name from .I buf of length .IR len , rewrites it according to instructions in .IR rules , and puts the rewritten host name into .IR out . .I rules is a series of \e0-terminated instructions; see .BR rewriting (5) for the instruction format. .B rewritehost_addr reads an address in the form .I user\fB@\fIhost from .I buf of length .IR len . It rewrites .I host according to instructions in .IR rules , unless both .I user and .I host are empty, in which case it rewrites the address as the empty string. It puts the rewritten address into .IR out . .B rewritehost_addr accepts .I user as a synonym for .I user\fB@ with an empty host name. .B rewritehost_list reads an address list from .I buf of length .IR len , rewrites each address in the list according to instructions in .IR rules , and puts the rewritten address list into .IR out . The address list consists of \e0-terminated chunks; a chunk is either an address preceded by a plus sign, or a comment preceded by a left parenthesis. .B rewritehost_list copies comments without change. Each function returns 1 if it succeeds, 0 if it runs out of memory. .SH "SEE ALSO" stralloc(3), rewriting(5)