8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 00:03:03 +01:00

Firebird 2.0 MacOS Classic Intel Build - Missed 1st time round

This commit is contained in:
paulbeach 2007-03-26 11:36:36 +00:00
parent a8d6016262
commit ae966b05bc
2 changed files with 88 additions and 91 deletions

View File

@ -1,28 +1,38 @@
/*
* PROGRAM: Client/Server Common Code
* MODULE: config_root.cpp
* PROGRAM: Client/Server Common Code
* MODULE: config_root.cpp
* DESCRIPTION: Configuration manager (platform specific - linux/posix)
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* You may obtain a copy of the Licence at
* http://www.gnu.org/licences/lgpl.html
*
* As a special exception this file can also be included in modules
* with other source code as long as that source code has been
* released under an Open Source Initiative certificed licence.
* More information about OSI certification can be found at:
* http://www.opensource.org
*
* This module is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public Licence for more details.
*
* This module was created by members of the firebird development
* team. All individual contributions remain the Copyright (C) of
* those individuals and all rights are reserved. Contributors to
* this file are either listed below or can be obtained from a CVS
* history command.
*
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
* Created by: Mark O'Donohue <skywalker@users.sourceforge.net>
*
* 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>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* Contributor(s):
*
*
* $Id: config_root.cpp,v 1.5.4.1 2007-03-26 11:36:36 paulbeach Exp $
*/
#include "firebird.h"
@ -38,39 +48,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 +102,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,32 +1,10 @@
/*
* PROGRAM: JRD Module Loader
* MODULE: mod_loader.cpp
* 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");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
*
* The Original Code was created by John Bellardo
* for the Firebird Open Source RDBMS project.
*
* Copyright (c) 2002 John Bellardo <bellardo at cs.ucsd.edu>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* mod_loader.cpp
*
*/
#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 +23,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 +35,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 +79,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 +100,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 +116,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 +131,3 @@ void *DarwinModule::findSymbol(const Firebird::string& symName)
}
return NSAddressOfSymbol(symbol);
}