Annotation of embedaddon/miniupnpd/miniupnpc-async/parsessdpreply.c, revision 1.1.1.1
1.1 misho 1: /* $Id: parsessdpreply.c,v 1.2 2009/11/14 10:37:55 nanard Exp $ */
2: /* Project : miniupnp
3: * website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4: * Author : Thomas Bernard
5: * copyright (c) 2005-2009 Thomas Bernard
6: *
7: * Permission to use, copy, modify, and/or distribute this software for any
8: * purpose with or without fee is hereby granted, provided that the above
9: * copyright notice and this permission notice appear in all copies.
10: *
11: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
18: #include <strings.h>
19: #include "parsessdpreply.h"
20:
21: /* parseMSEARCHReply()
22: * the last 4 arguments are filled during the parsing :
23: * - location/locationsize : "location:" field of the SSDP reply packet
24: * - st/stsize : "st:" field of the SSDP reply packet.
25: * The strings are NOT null terminated */
26: void
27: parseMSEARCHReply(const char * reply, int size,
28: const char * * location, int * locationsize,
29: const char * * st, int * stsize)
30: {
31: int a, b, i;
32: i = 0;
33: a = i; /* start of the line */
34: b = 0;
35: while(i<size)
36: {
37: switch(reply[i])
38: {
39: case ':':
40: if(b==0)
41: {
42: b = i; /* end of the "header" */
43: /*for(j=a; j<b; j++)
44: {
45: putchar(reply[j]);
46: }
47: */
48: }
49: break;
50: case '\x0a':
51: case '\x0d':
52: if(b!=0)
53: {
54: /*for(j=b+1; j<i; j++)
55: {
56: putchar(reply[j]);
57: }
58: putchar('\n');*/
59: do { b++; } while(reply[b]==' ');
60: if(0==strncasecmp(reply+a, "location:", 9))
61: {
62: *location = reply+b;
63: *locationsize = i-b;
64: }
65: else if(0==strncasecmp(reply+a, "st:", 3))
66: {
67: *st = reply+b;
68: *stsize = i-b;
69: }
70: b = 0;
71: }
72: a = i+1;
73: break;
74: default:
75: break;
76: }
77: i++;
78: }
79: }
80:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>