* Anthony Minessale II <anthmct@yahoo.com>
*
*
- * mod_dialplan_demo.c -- Example Dialplan Module
+ * mod_dialplan_flatfile.c -- Example Dialplan Module
*
*/
#include <switch.h>
#include <fcntl.h>
-static const char modname[] = "mod_dialplan_demo";
+static const char modname[] = "mod_dialplan_flatfile";
-static switch_caller_extension_t *demo_dialplan_hunt(switch_core_session_t *session)
+static switch_caller_extension_t *flatfile_dialplan_hunt(switch_core_session_t *session)
{
- switch_caller_profile_t *caller_profile;
+ switch_caller_profile_t *caller_profile = NULL;
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel;
char *cf = "extensions.conf";
switch_config_t cfg;
char *var, *val;
char app[1024];
+ char *context = NULL;
channel = switch_core_session_get_channel(session);
- caller_profile = switch_channel_get_caller_profile(channel);
- //switch_channel_set_variable(channel, "pleasework", "yay");
+
+ if ((caller_profile = switch_channel_get_caller_profile(channel))) {
+ context = caller_profile->context ? caller_profile->context : "default";
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
+ return NULL;
+ }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
- caller_profile->destination_number);
+ caller_profile->destination_number);
if (!switch_config_open_file(&cfg, cf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
}
while (switch_config_next_pair(&cfg, &var, &val)) {
- if (!strcasecmp(cfg.category, "extensions")) {
+ if (!strcasecmp(cfg.category, context)) {
if (!strcmp(var, caller_profile->destination_number) && val) {
char *data;
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
} else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Cannot locate extension %s in context %s\n", caller_profile->destination_number, context);
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
}
}
-static const switch_dialplan_interface_t demo_dialplan_interface = {
- /*.interface_name = */ "demo",
- /*.hunt_function = */ demo_dialplan_hunt
- /*.next = NULL */
+static const switch_dialplan_interface_t flatfile_dialplan_interface = {
+ /*.interface_name = */ "flatfile",
+ /*.hunt_function = */ flatfile_dialplan_hunt
+ /*.next = NULL */
};
-static const switch_loadable_module_interface_t demo_dialplan_module_interface = {
+static const switch_loadable_module_interface_t flatfile_dialplan_module_interface = {
/*.module_name = */ modname,
/*.endpoint_interface = */ NULL,
/*.timer_interface = */ NULL,
- /*.dialplan_interface = */ &demo_dialplan_interface,
+ /*.dialplan_interface = */ &flatfile_dialplan_interface,
/*.codec_interface = */ NULL,
/*.application_interface = */ NULL
};
{
/* connect my internal structure to the blank pointer passed to me */
- *module_interface = &demo_dialplan_module_interface;
+ *module_interface = &flatfile_dialplan_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
<VisualStudioProject\r
ProjectType="Visual C++"\r
Version="8.00"\r
- Name="mod_dialplan_demo"\r
+ Name="mod_dialplan_flatfile"\r
ProjectGUID="{2988EB83-785F-45D4-8731-8E1E4345177E}"\r
- RootNamespace="mod_dialplan_demo"\r
+ RootNamespace="mod_dialplan_flatfile"\r
Keyword="Win32Proj"\r
>\r
<Platforms>\r
/>\r
<Tool\r
Name="VCLinkerTool"\r
- OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_demo.dll"\r
+ OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"\r
LinkIncremental="2"\r
AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"\r
GenerateDebugInformation="true"\r
- ProgramDatabaseFile="$(OutDir)/mod_dialplan_demo.pdb"\r
+ ProgramDatabaseFile="$(OutDir)/mod_dialplan_flatfile.pdb"\r
SubSystem="2"\r
- ImportLibrary="$(OutDir)/mod_dialplan_demo.lib"\r
+ ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"\r
TargetMachine="1"\r
/>\r
<Tool\r
/>\r
<Tool\r
Name="VCLinkerTool"\r
- OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_demo.dll"\r
+ OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"\r
LinkIncremental="1"\r
AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"\r
GenerateDebugInformation="true"\r
SubSystem="2"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
- ImportLibrary="$(OutDir)/mod_dialplan_demo.lib"\r
+ ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"\r
TargetMachine="1"\r
/>\r
<Tool\r
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
>\r
<File\r
- RelativePath=".\mod_dialplan_demo.c"\r
+ RelativePath=".\mod_dialplan_flatfile.c"\r
>\r
</File>\r
</Filter>\r