PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/pecl/slightphp.c

http://slightphp.googlecode.com/
C | 667 lines | 411 code | 110 blank | 146 comment | 74 complexity | 9f60f33be4f89c09c77c2253f2205fe6 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, LGPL-2.1
  1. /*{{{LICENSE
  2. +-----------------------------------------------------------------------+
  3. | slightphp Framework |
  4. +-----------------------------------------------------------------------+
  5. | This program is free software; you can redistribute it and/or modify |
  6. | it under the terms of the GNU General Public License as published by |
  7. | the Free Software Foundation. You should have received a copy of the |
  8. | GNU General Public License along with this program. If not, see |
  9. | http://www.gnu.org/licenses/. |
  10. | Copyright (C) 2008-2009. All Rights Reserved. |
  11. +-----------------------------------------------------------------------+
  12. | Supports: http://www.slightphp.com |
  13. +-----------------------------------------------------------------------+
  14. }}}*/
  15. /* $ Id: $ */
  16. #ifdef HAVE_CONFIG_H
  17. #include "config.h"
  18. #endif
  19. #include "php.h"
  20. #include <regex.h>
  21. #include "ext/standard/info.h"
  22. #include "php_slightphp.h"
  23. typedef struct _op_item{
  24. time_t op_mtime;
  25. zend_op_array op_codes;
  26. }op_item;
  27. /* {{{ Class definitions */
  28. /* {{{ Class slightphp */
  29. static zend_class_entry * slightphp_ce_ptr = NULL;
  30. #include "slightphp_globals.h"
  31. #include "slightphp_globals.c"
  32. /* {{{ Methods */
  33. /* {{{ proto void setAppDir(mixed appDir)
  34. */
  35. PHP_METHOD(slightphp, setAppDir)
  36. {
  37. char* appDir;
  38. int appDir_len;
  39. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &appDir,&appDir_len) == FAILURE) {
  40. RETURN_FALSE;
  41. }
  42. zend_update_static_property_string(slightphp_ce_ptr, "appDir", sizeof("appDir")-1, appDir TSRMLS_CC);
  43. RETURN_TRUE;
  44. }
  45. /* }}} setAppDir */
  46. /* {{{ proto void setPathInfo(mixed pathInfo)
  47. */
  48. PHP_METHOD(slightphp, setPathInfo)
  49. {
  50. char* pathInfo;
  51. int pathInfo_len;
  52. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pathInfo,&pathInfo_len) == FAILURE) {
  53. RETURN_FALSE;
  54. }
  55. zend_update_static_property_string(slightphp_ce_ptr, "pathInfo", sizeof("pathInfo")-1, pathInfo TSRMLS_CC);
  56. RETURN_TRUE;
  57. }
  58. /* }}} setPathInfo */
  59. /* {{{ proto mixed getAppDir()
  60. */
  61. PHP_METHOD(slightphp, getAppDir)
  62. {
  63. zval *data = zend_read_static_property(slightphp_ce_ptr,"appDir",sizeof("appDir")-1,1 TSRMLS_CC);
  64. RETURN_ZVAL(data,1,0);
  65. }
  66. /* }}} getAppDir */
  67. /*
  68. PHP_METHOD(slightphp, setPluginsDir)
  69. {
  70. char * pluginsDir = NULL;
  71. int pluginsDir_len;
  72. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pluginsDir,&pluginsDir_len) == FAILURE) {
  73. RETURN_FALSE;
  74. }
  75. //if (Z_TYPE_P(pluginsDir)!= IS_STRING){ RETURN_FALSE; }
  76. zend_update_static_property_string(slightphp_ce_ptr, "pluginsDir", sizeof("pluginsDir")-1, pluginsDir TSRMLS_CC);
  77. RETURN_TRUE;
  78. }
  79. PHP_METHOD(slightphp, getPluginsDir)
  80. {
  81. zval *data = zend_read_static_property(slightphp_ce_ptr,"pluginsDir",sizeof("pluginsDir")-1,1 TSRMLS_CC);
  82. RETURN_ZVAL(data,1,0);
  83. }
  84. */
  85. PHP_METHOD(slightphp, setDefaultZone)
  86. {
  87. char* defaultZone= NULL;
  88. int defaultZone_len;
  89. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &defaultZone,&defaultZone_len) == FAILURE) {
  90. RETURN_FALSE;
  91. }
  92. zend_update_static_property_string(slightphp_ce_ptr, "defaultZone", sizeof("defaultZone")-1, defaultZone TSRMLS_CC);
  93. RETURN_TRUE;
  94. }
  95. PHP_METHOD(slightphp, getDefaultZone)
  96. {
  97. zval *data = zend_read_static_property(slightphp_ce_ptr,"defaultZone",sizeof("defaultZone")-1,1 TSRMLS_CC);
  98. RETURN_ZVAL(data,1,0);
  99. }
  100. PHP_METHOD(slightphp, setDefaultPage)
  101. {
  102. char * defaultPage= NULL;
  103. int defaultPage_len;
  104. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &defaultPage,&defaultPage_len) == FAILURE) {
  105. RETURN_FALSE;
  106. }
  107. zend_update_static_property_string(slightphp_ce_ptr, "defaultPage", sizeof("defaultPage")-1, defaultPage TSRMLS_CC);
  108. RETURN_TRUE;
  109. }
  110. PHP_METHOD(slightphp, getDefaultPage)
  111. {
  112. zval *data = zend_read_static_property(slightphp_ce_ptr,"defaultPage",sizeof("defaultPage")-1,1 TSRMLS_CC);
  113. RETURN_ZVAL(data,1,0);
  114. }
  115. PHP_METHOD(slightphp, setDefaultEntry)
  116. {
  117. char * defaultEntry= NULL;
  118. int defaultEntry_len;
  119. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &defaultEntry,&defaultEntry_len) == FAILURE) {
  120. RETURN_FALSE;
  121. }
  122. zend_update_static_property_string(slightphp_ce_ptr, "defaultEntry", sizeof("defaultEntry")-1, defaultEntry TSRMLS_CC);
  123. RETURN_TRUE;
  124. }
  125. PHP_METHOD(slightphp, getDefaultEntry)
  126. {
  127. zval *data = zend_read_static_property(slightphp_ce_ptr,"defaultEntry",sizeof("defaultEntry")-1,1 TSRMLS_CC);
  128. RETURN_ZVAL(data,1,0);
  129. }
  130. PHP_METHOD(slightphp, setSplitFlag)
  131. {
  132. char * splitFlag = NULL;
  133. int splitFlag_len;
  134. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &splitFlag, &splitFlag_len) == FAILURE) {
  135. RETURN_FALSE;
  136. }
  137. zend_update_static_property_string(slightphp_ce_ptr, "splitFlag", sizeof("splitFlag")-1, splitFlag TSRMLS_CC);
  138. RETURN_TRUE;
  139. }
  140. PHP_METHOD(slightphp, getSplitFlag)
  141. {
  142. zval *data = zend_read_static_property(slightphp_ce_ptr,"splitFlag",sizeof("splitFlag")-1,1 TSRMLS_CC);
  143. RETURN_ZVAL(data,1,0);
  144. }
  145. PHP_METHOD(slightphp, setZoneAlias)
  146. {
  147. char *zone, *alias;
  148. int zone_len, alias_len;
  149. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &zone, &zone_len, &alias ,&alias_len) == FAILURE) {
  150. RETURN_FALSE;
  151. }
  152. zval *zoneAlias = zend_read_static_property(slightphp_ce_ptr,"zoneAlias",sizeof("zoneAlias")-1,1 TSRMLS_CC);
  153. if(!zoneAlias){ RETURN_FALSE; }
  154. if(Z_TYPE_P(zoneAlias)!=IS_ARRAY){
  155. array_init(zoneAlias);
  156. }
  157. add_assoc_string(zoneAlias,zone,alias,1);
  158. zend_update_static_property(slightphp_ce_ptr,"zoneAlias",sizeof("zoneAlias")-1,zoneAlias TSRMLS_CC);
  159. RETURN_TRUE;
  160. }
  161. PHP_METHOD(slightphp, getZoneAlias)
  162. {
  163. char * zone= NULL;
  164. int zone_len;
  165. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &zone, &zone_len) == FAILURE) {
  166. RETURN_FALSE;
  167. }
  168. zval *zoneAlias = zend_read_static_property(slightphp_ce_ptr,"zoneAlias",sizeof("zoneAlias")-1,1 TSRMLS_CC);
  169. if(!zoneAlias || Z_TYPE_P(zoneAlias)!=IS_ARRAY){ RETURN_FALSE; }
  170. zval **token;
  171. if(zend_hash_find(Z_ARRVAL_P(zoneAlias),zone, zone_len+1, (void**)&token) == SUCCESS) {
  172. *return_value = **token;
  173. zval_copy_ctor(return_value);
  174. }else{
  175. RETURN_FALSE;
  176. }
  177. }
  178. PHP_METHOD(slightphp, setDebug)
  179. {
  180. int _debug;
  181. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &_debug) == FAILURE) {
  182. RETURN_FALSE;
  183. }
  184. zend_update_static_property_long(slightphp_ce_ptr, "_debug", sizeof("_debug")-1, _debug TSRMLS_CC);
  185. RETURN_TRUE;
  186. }
  187. PHP_METHOD(slightphp, getDebug)
  188. {
  189. zval *data = zend_read_static_property(slightphp_ce_ptr,"_debug",sizeof("_debug")-1,1 TSRMLS_CC);
  190. convert_to_long(data);
  191. RETURN_BOOL(Z_LVAL_P(data));
  192. }
  193. /* {{{ proto int loadFile(mixed filepath)
  194. */
  195. /*
  196. PHP_METHOD(slightphp, loadFile)
  197. {
  198. zval * filepath = NULL;
  199. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &filepath) == FAILURE) {
  200. RETURN_FALSE;
  201. }
  202. if (Z_TYPE_P(filepath)!= IS_STRING){
  203. RETURN_FALSE;
  204. }
  205. if(slightphp_loadFile(filepath TSRMLS_CC)==SUCCESS){
  206. RETURN_TRUE;
  207. }else{
  208. RETURN_FALSE;
  209. }
  210. }
  211. */
  212. /* }}} loadFile */
  213. /* {{{ proto int loadPlugin(mixed pluginName)
  214. */
  215. /*
  216. PHP_METHOD(slightphp, loadPlugin)
  217. {
  218. //zval * pluginName = NULL;
  219. char * pluginName = NULL;
  220. int pluginName_len;
  221. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pluginName,&pluginName_len) == FAILURE) {
  222. RETURN_FALSE;
  223. }
  224. zval *pluginsDir = zend_read_static_property(slightphp_ce_ptr,"pluginsDir",sizeof("pluginsDir")-1,1 TSRMLS_CC);
  225. char*inc_filename;
  226. spprintf(&inc_filename,0,"%s%c%s.class.php",Z_STRVAL_P(pluginsDir),DEFAULT_SLASH,pluginName);
  227. zval file_name;
  228. ZVAL_STRING(&file_name,inc_filename,1);
  229. if(slightphp_loadFile(&file_name TSRMLS_CC)==SUCCESS){;
  230. efree(inc_filename);
  231. RETURN_TRUE;
  232. }else{
  233. efree(inc_filename);
  234. RETURN_FALSE;
  235. }
  236. }
  237. */
  238. /* }}} loadPlugin */
  239. /* {{{ proto void __construct([mixed version])
  240. */
  241. PHP_METHOD(slightphp, __construct)
  242. {
  243. zend_class_entry * _this_ce;
  244. zval * _this_zval;
  245. zval * version = NULL;
  246. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/", &version) == FAILURE) {
  247. return;
  248. }
  249. _this_zval = getThis();
  250. _this_ce = Z_OBJCE_P(_this_zval);
  251. }
  252. /* }}} __construct */
  253. /* {{{ proto void run()
  254. */
  255. PHP_METHOD(slightphp, run)
  256. {
  257. zval *zone=NULL;
  258. zval *page=NULL;
  259. zval *entry=NULL;
  260. zval **token;
  261. zval *path_array;
  262. //{{{
  263. int isPart;
  264. zval * path = NULL;
  265. if (ZEND_NUM_ARGS()>0 && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &path) != FAILURE) {
  266. if (Z_TYPE_P(path)!= IS_STRING){
  267. RETURN_FALSE;
  268. }
  269. isPart = 1;
  270. }else{
  271. isPart = 0;
  272. path = zend_read_static_property(slightphp_ce_ptr,"pathInfo",sizeof("pathInfo")-1,1 TSRMLS_CC);
  273. int s = Z_STRLEN_P(path);
  274. if(s==0){
  275. zend_is_auto_global("_SERVER", sizeof("_SERVER") - 1 TSRMLS_CC);
  276. if(zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]),
  277. "PATH_INFO", sizeof("PATH_INFO"), (void **) &token) == SUCCESS
  278. ){
  279. path = *token;
  280. }else if(zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]),
  281. "PATH_INFO", sizeof("PATH_INFO"), (void **) &token) == SUCCESS
  282. ){
  283. path = *token;
  284. }
  285. }
  286. }
  287. //}}}
  288. MAKE_STD_ZVAL(path_array);
  289. array_init(path_array);
  290. if (path){
  291. //{{{
  292. zval quotedFlag;
  293. regex_t re;
  294. char *regex;
  295. regmatch_t subs[1];
  296. int err,size;
  297. char *strp = Z_STRVAL_P(path);
  298. char *endp = strp + Z_STRLEN_P(path);
  299. zval *splitFlag = zend_read_static_property(slightphp_ce_ptr,"splitFlag",sizeof("splitFlag")-1,1 TSRMLS_CC);
  300. if(preg_quote(splitFlag,&quotedFlag)>0){
  301. spprintf(&regex,0,"[%s\\/]",Z_STRVAL(quotedFlag));
  302. }else{
  303. spprintf(&regex,0,"[\\/]");
  304. }
  305. err = regcomp(&re, regex, REG_ICASE);
  306. if (err) {
  307. }else{
  308. while (!(err = regexec(&re, strp, 1, subs, 0))) {
  309. if (subs[0].rm_so == 0 && subs[0].rm_eo) {
  310. //ignore empty string
  311. strp += subs[0].rm_eo;
  312. }else if (subs[0].rm_so == 0 && subs[0].rm_eo == 0) {
  313. }else{
  314. size = subs[0].rm_so;
  315. add_next_index_stringl(path_array, strp, size, 1);
  316. strp += size;
  317. }
  318. }
  319. if (!err || err == REG_NOMATCH) {
  320. size = endp - strp;
  321. if(size>0) add_next_index_stringl(path_array, strp, size, 1);
  322. }
  323. regfree(&re);
  324. }
  325. efree(regex);
  326. //}}}
  327. int n_elems = zend_hash_num_elements(Z_ARRVAL_P(path_array));
  328. if(zend_hash_index_find(Z_ARRVAL_P(path_array), 0, (void **)&token) != FAILURE) {
  329. zone = *token;
  330. }
  331. if(zend_hash_index_find(Z_ARRVAL_P(path_array), 1, (void **)&token) != FAILURE) {
  332. page = *token;
  333. }
  334. if(zend_hash_index_find(Z_ARRVAL_P(path_array), 2, (void **)&token) != FAILURE) {
  335. entry = *token;
  336. }
  337. }
  338. if(!zone){
  339. zone = zend_read_static_property(slightphp_ce_ptr,"defaultZone",sizeof("defaultZone")-1,1 TSRMLS_CC);
  340. zend_hash_next_index_insert(Z_ARRVAL_P(path_array),&zone,sizeof(zval*),NULL);
  341. }
  342. if(!page){
  343. page = zend_read_static_property(slightphp_ce_ptr,"defaultPage",sizeof("defaultPage")-1,1 TSRMLS_CC);
  344. zend_hash_next_index_insert(Z_ARRVAL_P(path_array),&page,sizeof(zval*),NULL);
  345. }
  346. if(!entry){
  347. entry = zend_read_static_property(slightphp_ce_ptr,"defaultEntry",sizeof("defaultEntry")-1,1 TSRMLS_CC);
  348. zend_hash_next_index_insert(Z_ARRVAL_P(path_array),&entry,sizeof(zval*),NULL);
  349. }
  350. //{{{
  351. zval *zoneAlias = zend_read_static_property(slightphp_ce_ptr,"zoneAlias",sizeof("zoneAlias")-1,1 TSRMLS_CC);
  352. if(zoneAlias && Z_TYPE_P(zoneAlias)==IS_ARRAY){
  353. char *string_key;uint str_key_len;ulong num_key;
  354. HashPosition pos;
  355. zval **entry2;
  356. zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zoneAlias), &pos);
  357. while (zend_hash_get_current_data_ex(Z_ARRVAL_P(zoneAlias), (void **)&entry2, &pos) == SUCCESS) {
  358. if(strcmp(Z_STRVAL_PP(entry2) ,Z_STRVAL_P(zone))==0){
  359. switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(zoneAlias), &string_key, &str_key_len, &num_key, 0, &pos)) {
  360. case HASH_KEY_IS_STRING:
  361. ZVAL_STRING(zone,string_key,1);
  362. break;
  363. }
  364. }
  365. zend_hash_move_forward_ex(Z_ARRVAL_P(zoneAlias), &pos);
  366. }
  367. if(entry2)zval_ptr_dtor(entry2);
  368. if(string_key)efree(string_key);
  369. }
  370. //if(zoneAlias)FREE_ZVAL(zoneAlias);
  371. //}}}
  372. if(!isPart){
  373. zend_update_static_property(slightphp_ce_ptr,"zone",sizeof("zone")-1,zone TSRMLS_CC);
  374. zend_update_static_property(slightphp_ce_ptr,"page",sizeof("page")-1,page TSRMLS_CC);
  375. zend_update_static_property(slightphp_ce_ptr,"entry",sizeof("entry")-1,entry TSRMLS_CC);
  376. }else{
  377. if(
  378. strcmp(Z_STRVAL_P(zone),Z_STRVAL_P(zend_read_static_property(slightphp_ce_ptr,"zone",sizeof("zone")-1,1 TSRMLS_CC)))==0
  379. &&
  380. strcmp(Z_STRVAL_P(page),Z_STRVAL_P(zend_read_static_property(slightphp_ce_ptr,"page",sizeof("page")-1,1 TSRMLS_CC)))==0
  381. &&
  382. strcmp(Z_STRVAL_P(entry),Z_STRVAL_P(zend_read_static_property(slightphp_ce_ptr,"entry",sizeof("entry")-1,1 TSRMLS_CC)))==0
  383. ){
  384. debug("part ignored [%s]",Z_STRVAL_P(path));
  385. return;
  386. }
  387. }
  388. zval *appDir = zend_read_static_property(slightphp_ce_ptr,"appDir",sizeof("appDir")-1,1 TSRMLS_CC);
  389. zval *params[1];
  390. params[0]=path_array;
  391. if(slightphp_load(appDir,zone,page TSRMLS_CC) == SUCCESS){
  392. if(slightphp_run(zone,page,entry,return_value,1,params TSRMLS_CC)==SUCCESS){
  393. if(path_array)FREE_ZVAL(path_array);
  394. RETURN_ZVAL(return_value,1,0);
  395. };
  396. }
  397. if(path_array)FREE_ZVAL(path_array);
  398. RETURN_FALSE;
  399. }
  400. /* }}} run */
  401. static zend_function_entry slightphp_methods[] = {
  402. PHP_ME(slightphp, setAppDir, slightphp__setAppDir_args, /**/ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
  403. PHP_ME(slightphp, setPathInfo , slightphp__setPathInfo_args, /**/ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
  404. PHP_ME(slightphp, getAppDir, NULL, /**/ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
  405. //PHP_ME(slightphp, setPluginsDir, slightphp__setPluginsDir_arg, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  406. //PHP_ME(slightphp, getPluginsDir, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  407. PHP_ME(slightphp, setDefaultZone , slightphp__setDefaultZone_arg, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  408. PHP_ME(slightphp, getDefaultZone, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  409. PHP_ME(slightphp, setDefaultPage, slightphp__setDefaultPage_arg, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  410. PHP_ME(slightphp, getDefaultPage, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  411. PHP_ME(slightphp, setDefaultEntry, slightphp__setDefaultEntry_arg, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  412. PHP_ME(slightphp, getDefaultEntry, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  413. PHP_ME(slightphp, setDebug, slightphp__setDebug_arg, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  414. PHP_ME(slightphp, getDebug, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  415. PHP_ME(slightphp, setSplitFlag, slightphp__setSplitFlag_arg, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  416. PHP_ME(slightphp, getSplitFlag, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  417. PHP_ME(slightphp, setZoneAlias, slightphp__setZoneAlias_arg, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  418. PHP_ME(slightphp, getZoneAlias, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  419. //PHP_ME(slightphp, loadFile, slightphp__loadFile_args, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  420. //PHP_ME(slightphp, loadPlugin, slightphp__loadPlugin_args, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
  421. PHP_ME(slightphp, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
  422. PHP_ME(slightphp, run, NULL, /**/ZEND_ACC_STATIC | ZEND_ACC_PUBLIC | ZEND_ACC_FINAL)
  423. { NULL, NULL, NULL }
  424. };
  425. /* }}} Methods */
  426. static void class_init_slightphp(TSRMLS_D)
  427. {
  428. zend_class_entry ce;
  429. INIT_CLASS_ENTRY(ce, "slightphp", slightphp_methods);
  430. slightphp_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
  431. slightphp_ce_ptr->ce_flags |= ZEND_ACC_FINAL_CLASS;
  432. /* {{{ Property registration */
  433. zend_declare_property_string(slightphp_ce_ptr,
  434. "appDir", 6, ".",
  435. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  436. zend_declare_property_string(slightphp_ce_ptr,
  437. "pathInfo", 8, "",
  438. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  439. //zend_declare_property_string(slightphp_ce_ptr,
  440. // "pluginsDir", 10, "plugins",
  441. // ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  442. zend_declare_property_string(slightphp_ce_ptr,
  443. "defaultZone", 11, "zone",
  444. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  445. zend_declare_property_string(slightphp_ce_ptr,
  446. "zone", sizeof("zone")-1, "",
  447. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  448. zend_declare_property_string(slightphp_ce_ptr,
  449. "page", sizeof("page")-1, "",
  450. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  451. zend_declare_property_string(slightphp_ce_ptr,
  452. "entry", sizeof("entry")-1, "",
  453. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  454. zend_declare_property_string(slightphp_ce_ptr,
  455. "defaultPage", sizeof("defaultPage")-1, "page",
  456. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  457. zend_declare_property_string(slightphp_ce_ptr,
  458. "defaultEntry", sizeof("defaultEntry")-1, "entry",
  459. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  460. zend_declare_property_string(slightphp_ce_ptr,
  461. "splitFlag", 9, "/",
  462. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  463. zend_declare_property_null(slightphp_ce_ptr,
  464. "zoneAlias", sizeof("zoneAlias")-1,
  465. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  466. zend_declare_property_long(slightphp_ce_ptr,
  467. "_debug", 6, 0,
  468. ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);
  469. /* }}} Property registration */
  470. }
  471. /* }}} Class slightphp */
  472. /* }}} Class definitions*/
  473. /* {{{ slightphp_functions[] */
  474. function_entry slightphp_functions[] = {
  475. { NULL, NULL, NULL }
  476. };
  477. /* }}} */
  478. /* {{{ cross-extension dependencies */
  479. #if ZEND_EXTENSION_API_NO >= 220050617
  480. static zend_module_dep slightphp_deps[] = {
  481. ZEND_MOD_OPTIONAL("apc")
  482. {NULL, NULL, NULL, 0}
  483. };
  484. #endif
  485. /* }}} */
  486. /* {{{ slightphp_module_entry
  487. */
  488. zend_module_entry slightphp_module_entry = {
  489. #if ZEND_EXTENSION_API_NO >= 220050617
  490. STANDARD_MODULE_HEADER_EX, NULL,
  491. slightphp_deps,
  492. #else
  493. STANDARD_MODULE_HEADER,
  494. #endif
  495. "SlightPHP",
  496. slightphp_functions,
  497. PHP_MINIT(slightphp), /* Replace with NULL if there is nothing to do at php startup */
  498. PHP_MSHUTDOWN(slightphp), /* Replace with NULL if there is nothing to do at php shutdown */
  499. PHP_RINIT(slightphp), /* Replace with NULL if there is nothing to do at request start */
  500. PHP_RSHUTDOWN(slightphp), /* Replace with NULL if there is nothing to do at request end */
  501. PHP_MINFO(slightphp),
  502. "0.1",
  503. STANDARD_MODULE_PROPERTIES
  504. };
  505. /* }}} */
  506. #ifdef COMPILE_DL_SLIGHTPHP
  507. ZEND_GET_MODULE(slightphp)
  508. #endif
  509. /* {{{ PHP_MINIT_FUNCTION */
  510. PHP_MINIT_FUNCTION(slightphp)
  511. {
  512. REGISTER_STRINGL_CONSTANT("slightphp_VERSION", "0.2", 3, CONST_PERSISTENT | CONST_CS);
  513. class_init_slightphp(TSRMLS_C);
  514. return SUCCESS;
  515. }
  516. /* }}} */
  517. /* {{{ PHP_MSHUTDOWN_FUNCTION */
  518. PHP_MSHUTDOWN_FUNCTION(slightphp)
  519. {
  520. return SUCCESS;
  521. }
  522. /* }}} */
  523. /* {{{ PHP_RINIT_FUNCTION */
  524. PHP_RINIT_FUNCTION(slightphp)
  525. {
  526. return SUCCESS;
  527. }
  528. /* }}} */
  529. /* {{{ PHP_RSHUTDOWN_FUNCTION */
  530. PHP_RSHUTDOWN_FUNCTION(slightphp)
  531. {
  532. return SUCCESS;
  533. }
  534. /* }}} */
  535. /* {{{ PHP_MINFO_FUNCTION */
  536. PHP_MINFO_FUNCTION(slightphp)
  537. {
  538. php_info_print_table_start();
  539. php_info_print_table_colspan_header(2,"SlightPHP Framework");
  540. php_info_print_table_row(2, "Version", "1.0 stable (r272) (2011-08-29)" );
  541. php_info_print_table_row(2, "Authors", "admin@slightphp.com, hetao@hetao.name" );
  542. php_info_print_table_row(2, "Supports", "http://code.google.com/p/slightphp/" );
  543. php_info_print_table_end();
  544. /* add your stuff here */
  545. }
  546. /* }}} */
  547. /*
  548. * Local variables:
  549. * tab-width: 4
  550. * c-basic-offset: 4
  551. * End:
  552. * vim600: noet sw=4 ts=4 fdm=marker
  553. * vim<600: noet sw=4 ts=4
  554. */