summaryrefslogtreecommitdiff
path: root/cmdline/apt-dump-solver.cc
blob: 424764b3c35c5461e9ec3f8bf963f3a91480b0b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// -*- mode: cpp; mode: fold -*-
// Description								/*{{{*/
/* #####################################################################

   dummy solver to get quickly a scenario file out of APT

   ##################################################################### */
									/*}}}*/
// Include Files							/*{{{*/
#include <apt-pkg/edsp.h>

#include <string.h>
#include <unistd.h>
#include <cstdio>
#include <iostream>

#include <config.h>
									/*}}}*/

// ShowHelp - Show a help screen					/*{{{*/
// ---------------------------------------------------------------------
/* */
static bool ShowHelp() {

	std::cout <<
		PACKAGE " " 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;
	}
        // we really don't need anything
        DropPrivs();

	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("ERR_JUST_DUMPING", "I am too dumb, i can just dump!\nPlease use one of my friends instead!", stdout);
}