Lines Matching refs:ctx

58 	url_adapt_state_ex_t *ctx;  in php_ini_on_update_tags()  local
64 ctx = &BG(url_adapt_session_ex); in php_ini_on_update_tags()
66 ctx = &BG(url_adapt_output_ex); in php_ini_on_update_tags()
71 if (ctx->tags) in php_ini_on_update_tags()
72 zend_hash_destroy(ctx->tags); in php_ini_on_update_tags()
74 ctx->tags = malloc(sizeof(HashTable)); in php_ini_on_update_tags()
75 if (!ctx->tags) { in php_ini_on_update_tags()
81 zend_hash_init(ctx->tags, 0, NULL, tag_dtor, 1); in php_ini_on_update_tags()
98 zend_hash_str_add_mem(ctx->tags, key, keylen, val, strlen(val)+1); in php_ini_on_update_tags()
292 static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type) in tag_arg() argument
298 ZSTR_VAL(ctx->arg.s)[ZSTR_LEN(ctx->arg.s)] = '\0'; in tag_arg() local
299 if (!strcasecmp(ZSTR_VAL(ctx->arg.s), ctx->lookup_data)) { in tag_arg()
304 smart_str_appendc(&ctx->result, type); in tag_arg()
307 append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output); in tag_arg()
309 smart_str_append_smart_str(&ctx->result, &ctx->val); in tag_arg()
312 smart_str_appendc(&ctx->result, type); in tag_arg()
330 #define STATE ctx->state
332 #define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR
333 #define STD_ARGS ctx, start, xp
344 smart_str_appendl(&ctx->result, start, YYCURSOR - start); in passthru()
374 static int check_host_whitelist(url_adapt_state_ex_t *ctx) in check_host_whitelist() argument
377 …HashTable *allowed_hosts = ctx->type ? &BG(url_adapt_session_hosts_ht) : &BG(url_adapt_output_host… in check_host_whitelist()
379 ZEND_ASSERT(ctx->tag_type == TAG_FORM); in check_host_whitelist()
381 if (ctx->attr_val.s && ZSTR_LEN(ctx->attr_val.s)) { in check_host_whitelist()
382 url_parts = php_url_parse_ex(ZSTR_VAL(ctx->attr_val.s), ZSTR_LEN(ctx->attr_val.s)); in check_host_whitelist()
425 if (ZSTR_LEN(ctx->form_app.s) > 0) { in handle_form()
426 switch (ZSTR_LEN(ctx->tag.s)) { in handle_form()
428 if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s)) in handle_form()
429 && check_host_whitelist(ctx) == SUCCESS) { in handle_form()
437 smart_str_append_smart_str(&ctx->result, &ctx->form_app); in handle_form()
453 if (ctx->tag.s) { in handle_tag()
454 ZSTR_LEN(ctx->tag.s) = 0; in handle_tag()
456 smart_str_appendl(&ctx->tag, start, YYCURSOR - start); in handle_tag()
457 for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++) in handle_tag()
458 ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]); in handle_tag() local
460 …if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.… in handle_tag()
462 if (ZSTR_LEN(ctx->tag.s) == sizeof("form")-1 in handle_tag()
463 && !strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))) { in handle_tag()
464 ctx->tag_type = TAG_FORM; in handle_tag()
466 ctx->tag_type = TAG_NORMAL; in handle_tag()
474 if (ctx->arg.s) { in handle_arg()
475 ZSTR_LEN(ctx->arg.s) = 0; in handle_arg()
477 smart_str_appendl(&ctx->arg, start, YYCURSOR - start); in handle_arg()
478 if (ctx->tag_type == TAG_FORM && in handle_arg()
479 strncasecmp(ZSTR_VAL(ctx->arg.s), "action", ZSTR_LEN(ctx->arg.s)) == 0) { in handle_arg()
480 ctx->attr_type = ATTR_ACTION; in handle_arg()
482 ctx->attr_type = ATTR_NORMAL; in handle_arg()
488 smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); in handle_val()
489 if (ctx->tag_type == TAG_FORM && ctx->attr_type == ATTR_ACTION) { in handle_val()
490 smart_str_setl(&ctx->attr_val, start + quotes, YYCURSOR - start - quotes * 2); in handle_val()
492 tag_arg(ctx, quotes, type); in handle_val()
495 static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen) in xx_mainloop() argument
502 smart_str_appendl(&ctx->buf, newdata, newlen); in xx_mainloop()
504 YYCURSOR = ZSTR_VAL(ctx->buf.s); in xx_mainloop()
505 YYLIMIT = ZSTR_VAL(ctx->buf.s) + ZSTR_LEN(ctx->buf.s); in xx_mainloop()
994 …scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *Y… in xx_mainloop()
997 if (rest) memmove(ZSTR_VAL(ctx->buf.s), start, rest); in xx_mainloop()
998 ZSTR_LEN(ctx->buf.s) = rest; in xx_mainloop()
1041 …_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush, url_adapt_state_ex_t *ctx) in url_adapt_ext() argument
1045 xx_mainloop(ctx, src, srclen); in url_adapt_ext()
1047 if (!ctx->result.s) { in url_adapt_ext()
1048 smart_str_appendl(&ctx->result, "", 0); in url_adapt_ext()
1051 *newlen = ZSTR_LEN(ctx->result.s); in url_adapt_ext()
1053 smart_str_0(&ctx->result); in url_adapt_ext()
1055 smart_str_append(&ctx->result, ctx->buf.s); in url_adapt_ext()
1056 *newlen += ZSTR_LEN(ctx->buf.s); in url_adapt_ext()
1057 smart_str_free(&ctx->buf); in url_adapt_ext()
1058 smart_str_free(&ctx->val); in url_adapt_ext()
1059 smart_str_free(&ctx->attr_val); in url_adapt_ext()
1061 retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s)); in url_adapt_ext()
1062 smart_str_free(&ctx->result); in url_adapt_ext()
1068 url_adapt_state_ex_t *ctx; in php_url_scanner_ex_activate() local
1071 ctx = &BG(url_adapt_session_ex); in php_url_scanner_ex_activate()
1073 ctx = &BG(url_adapt_output_ex); in php_url_scanner_ex_activate()
1076 memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags)); in php_url_scanner_ex_activate()
1083 url_adapt_state_ex_t *ctx; in php_url_scanner_ex_deactivate() local
1086 ctx = &BG(url_adapt_session_ex); in php_url_scanner_ex_deactivate()
1088 ctx = &BG(url_adapt_output_ex); in php_url_scanner_ex_deactivate()
1091 smart_str_free(&ctx->result); in php_url_scanner_ex_deactivate()
1092 smart_str_free(&ctx->buf); in php_url_scanner_ex_deactivate()
1093 smart_str_free(&ctx->tag); in php_url_scanner_ex_deactivate()
1094 smart_str_free(&ctx->arg); in php_url_scanner_ex_deactivate()
1095 smart_str_free(&ctx->attr_val); in php_url_scanner_ex_deactivate()
1119 url_adapt_state_ex_t *ctx = url_state; in php_url_scanner_session_handler_impl() local
1120 if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) { in php_url_scanner_session_handler_impl()
1121 smart_str_append(&ctx->result, ctx->buf.s); in php_url_scanner_session_handler_impl()
1122 smart_str_appendl(&ctx->result, output, output_len); in php_url_scanner_session_handler_impl()
1124 *handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s)); in php_url_scanner_session_handler_impl()
1125 *handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len; in php_url_scanner_session_handler_impl()
1127 smart_str_free(&ctx->buf); in php_url_scanner_session_handler_impl()
1128 smart_str_free(&ctx->result); in php_url_scanner_session_handler_impl()