CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

session.h
1 //
3 // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
4 //
5 // See accompanying file COPYING.TXT file for licensing details.
6 //
8 #ifndef CPPCMS_CAPI_SESSION_H
9 #define CPPCMS_CAPI_SESSION_H
10 #include <cppcms/defs.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
23 #define CPPCMS_CAPI_SESSION_FIXED 0
24 #define CPPCMS_CAPI_SESSION_RENEW 1
25 #define CPPCMS_CAPI_SESSION_BROWSER 2
26
28 #define CPPCMS_CAPI_ERROR_OK 0
32 #define CPPCMS_CAPI_ERROR_GENERAL 1
33 #define CPPCMS_CAPI_ERROR_RUNTIME 2
34 #define CPPCMS_CAPI_ERROR_INVALID_ARGUMENT 4
35 #define CPPCMS_CAPI_ERROR_LOGIC 5
36 #define CPPCMS_CAPI_ERROR_ALLOC 6
37
38 typedef void *cppcms_capi_object;
44
46
50 typedef struct cppcms_capi_session_pool cppcms_capi_session_pool;
54 typedef struct cppcms_capi_session cppcms_capi_session;
58 typedef struct cppcms_capi_cookie cppcms_capi_cookie;
59
63
64 CPPCMS_API int cppcms_capi_error(cppcms_capi_object obj);
65 CPPCMS_API char const *cppcms_capi_error_message(cppcms_capi_object obj);
66 CPPCMS_API char const *cppcms_capi_error_clear(cppcms_capi_object obj);
67
69
72
74 CPPCMS_API cppcms_capi_session_pool *cppcms_capi_session_pool_new();
76 CPPCMS_API void cppcms_capi_session_pool_delete(cppcms_capi_session_pool *pool);
77
79 CPPCMS_API int cppcms_capi_session_pool_init(cppcms_capi_session_pool *pool,char const *config_file);
81 CPPCMS_API int cppcms_capi_session_pool_init_from_json(cppcms_capi_session_pool *pool,char const *json);
82
84
85 CPPCMS_API cppcms_capi_session *cppcms_capi_session_new();
86 CPPCMS_API void cppcms_capi_session_delete(cppcms_capi_session *session);
87
88
89 CPPCMS_API int cppcms_capi_session_init(cppcms_capi_session *session,cppcms_capi_session_pool *pool);
90
91 CPPCMS_API int cppcms_capi_session_clear(cppcms_capi_session *session);
92
93 CPPCMS_API int cppcms_capi_session_is_set(cppcms_capi_session *session,char const *key);
94 CPPCMS_API int cppcms_capi_session_erase(cppcms_capi_session *session,char const *key);
95 CPPCMS_API int cppcms_capi_session_get_exposed(cppcms_capi_session *session,char const *key);
96 CPPCMS_API int cppcms_capi_session_set_exposed(cppcms_capi_session *session,char const *key,int is_exposed);
97
98 CPPCMS_API char const *cppcms_capi_session_get_first_key(cppcms_capi_session *session);
99 CPPCMS_API char const *cppcms_capi_session_get_next_key(cppcms_capi_session *session);
100
101
102 CPPCMS_API char const *cppcms_capi_session_get_csrf_token(cppcms_capi_session *session);
103
104
105 CPPCMS_API int cppcms_capi_session_set(cppcms_capi_session *session,char const *key,char const *value);
106 CPPCMS_API char const *cppcms_capi_session_get(cppcms_capi_session *session,char const *key);
107
108 CPPCMS_API int cppcms_capi_session_set_binary_as_hex(cppcms_capi_session *session,char const *key,char const *value);
109 CPPCMS_API char const *cppcms_capi_session_get_binary_as_hex(cppcms_capi_session *session,char const *key);
110
111 CPPCMS_API int cppcms_capi_session_set_binary(cppcms_capi_session *session,char const *key,void const *value,int length);
112 CPPCMS_API int cppcms_capi_session_get_binary(cppcms_capi_session *session,char const *key,void *buf,int buffer_size);
113 CPPCMS_API int cppcms_capi_session_get_binary_len(cppcms_capi_session *session,char const *key);
114
115
116 CPPCMS_API int cppcms_capi_session_reset_session(cppcms_capi_session *session);
117
118 CPPCMS_API int cppcms_capi_session_set_default_age(cppcms_capi_session *session);
119 CPPCMS_API int cppcms_capi_session_set_age(cppcms_capi_session *session,int t);
120 CPPCMS_API int cppcms_capi_session_get_age(cppcms_capi_session *session);
121
122 CPPCMS_API int cppcms_capi_session_set_default_expiration(cppcms_capi_session *session);
124 CPPCMS_API int cppcms_capi_session_set_expiration(cppcms_capi_session *session,int t);
126 CPPCMS_API int cppcms_capi_session_get_expiration(cppcms_capi_session *session);
127
128 CPPCMS_API int cppcms_capi_session_set_on_server(cppcms_capi_session *session,int is_on_server);
129 CPPCMS_API int cppcms_capi_session_get_on_server(cppcms_capi_session *session);
130
131 CPPCMS_API char const *cppcms_capi_session_get_session_cookie_name(cppcms_capi_session *session);
132 CPPCMS_API int cppcms_capi_session_set_session_cookie(cppcms_capi_session *session,char const *session_cookie_value);
133 CPPCMS_API int cppcms_capi_session_add_cookie_name(cppcms_capi_session *session,char const *name);
134 CPPCMS_API int cppcms_capi_session_load(cppcms_capi_session *session);
135 CPPCMS_API int cppcms_capi_session_save(cppcms_capi_session *session);
136
137 CPPCMS_API cppcms_capi_cookie *cppcms_capi_session_cookie_first(cppcms_capi_session *session);
138 CPPCMS_API cppcms_capi_cookie *cppcms_capi_session_cookie_next(cppcms_capi_session *session);
139
140 CPPCMS_API void cppcms_capi_cookie_delete(cppcms_capi_cookie *cookie);
141
142 CPPCMS_API char const *cppcms_capi_cookie_header(cppcms_capi_cookie const *cookie);
143 CPPCMS_API char const *cppcms_capi_cookie_header_content(cppcms_capi_cookie const *cookie);
144
145 CPPCMS_API char const *cppcms_capi_cookie_name(cppcms_capi_cookie const *cookie);
146 CPPCMS_API char const *cppcms_capi_cookie_value(cppcms_capi_cookie const *cookie);
147 CPPCMS_API char const *cppcms_capi_cookie_path(cppcms_capi_cookie const *cookie);
148 CPPCMS_API char const *cppcms_capi_cookie_domain(cppcms_capi_cookie const *cookie);
149
150 CPPCMS_API int cppcms_capi_cookie_max_age_defined(cppcms_capi_cookie const *cookie);
151 CPPCMS_API unsigned cppcms_capi_cookie_max_age(cppcms_capi_cookie const *cookie);
152
153 CPPCMS_API int cppcms_capi_cookie_expires_defined(cppcms_capi_cookie const *cookie);
154 CPPCMS_API long long cppcms_capi_cookie_expires(cppcms_capi_cookie const *cookie);
155
156 CPPCMS_API int cppcms_capi_cookie_is_secure(cppcms_capi_cookie const *cookie);
157
161 #ifdef __cplusplus
162 } // extern "C"
163 #endif
164 #endif
cppcms_capi_session_pool_init_from_json
CPPCMS_API int cppcms_capi_session_pool_init_from_json(cppcms_capi_session_pool *pool, char const *json)
Initialize the pool from CppCMS configuration in json fromat json.
cppcms_capi_session_pool_init
CPPCMS_API int cppcms_capi_session_pool_init(cppcms_capi_session_pool *pool, char const *config_file)
Initialize the pool from CppCMS configuration file,config_file.
cppcms_capi_error_message
CPPCMS_API char const * cppcms_capi_error_message(cppcms_capi_object obj)
Get error message for the object.
cppcms_capi_object
void * cppcms_capi_object
Definition: session.h:43
cppcms_capi_error
CPPCMS_API int cppcms_capi_error(cppcms_capi_object obj)
Get error code for the object.
cppcms_capi_session_set_expiration
CPPCMS_API int cppcms_capi_session_set_expiration(cppcms_capi_session *session, int t)
Define expiration method.
cppcms_capi_session_pool_new
CPPCMS_API cppcms_capi_session_pool * cppcms_capi_session_pool_new()
Create new empty pool object, returns NULL in case of fatal error.
cppcms_capi_session_get_expiration
CPPCMS_API int cppcms_capi_session_get_expiration(cppcms_capi_session *session)
Get current expiration method.
cppcms_capi_session_pool_delete
CPPCMS_API void cppcms_capi_session_pool_delete(cppcms_capi_session_pool *pool)
Destroys pool object.
cppcms_capi_error_clear
CPPCMS_API char const * cppcms_capi_error_clear(cppcms_capi_object obj)
Clear error and get last message.