Annotation of embedaddon/php/ext/intl/resourcebundle/resourcebundle.c, revision 1.1.1.3

1.1.1.2   misho       1: /*
1.1       misho       2:    +----------------------------------------------------------------------+
                      3:    | PHP Version 5                                                        |
                      4:    +----------------------------------------------------------------------+
                      5:    | This source file is subject to version 3.01 of the PHP license,      |
                      6:    | that is bundled with this package in the file LICENSE, and is        |
                      7:    | available through the world-wide-web at the following url:           |
                      8:    | http://www.php.net/license/3_01.txt                                  |
                      9:    | If you did not receive a copy of the PHP license and are unable to   |
                     10:    | obtain it through the world-wide-web, please send a note to          |
                     11:    | license@php.net so we can mail you a copy immediately.               |
                     12:    +----------------------------------------------------------------------+
                     13:    | Authors: Hans-Peter Oeri (University of St.Gallen) <hp@oeri.ch>      |
                     14:    +----------------------------------------------------------------------+
                     15:  */
                     16: 
                     17: #include <unicode/ures.h>
                     18: 
                     19: #include <zend.h>
                     20: #include <zend_API.h>
                     21: 
                     22: #include "intl_convert.h"
                     23: #include "intl_data.h"
                     24: #include "resourcebundle/resourcebundle_class.h"
                     25: 
                     26: /* {{{ ResourceBundle_extract_value */
                     27: void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *source TSRMLS_DC ) 
                     28: {
                     29:        UResType               restype;
                     30:        const UChar*           ufield;
                     31:        const uint8_t*         bfield;
                     32:        const int32_t*         vfield;
                     33:        int32_t                ilen;
                     34:        int                    i;
                     35:        long                   lfield;
                     36:        ResourceBundle_object* newrb;
                     37: 
                     38:        restype = ures_getType( source->child );
                     39:        switch (restype)
                     40:        {
                     41:                case URES_STRING:
                     42:                        ufield = ures_getString( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
                     43:                        INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve string value");
1.1.1.3 ! misho      44:                        INTL_METHOD_RETVAL_UTF8(source, (UChar *)ufield, ilen, 0);
1.1       misho      45:                        break;
                     46: 
                     47:                case URES_BINARY:
                     48:                        bfield = ures_getBinary( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
                     49:                        INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve binary value");
                     50:                        ZVAL_STRINGL( return_value, (char *) bfield, ilen, 1 );
                     51:                        break;
                     52: 
                     53:                case URES_INT:
                     54:                        lfield = ures_getInt( source->child, &INTL_DATA_ERROR_CODE(source) );
                     55:                        INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve integer value");
                     56:                        ZVAL_LONG( return_value, lfield );
                     57:                        break;
                     58: 
                     59:                case URES_INT_VECTOR:
                     60:                        vfield = ures_getIntVector( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
                     61:                        INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve vector value");
                     62:                        array_init( return_value );
                     63:                        for (i=0; i<ilen; i++) {
                     64:                                add_next_index_long( return_value, vfield[i] );
                     65:                        }
                     66:                        break;
                     67: 
                     68:                case URES_ARRAY:
                     69:                case URES_TABLE:
                     70:                        object_init_ex( return_value, ResourceBundle_ce_ptr );
                     71:                        newrb = (ResourceBundle_object *) zend_object_store_get_object( return_value TSRMLS_CC );
                     72:                        newrb->me = source->child;
                     73:                        source->child = NULL;
                     74:                        intl_errors_reset(INTL_DATA_ERROR_P(source) TSRMLS_CC);
                     75:                        break;
                     76: 
                     77:                default:
                     78:                        intl_errors_set(INTL_DATA_ERROR_P(source), U_ILLEGAL_ARGUMENT_ERROR, "Unknown resource type", 0 TSRMLS_CC);
                     79:                        RETURN_FALSE;
                     80:                        break;
                     81:        }
                     82: }
                     83: /* }}} */
                     84: 
                     85: /*
                     86:  * Local variables:
                     87:  * tab-width: 4
                     88:  * c-basic-offset: 4
                     89:  * End:
                     90:  * vim600: noet sw=4 ts=4 fdm=marker
                     91:  * vim<600: noet sw=4 ts=4
                     92:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>