Back to index

php5  5.3.10
phar_path_check.c
Go to the documentation of this file.
00001 /* Generated by re2c 0.13.5 on Fri Feb 25 04:29:05 2011 */
00002 #line 1 "ext/phar/phar_path_check.re"
00003 /*
00004   +----------------------------------------------------------------------+
00005   | phar php single-file executable PHP extension                        |
00006   +----------------------------------------------------------------------+
00007   | Copyright (c) 2007-2012 The PHP Group                                |
00008   +----------------------------------------------------------------------+
00009   | This source file is subject to version 3.01 of the PHP license,      |
00010   | that is bundled with this package in the file LICENSE, and is        |
00011   | available through the world-wide-web at the following url:           |
00012   | http://www.php.net/license/3_01.txt.                                 |
00013   | If you did not receive a copy of the PHP license and are unable to   |
00014   | obtain it through the world-wide-web, please send a note to          |
00015   | license@php.net so we can mail you a copy immediately.               |
00016   +----------------------------------------------------------------------+
00017   | Authors: Marcus Boerger <helly@php.net>                              |
00018   +----------------------------------------------------------------------+
00019 */
00020 
00021 /* $Id: phar_path_check.c 321634 2012-01-01 13:15:04Z felipe $ */
00022 
00023 #include "phar_internal.h"
00024 
00025 phar_path_check_result phar_path_check(char **s, int *len, const char **error)
00026 {
00027        const unsigned char *p = (const unsigned char*)*s;
00028        const unsigned char *m;
00029 
00030        if (*len == 1 && *p == '.') {
00031               *error = "current directory reference";
00032               return pcr_err_curr_dir;
00033        } else if (*len == 2 && p[0] == '.' && p[1] == '.') {
00034               *error = "upper directory reference";
00035               return pcr_err_up_dir;
00036        }
00037 
00038 #define YYCTYPE         unsigned char
00039 #define YYCURSOR        p
00040 #define YYLIMIT         p+*len
00041 #define YYMARKER        m
00042 #define YYFILL(n)
00043 
00044 loop:
00045 
00046 #line 47 "ext/phar/phar_path_check.c"
00047 {
00048        YYCTYPE yych;
00049 
00050        if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
00051        yych = *YYCURSOR;
00052        if (yych <= '.') {
00053               if (yych <= '\n') {
00054                      if (yych <= 0x00) goto yy13;
00055                      if (yych <= '\t') goto yy10;
00056                      goto yy12;
00057               } else {
00058                      if (yych <= 0x19) goto yy10;
00059                      if (yych == '*') goto yy6;
00060                      goto yy15;
00061               }
00062        } else {
00063               if (yych <= '?') {
00064                      if (yych <= '/') goto yy2;
00065                      if (yych <= '>') goto yy15;
00066                      goto yy8;
00067               } else {
00068                      if (yych == '\\') goto yy4;
00069                      if (yych <= 0x7F) goto yy15;
00070                      goto yy10;
00071               }
00072        }
00073 yy2:
00074        yych = *(YYMARKER = ++YYCURSOR);
00075        if (yych <= '-') goto yy3;
00076        if (yych <= '.') goto yy16;
00077        if (yych <= '/') goto yy18;
00078 yy3:
00079 #line 93 "ext/phar/phar_path_check.re"
00080        {
00081                      goto loop;
00082               }
00083 #line 84 "ext/phar/phar_path_check.c"
00084 yy4:
00085        ++YYCURSOR;
00086 #line 60 "ext/phar/phar_path_check.re"
00087        {
00088                      *error = "back-slash";
00089                      return pcr_err_back_slash;
00090               }
00091 #line 92 "ext/phar/phar_path_check.c"
00092 yy6:
00093        ++YYCURSOR;
00094 #line 64 "ext/phar/phar_path_check.re"
00095        {
00096                      *error = "star";
00097                      return pcr_err_star;
00098               }
00099 #line 100 "ext/phar/phar_path_check.c"
00100 yy8:
00101        ++YYCURSOR;
00102 #line 68 "ext/phar/phar_path_check.re"
00103        {
00104                      if (**s == '/') {
00105                             (*s)++;
00106                      }
00107                      *len = (p - (const unsigned char*)*s) -1;
00108                      *error = NULL;
00109                      return pcr_use_query;
00110               }
00111 #line 112 "ext/phar/phar_path_check.c"
00112 yy10:
00113        ++YYCURSOR;
00114 yy11:
00115 #line 76 "ext/phar/phar_path_check.re"
00116        {
00117                      *error ="illegal character";
00118                      return pcr_err_illegal_char;
00119               }
00120 #line 121 "ext/phar/phar_path_check.c"
00121 yy12:
00122        yych = *++YYCURSOR;
00123        goto yy11;
00124 yy13:
00125        ++YYCURSOR;
00126 #line 80 "ext/phar/phar_path_check.re"
00127        {
00128                      if (**s == '/') {
00129                             (*s)++;
00130                             (*len)--;
00131                      }
00132                      if ((p - (const unsigned char*)*s) - 1 != *len)
00133                      {
00134                             *error ="illegal character";
00135                             return pcr_err_illegal_char;
00136                      }
00137                      *error = NULL;
00138                      return pcr_is_ok;
00139               }
00140 #line 141 "ext/phar/phar_path_check.c"
00141 yy15:
00142        yych = *++YYCURSOR;
00143        goto yy3;
00144 yy16:
00145        yych = *++YYCURSOR;
00146        if (yych <= 0x00) goto yy21;
00147        if (yych <= '-') goto yy17;
00148        if (yych <= '.') goto yy20;
00149        if (yych <= '/') goto yy21;
00150 yy17:
00151        YYCURSOR = YYMARKER;
00152        goto yy3;
00153 yy18:
00154        ++YYCURSOR;
00155 #line 48 "ext/phar/phar_path_check.re"
00156        {
00157                      *error = "double slash";
00158                      return pcr_err_double_slash;
00159               }
00160 #line 161 "ext/phar/phar_path_check.c"
00161 yy20:
00162        yych = *++YYCURSOR;
00163        if (yych <= 0x00) goto yy23;
00164        if (yych == '/') goto yy23;
00165        goto yy17;
00166 yy21:
00167        ++YYCURSOR;
00168 #line 56 "ext/phar/phar_path_check.re"
00169        {
00170                      *error = "current directory reference";
00171                      return pcr_err_curr_dir;
00172               }
00173 #line 174 "ext/phar/phar_path_check.c"
00174 yy23:
00175        ++YYCURSOR;
00176 #line 52 "ext/phar/phar_path_check.re"
00177        {
00178                      *error = "upper directory reference";
00179                      return pcr_err_up_dir;
00180               }
00181 #line 182 "ext/phar/phar_path_check.c"
00182 }
00183 #line 96 "ext/phar/phar_path_check.re"
00184 
00185 }