/*
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 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_0.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: Christophe Vu-Brugier <cvubrugier@yahoo.fr>                 |
   +----------------------------------------------------------------------+
*/

/* $ Id: $ */ 

#ifndef PHP_CLUCENE_H
#define PHP_CLUCENE_H

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <php.h>

#ifdef HAVE_CLUCENE

#include <php_ini.h>
#include <SAPI.h>
#include <ext/standard/info.h>
#include <Zend/zend_extensions.h>
#include <Zend/zend_exceptions.h>
#ifdef  __cplusplus
} /* extern "C" */
#endif

#include <CLucene.h>

/* Class structures */
typedef struct _index_searcher_object {
	zend_object                   std;
	lucene::search::IndexSearcher *searcher;
	wchar_t                       *field;
} index_searcher_object;

typedef struct _hits_object {
	zend_object          std;
	lucene::search::Hits *hits;
} hits_object;

/* Standard analyzer */
static lucene::analysis::standard::StandardAnalyzer 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 */


/*
 * 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
 */
