1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #ifndef __sysdeps_h__ 13 #define __sysdeps_h__ 14 15 /* system-dependent platform abstraction used by the emulated GSM modem 16 */ 17 18 /* to be called before anything else */ 19 20 extern void sys_main_init( void ); 21 22 /** callbacks 23 **/ 24 typedef void (*SysCallback)( void* opaque ); 25 26 /** events 27 **/ 28 enum { 29 SYS_EVENT_READ = 0x01, 30 SYS_EVENT_WRITE = 0x02, 31 SYS_EVENT_ERROR = 0x04, 32 SYS_EVENT_ALL = 0x07 33 }; 34 35 /** channels 36 **/ 37 typedef struct SysChannelRec_* SysChannel; 38 39 typedef void (*SysChannelCallback)( void* opaque, int event_flags ); 40 41 /* XXX: TODO: channel creation functions */ 42 extern SysChannel sys_channel_create_tcp_server( int port ); 43 extern SysChannel sys_channel_create_tcp_handler( SysChannel server_channel ); 44 extern SysChannel sys_channel_create_tcp_client( const char* hostname, int port ); 45 extern int sys_channel_set_non_block( SysChannel channel ); 46 47 extern void sys_channel_on( SysChannel channel, 48 int event_flags, 49 SysChannelCallback event_callback, 50 void* event_opaqe ); 51 52 extern int sys_channel_read( SysChannel channel, void* buffer, int size ); 53 54 extern int sys_channel_write( SysChannel channel, const void* buffer, int size ); 55 56 extern void sys_channel_close( SysChannel channel ); 57 58 59 /** time measurement 60 **/ 61 typedef long long SysTime; 62 63 extern SysTime sys_time_now( void ); 64 65 /** timers 66 **/ 67 typedef struct SysTimerRec_* SysTimer; 68 69 extern SysTimer sys_timer_create( void ); 70 extern void sys_timer_set( SysTimer timer, SysTime when, SysCallback callback, void* opaque ); 71 extern void sys_timer_unset( SysTimer timer ); 72 extern void sys_timer_destroy( SysTimer timer ); 73 74 extern long long sys_time_ms( void ); 75 76 /** main loop (may return immediately on some platform) 77 **/ 78 extern int sys_main_loop( void ); 79 80 #endif /* __sysdeps_h__ */ 81