1 /*
2 ** Copyright 1998 - 1999 Double Precision, Inc.
3 ** See COPYING for distribution information.
4 */
5
6 #include "comreadtime.h"
7
config_readtime(const char * control,time_t deftime)8 time_t config_readtime(const char *control, time_t deftime)
9 {
10 char *n=config_search(control);
11 char *buf=config_read1l(n);
12 const char *p;
13
14 time_t t, t2;
15
16 free(n);
17 if (!buf)
18 return (deftime);
19
20 p=buf;
21 t=0;
22 while (*p)
23 {
24 if (isspace((int)(char)*p))
25 {
26 p++;
27 continue;
28 }
29
30 t2=0;
31 for (; *p; p++)
32 {
33 if (!isdigit((int)(char)*p)) break;
34 t2 = t2 * 10 + (*p-'0');
35 }
36 while (*p && isspace((int)(char)*p)) p++;
37
38 switch (*p) {
39 case 'm':
40 case 'M':
41 t += t2 * 60;
42 ++p;
43 continue;
44 case 'h':
45 case 'H':
46 t += t2 * 60*60;
47 ++p;
48 continue;
49 case 'd':
50 case 'D':
51 t += t2 * 60*60*24;
52 ++p;
53 continue;
54 case 'w':
55 case 'W':
56 t += t2 * 60*60*24*7;
57 ++p;
58 continue;
59 case '\0':
60 t += t2;
61 break;
62 case 's':
63 case 'S':
64 t += t2;
65 ++p;
66 continue;
67 }
68 break;
69 }
70 free(buf);
71 return (t);
72 }
73
config_time_queuetime()74 time_t config_time_queuetime()
75 {
76 return (config_readtime("queuetime", 7L * 24 * 60 * 60 ));
77 }
78
config_time_faxqueuetime()79 time_t config_time_faxqueuetime()
80 {
81 return (config_readtime("faxqueuetime", 8 * 60 * 60 ));
82 }
83
config_time_warntime()84 time_t config_time_warntime()
85 {
86 return (config_readtime("warntime", 4L * 60 * 60));
87 }
88
config_time_respawnlo()89 time_t config_time_respawnlo()
90 {
91 return (config_readtime("respawnlo", 60 * 60));
92 }
93
config_time_respawnhi()94 time_t config_time_respawnhi()
95 {
96 return (config_readtime("respawnhi", 7L * 24 * 60 * 60 ));
97 }
98
config_time_retryalpha()99 time_t config_time_retryalpha()
100 {
101 return (config_readtime("retryalpha", 60 * 5));
102 }
103
config_time_retrygamma()104 time_t config_time_retrygamma()
105 {
106 return (config_readtime("retrygamma", 60 * 15));
107 }
108
config_time_submitdelay()109 time_t config_time_submitdelay()
110 {
111 return (config_readtime("submitdelay", 0));
112 }
113
config_time_queuefill()114 time_t config_time_queuefill()
115 {
116 return (config_readtime("queuefill", 5 * 60));
117 }
118