From: <av...@us...> - 2010-12-26 15:13:07
|
Revision: 7234 http://openhpi.svn.sourceforge.net/openhpi/?rev=7234&view=rev Author: avpak Date: 2010-12-26 15:13:00 +0000 (Sun, 26 Dec 2010) Log Message: ----------- Feature request #3129975 Modified Paths: -------------- openhpi/trunk/openhpid/event.c openhpi/trunk/openhpid/ohpi.c openhpi/trunk/plugins/simulator/sim_init.c openhpi/trunk/plugins/slave/handler.cpp Modified: openhpi/trunk/openhpid/event.c =================================================================== --- openhpi/trunk/openhpid/event.c 2010-12-25 13:14:54 UTC (rev 7233) +++ openhpi/trunk/openhpid/event.c 2010-12-26 15:13:00 UTC (rev 7234) @@ -274,6 +274,7 @@ break; case SAHPI_RESE_RESOURCE_REMOVED: remove = TRUE; + process = ( exists != 0 ) ? TRUE : FALSE; break; default: // unknown resource event @@ -283,7 +284,9 @@ } if ( remove ) { - oh_remove_resource(rpt, e->resource.ResourceId); + if ( exists ) { + oh_remove_resource(rpt, e->resource.ResourceId); + } } else { hidp = g_new0(unsigned int, 1); *hidp = e->hid; Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-12-25 13:14:54 UTC (rev 7233) +++ openhpi/trunk/openhpid/ohpi.c 2010-12-26 15:13:00 UTC (rev 7234) @@ -129,6 +129,44 @@ if (error == SA_OK) if (oh_destroy_handler(id)) error = SA_ERR_HPI_ERROR; + + if (error == SA_OK) { + // Remove all handler remaing resources from the Domain RPT + SaHpiRptEntryT *rpte; + SaHpiResourceIdT rid; + GSList *events = 0; + + rid = SAHPI_FIRST_ENTRY; + while ((rpte = oh_get_resource_next(&(d->rpt), rid)) != 0) { + const void * data; + data = oh_get_resource_data(&(d->rpt), rpte->ResourceId); + if (data) { + const unsigned int hid = *(const unsigned int*)(data); + if (hid == id) { + struct oh_event * e = g_new0(struct oh_event, 1); + e->hid = id; + e->resource = *rpte; + e->rdrs = 0; + e->rdrs_to_remove = 0; + e->event.Source = rpte->ResourceId; + e->event.EventType = SAHPI_ET_RESOURCE; + oh_gettimeofday(&e->event.Timestamp); + e->event.Severity = SAHPI_MAJOR; + e->event.EventDataUnion.ResourceEvent.ResourceEventType + = SAHPI_RESE_RESOURCE_REMOVED; + events = g_slist_prepend(events, e); + } + } + rid = rpte->ResourceId; + } + + GSList *iter = events; + while (iter) { + oh_evt_queue_push(oh_process_q, iter->data); + iter = g_slist_next(iter); + } + g_slist_free(events); + } oh_release_domain(d); /* Unlock domain */ return error; Modified: openhpi/trunk/plugins/simulator/sim_init.c =================================================================== --- openhpi/trunk/plugins/simulator/sim_init.c 2010-12-25 13:14:54 UTC (rev 7233) +++ openhpi/trunk/plugins/simulator/sim_init.c 2010-12-26 15:13:00 UTC (rev 7234) @@ -204,26 +204,33 @@ { struct oh_handler_state *state = hnd; - SaHpiEntryIdT id; - SaHpiRptEntryT * rpte; + SaHpiEntryIdT rid; + SaHpiRptEntryT *rpte; + GSList *events = 0; - id = SAHPI_FIRST_ENTRY; - while ((rpte = oh_get_resource_next(state->rptcache, id)) != 0) { - struct oh_event * e = (struct oh_event *)g_malloc0(sizeof(struct oh_event)); - + rid = SAHPI_FIRST_ENTRY; + while ((rpte = oh_get_resource_next(state->rptcache, rid)) != 0) { + struct oh_event *e = g_new0(struct oh_event, 1); e->hid = state->hid; e->resource = *rpte; e->rdrs = 0; + e->rdrs_to_remove = 0; e->event.Source = rpte->ResourceId; e->event.EventType = SAHPI_ET_RESOURCE; oh_gettimeofday(&e->event.Timestamp); e->event.Severity = SAHPI_MAJOR; e->event.EventDataUnion.ResourceEvent.ResourceEventType = SAHPI_RESE_RESOURCE_REMOVED; + events = g_slist_prepend(events, e); - oh_evt_queue_push(state->eventq, e ); + rid = rpte->ResourceId; + } - id = rpte->EntryId; + GSList *iter = events; + while (iter) { + oh_evt_queue_push(state->eventq, iter->data ); + iter = g_slist_next(iter); } + g_slist_free(events); oh_el_close(state->elcache); oh_flush_rpt(state->rptcache); Modified: openhpi/trunk/plugins/slave/handler.cpp =================================================================== --- openhpi/trunk/plugins/slave/handler.cpp 2010-12-25 13:14:54 UTC (rev 7233) +++ openhpi/trunk/plugins/slave/handler.cpp 2010-12-26 15:13:00 UTC (rev 7234) @@ -278,7 +278,7 @@ e->resource.ResourceCapabilities = 0; SaHpiEventT& he = e->event; he.EventType = SAHPI_ET_RESOURCE; - he.Severity = SAHPI_MAJOR; // TODO + he.Severity = SAHPI_MAJOR; SaHpiResourceEventT& re = he.EventDataUnion.ResourceEvent; re.ResourceEventType = SAHPI_RESE_RESOURCE_REMOVED; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-01-07 20:58:06
|
Revision: 7237 http://openhpi.svn.sourceforge.net/openhpi/?rev=7237&view=rev Author: avpak Date: 2011-01-07 20:57:59 +0000 (Fri, 07 Jan 2011) Log Message: ----------- Feature request #3143658 Modified Paths: -------------- openhpi/trunk/clients/Makefile.am openhpi/trunk/configure.ac openhpi/trunk/include/oh_handler.h openhpi/trunk/openhpid/Makefile.am openhpi/trunk/openhpid/plugin.c openhpi/trunk/plugins/snmp_bc/t/Makefile.am Removed Paths: ------------- openhpi/trunk/openhpid/plugin_static.c.in Modified: openhpi/trunk/clients/Makefile.am =================================================================== --- openhpi/trunk/clients/Makefile.am 2011-01-07 13:05:23 UTC (rev 7236) +++ openhpi/trunk/clients/Makefile.am 2011-01-07 20:57:59 UTC (rev 7237) @@ -7,10 +7,8 @@ EXTRA_DIST = Makefile.mingw32 -COMMONLIBS = @STATIC_PLUGIN_LIBS@ @STATIC_PLUGIN_EXTRA_LIBS@ +COMMONLIBS = $(top_builddir)/baselib/libopenhpi.la -COMMONLIBS += $(top_builddir)/baselib/libopenhpi.la - CLIENTS_SRC = clients.c oh_clients.h bin_PROGRAMS = \ Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2011-01-07 13:05:23 UTC (rev 7236) +++ openhpi/trunk/configure.ac 2011-01-07 20:57:59 UTC (rev 7237) @@ -221,10 +221,6 @@ dnl plugin enablement stanzas -dnl list of static plugins -STATIC_PLUGIN_LIST= -STATIC_PLUGIN_EXTRA_LIBS= - AC_CHECK_HEADER([linux/watchdog.h], [have_linux_watchdog_h=yes], [], [#include <linux/types.h>]) AC_ARG_ENABLE([watchdog], [ --enable-watchdog build watchdog plugin [[default=yes if linux/watchdog.h exists]]], @@ -266,16 +262,6 @@ OH_CHECK_FAIL(OpenIPMI,libOpenIPMI-devel,http://openipmi.sf.net, Can not build IPMI support without OpenIPMI >= 1.4.20) fi - elif test "x$enableval" = "xstatic"; then - if test "x$have_openipmi" = "xyes"; then - AC_SUBST(IPMI,ipmi) - AC_SUBST(WITH_IPMI,1) - STATIC_PLUGIN_LIST="$STATIC_PLUGIN_LIST ipmi" - STATIC_PLUGIN_EXTRA_LIBS="$STATIC_PLUGIN_EXTRA_LIBS" - else - OH_CHECK_FAIL(OpenIPMI,libOpenIPMI-devel,http://openipmi.sf.net, - Can not build IPMI support without OpenIPMI >= 1.4.20) - fi else AC_SUBST(WITH_IPMI,0) fi], @@ -329,10 +315,6 @@ [ --enable-ipmidirect build direct ipmi plugin [[default=yes]]], [if test "x$enableval" = "xyes"; then AC_SUBST(IPMIDIRECT,ipmidirect) - elif test "x$enableval" = "xstatic"; then - AC_SUBST(IPMIDIRECT,ipmidirect) - STATIC_PLUGIN_LIST="$STATIC_PLUGIN_LIST ipmidirect" - STATIC_PLUGIN_EXTRA_LIBS="$STATIC_PLUGIN_EXTRA_LIBS $SSL_LIB -luuid -lm -lstdc++" fi], [AC_SUBST(IPMIDIRECT,ipmidirect)]) @@ -429,28 +411,6 @@ AC_SUBST(SLAVE,slave) fi]) -dnl -dnl create static plugin config -dnl - -STATIC_PLUGIN= -STATIC_PLUGIN_EXTERN= -STATIC_PLUGIN_LIBS= - -for name in $STATIC_PLUGIN_LIST; do - STATIC_PLUGIN="$STATIC_PLUGIN { \"$name\", ${name}_get_interface },"; - STATIC_PLUGIN_EXTERN="${STATIC_PLUGIN_EXTERN} extern int ${name}_get_interface(void **pp, const uuid_t uuid);"; - STATIC_PLUGIN_LIBS="$STATIC_PLUGIN_LIBS \$(top_builddir)/plugins/$name/lib${name}.la"; -done - -dnl use openhpid/plugin_static.c.in -AC_SUBST(STATIC_PLUGIN_EXTERN) -AC_SUBST(STATIC_PLUGIN) - -dnl additional libs -AC_SUBST(STATIC_PLUGIN_LIBS) -AC_SUBST(STATIC_PLUGIN_EXTRA_LIBS) - dnl setup SNMPFLAGS AC_SUBST(SNMPFLAGS) AC_SUBST(SNMPLIBS) @@ -753,7 +713,6 @@ docs/man/Makefile openhpid/Makefile openhpid/openhpid.sh - openhpid/plugin_static.c openhpid/t/Makefile openhpid/t/ohpi/Makefile hpi_shell/Makefile Modified: openhpi/trunk/include/oh_handler.h =================================================================== --- openhpi/trunk/include/oh_handler.h 2011-01-07 13:05:23 UTC (rev 7236) +++ openhpi/trunk/include/oh_handler.h 2011-01-07 20:57:59 UTC (rev 7237) @@ -21,7 +21,6 @@ #ifndef __OH_HANDLER_H #define __OH_HANDLER_H -#include <uuid/uuid.h> #include <glib.h> #include <SaHpi.h> @@ -126,40 +125,7 @@ void *data; }; -/* Current abi is version 2. Version 1 is out-of-date and nobody - * should use it - */ -/* UUID_OH_ABI_V1 is out-of-date, keep here just for reference - * ee778a5f-32cf-453b-a650-518814dc956c - */ -/* static const uuid_t UUID_OH_ABI_V1 = { - 0xee, 0x77, 0x8a, 0x5f, 0x32, 0xcf, 0x45, 0x3b, - 0xa6, 0x50, 0x51, 0x88, 0x14, 0xdc, 0x95, 0x6c -}; -*/ - -/* 13adfcc7-d788-4aaf-b966-5cd30bdcd808 */ -/* regen this with via - * - * perl -e 'use POSIX qw(strftime); my $str = strftime("%Y%m%d%H%M%S",gmtime(time)); $str .= "00"; for my $c (split(//, $str)) {print "0x0$c, "} ' - * - * any time you make a change */ - -/* -static const uuid_t UUID_OH_ABI_V2 = { - 0x02, 0x00, 0x00, 0x04, 0x01, 0x02, 0x01, 0x05, - 0x01, 0x06, 0x01, 0x04, 0x01, 0x00, 0x00, 0x00, -}; -*/ - - -static const uuid_t UUID_OH_ABI_V2 = { - 0x02, 0x00, 0x00, 0x05, 0x00, 0x04, 0x01, 0x03, - 0x01, 0x02, 0x05, 0x04, 0x05, 0x00, 0x00, 0x00, -}; - - struct oh_abi_v2 { /*** * open @@ -1011,18 +977,6 @@ }; -/*The function is used for plugin loader to get interface*/ -int get_interface(void **pp, const uuid_t uuid) __attribute__ ((weak)); - -/* Structure for static plugins */ -typedef int (*get_interface_t)( void **pp, const uuid_t uuid ); - -struct oh_static_plugin -{ - char *name; - get_interface_t get_interface; -}; - #ifdef __cplusplus } #endif Modified: openhpi/trunk/openhpid/Makefile.am =================================================================== --- openhpi/trunk/openhpid/Makefile.am 2011-01-07 13:05:23 UTC (rev 7236) +++ openhpi/trunk/openhpid/Makefile.am 2011-01-07 20:57:59 UTC (rev 7237) @@ -47,7 +47,6 @@ lock.h \ ohpi.c \ plugin.c \ - plugin_static.c \ safhpi.c \ session.c \ threaded.c \ Modified: openhpi/trunk/openhpid/plugin.c =================================================================== --- openhpi/trunk/openhpid/plugin.c 2011-01-07 13:05:23 UTC (rev 7236) +++ openhpi/trunk/openhpid/plugin.c 2011-01-07 20:57:59 UTC (rev 7237) @@ -220,8 +220,6 @@ return -1; } -/* list of static plugins. defined in plugin_static.c.in */ -extern struct oh_static_plugin static_plugins[]; /** * oh_load_plugin * @plugin_name: name of plugin to be loaded (e.g. "libdummy"). @@ -238,7 +236,6 @@ gchar *plugin_path; struct oh_plugin *plugin = NULL; - struct oh_static_plugin *p = static_plugins; int err; if (!plugin_name) { @@ -270,28 +267,6 @@ g_static_rec_mutex_init(&plugin->lock); g_static_rec_mutex_init(&plugin->refcount_lock); - /* first take search plugin in the array of static plugin */ - while (p->name) { - if (!strcmp(plugin->name, p->name)) { - plugin->dl_handle = 0; - err = (*p->get_interface)((void **)&plugin->abi, UUID_OH_ABI_V2); - - if (err < 0 || !plugin->abi || !plugin->abi->open) { - CRIT("Can not get ABI V2"); - goto cleanup_and_quit; - } - - DBG("found static plugin %s", p->name); - - g_static_rec_mutex_lock(&oh_plugins.lock); - oh_plugins.list = g_slist_append(oh_plugins.list, plugin); - g_static_rec_mutex_unlock(&oh_plugins.lock); - - return 0; - } - p++; - } - oh_get_global_param(&path_param); plugin_search_dirs = g_strsplit(path_param.u.path, ":", -1); for( i = 0; plugin_search_dirs[i] != 0; ++i) { Deleted: openhpi/trunk/openhpid/plugin_static.c.in =================================================================== --- openhpi/trunk/openhpid/plugin_static.c.in 2011-01-07 13:05:23 UTC (rev 7236) +++ openhpi/trunk/openhpid/plugin_static.c.in 2011-01-07 20:57:59 UTC (rev 7237) @@ -1,26 +0,0 @@ -/* -*- linux-c -*- - * - * Copyright (c) 2003 by FORCE Computers. - * - * 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: - * Thomas Kanngieser - */ - -#include "oh_plugin.h" - - -@STATIC_PLUGIN_EXTERN@ - - -struct oh_static_plugin static_plugins[] = -{ - @STATIC_PLUGIN@ - { 0, 0 } /* end mark */ -}; Modified: openhpi/trunk/plugins/snmp_bc/t/Makefile.am =================================================================== --- openhpi/trunk/plugins/snmp_bc/t/Makefile.am 2011-01-07 13:05:23 UTC (rev 7236) +++ openhpi/trunk/plugins/snmp_bc/t/Makefile.am 2011-01-07 20:57:59 UTC (rev 7237) @@ -71,7 +71,7 @@ tsetup.c nodist_libsnmp_bc_la_SOURCES = $(GENERATED_EVENT_CODE) $(REMOTE_SIM_SOURCES) -# libopenhpi_la_LIBADD = @STATIC_PLUGIN_LIBS@ @STATIC_PLUGIN_EXTRA_LIBS@ $(top_builddir)/utils/libopenhpiutils.la +# libopenhpi_la_LIBADD = $(top_builddir)/utils/libopenhpiutils.la # libopenhpi_la_LDFLAGS = -L$(top_builddir)/utils -version-info @HPI_LIB_VERSION@ -export-symbols $(top_srcdir)/src/hpi.sym libsnmp_bc_la_LIBADD = -luuid @SNMPLIBS@ $(top_builddir)/utils/libopenhpiutils.la This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-01-07 21:25:04
|
Revision: 7238 http://openhpi.svn.sourceforge.net/openhpi/?rev=7238&view=rev Author: avpak Date: 2011-01-07 21:24:57 +0000 (Fri, 07 Jan 2011) Log Message: ----------- Initial attempt for Feature request #3153081 Modified Paths: -------------- openhpi/trunk/Makefile.mingw32 openhpi/trunk/openhpid/Makefile.am openhpi/trunk/openhpid/Makefile.mingw32 openhpi/trunk/plugins/slave/Makefile.am openhpi/trunk/plugins/slave/baselib.cpp Added Paths: ----------- openhpi/trunk/plugins/slave/Makefile.mingw32 Modified: openhpi/trunk/Makefile.mingw32 =================================================================== --- openhpi/trunk/Makefile.mingw32 2011-01-07 20:57:59 UTC (rev 7237) +++ openhpi/trunk/Makefile.mingw32 2011-01-07 21:24:57 UTC (rev 7238) @@ -5,9 +5,9 @@ transport \ marshal \ baselib \ - clients -# openhpid \ -# plugins/slave + clients \ + openhpid \ + plugins/slave .PHONY: all clean $(openhpi_libs) @@ -26,7 +26,7 @@ out: all rm -rf ${out} mkdir -p ${out} -# mkdir -p ${out}/plugins + mkdir -p ${out}/plugins cp README.windows ${out} cat include/SaHpi.h | sed -e 's/ __attribute__.*/;/' -e 's/#define SAHPI_API/#define SAHPI_API __declspec(dllimport)/' > ${out}/SaHpi.h cp include/oHpi.h ${out} @@ -39,6 +39,6 @@ cp baselib/libopenhpi-${VERSION}.a ${out}/ cp baselib/libopenhpi-${VERSION}.def ${out}/ cp clients/*.exe ${out}/ -# cp openhpid/openhpid.exe ${out}/ -# cp plugins/slave/libslave.dll ${out}/plugins + cp openhpid/openhpid.exe ${out}/ + cp plugins/slave/libslave.dll ${out}/plugins Modified: openhpi/trunk/openhpid/Makefile.am =================================================================== --- openhpi/trunk/openhpid/Makefile.am 2011-01-07 20:57:59 UTC (rev 7237) +++ openhpi/trunk/openhpid/Makefile.am 2011-01-07 21:24:57 UTC (rev 7238) @@ -26,8 +26,9 @@ DIST_SUBDIRS = t EXTRA_DIST = \ + openhpid.sh.in \ Makefile.mingw32 \ - openhpid.sh.in + openhpid-win32.cpp # daemon library noinst_LTLIBRARIES = libopenhpidaemon.la Modified: openhpi/trunk/openhpid/Makefile.mingw32 =================================================================== --- openhpi/trunk/openhpid/Makefile.mingw32 2011-01-07 20:57:59 UTC (rev 7237) +++ openhpi/trunk/openhpid/Makefile.mingw32 2011-01-07 21:24:57 UTC (rev 7238) @@ -11,7 +11,6 @@ lock.c \ ohpi.c \ plugin.c \ - plugin_static.c \ safhpi.c \ session.c \ threaded.c \ Modified: openhpi/trunk/plugins/slave/Makefile.am =================================================================== --- openhpi/trunk/plugins/slave/Makefile.am 2011-01-07 20:57:59 UTC (rev 7237) +++ openhpi/trunk/plugins/slave/Makefile.am 2011-01-07 21:24:57 UTC (rev 7238) @@ -19,6 +19,8 @@ INCLUDES = @OPENHPI_INCLUDES@ +EXTRA_DIST = Makefile.mingw32 + pkglib_LTLIBRARIES = libslave.la libslave_la_SOURCES = baselib.cpp \ Added: openhpi/trunk/plugins/slave/Makefile.mingw32 =================================================================== --- openhpi/trunk/plugins/slave/Makefile.mingw32 (rev 0) +++ openhpi/trunk/plugins/slave/Makefile.mingw32 2011-01-07 21:24:57 UTC (rev 7238) @@ -0,0 +1,31 @@ +include ../../Makefile.mingw32.def + +TARGET := libslave.dll + +SRC := baselib.cpp \ + handler.cpp \ + resourcemap.cpp \ + slave.cpp \ + util.cpp + +OBJ := $(patsubst %.cpp, %.o, ${SRC}) + +DEFS := -DG_LOG_DOMAIN=\"slave\" + +INCLUDES := ${GLIB_INCLUDES} -I ../../mingw32 -I ../../include -I ../../utils + +LIBS := ${GLIB_LIBS} ${GTHREAD_LIBS} ${GMODULE_LIBS} +LIBS += -L ../../utils -lopenhpiutils-${VERSION} + +CPPFLAGS += ${DEFS} ${INCLUDES} + +.PHONY: all clean + +all : ${TARGET} + +${TARGET} : ${OBJ} + ${CXX} -shared -o $@ $^ ${LIBS} + +clean: + rm -f ${OBJ} ${TARGET} + Modified: openhpi/trunk/plugins/slave/baselib.cpp =================================================================== --- openhpi/trunk/plugins/slave/baselib.cpp 2011-01-07 20:57:59 UTC (rev 7237) +++ openhpi/trunk/plugins/slave/baselib.cpp 2011-01-07 21:24:57 UTC (rev 7238) @@ -62,8 +62,12 @@ CRIT( "GModule is not supported. Cannot load base library." ); return false; } - +// TODO fix me +#ifdef _WIN32 + m_handle = g_module_open( "libopenhpi-" VERSION, G_MODULE_BIND_LOCAL ); +#else m_handle = g_module_open( "libopenhpi", G_MODULE_BIND_LOCAL ); +#endif if ( !m_handle ) { CRIT( "Cannot load base library." ); return false; @@ -565,7 +569,7 @@ reinterpret_cast<gpointer *>( &m_abi.oHpiDomainAdd ), nerrors ); GetF( m_handle, - "xoHpiDomainAdd", + "oHpiDomainAdd", reinterpret_cast<gpointer *>( &m_abi.oHpiDomainAdd ), nerrors ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-01-10 19:26:34
|
Revision: 7243 http://openhpi.svn.sourceforge.net/openhpi/?rev=7243&view=rev Author: avpak Date: 2011-01-10 19:26:26 +0000 (Mon, 10 Jan 2011) Log Message: ----------- Begin work on Feature Request #3130030 Modified Paths: -------------- openhpi/trunk/Makefile.mingw32 openhpi/trunk/Makefile.mingw32.def openhpi/trunk/clients/Makefile.am openhpi/trunk/configure.ac openhpi/trunk/docs/man/Makefile.am Added Paths: ----------- openhpi/trunk/clients/hpixml/ openhpi/trunk/clients/hpixml/Makefile.am openhpi/trunk/clients/hpixml/Makefile.mingw32 openhpi/trunk/clients/hpixml/hpi.cpp openhpi/trunk/clients/hpixml/hpi.h openhpi/trunk/clients/hpixml/hpi_xml_writer.cpp openhpi/trunk/clients/hpixml/hpi_xml_writer.h openhpi/trunk/clients/hpixml/main.cpp openhpi/trunk/clients/hpixml/schema.h openhpi/trunk/clients/hpixml/schema.xsd openhpi/trunk/clients/hpixml/xml_writer.cpp openhpi/trunk/clients/hpixml/xml_writer.h openhpi/trunk/docs/man/hpixml.pod.1 Modified: openhpi/trunk/Makefile.mingw32 =================================================================== --- openhpi/trunk/Makefile.mingw32 2011-01-10 17:52:11 UTC (rev 7242) +++ openhpi/trunk/Makefile.mingw32 2011-01-10 19:26:26 UTC (rev 7243) @@ -6,6 +6,7 @@ marshal \ baselib \ clients \ + clients/hpixml \ openhpid \ plugins/slave @@ -39,6 +40,7 @@ cp baselib/libopenhpi-${VERSION}.a ${out}/ cp baselib/libopenhpi-${VERSION}.def ${out}/ cp clients/*.exe ${out}/ + cp clients/hpixml/hpixml.exe ${out}/ cp openhpid/openhpid.exe ${out}/ cp plugins/slave/libslave.dll ${out}/plugins Modified: openhpi/trunk/Makefile.mingw32.def =================================================================== --- openhpi/trunk/Makefile.mingw32.def 2011-01-10 17:52:11 UTC (rev 7242) +++ openhpi/trunk/Makefile.mingw32.def 2011-01-10 19:26:26 UTC (rev 7243) @@ -5,6 +5,7 @@ CC := ${TOOLCHAIN_PATH}/bin/i386-mingw32-gcc CXX := ${TOOLCHAIN_PATH}/bin/i386-mingw32-g++ +LD := ${TOOLCHAIN_PATH}/bin/i386-mingw32-ld GLIB_DIR := /home/avpak/usr/cross/mingw32/i386-mingw32/glib-2.0 Modified: openhpi/trunk/clients/Makefile.am =================================================================== --- openhpi/trunk/clients/Makefile.am 2011-01-10 17:52:11 UTC (rev 7242) +++ openhpi/trunk/clients/Makefile.am 2011-01-10 19:26:26 UTC (rev 7243) @@ -5,6 +5,9 @@ INCLUDES = @OPENHPI_INCLUDES@ +SUBDIRS = hpixml +DIST_SUBDIRS = hpixml + EXTRA_DIST = Makefile.mingw32 COMMONLIBS = $(top_builddir)/baselib/libopenhpi.la Added: openhpi/trunk/clients/hpixml/Makefile.am =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.am (rev 0) +++ openhpi/trunk/clients/hpixml/Makefile.am 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,30 @@ +MAINTAINERCLEANFILES = Makefile.in +MOSTLYCLEANFILES = @TEST_CLEAN@ + +AM_CPPFLAGS = -DG_LOG_DOMAIN=\"hpixml\" + +INCLUDES = @OPENHPI_INCLUDES@ + +EXTRA_DIST = Makefile.mingw32 + +bin_PROGRAMS = hpixml + +hpixml_SOURCES = \ + hpi.cpp \ + hpi.h \ + hpi_xml_writer.cpp \ + hpi_xml_writer.h \ + main.cpp \ + schema.h \ + schema.xsd \ + xml_writer.cpp \ + xml_writer.h + +hpixml_LDADD = $(top_builddir)/baselib/libopenhpi.la + +.xsd.o: + ${LD} -r -b binary -o $@ $< + +clean-local: + rm -f *~ *.o + Added: openhpi/trunk/clients/hpixml/Makefile.mingw32 =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.mingw32 (rev 0) +++ openhpi/trunk/clients/hpixml/Makefile.mingw32 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,37 @@ +include ../../Makefile.mingw32.def + +TARGET := hpixml.exe + +SRC := \ + hpi.cpp \ + hpi_xml_writer.cpp \ + schema.xsd \ + main.cpp \ + xml_writer.cpp + +OBJ := $(patsubst %.xsd, %.o,$(patsubst %.cpp, %.o, ${SRC} ) ) + +DEFS := -DG_LOG_DOMAIN=\"hpixml\" + +INCLUDES := ${GLIB_INCLUDES} +INCLUDES += -I ../../mingw32 -I ../../include -I ../../utils + +LIBS := ${GLIB_LIBS} +LIBS += -L ../../utils -lopenhpiutils-${VERSION} +LIBS += -L ../../baselib -lopenhpi-${VERSION} + +CPPFLAGS += ${DEFS} ${INCLUDES} + +.PHONY: all clean + +all : ${TARGET} + +%.o : %.xsd + ${LD} -r -b binary -o $@ $^ + +${TARGET} : ${OBJ} + ${CXX} -o $@ $^ ${LIBS} + +clean: + rm -f ${OBJ} ${TARGET} + Added: openhpi/trunk/clients/hpixml/hpi.cpp =================================================================== --- openhpi/trunk/clients/hpixml/hpi.cpp (rev 0) +++ openhpi/trunk/clients/hpixml/hpi.cpp 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,440 @@ +/* -*- c++ -*- + * + * Copyright (c) 2010 by Pigeon Point Systems. + * + * 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: + * Anton Pak <av...@pi...> + * + */ + +#include <list> + +#include <oh_error.h> +#include <oh_utils.h> + +#include "hpi.h" +#include "hpi_xml_writer.h" + + +/*************************************************** + * Helper Functions + ***************************************************/ +static bool GetDomainInfo( SaHpiSessionIdT sid, SaHpiDomainInfoT& di ) +{ + SaErrorT rv; + rv = saHpiDomainInfoGet( sid, &di ); + if ( rv != SA_OK ) { + CRIT( "saHpiDomainInfoGet returned %s", oh_lookup_error( rv ) ); + } + return ( rv == SA_OK ); +} + +/* +static SaHpiUint32T GetRdrUpdateCounter( SaHpiSessionIdT rid ) +{ +} +*/ + +static bool FetchDrt( SaHpiSessionIdT sid, + SaHpiDomainInfoT& di, + std::list<SaHpiDrtEntryT>& drt ) +{ + SaHpiDomainInfoT di2; + + do { + drt.clear(); + + bool rc; + + rc = GetDomainInfo( sid, di ); + if ( !rc ) { + return false; + } + + SaHpiEntryIdT id, next_id; + SaHpiDrtEntryT drte; + id = SAHPI_FIRST_ENTRY; + while ( id != SAHPI_LAST_ENTRY ) { + SaErrorT rv; + rv = saHpiDrtEntryGet( sid, id, &next_id, &drte ); + if ( rv == SA_ERR_HPI_NOT_PRESENT ) { + break; + } + if ( rv != SA_OK ) { + drt.clear(); + CRIT( "saHpiDrtEntryGet returned %s", oh_lookup_error( rv ) ); + return false; + } + drt.push_back( drte ); + id = next_id; + } + + rc = GetDomainInfo( sid, di2 ); + if ( !rc ) { + drt.clear(); + return false; + } + + } while ( di.DrtUpdateCount != di2.DrtUpdateCount ); + + return true; +} + +static bool FetchResources( SaHpiSessionIdT sid, + SaHpiDomainInfoT& di, + std::list<SaHpiRptEntryT>& rpt ) +{ + SaHpiDomainInfoT di2; + + do { + rpt.clear(); + + bool rc; + + rc = GetDomainInfo( sid, di ); + if ( !rc ) { + return false; + } + + SaHpiEntryIdT id, next_id; + SaHpiRptEntryT rpte; + id = SAHPI_FIRST_ENTRY; + while ( id != SAHPI_LAST_ENTRY ) { + SaErrorT rv; + rv = saHpiRptEntryGet( sid, id, &next_id, &rpte ); + if ( rv == SA_ERR_HPI_NOT_PRESENT ) { + break; + } + if ( rv != SA_OK ) { + rpt.clear(); + CRIT( "saHpiRptEntryGet returned %s", oh_lookup_error( rv ) ); + return false; + } + rpt.push_back( rpte ); + id = next_id; + } + + rc = GetDomainInfo( sid, di2 ); + if ( !rc ) { + rpt.clear(); + return false; + } + + } while ( di.RptUpdateCount != di2.RptUpdateCount ); + + return true; +} + +static bool FetchDat( SaHpiSessionIdT sid, + SaHpiDomainInfoT& di, + std::list<SaHpiAlarmT>& dat ) +{ + SaHpiDomainInfoT di2; + + do { + dat.clear(); + + bool rc; + + rc = GetDomainInfo( sid, di ); + if ( !rc ) { + return false; + } + + SaHpiAlarmT a; + a.AlarmId = SAHPI_FIRST_ENTRY; + while ( true ) { + SaErrorT rv; + rv = saHpiAlarmGetNext( sid, SAHPI_ALL_SEVERITIES, SAHPI_FALSE, &a ); + if ( rv == SA_ERR_HPI_NOT_PRESENT ) { + break; + } + if ( rv != SA_OK ) { + dat.clear(); + CRIT( "saHpiDatEntryGet returned %s", oh_lookup_error( rv ) ); + return false; + } + dat.push_back( a ); + } + + rc = GetDomainInfo( sid, di2 ); + if ( !rc ) { + dat.clear(); + return false; + } + + } while ( di.DatUpdateCount != di2.DatUpdateCount ); + + return true; +} + +/* +void cHpiSubProviderDRT::GetEntries( std::deque<HpiEntry>& entries ) const +{ + entries.clear(); + + SaErrorT rv; + SaHpiEntryIdT id, next_id; + SaHpiDrtEntryT drte; + + bool first = true; + id = SAHPI_FIRST_ENTRY; + while ( id != SAHPI_LAST_ENTRY ) { + rv = saHpiDrtEntryGet( m_ctx.session_id, id, &next_id, &drte ); + if ( first && ( rv == SA_ERR_HPI_NOT_PRESENT ) ) { + break; + } + + if ( rv != SA_OK ) { + return; + } + + std::wstring name; + MakeNameForDomain( drte.DomainId, name ); + entries.push_back( HpiEntry( eHpiEntryResource, drte.EntryId, name ) ); + + first = false; + id = next_id; + } +} + +SaHpiUint32T cHandler::GetRptUpdateCounter() const +{ + SaErrorT rv; + SaHpiDomainInfoT di; + rv = Abi()->saHpiDomainInfoGet( m_sid, &di ); + if ( rv == SA_OK ) { + return di.RptUpdateCount; + } else { + CRIT( "saHpiDomainInfoGet failed with rv = %d", rv ); + return 0; + } +} + +SaHpiUint32T cHandler::GetRdrUpdateCounter( SaHpiResourceIdT slave_rid ) const +{ + SaErrorT rv; + SaHpiUint32T cnt; + rv = Abi()->saHpiRdrUpdateCountGet( m_sid, slave_rid, &cnt ); + if ( rv == SA_OK ) { + return cnt; + } else { + CRIT( "saHpiRdrUpdateCountGet failed with rv = %d", rv ); + return 0; + } +} + +bool cHandler::FetchRptAndRdrs( std::queue<struct oh_event *>& events ) const +{ + for ( unsigned int attempt = 0; attempt < MaxFetchAttempts; ++attempt ) { + while( !events.empty() ) { + oh_event_free( events.front(), 0 ); + events.pop(); + } + + SaHpiUint32T cnt = GetRptUpdateCounter(); + SaHpiEntryIdT id, next_id; + for ( id = SAHPI_FIRST_ENTRY; id != SAHPI_LAST_ENTRY; id = next_id ) { + struct oh_event * e = g_new0( struct oh_event, 1 ); + SaErrorT rv = Abi()->saHpiRptEntryGet( m_sid, + id, + &next_id, + &e->resource ); + if ( rv != SA_OK ) { + CRIT( "saHpiRptEntryGet failed with rv = %d", rv ); + break; + } + e->event.Source = e->resource.ResourceId; + bool rc = FetchRdrs( e ); + if ( !rc ) { + break; + } + events.push( e ); + } + if ( cnt == GetRptUpdateCounter() ) { + return true; + } + } + + while( !events.empty() ) { + oh_event_free( events.front(), 0 ); + events.pop(); + + while( !events.empty() ) { + oh_event_free( events.front(), 0 ); + events.pop(); + } + + return false; +} + +bool cHandler::FetchRdrs( struct oh_event * e ) const +{ + SaHpiResourceIdT slave_rid = e->event.Source; + + for ( unsigned int attempt = 0; attempt < MaxFetchAttempts; ++attempt ) { + oh_event_free( e, 1 ); + e->rdrs = 0; + + SaHpiUint32T cnt = GetRdrUpdateCounter( slave_rid ); + SaHpiEntryIdT id, next_id; + for ( id = SAHPI_FIRST_ENTRY; id != SAHPI_LAST_ENTRY; id = next_id ) { + SaHpiRdrT * rdr = g_new0( SaHpiRdrT, 1 ); + SaErrorT rv = Abi()->saHpiRdrGet( m_sid, + slave_rid, + id, + &next_id, + rdr ); + if ( rv != SA_OK ) { + g_free( rdr ); + CRIT( "saHpiRdrGet failed with rv = %d", rv ); + break; + } + e->rdrs = g_slist_append( e->rdrs, rdr ); + } + + if ( cnt == GetRdrUpdateCounter( slave_rid ) ) { + return true; + } + } + + oh_event_free( e, 1 ); + e->rdrs = 0; + + return false; +} + +*/ + + +/*************************************************** + * class cHpi + ***************************************************/ +cHpi::cHpi( SaHpiDomainIdT did ) + : m_initialized( false ), + m_opened( false ), + m_did( did ), + m_sid( 0 ) +{ + // empty +} + +cHpi::~cHpi() +{ + Close(); +} + +bool cHpi::Open() +{ + if ( m_opened ) { + return true; + } + + SaErrorT rv; + + if ( !m_initialized ) { + rv = saHpiInitialize( SAHPI_INTERFACE_VERSION, 0, 0, 0, 0 ); + if ( rv != SA_OK ) { + CRIT( "saHpiInitialize returned %s", oh_lookup_error( rv ) ); + return false; + } + m_initialized = true; + } + rv = saHpiSessionOpen( m_did, &m_sid, 0 ); + if ( rv != SA_OK ) { + CRIT( "saHpiSessionOpen returned %s", oh_lookup_error( rv ) ); + return false; + } + m_opened = true; + rv = saHpiDiscover( m_sid ); + if ( rv != SA_OK ) { + CRIT( "saHpiDiscover returned %s", oh_lookup_error( rv ) ); + return false; + } + + return true; +} + +void cHpi::Close() +{ + if ( m_opened ) { + saHpiSessionClose( m_sid ); + m_sid = 0; + m_opened = false; + } + if ( m_initialized ) { + saHpiFinalize(); + m_initialized = false; + } +} + +bool cHpi::Dump( cHpiXmlWriter& writer ) +{ + bool rc; + + writer.Begin(); + + writer.VersionNode( saHpiVersionGet() ); + + SaHpiDomainInfoT di; + rc = GetDomainInfo( m_sid, di ); + if ( !rc ) { + return false; + } + + writer.BeginDomainNode( di ); + + SaHpiDomainInfoT drt_di; + std::list<SaHpiDrtEntryT> drt; + rc = FetchDrt( m_sid, drt_di, drt ); + if ( !rc ) { + return false; + } + writer.BeginDrtNode( drt_di ); + while ( !drt.empty() ) { + writer.DrtEntryNode( drt.front() ); + drt.pop_front(); + } + writer.EndDrtNode(); + + SaHpiDomainInfoT rpt_di; + std::list<SaHpiRptEntryT> rpt; + rc = FetchResources( m_sid, rpt_di, rpt ); + if ( !rc ) { + return false; + } + writer.BeginRptNode( rpt_di ); + while ( !rpt.empty() ) { + writer.BeginResourceNode( rpt.front() ); + writer.EndResourceNode(); + rpt.pop_front(); + } + writer.EndRptNode(); + + SaHpiDomainInfoT dat_di; + std::list<SaHpiAlarmT> dat; + rc = FetchDat( m_sid, dat_di, dat ); + if ( !rc ) { + return false; + } + writer.BeginDatNode( dat_di ); + while ( !dat.empty() ) { + writer.AlarmNode( dat.front() ); + dat.pop_front(); + } + writer.EndDatNode(); + + writer.EndDomainNode(); + + writer.End(); + + return true; +} + Added: openhpi/trunk/clients/hpixml/hpi.h =================================================================== --- openhpi/trunk/clients/hpixml/hpi.h (rev 0) +++ openhpi/trunk/clients/hpixml/hpi.h 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,54 @@ +/* -*- c++ -*- + * + * Copyright (C) 2010, Pigeon Point Systems + * + * 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. + * + * Author(s): + * Anton Pak <ant...@pi...> + */ + +#ifndef HPI_H_EC5AF80F_A79B_49D7_8371_F71504C426A6 +#define HPI_H_EC5AF80F_A79B_49D7_8371_F71504C426A6 + +#include <SaHpi.h> + + +class cHpiXmlWriter; + +/*************************************************** + * class cHpi + ***************************************************/ +class cHpi +{ +public: + + explicit cHpi( SaHpiDomainIdT did ); + ~cHpi(); + + bool Open(); + void Close(); + + bool Dump( cHpiXmlWriter& writer ); + +private: + + cHpi( const cHpi& ); + cHpi& operator =( const cHpi& ); + +private: + + bool m_initialized; + bool m_opened; + SaHpiDomainIdT m_did; + SaHpiSessionIdT m_sid; +}; + + +#endif /* HPI_H_EC5AF80F_A79B_49D7_8371_F71504C426A6 */ + Added: openhpi/trunk/clients/hpixml/hpi_xml_writer.cpp =================================================================== --- openhpi/trunk/clients/hpixml/hpi_xml_writer.cpp (rev 0) +++ openhpi/trunk/clients/hpixml/hpi_xml_writer.cpp 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,984 @@ +/* -*- c++ -*- + * + * Copyright (c) 2010 by Pigeon Point Systems. + * + * 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: + * Anton Pak <av...@pi...> + * + */ + +#include <string> + +#include <glib.h> + +#include <oh_utils.h> + +#include "hpi_xml_writer.h" + + +/*************************************************** + * class cHpiXmlWriter + ***************************************************/ +cHpiXmlWriter::cHpiXmlWriter( int indent_step, bool use_names ) + : cXmlWriter( "http://openhpi.org/SAI-HPI-B.03.02", + "http://openhpi.org hpixml.xsd", + indent_step, + use_names ) +{ + // empty +} + +void cHpiXmlWriter::Begin( void ) +{ + cXmlWriter::Begin( "HPI" ); +} + +void cHpiXmlWriter::End( void ) +{ + cXmlWriter::End( "HPI" ); +} + +void cHpiXmlWriter::VersionNode( const SaHpiVersionT& ver ) +{ + NodeSaHpiVersionT( "Version", ver ); +} + +void cHpiXmlWriter::BeginDomainNode( const SaHpiDomainInfoT& di ) +{ + cXmlWriter::BeginNode( "Domain" ); + NodeSaHpiDomainIdT( "DomainId", di.DomainId ); + NodeSaHpiDomainCapabilitiesT( "DomainCapabilities", di.DomainCapabilities ); + NodeSaHpiBoolT( "IsPeer", di.IsPeer ); + NodeSaHpiTextBufferT( "DomainTag", di.DomainTag ); + NodeSaHpiGuidT( "Guid", di.Guid ); +} + +void cHpiXmlWriter::EndDomainNode() +{ + cXmlWriter::EndNode( "Domain" ); +} + +void cHpiXmlWriter::BeginDrtNode( const SaHpiDomainInfoT& di ) +{ + cXmlWriter::BeginNode( "DomainReferenceTable" ); + NodeSaHpiUint32T( "DrtUpdateCount", di.DrtUpdateCount ); + NodeSaHpiTimeT( "DrtUpdateTimestamp", di.DrtUpdateTimestamp ); +} + +void cHpiXmlWriter::EndDrtNode() +{ + cXmlWriter::EndNode( "DomainReferenceTable" ); +} + +void cHpiXmlWriter::DrtEntryNode( const SaHpiDrtEntryT& drte ) +{ + cXmlWriter::BeginNode( "Reference" ); + NodeSaHpiDomainIdT( "DomainId", drte.DomainId ); + NodeSaHpiBoolT( "IsPeer", drte.IsPeer ); + cXmlWriter::EndNode( "Reference" ); +} + +void cHpiXmlWriter::BeginRptNode( const SaHpiDomainInfoT& di ) +{ + cXmlWriter::BeginNode( "ResourcePresenceTable" ); + NodeSaHpiUint32T( "RptUpdateCount", di.RptUpdateCount ); + NodeSaHpiTimeT( "RptUpdateTimestamp", di.RptUpdateTimestamp ); +} + +void cHpiXmlWriter::EndRptNode() +{ + cXmlWriter::EndNode( "ResourcePresenceTable" ); +} + +void cHpiXmlWriter::BeginResourceNode( const SaHpiRptEntryT& rpte ) +{ + const SaHpiResourceInfoT info = rpte.ResourceInfo; + + cXmlWriter::BeginNode( "Resource" ); + NodeSaHpiResourceIdT( "ResourceId", rpte.ResourceId ); + cXmlWriter::BeginNode( "ResourceInfo" ); + NodeSaHpiUint8T( "ResourceRev", info.ResourceRev ); + NodeSaHpiUint8T( "SpecificVer", info.SpecificVer ); + NodeSaHpiUint8T( "DeviceSupport", info.DeviceSupport ); + NodeSaHpiManufacturerIdT( "ManufacturerId", info.ManufacturerId ); + NodeSaHpiUint16T( "ProductId", info.ProductId ); + NodeSaHpiUint8T( "FirmwareMajorRev", info.FirmwareMajorRev ); + NodeSaHpiUint8T( "FirmwareMinorRev", info.FirmwareMinorRev ); + NodeSaHpiUint8T( "AuxFirmwareRev", info.AuxFirmwareRev ); + NodeSaHpiGuidT( "Guid", info.Guid ); + cXmlWriter::EndNode( "ResourceInfo" ); + NodeSaHpiEntityPathT( "ResourceEntity", rpte.ResourceEntity ); + NodeSaHpiCapabilitiesT( "ResourceCapabilities", rpte.ResourceCapabilities ); + NodeSaHpiHsCapabilitiesT( "HotSwapCapabilities", rpte.HotSwapCapabilities ); + NodeSaHpiSeverityT( "ResourceSeverity", rpte.ResourceSeverity ); + NodeSaHpiBoolT( "ResourceFailed", rpte.ResourceFailed ); + NodeSaHpiTextBufferT( "ResourceTag", rpte.ResourceTag ); +} + +void cHpiXmlWriter::EndResourceNode() +{ + cXmlWriter::EndNode( "Resource" ); +} + + +void cHpiXmlWriter::BeginDatNode( const SaHpiDomainInfoT& di ) +{ + cXmlWriter::BeginNode( "DomainAlarmTable" ); + NodeSaHpiUint32T( "DatUpdateCount", di.DatUpdateCount ); + NodeSaHpiTimeT( "DatUpdateTimestamp", di.DatUpdateTimestamp ); + NodeSaHpiUint32T( "ActiveAlarms", di.ActiveAlarms ); + NodeSaHpiUint32T( "CriticalAlarms", di.CriticalAlarms ); + NodeSaHpiUint32T( "MajorAlarms", di.MajorAlarms ); + NodeSaHpiUint32T( "MinorAlarms", di.MinorAlarms ); + NodeSaHpiUint32T( "DatUserAlarmLimit", di.DatUserAlarmLimit ); + NodeSaHpiBoolT( "DatOverflow", di.DatOverflow ); +} + +void cHpiXmlWriter::EndDatNode() +{ + cXmlWriter::EndNode( "DomainAlarmTable" ); +} + +void cHpiXmlWriter::AlarmNode( const SaHpiAlarmT& a ) +{ + cXmlWriter::BeginNode( "Alarm" ); + NodeSaHpiAlarmIdT( "AlarmId", a.AlarmId ); + NodeSaHpiTimeT( "Timestamp", a.Timestamp ); + NodeSaHpiSeverityT( "Severity", a.Severity ); + NodeSaHpiBoolT( "Acknowledged", a.Acknowledged ); + NodeSaHpiConditionT( "AlarmCond", a.AlarmCond ); + cXmlWriter::EndNode( "Alarm" ); +} + + +/**************************** + * Basic Types + ***************************/ +void cHpiXmlWriter::NodeSaHpiUint8T( + const char * name, + const SaHpiUint8T& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiUint16T( + const char * name, + const SaHpiUint16T& x ) + +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiUint32T( + const char * name, + const SaHpiUint32T& x ) +{ + cXmlWriter::Node( name, "%u", x ); +} + +void cHpiXmlWriter::NodeSaHpiUint64T( + const char * name, + const SaHpiUint64T& x ) +{ + cXmlWriter::Node( name, "%llu", x ); +} + +void cHpiXmlWriter::NodeSaHpiInt8T( + const char * name, + const SaHpiInt8T& x ) +{ + NodeSaHpiInt32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiInt16T( + const char * name, + const SaHpiInt16T& x ) +{ + NodeSaHpiInt32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiInt32T( + const char * name, + const SaHpiInt32T& x ) +{ + cXmlWriter::Node( name, "%d", x ); +} + +void cHpiXmlWriter::NodeSaHpiInt64T( + const char * name, + const SaHpiInt64T& x ) +{ + cXmlWriter::Node( name, "%lld", x ); +} + +void cHpiXmlWriter::NodeSaHpiFloat64T( + const char * name, + const SaHpiFloat64T& x ) +{ + cXmlWriter::Node( name, "%f", x ); +} + + +/**************************** + * Typedefs + ***************************/ +void cHpiXmlWriter::NodeSaHpiBoolT( + const char * name, + const SaHpiBoolT& x ) +{ + cXmlWriter::Node( name, "%s", ( x == SAHPI_FALSE ) ? "false" : "true" ); +} + +void cHpiXmlWriter::NodeSaHpiManufacturerIdT( + const char * name, + const SaHpiManufacturerIdT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiVersionT( + const char * name, + const SaHpiVersionT& x ) +{ + SaHpiUint8T comp = ( x >> 16 ) & 0xFF; + SaHpiUint8T major = ( x >> 8 ) & 0xFF; + SaHpiUint8T minor = x & 0xFF; + cXmlWriter::Node( name, "%c.%02u.%02u", 'A' - 1 + comp, major, minor ); +} + +void cHpiXmlWriter::NodeSaErrorT( + const char * name, + const SaErrorT& x ) +{ + NodeSaHpiInt32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiDomainIdT( + const char * name, + const SaHpiDomainIdT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiSessionIdT( + const char * name, + const SaHpiSessionIdT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiResourceIdT( + const char * name, + const SaHpiResourceIdT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiEntryIdT( + const char * name, + const SaHpiEntryIdT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiTimeT( + const char * name, + const SaHpiTimeT& x ) +{ + NodeSaHpiInt64T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiTimeoutT( + const char * name, + const SaHpiTimeoutT& x ) +{ + NodeSaHpiInt64T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiInstrumentIdT( + const char * name, + const SaHpiInstrumentIdT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiEntityLocationT( + const char * name, + const SaHpiEntityLocationT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiEventCategoryT( + const char * name, + const SaHpiEventCategoryT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiEventStateT( + const char * name, + const SaHpiEventStateT& x ) +{ + NodeSaHpiUint16T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiSensorNumT( + const char * name, + const SaHpiSensorNumT& x ) +{ + NodeSaHpiInstrumentIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiSensorRangeFlagsT( + const char * name, + const SaHpiSensorRangeFlagsT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiSensorThdMaskT( + const char * name, + const SaHpiSensorThdMaskT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiCtrlNumT( + const char * name, + const SaHpiCtrlNumT& x ) +{ + NodeSaHpiInstrumentIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiCtrlStateDiscreteT( + const char * name, + const SaHpiCtrlStateDiscreteT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiCtrlStateAnalogT( + const char * name, + const SaHpiCtrlStateAnalogT& x ) +{ + NodeSaHpiInt32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiTxtLineNumT( + const char * name, + const SaHpiTxtLineNumT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiIdrIdT( + const char * name, + const SaHpiIdrIdT& x ) +{ + NodeSaHpiInstrumentIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiWatchdogNumT( + const char * name, + const SaHpiWatchdogNumT& x ) +{ + NodeSaHpiInstrumentIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiWatchdogExpFlagsT( + const char * name, + const SaHpiWatchdogExpFlagsT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiDimiNumT( + const char * name, + const SaHpiDimiNumT& x ) +{ + NodeSaHpiInstrumentIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiDimiTestCapabilityT( + const char * name, + const SaHpiDimiTestCapabilityT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiDimiTestNumT( + const char * name, + const SaHpiDimiTestNumT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiDimiTestPercentCompletedT( + const char * name, + const SaHpiDimiTestPercentCompletedT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiFumiNumT( + const char * name, + const SaHpiFumiNumT& x ) +{ + NodeSaHpiInstrumentIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiBankNumT( + const char * name, + const SaHpiBankNumT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiFumiLogicalBankStateFlagsT( + const char * name, + const SaHpiFumiLogicalBankStateFlagsT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiFumiProtocolT( + const char * name, + const SaHpiFumiProtocolT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiFumiCapabilityT( + const char * name, + const SaHpiFumiCapabilityT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiSensorOptionalDataT( + const char * name, + const SaHpiSensorOptionalDataT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiSensorEnableOptDataT( + const char * name, + const SaHpiSensorEnableOptDataT& x ) +{ + NodeSaHpiUint8T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiEvtQueueStatusT( + const char * name, + const SaHpiEvtQueueStatusT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiAnnunciatorNumT( + const char * name, + const SaHpiAnnunciatorNumT& x ) +{ + NodeSaHpiInstrumentIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiLoadNumberT( + const char * name, + const SaHpiLoadNumberT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiCapabilitiesT( + const char * name, + const SaHpiCapabilitiesT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiHsCapabilitiesT( + const char * name, + const SaHpiHsCapabilitiesT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiDomainCapabilitiesT( + const char * name, + const SaHpiDomainCapabilitiesT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiAlarmIdT( + const char * name, + const SaHpiAlarmIdT& x ) +{ + NodeSaHpiEntryIdT( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiEventLogCapabilitiesT( + const char * name, + const SaHpiEventLogCapabilitiesT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + +void cHpiXmlWriter::NodeSaHpiEventLogEntryIdT( + const char * name, + const SaHpiEventLogEntryIdT& x ) +{ + NodeSaHpiUint32T( name, x ); +} + + +/**************************** + * Enums + ***************************/ +void cHpiXmlWriter::NodeSaHpiLanguageT( + const char * name, + const SaHpiLanguageT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_language ); +} + +void cHpiXmlWriter::NodeSaHpiTextTypeT( + const char * name, + const SaHpiTextTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_texttype ); +} + +void cHpiXmlWriter::NodeSaHpiEntityTypeT( + const char * name, + const SaHpiEntityTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_entitytype ); +} + +void cHpiXmlWriter::NodeSaHpiSensorTypeT( + const char * name, + const SaHpiSensorTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_sensortype ); +} + +void cHpiXmlWriter::NodeSaHpiSensorReadingTypeT( + const char * name, + const SaHpiSensorReadingTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_sensorreadingtype ); +} + +void cHpiXmlWriter::NodeSaHpiSensorEventMaskActionT( + const char * name, + const SaHpiSensorEventMaskActionT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_sensoreventmaskaction ); +} + +void cHpiXmlWriter::NodeSaHpiSensorUnitsT( + const char * name, + const SaHpiSensorUnitsT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_sensorunits ); +} + +void cHpiXmlWriter::NodeSaHpiSensorModUnitUseT( + const char * name, + const SaHpiSensorModUnitUseT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_sensormodunituse ); +} + +void cHpiXmlWriter::NodeSaHpiSensorEventCtrlT( + const char * name, + const SaHpiSensorEventCtrlT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_sensoreventctrl ); +} + +void cHpiXmlWriter::NodeSaHpiCtrlTypeT( + const char * name, + const SaHpiCtrlTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_ctrltype ); +} + +void cHpiXmlWriter::NodeSaHpiCtrlStateDigitalT( + const char * name, + const SaHpiCtrlStateDigitalT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_ctrlstatedigital ); +} + +void cHpiXmlWriter::NodeSaHpiCtrlModeT( + const char * name, + const SaHpiCtrlModeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_ctrlmode ); +} + +void cHpiXmlWriter::NodeSaHpiCtrlOutputTypeT( + const char * name, + const SaHpiCtrlOutputTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_ctrloutputtype ); +} + +void cHpiXmlWriter::NodeSaHpiIdrAreaTypeT( + const char * name, + const SaHpiIdrAreaTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_idrareatype ); +} + +void cHpiXmlWriter::NodeSaHpiIdrFieldTypeT( + const char * name, + const SaHpiIdrFieldTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_idrfieldtype ); +} + +void cHpiXmlWriter::NodeSaHpiWatchdogActionT( + const char * name, + const SaHpiWatchdogActionT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_watchdogaction ); +} + +void cHpiXmlWriter::NodeSaHpiWatchdogActionEventT( + const char * name, + const SaHpiWatchdogActionEventT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_watchdogactionevent ); +} + +void cHpiXmlWriter::NodeSaHpiWatchdogPretimerInterruptT( + const char * name, + const SaHpiWatchdogPretimerInterruptT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_watchdogpretimerinterrupt ); +} + +void cHpiXmlWriter::NodeSaHpiWatchdogTimerUseT( + const char * name, + const SaHpiWatchdogTimerUseT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_watchdogtimeruse ); +} + +void cHpiXmlWriter::NodeSaHpiDimiTestServiceImpactT( + const char * name, + const SaHpiDimiTestServiceImpactT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_dimitestserviceimpact ); +} + +void cHpiXmlWriter::NodeSaHpiDimiTestRunStatusT( + const char * name, + const SaHpiDimiTestRunStatusT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_dimitestrunstatus ); +} + +void cHpiXmlWriter::NodeSaHpiDimiTestErrCodeT( + const char * name, + const SaHpiDimiTestErrCodeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_dimitesterrcode ); +} + +void cHpiXmlWriter::NodeSaHpiDimiTestParamTypeT( + const char * name, + const SaHpiDimiTestParamTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_dimitestparamtype ); +} + +void cHpiXmlWriter::NodeSaHpiDimiReadyT( + const char * name, + const SaHpiDimiReadyT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_dimiready ); +} + +void cHpiXmlWriter::NodeSaHpiFumiSpecInfoTypeT( + const char * name, + const SaHpiFumiSpecInfoTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_fumispecinfotype ); +} + +void cHpiXmlWriter::NodeSaHpiFumiSafDefinedSpecIdT( + const char * name, + const SaHpiFumiSafDefinedSpecIdT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_fumisafdefinedspecid ); +} + +void cHpiXmlWriter::NodeSaHpiFumiServiceImpactT( + const char * name, + const SaHpiFumiServiceImpactT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_fumiserviceimpact ); +} + +void cHpiXmlWriter::NodeSaHpiFumiSourceStatusT( + const char * name, + const SaHpiFumiSourceStatusT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_fumisourcestatus ); +} + +void cHpiXmlWriter::NodeSaHpiFumiBankStateT( + const char * name, + const SaHpiFumiBankStateT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_fumibankstate ); +} + +void cHpiXmlWriter::NodeSaHpiFumiUpgradeStatusT( + const char * name, + const SaHpiFumiUpgradeStatusT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_fumiupgradestatus ); +} + +void cHpiXmlWriter::NodeSaHpiHsIndicatorStateT( + const char * name, + const SaHpiHsIndicatorStateT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_hsindicatorstate ); +} + +void cHpiXmlWriter::NodeSaHpiHsActionT( + const char * name, + const SaHpiHsActionT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_hsaction ); +} + +void cHpiXmlWriter::NodeSaHpiHsStateT( + const char * name, + const SaHpiHsStateT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_hsstate ); +} + +void cHpiXmlWriter::NodeSaHpiHsCauseOfStateChangeT( + const char * name, + const SaHpiHsCauseOfStateChangeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_hscauseofstatechange ); +} + +void cHpiXmlWriter::NodeSaHpiSeverityT( + const char * name, + const SaHpiSeverityT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_severity ); +} + +void cHpiXmlWriter::NodeSaHpiResourceEventTypeT( + const char * name, + const SaHpiResourceEventTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_resourceeventtype ); +} + +void cHpiXmlWriter::NodeSaHpiDomainEventTypeT( + const char * name, + const SaHpiDomainEventTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_domaineventtype ); +} + +void cHpiXmlWriter::NodeSaHpiSwEventTypeT( + const char * name, + const SaHpiSwEventTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_sweventtype ); +} + +void cHpiXmlWriter::NodeSaHpiEventTypeT( + const char * name, + const SaHpiEventTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_eventtype ); +} + +void cHpiXmlWriter::NodeSaHpiStatusCondTypeT( + const char * name, + const SaHpiStatusCondTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_statuscondtype ); +} + +void cHpiXmlWriter::NodeSaHpiAnnunciatorModeT( + const char * name, + const SaHpiAnnunciatorModeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_annunciatormode ); +} + +void cHpiXmlWriter::NodeSaHpiAnnunciatorTypeT( + const char * name, + const SaHpiAnnunciatorTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_annunciatortype ); +} + +void cHpiXmlWriter::NodeSaHpiRdrTypeT( + const char * name, + const SaHpiRdrTypeT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_rdrtype ); +} + +void cHpiXmlWriter::NodeSaHpiParmActionT( + const char * name, + const SaHpiParmActionT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_parmaction ); +} + +void cHpiXmlWriter::NodeSaHpiResetActionT( + const char * name, + const SaHpiResetActionT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_resetaction ); +} + +void cHpiXmlWriter::NodeSaHpiPowerStateT( + const char * name, + const SaHpiPowerStateT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_powerstate ); +} + +void cHpiXmlWriter::NodeSaHpiEventLogOverflowActionT( + const char * name, + const SaHpiEventLogOverflowActionT& x ) +{ + cXmlWriter::NodeEnum( name, x, oh_lookup_eventlogoverflowaction ); +} + + +/**************************** + * Complex Types + ***************************/ +void cHpiXmlWriter::NodeSaHpiTextBufferT( + const char * name, + const SaHpiTextBufferT& x ) +{ + std::string s; + + cXmlWriter::BeginNode( name ); + NodeSaHpiTextTypeT( "DataType", x.DataType ); + NodeSaHpiLanguageT( "Language", x.Language ); + NodeSaHpiUint8T( "DataLength", x.DataLength ); + switch ( x.DataType ) { + case SAHPI_TL_TYPE_UNICODE: // UTF-16, Little-Endian + for ( size_t i = 0; i < x.DataLength; i += 2 ) { + gunichar2 utf16; + utf16 = ( ( (gunichar2)x.Data[i + 1] ) << 8 ) | x.Data[i]; + gchar * utf8 = g_utf16_to_utf8( &utf16, 1, 0, 0, 0 ); + if ( utf8 ) { + s.append( utf8 ); + g_free( utf8 ); + } else { + s.push_back( '?' ); + } + } + cXmlWriter::Node( "Data", "%s", s.c_str() ); + break; + case SAHPI_TL_TYPE_BCDPLUS: + case SAHPI_TL_TYPE_ASCII6: + case SAHPI_TL_TYPE_TEXT: + s.assign( reinterpret_cast<const char *>(&x.Data[0]), x.DataLength ); + cXmlWriter::Node( "Data", "%s", s.c_str() ); + break; + case SAHPI_TL_TYPE_BINARY: + default: + cXmlWriter::NodeHex( "Data", &x.Data[0], x.DataLength ); + } + cXmlWriter::EndNode( name ); +} + +void cHpiXmlWriter::NodeSaHpiEntityPathT( + const char * name, + const SaHpiEntityPathT& x ) +{ + SaErrorT rv; + oh_big_textbuffer buf; + rv = oh_init_bigtext( &buf ); + if ( rv == SA_OK ) { + rv = oh_decode_entitypath( &x, &buf ); + } + if ( rv == SA_OK ) { + cXmlWriter::Node( name, + "%s", + reinterpret_cast<const char *>(&buf.Data[0]) ); + } else { + cXmlWriter::Node( name, "%s", "{UNKNOWN, 0}" ); + } +} + +void cHpiXmlWriter::NodeSaHpiConditionT( + const char * name, + const SaHpiConditionT& x ) +{ + cXmlWriter::BeginNode( name ); + NodeSaHpiStatusCondTypeT( "Type", x.Type ); + +typedef struct { + + SaHpiStatusCondTypeT Type; /* Status Condition Type */ + SaHpiEntityPathT Entity; /* Entity assoc. with status condition */ + SaHpiDomainIdT DomainId; /* Domain associated with status. + May be SAHPI_UNSPECIFIED_DOMAIN_ID + meaning current domain, or domain + not meaningful for status condition*/ + SaHpiResourceIdT ResourceId; /* Resource associated with status. + May be SAHPI_UNSPECIFIED_RESOURCE_ID + if Type is SAHPI_STATUS_COND_USER. + Must be set to valid ResourceId in + domain specified by DomainId, + or in current domain, if DomainId + is SAHPI_UNSPECIFIED_DOMAIN_ID */ + SaHpiSensorNumT SensorNum; /* Sensor associated with status + Only valid if Type is + SAHPI_STATUS_COND_TYPE_SENSOR */ + SaHpiEventStateT EventState; /* Sensor event state. + Only valid if Type is + SAHPI_STATUS_COND_TYPE_SENSOR. */ + SaHpiNameT Name; /* AIS compatible identifier associated + with Status condition */ + SaHpiManufacturerIdT Mid; /* Manufacturer Id associated with + status condition, required when type + is SAHPI_STATUS_COND_TYPE_OEM. */ + SaHpiTextBufferT Data; /* Optional Data associated with + Status condition */ +} SaHpiConditionT; + + + cXmlWriter::EndNode( name ); +} + +void cHpiXmlWriter::NodeSaHpiGuidT( + const char * name, + const SaHpiGuidT& x ) +{ + cXmlWriter::NodeHex( name, &x[0], sizeof(x) ); +} + Added: openhpi/trunk/clients/hpixml/hpi_xml_writer.h =================================================================== --- openhpi/trunk/clients/hpixml/hpi_xml_writer.h (rev 0) +++ openhpi/trunk/clients/hpixml/hpi_xml_writer.h 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,493 @@ +/* -*- c++ -*- + * + * Copyright (C) 2010, Pigeon Point Systems + * + * 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. + * + * Author(s): + * Anton Pak <ant...@pi...> + */ + +#ifndef HPI_XML_WRITER_H_EC5AF80F_A79B_49D7_8371_F71504C426A6 +#define HPI_XML_WRITER_H_EC5AF80F_A79B_49D7_8371_F71504C426A6 + +#include <SaHpi.h> + +#include "xml_writer.h" + + +/*************************************************** + * class cHpiXmlWriter + ***************************************************/ +class cHpiXmlWriter : private cXmlWriter +{ +public: + + explicit cHpiXmlWriter( int indent_step, bool use_names ); + + void Begin( void ); + void End( void ); + + void VersionNode( const SaHpiVersionT& ver ); + + void BeginDomainNode( const SaHpiDomainInfoT& di ); + void EndDomainNode(); + + void BeginDrtNode( const SaHpiDomainInfoT& di ); + void EndDrtNode(); + void DrtEntryNode( const SaHpiDrtEntryT& drte ); + + void BeginRptNode( const SaHpiDomainInfoT& di ); + void EndRptNode(); + void BeginResourceNode( const SaHpiRptEntryT& rpte ); + void EndResourceNode(); + + void BeginDatNode( const SaHpiDomainInfoT& di ); + void EndDatNode(); + void AlarmNode( const SaHpiAlarmT& a ); + +private: + + /**************************** + * Basic Types + ***************************/ + void NodeSaHpiUint8T( + const char * name, + const SaHpiUint8T& x + ); + void NodeSaHpiUint16T( + const char * name, + const SaHpiUint16T& x + ); + void NodeSaHpiUint32T( + const char * name, + const SaHpiUint32T& x + ); + void NodeSaHpiUint64T( + const char * name, + const SaHpiUint64T& x + ); + void NodeSaHpiInt8T( + const char * name, + const SaHpiInt8T& x + ); + void NodeSaHpiInt16T( + const char * name, + const SaHpiInt16T& x + ); + void NodeSaHpiInt32T( + const char * name, + const SaHpiInt32T& x + ); + void NodeSaHpiInt64T( + const char * name, + const SaHpiInt64T& x + ); + void NodeSaHpiFloat64T( + const char * name, + const SaHpiFloat64T& x + ); + + /**************************** + * Typedefs + ***************************/ + void NodeSaHpiBoolT( + const char * name, + const SaHpiBoolT& x + ); + void NodeSaHpiManufacturerIdT( + const char * name, + const SaHpiManufacturerIdT& x + ); + void NodeSaHpiVersionT( + const char * name, + const SaHpiVersionT& x + ); + void NodeSaErrorT( + const char * name, + const SaErrorT& x + ); + void NodeSaHpiDomainIdT( + const char * name, + const SaHpiDomainIdT& x + ); + void NodeSaHpiSessionIdT( + const char * name, + const SaHpiSessionIdT& x + ); + void NodeSaHpiResourceIdT( + const char * name, + const SaHpiResourceIdT& x + ); + void NodeSaHpiEntryIdT( + const char * name, + const SaHpiEntryIdT& x + ); + void NodeSaHpiTimeT( + const char * name, + const SaHpiTimeT& x + ); + void NodeSaHpiTimeoutT( + const char * name, + const SaHpiTimeoutT& x + ); + void NodeSaHpiInstrumentIdT( + const char * name, + const SaHpiInstrumentIdT& x + ); + void NodeSaHpiEntityLocationT( + const char * name, + const SaHpiEntityLocationT& x + ); + void NodeSaHpiEventCategoryT( + const char * name, + const SaHpiEventCategoryT& x + ); + void NodeSaHpiEventStateT( + const char * name, + const SaHpiEventStateT& x + ); + void NodeSaHpiSensorNumT( + const char * name, + const SaHpiSensorNumT& x + ); + void NodeSaHpiSensorRangeFlagsT( + const char * name, + const SaHpiSensorRangeFlagsT& x + ); + void NodeSaHpiSensorThdMaskT( + const char * name, + const SaHpiSensorThdMaskT& x + ); + void NodeSaHpiCtrlNumT( + const char * name, + const SaHpiCtrlNumT& x + ); + void NodeSaHpiCtrlStateDiscreteT( + const char * name, + const SaHpiCtrlStateDiscreteT& x + ); + void NodeSaHpiCtrlStateAnalogT( + const char * name, + const SaHpiCtrlStateAnalogT& x + ); + void NodeSaHpiTxtLineNumT( + const char * name, + const SaHpiTxtLineNumT& x + ); + void NodeSaHpiIdrIdT( + const char * name, + const SaHpiIdrIdT& x + ); + void NodeSaHpiWatchdogNumT( + const char * name, + const SaHpiWatchdogNumT& x + ); + void NodeSaHpiWatchdogExpFlagsT( + const char * name, + const SaHpiWatchdogExpFlagsT& x + ); + void NodeSaHpiDimiNumT( + const char * name, + const SaHpiDimiNumT& x + ); + void NodeSaHpiDimiTestCapabilityT( + const char * name, + const SaHpiDimiTestCapabilityT& x + ); + void NodeSaHpiDimiTestNumT( + const char * name, + const SaHpiDimiTestNumT& x + ); + void NodeSaHpiDimiTestPercentCompletedT( + const char * name, + const SaHpiDimiTestPercentCompletedT& x + ); + void NodeSaHpiFumiNumT( + const char * name, + const SaHpiFumiNumT& x + ); + void NodeSaHpiBankNumT( + const char * name, + const SaHpiBankNumT& x + ); + void NodeSaHpiFumiLogicalBankStateFlagsT( + const char * name, + const SaHpiFumiLogicalBankStateFlagsT& x + ); + void NodeSaHpiFumiProtocolT( + const char * name, + const SaHpiFumiProtocolT& x + ); + void NodeSaHpiFumiCapabilityT( + const char * name, + const SaHpiFumiCapabilityT& x + ); + void NodeSaHpiSensorOptionalDataT( + const char * name, + const SaHpiSensorOptionalDataT& x + ); + void NodeSaHpiSensorEnableOptDataT( + const char * name, + const SaHpiSensorEnableOptDataT& x + ); + void NodeSaHpiEvtQueueStatusT( + const char * name, + const SaHpiEvtQueueStatusT& x + ); + void NodeSaHpiAnnunciatorNumT( + const char * name, + const SaHpiAnnunciatorNumT& x + ); + void NodeSaHpiLoadNumberT( + const char * name, + const SaHpiLoadNumberT& x + ); + void NodeSaHpiCapabilitiesT( + const char * name, + const SaHpiCapabilitiesT& x + ); + void NodeSaHpiHsCapabilitiesT( + const char * name, + const SaHpiHsCapabilitiesT& x + ); + void NodeSaHpiDomainCapabilitiesT( + const char * name, + const SaHpiDomainCapabilitiesT& x + ); + void NodeSaHpiAlarmIdT( + const char * name, + const SaHpiAlarmIdT& x + ); + void NodeSaHpiEventLogCapabilitiesT( + const char * name, + const SaHpiEventLogCapabilitiesT& x + ); + void NodeSaHpiEventLogEntryIdT( + const char * name, + const SaHpiEventLogEntryIdT& x + ); + + + /**************************** + * Enums + ***************************/ + void NodeSaHpiLanguageT( + const char * name, + const SaHpiLanguageT& x + ); + void NodeSaHpiTextTypeT( + const char * name, + const SaHpiTextTypeT& x + ); + void NodeSaHpiEntityTypeT( + const char * name, + const SaHpiEntityTypeT& x + ); + void NodeSaHpiSensorTypeT( + const char * name, + const SaHpiSensorTypeT& x + ); + void NodeSaHpiSensorReadingTypeT( + const char * name, + const SaHpiSensorReadingTypeT& x + ); + void NodeSaHpiSensorEventMaskActionT( + const char * name, + const SaHpiSensorEventMaskActionT& x + ); + void NodeSaHpiSensorUnitsT( + const char * name, + const SaHpiSensorUnitsT& x + ); + void NodeSaHpiSensorModUnitUseT( + const char * name, + const SaHpiSensorModUnitUseT& x + ); + void NodeSaHpiSensorEventCtrlT( + const char * name, + const SaHpiSensorEventCtrlT& x + ); + void NodeSaHpiCtrlTypeT( + const char * name, + const SaHpiCtrlTypeT& x + ); + void NodeSaHpiCtrlStateDigitalT( + const char * name, + const SaHpiCtrlStateDigitalT& x + ); + void NodeSaHpiCtrlModeT( + const char * name, + const SaHpiCtrlModeT& x + ); + void NodeSaHpiCtrlOutputTypeT( + const char * name, + const SaHpiCtrlOutputTypeT& x + ); + void NodeSaHpiIdrAreaTypeT( + const char * name, + const SaHpiIdrAreaTypeT& x + ); + void NodeSaHpiIdrFieldTypeT( + const char * name, + const SaHpiIdrFieldTypeT& x + ); + void NodeSaHpiWatchdogActionT( + const char * name, + const SaHpiWatchdogActionT& x + ); + void NodeSaHpiWatchdogActionEventT( + const char * name, + const SaHpiWatchdogActionEventT& x + ); + void NodeSaHpiWatchdogPretimerInterruptT( + const char * name, + const SaHpiWatchdogPretimerInterruptT& x + ); + void NodeSaHpiWatchdogTimerUseT( + const char * name, + const SaHpiWatchdogTimerUseT& x + ); + void NodeSaHpiDimiTestServiceImpactT( + const char * name, + const SaHpiDimiTestServiceImpactT& x + ); + void NodeSaHpiDimiTestRunStatusT( + const char * name, + const SaHpiDimiTestRunStatusT& x + ); + void NodeSaHpiDimiTestErrCodeT( + const char * name, + const SaHpiDimiTestErrCodeT& x + ); + void NodeSaHpiDimiTestParamTypeT( + const char * name, + const SaHpiDimiTestParamTypeT& x + ); + void NodeSaHpiDimiReadyT( + const char * name, + const SaHpiDimiReadyT& x + ); + void NodeSaHpiFumiSpecInfoTypeT( + const char * name, + const SaHpiFumiSpecInfoTypeT& x + ); + void NodeSaHpiFumiSafDefinedSpecIdT( + const char * name, + const SaHpiFumiSafDefinedSpecIdT& x + ); + void NodeSaHpiFumiServiceImpactT( + const char * name, + const SaHpiFumiServiceImpactT& x + ); + void NodeSaHpiFumiSourceStatusT( + const char * name, + const SaHpiFumiSourceStatusT& x + ); + void NodeSaHpiFumiBankStateT( + const char * name, + const SaHpiFumiBankStateT& x + ); + void NodeSaHpiFumiUpgradeStatusT( + const char * name, + const SaHpiFumiUpgradeStatusT& x + ); + void NodeSaHpiHsIndicatorStateT( + const char * name, + const SaHpiHsIndicatorStateT& x + ); + void NodeSaHpiHsActionT( + const char * name, + const SaHpiHsActionT& x + ); + void NodeSaHpiHsStateT( + const char * name, + const SaHpiHsStateT& x + ); + void NodeSaHpiHsCauseOfStateChangeT( + const char * name, + const SaHpiHsCauseOfStateChangeT& x + ); + void NodeSaHpiSeverityT( + const char * name, + const SaHpiSeverityT& x + ); + void NodeSaHpiResourceEventTypeT( + const char * name, + const SaHpiResourceEventTypeT& x + ); + void NodeSaHpiDomainEventTypeT( + const char * name, + const SaHpiDomainEventTypeT& x + ); + void NodeSaHpiSwEventTypeT( + const char * name, + const SaHpiSwEventTypeT& x + ); + void NodeSaHpiEventTypeT( + const char * name, + const SaHpiEventTypeT& x + ); + void NodeSaHpiStatusCondTypeT( + const char * name, + const SaHpiStatusCondTypeT& x + ); + void NodeSaHpiAnnunciatorModeT( + const char * name, + const SaHpiAnnunciatorModeT& x + ); + void NodeSaHpiAnnunciatorTypeT( + const char * name, + const SaHpiAnnunciatorTypeT& x + ); + void NodeSaHpiRdrTypeT( + const char * name, + const SaHpiRdrTypeT& x + ); + void NodeSaHpiParmActionT( + const char * name, + const SaHpiParmActionT& x + ); + void NodeSaHpiResetActionT( + const char * name, + const SaHpiResetActionT& x + ); + void NodeSaHpiPowerStateT( + const char * name, + const SaHpiPowerStateT& x + ); + void NodeSaHpiEventLogOverflowActionT( + const char * name, + const SaHpiEventLogOverflowActionT& x + ); + + + /**************************** + * Complex Types + ***************************/ + void NodeSaHpiTextBufferT( + const char * name, + const SaHpiTextBufferT& x + ); + void NodeSaHpiEntityPathT( + const char * name, + const SaHpiEntityPathT& x + ); + void NodeSaHpiConditionT( + const char * name, + const SaHpiConditionT& x + ); + void NodeSaHpiGuidT( + const char * name, + const SaHpiGuidT& x + ); +}; + + +#endif /* HPI_XML_WRITER_H_EC5AF80F_A79B_49D7_8371_F71504C426A6 */ + Added: openhpi/trunk/clients/hpixml/main.cpp =================================================================== --- openhpi/trunk/clients/hpixml/main.cpp (rev 0) +++ openhpi/trunk/clients/hpixml/main.cpp 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,100 @@ +/* -*- c++ -*- + * + * Copyright (c) 2010 by Pigeon Point Systems. + * + * 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: + * Anton Pak <av...@pi...> + * + */ + +#include <getopt.h> +#include <stdio.h> +#include <stdlib.h> + +#include <oh_error.h> + +#include "hpi.h" +#include "hpi_xml_writer.h" +#include "schema.h" + + +/*************************************************** + * Main + ***************************************************/ +int main( int argc, char * argv[] ) +{ + int indent_step = 0; + bool use_names = false; + + SaHpiDomainIdT did = SAHPI_UNSPECIFIED_DOMAIN_ID; + + int c; + bool print_usage = false; + bool print_xsd = false; + while ( ( c = getopt( argc, argv,"D:its") ) != EOF ) { + switch( c ) { + case 'D': + if ( optarg ) { + did = atoi( optarg ); + } else { + print_usage = true; + } + break; + case 'i': + indent_step = 1; + break; + case 't': + use_names = true; + break; + case 's': + print_xsd = true; + break; + default: + print_usage = true; + break; + } + } + if ( optind < argc ) { + print_usage = true; + } + if ( print_usage ) { + printf( "Usage: %s [-option]\n\n", argv[0] ); + printf( " (No Option) Work with default domain\n" ); + printf( " -D nn Select domain id nn\n" ); + printf( " -i Use indentation\n" ); + printf( " -t Use enum and flag text names instead of raw values\n" ); + printf( " -s Show XML schema\n" ); + printf( "\n" ); + return 1; + } + if ( print_xsd ) { + for ( char * p = SCHEMA_START; p < SCHEMA_END; ++p ) { + fwrite( p, 1, 1, stdout ); + } + return 0; + } + + bool rc; + + cHpi hpi( did ); + rc = hpi.Open(); + if ( !rc ) { + return 1; + } + cHpiXmlWriter writer( indent_step, use_names ); + rc = hpi.Dump( writer ); + if ( !rc ) { + CRIT( "Failed to produce XML" ); + return 1; + } + + return 0; +} + Added: openhpi/trunk/clients/hpixml/schema.h =================================================================== --- openhpi/trunk/clients/hpixml/schema.h (rev 0) +++ openhpi/trunk/clients/hpixml/schema.h 2011-01-10 19:26:26 UTC (rev 7243) @@ -0,0 +1,43 @@ +/* -*- c++ -*- + * + * Copyright (C) 2010, Pigeon Point Systems + * + * 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 + * fi... [truncated message content] |
From: <av...@us...> - 2011-01-10 21:43:56
|
Revision: 7244 http://openhpi.svn.sourceforge.net/openhpi/?rev=7244&view=rev Author: avpak Date: 2011-01-10 21:43:49 +0000 (Mon, 10 Jan 2011) Log Message: ----------- More on hpixml. Fixed distcheck Modified Paths: -------------- openhpi/trunk/Makefile.mingw32.def openhpi/trunk/README.windows openhpi/trunk/clients/hpixml/Makefile.am openhpi/trunk/clients/hpixml/Makefile.mingw32 openhpi/trunk/clients/hpixml/main.cpp openhpi/trunk/clients/hpixml/schema.h openhpi/trunk/configure.ac Added Paths: ----------- openhpi/trunk/clients/hpixml/schema.S Modified: openhpi/trunk/Makefile.mingw32.def =================================================================== --- openhpi/trunk/Makefile.mingw32.def 2011-01-10 19:26:26 UTC (rev 7243) +++ openhpi/trunk/Makefile.mingw32.def 2011-01-10 21:43:49 UTC (rev 7244) @@ -5,7 +5,7 @@ CC := ${TOOLCHAIN_PATH}/bin/i386-mingw32-gcc CXX := ${TOOLCHAIN_PATH}/bin/i386-mingw32-g++ -LD := ${TOOLCHAIN_PATH}/bin/i386-mingw32-ld +AS := ${TOOLCHAIN_PATH}/bin/i386-mingw32-as GLIB_DIR := /home/avpak/usr/cross/mingw32/i386-mingw32/glib-2.0 Modified: openhpi/trunk/README.windows =================================================================== --- openhpi/trunk/README.windows 2011-01-10 19:26:26 UTC (rev 7243) +++ openhpi/trunk/README.windows 2011-01-10 21:43:49 UTC (rev 7244) @@ -53,8 +53,7 @@ - Get archive with glib2 for windows and unpack it somewhere. - Enter openhpi source tree root directory. - Modify Makefile.mingw32.def: --- TOOLCHAIN_PATH in order that CC and CXX point to C and C++ - compilers correspondingly. +-- TOOLCHAIN_PATH in order that CC, CXX and AS point to correct files. -- GLIB_DIR: in order that GLIB_INCLUDES and GLIB_LIBS point to valid directories with glib headers and libraries. - Run "make -f Makefile.mingw32". Modified: openhpi/trunk/clients/hpixml/Makefile.am =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.am 2011-01-10 19:26:26 UTC (rev 7243) +++ openhpi/trunk/clients/hpixml/Makefile.am 2011-01-10 21:43:49 UTC (rev 7244) @@ -2,10 +2,11 @@ MOSTLYCLEANFILES = @TEST_CLEAN@ AM_CPPFLAGS = -DG_LOG_DOMAIN=\"hpixml\" +AM_CCASFLAGS = -DSCHEMA=\"$(srcdir)/schema.xsd\" INCLUDES = @OPENHPI_INCLUDES@ -EXTRA_DIST = Makefile.mingw32 +EXTRA_DIST = Makefile.mingw32 schema.xsd bin_PROGRAMS = hpixml @@ -16,15 +17,12 @@ hpi_xml_writer.h \ main.cpp \ schema.h \ - schema.xsd \ + schema.S \ xml_writer.cpp \ xml_writer.h hpixml_LDADD = $(top_builddir)/baselib/libopenhpi.la -.xsd.o: - ${LD} -r -b binary -o $@ $< - clean-local: rm -f *~ *.o Modified: openhpi/trunk/clients/hpixml/Makefile.mingw32 =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.mingw32 2011-01-10 19:26:26 UTC (rev 7243) +++ openhpi/trunk/clients/hpixml/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) @@ -5,13 +5,13 @@ SRC := \ hpi.cpp \ hpi_xml_writer.cpp \ - schema.xsd \ + schema.S \ main.cpp \ xml_writer.cpp -OBJ := $(patsubst %.xsd, %.o,$(patsubst %.cpp, %.o, ${SRC} ) ) +OBJ := $(patsubst %.S, %.o,$(patsubst %.cpp, %.o, ${SRC} ) ) -DEFS := -DG_LOG_DOMAIN=\"hpixml\" +DEFS := -DG_LOG_DOMAIN=\"hpixml\" -DSCHEMA=\"schema.xsd\" INCLUDES := ${GLIB_INCLUDES} INCLUDES += -I ../../mingw32 -I ../../include -I ../../utils @@ -26,9 +26,6 @@ all : ${TARGET} -%.o : %.xsd - ${LD} -r -b binary -o $@ $^ - ${TARGET} : ${OBJ} ${CXX} -o $@ $^ ${LIBS} Modified: openhpi/trunk/clients/hpixml/main.cpp =================================================================== --- openhpi/trunk/clients/hpixml/main.cpp 2011-01-10 19:26:26 UTC (rev 7243) +++ openhpi/trunk/clients/hpixml/main.cpp 2011-01-10 21:43:49 UTC (rev 7244) @@ -75,7 +75,7 @@ return 1; } if ( print_xsd ) { - for ( char * p = SCHEMA_START; p < SCHEMA_END; ++p ) { + for ( char * p = &schema_begin; p < &schema_end; ++p ) { fwrite( p, 1, 1, stdout ); } return 0; Added: openhpi/trunk/clients/hpixml/schema.S =================================================================== --- openhpi/trunk/clients/hpixml/schema.S (rev 0) +++ openhpi/trunk/clients/hpixml/schema.S 2011-01-10 21:43:49 UTC (rev 7244) @@ -0,0 +1,12 @@ +.data + +.globl schema_begin +.globl _schema_begin +.globl schema_end +.globl _schema_end +schema_begin: +_schema_begin: +.incbin SCHEMA +schema_end: +_schema_end: + Modified: openhpi/trunk/clients/hpixml/schema.h =================================================================== --- openhpi/trunk/clients/hpixml/schema.h 2011-01-10 19:26:26 UTC (rev 7243) +++ openhpi/trunk/clients/hpixml/schema.h 2011-01-10 21:43:49 UTC (rev 7244) @@ -20,22 +20,9 @@ extern "C" { -#ifdef WIN32 +extern char schema_begin; +extern char schema_end; -extern char binary_schema_xsd_start; -extern char binary_schema_xsd_end; -#define SCHEMA_START (&binary_schema_xsd_start) -#define SCHEMA_END (&binary_schema_xsd_end) - -#else - -extern char _binary_schema_xsd_start; -extern char _binary_schema_xsd_end; -#define SCHEMA_START (&_binary_schema_xsd_start) -#define SCHEMA_END (&_binary_schema_xsd_end) - -#endif - }; Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2011-01-10 19:26:26 UTC (rev 7243) +++ openhpi/trunk/configure.ac 2011-01-10 21:43:49 UTC (rev 7244) @@ -35,6 +35,7 @@ dnl Checks for programs AC_PROG_CC +AM_PROG_AS AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL AC_PROG_LN_S This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-01-15 23:34:39
|
Revision: 7245 http://openhpi.svn.sourceforge.net/openhpi/?rev=7245&view=rev Author: avpak Date: 2011-01-15 23:34:32 +0000 (Sat, 15 Jan 2011) Log Message: ----------- More on Windows libraries. - Introduced Side-by-Side assemblies. - Updated README - Removed version from DLL file names Modified Paths: -------------- openhpi/trunk/Makefile.am openhpi/trunk/Makefile.mingw32 openhpi/trunk/Makefile.mingw32.def openhpi/trunk/README.windows openhpi/trunk/baselib/Makefile.mingw32 openhpi/trunk/clients/Makefile.am openhpi/trunk/clients/Makefile.mingw32 openhpi/trunk/clients/hpixml/Makefile.am openhpi/trunk/clients/hpixml/Makefile.mingw32 openhpi/trunk/marshal/Makefile.mingw32 openhpi/trunk/openhpid/Makefile.am openhpi/trunk/openhpid/Makefile.mingw32 openhpi/trunk/openhpid/plugin.c openhpi/trunk/plugins/slave/Makefile.mingw32 openhpi/trunk/plugins/slave/baselib.cpp openhpi/trunk/transport/Makefile.mingw32 openhpi/trunk/utils/Makefile.mingw32 Added Paths: ----------- openhpi/trunk/clients/hpixml/manifest.rc openhpi/trunk/clients/manifest.rc openhpi/trunk/mingw32/app.manifest openhpi/trunk/mingw32/openhpi.windows.libraries.manifest openhpi/trunk/mingw32/openhpi.windows.plugins.manifest openhpi/trunk/mingw32/openhpid.manifest openhpi/trunk/openhpid/manifest.rc Modified: openhpi/trunk/Makefile.am =================================================================== --- openhpi/trunk/Makefile.am 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/Makefile.am 2011-01-15 23:34:32 UTC (rev 7245) @@ -47,7 +47,11 @@ README.windows \ Makefile.mingw32 \ Makefile.mingw32.def \ + mingw32/app.manifest \ mingw32/config.h \ + mingw32/openhpi.windows.libraries.manifest \ + mingw32/openhpi.windows.plugins.manifest \ + mingw32/openhpid.manifest \ $(shell find $(srcdir)/include -name '*.h') AUTOMAKE_OPTIONS = foreign Modified: openhpi/trunk/Makefile.mingw32 =================================================================== --- openhpi/trunk/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -1,6 +1,12 @@ include Makefile.mingw32.def -out := openhpi-${VERSION}-win32 +out := openhpi-${VERSION}-win32 +doc := ${out}/doc +libs := ${out}/openhpi.windows.libraries +devel := ${out}/devel +progs := ${out} +plugins := ${out}/openhpi.windows.plugins + openhpi_libs := utils \ transport \ marshal \ @@ -27,20 +33,30 @@ out: all rm -rf ${out} mkdir -p ${out} - mkdir -p ${out}/plugins - cp README.windows ${out} - cat include/SaHpi.h | sed -e 's/ __attribute__.*/;/' -e 's/#define SAHPI_API/#define SAHPI_API __declspec(dllimport)/' > ${out}/SaHpi.h - cp include/oHpi.h ${out} - cp utils/libopenhpiutils-${VERSION}.dll ${out}/ - cp utils/libopenhpiutils-${VERSION}.a ${out}/ - cp utils/libopenhpiutils-${VERSION}.def ${out}/ - cp transport/libopenhpitransport-${VERSION}.dll ${out}/ - cp marshal/libopenhpimarshal-${VERSION}.dll ${out}/ - cp baselib/libopenhpi-${VERSION}.dll ${out}/ - cp baselib/libopenhpi-${VERSION}.a ${out}/ - cp baselib/libopenhpi-${VERSION}.def ${out}/ - cp clients/*.exe ${out}/ - cp clients/hpixml/hpixml.exe ${out}/ - cp openhpid/openhpid.exe ${out}/ - cp plugins/slave/libslave.dll ${out}/plugins + mkdir -p ${doc} + cp README.windows ${doc}/README.windows.txt + mkdir -p ${libs} + cp transport/libopenhpitransport.dll ${libs} + cp marshal/libopenhpimarshal.dll ${libs} + cp utils/libopenhpiutils.dll ${libs} + cp baselib/libopenhpi.dll ${libs} + cp ${GLIB_DIR}/bin/libglib-2.0-0.dll ${libs} + cp ${GLIB_DIR}/bin/libgmodule-2.0-0.dll ${libs} + cp ${GLIB_DIR}/bin/libgthread-2.0-0.dll ${libs} + cp mingw32/openhpi.windows.libraries.manifest ${libs} + mkdir -p ${devel} + cat include/SaHpi.h | sed -e 's/ __attribute__.*/;/' -e 's/#define SAHPI_API/#define SAHPI_API __declspec(dllimport)/' > ${devel}/SaHpi.h + cp include/oHpi.h ${devel} + cp utils/libopenhpiutils.a ${devel} + cp utils/libopenhpiutils.def ${devel} + cp baselib/libopenhpi.a ${devel} + cp baselib/libopenhpi.def ${devel} + cp mingw32/app.manifest ${devel} + mkdir -p ${progs} + cp clients/*.exe ${progs} + cp clients/hpixml/hpixml.exe ${progs} + cp openhpid/openhpid.exe ${progs} + mkdir -p ${plugins} + cp plugins/slave/libslave.dll ${plugins} + cp mingw32/openhpi.windows.plugins.manifest ${plugins} Modified: openhpi/trunk/Makefile.mingw32.def =================================================================== --- openhpi/trunk/Makefile.mingw32.def 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/Makefile.mingw32.def 2011-01-15 23:34:32 UTC (rev 7245) @@ -6,6 +6,7 @@ CC := ${TOOLCHAIN_PATH}/bin/i386-mingw32-gcc CXX := ${TOOLCHAIN_PATH}/bin/i386-mingw32-g++ AS := ${TOOLCHAIN_PATH}/bin/i386-mingw32-as +RC := ${TOOLCHAIN_PATH}/bin/i386-mingw32-windres GLIB_DIR := /home/avpak/usr/cross/mingw32/i386-mingw32/glib-2.0 Modified: openhpi/trunk/README.windows =================================================================== --- openhpi/trunk/README.windows 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/README.windows 2011-01-15 23:34:32 UTC (rev 7245) @@ -1,9 +1,9 @@ ======================================================================== -OpenHPI provides windows version of -- Base HPI library (libopenhpi-${VERSION}.dll) -- OpenHPI utils library (libopenhpiutils-${VERSION}.dll) -- OpenHPI marshal library (libopenhpimarshal-${VERSION}.dll) -- OpenHPI transport library (libopenhpitransport-${VERSION}.dll) +This package provides windows version of +- Base HPI library (libopenhpi.dll) +- OpenHPI utils library (libopenhpiutils.dll) +- OpenHPI marshal library (libopenhpimarshal.dll) +- OpenHPI transport library (libopenhpitransport.dll) - OpenHPI clients: -- hpialarms.exe -- hpidomain.exe @@ -27,6 +27,23 @@ - OpenHPI daemon as a console Windows application (openhpid.exe) -- Slave plug-in (libslave.dll) +libopenhpi.dll, libopenhpiutils.dll, libopenhpimarshal.dll, +libopenhpitransport.dll constitute +private side-by-side assembly openhpi.windows.libraries. +And the assembly also includes necessary glib2 libraries: +- libglib-2.0-0.dll +- libgthread-2.0-0.dll +- libgmodule-2.0-0.dll + +NB: glib2 libraries were obtained in binary form from +http://www.gtk.org/download-windows.html and were included +without any change. +NB: glib2 is distributed under LGPL2 license. + +libslave.dll constitutes private side-by-side assembly +openhpi.windows.plugins. It is planned to use this assembly +for OpenHPI daemon plug-ins. + ======================================================================== Dependencies: @@ -40,20 +57,13 @@ in projects with any compiler. ======================================================================== -The libraries' names are constructed in the following way: -lib + name + '-' + version + '.dll'. -I.e. libopenhpi-2.17.0.dll - -N.B. This naming schema can be changed in future releases. - -======================================================================== Build instructions: - Get mingw (cross or native). - Get archive with glib2 for windows and unpack it somewhere. -- Enter openhpi source tree root directory. +- Enter OpenHPI source tree root directory. - Modify Makefile.mingw32.def: --- TOOLCHAIN_PATH in order that CC, CXX and AS point to correct files. +-- TOOLCHAIN_PATH in order that CC, CXX, AS and RC point to correct files. -- GLIB_DIR: in order that GLIB_INCLUDES and GLIB_LIBS point to valid directories with glib headers and libraries. - Run "make -f Makefile.mingw32". @@ -66,7 +76,7 @@ There are two ways: -Way 1) prepare openhpiclient.conf and set env. var. OPENHPI_CLIENT_CONF +Way 1) prepare openhpiclient.conf and set env. var. OPENHPICLIENT_CONF to its path Way 2) set env. var. OPENHPI_DAEMON_HOST to OpenHPI daemon address. @@ -74,19 +84,28 @@ ======================================================================== Library Usage instructions: -Header file SaHpi.h contains declarations on provided functions. -The functions are in libopenhpi-${VERSION}.dll. +Header file SaHpi.h contains declarations on provided HPI functions. +Header file oHpi.h contains declarations on provided OpenHPI extension functions. +The functions are in libopenhpi.dll. Define "SAHPI_API" macro as "__declspec(dllimport)". For mingw compiler it can be just linked. For MSVC: -- There is def file libopenhpi-${VERSION}.def +- There is def file libopenhpi.def - With lib tool you can create import library -- Command example "lib /machine:i386 /def:libopenhpi-${VERSION}.def" +- Command example "lib /machine:i386 /def:libopenhpi.def" - Point produced import library in Project settings +For application running and distribution there are two ways: +- you can copy assembly openhpi.windows.libraries dir + to application dir and put copy app.manifest as + your_application_name.exe.manifest into application dir. + Or embed this manifest to your application. +- get necessary libraries from assembly openhpi.windows.libraries + assembly dir and copy them to your application dir. + And see Client Usage instructions about configuring OpenHPI daemon address to connect. @@ -115,9 +134,10 @@ - prepare openhpi.conf - set OPENHPI_UID_MAP="path to uid map file" -- set OPENHPI_PATH="path to directory with libslave.dll" - openhpid.exe -n -v -c "path to openhpi.conf" +NB: Flags -v is for verbose messages and can be omitted. + ======================================================================== Troubleshouting: @@ -127,6 +147,3 @@ IRC channel #openhpi on FreeNode. - - Anton Pak - Modified: openhpi/trunk/baselib/Makefile.mingw32 =================================================================== --- openhpi/trunk/baselib/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/baselib/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -1,6 +1,6 @@ include ../Makefile.mingw32.def -TARGET := libopenhpi-${VERSION}.dll +TARGET := libopenhpi.dll SRC := conf.c \ init.cpp \ @@ -18,9 +18,9 @@ INCLUDES += -I ../mingw32 -I ../include -I ../utils -I ../transport -I ../marshal LIBS := ${GLIB_LIBS} ${GTHREAD_LIBS} -LIBS += -L ../utils -lopenhpiutils-${VERSION} -LIBS += -L ../transport -lopenhpitransport-${VERSION} -LIBS += -L ../marshal -lopenhpimarshal-${VERSION} +LIBS += -L ../utils -lopenhpiutils +LIBS += -L ../transport -lopenhpitransport +LIBS += -L ../marshal -lopenhpimarshal CPPFLAGS += ${DEFS} ${INCLUDES} Modified: openhpi/trunk/clients/Makefile.am =================================================================== --- openhpi/trunk/clients/Makefile.am 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/clients/Makefile.am 2011-01-15 23:34:32 UTC (rev 7245) @@ -8,7 +8,7 @@ SUBDIRS = hpixml DIST_SUBDIRS = hpixml -EXTRA_DIST = Makefile.mingw32 +EXTRA_DIST = Makefile.mingw32 manifest.rc COMMONLIBS = $(top_builddir)/baselib/libopenhpi.la Modified: openhpi/trunk/clients/Makefile.mingw32 =================================================================== --- openhpi/trunk/clients/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/clients/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -28,8 +28,8 @@ INCLUDES := ${GLIB_INCLUDES} -I ../mingw32 -I ../include -I ../utils LIBS := ${GLIB_LIBS} -LIBS += -L ../baselib -lopenhpi-${VERSION} -LIBS += -L ../utils -lopenhpiutils-${VERSION} +LIBS += -L ../baselib -lopenhpi +LIBS += -L ../utils -lopenhpiutils CPPFLAGS += ${DEFS} ${INCLUDES} @@ -37,9 +37,12 @@ all : ${TARGETS} -%.exe : %.o clients.o +manifest.o: manifest.rc + ${RC} -i $^ -o $@ + +%.exe : %.o clients.o manifest.o ${CXX} -o $@ $^ ${LIBS} clean: - rm -f ${OBJS} ${TARGETS} + rm -f ${OBJS} ${TARGETS} manifest.o clients.o Modified: openhpi/trunk/clients/hpixml/Makefile.am =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.am 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/clients/hpixml/Makefile.am 2011-01-15 23:34:32 UTC (rev 7245) @@ -6,7 +6,7 @@ INCLUDES = @OPENHPI_INCLUDES@ -EXTRA_DIST = Makefile.mingw32 schema.xsd +EXTRA_DIST = Makefile.mingw32 schema.xsd manifest.rc bin_PROGRAMS = hpixml Modified: openhpi/trunk/clients/hpixml/Makefile.mingw32 =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/clients/hpixml/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -7,9 +7,10 @@ hpi_xml_writer.cpp \ schema.S \ main.cpp \ + manifest.rc \ xml_writer.cpp -OBJ := $(patsubst %.S, %.o,$(patsubst %.cpp, %.o, ${SRC} ) ) +OBJ := $(patsubst %.rc, %.o, $(patsubst %.S, %.o, $(patsubst %.cpp, %.o, ${SRC} ) ) ) DEFS := -DG_LOG_DOMAIN=\"hpixml\" -DSCHEMA=\"schema.xsd\" @@ -17,8 +18,8 @@ INCLUDES += -I ../../mingw32 -I ../../include -I ../../utils LIBS := ${GLIB_LIBS} -LIBS += -L ../../utils -lopenhpiutils-${VERSION} -LIBS += -L ../../baselib -lopenhpi-${VERSION} +LIBS += -L ../../utils -lopenhpiutils +LIBS += -L ../../baselib -lopenhpi CPPFLAGS += ${DEFS} ${INCLUDES} @@ -26,6 +27,9 @@ all : ${TARGET} +manifest.o: manifest.rc + ${RC} -i $^ -o $@ + ${TARGET} : ${OBJ} ${CXX} -o $@ $^ ${LIBS} Added: openhpi/trunk/clients/hpixml/manifest.rc =================================================================== --- openhpi/trunk/clients/hpixml/manifest.rc (rev 0) +++ openhpi/trunk/clients/hpixml/manifest.rc 2011-01-15 23:34:32 UTC (rev 7245) @@ -0,0 +1,3 @@ +#include <winuser.h> + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../../mingw32/app.manifest" Added: openhpi/trunk/clients/manifest.rc =================================================================== --- openhpi/trunk/clients/manifest.rc (rev 0) +++ openhpi/trunk/clients/manifest.rc 2011-01-15 23:34:32 UTC (rev 7245) @@ -0,0 +1,3 @@ +#include <winuser.h> + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../mingw32/app.manifest" Modified: openhpi/trunk/marshal/Makefile.mingw32 =================================================================== --- openhpi/trunk/marshal/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/marshal/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -1,6 +1,6 @@ include ../Makefile.mingw32.def -TARGET := libopenhpimarshal-${VERSION}.dll +TARGET := libopenhpimarshal.dll SRC := marshal.c \ marshal_hpi.c \ Added: openhpi/trunk/mingw32/app.manifest =================================================================== --- openhpi/trunk/mingw32/app.manifest (rev 0) +++ openhpi/trunk/mingw32/app.manifest 2011-01-15 23:34:32 UTC (rev 7245) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" name="openhpi.windows.app" version="2.17.0.3" processorArchitecture="x86"/> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="openhpi.windows.libraries" version="2.17.0.3" processorArchitecture="x86"/> + </dependentAssembly> + </dependency> +</assembly> + Added: openhpi/trunk/mingw32/openhpi.windows.libraries.manifest =================================================================== --- openhpi/trunk/mingw32/openhpi.windows.libraries.manifest (rev 0) +++ openhpi/trunk/mingw32/openhpi.windows.libraries.manifest 2011-01-15 23:34:32 UTC (rev 7245) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" name="openhpi.windows.libraries" version="2.17.0.3" processorArchitecture="x86"/> + <file name="libopenhpi.dll"/> + <file name="libopenhpimarshal.dll"/> + <file name="libopenhpitransport.dll"/> + <file name="libopenhpiutils.dll"/> + <file name="libglib-2.0-0.dll"/> + <file name="libgmodule-2.0-0.dll"/> + <file name="libgthread-2.0-0.dll"/> +</assembly> Added: openhpi/trunk/mingw32/openhpi.windows.plugins.manifest =================================================================== --- openhpi/trunk/mingw32/openhpi.windows.plugins.manifest (rev 0) +++ openhpi/trunk/mingw32/openhpi.windows.plugins.manifest 2011-01-15 23:34:32 UTC (rev 7245) @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" name="openhpi.windows.plugins" version="2.17.0.3" processorArchitecture="x86"/> + <file name="libslave.dll"/> +</assembly> Added: openhpi/trunk/mingw32/openhpid.manifest =================================================================== --- openhpi/trunk/mingw32/openhpid.manifest (rev 0) +++ openhpi/trunk/mingw32/openhpid.manifest 2011-01-15 23:34:32 UTC (rev 7245) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" name="openhpi.windows.openhpid" version="2.17.0.3" processorArchitecture="x86"/> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="openhpi.windows.libraries" version="2.17.0.3" processorArchitecture="x86"/> + </dependentAssembly> + </dependency> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="openhpi.windows.plugins" version="2.17.0.3" processorArchitecture="x86"/> + </dependentAssembly> + </dependency> +</assembly> + Modified: openhpi/trunk/openhpid/Makefile.am =================================================================== --- openhpi/trunk/openhpid/Makefile.am 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/openhpid/Makefile.am 2011-01-15 23:34:32 UTC (rev 7245) @@ -28,6 +28,7 @@ EXTRA_DIST = \ openhpid.sh.in \ Makefile.mingw32 \ + manifest.rc \ openhpid-win32.cpp # daemon library Modified: openhpi/trunk/openhpid/Makefile.mingw32 =================================================================== --- openhpi/trunk/openhpid/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/openhpid/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -15,9 +15,10 @@ session.c \ threaded.c \ server.cpp \ - openhpid-win32.cpp + openhpid-win32.cpp \ + manifest.rc -OBJ := $(patsubst %.c, %.o,$(patsubst %.cpp, %.o, ${SRC} ) ) +OBJ := $(patsubst %.rc, %.o, $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, ${SRC} ) ) ) DEFS := -DG_LOG_DOMAIN=\"openhpid\" @@ -25,9 +26,9 @@ INCLUDES += -I ../mingw32 -I ../include -I ../utils -I ../transport -I ../marshal LIBS := ${GLIB_LIBS} ${GTHREAD_LIBS} ${GMODULE_LIBS} -LIBS += -L ../utils -lopenhpiutils-${VERSION} -LIBS += -L ../transport -lopenhpitransport-${VERSION} -LIBS += -L ../marshal -lopenhpimarshal-${VERSION} +LIBS += -L ../utils -lopenhpiutils +LIBS += -L ../transport -lopenhpitransport +LIBS += -L ../marshal -lopenhpimarshal CPPFLAGS += ${DEFS} ${INCLUDES} @@ -35,6 +36,9 @@ all : ${TARGET} +manifest.o: manifest.rc + ${RC} -i $^ -o $@ + ${TARGET} : ${OBJ} ${CXX} -o $@ $^ ${LIBS} Added: openhpi/trunk/openhpid/manifest.rc =================================================================== --- openhpi/trunk/openhpid/manifest.rc (rev 0) +++ openhpi/trunk/openhpid/manifest.rc 2011-01-15 23:34:32 UTC (rev 7245) @@ -0,0 +1,3 @@ +#include <winuser.h> + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../mingw32/openhpid.manifest" Modified: openhpi/trunk/openhpid/plugin.c =================================================================== --- openhpi/trunk/openhpid/plugin.c 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/openhpid/plugin.c 2011-01-15 23:34:32 UTC (rev 7245) @@ -230,11 +230,6 @@ **/ int oh_load_plugin(char *plugin_name) { - struct oh_global_param path_param = { .type = OPENHPI_PATH }; - gchar **plugin_search_dirs; - size_t i; - gchar *plugin_path; - struct oh_plugin *plugin = NULL; int err; @@ -267,17 +262,28 @@ g_static_rec_mutex_init(&plugin->lock); g_static_rec_mutex_init(&plugin->refcount_lock); - oh_get_global_param(&path_param); - plugin_search_dirs = g_strsplit(path_param.u.path, ":", -1); - for( i = 0; plugin_search_dirs[i] != 0; ++i) { - plugin_path = g_module_build_path(plugin_search_dirs[i], plugin->name); - plugin->dl_handle = g_module_open(plugin_path, G_MODULE_BIND_LOCAL); - g_free(plugin_path); - if (plugin->dl_handle) { - break; +#ifdef _WIN32 + plugin->dl_handle = g_module_open(plugin->name, G_MODULE_BIND_LOCAL); +#else + { + struct oh_global_param path_param = { .type = OPENHPI_PATH }; + gchar **plugin_search_dirs; + size_t i; + gchar *plugin_path; + + oh_get_global_param(&path_param); + plugin_search_dirs = g_strsplit(path_param.u.path, ":", -1); + for( i = 0; plugin_search_dirs[i] != 0; ++i) { + plugin_path = g_module_build_path(plugin_search_dirs[i], plugin->name); + plugin->dl_handle = g_module_open(plugin_path, G_MODULE_BIND_LOCAL); + g_free(plugin_path); + if (plugin->dl_handle) { + break; + } } + g_strfreev(plugin_search_dirs); } - g_strfreev(plugin_search_dirs); +#endif if (plugin->dl_handle == NULL) { CRIT("Can not open %s plugin: %s", plugin->name, g_module_error()); goto cleanup_and_quit; Modified: openhpi/trunk/plugins/slave/Makefile.mingw32 =================================================================== --- openhpi/trunk/plugins/slave/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/plugins/slave/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -15,7 +15,7 @@ INCLUDES := ${GLIB_INCLUDES} -I ../../mingw32 -I ../../include -I ../../utils LIBS := ${GLIB_LIBS} ${GTHREAD_LIBS} ${GMODULE_LIBS} -LIBS += -L ../../utils -lopenhpiutils-${VERSION} +LIBS += -L ../../utils -lopenhpiutils CPPFLAGS += ${DEFS} ${INCLUDES} Modified: openhpi/trunk/plugins/slave/baselib.cpp =================================================================== --- openhpi/trunk/plugins/slave/baselib.cpp 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/plugins/slave/baselib.cpp 2011-01-15 23:34:32 UTC (rev 7245) @@ -62,12 +62,7 @@ CRIT( "GModule is not supported. Cannot load base library." ); return false; } -// TODO fix me -#ifdef _WIN32 - m_handle = g_module_open( "libopenhpi-" VERSION, G_MODULE_BIND_LOCAL ); -#else m_handle = g_module_open( "libopenhpi", G_MODULE_BIND_LOCAL ); -#endif if ( !m_handle ) { CRIT( "Cannot load base library." ); return false; Modified: openhpi/trunk/transport/Makefile.mingw32 =================================================================== --- openhpi/trunk/transport/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/transport/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -1,6 +1,6 @@ include ../Makefile.mingw32.def -TARGET := libopenhpitransport-${VERSION}.dll +TARGET := libopenhpitransport.dll SRC := strmsock.cpp Modified: openhpi/trunk/utils/Makefile.mingw32 =================================================================== --- openhpi/trunk/utils/Makefile.mingw32 2011-01-10 21:43:49 UTC (rev 7244) +++ openhpi/trunk/utils/Makefile.mingw32 2011-01-15 23:34:32 UTC (rev 7245) @@ -1,6 +1,6 @@ include ../Makefile.mingw32.def -TARGET := libopenhpiutils-${VERSION}.dll +TARGET := libopenhpiutils.dll SRC := announcement_utils.c \ el_utils.c \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-01-24 08:12:34
|
Revision: 7255 http://openhpi.svn.sourceforge.net/openhpi/?rev=7255&view=rev Author: ulikleber Date: 2011-01-24 08:12:27 +0000 (Mon, 24 Jan 2011) Log Message: ----------- fix for Bug 3141567 README files are outdated Modified Paths: -------------- openhpi/trunk/README openhpi/trunk/configure.ac openhpi/trunk/docs/man/openhpi.pod.7 openhpi/trunk/openhpi.spec.in Modified: openhpi/trunk/README =================================================================== --- openhpi/trunk/README 2011-01-20 23:06:10 UTC (rev 7254) +++ openhpi/trunk/README 2011-01-24 08:12:27 UTC (rev 7255) @@ -1,18 +1,26 @@ This is an implementation of the Service Availability Forum's -Hardware Platform Interface B.03.01 specification. +Hardware Platform Interface B.03 specification. The following components are supported: * OpenHPI base library -* OpenHPI utility library +* OpenHPI utility functions * OpenHPI Daemon +* HPI Client programs and HPI shell + * Simulator Plugin +* Dynamic Simulator Plugin +* slave Plugin +* IMPI Direct Plugin * SNMP BladeCenter/RSA Plugin -* IPMI Plugin -* IMPI Direct Plugin -* iLO2 RIBCL Plug-in +* iLO2 RIBCL Plugin * SOAP/XML BladeSystem c-Class Plugin -* HPI Clients +* rtas Plugin +* sysfs Plugin +* watchdog Plugin +NOTE: The ipmi plugin is still provided with this release, but +will not be maintained any longer. Please use ipmidirect instead. + Feedback, as always, is welcome and encouraged: ope...@li... @@ -30,9 +38,6 @@ The follow libraries are needed to build certain plugins -ipmi plugin - OpenIPMI >= 1.4.20 (http://openipmi.sf.net) - sysfs plugin libsysfs =< 1.3 @@ -43,6 +48,10 @@ libssl >= 0.9.7 libxml2 +ipmi plugin + OpenIPMI >= 1.4.20 (http://openipmi.sf.net) + + --------------------------------------------------------- RPM BUILD NOTE --------------------------------------------------------- @@ -96,8 +105,9 @@ FOR SUBVERSION EXTRACTS -svn co https://svn.sourceforge.net/svnroot/openhpi/openhpi/trunk openhpi +svn co https://openhpi.svn.sf.net/svnroot/openhpi/openhpi/trunk mydir +It will extract OpenHPI trunk to mydir. First time after extracting the code: run ./bootstrap @@ -122,24 +132,110 @@ --------------------------------------------------------- Active Plug-ins --------------------------------------------------------- -simulator - plugin for use in testing -ipmi - OpenIPMI based plugin -ipmidirect - IPMI plugin that talks to device driver directly -snmp_bc - IBM BladeCenter/RSA plugin (uses snmp) -watchdog - Linux watchdog device interface -sysfs - Linux sysfs plugin (LM sensors and I2C devices exported in - sysfs requires kernel 2.6 or >= 2.5.72) -ilo2_ribcl - HP ProLiant Rack Mount Server plug-in -oa_soap - HP BladeSystem c-Class plugin +simulator - plugin for simple testing. It uses a static database + for hardware configuration. +dynamic_simulator - plugin for advanced testing. It uses a configuration file + to simulate any hardware. +slave - allows to aggregate resources from different domains (slave domains) + and to provide aggregated resources as part of the one domain (master domain). +ipmidirect - IPMI plugin that directly uses ipmi protocol to ipmi + infrastructure, e.g. chassis managers. +snmp_bc - IBM BladeCenter/RSA plugin (uses snmp) +ilo2_ribcl - HP ProLiant Rack Mount Server plug-in +oa_soap - HP BladeSystem c-Class plugin +rtas - Run-Time Abstraction Services (RTAS) plug-in +sysfs - Linux sysfs plugin (LM sensors and I2C devices exported in + sysfs requires kernel 2.6 or >= 2.5.72) +watchdog - Linux watchdog device interface + For information on recent changes, see the changelogs at +http://openhpi.org http://openhpi.sf.net --------------------------------------------------------- +CLIENT PROGRAMS +--------------------------------------------------------- + +Openhpi provides a set of client programs, that can be use as examples for +typical HPI usage. They also help testing when invoked from a command line, +or could even be called by applications. + +The hpi_shell provides are command shell for calling HPI functions +interactively. + +The following client programs are provided: + +hpialarms - show Alarm Control management instruments. +hpidomain - show information about domains or set the domain tag. +hpiel - displays HPI event log entries +hpievents - polls for events +hpifan - show Fan Control management instruments +hpigensimdata - generate data file for dynamic simulator plugin +hpiinv - show inventory records for hardware resources +hpionIBMblade - display and manage resources of an IBM Blade with + Basedboard Management Controller (BMC) +hpipower - Invoke HPI Power Management APIs +hpireset - Invoke HPI Reset Management APIs +hpisensor - display sensor info for all resources with Sensor Capability +hpisettime - Invoke Event Log clock APIs. +hpithres - display sensor thresholds and sensor info. +hpitop - display highlevel topology for a managed openHPI complex. +hpitree - show in details the resources (rpt's) and resources' + manamegement instruments (rdr's) data structures +hpiwdt - read and enables the watchdog timer. +hpixml - display system view in XML + +ohdomainlist - show information about domains on the level of the openhpi + base library +ohhandler - uses the openhpi additional interfaces to control openhpi + configuration. That is plugins can be loaded, plugin instances + (handlers) created, unloaded or their configuration displayed. +ohparam - control openhpi configuration parameters + +hpi_shell - allows a user to interactively perform a number of HPI + operations in a command shell with prompting. + +--------------------------------------------------------- +HPI EXTENSIONS +--------------------------------------------------------- + +OpenHPI provides a small set of functions in addition to the SAF standard. +Mainly they are needed because of the OpenHPI architecture: +- manage plugins +- manage OpenHPI configuration dynamically + +* oHpiVersionGet +* oHpiHandlerCreate +* oHpiHandlerDestroy +* oHpiHandlerInfo +* oHpiHandlerGetNext +* oHpiHandlerFind +* oHpiHandlerRetry +* oHpiGlobalParamGet +* oHpiGlobalParamSet +* oHpiInjectEvent +* oHpiDomainAdd +* oHpiDomainAddById +* oHpiDomainEntryGet +* oHpiDomainEntryGetByDomainId + +Please find more information in the inline documentation in files: +include/oHpi.h - function declarations +baselib/ohpi.c - function implementation in Base Library +openhpid/ohpi.c - function implementation in OpenHPI Daemon + +--------------------------------------------------------- FOR MORE INFO --------------------------------------------------------- -For more information please see the project webiste at +Please refer also to README.daemon and README.windows. + +Please find more documentation in the docs subdirectory and in the +man pages (openhpi, openhpid, clients). + +For more information please see the project webiste at: +http://openhpi.org http://openhpi.sourceforge.net Also visit SAForum's website at http://www.saforum.org Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2011-01-20 23:06:10 UTC (rev 7254) +++ openhpi/trunk/configure.ac 2011-01-24 08:12:27 UTC (rev 7255) @@ -254,11 +254,16 @@ fi AC_ARG_ENABLE([ipmi], - [ --enable-ipmi build openipmi plugin [[default=no]]], + [ --enable-ipmi build openipmi plugin [[deprecated, default=no]]], [if test "x$enableval" = "xyes"; then if test "x$have_openipmi" = "xyes"; then AC_SUBST(IPMI,ipmi) AC_SUBST(WITH_IPMI,1) + AC_MSG_WARN([ +*** The ipmi plugin is deprecated. Please consider to replace it +*** by using the ipmidirect plugin + ]) + else OH_CHECK_FAIL(OpenIPMI,libOpenIPMI-devel,http://openipmi.sf.net, Can not build IPMI support without OpenIPMI >= 1.4.20) Modified: openhpi/trunk/docs/man/openhpi.pod.7 =================================================================== --- openhpi/trunk/docs/man/openhpi.pod.7 2011-01-20 23:06:10 UTC (rev 7254) +++ openhpi/trunk/docs/man/openhpi.pod.7 2011-01-24 08:12:27 UTC (rev 7255) @@ -8,12 +8,17 @@ Interface, which provides a standard C library interface to manage, monitor, and control hardware (both local and remote). -OpenHPI 2.x implements the HPI B.01.01 specification. +Starting with release 2.14.0 OpenHPI implements the HPI B.03.02 specification. The OpenHPI client library (libopenhpi) provides all the connection functionality needed by the client application to connect to the OpenHPI daemon running on the local or remote server. +The OpenHPI daemon runs as a background process and executes the requests. +It loads plugins to adapt to the different hardware types. The plugins can +be defined in the openhpi.conf file or can be loaded dynamically. + + =head1 ENVIRONMENTAL VARIABLES Some of OpenHPI's functioning can be changed by setting environment @@ -21,34 +26,37 @@ =over 2 +=item B<OPENHPICLIENT_CONF>="filename" + +Location for the client's configuration file that specifies the HPI domains +and addresses of daemons serving the domains. If the variable is not set, +OpenHPI will look for a file openhpiclient.conf in the directory specified +during the build process (default /etc/openhpi). + =item B<OPENHPI_DAEMON_HOST>=URL URL for the host running the daemon. This can be "localhost" (default) -if the daemon is running on the local host or an ip address. +if the daemon is running on the local host or an ip address. +The variable is only used if no default domain is defined via the client conf +file. =item B<OPENHPI_DAEMON_PORT>=PORT_NUMBER The port number the host is listening on for clent connections. Default port is 4743. +The variable is only used if no default domain is defined via the client conf +file. + =back =head1 HARDWARE SUPPORT OpenHPI provides a number of plugins that talk to different hardware -types. The following is a list of tested plugins in OpenHPI 2.x. +types. The following is a list of supported plugins. =over 4 -=item B<ipmi> - -An IPMI plugin that can talk locally (via smi interface and OpenIPMI -device driver) or remotely (via IPMI over LAN). It supports IPMI 1.5 -for standard rackmount servers, and some of IPMI 2.0 for support of -ATCA chassis. - -IPMI plugin depends on libOpenIPMI version 1.4.x. - =item B<ipmidirect> An IPMI plugin designed specifically for ATCA chassis. It implements @@ -61,23 +69,63 @@ SNMP_BC plugin depends on net-snmp > 5.0.7. +=item B<ilo2_ribcl> + +OpenHPI plugin supporting HP ProLiant Rack Mount Servers. This plug-in connects +to iLO2 on HP ProLiant Rack Mount Server using a SSL connection and exchanges +information via Remote Insight Board Command Language (RIBCL). + +=item B<oa_soap> + +OpenHPI plug-in supporting HP BladeSystems c-Class. This plug-in connects +to the OA of a c-Class chassis using an SSL connection and manages the system +using an XML-encoded SOAP interface. + +=item B<rtas> + +Run-Time Abstraction Services (RTAS) plug-in + =item B<sysfs> -Current status?? +OpenHPI plugin that reads system information from sysfs. +(LM sensors and I2C devices exported in sysfs requires kernel 2.6 or >= 2.5.72) =item B<watchdog> -Current status?? +Linux watchdog device interface =back +The following plugins are provided to ease testing or support complex +hardware architectures: + +=over 4 + +=item B<simulator> + +OpenHPI plugin that reports fakes hardware used for +testing the core library. + +=item B<dynamic_simulator> + +OpenHPI plugin that reports fakes hardware defined in the file +simulation.data used for testing the core library. + +=item B<slave> + +OpenHPI plug-in that allows to aggregate resources from different +domains (slave domains) and to provide aggregated resources as part +of the one domain (master domain). + +=back + =head1 OTHER DOCUMENTATION The definitive guide to HPI is the SA Forum specification at http://saforum.org. More info on OpenHPI can be found at our webpage -(http://openhpi.org). +(http://openhpi.org) and in inline documentation. =head1 SEE ALSO @@ -89,6 +137,15 @@ The openhpi daemon, providing OpenHPI data as a system service. +=item B<OpenHPI client programs> + + hpialarms hpigensimdata hpireset hpitop + hpidomain hpiinv hpisensor hpitree + hpiel hpionIBMblade hpisettime hpiwdt + hpievents hpipower hpithres + ohdomainlist ohhandler ohparam + hpi_shell + =back =head1 AUTHORS @@ -97,4 +154,6 @@ Sean Dague (http://dague.net/sean) Renier Morales (re...@op...) + Ulrich Kleber (uli...@us...) + Modified: openhpi/trunk/openhpi.spec.in =================================================================== --- openhpi/trunk/openhpi.spec.in 2011-01-20 23:06:10 UTC (rev 7254) +++ openhpi/trunk/openhpi.spec.in 2011-01-24 08:12:27 UTC (rev 7255) @@ -94,7 +94,7 @@ %if 0%{?with_ipmi} %package ipmi -Summary: OpenHPI plugin for OpenIPMI +Summary: OpenHPI plugin for OpenIPMI (deprecated) Group: System/Monitoring BuildRequires: OpenIPMI-devel Requires: openhpi = %{version} OpenIPMI @@ -193,7 +193,8 @@ %description ipmi This OpenHPI plugin uses OpenIPMI to connect to IPMI-enabled hardware locally or over the network. Its focus is wide, created to support -any generic hardware topology that uses IPMI. +any generic hardware topology that uses IPMI. This plugin is not maintained +any more; it is recommended to use ipmidirect plugin instead. %endif %if 0%{?with_ipmidirect} @@ -204,8 +205,7 @@ %if 0%{?with_rtas} %description rtas -OpenHPI plugin for reading sensor and vpd information -from IBM PPC systems. +Run-Time Abstraction Services (RTAS) plug-in %endif %if 0%{?with_simulator} @@ -254,8 +254,10 @@ %if 0%{?with_slave} %description slave -OpenHPI plug-in that connects to a specified OpenHPI daemon and -represents the remote daemon resources at its owns. +OpenHPI plug-in that allows to aggregate resources from different domains +(slave domains) and to provide aggregated resources as part of the one domain +(master domain). + %endif ################################################### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-01-24 10:05:10
|
Revision: 7258 http://openhpi.svn.sourceforge.net/openhpi/?rev=7258&view=rev Author: ulikleber Date: 2011-01-24 10:05:04 +0000 (Mon, 24 Jan 2011) Log Message: ----------- Feature 3141155: Move to newer version of glib2 Modified Paths: -------------- openhpi/trunk/README openhpi/trunk/configure.ac Modified: openhpi/trunk/README =================================================================== --- openhpi/trunk/README 2011-01-24 09:06:11 UTC (rev 7257) +++ openhpi/trunk/README 2011-01-24 10:05:04 UTC (rev 7258) @@ -33,7 +33,7 @@ automake >= 1.8 gcc >= 3.2.0 uuid.h (may be found in e2fsprogs-devel or uuid-dev) -glib2 >= 2.2 +glib2 >= 2.12 pkgconfig (may be called pkg-config depending on distro) The follow libraries are needed to build certain plugins Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2011-01-24 09:06:11 UTC (rev 7257) +++ openhpi/trunk/configure.ac 2011-01-24 10:05:04 UTC (rev 7258) @@ -97,7 +97,7 @@ OH_CHECK_GCC(3,2,0) dnl glib 2.x checks -GLIB_REQUIRED_VERSION=2.2.0 +GLIB_REQUIRED_VERSION=2.12 GLIB=glib-2.0 GTHREAD=gthread-2.0 GMODULE=gmodule-2.0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-01-26 08:58:35
|
Revision: 7259 http://openhpi.svn.sourceforge.net/openhpi/?rev=7259&view=rev Author: ulikleber Date: 2011-01-26 08:58:28 +0000 (Wed, 26 Jan 2011) Log Message: ----------- First part of Feature 1493787 Update clients to use long options and uniform format Common part and clients hpialarms, hpidomain, hpitop, hpitree. Modified Paths: -------------- openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpialarms.c openhpi/trunk/clients/hpidomain.c openhpi/trunk/clients/hpitop.c openhpi/trunk/clients/hpitree.c openhpi/trunk/clients/oh_clients.h openhpi/trunk/docs/man/hpialarms.pod.1 openhpi/trunk/docs/man/hpidomain.pod.1 openhpi/trunk/docs/man/hpitop.pod.1 openhpi/trunk/docs/man/hpitree.pod.1 Modified: openhpi/trunk/clients/clients.c =================================================================== --- openhpi/trunk/clients/clients.c 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/clients/clients.c 2011-01-26 08:58:28 UTC (rev 7259) @@ -1,45 +1,192 @@ -/* -*- linux-c -*- - * - * Copyright (C) 2007-2008, Hewlett-Packard Development Company, LLP - * (C) Copyright IBM Corp. 2007 - * - * 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. - * - * Author(s): - * Shuah Khan <shu...@hp...> - * Renier Morales <re...@op...> - */ - -#include <stdio.h> -#include <string.h> - -#include <SaHpi.h> -#include <oHpi.h> - -#include "oh_clients.h" - -void oh_prog_version(const char *prog_name, const char *svn_rev_str) -{ - SaHpiUint32T ohpi_major = oHpiVersionGet() >> 48; - SaHpiUint32T ohpi_minor = (oHpiVersionGet() << 16) >> 48; - SaHpiUint32T ohpi_patch = (oHpiVersionGet() << 32) >> 48; - SaHpiVersionT hpiver; - char svn_rev[SAHPI_MAX_TEXT_BUFFER_LENGTH]; - - strncpy(svn_rev, svn_rev_str, SAHPI_MAX_TEXT_BUFFER_LENGTH); - svn_rev[strlen(svn_rev_str)-2] = '\0'; - - printf("%s (rev %s) - This program came with OpenHPI %u.%u.%u\n", - prog_name, svn_rev+11, ohpi_major, ohpi_minor, ohpi_patch); - hpiver = saHpiVersionGet(); - printf("SAF HPI Version %c.0%d.0%d\n\n", - (hpiver >> 16) + ('A' - 1), - (hpiver & 0x0000FF00) >> 8, - hpiver & 0x000000FF); -} - +/* -*- linux-c -*- + * + * Copyright (C) 2007-2008, Hewlett-Packard Development Company, LLP + * (C) Copyright IBM Corp. 2007 + * (C) Copyright Ulrich Kleber 2011 + * + * 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. + * + * Author(s): + * Shuah Khan <shu...@hp...> + * Renier Morales <re...@op...> + * Ulrich Kleber <uli...@us...> + * + * Changes: + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients + * + */ + +#include "oh_clients.h" + +static gint optdid = SAHPI_UNSPECIFIED_DOMAIN_ID; +static gboolean optdebug = FALSE; +static gboolean optverbose = FALSE; +static gchar *optep = ""; +static gchar *optdaemon = ""; + +static GOptionEntry domain_option[] = +{ + { "domain", 'D', 0, G_OPTION_ARG_INT, &optdid, "Select domain id nn", "nn" }, + { NULL } +}; + +static GOptionEntry debug_option[] = +{ + { "debug", 'X', 0, G_OPTION_ARG_NONE, &optdebug, "Display debug messages", NULL }, + { NULL } +}; + +static GOptionEntry verbose_option[] = +{ + { "verbose", 'V', 0, G_OPTION_ARG_NONE, &optverbose, "Verbose mode", NULL }, + { NULL } +}; + +static GOptionEntry entity_path_option[] = +{ + { "entity-path", 'E', 0, G_OPTION_ARG_STRING, &optep, "Use entity path epath", "\"epath\"" }, + { NULL } +}; + +static GOptionEntry host_option[] = +{ + { "host", 'N', 0, G_OPTION_ARG_STRING, &optdaemon, "Connect to daemon host:port", "\"host<:port>\"" }, + { NULL } +}; + + + +void oh_prog_version(const char *prog_name, const char *svn_rev_str) +{ + SaHpiUint32T ohpi_major = oHpiVersionGet() >> 48; + SaHpiUint32T ohpi_minor = (oHpiVersionGet() << 16) >> 48; + SaHpiUint32T ohpi_patch = (oHpiVersionGet() << 32) >> 48; + SaHpiVersionT hpiver; + char svn_rev[SAHPI_MAX_TEXT_BUFFER_LENGTH]; + + strncpy(svn_rev, svn_rev_str, SAHPI_MAX_TEXT_BUFFER_LENGTH); + svn_rev[strlen(svn_rev_str)-2] = '\0'; + + printf("%s (rev %s) - This program came with OpenHPI %u.%u.%u\n", + prog_name, svn_rev+11, ohpi_major, ohpi_minor, ohpi_patch); + hpiver = saHpiVersionGet(); + printf("SAF HPI Version %c.0%d.0%d\n\n", + (hpiver >> 16) + ('A' - 1), + (hpiver & 0x0000FF00) >> 8, + hpiver & 0x000000FF); +} + + +gboolean ohc_option_parse(int *argc, char *argv[], + GOptionContext *context, + oHpiCommonOptionsT *common_options, + SaHpiUint8T optionmask, + GError *error) +{ + SaErrorT rv = SA_OK; + + if (!argc || !argv || !context || !common_options) { + g_print ("Internal error. Terminating.\n"); + exit (1); + } + + if (optionmask & OHC_DOMAIN_OPTION) + g_option_context_add_main_entries (context, domain_option, NULL); + if (optionmask & OHC_DEBUG_OPTION) + g_option_context_add_main_entries (context, debug_option, NULL); + if (optionmask & OHC_VERBOSE_OPTION) + g_option_context_add_main_entries (context, verbose_option, NULL); + if (optionmask & OHC_ENTITY_PATH_OPTION) + g_option_context_add_main_entries (context, entity_path_option, NULL); +// Preparation for option -N / --host (Features 2726603 & 3129972 & 3129967) +// if (optionmask & OHC_HOST_OPTION) +// g_option_context_add_main_entries (context, host_option, NULL); + + if (!g_option_context_parse (context, argc, &argv, &error)) { + g_print ("option parsing failed: %s\n",error->message); + // g_print ("\n%s", g_option_context_get_help (context, FALSE, NULL)); + // Needs glib-2.14 + exit (1); + } + + common_options->withentitypath = (strnlen(optep,1) > 0); + common_options->withdaemonhost = (strnlen(optdaemon,1) > 0); + + if (optdebug && optverbose) { + g_print("Parsing of options completed. Common options:\n --debug --verbose"); + if (optdid >= 0) g_print(" --domain=%u ",optdid); + if (common_options->withentitypath) g_print(" --entity-path=%s ",optep); + if (common_options->withdaemonhost) g_print(" --daemon=%s ",optdaemon); + g_print("\n"); + } + + /* prepare output */ + common_options->debug = optdebug; + common_options->verbose = optverbose; + common_options->domainid = optdid; + + oh_init_ep(&common_options->entitypath); + if (common_options->withentitypath) { + rv = oh_encode_entitypath(optep, &common_options->entitypath); + if (error) { + g_print("Invalid entity path: %s\n" + "oh_encode_entitypath() returned %s \n", + optep, oh_lookup_error(rv)); + exit (1); + } + if (optdebug && optverbose) { + g_print("Entity Path encoded successfully: "); + oh_print_ep(&common_options->entitypath, 0); + g_print("\n"); + } + } + + oh_init_textbuffer(&common_options->daemonhost); + if (common_options->withdaemonhost) { + char *colon=strchr(optdaemon, ':'); + if (colon!=NULL) { + *colon = '\0'; + common_options->daemonport = atoi(++colon); + } else common_options->daemonport = OPENHPI_DEFAULT_DAEMON_PORT; + rv = oh_append_textbuffer(&common_options->daemonhost, optdaemon); + if (optdebug && optverbose) { + g_print("Daemon host:port scanned successfully: host="); + oh_print_text(&common_options->daemonhost); + g_print(" port=%u\n",common_options->daemonport); + } + } + return TRUE; +} + +SaErrorT ohc_session_open_by_option ( + oHpiCommonOptionsT *opt, + SaHpiSessionIdT *sessionid) +{ + // TODO implement -N option + SaErrorT rv = SA_OK; + + if (opt->debug) { + if (opt->domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); + else printf("saHpiSessionOpen to domain %u\n",opt->domainid); + } + + rv = saHpiSessionOpen(opt->domainid, sessionid, NULL); + + if (rv != SA_OK || opt->debug) { + printf("saHpiSessionOpen returns %s\n",oh_lookup_error(rv)); + return rv; + } + + if (opt->debug) + printf("saHpiSessionOpen returns with SessionId %u\n", *sessionid); + + return SA_OK; +} + + /* end clients.c */ Modified: openhpi/trunk/clients/hpialarms.c =================================================================== --- openhpi/trunk/clients/hpialarms.c 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/clients/hpialarms.c 2011-01-26 08:58:28 UTC (rev 7259) @@ -2,6 +2,7 @@ * Copyright (c) 2003 Intel Corporation. * (C) Copyright IBM Corp 2007 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * 04/15/03 Andy Cress - created * 04/17/03 Andy Cress - mods for resourceid, first good run @@ -13,6 +14,8 @@ * 10/13/04 Andy Cress - v1.2 add ifdefs for HPI_A & HPI_B, added -d/raw * < ...for more changes look at svn logs... > * 09/06/2010 ulikleber New option -D to select domain + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * * Author(s): * Andy Cress <and...@in...> @@ -47,12 +50,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *M*/ -#include <stdio.h> -#include <stdlib.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oHpi.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" @@ -61,29 +58,32 @@ #define SAHPI_OEM_ALARM_LED 0x10 #define SAHPI_OEM_DISK_LED 0x20 -char fdebug = 0; -char *states[3] = {"off", "ON ", "unknown" }; -uchar fsetid = 0; -uchar fid = 0; +static char *states[3] = {"off", "ON ", "unknown" }; +static gint fid = -1; // set chassis id #define NLEDS 6 -struct { - uchar fset; - uchar val; -} leds[NLEDS] = { /* rdr.RdrTypeUnion.CtrlRec.Oem is an index for this */ -{/*pwr*/ 0, 0}, -{/*crt*/ 0, 0}, -{/*maj*/ 0, 0}, -{/*min*/ 0, 0}, -{/*diska*/ 0, 0}, -{/*diskb*/ 0, 0} }; +static gint leds[NLEDS] = { /* rdr.RdrTypeUnion.CtrlRec.Oem is an index for this */ +/*pwr*/ -1, /*crt*/ -1, /*maj*/ -1, /*min*/ -1, /*diska*/ -1, /*diskb*/ -1}; +static gboolean fall = FALSE; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "critical", 'c', 0, G_OPTION_ARG_INT, &leds[1], "Set critical alarm on|off", "1|0" }, + { "major", 'm', 0, G_OPTION_ARG_INT, &leds[2], "Set major alarm on|off", "1|0" }, + { "minor", 'n', 0, G_OPTION_ARG_INT, &leds[3], "Set minor alarm on|off", "1|0" }, + { "diska", 'a', 0, G_OPTION_ARG_INT, &leds[4], "Set diska alarm on|off", "1|0" }, + { "diskb", 'b', 0, G_OPTION_ARG_INT, &leds[5], "Set diskb alarm on|off", "1|0" }, + { "power", 'p', 0, G_OPTION_ARG_INT, &leds[0], "Set power alarm on|off", "1|0" }, + { "chassisid", 'i', 0, G_OPTION_ARG_INT, &fid, "Set chassis id on for n seconds", "n" }, + { "all", 'o', 0, G_OPTION_ARG_NONE, &fall, "Set all alarms off", NULL }, + { NULL } +}; + int main(int argc, char **argv) { - int c; SaErrorT rv; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT sessionid; SaHpiRptEntryT rptentry; SaHpiEntryIdT rptentryid; @@ -95,89 +95,36 @@ SaHpiCtrlTypeT ctltype; SaHpiCtrlNumT ctlnum; SaHpiCtrlStateT ctlstate; - int raw_val = 0; - int j; - uchar b = 0; - SaHpiBoolT printusage = FALSE; + //int raw_val = 0; Option d for raw alarm byte not implemented + int b, j; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:rxa:b:c:m:n:p:i:d:o?")) != EOF ) - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else printusage = TRUE; - break; - case 'c': b = atoi(optarg); /* set crit alarm value */ - leds[1].fset = 1; - leds[1].val = b; - break; - case 'm': b = atoi(optarg); /* set major alarm value */ - leds[2].fset = 1; - leds[2].val = b; - break; - case 'n': b = atoi(optarg); /* set minor alarm value */ - leds[3].fset = 1; - leds[3].val = b; - break; - case 'a': b = atoi(optarg); /* set disk a fault led */ - leds[4].fset = 1; - leds[4].val = b; - break; - case 'b': b = atoi(optarg); /* set disk b fault led */ - leds[5].fset = 1; - leds[5].val = b; - break; - case 'p': b = atoi(optarg); /* set power alarm value */ - leds[0].fset = 1; - leds[0].val = b; - break; - case 'i': fid = atoi(optarg); /* set chassis id on/off */ - fsetid = 1; - break; - case 'd': raw_val = atoi(optarg); /* set raw alarm byte */ - break; - case 'o': fsetid=1; fid=0; /* set all alarms off */ - for (j = 0; j < NLEDS; j++) { - leds[j].fset = 1; - leds[j].val = 0; - } - break; - case 'x': fdebug = 1; break; /* debug messages */ - default: printusage = TRUE; - } - if (printusage) { - printf("Usage: %s [-a -b -c -i -m -n -p -o -x]\n", argv[0]); - printf(" where -D domain id Selects the domain\n"); - printf(" -c1 sets Critical Alarm on\n"); - printf(" -c0 sets Critical Alarm off\n"); - printf(" -m1 sets Major Alarm on\n"); - printf(" -m0 sets Major Alarm off\n"); - printf(" -n1 sets Minor Alarm on\n"); - printf(" -n0 sets Minor Alarm off\n"); - printf(" -p1 sets Power Alarm on\n"); - printf(" -p0 sets Power Alarm off\n"); - printf(" -i5 sets Chassis ID on for 5 sec\n"); - printf(" -i0 sets Chassis ID off\n"); - printf(" -a1 sets Disk A fault on\n"); - printf(" -a0 sets Disk A fault off\n"); - printf(" -b1 sets Disk B fault on\n"); - printf(" -b0 sets Disk B fault off\n"); - printf(" -d[byte] sets raw Alarm byte\n"); - printf(" -o sets all Alarms off\n"); - printf(" -x show eXtra debug messages\n"); + + context = g_option_context_new ("- Control alarm management instruments"); + g_option_context_add_main_entries (context, my_options, NULL); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 ? + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); exit(1); - } - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen error %d\n",rv); - exit(-1); - } + + if (fall) { /* set all alarms off */ + fid=0; + for (j = 0; j < NLEDS; j++) leds[j] = 0; + } + + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); + rv = saHpiDiscover(sessionid); - if (fdebug) printf("saHpiDiscover complete, rv = %d\n",rv); + if (copt.debug) printf("saHpiDiscover complete, rv = %d\n",rv); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; @@ -194,7 +141,7 @@ * a DataLength of zero here (for processor, bios). * rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; */ - //if (fdebug) + //if (copt.debug) printf("rptentry[%u] resourceid=%u tlen=%u tag: %s\n", entryid, resourceid, rptentry.ResourceTag.DataLength, rptentry.ResourceTag.Data); @@ -202,22 +149,22 @@ { rv = saHpiRdrGet(sessionid,resourceid, entryid,&nextentryid, &rdr); - if (fdebug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv); + if (copt.debug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv); if (rv == SA_OK) { if (rdr.RdrType == SAHPI_CTRL_RDR) { /*type 1 includes alarm LEDs*/ ctlnum = rdr.RdrTypeUnion.CtrlRec.Num; rdr.IdString.Data[rdr.IdString.DataLength] = 0; - if (fdebug) printf("Ctl[%u]: %u %u %s\n", + if (copt.debug) printf("Ctl[%u]: %u %u %s\n", ctlnum, rdr.RdrTypeUnion.CtrlRec.Type, rdr.RdrTypeUnion.CtrlRec.OutputType, rdr.IdString.Data); rv = saHpiControlTypeGet(sessionid,resourceid, ctlnum,&ctltype); - if (fdebug) printf("saHpiControlTypeGet[%u] rv = %d, type = %u\n",ctlnum,rv,ctltype); + if (copt.debug) printf("saHpiControlTypeGet[%u] rv = %d, type = %u\n",ctlnum,rv,ctltype); rv = saHpiControlGet(sessionid, resourceid, ctlnum, NULL, &ctlstate); - if (fdebug) + if (copt.debug) printf("saHpiControlStateGet[%u] rv = %d v = %x\n", ctlnum,rv,ctlstate.StateUnion.Digital); printf("RDR[%u]: ctltype=%u:%u oem=%02x %s \t", @@ -238,7 +185,7 @@ if (rdr.RdrTypeUnion.CtrlRec.Type == SAHPI_CTRL_TYPE_ANALOG && rdr.RdrTypeUnion.CtrlRec.OutputType == SAHPI_CTRL_LED) { /* This is a Chassis Identify */ - if (fsetid) { + if (fid>=0) { printf("Setting ID led to %u sec\n", fid); ctlstate.Type = SAHPI_CTRL_TYPE_ANALOG; ctlstate.StateUnion.Analog = fid; @@ -253,16 +200,16 @@ rdr.RdrTypeUnion.CtrlRec.OutputType == SAHPI_CTRL_LED) { /* this is an alarm LED */ b = (uchar)rdr.RdrTypeUnion.CtrlRec.Oem & 0x0f; - if ((b < NLEDS) && leds[b].fset) { - printf("Setting alarm led %u to %u\n",b,leds[b].val); - if (leds[b].val == 0) + if ((b < NLEDS) && leds[b]>=0) { + printf("Setting alarm led %u to %u\n",b,leds[b]); + if (leds[b] == 0) ctlstate.StateUnion.Digital = SAHPI_CTRL_STATE_OFF; else ctlstate.StateUnion.Digital = SAHPI_CTRL_STATE_ON; rv = saHpiControlSet(sessionid, resourceid, ctlnum, SAHPI_CTRL_MODE_MANUAL, &ctlstate); - /* if (fdebug) */ + /* if (copt.debug) */ printf("saHpiControlStateSet[%u] rv = %d\n",ctlnum,rv); } } @@ -271,9 +218,9 @@ rdr.RdrTypeUnion.CtrlRec.OutputType == SAHPI_CTRL_LED) { /* this is a disk LED */ b = (uchar)rdr.RdrTypeUnion.CtrlRec.Oem & 0x0f; - if ((b < NLEDS) && leds[b].fset) { - printf("Setting disk led %u to %u\n",b,leds[b].val); - if (leds[b].val == 0) + if ((b < NLEDS) && leds[b]>=0) { + printf("Setting disk led %u to %u\n",b,leds[b]); + if (leds[b] == 0) ctlstate.StateUnion.Digital = SAHPI_CTRL_STATE_OFF; else ctlstate.StateUnion.Digital = SAHPI_CTRL_STATE_ON; Modified: openhpi/trunk/clients/hpidomain.c =================================================================== --- openhpi/trunk/clients/hpidomain.c 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/clients/hpidomain.c 2011-01-26 08:58:28 UTC (rev 7259) @@ -1,6 +1,7 @@ /* -*- linux-c -*- * * Copyright (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,17 +19,11 @@ * openHPI complex * * Changes: + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oh_utils.h> -#include <oHpi.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision: 7112 $" @@ -44,10 +39,16 @@ /* * Globals for this driver */ -int fdebug = 0; -int fverbose = 0; +static gchar *f_domtag = NULL; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "tag", 't', 0, G_OPTION_ARG_STRING, &f_domtag, "Set domain tag to the specified string", "tttt" }, + { NULL } +}; + /* * Main */ @@ -55,79 +56,40 @@ main(int argc, char **argv) { SaErrorT rv = SA_OK; - - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT sessionid; - SaHpiBoolT printusage = FALSE; SaHpiTextBufferT domtag; int c; + GError *error = NULL; + GOptionContext *context; + oh_init_textbuffer(&domtag); oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:t:vx?")) != EOF ) { - switch(c) { - case 'D': - if (optarg) { - domainid = atoi(optarg); - } - else printusage = TRUE; - break; - case 't': - if (optarg) { - oh_append_textbuffer(&domtag, optarg); - } - else printusage = TRUE; - break; - case 'x': fdebug = 1; break; - case 'v': fverbose = 1; break; - default: printusage = TRUE; break; - } - } - if (printusage == TRUE) - { - printf("\n\tUsage: %s [-option]\n\n", argv[0]); - printf("\t (No Option) Display domain topology via " - "default domain: drt and headers\n"); - printf("\t -D nn Select domain id nn\n"); - printf("\t -v Display in verbose mode including " - "domain info for directly related domains\n"); - printf("\t -x Display debug messages\n"); - printf("\n\n\n\n"); + context = g_option_context_new ("- Display info about domains or set domain tag"); + g_option_context_add_main_entries (context, my_options, NULL); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? + error)) { + g_print ("option parsing failed: %s\n", error->message); exit(1); } - - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) - printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen returns %s\n",oh_lookup_error(rv)); - exit(-1); - } - if (fdebug) - printf("saHpiSessionOpen returns with SessionId %u\n", - sessionid); - /* - * Resource discovery ------ do we need it? - * - if (fdebug) printf("saHpiDiscover\n"); - rv = saHpiDiscover(sessionid); - if (rv != SA_OK) { - printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); - exit(-1); - } */ + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); - if (domtag.DataLength>0){ - if (fdebug) printf ("Let's go change the tag\n"); + if (f_domtag){ + oh_append_textbuffer(&domtag, f_domtag); + if (copt.debug) printf ("Let's go change the tag" + "to %s\n",f_domtag); set_domaintag(sessionid, domtag); } - if (fdebug) printf ("Let's go and list the domains!\n"); + if (copt.debug) printf ("Let's go and list the domains!\n"); show_domain(sessionid); @@ -152,7 +114,7 @@ SaHpiDomainIdT relateddomainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT relatedsessionid; - if (fdebug) printf("saHpiDomainInfoGet\n"); + if (copt.debug) printf("saHpiDomainInfoGet\n"); rv = saHpiDomainInfoGet(sessionid,&domaininfo); if (rv!=SA_OK) { printf("saHpiDomainInfoGet failed with returncode %s\n", @@ -166,14 +128,14 @@ /* walk the DRT */ drtentryid = SAHPI_FIRST_ENTRY; do { - if (fdebug) printf("saHpiDrtEntryGet\n"); + if (copt.debug) printf("saHpiDrtEntryGet\n"); rv = saHpiDrtEntryGet(sessionid, drtentryid,&nextdrtentryid,&drtentry); - if ((rv != SA_OK && rv != SA_ERR_HPI_NOT_PRESENT) || fdebug) + if ((rv != SA_OK && rv != SA_ERR_HPI_NOT_PRESENT) || copt.debug) printf("DrtEntryGet returns %s\n",oh_lookup_error(rv)); if (rv == SA_OK ) { - if (fverbose) { + if (copt.verbose) { /* display the domaininfo for that related domain */ relateddomainid = drtentry.DomainId; rv = saHpiSessionOpen(relateddomainid, @@ -186,7 +148,7 @@ relateddomainid,oh_lookup_error(rv)); continue; } - if (fdebug) { + if (copt.debug) { printf("saHpiSessionOpen returns with SessionId %u\n", relatedsessionid); printf("saHpiDomainInfoGet for related domain %u\n", @@ -208,7 +170,7 @@ } rv = saHpiSessionClose(relatedsessionid); - if (fdebug) + if (copt.debug) printf("saHpiSessionClose returns %s\n", oh_lookup_error(rv)); @@ -308,7 +270,7 @@ SaHpiDomainInfoT domaininfo; - if (fdebug) printf("saHpiDomainInfoGet\n"); + if (copt.debug) printf("saHpiDomainInfoGet\n"); rv = saHpiDomainInfoGet(sessionid,&domaininfo); if (rv!=SA_OK) { printf("saHpiDomainInfoGet failed with returncode %s\n", @@ -321,9 +283,10 @@ printf("\n"); rv = saHpiDomainTagSet (sessionid, &domtag); - if (rv!=SA_OK || fdebug) + if (rv!=SA_OK) printf("saHpiDomainTagSet failed with returncode %s. " "Tag not changed.\n",oh_lookup_error(rv)); + else if (copt.debug) printf("saHpiDomainTagSet completed.\n"); return rv; } Modified: openhpi/trunk/clients/hpitop.c =================================================================== --- openhpi/trunk/clients/hpitop.c 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/clients/hpitop.c 2011-01-26 08:58:28 UTC (rev 7259) @@ -3,6 +3,7 @@ * Copyright (c) 2003 by Intel Corp. * (C) Copyright IBM Corp. 2004, 2005 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,16 +23,11 @@ * Changes: * 09/02/2010 lwetzel Fixed Bug: ResourceId 255 (0xFF) is a valid ResourceId * 07/06/2010 ulikleber New option -D to select domain + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" @@ -91,111 +87,86 @@ #define EPATHSTRING_END_DELIMITER "}" #define rpt_startblock " |\n +--- " #define rdr_startblock " | |__ " + /* * Globals for this driver */ -int fdebug = 0; -int f_rpt = 0; -int f_inv = 0; -int f_sensor = 0; -int f_wdog = 0; -int f_dimi = 0; -int f_fumi = 0; -int f_ann = 0; -int f_ctrl = 0; -int f_overview = 0; -int f_allres = 1; +static gboolean f_rpt = FALSE; +static gboolean f_inv = FALSE; +static gboolean f_sensor = FALSE; +static gboolean f_wdog = FALSE; +static gboolean f_dimi = FALSE; +static gboolean f_fumi = FALSE; +static gboolean f_ann = FALSE; +static gboolean f_ctrl = FALSE; +static gboolean f_overview = TRUE; +static gboolean f_allres = TRUE; +static gint resourceid = 0; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "rpts", 'r', 0, G_OPTION_ARG_NONE, &f_rpt, "Display only rpts", NULL }, + { "sensors", 's', 0, G_OPTION_ARG_NONE, &f_sensor, "Display only sensors", NULL }, + { "controls", 'c', 0, G_OPTION_ARG_NONE, &f_ctrl, "Display only controls", NULL }, + { "watchdogs", 'w', 0, G_OPTION_ARG_NONE, &f_wdog, "Display only watchdogs", NULL }, + { "inventories", 'i', 0, G_OPTION_ARG_NONE, &f_inv, "Display only inventories", NULL }, + { "annunciators", 'a', 0, G_OPTION_ARG_NONE, &f_ann, "Display only annunciators", NULL }, + { "fumis", 'f', 0, G_OPTION_ARG_NONE, &f_fumi, "Display only fumis", NULL }, + { "dimis", 'd', 0, G_OPTION_ARG_NONE, &f_dimi, "Display only dimis", NULL }, + { "resource", 'n', 0, G_OPTION_ARG_INT, &resourceid, "Display only resource nn and its topology", "nn" }, + { NULL } +}; + + char previous_system[SAHPI_MAX_TEXT_BUFFER_LENGTH] = ""; + /* * Main */ int main(int argc, char **argv) { - SaErrorT rv = SA_OK; - - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; + SaErrorT rv = SA_OK; SaHpiSessionIdT sessionid; - SaHpiResourceIdT resourceid = 0; - SaHpiBoolT printusage = FALSE; - int c; - + GError *error = NULL; + GOptionContext *context; + oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"rsicwadfD:n:x?")) != EOF ) { - switch(c) { - case 'D': - if (optarg) { - domainid = atoi(optarg); - } - else printusage = TRUE; - break; - case 'r': f_rpt = 1; break; - case 's': f_sensor = 1; break; - case 'i': f_inv = 1; break; - case 'c': f_ctrl = 1; break; - case 'w': f_wdog = 1; break; - case 'a': f_ann = 1; break; - case 'f': f_fumi = 1; break; - case 'd': f_dimi = 1; break; - case 'n': - if (optarg) { - resourceid = atoi(optarg); - f_allres = 0; - } - else printusage = TRUE; - break; + context = g_option_context_new ("- Display system topology"); + g_option_context_add_main_entries (context, my_options, NULL); - case 'x': fdebug = 1; break; - default: printusage = TRUE; break; - } - } - if (printusage == TRUE) - { - printf("\n\tUsage: %s [-option]\n\n", argv[0]); - printf("\t (No Option) Display system topology via default domain: rpt & rdr headers\n"); - printf("\t -D nn Select domain id nn\n"); - printf("\t -r Display only rpts\n"); - printf("\t -s Display only sensors\n"); - printf("\t -c Display only controls\n"); - printf("\t -w Display only watchdogs\n"); - printf("\t -i Display only inventories\n"); - printf("\t -a Display only annunciators\n"); - printf("\t -f Display only fumis\n"); - printf("\t -d Display only dimis\n"); - printf("\t -n nn Display only resource nn and its topology\n"); - printf("\t -x Display debug messages\n"); - printf("\n\n\n\n"); + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); exit(1); } - - if (argc == 1) f_overview = 1; + + if (f_rpt || f_sensor || f_ctrl || f_wdog || f_inv || + f_ann || f_fumi || f_dimi || resourceid>0) + f_overview = FALSE; + memset (previous_system, 0, SAHPI_MAX_TEXT_BUFFER_LENGTH); - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen returns %s\n",oh_lookup_error(rv)); - exit(-1); - } - if (fdebug) - printf("saHpiSessionOpen returns with SessionId %u\n", sessionid); + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); /* * Resource discovery */ - if (fdebug) printf("saHpiDiscover\n"); + if (copt.debug) printf("saHpiDiscover\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); exit(-1); } - if (fdebug) printf("Discovery done\n"); + if (copt.debug) printf("Discovery done\n"); list_resources(sessionid, resourceid); rv = saHpiSessionClose(sessionid); @@ -223,15 +194,15 @@ SaHpiResourceIdT l_resourceid; SaHpiTextBufferT working; - oh_init_textbuffer(&working); + oh_init_textbuffer(&working); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; do { - if (fdebug) printf("saHpiRptEntryGet\n"); + if (copt.debug) printf("saHpiRptEntryGet\n"); rvRptGet = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if ((rvRptGet != SA_OK) || fdebug) + if ((rvRptGet != SA_OK) || copt.debug) printf("RptEntryGet returns %s\n",oh_lookup_error(rvRptGet)); rv = show_rpt(&rptentry, resourceid); @@ -247,11 +218,11 @@ /* walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; - if (fdebug) printf("rptentry[%u] resourceid=%u\n", entryid,resourceid); + if (copt.debug) printf("rptentry[%u] resourceid=%u\n", entryid,resourceid); do { rvRdrGet = saHpiRdrGet(sessionid,l_resourceid, entryid,&nextentryid, &rdr); - if (fdebug) printf("saHpiRdrGet[%u] rv = %s\n",entryid,oh_lookup_error(rvRdrGet)); + if (copt.debug) printf("saHpiRdrGet[%u] rv = %s\n",entryid,oh_lookup_error(rvRdrGet)); if (rvRdrGet == SA_OK) Modified: openhpi/trunk/clients/hpitree.c =================================================================== --- openhpi/trunk/clients/hpitree.c 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/clients/hpitree.c 2011-01-26 08:58:28 UTC (rev 7259) @@ -3,6 +3,7 @@ * Copyright (c) 2003 by Intel Corp. * (C) Copyright IBM Corp. 2004 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,16 +24,11 @@ * 11/03/2004 kouzmich Fixed Bug #1057934 * 09/02/2010 lwetzel Fixed Bug ResourceId 255 (0xFF) is a valid ResourceId * 07/06/2010 ulikleber New option -D to select domain + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" @@ -90,18 +86,43 @@ /* * Globals for this driver */ -int fdebug = 0; -int f_listall = 0; -int f_rpt = 0; -int f_sensor = 0; -int f_inv = 0; -int f_ctrl = 0; -int f_rdr = 0; -int f_wdog = 0; -int f_ann = 0; -int f_overview = 0; -int f_allres = 1; +static gboolean f_listall = FALSE; +static gboolean f_rpt = FALSE; +static gboolean f_rdr = FALSE; +static gboolean f_inv = FALSE; +static gboolean f_sensor = FALSE; +static gboolean f_wdog = FALSE; +//static gboolean f_dimi = FALSE; why is this implemented only in hpitop? +//static gboolean f_fumi = FALSE; why is this implemented only in hpitop? +static gboolean f_ann = FALSE; +static gboolean f_ctrl = FALSE; +static gboolean f_overview = FALSE; +static gboolean f_allres = TRUE; +static gint resourceid = 0; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "all", 'a', 0, G_OPTION_ARG_NONE, &f_listall, "Display all rpts and rdrs (default)", NULL }, + { "controls", 'c', 0, G_OPTION_ARG_NONE, &f_ctrl, "Display only controls", NULL }, + { "rdrs", 'd', 0, G_OPTION_ARG_NONE, &f_rdr, "Display rdr records", NULL }, + { "inventories", 'i', 0, G_OPTION_ARG_NONE, &f_inv, "Display only inventories", NULL }, + { "rpts", 'r', 0, G_OPTION_ARG_NONE, &f_rpt, "Display only rpts", NULL }, + { "sensors", 's', 0, G_OPTION_ARG_NONE, &f_sensor, "Display only sensors", NULL }, + { "watchdogs", 'w', 0, G_OPTION_ARG_NONE, &f_wdog, "Display only watchdogs", NULL }, + { "overview", 'o', 0, G_OPTION_ARG_NONE, &f_overview, "Display system overview: rpt & rdr headers",NULL }, + +// { "fumis", 'f', 0, G_OPTION_ARG_NONE, &f_fumi, "Display only fumis", NULL }, +// { "dimis", 'd', 0, G_OPTION_ARG_NONE, &f_dimi, "Display only dimis", NULL }, +// { "annunciators", 'a', 0, G_OPTION_ARG_NONE, &f_ann, "Display only annunciators", NULL }, + // Annunciators not implemented + + { "resource", 'n', 0, G_OPTION_ARG_INT, &resourceid, "Select particular resource id to display\n\t\t\t" + "(Used with [-cdirs] options)", NULL }, + { NULL } +}; + + /* * Main */ @@ -109,82 +130,36 @@ main(int argc, char **argv) { SaErrorT rv = SA_OK; - SaHpiSessionIdT sessionid; - SaHpiResourceIdT resourceid = 0; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; - SaHpiBoolT printusage = FALSE; - - int c; +// SaHpiResourceIdT resourceid = 0; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:acdirswon:x?")) != EOF ) { - switch(c) { - case 'D': - if (optarg) { - domainid = atoi(optarg); - } - else printusage = TRUE; - break; - case 'a': f_listall = 1; break; - case 'c': f_ctrl = 1; break; - case 'd': f_rdr = 1; break; - case 'i': f_inv = 1; break; - case 'r': f_rpt = 1; break; - case 's': f_sensor = 1; break; - case 'w': f_wdog = 1; break; - case 'o': f_overview = 1; break; - case 'n': - if (optarg) { - resourceid = atoi(optarg); - f_allres = 0; - } - else printusage = TRUE; - break; - case 'x': fdebug = 1; break; - default: printusage = TRUE; break; - } - } - if (printusage == TRUE) - { - printf("\n\tUsage: %s [-option]\n\n", argv[0]); - printf("\t (No Option) Display all rpts and rdrs via default domain\n"); - printf("\t -D nn Select domain id nn\n"); - printf("\t -a Display all rpts and rdrs\n"); - printf("\t -c Display only controls\n"); - printf("\t -d Display rdr records\n"); - printf("\t -i Display only inventories\n"); - printf("\t -o Display system overview: rpt & rdr headers\n"); - printf("\t -r Display only rpts\n"); - printf("\t -s Display only sensors\n"); - printf("\t -w Display only watchdog\n"); - printf("\t -n nn Select particular resource id to display\n"); - printf("\t (Used with [-cdirs] options)\n"); - printf("\t -x Display debug messages\n"); - printf("\n\n\n\n"); + context = g_option_context_new ("- Display system topology"); + g_option_context_add_main_entries (context, my_options, NULL); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127? + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); exit(1); } - if (f_rpt+f_sensor+f_inv+f_ctrl+f_rdr+f_wdog == 0) f_listall = 1; + if (f_rpt || f_sensor || f_inv || f_ctrl || f_rdr || f_wdog) + f_listall = TRUE; - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); - if (rv != SA_OK) { - printf("saHpiSessionOpen returns %s\n",oh_lookup_error(rv)); - exit(-1); - } - if (fdebug) - printf("saHpiSessionOpen returns with SessionId %u\n", sessionid); - /* * Resource discovery */ - if (fdebug) printf("saHpiDiscover\n"); + if (copt.debug) printf("saHpiDiscover\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); @@ -219,15 +194,15 @@ SaHpiResourceIdT l_resourceid; SaHpiTextBufferT working; - oh_init_textbuffer(&working); + oh_init_textbuffer(&working); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; do { - if (fdebug) printf("saHpiRptEntryGet\n"); + if (copt.debug) printf("saHpiRptEntryGet\n"); rvRptGet = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if ((rvRptGet != SA_OK) || fdebug) + if ((rvRptGet != SA_OK) || copt.debug) printf("RptEntryGet returns %s\n",oh_lookup_error(rvRptGet)); rv = list_rpt(&rptentry, resourceid); @@ -243,11 +218,11 @@ /* walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; - if (fdebug) printf("rptentry[%u] resourceid=%u\n", entryid,resourceid); + if (copt.debug) printf("rptentry[%u] resourceid=%u\n", entryid,resourceid); do { rvRdrGet = saHpiRdrGet(sessionid,l_resourceid, entryid,&nextentryid, &rdr); - if (fdebug) printf("saHpiRdrGet[%u] rv = %s\n",entryid,oh_lookup_error(rvRdrGet)); + if (copt.debug) printf("saHpiRdrGet[%u] rv = %s\n",entryid,oh_lookup_error(rvRdrGet)); if (rvRdrGet == SA_OK) @@ -401,7 +376,7 @@ oh_print_idrfield(&thisField, 12); } - if (fdebug) printf("saHpiIdrFieldGet error %s\n",oh_lookup_error(rvField)); + if (copt.debug) printf("saHpiIdrFieldGet error %s\n",oh_lookup_error(rvField)); fieldId = nextFieldId; } while ((rvField == SA_OK) && (fieldId != SAHPI_LAST_ENTRY)); Modified: openhpi/trunk/clients/oh_clients.h =================================================================== --- openhpi/trunk/clients/oh_clients.h 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/clients/oh_clients.h 2011-01-26 08:58:28 UTC (rev 7259) @@ -1,6 +1,7 @@ /* -*- linux-c -*- * * Copyright (C) 2007-2008, Hewlett-Packard Development Company, LLP + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -11,12 +12,56 @@ * * Author(s): * Shuah Khan <shu...@hp...> + * Ulrich Kleber <uli...@us...> + * + * Changes: + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients + * */ #ifndef __OH_CLIENTS_H #define __OH_CLIENTS_H +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <glib.h> +#include <SaHpi.h> + +#include <oHpi.h> +#include <oh_utils.h> + +#define OHC_ALL_OPTIONS (SaHpiUint8T) 0x01F +#define OHC_DEBUG_OPTION (SaHpiUint8T) 0x001 +#define OHC_DOMAIN_OPTION (SaHpiUint8T) 0x002 +#define OHC_VERBOSE_OPTION (SaHpiUint8T) 0x004 +#define OHC_ENTITY_PATH_OPTION (SaHpiUint8T) 0x008 +#define OHC_HOST_OPTION (SaHpiUint8T) 0x010 + +typedef struct { + gboolean debug; + gboolean verbose; + SaHpiDomainIdT domainid; + gboolean withentitypath; + SaHpiEntityPathT entitypath; + gboolean withdaemonhost; + SaHpiTextBufferT daemonhost; + SaHpiUint16T daemonport; +} oHpiCommonOptionsT; + void oh_prog_version(const char *prog_name, const char *svn_rev_str); +gboolean ohc_option_parse(int *argc, char *argv[], + GOptionContext *context, + oHpiCommonOptionsT *common_options, + SaHpiUint8T optionmask, + GError *error); + +SaErrorT ohc_session_open_by_option ( + oHpiCommonOptionsT *opt, + SaHpiSessionIdT *SessionId); + + #endif /* __OH_CLIENTS_H */ Modified: openhpi/trunk/docs/man/hpialarms.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpialarms.pod.1 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/docs/man/hpialarms.pod.1 2011-01-26 08:58:28 UTC (rev 7259) @@ -8,7 +8,7 @@ =head1 DESCRIPTION -hpialarms walks the RPT (Resource Present Table) for resouces that have +hpialarms walks the RPT (Resource Presence Table) for resources that have "Alarm Control" management instruments (SAHPI_CTRL_LED). If no domain is selected, hpialarms uses a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. @@ -18,25 +18,24 @@ =over 2 - -D domain id Select domain id - -c1 sets Critical Alarm on - -c0 sets Critical Alarm off - -m1 sets Major Alarm on - -m0 sets Major Alarm off - -n1 sets Minor Alarm on - -n0 sets Minor Alarm off - -p1 sets Power Alarm on - -p0 sets Power Alarm off - -i5 sets Chassis ID on for 5 sec - -i0 sets Chassis ID off - -a1 sets Disk A fault on - -a0 sets Disk A fault off - -b1 sets Disk B fault on - -b0 sets Disk B fault off - -d[byte] sets raw Alarm byte - -o sets all Alarms off - -x show eXtra debug messages +(No Option) Display alarm states +Help Options: + -h, --help Show help options + +Application Options: + -c, --critical=1|0 Set critical alarm on|off + -m, --major=1|0 Set major alarm on|off + -n, --minor=1|0 Set minor alarm on|off + -a, --diska=1|0 Set diska alarm on|off + -b, --diskb=1|0 Set diskb alarm on|off + -p, --power=1|0 Set power alarm on|off + -i, --chassisid=n Set chassis id on for n seconds + -o, --all Set all alarms off + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + + =back =head1 SAMPLE OUTPUT @@ -61,7 +60,7 @@ hpidomain hpigensimdata hpireset hpitop hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt - hpifan hpipower hpithres + hpifan hpipower hpithres hpixml ohdomainlist ohhandler ohparam Modified: openhpi/trunk/docs/man/hpidomain.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpidomain.pod.1 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/docs/man/hpidomain.pod.1 2011-01-26 08:58:28 UTC (rev 7259) @@ -16,12 +16,17 @@ =over 2 - (No Option) Display domain info - -D nn Select domain id nn - -v Verbose: Display domain info for all domains found in DRT - -t tag Set domain tag to the specified string - -x Display debug messages +(No Option) Display domain info +Help Options: + -h, --help Show help options + +Application Options: + -t, --tag=tttt Set domain tag to the specified string + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + -V, --verbose Verbose mode + =back =head1 SEE ALSO @@ -30,7 +35,7 @@ hpialarms hpigensimdata hpireset hpitop hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt - hpifan hpipower hpithres + hpifan hpipower hpithres hpixml ohdomainlist ohhandler ohparam Modified: openhpi/trunk/docs/man/hpitop.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitop.pod.1 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/docs/man/hpitop.pod.1 2011-01-26 08:58:28 UTC (rev 7259) @@ -17,19 +17,24 @@ =over 2 - (No Option) Display system topology via default domain: rpt & rdr headers - -D nn Select domain id nn - -r Display only rpts - -s Display only sensors - -c Display only controls - -w Display only watchdogs - -i Display only inventories - -a Display only annunciators - -f Display only fumis - -d Display only dimis - -n nn Display only resource nn and its topology - -x Display debug messages +(No Option) Display system topology via default domain: rpt & rdr headers +Help Options: + -h, --help Show help options + +Application Options: + -r, --rpts Display only rpts + -s, --sensors Display only sensors + -c, --controls Display only controls + -w, --watchdogs Display only watchdogs + -i, --inventories Display only inventories + -a, --annunciators Display only annunciators + -f, --fumis Display only fumis + -d, --dimis Display only dimis + -n, --resource=nn Display only resource nn and its topology + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + =back =head1 SEE ALSO @@ -38,7 +43,7 @@ hpialarms hpifan hpipower hpithres hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt - hpievents hpionIBMblade hpisettime + hpievents hpionIBMblade hpisettime hpixml ohdomainlist ohhandler ohparam Modified: openhpi/trunk/docs/man/hpitree.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitree.pod.1 2011-01-24 10:05:04 UTC (rev 7258) +++ openhpi/trunk/docs/man/hpitree.pod.1 2011-01-26 08:58:28 UTC (rev 7259) @@ -18,20 +18,25 @@ =over 2 - (No Option) Display all rpts and rdrs - -D nn Select domain id nn - -a Display all rpts and rdrs - -c Display only controls - -d Display rdr records - -i Display only inventories - -o Display system overview: rpt & rdr headers - -r Display only rpts - -s Display only sensors - -w Display only watchdog - -n nn Select particular resource id to display - (Used with [-cdirs] options) - -x Display debug messages +(No Option) Display all rpts and rdrs +Help Options: + -h, --help Show help options + +Application Options: + -a, --all Display all rpts and rdrs (default) + -c, --controls Display only controls + -d, --rdrs Display rdr records + -i, --inventories Display only inventories + -r, --rpts Display only rpts + -s, --sensors Display only sensors + -w, --watchdogs Display only watchdogs + -o, --overview Display system overview: rpt & rdr headers + -n, --resource Select particular resource id to display + (Used with [-cdirs] options) + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + =back =head1 SEE ALSO @@ -40,7 +45,7 @@ hpialarms hpifan hpipower hpithres hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpiwdt - hpievents hpionIBMblade hpisettime + hpievents hpionIBMblade hpisettime hpixml ohdomainlist ohhandler ohparam This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-01-29 22:42:39
|
Revision: 7260 http://openhpi.svn.sourceforge.net/openhpi/?rev=7260&view=rev Author: avpak Date: 2011-01-29 22:42:33 +0000 (Sat, 29 Jan 2011) Log Message: ----------- Fix for #3167845 Modified Paths: -------------- openhpi/trunk/baselib/conf.c openhpi/trunk/include/SaHpi.h openhpi/trunk/openhpid/conf.c openhpi/trunk/openhpid/domain.c openhpi/trunk/openhpid/openhpid-win32.cpp openhpi/trunk/openhpid/session.c openhpi/trunk/transport/strmsock.cpp openhpi/trunk/utils/sahpi_struct_utils.c Modified: openhpi/trunk/baselib/conf.c =================================================================== --- openhpi/trunk/baselib/conf.c 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/baselib/conf.c 2011-01-29 22:42:33 UTC (rev 7260) @@ -309,8 +309,8 @@ FALSE /* scope_0_fallback */, }; -static GTokenType get_next_good_token(GScanner *oh_scanner) { - GTokenType next_token; +static int get_next_good_token(GScanner *oh_scanner) { + int next_token; next_token = g_scanner_get_next_token(oh_scanner); while (next_token != G_TOKEN_RIGHT_CURLY && @@ -342,12 +342,13 @@ char host[SAHPI_MAX_TEXT_BUFFER_LENGTH]; unsigned int port; - GTokenType next_token; + int next_token; host[0] = '\0'; port = OPENHPI_DEFAULT_DAEMON_PORT; - if (g_scanner_get_next_token(oh_scanner) != HPI_CLIENT_CONF_TOKEN_DOMAIN) { + next_token = g_scanner_get_next_token(oh_scanner); + if (next_token != HPI_CLIENT_CONF_TOKEN_DOMAIN) { CRIT("Processing domain: Expected a domain token"); return -1; } @@ -467,7 +468,7 @@ g_scanner_scope_add_symbol( oh_scanner, 0, ohc_conf_tokens[i].name, - (void *)((unsigned long)ohc_conf_tokens[i].token)); + GUINT_TO_POINTER(ohc_conf_tokens[i].token)); } while (!done) { Modified: openhpi/trunk/include/SaHpi.h =================================================================== --- openhpi/trunk/include/SaHpi.h 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/include/SaHpi.h 2011-01-29 22:42:33 UTC (rev 7260) @@ -638,6 +638,19 @@ Reserved for future use by this specification */ SAHPI_ENT_CHASSIS_SPECIFIC = SAHPI_ENT_IPMI_GROUP + 0x90, + SAHPI_ENT_CHASSIS_SPECIFIC01, /* include numbers from SaHpiXtca.h to */ + SAHPI_ENT_CHASSIS_SPECIFIC02, /* avoid gcc-4.6 warning */ + SAHPI_ENT_CHASSIS_SPECIFIC03, /* from -Wswitch check */ + SAHPI_ENT_CHASSIS_SPECIFIC04, + SAHPI_ENT_CHASSIS_SPECIFIC05, + SAHPI_ENT_CHASSIS_SPECIFIC06, + SAHPI_ENT_CHASSIS_SPECIFIC07, + SAHPI_ENT_CHASSIS_SPECIFIC08, + SAHPI_ENT_CHASSIS_SPECIFIC09, + SAHPI_ENT_CHASSIS_SPECIFIC10, + SAHPI_ENT_CHASSIS_SPECIFIC11, + SAHPI_ENT_CHASSIS_SPECIFIC12, + SAHPI_ENT_CHASSIS_SPECIFIC13, SAHPI_ENT_BOARD_SET_SPECIFIC = SAHPI_ENT_IPMI_GROUP + 0xB0, SAHPI_ENT_OEM_SYSINT_SPECIFIC = SAHPI_ENT_IPMI_GROUP + 0xD0, SAHPI_ENT_ROOT = SAHPI_ENT_ROOT_VALUE, Modified: openhpi/trunk/openhpid/conf.c =================================================================== --- openhpi/trunk/openhpid/conf.c 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/openhpid/conf.c 2011-01-29 22:42:33 UTC (rev 7260) @@ -264,7 +264,7 @@ data_access_lock(); - if (g_scanner_get_next_token(oh_scanner) != HPI_CONF_TOKEN_HANDLER) { + if (g_scanner_get_next_token(oh_scanner) != (int)HPI_CONF_TOKEN_HANDLER) { CRIT("Processing handler: Unexpected token."); data_access_unlock(); return -1; @@ -381,7 +381,7 @@ static int process_global_token(GScanner *scanner) { char *name = NULL, *value = NULL; - guint current_token; + int current_token; data_access_lock(); @@ -513,11 +513,11 @@ g_scanner_scope_add_symbol( oh_scanner, 0, oh_conf_tokens[i].name, - (void *)((unsigned long)oh_conf_tokens[i].token)); + GUINT_TO_POINTER(oh_conf_tokens[i].token)); } while (!done) { - guint my_token; + int my_token; my_token = g_scanner_peek_next_token (oh_scanner); /*DBG("token: %d", my_token);*/ switch (my_token) Modified: openhpi/trunk/openhpid/domain.c =================================================================== --- openhpi/trunk/openhpid/domain.c 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/openhpid/domain.c 2011-01-29 22:42:33 UTC (rev 7260) @@ -168,7 +168,7 @@ gen_domain_event(target_id, subject_id, SAHPI_TRUE); } else { GSList *node = NULL, *savenode = NULL; - int child_count = 0, peer_count = 0, is_peer = 0; + int child_count = 0, peer_count = 0; for (node = domain->drt.list; node || savenode; @@ -180,7 +180,6 @@ else child_count++; if (drtentry->DomainId == subject_id && !found) { - is_peer = drtentry->IsPeer; savenode = node->next; domain->drt.list = g_slist_delete_link(domain->drt.list, Modified: openhpi/trunk/openhpid/openhpid-win32.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid-win32.cpp 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/openhpid/openhpid-win32.cpp 2011-01-29 22:42:33 UTC (rev 7260) @@ -139,7 +139,7 @@ int port = OPENHPI_DEFAULT_DAEMON_PORT; unsigned int sock_timeout = 0; // unlimited int max_threads = -1; // unlimited - bool runasdaemon = true; + //bool runasdaemon = true; /* get the command line options */ int c; @@ -174,7 +174,7 @@ } break; case 'n': - runasdaemon = false; + //runasdaemon = false; break; case '?': default: Modified: openhpi/trunk/openhpid/session.c =================================================================== --- openhpi/trunk/openhpid/session.c 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/openhpid/session.c 2011-01-29 22:42:33 UTC (rev 7260) @@ -386,7 +386,6 @@ SaErrorT oh_destroy_session(SaHpiSessionIdT sid) { struct oh_session *session = NULL; - SaHpiDomainIdT did; gpointer event = NULL; int i, len; @@ -402,7 +401,6 @@ oh_sessions.list = g_slist_remove(oh_sessions.list, session); g_hash_table_remove(oh_sessions.table, &(session->id)); g_static_rec_mutex_unlock(&oh_sessions.lock); /* Unlocked session table */ - did = session->did; /* Finalize session */ len = g_async_queue_length(session->eventq); Modified: openhpi/trunk/transport/strmsock.cpp =================================================================== --- openhpi/trunk/transport/strmsock.cpp 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/transport/strmsock.cpp 2011-01-29 22:42:33 UTC (rev 7260) @@ -20,9 +20,9 @@ #include <string.h> #ifdef _WIN32 -#include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> +#include <windows.h> #else #include <netdb.h> #include <netinet/in.h> Modified: openhpi/trunk/utils/sahpi_struct_utils.c =================================================================== --- openhpi/trunk/utils/sahpi_struct_utils.c 2011-01-26 08:58:28 UTC (rev 7259) +++ openhpi/trunk/utils/sahpi_struct_utils.c 2011-01-29 22:42:33 UTC (rev 7260) @@ -18,6 +18,7 @@ */ #include <glib.h> +#include <inttypes.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -403,13 +404,13 @@ switch(reading.Type) { case SAHPI_SENSOR_READING_TYPE_INT64: snprintf(text, SAHPI_MAX_TEXT_BUFFER_LENGTH, - "%lld", reading.Value.SensorInt64); + "%" PRId64, (int64_t)reading.Value.SensorInt64); err = oh_append_textbuffer(&working, text); if (err) { return(err); } break; case SAHPI_SENSOR_READING_TYPE_UINT64: snprintf(text, SAHPI_MAX_TEXT_BUFFER_LENGTH, - "%llu", reading.Value.SensorUint64); + "%" PRIu64, (uint64_t)reading.Value.SensorUint64); err = oh_append_textbuffer(&working, text); if (err) { return(err); } break; @@ -517,7 +518,6 @@ char numstr[SAHPI_MAX_TEXT_BUFFER_LENGTH]; int i, j, skip; int found_sign, found_number, found_float, in_number; - int is_percent = 0; SaHpiFloat64T num_float64 = 0.0; SaHpiInt64T num_int64 = 0; SaHpiUint64T num_uint64 = 0; @@ -548,9 +548,15 @@ */ /* Skip any characters before an '=' sign */ - char *skipstr = strchr((char *)buffer->Data, '='); - if (skipstr) skip = (long int)skipstr - (long int)(buffer->Data) + 1; - else skip = 0; + for (skip = 0; skip < buffer->DataLength; ++skip) { + if (buffer->Data[skip] == '=') { + ++skip; + break; + } + } + if (skip >= buffer->DataLength) { + skip = 0; + } j = found_sign = in_number = found_number = found_float = 0; for (i=skip; i<buffer->DataLength && !found_number; i++) { @@ -592,12 +598,6 @@ } if (found_number || in_number) { /* in_number means string ended in a digit character */ - for (j=i-1; j<buffer->DataLength; j++) { - if (buffer->Data[j] == '%') { - is_percent = 1; - break; - } - } found_number = 1; } @@ -3499,7 +3499,6 @@ { char str[SAHPI_MAX_TEXT_BUFFER_LENGTH]; SaHpiTextBufferT tmpbuffer; - SaErrorT err; if ( !buffer || !event) { return(SA_ERR_HPI_INVALID_PARAMS); @@ -3511,7 +3510,7 @@ offsets++; oh_append_offset(buffer, offsets); - err = oh_decode_manufacturerid(event->EventDataUnion.HpiSwEvent.MId, &tmpbuffer); + oh_decode_manufacturerid(event->EventDataUnion.HpiSwEvent.MId, &tmpbuffer); snprintf(str, SAHPI_MAX_TEXT_BUFFER_LENGTH, "ManufacturerId: %s\n", tmpbuffer.Data); oh_append_bigtext(buffer, str); @@ -3539,7 +3538,6 @@ static SaErrorT oh_build_event_oem(oh_big_textbuffer *buffer, const SaHpiEventT *event, int offsets) { char str[SAHPI_MAX_TEXT_BUFFER_LENGTH]; - SaErrorT err; SaHpiTextBufferT tmpbuffer; if ( !buffer || !event) { @@ -3552,7 +3550,7 @@ offsets++; oh_append_offset(buffer, offsets); - err = oh_decode_manufacturerid(event->EventDataUnion.OemEvent.MId, &tmpbuffer); + oh_decode_manufacturerid(event->EventDataUnion.OemEvent.MId, &tmpbuffer); snprintf(str, SAHPI_MAX_TEXT_BUFFER_LENGTH, "ManufacturerId: %s\n", tmpbuffer.Data); oh_append_bigtext(buffer, str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-02-02 09:41:26
|
Revision: 7265 http://openhpi.svn.sourceforge.net/openhpi/?rev=7265&view=rev Author: ulikleber Date: 2011-02-02 09:41:18 +0000 (Wed, 02 Feb 2011) Log Message: ----------- more on 1493787 Update clients to use long options and uniform format clients hpiel, hpievents, hpifan, hpigensimdata, hpireset, hpipower, hpionIBMblade, hpiinv and some small fixes. Modified Paths: -------------- openhpi/trunk/clients/hpialarms.c openhpi/trunk/clients/hpiel.c openhpi/trunk/clients/hpievents.c openhpi/trunk/clients/hpifan.c openhpi/trunk/clients/hpigensimdata.c openhpi/trunk/clients/hpiinv.c openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/hpipower.c openhpi/trunk/clients/hpireset.c openhpi/trunk/clients/hpitree.c openhpi/trunk/clients/oh_clients.h openhpi/trunk/docs/man/hpialarms.pod.1 openhpi/trunk/docs/man/hpidomain.pod.1 openhpi/trunk/docs/man/hpiel.pod.1 openhpi/trunk/docs/man/hpievents.pod.1 openhpi/trunk/docs/man/hpifan.pod.1 openhpi/trunk/docs/man/hpigensimdata.pod.1 openhpi/trunk/docs/man/hpiinv.pod.1 openhpi/trunk/docs/man/hpionIBMblade.pod.1 openhpi/trunk/docs/man/hpipower.pod.1 openhpi/trunk/docs/man/hpireset.pod.1 openhpi/trunk/docs/man/hpitop.pod.1 openhpi/trunk/docs/man/hpitree.pod.1 Modified: openhpi/trunk/clients/hpialarms.c =================================================================== --- openhpi/trunk/clients/hpialarms.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpialarms.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -14,7 +14,7 @@ * 10/13/04 Andy Cress - v1.2 add ifdefs for HPI_A & HPI_B, added -d/raw * < ...for more changes look at svn logs... > * 09/06/2010 ulikleber New option -D to select domain - * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * 01/02/2011 ulikleber Refactoring to use glib for option parsing and * introduce common options for all clients * * Author(s): Modified: openhpi/trunk/clients/hpiel.c =================================================================== --- openhpi/trunk/clients/hpiel.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpiel.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -2,6 +2,7 @@ * * (C) Copyright IBM Corp 2006 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,24 +20,17 @@ * * Changes: * 09/06/2010 ulikleber New option -D to select domain + * 01/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients */ -#include <stdlib.h> -#include <string.h> -#include <getopt.h> - - -#include <SaHpi.h> -#include <oHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" #define err(format, ...) \ do { \ - if (opts.dbg) { \ + if (copt.debug) { \ fprintf(stderr, format "\n", ## __VA_ARGS__); \ } \ } while(0) @@ -44,7 +38,7 @@ #define show_error_quit(msg) \ do { \ if (error) { \ - opts.dbg = 1; \ + copt.debug = TRUE; \ err(msg, oh_lookup_error(error)); \ exit(-1); \ } \ @@ -52,19 +46,28 @@ /* Globals */ static struct hpiel_opts { - int del; /* Domain Event Log option. */ - char *ep; /* Resource Event Log option. */ - int clear; /* Clear the event log before traversing it. */ - int resource; /* Get resource along with event log entry. */ - int rdr; /* Get RDR along with event log entry. */ - int dbg; /* Display debug messages. */ -} opts = { 0, NULL, 0, 0, 0, 0 }; + gboolean del; /* Domain Event Log option. */ + gboolean clear; /* Clear the event log before traversing it. */ + gboolean resource; /* Get resource along with event log entry. */ + gboolean rdr; /* Get RDR along with event log entry. */ +} opts = { FALSE, FALSE, FALSE, FALSE }; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "del", 'd', 0, G_OPTION_ARG_NONE, &opts.del, "Display domain event log entries", NULL }, + { "clear", 'c', 0, G_OPTION_ARG_NONE, &opts.clear, "Clear log before reading event log entries", NULL }, + { "resource", 'p', 0, G_OPTION_ARG_NONE, &opts.resource, "Pull resource info along with log entry", NULL }, + { "rdr", 'r', 0, G_OPTION_ARG_NONE, &opts.rdr, "Pull RDR info along with log entry", NULL }, + { NULL } +}; + + SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; /* Prototypes */ -SaErrorT parse_options(int argc, char ***argv, struct hpiel_opts *opts); -SaErrorT harvest_sels(SaHpiSessionIdT sid, SaHpiDomainInfoT *dinfo, char *ep); +SaErrorT parse_options(int argc, char ***argv); +SaErrorT harvest_sels(SaHpiSessionIdT sid, SaHpiDomainInfoT *dinfo); SaErrorT display_el(SaHpiSessionIdT sid, SaHpiResourceIdT rid, SaHpiTextBufferT *tag); int main(int argc, char **argv) @@ -72,18 +75,32 @@ SaErrorT error = SA_OK; SaHpiSessionIdT sid; SaHpiDomainInfoT dinfo; + GError *gerror = NULL; + GOptionContext *context; /* Print version strings */ oh_prog_version(argv[0], OH_SVN_REV); /* Parsing options */ - if (parse_options(argc, &argv, &opts)) { - fprintf(stderr, "There was an error parsing the options. Exiting.\n"); - exit(-1); - } + context = g_option_context_new ("- Displays HPI event log entries\n" + "Option E (entity-path) displays resource event log entries.\n" + "If neither -d or -E \"<arg>\" are specified, " + "event log entries will be shown\n" + "for all supporting resources by default."); + g_option_context_add_main_entries (context, my_options, NULL); + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_VERBOSE_OPTION, // no verbose mode implemented + gerror)) { + g_print ("option parsing failed: %s\n", gerror->message); + exit(1); + } + /* Program really begins here - all options parsed at this point */ - error = saHpiSessionOpen(domainid, &sid, NULL); + error = ohc_session_open_by_option ( &copt, &sid); + if (error != SA_OK) exit(-1); show_error_quit("saHpiSessionOpen() returned %s. Exiting.\n"); error = saHpiDiscover(sid); @@ -92,18 +109,15 @@ error = saHpiDomainInfoGet(sid, &dinfo); show_error_quit("saHpiDomainInfoGet() returned %s. Exiting.\n"); - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) - printf("Domain Info: UpdateCount = %u, UpdateTime = %lx\n", - dinfo.RptUpdateCount, (unsigned long)dinfo.RptUpdateTimestamp); - else printf("Domain Info: DomainId = %u, UpdateCount = %u, UpdateTime = %lx\n", - domainid, dinfo.RptUpdateCount, (unsigned long)dinfo.RptUpdateTimestamp); + printf("Domain Info: UpdateCount = %u, UpdateTime = %lx\n", + dinfo.RptUpdateCount, (unsigned long)dinfo.RptUpdateTimestamp); - if (opts.ep) { /* Entity path specified */ - error = harvest_sels(sid, &dinfo, opts.ep); + if (copt.withentitypath) { /* Entity path specified */ + error = harvest_sels(sid, &dinfo); } else if (opts.del) { /* Domain event log specified */ error = display_el(sid, SAHPI_UNSPECIFIED_RESOURCE_ID, &dinfo.DomainTag); } else { /* Else, show SELs of all supporting resources */ - error = harvest_sels(sid, &dinfo, NULL); + error = harvest_sels(sid, &dinfo); } if (error) err("An error happened. Gathering event log entries returned %s", @@ -116,97 +130,13 @@ return error; } -#define print_usage_quit() \ - do { \ - printf("\nUsage:\n" \ - " hpiel - Displays HPI event log entries.\n\n" \ - " --Domain=\"<arg>\", -D \"<arg>\" select domain id\n" \ - " --del, -d display domain event log entries\n" \ - " --entitypath=\"<arg>\", -e \"<arg>\" display resource event log entries\n" \ - " (e.g. -e \"{SYSTEM_CHASSIS,2}{SBC_BLADE,5}\")\n" \ - " --clear, -c clear log before reading event log entries\n" \ - " --resource, -p pull resource info along with log entry\n" \ - " --rdr, -r pull RDR info along with log entry\n" \ - " --xml, -x print output in xml format (not implemented)\n" \ - " --verbose, -v print debug messages\n" \ - " --help, -h print this usage message\n" \ - "\n If neither -d or -e \"<arg>\" are specified, event log entries will be shown\n" \ - " for all supporting resources by default.\n\n"); \ - exit(0); \ - } while(0) - -SaErrorT parse_options(int argc, char ***argv, struct hpiel_opts *opts) +SaErrorT harvest_sels(SaHpiSessionIdT sid, SaHpiDomainInfoT *dinfo) { - static struct option long_options[] = { - {"Domain", required_argument, 0, 'D'}, - {"del", no_argument, 0, 'd'}, - {"entitypath", required_argument, 0, 'e'}, - {"clear", no_argument, 0, 'c'}, - {"resource", no_argument, 0, 'p'}, - {"rdr", no_argument, 0, 'r'}, - {"verbose", no_argument, 0, 'v'}, - {"help", no_argument, 0, 'h'}, - {0, 0, 0, 0} - }; - int c, option_index = 0; - - while ((c = getopt_long(argc, *argv, "D:de:cprvh", long_options, &option_index)) != -1) { - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else { - printf("hpiel: option requires an argument -- D"); - print_usage_quit(); - } - break; - - case 'd': - opts->del = 1; - break; - case 'e': - if (optarg) opts->ep = strdup(optarg); - else { - printf("hpiel: option requires an argument -- e"); - print_usage_quit(); - } - break; - case 'c': - opts->clear = 1; - break; - case 'p': - opts->resource = 1; - break; - case 'r': - opts->rdr = 1; - break; - case 'v': - opts->dbg = 1; - break; - case 'h': - print_usage_quit(); - break; - case '?': - printf("extraneous option found, %d\n", optopt); - print_usage_quit(); - break; - default: - printf("Found bad option %d.\n", c); - print_usage_quit(); - break; - } - } - - return 0; -} - -SaErrorT harvest_sels(SaHpiSessionIdT sid, SaHpiDomainInfoT *dinfo, char *ep) -{ SaErrorT error = SA_OK; SaHpiRptEntryT rptentry; SaHpiEntryIdT entryid, nextentryid; SaHpiResourceIdT rid; oh_big_textbuffer bigbuf; - SaHpiEntityPathT entitypath; SaHpiBoolT found_entry = SAHPI_FALSE; if (!sid || !dinfo) { @@ -214,23 +144,14 @@ return SA_ERR_HPI_INVALID_PARAMS; } - if (opts.ep && ep) { - error = oh_encode_entitypath(ep, &entitypath); - if (error) { - err("oh_encode_entitypath() returned %s from %s\n", - oh_lookup_error(error), ep); - return error; - } - } - entryid = SAHPI_FIRST_ENTRY; while (error == SA_OK && entryid != SAHPI_LAST_ENTRY) { error = saHpiRptEntryGet(sid, entryid, &nextentryid, &rptentry); err("saHpiRptEntryGet() returned %s\n", oh_lookup_error(error)); if (error == SA_OK) { - if (opts.ep && ep) { - if (!oh_cmp_ep(&entitypath, &rptentry.ResourceEntity)) { + if (copt.withentitypath) { + if (!oh_cmp_ep(&copt.entitypath, &rptentry.ResourceEntity)) { entryid = nextentryid; continue; } @@ -255,15 +176,18 @@ error = display_el(sid, rid, &rptentry.ResourceTag); - if (opts.ep && ep) return SA_OK; + if (copt.withentitypath) return SA_OK; } entryid = nextentryid; } if (!found_entry) { - if (opts.ep && ep) { - err("Could not find resource matching %s\n", ep); + if (copt.withentitypath) { + fprintf(stderr, //cannot use err macro here + "Could not find resource matching "); + oh_fprint_ep(stderr, &copt.entitypath, 0); + fprintf(stderr,"\n"); } else { err("No resources supporting event logs were found.\n"); } Modified: openhpi/trunk/clients/hpievents.c =================================================================== --- openhpi/trunk/clients/hpievents.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpievents.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -2,6 +2,7 @@ * * (C) Copyright IBM Corp. 2003, 2004, 2007 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,40 +21,33 @@ * added -d option for call saHpiDiscover after saHpiSubscribe * 11/17/2004 kouzmich linux style and checking timeout error * 09/06/2010 ulikleber New option -D to select domain + * 01/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients */ -#include <stdio.h> -#include <stdlib.h> -#include <getopt.h> -#include <string.h> - -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" #define HPI_NSEC_PER_SEC 1000000000LL -int fdebug = 0; -SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; +static gchar *timeout_str = NULL; +static gboolean do_discover_after_subscribe = FALSE; +static oHpiCommonOptionsT copt; -static void Usage(char **argv) +static GOptionEntry my_options[] = { - printf("Usage %s [-D <value>] [-t <value> | SAHPI_TIMEOUT_BLOCK | BLOCK] [-d] [-x]\n",argv[0]); - printf(" where: -D <value> - select domain id\n"); - printf(" -t <value> - wait <value> seconds for event;\n"); - printf(" -t SAHPI_TIMEOUT_BLOCK or BLOCK - infinite wait\n"); - printf(" -d - call saHpiDiscover() after saHpiSubscribe()\n"); - printf(" -x - displays eXtra debug messages\n"); -} + { "timeout", 't', 0, G_OPTION_ARG_STRING, &timeout_str, "Wait n seconds for event or infinite wait", + "n|BLOCK|SAHPI_TIMEOUT_BLOCK" }, + { "discover", 'd', 0, G_OPTION_ARG_NONE, &do_discover_after_subscribe, "Call saHpiDiscover() after saHpiSubscribe()", + NULL }, + { NULL } +}; + int main(int argc, char **argv) { - int c, test_fail = 0, wait = 0; - char *timeout_str= (char *)NULL; - int do_discover_after_subscribe = 0; + int test_fail = 0, wait = 0; SaErrorT rv; SaHpiSessionIdT sessionid; SaHpiDomainInfoT domainInfo; @@ -65,42 +59,32 @@ SaHpiRdrT rdr; SaHpiTimeoutT timeout; SaHpiEventT event; + GError *error = NULL; + GOptionContext *context; memset(&rptentry, 0, sizeof(rptentry)); oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:t:xd?")) != EOF ) { - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else { - printf("hpievents: option requires an argument -- D"); - Usage(argv); - exit(1); - } - break; - case 't': - if (optarg) timeout_str = optarg; - else { - printf("hpievents: option requires an argument -- t"); - Usage(argv); - exit(1); - } - break; - case 'd': - do_discover_after_subscribe = 1; - break; - case 'x': - fdebug = 1; - break; - default: - Usage(argv); - exit(1); - } - } + context = g_option_context_new ("- Poll for HPI events"); + g_option_context_add_main_entries (context, my_options, NULL); - if (timeout_str != (char *)NULL) { + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); + } + + if (timeout_str) { + int i = 0; + while (i < 20 && timeout_str[i] != '\0') { + timeout_str[i] = toupper((char) timeout_str[i]); + i++; + } if ((strcmp(timeout_str, "SAHPI_TIMEOUT_BLOCK") == 0) || (strcmp(timeout_str, "BLOCK") == 0)) { timeout = SAHPI_TIMEOUT_BLOCK; @@ -114,22 +98,11 @@ printf("************** timeout:[%" PRId64 "] ****************\n", (uint64_t) timeout); - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - - rv = saHpiSessionOpen(domainid, &sessionid, NULL); - if (rv != SA_OK) { - if (rv == SA_ERR_HPI_ERROR) - printf("saHpiSessionOpen: error %d, SpiLibd not running\n", rv); - else - printf("saHpiSessionOpen: %s\n", oh_lookup_error(rv)); - exit(-1); - } + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); if (!do_discover_after_subscribe) { - if (fdebug) printf("saHpiDiscover\n"); + if (copt.debug) printf("saHpiDiscover\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); @@ -137,7 +110,7 @@ } } - if (fdebug) printf( "Subscribe to events\n"); + if (copt.debug) printf( "Subscribe to events\n"); rv = saHpiSubscribe( sessionid ); if (rv != SA_OK) { printf("saHpiSubscribe: %s\n", oh_lookup_error(rv)); @@ -145,7 +118,7 @@ } if (do_discover_after_subscribe) { - if (fdebug) printf("saHpiDiscover after saHpiSubscribe\n"); + if (copt.debug) printf("saHpiDiscover after saHpiSubscribe\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover after saHpiSubscribe: %s\n", oh_lookup_error(rv)); @@ -155,7 +128,7 @@ rv = saHpiDomainInfoGet(sessionid, &domainInfo); - if (fdebug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); printf("DomainInfo: UpdateCount = %u, UpdateTime = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); @@ -165,23 +138,23 @@ printf("**********************************************\n"); rv = saHpiRptEntryGet(sessionid, rptentryid, &nextrptentryid, &rptentry); - if (fdebug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); if (rv == SA_OK) { resourceid = rptentry.ResourceId; - if (fdebug) + if (copt.debug) printf("RPT %x capabilities = %x\n", resourceid, rptentry.ResourceCapabilities); if ( (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_EVENT_LOG)) { /* Using EventLogInfo to build up event queue - for now */ rv = saHpiEventLogInfoGet(sessionid, resourceid, &info); - if (fdebug) + if (copt.debug) printf("saHpiEventLogInfoGet %s\n", oh_lookup_error(rv)); if (rv == SA_OK) oh_print_eventloginfo(&info, 4); } else { - if (fdebug) + if (copt.debug) printf("RPT doesn't have SEL\n"); } @@ -238,7 +211,7 @@ printf(" Test FAILED.\n"); /* Unsubscribe to future events */ - if (fdebug) printf( "Unsubscribe\n"); + if (copt.debug) printf( "Unsubscribe\n"); rv = saHpiUnsubscribe( sessionid ); rv = saHpiSessionClose(sessionid); Modified: openhpi/trunk/clients/hpifan.c =================================================================== --- openhpi/trunk/clients/hpifan.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpifan.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -3,6 +3,7 @@ * * Copyright (c) 2003,2004 by FORCE Computers * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,17 +19,11 @@ * Changes: * 10/13/2004 kouzmich porting to HPI B * 09/06/2010 ulikleber New option -D to select domain + * 01/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> - -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" @@ -36,53 +31,16 @@ static SaHpiBoolT set_new = SAHPI_FALSE; static SaHpiCtrlModeT new_mode = SAHPI_CTRL_MODE_MANUAL; static int new_speed = -1; -SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; +static gchar *f_speed = NULL; +static oHpiCommonOptionsT copt; - -static int -usage( char *progname ) +static GOptionEntry my_options[] = { - fprintf( stderr, "usage: %s [-D domainid] [-h] [-s fan_speed_level]\n", progname ); - fprintf( stderr, "\t\t -D domainid select the domain to work on\n" ); - fprintf( stderr, "\t\t -h help\n" ); - fprintf( stderr, "\t\t -s speed set fan speed for ALL fans in domain\n" ); - fprintf( stderr, "\t\t speed is a number or \"auto\" for setting fan in auto mode\n" ); + { "speed", 's', 0, G_OPTION_ARG_STRING, &f_speed, "Set fan speed for ALL fans in domain\n" + " speed is a number or \"auto\" for setting fan in auto mode", "auto|nn" }, + { NULL } +}; - return 1; -} - - -static void -display_textbuffer( SaHpiTextBufferT string ) -{ - int i; - switch( string.DataType ) { - case SAHPI_TL_TYPE_BINARY: - for( i = 0; i < string.DataLength; i++ ) - printf( "%x", string.Data[i] ); - break; - case SAHPI_TL_TYPE_BCDPLUS: - for( i = 0; i < string.DataLength; i++ ) - printf( "%c", string.Data[i] ); - break; - case SAHPI_TL_TYPE_ASCII6: - for( i = 0; i < string.DataLength; i++ ) - printf( "%c", string.Data[i] ); - break; - case SAHPI_TL_TYPE_UNICODE: - for( i = 0; i < string.DataLength; i++ ) - printf( "%c", string.Data[i] ); - break; - case SAHPI_TL_TYPE_TEXT: - for( i = 0; i < string.DataLength; i++ ) - printf( "%c", string.Data[i] ); - break; - default: - printf("Invalid string data type=%u", string.DataType ); - } -} - - static SaErrorT get_fan_speed( SaHpiSessionIdT session_id, SaHpiResourceIdT resource_id, @@ -92,6 +50,8 @@ { SaHpiCtrlStateT state; + if (copt.debug) printf("get fan speed for resource %u, control %u\n", resource_id, ctrl_num); + SaErrorT rv = saHpiControlGet( session_id, resource_id, ctrl_num, mode, &state ); if ( rv != SA_OK ) { @@ -122,6 +82,7 @@ state.Type = SAHPI_CTRL_TYPE_ANALOG; state.StateUnion.Analog = speed; + if (copt.debug) printf("set fan speed for resource %u, control %u\n", resource_id, ctrl_num); rv = saHpiControlSet( session_id, resource_id, ctrl_num, mode, &state ); if ( rv != SA_OK ) { @@ -142,7 +103,7 @@ SaHpiCtrlModeT ctrl_mode; printf( "\tfan: num %u, id ", ctrl_rec->Num ); - display_textbuffer( rdr->IdString ); + oh_print_text ( &rdr->IdString ); printf( "\n" ); if ( ctrl_rec->Type != SAHPI_CTRL_TYPE_ANALOG ) { @@ -265,69 +226,58 @@ int main( int argc, char *argv[] ) { - int c; - int help = 0; SaErrorT rv; + SaHpiSessionIdT sessionid; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while( (c = getopt( argc, argv,"D:hs:") ) != -1 ) - switch( c ) { - case 'D': - if (optarg) domainid = atoi(optarg); - else { - printf("hpifan: option requires an argument -- D"); - help = 1; - } - break; - case 'h': - help = 1; - break; + context = g_option_context_new ("- Show \"Fan Control\" management instruments"); + g_option_context_add_main_entries (context, my_options, NULL); - case 's': - if (optarg) { - set_new = SAHPI_TRUE; - if ( strcmp( optarg, "auto" ) == 0 ) { - new_mode = SAHPI_CTRL_MODE_AUTO; - } else { - new_speed = atoi( optarg ); - } - } else { - printf("hpifan: option requires an argument -- s"); - help = 1; - } - break; - - default: - fprintf( stderr, "unknown option %s !\n", - argv[optind] ); - help = 1; - } - - if ( help ) - return usage(argv[0]); - - SaHpiSessionIdT sessionid; - rv = saHpiSessionOpen(domainid, &sessionid, NULL); - if ( rv != SA_OK ) { - printf( "saHpiSessionOpen: %s\n", oh_lookup_error( rv ) ); - return 1; + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); + } + + if (f_speed) { + set_new = SAHPI_TRUE; + if ( strcmp( f_speed, "auto" ) == 0 ) { + new_mode = SAHPI_CTRL_MODE_AUTO; + } else if ( strcmp( f_speed, "0" ) == 0 ) { + new_speed = 0; + } else { + new_speed = atoi( f_speed ); + if (new_speed == 0) { + g_print ("please enter a valid speed: \"auto\" or a number.\n"); + exit(1); + } + } } - if (domainid!=SAHPI_UNSPECIFIED_DOMAIN_ID) - printf("HPI Session to domain %u\n",domainid); + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); - rv = saHpiDiscover( sessionid ); - + /* + * Resource discovery + */ + if (copt.debug) printf("saHpiDiscover\n"); + rv = saHpiDiscover(sessionid); if ( rv != SA_OK ) { printf( "saHpiDiscover: %s\n", oh_lookup_error( rv ) ); return 1; } + if (copt.debug) printf("Discovery done\n"); int rc = discover_domain( sessionid ); rv = saHpiSessionClose( sessionid ); - if ( rv != SA_OK ) printf( "saHpiSessionClose: %s\n", oh_lookup_error( rv ) ); Modified: openhpi/trunk/clients/hpigensimdata.c =================================================================== --- openhpi/trunk/clients/hpigensimdata.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpigensimdata.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -2,6 +2,7 @@ * hpigensimdata.c * * Copyright (c) 2010 by Lars Wetzel + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,6 +13,7 @@ * * Authors: * Lars Wetzel (klw) <lar...@us...> + * Ulrich Kleber <uli...@us...> * * Changes: * 10/02/09 (klw) Release 0.9 @@ -24,20 +26,15 @@ * - maybe more selection criteria at the command line (eg. only sensor) * depends on user which needs this client for some other reasons * + * Changes: + * 01/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <ctype.h> -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision: 6571 $" -#define GEN_SIM_DATA_VERSION 0.901 +#define GEN_SIM_DATA_VERSION "0.901000" #define OFFSET_STEP 3 #define OFFSET_FILLER ' ' @@ -83,9 +80,19 @@ /* * Globals */ -int g_resource = FALSE; -int g_file = FALSE; +static gint g_resourceid = (gint) SAHPI_UNSPECIFIED_RESOURCE_ID; +static gchar *g_file = NULL; +static gchar *g_mode = NULL; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "resource", 'r', 0, G_OPTION_ARG_INT, &g_resourceid, "Select particular resource id for an update file", "res_id" }, + { "file", 'f', 0, G_OPTION_ARG_FILENAME, &g_file, "Name of the file to be generated", "filename" }, + { "mode", 'm', 0, G_OPTION_ARG_STRING, &g_mode, "Write update or initial file", "UPD|INIT" }, + { NULL } +}; + char offSet[MAX_OFFSETS][MAX_CHAR]; @@ -282,82 +289,53 @@ */ int main(int argc, char **argv) { SaErrorT rv = SA_OK; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT sessionid; - SaHpiResourceIdT resourceid = 0; - char filename[MAX_CHAR+1]; FILE *outfile = stdout; - int c; ConfigurationDataT confdata; - SaHpiBoolT printusage = FALSE; + GError *error = NULL; + GOptionContext *context; confdata.mode = MODE_INIT; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"xD:r:f:m:?")) != EOF ) { - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else printusage = TRUE; - break; - case 'r': - if (optarg) { - resourceid = atoi(optarg); - g_resource = TRUE; - } else { - fprintf(stderr, "\nResourceid is missing\n"); - printusage = TRUE; - } - break; - case 'm': - if (optarg) { - char tmpmode[MAX_SHORT_CHAR+1]; - int i = 0; - while (i < MAX_SHORT_CHAR || optarg[i] != '\0') { - tmpmode[i] = toupper((char) optarg[i]); - i++; - } - tmpmode[i] = '\0'; - if (!strcmp(tmpmode, "UPD")) { - confdata.mode = MODE_UPD; - } else if (!strcmp(tmpmode, "INIT")) { - confdata.mode = MODE_INIT; - } else { - fprintf(stderr, "\nUnknown mode %s.\n", tmpmode); - printusage = TRUE; - } - } - break; - case 'f': - g_file = 1; - if (optarg) { - strncpy(filename, optarg, MAX_CHAR); - filename[MAX_CHAR] = '\0'; - outfile = fopen(filename, "w"); - if (outfile == NULL) { - fprintf(stderr, "\n%s couldn't be opened for writing.\n", filename); - exit(1); - } - break; - } - default: printusage = TRUE; + context = g_option_context_new ("- Version " GEN_SIM_DATA_VERSION + "\nThe client will print all HPI information in a format that can be parsed by Dynamic" + "\nSimulator plugin."); + g_option_context_add_main_entries (context, my_options, NULL); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION // no verbose mode + - OHC_DEBUG_OPTION, // no debug mode + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); + } + + if (g_file) { + outfile = fopen(g_file, "w"); + if (outfile == NULL) { + fprintf(stderr, "\n%s couldn't be opened for writing.\n", g_file); + exit(1); } } - if (printusage == TRUE) - { - printf("\n %s - Version %.3f\n", argv[0], GEN_SIM_DATA_VERSION); - printf("\nThe client will print all HPI information. This information can be parsed by NewSimulator plugin."); - printf("\nTo spare some encoding/decoding function, values of enums are printed as int values instead of" - "encode them to ASCII values and decode them afterwards."); - printf("\nSince this client is primarily for the NewSimulator, the output functions don't depend on the" - "oh_.. - output function. Therefore they can be easily changed without influence on other clients."); - printf("\n\tUsage: %s [-option]\n\n", argv[0]); - printf("\t -D domain_id Select particular Domain\n"); - printf("\t -r res_id Select particular resource id for an update file\n"); - printf("\t -f filename Name of the file to be generated\n"); - printf("\t -m (UPD|INIT) Write update or initial file\n"); - printf("\n\n\n\n"); - exit(1); + + if (g_mode) { + int i = 0; + while (i < MAX_SHORT_CHAR && g_mode[i] != '\0') { + g_mode[i] = toupper((char) g_mode[i]); + i++; + } + if (!strcmp(g_mode, "UPD")) { + confdata.mode = MODE_UPD; + } else if (!strcmp(g_mode, "INIT")) { + confdata.mode = MODE_INIT; + } else { + fprintf(stderr, "\nUnknown mode %s.\n", g_mode); + exit (1); + } } /** @@ -373,11 +351,8 @@ print_header(outfile, 0, confdata); - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen returns %s\n",oh_lookup_error(rv)); - exit(-1); - } + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); /* * Resource discovery @@ -387,7 +362,7 @@ printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); exit(-1); } - print_resources(outfile, 0, sessionid, resourceid); + print_resources(outfile, 0, sessionid, (SaHpiResourceIdT) g_resourceid); rv = saHpiSessionClose(sessionid); if (g_file) fclose(outfile); @@ -411,7 +386,7 @@ fprintf(out, "%s%s {\n", offSet[myoffset++], CONF_SECTION); fprintf(out, "%sMODE=%s\n", offSet[myoffset], strMode); - fprintf(out, "%sVERSION=%f\n", offSet[myoffset], GEN_SIM_DATA_VERSION); + fprintf(out, "%sVERSION=%s\n", offSet[myoffset], GEN_SIM_DATA_VERSION); fprintf(out, "%s}\n", offSet[--myoffset]); } @@ -440,7 +415,8 @@ return rvRptGet; } - if ((g_resource == FALSE) || (resourceid == rptentry.ResourceId)) { + if ((resourceid == SAHPI_UNSPECIFIED_RESOURCE_ID) + || (resourceid == rptentry.ResourceId)) { fprintf(out, "%s%s {\n", offSet[myoffset], RPT_SECTION); myoffset++; Modified: openhpi/trunk/clients/hpiinv.c =================================================================== --- openhpi/trunk/clients/hpiinv.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpiinv.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -5,6 +5,7 @@ * Copyright (c) 2003-2005 by Intel Corp. * (C) Copyright IBM Corp. 2004 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,19 +28,12 @@ * 2/09/05 ARCress re-merged with hpifru.c, adding IdrFieldSet, * generalized for other HPI libraris also. * 09/06/10 ulikleber New option -D to select domain + * 20/01/11 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients */ #define OPENHPI_USED 1 -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> - #include "oh_clients.h" -#ifdef OPENHPI_USED -#include <oh_utils.h> -#endif #define OH_SVN_REV "$Revision$" @@ -54,16 +48,24 @@ "Buss Expansion Chassis", "Peripheral Chassis", "RAID Chassis", "Rack-Mount Chassis", "New" }; -int fasset = 0; -int fverbose = 0; -int foundasset = 0; -int fdebug = 0; -int fzdebug = 0; +static gchar *fatag = NULL; +static oHpiCommonOptionsT copt; + +static GOptionEntry my_options[] = +{ + { "asset-tag", 'a', 0, G_OPTION_ARG_STRING, &fatag, "Set the asset tag to the specified string", "tag" }, + { NULL } +}; + + + + int i,j,k = 0; SaHpiUint32T buffersize; SaHpiUint32T actualsize; char inbuff[2048]; char outbuff[1024]; +int foundasset = 0; SaHpiIdrAreaHeaderT *inv; SaHpiIdrFieldTypeT chasstype; SaHpiTextBufferT *strptr; @@ -175,7 +177,7 @@ if (datalen != 0) { strncpy ((char *)outstr, (char *)strptr->Data, datalen); outstr[datalen] = 0; - if (fdebug) { + if (copt.debug) { printf("TextBuffer len=%u, dtype=%x lang=%u: %s\n", strptr->DataLength,strptr->DataType,strptr->Language, strptr->Data ); @@ -293,7 +295,7 @@ char *pstr; #ifdef OPENHPI_USED - if (fverbose) { + if (copt.verbose) { oh_print_ep(epath, len); } else #endif @@ -320,11 +322,11 @@ static void print_idrinfo(SaHpiIdrInfoT *idrInfo,int len) { #ifdef OPENHPI_USED - if (fverbose) { + if (copt.verbose) { oh_print_idrinfo(idrInfo, len); } else #endif - { /* don't need to show this if not fverbose */ + { /* don't need to show this if not verbose */ } } @@ -333,7 +335,7 @@ { int i; #ifdef OPENHPI_USED - if (fverbose) { + if (copt.verbose) { oh_print_idrareaheader(areaHeader, len); } else #endif @@ -354,7 +356,7 @@ int i; #ifdef OPENHPI_USED - if (fverbose) { + if (copt.verbose) { oh_print_idrfield(field, len); } else #endif @@ -418,7 +420,7 @@ areaHeader.AreaId, fieldType, fieldId, &nextFieldId, &thisField); - if (fdebug) + if (copt.debug) printf("saHpiIdrFieldGet[%x] rv = %d type=%u\n", idrInfo->IdrId,rvField, thisField.Type); @@ -457,9 +459,7 @@ int main(int argc, char **argv) { - int c; SaErrorT rv,rv_rdr; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT sessionid; SaHpiDomainInfoT rptinfo; SaHpiRptEntryT rptentry; @@ -473,58 +473,38 @@ SaHpiIdrIdT idrid; int invfound = 0; int nloops = 0; - SaHpiBoolT printusage = FALSE; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); atag.tlen = 0; - while ( (c = getopt( argc, argv,"D:a:vxz?")) != EOF ) - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else printusage = TRUE; - break; - case 'z': fzdebug = 1; /* fall thru to include next setting */ - case 'x': fdebug = 1; break; - case 'v': fverbose = 1; break; - case 'a': - fasset = 1; - if (optarg) { - atag.tag = (char *)strdup(optarg); - atag.tlen = strlen(optarg); - } - else printusage = TRUE; - break; - default: printusage = TRUE; + context = g_option_context_new ("- Shows resources' inventory records"); + g_option_context_add_main_entries (context, my_options, NULL); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); } - if (printusage) { - printf("Usage: %s [-x] [-a asset_tag]\n", argv[0]); - printf(" -D domainid Selects the domain\n"); - printf(" -a tag Sets the asset tag\n"); - printf(" -v Use verbose output mode\n"); - printf(" -x Display debug messages\n"); - printf(" -z Display extra debug messages\n"); - exit(1); + if (fatag) { + atag.tag = (char *)strdup(fatag); + atag.tlen = strlen(fatag); } /* compile error */ // inv = (SaHpiIdrAreaHeaderT *)&inbuff[0]; inv = (SaHpiIdrAreaHeaderT *)(void *)&inbuff[0]; - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (fdebug) printf("saHpiSessionOpen rv = %d sessionid = %u\n",rv,sessionid); - if (rv != SA_OK) { - printf("saHpiSessionOpen error %d\n",rv); - exit(-1); - } - + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); + rv = saHpiDomainInfoGet(sessionid,&rptinfo); - if (fdebug) printf("saHpiDomainInfoGet rv = %d\n",rv); - // if (fdebug) printf("RptInfo: UpdateCount = %x, UpdateTime = %lx\n", + if (copt.debug) printf("saHpiDomainInfoGet rv = %d\n",rv); + // if (copt.debug) printf("RptInfo: UpdateCount = %x, UpdateTime = %lx\n", // rptinfo.UpdateCount, (unsigned long)rptinfo.UpdateTimestamp); while (!invfound && (nloops < 7)) @@ -535,9 +515,9 @@ * This should not apply to other well-behaved plugins. */ nloops++; - if (fdebug) printf("Starting Discovery, pass %u ...\n",nloops); + if (copt.debug) printf("Starting Discovery, pass %u ...\n",nloops); rv = saHpiDiscover(sessionid); - if (fdebug) printf("saHpiDiscover rv = %d\n",rv); + if (copt.debug) printf("saHpiDiscover rv = %d\n",rv); if (rv != SA_OK) { printf("saHpiDiscover error %d\n",rv); break; @@ -558,7 +538,7 @@ /* walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; resourceid = rptentry.ResourceId; - if (fdebug) printf("rptentry[%u] resourceid=%d\n", rptentryid,resourceid); + if (copt.debug) printf("rptentry[%u] resourceid=%d\n", rptentryid,resourceid); if (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_INVENTORY_DATA) { printf("Resource[%u] Tag: %s \thas inventory capability\n", rptentryid,tagstr); @@ -566,10 +546,10 @@ while ((rv_rdr == SA_OK) && (entryid != SAHPI_LAST_ENTRY)) { rv_rdr = saHpiRdrGet(sessionid,resourceid, entryid,&nextentryid, &rdr); - if (fdebug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv_rdr); + if (copt.debug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv_rdr); if (rv_rdr == SA_OK) { - if (fdebug) printf("Rdr[%u] type = %u tag = %s\n",entryid, + if (copt.debug) printf("Rdr[%u] type = %u tag = %s\n",entryid, rdr.RdrType,rdr.IdString.Data); if (rdr.RdrType == SAHPI_INVENTORY_RDR) { @@ -578,7 +558,7 @@ rdr.IdString.Data[rdr.IdString.DataLength] = 0; idrid = rdr.RdrTypeUnion.InventoryRec.IdrId; buffersize = sizeof(inbuff); - if (fdebug) { + if (copt.debug) { printf("Rdr[%x] is inventory, IdrId=%x\n",rdr.RecordId,idrid); printf("Inv BufferSize=%u\n", buffersize); } @@ -590,18 +570,18 @@ if (rv_rdr != SA_OK) { printf("IDR Info error: rv_rdr = %d\n",rv_rdr); } else { /* idrInfo is ok */ - if (fdebug) printf("IDR Info: ok \n"); + if (copt.debug) printf("IDR Info: ok \n"); print_epath(&rptentry.ResourceEntity, 1); printf("RDR[%x]: Inventory, IdrId=%x %s\n",rdr.RecordId, idrid,rdr.IdString.Data); print_idrinfo(&idrInfo,4); rv_rdr = walkInventory(sessionid, resourceid, &idrInfo); - if (fdebug) printf("walkInventory rv_rdr = %d\n",rv_rdr); + if (copt.debug) printf("walkInventory rv_rdr = %d\n",rv_rdr); } if (!ent_writable(&rptentry.ResourceEntity,&idrInfo)) foundasset = 0; - if ((fasset == 1) && (foundasset == 1)) { + if ((fatag) && (foundasset == 1)) { SaHpiIdrFieldT atagField; atagField.Type = SAHPI_IDR_FIELDTYPE_ASSET_TAG; atagField.ReadOnly = SAHPI_FALSE; @@ -620,22 +600,22 @@ if (rv_rdr == SA_OK) { printf ("Good write - re-reading!\n"); rv_rdr = walkInventory(sessionid, resourceid, &idrInfo); - if (fdebug) printf("walkInventory rv_rdr = %d\n",rv_rdr); + if (copt.debug) printf("walkInventory rv_rdr = %d\n",rv_rdr); } /* Good write - re-read */ - } /*endif fasset*/ + } /*endif foundasset*/ } /*endif RDR tag ok*/ } /* Inventory Data Records - Type 3 */ - else if (fdebug) printf("rdr type = %u\n", rdr.RdrType); + else if (copt.debug) printf("rdr type = %u\n", rdr.RdrType); } /*endif RdrGet ok*/ entryid = nextentryid; } /*end while rdr*/ } /*endif rpt invent capab*/ else - if (fdebug) printf("Resource[%u] Tag: %s\n", rptentryid,tagstr); + if (copt.debug) printf("Resource[%u] Tag: %s\n", rptentryid,tagstr); } /*endif rpt ok*/ rptentryid = nextrptentryid; } /*end rpt loop */ - if (fdebug) printf("loop %u inventory found = %d\n",nloops,invfound); + if (copt.debug) printf("loop %u inventory found = %d\n",nloops,invfound); } /*end while no inv */ rv = saHpiSessionClose(sessionid); exit(0); Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpionIBMblade.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -2,6 +2,8 @@ * * Copyright (c) 2003 by Intel Corp. * 2006 by IBM Corp. + * (C) Copyright Ulrich Kleber 2011 + * * 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 @@ -57,19 +59,11 @@ * 10/13/2006 pdphan Copy from kouzmich's hpithres.c to hpionIBMblade.c * Add functions specifically for * an IBM blade with Baseboard Management Controller (BMC) + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients, + * e.g. --domain and --host */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> - -#include <glib.h> - -#include <SaHpi.h> -#include <oh_utils.h> -#include <oHpi.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision: 6412 $" @@ -138,8 +132,7 @@ int nrpts = 0; long int blade_slot = 0; -int fdebug = 0; - +static oHpiCommonOptionsT copt; SaHpiSessionIdT sessionid; static void *resize_array(void *Ar, int item_size, int *last_num, int add_num) @@ -232,13 +225,13 @@ Rpt->Rpt.ResourceId, &this_handler_id); if (rv) { - if (fdebug) printf("oHpiHandlerFind returns %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("oHpiHandlerFind returns %s\n", oh_lookup_error(rv)); return(0); } rv = oHpiHandlerInfo(sessionid, this_handler_id, &handler_info, config); if (rv) { - if (fdebug) printf("oHpiHandlerInfo returns %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("oHpiHandlerInfo returns %s\n", oh_lookup_error(rv)); return(0); } @@ -588,7 +581,7 @@ NULL, NULL, NULL); if (rv == SA_OK) break; - if (fdebug) printf("sleep before saHpiEventGet\n"); + if (copt.debug) printf("sleep before saHpiEventGet\n"); g_usleep(G_USEC_PER_SEC); }; saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, @@ -898,39 +891,41 @@ int main(int argc, char **argv) { - int c, i; + int i; SaErrorT rv; char buf[READ_BUF_SIZE]; char *S; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"x?")) != EOF ) - switch(c) { - case 'x': - fdebug = 1; - break; - default: - printf("Usage: %s [-x]\n", argv[0]); - printf(" -x Display debug messages\n"); - return(1); - } + context = g_option_context_new ("- Shows how to use two (2) openhpi " + "plugins to display and manage resources of an IBM Blade " + "with Basedboard Management Controller (BMC)"); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION // not implemented + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); + } + rv = hpiIBMspecial_find_blade_slot(); if (rv != SA_OK) { printf("ipmitool can not find slot number in which this blade resides.\n"); return(-1); } - rv = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sessionid, NULL); + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); - if (rv != SA_OK) { - printf("saHpiSessionOpen: %s\n", oh_lookup_error(rv)); - return(-1); - } - rv = saHpiDiscover(sessionid); - if (fdebug) printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); rv = saHpiSubscribe(sessionid); if (rv != SA_OK) { @@ -954,4 +949,4 @@ rv = saHpiSessionClose(sessionid); return(0); } - /* end hpthres.c */ + /* end hpionIBMblade.c */ Modified: openhpi/trunk/clients/hpipower.c =================================================================== --- openhpi/trunk/clients/hpipower.c 2011-02-01 16:12:21 UTC (rev 7264) +++ openhpi/trunk/clients/hpipower.c 2011-02-02 09:41:18 UTC (rev 7265) @@ -2,6 +2,7 @@ * * (C) Copyright IBM Corp. 2004-2006 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,22 +17,16 @@ * * Changes: * 09/06/2010 ulikleber New option -D to select domain + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" #define MAX_MANAGED_SYSTEMS 80 -#define HPI_POWER_DEBUG_PRINT(a) if(DebugPrints==TRUE)printf(a) +#define HPI_POWER_DEBUG_PRINT(a) if(copt.debug==TRUE)printf(a) typedef struct COMPUTER_DATA_ { @@ -42,7 +37,24 @@ char NameStr[80];//Text Name for the computer or plade } COMPUTER_DATA; +static gboolean f_down = FALSE; +static gboolean f_up = FALSE; +static gboolean f_reset = FALSE; +static gboolean f_unattended = FALSE; +static gint f_blade = 0; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "power-down", 'd', 0, G_OPTION_ARG_NONE, &f_down, "Power down target object", NULL }, + { "power-up", 'p', 0, G_OPTION_ARG_NONE, &f_up, "Power on target object", NULL }, + { "reset", 'r', 0, G_OPTION_ARG_NONE, &f_reset, "Reset target object", NULL }, + { "unattended", 'u', 0, G_OPTION_ARG_NONE, &f_unattended, "Unattended", NULL }, + { "blade", 'b', 0, G_OPTION_ARG_INT, &f_blade, "Specify blade n (1...n)", "n" }, + { NULL } +}; + + /* Utility function to work with SaHpiTextBufferT */ static void HpiTextBuffer2CString( const SaHpiTextBufferT * tb, char * cstr ) { @@ -61,126 +73,76 @@ * main * * Hpi Power Utility Entry point routine - * - * Parameters: - * int - argc, - * char pointer pointer - argv - * Program Command line Arguments: - * 'd' power down - * 'p' power up - * 'r' hard reset - * 'u' unattended - * 'b:n' Blade number - * '?' useage - help - * 'x' debug messages - * Reserved Platform Specific for future use: - * 'c' 'o' 'n' 's' ************************************************/ int main(int argc, char **argv) { - SaHpiInt32T ComputerNumber; //0..n-1 - SaHpiInt32T SelectedSystem; //0..n-1 - SaHpiPowerStateT Action; + SaHpiInt32T ComputerNumber = 0; //0..n-1 + SaHpiInt32T SelectedSystem = 0; //0..n-1 + SaHpiPowerStateT Action = 255; //set it out of range to stand for status; COMPUTER_DATA *ComputerPtr; - SaHpiBoolT BladeSelected; - SaHpiBoolT MultipleBlades; - SaHpiBoolT ActionSelected; - SaHpiBoolT PrintUsage; - SaHpiBoolT DebugPrints; + SaHpiBoolT BladeSelected = FALSE; + SaHpiBoolT MultipleBlades = FALSE; + SaHpiBoolT ActionSelected = FALSE; GSList* Computer; GSList* ComputerListHead; - int option; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT SessionId; SaErrorT Status; - SaHpiEntryIdT RptEntry, RptNextEntry; + SaHpiEntryIdT RptEntry = SAHPI_FIRST_ENTRY; + SaHpiEntryIdT RptNextEntry; SaHpiRptEntryT Report; SaHpiInt32T Index, EntityElement; - SaHpiPowerStateT PowerState; + SaHpiPowerStateT PowerState; char PowerStateString[3][7]={"off\0","on\0","cycled\0"}; + GError *error = NULL; + GOptionContext *context; /* // Print out the Program name and Version */ oh_prog_version(argv[0], OH_SVN_REV); - /* Set Program Defaults */ - ComputerNumber = 0; - SelectedSystem = 0; - Action = 255; //set it out of range to stand for status - BladeSelected = FALSE; - MultipleBlades = FALSE; - ActionSelected = FALSE; - PrintUsage = FALSE; - DebugPrints = FALSE; - RptEntry = SAHPI_FIRST_ENTRY; /* Parse out option instructions */ - while (1) - { - option = getopt(argc, argv, "D:dpruxb:"); - if ((option == EOF) || (PrintUsage == TRUE)) - { - break; //break out of the while loop - } + context = g_option_context_new ("- Exercise HPI Power Management APIs"); + g_option_context_add_main_entries (context, my_options, NULL); - switch (option) - { - case 'D': - if (optarg) domainid = atoi(optarg); - else { - printf("hpipower: option requires an argument -- D"); - PrintUsage = TRUE; - } - break; - case 'd': - Action = SAHPI_POWER_OFF; - ActionSelected = TRUE; - break; - case 'p': - Action = SAHPI_POWER_ON; - ActionSelected = TRUE; - break; - case 'r': - Action = SAHPI_POWER_CYCLE; - ActionSelected = TRUE; - break; - case 'u': - BladeSelected = TRUE; - ActionSelected = TRUE; - break; - case 'x': - DebugPrints = TRUE; - break; - case 'b': - if (*optarg == 0) - { - printf("hpipower: option requires an argument -- b"); - PrintUsage = TRUE; - break; //no argument - } - SelectedSystem = atoi(optarg) - 1; //Normalizing to 0...n-1 - if ((SelectedSystem > MAX_MANAGED_SYSTEMS) || - (SelectedSystem < 0)) - { - //Argument is out of Range - PrintUsage = TRUE; - } - BladeSelected = TRUE; - break; - default: - PrintUsage = TRUE; - break; - } //end of switch statement - } //end of argument parsing while loop - - if (PrintUsage == TRUE) - { - UsageMessage(argv[0]); - exit(1); //When we exit here, there is nothing to clean up + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); + } + if (f_down) { + Action = SAHPI_POWER_OFF; + ActionSelected = TRUE; + } + if (f_up) { + Action = SAHPI_POWER_ON; + ActionSelected = TRUE; + } + if (f_reset) { + Action = SAHPI_POWER_CYCLE; + ActionSelected = TRUE; + } + if (f_unattended) { + BladeSelected = TRUE; + ActionSelected = TRUE; + } + if (f_blade > 0) { + BladeSelected = TRUE; + SelectedSystem = f_blade - 1; //Normalizing to 0...n-1 + if ((SelectedSystem > MAX_MANAGED_SYSTEMS) || + (SelectedSystem < 0)) { + printf("hpipower: blade number out of r... [truncated message content] |
From: <av...@us...> - 2011-02-02 12:34:06
|
Revision: 7266 http://openhpi.svn.sourceforge.net/openhpi/?rev=7266&view=rev Author: avpak Date: 2011-02-02 12:33:59 +0000 (Wed, 02 Feb 2011) Log Message: ----------- Feature request #3095642 Modified Paths: -------------- openhpi/trunk/baselib/session.cpp openhpi/trunk/transport/strmsock.cpp Modified: openhpi/trunk/baselib/session.cpp =================================================================== --- openhpi/trunk/baselib/session.cpp 2011-02-02 09:41:18 UTC (rev 7265) +++ openhpi/trunk/baselib/session.cpp 2011-02-02 12:33:59 UTC (rev 7266) @@ -65,6 +65,9 @@ private: + static const size_t RPC_ATTEMPTS = 2; + static const gulong NEXT_RPC_ATTEMPT_TIMEOUT = 2 * G_USEC_PER_SEC; + // data SaHpiDomainIdT m_did; SaHpiSessionIdT m_remote_sid; @@ -120,12 +123,6 @@ return SA_ERR_HPI_UNSUPPORTED_API; } - cClientStreamSock * sock; - rv = GetSock( sock ); - if ( rv != SA_OK ) { - return rv; - } - char data[dMaxPayloadLength]; uint32_t data_len; uint8_t rp_type; @@ -133,14 +130,33 @@ int rp_byte_order; data_len = HpiMarshalRequest( hm, data, iparams.const_array ); - bool rc = sock->WriteMsg( eMhMsg, id, data, data_len ); - if ( rc ) { - rc = sock->ReadMsg( rp_type, rp_id, data, data_len, rp_byte_order ); + + bool rc = false; + for ( size_t attempt = 0; attempt < RPC_ATTEMPTS; ++attempt ) { + if ( attempt > 0 ) { + DBG( "Session: RPC request %u, Attempt %u\n", id, (unsigned int)attempt ); + } + cClientStreamSock * sock; + rv = GetSock( sock ); + if ( rv != SA_OK ) { + return rv; + } + + rc = sock->WriteMsg( eMhMsg, id, data, data_len ); + if ( rc ) { + rc = sock->ReadMsg( rp_type, rp_id, data, data_len, rp_byte_order ); + if ( rc ) { + break; + } + } + + g_static_private_set( &m_sockets, 0, 0 ); // close socket + g_usleep( NEXT_RPC_ATTEMPT_TIMEOUT ); } if ( !rc ) { - g_static_private_set( &m_sockets, 0, 0 ); // close socket return SA_ERR_HPI_NO_RESPONSE; } + oparams.SetFirst( &rv ); int mr = HpiDemarshalReply( rp_byte_order, hm, data, oparams.array ); Modified: openhpi/trunk/transport/strmsock.cpp =================================================================== --- openhpi/trunk/transport/strmsock.cpp 2011-02-02 09:41:18 UTC (rev 7265) +++ openhpi/trunk/transport/strmsock.cpp 2011-02-02 12:33:59 UTC (rev 7266) @@ -84,7 +84,7 @@ struct addrinfo * items; int cc = getaddrinfo( node, service, &hints, &items ); if ( cc != 0 ) { - CRIT( "Transport: getaddrinfo failed." ); + CRIT( "getaddrinfo failed." ); return; } @@ -152,10 +152,10 @@ while ( got < need ) { ssize_t len = recv( m_sockfd, dst + got, need - got, 0 ); if ( len < 0 ) { - CRIT( "Transport: error while reading message." ); + CRIT( "error while reading message." ); return false; } else if ( len == 0 ) { - CRIT( "Transport: peer closed connection." ); + CRIT( "peer closed connection." ); return false; } got += len; @@ -164,7 +164,7 @@ // we got header uint8_t ver = hdr.flags >> 4; if ( ver != dMhRpcVersion ) { - CRIT( "Transport: unsupported version 0x%x != 0x%x.", + CRIT( "unsupported version 0x%x != 0x%x.", ver, dMhRpcVersion ); return false; @@ -222,7 +222,7 @@ return false; } if ( payload_len > dMaxPayloadLength ) { - CRIT("Transport: message payload too large."); + CRIT("message payload too large."); return false; } @@ -260,7 +260,7 @@ ssize_t cc = send( m_sockfd, &msg[0], msg_len, 0 ); if ( cc != (ssize_t)msg_len ) { - CRIT( "Transport: error while sending message." ); + CRIT( "error while sending message." ); return false; } @@ -277,7 +277,7 @@ SockFdT new_sock; new_sock = socket( info->ai_family, info->ai_socktype, info->ai_protocol ); if ( new_sock == InvalidSockFd ) { - CRIT( "Transport: cannot create stream socket." ); + CRIT( "cannot create stream socket." ); return false; } @@ -299,7 +299,7 @@ cc = close( m_sockfd ); #endif if ( cc != 0 ) { - CRIT( "Transport: cannot close stream socket." ); + CRIT( "cannot close stream socket." ); return false; } @@ -328,7 +328,7 @@ struct addrinfo * infos; SelectAddresses( 0, host, port, infos ); if ( infos == 0 ) { - CRIT( "Transport: failed to find sockaddr." ); + CRIT( "failed to find sockaddr." ); return false; } @@ -357,25 +357,25 @@ val = 1; rc = setsockopt( SockFd(), SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val) ); if ( rc != 0 ) { - CRIT( "Transport: failed to set SO_KEEPALIVE option." ); + CRIT( "failed to set SO_KEEPALIVE option." ); return false; } val = keepalive_time; rc = setsockopt( SockFd(), SOL_TCP, TCP_KEEPIDLE, &val, sizeof(val) ); if ( rc != 0 ) { - CRIT( "Transport: failed to set TCP_KEEPIDLE option." ); + CRIT( "failed to set TCP_KEEPIDLE option." ); return false; } val = keepalive_intvl; rc = setsockopt( SockFd(), SOL_TCP, TCP_KEEPINTVL, &val, sizeof(val) ); if ( rc != 0 ) { - CRIT( "Transport: failed to set TCP_KEEPINTVL option." ); + CRIT( "failed to set TCP_KEEPINTVL option." ); return false; } val = keepalive_probes; rc = setsockopt( SockFd(), SOL_TCP, TCP_KEEPCNT, &val, sizeof(val) ); if ( rc != 0 ) { - CRIT( "Transport: failed to set TCP_KEEPCNT option." ); + CRIT( "failed to set TCP_KEEPCNT option." ); return false; } @@ -383,7 +383,7 @@ #else - CRIT( "Transport: TCP Keep-Alive Probes are not supported." ); + CRIT( "TCP Keep-Alive Probes are not supported." ); return false; @@ -400,7 +400,7 @@ int cc = connect( SockFd(), info->ai_addr, info->ai_addrlen ); if ( cc != 0 ) { Close(); - CRIT( "Transport: connect failed." ); + CRIT( "connect failed." ); return false; } @@ -427,7 +427,7 @@ struct addrinfo * infos; SelectAddresses( AI_PASSIVE, 0, port, infos ); if ( infos == 0 ) { - CRIT( "Transport: failed to find sockaddr." ); + CRIT( "failed to find sockaddr." ); return false; } @@ -469,19 +469,19 @@ #endif if ( cc != 0 ) { Close(); - CRIT( "Transport: failed to set SO_REUSEADDR option." ); + CRIT( "failed to set SO_REUSEADDR option." ); return false; } cc = bind( SockFd(), info->ai_addr, info->ai_addrlen ); if ( cc != 0 ) { Close(); - CRIT( "Transport: bind failed." ); + CRIT( "bind failed." ); return false; } cc = listen( SockFd(), 5 /* TODO */ ); if ( cc != 0 ) { Close(); - CRIT( "Transport: listen failed." ); + CRIT( "listen failed." ); return false; } @@ -492,7 +492,7 @@ { SockFdT sock = accept( SockFd(), 0, 0 ); if ( sock == InvalidSockFd ) { - CRIT( "Transport: accept failed." ); + CRIT( "accept failed." ); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-02-02 14:51:35
|
Revision: 7267 http://openhpi.svn.sourceforge.net/openhpi/?rev=7267&view=rev Author: ulikleber Date: 2011-02-02 14:51:27 +0000 (Wed, 02 Feb 2011) Log Message: ----------- more on 1493787 Update clients to use long options and uniform format clients hpisensor, hpisettime, hpithres and some fixes (warnings removed, typos) Modified Paths: -------------- openhpi/trunk/clients/hpireset.c openhpi/trunk/clients/hpisensor.c openhpi/trunk/clients/hpisettime.c openhpi/trunk/clients/hpithres.c openhpi/trunk/docs/man/hpialarms.pod.1 openhpi/trunk/docs/man/hpiel.pod.1 openhpi/trunk/docs/man/hpievents.pod.1 openhpi/trunk/docs/man/hpifan.pod.1 openhpi/trunk/docs/man/hpiinv.pod.1 openhpi/trunk/docs/man/hpionIBMblade.pod.1 openhpi/trunk/docs/man/hpipower.pod.1 openhpi/trunk/docs/man/hpisensor.pod.1 openhpi/trunk/docs/man/hpisettime.pod.1 openhpi/trunk/docs/man/hpithres.pod.1 openhpi/trunk/docs/man/hpitop.pod.1 openhpi/trunk/docs/man/hpitree.pod.1 Modified: openhpi/trunk/clients/hpireset.c =================================================================== --- openhpi/trunk/clients/hpireset.c 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/clients/hpireset.c 2011-02-02 14:51:27 UTC (rev 7267) @@ -30,7 +30,6 @@ #define uchar unsigned char static gboolean f_hard = TRUE; // hard reset as default static gboolean f_warm = FALSE; -static gint resourceid = 0; static oHpiCommonOptionsT copt; static GOptionEntry my_options[] = @@ -48,7 +47,6 @@ int main(int argc, char **argv) { - int c; int is_reset = 0; SaErrorT rv; SaHpiSessionIdT sessionid; Modified: openhpi/trunk/clients/hpisensor.c =================================================================== --- openhpi/trunk/clients/hpisensor.c 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/clients/hpisensor.c 2011-02-02 14:51:27 UTC (rev 7267) @@ -3,6 +3,7 @@ * Copyright (c) 2003 by Intel Corp. * (C) Copyright IBM Corp. 2004 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,25 +21,27 @@ * 09/08/04 pd...@us... Add sensor number to the display. * 01/06/05 arcress reduce number of display lines per sensor * 09/06/10 ulikleber New option -D to select domain + * 02/02/11 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients */ -#include <stdio.h> -#include <stdlib.h> -#include <getopt.h> -#include <string.h> - -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" -int fdebug = 0; -int fshowthr = 0; -int fshowrange = 0; -int fshowstate = 0; +static gboolean fshowthr = FALSE; +static gboolean fshowrange = FALSE; +static gboolean fshowstate = FALSE; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "threshold", 't', 0, G_OPTION_ARG_NONE, &fshowthr, "Show Thresholds also", NULL }, + { "range", 'r', 0, G_OPTION_ARG_NONE, &fshowrange, "Show Range values also", NULL }, + { "eventstate", 's', 0, G_OPTION_ARG_NONE, &fshowstate, "Show EventState also", NULL }, + { NULL } +}; + static void ShowSensor(SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiSensorRecT *sensorrec ) @@ -200,10 +203,7 @@ int main(int argc, char **argv) { - int c; - char *ep_string = NULL; SaErrorT rv; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiDomainInfoT dinfo; SaHpiSessionIdT sessionid; SaHpiRptEntryT rptentry; @@ -213,59 +213,34 @@ SaHpiEntryIdT nextentryid; SaHpiResourceIdT resourceid; SaHpiRdrT rdr; - SaHpiEntityPathT ep_target; - SaHpiBoolT printusage = FALSE; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:rtse:x?")) != EOF ) - switch(c) { - case 'D': if (optarg) domainid = atoi(optarg); - else printusage = TRUE; - break; - case 't': fshowthr = 1; break; - case 'r': fshowrange = 1; break; - case 's': fshowstate = 1; break; - case 'x': fdebug = 1; break; - case 'e': - if (optarg) { - ep_string = (char *)strdup(optarg); - } - else printusage = TRUE; - oh_encode_entitypath(ep_string, &ep_target); - break; - default: printusage = TRUE; - } + context = g_option_context_new ("- Display sensor info for resources with Sensor Capability"); + g_option_context_add_main_entries (context, my_options, NULL); - if (printusage) { - printf("Usage %s [-D -t -r -s -x -e]\n", argv[0]); - printf("where -D id = select domain\n"); - printf(" -t = show Thresholds also\n"); - printf(" -r = show Range values also\n"); - printf(" -s = show EventState also\n"); - printf(" -e entity path = limit to a single entity\n"); - printf(" -x = show eXtra debug messages\n"); - exit(1); - } - - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen: %s\n", oh_lookup_error(rv)); - exit(-1); - } + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); + } + + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); + - if (fdebug) printf("Starting Discovery ...\n"); + if (copt.debug) printf("Starting Discovery ...\n"); rv = saHpiDiscover(sessionid); - if (fdebug) printf("saHpiResourcesDiscover %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiResourcesDiscover %s\n", oh_lookup_error(rv)); - rv = saHpiDomainInfoGet(sessionid,&dinfo); - if (fdebug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); printf("RptInfo: UpdateCount = %u, UpdateTime = %lx\n", dinfo.RptUpdateCount, (unsigned long)dinfo.RptUpdateTimestamp); @@ -275,13 +250,14 @@ while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if (fdebug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); if (rv == SA_OK) { /* Walk the RDR list for this RPT entry */ /* Filter by entity path if specified */ - if (ep_string && !oh_cmp_ep(&ep_target,&(rptentry.ResourceEntity))) { + if (copt.withentitypath && + !oh_cmp_ep(&copt.entitypath, &(rptentry.ResourceEntity))) { rptentryid = nextrptentryid; continue; } @@ -296,7 +272,7 @@ { rv = saHpiRdrGet(sessionid,resourceid, entryid,&nextentryid, &rdr); - if (fdebug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv); + if (copt.debug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv); if (rv == SA_OK) { rdr.IdString.Data[rdr.IdString.DataLength] = 0; if (rdr.RdrType == SAHPI_SENSOR_RDR) { Modified: openhpi/trunk/clients/hpisettime.c =================================================================== --- openhpi/trunk/clients/hpisettime.c 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/clients/hpisettime.c 2011-02-02 14:51:27 UTC (rev 7267) @@ -3,6 +3,7 @@ * * (C) Copyright IBM Corp 2003,2004 * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * Authors: * Peter D.Phan pd...@us... @@ -15,6 +16,8 @@ * check month, day, year, hours, minutes and seconds * for correctness * 07/06/2010 ulikleber New option -D to select domain + * 20/01/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients */ /* Redistribution and use in source and binary forms, with or without @@ -41,117 +44,73 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <stdio.h> -#include <stdlib.h> -#include <getopt.h> -#include <string.h> -#include <time.h> - -#include <SaHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" -int fdebug = 0; -int findate = 0; -int fintime = 0; +static gchar *findate = NULL; +static gchar *fintime = NULL; +static oHpiCommonOptionsT copt; -static void usage(char **argv) +static GOptionEntry my_options[] = { - printf("Usage\n\t%s -d mm/dd/yyyy -t HH:MM:SS [-x]\n",argv[0]); - printf("\twhere -D domainid selects the domain\n"); - printf("\t -d date in mm/dd/yyyy format\n"); - printf("\t -t time of day in 24-hr format\n"); - printf("\t -x displays eXtra debug messages\n"); + { "date", 'd', 0, G_OPTION_ARG_STRING, &findate, "New date", "mm/dd/yyyy" }, + { "time", 't', 0, G_OPTION_ARG_STRING, &fintime, "New time of day in 24-hr format", "24:12:60" }, + { NULL } +}; - return; -} - int main(int argc, char **argv) { - int c, month, day, year; - char i_newdate[20]; - char i_newtime[20]; + int month, day, year; int day_array[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; struct tm new_tm_time; SaErrorT rv; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT sessionid; SaHpiDomainInfoT domainInfo; SaHpiRptEntryT rptentry; SaHpiEntryIdT rptentryid; SaHpiEntryIdT nextrptentryid; SaHpiResourceIdT resourceid; - // SaHpiEventLogEntryIdT entryid; SaHpiTimeT oldtime; SaHpiTimeT newtime; SaHpiTimeT readbacktime; SaHpiTextBufferT buffer; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:d:t:x")) != EOF ) - { - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else { - usage(argv); - exit(1); - } - break; - case 'd': - if (optarg) { - findate = 1; - strcpy(i_newdate, optarg); - } - else { - usage(argv); - exit(1); - } - break; - case 't': - if (optarg) { - fintime = 1; - strcpy(i_newtime, optarg); - } - else { - usage(argv); - exit(1); - } - break; - case 'x': - fdebug = 1; - break; - default: - usage(argv); - exit(1); - } + context = g_option_context_new ("- Exercises Event Log clock APIs."); + g_option_context_add_main_entries (context, my_options, NULL); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION // not applicable + - OHC_VERBOSE_OPTION, // no verbose mode + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); } - + if ( !findate || !fintime) { - usage(argv); + printf("Please enter date and time to be set.\n"); exit(1); } if (findate) { - if (fdebug) printf("New date to be set: %s\n",i_newdate); - if (sscanf(i_newdate,"%2d/%2d/%4d", &month, &day, &year) != 3) { + if (copt.debug) printf("New date to be set: %s\n",findate); + if (sscanf(findate,"%2d/%2d/%4d", &month, &day, &year) != 3) { printf("%s: Invalid date\n", argv[0]); - usage(argv); exit(1); } /* check month, day and year for correctness */ if ((month < 1) || (month > 12)) { printf("%s: Month out of range: (%d)\n", argv[0], month); - usage(argv); exit(1); }; if (year < 1900) { printf("%s: Year out of range: (%d)\n", argv[0], year); - usage(argv); exit(1); }; month--; @@ -162,7 +121,6 @@ }; if ((day < 1) || (day > day_array[month])) { printf("%s: Day out of range: (%d)\n", argv[0], day); - usage(argv); exit(1); }; @@ -172,55 +130,43 @@ } if (fintime) { - if (fdebug) printf("New time to be set: %s\n",i_newtime); - if (sscanf(i_newtime,"%2d:%2d:%2d", + if (copt.debug) printf("New time to be set: %s\n",fintime); + if (sscanf(fintime,"%2d:%2d:%2d", &new_tm_time.tm_hour, &new_tm_time.tm_min, &new_tm_time.tm_sec) != 3) { printf("%s: Invalid time\n", argv[0]); - usage(argv); exit(1); } /* check hours, minutes and seconds for correctness */ if ((new_tm_time.tm_hour < 0) || (new_tm_time.tm_hour > 24)) { printf("%s: Hours out of range: (%d)\n", argv[0], new_tm_time.tm_hour); - usage(argv); exit(1); }; if ((new_tm_time.tm_min < 0) || (new_tm_time.tm_min > 60)) { printf("%s: Minutes out of range: (%d)\n", argv[0], new_tm_time.tm_min); - usage(argv); exit(1); }; if ((new_tm_time.tm_sec < 0) || (new_tm_time.tm_sec > 60)) { printf("%s: Seconds out of range: (%d)\n", argv[0], new_tm_time.tm_sec); - usage(argv); exit(1); } } - if (fdebug) printf("Values passed to mktime():\n\tmon %d\n\tday %d\n\tyear %d\n\tHH %d\n\tMM %d\n\tSS %d\n", + if (copt.debug) printf("Values passed to mktime():\n\tmon %d\n\tday %d\n\tyear %d\n\tHH %d\n\tMM %d\n\tSS %d\n", new_tm_time.tm_mon, new_tm_time.tm_mday, new_tm_time.tm_year, new_tm_time.tm_hour, new_tm_time.tm_min, new_tm_time.tm_sec); newtime = (SaHpiTimeT) mktime(&new_tm_time) * 1000000000; - if (fdebug) { - printf("New date and time in SaHpiTimeT %" PRId64 "\n\n", (int64_t)newtime); - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - if (rv == SA_ERR_HPI_ERROR) - printf("saHpiSessionOpen: error %d, SpiLibd not running\n",rv); - else - printf("saHpiSessionOpen: %s\n", oh_lookup_error(rv)); - exit(-1); - } - + if (copt.debug) + printf("New date and time in SaHpiTimeT %" PRId64 "\n\n", (int64_t)newtime); + + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); + rv = saHpiDiscover(sessionid); - if (fdebug) printf("saHpiDiscover %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiDiscover %s\n", oh_lookup_error(rv)); rv = saHpiDomainInfoGet(sessionid, &domainInfo); - if (fdebug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); printf("DomainInfo: RptUpdateCount = %u, RptUpdateTimestamp = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); @@ -229,10 +175,10 @@ while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if (fdebug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); if ((rv == SA_OK) && (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_EVENT_LOG)) { resourceid = rptentry.ResourceId; - if (fdebug) printf("RPT %x capabilities = %x\n", resourceid, + if (copt.debug) printf("RPT %x capabilities = %x\n", resourceid, rptentry.ResourceCapabilities); rv = saHpiEventLogTimeGet(sessionid, resourceid, &oldtime); oh_decode_time(oldtime, &buffer); Modified: openhpi/trunk/clients/hpithres.c =================================================================== --- openhpi/trunk/clients/hpithres.c 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/clients/hpithres.c 2011-02-02 14:51:27 UTC (rev 7267) @@ -2,6 +2,7 @@ * * Copyright (c) 2003 by Intel Corp. * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,17 +22,11 @@ * 11/03/2004 kouzmich porting to HPI B * 11/25/2004 kouzmich changed as new threshold client (first release) * 09/06/2010 ulikleber New option -D to select domain + * 01/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients + * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> - -#include <SaHpi.h> -#include <glib.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision$" @@ -98,9 +93,7 @@ Rpt_t *Rpts; int nrpts = 0; -int fdebug = 0; - -SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; +static oHpiCommonOptionsT copt; SaHpiSessionIdT sessionid; static void *resize_array(void *Ar, int item_size, int *last_num, int add_num) @@ -507,7 +500,7 @@ NULL, NULL, NULL); if (rv == SA_OK) break; - if (fdebug) printf("sleep before saHpiEventGet\n"); + if (copt.debug) printf("sleep before saHpiEventGet\n"); g_usleep(G_USEC_PER_SEC); }; saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, @@ -645,45 +638,33 @@ int main(int argc, char **argv) { - int c, i; + int i; SaErrorT rv; char buf[READ_BUF_SIZE]; char *S; - SaHpiBoolT printusage = FALSE; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:x?")) != EOF ) - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else printusage = TRUE; - break; - case 'x': - fdebug = 1; - break; - default: printusage = TRUE; - } - if (printusage) { - printf("Usage: %s [-D domain] [-x]\n", argv[0]); - printf(" -D domainid Select domain\n"); - printf(" -x Display debug messages\n"); - return(1); - } - - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen: %s\n", oh_lookup_error(rv)); - return(-1); + context = g_option_context_new ("- Display sensors and sensor info"); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + exit(1); } + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); + rv = saHpiDiscover(sessionid); - if (fdebug) printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); + if (copt.debug) printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); rv = saHpiSubscribe(sessionid); if (rv != SA_OK) { Modified: openhpi/trunk/docs/man/hpialarms.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpialarms.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpialarms.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,9 +4,9 @@ =head1 SYNOPSIS - hpialarms [-D id][-a 1|0][-b 1|0][-c 1|0][-m 1|0][-n 1|0][-p 1|0][-i n][-o][-X] + hpialarms [-D id][-a 1|0][-b 1|0][-c 1|0][-m 1|0][-n 1|0][-p 1|0][-i n][-o][-X][-h] hpialarms [--domain=id][--diska=1|0][--diskb=1|0][--critical=1|0][--major=1|0] - [--minor=1|0][--power=1|0][--chassisid=n][--all][-debug] + [--minor=1|0][--power=1|0][--chassisid=n][--all][--debug][--help] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpiel.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiel.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpiel.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,8 +4,8 @@ =head1 SYNOPSIS - hpiel [-D nn] [-d] [-e entitypath] [-c -p -r -x -v -h ] - hpiel [--Domain=nn] [--del] [--entitypath="entitypath"] [--clear --resource --rdr --xml --verbose --help] + hpiel [-D nn] [-d] [-e entitypath] [-c -p -r -X -h ] + hpiel [--Domain=nn] [--del] [--entitypath="entitypath"] [--clear --resource --rdr --xml --debug --help] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpievents.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpievents.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpievents.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,7 +4,7 @@ =head1 SYNOPSIS - hpievents [ -D <value> ] [ -t BLOCK|SAHPI_TIMEOUT_BLOCK|n ] [ -d -x -h ] + hpievents [ -D <value> ] [ -t BLOCK|SAHPI_TIMEOUT_BLOCK|n ] [ -d -X -h ] hpievents [--domain=nn] [--timeout=BLOCK|SAHPI_TIMEOUT_BLOCK|n ] [--discover] [--debug] [--help] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpifan.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpifan.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpifan.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,7 +4,7 @@ =head1 SYNOPSIS - hpifan [-D nn] [-h] [-s auto|nn] [X] + hpifan [-D nn] [-h] [-s auto|nn] [-X] hpifan [--domain=nn] [--help] [--speed=auto|nn] [--debug] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpiinv.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiinv.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpiinv.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,8 +4,8 @@ =head1 SYNOPSIS - hpiinv [-D nn] [-V] [ -X] [-a tag] - hpiinv [--domain=nn] [--verbose] [--debug] [--asset-tag=tag] + hpiinv [-D nn] [-V] [ -X] [-a tag] [-h] + hpiinv [--domain=nn] [--verbose] [--debug] [--asset-tag=tag] [--help] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpionIBMblade.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpionIBMblade.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpionIBMblade.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,8 +4,8 @@ =head1 SYNOPSIS - hpionIBMblade [-D nn] [ -X ] - hpionIBMblade [--domain nn] [ --debug ] + hpionIBMblade [-D nn] [ -X ] [ -h ] + hpionIBMblade [--domain nn] [--debug] [--help] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpipower.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpipower.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpipower.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,8 +4,8 @@ =head1 SYNOPSIS - hpipower [ -D nn ] [ -d -p -r -u -x -h] [ -b n ] - hpipower [--domain nn] [--power-down --power-up --reset --unattended --debug --help] [--blade n ] + hpipower [ -D nn ] [ -d -p -r -u -X -h] [ -b n ] + hpipower [--domain=nn] [--power-down --power-up --reset --unattended --debug --help] [--blade=n ] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpisensor.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisensor.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpisensor.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,11 +4,13 @@ =head1 SYNOPSIS -hpisensor [-D domain] [-t -r -x] [-e entitypath] + hpisensor [-D nn] [-t -r -s -X -h] [-E epath] + hpisensor [--domain=nn] [--threshold --range --eventstate --debug --help] [--entity-path="epath"] =head1 DESCRIPTION -hpisensor displays sensor info for all resources with Sensor Capability . +hpisensor displays sensor info for all resources with Sensor Capability. +Option -E (entity-path) restricts the output on the specified entity-path. If no domain is selected, hpisensor uses a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. @@ -17,12 +19,13 @@ =over 2 - -D domain id select Domain id - -t show Thresholds also - -r show Range values also - -s show EventState also - -e entity path limit to a single entity - -x show eXtra debug messages + -h, --help Show help options + -t, --threshold Show Thresholds also + -r, --range Show Range values also + -s, --eventstate Show EventState also + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + -E, --entity-path="epath" Use entity path epath =back @@ -32,7 +35,7 @@ hpialarms hpifan hpipower hpitop hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisettime hpiwdt - hpievents hpionIBMblade hpithres + hpievents hpionIBMblade hpithres hpixml ohdomainlist ohhandler ohparam Modified: openhpi/trunk/docs/man/hpisettime.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisettime.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpisettime.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,7 +4,8 @@ =head1 SYNOPSIS -hpisettime [-D domainid] -d mm/dd/yyyy -t HH:MM:SS [-x] + hpisettime [-D nn] -d mm/dd/yyyy -t HH:MM:SS [-X] [-h] + hpisettime [--domain=nn] --date=mm/dd/yyyy --time=HH:MM:SS [--debug] [--help] =head1 DESCRIPTION @@ -16,10 +17,11 @@ =over 2 - -D domainid select domain - -d date in mm/dd/yyyy format - -t time of day in 24-hr format - -x displays eXtra debug messages + -h, --help Show help options + -d, --date=mm/dd/yyyy New date + -t, --time=24:12:60 New time of day in 24-hr format + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages =back Modified: openhpi/trunk/docs/man/hpithres.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpithres.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpithres.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -4,7 +4,8 @@ =head1 SYNOPSIS -hpithres [-D domain] [-x] + hpithres [-D nn] [-X] [-h] + hpithres [--domain=nn] [--debug] [--help] =head1 DESCRIPTION @@ -16,8 +17,9 @@ =over 2 --D domainid Select domain --x Display debug messages + -h, --help Show help options + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages =back @@ -27,7 +29,7 @@ hpialarms hpifan hpipower hpitop hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt - hpievents hpionIBMblade hpisettime + hpievents hpionIBMblade hpisettime hpixml ohdomainlist ohhandler ohparam Modified: openhpi/trunk/docs/man/hpitop.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitop.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpitop.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -5,10 +5,10 @@ =head1 SYNOPSIS - hpitop [-D nn] [-rscwiafd] [-n nn] [-x] + hpitop [-D nn] [-rscwiafd] [-n nn] [-X] [-h] hpitop [--domain=nn] [--rpts] [--sensors] [--controls] [--watchdogs] [--inventories] [--annunciators] [--fumis] [--dimis] - [--resource=nn] [--debug] + [--resource=nn] [--debug] [--help] =head1 DESCRIPTION Modified: openhpi/trunk/docs/man/hpitree.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitree.pod.1 2011-02-02 12:33:59 UTC (rev 7266) +++ openhpi/trunk/docs/man/hpitree.pod.1 2011-02-02 14:51:27 UTC (rev 7267) @@ -5,9 +5,9 @@ =head1 SYNOPSIS - hpitree [-D nn] [-acdiorsw ] [-n nn] [-x] + hpitree [-D nn] [-acdiorsw ] [-n nn] [-x] [-h] hpitree [--domain=nn] [--all] [--controls] [--rdrs] [--inventories] [--rpts] - [--sensors] [--watchdogs] [--overview] [--resource=nn] [--debug] + [--sensors] [--watchdogs] [--overview] [--resource=nn] [--debug] [--help] =head1 DESCRIPTION This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-02-03 14:27:54
|
Revision: 7268 http://openhpi.svn.sourceforge.net/openhpi/?rev=7268&view=rev Author: ulikleber Date: 2011-02-03 14:27:46 +0000 (Thu, 03 Feb 2011) Log Message: ----------- more on 1493787 Update clients to use long options and uniform format remaining clients in clients directory done. Changes to free memory. hpixml and hpi_shell still missing. Modified Paths: -------------- openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpialarms.c openhpi/trunk/clients/hpidomain.c openhpi/trunk/clients/hpiel.c openhpi/trunk/clients/hpievents.c openhpi/trunk/clients/hpifan.c openhpi/trunk/clients/hpigensimdata.c openhpi/trunk/clients/hpiinv.c openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/hpipower.c openhpi/trunk/clients/hpireset.c openhpi/trunk/clients/hpisensor.c openhpi/trunk/clients/hpisettime.c openhpi/trunk/clients/hpithres.c openhpi/trunk/clients/hpitop.c openhpi/trunk/clients/hpitree.c openhpi/trunk/clients/hpiwdt.c openhpi/trunk/clients/ohdomainlist.c openhpi/trunk/clients/ohhandler.c openhpi/trunk/clients/ohparam.c openhpi/trunk/docs/man/hpiwdt.pod.1 openhpi/trunk/docs/man/ohdomainlist.pod.1 openhpi/trunk/docs/man/ohhandler.pod.1 openhpi/trunk/docs/man/ohparam.pod.1 Modified: openhpi/trunk/clients/clients.c =================================================================== --- openhpi/trunk/clients/clients.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/clients.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -27,8 +27,8 @@ static gint optdid = SAHPI_UNSPECIFIED_DOMAIN_ID; static gboolean optdebug = FALSE; static gboolean optverbose = FALSE; -static gchar *optep = ""; -static gchar *optdaemon = ""; +static gchar *optep = NULL; +static gchar *optdaemon = NULL; static GOptionEntry domain_option[] = { @@ -116,8 +116,8 @@ exit (1); } - common_options->withentitypath = (optep[0] != '\0'); - common_options->withdaemonhost = (optdaemon[0] != '\0'); + common_options->withentitypath = (optep != NULL); + common_options->withdaemonhost = (optdaemon != NULL); if (optdebug && optverbose) { g_print("Parsing of options completed. Common options:\n --debug --verbose"); @@ -162,6 +162,9 @@ g_print(" port=%u\n",common_options->daemonport); } } + + g_free (optep); + g_free (optdaemon); return TRUE; } Modified: openhpi/trunk/clients/hpialarms.c =================================================================== --- openhpi/trunk/clients/hpialarms.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpialarms.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -112,8 +112,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); if (fall) { /* set all alarms off */ fid=0; Modified: openhpi/trunk/clients/hpidomain.c =================================================================== --- openhpi/trunk/clients/hpidomain.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpidomain.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -74,14 +74,20 @@ - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) { + g_free(f_domtag); + exit(-1); + } if (f_domtag){ oh_append_textbuffer(&domtag, f_domtag); + g_free (f_domtag); if (copt.debug) printf ("Let's go change the tag" "to %s\n",f_domtag); set_domaintag(sessionid, domtag); Modified: openhpi/trunk/clients/hpiel.c =================================================================== --- openhpi/trunk/clients/hpiel.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpiel.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -95,8 +95,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented gerror)) { g_print ("option parsing failed: %s\n", gerror->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); /* Program really begins here - all options parsed at this point */ error = ohc_session_open_by_option ( &copt, &sid); Modified: openhpi/trunk/clients/hpievents.c =================================================================== --- openhpi/trunk/clients/hpievents.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpievents.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -76,8 +76,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); if (timeout_str) { int i = 0; @@ -92,6 +94,7 @@ wait = atoi(timeout_str); timeout = (SaHpiTimeoutT)(wait * HPI_NSEC_PER_SEC); } + g_free (timeout_str); } else timeout = (SaHpiTimeoutT) SAHPI_TIMEOUT_IMMEDIATE; Modified: openhpi/trunk/clients/hpifan.c =================================================================== --- openhpi/trunk/clients/hpifan.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpifan.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -243,8 +243,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); if (f_speed) { set_new = SAHPI_TRUE; @@ -256,9 +258,11 @@ new_speed = atoi( f_speed ); if (new_speed == 0) { g_print ("please enter a valid speed: \"auto\" or a number.\n"); + g_free (f_speed); exit(1); } } + g_free(f_speed); } rv = ohc_session_open_by_option ( &copt, &sessionid); Modified: openhpi/trunk/clients/hpigensimdata.c =================================================================== --- openhpi/trunk/clients/hpigensimdata.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpigensimdata.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -93,6 +93,8 @@ { NULL } }; +#define GFREE g_option_context_free (context);g_free(g_file);g_free(g_mode); + char offSet[MAX_OFFSETS][MAX_CHAR]; @@ -311,13 +313,16 @@ - OHC_DEBUG_OPTION, // no debug mode error)) { g_print ("option parsing failed: %s\n", error->message); + GFREE exit(1); } + GFREE if (g_file) { outfile = fopen(g_file, "w"); if (outfile == NULL) { fprintf(stderr, "\n%s couldn't be opened for writing.\n", g_file); + GFREE exit(1); } } @@ -334,6 +339,8 @@ confdata.mode = MODE_INIT; } else { fprintf(stderr, "\nUnknown mode %s.\n", g_mode); + if (g_file) fclose(outfile); + GFREE exit (1); } } @@ -352,7 +359,11 @@ print_header(outfile, 0, confdata); rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) { + if (g_file) fclose(outfile); + GFREE + exit(-1); + } /* * Resource discovery @@ -360,13 +371,15 @@ rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); + if (g_file) fclose(outfile); + GFREE exit(-1); } print_resources(outfile, 0, sessionid, (SaHpiResourceIdT) g_resourceid); rv = saHpiSessionClose(sessionid); if (g_file) fclose(outfile); - + GFREE exit(0); } Modified: openhpi/trunk/clients/hpiinv.c =================================================================== --- openhpi/trunk/clients/hpiinv.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpiinv.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -488,11 +488,14 @@ - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); if (fatag) { atag.tag = (char *)strdup(fatag); atag.tlen = strlen(fatag); + g_free(fatag); } /* compile error */ @@ -581,7 +584,7 @@ if (!ent_writable(&rptentry.ResourceEntity,&idrInfo)) foundasset = 0; - if ((fatag) && (foundasset == 1)) { + if ((atag.tlen > 0) && (foundasset == 1)) { SaHpiIdrFieldT atagField; atagField.Type = SAHPI_IDR_FIELDTYPE_ASSET_TAG; atagField.ReadOnly = SAHPI_FALSE; Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpionIBMblade.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -911,8 +911,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); rv = hpiIBMspecial_find_blade_slot(); if (rv != SA_OK) { Modified: openhpi/trunk/clients/hpipower.c =================================================================== --- openhpi/trunk/clients/hpipower.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpipower.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -114,8 +114,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); if (f_down) { Action = SAHPI_POWER_OFF; ActionSelected = TRUE; Modified: openhpi/trunk/clients/hpireset.c =================================================================== --- openhpi/trunk/clients/hpireset.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpireset.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -72,8 +72,11 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); - } + } + g_option_context_free (context); + if (f_warm) action = SAHPI_WARM_RESET; rv = ohc_session_open_by_option ( &copt, &sessionid); Modified: openhpi/trunk/clients/hpisensor.c =================================================================== --- openhpi/trunk/clients/hpisensor.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpisensor.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -227,8 +227,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); rv = ohc_session_open_by_option ( &copt, &sessionid); if (rv != SA_OK) exit(-1); Modified: openhpi/trunk/clients/hpisettime.c =================================================================== --- openhpi/trunk/clients/hpisettime.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpisettime.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -59,6 +59,9 @@ { NULL } }; +#define EXIT1 g_free(findate);g_free(fintime);exit(1); + + int main(int argc, char **argv) { int month, day, year; @@ -90,28 +93,30 @@ - OHC_VERBOSE_OPTION, // no verbose mode error)) { g_print ("option parsing failed: %s\n", error->message); - exit(1); + g_option_context_free (context); + EXIT1; } + g_option_context_free (context); if ( !findate || !fintime) { printf("Please enter date and time to be set.\n"); - exit(1); + EXIT1; } if (findate) { if (copt.debug) printf("New date to be set: %s\n",findate); if (sscanf(findate,"%2d/%2d/%4d", &month, &day, &year) != 3) { printf("%s: Invalid date\n", argv[0]); - exit(1); + EXIT1; } /* check month, day and year for correctness */ if ((month < 1) || (month > 12)) { printf("%s: Month out of range: (%d)\n", argv[0], month); - exit(1); + EXIT1; }; if (year < 1900) { printf("%s: Year out of range: (%d)\n", argv[0], year); - exit(1); + EXIT1; }; month--; if (month == 1) { @@ -121,7 +126,7 @@ }; if ((day < 1) || (day > day_array[month])) { printf("%s: Day out of range: (%d)\n", argv[0], day); - exit(1); + EXIT1; }; new_tm_time.tm_mon = month; @@ -134,20 +139,20 @@ if (sscanf(fintime,"%2d:%2d:%2d", &new_tm_time.tm_hour, &new_tm_time.tm_min, &new_tm_time.tm_sec) != 3) { printf("%s: Invalid time\n", argv[0]); - exit(1); + EXIT1; } /* check hours, minutes and seconds for correctness */ if ((new_tm_time.tm_hour < 0) || (new_tm_time.tm_hour > 24)) { printf("%s: Hours out of range: (%d)\n", argv[0], new_tm_time.tm_hour); - exit(1); + EXIT1; }; if ((new_tm_time.tm_min < 0) || (new_tm_time.tm_min > 60)) { printf("%s: Minutes out of range: (%d)\n", argv[0], new_tm_time.tm_min); - exit(1); + EXIT1; }; if ((new_tm_time.tm_sec < 0) || (new_tm_time.tm_sec > 60)) { printf("%s: Seconds out of range: (%d)\n", argv[0], new_tm_time.tm_sec); - exit(1); + EXIT1; } } @@ -161,7 +166,7 @@ printf("New date and time in SaHpiTimeT %" PRId64 "\n\n", (int64_t)newtime); rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) EXIT1; rv = saHpiDiscover(sessionid); if (copt.debug) printf("saHpiDiscover %s\n", oh_lookup_error(rv)); @@ -199,7 +204,10 @@ } rv = saHpiSessionClose(sessionid); - + + g_free(findate); + g_free(fintime); + return(0); } Modified: openhpi/trunk/clients/hpithres.c =================================================================== --- openhpi/trunk/clients/hpithres.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpithres.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -656,8 +656,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); rv = ohc_session_open_by_option ( &copt, &sessionid); if (rv != SA_OK) exit(-1); Modified: openhpi/trunk/clients/hpitop.c =================================================================== --- openhpi/trunk/clients/hpitop.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpitop.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -144,8 +144,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); if (f_rpt || f_sensor || f_ctrl || f_wdog || f_inv || f_ann || f_fumi || f_dimi || resourceid>0) Modified: openhpi/trunk/clients/hpitree.c =================================================================== --- openhpi/trunk/clients/hpitree.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpitree.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -147,8 +147,10 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); if (f_rpt || f_sensor || f_inv || f_ctrl || f_rdr || f_wdog) f_listall = TRUE; Modified: openhpi/trunk/clients/hpiwdt.c =================================================================== --- openhpi/trunk/clients/hpiwdt.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/hpiwdt.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -2,6 +2,7 @@ * * Copyright (c) 2004 by Intel Corp. * (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,6 +20,9 @@ * 10/13/04 kouzmich - porting to HPI B * 12/02/04 Andy Cress - v1.1 fixed domain/RPT loop, added some decoding * 09/06/2010 ulikleber New option -D to select domain + * 01/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients + * */ /* * This tool reads and enables the watchdog timer via HPI. @@ -30,13 +34,6 @@ * will reset your system. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oHpi.h> - #include "oh_clients.h" #define uchar unsigned char @@ -48,8 +45,22 @@ #define NACT 5 char *actions[NACT] = {"No action", "Hard Reset", "Power down", "Power cycle", "Reserved" }; -char fdebug = 0; +static gboolean fenable = FALSE; +static gboolean fdisable = FALSE; +static gboolean freset = FALSE; +static gint ftimeout = 0; +static oHpiCommonOptionsT copt; + +static GOptionEntry my_options[] = +{ + { "enable", 'e', 0, G_OPTION_ARG_NONE, &fenable, "enables the watchdog timer", NULL }, + { "disable", 'd', 0, G_OPTION_ARG_NONE, &fdisable, "disables the watchdog timer", NULL }, + { "reset", 'r', 0, G_OPTION_ARG_NONE, &freset, "resets the watchdog timer", NULL }, + { "timeout", 't', 0, G_OPTION_ARG_INT, &ftimeout, "sets timeout to n seconds", "n" }, + { NULL } +}; + static void show_wdt(SaHpiWatchdogNumT wdnum, SaHpiWatchdogT *wdt) { @@ -92,9 +103,7 @@ int main(int argc, char **argv) { - int c; SaErrorT rv; - SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT sessionid; SaHpiDomainInfoT domainInfo; SaHpiRptEntryT rptentry; @@ -103,63 +112,35 @@ SaHpiResourceIdT resourceid; SaHpiWatchdogNumT wdnum; SaHpiWatchdogT wdt; - int t = 0; - char freset = 0; - char fenable = 0; - char fdisable = 0; - SaHpiBoolT printusage = FALSE; + GError *error = NULL; + GOptionContext *context; oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"D:dert:x?")) != EOF ) - switch(c) { - case 'D': - if (optarg) domainid = atoi(optarg); - else printusage = TRUE; - break; - case 'r': /* reset wdt */ - freset = 1; - break; - case 'e': /* disable wdt */ - fenable = 1; - break; - case 'd': /* disable wdt */ - fdisable = 1; - break; - case 't': /* timeout (enable implied) */ - if (optarg) { - t = atoi(optarg); - fenable = 1; - } - else printusage = TRUE; - break; - case 'x': fdebug = 1; break; /* debug messages */ - default: printusage = TRUE; - } - if (printusage) { - printf("Usage: %s [-derx -t sec]\n", argv[0]); - printf(" where -D domainid Selects the domain\n"); - printf(" -e enables the watchdog timer\n"); - printf(" -d disables the watchdog timer\n"); - printf(" -r resets the watchdog timer\n"); - printf(" -t N sets timeout to N seconds\n"); - printf(" -x show eXtra debug messages\n"); + + context = g_option_context_new ("- Read and Enables the watchdog timer."); + g_option_context_add_main_entries (context, my_options, NULL); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); - } - if (t == 0) t = 120; - - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen error %d\n",rv); - exit(-1); - } + g_option_context_free (context); + if (ftimeout == 0) ftimeout = 120; + else fenable = TRUE; + + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); + rv = saHpiDiscover(sessionid); - if (fdebug) printf("saHpiDiscover rv = %d\n",rv); + if (copt.debug) printf("saHpiDiscover rv = %d\n",rv); rv = saHpiDomainInfoGet(sessionid, &domainInfo); - if (fdebug) printf("saHpiDomainInfoGet rv = %d\n",rv); + if (copt.debug) printf("saHpiDomainInfoGet rv = %d\n",rv); printf("DomainInfo: UpdateCount = %x, UpdateTime = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); @@ -173,7 +154,7 @@ /* handle WDT for this RPT entry */ resourceid = rptentry.ResourceId; rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; - if (fdebug) + if (copt.debug) printf("rptentry[%u] resourceid=%u capab=%x tag: %s\n", rptentryid, resourceid, rptentry.ResourceCapabilities, rptentry.ResourceTag.Data); @@ -183,7 +164,7 @@ wdnum = SAHPI_DEFAULT_WATCHDOG_NUM; rv = saHpiWatchdogTimerGet(sessionid,resourceid,wdnum,&wdt); - if (fdebug) printf("saHpiWatchdogTimerGet rv = %d\n",rv); + if (copt.debug) printf("saHpiWatchdogTimerGet rv = %d\n",rv); if (rv != 0) { printf("saHpiWatchdogTimerGet error = %d\n",rv); rv = 0; @@ -204,27 +185,27 @@ wdt.PresentCount = 120000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); - if (fdebug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); + if (copt.debug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); if (rv == 0) show_wdt(wdnum,&wdt); } else if (fenable) { printf("Enabling watchdog timer ...\n"); /* hard reset action, no pretimeout, clear SMS/OS when done */ - /* use t for timeout */ + /* use ftimeout for timeout */ wdt.TimerUse = SAHPI_WTU_SMS_OS; /* 1=FRB2 2=POST 3=OSLoad 4=SMS_OS 5=OEM */ wdt.TimerAction = SAHPI_WAE_RESET; /* 0=none 1=reset 2=powerdown 3=powercycle */ wdt.PretimerInterrupt = SAHPI_WPI_NMI; /* 0=none 1=SMI 2=NMI 3=message */ - wdt.PreTimeoutInterval = (t / 2) * 1000; /*msec*/ - wdt.InitialCount = t * 1000; /*msec*/ - wdt.PresentCount = t * 1000; /*msec*/ + wdt.PreTimeoutInterval = (ftimeout / 2) * 1000; /*msec*/ + wdt.InitialCount = ftimeout * 1000; /*msec*/ + wdt.PresentCount = ftimeout * 1000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); - if (fdebug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); + if (copt.debug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); if (rv == 0) show_wdt(wdnum,&wdt); } if (freset && !fdisable) { printf("Resetting watchdog timer ...\n"); rv = saHpiWatchdogTimerReset(sessionid,resourceid,wdnum); - if (fdebug) printf("saHpiWatchdogTimerReset rv = %d\n",rv); + if (copt.debug) printf("saHpiWatchdogTimerReset rv = %d\n",rv); } } /*watchdog capability*/ rptentryid = nextrptentryid; /* get next RPT (usu only one anyway) */ Modified: openhpi/trunk/clients/ohdomainlist.c =================================================================== --- openhpi/trunk/clients/ohdomainlist.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/ohdomainlist.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -1,6 +1,7 @@ /* -*- linux-c -*- * * Copyright (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,17 +19,11 @@ * openHPI complex * * Changes: + * 03/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oHpi.h> -#include <oh_utils.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision: 7112 $" @@ -42,37 +37,33 @@ /* * Globals for this driver */ -int fdebug = 0; -int fverbose = 0; +static oHpiCommonOptionsT copt; - /* * Main */ int main(int argc, char **argv) { - SaHpiBoolT printusage = FALSE; - int c; - - oh_prog_version(argv[0], OH_SVN_REV); - while ( (c = getopt( argc, argv,"vx?")) != EOF ) { - switch(c) { - case 'x': fdebug = 1; break; - case 'v': fverbose = 1; break; - default: printusage = TRUE; break; - } - } - if (printusage == TRUE) - { - printf("\n\tUsage: %s [-option]\n\n", argv[0]); - printf("\t (No Option) Display domains known to baselib \n"); - printf("\t -v Display in verbose mode including " - "domain info for directly related domains\n"); - printf("\t -x Display debug messages\n"); - printf("\n\n\n\n"); + GError *error = NULL; + GOptionContext *context; + + oh_prog_version(argv[0], OH_SVN_REV); + + context = g_option_context_new ("- Show information about domains" + " on the level of the openhpi base library."); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION // not applicable + - OHC_DOMAIN_OPTION, // not applicable + error)) { + g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); exit(1); } + g_option_context_free (context); show_domains(); @@ -97,17 +88,17 @@ /* walk the Domain Table */ domainentryid = SAHPI_FIRST_ENTRY; do { - if (fdebug) printf("oHpiDomainEntryGet called with entry=%u\n", + if (copt.debug) printf("oHpiDomainEntryGet called with entry=%u\n", domainentryid); rv = oHpiDomainEntryGet( domainentryid,&nextdomainentryid,&domainentry); - if ((rv != SA_OK) || fdebug) + if ((rv != SA_OK) || copt.debug) printf("oHpiDomainEntryGet returns %s\n", oh_lookup_error(rv)); if (rv == SA_OK ) { - if (fdebug) printf("oHpiDomainEntryGet provides domainid=%u," + if (copt.debug) printf("oHpiDomainEntryGet provides domainid=%u," " nextentryid=%u\n", domainentry.id, nextdomainentryid); @@ -116,7 +107,7 @@ domainentry.port, domainentry.id); - if (fverbose) { + if (copt.verbose) { /* display the domaininfo for that related domain */ relateddomainid = domainentry.id; rv = saHpiSessionOpen(relateddomainid, @@ -126,7 +117,7 @@ relateddomainid); continue; } - if (fdebug) { + if (copt.debug) { printf("saHpiSessionOpen returns with SessionId %u\n", relatedsessionid); printf("saHpiDomainInfoGet for domain %u\n", @@ -138,7 +129,7 @@ printf("\nDomaininfo of domain %u cannot be " "retrieved.\n", relateddomainid); - if (fdebug) + if (copt.debug) printf("saHpiDomainInfoGet for domain " "%u failed with returncode %s\n", relateddomainid, oh_lookup_error(rv)); @@ -149,7 +140,7 @@ } rv = saHpiSessionClose(relatedsessionid); - if (fdebug) + if (copt.debug) printf("saHpiSessionClose returns %s\n", oh_lookup_error(rv)); Modified: openhpi/trunk/clients/ohhandler.c =================================================================== --- openhpi/trunk/clients/ohhandler.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/ohhandler.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -1,6 +1,7 @@ /* -*- linux-c -*- * * Copyright (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,21 +19,38 @@ * using the OpenHPI extensions as described in ohpi.c * * Changes: + * 03/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oh_utils.h> -#include <oHpi.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision: 7133 $" +#define OHHANDLER_HELP \ + "Command list \n" \ + " List the handlers loaded in specified domain \n\n" \ + "Command info <handler-id> \n" \ + " Display info about handler <handler-id> \n\n" \ + "Command destroy <handler-id> \n" \ + " Unload handler <handler-id> and delete its config \n\n" \ + "Command getnext <handler-id> \n" \ + " Find next valid handler id from <handler-id> \n\n" \ + "Command find <resource-id> \n" \ + " Find the right handler for a resource id \n\n" \ + "Command retry <handler-id> \n" \ + " Retry loading of handler <handler-id> \n\n" \ + "Command create plugin <name> <params> \n" \ + " Create handler with the specified parameters. \n" \ + " Pairs of strings in commandline like in openhpi.conf. \n" \ + " Keyword plugin to select type of handler. \n" \ + " Entity root and other complex strings must be \n" \ + " enclosed in \". \n" \ + " Example: \n" \ + " ohhandler create plugin libsimulator " \ + "entity_root \"{SYSTEM_CHASSIS,1}\" name sim\n" + /********************************************/ /* Function prototypes */ /********************************************/ @@ -48,8 +66,7 @@ /********************************************/ /* Globals */ /********************************************/ -int fdebug = 0; -SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; +static oHpiCommonOptionsT copt; SaHpiSessionIdT sessionid; @@ -60,11 +77,12 @@ main(int argc, char **argv) { SaErrorT rv = SA_OK; - oHpiHandlerIdT handlerid = 0; SaHpiResourceIdT resid = 0; SaHpiBoolT printusage = FALSE; int i=1; + GError *error = NULL; + GOptionContext *context; enum cmdT {eUndefined, eHandlerCreate, @@ -77,14 +95,25 @@ oh_prog_version(argv[0], OH_SVN_REV); - while (i<argc && !printusage && cmd!=eHandlerCreate) { - if (strcmp(argv[i],"-D")==0) { - if (++i<argc) domainid = atoi(argv[i]); - else printusage = TRUE; - } - else if (strcmp(argv[i],"-x")==0) fdebug=1; + /* Parse common options */ + context = g_option_context_new ("command [specific arguments] - " + "Control openhpi plugin instances (handlers).\n\n" + OHHANDLER_HELP ); - else if (strcmp(argv[i],"create")==0) { + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION // not applicable + - OHC_VERBOSE_OPTION, // no verbose mode + error)) { + g_print ("option parsing failed: %s\n", error->message); + printusage = TRUE; + } + g_option_context_free (context); + + /* Parse ohparam specific commands */ + while (i<argc && !printusage && cmd!=eHandlerCreate) { + if (strcmp(argv[i],"create")==0) { cmd=eHandlerCreate; // exechandlercreate will do the remaining reading of // parameters itself @@ -145,51 +174,18 @@ if (printusage == TRUE || cmd == eUndefined) { printf("\n"); - printf("Usage: %s [-D domain] [-x] command [specific arguments]\n\n", + printf("Usage: %s [-D nn] [-X] command [specific arguments]\n\n", argv[0]); - printf(" -D nn Select domain id nn (not supported yet by oh-functions)\n"); - printf(" -x Display debug messages\n"); - printf("\n"); - printf(" ohhander [-D domain] [-x] list\n"); - printf(" List the handlers loaded in specified domain\n\n"); - printf(" ohhander [-D domain] [-x] info <handler-id>\n"); - printf(" Display info about handler <handler-id> \n\n"); - printf(" ohhander [-D domain] [-x] destroy <handler-id>\n"); - printf(" Unload handler <handler-id> and delete its config \n\n"); - printf(" ohhander [-D domain] [-x] getnext <handler-id>\n"); - printf(" Find next valid handler id from <handler-id> \n\n"); - printf(" ohhander [-D domain] [-x] find <resource-id>\n"); - printf(" Find the right handler for a resource id \n\n"); - printf(" ohhander [-D domain] [-x] retry <handler-id>\n"); - printf(" Retry loading of handler <handler-id> \n\n"); - printf(" ohhander [-D domain] [-x] create plugin <name> <params>\n"); - printf(" Create handler with the specified parameters.\n"); - printf(" Pairs of strings in commandline like in openhpi.conf.\n"); - printf(" Keyword plugin to select type of handler.\n"); - printf(" Entity root and other complex strings must be \n"); - printf(" enclosed in \".\n"); - printf(" example:\n"); - printf(" ohhandler create plugin libsimulator " - "entity_root \"{SYSTEM_CHASSIS,1}\" name sim\n"); - - printf("\n\n"); + printf(OHHANDLER_HELP"\n"); + printf(" Options: \n"); + printf(" -h, --help Show help options \n"); + printf(" -D, --domain=nn Select domain id nn \n"); + printf(" -X, --debug Display debug messages \n\n"); exit(1); } - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) - printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen returns %d (%s)\n", - rv, oh_lookup_error(rv)); - exit(-1); - } - if (fdebug) - printf("saHpiSessionOpen returns with SessionId %u\n", - sessionid); + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); switch (cmd){ case eHandlerCreate: break; //already done @@ -214,14 +210,14 @@ case eUndefined: break; //already done } - if (fdebug) { + if (copt.debug) { printf("Internal processing returns %d (%s)\n", rv, oh_lookup_error(rv)); printf("Calling saHpiSessionClose for session %u\n",sessionid); } rv = saHpiSessionClose(sessionid); - if (fdebug) { + if (copt.debug) { printf("saHpiSessionClose returns %d (%s)\n", rv, oh_lookup_error(rv)); } @@ -240,7 +236,7 @@ g_str_hash, g_str_equal, g_free, g_free); SaHpiBoolT pluginnamegiven = SAHPI_FALSE; - if (fdebug) printf ("createhandler started\n"); + if (copt.debug) printf ("createhandler started\n"); while (i<argc){ if (strcmp(argv[i],"-f")==0) { @@ -252,7 +248,7 @@ g_hash_table_insert( createparams, g_strdup( argv[i-1] ), g_strdup( argv[i] )); - if (fdebug) printf ("Pair of arguments: %s - %s\n", + if (copt.debug) printf ("Pair of arguments: %s - %s\n", g_strdup( argv[i-1] ), g_strdup( argv[i] )); } @@ -266,22 +262,10 @@ return (SA_ERR_HPI_INVALID_PARAMS); } - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) - printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen returns %d (%s)\n", - rv, oh_lookup_error(rv)); - return (SA_ERR_HPI_INVALID_PARAMS); - } - if (fdebug) - printf("saHpiSessionOpen returns with SessionId %u\n", - sessionid); + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); - if (fdebug) printf ("Calling oHpiHandlerCreate!\n"); + if (copt.debug) printf ("Calling oHpiHandlerCreate!\n"); rv = oHpiHandlerCreate(sessionid, createparams, &handlerid ); if ( rv != SA_OK ) { @@ -304,12 +288,12 @@ static SaErrorT exechandlerdestroy(oHpiHandlerIdT handlerid) { SaErrorT rv = SA_OK; - if (fdebug) printf("Go and unload handler %u in domain %u\n", - handlerid, domainid); + if (copt.debug) printf("Go and unload handler %u in domain %u\n", + handlerid, copt.domainid); rv = oHpiHandlerDestroy ( sessionid, handlerid ); - if (fdebug) printf("oHpiHandlerDestroy returned %d (%s)\n", + if (copt.debug) printf("oHpiHandlerDestroy returned %d (%s)\n", rv, oh_lookup_error(rv)); if (rv==SA_OK) { @@ -317,11 +301,11 @@ return rv; } else if (rv==SA_ERR_HPI_NOT_PRESENT) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("Handler %u is not existing in default domain.\n", handlerid); else printf("Handler %u is not existing in domain %u.\n", - handlerid, domainid); + handlerid, copt.domainid); return rv; } else printf("\nHandler %u couldn't be unloaded, Returncode %d (%s)\n", @@ -350,16 +334,16 @@ g_str_hash, g_str_equal, g_free, g_free ); - if (fdebug) printf("Go and display handler info for %u\n", handlerid); + if (copt.debug) printf("Go and display handler info for %u\n", handlerid); rv = oHpiHandlerInfo ( sessionid, handlerid, &handlerinfo, handlerconfig ); if (rv==SA_ERR_HPI_NOT_PRESENT) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("Handler %u is not existing in default domain.\n", handlerid); else printf("Handler %u is not existing in domain %u.\n", - handlerid, domainid); + handlerid, copt.domainid); g_hash_table_destroy(handlerconfig); return SA_OK; } @@ -369,9 +353,9 @@ g_hash_table_destroy(handlerconfig); return rv; } - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("\n\nInfo for handler %u in default domain:\n\n",handlerid); - else printf("\n\nInfo for handler %u in domain %u:\n\n",handlerid, domainid); + else printf("\n\nInfo for handler %u in domain %u:\n\n",handlerid, copt.domainid); printf("Plugin name: %s\n",handlerinfo.plugin_name); printf("Root "); @@ -397,12 +381,12 @@ SaErrorT rv = SA_OK; oHpiHandlerIdT nexthandlerid; - if (fdebug) printf("Go and get next handler from %u in domain %u\n", - handlerid, domainid); + if (copt.debug) printf("Go and get next handler from %u in domain %u\n", + handlerid, copt.domainid); rv = oHpiHandlerGetNext ( sessionid, handlerid, &nexthandlerid ); - if (fdebug) printf("oHpiHandlerGetNext returned %d (%s)\n", + if (copt.debug) printf("oHpiHandlerGetNext returned %d (%s)\n", rv, oh_lookup_error(rv)); if (rv==SA_OK) { @@ -410,11 +394,11 @@ handlerid, nexthandlerid); } else if (rv==SA_ERR_HPI_NOT_PRESENT) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("No next Handler found from %u in default domain.\n", handlerid); else printf("No next Handler found from %u in domain %u.\n", - handlerid, domainid); + handlerid, copt.domainid); } else printf("\noHpiHandlerGetNext returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -429,13 +413,13 @@ SaErrorT rv = SA_OK; oHpiHandlerIdT handlerid; - if (fdebug) printf("Go and find handler for resource %u in domain " + if (copt.debug) printf("Go and find handler for resource %u in domain " "%u using session %u\n", - resid, domainid, sessionid); + resid, copt.domainid, sessionid); rv = oHpiHandlerFind ( sessionid, resid, &handlerid ); - if (fdebug) printf("oHpiHandlerFind returned %d (%s)\n", + if (copt.debug) printf("oHpiHandlerFind returned %d (%s)\n", rv, oh_lookup_error(rv)); if (rv==SA_OK) { @@ -443,11 +427,11 @@ resid, handlerid); } else if (rv==SA_ERR_HPI_NOT_PRESENT) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("No Handler found for resource %u in default domain.\n", resid); else printf("No Handler found for resource %u in domain %u.\n", - resid, domainid); + resid, copt.domainid); } else printf("\noHpiHandlerFind returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -461,8 +445,8 @@ { SaErrorT rv = SA_OK; - if (fdebug) printf("Go and retry loading handler %u in domain %u\n", - handlerid, domainid); + if (copt.debug) printf("Go and retry loading handler %u in domain %u\n", + handlerid, copt.domainid); rv = oHpiHandlerRetry ( sessionid, handlerid ); @@ -471,11 +455,11 @@ rv, oh_lookup_error(rv)); return rv; } - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("\nHandler %u in default domain successfully re-loaded.\n", handlerid); else printf("\nHandler %u in domain %u successfully re-loaded.\n", - handlerid, domainid); + handlerid, copt.domainid); return rv; } @@ -490,13 +474,13 @@ oHpiHandlerInfoT handlerinfo; GHashTable *config = 0; - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("Handlers defined in default domain:\n"); - else printf("Handlers defined in Domain %u:\n",domainid); + else printf("Handlers defined in Domain %u:\n",copt.domainid); while (rv==SA_OK) { rv = oHpiHandlerGetNext ( sessionid, handlerid, &nexthandlerid ); - if (fdebug) printf("oHpiHandlerGetNext (%u) returned %d (%s)\n", + if (copt.debug) printf("oHpiHandlerGetNext (%u) returned %d (%s)\n", handlerid, rv, oh_lookup_error(rv)); if (rv==SA_OK) { Modified: openhpi/trunk/clients/ohparam.c =================================================================== --- openhpi/trunk/clients/ohparam.c 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/clients/ohparam.c 2011-02-03 14:27:46 UTC (rev 7268) @@ -1,6 +1,7 @@ /* -*- linux-c -*- * * Copyright (C) Copyright Nokia Siemens Networks 2010 + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,21 +20,29 @@ * the OpenHPI extensions as described in ohpi.c * * Changes: + * 03/02/2011 ulikleber Refactoring to use glib for option parsing and + * introduce common options for all clients * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <getopt.h> -#include <SaHpi.h> -#include <oh_utils.h> -#include <oHpi.h> - #include "oh_clients.h" #define OH_SVN_REV "$Revision: 7142 $" +#define OHPARAM_HELP \ + "Command get: display info about all global parameters \n" \ + " no specific arguments \n" \ + "Command set: \n" \ + " one of the daemon's global parameters: \n" \ + " (without the OPENHPI prefix) \n" \ + " ON_EP, LOG_ON_SEV, EVT_QUEUE_LIMIT, \n" \ + " DEL_SIZE_LIMIT, DEL_SAVE \n" \ + " DAT_SIZE_LIMIT, DAT_USER_LIMIT, DAT_SAVE \n" \ + " PATH, VARPATH, CONF \n" \ + " and the desired new value. Example: \n" \ + " ohparam set DEL_SIZE_LIMIT 20000 " + + /* * Function prototypes */ @@ -44,8 +53,7 @@ /* * Globals */ -int fdebug = 0; -SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; +static oHpiCommonOptionsT copt; SaHpiSessionIdT sessionid; @@ -56,11 +64,12 @@ main(int argc, char **argv) { SaErrorT rv = SA_OK; - oHpiGlobalParamTypeT paramtype = OHPI_CONF; char setparam[OH_PATH_PARAM_MAX_LENGTH]; SaHpiBoolT printusage = FALSE; int i=1; + GError *error = NULL; + GOptionContext *context; enum cmdT {eUndefined, eGlobalParamGet, @@ -68,13 +77,25 @@ oh_prog_version(argv[0], OH_SVN_REV); + /* Parse common options */ + context = g_option_context_new ("command [specific arguments] - " + "Control openhpi configuration parameters.\n\n" + OHPARAM_HELP ); + + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION // not applicable + - OHC_VERBOSE_OPTION, // no verbose mode + error)) { + g_print ("option parsing failed: %s\n", error->message); + printusage = TRUE; + } + g_option_context_free (context); + + /* Parse ohparam specific commands */ while (i<argc && !printusage) { - if (strcmp(argv[i],"-D")==0) { - if (++i<argc) domainid = atoi(argv[i]); - else printusage = TRUE; - } - else if (strcmp(argv[i],"-x")==0) fdebug=1; - else if (strcmp(argv[i],"get")==0) { + if (strcmp(argv[i],"get")==0) { cmd=eGlobalParamGet; } else if (strcmp(argv[i],"set")==0) { @@ -118,40 +139,18 @@ if (printusage == TRUE || cmd == eUndefined) { printf("\n"); - printf("Usage: %s [-D domain] [-x] command [specific arguments]\n\n", + printf("Usage: %s [-D nn] [-X] command [specific arguments]\n\n", argv[0]); - printf(" -D nn Select domain id nn (not supported yet by oh-functions)\n"); - printf(" -x Display debug messages\n"); - printf("\n"); - printf(" Command get: display info about all global parameters\n"); - printf(" no specific arguments\n"); - printf(" Command set:\n"); - printf(" one of the daemon's global parameters:\n"); - printf(" (without the OPENHPI prefix)\n"); - printf(" ON_EP, LOG_ON_SEV, EVT_QUEUE_LIMIT, \n"); - printf(" DEL_SIZE_LIMIT, DEL_SAVE\n"); - printf(" DAT_SIZE_LIMIT, DAT_USER_LIMIT, DAT_SAVE\n"); - printf(" PATH, VARPATH, CONF\n"); - printf(" and the desired new value. Example:\n"); - printf(" ohparam set DEL_SIZE_LIMIT 20000\n"); - printf("\n\n"); + printf(OHPARAM_HELP"\n"); + printf(" Options: \n"); + printf(" -h, --help Show help options \n"); + printf(" -D, --domain=nn Select domain id nn \n"); + printf(" -X, --debug Display debug messages \n\n"); exit(1); } - if (fdebug) { - if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) - printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",domainid); - } - rv = saHpiSessionOpen(domainid,&sessionid,NULL); - if (rv != SA_OK) { - printf("saHpiSessionOpen returns %d (%s)\n", - rv, oh_lookup_error(rv)); - exit(-1); - } - if (fdebug) - printf("saHpiSessionOpen returns with SessionId %u\n", - sessionid); + rv = ohc_session_open_by_option ( &copt, &sessionid); + if (rv != SA_OK) exit(-1); switch (cmd){ case eGlobalParamGet: @@ -183,7 +182,7 @@ SaErrorT rv = SA_OK; oHpiGlobalParamT param; - if (fdebug) printf("Go and read global parameters in domain %u\n", domainid); + if (copt.debug) printf("Go and read global parameters in domain %u\n", copt.domainid); param.Type = OHPI_ON_EP; rv = oHpiGlobalParamGet (sessionid, ¶m); @@ -301,7 +300,7 @@ oHpiGlobalParamT param; SaHpiTextBufferT buffer; - if (fdebug) printf("Go and set global parameter %u in domain %u to %s\n", ptype, domainid, setparam); + if (copt.debug) printf("Go and set global parameter %u in domain %u to %s\n", ptype, copt.domainid, setparam); param.Type = ptype; switch (ptype){ Modified: openhpi/trunk/docs/man/hpiwdt.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiwdt.pod.1 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/docs/man/hpiwdt.pod.1 2011-02-03 14:27:46 UTC (rev 7268) @@ -4,7 +4,8 @@ =head1 SYNOPSIS -hpiwdt [-D domain] [-derx -t sec] + hpiwdt [-D nn] [-der -t sec] [-X] [-h] + hpiwdt [--domain=nn] [--disable][--enable][--reset][--timout n] [--debug] [--help] =head1 DESCRIPTION @@ -17,12 +18,13 @@ =over 2 - -D domainid selects the domain - -e enables the watchdog timer - -d disables the watchdog timer - -r resets the watchdog timer - -t N sets timeout to N seconds - -x show eXtra debug messages + -h, --help Show help options + -e, --enable enables the watchdog timer + -d, --disable disables the watchdog timer + -r, --reset resets the watchdog timer + -t, --timeout=n sets timeout to n seconds + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages =back @@ -32,7 +34,7 @@ hpialarms hpifan hpipower hpithres hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpitree - hpievents hpionIBMblade hpisettime + hpievents hpionIBMblade hpisettime hpixml ohdomainlist ohhandler ohparam Modified: openhpi/trunk/docs/man/ohdomainlist.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohdomainlist.pod.1 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/docs/man/ohdomainlist.pod.1 2011-02-03 14:27:46 UTC (rev 7268) @@ -5,7 +5,8 @@ =head1 SYNOPSIS -hpidomain [-D id] [-t tag] [-v -x] + hpidomain [-h -V -X] + hpidomain [--help] [--verbose] [--debug] =head1 DESCRIPTION @@ -19,11 +20,14 @@ Dynamic changes of the domain list done using the oHpiDomainAdd and oHpiDomainAddById API are valid only for the life-time of the client library. +=head1 OPTIONS + =over 2 (No Option) Display domain info - -v Verbose: Display domain info for all domains found in DRT - -x Display debug messages + -h, --help Show help options + -X, --debug Display debug messages + -V, --verbose Verbose mode =back @@ -35,7 +39,7 @@ hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt - + hpixml ohhandler ohparam Modified: openhpi/trunk/docs/man/ohhandler.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohhandler.pod.1 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/docs/man/ohhandler.pod.1 2011-02-03 14:27:46 UTC (rev 7268) @@ -4,14 +4,17 @@ =head1 SYNOPSIS - ohhandler [-D domain] [-x] list - ohhandler [-D domain] [-x] info <handler-id> - ohhandler [-D domain] [-x] destroy <handler-id> - ohhandler [-D domain] [-x] getnext <handler-id> - ohhandler [-D domain] [-x] find <resource-id> - ohhandler [-D domain] [-x] retry <handler-id> - ohhandler [-D domain] [-x] create plugin <plugin-name> <configuration-parameters> + ohhandler [-D nn] [-X] command <specific arguments> + ohhandler [--domain nn] [--debug] command <specific arguments> + ohhandler [-D nn] [-x] list + ohhandler [-D nn] [-x] info <handler-id> + ohhandler [-D nn] [-x] destroy <handler-id> + ohhandler [-D nn] [-x] getnext <handler-id> + ohhandler [-D nn] [-x] find <resource-id> + ohhandler [-D nn] [-x] retry <handler-id> + ohhandler [-D nn] [-x] create plugin <plugin-name> <configuration-parameters> + =head1 DESCRIPTION ohhandler list will display a list of all plugin instances (handlers) currently defined in the openhpi daemon for the specified domain. Part of the output is the handler-id that can be used in subsequent commands. @@ -39,19 +42,21 @@ =over 2 - -D <domainid> select domain id - -x display debug messages. - -h help + -h, --help Show help options + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages =back =head1 SEE ALSO hpi_shell - hpialarms hpigensimdata hpireset hpitop - hpidomain hpiinv hpisensor hpitree - hpiel hpionIBMblade hpisettime hpiwdt - hpievents hpipower hpithres + + hpialarms hpifan hpipower hpithres + hpidomain hpigensimdata hpireset hpitop + hpiel hpiiinv hpisensor hpitree + hpievents hpionIBMblade hpisettime hpiwdt + hpixml ohdomainlist ohparam Modified: openhpi/trunk/docs/man/ohparam.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohparam.pod.1 2011-02-02 14:51:27 UTC (rev 7267) +++ openhpi/trunk/docs/man/ohparam.pod.1 2011-02-03 14:27:46 UTC (rev 7268) @@ -4,8 +4,10 @@ =head1 SYNOPSIS - ohparam [-D domain] [-x] get - ohparam [-D domain] [-x] set <paramname newvalue> + ohparam [-D nn] [-X] get + ohparam [-D nn] [-X] set <paramname newvalue> + ohparam [--domain nn] [--debug] get + ohparam [--domain nn] [--debug] set <paramname newvalue> =head1 DESCRIPTION @@ -15,23 +17,44 @@ If no domain is selected, ohparam uses the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +=head1 COMMANDS + +=over 2 + + Command get: display info about all global parameters + no specific arguments + + Command set: + one of the daemon's global parameters: + (without the OPENHPI prefix) + ON_EP, LOG_ON_SEV, EVT_QUEUE_LIMIT, + DEL_SIZE_LIMIT, DEL_SAVE + DAT_SIZE_LIMIT, DAT_USER_LIMIT, DAT_SAVE + PATH, VARPATH, CONF + and the desired new value. Example: + ohparam set DEL_SIZE_LIMIT 20000 + +=back + =head1 OPTIONS =over 2 - -D <domainid> select domain id - -x display debug messages. - -h help + -h, --help Show help options + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages =back =head1 SEE ALSO hpi_shell - hpialarms hpigensimdata hpireset hpitop - hpidomain hpiinv hpisensor hpitree - hpiel hpionIBMblade hpisettime hpiwdt - hpievents hpipower hpithres + + hpialarms hpifan hpipower hpithres + hpidomain hpigensimdata hpireset hpitop + hpiel hpiiinv hpisensor hpitree + hpievents hpionIBMblade hpisettime hpiwdt + hpixml ohdomainlist ohhandler This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-02-08 23:13:44
|
Revision: 7269 http://openhpi.svn.sourceforge.net/openhpi/?rev=7269&view=rev Author: avpak Date: 2011-02-08 23:13:37 +0000 (Tue, 08 Feb 2011) Log Message: ----------- Feature request #3129977 Command line options -4 and -6 for IPv4 and IPv6 implemented in openhpid. Modified Paths: -------------- openhpi/trunk/docs/man/openhpid.pod.8 openhpi/trunk/openhpid/openhpid-posix.cpp openhpi/trunk/openhpid/openhpid-win32.cpp openhpi/trunk/openhpid/server.cpp openhpi/trunk/openhpid/server.h openhpi/trunk/transport/strmsock.cpp openhpi/trunk/transport/strmsock.h Modified: openhpi/trunk/docs/man/openhpid.pod.8 =================================================================== --- openhpi/trunk/docs/man/openhpid.pod.8 2011-02-03 14:27:46 UTC (rev 7268) +++ openhpi/trunk/docs/man/openhpid.pod.8 2011-02-08 23:13:37 UTC (rev 7269) @@ -62,6 +62,18 @@ Display verbose messages +=item -4 + +The daemon will try to bind IPv4 socket. + +=item -6 + +The daemon will try to bind IPv6 socket. + +=item -4 -6 + +The daemon will try to bind IPv4 or IPv6 socket. + =back =head1 ENVIRONMENTAL VARIABLES Modified: openhpi/trunk/openhpid/openhpid-posix.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid-posix.cpp 2011-02-03 14:27:46 UTC (rev 7268) +++ openhpi/trunk/openhpid/openhpid-posix.cpp 2011-02-08 23:13:37 UTC (rev 7269) @@ -36,6 +36,7 @@ #include <oHpi.h> #include <oh_error.h> +#include <strmsock.h> #include "init.h" #include "server.h" @@ -71,6 +72,9 @@ printf(" -n Forces the code to run as a foreground process\n"); printf(" and NOT as a daemon. The default is to run as\n"); printf(" a daemon. The option is optional.\n\n"); + printf(" -4 The daemon will try to bind IPv4 socket.\n"); + printf(" -6 The daemon will try to bind IPv6 socket.\n"); + printf(" -4 -6 The daemon will try to bind IPv4 or IPv6 socket.\n"); printf("A typical invocation might be\n\n"); printf(" ./openhpid -c /etc/openhpi/openhpi.conf\n\n"); } @@ -247,6 +251,8 @@ struct option options[] = { {"verbose", no_argument, 0, 'v'}, {"nondaemon", no_argument, 0, 'n'}, + {"ipv4", no_argument, 0, '4'}, + {"ipv6", no_argument, 0, '6'}, {"cfg", required_argument, 0, 'c'}, {"port", required_argument, 0, 'p'}, {"pidfile", required_argument, 0, 'f'}, @@ -261,11 +267,12 @@ unsigned int sock_timeout = 0; // unlimited int max_threads = -1; // unlimited bool runasdaemon = true; + int ipvflags = 0; /* get the command line options */ int c; while (1) { - c = getopt_long(argc, argv, "nvc:p:f:s:t:", options, 0); + c = getopt_long(argc, argv, "nv46c:p:f:s:t:", options, 0); /* detect when done scanning options */ if (c == -1) { break; @@ -300,6 +307,12 @@ case 'n': runasdaemon = false; break; + case '4': + ipvflags |= FlagIPv4; + break; + case '6': + ipvflags |= FlagIPv6; + break; case '?': default: /* they obviously need it */ @@ -313,6 +326,10 @@ exit(-1); } + if (ipvflags == 0) { + ipvflags = FlagIPv4; + } + // see if we have a valid configuration file if ((!cfgfile) || (!g_file_test(cfgfile, G_FILE_TEST_EXISTS))) { CRIT("Cannot find configuration file. Exiting."); @@ -347,8 +364,11 @@ INFO("%s version %s started.", argv[0], VERSION); INFO("OPENHPI_CONF = %s.", cfgfile); INFO("OPENHPI_DAEMON_PORT = %u", port); + INFO("Enabled IP versions:%s%s\n", + (ipvflags & FlagIPv4) ? " IPv4" : "", + (ipvflags & FlagIPv6) ? " IPv6" : ""); - bool rc = oh_server_run(port, sock_timeout, max_threads); + bool rc = oh_server_run(ipvflags, port, sock_timeout, max_threads); if (!rc) { return 9; } Modified: openhpi/trunk/openhpid/openhpid-win32.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid-win32.cpp 2011-02-03 14:27:46 UTC (rev 7268) +++ openhpi/trunk/openhpid/openhpid-win32.cpp 2011-02-08 23:13:37 UTC (rev 7269) @@ -24,6 +24,7 @@ #include <oHpi.h> #include <oh_error.h> +#include <strmsock.h> #include "init.h" #include "server.h" @@ -57,6 +58,9 @@ printf(" -n Forces the code to run as a foreground process\n"); printf(" and NOT as a daemon. The default is to run as\n"); printf(" a daemon. The option is optional.\n\n"); + printf(" -4 The daemon will try to bind IPv4 socket.\n"); + printf(" -6 The daemon will try to bind IPv6 socket.\n"); + printf(" -4 -6 The daemon will try to bind IPv4 or IPv6 socket.\n"); printf("A typical invocation might be\n\n"); printf(" openhpid.exe -c C:\\openhpi.conf\n\n"); } @@ -128,6 +132,8 @@ struct option options[] = { {"verbose", no_argument, 0, 'v'}, {"nondaemon", no_argument, 0, 'n'}, + {"ipv4", no_argument, 0, '4'}, + {"ipv6", no_argument, 0, '6'}, {"cfg", required_argument, 0, 'c'}, {"port", required_argument, 0, 'p'}, {"timeout", required_argument, 0, 's'}, @@ -140,11 +146,12 @@ unsigned int sock_timeout = 0; // unlimited int max_threads = -1; // unlimited //bool runasdaemon = true; + int ipvflags = 0; /* get the command line options */ int c; while (1) { - c = getopt_long(argc, argv, "nvc:p:f:s:t:", options, 0); + c = getopt_long(argc, argv, "nv46c:p:f:s:t:", options, 0); /* detect when done scanning options */ if (c == -1) { break; @@ -157,7 +164,7 @@ setenv("OPENHPI_CONF", optarg); cfgfile = g_strdup(optarg); break; - case 'p': + case 'P': setenv("OPENHPI_DAEMON_PORT", optarg); port = atoi(optarg); break; @@ -176,6 +183,12 @@ case 'n': //runasdaemon = false; break; + case '4': + ipvflags |= FlagIPv4; + break; + case '6': + ipvflags |= FlagIPv6; + break; case '?': default: /* they obviously need it */ @@ -189,6 +202,10 @@ exit(-1); } + if (ipvflags == 0) { + ipvflags = FlagIPv4; + } + // see if we have a valid configuration file if ((!cfgfile) || (!g_file_test(cfgfile, G_FILE_TEST_EXISTS))) { CRIT("Cannot find configuration file. Exiting."); @@ -205,8 +222,12 @@ INFO("%s version %s started.", argv[0], VERSION); INFO("OPENHPI_CONF = %s.", cfgfile); INFO("OPENHPI_DAEMON_PORT = %u.", port); + INFO("Enabled IP versions:%s%s\n", + (ipvflags & FlagIPv4) ? " IPv4" : "", + (ipvflags & FlagIPv6) ? " IPv6" : ""); - bool rc = oh_server_run(port, sock_timeout, max_threads); + + bool rc = oh_server_run(ipvflags, port, sock_timeout, max_threads); if (!rc) { return 9; } Modified: openhpi/trunk/openhpid/server.cpp =================================================================== --- openhpi/trunk/openhpid/server.cpp 2011-02-03 14:27:46 UTC (rev 7268) +++ openhpi/trunk/openhpid/server.cpp 2011-02-08 23:13:37 UTC (rev 7269) @@ -75,13 +75,14 @@ /* HPI Server Interface */ /*--------------------------------------------------------------------*/ -bool oh_server_run( uint16_t port, +bool oh_server_run( int ipvflags, + uint16_t port, unsigned int sock_timeout, int max_threads ) { // create the server socket cServerStreamSock ssock; - if (!ssock.Create(port)) { + if (!ssock.Create(ipvflags, port)) { CRIT("Error creating server socket. Exiting."); return false; } Modified: openhpi/trunk/openhpid/server.h =================================================================== --- openhpi/trunk/openhpid/server.h 2011-02-03 14:27:46 UTC (rev 7268) +++ openhpi/trunk/openhpid/server.h 2011-02-08 23:13:37 UTC (rev 7269) @@ -19,8 +19,11 @@ #include <stdint.h> +#include <strmsock.h> -bool oh_server_run( uint16_t port, + +bool oh_server_run( int ipvflags, + uint16_t port, unsigned int sock_timeout, int max_threads ); Modified: openhpi/trunk/transport/strmsock.cpp =================================================================== --- openhpi/trunk/transport/strmsock.cpp 2011-02-03 14:27:46 UTC (rev 7268) +++ openhpi/trunk/transport/strmsock.cpp 2011-02-08 23:13:37 UTC (rev 7269) @@ -19,6 +19,8 @@ #include <stdio.h> #include <string.h> +#include <list> + #ifdef _WIN32 #include <winsock2.h> #include <ws2tcpip.h> @@ -64,13 +66,12 @@ /*************************************************************** * Helper functions **************************************************************/ -static void SelectAddresses( int hintflags, +static void SelectAddresses( int ipvflags, + int hintflags, const char * node, uint16_t port, - struct addrinfo * & selected ) + std::list<struct addrinfo *>& selected ) { - selected = 0; - struct addrinfo hints; memset( &hints, 0, sizeof(hints) ); hints.ai_flags = hintflags; @@ -88,36 +89,19 @@ return; } - struct addrinfo * in = 0; - struct addrinfo * in_tail = 0; - struct addrinfo * out = 0; - struct addrinfo * out_tail = 0; - for ( struct addrinfo * item = items; item != 0; item = item->ai_next ) { - if ( ( item->ai_family == AF_INET ) || ( item->ai_family == AF_INET6 ) ) { - if ( in_tail ) { - in_tail->ai_next = item; - in_tail = item; - } else { - in = in_tail = item; - } + for ( struct addrinfo * item = items; item != 0; ) { + struct addrinfo * next = item->ai_next; + item->ai_next = 0; + if ( ( ipvflags & FlagIPv4 ) && ( item->ai_family == AF_INET ) ) { + selected.push_back( item ); + } else if ( ( ipvflags & FlagIPv6 ) && ( item->ai_family == AF_INET6 ) ) { + selected.push_back( item ); } else { - if ( out_tail ) { - out_tail->ai_next = item; - out_tail = item; - } else { - out = out_tail = item; - } + freeaddrinfo( item ); } - } - if ( in_tail ) { - in_tail->ai_next = 0; - } - if ( out_tail ) { - out_tail->ai_next = 0; - freeaddrinfo( out ); - } - selected = in; + item = next; + } } @@ -325,24 +309,21 @@ bool cClientStreamSock::Create( const char * host, uint16_t port ) { - struct addrinfo * infos; - SelectAddresses( 0, host, port, infos ); - if ( infos == 0 ) { - CRIT( "failed to find sockaddr." ); - return false; - } - bool connected = false; struct addrinfo * info; - for ( info = infos; info != 0; info = info->ai_next ) { - connected = Create( info ); - if ( connected ) { - break; + std::list<struct addrinfo *> infos; + + SelectAddresses( FlagIPv4 | FlagIPv6, 0, host, port, infos ); + + while ( !infos.empty() ) { + info = *infos.begin(); + if ( !connected ) { + connected = Create( info ); } + freeaddrinfo( info ); + infos.pop_front(); } - freeaddrinfo( infos ); - return connected; } @@ -422,26 +403,23 @@ // empty } -bool cServerStreamSock::Create( uint16_t port ) +bool cServerStreamSock::Create( int ipvflags, uint16_t port ) { - struct addrinfo * infos; - SelectAddresses( AI_PASSIVE, 0, port, infos ); - if ( infos == 0 ) { - CRIT( "failed to find sockaddr." ); - return false; - } - bool bound = false; struct addrinfo * info; - for ( info = infos; info != 0; info = info->ai_next ) { - bound = Create( info ); - if ( bound ) { - break; + std::list<struct addrinfo *> infos; + + SelectAddresses( ipvflags, AI_PASSIVE, 0, port, infos ); + + while ( !infos.empty() ) { + info = *infos.begin(); + if ( !bound ) { + bound = Create( info ); } + freeaddrinfo( info ); + infos.pop_front(); } - freeaddrinfo( infos ); - return bound; } Modified: openhpi/trunk/transport/strmsock.h =================================================================== --- openhpi/trunk/transport/strmsock.h 2011-02-03 14:27:46 UTC (rev 7268) +++ openhpi/trunk/transport/strmsock.h 2011-02-08 23:13:37 UTC (rev 7269) @@ -33,6 +33,16 @@ /*************************************************************** + * IPv4 / IPv6 + **************************************************************/ +typedef enum +{ + FlagIPv4 = 1, + FlagIPv6 = 2 +} IPvFlags; + + +/*************************************************************** * Message Header **************************************************************/ typedef struct @@ -152,7 +162,7 @@ explicit cServerStreamSock(); ~cServerStreamSock(); - bool Create( uint16_t port ); + bool Create( int ipvflags, uint16_t port ); cStreamSock * Accept(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-02-14 12:53:13
|
Revision: 7273 http://openhpi.svn.sourceforge.net/openhpi/?rev=7273&view=rev Author: ulikleber Date: 2011-02-14 12:53:05 +0000 (Mon, 14 Feb 2011) Log Message: ----------- more on feature 1493787. hpi_shell and hpixml use common options. Options -C and -N of hpi_shell made available for all clients. Bad exit statements replaced. Modified Paths: -------------- openhpi/trunk/Makefile.am openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpialarms.c openhpi/trunk/clients/hpidomain.c openhpi/trunk/clients/hpiel.c openhpi/trunk/clients/hpievents.c openhpi/trunk/clients/hpifan.c openhpi/trunk/clients/hpigensimdata.c openhpi/trunk/clients/hpiinv.c openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/hpipower.c openhpi/trunk/clients/hpireset.c openhpi/trunk/clients/hpisensor.c openhpi/trunk/clients/hpisettime.c openhpi/trunk/clients/hpithres.c openhpi/trunk/clients/hpitop.c openhpi/trunk/clients/hpitree.c openhpi/trunk/clients/hpiwdt.c openhpi/trunk/clients/hpixml/Makefile.am openhpi/trunk/clients/hpixml/hpi.cpp openhpi/trunk/clients/hpixml/hpi.h openhpi/trunk/clients/hpixml/main.cpp openhpi/trunk/clients/oh_clients.h openhpi/trunk/clients/ohdomainlist.c openhpi/trunk/clients/ohhandler.c openhpi/trunk/clients/ohparam.c openhpi/trunk/configure.ac openhpi/trunk/hpi_shell/Makefile.am openhpi/trunk/hpi_shell/hpi_cmd.c Modified: openhpi/trunk/Makefile.am =================================================================== --- openhpi/trunk/Makefile.am 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/Makefile.am 2011-02-14 12:53:05 UTC (rev 7273) @@ -52,7 +52,7 @@ mingw32/openhpi.windows.libraries.manifest \ mingw32/openhpi.windows.plugins.manifest \ mingw32/openhpid.manifest \ - $(shell find $(srcdir)/include -name '*.h') + $(shell find $(srcdir)/include -name '*.h') AUTOMAKE_OPTIONS = foreign @@ -112,7 +112,8 @@ $(top_srcdir)/utils/uid_utils.h \ $(top_srcdir)/utils/epath_utils.h \ $(top_srcdir)/utils/el_utils.h \ - $(top_srcdir)/utils/event_utils.h + $(top_srcdir)/utils/event_utils.h \ + $(top_srcdir)/clients/oh_clients.h docsdir=$(datadir)/doc/$(PACKAGE_NAME)-$(VERSION) docs_DATA = README README.daemon COPYING Modified: openhpi/trunk/clients/clients.c =================================================================== --- openhpi/trunk/clients/clients.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/clients.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -29,6 +29,7 @@ static gboolean optverbose = FALSE; static gchar *optep = NULL; static gchar *optdaemon = NULL; +static gchar *optcfgfile = NULL; static GOptionEntry domain_option[] = { @@ -55,12 +56,17 @@ }; // Preparation for option -N / --host (Features 2726603 & 3129972 & 3129967) -//static GOptionEntry host_option[] = -//{ -// { "host", 'N', 0, G_OPTION_ARG_STRING, &optdaemon, "Connect to daemon host:port", "\"host<:port>\"" }, -// { NULL } -//}; +static GOptionEntry host_option[] = +{ + { "host", 'N', 0, G_OPTION_ARG_STRING, &optdaemon, "Connect to daemon host:port", "\"host<:port>\"" }, + { NULL } +}; +static GOptionEntry clientconf_option[] = +{ + { "cfgfile", 'C', 0, G_OPTION_ARG_FILENAME, &optcfgfile, "Use passed file as client configuration file", "\"file\"" }, + { NULL } +}; void oh_prog_version(const char *prog_name, const char *svn_rev_str) @@ -74,8 +80,11 @@ strncpy(svn_rev, svn_rev_str, SAHPI_MAX_TEXT_BUFFER_LENGTH); svn_rev[strlen(svn_rev_str)-2] = '\0'; - printf("%s (rev %s) - This program came with OpenHPI %u.%u.%u\n", - prog_name, svn_rev+11, ohpi_major, ohpi_minor, ohpi_patch); + // Revision not printed here any more + //printf("%s (rev %s) - This program came with OpenHPI %u.%u.%u\n", + // prog_name, svn_rev+11, ohpi_major, ohpi_minor, ohpi_patch); + printf("%s - This program came with OpenHPI %u.%u.%u\n", + prog_name, ohpi_major, ohpi_minor, ohpi_patch); hpiver = saHpiVersionGet(); printf("SAF HPI Version %c.0%d.0%d\n\n", (hpiver >> 16) + ('A' - 1), @@ -83,7 +92,6 @@ hpiver & 0x000000FF); } - gboolean ohc_option_parse(int *argc, char *argv[], GOptionContext *context, oHpiCommonOptionsT *common_options, @@ -93,8 +101,8 @@ SaErrorT rv = SA_OK; if (!argc || !argv || !context || !common_options) { - g_print ("Internal error. Terminating.\n"); - exit (1); + CRIT ("Internal error. Terminating.\n"); + return FALSE; } if (optionmask & OHC_DOMAIN_OPTION) @@ -106,25 +114,28 @@ if (optionmask & OHC_ENTITY_PATH_OPTION) g_option_context_add_main_entries (context, entity_path_option, NULL); // Preparation for option -N / --host (Features 2726603 & 3129972 & 3129967) -// if (optionmask & OHC_HOST_OPTION) -// g_option_context_add_main_entries (context, host_option, NULL); +// Preliminary implementation like it was in hpi_shell + if (optionmask & OHC_HOST_OPTION) + g_option_context_add_main_entries (context, host_option, NULL); + if (optionmask & OHC_CLIENTCONF_OPTION) + g_option_context_add_main_entries (context, clientconf_option, NULL); if (!g_option_context_parse (context, argc, &argv, &error)) { - g_print ("option parsing failed: %s\n",error->message); - // g_print ("\n%s", g_option_context_get_help (context, FALSE, NULL)); + CRIT ("option parsing failed: %s\n",error->message); + // CRIT ("\n%s", g_option_context_get_help (context, FALSE, NULL)); // Needs glib-2.14 - exit (1); + return FALSE; } common_options->withentitypath = (optep != NULL); common_options->withdaemonhost = (optdaemon != NULL); if (optdebug && optverbose) { - g_print("Parsing of options completed. Common options:\n --debug --verbose"); - if (optdid >= 0) g_print(" --domain=%u ",optdid); - if (common_options->withentitypath) g_print(" --entity-path=%s ",optep); - if (common_options->withdaemonhost) g_print(" --daemon=%s ",optdaemon); - g_print("\n"); + DBG("Parsing of options completed. Common options:\n --debug --verbose"); + if (optdid >= 0) DBG(" --domain=%u ",optdid); + if (common_options->withentitypath) DBG(" --entity-path=%s ",optep); + if (common_options->withdaemonhost) DBG(" --daemon=%s ",optdaemon); + DBG("\n"); } /* prepare output */ @@ -136,35 +147,44 @@ if (common_options->withentitypath) { rv = oh_encode_entitypath(optep, &common_options->entitypath); if (error) { - g_print("Invalid entity path: %s\n" + CRIT ("Invalid entity path: %s\n" "oh_encode_entitypath() returned %s \n", optep, oh_lookup_error(rv)); - exit (1); + return FALSE; } if (optdebug && optverbose) { - g_print("Entity Path encoded successfully: "); + DBG("Entity Path encoded successfully: "); oh_print_ep(&common_options->entitypath, 0); - g_print("\n"); + DBG("\n"); } } - + oh_init_textbuffer(&common_options->daemonhost); if (common_options->withdaemonhost) { char *colon=strchr(optdaemon, ':'); if (colon!=NULL) { *colon = '\0'; common_options->daemonport = atoi(++colon); + setenv("OPENHPI_DAEMON_PORT", colon, 1); } else common_options->daemonport = OPENHPI_DEFAULT_DAEMON_PORT; + setenv("OPENHPI_DAEMON_HOST", optdaemon, 1); // copied from hpi_shell rv = oh_append_textbuffer(&common_options->daemonhost, optdaemon); if (optdebug && optverbose) { - g_print("Daemon host:port scanned successfully: host="); + DBG("Daemon host:port scanned successfully: host="); oh_print_text(&common_options->daemonhost); - g_print(" port=%u\n",common_options->daemonport); + DBG(" port=%u\n",common_options->daemonport); } } + oh_init_textbuffer(&common_options->clientconf); + if (optcfgfile) { + rv = oh_append_textbuffer(&common_options->daemonhost, optcfgfile); + setenv("OPENHPICLIENT_CONF", optcfgfile, 1); // copied from hpi_shell + } + g_free (optep); g_free (optdaemon); + g_free (optcfgfile); return TRUE; } @@ -172,7 +192,7 @@ oHpiCommonOptionsT *opt, SaHpiSessionIdT *sessionid) { - // TODO implement -N option + // TODO correctly implement -N / -C option SaErrorT rv = SA_OK; if (opt->debug) { Modified: openhpi/trunk/clients/hpialarms.c =================================================================== --- openhpi/trunk/clients/hpialarms.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpialarms.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -111,9 +111,8 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 ? - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); @@ -123,7 +122,7 @@ } rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); if (copt.debug) printf("saHpiDiscover complete, rv = %d\n",rv); @@ -245,7 +244,6 @@ rv = saHpiSessionClose(sessionid); - exit(0); return(0); } Modified: openhpi/trunk/clients/hpidomain.c =================================================================== --- openhpi/trunk/clients/hpidomain.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpidomain.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -73,16 +73,15 @@ OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); rv = ohc_session_open_by_option ( &copt, &sessionid); if (rv != SA_OK) { g_free(f_domtag); - exit(-1); + return rv; } if (f_domtag){ @@ -100,7 +99,7 @@ rv = saHpiSessionClose(sessionid); - exit(0); + return 0; } Modified: openhpi/trunk/clients/hpiel.c =================================================================== --- openhpi/trunk/clients/hpiel.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpiel.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -31,7 +31,7 @@ #define err(format, ...) \ do { \ if (copt.debug) { \ - fprintf(stderr, format "\n", ## __VA_ARGS__); \ + CRIT(format "\n", ## __VA_ARGS__); \ } \ } while(0) @@ -40,7 +40,7 @@ if (error) { \ copt.debug = TRUE; \ err(msg, oh_lookup_error(error)); \ - exit(-1); \ + return error; \ } \ } while(0) @@ -95,14 +95,12 @@ - OHC_VERBOSE_OPTION, // no verbose mode implemented gerror)) { g_print ("option parsing failed: %s\n", gerror->message); - g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); /* Program really begins here - all options parsed at this point */ error = ohc_session_open_by_option ( &copt, &sid); - if (error != SA_OK) exit(-1); show_error_quit("saHpiSessionOpen() returned %s. Exiting.\n"); error = saHpiDiscover(sid); @@ -122,11 +120,11 @@ error = harvest_sels(sid, &dinfo); } - if (error) err("An error happened. Gathering event log entries returned %s", + if (error) CRIT("Gathering event log entries returned %s", oh_lookup_error(error)); error = saHpiSessionClose(sid); - if (error) err("saHpiSessionClose() returned %s.", + if (error) CRIT("saHpiSessionClose() returned %s.", oh_lookup_error(error)); return error; Modified: openhpi/trunk/clients/hpievents.c =================================================================== --- openhpi/trunk/clients/hpievents.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpievents.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -75,9 +75,8 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); @@ -102,30 +101,30 @@ (uint64_t) timeout); rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return -1; if (!do_discover_after_subscribe) { if (copt.debug) printf("saHpiDiscover\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { - printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); - exit(-1); + CRIT("saHpiDiscover: %s\n", oh_lookup_error(rv)); + return rv; } } if (copt.debug) printf( "Subscribe to events\n"); rv = saHpiSubscribe( sessionid ); if (rv != SA_OK) { - printf("saHpiSubscribe: %s\n", oh_lookup_error(rv)); - exit(-1); + CRIT("saHpiSubscribe: %s\n", oh_lookup_error(rv)); + return rv; } if (do_discover_after_subscribe) { if (copt.debug) printf("saHpiDiscover after saHpiSubscribe\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { - printf("saHpiDiscover after saHpiSubscribe: %s\n", oh_lookup_error(rv)); - exit(-1); + CRIT("saHpiDiscover after saHpiSubscribe: %s\n", oh_lookup_error(rv)); + return rv; } } Modified: openhpi/trunk/clients/hpifan.c =================================================================== --- openhpi/trunk/clients/hpifan.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpifan.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -242,9 +242,8 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); @@ -257,16 +256,16 @@ } else { new_speed = atoi( f_speed ); if (new_speed == 0) { - g_print ("please enter a valid speed: \"auto\" or a number.\n"); + CRIT ("please enter a valid speed: \"auto\" or a number.\n"); g_free (f_speed); - exit(1); + return 1; } } g_free(f_speed); } rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; /* * Resource discovery @@ -274,8 +273,8 @@ if (copt.debug) printf("saHpiDiscover\n"); rv = saHpiDiscover(sessionid); if ( rv != SA_OK ) { - printf( "saHpiDiscover: %s\n", oh_lookup_error( rv ) ); - return 1; + CRIT( "saHpiDiscover: %s\n", oh_lookup_error( rv ) ); + return rv; } if (copt.debug) printf("Discovery done\n"); @@ -283,7 +282,7 @@ rv = saHpiSessionClose( sessionid ); if ( rv != SA_OK ) - printf( "saHpiSessionClose: %s\n", oh_lookup_error( rv ) ); + CRIT( "saHpiSessionClose: %s\n", oh_lookup_error( rv ) ); return rc; } Modified: openhpi/trunk/clients/hpigensimdata.c =================================================================== --- openhpi/trunk/clients/hpigensimdata.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpigensimdata.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -312,9 +312,8 @@ - OHC_VERBOSE_OPTION // no verbose mode - OHC_DEBUG_OPTION, // no debug mode error)) { - g_print ("option parsing failed: %s\n", error->message); GFREE - exit(1); + return 1; } GFREE @@ -323,7 +322,7 @@ if (outfile == NULL) { fprintf(stderr, "\n%s couldn't be opened for writing.\n", g_file); GFREE - exit(1); + return 1; } } @@ -341,7 +340,7 @@ fprintf(stderr, "\nUnknown mode %s.\n", g_mode); if (g_file) fclose(outfile); GFREE - exit (1); + return 1; } } @@ -362,7 +361,7 @@ if (rv != SA_OK) { if (g_file) fclose(outfile); GFREE - exit(-1); + return rv; } /* @@ -373,14 +372,14 @@ printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); if (g_file) fclose(outfile); GFREE - exit(-1); + return rv; } print_resources(outfile, 0, sessionid, (SaHpiResourceIdT) g_resourceid); rv = saHpiSessionClose(sessionid); if (g_file) fclose(outfile); GFREE - exit(0); + return 0; } Modified: openhpi/trunk/clients/hpiinv.c =================================================================== --- openhpi/trunk/clients/hpiinv.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpiinv.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -487,9 +487,8 @@ OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); if (fatag) { @@ -503,7 +502,7 @@ inv = (SaHpiIdrAreaHeaderT *)(void *)&inbuff[0]; rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; rv = saHpiDomainInfoGet(sessionid,&rptinfo); if (copt.debug) printf("saHpiDomainInfoGet rv = %d\n",rv); @@ -621,6 +620,6 @@ if (copt.debug) printf("loop %u inventory found = %d\n",nloops,invfound); } /*end while no inv */ rv = saHpiSessionClose(sessionid); - exit(0); + return 0; } /* end hpifru.c */ Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpionIBMblade.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -910,9 +910,8 @@ - OHC_ENTITY_PATH_OPTION // not implemented - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); @@ -923,7 +922,7 @@ } rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); @@ -932,7 +931,7 @@ rv = saHpiSubscribe(sessionid); if (rv != SA_OK) { printf( "saHpiSubscribe error %d\n",rv); - return(-1); + return rv; } /* make the RPT list */ Modified: openhpi/trunk/clients/hpipower.c =================================================================== --- openhpi/trunk/clients/hpipower.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpipower.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -113,9 +113,8 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); if (f_down) { @@ -139,8 +138,8 @@ SelectedSystem = f_blade - 1; //Normalizing to 0...n-1 if ((SelectedSystem > MAX_MANAGED_SYSTEMS) || (SelectedSystem < 0)) { - printf("hpipower: blade number out of range"); - exit(1); //When we exit here, there is nothing to clean up + CRIT("hpipower: blade number out of range"); + return 1; //When we exit here, there is nothing to clean up } } Modified: openhpi/trunk/clients/hpireset.c =================================================================== --- openhpi/trunk/clients/hpireset.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpireset.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -71,16 +71,15 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127? - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); if (f_warm) action = SAHPI_WARM_RESET; rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); if (copt.debug) printf("saHpiDiscover rv = %d\n",rv); Modified: openhpi/trunk/clients/hpisensor.c =================================================================== --- openhpi/trunk/clients/hpisensor.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpisensor.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -226,14 +226,13 @@ OHC_ALL_OPTIONS - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; if (copt.debug) printf("Starting Discovery ...\n"); @@ -303,7 +302,6 @@ rv = saHpiSessionClose(sessionid); - exit(0); return(0); } Modified: openhpi/trunk/clients/hpisettime.c =================================================================== --- openhpi/trunk/clients/hpisettime.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpisettime.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -59,7 +59,7 @@ { NULL } }; -#define EXIT1 g_free(findate);g_free(fintime);exit(1); +#define EXIT1 g_free(findate);g_free(fintime);return 1; int main(int argc, char **argv) Modified: openhpi/trunk/clients/hpithres.c =================================================================== --- openhpi/trunk/clients/hpithres.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpithres.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -655,14 +655,13 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); @@ -671,7 +670,7 @@ rv = saHpiSubscribe(sessionid); if (rv != SA_OK) { printf( "saHpiSubscribe error %d\n",rv); - return(-1); + return rv; } /* make the RPT list */ Modified: openhpi/trunk/clients/hpitop.c =================================================================== --- openhpi/trunk/clients/hpitop.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpitop.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -143,9 +143,8 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); @@ -156,7 +155,7 @@ memset (previous_system, 0, SAHPI_MAX_TEXT_BUFFER_LENGTH); rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; /* * Resource discovery @@ -165,7 +164,7 @@ rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); - exit(-1); + return rv; } if (copt.debug) printf("Discovery done\n"); @@ -173,7 +172,7 @@ rv = saHpiSessionClose(sessionid); - exit(0); + return 0; } Modified: openhpi/trunk/clients/hpitree.c =================================================================== --- openhpi/trunk/clients/hpitree.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpitree.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -146,9 +146,8 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127? - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); @@ -156,7 +155,7 @@ f_listall = TRUE; rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; /* * Resource discovery @@ -165,7 +164,7 @@ rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); - exit(-1); + return rv; } printf("Discovery done\n"); @@ -173,7 +172,7 @@ rv = saHpiSessionClose(sessionid); - exit(0); + return 0; } Modified: openhpi/trunk/clients/hpiwdt.c =================================================================== --- openhpi/trunk/clients/hpiwdt.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpiwdt.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -126,16 +126,15 @@ - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION, // no verbose mode implemented error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); if (ftimeout == 0) ftimeout = 120; else fenable = TRUE; rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); if (copt.debug) printf("saHpiDiscover rv = %d\n",rv); @@ -214,7 +213,7 @@ rv = saHpiSessionClose(sessionid); - exit(0); + return 0; } /* end hpiwdt.c */ Modified: openhpi/trunk/clients/hpixml/Makefile.am =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.am 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpixml/Makefile.am 2011-02-14 12:53:05 UTC (rev 7273) @@ -20,7 +20,8 @@ schema.h \ schema.S \ xml_writer.cpp \ - xml_writer.h + xml_writer.h \ + $(top_srcdir)/clients/clients.c hpixml_LDADD = $(top_builddir)/baselib/libopenhpi.la Modified: openhpi/trunk/clients/hpixml/hpi.cpp =================================================================== --- openhpi/trunk/clients/hpixml/hpi.cpp 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpixml/hpi.cpp 2011-02-14 12:53:05 UTC (rev 7273) @@ -18,6 +18,7 @@ #include <oh_error.h> #include <oh_utils.h> +#include <oh_clients.h> #include "hpi.h" #include "hpi_xml_writer.h" @@ -374,10 +375,10 @@ /*************************************************** * class cHpi ***************************************************/ -cHpi::cHpi( SaHpiDomainIdT did ) +cHpi::cHpi( oHpiCommonOptionsT copt ) : m_initialized( false ), m_opened( false ), - m_did( did ), + m_copt( copt ), m_sid( 0 ) { // empty @@ -404,9 +405,10 @@ } m_initialized = true; } - rv = saHpiSessionOpen( m_did, &m_sid, 0 ); + + rv = ohc_session_open_by_option ( &m_copt, &m_sid); if ( rv != SA_OK ) { - CRIT( "saHpiSessionOpen returned %s", oh_lookup_error( rv ) ); + CRIT( "saHpiSessionOpen returned %s", oh_lookup_error( rv ) ); return false; } m_opened = true; Modified: openhpi/trunk/clients/hpixml/hpi.h =================================================================== --- openhpi/trunk/clients/hpixml/hpi.h 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpixml/hpi.h 2011-02-14 12:53:05 UTC (rev 7273) @@ -17,6 +17,7 @@ #define HPI_H_EC5AF80F_A79B_49D7_8371_F71504C426A6 #include <SaHpi.h> +#include <oh_clients.h> class cHpiXmlWriter; @@ -28,7 +29,7 @@ { public: - explicit cHpi( SaHpiDomainIdT did ); + explicit cHpi( oHpiCommonOptionsT copt ); ~cHpi(); bool Open(); @@ -45,7 +46,7 @@ bool m_initialized; bool m_opened; - SaHpiDomainIdT m_did; + oHpiCommonOptionsT m_copt; SaHpiSessionIdT m_sid; }; Modified: openhpi/trunk/clients/hpixml/main.cpp =================================================================== --- openhpi/trunk/clients/hpixml/main.cpp 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/hpixml/main.cpp 2011-02-14 12:53:05 UTC (rev 7273) @@ -1,6 +1,7 @@ /* -*- c++ -*- * * Copyright (c) 2011 by Pigeon Point Systems. + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -11,7 +12,12 @@ * * Authors: * Anton Pak <av...@pi...> + * Ulrich Kleber <uli...@us...> * + * Changes: + * 09/02/2011 ulikleber Use glib for option parsing and common + * options for all clients + * */ #include <getopt.h> @@ -23,58 +29,50 @@ #include "hpi.h" #include "hpi_xml_writer.h" #include "schema.h" +#include <oh_clients.h> +static gboolean f_indent = FALSE; +static gboolean f_xsd = FALSE; +static gboolean f_use_names = FALSE; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "indent", 'i', 0, G_OPTION_ARG_NONE, &f_indent, "Use indentation", NULL }, + { "text", 't', 0, G_OPTION_ARG_NONE, &f_use_names, "Use enum and flag text names instead of raw values", NULL }, + { "xsd", 's', 0, G_OPTION_ARG_NONE, &f_xsd, "Show XML schema", NULL }, + { NULL } +}; + + /*************************************************** * Main ***************************************************/ int main( int argc, char * argv[] ) { int indent_step = 0; - bool use_names = false; - SaHpiDomainIdT did = SAHPI_UNSPECIFIED_DOMAIN_ID; + GError *error = NULL; + GOptionContext *context; + + context = g_option_context_new ("- Display system view in XML"); + g_option_context_add_main_entries (context, my_options, NULL); - int c; - bool print_usage = false; - bool print_xsd = false; - while ( ( c = getopt( argc, argv,"D:its") ) != EOF ) { - switch( c ) { - case 'D': - if ( optarg ) { - did = atoi( optarg ); - } else { - print_usage = true; - } - break; - case 'i': - indent_step = 1; - break; - case 't': - use_names = true; - break; - case 's': - print_xsd = true; - break; - default: - print_usage = true; - break; - } - } - if ( optind < argc ) { - print_usage = true; - } - if ( print_usage ) { - printf( "Usage: %s [-option]\n\n", argv[0] ); - printf( " (No Option) Work with default domain\n" ); - printf( " -D nn Select domain id nn\n" ); - printf( " -i Use indentation\n" ); - printf( " -t Use enum and flag text names instead of raw values\n" ); - printf( " -s Show XML schema\n" ); - printf( "\n" ); - return 1; - } - if ( print_xsd ) { + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127? + - OHC_VERBOSE_OPTION // no verbose mode implemented + - OHC_DEBUG_OPTION, // no debug option implemented + error)) { + CRIT ("option parsing failed: %s\n", error->message); + g_option_context_free (context); + return 1; + } + g_option_context_free (context); + if (f_indent) indent_step = 1; + + if ( f_xsd ) { for ( char * p = &schema_begin; p < &schema_end; ++p ) { fwrite( p, 1, 1, stdout ); } @@ -83,12 +81,12 @@ bool rc; - cHpi hpi( did ); + cHpi hpi( copt ); rc = hpi.Open(); if ( !rc ) { return 1; } - cHpiXmlWriter writer( indent_step, use_names ); + cHpiXmlWriter writer( indent_step, f_use_names ); rc = hpi.Dump( writer ); if ( !rc ) { CRIT( "Failed to produce XML" ); Modified: openhpi/trunk/clients/oh_clients.h =================================================================== --- openhpi/trunk/clients/oh_clients.h 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/oh_clients.h 2011-02-14 12:53:05 UTC (rev 7273) @@ -33,14 +33,21 @@ #include <oHpi.h> #include <oh_utils.h> +#include <oh_error.h> -#define OHC_ALL_OPTIONS (SaHpiUint8T) 0x01F +#define OHC_ALL_OPTIONS (SaHpiUint8T) 0x03F #define OHC_DEBUG_OPTION (SaHpiUint8T) 0x001 #define OHC_DOMAIN_OPTION (SaHpiUint8T) 0x002 #define OHC_VERBOSE_OPTION (SaHpiUint8T) 0x004 #define OHC_ENTITY_PATH_OPTION (SaHpiUint8T) 0x008 #define OHC_HOST_OPTION (SaHpiUint8T) 0x010 +#define OHC_CLIENTCONF_OPTION (SaHpiUint8T) 0x020 +#define OHC_SESSION_OPTIONS (SaHpiUint8T) 0x032 // -D -N and -C +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { gboolean debug; gboolean verbose; @@ -50,6 +57,7 @@ gboolean withdaemonhost; SaHpiTextBufferT daemonhost; SaHpiUint16T daemonport; + SaHpiTextBufferT clientconf; } oHpiCommonOptionsT; void oh_prog_version(const char *prog_name, const char *svn_rev_str); @@ -65,5 +73,9 @@ SaHpiSessionIdT *SessionId); +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* __OH_CLIENTS_H */ Modified: openhpi/trunk/clients/ohdomainlist.c =================================================================== --- openhpi/trunk/clients/ohdomainlist.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/ohdomainlist.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -57,17 +57,16 @@ context, &copt, OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION // not applicable - - OHC_DOMAIN_OPTION, // not applicable + - OHC_SESSION_OPTIONS, // not applicable error)) { - g_print ("option parsing failed: %s\n", error->message); g_option_context_free (context); - exit(1); + return 1; } g_option_context_free (context); show_domains(); - exit(0); + return 0; } Modified: openhpi/trunk/clients/ohhandler.c =================================================================== --- openhpi/trunk/clients/ohhandler.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/ohhandler.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -106,7 +106,6 @@ - OHC_ENTITY_PATH_OPTION // not applicable - OHC_VERBOSE_OPTION, // no verbose mode error)) { - g_print ("option parsing failed: %s\n", error->message); printusage = TRUE; } g_option_context_free (context); @@ -118,8 +117,8 @@ // exechandlercreate will do the remaining reading of // parameters itself rv = exechandlercreate (argc, argv, ++i); - if (rv == SA_OK) exit (0); - if (rv != SA_ERR_HPI_INVALID_PARAMS) exit (1); + if (rv == SA_OK) return 0; + if (rv != SA_ERR_HPI_INVALID_PARAMS) return 1; printusage = TRUE; } @@ -165,10 +164,10 @@ if (cmd == eHandlerCreate) { rv = exechandlercreate (argc, argv, i); - if (rv == SA_OK) exit (0); + if (rv == SA_OK) return 0; if (rv == SA_ERR_HPI_INVALID_PARAMS) printusage = TRUE; - else exit (1); + else return 1; } if (printusage == TRUE || cmd == eUndefined) @@ -181,11 +180,11 @@ printf(" -h, --help Show help options \n"); printf(" -D, --domain=nn Select domain id nn \n"); printf(" -X, --debug Display debug messages \n\n"); - exit(1); + return 1; } rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; switch (cmd){ case eHandlerCreate: break; //already done @@ -222,7 +221,7 @@ rv, oh_lookup_error(rv)); } - exit(0); + return 0; } /********************************************/ @@ -263,7 +262,7 @@ } rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return rv; if (copt.debug) printf ("Calling oHpiHandlerCreate!\n"); rv = oHpiHandlerCreate(sessionid, createparams, &handlerid ); @@ -271,6 +270,7 @@ if ( rv != SA_OK ) { printf("oHpiHandlerCreate returned %d (%s)\n", rv, oh_lookup_error(rv)); + saHpiSessionClose(sessionid); return(rv); } Modified: openhpi/trunk/clients/ohparam.c =================================================================== --- openhpi/trunk/clients/ohparam.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/clients/ohparam.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -146,11 +146,11 @@ printf(" -h, --help Show help options \n"); printf(" -D, --domain=nn Select domain id nn \n"); printf(" -X, --debug Display debug messages \n\n"); - exit(1); + return 1; } rv = ohc_session_open_by_option ( &copt, &sessionid); - if (rv != SA_OK) exit(-1); + if (rv != SA_OK) return -1; switch (cmd){ case eGlobalParamGet: @@ -166,11 +166,11 @@ if (rv == SA_OK) { rv = saHpiSessionClose(sessionid); - exit(0); + return 0; } printf("Param set failed with returncode %d (%s)\n", rv, oh_lookup_error(rv)); - exit(-1); + return rv; } Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/configure.ac 2011-02-14 12:53:05 UTC (rev 7273) @@ -629,7 +629,7 @@ OH_SSL_INCLUDES="-I\$(top_srcdir)/ssl" AC_SUBST(OH_SSL_INCLUDES) -OPENHPI_INCLUDES="-I\$(top_srcdir)/include -I\$(top_srcdir)/utils -I\$(top_builddir)/utils" +OPENHPI_INCLUDES="-I\$(top_srcdir)/include -I\$(top_srcdir)/utils -I\$(top_builddir)/utils -I\$(top_srcdir)/clients" dnl replace common includes here AC_SUBST(OPENHPI_INCLUDES) Modified: openhpi/trunk/hpi_shell/Makefile.am =================================================================== --- openhpi/trunk/hpi_shell/Makefile.am 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/hpi_shell/Makefile.am 2011-02-14 12:53:05 UTC (rev 7273) @@ -12,6 +12,7 @@ INCLUDES += -I$(top_srcdir)/openhpid \ -I$(top_srcdir)/marshal \ + -I$(top_srcdir)/clients \ -DCLIENT COMMONLIBS = $(top_builddir)/transport/libopenhpitransport.la \ $(top_builddir)/utils/libopenhpiutils.la \ @@ -31,7 +32,8 @@ sensor.c \ service.c \ session.c \ - show.c + show.c \ + $(top_srcdir)/clients/clients.c hpi_shell_LDADD = $(COMMONLIBS) Modified: openhpi/trunk/hpi_shell/hpi_cmd.c =================================================================== --- openhpi/trunk/hpi_shell/hpi_cmd.c 2011-02-11 00:10:51 UTC (rev 7272) +++ openhpi/trunk/hpi_shell/hpi_cmd.c 2011-02-14 12:53:05 UTC (rev 7273) @@ -1,6 +1,7 @@ /* -*- linux-c -*- * * Copyright (c) 2004 by Intel Corp. + * (C) Copyright Ulrich Kleber 2011 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,6 +17,8 @@ * 11.30.2004 - Kouzmich: porting to HPI-B * 28.10.2010 - Anton Pak: fixed -c command line argument * 28.10.2010 - Anton Pak: added -D command line argument + * 10.02.2011 - Ulrich Kleber: Refactoring to use glib for option parsing and + * introduce common options for all clients * */ @@ -24,57 +27,56 @@ #include <string.h> #include <getopt.h> #include "hpi_cmd.h" +#include <oh_clients.h> +#define OH_SVN_REV "$Revision$" + int debug_flag = 0; +static gchar *f_cmdfile = NULL; +static gboolean f_events = FALSE; +static oHpiCommonOptionsT copt; +static GOptionEntry my_options[] = +{ + { "cmdfile", 'f', 0, G_OPTION_ARG_FILENAME, &f_cmdfile, "Execute command file", "filename" }, + { "events", 'e', 0, G_OPTION_ARG_NONE, &f_events, "Show short events, discover after subscribe", NULL }, + { NULL } +}; + + int main(int argc, char **argv) { - int c, eflag = 0; - SaHpiBoolT printusage = SAHPI_FALSE; - SaHpiDomainIdT domainId = SAHPI_UNSPECIFIED_DOMAIN_ID; + GError *error = NULL; + GOptionContext *context; - while ( (c = getopt( argc, argv,"D:c:ef:xn:?")) != EOF ) { - switch(c) { - case 'D': - if (optarg) { - domainId = atoi(optarg); - } else { - printusage = SAHPI_TRUE; - } - break; - case 'c': - setenv("OPENHPICLIENT_CONF", optarg, 1); - break; - case 'e': - eflag = 1; - break; - case 'f': - open_file(optarg); - break; - case 'x': - debug_flag = 1; - break; - case 'n': - setenv("OPENHPI_DAEMON_HOST", optarg, 1); - break; - default: - printusage = SAHPI_TRUE; - } - } + oh_prog_version(argv[0], OH_SVN_REV); - if (printusage != SAHPI_FALSE) { - printf("Usage: %s [-c <cfgfile>][-e][-f <file>][-n <hostname>]\n", argv[0]); - printf(" -D <did> - select domain id\n"); - printf(" -c <cfgfile> - use passed file as client configuration file\n"); - printf(" -e - show short events, discover after subscribe\n"); - printf(" -f <file> - execute command file\n"); - printf(" -x - display debug messages\n"); - printf(" -n <hostname> - use passed hostname as OpenHPI daemon host\n"); - return 1; - } + context = g_option_context_new ("- Allows a user to interactively " + "perform a number of HPI operations"); + g_option_context_add_main_entries (context, my_options, NULL); + if (!ohc_option_parse(&argc, argv, + context, &copt, + OHC_ALL_OPTIONS + - OHC_ENTITY_PATH_OPTION // not applicable + - OHC_VERBOSE_OPTION, // no verbose mode implemented + error)) { + g_print ("option parsing failed: %s\n", error->message); + g_option_context_free (context); + exit(1); + } + if (copt.debug) debug_flag = 1; + g_option_context_free (context); + if (f_cmdfile) { + open_file ( f_cmdfile ); + g_free ( f_cmdfile ); + } + domainlist = (GSList *)NULL; - if (open_session(domainId, eflag) == -1) + if (open_session(copt.domainid, f_events) == -1) + //TODO For complete implementation of -N option, need to call + //TODO ohAddDomain to get the domain Id. + return(1); cmd_shell(); close_session(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-02-14 21:50:33
|
Revision: 7274 http://openhpi.svn.sourceforge.net/openhpi/?rev=7274&view=rev Author: avpak Date: 2011-02-14 21:50:26 +0000 (Mon, 14 Feb 2011) Log Message: ----------- More on feature requests #3153081 and #3031797 Modified Paths: -------------- openhpi/trunk/Makefile.am openhpi/trunk/Makefile.mingw32 openhpi/trunk/Makefile.mingw32.def openhpi/trunk/README.windows openhpi/trunk/clients/Makefile.mingw32 openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpixml/Makefile.mingw32 openhpi/trunk/openhpid/Makefile.mingw32 Removed Paths: ------------- openhpi/trunk/clients/hpixml/manifest.rc openhpi/trunk/clients/manifest.rc openhpi/trunk/mingw32/app.manifest openhpi/trunk/mingw32/openhpi.windows.libraries.manifest openhpi/trunk/mingw32/openhpi.windows.plugins.manifest openhpi/trunk/mingw32/openhpid.manifest openhpi/trunk/openhpid/manifest.rc Modified: openhpi/trunk/Makefile.am =================================================================== --- openhpi/trunk/Makefile.am 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/Makefile.am 2011-02-14 21:50:26 UTC (rev 7274) @@ -47,11 +47,8 @@ README.windows \ Makefile.mingw32 \ Makefile.mingw32.def \ - mingw32/app.manifest \ mingw32/config.h \ - mingw32/openhpi.windows.libraries.manifest \ - mingw32/openhpi.windows.plugins.manifest \ - mingw32/openhpid.manifest \ + mingw32/openhpi.conf.example \ $(shell find $(srcdir)/include -name '*.h') AUTOMAKE_OPTIONS = foreign Modified: openhpi/trunk/Makefile.mingw32 =================================================================== --- openhpi/trunk/Makefile.mingw32 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/Makefile.mingw32 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,11 +1,13 @@ include Makefile.mingw32.def -out := openhpi-${VERSION}-win32 -doc := ${out}/doc -libs := ${out}/openhpi.windows.libraries -devel := ${out}/devel +out := openhpi-${VERSION}-win32-${ARCH} +doc := ${out} +deps := ${out} +libs := ${out} +devel := ${out} progs := ${out} -plugins := ${out}/openhpi.windows.plugins +plugins := ${out} +conf := ${out} openhpi_libs := utils \ transport \ @@ -35,15 +37,15 @@ mkdir -p ${out} mkdir -p ${doc} cp README.windows ${doc}/README.windows.txt + mkdir -p ${deps} + cp ${GLIB_DIR}/bin/libglib-2.0-0.dll ${deps} + cp ${GLIB_DIR}/bin/libgmodule-2.0-0.dll ${deps} + cp ${GLIB_DIR}/bin/libgthread-2.0-0.dll ${deps} mkdir -p ${libs} cp transport/libopenhpitransport.dll ${libs} cp marshal/libopenhpimarshal.dll ${libs} cp utils/libopenhpiutils.dll ${libs} cp baselib/libopenhpi.dll ${libs} - cp ${GLIB_DIR}/bin/libglib-2.0-0.dll ${libs} - cp ${GLIB_DIR}/bin/libgmodule-2.0-0.dll ${libs} - cp ${GLIB_DIR}/bin/libgthread-2.0-0.dll ${libs} - cp mingw32/openhpi.windows.libraries.manifest ${libs} mkdir -p ${devel} cat include/SaHpi.h | sed -e 's/ __attribute__.*/;/' -e 's/#define SAHPI_API/#define SAHPI_API __declspec(dllimport)/' > ${devel}/SaHpi.h cp include/oHpi.h ${devel} @@ -51,12 +53,12 @@ cp utils/libopenhpiutils.def ${devel} cp baselib/libopenhpi.a ${devel} cp baselib/libopenhpi.def ${devel} - cp mingw32/app.manifest ${devel} mkdir -p ${progs} cp clients/*.exe ${progs} cp clients/hpixml/hpixml.exe ${progs} cp openhpid/openhpid.exe ${progs} mkdir -p ${plugins} cp plugins/slave/libslave.dll ${plugins} - cp mingw32/openhpi.windows.plugins.manifest ${plugins} + mkdir -p ${conf} + cp mingw32/openhpi.conf.example ${conf}/openhpi.conf Modified: openhpi/trunk/Makefile.mingw32.def =================================================================== --- openhpi/trunk/Makefile.mingw32.def 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/Makefile.mingw32.def 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,3 +1,7 @@ +############################################################################ +ARCH := x86 +#ARCH := amd64 + VERSION := 2.17.0 ############################################################################ @@ -6,7 +10,6 @@ CC := ${TOOLCHAIN_PATH}/bin/i386-mingw32-gcc CXX := ${TOOLCHAIN_PATH}/bin/i386-mingw32-g++ AS := ${TOOLCHAIN_PATH}/bin/i386-mingw32-as -RC := ${TOOLCHAIN_PATH}/bin/i386-mingw32-windres GLIB_DIR := /home/avpak/usr/cross/mingw32/i386-mingw32/glib-2.0 Modified: openhpi/trunk/README.windows =================================================================== --- openhpi/trunk/README.windows 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/README.windows 2011-02-14 21:50:26 UTC (rev 7274) @@ -68,7 +68,7 @@ point to valid directories with glib headers and libraries. - Run "make -f Makefile.mingw32". - Run "make -f Makefile.mingw32 out". -- The bin sub-directory will contain all produced stuff. +- The openhpi-${VERSION}-win32 sub-directory will contain all produced stuff. - Optional step - strip produced exe and dll files. ======================================================================== @@ -141,7 +141,7 @@ The uid map file will be used for persistent resource id <-> entity path mapping. -NB: Flags -v is for verbose messages and can be omitted. +NB: -v is optional flag for verbose messages. ======================================================================== Troubleshouting: Modified: openhpi/trunk/clients/Makefile.mingw32 =================================================================== --- openhpi/trunk/clients/Makefile.mingw32 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/clients/Makefile.mingw32 2011-02-14 21:50:26 UTC (rev 7274) @@ -37,12 +37,9 @@ all : ${TARGETS} -manifest.o: manifest.rc - ${RC} -i $^ -o $@ - -%.exe : %.o clients.o manifest.o +%.exe : %.o clients.o ${CXX} -o $@ $^ ${LIBS} clean: - rm -f ${OBJS} ${TARGETS} manifest.o clients.o + rm -f ${OBJS} ${TARGETS} clients.o Modified: openhpi/trunk/clients/clients.c =================================================================== --- openhpi/trunk/clients/clients.c 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/clients/clients.c 2011-02-14 21:50:26 UTC (rev 7274) @@ -69,6 +69,20 @@ }; +#ifdef _WIN32 +/*--------------------------------------------------------------------*/ +/* Function: setenv */ +/*--------------------------------------------------------------------*/ +static int setenv(const char * var, const char * val, int overwrite) +{ + static const size_t BUFSIZE = 1024; + char buf[BUFSIZE]; + snprintf(buf, BUFSIZE, "%s=%s", var, val); + return _putenv(buf); +} +#endif /* _WIN32 */ + + void oh_prog_version(const char *prog_name, const char *svn_rev_str) { SaHpiUint32T ohpi_major = oHpiVersionGet() >> 48; Modified: openhpi/trunk/clients/hpixml/Makefile.mingw32 =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.mingw32 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/clients/hpixml/Makefile.mingw32 2011-02-14 21:50:26 UTC (rev 7274) @@ -3,19 +3,19 @@ TARGET := hpixml.exe SRC := \ + ../clients.c \ hpi.cpp \ hpi_xml_writer.cpp \ schema.S \ main.cpp \ - manifest.rc \ xml_writer.cpp -OBJ := $(patsubst %.rc, %.o, $(patsubst %.S, %.o, $(patsubst %.cpp, %.o, ${SRC} ) ) ) +OBJ := $(patsubst %.S, %.o,$(patsubst %.c, %.o, $(patsubst %.cpp, %.o, ${SRC} ) ) ) DEFS := -DG_LOG_DOMAIN=\"hpixml\" -DSCHEMA=\"schema.xsd\" INCLUDES := ${GLIB_INCLUDES} -INCLUDES += -I ../../mingw32 -I ../../include -I ../../utils +INCLUDES += -I ../../mingw32 -I ../../include -I ../../utils -I ../ LIBS := ${GLIB_LIBS} LIBS += -L ../../utils -lopenhpiutils @@ -27,9 +27,6 @@ all : ${TARGET} -manifest.o: manifest.rc - ${RC} -i $^ -o $@ - ${TARGET} : ${OBJ} ${CXX} -o $@ $^ ${LIBS} Deleted: openhpi/trunk/clients/hpixml/manifest.rc =================================================================== --- openhpi/trunk/clients/hpixml/manifest.rc 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/clients/hpixml/manifest.rc 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,3 +0,0 @@ -#include <winuser.h> - -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../../mingw32/app.manifest" Deleted: openhpi/trunk/clients/manifest.rc =================================================================== --- openhpi/trunk/clients/manifest.rc 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/clients/manifest.rc 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,3 +0,0 @@ -#include <winuser.h> - -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../mingw32/app.manifest" Deleted: openhpi/trunk/mingw32/app.manifest =================================================================== --- openhpi/trunk/mingw32/app.manifest 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/mingw32/app.manifest 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <assemblyIdentity type="win32" name="openhpi.windows.app" version="2.17.0.3" processorArchitecture="x86"/> - <dependency> - <dependentAssembly> - <assemblyIdentity type="win32" name="openhpi.windows.libraries" version="2.17.0.3" processorArchitecture="x86"/> - </dependentAssembly> - </dependency> -</assembly> - Deleted: openhpi/trunk/mingw32/openhpi.windows.libraries.manifest =================================================================== --- openhpi/trunk/mingw32/openhpi.windows.libraries.manifest 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/mingw32/openhpi.windows.libraries.manifest 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <assemblyIdentity type="win32" name="openhpi.windows.libraries" version="2.17.0.3" processorArchitecture="x86"/> - <file name="libopenhpi.dll"/> - <file name="libopenhpimarshal.dll"/> - <file name="libopenhpitransport.dll"/> - <file name="libopenhpiutils.dll"/> - <file name="libglib-2.0-0.dll"/> - <file name="libgmodule-2.0-0.dll"/> - <file name="libgthread-2.0-0.dll"/> -</assembly> Deleted: openhpi/trunk/mingw32/openhpi.windows.plugins.manifest =================================================================== --- openhpi/trunk/mingw32/openhpi.windows.plugins.manifest 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/mingw32/openhpi.windows.plugins.manifest 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <assemblyIdentity type="win32" name="openhpi.windows.plugins" version="2.17.0.3" processorArchitecture="x86"/> - <file name="libslave.dll"/> -</assembly> Deleted: openhpi/trunk/mingw32/openhpid.manifest =================================================================== --- openhpi/trunk/mingw32/openhpid.manifest 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/mingw32/openhpid.manifest 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <assemblyIdentity type="win32" name="openhpi.windows.openhpid" version="2.17.0.3" processorArchitecture="x86"/> - <dependency> - <dependentAssembly> - <assemblyIdentity type="win32" name="openhpi.windows.libraries" version="2.17.0.3" processorArchitecture="x86"/> - </dependentAssembly> - </dependency> - <dependency> - <dependentAssembly> - <assemblyIdentity type="win32" name="openhpi.windows.plugins" version="2.17.0.3" processorArchitecture="x86"/> - </dependentAssembly> - </dependency> -</assembly> - Modified: openhpi/trunk/openhpid/Makefile.mingw32 =================================================================== --- openhpi/trunk/openhpid/Makefile.mingw32 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/openhpid/Makefile.mingw32 2011-02-14 21:50:26 UTC (rev 7274) @@ -15,10 +15,9 @@ session.c \ threaded.c \ server.cpp \ - openhpid-win32.cpp \ - manifest.rc + openhpid-win32.cpp -OBJ := $(patsubst %.rc, %.o, $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, ${SRC} ) ) ) +OBJ := $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, ${SRC} ) ) DEFS := -DG_LOG_DOMAIN=\"openhpid\" @@ -36,9 +35,6 @@ all : ${TARGET} -manifest.o: manifest.rc - ${RC} -i $^ -o $@ - ${TARGET} : ${OBJ} ${CXX} -o $@ $^ ${LIBS} Deleted: openhpi/trunk/openhpid/manifest.rc =================================================================== --- openhpi/trunk/openhpid/manifest.rc 2011-02-14 12:53:05 UTC (rev 7273) +++ openhpi/trunk/openhpid/manifest.rc 2011-02-14 21:50:26 UTC (rev 7274) @@ -1,3 +0,0 @@ -#include <winuser.h> - -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../mingw32/openhpid.manifest" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-02-14 22:25:33
|
Revision: 7275 http://openhpi.svn.sourceforge.net/openhpi/?rev=7275&view=rev Author: avpak Date: 2011-02-14 22:25:27 +0000 (Mon, 14 Feb 2011) Log Message: ----------- More on Feature Requests #3153081 and #3031797 Modified Paths: -------------- openhpi/trunk/README.windows openhpi/trunk/clients/Makefile.am openhpi/trunk/clients/hpixml/Makefile.am openhpi/trunk/openhpid/Makefile.am Modified: openhpi/trunk/README.windows =================================================================== --- openhpi/trunk/README.windows 2011-02-14 21:50:26 UTC (rev 7274) +++ openhpi/trunk/README.windows 2011-02-14 22:25:27 UTC (rev 7275) @@ -21,16 +21,14 @@ -- hpitop.exe -- hpitree.exe -- hpiwdt.exe +-- hpixml.exe -- ohdomainlist.exe -- ohhandler.exe -- ohparam.exe - OpenHPI daemon as a console Windows application (openhpid.exe) -- Slave plug-in (libslave.dll) -libopenhpi.dll, libopenhpiutils.dll, libopenhpimarshal.dll, -libopenhpitransport.dll constitute -private side-by-side assembly openhpi.windows.libraries. -And the assembly also includes necessary glib2 libraries: +The package also provides necessary glib2 libraries: - libglib-2.0-0.dll - libgthread-2.0-0.dll - libgmodule-2.0-0.dll @@ -40,9 +38,7 @@ without any change. NB: glib2 is distributed under LGPL2 license. -libslave.dll constitutes private side-by-side assembly -openhpi.windows.plugins. It is planned to use this assembly -for OpenHPI daemon plug-ins. +The package can include additional auxiliary libraries. ======================================================================== Dependencies: @@ -63,12 +59,13 @@ - Get archive with glib2 for windows and unpack it somewhere. - Enter OpenHPI source tree root directory. - Modify Makefile.mingw32.def: --- TOOLCHAIN_PATH in order that CC, CXX, AS and RC point to correct files. +-- ARCH in order to point architecture for produced binaries +-- TOOLCHAIN_PATH in order that CC, CXX and AS point to correct files. -- GLIB_DIR: in order that GLIB_INCLUDES and GLIB_LIBS point to valid directories with glib headers and libraries. - Run "make -f Makefile.mingw32". - Run "make -f Makefile.mingw32 out". -- The openhpi-${VERSION}-win32 sub-directory will contain all produced stuff. +- The openhpi-${VERSION}-win32-${ARCH} sub-directory will contain all produced stuff. - Optional step - strip produced exe and dll files. ======================================================================== @@ -98,13 +95,8 @@ - Command example "lib /machine:i386 /def:libopenhpi.def" - Point produced import library in Project settings -For application running and distribution there are two ways: -- you can copy assembly openhpi.windows.libraries dir - to application dir and put copy app.manifest as - your_application_name.exe.manifest into application dir. - Or embed this manifest to your application. -- get necessary libraries from assembly openhpi.windows.libraries - assembly dir and copy them to your application dir. +For application running and distribution:: +- copy necessary libraries to your application dir. And see Client Usage instructions about configuring OpenHPI daemon address to connect. Modified: openhpi/trunk/clients/Makefile.am =================================================================== --- openhpi/trunk/clients/Makefile.am 2011-02-14 21:50:26 UTC (rev 7274) +++ openhpi/trunk/clients/Makefile.am 2011-02-14 22:25:27 UTC (rev 7275) @@ -8,7 +8,7 @@ SUBDIRS = hpixml DIST_SUBDIRS = hpixml -EXTRA_DIST = Makefile.mingw32 manifest.rc +EXTRA_DIST = Makefile.mingw32 COMMONLIBS = $(top_builddir)/baselib/libopenhpi.la Modified: openhpi/trunk/clients/hpixml/Makefile.am =================================================================== --- openhpi/trunk/clients/hpixml/Makefile.am 2011-02-14 21:50:26 UTC (rev 7274) +++ openhpi/trunk/clients/hpixml/Makefile.am 2011-02-14 22:25:27 UTC (rev 7275) @@ -6,7 +6,7 @@ INCLUDES = @OPENHPI_INCLUDES@ -EXTRA_DIST = Makefile.mingw32 schema.xsd manifest.rc +EXTRA_DIST = Makefile.mingw32 schema.xsd bin_PROGRAMS = hpixml Modified: openhpi/trunk/openhpid/Makefile.am =================================================================== --- openhpi/trunk/openhpid/Makefile.am 2011-02-14 21:50:26 UTC (rev 7274) +++ openhpi/trunk/openhpid/Makefile.am 2011-02-14 22:25:27 UTC (rev 7275) @@ -28,7 +28,6 @@ EXTRA_DIST = \ openhpid.sh.in \ Makefile.mingw32 \ - manifest.rc \ openhpid-win32.cpp # daemon library This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-02-16 12:03:56
|
Revision: 7281 http://openhpi.svn.sourceforge.net/openhpi/?rev=7281&view=rev Author: ulikleber Date: 2011-02-16 12:03:50 +0000 (Wed, 16 Feb 2011) Log Message: ----------- fix for 3183666 gcc 4.5 warning in ipmidirect and 3183665 gcc 4.5 warnings in hpi_shell Modified Paths: -------------- openhpi/trunk/hpi_shell/commands.c openhpi/trunk/plugins/ipmidirect/ipmi_mc_vendor.cpp Modified: openhpi/trunk/hpi_shell/commands.c =================================================================== --- openhpi/trunk/hpi_shell/commands.c 2011-02-15 19:11:31 UTC (rev 7280) +++ openhpi/trunk/hpi_shell/commands.c 2011-02-16 12:03:50 UTC (rev 7281) @@ -958,16 +958,16 @@ }; printf(" Timer Use: %s", str); switch (watchdog.TimerAction) { - case SAHPI_WAE_NO_ACTION: + case SAHPI_WA_NO_ACTION: str = "NO_ACTION"; break; - case SAHPI_WAE_RESET: + case SAHPI_WA_RESET: str = "RESET"; break; - case SAHPI_WAE_POWER_DOWN: + case SAHPI_WA_POWER_DOWN: str = "POWER_DOWN"; break; - case SAHPI_WAE_POWER_CYCLE: + case SAHPI_WA_POWER_CYCLE: str = "POWER_CYCLE"; break; - case SAHPI_WAE_TIMER_INT: - str = "TIMER_INT"; break; + //case SAHPI_WAE_TIMER_INT: + // str = "TIMER_INT"; break; default: str = "Unknown"; break; }; printf(" Action: %s", str); Modified: openhpi/trunk/plugins/ipmidirect/ipmi_mc_vendor.cpp =================================================================== --- openhpi/trunk/plugins/ipmidirect/ipmi_mc_vendor.cpp 2011-02-15 19:11:31 UTC (rev 7280) +++ openhpi/trunk/plugins/ipmidirect/ipmi_mc_vendor.cpp 2011-02-16 12:03:50 UTC (rev 7281) @@ -502,7 +502,7 @@ if ( instance >= 0x60 ) instance -= 0x60; - switch (type) + switch ((tIpmiEntityId)type) { default: break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-02-19 08:58:03
|
Revision: 7283 http://openhpi.svn.sourceforge.net/openhpi/?rev=7283&view=rev Author: ulikleber Date: 2011-02-19 08:57:56 +0000 (Sat, 19 Feb 2011) Log Message: ----------- more on Feature 1493787 Update clients to use long options and uniform format Output of svn revision moved to use text. Started on Bug 3193692 clients should use CRIT/DBG macros consistently. Modified Paths: -------------- openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpialarms.c openhpi/trunk/clients/hpidomain.c openhpi/trunk/clients/hpiel.c openhpi/trunk/clients/hpievents.c openhpi/trunk/clients/hpifan.c openhpi/trunk/clients/hpigensimdata.c openhpi/trunk/clients/hpiinv.c openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/hpipower.c openhpi/trunk/clients/hpireset.c openhpi/trunk/clients/hpisensor.c openhpi/trunk/clients/hpisettime.c openhpi/trunk/clients/hpithres.c openhpi/trunk/clients/hpitop.c openhpi/trunk/clients/hpitree.c openhpi/trunk/clients/hpiwdt.c openhpi/trunk/clients/hpixml/main.cpp openhpi/trunk/clients/oh_clients.h openhpi/trunk/clients/ohdomainlist.c openhpi/trunk/clients/ohhandler.c openhpi/trunk/clients/ohparam.c openhpi/trunk/hpi_shell/hpi_cmd.c Modified: openhpi/trunk/clients/clients.c =================================================================== --- openhpi/trunk/clients/clients.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/clients.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -83,20 +83,13 @@ #endif /* _WIN32 */ -void oh_prog_version(const char *prog_name, const char *svn_rev_str) +void oh_prog_version(const char *prog_name) { SaHpiUint32T ohpi_major = oHpiVersionGet() >> 48; SaHpiUint32T ohpi_minor = (oHpiVersionGet() << 16) >> 48; SaHpiUint32T ohpi_patch = (oHpiVersionGet() << 32) >> 48; SaHpiVersionT hpiver; - char svn_rev[SAHPI_MAX_TEXT_BUFFER_LENGTH]; - strncpy(svn_rev, svn_rev_str, SAHPI_MAX_TEXT_BUFFER_LENGTH); - svn_rev[strlen(svn_rev_str)-2] = '\0'; - - // Revision not printed here any more - //printf("%s (rev %s) - This program came with OpenHPI %u.%u.%u\n", - // prog_name, svn_rev+11, ohpi_major, ohpi_minor, ohpi_patch); printf("%s - This program came with OpenHPI %u.%u.%u\n", prog_name, ohpi_major, ohpi_minor, ohpi_patch); hpiver = saHpiVersionGet(); Modified: openhpi/trunk/clients/hpialarms.c =================================================================== --- openhpi/trunk/clients/hpialarms.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpialarms.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -100,9 +100,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Control alarm management instruments"); + /* Parsing options */ + static char usetext[]="- Control alarm management instruments\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpidomain.c =================================================================== --- openhpi/trunk/clients/hpidomain.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpidomain.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -63,9 +63,14 @@ oh_init_textbuffer(&domtag); - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Display info about domains or set domain tag"); + /* Parsing options */ + static char usetext[]="- Display info about domains or set domain tag\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpiel.c =================================================================== --- openhpi/trunk/clients/hpiel.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpiel.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -28,18 +28,10 @@ #define OH_SVN_REV "$Revision$" -#define err(format, ...) \ - do { \ - if (copt.debug) { \ - CRIT(format "\n", ## __VA_ARGS__); \ - } \ - } while(0) - #define show_error_quit(msg) \ do { \ if (error) { \ - copt.debug = TRUE; \ - err(msg, oh_lookup_error(error)); \ + CRIT(msg, oh_lookup_error(error)); \ return error; \ } \ } while(0) @@ -79,14 +71,15 @@ GOptionContext *context; /* Print version strings */ - oh_prog_version(argv[0], OH_SVN_REV); + oh_prog_version(argv[0]); /* Parsing options */ - context = g_option_context_new ("- Displays HPI event log entries\n" - "Option E (entity-path) displays resource event log entries.\n" - "If neither -d or -E \"<arg>\" are specified, " - "event log entries will be shown\n" - "for all supporting resources by default."); + static char usetext[]="- Displays HPI event log entries\n\n" + "Option E (entity-path) displays resource event log entries.\n" + "If neither -d or -E \"<arg>\" are specified, event log entries will be\n" + "shown for all supporting resources by default.\n" OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, @@ -140,7 +133,7 @@ SaHpiBoolT found_entry = SAHPI_FALSE; if (!sid || !dinfo) { - err("Invalid parameters in havest_sels()\n"); + if (copt.debug) CRIT("Invalid parameters in havest_sels()\n"); return SA_ERR_HPI_INVALID_PARAMS; } @@ -148,7 +141,8 @@ while (error == SA_OK && entryid != SAHPI_LAST_ENTRY) { error = saHpiRptEntryGet(sid, entryid, &nextentryid, &rptentry); - err("saHpiRptEntryGet() returned %s\n", oh_lookup_error(error)); + if (copt.debug) + CRIT("saHpiRptEntryGet() returned %s", oh_lookup_error(error)); if (error == SA_OK) { if (copt.withentitypath) { if (!oh_cmp_ep(&copt.entitypath, &rptentry.ResourceEntity)) { @@ -158,14 +152,14 @@ } if (!(rptentry.ResourceCapabilities & SAHPI_CAPABILITY_EVENT_LOG)) { - err("RPT doesn't have SEL\n"); + if (copt.debug) CRIT("RPT doesn't have SEL"); entryid = nextentryid; continue; /* no SEL here, try next RPT */ } found_entry = SAHPI_TRUE; rid = rptentry.ResourceId; - err("RPT %u capabilities = %x\n", + if (copt.debug) CRIT("RPT %u capabilities = %x", rid, rptentry.ResourceCapabilities); rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; @@ -184,12 +178,10 @@ if (!found_entry) { if (copt.withentitypath) { - fprintf(stderr, //cannot use err macro here - "Could not find resource matching "); - oh_fprint_ep(stderr, &copt.entitypath, 0); - fprintf(stderr,"\n"); + CRIT("Could not find resource matching entity path."); } else { - err("No resources supporting event logs were found.\n"); + if (copt.debug) + CRIT("No resources supporting event logs were found."); } } @@ -206,13 +198,13 @@ SaHpiRptEntryT res; if (!sid || !rid) { - err("Invalid parameters in display_el()\n"); + if (copt.debug) CRIT("Invalid parameters in display_el()."); return SA_ERR_HPI_INVALID_PARAMS; } error = saHpiEventLogInfoGet(sid, rid, &elinfo); if (error) { - err("saHpiEventLogInfoGet() returned %s. Exiting\n", + if (copt.debug) CRIT("saHpiEventLogInfoGet() returned %s. Exiting\n", oh_lookup_error(error)); return error; } @@ -246,7 +238,9 @@ &rdr, &res); - err("saHpiEventLogEntryGet() returned %s\n", oh_lookup_error(error)); + if (copt.debug) + CRIT ("saHpiEventLogEntryGet() returned %s\n", + oh_lookup_error(error)); if (error == SA_OK) { SaHpiEntityPathT *ep = NULL; /* Get a reference to the entity path for this log entry */ Modified: openhpi/trunk/clients/hpievents.c =================================================================== --- openhpi/trunk/clients/hpievents.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpievents.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -64,9 +64,14 @@ memset(&rptentry, 0, sizeof(rptentry)); - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Poll for HPI events"); + /* Parsing options */ + static char usetext[]="- Poll for HPI events\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpifan.c =================================================================== --- openhpi/trunk/clients/hpifan.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpifan.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -231,9 +231,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Show \"Fan Control\" management instruments"); + /* Parsing options */ + static char usetext[]="- Show \"Fan Control\" management instruments\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpigensimdata.c =================================================================== --- openhpi/trunk/clients/hpigensimdata.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpigensimdata.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -298,11 +298,17 @@ GOptionContext *context; confdata.mode = MODE_INIT; - oh_prog_version(argv[0], OH_SVN_REV); - - context = g_option_context_new ("- Version " GEN_SIM_DATA_VERSION + + /* Print version strings */ + oh_prog_version(argv[0]); + + /* Parsing options */ + static char usetext[]="- Version " GEN_SIM_DATA_VERSION "\nThe client will print all HPI information in a format that can be parsed by Dynamic" - "\nSimulator plugin."); + "\nSimulator plugin.\n" + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpiinv.c =================================================================== --- openhpi/trunk/clients/hpiinv.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpiinv.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -476,10 +476,16 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); atag.tlen = 0; - context = g_option_context_new ("- Shows resources' inventory records"); + /* Print version strings */ + oh_prog_version(argv[0]); + + /* Parsing options */ + static char usetext[]="- Shows resources' inventory records\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpionIBMblade.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -898,11 +898,16 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Shows how to use two (2) openhpi " - "plugins to display and manage resources of an IBM Blade " - "with Basedboard Management Controller (BMC)"); + /* Parsing options */ + static char usetext[]="- Shows how to use two (2) openhpi\n " + "plugins to display and manage resources of an IBM Blade\n " + "with Basedboard Management Controller (BMC)\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); if (!ohc_option_parse(&argc, argv, context, &copt, Modified: openhpi/trunk/clients/hpipower.c =================================================================== --- openhpi/trunk/clients/hpipower.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpipower.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -97,14 +97,14 @@ GError *error = NULL; GOptionContext *context; - /* - // Print out the Program name and Version - */ - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - - /* Parse out option instructions */ - context = g_option_context_new ("- Exercise HPI Power Management APIs"); + /* Parsing options */ + static char usetext[]="- Exercise HPI Power Management APIs\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpireset.c =================================================================== --- openhpi/trunk/clients/hpireset.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpireset.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -60,9 +60,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Exercise HPI Reset Management APIs"); + /* Parsing options */ + static char usetext[]="- Exercise HPI Reset Management APIs\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpisensor.c =================================================================== --- openhpi/trunk/clients/hpisensor.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpisensor.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -216,9 +216,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); - - context = g_option_context_new ("- Display sensor info for resources with Sensor Capability"); + /* Print version strings */ + oh_prog_version(argv[0]); + + /* Parsing options */ + static char usetext[]="- Display sensor info for resources with Sensor Capability\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpisettime.c =================================================================== --- openhpi/trunk/clients/hpisettime.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpisettime.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -81,9 +81,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); - - context = g_option_context_new ("- Exercises Event Log clock APIs."); + /* Print version strings */ + oh_prog_version(argv[0]); + + /* Parsing options */ + static char usetext[]="- Exercises Event Log clock APIs.\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpithres.c =================================================================== --- openhpi/trunk/clients/hpithres.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpithres.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -645,9 +645,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Display sensors and sensor info"); + /* Parsing options */ + static char usetext[]="- Display sensors and sensor info\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); if (!ohc_option_parse(&argc, argv, context, &copt, Modified: openhpi/trunk/clients/hpitop.c =================================================================== --- openhpi/trunk/clients/hpitop.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpitop.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -132,9 +132,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Display system topology"); + /* Parsing options */ + static char usetext[]="- Display system topology\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpitree.c =================================================================== --- openhpi/trunk/clients/hpitree.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpitree.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -135,9 +135,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Display system topology"); + /* Parsing options */ + static char usetext[]="- Display system topology\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpiwdt.c =================================================================== --- openhpi/trunk/clients/hpiwdt.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpiwdt.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -115,9 +115,14 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Read and Enables the watchdog timer."); + /* Parsing options */ + static char usetext[]="- Read and Enables the watchdog timer.\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/hpixml/main.cpp =================================================================== --- openhpi/trunk/clients/hpixml/main.cpp 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/hpixml/main.cpp 2011-02-19 08:57:56 UTC (rev 7283) @@ -20,6 +20,8 @@ * */ +#define OH_SVN_REV "$Revision: 7281 $" + #include <getopt.h> #include <stdio.h> #include <stdlib.h> @@ -56,6 +58,12 @@ GOptionContext *context; context = g_option_context_new ("- Display system view in XML"); + /* Parsing options */ + static char usetext[]="- Display system view in XML.\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, Modified: openhpi/trunk/clients/oh_clients.h =================================================================== --- openhpi/trunk/clients/oh_clients.h 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/oh_clients.h 2011-02-19 08:57:56 UTC (rev 7283) @@ -44,6 +44,13 @@ #define OHC_CLIENTCONF_OPTION (SaHpiUint8T) 0x020 #define OHC_SESSION_OPTIONS (SaHpiUint8T) 0x032 // -D -N and -C +//Macro to replace $ with () in OH_SVN_REV string for print +#define OHC_PREPARE_REVISION(txt) \ + char *dollar=strchr(txt, '$'); \ + if (dollar!=NULL) *dollar = '('; \ + dollar=strchr(txt, '$'); \ + if (dollar!=NULL) *dollar = ')'; + #ifdef __cplusplus extern "C" { #endif @@ -60,7 +67,7 @@ SaHpiTextBufferT clientconf; } oHpiCommonOptionsT; -void oh_prog_version(const char *prog_name, const char *svn_rev_str); +void oh_prog_version(const char *prog_name); gboolean ohc_option_parse(int *argc, char *argv[], GOptionContext *context, Modified: openhpi/trunk/clients/ohdomainlist.c =================================================================== --- openhpi/trunk/clients/ohdomainlist.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/ohdomainlist.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -48,10 +48,15 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Show information about domains" - " on the level of the openhpi base library."); + /* Parsing options */ + static char usetext[]="- Show information about domains" + " on the level of the openhpi base library.\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); if (!ohc_option_parse(&argc, argv, context, &copt, Modified: openhpi/trunk/clients/ohhandler.c =================================================================== --- openhpi/trunk/clients/ohhandler.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/ohhandler.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -93,13 +93,17 @@ eHandlerRetry, eHandlerList} cmd=eUndefined; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - /* Parse common options */ - context = g_option_context_new ("command [specific arguments] - " - "Control openhpi plugin instances (handlers).\n\n" - OHHANDLER_HELP ); + /* Parsing options */ + static char usetext[]="command [specific arguments] - " + "Control openhpi plugin instances (handlers).\n " + OH_SVN_REV "\n\n" OHHANDLER_HELP ; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); + if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS Modified: openhpi/trunk/clients/ohparam.c =================================================================== --- openhpi/trunk/clients/ohparam.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/clients/ohparam.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -75,13 +75,17 @@ eGlobalParamGet, eGlobalParamSet} cmd=eUndefined; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - /* Parse common options */ - context = g_option_context_new ("command [specific arguments] - " - "Control openhpi configuration parameters.\n\n" - OHPARAM_HELP ); + /* Parsing options */ + static char usetext[]="command [specific arguments] - " + "Control openhpi configuration parameters.\n " + OH_SVN_REV "\n\n" OHPARAM_HELP ; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); + if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS Modified: openhpi/trunk/hpi_shell/hpi_cmd.c =================================================================== --- openhpi/trunk/hpi_shell/hpi_cmd.c 2011-02-17 00:06:17 UTC (rev 7282) +++ openhpi/trunk/hpi_shell/hpi_cmd.c 2011-02-19 08:57:56 UTC (rev 7283) @@ -49,10 +49,15 @@ GError *error = NULL; GOptionContext *context; - oh_prog_version(argv[0], OH_SVN_REV); + /* Print version strings */ + oh_prog_version(argv[0]); - context = g_option_context_new ("- Allows a user to interactively " - "perform a number of HPI operations"); + /* Parsing options */ + static char usetext[]="- Allows a user to interactively " + "perform a number of HPI operations\n " + OH_SVN_REV; + OHC_PREPARE_REVISION(usetext); + context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-03-03 12:27:37
|
Revision: 7288 http://openhpi.svn.sourceforge.net/openhpi/?rev=7288&view=rev Author: ulikleber Date: 2011-03-03 12:27:30 +0000 (Thu, 03 Mar 2011) Log Message: ----------- Feature 3129972 change -n and OPENHPI_DATEMON_HOST semantics Modified Paths: -------------- openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpievents.c openhpi/trunk/clients/ohdomainlist.c openhpi/trunk/docs/man/hpi_shell.pod.1 openhpi/trunk/docs/man/hpialarms.pod.1 openhpi/trunk/docs/man/hpidomain.pod.1 openhpi/trunk/docs/man/hpiel.pod.1 openhpi/trunk/docs/man/hpievents.pod.1 openhpi/trunk/docs/man/hpifan.pod.1 openhpi/trunk/docs/man/hpigensimdata.pod.1 openhpi/trunk/docs/man/hpiinv.pod.1 openhpi/trunk/docs/man/hpionIBMblade.pod.1 openhpi/trunk/docs/man/hpipower.pod.1 openhpi/trunk/docs/man/hpireset.pod.1 openhpi/trunk/docs/man/hpisensor.pod.1 openhpi/trunk/docs/man/hpisettime.pod.1 openhpi/trunk/docs/man/hpithres.pod.1 openhpi/trunk/docs/man/hpitop.pod.1 openhpi/trunk/docs/man/hpitree.pod.1 openhpi/trunk/docs/man/hpiwdt.pod.1 openhpi/trunk/docs/man/hpixml.pod.1 openhpi/trunk/docs/man/ohdomainlist.pod.1 openhpi/trunk/docs/man/ohhandler.pod.1 openhpi/trunk/docs/man/ohparam.pod.1 openhpi/trunk/docs/man/openhpi.pod.7 Modified: openhpi/trunk/clients/clients.c =================================================================== --- openhpi/trunk/clients/clients.c 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/clients/clients.c 2011-03-03 12:27:30 UTC (rev 7288) @@ -55,16 +55,20 @@ { NULL } }; -// Preparation for option -N / --host (Features 2726603 & 3129972 & 3129967) static GOptionEntry host_option[] = { - { "host", 'N', 0, G_OPTION_ARG_STRING, &optdaemon, "Connect to daemon host:port", "\"host<:port>\"" }, + { "host", 'N', 0, G_OPTION_ARG_STRING, &optdaemon, "Open session to the domain served by the daemon\n" +" at the specified URL (host:port)\n" +" This option overrides the OPENHPI_DAEMON_HOST and\n" +" OPENHPI_DAEMON_PORT environment variables.", "\"host<:port>\"" }, { NULL } }; static GOptionEntry clientconf_option[] = { - { "cfgfile", 'C', 0, G_OPTION_ARG_FILENAME, &optcfgfile, "Use passed file as client configuration file", "\"file\"" }, + { "cfgfile", 'C', 0, G_OPTION_ARG_FILENAME, &optcfgfile, "Use passed file as client configuration file\n" +" This option overrides the OPENHPICLIENT_CONf\n" +" environment variable.", "\"file\"" }, { NULL } }; @@ -82,7 +86,90 @@ } #endif /* _WIN32 */ +/*--------------------------------------------------------------------*/ +/* ohc_domain_add_by_options */ +/*--------------------------------------------------------------------*/ +static SaErrorT ohc_domain_add_by_options(oHpiCommonOptionsT *opt) +{ + SaErrorT rv = SA_OK; + SaHpiDomainIdT did_N = SAHPI_UNSPECIFIED_DOMAIN_ID; + const char *envhoststr, *envportstr; + unsigned short envport; + SaHpiTextBufferT envhost; + SaHpiDomainIdT did_env = SAHPI_UNSPECIFIED_DOMAIN_ID; + // Add a domain for the -N option + if (opt->withdaemonhost) {// add a domain for that host + if (opt->domainid == SAHPI_UNSPECIFIED_DOMAIN_ID) { // add with generated did + rv = oHpiDomainAdd ( &opt->daemonhost, opt->daemonport, &did_N ); + if (rv != SA_OK) { + CRIT("Domain could not be created for given daemonhost"); + return rv; + } + if (opt->debug) DBG("Added domain %u for daemonhost", did_N); + // use this did (thus -N option will override environment variables) + opt->domainid = did_N; + } + else { // add with given domain id + rv = oHpiDomainAddById ( opt->domainid, &opt->daemonhost, opt->daemonport); + if (rv != SA_OK) { + CRIT("Domain %u could not be created for given daemonhost", opt->domainid); + return rv; + } + if (opt->debug) DBG("Added domain %u for daemonhost", opt->domainid); + } + } + + // check always for the environment variables. + envhoststr = getenv("OPENHPI_DAEMON_HOST"); + if (envhoststr != NULL) { // add a domain for this host + oh_init_textbuffer(&envhost); + rv = oh_append_textbuffer(&envhost, envhoststr); + envportstr = getenv("OPENHPI_DAEMON_PORT"); + if (envportstr == NULL) envport = OPENHPI_DEFAULT_DAEMON_PORT; + else envport = atoi(envportstr); + + if (opt->withdaemonhost) { // we will add the domain with a new did, but + // we will not use it now. + rv = oHpiDomainAdd ( &envhost, envport, &did_env ); + if (rv != SA_OK) { + CRIT("Domain could not be created for OPENHPI_DAEMON_HOST %s:%u", + envhoststr, envport); + return rv; + } + if (opt->debug) DBG("Added domain %u for OPENHPI_DAEMON_HOST %s:%u", + did_env, envhoststr, envport); + } + else if (opt->domainid == SAHPI_UNSPECIFIED_DOMAIN_ID) { + // add with generated did (here we don't have -N or -D options) + rv = oHpiDomainAdd ( &envhost, envport, &did_env ); + if (rv != SA_OK) { + CRIT("Domain could not be created for OPENHPI_DAEMON_HOST %s:%u", + envhoststr, envport); + return rv; + } + if (opt->debug) DBG("Added domain %u for OPENHPI_DAEMON_HOST %s:%u", + did_env, envhoststr, envport); + opt->domainid = did_env; + } + + else { // use the given did for OPENHPI_DAEMON_HOST + rv = oHpiDomainAddById ( opt->domainid, &envhost, envport); + if (rv != SA_OK) { + CRIT("Domain %u could not be created for OPENHPI_DAEMON_HOST %s:%u", + opt->domainid, envhoststr, envport); + return rv; + } + if (opt->debug) DBG("Added domain %u for OPENHPI_DAEMON_HOST %s:%u", + opt->domainid, envhoststr, envport); + } + } + return SA_OK; +} + +/*--------------------------------------------------------------------*/ +/* oh_prog_version */ +/*--------------------------------------------------------------------*/ void oh_prog_version(const char *prog_name) { SaHpiUint32T ohpi_major = oHpiVersionGet() >> 48; @@ -99,6 +186,9 @@ hpiver & 0x000000FF); } +/*--------------------------------------------------------------------*/ +/* ohc_option_parse */ +/*--------------------------------------------------------------------*/ gboolean ohc_option_parse(int *argc, char *argv[], GOptionContext *context, oHpiCommonOptionsT *common_options, @@ -108,7 +198,7 @@ SaErrorT rv = SA_OK; if (!argc || !argv || !context || !common_options) { - CRIT ("Internal error. Terminating.\n"); + CRIT ("Internal error. Terminating."); return FALSE; } @@ -120,8 +210,6 @@ g_option_context_add_main_entries (context, verbose_option, NULL); if (optionmask & OHC_ENTITY_PATH_OPTION) g_option_context_add_main_entries (context, entity_path_option, NULL); -// Preparation for option -N / --host (Features 2726603 & 3129972 & 3129967) -// Preliminary implementation like it was in hpi_shell if (optionmask & OHC_HOST_OPTION) g_option_context_add_main_entries (context, host_option, NULL); if (optionmask & OHC_CLIENTCONF_OPTION) @@ -172,9 +260,9 @@ if (colon!=NULL) { *colon = '\0'; common_options->daemonport = atoi(++colon); - setenv("OPENHPI_DAEMON_PORT", colon, 1); + // setenv("OPENHPI_DAEMON_PORT", colon, 1); } else common_options->daemonport = OPENHPI_DEFAULT_DAEMON_PORT; - setenv("OPENHPI_DAEMON_HOST", optdaemon, 1); // copied from hpi_shell + //setenv("OPENHPI_DAEMON_HOST", optdaemon, 1); // copied from hpi_shell rv = oh_append_textbuffer(&common_options->daemonhost, optdaemon); if (optdebug && optverbose) { DBG("Daemon host:port scanned successfully: host="); @@ -185,37 +273,43 @@ oh_init_textbuffer(&common_options->clientconf); if (optcfgfile) { - rv = oh_append_textbuffer(&common_options->daemonhost, optcfgfile); - setenv("OPENHPICLIENT_CONF", optcfgfile, 1); // copied from hpi_shell + rv = oh_append_textbuffer(&common_options->clientconf, optcfgfile); + setenv("OPENHPICLIENT_CONF", optcfgfile, 1); // -C option overrides environment var } g_free (optep); g_free (optdaemon); g_free (optcfgfile); + + // add domains for -N option and environment variables + ohc_domain_add_by_options ( common_options ); + return TRUE; } +/*--------------------------------------------------------------------*/ +/* ohc_session_open_by_option */ +/*--------------------------------------------------------------------*/ SaErrorT ohc_session_open_by_option ( oHpiCommonOptionsT *opt, SaHpiSessionIdT *sessionid) { - // TODO correctly implement -N / -C option SaErrorT rv = SA_OK; if (opt->debug) { - if (opt->domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) printf("saHpiSessionOpen\n"); - else printf("saHpiSessionOpen to domain %u\n",opt->domainid); + if (opt->domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) DBG("saHpiSessionOpen"); + else DBG("saHpiSessionOpen to domain %u",opt->domainid); } rv = saHpiSessionOpen(opt->domainid, sessionid, NULL); if (rv != SA_OK || opt->debug) { - printf("saHpiSessionOpen returns %s\n",oh_lookup_error(rv)); + DBG("saHpiSessionOpen returns %s",oh_lookup_error(rv)); return rv; } if (opt->debug) - printf("saHpiSessionOpen returns with SessionId %u\n", *sessionid); + DBG("saHpiSessionOpen returns with SessionId %u\n", *sessionid); return SA_OK; } Modified: openhpi/trunk/clients/hpievents.c =================================================================== --- openhpi/trunk/clients/hpievents.c 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/clients/hpievents.c 2011-03-03 12:27:30 UTC (rev 7288) @@ -37,8 +37,9 @@ static GOptionEntry my_options[] = { - { "timeout", 't', 0, G_OPTION_ARG_STRING, &timeout_str, "Wait n seconds for event or infinite wait", - "n|BLOCK|SAHPI_TIMEOUT_BLOCK" }, + { "timeout", 't', 0, G_OPTION_ARG_STRING, &timeout_str, "Wait n seconds for event or infinite wait\n" +" (BLOCK or SAHPI_TIMEOUT_BLOCK)", + "n|BLOCK" }, { "discover", 'd', 0, G_OPTION_ARG_NONE, &do_discover_after_subscribe, "Call saHpiDiscover() after saHpiSubscribe()", NULL }, { NULL } Modified: openhpi/trunk/clients/ohdomainlist.c =================================================================== --- openhpi/trunk/clients/ohdomainlist.c 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/clients/ohdomainlist.c 2011-03-03 12:27:30 UTC (rev 7288) @@ -61,8 +61,7 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION // not applicable - - OHC_SESSION_OPTIONS, // not applicable + - OHC_ENTITY_PATH_OPTION, // not applicable error)) { g_option_context_free (context); return 1; Modified: openhpi/trunk/docs/man/hpi_shell.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpi_shell.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpi_shell.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -17,6 +17,8 @@ Once in hpi_shell, use the "help" command for a list of commands, or "help command" for details on a particular command. +If no domain or host is selected, ohparam uses the default domain as specified in the openhpiclient.conf file. + =head1 OPTIONS =over 2 @@ -27,10 +29,15 @@ Application Options: -f, --cmdfile=filename Execute command file -e, --events Show short events, discover after subscribe - -D, --domain=nn Select domain id nn + -D, --domain=nn Initially connect to domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Define a domain at the specified URL (host:port) + and initially connect to that domain + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpialarms.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpialarms.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpialarms.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -15,7 +15,7 @@ hpialarms walks the RPT (Resource Presence Table) for resources that have "Alarm Control" management instruments (SAHPI_CTRL_LED). -If no domain is selected, hpialarms uses a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpialarms uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -37,8 +37,13 @@ -o, --all Set all alarms off -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpidomain.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpidomain.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpidomain.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -12,11 +12,12 @@ =head1 DESCRIPTION hpidomain displays the domain info for the specified domain. -If no domain is selected, hpidomain works with the default domain. +If no domain or host is selected, ohparam uses the default domain as specified in the openhpiclient.conf file. In verbose mode, it walks the DRT and displays domaininfo for all directly related domains. Option -t allows to change the domain tag. + =over 2 (No Option) Display domain info @@ -29,8 +30,13 @@ -D, --domain=nn Select domain id nn -X, --debug Display debug messages -V, --verbose Verbose mode - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpiel.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiel.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpiel.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -20,19 +20,24 @@ =over 2 Help Options: - -h, --help Show help options + -h, --help Show help options Application Options: - -d, --del Display domain event log entries - -c, --clear Clear log before reading event log entries - -p, --resource Pull resource info along with log entry - -r, --rdr Pull RDR info along with log entry - -D, --domain=nn Select domain id nn - -X, --debug Display debug messages - -E, --entity-path="epath" Use entity path epath and display resource - event log entries. - -N, --host="host<:port>" Connect to daemon host:port - -C, --cfgfile="file" Use passed file as client configuration file + -d, --del Display domain event log entries + -c, --clear Clear log before reading event log entries + -p, --resource Pull resource info along with log entry + -r, --rdr Pull RDR info along with log entry + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + -E, --entity-path="epath" Use entity path epath and display resource + event log entries. + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. + -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. If neither -d or -E "<arg>" are specified, event log entries will be shown for all supporting resources by default. Modified: openhpi/trunk/docs/man/hpievents.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpievents.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpievents.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -12,7 +12,7 @@ hpievents polls for events in an opened HPI session. User can specify wait time for the event. User can also select the order between hpi resource (resource event) discovery and hpi event subscription. -If no domain is selected, hpievents polls for events in the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpievents polls for events in the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -20,15 +20,21 @@ =over 2 Help Options: - -h, --help Show help options + -h, --help Show help options Application Options: - -t, --timeout=n|BLOCK|SAHPI_TIMEOUT_BLOCK Wait n seconds for event or infinite wait - -d, --discover Call saHpiDiscover() after saHpiSubscribe() - -D, --domain=nn Select domain id nn - -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port - -C, --cfgfile="file" Use passed file as client configuration file + -t, --timeout=n|BLOCK Wait n seconds for event or infinite wait + (BLOCK or SAHPI_TIMEOUT_BLOCK) + -d, --discover Call saHpiDiscover() after saHpiSubscribe() + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. + -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpifan.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpifan.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpifan.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -12,7 +12,7 @@ hpifan walks the RPT (Resource Present Table) for resouces that have "Fan Control" management instruments (SAHPI_CTRL_FAN_SPEED). -If no domain is selected, hpifan uses a session to the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpifan uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -26,8 +26,13 @@ speed is a number or "auto" for setting fan in auto mode -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpigensimdata.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpigensimdata.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpigensimdata.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -20,7 +20,8 @@ Please refer to README and detailed documentation with the plugin. -If no domain is selected, hpidomain works with the default domain. +If no domain or host is selected, ohparam uses the default domain as specified in the openhpiclient.conf file. + If no file name is specified, the data is displayed on console. =over 2 @@ -33,8 +34,13 @@ -f, --file=filename Name of the file to be generated -m, --mode=UPD|INIT Write update or initial file -D, --domain=nn Select domain id nn - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpiinv.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiinv.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpiinv.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -25,8 +25,13 @@ -D, --domain=nn Select domain id nn -X, --debug Display debug messages -V, --verbose Verbose mode - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpionIBMblade.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpionIBMblade.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpionIBMblade.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -21,6 +21,8 @@ This client application is designed to run **only** inband on an IBM Blade with Basedboard Management Controller (BMC) +If no domain or host is selected, hpionIBMblade uses the default domain as specified in the openhpiclient.conf file. + =head1 OPTIONS =over 2 @@ -31,8 +33,13 @@ Application Options: -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpipower.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpipower.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpipower.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -12,7 +12,7 @@ hpipower searches the Resource Presence Table (RPT) for resources with Power Capability. It sends the requested power action to the selected target. -If no domain is selected, hpievents polls for events in the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpipower uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -30,8 +30,13 @@ -b, --blade=n Specify blade n (1...n) -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpireset.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpireset.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpireset.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -26,8 +26,13 @@ -w, --warm warm resets the system -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpisensor.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisensor.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpisensor.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -13,7 +13,7 @@ hpisensor displays sensor info for all resources with Sensor Capability. Option -E (entity-path) restricts the output on the specified entity-path. -If no domain is selected, hpisensor uses a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpisensor uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -21,17 +21,22 @@ =over 2 Help Options: - -h, --help Show help options + -h, --help Show help options Application Options: - -t, --threshold Show Thresholds also - -r, --range Show Range values also - -s, --eventstate Show EventState also - -D, --domain=nn Select domain id nn - -X, --debug Display debug messages - -E, --entity-path="epath" Use entity path epath - -N, --host="host<:port>" Connect to daemon host:port - -C, --cfgfile="file" Use passed file as client configuration file + -t, --threshold Show Thresholds also + -r, --range Show Range values also + -s, --eventstate Show EventState also + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + -E, --entity-path="epath" Use entity path epath + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. + -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpisettime.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisettime.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpisettime.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -25,8 +25,13 @@ -t, --time=24:12:60 New time of day in 24-hr format -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpithres.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpithres.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpithres.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -11,7 +11,7 @@ hpithres interactively displays sensor info for resources with Sensor Capability. Resources, sensors,and sensor info can be individually selected. -If no domain is selected, hpiel uses a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpithres uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -23,8 +23,13 @@ Application Options: -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpitop.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitop.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpitop.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -14,7 +14,7 @@ hpitop walks the Resource Present Table (RPT) of the managed openHPI complex and displays all the resources and resources' management instruments. -If no domain is selected, hpitop displays information using a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpitop uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -37,8 +37,13 @@ -n, --resource=nn Display only resource nn and its topology -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpitree.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitree.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpitree.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -13,7 +13,7 @@ hpitree walks the Resource Presence Table (RPT) of the managed openHPI complex, and displays in details the resources (rpt's) and resources' management instruments (rdr's) data structures. -If no domain is selected, hpitop displays information using a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpitree uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -38,8 +38,13 @@ (Used with [-cdirs] options) -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpiwdt.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiwdt.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpiwdt.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -12,7 +12,7 @@ hpiwdt reads and enables the watchdog timer. -If no domain is selected, hpiwdt uses a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpiwdt uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -29,8 +29,13 @@ -t, --timeout=n sets timeout to n seconds -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/hpixml.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpixml.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/hpixml.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -11,7 +11,7 @@ hpixml displays system view in XML. -If no domain is selected, hpixml uses a session with the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, hpixml uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -26,8 +26,13 @@ -t, --text Use enum and flag text names instead of raw values -s, --xsd Show XML schema -D, --domain=nn Select domain id nn - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/ohdomainlist.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohdomainlist.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/ohdomainlist.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -20,6 +20,8 @@ Dynamic changes of the domain list done using the oHpiDomainAdd and oHpiDomainAddById API are valid only for the life-time of the client library. +If no domain or host is selected, ohdomainlist lists the domains as specified in the openhpiclient.conf file. + =head1 OPTIONS =over 2 @@ -27,11 +29,16 @@ (No Option) Display domain info Help Options: - -h, --help Show help options + -h, --help Show help options Application Options: - -X, --debug Display debug messages - -V, --verbose Verbose mode + -D, --domain=nn Select domain id nn + -X, --debug Display debug messages + -V, --verbose Verbose mode + -N, --host="host<:port>" Define also a domain at the specified host:port + -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/ohhandler.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohhandler.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/ohhandler.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -36,7 +36,7 @@ Example: ohhandler create plugin libsimulator entity_root "{SYSTEM_CHASSIS,1}" name sim -If no domain is selected, ohhandler uses the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, ohhandler uses the default domain as specified in the openhpiclient.conf file. =head1 OPTIONS @@ -48,8 +48,13 @@ Application Options: -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/ohparam.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohparam.pod.1 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/ohparam.pod.1 2011-03-03 12:27:30 UTC (rev 7288) @@ -15,7 +15,7 @@ ohparam set will change the given global configuration parameters of the openhpi daemon for the specified domain to the new value. -If no domain is selected, ohparam uses the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. +If no domain or host is selected, ohparam uses the default domain as specified in the openhpiclient.conf file. =head1 COMMANDS @@ -46,8 +46,13 @@ Application Options: -D, --domain=nn Select domain id nn -X, --debug Display debug messages - -N, --host="host<:port>" Connect to daemon host:port + -N, --host="host<:port>" Open session to the domain served by the daemon + at the specified URL (host:port) + This option overrides the OPENHPI_DAEMON_HOST and + OPENHPI_DAEMON_PORT environment variables. -C, --cfgfile="file" Use passed file as client configuration file + This option overrides the OPENHPICLIENT_CONf + environment variable. =back Modified: openhpi/trunk/docs/man/openhpi.pod.7 =================================================================== --- openhpi/trunk/docs/man/openhpi.pod.7 2011-02-23 21:22:38 UTC (rev 7287) +++ openhpi/trunk/docs/man/openhpi.pod.7 2011-03-03 12:27:30 UTC (rev 7288) @@ -23,6 +23,9 @@ Some of OpenHPI's functioning can be changed by setting environment variables. This documents all client environmental settings. +Client environmental settings are evaluated in the openhpi library that is +linked to the client. There are other environmental settings for the +openhpi daemon. =over 2 @@ -35,14 +38,15 @@ =item B<OPENHPI_DAEMON_HOST>=URL -URL for the host running the daemon. This can be "localhost" (default) -if the daemon is running on the local host or an ip address. +URL for the host running the daemon which the client wants to connect to. +This can be an ip address or "localhost" (default) if the daemon is running +on the same host as the client. The variable is only used if no default domain is defined via the client conf file. =item B<OPENHPI_DAEMON_PORT>=PORT_NUMBER -The port number the host is listening on for clent connections. +The port number used by the daemon which the client wants to connect to. Default port is 4743. The variable is only used if no default domain is defined via the client conf file. @@ -53,7 +57,7 @@ =head1 HARDWARE SUPPORT OpenHPI provides a number of plugins that talk to different hardware -types. The following is a list of supported plugins. +types. The following is a list of plugins provided by the OpenHPI project. =over 4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2011-03-19 17:05:02
|
Revision: 7291 http://openhpi.svn.sourceforge.net/openhpi/?rev=7291&view=rev Author: ulikleber Date: 2011-03-19 17:04:54 +0000 (Sat, 19 Mar 2011) Log Message: ----------- Fix for 3183692 clients should use CRIT/DBG macros consistently Modified Paths: -------------- openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpialarms.c openhpi/trunk/clients/hpidomain.c openhpi/trunk/clients/hpiel.c openhpi/trunk/clients/hpievents.c openhpi/trunk/clients/hpifan.c openhpi/trunk/clients/hpigensimdata.c openhpi/trunk/clients/hpiinv.c openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/hpipower.c openhpi/trunk/clients/hpireset.c openhpi/trunk/clients/hpisensor.c openhpi/trunk/clients/hpisettime.c openhpi/trunk/clients/hpithres.c openhpi/trunk/clients/hpitop.c openhpi/trunk/clients/hpitree.c openhpi/trunk/clients/hpiwdt.c openhpi/trunk/clients/hpixml/main.cpp openhpi/trunk/clients/oh_clients.h openhpi/trunk/clients/ohdomainlist.c openhpi/trunk/clients/ohhandler.c openhpi/trunk/clients/ohparam.c openhpi/trunk/hpi_shell/hpi_cmd.c Modified: openhpi/trunk/clients/clients.c =================================================================== --- openhpi/trunk/clients/clients.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/clients.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -192,9 +192,9 @@ gboolean ohc_option_parse(int *argc, char *argv[], GOptionContext *context, oHpiCommonOptionsT *common_options, - SaHpiUint8T optionmask, - GError *error) + SaHpiUint8T optionmask ) { + GError *error = NULL; SaErrorT rv = SA_OK; if (!argc || !argv || !context || !common_options) { @@ -230,7 +230,6 @@ if (optdid >= 0) DBG(" --domain=%u ",optdid); if (common_options->withentitypath) DBG(" --entity-path=%s ",optep); if (common_options->withdaemonhost) DBG(" --daemon=%s ",optdaemon); - DBG("\n"); } /* prepare output */ @@ -241,16 +240,15 @@ oh_init_ep(&common_options->entitypath); if (common_options->withentitypath) { rv = oh_encode_entitypath(optep, &common_options->entitypath); - if (error) { - CRIT ("Invalid entity path: %s\n" - "oh_encode_entitypath() returned %s \n", - optep, oh_lookup_error(rv)); - return FALSE; + if (optdebug) DBG("oh_encode_entitypath returned %s", oh_lookup_error(rv)); + if (rv) { + CRIT ("oh_encode_entitypath() returned %s", oh_lookup_error(rv)); + CRIT ("Invalid entity path: %s", optep); + return FALSE; } if (optdebug && optverbose) { DBG("Entity Path encoded successfully: "); oh_print_ep(&common_options->entitypath, 0); - DBG("\n"); } } @@ -303,13 +301,13 @@ rv = saHpiSessionOpen(opt->domainid, sessionid, NULL); - if (rv != SA_OK || opt->debug) { - DBG("saHpiSessionOpen returns %s",oh_lookup_error(rv)); + if (rv != SA_OK) { + CRIT("saHpiSessionOpen returns %s",oh_lookup_error(rv)); return rv; } if (opt->debug) - DBG("saHpiSessionOpen returns with SessionId %u\n", *sessionid); + DBG("saHpiSessionOpen returns with SessionId %u", *sessionid); return SA_OK; } Modified: openhpi/trunk/clients/hpialarms.c =================================================================== --- openhpi/trunk/clients/hpialarms.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpialarms.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -97,7 +97,6 @@ SaHpiCtrlStateT ctlstate; //int raw_val = 0; Option d for raw alarm byte not implemented int b, j; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -113,9 +112,8 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 ? - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 ? + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -130,14 +128,14 @@ if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiDiscover complete, rv = %d\n",rv); + if (copt.debug) DBG("saHpiDiscover complete, rv = %d",rv); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if (rv != SA_OK) printf("RptEntryGet: rv = %d\n",rv); + if (rv != SA_OK) DBG("RptEntryGet: rv = %d\n",rv); if (rv == SA_OK) { /* Walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; @@ -155,23 +153,24 @@ { rv = saHpiRdrGet(sessionid,resourceid, entryid,&nextentryid, &rdr); - if (copt.debug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv); + if (copt.debug) DBG("saHpiRdrGet[%u] rv = %d",entryid,rv); if (rv == SA_OK) { if (rdr.RdrType == SAHPI_CTRL_RDR) { /*type 1 includes alarm LEDs*/ ctlnum = rdr.RdrTypeUnion.CtrlRec.Num; rdr.IdString.Data[rdr.IdString.DataLength] = 0; - if (copt.debug) printf("Ctl[%u]: %u %u %s\n", + if (copt.debug) DBG("Ctl[%u]: %u %u %s", ctlnum, rdr.RdrTypeUnion.CtrlRec.Type, rdr.RdrTypeUnion.CtrlRec.OutputType, rdr.IdString.Data); rv = saHpiControlTypeGet(sessionid,resourceid, ctlnum,&ctltype); - if (copt.debug) printf("saHpiControlTypeGet[%u] rv = %d, type = %u\n",ctlnum,rv,ctltype); + if (copt.debug) DBG("saHpiControlTypeGet[%u] rv = %d, type = %u", + ctlnum,rv,ctltype); rv = saHpiControlGet(sessionid, resourceid, ctlnum, NULL, &ctlstate); if (copt.debug) - printf("saHpiControlStateGet[%u] rv = %d v = %x\n", + DBG("saHpiControlStateGet[%u] rv = %d v = %x", ctlnum,rv,ctlstate.StateUnion.Digital); printf("RDR[%u]: ctltype=%u:%u oem=%02x %s \t", rdr.RecordId, Modified: openhpi/trunk/clients/hpidomain.c =================================================================== --- openhpi/trunk/clients/hpidomain.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpidomain.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -58,7 +58,6 @@ SaErrorT rv = SA_OK; SaHpiSessionIdT sessionid; SaHpiTextBufferT domtag; - GError *error = NULL; GOptionContext *context; oh_init_textbuffer(&domtag); @@ -76,8 +75,7 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? - error)) { + - OHC_ENTITY_PATH_OPTION)) { //TODO: Feature 880127? g_option_context_free (context); return 1; } @@ -92,13 +90,13 @@ if (f_domtag){ oh_append_textbuffer(&domtag, f_domtag); g_free (f_domtag); - if (copt.debug) printf ("Let's go change the tag" - "to %s\n",f_domtag); + if (copt.debug) DBG ("Let's go change the tag to %s", + f_domtag); set_domaintag(sessionid, domtag); } - if (copt.debug) printf ("Let's go and list the domains!\n"); + if (copt.debug) DBG ("Let's go and list the domains!"); show_domain(sessionid); @@ -123,10 +121,10 @@ SaHpiDomainIdT relateddomainid = SAHPI_UNSPECIFIED_DOMAIN_ID; SaHpiSessionIdT relatedsessionid; - if (copt.debug) printf("saHpiDomainInfoGet\n"); + if (copt.debug) DBG("saHpiDomainInfoGet"); rv = saHpiDomainInfoGet(sessionid,&domaininfo); if (rv!=SA_OK) { - printf("saHpiDomainInfoGet failed with returncode %s\n", + CRIT("saHpiDomainInfoGet failed with returncode %s", oh_lookup_error(rv)); return rv; } @@ -137,11 +135,11 @@ /* walk the DRT */ drtentryid = SAHPI_FIRST_ENTRY; do { - if (copt.debug) printf("saHpiDrtEntryGet\n"); + if (copt.debug) DBG("saHpiDrtEntryGet"); rv = saHpiDrtEntryGet(sessionid, drtentryid,&nextdrtentryid,&drtentry); if ((rv != SA_OK && rv != SA_ERR_HPI_NOT_PRESENT) || copt.debug) - printf("DrtEntryGet returns %s\n",oh_lookup_error(rv)); + DBG("DrtEntryGet returns %s",oh_lookup_error(rv)); if (rv == SA_OK ) { if (copt.verbose) { @@ -158,9 +156,9 @@ continue; } if (copt.debug) { - printf("saHpiSessionOpen returns with SessionId %u\n", + DBG("saHpiSessionOpen returns with SessionId %u", relatedsessionid); - printf("saHpiDomainInfoGet for related domain %u\n", + DBG("saHpiDomainInfoGet for related domain %u", relateddomainid); } rv = saHpiDomainInfoGet(relatedsessionid, @@ -180,7 +178,7 @@ rv = saHpiSessionClose(relatedsessionid); if (copt.debug) - printf("saHpiSessionClose returns %s\n", + DBG("saHpiSessionClose returns %s", oh_lookup_error(rv)); } @@ -192,9 +190,9 @@ else if (rv == SA_ERR_HPI_NOT_PRESENT) { if (drtentryid == SAHPI_FIRST_ENTRY) printf(" DRT is empty. \n"); - else printf("Internal error while walking the DRT\n"); + else CRIT("Internal error while walking the DRT"); } - else printf("Internal error while walking the DRT\n"); + else CRIT("Internal error while walking the DRT"); drtentryid = nextdrtentryid; } while ((rv == SA_OK) && (drtentryid != SAHPI_LAST_ENTRY)); @@ -279,10 +277,10 @@ SaHpiDomainInfoT domaininfo; - if (copt.debug) printf("saHpiDomainInfoGet\n"); + if (copt.debug) DBG("saHpiDomainInfoGet"); rv = saHpiDomainInfoGet(sessionid,&domaininfo); if (rv!=SA_OK) { - printf("saHpiDomainInfoGet failed with returncode %s\n", + CRIT("saHpiDomainInfoGet failed with returncode %s", oh_lookup_error(rv)); return rv; } @@ -293,9 +291,9 @@ rv = saHpiDomainTagSet (sessionid, &domtag); if (rv!=SA_OK) - printf("saHpiDomainTagSet failed with returncode %s. " - "Tag not changed.\n",oh_lookup_error(rv)); - else if (copt.debug) printf("saHpiDomainTagSet completed.\n"); + CRIT("saHpiDomainTagSet failed with returncode %s. " + "Tag not changed.",oh_lookup_error(rv)); + else if (copt.debug) DBG("saHpiDomainTagSet completed."); return rv; } Modified: openhpi/trunk/clients/hpiel.c =================================================================== --- openhpi/trunk/clients/hpiel.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpiel.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -67,7 +67,6 @@ SaErrorT error = SA_OK; SaHpiSessionIdT sid; SaHpiDomainInfoT dinfo; - GError *gerror = NULL; GOptionContext *context; /* Print version strings */ @@ -85,9 +84,8 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_VERBOSE_OPTION, // no verbose mode implemented - gerror)) { - g_print ("option parsing failed: %s\n", gerror->message); + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented + g_option_context_free (context); return 1; } g_option_context_free (context); Modified: openhpi/trunk/clients/hpievents.c =================================================================== --- openhpi/trunk/clients/hpievents.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpievents.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -60,7 +60,6 @@ SaHpiRdrT rdr; SaHpiTimeoutT timeout; SaHpiEventT event; - GError *error = NULL; GOptionContext *context; memset(&rptentry, 0, sizeof(rptentry)); @@ -78,9 +77,8 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -110,33 +108,33 @@ if (rv != SA_OK) return -1; if (!do_discover_after_subscribe) { - if (copt.debug) printf("saHpiDiscover\n"); + if (copt.debug) DBG("saHpiDiscover"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { - CRIT("saHpiDiscover: %s\n", oh_lookup_error(rv)); + CRIT("saHpiDiscover: %s", oh_lookup_error(rv)); return rv; } } - if (copt.debug) printf( "Subscribe to events\n"); + if (copt.debug) DBG( "Subscribe to events\n"); rv = saHpiSubscribe( sessionid ); if (rv != SA_OK) { - CRIT("saHpiSubscribe: %s\n", oh_lookup_error(rv)); + CRIT("saHpiSubscribe: %s", oh_lookup_error(rv)); return rv; } if (do_discover_after_subscribe) { - if (copt.debug) printf("saHpiDiscover after saHpiSubscribe\n"); + if (copt.debug) DBG("saHpiDiscover after saHpiSubscribe"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { - CRIT("saHpiDiscover after saHpiSubscribe: %s\n", oh_lookup_error(rv)); + CRIT("saHpiDiscover after saHpiSubscribe: %s", oh_lookup_error(rv)); return rv; } } rv = saHpiDomainInfoGet(sessionid, &domainInfo); - if (copt.debug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiDomainInfoGet %s", oh_lookup_error(rv)); printf("DomainInfo: UpdateCount = %u, UpdateTime = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); @@ -146,24 +144,24 @@ printf("**********************************************\n"); rv = saHpiRptEntryGet(sessionid, rptentryid, &nextrptentryid, &rptentry); - if (copt.debug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiRptEntryGet %s", oh_lookup_error(rv)); if (rv == SA_OK) { resourceid = rptentry.ResourceId; if (copt.debug) - printf("RPT %x capabilities = %x\n", resourceid, + DBG("RPT %x capabilities = %x", resourceid, rptentry.ResourceCapabilities); if ( (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_EVENT_LOG)) { /* Using EventLogInfo to build up event queue - for now */ rv = saHpiEventLogInfoGet(sessionid, resourceid, &info); if (copt.debug) - printf("saHpiEventLogInfoGet %s\n", oh_lookup_error(rv)); + DBG("saHpiEventLogInfoGet %s", oh_lookup_error(rv)); if (rv == SA_OK) oh_print_eventloginfo(&info, 4); } else { if (copt.debug) - printf("RPT doesn't have SEL\n"); + DBG("RPT doesn't have SEL"); } rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; @@ -219,7 +217,7 @@ printf(" Test FAILED.\n"); /* Unsubscribe to future events */ - if (copt.debug) printf( "Unsubscribe\n"); + if (copt.debug) DBG( "Unsubscribe"); rv = saHpiUnsubscribe( sessionid ); rv = saHpiSessionClose(sessionid); Modified: openhpi/trunk/clients/hpifan.c =================================================================== --- openhpi/trunk/clients/hpifan.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpifan.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -50,7 +50,7 @@ { SaHpiCtrlStateT state; - if (copt.debug) printf("get fan speed for resource %u, control %u\n", resource_id, ctrl_num); + if (copt.debug) DBG("get fan speed for resource %u, control %u", resource_id, ctrl_num); SaErrorT rv = saHpiControlGet( session_id, resource_id, ctrl_num, mode, &state ); @@ -82,7 +82,7 @@ state.Type = SAHPI_CTRL_TYPE_ANALOG; state.StateUnion.Analog = speed; - if (copt.debug) printf("set fan speed for resource %u, control %u\n", resource_id, ctrl_num); + if (copt.debug) DBG("set fan speed for resource %u, control %u", resource_id, ctrl_num); rv = saHpiControlSet( session_id, resource_id, ctrl_num, mode, &state ); if ( rv != SA_OK ) { @@ -228,7 +228,6 @@ { SaErrorT rv; SaHpiSessionIdT sessionid; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -244,9 +243,8 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -275,19 +273,19 @@ /* * Resource discovery */ - if (copt.debug) printf("saHpiDiscover\n"); + if (copt.debug) DBG("saHpiDiscover"); rv = saHpiDiscover(sessionid); if ( rv != SA_OK ) { - CRIT( "saHpiDiscover: %s\n", oh_lookup_error( rv ) ); + CRIT( "saHpiDiscover: %s", oh_lookup_error( rv ) ); return rv; } - if (copt.debug) printf("Discovery done\n"); + if (copt.debug) DBG("Discovery done"); int rc = discover_domain( sessionid ); rv = saHpiSessionClose( sessionid ); if ( rv != SA_OK ) - CRIT( "saHpiSessionClose: %s\n", oh_lookup_error( rv ) ); + CRIT( "saHpiSessionClose: %s", oh_lookup_error( rv ) ); return rc; } Modified: openhpi/trunk/clients/hpigensimdata.c =================================================================== --- openhpi/trunk/clients/hpigensimdata.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpigensimdata.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -294,7 +294,6 @@ SaHpiSessionIdT sessionid; FILE *outfile = stdout; ConfigurationDataT confdata; - GError *error = NULL; GOptionContext *context; confdata.mode = MODE_INIT; @@ -316,17 +315,15 @@ OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION // no verbose mode - - OHC_DEBUG_OPTION, // no debug mode - error)) { + - OHC_DEBUG_OPTION )) { // no debug mode GFREE return 1; } - GFREE if (g_file) { outfile = fopen(g_file, "w"); if (outfile == NULL) { - fprintf(stderr, "\n%s couldn't be opened for writing.\n", g_file); + CRIT("%s couldn't be opened for writing.", g_file); GFREE return 1; } @@ -349,7 +346,7 @@ return 1; } } - + /** * Initialize the offset strings **/ Modified: openhpi/trunk/clients/hpiinv.c =================================================================== --- openhpi/trunk/clients/hpiinv.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpiinv.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -178,7 +178,7 @@ strncpy ((char *)outstr, (char *)strptr->Data, datalen); outstr[datalen] = 0; if (copt.debug) { - printf("TextBuffer len=%u, dtype=%x lang=%u: %s\n", + DBG("TextBuffer len=%u, dtype=%x lang=%u: %s", strptr->DataLength,strptr->DataType,strptr->Language, strptr->Data ); } @@ -451,7 +451,7 @@ fieldId, &nextFieldId, &thisField); if (copt.debug) - printf("saHpiIdrFieldGet[%x] rv = %d type=%u\n", + DBG("saHpiIdrFieldGet[%x] rv = %d type=%u", idrInfo->IdrId,rvField, thisField.Type); if (rvField == SA_OK) { @@ -503,7 +503,6 @@ SaHpiIdrIdT idrid; int invfound = 0; int nloops = 0; - GError *error = NULL; GOptionContext *context; atag.tlen = 0; @@ -521,8 +520,7 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION, //TODO: Feature 880127? - error)) { + - OHC_ENTITY_PATH_OPTION )) { //TODO: Feature 880127? g_option_context_free (context); return 1; } @@ -541,8 +539,8 @@ if (rv != SA_OK) return rv; rv = saHpiDomainInfoGet(sessionid,&rptinfo); - if (copt.debug) printf("saHpiDomainInfoGet rv = %d\n",rv); - // if (copt.debug) printf("RptInfo: UpdateCount = %x, UpdateTime = %lx\n", + if (copt.debug) DBG("saHpiDomainInfoGet rv = %d",rv); + // if (copt.debug) DBG("RptInfo: UpdateCount = %x, UpdateTime = %lx", // rptinfo.UpdateCount, (unsigned long)rptinfo.UpdateTimestamp); while (!invfound && (nloops < 7)) @@ -553,11 +551,11 @@ * This should not apply to other well-behaved plugins. */ nloops++; - if (copt.debug) printf("Starting Discovery, pass %u ...\n",nloops); + if (copt.debug) DBG("Starting Discovery, pass %u ...",nloops); rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiDiscover rv = %d\n",rv); + if (copt.debug) DBG("saHpiDiscover rv = %d",rv); if (rv != SA_OK) { - printf("saHpiDiscover error %d\n",rv); + CRIT("saHpiDiscover error %d",rv); break; } @@ -576,7 +574,7 @@ /* walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; resourceid = rptentry.ResourceId; - if (copt.debug) printf("rptentry[%u] resourceid=%d\n", rptentryid,resourceid); + if (copt.debug) DBG("rptentry[%u] resourceid=%d", rptentryid,resourceid); if (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_INVENTORY_DATA) { printf("Resource[%u] Tag: %s \thas inventory capability\n", rptentryid,tagstr); @@ -584,10 +582,10 @@ while ((rv_rdr == SA_OK) && (entryid != SAHPI_LAST_ENTRY)) { rv_rdr = saHpiRdrGet(sessionid,resourceid, entryid,&nextentryid, &rdr); - if (copt.debug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv_rdr); + if (copt.debug) DBG("saHpiRdrGet[%u] rv = %d",entryid,rv_rdr); if (rv_rdr == SA_OK) { - if (copt.debug) printf("Rdr[%u] type = %u tag = %s\n",entryid, + if (copt.debug) DBG("Rdr[%u] type = %u tag = %s",entryid, rdr.RdrType,rdr.IdString.Data); if (rdr.RdrType == SAHPI_INVENTORY_RDR) { @@ -597,8 +595,8 @@ idrid = rdr.RdrTypeUnion.InventoryRec.IdrId; buffersize = sizeof(inbuff); if (copt.debug) { - printf("Rdr[%x] is inventory, IdrId=%x\n",rdr.RecordId,idrid); - printf("Inv BufferSize=%u\n", buffersize); + DBG("Rdr[%x] is inventory, IdrId=%x",rdr.RecordId,idrid); + DBG("Inv BufferSize=%u", buffersize); } if ( IsTagBmc((char *)rdr.IdString.Data, rdr.IdString.DataLength) ) { @@ -608,13 +606,13 @@ if (rv_rdr != SA_OK) { printf("IDR Info error: rv_rdr = %d\n",rv_rdr); } else { /* idrInfo is ok */ - if (copt.debug) printf("IDR Info: ok \n"); + if (copt.debug) DBG("IDR Info: ok "); print_epath(&rptentry.ResourceEntity, 1); printf("RDR[%x]: Inventory, IdrId=%x %s\n",rdr.RecordId, idrid,rdr.IdString.Data); print_idrinfo(&idrInfo,4); rv_rdr = walkInventory(sessionid, resourceid, &idrInfo); - if (copt.debug) printf("walkInventory rv_rdr = %d\n",rv_rdr); + if (copt.debug) DBG("walkInventory rv_rdr = %d",rv_rdr); } if (!ent_writable(&rptentry.ResourceEntity,&idrInfo)) @@ -638,22 +636,22 @@ if (rv_rdr == SA_OK) { printf ("Good write - re-reading!\n"); rv_rdr = walkInventory(sessionid, resourceid, &idrInfo); - if (copt.debug) printf("walkInventory rv_rdr = %d\n",rv_rdr); + if (copt.debug) DBG("walkInventory rv_rdr = %d",rv_rdr); } /* Good write - re-read */ } /*endif foundasset*/ } /*endif RDR tag ok*/ } /* Inventory Data Records - Type 3 */ - else if (copt.debug) printf("rdr type = %u\n", rdr.RdrType); + else if (copt.debug) DBG("rdr type = %u", rdr.RdrType); } /*endif RdrGet ok*/ entryid = nextentryid; } /*end while rdr*/ } /*endif rpt invent capab*/ else - if (copt.debug) printf("Resource[%u] Tag: %s\n", rptentryid,tagstr); + if (copt.debug) DBG("Resource[%u] Tag: %s", rptentryid,tagstr); } /*endif rpt ok*/ rptentryid = nextrptentryid; } /*end rpt loop */ - if (copt.debug) printf("loop %u inventory found = %d\n",nloops,invfound); + if (copt.debug) DBG("loop %u inventory found = %d",nloops,invfound); } /*end while no inv */ rv = saHpiSessionClose(sessionid); return 0; Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpionIBMblade.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -225,13 +225,13 @@ Rpt->Rpt.ResourceId, &this_handler_id); if (rv) { - if (copt.debug) printf("oHpiHandlerFind returns %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("oHpiHandlerFind returns %s", oh_lookup_error(rv)); return(0); } rv = oHpiHandlerInfo(sessionid, this_handler_id, &handler_info, config); if (rv) { - if (copt.debug) printf("oHpiHandlerInfo returns %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("oHpiHandlerInfo returns %s", oh_lookup_error(rv)); return(0); } @@ -356,7 +356,7 @@ R->Rdr.RdrTypeUnion.SensorRec.Num, &(R->reading), NULL); if (rv != SA_OK) { - printf("ERROR: %s\n", oh_lookup_error(rv)); + CRIT("ERROR: saHpiSensorReadingGet returns %s", oh_lookup_error(rv)); return; }; k = R->Rdr.RdrTypeUnion.SensorRec.DataFormat.BaseUnits; @@ -373,7 +373,7 @@ rv = saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, R->Rdr.RdrTypeUnion.SensorRec.Num, &buf); if (rv != SA_OK) { - printf("ERROR: %s\n", oh_lookup_error(rv)); + CRIT("ERROR: saHpiSensorThresholdsGet returns %s\n", oh_lookup_error(rv)); return; }; printf(" Thresholds:\n"); @@ -572,7 +572,7 @@ rv = saHpiSensorThresholdsSet(sessionid, Rpt->Rpt.ResourceId, Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres); if (rv != SA_OK) { - printf("ERROR: saHpiSensorThresholdsSet: %s\n", oh_lookup_error(rv)); + CRIT("ERROR: saHpiSensorThresholdsSet: %s", oh_lookup_error(rv)); return; }; Rdr->modify = 1; @@ -581,7 +581,7 @@ NULL, NULL, NULL); if (rv == SA_OK) break; - if (copt.debug) printf("sleep before saHpiEventGet\n"); + if (copt.debug) DBG("sleep before saHpiEventGet\n"); g_usleep(G_USEC_PER_SEC); }; saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, @@ -895,7 +895,6 @@ SaErrorT rv; char buf[READ_BUF_SIZE]; char *S; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -913,8 +912,7 @@ context, &copt, OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION // not implemented - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -922,7 +920,7 @@ rv = hpiIBMspecial_find_blade_slot(); if (rv != SA_OK) { - printf("ipmitool can not find slot number in which this blade resides.\n"); + CRIT("ipmitool can not find slot number in which this blade resides."); return(-1); } @@ -931,11 +929,11 @@ rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiDiscover: %s", oh_lookup_error(rv)); rv = saHpiSubscribe(sessionid); if (rv != SA_OK) { - printf( "saHpiSubscribe error %d\n",rv); + CRIT( "saHpiSubscribe error %d",rv); return rv; } Modified: openhpi/trunk/clients/hpipower.c =================================================================== --- openhpi/trunk/clients/hpipower.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpipower.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -26,8 +26,10 @@ #define OH_SVN_REV "$Revision$" #define MAX_MANAGED_SYSTEMS 80 -#define HPI_POWER_DEBUG_PRINT(a) if(copt.debug==TRUE)printf(a) +#define HPI_POWER_DEBUG_PRINT(a) if(copt.debug==TRUE)DBG(a) +#define HPI_POWER_DEBUG_PRINT1(a) if(copt.debug==TRUE)printf(a) + typedef struct COMPUTER_DATA_ { SaHpiResourceIdT ResID; @@ -94,7 +96,6 @@ SaHpiInt32T Index, EntityElement; SaHpiPowerStateT PowerState; char PowerStateString[3][7]={"off\0","on\0","cycled\0"}; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -111,8 +112,7 @@ context, &copt, OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -146,33 +146,33 @@ /* Initialize the first of a list of computers */ - HPI_POWER_DEBUG_PRINT("1.0 Initializing the List Structure for the computers\n"); + HPI_POWER_DEBUG_PRINT("Initializing the List Structure for the computers"); Computer = g_slist_alloc(); ComputerListHead = Computer; - HPI_POWER_DEBUG_PRINT("1.1 Allocating space for the information on each computer\n"); + HPI_POWER_DEBUG_PRINT("Allocating space for the information on each computer"); ComputerPtr = (COMPUTER_DATA*)malloc(sizeof(COMPUTER_DATA)); Computer->data = (gpointer)ComputerPtr; /* Initialize HPI domain and session */ - HPI_POWER_DEBUG_PRINT("2.1 Initalizing HPI Session\n"); + HPI_POWER_DEBUG_PRINT("Initalizing HPI Session"); Status = ohc_session_open_by_option ( &copt, &SessionId); if (Status == SA_OK) { /* Find all of the individual systems */ // regenerate the Resource Presence Table(RPT) - HPI_POWER_DEBUG_PRINT("2.2 Hpi Discovery\n"); + HPI_POWER_DEBUG_PRINT("Hpi Discovery"); Status = saHpiDiscover(SessionId); } else { - printf("2.1 Initalizing HPI Session FAILED, code %s\n", oh_lookup_error(Status)); + CRIT("Initalizing HPI Session FAILED, code %s", oh_lookup_error(Status)); return -1; } - HPI_POWER_DEBUG_PRINT("3.0 Walking through all of the Report Tables\n"); + HPI_POWER_DEBUG_PRINT("Walking through all of the Report Tables"); while ((Status == SA_OK) && (RptEntry != SAHPI_LAST_ENTRY)) { - HPI_POWER_DEBUG_PRINT("@"); + HPI_POWER_DEBUG_PRINT1("@"); Status = saHpiRptEntryGet(SessionId, RptEntry, &RptNextEntry, @@ -181,12 +181,12 @@ // Blades will have the first Element of the Entity Path set to SBC_BLADE EntityElement = 0; - HPI_POWER_DEBUG_PRINT("."); + HPI_POWER_DEBUG_PRINT1("."); if (Report.ResourceCapabilities & SAHPI_CAPABILITY_POWER) { char tagbuf[SAHPI_MAX_TEXT_BUFFER_LENGTH + 1]; - HPI_POWER_DEBUG_PRINT("#"); + HPI_POWER_DEBUG_PRINT1("#"); // We have found a Blade ComputerPtr->ResID = Report.ResourceId; /* enumerate this list as created */ @@ -211,15 +211,15 @@ } } - HPI_POWER_DEBUG_PRINT("\n4.0 Generating Listing of options to choose from:\n"); + HPI_POWER_DEBUG_PRINT("Generating Listing of options to choose from:"); /* If parsed option does not select blade and more than one is found */ if ((MultipleBlades == TRUE) && (BladeSelected == FALSE) && (Status == SA_OK)) { - HPI_POWER_DEBUG_PRINT("4.1 Printing out a listing of all the blades\n"); + HPI_POWER_DEBUG_PRINT("Printing out a listing of all the blades"); for (Index = 0; Index < ComputerNumber; Index++) { - HPI_POWER_DEBUG_PRINT("$"); + HPI_POWER_DEBUG_PRINT1("$"); // obtain the information for this computer ComputerPtr = g_slist_nth_data(ComputerListHead, Index); if (ComputerPtr == NULL) @@ -229,7 +229,7 @@ } // retrieve the power status for this computer - HPI_POWER_DEBUG_PRINT("%%"); + HPI_POWER_DEBUG_PRINT1("%%"); PowerState = 0; Status = saHpiResourcePowerStateGet(SessionId, ComputerPtr->ResID, @@ -258,7 +258,7 @@ BladeSelected = TRUE; SelectedSystem = Index; } - HPI_POWER_DEBUG_PRINT("4.2 Generating Listing of Actions to choose from\n"); + HPI_POWER_DEBUG_PRINT("Generating Listing of Actions to choose from"); /* If action is not selected */ if ((ActionSelected == FALSE) && (Status == SA_OK)) { @@ -288,7 +288,7 @@ if (Status == SA_OK) { - HPI_POWER_DEBUG_PRINT("5.0 Executing the command\n\r"); + HPI_POWER_DEBUG_PRINT("Executing the command"); // obtain the information for this computer ComputerPtr = g_slist_nth_data(ComputerListHead, SelectedSystem); if (ComputerPtr == NULL) @@ -299,7 +299,7 @@ if (Action <= SAHPI_POWER_CYCLE) { - HPI_POWER_DEBUG_PRINT("5.1 Setting a New Power State\n\r"); + HPI_POWER_DEBUG_PRINT("Setting a New Power State"); // Set the new power status for this computer Status = saHpiResourcePowerStateSet(SessionId, ComputerPtr->ResID, @@ -315,7 +315,7 @@ } else // Report Power status for the system { - HPI_POWER_DEBUG_PRINT("5.2 Getting the Power Status\n\r"); + HPI_POWER_DEBUG_PRINT("Getting the Power Status\r"); // retrieve the power status for this computer PowerState = 0; Status = saHpiResourcePowerStateGet(SessionId, @@ -333,7 +333,7 @@ PowerStateString[PowerState]); } } - HPI_POWER_DEBUG_PRINT("6.0 Clean up"); + HPI_POWER_DEBUG_PRINT("Clean up"); /* clean up */ saHpiSessionClose(SessionId); @@ -351,8 +351,8 @@ if (Status != SA_OK) { - HPI_POWER_DEBUG_PRINT("7.0 Reporting Bad Status"); - printf("Program %s returns with Error = %s\n", argv[0], oh_lookup_error(Status)); + HPI_POWER_DEBUG_PRINT("Reporting Bad Status"); + CRIT("Error: %s", oh_lookup_error(Status)); } return(Status); Modified: openhpi/trunk/clients/hpireset.c =================================================================== --- openhpi/trunk/clients/hpireset.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpireset.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -57,7 +57,6 @@ SaHpiEntryIdT entryid; SaHpiResourceIdT resourceid; SaHpiResetActionT action = SAHPI_COLD_RESET; // hard reset as default - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -74,8 +73,7 @@ context, &copt, OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127? - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -87,9 +85,9 @@ if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiDiscover rv = %d\n",rv); + if (copt.debug) DBG("saHpiDiscover rv = %d",rv); rv = saHpiDomainInfoGet(sessionid, &domainInfo); - if (copt.debug) printf("saHpiDomainInfoGet rv = %d\n",rv); + if (copt.debug) DBG("saHpiDomainInfoGet rv = %d",rv); printf("RptInfo: UpdateCount = %x, UpdateTime = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); Modified: openhpi/trunk/clients/hpisensor.c =================================================================== --- openhpi/trunk/clients/hpisensor.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpisensor.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -213,7 +213,6 @@ SaHpiEntryIdT nextentryid; SaHpiResourceIdT resourceid; SaHpiRdrT rdr; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -229,8 +228,7 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -240,13 +238,13 @@ if (rv != SA_OK) return rv; - if (copt.debug) printf("Starting Discovery ...\n"); + if (copt.debug) DBG("Starting Discovery "); rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiResourcesDiscover %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiDiscover returned %s", oh_lookup_error(rv)); rv = saHpiDomainInfoGet(sessionid,&dinfo); - if (copt.debug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiDomainInfoGet returned %s", oh_lookup_error(rv)); printf("RptInfo: UpdateCount = %u, UpdateTime = %lx\n", dinfo.RptUpdateCount, (unsigned long)dinfo.RptUpdateTimestamp); @@ -256,7 +254,7 @@ while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if (copt.debug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiRptEntryGet returned %s", oh_lookup_error(rv)); if (rv == SA_OK) { /* Walk the RDR list for this RPT entry */ @@ -278,7 +276,7 @@ { rv = saHpiRdrGet(sessionid,resourceid, entryid,&nextentryid, &rdr); - if (copt.debug) printf("saHpiRdrGet[%u] rv = %d\n",entryid,rv); + if (copt.debug) DBG("saHpiRdrGet[%u] returned %s",entryid,oh_lookup_error(rv)); if (rv == SA_OK) { rdr.IdString.Data[rdr.IdString.DataLength] = 0; if (rdr.RdrType == SAHPI_SENSOR_RDR) { Modified: openhpi/trunk/clients/hpisettime.c =================================================================== --- openhpi/trunk/clients/hpisettime.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpisettime.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -78,7 +78,6 @@ SaHpiTimeT newtime; SaHpiTimeT readbacktime; SaHpiTextBufferT buffer; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -95,32 +94,30 @@ context, &copt, OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION // not applicable - - OHC_VERBOSE_OPTION, // no verbose mode - error)) { - g_print ("option parsing failed: %s\n", error->message); + - OHC_VERBOSE_OPTION )) { // no verbose mode g_option_context_free (context); EXIT1; } g_option_context_free (context); if ( !findate || !fintime) { - printf("Please enter date and time to be set.\n"); + CRIT("Please enter date and time to be set."); EXIT1; } if (findate) { if (copt.debug) printf("New date to be set: %s\n",findate); if (sscanf(findate,"%2d/%2d/%4d", &month, &day, &year) != 3) { - printf("%s: Invalid date\n", argv[0]); + CRIT("%s: Invalid date", argv[0]); EXIT1; } /* check month, day and year for correctness */ if ((month < 1) || (month > 12)) { - printf("%s: Month out of range: (%d)\n", argv[0], month); + CRIT("%s: Month out of range: (%d)", argv[0], month); EXIT1; }; if (year < 1900) { - printf("%s: Year out of range: (%d)\n", argv[0], year); + CRIT("%s: Year out of range: (%d)", argv[0], year); EXIT1; }; month--; @@ -130,7 +127,7 @@ day_array[1] = 29; }; if ((day < 1) || (day > day_array[month])) { - printf("%s: Day out of range: (%d)\n", argv[0], day); + CRIT("%s: Day out of range: (%d)", argv[0], day); EXIT1; }; @@ -140,43 +137,44 @@ } if (fintime) { - if (copt.debug) printf("New time to be set: %s\n",fintime); + if (copt.debug) DBG("New time to be set: %s",fintime); if (sscanf(fintime,"%2d:%2d:%2d", &new_tm_time.tm_hour, &new_tm_time.tm_min, &new_tm_time.tm_sec) != 3) { - printf("%s: Invalid time\n", argv[0]); + CRIT("%s: Invalid time", argv[0]); EXIT1; } /* check hours, minutes and seconds for correctness */ if ((new_tm_time.tm_hour < 0) || (new_tm_time.tm_hour > 24)) { - printf("%s: Hours out of range: (%d)\n", argv[0], new_tm_time.tm_hour); + CRIT("%s: Hours out of range: (%d)", argv[0], new_tm_time.tm_hour); EXIT1; }; if ((new_tm_time.tm_min < 0) || (new_tm_time.tm_min > 60)) { - printf("%s: Minutes out of range: (%d)\n", argv[0], new_tm_time.tm_min); + CRIT("%s: Minutes out of range: (%d)", argv[0], new_tm_time.tm_min); EXIT1; }; if ((new_tm_time.tm_sec < 0) || (new_tm_time.tm_sec > 60)) { - printf("%s: Seconds out of range: (%d)\n", argv[0], new_tm_time.tm_sec); + CRIT("%s: Seconds out of range: (%d)", argv[0], new_tm_time.tm_sec); EXIT1; } } - if (copt.debug) printf("Values passed to mktime():\n\tmon %d\n\tday %d\n\tyear %d\n\tHH %d\n\tMM %d\n\tSS %d\n", + if (copt.debug) DBG("Values passed to mktime():\n\tmon %d\n\tday %d\n\tyear %d\n\tHH %d\n\tMM %d\n\tSS %d", new_tm_time.tm_mon, new_tm_time.tm_mday, new_tm_time.tm_year, new_tm_time.tm_hour, new_tm_time.tm_min, new_tm_time.tm_sec); newtime = (SaHpiTimeT) mktime(&new_tm_time) * 1000000000; if (copt.debug) - printf("New date and time in SaHpiTimeT %" PRId64 "\n\n", (int64_t)newtime); + DBG("New date and time in SaHpiTimeT %" PRId64 "\n", (int64_t)newtime); rv = ohc_session_open_by_option ( &copt, &sessionid); if (rv != SA_OK) EXIT1; + if (copt.debug) DBG("saHpiDiscover"); rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiDiscover %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiDiscover %s", oh_lookup_error(rv)); rv = saHpiDomainInfoGet(sessionid, &domainInfo); - if (copt.debug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiDomainInfoGet %s", oh_lookup_error(rv)); printf("DomainInfo: RptUpdateCount = %u, RptUpdateTimestamp = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); @@ -185,10 +183,10 @@ while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if (copt.debug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiRptEntryGet %s", oh_lookup_error(rv)); if ((rv == SA_OK) && (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_EVENT_LOG)) { resourceid = rptentry.ResourceId; - if (copt.debug) printf("RPT %x capabilities = %x\n", resourceid, + if (copt.debug) DBG("RPT %x capabilities = %x", resourceid, rptentry.ResourceCapabilities); rv = saHpiEventLogTimeGet(sessionid, resourceid, &oldtime); oh_decode_time(oldtime, &buffer); @@ -197,7 +195,7 @@ rv = saHpiEventLogTimeSet(sessionid, resourceid, newtime); if (rv != SA_OK) { - printf("saHpiEventLogTimeSet %s\n", oh_lookup_error(rv)); + CRIT("saHpiEventLogTimeSet returned %s", oh_lookup_error(rv)); } rv = saHpiEventLogTimeGet(sessionid, resourceid, &readbacktime); oh_decode_time(readbacktime, &buffer); Modified: openhpi/trunk/clients/hpithres.c =================================================================== --- openhpi/trunk/clients/hpithres.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpithres.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -277,7 +277,7 @@ R->Rdr.RdrTypeUnion.SensorRec.Num, &(R->reading), NULL); if (rv != SA_OK) { - printf("ERROR: %s\n", oh_lookup_error(rv)); + CRIT("ERROR: saHpiSensorReadingGet returned %s", oh_lookup_error(rv)); return; }; k = R->Rdr.RdrTypeUnion.SensorRec.DataFormat.BaseUnits; @@ -294,7 +294,7 @@ rv = saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, R->Rdr.RdrTypeUnion.SensorRec.Num, &buf); if (rv != SA_OK) { - printf("ERROR: %s\n", oh_lookup_error(rv)); + CRIT("ERROR: saHpiSensorThresholdsGet returned %s", oh_lookup_error(rv)); return; }; printf(" Thresholds:\n"); @@ -368,7 +368,7 @@ static void set_thres_value(SaHpiSensorReadingT *R, double val) { if (R->IsSupported == 0) { - printf("ERROR: this threshold isn't supported\n"); + CRIT("ERROR: this threshold isn't supported"); return; }; R->Value.SensorFloat64 = val; @@ -388,12 +388,12 @@ i = get_number("RPT number: ", &rpt); if (i != 1) { - printf("ERROR: no RPT number\n"); + CRIT("ERROR: no RPT number"); return; }; i = find_rpt_by_id(rpt); if (i < 0) { - printf("ERROR: invalid RPT number\n"); + CRIT("ERROR: invalid RPT number"); return; }; rpt = i; @@ -401,12 +401,12 @@ show_sens_for_rpt(Rpt); i = get_number("Sensor number: ", &num); if (i != 1) { - printf("ERROR: no Sensor number\n"); + CRIT("ERROR: no Sensor number"); return; }; rdr = find_sensor_by_num(Rpt, num); if (rdr < 0) { - printf("ERROR: invalid sensor number\n"); + CRIT("ERROR: invalid sensor number"); return; }; Rdr = Rpt->rdrs + rdr; @@ -415,7 +415,7 @@ rv = saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres); if (rv != SA_OK) { - printf("ERROR: %s\n", oh_lookup_error(rv)); + CRIT("ERROR: saHpiSensorThresholdsGet returned %s", oh_lookup_error(rv)); return; }; printf(" Thresholds:\n"); @@ -428,7 +428,7 @@ S = fgets(buf, READ_BUF_SIZE, stdin); while (*S == ' ') S++; if (strlen(S) < 2) { - printf("ERROR: invalid threshold type: %s\n", S); + CRIT("ERROR: invalid threshold type: %s", S); return; }; @@ -442,7 +442,7 @@ if (strncmp(S, "nh", 2) == 0) type = NEG_HYST; if (type == UNKNOWN_TYPE) { - printf("ERROR: unknown threshold type: %s\n", S); + CRIT("ERROR: unknown threshold type: %s", S); return; }; @@ -450,7 +450,7 @@ S = fgets(buf, READ_BUF_SIZE, stdin); i = sscanf(buf, "%f", &f); if (i == 0) { - printf("ERROR: no value\n"); + CRIT("ERROR: no value"); return; }; switch (type) { @@ -479,7 +479,7 @@ set_thres_value(&(thres.NegThdHysteresis), (double)f); break; default: - printf("ERROR: unknown threshold\n"); + CRIT("ERROR: unknown threshold"); }; printf("\n Nem threshold:\n"); ShowThres(&thres); @@ -491,7 +491,7 @@ rv = saHpiSensorThresholdsSet(sessionid, Rpt->Rpt.ResourceId, Rdr->Rdr.RdrTypeUnion.SensorRec.Num, &thres); if (rv != SA_OK) { - printf("ERROR: saHpiSensorThresholdsSet: %s\n", oh_lookup_error(rv)); + CRIT("ERROR: saHpiSensorThresholdsSet returned %s\n", oh_lookup_error(rv)); return; }; Rdr->modify = 1; @@ -500,7 +500,7 @@ NULL, NULL, NULL); if (rv == SA_OK) break; - if (copt.debug) printf("sleep before saHpiEventGet\n"); + if (copt.debug) DBG("sleep before saHpiEventGet"); g_usleep(G_USEC_PER_SEC); }; saHpiSensorThresholdsGet(sessionid, Rpt->Rpt.ResourceId, @@ -642,7 +642,6 @@ SaErrorT rv; char buf[READ_BUF_SIZE]; char *S; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -658,8 +657,7 @@ context, &copt, OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -670,11 +668,11 @@ rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); + if (copt.debug) DBG("saHpiDiscover: %s", oh_lookup_error(rv)); rv = saHpiSubscribe(sessionid); if (rv != SA_OK) { - printf( "saHpiSubscribe error %d\n",rv); + CRIT( "saHpiSubscribe error %d",rv); return rv; } Modified: openhpi/trunk/clients/hpitop.c =================================================================== --- openhpi/trunk/clients/hpitop.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpitop.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -129,7 +129,6 @@ { SaErrorT rv = SA_OK; SaHpiSessionIdT sessionid; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -145,9 +144,8 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -165,14 +163,14 @@ /* * Resource discovery */ - if (copt.debug) printf("saHpiDiscover\n"); + if (copt.debug) DBG("saHpiDiscover"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { - printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); + CRIT("saHpiDiscover returns %s",oh_lookup_error(rv)); return rv; } - if (copt.debug) printf("Discovery done\n"); + if (copt.debug) DBG("Discovery done"); list_resources(sessionid, resourceid); rv = saHpiSessionClose(sessionid); @@ -206,10 +204,10 @@ rptentryid = SAHPI_FIRST_ENTRY; do { - if (copt.debug) printf("saHpiRptEntryGet\n"); + if (copt.debug) DBG("saHpiRptEntryGet"); rvRptGet = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); if ((rvRptGet != SA_OK) || copt.debug) - printf("RptEntryGet returns %s\n",oh_lookup_error(rvRptGet)); + DBG("RptEntryGet returns %s",oh_lookup_error(rvRptGet)); rv = show_rpt(&rptentry, resourceid); @@ -224,11 +222,11 @@ /* walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; - if (copt.debug) printf("rptentry[%u] resourceid=%u\n", entryid,resourceid); + if (copt.debug) DBG("rptentry[%u] resourceid=%u", entryid,resourceid); do { rvRdrGet = saHpiRdrGet(sessionid,l_resourceid, entryid,&nextentryid, &rdr); - if (copt.debug) printf("saHpiRdrGet[%u] rv = %s\n",entryid,oh_lookup_error(rvRdrGet)); + if (copt.debug) DBG("saHpiRdrGet[%u] rv = %s",entryid,oh_lookup_error(rvRdrGet)); if (rvRdrGet == SA_OK) Modified: openhpi/trunk/clients/hpitree.c =================================================================== --- openhpi/trunk/clients/hpitree.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpitree.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -98,7 +98,7 @@ static gboolean f_ctrl = FALSE; static gboolean f_overview = FALSE; static gboolean f_allres = TRUE; -static gint resourceid = 0; +static gint f_resourceid = 0; static oHpiCommonOptionsT copt; static GOptionEntry my_options[] = @@ -117,7 +117,7 @@ // { "annunciators", 'a', 0, G_OPTION_ARG_NONE, &f_ann, "Display only annunciators", NULL }, // Annunciators not implemented - { "resource", 'n', 0, G_OPTION_ARG_INT, &resourceid, "Select particular resource id to display\n\t\t\t" + { "resource", 'n', 0, G_OPTION_ARG_INT, &f_resourceid, "Select particular resource id to display\n\t\t\t" "(Used with [-cdirs] options)", "nn" }, { NULL } }; @@ -131,8 +131,6 @@ { SaErrorT rv = SA_OK; SaHpiSessionIdT sessionid; -// SaHpiResourceIdT resourceid = 0; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -148,9 +146,8 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127? - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127? + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -158,6 +155,7 @@ if (f_rpt || f_sensor || f_inv || f_ctrl || f_rdr || f_wdog) f_listall = TRUE; + if (f_resourceid != 0) f_allres = FALSE; rv = ohc_session_open_by_option ( &copt, &sessionid); if (rv != SA_OK) return rv; @@ -165,15 +163,15 @@ /* * Resource discovery */ - if (copt.debug) printf("saHpiDiscover\n"); + if (copt.debug) DBG("saHpiDiscover"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { - printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); + CRIT("saHpiDiscover returns %s",oh_lookup_error(rv)); return rv; } printf("Discovery done\n"); - list_resources(sessionid, resourceid); + list_resources(sessionid, (SaHpiResourceIdT) f_resourceid); rv = saHpiSessionClose(sessionid); @@ -206,10 +204,10 @@ rptentryid = SAHPI_FIRST_ENTRY; do { - if (copt.debug) printf("saHpiRptEntryGet\n"); + if (copt.debug) DBG("saHpiRptEntryGet"); rvRptGet = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); if ((rvRptGet != SA_OK) || copt.debug) - printf("RptEntryGet returns %s\n",oh_lookup_error(rvRptGet)); + DBG("RptEntryGet returns %s",oh_lookup_error(rvRptGet)); rv = list_rpt(&rptentry, resourceid); @@ -224,11 +222,11 @@ /* walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; - if (copt.debug) printf("rptentry[%u] resourceid=%u\n", entryid,resourceid); + if (copt.debug) DBG("rptentry[%u] resourceid=%u\n", entryid,resourceid); do { rvRdrGet = saHpiRdrGet(sessionid,l_resourceid, entryid,&nextentryid, &rdr); - if (copt.debug) printf("saHpiRdrGet[%u] rv = %s\n",entryid,oh_lookup_error(rvRdrGet)); + if (copt.debug) DBG("saHpiRdrGet[%u] rv = %s\n",entryid,oh_lookup_error(rvRdrGet)); if (rvRdrGet == SA_OK) @@ -382,7 +380,7 @@ oh_print_idrfield(&thisField, 12); } - if (copt.debug) printf("saHpiIdrFieldGet error %s\n",oh_lookup_error(rvField)); + if (copt.debug) DBG("saHpiIdrFieldGet error %s",oh_lookup_error(rvField)); fieldId = nextFieldId; } while ((rvField == SA_OK) && (fieldId != SAHPI_LAST_ENTRY)); Modified: openhpi/trunk/clients/hpiwdt.c =================================================================== --- openhpi/trunk/clients/hpiwdt.c 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpiwdt.c 2011-03-19 17:04:54 UTC (rev 7291) @@ -112,7 +112,6 @@ SaHpiResourceIdT resourceid; SaHpiWatchdogNumT wdnum; SaHpiWatchdogT wdt; - GError *error = NULL; GOptionContext *context; /* Print version strings */ @@ -128,9 +127,8 @@ if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - - OHC_VERBOSE_OPTION, // no verbose mode implemented - error)) { + - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 + - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } @@ -142,9 +140,9 @@ if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); - if (copt.debug) printf("saHpiDiscover rv = %d\n",rv); + if (copt.debug) DBG("saHpiDiscover rv = %s",oh_lookup_error(rv)); rv = saHpiDomainInfoGet(sessionid, &domainInfo); - if (copt.debug) printf("saHpiDomainInfoGet rv = %d\n",rv); + if (copt.debug) DBG("saHpiDomainInfoGet rv = %s",oh_lookup_error(rv)); printf("DomainInfo: UpdateCount = %x, UpdateTime = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); @@ -153,7 +151,7 @@ while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); - if (rv != SA_OK) printf("RptEntryGet: rv = %d\n",rv); + if (rv != SA_OK) printf("RptEntryGet: rv = %s\n",oh_lookup_error(rv)); if (rv == SA_OK) { /* handle WDT for this RPT entry */ resourceid = rptentry.ResourceId; @@ -168,9 +166,9 @@ wdnum = SAHPI_DEFAULT_WATCHDOG_NUM; rv = saHpiWatchdogTimerGet(sessionid,resourceid,wdnum,&wdt); - if (copt.debug) printf("saHpiWatchdogTimerGet rv = %d\n",rv); + if (copt.debug) DBG("saHpiWatchdogTimerGet rv = %s",oh_lookup_error(rv)); if (rv != 0) { - printf("saHpiWatchdogTimerGet error = %d\n",rv); + printf("saHpiWatchdogTimerGet error = %s\n",oh_lookup_error(rv)); rv = 0; rptentryid = nextrptentryid; continue; @@ -189,7 +187,7 @@ wdt.PresentCount = 120000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); - if (copt.debug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); + if (copt.debug) DBG("saHpiWatchdogTimerSet rv = %s",oh_lookup_error(rv)); if (rv == 0) show_wdt(wdnum,&wdt); } else if (fenable) { printf("Enabling watchdog timer ...\n"); @@ -203,13 +201,13 @@ wdt.PresentCount = ftimeout * 1000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); - if (copt.debug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); + if (copt.debug) DBG("saHpiWatchdogTimerSet rv = %s",oh_lookup_error(rv)); if (rv == 0) show_wdt(wdnum,&wdt); } if (freset && !fdisable) { printf("Resetting watchdog timer ...\n"); rv = saHpiWatchdogTimerReset(sessionid,resourceid,wdnum); - if (copt.debug) printf("saHpiWatchdogTimerReset rv = %d\n",rv); + if (copt.debug) DBG("saHpiWatchdogTimerReset rv = %s",oh_lookup_error(rv)); } } /*watchdog capability*/ rptentryid = nextrptentryid; /* get next RPT (usu only one anyway) */ Modified: openhpi/trunk/clients/hpixml/main.cpp =================================================================== --- openhpi/trunk/clients/hpixml/main.cpp 2011-03-17 17:40:39 UTC (rev 7290) +++ openhpi/trunk/clients/hpixml/main.cpp 2011-03-19 17:04:54 UTC (rev 7291) @@ -54,7 +54,6 @@ { int indent_step = 0; - GError ... [truncated message content] |
From: <av...@us...> - 2011-04-11 13:41:25
|
Revision: 7297 http://openhpi.svn.sourceforge.net/openhpi/?rev=7297&view=rev Author: avpak Date: 2011-04-11 13:41:18 +0000 (Mon, 11 Apr 2011) Log Message: ----------- Feature request #3094859 Modified Paths: -------------- openhpi/trunk/openhpid/openhpid-posix.cpp openhpi/trunk/openhpid/openhpid-win32.cpp openhpi/trunk/openhpid/server.cpp openhpi/trunk/openhpid/server.h openhpi/trunk/transport/strmsock.cpp openhpi/trunk/transport/strmsock.h Modified: openhpi/trunk/openhpid/openhpid-posix.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid-posix.cpp 2011-04-06 12:08:34 UTC (rev 7296) +++ openhpi/trunk/openhpid/openhpid-posix.cpp 2011-04-11 13:41:18 UTC (rev 7297) @@ -49,9 +49,10 @@ static gchar *cfgfile = NULL; static gboolean verbose_flag = FALSE; +static gchar *bindaddr = NULL; static gint port = OPENHPI_DEFAULT_DAEMON_PORT; static gchar *portstr = NULL; -static gchar *optpidfile = NULL; +static gchar *optpidfile = NULL; static gint sock_timeout = 0; // unlimited -- TODO: unlimited or 30 minutes default? was unsigned int static gint max_threads = -1; // unlimited static gboolean runasforeground = FALSE; @@ -67,8 +68,13 @@ " configuration file.", "conf_file" }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_flag, "This option causes the daemon to display verbose\n" " messages. This option is optional.", NULL }, + { "bind", 'b', 0, G_OPTION_ARG_STRING, &bindaddr, "Bind address for the daemon socket.\n" + " Also bind address can be specified with\n" + " OPENHPI_DAEMON_BIND_ADDRESS environment variable.\n" + " No bind address is used by default.", "bind_address" }, { "port", 'p', 0, G_OPTION_ARG_STRING, &portstr, "Overrides the default listening port (4743) of\n" " the daemon. The option is optional.", "port" }, + { "pidfile", 'f', 0, G_OPTION_ARG_FILENAME, &optpidfile, "Overrides the default path/name for the daemon.\n" " pid file. The option is optional.", "pidfile" }, { "timeout", 's', 0, G_OPTION_ARG_INT, &sock_timeout, "Overrides the default socket read timeout of 30\n" @@ -111,6 +117,10 @@ printf(" configuration file.\n"); printf(" -v, --verbose This option causes the daemon to display verbose\n"); printf(" messages. This option is optional.\n"); + printf(" -b, --bind Sets bind address for the daemon socket.\n"); + printf(" Also bind address can be specified with\n"); + printf(" OPENHPI_DAEMON_BIND_ADDRESS environment variable.\n"); + printf(" No bind address is used by default.\n"); printf(" -p, --port=port Overrides the default listening port (4743) of\n"); printf(" the daemon. The option is optional.\n"); printf(" -f, --pidfile=pidfile Overrides the default path/name for the daemon.\n"); @@ -314,25 +324,43 @@ exit(-1); } + if (cfgfile) { + setenv("OPENHPI_CONF", cfgfile, 1); + } else { + cfgfile = getenv("OPENHPI_CONF"); + } + if (bindaddr) { + setenv("OPENHPI_DAEMON_BIND_ADDRESS", bindaddr, 1); + } else { + bindaddr = getenv("OPENHPI_DAEMON_BIND_ADDRESS"); + } if (portstr) { setenv("OPENHPI_DAEMON_PORT", portstr, 1); + } else { + portstr = getenv("OPENHPI_DAEMON_PORT"); + } + if (portstr) { port = atoi(portstr); } - if (cfgfile) setenv("OPENHPI_CONF", cfgfile, 1); + if (enableIPv4) { + ipvflags |= FlagIPv4; + } + if (enableIPv6) { + ipvflags |= FlagIPv6; + } + if (ipvflags == 0) { + ipvflags = FlagIPv4; + } + if (optpidfile) { + pidfile = g_strdup(optpidfile); + } - if (enableIPv4) ipvflags |= FlagIPv4; - if (enableIPv6) ipvflags |= FlagIPv6; - if (ipvflags == 0) ipvflags = FlagIPv4; - if (optpidfile) pidfile = g_strdup(optpidfile); - - // see if any invalid parameters are given if (sock_timeout<0) { CRIT("Socket timeout value must be positive. Exiting."); display_help(); } - // see if we have a valid configuration file if ((!cfgfile) || (!g_file_test(cfgfile, G_FILE_TEST_EXISTS))) { CRIT("Cannot find configuration file. Exiting."); @@ -365,15 +393,20 @@ // announce ourselves INFO("%s version %s started.", argv[0], VERSION); - if (cfgfile) INFO("OPENHPI_CONF = %s.", cfgfile); - INFO("OPENHPI_DAEMON_PORT = %u", port); - INFO("Enabled IP versions:%s%s\n", + if (cfgfile) { + INFO("OPENHPI_CONF = %s.", cfgfile); + } + if (bindaddr) { + INFO("OPENHPI_DAEMON_BIND_ADDRESS = %s.", bindaddr); + } + INFO("OPENHPI_DAEMON_PORT = %u.", port); + INFO("Enabled IP versions:%s%s.\n", (ipvflags & FlagIPv4) ? " IPv4" : "", (ipvflags & FlagIPv6) ? " IPv6" : ""); - INFO("Max threads: %d\n", max_threads); - INFO("Socket timeout(sec): %d\n", sock_timeout); + INFO("Max threads: %d.\n", max_threads); + INFO("Socket timeout(sec): %d.\n", sock_timeout); - bool rc = oh_server_run(ipvflags, port, sock_timeout, max_threads); + bool rc = oh_server_run(ipvflags, bindaddr, port, sock_timeout, max_threads); if (!rc) { return 9; } Modified: openhpi/trunk/openhpid/openhpid-win32.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid-win32.cpp 2011-04-06 12:08:34 UTC (rev 7296) +++ openhpi/trunk/openhpid/openhpid-win32.cpp 2011-04-11 13:41:18 UTC (rev 7297) @@ -35,6 +35,7 @@ /*--------------------------------------------------------------------*/ static gchar *cfgfile = NULL; static gboolean verbose_flag = FALSE; +static gchar *bindaddr = NULL; static gint port = OPENHPI_DEFAULT_DAEMON_PORT; static gchar *portstr = NULL; static gint sock_timeout = 0; // unlimited -- TODO: unlimited or 30 minutes default? was unsigned int @@ -52,6 +53,10 @@ " configuration file.", "conf_file" }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_flag, "This option causes the daemon to display verbose\n" " messages. This option is optional.", NULL }, + { "bind", 'b', 0, G_OPTION_ARG_STRING, &bindaddr, "Bind address for the daemon socket.\n" + " Also bind address can be specified with\n" + " OPENHPI_DAEMON_BIND_ADDRESS environment variable.\n" + " No bind address is used by default.", "bind_address" }, { "port", 'p', 0, G_OPTION_ARG_STRING, &portstr, "Overrides the default listening port (4743) of\n" " the daemon. The option is optional.", "port" }, { "timeout", 's', 0, G_OPTION_ARG_INT, &sock_timeout, "Overrides the default socket read timeout of 30\n" @@ -93,6 +98,10 @@ printf(" configuration file.\n"); printf(" -v, --verbose This option causes the daemon to display verbose\n"); printf(" messages. This option is optional.\n"); + printf(" -b, --bind Sets bind address for the daemon socket.\n"); + printf(" Also bind address can be specified with\n"); + printf(" OPENHPI_DAEMON_BIND_ADDRESS environment variable.\n"); + printf(" No bind address is used by default.\n"); printf(" -p, --port=port Overrides the default listening port (4743) of\n"); printf(" the daemon. The option is optional.\n"); printf(" -s, --timeout=seconds Overrides the default socket read timeout of 30\n"); @@ -187,16 +196,34 @@ exit(-1); } + if (cfgfile) { + setenv("OPENHPI_CONF", cfgfile); + } else { + cfgfile = getenv("OPENHPI_CONF"); + } + if (bindaddr) { + setenv("OPENHPI_DAEMON_BIND_ADDRESS", bindaddr); + } else { + bindaddr = getenv("OPENHPI_DAEMON_BIND_ADDRESS"); + } if (portstr) { setenv("OPENHPI_DAEMON_PORT", portstr); + } else { + portstr = getenv("OPENHPI_DAEMON_PORT"); + } + if (portstr) { port = atoi(portstr); } - if (cfgfile) setenv("OPENHPI_CONF", cfgfile); + if (enableIPv4) { + ipvflags |= FlagIPv4; + } + if (enableIPv6) { + ipvflags |= FlagIPv6; + } + if (ipvflags == 0) { + ipvflags = FlagIPv4; + } - if (enableIPv4) ipvflags |= FlagIPv4; - if (enableIPv6) ipvflags |= FlagIPv6; - if (ipvflags == 0) ipvflags = FlagIPv4; - // see if any invalid parameters are given if (sock_timeout<0) { CRIT("Socket timeout value must be positive. Exiting."); @@ -217,15 +244,20 @@ // announce ourselves INFO("%s version %s started.", argv[0], VERSION); - if (cfgfile) INFO("OPENHPI_CONF = %s.", cfgfile); + if (cfgfile) { + INFO("OPENHPI_CONF = %s.", cfgfile); + } + if (bindaddr) { + INFO("OPENHPI_DAEMON_BIND_ADDRESS = %s.", bindaddr); + } INFO("OPENHPI_DAEMON_PORT = %u.", port); INFO("Enabled IP versions:%s%s\n", (ipvflags & FlagIPv4) ? " IPv4" : "", (ipvflags & FlagIPv6) ? " IPv6" : ""); - INFO("Max threads: %d\n", max_threads); - INFO("Socket timeout(sec): %d\n", sock_timeout); + INFO("Max threads: %d.\n", max_threads); + INFO("Socket timeout(sec): %d.\n", sock_timeout); - bool rc = oh_server_run(ipvflags, port, sock_timeout, max_threads); + bool rc = oh_server_run(ipvflags, bindaddr, port, sock_timeout, max_threads); if (!rc) { return 9; } Modified: openhpi/trunk/openhpid/server.cpp =================================================================== --- openhpi/trunk/openhpid/server.cpp 2011-04-06 12:08:34 UTC (rev 7296) +++ openhpi/trunk/openhpid/server.cpp 2011-04-11 13:41:18 UTC (rev 7297) @@ -76,13 +76,14 @@ /*--------------------------------------------------------------------*/ bool oh_server_run( int ipvflags, + const char * bindaddr, uint16_t port, unsigned int sock_timeout, int max_threads ) { // create the server socket cServerStreamSock ssock; - if (!ssock.Create(ipvflags, port)) { + if (!ssock.Create(ipvflags, bindaddr, port)) { CRIT("Error creating server socket. Exiting."); return false; } Modified: openhpi/trunk/openhpid/server.h =================================================================== --- openhpi/trunk/openhpid/server.h 2011-04-06 12:08:34 UTC (rev 7296) +++ openhpi/trunk/openhpid/server.h 2011-04-11 13:41:18 UTC (rev 7297) @@ -23,6 +23,7 @@ bool oh_server_run( int ipvflags, + const char * bindaddr, uint16_t port, unsigned int sock_timeout, int max_threads ); Modified: openhpi/trunk/transport/strmsock.cpp =================================================================== --- openhpi/trunk/transport/strmsock.cpp 2011-04-06 12:08:34 UTC (rev 7296) +++ openhpi/trunk/transport/strmsock.cpp 2011-04-11 13:41:18 UTC (rev 7297) @@ -276,6 +276,8 @@ return true; } + // TODO shutdown + int cc; #ifdef _WIN32 cc = closesocket( m_sockfd ); @@ -403,13 +405,13 @@ // empty } -bool cServerStreamSock::Create( int ipvflags, uint16_t port ) +bool cServerStreamSock::Create( int ipvflags, const char * bindaddr, uint16_t port ) { bool bound = false; struct addrinfo * info; std::list<struct addrinfo *> infos; - SelectAddresses( ipvflags, AI_PASSIVE, 0, port, infos ); + SelectAddresses( ipvflags, AI_PASSIVE, bindaddr, port, infos ); while ( !infos.empty() ) { info = *infos.begin(); Modified: openhpi/trunk/transport/strmsock.h =================================================================== --- openhpi/trunk/transport/strmsock.h 2011-04-06 12:08:34 UTC (rev 7296) +++ openhpi/trunk/transport/strmsock.h 2011-04-11 13:41:18 UTC (rev 7297) @@ -162,7 +162,7 @@ explicit cServerStreamSock(); ~cServerStreamSock(); - bool Create( int ipvflags, uint16_t port ); + bool Create( int ipvflags, const char * bindaddr, uint16_t port ); cStreamSock * Accept(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-04-12 12:19:18
|
Revision: 7298 http://openhpi.svn.sourceforge.net/openhpi/?rev=7298&view=rev Author: avpak Date: 2011-04-12 12:19:11 +0000 (Tue, 12 Apr 2011) Log Message: ----------- Bugfix for #2798408 Modified Paths: -------------- openhpi/trunk/openhpi.conf.example openhpi/trunk/openhpid/conf.c openhpi/trunk/openhpid/conf.h openhpi/trunk/openhpid/init.c openhpi/trunk/openhpid/openhpid-posix.cpp openhpi/trunk/openhpid/openhpid-win32.cpp openhpi/trunk/openhpid/plugin.c Modified: openhpi/trunk/openhpi.conf.example =================================================================== --- openhpi/trunk/openhpi.conf.example 2011-04-11 13:41:18 UTC (rev 7297) +++ openhpi/trunk/openhpi.conf.example 2011-04-12 12:19:11 UTC (rev 7298) @@ -19,7 +19,10 @@ #OPENHPI_DAT_SAVE = "NO" #OPENHPI_PATH = "/usr/local/lib/openhpi:/usr/lib/openhpi" #OPENHPI_VARPATH = "/usr/local/var/lib/openhpi" +#OPENHPI_AUTOINSERT_TIMEOUT = 0 +#OPENHPI_AUTOINSERT_TIMEOUT_READONLY = "NO" + ## The default values for each have been selected in the example above (except ## for OPENHPI_PATH and OPENHPI_CONF. See below). ## No need to specify any one of them because the defaults is used Modified: openhpi/trunk/openhpid/conf.c =================================================================== --- openhpi/trunk/openhpid/conf.c 2011-04-11 13:41:18 UTC (rev 7297) +++ openhpi/trunk/openhpid/conf.c 2011-04-12 12:19:11 UTC (rev 7298) @@ -45,8 +45,10 @@ "OPENHPI_PATH", "OPENHPI_VARPATH", "OPENHPI_CONF", - "OPENHPICLIENT_CONF", + // The parameters below are not accessible via oHpiGlobalParamSet/oHpiGlobalParamGet "OPENHPI_UNCONFIGURED", + "OPENHPI_AUTOINSERT_TIMEOUT", + "OPENHPI_AUTOINSERT_TIMEOUT_READONLY", NULL }; @@ -62,8 +64,10 @@ char path[OH_PATH_PARAM_MAX_LENGTH]; char varpath[OH_PATH_PARAM_MAX_LENGTH]; char conf[OH_PATH_PARAM_MAX_LENGTH]; - char client_conf[OH_PATH_PARAM_MAX_LENGTH]; + // The parameters below are not accessible via oHpiGlobalParamSet/oHpiGlobalParamGet SaHpiBoolT unconfigured; + SaHpiTimeoutT ai_timeout; + SaHpiBoolT ai_timeout_readonly; unsigned char read_env; GStaticRecMutex lock; } global_params = { /* Defaults for global params are set here */ @@ -78,8 +82,9 @@ .path = OH_PLUGIN_PATH, .varpath = VARPATH, .conf = OH_DEFAULT_CONF, - .client_conf = OH_CLIENT_DEFAULT_CONF, .unconfigured = SAHPI_FALSE, + .ai_timeout = 0, + .ai_timeout_readonly = SAHPI_FALSE, .read_env = 0, .lock = G_STATIC_REC_MUTEX_INIT }; @@ -165,16 +170,14 @@ static void process_global_param(const char *name, char *value) { + g_static_rec_mutex_lock(&global_params.lock); + if (!strcmp("OPENHPI_ON_EP", name)) { - g_static_rec_mutex_lock(&global_params.lock); oh_encode_entitypath(value, &global_params.on_ep); - g_static_rec_mutex_unlock(&global_params.lock); } else if (!strcmp("OPENHPI_LOG_ON_SEV", name)) { SaHpiTextBufferT buffer; strncpy((char *)buffer.Data, value, SAHPI_MAX_TEXT_BUFFER_LENGTH); - g_static_rec_mutex_lock(&global_params.lock); oh_encode_severity(&buffer, &global_params.log_on_sev); - g_static_rec_mutex_unlock(&global_params.lock); } else if (!strcmp("OPENHPI_EVT_QUEUE_LIMIT", name)) { global_params.evt_queue_limit = atoi(value); } else if (!strcmp("OPENHPI_DEL_SIZE_LIMIT", name)) { @@ -196,36 +199,33 @@ global_params.dat_save = SAHPI_FALSE; } } else if (!strcmp("OPENHPI_PATH", name)) { - g_static_rec_mutex_lock(&global_params.lock); memset(global_params.path, 0, OH_PATH_PARAM_MAX_LENGTH); strncpy(global_params.path, value, OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); } else if (!strcmp("OPENHPI_VARPATH", name)) { - g_static_rec_mutex_lock(&global_params.lock); memset(global_params.varpath, 0, OH_PATH_PARAM_MAX_LENGTH); strncpy(global_params.varpath, value, OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); } else if (!strcmp("OPENHPI_CONF", name)) { - g_static_rec_mutex_lock(&global_params.lock); memset(global_params.conf, 0, OH_PATH_PARAM_MAX_LENGTH); strncpy(global_params.conf, value, OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); - } else if (!strcmp("OPENHPICLIENT_CONF", name)) { - g_static_rec_mutex_lock(&global_params.lock); - memset(global_params.client_conf, 0, OH_PATH_PARAM_MAX_LENGTH); - strncpy(global_params.client_conf, value, OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); } else if (!strcmp("OPENHPI_UNCONFIGURED", name)) { if (!strcmp("YES", value)) { global_params.unconfigured = SAHPI_TRUE; } else { global_params.unconfigured = SAHPI_FALSE; } + } else if (!strcmp("OPENHPI_AUTOINSERT_TIMEOUT", name)) { + global_params.ai_timeout = strtoll(value, 0, 10); + } else if (!strcmp("OPENHPI_AUTOINSERT_TIMEOUT_READONLY", name)) { + if (!strcmp("YES", value)) { + global_params.ai_timeout_readonly = SAHPI_TRUE; + } else { + global_params.ai_timeout_readonly = SAHPI_FALSE; + } } else { - CRIT("ERROR. Invalid global parameter %s in config file", name); + CRIT("Invalid global parameter %s in config file.", name); } - return; + g_static_rec_mutex_unlock(&global_params.lock); } static void read_globals_from_env(int force) @@ -337,7 +337,7 @@ if (value == NULL) { CRIT("Processing handler:" " Unable to allocate memory for value." - " Token Type: %d", + " Token Type: %d.", current_token); goto free_table_and_key; } @@ -388,7 +388,7 @@ /* Get the global parameter name */ current_token = g_scanner_get_next_token(scanner); if (current_token != G_TOKEN_STRING) { - CRIT("Processing global: Expected string token. Got %d", + CRIT("Processing global: Expected string token. Got %d.", current_token); goto quit; } @@ -401,14 +401,14 @@ current_token = g_scanner_get_next_token(scanner); if (current_token != G_TOKEN_EQUAL_SIGN) { - CRIT("Did not get expected '=' token. Got %d", current_token); + CRIT("Did not get expected '=' token. Got %d.", current_token); goto free_and_quit; } current_token = g_scanner_get_next_token(scanner); if (current_token != G_TOKEN_STRING && current_token != G_TOKEN_INT) { CRIT("Did not get expected string value for global parameter." - " Got %d", current_token); + " Got %d.", current_token); goto free_and_quit; } @@ -458,7 +458,7 @@ { g_return_if_fail (scanner != NULL); - CRIT("%s:%d: %s%s\n", + CRIT("%s:%d: %s%s.\n", scanner->input_name ? scanner->input_name : "<memory>", scanner->line, is_error ? "error: " : "", message ); } @@ -482,14 +482,14 @@ int num_tokens = sizeof(oh_conf_tokens) / sizeof(oh_conf_tokens[0]); if (!filename || !config) { - CRIT("Error. Invalid parameters"); + CRIT("Error. Invalid parameters."); return -1; } handler_configs = NULL; oh_scanner = g_scanner_new(&oh_scanner_config); if (!oh_scanner) { - CRIT("Couldn't allocate g_scanner for file parsing"); + CRIT("Couldn't allocate g_scanner for file parsing."); return -2; } @@ -498,7 +498,7 @@ fp = fopen(filename, "r"); if (!fp) { - CRIT("Configuration file '%s' could not be opened", filename); + CRIT("Configuration file '%s' could not be opened.", filename); g_scanner_destroy(oh_scanner); return -4; } @@ -584,7 +584,7 @@ (char *)g_hash_table_lookup(handler_config, "plugin")); config->handlers_loaded++; } else { - CRIT("Couldn't load handler for plugin %s", + CRIT("Couldn't load handler for plugin %s.", (char *)g_hash_table_lookup(handler_config, "plugin")); if (hid == 0) g_hash_table_destroy(handler_config); } @@ -612,11 +612,11 @@ if (!param || !(param->type)) { if (!param) { - CRIT("ERROR. Invalid parameters param NULL"); + CRIT("Invalid parameters param NULL."); } if (!param->type) { - CRIT("ERROR. Invalid parameters param->type NULL"); + CRIT("Invalid parameters param->type NULL."); } return -1; @@ -624,11 +624,10 @@ read_globals_from_env(0); + g_static_rec_mutex_lock(&global_params.lock); switch (param->type) { case OPENHPI_ON_EP: - g_static_rec_mutex_lock(&global_params.lock); param->u.on_ep = global_params.on_ep; - g_static_rec_mutex_unlock(&global_params.lock); break; case OPENHPI_LOG_ON_SEV: param->u.log_on_sev = global_params.log_on_sev; @@ -652,64 +651,76 @@ param->u.dat_save = global_params.dat_save; break; case OPENHPI_PATH: - g_static_rec_mutex_lock(&global_params.lock); strncpy(param->u.path, global_params.path, OH_PATH_PARAM_MAX_LENGTH); - g_static_rec_mutex_unlock(&global_params.lock); break; case OPENHPI_VARPATH: - g_static_rec_mutex_lock(&global_params.lock); strncpy(param->u.varpath, global_params.varpath, OH_PATH_PARAM_MAX_LENGTH); - g_static_rec_mutex_unlock(&global_params.lock); break; case OPENHPI_CONF: - g_static_rec_mutex_lock(&global_params.lock); strncpy(param->u.conf, global_params.conf, OH_PATH_PARAM_MAX_LENGTH); - g_static_rec_mutex_unlock(&global_params.lock); break; - case OPENHPICLIENT_CONF: - g_static_rec_mutex_lock(&global_params.lock); - strncpy(param->u.conf, - global_params.client_conf, - OH_PATH_PARAM_MAX_LENGTH); - g_static_rec_mutex_unlock(&global_params.lock); - break; case OPENHPI_UNCONFIGURED: param->u.unconfigured = global_params.unconfigured; break; - default: - CRIT("ERROR. Invalid global parameter %d!", param->type); + case OPENHPI_AUTOINSERT_TIMEOUT: + param->u.ai_timeout = global_params.ai_timeout; + break; + case OPENHPI_AUTOINSERT_TIMEOUT_READONLY: + param->u.ai_timeout_readonly = global_params.ai_timeout_readonly; + break; + default: + g_static_rec_mutex_unlock(&global_params.lock); + CRIT("Invalid global parameter %d!", param->type); return -2; } + g_static_rec_mutex_unlock(&global_params.lock); return 0; } /** + * oh_get_global_param2 + * @param + * + * Returns: 0 on Success. + **/ +int oh_get_global_param2(oh_global_param_type type, struct oh_global_param *param) +{ + if (!param) { + CRIT("Invalid parameters."); + return -1; + } + + param->type = type; + + return oh_get_global_param(param); +} + +/** * oh_set_global_param * @param * * Returns: 0 on Success. **/ -int oh_set_global_param(struct oh_global_param *param) +int oh_set_global_param(const struct oh_global_param *param) { if (!param || !(param->type)) { - CRIT("ERROR. Invalid parameters"); + CRIT("Invalid parameters."); return -1; } read_globals_from_env(0); + g_static_rec_mutex_lock(&global_params.lock); switch (param->type) { case OPENHPI_ON_EP: - g_static_rec_mutex_lock(&global_params.lock); global_params.on_ep = param->u.on_ep; - g_static_rec_mutex_unlock(&global_params.lock); break; case OPENHPI_LOG_ON_SEV: global_params.log_on_sev = param->u.log_on_sev; @@ -733,44 +744,39 @@ global_params.dat_save = param->u.dat_save; break; case OPENHPI_PATH: - g_static_rec_mutex_lock(&global_params.lock); memset(global_params.path, 0, OH_PATH_PARAM_MAX_LENGTH); strncpy(global_params.path, param->u.path, OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); break; case OPENHPI_VARPATH: - g_static_rec_mutex_lock(&global_params.lock); memset(global_params.varpath, 0, OH_PATH_PARAM_MAX_LENGTH); strncpy(global_params.varpath, param->u.varpath, OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); break; case OPENHPI_CONF: - g_static_rec_mutex_lock(&global_params.lock); memset(global_params.conf, 0, OH_PATH_PARAM_MAX_LENGTH); strncpy(global_params.conf, param->u.conf, OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); break; - case OPENHPICLIENT_CONF: - g_static_rec_mutex_lock(&global_params.lock); - memset(global_params.conf, 0, OH_PATH_PARAM_MAX_LENGTH); - strncpy(global_params.client_conf, - param->u.conf, - OH_PATH_PARAM_MAX_LENGTH-1); - g_static_rec_mutex_unlock(&global_params.lock); - break; case OPENHPI_UNCONFIGURED: global_params.unconfigured = param->u.unconfigured; break; + case OPENHPI_AUTOINSERT_TIMEOUT: + global_params.ai_timeout = param->u.ai_timeout; + break; + case OPENHPI_AUTOINSERT_TIMEOUT_READONLY: + global_params.ai_timeout_readonly = param->u.ai_timeout_readonly; + break; default: - CRIT("ERROR. Invalid global parameter %d!", param->type); + g_static_rec_mutex_unlock(&global_params.lock); + CRIT("Invalid global parameter %d!", param->type); return -2; } + g_static_rec_mutex_unlock(&global_params.lock); return 0; } + Modified: openhpi/trunk/openhpid/conf.h =================================================================== --- openhpi/trunk/openhpid/conf.h 2011-04-11 13:41:18 UTC (rev 7297) +++ openhpi/trunk/openhpid/conf.h 2011-04-12 12:19:11 UTC (rev 7298) @@ -44,8 +44,9 @@ OPENHPI_PATH, OPENHPI_VARPATH, OPENHPI_CONF, - OPENHPICLIENT_CONF, - OPENHPI_UNCONFIGURED + OPENHPI_UNCONFIGURED, + OPENHPI_AUTOINSERT_TIMEOUT, + OPENHPI_AUTOINSERT_TIMEOUT_READONLY } oh_global_param_type; typedef union { @@ -61,6 +62,8 @@ char varpath[OH_MAX_TEXT_BUFFER_LENGTH]; char conf[OH_MAX_TEXT_BUFFER_LENGTH]; SaHpiBoolT unconfigured; + SaHpiTimeoutT ai_timeout; + SaHpiBoolT ai_timeout_readonly; } oh_global_param_union; struct oh_global_param { @@ -75,7 +78,8 @@ /* For handling global parameters */ int oh_get_global_param(struct oh_global_param *param); -int oh_set_global_param(struct oh_global_param *param); +int oh_get_global_param2(oh_global_param_type type, struct oh_global_param *param); +int oh_set_global_param(const struct oh_global_param *param); #ifdef __cplusplus } Modified: openhpi/trunk/openhpid/init.c =================================================================== --- openhpi/trunk/openhpid/init.c 2011-04-11 13:41:18 UTC (rev 7297) +++ openhpi/trunk/openhpid/init.c 2011-04-12 12:19:11 UTC (rev 7298) @@ -42,9 +42,8 @@ int oh_init(void) { static int initialized = 0; + struct oh_global_param param; struct oh_parsed_config config = { NULL, 0, 0 }; - struct oh_global_param config_param = { .type = OPENHPI_CONF }; - struct oh_global_param unconf_param = { .type = OPENHPI_UNCONFIGURED }; SaErrorT rval; if (g_thread_supported() == FALSE) { @@ -59,8 +58,9 @@ /* Initialize thread engine */ oh_threaded_init(); + #ifdef HAVE_OPENSSL - /* Initialize SSL library */ + INFO("Initializing SSL Library."); if (oh_ssl_init()) { CRIT("SSL library intialization failed."); data_access_unlock(); @@ -68,9 +68,9 @@ } #endif /* Set openhpi configuration file location */ - oh_get_global_param(&config_param); - - rval = oh_load_config(config_param.u.conf, &config); + oh_get_global_param2(OPENHPI_CONF, ¶m); + INFO("Loading config file %s.", param.u.conf); + rval = oh_load_config(param.u.conf, &config); /* Don't error out if there is no conf file */ if (rval < 0 && rval != -4) { CRIT("Can not load config."); @@ -81,48 +81,56 @@ /* One particular variable, OPENHPI_UNCONFIGURED, can cause us to exit * immediately, without trying to run the daemon any further. */ - oh_get_global_param(&unconf_param); - if (unconf_param.u.unconfigured) { - CRIT("OpenHPI is not configured. See openhpi.conf file."); + oh_get_global_param2(OPENHPI_UNCONFIGURED, ¶m); + if (param.u.unconfigured != SAHPI_FALSE) { + CRIT("OpenHPI is not configured. See config file."); data_access_unlock(); return SA_ERR_HPI_ERROR; } /* Initialize uid_utils */ + INFO("Initializing UID."); rval = oh_uid_initialize(); if( (rval != SA_OK) && (rval != SA_ERR_HPI_ERROR) ) { CRIT("Unique ID intialization failed."); data_access_unlock(); return rval; } - DBG("Initialized UID."); /* Initialize handler table */ oh_handlers.table = g_hash_table_new(g_int_hash, g_int_equal); - DBG("Initialized handler table"); /* Initialize domain table */ oh_domains.table = g_hash_table_new(g_int_hash, g_int_equal); - DBG("Initialized domain table"); /* Initialize session table */ oh_sessions.table = g_hash_table_new(g_int_hash, g_int_equal); - DBG("Initialized session table"); /* Load plugins, create handlers and domains */ oh_process_config(&config); - /* Create default domain if it does not exist yet. */ - if (oh_create_domain(OH_DEFAULT_DOMAIN_ID, - "DEFAULT", - SAHPI_UNSPECIFIED_DOMAIN_ID, - SAHPI_UNSPECIFIED_DOMAIN_ID, - SAHPI_DOMAIN_CAP_AUTOINSERT_READ_ONLY, - SAHPI_TIMEOUT_IMMEDIATE)) { + INFO("Creating default domain."); + oh_get_global_param2(OPENHPI_AUTOINSERT_TIMEOUT, ¶m); + SaHpiTimeoutT ai_timeout = param.u.ai_timeout; + INFO("Auto-Insert Timeout is %lld nsec.", ai_timeout); + oh_get_global_param2(OPENHPI_AUTOINSERT_TIMEOUT_READONLY, ¶m); + SaHpiDomainCapabilitiesT caps = 0; + if ( param.u.ai_timeout_readonly != SAHPI_FALSE ) { + INFO("Auto-Insert Timeout is READ-ONLY."); + caps = SAHPI_DOMAIN_CAP_AUTOINSERT_READ_ONLY; + } + + rval = oh_create_domain(OH_DEFAULT_DOMAIN_ID, + "DEFAULT", + SAHPI_UNSPECIFIED_DOMAIN_ID, + SAHPI_UNSPECIFIED_DOMAIN_ID, + caps, + ai_timeout); + if (rval != SA_OK) { data_access_unlock(); CRIT("Could not create first domain!"); return SA_ERR_HPI_ERROR; - } + } /* * Wipes away configuration lists (plugin_names and handler_configs). @@ -147,15 +155,14 @@ initialized = 1; data_access_unlock(); - DBG("OpenHPI has been initialized"); + INFO("OpenHPI has been initialized."); /* infrastructure initialization has completed at this point */ /* Check if there are any handlers loaded */ if (config.handlers_defined == 0) { WARN("*Warning*: No handler definitions found in config file." - " Check configuration file %s and previous messages", - config_param.u.conf); + " Check configuration file and previous messages" ); } /* Modified: openhpi/trunk/openhpid/openhpid-posix.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid-posix.cpp 2011-04-11 13:41:18 UTC (rev 7297) +++ openhpi/trunk/openhpid/openhpid-posix.cpp 2011-04-12 12:19:11 UTC (rev 7298) @@ -386,13 +386,8 @@ } } - if (oh_init()) { // Initialize OpenHPI - CRIT("There was an error initializing OpenHPI. Exiting."); - return 8; - } - // announce ourselves - INFO("%s version %s started.", argv[0], VERSION); + INFO("Starting OpenHPI %s.", VERSION); if (cfgfile) { INFO("OPENHPI_CONF = %s.", cfgfile); } @@ -400,12 +395,17 @@ INFO("OPENHPI_DAEMON_BIND_ADDRESS = %s.", bindaddr); } INFO("OPENHPI_DAEMON_PORT = %u.", port); - INFO("Enabled IP versions:%s%s.\n", + INFO("Enabled IP versions:%s%s.", (ipvflags & FlagIPv4) ? " IPv4" : "", (ipvflags & FlagIPv6) ? " IPv6" : ""); - INFO("Max threads: %d.\n", max_threads); - INFO("Socket timeout(sec): %d.\n", sock_timeout); + INFO("Max threads: %d.", max_threads); + INFO("Socket timeout(sec): %d.", sock_timeout); + if (oh_init()) { // Initialize OpenHPI + CRIT("There was an error initializing OpenHPI. Exiting."); + return 8; + } + bool rc = oh_server_run(ipvflags, bindaddr, port, sock_timeout, max_threads); if (!rc) { return 9; Modified: openhpi/trunk/openhpid/openhpid-win32.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid-win32.cpp 2011-04-11 13:41:18 UTC (rev 7297) +++ openhpi/trunk/openhpid/openhpid-win32.cpp 2011-04-12 12:19:11 UTC (rev 7298) @@ -237,13 +237,8 @@ exit(-1); } - if (oh_init()) { // Initialize OpenHPI - CRIT("There was an error initializing OpenHPI. Exiting."); - return 8; - } - // announce ourselves - INFO("%s version %s started.", argv[0], VERSION); + INFO("Starting OpenHPI %s.", VERSION); if (cfgfile) { INFO("OPENHPI_CONF = %s.", cfgfile); } @@ -251,12 +246,17 @@ INFO("OPENHPI_DAEMON_BIND_ADDRESS = %s.", bindaddr); } INFO("OPENHPI_DAEMON_PORT = %u.", port); - INFO("Enabled IP versions:%s%s\n", + INFO("Enabled IP versions:%s%s.", (ipvflags & FlagIPv4) ? " IPv4" : "", (ipvflags & FlagIPv6) ? " IPv6" : ""); - INFO("Max threads: %d.\n", max_threads); - INFO("Socket timeout(sec): %d.\n", sock_timeout); + INFO("Max threads: %d.", max_threads); + INFO("Socket timeout(sec): %d.", sock_timeout); + if (oh_init()) { // Initialize OpenHPI + CRIT("There was an error initializing OpenHPI. Exiting."); + return 8; + } + bool rc = oh_server_run(ipvflags, bindaddr, port, sock_timeout, max_threads); if (!rc) { return 9; Modified: openhpi/trunk/openhpid/plugin.c =================================================================== --- openhpi/trunk/openhpid/plugin.c 2011-04-11 13:41:18 UTC (rev 7297) +++ openhpi/trunk/openhpid/plugin.c 2011-04-12 12:19:11 UTC (rev 7298) @@ -535,6 +535,18 @@ g_static_rec_mutex_init(&handler->lock); g_static_rec_mutex_init(&handler->refcount_lock); + // TODO reimplement to get timeout value from domain + // set auto-extract timeout + if (handler->abi->set_autoinsert_timeout) { + struct oh_global_param param; + oh_get_global_param2(OPENHPI_AUTOINSERT_TIMEOUT, ¶m); + SaHpiTimeoutT ai_timeout = param.u.ai_timeout; + SaErrorT rv = handler->abi->set_autoinsert_timeout(handler->hnd, ai_timeout); + if (rv != SA_OK) { + CRIT("Cannot propagate auto-insert timeout to handler."); + } + } + return handler; cleanexit: g_free(handler); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-04-29 22:57:12
|
Revision: 7302 http://openhpi.svn.sourceforge.net/openhpi/?rev=7302&view=rev Author: avpak Date: 2011-04-29 22:57:05 +0000 (Fri, 29 Apr 2011) Log Message: ----------- Some for bug #3289939 Modified Paths: -------------- openhpi/trunk/openhpi.conf.example openhpi/trunk/openhpid/conf.c Modified: openhpi/trunk/openhpi.conf.example =================================================================== --- openhpi/trunk/openhpi.conf.example 2011-04-19 16:26:18 UTC (rev 7301) +++ openhpi/trunk/openhpi.conf.example 2011-04-29 22:57:05 UTC (rev 7302) @@ -20,7 +20,7 @@ #OPENHPI_PATH = "/usr/local/lib/openhpi:/usr/lib/openhpi" #OPENHPI_VARPATH = "/usr/local/var/lib/openhpi" #OPENHPI_AUTOINSERT_TIMEOUT = 0 -#OPENHPI_AUTOINSERT_TIMEOUT_READONLY = "NO" +#OPENHPI_AUTOINSERT_TIMEOUT_READONLY = "YES" ## The default values for each have been selected in the example above (except Modified: openhpi/trunk/openhpid/conf.c =================================================================== --- openhpi/trunk/openhpid/conf.c 2011-04-19 16:26:18 UTC (rev 7301) +++ openhpi/trunk/openhpid/conf.c 2011-04-29 22:57:05 UTC (rev 7302) @@ -84,7 +84,7 @@ .conf = OH_DEFAULT_CONF, .unconfigured = SAHPI_FALSE, .ai_timeout = 0, - .ai_timeout_readonly = SAHPI_FALSE, + .ai_timeout_readonly = SAHPI_TRUE, .read_env = 0, .lock = G_STATIC_REC_MUTEX_INIT }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |