]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8049 #resolve [Add getenv FSAPI]
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Aug 2015 22:26:31 +0000 (17:26 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Aug 2015 22:26:38 +0000 (17:26 -0500)
src/mod/applications/mod_commands/mod_commands.c

index 05a045b07fd4ab5391a059b143b08f7c4847e896..68e8d2a605d850ecb2f1455b089300b2bb1929d2 100644 (file)
@@ -6474,6 +6474,21 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown)
        return SWITCH_STATUS_SUCCESS;
 }
 
+#define GETENV_SYNTAX "<name>"
+SWITCH_STANDARD_API(getenv_function)
+{
+       const char *var = NULL;
+
+       if (cmd) {
+               var = getenv((char *)cmd);
+       }
+
+       stream->write_function(stream, "%s", var ? var : "_undef_");
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+
 #define LOG_SYNTAX "<level> <message>"
 SWITCH_STANDARD_API(log_function)
 {
@@ -6867,6 +6882,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "interface_ip", "Return the primary IP of an interface", interface_ip_function, INTERFACE_IP_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "switchname", "Return the switch name", switchname_api_function, "");
        SWITCH_ADD_API(commands_api_interface, "gethost", "gethostbyname", gethost_api_function, "");
+       SWITCH_ADD_API(commands_api_interface, "getenv", "getenv", getenv_function, GETENV_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "hupall", "hupall", hupall_api_function, "<cause> [<var> <value>]");
        SWITCH_ADD_API(commands_api_interface, "in_group", "Determine if a user is in a group", in_group_function, "<user>[@<domain>] <group_name>");
        SWITCH_ADD_API(commands_api_interface, "is_lan_addr", "See if an ip is a lan addr", lan_addr_function, "<ip>");