]> git.pld-linux.org Git - packages/mpg123.git/blame - mpg123-no-la.patch
- up to 1.20.1
[packages/mpg123.git] / mpg123-no-la.patch
CommitLineData
4f61aa87
WF
1--- mpg123-1.16.0/src/module.c.orig 2013-10-15 15:34:52.184320390 +0200
2+++ mpg123-1.16.0/src/module.c 2013-10-15 16:38:49.842888001 +0200
3@@ -167,31 +167,85 @@ mpg123_module_t* open_module_here(const
4 }
5
6
7-/* Open a module, including directory search. */
8+/* Open a module */
9 mpg123_module_t* open_module(const char* type, const char* name)
10 {
11+ lt_dlhandle handle = NULL;
12 mpg123_module_t *module = NULL;
9c918b96 13- char *workdir = NULL;
4f61aa87
WF
14- char *moddir = NULL;
15+ char* module_path = NULL;
16+ size_t module_path_len = 0;
17+ char* module_symbol = NULL;
18+ size_t module_symbol_len = 0;
19+ char *moddir = get_module_dir();
20
1675bc69 21- workdir = get_the_cwd();
4f61aa87 22- moddir = get_module_dir();
1675bc69 23- if(workdir == NULL || moddir == NULL)
4f61aa87 24+ if (moddir == NULL)
1675bc69 25 {
4f61aa87 26- error("Failure getting workdir or moddir! (Perhaps set MPG123_MODDIR?)");
b6b9017a 27- 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");
4f61aa87
WF
28+ goto ex;
29+ }
b6b9017a
JB
30
31- if(workdir != NULL) free(workdir);
4f61aa87
WF
32- if(moddir != NULL) free(moddir);
33- return NULL;
34+ /* Initialize libltdl */
35+ if(lt_dlinit())
36+ {
37+ error("Failed to initialise libltdl");
38+ goto ex;
1675bc69 39 }
1675bc69 40
4f61aa87
WF
41- if(chdir(moddir) == 0) module = open_module_here(type, name);
42- else error2("Failed to enter module directory %s: %s", moddir, strerror(errno));
43+ /* Work out the path of the module to open */
44+ /* Note that we need to open ./file, not just file! */
1675bc69 45+ module_path_len = strlen(moddir) + 1 + strlen(type) + 1 + strlen(name) + strlen(MODULE_FILE_SUFFIX) + 1;
4f61aa87
WF
46+ module_path = malloc( module_path_len );
47+ if (module_path == NULL) {
48+ error1( "Failed to allocate memory for module name: %s", strerror(errno) );
49+ goto ex;
50+ }
1675bc69 51+ snprintf( module_path, module_path_len, "%s/%s_%s%s", moddir, type, name, MODULE_FILE_SUFFIX );
4f61aa87
WF
52+ /* Display the path of the module created */
53+ if(param.verbose > 1) fprintf(stderr, "Module path: %s\n", module_path );
54+
55+ /* Open the module */
56+ handle = lt_dlopen( module_path );
57+ free( module_path );
58+ if (handle==NULL) {
59+ error2( "Failed to open module %s: %s", name, lt_dlerror() );
60+ if(param.verbose > 1)
61+ fprintf(stderr, "Note: This could be because of braindead path in the .la file...\n");
62+
63+ goto ex;
64+ }
65+
66+ /* Work out the symbol name */
67+ module_symbol_len = strlen( MODULE_SYMBOL_PREFIX ) +
68+ strlen( type ) +
69+ strlen( MODULE_SYMBOL_SUFFIX ) + 1;
70+ module_symbol = malloc(module_symbol_len);
71+ if (module_symbol == NULL) {
72+ error1( "Failed to allocate memory for module symbol: %s", strerror(errno) );
73+ goto ex;
74+ }
75+ snprintf( module_symbol, module_symbol_len, "%s%s%s", MODULE_SYMBOL_PREFIX, type, MODULE_SYMBOL_SUFFIX );
76+ debug1( "Module symbol: %s", module_symbol );
77+
78+ /* Get the information structure from the module */
79+ module = (mpg123_module_t*)lt_dlsym(handle, module_symbol );
80+ free( module_symbol );
81+ if (module==NULL) {
82+ error1( "Failed to get module symbol: %s", lt_dlerror() );
83+ goto ex;
84+ }
85+
86+ /* Check the API version */
87+ if (MPG123_MODULE_API_VERSION != module->api_version)
88+ {
89+ error2( "API version of module does not match (got %i, expected %i).", module->api_version, MPG123_MODULE_API_VERSION);
90+ lt_dlclose(handle);
91+ module = NULL;
92+ goto ex;
93+ }
1675bc69 94
1675bc69 95- chdir(workdir);
4f61aa87 96- free(moddir);
1675bc69 97- free(workdir);
4f61aa87
WF
98+ /* Store handle in the data structure */
99+ module->handle = handle;
100+ex:
101+ if (moddir != NULL) free(moddir);
1675bc69
JB
102 return module;
103 }
104
This page took 0.130555 seconds and 4 git commands to generate.