MCPcopy Create free account
hub / github.com/F-Stack/f-stack / p_sockaddr

Function p_sockaddr

tools/netstat/route.c:375–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375int
376p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask,
377 int flags, int width)
378{
379 const char *cp;
380 char buf[128];
381 int protrusion;
382
383 cp = fmt_sockaddr(sa, mask, flags);
384
385 if (width < 0) {
386 snprintf(buf, sizeof(buf), "{:%s/%%s} ", name);
387 xo_emit(buf, cp);
388 protrusion = 0;
389 } else {
390 if (Wflag != 0 || numeric_addr) {
391 snprintf(buf, sizeof(buf), "{[:%d}{:%s/%%s}{]:} ",
392 -width, name);
393 xo_emit(buf, cp);
394 protrusion = strlen(cp) - width;
395 if (protrusion < 0)
396 protrusion = 0;
397 } else {
398 snprintf(buf, sizeof(buf), "{[:%d}{:%s/%%-.*s}{]:} ",
399 -width, name);
400 xo_emit(buf, width, cp);
401 protrusion = 0;
402 }
403 }
404 return (protrusion);
405}
406
407const char *
408fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags)

Callers 2

print_nhop_entry_sysctlFunction · 0.70
p_rtentry_sysctlFunction · 0.70

Calls 3

fmt_sockaddrFunction · 0.85
snprintfFunction · 0.85
xo_emitFunction · 0.85

Tested by

no test coverage detected