aboutsummaryrefslogtreecommitdiffstats
path: root/android/async-console.h
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2010-11-18 16:14:03 +0100
committerDavid 'Digit' Turner <digit@android.com>2010-11-19 15:01:21 +0100
commit6d448806a80bcc2557ae0a38e7fd206967cf844e (patch)
tree08c567d36949bbc4263eb7a84b67936ce7789f6d /android/async-console.h
parent1bb627cd086588d3f9650fac04f4034961caf9f1 (diff)
downloadexternal_qemu-6d448806a80bcc2557ae0a38e7fd206967cf844e.zip
external_qemu-6d448806a80bcc2557ae0a38e7fd206967cf844e.tar.gz
external_qemu-6d448806a80bcc2557ae0a38e7fd206967cf844e.tar.bz2
Introduce asynchronous operation helpers.
<android/async-utils.h> contains generic helpers to read, write and connect to sockets. <android/async-console.h> contains a helper class to connect to Android console port asynchronously. Change-Id: I5d0a49a770ad974c5d4382438d75e9eb624368d1
Diffstat (limited to 'android/async-console.h')
-rw-r--r--android/async-console.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/android/async-console.h b/android/async-console.h
new file mode 100644
index 0000000..6779ae2
--- /dev/null
+++ b/android/async-console.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ANDROID_ASYNC_CONSOLE_H
+#define ANDROID_ASYNC_CONSOLE_H
+
+#include "android/async-utils.h"
+
+/* An AsyncConsoleConnector allows you to asynchronously connect to an
+ * Android console port.
+ */
+typedef struct {
+ int state;
+ int error;
+ LoopIo* io;
+ SockAddress address;
+ AsyncConnector connector[1];
+ AsyncLineReader lreader[1];
+ uint8_t lbuff[128];
+} AsyncConsoleConnector;
+
+/* Initialize the console connector. This attempts to connect to the address
+ * provided through 'io'. Use asyncConsoleConnect_run() after that.
+ */
+AsyncStatus
+asyncConsoleConnector_connect(AsyncConsoleConnector* acc,
+ const SockAddress* address,
+ LoopIo* io);
+
+/* Asynchronous console connection management. Returns:
+ *
+ * ASYNC_COMPLETE:
+ * Connection was complete, and the console banner was properly read/eaten.
+ * you can now send/write commands through the console with 'io'.
+ *
+ * ASYNC_ERROR:
+ * An error occured, either during the connection itself, or when
+ * reading the content. This sets errno to ENOPROTOOPT if the connector
+ * detects that you're not connected to a proper Android emulator console
+ * port (i.e. if the banner was incorrect). Other errors are possible
+ * (e.g. in case of early connection termination).
+ *
+ * ASYNC_NEED_MORE:
+ * Not enough data was exchanged, call this function later.
+ */
+AsyncStatus
+asyncConsoleConnector_run(AsyncConsoleConnector* acc,
+ LoopIo* io);
+
+
+#endif /* ANDROID_ASYNC_CONSOLE_H */