~ubuntu-branches/ubuntu/lucid/varnish/lucid

« back to all changes in this revision

Viewing changes to bin/varnishlog/varnishlog.c

  • Committer: Bazaar Package Importer
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2010-03-24 13:26:08 UTC
  • mfrom: (0.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100324132608-4uzkavctn26bdwyi
Tags: 2.1.0-1
* New upstream version
* Fix small error in man/vcl.7so

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*-
2
2
 * Copyright (c) 2006 Verdens Gang AS
3
 
 * Copyright (c) 2006-2008 Linpro AS
 
3
 * Copyright (c) 2006-2009 Linpro AS
4
4
 * All rights reserved.
5
5
 *
6
6
 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
26
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
27
 * SUCH DAMAGE.
28
28
 *
29
 
 * $Id: varnishlog.c 4003 2009-03-27 12:13:31Z tfheen $
30
 
 *
31
29
 * Log tailer for Varnish
32
30
 */
33
31
 
34
32
#include "config.h"
35
33
 
 
34
#include "svnid.h"
 
35
SVNID("$Id: varnishlog.c 4334 2009-10-20 13:55:55Z tfheen $")
 
36
 
36
37
#include <errno.h>
37
38
#include <fcntl.h>
38
 
#include <regex.h>
39
39
#include <signal.h>
40
40
#include <stdio.h>
41
41
#include <stdlib.h>
43
43
#include <unistd.h>
44
44
#include <limits.h>
45
45
 
46
 
#ifndef HAVE_DAEMON
47
46
#include "compat/daemon.h"
48
 
#endif
49
47
 
50
48
#include "vsb.h"
51
49
#include "vpf.h"
52
50
 
53
51
#include "libvarnish.h"
54
52
#include "shmlog.h"
 
53
#include "vre.h"
55
54
#include "varnishapi.h"
56
55
 
57
56
static int      b_flag, c_flag;
81
80
#define F_MATCH         (1 << 1)
82
81
 
83
82
static int              match_tag = -1;
84
 
static regex_t          match_re;
 
83
static vre_t            *match_re;
85
84
 
86
85
static void
87
86
h_order_finish(int fd)
133
132
                assert(ob[fd] != NULL);
134
133
        }
135
134
        if (tag == match_tag &&
136
 
            !regexec(&match_re, ptr, 0, NULL, 0))
 
135
            VRE_exec(match_re, ptr, len, 0, 0, NULL, 0) > 0)
137
136
                flg[fd] |= F_MATCH;
138
137
 
139
138
        if ((tag == SLT_BackendOpen || tag == SLT_SessionOpen ||
199
198
do_order(struct VSL_data *vd, int argc, char **argv)
200
199
{
201
200
        int i;
 
201
        const char *error;
 
202
        int erroroffset;
202
203
 
203
204
        if (argc == 2) {
204
205
                match_tag = name2tag(argv[0]);
206
207
                        fprintf(stderr, "Tag \"%s\" unknown\n", argv[0]);
207
208
                        exit(2);
208
209
                }
209
 
                i = regcomp(&match_re, argv[1], REG_EXTENDED | REG_NOSUB);
210
 
                if (i) {
211
 
                        char buf[BUFSIZ];
212
 
                        regerror(i, &match_re, buf, sizeof buf);
213
 
                        fprintf(stderr, "%s\n", buf);
 
210
                match_re = VRE_compile(argv[1], 0, &error, &erroroffset);
 
211
                if (match_re == NULL) {
 
212
                        fprintf(stderr, "Invalid regex: %s\n", error);
214
213
                        exit(2);
215
214
                }
216
215
        }
372
371
                exit(1);
373
372
        }
374
373
 
375
 
        if (D_flag && inxorcise(0, 0) == -1) {
 
374
        if (D_flag && varnish_daemon(0, 0) == -1) {
376
375
                perror("daemon()");
377
376
                if (pfh != NULL)
378
377
                        vpf_remove(pfh);