Solvable *solvable;
Id handle;
-
- Id langcache[ID_NUM_INTERNAL];
};
/*
- * create localized tag
- */
-
-static Id
-langtag(struct parsedata *pd, Id tag, const char *language)
-{
- if (language && !language[0])
- language = 0;
- if (!language || tag >= ID_NUM_INTERNAL || 1)
- return pool_id2langid(pd->repo->pool, tag, language, 1);
- if (!pd->langcache[tag])
- pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, language, 1);
- return pd->langcache[tag];
-}
-
-
-/*
* XML callback: startElement
*/
case STATE_NAME:
case STATE_CNAME:
- repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content);
+ repodata_set_str(pd->data, pd->handle, pool_id2langid(pd->pool, SOLVABLE_SUMMARY, pd->tmplang, 1), pd->content);
pd->tmplang = solv_free((void *)pd->tmplang);
break;
case STATE_DESCRIPTION:
case STATE_CDESCRIPTION:
- repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_DESCRIPTION, pd->tmplang), pd->content);
+ repodata_set_str(pd->data, pd->handle, pool_id2langid(pd->pool, SOLVABLE_DESCRIPTION, pd->tmplang, 1), pd->content);
pd->tmplang = solv_free((void *)pd->tmplang);
break;
#include "pool.h"
#include "repo.h"
+#include "chksum.h"
#include "repo_updateinfoxml.h"
#define DISABLE_SPLIT
break;
case STATE_NEWPACKAGE:
if ((str = find_attr("name", atts)) != 0)
- {
- pd->newpkgname = pool_str2id(pool, str, 1);
- }
+ pd->newpkgname = pool_str2id(pool, str, 1);
pd->newpkgevr = makeevr_atts(pool, pd, atts);
if ((str = find_attr("arch", atts)) != 0)
- {
- pd->newpkgarch = pool_str2id(pool, str, 1);
- }
+ pd->newpkgarch = pool_str2id(pool, str, 1);
break;
case STATE_DELTA:
pd->delta.filechecksumtype = REPOKEY_TYPE_SHA1;
if ((str = find_attr("type", atts)) != 0)
{
- if (!strcasecmp(str, "sha"))
- pd->delta.filechecksumtype = REPOKEY_TYPE_SHA1;
- else if (!strcasecmp(str, "sha256"))
- pd->delta.filechecksumtype = REPOKEY_TYPE_SHA256;
- else if (!strcasecmp(str, "md5"))
- pd->delta.filechecksumtype = REPOKEY_TYPE_MD5;
- else
+ pd->delta.filechecksumtype = solv_chksum_str2type(str);
+ if (!pd->delta.filechecksumtype)
pool_debug(pool, SOLV_ERROR, "unknown checksum type: '%s'\n", str);
}
case STATE_SEQUENCE:
ino_t baseproduct;
ino_t currentproduct;
int productscheme;
-
- Id langcache[ID_NUM_INTERNAL];
};
/*
- * create localized tag
- */
-
-static Id
-langtag(struct parsedata *pd, Id tag, const char *language)
-{
- if (language && !language[0])
- language = 0;
- if (!language || tag >= ID_NUM_INTERNAL)
- return pool_id2langid(pd->repo->pool, tag, language, 1);
- if (!pd->langcache[tag])
- pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, language, 1);
- return pd->langcache[tag];
-}
-
-
-/*
* XML callback: startElement
*/
/** obsolete **/
break;
case STATE_SUMMARY:
- repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content);
+ repodata_set_str(pd->data, pd->handle, pool_id2langid(pd->pool, SOLVABLE_SUMMARY, pd->tmplang, 1), pd->content);
pd->tmplang = solv_free((void *)pd->tmplang);
break;
case STATE_SHORTSUMMARY:
repodata_set_str(pd->data, pd->handle, PRODUCT_SHORTLABEL, pd->content);
break;
case STATE_DESCRIPTION:
- repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_DESCRIPTION, pd->tmplang), pd->content );
+ repodata_set_str(pd->data, pd->handle, pool_id2langid(pd->pool, SOLVABLE_DESCRIPTION, pd->tmplang, 1), pd->content);
pd->tmplang = solv_free((void *)pd->tmplang);
break;
case STATE_URL:
/* repo data handle */
Id rdhandle;
- const char *tmpattr;
+ Id chksumtype;
};
/*
}
case STATE_CHECKSUM:
case STATE_OPENCHECKSUM:
- pd->tmpattr= find_attr("type", atts);
+ {
+ const char *type= find_attr("type", atts);
+ pd->chksumtype = type && *type ? solv_chksum_str2type(type) : 0;
+ if (!pd->chksumtype)
+ {
+ fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), type ? type : "NULL");
+ exit(1);
+ }
+ }
break;
default:
break;
case STATE_CHECKSUM:
case STATE_OPENCHECKSUM:
- {
- Id type = solv_chksum_str2type(pd->tmpattr);
- if (!type)
- {
- fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr);
- exit(1);
- }
- if (strlen(pd->content) != 2 * solv_chksum_len(type))
- {
- fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr);
- exit(1);
- }
- repodata_set_checksum(pd->data, pd->rdhandle, pd->state == STATE_CHECKSUM ? REPOSITORY_REPOMD_CHECKSUM : REPOSITORY_REPOMD_OPENCHECKSUM, type, pd->content);
- break;
- }
+ if (strlen(pd->content) != 2 * solv_chksum_len(pd->chksumtype))
+ {
+ fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), solv_chksum_type2str(pd->chksumtype));
+ exit(1);
+ }
+ repodata_set_checksum(pd->data, pd->rdhandle, pd->state == STATE_CHECKSUM ? REPOSITORY_REPOMD_CHECKSUM : REPOSITORY_REPOMD_OPENCHECKSUM, pd->chksumtype, pd->content);
+ break;
case STATE_TIMESTAMP:
{
#define CSREALLOC_STEP 1024
struct parsedata {
- struct parsedata_common common;
+ Pool *pool;
+ Repo *repo;
+ Repodata *data;
char *kind;
int depth;
enum state state;
enum state sbtab[NUMSTATES];
/* temporal to store attribute tag language */
const char *tmplang;
- const char *capkind;
- // used to store tmp attributes
- // while the tag ends
- const char *tmpattr;
- Repodata *data;
+ Id chksumtype;
Id handle;
XML_Parser *parser;
Id (*dirs)[3]; // dirid, size, nfiles
int ndirs;
- Id langcache[ID_NUM_INTERNAL];
- /** system language */
- const char *language;
+ const char *language; /* default language */
+ Id langcache[ID_NUM_INTERNAL]; /* cache for the default language */
Id lastdir;
char *lastdirstr;
static Id
langtag(struct parsedata *pd, Id tag, const char *language)
{
- if (!language) /* fall back to default if not specified */
- language = pd->language;
- if (language && (!language[0] || !strcmp(language, "en")))
- language = 0;
- if (!language || tag >= ID_NUM_INTERNAL)
- return pool_id2langid(pd->common.repo->pool, tag, language, 1);
- return pool_id2langid(pd->common.repo->pool, tag, language, 1);
+ if (language)
+ {
+ if (!language[0] || !strcmp(language, "en"))
+ return tag;
+ return pool_id2langid(pd->pool, tag, language, 1);
+ }
+ if (!pd->language)
+ return tag;
+ if (tag >= ID_NUM_INTERNAL)
+ return pool_id2langid(pd->pool, tag, pd->language, 1);
if (!pd->langcache[tag])
- pd->langcache[tag] = pool_id2langid(pd->common.repo->pool, tag, language, 1);
+ pd->langcache[tag] = pool_id2langid(pd->pool, tag, pd->language, 1);
return pd->langcache[tag];
}
#if 0
fprintf(stderr, "new dep %s%s%s\n", pool_id2str(pool, d), id2rel(pool, d), id2evr(pool, d));
#endif
- return repo_addid_dep(pd->common.repo, olddeps, id, marker);
+ return repo_addid_dep(pd->repo, olddeps, id, marker);
}
{
//fprintf(stderr,"+tag: %s\n", name);
struct parsedata *pd = userData;
- Pool *pool = pd->common.pool;
+ Pool *pool = pd->pool;
Solvable *s = pd->solvable;
struct stateswitch *sw;
const char *str;
else
{
/* this is a new package */
- pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->common.repo));
+ pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
pd->freshens = 0;
}
pd->handle = pd->solvable - pool->solvables;
case STATE_SUMMARY:
case STATE_CATEGORY:
case STATE_DESCRIPTION:
- pd->tmplang = find_attr("lang", atts);
+ pd->tmplang = solv_strdup(find_attr("lang", atts));
break;
case STATE_USERVISIBLE:
- repodata_set_void(pd->data, handle, SOLVABLE_ISVISIBLE );
+ repodata_set_void(pd->data, handle, SOLVABLE_ISVISIBLE);
break;
case STATE_INCLUDESENTRY:
{
repodata_set_location(pd->data, handle, 0, 0, str);
break;
case STATE_CHECKSUM:
- pd->tmpattr = find_attr("type", atts);
+ {
+ const char *tmp = find_attr("type", atts);
+ pd->chksumtype = tmp && *tmp ? solv_chksum_str2type(tmp) : 0;
+ if (!pd->chksumtype)
+ {
+ fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), tmp ? tmp: "NULL");
+ exit(1);
+ }
+ }
break;
case STATE_TIME:
{
{
//fprintf(stderr,"-tag: %s\n", name);
struct parsedata *pd = userData;
- Pool *pool = pd->common.pool;
+ Pool *pool = pd->pool;
Solvable *s = pd->solvable;
- Repo *repo = pd->common.repo;
+ Repo *repo = pd->repo;
Id handle = pd->handle;
Id id;
char *p;
break;
case STATE_CHECKSUM:
{
- Id type, index;
- type = solv_chksum_str2type(pd->tmpattr);
- if (!type)
- {
- fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr);
- exit(1);
- }
- if (strlen(pd->content) != 2 * solv_chksum_len(type))
+ Id index;
+
+ if (strlen(pd->content) != 2 * solv_chksum_len(pd->chksumtype))
{
- fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr);
+ fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), solv_chksum_type2str(pd->chksumtype));
exit(1);
}
- repodata_set_checksum(pd->data, handle, SOLVABLE_CHECKSUM, type, pd->content);
+ repodata_set_checksum(pd->data, handle, SOLVABLE_CHECKSUM, pd->chksumtype, pd->content);
/* we save the checksum to solvable id relationship for extended
metadata */
index = stringpool_str2id(&pd->cspool, pd->content, 1 /* create it */);
break;
case STATE_SUMMARY:
repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content);
+ pd->tmplang = solv_free((char *)pd->tmplang);
break;
case STATE_DESCRIPTION:
set_description_author(pd->data, handle, pd->content, pd);
+ pd->tmplang = solv_free((char *)pd->tmplang);
break;
case STATE_CATEGORY:
repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_CATEGORY, pd->tmplang), pd->content);
+ pd->tmplang = solv_free((char *)pd->tmplang);
break;
case STATE_DISTRIBUTION:
repodata_set_poolstr(pd->data, handle, SOLVABLE_DISTRIBUTION, pd->content);
case STATE_EULA:
if (pd->content[0])
repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_EULA, pd->tmplang), pd->content);
+ pd->tmplang = solv_free((char *)pd->tmplang);
break;
case STATE_KEYWORD:
if (pd->content[0])
pd.swtab[sw->from] = sw;
pd.sbtab[sw->to] = sw->from;
}
- pd.common.pool = pool;
- pd.common.repo = repo;
-
+ pd.pool = pool;
+ pd.repo = repo;
pd.data = data;
pd.content = solv_malloc(256);
pd.acontent = 256;
pd.lcontent = 0;
- pd.common.tmp = 0;
- pd.common.tmpl = 0;
pd.kind = 0;
- pd.language = language;
+ pd.language = language && *language && strcmp(language, "en") != 0 ? language : 0;
/* initialize the string pool where we will store
the package checksums we know about, to get an Id
Id evr;
Id arch;
};
+
struct parsedata {
- char *kind;
+ Pool *pool;
Repo *repo;
Repodata *data;
+ char *kind;
int flags;
- struct parsedata_common common;
int last_found_source;
struct datashare *share_with;
int nshare;
- Id (*dirs)[3]; // dirid, size, nfiles
+ Id (*dirs)[3]; /* dirid, size, nfiles */
int ndirs;
- Id langcache[ID_NUM_INTERNAL];
+
+ char *language; /* the default language */
+ Id langcache[ID_NUM_INTERNAL]; /* cache for the default language */
int lineno;
};
static Id
langtag(struct parsedata *pd, Id tag, const char *language)
{
- if (language && !language[0])
- language = 0;
- if (!language || tag >= ID_NUM_INTERNAL)
+ if (language && *language)
return pool_id2langid(pd->repo->pool, tag, language, 1);
- return pool_id2langid(pd->repo->pool, tag, language, 1);
+ if (!pd->language)
+ return tag;
+ if (tag >= ID_NUM_INTERNAL)
+ return pool_id2langid(pd->repo->pool, tag, pd->language, 1);
if (!pd->langcache[tag])
- pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, language, 1);
+ pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, pd->language, 1);
return pd->langcache[tag];
}
line = malloc(1024);
aline = 1024;
- pd.repo = pd.common.repo = repo;
+ pd.pool = pool;
+ pd.repo = repo;
pd.data = data;
- pd.common.pool = pool;
pd.flags = flags;
+ pd.language = language && *language ? solv_strdup(language) : 0;
linep = line;
s = 0;
continue;
if (! (line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
continue;
+ line_lang[0] = 0;
if (line[4] == '.')
{
char *endlang;
endlang = strchr(line + 5, ':');
if (endlang)
{
+ int langsize = endlang - (line + 5);
keylen = endlang - line - 1;
- strncpy(line_lang, line + 5, 5);
- line_lang[endlang - line - 5] = 0;
+ if (langsize > 5)
+ langsize = 5;
+ strncpy(line_lang, line + 5, langsize);
+ line_lang[langsize] = 0;
}
}
- else
- line_lang[0] = 0;
tag = tag_from_string(line);
if (indelta)
repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
continue;
case CTAG('=', 'S', 'u', 'm'):
- repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, language ? language : line_lang), line + 3 + keylen );
+ repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, line_lang), line + 3 + keylen);
continue;
case CTAG('=', 'D', 'e', 's'):
- repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, language ? language : line_lang), line + 3 + keylen );
+ repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, line_lang), line + 3 + keylen);
continue;
case CTAG('=', 'E', 'u', 'l'):
- repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, language), line + 6);
+ repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, line_lang), line + 6);
continue;
case CTAG('=', 'I', 'n', 's'):
- repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, language), line + 6);
+ repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, line_lang), line + 6);
continue;
case CTAG('=', 'D', 'e', 'l'):
- repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, language), line + 6);
+ repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, line_lang), line + 6);
continue;
case CTAG('=', 'V', 'i', 's'):
{
unsigned k;
k = atoi(line + 6);
if (k || !strcasecmp(line + 6, "true"))
- repodata_set_void(data, handle, SOLVABLE_ISVISIBLE );
+ repodata_set_void(data, handle, SOLVABLE_ISVISIBLE);
}
continue;
case CTAG('=', 'S', 'h', 'r'):
set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
break;
case CTAG('=', 'L', 'a', 'n'):
- language = solv_strdup(line + 6);
+ pd.language = solv_free(pd.language);
+ if (line[6])
+ pd.language = solv_strdup(line + 6);
break;
case CTAG('=', 'F', 'l', 's'):
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
- if (pd.common.tmp)
- free(pd.common.tmp);
+ solv_free(pd.language);
free(line);
join_freemem();
return 0;
Solvable *solvable;
Id handle;
-
- Id langcache[ID_NUM_INTERNAL];
};
/*
- * create localized tag
- */
-
-static Id
-langtag(struct parsedata *pd, Id tag, const char *language)
-{
- if (language && !language[0])
- language = 0;
- if (!language || tag >= ID_NUM_INTERNAL)
- return pool_id2langid(pd->repo->pool, tag, language, 1);
- if (!pd->langcache[tag])
- pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, language, 1);
- return pd->langcache[tag];
-}
-
-
-/*
* XML callback: startElement
*/
repodata_extend(pd->data, s - pool->solvables);
pd->handle = s - pool->solvables;
if (type)
- {
- repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, type);
- }
+ repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, type);
}
break;
case STATE_VERSION:
s->arch = pool_str2id(pd->pool, pd->content, 1);
break;
case STATE_SUMMARY:
- repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content);
+ repodata_set_str(pd->data, pd->handle, pool_id2langid(pd->pool, SOLVABLE_SUMMARY, pd->tmplang, 1), pd->content);
pd->tmplang = solv_free((void *)pd->tmplang);
break;
case STATE_VENDOR:
static char *_join_tmp;
static int _join_tmpl;
-struct parsedata_common {
- char *tmp;
- int tmpl;
- Pool *pool;
- Repo *repo;
-};
-
static inline Id
makeevr(Pool *pool, const char *s)
{
char buf[256], *p;
int l;
- if (!lang)
+ if (!lang || !*lang)
return id;
n = pool_id2str(pool, id);
l = strlen(n) + strlen(lang) + 2;