/***********************************************************************/
Repodata *
-repo_add_repodata(Repo *repo)
+repo_add_repodata(Repo *repo, int localpool)
{
Repodata *data;
repo->nrepodata++;
repo->repodata = sat_realloc2(repo->repodata, repo->nrepodata, sizeof(*data));
data = repo->repodata + repo->nrepodata - 1;
- repodata_init(data, repo, 0);
+ repodata_init(data, repo, localpool);
return data;
}
static Repodata *
-findrepodata(Repo *repo, Id p, Id keyname)
+repo_findrepodata(Repo *repo, Id p, Id keyname)
{
int i;
Repodata *data;
repodata_extend(data, p);
return data;
}
- return repo_add_repodata(repo);
+ return repo_add_repodata(repo, 0);
}
void
repo_set_id(Repo *repo, Id p, Id keyname, Id id)
{
- Repodata *data = findrepodata(repo, p, keyname);
+ Repodata *data = repo_findrepodata(repo, p, keyname);
repodata_set_id(data, p - data->start, keyname, id);
}
void
repo_set_num(Repo *repo, Id p, Id keyname, Id num)
{
- Repodata *data = findrepodata(repo, p, keyname);
+ Repodata *data = repo_findrepodata(repo, p, keyname);
repodata_set_num(data, p - data->start, keyname, num);
}
void
repo_set_str(Repo *repo, Id p, Id keyname, const char *str)
{
- Repodata *data = findrepodata(repo, p, keyname);
+ Repodata *data = repo_findrepodata(repo, p, keyname);
repodata_set_str(data, p - data->start, keyname, str);
}
void
repo_set_poolstr(Repo *repo, Id p, Id keyname, const char *str)
{
- Repodata *data = findrepodata(repo, p, keyname);
+ Repodata *data = repo_findrepodata(repo, p, keyname);
repodata_set_poolstr(data, p - data->start, keyname, str);
}
/* Internal */
#define __SEARCH_ONESOLVABLE (1 << 31)
-Repodata *repo_add_repodata(Repo *repo);
+Repodata *repo_add_repodata(Repo *repo, int localpool);
+
void repo_search(Repo *repo, Id p, Id key, const char *match, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata);
/* returns the string value of the attribute, or NULL if not found */
char *pp = prefix;
char *old_str = 0;
char *dest = strsp;
+ int freesp = sizeid;
+
if (pfsize && fread(prefix, pfsize, 1, fp) != 1)
{
pool_debug(pool, SAT_ERROR, "read error while reading strings\n");
for (i = 1; i < numid; i++)
{
int same = (unsigned char)*pp++;
- size_t len = strlen (pp) + 1;
+ size_t len = strlen(pp) + 1;
+ freesp -= same + len;
+ if (freesp < 0)
+ {
+ pool_debug(pool, SAT_ERROR, "overflow while expanding strings\n");
+ sat_free(prefix);
+ return SOLV_ERROR_OVERFLOW;
+ }
if (same)
memcpy(dest, old_str, same);
memcpy(dest + same, pp, len);
dest += same + len;
}
sat_free(prefix);
+ if (freesp != 0)
+ {
+ pool_debug(pool, SAT_ERROR, "expanding strings size mismatch\n");
+ return SOLV_ERROR_CORRUPT;
+ }
}
strsp[sizeid] = 0; /* make string space \0 terminated */
sp = strsp;
{
sat_free(hashtbl);
sat_free(idmap);
- pool_debug(pool, SAT_ERROR, "not enough strings\n");
+ pool_debug(pool, SAT_ERROR, "not enough strings %d %d\n", i, numid);
return SOLV_ERROR_OVERFLOW;
}
if (!*sp) /* empty string */
#define REPODATA_BLOCK 255
+
+void
+repodata_init(Repodata *data, Repo *repo, int localpool)
+{
+ memset(data, 0, sizeof (*data));
+ data->repo = repo;
+ data->localpool = localpool;
+ if (localpool)
+ stringpool_init_empty(&data->spool);
+ data->keys = sat_calloc(1, sizeof(Repokey));
+ data->nkeys = 1;
+ data->schemata = sat_calloc(1, sizeof(Id));
+ data->schemadata = sat_calloc(1, sizeof(Id));
+ data->nschemata = 1;
+ data->schemadatalen = 1;
+ data->start = repo->start;
+ data->end = repo->end;
+ data->incoreoffset = sat_extend_resize(0, data->end - data->start, sizeof(Id), REPODATA_BLOCK);
+ data->pagefd = -1;
+}
+
void
repodata_free(Repodata *data)
{
}
static unsigned char *
-forward_to_key(Repodata *data, Id key, Id schemaid, unsigned char *dp)
+forward_to_key(Repodata *data, Id keyid, Id schemaid, unsigned char *dp)
{
Id k, *keyp;
keyp = data->schemadata + data->schemata[schemaid];
while ((k = *keyp++) != 0)
{
- if (k == key)
+ if (k == keyid)
return dp;
if (data->keys[k].storage == KEY_STORAGE_VERTICAL_OFFSET)
{
make_vertical_available(Repodata *data, Repokey *key, Id off, Id len)
{
unsigned char *dp;
- if (key->type == REPOKEY_TYPE_VOID)
+ if (!len)
return 0;
if (off >= data->lastverticaloffset)
{
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 = load_page_range(data, off / BLOB_PAGESIZE, (off + len - 1) / BLOB_PAGESIZE);
if (dp)
dp += off % BLOB_PAGESIZE;
return 1;
}
-void
-repodata_init(Repodata *data, Repo *repo, int localpool)
-{
- memset(data, 0, sizeof (*data));
- data->repo = repo;
- data->localpool = localpool;
- if (localpool)
- stringpool_init_empty(&data->spool);
- data->keys = sat_calloc(1, sizeof(Repokey));
- data->nkeys = 1;
- data->schemata = sat_calloc(1, sizeof(Id));
- data->schemadata = sat_calloc(1, sizeof(Id));
- data->nschemata = 1;
- data->schemadatalen = 1;
- data->start = repo->start;
- data->end = repo->end;
- data->incoreoffset = sat_extend_resize(0, data->end - data->start, sizeof(Id), REPODATA_BLOCK);
- data->pagefd = -1;
-}
-
/* extend repodata so that it includes solvables p */
void
repodata_extend(Repodata *data, Id p)
repodata_extend(data, start + num - 1);
}
+/**********************************************************************/
+
#define REPODATA_ATTRS_BLOCK 63
#define REPODATA_ATTRDATA_BLOCK 1023
#define REPODATA_ATTRIDDATA_BLOCK 63