Skip to content

Commit

Permalink
git-svn-id: svn://cherokee-project.com/cherokee/trunk@493 5dc97367-97…
Browse files Browse the repository at this point in the history
…f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Dec 4, 2006
1 parent 0df5085 commit 970534b
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 66 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
2006-12-04 Alvaro Lopez Ortega <alvaro@alobbs.com>

* cherokee/version.h, cherokee/version.c: New files. Implements
cherokee_version_add_w_port() and cherokee_version_add().

* cherokee/handler_error.c (build_hardcoded_response_page): Now,
it uses the new cherokee_version_add_w_port() function.

* cherokee/buffer.c (cherokee_buffer_add_version): Removed.

* cherokee/buffer.h: cherokee_version_t Removed.

* cherokee/config_node.c (cherokee_config_node_read_list): Now it
skips whites before each list entry. "a, b, c" should be "a", "b"
and "c" instead of "a", " b" and " c" like previously.
Expand Down
3 changes: 3 additions & 0 deletions cherokee/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,8 @@ common.h \
common-internal.h \
util.h \
util.c \
version.h \
version.c \
buffer.h \
buffer.c \
table.h \
Expand Down Expand Up @@ -874,6 +876,7 @@ cherokee.h \
macros.h \
common.h \
util.h \
version.h \
buffer.h\
fdpoll.h \
table.h \
Expand Down
37 changes: 0 additions & 37 deletions cherokee/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,43 +674,6 @@ cherokee_buffer_print_debug (cherokee_buffer_t *buf, int len)
}


ret_t
cherokee_buffer_add_version (cherokee_buffer_t *buf, int port, cherokee_version_t ver)
{
ret_t ret;
static char port_str[6];
static int port_len = 0;

if (port_len == 0) {
port_len = snprintf (port_str, 6, "%d", port);
}

switch (ver) {
case ver_full_html:
cherokee_buffer_ensure_size (buf, buf->len + 29 + sizeof(PACKAGE_VERSION) + 6 + port_len + 10);

cherokee_buffer_add_str (buf,
"<address>Cherokee web server " PACKAGE_VERSION " Port ");
cherokee_buffer_add (buf, port_str, port_len);
cherokee_buffer_add_str (buf, "</address>");
break;

case ver_port_html:
cherokee_buffer_ensure_size (buf, buf->len + 34 + port_len + 10);

cherokee_buffer_add_str (buf, "<address>Cherokee web server Port ");
cherokee_buffer_add (buf, port_str, port_len);
cherokee_buffer_add_str (buf, "</address>");
break;

default:
SHOULDNT_HAPPEN;
}

return ret;
}


/*
* Unescape a string that may have escaped characters %xx
* where xx is the hexadecimal number equal to the character ascii value.
Expand Down
6 changes: 0 additions & 6 deletions cherokee/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@

CHEROKEE_BEGIN_DECLS

typedef enum {
ver_full_html, /*!< Eg: <address>Cherokee web server 0.5.0 Port 80</address> */
ver_port_html /*!< Eg: <address>Cherokee web server Port 80</address> */
} cherokee_version_t;

typedef struct {
char *buf; /**< Memory chunk */
int size; /**< Total amount of memory */
Expand Down Expand Up @@ -115,7 +110,6 @@ ret_t cherokee_buffer_unescape_uri (cherokee_buffer_t *buf);
ret_t cherokee_buffer_escape_html (cherokee_buffer_t *buf, cherokee_buffer_t **maybe_new);
ret_t cherokee_buffer_add_comma_marks (cherokee_buffer_t *buf);

ret_t cherokee_buffer_add_version (cherokee_buffer_t *buf, int port, cherokee_version_t ver);
ret_t cherokee_buffer_print_debug (cherokee_buffer_t *buf, int length);


Expand Down
1 change: 1 addition & 0 deletions cherokee/cherokee.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <cherokee/macros.h>
#include <cherokee/common.h>
#include <cherokee/util.h>
#include <cherokee/version.h>
#include <cherokee/buffer.h>
#include <cherokee/fdpoll.h>
#include <cherokee/table.h>
Expand Down
11 changes: 2 additions & 9 deletions cherokee/handler_dirlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,8 @@ cherokee_handler_dirlist_init (cherokee_handler_dirlist_t *dhdl)
else
port = srv->port_tls;

switch (srv->server_token) {
case cherokee_version_product:
cherokee_buffer_add_version (&dhdl->server_software, port, ver_full_html);
case cherokee_version_minor:
case cherokee_version_minimal:
case cherokee_version_os:
case cherokee_version_full:
cherokee_buffer_add_version (&dhdl->server_software, port, ver_port_html);
}
ret = cherokee_version_add_w_port (&dhdl->server_software, srv->server_token, port);
if (unlikely (ret != ret_ok)) return ret;

return ret_ok;
}
Expand Down
9 changes: 4 additions & 5 deletions cherokee/handler_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ cherokee_handler_error_free (cherokee_handler_error_t *hdl)
static ret_t
build_hardcoded_response_page (cherokee_connection_t *cnt, cherokee_buffer_t *buffer)
{
ret_t ret;
cuint_t port;
cherokee_buffer_t *escaped = NULL;

Expand Down Expand Up @@ -177,11 +178,9 @@ build_hardcoded_response_page (cherokee_connection_t *cnt, cherokee_buffer_t *bu
else
port = CONN_SRV(cnt)->port_tls;

if (CONN_SRV(cnt)->server_token <= cherokee_version_product) {
cherokee_buffer_add_version (buffer, port, ver_port_html);
} else {
cherokee_buffer_add_version (buffer, port, ver_full_html);
}
ret = cherokee_version_add_w_port (buffer, CONN_SRV(cnt)->server_token, port);
if (unlikely (ret != ret_ok)) return ret;

cherokee_buffer_add_str (buffer, "</body></html>");

return ret_ok;
Expand Down
1 change: 1 addition & 0 deletions cherokee/server-protected.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "nonce.h"
#include "mime.h"
#include "config_node.h"
#include "version.h"


struct cherokee_server {
Expand Down
8 changes: 0 additions & 8 deletions cherokee/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@

CHEROKEE_BEGIN_DECLS

typedef enum {
cherokee_version_product,
cherokee_version_minor,
cherokee_version_minimal,
cherokee_version_os,
cherokee_version_full
} cherokee_server_token_t;

typedef struct cherokee_server cherokee_server_t;
typedef void (* cherokee_server_reinit_cb_t) (cherokee_server_t *new_srv);

Expand Down
1 change: 1 addition & 0 deletions cherokee/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,3 +1267,4 @@ cherokee_close_fd (cint_t fd)

return (re == 0) ? ret_ok : ret_error;
}

1 change: 0 additions & 1 deletion cherokee/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

#include <cherokee/buffer.h>


CHEROKEE_BEGIN_DECLS

#ifdef _WIN32
Expand Down
70 changes: 70 additions & 0 deletions cherokee/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* Cherokee
*
* Authors:
* Alvaro Lopez Ortega <alvaro@alobbs.com>
*
* Copyright (C) 2001-2006 Alvaro Lopez Ortega
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/

#include "common-internal.h"
#include "version.h"


ret_t
cherokee_version_add (cherokee_buffer_t *buf, cherokee_server_token_t level)
{
ret_t ret;

switch (level) {
case cherokee_version_product:
ret = cherokee_buffer_add_str (buf, "Cherokee web server");
case cherokee_version_minor:
ret = cherokee_buffer_add_str (buf, "Cherokee web server " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION);
case cherokee_version_minimal:
ret = cherokee_buffer_add_str (buf, "Cherokee web server " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION "." PACKAGE_MICRO_VERSION);
case cherokee_version_os:
ret = cherokee_buffer_add_str (buf, "Cherokee web server " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION "." PACKAGE_MICRO_VERSION " (" OS_TYPE ")");
case cherokee_version_full:
ret = cherokee_buffer_add_str (buf, "Cherokee web server " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION "." PACKAGE_MICRO_VERSION " (" OS_TYPE ")");
}

return ret;
}


ret_t
cherokee_version_add_w_port (cherokee_buffer_t *buf, cherokee_server_token_t level, cuint_t port)
{
ret_t ret;

switch (level) {
case cherokee_version_product:
ret = cherokee_buffer_add_va (buf, "Cherokee web server Port %d", port);
case cherokee_version_minor:
ret = cherokee_buffer_add_va (buf, "Cherokee web server Port %d " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION, port);
case cherokee_version_minimal:
ret = cherokee_buffer_add_va (buf, "Cherokee web server Port %d " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION "." PACKAGE_MICRO_VERSION, port);
case cherokee_version_os:
ret = cherokee_buffer_add_va (buf, "Cherokee web server Port %d " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION "." PACKAGE_MICRO_VERSION " (" OS_TYPE ")", port);
case cherokee_version_full:
ret = cherokee_buffer_add_va (buf, "Cherokee web server Port %d " PACKAGE_MAJOR_VERSION "." PACKAGE_MINOR_VERSION "." PACKAGE_MICRO_VERSION " (" OS_TYPE ")", port);
}

return ret;
}
53 changes: 53 additions & 0 deletions cherokee/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* Cherokee
*
* Authors:
* Alvaro Lopez Ortega <alvaro@alobbs.com>
*
* Copyright (C) 2001-2006 Alvaro Lopez Ortega
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/

#if !defined (CHEROKEE_INSIDE_CHEROKEE_H) && !defined (CHEROKEE_COMPILATION)
# error "Only <cherokee/cherokee.h> can be included directly, this file may disappear or change contents."
#endif


#ifndef CHEROKEE_VERSION_H
#define CHEROKEE_VERSION_H

#include <cherokee/common.h>
#include <cherokee/buffer.h>

CHEROKEE_BEGIN_DECLS


typedef enum {
cherokee_version_product,
cherokee_version_minor,
cherokee_version_minimal,
cherokee_version_os,
cherokee_version_full
} cherokee_server_token_t;

ret_t cherokee_version_add (cherokee_buffer_t *buf, cherokee_server_token_t level);
ret_t cherokee_version_add_w_port (cherokee_buffer_t *buf, cherokee_server_token_t level, cuint_t port);


CHEROKEE_END_DECLS

#endif /* CHEROKEE_VERSION_H */

0 comments on commit 970534b

Please sign in to comment.