diff options
author | Elliott Hughes <enh@google.com> | 2019-05-03 09:02:45 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2019-05-03 12:49:31 -0700 |
commit | b4dc7be6c57a911c8f496af188a15efdeb8ec2bc (patch) | |
tree | 3e2ffd39f262073f43528c25845860dcb46b43d2 /adb/adb.cpp | |
parent | 56311071fec472ab546a6722295e84e4b4920c85 (diff) |
libbase: add ConsumePrefix/ConsumeSuffix.
adb was already using ConsumePrefix, and now we have another would-be
user in cutils. (There appears to be one place in adb that should use
ConsumeSuffix, so I'm assuming we'll want that sooner or later.)
I've kept these inline because adb and google3's versions both were, and
I'm easily led.
Test: treehugger
Change-Id: I29d99032f6f6ccbfaefece59725db8afb02a4c87
Diffstat (limited to 'adb/adb.cpp')
-rw-r--r-- | adb/adb.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/adb/adb.cpp b/adb/adb.cpp index 2dd22b38b..24d4292d0 100644 --- a/adb/adb.cpp +++ b/adb/adb.cpp @@ -1048,9 +1048,9 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty // New transport selection protocol: // This is essentially identical to the previous version, except it returns the selected // transport id to the caller as well. - if (ConsumePrefix(&service, "tport:")) { + if (android::base::ConsumePrefix(&service, "tport:")) { legacy = false; - if (ConsumePrefix(&service, "serial:")) { + if (android::base::ConsumePrefix(&service, "serial:")) { serial_storage = service; serial = serial_storage.c_str(); } else if (service == "usb") { @@ -1064,7 +1064,7 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty // Selection by id is unimplemented, since you obviously already know the transport id // you're connecting to. } else { - if (ConsumePrefix(&service, "transport-id:")) { + if (android::base::ConsumePrefix(&service, "transport-id:")) { if (!ParseUint(&transport_id, service)) { SendFail(reply_fd, "invalid transport id"); return HostRequestResult::Handled; @@ -1075,7 +1075,7 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty type = kTransportLocal; } else if (service == "transport-any") { type = kTransportAny; - } else if (ConsumePrefix(&service, "transport:")) { + } else if (android::base::ConsumePrefix(&service, "transport:")) { serial_storage = service; serial = serial_storage.c_str(); } @@ -1216,7 +1216,7 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty } // Indicates a new emulator instance has started. - if (ConsumePrefix(&service, "emulator:")) { + if (android::base::ConsumePrefix(&service, "emulator:")) { unsigned int port; if (!ParseUint(&port, service)) { LOG(ERROR) << "received invalid port for emulator: " << service; |