David Rose 20 лет назад
Родитель
Сommit
c9c13dc10f

+ 27 - 0
panda/src/express/hashVal.cxx

@@ -164,6 +164,33 @@ set_from_hex(const string &text) {
   return !strm.fail();
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: HashVal::as_bin
+//       Access: Published
+//  Description: Returns the HashVal as a 16-byte binary string.
+////////////////////////////////////////////////////////////////////
+string HashVal::
+as_bin() const {
+  Datagram dg;
+  write_datagram(dg);
+  return dg.get_message();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: HashVal::set_from_bin
+//       Access: Published
+//  Description: Sets the HashVal from a 16-byte binary string.
+//               Returns true if successful, false otherwise.
+////////////////////////////////////////////////////////////////////
+bool HashVal::
+set_from_bin(const string &text) {
+  nassertr(text.size() == 16, false);
+  Datagram dg(text);
+  DatagramIterator dgi(dg);
+  read_datagram(dgi);
+  return true;
+}
+
 #ifdef HAVE_OPENSSL
 ////////////////////////////////////////////////////////////////////
 //     Function: HashVal::hash_file

+ 3 - 0
panda/src/express/hashVal.h

@@ -61,6 +61,9 @@ PUBLISHED:
   string as_hex() const;
   bool set_from_hex(const string &text);
 
+  string as_bin() const;
+  bool set_from_bin(const string &text);
+
   INLINE void write_datagram(Datagram &destination) const;
   INLINE void read_datagram(DatagramIterator &source);
   INLINE void write_stream(StreamWriter &destination) const;

+ 20 - 0
panda/src/putil/load_prc_file.cxx

@@ -18,9 +18,11 @@
 
 #include "load_prc_file.h"
 #include "configPageManager.h"
+#include "configVariableManager.h"
 #include "virtualFileSystem.h"
 #include "config_express.h"
 #include "config_util.h"
+#include "hashVal.h"
 
 ////////////////////////////////////////////////////////////////////
 //     Function: load_prc_file
@@ -121,3 +123,21 @@ unload_prc_file(ConfigPage *page) {
   return cp_mgr->delete_explicit_page(page);
 }
 
+
+#ifdef HAVE_OPENSSL
+
+////////////////////////////////////////////////////////////////////
+//     Function: hash_prc_variables
+//  Description: Fills HashVal with the hash from the current prc file
+//               state as reported by
+//               ConfigVariableManager::write_prc_variables().
+////////////////////////////////////////////////////////////////////
+void
+hash_prc_variables(HashVal &hash) {
+  ostringstream strm;
+  ConfigVariableManager *cv_mgr = ConfigVariableManager::get_global_ptr();
+  cv_mgr->write_prc_variables(strm);
+  hash.hash_string(strm.str());
+}
+
+#endif  // HAVE_OPENSSL

+ 16 - 0
panda/src/putil/load_prc_file.h

@@ -22,6 +22,7 @@
 #include "pandabase.h"
 
 class ConfigPage;
+class HashVal;
 
 BEGIN_PUBLISH
 ////////////////////////////////////////////////////////////////////
@@ -69,6 +70,21 @@ load_prc_file_data(const string &name, const string &data);
 ////////////////////////////////////////////////////////////////////
 EXPCL_PANDA bool
 unload_prc_file(ConfigPage *page);
+
+#ifdef HAVE_OPENSSL
+
+////////////////////////////////////////////////////////////////////
+//     Function: hash_prc_variables
+//  Description: Fills HashVal with the hash from the current prc file
+//               state as reported by
+//               ConfigVariableManager::write_prc_variables().
+////////////////////////////////////////////////////////////////////
+EXPCL_PANDA void
+hash_prc_variables(HashVal &hash);
+
+#endif  // HAVE_OPENSSL
+
+
 END_PUBLISH
 
 #endif