Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vid_data.sh « libwdi « source « driver - github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1f9c1c7677e68c9c1d94db3dbb38f471742f6482 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh

echo This file recreates vid_data.c according http://www.linux-usb.org/usb.ids
echo

# check that wget and sed are available
type -P wget &>/dev/null || { echo "wget command not found. Aborting." >&2; exit 1; }
type -P sed &>/dev/null || { echo "sed command not found. Aborting." >&2; exit 1; }

# Download the latest version (overwrite previous if newer)
wget -m -nd http://www.linux-usb.org/usb.ids

# Create the sed command file
cat > cmd.sed <<\_EOF
# Header, part 1
s¦^#.*List of USB.*¦/*\
 * USB vendors, by VID\
 * This file is autogenerated from http://www.linux-usb.org/usb.ids\
 * See http://www.linux-usb.org/usb-ids.html to submit new VIDs or PIDs\
 *\
 *\
 * This library is free software; you can redistribute it and/or\
 * modify it under the terms of the GNU Lesser General Public\
 * License as published by the Free Software Foundation; either\
 * version 3 of the License, or (at your option) any later version.\
 *\
 * This library is distributed in the hope that it will be useful,\
 * but WITHOUT ANY WARRANTY; without even the implied warranty of\
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\
 * Lesser General Public License for more details.\
 *\
 * You should have received a copy of the GNU Lesser General Public\
 * License along with this library; if not, write to the Free Software\
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\
 */\
\
#include <stdlib.h>\
#include "libwdi.h"\
\
struct vendor_name \{\
	unsigned short vid;\
	const char* name;\
\};\
\
/*\
 * http://www.linux-usb.org/usb.ids¦p

# Header part 2, version
s|# Version:| * Version:|
/ \* Version:/p

# Header Part 3
s|^#.*Date:.*| \*/\
static struct vendor_name usb_vendor[] = \{|p

# Footer
$a\
\};\
\
const char* LIBWDI_API wdi_get_vendor_name(unsigned short vid)\
\{\
	int i;\
\
	for(i=0; i<sizeof(usb_vendor)/sizeof(usb_vendor[0]); i++) \{\
		if (usb_vendor[i].vid == vid) \{\
			return usb_vendor[i].name;\
		\}\
	\}\
	return NULL;\
\}

# Main Data
/^[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]  /!d
s/^\([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\)  \(.*\)/\	{ 0x\1, "\2" \},/
s/???/?/
s/??/?/
_EOF

# Run sed to generate the source.
sed -f cmd.sed usb.ids > vid_data.c
rm cmd.sed
echo Done.