razor.h
author Kristian H?gsberg <krh@redhat.com>
Wed Sep 19 14:34:11 2007 -0400 (2007-09-19)
changeset 29 28a13008d80b
parent 27 5dbd81809d26
child 30 702c01e59497
permissions -rw-r--r--
Fix swapping of map entries in __qsort_with_data.
     1 #ifndef _RAZOR_H_
     2 #define _RAZOR_H_
     3 
     4 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
     5 
     6 struct array {
     7 	void *data;
     8 	int size, alloc;
     9 };
    10 
    11 struct razor_set_section {
    12 	unsigned int type;
    13 	unsigned int offset;
    14 	unsigned int size;
    15 };
    16 
    17 struct razor_set_header {
    18 	unsigned int magic;
    19 	unsigned int version;
    20 	struct razor_set_section sections[0];
    21 };
    22 
    23 #define RAZOR_MAGIC 0x7a7a7a7a
    24 #define RAZOR_VERSION 1
    25 
    26 #define RAZOR_PACKAGES 0
    27 #define RAZOR_REQUIRES 1
    28 #define RAZOR_PROVIDES 2
    29 #define RAZOR_STRING_POOL 3
    30 #define RAZOR_PROPERTY_POOL 4
    31 
    32 struct razor_package {
    33 	unsigned long name;
    34 	unsigned long version;
    35 	unsigned long requires;
    36 	unsigned long provides;
    37 };
    38 
    39 struct razor_property {
    40 	unsigned long name;
    41 	unsigned long version;
    42 	unsigned long packages;
    43 };
    44 
    45 struct razor_set {
    46 	struct array buckets;
    47 	struct array string_pool;
    48 	struct array property_pool;
    49  	struct array packages;
    50  	struct array requires;
    51  	struct array provides;
    52 	struct razor_set_header *header;
    53 };
    54 
    55 struct import_property_context {
    56 	struct array *all;
    57 	struct array package;
    58 };
    59 
    60 struct import_context {
    61 	struct razor_set *set;
    62 	struct import_property_context requires;
    63 	struct import_property_context provides;
    64 	struct razor_package *package;
    65 	unsigned long *requires_map;
    66 	unsigned long *provides_map;
    67 };
    68 
    69 void import_context_add_package(struct import_context *ctx,
    70 				const char *name, const char *version);
    71 void import_context_add_property(struct import_context *ctx,
    72 				 struct import_property_context *pctx,
    73 				 const char *name, const char *version);
    74 void import_context_finish_package(struct import_context *ctx);
    75 
    76 unsigned long razor_set_tokenize(struct razor_set *set, const char *string);
    77 void razor_prepare_import(struct import_context *ctx);
    78 struct razor_set *razor_finish_import(struct import_context *ctx);
    79 
    80 struct razor_set *razor_import_rzr_files(int count, const char **files);
    81 struct razor_set *razor_set_create_from_yum_filelist(int fd);
    82 struct razor_set *razor_set_create_from_rpmdb(void);
    83 
    84 #endif /* _RAZOR_H_ */