From 51531a6f1dafafe9444ff418a93bb97818888852 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Thu, 20 Mar 2008 13:43:57 +0000 Subject: [PATCH] - clean up a bit --- tools/CMakeLists.txt | 7 --- tools/addstore.c | 57 ----------------- tools/dumpattr.c | 168 --------------------------------------------------- 3 files changed, 232 deletions(-) delete mode 100644 tools/addstore.c delete mode 100644 tools/dumpattr.c diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index d8027ad..ad97b1c 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -38,13 +38,6 @@ SET(mergesolv_REPOS mergesolv.c repo_write.c common_write.c) ADD_EXECUTABLE( mergesolv ${mergesolv_REPOS} ) TARGET_LINK_LIBRARIES( mergesolv satsolver) -#SET(dumpattr_REPOS dumpattr.c) -#ADD_EXECUTABLE( dumpattr ${dumpattr_REPOS} ) -#TARGET_LINK_LIBRARIES( dumpattr satsolver) - -#ADD_EXECUTABLE( addstore addstore.c repo_write.c ) -#TARGET_LINK_LIBRARIES( addstore satsolver ) - install(TARGETS mergesolv dumpsolv diff --git a/tools/addstore.c b/tools/addstore.c deleted file mode 100644 index 22d09bd..0000000 --- a/tools/addstore.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2007, Novell Inc. - * - * This program is licensed under the BSD license, read LICENSE.BSD - * for further information - */ - -#include -#include -#include -#include - -#include "pool.h" -#include "repo_solv.h" -#include "repo_write.h" -#include "attr_store.h" -#include "attr_store_p.h" - -int -main(int argc, char **argv) -{ - Repo *repo; - Pool *pool; - int i; - FILE *fp; - - if (argc == 1) - { - printf ("%s repo.solv one.attr [more.attr ...] > out.solv\n", argv[0]); - exit (1); - } - if ((fp = fopen (argv[1], "r")) == 0) - { - perror (argv[1]); - exit (1); - } - pool = pool_create (); - repo = repo_create (pool, argv[1]); - repo_add_solv (repo, fp); - fclose (fp); - for (i = 2; i < argc; i++) - { - if ((fp = fopen (argv[i], "r")) == 0) - { - perror (argv[1]); - exit (1); - } - Attrstore *s = attr_store_read (fp, pool); - fclose (fp); - /* XXX We should probably use the basename here. - And calculate the SHA1 sum of the file and store it. */ - repo_add_attrstore (repo, s, argv[i]); - } - repo_write(repo, stdout); - pool_free(pool); - exit(0); -} diff --git a/tools/dumpattr.c b/tools/dumpattr.c deleted file mode 100644 index 19b3ab9..0000000 --- a/tools/dumpattr.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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 -#include - -#include "attr_store.h" -#include "pool.h" -#include "attr_store_p.h" - -static Id id_diskusage; - -static void -dump_diskusage (Attrstore *s, const unsigned char *numlist) -{ - char sbuf[1024]; - char *buf = sbuf; - unsigned slen = sizeof (sbuf); - fprintf (stdout, "DU\n"); - while (1) - { - unsigned dirid, filesz, filenum; - int val; - get_num (numlist, val); - dirid = (val & 63) | ((val >> 1) & ~63); - if (!(val & 64)) - break; - get_num (numlist, val); - filesz = (val & 63) | ((val >> 1) & ~63); - if (!(val & 64)) - break; - get_num (numlist, val); - filenum = (val & 63) | ((val >> 1) & ~63); - dir2str (s, dirid, &buf, &slen); - fprintf (stdout, " %s %d %d %d\n", buf, dirid, filesz, filenum); - if (!(val & 64)) - break; - } - if (buf != sbuf) - free (buf); -} - -static void -dump_attrs (Attrstore *s, unsigned int entry) -{ - attr_iterator ai; - FOR_ATTRS (s, entry, &ai) - { - fprintf (stdout, "%s:", id2str (s->pool, ai.name)); - switch (ai.type) - { - case TYPE_VOID: - fprintf (stdout, "spec %d\n", ai.as_int); - break; - case TYPE_ATTR_INT: - fprintf (stdout, "int %u\n", ai.as_int); - break; - case TYPE_ATTR_CHUNK: - { - const char *str = attr_retrieve_blob (s, ai.as_chunk[0], ai.as_chunk[1]); - if (str) - fprintf (stdout, "blob %s\n", str); - else - fprintf (stdout, "blob %u+%u\n", ai.as_chunk[0], ai.as_chunk[1]); - } - break; - case TYPE_ATTR_STRING: - fprintf (stdout, "str %s\n", ai.as_string); - break; - case TYPE_ATTR_INTLIST: - if (ai.name == id_diskusage) - dump_diskusage (s, ai.as_numlist); - else - { - fprintf (stdout, "lint\n "); - while (1) - { - int val; - get_num (ai.as_numlist, val); - fprintf (stdout, " %d", (val & 63) | ((val >> 1) & ~63)); - if (!(val & 64)) - break; - } - fprintf (stdout, "\n"); - } - break; - case TYPE_ATTR_LOCALIDS: - { - fprintf (stdout, "lids"); - while (1) - { - Id val; - get_num (ai.as_numlist, val); - if (!val) - break; - fprintf (stdout, "\n %s(%d)", localid2str (s, val), val); - } - fprintf (stdout, "\n"); - break; - } - default: - break; - } - } -} - -static int -callback (Attrstore *s, unsigned entry, Id name, const char *str) -{ - fprintf (stdout, "%d:%s:%s\n", entry, id2str (s->pool, name), str); - return 1; -} - -int -main (int argc, char *argv[]) -{ - unsigned int i; - Pool *pool = pool_create (); - Attrstore *s = attr_store_read (stdin, pool); - id_diskusage = str2id (pool, "diskusage", 0); - /* For now test the packing code. */ - attr_store_unpack (s); - attr_store_pack (s); - fprintf (stdout, "attribute store contains %d entities\n", s->entries); - if (argc == 1) - for (i = 0; i < s->entries; i++) - { - fprintf (stdout, "\nentity %u:\n", i); - dump_attrs (s, i); - } - else - { - int g; - unsigned flags; - unsigned search_type; - Id name; - name = 0; - flags = SEARCH_IDS; - search_type = SEARCH_SUBSTRING; - while ((g = getopt (argc, argv, "-n:bgeri")) >= 0) - switch (g) - { - case 'n': name = str2id (s->pool, optarg, 1); break; - case 'b': flags |= SEARCH_BLOBS; break; - case 'g': search_type = SEARCH_GLOB; break; - case 'e': search_type = SEARCH_STRING; break; - case 'r': search_type = SEARCH_REGEX; break; - case 'i': flags |= SEARCH_NOCASE; break; - case 1: - attr_store_search_s (s, optarg, search_type | flags, name, callback); - flags = SEARCH_IDS; - name = 0; - search_type = SEARCH_SUBSTRING; - break; - } - } - return 0; -} -- 2.7.4