Changeset 336
- Timestamp:
- 08/14/06 00:56:36 (2 years ago)
- Files:
-
- cherokee/trunk/cherokee/config_entry.c (modified) (2 diffs)
- cherokee/trunk/cherokee/connection.c (modified) (3 diffs)
- cherokee/trunk/cherokee/downloader.c (modified) (1 diff)
- cherokee/trunk/cherokee/handler_cgi_base.c (modified) (1 diff)
- cherokee/trunk/cherokee/handler_error_redir.c (modified) (2 diffs)
- cherokee/trunk/cherokee/handler_error_redir.h (modified) (1 diff)
- cherokee/trunk/cherokee/handler_file.c (modified) (1 diff)
- cherokee/trunk/cherokee/handler_remote_control.c (modified) (3 diffs)
- cherokee/trunk/cherokee/handler_webcam.c (modified) (1 diff)
- cherokee/trunk/cherokee/main.c (modified) (3 diffs)
- cherokee/trunk/cherokee/module.h (modified) (3 diffs)
- cherokee/trunk/cherokee/request.c (modified) (4 diffs)
- cherokee/trunk/cherokee/server.c (modified) (2 diffs)
- cherokee/trunk/cherokee/tdate_parse.c (modified) (8 diffs)
- cherokee/trunk/cherokee/validator_htpasswd.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/cherokee/config_entry.c
r289 r336 81 81 82 82 if (entry->validator_properties != NULL) { 83 cherokee_ typed_table_free (entry->validator_properties);83 cherokee_validator_props_free (entry->validator_properties); 84 84 entry->validator_properties = NULL; 85 85 } … … 113 113 { 114 114 cherokee_config_entry_mrproper (entry); 115 115 116 free (entry); 116 117 117 return ret_ok; 118 118 } cherokee/trunk/cherokee/connection.c
r293 r336 1 2 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 3 2 … … 459 458 460 459 cherokee_http_code_copy (cnt->error_code, buffer); 461 cherokee_buffer_add (buffer, CRLF, 2);460 cherokee_buffer_add_str (buffer, CRLF); 462 461 463 462 /* Add the "Connection:" header … … 478 477 cherokee_buffer_add_str (buffer, "Date: "); 479 478 cherokee_buffer_add_buffer (buffer, &CONN_SRV(cnt)->bogo_now_string); 480 cherokee_buffer_add (buffer, CRLF, 2);479 cherokee_buffer_add_str (buffer, CRLF); 481 480 482 481 /* Add the Server header cherokee/trunk/cherokee/downloader.c
r270 r336 462 462 break; 463 463 case ret_eof: 464 downloader->status = downloader->status & ~downloader_status_data_available | downloader_status_finished;464 downloader->status = downloader->status & (~downloader_status_data_available | downloader_status_finished); 465 465 break; 466 466 case ret_eagain: cherokee/trunk/cherokee/handler_cgi_base.c
r294 r336 732 732 cherokee_buffer_ensure_size (outbuf, len+6); 733 733 cherokee_buffer_add (outbuf, inbuf->buf, len); 734 cherokee_buffer_add (outbuf, CRLF CRLF, 4);734 cherokee_buffer_add_str (outbuf, CRLF CRLF); 735 735 736 736 /* Drop out the headers, we already have a copy cherokee/trunk/cherokee/handler_error_redir.c
r333 r336 24 24 25 25 #include "common-internal.h" 26 27 #include "handler_redir.h" 26 28 #include "handler_error_redir.h" 27 29 28 30 #include "connection.h" 29 #include "connection-protected.h"30 #include "handler_redir.h"31 31 #include "module_loader.h" 32 32 33 33 34 ret_t 35 cherokee_handler_error_redir_configure () 34 typedef struct { 35 list_t entry; 36 cuint_t error; 37 cherokee_buffer_t url; 38 } error_entry_t; 39 40 41 static ret_t 42 props_free (cherokee_handler_error_redir_props_t *props) 36 43 { 44 return cherokee_handler_props_free_base (HANDLER_PROPS(props)); 45 } 46 47 ret_t 48 cherokee_handler_error_redir_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_handler_props_t **_props) 49 { 50 list_t *i; 51 cherokee_handler_error_redir_props_t *props; 52 53 if (*_props == NULL) { 54 CHEROKEE_NEW_STRUCT (n, handler_error_redir_props); 55 56 cherokee_handler_props_init_base (HANDLER_PROPS(n), 57 HANDLER_PROPS_FREE(props_free)); 58 INIT_LIST_HEAD (&n->errors); 59 *_props = HANDLER_PROPS(n); 60 } 61 62 props = PROP_ERREDIR(*_props); 63 64 cherokee_config_node_foreach (i, conf) { 65 cuint_t error; 66 cherokee_config_node_t *subconf = CONFIG_NODE(i); 67 68 error = atoi (subconf->key.buf); 69 if (!http_type_300 (error) && 70 !http_type_400 (error) && 71 !http_type_500 (error)) 72 { 73 PRINT_ERROR ("ERROR: error_redir: Wrong error code: '%s'\n", subconf->key.buf); 74 continue; 75 } 76 77 // if (equal_buf_str (&subconf->key, "iocache")) { 78 79 // ALO TODO: Finish this mess 80 81 subconf = subconf; 82 } 83 37 84 return ret_ok; 38 85 } 39 86 87 40 88 ret_t 41 cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_ table_t *properties)89 cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_handler_props_t *props) 42 90 { 43 91 ret_t ret; … … 45 93 char code[4]; 46 94 47 if (prop erties == NULL) {95 if (props == NULL) { 48 96 return ret_not_found; 49 97 } 50 98 51 snprintf (code, 4, "%d", cnt->error_code); 99 /* snprintf (code, 4, "%d", cnt->error_code); */ 52 100 53 ret = cherokee_typed_table_get_str (properties, code, &dir); 54 if (ret != ret_ok) return ret_error; 101 /* ret = cherokee_typed_table_get_str (properties, code, &dir); */ 102 /* if (ret != ret_ok) return ret_error; */ 55 103 56 cherokee_buffer_add (&cnt->redirect, dir, strlen(dir)); 57 cnt->error_code = http_moved_permanently; 104 /* cherokee_buffer_add (&cnt->redirect, dir, strlen(dir)); */ 105 /* cnt->error_code = http_moved_permanently; */ 58 106 59 return cherokee_handler_redir_new (hdl, cnt, prop erties);107 return cherokee_handler_redir_new (hdl, cnt, props); 60 108 } 61 109 cherokee/trunk/cherokee/handler_error_redir.h
r191 r336 27 27 28 28 #include "common-internal.h" 29 29 30 #include "handler.h" 30 31 #include "connection.h" 31 32 #include "module_loader.h" 32 33 34 typedef struct { 35 cherokee_handler_t handler; 36 cherokee_buffer_t *content; 37 } cherokee_handler_error_redir_t; 33 38 34 39 typedef struct { 35 cherokee_handler_t handler;36 cherokee_buffer_t *content;37 } cherokee_handler_error_redir_ t;40 cherokee_handler_props_t base; 41 list_t errors; 42 } cherokee_handler_error_redir_props_t; 38 43 39 44 #define ERREDIR_HANDLER(x) ((cherokee_handler_error_redir_t *)(x)) 40 45 #define PROP_ERREDIR(x) ((cherokee_handler_error_redir_props_t *)(x)) 46 #define HDL_ERREDIR_PROP(x) (PROP_ERREDIR(HANDLER(x)->props)) 41 47 42 48 /* Library init function 43 49 */ 44 50 void MODULE_INIT(error_redir) (cherokee_module_loader_t *loader); 45 ret_t cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_table_t *properties); 51 52 ret_t cherokee_handler_error_redir_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_handler_props_t **_props); 53 ret_t cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_handler_props_t *props); 46 54 47 55 #endif /* CHEROKEE_HANDLER_ERROR_REDIR_H */ cherokee/trunk/cherokee/handler_file.c
r333 r336 636 636 cherokee_gmtime (&fhdl->info->st_mtime, &modified_tm); 637 637 638 cherokee_buffer_add_va (buffer, "Last-Modified: %s, %02d %s %d %02d:%02d:%02d GMT"CRLF, 638 cherokee_buffer_add_va (buffer, 639 "Last-Modified: %s, %02d %s %d %02d:%02d:%02d GMT"CRLF, 639 640 cherokee_weekdays[modified_tm.tm_wday], 640 641 modified_tm.tm_mday, cherokee/trunk/cherokee/handler_remote_control.c
r122 r336 78 78 cherokee_connection_parse_args (HANDLER_CONN(hdl)); 79 79 80 cherokee_buffer_add (hdl->buffer, "<?xml version=\"1.0\"?>"CRLF, 23);81 cherokee_buffer_add (hdl->buffer, "<status>"CRLF, 10);80 cherokee_buffer_add_str (hdl->buffer, "<?xml version=\"1.0\"?>"CRLF); 81 cherokee_buffer_add_str (hdl->buffer, "<status>"CRLF); 82 82 83 83 /* Connections … … 123 123 124 124 125 cherokee_buffer_add (hdl->buffer, "</status>"CRLF, 11);125 cherokee_buffer_add_str (hdl->buffer, "</status>"CRLF); 126 126 127 127 return ret_ok; … … 140 140 cherokee_handler_remote_control_add_headers (cherokee_handler_remote_control_t *hdl, cherokee_buffer_t *buffer) 141 141 { 142 cherokee_buffer_add (buffer, "Content-Type: text/html"CRLF, 25);142 cherokee_buffer_add_str(buffer, "Content-Type: text/html"CRLF); 143 143 cherokee_buffer_add_va (buffer, "Content-Length: %d"CRLF, hdl->buffer->len); 144 144 145 cherokee_buffer_add (buffer, "Cache-Control: no-cache"CRLF, 25);146 cherokee_buffer_add (buffer, "Pragma: no-cache"CRLF, 18);145 cherokee_buffer_add_str(buffer, "Cache-Control: no-cache"CRLF); 146 cherokee_buffer_add_str(buffer, "Pragma: no-cache"CRLF); 147 147 148 148 return ret_ok; cherokee/trunk/cherokee/handler_webcam.c
r122 r336 90 90 cherokee_handler_webcam_add_headers (cherokee_handler_webcam_t *hdl, cherokee_buffer_t *buffer) 91 91 { 92 cherokee_buffer_add (buffer, "Content-Type: image/jpeg"CRLF, 26);92 cherokee_buffer_add_str (buffer, "Content-Type: image/jpeg"CRLF); 93 93 return ret_ok; 94 94 } cherokee/trunk/cherokee/main.c
r314 r336 36 36 #include "server.h" 37 37 38 #define DEFAULT_CONFIG_FILE "/etc/cherokee/cherokee.conf" 39 38 40 #ifndef CHEROKEE_EMBEDDED 39 41 # define GETOPT_OPT "C:br:" 40 # define CONFIG_FILE "[-C configfile]"42 # define CONFIG_FILE_HELP "[-C configfile] [-r]" 41 43 #else 42 44 # define GETOPT_OPT "br:" 43 # define CONFIG_FILE ""45 # define CONFIG_FILE_HELP "" 44 46 #endif 45 47 … … 108 110 cherokee_buffer_mrproper (&tmp); 109 111 } else { 110 ret = cherokee_server_read_config_file (srv, config_file); 112 char *config = (config_file) ? config_file : DEFAULT_CONFIG_FILE; 113 ret = cherokee_server_read_config_file (srv, config); 111 114 } 112 115 … … 149 152 150 153 default: 151 fprintf (stderr, "Usage: %s " CONFIG_FILE "[-b]\n", argv[0]);154 fprintf (stderr, "Usage: %s " CONFIG_FILE_HELP "[-b]\n", argv[0]); 152 155 exit(1); 153 156 } cherokee/trunk/cherokee/module.h
r333 r336 53 53 typedef ret_t (* module_func_free_t) (void *); 54 54 typedef void (* module_func_get_name_t) (void *, const char **name); 55 typedef ret_t (* module_func_configure_t) (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_table_t**props);55 typedef ret_t (* module_func_configure_t) (cherokee_config_node_t *conf, cherokee_server_t *srv, void **props); 56 56 57 57 … … 117 117 cherokee_module_info_handler_t MODULE_INFO(name) = { \ 118 118 { cherokee_handler, \ 119 cherokee_handler_ ## name ## _new,\120 cherokee_handler_ ## name ## _configure,\119 (void *) cherokee_handler_ ## name ## _new, \ 120 (void *) cherokee_handler_ ## name ## _configure, \ 121 121 }, (methods) } 122 122 … … 124 124 cherokee_module_info_handler_t MODULE_INFO(name) = { \ 125 125 { cherokee_validator, \ 126 cherokee_validator_ ## name ## _new, \127 cherokee_validator_ ## name ## _configure,\126 (void *) cherokee_validator_ ## name ## _new, \ 127 (void *) cherokee_validator_ ## name ## _configure, \ 128 128 }, (methods) } 129 129 cherokee/trunk/cherokee/request.c
r254 r336 109 109 switch (REQUEST_VERSION(request)) { 110 110 case http_version_11: 111 cherokee_buffer_add (buf, " HTTP/1.1" CRLF, 11);111 cherokee_buffer_add_str (buf, " HTTP/1.1" CRLF); 112 112 break; 113 113 case http_version_10: 114 cherokee_buffer_add (buf, " HTTP/1.0" CRLF, 11);114 cherokee_buffer_add_str (buf, " HTTP/1.0" CRLF); 115 115 break; 116 116 case http_version_09: 117 cherokee_buffer_add (buf, " HTTP/0.9" CRLF, 11);117 cherokee_buffer_add_str (buf, " HTTP/0.9" CRLF); 118 118 break; 119 119 default: … … 126 126 cherokee_buffer_add (buf, "Host: ", 6); 127 127 cherokee_buffer_add_buffer (buf, URL_HOST(url)); 128 cherokee_buffer_add (buf, CRLF, 2);128 cherokee_buffer_add_str (buf, CRLF); 129 129 } 130 130 … … 139 139 */ 140 140 if (REQUEST_KEEPALIVE(request)) { 141 cherokee_buffer_add (buf, "Connection: Keep-alive"CRLF, 24);141 cherokee_buffer_add_str (buf, "Connection: Keep-alive"CRLF); 142 142 } else { 143 cherokee_buffer_add (buf, "Connection: Close"CRLF, 19);143 cherokee_buffer_add_str (buf, "Connection: Close"CRLF); 144 144 } 145 145 … … 167 167 /* Finish the header 168 168 */ 169 cherokee_buffer_add (buf, CRLF, 2);169 cherokee_buffer_add_str (buf, CRLF); 170 170 171 171 return ret_ok; cherokee/trunk/cherokee/server.c
r302 r336 1097 1097 update_bogo_now (cherokee_server_t *srv) 1098 1098 { 1099 time_t prev;1099 time_t newtime; 1100 1100 static long *this_timezone = NULL; 1101 1101 1102 1102 CHEROKEE_RWLOCK_WRITER (&srv->bogo_now_mutex); /* 1.- lock as writer */ 1103 1103 1104 prev = srv->bogo_now; 1105 srv->bogo_now = time (NULL); 1106 cherokee_localtime (&srv->bogo_now, &srv->bogo_now_tm); 1107 1108 /* Update time string if needed 1109 */ 1110 if (prev < srv->bogo_now) { 1111 int z; 1112 1113 cherokee_buffer_clean (&srv->bogo_now_string); 1114 1115 if (this_timezone == NULL) 1116 this_timezone = cherokee_get_timezone_ref(); 1117 z = - (*this_timezone / 60); 1118 1119 cherokee_buffer_add_va (&srv->bogo_now_string, "%s, %02d %s %d %02d:%02d:%02d GMT%c%d", 1104 newtime = time (NULL); 1105 if (srv->bogo_now != newtime) { 1106 time_t prevtime = srv->bogo_now; 1107 1108 srv->bogo_now = newtime; 1109 cherokee_localtime (&newtime, &srv->bogo_now_tm); 1110 1111 /* Update time string if needed 1112 */ 1113 if (prevtime < newtime) { 1114 int z; 1115 1116 cherokee_buffer_clean (&srv->bogo_now_string); 1117 1118 if (this_timezone == NULL) 1119 this_timezone = cherokee_get_timezone_ref(); 1120 z = - (*this_timezone / 60); 1121 1122 cherokee_buffer_add_va (&srv->bogo_now_string, 1123 "%s, %02d %s %d %02d:%02d:%02d GMT%c%d", 1120 1124 cherokee_weekdays[srv->bogo_now_tm.tm_wday], 1121 1125 srv->bogo_now_tm.tm_mday, … … 1127 1131 (z < 0) ? '-' : '+', 1128 1132 (z / 60)); 1133 } 1129 1134 } 1130 1135 cherokee/trunk/cherokee/tdate_parse.c
r114 r336 26 26 */ 27 27 28 /* This is a stripped-down version of date_parse.c, available at28 /* This is a stripped-down / modified version of date_parse.c, available at 29 29 ** http://www.acme.com/software/date_parse/ 30 30 */ … … 58 58 *str = tolower( (int) *str ); 59 59 } 60 }61 62 static int63 strlong_compare (void *v1, void *v2)64 {65 return strcmp( ((struct strlong*) v1)->s, ((struct strlong*) v2)->s );66 60 } 67 61 … … 97 91 { 98 92 static struct strlong wday_tab[] = { 99 { "sun", 0 }, { "sunday", 0 }, 100 { "mon", 1 }, { "monday", 1 }, 101 { "tue", 2 }, { "tuesday", 2 }, 102 { "wed", 3 }, { "wednesday", 3 }, 103 { "thu", 4 }, { "thursday", 4 }, 104 { "fri", 5 }, { "friday", 5 }, 105 { "sat", 6 }, { "saturday", 6 }, 106 }; 107 static int sorted = 0; 108 109 if ( ! sorted ) 110 { 111 (void) qsort( 112 wday_tab, sizeof(wday_tab)/sizeof(struct strlong), 113 sizeof(struct strlong), strlong_compare ); 114 sorted = 1; 115 } 93 { "fri", 5 }, 94 { "friday", 5 }, 95 { "mon", 1 }, 96 { "monday", 1 }, 97 { "sat", 6 }, 98 { "saturday", 6 }, 99 { "sun", 0 }, 100 { "sunday", 0 }, 101 { "thu", 4 }, 102 { "thursday", 4 }, 103 { "tue", 2 }, 104 { "tuesday", 2 }, 105 { "wed", 3 }, 106 { "wednesday", 3 } 107 }; 108 116 109 pound_case( str_wday ); 117 110 return strlong_search( 118 str_wday, wday_tab, sizeof(wday_tab)/sizeof(struct strlong), tm_wdayP );111 str_wday, wday_tab, sizeof(wday_tab)/sizeof(struct strlong), tm_wdayP ); 119 112 } 120 113 … … 124 117 { 125 118 static struct strlong mon_tab[] = { 126 { "jan", 0 }, { "january", 0 }, 127 { "feb", 1 }, { "february", 1 }, 128 { "mar", 2 }, { "march", 2 }, 129 { "apr", 3 }, { "april", 3 }, 130 { "may", 4 }, 131 { "jun", 5 }, { "june", 5 }, 132 { "jul", 6 }, { "july", 6 }, 133 { "aug", 7 }, { "august", 7 }, 134 { "sep", 8 }, { "september", 8 }, 135 { "oct", 9 }, { "october", 9 }, 136 { "nov", 10 }, { "november", 10 }, 137 { "dec", 11 }, { "december", 11 }, 138 }; 139 static int sorted = 0; 140 141 if ( ! sorted ) 142 { 143 (void) qsort( 144 mon_tab, sizeof(mon_tab)/sizeof(struct strlong), 145 sizeof(struct strlong), strlong_compare ); 146 sorted = 1; 147 } 119 { "apr", 3 }, 120 { "april", 3 }, 121 { "aug", 7 }, 122 { "august", 7 }, 123 { "dec", 11 }, 124 { "december", 11 }, 125 { "feb", 1 }, 126 { "february", 1 }, 127 { "jan", 0 }, 128 { "january", 0 }, 129 { "jul", 6 }, 130 { "july", 6 }, 131 { "jun", 5 }, 132 { "june", 5 }, 133 { "mar", 2 }, 134 { "march", 2 }, 135 { "may", 4 }, 136 { "nov", 10 }, 137 { "november", 10 }, 138 { "oct", 9 }, 139 { "october", 9 }, 140 { "sep", 8 }, 141 { "september", 8 } 142 }; 143 148 144 pound_case( str_mon ); 149 145 return strlong_search( 150 str_mon, mon_tab, sizeof(mon_tab)/sizeof(struct strlong), tm_monP );146 str_mon, mon_tab, sizeof(mon_tab)/sizeof(struct strlong), tm_monP ); 151 147 } 152 148 … … 187 183 188 184 185 /* 186 ** Parse the date-time string and returns the equivalent time in seconds. 187 */ 189 188 time_t 190 189 tdate_parse( char* str ) … … 192 191 struct tm tm; 193 192 char* cp; 194 char str_mon[500], str_wday[500]; 193 char str_mon[64], str_wday[64]; 194 char str_sep1[8], str_sep2[8]; 195 195 int tm_sec, tm_min, tm_hour, tm_mday, tm_year; 196 196 long tm_mon, tm_wday; … … 203 203 for ( cp = str; *cp == ' ' || *cp == '\t'; ++cp ) 204 204 continue; 205 206 /* If there is no date-time, then return now */ 207 if ( !*cp ) 208 return (time_t) -1; 205 209 206 210 /* And do the sscanfs. WARNING: you can add more formats here, … … 209 213 */ 210 214 215 /* wdy, DD mth YYYY HH:MM:SS GMT (RFC 822, 1123 - standard). */ 216 if ( sscanf( cp, "%60[a-zA-Z], %d %60[a-zA-Z] %d %d:%d:%d GMT", 217 str_wday, &tm_mday, str_mon, &tm_year, 218 &tm_hour, &tm_min, &tm_sec ) == 7 && 219 scan_wday( str_wday, &tm_wday ) && 220 scan_mon( str_mon, &tm_mon ) ) 221 { 222 tm.tm_wday = tm_wday; 223 tm.tm_mday = tm_mday; 224 tm.tm_mon = tm_mon; 225 tm.tm_year = tm_year; 226 tm.tm_hour = tm_hour; 227 tm.tm_min = tm_min; 228 tm.tm_sec = tm_sec; 229 } 230 231 /* wdy, DD-mth-YY HH:MM:SS GMT (RFC 850 - obsolete) */ 232 /* wdy, DD-mth-YYYY HH:MM:SS GMT (strange RFC 822) */ 233 else 234 if ( sscanf( cp, "%60[a-zA-Z], %d%2[ -]%60[a-zA-Z]%2[ -]%d %d:%d:%d GMT", 235 str_wday, &tm_mday, str_sep1, str_mon, str_sep2, &tm_year, 236 &tm_hour, &tm_min, &tm_sec ) == 9 && 237 scan_wday( str_wday, &tm_wday ) && 238 scan_mon( str_mon, &tm_mon ) ) 239 { 240 tm.tm_wday = tm_wday; 241 tm.tm_mday = tm_mday; 242 tm.tm_mon = tm_mon; 243 tm.tm_year = tm_year; 244 tm.tm_hour = tm_hour; 245 tm.tm_min = tm_min; 246 tm.tm_sec = tm_sec; 247 } 248 249 /* wdy mth DD HH:MM:SS YYYY (ANSI C asctime() format - uncommon) */ 250 else 251 if ( sscanf( cp, "%60[a-zA-Z] %60[a-zA-Z] %d %d:%d:%d %d", 252 str_wday, str_mon, &tm_mday, &tm_hour, &tm_min, &tm_sec, 253 &tm_year ) == 7 && 254 scan_wday( str_wday, &tm_wday ) && 255 scan_mon( str_mon, &tm_mon ) ) 256 { 257 tm.tm_wday = tm_wday; 258 tm.tm_mon = tm_mon; 259 tm.tm_mday = tm_mday; 260 tm.tm_hour = tm_hour; 261 tm.tm_min = tm_min; 262 tm.tm_sec = tm_sec; 263 tm.tm_year = tm_year; 264 } 265 /* other VERY VERY UNCOMMON formats */ 266 267 /* wdy mth DD HH:MM:SS GMT YY */ 268 else 269 if ( sscanf( cp, "%60[a-zA-Z] %60[a-zA-Z] %d %d:%d:%d GMT %d", 270 str_wday, str_mon, &tm_mday, &tm_hour, &tm_min, &tm_sec, 271 &tm_year ) == 7 && 272 scan_wday( str_wday, &tm_wday ) && 273 scan_mon( str_mon, &tm_mon ) ) 274 { 275 tm.tm_wday = tm_wday; 276 tm.tm_mon = tm_mon; 277 tm.tm_mday = tm_mday; 278 tm.tm_hour = tm_hour; 279 tm.tm_min = tm_min; 280 tm.tm_sec = tm_sec; 281 tm.tm_year = tm_year; 282 } 283 211 284 /* DD-mth-YY HH:MM:SS GMT */ 212 if ( sscanf( cp, "%d-%400[a-zA-Z]-%d %d:%d:%d GMT",213 &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min,214 &tm_sec ) == 6 &&215 scan_mon( str_mon, &tm_mon ) )216 {217 tm.tm_mday = tm_mday;218 tm.tm_mon = tm_mon;219 tm.tm_year = tm_year;220 tm.tm_hour = tm_hour;221 tm.tm_min = tm_min;222 tm.tm_sec = tm_sec;223 }224 225 285 /* DD mth YY HH:MM:SS GMT */ 226 else if ( sscanf( cp, "%d %400[a-zA-Z] %d %d:%d:%d GMT", 227 &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, 228 &tm_sec) == 6 && 229 scan_mon( str_mon, &tm_mon ) ) 230 { 231 tm.tm_mday = tm_mday; 232 tm.tm_mon = tm_mon; 233 tm.tm_year = tm_year; 234 tm.tm_hour = tm_hour; 235 tm.tm_min = tm_min; 236 tm.tm_sec = tm_sec; 286 else 287 if ( sscanf( cp, "%d%2[ -]%60[a-zA-Z]%2[ -]%d %d:%d:%d GMT", 288 &tm_mday, str_sep1, str_mon, str_sep2, &tm_year, 289 &tm_hour, &tm_min, &tm_sec ) == 8 && 290 scan_mon( str_mon, &tm_mon ) ) 291 { 292 tm.tm_mday = tm_mday; 293 tm.tm_mon = tm_mon; 294 tm.tm_year = tm_year; 295 tm.tm_hour = tm_hour; 296 tm.tm_min = tm_min; 297 tm.tm_sec = tm_sec; 237 298 } 238 299 239 300 /* HH:MM:SS GMT DD-mth-YY */ 240 else if ( sscanf( cp, "%d:%d:%d GMT %d-%400[a-zA-Z]-%d",241 &tm_hour, &tm_min, &tm_sec, &tm_mday, str_mon,242 &tm_year ) == 6 &&243 scan_mon( str_mon, &tm_mon ) )244 {245 tm.tm_hour = tm_hour;246 tm.tm_min = tm_min;247 tm.tm_sec = tm_sec;248 tm.tm_mday = tm_mday;249 tm.tm_mon = tm_mon;250 tm.tm_year = tm_year;251 }252 253 301 /* HH:MM:SS GMT DD mth YY */ 254 else if ( sscanf( cp, "%d:%d:%d GMT %d %400[a-zA-Z] %d", 255 &tm_hour, &tm_min, &tm_sec, &tm_mday, str_mon, 256 &tm_year ) == 6 && 257 scan_mon( str_mon, &tm_mon ) ) 258 { 259 tm.tm_hour = tm_hour; 260 tm.tm_min = tm_min; 261 tm.tm_sec = tm_sec; 262 tm.tm_mday = tm_mday; 263 tm.tm_mon = tm_mon; 264 tm.tm_year = tm_year; 265 } 266 267 /* wdy, DD-mth-YY HH:MM:SS GMT */ 268 else if ( sscanf( cp, "%400[a-zA-Z], %d-%400[a-zA-Z]-%d %d:%d:%d GMT", 269 str_wday, &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, 270 &tm_sec ) == 7 && 271 scan_wday( str_wday, &tm_wday ) && 272 scan_mon( str_mon, &tm_mon ) ) 273 { 274 tm.tm_wday = tm_wday; 275 tm.tm_mday = tm_mday; 276 tm.tm_mon = tm_mon; 277 tm.tm_year = tm_year; 278 tm.tm_hour = tm_hour; 279 tm.tm_min = tm_min; 280 tm.tm_sec = tm_sec; 281 } 282 283 /* wdy, DD mth YY HH:MM:SS GMT */ 284 else if ( sscanf( cp, "%400[a-zA-Z], %d %400[a-zA-Z] %d %d:%d:%d GMT", 285 str_wday, &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, 286 &tm_sec ) == 7 && 287 scan_wday( str_wday, &tm_wday ) && 288 scan_mon( str_mon, &tm_mon ) ) 289 { 290 tm.tm_wday = tm_wday; 291 tm.tm_mday = tm_mday; 292 tm.tm_mon = tm_mon; 293 tm.tm_year = tm_year; 294 tm.tm_hour = tm_hour; 295 tm.tm_min = tm_min; 296 tm.tm_sec = tm_sec; 297 } 298 299 /* wdy mth DD HH:MM:SS GMT YY */ 300 else if ( sscanf( cp, "%400[a-zA-Z] %400[a-zA-Z] %d %d:%d:%d GMT %d", 301 str_wday, str_mon, &tm_mday, &tm_hour, &tm_min, &tm_sec, 302 &tm_year ) == 7 && 303 scan_wday( str_wday, &tm_wday ) && 304 scan_mon( str_mon, &tm_mon ) ) 305 { 306 tm.tm_wday = tm_wday; 307 tm.tm_mon = tm_mon; 308 tm.tm_mday = tm_mday; 309 tm.tm_hour = tm_hour; 310 tm.tm_min = tm_min; 311 tm.tm_sec = tm_sec; 312 tm.tm_year = tm_year; 313 } 314 else 315 return (time_t) -1; 302 else 303 if ( sscanf( cp, "%d:%d:%d GMT %d%2[ -]%60[a-zA-Z]%2[ -]%d", 304 &tm_hour, &tm_min, &tm_sec, 305 &tm_mday, str_sep1, str_mon, str_sep2, &tm_year ) == 8 && 306 scan_mon( str_mon, &tm_mon ) ) 307 { 308 tm.tm_hour = tm_hour; 309 tm.tm_min = tm_min; 310 tm.tm_sec = tm_sec; 311 tm.tm_mday = tm_mday; 312 tm.tm_mon = tm_mon; 313 tm.tm_year = tm_year; 314 } 315 else 316 return (time_t) -1; 316 317 317 318 if ( tm.tm_year > 1900 ) cherokee/trunk/cherokee/validator_htpasswd.c
r333 r336 47 47 48 48 ret_t 49 cherokee_validator_htpasswd_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_ table_t **_props)49 cherokee_validator_htpasswd_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_validator_props_t **_props) 50 50 { 51 51 ret_t ret;