mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-15 19:40:06 +00:00
mod_mono on Windows now looks for paths a bit better
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9585 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
ee5cdacf6c
commit
e9cc4dffe8
@ -24,7 +24,8 @@
|
|||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*
|
*
|
||||||
* Michael Giagnocavo <mgg@packetrino.com>
|
* Michael Giagnocavo <mgg@packetrino.com>
|
||||||
*
|
* David Brazier <David.Brazier@360crm.co.uk>
|
||||||
|
*
|
||||||
* mod_mono.cpp -- FreeSWITCH mod_mono main class
|
* mod_mono.cpp -- FreeSWITCH mod_mono main class
|
||||||
*
|
*
|
||||||
* Most of mod_mono is implmented in the mod_mono_managed Loader class.
|
* Most of mod_mono is implmented in the mod_mono_managed Loader class.
|
||||||
@ -88,44 +89,69 @@ SWITCH_MOD_DECLARE(void) InitMonoSession(MonoSession * session, MonoObject * dtm
|
|||||||
switch_status_t setMonoDirs()
|
switch_status_t setMonoDirs()
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/* Win32 Mono installs can't figure out their own path
|
// Win32 Mono installs can't figure out their own path
|
||||||
// Guys in #mono say we should just deploy all the libs we need
|
// Guys in #mono say we should just deploy all the libs we need
|
||||||
// I think it's much nicer to let the user deal with installing Mono
|
// We'll first check for Program Files\Mono to allow people to use the symlink dir for a specific version.
|
||||||
// and we'll just look for it in program files. */
|
// Then we'll check HKEY_LOCAL_MACHINE\SOFTWARE\Novell\Mono\2.0\FrameworkAssemblyDirectory and MonoConfigDir
|
||||||
HANDLE hFind;
|
// After that, we'll scan program files for a Mono-* dir.
|
||||||
WIN32_FIND_DATA findData;
|
|
||||||
char progFilesPath[MAX_PATH];
|
char progFilesPath[MAX_PATH];
|
||||||
|
char libPath[MAX_PATH];
|
||||||
|
char etcPath[MAX_PATH];
|
||||||
char findPath[MAX_PATH];
|
char findPath[MAX_PATH];
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, progFilesPath);
|
SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, progFilesPath);
|
||||||
switch_snprintf(findPath, MAX_PATH, "%s\\Mono-*", progFilesPath);
|
|
||||||
hFind = FindFirstFile(findPath, &findData);
|
|
||||||
if (hFind == INVALID_HANDLE_VALUE) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error looking for Mono in Program Files.\n");
|
|
||||||
return SWITCH_STATUS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
|
{ // Check PF\Mono directly
|
||||||
if (FindNextFile(hFind, &findData) == 0) {
|
DWORD attr;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find Mono directory in Program Files.\n");
|
switch_snprintf(findPath, MAX_PATH, "%s\\Mono", progFilesPath);
|
||||||
FindClose(hFind);
|
attr = GetFileAttributes(findPath);
|
||||||
return SWITCH_STATUS_FALSE;
|
found = (attr != INVALID_FILE_ATTRIBUTES && ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY));
|
||||||
|
if (found) {
|
||||||
|
switch_snprintf(libPath, MAX_PATH, "%s\\lib", findPath);
|
||||||
|
switch_snprintf(etcPath, MAX_PATH, "%s\\etc", findPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Got it */
|
if(!found)
|
||||||
{
|
{ // Check registry
|
||||||
char libPath[MAX_PATH];
|
DWORD size = MAX_PATH;
|
||||||
char etcPath[MAX_PATH];
|
if (ERROR_SUCCESS == RegGetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Novell\\Mono\\2.0", "FrameworkAssemblyDirectory", RRF_RT_REG_SZ, NULL, &libPath, &size)) {
|
||||||
|
size = MAX_PATH;
|
||||||
|
if (ERROR_SUCCESS == RegGetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Novell\\Mono\\2.0", "MonoConfigDir", RRF_RT_REG_SZ, NULL, &etcPath, &size)) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{ // Scan program files for Mono-2something
|
||||||
|
HANDLE hFind;
|
||||||
|
WIN32_FIND_DATA findData;
|
||||||
|
switch_snprintf(findPath, MAX_PATH, "%s\\Mono-2*", progFilesPath);
|
||||||
|
hFind = FindFirstFile(findPath, &findData);
|
||||||
|
if (hFind == INVALID_HANDLE_VALUE) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error looking for Mono in Program Files.\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
|
if (FindNextFile(hFind, &findData) == 0) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find Mono directory in Program Files.\n");
|
||||||
|
FindClose(hFind);
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch_snprintf(libPath, MAX_PATH, "%s\\%s\\lib", progFilesPath, findData.cFileName);
|
switch_snprintf(libPath, MAX_PATH, "%s\\%s\\lib", progFilesPath, findData.cFileName);
|
||||||
switch_snprintf(etcPath, MAX_PATH, "%s\\%s\\etc", progFilesPath, findData.cFileName);
|
switch_snprintf(etcPath, MAX_PATH, "%s\\%s\\etc", progFilesPath, findData.cFileName);
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Using Mono paths '%s' and '%s'.\n", libPath, etcPath);
|
|
||||||
mono_set_dirs(libPath, etcPath);
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Got it */
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Using Mono paths '%s' and '%s'.\n", libPath, etcPath);
|
||||||
|
mono_set_dirs(libPath, etcPath);
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// On other platforms, it should just work if it hasn't been relocated
|
// On other platforms, it should just work if it hasn't been relocated
|
||||||
mono_set_dirs(NULL, NULL);
|
mono_set_dirs(NULL, NULL);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*
|
*
|
||||||
* Michael Giagnocavo <mgg@packetrino.com>
|
* Michael Giagnocavo <mgg@packetrino.com>
|
||||||
|
* David Brazier <David.Brazier@360crm.co.uk>
|
||||||
*
|
*
|
||||||
* Loader.cs -- mod_mono managed loader
|
* Loader.cs -- mod_mono managed loader
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user