<commit_before>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkDynamicLoader.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "itkDynamicLoader.h"

// This file is actually 3 different implementations.
// 1. HP machines which uses shl_load
// 2. Power PC MAC which uses GetSharedLibrary
// 3. Windows which uses LoadLibrary
// 4. Most unix systems which use dlopen (default )
// Each part of the ifdef contains a complete implementation for
// the static methods of DynamicLoader.  


// ---------------------------------------------------------------
// 1. Implementation for HPUX  machines
#ifdef __hpux
#define ITKDYNAMICLOADER_DEFINED 1
#include <dl.h>

namespace itk
{

//----------------------------------------------------------------------------
LibHandle 
DynamicLoader
::OpenLibrary(const char* libname )
{
  return shl_load(libname, BIND_DEFERRED | DYNAMIC_PATH, 0L);
}

int 
DynamicLoader::
CloseLibrary(LibHandle lib)
{
  return 0;
}

//----------------------------------------------------------------------------
void* 
DynamicLoader
::GetSymbolAddress(LibHandle lib, const char* sym)
{ 
  void* addr;
  int status;
  
  status = shl_findsym (&lib, sym, TYPE_PROCEDURE, &addr);
  return (status < 0) ? (void*)0 : addr;
}

//----------------------------------------------------------------------------
const char* 
DynamicLoader
::LibPrefix()
{ 
  return "lib";
}

//----------------------------------------------------------------------------
const char* 
DynamicLoader
::LibExtension()
{
  return ".sl";
}

//----------------------------------------------------------------------------
const char* 
DynamicLoader
::LastError()
{
  return 0;
}

} // end namespace itk

#endif


// ---------------------------------------------------------------
// 2. Implementation for the Power PC (MAC)
#ifdef __APPLE__
#define ITKDYNAMICLOADER_DEFINED 
#include <mach-o/dyld.h>

namespace itk
{

//----------------------------------------------------------------------------
LibHandle 
DynamicLoader
::OpenLibrary(const char* libname )
{
  NSObjectFileImageReturnCode rc;
  NSObjectFileImage image;
  
  rc = NSCreateObjectFileImageFromFile(libname, &image);
  return NSLinkModule(image, libname, TRUE);
}

//----------------------------------------------------------------------------
int 
DynamicLoader
::CloseLibrary(LibHandle lib)
{
  return 0;
}

//----------------------------------------------------------------------------
void* 
DynamicLoader
::GetSymbolAddress(LibHandle lib, const char* sym)
{ 
  void *result=0;
  if(NSIsSymbolNameDefined(sym))
    {
    NSSymbol symbol= NSLookupAndBindSymbol(sym);
    if(symbol)
      {
      result = NSAddressOfSymbol(symbol);
      }
    }
  return result;
}<commit_msg>FIX: Warnings: Unused arguments removed. Added as comments in front.<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkDynamicLoader.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "itkDynamicLoader.h"

// This file is actually 3 different implementations.
// 1. HP machines which uses shl_load
// 2. Power PC MAC which uses GetSharedLibrary
// 3. Windows which uses LoadLibrary
// 4. Most unix systems which use dlopen (default )
// Each part of the ifdef contains a complete implementation for
// the static methods of DynamicLoader.  


// ---------------------------------------------------------------
// 1. Implementation for HPUX  machines
#ifdef __hpux
#define ITKDYNAMICLOADER_DEFINED 1
#include <dl.h>

namespace itk
{

//----------------------------------------------------------------------------
LibHandle 
DynamicLoader
::OpenLibrary(const char* libname )
{
  return shl_load(libname, BIND_DEFERRED | DYNAMIC_PATH, 0L);
}

int 
DynamicLoader::
CloseLibrary(LibHandle lib)
{
  return 0;
}

//----------------------------------------------------------------------------
void* 
DynamicLoader
::GetSymbolAddress(LibHandle lib, const char* sym)
{ 
  void* addr;
  int status;
  
  status = shl_findsym (&lib, sym, TYPE_PROCEDURE, &addr);
  return (status < 0) ? (void*)0 : addr;
}

//----------------------------------------------------------------------------
const char* 
DynamicLoader
::LibPrefix()
{ 
  return "lib";
}

//----------------------------------------------------------------------------
const char* 
DynamicLoader
::LibExtension()
{
  return ".sl";
}

//----------------------------------------------------------------------------
const char* 
DynamicLoader
::LastError()
{
  return 0;
}

} // end namespace itk

#endif


// ---------------------------------------------------------------
// 2. Implementation for the Power PC (MAC)
#ifdef __APPLE__
#define ITKDYNAMICLOADER_DEFINED 
#include <mach-o/dyld.h>

namespace itk
{

//----------------------------------------------------------------------------
LibHandle 
DynamicLoader
::OpenLibrary(const char* libname )
{
  NSObjectFileImageReturnCode rc;
  NSObjectFileImage image;
  
  rc = NSCreateObjectFileImageFromFile(libname, &image);
  return NSLinkModule(image, libname, TRUE);
}

//----------------------------------------------------------------------------
int 
DynamicLoader
::CloseLibrary( LibHandle ) // argument expected (LibHandle lib)
{
  return 0;
}

//----------------------------------------------------------------------------
void* 
DynamicLoader
::GetSymbolAddress(LibHandle , const char* sym) // (LibHandle lib)
{ 
  void *result=0;
  if(NSIsSymbolNameDefined(sym))
    {
    NSSymbol symbol= NSLookupAndBindSymbol(sym);
    if(symbol)
      {
      result = NSAddressOfSymbol(symbol);
      }
    }
  return result;
}
{'fraction_non_alphanumeric': 0.3402340234023402, 'fraction_numerical': 0.005700570057005701, 'mean_word_length': 1.6320568495854717, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2624364', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1641, 'n_words': 484}