]> git.sesse.net Git - vlc/blob - src/test/xmlent.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / test / xmlent.c
1 /*****************************************************************************
2  * xmlent.c: Test for XML entities
3  *****************************************************************************
4  * Copyright (C) 2006, 2008 Rémi Denis-Courmont
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28
29 #include <vlc_common.h>
30 #include <vlc_strings.h>
31
32 static void decode (const char *in, const char *out)
33 {
34     char buf[strlen (in) + 1];
35
36     printf ("\"%s\" -> \"%s\" ?\n", in, out);
37     strcpy (buf, in);
38     resolve_xml_special_chars (buf);
39
40     if (strcmp (buf, out))
41     {
42         printf (" ERROR: got \"%s\"\n", buf);
43         exit (2);
44     }
45 }
46
47 static void encode (const char *in, const char *out)
48 {
49     char *buf;
50
51     printf ("\"%s\" -> \"%s\" ?\n", in, out);
52     buf = convert_xml_special_chars (in);
53
54     if (strcmp (buf, out))
55     {
56         printf (" ERROR: got \"%s\"\n", buf);
57         exit (2);
58     }
59     free (buf);
60 }
61
62 int main (void)
63 {
64     (void)setvbuf (stdout, NULL, _IONBF, 0);
65     decode ("This should not be modified 1234",
66             "This should not be modified 1234");
67
68     decode ("R&eacute;mi&nbsp;Fran&ccedil;ois&nbsp;&amp;&nbsp;&Eacute;mile",
69             "Rémi François & Émile");
70
71     decode ("", "");
72
73     /* tests with invalid input */
74     decode ("&<\"'", "&<\"'");
75     decode ("&oelig", "&oelig");
76
77     encode ("", "");
78     encode ("a'àc\"çe&én<ño>ö1:", "a&#39;àc&quot;çe&amp;én&lt;ño&gt;ö1:");
79
80     return 0;
81 }