libdebian-installer
package.h
1 /*
2  * package.h
3  *
4  * Copyright (C) 2003 Bastian Blank <waldi@debian.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef DEBIAN_INSTALLER__PACKAGE_H
21 #define DEBIAN_INSTALLER__PACKAGE_H
22 
23 #include <debian-installer/mem.h>
24 #include <debian-installer/parser.h>
25 #include <debian-installer/slist.h>
26 #include <debian-installer/string.h>
27 
28 typedef struct di_package di_package;
31 
36 typedef enum di_package_type di_package_type;
37 
38 #include <debian-installer/packages.h>
39 
49 {
50  di_package_priority_extra = 1,
51  di_package_priority_optional,
52  di_package_priority_standard,
53  di_package_priority_important,
54  di_package_priority_required,
55 };
56 
61 {
62  di_package_status_undefined = 0,
63  di_package_status_not_installed,
64  di_package_status_unpacked,
65  di_package_status_installed,
66  di_package_status_half_configured,
67  di_package_status_config_files,
68 };
69 
74 {
75  di_package_status_want_unknown = 0,
76  di_package_status_want_install,
77  di_package_status_want_hold,
78  di_package_status_want_deinstall,
79  di_package_status_want_purge,
80 };
81 
86 {
90 };
91 
95 struct di_package
96 {
97  union
98  {
99  char *package;
101  };
105  int essential;
107  char *section;
109  char *maintainer;
110  char *architecture;
111  char *version;
113  char *filename;
114  size_t size;
115  char *md5sum;
117  char *description;
118  unsigned int resolver;
119 };
120 
125 {
136 };
137 
142 {
145 };
146 
151 {
152  unsigned long epoch;
153  char *upstream;
155 };
156 
157 void di_package_destroy (di_package *package);
158 
159 static inline di_package *di_package_alloc (di_packages_allocator *allocator)
160 {
161  return di_mem_chunk_alloc0 (allocator->package_mem_chunk);
162 }
163 
164 static inline di_package_dependency *di_package_dependency_alloc (di_packages_allocator *allocator)
165 {
167 }
168 
169 void di_package_version_free (di_package_version *version);
170 
171 int di_package_version_compare (const di_package_version *a, const di_package_version *b);
172 di_package_version *di_package_version_parse (di_package *package);
173 
174 extern const char *const di_package_priority_text[];
175 extern const char *const di_package_status_want_text[];
176 extern const char *const di_package_status_text[];
177 
178 int di_package_array_text_from (const char *const *array, const char *text);
179 
180 static inline di_package_priority di_package_priority_text_from (const char *text)
181 {
182  return di_package_array_text_from (di_package_priority_text, text);
183 }
184 
185 static inline di_package_status_want di_package_status_want_text_from (const char *text)
186 {
187  return di_package_array_text_from (di_package_status_want_text, text);
188 }
189 
190 static inline di_package_status di_package_status_text_from (const char *text)
191 {
192  return di_package_array_text_from (di_package_status_text, text);
193 }
194 
195 static inline const char *di_package_priority_text_to (const di_package_priority priority)
196 {
197  return di_package_priority_text[priority];
198 }
199 
200 static inline const char *di_package_status_want_text_to (const di_package_status_want status)
201 {
202  return di_package_status_want_text[status];
203 }
204 
205 static inline const char *di_package_status_text_to (const di_package_status status)
206 {
207  return di_package_status_text[status];
208 }
209 
234 
252 
257 
263 
271 di_package *di_package_special_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator, di_parser_info *(info) (void));
272 
280 static inline di_package *di_package_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator)
281 {
282  return di_package_special_read_file (file, packages, allocator, di_package_parser_info);
283 }
284 
286 #endif