Preparation for structured types. The repodata_set_* functions now take
authorMichael Matz <matz@suse.de>
Mon, 14 Apr 2008 09:19:01 +0000 (09:19 +0000)
committerMichael Matz <matz@suse.de>
Mon, 14 Apr 2008 09:19:01 +0000 (09:19 +0000)
a "handle" not an entry number.  Converting from the latter to the
former is done via repodata_get_handle.  This change required adjusting
all callers and in order to not miss any I changed all arguments from
"entry" to "handle".  That's why this is a big change.  It should be a
no-op, though (I tested this patch on top of some other changes, so
let's hope that was enough).

src/repo.c
src/repo_helix.c
src/repodata.c
src/repodata.h
tools/repo_patchxml.c
tools/repo_rpmdb.c
tools/repo_rpmmd.c
tools/repo_susetags.c
tools/repo_updateinfoxml.c
tools/tools_util.h

index deeabef..913f8ce 100644 (file)
@@ -913,7 +913,7 @@ repo_set_id(Repo *repo, Id p, Id keyname, Id id)
     p = p + data->extrastart;
   else
     p = p - data->start;
-  repodata_set_id(data, p, keyname, id);
+  repodata_set_id(data, repodata_get_handle(data, p), keyname, id);
 }
 
 void
@@ -924,7 +924,7 @@ repo_set_num(Repo *repo, Id p, Id keyname, Id num)
     p = p + data->extrastart;
   else
     p = p - data->start;
-  repodata_set_num(data, p, keyname, num);
+  repodata_set_num(data, repodata_get_handle(data, p), keyname, num);
 }
 
 void
@@ -935,7 +935,7 @@ repo_set_str(Repo *repo, Id p, Id keyname, const char *str)
     p = p + data->extrastart;
   else
     p = p - data->start;
-  repodata_set_str(data, p, keyname, str);
+  repodata_set_str(data, repodata_get_handle(data, p), keyname, str);
 }
 
 void
@@ -946,7 +946,7 @@ repo_set_poolstr(Repo *repo, Id p, Id keyname, const char *str)
     p = p + data->extrastart;
   else
     p = p - data->start;
-  repodata_set_poolstr(data, p, keyname, str);
+  repodata_set_poolstr(data, repodata_get_handle(data, p), keyname, str);
 }
 
 void
index 815a052..820bbec 100644 (file)
@@ -34,7 +34,7 @@ enum state {
   STATE_PACKAGE,
   STATE_NAME,
   STATE_VENDOR,
-  STATE_BUILDTIME,  
+  STATE_BUILDTIME,
   STATE_HISTORY,
   STATE_UPDATE,
   STATE_EPOCH,
@@ -714,9 +714,9 @@ endElement(void *userData, const char *name)
       s->vendor = str2id(pool, pd->content, 1);
       break;
     case STATE_BUILDTIME:
-       t = atoi (pd->content);
-       if (t)
-         repodata_set_num(pd->data, (s - pool->solvables) - pd->repo->start, SOLVABLE_BUILDTIME, t);
+      t = atoi (pd->content);
+      if (t)
+       repodata_set_num(pd->data, repodata_get_handle(pd->data, (s - pool->solvables) - pd->repo->start), SOLVABLE_BUILDTIME, t);
       break;   
     case STATE_UPDATE:                /* new version, keeping all other metadata */
       evr = evr2id(pool, pd,
@@ -866,7 +866,7 @@ repo_add_helix(Repo *repo, FILE *fp)
   XML_ParserFree(parser);
 
   if (pd.data)
-    repodata_internalize(pd.data);  
+    repodata_internalize(pd.data);
 
   free(pd.content);
   free(pd.evrspace);
index 1c2161c..947ec4b 100644 (file)
@@ -1057,8 +1057,8 @@ repodata_extend(Repodata *data, Id p)
       int new = p - data->end + 1;
       if (data->attrs)
        {
-         data->attrs = sat_extend(data->attrs, old, new, sizeof(Id *), REPODATA_BLOCK);
-         memset(data->attrs + old, 0, new * sizeof(Id *));
+         data->attrs = sat_extend(data->attrs, old, new, sizeof(Id), REPODATA_BLOCK);
+         memset(data->attrs + old, 0, new * sizeof(Id));
        }
       data->incoreoffset = sat_extend(data->incoreoffset, old, new, sizeof(Id), REPODATA_BLOCK);
       memset(data->incoreoffset + old, 0, new * sizeof(Id));
@@ -1070,9 +1070,9 @@ repodata_extend(Repodata *data, Id p)
       int new = data->start - p;
       if (data->attrs)
        {
-         data->attrs = sat_extend_resize(data->attrs, old + new, sizeof(Id *), REPODATA_BLOCK);
-         memmove(data->attrs + new, data->attrs, old * sizeof(Id *));
-         memset(data->attrs, 0, new * sizeof(Id *));
+         data->attrs = sat_extend_resize(data->attrs, old + new, sizeof(Id), REPODATA_BLOCK);
+         memmove(data->attrs + new, data->attrs, old * sizeof(Id));
+         memset(data->attrs, 0, new * sizeof(Id));
        }
       data->incoreoffset = sat_extend_resize(data->incoreoffset, old + new, sizeof(Id), REPODATA_BLOCK);
       memmove(data->incoreoffset + new, data->incoreoffset, old * sizeof(Id));
@@ -1088,8 +1088,8 @@ repodata_extend_extra(Repodata *data, int nextra)
     return;
   if (data->extraattrs)
     {
-      data->extraattrs = sat_extend(data->extraattrs, data->nextra, nextra - data->nextra, sizeof(Id *), REPODATA_BLOCK);
-      memset(data->extraattrs + data->nextra, 0, (nextra - data->nextra) * sizeof (Id *));
+      data->extraattrs = sat_extend(data->extraattrs, data->nextra, nextra - data->nextra, sizeof(Id), REPODATA_BLOCK);
+      memset(data->extraattrs + data->nextra, 0, (nextra - data->nextra) * sizeof (Id));
     }
   data->extraoffset = sat_extend(data->extraoffset, data->nextra, nextra - data->nextra, sizeof(Id), REPODATA_BLOCK);
   memset(data->extraoffset + data->nextra, 0, (nextra - data->nextra) * sizeof(Id));
@@ -1119,23 +1119,59 @@ repodata_extend_block(Repodata *data, Id start, Id num)
 #define REPODATA_ATTRDATA_BLOCK 1023
 #define REPODATA_ATTRIDDATA_BLOCK 63
 
-static void
-repodata_insert_keyid(Repodata *data, Id entry, Id keyid, Id val, int overwrite)
+static inline Id
+get_new_struct(Repodata *data)
+{
+  /* Make sure to never give out struct id 0. */
+  if (!data->structs)
+    {
+      data->structs = sat_extend(0, 0, 2, sizeof(Id *), REPODATA_BLOCK);
+      data->structs[0] = 0;
+      data->structs[1] = 0;
+      data->nstructs = 2;
+      return 1;
+    }
+  data->structs = sat_extend(data->structs, data->nstructs, 1, sizeof(Id *), REPODATA_BLOCK);
+  data->structs[data->nstructs] = 0;
+  return data->nstructs++;
+}
+
+static Id
+repodata_get_handle_int(Repodata *data, Id entry)
 {
-  Id *pp;
   Id *ap;
-  int i;
   if (!data->attrs && entry >= 0)
     {
-      data->attrs = sat_calloc_block(data->end - data->start, sizeof(Id *),
+      data->attrs = sat_calloc_block(data->end - data->start, sizeof(Id),
                                     REPODATA_BLOCK);
     }
   else if (!data->extraattrs && entry < 0)
-    data->extraattrs = sat_calloc_block(data->nextra, sizeof(Id *), REPODATA_BLOCK);
+    data->extraattrs = sat_calloc_block(data->nextra, sizeof(Id), REPODATA_BLOCK);
   if (entry < 0)
-    ap = data->extraattrs[-1 - entry];
+    ap = &data->extraattrs[-1 - entry];
   else
-    ap = data->attrs[entry];
+    ap = &data->attrs[entry];
+  if (!*ap)
+    *ap = get_new_struct(data);
+  return *ap;
+}
+
+Id
+repodata_get_handle(Repodata *data, Id entry)
+{
+  return repodata_get_handle_int(data, entry);
+}
+
+static void
+repodata_insert_keyid(Repodata *data, Id handle, Id keyid, Id val, int overwrite)
+{
+  Id *pp;
+  Id *ap;
+  Id sid;
+  int i;
+  //sid = repodata_get_handle(data, handle);
+  sid = handle;
+  ap = data->structs[sid];
   i = 0;
   if (ap)
     {
@@ -1156,10 +1192,7 @@ repodata_insert_keyid(Repodata *data, Id entry, Id keyid, Id val, int overwrite)
       i = pp - ap;
     }
   ap = sat_extend(ap, i, 3, sizeof(Id), REPODATA_ATTRS_BLOCK);
-  if (entry < 0)
-    data->extraattrs[-1 - entry] = ap;
-  else
-    data->attrs[entry] = ap;
+  data->structs[sid] = ap;
   pp = ap + i;
   *pp++ = keyid;
   *pp++ = val;
@@ -1167,7 +1200,7 @@ repodata_insert_keyid(Repodata *data, Id entry, Id keyid, Id val, int overwrite)
 }
 
 void
-repodata_set(Repodata *data, Id entry, Repokey *key, Id val)
+repodata_set(Repodata *data, Id handle, Repokey *key, Id val)
 {
   Id keyid;
 
@@ -1190,33 +1223,33 @@ repodata_set(Repodata *data, Id entry, Repokey *key, Id val)
          data->verticaloffset[data->nkeys - 1] = 0;
        }
     }
-  repodata_insert_keyid(data, entry, keyid, val, 1);
+  repodata_insert_keyid(data, handle, keyid, val, 1);
 }
 
 void
-repodata_set_id(Repodata *data, Id entry, Id keyname, Id id)
+repodata_set_id(Repodata *data, Id handle, Id keyname, Id id)
 {
   Repokey key;
   key.name = keyname;
   key.type = REPOKEY_TYPE_ID;
   key.size = 0;
   key.storage = KEY_STORAGE_INCORE;
-  repodata_set(data, entry, &key, id);
+  repodata_set(data, handle, &key, id);
 }
 
 void
-repodata_set_num(Repodata *data, Id entry, Id keyname, unsigned int num)
+repodata_set_num(Repodata *data, Id handle, Id keyname, unsigned int num)
 {
   Repokey key;
   key.name = keyname;
   key.type = REPOKEY_TYPE_NUM;
   key.size = 0;
   key.storage = KEY_STORAGE_INCORE;
-  repodata_set(data, entry, &key, (Id)num);
+  repodata_set(data, handle, &key, (Id)num);
 }
 
 void
-repodata_set_poolstr(Repodata *data, Id entry, Id keyname, const char *str)
+repodata_set_poolstr(Repodata *data, Id handle, Id keyname, const char *str)
 {
   Repokey key;
   Id id;
@@ -1228,44 +1261,44 @@ repodata_set_poolstr(Repodata *data, Id entry, Id keyname, const char *str)
   key.type = REPOKEY_TYPE_ID;
   key.size = 0;
   key.storage = KEY_STORAGE_INCORE;
-  repodata_set(data, entry, &key, id);
+  repodata_set(data, handle, &key, id);
 }
 
 void
-repodata_set_constant(Repodata *data, Id entry, Id keyname, unsigned int constant)
+repodata_set_constant(Repodata *data, Id handle, Id keyname, unsigned int constant)
 {
   Repokey key;
   key.name = keyname;
   key.type = REPOKEY_TYPE_CONSTANT;
   key.size = constant;
   key.storage = KEY_STORAGE_INCORE;
-  repodata_set(data, entry, &key, 0);
+  repodata_set(data, handle, &key, 0);
 }
 
 void
-repodata_set_constantid(Repodata *data, Id entry, Id keyname, Id id)
+repodata_set_constantid(Repodata *data, Id handle, Id keyname, Id id)
 {
   Repokey key;
   key.name = keyname;
   key.type = REPOKEY_TYPE_CONSTANTID;
   key.size = id;
   key.storage = KEY_STORAGE_INCORE;
-  repodata_set(data, entry, &key, 0);
+  repodata_set(data, handle, &key, 0);
 }
 
 void
-repodata_set_void(Repodata *data, Id entry, Id keyname)
+repodata_set_void(Repodata *data, Id handle, Id keyname)
 {
   Repokey key;
   key.name = keyname;
   key.type = REPOKEY_TYPE_VOID;
   key.size = 0;
   key.storage = KEY_STORAGE_INCORE;
-  repodata_set(data, entry, &key, 0);
+  repodata_set(data, handle, &key, 0);
 }
 
 void
-repodata_set_str(Repodata *data, Id entry, Id keyname, const char *str)
+repodata_set_str(Repodata *data, Id handle, Id keyname, const char *str)
 {
   Repokey key;
   int l;
@@ -1277,20 +1310,17 @@ repodata_set_str(Repodata *data, Id entry, Id keyname, const char *str)
   key.storage = KEY_STORAGE_INCORE;
   data->attrdata = sat_extend(data->attrdata, data->attrdatalen, l, 1, REPODATA_ATTRDATA_BLOCK);
   memcpy(data->attrdata + data->attrdatalen, str, l);
-  repodata_set(data, entry, &key, data->attrdatalen);
+  repodata_set(data, handle, &key, data->attrdatalen);
   data->attrdatalen += l;
 }
 
 static void
-repoadata_add_array(Repodata *data, Id entry, Id keyname, Id keytype, int entrysize)
+repoadata_add_array(Repodata *data, Id handle, Id keyname, Id keytype, int entrysize)
 {
   int oldsize;
   Id *ida, *pp;
 
-  if (entry < 0)
-    pp = data->extraattrs ? data->extraattrs[-1 - entry] : 0;
-  else
-    pp = data->attrs ? data->attrs[entry] : 0;
+  pp = data->structs[handle];
   if (pp)
     for (; *pp; pp += 2)
       if (data->keys[*pp].name == keyname && data->keys[*pp].type == keytype)
@@ -1304,7 +1334,7 @@ repoadata_add_array(Repodata *data, Id entry, Id keyname, Id keytype, int entrys
       key.size = 0;
       key.storage = KEY_STORAGE_INCORE;
       data->attriddata = sat_extend(data->attriddata, data->attriddatalen, entrysize + 1, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
-      repodata_set(data, entry, &key, data->attriddatalen);
+      repodata_set(data, handle, &key, data->attriddatalen);
       return;
     }
   oldsize = 0;
@@ -1343,7 +1373,7 @@ checksumtype2len(Id type)
 }
 
 void
-repodata_set_bin_checksum(Repodata *data, Id entry, Id keyname, Id type,
+repodata_set_bin_checksum(Repodata *data, Id handle, Id keyname, Id type,
                      const unsigned char *str)
 {
   Repokey key;
@@ -1357,7 +1387,7 @@ repodata_set_bin_checksum(Repodata *data, Id entry, Id keyname, Id type,
   key.storage = KEY_STORAGE_INCORE;
   data->attrdata = sat_extend(data->attrdata, data->attrdatalen, l, 1, REPODATA_ATTRDATA_BLOCK);
   memcpy(data->attrdata + data->attrdatalen, str, l);
-  repodata_set(data, entry, &key, data->attrdatalen);
+  repodata_set(data, handle, &key, data->attrdatalen);
   data->attrdatalen += l;
 }
 
@@ -1387,7 +1417,7 @@ hexstr2bytes(unsigned char *buf, const char *str, int buflen)
 }
 
 void
-repodata_set_checksum(Repodata *data, Id entry, Id keyname, Id type,
+repodata_set_checksum(Repodata *data, Id handle, Id keyname, Id type,
                      const char *str)
 {
   unsigned char buf[64];
@@ -1400,7 +1430,7 @@ repodata_set_checksum(Repodata *data, Id entry, Id keyname, Id type,
       fprintf(stderr, "Invalid hex character in '%s'\n", str);
       return;
     }
-  repodata_set_bin_checksum(data, entry, keyname, type, buf);
+  repodata_set_bin_checksum(data, handle, keyname, type, buf);
 }
 
 const char *
@@ -1434,13 +1464,13 @@ repodata_globalize_id(Repodata *data, Id id)
 }
 
 void
-repodata_add_dirnumnum(Repodata *data, Id entry, Id keyname, Id dir, Id num, Id num2)
+repodata_add_dirnumnum(Repodata *data, Id handle, Id keyname, Id dir, Id num, Id num2)
 {
 
 #if 0
-fprintf(stderr, "repodata_add_dirnumnum %d %d %d %d (%d)\n", entry, dir, num, num2, data->attriddatalen);
+fprintf(stderr, "repodata_add_dirnumnum %d %d %d %d (%d)\n", handle, dir, num, num2, data->attriddatalen);
 #endif
-  repoadata_add_array(data, entry, keyname, REPOKEY_TYPE_DIRNUMNUMARRAY, 3);
+  repoadata_add_array(data, handle, keyname, REPOKEY_TYPE_DIRNUMNUMARRAY, 3);
   data->attriddata[data->attriddatalen++] = dir;
   data->attriddata[data->attriddatalen++] = num;
   data->attriddata[data->attriddatalen++] = num2;
@@ -1448,7 +1478,7 @@ fprintf(stderr, "repodata_add_dirnumnum %d %d %d %d (%d)\n", entry, dir, num, nu
 }
 
 void
-repodata_add_dirstr(Repodata *data, Id entry, Id keyname, Id dir, const char *str)
+repodata_add_dirstr(Repodata *data, Id handle, Id keyname, Id dir, const char *str)
 {
   Id stroff;
   int l;
@@ -1460,27 +1490,27 @@ repodata_add_dirstr(Repodata *data, Id entry, Id keyname, Id dir, const char *st
   data->attrdatalen += l;
 
 #if 0
-fprintf(stderr, "repodata_add_dirstr %d %d %s (%d)\n", entry, dir, str,  data->attriddatalen);
+fprintf(stderr, "repodata_add_dirstr %d %d %s (%d)\n", handle, dir, str,  data->attriddatalen);
 #endif
-  repoadata_add_array(data, entry, keyname, REPOKEY_TYPE_DIRSTRARRAY, 2);
+  repoadata_add_array(data, handle, keyname, REPOKEY_TYPE_DIRSTRARRAY, 2);
   data->attriddata[data->attriddatalen++] = dir;
   data->attriddata[data->attriddatalen++] = stroff;
   data->attriddata[data->attriddatalen++] = 0;
 }
 
 void
-repodata_add_idarray(Repodata *data, Id entry, Id keyname, Id id)
+repodata_add_idarray(Repodata *data, Id handle, Id keyname, Id id)
 {
 #if 0
-fprintf(stderr, "repodata_add_idarray %d %d (%d)\n", entry, id, data->attriddatalen);
+fprintf(stderr, "repodata_add_idarray %d %d (%d)\n", handle, id, data->attriddatalen);
 #endif
-  repoadata_add_array(data, entry, keyname, REPOKEY_TYPE_IDARRAY, 1);
+  repoadata_add_array(data, handle, keyname, REPOKEY_TYPE_IDARRAY, 1);
   data->attriddata[data->attriddatalen++] = id;
   data->attriddata[data->attriddatalen++] = 0;
 }
 
 void
-repodata_add_poolstr_array(Repodata *data, Id entry, Id keyname,
+repodata_add_poolstr_array(Repodata *data, Id handle, Id keyname,
                           const char *str)
 {
   Id id;
@@ -1488,16 +1518,31 @@ repodata_add_poolstr_array(Repodata *data, Id entry, Id keyname,
     id = stringpool_str2id(&data->spool, str, 1);
   else
     id = str2id(data->repo->pool, str, 1);
-  repodata_add_idarray(data, entry, keyname, id);
+  repodata_add_idarray(data, handle, keyname, id);
 }
 
+#if 0
+void
+repodata_open_struct(Repodata *data, Id handle, Id keyname)
+{
+}
+
+void
+repodata_close_struct(Repodata *data, Id entry, Id keyname)
+{
+}
+#endif
+
 void
 repodata_merge_attrs(Repodata *data, Id dest, Id src)
 {
   Id *keyp;
   if (dest == src
-      || !(keyp = src < 0 ? data->extraattrs[-1 - src] : data->attrs[src]))
+      || !(keyp = data->structs[src < 0
+                               ? data->extraattrs[-1 - src]
+                               : data->attrs[src]]))
     return;
+  dest = repodata_get_handle_int(data, dest);
   for (; *keyp; keyp += 2)
     repodata_insert_keyid(data, dest, keyp[0], keyp[1], 0);
 }
@@ -1640,6 +1685,7 @@ repodata_internalize(Repodata *data)
     nentry = 0;
   for (entry = data->extraattrs ? -data->nextra : 0; entry < nentry; entry++)
     {
+      Id sid;
       memset(seen, 0, data->nkeys * sizeof(Id));
       sp = schema;
       dp = entry2data(data, entry);
@@ -1666,7 +1712,8 @@ fprintf(stderr, "schemadata %p\n", data->schemadata);
          *sp++ = *keyp;
          oldcount++;
        }
-      keyp = entry < 0 ? data->extraattrs[-1 - entry] : data->attrs[entry];
+      sid = entry < 0 ? data->extraattrs[-1 - entry] : data->attrs[entry];
+      keyp = data->structs[sid];
       if (keyp)
         for (; *keyp; keyp += 2)
          {
@@ -1793,11 +1840,13 @@ fprintf(stderr, "schemadata %p\n", data->schemadata);
            }
          dp = ndp;
        }
-      if (entry < 0 && data->extraattrs[-1 - entry])
-       sat_free(data->extraattrs[-1 - entry]);
-      else if (entry >= 0 && data->attrs[entry])
-        sat_free(data->attrs[entry]);
+      if (data->structs[sid])
+       data->structs[sid] = sat_free(data->structs[sid]);
     }
+  for (entry = 0; entry < data->nstructs; entry++)
+    if (data->structs[entry])
+      sat_free(data->structs[entry]);
+  data->structs = sat_free(data->structs);
   sat_free(schema);
   sat_free(seen);
 
index d13dd87..8d94930 100644 (file)
@@ -102,12 +102,14 @@ typedef struct _Repodata {
   unsigned char *vincore;      
   unsigned int vincorelen;
 
-  Id **attrs;                  /* un-internalized attributes */
-  Id **extraattrs;             /* Same, but for extra objects.  */
+  Id *attrs;                   /* un-internalized attributes */
+  Id *extraattrs;              /* Same, but for extra objects.  */
   unsigned char *attrdata;     /* their string data space */
   unsigned int attrdatalen;
   Id *attriddata;              /* their id space */
   unsigned int attriddatalen;
+  Id **structs;                        /* key-value lists */
+  unsigned int nstructs;
 
   Id *addedfileprovides;
 } Repodata;
@@ -148,37 +150,43 @@ const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id entry, Id k
  * data assignment functions
  */
 
+/* Returns a handle for the attributes of ENTRY.  ENTRY >= 0
+   corresponds to data associated with a solvable, ENTRY < 0 is
+   extra data.  The returned handle is used in the various repodata_set_*
+   functions to add attributes to it.  */
+Id repodata_get_handle(Repodata *data, Id entry);
+
 /* basic types: void, num, string, Id */
 
-void repodata_set_void(Repodata *data, Id entry, Id keyname);
-void repodata_set_num(Repodata *data, Id entry, Id keyname, unsigned int num);
-void repodata_set_str(Repodata *data, Id entry, Id keyname, const char *str);
-void repodata_set_id(Repodata *data, Id entry, Id keyname, Id id);
+void repodata_set_void(Repodata *data, Id handle, Id keyname);
+void repodata_set_num(Repodata *data, Id handle, Id keyname, unsigned int num);
+void repodata_set_str(Repodata *data, Id handle, Id keyname, const char *str);
+void repodata_set_id(Repodata *data, Id handle, Id keyname, Id id);
 
 /*  */
 
-void repodata_set_poolstr(Repodata *data, Id entry, Id keyname, const char *str);
+void repodata_set_poolstr(Repodata *data, Id handle, Id keyname, const char *str);
 
 /* set numeric constant */
-void repodata_set_constant(Repodata *data, Id entry, Id keyname, unsigned int constant);
+void repodata_set_constant(Repodata *data, Id handle, Id keyname, unsigned int constant);
 
 /* set Id constant */
-void repodata_set_constantid(Repodata *data, Id entry, Id keyname, Id id);
+void repodata_set_constantid(Repodata *data, Id handle, Id keyname, Id id);
 
 /* checksum */
-void repodata_set_bin_checksum(Repodata *data, Id entry, Id keyname, Id type,
+void repodata_set_bin_checksum(Repodata *data, Id handle, Id keyname, Id type,
                               const unsigned char *buf);
-void repodata_set_checksum(Repodata *data, Id entry, Id keyname, Id type,
+void repodata_set_checksum(Repodata *data, Id handle, Id keyname, Id type,
                           const char *str);
 
 /* directory (for package file list) */
-void repodata_add_dirnumnum(Repodata *data, Id entry, Id keyname, Id dir, Id num, Id num2);
-void repodata_add_dirstr(Repodata *data, Id entry, Id keyname, Id dir, const char *str);
+void repodata_add_dirnumnum(Repodata *data, Id handle, Id keyname, Id dir, Id num, Id num2);
+void repodata_add_dirstr(Repodata *data, Id handle, Id keyname, Id dir, const char *str);
 
 
 /* Arrays */
-void repodata_add_idarray(Repodata *data, Id entry, Id keyname, Id id);
-void repodata_add_poolstr_array(Repodata *data, Id entry, Id keyname,
+void repodata_add_idarray(Repodata *data, Id handle, Id keyname, Id id);
+void repodata_add_poolstr_array(Repodata *data, Id handle, Id keyname,
                                const char *str);
 
 /*-----
index 39b35c5..aed69ed 100644 (file)
@@ -412,6 +412,7 @@ startElement(void *userData, const char *name, const char **atts)
         {
           pd->datanum = (pd->solvable - pool->solvables) - pd->repo->start;
          repodata_extend(pd->data, pd->solvable - pool->solvables);
+         pd->datanum = repodata_get_handle(pd->data, pd->datanum);
           repodata_set_num(pd->data, pd->datanum, SOLVABLE_BUILDTIME, pd->timestamp);
        }
 #if 0
index 58b82fa..e65ba6e 100644 (file)
@@ -427,7 +427,7 @@ static struct filefilter filefilters[] = {
 static void
 adddudata(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead *rpmhead, char **dn, unsigned int *di, int fc, int dic)
 {
-  Id entry, did;
+  Id handle, did;
   int i, fszc;
   unsigned int *fkb, *fn, *fsz, *fm, *fino;
   unsigned int inotest[256], inotestok;
@@ -537,7 +537,8 @@ adddudata(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead *rpmh
   sat_free(fm);
   /* commit */
   repodata_extend(repodata, s - pool->solvables);
-  entry = (s - pool->solvables) - repodata->start;
+  handle = (s - pool->solvables) - repodata->start;
+  handle = repodata_get_handle(repodata, handle);
   for (i = 0; i < fc; i++)
     {
       if (!fn[i])
@@ -546,7 +547,7 @@ adddudata(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead *rpmh
         did = repodata_str2dir(repodata, "/usr/src", 1);
       else
         did = repodata_str2dir(repodata, dn[i], 1);
-      repodata_add_dirnumnum(repodata, entry, SOLVABLE_DISKUSAGE, did, fkb[i], fn[i]);
+      repodata_add_dirnumnum(repodata, handle, SOLVABLE_DISKUSAGE, did, fkb[i], fn[i]);
     }
   sat_free(fn);
   sat_free(fkb);
@@ -640,11 +641,12 @@ addfileprovides(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead
 #endif
       if (repodata)
        {
-         Id entry, did;
+         Id handle, did;
          repodata_extend(repodata, s - pool->solvables);
-         entry = (s - pool->solvables) - repodata->start;
+         handle = (s - pool->solvables) - repodata->start;
+         handle = repodata_get_handle(repodata, handle);
          did = repodata_str2dir(repodata, dn[di[i]], 1);
-         repodata_add_dirstr(repodata, entry, SOLVABLE_FILELIST, did, bn[i]);
+         repodata_add_dirstr(repodata, handle, SOLVABLE_FILELIST, did, bn[i]);
        }
     }
 #if 0
@@ -658,9 +660,8 @@ addfileprovides(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead
 }
 
 static void
-addsourcerpm(Pool *pool, Repodata *repodata, Solvable *s, char *sourcerpm, char *name, char *evr)
+addsourcerpm(Pool *pool, Repodata *repodata, Id handle, char *sourcerpm, char *name, char *evr)
 {
-  Id entry;
   const char *p, *sevr, *sarch;
 
   p = strrchr(sourcerpm, '.');
@@ -682,21 +683,20 @@ addsourcerpm(Pool *pool, Repodata *repodata, Solvable *s, char *sourcerpm, char
   if (*p != '-' || p == sourcerpm)
     return;
   sevr = p + 1;
-  entry = (s - pool->solvables) - repodata->start;
   if (!strcmp(sarch, "src.rpm"))
-    repodata_set_constantid(repodata, entry, SOLVABLE_SOURCEARCH, ARCH_SRC);
+    repodata_set_constantid(repodata, handle, SOLVABLE_SOURCEARCH, ARCH_SRC);
   else if (!strcmp(sarch, "nosrc.rpm"))
-    repodata_set_constantid(repodata, entry, SOLVABLE_SOURCEARCH, ARCH_NOSRC);
+    repodata_set_constantid(repodata, handle, SOLVABLE_SOURCEARCH, ARCH_NOSRC);
   else
-    repodata_set_constantid(repodata, entry, SOLVABLE_SOURCEARCH, strn2id(pool, sarch, strlen(sarch) - 4, 1));
+    repodata_set_constantid(repodata, handle, SOLVABLE_SOURCEARCH, strn2id(pool, sarch, strlen(sarch) - 4, 1));
   if (!strncmp(sevr, evr, sarch - sevr - 1) && evr[sarch - sevr - 1] == 0)
-    repodata_set_void(repodata, entry, SOLVABLE_SOURCEEVR);
+    repodata_set_void(repodata, handle, SOLVABLE_SOURCEEVR);
   else
-    repodata_set_id(repodata, entry, SOLVABLE_SOURCEEVR, strn2id(pool, sevr, sarch - sevr - 1, 1));
+    repodata_set_id(repodata, handle, SOLVABLE_SOURCEEVR, strn2id(pool, sevr, sarch - sevr - 1, 1));
   if (!strncmp(sourcerpm, name, sevr - sourcerpm - 1) && name[sevr - sourcerpm - 1] == 0)
-    repodata_set_void(repodata, entry, SOLVABLE_SOURCENAME);
+    repodata_set_void(repodata, handle, SOLVABLE_SOURCENAME);
   else
-    repodata_set_id(repodata, entry, SOLVABLE_SOURCENAME, strn2id(pool, sourcerpm, sevr - sourcerpm - 1, 1));
+    repodata_set_id(repodata, handle, SOLVABLE_SOURCENAME, strn2id(pool, sourcerpm, sevr - sourcerpm - 1, 1));
 }
 
 static int
@@ -747,15 +747,15 @@ rpm2solv(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead *rpmhe
 
   if (repodata)
     {
-      Id entry;
+      Id handle;
       char *str;
       unsigned int u32;
 
       repodata_extend(repodata, s - pool->solvables);
-      entry = (s - pool->solvables) - repodata->start;
+      handle = repodata_get_handle(repodata, (s - pool->solvables) - repodata->start);
       str = headstring(rpmhead, TAG_SUMMARY);
       if (str)
-        repodata_set_str(repodata, entry, SOLVABLE_SUMMARY, str);
+        repodata_set_str(repodata, handle, SOLVABLE_SUMMARY, str);
       str = headstring(rpmhead, TAG_DESCRIPTION);
       if (str)
        {
@@ -773,7 +773,7 @@ rpm2solv(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead *rpmhe
              while (l > 0 && str[l - 1] == '\n')
                str[--l] = 0;
              if (l)
-                repodata_set_str(repodata, entry, SOLVABLE_DESCRIPTION, str);
+                repodata_set_str(repodata, handle, SOLVABLE_DESCRIPTION, str);
              p = aut + 19;
              aut = str;        /* copy over */
              while (*p == ' ' || *p == '\n')
@@ -793,29 +793,29 @@ rpm2solv(Pool *pool, Repo *repo, Repodata *repodata, Solvable *s, RpmHead *rpmhe
                aut--;
              *aut = 0;
              if (*str)
-               repodata_set_str(repodata, entry, SOLVABLE_AUTHORS, str);
+               repodata_set_str(repodata, handle, SOLVABLE_AUTHORS, str);
              free(str);
            }
          else if (*str)
-           repodata_set_str(repodata, entry, SOLVABLE_DESCRIPTION, str);
+           repodata_set_str(repodata, handle, SOLVABLE_DESCRIPTION, str);
        }
       str = headstring(rpmhead, TAG_GROUP);
       if (str)
-        repodata_set_poolstr(repodata, entry, SOLVABLE_GROUP, str);
+        repodata_set_poolstr(repodata, handle, SOLVABLE_GROUP, str);
       str = headstring(rpmhead, TAG_LICENSE);
       if (str)
-        repodata_set_poolstr(repodata, entry, SOLVABLE_LICENSE, str);
+        repodata_set_poolstr(repodata, handle, SOLVABLE_LICENSE, str);
       u32 = headint32(rpmhead, TAG_BUILDTIME);
       if (u32)
-        repodata_set_num(repodata, entry, SOLVABLE_BUILDTIME, u32);
+        repodata_set_num(repodata, handle, SOLVABLE_BUILDTIME, u32);
       u32 = headint32(rpmhead, TAG_INSTALLTIME);
       if (u32)
-        repodata_set_num(repodata, entry, SOLVABLE_INSTALLTIME, u32);
+        repodata_set_num(repodata, handle, SOLVABLE_INSTALLTIME, u32);
       u32 = headint32(rpmhead, TAG_SIZE);
       if (u32)
-        repodata_set_num(repodata, entry, SOLVABLE_INSTALLSIZE, (u32 + 1023) / 1024);
+        repodata_set_num(repodata, handle, SOLVABLE_INSTALLSIZE, (u32 + 1023) / 1024);
       if (sourcerpm)
-       addsourcerpm(pool, repodata, s, sourcerpm, name, evr);
+       addsourcerpm(pool, repodata, handle, sourcerpm, name, evr);
     }
   sat_free(evr);
   return 1;
@@ -887,7 +887,7 @@ copydir(Pool *pool, Repodata *data, Stringpool *fromspool, Repodata *fromdata, I
 
 struct solvable_copy_cbdata {
   Repodata *data;
-  Id entry;
+  Id handle;
 };
 
 static int
@@ -895,7 +895,7 @@ solvable_copy_cb(void *cbdata, Solvable *r, Repodata *fromdata, Repokey *key, Ke
 {
   Id id, keyname;
   Repodata *data = ((struct solvable_copy_cbdata *)cbdata)->data;
-  Id entry = ((struct solvable_copy_cbdata *)cbdata)->entry;
+  Id handle = ((struct solvable_copy_cbdata *)cbdata)->handle;
   Pool *pool = data->repo->pool, *frompool = fromdata->repo->pool;
   Stringpool *fromspool = fromdata->localpool ? &fromdata->spool : &frompool->ss;
 
@@ -916,33 +916,33 @@ solvable_copy_cb(void *cbdata, Solvable *r, Repodata *fromdata, Repokey *key, Ke
            id = str2id(pool, stringpool_id2str(fromspool, id), 1);
        }
       if (key->type == REPOKEY_TYPE_ID)
-        repodata_set_id(data, entry, keyname, id);
+        repodata_set_id(data, handle, keyname, id);
       else
-        repodata_set_constantid(data, entry, keyname, id);
+        repodata_set_constantid(data, handle, keyname, id);
       break;
     case REPOKEY_TYPE_STR:
-      repodata_set_str(data, entry, keyname, kv->str);
+      repodata_set_str(data, handle, keyname, kv->str);
       break;
     case REPOKEY_TYPE_VOID:
-      repodata_set_void(data, entry, keyname);
+      repodata_set_void(data, handle, keyname);
       break;
     case REPOKEY_TYPE_NUM:
-      repodata_set_num(data, entry, keyname, kv->num);
+      repodata_set_num(data, handle, keyname, kv->num);
       break;
     case REPOKEY_TYPE_CONSTANT:
-      repodata_set_constant(data, entry, keyname, kv->num);
+      repodata_set_constant(data, handle, keyname, kv->num);
       break;
     case REPOKEY_TYPE_DIRNUMNUMARRAY:
       id = kv->id;
       assert(!data->localpool);        /* implement me! */
       id = copydir(pool, data, fromspool, fromdata, id);
-      repodata_add_dirnumnum(data, entry, keyname, id, kv->num, kv->num2);
+      repodata_add_dirnumnum(data, handle, keyname, id, kv->num, kv->num2);
       break;
     case REPOKEY_TYPE_DIRSTRARRAY:
       id = kv->id;
       assert(!data->localpool);        /* implement me! */
       id = copydir(pool, data, fromspool, fromdata, id);
-      repodata_add_dirstr(data, entry, keyname, id, kv->str);
+      repodata_add_dirstr(data, handle, keyname, id, kv->str);
       break;
     default:
       break;
@@ -992,7 +992,7 @@ solvable_copy(Solvable *s, Solvable *r, Repodata *data)
     return;
   repodata_extend(data, s - pool->solvables);
   cbdata.data = data;
-  cbdata.entry = (s - pool->solvables) - data->start;
+  cbdata.handle = repodata_get_handle(data, (s - pool->solvables) - data->start);
   repo_search(fromrepo, (r - fromrepo->pool->solvables), 0, 0, SEARCH_NO_STORAGE_SOLVABLE, solvable_copy_cb, &cbdata);
 }
 
@@ -1042,7 +1042,7 @@ swap_solvables(Repo *repo, Repodata *data, Id pa, Id pb)
   /* only works if nothing is already internalized! */
   if (data && data->attrs)
     {
-      Id *tmpattrs = data->attrs[pa - data->start];
+      Id tmpattrs = data->attrs[pa - data->start];
       data->attrs[pa - data->start] = data->attrs[pb - data->start];
       data->attrs[pb - data->start] = tmpattrs;
     }
@@ -1400,15 +1400,13 @@ getu32(unsigned char *dp)
 }
 
 static void
-add_location(Repodata *data, Solvable *s, const char *location)
+add_location(Repodata *data, Solvable *s, Id handle, const char *location)
 {
   Pool *pool = s->repo->pool;
   const char *name, *n1, *n2;
   int l;
-  Id entry;
 
   repodata_extend(data, s - pool->solvables);
-  entry = (s - pool->solvables) - data->start;
 
   /* skip ./ prefix */
   if (location[0] == '.' && location[1] == '/' && location[2] != '/')
@@ -1427,11 +1425,11 @@ add_location(Repodata *data, Solvable *s, const char *location)
          /* too bad, need to store directory */
          char *dir = strdup(location);
          dir[name - location - 1] = 0;
-         repodata_set_str(data, entry, SOLVABLE_MEDIADIR, dir);
+         repodata_set_str(data, handle, SOLVABLE_MEDIADIR, dir);
          free(dir);
        }
       else
-        repodata_set_void(data, entry, SOLVABLE_MEDIADIR);
+        repodata_set_void(data, handle, SOLVABLE_MEDIADIR);
     }
   n1 = name;
   for (n2 = id2str(pool, s->name); *n2; n1++, n2++)
@@ -1451,11 +1449,11 @@ add_location(Repodata *data, Solvable *s, const char *location)
       break;
   if (*n2 || strcmp (n1, ".rpm"))
     goto nontrivial;
-  repodata_set_void(data, entry, SOLVABLE_MEDIAFILE);
+  repodata_set_void(data, handle, SOLVABLE_MEDIAFILE);
   return;
 
 nontrivial:
-  repodata_set_str(data, entry, SOLVABLE_MEDIAFILE, name);
+  repodata_set_str(data, handle, SOLVABLE_MEDIAFILE, name);
   return;
 }
 
@@ -1578,12 +1576,13 @@ repo_add_rpms(Repo *repo, const char **rpms, int nrpms)
       fclose(fp);
       s = pool_id2solvable(pool, repo_add_solvable(repo));
       rpm2solv(pool, repo, repodata, s, rpmhead);
-      add_location(repodata, s, rpms[i]);
       if (repodata)
        {
-         Id entry = (s - pool->solvables) - repodata->start;
-         repodata_set_num(repodata, entry, SOLVABLE_DOWNLOADSIZE, (unsigned int)((stb.st_size + 1023) / 1024));
-         repodata_set_num(repodata, entry, SOLVABLE_HEADEREND, headerend);
+         Id handle = (s - pool->solvables) - repodata->start;
+         handle = repodata_get_handle(repodata, handle);
+         add_location(repodata, s, handle, rpms[i]);
+         repodata_set_num(repodata, handle, SOLVABLE_DOWNLOADSIZE, (unsigned int)((stb.st_size + 1023) / 1024));
+         repodata_set_num(repodata, handle, SOLVABLE_HEADEREND, headerend);
        }
     }
   if (rpmhead)
index ce05260..607b644 100644 (file)
@@ -235,6 +235,7 @@ struct parsedata {
   // while the tag ends
   const char *tmpattr;
   Repodata *data;
+  Id handle;
 };
 
 static char *flagtabnum[] = {
@@ -431,7 +432,7 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts
 }
 
 static void
-set_desciption_author(Repodata *data, Id entry, char *str)
+set_desciption_author(Repodata *data, Id handle, char *str)
 {
   char *aut, *p;
 
@@ -448,7 +449,7 @@ set_desciption_author(Repodata *data, Id entry, char *str)
       while (l > 0 && str[l - 1] == '\n')
        str[--l] = 0; 
       if (l)
-       repodata_set_str(data, entry, SOLVABLE_DESCRIPTION, str);
+       repodata_set_str(data, handle, SOLVABLE_DESCRIPTION, str);
       p = aut + 19;
       aut = str;        /* copy over */
       while (*p == ' ' || *p == '\n')
@@ -468,19 +469,19 @@ set_desciption_author(Repodata *data, Id entry, char *str)
        aut--;
       *aut = 0; 
       if (*str)
-       repodata_set_str(data, entry, SOLVABLE_AUTHORS, str);
+       repodata_set_str(data, handle, SOLVABLE_AUTHORS, str);
     }
   else if (*str)
-    repodata_set_str(data, entry, SOLVABLE_DESCRIPTION, str);
+    repodata_set_str(data, handle, SOLVABLE_DESCRIPTION, str);
 }
 
 static void
-set_sourcerpm(Repodata *data, Solvable *s, Id entry, char *sourcerpm)
+set_sourcerpm(Repodata *data, Solvable *s, Id handle, char *sourcerpm)
 {
   const char *p, *sevr, *sarch, *name, *evr;
   Pool *pool;
 
-    p = strrchr(sourcerpm, '.');
+  p = strrchr(sourcerpm, '.');
   if (!p || strcmp(p, ".rpm") != 0)
     return;
   p--;
@@ -503,20 +504,20 @@ set_sourcerpm(Repodata *data, Solvable *s, Id entry, char *sourcerpm)
   name = id2str(pool, s->name);
   evr = id2str(pool, s->evr);
   if (!strcmp(sarch, "src.rpm"))
-    repodata_set_constantid(data, entry, SOLVABLE_SOURCEARCH, ARCH_SRC);
+    repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, ARCH_SRC);
   else if (!strcmp(sarch, "nosrc.rpm"))
-    repodata_set_constantid(data, entry, SOLVABLE_SOURCEARCH, ARCH_NOSRC);
+    repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, ARCH_NOSRC);
   else
-    repodata_set_constantid(data, entry, SOLVABLE_SOURCEARCH, strn2id(pool, sarch, strlen(sarch) - 4, 1));
+    repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, strn2id(pool, sarch, strlen(sarch) - 4, 1));
   if (!strncmp(sevr, evr, sarch - sevr - 1) && evr[sarch - sevr - 1] == 0)
-    repodata_set_void(data, entry, SOLVABLE_SOURCEEVR);
+    repodata_set_void(data, handle, SOLVABLE_SOURCEEVR);
   else
-    repodata_set_id(data, entry, SOLVABLE_SOURCEEVR, strn2id(pool, sevr, sarch - sevr - 1, 1));
+    repodata_set_id(data, handle, SOLVABLE_SOURCEEVR, strn2id(pool, sevr, sarch - sevr - 1, 1));
   if (!strncmp(sourcerpm, name, sevr - sourcerpm - 1) && name[sevr - sourcerpm -
  1] == 0)
-    repodata_set_void(data, entry, SOLVABLE_SOURCENAME);
+    repodata_set_void(data, handle, SOLVABLE_SOURCENAME);
   else
-    repodata_set_id(data, entry, SOLVABLE_SOURCENAME, strn2id(pool, sourcerpm, sevr - sourcerpm - 1, 1));
+    repodata_set_id(data, handle, SOLVABLE_SOURCENAME, strn2id(pool, sourcerpm, sevr - sourcerpm - 1, 1));
 }
 
 static void XMLCALL
@@ -528,7 +529,7 @@ startElement(void *userData, const char *name, const char **atts)
   Solvable *s = pd->solvable;
   struct stateswitch *sw;
   const char *str;
-  Id entry = s ? (s - pool->solvables) - pd->data->start : 0;
+  Id handle = pd->handle;
 
   // fprintf(stderr, "into %s, from %d, depth %d, statedepth %d\n", name, pd->state, pd->depth, pd->statedepth);
 
@@ -574,6 +575,7 @@ startElement(void *userData, const char *name, const char **atts)
       
       pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->common.repo));
       repodata_extend(pd->data, pd->solvable - pool->solvables);
+      pd->handle = repodata_get_handle(pd->data, (pd->solvable - pool->solvables) - pd->data->start);
 #if 0
       fprintf(stderr, "package #%d\n", pd->solvable - pool->solvables);
 #endif
@@ -669,12 +671,12 @@ startElement(void *userData, const char *name, const char **atts)
            {
              char *str3 = strdup(str);
              str3[str2 - str] = 0;
-             repodata_set_poolstr(pd->data, entry, SOLVABLE_MEDIADIR, str3);
+             repodata_set_poolstr(pd->data, handle, SOLVABLE_MEDIADIR, str3);
              free(str3);
-              repodata_set_str(pd->data, entry, SOLVABLE_MEDIAFILE, str2 + 1);
+              repodata_set_str(pd->data, handle, SOLVABLE_MEDIAFILE, str2 + 1);
            }
          else
-            repodata_set_str(pd->data, entry, SOLVABLE_MEDIAFILE, str);
+            repodata_set_str(pd->data, handle, SOLVABLE_MEDIAFILE, str);
        }
       break;
     case STATE_CHECKSUM:
@@ -685,7 +687,7 @@ startElement(void *userData, const char *name, const char **atts)
         unsigned int t;
         str = find_attr("build", atts);
         if (str && (t = atoi(str)) != 0)
-          repodata_set_num(pd->data, entry, SOLVABLE_BUILDTIME, t);
+          repodata_set_num(pd->data, handle, SOLVABLE_BUILDTIME, t);
        break;
       }
     case STATE_SIZE:
@@ -693,14 +695,14 @@ startElement(void *userData, const char *name, const char **atts)
         unsigned int k;
         str = find_attr("installed", atts);
        if (str && (k = atoi(str)) != 0)
-         repodata_set_num(pd->data, entry, SOLVABLE_INSTALLSIZE, (k + 1023) / 1024);
+         repodata_set_num(pd->data, handle, SOLVABLE_INSTALLSIZE, (k + 1023) / 1024);
        /* XXX the "package" attribute gives the size of the rpm file,
           i.e. the download size.  Except on packman, there it seems to be
           something else entirely, it has a value near to the other two
           values, as if the rpm is uncompressed.  */
         str = find_attr("package", atts);
        if (str && (k = atoi(str)) != 0)
-         repodata_set_num(pd->data, entry, SOLVABLE_DOWNLOADSIZE, (k + 1023) / 1024);
+         repodata_set_num(pd->data, handle, SOLVABLE_DOWNLOADSIZE, (k + 1023) / 1024);
         break;
       }
     case STATE_HEADERRANGE:
@@ -708,7 +710,7 @@ startElement(void *userData, const char *name, const char **atts)
         unsigned int end;
         str = find_attr("end", atts);
        if (str && (end = atoi(str)) != 0)
-         repodata_set_num(pd->data, entry, SOLVABLE_HEADEREND, end);
+         repodata_set_num(pd->data, handle, SOLVABLE_HEADEREND, end);
       }
     default:
       break;
@@ -723,7 +725,7 @@ endElement(void *userData, const char *name)
   Pool *pool = pd->common.pool;
   Solvable *s = pd->solvable;
   Repo *repo = pd->common.repo;
-  Id entry = s ? (s - pool->solvables) - pd->data->start : 0;
+  Id handle = pd->handle;
   Id id;
   char *p;
 
@@ -771,10 +773,10 @@ endElement(void *userData, const char *name)
       s->vendor = str2id(pool, pd->content, 1);
       break;
     case STATE_RPM_GROUP:
-      repodata_set_poolstr(pd->data, entry, SOLVABLE_GROUP, pd->content);
+      repodata_set_poolstr(pd->data, handle, SOLVABLE_GROUP, pd->content);
       break;
     case STATE_RPM_LICENSE:
-      repodata_set_poolstr(pd->data, entry, SOLVABLE_LICENSE, pd->content);
+      repodata_set_poolstr(pd->data, handle, SOLVABLE_LICENSE, pd->content);
       break;
     case STATE_FILE:
 #if 0
@@ -791,7 +793,7 @@ endElement(void *userData, const char *name)
          p = pd->content;
          id = repodata_str2dir(pd->data, "/", 1);
        }
-      repodata_add_dirstr(pd->data, entry, SOLVABLE_FILELIST, id, p);
+      repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, id, p);
       break;
     // xml store capabilities
     case STATE_CAP_PROVIDES:
@@ -823,14 +825,14 @@ endElement(void *userData, const char *name)
       break;
     case STATE_SUMMARY:
       pd->lang = 0;
-      repodata_set_str(pd->data, entry, SOLVABLE_SUMMARY, pd->content);
+      repodata_set_str(pd->data, handle, SOLVABLE_SUMMARY, pd->content);
       break;
     case STATE_DESCRIPTION:
       pd->lang = 0;
-      set_desciption_author(pd->data, entry, pd->content);
+      set_desciption_author(pd->data, handle, pd->content);
       break;
     case STATE_SOURCERPM:
-      set_sourcerpm(pd->data, s, entry, pd->content);
+      set_sourcerpm(pd->data, s, handle, pd->content);
       break;
     default:
       break;
index e9fd823..490f3b9 100644 (file)
@@ -104,7 +104,7 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id ma
  */
 
 static void
-add_location(struct parsedata *pd, char *line, Solvable *s, unsigned entry)
+add_location(struct parsedata *pd, char *line, Solvable *s, unsigned handle)
 {
   Pool *pool = s->repo->pool;
   char *sp[3];
@@ -124,9 +124,9 @@ add_location(struct parsedata *pd, char *line, Solvable *s, unsigned entry)
     {
       /* medianr filename dir
          don't optimize this one */
-      repodata_set_constant(pd->data, entry, SOLVABLE_MEDIANR, atoi(sp[0]));
-      repodata_set_poolstr(pd->data, entry, SOLVABLE_MEDIADIR, sp[2]);
-      repodata_set_str(pd->data, entry, SOLVABLE_MEDIAFILE, sp[1]);
+      repodata_set_constant(pd->data, handle, SOLVABLE_MEDIANR, atoi(sp[0]));
+      repodata_set_poolstr(pd->data, handle, SOLVABLE_MEDIADIR, sp[2]);
+      repodata_set_str(pd->data, handle, SOLVABLE_MEDIAFILE, sp[1]);
       return;
     }
   else
@@ -156,15 +156,15 @@ add_location(struct parsedata *pd, char *line, Solvable *s, unsigned entry)
       if (*n2 || strcmp (n1, ".rpm"))
         goto nontrivial;
 
-      repodata_set_constant(pd->data, entry, SOLVABLE_MEDIANR, medianr);
-      repodata_set_void(pd->data, entry, SOLVABLE_MEDIADIR);
-      repodata_set_void(pd->data, entry, SOLVABLE_MEDIAFILE);
+      repodata_set_constant(pd->data, handle, SOLVABLE_MEDIANR, medianr);
+      repodata_set_void(pd->data, handle, SOLVABLE_MEDIADIR);
+      repodata_set_void(pd->data, handle, SOLVABLE_MEDIAFILE);
       return;
 
 nontrivial:
-      repodata_set_constant(pd->data, entry, SOLVABLE_MEDIANR, medianr);
-      repodata_set_void(pd->data, entry, SOLVABLE_MEDIADIR);
-      repodata_set_str(pd->data, entry, SOLVABLE_MEDIAFILE, sp[1]);
+      repodata_set_constant(pd->data, handle, SOLVABLE_MEDIANR, medianr);
+      repodata_set_void(pd->data, handle, SOLVABLE_MEDIADIR);
+      repodata_set_str(pd->data, handle, SOLVABLE_MEDIAFILE, sp[1]);
       return;
     }
 }
@@ -175,7 +175,7 @@ nontrivial:
  */
 
 static void
-add_source(struct parsedata *pd, char *line, Solvable *s, unsigned entry)
+add_source(struct parsedata *pd, char *line, Solvable *s, unsigned handle)
 {
   Repo *repo = s->repo;
   Pool *pool = repo->pool;
@@ -192,14 +192,14 @@ add_source(struct parsedata *pd, char *line, Solvable *s, unsigned entry)
   Id arch = str2id(pool, sp[3], 1);
   /* XXX: could record a dep here, depends on where we want to store the data */
   if (name == s->name)
-    repodata_set_void(pd->data, entry, SOLVABLE_SOURCENAME);
+    repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
   else
-    repodata_set_id(pd->data, entry, SOLVABLE_SOURCENAME, name);
+    repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
   if (evr == s->evr)
-    repodata_set_void(pd->data, entry, SOLVABLE_SOURCEEVR);
+    repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
   else
-    repodata_set_id(pd->data, entry, SOLVABLE_SOURCEEVR, evr);
-  repodata_set_constantid(pd->data, entry, SOLVABLE_SOURCEARCH, arch);
+    repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, evr);
+  repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
 }
   
 /*
@@ -233,7 +233,7 @@ fprintf(stderr, "%s -> %d\n", sp[0], dirid);
 }
 
 static void
-set_checksum(Repodata *data, int last_found_pack, Id keyname, char *line)
+set_checksum(Repodata *data, int handle, Id keyname, char *line)
 {
   char *sp[3];
   int l;
@@ -257,7 +257,7 @@ set_checksum(Repodata *data, int last_found_pack, Id keyname, char *line)
       fprintf(stderr, "Invalid checksum length for %s: %s\n", sp[0], sp[1]);
       exit(1);
     }
-  repodata_set_checksum(data, last_found_pack, keyname, type, sp[1]);
+  repodata_set_checksum(data, handle, keyname, type, sp[1]);
 }
 
 /*
@@ -281,7 +281,7 @@ id3_cmp (const void *v1, const void *v2)
  */
 
 static void
-commit_diskusage (struct parsedata *pd, unsigned entry)
+commit_diskusage (struct parsedata *pd, unsigned handle)
 {
   unsigned i;
   Dirpool *dp = &pd->data->dirpool;
@@ -334,7 +334,7 @@ commit_diskusage (struct parsedata *pd, unsigned entry)
   for (i = 0; i < pd->ndirs; i++)
     if (pd->dirs[i][1] || pd->dirs[i][2])
       {
-       repodata_add_dirnumnum(pd->data, entry, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
+       repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
       }
   pd->ndirs = 0;
 }
@@ -384,7 +384,7 @@ tag_from_string (char *cs)
  */
 
 void
-finish_solvable(struct parsedata *pd, Solvable *s, int last_found_pack)
+finish_solvable(struct parsedata *pd, Solvable *s, int handle)
 {
   Pool *pool = pd->repo->pool;
 
@@ -425,7 +425,7 @@ finish_solvable(struct parsedata *pd, Solvable *s, int last_found_pack)
                  sdup[sp - str] = 0;
                  did = repodata_str2dir(pd->data, sdup, 1);
                }
-             repodata_add_dirstr(pd->data, last_found_pack, SOLVABLE_FILELIST, did, sp + 1);
+             repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, sp + 1);
              *p = 0;
            }
        }
@@ -440,7 +440,7 @@ finish_solvable(struct parsedata *pd, Solvable *s, int last_found_pack)
      harmless to do twice.  */
   s->supplements = repo_fix_legacy(pd->repo, s->provides, s->supplements);
   if (pd->ndirs)
-    commit_diskusage (pd, last_found_pack);
+    commit_diskusage (pd, handle);
 }
 
 void
@@ -458,6 +458,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
   struct parsedata pd;
   Repodata *data = 0;
   Id blanr = -1;
+  Id handle = 0;
 
   if ((flags & SUSETAGS_EXTEND) && repo->nrepodata)
     indesc = 1;
@@ -588,7 +589,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
          /* If we have an old solvable, complete it by filling in some
             default stuff.  */
          if (s)
-           finish_solvable(&pd, s, last_found_pack);
+           finish_solvable(&pd, s, handle);
 
          /*
           * define kind
@@ -639,7 +640,10 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
              if (n == repo->end)
                s = 0;
              else
-               last_found_pack = nn - repo->start;
+               {
+                 last_found_pack = nn - repo->start;
+                 handle = repodata_get_handle(data, last_found_pack);
+               }
            }
 
          /* And if we still don't have a solvable, create a new one.  */
@@ -648,7 +652,10 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
              s = pool_id2solvable(pool, repo_add_solvable(repo));
              last_found_pack = (s - pool->solvables) - repo->start;
              if (data)
-               repodata_extend(data, s - pool->solvables);
+               {
+                 repodata_extend(data, s - pool->solvables);
+                 handle = repodata_get_handle(data, last_found_pack);
+               }
              if (name)
                s->name = name;
              else if (pd.kind)
@@ -684,7 +691,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
            if (pd.kind)
              {
                if (flags & SUSETAGS_KINDS_SEPARATELY)
-                 repodata_set_poolstr(data, last_found_pack, str2id(pool, "solvable:must", 1), line + 6);
+                 repodata_set_poolstr(data, handle, str2id(pool, "solvable:must", 1), line + 6);
                else
                  s->requires = adddep(pool, &pd, s->requires, line, 0, 0);           /* patterns: a required package */
              }
@@ -714,13 +721,13 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
            continue;
           case CTAG('=', 'P', 'r', 'c'):                                        /* packages recommended */
            if (flags & SUSETAGS_KINDS_SEPARATELY)
-             repodata_set_poolstr(data, last_found_pack, str2id(pool, "solvable:should", 1), line + 6);
+             repodata_set_poolstr(data, handle, str2id(pool, "solvable:should", 1), line + 6);
            else
              s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
            continue;
           case CTAG('=', 'P', 's', 'g'):                                        /* packages suggested */
            if (flags & SUSETAGS_KINDS_SEPARATELY)
-             repodata_set_poolstr(data, last_found_pack, str2id(pool, "solvable:may", 1), line + 6);
+             repodata_set_poolstr(data, handle, str2id(pool, "solvable:may", 1), line + 6);
            else
              s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
            continue;
@@ -756,53 +763,54 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
            continue;
           case CTAG('=', 'V', 'e', 'r'):                                        /* - version - */
            last_found_pack = 0;
+           handle = 0;
            indesc++;
            continue;
 
         /* From here it's the attribute tags.  */
           case CTAG('=', 'G', 'r', 'p'):
-           repodata_set_poolstr(data, last_found_pack, SOLVABLE_GROUP, line + 6);
+           repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
            continue;
           case CTAG('=', 'L', 'i', 'c'):
-           repodata_set_poolstr(data, last_found_pack, SOLVABLE_LICENSE, line + 6);
+           repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
            continue;
           case CTAG('=', 'L', 'o', 'c'):
-           add_location(&pd, line + 6, s, last_found_pack);
+           add_location(&pd, line + 6, s, handle);
            continue;
           case CTAG('=', 'S', 'r', 'c'):
-           add_source(&pd, line + 6, s, last_found_pack);
+           add_source(&pd, line + 6, s, handle);
            continue;
           case CTAG('=', 'S', 'i', 'z'):
            if (split (line + 6, sp, 3) == 2)
              {
-               repodata_set_num(data, last_found_pack, SOLVABLE_DOWNLOADSIZE, (atoi(sp[0]) + 1023) / 1024);
-               repodata_set_num(data, last_found_pack, SOLVABLE_INSTALLSIZE, (atoi(sp[1]) + 1023) / 1024);
+               repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, (atoi(sp[0]) + 1023) / 1024);
+               repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, (atoi(sp[1]) + 1023) / 1024);
              }
            continue;
           case CTAG('=', 'T', 'i', 'm'):
            {
              unsigned int t = atoi (line + 6);
              if (t)
-               repodata_set_num(data, last_found_pack, SOLVABLE_BUILDTIME, t);
+               repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
            }
            continue;
           case CTAG('=', 'K', 'w', 'd'):
-           repodata_add_poolstr_array(data, last_found_pack, SOLVABLE_KEYWORDS, line + 6);
+           repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
            continue;
           case CTAG('=', 'A', 'u', 't'):
-           repodata_set_str(data, last_found_pack, SOLVABLE_AUTHORS, line + 6);
+           repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
            continue;
           case CTAG('=', 'S', 'u', 'm'):
-           repodata_set_str(data, last_found_pack, langtag(&pd, SOLVABLE_SUMMARY, language), line + 6);
+           repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, language), line + 6);
            continue;
           case CTAG('=', 'D', 'e', 's'):
-           repodata_set_str(data, last_found_pack, langtag(&pd, SOLVABLE_DESCRIPTION, language), line + 6);
+           repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, language), line + 6);
            continue;
           case CTAG('=', 'E', 'u', 'l'):
-           repodata_set_str(data, last_found_pack, langtag(&pd, SOLVABLE_EULA, language), line + 6);
+           repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, language), line + 6);
            continue;
           case CTAG('=', 'I', 'n', 's'):
-           repodata_set_str(data, last_found_pack, langtag(&pd, SOLVABLE_MESSAGEINS, language), line + 6);
+           repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, language), line + 6);
            if (blanr)
              {
                /* XXX testcode */
@@ -811,7 +819,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
              }
            continue;
           case CTAG('=', 'D', 'e', 'l'):
-           repodata_set_str(data, last_found_pack, langtag(&pd, SOLVABLE_MESSAGEDEL, language), line + 6);
+           repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, language), line + 6);
            continue;
           case CTAG('=', 'V', 'i', 's'):
            {
@@ -819,7 +827,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
              unsigned k;
              k = atoi (line + 6);
              if (k || !strcasecmp (line + 6, "true"))
-               repodata_set_constant(data, last_found_pack, SOLVABLE_ISVISIBLE, 1);
+               repodata_set_constant(data, handle, SOLVABLE_ISVISIBLE, 1);
            }
            continue;
           case CTAG('=', 'S', 'h', 'r'):
@@ -840,24 +848,24 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
            add_dirline (&pd, line + 6);
            continue;
          case CTAG('=', 'C', 'a', 't'):
-           repodata_set_poolstr(data, last_found_pack, SOLVABLE_CATEGORY, line + 6);
+           repodata_set_poolstr(data, handle, SOLVABLE_CATEGORY, line + 6);
            break;
          case CTAG('=', 'O', 'r', 'd'):
            /* Order is a string not a number, so we can retroactively insert
               new patterns in the middle, i.e. 1 < 15 < 2.  */
-           repodata_set_str(data, last_found_pack, SOLVABLE_ORDER, line + 6);
+           repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
            break;
          case CTAG('=', 'I', 'c', 'o'):
-           repodata_set_str(data, last_found_pack, SOLVABLE_ICON, line + 6);
+           repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
            break;
          case CTAG('=', 'E', 'x', 't'):
-           repodata_add_poolstr_array(data, last_found_pack, SOLVABLE_EXTENDS, join2("pattern", ":", line + 6));
+           repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2("pattern", ":", line + 6));
            break;
          case CTAG('=', 'I', 'n', 'c'):
-           repodata_add_poolstr_array(data, last_found_pack, SOLVABLE_INCLUDES, join2("pattern", ":", line + 6));
+           repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2("pattern", ":", line + 6));
            break;
          case CTAG('=', 'C', 'k', 's'):
-           set_checksum(data, last_found_pack, SOLVABLE_CHECKSUM, line + 6);
+           set_checksum(data, handle, SOLVABLE_CHECKSUM, line + 6);
            break;
          case CTAG('=', 'L', 'a', 'n'):
            language = strdup(line + 6);
@@ -874,7 +882,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
     } /* for(;;) */
 
   if (s)
-    finish_solvable(&pd, s, last_found_pack);
+    finish_solvable(&pd, s, handle);
     
   /* Shared attributes
    *  (e.g. multiple binaries built from same source)
@@ -925,4 +933,3 @@ repo_add_susetags(Repo *repo, FILE *fp, Id vendor, const char *language, int fla
     free(pd.common.tmp);
   free(line);
 }
-
index ec76ff3..78fa742 100644 (file)
@@ -21,8 +21,6 @@
 #include "repo_updateinfoxml.h"
 #include "tools_util.h"
 
-//#define TESTMM
-
 /*
  * <updates>
  *   <update from="rel-eng@fedoraproject.org" status="stable" type="security" version="1.4">
@@ -288,6 +286,7 @@ startElement(void *userData, const char *name, const char **atts)
        solvable = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
        pd->datanum = (pd->solvable - pool->solvables) - pd->repo->start;
        repodata_extend(pd->data, pd->solvable - pool->solvables);      
+       pd->datanum = repodata_get_handle(pd->data, pd->datanum);
        
        solvable->vendor = str2id(pool, from, 1);
        solvable->evr = str2id(pool, version, 1);
index 34878ba..4b0e69d 100644 (file)
@@ -136,11 +136,11 @@ join2(const char *s1, const char *s2, const char *s3)
 
 
 /* util function to set a translated string */
-static inline void repodata_set_tstr(Repodata *data, Id rid, const char *attrname, const char *lang, const char *str)
+static inline void repodata_set_tstr(Repodata *data, Id handle, const char *attrname, const char *lang, const char *str)
 {
   Id attrid;
   attrid = str2id(data->repo->pool, join2(attrname, ":", lang), 1);
-  repodata_set_str(data, rid, attrid, str);
+  repodata_set_str(data, handle, attrid, str);
 }
 
 #endif /* SATSOLVER_TOOLS_UTIL_H */