aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: 1a5f47ba06afa79c1932e83a2ea83a4a2c2796bc (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* https://github.com/grizzlybearington/steam-montage
 * See LICENSE file for copyright & license details.
 *
 * Most information can be found in the README.
 */
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

#include "api.h"
#include "command.h"
#include "config.h"
#include "image.h"
#include "steammontage.h"
#include "version.h"
#include "whereami/whereami.h"

int
main (int argc, char *argv[])
{
	int exit_code = 0;
	runningdir runningdir;

	printf("steammontage %s - "
		"https://github.com/grizzlybearington/steammontage\n\n", SM_VERSION);

	struct options opts = {
		.cfg = CONFIG_DEFAULTS,
		.help = 0,
		.version = 0,
	};

	if (!parse_args(&opts, argc, argv)) {
		print_cli_failure(argv[0]);
		return exit_code;
	}

	if (opts.help) {
		print_help(argv[0]);
		return 1;
	}

	if (opts.version) {
		return 1;
	}

	if (get_running_dir(&runningdir) < 0) {
		goto end;
	}

	if (parse_config(runningdir.dirpath, &opts.cfg) < 0) {
		goto end;
	}

	if (validate_input(&opts.cfg) < 0) {
		goto end;
	}

	init_curl();

	if (create_montage(&opts.cfg, runningdir) < 0) {
		goto end;
	}
	exit_code = 1;
	printf("Job's done!\n");

end:
	free_curl();
	free(runningdir.dirpath);
	return exit_code;
}
(git 2.53.0) at 2026-05-13 17:20:10 +0000