annotate vidix/pci_db2c.awk @ 30060:34e381629bb8

Register lavc Aura decoder
author kostya
date Wed, 23 Dec 2009 13:44:23 +0000
parents fb44c9cb05fa
children fbff89bae6a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30005
835d6e5e5de0 Make vidix/pci_db2c.awk executable.
diego
parents: 29263
diff changeset
1 #!/usr/bin/awk -f
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
2 # This file converts given pci.db to "C" source and header files
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
3 # For latest version of pci ids see: http://pciids.sf.net
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
4 # Copyright 2002 Nick Kurshev
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
5 #
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
6 # Tested with Gawk v 3.0.x and Mawk 1.3.3
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
7 # But it should work with standard Awk implementations (hopefully).
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
8 # (Nobody tested it with Nawk, but it should work, too).
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
9 #
23292
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
10 # This file is part of MPlayer.
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
11 #
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
12 # MPlayer is free software; you can redistribute it and/or modify
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
13 # it under the terms of the GNU General Public License as published by
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
14 # the Free Software Foundation; either version 2 of the License, or
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
15 # (at your option) any later version.
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
16 #
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
17 # MPlayer is distributed in the hope that it will be useful,
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
20 # GNU General Public License for more details.
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
21 #
26719
3abd1629658b Use standard license headers.
diego
parents: 26516
diff changeset
22 # You should have received a copy of the GNU General Public License along
3abd1629658b Use standard license headers.
diego
parents: 26516
diff changeset
23 # with MPlayer; if not, write to the Free Software Foundation, Inc.,
3abd1629658b Use standard license headers.
diego
parents: 26516
diff changeset
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
25
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
26 BEGIN {
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
27
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
28 if (ARGC != 3) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
29 # check for arguments:
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
30 print "Usage ./pci_db2c.awk pci.db (and make sure pci.db file exists first)";
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
31 exit(1);
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
32 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
33 in_file = ARGV[1];
25271
4ba5a1593296 add new configure option to disable VIDIX PCI device name database (saves a 300 kB on mplayer binary)
ben
parents: 23292
diff changeset
34 with_pci_db = ARGV[2];
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
35 dev_ids_c_file = "vidix/pci_dev_ids.c"
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
36 ids_h_file = "vidix/pci_ids.h"
30052
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
37 vendor_ids_h_file = "vidix/pci_vendor_ids.h"
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
38 vendors_h_file = "vidix/pci_vendors.h";
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
39 # print out head lines
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
40 print_head(vendors_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
41 print_head(ids_h_file);
30052
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
42 print_head(vendor_ids_h_file);
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
43 print_head(dev_ids_c_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
44 print "#include <stdlib.h>" > dev_ids_c_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
45 print "#include \"pci_names.h\"" > dev_ids_c_file;
30048
3acbd834b269 Eliminate completely pointless print_includes function.
diego
parents: 30046
diff changeset
46
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
47 print_guards_start(vendors_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
48 print_guards_start(ids_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
49 print "#include \"pci_vendors.h\"" > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
50 print "" > ids_h_file
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
51
30052
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
52 print "#include <stddef.h>" > vendor_ids_h_file
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
53 print "#include \"pci_names.h\"" > vendor_ids_h_file
25271
4ba5a1593296 add new configure option to disable VIDIX PCI device name database (saves a 300 kB on mplayer binary)
ben
parents: 23292
diff changeset
54 if (with_pci_db) {
30052
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
55 print "#include \"pci_dev_ids.c\"" > vendor_ids_h_file
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
56 print "" > vendor_ids_h_file
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
57 print "static struct vendor_id_s vendor_ids[] = {" > vendor_ids_h_file
25271
4ba5a1593296 add new configure option to disable VIDIX PCI device name database (saves a 300 kB on mplayer binary)
ben
parents: 23292
diff changeset
58 }
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
59 first_pass = 1;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
60 init_name_db();
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
61 while (getline < in_file) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
62 n = split($0, field, "[\t]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
63 name_field = kill_double_quoting(field[3])
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
64 if (field[1] == "v" && length(field[3]) > 0 && field[4] == "0") {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
65 init_device_db()
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
66 svend_name = get_short_vendor_name(field[3])
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
67 printf("#define VENDOR_%s\t", svend_name) > vendors_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
68 if (length(svend_name) < 9) printf("\t") > vendors_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
69 printf("0x%s /*%s*/\n", field[2], name_field) > vendors_h_file;
30052
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
70 if (with_pci_db) printf("{ 0x%s, \"%s\", dev_lst_%s },\n", field[2], name_field, field[2]) > vendor_ids_h_file;
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
71 printf("/* Vendor: %s: %s */\n", field[2], name_field) > ids_h_file
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
72 if (first_pass == 1) first_pass = 0;
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
73 else print "{ 0xFFFF, NULL }\n};" > dev_ids_c_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
74 printf("static const struct device_id_s dev_lst_%s[] = {\n", field[2])> dev_ids_c_file
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
75 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
76 if (field[1] == "d" && length(field[3]) > 0 && field[4] == "0") {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
77 sdev_name = get_short_device_name(field[3])
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
78 full_name = sprintf("#define DEVICE_%s_%s", svend_name, sdev_name);
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
79 printf("%s\t", full_name) > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
80 if (length(full_name) < 9) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
81 if (length(full_name) < 17) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
82 if (length(full_name) < 25) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
83 if (length(full_name) < 32) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
84 if (length(full_name) < 40) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
85 if (length(full_name) < 48) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
86 printf("0x%s /*%s*/\n", substr(field[2], 5), name_field) > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
87 printf("{ 0x%s, \"%s\" },\n", substr(field[2], 5), name_field) > dev_ids_c_file
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
88 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
89 if (field[1] == "s" && length(field[3]) > 0 && field[4] == "0") {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
90 subdev_name = get_short_subdevice_name(field[3])
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
91 full_name = sprintf("#define SUBDEVICE_%s_%s", svend_name, subdev_name)
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
92 printf("\t%s\t", full_name) > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
93 if (length(full_name) < 9) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
94 if (length(full_name) < 17) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
95 if (length(full_name) < 25) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
96 if (length(full_name) < 32) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
97 if (length(full_name) < 40) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
98 printf("0x%s /*%s*/\n", substr(field[2], 9), name_field) > ids_h_file
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
99 }
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
100 }
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
101 print_guards_end(vendors_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
102 print_guards_end(ids_h_file);
30052
fb44c9cb05fa Do not auto-generate the C code to handle PCI vendor and device names.
diego
parents: 30050
diff changeset
103 if (with_pci_db) print "};" > vendor_ids_h_file
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
104 print "{ 0xFFFF, NULL }" > dev_ids_c_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
105 print "};" > dev_ids_c_file
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
106 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
107
30041
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
108 function construct_guard_name(out_file)
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
109 {
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
110 split(out_file, path_components, "/");
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
111 sub(".h","_h", path_components[2]);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
112 return "MPLAYER_" toupper(path_components[2]);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
113 }
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
114
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
115 function print_guards_start(out_file)
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
116 {
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
117 guard_name = construct_guard_name(out_file);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
118 printf("#ifndef %s\n", guard_name) > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
119 printf("#define %s\n", guard_name) > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
120 print "" > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
121 }
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
122
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
123 function print_guards_end(out_file)
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
124 {
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
125 guard_name = construct_guard_name(out_file);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
126 print "" > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
127 printf("#endif /* %s */\n", guard_name) > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
128 }
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
129
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
130 function print_head(out_file)
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
131 {
30038
d1c5b275d3f9 cosmetics: Use more consistent formatting style for generated files.
diego
parents: 30037
diff changeset
132 printf("/* File: %s\n", out_file) > out_file;
d1c5b275d3f9 cosmetics: Use more consistent formatting style for generated files.
diego
parents: 30037
diff changeset
133 printf(" * This file was generated automatically. Don't modify it. */\n") > out_file;
d1c5b275d3f9 cosmetics: Use more consistent formatting style for generated files.
diego
parents: 30037
diff changeset
134 print "" > out_file
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
135 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
136
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
137 function kill_double_quoting(fld)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
138 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
139 n = split(fld, phrases, "[\"]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
140 new_fld = phrases[1]
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
141 for (i = 2; i <= n; i++) new_fld = sprintf("%s\\\"%s", new_fld, phrases[i])
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
142 return new_fld
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
143 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
144
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
145 function init_name_db()
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
146 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
147 vendor_names[1] = ""
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
148 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
149
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
150 function init_device_db()
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
151 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
152 # delete device_names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
153 for (i in device_names) delete device_names[i];
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
154 device_names[1] = ""
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
155 # delete subdevice_names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
156 for (i in subdevice_names) delete subdevice_names[i];
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
157 subdevice_names[1] = ""
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
158 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
159
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
160 function get_short_vendor_name(from)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
161 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
162 n = split(from, name, "[ ]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
163 new_name = toupper(name[1]);
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
164 if (length(new_name) < 3) new_name = sprintf("%s_%s", new_name, toupper(name[2]));
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
165 n = split(new_name, name, "[^0-9A-Za-z]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
166 svendor = name[1];
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
167 for (i = 2; i <= n; i++) svendor = sprintf("%s%s%s", svendor, length(name[i]) ? "_" : "", name[i]);
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
168 new_name = svendor;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
169 vend_suffix = 2;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
170 # check for unique
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
171 while (new_name in vendor_names) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
172 new_name = sprintf("%s%u", svendor, vend_suffix)
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
173 vend_suffix = vend_suffix + 1;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
174 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
175 # Add new name in array of vendor's names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
176 vendor_names[new_name] = new_name
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
177 return new_name;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
178 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
179
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
180 function get_short_device_name(from_name)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
181 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
182 n = split(from_name, name, "[ ]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
183 new_name = toupper(name[1]);
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
184 if (length(name[2])) new_name = sprintf("%s_%s", new_name, toupper(name[2]));
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
185 if (length(name[3])) new_name = sprintf("%s_%s", new_name, toupper(name[3]));
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
186 n = split(new_name, name, "[^0-9A-Za-z]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
187 sdevice = name[1];
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
188 for (i = 2; i <= n; i++) sdevice = sprintf("%s%s%s", sdevice, length(name[i]) ? "_" : "", name[i]);
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
189 new_name = sdevice;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
190 dev_suffix = 2;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
191 # check for unique
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
192 while (new_name in device_names) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
193 new_name = sprintf("%s%u", sdevice, dev_suffix)
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
194 dev_suffix = dev_suffix + 1;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
195 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
196 # Add new name in array of device names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
197 device_names[new_name] = new_name
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
198 return new_name;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
199 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
200
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
201 function get_short_subdevice_name(from_name)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
202 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
203 n = split(from_name, name, "[ ]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
204 new_name = toupper(name[1]);
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
205 if (length(name[2])) new_name = sprintf("%s_%s", new_name, toupper(name[2]));
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
206 if (length(name[3])) new_name = sprintf("%s_%s", new_name, toupper(name[3]));
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
207 n = split(new_name, name, "[^0-9A-Za-z]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
208 ssdevice = name[1];
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
209 for (i = 2; i <= n; i++) ssdevice = sprintf("%s%s%s", ssdevice, length(name[i]) ? "_" : "", name[i]);
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
210 new_name = ssdevice;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
211 sdev_suffix = 2;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
212 # check for unique
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
213 while (new_name in subdevice_names) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
214 new_name = sprintf("%s%u", ssdevice, sdev_suffix)
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
215 sdev_suffix = sdev_suffix + 1;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
216 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
217 # Add new name in array of subdevice names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
218 subdevice_names[new_name] = new_name
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
219 return new_name;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
220 }