Subversion Repositories Kolibri OS

Rev

Rev 5728 | Details | Compare with Previous | Last modification | View Log | RSS feed

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