~ubuntu-branches/ubuntu/karmic/postfix/karmic-security

« back to all changes in this revision

Viewing changes to src/global/mail_conf_str.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2008-09-07 14:02:15 UTC
  • mfrom: (29.1.21 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080907140215-d9zf8bj803ditke5
Tags: 2.5.5-1.1
* Non-maintainer upload.
* Add rsyslog.d config snipped to create a /dev/log syslog socket in the
  postfix chroot.  Also, add a note about other syslog daemons to
  README.Debian.  Closes: #311812

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
/*      const char *value;
24
24
/*
25
25
/*      void    get_mail_conf_str_table(table)
26
 
/*      CONFIG_STR_TABLE *table;
 
26
/*      const CONFIG_STR_TABLE *table;
27
27
/*
28
28
/*      void    get_mail_conf_str_fn_table(table)
29
 
/*      CONFIG_STR_TABLE *table;
 
29
/*      const CONFIG_STR_TABLE *table;
 
30
/* AUXILIARY FUNCTIONS
 
31
/*      char    *get_mail_conf_str2(name, suffix, defval, min, max)
 
32
/*      const char *name;
 
33
/*      const char *suffix;
 
34
/*      const char *defval;
 
35
/*      int     min;
 
36
/*      int     max;
30
37
/* DESCRIPTION
31
38
/*      This module implements support for string-valued global
32
39
/*      configuration parameters.
49
56
/*      get_mail_conf_str_table() and get_mail_conf_str_fn_table() read
50
57
/*      lists of variables, as directed by their table arguments. A table
51
58
/*      must be terminated by a null entry.
 
59
/*
 
60
/*      get_mail_conf_str2() concatenates the two names and is otherwise
 
61
/*      identical to get_mail_conf_str().
52
62
/* DIAGNOSTICS
53
63
/*      Fatal errors: bad string length.
54
64
/* SEE ALSO
74
84
 
75
85
#include <msg.h>
76
86
#include <mymalloc.h>
 
87
#include <stringops.h>
77
88
 
78
89
/* Global library. */
79
90
 
82
93
/* check_mail_conf_str - validate string length */
83
94
 
84
95
static void check_mail_conf_str(const char *name, const char *strval,
85
 
                                     int min, int max)
 
96
                                        int min, int max)
86
97
{
87
98
    ssize_t len = strlen(strval);
88
99
 
97
108
/* get_mail_conf_str - evaluate string-valued configuration variable */
98
109
 
99
110
char   *get_mail_conf_str(const char *name, const char *defval,
100
 
                               int min, int max)
101
 
{
102
 
    const char *strval;
103
 
 
104
 
    if ((strval = mail_conf_lookup_eval(name)) == 0) {
105
 
        strval = mail_conf_eval(defval);
106
 
        mail_conf_update(name, strval);
107
 
    }
108
 
    check_mail_conf_str(name, strval, min, max);
 
111
                                  int min, int max)
 
112
{
 
113
    const char *strval;
 
114
 
 
115
    if ((strval = mail_conf_lookup_eval(name)) == 0) {
 
116
        strval = mail_conf_eval(defval);
 
117
        mail_conf_update(name, strval);
 
118
    }
 
119
    check_mail_conf_str(name, strval, min, max);
 
120
    return (mystrdup(strval));
 
121
}
 
122
 
 
123
/* get_mail_conf_str2 - evaluate string-valued configuration variable */
 
124
 
 
125
char   *get_mail_conf_str2(const char *name1, const char *name2,
 
126
                                   const char *defval,
 
127
                                   int min, int max)
 
128
{
 
129
    const char *strval;
 
130
    char   *name;
 
131
 
 
132
    name = concatenate(name1, name2, (char *) 0);
 
133
    if ((strval = mail_conf_lookup_eval(name)) == 0) {
 
134
        strval = mail_conf_eval(defval);
 
135
        mail_conf_update(name, strval);
 
136
    }
 
137
    check_mail_conf_str(name, strval, min, max);
 
138
    myfree(name);
109
139
    return (mystrdup(strval));
110
140
}
111
141
 
114
144
typedef const char *(*stupid_indent_str) (void);
115
145
 
116
146
char   *get_mail_conf_str_fn(const char *name, stupid_indent_str defval,
117
 
                                  int min, int max)
 
147
                                     int min, int max)
118
148
{
119
149
    const char *strval;
120
150
 
135
165
 
136
166
/* get_mail_conf_str_table - look up table of strings */
137
167
 
138
 
void    get_mail_conf_str_table(CONFIG_STR_TABLE *table)
 
168
void    get_mail_conf_str_table(const CONFIG_STR_TABLE *table)
139
169
{
140
170
    while (table->name) {
141
171
        if (table->target[0])
142
172
            myfree(table->target[0]);
143
173
        table->target[0] = get_mail_conf_str(table->name, table->defval,
144
 
                                          table->min, table->max);
 
174
                                             table->min, table->max);
145
175
        table++;
146
176
    }
147
177
}
148
178
 
149
179
/* get_mail_conf_str_fn_table - look up strings, defaults are functions */
150
180
 
151
 
void    get_mail_conf_str_fn_table(CONFIG_STR_FN_TABLE *table)
 
181
void    get_mail_conf_str_fn_table(const CONFIG_STR_FN_TABLE *table)
152
182
{
153
183
    while (table->name) {
154
184
        if (table->target[0])
155
185
            myfree(table->target[0]);
156
186
        table->target[0] = get_mail_conf_str_fn(table->name, table->defval,
157
 
                                             table->min, table->max);
 
187
                                                table->min, table->max);
158
188
        table++;
159
189
    }
160
190
}