1 /*
2 * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3 * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4 *
5 * Version: MPL 1.1
6 *
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
16 *
17 * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18 *
19 * The Initial Developer of the Original Code is
20 * Anthony Minessale II <anthm@freeswitch.org>
21 * Portions created by the Initial Developer are Copyright (C)
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 *
26 * Anthony Minessale II <anthm@freeswitch.org>
27 * Rupa Schomaker <rupa@rupa.com>
28 *
29 *
30 * mod_limit.c -- backward compat module for transition to new core limits
31 *
32 */
33 #include <switch.h>
34
35 /* Prototypes */
36 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_limit_shutdown);
37 SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load);
38
39 SWITCH_MODULE_DEFINITION(mod_limit, mod_limit_load, mod_limit_shutdown, NULL);
40
SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load)41 SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load)
42 {
43 const char *err = NULL;
44 /* connect my internal structure to the blank pointer passed to me */
45 *module_interface = switch_loadable_module_create_module_interface(pool, modname);
46
47 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Loading mod_limit - a shim for backwards compatability with the new limit system. This is deprecated, remove mod_limit and instead load mod_hash and mod_db!\n");
48
49 /* try to load mod_hash if it isn't loaded */
50 if (switch_loadable_module_exists("mod_hash") != SWITCH_STATUS_SUCCESS) {
51 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "mod_hash not loaded, trying to load...!\n");
52 if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, "mod_hash", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
53 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load mod_hash (%s)!\n", err);
54 }
55 }
56
57 /* try to load mod_db if it isn't loaded */
58 if (switch_loadable_module_exists("mod_db") != SWITCH_STATUS_SUCCESS) {
59 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "mod_db not loaded, trying to load...!\n");
60 if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, "mod_db", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
61 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load mod_db (%s)!\n", err);
62 }
63 }
64
65 /* set compat flag */
66 switch_core_set_variable("switch_limit_backwards_compat_flag", "true");
67
68 /* indicate that the module should continue to be loaded */
69 return SWITCH_STATUS_SUCCESS;
70 }
71
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_limit_shutdown)72 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_limit_shutdown)
73 {
74 switch_core_set_variable("switch_limit_backwards_compat_flag", "false");
75 return SWITCH_STATUS_SUCCESS;
76 }
77
78 /* For Emacs:
79 * Local Variables:
80 * mode:c
81 * indent-tabs-mode:t
82 * tab-width:4
83 * c-basic-offset:4
84 * End:
85 * For VIM:
86 * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet
87 */
88