author | kergoth <kergoth> | 2002-11-01 00:10:42 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-11-01 00:10:42 (UTC) |
commit | 5042e3cf0d3514552769e441f5aad590c8eaf967 (patch) (unidiff) | |
tree | 4a5ea45f3519d981a172ab5275bf38c6fa778dec /qmake/tools/qlibrary_unix.cpp | |
parent | 108c1c753e74e989cc13923086996791428c9af4 (diff) | |
download | opie-5042e3cf0d3514552769e441f5aad590c8eaf967.zip opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.gz opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.bz2 |
Adding qmake in preperation for new build system
Diffstat (limited to 'qmake/tools/qlibrary_unix.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/tools/qlibrary_unix.cpp | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/qmake/tools/qlibrary_unix.cpp b/qmake/tools/qlibrary_unix.cpp new file mode 100644 index 0000000..f0fbdf6 --- a/dev/null +++ b/qmake/tools/qlibrary_unix.cpp | |||
@@ -0,0 +1,163 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Implementation of QLibraryPrivate class | ||
5 | ** | ||
6 | ** Created : 2000-01-01 | ||
7 | ** | ||
8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the tools module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed under the terms of the Q Public License | ||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
16 | ** This file may be distributed and/or modified under the terms of the | ||
17 | ** GNU General Public License version 2 as published by the Free Software | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | ||
22 | ** licenses may use this file in accordance with the Qt Commercial License | ||
23 | ** Agreement provided with the Software. | ||
24 | ** | ||
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | #include "qplatformdefs.h" | ||
39 | #include "private/qlibrary_p.h" | ||
40 | |||
41 | #ifndef QT_NO_LIBRARY | ||
42 | |||
43 | #if defined(QT_AOUT_UNDERSCORE) | ||
44 | #include <string.h> | ||
45 | #endif | ||
46 | |||
47 | /* | ||
48 | The platform dependent implementations of | ||
49 | - loadLibrary | ||
50 | - freeLibrary | ||
51 | - resolveSymbol | ||
52 | |||
53 | It's not too hard to guess what the functions do. | ||
54 | */ | ||
55 | |||
56 | #if defined(QT_HPUX_LD) // for HP-UX < 11.x and 32 bit | ||
57 | |||
58 | bool QLibraryPrivate::loadLibrary() | ||
59 | { | ||
60 | if ( pHnd ) | ||
61 | return TRUE; | ||
62 | |||
63 | QString filename = library->library(); | ||
64 | |||
65 | pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 ); | ||
66 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | ||
67 | if ( !pHnd ) | ||
68 | qWarning( "%s: failed to load library!", filename.latin1() ); | ||
69 | #endif | ||
70 | return pHnd != 0; | ||
71 | } | ||
72 | |||
73 | bool QLibraryPrivate::freeLibrary() | ||
74 | { | ||
75 | if ( !pHnd ) | ||
76 | return TRUE; | ||
77 | |||
78 | if ( shl_unload( (shl_t)pHnd ) ) { | ||
79 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | ||
80 | QString filename = library->library(); | ||
81 | qWarning( "%s: Failed to unload library!", filename.latin1() ); | ||
82 | #endif | ||
83 | return FALSE; | ||
84 | } | ||
85 | pHnd = 0; | ||
86 | return TRUE; | ||
87 | } | ||
88 | |||
89 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) | ||
90 | { | ||
91 | if ( !pHnd ) | ||
92 | return 0; | ||
93 | |||
94 | void* address = 0; | ||
95 | if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address ) < 0 ) { | ||
96 | #if defined(QT_DEBUG_COMPONENT) | ||
97 | QString filename = library->library(); | ||
98 | qWarning( "%s: couldn't resolve symbol \"%s\"", filename.latin1(), symbol ); | ||
99 | #endif | ||
100 | } | ||
101 | return address; | ||
102 | } | ||
103 | |||
104 | #else // POSIX | ||
105 | #include <dlfcn.h> | ||
106 | |||
107 | bool QLibraryPrivate::loadLibrary() | ||
108 | { | ||
109 | if ( pHnd ) | ||
110 | return TRUE; | ||
111 | |||
112 | QString filename = library->library(); | ||
113 | |||
114 | pHnd = dlopen( filename.latin1(), RTLD_LAZY ); | ||
115 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | ||
116 | if ( !pHnd ) | ||
117 | qWarning( "%s", dlerror() ); | ||
118 | #endif | ||
119 | return pHnd != 0; | ||
120 | } | ||
121 | |||
122 | bool QLibraryPrivate::freeLibrary() | ||
123 | { | ||
124 | if ( !pHnd ) | ||
125 | return TRUE; | ||
126 | |||
127 | if ( dlclose( pHnd ) ) { | ||
128 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | ||
129 | qWarning( "%s", dlerror() ); | ||
130 | #endif | ||
131 | return FALSE; | ||
132 | } | ||
133 | |||
134 | pHnd = 0; | ||
135 | return TRUE; | ||
136 | } | ||
137 | |||
138 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) | ||
139 | { | ||
140 | if ( !pHnd ) | ||
141 | return 0; | ||
142 | |||
143 | #if defined(QT_AOUT_UNDERSCORE) | ||
144 | // older a.out systems add an underscore in front of symbols | ||
145 | char* undrscr_symbol = new char[strlen(symbol)+2]; | ||
146 | undrscr_symbol[0] = '_'; | ||
147 | strcpy(undrscr_symbol+1, symbol); | ||
148 | void* address = dlsym( pHnd, undrscr_symbol ); | ||
149 | delete [] undrscr_symbol; | ||
150 | #else | ||
151 | void* address = dlsym( pHnd, symbol ); | ||
152 | #endif | ||
153 | #if defined(QT_DEBUG_COMPONENT) | ||
154 | const char* error = dlerror(); | ||
155 | if ( error ) | ||
156 | qWarning( "%s", error ); | ||
157 | #endif | ||
158 | return address; | ||
159 | } | ||
160 | |||
161 | #endif // POSIX | ||
162 | |||
163 | #endif | ||