From: Michael Matz Date: Sat, 8 Dec 2007 03:08:32 +0000 (+0000) Subject: I'm going to use the file info block real soon now and noticed that X-Git-Tag: BASE-SuSE-Code-12_1-Branch~1063 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c32508241b64f6de19f35a07afaf2d1089fd842;p=platform%2Fupstream%2Flibsolv.git I'm going to use the file info block real soon now and noticed that doing it with the schema way brings only hassle for no good. The info is per file, hence probably the same scheme won't be reused by anything else. Hence going back to nearly the old way. I do have use for a counted type, in order to skip safely over unknown entries. Old SOLV files can be read when they don't have any file info. None should have. --- diff --git a/src/pool.h b/src/pool.h index 2149f2b..027d49b 100644 --- a/src/pool.h +++ b/src/pool.h @@ -132,7 +132,9 @@ struct _Pool { #define TYPE_ATTR_STRING 8 #define TYPE_ATTR_INTLIST 9 #define TYPE_ATTR_LOCALIDS 10 -#define TYPE_ATTR_TYPE_MAX 10 + +#define TYPE_COUNT_NAMED 11 +#define TYPE_ATTR_TYPE_MAX 11 //----------------------------------------------- diff --git a/src/pooltypes.h b/src/pooltypes.h index afacf62..b64bbbc 100644 --- a/src/pooltypes.h +++ b/src/pooltypes.h @@ -17,6 +17,7 @@ #define SOLV_VERSION_0 0 #define SOLV_VERSION_1 1 #define SOLV_VERSION_2 2 +#define SOLV_VERSION_3 3 #define SOLV_FLAG_PACKEDSIZES 1 #define SOLV_FLAG_VERTICAL 2 #define SOLV_FLAG_PREFIX_POOL 4 diff --git a/src/repo_solv.c b/src/repo_solv.c index d6a461c..7a9bda8 100644 --- a/src/repo_solv.c +++ b/src/repo_solv.c @@ -184,6 +184,55 @@ read_idarray(FILE *fp, Id max, Id *map, Id *store, Id *end, int relative) } +static void +skip_item (FILE *fp, unsigned type, Id *idmap, unsigned numid, unsigned numrel) +{ + switch (type) + { + case TYPE_ID: + read_id(fp, numid + numrel); /* just check Id */ + break; + case TYPE_U32: + read_u32(fp); + break; + case TYPE_ATTR_STRING: + case TYPE_STR: + while(read_u8(fp) != 0) + ; + break; + case TYPE_IDARRAY: + case TYPE_REL_IDARRAY: + while ((read_u8(fp) & 0xc0) != 0) + ; + break; + case TYPE_COUNT_NAMED: + { + unsigned count = read_id (fp, 0); + while (count--) + { + read_id (fp, numid); /* Name */ + unsigned t = read_id (fp, TYPE_ATTR_TYPE_MAX + 1); + skip_item (fp, t, idmap, numid, numrel); + } + } + break; + case TYPE_ATTR_CHUNK: + read_id(fp, 0); + /* Fallthrough. */ + case TYPE_ATTR_INT: + read_id(fp, 0); + break; + case TYPE_ATTR_INTLIST: + case TYPE_ATTR_LOCALIDS: + while (read_id(fp, 0) != 0) + ; + break; + default: + pool_debug(mypool, SAT_FATAL, "unknown type %d\n", type); + exit(1); + } +} + /*-----------------------------------------------------------------*/ struct key { @@ -208,7 +257,6 @@ repo_add_solv(Repo *repo, FILE *fp) unsigned int numkeys, numschemata, numinfo; Attrstore *embedded_store = 0; - int type; Offset sizeid; Offset *str; /* map Id -> Offset into string space */ char *strsp; /* repo string space */ @@ -243,6 +291,7 @@ repo_add_solv(Repo *repo, FILE *fp) { case SOLV_VERSION_1: case SOLV_VERSION_2: + case SOLV_VERSION_3: break; default: pool_debug(pool, SAT_FATAL, "unsupported SOLV version\n"); @@ -259,6 +308,13 @@ repo_add_solv(Repo *repo, FILE *fp) numinfo = read_u32(fp); solvflags = read_u32(fp); + if (solvversion < SOLV_VERSION_3 + && numinfo) + { + pool_debug(pool, SAT_FATAL, "unsupported SOLV format (has info)\n"); + exit(1); + } + /******* Part 1: string IDs *****************************************/ sizeid = read_u32(fp); /* size of string+Id space */ @@ -512,44 +568,13 @@ repo_add_solv(Repo *repo, FILE *fp) /* we skip the info for now... */ for (i = 0; i < numinfo; i++) { - Id *schema = schemadata + schemata[read_id(fp, numschemata)]; - while ((key = *schema++) != 0) - { - type = keys[key].type; - switch (type) - { - case TYPE_ID: - read_id(fp, numid + numrel); /* just check Id */ - break; - case TYPE_U32: - read_u32(fp); - break; - case TYPE_ATTR_STRING: - case TYPE_STR: - while(read_u8(fp) != 0) - ; - break; - case TYPE_IDARRAY: - case TYPE_REL_IDARRAY: - while ((read_u8(fp) & 0xc0) != 0) - ; - break; - case TYPE_ATTR_CHUNK: - read_id(fp, 0); - /* Fallthrough. */ - case TYPE_ATTR_INT: - read_id(fp, 0); - break; - case TYPE_ATTR_INTLIST: - case TYPE_ATTR_LOCALIDS: - while (read_id(fp, 0) != 0) - ; - break; - default: - pool_debug(pool, SAT_FATAL, "unknown type %d\n", type); - exit(0); - } - } + unsigned name = idmap[read_id (fp, numid)]; + unsigned type = read_id (fp, TYPE_ATTR_TYPE_MAX + 1); + if (type == TYPE_COUNT_NAMED + && !strcmp (id2str (pool, name), "repodata")) + skip_item (fp, type, idmap, numid, numrel); + else + skip_item (fp, type, idmap, numid, numrel); } /******* Part 6: packed sizes (optional) ****************************/