本文整理汇总了C++中MI_SSTR函数的典型用法代码示例。如果您正苦于以下问题:C++ MI_SSTR函数的具体用法?C++ MI_SSTR怎么用?C++ MI_SSTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MI_SSTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_mi_tree
struct mi_root *mi_set_shtag_active(struct mi_root *cmd_tree, void *param)
{
struct mi_node* node;
struct dlg_sharing_tag *tag;
if (!dialog_repl_cluster)
return init_mi_tree(400, MI_SSTR("Dialog replication disabled"));
node = cmd_tree->node.kids;
if (node == NULL || !node->value.s || !node->value.len)
return init_mi_tree(400, MI_SSTR(MI_MISSING_PARM));
lock_start_write(shtags_lock);
if ((tag = get_shtag_unsafe(&node->value)) == NULL)
return init_mi_tree(500, MI_SSTR("Unable to set sharing tag"));
tag->state = SHTAG_STATE_ACTIVE;
lock_stop_write(shtags_lock);
if (send_shtag_active_info(&node->value, 0) < 0)
LM_WARN("Failed to broadcast message about tag [%.*s] going active\n",
node->value.len, node->value.s);
return init_mi_tree( 200, MI_SSTR(MI_OK));
}
示例2: init_mi_tree
static struct mi_root *mi_debug(struct mi_root *cmd, void *param)
{
struct mi_root *rpl_tree;
struct mi_node *node;
char *p;
int len;
int new_debug;
node = cmd->node.kids;
if (node!=NULL) {
if (str2sint( &node->value, &new_debug) < 0)
return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM));
} else
new_debug = debug;
rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK));
if (rpl_tree==0)
return 0;
p = sint2str((long)new_debug, &len);
node = add_mi_node_child( &rpl_tree->node, MI_DUP_VALUE,
MI_SSTR("DEBUG"),p, len);
if (node==0) {
free_mi_tree(rpl_tree);
return 0;
}
debug = new_debug;
return rpl_tree;
}
示例3: clusterer_set_status
static struct mi_root* clusterer_set_status(struct mi_root *cmd, void *param)
{
unsigned int cluster_id;
unsigned int state;
int rc;
struct mi_node *node;
node = cmd->node.kids;
if (node == NULL || node->next == NULL || node->next->next != NULL)
return init_mi_tree(400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
rc = str2int(&node->value, &cluster_id);
if (rc < 0 || cluster_id < 1)
return init_mi_tree(400, MI_SSTR(MI_BAD_PARM));
rc = str2int(&node->next->value, &state);
if (rc < 0 || (state != STATE_DISABLED && state != STATE_ENABLED))
return init_mi_tree(400, MI_SSTR(MI_BAD_PARM));
rc = cl_set_state(cluster_id, state);
if (rc == -1)
return init_mi_tree(404, "Cluster id not found", 20);
if (rc == 1)
return init_mi_tree(404, "Node id not found", 17);
return init_mi_tree(200, MI_SSTR(MI_OK));
}
示例4: init_mi_param_error
static mi_response_t *clusterer_set_status(const mi_params_t *params,
struct mi_handler *async_hdl)
{
int cluster_id;
int state;
int rc;
if (get_mi_int_param(params, "cluster_id", &cluster_id) < 0)
return init_mi_param_error();
if (cluster_id < 1)
return init_mi_error(400, MI_SSTR("Bad value for 'cluster_id'"));
if (get_mi_int_param(params, "status", &state) < 0)
return init_mi_param_error();
if (state != STATE_DISABLED && state != STATE_ENABLED)
return init_mi_error(400, MI_SSTR("Bad value for 'status'"));
rc = cl_set_state(cluster_id, state);
if (rc == -1)
return init_mi_error(404, MI_SSTR("Cluster id not found"));
if (rc == 1)
return init_mi_error(404, MI_SSTR("Node id not found"));
return init_mi_result_ok();
}
示例5: mi_sync_db_dlg
struct mi_root* mi_sync_db_dlg(struct mi_root *cmd, void *param)
{
if (sync_dlg_db_mem() < 0)
return init_mi_tree( 400, MI_SSTR("Sync mem with DB failed"));
else
return init_mi_tree( 200, MI_SSTR(MI_OK));
}
示例6: init_mi_result_array
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;
}
示例7: mi_address_reload
/*! \brief
* MI function to reload address table
*/
struct mi_root* mi_address_reload(struct mi_root *cmd_tree, void *param)
{
if (reload_address_table_cmd () == 1) {
return init_mi_tree( 200, MI_SSTR(MI_OK));
} else {
return init_mi_tree( 400, MI_SSTR("Address table reload failed"));
}
}
示例8: mi_lb_resize
static struct mi_root* mi_lb_resize(struct mi_root *cmd, void *param)
{
struct mi_root *rpl_tree;
struct lb_dst *dst;
struct mi_node *node;
unsigned int id, size;
str *name;
int n;
for( n=0,node = cmd->node.kids; n<3 && node ; n++,node=node->next );
if (n!=3 || node!=0)
return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
node = cmd->node.kids;
/* id (param 1) */
if (str2int( &node->value, &id) < 0)
goto bad_syntax;
/* resource (param 2) */
node = node->next;
name = &node->value;
/* id (param 3) */
node = node->next;
if (str2int( &node->value, &size) < 0)
goto bad_syntax;
lock_start_read( ref_lock );
/* get destination */
for( dst=(*curr_data)->dsts ; dst && dst->id!=id ; dst=dst->next);
if (dst==NULL) {
rpl_tree = init_mi_tree( 404, MI_SSTR("Destination ID not found"));
} else {
/* get resource */
for( n=0 ; n<dst->rmap_no ; n++)
if (dst->rmap[n].resource->name.len == name->len &&
memcmp( dst->rmap[n].resource->name.s, name->s, name->len)==0)
break;
if (n==dst->rmap_no) {
rpl_tree = init_mi_tree( 404,
MI_SSTR("Destination has no such resource"));
} else {
dst->rmap[n].max_load = size;
rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK_S));
}
}
lock_stop_read( ref_lock );
return rpl_tree;
bad_syntax:
return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM_S));
}
示例9: mi_sync_cl_dlg
struct mi_root* mi_sync_cl_dlg(struct mi_root *cmd, void *param)
{
if (!dialog_repl_cluster)
return init_mi_tree(400, MI_SSTR("Dialog replication disabled"));
if (clusterer_api.request_sync(&dlg_repl_cap, dialog_repl_cluster, 1) < 0)
return init_mi_tree(400, MI_SSTR("Failed to send sync request"));
else
return init_mi_tree(200, MI_SSTR(MI_OK));
}
示例10: LM_ERR
struct mi_root *mi_help(struct mi_root *root, void *param)
{
struct mi_root *rpl_tree = 0;
struct mi_node *node;
struct mi_node *rpl;
struct mi_cmd *cmd;
if (!root) {
LM_ERR("invalid MI command\n");
return 0;
}
node = root->node.kids;
if (!node || !node->value.len || !node->value.s) {
rpl_tree = init_mi_tree(200, MI_SSTR(MI_OK));
if (!rpl_tree) {
LM_ERR("cannot init mi tree\n");
return 0;
}
rpl = &rpl_tree->node;
if (!add_mi_node_child(rpl, 0, "Usage", 5, MI_SSTR(MI_HELP_STR))) {
LM_ERR("cannot add new child\n");
goto error;
}
} else {
/* search the command */
cmd = lookup_mi_cmd(node->value.s, node->value.len);
if (!cmd)
return init_mi_tree(404, MI_SSTR(MI_UNKNOWN_CMD));
rpl_tree = init_mi_tree(200, MI_SSTR(MI_OK));
if (!rpl_tree) {
LM_ERR("cannot init mi tree\n");
return 0;
}
rpl = &rpl_tree->node;
if (!addf_mi_node_child(rpl, 0, "Help", 4, "%s", cmd->help.s ?
cmd->help.s : MI_NO_HELP)) {
LM_ERR("cannot add new child\n");
goto error;
}
if (cmd->module.len && cmd->module.s &&
!add_mi_node_child(rpl, 0, "Exported by", 11,
cmd->module.s, cmd->module.len)) {
LM_ERR("cannot add new child\n");
goto error;
}
}
return rpl_tree;
error:
if (rpl_tree)
free_mi_tree(rpl_tree);
return 0;
}
示例11: process_mi_params
static inline struct mi_root* process_mi_params(struct mi_root *cmd_tree,
struct dlg_cell **dlg_p)
{
struct mi_node* node;
struct dlg_entry *d_entry;
struct dlg_cell *dlg;
str *callid;
str *from_tag;
unsigned int h_entry;
node = cmd_tree->node.kids;
if (node == NULL) {
/* no parameters at all */
*dlg_p = NULL;
return NULL;
}
/* we have params -> get callid and fromtag */
callid = &node->value;
if(callid->s==NULL || callid->len<=0)
return init_mi_tree(400, MI_SSTR(MI_MISSING_PARM));
LM_DBG("callid='%.*s'\n", callid->len, callid->s);
node = node->next;
if ( !node || !node->value.s || !node->value.len) {
from_tag = NULL;
} else {
from_tag = &node->value;
LM_DBG("from_tag='%.*s'\n", from_tag->len, from_tag->s);
if ( node->next!=NULL )
return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM));
}
h_entry = core_hash( callid, 0, d_table->size);
d_entry = &(d_table->entries[h_entry]);
dlg_lock( d_table, d_entry);
for( dlg = d_entry->first ; dlg ; dlg = dlg->next ) {
if (match_downstream_dialog( dlg, callid, from_tag)==1) {
if (dlg->state==DLG_STATE_DELETED) {
*dlg_p = NULL;
break;
} else {
*dlg_p = dlg;
dlg_unlock( d_table, d_entry);
return 0;
}
}
}
dlg_unlock( d_table, d_entry);
return init_mi_tree( 404, MI_SSTR("Nu such dialog"));
}
示例12: mi_agent_login
/* FORMAT : agent_id log_state */
static struct mi_root* mi_agent_login(struct mi_root *cmd_tree, void *param)
{
struct mi_node *node;
struct cc_agent *agent;
unsigned int loged_in;
struct cc_agent* prev_agent= 0;
node = cmd_tree->node.kids;
if (node==NULL || node->next==NULL || node->next->next!=NULL)
return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
/* block access to data */
lock_get( data->lock );
/* name of the agent */
agent = get_agent_by_name( data, &node->value, &prev_agent);
if (agent==NULL) {
lock_release( data->lock );
return init_mi_tree( 404, MI_SSTR("Agent not found") );
}
/* login state */
node = node->next;
if (str2int( &node->value , &loged_in)!=0 ) {
lock_release( data->lock );
return init_mi_tree( 400, MI_SSTR("Bad loged_in state") );
}
if (agent->loged_in != loged_in) {
if(loged_in && (agent->state==CC_AGENT_WRAPUP) &&
(get_ticks() - agent->last_call_end > wrapup_time))
agent->state = CC_AGENT_FREE;
if(loged_in && data->agents[CC_AG_ONLINE] == NULL)
data->last_online_agent = agent;
agent_switch_login(data, agent, prev_agent);
if(loged_in) {
data->logedin_agents++;
log_agent_to_flows( data, agent, 1);
} else {
data->logedin_agents--;
log_agent_to_flows(data, agent, 0);
}
}
/* release the readers */
lock_release( data->lock );
return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
}
示例13: internal_mi_print_b2bl_entity_id
static inline int internal_mi_print_b2bl_entity_id(mi_item_t *item, b2bl_entity_id_t *c)
{
if (c->scenario_id.s && c->scenario_id.len != 0)
if (add_mi_string(item, MI_SSTR("scenario_id"),
c->scenario_id.s, c->scenario_id.len) < 0)
goto error;
if (c->key.s && c->key.len != 0)
if (add_mi_string(item, MI_SSTR("key"),
c->key.s, c->key.len) < 0)
goto error;
if (add_mi_number(item, MI_SSTR("disconnected"),
c->disconnected) < 0)
goto error;
if (add_mi_number(item, MI_SSTR("state"),
c->state) < 0)
goto error;
if (add_mi_number(item, MI_SSTR("no"),
c->no) < 0)
goto error;
if (add_mi_number(item, MI_SSTR("type"),
c->type) < 0)
goto error;
if (c->peer)
{
if (c->peer->key.s && c->peer->key.len != 0)
if (add_mi_string(item, MI_SSTR("peer"),
c->peer->key.s, c->peer->key.len) < 0)
goto error;
}
if (c->to_uri.s && c->to_uri.len != 0)
if (add_mi_string(item, MI_SSTR("to_uri"),
c->to_uri.s, c->to_uri.len) < 0)
goto error;
if (c->from_uri.s && c->from_uri.len != 0)
if (add_mi_string(item, MI_SSTR("from_uri"),
c->from_uri.s, c->from_uri.len) < 0)
goto error;
if (c->from_dname.s && c->from_dname.len != 0)
if (add_mi_string(item, MI_SSTR("from_dname"),
c->from_dname.s, c->from_dname.len) < 0)
goto error;
return 0;
error:
LM_ERR("failed to add mi item\n");
return -1;
}
示例14: mi_trusted_reload
/*
* MI function to reload trusted table
*/
struct mi_root* mi_trusted_reload(struct mi_root *cmd_tree, void *param)
{
if (hash_table==NULL) {
return init_mi_tree( 200, MI_SSTR(MI_OK));
}
if (reload_trusted_table () == 1) {
return init_mi_tree( 200, MI_SSTR(MI_OK));
} else {
return init_mi_tree( 400, MI_SSTR("Trusted table reload failed"));
}
}
示例15: cluster_send_mi
static struct mi_root* cluster_send_mi(struct mi_root *cmd, void *param)
{
struct mi_node *node, *cmd_params_n;
unsigned int cluster_id, node_id;
int rc;
str cl_cmd_name;
str cl_cmd_params[MI_CMD_MAX_NR_PARAMS];
int no_params = 0;
node = cmd->node.kids;
if (node == NULL || node->next == NULL || node->next->next == NULL)
return init_mi_tree(400, MI_SSTR(MI_MISSING_PARM));
rc = str2int(&node->value, &cluster_id);
if (rc < 0 || cluster_id < 1)
return init_mi_tree(400, MI_SSTR(MI_BAD_PARM));
rc = str2int(&node->next->value, &node_id);
if (rc < 0 || node_id < 1)
return init_mi_tree(400, MI_SSTR(MI_BAD_PARM));
if (node_id == current_id)
return init_mi_tree(400, MI_SSTR("Local node specified as destination"));
cl_cmd_name = node->next->next->value;
cmd_params_n = node->next->next->next;
for (; cmd_params_n; cmd_params_n = cmd_params_n->next, no_params++)
cl_cmd_params[no_params] = cmd_params_n->value;
/* send MI cmd in cluster */
rc = send_mi_cmd(cluster_id, node_id, cl_cmd_name, cl_cmd_params, no_params);
switch (rc) {
case CLUSTERER_SEND_SUCCES:
LM_DBG("MI command <%.*s> sent\n", cl_cmd_name.len, cl_cmd_name.s);
break;
case CLUSTERER_CURR_DISABLED:
LM_INFO("Local node disabled, MI command <%.*s> not sent\n",
cl_cmd_name.len, cl_cmd_name.s);
break;
case CLUSTERER_DEST_DOWN:
LM_ERR("Destination down, MI command <%.*s> not sent\n",
cl_cmd_name.len, cl_cmd_name.s);
break;
case CLUSTERER_SEND_ERR:
LM_ERR("Error sending MI command <%.*s>+\n",
cl_cmd_name.len, cl_cmd_name.s);
break;
}
return init_mi_tree(200, MI_SSTR(MI_OK));
}