Made the webserver logging follow the popular pattern of foo_???() being declared in foo.h and defined in foo.c.

This commit is contained in:
oliverschmidt 2007-04-23 21:19:55 +00:00
parent ca2add3641
commit 2662a31d30
6 changed files with 29 additions and 28 deletions

View file

@ -30,16 +30,19 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: httpd.c,v 1.4 2006/09/20 19:18:56 adamdunkels Exp $
* $Id: httpd.c,v 1.5 2007/04/23 21:19:55 oliverschmidt Exp $
*/
#include <string.h>
#include "contiki-net.h"
#include "httpd.h"
#include "webserver.h"
#include "httpd-fs.h"
#include "httpd-cgi.h"
#include "http-strings.h"
#include <string.h>
#include "httpd.h"
#define STATE_WAITING 0
#define STATE_OUTPUT 1
@ -55,7 +58,6 @@ MEMB(conns, struct httpd_state, 4);
#define ISO_slash 0x2f
#define ISO_colon 0x3a
/*---------------------------------------------------------------------------*/
static unsigned short
generate(void *state)
@ -121,7 +123,6 @@ PT_THREAD(handle_script(struct httpd_state *s))
PT_BEGIN(&s->scriptpt);
while(s->file.len > 0) {
/* Check if we should start executing a script. */
@ -167,7 +168,6 @@ PT_THREAD(handle_script(struct httpd_state *s))
PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
s->file.data += s->len;
s->file.len -= s->len;
}
}
@ -240,7 +240,6 @@ PT_THREAD(handle_input(struct httpd_state *s))
PSOCK_BEGIN(&s->sin);
PSOCK_READTO(&s->sin, ISO_space);
if(strncmp(s->inputbuf, http_get, 4) != 0) {
PSOCK_CLOSE_EXIT(&s->sin);
@ -258,7 +257,7 @@ PT_THREAD(handle_input(struct httpd_state *s))
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
}
httpd_log_file(&uip_conn->ripaddr, s->filename);
webserver_log_file(&uip_conn->ripaddr, s->filename);
s->state = STATE_OUTPUT;
@ -267,7 +266,7 @@ PT_THREAD(handle_input(struct httpd_state *s))
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
httpd_log(&s->inputbuf[9]);
webserver_log(&s->inputbuf[9]);
}
}

View file

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd.h,v 1.3 2007/04/07 01:31:29 oliverschmidt Exp $
* $Id: httpd.h,v 1.4 2007/04/23 21:19:55 oliverschmidt Exp $
*
*/
@ -61,7 +61,4 @@ struct httpd_state {
void httpd_init(void);
void httpd_appcall(void *state);
void httpd_log(char *msg);
void httpd_log_file(uip_ipaddr_t *requester, char *file);
#endif /* __HTTPD_H__ */

View file

@ -29,7 +29,7 @@
*
* This file is part of the Contiki OS.
*
* $Id: webserver-nogui.c,v 1.3 2007/04/14 13:40:53 oliverschmidt Exp $
* $Id: webserver-nogui.c,v 1.4 2007/04/23 21:19:55 oliverschmidt Exp $
*
*/
@ -40,7 +40,7 @@
#include "sys/log.h"
#include "http-strings.h"
#include "webserver.h"
#include "webserver-nogui.h"
#include "httpd.h"
PROCESS(webserver_nogui_process, "Web server");
@ -60,7 +60,7 @@ PROCESS_THREAD(webserver_nogui_process, ev, data)
}
/*---------------------------------------------------------------------------*/
void
httpd_log_file(uip_ipaddr_t *requester, char *file)
webserver_log_file(uip_ipaddr_t *requester, char *file)
{
#if LOG_CONF_ENABLED
char buf[18];
@ -73,7 +73,7 @@ httpd_log_file(uip_ipaddr_t *requester, char *file)
}
/*---------------------------------------------------------------------------*/
void
httpd_log(char *msg)
webserver_log(char *msg)
{
log_message(msg, "");
}

View file

@ -29,14 +29,17 @@
*
* This file is part of the Contiki OS
*
* $Id: webserver-nogui.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $
* $Id: webserver-nogui.h,v 1.2 2007/04/23 21:19:55 oliverschmidt Exp $
*
*/
#ifndef __WEBSERVER_NOGUI_H__
#define __WEBSERVER_NOGUI_H__
#include "contiki.h"
#include "contiki-net.h"
PROCESS_NAME(webserver_nogui_process);
void webserver_log(char *msg);
void webserver_log_file(uip_ipaddr_t *requester, char *file);
#endif /* __WEBSERVER_H__ */

View file

@ -29,10 +29,13 @@
*
* This file is part of the Contiki desktop environment for the C64.
*
* $Id: webserver.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
* $Id: webserver.c,v 1.3 2007/04/23 21:19:55 oliverschmidt Exp $
*
*/
#include <string.h>
#include <stdio.h>
#include "contiki.h"
#include "ctk/ctk.h"
@ -40,9 +43,6 @@
#include "webserver.h"
#include "httpd.h"
#include <string.h>
#include <stdio.h>
/* The main window. */
static struct ctk_window mainwindow;
@ -60,7 +60,6 @@ static struct ctk_label loglabel =
/*-----------------------------------------------------------------------------------*/
PROCESS_THREAD(webserver_process, ev, data)
{
PROCESS_BEGIN();
ctk_window_new(&mainwindow, LOG_WIDTH, LOG_HEIGHT+1, "Web server");
@ -89,7 +88,7 @@ PROCESS_THREAD(webserver_process, ev, data)
}
/*-----------------------------------------------------------------------------------*/
void
httpd_log_file(uip_ipaddr_t *requester, char *file)
webserver_log_file(uip_ipaddr_t *requester, char *file)
{
int size;
@ -112,7 +111,7 @@ httpd_log_file(uip_ipaddr_t *requester, char *file)
}
/*-----------------------------------------------------------------------------------*/
void
httpd_log(char *msg)
webserver_log(char *msg)
{
/* Scroll previous entries upwards */
memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));

View file

@ -29,14 +29,17 @@
*
* This file is part of the Contiki operating system
*
* $Id: webserver.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $
* $Id: webserver.h,v 1.2 2007/04/23 21:19:55 oliverschmidt Exp $
*
*/
#ifndef __WEBSERVER_H__
#define __WEBSERVER_H__
#include "contiki.h"
#include "contiki-net.h"
PROCESS_NAME(webserver_process);
void webserver_log(char *msg);
void webserver_log_file(uip_ipaddr_t *requester, char *file);
#endif /* __WEBSERVER_H__ */