42 for(i=0; *cmd !=
' ' && *cmd !=
'\t' && *cmd !=
'\n' && *cmd !=
'\0'; cmd++, i++);
64 priority = strtol(cmd, &cont, 10);
66 if(cmd == cont) priority = -1;
67 if(priority < -128) priority = -128;
68 if(priority > 127) priority = 127;
70 snprintf(prioritystr, 5,
"%ld", priority);
74 while(*cmd ==
' ') { cmd++; }
78 if(!strncmp(
"CHAT", cmd, 4)) {
82 if(!strncmp(
"ONLINE", cmd, 6)) {
85 if(!strncmp(
"DND", cmd, 3)) {
89 if(!strncmp(
"AWAY", cmd, 4)) {
93 if(!strncmp(
"XA", cmd, 2)) {
103 while(*cmd ==
' ') { cmd++; }
105 if(*cmd !=
'\0' && *cmd !=
'\n') {
106 int len = strlen(cmd);
123 char hashbuf[44] =
"PBX";
126 sesshash = hashbuf+3;
129 if(!strncasecmp(
"START ", cmd, 6)) {
133 if(!strncasecmp(
"STOP ", cmd, 5)) {
143 if(*cmd !=
'\0') cmd++;
158 snprintf(sess->
skey,
sizeof(sess->
skey),
"%s", hashbuf);
161 sess->resources = (
bres_t) calloc(1,
sizeof(
struct bres_st));
162 snprintf(sess->resources->c2s_id,
sizeof(sess->resources->c2s_id),
"%s", hashbuf);
163 sess->resources->jid = jid;
165 log_write(sess->c2s->log, LOG_NOTICE,
"[PBX] requesting session: jid=%s",
jid_full(jid));
201 if(!strncasecmp(
"STATUS", cmd, 6)) {
202 log_write(c2s->
log, LOG_INFO,
"STATUS PBX command not implemented yet");
C2S_API void sm_end(sess_t sess, bres_t res)
nad_t nad_new(void)
create a new nad
int nad_append_attr(nad_t nad, int ns, const char *name, const char *val)
attach new attr to the last elem
const char * jid_user(jid_t jid)
expand and return the user
const char * jid_full(jid_t jid)
expand and return the full
jid_t jid_new(const char *id, int len)
make a new jid
static nad_t _pbx_presence_nad(int available, const char *cmd)
void nad_append_cdata(nad_t nad, const char *cdata, int len, int depth)
append new cdata to the last elem
void log_write(log_t log, int level, const char *msgfmt,...)
C2S_API void sm_packet(sess_t sess, bres_t res, nad_t nad)
void shahash_r(const char *str, char hashbuf[41])
convenience (originally by Thomas Muldowney)
list of resources bound to session
int nad_add_namespace(nad_t nad, const char *uri, const char *prefix)
bring a new namespace into scope
int nad_append_elem(nad_t nad, int ns, const char *name, int depth)
create a new elem on the list
void jqueue_push(jqueue_t q, void *data, int priority)
void xhash_put(xht h, const char *key, void *val)
int _pbx_process_command(c2s_t c2s, const char *cmd)
process commandline
void xhash_zap(xht h, const char *key)
C2S_API void sm_start(sess_t sess, bres_t res)
jqueue_t dead_sess
list of sess on the way out
There is one instance of this struct per user who is logged in to this c2s instance.
void * xhash_get(xht h, const char *key)
static int _pbx_command_part_len(const char *cmd)
Available commands: START jid/resource [[priority ]status] [description] - opens PBX resource session...