Develop and Download Open Source Software

Browse CVS Repository

Diff of /xoonips/AL/xnpal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.25 by youi, Mon Jan 24 01:53:03 2005 UTC revision 1.26 by youi, Mon Jan 24 10:53:38 2005 UTC
# Line 116  ZEND_FUNCTION(xnp_unregister_binder_item Line 116  ZEND_FUNCTION(xnp_unregister_binder_item
116  ZEND_FUNCTION(xnp_register_item            );  ZEND_FUNCTION(xnp_register_item            );
117  ZEND_FUNCTION(xnp_unregister_item          );  ZEND_FUNCTION(xnp_unregister_item          );
118    
119    ZEND_FUNCTION(xnp_get_uncertified_link     );
120    ZEND_FUNCTION(xnp_get_private_item_id      );
121    
122    ZEND_FUNCTION(xnp_get_item_types            );
123    
124  };  };
125  /* compiled function list so Zend knows what's in this module */  /* compiled function list so Zend knows what's in this module */
126  zend_function_entry xnpalmod_functions[] =  zend_function_entry xnpalmod_functions[] =
# Line 201  zend_function_entry xnpalmod_functions[] Line 206  zend_function_entry xnpalmod_functions[]
206          ZEND_FE(xnp_register_item            ,NULL)          ZEND_FE(xnp_register_item            ,NULL)
207          ZEND_FE(xnp_unregister_item          ,NULL)          ZEND_FE(xnp_unregister_item          ,NULL)
208    
209            ZEND_FE(xnp_get_uncertified_link     ,NULL)
210            ZEND_FE(xnp_get_private_item_id      ,NULL)
211    
212            ZEND_FE(xnp_get_item_types            ,NULL)
213        
214          {NULL, NULL, NULL}          {NULL, NULL, NULL}
215  };  };
216    
# Line 746  result_t itemidsToZval( const itemid_t * Line 756  result_t itemidsToZval( const itemid_t *
756  {  {
757          zend_hash_clean( Z_ARRVAL_PP(ppz) );          zend_hash_clean( Z_ARRVAL_PP(ppz) );
758    
759          // add GIDs          // add IDs
760            for ( int i = 0; i < len; i++ ){
761                    add_next_index_long(*ppz, (long)(piid[i]) );
762            }
763    
764            return RES_OK;
765    }
766    
767    /**
768     *
769     * indexid_tの配列をPHPの配列に変換する
770     * @param piid 変換元のindexid_tの配列
771     * @param len  piidの配列の長さ
772     * @param ppz  変換結果を書き込む配列(初期化済みであること)
773     * @return RES_OK
774     *
775     */
776    result_t indexidsToZval( const indexid_t *piid, int len, zval **ppz )
777    {
778            zend_hash_clean( Z_ARRVAL_PP(ppz) );
779        
780            // add IDs
781          for ( int i = 0; i < len; i++ ){          for ( int i = 0; i < len; i++ ){
782                  add_next_index_long(*ppz, (long)(piid[i]) );                  add_next_index_long(*ppz, (long)(piid[i]) );
783          }          }
# Line 2834  ZEND_FUNCTION(xnp_delete_item) Line 2865  ZEND_FUNCTION(xnp_delete_item)
2865    
2866    
2867  /**  /**
2868     *
2869     * 個人の非公開アイテムのIDを取得します.
2870     * 公開インデックスに登録承認されたものは結果に含みません
2871     *
2872     * @param sid セッションID
2873     * @param uid 対象ユーザのID
2874     * @param iids 登録されたアイテムIDを受け取る引数
2875     * @param iidsLen iidsに格納された個数を受け取る引数
2876     * @return RES_OK
2877     * @return RES_DB_NOT_INITIALIZED
2878     * @return RES_NO_SUCH_SESSION
2879     * @return RES_DB_QUERY_ERROR
2880     * @return RES_ERROR
2881     *
2882     */
2883    //result_t getPrivateItemID( sessionid_t sid, userid_t uid, const itemid_t** iids, int* iidsLen )
2884    ZEND_FUNCTION(xnp_get_private_item_id)
2885    {
2886            long sid;
2887            userid_t uid;
2888        zval* ziids;
2889        
2890            if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
2891                                  &sid, &uid, &ziids) == FAILURE) {
2892                    return;
2893            }
2894        
2895        const itemid_t *piids;
2896        int iidsLen;
2897        result_t result = getPrivateItemID( (sessionid_t)sid, uid, &piids, &iidsLen );
2898        if ( RES_OK == result ){
2899            itemidsToZval( piids, iidsLen, &ziids );
2900            freeItemID( piids );
2901        }
2902        
2903            RETURN_LONG( result );
2904        
2905    }
2906    
2907    
2908    /**
2909   *   *
2910   * アイテム情報取得.   * アイテム情報取得.
2911   * 取得したアイテムは,使用後freeItemで解放する.   * 取得したアイテムは,使用後freeItemで解放する.
# Line 3115  ZEND_FUNCTION(xnp_unregister_item) Line 3187  ZEND_FUNCTION(xnp_unregister_item)
3187          result = unregisterItem( (sessionid_t)sid, xid, iid );          result = unregisterItem( (sessionid_t)sid, xid, iid );
3188          RETURN_LONG(result);          RETURN_LONG(result);
3189  }  }
3190    
3191    
3192    /**
3193     *
3194     * 承認待ち状態のアイテムのうち,承認権限のあるアイテムのIDと登録先インデックスのIDをペアで取得します.
3195     * アイテムiids[i]が現在xids[i]への登録の承認待ち状態にあることを返します.
3196     *
3197     * @param sid セッションID
3198     * @param xids 承認待ちアイテムを登録するインデックスIDを受け取る引数
3199     * @param iids 承認待ちアイテムIDを受け取る引数
3200     * @param len iids,xidsに格納された個数を受け取る引数
3201     * @return RES_OK
3202     * @return RES_DB_NOT_INITIALIZED
3203     * @return RES_NO_SUCH_SESSION
3204     * @return RES_DB_QUERY_ERROR
3205     * @return RES_ERROR
3206     *
3207     */
3208    //result_t getUncertifiedLink( sessionid_t sid, const itemid_t** xids, const itemid_t** iids, int* len )
3209    ZEND_FUNCTION(xnp_get_uncertified_link)
3210    {
3211            long sid;
3212        zval* zxids;
3213        zval* ziids;
3214        
3215            if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
3216                                  &sid, &zxids, &ziids) == FAILURE) {
3217                    return;
3218            }
3219        
3220        const itemid_t *pxids;
3221        const itemid_t *piids;
3222        int len;
3223        result_t result = getUncertifiedLink( (sessionid_t)sid, &pxids, &piids, &len );
3224        if ( RES_OK == result ){
3225            indexidsToZval( piids, len, &zxids );
3226            itemidsToZval( piids, len, &ziids );
3227            freeIndexID( pxids );
3228            freeItemID( piids );
3229        }
3230            RETURN_LONG( result );
3231    }
3232    
3233    /**
3234     *
3235     * @param types
3236     * @return RES_OK
3237     * @return RES_DB_NOT_INITIALIZED
3238     * @return RES_NO_SUCH_SESSION
3239     * @return RES_DB_QUERY_ERROR
3240     * @return RES_ERROR
3241     *
3242     */
3243    ZEND_FUNCTION(xnp_get_item_types)
3244    {
3245        zval* ztypes;
3246        
3247            if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
3248                                  &ztypes) == FAILURE) {
3249                    return;
3250            }
3251        
3252        const itemtype_t *ptypes;
3253        int len;
3254        result_t result = getItemTypes( &ptypes, &len );
3255        if ( RES_OK == result ){
3256    
3257            zend_hash_clean( ztypes -> value.ht );
3258            for( int i = 0; i < len; i++ ){
3259                zval *new_array;
3260                MAKE_STD_ZVAL(new_array);
3261                if(array_init(new_array) != SUCCESS){
3262                    result = RES_ERROR;
3263                    break;
3264                }
3265                add_index_zval( ztypes, i, new_array );
3266                
3267                zend_hash_clean( new_array -> value.ht );
3268                add_assoc_long( new_array, "item_type_id", ptypes[ i ].getItemTypeID( ) );
3269                add_assoc_long( new_array, "mid", ptypes[ i ].getModuleID( ) );
3270                add_assoc_string( new_array, "name", ( char* )ptypes[ i ].getName( ), 1 );
3271                add_assoc_string( new_array, "display_name", ( char* )ptypes[ i ].getDisplayName( ), 1 );
3272            }
3273            result = RES_OK;
3274            freeItemType( ptypes );
3275        }
3276            RETURN_LONG( result );
3277    }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26