ohpi_008.c

来自「HIP 硬件设备管理标准接口」· C语言 代码 · 共 91 行

C
91
字号
/*      -*- linux-c -*- * * (C) Copyright IBM Corp. 2004 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  This * file and program are licensed under a BSD style license.  See * the Copying file included with the OpenHPI distribution for * full licensing terms. * * Authors: *     Renier Morales <renierm@users.sf.net> */ #include <stdlib.h>#include <string.h>#include <SaHpi.h>#include <oHpi.h>/** * Load 'libdummy' and 'libwatchdog', create two handlers on each. * Destroy handlers and unload plugin. * Pass on success, otherwise failure. **/ #define PLUGIN_NAME_SIZE 32 int main(int argc, char **argv){        SaHpiSessionIdT sid = 0;        char *config_file = NULL;        oHpiHandlerIdT hid0, hid1, hid2, hid3;        GHashTable *h0 = g_hash_table_new(g_str_hash, g_str_equal),                   *h1 = g_hash_table_new(g_str_hash, g_str_equal),                   *h2 = g_hash_table_new(g_str_hash, g_str_equal),                   *h3 = g_hash_table_new(g_str_hash, g_str_equal);                /* Save config file env variable and unset it */        config_file = getenv("OPENHPI_CONF");        setenv("OPENHPI_CONF","./noconfig", 1);                if (saHpiSessionOpen(1, &sid, NULL))                return -1;                            /* Load plugins */        if (oHpiPluginLoad("libdummy"))                return -1;                        if (oHpiPluginLoad("libwatchdog"))                return -1;                        /* Set configuration for handlers and create them. */        g_hash_table_insert(h0, "plugin", "libdummy");        g_hash_table_insert(h0, "entity_root", "{SYSTEM_CHASSIS,1}");        g_hash_table_insert(h0, "name", "test0");        g_hash_table_insert(h0, "addr", "0");                g_hash_table_insert(h1, "plugin", "libdummy");        g_hash_table_insert(h1, "entity_root", "{SYSTEM_CHASSIS,2}");        g_hash_table_insert(h1, "name", "test1");        g_hash_table_insert(h1, "addr", "1");                /* Set configuration for two handlers and create them. */        g_hash_table_insert(h2, "plugin", "libwatchdog");        g_hash_table_insert(h2, "entity_root", "{SYSTEM_CHASSIS,3}");        g_hash_table_insert(h2, "addr", "0");                g_hash_table_insert(h3, "plugin", "libwatchdog");        g_hash_table_insert(h3, "entity_root", "{SYSTEM_CHASSIS,4}");        g_hash_table_insert(h3, "addr", "1");                if (oHpiHandlerCreate(h0,&hid0) || oHpiHandlerCreate(h1,&hid1))                return -1;                        if (oHpiHandlerCreate(h2,&hid2) || oHpiHandlerCreate(h3,&hid3))                return -1;                        if (oHpiHandlerDestroy(hid0) || oHpiHandlerDestroy(hid1))                return -1;                        if (oHpiHandlerDestroy(hid2) || oHpiHandlerDestroy(hid3))                return -1;                        if (oHpiPluginUnload("libdummy") || oHpiPluginUnload("libwatchdog"))                return -1;                                return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?