1 /*
2 	legacy_module.c: dummy interface to modular code loader for legacy build system
3 
4 	copyright 2008 by the mpg123 project - free software under the terms of the LGPL 2.1
5 	see COPYING and AUTHORS files in distribution or http://mpg123.org
6 	initially written by Nicholas J Humfrey
7 */
8 
9 #include "out123_int.h"
10 #include "debug.h"
11 
12 /* A single module is staticly compiled in for each type */
13 extern mpg123_module_t mpg123_output_module_info;
14 /* extern mpg123_module_t mpg123_input_module_info; */
15 
16 
17 /* Open a module */
18 mpg123_module_t*
open_module(const char * type,const char * name,int verbose,const char * bindir)19 open_module(const char* type, const char* name, int verbose, const char *bindir)
20 {
21 	mpg123_module_t *mod = NULL;
22 
23 	/* Select the module info structure, based on the desired type */
24 	if (strcmp(type, "output")==0) {
25 		mod = &mpg123_output_module_info;
26 /*
27 	} else if (strcmp(type, "input")==0) {
28 		mod = &mpg123_input_module_info;
29 */
30 	} else {
31 		if(verbose >= 0)
32 			error1("Unable to open module type '%s'.", type);
33 		return NULL;
34 	}
35 
36 	/* Check the module compiled in is the module requested */
37 	if (strcmp(name, mod->name)!=0) {
38 		if(verbose >= 0)
39 		{
40 			error1("Unable to open requested module '%s'.", name);
41 			error1("The only available statically compiled module is '%s'."
42 			,	mod->name);
43 		}
44 		return NULL;
45 	}
46 
47 	/* Debugging info */
48 	debug1("Details of static module type '%s':", type);
49 	debug1("  api_version=%d", mod->api_version);
50 	debug1("  name=%s", mod->name);
51 	debug1("  description=%s", mod->description);
52 	debug1("  revision=%s", mod->revision);
53 	debug1("  handle=%p", (void*)mod->handle);
54 
55 	return mod;
56 }
57 
58 
close_module(mpg123_module_t * module,int verbose)59 void close_module(mpg123_module_t* module, int verbose)
60 {
61 	debug("close_module()");
62 
63 	/* Module was never really 'loaded', so nothing to do here. */
64 }
65 
66 
list_modules(const char * type,char *** names,char *** descr,int verbose,const char * bindir)67 int list_modules(const char *type, char ***names, char ***descr, int verbose
68 ,	const char *bindir)
69 {
70 	debug("list_modules()" );
71 
72 	*names = NULL;
73 	*descr = NULL;
74 
75 	if(
76 		(*names=malloc(sizeof(char*)))
77 	&&	!((*names)[0]=NULL) /* for safe cleanup */
78 	&&	((*names)[0]=compat_strdup(mpg123_output_module_info.name))
79 	&&	(*descr=malloc(sizeof(char*)))
80 	&&	!((*descr)[0]=NULL) /* for safe cleanup */
81 	&& ((*descr)[0]=compat_strdup(mpg123_output_module_info.description))
82 	)
83 		return 1;
84 	else
85 	{
86 		if(*names)
87 			free((*names)[0]);
88 		free(*names);
89 		if(*descr)
90 			free((*descr)[0]);
91 		free(*descr);
92 		return -1;
93 	}
94 }
95 
96 
97