-/* Generated by re2c 0.5 on Tue Sep 19 20:01:37 2000 */
+/* Generated by re2c 0.5 on Tue Sep 19 20:15:55 2000 */
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
smart_str_append(dest, &s);
}
+static inline void smart_str_setl(smart_str *dest, const char *src, size_t len)
+{
+ dest->len = len;
+ dest->a = len + 1;
+ dest->c = src;
+}
+
static inline void smart_str_appends(smart_str *dest, const char *src)
{
smart_str_appendl(dest, src, strlen(src));
smart_str_copyl(dest, src, strlen(src));
}
+static inline void smart_str_sets(smart_str *dest, const char *src)
+{
+ smart_str_setl(dest, src, strlen(src));
+}
+
static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator)
{
if (strchr(url->c, ':')) return;
smart_str_appends(&ctx->result, "\"");
}
-#line 139
+#line 151
#define NEXT continue
if(yybm[0+yych] & 128) goto yy4;
yy2: yych = *++YYCURSOR;
yy3:
-#line 196
+#line 208
{ tag_start = YYCURSOR; GO(STATE_TAG); COPY_ALL;}
yy4: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy5: if(yybm[0+yych] & 128) goto yy4;
yy6:
-#line 197
+#line 209
{ COPY_ALL; }
}
-#line 198
+#line 210
break;
if(yych == ' ') goto yy12;
if(yych == '>') goto yy12;
yy10:
-#line 213
+#line 225
{
YYCURSOR--;
GO(STATE_PLAIN);
goto yy10;
yy12: yych = *++YYCURSOR;
yy13:
-#line 203
+#line 215
{
YYCURSOR--;
arg_start = YYCURSOR;
case 0: goto yy10;
}
}
-#line 219
+#line 231
break;
yych = *YYCURSOR;
yy21: if(yybm[0+yych] & 128) goto yy20;
yy22:
-#line 224
+#line 236
{
GO(STATE_ARG);
NEXT;
}
yy23: yych = *++YYCURSOR;
yy24:
-#line 228
+#line 240
{
HANDLE_FORM;
GO(STATE_PLAIN);
COPY_ALL;
}
}
-#line 234
+#line 246
break;
if(yych <= '<') goto yy30;
if(yych >= '?') goto yy30;
yy27:
-#line 252
+#line 264
{
arg_start = YYCURSOR;
ctx->state--;
yych = *YYCURSOR;
yy36: if(yych == ' ') goto yy35;
yy37:
-#line 240
+#line 252
{
char *p;
for (p = start; isalpha(*p); p++);
- smart_str_copyl(&ctx->arg, start, p - start);
+ smart_str_setl(&ctx->arg, start, p - start);
#ifdef SCANNER_DEBUG
printf("ARG(%s)\n", ctx->arg.c);
#endif
COPY_ALL;
}
}
-#line 257
+#line 269
break;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '^') goto yy51;
yy41:
-#line 286
+#line 298
{
YYCURSOR--;
ctx->state = 2;
goto yy41;
yy44: yych = *++YYCURSOR;
yy45:
-#line 274
+#line 286
{
YYCURSOR--;
para_start = NULL;
- smart_str_copyl(&ctx->para, start, YYCURSOR - start);
+ smart_str_setl(&ctx->para, start, YYCURSOR - start);
#ifdef SCANNER_DEBUG
printf("PARA(%s)\n", ctx->para.c);
#endif
if(yych != '>') goto yy47;
yy53: yych = *++YYCURSOR;
yy54:
-#line 262
+#line 274
{
YYCURSOR--;
para_start = NULL;
- smart_str_copyl(&ctx->para, start + 1, YYCURSOR - start - 2);
+ smart_str_setl(&ctx->para, start + 1, YYCURSOR - start - 2);
#ifdef SCANNER_DEBUG
printf("PARA(%s)\n", ctx->para.c);
#endif
yy58: yych = *++YYCURSOR;
goto yy54;
}
-#line 291
+#line 303
break;
}
char *ret;
BLS_FETCH();
- smart_str_copys(&BG(url_adapt_state).name, name);
- smart_str_copys(&BG(url_adapt_state).value, value);
+ smart_str_sets(&BG(url_adapt_state).name, name);
+ smart_str_sets(&BG(url_adapt_state).value, value);
str.c = (char *) src;
str.len = srclen;
mainloop(&BG(url_adapt_state), &str);
*newlen = BG(url_adapt_state).result.len;
- //printf("(%d)NEW(%d): %s'\n", srclen, BG(url_adapt_state).result.len, BG(url_adapt_state).result.c);
+#ifdef SCANNER_DEBUG
+ printf("(%d)NEW(%d): %s'\n", srclen, BG(url_adapt_state).result.len, BG(url_adapt_state).result.c);
+#endif
+#if 1
ret = BG(url_adapt_state).result.c;
BG(url_adapt_state).result.c = NULL;
return ret;
+#else
+ return strdup(BG(url_adapt_state).result.c);
+#endif
}
PHP_RINIT_FUNCTION(url_scanner)
{
BLS_FETCH();
- smart_str_free(&BG(url_adapt_state).name);
- smart_str_free(&BG(url_adapt_state).value);
smart_str_free(&BG(url_adapt_state).result);
smart_str_free(&BG(url_adapt_state).work);
- smart_str_free(&BG(url_adapt_state).arg);
- smart_str_free(&BG(url_adapt_state).tag);
- smart_str_free(&BG(url_adapt_state).para);
return SUCCESS;
}
-#if 0
-void main()
-{
- url_adapt_state_t ctx;
- smart_str str = {0};
-
- memset(&ctx, 0, sizeof(ctx));
-
- smart_str_copys(&ctx.name, "PHPSESSID");
- smart_str_copys(&ctx.value, "FOOBAR");
- smart_str_copys(&str, "blabla<HTML>asdasd<a c=d target=_b foobar=x");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "lank dontblink href=someurl onclick=\"xxx\">bla</a>\n<");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "area href=foobar>");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "<form action=blabla ");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "method=post>");
- mainloop(&ctx, &str);
-
- printf("\n%s\n", ctx.result.c);
-}
-#endif
-
#endif
smart_str_append(dest, &s);
}
+static inline void smart_str_setl(smart_str *dest, const char *src, size_t len)
+{
+ dest->len = len;
+ dest->a = len + 1;
+ dest->c = src;
+}
+
static inline void smart_str_appends(smart_str *dest, const char *src)
{
smart_str_appendl(dest, src, strlen(src));
smart_str_copyl(dest, src, strlen(src));
}
+static inline void smart_str_sets(smart_str *dest, const char *src)
+{
+ smart_str_setl(dest, src, strlen(src));
+}
+
static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator)
{
if (strchr(url->c, ':')) return;
char *p;
for (p = start; isalpha(*p); p++);
- smart_str_copyl(&ctx->arg, start, p - start);
+ smart_str_setl(&ctx->arg, start, p - start);
#ifdef SCANNER_DEBUG
printf("ARG(%s)\n", ctx->arg.c);
#endif
["] (all\[^>"])* ["] [ >] {
YYCURSOR--;
para_start = NULL;
- smart_str_copyl(&ctx->para, start + 1, YYCURSOR - start - 2);
+ smart_str_setl(&ctx->para, start + 1, YYCURSOR - start - 2);
#ifdef SCANNER_DEBUG
printf("PARA(%s)\n", ctx->para.c);
#endif
(all\[^> ])+ [ >] {
YYCURSOR--;
para_start = NULL;
- smart_str_copyl(&ctx->para, start, YYCURSOR - start);
+ smart_str_setl(&ctx->para, start, YYCURSOR - start);
#ifdef SCANNER_DEBUG
printf("PARA(%s)\n", ctx->para.c);
#endif
char *ret;
BLS_FETCH();
- smart_str_copys(&BG(url_adapt_state).name, name);
- smart_str_copys(&BG(url_adapt_state).value, value);
+ smart_str_sets(&BG(url_adapt_state).name, name);
+ smart_str_sets(&BG(url_adapt_state).value, value);
str.c = (char *) src;
str.len = srclen;
mainloop(&BG(url_adapt_state), &str);
*newlen = BG(url_adapt_state).result.len;
- //printf("(%d)NEW(%d): %s'\n", srclen, BG(url_adapt_state).result.len, BG(url_adapt_state).result.c);
+#ifdef SCANNER_DEBUG
+ printf("(%d)NEW(%d): %s'\n", srclen, BG(url_adapt_state).result.len, BG(url_adapt_state).result.c);
+#endif
+#if 1
ret = BG(url_adapt_state).result.c;
BG(url_adapt_state).result.c = NULL;
return ret;
+#else
+ return strdup(BG(url_adapt_state).result.c);
+#endif
}
PHP_RINIT_FUNCTION(url_scanner)
{
BLS_FETCH();
- smart_str_free(&BG(url_adapt_state).name);
- smart_str_free(&BG(url_adapt_state).value);
smart_str_free(&BG(url_adapt_state).result);
smart_str_free(&BG(url_adapt_state).work);
- smart_str_free(&BG(url_adapt_state).arg);
- smart_str_free(&BG(url_adapt_state).tag);
- smart_str_free(&BG(url_adapt_state).para);
return SUCCESS;
}
-#if 0
-void main()
-{
- url_adapt_state_t ctx;
- smart_str str = {0};
-
- memset(&ctx, 0, sizeof(ctx));
-
- smart_str_copys(&ctx.name, "PHPSESSID");
- smart_str_copys(&ctx.value, "FOOBAR");
- smart_str_copys(&str, "blabla<HTML>asdasd<a c=d target=_b foobar=x");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "lank dontblink href=someurl onclick=\"xxx\">bla</a>\n<");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "area href=foobar>");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "<form action=blabla ");
- mainloop(&ctx, &str);
- smart_str_copys(&str, "method=post>");
- mainloop(&ctx, &str);
-
- printf("\n%s\n", ctx.result.c);
-}
-#endif
-
#endif