- fix di->repoid to be consistent with repo->repoid
[platform/upstream/libsolv.git] / src / repodata.c
index 9bf755c..55517c5 100644 (file)
 #include "repopack.h"
 #include "repopage.h"
 
-extern unsigned int compress_buf (const unsigned char *in, unsigned int in_len,
-                                 unsigned char *out, unsigned int out_len);
-extern unsigned int unchecked_decompress_buf (const unsigned char *in,
-                                             unsigned int in_len,
-                                             unsigned char *out,
-                                             unsigned int out_len);
-
 #define REPODATA_BLOCK 255
 
+static unsigned char *data_skip_key(Repodata *data, unsigned char *dp, Repokey *key);
 
 void
 repodata_initdata(Repodata *data, Repo *repo, int localpool)
@@ -273,7 +267,7 @@ repodata_str2dir(Repodata *data, const char *dir, int create)
       if (data->localpool)
         id = stringpool_strn2id(&data->spool, dir, dire - dir, create);
       else
-       id = strn2id(data->repo->pool, dir, dire - dir, create);
+       id = pool_strn2id(data->repo->pool, dir, dire - dir, create);
       if (!id)
        return 0;
       parent = dirpool_add_dir(&data->dirpool, parent, id, create);
@@ -431,10 +425,10 @@ get_vertical_data(Repodata *data, Repokey *key, Id off, Id len)
     return 0;
   /* we now have the offset, go into vertical */
   off += data->verticaloffset[key - data->keys];
-  /* fprintf(stderr, "key %d page %d\n", key->name, off / BLOB_PAGESIZE); */
-  dp = repopagestore_load_page_range(&data->store, off / BLOB_PAGESIZE, (off + len - 1) / BLOB_PAGESIZE);
+  /* fprintf(stderr, "key %d page %d\n", key->name, off / REPOPAGE_BLOBSIZE); */
+  dp = repopagestore_load_page_range(&data->store, off / REPOPAGE_BLOBSIZE, (off + len - 1) / REPOPAGE_BLOBSIZE);
   if (dp)
-    dp += off % BLOB_PAGESIZE;
+    dp += off % REPOPAGE_BLOBSIZE;
   return dp;
 }
 
@@ -618,7 +612,7 @@ repodata_lookup_str(Repodata *data, Id solvid, Id keyname)
     return 0;
   if (data->localpool)
     return stringpool_id2str(&data->spool, id);
-  return id2str(data->repo->pool, id);
+  return pool_id2str(data->repo->pool, id);
 }
 
 int
@@ -636,6 +630,7 @@ repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned int *value)
       || key->type == REPOKEY_TYPE_U32
       || key->type == REPOKEY_TYPE_CONSTANT)
     {
+      kv.num = 0;
       dp = data_fetch(dp, &kv, key);
       *value = kv.num;
       return 1;
@@ -704,7 +699,7 @@ repodata_globalize_id(Repodata *data, Id id, int create)
 {
   if (!id || !data || !data->localpool)
     return id;
-  return str2id(data->repo->pool, stringpool_id2str(&data->spool, id), create);
+  return pool_str2id(data->repo->pool, stringpool_id2str(&data->spool, id), create);
 }
 
 Id
@@ -712,7 +707,7 @@ repodata_localize_id(Repodata *data, Id id, int create)
 {
   if (!id || !data || !data->localpool)
     return id;
-  return stringpool_str2id(&data->spool, id2str(data->repo->pool, id), create);
+  return stringpool_str2id(&data->spool, pool_id2str(data->repo->pool, id), create);
 }
 
 
@@ -732,7 +727,7 @@ repodata_stringify(Pool *pool, Repodata *data, Repokey *key, KeyValue *kv, int f
       if (data && data->localpool)
        kv->str = stringpool_id2str(&data->spool, kv->id);
       else
-       kv->str = id2str(pool, kv->id);
+       kv->str = pool_id2str(pool, kv->id);
       if ((flags & SEARCH_SKIP_KIND) != 0 && key->storage == KEY_STORAGE_SOLVABLE)
        {
          const char *s;
@@ -1181,7 +1176,7 @@ void
 dataiterator_set_search(Dataiterator *di, Repo *repo, Id p)
 {
   di->repo = repo;
-  di->repoid = -1;
+  di->repoid = 0;
   di->flags &= ~SEARCH_THISSOLVID;
   di->nparents = 0;
   di->rootlevel = 0;
@@ -1193,7 +1188,7 @@ dataiterator_set_search(Dataiterator *di, Repo *repo, Id p)
     }
   if (!repo)
     {
-      di->repoid = 0;
+      di->repoid = 1;
       di->repo = di->pool->repos[0];
     }
   di->state = di_enterrepo;
@@ -1388,13 +1383,13 @@ dataiterator_step(Dataiterator *di)
          /* FALLTHROUGH */
 
        case di_nextrepo: di_nextrepo:
-         if (di->repoid >= 0)
+         if (di->repoid > 0)
            {
              di->repoid++;
              di->repodataid = 0;
-             if (di->repoid < di->pool->nrepos)
+             if (di->repoid - 1 < di->pool->nrepos)
                {
-                 di->repo = di->pool->repos[di->repoid];
+                 di->repo = di->pool->repos[di->repoid - 1];
                  goto di_enterrepo;
                }
            }
@@ -1681,7 +1676,7 @@ dataiterator_jump_to_solvid(Dataiterator *di, Id solvid)
          di->state = di_bye;
          return;
        }
-      di->repoid = -1;
+      di->repoid = 0;
       di->data = di->repo->repodata + di->pool->pos.repodataid;
       di->repodataid = -1;
       di->solvid = solvid;
@@ -1692,17 +1687,17 @@ dataiterator_jump_to_solvid(Dataiterator *di, Id solvid)
   if (solvid > 0)
     {
       di->repo = di->pool->solvables[solvid].repo;
-      di->repoid = -1;
+      di->repoid = 0;
     }
-  else if (di->repoid >= 0)
+  else if (di->repoid > 0)
     {
       if (!di->pool->nrepos)
        {
          di->state = di_bye;
          return;
        }
+      di->repoid = 1;
       di->repo = di->pool->repos[0];
-      di->repoid = 0;
     }
   di->repodataid = 0;
   di->solvid = solvid;
@@ -1718,7 +1713,7 @@ dataiterator_jump_to_repo(Dataiterator *di, Repo *repo)
   di->kv.parent = 0;
   di->rootlevel = 0;
   di->repo = repo;
-  di->repoid = -1;
+  di->repoid = 0;      /* 0 means stay at repo */
   di->repodataid = 0;
   di->solvid = 0;
   di->flags &= ~SEARCH_THISSOLVID;
@@ -1940,7 +1935,7 @@ repodata_set_poolstr(Repodata *data, Id solvid, Id keyname, const char *str)
   if (data->localpool)
     id = stringpool_str2id(&data->spool, str, 1);
   else
-    id = str2id(data->repo->pool, str, 1);
+    id = pool_str2id(data->repo->pool, str, 1);
   key.name = keyname;
   key.type = REPOKEY_TYPE_ID;
   key.size = 0;
@@ -2139,7 +2134,7 @@ repodata_chk2str(Repodata *data, Id type, const unsigned char *buf)
 static inline const char *
 evrid2vrstr(Pool *pool, Id evrid)
 {
-  const char *p, *evr = id2str(pool, evrid);
+  const char *p, *evr = pool_id2str(pool, evrid);
   if (!evr)
     return evr;
   for (p = evr; *p >= '0' && *p <= '9'; p++)
@@ -2180,7 +2175,7 @@ repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, c
   s = pool->solvables + solvid;
   if (dir && l)
     {
-      str = id2str(pool, s->arch);
+      str = pool_id2str(pool, s->arch);
       if (!strncmp(dir, str, l) && !str[l])
        repodata_set_void(data, solvid, SOLVABLE_MEDIADIR);
       else if (!dir[l])
@@ -2194,7 +2189,7 @@ repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, c
        }
     }
   fp = file;
-  str = id2str(pool, s->name);
+  str = pool_id2str(pool, s->name);
   l = strlen(str);
   if ((!l || !strncmp(fp, str, l)) && fp[l] == '-')
     {
@@ -2204,7 +2199,7 @@ repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, c
       if ((!l || !strncmp(fp, str, l)) && fp[l] == '.')
        {
          fp += l + 1;
-         str = id2str(pool, s->arch);
+         str = pool_id2str(pool, s->arch);
          l = strlen(str);
          if ((!l || !strncmp(fp, str, l)) && !strcmp(fp + l, ".rpm"))
            {
@@ -2288,7 +2283,7 @@ repodata_add_poolstr_array(Repodata *data, Id solvid, Id keyname,
   if (data->localpool)
     id = stringpool_str2id(&data->spool, str, 1);
   else
-    id = str2id(data->repo->pool, str, 1);
+    id = pool_str2id(data->repo->pool, str, 1);
   repodata_add_idarray(data, solvid, keyname, id);
 }
 
@@ -2705,7 +2700,7 @@ fprintf(stderr, "schemadata %p\n", data->schemadata);
            }
          key = data->keys + *keyp;
 #if 0
-         fprintf(stderr, "internalize %d(%d):%s:%s\n", entry, entry + data->start, id2str(data->repo->pool, key->name), id2str(data->repo->pool, key->type));
+         fprintf(stderr, "internalize %d(%d):%s:%s\n", entry, entry + data->start, pool_id2str(data->repo->pool, key->name), pool_id2str(data->repo->pool, key->type));
 #endif
          ndp = dp;
          if (oldcount)