1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #define DRD64_SRC_LIBBROWNIE_SEARCHLIB
38 #include"drd64_libbrownie.h"
41 /*----------------------------------------------------------------------
42 ----------------------------------------------------------------------*/
44 LibBrownie_SearchLib_IsExistLibrary(
46 char *pstr_solibname )
50 struct stat t_filestat;
51 char str_solibpath[DRD64_MAX_PATH];
53 sz_len = strnlen( pstr_path, DRD64_MAX_PATH );
54 sz_len += strnlen( pstr_solibname, DRD64_MAX_PATH );
56 if( DRD64_MAX_PATH - 1 <= sz_len ) {
60 strncpy( str_solibpath, pstr_path, DRD64_MAX_PATH );
61 strncat( str_solibpath, "/", DRD64_MAX_PATH );
62 strncat( str_solibpath, pstr_solibname, DRD64_MAX_PATH );
63 i_result = stat( str_solibpath, &t_filestat );
69 /***********************************************************************
70 ***********************************************************************/
71 LIBBROWNIE_SEARCHLIB_API
73 LibBrownie_GetLibraryPath(
77 char *pstr_ldsohints )
86 if( NULL == pstr_solibpath ) {
90 if( NULL == pstr_ldsohints ) {
94 if( NULL != pstr_rpath ) {
95 i_result = LibBrownie_SearchLib_IsExistLibrary( pstr_rpath, pstr_solibname );
96 if( 0x00 == i_result ) {
97 pstr_nowpath = pstr_rpath;
98 goto goto_LibBrownie_GetLibraryPath_setting;
102 sz_len = strlen( pstr_ldsohints );
103 pstr_hintslist = (char *)alloca( sz_len + 1 );
104 if( NULL == pstr_hintslist ) {
108 strncpy( pstr_hintslist, pstr_ldsohints, sz_len + 1 );
111 pstr_nowpath = pstr_hintslist;
112 pstr_nowpos = pstr_hintslist;
114 if(( ':' == *pstr_nowpos ) || ( '\0' == *pstr_nowpos)) {
115 if( '\0' == *pstr_nowpos ) { i_flag = 0x01; }
116 else { *pstr_nowpos = '\0'; }
117 i_result = LibBrownie_SearchLib_IsExistLibrary( pstr_nowpath, pstr_solibname );
118 if( 0x00 == i_result ) {
119 goto goto_LibBrownie_GetLibraryPath_setting;
122 if( 0x00 != i_flag ) {
126 { *pstr_nowpos = ':'; }
128 pstr_nowpath = pstr_nowpos + 1;
131 }while( '\0' != *pstr_nowpos++ );
133 goto_LibBrownie_GetLibraryPath_setting:
134 strncpy( pstr_solibpath, pstr_nowpath, DRD64_MAX_PATH );
135 strncat( pstr_solibpath, "/", DRD64_MAX_PATH );
136 strncat( pstr_solibpath, pstr_solibname, DRD64_MAX_PATH );
142 /* EOF of drd64_.c ----------------------------------- */