summaryrefslogtreecommitdiff
path: root/src/bin/main.c
blob: f4118626d43590c7d9080223b6535c57ad989ffa (plain) (blame)
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
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <aplwc.h>

#if ENABLE_NLS
#include <libintl.h>
#define _(S) dgettext(PACKAGE, S)
#else
#define _(S) S
#endif

static void
version(void)
{
	printf(_(PACKAGE " version %s\n"), PACKAGE_VERSION);
	exit(EXIT_SUCCESS);
}

static void
usage(void)
{
	puts(_("There is no usage text yet."));
	exit(EXIT_SUCCESS);
}

int
main(int argc, char *argv[])
{
	APLWCFunctions fns;
	APLWC *aplwc;

	aplwc_boot();

	for(int i = 1; i < argc; i++){
		if(strcmp(argv[i], "--version") == 0)
			version();
		else if(strcmp(argv[i], "--help") == 0)
			usage();
		else
			break;
	}
	if(argc > 1){
		printf(_("Unknown command-line argument: '%s'\n"), argv[1]);
		exit(EXIT_FAILURE);
	}

	aplwc_init_fns(&fns);
	aplwc = aplwc_init(&fns, NULL);
	aplwc_exit(aplwc);
	return 0;
}