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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message