Subversion Repositories Kolibri OS

Rev

Rev 5728 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5728 Rev 5809
Line 1... Line 1...
1
#include "tinyxml/tinyxml.h"
1
#include "tinyxml/tinyxml.h"
2
#include "package.h"
2
#include "package.h"
Line -... Line 3...
-
 
3
 
3
 
4
// *INDENT-OFF*
4
const char *key_collection  = "collection";
5
const char *key_collection  = "collection";
5
const char *key_package     = "package";
6
const char *key_package     = "package";
6
const char *key_name        = "name";
7
const char *key_name        = "name";
-
 
8
const char *key_version     = "version";
7
const char *key_version     = "version";
9
const char *key_group       = "group";
8
const char *key_description = "description";
10
const char *key_description = "description";
9
const char *key_title       = "title";
11
const char *key_title       = "title";
10
const char *key_release     = "release";
12
const char *key_release     = "release";
-
 
13
const char *key_file        = "file";
Line 11... Line 14...
11
const char *key_file        = "file";
14
// *INDENT-ON*
Line -... Line 15...
-
 
15
 
-
 
16
int package_id;
-
 
17
 
-
 
18
collection_t *
-
 
19
load_collection_file(const char *name)
-
 
20
{
-
 
21
	TiXmlDocument doc;
-
 
22
	TiXmlElement *col;
12
 
23
	collection_t *collection = NULL;
-
 
24
 
13
int package_id;
25
	doc.LoadFile(name);
14
 
26
	col = doc.FirstChildElement(key_collection);
15
void parse_group(pkg_group_t* gr, TiXmlElement *xmlgroup)
27
	if (col)
Line -... Line 28...
-
 
28
	{
-
 
29
		TiXmlElement *xmlpkg;
-
 
30
		TiXmlElement *xmle;
16
{
31
 
-
 
32
		collection = (collection_t *) malloc(sizeof(collection_t));
17
	TiXmlElement *xmlpkg;
33
		INIT_LIST_HEAD(&collection->packages);
18
	TiXmlElement *xmle;
34
 
19
 
35
		xmlpkg = col->FirstChildElement(key_package);
Line 20... Line 36...
20
    xmlpkg = xmlgroup->FirstChildElement(key_package);
36
 
Line 21... Line 37...
21
	while (xmlpkg)
37
		while (xmlpkg)
-
 
38
		{
22
	{
39
			package_t *pkg;
23
		package_t *pkg;
40
 
24
 
41
			pkg = (package_t *) malloc(sizeof(package_t));
-
 
42
 
Line 25... Line 43...
25
		pkg = (package_t*)malloc(sizeof(package_t));
43
			INIT_LIST_HEAD(&pkg->file_list);
26
 
44
 
Line 27... Line 45...
27
        INIT_LIST_HEAD(&pkg->file_list);
45
			pkg->id = package_id++;
28
		pkg->id = package_id++;
46
			pkg->name = strdup(xmlpkg->Attribute(key_name));
Line 29... Line 47...
29
        pkg->name = strdup(xmlpkg->Attribute(key_name));
47
			pkg->version = strdup(xmlpkg->Attribute(key_version));
30
        pkg->version = strdup(xmlpkg->Attribute(key_version));
48
			pkg->group = strdup(xmlpkg->Attribute(key_group));
31
 
49
 
32
        xmle = xmlpkg->FirstChildElement(key_description);
50
			xmle = xmlpkg->FirstChildElement(key_description);
Line 33... Line -...
33
        pkg->description = strdup(xmle->Attribute(key_title));
-
 
34
 
-
 
35
        xmle = xmlpkg->FirstChildElement(key_release);
-
 
36
        pkg->filename = strdup(xmle->Attribute(key_file));
-
 
37
 
-
 
38
        list_add_tail(&pkg->list, &gr->packages);
-
 
39
		xmlpkg = xmlpkg->NextSiblingElement();
-
 
40
	};
-
 
41
};
-
 
42
 
-
 
43
 
-
 
44
collection_t* load_collection_file(const char *name)
-
 
45
{
-
 
46
	TiXmlDocument doc;
-
 
47
	TiXmlElement *col;
-
 
48
    collection_t *collection = NULL;
-
 
49
 
-
 
50
	doc.LoadFile(name);
-
 
51
    col = doc.FirstChildElement(key_collection);
-
 
52
	if (col)
-
 
53
	{
-
 
54
        collection = (collection_t*)malloc(sizeof(collection_t));
-
 
55
        INIT_LIST_HEAD(&collection->groups);
-
 
56
 
-
 
57
		TiXmlElement* xmlgroup = col->FirstChildElement();
-
 
58
		if (xmlgroup)
-
 
59
		{
-
 
60
			pkg_group_t *gr;
-
 
61
 
-
 
62
			gr = (pkg_group_t*)malloc(sizeof(pkg_group_t));
51
			pkg->description = strdup(xmle->Attribute(key_title));
63
			INIT_LIST_HEAD(&gr->list);
52
 
64
			INIT_LIST_HEAD(&gr->packages);
-
 
65
 
-