| 1096 | } |
| 1097 | |
| 1098 | static int |
| 1099 | oidfmt(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 |