Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apreq_cookie.h
Go to the documentation of this file.
1 /*
2 ** Licensed to the Apache Software Foundation (ASF) under one or more
3 ** contributor license agreements. See the NOTICE file distributed with
4 ** this work for additional information regarding copyright ownership.
5 ** The ASF licenses this file to You under the Apache License, Version 2.0
6 ** (the "License"); you may not use this file except in compliance with
7 ** the License. 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 
18 #ifndef APREQ_COOKIE_H
19 #define APREQ_COOKIE_H
20 
21 #include "apreq.h"
22 #include "apr_time.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
48 #define APREQ_COOKIE_MAX_LENGTH 4096
49 
53 typedef struct apreq_cookie_t {
54 
55  char *path;
56  char *domain;
57  char *port;
58  char *comment;
59  char *commentURL;
61  unsigned flags;
62  const apreq_value_t v;
65 
66 
68 static APR_INLINE
69 apreq_cookie_t *apreq_value_to_cookie(const char *val)
70 {
71  union { const char *in; char *out; } deconst;
72 
73  deconst.in = val;
75  apreq_attr_to_type(apreq_value_t, data, deconst.out));
76 }
77 
79 static APR_INLINE
80 unsigned apreq_cookie_version(const apreq_cookie_t *c) {
81  return APREQ_FLAGS_GET(c->flags, APREQ_COOKIE_VERSION);
82 }
83 
85 static APR_INLINE
86 void apreq_cookie_version_set(apreq_cookie_t *c, unsigned v) {
87  APREQ_FLAGS_SET(c->flags, APREQ_COOKIE_VERSION, v);
88 }
89 
91 static APR_INLINE
92 unsigned apreq_cookie_is_secure(const apreq_cookie_t *c) {
93  return APREQ_FLAGS_GET(c->flags, APREQ_COOKIE_SECURE);
94 }
95 
99 static APR_INLINE
100 void apreq_cookie_secure_on(apreq_cookie_t *c) {
101  APREQ_FLAGS_ON(c->flags, APREQ_COOKIE_SECURE);
102 }
103 
105 static APR_INLINE
106 void apreq_cookie_secure_off(apreq_cookie_t *c) {
107  APREQ_FLAGS_OFF(c->flags, APREQ_COOKIE_SECURE);
108 }
109 
111 static APR_INLINE
112 unsigned apreq_cookie_is_httponly(const apreq_cookie_t *c) {
113  return APREQ_FLAGS_GET(c->flags, APREQ_COOKIE_HTTPONLY);
114 }
115 
120 static APR_INLINE
121 void apreq_cookie_httponly_on(apreq_cookie_t *c) {
122  APREQ_FLAGS_ON(c->flags, APREQ_COOKIE_HTTPONLY);
123 }
124 
126 static APR_INLINE
127 void apreq_cookie_httponly_off(apreq_cookie_t *c) {
128  APREQ_FLAGS_OFF(c->flags, APREQ_COOKIE_HTTPONLY);
129 }
130 
131 
133 static APR_INLINE
134 unsigned apreq_cookie_is_tainted(const apreq_cookie_t *c) {
135  return APREQ_FLAGS_GET(c->flags, APREQ_TAINTED);
136 }
137 
139 static APR_INLINE
140 void apreq_cookie_tainted_on(apreq_cookie_t *c) {
141  APREQ_FLAGS_ON(c->flags, APREQ_TAINTED);
142 }
143 
145 static APR_INLINE
146 void apreq_cookie_tainted_off(apreq_cookie_t *c) {
147  APREQ_FLAGS_OFF(c->flags, APREQ_TAINTED);
148 }
149 
166  apr_table_t *jar,
167  const char *header);
168 
181  const char *name,
182  const apr_size_t nlen,
183  const char *value,
184  const apr_size_t vlen);
185 
196  apr_pool_t *p);
197 
198 
212  char *buf, apr_size_t len);
213 
229  const char *time_str);
230 
231 #ifdef __cplusplus
232  }
233 #endif
234 
235 #endif /*APREQ_COOKIE_H*/
236 
237 
size_t apr_size_t
Definition: apr.h:375
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
#define APREQ_DECLARE(x)
Definition: macros.h:12
#define APREQ_FLAGS_OFF(f, name)
Definition: apreq.h:73
#define APREQ_FLAGS_ON(f, name)
Definition: apreq.h:77
#define APREQ_FLAGS_SET(f, name, value)
Definition: apreq.h:88
apr_int64_t apr_time_t
Definition: apr_time.h:45
#define APREQ_FLAGS_GET(f, name)
Definition: apreq.h:81
libapreq's pre-extensible string type
Definition: apreq.h:190
#define APR_INLINE
Definition: apr.h:65
apr_pool_t * p
Main header file...Define the common data structures.
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
const char * name
Definition: mod_dav.h:726
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int apr_status_t
Definition: apr_errno.h:44
APR Time Library.
#define apreq_attr_to_type(T, A, P)
Definition: apreq.h:220