]> err.no Git - varnish/commitdiff
Use shmlog api from libvarnishapi
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 28 Jun 2006 21:03:47 +0000 (21:03 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 28 Jun 2006 21:03:47 +0000 (21:03 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@261 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishstat/Makefile.am
varnish-cache/bin/varnishstat/varnishstat.c

index c2302a7c039482a31e1a53d59bf85ab9337c2259..167023300e725ed95f9f7a26875afa2bff803914 100644 (file)
@@ -6,5 +6,6 @@ bin_PROGRAMS = varnishstat
 
 varnishstat_SOURCES = varnishstat.c
 
-varnishstat_LDADD = -lcurses
-# varnishlog_LDADD = $(top_builddir)/lib/libvarnishapi/libvarnishapi.la 
+varnishstat_LDADD = \
+       -lcurses \
+       $(top_builddir)/lib/libvarnishapi/libvarnishapi.la 
index 85bba07f90b6ca8da1788a1d2fe948cc09f66d24..9d7b253b037c24893937e4a910366415df712fd9 100644 (file)
@@ -9,50 +9,22 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <curses.h>
-#include <sys/mman.h>
 
-#include <shmlog.h>
-
-static struct shmloghead *loghead;
+#include "shmlog.h"
+#include "varnishapi.h"
 
 int
 main(int argc, char **argv)
 {
-       int fd;
-       int i, c;
-       struct shmloghead slh;
+       int c;
+       struct shmloghead *lh;
        struct varnish_stats *VSL_stats;
        int c_flag = 0;
 
-       fd = open(SHMLOG_FILENAME, O_RDONLY);
-       if (fd < 0) {
-               fprintf(stderr, "Cannot open %s: %s\n",
-                   SHMLOG_FILENAME, strerror(errno));
-               exit (1);
-       }
-       i = read(fd, &slh, sizeof slh);
-       if (i != sizeof slh) {
-               fprintf(stderr, "Cannot read %s: %s\n",
-                   SHMLOG_FILENAME, strerror(errno));
-               exit (1);
-       }
-       if (slh.magic != SHMLOGHEAD_MAGIC) {
-               fprintf(stderr, "Wrong magic number in file %s\n",
-                   SHMLOG_FILENAME);
-               exit (1);
-       }
-
-       loghead = mmap(NULL, slh.size + sizeof slh,
-           PROT_READ, MAP_HASSEMAPHORE, fd, 0);
-       if (loghead == MAP_FAILED) {
-               fprintf(stderr, "Cannot mmap %s: %s\n",
-                   SHMLOG_FILENAME, strerror(errno));
-               exit (1);
-       }
+       lh = VSL_OpenLog();
 
-       VSL_stats = &loghead->stats;
+       VSL_stats = &lh->stats;
 
        while ((c = getopt(argc, argv, "c")) != -1) {
                switch (c) {