[docs] Replace cyrillic 'с' with latin 'c' in register names
[kolibrios.git] / contrib / other / kpm / collection.cpp
blob009f5dc0b93bd882c35f98a4b4c72884372c8fe1
1 #include "tinyxml/tinyxml.h"
2 #include "package.h"
4 // *INDENT-OFF*
5 const char *key_collection = "collection";
6 const char *key_package = "package";
7 const char *key_name = "name";
8 const char *key_version = "version";
9 const char *key_group = "group";
10 const char *key_description = "description";
11 const char *key_title = "title";
12 const char *key_release = "release";
13 const char *key_file = "file";
14 // *INDENT-ON*
16 int package_id;
18 collection_t *
19 load_collection_file(const char *name)
21 TiXmlDocument doc;
22 TiXmlElement *col;
23 collection_t *collection = NULL;
25 doc.LoadFile(name);
26 col = doc.FirstChildElement(key_collection);
27 if (col)
29 TiXmlElement *xmlpkg;
30 TiXmlElement *xmle;
32 collection = (collection_t *) malloc(sizeof(collection_t));
33 INIT_LIST_HEAD(&collection->packages);
35 xmlpkg = col->FirstChildElement(key_package);
37 while (xmlpkg)
39 package_t *pkg;
41 pkg = (package_t *) malloc(sizeof(package_t));
43 INIT_LIST_HEAD(&pkg->file_list);
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));
50 xmle = xmlpkg->FirstChildElement(key_description);
51 pkg->description = strdup(xmle->Attribute(key_title));
53 xmle = xmlpkg->FirstChildElement(key_release);
54 pkg->filename = strdup(xmle->Attribute(key_file));
56 list_add_tail(&pkg->list, &collection->packages);
57 xmlpkg = xmlpkg->NextSiblingElement();
61 return collection;