xref: /haiku/src/bin/get_driver_settings.cpp (revision 587b70d5cdc6de5dccb242b2854b38d7c236bde2)
1 /*
2  * Copyright 2017, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		 <François Revol>
7  */
8 
9 #include <stdio.h>
10 
11 #include <driver_settings.h>
12 
13 static const char *sTabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
14 
usage(const char * progname)15 int usage(const char *progname)
16 {
17 	return 1;
18 }
19 
print_params(int indent,const driver_parameter * p)20 void print_params(int indent, const driver_parameter *p)
21 {
22 	printf("indent: %d\n", indent);
23 	printf("%.*s'%s': [", indent, sTabs, p->name);
24 	for (int i = 0; i < p->value_count; i++) {
25 		printf(" '%s',", p->values[i]);
26 	}
27 	printf("]\n");
28 	indent++;
29 	for (int i = 0; i < p->parameter_count; i++)
30 		print_params(indent, &p->parameters[i]);
31 }
32 
main(int argc,char ** argv)33 int main(int argc, char **argv)
34 {
35 	void *h;
36 	const driver_settings *s;
37 	h = load_driver_settings(argv[1]);
38 	if (h == NULL)
39 		return usage(argv[0]);
40 
41 	s = get_driver_settings(h);
42 
43 	printf("%d\n", s->parameter_count);
44 	for (int i = 0; i < s->parameter_count; i++) {
45 		print_params(0, &s->parameters[i]);
46 	}
47 
48 	unload_driver_settings(h);
49 
50 	return 0;
51 }
52