asterisk/rest-api-templates/param_parsing.mustache

46 lines
1.2 KiB
Plaintext
Raw Normal View History

{{!
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2013, Digium, Inc.
*
* David M. Lee, II <dlee@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
}}
{{!
* Snippet for decoding parameters into an _args struct.
}}
struct ast_{{c_nickname}}_args args = {};
{{#has_parameters}}
struct ast_variable *i;
{{#has_query_parameters}}
for (i = get_params; i; i = i->next) {
{{#query_parameters}}
if (strcmp(i->name, "{{name}}") == 0) {
args.{{c_name}} = {{c_convert}}(i->value);
} else
{{/query_parameters}}
{}
}
{{/has_query_parameters}}
{{#has_path_parameters}}
for (i = path_vars; i; i = i->next) {
{{#path_parameters}}
if (strcmp(i->name, "{{name}}") == 0) {
args.{{c_name}} = {{c_convert}}(i->value);
} else
{{/path_parameters}}
{}
}
{{/has_path_parameters}}
{{/has_parameters}}