2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
17 #include "repo_write.h"
18 #include "common_write.h"
20 static char *verticals[] = {
31 static unsigned char *filter;
35 create_filter(Pool *pool)
39 for (s = verticals; *s; s++)
41 id = str2id(pool, *s, 1);
44 filter = sat_realloc(filter, id + 16);
45 memset(filter + nfilter, 0, id + 16 - nfilter);
52 static int test_separate = 0;
55 keyfilter_solv(Repo *data, Repokey *key, void *kfdata)
57 if (test_separate && key->storage != KEY_STORAGE_SOLVABLE)
58 return KEY_STORAGE_DROPPED;
59 if (key->name < nfilter && filter[key->name])
60 return KEY_STORAGE_VERTICAL_OFFSET;
61 return KEY_STORAGE_INCORE;
65 keyfilter_attr(Repo *data, Repokey *key, void *kfdata)
67 if (key->storage == KEY_STORAGE_SOLVABLE)
68 return KEY_STORAGE_DROPPED;
69 if (key->name < nfilter && filter[key->name])
70 return KEY_STORAGE_VERTICAL_OFFSET;
71 return KEY_STORAGE_INCORE;
75 * Write <repo> to stdout
76 * If <attrname> is given, write attributes to <attrname>
80 tool_write(Repo *repo, const char *basename, const char *attrname)
82 Pool *pool = repo->pool;
83 Repodatafile fileinfoa[1];
84 Repodatafile *fileinfo = 0;
88 memset (fileinfoa, 0, sizeof fileinfoa);
93 FILE *fp = fopen (attrname, "w");
94 repo_write(repo, fp, keyfilter_attr, 0, fileinfo, 0);
96 fileinfo->location = strdup (attrname);
99 nsubfiles = fileinfo - fileinfoa;
100 fileinfo = fileinfoa;
102 repo_write(repo, stdout, keyfilter_solv, 0, fileinfo, nsubfiles);