Created
October 22, 2012 18:20
-
-
Save xcir/3933140 to your computer and use it in GitHub Desktop.
iterate i/f(draft)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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