Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.344 diff -u -r1.344 chan_sip.c --- channels/chan_sip.c 26 Apr 2004 14:54:33 -0000 1.344 +++ channels/chan_sip.c 27 Apr 2004 22:13:56 -0000 @@ -1983,6 +1983,51 @@ return 0; } +int lws2sws(char *msgbuf, int len) +{ + int h = 0, t = 0; + int lws = 0; + + for (; h < len;) { + /* Eliminate all CRs */ + if (msgbuf[h] == '\r') { + h++; + continue; + } + /* Check for end-of-line */ + if (msgbuf[h] == '\n') { + /* Check for end-of-message */ + if (h + 1 == len) + break; + /* Check for a continuation line */ + if (msgbuf[h + 1] == ' ') { + /* Merge continuation line */ + h++; + continue; + } + /* Propagate LF and start new line */ + msgbuf[t++] = msgbuf[h++]; + lws = 0; + continue; + } + + if (msgbuf[h] == ' ' || msgbuf[h] == '\t') { + if (lws) { + h++; + continue; + } + msgbuf[t++] = msgbuf[h++]; + lws = 1; + continue; + } + msgbuf[t++] = msgbuf[h++]; + if (lws) + lws = 0; + } + msgbuf[t] = '\0'; + return t; +} + static void parse(struct sip_request *req) { /* Divide fields by NULL's */