Example #1
0
static mi_response_t *mi_list_root_path(const mi_params_t *params,
						struct mi_handler *async_hdl)
{
	mi_response_t *resp;
	mi_item_t *resp_arr;
	mi_item_t *root_item;
	struct httpd_cb *cb = httpd_cb_list;

	resp = init_mi_result_array(&resp_arr);
	if (!resp)
		return 0;

	while(cb) {
		root_item = add_mi_object(resp_arr, 0, 0);
		if (!root_item)
			goto error;

		if (add_mi_string(root_item, MI_SSTR("http_root"),
				cb->http_root->s, cb->http_root->len) < 0)
			goto error;

		if (add_mi_string(root_item, MI_SSTR("module"),
				(char*)cb->module, strlen(cb->module)) < 0)
			goto error;

		cb = cb->next;
	}

	return resp;

error:
	free_mi_response(resp);
	return 0;
}
Example #2
0
static mi_response_t *mi_b2be_list(const mi_params_t *params,
								struct mi_handler *async_hdl)
{
	mi_response_t *resp;
	mi_item_t *resp_arr;

	resp = init_mi_result_array(&resp_arr);
	if (!resp)
		return 0;

	if (server_htable)
		if (mi_print_b2be_dlg(resp_arr, server_htable, server_hsize)!=0)
			goto error;
	if (client_htable)
		if (mi_print_b2be_dlg(resp_arr, client_htable, client_hsize)!=0)
			goto error;

	return resp;
error:
	LM_ERR("Unable to create response\n");
	free_mi_response(resp);
	return NULL;
}
Example #3
0
mi_response_t *mi_sca_list(const mi_params_t *params,
								struct mi_handler *async_hdl)
{
	int i, index;
	b2b_sca_record_t *rec;
	b2b_sca_call_t *call;
	str_lst_t *watcher;
	mi_response_t *resp;
	mi_item_t *resp_arr;
	mi_item_t *resp_item, *watchers_arr, *apps_arr, *app_item;

	resp = init_mi_result_array(&resp_arr);
	if (!resp)
		return 0;

	for(index = 0; index<b2b_sca_hsize; index++) {
		lock_get(&b2b_sca_htable[index].lock);
		rec = b2b_sca_htable[index].first;
		while(rec) {
			resp_item = add_mi_object(resp_arr, NULL, 0);
			if (!resp_item)
				goto error;

			if (add_mi_string(resp_item, MI_SSTR("shared_line"),
				rec->shared_line.s, rec->shared_line.len) < 0)
				goto error;

			watchers_arr = add_mi_array(resp_item, MI_SSTR("watchers"));
			if (!watchers_arr)
				goto error;
			watcher = rec->watchers;
			while (watcher) {
				if (add_mi_string(watchers_arr, 0, 0,
					watcher->watcher.s, watcher->watcher.len) < 0)
					goto error;
				watcher = watcher->next;
			}

			apps_arr = add_mi_array(resp_item, MI_SSTR("appearances"));
			if (!apps_arr)
				goto error;
			for (i=0; i<MAX_APPEARANCE_INDEX; i++) {
				if (rec->call[i]) {
					call = rec->call[i];
					app_item = add_mi_object(apps_arr, NULL, 0);
					if (!app_item)
						goto error;

					if (add_mi_string(app_item, MI_SSTR("index"),
						call->appearance_index_str.s,
						call->appearance_index_str.len) < 0)
						goto error;

					if (add_mi_string(app_item, MI_SSTR("state"),
						app_state[call->call_state].s,
						app_state[call->call_state].len) < 0)
						goto error;

					if (add_mi_string(app_item, MI_SSTR("b2b_key"),
						call->b2bl_key.s, call->b2bl_key.len) < 0)
						goto error;

					if (add_mi_string(app_item, MI_SSTR("app_uri"),
						call->call_info_apperance_uri.s,
						call->call_info_apperance_uri.len) < 0)
						goto error;
				}
			}

			rec = rec->next;
		}
		lock_release(&b2b_sca_htable[index].lock);
	}

	return resp;

error:
	lock_release(&b2b_sca_htable[index].lock);
	LM_ERR("Unable to create reply\n");
	free_mi_response(resp);
	return NULL;
}