]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9096: [mod_commands] new uuid argument for bgapi
authorVitaly Kovalyshyn <v.kovalyshyn@webitel.com>
Fri, 28 Jul 2017 12:01:39 +0000 (15:01 +0300)
committerVitaly Kovalyshyn <v.kovalyshyn@webitel.com>
Fri, 28 Jul 2017 12:01:39 +0000 (15:01 +0300)
src/mod/applications/mod_commands/mod_commands.c

index e592b3fabcd5c68e6cd87416732e86145d8adb36..5082a60d9ad2ec686d73028d7405ad2a2f3a74a2 100644 (file)
@@ -5178,19 +5178,38 @@ SWITCH_STANDARD_API(bgapi_function)
        switch_memory_pool_t *pool;
        switch_thread_t *thread;
        switch_threadattr_t *thd_attr = NULL;
+       
+       const char *p, *arg = cmd;
+       char my_uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
 
        if (!cmd) {
                stream->write_function(stream, "-ERR Invalid syntax\n");
                return SWITCH_STATUS_SUCCESS;
        }
 
+       if (!strncasecmp(cmd, "uuid:", 5)) {
+               p = cmd + 5;
+               if ((arg = strchr(p, ' ')) && *arg++) {
+                       switch_copy_string(my_uuid, p, arg - p);
+               }
+       }
+
+       if (zstr(arg)) {
+               stream->write_function(stream, "-ERR Invalid syntax\n");
+               return SWITCH_STATUS_SUCCESS;
+       }
+
        switch_core_new_memory_pool(&pool);
        job = switch_core_alloc(pool, sizeof(*job));
-       job->cmd = switch_core_strdup(pool, cmd);
+       job->cmd = switch_core_strdup(pool, arg);
        job->pool = pool;
 
-       switch_uuid_get(&uuid);
-       switch_uuid_format(job->uuid_str, &uuid);
+       if (*my_uuid) {
+               switch_copy_string(job->uuid_str, my_uuid, strlen(my_uuid)+1);
+       } else {
+               switch_uuid_get(&uuid);
+               switch_uuid_format(job->uuid_str, &uuid);
+       }
 
        switch_threadattr_create(&thd_attr, job->pool);
        switch_threadattr_detach_set(thd_attr, 1);