Apache2
mod_session.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MOD_SESSION_H
18 #define MOD_SESSION_H
19 
20 /* Create a set of SESSION_DECLARE(type), SESSION_DECLARE_NONSTD(type) and
21  * SESSION_DECLARE_DATA with appropriate export and import tags for the platform
22  */
23 #if !defined(WIN32)
24 #define SESSION_DECLARE(type) type
25 #define SESSION_DECLARE_NONSTD(type) type
26 #define SESSION_DECLARE_DATA
27 #elif defined(SESSION_DECLARE_STATIC)
28 #define SESSION_DECLARE(type) type __stdcall
29 #define SESSION_DECLARE_NONSTD(type) type
30 #define SESSION_DECLARE_DATA
31 #elif defined(SESSION_DECLARE_EXPORT)
32 #define SESSION_DECLARE(type) __declspec(dllexport) type __stdcall
33 #define SESSION_DECLARE_NONSTD(type) __declspec(dllexport) type
34 #define SESSION_DECLARE_DATA __declspec(dllexport)
35 #else
36 #define SESSION_DECLARE(type) __declspec(dllimport) type __stdcall
37 #define SESSION_DECLARE_NONSTD(type) __declspec(dllimport) type
38 #define SESSION_DECLARE_DATA __declspec(dllimport)
39 #endif
40 
50 #include "apr_hooks.h"
51 #include "apr_optional.h"
52 #include "apr_tables.h"
53 #include "apr_uuid.h"
54 #include "apr_pools.h"
55 #include "apr_time.h"
56 
57 #include "httpd.h"
58 #include "http_config.h"
59 #include "ap_config.h"
60 
61 #define MOD_SESSION_NOTES_KEY "mod_session_key"
62 
67 #define MOD_SESSION_USER "user"
68 
73 #define MOD_SESSION_PW "pw"
74 
84 typedef struct {
85  apr_pool_t *pool; /* pool to be used for this session */
86  apr_uuid_t *uuid; /* anonymous uuid of this particular session */
87  const char *remote_user; /* user who owns this particular session */
88  apr_table_t *entries; /* key value pairs */
89  const char *encoded; /* the encoded version of the key value pairs */
90  apr_time_t expiry; /* if > 0, the time of expiry of this session */
91  long maxage; /* if > 0, the maxage of the session, from
92  * which expiry is calculated */
93  int dirty; /* dirty flag */
94  int cached; /* true if this session was loaded from a
95  * cache of some kind */
96  int written; /* true if this session has already been
97  * written */
98 } session_rec;
99 
103 typedef struct {
104  int enabled; /* whether the session has been enabled for
105  * this directory */
107  long maxage; /* seconds until session expiry */
109  const char *header; /* header to inject session */
111  int env; /* whether the session has been enabled for
112  * this directory */
113  int env_set;
114  apr_array_header_t *includes; /* URL prefixes to be included. All
115  * URLs included if empty */
116  apr_array_header_t *excludes; /* URL prefixes to be excluded. No
117  * URLs excluded if empty */
118  apr_time_t expiry_update_time; /* seconds the session expiry may change and
119  * not have to be rewritten */
122 
131 APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_load,
133 
134 
143 APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_save,
145 
146 
156 APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_encode,
158 
159 
169 APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_decode,
171 
173  apr_status_t,
175  (request_rec * r, session_rec * z, const char *key, const char **value));
177  (request_rec * r, session_rec * z, const char *key, const char *value));
182 
187 
188 #endif /* MOD_SESSION_H */
Symbol export macros and hook functions.
Apache hook functions.
APR-UTIL registration of functions exported by modules.
APR memory allocation.
APR Table library.
APR Time Library.
APR UUID library.
#define APR_DECLARE_EXTERNAL_HOOK(ns, link, ret, name, args)
Definition: apr_hooks.h:118
#define APR_DECLARE_OPTIONAL_FN(ret, name, args)
Definition: apr_optional.h:50
request_rec * r
Definition: mod_dav.h:518
module AP_MODULE_DECLARE_DATA session_module
apr_status_t ap_session_save(request_rec *, session_rec *)
apr_status_t ap_session_get(request_rec *r, session_rec *z, const char *key, const char **value)
apr_status_t ap_session_load(request_rec *, session_rec **)
apr_status_t ap_session_set(request_rec *r, session_rec *z, const char *key, const char *value)
int apr_status_t
Definition: apr_errno.h:44
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
apr_int64_t apr_time_t
Definition: apr_time.h:45
Apache Configuration.
HTTP Daemon routines.
#define AP_MODULE_DECLARE_DATA
Definition: macros.h:16
Definition: apr_tables.h:62
Definition: apr_uuid.h:41
Definition: http_config.h:348
A structure that represents the current request.
Definition: httpd.h:856
Definition: mod_session.h:103
int header_set
Definition: mod_session.h:110
apr_time_t expiry_update_time
Definition: mod_session.h:118
apr_array_header_t * includes
Definition: mod_session.h:114
int env
Definition: mod_session.h:111
const char * header
Definition: mod_session.h:109
int maxage_set
Definition: mod_session.h:108
int enabled
Definition: mod_session.h:104
int enabled_set
Definition: mod_session.h:106
long maxage
Definition: mod_session.h:107
apr_array_header_t * excludes
Definition: mod_session.h:116
int expiry_update_set
Definition: mod_session.h:120
int env_set
Definition: mod_session.h:113
Definition: mod_session.h:84
apr_time_t expiry
Definition: mod_session.h:90
apr_pool_t * pool
Definition: mod_session.h:85
int written
Definition: mod_session.h:96
apr_table_t * entries
Definition: mod_session.h:88
const char * remote_user
Definition: mod_session.h:87
apr_uuid_t * uuid
Definition: mod_session.h:86
const char * encoded
Definition: mod_session.h:89
int dirty
Definition: mod_session.h:93
long maxage
Definition: mod_session.h:91
int cached
Definition: mod_session.h:94