garten

diff weather.c @ 12:8db6497d6065

merged everything to only one program
author meillo@marmaro.de
date Wed, 23 Jul 2008 15:19:45 +0200
parents 176ee28e7464
children 5e6c9260913a
line diff
     1.1 --- a/weather.c	Wed Jul 23 11:41:38 2008 +0200
     1.2 +++ b/weather.c	Wed Jul 23 15:19:45 2008 +0200
     1.3 @@ -1,7 +1,6 @@
     1.4  #include <stdio.h>
     1.5  #include <stdlib.h>
     1.6  #include <time.h>
     1.7 -
     1.8  #include "db.h"
     1.9  #include "game.h"
    1.10  
    1.11 @@ -88,41 +87,18 @@
    1.12  			" (tick, temp, sun, rain, wind, hum) "
    1.13  			" values ('%d', '%f', '%f', '%f', '%f', '%f') "
    1.14  			, gametime, w->temp, w->sun, w->rain, w->wind, w->hum);
    1.15 -	db_query(query);
    1.16 -	puts(query);
    1.17 -	if (sqlite3_step(stmt) == SQLITE_DONE) {
    1.18 -		printf("weather successful inserted\n");
    1.19 -	} else {
    1.20 +	/* puts(query); */
    1.21 +	if (!db_update(query)) {
    1.22  		printf("error: weather insertion failed: %s\n", sqlite3_errmsg(db));
    1.23  	}
    1.24  }
    1.25  
    1.26  
    1.27 -int main(int argc, char* argv[]) {
    1.28 -	printf("  --> weather\n");
    1.29 -
    1.30 -	/* init */
    1.31 -	if (argc != 2) {
    1.32 -		printf("usage: %s <database>\n", argv[0]);
    1.33 -		exit(1);
    1.34 -	}
    1.35 -	database = argv[1];
    1.36 -
    1.37 -	db_connect();
    1.38 -	read_time();
    1.39 -
    1.40 -	srand((unsigned int) time(NULL));
    1.41 -
    1.42 -
    1.43 +void weather(void) {
    1.44  	struct weather w;
    1.45  	struct weather lastn[Nlast];
    1.46  
    1.47  	getlastweather(lastn, Nlast);
    1.48  	genweather(&w, lastn, Nlast, May);
    1.49  	setweather(&w);
    1.50 -
    1.51 -	db_close();
    1.52 -
    1.53 -	printf("  --< weather\n");
    1.54 -	return 0;
    1.55  }