annotate src/timeival.c @ 9:31cc8a89cb74
removed tests from configure script
author |
meillo@marmaro.de |
date |
Mon, 27 Oct 2008 16:21:27 +0100 |
parents |
|
children |
26e34ae9a3e3 |
rev |
line source |
meillo@0
|
1 /* MasqMail
|
meillo@0
|
2 Copyright (C) 1999-2002 Oliver Kurth
|
meillo@0
|
3
|
meillo@0
|
4 This program is free software; you can redistribute it and/or modify
|
meillo@0
|
5 it under the terms of the GNU General Public License as published by
|
meillo@0
|
6 the Free Software Foundation; either version 2 of the License, or
|
meillo@0
|
7 (at your option) any later version.
|
meillo@0
|
8
|
meillo@0
|
9 This program is distributed in the hope that it will be useful,
|
meillo@0
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
meillo@0
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
meillo@0
|
12 GNU General Public License for more details.
|
meillo@0
|
13
|
meillo@0
|
14 You should have received a copy of the GNU General Public License
|
meillo@0
|
15 along with this program; if not, write to the Free Software
|
meillo@0
|
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
meillo@0
|
17 */
|
meillo@0
|
18
|
meillo@0
|
19 #include <ctype.h>
|
meillo@0
|
20 #include <glib.h>
|
meillo@0
|
21
|
meillo@0
|
22 #include "masqmail.h"
|
meillo@0
|
23
|
meillo@0
|
24 gint time_interval(gchar *str, gint *pos)
|
meillo@0
|
25 {
|
meillo@0
|
26 gchar buf[16];
|
meillo@0
|
27 gchar *p = str, *q = buf;
|
meillo@0
|
28 gint factor = 1, val;
|
meillo@0
|
29
|
meillo@0
|
30 while(*p && isdigit(*p) && (q < buf+15)){
|
meillo@0
|
31 *(q++) = *(p++);
|
meillo@0
|
32 (*pos)++;
|
meillo@0
|
33 }
|
meillo@0
|
34 (*pos)++;
|
meillo@0
|
35 *q = 0;
|
meillo@0
|
36 val = atoi(buf);
|
meillo@0
|
37
|
meillo@0
|
38 /* fall through: */
|
meillo@0
|
39 switch(*p){
|
meillo@0
|
40 case 'w':
|
meillo@0
|
41 factor *= 7;
|
meillo@0
|
42 case 'd':
|
meillo@0
|
43 factor *= 24;
|
meillo@0
|
44 case 'h':
|
meillo@0
|
45 factor *= 60;
|
meillo@0
|
46 case 'm':
|
meillo@0
|
47 factor *= 60;
|
meillo@0
|
48 case 's':
|
meillo@0
|
49 break;
|
meillo@0
|
50 default:
|
meillo@0
|
51 return -1;
|
meillo@0
|
52 }
|
meillo@0
|
53 return val * factor;
|
meillo@0
|
54 }
|