summaryrefslogtreecommitdiffstats
path: root/adb/sockets.c
diff options
context:
space:
mode:
authorScott Anderson <saa@android.com>2012-06-05 16:21:04 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-05 16:21:04 -0700
commit0e9e13eb46d8ffbb456f937db4a8fb0da02dd5d2 (patch)
tree8560164bfd6e5e8d24d9091aa68afdadb2ddd433 /adb/sockets.c
parent3fef581bc7a513defe48329973d14bec722f1293 (diff)
parent2ca3e6b35f79136418ebc32fef57580698dbd045 (diff)
downloadcore-0e9e13eb46d8ffbb456f937db4a8fb0da02dd5d2.tar.gz
core-0e9e13eb46d8ffbb456f937db4a8fb0da02dd5d2.tar.bz2
core-0e9e13eb46d8ffbb456f937db4a8fb0da02dd5d2.zip
am 2ca3e6b3: adb: Generalizing -s to take qualifiers.
* commit '2ca3e6b35f79136418ebc32fef57580698dbd045': adb: Generalizing -s to take qualifiers.
Diffstat (limited to 'adb/sockets.c')
-rw-r--r--adb/sockets.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/adb/sockets.c b/adb/sockets.c
index cad107fee..b77c38cf6 100644
--- a/adb/sockets.c
+++ b/adb/sockets.c
@@ -608,15 +608,29 @@ unsigned unhex(unsigned char *s, int len)
return n;
}
+#define PREFIX(str) { str, sizeof(str) - 1 }
+static const struct prefix_struct {
+ const char *str;
+ const size_t len;
+} prefixes[] = {
+ PREFIX("usb:"),
+ PREFIX("product:"),
+ PREFIX("model:"),
+ PREFIX("device:"),
+};
+static const int num_prefixes = (sizeof(prefixes) / sizeof(prefixes[0]));
+
/* skip_host_serial return the position in a string
skipping over the 'serial' parameter in the ADB protocol,
where parameter string may be a host:port string containing
the protocol delimiter (colon). */
char *skip_host_serial(char *service) {
char *first_colon, *serial_end;
+ int i;
- if (!strncmp(service, "usb:", 4)) {
- return strchr(service + 4, ':');
+ for (i = 0; i < num_prefixes; i++) {
+ if (!strncmp(service, prefixes[i].str, prefixes[i].len))
+ return strchr(service + prefixes[i].len, ':');
}
first_colon = strchr(service, ':');