psutils: Move utility functions to utils.*pp

The files named version.hpp and version.cpp implement the --get-version
option of the psutils tool.

However, the files also contain some utility functions that would be
helpful for implementing other command line options, such as --update or
the planned new option --get-model.

Move the utility functions into new files named utils.hpp and utils.cpp.
The functions will be defined within a namespace named 'utils'.

Tested:
* Verified automated testcases ran successfully
* Verified --get-version option worked correctly
  * When using a psu.json file
  * When using D-Bus information

Change-Id: If902ee4581fce000af37073ac2e7a7b0ade01f78
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/tools/power-utils/utils.hpp b/tools/power-utils/utils.hpp
new file mode 100644
index 0000000..4c86b54
--- /dev/null
+++ b/tools/power-utils/utils.hpp
@@ -0,0 +1,88 @@
+/**
+ * Copyright © 2024 IBM Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include "pmbus.hpp"
+
+#include <sdbusplus/bus.hpp>
+
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <tuple>
+
+/**
+ * @namespace utils
+ *
+ * Contains utility functions used within the psutils tool.
+ */
+namespace utils
+{
+
+// PsuI2cInfo contains the device i2c bus and i2c address
+using PsuI2cInfo = std::tuple<std::uint64_t, std::uint64_t>;
+
+/**
+ * @brief Get i2c bus and address
+ *
+ * @param[in] bus - Systemd bus connection
+ * @param[in] psuInventoryPath - The PSU inventory path.
+ *
+ * @return tuple - i2cBus and i2cAddr.
+ */
+PsuI2cInfo getPsuI2c(sdbusplus::bus_t& bus,
+                     const std::string& psuInventoryPath);
+
+/**
+ * @brief Get PMBus interface pointer
+ *
+ * @param[in] i2cBus - PSU i2c bus
+ * @param[in] i2cAddr - PSU i2c address
+ *
+ * @return Pointer to PSU PMBus interface
+ */
+std::unique_ptr<phosphor::pmbus::PMBusBase>
+    getPmbusIntf(std::uint64_t i2cBus, std::uint64_t i2cAddr);
+
+/**
+ * @brief Reads a VPD value from PMBus, corrects size, and contents.
+ *
+ * If the VPD data read is not the passed in size, resize and fill with
+ * spaces. If the data contains a non-alphanumeric value, replace any of
+ * those values with spaces.
+ *
+ * @param[in] pmbusIntf - PMBus Interface.
+ * @param[in] vpdName - The name of the sysfs "file" to read data from.
+ * @param[in] type - The HWMON file type to read from.
+ * @param[in] vpdSize - The expected size of the data for this VPD/property
+ *
+ * @return A string containing the VPD data read, resized if necessary
+ */
+std::string readVPDValue(phosphor::pmbus::PMBusBase& pmbusIntf,
+                         const std::string& vpdName,
+                         const phosphor::pmbus::Type& type,
+                         const std::size_t& vpdSize);
+
+/**
+ * @brief Check for file existence
+ *
+ * @param[in] filePath - File path
+ *
+ * @return bool
+ */
+bool checkFileExists(const std::string& filePath);
+
+} // namespace utils