11#include <stdlib.h>
22
33#include "vrt.h"
4- #include "bin/varnishd /cache.h"
4+ #include "cache /cache.h"
55
66#include "vcc_if.h"
77
@@ -12,17 +12,16 @@ static char hexchars[] = "0123456789ABCDEF";
1212 ((c >= '0' && c <= '9') || visalpha(c))
1313
1414const char *
15- vmod_encode (struct sess * sp , const char * str , ...)
15+ vmod_encode (const struct vrt_ctx * ctx , const char * str , ...)
1616{
1717 char * b , * e ;
1818 unsigned u ;
1919 va_list ap ;
2020
21- CHECK_OBJ_NOTNULL (sp , SESS_MAGIC );
22- CHECK_OBJ_NOTNULL (sp -> http , HTTP_MAGIC );
23- CHECK_OBJ_NOTNULL (sp -> http -> ws , WS_MAGIC );
24- u = WS_Reserve (sp -> http -> ws , 0 );
25- e = b = sp -> http -> ws -> f ;
21+ CHECK_OBJ_NOTNULL (ctx , VRT_CTX_MAGIC );
22+ CHECK_OBJ_NOTNULL (ctx -> ws , WS_MAGIC );
23+ u = WS_Reserve (ctx -> ws , 0 );
24+ e = b = ctx -> ws -> f ;
2625 e += u ;
2726 va_start (ap , str );
2827 while (b < e && str != vrt_magic_string_end ) {
@@ -46,12 +45,12 @@ vmod_encode(struct sess *sp, const char *str, ...)
4645 * b = '\0' ;
4746 b ++ ;
4847 if (b > e ) {
49- WS_Release (sp -> http -> ws , 0 );
48+ WS_Release (ctx -> ws , 0 );
5049 return (NULL );
5150 } else {
5251 e = b ;
53- b = sp -> http -> ws -> f ;
54- WS_Release (sp -> http -> ws , e - b );
52+ b = ctx -> ws -> f ;
53+ WS_Release (ctx -> ws , e - b );
5554 return (b );
5655 }
5756}
@@ -69,19 +68,18 @@ vmod_hex_to_int(char c)
6968}
7069
7170const char *
72- vmod_decode (struct sess * sp , const char * str , ...)
71+ vmod_decode (const struct vrt_ctx * ctx , const char * str , ...)
7372{
7473 char * b , * e ;
7574 int h , l ;
7675 unsigned u ;
7776 va_list ap ;
7877 int percent = 0 ;
7978
80- CHECK_OBJ_NOTNULL (sp , SESS_MAGIC );
81- CHECK_OBJ_NOTNULL (sp -> http , HTTP_MAGIC );
82- CHECK_OBJ_NOTNULL (sp -> http -> ws , WS_MAGIC );
83- u = WS_Reserve (sp -> http -> ws , 0 );
84- e = b = sp -> http -> ws -> f ;
79+ CHECK_OBJ_NOTNULL (ctx , VRT_CTX_MAGIC );
80+ CHECK_OBJ_NOTNULL (ctx -> ws , WS_MAGIC );
81+ u = WS_Reserve (ctx -> ws , 0 );
82+ e = b = ctx -> ws -> f ;
8583 e += u ;
8684 va_start (ap , str );
8785 while (b < e && str != vrt_magic_string_end ) {
@@ -118,12 +116,12 @@ vmod_decode(struct sess *sp, const char *str, ...)
118116 * b = '\0' ;
119117 b ++ ;
120118 if (b > e ) {
121- WS_Release (sp -> http -> ws , 0 );
119+ WS_Release (ctx -> ws , 0 );
122120 return (NULL );
123121 } else {
124122 e = b ;
125- b = sp -> http -> ws -> f ;
126- WS_Release (sp -> http -> ws , e - b );
123+ b = ctx -> ws -> f ;
124+ WS_Release (ctx -> ws , e - b );
127125 return (b );
128126 }
129127}
0 commit comments