All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation
@ 2013-04-11 18:59 Anderson Lizardo
  2013-04-11 18:59 ` [PATCH BlueZ 2/2] lib: Fix list of company identifiers Anderson Lizardo
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Anderson Lizardo @ 2013-04-11 18:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

This script uses curl and html2text to fetch company IDs from
bluetooth.org's "Assigned Numbers" section.
---
 tools/update_compids.sh |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 tools/update_compids.sh

diff --git a/tools/update_compids.sh b/tools/update_compids.sh
new file mode 100755
index 0000000..8a0aa3c
--- /dev/null
+++ b/tools/update_compids.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# Download the list of company IDs from bluetooth.org and generate a diff which
+# can be applied to source tree to update bt_compidtostr(). Usage:
+#
+# $ ./tools/update_compids.sh | git apply -p0
+# (inspect changes to make sure they are sane)
+# $ git commit -m "lib: Update list of company identifiers" lib/bluetooth.c
+#
+# Requires html2text: http://www.mbayer.de/html2text/
+#
+set -e -u
+
+tmpdir=$(mktemp -d)
+trap "rm -rf $tmpdir" EXIT
+
+mkdir $tmpdir/lib
+cp lib/bluetooth.c $tmpdir/lib/bluetooth.c.orig
+cp lib/bluetooth.c $tmpdir/lib/bluetooth.c
+
+cd $tmpdir
+
+path=en-us/specification/assigned-numbers-overview/company-identifiers
+curl https://www.bluetooth.org/$path | html2text -ascii -o identifiers.txt
+
+sed -n '/^const char \*bt_compidtostr(int compid)/,/^}/p' \
+    lib/bluetooth.c > old.c
+
+echo -e 'const char *bt_compidtostr(int compid)\n{\n\tswitch (compid) {' > new.c
+cat identifiers.txt |
+    # remove Unicode character 'ZERO WIDTH SPACE' (U+200B)
+    perl -ne 's/\xe2\x80\x8b//g; m/^(\d+)\s+0x[0-9a-f]+\s+(.*)/i &&
+        print "\tcase $1:\n\t\treturn \"$2\";\n"' >> new.c
+echo -e '\tcase 65535:\n\t\treturn "internal use";' >> new.c
+echo -e '\tdefault:\n\t\treturn "not assigned";\n\t}\n}' >> new.c
+
+diff -Naur old.c new.c | patch -sp0 lib/bluetooth.c
+diff -Naur lib/bluetooth.c.orig lib/bluetooth.c
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH BlueZ 2/2] lib: Fix list of company identifiers
  2013-04-11 18:59 [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Anderson Lizardo
@ 2013-04-11 18:59 ` Anderson Lizardo
  2013-04-30 10:32   ` Johan Hedberg
  2013-04-30 10:06 ` [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Johan Hedberg
  2013-05-03 20:19 ` [PATCH v2 BlueZ] " Anderson Lizardo
  2 siblings, 1 reply; 13+ messages in thread
From: Anderson Lizardo @ 2013-04-11 18:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

Fix minor typos on company names.
---
 lib/bluetooth.c |   34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index cc40ac5..80849b9 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -290,13 +290,13 @@ const char *bt_compidtostr(int compid)
 	case 13:
 		return "Texas Instruments Inc.";
 	case 14:
-		return "Ceva, Inc. (formerly Parthus Technologies Inc.)";
+		return "Ceva, Inc. (formerly Parthus Technologies, Inc.)";
 	case 15:
 		return "Broadcom Corporation";
 	case 16:
 		return "Mitel Semiconductor";
 	case 17:
-		return "Widcomm, Inc.";
+		return "Widcomm, Inc";
 	case 18:
 		return "Zeevo, Inc.";
 	case 19:
@@ -308,11 +308,11 @@ const char *bt_compidtostr(int compid)
 	case 22:
 		return "KC Technology Inc.";
 	case 23:
-		return "Newlogic";
+		return "NewLogic";
 	case 24:
 		return "Transilica, Inc.";
 	case 25:
-		return "Rohde & Schwartz GmbH & Co. KG";
+		return "Rohde & Schwarz GmbH & Co. KG";
 	case 26:
 		return "TTPCom Limited";
 	case 27:
@@ -360,7 +360,7 @@ const char *bt_compidtostr(int compid)
 	case 48:
 		return "ST Microelectronics";
 	case 49:
-		return "Synopsys";
+		return "Synopsis";
 	case 50:
 		return "Red-M (Communications) Ltd";
 	case 51:
@@ -386,13 +386,13 @@ const char *bt_compidtostr(int compid)
 	case 61:
 		return "IPextreme, Inc.";
 	case 62:
-		return "Systems and Chips, Inc";
+		return "Systems and Chips, Inc.";
 	case 63:
-		return "Bluetooth SIG, Inc";
+		return "Bluetooth SIG, Inc.";
 	case 64:
 		return "Seiko Epson Corporation";
 	case 65:
-		return "Integrated Silicon Solution Taiwain, Inc.";
+		return "Integrated Silicon Solution Taiwan, Inc.";
 	case 66:
 		return "CONWISE Technology Corporation Ltd";
 	case 67:
@@ -422,7 +422,7 @@ const char *bt_compidtostr(int compid)
 	case 79:
 		return "APT Licensing Ltd.";
 	case 80:
-		return "SiRF Technology, Inc.";
+		return "SiRF Technology";
 	case 81:
 		return "Tzero Technologies, Inc.";
 	case 82:
@@ -512,7 +512,7 @@ const char *bt_compidtostr(int compid)
 	case 124:
 		return "A & R Cambridge";
 	case 125:
-		return "Seers Technology Co. Ltd.";
+		return "Seers Technology Co. Ltd";
 	case 126:
 		return "Sports Tracking Technologies Ltd.";
 	case 127:
@@ -530,7 +530,7 @@ const char *bt_compidtostr(int compid)
 	case 133:
 		return "BlueRadios, Inc.";
 	case 134:
-		return "equinux AG";
+		return "equinox AG";
 	case 135:
 		return "Garmin International, Inc.";
 	case 136:
@@ -540,7 +540,7 @@ const char *bt_compidtostr(int compid)
 	case 138:
 		return "Jawbone";
 	case 139:
-		return "Topcon Positioning Systems, LLC";
+		return "Topcorn Positioning Systems, LLC";
 	case 140:
 		return "Qualcomm Labs, Inc.";
 	case 141:
@@ -548,11 +548,11 @@ const char *bt_compidtostr(int compid)
 	case 142:
 		return "Quintic Corp.";
 	case 143:
-		return "Stollmann E+V GmbH";
+		return "Stollman E+V GmbH";
 	case 144:
 		return "Funai Electric Co., Ltd.";
 	case 145:
-		return "Advanced PANMOBIL systems GmbH & Co. KG";
+		return "Advanced PANMOBIL Systems GmbH & Co. KG";
 	case 146:
 		return "ThinkOptics, Inc.";
 	case 147:
@@ -566,7 +566,7 @@ const char *bt_compidtostr(int compid)
 	case 151:
 		return "Bluetrek Technologies Limited";
 	case 152:
-		return "zero1.tv GmbH";
+		return "zer01.tv GmbH";
 	case 153:
 		return "i.Tech Dynamic Global Distribution Ltd.";
 	case 154:
@@ -600,7 +600,7 @@ const char *bt_compidtostr(int compid)
 	case 168:
 		return "ARP Devices Limited";
 	case 169:
-		return "Magneti Marelli S.p.A.";
+		return "Magneti Marelli S.p.A";
 	case 170:
 		return "CAEN RFID srl";
 	case 171:
@@ -638,7 +638,7 @@ const char *bt_compidtostr(int compid)
 	case 187:
 		return "S-Power Electronics Limited";
 	case 188:
-		return "Ace Sensor Inc.";
+		return "Ace Sensor Inc";
 	case 189:
 		return "Aplix Corporation";
 	case 190:
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation
  2013-04-11 18:59 [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Anderson Lizardo
  2013-04-11 18:59 ` [PATCH BlueZ 2/2] lib: Fix list of company identifiers Anderson Lizardo
@ 2013-04-30 10:06 ` Johan Hedberg
  2013-04-30 12:32   ` Anderson Lizardo
  2013-05-03 20:19 ` [PATCH v2 BlueZ] " Anderson Lizardo
  2 siblings, 1 reply; 13+ messages in thread
From: Johan Hedberg @ 2013-04-30 10:06 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth

Hi Lizardo,

On Thu, Apr 11, 2013, Anderson Lizardo wrote:
> This script uses curl and html2text to fetch company IDs from
> bluetooth.org's "Assigned Numbers" section.
> ---
>  tools/update_compids.sh |   37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>  create mode 100755 tools/update_compids.sh

I tried this script but after downloading the page it fails with "Input
recoding failed due to invalid input sequence." and then proceeds with
generating a diff to remove all entries from the switch statement.

Johan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH BlueZ 2/2] lib: Fix list of company identifiers
  2013-04-11 18:59 ` [PATCH BlueZ 2/2] lib: Fix list of company identifiers Anderson Lizardo
@ 2013-04-30 10:32   ` Johan Hedberg
  0 siblings, 0 replies; 13+ messages in thread
From: Johan Hedberg @ 2013-04-30 10:32 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth

Hi Lizardo,

On Thu, Apr 11, 2013, Anderson Lizardo wrote:
> Fix minor typos on company names.
> ---
>  lib/bluetooth.c |   34 +++++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 17 deletions(-)

This patch has been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation
  2013-04-30 10:06 ` [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Johan Hedberg
@ 2013-04-30 12:32   ` Anderson Lizardo
  2013-04-30 12:36     ` Anderson Lizardo
  0 siblings, 1 reply; 13+ messages in thread
From: Anderson Lizardo @ 2013-04-30 12:32 UTC (permalink / raw)
  To: Anderson Lizardo, linux-bluetooth

Hi Johan,

> I tried this script but after downloading the page it fails with "Input
> recoding failed due to invalid input sequence." and then proceeds with
> generating a diff to remove all entries from the switch statement.

That's strange. I just tested here and it worked fine, even found 3
new companies:

--- lib/bluetooth.c.orig	2013-04-30 08:29:11.000000000 -0400
+++ lib/bluetooth.c	2013-04-30 08:29:21.000000000 -0400
@@ -655,6 +655,12 @@
 		return "adidas AG";
 	case 196:
 		return "LG Electronics";
+	case 197:
+		return "Onset Computer Corporation";
+	case 198:
+		return "Selfly BV";
+	case 199:
+		return "Quuppa Oy.";
 	case 65535:
 		return "internal use";
 	default:

Maybe "html2text" is not the same tool on all distros. I'll see if I
can make it more robust. Can you tell me the output of "html2text
-version" ?

Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation
  2013-04-30 12:32   ` Anderson Lizardo
@ 2013-04-30 12:36     ` Anderson Lizardo
  2013-04-30 13:49       ` Johan Hedberg
  0 siblings, 1 reply; 13+ messages in thread
From: Anderson Lizardo @ 2013-04-30 12:36 UTC (permalink / raw)
  To: Anderson Lizardo, linux-bluetooth

On Tue, Apr 30, 2013 at 8:32 AM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi Johan,
>
>> I tried this script but after downloading the page it fails with "Input
>> recoding failed due to invalid input sequence." and then proceeds with
>> generating a diff to remove all entries from the switch statement.

I think I found the culprit, it's some problem related to Unicode handling:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=545695

There are a few unicode characters on the HTML, I'll remove them
before passing the HTML file to html2test.

Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation
  2013-04-30 12:36     ` Anderson Lizardo
@ 2013-04-30 13:49       ` Johan Hedberg
  0 siblings, 0 replies; 13+ messages in thread
From: Johan Hedberg @ 2013-04-30 13:49 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth

Hi Lizardo,

On Tue, Apr 30, 2013, Anderson Lizardo wrote:
> On Tue, Apr 30, 2013 at 8:32 AM, Anderson Lizardo
> <anderson.lizardo@openbossa.org> wrote:
> > Hi Johan,
> >
> >> I tried this script but after downloading the page it fails with "Input
> >> recoding failed due to invalid input sequence." and then proceeds with
> >> generating a diff to remove all entries from the switch statement.
> 
> I think I found the culprit, it's some problem related to Unicode handling:
> 
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=545695
> 
> There are a few unicode characters on the HTML, I'll remove them
> before passing the HTML file to html2test.

Sounds like a plausible explanation. FWIW, I'm running html2text from
Fedora 18: "This is html2text, version 1.3.2a".

Johan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 BlueZ] tools: Add script for updating bt_compidtostr() implementation
  2013-04-11 18:59 [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Anderson Lizardo
  2013-04-11 18:59 ` [PATCH BlueZ 2/2] lib: Fix list of company identifiers Anderson Lizardo
  2013-04-30 10:06 ` [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Johan Hedberg
@ 2013-05-03 20:19 ` Anderson Lizardo
  2013-05-16 13:13   ` Anderson Lizardo
  2013-05-17 14:21   ` [PATCH v3 " Anderson Lizardo
  2 siblings, 2 replies; 13+ messages in thread
From: Anderson Lizardo @ 2013-05-03 20:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

This script uses curl and html2text to fetch company IDs from
bluetooth.org's "Assigned Numbers" section.
---

v2:

* Use iconv to strip unrelated UTF-8 text from the HTML prior to passing it to
  html2text.
* Add simple sanity check for when HTML parsing fails.


 tools/update_compids.sh |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100755 tools/update_compids.sh

diff --git a/tools/update_compids.sh b/tools/update_compids.sh
new file mode 100755
index 0000000..296e32f
--- /dev/null
+++ b/tools/update_compids.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+# Download the list of company IDs from bluetooth.org and generate a diff which
+# can be applied to source tree to update bt_compidtostr(). Usage:
+#
+# 1) ./tools/update_compids.sh | git apply -p0
+# 2) Inspect changes to make sure they are sane
+# 3) git commit -m "lib: Update list of company identifiers" lib/bluetooth.c
+#
+# Requires html2text: http://www.mbayer.de/html2text/
+#
+set -e -u
+
+tmpdir=$(mktemp -d)
+trap "rm -rf $tmpdir" EXIT
+
+mkdir $tmpdir/lib
+cp lib/bluetooth.c $tmpdir/lib/bluetooth.c.orig
+cp lib/bluetooth.c $tmpdir/lib/bluetooth.c
+
+cd $tmpdir
+
+path=en-us/specification/assigned-numbers-overview/company-identifiers
+# Use "iconv -c" to strip unwanted unicode characters
+curl https://www.bluetooth.org/$path | iconv -c -f UTF-8 -t ISO-8859-1 | \
+    html2text -ascii -o identifiers.txt
+
+sed -n '/^const char \*bt_compidtostr(int compid)/,/^}/p' \
+    lib/bluetooth.c > old.c
+
+echo -e 'const char *bt_compidtostr(int compid)\n{\n\tswitch (compid) {' > new.c
+cat identifiers.txt |
+    perl -ne 'm/^(\d+)\s+0x[0-9a-f]+\s+(.*)/i &&
+        print "\tcase $1:\n\t\treturn \"$2\";\n"' >> new.c
+if ! grep -q "return \"" new.c; then
+    echo "ERROR: could not parse company IDs from bluetooth.org" >&2
+    exit 1
+fi
+echo -e '\tcase 65535:\n\t\treturn "internal use";' >> new.c
+echo -e '\tdefault:\n\t\treturn "not assigned";\n\t}\n}' >> new.c
+
+diff -Naur old.c new.c | patch -sp0 lib/bluetooth.c
+diff -Naur lib/bluetooth.c.orig lib/bluetooth.c
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 BlueZ] tools: Add script for updating bt_compidtostr() implementation
  2013-05-03 20:19 ` [PATCH v2 BlueZ] " Anderson Lizardo
@ 2013-05-16 13:13   ` Anderson Lizardo
  2013-05-17  7:28     ` Johan Hedberg
  2013-05-17 14:21   ` [PATCH v3 " Anderson Lizardo
  1 sibling, 1 reply; 13+ messages in thread
From: Anderson Lizardo @ 2013-05-16 13:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

Hi,

On Fri, May 3, 2013 at 4:19 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> This script uses curl and html2text to fetch company IDs from
> bluetooth.org's "Assigned Numbers" section.
> ---
>
> v2:
>
> * Use iconv to strip unrelated UTF-8 text from the HTML prior to passing it to
>   html2text.
> * Add simple sanity check for when HTML parsing fails.

ping

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 BlueZ] tools: Add script for updating bt_compidtostr() implementation
  2013-05-16 13:13   ` Anderson Lizardo
@ 2013-05-17  7:28     ` Johan Hedberg
  2013-05-17 10:49       ` Anderson Lizardo
  0 siblings, 1 reply; 13+ messages in thread
From: Johan Hedberg @ 2013-05-17  7:28 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth

Hi Lizardo,

On Thu, May 16, 2013, Anderson Lizardo wrote:
> On Fri, May 3, 2013 at 4:19 PM, Anderson Lizardo
> <anderson.lizardo@openbossa.org> wrote:
> > This script uses curl and html2text to fetch company IDs from
> > bluetooth.org's "Assigned Numbers" section.
> > ---
> >
> > v2:
> >
> > * Use iconv to strip unrelated UTF-8 text from the HTML prior to passing it to
> >   html2text.
> > * Add simple sanity check for when HTML parsing fails.
> 
> ping

The script still doesn't work for me. It spews out some java script and
finally ends with "ERROR: could not parse company IDs from bluetooth.org".

Johan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 BlueZ] tools: Add script for updating bt_compidtostr() implementation
  2013-05-17  7:28     ` Johan Hedberg
@ 2013-05-17 10:49       ` Anderson Lizardo
  0 siblings, 0 replies; 13+ messages in thread
From: Anderson Lizardo @ 2013-05-17 10:49 UTC (permalink / raw)
  To: Anderson Lizardo, linux-bluetooth

Hi Johan,

On Fri, May 17, 2013 at 3:28 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> The script still doesn't work for me. It spews out some java script and
> finally ends with "ERROR: could not parse company IDs from bluetooth.org".

It seems that FC18 source has some patches that make it behave
different from Ubuntu and upstream sources. I built the upstream
(without any patches) and it worked fine (just like the Ubuntu
version). After applying FC18 patches, I got the problem you
mentioned.

I'll now change the script to make it work with both upstream and FC18 versions.

Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 BlueZ] tools: Add script for updating bt_compidtostr() implementation
  2013-05-03 20:19 ` [PATCH v2 BlueZ] " Anderson Lizardo
  2013-05-16 13:13   ` Anderson Lizardo
@ 2013-05-17 14:21   ` Anderson Lizardo
  2013-05-19  4:06     ` Johan Hedberg
  1 sibling, 1 reply; 13+ messages in thread
From: Anderson Lizardo @ 2013-05-17 14:21 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

This script uses curl and html2text to fetch company IDs from
bluetooth.org's "Assigned Numbers" section.
---

v3:

* Make the script work better with modified html2text versions.
(it is unfortunate that in this case the upstream unmodified version works
better than the distro one).

I should report a bug to Fedora as time permits...


 tools/update_compids.sh |   48 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100755 tools/update_compids.sh

diff --git a/tools/update_compids.sh b/tools/update_compids.sh
new file mode 100755
index 0000000..38d7032
--- /dev/null
+++ b/tools/update_compids.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# Download the list of company IDs from bluetooth.org and generate a diff which
+# can be applied to source tree to update bt_compidtostr(). Usage:
+#
+# 1) ./tools/update_compids.sh | git apply -p0
+# 2) Inspect changes to make sure they are sane
+# 3) git commit -m "lib: Update list of company identifiers" lib/bluetooth.c
+#
+# Requires html2text: http://www.mbayer.de/html2text/
+#
+set -e -u
+
+tmpdir=$(mktemp -d)
+trap "rm -rf $tmpdir" EXIT
+
+mkdir $tmpdir/lib
+cp lib/bluetooth.c $tmpdir/lib/bluetooth.c.orig
+cp lib/bluetooth.c $tmpdir/lib/bluetooth.c
+
+cd $tmpdir
+
+path=en-us/specification/assigned-numbers-overview/company-identifiers
+# Use "iconv -c" to strip unwanted unicode characters
+# Also strip <input> tags of type checkbox because html2text generates UTF-8
+# for them in some distros even when using -ascii (e.g. Fedora 18)
+curl https://www.bluetooth.org/$path | iconv -c -f utf8 -t ascii | \
+    sed '/<input.*type="checkbox"/d' | \
+    html2text -ascii -o identifiers.txt >/dev/null
+
+# Some versions of html2text do not replace &amp; (e.g. Fedora 18)
+sed -i 's/&amp;/\&/g' identifiers.txt
+
+sed -n '/^const char \*bt_compidtostr(int compid)/,/^}/p' \
+    lib/bluetooth.c > old.c
+
+echo -e 'const char *bt_compidtostr(int compid)\n{\n\tswitch (compid) {' > new.c
+cat identifiers.txt |
+    perl -ne 'm/^(\d+)\s+0x[0-9a-f]+\s+(.*)/i &&
+        print "\tcase $1:\n\t\treturn \"$2\";\n"' >> new.c
+if ! grep -q "return \"" new.c; then
+    echo "ERROR: could not parse company IDs from bluetooth.org" >&2
+    exit 1
+fi
+echo -e '\tcase 65535:\n\t\treturn "internal use";' >> new.c
+echo -e '\tdefault:\n\t\treturn "not assigned";\n\t}\n}' >> new.c
+
+diff -Naur old.c new.c | patch -sp0 lib/bluetooth.c
+diff -Naur lib/bluetooth.c.orig lib/bluetooth.c
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 BlueZ] tools: Add script for updating bt_compidtostr() implementation
  2013-05-17 14:21   ` [PATCH v3 " Anderson Lizardo
@ 2013-05-19  4:06     ` Johan Hedberg
  0 siblings, 0 replies; 13+ messages in thread
From: Johan Hedberg @ 2013-05-19  4:06 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth

Hi Lizardo,

On Fri, May 17, 2013, Anderson Lizardo wrote:
> This script uses curl and html2text to fetch company IDs from
> bluetooth.org's "Assigned Numbers" section.
> ---
> 
> v3:
> 
> * Make the script work better with modified html2text versions.
> (it is unfortunate that in this case the upstream unmodified version works
> better than the distro one).
> 
> I should report a bug to Fedora as time permits...
> 
> 
>  tools/update_compids.sh |   48 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100755 tools/update_compids.sh

Applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-05-19  4:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 18:59 [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Anderson Lizardo
2013-04-11 18:59 ` [PATCH BlueZ 2/2] lib: Fix list of company identifiers Anderson Lizardo
2013-04-30 10:32   ` Johan Hedberg
2013-04-30 10:06 ` [PATCH BlueZ 1/2] tools: Add script for updating bt_compidtostr() implementation Johan Hedberg
2013-04-30 12:32   ` Anderson Lizardo
2013-04-30 12:36     ` Anderson Lizardo
2013-04-30 13:49       ` Johan Hedberg
2013-05-03 20:19 ` [PATCH v2 BlueZ] " Anderson Lizardo
2013-05-16 13:13   ` Anderson Lizardo
2013-05-17  7:28     ` Johan Hedberg
2013-05-17 10:49       ` Anderson Lizardo
2013-05-17 14:21   ` [PATCH v3 " Anderson Lizardo
2013-05-19  4:06     ` Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.