~ubuntu-branches/ubuntu/saucy/postfix/saucy

« back to all changes in this revision

Viewing changes to src/global/mail_conf_nint.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2011-02-22 11:20:43 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20110222112043-c34ht219w3ybrilr
Tags: 2.8.0-2
* a little more lintian cleanup
* Fix missing format strings in smtp-sink.c

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
/*      int     max;
41
41
/* DESCRIPTION
42
42
/*      This module implements configuration parameter support
43
 
/*      for integer values. The default value can be a macro
44
 
/*      expression ($name, ${name?value} and ${name:value}).
 
43
/*      for integer values. Unlike mail_conf_int, the default
 
44
/*      is a string, which can be subjected to macro expansion.
45
45
/*
46
46
/*      get_mail_conf_nint() looks up the named entry in the global
47
47
/*      configuration dictionary. The default value is returned
84
84
 
85
85
#include <sys_defs.h>
86
86
#include <stdlib.h>
87
 
#include <stdio.h>                      /* sscanf() */
 
87
#include <stdio.h>                      /* BUFSIZ */
 
88
#include <errno.h>
88
89
 
89
90
/* Utility library. */
90
91
 
102
103
static int convert_mail_conf_nint(const char *name, int *intval)
103
104
{
104
105
    const char *strval;
105
 
    char    junk;
 
106
    char   *end;
 
107
    long    longval;
106
108
 
107
109
    if ((strval = mail_conf_lookup_eval(name)) != 0) {
108
 
        if (sscanf(strval, "%d%c", intval, &junk) != 1)
 
110
        errno = 0;
 
111
        *intval = longval = strtol(strval, &end, 10);
 
112
        if (*strval == 0 || *end != 0 || errno == ERANGE || longval != *intval)
109
113
            msg_fatal("bad numerical configuration: %s = %s", name, strval);
110
114
        return (1);
111
115
    }