From owner-freebsd-hackers Tue Jul 11 19:16: 0 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id 555D337B673; Tue, 11 Jul 2000 19:15:54 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id UAA50802; Tue, 11 Jul 2000 20:15:52 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id UAA09795; Tue, 11 Jul 2000 20:15:46 -0600 (MDT) Message-Id: <200007120215.UAA09795@harmony.village.org> To: "Gary T. Corcoran" Subject: Re: Module parameters? Cc: Mike Smith , FreeBSD Hackers In-reply-to: Your message of "Tue, 11 Jul 2000 22:01:47 EDT." <396BD18B.9155B046@lucent.com> References: <396BD18B.9155B046@lucent.com> <396BC2C5.E89AD827@lucent.com> <200007112355.QAA00803@mass.osd.bsdi.com> <200007112352.RAA08554@harmony.village.org> <200007120148.TAA09591@harmony.village.org> Date: Tue, 11 Jul 2000 20:15:46 -0600 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Something like the following? I know that there's more routines that need to be written. parse_int, parse_string, parse_bool, parse_enum should be enough. Comments? struct driver_param { const char *name; int (*fnp)(const char *, void *, void *); size_t off; void *argp; }; int get_parameters(device_t dev, struct driver_param *param, size_t nparam) { int i; caddr_t sc; const char *name; int unit; char buffer[1024]; const char *cp; sc = device_get_softc(dev); name = device_get_name(dev); unit = device_get_unit(dev); for (i = 0; i < nparam; i++) { snprintf(buffer, "hints.%s.%d.%s", name, unit, param[i].name); cp = getenv (buffer); if (cp) { if (param[i].fnp(cp, (void *) (sc + param[i].off), param[i].argp) == 0) continue; } snprintf(buffer, "hints.%s.%d.%s", name, -1, param[i].name); cp = getenv (buffer); if (cp) { if (param[i].fnp(cp, (void *) (sc + param[i].off), param[i].argp) == 0) continue; } } return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message