apt-dump-solver.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* #####################################################################
  4. dummy solver to get quickly a scenario file out of APT
  5. ##################################################################### */
  6. /*}}}*/
  7. // Include Files /*{{{*/
  8. #include <apt-pkg/edsp.h>
  9. #include <config.h>
  10. #include <cstdio>
  11. /*}}}*/
  12. // ShowHelp - Show a help screen /*{{{*/
  13. // ---------------------------------------------------------------------
  14. /* */
  15. bool ShowHelp() {
  16. std::cout <<
  17. PACKAGE " " VERSION " for " COMMON_ARCH " compiled on " __DATE__ " " __TIME__ << std::endl <<
  18. "Usage: apt-dump-resolver\n"
  19. "\n"
  20. "apt-dump-resolver is a dummy solver who just dumps its input to the\n"
  21. "file /tmp/dump.edsp and exists with a proper EDSP error.\n"
  22. "\n"
  23. " This dump has lost Super Cow Powers.\n";
  24. return true;
  25. }
  26. /*}}}*/
  27. int main(int argc,const char *argv[]) /*{{{*/
  28. {
  29. if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1],"-h") == 0 ||
  30. strcmp(argv[1],"-v") == 0 || strcmp(argv[1],"--version") == 0)) {
  31. ShowHelp();
  32. return 0;
  33. }
  34. FILE* input = fdopen(STDIN_FILENO, "r");
  35. FILE* output = fopen("/tmp/dump.edsp", "w");
  36. char buffer[400];
  37. while (fgets(buffer, sizeof(buffer), input) != NULL)
  38. fputs(buffer, output);
  39. fclose(output);
  40. fclose(input);
  41. EDSP::WriteError("I am too dumb, i can just dump!", stdout);
  42. }