This repository has been archived by the owner on Nov 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.c
88 lines (74 loc) · 2.5 KB
/
session.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
+------------------------------------------------------------------------+
| Zephir Language |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to [email protected] so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <[email protected]> |
| Eduar Carvajal <[email protected]> |
| Vladimir Kolesnikov <[email protected]> |
+------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ext.h"
#include "kernel/main.h"
#include "kernel/fcall.h"
#include "kernel/session.h"
#ifdef ZEPHIR_USE_PHP_SESSION
#include <ext/session/php_session.h>
#endif
void zephir_session_start(TSRMLS_D)
{
#ifdef ZEPHIR_USE_PHP_SESSION
php_session_start(TSRMLS_C);
#else
//zephir_call_func_params(NULL, NULL, SL("session_start") TSRMLS_CC, 0);
#endif
}
void zephir_session_destroy(TSRMLS_D)
{
//zephir_call_func_params(NULL, NULL, SL("session_destroy") TSRMLS_CC, 0);
}
void zephir_get_session_id(zval *return_value, zval **return_value_ptr TSRMLS_DC)
{
#ifdef ZEPHIR_USE_PHP_SESSION
if (PS(id)) {
RETURN_STRING(PS(id), 1);
}
RETURN_EMPTY_STRING();
#else
//zephir_call_func_params(return_value, return_value_ptr, SL("session_id") TSRMLS_CC, 0);
#endif
}
void zephir_set_session_id(zval *sid TSRMLS_DC)
{
#ifdef ZEPHIR_USE_PHP_SESSION
zval copy;
int use_copy = 0;
if (unlikely(Z_TYPE_P(sid) != IS_STRING)) {
zend_make_printable_zval(sid, ©, &use_copy);
if (use_copy) {
sid = ©
}
}
if (PS(id)) {
efree(PS(id));
}
PS(id) = estrndup(Z_STRVAL_P(sid), Z_STRLEN_P(sid));
if (unlikely(use_copy)) {
zval_dtor(©);
}
#else
//zephir_call_func_params(NULL, NULL, SL("session_id") TSRMLS_CC, 1, sid);
#endif
}