Merged revisions 49676 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49676 | kpfleming | 2007-01-05 16:16:33 -0600 (Fri, 05 Jan 2007) | 2 lines reduce stack consumption for AMI and AMI/HTTP requests by nearly 20K in most cases ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@49678 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
e37f8f077a
commit
d8e7fcf209
|
@ -2773,12 +2773,12 @@ static int admin_exec(struct ast_channel *chan, void *data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int meetmemute(struct mansession *s, struct message *m, int mute)
|
||||
static int meetmemute(struct mansession *s, const struct message *m, int mute)
|
||||
{
|
||||
struct ast_conference *conf;
|
||||
struct ast_conf_user *user;
|
||||
char *confid = astman_get_header(m, "Meetme");
|
||||
char *userid = astman_get_header(m, "Usernum");
|
||||
const char *confid = astman_get_header(m, "Meetme");
|
||||
char *userid = ast_strdupa(astman_get_header(m, "Usernum"));
|
||||
int userno;
|
||||
|
||||
if (ast_strlen_zero(confid)) {
|
||||
|
@ -2834,12 +2834,12 @@ static int meetmemute(struct mansession *s, struct message *m, int mute)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int action_meetmemute(struct mansession *s, struct message *m)
|
||||
static int action_meetmemute(struct mansession *s, const struct message *m)
|
||||
{
|
||||
return meetmemute(s, m, 1);
|
||||
}
|
||||
|
||||
static int action_meetmeunmute(struct mansession *s, struct message *m)
|
||||
static int action_meetmeunmute(struct mansession *s, const struct message *m)
|
||||
{
|
||||
return meetmemute(s, m, 0);
|
||||
}
|
||||
|
|
|
@ -408,7 +408,7 @@ struct call_queue {
|
|||
|
||||
static AST_LIST_HEAD_STATIC(queues, call_queue);
|
||||
|
||||
static int set_member_paused(char *queuename, char *interface, int paused);
|
||||
static int set_member_paused(const char *queuename, const char *interface, int paused);
|
||||
|
||||
static void set_queue_result(struct ast_channel *chan, enum queue_result res)
|
||||
{
|
||||
|
@ -635,7 +635,7 @@ static int statechange_queue(const char *dev, int state, void *ign)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct member *create_queue_member(char *interface, const char *membername, int penalty, int paused)
|
||||
static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused)
|
||||
{
|
||||
struct member *cur;
|
||||
|
||||
|
@ -711,7 +711,7 @@ static void clear_queue(struct call_queue *q)
|
|||
q->wrapuptime = 0;
|
||||
}
|
||||
|
||||
static int add_to_interfaces(char *interface)
|
||||
static int add_to_interfaces(const char *interface)
|
||||
{
|
||||
struct member_interface *curint;
|
||||
|
||||
|
@ -738,7 +738,7 @@ static int add_to_interfaces(char *interface)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int interface_exists_global(char *interface)
|
||||
static int interface_exists_global(const char *interface)
|
||||
{
|
||||
struct call_queue *q;
|
||||
struct member *mem;
|
||||
|
@ -760,7 +760,7 @@ static int interface_exists_global(char *interface)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int remove_from_interfaces(char *interface)
|
||||
static int remove_from_interfaces(const char *interface)
|
||||
{
|
||||
struct member_interface *curint;
|
||||
|
||||
|
@ -1133,7 +1133,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
|
|||
return q;
|
||||
}
|
||||
|
||||
static struct call_queue *load_realtime_queue(char *queuename)
|
||||
static struct call_queue *load_realtime_queue(const char *queuename)
|
||||
{
|
||||
struct ast_variable *queue_vars;
|
||||
struct ast_config *member_config = NULL;
|
||||
|
@ -2781,7 +2781,7 @@ static int wait_a_bit(struct queue_ent *qe)
|
|||
return ast_waitfordigit(qe->chan, retrywait);
|
||||
}
|
||||
|
||||
static struct member *interface_exists(struct call_queue *q, char *interface)
|
||||
static struct member *interface_exists(struct call_queue *q, const char *interface)
|
||||
{
|
||||
struct member *mem;
|
||||
|
||||
|
@ -2836,7 +2836,7 @@ static void dump_queue_members(struct call_queue *pm_queue)
|
|||
ast_db_del(pm_family, pm_queue->name);
|
||||
}
|
||||
|
||||
static int remove_from_queue(char *queuename, char *interface)
|
||||
static int remove_from_queue(const char *queuename, const char *interface)
|
||||
{
|
||||
struct call_queue *q;
|
||||
struct member *last_member, *look;
|
||||
|
@ -2890,7 +2890,7 @@ static int remove_from_queue(char *queuename, char *interface)
|
|||
}
|
||||
|
||||
|
||||
static int add_to_queue(char *queuename, char *interface, char *membername, int penalty, int paused, int dump)
|
||||
static int add_to_queue(const char *queuename, const char *interface, const char *membername, int penalty, int paused, int dump)
|
||||
{
|
||||
struct call_queue *q;
|
||||
struct member *new_member;
|
||||
|
@ -2941,7 +2941,7 @@ static int add_to_queue(char *queuename, char *interface, char *membername, int
|
|||
return res;
|
||||
}
|
||||
|
||||
static int set_member_paused(char *queuename, char *interface, int paused)
|
||||
static int set_member_paused(const char *queuename, const char *interface, int paused)
|
||||
{
|
||||
int found = 0;
|
||||
struct call_queue *q;
|
||||
|
@ -4162,7 +4162,7 @@ static char *complete_queue(const char *line, const char *word, int pos, int sta
|
|||
/*!\brief callback to display queues status in manager
|
||||
\addtogroup Group_AMI
|
||||
*/
|
||||
static int manager_queues_show( struct mansession *s, struct message *m )
|
||||
static int manager_queues_show(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *a[] = { "queue", "show" };
|
||||
|
||||
|
@ -4173,14 +4173,14 @@ static int manager_queues_show( struct mansession *s, struct message *m )
|
|||
}
|
||||
|
||||
/* Dump summary of queue info */
|
||||
static int manager_queues_summary(struct mansession *s, struct message *m)
|
||||
static int manager_queues_summary(struct mansession *s, const struct message *m)
|
||||
{
|
||||
time_t now;
|
||||
int qmemcount = 0;
|
||||
int qmemavail = 0;
|
||||
int qchancount = 0;
|
||||
char *id = astman_get_header(m, "ActionID");
|
||||
char *queuefilter = astman_get_header(m, "Queue");
|
||||
const char *id = astman_get_header(m, "ActionID");
|
||||
const char *queuefilter = astman_get_header(m, "Queue");
|
||||
char idText[256] = "";
|
||||
struct call_queue *q;
|
||||
struct queue_ent *qe;
|
||||
|
@ -4231,13 +4231,13 @@ static int manager_queues_summary(struct mansession *s, struct message *m)
|
|||
}
|
||||
|
||||
/* Dump queue status */
|
||||
static int manager_queues_status(struct mansession *s, struct message *m)
|
||||
static int manager_queues_status(struct mansession *s, const struct message *m)
|
||||
{
|
||||
time_t now;
|
||||
int pos;
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
char *queuefilter = astman_get_header(m,"Queue");
|
||||
char *memberfilter = astman_get_header(m,"Member");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
const char *queuefilter = astman_get_header(m,"Queue");
|
||||
const char *memberfilter = astman_get_header(m,"Member");
|
||||
char idText[256] = "";
|
||||
struct call_queue *q;
|
||||
struct queue_ent *qe;
|
||||
|
@ -4322,9 +4322,9 @@ static int manager_queues_status(struct mansession *s, struct message *m)
|
|||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static int manager_add_queue_member(struct mansession *s, struct message *m)
|
||||
static int manager_add_queue_member(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *queuename, *interface, *penalty_s, *paused_s, *membername;
|
||||
const char *queuename, *interface, *penalty_s, *paused_s, *membername;
|
||||
int paused, penalty = 0;
|
||||
|
||||
queuename = astman_get_header(m, "Queue");
|
||||
|
@ -4375,9 +4375,9 @@ static int manager_add_queue_member(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int manager_remove_queue_member(struct mansession *s, struct message *m)
|
||||
static int manager_remove_queue_member(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *queuename, *interface;
|
||||
const char *queuename, *interface;
|
||||
|
||||
queuename = astman_get_header(m, "Queue");
|
||||
interface = astman_get_header(m, "Interface");
|
||||
|
@ -4406,9 +4406,9 @@ static int manager_remove_queue_member(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int manager_pause_queue_member(struct mansession *s, struct message *m)
|
||||
static int manager_pause_queue_member(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *queuename, *interface, *paused_s;
|
||||
const char *queuename, *interface, *paused_s;
|
||||
int paused;
|
||||
|
||||
interface = astman_get_header(m, "Interface");
|
||||
|
@ -4429,9 +4429,9 @@ static int manager_pause_queue_member(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int manager_queue_log_custom(struct mansession *s, struct message *m)
|
||||
static int manager_queue_log_custom(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *queuename, *event, *message, *interface, *uniqueid;
|
||||
const char *queuename, *event, *message, *interface, *uniqueid;
|
||||
|
||||
queuename = astman_get_header(m, "Queue");
|
||||
uniqueid = astman_get_header(m, "UniqueId");
|
||||
|
|
|
@ -94,10 +94,10 @@ static char mandescr_playdtmf[] =
|
|||
" Channel: Channel name to send digit to\n"
|
||||
" Digit: The dtmf digit to play\n";
|
||||
|
||||
static int manager_play_dtmf(struct mansession *s, struct message *m)
|
||||
static int manager_play_dtmf(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *channel = astman_get_header(m, "Channel");
|
||||
char *digit = astman_get_header(m, "Digit");
|
||||
const char *channel = astman_get_header(m, "Channel");
|
||||
const char *digit = astman_get_header(m, "Digit");
|
||||
struct ast_channel *chan = ast_get_channel_by_name_locked(channel);
|
||||
|
||||
if (!chan) {
|
||||
|
|
|
@ -1389,9 +1389,9 @@ static force_inline int powerof(unsigned int d)
|
|||
* \returns
|
||||
* \sa action_agent_logoff(), action_agent_callback_login(), load_module().
|
||||
*/
|
||||
static int action_agents(struct mansession *s, struct message *m)
|
||||
static int action_agents(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
char idText[256] = "";
|
||||
char chanbuf[256];
|
||||
struct agent_pvt *p;
|
||||
|
@ -1499,7 +1499,7 @@ static void agent_logoff_maintenance(struct agent_pvt *p, char *loginchan, long
|
|||
|
||||
}
|
||||
|
||||
static int agent_logoff(char *agent, int soft)
|
||||
static int agent_logoff(const char *agent, int soft)
|
||||
{
|
||||
struct agent_pvt *p;
|
||||
long logintime;
|
||||
|
@ -1550,10 +1550,10 @@ static int agent_logoff_cmd(int fd, int argc, char **argv)
|
|||
* \returns
|
||||
* \sa action_agents(), action_agent_callback_login(), load_module().
|
||||
*/
|
||||
static int action_agent_logoff(struct mansession *s, struct message *m)
|
||||
static int action_agent_logoff(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *agent = astman_get_header(m, "Agent");
|
||||
char *soft_s = astman_get_header(m, "Soft"); /* "true" is don't hangup */
|
||||
const char *agent = astman_get_header(m, "Agent");
|
||||
const char *soft_s = astman_get_header(m, "Soft"); /* "true" is don't hangup */
|
||||
int soft;
|
||||
int ret; /* return value of agent_logoff */
|
||||
|
||||
|
|
|
@ -4289,7 +4289,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
|
|||
{
|
||||
return __iax2_show_peers(0, fd, NULL, argc, argv);
|
||||
}
|
||||
static int manager_iax2_show_netstats( struct mansession *s, struct message *m )
|
||||
static int manager_iax2_show_netstats(struct mansession *s, const struct message *m)
|
||||
{
|
||||
ast_cli_netstats(s, -1, 0);
|
||||
astman_append(s, "\r\n");
|
||||
|
@ -4317,12 +4317,12 @@ static int iax2_show_firmware(int fd, int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* JDG: callback to display iax peers in manager */
|
||||
static int manager_iax2_show_peers( struct mansession *s, struct message *m )
|
||||
static int manager_iax2_show_peers(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *a[] = { "iax2", "show", "users" };
|
||||
int ret;
|
||||
char *id;
|
||||
id = astman_get_header(m,"ActionID");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
|
||||
if (!ast_strlen_zero(id))
|
||||
astman_append(s, "ActionID: %s\r\n",id);
|
||||
ret = __iax2_show_peers(1, -1, s, 3, a );
|
||||
|
|
|
@ -1356,8 +1356,7 @@ static char *transfermode2str(enum transfermodes mode) attribute_const;
|
|||
static char *nat2str(int nat) attribute_const;
|
||||
static int peer_status(struct sip_peer *peer, char *status, int statuslen);
|
||||
static int sip_show_users(int fd, int argc, char *argv[]);
|
||||
static int _sip_show_peers(int fd, int *total, struct mansession *s, struct message *m, int argc, char *argv[]);
|
||||
static int manager_sip_show_peers( struct mansession *s, struct message *m );
|
||||
static int _sip_show_peers(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[]);
|
||||
static int sip_show_peers(int fd, int argc, char *argv[]);
|
||||
static int sip_show_objects(int fd, int argc, char *argv[]);
|
||||
static void print_group(int fd, ast_group_t group, int crlf);
|
||||
|
@ -1367,10 +1366,8 @@ static void cleanup_stale_contexts(char *new, char *old);
|
|||
static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
|
||||
static const char *domain_mode_to_text(const enum domain_mode mode);
|
||||
static int sip_show_domains(int fd, int argc, char *argv[]);
|
||||
static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[]);
|
||||
static int manager_sip_show_peer( struct mansession *s, struct message *m);
|
||||
static int _sip_show_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[]);
|
||||
static int sip_show_peer(int fd, int argc, char *argv[]);
|
||||
static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[]);
|
||||
static int sip_show_user(int fd, int argc, char *argv[]);
|
||||
static int sip_show_registry(int fd, int argc, char *argv[]);
|
||||
static int sip_show_settings(int fd, int argc, char *argv[]);
|
||||
|
@ -9614,10 +9611,10 @@ static char mandescr_show_peers[] =
|
|||
|
||||
/*! \brief Show SIP peers in the manager API */
|
||||
/* Inspired from chan_iax2 */
|
||||
static int manager_sip_show_peers( struct mansession *s, struct message *m )
|
||||
static int manager_sip_show_peers(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
char *a[] = { "sip", "show", "peers" };
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
const char *a[] = {"sip", "show", "peers"};
|
||||
char idtext[256] = "";
|
||||
int total = 0;
|
||||
|
||||
|
@ -9640,11 +9637,11 @@ static int manager_sip_show_peers( struct mansession *s, struct message *m )
|
|||
/*! \brief CLI Show Peers command */
|
||||
static int sip_show_peers(int fd, int argc, char *argv[])
|
||||
{
|
||||
return _sip_show_peers(fd, NULL, NULL, NULL, argc, argv);
|
||||
return _sip_show_peers(fd, NULL, NULL, NULL, argc, (const char **) argv);
|
||||
}
|
||||
|
||||
/*! \brief _sip_show_peers: Execute sip show peers command */
|
||||
static int _sip_show_peers(int fd, int *total, struct mansession *s, struct message *m, int argc, char *argv[])
|
||||
static int _sip_show_peers(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[])
|
||||
{
|
||||
regex_t regexbuf;
|
||||
int havepattern = FALSE;
|
||||
|
@ -9658,7 +9655,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
|
|||
int peers_mon_offline = 0;
|
||||
int peers_unmon_offline = 0;
|
||||
int peers_unmon_online = 0;
|
||||
char *id;
|
||||
const char *id;
|
||||
char idtext[256] = "";
|
||||
int realtimepeers;
|
||||
|
||||
|
@ -10064,11 +10061,11 @@ static char mandescr_show_peer[] =
|
|||
" ActionID: <id> Optional action ID for this AMI transaction.\n";
|
||||
|
||||
/*! \brief Show SIP peers in the manager API */
|
||||
static int manager_sip_show_peer( struct mansession *s, struct message *m)
|
||||
static int manager_sip_show_peer(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
char *a[4];
|
||||
char *peer;
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
const char *a[4];
|
||||
const char *peer;
|
||||
int ret;
|
||||
|
||||
peer = astman_get_header(m,"Peer");
|
||||
|
@ -10083,7 +10080,7 @@ static int manager_sip_show_peer( struct mansession *s, struct message *m)
|
|||
|
||||
if (!ast_strlen_zero(id))
|
||||
astman_append(s, "ActionID: %s\r\n",id);
|
||||
ret = _sip_show_peer(1, -1, s, m, 4, a );
|
||||
ret = _sip_show_peer(1, -1, s, m, 4, a);
|
||||
astman_append(s, "\r\n\r\n" );
|
||||
return ret;
|
||||
}
|
||||
|
@ -10093,11 +10090,11 @@ static int manager_sip_show_peer( struct mansession *s, struct message *m)
|
|||
/*! \brief Show one peer in detail */
|
||||
static int sip_show_peer(int fd, int argc, char *argv[])
|
||||
{
|
||||
return _sip_show_peer(0, fd, NULL, NULL, argc, argv);
|
||||
return _sip_show_peer(0, fd, NULL, NULL, argc, (const char **) argv);
|
||||
}
|
||||
|
||||
/*! \brief Show one peer in detail (main function) */
|
||||
static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[])
|
||||
static int _sip_show_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
|
||||
{
|
||||
char status[30] = "";
|
||||
char cbuf[256];
|
||||
|
|
|
@ -10682,7 +10682,7 @@ static int zap_restart_cmd(int fd, int argc, char **argv)
|
|||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static int action_zaprestart(struct mansession *s, struct message *m)
|
||||
static int action_zaprestart(struct mansession *s, const struct message *m)
|
||||
{
|
||||
if (zap_restart() != 0) {
|
||||
astman_send_error(s, m, "Failed rereading zaptel configuration");
|
||||
|
@ -11077,46 +11077,49 @@ static struct zt_pvt *find_channel(int channel)
|
|||
return p;
|
||||
}
|
||||
|
||||
static int action_zapdndon(struct mansession *s, struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
char *channel = astman_get_header(m, "ZapChannel");
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
}
|
||||
p = find_channel(atoi(channel));
|
||||
if (!p) {
|
||||
astman_send_error(s, m, "No such channel");
|
||||
return 0;
|
||||
}
|
||||
p->dnd = 1;
|
||||
astman_send_ack(s, m, "DND Enabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_zapdndoff(struct mansession *s, struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
char *channel = astman_get_header(m, "ZapChannel");
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
}
|
||||
p = find_channel(atoi(channel));
|
||||
if (!p) {
|
||||
astman_send_error(s, m, "No such channel");
|
||||
return 0;
|
||||
}
|
||||
p->dnd = 0;
|
||||
astman_send_ack(s, m, "DND Disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_transfer(struct mansession *s, struct message *m)
|
||||
static int action_zapdndon(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
char *channel = astman_get_header(m, "ZapChannel");
|
||||
const char *channel = astman_get_header(m, "ZapChannel");
|
||||
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
}
|
||||
p = find_channel(atoi(channel));
|
||||
if (!p) {
|
||||
astman_send_error(s, m, "No such channel");
|
||||
return 0;
|
||||
}
|
||||
p->dnd = 1;
|
||||
astman_send_ack(s, m, "DND Enabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_zapdndoff(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
const char *channel = astman_get_header(m, "ZapChannel");
|
||||
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
}
|
||||
p = find_channel(atoi(channel));
|
||||
if (!p) {
|
||||
astman_send_error(s, m, "No such channel");
|
||||
return 0;
|
||||
}
|
||||
p->dnd = 0;
|
||||
astman_send_ack(s, m, "DND Disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_transfer(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
const char *channel = astman_get_header(m, "ZapChannel");
|
||||
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
|
@ -11131,10 +11134,11 @@ static int action_transfer(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int action_transferhangup(struct mansession *s, struct message *m)
|
||||
static int action_transferhangup(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
char *channel = astman_get_header(m, "ZapChannel");
|
||||
const char *channel = astman_get_header(m, "ZapChannel");
|
||||
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
|
@ -11149,12 +11153,13 @@ static int action_transferhangup(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int action_zapdialoffhook(struct mansession *s, struct message *m)
|
||||
static int action_zapdialoffhook(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct zt_pvt *p = NULL;
|
||||
char *channel = astman_get_header(m, "ZapChannel");
|
||||
char *number = astman_get_header(m, "Number");
|
||||
const char *channel = astman_get_header(m, "ZapChannel");
|
||||
const char *number = astman_get_header(m, "Number");
|
||||
int i;
|
||||
|
||||
if (ast_strlen_zero(channel)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
|
@ -11180,10 +11185,10 @@ static int action_zapdialoffhook(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int action_zapshowchannels(struct mansession *s, struct message *m)
|
||||
static int action_zapshowchannels(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct zt_pvt *tmp = NULL;
|
||||
char *id = astman_get_header(m, "ActionID");
|
||||
const char *id = astman_get_header(m, "ActionID");
|
||||
char idText[256] = "";
|
||||
|
||||
astman_send_ack(s, m, "Zapata channel status will follow");
|
||||
|
|
|
@ -122,14 +122,14 @@ struct aji_client_container{
|
|||
ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
|
||||
};
|
||||
|
||||
int ast_aji_send(struct aji_client *client, char *address, char *message);
|
||||
int ast_aji_send(struct aji_client *client, const char *address, const char *message);
|
||||
int ast_aji_disconnect(struct aji_client *client);
|
||||
int ast_aji_check_roster(void);
|
||||
void ast_aji_increment_mid(char *mid);
|
||||
int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic);
|
||||
int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message);
|
||||
int ast_aji_join_chat(struct aji_client *client,char *room);
|
||||
struct aji_client *ast_aji_get_client(char *name);
|
||||
struct aji_client *ast_aji_get_client(const char *name);
|
||||
struct aji_client_container *ast_aji_get_clients(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
|
||||
/* Export manager structures */
|
||||
#define AST_MAX_MANHEADERS 80
|
||||
#define AST_MAX_MANHEADER_LEN 256
|
||||
|
||||
/* Manager Helper Function */
|
||||
typedef int (*manager_hook_t)(int, const char *, char *);
|
||||
|
@ -85,8 +84,8 @@ void ast_manager_unregister_hook(struct manager_custom_hook *hook);
|
|||
struct mansession;
|
||||
|
||||
struct message {
|
||||
int hdrcount;
|
||||
char headers[AST_MAX_MANHEADERS][AST_MAX_MANHEADER_LEN];
|
||||
unsigned int hdrcount;
|
||||
const char *headers[AST_MAX_MANHEADERS];
|
||||
};
|
||||
|
||||
struct manager_action {
|
||||
|
@ -99,7 +98,7 @@ struct manager_action {
|
|||
/*! Permission required for action. EVENT_FLAG_* */
|
||||
int authority;
|
||||
/*! Function to be called */
|
||||
int (*func)(struct mansession *s, struct message *m);
|
||||
int (*func)(struct mansession *s, const struct message *m);
|
||||
/*! For easy linking */
|
||||
struct manager_action *next;
|
||||
};
|
||||
|
@ -119,7 +118,7 @@ struct manager_action {
|
|||
int ast_manager_register2(
|
||||
const char *action,
|
||||
int authority,
|
||||
int (*func)(struct mansession *s, struct message *m),
|
||||
int (*func)(struct mansession *s, const struct message *m),
|
||||
const char *synopsis,
|
||||
const char *description);
|
||||
|
||||
|
@ -133,34 +132,32 @@ int ast_manager_unregister( char *action );
|
|||
\param event Event name
|
||||
\param contents Contents of event
|
||||
*/
|
||||
|
||||
/* XXX the parser in gcc 2.95 gets confused if you don't put a space
|
||||
* between the last arg before VA_ARGS and the comma */
|
||||
#define manager_event(category, event, contents , ...) \
|
||||
__manager_event(category, event, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
|
||||
|
||||
int __manager_event(int category, const char *event,
|
||||
const char *file, int line, const char *func, const char *contents, ...)
|
||||
__attribute__ ((format (printf, 6,7)));
|
||||
int __attribute__ ((format(printf, 6, 7))) __manager_event(int category, const char *event,
|
||||
const char *file, int line, const char *func,
|
||||
const char *contents, ...);
|
||||
|
||||
/*! Get header from mananger transaction */
|
||||
char *astman_get_header(struct message *m, char *var);
|
||||
const char *astman_get_header(const struct message *m, char *var);
|
||||
|
||||
/*! Get a linked list of the Variable: headers */
|
||||
struct ast_variable *astman_get_variables(struct message *m);
|
||||
struct ast_variable *astman_get_variables(const struct message *m);
|
||||
|
||||
/*! Send error in manager transaction */
|
||||
void astman_send_error(struct mansession *s, struct message *m, char *error);
|
||||
void astman_send_response(struct mansession *s, struct message *m, char *resp, char *msg);
|
||||
void astman_send_ack(struct mansession *s, struct message *m, char *msg);
|
||||
void astman_send_listack(struct mansession *s, struct message *m, char *msg, char *listflag);
|
||||
|
||||
void astman_append(struct mansession *s, const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
void astman_send_error(struct mansession *s, const struct message *m, char *error);
|
||||
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg);
|
||||
void astman_send_ack(struct mansession *s, const struct message *m, char *msg);
|
||||
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag);
|
||||
|
||||
void __attribute__ ((format (printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
|
||||
|
||||
/*! Called by Asterisk initialization */
|
||||
int init_manager(void);
|
||||
/*! Called by Asterisk initialization */
|
||||
int reload_manager(void);
|
||||
|
||||
#endif /* _ASTERISK_MANAGER_H */
|
||||
|
|
|
@ -855,7 +855,6 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||
lineno++;
|
||||
if (fgets(buf, sizeof(buf), f)) {
|
||||
if ( withcomments ) {
|
||||
ast_log(LOG_NOTICE, "moo\n");
|
||||
CB_ADD(lline_buffer); /* add the current lline buffer to the comment buffer */
|
||||
lline_buffer[0] = 0; /* erase the lline buffer */
|
||||
}
|
||||
|
|
18
main/db.c
18
main/db.c
|
@ -522,11 +522,11 @@ struct ast_cli_entry cli_database[] = {
|
|||
database_deltree_usage },
|
||||
};
|
||||
|
||||
static int manager_dbput(struct mansession *s, struct message *m)
|
||||
static int manager_dbput(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *family = astman_get_header(m, "Family");
|
||||
char *key = astman_get_header(m, "Key");
|
||||
char *val = astman_get_header(m, "Val");
|
||||
const char *family = astman_get_header(m, "Family");
|
||||
const char *key = astman_get_header(m, "Key");
|
||||
const char *val = astman_get_header(m, "Val");
|
||||
int res;
|
||||
|
||||
if (ast_strlen_zero(family)) {
|
||||
|
@ -542,7 +542,7 @@ static int manager_dbput(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
res = ast_db_put(family, key, val);
|
||||
res = ast_db_put(family, key, (char *) val);
|
||||
if (res) {
|
||||
astman_send_error(s, m, "Failed to update entry");
|
||||
} else {
|
||||
|
@ -551,12 +551,12 @@ static int manager_dbput(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int manager_dbget(struct mansession *s, struct message *m)
|
||||
static int manager_dbget(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
char idText[256] = "";
|
||||
char *family = astman_get_header(m, "Family");
|
||||
char *key = astman_get_header(m, "Key");
|
||||
const char *family = astman_get_header(m, "Family");
|
||||
const char *key = astman_get_header(m, "Key");
|
||||
char tmp[256];
|
||||
int res;
|
||||
|
||||
|
|
329
main/manager.c
329
main/manager.c
|
@ -138,8 +138,8 @@ struct mansession {
|
|||
int authenticated; /*!< Authentication status */
|
||||
int readperm; /*!< Authorization for reading */
|
||||
int writeperm; /*!< Authorization for writing */
|
||||
char inbuf[AST_MAX_MANHEADER_LEN+1]; /*!< Buffer */
|
||||
/* we use the extra byte to add a '\0' and simplify parsing */
|
||||
char inbuf[1025]; /*!< Buffer */
|
||||
/* we use the extra byte to add a '\0' and simplify parsing */
|
||||
int inlen; /*!< number of buffered bytes */
|
||||
int send_events; /*!< XXX what ? */
|
||||
struct eventqent *last_ev; /*!< last event processed. */
|
||||
|
@ -356,7 +356,7 @@ static int get_perm(const char *instr)
|
|||
* A number returns itself, false returns 0, true returns all flags,
|
||||
* other strings return the flags that are set.
|
||||
*/
|
||||
static int ast_strings_to_mask(const char *string)
|
||||
static int strings_to_mask(const char *string)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
|
@ -671,12 +671,12 @@ static void destroy_session(struct mansession *s)
|
|||
free_session(s);
|
||||
}
|
||||
|
||||
char *astman_get_header(struct message *m, char *var)
|
||||
const char *astman_get_header(const struct message *m, char *var)
|
||||
{
|
||||
int x, l = strlen(var);
|
||||
|
||||
for (x = 0; x < m->hdrcount; x++) {
|
||||
char *h = m->headers[x];
|
||||
const char *h = m->headers[x];
|
||||
if (!strncasecmp(var, h, l) && h[l] == ':' && h[l+1] == ' ')
|
||||
return h + l + 2;
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ char *astman_get_header(struct message *m, char *var)
|
|||
return "";
|
||||
}
|
||||
|
||||
struct ast_variable *astman_get_variables(struct message *m)
|
||||
struct ast_variable *astman_get_variables(const struct message *m)
|
||||
{
|
||||
int varlen, x, y;
|
||||
struct ast_variable *head = NULL, *cur;
|
||||
|
@ -795,9 +795,9 @@ void astman_append(struct mansession *s, const char *fmt, ...)
|
|||
* XXX MSG_MOREDATA should go to a header file.
|
||||
*/
|
||||
#define MSG_MOREDATA ((char *)astman_send_response)
|
||||
static void astman_send_response_full(struct mansession *s, struct message *m, char *resp, char *msg, char *listflag)
|
||||
static void astman_send_response_full(struct mansession *s, const struct message *m, char *resp, char *msg, char *listflag)
|
||||
{
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
|
||||
astman_append(s, "Response: %s\r\n", resp);
|
||||
if (!ast_strlen_zero(id))
|
||||
|
@ -812,40 +812,39 @@ static void astman_send_response_full(struct mansession *s, struct message *m, c
|
|||
astman_append(s, "\r\n");
|
||||
}
|
||||
|
||||
void astman_send_response(struct mansession *s, struct message *m, char *resp, char *msg)
|
||||
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
|
||||
{
|
||||
astman_send_response_full(s, m, resp, msg, NULL);
|
||||
}
|
||||
|
||||
void astman_send_error(struct mansession *s, struct message *m, char *error)
|
||||
void astman_send_error(struct mansession *s, const struct message *m, char *error)
|
||||
{
|
||||
astman_send_response_full(s, m, "Error", error, NULL);
|
||||
}
|
||||
|
||||
void astman_send_ack(struct mansession *s, struct message *m, char *msg)
|
||||
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
|
||||
{
|
||||
astman_send_response_full(s, m, "Success", msg, NULL);
|
||||
}
|
||||
|
||||
static void astman_start_ack(struct mansession *s, struct message *m)
|
||||
static void astman_start_ack(struct mansession *s, const struct message *m)
|
||||
{
|
||||
astman_send_response_full(s, m, "Success", MSG_MOREDATA, NULL);
|
||||
}
|
||||
|
||||
void astman_send_listack(struct mansession *s, struct message *m, char *msg, char *listflag)
|
||||
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
|
||||
{
|
||||
astman_send_response_full(s, m, "Success", msg, listflag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! \brief
|
||||
Rather than braindead on,off this now can also accept a specific int mask value
|
||||
or a ',' delim list of mask strings (the same as manager.conf) -anthm
|
||||
*/
|
||||
static int set_eventmask(struct mansession *s, char *eventmask)
|
||||
static int set_eventmask(struct mansession *s, const char *eventmask)
|
||||
{
|
||||
int maskint = ast_strings_to_mask(eventmask);
|
||||
int maskint = strings_to_mask(eventmask);
|
||||
|
||||
ast_mutex_lock(&s->__lock);
|
||||
if (maskint >= 0)
|
||||
|
@ -862,9 +861,9 @@ static int set_eventmask(struct mansession *s, char *eventmask)
|
|||
*/
|
||||
|
||||
/* helper function for action_login() */
|
||||
static int authenticate(struct mansession *s, struct message *m)
|
||||
static int authenticate(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *user = astman_get_header(m, "Username");
|
||||
const char *user = astman_get_header(m, "Username");
|
||||
int error = -1;
|
||||
struct ast_ha *ha = NULL;
|
||||
char *password = NULL;
|
||||
|
@ -928,7 +927,7 @@ static int authenticate(struct mansession *s, struct message *m)
|
|||
}
|
||||
}
|
||||
if (!strcasecmp(astman_get_header(m, "AuthType"), "MD5")) {
|
||||
char *key = astman_get_header(m, "Key");
|
||||
const char *key = astman_get_header(m, "Key");
|
||||
if (!ast_strlen_zero(key) && !ast_strlen_zero(s->challenge)) {
|
||||
int x;
|
||||
int len = 0;
|
||||
|
@ -946,7 +945,7 @@ static int authenticate(struct mansession *s, struct message *m)
|
|||
error = 0;
|
||||
}
|
||||
} else if (password) {
|
||||
char *pass = astman_get_header(m, "Secret");
|
||||
const char *pass = astman_get_header(m, "Secret");
|
||||
if (!strcmp(password, pass))
|
||||
error = 0;
|
||||
}
|
||||
|
@ -967,7 +966,7 @@ static char mandescr_ping[] =
|
|||
" manager connection open.\n"
|
||||
"Variables: NONE\n";
|
||||
|
||||
static int action_ping(struct mansession *s, struct message *m)
|
||||
static int action_ping(struct mansession *s, const struct message *m)
|
||||
{
|
||||
astman_send_response(s, m, "Pong", NULL);
|
||||
return 0;
|
||||
|
@ -979,10 +978,10 @@ static char mandescr_getconfig[] =
|
|||
"Variables:\n"
|
||||
" Filename: Configuration filename (e.g. foo.conf)\n";
|
||||
|
||||
static int action_getconfig(struct mansession *s, struct message *m)
|
||||
static int action_getconfig(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_config *cfg;
|
||||
char *fn = astman_get_header(m, "Filename");
|
||||
const char *fn = astman_get_header(m, "Filename");
|
||||
int catcount = 0;
|
||||
int lineno = 0;
|
||||
char *category=NULL;
|
||||
|
@ -1011,11 +1010,11 @@ static int action_getconfig(struct mansession *s, struct message *m)
|
|||
}
|
||||
|
||||
/* helper function for action_updateconfig */
|
||||
static void handle_updates(struct mansession *s, struct message *m, struct ast_config *cfg)
|
||||
static void handle_updates(struct mansession *s, const struct message *m, struct ast_config *cfg)
|
||||
{
|
||||
int x;
|
||||
char hdr[40];
|
||||
char *action, *cat, *var, *value, *match;
|
||||
const char *action, *cat, *var, *value, *match;
|
||||
struct ast_category *category;
|
||||
struct ast_variable *v;
|
||||
|
||||
|
@ -1047,13 +1046,13 @@ static void handle_updates(struct mansession *s, struct message *m, struct ast_c
|
|||
}
|
||||
} else if (!strcasecmp(action, "delcat")) {
|
||||
if (!ast_strlen_zero(cat))
|
||||
ast_category_delete(cfg, cat);
|
||||
ast_category_delete(cfg, (char *) cat);
|
||||
} else if (!strcasecmp(action, "update")) {
|
||||
if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
|
||||
ast_variable_update(category, var, value, match);
|
||||
ast_variable_update(category, (char *) var, (char *) value, (char *) match);
|
||||
} else if (!strcasecmp(action, "delete")) {
|
||||
if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
|
||||
ast_variable_delete(category, var, match);
|
||||
ast_variable_delete(category, (char *) var, (char *) match);
|
||||
} else if (!strcasecmp(action, "append")) {
|
||||
if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) &&
|
||||
(category = ast_category_get(cfg, cat)) &&
|
||||
|
@ -1079,13 +1078,13 @@ static char mandescr_updateconfig[] =
|
|||
" Value-XXXXXX: Value to work on\n"
|
||||
" Match-XXXXXX: Extra match required to match line\n";
|
||||
|
||||
static int action_updateconfig(struct mansession *s, struct message *m)
|
||||
static int action_updateconfig(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_config *cfg;
|
||||
char *sfn = astman_get_header(m, "SrcFilename");
|
||||
char *dfn = astman_get_header(m, "DstFilename");
|
||||
const char *sfn = astman_get_header(m, "SrcFilename");
|
||||
const char *dfn = astman_get_header(m, "DstFilename");
|
||||
int res;
|
||||
char *rld = astman_get_header(m, "Reload");
|
||||
const char *rld = astman_get_header(m, "Reload");
|
||||
|
||||
if (ast_strlen_zero(sfn) || ast_strlen_zero(dfn)) {
|
||||
astman_send_error(s, m, "Filename not specified");
|
||||
|
@ -1119,13 +1118,13 @@ static char mandescr_waitevent[] =
|
|||
"Variables: \n"
|
||||
" Timeout: Maximum time (in seconds) to wait for events, -1 means forever.\n";
|
||||
|
||||
static int action_waitevent(struct mansession *s, struct message *m)
|
||||
static int action_waitevent(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *timeouts = astman_get_header(m, "Timeout");
|
||||
const char *timeouts = astman_get_header(m, "Timeout");
|
||||
int timeout = -1;
|
||||
int x;
|
||||
int needexit = 0;
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
char idText[256] = "";
|
||||
|
||||
if (!ast_strlen_zero(id))
|
||||
|
@ -1219,7 +1218,7 @@ static char mandescr_listcommands[] =
|
|||
" action that is available to the user\n"
|
||||
"Variables: NONE\n";
|
||||
|
||||
static int action_listcommands(struct mansession *s, struct message *m)
|
||||
static int action_listcommands(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct manager_action *cur;
|
||||
struct ast_str *temp = ast_str_alloca(BUFSIZ); /* XXX very large ? */
|
||||
|
@ -1245,9 +1244,9 @@ static char mandescr_events[] =
|
|||
" 'off' if no events should be sent,\n"
|
||||
" 'system,call,log' to select which flags events should have to be sent.\n";
|
||||
|
||||
static int action_events(struct mansession *s, struct message *m)
|
||||
static int action_events(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *mask = astman_get_header(m, "EventMask");
|
||||
const char *mask = astman_get_header(m, "EventMask");
|
||||
int res;
|
||||
|
||||
res = set_eventmask(s, mask);
|
||||
|
@ -1263,13 +1262,13 @@ static char mandescr_logoff[] =
|
|||
"Description: Logoff this manager session\n"
|
||||
"Variables: NONE\n";
|
||||
|
||||
static int action_logoff(struct mansession *s, struct message *m)
|
||||
static int action_logoff(struct mansession *s, const struct message *m)
|
||||
{
|
||||
astman_send_response(s, m, "Goodbye", "Thanks for all the fish.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int action_login(struct mansession *s, struct message *m)
|
||||
static int action_login(struct mansession *s, const struct message *m)
|
||||
{
|
||||
if (authenticate(s, m)) {
|
||||
sleep(1);
|
||||
|
@ -1287,9 +1286,9 @@ static int action_login(struct mansession *s, struct message *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int action_challenge(struct mansession *s, struct message *m)
|
||||
static int action_challenge(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *authtype = astman_get_header(m, "AuthType");
|
||||
const char *authtype = astman_get_header(m, "AuthType");
|
||||
|
||||
if (!strcasecmp(authtype, "MD5")) {
|
||||
if (ast_strlen_zero(s->challenge))
|
||||
|
@ -1309,10 +1308,10 @@ static char mandescr_hangup[] =
|
|||
"Variables: \n"
|
||||
" Channel: The channel name to be hungup\n";
|
||||
|
||||
static int action_hangup(struct mansession *s, struct message *m)
|
||||
static int action_hangup(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
if (ast_strlen_zero(name)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
|
@ -1335,12 +1334,12 @@ static char mandescr_setvar[] =
|
|||
" *Variable: Variable name\n"
|
||||
" *Value: Value\n";
|
||||
|
||||
static int action_setvar(struct mansession *s, struct message *m)
|
||||
static int action_setvar(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
char *varname = astman_get_header(m, "Variable");
|
||||
char *varval = astman_get_header(m, "Value");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
const char *varname = astman_get_header(m, "Variable");
|
||||
const char *varval = astman_get_header(m, "Value");
|
||||
|
||||
if (ast_strlen_zero(varname)) {
|
||||
astman_send_error(s, m, "No variable specified");
|
||||
|
@ -1377,11 +1376,11 @@ static char mandescr_getvar[] =
|
|||
" *Variable: Variable name\n"
|
||||
" ActionID: Optional Action id for message matching.\n";
|
||||
|
||||
static int action_getvar(struct mansession *s, struct message *m)
|
||||
static int action_getvar(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
char *varname = astman_get_header(m, "Variable");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
const char *varname = astman_get_header(m, "Variable");
|
||||
char *varval;
|
||||
char workspace[1024];
|
||||
|
||||
|
@ -1399,7 +1398,7 @@ static int action_getvar(struct mansession *s, struct message *m)
|
|||
}
|
||||
|
||||
if (varname[strlen(varname) - 1] == ')') {
|
||||
ast_func_read(c, varname, workspace, sizeof(workspace));
|
||||
ast_func_read(c, (char *) varname, workspace, sizeof(workspace));
|
||||
} else {
|
||||
pbx_retrieve_variable(c, varname, &varval, workspace, sizeof(workspace), NULL);
|
||||
}
|
||||
|
@ -1415,15 +1414,15 @@ static int action_getvar(struct mansession *s, struct message *m)
|
|||
|
||||
/*! \brief Manager "status" command to show channels */
|
||||
/* Needs documentation... */
|
||||
static int action_status(struct mansession *s, struct message *m)
|
||||
static int action_status(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *name = astman_get_header(m,"Channel");
|
||||
const char *name = astman_get_header(m,"Channel");
|
||||
struct ast_channel *c;
|
||||
char bridge[256];
|
||||
struct timeval now = ast_tvnow();
|
||||
long elapsed_seconds = 0;
|
||||
int all = ast_strlen_zero(name); /* set if we want all channels */
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
char idText[256] = "";
|
||||
|
||||
if (!ast_strlen_zero(id))
|
||||
|
@ -1509,11 +1508,11 @@ static char mandescr_sendtext[] =
|
|||
" *Message: Message to send\n"
|
||||
" ActionID: Optional Action id for message matching.\n";
|
||||
|
||||
static int action_sendtext(struct mansession *s, struct message *m)
|
||||
static int action_sendtext(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
char *textmsg = astman_get_header(m, "Message");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
const char *textmsg = astman_get_header(m, "Message");
|
||||
int res = 0;
|
||||
|
||||
if (ast_strlen_zero(name)) {
|
||||
|
@ -1554,13 +1553,13 @@ static char mandescr_redirect[] =
|
|||
" ActionID: Optional Action id for message matching.\n";
|
||||
|
||||
/*! \brief action_redirect: The redirect manager command */
|
||||
static int action_redirect(struct mansession *s, struct message *m)
|
||||
static int action_redirect(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
char *name2 = astman_get_header(m, "ExtraChannel");
|
||||
char *exten = astman_get_header(m, "Exten");
|
||||
char *context = astman_get_header(m, "Context");
|
||||
char *priority = astman_get_header(m, "Priority");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
const char *name2 = astman_get_header(m, "ExtraChannel");
|
||||
const char *exten = astman_get_header(m, "Exten");
|
||||
const char *context = astman_get_header(m, "Context");
|
||||
const char *priority = astman_get_header(m, "Priority");
|
||||
struct ast_channel *chan, *chan2 = NULL;
|
||||
int pi = 0;
|
||||
int res;
|
||||
|
@ -1614,10 +1613,10 @@ static char mandescr_command[] =
|
|||
" ActionID: Optional Action id for message matching.\n";
|
||||
|
||||
/*! \brief Manager command "command" - execute CLI command */
|
||||
static int action_command(struct mansession *s, struct message *m)
|
||||
static int action_command(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *cmd = astman_get_header(m, "Command");
|
||||
char *id = astman_get_header(m, "ActionID");
|
||||
const char *cmd = astman_get_header(m, "Command");
|
||||
const char *id = astman_get_header(m, "ActionID");
|
||||
char *buf;
|
||||
char template[] = "/tmp/ast-ami-XXXXXX"; /* template for temporary file */
|
||||
int fd = mkstemp(template);
|
||||
|
@ -1642,16 +1641,16 @@ static int action_command(struct mansession *s, struct message *m)
|
|||
|
||||
/* helper function for originate */
|
||||
struct fast_originate_helper {
|
||||
char tech[AST_MAX_MANHEADER_LEN];
|
||||
char data[AST_MAX_MANHEADER_LEN];
|
||||
char tech[AST_MAX_EXTENSION];
|
||||
char data[AST_MAX_EXTENSION];
|
||||
int timeout;
|
||||
char app[AST_MAX_APP];
|
||||
char appdata[AST_MAX_MANHEADER_LEN];
|
||||
char cid_name[AST_MAX_MANHEADER_LEN];
|
||||
char cid_num[AST_MAX_MANHEADER_LEN];
|
||||
char appdata[AST_MAX_EXTENSION];
|
||||
char cid_name[AST_MAX_EXTENSION];
|
||||
char cid_num[AST_MAX_EXTENSION];
|
||||
char context[AST_MAX_CONTEXT];
|
||||
char exten[AST_MAX_EXTENSION];
|
||||
char idtext[AST_MAX_MANHEADER_LEN];
|
||||
char idtext[AST_MAX_EXTENSION];
|
||||
char account[AST_MAX_ACCOUNT_CODE];
|
||||
int priority;
|
||||
struct ast_variable *vars;
|
||||
|
@ -1719,19 +1718,19 @@ static char mandescr_originate[] =
|
|||
" Account: Account code\n"
|
||||
" Async: Set to 'true' for fast origination\n";
|
||||
|
||||
static int action_originate(struct mansession *s, struct message *m)
|
||||
static int action_originate(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
char *exten = astman_get_header(m, "Exten");
|
||||
char *context = astman_get_header(m, "Context");
|
||||
char *priority = astman_get_header(m, "Priority");
|
||||
char *timeout = astman_get_header(m, "Timeout");
|
||||
char *callerid = astman_get_header(m, "CallerID");
|
||||
char *account = astman_get_header(m, "Account");
|
||||
char *app = astman_get_header(m, "Application");
|
||||
char *appdata = astman_get_header(m, "Data");
|
||||
char *async = astman_get_header(m, "Async");
|
||||
char *id = astman_get_header(m, "ActionID");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
const char *exten = astman_get_header(m, "Exten");
|
||||
const char *context = astman_get_header(m, "Context");
|
||||
const char *priority = astman_get_header(m, "Priority");
|
||||
const char *timeout = astman_get_header(m, "Timeout");
|
||||
const char *callerid = astman_get_header(m, "CallerID");
|
||||
const char *account = astman_get_header(m, "Account");
|
||||
const char *app = astman_get_header(m, "Application");
|
||||
const char *appdata = astman_get_header(m, "Data");
|
||||
const char *async = astman_get_header(m, "Async");
|
||||
const char *id = astman_get_header(m, "ActionID");
|
||||
struct ast_variable *vars = astman_get_variables(m);
|
||||
char *tech, *data;
|
||||
char *l = NULL, *n = NULL;
|
||||
|
@ -1836,9 +1835,9 @@ static char mandescr_mailboxstatus[] =
|
|||
" Waiting: <count>\n"
|
||||
"\n";
|
||||
|
||||
static int action_mailboxstatus(struct mansession *s, struct message *m)
|
||||
static int action_mailboxstatus(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *mailbox = astman_get_header(m, "Mailbox");
|
||||
const char *mailbox = astman_get_header(m, "Mailbox");
|
||||
int ret;
|
||||
|
||||
if (ast_strlen_zero(mailbox)) {
|
||||
|
@ -1864,9 +1863,9 @@ static char mandescr_mailboxcount[] =
|
|||
" NewMessages: <count>\n"
|
||||
" OldMessages: <count>\n"
|
||||
"\n";
|
||||
static int action_mailboxcount(struct mansession *s, struct message *m)
|
||||
static int action_mailboxcount(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *mailbox = astman_get_header(m, "Mailbox");
|
||||
const char *mailbox = astman_get_header(m, "Mailbox");
|
||||
int newmsgs = 0, oldmsgs = 0;
|
||||
|
||||
if (ast_strlen_zero(mailbox)) {
|
||||
|
@ -1895,10 +1894,10 @@ static char mandescr_extensionstate[] =
|
|||
"Will return an \"Extension Status\" message.\n"
|
||||
"The response will include the hint for the extension and the status.\n";
|
||||
|
||||
static int action_extensionstate(struct mansession *s, struct message *m)
|
||||
static int action_extensionstate(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *exten = astman_get_header(m, "Exten");
|
||||
char *context = astman_get_header(m, "Context");
|
||||
const char *exten = astman_get_header(m, "Exten");
|
||||
const char *context = astman_get_header(m, "Context");
|
||||
char hint[256] = "";
|
||||
int status;
|
||||
if (ast_strlen_zero(exten)) {
|
||||
|
@ -1926,10 +1925,10 @@ static char mandescr_timeout[] =
|
|||
" *Timeout: Maximum duration of the call (sec)\n"
|
||||
"Acknowledges set time with 'Timeout Set' message\n";
|
||||
|
||||
static int action_timeout(struct mansession *s, struct message *m)
|
||||
static int action_timeout(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
int timeout = atoi(astman_get_header(m, "Timeout"));
|
||||
|
||||
if (ast_strlen_zero(name)) {
|
||||
|
@ -1986,9 +1985,9 @@ static char mandescr_userevent[] =
|
|||
" Header1: Content1\n"
|
||||
" HeaderN: ContentN\n";
|
||||
|
||||
static int action_userevent(struct mansession *s, struct message *m)
|
||||
static int action_userevent(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *event = astman_get_header(m, "UserEvent");
|
||||
const char *event = astman_get_header(m, "UserEvent");
|
||||
char body[2048] = "";
|
||||
int x, bodylen = 0;
|
||||
for (x = 0; x < m->hdrcount; x++) {
|
||||
|
@ -2017,7 +2016,7 @@ static int action_userevent(struct mansession *s, struct message *m)
|
|||
* Process an AMI message, performing desired action.
|
||||
* Return 0 on success, -1 on error that require the session to be destroyed.
|
||||
*/
|
||||
static int process_message(struct mansession *s, struct message *m)
|
||||
static int process_message(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char action[80] = "";
|
||||
int ret = 0;
|
||||
|
@ -2128,6 +2127,29 @@ static int get_input(struct mansession *s, char *output)
|
|||
return res;
|
||||
}
|
||||
|
||||
static int do_message(struct mansession *s)
|
||||
{
|
||||
struct message m = { 0 };
|
||||
char header_buf[sizeof(s->inbuf)] = { '\0' };
|
||||
int res;
|
||||
|
||||
for (;;) {
|
||||
res = get_input(s, header_buf);
|
||||
if (res > 0) {
|
||||
/* Strip trailing \r\n */
|
||||
if (strlen(header_buf) < 2)
|
||||
continue;
|
||||
header_buf[strlen(header_buf) - 2] = '\0';
|
||||
if (ast_strlen_zero(header_buf))
|
||||
return process_message(s, &m) ? -1 : 0;
|
||||
else if (m.hdrcount < (AST_MAX_MANHEADERS - 1))
|
||||
m.headers[m.hdrcount++] = ast_strdupa(header_buf);
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief The body of the individual manager session.
|
||||
* Call get_input() to read one line at a time
|
||||
* (or be woken up on new events), collect the lines in a
|
||||
|
@ -2138,10 +2160,10 @@ static int get_input(struct mansession *s, char *output)
|
|||
*/
|
||||
static void *session_do(void *data)
|
||||
{
|
||||
struct message m; /* XXX watch out, this is 20k of memory! */
|
||||
struct server_instance *ser = data;
|
||||
struct mansession *s = ast_calloc(1, sizeof(*s));
|
||||
int flags;
|
||||
int res;
|
||||
|
||||
if (s == NULL)
|
||||
goto done;
|
||||
|
@ -2173,19 +2195,11 @@ static void *session_do(void *data)
|
|||
s->f = ser->f;
|
||||
astman_append(s, "Asterisk Call Manager/1.0\r\n"); /* welcome prompt */
|
||||
ast_mutex_unlock(&s->__lock);
|
||||
memset(&m, 0, sizeof(m));
|
||||
for (;;) {
|
||||
char *buf = m.headers[m.hdrcount];
|
||||
int res = get_input(s, buf);
|
||||
if (res < 0) /* error */
|
||||
break;
|
||||
if (res > 0) { /* got one line */
|
||||
if (ast_strlen_zero(buf)) { /* empty line, terminator */
|
||||
if (process_message(s, &m))
|
||||
break;
|
||||
memset(&m, 0, sizeof(m));
|
||||
} else if (m.hdrcount < AST_MAX_MANHEADERS - 1)
|
||||
m.hdrcount++;
|
||||
res = do_message(s);
|
||||
|
||||
if (res == 0) {
|
||||
continue;
|
||||
} else if (process_events(s))
|
||||
break;
|
||||
}
|
||||
|
@ -2393,7 +2407,7 @@ static int ast_manager_register_struct(struct manager_action *act)
|
|||
|
||||
/*! \brief register a new command with manager, including online help. This is
|
||||
the preferred way to register a manager command */
|
||||
int ast_manager_register2(const char *action, int auth, int (*func)(struct mansession *s, struct message *m), const char *synopsis, const char *description)
|
||||
int ast_manager_register2(const char *action, int auth, int (*func)(struct mansession *s, const struct message *m), const char *synopsis, const char *description)
|
||||
{
|
||||
struct manager_action *cur;
|
||||
|
||||
|
@ -2465,17 +2479,6 @@ static struct mansession *find_session(unsigned long ident)
|
|||
return s;
|
||||
}
|
||||
|
||||
static void vars2msg(struct message *m, struct ast_variable *vars)
|
||||
{
|
||||
int x;
|
||||
for (x = 0; vars && (x < AST_MAX_MANHEADERS); x++, vars = vars->next) {
|
||||
if (!vars)
|
||||
break;
|
||||
m->hdrcount = x + 1;
|
||||
snprintf(m->headers[x], sizeof(m->headers[x]), "%s: %s", vars->name, vars->value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* convert to xml with various conversion:
|
||||
* mode & 1 -> lowercase;
|
||||
|
@ -2661,17 +2664,19 @@ static void xml_translate(struct ast_str **out, char *in, struct ast_variable *v
|
|||
}
|
||||
|
||||
static struct ast_str *generic_http_callback(enum output_format format,
|
||||
struct sockaddr_in *requestor, const char *uri,
|
||||
struct ast_variable *params, int *status,
|
||||
char **title, int *contentlength)
|
||||
struct sockaddr_in *requestor, const char *uri,
|
||||
struct ast_variable *params, int *status,
|
||||
char **title, int *contentlength)
|
||||
{
|
||||
struct mansession *s = NULL;
|
||||
unsigned long ident = 0; /* invalid, so find_session will fail if not set through the cookie */
|
||||
int blastaway = 0;
|
||||
struct message m;
|
||||
struct ast_variable *v;
|
||||
char template[] = "/tmp/ast-http-XXXXXX"; /* template for temporary file */
|
||||
struct ast_str *out = NULL;
|
||||
struct message m = { 0 };
|
||||
unsigned int x;
|
||||
size_t hdrlen;
|
||||
|
||||
for (v = params; v; v = v->next) {
|
||||
if (!strcasecmp(v->name, "mansession_id")) {
|
||||
|
@ -2705,42 +2710,22 @@ static struct ast_str *generic_http_callback(enum output_format format,
|
|||
|
||||
ast_mutex_unlock(&s->__lock);
|
||||
|
||||
out = ast_str_create(1024);
|
||||
if (out == NULL) {
|
||||
if (!(out = ast_str_create(1024))) {
|
||||
*status = 500;
|
||||
goto generic_callback_out;
|
||||
}
|
||||
memset(&m, 0, sizeof(m));
|
||||
ast_str_append(&out, 0,
|
||||
"Content-type: text/%s\r\n"
|
||||
"Cache-Control: no-cache;\r\n"
|
||||
"Set-Cookie: mansession_id=\"%08lx\"; Version=\"1\"; Max-Age=%d\r\n"
|
||||
"\r\n",
|
||||
contenttype[format],
|
||||
s->managerid, httptimeout);
|
||||
|
||||
if (format == FORMAT_HTML)
|
||||
ast_str_append(&out, 0, "<title>Asterisk™ Manager Test Interface</title>");
|
||||
vars2msg(&m, params);
|
||||
|
||||
if (format == FORMAT_XML) {
|
||||
ast_str_append(&out, 0, "<ajax-response>\n");
|
||||
} else if (format == FORMAT_HTML) {
|
||||
|
||||
#define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n"
|
||||
#define TEST_STRING \
|
||||
"<form action=\"manager\">action: <input name=\"action\"> cmd <input name=\"command\"><br> \
|
||||
user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br> \
|
||||
<input type=\"submit\"></form>"
|
||||
|
||||
ast_str_append(&out, 0, "<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
|
||||
ast_str_append(&out, 0, ROW_FMT, "<h1>Manager Tester</h1>");
|
||||
ast_str_append(&out, 0, ROW_FMT, TEST_STRING);
|
||||
}
|
||||
|
||||
s->fd = mkstemp(template); /* create a temporary file for command output */
|
||||
unlink(template);
|
||||
s->f = fdopen(s->fd, "w+");
|
||||
|
||||
for (x = 0; params && (x < AST_MAX_MANHEADERS); x++, params = params->next) {
|
||||
hdrlen = strlen(params->name) + strlen(params->value) + 3;
|
||||
m.headers[m.hdrcount] = alloca(hdrlen);
|
||||
snprintf((char *) m.headers[m.hdrcount], hdrlen, "%s: %s", params->name, params->value);
|
||||
m.hdrcount = x + 1;
|
||||
}
|
||||
|
||||
if (process_message(s, &m)) {
|
||||
if (s->authenticated) {
|
||||
if (option_verbose > 1) {
|
||||
|
@ -2757,12 +2742,39 @@ static struct ast_str *generic_http_callback(enum output_format format,
|
|||
}
|
||||
s->needdestroy = 1;
|
||||
}
|
||||
|
||||
ast_str_append(&out, 0,
|
||||
"Content-type: text/%s\r\n"
|
||||
"Cache-Control: no-cache;\r\n"
|
||||
"Set-Cookie: mansession_id=\"%08lx\"; Version=\"1\"; Max-Age=%d\r\n"
|
||||
"\r\n",
|
||||
contenttype[format],
|
||||
s->managerid, httptimeout);
|
||||
|
||||
if (format == FORMAT_HTML)
|
||||
ast_str_append(&out, 0, "<title>Asterisk™ Manager Interface</title>");
|
||||
|
||||
if (format == FORMAT_XML) {
|
||||
ast_str_append(&out, 0, "<ajax-response>\n");
|
||||
} else if (format == FORMAT_HTML) {
|
||||
|
||||
#define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n"
|
||||
#define TEST_STRING \
|
||||
"<form action=\"manager\">action: <input name=\"action\"> cmd <input name=\"command\"><br> \
|
||||
user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br> \
|
||||
<input type=\"submit\"></form>"
|
||||
|
||||
ast_str_append(&out, 0, "<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
|
||||
ast_str_append(&out, 0, ROW_FMT, "<h1>Manager Tester</h1>");
|
||||
ast_str_append(&out, 0, ROW_FMT, TEST_STRING);
|
||||
}
|
||||
|
||||
if (s->f != NULL) { /* have temporary output */
|
||||
char *buf;
|
||||
int l = ftell(s->f);
|
||||
|
||||
/* always return something even if len == 0 */
|
||||
if ((buf = ast_calloc(1, l+1))) {
|
||||
if ((buf = ast_calloc(1, l + 1))) {
|
||||
if (l > 0) {
|
||||
fseek(s->f, 0, SEEK_SET);
|
||||
fread(buf, 1, l, s->f);
|
||||
|
@ -2774,7 +2786,6 @@ static struct ast_str *generic_http_callback(enum output_format format,
|
|||
fclose(s->f);
|
||||
s->f = NULL;
|
||||
s->fd = -1;
|
||||
unlink(template);
|
||||
}
|
||||
|
||||
/* Still okay because c would safely be pointing to workspace even
|
||||
|
@ -2787,9 +2798,7 @@ static struct ast_str *generic_http_callback(enum output_format format,
|
|||
ast_mutex_lock(&s->__lock);
|
||||
/* Reset HTTP timeout. If we're not authenticated, keep it extremely short */
|
||||
s->sessiontimeout = time(NULL) + ((s->authenticated || httptimeout < 5) ? httptimeout : 5);
|
||||
if (0)
|
||||
ast_verbose("die in %d seconds\n",
|
||||
(int)(s->sessiontimeout - time(NULL)) );
|
||||
|
||||
if (s->needdestroy) {
|
||||
if (s->inuse == 1) {
|
||||
if (option_debug)
|
||||
|
|
14
main/pbx.c
14
main/pbx.c
|
@ -3422,7 +3422,7 @@ static int handle_show_dialplan(int fd, int argc, char *argv[])
|
|||
}
|
||||
|
||||
/*! \brief Send ack once */
|
||||
static void manager_dpsendack(struct mansession *s, struct message *m)
|
||||
static void manager_dpsendack(struct mansession *s, const struct message *m)
|
||||
{
|
||||
astman_send_listack(s, m, "DialPlan list will follow", "start");
|
||||
}
|
||||
|
@ -3431,8 +3431,10 @@ static void manager_dpsendack(struct mansession *s, struct message *m)
|
|||
* XXX this function is similar but not exactly the same as the CLI's
|
||||
* show dialplan. Must check whether the difference is intentional or not.
|
||||
*/
|
||||
static int manager_show_dialplan_helper(struct mansession *s, struct message *m,
|
||||
const char *actionidtext, const char *context, char *exten, struct dialplan_counters *dpc, struct ast_include *rinclude)
|
||||
static int manager_show_dialplan_helper(struct mansession *s, const struct message *m,
|
||||
const char *actionidtext, const char *context,
|
||||
const char *exten, struct dialplan_counters *dpc,
|
||||
struct ast_include *rinclude)
|
||||
{
|
||||
struct ast_context *c;
|
||||
int res=0, old_total_exten = dpc->total_exten;
|
||||
|
@ -3574,10 +3576,10 @@ static int manager_show_dialplan_helper(struct mansession *s, struct message *m,
|
|||
}
|
||||
|
||||
/*! \brief Manager listing of dial plan */
|
||||
static int manager_show_dialplan(struct mansession *s, struct message *m)
|
||||
static int manager_show_dialplan(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *exten = NULL, *context = NULL;
|
||||
char *id = astman_get_header(m, "ActionID");
|
||||
const char *exten, *context;
|
||||
const char *id = astman_get_header(m, "ActionID");
|
||||
char idtext[256];
|
||||
int res;
|
||||
|
||||
|
|
|
@ -1932,10 +1932,10 @@ static struct ast_cli_entry cli_features[] = {
|
|||
};
|
||||
|
||||
/*! \brief Dump lot status */
|
||||
static int manager_parking_status( struct mansession *s, struct message *m )
|
||||
static int manager_parking_status( struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct parkeduser *cur;
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
char idText[256] = "";
|
||||
|
||||
if (!ast_strlen_zero(id))
|
||||
|
@ -1979,11 +1979,11 @@ static char mandescr_park[] =
|
|||
" *Channel2: Channel to announce park info to (and return to if timeout)\n"
|
||||
" Timeout: Number of milliseconds to wait before callback.\n";
|
||||
|
||||
static int manager_park(struct mansession *s, struct message *m)
|
||||
static int manager_park(struct mansession *s, const struct message *m)
|
||||
{
|
||||
char *channel = astman_get_header(m, "Channel");
|
||||
char *channel2 = astman_get_header(m, "Channel2");
|
||||
char *timeout = astman_get_header(m, "Timeout");
|
||||
const char *channel = astman_get_header(m, "Channel");
|
||||
const char *channel2 = astman_get_header(m, "Channel2");
|
||||
const char *timeout = astman_get_header(m, "Timeout");
|
||||
char buf[BUFSIZ];
|
||||
int to = 0;
|
||||
int res = 0;
|
||||
|
|
|
@ -55,7 +55,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||
#define JABBER_CONFIG "jabber.conf"
|
||||
|
||||
/*-- Forward declarations */
|
||||
static int manager_jabber_send( struct mansession *s, struct message *m );
|
||||
static int aji_highest_bit(int number);
|
||||
static void aji_buddy_destroy(struct aji_buddy *obj);
|
||||
static void aji_client_destroy(struct aji_client *obj);
|
||||
|
@ -1371,7 +1370,7 @@ static void aji_handle_subscribe(struct aji_client *client, ikspak *pak)
|
|||
* \param aji_client struct , reciever, message.
|
||||
* \return 1.
|
||||
*/
|
||||
int ast_aji_send(struct aji_client *client, char *address, char *message)
|
||||
int ast_aji_send(struct aji_client *client, const char *address, const char *message)
|
||||
{
|
||||
int res = 0;
|
||||
iks *message_packet = NULL;
|
||||
|
@ -2295,7 +2294,7 @@ static int aji_load_config(void)
|
|||
* \param void.
|
||||
* \return 1.
|
||||
*/
|
||||
struct aji_client *ast_aji_get_client(char *name)
|
||||
struct aji_client *ast_aji_get_client(const char *name)
|
||||
{
|
||||
struct aji_client *client = NULL;
|
||||
|
||||
|
@ -2318,13 +2317,13 @@ static char mandescr_jabber_send[] =
|
|||
" Message: Message to be sent to the buddy\n";
|
||||
|
||||
/*! \brief Send a Jabber Message via call from the Manager */
|
||||
static int manager_jabber_send( struct mansession *s, struct message *m )
|
||||
static int manager_jabber_send(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct aji_client *client = NULL;
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
char *jabber = astman_get_header(m,"Jabber");
|
||||
char *screenname = astman_get_header(m,"ScreenName");
|
||||
char *message = astman_get_header(m,"Message");
|
||||
const char *id = astman_get_header(m,"ActionID");
|
||||
const char *jabber = astman_get_header(m,"Jabber");
|
||||
const char *screenname = astman_get_header(m,"ScreenName");
|
||||
const char *message = astman_get_header(m,"Message");
|
||||
|
||||
if (ast_strlen_zero(jabber)) {
|
||||
astman_send_error(s, m, "No transport specified");
|
||||
|
|
|
@ -477,13 +477,13 @@ static char start_monitor_action_help[] =
|
|||
" the input and output channels together after the\n"
|
||||
" recording is finished.\n";
|
||||
|
||||
static int start_monitor_action(struct mansession *s, struct message *m)
|
||||
static int start_monitor_action(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
char *fname = astman_get_header(m, "File");
|
||||
char *format = astman_get_header(m, "Format");
|
||||
char *mix = astman_get_header(m, "Mix");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
const char *fname = astman_get_header(m, "File");
|
||||
const char *format = astman_get_header(m, "Format");
|
||||
const char *mix = astman_get_header(m, "Mix");
|
||||
char *d;
|
||||
|
||||
if (ast_strlen_zero(name)) {
|
||||
|
@ -530,10 +530,10 @@ static char stop_monitor_action_help[] =
|
|||
" started 'Monitor' action. The only parameter is 'Channel', the name\n"
|
||||
" of the channel monitored.\n";
|
||||
|
||||
static int stop_monitor_action(struct mansession *s, struct message *m)
|
||||
static int stop_monitor_action(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
int res;
|
||||
if (ast_strlen_zero(name)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
|
@ -562,11 +562,11 @@ static char change_monitor_action_help[] =
|
|||
" File - Required. Is the new name of the file created in the\n"
|
||||
" monitor spool directory.\n";
|
||||
|
||||
static int change_monitor_action(struct mansession *s, struct message *m)
|
||||
static int change_monitor_action(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
char *fname = astman_get_header(m, "File");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
const char *fname = astman_get_header(m, "File");
|
||||
if (ast_strlen_zero(name)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
return 0;
|
||||
|
@ -602,10 +602,10 @@ enum MONITOR_PAUSING_ACTION
|
|||
MONITOR_ACTION_UNPAUSE
|
||||
};
|
||||
|
||||
static int do_pause_or_unpause(struct mansession *s, struct message *m, int action)
|
||||
static int do_pause_or_unpause(struct mansession *s, const struct message *m, int action)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
char *name = astman_get_header(m, "Channel");
|
||||
const char *name = astman_get_header(m, "Channel");
|
||||
|
||||
if (ast_strlen_zero(name)) {
|
||||
astman_send_error(s, m, "No channel specified");
|
||||
|
@ -634,7 +634,7 @@ static char pause_monitor_action_help[] =
|
|||
" be used to control this:\n"
|
||||
" Channel - Required. Used to specify the channel to record.\n";
|
||||
|
||||
static int pause_monitor_action(struct mansession *s, struct message *m)
|
||||
static int pause_monitor_action(struct mansession *s, const struct message *m)
|
||||
{
|
||||
return do_pause_or_unpause(s, m, MONITOR_ACTION_PAUSE);
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ static char unpause_monitor_action_help[] =
|
|||
" be used to control this:\n"
|
||||
" Channel - Required. Used to specify the channel to record.\n";
|
||||
|
||||
static int unpause_monitor_action(struct mansession *s, struct message *m)
|
||||
static int unpause_monitor_action(struct mansession *s, const struct message *m)
|
||||
{
|
||||
return do_pause_or_unpause(s, m, MONITOR_ACTION_UNPAUSE);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
#include "asterisk/md5.h"
|
||||
#include "asterisk/linkedlists.h"
|
||||
#include "asterisk/manager.h"
|
||||
|
||||
#undef gethostbyname
|
||||
|
||||
|
@ -54,6 +53,13 @@
|
|||
*/
|
||||
#define _NEWT_CAST (void *)
|
||||
|
||||
#define DEFAULT_MANAGER_PORT 5038
|
||||
|
||||
struct message {
|
||||
unsigned int hdrcount;
|
||||
char headers[MAX_HEADERS][MAX_LEN];
|
||||
};
|
||||
|
||||
static struct ast_mansession {
|
||||
struct sockaddr_in sin;
|
||||
int fd;
|
||||
|
|
Reference in New Issue