Lines 72-78
Link Here
|
72 |
static const char *conffile; |
72 |
static const char *conffile; |
73 |
|
73 |
|
74 |
static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag; |
74 |
static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag; |
75 |
static int Nflag, nflag, oflag, qflag, Tflag, Wflag, xflag; |
75 |
static int Nflag, nflag, oflag, qflag, tflag, Tflag, Wflag, xflag; |
76 |
|
76 |
|
77 |
static int oidfmt(int *, int, char *, u_int *); |
77 |
static int oidfmt(int *, int, char *, u_int *); |
78 |
static int parsefile(const char *); |
78 |
static int parsefile(const char *); |
Lines 105-110
Link Here
|
105 |
[CTLTYPE_ULONG] = "unsigned long", |
105 |
[CTLTYPE_ULONG] = "unsigned long", |
106 |
[CTLTYPE_S64] = "int64_t", |
106 |
[CTLTYPE_S64] = "int64_t", |
107 |
[CTLTYPE_U64] = "uint64_t", |
107 |
[CTLTYPE_U64] = "uint64_t", |
|
|
108 |
[CTLTYPE_NODE] = "node", |
109 |
[CTLTYPE_STRING] = "string", |
110 |
[CTLTYPE_OPAQUE] = "opaque", |
108 |
}; |
111 |
}; |
109 |
|
112 |
|
110 |
static void |
113 |
static void |
Lines 112-119
Link Here
|
112 |
{ |
115 |
{ |
113 |
|
116 |
|
114 |
(void)fprintf(stderr, "%s\n%s\n", |
117 |
(void)fprintf(stderr, "%s\n%s\n", |
115 |
"usage: sysctl [-bdehiNnoqTWx] [ -B <bufsize> ] [-f filename] name[=value] ...", |
118 |
"usage: sysctl [-bdehiNnoqTtWx] [ -B <bufsize> ] [-f filename] name[=value] ...", |
116 |
" sysctl [-bdehNnoqTWx] [ -B <bufsize> ] -a"); |
119 |
" sysctl [-bdehNnoqTtWx] [ -B <bufsize> ] -a"); |
117 |
exit(1); |
120 |
exit(1); |
118 |
} |
121 |
} |
119 |
|
122 |
|
Lines 127-133
Link Here
|
127 |
setbuf(stdout,0); |
130 |
setbuf(stdout,0); |
128 |
setbuf(stderr,0); |
131 |
setbuf(stderr,0); |
129 |
|
132 |
|
130 |
while ((ch = getopt(argc, argv, "AabB:def:hiNnoqTwWxX")) != -1) { |
133 |
while ((ch = getopt(argc, argv, "AabB:def:hiNnoqtTwWxX")) != -1) { |
131 |
switch (ch) { |
134 |
switch (ch) { |
132 |
case 'A': |
135 |
case 'A': |
133 |
/* compatibility */ |
136 |
/* compatibility */ |
Lines 169-174
Link Here
|
169 |
case 'q': |
172 |
case 'q': |
170 |
qflag = 1; |
173 |
qflag = 1; |
171 |
break; |
174 |
break; |
|
|
175 |
case 't': |
176 |
tflag = 1; |
177 |
break; |
172 |
case 'T': |
178 |
case 'T': |
173 |
Tflag = 1; |
179 |
Tflag = 1; |
174 |
break; |
180 |
break; |
Lines 795-801
Link Here
|
795 |
{ |
801 |
{ |
796 |
u_char buf[BUFSIZ], *val, *oval, *p; |
802 |
u_char buf[BUFSIZ], *val, *oval, *p; |
797 |
char name[BUFSIZ], fmt[BUFSIZ]; |
803 |
char name[BUFSIZ], fmt[BUFSIZ]; |
798 |
const char *sep, *sep1; |
804 |
const char *sep, *sep1, *prntype; |
799 |
int qoid[CTL_MAXNAME+2]; |
805 |
int qoid[CTL_MAXNAME+2]; |
800 |
uintmax_t umv; |
806 |
uintmax_t umv; |
801 |
intmax_t mv; |
807 |
intmax_t mv; |
Lines 841-852
Link Here
|
841 |
else |
847 |
else |
842 |
sep = ": "; |
848 |
sep = ": "; |
843 |
|
849 |
|
844 |
if (dflag) { /* just print description */ |
850 |
ctltype = (kind & CTLTYPE); |
|
|
851 |
if (tflag || dflag) { /* just print type and/or description */ |
852 |
if (!nflag) |
853 |
printf("%s%s", name, sep); |
854 |
prntype = ctl_typename[ctltype] ? |
855 |
ctl_typename[ctltype] : "unknown"; |
856 |
if (tflag && dflag) /* print type and description */ |
857 |
printf("%s%s", prntype, sep); |
858 |
else if (tflag) { /* print type only */ |
859 |
printf("%s", prntype); |
860 |
return (0); |
861 |
} |
845 |
qoid[1] = 5; |
862 |
qoid[1] = 5; |
846 |
j = sizeof(buf); |
863 |
j = sizeof(buf); |
847 |
i = sysctl(qoid, nlen + 2, buf, &j, 0, 0); |
864 |
i = sysctl(qoid, nlen + 2, buf, &j, 0, 0); |
848 |
if (!nflag) |
|
|
849 |
printf("%s%s", name, sep); |
850 |
printf("%s", buf); |
865 |
printf("%s", buf); |
851 |
return (0); |
866 |
return (0); |
852 |
} |
867 |
} |
Lines 864-870
Link Here
|
864 |
warnx("malloc failed"); |
879 |
warnx("malloc failed"); |
865 |
return (1); |
880 |
return (1); |
866 |
} |
881 |
} |
867 |
ctltype = (kind & CTLTYPE); |
|
|
868 |
len = j; |
882 |
len = j; |
869 |
i = sysctl(oid, nlen, val, &len, 0, 0); |
883 |
i = sysctl(oid, nlen, val, &len, 0, 0); |
870 |
if (i != 0 || (len == 0 && ctltype != CTLTYPE_STRING)) { |
884 |
if (i != 0 || (len == 0 && ctltype != CTLTYPE_STRING)) { |