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