Skip to content

Instantly share code, notes, and snippets.

@xcir
Created October 22, 2012 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcir/3933140 to your computer and use it in GitHub Desktop.
Save xcir/3933140 to your computer and use it in GitHub Desktop.
iterate i/f(draft)
//vmod.vcc
Function STRING filter_a()
Function STRING filter_b()
//vmod.c
void filter_a(const char* c){
syslog(6,"hello(A):%s",c);
}
void filter_b(const char* c){
syslog(6,"hello(B):%s",c);
}
const char *vmod_filter_a(struct sess *sp){
char buf[64];
buf[0] = 0;
snprintf(buf,64,"%ld",filter_a);
int u = WS_Reserve(sp->wrk->ws,0);
if(u < strlen(buf)+1){
WS_Release(sp->wrk->ws,0);
return NULL;
}
char *p = sp->wrk->ws->f;
p[0] = 0;
strcpy(p,buf);
WS_Release(sp->wrk->ws,strlen(buf)+1);
return p;
}
const char *vmod_filter_b(struct sess *sp){
char buf[64];
buf[0] = 0;
snprintf(buf,64,"%ld",filter_b);
int u = WS_Reserve(sp->wrk->ws,0);
if(u < strlen(buf)+1){
WS_Release(sp->wrk->ws,0);
return NULL;
}
char *p = sp->wrk->ws->f;
p[0] = 0;
strcpy(p,buf);
WS_Release(sp->wrk->ws,strlen(buf)+1);
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment