8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 21:23:04 +01:00

MacOS Port into HEAD - Minor mods

This commit is contained in:
paulbeach 2007-06-13 10:07:22 +00:00
parent 82a6c254ae
commit facca2f278
3 changed files with 65 additions and 56 deletions

View File

@ -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_print $(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/gstat $(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
darwin_finish_ss_framework: FB_FW = ../gen/firebird/frameworks/FirebirdSS.framework
darwin_finish_ss_framework:
-$(RM) -rf $(FB_FW)
mkdir -p $(FB_FW)/Versions/A/Resources/English.lproj/var
mkdir -p $(FB_FW)/Versions/A/Libraries

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: Client/Server Common Code
* MODULE: config_root.cpp
* DESCRIPTION: Configuration manager (platform specific - linux/posix)
* PROGRAM: Client/Server Common Code
* MODULE: config_root.cpp
* DESCRIPTION: Configuration manager (platform specific - Darwin)
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
@ -17,7 +17,7 @@
* The Original Code was created by John Bellardo
* 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.
*
* All Rights Reserved.
@ -38,39 +38,52 @@
#include "../jrd/os/path_utils.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/CFURL.h>
typedef Firebird::string string;
//typedef Firebird::string string;
#error This file needs revision, check the header file jrd/os/config_root.h
ConfigRoot::ConfigRoot()
typedef Firebird::PathName string;
//static const char *CONFIG_FILE = "firebird.conf";
void ConfigRoot::osConfigRoot()
{
CFBundleRef fbFramework;
CFURLRef msgFileUrl;
CFStringRef msgFilePath;
char file_buff[MAXPATHLEN];
// Check the environment variable
Firebird::PathName envPath;
if (fb_utils::readenv("FIREBIRD", envPath))
const char* envPath = getenv("FIREBIRD");
if (envPath != NULL && strcmp("", envPath))
{
root_dir = envPath;
return;
}
// Attempt to locate the Firebird.framework bundle
CFURLRef msgFileUrl;
CFStringRef msgFilePath;
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))) )
if ((fbFramework = CFBundleGetBundleWithIdentifier(
CFSTR(DARWIN_FRAMEWORK_ID)) ))
{
root_dir = file_buff;
return;
if ((msgFileUrl = CFBundleCopyResourceURL( fbFramework,
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
@ -79,11 +92,3 @@ ConfigRoot::ConfigRoot()
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();
}

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: JRD Module Loader
* 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
* Developer's Public License Version 1.0 (the "License");
@ -24,9 +24,8 @@
* Contributor(s): ______________________________________.
*
*/
#include "../jrd/os/mod_loader.h"
#include "common.h"
#include "../../common.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -45,7 +44,7 @@ private:
NSModule module;
};
bool ModuleLoader::isLoadableModule(const Firebird::string& module)
bool ModuleLoader::isLoadableModule(const Firebird::PathName& module)
{
struct stat sb;
if (-1 == stat(module.c_str(), &sb))
@ -57,24 +56,27 @@ bool ModuleLoader::isLoadableModule(const Firebird::string& module)
return true;
}
void ModuleLoader::doctorModuleExtention(Firebird::string& name)
void ModuleLoader::doctorModuleExtention(Firebird::PathName& name)
{
Firebird::string::size_type pos = name.rfind(".dylib");
if (pos != Firebird::string::npos && pos == name.length() - 6)
Firebird::PathName::size_type pos = name.rfind(".dylib");
if (pos != Firebird::PathName::npos && pos == name.length() - 6)
return; // No doctoring necessary
name += ".dylib";
}
ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::string& modPath)
ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::PathName& modPath)
{
NSObjectFileImage image;
NSObjectFileImageReturnCode retVal;
NSModule mod_handle;
NSSymbol initSym;
void (*init)(void);
/* Create an object file image from the given path */
const NSObjectFileImageReturnCode retVal =
NSCreateObjectFileImageFromFile(modPath.c_str(), &image);
if (retVal != NSObjectFileImageSuccess)
retVal = NSCreateObjectFileImageFromFile(modPath.c_str(), &image);
if(retVal != NSObjectFileImageSuccess)
{
switch (retVal)
switch(retVal)
{
case NSObjectFileImageFailure:
/*printf("object file setup failure");*/
@ -98,20 +100,18 @@ ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::string& modPath)
}
/* link the image */
NSModule mod_handle =
NSLinkModule(image, modPath.c_str(), NSLINKMODULE_OPTION_PRIVATE);
NSDestroyObjectFileImage(image);
if (mod_handle == NULL)
mod_handle = NSLinkModule(image, modPath.c_str(), NSLINKMODULE_OPTION_PRIVATE);
NSDestroyObjectFileImage(image) ;
if(mod_handle == NULL)
{
/*printf("NSLinkModule() failed for dlopen()");*/
// We should really throw an error here.
return 0;
}
NSSymbol initSym = NSLookupSymbolInModule(mod_handle, "__init");
initSym = NSLookupSymbolInModule(mod_handle, "__init");
if (initSym != NULL)
{
void (*init)(void);
init = ( void (*)(void)) NSAddressOfSymbol(initSym);
init();
}
@ -121,11 +121,13 @@ ModuleLoader::Module *ModuleLoader::loadModule(const Firebird::string& modPath)
DarwinModule::~DarwinModule()
{
NSSymbol symbol;
void (*fini)(void);
/* Make sure the fini function gets called, if there is one */
NSSymbol symbol = NSLookupSymbolInModule(module, "__fini");
symbol = NSLookupSymbolInModule(module, "__fini");
if (symbol != NULL)
{
void (*fini)(void);
fini = (void (*)(void)) NSAddressOfSymbol(symbol);
fini();
}
@ -135,7 +137,9 @@ DarwinModule::~DarwinModule()
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)
{
Firebird::string newSym = '_' + symName;
@ -148,4 +152,3 @@ void *DarwinModule::findSymbol(const Firebird::string& symName)
}
return NSAddressOfSymbol(symbol);
}