From: michael Date: Sun, 2 Jul 2006 11:52:15 +0000 (+0000) Subject: line parsing fixes X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/record-dvb/commitdiff_plain/1e93139aeb2830429aaf13978bf90b9f75569a1e?ds=inline line parsing fixes --- diff --git a/sap.c b/sap.c index 85ec2c3..6a8ef79 100644 --- a/sap.c +++ b/sap.c @@ -31,7 +31,7 @@ struct sdp_info { struct sdp_info *parse_sdp(char *sdp, int len) { - char *pos; + char *pos, *line; static struct sdp_info sdpinfo; /* RFC 2327 @@ -47,7 +47,7 @@ struct sdp_info *parse_sdp(char *sdp, int len) bzero(&sdpinfo, sizeof(struct sdp_info)); - pos = sdp; + pos = line = sdp; while(*pos != 0 && (pos-sdp) < len) { if (*pos == 0x0d) *pos = 0; @@ -55,55 +55,55 @@ struct sdp_info *parse_sdp(char *sdp, int len) if (*pos == 0x0a) { *pos = 0; - if (!strncasecmp("s=", sdp, 2)) { - sdpinfo.service = sdp + 2; - } else if (!strncasecmp("c=", sdp, 2)) { + if (!strncasecmp("s=", line, 2)) { + sdpinfo.service = line + 2; + } else if (!strncasecmp("c=", line, 2)) { int poscnt = 0; - sdp += 2; - while (*sdp != 0) { - if (poscnt == 2 && *sdp == '/') { - *sdp = 0; + line += 2; + while (*line != 0) { + if (poscnt == 2 && *line == '/') { + *line = 0; break; } - if (*sdp == ' ') { - *sdp = 0; + if (*line == ' ') { + *line = 0; poscnt++; /* c=
*/ if (poscnt == 2) - sdpinfo.host = sdp + 1; + sdpinfo.host = line + 1; if (poscnt > 2) break; } - sdp++; + line++; } - } else if (!strncasecmp("m=", sdp, 2)) { + } else if (!strncasecmp("m=", line, 2)) { int poscnt = 0; - sdp += 2; - while (*sdp != 0) { - if (*sdp == ' ') { - *sdp = 0; + line += 2; + while (*line != 0) { + if (*line == ' ') { + *line = 0; poscnt++; /* m= */ if (poscnt == 1) - sdpinfo.port = sdp + 1; + sdpinfo.port = line + 1; if (poscnt == 2) - sdpinfo.proto = sdp + 1; + sdpinfo.proto = line + 1; if (poscnt > 2) break; } - sdp++; + line++; } } - sdp = ++pos; + line = ++pos; continue; } pos++;