+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
#include <sys/types.h>
#include <limits.h>
#include <fcntl.h>
#include <expat.h>
#include "pool.h"
+#include "util.h"
#include "repo_rpmmd.h"
STATE_ARCH,
STATE_VERSION,
STATE_FORMAT,
+ STATE_VENDOR,
STATE_PROVIDES,
STATE_PROVIDESENTRY,
STATE_REQUIRES,
{ STATE_PACKAGE, "arch", STATE_ARCH, 1 },
{ STATE_PACKAGE, "version", STATE_VERSION, 0 },
{ STATE_PACKAGE, "format", STATE_FORMAT, 0 },
+ { STATE_FORMAT, "rpm:vendor", STATE_VENDOR, 1 },
{ STATE_FORMAT, "rpm:provides", STATE_PROVIDES, 0 },
{ STATE_FORMAT, "rpm:requires", STATE_REQUIRES, 0 },
{ STATE_FORMAT, "rpm:obsoletes", STATE_OBSOLETES , 0 },
l += strlen(r) + 1;
if (l > pd->acontent)
{
- pd->content = realloc(pd->content, l + 256);
+ pd->content = xrealloc(pd->content, l + 256);
pd->acontent = l + 256;
}
c = pd->content;
int l = strlen(k) + 1 + strlen(n) + 1;
if (l > pd->acontent)
{
- pd->content = realloc(pd->content, l + 256);
+ pd->content = xrealloc(pd->content, l + 256);
pd->acontent = l + 256;
}
sprintf(pd->content, "%s:%s", k, n);
#if 0
fprintf(stderr, "numpacks: %d\n", pd->numpacks);
#endif
- pool->solvables = realloc(pool->solvables, (pool->nsolvables + pd->numpacks) * sizeof(Solvable));
- pd->start = pool->solvables + pd->repo->start;
+ pool->solvables = xrealloc2(pool->solvables, (pool->nsolvables + pd->numpacks), sizeof(Solvable));
+ pd->start = pool->solvables + pool->nsolvables;
memset(pd->start, 0, pd->numpacks * sizeof(Solvable));
}
}
case STATE_ARCH:
s->arch = str2id(pool, pd->content, 1);
break;
+ case STATE_VENDOR:
+ s->vendor = str2id(pool, pd->content, 1);
+ break;
case STATE_FILE:
id = str2id(pool, pd->content, 1);
s->provides = repo_addid(pd->repo, s->provides, id);
l = pd->lcontent + len + 1;
if (l > pd->acontent)
{
- pd->content = realloc(pd->content, l + 256);
+ pd->content = xrealloc(pd->content, l + 256);
pd->acontent = l + 256;
}
c = pd->content + pd->lcontent;
#define BUFF_SIZE 8192
-Repo *
-pool_addrepo_rpmmd(Pool *pool, FILE *fp)
+void
+repo_add_rpmmd(Repo *repo, FILE *fp)
{
+ Pool *pool = repo->pool;
struct parsedata pd;
char buf[BUFF_SIZE];
int i, l;
- Repo *repo;
struct stateswitch *sw;
- repo = pool_addrepo_empty(pool);
+ if (repo->start && repo->start + repo->nsolvables != pool->nsolvables)
+ abort();
+ if (!repo->start)
+ repo->start = pool->nsolvables;
+
memset(&pd, 0, sizeof(pd));
for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++)
{
XML_ParserFree(parser);
pool->nsolvables += pd.pack;
- repo->nsolvables = pd.pack;
+ repo->nsolvables += pd.pack;
free(pd.content);
- return repo;
}