int main(int argc, char **argv) { unsigned int len; pcont_t *pc; char inbuf[256]; char outbuf[1024]; strcpy(inbuf,RAWSTRING); len = strlen(inbuf); pc = NULL; pc = cparse_sexp(inbuf,len,pc); if (sexp_errno == SEXP_ERR_INCOMPLETE) { printf("Incomplete expression detected.\n"); } else { printf("Unexpected error: %d\n", sexp_errno); exit(EXIT_FAILURE); } print_pcont(pc,outbuf,1024); printf("%s\n",outbuf); destroy_continuation(pc); sexp_cleanup(); exit(EXIT_SUCCESS); }
static int blacklist_plugin(TSCont contp, TSEvent event, void *edata) { TSHttpTxn txnp; cdata *cd; switch (event) { case TS_EVENT_HTTP_TXN_START: txnp = (TSHttpTxn)edata; handle_txn_start(contp, txnp); return 0; case TS_EVENT_HTTP_OS_DNS: if (contp != global_contp) { cd = (cdata *)TSContDataGet(contp); cd->cf = HANDLE_DNS; handle_dns(cd->txnp, contp); return 0; } else { break; } case TS_EVENT_HTTP_TXN_CLOSE: txnp = (TSHttpTxn)edata; if (contp != global_contp) { destroy_continuation(txnp, contp); } break; case TS_EVENT_HTTP_SEND_RESPONSE_HDR: if (contp != global_contp) { cd = (cdata *)TSContDataGet(contp); cd->cf = HANDLE_RESPONSE; handle_response(cd->txnp, contp); return 0; } else { break; } case TS_EVENT_TIMEOUT: /* when mutex lock is not acquired and continuation is rescheduled, the plugin is called back with TS_EVENT_TIMEOUT with a NULL edata. We need to decide, in which function did the MutexLock failed and call that function again */ if (contp != global_contp) { cd = (cdata *)TSContDataGet(contp); switch (cd->cf) { case HANDLE_DNS: handle_dns(cd->txnp, contp); return 0; case HANDLE_RESPONSE: handle_response(cd->txnp, contp); return 0; default: TSDebug(PLUGIN_NAME, "This event was unexpected: %d", event); break; } } else { read_blacklist(contp); return 0; } default: break; } return 0; }
void destroy_iowrap(sexp_mem_t *smem, sexp_iowrap_t *iow) { if (iow == NULL) return; /* idiot */ destroy_continuation(smem, iow->cc); free(iow); }