Apache HTTP Server Request Library
00001 /* 00002 ** Copyright 2003-2004 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_tables.h" 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00044 typedef struct apreq_jar_t { 00045 apr_table_t *cookies; 00046 void *env; 00047 apr_status_t status; 00048 } apreq_jar_t; 00049 00050 00061 typedef enum { APREQ_COOKIE_VERSION_NETSCAPE, 00062 APREQ_COOKIE_VERSION_RFC } apreq_cookie_version_t; 00063 00064 00066 #define APREQ_COOKIE_VERSION_DEFAULT APREQ_COOKIE_VERSION_NETSCAPE 00067 00069 #define APREQ_COOKIE_MAX_LENGTH 4096 00070 00073 typedef struct apreq_cookie_t { 00074 00075 apreq_cookie_version_t version; 00077 char *path; 00078 char *domain; 00079 char *port; 00080 unsigned secure; 00081 char *comment; 00082 char *commentURL; 00083 apr_time_t max_age; 00084 apreq_value_t v; 00086 } apreq_cookie_t; 00087 00088 00089 #define apreq_value_to_cookie(ptr) apreq_attr_to_type(apreq_cookie_t, \ 00090 v, ptr) 00091 #define apreq_cookie_name(c) ((c)->v.name) 00092 #define apreq_cookie_value(c) ((c)->v.data) 00093 00094 #define apreq_jar_items(j) apr_table_elts(j->cookies)->nelts 00095 #define apreq_jar_nelts(j) apr_table_elts(j->cookies)->nelts 00096 00104 APREQ_DECLARE(apreq_cookie_t *)apreq_cookie(const apreq_jar_t *jar, 00105 const char *name); 00106 00114 APREQ_DECLARE(void) apreq_jar_add(apreq_jar_t *jar, 00115 const apreq_cookie_t *c); 00116 00117 #define apreq_add_cookie(j,c) apreq_jar_add(j,c) 00118 00135 APREQ_DECLARE(apreq_jar_t *) apreq_jar(void *env, const char *hdr); 00136 00146 APREQ_DECLARE(apreq_cookie_t *) apreq_cookie_make(apr_pool_t *pool, 00147 const char *name, const apr_size_t nlen, 00148 const char *value, const apr_size_t vlen); 00149 00150 #define apreq_make_cookie(p,n,nl,v,vl) apreq_cookie_make(p,n,nl,v,vl) 00151 00163 APREQ_DECLARE(apr_status_t) 00164 apreq_cookie_attr(apr_pool_t *p, apreq_cookie_t *c, 00165 const char *attr, apr_size_t alen, 00166 const char *val, apr_size_t vlen); 00167 00168 00176 APREQ_DECLARE(char*) apreq_cookie_as_string(const apreq_cookie_t *c, 00177 apr_pool_t *p); 00178 00179 00191 APREQ_DECLARE(int) apreq_cookie_serialize(const apreq_cookie_t *c, 00192 char *buf, apr_size_t len); 00193 00194 #define apreq_serialize_cookie(buf,len,c) apreq_cookie_serialize(c,buf,len) 00195 00207 APREQ_DECLARE(void) apreq_cookie_expires(apreq_cookie_t *c, 00208 const char *time_str); 00209 00216 APREQ_DECLARE(apr_status_t) apreq_cookie_bake(const apreq_cookie_t *c, 00217 void *env); 00218 00225 APREQ_DECLARE(apr_status_t) apreq_cookie_bake2(const apreq_cookie_t *c, 00226 void *env); 00227 00235 APREQ_DECLARE(apreq_cookie_version_t) apreq_ua_cookie_version(void *env); 00236 00237 #ifdef __cplusplus 00238 } 00239 #endif 00240 00241 #endif /*APREQ_COOKIE_H*/ 00242 00243