Deleted
Added
nxt_conf_validation.c (1432:f650ced3012a) | nxt_conf_validation.c (1439:32578e837322) |
---|---|
1 2/* 3 * Copyright (C) Valentin V. Bartenev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> 8#include <nxt_conf.h> 9#include <nxt_cert.h> 10#include <nxt_router.h> 11#include <nxt_http.h> 12#include <nxt_sockaddr.h> 13#include <nxt_http_route_addr.h> 14 15 16typedef enum { 17 NXT_CONF_VLDT_NULL = 1 << NXT_CONF_NULL, 18 NXT_CONF_VLDT_BOOLEAN = 1 << NXT_CONF_BOOLEAN, 19 NXT_CONF_VLDT_INTEGER = 1 << NXT_CONF_INTEGER, | 1 2/* 3 * Copyright (C) Valentin V. Bartenev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> 8#include <nxt_conf.h> 9#include <nxt_cert.h> 10#include <nxt_router.h> 11#include <nxt_http.h> 12#include <nxt_sockaddr.h> 13#include <nxt_http_route_addr.h> 14 15 16typedef enum { 17 NXT_CONF_VLDT_NULL = 1 << NXT_CONF_NULL, 18 NXT_CONF_VLDT_BOOLEAN = 1 << NXT_CONF_BOOLEAN, 19 NXT_CONF_VLDT_INTEGER = 1 << NXT_CONF_INTEGER, |
20 NXT_CONF_VLDT_NUMBER = 1 << NXT_CONF_NUMBER, | 20 NXT_CONF_VLDT_NUMBER = (1 << NXT_CONF_NUMBER) | NXT_CONF_VLDT_INTEGER, |
21 NXT_CONF_VLDT_STRING = 1 << NXT_CONF_STRING, 22 NXT_CONF_VLDT_ARRAY = 1 << NXT_CONF_ARRAY, 23 NXT_CONF_VLDT_OBJECT = 1 << NXT_CONF_OBJECT, 24} nxt_conf_vldt_type_t; 25 26 27typedef struct { 28 nxt_str_t name; --- 739 unchanged lines hidden (view full) --- 768 nxt_str_t expected; 769 nxt_bool_t serial; 770 nxt_uint_t value_type, n, t; 771 u_char buf[nxt_length(NXT_CONF_VLDT_ANY_TYPE)]; 772 773 static nxt_str_t type_name[] = { 774 nxt_string("a null"), 775 nxt_string("a boolean"), | 21 NXT_CONF_VLDT_STRING = 1 << NXT_CONF_STRING, 22 NXT_CONF_VLDT_ARRAY = 1 << NXT_CONF_ARRAY, 23 NXT_CONF_VLDT_OBJECT = 1 << NXT_CONF_OBJECT, 24} nxt_conf_vldt_type_t; 25 26 27typedef struct { 28 nxt_str_t name; --- 739 unchanged lines hidden (view full) --- 768 nxt_str_t expected; 769 nxt_bool_t serial; 770 nxt_uint_t value_type, n, t; 771 u_char buf[nxt_length(NXT_CONF_VLDT_ANY_TYPE)]; 772 773 static nxt_str_t type_name[] = { 774 nxt_string("a null"), 775 nxt_string("a boolean"), |
776 nxt_string("an integer"), 777 nxt_string("a number"), | 776 nxt_string("an integer number"), 777 nxt_string("a fractional number"), |
778 nxt_string("a string"), 779 nxt_string("an array"), 780 nxt_string("an object"), 781 }; 782 783 value_type = nxt_conf_type(value); 784 785 if ((1 << value_type) & type) { --- 347 unchanged lines hidden (view full) --- 1133 1134 1135static nxt_int_t 1136nxt_conf_vldt_return(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, 1137 void *data) 1138{ 1139 int64_t status; 1140 | 778 nxt_string("a string"), 779 nxt_string("an array"), 780 nxt_string("an object"), 781 }; 782 783 value_type = nxt_conf_type(value); 784 785 if ((1 << value_type) & type) { --- 347 unchanged lines hidden (view full) --- 1133 1134 1135static nxt_int_t 1136nxt_conf_vldt_return(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, 1137 void *data) 1138{ 1139 int64_t status; 1140 |
1141 status = nxt_conf_get_integer(value); | 1141 status = nxt_conf_get_number(value); |
1142 1143 if (status < NXT_HTTP_INVALID || status > NXT_HTTP_STATUS_MAX) { 1144 return nxt_conf_vldt_error(vldt, "The \"return\" value is out of " 1145 "allowed HTTP status code range 0-999."); 1146 } 1147 1148 return NXT_OK; 1149} --- 471 unchanged lines hidden (view full) --- 1621static nxt_int_t 1622nxt_conf_vldt_processes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, 1623 void *data) 1624{ 1625 int64_t int_value; 1626 nxt_int_t ret; 1627 nxt_conf_vldt_processes_conf_t proc; 1628 | 1142 1143 if (status < NXT_HTTP_INVALID || status > NXT_HTTP_STATUS_MAX) { 1144 return nxt_conf_vldt_error(vldt, "The \"return\" value is out of " 1145 "allowed HTTP status code range 0-999."); 1146 } 1147 1148 return NXT_OK; 1149} --- 471 unchanged lines hidden (view full) --- 1621static nxt_int_t 1622nxt_conf_vldt_processes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, 1623 void *data) 1624{ 1625 int64_t int_value; 1626 nxt_int_t ret; 1627 nxt_conf_vldt_processes_conf_t proc; 1628 |
1629 if (nxt_conf_type(value) == NXT_CONF_INTEGER) { 1630 int_value = nxt_conf_get_integer(value); | 1629 if (nxt_conf_type(value) == NXT_CONF_NUMBER) { 1630 int_value = nxt_conf_get_number(value); |
1631 1632 if (int_value < 1) { 1633 return nxt_conf_vldt_error(vldt, "The \"processes\" number must be " 1634 "equal to or greater than 1."); 1635 } 1636 1637 if (int_value > NXT_INT32_T_MAX) { 1638 return nxt_conf_vldt_error(vldt, "The \"processes\" number must " --- 418 unchanged lines hidden (view full) --- 2057 2058 2059static nxt_int_t 2060nxt_conf_vldt_server_weight(nxt_conf_validation_t *vldt, 2061 nxt_conf_value_t *value, void *data) 2062{ 2063 int64_t int_value; 2064 | 1631 1632 if (int_value < 1) { 1633 return nxt_conf_vldt_error(vldt, "The \"processes\" number must be " 1634 "equal to or greater than 1."); 1635 } 1636 1637 if (int_value > NXT_INT32_T_MAX) { 1638 return nxt_conf_vldt_error(vldt, "The \"processes\" number must " --- 418 unchanged lines hidden (view full) --- 2057 2058 2059static nxt_int_t 2060nxt_conf_vldt_server_weight(nxt_conf_validation_t *vldt, 2061 nxt_conf_value_t *value, void *data) 2062{ 2063 int64_t int_value; 2064 |
2065 int_value = nxt_conf_get_integer(value); | 2065 int_value = nxt_conf_get_number(value); |
2066 2067 if (int_value <= 0) { 2068 return nxt_conf_vldt_error(vldt, "The \"weight\" number must be " 2069 "greater than 0."); 2070 } 2071 2072 if (int_value > NXT_INT32_T_MAX) { 2073 return nxt_conf_vldt_error(vldt, "The \"weight\" number must " 2074 "not exceed %d.", NXT_INT32_T_MAX); 2075 } 2076 2077 return NXT_OK; 2078} | 2066 2067 if (int_value <= 0) { 2068 return nxt_conf_vldt_error(vldt, "The \"weight\" number must be " 2069 "greater than 0."); 2070 } 2071 2072 if (int_value > NXT_INT32_T_MAX) { 2073 return nxt_conf_vldt_error(vldt, "The \"weight\" number must " 2074 "not exceed %d.", NXT_INT32_T_MAX); 2075 } 2076 2077 return NXT_OK; 2078} |