More adb buffer fixes.
This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.
ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.
Also actually build the device tracker test tool (and remove its duplicate).
Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
diff --git a/adb/adb_io.h b/adb/adb_io.h
index 8d237ce..3b8b050 100644
--- a/adb/adb_io.h
+++ b/adb/adb_io.h
@@ -17,9 +17,19 @@
#ifndef ADB_IO_H
#define ADB_IO_H
-#include <stdbool.h>
#include <sys/types.h>
+#include <string>
+
+// Sends the protocol "OKAY" message.
+bool SendOkay(int fd);
+
+// Sends the protocol "FAIL" message, with the given failure reason.
+bool SendFail(int fd, const std::string& reason);
+
+// Writes a protocol-format string; a four hex digit length followed by the string data.
+bool SendProtocolString(int fd, const std::string& s);
+
/*
* Reads exactly len bytes from fd into buf.
*
@@ -37,9 +47,13 @@
* completed. If the other end of the fd (such as in a socket, pipe, or fifo),
* is closed, errno will be set to 0.
*/
-bool WriteFdExactly(int fd, const void *buf, size_t len);
+bool WriteFdExactly(int fd, const void* buf, size_t len);
-/* Same as WriteFdExactly, but with an implicit len = strlen(buf). */
+/* Same as above, but with an implicit len = strlen(buf). */
+bool WriteFdExactly(int fd, const char* s);
+bool WriteFdExactly(int fd, const std::string& s);
+
+// TODO: move minadb off this and remove it.
bool WriteStringFully(int fd, const char* str);
#endif /* ADB_IO_H */