From e921cd65ea18c86a132c2e5eac480f934dde2046 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 8 Sep 2009 14:19:47 +0200 Subject: [PATCH] const some arguments. Remove http_command.h --- src/Makefile.am | 2 +- src/http.c | 5 ++--- src/http.h | 7 +++++-- src/http_command.c | 23 +++++++++++------------ src/http_command.h | 27 --------------------------- src/logic.c | 2 +- src/pazpar2.h | 4 ++-- 7 files changed, 22 insertions(+), 48 deletions(-) delete mode 100644 src/http_command.h diff --git a/src/Makefile.am b/src/Makefile.am index 81dbe02..2b3ab51 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ CONFIG_CLEAN_FILES=*.log AM_CFLAGS = $(YAZINC) libpazpar2_a_SOURCES = pazpar2_config.c pazpar2_config.h eventl.c eventl.h \ - http.c http_command.c http_command.h http.h \ + http.c http_command.c http.h \ logic.c pazpar2.h \ record.h record.c reclists.c reclists.h \ relevance.c relevance.h termlists.c termlists.h \ diff --git a/src/http.c b/src/http.c index 87cb644..0e1c47b 100644 --- a/src/http.c +++ b/src/http.c @@ -66,7 +66,6 @@ typedef int socklen_t; #include "eventl.h" #include "pazpar2.h" #include "http.h" -#include "http_command.h" #define MAX_HTTP_HEADER 4096 @@ -268,7 +267,7 @@ void http_addheader(struct http_response *r, const char *name, const char *value r->headers = h; } -char *http_argbyname(struct http_request *r, char *name) +const char *http_argbyname(struct http_request *r, const char *name) { struct http_argument *p; if (!name) @@ -279,7 +278,7 @@ char *http_argbyname(struct http_request *r, char *name) return 0; } -char *http_headerbyname(struct http_header *h, char *name) +const char *http_headerbyname(struct http_header *h, const char *name) { for (; h; h = h->next) if (!strcmp(h->name, name)) diff --git a/src/http.h b/src/http.h index dcaa3a8..c93a85b 100644 --- a/src/http.h +++ b/src/http.h @@ -109,8 +109,8 @@ struct http_header * http_header_append(struct http_channel *ch, struct http_header * hp, const char *name, const char *value); -char *http_argbyname(struct http_request *r, char *name); -char *http_headerbyname(struct http_header *r, char *name); +const char *http_argbyname(struct http_request *r, const char *name); +const char *http_headerbyname(struct http_header *r, const char *name); struct http_response *http_create_response(struct http_channel *c); void http_send_response(struct http_channel *c); void urlencode(const char *i, char *o); @@ -124,6 +124,9 @@ void http_observer_set_data2(http_channel_observer_t obs, void *data2); void http_remove_observer(http_channel_observer_t obs); struct http_channel *http_channel_observer_chan(http_channel_observer_t obs); + +void http_command(struct http_channel *c); + #endif /* diff --git a/src/http_command.c b/src/http_command.c index 13f421d..f9c5d42 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -37,7 +37,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "eventl.h" #include "pazpar2.h" #include "http.h" -#include "http_command.h" #include "settings.h" #include "client.h" @@ -186,7 +185,7 @@ unsigned int make_sessionid(void) static struct http_session *locate_session(struct http_request *rq, struct http_response *rs) { struct http_session *p; - char *session = http_argbyname(rq, "session"); + const char *session = http_argbyname(rq, "session"); unsigned int id; if (!session) @@ -343,8 +342,8 @@ static void cmd_termlist(struct http_channel *c) struct termlist_score **p; int len; int i; - char *name = http_argbyname(rq, "name"); - char *nums = http_argbyname(rq, "num"); + const char *name = http_argbyname(rq, "name"); + const char *nums = http_argbyname(rq, "num"); int num = 15; int status; @@ -367,7 +366,7 @@ static void cmd_termlist(struct http_channel *c) while (*name) { char tname[256]; - char *tp; + const char *tp; if (!(tp = strchr(name, ','))) tp = name + strlen(name); @@ -665,9 +664,9 @@ static void show_records(struct http_channel *c, int active) struct http_session *s = locate_session(rq, rs); struct record_cluster **rl; struct reclist_sortparms *sp; - char *start = http_argbyname(rq, "start"); - char *num = http_argbyname(rq, "num"); - char *sort = http_argbyname(rq, "sort"); + const char *start = http_argbyname(rq, "start"); + const char *num = http_argbyname(rq, "num"); + const char *sort = http_argbyname(rq, "sort"); int startn = 0; int numn = 20; int total; @@ -739,7 +738,7 @@ static void cmd_show(struct http_channel *c) struct http_request *rq = c->request; struct http_response *rs = c->response; struct http_session *s = locate_session(rq, rs); - char *block = http_argbyname(rq, "block"); + const char *block = http_argbyname(rq, "block"); int status; if (!s) @@ -805,8 +804,8 @@ static void cmd_search(struct http_channel *c) struct http_request *rq = c->request; struct http_response *rs = c->response; struct http_session *s = locate_session(rq, rs); - char *query = http_argbyname(rq, "query"); - char *filter = http_argbyname(rq, "filter"); + const char *query = http_argbyname(rq, "query"); + const char *filter = http_argbyname(rq, "filter"); enum pazpar2_error_code code; const char *addinfo = 0; @@ -922,7 +921,7 @@ struct { void http_command(struct http_channel *c) { - char *command = http_argbyname(c->request, "command"); + const char *command = http_argbyname(c->request, "command"); struct http_response *rs = http_create_response(c); int i; diff --git a/src/http_command.h b/src/http_command.h deleted file mode 100644 index c460f34..0000000 --- a/src/http_command.h +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of Pazpar2. - Copyright (C) 2006-2009 Index Data - -Pazpar2 is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Pazpar2 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#ifndef HTTP_COMMAND_H -#define HTTP_COMMAND - -#include "http.h" - -void http_command(struct http_channel *c); - -#endif diff --git a/src/logic.c b/src/logic.c index 0e77804..c3aecbe 100644 --- a/src/logic.c +++ b/src/logic.c @@ -502,7 +502,7 @@ static struct database_criterion *parse_filter(NMEM m, const char *buf) } enum pazpar2_error_code search(struct session *se, - char *query, char *filter, + const char *query, const char *filter, const char **addinfo) { int live_channels = 0; diff --git a/src/pazpar2.h b/src/pazpar2.h index 8724a69..ad25df6 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -169,8 +169,8 @@ void destroy_session(struct session *s); void session_init_databases(struct session *s); int load_targets(struct session *s, const char *fn); void statistics(struct session *s, struct statistics *stat); -enum pazpar2_error_code search(struct session *s, char *query, - char *filter, const char **addinfo); +enum pazpar2_error_code search(struct session *s, const char *query, + const char *filter, const char **addinfo); struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, int start, int *num, int *total, int *sumhits, NMEM nmem_show); struct record_cluster *show_single(struct session *s, const char *id, -- 1.7.10.4