Rev 5727 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5727 | Rev 5728 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "tinyxml/tinyxml.h" |
1 | #include "tinyxml/tinyxml.h" |
2 | #include "collection.h" |
2 | #include "package.h" |
3 | #include |
- | |
Line 4... | Line 3... | ||
4 | 3 | ||
5 | const char *key_collection = "collection"; |
4 | const char *key_collection = "collection"; |
6 | const char *key_package = "package"; |
5 | const char *key_package = "package"; |
7 | const char *key_name = "name"; |
6 | const char *key_name = "name"; |
Line 22... | Line 21... | ||
22 | while (xmlpkg) |
21 | while (xmlpkg) |
23 | { |
22 | { |
24 | package_t *pkg; |
23 | package_t *pkg; |
Line 25... | Line 24... | ||
25 | 24 | ||
- | 25 | pkg = (package_t*)malloc(sizeof(package_t)); |
|
- | 26 | ||
26 | pkg = (package_t*)malloc(sizeof(package_t)); |
27 | INIT_LIST_HEAD(&pkg->file_list); |
27 | pkg->id = package_id++; |
28 | pkg->id = package_id++; |
28 | pkg->name = strdup(xmlpkg->Attribute(key_name)); |
29 | pkg->name = strdup(xmlpkg->Attribute(key_name)); |
Line 29... | Line 30... | ||
29 | pkg->version = strdup(xmlpkg->Attribute(key_version)); |
30 | pkg->version = strdup(xmlpkg->Attribute(key_version)); |
Line 69... | Line 70... | ||
69 | }; |
70 | }; |
Line 70... | Line 71... | ||
70 | 71 | ||
71 | return collection; |
72 | return collection; |
Line 72... | Line -... | ||
72 | } |
- | |
73 | - | ||
74 | int build_install_list(list_t *list, collection_t *collection) |
- | |
75 | { |
- | |
76 | pkg_group_t *gr; |
- | |
77 | int count = 0; |
- | |
78 | - | ||
79 | list_for_each_entry(gr, &collection->groups, list) |
- | |
80 | { |
- | |
81 | package_t *pkg, *tmp; |
- | |
82 | - | ||
83 | list_for_each_entry(tmp, &gr->packages, list) |
- | |
84 | { |
- | |
85 | pkg = (package_t*)malloc(sizeof(package_t)); |
- | |
86 | - | ||
87 | pkg->id = tmp->id; |
- | |
88 | pkg->name = strdup(tmp->name); |
- | |
89 | pkg->version = strdup(tmp->version); |
- | |
90 | pkg->filename = strdup(tmp->filename); |
- | |
91 | pkg->description = strdup(tmp->description); |
- | |
92 | list_add_tail(&pkg->list, list); |
- | |
93 | // printf("add package %s-%s\n", pkg->name, pkg->version); |
- | |
94 | - | ||
95 | count++; |
- | |
96 | } |
- | |
97 | }; |
- | |
98 | return count; |
- | |
99 | } |
- | |
100 | - | ||
101 | int build_download_list(list_t *download, list_t *src) |
- | |
102 | { |
- | |
103 | int count = 0; |
- | |
104 | char *cache_path; |
- | |
105 | package_t *pkg, *tmp; |
- | |
106 | fileinfo_t info; |
- | |
107 | list_for_each_entry(tmp, src, list) |
- | |
Line 108... | Line -... | ||
108 | { |
- | |
109 | cache_path = make_cache_path(tmp->filename); |
- | |
110 | - | ||
111 | if( get_fileinfo(cache_path, &info) != 0) |
- | |
112 | { |
- | |
113 | pkg = (package_t*)malloc(sizeof(package_t)); |
- | |
114 | - | ||
115 | pkg->id = tmp->id; |
- | |
116 | pkg->name = strdup(tmp->name); |
- | |
117 | pkg->version = strdup(tmp->version); |
- | |
118 | pkg->filename = strdup(tmp->filename); |
- | |
119 | pkg->description = strdup(tmp->description); |
- | |
120 | list_add_tail(&pkg->list, download); |
- | |
121 | count++; |
- | |
122 | printf("add package %s-%s\n", pkg->name, pkg->version); |
- | |
123 | }; |
- |