Deleted
Added
nxt_conf_validation.c (180:3453139f9728) | nxt_conf_validation.c (216:07257705cd64) |
---|---|
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> | 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_application.h> |
|
9 10 11typedef struct { 12 nxt_str_t name; 13 nxt_uint_t type; 14 nxt_int_t (*validator)(nxt_conf_value_t *conf, nxt_conf_value_t *value, 15 void *data); 16 void *data; --- 191 unchanged lines hidden (view full) --- 208 return NXT_OK; 209} 210 211 212static nxt_int_t 213nxt_conf_vldt_app(nxt_conf_value_t *conf, nxt_str_t *name, 214 nxt_conf_value_t *value) 215{ | 10 11 12typedef struct { 13 nxt_str_t name; 14 nxt_uint_t type; 15 nxt_int_t (*validator)(nxt_conf_value_t *conf, nxt_conf_value_t *value, 16 void *data); 17 void *data; --- 191 unchanged lines hidden (view full) --- 209 return NXT_OK; 210} 211 212 213static nxt_int_t 214nxt_conf_vldt_app(nxt_conf_value_t *conf, nxt_str_t *name, 215 nxt_conf_value_t *value) 216{ |
216 nxt_str_t type; 217 nxt_conf_value_t *type_value; | 217 nxt_str_t type; 218 nxt_uint_t n; 219 nxt_thread_t *thread; 220 nxt_conf_value_t *type_value; 221 nxt_app_lang_module_t *lang; |
218 219 static nxt_str_t type_str = nxt_string("type"); 220 | 222 223 static nxt_str_t type_str = nxt_string("type"); 224 |
225 static void *members[] = { 226 nxt_conf_vldt_python_members, 227 nxt_conf_vldt_php_members, 228 nxt_conf_vldt_go_members, 229 }; 230 |
|
221 type_value = nxt_conf_get_object_member(value, &type_str, NULL); 222 223 if (nxt_slow_path(type_value == NULL)) { 224 return NXT_ERROR; 225 } 226 227 if (nxt_conf_type(type_value) != NXT_CONF_STRING) { 228 return NXT_ERROR; 229 } 230 231 nxt_conf_get_string(type_value, &type); 232 | 231 type_value = nxt_conf_get_object_member(value, &type_str, NULL); 232 233 if (nxt_slow_path(type_value == NULL)) { 234 return NXT_ERROR; 235 } 236 237 if (nxt_conf_type(type_value) != NXT_CONF_STRING) { 238 return NXT_ERROR; 239 } 240 241 nxt_conf_get_string(type_value, &type); 242 |
233 if (nxt_str_eq(&type, "python", 6)) { 234 return nxt_conf_vldt_object(conf, value, nxt_conf_vldt_python_members); 235 } | 243 thread = nxt_thread(); |
236 | 244 |
237 if (nxt_str_eq(&type, "php", 3)) { 238 return nxt_conf_vldt_object(conf, value, nxt_conf_vldt_php_members); | 245 lang = nxt_app_lang_module(thread->runtime, &type); 246 if (lang == NULL) { 247 return NXT_ERROR; |
239 } 240 | 248 } 249 |
241 if (nxt_str_eq(&type, "go", 2)) { 242 return nxt_conf_vldt_object(conf, value, nxt_conf_vldt_go_members); | 250 n = nxt_app_parse_type(&lang->type); 251 if (n != NXT_APP_UNKNOWN) { 252 return nxt_conf_vldt_object(conf, value, members[n]); |
243 } 244 245 return NXT_ERROR; 246} 247 248 249static nxt_int_t 250nxt_conf_vldt_object(nxt_conf_value_t *conf, nxt_conf_value_t *value, --- 68 unchanged lines hidden --- | 253 } 254 255 return NXT_ERROR; 256} 257 258 259static nxt_int_t 260nxt_conf_vldt_object(nxt_conf_value_t *conf, nxt_conf_value_t *value, --- 68 unchanged lines hidden --- |