MCPcopy Create free account
hub / github.com/apache/brpc / str2endpoint

Function str2endpoint

src/butil/endpoint.cpp:267–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267int str2endpoint(const char* str, EndPoint* point) {
268 if (ExtendedEndPoint::create(str, point)) {
269 return 0;
270 }
271
272 // Should be enough to hold ip address
273 char buf[64];
274 size_t i = 0;
275 for (; i < sizeof(buf) && str[i] != '\0' && str[i] != ':'; ++i) {
276 buf[i] = str[i];
277 }
278 if (i >= sizeof(buf) || str[i] != ':') {
279 return -1;
280 }
281 buf[i] = '\0';
282 if (str2ip(buf, &point->ip) != 0) {
283 return -1;
284 }
285 ++i;
286 char* end = NULL;
287 point->port = strtol(str + i, &end, 10);
288 if (end == str + i) {
289 return -1;
290 } else if (*end) {
291 for (; isspace(*end); ++end);
292 if (*end) {
293 return -1;
294 }
295 }
296 if (point->port < 0 || point->port > 65535) {
297 return -1;
298 }
299 return 0;
300}
301
302int str2endpoint(const char* ip_str, int port, EndPoint* point) {
303 if (ExtendedEndPoint::create(ip_str, port, point)) {

Callers 15

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
TrackMeMethod · 0.85
mainFunction · 0.85
HandshakeWithServerMethod · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85

Calls 1

str2ipFunction · 0.85

Tested by 15

mainFunction · 0.68
HandshakeWithServerMethod · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TestShutdownWriteFunction · 0.68
TESTFunction · 0.68
test_listen_connectFunction · 0.68
test_parse_and_serializeFunction · 0.68
concurrent_procFunction · 0.68