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

« back to all changes in this revision

Viewing changes to src/global/mail_conf_int.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:
79
79
 
80
80
#include <sys_defs.h>
81
81
#include <stdlib.h>
82
 
#include <stdio.h>                      /* sscanf() */
 
82
#include <stdio.h>                      /* BUFSIZ */
 
83
#include <errno.h>
83
84
 
84
85
/* Utility library. */
85
86
 
97
98
static int convert_mail_conf_int(const char *name, int *intval)
98
99
{
99
100
    const char *strval;
100
 
    char    junk;
 
101
    char   *end;
 
102
    long    longval;
101
103
 
102
104
    if ((strval = mail_conf_lookup_eval(name)) != 0) {
103
 
        if (sscanf(strval, "%d%c", intval, &junk) != 1)
 
105
        errno = 0;
 
106
        *intval = longval = strtol(strval, &end, 10);
 
107
        if (*strval == 0 || *end != 0 || errno == ERANGE || longval != *intval)
104
108
            msg_fatal("bad numerical configuration: %s = %s", name, strval);
105
109
        return (1);
106
110
    }
132
136
/* get_mail_conf_int2 - evaluate integer-valued configuration variable */
133
137
 
134
138
int     get_mail_conf_int2(const char *name1, const char *name2, int defval,
135
 
                                int min, int max)
 
139
                                   int min, int max)
136
140
{
137
141
    int     intval;
138
142
    char   *name;
150
154
typedef int (*stupid_indent_int) (void);
151
155
 
152
156
int     get_mail_conf_int_fn(const char *name, stupid_indent_int defval,
153
 
                                  int min, int max)
 
157
                                     int min, int max)
154
158
{
155
159
    int     intval;
156
160
 
176
180
{
177
181
    while (table->name) {
178
182
        table->target[0] = get_mail_conf_int(table->name, table->defval,
179
 
                                          table->min, table->max);
 
183
                                             table->min, table->max);
180
184
        table++;
181
185
    }
182
186
}
187
191
{
188
192
    while (table->name) {
189
193
        table->target[0] = get_mail_conf_int_fn(table->name, table->defval,
190
 
                                             table->min, table->max);
 
194
                                                table->min, table->max);
191
195
        table++;
192
196
    }
193
197
}