Back to index

courier  0.68.2
comreadtime.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 1999 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #include      "comreadtime.h"
00007 
00008 time_t config_readtime(const char *control, time_t deftime)
00009 {
00010 char   *n=config_localfilename(control);
00011 char   *buf=config_read1l(n);
00012 const char *p;
00013 
00014 time_t t, t2;
00015 
00016        free(n);
00017        if (!buf)
00018               return (deftime);
00019 
00020        p=buf;
00021        t=0;
00022        while (*p)
00023        {
00024               if (isspace((int)(char)*p))
00025               {
00026                      p++;
00027                      continue;
00028               }
00029 
00030               t2=0;
00031               for (; *p; p++)
00032               {
00033                      if (!isdigit((int)(char)*p))       break;
00034                      t2 = t2 * 10 + (*p-'0');
00035               }
00036               while (*p && isspace((int)(char)*p))      p++;
00037 
00038               switch (*p)   {
00039               case 'm':
00040               case 'M':
00041                      t += t2 * 60;
00042                      ++p;
00043                      continue;
00044               case 'h':
00045               case 'H':
00046                      t += t2 * 60*60;
00047                      ++p;
00048                      continue;
00049               case 'd':
00050               case 'D':
00051                      t += t2 * 60*60*24;
00052                      ++p;
00053                      continue;
00054               case 'w':
00055               case 'W':
00056                      t += t2 * 60*60*24*7;
00057                      ++p;
00058                      continue;
00059               case '\0':
00060                      t += t2;
00061                      break;
00062               case 's':
00063               case 'S':
00064                      t += t2;
00065                      ++p;
00066                      continue;
00067               }
00068               break;
00069        }
00070        free(buf);
00071        return (t);
00072 }
00073 
00074 time_t config_time_queuetime()
00075 {
00076        return (config_readtime("queuetime", 7L * 24 * 60 * 60 ));
00077 }
00078 
00079 time_t config_time_faxqueuetime()
00080 {
00081        return (config_readtime("faxqueuetime", 8 * 60 * 60 ));
00082 }
00083 
00084 time_t config_time_warntime()
00085 {
00086        return (config_readtime("warntime", 4L * 60 * 60));
00087 }
00088 
00089 time_t config_time_respawnlo()
00090 {
00091        return (config_readtime("respawnlo", 60 * 60));
00092 }
00093 
00094 time_t config_time_respawnhi()
00095 {
00096        return (config_readtime("respawnhi", 7L * 24 * 60 * 60 ));
00097 }
00098 
00099 time_t config_time_retryalpha()
00100 {
00101        return (config_readtime("retryalpha", 60 * 5));
00102 }
00103 
00104 time_t config_time_retrygamma()
00105 {
00106        return (config_readtime("retrygamma", 60 * 15));
00107 }
00108 
00109 time_t config_time_submitdelay()
00110 {
00111        return (config_readtime("submitdelay", 0));
00112 }
00113 
00114 time_t config_time_queuefill()
00115 {
00116        return (config_readtime("queuefill", 5 * 60));
00117 }