remove kerberos/heimdal
[dragonfly.git] / lib / libc / gen / sysctlbyname.c
blob74de709189d650d3fe4cd7598cb62aec5c64aca5
1 /*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
9 * $FreeBSD: src/lib/libc/gen/sysctlbyname.c,v 1.4 1999/08/27 23:59:01 peter Exp $
10 * $DragonFly: src/lib/libc/gen/sysctlbyname.c,v 1.2 2003/06/17 04:26:42 dillon Exp $
13 #include <sys/types.h>
14 #include <sys/sysctl.h>
15 #include <string.h>
17 int
18 sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp,
19 size_t newlen)
21 int name2oid_oid[2];
22 int real_oid[CTL_MAXNAME+2];
23 int error;
24 size_t oidlen;
26 name2oid_oid[0] = 0; /* This is magic & undocumented! */
27 name2oid_oid[1] = 3;
29 oidlen = sizeof(real_oid);
30 error = sysctl(name2oid_oid, 2, real_oid, &oidlen, (void *)name,
31 strlen(name));
32 if (error < 0)
33 return error;
34 oidlen /= sizeof (int);
35 error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
36 return (error);