I noticed different hpi client programs use different format to print
HPI and openhpi strings. For example hpitree prints the following which
is a decimal notation of the saHpiVersionGet() returned version number.
hpitree ver 0.2 HPI-B
Hpi Version 131585 Implemented.
hpitop does the same. hpiel does a good job of printing the version
strings in the following format:
hpiel - This program came with OpenHPI 2.10.0 (6418)
HPI Version is b.02.01
I took the version string generation code from hpiel.c: main() and
turned it into a common routine all clients can call. I had to add a
new .c and .h to define the routine and its prototype. Changed hpiel.c,
hpitree.c, and hpitop.c to use the hpiversion() routine defined in the
new hpiversion.c file. Here are the changes in this patch:
- New files hpiversion.c and hpiversion.h
- Makefile.am changes to add new file to hpitree, hpiel, hpitop
- Changes to hpitree.c, hpitop.c, and hpiel.c to call the new
hpiversion() and include hpiversion.h. Also removed version strings code
from these files.
Version strings information that gets printed from hpitree, hpitop, and
hpiel after applying this patch:
This program came with OpenHPI 2.10.0 (6418)
HPI Version is b.02.01
====================Cut here=====================================
diff -urNp openhpi-2.10.0/clients/hpiel.c
openhpi-2.10.0_version/clients/hpiel.c
--- openhpi-2.10.0/clients/hpiel.c 2007-08-31 10:15:37.000000000 -0600
+++ openhpi-2.10.0_version/clients/hpiel.c 2007-09-27 21:48:47.000000000
-0600
@@ -18,7 +18,7 @@
#include <oHpi.h>
#include <oh_utils.h>
-#define OH_SVN_REV "$Revision: 6418 $"
+#include <hpiversion.h>
#define dbg(format, ...) \
do { \
@@ -52,27 +52,12 @@ SaErrorT display_el(SaHpiSessionIdT sid,
int main(int argc, char **argv)
{
- SaHpiUint32T ohpi_major = oHpiVersionGet() >> 48;
- SaHpiUint32T ohpi_minor = (oHpiVersionGet() << 16) >> 48;
- SaHpiUint32T ohpi_patch = (oHpiVersionGet() << 32) >> 48;
- SaHpiVersionT hpiver;
SaErrorT error = SA_OK;
SaHpiSessionIdT sid;
SaHpiDomainInfoT dinfo;
- char svn_rev[SAHPI_MAX_TEXT_BUFFER_LENGTH];
- /* Generating version strings */
- memset(svn_rev, 0, sizeof(SAHPI_MAX_TEXT_BUFFER_LENGTH));
- strncpy(svn_rev, OH_SVN_REV, SAHPI_MAX_TEXT_BUFFER_LENGTH);
- svn_rev[strlen(OH_SVN_REV)-2] = '\0';
- printf("%s - This program came with OpenHPI %u.%u.%u (%s)\n",
- argv[0], ohpi_major, ohpi_minor, ohpi_patch,
- svn_rev + 11);
- hpiver = saHpiVersionGet();
- printf("HPI Version is %x.0%d.0%d\n",
- (hpiver >> 16) + 9,
- (hpiver & 0x0000FF00) >> 8,
- hpiver & 0x000000FF);
+ printf("\n\n%s\n", argv[0]);
+ hpiversion();
/* Parsing options */
if (parse_options(argc, &argv, &opts)) {
diff -urNp openhpi-2.10.0/clients/hpitop.c
openhpi-2.10.0_version/clients/hpitop.c
--- openhpi-2.10.0/clients/hpitop.c 2007-08-31 10:15:38.000000000 -0600
+++ openhpi-2.10.0_version/clients/hpitop.c 2007-09-27
21:48:38.000000000 -0600
@@ -30,6 +30,8 @@
#include <SaHpi.h>
#include <oh_utils.h>
+#include <hpiversion.h>
+
/*
* Function prototypes
*/
@@ -99,7 +101,6 @@ main(int argc, char **argv)
{
SaErrorT rv = SA_OK;
- SaHpiVersionT hpiVer;
SaHpiSessionIdT sessionid;
SaHpiResourceIdT resourceid = all_resources;
@@ -144,8 +145,7 @@ main(int argc, char **argv)
* -- open hpi session
*/
if (fdebug) printf("saHpiVersionGet\n");
- hpiVer = saHpiVersionGet();
- printf("Hpi Version %d Implemented.\n", hpiVer);
+ hpiversion();
if (fdebug) printf("saHpiSessionOpen\n");
rv =
saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID,&sessionid,NULL);
diff -urNp openhpi-2.10.0/clients/hpitree.c
openhpi-2.10.0_version/clients/hpitree.c
--- openhpi-2.10.0/clients/hpitree.c 2007-08-31 10:15:38.000000000 -0600
+++ openhpi-2.10.0_version/clients/hpitree.c 2007-09-27
21:48:28.000000000 -0600
@@ -30,6 +30,8 @@
#include <SaHpi.h>
#include <oh_utils.h>
+#include <hpiversion.h>
+
/*
* Function prototypes
*/
@@ -104,7 +106,6 @@ main(int argc, char **argv)
{
SaErrorT rv = SA_OK;
- SaHpiVersionT hpiVer;
SaHpiSessionIdT sessionid;
SaHpiResourceIdT resourceid = all_resources;
@@ -155,8 +156,7 @@ main(int argc, char **argv)
* -- open hpi session
*/
if (fdebug) printf("saHpiVersionGet\n");
- hpiVer = saHpiVersionGet();
- printf("Hpi Version %d Implemented.\n", hpiVer);
+ hpiversion();
if (fdebug) printf("saHpiSessionOpen\n");
rv =
saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID,&sessionid,NULL);
diff -urNp openhpi-2.10.0/clients/hpiversion.c
openhpi-2.10.0_version/clients/hpiversion.c
--- openhpi-2.10.0/clients/hpiversion.c 1969-12-31 17:00:00.000000000
-0700
+++ openhpi-2.10.0_version/clients/hpiversion.c 2007-09-28
08:31:03.000000000 -0600
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2007-2008, Hewlett-Packard Development Company, LLP
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
distribution.
+ *
+ * Neither the name of the Hewlett-Packard Corporation, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author(s)
+ * Shuah Khan <[EMAIL PROTECTED]>
+*/
+/*
+ * This file contains a routine to print hpiversion. The original code
+ * for this rooutine came from hpiel.c main().
+*/
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+#include <SaHpi.h>
+#include <oHpi.h>
+#include <oh_utils.h>
+
+#include <hpiversion.h>
+
+#define OH_SVN_REV "$Revision: 6418 $"
+
+/**
+ * hpiversion: generates and prints HPI and OpenHPI version strings.
+ * Input params: none
+ * Output params: none
+ * Return values: None
+ **/
+void hpiversion( void )
+{
+ 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];
+
+ /* Generating version strings */
+ memset(svn_rev, 0, sizeof(SAHPI_MAX_TEXT_BUFFER_LENGTH));
+ strncpy(svn_rev, OH_SVN_REV, SAHPI_MAX_TEXT_BUFFER_LENGTH);
+ svn_rev[strlen(OH_SVN_REV)-2] = '\0';
+ printf("This program came with OpenHPI %u.%u.%u (%s)\n",
+ ohpi_major, ohpi_minor, ohpi_patch,
+ svn_rev + 11);
+ hpiver = saHpiVersionGet();
+ printf("HPI Version is %x.0%d.0%d\n",
+ (hpiver >> 16) + 9,
+ (hpiver & 0x0000FF00) >> 8,
+ hpiver & 0x000000FF);
+}
+
diff -urNp openhpi-2.10.0/clients/hpiversion.h
openhpi-2.10.0_version/clients/hpiversion.h
--- openhpi-2.10.0/clients/hpiversion.h 1969-12-31 17:00:00.000000000
-0700
+++ openhpi-2.10.0_version/clients/hpiversion.h 2007-09-27
21:47:22.000000000 -0600
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007-2008, Hewlett-Packard Development Company, LLP
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
distribution.
+ *
+ * Neither the name of the Hewlett-Packard Corporation, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author(s)
+ * Shuah Khan <[EMAIL PROTECTED]>
+*/
+/*
+ * This file contains a prototype for hpiversion() defined in
hpiversion.c
+*/
+extern void hpiversion( void );
diff -urNp openhpi-2.10.0/clients/Makefile.am
openhpi-2.10.0_version/clients/Makefile.am
--- openhpi-2.10.0/clients/Makefile.am 2007-08-31 10:15:37.000000000
-0600
+++ openhpi-2.10.0_version/clients/Makefile.am 2007-09-27
21:50:40.000000000 -0600
@@ -43,7 +43,7 @@ hpifan_SOURCES = hpifan.c
hpifan_LDADD = $(COMMONLIBS)
hpifan_LDFLAGS =
-hpitop_SOURCES = hpitop.c
+hpitop_SOURCES = hpitop.c hpiversion.c
hpitop_LDADD = $(COMMONLIBS)
hpitop_LDFLAGS =
@@ -51,7 +51,7 @@ hpireset_SOURCES = hpireset.c
hpireset_LDADD = $(COMMONLIBS)
hpireset_LDFLAGS =
-hpiel_SOURCES = hpiel.c
+hpiel_SOURCES = hpiel.c hpiversion.c
hpiel_LDADD = $(COMMONLIBS)
hpiel_LDFLAGS =
@@ -79,7 +79,7 @@ hpipower_SOURCES = hpipower.c
hpipower_LDADD = $(COMMONLIBS)
hpipower_LDFLAGS =
-hpitree_SOURCES = hpitree.c
+hpitree_SOURCES = hpitree.c hpiversion.c
hpitree_LDADD = $(COMMONLIBS)
hpitree_LDFLAGS =
====================Cut here=====================================
Thanks,
-- Shuah
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Openhpi-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openhpi-devel