Changeset 1072 for trunk/ext
- Timestamp:
- 09/03/08 00:07:24 (4 months ago)
- Files:
-
- trunk/ext/jelix/jelix.c (modified) (51 diffs)
- trunk/ext/jelix/php_jelix.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ext/jelix/jelix.c
r695 r1072 2 2 * Jelix 3 3 * a php extension for Jelix Framework 4 * @copyright Copyright (c) 2006-200 7Laurent Jouanneau4 * @copyright Copyright (c) 2006-2008 Laurent Jouanneau 5 5 * @author : Laurent Jouanneau 6 6 * @link http://jelix.org … … 62 62 /* {{{ PHP_INI 63 63 */ 64 /* Remove comments and fill if you need to have entries in php.ini65 64 PHP_INI_BEGIN() 66 STD_PHP_INI_ENTRY("jelix.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_jelix_globals, jelix_globals) 67 STD_PHP_INI_ENTRY("jelix.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_jelix_globals, jelix_globals) 65 /* this flag allow to disable some features of the jelix extension, so we can use 66 * dev or opt edition of jelix 67 */ 68 STD_PHP_INI_BOOLEAN("jelix.activated", "1", PHP_INI_SYSTEM, OnUpdateBool, activated, zend_jelix_globals, jelix_globals) 68 69 PHP_INI_END() 69 */ 70 70 71 /* }}} */ 71 72 72 73 /* {{{ php_jelix_init_globals 73 74 */ 74 /* Uncomment this function if you have INI entries 75 75 76 static void php_jelix_init_globals(zend_jelix_globals *jelix_globals) 76 77 { 77 jelix_globals->global_value = 0; 78 jelix_globals->global_string = NULL; 79 } 80 */ 78 jelix_globals->activated = 1; 79 } 80 81 81 /* }}} */ 82 82 … … 85 85 PHP_MINIT_FUNCTION(jelix) 86 86 { 87 /* If you have INI entries, uncomment these lines 88 REGISTER_INI_ENTRIES(); 89 */ 90 91 PHP_MINIT(jelix_interfaces)(INIT_FUNC_ARGS_PASSTHRU); 92 93 REGISTER_STRING_CONSTANT("JELIX_NAMESPACE_BASE", "http://jelix.org/ns/", CONST_CS | CONST_PERSISTENT); 94 95 return SUCCESS; 87 REGISTER_INI_ENTRIES(); 88 if (JELIX_G(activated)) { 89 PHP_MINIT(jelix_interfaces)(INIT_FUNC_ARGS_PASSTHRU); 90 91 REGISTER_STRING_CONSTANT("JELIX_NAMESPACE_BASE", "http://jelix.org/ns/", CONST_CS | CONST_PERSISTENT); 92 } 93 return SUCCESS; 96 94 } 97 95 /* }}} */ … … 101 99 PHP_MSHUTDOWN_FUNCTION(jelix) 102 100 { 103 /* uncomment this line if you have INI entries 104 UNREGISTER_INI_ENTRIES(); 105 */ 106 return SUCCESS; 101 UNREGISTER_INI_ENTRIES(); 102 return SUCCESS; 107 103 } 108 104 /* }}} */ … … 113 109 PHP_RINIT_FUNCTION(jelix) 114 110 { 115 return SUCCESS;111 return SUCCESS; 116 112 } 117 113 /* }}} */ … … 134 130 php_info_print_table_end(); 135 131 136 /* Remove comments if you have entries in php.ini137 132 DISPLAY_INI_ENTRIES(); 138 */139 133 } 140 134 /* }}} */ … … 146 140 { 147 141 if(ZEND_NUM_ARGS() != 0) ZEND_WRONG_PARAM_COUNT() 148 142 149 143 RETURN_STRINGL(JELIX_VERSION, sizeof(JELIX_VERSION)-1, 1); 150 144 } … … 327 321 if(type < 1 || type > 4){ 328 322 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Third argument doesn't correspond to one of JELIX_SEL_* constant"); 329 RETURN_FALSE 323 RETURN_FALSE; 330 324 } 331 325 break;*/ … … 337 331 if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 338 332 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 339 RETURN_FALSE 333 RETURN_FALSE; 340 334 } 341 335 … … 362 356 || ( *cursor >= '0' && *cursor <= '9') 363 357 || *cursor == '_' || *cursor == '.')){ 364 RETURN_FALSE 358 RETURN_FALSE; 365 359 } 366 360 module_length ++; … … 378 372 // to keep compatibily with php version of selectors. 379 373 if(module_length == 0){ 380 RETURN_FALSE 374 RETURN_FALSE; 381 375 } 382 376 … … 390 384 || ( *cursor >= '0' && *cursor <= '9') 391 385 || *cursor == '_' || *cursor == '.')){ 392 RETURN_FALSE 386 RETURN_FALSE; 393 387 } 394 388 resource_length ++; … … 399 393 400 394 if( resource_length == 0 ){ 401 RETURN_FALSE 395 RETURN_FALSE; 402 396 } 403 397 404 398 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1, module, module_length TSRMLS_CC); 405 399 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 406 RETURN_TRUE 400 RETURN_TRUE; 407 401 } 408 402 /* }}} */ … … 430 424 if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 431 425 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 432 RETURN_FALSE 426 RETURN_FALSE; 433 427 } 434 428 if(Z_TYPE_P(*defaultActionArg) != IS_STRING){ 435 429 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid third argument, not a string"); 436 RETURN_FALSE 430 RETURN_FALSE; 437 431 } 438 432 … … 462 456 if(*cursor == '#'){ 463 457 if(sharpOk || module_length > 1){ 464 RETURN_FALSE 458 RETURN_FALSE; 465 459 } 466 460 sharpOk=1; … … 471 465 || ( *cursor >= '0' && *cursor <= '9') 472 466 || *cursor == '_' ) || sharpOk){ 473 RETURN_FALSE 467 RETURN_FALSE; 474 468 } 475 469 if(*cursor == '_' && firstDashPos == -1){ … … 484 478 if(cursor_count >= length){ 485 479 // we don't find any '~' characters, so we have parsed the resource 486 if(hasDot) RETURN_FALSE 480 if(hasDot) RETURN_FALSE; 487 481 488 482 resource_length = module_length; … … 490 484 }else if( *cursor == '@'){ 491 485 // we don't find any '~' characters, so we have parsed the resource 492 if(hasDot) RETURN_FALSE 486 if(hasDot) RETURN_FALSE; 493 487 494 488 resource_length = module_length; … … 506 500 || ( *cursor >= '0' && *cursor <= '9') 507 501 || *cursor == '_' || *cursor == '.')){ 508 RETURN_FALSE 502 RETURN_FALSE; 509 503 } 510 504 request_length ++; … … 516 510 // to keep compatibily with php version of selectors. 517 511 if(module_length == 0){ 518 RETURN_FALSE 512 RETURN_FALSE; 519 513 } 520 514 firstDashPos=-1; … … 531 525 if(*cursor == '#'){ 532 526 if(sharpOk || resource_length > 1){ 533 RETURN_FALSE 527 RETURN_FALSE; 534 528 } 535 529 sharpOk=1; … … 538 532 || ( *cursor >= '0' && *cursor <= '9') 539 533 || *cursor == '_') || sharpOk){ 540 RETURN_FALSE 534 RETURN_FALSE; 541 535 } 542 536 if(*cursor == '_' && firstDashPos == -1){ … … 560 554 || ( *cursor >= '0' && *cursor <= '9') 561 555 || *cursor == '_' || *cursor == '.')){ 562 RETURN_FALSE 556 RETURN_FALSE; 563 557 } 564 558 request_length ++; … … 571 565 // request shouldn't empty if there is a @ 572 566 if(hasRequest && request_length == 0){ 573 RETURN_FALSE 567 RETURN_FALSE; 574 568 } 575 569 … … 665 659 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1, module, module_length TSRMLS_CC); 666 660 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "request", sizeof("request") - 1, request, request_length TSRMLS_CC); 667 RETURN_TRUE 661 RETURN_TRUE; 668 662 } 669 663 /* }}} */ … … 691 685 if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 692 686 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 693 RETURN_FALSE 687 RETURN_FALSE; 694 688 } 695 689 if(Z_TYPE_P(*defaultActionArg) != IS_STRING){ 696 690 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid third argument, not a string"); 697 RETURN_FALSE 691 RETURN_FALSE; 698 692 } 699 693 … … 723 717 if(*cursor == '#'){ 724 718 if(sharpOk || module_length > 1){ 725 RETURN_FALSE 719 RETURN_FALSE; 726 720 } 727 721 sharpOk=1; … … 732 726 || ( *cursor >= '0' && *cursor <= '9') 733 727 || *cursor == '_' || *cursor == ':' ) || sharpOk){ 734 RETURN_FALSE 728 RETURN_FALSE; 735 729 } 736 730 if(*cursor == ':' && firstDashPos == -1){ … … 745 739 if(cursor_count >= length){ 746 740 // we don't find any '~' characters, so we have parsed the resource 747 if(hasDot) RETURN_FALSE 741 if(hasDot) RETURN_FALSE; 748 742 749 743 resource_length = module_length; … … 751 745 }else if( *cursor == '@'){ 752 746 // we don't find any '~' characters, so we have parsed the resource 753 if(hasDot) RETURN_FALSE 747 if(hasDot) RETURN_FALSE; 754 748 755 749 resource_length = module_length; … … 767 761 || ( *cursor >= '0' && *cursor <= '9') 768 762 || *cursor == '_' || *cursor == ':' || *cursor == '.')){ 769 RETURN_FALSE 763 RETURN_FALSE; 770 764 } 771 765 request_length ++; … … 777 771 // to keep compatibily with php version of selectors. 778 772 if(module_length == 0){ 779 RETURN_FALSE 773 RETURN_FALSE; 780 774 } 781 775 firstDashPos=-1; … … 792 786 if(*cursor == '#'){ 793 787 if(sharpOk || resource_length > 1){ 794 RETURN_FALSE 788 RETURN_FALSE; 795 789 } 796 790 sharpOk=1; … … 799 793 || ( *cursor >= '0' && *cursor <= '9') 800 794 || *cursor == '_' || *cursor == ':') || sharpOk){ 801 RETURN_FALSE 795 RETURN_FALSE; 802 796 } 803 797 if(*cursor == ':' && firstDashPos == -1){ … … 821 815 || ( *cursor >= '0' && *cursor <= '9') 822 816 || *cursor == '_' || *cursor == '.')){ 823 RETURN_FALSE 817 RETURN_FALSE; 824 818 } 825 819 request_length ++; … … 832 826 // request shouldn't empty if there is a @ 833 827 if(hasRequest && request_length == 0){ 834 RETURN_FALSE 828 RETURN_FALSE; 835 829 } 836 830 … … 909 903 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "module", sizeof("module") - 1, module, module_length TSRMLS_CC); 910 904 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "request", sizeof("request") - 1, request, request_length TSRMLS_CC); 911 RETURN_TRUE 905 RETURN_TRUE; 912 906 } 913 907 /* }}} */ … … 934 928 if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 935 929 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 936 RETURN_FALSE 930 RETURN_FALSE; 937 931 } 938 932 … … 968 962 || ( *cursor >= '0' && *cursor <= '9') 969 963 || *cursor == '_' || *cursor == '.')) { 970 RETURN_FALSE 964 RETURN_FALSE; 971 965 } 972 966 module_length ++; … … 984 978 // to keep compatibility with php version of selectors. 985 979 if(module_length == 0 || subpath_length != 0){ 986 RETURN_FALSE 980 RETURN_FALSE; 987 981 } 988 982 … … 999 993 || ( *cursor >= '0' && *cursor <= '9') 1000 994 || *cursor == '_' || *cursor == '.')){ 1001 RETURN_FALSE 995 RETURN_FALSE; 1002 996 } 1003 997 resource_length ++; … … 1009 1003 1010 1004 if( resource_length == 0 ){ 1011 RETURN_FALSE 1005 RETURN_FALSE; 1012 1006 } 1013 1007 … … 1018 1012 else if (subpath_length == 1) { 1019 1013 if (resource_length == 1) { 1020 RETURN_FALSE 1014 RETURN_FALSE; 1021 1015 } 1022 1016 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1, classname, resource_length-1 TSRMLS_CC); … … 1025 1019 else { 1026 1020 if (resource_length == subpath_length) { 1027 RETURN_FALSE 1021 RETURN_FALSE; 1028 1022 } 1029 1023 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "className", sizeof("className") - 1, classname, resource_length - subpath_length TSRMLS_CC); … … 1034 1028 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, resource, resource_length TSRMLS_CC); 1035 1029 1036 RETURN_TRUE 1030 RETURN_TRUE; 1037 1031 } 1038 1032 … … 1057 1051 if(Z_TYPE_P(*objectArg) != IS_OBJECT){ 1058 1052 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid second argument, not an object"); 1059 RETURN_FALSE 1053 RETURN_FALSE; 1060 1054 } 1061 1055 … … 1092 1086 || ( *cursor >= '0' && *cursor <= '9') 1093 1087 || *cursor == '_' || *cursor == '.')) { 1094 RETURN_FALSE 1088 RETURN_FALSE; 1095 1089 } 1096 1090 module_length ++; … … 1107 1101 // to keep compatibility with php version of selectors. 1108 1102 if(module_length == 0){ 1109 RETURN_FALSE 1103 RETURN_FALSE; 1110 1104 } 1111 1105 hasPoint = 0; … … 1124 1118 || ( *cursor >= '0' && *cursor <= '9') 1125 1119 || *cursor == '_' || *cursor == '.')){ 1126 RETURN_FALSE 1120 RETURN_FALSE; 1127 1121 } 1128 1122 resource_length ++; … … 1134 1128 if (resource_length == 0 || filekey_length == 0 || filekey_length == 1 1135 1129 || filekey_length == resource_length || filekey_length == resource_length -1) { 1136 RETURN_FALSE 1130 RETURN_FALSE; 1137 1131 } 1138 1132 … … 1143 1137 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1, filekey, filekey_length TSRMLS_CC); 1144 1138 1145 RETURN_TRUE 1146 } 1147 /* }}} */ 1139 RETURN_TRUE; 1140 } 1141 /* }}} */ trunk/ext/jelix/php_jelix.h
r691 r1072 2 2 * Jelix 3 3 * a php extension for Jelix Framework 4 * @copyright Copyright (c) 2006-200 7Laurent Jouanneau4 * @copyright Copyright (c) 2006-2008 Laurent Jouanneau 5 5 * @author : Laurent Jouanneau 6 6 * @link http://jelix.org … … 42 42 ZEND_BEGIN_MODULE_GLOBALS(jelix) 43 43 zval * active_ini_file_section; 44 int activated; 44 45 ZEND_END_MODULE_GLOBALS(jelix) 45 46
