package.h
/*
* package.h
*
* Copyright (C) 2003 Bastian Blank <waldi@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEBIAN_INSTALLER__PACKAGE_H
#define DEBIAN_INSTALLER__PACKAGE_H
#include <debian-installer/mem.h>
#include <debian-installer/parser.h>
#include <debian-installer/slist.h>
#include <debian-installer/string.h>
typedef struct di_package di_package;
typedef struct di_package_dependency di_package_dependency;
typedef struct di_package_version di_package_version;
typedef enum di_package_dependency_type di_package_dependency_type;
typedef enum di_package_priority di_package_priority;
typedef enum di_package_status di_package_status;
typedef enum di_package_status_want di_package_status_want;
typedef enum di_package_type di_package_type;
#include <debian-installer/packages.h>
enum di_package_priority
{
di_package_priority_extra = 1,
di_package_priority_optional,
di_package_priority_standard,
di_package_priority_important,
di_package_priority_required,
};
enum di_package_status
{
di_package_status_undefined = 0,
di_package_status_not_installed,
di_package_status_unpacked,
di_package_status_installed,
di_package_status_half_configured,
di_package_status_config_files,
};
enum di_package_status_want
{
di_package_status_want_unknown = 0,
di_package_status_want_install,
di_package_status_want_hold,
di_package_status_want_deinstall,
di_package_status_want_purge,
};
enum di_package_type
{
di_package_type_non_existent = 0,
di_package_type_virtual_package,
di_package_type_real_package,
};
struct di_package
{
union
{
char *package;
di_rstring key;
};
di_package_type type;
di_package_status_want status_want;
di_package_status status;
int essential;
di_package_priority priority;
char *section;
int installed_size;
char *maintainer;
char *architecture;
char *version;
di_slist depends;
char *filename;
size_t size;
char *sha256;
char *short_description;
char *description;
unsigned int resolver;
};
enum di_package_dependency_type
{
di_package_dependency_type_replaces = 1,
di_package_dependency_type_provides,
di_package_dependency_type_depends,
di_package_dependency_type_pre_depends,
di_package_dependency_type_recommends,
di_package_dependency_type_suggests,
di_package_dependency_type_conflicts,
di_package_dependency_type_enhances,
di_package_dependency_type_reverse_provides = 0x100,
di_package_dependency_type_reverse_enhances,
};
struct di_package_dependency
{
di_package_dependency_type type;
di_package *ptr;
};
struct di_package_version
{
unsigned long epoch;
char *upstream;
char *debian_revision;
};
void di_package_destroy (di_package *package);
static inline di_package *di_package_alloc (di_packages_allocator *allocator)
{
return di_mem_chunk_alloc0 (allocator->package_mem_chunk);
}
static inline di_package_dependency *di_package_dependency_alloc (di_packages_allocator *allocator)
{
return di_mem_chunk_alloc0 (allocator->package_dependency_mem_chunk);
}
void di_package_version_free (di_package_version *version);
int di_package_version_compare (const di_package_version *a, const di_package_version *b);
di_package_version *di_package_version_parse (di_package *package);
extern const char *const di_package_priority_text[];
extern const char *const di_package_status_want_text[];
extern const char *const di_package_status_text[];
int di_package_array_text_from (const char *const *array, const char *text);
static inline di_package_priority di_package_priority_text_from (const char *text)
{
return di_package_array_text_from (di_package_priority_text, text);
}
static inline di_package_status_want di_package_status_want_text_from (const char *text)
{
return di_package_array_text_from (di_package_status_want_text, text);
}
static inline di_package_status di_package_status_text_from (const char *text)
{
return di_package_array_text_from (di_package_status_text, text);
}
static inline const char *di_package_priority_text_to (const di_package_priority priority)
{
return di_package_priority_text[priority];
}
static inline const char *di_package_status_want_text_to (const di_package_status_want status)
{
return di_package_status_want_text[status];
}
static inline const char *di_package_status_text_to (const di_package_status status)
{
return di_package_status_text[status];
}
di_parser_fields_function_read
di_package_parser_read_dependency,
di_package_parser_read_description,
di_package_parser_read_priority,
di_package_parser_read_status;
di_parser_fields_function_write
di_package_parser_write_dependency,
di_package_parser_write_description,
di_package_parser_write_priority,
di_package_parser_write_status;
extern const di_parser_fieldinfo *di_package_parser_fieldinfo[];
di_parser_info *di_package_parser_info (void);
di_package *di_package_special_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator, di_parser_info *(info) (void));
static inline di_package *di_package_read_file (const char *file, di_packages *packages, di_packages_allocator *allocator)
{
return di_package_special_read_file (file, packages, allocator, di_package_parser_info);
}
#endif
di_mem_chunk_alloc0
void * di_mem_chunk_alloc0(di_mem_chunk *mem_chunk)
Definition mem_chunk.c:156
di_package_special_read_file
di_package * di_package_special_read_file(const char *file, di_packages *packages, di_packages_allocator *allocator, di_parser_info *(info)(void))
di_package_parser_write_description
di_parser_fields_function_write di_package_parser_write_description
Definition package.h:243
di_package_parser_read_description
di_parser_fields_function_read di_package_parser_read_description
Definition package.h:225
di_package_parser_info
di_parser_info * di_package_parser_info(void)
Definition package_parser.c:233
di_package_read_file
static di_package * di_package_read_file(const char *file, di_packages *packages, di_packages_allocator *allocator)
Definition package.h:280
di_package_parser_read_priority
di_parser_fields_function_read di_package_parser_read_priority
Definition package.h:229
di_package_parser_read_status
di_parser_fields_function_read di_package_parser_read_status
Definition package.h:233
di_package_parser_write_status
di_parser_fields_function_write di_package_parser_write_status
Definition package.h:251
di_package_parser_write_priority
di_parser_fields_function_write di_package_parser_write_priority
Definition package.h:247
di_package_parser_fieldinfo
const di_parser_fieldinfo * di_package_parser_fieldinfo[]
Definition package_parser.c:200
di_package_parser_read_dependency
di_parser_fields_function_read di_package_parser_read_dependency
Definition package.h:221
di_package_parser_write_dependency
di_parser_fields_function_write di_package_parser_write_dependency
Definition package.h:239
di_package_priority
di_package_priority
Definition package.h:49
di_package_status_want
di_package_status_want
Definition package.h:74
di_package_type
di_package_type
Definition package.h:86
di_package_status
di_package_status
Definition package.h:61
di_package_dependency_type
di_package_dependency_type
Definition package.h:125
di_package_type_virtual_package
@ di_package_type_virtual_package
Definition package.h:88
di_package_type_real_package
@ di_package_type_real_package
Definition package.h:89
di_package_type_non_existent
@ di_package_type_non_existent
Definition package.h:87
di_package_dependency_type_pre_depends
@ di_package_dependency_type_pre_depends
Definition package.h:129
di_package_dependency_type_reverse_enhances
@ di_package_dependency_type_reverse_enhances
Definition package.h:135
di_package_dependency_type_replaces
@ di_package_dependency_type_replaces
Definition package.h:126
di_package_dependency_type_conflicts
@ di_package_dependency_type_conflicts
Definition package.h:132
di_package_dependency_type_provides
@ di_package_dependency_type_provides
Definition package.h:127
di_package_dependency_type_depends
@ di_package_dependency_type_depends
Definition package.h:128
di_package_dependency_type_enhances
@ di_package_dependency_type_enhances
Definition package.h:133
di_package_dependency_type_suggests
@ di_package_dependency_type_suggests
Definition package.h:131
di_package_dependency_type_recommends
@ di_package_dependency_type_recommends
Definition package.h:130
di_package_dependency_type_reverse_provides
@ di_package_dependency_type_reverse_provides
Definition package.h:134
di_parser_fields_function_write
void di_parser_fields_function_write(void **data, const di_parser_fieldinfo *fip, di_parser_fields_function_write_callback callback, void *callback_data, void *user_data)
Definition parser.h:70
di_parser_fields_function_read
void di_parser_fields_function_read(void **data, const di_parser_fieldinfo *fip, di_rstring *field_modifier, di_rstring *value, void *user_data)
Definition parser.h:49
di_package_dependency
Package dependency.
Definition package.h:142
di_package_dependency::type
di_package_dependency_type type
Definition package.h:143
di_package_dependency::ptr
di_package * ptr
Definition package.h:144
di_package_version
Package version.
Definition package.h:151
di_package_version::upstream
char * upstream
Definition package.h:153
di_package_version::epoch
unsigned long epoch
Definition package.h:152
di_package_version::debian_revision
char * debian_revision
Definition package.h:154
di_package
Package.
Definition package.h:96
di_package::maintainer
char * maintainer
Definition package.h:109
di_package::priority
di_package_priority priority
Definition package.h:106
di_package::section
char * section
Definition package.h:107
di_package::depends
di_slist depends
Definition package.h:112
di_package::resolver
unsigned int resolver
Definition package.h:118
di_package::version
char * version
Definition package.h:111
di_package::architecture
char * architecture
Definition package.h:110
di_package::description
char * description
Definition package.h:117
di_package::essential
int essential
Definition package.h:105
di_package::size
size_t size
Definition package.h:114
di_package::short_description
char * short_description
Definition package.h:116
di_package::type
di_package_type type
Definition package.h:102
di_package::sha256
char * sha256
Definition package.h:115
di_package::status
di_package_status status
Definition package.h:104
di_package::status_want
di_package_status_want status_want
Definition package.h:103
di_package::filename
char * filename
Definition package.h:113
di_package::key
di_rstring key
Definition package.h:100
di_package::installed_size
int installed_size
Definition package.h:108
di_package::package
char * package
Definition package.h:99
di_packages_allocator
Packages file - Allocator.
Definition packages.h:53
di_packages_allocator::package_mem_chunk
di_mem_chunk * package_mem_chunk
Definition packages.h:54
di_packages_allocator::package_dependency_mem_chunk
di_mem_chunk * package_dependency_mem_chunk
Definition packages.h:55
di_packages
Packages file.
Definition packages.h:42
di_parser_fieldinfo
Info about a parser field.
Definition parser.h:105
di_parser_info
Parse info.
Definition parser.h:94
di_rstring
raw string
Definition string.h:38
di_slist
Single-linked list.
Definition slist.h:37