# C includes must happen outside a VCL function
# see http://varnish-cache.org/wiki/VCLExampleSyslog
C{
  #include <stdlib.h>
  #include <time.h>
  #include <stdio.h>
}C

sub vcl_recv {
  if (req.url ~ "^/random$" ) {
    C{
      #define MINVAL 1
      #define MAXVAL 100
      #define BASEURL "/random/"
      srand((double)time(NULL));
      int r=MINVAL+(rand()%MAXVAL);
      char s[50];
      sprintf(s, BASEURL"%i", r);
      VRT_l_req_url(sp, s, vrt_magic_string_end);
    }C
  }
}