Lib_Find.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Lib_Find.h
00006  *
00007  *  All the static function calls needed to search and open shared
00008  *  libraries.
00009  *
00010  *  Lib_Find.h,v 1.17 2006/06/20 12:40:38 jwillemsen Exp
00011  */
00012 //=============================================================================
00013 
00014 #ifndef ACE_LIB_FIND_H
00015 #define ACE_LIB_FIND_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/config-all.h"
00019 #include "ace/ACE_export.h"
00020 #include "ace/os_include/os_stdio.h"
00021 #if defined (ACE_OPENVMS)
00022 # include "ace/OS_NS_dlfcn.h"
00023 #endif
00024 
00025 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00026 
00027 namespace ACE
00028 {
00029   // = Methods for searching and opening shared libraries.
00030 
00031   /**
00032    * Finds the file @a filename either using an absolute path or using
00033    * a relative path in conjunction with ACE_LD_SEARCH_PATH (e.g.,
00034    * $LD_LIBRARY_PATH on UNIX or the directories scaned by Win32 API
00035    * SearchPath on Win32).  This function will add appropriate suffix
00036    * (e.g., .dll on Win32 or .so on UNIX) according to the OS
00037    * platform.  In addition, this function will apply the appropriate
00038    * prefix (e.g., "lib" on UNIX and "" on Win32) if the @a filename
00039    * doesn't match directly.
00040    */
00041   extern ACE_Export int ldfind (const ACE_TCHAR* filename,
00042                                 ACE_TCHAR pathname[],
00043                                 size_t maxpathnamelen);
00044 
00045   /**
00046    * Uses @c ldfind to locate and open the appropriate @a filename and
00047    * returns a pointer to the file, else it returns a NULL
00048    * pointer. @a type specifies how the file should be open.
00049    */
00050   extern ACE_Export FILE *ldopen (const ACE_TCHAR *filename,
00051                                   const ACE_TCHAR *type);
00052 
00053   /**
00054    * Transforms @a entry_point into a form that can be located in a
00055    * dynamic library using <dlsym>. For example, with Win32/Borland
00056    * extern "C" functions which use the default calling convention
00057    * have a '_' prepended. Always returns a buffer that has been
00058    * dynamically allocated using <operator new>.
00059    */
00060   extern ACE_Export ACE_TCHAR *ldname (const ACE_TCHAR *entry_point);
00061 
00062 
00063 #if defined (ACE_OPENVMS)
00064   /**
00065    * Registers an @a entry_point and its address for later retrieval
00066    * through the ACE::ldsymbol () method.
00067    * For use in cases where the OS compiler encodes long symbolnames.
00068    */
00069   extern ACE_Export void ldregister (const ACE_TCHAR *entry_point,
00070                                      void* entry_addr);
00071 
00072   /**
00073    * Looks up an @a entry_point address either from previously registered
00074    * symbols or through ACE_OS::dlsym ().
00075    * Returns 0 in case the entry_point is not found, otherwise nonzero.
00076    * For use in cases where the OS compiler encodes long symbolnames.
00077    */
00078   extern ACE_Export void *ldsymbol (ACE_SHLIB_HANDLE sh,
00079                                     const ACE_TCHAR *entry_point);
00080 #endif
00081 
00082   /**
00083    * Returns the temporary directory including the trailing slash in
00084    * @a buffer.  Returns -1 for an error or if the buffer_len is not
00085    * long enough.
00086    */
00087   extern ACE_Export int get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len);
00088 
00089   /// Opening the temp file.  File is automagically unlinked when it is
00090   /// closed.  This is useful for have temp files.
00091   extern ACE_Export ACE_HANDLE open_temp_file (const ACE_TCHAR *name,
00092                                                int mode,
00093                                                int perm = 0);
00094 
00095   // @@ Though the following functions dont come under the same category as
00096   // above, these are used only in the functions in this class. So it makes
00097   // more sense to move these functions too to this class.
00098   //
00099   /// Replace all instances of @a search in @a s with @a replace.  Returns
00100   /// the number of replacements made.
00101   extern ACE_Export size_t strrepl (char *s, char search, char replace);
00102 
00103   /**
00104    * Splits string <s> into pieces separated by the string <token>.
00105    * <next_start> is an opaque cookie handed back by the call to store
00106    * its state for the next invocation, thus making it re-entrant.
00107    * This operates very similar to Perl's <split> function except that
00108    * it returns pieces one at a time instead of into an array.
00109    */
00110   extern ACE_Export char *strsplit_r (char *s,
00111                                       const char *token,
00112                                       char *&next_start);
00113 
00114 #if defined (ACE_HAS_WCHAR)
00115   /// As strrepl, but for wide characters.
00116   extern ACE_Export size_t strrepl (wchar_t *s,
00117                                     wchar_t search,
00118                                     wchar_t replace);
00119 
00120   /// As strsplit_r, but for wide characters.
00121   extern ACE_Export wchar_t *strsplit_r (wchar_t *s,
00122                                          const wchar_t *token,
00123                                          wchar_t *&next_start);
00124 #endif /* ACE_HAS_WCHAR */
00125 }
00126 
00127 ACE_END_VERSIONED_NAMESPACE_DECL
00128 
00129 #include /**/ "ace/post.h"
00130 #endif  /* ACE_LIB_FIND_H */
00131 

Generated on Thu Nov 9 09:41:52 2006 for ACE by doxygen 1.3.6