PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_HEAD/lcov_data/ext/standard - url_scanner_ex.c
Test: PHP Code Coverage
Date: 2009-11-23 Instrumented lines: 222
Code covered: 75.2 % Executed lines: 167
Legend: not executed executed

       1                 : /* Generated by re2c 0.13.5 on Wed Aug  5 23:53:08 2009 */
       2                 : #line 1 "ext/standard/url_scanner_ex.re"
       3                 : /*
       4                 :   +----------------------------------------------------------------------+
       5                 :   | PHP Version 6                                                        |
       6                 :   +----------------------------------------------------------------------+
       7                 :   | Copyright (c) 1997-2006 The PHP Group                                |
       8                 :   +----------------------------------------------------------------------+
       9                 :   | This source file is subject to version 3.01 of the PHP license,      |
      10                 :   | that is bundled with this package in the file LICENSE, and is        |
      11                 :   | available through the world-wide-web at the following url:           |
      12                 :   | http://www.php.net/license/3_01.txt                                  |
      13                 :   | If you did not receive a copy of the PHP license and are unable to   |
      14                 :   | obtain it through the world-wide-web, please send a note to          |
      15                 :   | license@php.net so we can mail you a copy immediately.               |
      16                 :   +----------------------------------------------------------------------+
      17                 :   | Author: Sascha Schumann <sascha@schumann.cx>                         |
      18                 :   +----------------------------------------------------------------------+
      19                 : */
      20                 : 
      21                 : /* $Id: url_scanner_ex.c 286857 2009-08-05 23:20:17Z scottmac $ */
      22                 : 
      23                 : #include "php.h"
      24                 : 
      25                 : #ifdef HAVE_UNISTD_H
      26                 : #include <unistd.h>
      27                 : #endif
      28                 : #ifdef HAVE_LIMITS_H
      29                 : #include <limits.h>
      30                 : #endif
      31                 : 
      32                 : #include <stdio.h>
      33                 : #include <stdlib.h>
      34                 : #include <string.h>
      35                 : 
      36                 : #include "php_ini.h"
      37                 : #include "php_globals.h"
      38                 : #define STATE_TAG SOME_OTHER_STATE_TAG
      39                 : #include "basic_functions.h"
      40                 : #include "url.h"
      41                 : #undef STATE_TAG
      42                 : 
      43                 : #define url_scanner url_scanner_ex
      44                 : 
      45                 : #include "php_smart_str.h"
      46                 : 
      47                 : static PHP_INI_MH(OnUpdateTags)
      48                 : {
      49                 :         url_adapt_state_ex_t *ctx;
      50                 :         char *key;
      51                 :         char *lasts;
      52                 :         char *tmp;
      53                 :         
      54                 :         ctx = &BG(url_adapt_state_ex);
      55                 :         
      56                 :         tmp = estrndup(new_value, new_value_length);
      57                 :         
      58                 :         if (ctx->tags)
      59                 :                 zend_hash_destroy(ctx->tags);
      60                 :         else
      61                 :                 ctx->tags = malloc(sizeof(HashTable));
      62                 :         
      63                 :         zend_hash_init(ctx->tags, 0, NULL, NULL, 1);
      64                 :         
      65                 :         for (key = php_strtok_r(tmp, ",", &lasts);
      66                 :                         key;
      67                 :                         key = php_strtok_r(NULL, ",", &lasts)) {
      68                 :                 char *val;
      69                 : 
      70                 :                 val = strchr(key, '=');
      71                 :                 if (val) {
      72                 :                         char *q;
      73                 :                         int keylen;
      74                 :                         
      75                 :                         *val++ = '\0';
      76                 :                         for (q = key; *q; q++)
      77                 :                                 *q = tolower(*q);
      78                 :                         keylen = q - key;
      79                 :                         /* key is stored withOUT NUL
      80                 :                            val is stored WITH    NUL */
      81                 :                         zend_hash_add(ctx->tags, key, keylen, val, strlen(val)+1, NULL);
      82                 :                 }
      83                 :         }
      84                 : 
      85                 :         efree(tmp);
      86                 : 
      87                 :         return SUCCESS;
      88                 : }
      89                 : 
      90                 : PHP_INI_BEGIN()
      91                 :         STD_PHP_INI_ENTRY("url_rewriter.tags", "a=href,area=href,frame=src,form=,fieldset=", PHP_INI_ALL, OnUpdateTags, url_adapt_state_ex, php_basic_globals, basic_globals)
      92                 : PHP_INI_END()
      93                 : 
      94                 : #line 98 "ext/standard/url_scanner_ex.re"
      95                 : 
      96                 : 
      97                 : #define YYFILL(n) goto done
      98                 : #define YYCTYPE unsigned char
      99                 : #define YYCURSOR p
     100                 : #define YYLIMIT q
     101                 : #define YYMARKER r
     102                 :         
     103                 : static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator)
     104                 : {
     105                 :         register const char *p, *q;
     106                 :         const char *bash = NULL;
     107                 :         const char *sep = "?";
     108                 :         
     109                 :         q = (p = url->c) + url->len;
     110                 : 
     111                 : scan:
     112                 : 
     113                 : #line 114 "ext/standard/url_scanner_ex.c"
     114                 : {
     115                 :         YYCTYPE yych;
     116                 :         static const unsigned char yybm[] = {
     117                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     118                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     119                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     120                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     121                 :                 128, 128, 128,   0, 128, 128, 128, 128, 
     122                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     123                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     124                 :                 128, 128,   0, 128, 128, 128, 128,   0, 
     125                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     126                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     127                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     128                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     129                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     130                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     131                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     132                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     133                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     134                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     135                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     136                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     137                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     138                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     139                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     140                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     141                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     142                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     143                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     144                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     145                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     146                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     147                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     148                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     149                 :         };
     150                 : 
     151              25 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     152              25 :         yych = *YYCURSOR;
     153              25 :         if (yybm[0+yych] & 128) {
     154              18 :                 goto yy8;
     155                 :         }
     156               7 :         if (yych <= '9') goto yy6;
     157               7 :         if (yych >= ';') goto yy4;
     158               0 :         ++YYCURSOR;
     159                 : #line 116 "ext/standard/url_scanner_ex.re"
     160                 :         { smart_str_append(dest, url); return; }
     161                 : #line 162 "ext/standard/url_scanner_ex.c"
     162               7 : yy4:
     163               7 :         ++YYCURSOR;
     164                 : #line 117 "ext/standard/url_scanner_ex.re"
     165                 :         { sep = separator; goto scan; }
     166                 : #line 167 "ext/standard/url_scanner_ex.c"
     167               0 : yy6:
     168               0 :         ++YYCURSOR;
     169                 : #line 118 "ext/standard/url_scanner_ex.re"
     170                 :         { bash = p - 1; goto done; }
     171                 : #line 172 "ext/standard/url_scanner_ex.c"
     172             170 : yy8:
     173             170 :         ++YYCURSOR;
     174             170 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     175             159 :         yych = *YYCURSOR;
     176             159 :         if (yybm[0+yych] & 128) {
     177             152 :                 goto yy8;
     178                 :         }
     179                 : #line 119 "ext/standard/url_scanner_ex.re"
     180                 :         { goto scan; }
     181                 : #line 182 "ext/standard/url_scanner_ex.c"
     182                 : }
     183                 : #line 120 "ext/standard/url_scanner_ex.re"
     184                 : 
     185                 : done:
     186                 :         
     187                 :         /* Don't modify URLs of the format "#mark" */
     188                 :         if (bash && bash - url->c == 0) {
     189                 :                 smart_str_append(dest, url);
     190                 :                 return;
     191                 :         }
     192                 : 
     193                 :         if (bash)
     194                 :                 smart_str_appendl(dest, url->c, bash - url->c);
     195                 :         else
     196                 :                 smart_str_append(dest, url);
     197                 : 
     198                 :         smart_str_appends(dest, sep);
     199                 :         smart_str_append(dest, url_app);
     200                 : 
     201                 :         if (bash)
     202                 :                 smart_str_appendl(dest, bash, q - bash);
     203                 : }
     204                 : 
     205                 : 
     206                 : #undef YYFILL
     207                 : #undef YYCTYPE
     208                 : #undef YYCURSOR
     209                 : #undef YYLIMIT
     210                 : #undef YYMARKER
     211                 : 
     212                 : static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type TSRMLS_DC)
     213                 : {
     214                 :         char f = 0;
     215                 : 
     216                 :         if (strncasecmp(ctx->arg.c, ctx->lookup_data, ctx->arg.len) == 0)
     217                 :                 f = 1;
     218                 : 
     219                 :         if (quotes)
     220                 :                 smart_str_appendc(&ctx->result, type);
     221                 :         if (f) {
     222                 :                 append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output);
     223                 :         } else {
     224                 :                 smart_str_append(&ctx->result, &ctx->val);
     225                 :         }
     226                 :         if (quotes)
     227                 :                 smart_str_appendc(&ctx->result, type);
     228                 : }
     229                 : 
     230                 : enum {
     231                 :         STATE_PLAIN = 0,
     232                 :         STATE_TAG,
     233                 :         STATE_NEXT_ARG,
     234                 :         STATE_ARG,
     235                 :         STATE_BEFORE_VAL,
     236                 :         STATE_VAL
     237                 : };
     238                 : 
     239                 : #define YYFILL(n) goto stop
     240                 : #define YYCTYPE unsigned char
     241                 : #define YYCURSOR xp
     242                 : #define YYLIMIT end
     243                 : #define YYMARKER q
     244                 : #define STATE ctx->state
     245                 : 
     246                 : #define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR TSRMLS_DC
     247                 : #define STD_ARGS ctx, start, xp TSRMLS_CC
     248                 : 
     249                 : #if SCANNER_DEBUG
     250                 : #define scdebug(x) printf x
     251                 : #else
     252                 : #define scdebug(x)
     253                 : #endif
     254                 : 
     255                 : static inline void passthru(STD_PARA) 
     256                 : {
     257                 :         scdebug(("appending %d chars, starting with %c\n", YYCURSOR-start, *start));
     258                 :         smart_str_appendl(&ctx->result, start, YYCURSOR - start);
     259                 : }
     260                 : 
     261                 : /*
     262                 :  * This function appends a hidden input field after a <form> or
     263                 :  * <fieldset>.  The latter is important for XHTML.
     264                 :  */
     265                 : 
     266                 : static void handle_form(STD_PARA) 
     267                 : {
     268                 :         int doit = 0;
     269                 : 
     270                 :         if (ctx->form_app.len > 0) {
     271                 :                 switch (ctx->tag.len) {
     272                 :                         case sizeof("form") - 1:
     273                 :                                 if (!strncasecmp(ctx->tag.c, "form", sizeof("form") - 1)) {
     274                 :                                         doit = 1;               
     275                 :                                 }
     276                 :                                 if (doit && ctx->val.c && ctx->lookup_data && *ctx->lookup_data) {
     277                 :                                         char *e, *p = zend_memnstr(ctx->val.c, "://", sizeof("://") - 1, ctx->val.c + ctx->val.len);
     278                 :                                         if (p) {
     279                 :                                                 e = memchr(p, '/', (ctx->val.c + ctx->val.len) - p);
     280                 :                                                 if (!e) {
     281                 :                                                         e = ctx->val.c + ctx->val.len;
     282                 :                                                 }
     283                 :                                                 if ((e - p) && strncasecmp(p, ctx->lookup_data, (e - p))) {
     284                 :                                                         doit = 0;
     285                 :                                                 }
     286                 :                                         }
     287                 :                                 }
     288                 :                                 break;
     289                 : 
     290                 :                         case sizeof("fieldset") - 1:
     291                 :                                 if (!strncasecmp(ctx->tag.c, "fieldset", sizeof("fieldset") - 1)) {
     292                 :                                         doit = 1;               
     293                 :                                 }
     294                 :                                 break;
     295                 :                 }
     296                 : 
     297                 :                 if (doit)
     298                 :                         smart_str_append(&ctx->result, &ctx->form_app);
     299                 :         }
     300                 : }
     301                 : 
     302                 : /*
     303                 :  *  HANDLE_TAG copies the HTML Tag and checks whether we 
     304                 :  *  have that tag in our table. If we might modify it,
     305                 :  *  we continue to scan the tag, otherwise we simply copy the complete
     306                 :  *  HTML stuff to the result buffer.
     307                 :  */
     308                 : 
     309                 : static inline void handle_tag(STD_PARA) 
     310                 : {
     311                 :         int ok = 0;
     312                 :         int i;
     313                 : 
     314                 :         ctx->tag.len = 0;
     315                 :         smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
     316                 :         for (i = 0; i < ctx->tag.len; i++)
     317                 :                 ctx->tag.c[i] = tolower((int)(unsigned char)ctx->tag.c[i]);
     318                 :         if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS)
     319                 :                 ok = 1;
     320                 :         STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
     321                 : }
     322                 : 
     323                 : static inline void handle_arg(STD_PARA) 
     324                 : {
     325                 :         ctx->arg.len = 0;
     326                 :         smart_str_appendl(&ctx->arg, start, YYCURSOR - start);
     327                 : }
     328                 : 
     329                 : static inline void handle_val(STD_PARA, char quotes, char type) 
     330                 : {
     331                 :         smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2);
     332                 :         tag_arg(ctx, quotes, type TSRMLS_CC);
     333                 : }
     334                 : 
     335                 : static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen TSRMLS_DC)
     336                 : {
     337                 :         char *end, *q;
     338                 :         char *xp;
     339                 :         char *start;
     340                 :         int rest;
     341                 : 
     342                 :         smart_str_appendl(&ctx->buf, newdata, newlen);
     343                 :         
     344                 :         YYCURSOR = ctx->buf.c;
     345                 :         YYLIMIT = ctx->buf.c + ctx->buf.len;
     346                 : 
     347                 :         switch (STATE) {
     348                 :                 case STATE_PLAIN: goto state_plain;
     349                 :                 case STATE_TAG: goto state_tag;
     350                 :                 case STATE_NEXT_ARG: goto state_next_arg;
     351                 :                 case STATE_ARG: goto state_arg;
     352                 :                 case STATE_BEFORE_VAL: goto state_before_val;
     353                 :                 case STATE_VAL: goto state_val;
     354                 :         }
     355                 :         
     356                 : 
     357                 : state_plain_begin:
     358                 :         STATE = STATE_PLAIN;
     359                 :         
     360                 : state_plain:
     361                 :         start = YYCURSOR;
     362                 : 
     363                 : #line 364 "ext/standard/url_scanner_ex.c"
     364                 : {
     365                 :         YYCTYPE yych;
     366                 :         static const unsigned char yybm[] = {
     367                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     368                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     369                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     370                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     371                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     372                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     373                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     374                 :                 128, 128, 128, 128,   0, 128, 128, 128, 
     375                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     376                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     377                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     378                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     379                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     380                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     381                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     382                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     383                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     384                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     385                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     386                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     387                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     388                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     389                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     390                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     391                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     392                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     393                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     394                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     395                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     396                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     397                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     398                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     399                 :         };
     400              76 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     401              75 :         yych = *YYCURSOR;
     402              75 :         if (yybm[0+yych] & 128) {
     403              38 :                 goto yy15;
     404                 :         }
     405              37 :         ++YYCURSOR;
     406                 : #line 299 "ext/standard/url_scanner_ex.re"
     407                 :         { passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
     408                 : #line 409 "ext/standard/url_scanner_ex.c"
     409             596 : yy15:
     410             596 :         ++YYCURSOR;
     411             596 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     412             582 :         yych = *YYCURSOR;
     413             582 :         if (yybm[0+yych] & 128) {
     414             558 :                 goto yy15;
     415                 :         }
     416                 : #line 300 "ext/standard/url_scanner_ex.re"
     417                 :         { passthru(STD_ARGS); goto state_plain; }
     418                 : #line 419 "ext/standard/url_scanner_ex.c"
     419                 : }
     420                 : #line 301 "ext/standard/url_scanner_ex.re"
     421                 : 
     422                 : 
     423                 : state_tag:      
     424                 :         start = YYCURSOR;
     425                 : 
     426                 : #line 427 "ext/standard/url_scanner_ex.c"
     427                 : {
     428                 :         YYCTYPE yych;
     429                 :         static const unsigned char yybm[] = {
     430                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     431                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     432                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     433                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     434                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     435                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     436                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     437                 :                   0,   0, 128,   0,   0,   0,   0,   0, 
     438                 :                   0, 128, 128, 128, 128, 128, 128, 128, 
     439                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     440                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     441                 :                 128, 128, 128,   0,   0,   0,   0,   0, 
     442                 :                   0, 128, 128, 128, 128, 128, 128, 128, 
     443                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     444                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     445                 :                 128, 128, 128,   0,   0,   0,   0,   0, 
     446                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     447                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     448                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     449                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     450                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     451                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     452                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     453                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     454                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     455                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     456                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     457                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     458                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     459                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     460                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     461                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     462                 :         };
     463              37 :         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
     464              37 :         yych = *YYCURSOR;
     465              37 :         if (yych <= '@') {
     466              10 :                 if (yych != ':') goto yy22;
     467                 :         } else {
     468              27 :                 if (yych <= 'Z') goto yy20;
     469              27 :                 if (yych <= '`') goto yy22;
     470              27 :                 if (yych >= '{') goto yy22;
     471                 :         }
     472              27 : yy20:
     473              27 :         ++YYCURSOR;
     474              27 :         yych = *YYCURSOR;
     475              27 :         goto yy25;
     476              27 : yy21:
     477                 : #line 306 "ext/standard/url_scanner_ex.re"
     478                 :         { handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
     479                 : #line 480 "ext/standard/url_scanner_ex.c"
     480              10 : yy22:
     481              10 :         ++YYCURSOR;
     482                 : #line 307 "ext/standard/url_scanner_ex.re"
     483                 :         { passthru(STD_ARGS); goto state_plain_begin; }
     484                 : #line 485 "ext/standard/url_scanner_ex.c"
     485              58 : yy24:
     486              58 :         ++YYCURSOR;
     487              58 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     488              58 :         yych = *YYCURSOR;
     489              85 : yy25:
     490              85 :         if (yybm[0+yych] & 128) {
     491              58 :                 goto yy24;
     492                 :         }
     493              27 :         goto yy21;
     494                 : }
     495                 : #line 308 "ext/standard/url_scanner_ex.re"
     496                 : 
     497                 : 
     498                 : state_next_arg_begin:
     499                 :         STATE = STATE_NEXT_ARG;
     500                 :         
     501                 : state_next_arg:
     502                 :         start = YYCURSOR;
     503                 : 
     504                 : #line 505 "ext/standard/url_scanner_ex.c"
     505                 : {
     506                 :         YYCTYPE yych;
     507                 :         static const unsigned char yybm[] = {
     508                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     509                 :                   0, 128, 128, 128,   0, 128,   0,   0, 
     510                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     511                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     512                 :                 128,   0,   0,   0,   0,   0,   0,   0, 
     513                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     514                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     515                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     516                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     517                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     518                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     519                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     520                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     521                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     522                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     523                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     524                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     525                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     526                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     527                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     528                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     529                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     530                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     531                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     532                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     533                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     534                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     535                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     536                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     537                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     538                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     539                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     540                 :         };
     541              47 :         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
     542              47 :         yych = *YYCURSOR;
     543              47 :         if (yych <= ' ') {
     544              15 :                 if (yych <= '\f') {
     545               1 :                         if (yych <= 0x08) goto yy34;
     546               1 :                         if (yych <= '\v') goto yy30;
     547               0 :                         goto yy34;
     548                 :                 } else {
     549              14 :                         if (yych <= '\r') goto yy30;
     550              14 :                         if (yych <= 0x1F) goto yy34;
     551              14 :                         goto yy30;
     552                 :                 }
     553                 :         } else {
     554              32 :                 if (yych <= '@') {
     555              17 :                         if (yych != '>') goto yy34;
     556                 :                 } else {
     557              15 :                         if (yych <= 'Z') goto yy32;
     558              15 :                         if (yych <= '`') goto yy34;
     559              15 :                         if (yych <= 'z') goto yy32;
     560               0 :                         goto yy34;
     561                 :                 }
     562                 :         }
     563              17 :         ++YYCURSOR;
     564                 : #line 316 "ext/standard/url_scanner_ex.re"
     565                 :         { passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
     566                 : #line 567 "ext/standard/url_scanner_ex.c"
     567              15 : yy30:
     568              15 :         ++YYCURSOR;
     569              15 :         yych = *YYCURSOR;
     570              15 :         goto yy37;
     571              15 : yy31:
     572                 : #line 317 "ext/standard/url_scanner_ex.re"
     573                 :         { passthru(STD_ARGS); goto state_next_arg; }
     574                 : #line 575 "ext/standard/url_scanner_ex.c"
     575              15 : yy32:
     576              15 :         ++YYCURSOR;
     577                 : #line 318 "ext/standard/url_scanner_ex.re"
     578                 :         { --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
     579                 : #line 580 "ext/standard/url_scanner_ex.c"
     580               0 : yy34:
     581               0 :         ++YYCURSOR;
     582                 : #line 319 "ext/standard/url_scanner_ex.re"
     583                 :         { passthru(STD_ARGS); goto state_plain_begin; }
     584                 : #line 585 "ext/standard/url_scanner_ex.c"
     585               7 : yy36:
     586               7 :         ++YYCURSOR;
     587               7 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     588               7 :         yych = *YYCURSOR;
     589              22 : yy37:
     590              22 :         if (yybm[0+yych] & 128) {
     591               7 :                 goto yy36;
     592                 :         }
     593              15 :         goto yy31;
     594                 : }
     595                 : #line 320 "ext/standard/url_scanner_ex.re"
     596                 : 
     597                 : 
     598                 : state_arg:
     599                 :         start = YYCURSOR;
     600                 : 
     601                 : #line 602 "ext/standard/url_scanner_ex.c"
     602                 : {
     603                 :         YYCTYPE yych;
     604                 :         static const unsigned char yybm[] = {
     605                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     606                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     607                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     608                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     609                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     610                 :                   0,   0,   0,   0,   0, 128,   0,   0, 
     611                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     612                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     613                 :                   0, 128, 128, 128, 128, 128, 128, 128, 
     614                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     615                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     616                 :                 128, 128, 128,   0,   0,   0,   0,   0, 
     617                 :                   0, 128, 128, 128, 128, 128, 128, 128, 
     618                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     619                 :                 128, 128, 128, 128, 128, 128, 128, 128, 
     620                 :                 128, 128, 128,   0,   0,   0,   0,   0, 
     621                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     622                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     623                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     624                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     625                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     626                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     627                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     628                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     629                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     630                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     631                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     632                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     633                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     634                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     635                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     636                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     637                 :         };
     638              15 :         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
     639              15 :         yych = *YYCURSOR;
     640              15 :         if (yych <= '@') goto yy42;
     641              15 :         if (yych <= 'Z') goto yy40;
     642              15 :         if (yych <= '`') goto yy42;
     643              15 :         if (yych >= '{') goto yy42;
     644              15 : yy40:
     645              15 :         ++YYCURSOR;
     646              15 :         yych = *YYCURSOR;
     647              15 :         goto yy45;
     648              15 : yy41:
     649                 : #line 325 "ext/standard/url_scanner_ex.re"
     650                 :         { passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
     651                 : #line 652 "ext/standard/url_scanner_ex.c"
     652               0 : yy42:
     653               0 :         ++YYCURSOR;
     654                 : #line 326 "ext/standard/url_scanner_ex.re"
     655                 :         { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; }
     656                 : #line 657 "ext/standard/url_scanner_ex.c"
     657              59 : yy44:
     658              59 :         ++YYCURSOR;
     659              59 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     660              59 :         yych = *YYCURSOR;
     661              74 : yy45:
     662              74 :         if (yybm[0+yych] & 128) {
     663              59 :                 goto yy44;
     664                 :         }
     665              15 :         goto yy41;
     666                 : }
     667                 : #line 327 "ext/standard/url_scanner_ex.re"
     668                 : 
     669                 : 
     670                 : state_before_val:
     671                 :         start = YYCURSOR;
     672                 : 
     673                 : #line 674 "ext/standard/url_scanner_ex.c"
     674                 : {
     675                 :         YYCTYPE yych;
     676                 :         static const unsigned char yybm[] = {
     677                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     678                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     679                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     680                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     681                 :                 128,   0,   0,   0,   0,   0,   0,   0, 
     682                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     683                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     684                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     685                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     686                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     687                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     688                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     689                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     690                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     691                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     692                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     693                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     694                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     695                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     696                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     697                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     698                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     699                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     700                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     701                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     702                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     703                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     704                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     705                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     706                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     707                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     708                 :                   0,   0,   0,   0,   0,   0,   0,   0, 
     709                 :         };
     710              15 :         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
     711              15 :         yych = *YYCURSOR;
     712              15 :         if (yych == ' ') goto yy48;
     713              15 :         if (yych == '=') goto yy50;
     714               0 :         goto yy52;
     715               0 : yy48:
     716               0 :         yych = *(YYMARKER = ++YYCURSOR);
     717               0 :         if (yych == ' ') goto yy55;
     718               0 :         if (yych == '=') goto yy53;
     719               0 : yy49:
     720                 : #line 333 "ext/standard/url_scanner_ex.re"
     721                 :         { --YYCURSOR; goto state_next_arg_begin; }
     722                 : #line 723 "ext/standard/url_scanner_ex.c"
     723              15 : yy50:
     724              15 :         ++YYCURSOR;
     725              15 :         yych = *YYCURSOR;
     726              15 :         goto yy54;
     727              15 : yy51:
     728                 : #line 332 "ext/standard/url_scanner_ex.re"
     729                 :         { passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
     730                 : #line 731 "ext/standard/url_scanner_ex.c"
     731               0 : yy52:
     732               0 :         yych = *++YYCURSOR;
     733               0 :         goto yy49;
     734               0 : yy53:
     735               0 :         ++YYCURSOR;
     736               0 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     737               0 :         yych = *YYCURSOR;
     738              15 : yy54:
     739              15 :         if (yybm[0+yych] & 128) {
     740               0 :                 goto yy53;
     741                 :         }
     742              15 :         goto yy51;
     743               0 : yy55:
     744               0 :         ++YYCURSOR;
     745               0 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     746               0 :         yych = *YYCURSOR;
     747               0 :         if (yych == ' ') goto yy55;
     748               0 :         if (yych == '=') goto yy53;
     749               0 :         YYCURSOR = YYMARKER;
     750               0 :         goto yy49;
     751                 : }
     752                 : #line 334 "ext/standard/url_scanner_ex.re"
     753                 : 
     754                 : 
     755                 : 
     756                 : state_val:
     757                 :         start = YYCURSOR;
     758                 : 
     759                 : #line 760 "ext/standard/url_scanner_ex.c"
     760                 : {
     761                 :         YYCTYPE yych;
     762                 :         static const unsigned char yybm[] = {
     763                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     764                 :                 248, 160, 160, 248, 248, 160, 248, 248, 
     765                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     766                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     767                 :                 160, 248,  56, 248, 248, 248, 248, 200, 
     768                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     769                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     770                 :                 248, 248, 248, 248, 248, 248,   0, 248, 
     771                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     772                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     773                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     774                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     775                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     776                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     777                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     778                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     779                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     780                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     781                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     782                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     783                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     784                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     785                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     786                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     787                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     788                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     789                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     790                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     791                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     792                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     793                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     794                 :                 248, 248, 248, 248, 248, 248, 248, 248, 
     795                 :         };
     796              15 :         if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
     797              15 :         yych = *YYCURSOR;
     798              15 :         if (yych <= ' ') {
     799               0 :                 if (yych <= '\f') {
     800               0 :                         if (yych <= 0x08) goto yy63;
     801               0 :                         if (yych <= '\n') goto yy64;
     802               0 :                         goto yy63;
     803                 :                 } else {
     804               0 :                         if (yych <= '\r') goto yy64;
     805               0 :                         if (yych <= 0x1F) goto yy63;
     806               0 :                         goto yy64;
     807                 :                 }
     808                 :         } else {
     809              15 :                 if (yych <= '&') {
     810              12 :                         if (yych != '"') goto yy63;
     811                 :                 } else {
     812               3 :                         if (yych <= '\'') goto yy62;
     813               1 :                         if (yych == '>') goto yy64;
     814               1 :                         goto yy63;
     815                 :                 }
     816                 :         }
     817              12 :         yych = *(YYMARKER = ++YYCURSOR);
     818              12 :         goto yy77;
     819               1 : yy61:
     820                 : #line 342 "ext/standard/url_scanner_ex.re"
     821                 :         { handle_val(STD_ARGS, 0, ' '); goto state_next_arg_begin; }
     822                 : #line 823 "ext/standard/url_scanner_ex.c"
     823               2 : yy62:
     824               2 :         yych = *(YYMARKER = ++YYCURSOR);
     825               2 :         goto yy69;
     826               1 : yy63:
     827               1 :         yych = *++YYCURSOR;
     828               1 :         goto yy67;
     829               0 : yy64:
     830               0 :         ++YYCURSOR;
     831                 : #line 343 "ext/standard/url_scanner_ex.re"
     832                 :         { passthru(STD_ARGS); goto state_next_arg_begin; }
     833                 : #line 834 "ext/standard/url_scanner_ex.c"
     834               6 : yy66:
     835               6 :         ++YYCURSOR;
     836               6 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     837               6 :         yych = *YYCURSOR;
     838               7 : yy67:
     839               7 :         if (yybm[0+yych] & 8) {
     840               6 :                 goto yy66;
     841                 :         }
     842               1 :         goto yy61;
     843              10 : yy68:
     844              10 :         YYMARKER = ++YYCURSOR;
     845              10 :         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
     846              10 :         yych = *YYCURSOR;
     847              12 : yy69:
     848              12 :         if (yybm[0+yych] & 16) {
     849              10 :                 goto yy68;
     850                 :         }
     851               2 :         if (yych <= '&') goto yy72;
     852               2 :         if (yych >= '(') goto yy61;
     853               2 :         ++YYCURSOR;
     854               2 :         if (yybm[0+(yych = *YYCURSOR)] & 8) {
     855               0 :                 goto yy66;
     856                 :         }
     857               2 : yy71:
     858                 : #line 341 "ext/standard/url_scanner_ex.re"
     859                 :         { handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
     860                 : #line 861 "ext/standard/url_scanner_ex.c"
     861               0 : yy72:
     862               0 :         ++YYCURSOR;
     863               0 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     864               0 :         yych = *YYCURSOR;
     865               0 :         if (yybm[0+yych] & 32) {
     866               0 :                 goto yy72;
     867                 :         }
     868               0 :         if (yych <= '=') goto yy75;
     869               0 : yy74:
     870               0 :         YYCURSOR = YYMARKER;
     871               0 :         goto yy61;
     872               0 : yy75:
     873               0 :         yych = *++YYCURSOR;
     874               0 :         goto yy71;
     875             189 : yy76:
     876             189 :         YYMARKER = ++YYCURSOR;
     877             189 :         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
     878             189 :         yych = *YYCURSOR;
     879             201 : yy77:
     880             201 :         if (yybm[0+yych] & 64) {
     881             189 :                 goto yy76;
     882                 :         }
     883              12 :         if (yych <= '!') goto yy80;
     884               9 :         if (yych >= '#') goto yy61;
     885               9 :         ++YYCURSOR;
     886               9 :         if (yybm[0+(yych = *YYCURSOR)] & 8) {
     887               0 :                 goto yy66;
     888                 :         }
     889              12 : yy79:
     890                 : #line 340 "ext/standard/url_scanner_ex.re"
     891                 :         { handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
     892                 : #line 893 "ext/standard/url_scanner_ex.c"
     893              67 : yy80:
     894              67 :         ++YYCURSOR;
     895              67 :         if (YYLIMIT <= YYCURSOR) YYFILL(1);
     896              67 :         yych = *YYCURSOR;
     897              67 :         if (yybm[0+yych] & 128) {
     898              64 :                 goto yy80;
     899                 :         }
     900               3 :         if (yych >= '>') goto yy74;
     901               3 :         ++YYCURSOR;
     902               3 :         yych = *YYCURSOR;
     903               3 :         goto yy79;
     904                 : }
     905                 : #line 344 "ext/standard/url_scanner_ex.re"
     906                 : 
     907                 : 
     908                 : stop:
     909                 :         rest = YYLIMIT - start;
     910                 :         scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest));
     911                 :         /* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */    
     912                 :         if (rest < 0) rest = 0;
     913                 :         
     914                 :         if (rest) memmove(ctx->buf.c, start, rest);
     915                 :         ctx->buf.len = rest;
     916                 : }
     917                 : 
     918                 : char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen TSRMLS_DC)
     919                 : {
     920                 :         smart_str surl = {0};
     921                 :         smart_str buf = {0};
     922                 :         smart_str url_app = {0};
     923                 : 
     924                 :         smart_str_setl(&surl, url, urllen);
     925                 : 
     926                 :         smart_str_appends(&url_app, name);
     927                 :         smart_str_appendc(&url_app, '=');
     928                 :         smart_str_appends(&url_app, value);
     929                 : 
     930                 :         append_modified_url(&surl, &buf, &url_app, PG(arg_separator).output);
     931                 : 
     932                 :         smart_str_0(&buf);
     933                 :         if (newlen) *newlen = buf.len;
     934                 : 
     935                 :         smart_str_free(&url_app);
     936                 : 
     937                 :         return buf.c;
     938                 : }
     939                 : 
     940                 : 
     941                 : static char *url_adapt_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush TSRMLS_DC)
     942                 : {
     943                 :         url_adapt_state_ex_t *ctx;
     944                 :         char *retval;
     945                 : 
     946                 :         ctx = &BG(url_adapt_state_ex);
     947                 : 
     948                 :         xx_mainloop(ctx, src, srclen TSRMLS_CC);
     949                 : 
     950                 :         *newlen = ctx->result.len;
     951                 :         if (!ctx->result.c) {
     952                 :                 smart_str_appendl(&ctx->result, "", 0);
     953                 :         }
     954                 :         smart_str_0(&ctx->result);
     955                 :         if (do_flush) {
     956                 :                 smart_str_appendl(&ctx->result, ctx->buf.c, ctx->buf.len);
     957                 :                 *newlen += ctx->buf.len;
     958                 :                 smart_str_free(&ctx->buf);
     959                 :         }
     960                 :         retval = ctx->result.c;
     961                 :         ctx->result.c = NULL;
     962                 :         ctx->result.len = 0;
     963                 :         return retval;
     964                 : }
     965                 : 
     966                 : static int php_url_scanner_ex_activate(TSRMLS_D)
     967                 : {
     968                 :         url_adapt_state_ex_t *ctx;
     969                 :         
     970                 :         ctx = &BG(url_adapt_state_ex);
     971                 : 
     972                 :         memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags));
     973                 : 
     974                 :         return SUCCESS;
     975                 : }
     976                 : 
     977                 : static int php_url_scanner_ex_deactivate(TSRMLS_D)
     978                 : {
     979                 :         url_adapt_state_ex_t *ctx;
     980                 :         
     981                 :         ctx = &BG(url_adapt_state_ex);
     982                 : 
     983                 :         smart_str_free(&ctx->result);
     984                 :         smart_str_free(&ctx->buf);
     985                 :         smart_str_free(&ctx->tag);
     986                 :         smart_str_free(&ctx->arg);
     987                 : 
     988                 :         return SUCCESS;
     989                 : }
     990                 : 
     991                 : static void php_url_scanner_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
     992                 : {
     993                 :         size_t len;
     994                 : 
     995                 :         if (BG(url_adapt_state_ex).url_app.len != 0) {
     996                 :                 *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0) TSRMLS_CC);
     997                 :                 if (sizeof(uint) < sizeof(size_t)) {
     998                 :                         if (len > UINT_MAX)
     999                 :                                 len = UINT_MAX;
    1000                 :                 }
    1001                 :                 *handled_output_len = len;
    1002                 :         } else if (BG(url_adapt_state_ex).url_app.len == 0) {
    1003                 :                 url_adapt_state_ex_t *ctx = &BG(url_adapt_state_ex);
    1004                 :                 if (ctx->buf.len) {
    1005                 :                         smart_str_appendl(&ctx->result, ctx->buf.c, ctx->buf.len);
    1006                 :                         smart_str_appendl(&ctx->result, output, output_len);
    1007                 : 
    1008                 :                         *handled_output = ctx->result.c;
    1009                 :                         *handled_output_len = ctx->buf.len + output_len;
    1010                 : 
    1011                 :                         ctx->result.c = NULL;
    1012                 :                         ctx->result.len = 0;
    1013                 :                         smart_str_free(&ctx->buf);
    1014                 :                 } else {
    1015                 :                         *handled_output = NULL;
    1016                 :                 }
    1017                 :         } else {
    1018                 :                 *handled_output = NULL;
    1019                 :         }
    1020                 : }
    1021                 : 
    1022                 : PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC)
    1023                 : {
    1024                 :         char *encoded;
    1025                 :         int encoded_len;
    1026                 :         smart_str val;
    1027                 :         zval *ob_name;
    1028                 :         
    1029                 :         if (! BG(url_adapt_state_ex).active) {
    1030                 :                 MAKE_STD_ZVAL(ob_name);
    1031                 :                 ZVAL_ASCII_STRING(ob_name, "URL-Rewriter", ZSTR_DUPLICATE);
    1032                 :                 php_url_scanner_ex_activate(TSRMLS_C);
    1033                 :                 php_output_start_internal(ob_name, php_url_scanner_output_handler, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
    1034                 :                 BG(url_adapt_state_ex).active = 1;
    1035                 :                 zval_ptr_dtor(&ob_name);
    1036                 :         }
    1037                 : 
    1038                 : 
    1039                 :         if (BG(url_adapt_state_ex).url_app.len != 0) {
    1040                 :                 smart_str_appends(&BG(url_adapt_state_ex).url_app, PG(arg_separator).output);
    1041                 :         }
    1042                 : 
    1043                 :         if (urlencode) {
    1044                 :                 encoded = php_url_encode(value, value_len, &encoded_len);
    1045                 :                 smart_str_setl(&val, encoded, encoded_len);
    1046                 :         } else {
    1047                 :                 smart_str_setl(&val, value, value_len);
    1048                 :         }
    1049                 :         
    1050                 :         smart_str_appendl(&BG(url_adapt_state_ex).url_app, name, name_len);
    1051                 :         smart_str_appendc(&BG(url_adapt_state_ex).url_app, '=');
    1052                 :         smart_str_append(&BG(url_adapt_state_ex).url_app, &val);
    1053                 : 
    1054                 :         smart_str_appends(&BG(url_adapt_state_ex).form_app, "<input type=\"hidden\" name=\""); 
    1055                 :         smart_str_appendl(&BG(url_adapt_state_ex).form_app, name, name_len);
    1056                 :         smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" value=\"");
    1057                 :         smart_str_append(&BG(url_adapt_state_ex).form_app, &val);
    1058                 :         smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" />");
    1059                 : 
    1060                 :         if (urlencode)
    1061                 :                 efree(encoded);
    1062                 : 
    1063                 :         return SUCCESS;
    1064                 : }
    1065                 : 
    1066                 : PHPAPI int php_url_scanner_reset_vars(TSRMLS_D)
    1067                 : {
    1068                 :         BG(url_adapt_state_ex).form_app.len = 0;
    1069                 :         BG(url_adapt_state_ex).url_app.len = 0;
    1070                 : 
    1071                 :         return SUCCESS;
    1072                 : }
    1073                 : 
    1074                 : PHP_MINIT_FUNCTION(url_scanner)
    1075                 : {
    1076                 :         BG(url_adapt_state_ex).tags = NULL;
    1077                 : 
    1078                 :         BG(url_adapt_state_ex).form_app.c = BG(url_adapt_state_ex).url_app.c = 0;
    1079                 :         BG(url_adapt_state_ex).form_app.len = BG(url_adapt_state_ex).url_app.len = 0;
    1080                 : 
    1081                 :         REGISTER_INI_ENTRIES();
    1082                 :         return SUCCESS;
    1083                 : }
    1084                 : 
    1085                 : PHP_MSHUTDOWN_FUNCTION(url_scanner)
    1086                 : {
    1087                 :         UNREGISTER_INI_ENTRIES();
    1088                 : 
    1089                 :         return SUCCESS;
    1090                 : }
    1091                 : 
    1092                 : PHP_RINIT_FUNCTION(url_scanner)
    1093                 : {
    1094                 :         BG(url_adapt_state_ex).active = 0;
    1095                 :         
    1096                 :         return SUCCESS;
    1097                 : }
    1098                 : 
    1099                 : PHP_RSHUTDOWN_FUNCTION(url_scanner)
    1100                 : {
    1101                 :         if (BG(url_adapt_state_ex).active) {
    1102                 :                 php_url_scanner_ex_deactivate(TSRMLS_C);
    1103                 :                 BG(url_adapt_state_ex).active = 0;
    1104                 :         }
    1105                 : 
    1106                 :         smart_str_free(&BG(url_adapt_state_ex).form_app);
    1107                 :         smart_str_free(&BG(url_adapt_state_ex).url_app);
    1108                 : 
    1109                 :         return SUCCESS;
    1110                 : }

Generated by: LTP GCOV extension version 1.5

Generated at Mon, 23 Nov 2009 17:39:46 +0000 (36 hours ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.