2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
14 #include "repo_solv.h"
15 #include "attr_store.h"
16 #include "attr_store_p.h"
19 dump_attrs_1 (Attrstore *s, unsigned int entry)
22 FOR_ATTRS (s, entry, &ai)
24 fprintf (stdout, "%s:", id2str (s->pool, ai.name));
28 fprintf (stdout, "int %u\n", ai.as_int);
32 const char *str = attr_retrieve_blob (s, ai.as_chunk[0], ai.as_chunk[1]);
34 fprintf (stdout, "blob %s\n", str);
36 fprintf (stdout, "blob %u+%u\n", ai.as_chunk[0], ai.as_chunk[1]);
39 case TYPE_ATTR_STRING:
40 fprintf (stdout, "str %s\n", ai.as_string);
42 case TYPE_ATTR_INTLIST:
44 fprintf (stdout, "lint\n ");
48 get_num (ai.as_numlist, val);
51 fprintf (stdout, " %d", val);
53 fprintf (stdout, "\n");
56 case TYPE_ATTR_LOCALIDS:
58 fprintf (stdout, "lids");
62 get_num (ai.as_numlist, val);
65 fprintf (stdout, "\n %s(%d)", localid2str (s, val), val);
67 fprintf (stdout, "\n");
77 dump_attrs (Repo *repo, unsigned int entry)
80 for (i = 0; i < repo->nrepodata; i++)
82 Attrstore *s = repo->repodata[i].s;
83 if (s && entry < s->entries)
84 dump_attrs_1 (s, entry);
89 dump_repodata (Repo *repo)
93 if (repo->nrepodata == 0)
95 printf ("repo refers to %d attribute stores:\n", repo->nrepodata);
96 for (i = 0, d = repo->repodata; i < repo->nrepodata; i++, d++)
99 printf ("%s has %d keys", d->name ? d->name : "**EMBED**", d->nkeys);
100 for (j = 0; j < d->nkeys; j++)
101 printf ("\n %s", id2str (repo->pool, d->keys[j].name));
108 printids(Repo *repo, char *kind, Offset ido)
110 Pool *pool = repo->pool;
114 printf("%s:\n", kind);
115 ids = repo->idarraydata + ido;
116 while((id = *ids++) != 0)
117 printf(" %s\n", dep2str(pool, id));
120 int main(int argc, char **argv)
129 if (freopen(argv[1], "r", stdin) == 0)
135 pool = pool_create();
136 repo = repo_create(pool, argc != 1 ? argv[1] : "<stdin>");
137 repo_add_solv(repo, stdin);
138 dump_repodata (repo);
139 printf("repo contains %d solvables\n", repo->nsolvables);
140 for (i = repo->start, n = 1; i < repo->end; i++)
142 s = pool->solvables + i;
146 printf("solvable %d:\n", n);
147 if (s->name || s->evr || s->arch)
148 printf("name: %s %s %s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch));
150 printf("vendor: %s\n", id2str(pool, s->vendor));
151 printids(repo, "provides", s->provides);
152 printids(repo, "obsoletes", s->obsoletes);
153 printids(repo, "conflicts", s->conflicts);
154 printids(repo, "requires", s->requires);
155 printids(repo, "recommends", s->recommends);
156 printids(repo, "suggests", s->suggests);
157 printids(repo, "supplements", s->supplements);
158 printids(repo, "enhances", s->enhances);
159 printids(repo, "freshens", s->freshens);
160 dump_attrs (repo, n - 1);