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

Function print_string

tools/ifconfig/ifieee80211.c:5672–5701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5670}
5671
5672static void
5673print_string(const u_int8_t *buf, int len)
5674{
5675 int i;
5676 int hasspc;
5677 int utf8;
5678
5679 i = 0;
5680 hasspc = 0;
5681
5682 setlocale(LC_CTYPE, "");
5683 utf8 = strncmp("UTF-8", nl_langinfo(CODESET), 5) == 0;
5684
5685 for (; i < len; i++) {
5686 if (!isprint(buf[i]) && buf[i] != '\0' && !utf8)
5687 break;
5688 if (isspace(buf[i]))
5689 hasspc++;
5690 }
5691 if (i == len || utf8) {
5692 if (hasspc || len == 0 || buf[0] == '\0')
5693 printf("\"%.*s\"", len, buf);
5694 else
5695 printf("%.*s", len, buf);
5696 } else {
5697 printf("0x");
5698 for (i = 0; i < len; i++)
5699 printf("%02x", buf[i]);
5700 }
5701}
5702
5703static void
5704setdefregdomain(int s)

Callers 1

ieee80211_statusFunction · 0.85

Calls 4

strncmpFunction · 0.85
isprintFunction · 0.85
isspaceFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected