to write which attributes.
repo_rpmdb.h
repo_rpmdb.c
repo_write.c
+ common_write.c
)
ADD_EXECUTABLE( rpmdb2solv ${rpmdb2solv_REPOS} )
TARGET_LINK_LIBRARIES( rpmdb2solv satsolver ${DB43_LIBRARY})
-SET(rpmmd2solv_REPOS rpmmd2solv.c repo_rpmmd.h repo_rpmmd.c repo_write.c )
+SET(rpmmd2solv_REPOS rpmmd2solv.c repo_rpmmd.h repo_rpmmd.c repo_write.c common_write.c )
ADD_EXECUTABLE( rpmmd2solv ${rpmmd2solv_REPOS} )
TARGET_LINK_LIBRARIES( rpmmd2solv satsolver ${EXPAT_LIBRARY})
-SET(helix2solv_REPOS helix2solv.c repo_helix.h repo_helix.c repo_write.c )
+SET(helix2solv_REPOS helix2solv.c repo_helix.h repo_helix.c repo_write.c common_write.c )
ADD_EXECUTABLE( helix2solv ${helix2solv_REPOS} )
TARGET_LINK_LIBRARIES( helix2solv satsolver ${EXPAT_LIBRARY})
-SET(susetags2solv_REPOS susetags2solv.c repo_susetags.h repo_susetags.c repo_write.c)
+SET(susetags2solv_REPOS susetags2solv.c repo_susetags.h repo_susetags.c repo_write.c common_write.c)
ADD_EXECUTABLE( susetags2solv ${susetags2solv_REPOS} )
TARGET_LINK_LIBRARIES( susetags2solv satsolver)
-SET(patchxml2solv_REPOS patchxml2solv.c repo_patchxml.h repo_patchxml.c repo_write.c)
+SET(patchxml2solv_REPOS patchxml2solv.c repo_patchxml.h repo_patchxml.c repo_write.c common_write.c)
ADD_EXECUTABLE( patchxml2solv ${patchxml2solv_REPOS} )
TARGET_LINK_LIBRARIES( patchxml2solv satsolver ${EXPAT_LIBRARY})
content2solv.c
repo_content.h
repo_content.c
- repo_write.c)
+ repo_write.c common_write.c)
ADD_EXECUTABLE( content2solv ${content2solv_REPOS} )
TARGET_LINK_LIBRARIES( content2solv satsolver)
ADD_EXECUTABLE( dumpsolv ${dumpsolv_REPOS} )
TARGET_LINK_LIBRARIES( dumpsolv satsolver)
-SET(mergesolv_REPOS mergesolv.c repo_write.c)
+SET(mergesolv_REPOS mergesolv.c repo_write.c common_write.c)
ADD_EXECUTABLE( mergesolv ${mergesolv_REPOS} )
TARGET_LINK_LIBRARIES( mergesolv satsolver)
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "pool.h"
+#include "repo.h"
+#include "repo_write.h"
+#include "common_write.h"
+
+static char *verticals[] = {
+ "authors",
+ "description",
+ "messagedel",
+ "messageins",
+ "eula",
+ "diskusage",
+ 0
+};
+
+static unsigned char *filter;
+static int nfilter;
+
+static void
+create_filter(Pool *pool)
+{
+ char **s;
+ Id id;
+ for (s = verticals; *s; s++)
+ {
+ id = str2id(pool, *s, 1);
+ if (id >= nfilter)
+ {
+ filter = sat_realloc(filter, id + 16);
+ memset(filter + nfilter, 0, id + 16 - nfilter);
+ nfilter = id + 16;
+ }
+ filter[id] = 1;
+ }
+}
+
+static int test_separate = 0;
+
+static int
+keyfilter_solv(Repo *data, Repokey *key, void *kfdata)
+{
+ if (test_separate && key->storage != KEY_STORAGE_SOLVABLE)
+ return KEY_STORAGE_DROPPED;
+ if (key->name < nfilter && filter[key->name])
+ return KEY_STORAGE_VERTICAL_OFFSET;
+ return KEY_STORAGE_INCORE;
+}
+
+static int
+keyfilter_attr(Repo *data, Repokey *key, void *kfdata)
+{
+ if (key->storage == KEY_STORAGE_SOLVABLE)
+ return KEY_STORAGE_DROPPED;
+ if (key->name < nfilter && filter[key->name])
+ return KEY_STORAGE_VERTICAL_OFFSET;
+ return KEY_STORAGE_INCORE;
+}
+
+int
+tool_write(Repo *repo, const char *basename, int separate)
+{
+ Pool *pool = repo->pool;
+ Repodatafile fileinfoa[1];
+ Repodatafile *fileinfo = 0;
+ int nsubfiles = 0;
+
+ create_filter(pool);
+ memset (fileinfoa, 0, sizeof fileinfoa);
+ if (separate)
+ {
+ test_separate = 1;
+ fileinfo = fileinfoa;
+ FILE *fp = fopen ("test.attr", "w");
+ repo_write(repo, fp, keyfilter_attr, 0, fileinfo, 0);
+ fclose (fp);
+ fileinfo->location = strdup ("test.attr");
+ fileinfo++;
+
+ nsubfiles = fileinfo - fileinfoa;
+ fileinfo = fileinfoa;
+ }
+ repo_write(repo, stdout, keyfilter_solv, 0, fileinfo, nsubfiles);
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+#ifndef COMMON_WRITE_H
+#define COMMON_WRITE_H
+
+#include "repo.h"
+
+int tool_write(Repo *repo, const char *basename, int separate);
+
+#endif
#include "pool.h"
#include "repo.h"
#include "repo_content.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
repo_add_content(repo, stdin);
- repo_write(repo, stdout, 0, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
return 0;
}
#include "pool.h"
#include "repo_helix.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
repo_add_helix(repo, stdin);
- repo_write(repo, stdout, 0, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
}
#include "pool.h"
#include "repo_solv.h"
-#include "repo_write.h"
-
-static char *verticals[] = {
- "authors",
- "description",
- "messagedel",
- "messageins",
- "eula",
- "diskusage",
- 0
-};
-
-static unsigned char *filter;
-static int nfilter;
-
-static void
-create_filter(Pool *pool)
-{
- char **s;
- Id id;
- for (s = verticals; *s; s++)
- {
- id = str2id(pool, *s, 1);
- if (id >= nfilter)
- {
- filter = sat_realloc(filter, id + 16);
- memset(filter + nfilter, 0, id + 16 - nfilter);
- nfilter = id + 16;
- }
- filter[id] = 1;
- }
-}
-
-static int
-keyfilter(Repo *data, Repokey *key, void *kfdata)
-{
- if (key->name < nfilter && filter[key->name])
- return KEY_STORAGE_VERTICAL_OFFSET;
- return KEY_STORAGE_INCORE;
-}
+#include "common_write.h"
int
main(int argc, char **argv)
fclose(fp);
}
- create_filter(pool);
- repo_write(repo, stdout, keyfilter, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
return 0;
#include "pool.h"
#include "repo.h"
#include "repo_patchxml.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
repo_add_patchxml(repo, stdin);
- repo_write(repo, stdout, 0, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
}
#include "repo.h"
#include "repo_rpmdb.h"
#include "repo_solv.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
ref = 0;
}
- repo_write(repo, stdout, 0, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
#include "pool.h"
#include "repo.h"
#include "repo_rpmmd.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
repo_add_rpmmd(repo, stdin);
- repo_write(repo, stdout, 0, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
}
#include "pool.h"
#include "repo.h"
#include "repo_susetags.h"
-#include "repo_write.h"
-#if 0
-#include "attr_store.h"
-
-extern Attrstore *attr;
-#endif
-
-static char *verticals[] = {
- "authors",
- "description",
- "messagedel",
- "messageins",
- "eula",
- "diskusage",
- 0
-};
-
-static unsigned char *filter;
-static int nfilter;
-
-static void
-create_filter(Pool *pool)
-{
- char **s;
- Id id;
- for (s = verticals; *s; s++)
- {
- id = str2id(pool, *s, 1);
- if (id >= nfilter)
- {
- filter = sat_realloc(filter, id + 16);
- memset(filter + nfilter, 0, id + 16 - nfilter);
- nfilter = id + 16;
- }
- filter[id] = 1;
- }
-}
-
-static int test_separate = 0;
-
-static int
-keyfilter_solv(Repo *data, Repokey *key, void *kfdata)
-{
- if (test_separate && key->storage != KEY_STORAGE_SOLVABLE)
- return KEY_STORAGE_DROPPED;
- if (key->name < nfilter && filter[key->name])
- return KEY_STORAGE_VERTICAL_OFFSET;
- return KEY_STORAGE_INCORE;
-}
-
-static int
-keyfilter_attr(Repo *data, Repokey *key, void *kfdata)
-{
- if (key->storage == KEY_STORAGE_SOLVABLE)
- return KEY_STORAGE_DROPPED;
- if (key->name < nfilter && filter[key->name])
- return KEY_STORAGE_VERTICAL_OFFSET;
- return KEY_STORAGE_INCORE;
-}
+#include "common_write.h"
int
main(int argc, char **argv)
{
- Repodatafile fileinfoa[1];
- Repodatafile *fileinfo = 0;
- int nsubfiles = 0;
int with_attr = 0;
+ int test_separate = 0;
argv++;
argc--;
while (argc--)
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
repo_add_susetags(repo, stdin, 0, with_attr);
- create_filter(pool);
- memset (fileinfoa, 0, sizeof fileinfoa);
- if (with_attr && test_separate)
- {
- fileinfo = fileinfoa;
- FILE *fp = fopen ("test.attr", "w");
- repo_write(repo, fp, keyfilter_attr, 0, fileinfo, 0);
- fclose (fp);
- fileinfo->location = strdup ("test.attr");
- fileinfo++;
-
- nsubfiles = fileinfo - fileinfoa;
- fileinfo = fileinfoa;
- }
- repo_write(repo, stdout, keyfilter_solv, 0, fileinfo, nsubfiles);
-#if 0
- if (with_attr && attr)
- {
- FILE *fp = fopen ("test.attr", "w");
- write_attr_store (fp, attr);
- fclose (fp);
- }
-#endif
+ tool_write(repo, 0, with_attr && test_separate);
pool_free(pool);
exit(0);
}