MCPcopy Index your code
hub / github.com/F-Stack/f-stack / oidfmt

Function oidfmt

tools/sysctl/sysctl.c:1098–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1096}
1097
1098static int
1099oidfmt(int *oid, int len, char *fmt, u_int *kind)
1100{
1101 int qoid[CTL_MAXNAME+2];
1102 u_char buf[BUFSIZ];
1103 int i;
1104 size_t j;
1105
1106 qoid[0] = CTL_SYSCTL;
1107 qoid[1] = CTL_SYSCTL_OIDFMT;
1108 memcpy(qoid + 2, oid, len * sizeof(int));
1109
1110 j = sizeof(buf);
1111 i = sysctl(qoid, len + 2, buf, &j, 0, 0);
1112 if (i)
1113 err(1, "sysctl fmt %d %zu %d", i, j, errno);
1114
1115 if (kind)
1116 *kind = *(u_int *)buf;
1117
1118 if (fmt)
1119 strcpy(fmt, (char *)(buf + sizeof(u_int)));
1120 return (0);
1121}
1122
1123/*
1124 * This formats and outputs the value of one variable

Callers 2

parseFunction · 0.85
show_varFunction · 0.85

Calls 2

sysctlFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected