summaryrefslogtreecommitdiff
path: root/cmdline/apt-dump-solver.cc
blob: 5bcfe4f0614098e705086dd082a90c22cb17052b (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
// -*- 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);
}