libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / minidlna / testupnpdescgen.c
blob5d884433eb0152aa8aa5867bef1e8b0adbf60157
1 /* MiniUPnP project
2 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * Copyright (c) 2006-2008, Thomas Bernard
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <string.h>
33 #include "config.h"
34 #include "upnpdescgen.h"
36 char uuidvalue[] = "uuid:12345678-0000-0000-0000-00000000abcd";
37 char friendly_name[] = "localhost: system_type";
38 char serialnumber[] = "12345678";
39 char modelname[] = "MiniDLNA";
40 char modelnumber[] = "1";
41 char presentationurl[] = "http://192.168.0.1:8080/";
42 unsigned int updateID = 0;
43 #if PNPX
44 char pnpx_hwid[] = "VEN_01F2&amp;DEV_0101&amp;REV_01 VEN_0033&amp;DEV_0001&amp;REV_01";
45 #endif
47 int getifaddr(const char * ifname, char * buf, int len)
49 strncpy(buf, "1.2.3.4", len);
50 return 0;
53 int upnp_get_portmapping_number_of_entries()
55 return 42;
58 /* To be improved */
59 int
60 xml_pretty_print(const char * s, int len, FILE * f)
62 int n = 0, i;
63 int elt_close = 0;
64 int c, indent = 0;
65 while(len > 0)
67 c = *(s++); len--;
68 switch(c)
70 case '<':
71 if(len>0 && *s == '/')
72 elt_close++;
73 else if(len>0 && *s == '?')
74 elt_close = 1;
75 else
76 elt_close = 0;
77 if(elt_close!=1)
79 if(elt_close > 1)
80 indent--;
81 fputc('\n', f); n++;
82 for(i=indent; i>0; i--)
83 fputc(' ', f);
84 n += indent;
86 fputc(c, f); n++;
87 break;
88 case '>':
89 fputc(c, f); n++;
90 if(elt_close==1)
92 /*fputc('\n', f); n++; */
93 //elt_close = 0;
94 if(indent > 0)
95 indent--;
97 else if(elt_close == 0)
98 indent++;
99 break;
100 default:
101 fputc(c, f); n++;
104 return n;
107 /* stupid test */
108 const char * str1 = "Prefix123String";
109 const char * str2 = "123String";
111 void stupid_test()
113 printf("str1:'%s' str2:'%s'\n", str1, str2);
114 printf("str1:%p str2:%p str2-str1:%ld\n", str1, str2, (long)(str2-str1));
117 /* main */
120 main(int argc, char * * argv)
122 char * rootDesc;
123 int rootDescLen;
124 char * s;
125 int l;
126 rootDesc = genRootDesc(&rootDescLen);
127 xml_pretty_print(rootDesc, rootDescLen, stdout);
128 free(rootDesc);
129 printf("\n----------------\n");
130 printf("ContentDirectory\n");
131 printf("----------------\n");
132 s = genContentDirectory(&l);
133 xml_pretty_print(s, l, stdout);
134 free(s);
135 printf("\n----------------\n");
136 printf("ConnectionManager\n");
137 printf("----------------\n");
138 s = genConnectionManager(&l);
139 xml_pretty_print(s, l, stdout);
140 free(s);
141 printf("\n----------------\n");
142 printf("X_MS_MRR\n");
143 printf("----------------\n");
144 s = genX_MS_MediaReceiverRegistrar(&l);
145 xml_pretty_print(s, l, stdout);
146 free(s);
147 printf("\n-------------\n");
149 stupid_test();
151 return 0;