
pablo at eurodev
Jun 26, 2003, 4:54 PM
Post #1 of 1
(178 views)
Permalink
|
hi students! hey, Ajo, your last email was quite easier to understand than the "sleepy" one, hehe. I finished my exams so time to play with cherokee. Well, I added some changes to the first implementation, of course I know it won't the last. So let me show you what I did: server.h, cherokee_server_t. void *logging_config; <-- I added this new field to the structure. and logging_NCSA.h looks like: typedef struct { char *accesslog_file; char *errorlog_file; FILE *accesslog_fd; FILE *errorlog_fd; }cherokee_logging_NCSA_config_t; /* so every logging module could have their own structure which will be linked to the server by using the field logging_config. #define IN_ADDR(c) ((struct in_addr) (c).sin_addr) #define LOG_CONFIG(c) ((cherokee_logging_config_t *) (c)->logging_config) /* so macros to make like easier */ ret_t cherokee_logging_NCSA_open (cherokee_server_t *, char *, char *); /* it is called when cherokee starts */ ret_t cherokee_logging_NCSA_write (cherokee_connection_t *); /* write a log */ ret_t cherokee_logging_NCSA_close (cherokee_server_t *); /* close and release the resources, it must be called before releasing the server structure */ so this is mostly how you told me. well, both files compile (logging_NCSA.c/h) but I still cannot add them to cherokee because I don't know how to do it, I know you are quite busy so I can wait, study hard guys. by the way, the patch doesn't modify so much, main things are in logging_NCSA.c/h, I also fixed a bug related to the IP showed by the log is not correct, do you recall I fixed this and I posted to the list? but you know, it was for version 0.43, I found a better way to fix this problem (see the macro IN_ADDR). That's all. Pablo -------------- next part -------------- A non-text attachment was scrubbed... Name: logging_NCSA.c Type: text/x-csrc Size: 3004 bytes Desc: not available Url : /pipermail/attachments/20030626/07efce22/logging_NCSA.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: logging_NCSA.h Type: text/x-chdr Size: 1816 bytes Desc: not available Url : /pipermail/attachments/20030626/07efce22/logging_NCSA-0001.bin -------------- next part -------------- ? logging_NCSA.c ? logging_NCSA.h ? patch.diff Index: Makefile.am =================================================================== RCS file: /cherokee/cherokee/src/Makefile.am,v retrieving revision 1.2 diff -u -w -r1.2 Makefile.am Index: connection.c =================================================================== RCS file: /cherokee/cherokee/src/connection.c,v retrieving revision 1.8 diff -u -w -r1.8 connection.c --- connection.c 18 Jun 2003 19:42:58 -0000 1.8 +++ connection.c 26 Jun 2003 14:44:18 -0000 @@ -31,12 +31,6 @@ #include <pwd.h> #include <time.h> -/* inet_ntoa() - */ -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - #include "log.h" #include "handler.h" #include "handler_dirlist.h" @@ -47,15 +41,6 @@ #include "encoder_table.h" -static char *month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; - -static char *method[] = {"GET", "POST", "HEAD", "UNKNOWN", NULL}; - -static char *version[] = {"HTTP/0.9", "HTTP/1.0", "HTTP/1.1", "UNKNOWN", NULL}; - - - ret_t cherokee_connection_new (cherokee_connection_t **cnt) { @@ -872,41 +857,3 @@ return ret_error; } - - -void -cherokee_connection_log (cherokee_connection_t *cnt, time_t bogo_now) -{ - struct tm *timep; - long int z; - - timep = (struct tm *) localtime(&bogo_now); - -#ifdef HAVE_INT_TIMEZONE - z = - (timezone / 60); -#else -#warning TODO - z = 0; -#endif - - snprintf (gbl_buffer, gbl_buffer_size, "%s - - [%02d/%s/%d:%02d:%02d:%02d %c%02d%02d] \"%s %s %s\" %d %d", - - inet_ntoa(cnt->addr_in.sin_addr), - - timep->tm_mday, - month[timep->tm_mon], - 1900 + timep->tm_year, - timep->tm_hour, - timep->tm_min, - timep->tm_sec, - (z < 0) ? '-' : '+', - (int) z/60, - (int) z%60, - method[cnt->method], - cnt->request->buf, - version[cnt->version], - cnt->error_code, - cnt->range_end - cnt->range_start); - - cherokee_log (LOG_INFO, gbl_buffer); -} Index: connection.h =================================================================== RCS file: /cherokee/cherokee/src/connection.h,v retrieving revision 1.3 diff -u -w -r1.3 connection.h --- connection.h 17 Jun 2003 11:11:07 -0000 1.3 +++ connection.h 26 Jun 2003 14:44:19 -0000 @@ -69,7 +69,8 @@ void *server; int socket; - struct sockaddr_in addr_in; + struct sockaddr_in addr; + cherokee_connection_status_t status; cherokee_connection_phase_t phase; Index: log.h =================================================================== RCS file: /cherokee/cherokee/src/log.h,v retrieving revision 1.1 diff -u -w -r1.1 log.h --- log.h 3 Jun 2003 15:14:37 -0000 1.1 +++ log.h 26 Jun 2003 14:44:20 -0000 @@ -30,7 +30,6 @@ #include <syslog.h> - ret_t cherokee_log_init (void); ret_t cherokee_log_close (void); void cherokee_log (int priority, const char *format, ...); Index: server.c =================================================================== RCS file: /cherokee/cherokee/src/server.c,v retrieving revision 1.4 diff -u -w -r1.4 server.c --- server.c 18 Jun 2003 19:42:58 -0000 1.4 +++ server.c 26 Jun 2003 14:44:23 -0000 @@ -87,6 +87,7 @@ n->group_orig = getgid(); n->group = n->group_orig; + n->logging_config = NULL; /* Virtual servers table */ @@ -423,7 +424,7 @@ if (srv->log) { socklen_t len; len = sizeof(struct sockaddr_in); - new_socket = accept (srv->socket, (struct sockaddr *) &new_connection->addr_in, &len); + new_socket = accept (srv->socket, (struct sockaddr *)&new_connection->addr, &len); } else { new_socket = accept (srv->socket, NULL, NULL); } Index: server.h =================================================================== RCS file: /cherokee/cherokee/src/server.h,v retrieving revision 1.1 diff -u -w -r1.1 server.h --- server.h 3 Jun 2003 15:14:37 -0000 1.1 +++ server.h 26 Jun 2003 14:44:24 -0000 @@ -35,7 +35,6 @@ #include "virtual_server.h" #include "encoder_table.h" - typedef struct { time_t bogo_now; @@ -73,8 +72,9 @@ gid_t group; gid_t group_orig; - char *mimetypes_file; + void *logging_config; + char *mimetypes_file; char *userdir; /* Eg: public_html */ cherokee_plugin_table_entry_t *userdir_handler; } cherokee_server_t;
|