nxt_conf_validation.c (1034:aebd59f82821) nxt_conf_validation.c (1059:11b44092759d)
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>

--- 52 unchanged lines hidden (view full) ---

61static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
62 nxt_str_t *name, nxt_conf_value_t *value);
63static nxt_int_t nxt_conf_vldt_route(nxt_conf_validation_t *vldt,
64 nxt_conf_value_t *value);
65static nxt_int_t nxt_conf_vldt_match_patterns(nxt_conf_validation_t *vldt,
66 nxt_conf_value_t *value, void *data);
67static nxt_int_t nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
68 nxt_conf_value_t *value);
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>

--- 52 unchanged lines hidden (view full) ---

61static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
62 nxt_str_t *name, nxt_conf_value_t *value);
63static nxt_int_t nxt_conf_vldt_route(nxt_conf_validation_t *vldt,
64 nxt_conf_value_t *value);
65static nxt_int_t nxt_conf_vldt_match_patterns(nxt_conf_validation_t *vldt,
66 nxt_conf_value_t *value, void *data);
67static nxt_int_t nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
68 nxt_conf_value_t *value);
69static nxt_int_t nxt_conf_vldt_match_patterns_sets(nxt_conf_validation_t *vldt,
70 nxt_conf_value_t *value, void *data);
71static nxt_int_t nxt_conf_vldt_match_patterns_set(nxt_conf_validation_t *vldt,
72 nxt_conf_value_t *value);
73static nxt_int_t nxt_conf_vldt_match_patterns_set_member(
74 nxt_conf_validation_t *vldt, nxt_str_t *name, nxt_conf_value_t *value);
69static nxt_int_t nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt,
70 nxt_conf_value_t *value, void *data);
71static nxt_int_t nxt_conf_vldt_app(nxt_conf_validation_t *vldt,
72 nxt_str_t *name, nxt_conf_value_t *value);
73static nxt_int_t nxt_conf_vldt_object(nxt_conf_validation_t *vldt,
74 nxt_conf_value_t *value, void *data);
75static nxt_int_t nxt_conf_vldt_processes(nxt_conf_validation_t *vldt,
76 nxt_conf_value_t *value, void *data);

--- 136 unchanged lines hidden (view full) ---

213 &nxt_conf_vldt_match_patterns,
214 NULL },
215
216 { nxt_string("uri"),
217 NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
218 &nxt_conf_vldt_match_patterns,
219 NULL },
220
75static nxt_int_t nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt,
76 nxt_conf_value_t *value, void *data);
77static nxt_int_t nxt_conf_vldt_app(nxt_conf_validation_t *vldt,
78 nxt_str_t *name, nxt_conf_value_t *value);
79static nxt_int_t nxt_conf_vldt_object(nxt_conf_validation_t *vldt,
80 nxt_conf_value_t *value, void *data);
81static nxt_int_t nxt_conf_vldt_processes(nxt_conf_validation_t *vldt,
82 nxt_conf_value_t *value, void *data);

--- 136 unchanged lines hidden (view full) ---

219 &nxt_conf_vldt_match_patterns,
220 NULL },
221
222 { nxt_string("uri"),
223 NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
224 &nxt_conf_vldt_match_patterns,
225 NULL },
226
227 { nxt_string("arguments"),
228 NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
229 &nxt_conf_vldt_match_patterns_sets,
230 NULL },
231
232 { nxt_string("headers"),
233 NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
234 &nxt_conf_vldt_match_patterns_sets,
235 NULL },
236
237 { nxt_string("cookies"),
238 NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
239 &nxt_conf_vldt_match_patterns_sets,
240 NULL },
241
221 NXT_CONF_VLDT_END
222};
223
224
225static nxt_conf_vldt_object_t nxt_conf_vldt_action_members[] = {
226 { nxt_string("pass"),
227 NXT_CONF_VLDT_STRING,
228 &nxt_conf_vldt_pass,

--- 514 unchanged lines hidden (view full) ---

743
744 enum {
745 sw_none,
746 sw_side,
747 sw_middle
748 } state;
749
750 if (nxt_conf_type(value) != NXT_CONF_STRING) {
242 NXT_CONF_VLDT_END
243};
244
245
246static nxt_conf_vldt_object_t nxt_conf_vldt_action_members[] = {
247 { nxt_string("pass"),
248 NXT_CONF_VLDT_STRING,
249 &nxt_conf_vldt_pass,

--- 514 unchanged lines hidden (view full) ---

764
765 enum {
766 sw_none,
767 sw_side,
768 sw_middle
769 } state;
770
771 if (nxt_conf_type(value) != NXT_CONF_STRING) {
751 return nxt_conf_vldt_error(vldt,
752 "The \"match\" patterns must be strings.");
772 return nxt_conf_vldt_error(vldt, "The \"match\" patterns for \"host\", "
773 "\"uri\", and \"method\" must be strings.");
753 }
754
755 nxt_conf_get_string(value, &pattern);
756
757 if (pattern.length == 0) {
758 return NXT_OK;
759 }
760

--- 32 unchanged lines hidden (view full) ---

793 "the sides or only one in the middle.");
794 }
795 }
796
797 return NXT_OK;
798}
799
800
774 }
775
776 nxt_conf_get_string(value, &pattern);
777
778 if (pattern.length == 0) {
779 return NXT_OK;
780 }
781

--- 32 unchanged lines hidden (view full) ---

814 "the sides or only one in the middle.");
815 }
816 }
817
818 return NXT_OK;
819}
820
821
822static nxt_int_t
823nxt_conf_vldt_match_patterns_sets(nxt_conf_validation_t *vldt,
824 nxt_conf_value_t *value, void *data)
825{
826 if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
827 return nxt_conf_vldt_array_iterator(vldt, value,
828 &nxt_conf_vldt_match_patterns_set);
829 }
830
831 /* NXT_CONF_OBJECT */
832
833 return nxt_conf_vldt_match_patterns_set(vldt, value);
834}
835
836
837static nxt_int_t
838nxt_conf_vldt_match_patterns_set(nxt_conf_validation_t *vldt,
839 nxt_conf_value_t *value)
840{
841 if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
842 return nxt_conf_vldt_error(vldt, "The \"match\" patterns for "
843 "\"arguments\", \"cookies\", and "
844 "\"headers\" must be objects.");
845 }
846
847 return nxt_conf_vldt_object_iterator(vldt, value,
848 &nxt_conf_vldt_match_patterns_set_member);
849}
850
851
852static nxt_int_t
853nxt_conf_vldt_match_patterns_set_member(nxt_conf_validation_t *vldt,
854 nxt_str_t *name, nxt_conf_value_t *value)
855{
856 if (name->length == 0) {
857 return nxt_conf_vldt_error(vldt, "The \"match\" pattern objects must "
858 "not contain empty member names.");
859 }
860
861 return nxt_conf_vldt_match_patterns(vldt, value, NULL);
862}
863
864
801#if (NXT_TLS)
802
803static nxt_int_t
804nxt_conf_vldt_certificate(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
805 void *data)
806{
807 nxt_str_t name;
808 nxt_conf_value_t *cert;

--- 508 unchanged lines hidden ---
865#if (NXT_TLS)
866
867static nxt_int_t
868nxt_conf_vldt_certificate(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
869 void *data)
870{
871 nxt_str_t name;
872 nxt_conf_value_t *cert;

--- 508 unchanged lines hidden ---