2015-08-16 09:53:30 +02:00
|
|
|
#include "tinyxml/tinyxml.h"
|
2015-08-16 18:59:54 +02:00
|
|
|
#include "package.h"
|
2015-08-16 09:53:30 +02:00
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
// *INDENT-OFF*
|
2015-08-16 09:53:30 +02:00
|
|
|
const char *key_collection = "collection";
|
|
|
|
const char *key_package = "package";
|
|
|
|
const char *key_name = "name";
|
|
|
|
const char *key_version = "version";
|
2015-09-06 12:18:55 +02:00
|
|
|
const char *key_group = "group";
|
2015-08-16 09:53:30 +02:00
|
|
|
const char *key_description = "description";
|
|
|
|
const char *key_title = "title";
|
|
|
|
const char *key_release = "release";
|
|
|
|
const char *key_file = "file";
|
2015-09-06 12:18:55 +02:00
|
|
|
// *INDENT-ON*
|
2015-08-16 09:53:30 +02:00
|
|
|
|
|
|
|
int package_id;
|
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
collection_t *
|
|
|
|
load_collection_file(const char *name)
|
2015-08-16 09:53:30 +02:00
|
|
|
{
|
|
|
|
TiXmlDocument doc;
|
|
|
|
TiXmlElement *col;
|
2015-09-06 12:18:55 +02:00
|
|
|
collection_t *collection = NULL;
|
2015-08-16 09:53:30 +02:00
|
|
|
|
|
|
|
doc.LoadFile(name);
|
2015-09-06 12:18:55 +02:00
|
|
|
col = doc.FirstChildElement(key_collection);
|
2015-08-16 09:53:30 +02:00
|
|
|
if (col)
|
|
|
|
{
|
2015-09-06 12:18:55 +02:00
|
|
|
TiXmlElement *xmlpkg;
|
|
|
|
TiXmlElement *xmle;
|
|
|
|
|
|
|
|
collection = (collection_t *) malloc(sizeof(collection_t));
|
|
|
|
INIT_LIST_HEAD(&collection->packages);
|
2015-08-16 09:53:30 +02:00
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
xmlpkg = col->FirstChildElement(key_package);
|
|
|
|
|
|
|
|
while (xmlpkg)
|
2015-08-16 09:53:30 +02:00
|
|
|
{
|
2015-09-06 12:18:55 +02:00
|
|
|
package_t *pkg;
|
2015-08-16 09:53:30 +02:00
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
pkg = (package_t *) malloc(sizeof(package_t));
|
2015-08-16 09:53:30 +02:00
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
INIT_LIST_HEAD(&pkg->file_list);
|
2015-08-16 09:53:30 +02:00
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
pkg->id = package_id++;
|
|
|
|
pkg->name = strdup(xmlpkg->Attribute(key_name));
|
|
|
|
pkg->version = strdup(xmlpkg->Attribute(key_version));
|
|
|
|
pkg->group = strdup(xmlpkg->Attribute(key_group));
|
2015-08-16 09:53:30 +02:00
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
xmle = xmlpkg->FirstChildElement(key_description);
|
|
|
|
pkg->description = strdup(xmle->Attribute(key_title));
|
2015-08-16 09:53:30 +02:00
|
|
|
|
2015-09-06 12:18:55 +02:00
|
|
|
xmle = xmlpkg->FirstChildElement(key_release);
|
|
|
|
pkg->filename = strdup(xmle->Attribute(key_file));
|
|
|
|
|
|
|
|
list_add_tail(&pkg->list, &collection->packages);
|
|
|
|
xmlpkg = xmlpkg->NextSiblingElement();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
return collection;
|
|
|
|
};
|