comparison src/core/ngx_conf_file.c @ 156:afc333135a6b

nginx-0.0.1-2003-10-23-10:13:16 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 23 Oct 2003 06:13:16 +0000
parents 46eb23d9471d
children 70b36c805682
comparison
equal deleted inserted replaced
155:46eb23d9471d 156:afc333135a6b
544 char *p = conf; 544 char *p = conf;
545 545
546 int flag; 546 int flag;
547 ngx_str_t *value; 547 ngx_str_t *value;
548 548
549
549 if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { 550 if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
550 return "is duplicate"; 551 return "is duplicate";
551 } 552 }
552 553
553 value = (ngx_str_t *) cf->args->elts; 554 value = (ngx_str_t *) cf->args->elts;
594 595
595 char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 596 char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
596 { 597 {
597 char *p = conf; 598 char *p = conf;
598 599
599 int num, len; 600 int *np;
600 ngx_str_t *value; 601 ngx_str_t *value;
601 602
602 if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { 603
604 np = (int *) (p + cmd->offset);
605
606 if (*np != NGX_CONF_UNSET) {
603 return "is duplicate"; 607 return "is duplicate";
604 } 608 }
605 609
606 value = (ngx_str_t *) cf->args->elts; 610 value = (ngx_str_t *) cf->args->elts;
607 611 *np = ngx_atoi(value[1].data, value[1].len);
608 len = value[1].len; 612 if (*np == NGX_ERROR) {
609
610 num = ngx_atoi(value[1].data, len);
611 if (num == NGX_ERROR) {
612 return "invalid number"; 613 return "invalid number";
613 } 614 }
614 615
615 *(int *) (p + cmd->offset) = num; 616 if (cmd->bounds) {
617 return cmd->bounds->check(cf, cmd->bounds, np);
618 }
616 619
617 return NGX_CONF_OK; 620 return NGX_CONF_OK;
618 } 621 }
619 622
620 623
621 char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 624 char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
622 { 625 {
623 char *p = conf; 626 char *p = conf;
624 627
625 int size, len, scale; 628 int size, len, scale, *np;
626 char last; 629 char last;
627 ngx_str_t *value; 630 ngx_str_t *value;
628 631
629 if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { 632
633 np = (int *) (p + cmd->offset);
634
635 if (*np != NGX_CONF_UNSET) {
630 return "is duplicate"; 636 return "is duplicate";
631 } 637 }
632 638
633 value = (ngx_str_t *) cf->args->elts; 639 value = (ngx_str_t *) cf->args->elts;
634 640
656 if (size == NGX_ERROR) { 662 if (size == NGX_ERROR) {
657 return "invalid value"; 663 return "invalid value";
658 } 664 }
659 665
660 size *= scale; 666 size *= scale;
661 667 *np = size;
662 *(int *) (p + cmd->offset) = size; 668
669 if (cmd->bounds) {
670 return cmd->bounds->check(cf, cmd->bounds, np);
671 }
663 672
664 return NGX_CONF_OK; 673 return NGX_CONF_OK;
665 } 674 }
666 675
667 676
668 char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 677 char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
669 { 678 {
670 char *p = conf; 679 char *p = conf;
671 680
672 int size, total, len, scale; 681 int size, total, len, scale, *np;
673 u_int max, i; 682 u_int max, i;
674 char last, *start; 683 char last, *start;
675 ngx_str_t *value; 684 ngx_str_t *value;
676 685
677 if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { 686
687 np = (int *) (p + cmd->offset);
688
689 if (*np != NGX_CONF_UNSET) {
678 return "is duplicate"; 690 return "is duplicate";
679 } 691 }
680 692
681 value = (ngx_str_t *) cf->args->elts; 693 value = (ngx_str_t *) cf->args->elts;
682 start = value[1].data; 694 start = value[1].data;
754 766
755 len = 0; 767 len = 0;
756 start = &value[1].data[i + 1]; 768 start = &value[1].data[i + 1];
757 } 769 }
758 770
759 *(int *) (p + cmd->offset) = total; 771 *np = total;
772
773 if (cmd->bounds) {
774 return cmd->bounds->check(cf, cmd->bounds, np);
775 }
760 776
761 return NGX_CONF_OK; 777 return NGX_CONF_OK;
762 } 778 }
763 779
764 780
765 char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 781 char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
766 { 782 {
767 char *p = conf; 783 char *p = conf;
768 784
769 int size, total, len, scale; 785 int size, total, len, scale, *np;
770 u_int max, i; 786 u_int max, i;
771 char last, *start; 787 char last, *start;
772 ngx_str_t *value; 788 ngx_str_t *value;
773 789
774 if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { 790
791 np = (int *) (p + cmd->offset);
792
793 if (*np != NGX_CONF_UNSET) {
775 return "is duplicate"; 794 return "is duplicate";
776 } 795 }
777 796
778 value = (ngx_str_t *) cf->args->elts; 797 value = (ngx_str_t *) cf->args->elts;
779 start = value[1].data; 798 start = value[1].data;
863 882
864 len = 0; 883 len = 0;
865 start = &value[1].data[i + 1]; 884 start = &value[1].data[i + 1];
866 } 885 }
867 886
868 *(int *) (p + cmd->offset) = total; 887 *np = total;
888
889 if (cmd->bounds) {
890 return cmd->bounds->check(cf, cmd->bounds, np);
891 }
869 892
870 return NGX_CONF_OK; 893 return NGX_CONF_OK;
871 } 894 }
872 895
873 896
927 950
928 char *ngx_conf_unsupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 951 char *ngx_conf_unsupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
929 { 952 {
930 return "unsupported on this platform"; 953 return "unsupported on this platform";
931 } 954 }
955
956
957 char *ngx_conf_check_num_bounds(ngx_conf_t *cf, ngx_conf_bounds_t *bounds,
958 void *conf)
959 {
960 int *num = conf;
961
962 if (*num >= bounds->type.num.low && *num <= bounds->type.num.high) {
963 return NGX_CONF_OK;
964
965 }
966
967 return "invalid value";
968 }