]> granicus.if.org Git - php/commitdiff
More fixes and refinements
authorZeev Suraski <zeev@php.net>
Mon, 27 Aug 2001 00:23:55 +0000 (00:23 +0000)
committerZeev Suraski <zeev@php.net>
Mon, 27 Aug 2001 00:23:55 +0000 (00:23 +0000)
ext/session/php_session.h
ext/session/session.c
ext/standard/url_scanner_ex.c
ext/standard/url_scanner_ex.re

index 589e0661d13c3b9a26c8dab113a8f0165f2d6df3..f6ee4f7324d4b310bf0004f8777430c2f7cbc427 100644 (file)
@@ -91,6 +91,7 @@ typedef struct _php_ps_globals {
        zend_bool define_sid;
        zend_bool use_cookies;
        zend_bool use_trans_sid;
+       zend_bool output_handler_registered;
 } php_ps_globals;
 
 extern zend_module_entry session_module_entry;
index 759949e5f561faaff2402d54a82320cd86ac9f8f..7250820ee492b281657dbe4e5d5cca7ffd1d747e 100644 (file)
@@ -82,7 +82,7 @@ php_ps_globals ps_globals;
 
 static ps_module *_php_find_ps_module(char *name TSRMLS_DC);
 static const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC);
-
+static void php_session_end_output_handler(TSRMLS_D);
 
 static int session_adapt_uris(const char *src, size_t srclen, char **new, size_t *newlen, zend_bool do_flush TSRMLS_DC)
 {
@@ -95,7 +95,6 @@ static int session_adapt_uris(const char *src, size_t srclen, char **new, size_t
 }
 
 
-
 static void php_session_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
 {
        zend_bool do_flush;
@@ -115,17 +114,11 @@ static void php_session_start_output_handler(uint chunk_size TSRMLS_DC)
        php_url_scanner_ex_activate(TSRMLS_C);
        php_start_ob_buffer(NULL, chunk_size TSRMLS_CC);
        php_ob_set_internal_handler(php_session_output_handler, chunk_size TSRMLS_CC);
+       PS(output_handler_registered) = 1;
 }
 
 
-static void php_session_activate(TSRMLS_D)
-{
-}
-
-
-
-
-static void php_session_end_output_handler(SHUTDOWN_FUNC_ARGS)
+static void php_session_end_output_handler(TSRMLS_D)
 {
        php_url_scanner_ex_deactivate(TSRMLS_C);
        php_url_scanner_deactivate(TSRMLS_C);
@@ -136,7 +129,7 @@ static PHP_INI_MH(OnUpdateSaveHandler)
 {
        PS(mod) = _php_find_ps_module(new_value TSRMLS_CC);
        if(!PS(mod)) {
-         php_error(E_ERROR,"Cannot find save handler %s",new_value);
+               php_error(E_ERROR,"Cannot find save handler %s",new_value);
        }
        return SUCCESS;
 }
@@ -916,8 +909,9 @@ static void php_session_start(TSRMLS_D)
                send_cookie = 0;
        }
        
-       if (send_cookie)
+       if (send_cookie) {
                php_session_send_cookie(TSRMLS_C);
+       }
 
 
        if (define_sid) {
@@ -928,8 +922,9 @@ static void php_session_start(TSRMLS_D)
                smart_str_appends(&var, PS(id));
                smart_str_0(&var);
                REGISTER_STRING_CONSTANT("SID", var.c, 0);
-       } else
+       } else {
                REGISTER_STRING_CONSTANT("SID", empty_string, 0);
+       }
        PS(define_sid) = define_sid;
 
        PS(session_status) = php_session_active;
@@ -1371,14 +1366,17 @@ static void php_rinit_session_globals(TSRMLS_D)
        PS(id) = NULL;
        PS(session_status) = php_session_none;
        PS(mod_data) = NULL;
+       PS(output_handler_registered) = 0;
 }
 
 static void php_rshutdown_session_globals(TSRMLS_D)
 {
-       if (PS(mod_data))
+       if (PS(mod_data)) {
                PS(mod)->close(&PS(mod_data));
-       if (PS(id)) 
+       }
+       if (PS(id)) {
                efree(PS(id));
+       }
        zend_hash_destroy(&PS(vars));
 }
 
@@ -1424,8 +1422,8 @@ PHP_FUNCTION(session_write_close)
 
 PHP_RSHUTDOWN_FUNCTION(session)
 {
-       if (PS(use_trans_sid)) {
-               php_session_end_output_handler(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+       if (PS(output_handler_registered)) {
+               php_session_end_output_handler(TSRMLS_C);
        }
        php_session_flush(TSRMLS_C);
        php_rshutdown_session_globals(TSRMLS_C);
index 4f227f7c73a2dbbf18ccc7d608d3f0d965dde24d..ae28f04fa79799bda697e0f804df83b509378ae5 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.5 on Sun Aug  5 18:41:23 2001 */
+/* Generated by re2c 0.5 on Mon Aug 27 01:07:32 2001 */
 #line 1 "url_scanner_ex.re"
 /*
   +----------------------------------------------------------------------+
@@ -86,7 +86,7 @@ PHP_INI_BEGIN()
        STD_PHP_INI_ENTRY("url_rewriter.tags", "a=href,area=href,frame=src,form=fakeentry", PHP_INI_ALL, OnUpdateTags, url_adapt_state_ex, php_basic_globals, basic_globals)
 PHP_INI_END()
 
-#line 93
+#line 91
 
 
 #define YYFILL(n) goto done
@@ -151,25 +151,25 @@ yy0:
        if(yych >= ';') goto yy4;
 yy2:   yych = *++YYCURSOR;
 yy3:
-#line 111
+#line 109
        { smart_str_append(dest, url); return; }
 yy4:   yych = *++YYCURSOR;
 yy5:
-#line 112
+#line 110
        { sep = separator; goto done; }
 yy6:   yych = *++YYCURSOR;
 yy7:
-#line 113
+#line 111
        { bash = p; goto done; }
 yy8:   ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
 yy9:   if(yybm[0+yych] & 128)  goto yy8;
 yy10:
-#line 114
+#line 112
        { goto scan; }
 }
-#line 115
+#line 113
 
 done:
   
@@ -361,17 +361,17 @@ yy11:
        if(yybm[0+yych] & 128)  goto yy15;
 yy13:  yych = *++YYCURSOR;
 yy14:
-#line 262
+#line 260
        { passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
 yy15:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
 yy16:  if(yybm[0+yych] & 128)  goto yy15;
 yy17:
-#line 263
+#line 261
        { passthru(STD_ARGS); goto state_plain; }
 }
-#line 264
+#line 262
 
 
 state_tag:     
@@ -425,11 +425,11 @@ yy18:
 yy20:  yych = *++YYCURSOR;
        goto yy25;
 yy21:
-#line 269
+#line 267
        { handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
 yy22:  yych = *++YYCURSOR;
 yy23:
-#line 270
+#line 268
        { passthru(STD_ARGS); goto state_plain_begin; }
 yy24:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -437,7 +437,7 @@ yy24:       ++YYCURSOR;
 yy25:  if(yybm[0+yych] & 128)  goto yy24;
        goto yy21;
 }
-#line 271
+#line 269
 
 
 state_next_arg_begin:
@@ -508,20 +508,20 @@ yy26:
        }
 yy28:  yych = *++YYCURSOR;
 yy29:
-#line 279
+#line 277
        { passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
 yy30:  yych = *++YYCURSOR;
        goto yy37;
 yy31:
-#line 280
+#line 278
        { passthru(STD_ARGS); goto state_next_arg; }
 yy32:  yych = *++YYCURSOR;
 yy33:
-#line 281
+#line 279
        { --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
 yy34:  yych = *++YYCURSOR;
 yy35:
-#line 282
+#line 280
        { passthru(STD_ARGS); goto state_plain_begin; }
 yy36:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -529,7 +529,7 @@ yy36:       ++YYCURSOR;
 yy37:  if(yybm[0+yych] & 128)  goto yy36;
        goto yy31;
 }
-#line 283
+#line 281
 
 
 state_arg:
@@ -583,11 +583,11 @@ yy38:
 yy40:  yych = *++YYCURSOR;
        goto yy45;
 yy41:
-#line 288
+#line 286
        { passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
 yy42:  yych = *++YYCURSOR;
 yy43:
-#line 289
+#line 287
        { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; }
 yy44:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -595,7 +595,7 @@ yy44:       ++YYCURSOR;
 yy45:  if(yybm[0+yych] & 128)  goto yy44;
        goto yy41;
 }
-#line 290
+#line 288
 
 
 state_before_val:
@@ -650,12 +650,12 @@ yy48:     yyaccept = 0;
        if(yych == ' ') goto yy55;
        if(yych == '=') goto yy53;
 yy49:
-#line 296
+#line 294
        { --YYCURSOR; goto state_next_arg_begin; }
 yy50:  yych = *++YYCURSOR;
        goto yy54;
 yy51:
-#line 295
+#line 293
        { passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
 yy52:  yych = *++YYCURSOR;
        goto yy49;
@@ -674,7 +674,7 @@ yy57:       YYCURSOR = YYMARKER;
        case 0: goto yy49;
        }
 }
-#line 297
+#line 295
 
 
 
@@ -744,7 +744,7 @@ yy60:       yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych != '>') goto yy74;
 yy61:
-#line 306
+#line 304
        { passthru(STD_ARGS); goto state_next_arg_begin; }
 yy62:  yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
@@ -753,7 +753,7 @@ yy62:       yyaccept = 0;
 yy63:  yych = *++YYCURSOR;
        goto yy67;
 yy64:
-#line 305
+#line 303
        { handle_val(STD_ARGS, 0, '"'); goto state_next_arg_begin; }
 yy65:  yych = *++YYCURSOR;
        goto yy61;
@@ -773,7 +773,7 @@ yy70:       YYCURSOR = YYMARKER;
        }
 yy71:  yych = *++YYCURSOR;
 yy72:
-#line 304
+#line 302
        { handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
 yy73:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -782,10 +782,10 @@ yy74:     if(yybm[0+yych] & 128)  goto yy73;
        if(yych >= '>') goto yy70;
 yy75:  yych = *++YYCURSOR;
 yy76:
-#line 303
+#line 301
        { handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
 }
-#line 307
+#line 305
 
 
 stop:
@@ -798,22 +798,6 @@ stop:
        ctx->buf.len = rest;
 }
 
-char *url_adapt_flush(size_t *newlen TSRMLS_DC)
-{
-       char *ret = NULL;
-       url_adapt_state_ex_t *ctx;
-       
-       ctx = &BG(url_adapt_state_ex);
-       
-       if (ctx->buf.len) {
-               ret = ctx->buf.c;
-               *newlen = ctx->buf.len;
-               ctx->buf.c = 0;
-               ctx->buf.len = 0;
-       }
-
-       return ret;
-}
 
 char *url_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen TSRMLS_DC)
 {
@@ -838,6 +822,7 @@ char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char
 {
        char *ret;
        url_adapt_state_ex_t *ctx;
+       char *retval;
 
        ctx = &BG(url_adapt_state_ex);
 
@@ -853,11 +838,12 @@ char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char
        if (do_flush) {
                smart_str_appendl(&ctx->result, ctx->buf.c, ctx->buf.len);
                *newlen += ctx->buf.len;
-               ctx->buf.c = 0;
-               ctx->buf.len = 0;
+               smart_str_free(&ctx->buf);
        }
+       retval = ctx->result.c;
+       ctx->result.c = NULL;
        ctx->result.len = 0;
-       return ctx->result.c;
+       return retval;
 }
 
 int php_url_scanner_ex_activate(TSRMLS_D)
index 5074fa66bd4d0aa09fbc8cf3037c35be104eab2a..26a30d30a8be6e52236867e60dbf25d07187bb64 100644 (file)
@@ -314,22 +314,6 @@ stop:
        ctx->buf.len = rest;
 }
 
-char *url_adapt_flush(size_t *newlen TSRMLS_DC)
-{
-       char *ret = NULL;
-       url_adapt_state_ex_t *ctx;
-       
-       ctx = &BG(url_adapt_state_ex);
-       
-       if (ctx->buf.len) {
-               ret = ctx->buf.c;
-               *newlen = ctx->buf.len;
-               ctx->buf.c = 0;
-               ctx->buf.len = 0;
-       }
-
-       return ret;
-}
 
 char *url_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen TSRMLS_DC)
 {
@@ -354,6 +338,7 @@ char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char
 {
        char *ret;
        url_adapt_state_ex_t *ctx;
+       char *retval;
 
        ctx = &BG(url_adapt_state_ex);
 
@@ -369,11 +354,12 @@ char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char
        if (do_flush) {
                smart_str_appendl(&ctx->result, ctx->buf.c, ctx->buf.len);
                *newlen += ctx->buf.len;
-               ctx->buf.c = 0;
-               ctx->buf.len = 0;
+               smart_str_free(&ctx->buf);
        }
+       retval = ctx->result.c;
+       ctx->result.c = NULL;
        ctx->result.len = 0;
-       return ctx->result.c;
+       return retval;
 }
 
 int php_url_scanner_ex_activate(TSRMLS_D)