source: titan/minidlna-1.0.22/testupnpdescgen.c @ 15746

Last change on this file since 15746 was 13567, checked in by obi, 12 years ago

[titan] add minidlna-1.0.22 first step

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