16d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner/* 26d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * Copyright (C) 2010 The Android Open Source Project 36d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * 46d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * Licensed under the Apache License, Version 2.0 (the "License"); 56d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * you may not use this file except in compliance with the License. 66d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * You may obtain a copy of the License at 76d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * 86d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * http://www.apache.org/licenses/LICENSE-2.0 96d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * 106d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * Unless required by applicable law or agreed to in writing, software 116d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * distributed under the License is distributed on an "AS IS" BASIS, 126d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * See the License for the specific language governing permissions and 146d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * limitations under the License. 156d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner */ 166d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner#ifndef ANDROID_ASYNC_CONSOLE_H 176d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner#define ANDROID_ASYNC_CONSOLE_H 186d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner 196d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner#include "android/async-utils.h" 206d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner 216d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner/* An AsyncConsoleConnector allows you to asynchronously connect to an 226d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * Android console port. 236d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner */ 246d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turnertypedef struct { 256d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner int state; 266d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner int error; 276d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner LoopIo* io; 286d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner SockAddress address; 296d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner AsyncConnector connector[1]; 306d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner AsyncLineReader lreader[1]; 316d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner uint8_t lbuff[128]; 326d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner} AsyncConsoleConnector; 336d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner 346d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner/* Initialize the console connector. This attempts to connect to the address 356d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * provided through 'io'. Use asyncConsoleConnect_run() after that. 366d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner */ 376d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' TurnerAsyncStatus 386d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' TurnerasyncConsoleConnector_connect(AsyncConsoleConnector* acc, 396d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner const SockAddress* address, 406d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner LoopIo* io); 416d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner 426d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner/* Asynchronous console connection management. Returns: 436d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * 446d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * ASYNC_COMPLETE: 456d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * Connection was complete, and the console banner was properly read/eaten. 466d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * you can now send/write commands through the console with 'io'. 476d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * 486d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * ASYNC_ERROR: 496d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * An error occured, either during the connection itself, or when 506d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * reading the content. This sets errno to ENOPROTOOPT if the connector 516d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * detects that you're not connected to a proper Android emulator console 526d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * port (i.e. if the banner was incorrect). Other errors are possible 536d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * (e.g. in case of early connection termination). 546d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * 556d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * ASYNC_NEED_MORE: 566d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner * Not enough data was exchanged, call this function later. 576d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner */ 586d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' TurnerAsyncStatus 59f9e333ade2529f257ced6bcff8e5824cb07eacf9David 'Digit' TurnerasyncConsoleConnector_run(AsyncConsoleConnector* acc); 606d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner 616d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner 626d448806a80bcc2557ae0a38e7fd206967cf844eDavid 'Digit' Turner#endif /* ANDROID_ASYNC_CONSOLE_H */ 63