File: main.c

package info (click to toggle)
s3d 0.2.1.1-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 5,256 kB
  • ctags: 2,684
  • sloc: ansic: 20,585; perl: 98; makefile: 32; python: 8; sh: 4
file content (73 lines) | stat: -rw-r--r-- 1,829 bytes parent folder | download
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
72
73
/*
 * main.c
 *
 * Copyright (C) 2006-2008 Simon Wunderlich <dotslash@packetmixer.de>
 *
 * This file is part of s3dosm, a gps card application for s3d.
 * See http://s3d.berlios.de/ for more updates.
 *
 * s3dosm is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * s3dosm is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with s3dosm; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */


#include <stdio.h>   /*  snprintf(), printf(), NULL */
#include <s3d.h>
#include <s3dw.h>
#include "s3dosm.h"
#include <time.h>  /*  nanosleep(), struct tm, time_t...  */
static int ready = 0;

void mainloop(void)
{
	struct timespec t = {
		0, 100*1000*1000
	}; /* 100 mili seconds */
	if (ready) {
		nanosleep(&t, NULL);
		gps_main();
		nav_main();
		s3dw_ani_mate();
	}
}
static int init(int argc, char **argv)
{
	s3d_select_font("vera");
	ui_init();
	if (db_init(":memory:")) return(-1);
	if (db_create()) return(-1);
	if (process_args(argc, argv)) return(-1);
	nav_init();
	nav_autocenter();
	draw_all_layers();
	gps_init("localhost");
	ready = 1;
	return(0);
}
static int quit(void)
{
	ready = 0;
	gps_quit();
	s3d_quit();
	db_quit();
	return(0);
}
int main(int argc, char **argv)
{
	if (!s3d_init(&argc, &argv, "s3dosm")) {
		if (!init(argc, argv)) s3d_mainloop(mainloop);
		quit();
	} else return(-1);
	return(0);
}