MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ParseAddress

Function ParseAddress

src/ipc/process.cpp:71–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71static bool ParseAddress(std::string& address,
72 const fs::path& data_dir,
73 const std::string& dest_exe_name,
74 struct sockaddr_un& addr,
75 std::string& error)
76{
77 if (address == "unix" || address.starts_with("unix:")) {
78 fs::path path;
79 if (address.size() <= 5) {
80 path = data_dir / fs::PathFromString(strprintf("%s.sock", RemovePrefixView(dest_exe_name, "bitcoin-")));
81 } else {
82 path = data_dir / fs::PathFromString(address.substr(5));
83 }
84 std::string path_str = fs::PathToString(path);
85 address = strprintf("unix:%s", path_str);
86 if (path_str.size() >= sizeof(addr.sun_path)) {
87 error = strprintf("Unix address path %s exceeded maximum socket path length", fs::quoted(fs::PathToString(path)));
88 return false;
89 }
90 memset(&addr, 0, sizeof(addr));
91 addr.sun_family = AF_UNIX;
92 strncpy(addr.sun_path, path_str.c_str(), sizeof(addr.sun_path)-1);
93 return true;
94 }
95
96 error = strprintf("Unrecognized address '%s'", address);
97 return false;
98}
99
100int ProcessImpl::connect(const fs::path& data_dir,
101 const std::string& dest_exe_name,

Callers 2

connectMethod · 0.85
bindMethod · 0.85

Calls 5

PathFromStringFunction · 0.85
RemovePrefixViewFunction · 0.85
PathToStringFunction · 0.85
quotedFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected