Exposes GetDefaultInstance() in host_config api
Bug: 73011528
Change-Id: Ic00c13175132ebd30a928832c5c0769b2fc25f70
diff --git a/host/libs/config/host_config.cpp b/host/libs/config/host_config.cpp
index cc0218d..14acdd8 100644
--- a/host/libs/config/host_config.cpp
+++ b/host/libs/config/host_config.cpp
@@ -27,7 +27,14 @@
const char kVsocUserPrefix[] = "vsoc-";
const char kDefaultUuidPrefix[] = "699acfc4-c8c4-11e7-882b-5065f31dc1";
-int GetDefaultInstance() {
+DEFINE_string(domain, vsoc::GetDefaultShmClientSocketPath(),
+ "Path to the ivshmem client socket");
+DEFINE_int32(instance, vsoc::GetDefaultInstance(),
+ "Instance number. Must be unique.");
+DEFINE_string(uuid, vsoc::GetPerInstanceDefault(kDefaultUuidPrefix).c_str(),
+ "UUID to use for the device. Random if not specified");
+
+int vsoc::GetDefaultInstance() {
char* user = getenv("USER");
if (user && !memcmp(user, kVsocUserPrefix, sizeof(kVsocUserPrefix) - 1)) {
int temp = atoi(user + sizeof(kVsocUserPrefix) - 1);
@@ -38,13 +45,6 @@
return 1;
}
-DEFINE_string(domain, vsoc::GetDefaultShmClientSocketPath(),
- "Path to the ivshmem client socket");
-DEFINE_int32(instance, GetDefaultInstance(),
- "Instance number. Must be unique.");
-DEFINE_string(uuid, vsoc::GetPerInstanceDefault(kDefaultUuidPrefix).c_str(),
- "UUID to use for the device. Random if not specified");
-
std::string vsoc::GetPerInstanceDefault(const char* prefix) {
std::ostringstream stream;
stream << prefix << std::setfill('0') << std::setw(2)
diff --git a/host/libs/config/host_config.h b/host/libs/config/host_config.h
index 65ef523..15d2059 100644
--- a/host/libs/config/host_config.h
+++ b/host/libs/config/host_config.h
@@ -21,6 +21,7 @@
#include <string>
namespace vsoc {
+int GetDefaultInstance();
std::string GetPerInstanceDefault(const char* prefix);
int GetPerInstanceDefault(int base);
std::string GetDefaultPerInstanceDir();