~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Source/cmDynamicLoader.h

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2005-03-02 09:22:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050302092244-y6o9j8wr27vqcqvx
Tags: 2.0.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   CMake - Cross-Platform Makefile Generator
 
4
  Module:    $RCSfile: cmDynamicLoader.h,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2002/10/23 22:03:26 $
 
7
  Version:   $Revision: 1.5 $
 
8
 
 
9
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
 
10
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
 
11
 
 
12
     This software is distributed WITHOUT ANY WARRANTY; without even 
 
13
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
14
     PURPOSE.  See the above copyright notices for more information.
 
15
 
 
16
=========================================================================*/
 
17
// .NAME cmDynamicLoader - class interface to system dynamic libraries
 
18
// .SECTION Description
 
19
// cmDynamicLoader provides a portable interface to loading dynamic 
 
20
// libraries into a process.  
 
21
 
 
22
 
 
23
#ifndef __cmDynamicLoader_h
 
24
#define __cmDynamicLoader_h
 
25
 
 
26
#include "cmStandardIncludes.h"
 
27
 
 
28
// Ugly stuff for library handles
 
29
// They are different on several different OS's
 
30
#if defined(__hpux)
 
31
# include <dl.h>
 
32
  typedef shl_t cmLibHandle;
 
33
#elif defined(_WIN32)
 
34
  #include <windows.h>
 
35
  typedef HMODULE cmLibHandle;
 
36
#else
 
37
  typedef void* cmLibHandle;
 
38
#endif
 
39
 
 
40
// Return type from cmDynamicLoader::GetSymbolAddress.
 
41
typedef void (*cmDynamicLoaderFunction)();
 
42
 
 
43
class cmDynamicLoader
 
44
{
 
45
public:
 
46
  // Description:
 
47
  // Load a dynamic library into the current process.
 
48
  // The returned cmLibHandle can be used to access the symbols in the 
 
49
  // library.
 
50
  static cmLibHandle OpenLibrary(const char*);
 
51
 
 
52
  // Description:
 
53
  // Attempt to detach a dynamic library from the
 
54
  // process.  A value of true is returned if it is successful.
 
55
  static int CloseLibrary(cmLibHandle);
 
56
  
 
57
  // Description:
 
58
  // Find the address of the symbol in the given library
 
59
  static cmDynamicLoaderFunction GetSymbolAddress(cmLibHandle, const char*);
 
60
 
 
61
  // Description:
 
62
  // Return the library prefix for the given architecture
 
63
  static const char* LibPrefix();
 
64
 
 
65
  // Description:
 
66
  // Return the library extension for the given architecture
 
67
  static const char* LibExtension();
 
68
 
 
69
  // Description:
 
70
  // Return the last error produced from a calls made on this class.
 
71
  static const char* LastError();
 
72
 
 
73
  // Description:
 
74
  // Flush the cache of dynamic loader.
 
75
  static void FlushCache();
 
76
  
 
77
protected:
 
78
  cmDynamicLoader() {};
 
79
  ~cmDynamicLoader() {};
 
80
 
 
81
  
 
82
private:
 
83
  cmDynamicLoader(const cmDynamicLoader&);  // Not implemented.
 
84
  void operator=(const cmDynamicLoader&);  // Not implemented.
 
85
};
 
86
 
 
87
#endif