Re: [EXIM] Exim imposed quotas

Top Page
Delete this message
Reply to this message
Author: Jeffrey Goldberg
Date:  
To: zilbauer
CC: exim-users
Subject: Re: [EXIM] Exim imposed quotas
On Sun, 13 Sep 1998, Robert Zilbauer wrote:

> I've added some more debugging statements to the code segment that was
> specified as follows:
>
> DEBUG(9) debug_printf("incoming quota string == %s\n", s);
> d = strtod(s, &rest);
> DEBUG(9) debug_printf("beginning quota value == %f\n", d);
> if (tolower(*rest) == 'k') { d *= 1024.0; rest++; }
> if (tolower(*rest) == 'm') { d *= 1024.0*1024.0; rest++; }
> while (isspace(*rest)) rest++;
> DEBUG(9) debug_printf("calculated quota value == %f\n", d);
>
> ....
>
> ob->quota_value = (int)d;
> DEBUG(9) debug_printf("returned quota value == %d\n", ob->quota_value);
> return OK;
>
> On my system (SunOS 4.1.4 running Exim 2.02), those 4 statements produce the
> following:
>
> incoming quota string == 20k
> beginning quota value == 559120.000000
> calculated quota value == 572538880.000000
> returned quota value == 572538880
>
> Unfortunately, my knowledge of C is far too rusty to understand why. As
> always, any suggestions would be most welcome.


That seems bizzare. A test of strtod() might be in order. Attached is
a small program for running strtod.

-j

--
Jeffrey Goldberg                +44 (0)1234 750 111 x 2826
 Cranfield Computer Centre      FAX         751 814
 J.Goldberg@???     http://WWW.Cranfield.ac.uk/public/cc/cc047/
Relativism is the triumph of authority over truth, convention over justice.

/* A simple test of strtod */

#include <stdlib.h>
#include <stdio.h>

main(void)
{
   double d;
   char line[128];
   char *rest;

   while((fgets(line, 128, stdin)) != NULL) {
     printf("String retrived (%s)\n", line);
     d = strtod(line, &rest);
     printf("d == %lf\n", d);
     printf("rest is (%s)\n", rest);
   }
   exit (0);
}