package.h

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, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * $Id: package.h 29603 2005-07-31 16:10:46Z cjwatson $
00021  */
00022 
00023 #ifndef DEBIAN_INSTALLER__PACKAGE_H
00024 #define DEBIAN_INSTALLER__PACKAGE_H
00025 
00026 #include <debian-installer/mem.h>
00027 #include <debian-installer/parser.h>
00028 #include <debian-installer/slist.h>
00029 #include <debian-installer/string.h>
00030 
00031 typedef struct di_package di_package;
00032 typedef struct di_package_dependency di_package_dependency;
00033 typedef struct di_package_version di_package_version;
00034 
00035 typedef enum di_package_dependency_type di_package_dependency_type;
00036 typedef enum di_package_priority di_package_priority;
00037 typedef enum di_package_status di_package_status;
00038 typedef enum di_package_status_want di_package_status_want;
00039 typedef enum di_package_type di_package_type;
00040 
00041 #include <debian-installer/packages.h>
00042 
00051 enum di_package_priority
00052 {
00053   di_package_priority_extra = 1,
00054   di_package_priority_optional,
00055   di_package_priority_standard,
00056   di_package_priority_important,
00057   di_package_priority_required,
00058 };
00059 
00063 enum di_package_status
00064 {
00065   di_package_status_undefined = 0,
00066   di_package_status_not_installed,
00067   di_package_status_unpacked,
00068   di_package_status_installed,
00069   di_package_status_half_configured,
00070   di_package_status_config_files,
00071 };
00072 
00076 enum di_package_status_want
00077 {
00078   di_package_status_want_unknown = 0,
00079   di_package_status_want_install,
00080   di_package_status_want_hold,
00081   di_package_status_want_deinstall,
00082   di_package_status_want_purge,
00083 };
00084 
00088 enum di_package_type
00089 {
00090   di_package_type_non_existent = 0,                     
00091   di_package_type_virtual_package,                      
00092   di_package_type_real_package,                         
00093 };
00094 
00098 struct di_package
00099 {
00100   union
00101   {
00102     char *package;                                      
00103     di_rstring key;                                     
00104   };
00105   di_package_type type;                                 
00106   di_package_status_want status_want;                   
00107   di_package_status status;                             
00108   int essential;                                        
00109   di_package_priority priority;                         
00110   char *section;                                        
00111   int installed_size;                                   
00112   char *maintainer;                                     
00113   char *architecture;                                   
00114   char *version;                                        
00115   di_slist depends;                                     
00116   char *filename;                                       
00117   size_t size;                                          
00118   char *md5sum;                                         
00119   char *short_description;                              
00120   char *description;                                    
00121   unsigned int resolver;                                
00122 };
00123 
00127 enum di_package_dependency_type
00128 {
00129   di_package_dependency_type_replaces = 1,              
00130   di_package_dependency_type_provides,                  
00131   di_package_dependency_type_depends,                   
00132   di_package_dependency_type_pre_depends,               
00133   di_package_dependency_type_recommends,                
00134   di_package_dependency_type_suggests,                  
00135   di_package_dependency_type_conflicts,                 
00136   di_package_dependency_type_enhances,                  
00137   di_package_dependency_type_reverse_provides = 0x100,  
00138   di_package_dependency_type_reverse_enhances,          
00139 };
00140 
00144 struct di_package_dependency
00145 {
00146   di_package_dependency_type type;                      
00147   di_package *ptr;                                      
00148 };
00149 
00153 struct di_package_version
00154 {
00155   unsigned long epoch;                                  
00156   char *upstream;                                       
00157   char *debian_revision;                                
00158 };
00159 
00160 void di_package_destroy (di_package *package);
00161 
00162 static inline di_package *di_package_alloc (di_packages_allocator *allocator)
00163 {
00164   return di_mem_chunk_alloc0 (allocator->package_mem_chunk);
00165 }
00166 
00167 static inline di_package_dependency *di_package_dependency_alloc (di_packages_allocator *allocator)
00168 {
00169   return di_mem_chunk_alloc0 (allocator->package_dependency_mem_chunk);
00170 }
00171 
00172 void di_package_version_free (di_package_version *version);
00173 
00174 int di_package_version_compare (const di_package_version *a, const di_package_version *b);
00175 di_package_version *di_package_version_parse (di_package *package);
00176 
00177 extern const char *const di_package_priority_text[];
00178 extern const char *const di_package_status_want_text[];
00179 extern const char *const di_package_status_text[];
00180 
00181 int di_package_array_text_from (const char *const *array, const char *text);
00182 
00183 static inline di_package_priority di_package_priority_text_from (const char *text)
00184 {
00185   return di_package_array_text_from (di_package_priority_text, text);
00186 }
00187 
00188 static inline di_package_status_want di_package_status_want_text_from (const char *text)
00189 {
00190   return di_package_array_text_from (di_package_status_want_text, text);
00191 }
00192 
00193 static inline di_package_status di_package_status_text_from (const char *text)
00194 {
00195   return di_package_array_text_from (di_package_status_text, text);
00196 }
00197 
00198 static inline const char *di_package_priority_text_to (const di_package_priority priority)
00199 {
00200   return di_package_priority_text[priority];
00201 }
00202 
00203 static inline const char *di_package_status_want_text_to (const di_package_status_want status)
00204 {
00205   return di_package_status_want_text[status];
00206 }
00207 
00208 static inline const char *di_package_status_text_to (const di_package_status status)
00209 {
00210   return di_package_status_text[status];
00211 }
00212 
00220 di_parser_fields_function_read
00224   di_package_parser_read_dependency,
00228   di_package_parser_read_description,
00232   di_package_parser_read_priority,
00236   di_package_parser_read_status;
00237 
00238 di_parser_fields_function_write
00242   di_package_parser_write_dependency,
00246   di_package_parser_write_description,
00250   di_package_parser_write_priority,
00254   di_package_parser_write_status;
00255 
00259 extern const di_parser_fieldinfo *di_package_parser_fieldinfo[];
00260 
00265 di_parser_info *di_package_parser_info (void);
00266 
00274 di_package *di_package_special_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator, di_parser_info *(info) (void));
00275 
00283 static inline di_package *di_package_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator)
00284 {
00285   return di_package_special_read_file (file, packages, allocator, di_package_parser_info);
00286 }
00287 
00289 #endif

Generated on Sat Sep 29 08:45:16 2007 for libdebian-installer by  doxygen 1.5.1