1#!/bin/awk
2# Copyright 2022, Haiku.
3# Distributed under the terms of the MIT License.
4#
5# Authors:
6#		J��r��me Duval, jerome.duval@gmail.com
7#
8# run as awk -f acpipnplist2h.awk pnp_id_registry.html acpi_id_registry.html
9BEGIN {
10	FS="</*td>"
11}
12NR == 1 {
13	printf("/*\tHaiku" "$\t*/\n\n")
14	printf("/*\n")
15	printf(" This file is generated automatically. Don't edit. \n")
16	printf("\n*/")
17}
18
19NF > 0 {
20	if ($2) {
21		n++
22
23		ids[n, 1] = $4;
24		ids[n, 2] = $2;
25	}
26}
27
28END {
29	printf("\n")
30	printf("typedef struct { const char* VenId; const char* VenName; } idTable;\n")
31	printf("idTable acpipnp_devids [] = {\n")
32	for (i = 1; i <= n; i++) {
33		printf("\t{\n")
34		printf("\t\t\"%s\", \"%s\"\n", ids[i,1], ids[i,2])
35		printf("\t},\n")
36	}
37	printf("\t};\n")
38	printf("// Use this value for loop control during searching:\n")
39	printf("#define	ACPIPNP_DEVTABLE_LEN	%i\n", n)
40}
41
42