diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2011-05-03 17:27:11 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2011-05-03 17:27:11 +0200 |
commit | 7f4713547665e12e032501228a98586e5add48f7 (patch) | |
tree | 24b7888cbbc24046ae15aa36b410e561db50721c /cmdline/apt-dump-solver.cc | |
parent | ee8c790a660a817417267379bca1a26e7813dfde (diff) |
add a tiny dump solver to quickly output a scenario
Diffstat (limited to 'cmdline/apt-dump-solver.cc')
-rw-r--r-- | cmdline/apt-dump-solver.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cmdline/apt-dump-solver.cc b/cmdline/apt-dump-solver.cc new file mode 100644 index 000000000..5bcfe4f06 --- /dev/null +++ b/cmdline/apt-dump-solver.cc @@ -0,0 +1,50 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ##################################################################### + + dummy solver to get quickly a scenario file out of APT + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include <apt-pkg/edsp.h> + +#include <config.h> + +#include <cstdio> + /*}}}*/ + +// ShowHelp - Show a help screen /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool ShowHelp() { + + std::cout << + PACKAGE " " VERSION " for " COMMON_ARCH " compiled on " __DATE__ " " __TIME__ << std::endl << + "Usage: apt-dump-resolver\n" + "\n" + "apt-dump-resolver is a dummy solver who just dumps its input to the\n" + "file /tmp/dump.edsp and exists with a proper EDSP error.\n" + "\n" + " This dump has lost Super Cow Powers.\n"; + return true; +} + /*}}}*/ +int main(int argc,const char *argv[]) /*{{{*/ +{ + if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1],"-h") == 0 || + strcmp(argv[1],"-v") == 0 || strcmp(argv[1],"--version") == 0)) { + ShowHelp(); + return 0; + } + + FILE* input = fdopen(STDIN_FILENO, "r"); + FILE* output = fopen("/tmp/dump.edsp", "w"); + char buffer[400]; + while (fgets(buffer, sizeof(buffer), input) != NULL) + fputs(buffer, output); + fclose(output); + fclose(input); + + EDSP::WriteError("I am too dumb, i can just dump!", stdout); +} |