Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 4.22 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/configure.ac b/configure.ac
  2. index ae5e0a8..3e0f0ea 100644
  3. --- a/configure.ac
  4. +++ b/configure.ac
  5. @@ -39,30 +39,31 @@ AC_CHECK_HEADERS([sys/stdlib.h])
  6.  # Check for python
  7.  AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, please install python.])])
  8.  
  9. -# Varnish source tree
  10. -AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (mandatory)])
  11. -if test "x$VARNISHSRC" = x; then
  12. -       AC_MSG_ERROR([No Varnish source tree specified])
  13. -fi
  14. -VARNISHSRC=`cd $VARNISHSRC && pwd`
  15. -AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
  16. +# Check for Varnish
  17. +AC_SUBST(VARNISH_BINDIR, `$PKG_CONFIG --variable=bindir varnishapi`)
  18. +AC_SUBST(VARNISH_SBINDIR, `$PKG_CONFIG --variable=sbindir varnishapi`)
  19. +AC_SUBST(VARNISH_PKGDATA, `$PKG_CONFIG --variable=pkgdatadir varnishapi`)
  20. +AC_SUBST(VMOD_INCLUDE, `$PKG_CONFIG --variable=pkgdataincludedir varnishapi`)
  21. +AC_SUBST(VMOD_DIR, `$PKG_CONFIG --variable=vmoddir varnishapi`)
  22. +AC_SUBST(VMOD_TOOL, $VARNISH_PKGDATA/vmodtool.py)
  23. +AC_CHECK_FILE([$VARNISH_SBINDIR/varnishd],
  24. +       [AC_SUBST(VARNISHD, "$VARNISH_SBINDIR/varnishd")],
  25. +       [AC_MSG_FAILURE([Can't find "$VARNISH_SBINDIR/varnishd"])]
  26. +)
  27. +AC_CHECK_FILE([$VARNISH_BINDIR/varnishtest],
  28. +       [AC_SUBST(VARNISHTEST, "$VARNISH_BINDIR/varnishtest")],
  29. +       [AC_MSG_FAILURE([Can't find "$VARNISH_BINDIR/varnishtest"])]
  30. +)
  31. +AC_CHECK_FILE([$VMOD_TOOL],
  32.         [],
  33. -       [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]
  34. +       [AC_MSG_FAILURE([Can't find "$VMOD_TOOL"])]
  35.  )
  36. -
  37. -# Check that varnishtest is built in the varnish source directory
  38. -AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest],
  39. +AC_CHECK_FILE([$VMOD_INCLUDE/cache/cache.h],
  40.         [],
  41. -       [AC_MSG_FAILURE([Can't find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])]
  42. +       [AC_MSG_FAILURE([Can't find "$VMOD_INCLUDE/cache/cache.h"])]
  43.  )
  44. -
  45. -# vmod installation dir
  46. -AC_ARG_VAR([VMODDIR], [vmod installation directory @<:@LIBDIR/varnish/vmods@:>@])
  47. -if test "x$VMODDIR" = x; then
  48. -       VMODDIR=`pkg-config --variable=vmoddir varnishapi`
  49. -       if test "x$VMODDIR" = x; then
  50. -               AC_MSG_FAILURE([Can't determine vmod installation directory])
  51. -       fi
  52. +if test ! -d "$VMOD_DIR"; then
  53. +       AC_MSG_FAILURE([Can't determine vmod installation directory])
  54.  fi
  55.  
  56.  AC_CONFIG_FILES([
  57. diff --git a/src/Makefile.am b/src/Makefile.am
  58. index c8f8088..985ad57 100644
  59. --- a/src/Makefile.am
  60. +++ b/src/Makefile.am
  61. @@ -1,6 +1,6 @@
  62. -INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC)
  63. +INCLUDES = -I$(VMOD_INCLUDE)
  64.  
  65. -vmoddir = $(VMODDIR)
  66. +vmoddir = $(VMOD_DIR)
  67.  vmod_LTLIBRARIES = libvmod_example.la
  68.  
  69.  libvmod_example_la_LDFLAGS = -module -export-dynamic -avoid-version
  70. @@ -10,14 +10,14 @@ libvmod_example_la_SOURCES = \
  71.         vcc_if.h \
  72.         vmod_example.c
  73.  
  74. -vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_example.vcc
  75. -       @PYTHON@ $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_example.vcc
  76. +vcc_if.c vcc_if.h: $(VMOD_TOOL) $(top_srcdir)/src/vmod_example.vcc
  77. +       @PYTHON@ $(VMOD_TOOL) $(top_srcdir)/src/vmod_example.vcc
  78.  
  79.  VMOD_TESTS = tests/*.vtc
  80.  .PHONY: $(VMOD_TESTS)
  81.  
  82.  tests/*.vtc:
  83. -       $(VARNISHSRC)/bin/varnishtest/varnishtest -Dvarnishd=$(VARNISHSRC)/bin/varnishd/varnishd -Dvmod_topbuild=$(abs_top_builddir) $@
  84. +       $(VARNISHTEST) -Dvarnishd=$(VARNISHD) -Dvmod_topbuild=$(abs_top_builddir) $@
  85.  
  86.  check: $(VMOD_TESTS)
  87.  
  88. diff --git a/src/vmod_example.c b/src/vmod_example.c
  89. index 468fa75..082f38e 100644
  90. --- a/src/vmod_example.c
  91. +++ b/src/vmod_example.c
  92. @@ -1,7 +1,8 @@
  93.  #include <stdlib.h>
  94. +#include <stdio.h>
  95.  
  96.  #include "vrt.h"
  97. -#include "bin/varnishd/cache.h"
  98. +#include "cache/cache.h"
  99.  
  100.  #include "vcc_if.h"
  101.  
  102. @@ -17,16 +18,16 @@ vmod_hello(struct sess *sp, const char *name)
  103.         char *p;
  104.         unsigned u, v;
  105.  
  106. -       u = WS_Reserve(sp->wrk->ws, 0); /* Reserve some work space */
  107. -       p = sp->wrk->ws->f;             /* Front of workspace area */
  108. +       u = WS_Reserve(sp->req->ws, 0); /* Reserve some work space */
  109. +       p = sp->req->ws->f;             /* Front of workspace area */
  110.         v = snprintf(p, u, "Hello, %s", name);
  111.         v++;
  112.         if (v > u) {
  113.                 /* No space, reset and leave */
  114. -               WS_Release(sp->wrk->ws, 0);
  115. +               WS_Release(sp->req->ws, 0);
  116.                 return (NULL);
  117.         }
  118.         /* Update work space with what we've used */
  119. -       WS_Release(sp->wrk->ws, v);
  120. +       WS_Release(sp->req->ws, v);
  121.         return (p);
  122.  }