[Freeswitch-svn] [commit] r2144 - freeswitch/trunk/src/mod/applications/mod_dptools
Freeswitch SVN
anthm at freeswitch.org
Tue Jul 25 19:51:38 EDT 2006
Author: anthm
Date: Tue Jul 25 19:51:38 2006
New Revision: 2144
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
Log:
Add strftime app to the dp_tools
Use in the dialplan like so:
<!-- continue="true" means keep searching even when you have a match -->
<extension name="set-date" continue="true">
<condition>
<action application="strftime" data="NOW=%H:%M"/>
</condition>
</extension>
<extension name="route-date">
<condition field="$NOW" expression="^0[34].*">
<action application="playback" data="/tmp/cluecon1.wav"/>
</condition>
</extension>
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Jul 25 19:51:38 2006
@@ -71,16 +71,47 @@
}
}
+static void strftime_function(switch_core_session_t *session, char *data)
+{
+ char *argv[2];
+ int argc;
+ char *lbuf;
+
+ if ((lbuf = switch_core_session_strdup(session, data))&&(argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
+ switch_size_t retsize;
+ switch_time_exp_t tm;
+ char date[80] = "";
+ switch_channel_t *channel;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ switch_time_exp_lt(&tm, switch_time_now());
+ switch_strftime(date, &retsize, sizeof(date), argv[1], &tm);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date);
+ switch_channel_set_variable(channel, argv[0], date);
+ }
+
+}
+
static const switch_application_interface_t set_application_interface = {
/*.interface_name */ "set",
/*.application_function */ set_function
};
+static const switch_application_interface_t strftime_application_interface = {
+ /*.interface_name */ "strftime",
+ /*.application_function */ strftime_function,
+ NULL,NULL,NULL,
+ &set_application_interface
+
+};
+
static const switch_application_interface_t sleep_application_interface = {
/*.interface_name */ "sleep",
/*.application_function */ sleep_function,
NULL,NULL,NULL,
- &set_application_interface
+ &strftime_application_interface
};
static const switch_loadable_module_interface_t mod_dptools_module_interface = {
More information about the Freeswitch-svn
mailing list