Add a helper function findFruAreaLocationAndField to
updateFRUProperty

Refactoring updateFRUProperty function and created a new helper
function findFruAreaLocationAndField. Moved this function to
fru_utils.cpp as it is common for all fru-device deamons and
avoid code duplication.

This patch is created based on suggestion on the below patch.
https://gerrit.openbmc.org/c/openbmc/entity-manager/+/51555

TESTED : Built Facebook YosemiteV2 images and loaded
on the target hardware. Verified all the fru's read and write.

Signed-off-by: Kumar Thangavel <thangavel.k@hcl.com>
Change-Id: I82265e66ea5db10003e96978979250ea45c2052d
diff --git a/include/fru_utils.hpp b/include/fru_utils.hpp
index e50b580..f1d8e94 100644
--- a/include/fru_utils.hpp
+++ b/include/fru_utils.hpp
@@ -62,6 +62,14 @@
     fruAreaMultirecord
 };
 
+struct FruArea
+{
+    size_t start;          // Fru Area Start offset
+    size_t size;           // Fru Area Size
+    size_t end;            // Fru Area end offset
+    size_t updateFieldLoc; // Fru Area update Field Location
+};
+
 const std::vector<std::string> fruAreaNames = {"INTERNAL", "CHASSIS", "BOARD",
                                                "PRODUCT", "MULTIRECORD"};
 const std::regex nonAsciiRegex("[^\x01-\x7f]");
@@ -157,3 +165,15 @@
 /// \param area - the area
 /// \return the field offset
 unsigned int getHeaderAreaFieldOffset(fruAreas area);
+
+/// \brief Iterate fruArea Names and find offset/location and fields and size of
+/// properties
+/// \param fruData - vector to store fru data
+/// \param propertyName - fru property Name
+/// \param fruAreaParams - struct to have fru Area paramteters like length,
+/// size. \return true if fru field is found, fruAreaParams are updated with
+/// fruArea and field info.
+bool findFruAreaLocationAndField(std::vector<uint8_t>& fruData,
+                                 const std::string& propertyName,
+                                 struct FruArea& fruAreaParams,
+                                 size_t& fruDataIter);