Author: matz
Date: Mon Feb 11 03:38:58 2008
New Revision: 8599
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8599&view=rev
Log:
Factor out the filter code in preparation for nicely configuring where
to write which attributes.
Added:
trunk/sat-solver/tools/common_write.c
trunk/sat-solver/tools/common_write.h
Modified:
trunk/sat-solver/tools/CMakeLists.txt
trunk/sat-solver/tools/content2solv.c
trunk/sat-solver/tools/helix2solv.c
trunk/sat-solver/tools/mergesolv.c
trunk/sat-solver/tools/patchxml2solv.c
trunk/sat-solver/tools/rpmdb2solv.c
trunk/sat-solver/tools/rpmmd2solv.c
trunk/sat-solver/tools/susetags2solv.c
Modified: trunk/sat-solver/tools/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/CMakeLists.txt?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/CMakeLists.txt (original)
+++ trunk/sat-solver/tools/CMakeLists.txt Mon Feb 11 03:38:58 2008
@@ -4,24 +4,25 @@
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})
@@ -30,7 +31,7 @@
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)
@@ -39,7 +40,7 @@
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)
Added: trunk/sat-solver/tools/common_write.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/common_write.c?rev=8599&view=auto
==============================================================================
--- trunk/sat-solver/tools/common_write.c (added)
+++ trunk/sat-solver/tools/common_write.c Mon Feb 11 03:38:58 2008
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#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;
+}
Added: trunk/sat-solver/tools/common_write.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/common_write.h?rev=8599&view=auto
==============================================================================
--- trunk/sat-solver/tools/common_write.h (added)
+++ trunk/sat-solver/tools/common_write.h Mon Feb 11 03:38:58 2008
@@ -0,0 +1,15 @@
+/*
+ * 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
Modified: trunk/sat-solver/tools/content2solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/content2solv.c?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/content2solv.c (original)
+++ trunk/sat-solver/tools/content2solv.c Mon Feb 11 03:38:58 2008
@@ -15,7 +15,7 @@
#include "pool.h"
#include "repo.h"
#include "repo_content.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
@@ -23,7 +23,7 @@
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;
}
Modified: trunk/sat-solver/tools/helix2solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/helix2solv.c?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/helix2solv.c (original)
+++ trunk/sat-solver/tools/helix2solv.c Mon Feb 11 03:38:58 2008
@@ -23,7 +23,7 @@
#include "pool.h"
#include "repo_helix.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
@@ -31,7 +31,7 @@
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);
}
Modified: trunk/sat-solver/tools/mergesolv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/mergesolv.c?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/mergesolv.c (original)
+++ trunk/sat-solver/tools/mergesolv.c Mon Feb 11 03:38:58 2008
@@ -20,46 +20,7 @@
#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)
@@ -81,8 +42,7 @@
fclose(fp);
}
- create_filter(pool);
- repo_write(repo, stdout, keyfilter, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
return 0;
Modified: trunk/sat-solver/tools/patchxml2solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/patchxml2solv.c?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/patchxml2solv.c (original)
+++ trunk/sat-solver/tools/patchxml2solv.c Mon Feb 11 03:38:58 2008
@@ -15,7 +15,7 @@
#include "pool.h"
#include "repo.h"
#include "repo_patchxml.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
@@ -23,7 +23,7 @@
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);
}
Modified: trunk/sat-solver/tools/rpmdb2solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/rpmdb2solv.c?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/rpmdb2solv.c (original)
+++ trunk/sat-solver/tools/rpmdb2solv.c Mon Feb 11 03:38:58 2008
@@ -21,7 +21,7 @@
#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)
@@ -54,7 +54,7 @@
ref = 0;
}
- repo_write(repo, stdout, 0, 0, 0, 0);
+ tool_write(repo, 0, 0);
pool_free(pool);
exit(0);
Modified: trunk/sat-solver/tools/rpmmd2solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/rpmmd2solv.c?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/rpmmd2solv.c (original)
+++ trunk/sat-solver/tools/rpmmd2solv.c Mon Feb 11 03:38:58 2008
@@ -15,7 +15,7 @@
#include "pool.h"
#include "repo.h"
#include "repo_rpmmd.h"
-#include "repo_write.h"
+#include "common_write.h"
int
main(int argc, char **argv)
@@ -23,7 +23,7 @@
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);
}
Modified: trunk/sat-solver/tools/susetags2solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/susetags2solv.c?rev=8599&r1=8598&r2=8599&view=diff
==============================================================================
--- trunk/sat-solver/tools/susetags2solv.c (original)
+++ trunk/sat-solver/tools/susetags2solv.c Mon Feb 11 03:38:58 2008
@@ -15,73 +15,13 @@
#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--)
@@ -100,29 +40,7 @@
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);
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org