]>
Commit | Line | Data |
---|---|---|
7f471354 DK |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
3 | /* ##################################################################### | |
4 | ||
5 | dummy solver to get quickly a scenario file out of APT | |
6 | ||
7 | ##################################################################### */ | |
8 | /*}}}*/ | |
9 | // Include Files /*{{{*/ | |
10 | #include <apt-pkg/edsp.h> | |
11 | ||
453b82a3 DK |
12 | #include <string.h> |
13 | #include <unistd.h> | |
7f471354 | 14 | #include <cstdio> |
472ff00e | 15 | #include <iostream> |
453b82a3 DK |
16 | |
17 | #include <config.h> | |
7f471354 DK |
18 | /*}}}*/ |
19 | ||
20 | // ShowHelp - Show a help screen /*{{{*/ | |
21 | // --------------------------------------------------------------------- | |
22 | /* */ | |
c3ccac92 | 23 | static bool ShowHelp() { |
7f471354 DK |
24 | |
25 | std::cout << | |
9179f697 | 26 | PACKAGE " " PACKAGE_VERSION " for " COMMON_ARCH " compiled on " __DATE__ " " __TIME__ << std::endl << |
7f471354 DK |
27 | "Usage: apt-dump-resolver\n" |
28 | "\n" | |
29 | "apt-dump-resolver is a dummy solver who just dumps its input to the\n" | |
30 | "file /tmp/dump.edsp and exists with a proper EDSP error.\n" | |
31 | "\n" | |
32 | " This dump has lost Super Cow Powers.\n"; | |
33 | return true; | |
34 | } | |
35 | /*}}}*/ | |
36 | int main(int argc,const char *argv[]) /*{{{*/ | |
37 | { | |
38 | if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1],"-h") == 0 || | |
39 | strcmp(argv[1],"-v") == 0 || strcmp(argv[1],"--version") == 0)) { | |
40 | ShowHelp(); | |
41 | return 0; | |
42 | } | |
fc1a78d8 MV |
43 | // we really don't need anything |
44 | DropPrivs(); | |
7f471354 DK |
45 | |
46 | FILE* input = fdopen(STDIN_FILENO, "r"); | |
47 | FILE* output = fopen("/tmp/dump.edsp", "w"); | |
48 | char buffer[400]; | |
49 | while (fgets(buffer, sizeof(buffer), input) != NULL) | |
50 | fputs(buffer, output); | |
51 | fclose(output); | |
52 | fclose(input); | |
53 | ||
ebfeeaed | 54 | EDSP::WriteError("ERR_JUST_DUMPING", "I am too dumb, i can just dump!\nPlease use one of my friends instead!", stdout); |
7f471354 | 55 | } |