Add a get_driver_settings debugging tool

This commit is contained in:
François Revol 2017-11-20 11:23:34 +01:00
parent d1805b9a36
commit 587b70d5cd
2 changed files with 52 additions and 0 deletions

View File

@ -35,6 +35,7 @@ StdBinCommands
fortune.c
finddir.c
fstrim.cpp
get_driver_settings.cpp
hd.c
listarea.c
listimage.c

View File

@ -0,0 +1,51 @@
/*
* Copyright 2017, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* <François Revol>
*/
#include <stdio.h>
#include <driver_settings.h>
static const char *sTabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
int usage(const char *progname)
{
return 1;
}
void print_params(int indent, const driver_parameter *p)
{
printf("indent: %d\n", indent);
printf("%.*s'%s': [", indent, sTabs, p->name);
for (int i = 0; i < p->value_count; i++) {
printf(" '%s',", p->values[i]);
}
printf("]\n");
indent++;
for (int i = 0; i < p->parameter_count; i++)
print_params(indent, &p->parameters[i]);
}
int main(int argc, char **argv)
{
void *h;
const driver_settings *s;
h = load_driver_settings(argv[1]);
if (h == NULL)
return usage(argv[0]);
s = get_driver_settings(h);
printf("%d\n", s->parameter_count);
for (int i = 0; i < s->parameter_count; i++) {
print_params(0, &s->parameters[i]);
}
unload_driver_settings(h);
return 0;
}