Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (74 sloc) 2.75 KB
#include "php.h"
#include <libcouchbase/couchbase.h>
#ifndef PHP_COUCHBASE_H
#define PHP_COUCHBASE_H 1
#define PHP_COUCHBASE_VERSION "0.0.1"
#define PHP_COUCHBASE_EXTNAME "couchbase"
PHP_FUNCTION(couchbase_version);
PHP_FUNCTION(couchbase_create);
PHP_FUNCTION(couchbase_execute);
PHP_FUNCTION(couchbase_mget);
PHP_FUNCTION(couchbase_set);
PHP_FUNCTION(couchbase_add);
PHP_FUNCTION(couchbase_replace);
PHP_FUNCTION(couchbase_remove);
PHP_FUNCTION(couchbase_mtouch);
PHP_FUNCTION(couchbase_arithmetic);
// callbacks
PHP_FUNCTION(couchbase_set_storage_callback);
PHP_FUNCTION(couchbase_set_get_callback);
PHP_FUNCTION(couchbase_set_remove_callback);
PHP_FUNCTION(couchbase_set_touch_callback);
PHP_FUNCTION(couchbase_set_arithmetic_callback);
typedef struct _php_couchbase_instance {
libcouchbase_t instance;
void *evbase;
} php_couchbase_instance;
typedef struct _php_couchbase_callbacks {
zval *storage;
zval *get;
zval *remove;
zval *touch;
zval *arithmetic;
} php_couchbase_callbacks;
typedef enum {
STORAGE_CALLBACK = 1,
GET_CALLBACK = 2,
REMOVE_CALLBACK = 3,
TOUCH_CALLBACK = 4,
ARITHMETIC_CALLBACK = 5
} php_couchbase_callback_type;
#define PHP_COUCHBASE_INSTANCE "Couchbase Instance"
PHP_MINIT_FUNCTION(couchbase);
// forward declaration
long map_error_constant(libcouchbase_error_t error);
static void couchbase_store(INTERNAL_FUNCTION_PARAMETERS, libcouchbase_storage_t operation);
static void couchbase_set_callback(INTERNAL_FUNCTION_PARAMETERS, php_couchbase_callback_type type);
static void storage_callback(libcouchbase_t instance,
const void *cookie,
libcouchbase_storage_t operation,
libcouchbase_error_t error,
const void *key, size_t nkey,
uint64_t cas);
static void get_callback(libcouchbase_t instance,
const void *cookie,
libcouchbase_error_t error,
const void *key, size_t nkey,
const void *bytes, size_t nbytes,
uint32_t flags, uint64_t cas);
static void remove_callback(libcouchbase_t instance,
const void *cookie,
libcouchbase_error_t error,
const void *key, size_t nkey);
static void touch_callback(libcouchbase_t instance,
const void *cookie,
libcouchbase_error_t error,
const void *key, size_t nkey);
static void arithmetic_callback(libcouchbase_t instance,
const void *cookie,
libcouchbase_error_t error,
const void *key, size_t nkey,
uint64_t value, uint64_t cas);
extern zend_module_entry couchbase_module_entry;
#define phpext_hello_ptr &couchbase_module_entry
#endif