libdebian-installer
|
00001 /* 00002 * package.h 00003 * 00004 * Copyright (C) 2003 Bastian Blank <waldi@debian.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef DEBIAN_INSTALLER__PACKAGE_H 00021 #define DEBIAN_INSTALLER__PACKAGE_H 00022 00023 #include <debian-installer/mem.h> 00024 #include <debian-installer/parser.h> 00025 #include <debian-installer/slist.h> 00026 #include <debian-installer/string.h> 00027 00028 typedef struct di_package di_package; 00029 typedef struct di_package_dependency di_package_dependency; 00030 typedef struct di_package_version di_package_version; 00031 00032 typedef enum di_package_dependency_type di_package_dependency_type; 00033 typedef enum di_package_priority di_package_priority; 00034 typedef enum di_package_status di_package_status; 00035 typedef enum di_package_status_want di_package_status_want; 00036 typedef enum di_package_type di_package_type; 00037 00038 #include <debian-installer/packages.h> 00039 00048 enum di_package_priority 00049 { 00050 di_package_priority_extra = 1, 00051 di_package_priority_optional, 00052 di_package_priority_standard, 00053 di_package_priority_important, 00054 di_package_priority_required, 00055 }; 00056 00060 enum di_package_status 00061 { 00062 di_package_status_undefined = 0, 00063 di_package_status_not_installed, 00064 di_package_status_unpacked, 00065 di_package_status_installed, 00066 di_package_status_half_configured, 00067 di_package_status_config_files, 00068 }; 00069 00073 enum di_package_status_want 00074 { 00075 di_package_status_want_unknown = 0, 00076 di_package_status_want_install, 00077 di_package_status_want_hold, 00078 di_package_status_want_deinstall, 00079 di_package_status_want_purge, 00080 }; 00081 00085 enum di_package_type 00086 { 00087 di_package_type_non_existent = 0, 00088 di_package_type_virtual_package, 00089 di_package_type_real_package, 00090 }; 00091 00095 struct di_package 00096 { 00097 union 00098 { 00099 char *package; 00100 di_rstring key; 00101 }; 00102 di_package_type type; 00103 di_package_status_want status_want; 00104 di_package_status status; 00105 int essential; 00106 di_package_priority priority; 00107 char *section; 00108 int installed_size; 00109 char *maintainer; 00110 char *architecture; 00111 char *version; 00112 di_slist depends; 00113 char *filename; 00114 size_t size; 00115 char *md5sum; 00116 char *short_description; 00117 char *description; 00118 unsigned int resolver; 00119 }; 00120 00124 enum di_package_dependency_type 00125 { 00126 di_package_dependency_type_replaces = 1, 00127 di_package_dependency_type_provides, 00128 di_package_dependency_type_depends, 00129 di_package_dependency_type_pre_depends, 00130 di_package_dependency_type_recommends, 00131 di_package_dependency_type_suggests, 00132 di_package_dependency_type_conflicts, 00133 di_package_dependency_type_enhances, 00134 di_package_dependency_type_reverse_provides = 0x100, 00135 di_package_dependency_type_reverse_enhances, 00136 }; 00137 00141 struct di_package_dependency 00142 { 00143 di_package_dependency_type type; 00144 di_package *ptr; 00145 }; 00146 00150 struct di_package_version 00151 { 00152 unsigned long epoch; 00153 char *upstream; 00154 char *debian_revision; 00155 }; 00156 00157 void di_package_destroy (di_package *package); 00158 00159 static inline di_package *di_package_alloc (di_packages_allocator *allocator) 00160 { 00161 return di_mem_chunk_alloc0 (allocator->package_mem_chunk); 00162 } 00163 00164 static inline di_package_dependency *di_package_dependency_alloc (di_packages_allocator *allocator) 00165 { 00166 return di_mem_chunk_alloc0 (allocator->package_dependency_mem_chunk); 00167 } 00168 00169 void di_package_version_free (di_package_version *version); 00170 00171 int di_package_version_compare (const di_package_version *a, const di_package_version *b); 00172 di_package_version *di_package_version_parse (di_package *package); 00173 00174 extern const char *const di_package_priority_text[]; 00175 extern const char *const di_package_status_want_text[]; 00176 extern const char *const di_package_status_text[]; 00177 00178 int di_package_array_text_from (const char *const *array, const char *text); 00179 00180 static inline di_package_priority di_package_priority_text_from (const char *text) 00181 { 00182 return di_package_array_text_from (di_package_priority_text, text); 00183 } 00184 00185 static inline di_package_status_want di_package_status_want_text_from (const char *text) 00186 { 00187 return di_package_array_text_from (di_package_status_want_text, text); 00188 } 00189 00190 static inline di_package_status di_package_status_text_from (const char *text) 00191 { 00192 return di_package_array_text_from (di_package_status_text, text); 00193 } 00194 00195 static inline const char *di_package_priority_text_to (const di_package_priority priority) 00196 { 00197 return di_package_priority_text[priority]; 00198 } 00199 00200 static inline const char *di_package_status_want_text_to (const di_package_status_want status) 00201 { 00202 return di_package_status_want_text[status]; 00203 } 00204 00205 static inline const char *di_package_status_text_to (const di_package_status status) 00206 { 00207 return di_package_status_text[status]; 00208 } 00209 00217 di_parser_fields_function_read 00221 di_package_parser_read_dependency, 00225 di_package_parser_read_description, 00229 di_package_parser_read_priority, 00233 di_package_parser_read_status; 00234 00235 di_parser_fields_function_write 00239 di_package_parser_write_dependency, 00243 di_package_parser_write_description, 00247 di_package_parser_write_priority, 00251 di_package_parser_write_status; 00252 00256 extern const di_parser_fieldinfo *di_package_parser_fieldinfo[]; 00257 00262 di_parser_info *di_package_parser_info (void); 00263 00271 di_package *di_package_special_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator, di_parser_info *(info) (void)); 00272 00280 static inline di_package *di_package_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator) 00281 { 00282 return di_package_special_read_file (file, packages, allocator, di_package_parser_info); 00283 } 00284 00286 #endif