libvpd-2.2.3/0000775000175000017500000000000012310046220013322 5ustar suzukikpsuzukikplibvpd-2.2.3/libvpd_cxx-2.pc.in0000664000175000017500000000050712310042633016562 0ustar suzukikpsuzukikpprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libvpd Description: C++ library for access to system VPD Version: @VERSION@ Libs: -L${libdir} -lpthread -lsqlite3 -lstdc++ -l@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@ Cflags: -I${includedir}/@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@libvpd-2.2.3/libvpd.spec.in0000664000175000017500000000745412310042633016101 0ustar suzukikpsuzukikp%define name libvpd %define version @VERSION@ Name: %{name} Version: %{version} Release: 0%{?dist} Summary: VPD Database access library for lsvpd Group: System Environment/Libraries License: LGPLv2+ Vendor: IBM Corp. URL: http://linux-diag.sf.net/Lsvpd.html Source: http://downloads.sourceforge.net/linux-diag/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: sqlite-devel zlib-devel libstdc++-devel %description The libvpd package contains the classes that are used to access a vpd database created by vpdupdate in the lsvpd package. %package devel Summary: Header files for libvpd Group: Development/Libraries Requires: %{name} = %{version}-%{release} sqlite-devel pkgconfig %description devel Contains header files for building with libvpd. %prep %setup -q %build %configure --disable-static %{__make} %{?_smp_mflags} %clean %{__rm} -rf $RPM_BUILD_ROOT %install %{__rm} -rf $RPM_BUILD_ROOT %{__make} install DESTDIR=$RPM_BUILD_ROOT %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr(-,root,root,-) %doc COPYING NEWS README AUTHORS %exclude %{_libdir}/*.la %{_libdir}/libvpd_cxx-@GENERIC_RELEASE@.so.* %{_libdir}/libvpd-@GENERIC_RELEASE@.so.* %{_sysconfdir}/udev/rules.d/90-vpdupdate.rules %{_var}/lib/lsvpd/run.vpdupdate %files devel %defattr(-,root,root,-) %exclude %{_libdir}/*.la %{_includedir}/libvpd-2 %{_libdir}/libvpd_cxx.so %{_libdir}/libvpd.so %{_libdir}/pkgconfig/libvpd-2.pc %{_libdir}/pkgconfig/libvpd_cxx-2.pc %changelog * Wed Mar 13 2014 Suzuki K Poulose 2.2.3 - Relese version 2.2.3 * Tue Nov 5 2013 Suzuki K Poulose 2.2.2-0 - Release version 2.2.2 * Thu Oct 31 2013 Phani Yadav - Automation of vpdupdate * Wed Feb 20 2013 Harsh P Bora 2.2.1-1 - Added Vendor tag in RPM package. * Fri Jan 18 2013 Harsh P Bora 2.2.1-0 - Fixed a possible segfault when fetching a corrupt vpd database * Fri Dec 4 2009 Jim Keniston 2.1.2-0 - Fixed a pack/unpack mismatch that was introduced with N5/N6 support. For every Component, all 28 DataItems between sysFsNode and plantMfg were getting the wrong values. * Mon Mar 17 2008 Eric Munson 2.0.1-1 - Update for libvpd-2.0.1 * Tue Feb 26 2008 Eric Munson 2.0.0-2 - Updating release number for new build in FC * Mon Feb 25 2008 Eric Munson 2.0.0-1 - Updated library to use sqlite instead of berkeley db. * Mon Feb 18 2008 Fedora Release Engineering - 1.5.0-2 - Autorebuild for GCC 4.3 * Mon Jan 7 2008 Eric Munson -1.5.0-1 - Moved pkgconfig to devel Requires - Updated %%defattrs to -,root,root,- - Added AUTHORS to %%doc * Thu Jan 3 2008 Eric Munson - 1.5.0-0 - Updated Requires and Provides fields per fedora community request * Fri Dec 7 2007 Brad Peters - 1.4.2-0 - Added functions to helper_functions class - Mnior changes necessary to support new device discovery method * Fri Nov 16 2007 Eric Munson - 1.4.1-1 - Removing INSTALL from docs and docs from -devel package - Fixing Makfile.am so libraries have the .so extension - Using %%configure, %%{__make}, and %%{__rm} calls - Changing source URL * Wed Oct 31 2007 Eric Munson - 1.4.0-2 - Changing files lists for libdirs to match library file names * Tue Oct 30 2007 Eric Munson - 1.4.0-1 - Adding C Library to files lists. * Sat Oct 20 2007 Ralf Corsepius - 1.3.5-4 - Various spec-file fixes. * Fri Oct 19 2007 Eric Munson - 1.3.5-3 - Removed hard coded /usr/lib from spec file - Install now sets all headers to 644 - Updated license libvpd-2.2.3/bootstrap.sh0000775000175000017500000000014012310042633015675 0ustar suzukikpsuzukikpset -x libtoolize --force && aclocal && autoheader && automake --add-missing --copy && autoconf libvpd-2.2.3/libvpd-2.pc.in0000664000175000017500000000047412310042633015703 0ustar suzukikpsuzukikpprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libvpd Description: C library for access to system VPD Version: @VERSION@ Libs: -L${libdir} -lpthread -lsqlite3 -l@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@ Cflags: -I${includedir}/@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@libvpd-2.2.3/configure.in0000664000175000017500000000353512310042633015645 0ustar suzukikpsuzukikp#base AC_INIT([libvpd],[2.2.3],[hegdevasant@in.ibm.com,suzuki@in.ibm.com]) AC_CONFIG_HEADER(src/libvpd-2/config.h) AM_INIT_AUTOMAKE AC_SUBST(DATE, [`date`]) #Generic variable setup GENERIC_LIBRARY_NAME=libvpd #Release version GENERIC_MAJOR_VERSION=2 GENERIC_MINOR_VERSION=2 GENERIC_MICRO_VERSION=3 GENERIC_API_VERSION=$GENERIC_MAJOR_VERSION AC_SUBST(GENERIC_API_VERSION) GENERIC_CXX_LIBRARY_VERSION=$GENERIC_MAJOR_VERSION:$GENERIC_MINOR_VERSION:$GENERIC_MICRO_VERSION GENERIC_C_LIBRARY_VERSION=$GENERIC_MAJOR_VERSION:$GENERIC_MINOR_VERSION:$GENERIC_MICRO_VERSION AC_SUBST(GENERIC_CXX_LIBRARY_VERSION) AC_SUBST(GENERIC_C_LIBRARY_VERSION) AC_SUBST(GENERIC_LIBRARY_VERSION) PACKAGE=$GENERIC_LIBRARY_NAME AC_SUBST(GENERIC_LIBRARY_NAME) GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION AC_SUBST(GENERIC_RELEASE) AC_SUBST(GENERIC_VERSION) VERSION=$GENERIC_VERSION #programs AC_LANG([C++]) AC_PROG_CC AC_PROG_CXX AC_C_CONST AC_C_INLINE AC_HEADER_STDBOOL AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AM_PROG_LIBTOOL AC_SUBST(LIBTOOL_DEPS) #headers AC_HEADER_STDBOOL AC_TYPE_SIZE_T AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/ioctl.h sys/param.h syslog.h unistd.h ctype.h]) AC_CHECK_HEADERS([sqlite3.h],,[AC_MSG_ERROR([sqlite header files are required for building libvpd])]) #libraries AC_CHECK_LIB(sqlite3, sqlite3_libversion_number, [], [ echo "sqlite3 library is required for lsvpd" exit 1 ]) AC_FUNC_CLOSEDIR_VOID AC_PROG_GCC_TRADITIONAL AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_HEADER_MAJOR AC_FUNC_MALLOC AC_FUNC_STAT AC_CHECK_FUNCS([memmove memset mkdir socket strdup strerror strtol uname sqlite3_prepare_v2]) #finished AC_CONFIG_FILES([Makefile libvpd.spec debian/changelog libvpd-2.pc libvpd_cxx-2.pc]) AC_OUTPUT libvpd-2.2.3/COPYING0000664000175000017500000005744412310042633014377 0ustar suzukikpsuzukikp GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. libvpd-2.2.3/AUTHORS0000664000175000017500000000010412310042633014371 0ustar suzukikpsuzukikpEric Munson Brad Peters libvpd-2.2.3/Makefile.am0000664000175000017500000000400712310042633015363 0ustar suzukikpsuzukikplib_hpp_files = src/libvpd-2/vpdretriever.hpp \ src/libvpd-2/system.hpp \ src/libvpd-2/component.hpp \ src/libvpd-2/vpdexception.hpp \ src/libvpd-2/dataitem.hpp \ src/libvpd-2/Source.hpp \ src/libvpd-2/logger.hpp \ src/libvpd-2/lsvpd.hpp \ src/libvpd-2/debug.hpp \ src/libvpd-2/helper_functions.hpp \ src/libvpd-2/lsvpd_error_codes.hpp \ src/libvpd-2/vpddbenv.hpp lib_h_files = src/libvpd-2/vpdretriever.h \ src/libvpd-2/system.h \ src/libvpd-2/component.h \ src/libvpd-2/dataitem.h \ src/libvpd-2/common.h \ src/libvpd-2/vpddbenv.h EXTRA_DIST = bootstrap.sh 90-vpdupdate.rules run.vpdupdate lib_LTLIBRARIES = libvpd_cxx.la libvpd.la library_includedir=$(includedir)/libvpd-2/ library_include_HEADERS = $(lib_hpp_files) $(lib_h_files) INCLUDES = -I./src/ libvpd_la_SOURCES = src/vpdretriever_c.c \ src/common.c \ src/vpddbenv_c.c \ src/system_c.c \ src/component_c.c \ src/dataitem_c.c \ $(lib_h_files) libvpd_cxx_la_SOURCES = src/vpdretriever.cpp \ src/helper_functions.cpp \ src/vpddbenv.cpp \ src/logger.cpp \ src/system.cpp \ src/component.cpp \ src/vpdexception.cpp \ src/dataitem.cpp \ src/Source.cpp \ $(lib_hpp_files) CXX_VERSION=@GENERIC_CXX_LIBRARY_VERSION@ C_VERSION=@GENERIC_C_LIBRARY_VERSION@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libvpd-2.pc libvpd_cxx-2.pc libvpd_cxx_la_LDFLAGS = -module -lstdc++ -version-number \ $(CXX_VERSION) -release @GENERIC_RELEASE@ libvpd_la_LDFLAGS = -module -version-number \ $(C_VERSION) -release @GENERIC_RELEASE@ AM_CXXFLAGS = -DDEST_DIR='"${exec_prefix}"' AM_CFLAGS = -DDEST_DIR='"${exec_prefix}"' LIBTOOL_DEPS = @LIBTOOL_DEPS@ libtool: $(LIBTOOL_DEPS) $(SHELL) ./config.status --recheck install-exec-hook: mkdir -p $(DESTDIR)/${sysconfdir}/udev/rules.d/ mkdir -p $(DESTDIR)/${localstatedir}/lib/lsvpd/ install -D --mode=644 run.vpdupdate \ ${DESTDIR}/${localstatedir}/lib/lsvpd/run.vpdupdate install -D --mode=644 90-vpdupdate.rules \ ${DESTDIR}/${sysconfdir}/udev/rules.d/90-vpdupdate.rules libvpd-2.2.3/NEWS0000664000175000017500000000004212310042633014021 0ustar suzukikpsuzukikpThis file is intentionally blank. libvpd-2.2.3/README0000664000175000017500000000201712310042633014206 0ustar suzukikpsuzukikplibvpd 2.1.0 Installation (briefly, For more detailed instructions please see ./INSTALL) : # ./bootstrap.sh # ./configure [--prefix=/usr/] # make # make install Binary Dependencies zlib Compilation Dependencies Sqlite3 development package (Src: http://www.sqlite.org/) ZLIB development package (Src: http://www.zlib.net/zlib-1.2.3.tar.gz) For users of older RHEL and SLES versions: slqite is not available in the default repositories for some of the older RHEL and SLES versions. If you want to run the new lsvpd/libvpd setup you need build sqlite version 3.0.0 or newer from source (available here: http://www.sqlite.org) or find an appropriate binary package for your architecture and software setup. BUILDING RPMS To build a tarball to feed to rpmbuild, do # make dist It is necessary to specify that the target architecture is 32 bit when building the rpm for this package. As an example, we use a command similar to the following: > rpmbuild -ba --prefix=/usr --target=ppc --nodeps [PATH TO SPEC FILE] libvpd-2.2.3/run.vpdupdate0000664000175000017500000000000012310042633016036 0ustar suzukikpsuzukikplibvpd-2.2.3/src/0000775000175000017500000000000012310042633014115 5ustar suzukikpsuzukikplibvpd-2.2.3/src/component_c.c0000664000175000017500000004131712310042633016573 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * ebmunson@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "libvpd-2/component.h" #include #include #include #include struct component* new_component( int init ) { struct component *ret = NULL; ret = malloc( sizeof( struct component ) ); if( !ret ) return NULL; memset( ret, 0, sizeof( struct component ) ); if( init ) { ret->id = new_dataitem( ); if( !ret->id ) goto outerr; ret->id->humanName = strdup( "Main Device Node, equals sysFsNode or deviceTreeNode" ); ret->deviceTreeNode = new_dataitem( ); if( !ret->deviceTreeNode ) goto outerr; ret->deviceTreeNode->humanName = strdup( "/proc/device-tree Device Node" ); ret->sysFsNode = new_dataitem( ); if( !ret->sysFsNode ) goto outerr; ret->sysFsNode->humanName = strdup( "/sys Device Node" ); ret->sysFsLinkTarget = new_dataitem( ); if( !ret->sysFsLinkTarget ) goto outerr; ret->sysFsLinkTarget->humanName = strdup( "/sys/bus Device Node" ); ret->devClass = new_dataitem( ); if( !ret->devClass ) goto outerr; ret->devClass->humanName = strdup( "/sys/bus/XXX - Device Class" ); ret->fru = new_dataitem( ); if( !ret->fru ) goto outerr; ret->fru->ac = strdup( "FN" ); ret->fru->humanName = strdup( "Field Replaceable Unit Number" ); ret->scsiDetail = new_dataitem( ); if( !ret->scsiDetail ) goto outerr; ret->scsiDetail->ac = strdup( "ZZ" ); ret->scsiDetail->humanName = strdup( "Device Details" ); ret->plantMfg = new_dataitem( ); if( !ret->plantMfg ) goto outerr; ret->plantMfg->ac = strdup( "SE" ); ret->plantMfg->humanName = strdup( "Plant of manufacture" ); ret->netAddr = new_dataitem( ); if( !ret->netAddr ) goto outerr; ret->netAddr->ac = strdup( "NA" ); ret->netAddr->humanName = strdup( "Network Address" ); ret->description = new_dataitem( ); if( !ret->description ) goto outerr; ret->description->ac = strdup( "DS" ); ret->description->humanName = strdup( "Displayable Message" ); ret->cdField = new_dataitem( ); if( !ret->cdField ) goto outerr; ret->cdField->ac = strdup( "CD" ); ret->cdField->humanName = strdup( "Card ID" ); ret->serialNumber = new_dataitem( ); if( !ret->serialNumber ) goto outerr; ret->serialNumber->ac = strdup( "SN" ); ret->serialNumber->humanName = strdup( "Serial Number" ); ret->partNumber = new_dataitem( ); if( !ret->partNumber ) goto outerr; ret->partNumber->ac = strdup( "PN" ); ret->partNumber->humanName = strdup( "Part Number of Assembly" ); ret->firmwareLevel = new_dataitem( ); if( !ret->firmwareLevel ) goto outerr; ret->firmwareLevel->ac = strdup( "RL" ); ret->firmwareLevel->humanName = strdup( "Non-alterable ROM level" ); ret->firmwareVersion = new_dataitem( ); if( !ret->firmwareVersion ) goto outerr; ret->firmwareVersion->ac = strdup( "RM" ); ret->firmwareVersion->humanName = strdup( "Alterable ROM level" ); ret->manufacturer = new_dataitem( ); if( !ret->manufacturer ) goto outerr; ret->manufacturer->ac = strdup( "MF" ); ret->manufacturer->humanName = strdup( "Manufacturer Name" ); ret->model = new_dataitem( ); if( !ret->model ) goto outerr; ret->model->ac = strdup( "TM" ); ret->model->humanName = strdup( "Machine Type-Model" ); ret->manufacturerID = new_dataitem( ); if( !ret->manufacturerID ) goto outerr; ret->manufacturerID->ac = strdup( "MN" ); ret->manufacturerID->humanName = strdup( "Manufacturer ID" ); ret->engChangeLevel = new_dataitem( ); if( !ret->engChangeLevel ) goto outerr; ret->engChangeLevel->ac = strdup( "EC" ); ret->engChangeLevel->humanName = strdup( "Engineering Change Level" ); ret->featureCode = new_dataitem( ); if( !ret->featureCode ) goto outerr; ret->featureCode->ac = strdup( "FC" ); ret->featureCode->humanName = strdup( "Feature Code or Request for Price Quotation (RPQ) number" ); ret->devDriver = new_dataitem( ); if( !ret->devDriver ) goto outerr; ret->devDriver->ac = strdup( "DD" ); ret->devDriver->humanName = strdup( "Device Driver Level" ); ret->recordType = new_dataitem( ); if( !ret->recordType ) goto outerr; ret->recordType->ac = strdup( "RT" ); ret->recordType->humanName = strdup( "Record Type" ); ret->keywordVersion = new_dataitem( ); if( !ret->keywordVersion ) goto outerr; ret->keywordVersion->ac = strdup( "VK" ); ret->keywordVersion->humanName = strdup( "Keyword Version" ); ret->microCodeImage = new_dataitem( ); if( !ret->microCodeImage ) goto outerr; ret->microCodeImage->ac = strdup( "MI" ); ret->microCodeImage->humanName = strdup( "Keyword Version" ); ret->physicalLocation = new_dataitem( ); if( !ret->physicalLocation ) goto outerr; ret->physicalLocation->ac = strdup( "YL" ); ret->physicalLocation->humanName = strdup( "Location Code" ); ret->secondLocation = new_dataitem( ); if( !ret->secondLocation ) goto outerr; ret->secondLocation->ac = strdup( "YL" ); ret->secondLocation->humanName = strdup( "Location Code" ); ret->devBus = new_dataitem( ); if( !ret->devBus ) goto outerr; ret->devBus->humanName = strdup( "Device Bus" ); } return ret; outerr: free_component( ret ); return NULL; } void free_component( struct component *freeme ) { struct component *this, *next; struct list *ids; /* Free dataitems */ free_dataitem( freeme->id ); free_dataitem( freeme->deviceTreeNode ); free_dataitem( freeme->sysFsNode ); free_dataitem( freeme->sysFsLinkTarget ); free_dataitem( freeme->halUDI ); free_dataitem( freeme->netAddr ); free_dataitem( freeme->devClass ); free_dataitem( freeme->description ); free_dataitem( freeme->cdField ); free_dataitem( freeme->serialNumber ); free_dataitem( freeme->partNumber ); free_dataitem( freeme->firmwareLevel ); free_dataitem( freeme->firmwareVersion ); free_dataitem( freeme->fru ); free_dataitem( freeme->manufacturer ); free_dataitem( freeme->model ); free_dataitem( freeme->manufacturerID ); free_dataitem( freeme->engChangeLevel ); free_dataitem( freeme->parent ); free_dataitem( freeme->devSubSystem ); free_dataitem( freeme->devDriver ); free_dataitem( freeme->devKernel ); free_dataitem( freeme->devKernelNumber ); free_dataitem( freeme->devSysName ); free_dataitem( freeme->devDevTreeName ); free_dataitem( freeme->devBus ); free_dataitem( freeme->devType ); free_dataitem( freeme->devBusAddr ); free_dataitem( freeme->microCodeImage ); free_dataitem( freeme->recordType ); free_dataitem( freeme->scsiDetail ); free_dataitem( freeme->plantMfg ); free_dataitem( freeme->featureCode ); free_dataitem( freeme->keywordVersion ); free_dataitem( freeme->microCodeVersion ); free_dataitem( freeme->physicalLocation ); free_dataitem( freeme->secondLocation ); free_dataitem( freeme->deviceSpecific ); free_dataitem( freeme->userData ); free_dataitem( freeme->aixNames ); /* Free Children */ this = freeme->children; while( this ) { next = this->next; free_component( this ); this = next; } if( freeme->childrenIDs ) { ids = freeme->childrenIDs; while( ids ) { free_list( ids ); ids = ids->next; } } free( freeme ); } /** * Code adapted from component.cpp, dataitems are unpacked in the same * order as the Component::unpack( void* ) method to maintain consistency. */ struct component * unpack_component( void *buffer ) { struct component *ret = NULL; u32 size = 0, netOrder; char *packed = (char*)buffer; char * next; struct list *item; struct dataitem *data; if( !buffer ) return ret; ret = new_component( 0 ); if( !ret ) return ret; memcpy( &netOrder, packed, sizeof( u32 ) ); size = ntohl( netOrder ); next = packed + sizeof( u32 ); ret->id = unpack_dataitem( next ); if( !ret->id ) goto unpackerr; next += calc_packed_length_dataitem( ret->id ); ret->deviceTreeNode = unpack_dataitem( next ); if( !ret->deviceTreeNode ) goto unpackerr; next += calc_packed_length_dataitem( ret->deviceTreeNode ); ret->sysFsNode = unpack_dataitem( next ); if( !ret->sysFsNode ) goto unpackerr; next += calc_packed_length_dataitem( ret->sysFsNode ); ret->sysFsLinkTarget = unpack_dataitem( next ); if( !ret->sysFsLinkTarget ) goto unpackerr; next += calc_packed_length_dataitem( ret->sysFsLinkTarget ); ret->halUDI = unpack_dataitem( next ); if( !ret->halUDI ) goto unpackerr; next += calc_packed_length_dataitem( ret->halUDI ); ret->netAddr = unpack_dataitem( next ); if( !ret->netAddr ) goto unpackerr; next += calc_packed_length_dataitem( ret->netAddr ); ret->devClass = unpack_dataitem( next ); if( !ret->devClass ) goto unpackerr; next += calc_packed_length_dataitem( ret->devClass ); ret->description = unpack_dataitem( next ); if( !ret->description ) goto unpackerr; next += calc_packed_length_dataitem( ret->description ); ret->cdField = unpack_dataitem( next ); if( !ret->cdField ) goto unpackerr; next += calc_packed_length_dataitem( ret->cdField ); ret->serialNumber = unpack_dataitem( next ); if( !ret->serialNumber ) goto unpackerr; next += calc_packed_length_dataitem( ret->serialNumber ); ret->partNumber = unpack_dataitem( next ); if( !ret->partNumber ) goto unpackerr; next += calc_packed_length_dataitem( ret->partNumber ); ret->firmwareLevel = unpack_dataitem( next ); if( !ret->firmwareLevel ) goto unpackerr; next += calc_packed_length_dataitem( ret->firmwareLevel ); ret->firmwareVersion = unpack_dataitem( next ); if( !ret->firmwareVersion ) goto unpackerr; next += calc_packed_length_dataitem( ret->firmwareVersion ); ret->fru = unpack_dataitem( next ); if( !ret->fru ) goto unpackerr; next += calc_packed_length_dataitem( ret->fru ); ret->manufacturer = unpack_dataitem( next ); if( !ret->manufacturer ) goto unpackerr; next += calc_packed_length_dataitem( ret->manufacturer ); ret->model = unpack_dataitem( next ); if( !ret->model ) goto unpackerr; next += calc_packed_length_dataitem( ret->model ); ret->manufacturerID = unpack_dataitem( next ); if( !ret->manufacturerID ) goto unpackerr; next += calc_packed_length_dataitem( ret->manufacturerID ); ret->engChangeLevel = unpack_dataitem( next ); if( !ret->engChangeLevel ) goto unpackerr; next += calc_packed_length_dataitem( ret->engChangeLevel ); ret->parent = unpack_dataitem( next ); if( !ret->parent ) goto unpackerr; next += calc_packed_length_dataitem( ret->parent ); ret->devSubSystem = unpack_dataitem( next ); if( !ret->devSubSystem ) goto unpackerr; next += calc_packed_length_dataitem( ret->devSubSystem ); ret->devDriver = unpack_dataitem( next ); if( !ret->devDriver ) goto unpackerr; next += calc_packed_length_dataitem( ret->devDriver ); ret->devKernel = unpack_dataitem( next ); if( !ret->devKernel ) goto unpackerr; next += calc_packed_length_dataitem( ret->devKernel ); ret->devKernelNumber = unpack_dataitem( next ); if( !ret->devKernelNumber ) goto unpackerr; next += calc_packed_length_dataitem( ret->devKernelNumber ); ret->devSysName = unpack_dataitem( next ); if( !ret->devSysName ) goto unpackerr; next += calc_packed_length_dataitem( ret->devSysName ); ret->devDevTreeName = unpack_dataitem( next ); if( !ret->devDevTreeName ) goto unpackerr; next += calc_packed_length_dataitem( ret->devDevTreeName ); ret->devBus = unpack_dataitem( next ); if( !ret->devBus ) goto unpackerr; next += calc_packed_length_dataitem( ret->devBus ); ret->devBusAddr = unpack_dataitem( next ); if( !ret->devBusAddr ) goto unpackerr; next += calc_packed_length_dataitem( ret->devBusAddr ); ret->recordType = unpack_dataitem( next ); if( !ret->recordType ) goto unpackerr; next += calc_packed_length_dataitem( ret->recordType ); ret->scsiDetail = unpack_dataitem( next ); if( !ret->scsiDetail ) goto unpackerr; next += calc_packed_length_dataitem( ret->scsiDetail ); ret->plantMfg = unpack_dataitem( next ); if( !ret->plantMfg ) goto unpackerr; next += calc_packed_length_dataitem( ret->plantMfg ); ret->featureCode = unpack_dataitem( next ); if( !ret->featureCode ) goto unpackerr; next += calc_packed_length_dataitem( ret->featureCode ); ret->keywordVersion = unpack_dataitem( next ); if( !ret->keywordVersion ) goto unpackerr; next += calc_packed_length_dataitem( ret->keywordVersion ); ret->microCodeImage = unpack_dataitem( next ); if( !ret->microCodeImage ) goto unpackerr; next += calc_packed_length_dataitem( ret->microCodeImage ); ret->secondLocation = unpack_dataitem( next ); if( !ret->secondLocation ) goto unpackerr; next += calc_packed_length_dataitem( ret->secondLocation ); ret->physicalLocation = unpack_dataitem( next ); if( !ret->physicalLocation ) goto unpackerr; next += calc_packed_length_dataitem( ret->physicalLocation ); while( 0 == strncmp( next, CHILD_START, strlen( CHILD_START ) ) ) { next++; if( next > packed + size ) goto unpackerr; } if( strncmp( next, CHILD_START, strlen( CHILD_START ) ) == 0 ) { next += strlen( CHILD_START ) + 1; if( next > packed + size ) goto unpackerr; while( strncmp( next, CHILD_END, strlen( CHILD_END ) ) != 0 ) { item = new_list( ); if( !next ) goto unpackerr; item->data = strdup( next ); next += strlen( (char*)item->data ) + 1; if( !ret->childrenIDs ) ret->childrenIDs = item; else concat_list( ret->childrenIDs, item ); if( next > packed + size ) goto unpackerr; } next += strlen( CHILD_END ) + 1; } if( strncmp( next, DEVICE_START, strlen( DEVICE_START ) ) == 0 ) { next += strlen( DEVICE_START ) + 1; if( next > packed + size ) goto unpackerr; while( strncmp( next, DEVICE_END, strlen( DEVICE_END ) ) != 0 ) { data = unpack_dataitem( next ); if( !data ) goto unpackerr; next += calc_packed_length_dataitem( data ); if( !ret->deviceSpecific ) ret->deviceSpecific = data; else add_dataitem( ret->deviceSpecific, data ); if( next > packed + size ) goto unpackerr; } next += strlen( DEVICE_END ) + 1; } if( strncmp( next, USER_START, strlen( USER_START ) ) == 0 ) { next += strlen( USER_START ) + 1; if( next > packed + size ) goto unpackerr; while( strncmp( next, USER_END, strlen( USER_END ) ) != 0 ) { data = unpack_dataitem( next ); if( !data ) goto unpackerr; next += calc_packed_length_dataitem( data ); if( !ret->userData ) ret->userData = data; else add_dataitem( ret->userData, data ); if( next > packed + size ) goto unpackerr; } next += strlen( USER_END ) + 1; } if( strncmp( next, AX_START, strlen( AX_START ) ) == 0 ) { next += strlen( AX_START ) + 1; if( next > packed + size ) goto unpackerr; while( strncmp( next, AX_END, strlen( AX_END ) ) != 0 ) { data = unpack_dataitem( next ); if( !data ) goto unpackerr; next += calc_packed_length_dataitem( data ); if( !ret->aixNames ) ret->aixNames = data; else add_dataitem( ret->aixNames, data ); if( next > packed + size ) goto unpackerr; } } return ret; unpackerr: free_component( ret ); return NULL; } void add_component( struct component *head, const struct component *addme ) { if( !head || !addme ) return; while( head->next ) head = head->next; head->next = addme; } libvpd-2.2.3/src/logger.cpp0000664000175000017500000000374012310042633016104 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include namespace lsvpd { Logger::Logger( const string& ident ) : mIdent( ident ) { openlog( mIdent.c_str( ), LOG_PID, LOG_USER ); } Logger::~Logger( ) { closelog( ); } void Logger::log( const string& message, int level ) const { syslog( level, "%s", message.c_str( ) ); } } libvpd-2.2.3/src/common.c0000664000175000017500000000444712310042633015562 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * ebmunson@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include struct list* new_list( ) { struct list *ret = NULL; ret = malloc( sizeof( struct list ) ); if( !ret ) return ret; memset( ret, 0, sizeof( struct list ) ); return ret; } void free_list( struct list *head ) { struct list *next; while( head ) { next = head->next; if( head->data ) free( head->data ); free( head ); head = next; } } struct list* concat_list( struct list *head, const struct list *addme ) { struct list *ret = head; if( !head || !addme ) return NULL; while( head->next ) head = head->next; head->next = addme; return ret; } libvpd-2.2.3/src/system.cpp0000664000175000017500000004176712310042633016164 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #define TRACE_ON #include #include #include #include #include #include #include #include namespace lsvpd { string const System::CHILD_START ( "::childrenStart::" ); string const System::CHILD_END ( "::childrenEnd::" ); string const System::DEVICE_START ( "::deviceSpecificStart::" ); string const System::DEVICE_END ( "::deviceSpecificEnd::" ); string const System::USER_START ( "::userStart::" ); string const System::USER_END ( "::userEnd::" ); string const System::ID ( "/sys/bus" ); System::System() { mIdNode.setValue( ID, 100, __FILE__, __LINE__ ); mDescription.ac = "DS"; mDescription.humanName = "Description"; mBrand.ac = "BR"; mBrand.humanName = "Brand Keyword"; mOS.ac = "OS"; mOS.humanName = "Operating System"; mProcessorID.ac = "PI"; mProcessorID.humanName = "Processor ID or unique ID"; mMachineType.ac = "TM"; mMachineType.humanName = "Machine Type"; mMachineModel.ac = "TM"; mMachineModel.humanName = "Machine Model"; mFeatureCode.ac = "FC"; mFeatureCode.humanName = "Feature Code"; mFlagField.ac = "FG"; mFlagField.humanName = "Flag Field"; mRecordType.ac = "RT"; mRecordType.humanName = "Record Type"; mSerialNum1.ac = "SE"; mSerialNum1.humanName = "Machine or Cabinet Serial Number"; mSerialNum2.ac = "SE"; mSerialNum2.humanName = "Machine or Cabinet Serial Number"; mSUID.ac = "SU"; mSUID.humanName = "System Unique ID"; mKeywordVersion.ac = "VK"; mKeywordVersion.humanName = "Version of Keywords"; mLocationCode.ac = "YL"; mLocationCode.humanName = "Location Code"; mArch = ""; mCPUCount = 1; mDeviceSpecific = vector( ); mUserData = vector( ); mChildren = vector( ); mLeaves = vector( ); } System::System( const void* packedData ) { unpack( packedData ); mIdNode.setValue( ID, 100, __FILE__, __LINE__ ); mLeaves = vector( ); } System::~System( ) { vector::iterator i, end = mLeaves.end( ); for( i = mLeaves.begin( ); i != end; ++i ) { delete (*i); } vector::iterator j, dEnd; for( j = mDeviceSpecific.begin( ), dEnd = mDeviceSpecific.end( ); j != dEnd; ++j ) { delete (*j); } } unsigned int System::getPackedSize( ) { unsigned int ret = INIT_BUF_SIZE; ret += ( sizeof( u32 ) * 2 ); ret += mIdNode.getPackedLength( ); ret += mArch.getPackedLength( ); ret += deviceTreeNode.getPackedLength( ); ret += mDescription.getPackedLength( ); ret += mBrand.getPackedLength( ); ret += mNodeName.getPackedLength( ); ret += mOS.getPackedLength( ); ret += mProcessorID.getPackedLength( ); ret += mMachineType.getPackedLength( ); ret += mMachineModel.getPackedLength( ); ret += mFeatureCode.getPackedLength( ); ret += mFlagField.getPackedLength( ); ret += mRecordType.getPackedLength( ); ret += mSerialNum1.getPackedLength( ); ret += mSerialNum2.getPackedLength( ); ret += mSUID.getPackedLength( ); ret += mKeywordVersion.getPackedLength( ); ret += mLocationCode.getPackedLength( ); ret += mDeviceSpecific.size( ); ret += mUserData.size( ); ret += mChildren.size( ); vector::iterator child, cEnd; vector::iterator item, dEnd; for( child = mChildren.begin( ), cEnd = mChildren.end( ); child != cEnd; ++child ) { ret += (*child).length( ); } for( item = mDeviceSpecific.begin( ), dEnd = mDeviceSpecific.end( ); item != dEnd; ++item ) { ret += (*item)->getPackedLength( ); } for( item = mUserData.begin( ), dEnd = mUserData.end( ); item != dEnd; ++item ) { ret += (*item)->getPackedLength( ); } return ret; } /** * pack serializes this object into the provided buffer (pack will allocate the * buffer) storing only the data fields (at the moment) and ignoring all the meta- * data within the DataItem object. The format for the packed object will be * direct strings seperated by '\0' charaters. If a given string field is empty * then there will be consectutive '\0' characters. Each of the vector fields will * be preceeded by ::listNameStart:: and followed by ::listNameEnd:: (e.g. the * children vector will be ::childrenStart::\0data\0data\0::childrenEnd::\0). */ unsigned int System::pack( void** buffer ) { u32 ret = getPackedSize( ), length; char* buf; buf = new char[ ret ]; if( buf == NULL ) { string message( "Component.pack( ): new call failed, out of memory." ); Logger l; l.log( message, LOG_ERR ); VpdException ve( message ); throw ve; } memset( buf, '\0', ret ); *buffer = (void*)buf; /* -----------------------------------------------------*/ /* ------------ Load up the buffer with data -----------*/ /* -----------------------------------------------------*/ // The first entry in our buffer is our length in network byte order u32 netOrder = htonl( ret ); memcpy( buf, &netOrder, sizeof( u32 ) ); buf += sizeof( u32 ); // Next is our system CPU count. netOrder = htonl( mCPUCount ); memcpy( buf, &netOrder, sizeof( u32 ) ); buf += sizeof( u32 ); // Pack the individual data items. length = mIdNode.pack( buf ); buf += length; length = mArch.pack( buf ); buf += length; length = deviceTreeNode.pack( buf ); buf += length; length = mDescription.pack( buf ); buf += length; length = mBrand.pack( buf ); buf += length; length = mNodeName.pack( buf ); buf += length; length = mOS.pack( buf ); buf += length; length = mProcessorID.pack( buf ); buf += length; length = mMachineType.pack( buf ); buf += length; length = mMachineModel.pack( buf ); buf += length; length = mFeatureCode.pack( buf ); buf += length; length = mFlagField.pack( buf ); buf += length; length = mRecordType.pack( buf ); buf += length; length = mSerialNum1.pack( buf ); buf += length; length = mSerialNum2.pack( buf ); buf += length; length = mSUID.pack( buf ); buf += length; length = mKeywordVersion.pack( buf ); buf += length; length = mLocationCode.pack( buf ); buf += length; // Pack the child vector. memcpy( buf, CHILD_START.c_str( ), CHILD_START.length( ) ); buf += CHILD_START.length( ); *buf = '\0'; buf++; vector::iterator child, cEnd; vector::iterator item, dEnd; for( child = mChildren.begin( ), cEnd = mChildren.end( ); child != cEnd; ++child ) { const char* str = (*child).c_str( ); int length = (*child).length( ); memcpy( buf, str, length ); buf+= length; *buf = '\0'; buf++; } memcpy( buf, CHILD_END.c_str( ), CHILD_END.length( ) ); buf += CHILD_END.length( ); *buf = '\0'; buf++; // Pack the Device Specific vector memcpy( buf, DEVICE_START.c_str( ), DEVICE_START.length( ) ); buf += DEVICE_START.length( ); *buf = '\0'; buf++; for( item = mDeviceSpecific.begin( ), dEnd = mDeviceSpecific.end( ); item != dEnd; ++item ) { length = (*item)->pack( buf ); buf+= length; } memcpy( buf, DEVICE_END.c_str( ), DEVICE_END.length( ) ); buf += DEVICE_END.length( ); *buf = '\0'; buf++; // Pack the User Data vector memcpy( buf, USER_START.c_str( ), USER_START.length( ) ); buf += USER_START.length( ); *buf = '\0'; buf++; for( item = mUserData.begin( ), dEnd = mUserData.end( ); item != dEnd; ++item ) { length = (*item)->pack( buf ); buf+= length; } memcpy( buf, USER_END.c_str( ), USER_END.length( ) ); buf += USER_END.length( ); *buf = '\0'; buf++; return ret; } /** * unpack does exactly the opposite from pack, it will take a data buffer * and load this object with the contents. If we need more data than the * size claims that we have, then we have a corrupt buffer and we will * throw an exception. */ void System::unpack( const void* payload ) { u32 size = 0, netOrder; char* packed = (char*) payload; char* next = packed;; string item; if( payload == NULL ) { // Rather than throwing an exception, this will just return, if NULL is handed in // this far there is nothing that we can do to stop program instability other // than refuse to mess with it. return; } // Load the size of the payload. (It is packed in network order) memcpy( &netOrder, next, sizeof( u32 ) ); size = ntohl( netOrder ); next += sizeof( u32 ); memcpy( &netOrder, next, sizeof( u32 ) ); mCPUCount = ntohl( netOrder ); next += sizeof( u32 ); mChildren = vector( ); mDeviceSpecific = vector( ); mIdNode = DataItem( next ); next += mIdNode.getPackedLength( ); if( next > packed + size ) { goto lderror; } mArch = DataItem( next ); next += mArch.getPackedLength( ); if( next > packed + size ) { goto lderror; } deviceTreeNode = DataItem( next ); next += deviceTreeNode.getPackedLength( ); if( next > packed + size ) { goto lderror; } mDescription = DataItem( next ); next += mDescription.getPackedLength( ); if( next > packed + size ) { goto lderror; } mBrand = DataItem( next ); next += mBrand.getPackedLength( ); if( next > packed + size ) { goto lderror; } mNodeName = DataItem( next ); next += mNodeName.getPackedLength( ); if( next > packed + size ) { goto lderror; } mOS = DataItem( next ); next += mOS.getPackedLength( ); if( next > packed + size ) { goto lderror; } mProcessorID = DataItem( next ); next += mProcessorID.getPackedLength( ); if( next > packed + size ) { goto lderror; } mMachineType = DataItem( next ); next += mMachineType.getPackedLength( ); if( next > packed + size ) { goto lderror; } mMachineModel = DataItem( next ); next += mMachineModel.getPackedLength( ); if( next > packed + size ) { goto lderror; } mFeatureCode = DataItem( next ); next += mFeatureCode.getPackedLength( ); if( next > packed + size ) { goto lderror; } mFlagField = DataItem( next ); next += mFlagField.getPackedLength( ); if( next > packed + size ) { goto lderror; } mRecordType = DataItem( next ); next += mRecordType.getPackedLength( ); if( next > packed + size ) { goto lderror; } mSerialNum1 = DataItem( next ); next += mSerialNum1.getPackedLength( ); if( next > packed + size ) { goto lderror; } mSerialNum2 = DataItem( next ); next += mSerialNum2.getPackedLength( ); if( next > packed + size ) { goto lderror; } mSUID = DataItem( next ); next += mSUID.getPackedLength( ); if( next > packed + size ) { goto lderror; } mKeywordVersion = DataItem( next ); next += mKeywordVersion.getPackedLength( ); if( next > packed + size ) { goto lderror; } mLocationCode = DataItem( next ); next += mLocationCode.getPackedLength( ); if( next > packed + size ) { goto lderror; } // Now onto the vectors, these should go much the same way that the packing // did. if( next == CHILD_START ) { next += CHILD_START.length( ) + 1; if( next > packed + size ) { goto lderror; } item = string( (char*)next ); while( CHILD_END != item ) { if( item != string( "" ) ) { string child = string( (char*)next ); mChildren.push_back( child ); next += item.length( ); } next++; item = string( (char*)next ); } next += CHILD_END.length( ) + 1; } if( DEVICE_START == next ) { next += DEVICE_START.length( ) + 1; if( next > packed + size ) { goto lderror; } item = string( (char*) next ); while( DEVICE_END != item ) { DataItem* d = new DataItem( next ); next += d->getPackedLength( ); if( next > packed + size ) { goto lderror; } mDeviceSpecific.push_back( d ); item = string( (char*)next ); } next += DEVICE_END.length( ) + 1; } if( USER_START == next ) { next += USER_START.length( ) + 1; if( next > packed + size ) { goto lderror; } item = string( (char*) next ); while( USER_END != item ) { DataItem* d = new DataItem( next ); next += d->getPackedLength( ); if( next > packed + size ) { goto lderror; } mDeviceSpecific.push_back( d ); item = string( (char*)next ); } } return; lderror: string message( "Component.unpack( ): Attempting to unpack corrupt buffer." ); Logger l; l.log( message, LOG_ERR ); VpdException ve( message ); throw ve; } void System::addDeviceSpecific( const string& ac, const string& humanName, const string& val, int lvl = 0 ) { DataItem *d = new DataItem( ); if( d == NULL ) { VpdException ve( "Out of memory." ); throw ve; } d->ac = ac; d->humanName = humanName; d->setValue( val, lvl, __FILE__, __LINE__ ); mDeviceSpecific.push_back( d ); } void System::addUserData( const string& ac, const string& humanName, const string& val, int prefLvl = 1, bool clobber = false ) { vector::iterator i, end; for( i = mUserData.begin( ), end = mUserData.end( ); i != end; ++i ) { if( (*i)->ac == ac ) { if( clobber ) { (*i)->dataValue = val; } return; } } DataItem *d = new DataItem( ); if( d == NULL ) { VpdException ve( "Out of memory." ); throw ve; } d->ac = ac; d->humanName = humanName; d->setValue( val, prefLvl, __FILE__, __LINE__ ); mUserData.push_back( d ); } /** * Adds this Component to the output stream in a meaningful way. */ /* ostream& operator<<( ostream& os, const System& in ) { os << "ID:" << endl << in.mIdNode; os << "Description:" << endl << in.mDescription; os << "Brand:" << endl << in.mBrand; os << "Node Name:" << endl << in.mNodeName; os << "OS:" << endl << in.mOS; os << "Processor ID:" << endl << in.mProcessorID; os << "Machine Type:" << endl << in.mMachineType; os << "Machine Model#:" << endl << in.mMachineModel; os << "Feature Code:" << endl << in.mFeatureCode; os << "Flag Field:" << endl << in.mFlagField; os << "Record Type:" << endl << in.mRecordType; os << "Serial Number 1:" << endl << in.mSerialNum1; os << "Serial Number 2:" << endl << in.mSerialNum2; os << "Unique ID:" << endl << in.mSUID; os << "Keyword Version:" << endl << in.mKeywordVersion; os << "Location Code:" << endl << in.mLocationCode; vector::const_iterator i, end; vector::const_iterator j, back; os << System::DEVICE_START << endl; for( i = in.mDeviceSpecific.begin( ), end = in.mDeviceSpecific.end( ); i != end; ++i ) { os << "Device Specific:" << endl << **i; } os << System::DEVICE_END << endl << System::CHILD_START << endl; for( j = in.mChildren.begin( ), back = in.mChildren.end( ); j != back; ++j ) { os << *j << endl; } os << System::CHILD_END << endl; return os; } */ /** * In-memory tree representation methods */ bool System::removeLeaf( int index ) { vector::iterator i = mLeaves.begin( ); if( index > mLeaves.size( ) ) { return false; } for( int j = 0; j < index; j++ ) { i++; } mLeaves.erase( i ); return true; } bool System::removeLeaf( const string& in ) { vector::iterator i = mLeaves.begin( ); for( ; i != mLeaves.end( ); ++i ) { if( (*i)->getID( ) == in ) { mLeaves.erase( i ); return true; } } return false; } void System::removeChild( const string& id ) { vector::iterator i, end; for( i = mChildren.begin( ), end = mChildren.end( ); i != end; ++i ) { if( id == *i ) { mChildren.erase(i); return; } } } } libvpd-2.2.3/src/vpdexception.cpp0000664000175000017500000000421512310042633017333 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include namespace lsvpd { VpdException::VpdException( ) { mMessage = string( ); } VpdException::VpdException( const exception& e ) { mMessage = string( e.what( ) ); } VpdException::VpdException( const string& in ) : mMessage( in ) { } VpdException::~VpdException( ) throw( ) { } const char* VpdException::what( ) const throw( ) { return mMessage.c_str( ); } void VpdException::setMessage( const string& in ) { mMessage = in; } } libvpd-2.2.3/src/helper_functions.cpp0000664000175000017500000002377612310042633020207 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #include #include #include #include #define BUF_SIZE 512 using namespace std; using namespace lsvpd; /** * findAIXFSEntry * @brief Finds AIX name which exists as a file or link in the dir * 'rootPath' */ string HelperFunctions::findAIXFSEntry(vector aixNames, const string& rootPath) { string fin; int fd; vector::const_iterator i, end; i = aixNames.begin(); end = aixNames.end(); while (i != end) { fin = rootPath + (*i)->getValue(); fd = open( fin.c_str( ), O_RDONLY | O_NONBLOCK ); if( fd < 0 ) i++; else { close(fd); return fin; } } return string(""); } /** * parseString * @brief Parses out strings based on a count of position [0...x], * with beginning and end of each string given by a '"'. * Ex: '"string 0" ... "string 1" ... "string 2" ... */ string HelperFunctions::parseString(const string& line, int str_pos, string& out) { int count = 0, pos = 0; int beg, len; do { beg = line.find('"', pos) + 1; pos = line.find('"', beg) + 1; len = pos - beg; count++; } while ((pos != string::npos) && (count < str_pos)); out = line.substr(beg, len - 1); return out; } /** * parsePathr * @brief Reverse parse of a path, returning the node specified by 'count' * @param count 0 is the tail node, 1 is 1 in, etc. * @example path = /sys/devices/x/y/z, * @ex count = 0, returns z * count = 1, returns y * count = 2, returns x */ string HelperFunctions::parsePathr(const string& path, int count) { int beg, end; int i = count; if( path == "" ) return path; beg = end = path.length(); if (path[end] == '/') beg--; cout << "String: " << path << endl; while (i >= 0) { end = beg - 1; cout << "RFind Bef: beg: " << beg << ", end: " << end << ", i: " << i << endl; beg = path.rfind("/", end - 1) + 1; cout << "RFind : beg: " << beg << ", end: " << end << ", i: " << i << endl; i--; } return path.substr(beg, end - beg); } /** * parsePath * @brief Parse of a path, returning the node specified by 'count' * @param count 0 is the first node, 1 is 1 in, etc. * @example path = /sys/devices/x/y/z, * @ex count = 0, returns sys * count = 1, returns devices * count = 2, returns x */ string HelperFunctions::parsePath(const string& path, int count) { int beg = 0, end, i = count; if( path == "" ) return path; if (path[end] == '/') end--; while (i >= 0) { beg = path.find("/", beg) + 1; i--; } end = path.find("/", beg); return path.substr(beg, end - beg); } /** * getSymLinkTarget * @brief Returns the absolute path pointed at by a sym link * @param full path of sym link * @return String abs target */ string HelperFunctions::getSymLinkTarget(const string& symLinkPath) { char linkTarget[BUF_SIZE], *buf; buf = strdup(symLinkPath.c_str()); int len = readlink(buf, linkTarget, sizeof( linkTarget)); linkTarget[len] = '\0'; return string(getAbsolutePath(linkTarget, buf)); } /* Drops one dir entry on the end of a path * @return Returns number of dirs successfully dropped*/ int HelperFunctions::dropDir(char * filePath) { int len = strlen(filePath); int i, ret = 0; if (len <= 0) return 0; /* erase filenames */ i = len; while (i > 0 && filePath[i] != '/') filePath[i--] = '\0'; filePath[len-1] = '\0'; //erase trailing '/' i = len; while (i > 0 && filePath[i] != '/') { filePath[i--] = '\0'; ret = 1; } return ret; } /* Drops one dir entry on the end of a path * @return Returns number of dirs successfully dropped*/ int HelperFunctions::dropDir(string& filePath_t) { int len = filePath_t.length(); int i, ret = 0; char *filePath; filePath = strdup(filePath_t.c_str()); if (len <= 0) { free(filePath); return 0; } /* erase filenames */ i = len; while (i > 0 && filePath[i] != '/') filePath[i--] = '\0'; filePath[len-1] = '\0'; //erase trailing '/' i = len; while (i > 0 && filePath[i] != '/') { filePath[i--] = '\0'; ret = 1; } filePath[i--] = '\0'; filePath_t = string(filePath); free(filePath); return ret; } /* @brief Drops dirs from curDir, 1 for each '../', then add remainder of filePath * to curDir */ string HelperFunctions::getAbsolutePath(char * relPath, char * curDir) { int len = strlen(relPath); int i = strlen(curDir); int lastHit; string tmp; if (len <= 0 || i <= 0) return string(); while (i > 0 && curDir[i] != '/') curDir[i--] = '\0'; i = 0; while (strncmp(&relPath[i * 3], "../", 3) == 0) { dropDir(curDir); lastHit = i; i++; } tmp = string(curDir) + string(&relPath[i * 3]); return tmp; } /** * Takes two strings and finds if the two are equivalent. * s1 can contain '*', meaning zero or more of anything can be * counted as a match */ bool HelperFunctions::matches(const string& s1, const string& s2) { int beg = 0, end = s1.length(); bool star = false; int z; // coutd << " s1 = " << s1 << ", s2 = " << s2 << endl; //strings have matched to end - base case if ((s1 == s2) || (s1.length() == 0) || (s2.length() == 0)) { return (s1 == s2); } //s1 has matched all the way up to a * - base case if (s1 == "*") { return true; } if (s1[0] == '*') { /* * Need to grab a substring of s2, up to size of s1 from * star to any other star */ beg = 1; end = s1.length(); if ( string::npos == (end = s1.find("*", beg))) { //No more stars - base case if (string::npos != (z = s2.find(s1.substr(beg, end), 0))) { return true; } } else { if (string::npos != s2.find(s1.substr(beg, end), 0)) matches(s1.substr(end, s1.length() - end), s2.substr(end, s2.length() - end)); } } else end = s1.find("*", 0); if (s1.substr(beg, end) == s2.substr(beg, end)) { return matches(s1.substr(end, s1.length() - end), s2.substr(end, s2.length() - end)); } else { return false; } } /* Caller responsible for deleting new'd memory */ void HelperFunctions::str2chr(char **str1, const string& str2) { int i; *str1 = new char[ str2.length( ) * sizeof( char ) ]; i=0; while (i < str2.length()) { (*str1)[i] = str2[i]; i++; } (*str1)[i] = '\0'; } /* @brief Ensure a passed in fs path arg is in reasonable format */ void HelperFunctions::fs_fixPath(string& str) { int i = str.length(); while (str[i] == '\0') i--; if (str[i] == '/') str[i] = '\0'; } /* @brief Ensure a passed in fs path arg is in reasonable format */ char *HelperFunctions::fs_fixPath(char *path_t) { char *path; char *chr; int i; path = strdup(path_t); /* Basic wierdness checking*/ chr = &path[strlen(path)]; while (chr != '\0') chr--; if (*chr == '/') *chr = '\0'; return path; } bool HelperFunctions::file_exists(const string& file) { FILE *f = fopen(file.c_str(), "r"); if (!f) return false; fclose(f); return true; } /** readMatchFromFile * @brief Returns first matching line from specified file, * in which was found a match to the specified string */ string HelperFunctions::readMatchFromFile(const string& file, const string& str) { char buf[BUF_SIZE]; string line; if (file_exists(file)) { ifstream fin(file.c_str()); while(!fin.eof()) { fin.getline(buf,BUF_SIZE - 1); line = string(buf); int loc = line.find(str); if (loc == 0) { return line; } } return string(""); } return string(""); } int HelperFunctions::countChar( const string& str, char c ) { string::const_iterator i, end; int ret = 0; for( i = str.begin( ), end = str.end( ); i != end; ++i ) { if( (*i) == c ) { ret++; } } return ret; } bool HelperFunctions::contains( const vector& vec, const string& val ) { vector::const_iterator i, end; for( i = vec.begin( ), end = vec.end( ); i != end; ++i ) { if( (*i)->getValue( ) == val ) return true; } return false; } int HelperFunctions::execCmd( const char *cmd, string& output ) { char buf[BUF_SIZE]; FILE *fp = popen(cmd, "r"); if (fp == NULL) return 1; while ( !feof(fp) ) if (fgets(buf, BUF_SIZE - 1, fp) != NULL) output += buf; pclose(fp); return 0; } libvpd-2.2.3/src/vpdretriever_c.c0000664000175000017500000000746112310042633017314 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include "libvpd-2/vpdretriever.h" static int build_component_sub( struct vpdretriever *dbenv, struct component *root ) { struct list *child; struct component *addme; char *id; child = root->childrenIDs; while( child ) { addme = get_component( dbenv, (char*)child->data ); if( !addme ) return 1; /* * Put this new component at the front of the child list because order * does not matter */ addme->next = root->children; root->children = addme; if( build_component_sub( dbenv, addme ) ) return 1; child = child->next; } return 0; } static int build_system_sub( struct vpdretriever *dbenv, struct system *root ) { struct list *child; struct component *addme; char *id; child = root->childrenIDs; while( child ) { addme = get_component( dbenv, (char*)child->data ); if( !addme ) return 1; /* * Put this new component at the front of the child list because order * does not matter */ addme->next = root->children; root->children = addme; if( build_component_sub( dbenv, addme ) ) return 1; child = child->next; } return 0; } struct vpdretriever * new_vpdretriever( const char* dir, const char *file ) { struct vpdretriever *ret = NULL; ret = malloc( sizeof( struct vpdretriever ) ); if( !ret ) return NULL; ret->dbenv = new_vpddbenv( dir, file ); if( !ret->dbenv ) { free( ret ); return NULL; } return ret; } void free_vpdretriever( struct vpdretriever *freeme ) { if( !freeme ) return; free_vpddbenv( freeme->dbenv ); free( freeme ); } struct system * get_component_tree( struct vpdretriever * dbenv ) { struct system *root; if( !dbenv ) return NULL; root = get_system( dbenv ); if( !root ) return NULL; if( build_system_sub( dbenv, root ) ) goto geterr; return root; geterr: free_system( root ); return NULL; } struct component * get_component( struct vpdretriever * dbenv, const char *id ) { if( !dbenv ) return NULL; return fetch_component( dbenv->dbenv, id ); } struct system * get_system( struct vpdretriever * dbenv ) { if( !dbenv ) return NULL; return fetch_system( dbenv->dbenv ); } libvpd-2.2.3/src/vpdretriever.cpp0000664000175000017500000001242012310042633017341 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include using namespace std; namespace lsvpd { const string VpdRetriever::DEFAULT_DIR ( "/var/lib/lsvpd/" ); const string VpdRetriever::DEFAULT_FILE ( "vpd.db" ); const string VpdRetriever::UDEV_NOTIFY_FILE ( "run.vpdupdate" ); VpdRetriever::VpdRetriever( string envDir, string dbFileName ) throw( VpdException& ) { db = new VpdDbEnv( envDir, dbFileName, true ); if( db == NULL ) { Logger logger; logger.log( "Out of memory, failed to build VpdEnv.", LOG_ERR ); VpdException ve( "Out of memory, failed to build VpdEnv." ); throw ve; } } VpdRetriever::VpdRetriever( ) throw( VpdException& ) { struct stat vpd_stat,udev_stat; const string vpddb = VpdRetriever::DEFAULT_DIR + VpdRetriever::DEFAULT_FILE; const string udev_file = VpdRetriever::DEFAULT_DIR + VpdRetriever::UDEV_NOTIFY_FILE; Logger logger; int flag = 1; /* Check if stat is successful for UDEV_NOTIFY_FILE. */ if ( stat ( udev_file.c_str(), &udev_stat ) != 0 ) { logger.log( "libvpd: Unable to stat udev rule file, run.vpdupdate.", LOG_INFO ); } else { /* Find the modification time for default DB. */ if ( stat ( vpddb.c_str(), &vpd_stat ) != 0 ) { logger.log( "libvpd: Unable to stat vpd.db file.", LOG_INFO ); if ( errno == ENOENT ) vpd_stat.st_mtime = 0; else flag = 0; } if ( flag && ( udev_stat.st_mtime > vpd_stat.st_mtime ) ) { /* * This implies there were changes to devices on the system * after the VPD db was created/modified. So * run vpdupdate. */ logger.log( "libvpd: Running vpdupdate to update the default db.", LOG_INFO ); system( "vpdupdate >/dev/null 2>&1" ); } } db = new VpdDbEnv( VpdRetriever::DEFAULT_DIR, VpdRetriever::DEFAULT_FILE, true ); if( db == NULL ) { Logger logger; logger.log( "Out of memory, failed to build VpdEnv.", LOG_ERR ); VpdException ve( "Out of memory, failed to build VpdEnv." ); throw ve; } } VpdRetriever::~VpdRetriever( ) { if( db != NULL ) { delete db; } } System* VpdRetriever::getComponentTree( ) { System *root = db->fetch( ); if (root) buildSubTree( root ); else { Logger logger; logger.log( "Failed to fetch VPD DB, it may be corrupt.", LOG_ERR ); VpdException ve( "Failed to fetch VPD DB, it may be corrupt." ); throw ve; } return root; } void VpdRetriever::buildSubTree( System* root ) { Component* leaf; const vector children = root->getChildren( ); vector::const_iterator i, end; end = children.end( ); for( i = children.begin( ); i != end; ++i ) { const string next = *i; leaf = db->fetch( next ); if( leaf == NULL ) { Logger logger; logger.log( "Failed to fetch requested item.", LOG_ERR ); VpdException ve( "Failed to fetch requested item." ); throw ve; } buildSubTree( leaf ); root->addLeaf( leaf ); } } void VpdRetriever::buildSubTree( Component* root ) { Component* leaf; const vector children = root->getChildren( ); vector::const_iterator i, end; end = children.end( ); for( i = children.begin( ); i != end; ++i ) { const string next = *i; leaf = db->fetch( next ); if( leaf == NULL ) { Logger logger; logger.log( "Failed to fetch requested item.", LOG_ERR ); VpdException ve( "Failed to fetch requested item." ); throw ve; } buildSubTree( leaf ); root->addLeaf( leaf ); } } } libvpd-2.2.3/src/dataitem.cpp0000664000175000017500000001647612310042633016427 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #define TRACE_ON #ifdef HAVE_CONFIG_H #include #endif #include #include #include // for memcpy #include // for isspace using namespace std; namespace lsvpd { DataItem::DataItem( const DataItem& copyMe ) : humanName( copyMe.humanName ), ac( copyMe.ac ), dataValue( copyMe.dataValue ), prefLevelUsed(copyMe.prefLevelUsed), packedLength( 0 ) {} DataItem::DataItem( ) : packedLength( 0 ), dataValue( "" ) { prefLevelUsed = 0; } DataItem::~DataItem( ) { vector::iterator i, end; for( i = sources.begin( ), end = sources.end( ); i != end; ++i ) { Source* s = *i; delete s; } } int DataItem::getNumSources() const { return sources.size(); } Source * DataItem::getSource(int i) const { if (i < getNumSources() || i == 0) { return sources[i]; } else { return NULL; } } void DataItem::addSource(Source *in) { vector::iterator i, end; for( i = sources.begin( ), end = sources.end( ); i != end; ++i ) { if( (*i)->getPrefLvl( ) < in->getPrefLvl( ) ) { sources.insert( i, in ); return; } } sources.push_back( in ); } void DataItem::removeSource(int i) { vector::iterator cur, end; int j = 0; for( cur = sources.begin( ), end = sources.end( ); cur != end; ++cur, j++ ) { if( j == i ) { Source * s = *cur; sources.erase( cur ); delete s; return; } } } const string& DataItem::getHumanName( ) const { return humanName; } void DataItem::setHumanName( const string& in ) { humanName = in; packedLength = 0; } const string& DataItem::getAC( ) const { return ac; } void DataItem::setAC( const string& in ) { ac = in; packedLength = 0; } const string& DataItem::getValue() const { return dataValue; } int DataItem::setValue( const string& in, int prefLevelUsed_t, const char *file, int lineNum) { int i; if ((prefLevelUsed_t > prefLevelUsed) && (!in.empty())) { string val( in ); // Get rid of any NULL bytes, new lines or carriage returns i = 0; int pos; while( ( pos = val.find( '\0' ) ) != string::npos || ( pos = val.find( '\n' ) ) != string::npos || ( pos = val.find( '\r' ) ) != string::npos ) { val.erase( pos, 1 ); } // Get rid of leading and trailing whitespace for( i = 0; i < val.length( ) && isspace( val.at( i ) ); i++ ) val.erase( i, 1 ); for( i = val.length( ) - 1; i >= 0 && isspace( val.at( i ) ); i-- ) val.erase( i, 1 ); /* if (ac == "AX") { coutd << "Attempting to set [" << ac << "]: " << endl << "Request src: " << file<< ", line " << lineNum << endl <<" Old PrefLevel: " << prefLevelUsed << endl <<" New PrefLevel: " << prefLevelUsed_t << endl << " Old dataVal: " << dataValue << endl <<" Attempting to set to dataVal to: '" << in << "'" << endl << endl; coutd << "DataVal Set! New Val: '" << val << "'" << endl; } */ /* if (humanName == "Device Bus") { coutd << "Attempting to set [" << ac << "]: " << endl << "Request src: " << file<< ", line " << lineNum << endl <<" Old PrefLevel: " << prefLevelUsed << endl <<" New PrefLevel: " << prefLevelUsed_t << endl << " Old dataVal: " << dataValue << endl <<" Attempting to set to dataVal to: '" << in << "'" << endl << endl; coutd << "DataVal Set! New Val: '" << val << "'" << endl; } */ dataValue = val; packedLength = 0; prefLevelUsed = prefLevelUsed_t; return 0; } else return -1; } int DataItem::getPrefLevel() { return prefLevelUsed; } /** * Method reports the number of bytes that would be required to "serialize" (in the Java * sense of the word) this object into a character buffer. The result of the computation * is stored to make multiple calls to this method move a little faster. Each time an item * is changed with a set method, the packedLength member is invalidated, forcing the method * to sum the length again. */ int DataItem::getPackedLength( ) { if( packedLength != 0 ) return packedLength; int ret = 3; // 3 bytes is the smallest a packed DataItem can be. ret += ac.length( ); ret += humanName.length( ); ret += dataValue.length( ); packedLength = ret; return ret; } /** * Like the pack method from Component, this method takes the contents * of this DataItem and packs them into the data buffer provided. It will return * the number of bytes packed into that buffer. Each field is followed by a '\0' * character to make unpacking easier. */ int DataItem::pack( void* buf ) { char * buffer = (char*)buf; int tmp; int ret = getPackedLength( ); memcpy( buffer, ac.c_str( ), ac.length( ) ); buffer += ac.length( ); *buffer = '\0'; buffer++; memcpy( buffer, humanName.c_str( ), humanName.length( ) ); buffer += humanName.length( ); *buffer = '\0'; buffer++; memcpy( buffer, dataValue.c_str( ), dataValue.length( ) ); buffer += dataValue.length( ); *buffer = '\0'; buffer++; return ret; } /** * Also like the like-named method within Component, this method loads this * DataItem object from the provided data buffer. */ void DataItem::unpack( const void * data ) { char * buf = (char*) data; ac = buf; buf += ( ac.length( ) + 1 ); humanName = buf; buf += ( humanName.length( ) + 1 ); dataValue = buf; int pos; } /* * Prints this DataItem to the ostream in a meaningful way. */ /* ostream& operator<<( ostream& os, const DataItem& in ) { os << " Human Name: " << in.getHumanName() << endl; os << " Acronym: " << in.getAC() << endl; os << " Value: " << in.getValue() << endl; return os; } */ } libvpd-2.2.3/src/vpddbenv_c.c0000664000175000017500000001062512310042633016377 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #define DATA_BUFFER_SIZE 12288 struct vpddbenv * new_vpddbenv( const char *dir, const char *file ) { struct vpddbenv *ret = NULL; int rc = 0; ret = malloc( sizeof( struct vpddbenv ) ); if( !ret ) return ret; memset( ret, 0, sizeof( struct vpddbenv ) ); if( dir == NULL || strncmp( dir, "", MAX_NAME_LENGTH ) == 0 ) strcpy( ret->envDir, DEFAULT_ENV ); else strncpy( ret->envDir, dir, MAX_NAME_LENGTH ); if( file == NULL || strncmp( file, "", MAX_NAME_LENGTH ) == 0 ) strcpy( ret->dbFileName, DEFAULT_DB ); else strncpy( ret->dbFileName, file, MAX_NAME_LENGTH ); strcpy( ret->fullPath, ret->envDir ); strcat( ret->fullPath, "/" ); strcat( ret->fullPath, ret->dbFileName ); rc = sqlite3_open( ret->fullPath, &(ret->db) ); if( rc != SQLITE_OK ) goto newerr; return ret; newerr: fprintf( stderr, "sqlite db error '%s'\n", sqlite3_errmsg( ret->db ) ); free_vpddbenv( ret ); return NULL; } void free_vpddbenv( struct vpddbenv *freeme ) { if( !freeme ) return; if( freeme->db ) sqlite3_close( freeme->db ); free( freeme ); } struct component* fetch_component( struct vpddbenv *db, const char *deviceID ) { struct component* ret = NULL; sqlite3_stmt *pstmt = NULL; int rc; const char *out; char sql[ QUERY_BUF_LENGTH ]; memset( sql, 0, QUERY_BUF_LENGTH ); snprintf( sql, QUERY_BUF_LENGTH, "SELECT %s FROM %s WHERE %s='%s';", DATA, TABLE_NAME, ID, deviceID ); rc = SQLITE3_PREPARE( db->db, sql, strlen( sql ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) goto FETCH_COMP_ERR; rc = sqlite3_step( pstmt ); if( rc != SQLITE_ROW && rc != SQLITE_DONE ) goto FETCH_COMP_ERR; if( rc == SQLITE_ROW ) { ret = unpack_component( (void *) sqlite3_column_blob( pstmt, 0 ) ); } sqlite3_finalize( pstmt ); return ret; FETCH_COMP_ERR: fprintf( stderr, "Error fetching '%s': %s\n", deviceID, sqlite3_errmsg( db->db ) ); if( pstmt ) sqlite3_finalize( pstmt ); return ret; } struct system* fetch_system( struct vpddbenv *db ) { struct system* ret = NULL; sqlite3_stmt *pstmt = NULL; int rc; const char *out; char sql[ QUERY_BUF_LENGTH ]; memset( sql, 0, QUERY_BUF_LENGTH ); sprintf( sql, "SELECT %s FROM %s WHERE %s='%s';", DATA, TABLE_NAME, ID, SYS_ID ); rc = SQLITE3_PREPARE( db->db, sql, strlen( sql ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) goto FETCH_SYS_ERR; rc = sqlite3_step( pstmt ); if( rc != SQLITE_ROW && rc != SQLITE_DONE ) goto FETCH_SYS_ERR; if( rc == SQLITE_ROW ) { ret = unpack_system( sqlite3_column_blob( pstmt, 0 ) ); } sqlite3_finalize( pstmt ); return ret; FETCH_SYS_ERR: fprintf( stderr, "Error fetching '%s': %s\n", SYS_ID, sqlite3_errmsg( db->db ) ); if( pstmt ) sqlite3_finalize( pstmt ); return ret; } libvpd-2.2.3/src/vpddbenv.cpp0000664000175000017500000002236412310042633016440 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #include #include #include #include #include using namespace::std; namespace lsvpd { const string VpdDbEnv::TABLE_NAME ( "components" ); const string VpdDbEnv::ID ( "comp_id" ); const string VpdDbEnv::DATA ( "comp_data" ); /* * The copy constructor is marked private but these things need to be * filled out to compile correctly. */ VpdDbEnv::VpdDbEnv( const VpdDbEnv& copyMe ): mDbFileName( copyMe.mDbFileName ), mEnvDir( copyMe.mEnvDir ), mpVpdDb( NULL ) { } VpdDbEnv::VpdDbEnv( const string& envDir, const string& dbFileName, bool readOnly = false ) : mDbFileName( dbFileName ), mEnvDir( envDir ), mpVpdDb( NULL ) { int rc; Logger l; ostringstream message; struct stat st; bool dbExists; mDbPath = mEnvDir + "/" + mDbFileName; dbExists = ( stat( mDbPath.c_str( ), &st ) ) == 0; if( readOnly && !dbExists ) { message << "DB requested for reading does not exist." << endl; goto CON_ERR; } rc = sqlite3_open( mDbPath.c_str( ), &mpVpdDb ); if( rc != SQLITE_OK ) { message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; goto CON_ERR; } if( !dbExists ) { sqlite3_stmt *pstmt; const char *out; ostringstream sql; sql << "CREATE TABLE " << TABLE_NAME << " ( " << ID << " TEXT NOT NULL UNIQUE, " << DATA << " BLOB NOT NULL );"; string stmt = sql.str( ); rc = SQLITE3_PREPARE( mpVpdDb, stmt.c_str( ), stmt.length( ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) { message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; goto CON_ERR; } rc = sqlite3_step( pstmt ); if( rc != SQLITE_DONE ) { message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; goto CON_ERR; } sqlite3_finalize( pstmt ); } return; CON_ERR: l.log( message.str( ), LOG_ERR ); VpdException ve( message.str( ) ); if( mpVpdDb != NULL ) sqlite3_close( mpVpdDb ); throw ve; } VpdDbEnv::~VpdDbEnv() { int rc; rc = sqlite3_close( mpVpdDb ); if( rc != SQLITE_OK ) { Logger l; ostringstream message; message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; l.log( message.str( ), LOG_ERR ); VpdException ve( message.str( ) ); throw ve; } } Component* VpdDbEnv::fetch( const string& deviceID ) { Component* ret = NULL; sqlite3_stmt *pstmt = NULL; int rc; const char *out; string sql = "SELECT " + DATA + " FROM " + TABLE_NAME + " WHERE " + ID + "='" + deviceID + "';"; rc = SQLITE3_PREPARE( mpVpdDb, sql.c_str( ), sql.length( ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) goto FETCH_COMP_ERR; rc = sqlite3_step( pstmt ); if( rc != SQLITE_ROW && rc != SQLITE_DONE ) goto FETCH_COMP_ERR; if( rc == SQLITE_ROW ) ret = new Component( sqlite3_column_blob( pstmt, 0 ) ); sqlite3_finalize( pstmt ); return ret; FETCH_COMP_ERR: Logger l; ostringstream message; message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; l.log( message.str( ), LOG_ERR ); if( pstmt ) sqlite3_finalize( pstmt ); return ret; } /* * Fetches the system root (the base of the component tree that * stores all the system-wide vpd. */ System* VpdDbEnv::fetch( ) { System* ret = NULL; sqlite3_stmt *pstmt = NULL; int rc; const char *out; string sql = "SELECT " + DATA + " FROM " + TABLE_NAME + " WHERE " + ID + "='" + System::ID + "';"; rc = SQLITE3_PREPARE( mpVpdDb, sql.c_str( ), sql.length( ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) goto FETCH_SYS_ERR; rc = sqlite3_step( pstmt ); if( rc != SQLITE_ROW && rc != SQLITE_DONE ) goto FETCH_SYS_ERR; if( rc == SQLITE_ROW ) ret = new System( sqlite3_column_blob( pstmt, 0 ) ); sqlite3_finalize( pstmt ); return ret; FETCH_SYS_ERR: Logger l; ostringstream message; message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; l.log( message.str( ), LOG_ERR ); if( pstmt ) sqlite3_finalize( pstmt ); return ret; } bool VpdDbEnv::store( Component *storeMe ) { void * buffer = NULL; unsigned int dataSize; int rc; const char *out; sqlite3_stmt *pstmt = NULL; string sql = "INSERT INTO " + TABLE_NAME + " (" + ID + ", " + DATA + ") VALUES ('" + storeMe->getID( ) + "', ?);"; rc = SQLITE3_PREPARE( mpVpdDb, sql.c_str( ), sql.length( ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) goto STORE_COMP_ERR; dataSize = storeMe->pack( &buffer ); rc = sqlite3_bind_blob( pstmt, 1, buffer, dataSize, SQLITE_TRANSIENT ); if( rc != SQLITE_OK ) goto STORE_COMP_ERR; rc = sqlite3_step( pstmt ); if( rc != SQLITE_DONE ) goto STORE_COMP_ERR; if( buffer != NULL ) delete [] (char*)buffer; sqlite3_finalize( pstmt ); return true; STORE_COMP_ERR: if( buffer != NULL ) delete [] (char*)buffer; Logger l; ostringstream message; message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; l.log( message.str( ), LOG_ERR ); sqlite3_finalize( pstmt ); return false; } bool VpdDbEnv::store( System *storeMe ) { void * buffer = NULL; unsigned int dataSize; int rc; const char *out; sqlite3_stmt *pstmt = NULL; string sql = "INSERT INTO " + TABLE_NAME + " (" + ID + ", " + DATA + ") VALUES ('" + storeMe->getID( ) + "', ?);"; rc = SQLITE3_PREPARE( mpVpdDb, sql.c_str( ), sql.length( ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) goto STORE_SYS_ERR; dataSize = storeMe->pack( &buffer ); rc = sqlite3_bind_blob( pstmt, 1, buffer, dataSize, SQLITE_TRANSIENT ); if( rc != SQLITE_OK ) goto STORE_SYS_ERR; rc = sqlite3_step( pstmt ); if( rc != SQLITE_DONE ) goto STORE_SYS_ERR; if( buffer != NULL ) delete [] (char*)buffer; sqlite3_finalize( pstmt ); return true; STORE_SYS_ERR: if( buffer != NULL ) delete [] (char*)buffer; Logger l; ostringstream message; message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; l.log( message.str( ), LOG_ERR ); sqlite3_finalize( pstmt ); return false; } bool VpdDbEnv::remove( const string& deviceID ) { int rc; const char *out; sqlite3_stmt *pstmt = NULL; string sql = "DELETE FROM " + TABLE_NAME + " WHERE " + ID + "='" + deviceID + "';"; rc = SQLITE3_PREPARE( mpVpdDb, sql.c_str( ), sql.length( ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) goto REMOVE_ERR; rc = sqlite3_step( pstmt ); if( rc != SQLITE_DONE ) goto REMOVE_ERR; sqlite3_finalize( pstmt ); return true; REMOVE_ERR: Logger l; ostringstream message; message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; l.log( message.str( ), LOG_ERR ); sqlite3_finalize( pstmt ); return false; } vector VpdDbEnv::getKeys( ) { vector ret; sqlite3_stmt *pstmt = NULL; int rc; const char *out; string sql = "SELECT " + ID + " FROM " + TABLE_NAME + ";"; rc = SQLITE3_PREPARE( mpVpdDb, sql.c_str( ), sql.length( ) + 1, &pstmt, &out ); if( rc != SQLITE_OK ) { Logger l; ostringstream message; message << "SQLITE Error " << rc << ": " << sqlite3_errmsg( mpVpdDb ) << endl; l.log( message.str( ), LOG_ERR ); return ret; } rc = sqlite3_step( pstmt ); while( rc == SQLITE_ROW ) { const char *row = (const char*)sqlite3_column_text( pstmt, 0 ); if( row ) ret.push_back( string( row ) ); rc = sqlite3_step( pstmt ); } sqlite3_finalize( pstmt ); return ret; } } libvpd-2.2.3/src/dataitem_c.c0000664000175000017500000000622412310042633016357 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * ebmunson@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "libvpd-2/dataitem.h" #include #include #include struct dataitem* new_dataitem( ) { struct dataitem *ret = NULL; ret = malloc( sizeof( struct dataitem ) ); if( !ret ) return ret; memset( ret, 0, sizeof( struct dataitem ) ); return ret; } void free_dataitem( struct dataitem *freeme ) { struct dataitem *next = NULL; struct dataitem *this = NULL; if( !freeme ) return; if( freeme->humanName ) free( freeme->humanName ); if( freeme->ac ) free( freeme->ac ); if( freeme->dataValue ) free( freeme->dataValue ); this = freeme->next; while( this ) { next = this->next; free_dataitem( this ); this = next; } free( freeme ); } int calc_packed_length_dataitem( struct dataitem *packme ) { int ret = 3; if( !packme ) return 0; if( packme->ac ) ret += strlen( packme->ac ); if( packme->dataValue ) ret += strlen( packme->dataValue ); if( packme->humanName ) ret += strlen( packme->humanName ); return ret; } struct dataitem * unpack_dataitem( void *buffer ) { char *buf = (char*)buffer; struct dataitem *ret = NULL; ret = new_dataitem( ); if( !ret ) return ret; ret->ac = strdup( buf ); buf += strlen( ret->ac ) + 1; ret->humanName = strdup( buf ); buf += strlen( ret->humanName ) + 1; ret->dataValue = strdup( buf ); return ret; } void add_dataitem( struct dataitem *head, const struct dataitem *addme ) { if( !head || !addme ) return; while( head->next ) head = head->next; head->next = addme; } libvpd-2.2.3/src/Source.cpp0000664000175000017500000000414612310042633016066 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ using namespace std; #include #include // For memcpy namespace lsvpd { ostream& operator<<( ostream& os, const Source& in ) { os << "Source:" << in.srcRef << endl; os << "Data: " << in.data << endl; os << "ID: "<< in.id << endl; os << "Source Type: "<< in.type << endl; os << "Source Lines: " << in.lines << endl; os << "Source Preference Level: " << in.preferenceLevel << endl; return os; } } libvpd-2.2.3/src/component.cpp0000664000175000017500000006515112310042633016633 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #include #include #include #include #include #include namespace lsvpd { string const Component::CHILD_START ( "::childrenStart::" ); string const Component::CHILD_END ( "::childrenEnd::" ); string const Component::DEVICE_START ( "::deviceSpecificStart::" ); string const Component::DEVICE_END ( "::deviceSpecificEnd::" ); string const Component::USER_START ( "::userStart::" ); string const Component::USER_END ( "::userEnd::" ); string const Component::AX_START ( "::axStart::" ); string const Component::AX_END ( "::axEnd::" ); Component::Component() { idNode.ac = "None"; idNode.humanName = "Main Device Node, equals sysFsNode or deviceTreeNode"; deviceTreeNode.ac = "None"; deviceTreeNode.humanName = "/proc/device-tree Device Node"; sysFsNode.ac = "None"; sysFsNode.humanName = "/sys Device Node"; sysFsLinkTarget.ac = "None"; sysFsLinkTarget.humanName = "/sys/bus Device Node"; mDevClass.ac = "None"; mDevClass.humanName = "/sys/class - Device Node"; mFRU.ac = "FN"; mFRU.humanName = "Field Replaceable Unit Number"; mParent.ac = "Parent Node"; mParent.humanName = "Parent Node"; devSysName.humanName = "Device name from sysFS"; devDevTreeName = "Device name from /proc/device-tree"; scsiDetail.ac = "ZZ"; scsiDetail.humanName = "Device Details"; plantMfg.ac = "SE"; plantMfg.humanName = "Plant of manufacture"; mNetAddr.ac = "NA"; mNetAddr.humanName = "Network Address"; mDescription.ac = "DS"; mDescription.humanName = "Displayable Message"; mCDField.ac = "CD"; mCDField.humanName = "Card ID"; mSerialNumber.ac = "SN"; mSerialNumber.humanName = "Serial Number"; mPartNumber.ac = "PN"; mPartNumber.humanName = "Part Number of assembly"; // For RL: Special rule applies. if devBus == "disk", is must be stored // as Hex. See device_scsi_append_field() in lsvpd-0.16 mFirmwareLevel.ac = "RL"; mFirmwareLevel.humanName = "Non-alterable ROM level"; mFirmwareVersion.ac = "RM"; mFirmwareVersion.humanName = "Alterable ROM Level"; mManufacturer.ac = "MF"; mManufacturer.humanName = "Manufacturer Name"; mModel.ac = "TM"; mModel.humanName = "Machine Type-Model"; mManufacturerID.ac = "MN"; mManufacturerID.humanName = "Manufacturer ID"; mEngChangeLevel.ac = "EC"; mEngChangeLevel.humanName = "Engineering Change Level"; mFeatureCode.ac = "FC"; mFeatureCode.humanName = "Feature Code or Request for Price Quotation (RPQ) number"; devDriver.ac = "DD"; devDriver.humanName = "Device Driver Level"; mRecordType.ac = "RT"; mRecordType.humanName = "Record Type"; mKeywordVersion.ac = "VK"; mKeywordVersion.humanName = "Keyword Version"; mMicroCodeImage.ac = "MI"; mMicroCodeImage.humanName = "Micro Code Image"; mPhysicalLocation.ac = "YL"; mPhysicalLocation.humanName = "Location Code"; mSecondLocation.ac = "YL"; mSecondLocation.humanName = "Location Code"; n5.ac = "N5"; n5.humanName = "Processor CoD Capacity Card Info"; n6.ac = "N6"; n6.humanName = "Memory CoD Capacity Card Info"; devState = COMPONENT_STATE_LIVE; devBus.humanName = "Device Bus"; mpParent = NULL; mDeviceSpecific = vector( ); mUserData = vector( ); mAIXNames = vector( ); mChildren = vector( ); mLeaves = vector( ); } Component::Component( const Component& copyMe ) { copyToMe( copyMe ); } Component::Component( const void* packedData ) { unpack( packedData ); mLeaves = vector( ); } Component::~Component( ) { vector::iterator i, end = mLeaves.end( ); for( i = mLeaves.begin( ); i != end; ++i ) { delete (*i); } vector::iterator j, dEnd; for( j = mDeviceSpecific.begin( ), dEnd = mDeviceSpecific.end( ); j != dEnd; ++j ) { delete (*j); } for( j = mUserData.begin( ), dEnd = mUserData.end( ); j != dEnd; ++j ) { delete (*j); } for( j = mAIXNames.begin( ), dEnd = mAIXNames.end( ); j != dEnd; ++j ) { delete (*j); } } Component& Component::operator=( const Component& rhs ) { copyToMe( rhs ); return (*this); } unsigned int Component::getPackedSize( ) { unsigned int ret = INIT_BUF_SIZE; ret += idNode.getPackedLength( ); ret += deviceTreeNode.getPackedLength( ); ret += sysFsNode.getPackedLength( ); ret += sysFsLinkTarget.getPackedLength( ); ret += halUDI.getPackedLength( ); ret += mNetAddr.getPackedLength( ); ret += mDevClass.getPackedLength( ); ret += mDescription.getPackedLength( ); ret += mCDField.getPackedLength( ); ret += mSerialNumber.getPackedLength( ); ret += mPartNumber.getPackedLength( ); ret += mFirmwareLevel.getPackedLength( ); ret += mFirmwareVersion.getPackedLength( ); ret += mFRU.getPackedLength( ); ret += mManufacturer.getPackedLength( ); ret += mModel.getPackedLength( ); ret += mManufacturerID.getPackedLength( ); ret += mEngChangeLevel.getPackedLength( ); ret += mParent.getPackedLength( ); ret += devSubsystem.getPackedLength( ); ret += devDriver.getPackedLength( ); ret += devKernel.getPackedLength( ); ret += devKernelNumber.getPackedLength( ); ret += devSysName.getPackedLength( ); ret += devDevTreeName.getPackedLength( ); ret += devBus.getPackedLength( ); ret += devBusAddr.getPackedLength( ); ret += mRecordType.getPackedLength( ); ret += scsiDetail.getPackedLength( ); ret += plantMfg.getPackedLength( ); ret += mFeatureCode.getPackedLength( ); ret += mKeywordVersion.getPackedLength( ); ret += mMicroCodeImage.getPackedLength( ); ret += mSecondLocation.getPackedLength( ); ret += n5.getPackedLength( ); ret += n6.getPackedLength( ); /* Must be last single item packed */ ret += mPhysicalLocation.getPackedLength( ); ret += mDeviceSpecific.size( ); ret += mUserData.size( ); ret += mChildren.size( ); ret += mAIXNames.size( ); vector::iterator child, cEnd; vector::iterator item, dEnd; for( child = mChildren.begin( ), cEnd = mChildren.end( ); child != cEnd; ++child ) { ret += (*child).length( ); } for( item = mDeviceSpecific.begin( ), dEnd = mDeviceSpecific.end( ); item != dEnd; ++item ) { ret += (*item)->getPackedLength( ); } for( item = mUserData.begin( ), dEnd = mUserData.end( ); item != dEnd; ++item ) { ret += (*item)->getPackedLength( ); } for( item = mAIXNames.begin( ), dEnd = mAIXNames.end( ); item != dEnd; ++item ) { ret += (*item)->getPackedLength( ); } ret += sizeof( u32 ); return ret; } /** * pack serializes this object into the provided buffer (pack will * allocate the buffer) storing only the data fields (at the moment) * and ignoring all the meta-data within the DataItem object. * The format for the packed object will be direct strings seperated * by '\0' charaters. If a given string field is empty then there will * be consectutive '\0' characters. Each of the vector fields will be * preceeded by ::listNameStart:: and followed by ::listNameEnd:: * (e.g. the children vector will be * ::childrenStart::\0data\0data\0::childrenEnd::\0). */ unsigned int Component::pack( void** buffer ) { u32 ret = getPackedSize( ), length; char* buf; buf = new char[ ret ]; if( buf == NULL ) { string message( "Component.pack( ): new call failed, out of memory." ); Logger l; l.log( message, LOG_ERR ); VpdException ve( message ); throw ve; } memset( buf, '\0', ret ); *buffer = (void*)buf; /* -----------------------------------------------------*/ /* ------------ Load up the buffer with data -----------*/ /* -----------------------------------------------------*/ // The first entry in our buffer is our length in network byte order u32 netOrder = htonl( ret ); memcpy( buf, &netOrder, sizeof( u32 ) ); buf += sizeof( u32 ); // Pack the individual data items. buf += idNode.pack( buf ); buf += deviceTreeNode.pack( buf ); buf += sysFsNode.pack( buf ); buf += sysFsLinkTarget.pack( buf ); buf += halUDI.pack( buf ); buf += mNetAddr.pack( buf ); buf += mDevClass.pack( buf ); buf += mDescription.pack( buf ); buf += mCDField.pack( buf ); buf += mSerialNumber.pack( buf ); buf += mPartNumber.pack( buf ); buf += mFirmwareLevel.pack( buf ); buf += mFirmwareVersion.pack( buf ); buf += mFRU.pack( buf ); buf += mManufacturer.pack( buf ); buf += mModel.pack( buf ); buf += mManufacturerID.pack( buf ); buf += mEngChangeLevel.pack( buf ); buf += mParent.pack( buf ); buf += devSubsystem.pack( buf ); buf += devDriver.pack( buf ); buf += devKernel.pack( buf ); buf += devKernelNumber.pack( buf ); buf += devSysName.pack( buf ); buf += devDevTreeName.pack( buf ); buf += devBus.pack( buf ); buf += devBusAddr.pack( buf ); buf += mRecordType.pack( buf ); buf += scsiDetail.pack( buf ); buf += n5.pack( buf ); buf += n6.pack( buf ); // Added - SCSI fill buf += plantMfg.pack( buf ); buf += mFeatureCode.pack( buf ); buf += mKeywordVersion.pack( buf ); buf += mMicroCodeImage.pack( buf ); buf += mSecondLocation.pack( buf ); // Must be last single item to be packed buf += mPhysicalLocation.pack( buf ); // Pack the child vector. memcpy( buf, CHILD_START.c_str( ), CHILD_START.length( ) ); buf += CHILD_START.length( ); *buf = '\0'; buf++; vector::iterator child, cEnd; vector::iterator item, dEnd; for( child = mChildren.begin( ), cEnd = mChildren.end( ); child != cEnd; ++child ) { const char* str = (*child).c_str( ); int length = (*child).length( ); memcpy( buf, str, length ); buf+= length; *buf = '\0'; buf++; } memcpy( buf, CHILD_END.c_str( ), CHILD_END.length( ) ); buf += CHILD_END.length( ); *buf = '\0'; buf++; memcpy( buf, DEVICE_START.c_str( ), DEVICE_START.length( ) ); buf += DEVICE_START.length( ); *buf = '\0'; buf++; for( item = mDeviceSpecific.begin( ), dEnd = mDeviceSpecific.end( ); item != dEnd; ++item ) { length = (*item)->pack( buf ); buf+= length; } memcpy( buf, DEVICE_END.c_str( ), DEVICE_END.length( ) ); buf += DEVICE_END.length( ); *buf = '\0'; buf++; memcpy( buf, USER_START.c_str( ), USER_START.length( ) ); buf += USER_START.length( ); *buf = '\0'; buf++; for( item = mUserData.begin( ), dEnd = mUserData.end( ); item != dEnd; ++item ) { length = (*item)->pack( buf ); buf+= length; } memcpy( buf, USER_END.c_str( ), USER_END.length( ) ); buf += USER_END.length( ); *buf = '\0'; buf++; memcpy( buf, AX_START.c_str( ), AX_START.length( ) ); buf += AX_START.length( ); *buf = '\0'; buf++; for( item = mAIXNames.begin( ), dEnd = mAIXNames.end( ); item != dEnd; ++item ) { length = (*item)->pack( buf ); buf+= length; } memcpy( buf, AX_END.c_str( ), AX_END.length( ) ); buf += AX_END.length( ); *buf = '\0'; return ret; } /** * unpack does exactly the opposite from pack, it will take a data buffer * and load this object with the contents. If we need more data than the * size claims that we have, then we have a corrupt buffer and we will * throw an exception. */ void Component::unpack( const void* payload ) { u32 size = 0, netOrder; char* packed = (char*) payload; char* next; string item; if( payload == NULL ) { /* Rather than throwing an exception, this will just return, if NULL is handed in this far there is nothing that we can do to stop program instability other than refuse to mess with it. */ return; } // Load the size of the payload. (It is packed in network order) memcpy( &netOrder, payload, sizeof( u32 ) ); size = ntohl( netOrder ); next = packed + sizeof( u32 ); mChildren = vector( ); mDeviceSpecific = vector( ); idNode = DataItem( next ); next += idNode.getPackedLength( ); if( next > packed + size ) { goto lderr; } deviceTreeNode = DataItem( next ); next += deviceTreeNode.getPackedLength( ); if( next > packed + size ) { goto lderr; } sysFsNode = DataItem( next ); next += sysFsNode.getPackedLength( ); if( next > packed + size ) { goto lderr; } sysFsLinkTarget = DataItem( next ); next += sysFsLinkTarget.getPackedLength( ); if( next > packed + size ) { goto lderr; } halUDI = DataItem( next ); next += halUDI.getPackedLength( ); if( next > packed + size ) { goto lderr; } mNetAddr = DataItem( next ); next += mNetAddr.getPackedLength( ); if( next > packed + size ) { goto lderr; } mDevClass = DataItem( next ); next += mDevClass.getPackedLength( ); if( next > packed + size ) { goto lderr; } mDescription = DataItem( next ); next += mDescription.getPackedLength( ); if( next > packed + size ) { goto lderr; } mCDField = DataItem( next ); next += mCDField.getPackedLength( ); if( next > packed + size ) { goto lderr; } mSerialNumber = DataItem( next ); next += mSerialNumber.getPackedLength( ); if( next > packed + size ) { goto lderr; } mPartNumber = DataItem( next ); next += mPartNumber.getPackedLength( ); if( next > packed + size ) { goto lderr; } mFirmwareLevel = DataItem( next ); next += mFirmwareLevel.getPackedLength( ); if( next > packed + size ) { goto lderr; } mFirmwareVersion = DataItem( next ); next += mFirmwareVersion.getPackedLength( ); if( next > packed + size ) { goto lderr; } mFRU = DataItem( next ); next += mFRU.getPackedLength( ); if( next > packed + size ) { goto lderr; } mManufacturer = DataItem( next ); next += mManufacturer.getPackedLength( ); if( next > packed + size ) { goto lderr; } mModel = DataItem( next ); next += mModel.getPackedLength( ); if( next > packed + size ) { goto lderr; } mManufacturerID = DataItem( next ); next += mManufacturerID.getPackedLength( ); if( next > packed + size ) { goto lderr; } mEngChangeLevel = DataItem( next ); next += mEngChangeLevel.getPackedLength( ); if( next > packed + size ) { goto lderr; } mParent = DataItem( next ); next += mParent.getPackedLength( ); if( next > packed + size ) { goto lderr; } devSubsystem = DataItem( next ); next += devSubsystem.getPackedLength( ); if( next > packed + size ) { goto lderr; } devDriver = DataItem( next ); next += devDriver.getPackedLength( ); if( next > packed + size ) { goto lderr; } devKernel = DataItem( next ); next += devKernel.getPackedLength( ); if( next > packed + size ) { goto lderr; } devKernelNumber = DataItem( next ); next += devKernelNumber.getPackedLength( ); if( next > packed + size ) { goto lderr; } devSysName = DataItem( next ); next += devSysName.getPackedLength( ); if( next > packed + size ) { goto lderr; } devDevTreeName = DataItem( next ); next += devDevTreeName.getPackedLength( ); if( next > packed + size ) { goto lderr; } devBus = DataItem( next ); next += devBus.getPackedLength( ); if( next > packed + size ) { goto lderr; } devBusAddr = DataItem( next ); next += devBusAddr.getPackedLength( ); if( next > packed + size ) { goto lderr; } mRecordType = DataItem( next ); next += mRecordType.getPackedLength( ); if( next > packed + size ) { goto lderr; } scsiDetail = DataItem( next ); next += scsiDetail.getPackedLength( ); if( next > packed + size ) { goto lderr; } n5 = DataItem( next ); next += n5.getPackedLength( ); if( next > packed + size ) { goto lderr; } n6 = DataItem( next ); next += n6.getPackedLength( ); if( next > packed + size ) { goto lderr; } /* Added - From SCSI fill */ plantMfg = DataItem( next ); next += plantMfg.getPackedLength( ); if( next > packed + size ) { goto lderr; } mFeatureCode = DataItem( next ); next += mFeatureCode.getPackedLength( ); if( next > packed + size ) { goto lderr; } mKeywordVersion = DataItem( next ); next += mKeywordVersion.getPackedLength( ); if( next > packed + size ) { goto lderr; } mMicroCodeImage = DataItem( next ); next += mMicroCodeImage.getPackedLength( ); if( next > packed + size ) { goto lderr; } mSecondLocation = DataItem( next ); next += mSecondLocation.getPackedLength( ); if( next > packed + size ) { goto lderr; } mPhysicalLocation = DataItem( next ); next += mPhysicalLocation.getPackedLength( ); if( next > packed + size ) { goto lderr; } // Now onto the vectors, these should go much the same way that the // packing did. while( next != CHILD_START ) { next++; if( next > packed + size ) { goto lderr; } } if( next == CHILD_START ) { next += CHILD_START.length( ) + 1; if( next > packed + size ) { goto lderr; } item = string( (char*)next ); while( CHILD_END != item ) { if( item != string( "" ) ) { string child = string( (char*)next ); mChildren.push_back( child ); next += item.length( ); } next++; item = string( (char*)next ); } next += CHILD_END.length( ) + 1; } if( DEVICE_START == next ) { next += DEVICE_START.length( ) + 1; if( next > packed + size ) { goto lderr; } item = string( (char*) next ); while( DEVICE_END != item ) { DataItem* d = new DataItem( next ); next += d->getPackedLength( ); if( next > packed + size ) { goto lderr; } mDeviceSpecific.push_back( d ); item = string( (char*)next ); } next += DEVICE_END.length( ) + 1; } if( USER_START == next ) { next += USER_START.length( ) + 1; if( next > packed + size ) { goto lderr; } item = string( (char*) next ); while( USER_END != item ) { DataItem* d = new DataItem( next ); next += d->getPackedLength( ); if( next > packed + size ) { goto lderr; } mUserData.push_back( d ); item = string( (char*)next ); } next += USER_END.length( ) + 1; } if( AX_START == next ) { next += AX_START.length( ) + 1; if( next > packed + size ) { goto lderr; } item = string( (char*) next ); while( AX_END != item ) { DataItem* d = new DataItem( next ); next += d->getPackedLength( ); if( next > packed + size ) { goto lderr; } mAIXNames.push_back( d ); item = string( (char*)next ); } } return; lderr: string message( "Component.unpack( ): Attempting to unpack corrupt buffer." ); Logger l; l.log( message, LOG_ERR ); VpdException ve( message ); throw ve; } /** * Internal use method only. This method houses the logic that would * otherwise be repeated in the copy constructor and the operator= * methods. */ void Component::copyToMe( const Component& copyMe ) { mChildren = vector( copyMe.mChildren ); vector::const_iterator i, dEnd; vector::const_iterator j, cEnd; for( i = copyMe.mDeviceSpecific.begin( ), dEnd = copyMe.mDeviceSpecific.end( ); i != dEnd; ++i ) { mDeviceSpecific.push_back( (*i) ); } for( i = copyMe.mUserData.begin( ), dEnd = copyMe.mUserData.end( ); i != dEnd; ++i ) { mUserData.push_back( (*i) ); } for( i = copyMe.mAIXNames.begin( ), dEnd = copyMe.mAIXNames.end( ); i != dEnd; ++i ) { mAIXNames.push_back( (*i) ); } for( j = copyMe.mLeaves.begin( ), cEnd = copyMe.mLeaves.end( ); j != cEnd; ++j ) { mLeaves.push_back( (*j) ); } mDescription = DataItem( copyMe.mDescription ); mSerialNumber = DataItem( copyMe.mSerialNumber ); mPartNumber = DataItem( copyMe.mPartNumber ); mFRU = DataItem( copyMe.mFRU ); mFirmwareLevel = DataItem( copyMe.mFirmwareLevel ); mFirmwareVersion = DataItem( copyMe.mFirmwareVersion ); mManufacturer = DataItem( copyMe.mManufacturer ); mModel = DataItem( copyMe.mModel ); mEngChangeLevel = DataItem( copyMe.mEngChangeLevel ); mParent = DataItem( copyMe.mParent ); idNode = DataItem( copyMe.idNode ); mPhysicalLocation = DataItem( copyMe.mPhysicalLocation ); mSecondLocation = DataItem( copyMe.mSecondLocation ); mFeatureCode = DataItem( copyMe.mFeatureCode ); /* * plantMfg = DataItem( copyMe.plantMfg ); */ } /* Children Manipulation Section */ void Component::addChild(const string& in ) { mChildren.push_back(in); } /** * @brief * Walk thru list of children of this component, checking to see * if the passed-in component is a child of this * @param child * The component which may or may not be a child of this */ bool Component::isChild(Component *child) { for (int i = 0; i < mChildren.size(); i++) if (mChildren[i] == child->idNode.getValue()) return true; return false; } /** * @brief * Walk thru list of children of this component, checking to see * if the passed-in component is a child of this * @param child * The component which may or may not be a child of this */ bool Component::isChild(const string& child) { for (int i = 0; i < mChildren.size(); i++) if (mChildren[i] == child) return true; return false; } /** * @param idNode * idNode of the child you are searching for */ const string& Component::getChild( int i ) const { return mChildren[i]; } int Component::numChildren() { return mChildren.size(); } void Component::removeChild( const string& id ) { vector::iterator i, end; for( i = mChildren.begin( ), end = mChildren.end( ); i != end; ++i ) { if( id == *i ) { mChildren.erase(i); return; } } } /** * getDevClass * @brief Returns the class node name - ie /sys/class/net/eth0 * would return net */ const string Component::getDevClass( ) { return HelperFunctions::parsePath(mDevClass.getValue(), 2); } /* Finds and returns the DataItem specified by the acronym field, AC */ const DataItem * Component::getDeviceSpecific(const string& itemAC ) { vector::iterator i, end; for( i = mDeviceSpecific.begin( ), end = mDeviceSpecific.end( ); i != end; ++i ) { if( (*i)->ac == itemAC ) { return *i; } } return NULL; } void Component::addDeviceSpecific( const string& ac, const string& humanName, const string& val, int lvl = 0 ) { DataItem *d = new DataItem( ); vector::iterator i, end; if( d == NULL ) { VpdException ve( "Out of memory." ); throw ve; } d->ac = ac; d->humanName = humanName; d->setValue( val, lvl, __FILE__, __LINE__ ); #if 0 /* * There can be multiple records with the 'CL' key. * e.g., system firmware has different values for indicating * the levels of Phyp, FSP etc. * So do not check if we already have the record. */ for( i = mDeviceSpecific.begin( ), end = mDeviceSpecific.end( ); i != end; ++i ) { if( (*i)->ac == ac ) return; //Failed to add - already present } #endif mDeviceSpecific.push_back( d ); } void Component::updateDeviceSpecific( const string& ac, const string& humanName, const string& val, int lvl = 0 ) { vector::iterator i, end; for ( i = mDeviceSpecific.begin( ), end = mDeviceSpecific.end( ); i != end; ++i ) { if ( (*i)->ac == ac ) { (*i)->setValue(val, lvl, __FILE__, __LINE__ ); return; } } /* We didn't find the entry, so add it */ addDeviceSpecific(ac, humanName, val, lvl); } const string* Component::getMicroCodeLevel( ) { const DataItem *d = getDeviceSpecific("ML"); if ( d != NULL ) return &((*d).getValue()); else return NULL; } void Component::addUserData( const string& ac, const string& humanName, const string& val, int prefLvl = 1, bool clobber = false ) { vector::iterator i, end; for( i = mUserData.begin( ), end = mUserData.end( ); i != end; ++i ) { if( (*i)->ac == ac ) { if( clobber ) { (*i)->dataValue = val; } return; } } DataItem *d = new DataItem( ); if( d == NULL ) { VpdException ve( "Out of memory." ); throw ve; } d->ac = ac; d->humanName = humanName; d->setValue( val, prefLvl, __FILE__, __LINE__ ); mUserData.push_back( d ); } void Component::addAIXName( const string& val, int prefLvl = 1 ) { DataItem *d = new DataItem( ); vector::const_iterator j, stop; j = getAIXNames().begin(); stop =getAIXNames().end(); if( d == NULL ) { VpdException ve( "Out of memory." ); throw ve; } /* Already present - remove */ for (;j != stop; j++) { if (val == (*j)->getValue()) return; } d->ac = "AX"; d->humanName = "AIX Name"; d->setValue( val, prefLvl, __FILE__, __LINE__ ); mAIXNames.push_back( d ); } /* * In-memory tree representation methods */ bool Component::removeLeaf( int index ) { vector::iterator i = mLeaves.begin( ); if( index > mLeaves.size( ) ) { return false; } for( int j = 0; j < index; j++ ) { i++; } mLeaves.erase( i ); return true; } bool Component::removeLeaf( const string& in ) { vector::iterator i = mLeaves.begin( ); for( ; i != mLeaves.end( ); ++i ) { if( (*i)->getID( ) == in ) { mLeaves.erase( i ); return true; } } return false; } } libvpd-2.2.3/src/libvpd-2/0000775000175000017500000000000012310042633015534 5ustar suzukikpsuzukikplibvpd-2.2.3/src/libvpd-2/vpdexception.hpp0000664000175000017500000000421112310042633020753 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPDVPDEXCEPTION_HPP #define LSVPDVPDEXCEPTION_HPP #include #include using namespace std; namespace lsvpd { class VpdException : public exception { public: VpdException( ); VpdException( const exception& e ); VpdException( const string& in ); virtual ~VpdException( ) throw( ); virtual const char* what( ) const throw( ); void setMessage( const string& in ); private: string mMessage; }; } #endif /*LSVPDVPDEXCEPTION_HPP*/ libvpd-2.2.3/src/libvpd-2/system.h0000664000175000017500000000541412310042633017235 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef SYSTEM_H_ #define SYSTEM_H_ #include #include #include #define SYS_INIT_BUF_SIZE 107 #define SYS_ID "/sys/bus" struct system { struct dataitem *id; struct dataitem *arch; struct dataitem *deviceTreeNode; struct dataitem *description; struct dataitem *brand; struct dataitem *nodeName; struct dataitem *os; struct dataitem *processorID; struct dataitem *machineType; struct dataitem *machineModel; struct dataitem *featureCode; struct dataitem *flagField; struct dataitem *recordType; struct dataitem *serialNum1; struct dataitem *serialNum2; struct dataitem *suid; struct dataitem *keywordVersion; struct dataitem *locationCode; u32 cpuCount; /* * The list struct uses a void * for its payload. All the data * pointers in this list will be char*'s. */ struct list *childrenIDs; struct dataitem *deviceSpecific; struct dataitem *userData; struct component *children; }; struct system * new_system( int init ); struct system * unpack_system( void * buffer ); void free_system( struct system *freeme ); #endif /*SYSTEM_H_*/ libvpd-2.2.3/src/libvpd-2/system.hpp0000664000175000017500000002152712310042633017600 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPDSYSTEM_HPP #define LSVPDSYSTEM_HPP #include #include #include #include #include #include #include #include namespace lsvpd { class System { friend class ProcCollector; friend class DeviceTreeCollector; friend class SysFSTreeCollector; friend class ICollector; friend class Gatherer; private: DataItem mIdNode; DataItem mArch; DataItem deviceTreeNode; DataItem mDescription; DataItem mBrand; DataItem mNodeName; DataItem mOS; DataItem mProcessorID; DataItem mMachineType; DataItem mMachineModel; DataItem mFeatureCode; DataItem mFlagField; DataItem mRecordType; DataItem mSerialNum1; DataItem mSerialNum2; DataItem mSUID; DataItem mKeywordVersion; DataItem mLocationCode; u32 mCPUCount; vector mChildren; vector mDeviceSpecific; vector mUserData; vector mLeaves; unsigned int getPackedSize( ); // All of the mutator methods for this are private to prevent anyone outside // of our friend list from modifying a System Object. void addDeviceSpecific( const string& ac, const string& humanName, const string& val, int lvl ); void addUserData( const string& ac, const string& humanName, const string& val, int prefLvl, bool clobber ); bool removeDeviceSpecific( int index ); bool removeDeviceSpecific( const string& spec ); bool removeLeaf( int index ); bool removeLeaf( const string& in ); bool isChild(Component *child); const string getChild( int i); inline void addChild( const string& in) { mChildren.push_back( in ); } public: static const int INIT_BUF_SIZE = 107; //Delimiters for data set vectors. static const string CHILD_START; static const string CHILD_END; static const string DEVICE_START; static const string DEVICE_END; static const string USER_START; static const string USER_END; static const string ID; System(); System( const void* packedData ); ~System( ); // These methods contain the logic to pack and unpack this object // for use with the db. pack will new the apporiate buffer and // store it in *buffer and it will expect the consumer to call an // appropriate delete. unpack will not do any memory management, // the consumer will be expected to new the appropriate memory // and free it when unpack finishes. void unpack( const void* packed ); unsigned int pack( void** buffer ); inline const vector& getChildren( ) const { return mChildren; } void removeChild( const string& id ); inline const string& getID( ) const { return ID; } //friend ostream& operator<<( ostream& os, const System& in ); /* * These functions will be used by the VPD library interface only, they allow * the consumer to hold a representation of the hardware as a tree. */ inline const vector& getLeaves( ) const { return mLeaves; } inline void addLeaf( Component* in ) { mLeaves.push_back( in ); } //Get Value methods inline const string& getMachineType( ) const { return mMachineType.getValue( ); } inline const string& getSerial1( ) const { return mSerialNum1.getValue( ); } inline const string& getSerial2( ) const { return mSerialNum2.getValue( ); } inline const string& getProcessorID( ) const { return mProcessorID.getValue( ); } inline const string& getOS( ) const { return mOS.getValue( ); } inline const string& getFeatureCode( ) const { return mFeatureCode.getValue( ); } inline const string& getDescription( ) const { return mDescription.getValue( ); } inline const string& getRecordType( ) const { return mRecordType.getValue( ); } inline const string& getLocation( ) const { return mLocationCode.getValue( ); } inline const string& getMachineModel( ) const { return mMachineModel.getValue( ); } inline const string& getSUID( ) const { return mSUID.getValue( ); } inline const string& getKeywordVer( ) const { return mKeywordVersion.getValue( ); } inline const string& getFlagField( ) const { return mFlagField.getValue( ); } inline const string& getBrand( ) const { return mBrand.getValue( ); } inline const vector& getDeviceSpecific( ) const { return mDeviceSpecific; } inline const string& getArch( ) const { return mArch.getValue( ); } inline int getCPUCount( ) const { return (int)mCPUCount; } inline const string& getDevTreeNode( ) const { return deviceTreeNode.getValue( ); } //Get AC Methods inline const string& getMachineTypeAC( ) const { return mMachineType.getAC( ); } inline const string& getSerial1AC( ) const { return mSerialNum1.getAC( ); } inline const string& getSerial2AC( ) const { return mSerialNum2.getAC( ); } inline const string& getProcessorIDAC( ) const { return mProcessorID.getAC( ); } inline const string& getOSAC( ) const { return mOS.getAC( ); } inline const string& getFeatureCodeAC( ) const { return mFeatureCode.getAC( ); } inline const string& getDescriptionAC( ) const { return mDescription.getAC( ); } inline const string& getRecordTypeAC( ) const { return mRecordType.getAC( ); } inline const string& getLocationAC( ) const { return mLocationCode.getAC( ); } inline const string& getMachineModelAC( ) const { return mMachineModel.getAC( ); } inline const string& getSUIDAC( ) const { return mSUID.getAC( ); } inline const string& getKeywordVerAC( ) const { return mKeywordVersion.getAC( ); } inline const string& getFlagFieldAC( ) const { return mFlagField.getAC( ); } inline const string& getBrandAC( ) const { return mBrand.getAC( ); } inline const string& getDevTreeNodeAC( ) const { return deviceTreeNode.getAC( ); } //Get Human Name methods inline const string& getMachineTypeHN( ) const { return mMachineType.getHumanName( ); } inline const string& getSerial1HN( ) const { return mSerialNum1.getHumanName( ); } inline const string& getSerial2HN( ) const { return mSerialNum2.getHumanName( ); } inline const string& getProcessorIDHN( ) const { return mProcessorID.getHumanName( ); } inline const string& getOSHN( ) const { return mOS.getHumanName( ); } inline const string& getFeatureCodeHN( ) const { return mFeatureCode.getHumanName( ); } inline const string& getDescriptionHN( ) const { return mDescription.getHumanName( ); } inline const string& getRecordTypeHN( ) const { return mRecordType.getHumanName( ); } inline const string& getLocationHN( ) const { return mLocationCode.getHumanName( ); } inline const string& getMachineModelHN( ) const { return mMachineModel.getHumanName( ); } inline const string& getSUIDHN( ) const { return mSUID.getHumanName( ); } inline const string& getKeywordVerHN( ) const { return mKeywordVersion.getHumanName( ); } inline const string& getFlagFieldHN( ) const { return mFlagField.getHumanName( ); } inline const string& getBrandHN( ) const { return mBrand.getHumanName( ); } inline const string& getDevTreeNodeHN( ) const { return deviceTreeNode.getHumanName( ); } }; } #endif libvpd-2.2.3/src/libvpd-2/dataitem.hpp0000664000175000017500000001315512310042633020042 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef DATAITEM_HPP #define DATAITEM_HPP #include #include #include #include using namespace std; namespace lsvpd { /** * Holds a single item of data inside a Component as well as some * meta-data about this information. It contains labels for this data * and a vector of sources for this data. * * @class DataItem * * @ingroup lsvpd * * @brief * Holds a single item of data for a Component * * @author Eric Munson , * Brad Peters sources; /**< A collection of all the alternative sources to fill this data item */ int prefLevelUsed; /**< PreferenceLevel of source used to fill this dataitem. Zero if not filled*/ int setValue( const string& in, int prefLevelUsed_t, const char *file, int lineNum); void setHumanName( const string& in ); void setAC(const string& in); int getPrefLevel(); public: DataItem( ); DataItem(string& in) : dataValue(in), packedLength( 0 ), prefLevelUsed(0) {}; /** * Unpackes a buffer using the unpack method to fill *this. * * @brief * Unpacks data into *this. * * @param data * The buffer holding the DataItem */ DataItem( const void * data ) : packedLength( 0 ), prefLevelUsed(0) { unpack( data ); } DataItem( const DataItem& copyMe ); ~DataItem( ); const string& getHumanName( ) const; const string& getAC( ) const; const string& getValue() const; /** * @brief * Returns the number of bytes required to hold *this. * * @return * The buffer size needed to hold *this. */ int getPackedLength( ); /** * Pack will not do any memory management, it assumes that * buffer is a valid pointer and that there is enough space * after buffer to hold *this. This is valid because this * method should only be called from Component::unpack. * * @brief * Stores *this into the buffer. * * @param buffer * The buffer to use to store *this. * * @return * The number of bytes added to the buffer. */ int pack( void* buffer ); /** * Like DataItem::pack, unpack does not do any memory management. * It assumes that data is a valid pointer and that the information * following *data will fill this DataItem. This assumption is * used only because this method should only be called from * Component::unpack. * * @brief * Unpacks buffer into *this. * * @param data * The buffer to be unpacked. */ void unpack( const void * data ); int getNumSources() const; Source * getSource(int i) const; void addSource(Source *in); void addSource(char **buf); void removeSource(int i); inline const int getPrefLevelUsed() { return prefLevelUsed; } inline const vector& getSources( ) const { return sources; } inline const Source* getFirstSource( ) const { if( !sources.empty( ) ) return sources.at( 0 ); else return NULL; } //friend ostream& operator<<( ostream& os, const DataItem& in ); }; } #endif /* DATAITEM_H */ libvpd-2.2.3/src/libvpd-2/debug.hpp0000664000175000017500000000413112310042633017332 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef DEBUG_HPP #define DEBUG_HPP //#define GREEN "\e[0;32m" //#define RED "\e[1;31m" //#define BLUE "\e[1;34m" //#define NC "\e[0m" #define GREEN "" #define RED "" #define BLUE "" #define NC "" #define STRIT(x) #x #define TOSTRING(x) STRIT(x) #ifdef TRACE_ON #define coutd cout << RED << __FILE__ << ": " << GREEN << __func__ << "()" << BLUE << " [" << __LINE__ << "] " << NC #else #define coutd if(0) cout #endif #endif /*DEBUG_H_*/ libvpd-2.2.3/src/libvpd-2/lsvpd.hpp0000664000175000017500000000356112310042633017402 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPD_HPP #define LSVPD_HPP #include #include #define INIT_PREF_LEVEL 10 typedef __u8 u8; typedef __u16 u16; typedef __u32 u32; typedef __u64 u64; #endif /*LSVPD_H_*/ libvpd-2.2.3/src/libvpd-2/component.h0000664000175000017500000000742312310042633017715 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * ebmunson@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef COMPONENT_H_ #define COMPONENT_H_ #include #include #define CHILD_START "::childrenStart::" #define CHILD_END "::childrenEnd::" #define DEVICE_START "::deviceSpecificStart::" #define DEVICE_END "::deviceSpecificEnd::" #define USER_START "::userStart::" #define USER_END "::userEnd::" #define AX_START "::axStart::" #define AX_END "::axEnd::" #define COMP_INIT_BUF_SIZE 129 /* All lists should be NULL terminated */ struct component { struct dataitem *id; struct dataitem *deviceTreeNode; struct dataitem *sysFsNode; struct dataitem *sysFsLinkTarget; struct dataitem *halUDI; struct dataitem *netAddr; struct dataitem *devClass; struct dataitem *description; struct dataitem *cdField; struct dataitem *serialNumber; struct dataitem *partNumber; struct dataitem *firmwareLevel; struct dataitem *firmwareVersion; struct dataitem *fru; struct dataitem *manufacturer; struct dataitem *model; struct dataitem *manufacturerID; struct dataitem *engChangeLevel; struct dataitem *parent; struct dataitem *devSubSystem; struct dataitem *devDriver; struct dataitem *devKernel; struct dataitem *devKernelNumber; struct dataitem *devSysName; struct dataitem *devDevTreeName; struct dataitem *devBus; struct dataitem *devType; struct dataitem *devBusAddr; struct dataitem *microCodeImage; struct dataitem *recordType; struct dataitem *scsiDetail; struct dataitem *plantMfg; struct dataitem *featureCode; struct dataitem *keywordVersion; struct dataitem *microCodeVersion; struct dataitem *physicalLocation; struct dataitem *secondLocation; /* * The next three data items are singlely linked lists that will * be NULL terminated. */ struct dataitem *deviceSpecific; struct dataitem *userData; struct dataitem *aixNames; struct list *childrenIDs; struct component *children; struct component *next; }; struct component* new_component( int init ); void free_component( struct component *freeme ); struct component * unpack_component( void *buffer ); void add_component( struct component *head, const struct component *addme ); #endif /*COMPONENT_H_*/ libvpd-2.2.3/src/libvpd-2/vpdretriever.hpp0000664000175000017500000001127312310042633020772 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPDVPDRETRIEVER_HPP #define LSVPDVPDRETRIEVER_HPP #include #include #include #include namespace lsvpd { class VpdRetriever { private: VpdDbEnv* db; void buildSubTree( System* root ); void buildSubTree( Component* root ); public: static const string DEFAULT_DIR; static const string DEFAULT_FILE; static const string UDEV_NOTIFY_FILE; /** * Builds A VpdRetriever object that can be used for reading the * vpd stored in the specified database. VpdExceptions * mean that there was a problem with the necessary resources * to access the database (e.g. The file was not present or was * not readable by the user). If any other exceptions come from * this constructor, there were serious underlying issues that * are not recoverable. * * @param envDir * The directory where the VPD database is stored. * @param dbFileName * The file name for the VPD database. */ VpdRetriever( string envDir, string dbFileName ) throw( VpdException& ); /** * Builds A VpdRetriever object that can be used for reading the * vpd stored in the specified database. VpdExceptions * mean that there was a problem with the necessary resources * to access the database (e.g. The file was not present or was * not readable by the user). If any other exceptions come from * this constructor, there were serious underlying issues that * are not recoverable. Uses the default dir and filename */ VpdRetriever( ) throw( VpdException& ); ~VpdRetriever( ); /** * Retrieves, builds, and returns a tree structure representing * the VPD available in the target VPD database. Each entry * corresponds to a single device available on a system and all * of the VPD for that device will be contained in the * corresponding entry only. * * @return * The root of the tree of device VPD. */ System* getComponentTree( ); /** * Gets a specified Component from the database. A Component is * the collection of VPD about a single device on the system. * * NOTE: The pointer returned is "newed" by this method but the * caller will be responsible for deleting the pointer that is * returned. * * @param id * The string ID for the requested component. * @return * A pointer to the requested information or NULL on failure. */ inline Component* getComponent( const string& id ) { return db->fetch( id ); } /** * Gets the root or System Component from the database. A * System is the collection of VPD about the System. * * NOTE: The pointer returned is "newed" by this method but the * caller will be responsible for deleting the pointer that is * returned. * * @return * A pointer to the System VPD collection or NULL on failure. */ inline System* getComponent( ) { return db->fetch( ); } }; } #endif /*LSVPDVPDRETRIEVER_HPP*/ libvpd-2.2.3/src/libvpd-2/config.h.in0000664000175000017500000001107312310042633017561 0ustar suzukikpsuzukikp/* src/libvpd-2/config.h.in. Generated from configure.in by autoheader. */ /* Define to 1 if the `closedir' function returns void instead of `int'. */ #undef CLOSEDIR_VOID /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ #undef HAVE_LIBSQLITE3 /* Define to 1 if `lstat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_LSTAT_EMPTY_STRING_BUG /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_SQLITE3_H /* Define to 1 if you have the `sqlite3_prepare_v2' function. */ #undef HAVE_SQLITE3_PREPARE_V2 /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the `uname' function. */ #undef HAVE_UNAME /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to 1 if `major', `minor', and `makedev' are declared in . */ #undef MAJOR_IN_MKDEV /* Define to 1 if `major', `minor', and `makedev' are declared in . */ #undef MAJOR_IN_SYSMACROS /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `unsigned int' if does not define. */ #undef size_t libvpd-2.2.3/src/libvpd-2/vpddbenv.h0000664000175000017500000000514512310042633017522 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef VPDDBENV_H_ #define VPDDBENV_H_ #include #include #include #include #include #define DEFAULT_ENV "/var/lib/lsvpd" #define DEFAULT_DB "vpd.db" #define TABLE_NAME "components" #define ID "comp_id" #define DATA "comp_data" #define MAX_NAME_LENGTH 256 #define QUERY_BUF_LENGTH 4096 #if HAVE_SQLITE3_PREPARE_V2 #define SQLITE3_PREPARE sqlite3_prepare_v2 #else #define SQLITE3_PREPARE sqlite3_prepare #endif struct vpddbenv { char envDir[ MAX_NAME_LENGTH + 1 ]; char dbFileName[ MAX_NAME_LENGTH + 1 ]; char fullPath[ MAX_NAME_LENGTH * 2 + 2 ]; sqlite3 *db; }; struct vpddbenv * new_vpddbenv( const char *dir, const char *file ); void free_vpddbenv( struct vpddbenv *freeme ); struct component* fetch_component( struct vpddbenv *db, const char *deviceID ); struct system* fetch_system( struct vpddbenv *db ); #endif /*VPDDBENV_H_*/ libvpd-2.2.3/src/libvpd-2/Source.hpp0000664000175000017500000000667112310042633017517 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPDSOURCE_HPP #define LSVPDSOURCE_HPP /* Collector Source data types */ enum { BINARY = 0, ASCII, UNUSED }; /* Various data sources/collectors */ enum { SRC_DEVICETREE = 0, SRC_SYSFS }; #include #include using namespace std; namespace lsvpd { class Source { private: /* * Identifier needed to access this source. May be a file to open, * mem pointer, unique ID, etc */ string srcRef; // Optional: Used for various purposes as needed by this source string data; /* * Optional: reference to where this data field resides - ie * PCIIDS, SYSFS, etc */ int id; // binary file? ascii? int type; /* * How many lines need to be read from this file to collect all * needed data */ int lines; /* * If prefLevel is set higher than other sources, values obtained * from this source will be used to overwrite values from other * sources */ int preferenceLevel; public: Source(string srcRef_t, string data_t, int id_t, int type_t, int lines_t, int preferenceLevel_t) : srcRef(srcRef_t), data(data_t), id(id_t), type(type_t), lines(lines_t), preferenceLevel(preferenceLevel_t) {} Source() : srcRef( "" ) {} ~Source() {} inline int getPrefLvl( ) const { return preferenceLevel; } inline const string& getSrcRef( ) const { return srcRef; } inline const string& getData( ) const { return data; } inline int getID( ) const { return id; } inline int getType( ) const { return type; } inline int getLines( ) const { return lines; } void unpack(char **buf); int getPackedLength(); void pack(char **buf); friend ostream& operator<<( ostream& os, const Source& in ); }; } #endif /*LSVPDSOURCE_H_*/ libvpd-2.2.3/src/libvpd-2/lsvpd_error_codes.hpp0000664000175000017500000000445612310042633021774 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPD_ERROR_CODES_HPP #define LSVPD_ERROR_CODES_HPP #include using namespace std; namespace lsvpd { /* Thrown error codes should be looked for in errno.h first. */ enum { FILE_NOT_FOUND = 151, DIRECTORY_NOT_FOUND, SYSTEM_COMMAND_PROCESSOR_NOT_FOUND, CLASS_NODE_UNDEFINED, ERROR_ACCESSING_DEVICE, BUFFER_EMPTY, SGUTILS_READ_ERROR, UNABLE_TO_OPEN_FILE, UNABLE_TO_MKNOD_FILE, SG_DATA_INVALID, SGUTILS_IOCTL_FAILED, RTAS_CALL_NOT_AVAILABLE, RTAS_PARAMETER_ERROR, RTAS_HARDWARD_ERROR, RTAS_ERROR, SCSI_FILL_TEMPLATE_LOADING }; string interp_err_code(int errCode); } #endif /*LSVPD_ERROR_CODES_H_*/ libvpd-2.2.3/src/libvpd-2/vpdretriever.h0000664000175000017500000000703712310042633020435 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef VPDRETRIEVER_H_ #define VPDRETRIEVER_H_ #include #include #include /* * struct vpdretriever is the outside world's access point for the VPD database * It can be used to request individual hardware records or the entire VPD tree * as the user needs. */ struct vpdretriever { struct vpddbenv *dbenv; }; /* * Creates a new vpdretiever, takes a directory where the VPD db lives, a * filename for the db to query, and an unsigned 32 bit integer that holds the * flags to be passed to onto the BerekelyDB create commands. This function * will open the default location for a VPD db (dir='/var/lib/lsvpd' file='db') * and no flags specified to the BerkeleyDB library. The pointer returned is * malloc'd and should be free'd using the free_vpdretriever function. On * error NULL is returned. */ struct vpdretriever * new_vpdretriever( const char* dir, const char *file ); /* * Releases all resources used by this vpdretriever. Closes connections to the * VPD db and free's all malloc'd memory. */ void free_vpdretriever( struct vpdretriever *freeme ); /* * Retrieves the entire tree of device VPD. The pointer returned is malloc'd * and should be free'd using the free_system function from system.h. On error * NULL is returned. */ struct system * get_component_tree( struct vpdretriever *dbenv ); /* * Retrieves the specified component. The pointer returned is malloc'd and * should be free'd using free_component function from component.h. On error * NULL is returned. */ struct component * get_component( struct vpdretriever *dbenv, const char *id ); /* * Retrieves the system level VPD. The pointer returned is malloc'd and * should be free'd using free_system function from system.h. On error * NULL is returned. */ struct system * get_system( struct vpdretriever *dbenv ); #endif /*VPDRETRIEVER_H_*/ libvpd-2.2.3/src/libvpd-2/component.hpp0000664000175000017500000005311112310042633020250 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPDCOMPONENT_HPP #define LSVPDCOMPONENT_HPP #include #include #include #include /** * @defgroup lsvpd lsvpd * * @brief * Group lsvpd holds the vpd access programs and library */ namespace lsvpd { static const int COMPONENT_STATE_LIVE = 0x00000001; static const int COMPONENT_STATE_DEAD = 0x00000002; /** * This class provides a single storage point for all the VPD connected * to a single entity on a system. An entity may be a physical piece of * hardware (e.g. an ethernet card or a PCI bus), a virtualized piece of * hardware (e.g. a virtual SCSI drive), or a specific group of * functionality provided by a piece of hardware (e.g. Some laptops have * a sound card that also has an onboard modem). This object has only * private mutator methods because we do not want programs using libvpd * to be able to modify information stored here. * * @class Component * * @ingroup lsvpd * * @brief * A Compontent holds VPD for a single entity on a system. * * @author Eric Munson , * Brad Peters mChildren; vector mDeviceSpecific; vector mUserData; /** * @brief * Holds the kernel names for this device */ vector mAIXNames; // These are not stored in the DB, they are computed. vector mLeaves; Component* mpParent; int devMajor; ///< Major:minor codes for device lookup int devMinor; int devAccessMode; // For direct query of device /** * This creates a new DataItem, filling it with the provided * data and adds it to the mDeviceSpecific vector. * * @brief * Adds an entry in to the Device Specifc vector. * @param ac * Holds the acronymn (in vpd-ese) for the new entry * @param humanName * A nore descriptive label for the new entry * @param val * The value of the new entry * @param prefLvl * The preference level to use for the new entry */ void addDeviceSpecific( const string& ac, const string& humanName, const string& val, int prefLvl ); /** * Like addDeviceSpecific, however, if it finds an existing * entry, we modify the existing one with the new Value. * @brief * Adds an entry in to the Device Specifc vector. * @param ac * Holds the acronymn (in vpd-ese) for the new entry * @param humanName * A more descriptive label for the new entry * @param val * The value of the new entry * @param prefLvl * The preference level to use for the new entry */ void updateDeviceSpecific( const string& ac, const string& humanName, const string& val, int prefLvl ); /** * This creates a new DataItem, filling it with the provided data * and attempts to add it to the UserData vector. Because the * UserData vector has to have unique acronymns the caller needs * to specify if this data should replace any data that might be * present. * * @brief * Adds or overwrites an entry in the UserData vector. * @param ac * The acronymn for the new entry * @param humanName * Descriptive label for the nex entry * @param prefLvl * The preference level to use for the new entry * @param clobber * If the Item exists, should the value be clobbered */ void addUserData( const string& ac, const string& humanName, const string& val, int prefLvl, bool clobber ); /** * This creates a new DataItem, filling it with the provided * data and adds it to the mAIXNames vector. * * @brief * Adds an entry in to the AIX Names vector. * @param val * The value of the new entry * @param prefLvl * The preference level to use for the new entry */ void addAIXName( const string& val, int prefLvl ); /** * @brief * Removes the specified entry from the mLeaves vector. * @param index * The index of the Item to remove */ bool removeLeaf( int index ); /** * @brief * Removes the specified entry from the mLeaves vector. * @param in * The Component ID to be removed */ bool removeLeaf( const string& in ); bool isChild(Component *child); bool isChild(const string& child); int numChildren(); /** * @brief * Copies data from arg to this. * @param copyMe * The Component to be copied. */ void copyToMe( const Component& copyMe ); /** * Starts with the base size of a Component (INIT_BUF_SIZE), and * sums the size of each Data Item and returns the number of * bytes required to store *this. * * @brief * Calculates the size of *this */ unsigned int getPackedSize( ); public: /** * This is the number of bytes required to store an empty * Component object into the DB. To recalculate this value * sum (remembering to add 1 to each for the null byte) * the length of each vector separator (CHILD_START, * CHILD_END, DEVICE_START, etc.) */ static const int INIT_BUF_SIZE = 129; //Delimiters for data set vectors. static const string CHILD_START; static const string CHILD_END; static const string DEVICE_START; static const string DEVICE_END; static const string USER_START; static const string USER_END; static const string AX_START; static const string AX_END; /** * @brief * Builds empty Component. */ Component( ); /** * @brief * Copies provided Component */ Component( const Component& copyMe ); /** * Uses the unpack method to populate a new Component with the * "serialized" data in the provided buffer. * * @brief * Unpackes the "serialized" Component from buffer. * @param packedData * Buffer that contains Component information */ Component( const void* packedData ); ~Component( ); Component& operator=( const Component& rhs ); void addChild( const string& in); void removeChild( const string& id ); /** * getDevClass * @brief Returns the class name - * ie: /sys/class/net/eth0 would return net */ const string getDevClass(); /** * getClassNode * @brief Returns the full path for the device in the /sys/class */ inline string getClassNode( ) { return mDevClass.getValue(); } void setMajor(int in) { devMajor = in; } void setMinor(int in) { devMinor = in; } void setMode(int in) { devAccessMode = in; } inline int getMajor() { return devMajor; } inline int getMinor() { return devMinor; } inline int getMode() { return devAccessMode; } const string& getChild( int i ) const; /** * Unpacks the packed Component information stored in the buffer. * This method will fill *this will the information stored in * the buffer. This method will not do any memory management, * that is it will not free the buffer passed in, that is the * responsibility of the caller. * * @brief * Unpacks the provided buffer into *this * @param packed * The buffer holding a packed Component */ void unpack( const void* packed ); /** * This method takes a char ** and creates a buffer sized * appropriately to hold the information stored in *this. * It will store the address of this buffer in *buffer for * use outside of the method. Pack will allocate the buffer * or reallocate if *buffer is not NULL. The caller will be * responsible for deleting the buffer when they are finished * with it. * * @brief * Packes *this into a buffer. * @param buffer * Address of a pointer to fill. * @return * The size of the buffer filled. */ unsigned int pack( void** buffer ); //The Get Value methods inline const string& getDescription( ) const { return mDescription.getValue(); } inline const string& getRecordType( ) const { return mRecordType.getValue( ); } inline const string& getSerialNumber( ) const { return mSerialNumber.getValue(); } inline const string& getPartNumber( ) const { return mPartNumber.getValue(); } inline const string& getFRU( ) const { return mFRU.getValue(); } inline const string& getFirmwareLvl( ) const { return mFirmwareLevel.getValue(); } inline const string& getFirmwareVersion( ) const { return mFirmwareVersion.getValue(); } inline const string& getFirmwareLevel( ) const { return mFirmwareLevel.getValue(); } inline const string& getManufacturer( ) const { return mManufacturer.getValue(); } inline const string& getDeviceDriverName( ) const { return devDriver.getValue(); } inline const string& getModel( ) const { return mModel.getValue(); } inline const string& getID( ) const { return idNode.getValue(); } inline const string& getFeatureCode( ) const { return mFeatureCode.getValue(); } inline const string& getEngChange( ) const { return mEngChangeLevel.getValue(); } inline const string& getParent( ) const { return mParent.getValue(); } inline const string& getManufacturerID( ) const { return mManufacturerID.getValue( ); } inline const string& getCD( ) const { return mCDField.getValue( ); } inline const string& getNetAddr( ) const { return mNetAddr.getValue( ); } inline const string& getPhysicalLocation( ) const { return mPhysicalLocation.getValue( ); } inline const string& getSecondLocation( ) const { return mSecondLocation.getValue( ); } inline const string& getIdNode( ) const { return idNode.getValue( ); } inline const vector& getChildren( ) const { return mChildren; } inline const vector& getDeviceSpecific( ) const { return mDeviceSpecific; } const DataItem * getDeviceSpecific(const string& itemAC ); inline const vector& getUserData( ) const { return mUserData; } inline const string& getDevTreeNode( ) const { return deviceTreeNode.getValue( ); } inline const string& getKeywordVersion( ) const { return mKeywordVersion.getValue( ); } inline const string& getMicroCodeImage( ) const { return mMicroCodeImage.getValue( ); } inline const vector& getAIXNames( ) const { return mAIXNames; } inline const string& getDeviceTreeNode( ) const { return deviceTreeNode.getValue( ); } inline const string& getSysFsNode( ) const { return sysFsNode.getValue( ); } inline const string& getSysFsLinkTarget( ) const { return sysFsLinkTarget.getValue( ); } inline const string& getHalUDI( ) const { return halUDI.getValue( ); } inline const string& getDevSysName( ) const { return devSysName.getValue( ); } inline const string& getDevTreeName( ) const { return devDevTreeName.getValue( ); } inline const string& getDevBus( ) const { return devBus.getValue( ); } inline const string& getDevType( ) const { return devType.getValue( ); } inline const string& getDevBusAddr( ) const { return devBusAddr.getValue( ); } inline const string& getn5( ) const { return n5.getValue(); } inline const string& getn6( ) const { return n6.getValue(); } inline const string& getMachineSerial() const { return plantMfg.getValue(); } const string* getMicroCodeLevel( ); // The Get Acronymn methods inline const string& getDescriptionAC( ) const {return mDescription.getAC( ); } inline const string& getRecordTypeAC( ) const { return mRecordType.getAC( ); } inline const string& getSerialNumberAC( ) const { return mSerialNumber.getAC(); } inline const string& getPartNumberAC( ) const { return mPartNumber.getAC(); } inline const string& getFRUAC( ) const { return mFRU.getAC(); } inline const string& getFirmwareLevelAC( ) const { return mFirmwareLevel.getAC(); } inline const string& getFirmwareVersionAC( ) const { return mFirmwareVersion.getAC(); } inline const string& getManufacturerAC( ) const { return mManufacturer.getAC(); } inline const string& getModelAC( ) const { return mModel.getAC(); } inline const string& getIDAC( ) const { return idNode.getAC(); } inline const string& getFeatureCodeAC( ) const { return mFeatureCode.getAC(); } inline const string& getEngChangeAC( ) const { return mEngChangeLevel.getAC(); } inline const string& getParentAC( ) const { return mParent.getAC(); } inline const string& getManufacturerIDAC( ) const { return mManufacturerID.getAC( ); } inline const string& getCDAC( ) const { return mCDField.getAC( ); } inline const string& getNetAddrAC( ) const { return mNetAddr.getAC( ); } inline const string& getPhysicalLocationAC( ) const { return mPhysicalLocation.getAC( ); } inline const string& getSecondLocationAC( ) const { return mSecondLocation.getAC( ); } inline const string& getidNodeAC( ) const { return idNode.getAC(); } inline const string& getDevTreeNodeAC( ) const { return deviceTreeNode.getAC( ); } inline const string& getKeywordVersionAC( ) const { return mKeywordVersion.getAC( ); } inline const string& getMicroCodeImageAC( ) const { return mMicroCodeImage.getAC( ); } inline const string& getn5AC( ) const { return n5.getAC( ); } inline const string& getn6AC( ) const { return n6.getAC( ); } inline const string& getMachineSerialAC() const { return plantMfg.getAC(); } // The get human name methods inline const string& getDescriptionHN( ) const { return mDescription.getHumanName(); } inline const string& getRecordTypeHN( ) const { return mRecordType.getHumanName( ); } inline const string& getSerialNumberHN( ) const { return mSerialNumber.getHumanName(); } inline const string& getPartNumberHN( ) const { return mPartNumber.getHumanName(); } inline const string& getFRUHN( ) const { return mFRU.getHumanName(); } inline const string& getFirmwareLvlHN( ) const { return mFirmwareLevel.getHumanName(); } inline const string& getFirmwareVersionHN( ) const { return mFirmwareVersion.getHumanName(); } inline const string& getManufacturerHN( ) const { return mManufacturer.getHumanName(); } inline const string& getModelHN( ) const { return mModel.getHumanName(); } inline const string& getIDHN( ) const { return idNode.getHumanName(); } inline const string& getFeatureCodeHN( ) const { return mFeatureCode.getHumanName(); } inline const string& getEngChangeHN( ) const { return mEngChangeLevel.getHumanName(); } inline const string& getParentHN( ) const { return mParent.getHumanName(); } inline const string& getManufacturerIDHN( ) const { return mManufacturerID.getHumanName( ); } inline const string& getCDHN( ) const { return mCDField.getHumanName( ); } inline const string& getNetAddrHN( ) const { return mNetAddr.getHumanName( ); } inline const string& getPhysicalLocationHN( ) const { return mPhysicalLocation.getHumanName( ); } inline const string& getSecondLocationHN( ) const { return mSecondLocation.getHumanName( ); } inline const string& getidNodeHN( ) const { return idNode.getHumanName(); } inline const string& getDevTreeNodeHN( ) const { return deviceTreeNode.getHumanName( ); } inline const string& getKeywordVersionHN( ) const { return mKeywordVersion.getHumanName( ); } inline const string& getMicroCodeImageHN( ) const { return mMicroCodeImage.getHumanName( ); } inline const string& getn5HN( ) const { return n5.getHumanName( ); } inline const string& getn6HN( ) const { return n6.getHumanName( ); } inline const string& getMachineSerialHN() const { return plantMfg.getHumanName(); } inline const vector& getLeaves( ) const { return mLeaves; } inline void addLeaf( Component* in ) { mLeaves.push_back( in ); } }; } #endif libvpd-2.2.3/src/libvpd-2/vpddbenv.hpp0000664000175000017500000001431212310042633020056 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPDVPDDBENV_HPP #define LSVPDVPDDBENV_HPP #include #include #include #include #include #include #if HAVE_SQLITE3_PREPARE_V2 #define SQLITE3_PREPARE sqlite3_prepare_v2 #else #define SQLITE3_PREPARE sqlite3_prepare #endif using namespace std; namespace lsvpd { /** * VpdDbEnv provides the interface for all of lsvpd to interact with the * Berkeley DB that is storing all the VPD information. This class * enforces the use of an BDB environment to give us multi-process saftey * and transaction support. */ class VpdDbEnv { private: VpdDbEnv& operator=( const VpdDbEnv& rhs ) { return (*this); } VpdDbEnv( const VpdDbEnv& copyMe ); string mEnvDir; string mDbFileName; string mDbPath; sqlite3* mpVpdDb; public: // Table name for the components static const string TABLE_NAME; static const string ID; static const string DATA; VpdDbEnv( const string& envDir, const string& dbFileName, bool readOnly ); ~VpdDbEnv(); /** * Fetch attempts to load the specified Component from the VPD * database. If the Component is not in the database, the returned * object will have empty data fields. A VpdException will only be * thrown if there is an unrecoverable problem communicating with * the database. * * @param deviceID * The ID for the device information to retrieve from the db * @returns * The collection of device information * @throws VpdException * In the event of an unrecoverable error (e.g. new returns NULL, * database is corrupt, etc.) a VpdException will be thrown. */ Component* fetch( const string& deviceID ); /** * Fetch attempts to load the root System from the VPD database. * If the System is not in the database, the returned object will * have empty data fields. A VpdException will only be thrown if * there is an unrecoverable problem communicating with the * database. * * @returns * The collection of system information * @throws VpdException * In the event of an unrecoverable error (e.g. new returns NULL, * database is corrupt, etc.) a VpdException will be thrown. */ System* fetch( ); /** * Store attempts to save the specified Component to the VPD * database. If the save is not successfull, store will return * false. A VpdException will only be thrown if there is an * unrecoverable problem communicating with the database. * * @param storeMe * The device information to store into the db * @returns * true is everything succeeded, fales otherwise * @throws VpdException * In the event of an unrecoverable error (e.g. new returns NULL, * database is corrupt, etc.) a VpdException will be thrown. */ bool store( Component *storeMe ); /** * Store attempts to save the specified System to the VPD database. * If the save is not successfull, store will return false. A * VpdException will only be thrown if there is an unrecoverable * problem communicating with the database. * * @param storeMe * The system information to store into the db * @returns * true is everything succeeded, fales otherwise * @throws VpdException * In the event of an unrecoverable error (e.g. new returns NULL, * database is corrupt, etc.) a VpdException will be thrown. */ bool store( System *storeMe ); /** * Remove deletes the specified Component from the VPD database, if * the delete is unsuccessfull remove will return false. A * VpdException will only be thrown if there is an unrecoverable * problem communicating with the database. * * @param deviceID * The ID for the information to remove from the db * @returns * true if deletion succeeded, otherwise false * @throws VpdException * In the event of an unrecoverable error (e.g. new returns NULL, * database is corrupt, etc.) a VpdException will be thrown. */ bool remove( const string& deviceID ); /** * getKeys returns all of the valid keys (device ID's) present in * the VPD database, if there is a problem retrieving the keys the * vector will be empty or incomplete. * * @returns * A vector containing all of the device ID's in the db * @throws VpdException * In the event of an unrecoverable error (e.g. new returns NULL, * database is corrupt, etc.) a VpdException will be thrown. */ vector getKeys( ); }; } #endif libvpd-2.2.3/src/libvpd-2/helper_functions.hpp0000664000175000017500000000610212310042633021613 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #ifndef HELPERFUNCTIONS_HPP #define HELPERFUNCTIONS_HPP /* Collection of definitions needed globally */ using namespace std; namespace lsvpd { class HelperFunctions { private: HelperFunctions(); ~HelperFunctions(); public: static string readMatchFromFile(const string&, const string&); static string parseString(const string& line, int str_pos, string& out); static string findAIXFSEntry(vector , const string&); static string parsePathr(const string& path, int count); static string parsePath(const string& path, int count); static string getSymLinkTarget(const string&); static int dropDir(char * filePath); static int dropDir(string& filePath_t); static string getAbsolutePath(char * relPath, char * curDir); static bool matches(const string& s1, const string& s2); /* Remove trailing '/', fix anything else mucked up with path */ static char *fs_fixPath(char *path_t); static void fs_fixPath(string& str); static bool file_exists(const string& file); static void str2chr(char **str1, const string& str2); /* Counts and returns the occurences of c in str. */ static int countChar( const string& str, char c ); static bool contains( const vector& vec, const string& val ); static int execCmd( const char *cmd, string& output ); }; } #endif /*HELPERFUNCTIONS_H_*/ libvpd-2.2.3/src/libvpd-2/logger.hpp0000664000175000017500000000474312310042633017534 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2006, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef LSVPDLOGGER_HPP #define LSVPDLOGGER_HPP #include #include #define L_DEFAULT_HANDLER syslog // replaces fprintf(3) by syslog(3) #define L_DEFAULT_PARAMS LOG_USER // default priority for syslog info using namespace std; namespace lsvpd { class Logger { public: /* * Log level will use the constants defined in syslog.h see * syslog(3) for their meanings. */ Logger( const string& ident = "lsvpd" ); ~Logger(); inline const string& getIdent( ) const { return mIdent; } /** * Sends the specified message to syslogd with the specified * severity level. The severity level defaults to LOG_NOTICE if * nothing is specified. */ void log( const string& message, int level = LOG_NOTICE ) const; private: string mIdent; }; } #endif //LSVPDLOGGER_H libvpd-2.2.3/src/libvpd-2/common.h0000664000175000017500000000402212310042633017173 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * ebmunson@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef COMMON_H_ #define COMMON_H_ #include #include typedef __u8 u8; typedef __u16 u16; typedef __u32 u32; typedef __u64 u64; struct list { void *data; struct list* next; }; struct list* new_list( ); void free_list( struct list *head ); struct list* concat_list( struct list *head, const struct list *addme ); #endif /*COMMON_H_*/ libvpd-2.2.3/src/libvpd-2/dataitem.h0000664000175000017500000000411012310042633017471 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * ebmunson@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef DATAITEM_H_ #define DATAITEM_H_ struct dataitem { char *humanName; char *ac; char *dataValue; struct dataitem *next; }; struct dataitem* new_dataitem( ); void free_dataitem( struct dataitem *freeme ); int calc_packed_length_dataitem( struct dataitem *packme ); struct dataitem * unpack_dataitem( void *buffer ); void add_dataitem( struct dataitem *head, const struct dataitem *addme ); #endif /*DATAITEM_H_*/ libvpd-2.2.3/src/system_c.c0000664000175000017500000002473412310042633016121 0ustar suzukikpsuzukikp/*************************************************************************** * Copyright (C) 2007, IBM * * * * Maintained By: * * Eric Munson and Brad Peters * * munsone@us.ibm.com, bpeters@us.ibm.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as * * published by the Free Software Foundation; either version 2.1 of the * * License, or at your option) any later version. * * * * 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. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include struct system * new_system( int init ) { struct system *ret = NULL; ret = malloc( sizeof( struct system ) ); if( !ret ) return NULL; memset( ret, 0 , sizeof( struct system ) ); if( init ) { ret->id = new_dataitem( ); if( !ret->id ) goto newsyserr; ret->id->dataValue = strdup( SYS_ID ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "DS" ); ret->description->humanName = strdup( "Description" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "BR" ); ret->description->humanName = strdup( "Brand Keyword" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "OS" ); ret->description->humanName = strdup( "Operation System" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "PI" ); ret->description->humanName = strdup( "Processor ID or Unique ID" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "TM" ); ret->description->humanName = strdup( "Machine Type" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "TM" ); ret->description->humanName = strdup( "Machine Model" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "FC" ); ret->description->humanName = strdup( "Feature Code" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "FG" ); ret->description->humanName = strdup( "Flag Field" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "RT" ); ret->description->humanName = strdup( "Record Type" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "SE" ); ret->description->humanName = strdup( "Machine or Cabinet Serial Number" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "SE" ); ret->description->humanName = strdup( "Machine or Cabinet Serial Number" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "SU" ); ret->description->humanName = strdup( "System Unique ID" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "VK" ); ret->description->humanName = strdup( "Version of Keywords" ); ret->description = new_dataitem( ); if( !ret->description ) goto newsyserr; ret->description->ac = strdup( "YL" ); ret->description->humanName = strdup( "Physical Location" ); ret->cpuCount = 1; } return ret; newsyserr: free_system( ret ); return NULL; } struct system * unpack_system( void * buffer ) { struct system *ret = NULL; u32 size = 0, netOrder; char *packed = (char*)buffer; char * next; struct list *item; struct dataitem *data; if( !buffer ) return ret; ret = new_system( 0 ); if( !ret ) return ret; memcpy( &netOrder, packed, sizeof( u32 ) ); size = ntohl( netOrder ); next = packed + sizeof( u32 ); memcpy( &netOrder, next, sizeof( u32 ) ); ret->cpuCount = ntohl( netOrder ); next = next + sizeof( u32 ); ret->id = unpack_dataitem( next ); if( !ret->id ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->id ); ret->arch = unpack_dataitem( next ); if( !ret->arch ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->arch ); ret->deviceTreeNode = unpack_dataitem( next ); if( !ret->deviceTreeNode ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->deviceTreeNode ); ret->description = unpack_dataitem( next ); if( !ret->description ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->description ); ret->brand = unpack_dataitem( next ); if( !ret->brand ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->brand ); ret->nodeName = unpack_dataitem( next ); if( !ret->nodeName ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->nodeName ); ret->os = unpack_dataitem( next ); if( !ret->os ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->os ); ret->processorID = unpack_dataitem( next ); if( !ret->processorID ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->processorID ); ret->machineType = unpack_dataitem( next ); if( !ret->machineType ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->machineType ); ret->machineModel = unpack_dataitem( next ); if( !ret->machineModel ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->machineModel ); ret->featureCode = unpack_dataitem( next ); if( !ret->featureCode ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->featureCode ); ret->flagField = unpack_dataitem( next ); if( !ret->flagField ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->flagField ); ret->recordType = unpack_dataitem( next ); if( !ret->recordType ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->recordType ); ret->serialNum1 = unpack_dataitem( next ); if( !ret->serialNum1 ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->serialNum1 ); ret->serialNum2 = unpack_dataitem( next ); if( !ret->serialNum2 ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->serialNum2 ); ret->suid = unpack_dataitem( next ); if( !ret->suid ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->suid ); ret->keywordVersion = unpack_dataitem( next ); if( !ret->keywordVersion ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->keywordVersion ); ret->locationCode = unpack_dataitem( next ); if( !ret->locationCode ) goto unpackerr; next = next + calc_packed_length_dataitem( ret->locationCode ); while( 0 != strncmp( next, CHILD_START, strlen( CHILD_START ) ) ) { next++; if( next > packed + size ) goto unpackerr; } if( strncmp( next, CHILD_START, strlen( CHILD_START ) ) == 0 ) { next = next + strlen( CHILD_START ) + 1; if( next > packed + size ) goto unpackerr; while( strncmp( next, CHILD_END, strlen( CHILD_END ) ) != 0 ) { item = new_list( ); if( !next ) goto unpackerr; item->data = strdup( next ); next = next + strlen( (char*)item->data ) + 1; if( !ret->childrenIDs ) ret->childrenIDs = item; else concat_list( ret->childrenIDs, item ); if( next > packed + size ) goto unpackerr; } next = next + strlen( CHILD_END ) + 1; } if( strncmp( next, DEVICE_START, strlen( DEVICE_START ) ) == 0 ) { next = next + strlen( DEVICE_START ) + 1; if( next > packed + size ) goto unpackerr; while( strncmp( next, DEVICE_END, strlen( DEVICE_END ) ) != 0 ) { data = unpack_dataitem( next ); if( !data ) goto unpackerr; next = next + calc_packed_length_dataitem( data ); if( !ret->deviceSpecific ) ret->deviceSpecific = data; else add_dataitem( ret->deviceSpecific, data ); if( next > packed + size ) goto unpackerr; } next = next + strlen( DEVICE_END ) + 1; } if( strncmp( next, USER_START, strlen( USER_START ) ) == 0 ) { next = next + strlen( USER_START ) + 1; if( next > packed + size ) goto unpackerr; while( strncmp( next, USER_END, strlen( USER_END ) ) != 0 ) { data = unpack_dataitem( next ); if( !data ) goto unpackerr; next = next + calc_packed_length_dataitem( data ); if( !ret->userData ) ret->userData = data; else add_dataitem( ret->userData, data ); if( next > packed + size ) goto unpackerr; } } return ret; unpackerr: free_system( ret ); return NULL; } void free_system( struct system *freeme ) { if( !freeme ) return; free_dataitem( freeme->id ); free_dataitem( freeme->description ); free_dataitem( freeme->arch ); free_dataitem( freeme->deviceTreeNode ); free_dataitem( freeme->brand ); free_dataitem( freeme->nodeName ); free_dataitem( freeme->os ); free_dataitem( freeme->processorID ); free_dataitem( freeme->machineType ); free_dataitem( freeme->machineModel ); free_dataitem( freeme->featureCode ); free_dataitem( freeme->flagField ); free_dataitem( freeme->recordType ); free_dataitem( freeme->serialNum1 ); free_dataitem( freeme->serialNum2 ); free_dataitem( freeme->suid ); free_dataitem( freeme->keywordVersion ); free_dataitem( freeme->locationCode ); free_dataitem( freeme->deviceSpecific ); free_dataitem( freeme->userData ); free_list( freeme->childrenIDs ); free( freeme ); } libvpd-2.2.3/ChangeLog0000664000175000017500000000042312310042633015077 0ustar suzukikpsuzukikp2.2.3 Restrict vpdupdate triggers to device change events 2.2.2 Automate vpdupdate 2.1.3 Fix numbering of .so files, per bug #69369. 2.1.0 Rebuild rpms for ppc 32-bit. 2.0.1 Updating/fixing C API. Adding configure time check for which slqite_prepare function to use libvpd-2.2.3/debian/0000775000175000017500000000000012310042633014550 5ustar suzukikpsuzukikplibvpd-2.2.3/debian/compat0000775000175000017500000000000212310042633015751 0ustar suzukikpsuzukikp5 libvpd-2.2.3/debian/docs0000775000175000017500000000003112310042633015420 0ustar suzukikpsuzukikpINSTALL NEWS README TODO libvpd-2.2.3/debian/postrm.debhelper0000775000175000017500000000011212310042633017745 0ustar suzukikpsuzukikp# Automatically added by dh_installinit # End automatically added section libvpd-2.2.3/debian/libvpd.postinst.debhelper0000664000175000017500000000016612310042633021571 0ustar suzukikpsuzukikp# Automatically added by dh_makeshlibs if [ "$1" = "configure" ]; then ldconfig fi # End automatically added section libvpd-2.2.3/debian/libvpd.prerm.debhelper0000664000175000017500000000011212310042633021022 0ustar suzukikpsuzukikp# Automatically added by dh_installinit # End automatically added section libvpd-2.2.3/debian/copyright0000775000175000017500000000215012310042633016504 0ustar suzukikpsuzukikpThis package was debianized by Eric Munson ebmunson@us.ibm.com on Wed, 26 Sept 2007 10:21:01 -0800 It was downloaded from http://linux-diag.sourceforge.net/ (C) Copyright IBM Corp. 2007 Written by Eric Munson , Brad Peters . These programs are free software; you can redistribute and/or modify libvpd under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. On Debian GNU/Linux systems, the complete text of the GNU Lesser General Public License can be found in `/usr/share/common-licenses/LGPL'. libvpd-2.2.3/debian/files0000664000175000017500000000005112310042633015571 0ustar suzukikpsuzukikplibvpd_1.3.4-1_i386.deb unknown optional libvpd-2.2.3/debian/rules0000775000175000017500000000514412310042633015634 0ustar suzukikpsuzukikp#!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # # Modified to make a template file for a multi-binary package with separated # build-arch and build-indep targets by Bill Allombert 2001 # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This has to be exported to make some magic below work. export DH_OPTIONS CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif configure: configure-stamp configure-stamp: dh_testdir ./configure --prefix=/usr/ touch configure-stamp #Architecture build: build-arch build-indep build-arch: build-arch-stamp build-arch-stamp: configure-stamp # Add here commands to compile the arch part of the package. $(MAKE) touch $@ build-indep: build-indep-stamp build-indep-stamp: configure-stamp # Add here commands to compile the indep part of the package. #$(MAKE) doc touch $@ clean: dh_testdir dh_testroot rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP# # Add here commands to clean up after the build process. $(MAKE) clean dh_clean install: install-indep install-arch install-indep: dh_testdir dh_testroot dh_clean -k -i dh_installdirs -i # Add here commands to install the indep part of the package into # debian/-doc. #INSTALLDOC# dh_install -i install-arch: dh_testdir dh_testroot dh_clean -k -s dh_installdirs -s # Add here commands to install the arch part of the package into # debian/tmp. $(MAKE) DESTDIR=$(CURDIR)/debian/lsvpd install dh_install -s # Must not depend on anything. This is to be called by # binary-arch/binary-indep # in another 'make' thread. binary-common: dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_installexamples dh_installman dh_link dh_strip dh_compress dh_fixperms dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # Build architecture independant packages using the common target. binary-indep: build-indep install-indep $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common # Build architecture dependant packages using the common target. binary-arch: build-arch install-arch $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common binary: binary-arch binary-indep .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure libvpd-2.2.3/debian/libvpd-doc.install0000664000175000017500000000001012310042633020152 0ustar suzukikpsuzukikp#DOCS# libvpd-2.2.3/debian/prerm.debhelper0000775000175000017500000000011212310042633017546 0ustar suzukikpsuzukikp# Automatically added by dh_installinit # End automatically added section libvpd-2.2.3/debian/control0000775000175000017500000000065412310042633016163 0ustar suzukikpsuzukikpSource: libvpd Section: unknown Priority: optional Maintainer: Eric Munson Build-Depends: debhelper (>= 5), libdb4.3++-dev, zlib1g-dev, libc6-dev, libstdc++-dev, Standards-Version: 3.7.2 Package: lsvpd Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, udev Provides: libvpd Description: A C++ library for access to information collected by lsvpd, a VPD/hardware inventory collection tool. libvpd-2.2.3/debian/changelog.in0000664000175000017500000000022612310042633017027 0ustar suzukikpsuzukikplibvpd (@VERSION@-1) unstable; urgency=low * See NEWS. -- Eric Munson @DATE@ -- Brad Peters @DATE@ libvpd-2.2.3/debian/postinst0000775000175000017500000000167512310042633016372 0ustar suzukikpsuzukikp#!/bin/sh # postinst script for lsvpd # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in configure) ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0 libvpd-2.2.3/debian/libvpd.postrm.debhelper0000664000175000017500000000016312310042633021227 0ustar suzukikpsuzukikp# Automatically added by dh_makeshlibs if [ "$1" = "remove" ]; then ldconfig fi # End automatically added section libvpd-2.2.3/debian/prerm0000775000175000017500000000003212310042633015616 0ustar suzukikpsuzukikp#!/bin/sh -e #DEBHELPER# libvpd-2.2.3/debian/postinst.debhelper0000775000175000017500000000011212310042633020304 0ustar suzukikpsuzukikp# Automatically added by dh_installinit # End automatically added section libvpd-2.2.3/debian/README.debian0000775000175000017500000000021012310042633016645 0ustar suzukikpsuzukikplibvpd for Debian ---------------------- libvpd package for Debian Eric Munson Brad Peters libvpd-2.2.3/debian/libvpd-doc.docs0000664000175000017500000000001012310042633017434 0ustar suzukikpsuzukikp#DOCS# libvpd-2.2.3/90-vpdupdate.rules0000664000175000017500000000014112310042633016620 0ustar suzukikpsuzukikpKERNELS=="*", ACTION=="*", DEVPATH=="/devices/*", RUN+="/bin/touch /var/lib/lsvpd/run.vpdupdate" libvpd-2.2.3/INSTALL0000664000175000017500000001575112310042633014370 0ustar suzukikpsuzukikpBasic Installation ================== If building from source, start by executing the bootstrap.sh script. This will run a number of autoconf pre-requisites, resulting in a "configure" script fit for your system. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type './bootstrap.sh' 2. Type `./configure --prefix=/usr' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes a while. While running, it prints some messages telling which features it is checking for. 3. Type `make' to compile the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options.