提交 521eac75 authored 作者: Michael Jerris's avatar Michael Jerris

create macro to define api command prototypes.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5167 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 493fdf5b
......@@ -1018,7 +1018,11 @@ typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task);
typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *);
typedef struct switch_stream_handle switch_stream_handle_t;
typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
typedef switch_status_t (*switch_api_function_t) (const char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
typedef switch_status_t (*switch_api_function_t) (const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream);
#define SWITCH_STANDARD_API(name) static switch_status_t name (const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input,
switch_input_type_t input_type, void *buf, unsigned int buflen);
typedef struct switch_say_interface switch_say_interface_t;
......
......@@ -3445,7 +3445,7 @@ switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_h
}
/* API Interface Function */
static switch_status_t conf_api_main(const char *buf, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(conf_api_main)
{
char *lbuf = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
......@@ -3453,8 +3453,8 @@ static switch_status_t conf_api_main(const char *buf, switch_core_session_t *ses
int argc;
char *argv[25] = { 0 };
if (!buf) {
buf = "help";
if (!cmd) {
cmd = "help";
}
if (session) {
......@@ -3470,7 +3470,7 @@ static switch_status_t conf_api_main(const char *buf, switch_core_session_t *ses
stream->write_function(stream, "<pre>\n");
}
if (!(lbuf = strdup(buf))) {
if (!(lbuf = strdup(cmd))) {
return status;
}
......@@ -3486,7 +3486,7 @@ static switch_status_t conf_api_main(const char *buf, switch_core_session_t *ses
goto done;
}
if (argc >= 2) {
conf_api_dispatch(conference, stream, argc, argv, (const char *) buf, 1);
conf_api_dispatch(conference, stream, argc, argv, cmd, 1);
} else {
stream->write_function(stream, "Conference command, not specified.\nTry 'help'\n");
}
......
......@@ -502,14 +502,14 @@ static void strftime_function(switch_core_session_t *session, char *data)
}
static switch_status_t strepoch_api_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(strepoch_api_function)
{
switch_time_t out;
if (switch_strlen_zero(data)) {
if (switch_strlen_zero(cmd)) {
out = switch_time_now();
} else {
out = switch_str_time(data);
out = switch_str_time(cmd);
}
stream->write_function(stream, "%d", (uint32_t) ((out) / (int64_t) (1000000)));
......@@ -517,7 +517,7 @@ static switch_status_t strepoch_api_function(const char *data, switch_core_sessi
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t strftime_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(strftime_api_function)
{
switch_size_t retsize;
......@@ -525,20 +525,20 @@ static switch_status_t strftime_api_function(const char *fmt, switch_core_sessio
char date[80] = "";
switch_time_exp_lt(&tm, switch_time_now());
switch_strftime(date, &retsize, sizeof(date), fmt ? fmt : "%Y-%m-%d %T", &tm);
switch_strftime(date, &retsize, sizeof(date), cmd ? cmd : "%Y-%m-%d %T", &tm);
stream->write_function(stream, "%s", date);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t presence_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(presence_api_function)
{
switch_event_t *event;
char *lbuf, *argv[4];
int argc = 0;
switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
if (fmt && (lbuf = strdup(fmt))
if (cmd && (lbuf = strdup(cmd))
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
if (!strcasecmp(argv[0], "out")) {
type = SWITCH_EVENT_PRESENCE_OUT;
......@@ -568,12 +568,12 @@ static switch_status_t presence_api_function(const char *fmt, switch_core_sessio
}
static switch_status_t chat_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(chat_api_function)
{
char *lbuf, *argv[4];
int argc = 0;
if (fmt && (lbuf = strdup(fmt))
if (cmd && (lbuf = strdup(cmd))
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
switch_chat_interface_t *ci;
......
......@@ -625,7 +625,7 @@ static void enum_app_function(switch_core_session_t *session, char *data)
}
static switch_status_t enum_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(enum_function)
{
int argc = 0;
......@@ -640,7 +640,7 @@ static switch_status_t enum_function(const char *data, switch_core_session_t *se
return SWITCH_STATUS_FALSE;
}
if (!(mydata = strdup(data))) {
if (!cmd || !(mydata = strdup(cmd))) {
stream->write_function(stream, "Error!\n");
return SWITCH_STATUS_FALSE;
}
......
......@@ -1522,7 +1522,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t pa_cmd(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(pa_cmd)
{
char *argv[1024] = { 0 };
int argc = 0;
......
......@@ -2028,7 +2028,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
}
}
static switch_status_t dl_debug(const char *tf, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(dl_debug)
{
int on, cur;
......@@ -2036,8 +2036,8 @@ static switch_status_t dl_debug(const char *tf, switch_core_session_t *session,
return SWITCH_STATUS_FALSE;
}
if (tf) {
on = switch_true(tf);
if (cmd) {
on = switch_true(cmd);
cur = ldl_global_debug(on);
} else {
cur = ldl_global_debug(-1);
......@@ -2049,7 +2049,7 @@ static switch_status_t dl_debug(const char *tf, switch_core_session_t *session,
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t dl_pres(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(dl_pres)
{
mdl_profile_t *profile;
......@@ -2057,26 +2057,26 @@ static switch_status_t dl_pres(const char *profile_name, switch_core_session_t *
return SWITCH_STATUS_FALSE;
}
if (!profile_name) {
if (!cmd) {
stream->write_function(stream, "USAGE: %s\n", pres_api_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
if ((profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
if ((profile = switch_core_hash_find(globals.profile_hash, cmd))) {
if (profile->user_flags & LDL_FLAG_COMPONENT) {
sign_on(profile);
stream->write_function(stream, "OK\n");
} else {
stream->write_function(stream, "NO PROFILE %s NOT A COMPONENT\n", profile_name);
stream->write_function(stream, "NO PROFILE %s NOT A COMPONENT\n", cmd);
}
} else {
stream->write_function(stream, "NO SUCH PROFILE %s\n", profile_name);
stream->write_function(stream, "NO SUCH PROFILE %s\n", cmd);
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t dl_logout(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(dl_logout)
{
mdl_profile_t *profile;
......@@ -2084,22 +2084,22 @@ static switch_status_t dl_logout(const char *profile_name, switch_core_session_t
return SWITCH_STATUS_FALSE;
}
if (!profile_name) {
if (!cmd) {
stream->write_function(stream, "USAGE: %s\n", logout_api_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
if ((profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
if ((profile = switch_core_hash_find(globals.profile_hash, cmd))) {
ldl_handle_stop(profile->handle);
stream->write_function(stream, "OK\n");
} else {
stream->write_function(stream, "NO SUCH PROFILE %s\n", profile_name);
stream->write_function(stream, "NO SUCH PROFILE %s\n", cmd);
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t dl_login(const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(dl_login)
{
char *argv[10] = { 0 };
int argc = 0;
......@@ -2111,16 +2111,16 @@ static switch_status_t dl_login(const char *arg, switch_core_session_t *session,
return SWITCH_STATUS_FALSE;
}
if (switch_strlen_zero(arg)) {
if (switch_strlen_zero(cmd)) {
stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
myarg = strdup(arg);
myarg = strdup(cmd);
argc = switch_separate_string(myarg, ';', argv, (sizeof(argv) / sizeof(argv[0])));
if (switch_strlen_zero(arg) || argc != 1) {
if (switch_strlen_zero(cmd) || argc != 1) {
stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
......
......@@ -1711,13 +1711,13 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t padep(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(padep)
{
stream->write_function(stream, "This command no longer exists (try 'pa help')\n");
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t pa_cmd(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(pa_cmd)
{
char *argv[1024] = { 0 };
int argc = 0;
......
......@@ -1175,7 +1175,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(sofia_function)
{
char *argv[1024] = { 0 };
int argc = 0;
......@@ -1190,7 +1190,7 @@ static switch_status_t sofia_function(const char *cmd, switch_core_session_t *is
"sofia status [[profile | gateway] <name>]\n"
"--------------------------------------------------------------------------------\n";
if (isession) {
if (session) {
return SWITCH_STATUS_FALSE;
}
......
......@@ -151,7 +151,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM;
}
static switch_status_t modcdr_reload(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
SWITCH_STANDARD_API(modcdr_reload)
{
#ifdef SWITCH_QUEUE_ENHANCED
switch_thread_rwlock_wrlock(cdr_rwlock);
......@@ -164,7 +164,7 @@ static switch_status_t modcdr_reload(const char *dest=0, switch_core_session_t *
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t modcdr_queue_pause(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
SWITCH_STANDARD_API(modcdr_queue_pause)
{
#ifdef SWITCH_QUEUE_ENHANCED
newcdrcontainer->queue_pause(stream);
......@@ -174,7 +174,7 @@ static switch_status_t modcdr_queue_pause(const char *dest=0, switch_core_sessio
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t modcdr_queue_resume(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
SWITCH_STANDARD_API(modcdr_queue_resume)
{
#ifdef SWITCH_QUEUE_ENHANCED
newcdrcontainer->queue_resume(stream);
......@@ -184,13 +184,13 @@ static switch_status_t modcdr_queue_resume(const char *dest=0, switch_core_sessi
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t modcdr_show_active(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
SWITCH_STANDARD_API(modcdr_show_active)
{
newcdrcontainer->active(stream);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t modcdr_show_available(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
SWITCH_STANDARD_API(modcdr_show_available)
{
newcdrcontainer->available(stream);
return SWITCH_STATUS_SUCCESS;
......
......@@ -161,14 +161,14 @@ static void *SWITCH_THREAD_FUNC py_thread_run(switch_thread_t *thread, void *obj
return NULL;
}
static switch_status_t launch_python(const char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(launch_python)
{
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
switch_memory_pool_t *pool;
struct switch_py_thread *pt;
if (switch_strlen_zero(text)) {
if (switch_strlen_zero(cmd)) {
stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
......@@ -180,7 +180,7 @@ static switch_status_t launch_python(const char *text, switch_core_session_t *se
assert(pt != NULL);
pt->pool = pool;
pt->args = switch_core_strdup(pt->pool, text);
pt->args = switch_core_strdup(pt->pool, cmd);
switch_threadattr_create(&thd_attr, pt->pool);
switch_threadattr_detach_set(thd_attr, 1);
......
......@@ -2739,15 +2739,15 @@ static void js_thread_launch(const char *text)
}
static switch_status_t launch_async(const char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
SWITCH_STANDARD_API(launch_async)
{
if (switch_strlen_zero(text)) {
if (switch_strlen_zero(cmd)) {
stream->write_function(stream, "USAGE: %s\n", js_run_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
js_thread_launch(text);
js_thread_launch(cmd);
stream->write_function(stream, "OK\n");
return SWITCH_STATUS_SUCCESS;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论