OSDN Git Service

* merge from 0.10.0
[modchxj/mod_chxj.git] / include / chxj_cookie.h
1 /*
2  * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef __CHXJ_COOKIE_H__
18 #define __CHXJ_COOKIE_H__
19
20 #include "mod_chxj.h"
21 #include "apr_file_io.h"
22 #include "apr_tables.h"
23 #include "apr_time.h"
24
25 #define CHXJ_COOKIE_PARAM               "_chxj_cc"
26 #define CHXJ_COOKIE_NOUPDATE_PARAM      "_chxj_nc"
27
28 #define DEFAULT_COOKIE_DB_DIR           "/tmp"
29 #define COOKIE_DB_NAME                  "cookie.db"
30 #define COOKIE_DB_LOCK_NAME             "cookie.db.lock"
31
32 #define COOKIE_EXPIRE_DB_NAME           "cookie.expire.db"
33 #define COOKIE_EXPIRE_DB_LOCK_NAME      "cookie.expire.db.lock"
34
35 #define REFERER_COOKIE_KEY              "CHXJ_REFER"
36
37 /* 
38  * default cookie timeout is 30 minute
39  */
40 #define DEFAULT_COOKIE_TIMEOUT          (1800)
41
42
43 typedef struct cookie_t cookie_t;
44
45
46 struct cookie_t {
47   char*               cookie_id;
48   apr_array_header_t* cookie_headers;
49 };
50
51
52 extern cookie_t* chxj_save_cookie(
53   request_rec*            r);
54
55 extern char* chxj_add_cookie_parameter(
56   request_rec*            r, 
57   char*                   value, 
58   cookie_t*               cookie);
59
60 extern int chxj_cookie_check_host(
61   request_rec*            r, 
62   char*                   value);
63
64 extern cookie_t* chxj_load_cookie(
65   request_rec*            r, 
66   char*                   cookie_id);
67
68 extern apr_file_t* chxj_cookie_db_lock(
69   request_rec*            r);
70
71 extern void chxj_cookie_db_unlock(
72   request_rec*            r, 
73   apr_file_t*             file);
74
75 extern void chxj_delete_cookie(request_rec *r, const char *cookie_id);
76
77 extern char* chxj_cookie_db_name_create(
78   request_rec*            r, 
79   const char*             dir);
80
81 extern char* chxj_cookie_db_lock_name_create(
82   request_rec* r, 
83   const char*  dir);
84
85 extern char* chxj_cookie_expire_db_lock_name_create(
86   request_rec* r, 
87   const char*  dir);
88
89 extern char* chxj_cookie_expire_db_name_create(
90   request_rec* r, 
91   const char*  dir);
92
93 extern apr_file_t* chxj_cookie_expire_db_lock(
94   request_rec* r);
95
96 extern void chxj_cookie_expire_db_unlock(
97   request_rec* r, 
98   apr_file_t*  file);
99
100 extern void chxj_save_cookie_expire(
101   request_rec* r, 
102   cookie_t*    cookie);
103
104 extern void chxj_delete_cookie_expire(
105   request_rec* r, 
106   char*        cookie_id);
107
108 extern void chxj_cookie_expire_gc(
109   request_rec* r);
110
111 extern cookie_t* chxj_update_cookie(
112   request_rec* r, 
113   cookie_t*    old_cookie);
114
115 extern apr_time_t chxj_parse_cookie_expires(const char *s);
116 #endif
117 /*
118  * vim:ts=2 et
119  */