[sane-devel] OS/2 specific patch for sane-backends/backend/dll.c

Franz Bakan Franz Bakan" <fbakan@gmx.net
Wed, 19 May 2004 23:59:56 +0200 (CEST)


Hi,

dynamic loading of the backend-code works on OS/2 via dlopen()
in principle, but there is one problem:

On OS/2 only filenames with max 8.3 length are possible for DLLs.
So loading test.dll, mustek.dll epson.dll ... works, but 
agfafocus.dll or coolscan2.dll ... fails.

The patch takes the first 2 and the last 6 letters of the backend name
to form the name for the backend.dll if the backend-name is longer
than 8 letters.

Example:

The build-process on OS/2 creates
  sane-backends/backend/.libs/libsane-coolscan2.dll
The install-process copies this file to
  /usr/lib/sane/libsane-coolscan2.dll
One has to rename this file to
  /usr/lib/sane/colscan2.dll

to make things work

Here's the patch:

--- cut ---
*** dll.c	Mon May 17 00:41:58 2004
--- dll.c.modified	Wed May 19 23:01:16 2004
***************
*** 378,385 ****
--- 378,391 ----
  
    while (dir)
      {
+ #ifdef HAVE_OS2_H   /* only max 8.3 names possible for dlls on OS/2 */
+       snprintf (libname, sizeof (libname), "%s/" PREFIX "%.2s%.6s" POSTFIX,
+ 		dir, be->name, strlen(be->name)>8 ? (be->name)+strlen(be->name)-6 :
+                                             (be->name)+2, V_MAJOR);
+ #else
        snprintf (libname, sizeof (libname), "%s/" PREFIX "%s" POSTFIX,
  		dir, be->name, V_MAJOR);
+ #endif
        DBG (4, "load: trying to load `%s'\n", libname);
        fp = fopen (libname, "r");
        if (fp)
--- cut ---

If nobody has a better solution could someone please submit this small patch?

Bye,
Franz