File: test-subclassing.c

package info (click to toggle)
shared-mime-info 1.3-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 7,764 kB
  • sloc: ansic: 3,674; xml: 1,063; sh: 1,027; makefile: 146
file content (47 lines) | stat: -rw-r--r-- 943 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <libxml/tree.h>
#include <stdio.h>
#include <string.h>

int
main (int    argc,
      char **argv)
{
	xmlDocPtr doc;
	xmlNodePtr node;

	doc = xmlReadFile ("freedesktop.org.xml", NULL, 0);
	if (doc == NULL) {
		fprintf (stderr, "Reading \"freedesktop.org.xml\" failed. Aborting.\n");
		return 1;
	}

	if ((node = xmlDocGetRootElement (doc)) == NULL) {
		fprintf (stderr, "\"freedesktop.org.xml\" has no root node. Aborting.\n");
		return 1;
	}

	for (node = node->children; node != NULL; node = node->next) {
		if (!strcmp ((char *) node->name, "mime-type")) {
			xmlNodePtr p;
			xmlChar *prop;

			for (p = node->children; p != NULL; p = p->next) {
				if (!strcmp ((char *) p->name, "sub-class-of")) {
					break;
				}
			}

			if (p != NULL) {
				/* got sub-class-of node */
				continue;
			}

			prop = xmlGetProp (node, (xmlChar *) "type");
			printf ("%s\n", prop);
			xmlFree (prop);
		}
	}

	xmlFreeDoc (doc);
	return 0;
}