File: test_gbs.c

package info (click to toggle)
gbsplay 0.0.93-3
  • links: PTS
  • area: main
  • in suites:
  • size: 488 kB
  • sloc: ansic: 5,581; sh: 861; makefile: 358
file content (50 lines) | stat: -rw-r--r-- 940 bytes parent folder | download | duplicates (2)
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
/*
 * gbsplay is a Gameboy sound player
 *
 * 2011 (C) by Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
 *             Christian Garbs <mitch@cgarbs.de>
 * Licensed under GNU GPL.
 */

#include "common.h"

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>

#include "gbs.h"
#include "util.h"

int main(int argc, char **argv)
{
	struct gbs *gbs;

	i18n_init();
	if (argc < 2) {
		fprintf(stderr, "Usage: %s <outfile>\n", argv[0]);
		exit(1);
	}

	gbs = gbs_open("examples/nightmode.gbs");
	if (gbs == NULL) {
		fprintf(stderr, "%s: gbs_open failed\n", argv[0]);
		exit(2);
	}
	if (!gbs_write(gbs, argv[1], 1)) {
		fprintf(stderr, "%s: gbs_write failed\n", argv[0]);
		unlink(argv[1]);
		exit(3);
	}
	if (!gbs_write(gbs, argv[1], 2)) {
		fprintf(stderr, "%s: gbs_write v2 failed\n", argv[0]);
		unlink(argv[1]);
		exit(4);
	}

	unlink(argv[1]);
	return 0;
}