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