diff --git a/ipmitool/include/ipmitool/ipmi_intf.h b/ipmitool/include/ipmitool/ipmi_intf.h index 64747df..cef6ea7 100644 --- a/ipmitool/include/ipmitool/ipmi_intf.h +++ b/ipmitool/include/ipmitool/ipmi_intf.h @@ -39,6 +39,11 @@ #include +struct static_intf { + char * name; + int (*setup)(struct ipmi_intf ** intf); +}; + int ipmi_intf_init(void); void ipmi_intf_exit(void); struct ipmi_intf * ipmi_intf_load(char * name); diff --git a/ipmitool/lib/ipmi_intf.c b/ipmitool/src/plugins/ipmi_intf.c similarity index 81% rename from ipmitool/lib/ipmi_intf.c rename to ipmitool/src/plugins/ipmi_intf.c index fdd9f3f..8c9bd88 100644 --- a/ipmitool/lib/ipmi_intf.c +++ b/ipmitool/src/plugins/ipmi_intf.c @@ -42,6 +42,8 @@ #include #include +extern struct static_intf static_intf_list[]; + /* ipmi_intf_init * initialize dynamic plugin interface */ @@ -78,23 +80,43 @@ struct ipmi_intf * ipmi_intf_load(char * name) { lt_dlhandle handle; struct ipmi_intf * intf; - int (*intf_setup)(struct ipmi_intf ** intf); + int (*setup)(struct ipmi_intf ** intf); + struct static_intf *i = static_intf_list; + char libname[16]; - handle = lt_dlopenext(name); - if (handle == NULL) { + while (i->name) { + if (!strcmp(name, i->name)) { + if (i->setup(&intf) < 0) { + printf("ERROR: Unable to setup static interface %s\n", name); + return NULL; + } + return intf; + } + i++; + } + + memset(libname, 0, 16); + if (snprintf(libname, sizeof(libname), "lib%s", name) <= 0) { printf("ERROR: Unable to find plugin '%s' in '%s'\n", name, PLUGIN_PATH); return NULL; } - intf_setup = lt_dlsym(handle, "intf_setup"); - if (!intf_setup) { + handle = lt_dlopenext(libname); + if (handle == NULL) { + printf("ERROR: Unable to find plugin '%s' in '%s'\n", + libname, PLUGIN_PATH); + return NULL; + } + + setup = lt_dlsym(handle, "intf_setup"); + if (!setup) { printf("ERROR: Unable to find interface setup symbol in plugin %s\n", name); lt_dlclose(handle); return NULL; } - if (intf_setup(&intf) < 0) { + if (setup(&intf) < 0) { printf("ERROR: Unable to run interface setup for plugin %s\n", name); lt_dlclose(handle); return NULL; diff --git a/ipmitool/src/plugins/ipmi_intf_static.c.in b/ipmitool/src/plugins/ipmi_intf_static.c.in new file mode 100644 index 0000000..2a784fa --- /dev/null +++ b/ipmitool/src/plugins/ipmi_intf_static.c.in @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + */ + +#include +#include + +#include +#include +#include + +@STATIC_INTF_EXT@ + +struct static_intf static_intf_list[] = { + @STATIC_INTF@ + { 0, 0 } +};