Recognizes if input is ogg or not.
[xiph/unicode.git] / planarity / timer.c
blobd6b0bc862af0af83f73f24e6d420308d2406f28e
1 /*
3 * gPlanarity:
4 * The geeky little puzzle game with a big noodly crunch!
5 *
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <time.h>
28 #include "timer.h"
29 #include "gettext.h"
31 static int paused;
32 static time_t begin_time_add;
33 static time_t begin_time;
34 static char timebuffer[160];
36 time_t get_timer(){
37 if(paused)
38 return begin_time_add;
39 else{
40 time_t ret = time(NULL);
41 return ret - begin_time + begin_time_add;
45 char *get_timer_string(){
46 int ho = get_timer() / 3600;
47 int mi = get_timer() / 60 - ho*60;
48 int se = get_timer() - ho*3600 - mi*60;
50 if(ho){
51 snprintf(timebuffer,160,_("%d:%02d:%02d"),ho,mi,se);
52 }else if (mi){
53 snprintf(timebuffer,160,_("%d:%02d"),mi,se);
54 }else{
55 snprintf(timebuffer,160,_("%d seconds"),se);
58 return timebuffer;
61 void set_timer(time_t off){
62 begin_time_add = off;
63 begin_time = time(NULL);
66 void pause_timer(){
67 begin_time_add = get_timer();
68 paused=1;
71 void unpause_timer(){
72 paused=0;
73 set_timer(begin_time_add);
76 int timer_paused_p(){
77 return paused;