comparison src/core/ngx_conf_file.c @ 496:f39b9e29530d NGINX_0_8_0

nginx 0.8.0 *) Feature: the "keepalive_requests" directive. *) Feature: the "limit_rate_after" directive. Thanks to Ivan Debnar. *) Bugfix: XLST filter did not work in subrequests. *) Bugfix: in relative paths handling in nginx/Windows. *) Bugfix: in proxy_store, fastcgi_store, proxy_cache, and fastcgi_cache in nginx/Windows. *) Bugfix: in memory allocation error handling. Thanks to Maxim Dounin and Kirill A. Korinskiy.
author Igor Sysoev <http://sysoev.ru>
date Tue, 02 Jun 2009 00:00:00 +0400
parents 98143f74eb3d
children 2b9e388c61f1
comparison
equal deleted inserted replaced
495:6d9fb4461113 496:f39b9e29530d
10 #define NGX_CONF_BUFFER 4096 10 #define NGX_CONF_BUFFER 4096
11 11
12 static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last); 12 static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
13 static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf); 13 static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
14 static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 14 static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
15 static ngx_int_t ngx_conf_test_full_name(ngx_str_t *name);
15 static void ngx_conf_flush_files(ngx_cycle_t *cycle); 16 static void ngx_conf_flush_files(ngx_cycle_t *cycle);
16 17
17 18
18 static ngx_command_t ngx_conf_commands[] = { 19 static ngx_command_t ngx_conf_commands[] = {
19 20
800 801
801 ngx_int_t 802 ngx_int_t
802 ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix) 803 ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
803 { 804 {
804 size_t len; 805 size_t len;
805 u_char *p, *prefix; 806 u_char *p, *n, *prefix;
806 ngx_str_t old; 807 ngx_int_t rc;
807 808
808 #if (NGX_WIN32) 809 rc = ngx_conf_test_full_name(name);
809 810
810 if (name->len > 2 811 if (rc == NGX_OK) {
811 && name->data[1] == ':' 812 return rc;
812 && ((name->data[0] >= 'a' && name->data[0] <= 'z') 813 }
813 || (name->data[0] >= 'A' && name->data[0] <= 'Z')))
814 {
815 return NGX_OK;
816 }
817
818 #else
819
820 if (name->data[0] == '/') {
821 return NGX_OK;
822 }
823
824 #endif
825
826 old = *name;
827 814
828 if (conf_prefix) { 815 if (conf_prefix) {
829 len = cycle->conf_prefix.len; 816 len = cycle->conf_prefix.len;
830 prefix = cycle->conf_prefix.data; 817 prefix = cycle->conf_prefix.data;
831 818
832 } else { 819 } else {
833 len = cycle->prefix.len; 820 len = cycle->prefix.len;
834 prefix = cycle->prefix.data; 821 prefix = cycle->prefix.data;
835 } 822 }
836 823
837 name->len = len + old.len; 824 #if (NGX_WIN32)
838 name->data = ngx_pnalloc(cycle->pool, name->len + 1); 825
839 if (name->data == NULL) { 826 if (rc == 2) {
827 len = rc;
828 }
829
830 #endif
831
832 n = ngx_pnalloc(cycle->pool, len + name->len + 1);
833 if (n == NULL) {
840 return NGX_ERROR; 834 return NGX_ERROR;
841 } 835 }
842 836
843 p = ngx_cpymem(name->data, prefix, len); 837 p = ngx_cpymem(n, prefix, len);
844 ngx_cpystrn(p, old.data, old.len + 1); 838 ngx_cpystrn(p, name->data, name->len + 1);
839
840 name->len += len;
841 name->data = n;
845 842
846 return NGX_OK; 843 return NGX_OK;
844 }
845
846
847 static ngx_int_t
848 ngx_conf_test_full_name(ngx_str_t *name)
849 {
850 #if (NGX_WIN32)
851 u_char c0, c1;
852
853 c0 = name->data[0];
854
855 if (name->len < 2) {
856 if (c0 == '/') {
857 return 2;
858 }
859
860 return NGX_DECLINED;
861 }
862
863 c1 = name->data[1];
864
865 if (c1 == ':') {
866 c0 |= 0x20;
867
868 if ((c0 >= 'a' && c0 <= 'z')) {
869 return NGX_OK;
870 }
871
872 return NGX_DECLINED;
873 }
874
875 if (c1 == '/') {
876 return NGX_OK;
877 }
878
879 if (c0 == '/') {
880 return 2;
881 }
882
883 return NGX_DECLINED;
884
885 #else
886
887 if (name->data[0] == '/') {
888 return NGX_OK;
889 }
890
891 return NGX_DECLINED;
892
893 #endif
847 } 894 }
848 895
849 896
850 ngx_open_file_t * 897 ngx_open_file_t *
851 ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) 898 ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)