| 871 | } |
| 872 | |
| 873 | static mi_response_t *w_mi_list_stats_1(const mi_params_t *params, |
| 874 | struct mi_handler *async_hdl) |
| 875 | { |
| 876 | mi_response_t *resp; |
| 877 | mi_item_t *resp_obj; |
| 878 | mi_item_t *params_arr; |
| 879 | int i, no_params; |
| 880 | int found; |
| 881 | module_stats *mods; |
| 882 | stat_var *stat; |
| 883 | str val; |
| 884 | |
| 885 | resp = init_mi_result_object(&resp_obj); |
| 886 | if (!resp) |
| 887 | return 0; |
| 888 | |
| 889 | if (get_mi_array_param(params, "statistics", ¶ms_arr, &no_params) < 0) { |
| 890 | free_mi_response(resp); |
| 891 | return init_mi_param_error(); |
| 892 | } |
| 893 | |
| 894 | for (i = 0; i < no_params; i++) { |
| 895 | if (get_mi_arr_param_string(params_arr, i, &val.s, &val.len) < 0) { |
| 896 | free_mi_response(resp); |
| 897 | return init_mi_param_error(); |
| 898 | } |
| 899 | |
| 900 | if ( val.len>1 && val.s[val.len-1]==':') { |
| 901 | /* add module statistics */ |
| 902 | val.len--; |
| 903 | mods = get_stat_module( &val ); |
| 904 | if (mods==0) |
| 905 | continue; |
| 906 | if (mi_list_module_stats(resp_obj, mods)!=0) |
| 907 | goto error; |
| 908 | |
| 909 | found = 1; |
| 910 | } else { |
| 911 | /* add only one statistic */ |
| 912 | stat = get_stat( &val ); |
| 913 | if (stat==0) |
| 914 | continue; |
| 915 | if (mi_list_stat(resp_obj,NULL, stat)!=0) |
| 916 | goto error; |
| 917 | |
| 918 | found = 1; |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | if (!found) { |
| 923 | free_mi_response(resp); |
| 924 | return init_mi_error(404, MI_SSTR("Statistics Not Found")); |
| 925 | } |
| 926 | |
| 927 | return resp; |
| 928 | |
| 929 | error: |
| 930 | free_mi_response(resp); |
nothing calls this directly
no test coverage detected