For the operating systems where it matters, it is sometimes good to
authorRichard Levitte <levitte@openssl.org>
Thu, 26 Oct 2000 18:30:34 +0000 (18:30 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 26 Oct 2000 18:30:34 +0000 (18:30 +0000)
translate library names by only adding ".so" to them without
prepending them with "lib".  Add the flag DSO_FLAG_NAME_TRANSLATION_EXT_ONLY
for that purpose.

crypto/dso/dso.h
crypto/dso/dso_dl.c
crypto/dso/dso_dlfcn.c

index add6858de854185c5b49103524ea85cb2e96dce9..8c495b1b247d3dce0cbcf83cd764bb8c9ddeef3d 100644 (file)
@@ -81,12 +81,19 @@ extern "C" {
  * DSO to prevent *any* native name-translation at all - eg. if the caller has
  * prompted the user for a path to a driver library so the filename should be
  * interpreted as-is. */
-#define DSO_FLAG_NO_NAME_TRANSLATION 0x01
+#define DSO_FLAG_NO_NAME_TRANSLATION           0x01
+/* An extra flag to give if only the extension should be added as
+ * translation.  This is obviously only of importance on Unix and
+ * other operating systems where the translation also may prefix
+ * the name with something, like 'lib', and ignored everywhere else.
+ * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used
+ * at the same time. */
+#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY     0x02
 
 /* The following flag controls the translation of symbol names to upper
  * case.  This is currently only being implemented for OpenVMS.
  */
-#define DSO_FLAG_UPCASE_SYMBOL    0x02
+#define DSO_FLAG_UPCASE_SYMBOL                 0x10
 
 
 typedef void (*DSO_FUNC_TYPE)(void);
@@ -182,6 +189,7 @@ int DSO_free(DSO *dso);
 int    DSO_flags(DSO *dso);
 int    DSO_up(DSO *dso);
 long   DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);
+
 /* This function sets the DSO's name_converter callback. If it is non-NULL,
  * then it will be used instead of the associated DSO_METHOD's function. If
  * oldcb is non-NULL then it is set to the function pointer value being
index 6dd1b197555ce3e3f4959d1106cdb53939f65b05..43078604afc632e37a2dc62995e8e4a7bdbb79e1 100644 (file)
@@ -240,16 +240,18 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
 static char *dl_name_converter(DSO *dso, const char *filename)
        {
        char *translated;
-       int len, transform;
+       int len, rsize, transform;
 
        len = strlen(filename);
+       rsize = len + 1;
        transform = (strstr(filename, "/") == NULL);
-       if(transform)
-               /* We will convert this to "lib%s.so" */
-               translated = OPENSSL_malloc(len + 7);
-       else
-               /* We will simply duplicate filename */
-               translated = OPENSSL_malloc(len + 1);
+               {
+               /* We will convert this to "%s.so" or "lib%s.so" */
+               rsize += 3;     /* The length of ".so" */
+               if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
+                       rsize += 3; /* The length of "lib" */
+               }
+       translated = OPENSSL_malloc(rsize);
        if(translated == NULL)
                {
                DSOerr(DSO_F_DL_NAME_CONVERTER,
@@ -257,7 +259,12 @@ static char *dl_name_converter(DSO *dso, const char *filename)
                return(NULL);   
                }
        if(transform)
-               sprintf(translated, "lib%s.so", filename);
+               {
+               if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
+                       sprintf(translated, "lib%s.so", filename);
+               else
+                       sprintf(translated, "%s.so", filename);
+               }
        else
                sprintf(translated, "%s", filename);
        return(translated);
index 279b37b0c84bffd43a4f15c53f5c6948fa80afc2..22e5059dd86dea0097e3ceca023d2a0f65e29270 100644 (file)
@@ -252,16 +252,19 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
 static char *dlfcn_name_converter(DSO *dso, const char *filename)
        {
        char *translated;
-       int len, transform;
+       int len, rsize, transform;
 
        len = strlen(filename);
+       rsize = len + 1;
        transform = (strstr(filename, "/") == NULL);
        if(transform)
-               /* We will convert this to "lib%s.so" */
-               translated = OPENSSL_malloc(len + 7);
-       else
-               /* We will simply duplicate filename */
-               translated = OPENSSL_malloc(len + 1);
+               {
+               /* We will convert this to "%s.so" or "lib%s.so" */
+               rsize += 3;     /* The length of ".so" */
+               if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
+                       rsize += 3; /* The length of "lib" */
+               }
+       translated = OPENSSL_malloc(rsize);
        if(translated == NULL)
                {
                DSOerr(DSO_F_DLFCN_NAME_CONVERTER,
@@ -269,7 +272,12 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename)
                return(NULL);
                }
        if(transform)
-               sprintf(translated, "lib%s.so", filename);
+               {
+               if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
+                       sprintf(translated, "lib%s.so", filename);
+               else
+                       sprintf(translated, "%s.so", filename);
+               }
        else
                sprintf(translated, "%s", filename);
        return(translated);