commit 4f61aa874bc6030ede6370f6f3975179bf620b87
Author: Witold Filipczyk <[email protected]>
Date:   Tue Oct 15 16:45:22 2013 +0200

    - open_module rewritten because chdir to modules dir is forced by mpg123 
authors

 mpg123-no-la.patch | 124 +++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 87 insertions(+), 37 deletions(-)
---
diff --git a/mpg123-no-la.patch b/mpg123-no-la.patch
index 5760f5d..360f579 100644
--- a/mpg123-no-la.patch
+++ b/mpg123-no-la.patch
@@ -1,54 +1,104 @@
---- mpg123-1.14.4/src/module.c.orig    2012-07-26 15:36:44.000000000 +0200
-+++ mpg123-1.14.4/src/module.c 2012-10-28 12:11:45.381479443 +0100
-@@ -101,16 +101,12 @@
-       size_t module_path_len = 0;
-       char* module_symbol = NULL;
-       size_t module_symbol_len = 0;
+--- mpg123-1.16.0/src/module.c.orig    2013-10-15 15:34:52.184320390 +0200
++++ mpg123-1.16.0/src/module.c 2013-10-15 16:38:49.842888001 +0200
+@@ -167,31 +167,85 @@ mpg123_module_t* open_module_here(const
+ }
+ 
+ 
+-/* Open a module, including directory search. */
++/* Open a module */
+ mpg123_module_t* open_module(const char* type, const char* name)
+ {
++      lt_dlhandle handle = NULL;
+       mpg123_module_t *module = NULL;
 -      char *workdir = NULL;
-       char *moddir  = NULL;
+-      char *moddir  = NULL;
++      char* module_path = NULL;
++      size_t module_path_len = 0;
++      char* module_symbol = NULL;
++      size_t module_symbol_len = 0;
++      char *moddir = get_module_dir();
+ 
 -      workdir = get_the_cwd();
-       moddir  = get_module_dir();
+-      moddir  = get_module_dir();
 -      if(workdir == NULL || moddir == NULL)
-+      if(moddir == NULL)
++      if (moddir == NULL)
        {
--              error("Failure getting workdir or moddir!");
+-              error("Failure getting workdir or moddir! (Perhaps set 
MPG123_MODDIR?)");
 -              if(workdir == NULL) fprintf(stderr, "Hint: I need to know the 
current working directory to be able to come back after hunting modules. I will 
not leave because I do not know where I am.\n");
-+              error("Failure getting moddir!");
++              goto ex;
++      }
  
 -              if(workdir != NULL) free(workdir);
-               if(moddir  != NULL) free(moddir);
-               return NULL;
+-              if(moddir  != NULL) free(moddir);
+-              return NULL;
++      /* Initialize libltdl */
++      if(lt_dlinit())
++      {
++              error("Failed to initialise libltdl");
++              goto ex;
        }
-@@ -118,20 +114,15 @@
-       /* Initialize libltdl */
-       if (lt_dlinit()) error( "Failed to initialise libltdl" );
  
--      if(chdir(moddir) != 0)
--      {
--              error2("Failed to enter module directory %s: %s", moddir, 
strerror(errno));
--              goto om_bad;
--      }
-       /* Work out the path of the module to open */
-       /* Note that we need to open ./file, not just file! */
--      module_path_len = 2 + strlen(type) + 1 + strlen(name) + 
strlen(MODULE_FILE_SUFFIX) + 1;
+-      if(chdir(moddir) == 0) module = open_module_here(type, name);
+-      else error2("Failed to enter module directory %s: %s", moddir, 
strerror(errno));
++      /* Work out the path of the module to open */
++      /* Note that we need to open ./file, not just file! */
 +      module_path_len = strlen(moddir) + 1 + strlen(type) + 1 + strlen(name) 
+ strlen(MODULE_FILE_SUFFIX) + 1;
-       module_path = malloc( module_path_len );
-       if (module_path == NULL) {
-               error1( "Failed to allocate memory for module name: %s", 
strerror(errno) );
-               goto om_bad;
-       }
--      snprintf( module_path, module_path_len, "./%s_%s%s", type, name, 
MODULE_FILE_SUFFIX );
++      module_path = malloc( module_path_len );
++      if (module_path == NULL) {
++              error1( "Failed to allocate memory for module name: %s", 
strerror(errno) );
++              goto ex;
++      }
 +      snprintf( module_path, module_path_len, "%s/%s_%s%s", moddir, type, 
name, MODULE_FILE_SUFFIX );
-       /* Display the path of the module created */
-       if(param.verbose > 1) fprintf(stderr, "Module path: %s\n", module_path 
);
++      /* Display the path of the module created */
++      if(param.verbose > 1) fprintf(stderr, "Module path: %s\n", module_path 
);
++
++      /* Open the module */
++      handle = lt_dlopen( module_path );
++      free( module_path );
++      if (handle==NULL) {
++              error2( "Failed to open module %s: %s", name, lt_dlerror() );
++              if(param.verbose > 1)
++              fprintf(stderr, "Note: This could be because of braindead path 
in the .la file...\n");
++
++              goto ex;
++      }
++      
++      /* Work out the symbol name */
++      module_symbol_len = strlen( MODULE_SYMBOL_PREFIX ) +
++                                              strlen( type )  +
++                                              strlen( MODULE_SYMBOL_SUFFIX ) 
+ 1;
++      module_symbol = malloc(module_symbol_len);
++      if (module_symbol == NULL) {
++              error1( "Failed to allocate memory for module symbol: %s", 
strerror(errno) );
++              goto ex;
++      }
++      snprintf( module_symbol, module_symbol_len, "%s%s%s", 
MODULE_SYMBOL_PREFIX, type, MODULE_SYMBOL_SUFFIX );
++      debug1( "Module symbol: %s", module_symbol );
++      
++      /* Get the information structure from the module */
++      module = (mpg123_module_t*)lt_dlsym(handle, module_symbol );
++      free( module_symbol );
++      if (module==NULL) {
++              error1( "Failed to get module symbol: %s", lt_dlerror() );
++              goto ex;
++      }
++      
++      /* Check the API version */
++      if (MPG123_MODULE_API_VERSION != module->api_version)
++      {
++              error2( "API version of module does not match (got %i, expected 
%i).", module->api_version, MPG123_MODULE_API_VERSION);
++              lt_dlclose(handle);
++              module = NULL;
++              goto ex;
++      }
  
-@@ -180,9 +171,7 @@
- om_bad:
-       module = NULL;
- om_end:
 -      chdir(workdir);
-       free(moddir);
+-      free(moddir);
 -      free(workdir);
++      /* Store handle in the data structure */
++      module->handle = handle;
++ex:
++      if (moddir != NULL) free(moddir);
        return module;
  }
  
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mpg123.git/commitdiff/1e9dcb6b0294281dd432ad11308777e96fe07ba2

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to