• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef ANDROID_ASYNC_CONSOLE_H
17 #define ANDROID_ASYNC_CONSOLE_H
18 
19 #include "android/async-utils.h"
20 
21 /* An AsyncConsoleConnector allows you to asynchronously connect to an
22  * Android console port.
23  */
24 typedef struct {
25     int              state;
26     int              error;
27     LoopIo*          io;
28     SockAddress      address;
29     AsyncConnector   connector[1];
30     AsyncLineReader  lreader[1];
31     uint8_t          lbuff[128];
32 } AsyncConsoleConnector;
33 
34 /* Initialize the console connector. This attempts to connect to the address
35  * provided through 'io'. Use asyncConsoleConnect_run() after that.
36  */
37 AsyncStatus
38 asyncConsoleConnector_connect(AsyncConsoleConnector* acc,
39                               const SockAddress*     address,
40                               LoopIo*                io);
41 
42 /* Asynchronous console connection management. Returns:
43  *
44  * ASYNC_COMPLETE:
45  *    Connection was complete, and the console banner was properly read/eaten.
46  *    you can now send/write commands through the console with 'io'.
47  *
48  * ASYNC_ERROR:
49  *    An error occured, either during the connection itself, or when
50  *    reading the content. This sets errno to ENOPROTOOPT if the connector
51  *    detects that you're not connected to a proper Android emulator console
52  *    port (i.e. if the banner was incorrect). Other errors are possible
53  *    (e.g. in case of early connection termination).
54  *
55  * ASYNC_NEED_MORE:
56  *     Not enough data was exchanged, call this function later.
57  */
58 AsyncStatus
59 asyncConsoleConnector_run(AsyncConsoleConnector* acc);
60 
61 
62 #endif /* ANDROID_ASYNC_CONSOLE_H */
63