apt-dump-solver.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #include <iostream>
  12. /*}}}*/
  13. // ShowHelp - Show a help screen /*{{{*/
  14. // ---------------------------------------------------------------------
  15. /* */
  16. bool ShowHelp() {
  17. std::cout <<
  18. PACKAGE " " PACKAGE_VERSION " for " COMMON_ARCH " compiled on " __DATE__ " " __TIME__ << std::endl <<
  19. "Usage: apt-dump-resolver\n"
  20. "\n"
  21. "apt-dump-resolver is a dummy solver who just dumps its input to the\n"
  22. "file /tmp/dump.edsp and exists with a proper EDSP error.\n"
  23. "\n"
  24. " This dump has lost Super Cow Powers.\n";
  25. return true;
  26. }
  27. /*}}}*/
  28. int main(int argc,const char *argv[]) /*{{{*/
  29. {
  30. if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1],"-h") == 0 ||
  31. strcmp(argv[1],"-v") == 0 || strcmp(argv[1],"--version") == 0)) {
  32. ShowHelp();
  33. return 0;
  34. }
  35. FILE* input = fdopen(STDIN_FILENO, "r");
  36. FILE* output = fopen("/tmp/dump.edsp", "w");
  37. char buffer[400];
  38. while (fgets(buffer, sizeof(buffer), input) != NULL)
  39. fputs(buffer, output);
  40. fclose(output);
  41. fclose(input);
  42. EDSP::WriteError("ERR_JUST_DUMPING", "I am too dumb, i can just dump!\nPlease use one of my friends instead!", stdout);
  43. }