PK!νEactivatenu[# This file must be used with "source bin/activate" *from bash* # you cannot run it directly deactivate () { # reset old environment variables if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then PATH="${_OLD_VIRTUAL_PATH:-}" export PATH unset _OLD_VIRTUAL_PATH fi if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" export PYTHONHOME unset _OLD_VIRTUAL_PYTHONHOME fi # This should detect bash and zsh, which have a hash command that must # be called to get it to forget past commands. Without forgetting # past commands the $PATH changes we made may not be respected if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then hash -r fi if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then PS1="${_OLD_VIRTUAL_PS1:-}" export PS1 unset _OLD_VIRTUAL_PS1 fi unset VIRTUAL_ENV if [ ! "${1:-}" = "nondestructive" ] ; then # Self destruct! unset -f deactivate fi } # unset irrelevant variables deactivate nondestructive VIRTUAL_ENV="__VENV_DIR__" export VIRTUAL_ENV _OLD_VIRTUAL_PATH="$PATH" PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH" export PATH # unset PYTHONHOME if set # this will fail if PYTHONHOME is set to the empty string (which is bad anyway) # could use `if (set -u; : $PYTHONHOME) ;` in bash if [ -n "${PYTHONHOME:-}" ] ; then _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" unset PYTHONHOME fi if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then _OLD_VIRTUAL_PS1="${PS1:-}" if [ "x__VENV_PROMPT__" != x ] ; then PS1="__VENV_PROMPT__${PS1:-}" else if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then # special case for Aspen magic directories # see https://aspen.io/ PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" else PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" fi fi export PS1 fi # This should detect bash and zsh, which have a hash command that must # be called to get it to forget past commands. Without forgetting # past commands the $PATH changes we made may not be respected if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then hash -r fi PK!1a\\'hid-sensors/hid-sensor-iio-common.ko.xznu[7zXZִF!t/;]?Eh=ڜ.+͟,SwF0R_mϒa+n_Lxǟ)2+^-0ErTǝ̗hɖ{"2G4lǭ ޯwS$q|Q;2DCY\rOGVK(\WͱiF{6ϴ<"g%P?9,~N.h%CZIYjv:h3N 6jXU`qY9lw4ϒ $l%H (}wH\'rC!ᄼgqlmh y &=%] Fņ o h{=pJ|M{ P0;nw+ s1yq0S Y>7GnzKqջ~8#Z7YCDM!\ wwN[߭d!D=DΏ+ݽdrGYC.^n K sѠ|L1^^f6G\6 Ed$RpZ~\`j,3Aȷjr+rhr*2,;p2 DgM%52cX?[b݉W_,]Knȱ0vhI/uP:ݙqqղLLLAZ="~o|u8IJq\4Uйh 'MGX 糐Z(t" R>!W/0g'ihU^EĎ] |bOhobm.񆣊m5+0xpjlC=G}ޟESz.aaDvL*{]Bҟ vxp]x¡%юR0>!XS}7qUfF%g3izE~/MM}]?_4r1&u!Ru rfY9)J1⺀ԙae&QnHJ:S\$ˢϗ_;csy/2/{[ Ozy'ftٚ0*r}?NJ'&aښTXLCԁh5t C/Y)Ԅ;٥}LQBt 8"Vx%V4y"\5qBW&Œw(mq?9E򈩖 -Wr7Fv eY&wpZE8X&ᑙ_C%i.FC H3D _Oc9e}F^ r`K4NuAh1]:wPʦ.5/Ց:57\\dI 4 kPM"3 !}x8L9o*Jw>h˥,*n  YSPh{**חr_VD-*8 䇵>D8]?"hp1^suK]qOH#>-Mې.YluF.E mmJ]>P<#z1mŚK{10w=@b/溑SAa2d' MkY9\ ``2N(Tqw(S !/-r{Ǭd8z"Q4 Ѯ1`F'Ȱ )z+ aWy Z? v"?z9bEL%^p1=ATpQ2yMOhe)l5) AB4a,V!Cj Yt|J\ԅ?rH?sBHqŶ8͊_žSG"CJ9ʛv O[SH:!(e#e؏PekTR%IfJ).g㓜 ':uP],h>Lp YG$nG V)(H}Rإd`[$d&% "ˏK}5M\Ie+~>qcU7~oFV{  u`ra٫>+Q$d77'tЬ\oݻG意r Kʰ؂]ǹ^j0Ox~J.UUk4x+ ѐQ\dqĩ_L$;\%DAubmΥ^5;UB2n9Z%ͤOhunl)+^O#ι#T̰ґF܇IM+9!65@_J@rYЛy}-`յq^)dH\HgVXMZ+AsiA]ˇFX2vr̽{1GT(pk[|NC~@11[<Ț3KfeyB%փLpײx!'OOjam"|+NӺ0i}*%@)b{9eL<1*r($ʩ0ЁC+@^/܋fݼ=6`vOC(/IE0=Yq5B͕ivjg֔C:ɖ(QA(7I|CπܜoAy6b`:ޔf1&/fVakWZ"4(c$Ft Yec1E=QLܵ.ãaY܎fe,"Ԙ J>Ic.LjNO93qn9}䟆g#Zk6$J(2e#}ߖ_.rHcdIRq(N e+.B◾Fz{.!0)noXXc0G1ERGJ~(Ӡ{;'tLG⳼\E%á}~F9gyF?#TCOjSaRLcUMzOvD]/d'~ܢ#!]F 5Oż#8b6Ѡlv8[òH<ڵ 0צ?pɺe3n8ZxWGF8kB(l+~3,cY!I3[ KzΓG&kє#B2nn{#SVH -|hYHuDJ tuӑljD;gV= .Ȫ!,:ow&y6_ ~YY#a^ay!hQ|sYļ'<c323Ď\iཪWkZj5>X$؁Z;wq2ja9Տ^Ћ{S3R-j4Ko.ծ?.`#WleP'jLȰ~h)Eux)i5k!&*3=r!ľy<0tNeՈYxV8c~EQ-:}O.49yN"Ï6;Dö8y=Щ*_OΪT0c'Eᶒ#n>\`m;d߆p,_Zqlp)4ܼ(/ȯ5?6F\TςS^SCL孳bʹ@oDVp0`V^:4 cuzkh,޲/q$/b+(Kg /"$|n7v>ѩex4[_n%=wɘ88z\_B42v[2+y\䦍z|nv,nMja|1np4Ѫ`eflIqO8"Nw`O OB+&/ړt>jR~+h4v2}v QQwI#9kFC)jFj%v+7>6"D>m>"P!&O+%7E=cNXDMNŌ=HQփrⴗ?]MSIT rJ (1!Q1fzr_Ɯ>ȸ&r"]G2e|L˟2WK J&tD/0:dl=rU W(o.nwgZ9Fo ۞dvZ+ N)LT~hEְ.klLV"lp[rP@YQ<& (84\L}Tۏ%F-sO~ps,oE/+J*u~ͼČ&MǡR9״-iMϷT8`nRD/e̢!8;L;IDg7;u8QzсlvP>|}B|oPȾ+ ?+}-u/@35YSO^vnɿ4[Le⨝se!#1*(6as*J,:]"ue"WѤF5*?alYTygyYmi][YeQP v7EzhbˬmyRȤEi?k5 0c?cK2p g O@;)5Դb JQJ2јԑ#񇋸waxx>mCNV0 ݔg"~fSLVXE;*e;&KM"MNC[^c2 κ CCϲG k #%u2)@[ai&q[ U/W9h-,d`kz2H̳s)@I:Fbi /H3(xVS n¡L<u7ҥ%:}׻ ϺgW7S&~8.~?gcee.BͶ6mδ/XG7ӏc^e@"}W BȊnW ^>!%a}۔.uDHO=aZzy=x[G&jҤX)6g=@aV2lX{Z4y<8] 4wq*DnZts7C2#rz,(i/|dxƙ|n^!_~$6Wq9#]?3{ /.-,ޚ5i7LyJ&{1H?8'3xCV?`$%/Fս{tǹS3ո5]_z*<*w `vTCe$k2w˓S$y;xH/o10JHV<0r3x^!MFiecoC:]c?΂w)*ݐooШ|c:g szZ$GR$#q0ldZ-I}o1Hm8X}~Ipi\{"|{C | | Dmitry Lakhtyuk | +----------------------------------------------------------------------+ */ #ifndef INTL_COMMON_ENUM_H #define INTL_COMMON_ENUM_H #include #ifdef __cplusplus #include extern "C" { #include #endif #include #include "../intl_error.h" #include "../intl_data.h" #ifdef __cplusplus } #endif #define INTLITERATOR_ERROR(ii) (ii)->err #define INTLITERATOR_ERROR_P(ii) &(INTLITERATOR_ERROR(ii)) #define INTLITERATOR_ERROR_CODE(ii) INTL_ERROR_CODE(INTLITERATOR_ERROR(ii)) #define INTLITERATOR_ERROR_CODE_P(ii) &(INTL_ERROR_CODE(INTLITERATOR_ERROR(ii))) #define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii) #define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(IntlIterator, ii) #define INTLITERATOR_METHOD_FETCH_OBJECT\ object = getThis(); \ INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \ if (ii->iterator == NULL) { \ intl_errors_set(&ii->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlIterator", 0 TSRMLS_CC); \ RETURN_FALSE; \ } typedef struct { zend_object zo; intl_error err; zend_object_iterator *iterator; } IntlIterator_object; typedef struct { zend_object_iterator zoi; zval *current; zval *wrapping_obj; void (*destroy_it)(zend_object_iterator *iterator TSRMLS_DC); } zoi_with_current; extern zend_class_entry *IntlIterator_ce_ptr; extern zend_object_handlers IntlIterator_handlers; U_CFUNC void zoi_with_current_dtor(zend_object_iterator *iter TSRMLS_DC); U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter TSRMLS_DC); U_CFUNC void zoi_with_current_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC); U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter TSRMLS_DC); #ifdef __cplusplus U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC); #endif U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D); #endif // INTL_COMMON_ENUM_H PK!RK)K)common_enum.cppnu[/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gustavo Lopes | +----------------------------------------------------------------------+ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "../intl_cppshims.h" // Fix build on Windows/old versions of ICU #include #include "common_enum.h" extern "C" { #include #include } zend_class_entry *IntlIterator_ce_ptr; zend_object_handlers IntlIterator_handlers; void zoi_with_current_dtor(zend_object_iterator *iter TSRMLS_DC) { zoi_with_current *zoiwc = (zoi_with_current*)iter; if (zoiwc->wrapping_obj) { /* we have to copy the pointer because zoiwc->wrapping_obj may be * changed midway the execution of zval_ptr_dtor() */ zval *zwo = zoiwc->wrapping_obj; /* object is still here, we can rely on it to call this again and * destroy this object */ zval_ptr_dtor(&zwo); } else { /* Object not here anymore (we've been called by the object free handler) * Note that the iterator wrapper objects (that also depend on this * structure) call this function earlier, in the destruction phase, which * precedes the object free phase. Therefore there's no risk on this * function being called by the iterator wrapper destructor function and * not finding the memory of this iterator allocated anymore. */ iter->funcs->invalidate_current(iter TSRMLS_CC); zoiwc->destroy_it(iter TSRMLS_CC); efree(iter); } } U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter TSRMLS_DC) { return ((zoi_with_current*)iter)->current != NULL ? SUCCESS : FAILURE; } U_CFUNC void zoi_with_current_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) { *data = &((zoi_with_current*)iter)->current; } U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter TSRMLS_DC) { zoi_with_current *zoi_iter = (zoi_with_current*)iter; if (zoi_iter->current) { zval_ptr_dtor(&zoi_iter->current); zoi_iter->current = NULL; //valid would return FAILURE now } } static void string_enum_current_move_forward(zend_object_iterator *iter TSRMLS_DC) { zoi_with_current *zoi_iter = (zoi_with_current*)iter; INTLITERATOR_METHOD_INIT_VARS; iter->funcs->invalidate_current(iter TSRMLS_CC); object = zoi_iter->wrapping_obj; INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; int32_t result_length; const char *result = ((StringEnumeration*)iter->data)->next( &result_length, INTLITERATOR_ERROR_CODE(ii)); intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC); if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) { intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), "Error fetching next iteration element", 0 TSRMLS_CC); } else if (result) { MAKE_STD_ZVAL(zoi_iter->current); ZVAL_STRINGL(zoi_iter->current, result, result_length, 1); } //else we've reached the end of the enum, nothing more is required } static void string_enum_rewind(zend_object_iterator *iter TSRMLS_DC) { zoi_with_current *zoi_iter = (zoi_with_current*)iter; INTLITERATOR_METHOD_INIT_VARS; if (zoi_iter->current) { iter->funcs->invalidate_current(iter TSRMLS_CC); } object = zoi_iter->wrapping_obj; INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; ((StringEnumeration*)iter->data)->reset(INTLITERATOR_ERROR_CODE(ii)); intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC); if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) { intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), "Error resetting enumeration", 0 TSRMLS_CC); } else { iter->funcs->move_forward(iter TSRMLS_CC); } } static void string_enum_destroy_it(zend_object_iterator *iter TSRMLS_DC) { delete (StringEnumeration*)iter->data; } static zend_object_iterator_funcs string_enum_object_iterator_funcs = { zoi_with_current_dtor, zoi_with_current_valid, zoi_with_current_get_current_data, NULL, string_enum_current_move_forward, string_enum_rewind, zoi_with_current_invalidate_current }; U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC) { IntlIterator_object *ii; object_init_ex(object, IntlIterator_ce_ptr); ii = (IntlIterator_object*)zend_object_store_get_object(object TSRMLS_CC); ii->iterator = (zend_object_iterator*)emalloc(sizeof(zoi_with_current)); ii->iterator->data = (void*)se; ii->iterator->funcs = &string_enum_object_iterator_funcs; ii->iterator->index = 0; ((zoi_with_current*)ii->iterator)->destroy_it = string_enum_destroy_it; ((zoi_with_current*)ii->iterator)->wrapping_obj = object; ((zoi_with_current*)ii->iterator)->current = NULL; } static void IntlIterator_objects_free(zend_object *object TSRMLS_DC) { IntlIterator_object *ii = (IntlIterator_object*) object; if (ii->iterator) { zval **wrapping_objp = &((zoi_with_current*)ii->iterator)->wrapping_obj; *wrapping_objp = NULL; ii->iterator->funcs->dtor(ii->iterator TSRMLS_CC); } intl_error_reset(INTLITERATOR_ERROR_P(ii) TSRMLS_CC); zend_object_std_dtor(&ii->zo TSRMLS_CC); efree(ii); } static zend_object_iterator *IntlIterator_get_iterator( zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) { if (by_ref) { zend_throw_exception(NULL, "Iteration by reference is not supported", 0 TSRMLS_CC); return NULL; } IntlIterator_object *ii = (IntlIterator_object*) zend_object_store_get_object(object TSRMLS_CC); if (ii->iterator == NULL) { zend_throw_exception(NULL, "The IntlIterator is not properly constructed", 0 TSRMLS_CC); return NULL; } zval_add_ref(&object); return ii->iterator; } static zend_object_value IntlIterator_object_create(zend_class_entry *ce TSRMLS_DC) { zend_object_value retval; IntlIterator_object *intern; intern = (IntlIterator_object*)ecalloc(1, sizeof(IntlIterator_object)); zend_object_std_init(&intern->zo, ce TSRMLS_CC); #if PHP_VERSION_ID < 50399 zend_hash_copy(intern->zo.properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*)); #else object_properties_init((zend_object*) intern, ce); #endif intl_error_init(INTLITERATOR_ERROR_P(intern) TSRMLS_CC); intern->iterator = NULL; retval.handle = zend_objects_store_put( intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)IntlIterator_objects_free, NULL TSRMLS_CC); retval.handlers = &IntlIterator_handlers; return retval; } static PHP_METHOD(IntlIterator, current) { zval **data; INTLITERATOR_METHOD_INIT_VARS; if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "IntlIterator::current: bad arguments", 0 TSRMLS_CC); return; } INTLITERATOR_METHOD_FETCH_OBJECT; ii->iterator->funcs->get_current_data(ii->iterator, &data TSRMLS_CC); if (data && *data) { RETURN_ZVAL(*data, 1, 0); } } static PHP_METHOD(IntlIterator, key) { INTLITERATOR_METHOD_INIT_VARS; if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "IntlIterator::key: bad arguments", 0 TSRMLS_CC); return; } INTLITERATOR_METHOD_FETCH_OBJECT; if (ii->iterator->funcs->get_current_key) { ii->iterator->funcs->get_current_key(ii->iterator, return_value TSRMLS_CC); } else { RETURN_LONG(ii->iterator->index); } } static PHP_METHOD(IntlIterator, next) { INTLITERATOR_METHOD_INIT_VARS; if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "IntlIterator::next: bad arguments", 0 TSRMLS_CC); return; } INTLITERATOR_METHOD_FETCH_OBJECT; ii->iterator->funcs->move_forward(ii->iterator TSRMLS_CC); /* foreach also advances the index after the last iteration, * so I see no problem in incrementing the index here unconditionally */ ii->iterator->index++; } static PHP_METHOD(IntlIterator, rewind) { INTLITERATOR_METHOD_INIT_VARS; if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "IntlIterator::rewind: bad arguments", 0 TSRMLS_CC); return; } INTLITERATOR_METHOD_FETCH_OBJECT; if (ii->iterator->funcs->rewind) { ii->iterator->funcs->rewind(ii->iterator TSRMLS_CC); } else { intl_errors_set(INTLITERATOR_ERROR_P(ii), U_UNSUPPORTED_ERROR, "IntlIterator::rewind: rewind not supported", 0 TSRMLS_CC); } } static PHP_METHOD(IntlIterator, valid) { INTLITERATOR_METHOD_INIT_VARS; if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "IntlIterator::valid: bad arguments", 0 TSRMLS_CC); return; } INTLITERATOR_METHOD_FETCH_OBJECT; RETURN_BOOL(ii->iterator->funcs->valid(ii->iterator TSRMLS_CC) == SUCCESS); } ZEND_BEGIN_ARG_INFO_EX(ainfo_se_void, 0, 0, 0) ZEND_END_ARG_INFO() static zend_function_entry IntlIterator_class_functions[] = { PHP_ME(IntlIterator, current, ainfo_se_void, ZEND_ACC_PUBLIC) PHP_ME(IntlIterator, key, ainfo_se_void, ZEND_ACC_PUBLIC) PHP_ME(IntlIterator, next, ainfo_se_void, ZEND_ACC_PUBLIC) PHP_ME(IntlIterator, rewind, ainfo_se_void, ZEND_ACC_PUBLIC) PHP_ME(IntlIterator, valid, ainfo_se_void, ZEND_ACC_PUBLIC) PHP_FE_END }; /* {{{ intl_register_IntlIterator_class * Initialize 'IntlIterator' class */ U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D) { zend_class_entry ce; /* Create and register 'IntlIterator' class. */ INIT_CLASS_ENTRY(ce, "IntlIterator", IntlIterator_class_functions); ce.create_object = IntlIterator_object_create; IntlIterator_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC); IntlIterator_ce_ptr->get_iterator = IntlIterator_get_iterator; zend_class_implements(IntlIterator_ce_ptr TSRMLS_CC, 1, zend_ce_iterator); memcpy(&IntlIterator_handlers, zend_get_std_object_handlers(), sizeof IntlIterator_handlers); IntlIterator_handlers.clone_obj = NULL; } PK!Ȏ((common_error.cnu[/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Vadim Savchuk | | Dmitry Lakhtyuk | +----------------------------------------------------------------------+ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php_intl.h" #include "intl_error.h" #include "common_error.h" /* {{{ proto int intl_get_error_code() * Get code of the last occurred error. */ PHP_FUNCTION( intl_get_error_code ) { RETURN_LONG( intl_error_get_code( NULL TSRMLS_CC ) ); } /* }}} */ /* {{{ proto string intl_get_error_message() * Get text description of the last occurred error. */ PHP_FUNCTION( intl_get_error_message ) { char* message = intl_error_get_message( NULL TSRMLS_CC ); RETURN_STRING( message, FALSE ); } /* }}} */ /* {{{ proto bool intl_is_failure() * Check whether the given error code indicates a failure. * Returns true if it does, and false if the code * indicates success or a warning. */ PHP_FUNCTION( intl_is_failure ) { long err_code; /* Parse parameters. */ if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l", &err_code ) == FAILURE ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "intl_is_failure: unable to parse input params", 0 TSRMLS_CC ); RETURN_FALSE; } RETURN_BOOL( U_FAILURE( err_code ) ); } /* {{{ proto string intl_error_name() * Return a string for a given error code. * The string will be the same as the name of the error code constant. */ PHP_FUNCTION( intl_error_name ) { long err_code; /* Parse parameters. */ if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l", &err_code ) == FAILURE ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "intl_error_name: unable to parse input params", 0 TSRMLS_CC ); RETURN_FALSE; } RETURN_STRING( (char*)u_errorName( err_code ), 1 ); } /* }}} */ /* {{{ intl_expose_icu_error_codes * Expose ICU error codes */ void intl_expose_icu_error_codes( INIT_FUNC_ARGS ) { #define INTL_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS) /* Warnings */ INTL_EXPOSE_CONST( U_USING_FALLBACK_WARNING ); INTL_EXPOSE_CONST( U_ERROR_WARNING_START ); INTL_EXPOSE_CONST( U_USING_DEFAULT_WARNING ); INTL_EXPOSE_CONST( U_SAFECLONE_ALLOCATED_WARNING ); INTL_EXPOSE_CONST( U_STATE_OLD_WARNING ); INTL_EXPOSE_CONST( U_STRING_NOT_TERMINATED_WARNING ); INTL_EXPOSE_CONST( U_SORT_KEY_TOO_SHORT_WARNING ); INTL_EXPOSE_CONST( U_AMBIGUOUS_ALIAS_WARNING ); INTL_EXPOSE_CONST( U_DIFFERENT_UCA_VERSION ); INTL_EXPOSE_CONST( U_ERROR_WARNING_LIMIT ); /* Standard errors */ INTL_EXPOSE_CONST( U_ZERO_ERROR ); INTL_EXPOSE_CONST( U_ILLEGAL_ARGUMENT_ERROR ); INTL_EXPOSE_CONST( U_MISSING_RESOURCE_ERROR ); INTL_EXPOSE_CONST( U_INVALID_FORMAT_ERROR ); INTL_EXPOSE_CONST( U_FILE_ACCESS_ERROR ); INTL_EXPOSE_CONST( U_INTERNAL_PROGRAM_ERROR ); INTL_EXPOSE_CONST( U_MESSAGE_PARSE_ERROR ); INTL_EXPOSE_CONST( U_MEMORY_ALLOCATION_ERROR ); INTL_EXPOSE_CONST( U_INDEX_OUTOFBOUNDS_ERROR ); INTL_EXPOSE_CONST( U_PARSE_ERROR ); INTL_EXPOSE_CONST( U_INVALID_CHAR_FOUND ); INTL_EXPOSE_CONST( U_TRUNCATED_CHAR_FOUND ); INTL_EXPOSE_CONST( U_ILLEGAL_CHAR_FOUND ); INTL_EXPOSE_CONST( U_INVALID_TABLE_FORMAT ); INTL_EXPOSE_CONST( U_INVALID_TABLE_FILE ); INTL_EXPOSE_CONST( U_BUFFER_OVERFLOW_ERROR ); INTL_EXPOSE_CONST( U_UNSUPPORTED_ERROR ); INTL_EXPOSE_CONST( U_RESOURCE_TYPE_MISMATCH ); INTL_EXPOSE_CONST( U_ILLEGAL_ESCAPE_SEQUENCE ); INTL_EXPOSE_CONST( U_UNSUPPORTED_ESCAPE_SEQUENCE ); INTL_EXPOSE_CONST( U_NO_SPACE_AVAILABLE ); INTL_EXPOSE_CONST( U_CE_NOT_FOUND_ERROR ); INTL_EXPOSE_CONST( U_PRIMARY_TOO_LONG_ERROR ); INTL_EXPOSE_CONST( U_STATE_TOO_OLD_ERROR ); INTL_EXPOSE_CONST( U_TOO_MANY_ALIASES_ERROR ); INTL_EXPOSE_CONST( U_ENUM_OUT_OF_SYNC_ERROR ); INTL_EXPOSE_CONST( U_INVARIANT_CONVERSION_ERROR ); INTL_EXPOSE_CONST( U_INVALID_STATE_ERROR ); INTL_EXPOSE_CONST( U_COLLATOR_VERSION_MISMATCH ); INTL_EXPOSE_CONST( U_USELESS_COLLATOR_ERROR ); INTL_EXPOSE_CONST( U_NO_WRITE_PERMISSION ); INTL_EXPOSE_CONST( U_STANDARD_ERROR_LIMIT ); /* The error code range 0x10000 0x10100 are reserved for Transliterator */ INTL_EXPOSE_CONST( U_BAD_VARIABLE_DEFINITION ); INTL_EXPOSE_CONST( U_PARSE_ERROR_START ); INTL_EXPOSE_CONST( U_MALFORMED_RULE ); INTL_EXPOSE_CONST( U_MALFORMED_SET ); INTL_EXPOSE_CONST( U_MALFORMED_SYMBOL_REFERENCE ); INTL_EXPOSE_CONST( U_MALFORMED_UNICODE_ESCAPE ); INTL_EXPOSE_CONST( U_MALFORMED_VARIABLE_DEFINITION ); INTL_EXPOSE_CONST( U_MALFORMED_VARIABLE_REFERENCE ); INTL_EXPOSE_CONST( U_MISMATCHED_SEGMENT_DELIMITERS ); INTL_EXPOSE_CONST( U_MISPLACED_ANCHOR_START ); INTL_EXPOSE_CONST( U_MISPLACED_CURSOR_OFFSET ); INTL_EXPOSE_CONST( U_MISPLACED_QUANTIFIER ); INTL_EXPOSE_CONST( U_MISSING_OPERATOR ); INTL_EXPOSE_CONST( U_MISSING_SEGMENT_CLOSE ); INTL_EXPOSE_CONST( U_MULTIPLE_ANTE_CONTEXTS ); INTL_EXPOSE_CONST( U_MULTIPLE_CURSORS ); INTL_EXPOSE_CONST( U_MULTIPLE_POST_CONTEXTS ); INTL_EXPOSE_CONST( U_TRAILING_BACKSLASH ); INTL_EXPOSE_CONST( U_UNDEFINED_SEGMENT_REFERENCE ); INTL_EXPOSE_CONST( U_UNDEFINED_VARIABLE ); INTL_EXPOSE_CONST( U_UNQUOTED_SPECIAL ); INTL_EXPOSE_CONST( U_UNTERMINATED_QUOTE ); INTL_EXPOSE_CONST( U_RULE_MASK_ERROR ); INTL_EXPOSE_CONST( U_MISPLACED_COMPOUND_FILTER ); INTL_EXPOSE_CONST( U_MULTIPLE_COMPOUND_FILTERS ); INTL_EXPOSE_CONST( U_INVALID_RBT_SYNTAX ); INTL_EXPOSE_CONST( U_INVALID_PROPERTY_PATTERN ); INTL_EXPOSE_CONST( U_MALFORMED_PRAGMA ); INTL_EXPOSE_CONST( U_UNCLOSED_SEGMENT ); INTL_EXPOSE_CONST( U_ILLEGAL_CHAR_IN_SEGMENT ); INTL_EXPOSE_CONST( U_VARIABLE_RANGE_EXHAUSTED ); INTL_EXPOSE_CONST( U_VARIABLE_RANGE_OVERLAP ); INTL_EXPOSE_CONST( U_ILLEGAL_CHARACTER ); INTL_EXPOSE_CONST( U_INTERNAL_TRANSLITERATOR_ERROR ); INTL_EXPOSE_CONST( U_INVALID_ID ); INTL_EXPOSE_CONST( U_INVALID_FUNCTION ); INTL_EXPOSE_CONST( U_PARSE_ERROR_LIMIT ); /* The error code range 0x10100 0x10200 are reserved for formatting API parsing error */ INTL_EXPOSE_CONST( U_UNEXPECTED_TOKEN ); INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_START ); INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPARATORS ); INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPERATORS ); /* Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */ INTL_EXPOSE_CONST( U_MULTIPLE_EXPONENTIAL_SYMBOLS ); INTL_EXPOSE_CONST( U_MALFORMED_EXPONENTIAL_PATTERN ); INTL_EXPOSE_CONST( U_MULTIPLE_PERCENT_SYMBOLS ); INTL_EXPOSE_CONST( U_MULTIPLE_PERMILL_SYMBOLS ); INTL_EXPOSE_CONST( U_MULTIPLE_PAD_SPECIFIERS ); INTL_EXPOSE_CONST( U_PATTERN_SYNTAX_ERROR ); INTL_EXPOSE_CONST( U_ILLEGAL_PAD_POSITION ); INTL_EXPOSE_CONST( U_UNMATCHED_BRACES ); INTL_EXPOSE_CONST( U_UNSUPPORTED_PROPERTY ); INTL_EXPOSE_CONST( U_UNSUPPORTED_ATTRIBUTE ); INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_LIMIT ); /* The error code range 0x10200 0x102ff are reserved for Break Iterator related error */ INTL_EXPOSE_CONST( U_BRK_INTERNAL_ERROR ); INTL_EXPOSE_CONST( U_BRK_ERROR_START ); INTL_EXPOSE_CONST( U_BRK_HEX_DIGITS_EXPECTED ); INTL_EXPOSE_CONST( U_BRK_SEMICOLON_EXPECTED ); INTL_EXPOSE_CONST( U_BRK_RULE_SYNTAX ); INTL_EXPOSE_CONST( U_BRK_UNCLOSED_SET ); INTL_EXPOSE_CONST( U_BRK_ASSIGN_ERROR ); INTL_EXPOSE_CONST( U_BRK_VARIABLE_REDFINITION ); INTL_EXPOSE_CONST( U_BRK_MISMATCHED_PAREN ); INTL_EXPOSE_CONST( U_BRK_NEW_LINE_IN_QUOTED_STRING ); INTL_EXPOSE_CONST( U_BRK_UNDEFINED_VARIABLE ); INTL_EXPOSE_CONST( U_BRK_INIT_ERROR ); INTL_EXPOSE_CONST( U_BRK_RULE_EMPTY_SET ); INTL_EXPOSE_CONST( U_BRK_UNRECOGNIZED_OPTION ); INTL_EXPOSE_CONST( U_BRK_MALFORMED_RULE_TAG ); INTL_EXPOSE_CONST( U_BRK_ERROR_LIMIT ); /* The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs */ INTL_EXPOSE_CONST( U_REGEX_INTERNAL_ERROR ); INTL_EXPOSE_CONST( U_REGEX_ERROR_START ); INTL_EXPOSE_CONST( U_REGEX_RULE_SYNTAX ); INTL_EXPOSE_CONST( U_REGEX_INVALID_STATE ); INTL_EXPOSE_CONST( U_REGEX_BAD_ESCAPE_SEQUENCE ); INTL_EXPOSE_CONST( U_REGEX_PROPERTY_SYNTAX ); INTL_EXPOSE_CONST( U_REGEX_UNIMPLEMENTED ); INTL_EXPOSE_CONST( U_REGEX_MISMATCHED_PAREN ); INTL_EXPOSE_CONST( U_REGEX_NUMBER_TOO_BIG ); INTL_EXPOSE_CONST( U_REGEX_BAD_INTERVAL ); INTL_EXPOSE_CONST( U_REGEX_MAX_LT_MIN ); INTL_EXPOSE_CONST( U_REGEX_INVALID_BACK_REF ); INTL_EXPOSE_CONST( U_REGEX_INVALID_FLAG ); INTL_EXPOSE_CONST( U_REGEX_LOOK_BEHIND_LIMIT ); INTL_EXPOSE_CONST( U_REGEX_SET_CONTAINS_STRING ); INTL_EXPOSE_CONST( U_REGEX_ERROR_LIMIT ); /* The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes */ INTL_EXPOSE_CONST( U_IDNA_PROHIBITED_ERROR ); INTL_EXPOSE_CONST( U_IDNA_ERROR_START ); INTL_EXPOSE_CONST( U_IDNA_UNASSIGNED_ERROR ); INTL_EXPOSE_CONST( U_IDNA_CHECK_BIDI_ERROR ); INTL_EXPOSE_CONST( U_IDNA_STD3_ASCII_RULES_ERROR ); INTL_EXPOSE_CONST( U_IDNA_ACE_PREFIX_ERROR ); INTL_EXPOSE_CONST( U_IDNA_VERIFICATION_ERROR ); INTL_EXPOSE_CONST( U_IDNA_LABEL_TOO_LONG_ERROR ); INTL_EXPOSE_CONST( U_IDNA_ZERO_LENGTH_LABEL_ERROR ); #if U_ICU_VERSION_MAJOR_NUM > 3 || U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM >= 8 INTL_EXPOSE_CONST( U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR ); #endif INTL_EXPOSE_CONST( U_IDNA_ERROR_LIMIT ); /* Aliases for StringPrep */ INTL_EXPOSE_CONST( U_STRINGPREP_PROHIBITED_ERROR ); INTL_EXPOSE_CONST( U_STRINGPREP_UNASSIGNED_ERROR ); INTL_EXPOSE_CONST( U_STRINGPREP_CHECK_BIDI_ERROR ); INTL_EXPOSE_CONST( U_ERROR_LIMIT ); #undef INTL_EXPOSE_CONST } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ PK!S&,^^common_error.hnu[/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Vadim Savchuk | | Dmitry Lakhtyuk | +----------------------------------------------------------------------+ */ #ifndef INTL_COMMON_ERROR_H #define INTL_COMMON_ERROR_H #include PHP_FUNCTION( intl_get_error_code ); PHP_FUNCTION( intl_get_error_message ); PHP_FUNCTION( intl_is_failure ); PHP_FUNCTION( intl_error_name ); void intl_expose_icu_error_codes( INIT_FUNC_ARGS ); #endif // INTL_COMMON_ERROR_H PK!T,common_date.cppnu[/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gustavo Lopes | +----------------------------------------------------------------------+ */ #include "../intl_cppshims.h" #include extern "C" { #include "../php_intl.h" #define USE_CALENDAR_POINTER 1 #include "../calendar/calendar_class.h" #include } #ifndef INFINITY #define INFINITY (DBL_MAX+DBL_MAX) #endif #ifndef NAN #define NAN (INFINITY-INFINITY) #endif /* {{{ timezone_convert_datetimezone * The timezone in DateTime and DateTimeZone is not unified. */ U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, int is_datetime, intl_error *outside_error, const char *func TSRMLS_DC) { char *id = NULL, offset_id[] = "GMT+00:00"; int id_len = 0; char *message; TimeZone *timeZone; switch (type) { case TIMELIB_ZONETYPE_ID: id = is_datetime ? ((php_date_obj*)object)->time->tz_info->name : ((php_timezone_obj*)object)->tzi.tz->name; id_len = strlen(id); break; case TIMELIB_ZONETYPE_OFFSET: { int offset_mins = is_datetime ? -((php_date_obj*)object)->time->z : -(int)((php_timezone_obj*)object)->tzi.utc_offset, hours = offset_mins / 60, minutes = offset_mins - hours * 60; minutes *= minutes > 0 ? 1 : -1; if (offset_mins <= -24 * 60 || offset_mins >= 24 * 60) { spprintf(&message, 0, "%s: object has an time zone offset " "that's too large", func); intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); return NULL; } id = offset_id; id_len = slprintf(id, sizeof(offset_id), "GMT%+03d:%02d", hours, minutes); break; } case TIMELIB_ZONETYPE_ABBR: id = is_datetime ? ((php_date_obj*)object)->time->tz_abbr : ((php_timezone_obj*)object)->tzi.z.abbr; id_len = strlen(id); break; } UnicodeString s = UnicodeString(id, id_len, US_INV); timeZone = TimeZone::createTimeZone(s); #if U_ICU_VERSION_MAJOR_NUM >= 49 if (*timeZone == TimeZone::getUnknown()) { #else UnicodeString resultingId; timeZone->getID(resultingId); if (resultingId == UnicodeString("Etc/Unknown", -1, US_INV) || resultingId == UnicodeString("GMT", -1, US_INV)) { #endif spprintf(&message, 0, "%s: time zone id '%s' " "extracted from ext/date DateTimeZone not recognized", func, id); intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); delete timeZone; return NULL; } return timeZone; } /* }}} */ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz, intl_error *err, const char *func TSRMLS_DC) { zval retval; zval *zfuncname; char *message; if (err && U_FAILURE(err->code)) { return FAILURE; } if (millis) { *millis = NAN; } if (tz) { *tz = NULL; } if (millis) { INIT_ZVAL(retval); MAKE_STD_ZVAL(zfuncname); ZVAL_STRING(zfuncname, "getTimestamp", 1); if (call_user_function(NULL, &(z), zfuncname, &retval, 0, NULL TSRMLS_CC) != SUCCESS || Z_TYPE(retval) != IS_LONG) { spprintf(&message, 0, "%s: error calling ::getTimeStamp() on the " "object", func); intl_errors_set(err, U_INTERNAL_PROGRAM_ERROR, message, 1 TSRMLS_CC); efree(message); zval_ptr_dtor(&zfuncname); return FAILURE; } *millis = U_MILLIS_PER_SECOND * (double)Z_LVAL(retval); zval_ptr_dtor(&zfuncname); } if (tz) { php_date_obj *datetime; datetime = (php_date_obj*)zend_object_store_get_object(z TSRMLS_CC); if (!datetime->time) { spprintf(&message, 0, "%s: the DateTime object is not properly " "initialized", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); return FAILURE; } if (!datetime->time->is_localtime) { *tz = TimeZone::getGMT()->clone(); } else { *tz = timezone_convert_datetimezone(datetime->time->zone_type, datetime, 1, NULL, func TSRMLS_CC); if (*tz == NULL) { spprintf(&message, 0, "%s: could not convert DateTime's " "time zone", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); return FAILURE; } } } return SUCCESS; } U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func TSRMLS_DC) { double rv = NAN; long lv; int type; char *message; if (err && U_FAILURE(err->code)) { return NAN; } switch (Z_TYPE_P(z)) { case IS_STRING: type = is_numeric_string(Z_STRVAL_P(z), Z_STRLEN_P(z), &lv, &rv, 0); if (type == IS_DOUBLE) { rv *= U_MILLIS_PER_SECOND; } else if (type == IS_LONG) { rv = U_MILLIS_PER_SECOND * (double)lv; } else { spprintf(&message, 0, "%s: string '%s' is not numeric, " "which would be required for it to be a valid date", func, Z_STRVAL_P(z)); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); } break; case IS_LONG: rv = U_MILLIS_PER_SECOND * (double)Z_LVAL_P(z); break; case IS_DOUBLE: rv = U_MILLIS_PER_SECOND * Z_DVAL_P(z); break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(z), php_date_get_date_ce() TSRMLS_CC)) { intl_datetime_decompose(z, &rv, NULL, err, func TSRMLS_CC); } else if (instanceof_function(Z_OBJCE_P(z), Calendar_ce_ptr TSRMLS_CC)) { Calendar_object *co = (Calendar_object *) zend_object_store_get_object(z TSRMLS_CC ); if (co->ucal == NULL) { spprintf(&message, 0, "%s: IntlCalendar object is not properly " "constructed", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); } else { UErrorCode status = UErrorCode(); rv = (double)co->ucal->getTime(status); if (U_FAILURE(status)) { spprintf(&message, 0, "%s: call to internal " "Calendar::getTime() has failed", func); intl_errors_set(err, status, message, 1 TSRMLS_CC); efree(message); } } } else { /* TODO: try with cast(), get() to obtain a number */ spprintf(&message, 0, "%s: invalid object type for date/time " "(only IntlCalendar and DateTime permitted)", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); } break; default: spprintf(&message, 0, "%s: invalid PHP type for date", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); efree(message); break; } return rv; } PK!66 common_date.hnu[/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gustavo Lopes | +----------------------------------------------------------------------+ */ #ifndef COMMON_DATE_H #define COMMON_DATE_H #include U_CDECL_BEGIN #include #include "../intl_error.h" U_CDECL_END #ifdef __cplusplus #include U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, int is_datetime, intl_error *outside_error, const char *func TSRMLS_DC); U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz, intl_error *err, const char *func TSRMLS_DC); #endif U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func TSRMLS_DC); #endif /* COMMON_DATE_H */ PK! "" Activate.ps1nu[<# .Synopsis Activate a Python virtual environment for the current PowerShell session. .Description Pushes the python executable for a virtual environment to the front of the $Env:PATH environment variable and sets the prompt to signify that you are in a Python virtual environment. Makes use of the command line switches as well as the `pyvenv.cfg` file values present in the virtual environment. .Parameter VenvDir Path to the directory that contains the virtual environment to activate. The default value for this is the parent of the directory that the Activate.ps1 script is located within. .Parameter Prompt The prompt prefix to display when this virtual environment is activated. By default, this prompt is the name of the virtual environment folder (VenvDir) surrounded by parentheses and followed by a single space (ie. '(.venv) '). .Example Activate.ps1 Activates the Python virtual environment that contains the Activate.ps1 script. .Example Activate.ps1 -Verbose Activates the Python virtual environment that contains the Activate.ps1 script, and shows extra information about the activation as it executes. .Example Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv Activates the Python virtual environment located in the specified location. .Example Activate.ps1 -Prompt "MyPython" Activates the Python virtual environment that contains the Activate.ps1 script, and prefixes the current prompt with the specified string (surrounded in parentheses) while the virtual environment is active. .Notes On Windows, it may be required to enable this Activate.ps1 script by setting the execution policy for the user. You can do this by issuing the following PowerShell command: PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser For more information on Execution Policies: https://go.microsoft.com/fwlink/?LinkID=135170 #> Param( [Parameter(Mandatory = $false)] [String] $VenvDir, [Parameter(Mandatory = $false)] [String] $Prompt ) <# Function declarations --------------------------------------------------- #> <# .Synopsis Remove all shell session elements added by the Activate script, including the addition of the virtual environment's Python executable from the beginning of the PATH variable. .Parameter NonDestructive If present, do not remove this function from the global namespace for the session. #> function global:deactivate ([switch]$NonDestructive) { # Revert to original values # The prior prompt: if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT } # The prior PYTHONHOME: if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME } # The prior PATH: if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH Remove-Item -Path Env:_OLD_VIRTUAL_PATH } # Just remove the VIRTUAL_ENV altogether: if (Test-Path -Path Env:VIRTUAL_ENV) { Remove-Item -Path env:VIRTUAL_ENV } # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force } # Leave deactivate function in the global namespace if requested: if (-not $NonDestructive) { Remove-Item -Path function:deactivate } } <# .Description Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the given folder, and returns them in a map. For each line in the pyvenv.cfg file, if that line can be parsed into exactly two strings separated by `=` (with any amount of whitespace surrounding the =) then it is considered a `key = value` line. The left hand string is the key, the right hand is the value. If the value starts with a `'` or a `"` then the first and last character is stripped from the value before being captured. .Parameter ConfigDir Path to the directory that contains the `pyvenv.cfg` file. #> function Get-PyVenvConfig( [String] $ConfigDir ) { Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue # An empty map will be returned if no config file is found. $pyvenvConfig = @{ } if ($pyvenvConfigPath) { Write-Verbose "File exists, parse `key = value` lines" $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath $pyvenvConfigContent | ForEach-Object { $keyval = $PSItem -split "\s*=\s*", 2 if ($keyval[0] -and $keyval[1]) { $val = $keyval[1] # Remove extraneous quotations around a string value. if ("'""".Contains($val.Substring(0, 1))) { $val = $val.Substring(1, $val.Length - 2) } $pyvenvConfig[$keyval[0]] = $val Write-Verbose "Adding Key: '$($keyval[0])'='$val'" } } } return $pyvenvConfig } <# Begin Activate script --------------------------------------------------- #> # Determine the containing directory of this script $VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition $VenvExecDir = Get-Item -Path $VenvExecPath Write-Verbose "Activation script is located in path: '$VenvExecPath'" Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" # Set values required in priority: CmdLine, ConfigFile, Default # First, get the location of the virtual environment, it might not be # VenvExecDir if specified on the command line. if ($VenvDir) { Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" } else { Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") Write-Verbose "VenvDir=$VenvDir" } # Next, read the `pyvenv.cfg` file to determine any required value such # as `prompt`. $pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir # Next, set the prompt from the command line, or the config file, or # just use the name of the virtual environment folder. if ($Prompt) { Write-Verbose "Prompt specified as argument, using '$Prompt'" } else { Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" if ($pyvenvCfg -and $pyvenvCfg['prompt']) { Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" $Prompt = $pyvenvCfg['prompt']; } else { Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)" Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" $Prompt = Split-Path -Path $venvDir -Leaf } } Write-Verbose "Prompt = '$Prompt'" Write-Verbose "VenvDir='$VenvDir'" # Deactivate any currently active virtual environment, but leave the # deactivate function in place. deactivate -nondestructive # Now set the environment variable VIRTUAL_ENV, used by many tools to determine # that there is an activated venv. $env:VIRTUAL_ENV = $VenvDir if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { Write-Verbose "Setting prompt to '$Prompt'" # Set the prompt to include the env name # Make sure _OLD_VIRTUAL_PROMPT is global function global:_OLD_VIRTUAL_PROMPT { "" } Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt function global:prompt { Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " _OLD_VIRTUAL_PROMPT } } # Clear PYTHONHOME if (Test-Path -Path Env:PYTHONHOME) { Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME Remove-Item -Path Env:PYTHONHOME } # Add the venv to the PATH Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH $Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" PK!νEactivatenu[PK!1a\\'hid-sensors/hid-sensor-iio-common.ko.xznu[PK!R$hid-sensors/hid-sensor-trigger.ko.xznu[PK![P *common_enum.hnu[PK!RK)K)w6common_enum.cppnu[PK!Ȏ((`common_error.cnu[PK!S&,^^common_error.hnu[PK!T,\common_date.cppnu[PK!66 common_date.hnu[PK! "" Activate.ps1nu[PK 3N