前言:
以前在空闲时,研究过PHP的扩展模块开发,苦于没有找到一个比较好的调试方法,因此只做了少量的基本工作,感觉zend公司开发的PHP扩展模块有点过于复杂,调试真是让人头痛的事,若哪位有比跟踪调试的好方法,请留言。
zend PHP的扩展模块开发帮助方面的,google等能找到,这里把曾经做过的接口部分给出来大家看看
clucene可能有不稳定的部分,在写接口前最好先测试,至于哪里有问题,当时忘做笔记了,暂时忘了
/************************************
** php_clucene.h
/************************************
#ifndef PHP_CLUCENE_H
#define PHP_CLUCENE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_CLUCENE
#include
#include
#include
#include
#include
#ifdef __cplusplus
} /* extern "C" */
#endif
#include
/* Class structures */
typedef struct _index_searcher_object {
zend_object std;
lucene::search::IndexSearcher *searcher;
const wchar_t **field;
} index_searcher_object;
typedef struct _hits_object {
zend_object std;
lucene::search::Hits *hits;
} hits_object;
//没实现
/******************************
typedef struct _index_writer_object {
zend_object std;
lucene::index::IndexWriter *writer;
wchar_t *field;
} index_writer_object;
/******************************/
/* Standard analyzer */
//ictclas 分词系统
//static lucene::analysis::standard::StandardAnalyzer analyzer;
static lucene::analysis::standard::StandardIctclas analyzer;
#ifdef __cplusplus
extern "C" {
#endif
extern zend_module_entry clucene_module_entry;
#define phpext_clucene_ptr &clucene_module_entry
#ifdef PHP_WIN32
#define PHP_CLUCENE_API __declspec(dllexport)
#else
#define PHP_CLUCENE_API
#endif
PHP_MINIT_FUNCTION(clucene);
PHP_MSHUTDOWN_FUNCTION(clucene);
PHP_RINIT_FUNCTION(clucene);
PHP_RSHUTDOWN_FUNCTION(clucene);
PHP_MINFO_FUNCTION(clucene);
#ifdef ZTS
#include "TSRM.h"
#endif
#define FREE_RESOURCE(resource) zend_list_delete(Z_LVAL_P(resource))
#define PROP_GET_LONG(name) Z_LVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
#define PROP_SET_LONG(name, l) zend_update_property_long(_this_ce, _this_zval, #name, strlen(#name), l TSRMLS_CC)
#define PROP_GET_DOUBLE(name) Z_DVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
#define PROP_SET_DOUBLE(name, d) zend_update_property_double(_this_ce, _this_zval, #name, strlen(#name), d TSRMLS_CC)
#define PROP_GET_STRING(name) Z_STRVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
#define PROP_GET_STRLEN(name) Z_STRLEN_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
#define PROP_SET_STRING(name, s) zend_update_property_string(_this_ce, _this_zval, #name, strlen(#name), s TSRMLS_CC)
#define PROP_SET_STRINGL(name, s, l) zend_update_property_string(_this_ce, _this_zval, #name, strlen(#name), s, l TSRMLS_CC)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PHP_HAVE_CLUCENE */
#endif /* PHP_CLUCENE_H */
阅读(2393) | 评论(0) | 转发(0) |