~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/cf_gen.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
1
/*
3
 
 * $Id: cf_gen.cc,v 1.62 2007/09/17 20:21:23 hno Exp $
4
 
 *
5
2
 * DEBUG: none          Generate squid.conf.default and cf_parser.h
6
3
 * AUTHOR: Max Okumoto
7
4
 *
21
18
 *  it under the terms of the GNU General Public License as published by
22
19
 *  the Free Software Foundation; either version 2 of the License, or
23
20
 *  (at your option) any later version.
24
 
 *  
 
21
 *
25
22
 *  This program is distributed in the hope that it will be useful,
26
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
27
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
25
 *  GNU General Public License for more details.
29
 
 *  
 
26
 *
30
27
 *  You should have received a copy of the GNU General Public License
31
28
 *  along with this program; if not, write to the Free Software
32
29
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
48
45
 *                       administrator.
49
46
 *****************************************************************************/
50
47
 
51
 
#include "squid.h"
52
 
#include "SquidTime.h"
 
48
//#include "squid.h"
 
49
#include "config.h"
 
50
//#include "SquidTime.h"
53
51
#include "cf_gen_defines.h"
 
52
#include "util.h"
 
53
 
 
54
#if HAVE_STRING_H
 
55
#include <string.h>
 
56
#endif
 
57
#if HAVE_STRING_H
 
58
#include <ctype.h>
 
59
#endif
54
60
 
55
61
#define MAX_LINE        1024    /* longest configuration line */
56
62
#define _PATH_PARSER            "cf_parser.h"
57
 
#define _PATH_SQUID_CONF        "squid.conf.default"
 
63
#define _PATH_SQUID_CONF        "squid.conf.documented"
58
64
#define _PATH_CF_DEPEND         "cf.data.depend"
59
65
 
60
66
enum State {
65
71
    sEXIT
66
72
};
67
73
 
68
 
typedef struct Line
69
 
{
 
74
typedef struct Line {
70
75
    char *data;
71
76
 
72
77
    struct Line *next;
73
 
}
74
 
 
75
 
Line;
76
 
 
77
 
typedef struct EntryAlias
78
 
{
 
78
} Line;
 
79
 
 
80
typedef struct EntryAlias {
79
81
 
80
82
    struct EntryAlias *next;
81
83
    char *name;
82
 
}
83
 
 
84
 
EntryAlias;
85
 
 
86
 
typedef struct Entry
87
 
{
 
84
} EntryAlias;
 
85
 
 
86
typedef struct Entry {
88
87
    char *name;
89
88
    EntryAlias *alias;
90
89
    char *type;
98
97
    int array_flag;
99
98
 
100
99
    struct Entry *next;
101
 
}
102
 
 
103
 
Entry;
104
 
 
105
 
typedef struct TypeDep
106
 
{
 
100
} Entry;
 
101
 
 
102
typedef struct TypeDep {
107
103
    char *name;
108
104
 
109
105
    TypeDep *next;
110
106
} TypeDep;
111
107
 
112
 
typedef struct Type
113
 
{
 
108
typedef struct Type {
114
109
    char *name;
115
110
    TypeDep *depend;
116
111
 
144
139
{
145
140
    const Type *type;
146
141
    for (type = types; type; type = type->next) {
147
 
        const TypeDep *dep;
148
 
        if (strcmp(type->name, name) != 0)
149
 
            continue;
150
 
        for (dep = type->depend; dep; dep = dep->next) {
151
 
            const Entry *entry;
152
 
            for (entry = entries; entry; entry = entry->next) {
153
 
                if (strcmp(entry->name, dep->name) == 0)
154
 
                    break;
155
 
            }
156
 
            if (!entry) {
157
 
                fprintf(stderr, "ERROR: '%s' (%s) depends on '%s'\n", directive, name, dep->name);
158
 
                exit(1);
159
 
            }
160
 
        }
161
 
        return;
 
142
        const TypeDep *dep;
 
143
        if (strcmp(type->name, name) != 0)
 
144
            continue;
 
145
        for (dep = type->depend; dep; dep = dep->next) {
 
146
            const Entry *entry;
 
147
            for (entry = entries; entry; entry = entry->next) {
 
148
                if (strcmp(entry->name, dep->name) == 0)
 
149
                    break;
 
150
            }
 
151
            if (!entry) {
 
152
                fprintf(stderr, "ERROR: '%s' (%s) depends on '%s'\n", directive, name, dep->name);
 
153
                exit(1);
 
154
            }
 
155
        }
 
156
        return;
162
157
    }
163
158
    fprintf(stderr, "ERROR: Dependencies for cf.data type '%s' used in '%s' not defined\n", name, directive);
164
159
    exit(1);
198
193
    }
199
194
 
200
195
    while ((NULL != fgets(buff, MAX_LINE, fp))) {
201
 
        const char *type = strtok(buff, WS);
202
 
        const char *dep;
203
 
        if (!type || type[0] == '#')
204
 
            continue;
205
 
        Type *t = (Type *)xcalloc(1, sizeof(*t));
206
 
        t->name = xstrdup(type);
207
 
        while ((dep = strtok(NULL, WS)) != NULL) {
208
 
            TypeDep *d = (TypeDep *)xcalloc(1, sizeof(*d));
209
 
            d->name = xstrdup(dep);
210
 
            d->next = t->depend;
211
 
            t->depend = d;
212
 
        }
213
 
        t->next = types;
214
 
        types = t;
 
196
        const char *type = strtok(buff, WS);
 
197
        const char *dep;
 
198
        if (!type || type[0] == '#')
 
199
            continue;
 
200
        Type *t = (Type *)xcalloc(1, sizeof(*t));
 
201
        t->name = xstrdup(type);
 
202
        while ((dep = strtok(NULL, WS)) != NULL) {
 
203
            TypeDep *d = (TypeDep *)xcalloc(1, sizeof(*d));
 
204
            d->name = xstrdup(dep);
 
205
            d->next = t->depend;
 
206
            t->depend = d;
 
207
        }
 
208
        t->next = types;
 
209
        types = t;
215
210
    }
216
211
    fclose(fp);
217
212
 
330
325
                    *(ptr + strlen(ptr) - 2) = '\0';
331
326
                }
332
327
 
333
 
                checkDepend(curr->name, ptr, types, entries);
 
328
                checkDepend(curr->name, ptr, types, entries);
334
329
                curr->type = xstrdup(ptr);
335
330
            } else if (!strncmp(buff, "IFDEF:", 6)) {
336
331
                if ((ptr = strtok(buff + 6, WS)) == NULL) {
787
782
    for (entry = head; entry != NULL; entry = entry->next) {
788
783
        Line *line;
789
784
        int blank = 1;
790
 
        int enabled = 1;
 
785
        int enabled = 1;
791
786
 
792
787
        if (!strcmp(entry->name, "comment"))
793
788
            (void) 0;
802
797
        if (!defined(entry->ifdef)) {
803
798
            fprintf(fp, "# Note: This option is only available if Squid is rebuilt with the\n");
804
799
            fprintf(fp, "#       %s\n#\n", available_if(entry->ifdef));
805
 
            enabled = 0;
 
800
            enabled = 0;
806
801
        }
807
802
 
808
803
        for (line = entry->doc; line != NULL; line = line->next) {
849
844
            fprintf(fp, "#\n");
850
845
 
851
846
        for (line = entry->nocomment; line != NULL; line = line->next) {
852
 
            if (!enabled && line->data[0] != '#')
853
 
                fprintf(fp, "#%s\n", line->data);
854
 
            else
855
 
                fprintf(fp, "%s\n", line->data);
 
847
            if (!enabled && line->data[0] != '#')
 
848
                fprintf(fp, "#%s\n", line->data);
 
849
            else
 
850
                fprintf(fp, "%s\n", line->data);
856
851
        }
857
852
 
858
853
        if (entry->doc != NULL) {