libapreq2-2.08: libapreq2: include/apreq_cookie.h Source File

Apache HTTP Server Request Library

- Main Page
- Modules
- Data Structures
- Files
- Related Pages
- Examples

- File List
- Globals

# include/apreq_cookie.h

Go to the documentation of this file.

    00001 /*
    00002 **  Copyright 2003-2006  The Apache Software Foundation
    00003 **
    00004 **  Licensed under the Apache License, Version 2.0 (the "License");
    00005 **  you may not use this file except in compliance with the License.
    00006 **  You may obtain a copy of the License at
    00007 **
    00008 **      http://www.apache.org/licenses/LICENSE-2.0
    00009 **
    00010 **  Unless required by applicable law or agreed to in writing, software
    00011 **  distributed under the License is distributed on an "AS IS" BASIS,
    00012 **  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013 **  See the License for the specific language governing permissions and
    00014 **  limitations under the License.
    00015 */
    00016
    00017 #ifndef APREQ_COOKIE_H
    00018 #define APREQ_COOKIE_H
    00019
    00020 #include "apreq.h"
    00021 #include "apr_time.h"
    00022
    00023 #ifdef  __cplusplus
    00024 extern "C" {
    00025 #endif
    00026
    00047 #define APREQ_COOKIE_MAX_LENGTH            4096
    00048
    00052 typedef struct apreq_cookie_t {
    00053
    00054     char           *path;
    00055     char           *domain;
    00056     char           *port;
    00057     char           *comment;
    00058     char           *commentURL;
    00059     apr_time_t      max_age;
    00060     unsigned        flags;
    00061     const apreq_value_t   v;
    00063 } apreq_cookie_t;
    00064
    00065
    00067 static APR_INLINE
    00068 apreq_cookie_t *apreq_value_to_cookie(const char *val)
    00069 {
    00070     union { const char *in; char *out; } deconst;
    00071
    00072     deconst.in = val;
    00073     return apreq_attr_to_type(apreq_cookie_t, v,
    00074            apreq_attr_to_type(apreq_value_t, data, deconst.out));
    00075 }
    00076
    00078 static APR_INLINE
    00079 unsigned apreq_cookie_version(const apreq_cookie_t *c) {
    00080     return APREQ_FLAGS_GET(c->flags, APREQ_COOKIE_VERSION);
    00081 }
    00082
    00084 static APR_INLINE
    00085 void apreq_cookie_version_set(apreq_cookie_t *c, unsigned v) {
    00086     APREQ_FLAGS_SET(c->flags, APREQ_COOKIE_VERSION, v);
    00087 }
    00088
    00090 static APR_INLINE
    00091 unsigned apreq_cookie_is_secure(const apreq_cookie_t *c) {
    00092     return APREQ_FLAGS_GET(c->flags, APREQ_COOKIE_SECURE);
    00093 }
    00094
    00098 static APR_INLINE
    00099 void apreq_cookie_secure_on(apreq_cookie_t *c) {
    00100     APREQ_FLAGS_ON(c->flags, APREQ_COOKIE_SECURE);
    00101 }
    00102
    00104 static APR_INLINE
    00105 void apreq_cookie_secure_off(apreq_cookie_t *c) {
    00106     APREQ_FLAGS_OFF(c->flags, APREQ_COOKIE_SECURE);
    00107 }
    00108
    00109
    00111 static APR_INLINE
    00112 unsigned apreq_cookie_is_tainted(const apreq_cookie_t *c) {
    00113     return APREQ_FLAGS_GET(c->flags, APREQ_TAINTED);
    00114 }
    00115
    00117 static APR_INLINE
    00118 void apreq_cookie_tainted_on(apreq_cookie_t *c) {
    00119     APREQ_FLAGS_ON(c->flags, APREQ_TAINTED);
    00120 }
    00121
    00123 static APR_INLINE
    00124 void apreq_cookie_tainted_off(apreq_cookie_t *c) {
    00125     APREQ_FLAGS_OFF(c->flags, APREQ_TAINTED);
    00126 }
    00127
    00143 APREQ_DECLARE(apr_status_t) apreq_parse_cookie_header(apr_pool_t *pool,
    00144                                                       apr_table_t *jar,
    00145                                                       const char *header);
    00146
    00158 APREQ_DECLARE(apreq_cookie_t *) apreq_cookie_make(apr_pool_t *pool,
    00159                                                   const char *name,
    00160                                                   const apr_size_t nlen,
    00161                                                   const char *value,
    00162                                                   const apr_size_t vlen);
    00163
    00173 APREQ_DECLARE(char*) apreq_cookie_as_string(const apreq_cookie_t *c,
    00174                                             apr_pool_t *p);
    00175
    00176
    00189 APREQ_DECLARE(int) apreq_cookie_serialize(const apreq_cookie_t *c,
    00190                                           char *buf, apr_size_t len);
    00191
    00206 APREQ_DECLARE(void) apreq_cookie_expires(apreq_cookie_t *c,
    00207                                          const char *time_str);
    00208
    00209 #ifdef __cplusplus
    00210  }
    00211 #endif
    00212
    00213 #endif /*APREQ_COOKIE_H*/
    00214
    00215