libdebian-installer
packages.h
00001 /*
00002  * packages.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__PACKAGES_H
00021 #define DEBIAN_INSTALLER__PACKAGES_H
00022 
00023 #include <debian-installer/hash.h>
00024 #include <debian-installer/parser.h>
00025 #include <debian-installer/slist.h>
00026 
00027 #include <stddef.h>
00028 #include <string.h>
00029 
00030 typedef struct di_packages di_packages;
00031 typedef struct di_packages_allocator di_packages_allocator;
00032 
00041 struct di_packages
00042 {
00043   di_hash_table *table;                                 
00044   di_slist list;                                        
00045   unsigned int resolver;                                
00046 };
00047 
00052 struct di_packages_allocator
00053 {
00054   di_mem_chunk *package_mem_chunk;                      
00055   di_mem_chunk *package_dependency_mem_chunk;           
00056   di_mem_chunk *slist_node_mem_chunk;                   
00057 };
00058 
00059 #include <debian-installer/package.h>
00060 
00061 di_packages *di_packages_alloc (void);
00062 void di_packages_free (di_packages *packages);
00063 
00064 di_packages_allocator *di_packages_allocator_alloc (void);
00065 void di_packages_allocator_free (di_packages_allocator *packages);
00066 
00067 void di_packages_append_package (di_packages *packages, di_package *package, di_packages_allocator *allocator);
00068 di_package *di_packages_get_package (di_packages *packages, const char *name, size_t n);
00069 di_package *di_packages_get_package_new (di_packages *packages, di_packages_allocator *allocator, char *name, size_t n);
00070 
00071 di_slist *di_packages_resolve_dependencies (di_packages *packages, di_slist *list, di_packages_allocator *allocator);
00072 di_slist *di_packages_resolve_dependencies_array (di_packages *packages, di_package **array, di_packages_allocator *allocator);
00073 void di_packages_resolve_dependencies_mark (di_packages *packages);
00074 
00077 di_parser_fields_function_read
00078   di_packages_parser_read_name;
00079 
00085 extern const di_parser_fieldinfo *di_packages_parser_fieldinfo[];
00086 extern const di_parser_fieldinfo *di_packages_status_parser_fieldinfo[];
00087 extern const di_parser_fieldinfo *di_packages_minimal_parser_fieldinfo[];
00088 
00089 di_parser_info *di_packages_parser_info (void);
00090 di_parser_info *di_packages_minimal_parser_info (void);
00091 di_parser_info *di_packages_status_parser_info (void);
00092 
00098 di_packages *di_packages_special_read_file (const char *file, di_packages_allocator *allocator, di_parser_info *(info) (void));
00099 
00108 int di_packages_special_write_file (di_packages *packages, const char *file, di_parser_info *(info) (void));
00109 
00116 static inline di_packages *di_packages_read_file (const char *file, di_packages_allocator *allocator)
00117 {
00118   return di_packages_special_read_file (file, allocator, di_packages_parser_info);
00119 }
00120 
00127 static inline di_packages *di_packages_minimal_read_file (const char *file, di_packages_allocator *allocator)
00128 {
00129   return di_packages_special_read_file (file, allocator, di_packages_minimal_parser_info);
00130 }
00131 
00138 static inline di_packages *di_packages_status_read_file (const char *file, di_packages_allocator *allocator)
00139 {
00140   return di_packages_special_read_file (file, allocator, di_packages_status_parser_info);
00141 }
00142 
00151 static inline int di_packages_write_file (di_packages *packages, const char *file)
00152 {
00153   return di_packages_special_write_file (packages, file, di_packages_parser_info);
00154 }
00155 
00164 static inline int di_packages_status_write_file (di_packages *packages, const char *file)
00165 {
00166   return di_packages_special_write_file (packages, file, di_packages_status_parser_info);
00167 }
00168 
00170 #endif