mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 00:43:02 +01:00
MacOS Port into HEAD - Minor mods
This commit is contained in:
parent
82a6c254ae
commit
facca2f278
@ -82,7 +82,7 @@ darwin_finish_cs_framework:
|
|||||||
cp ../gen/firebird/bin/fb_lock_mgr $(FB_FW)/Resources/bin
|
cp ../gen/firebird/bin/fb_lock_mgr $(FB_FW)/Resources/bin
|
||||||
cp ../gen/firebird/bin/fb_lock_print $(FB_FW)/Resources/bin
|
cp ../gen/firebird/bin/fb_lock_print $(FB_FW)/Resources/bin
|
||||||
cp ../gen/firebird/bin/gds_drop $(FB_FW)/Resources/bin
|
cp ../gen/firebird/bin/gds_drop $(FB_FW)/Resources/bin
|
||||||
cp ../gen/firebird/bin/gds_relay $(FB_FW)/Resources/bin
|
#cp ../gen/firebird/bin/gds_relay $(FB_FW)/Resources/bin
|
||||||
cp ../gen/firebird/bin/gsec $(FB_FW)/Resources/bin
|
cp ../gen/firebird/bin/gsec $(FB_FW)/Resources/bin
|
||||||
cp ../gen/firebird/bin/gstat $(FB_FW)/Resources/bin
|
cp ../gen/firebird/bin/gstat $(FB_FW)/Resources/bin
|
||||||
cp ../gen/firebird/bin/nbackup $(FB_FW)/Resources/bin
|
cp ../gen/firebird/bin/nbackup $(FB_FW)/Resources/bin
|
||||||
@ -94,6 +94,7 @@ darwin_finish_cs_framework:
|
|||||||
cp ../gen/firebird/misc/firebird.conf $(FB_FW)/Resources/English.lproj/var
|
cp ../gen/firebird/misc/firebird.conf $(FB_FW)/Resources/English.lproj/var
|
||||||
|
|
||||||
darwin_finish_ss_framework: FB_FW = ../gen/firebird/frameworks/FirebirdSS.framework
|
darwin_finish_ss_framework: FB_FW = ../gen/firebird/frameworks/FirebirdSS.framework
|
||||||
|
darwin_finish_ss_framework:
|
||||||
-$(RM) -rf $(FB_FW)
|
-$(RM) -rf $(FB_FW)
|
||||||
mkdir -p $(FB_FW)/Versions/A/Resources/English.lproj/var
|
mkdir -p $(FB_FW)/Versions/A/Resources/English.lproj/var
|
||||||
mkdir -p $(FB_FW)/Versions/A/Libraries
|
mkdir -p $(FB_FW)/Versions/A/Libraries
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* PROGRAM: Client/Server Common Code
|
* PROGRAM: Client/Server Common Code
|
||||||
* MODULE: config_root.cpp
|
* MODULE: config_root.cpp
|
||||||
* DESCRIPTION: Configuration manager (platform specific - linux/posix)
|
* DESCRIPTION: Configuration manager (platform specific - Darwin)
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the Initial
|
* The contents of this file are subject to the Initial
|
||||||
* Developer's Public License Version 1.0 (the "License");
|
* Developer's Public License Version 1.0 (the "License");
|
||||||
@ -17,7 +17,7 @@
|
|||||||
* The Original Code was created by John Bellardo
|
* The Original Code was created by John Bellardo
|
||||||
* for the Firebird Open Source RDBMS project.
|
* for the Firebird Open Source RDBMS project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2003 John Bellardo <bellardo at cs.ucsd.edu>
|
* Copyright (c) 2002 John Bellardo <bellardo at cs.ucsd.edu>
|
||||||
* and all contributors signed below.
|
* and all contributors signed below.
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
@ -38,39 +38,52 @@
|
|||||||
#include "../jrd/os/path_utils.h"
|
#include "../jrd/os/path_utils.h"
|
||||||
#include "../jrd/file_params.h"
|
#include "../jrd/file_params.h"
|
||||||
|
|
||||||
|
//#include <CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MacTypes.h>
|
||||||
|
|
||||||
|
#include </System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/MacTypes.h>
|
||||||
#include <CoreFoundation/CFBundle.h>
|
#include <CoreFoundation/CFBundle.h>
|
||||||
#include <CoreFoundation/CFURL.h>
|
#include <CoreFoundation/CFURL.h>
|
||||||
|
|
||||||
typedef Firebird::string string;
|
//typedef Firebird::string string;
|
||||||
|
|
||||||
#error This file needs revision, check the header file jrd/os/config_root.h
|
typedef Firebird::PathName string;
|
||||||
ConfigRoot::ConfigRoot()
|
|
||||||
|
//static const char *CONFIG_FILE = "firebird.conf";
|
||||||
|
|
||||||
|
void ConfigRoot::osConfigRoot()
|
||||||
{
|
{
|
||||||
|
CFBundleRef fbFramework;
|
||||||
|
CFURLRef msgFileUrl;
|
||||||
|
CFStringRef msgFilePath;
|
||||||
|
char file_buff[MAXPATHLEN];
|
||||||
|
|
||||||
// Check the environment variable
|
// Check the environment variable
|
||||||
Firebird::PathName envPath;
|
const char* envPath = getenv("FIREBIRD");
|
||||||
if (fb_utils::readenv("FIREBIRD", envPath))
|
if (envPath != NULL && strcmp("", envPath))
|
||||||
{
|
{
|
||||||
root_dir = envPath;
|
root_dir = envPath;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to locate the Firebird.framework bundle
|
// Attempt to locate the Firebird.framework bundle
|
||||||
CFURLRef msgFileUrl;
|
if ((fbFramework = CFBundleGetBundleWithIdentifier(
|
||||||
CFStringRef msgFilePath;
|
CFSTR(DARWIN_FRAMEWORK_ID)) ))
|
||||||
char file_buff[MAXPATHLEN];
|
|
||||||
|
|
||||||
CFBundleRef fbFramework = CFBundleGetBundleWithIdentifier(
|
|
||||||
CFSTR(DARWIN_FRAMEWORK_ID));
|
|
||||||
if (fbFramework
|
|
||||||
&& ((msgFileUrl = CFBundleCopyResourceURL(fbFramework,
|
|
||||||
CFSTR(DARWIN_GEN_DIR), NULL, NULL)))
|
|
||||||
&& ((msgFilePath = CFURLCopyFileSystemPath(msgFileUrl,
|
|
||||||
kCFURLPOSIXPathStyle)))
|
|
||||||
&& ((CFStringGetCString(msgFilePath, file_buff, MAXPATHLEN,
|
|
||||||
kCFStringEncodingMacRoman))) )
|
|
||||||
{
|
{
|
||||||
root_dir = file_buff;
|
if ((msgFileUrl = CFBundleCopyResourceURL( fbFramework,
|
||||||
return;
|
CFSTR(DARWIN_GEN_DIR), NULL, NULL)))
|
||||||
|
{
|
||||||
|
if ((msgFilePath = CFURLCopyFileSystemPath(msgFileUrl,
|
||||||
|
kCFURLPOSIXPathStyle)))
|
||||||
|
{
|
||||||
|
if ((CFStringGetCString(msgFilePath, file_buff, MAXPATHLEN,
|
||||||
|
kCFStringEncodingMacRoman )) )
|
||||||
|
{
|
||||||
|
root_dir = file_buff;
|
||||||
|
root_dir += PathUtils::dir_sep;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// As a last resort get it from the default install directory
|
// As a last resort get it from the default install directory
|
||||||
@ -79,11 +92,3 @@ ConfigRoot::ConfigRoot()
|
|||||||
root_dir = FB_PREFIX;
|
root_dir = FB_PREFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is already defined in the header, once the constructor problem
|
|
||||||
// is straightened it should disappear.
|
|
||||||
const char *ConfigRoot::getConfigFilePath() const
|
|
||||||
{
|
|
||||||
static string file = root_dir + string(CONFIG_FILE);
|
|
||||||
return file.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* PROGRAM: JRD Module Loader
|
* PROGRAM: JRD Module Loader
|
||||||
* MODULE: mod_loader.cpp
|
* MODULE: mod_loader.cpp
|
||||||
* DESCRIPTION: Darwin-specific class for loadable modules.
|
* DESCRIPTION: Darwin specific class for loadable modules.
|
||||||
*
|
*
|
||||||
* The contents of this file are subject to the Initial
|
* The contents of this file are subject to the Initial
|
||||||
* Developer's Public License Version 1.0 (the "License");
|
* Developer's Public License Version 1.0 (the "License");
|
||||||
@ -24,9 +24,8 @@
|
|||||||
* Contributor(s): ______________________________________.
|
* Contributor(s): ______________________________________.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../jrd/os/mod_loader.h"
|
#include "../jrd/os/mod_loader.h"
|
||||||
#include "common.h"
|
#include "../../common.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -45,7 +44,7 @@ private:
|
|||||||
NSModule module;
|
NSModule module;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ModuleLoader::isLoadableModule(const Firebird::string& module)
|
bool ModuleLoader::isLoadableModule(const Firebird::PathName& module)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
if (-1 == stat(module.c_str(), &sb))
|
if (-1 == stat(module.c_str(), &sb))
|
||||||
@ -57,24 +56,27 @@ bool ModuleLoader::isLoadableModule(const Firebird::string& module)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleLoader::doctorModuleExtention(Firebird::string& name)
|
void ModuleLoader::doctorModuleExtention(Firebird::PathName& name)
|
||||||
{
|
{
|
||||||
Firebird::string::size_type pos = name.rfind(".dylib");
|
Firebird::PathName::size_type pos = name.rfind(".dylib");
|
||||||
if (pos != Firebird::string::npos && pos == name.length() - 6)
|
if (pos != Firebird::PathName::npos && pos == name.length() - 6)
|
||||||
return; // No doctoring necessary
|
return; // No doctoring necessary
|
||||||
name += ".dylib";
|
name += ".dylib";
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::string& modPath)
|
ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::PathName& modPath)
|
||||||
{
|
{
|
||||||
NSObjectFileImage image;
|
NSObjectFileImage image;
|
||||||
|
NSObjectFileImageReturnCode retVal;
|
||||||
|
NSModule mod_handle;
|
||||||
|
NSSymbol initSym;
|
||||||
|
void (*init)(void);
|
||||||
|
|
||||||
/* Create an object file image from the given path */
|
/* Create an object file image from the given path */
|
||||||
const NSObjectFileImageReturnCode retVal =
|
retVal = NSCreateObjectFileImageFromFile(modPath.c_str(), &image);
|
||||||
NSCreateObjectFileImageFromFile(modPath.c_str(), &image);
|
if(retVal != NSObjectFileImageSuccess)
|
||||||
if (retVal != NSObjectFileImageSuccess)
|
|
||||||
{
|
{
|
||||||
switch (retVal)
|
switch(retVal)
|
||||||
{
|
{
|
||||||
case NSObjectFileImageFailure:
|
case NSObjectFileImageFailure:
|
||||||
/*printf("object file setup failure");*/
|
/*printf("object file setup failure");*/
|
||||||
@ -98,20 +100,18 @@ ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::string& modPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* link the image */
|
/* link the image */
|
||||||
NSModule mod_handle =
|
mod_handle = NSLinkModule(image, modPath.c_str(), NSLINKMODULE_OPTION_PRIVATE);
|
||||||
NSLinkModule(image, modPath.c_str(), NSLINKMODULE_OPTION_PRIVATE);
|
NSDestroyObjectFileImage(image) ;
|
||||||
NSDestroyObjectFileImage(image);
|
if(mod_handle == NULL)
|
||||||
if (mod_handle == NULL)
|
|
||||||
{
|
{
|
||||||
/*printf("NSLinkModule() failed for dlopen()");*/
|
/*printf("NSLinkModule() failed for dlopen()");*/
|
||||||
// We should really throw an error here.
|
// We should really throw an error here.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSSymbol initSym = NSLookupSymbolInModule(mod_handle, "__init");
|
initSym = NSLookupSymbolInModule(mod_handle, "__init");
|
||||||
if (initSym != NULL)
|
if (initSym != NULL)
|
||||||
{
|
{
|
||||||
void (*init)(void);
|
|
||||||
init = ( void (*)(void)) NSAddressOfSymbol(initSym);
|
init = ( void (*)(void)) NSAddressOfSymbol(initSym);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -121,11 +121,13 @@ ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::string& modPath)
|
|||||||
|
|
||||||
DarwinModule::~DarwinModule()
|
DarwinModule::~DarwinModule()
|
||||||
{
|
{
|
||||||
|
NSSymbol symbol;
|
||||||
|
void (*fini)(void);
|
||||||
|
|
||||||
/* Make sure the fini function gets called, if there is one */
|
/* Make sure the fini function gets called, if there is one */
|
||||||
NSSymbol symbol = NSLookupSymbolInModule(module, "__fini");
|
symbol = NSLookupSymbolInModule(module, "__fini");
|
||||||
if (symbol != NULL)
|
if (symbol != NULL)
|
||||||
{
|
{
|
||||||
void (*fini)(void);
|
|
||||||
fini = (void (*)(void)) NSAddressOfSymbol(symbol);
|
fini = (void (*)(void)) NSAddressOfSymbol(symbol);
|
||||||
fini();
|
fini();
|
||||||
}
|
}
|
||||||
@ -135,7 +137,9 @@ DarwinModule::~DarwinModule()
|
|||||||
|
|
||||||
void *DarwinModule::findSymbol(const Firebird::string& symName)
|
void *DarwinModule::findSymbol(const Firebird::string& symName)
|
||||||
{
|
{
|
||||||
NSSymbol symbol = NSLookupSymbolInModule(module, symName.c_str());
|
NSSymbol symbol;
|
||||||
|
|
||||||
|
symbol = NSLookupSymbolInModule(module, symName.c_str());
|
||||||
if (symbol == NULL)
|
if (symbol == NULL)
|
||||||
{
|
{
|
||||||
Firebird::string newSym = '_' + symName;
|
Firebird::string newSym = '_' + symName;
|
||||||
@ -148,4 +152,3 @@ void *DarwinModule::findSymbol(const Firebird::string& symName)
|
|||||||
}
|
}
|
||||||
return NSAddressOfSymbol(symbol);
|
return NSAddressOfSymbol(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user