Changeset 336

Show
Ignore:
Timestamp:
08/14/06 00:56:36 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/cherokee/config_entry.c

    r289 r336  
    8181 
    8282        if (entry->validator_properties != NULL) { 
    83                 cherokee_typed_table_free (entry->validator_properties); 
     83                cherokee_validator_props_free (entry->validator_properties); 
    8484                entry->validator_properties = NULL; 
    8585        } 
     
    113113{ 
    114114        cherokee_config_entry_mrproper (entry); 
     115 
    115116        free (entry); 
    116  
    117117        return ret_ok; 
    118118} 
  • cherokee/trunk/cherokee/connection.c

    r293 r336  
    1  
    21/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 
    32 
     
    459458         
    460459        cherokee_http_code_copy (cnt->error_code, buffer); 
    461         cherokee_buffer_add (buffer, CRLF, 2); 
     460        cherokee_buffer_add_str (buffer, CRLF); 
    462461 
    463462        /* Add the "Connection:" header 
     
    478477        cherokee_buffer_add_str (buffer, "Date: "); 
    479478        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); 
    481480 
    482481        /* Add the Server header 
  • cherokee/trunk/cherokee/downloader.c

    r270 r336  
    462462                        break; 
    463463                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)
    465465                        break; 
    466466                case ret_eagain: 
  • cherokee/trunk/cherokee/handler_cgi_base.c

    r294 r336  
    732732        cherokee_buffer_ensure_size (outbuf, len+6); 
    733733        cherokee_buffer_add (outbuf, inbuf->buf, len); 
    734         cherokee_buffer_add (outbuf, CRLF CRLF, 4); 
     734        cherokee_buffer_add_str (outbuf, CRLF CRLF); 
    735735 
    736736        /* Drop out the headers, we already have a copy 
  • cherokee/trunk/cherokee/handler_error_redir.c

    r333 r336  
    2424 
    2525#include "common-internal.h" 
     26 
     27#include "handler_redir.h" 
    2628#include "handler_error_redir.h" 
    2729 
    2830#include "connection.h" 
    29 #include "connection-protected.h" 
    30 #include "handler_redir.h" 
    3131#include "module_loader.h" 
    3232 
    3333 
    34 ret_t 
    35 cherokee_handler_error_redir_configure () 
     34typedef struct { 
     35        list_t            entry; 
     36        cuint_t           error; 
     37        cherokee_buffer_t url; 
     38} error_entry_t; 
     39 
     40 
     41static ret_t  
     42props_free (cherokee_handler_error_redir_props_t *props) 
    3643{ 
     44        return cherokee_handler_props_free_base (HANDLER_PROPS(props)); 
     45} 
     46 
     47ret_t  
     48cherokee_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 
    3784        return ret_ok; 
    3885} 
    3986 
     87 
    4088ret_t  
    41 cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_table_t *properties) 
     89cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_handler_props_t *props) 
    4290{ 
    4391        ret_t  ret; 
     
    4593        char   code[4]; 
    4694 
    47         if (properties == NULL) { 
     95        if (props == NULL) { 
    4896                return ret_not_found; 
    4997        } 
    5098 
    51         snprintf (code, 4, "%d", cnt->error_code); 
     99/*      snprintf (code, 4, "%d", cnt->error_code); */ 
    52100            
    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; */ 
    55103 
    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; */ 
    58106 
    59         return cherokee_handler_redir_new (hdl, cnt, properties); 
     107        return cherokee_handler_redir_new (hdl, cnt, props); 
    60108} 
    61109 
  • cherokee/trunk/cherokee/handler_error_redir.h

    r191 r336  
    2727 
    2828#include "common-internal.h" 
     29 
    2930#include "handler.h" 
    3031#include "connection.h" 
    3132#include "module_loader.h" 
    3233 
     34typedef struct { 
     35        cherokee_handler_t handler; 
     36        cherokee_buffer_t *content; 
     37} cherokee_handler_error_redir_t; 
    3338 
    3439typedef 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; 
    3843 
    3944#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)) 
    4147 
    4248/* Library init function 
    4349 */ 
    4450void 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 
     52ret_t cherokee_handler_error_redir_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_handler_props_t **_props); 
     53ret_t cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_handler_props_t *props); 
    4654 
    4755#endif /* CHEROKEE_HANDLER_ERROR_REDIR_H */ 
  • cherokee/trunk/cherokee/handler_file.c

    r333 r336  
    636636        cherokee_gmtime (&fhdl->info->st_mtime, &modified_tm); 
    637637 
    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, 
    639640                                cherokee_weekdays[modified_tm.tm_wday], 
    640641                                modified_tm.tm_mday, 
  • cherokee/trunk/cherokee/handler_remote_control.c

    r122 r336  
    7878        cherokee_connection_parse_args (HANDLER_CONN(hdl)); 
    7979 
    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);  
    8282         
    8383        /* Connections 
     
    123123 
    124124 
    125         cherokee_buffer_add (hdl->buffer, "</status>"CRLF, 11);  
     125        cherokee_buffer_add_str (hdl->buffer, "</status>"CRLF);  
    126126 
    127127        return ret_ok; 
     
    140140cherokee_handler_remote_control_add_headers (cherokee_handler_remote_control_t *hdl, cherokee_buffer_t *buffer) 
    141141{ 
    142         cherokee_buffer_add    (buffer, "Content-Type: text/html"CRLF, 25); 
     142        cherokee_buffer_add_str(buffer, "Content-Type: text/html"CRLF); 
    143143        cherokee_buffer_add_va (buffer, "Content-Length: %d"CRLF, hdl->buffer->len); 
    144144 
    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); 
    147147 
    148148        return ret_ok; 
  • cherokee/trunk/cherokee/handler_webcam.c

    r122 r336  
    9090cherokee_handler_webcam_add_headers (cherokee_handler_webcam_t *hdl, cherokee_buffer_t *buffer) 
    9191{ 
    92            cherokee_buffer_add (buffer, "Content-Type: image/jpeg"CRLF, 26); 
     92           cherokee_buffer_add_str (buffer, "Content-Type: image/jpeg"CRLF); 
    9393           return ret_ok; 
    9494} 
  • cherokee/trunk/cherokee/main.c

    r314 r336  
    3636#include "server.h" 
    3737 
     38#define DEFAULT_CONFIG_FILE "/etc/cherokee/cherokee.conf" 
     39 
    3840#ifndef CHEROKEE_EMBEDDED 
    3941# define GETOPT_OPT  "C:br:" 
    40 # define CONFIG_FILE "[-C configfile]
     42# define CONFIG_FILE_HELP "[-C configfile] [-r]
    4143#else 
    4244# define GETOPT_OPT  "br:" 
    43 # define CONFIG_FILE "" 
     45# define CONFIG_FILE_HELP "" 
    4446#endif  
    4547 
     
    108110                cherokee_buffer_mrproper (&tmp); 
    109111        } 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); 
    111114        } 
    112115 
     
    149152 
    150153                default: 
    151                         fprintf (stderr, "Usage: %s " CONFIG_FILE "[-b]\n", argv[0]); 
     154                        fprintf (stderr, "Usage: %s " CONFIG_FILE_HELP "[-b]\n", argv[0]); 
    152155                        exit(1); 
    153156                } 
  • cherokee/trunk/cherokee/module.h

    r333 r336  
    5353typedef ret_t (* module_func_free_t)      (void *); 
    5454typedef 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); 
     55typedef ret_t (* module_func_configure_t) (cherokee_config_node_t *conf, cherokee_server_t *srv, void **props); 
    5656 
    5757 
     
    117117        cherokee_module_info_handler_t MODULE_INFO(name) = {       \ 
    118118                { cherokee_handler,                                \ 
    119                   cherokee_handler_ ## name ## _new,             \ 
    120                   cherokee_handler_ ## name ## _configure,       
     119                  (void *) cherokee_handler_ ## name ## _new,    \ 
     120                  (void *) cherokee_handler_ ## name ## _configure,
    121121                }, (methods) } 
    122122 
     
    124124        cherokee_module_info_handler_t MODULE_INFO(name) = {       \ 
    125125                { cherokee_validator,                              \ 
    126                   cherokee_validator_ ## name ## _new,                   \ 
    127                   cherokee_validator_ ## name ## _configure,     
     126                  (void *) cherokee_validator_ ## name ## _new,                  \ 
     127                  (void *) cherokee_validator_ ## name ## _configure,
    128128                }, (methods) } 
    129129 
  • cherokee/trunk/cherokee/request.c

    r254 r336  
    109109        switch (REQUEST_VERSION(request)) { 
    110110        case http_version_11: 
    111                 cherokee_buffer_add (buf, " HTTP/1.1" CRLF, 11); 
     111                cherokee_buffer_add_str (buf, " HTTP/1.1" CRLF); 
    112112                break; 
    113113        case http_version_10: 
    114                 cherokee_buffer_add (buf, " HTTP/1.0" CRLF, 11); 
     114                cherokee_buffer_add_str (buf, " HTTP/1.0" CRLF); 
    115115                break; 
    116116        case http_version_09: 
    117                 cherokee_buffer_add (buf, " HTTP/0.9" CRLF, 11); 
     117                cherokee_buffer_add_str (buf, " HTTP/0.9" CRLF); 
    118118                break; 
    119119        default: 
     
    126126                cherokee_buffer_add (buf, "Host: ", 6); 
    127127                cherokee_buffer_add_buffer (buf, URL_HOST(url)); 
    128                 cherokee_buffer_add (buf, CRLF, 2); 
     128                cherokee_buffer_add_str (buf, CRLF); 
    129129        } 
    130130 
     
    139139         */ 
    140140        if (REQUEST_KEEPALIVE(request)) { 
    141                 cherokee_buffer_add (buf, "Connection: Keep-alive"CRLF, 24);  
     141                cherokee_buffer_add_str (buf, "Connection: Keep-alive"CRLF);  
    142142        } else { 
    143                 cherokee_buffer_add (buf, "Connection: Close"CRLF, 19);  
     143                cherokee_buffer_add_str (buf, "Connection: Close"CRLF);  
    144144        } 
    145145 
     
    167167        /* Finish the header 
    168168         */ 
    169         cherokee_buffer_add (buf, CRLF, 2); 
     169        cherokee_buffer_add_str (buf, CRLF); 
    170170 
    171171        return ret_ok; 
  • cherokee/trunk/cherokee/server.c

    r302 r336  
    10971097update_bogo_now (cherokee_server_t *srv) 
    10981098{ 
    1099         time_t       prev
     1099        time_t       newtime
    11001100        static long *this_timezone = NULL; 
    11011101 
    11021102        CHEROKEE_RWLOCK_WRITER (&srv->bogo_now_mutex);      /* 1.- lock as writer */ 
    11031103 
    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", 
    11201124                                        cherokee_weekdays[srv->bogo_now_tm.tm_wday],  
    11211125                                        srv->bogo_now_tm.tm_mday, 
     
    11271131                                        (z < 0) ? '-' : '+', 
    11281132                                        (z / 60)); 
     1133                } 
    11291134        } 
    11301135 
  • cherokee/trunk/cherokee/tdate_parse.c

    r114 r336  
    2626*/ 
    2727 
    28 /* This is a stripped-down version of date_parse.c, available at 
     28/* This is a stripped-down / modified version of date_parse.c, available at 
    2929** http://www.acme.com/software/date_parse/ 
    3030*/ 
     
    5858                                    *str = tolower( (int) *str ); 
    5959           } 
    60 } 
    61  
    62 static int 
    63 strlong_compare (void *v1, void *v2) 
    64 { 
    65            return strcmp( ((struct strlong*) v1)->s, ((struct strlong*) v2)->s ); 
    6660} 
    6761 
     
    9791{ 
    9892           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 
    116109           pound_case( str_wday ); 
    117110           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 ); 
    119112} 
    120113 
     
    124117{ 
    125118           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 
    148144           pound_case( str_mon ); 
    149145           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 ); 
    151147} 
    152148 
     
    187183 
    188184 
     185/* 
     186** Parse the date-time string and returns the equivalent time in seconds. 
     187*/ 
    189188time_t 
    190189tdate_parse( char* str ) 
     
    192191           struct tm tm; 
    193192           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]; 
    195195           int tm_sec, tm_min, tm_hour, tm_mday, tm_year; 
    196196           long tm_mon, tm_wday; 
     
    203203           for ( cp = str; *cp == ' ' || *cp == '\t'; ++cp ) 
    204204                         continue; 
     205 
     206           /* If there is no date-time, then return now */ 
     207           if ( !*cp ) 
     208                    return (time_t) -1; 
    205209 
    206210           /* And do the sscanfs.  WARNING: you can add more formats here, 
     
    209213           */ 
    210214 
     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 
    211284           /* 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  
    225285           /* 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; 
    237298           } 
    238299 
    239300           /* 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  
    253301           /* 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; 
    316317 
    317318           if ( tm.tm_year > 1900 ) 
  • cherokee/trunk/cherokee/validator_htpasswd.c

    r333 r336  
    4747 
    4848ret_t  
    49 cherokee_validator_htpasswd_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_table_t **_props) 
     49cherokee_validator_htpasswd_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_validator_props_t **_props) 
    5050{ 
    5151        ret_t                                ret;