@@ -0,0 +1,16 @@ | |||
<?php | |||
include_once('cppcms.php'); | |||
$pool=CppCMS_SessionPool::from_config('cppcms-config.js'); | |||
$session=$pool->session(); | |||
$session->load(); | |||
$x=0; | |||
if($session->is_set('x')) { | |||
$x=$session['x']; | |||
} | |||
$x=intval($x)+1; | |||
$session['x']=$x; | |||
$session->save(); | |||
echo "x=$x\n"; |
@@ -0,0 +1,197 @@ | |||
<?php | |||
include 'cppcms_api.php'; | |||
class CppCMS_SessioBase { | |||
protected $api = null; | |||
protected function check() | |||
{ | |||
$code = $this->api->error(); | |||
if($code == 0) | |||
return; | |||
$msg = $this->api->error_clear(); | |||
switch($code) { | |||
case cppcms_api::ERROR_INVALID_ARGUMENT; | |||
throw new InvalidArgumentException($msg); | |||
case cppcms_api::ERROR_LOGIC; | |||
throw new LogicException($msg); | |||
default: | |||
throw new RuntimeException($msg); | |||
} | |||
} | |||
}; | |||
class CppCMS_SessionPool extends CppCMS_SessioBase { | |||
private function __construct() | |||
{ | |||
$this->api = new CppCMSAPIPool; | |||
} | |||
public static function from_config($path) | |||
{ | |||
$pool=new CppCMS_SessionPool(); | |||
$pool->api->init($path); | |||
$pool->check(); | |||
return $pool; | |||
} | |||
public static function from_json($json) | |||
{ | |||
$pool=new CppCMS_SessionPool(); | |||
$pool->api->init_from_json($json); | |||
$pool->check(); | |||
return $pool; | |||
} | |||
public function session() | |||
{ | |||
return new CppCMS_Session($this); | |||
} | |||
} | |||
class CppCMS_Cookie { | |||
private $c=null; | |||
public function __construct($c) | |||
{ | |||
$this->c=$c; | |||
} | |||
function header() { return $this->c->header(); } | |||
function header_content() { return $this->c->header_content(); } | |||
function name() { return $this->c->name(); } | |||
function value() { return $this->c->value(); } | |||
function path() { return $this->c->path(); } | |||
function domain() { return $this->c->domain(); } | |||
function max_age_defined() { return $this->c->max_age_defined() != 0; } | |||
function max_age() { return $this->c->max_age(); } | |||
function expires_defined() { return $this->c->expires_defined() != 0; } | |||
function expires() { return $this->c->expires(); } | |||
function is_secure() { return $this->c->is_secure(); } | |||
function __toString() { return $this->header(); } | |||
} | |||
class CppCMS_Session extends CppCMS_SessioBase implements ArrayAccess { | |||
public function __construct($pool) | |||
{ | |||
$this->api = new CppCMSAPISession; | |||
$this->api->init($pool->api); | |||
$this->check(); | |||
} | |||
function clear() { $this->api->clear(); $this->check(); } | |||
function is_set($key) { $r = $this->api->is_set($key)!=0; $this->check(); return $r; } | |||
function erase($key) { $this->api->erase($key); $this->check(); } | |||
function set($key,$value) { | |||
$this->api->set_binary_as_hex($key,bin2hex($value)); | |||
$this->check(); | |||
} | |||
function get($key) { | |||
$r=$this->api->get_binary_as_hex($key); | |||
$this->check(); | |||
if($r==null) | |||
return null; | |||
return hex2bin($r); | |||
} | |||
/// ArrayAccess API | |||
function offsetExists($key) { return $this->is_set($key); } | |||
function offsetUnset($key) { $this->erase($key); } | |||
function offsetGet($key) { return $this->get($key); } | |||
function offsetSet($key,$value) { $this->set($key,$value); } | |||
function get_exposed($key) { $r=$this->api->get_exposed($key)!=0; $this->check(); return $r; } | |||
function set_exposed($key,$is_exposed) { $this->api->set_exposed($key,$is_exposed?1:0 ); $this->check(); } | |||
function keys() { | |||
$r=array(); | |||
$k=$this->api->get_first_key(); | |||
while($k!=null) { | |||
$r[]=$k; | |||
$k=$this->api->get_next_key(); | |||
} | |||
$this->check(); | |||
return $r; | |||
} | |||
function get_csrf_token() { $r=$this->api->get_csrf_token(); $this->check(); return $r; } | |||
function reset_session() { $this->api->reset_session(); $this->check(); } | |||
function set_default_age() { $this->api->set_default_age(); $this->check(); } | |||
function set_age($t) { $this->api->set_age($t); $this->check(); } | |||
function get_age() { $r=$this->api->get_age(); $this->check(); return $r; } | |||
function set_default_expiration() { $this->api->set_default_expiration(); $this->check(); } | |||
function set_expiration($t) { $this->api->set_expiration($t); $this->check(); } | |||
function get_expiration() { $r = $this->api->get_expiration(); $this->check(); return $r; } | |||
function set_on_server($is_on_server) { $this->api->set_on_server($is_on_server ? 1 : 0); $this->check(); } | |||
function get_on_server() { $r = $this->api->get_on_server(); $this->check(); return $r!=0; } | |||
function get_session_cookie_name() { $r=$this->api->get_session_cookie_name(); $this->check(); return $r; } | |||
function load($session_cookie_value = null) { | |||
if($session_cookie_value == null) { | |||
$name = $this->get_session_cookie_name(); | |||
if(isset($_COOKIE[$name])) { | |||
$session_cookie_value = $_COOKIE[$name]; | |||
} | |||
} | |||
if($session_cookie_value == null) | |||
$session_cookie_value = ""; | |||
$this->api->load($session_cookie_value); | |||
$this->check(); | |||
} | |||
function cookies() { | |||
$r=array(); | |||
$c=$this->api->cookie_first(); | |||
$this->check(); | |||
while($c!=null) { | |||
$r[]=new CppCMS_Cookie($c); | |||
$c=$this->api->cookie_next(); | |||
$this->check(); | |||
} | |||
return $r; | |||
} | |||
function save($set_headers = true) { | |||
$this->api->save(); | |||
$this->check(); | |||
if($set_headers) { | |||
$c=$this->api->cookie_first(); | |||
$this->check(); | |||
while($c!=null) { | |||
header($c->header(),false); | |||
$c=$this->api->cookie_next(); | |||
$this->check(); | |||
} | |||
} | |||
} | |||
} | |||
// Code Test | |||
if (!count(debug_backtrace())) | |||
{ | |||
$pool = CppCMS_SessionPool::from_config('cppcms-config.js'); | |||
$session = $pool->session(); | |||
$session->load(); | |||
$session['x']='yes'; | |||
$session['y']=13.4; | |||
$session->set_exposed('y',true); | |||
$session->save(false); | |||
$cookies = $session->cookies(); | |||
$state=''; | |||
foreach($cookies as $c) { | |||
echo $c,"\n"; | |||
if($c->name() == $session->get_session_cookie_name()) | |||
$state = $c->value(); | |||
} | |||
$session = $pool->session(); | |||
$session->load($state); | |||
$session->set_exposed('y',false); | |||
echo implode(', ',$session->keys()),"\n"; | |||
$session->save(false); | |||
$cookies = $session->cookies(); | |||
foreach($cookies as $c) { | |||
echo $c,"\n"; | |||
if($c->name() == $session->get_session_cookie_name()) | |||
$state = $c->value(); | |||
} | |||
} |
@@ -0,0 +1,335 @@ | |||
<?php | |||
/* ---------------------------------------------------------------------------- | |||
* This file was automatically generated by SWIG (http://www.swig.org). | |||
* Version 2.0.11 | |||
* | |||
* This file is not intended to be easily readable and contains a number of | |||
* coding conventions designed to improve portability and efficiency. Do not make | |||
* changes to this file unless you know what you are doing--modify the SWIG | |||
* interface file instead. | |||
* ----------------------------------------------------------------------------- */ | |||
// Try to load our extension if it's not already loaded. | |||
if (!extension_loaded('cppcms_api')) { | |||
if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { | |||
if (!dl('php_cppcms_api.dll')) return; | |||
} else { | |||
// PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'. | |||
if (PHP_SHLIB_SUFFIX === 'dylib') { | |||
if (!dl('cppcms_api.so')) return; | |||
} else { | |||
if (!dl('cppcms_api.'.PHP_SHLIB_SUFFIX)) return; | |||
} | |||
} | |||
} | |||
abstract class cppcms_api { | |||
const SESSION_FIXED = SESSION_FIXED; | |||
const SESSION_RENEW = SESSION_RENEW; | |||
const SESSION_BROWSER = SESSION_BROWSER; | |||
const ERROR_OK = ERROR_OK; | |||
const ERROR_GENERAL = ERROR_GENERAL; | |||
const ERROR_RUNTIME = ERROR_RUNTIME; | |||
const ERROR_INVALID_ARGUMENT = ERROR_INVALID_ARGUMENT; | |||
const ERROR_LOGIC = ERROR_LOGIC; | |||
const ERROR_ALLOC = ERROR_ALLOC; | |||
} | |||
/* PHP Proxy Classes */ | |||
class CppCMSAPIPool { | |||
public $_cPtr=null; | |||
protected $_pData=array(); | |||
function __set($var,$value) { | |||
if ($var === 'thisown') return swig_cppcms_api_alter_newobject($this->_cPtr,$value); | |||
$this->_pData[$var] = $value; | |||
} | |||
function __isset($var) { | |||
if ($var === 'thisown') return true; | |||
return array_key_exists($var, $this->_pData); | |||
} | |||
function __get($var) { | |||
if ($var === 'thisown') return swig_cppcms_api_get_newobject($this->_cPtr); | |||
return $this->_pData[$var]; | |||
} | |||
function __construct($res=null) { | |||
if (is_resource($res) && get_resource_type($res) === '_p_cppcms_capi_session_pool') { | |||
$this->_cPtr=$res; | |||
return; | |||
} | |||
$this->_cPtr=new_CppCMSAPIPool(); | |||
} | |||
function error() { | |||
return CppCMSAPIPool_error($this->_cPtr); | |||
} | |||
function error_message() { | |||
return CppCMSAPIPool_error_message($this->_cPtr); | |||
} | |||
function error_clear() { | |||
return CppCMSAPIPool_error_clear($this->_cPtr); | |||
} | |||
function init($conf) { | |||
return CppCMSAPIPool_init($this->_cPtr,$conf); | |||
} | |||
function init_from_json($conf) { | |||
return CppCMSAPIPool_init_from_json($this->_cPtr,$conf); | |||
} | |||
} | |||
class CppCMSAPISession { | |||
public $_cPtr=null; | |||
protected $_pData=array(); | |||
function __set($var,$value) { | |||
if ($var === 'thisown') return swig_cppcms_api_alter_newobject($this->_cPtr,$value); | |||
$this->_pData[$var] = $value; | |||
} | |||
function __isset($var) { | |||
if ($var === 'thisown') return true; | |||
return array_key_exists($var, $this->_pData); | |||
} | |||
function __get($var) { | |||
if ($var === 'thisown') return swig_cppcms_api_get_newobject($this->_cPtr); | |||
return $this->_pData[$var]; | |||
} | |||
function __construct($res=null) { | |||
if (is_resource($res) && get_resource_type($res) === '_p_cppcms_capi_session') { | |||
$this->_cPtr=$res; | |||
return; | |||
} | |||
$this->_cPtr=new_CppCMSAPISession(); | |||
} | |||
function error() { | |||
return CppCMSAPISession_error($this->_cPtr); | |||
} | |||
function error_message() { | |||
return CppCMSAPISession_error_message($this->_cPtr); | |||
} | |||
function error_clear() { | |||
return CppCMSAPISession_error_clear($this->_cPtr); | |||
} | |||
function init($pool) { | |||
return CppCMSAPISession_init($this->_cPtr,$pool); | |||
} | |||
function clear() { | |||
return CppCMSAPISession_clear($this->_cPtr); | |||
} | |||
function is_set($key) { | |||
return CppCMSAPISession_is_set($this->_cPtr,$key); | |||
} | |||
function erase($key) { | |||
return CppCMSAPISession_erase($this->_cPtr,$key); | |||
} | |||
function get_exposed($key) { | |||
return CppCMSAPISession_get_exposed($this->_cPtr,$key); | |||
} | |||
function set_exposed($key,$is_exposed) { | |||
return CppCMSAPISession_set_exposed($this->_cPtr,$key,$is_exposed); | |||
} | |||
function get_first_key() { | |||
return CppCMSAPISession_get_first_key($this->_cPtr); | |||
} | |||
function get_next_key() { | |||
return CppCMSAPISession_get_next_key($this->_cPtr); | |||
} | |||
function get_csrf_token() { | |||
return CppCMSAPISession_get_csrf_token($this->_cPtr); | |||
} | |||
function set($key,$value) { | |||
return CppCMSAPISession_set($this->_cPtr,$key,$value); | |||
} | |||
function get($key) { | |||
return CppCMSAPISession_get($this->_cPtr,$key); | |||
} | |||
function set_binary_as_hex($key,$value) { | |||
return CppCMSAPISession_set_binary_as_hex($this->_cPtr,$key,$value); | |||
} | |||
function get_binary_as_hex($key) { | |||
return CppCMSAPISession_get_binary_as_hex($this->_cPtr,$key); | |||
} | |||
function get_binary_len($key) { | |||
return CppCMSAPISession_get_binary_len($this->_cPtr,$key); | |||
} | |||
function reset_session() { | |||
return CppCMSAPISession_reset_session($this->_cPtr); | |||
} | |||
function set_default_age() { | |||
return CppCMSAPISession_set_default_age($this->_cPtr); | |||
} | |||
function set_age($t) { | |||
return CppCMSAPISession_set_age($this->_cPtr,$t); | |||
} | |||
function get_age() { | |||
return CppCMSAPISession_get_age($this->_cPtr); | |||
} | |||
function set_default_expiration() { | |||
return CppCMSAPISession_set_default_expiration($this->_cPtr); | |||
} | |||
function set_expiration($t) { | |||
return CppCMSAPISession_set_expiration($this->_cPtr,$t); | |||
} | |||
function get_expiration() { | |||
return CppCMSAPISession_get_expiration($this->_cPtr); | |||
} | |||
function set_on_server($is_on_server) { | |||
return CppCMSAPISession_set_on_server($this->_cPtr,$is_on_server); | |||
} | |||
function get_on_server() { | |||
return CppCMSAPISession_get_on_server($this->_cPtr); | |||
} | |||
function get_session_cookie_name() { | |||
return CppCMSAPISession_get_session_cookie_name($this->_cPtr); | |||
} | |||
function load($session_cookie_value) { | |||
return CppCMSAPISession_load($this->_cPtr,$session_cookie_value); | |||
} | |||
function save() { | |||
return CppCMSAPISession_save($this->_cPtr); | |||
} | |||
function cookie_first() { | |||
$r=CppCMSAPISession_cookie_first($this->_cPtr); | |||
if (is_resource($r)) { | |||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); | |||
if (class_exists($c)) return new $c($r); | |||
return new CppCMSAPICookie($r); | |||
} | |||
return $r; | |||
} | |||
function cookie_next() { | |||
$r=CppCMSAPISession_cookie_next($this->_cPtr); | |||
if (is_resource($r)) { | |||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); | |||
if (class_exists($c)) return new $c($r); | |||
return new CppCMSAPICookie($r); | |||
} | |||
return $r; | |||
} | |||
} | |||
class CppCMSAPICookie { | |||
public $_cPtr=null; | |||
protected $_pData=array(); | |||
function __set($var,$value) { | |||
if ($var === 'thisown') return swig_cppcms_api_alter_newobject($this->_cPtr,$value); | |||
$this->_pData[$var] = $value; | |||
} | |||
function __isset($var) { | |||
if ($var === 'thisown') return true; | |||
return array_key_exists($var, $this->_pData); | |||
} | |||
function __get($var) { | |||
if ($var === 'thisown') return swig_cppcms_api_get_newobject($this->_cPtr); | |||
return $this->_pData[$var]; | |||
} | |||
function __construct($res=null) { | |||
if (is_resource($res) && get_resource_type($res) === '_p_cppcms_capi_cookie') { | |||
$this->_cPtr=$res; | |||
return; | |||
} | |||
$this->_cPtr=new_CppCMSAPICookie(); | |||
} | |||
function header() { | |||
return CppCMSAPICookie_header($this->_cPtr); | |||
} | |||
function header_content() { | |||
return CppCMSAPICookie_header_content($this->_cPtr); | |||
} | |||
function name() { | |||
return CppCMSAPICookie_name($this->_cPtr); | |||
} | |||
function value() { | |||
return CppCMSAPICookie_value($this->_cPtr); | |||
} | |||
function path() { | |||
return CppCMSAPICookie_path($this->_cPtr); | |||
} | |||
function domain() { | |||
return CppCMSAPICookie_domain($this->_cPtr); | |||
} | |||
function max_age_defined() { | |||
return CppCMSAPICookie_max_age_defined($this->_cPtr); | |||
} | |||
function max_age() { | |||
return CppCMSAPICookie_max_age($this->_cPtr); | |||
} | |||
function expires_defined() { | |||
return CppCMSAPICookie_expires_defined($this->_cPtr); | |||
} | |||
function expires() { | |||
return CppCMSAPICookie_expires($this->_cPtr); | |||
} | |||
function is_secure() { | |||
return CppCMSAPICookie_is_secure($this->_cPtr); | |||
} | |||
} | |||
?> |
@@ -0,0 +1,83 @@ | |||
/* ---------------------------------------------------------------------------- | |||
* This file was automatically generated by SWIG (http://www.swig.org). | |||
* Version 2.0.11 | |||
* | |||
* This file is not intended to be easily readable and contains a number of | |||
* coding conventions designed to improve portability and efficiency. Do not make | |||
* changes to this file unless you know what you are doing--modify the SWIG | |||
* interface file instead. | |||
* ----------------------------------------------------------------------------- */ | |||
#ifndef PHP_CPPCMS_API_H | |||
#define PHP_CPPCMS_API_H | |||
extern zend_module_entry cppcms_api_module_entry; | |||
#define phpext_cppcms_api_ptr &cppcms_api_module_entry | |||
#ifdef PHP_WIN32 | |||
# define PHP_CPPCMS_API_API __declspec(dllexport) | |||
#else | |||
# define PHP_CPPCMS_API_API | |||
#endif | |||
#ifdef ZTS | |||
#include "TSRM.h" | |||
#endif | |||
PHP_MINIT_FUNCTION(cppcms_api); | |||
PHP_MSHUTDOWN_FUNCTION(cppcms_api); | |||
PHP_RINIT_FUNCTION(cppcms_api); | |||
PHP_RSHUTDOWN_FUNCTION(cppcms_api); | |||
PHP_MINFO_FUNCTION(cppcms_api); | |||
ZEND_NAMED_FUNCTION(_wrap_new_CppCMSAPIPool); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPIPool_error); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPIPool_error_message); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPIPool_error_clear); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPIPool_init); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPIPool_init_from_json); | |||
ZEND_NAMED_FUNCTION(_wrap_new_CppCMSAPISession); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_error); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_error_message); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_error_clear); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_init); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_clear); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_is_set); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_erase); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_exposed); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set_exposed); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_first_key); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_next_key); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_csrf_token); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set_binary_as_hex); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_binary_as_hex); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_binary_len); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_reset_session); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set_default_age); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set_age); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_age); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set_default_expiration); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set_expiration); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_expiration); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_set_on_server); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_on_server); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_get_session_cookie_name); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_load); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_save); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_cookie_first); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPISession_cookie_next); | |||
ZEND_NAMED_FUNCTION(_wrap_new_CppCMSAPICookie); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_header); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_header_content); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_name); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_value); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_path); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_domain); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_max_age_defined); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_max_age); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_expires_defined); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_expires); | |||
ZEND_NAMED_FUNCTION(_wrap_CppCMSAPICookie_is_secure); | |||
#endif /* PHP_CPPCMS_API_H */ |
@@ -0,0 +1,90 @@ | |||
%{ | |||
#include <cppcms/capi/session.h> | |||
%} | |||
%constant SESSION_FIXED = 0; | |||
%constant SESSION_RENEW = 1; | |||
%constant SESSION_BROWSER = 2; | |||
%constant ERROR_OK = 0; | |||
%constant ERROR_GENERAL = 1; | |||
%constant ERROR_RUNTIME = 2; | |||
%constant ERROR_INVALID_ARGUMENT = 4; | |||
%constant ERROR_LOGIC = 5; | |||
%constant ERROR_ALLOC = 6; | |||
%rename(CppCMSAPIPool) cppcms_capi_session_pool; | |||
typedef struct cppcms_capi_session_pool{} cppcms_capi_session_pool; | |||
%rename(CppCMSAPISession) cppcms_capi_session; | |||
typedef struct cppcms_capi_session{} cppcms_capi_session; | |||
%rename(CppCMSAPICookie) cppcms_capi_cookie; | |||
typedef struct cppcms_capi_cookie{} cppcms_capi_cookie; | |||
%extend cppcms_capi_session_pool { | |||
cppcms_capi_session_pool() { return cppcms_capi_session_pool_new(); } | |||
~cppcms_capi_session_pool() { return cppcms_capi_session_pool_delete($self); } | |||
int error() { return cppcms_capi_error($self); } | |||
char const *error_message() { return cppcms_capi_error_message($self); } | |||
char const *error_clear() { return cppcms_capi_error_clear($self); } | |||
int init(char const *conf); | |||
int init_from_json(char const *conf); | |||
}; | |||
%extend cppcms_capi_session { | |||
cppcms_capi_session() { return cppcms_capi_session_new(); } | |||
~cppcms_capi_session() { return cppcms_capi_session_delete($self); } | |||
int error() { return cppcms_capi_error($self); } | |||
char const *error_message() { return cppcms_capi_error_message($self); } | |||
char const *error_clear() { return cppcms_capi_error_clear($self); } | |||
int init(cppcms_capi_session_pool *pool); | |||
int clear(); | |||
int is_set(char const *key); | |||
int erase(char const *key); | |||
int get_exposed(char const *key); | |||
int set_exposed(char const *key,int is_exposed); | |||
char const *get_first_key(); | |||
char const *get_next_key(); | |||
char const *get_csrf_token(); | |||
int set(char const *key,char const *value); | |||
char const *get(char const *key); | |||
int set_binary_as_hex(char const *key,char const *value); | |||
char const *get_binary_as_hex(char const *key); | |||
#int set_binary(char const *key,void const *value,int length); | |||
#int get_binary(char const *key,void *buf,int buffer_size); | |||
int get_binary_len(char const *key); | |||
int reset_session(); | |||
int set_default_age(); | |||
int set_age(int t); | |||
int get_age(); | |||
int set_default_expiration(); | |||
int set_expiration(int t); | |||
int get_expiration(); | |||
int set_on_server(int is_on_server); | |||
int get_on_server(); | |||
char const *get_session_cookie_name(); | |||
int load(char const *session_cookie_value); | |||
int save(); | |||
%newobject cookie_first; | |||
cppcms_capi_cookie *cookie_first(); | |||
%newobject cookie_next; | |||
cppcms_capi_cookie *cookie_next(); | |||
}; | |||
%extend cppcms_capi_cookie { | |||
cppcms_capi_cookie() { return NULL; } | |||
~cppcms_capi_cookie() { cppcms_capi_cookie_delete($self); } | |||
char const *header(); | |||
char const *header_content(); | |||
char const *name(); | |||
char const *value(); | |||
char const *path(); | |||
char const *domain(); | |||
int max_age_defined(); | |||
unsigned max_age(); | |||
int expires_defined(); | |||
long long expires(); | |||
int is_secure(); | |||
}; | |||
@@ -0,0 +1,3 @@ | |||
#!/bin/bash | |||
swig -module cppcms_api -php -outdir ../php -o ../php/cppcms_api.c cppcms.i |