The abbreviations for Megabytes & Kilobytes "M", "m", "K" and "k"
have all been deprecated in the latest release of vpopmail
and qmailadmin.  You should use all numbers now.  The limits API
doesn't support this (and probably won't due to the database
holding numbers and not strings for these values).

Read the vpopmail README.quotas file and you'll see the string format
for quotas and an explanation.  Its along the lines  ######S,####C
(size & count only, M & K for meg & kilo are gone now).

Just use a number.

Thanks,

Brian

  > On Friday, March 14, 2003, at 11:52  AM, bob ketterhagen wrote:
  > > I have my user quotas set to 10m.
  > > <example>
  > > /home/vpopmail/bin/vmoduser -q 10m [EMAIL PROTECTED]
  > > /home/vpopmail/bin/vuserinfo [EMAIL PROTECTED]
  > > quota:     10m
  > > usage:     61%
  > > </example>
  > >
  > > When I use vuserinfo to check a user, I see what I should see, a 10m
  > > quota. When I log into qmailadmin It shows how much quota the user has
  > > used <example 6.19> but in the field that shows how many meg's their
  > > quota is, I see 0.00 This is the same with all my vpopmail accounts.
  > 
  > This patch for quota_to_megabytes in util.c checks to see if the quota 
  > is in megabytes instead of bytes.  The patch also corrects an error in 
  > quota_to_bytes previously pointed out by [EMAIL PROTECTED]  In 
  > addition to his fix, I use atof instead of atol, allowing for decimal 
  > quotas (e.g., 7.5 MB).  I also looked into his switch from %lf to %f, 
  > and confirmed that %f is for double.
  > 
  > It also adds some useful comments describing each function (at first, I 
  > was confused as to when each was used) and some formatting changes (to 
  > be more consistent with what I've seen in the source so far).  Ken, 
  > please apply to the latest build.
  > 
  > --- qmailadmin-1.0.12/util.c    Fri Jan 24 15:25:31 2003
  > +++ qmailadmin-1.0.12-tc/util.c Sun Mar 16 22:24:11 2003
  > @@ -261,30 +261,39 @@
  >       if (size > 0) {
  >           size = size / 1048576;  // Convert to MBs.
  >       }
  > -    sprintf(tmpbuff, "%-2.2lf", size);
  > +    sprintf(tmpbuff, "%.2f", size);
  >       tmpstr = tmpbuff;
  >       return tmpstr;
  >   }
  > +/* quota_to_bytes: used to convert user entered quota (given in MB)
  > +                   back to bytes for vpasswd file */
  >   int quota_to_bytes(char returnval[], char *quota) {
  >       char *tmpstr;
  >       double tmp;
  > 
  >       if (quota == NULL) { return 1; }
  > -    if (tmp = atol(quota)) { tmp *= 1048576; }
  > +    if (tmp = atof(quota)) {
  > +        tmp *= 1048576;
  > +        sprintf(returnval, "%.0f", tmp);
  > +        return 0;
  > +    }
  >       else { return 1; }
  > -    sprintf(returnval, "%-2.2lf", tmp);
  > -    return 0;
  >   }
  > +/* quota_to_megabytes: used to convert vpasswd representation of quota
  > +                       to number of megabytes. */
  >   int quota_to_megabytes(char returnval[], char *quota) {
  >       char *tmpstr;
  >       double tmp;
  > +    int i;
  > 
  >       if (quota == NULL) { return 1; }
  > -    if (tmp = atol(quota)) {
  > -         if (tmp != 0) { tmp /= 1048576.0; }
  > -    }
  > -    else { return 0; }
  > -    sprintf(returnval, "%-2.2lf", tmp);
  > +    i = strlen(quota);
  > +    if ((quota[i-1] == 'M') || (quota[i-1] == 'm')) {
  > +        tmp = atol(quota);  /* already in megabytes */
  > +    } else if (tmp = atol(quota)) {
  > +        if (tmp != 0) { tmp /= 1048576.0; }
  > +    } else { return 0; }
  > +    sprintf(returnval, "%.2f", tmp);
  >       return 0;
  >   }
  > 
  > --
  > Tom Collins
  > [EMAIL PROTECTED]
  > 
  > 


Reply via email to