util_cookies.c revision 7184de27ec1d62a83c41cdeac0953ca9fd661e8c
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "util_cookies.h"
#include "apr_lib.h"
#include "apr_strings.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#define LOG_PREFIX "ap_cookie: "
/* we know core's module_index is 0 */
/**
* Write an RFC2109 compliant cookie.
*
* @param r The request
* @param name The name of the cookie.
* @param val The value to place in the cookie.
* @param attrs The string containing additional cookie attributes. If NULL, the
* DEFAULT_ATTRS will be used.
* @param maxage If non zero, a Max-Age header will be added to the cookie.
*/
{
const char *buffer;
const char *rfc2109;
apr_table_t *t;
/* handle expiry */
buffer = "";
if (maxage) {
}
/* create RFC2109 compliant cookie */
/* write the cookie to the header table(s) provided */
}
return APR_SUCCESS;
}
/**
* Write an RFC2965 compliant cookie.
*
* @param r The request
* @param name2 The name of the cookie.
* @param val The value to place in the cookie.
* @param attrs2 The string containing additional cookie attributes. If NULL, the
* DEFAULT_ATTRS will be used.
* @param maxage If non zero, a Max-Age header will be added to the cookie.
*/
{
const char *buffer;
const char *rfc2965;
apr_table_t *t;
/* handle expiry */
buffer = "";
if (maxage) {
}
/* create RFC2965 compliant cookie */
/* write the cookie to the header table(s) provided */
}
return APR_SUCCESS;
}
/**
* Remove an RFC2109 compliant cookie.
*
* @param r The request
* @param name The name of the cookie.
*/
AP_DECLARE(apr_status_t) ap_cookie_remove(request_rec * r, const char *name, const char *attrs, ...)
{
apr_table_t *t;
/* create RFC2109 compliant cookie */
/* write the cookie to the header table(s) provided */
}
return APR_SUCCESS;
}
/**
* Remove an RFC2965 compliant cookie.
*
* @param r The request
* @param name2 The name of the cookie.
*/
AP_DECLARE(apr_status_t) ap_cookie_remove2(request_rec * r, const char *name2, const char *attrs2, ...)
{
apr_table_t *t;
/* create RFC2965 compliant cookie */
/* write the cookie to the header table(s) provided */
}
return APR_SUCCESS;
}
/* Iterate through the cookies, isolate our cookie and then remove it.
*
* If our cookie appears two or more times, but with different values,
* remove it twice and set the duplicated flag to true. Remove any
* $path or other attributes following our cookie if present. If we end
* up with an empty cookie, remove the whole header.
*/
{
const char *new_cookie = "";
const char *comma = ",";
char *next1;
const char *semi = ";";
char *next2;
const char *sep = "";
int cookies = 0;
/* find the cookie called name */
int eat = 0;
while (next1) {
while (next2) {
while (apr_isspace(*trim)) {
trim++;
}
if (v->encoded) {
v->duplicated = 1;
}
}
eat = 1;
}
else {
if (*trim != '$') {
cookies++;
eat = 0;
}
if (!eat) {
}
}
}
}
/* any cookies left over? */
if (cookies) {
}
return 1;
}
/**
* Read a cookie called name, placing its value in val.
*
* Both the Cookie and Cookie2 headers are scanned for the cookie.
*
* If the cookie is duplicated, this function returns APR_EGENERAL. If found,
* and if remove is non zero, the cookie will be removed from the headers, and
* thus kept private from the backend.
*/
int remove)
{
ap_cookie_do v;
v.r = r;
v.duplicated = 0;
apr_table_do((int (*) (void *, const char *, const char *))
extract_cookie_line, (void *) &v, r->headers_in,
if (v.duplicated) {
return APR_EGENERAL;
}
/* remove our cookie(s), and replace them */
if (remove) {
}
return APR_SUCCESS;
}
/**
* Sanity check a given string that it exists, is not empty,
* and does not contain the special characters '=', ';' and '&'.
*
* It is used to sanity check the cookie names.
*/
{
return APR_EGENERAL;
}
return APR_SUCCESS;
}