Imported Upstream version 0.6.15
[platform/upstream/libsolv.git] / src / repodata.h
index b0d9ea8..c18c688 100644 (file)
@@ -7,31 +7,41 @@
 
 /*
  * repodata.h
- * 
+ *
  */
 
-#ifndef SATSOLVER_REPODATA_H
-#define SATSOLVER_REPODATA_H
+#ifndef LIBSOLV_REPODATA_H
+#define LIBSOLV_REPODATA_H
 
-#include <stdio.h> 
+#include <stdio.h>
 
 #include "pooltypes.h"
 #include "pool.h"
 #include "dirpool.h"
+
+#ifdef LIBSOLV_INTERNAL
 #include "repopage.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #define SIZEOF_MD5     16
 #define SIZEOF_SHA1    20
+#define SIZEOF_SHA224  28
 #define SIZEOF_SHA256  32
+#define SIZEOF_SHA384  48
+#define SIZEOF_SHA512  64
 
 struct _Repo;
 struct _KeyValue;
 
 typedef struct _Repokey {
   Id name;
-  Id type;               /* REPOKEY_TYPE_xxx */
+  Id type;                     /* REPOKEY_TYPE_xxx */
   unsigned int size;
-  unsigned int storage; /* KEY_STORAGE_xxx */
+  unsigned int storage;                /* KEY_STORAGE_xxx */
 } Repokey;
 
 #define KEY_STORAGE_DROPPED             0
@@ -39,8 +49,12 @@ typedef struct _Repokey {
 #define KEY_STORAGE_INCORE              2
 #define KEY_STORAGE_VERTICAL_OFFSET     3
 
+#ifdef LIBSOLV_INTERNAL
+struct dircache;
+#endif
 
 typedef struct _Repodata {
+  Id repodataid;               /* our id */
   struct _Repo *repo;          /* back pointer to repo */
 
 #define REPODATA_AVAILABLE     0
@@ -56,24 +70,26 @@ typedef struct _Repodata {
   int start;                   /* start of solvables this repodata is valid for */
   int end;                     /* last solvable + 1 of this repodata */
 
-  FILE *fp;                    /* file pointer of solv file */
-  int error;                   /* corrupt solv file */
-
   Repokey *keys;               /* keys, first entry is always zero */
-  unsigned int nkeys;          /* length of keys array */
+  int nkeys;                   /* length of keys array */
   unsigned char keybits[32];   /* keyname hash */
 
   Id *schemata;                        /* schema -> offset into schemadata */
-  unsigned int nschemata;      /* number of schemata */
+  int nschemata;               /* number of schemata */
   Id *schemadata;              /* schema storage */
-  unsigned int schemadatalen;   /* schema storage size */
-  Id *schematahash;            /* unification helper */
 
   Stringpool spool;            /* local string pool */
   int localpool;               /* is local string pool used */
 
   Dirpool dirpool;             /* local dir pool */
 
+#ifdef LIBSOLV_INTERNAL
+  FILE *fp;                    /* file pointer of solv file */
+  int error;                   /* corrupt solv file */
+
+  unsigned int schemadatalen;   /* schema storage size */
+  Id *schematahash;            /* unification helper */
+
   unsigned char *incoredata;   /* in-core data */
   unsigned int incoredatalen;  /* in-core data used */
   unsigned int incoredatafree; /* free data len */
@@ -87,6 +103,7 @@ typedef struct _Repodata {
   Id lastverticaloffset;       /* end of verticals */
 
   Repopagestore store;         /* our page store */
+  Id storestate;               /* incremented every time the store might change */
 
   unsigned char *vincore;      /* internal vertical data */
   unsigned int vincorelen;     /* data size */
@@ -99,12 +116,18 @@ typedef struct _Repodata {
   unsigned int attrdatalen;    /* its len */
   Id *attriddata;              /* their id space */
   unsigned int attriddatalen;  /* its len */
+  unsigned long long *attrnum64data;   /* their 64bit num data space */
+  unsigned int attrnum64datalen;       /* its len */
 
   /* array cache to speed up repodata_add functions*/
   Id lasthandle;
   Id lastkey;
   Id lastdatalen;
 
+  /* directory cache to speed up repodata_str2dir */
+  struct dircache *dircache;
+#endif
+
 } Repodata;
 
 #define SOLVID_META            -1
@@ -118,7 +141,6 @@ typedef struct _Repodata {
 void repodata_initdata(Repodata *data, struct _Repo *repo, int localpool);
 void repodata_freedata(Repodata *data);
 
-Repodata *repodata_create(struct _Repo *repo, int localpool);
 void repodata_free(Repodata *data);
 void repodata_empty(Repodata *data, int localpool);
 
@@ -127,6 +149,7 @@ void repodata_empty(Repodata *data, int localpool);
  * key management functions
  */
 Id repodata_key2id(Repodata *data, Repokey *key, int create);
+
 static inline Repokey *
 repodata_id2key(Repodata *data, Id keyid)
 {
@@ -137,6 +160,8 @@ repodata_id2key(Repodata *data, Id keyid)
  * schema management functions
  */
 Id repodata_schema2id(Repodata *data, Id *schema, int create);
+void repodata_free_schemahash(Repodata *data);
+
 static inline Id *
 repodata_id2schema(Repodata *data, Id schemaid)
 {
@@ -173,9 +198,9 @@ repodata_has_keyname(Repodata *data, Id keyname)
  * Call <callback> for each match */
 void repodata_search(Repodata *data, Id solvid, Id keyname, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct _KeyValue *kv), void *cbdata);
 
-/* Make sure the found KeyValue has the "str" field set. Return false
- * if not possible */
-int repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags);
+/* Make sure the found KeyValue has the "str" field set. Return "str"
+ * if valid, NULL if not possible */
+const char *repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags);
 
 int repodata_filelistfilter_matches(Repodata *data, const char *str);
 
@@ -184,10 +209,11 @@ int repodata_filelistfilter_matches(Repodata *data, const char *str);
 Id repodata_lookup_type(Repodata *data, Id solvid, Id keyname);
 Id repodata_lookup_id(Repodata *data, Id solvid, Id keyname);
 const char *repodata_lookup_str(Repodata *data, Id solvid, Id keyname);
-int repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned int *value);
+int repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned long long *value);
 int repodata_lookup_void(Repodata *data, Id solvid, Id keyname);
 const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id keyname, Id *typep);
 int repodata_lookup_idarray(Repodata *data, Id solvid, Id keyname, Queue *q);
+const void *repodata_lookup_binary(Repodata *data, Id solvid, Id keyname, int *lenp);
 
 
 /*-----
@@ -212,7 +238,7 @@ Id repodata_new_handle(Repodata *data);
 
 /* basic types: void, num, string, Id */
 void repodata_set_void(Repodata *data, Id solvid, Id keyname);
-void repodata_set_num(Repodata *data, Id solvid, Id keyname, unsigned int num);
+void repodata_set_num(Repodata *data, Id solvid, Id keyname, unsigned long long num);
 void repodata_set_id(Repodata *data, Id solvid, Id keyname, Id id);
 void repodata_set_str(Repodata *data, Id solvid, Id keyname, const char *str);
 void repodata_set_binary(Repodata *data, Id solvid, Id keyname, void *buf, int len);
@@ -236,6 +262,7 @@ void repodata_set_idarray(Repodata *data, Id solvid, Id keyname, Queue *q);
 /* directory (for package file list) */
 void repodata_add_dirnumnum(Repodata *data, Id solvid, Id keyname, Id dir, Id num, Id num2);
 void repodata_add_dirstr(Repodata *data, Id solvid, Id keyname, Id dir, const char *str);
+void repodata_free_dircache(Repodata *data);
 
 
 /* Arrays */
@@ -244,18 +271,18 @@ void repodata_add_poolstr_array(Repodata *data, Id solvid, Id keyname, const cha
 void repodata_add_fixarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
 void repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
 
-void repodata_delete(Repodata *data, Id solvid, Id keyname);
-void repodata_delete_uninternalized(Repodata *data, Id solvid, Id keyname);
+void repodata_unset(Repodata *data, Id solvid, Id keyname);
+void repodata_unset_uninternalized(Repodata *data, Id solvid, Id keyname);
 
-/* 
- merge attributes from one solvable to another
+/*
+ merge/swap attributes from one solvable to another
  works only if the data is not yet internalized
 */
 void repodata_merge_attrs(Repodata *data, Id dest, Id src);
 void repodata_merge_some_attrs(Repodata *data, Id dest, Id src, Map *keyidmap, int overwrite);
+void repodata_swap_attrs(Repodata *data, Id dest, Id src);
 
-void repodata_create_stubs(Repodata *data);
-void repodata_join(Repodata *data, Id joinkey);
+Repodata *repodata_create_stubs(Repodata *data);
 
 /*
  * load all paged data, used to speed up copying in repo_rpmdb
@@ -265,9 +292,22 @@ void repodata_disable_paging(Repodata *data);
 /* helper functions */
 Id repodata_globalize_id(Repodata *data, Id id, int create);
 Id repodata_localize_id(Repodata *data, Id id, int create);
+Id repodata_translate_id(Repodata *data, Repodata *fromdata, Id id, int create);
+
 Id repodata_str2dir(Repodata *data, const char *dir, int create);
 const char *repodata_dir2str(Repodata *data, Id did, const char *suf);
 const char *repodata_chk2str(Repodata *data, Id type, const unsigned char *buf);
 void repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, const char *file);
+void repodata_set_deltalocation(Repodata *data, Id handle, int medianr, const char *dir, const char *file);
+void repodata_set_sourcepkg(Repodata *data, Id solvid, const char *sourcepkg);
+Id repodata_lookup_id_uninternalized(Repodata *data, Id solvid, Id keyname, Id voidid);
+const char *repodata_lookup_dirstrarray_uninternalized(Repodata *data, Id solvid, Id keyname, Id *didp, Id *iterp);
+
+/* stats */
+unsigned int repodata_memused(Repodata *data);
+
+#ifdef __cplusplus
+}
+#endif
 
-#endif /* SATSOLVER_REPODATA_H */
+#endif /* LIBSOLV_REPODATA_H */