~ubuntu-branches/ubuntu/hardy/lighttpd/hardy

« back to all changes in this revision

Viewing changes to src/mod_accesslog.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-05-01 13:15:59 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070501131559-y8jos9wp79uf3pp4
Tags: 1.4.15-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - Add fam/gamin stat cache engine support
  - Clean environment in init.d script
  - Replace Depends: on perl with Depends: on libterm-readline-perl-perl
  - Make sure that upgrades succeed, even if we can't restart lighttpd
  - DebianMaintainerField update

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
int accesslog_parse_format(server *srv, format_fields *fields, buffer *format) {
160
160
        size_t i, j, k = 0, start = 0;
161
161
 
 
162
        if (format->used == 0) return -1;
 
163
 
162
164
        for (i = 0; i < format->used - 1; i++) {
163
 
 
164
165
                switch(format->ptr[i]) {
165
166
                case '%':
166
 
                        if (start != i) {
167
 
                                /* copy the string */
 
167
                        if (i > 0 && start != i) {
 
168
                                /* copy the string before this % */
168
169
                                if (fields->size == 0) {
169
170
                                        fields->size = 16;
170
171
                                        fields->used = 0;
183
184
                                fields->used++;
184
185
                        }
185
186
 
186
 
 
187
187
                        /* we need a new field */
188
188
 
189
189
                        if (fields->size == 0) {
199
199
                        switch (format->ptr[i+1]) {
200
200
                        case '>':
201
201
                        case '<':
202
 
                                /* only for s */
 
202
                                /* after the } has to be a character */
 
203
                                if (format->ptr[i+2] == '\0') {
 
204
                                        log_error_write(srv, __FILE__, __LINE__, "s", "%< and %> have to be followed by a format-specifier");
 
205
                                        return -1;
 
206
                                }
 
207
 
203
208
 
204
209
                                for (j = 0; fmap[j].key != '\0'; j++) {
205
210
                                        if (fmap[j].key != format->ptr[i+2]) continue;
217
222
                                }
218
223
 
219
224
                                if (fmap[j].key == '\0') {
220
 
                                        log_error_write(srv, __FILE__, __LINE__, "ss", "config: ", "failed");
 
225
                                        log_error_write(srv, __FILE__, __LINE__, "s", "%< and %> have to be followed by a valid format-specifier");
221
226
                                        return -1;
222
227
                                }
223
228
 
224
229
                                start = i + 3;
 
230
                                i = start - 1; /* skip the string */
225
231
 
226
232
                                break;
227
233
                        case '{':
232
238
                                }
233
239
 
234
240
                                if (k == format->used - 1) {
235
 
                                        log_error_write(srv, __FILE__, __LINE__, "ss", "config: ", "failed");
 
241
                                        log_error_write(srv, __FILE__, __LINE__, "s", "%{ has to be terminated by a }");
236
242
                                        return -1;
237
243
                                }
 
244
 
 
245
                                /* after the } has to be a character */
238
246
                                if (format->ptr[k+1] == '\0') {
239
 
                                        log_error_write(srv, __FILE__, __LINE__, "ss", "config: ", "failed");
 
247
                                        log_error_write(srv, __FILE__, __LINE__, "s", "%{...} has to be followed by a format-specifier");
 
248
                                        return -1;
 
249
                                }
 
250
 
 
251
                                if (k == i + 2) {
 
252
                                        log_error_write(srv, __FILE__, __LINE__, "s", "%{...} has to be contain a string");
240
253
                                        return -1;
241
254
                                }
242
255
 
258
271
                                }
259
272
 
260
273
                                if (fmap[j].key == '\0') {
261
 
                                        log_error_write(srv, __FILE__, __LINE__, "ss", "config: ", "failed");
 
274
                                        log_error_write(srv, __FILE__, __LINE__, "s", "%{...} has to be followed by a valid format-specifier");
262
275
                                        return -1;
263
276
                                }
264
277
 
265
278
                                start = k + 2;
 
279
                                i = start - 1; /* skip the string */
266
280
 
267
281
                                break;
268
282
                        default:
 
283
                                /* after the % has to be a character */
 
284
                                if (format->ptr[i+1] == '\0') {
 
285
                                        log_error_write(srv, __FILE__, __LINE__, "s", "% has to be followed by a format-specifier");
 
286
                                        return -1;
 
287
                                }
 
288
 
269
289
                                for (j = 0; fmap[j].key != '\0'; j++) {
270
290
                                        if (fmap[j].key != format->ptr[i+1]) continue;
271
291
 
282
302
                                }
283
303
 
284
304
                                if (fmap[j].key == '\0') {
285
 
                                        log_error_write(srv, __FILE__, __LINE__, "ss", "config: ", "failed");
 
305
                                        log_error_write(srv, __FILE__, __LINE__, "s", "% has to be followed by a valid format-specifier");
286
306
                                        return -1;
287
307
                                }
288
308
 
289
309
                                start = i + 2;
 
310
                                i = start - 1; /* skip the string */
290
311
 
291
312
                                break;
292
313
                        }
605
626
                                PATCH(parsed_format);
606
627
                        } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("accesslog.use-syslog"))) {
607
628
                                PATCH(use_syslog);
 
629
                                PATCH(last_generated_accesslog_ts_ptr);
 
630
                                PATCH(access_logbuffer);
 
631
                                PATCH(ts_accesslog_str);
608
632
                        }
609
633
                }
610
634
        }
778
802
                        case FORMAT_REQUEST_METHOD:
779
803
                                buffer_append_string(b, get_http_method_name(con->request.http_method));
780
804
                                break;
 
805
                        case FORMAT_PERCENT:
 
806
                                buffer_append_string(b, "%");
 
807
                                break;
781
808
                        case FORMAT_SERVER_PORT:
782
809
                                buffer_append_long(b, srv->srvconf.port);
783
810
                                break;
813
840
        BUFFER_APPEND_STRING_CONST(b, "\n");
814
841
 
815
842
        if (p->conf.use_syslog ||  /* syslog doesn't cache */
816
 
            (p->conf.access_logfile->used && p->conf.access_logfile->ptr[0] != '|') || /* pipes don't cache */
 
843
            (p->conf.access_logfile->used && p->conf.access_logfile->ptr[0] == '|') || /* pipes don't cache */
817
844
            newts ||
818
845
            b->used > BUFFER_MAX_REUSE_SIZE) {
819
846
                if (p->conf.use_syslog) {