1*062a843bSAndroid Build Coastguard Worker /* //device/libs/telephony/ril_event.h 2*062a843bSAndroid Build Coastguard Worker ** 3*062a843bSAndroid Build Coastguard Worker ** Copyright 2008, The Android Open Source Project 4*062a843bSAndroid Build Coastguard Worker ** 5*062a843bSAndroid Build Coastguard Worker ** Licensed under the Apache License, Version 2.0 (the "License"); 6*062a843bSAndroid Build Coastguard Worker ** you may not use this file except in compliance with the License. 7*062a843bSAndroid Build Coastguard Worker ** You may obtain a copy of the License at 8*062a843bSAndroid Build Coastguard Worker ** 9*062a843bSAndroid Build Coastguard Worker ** http://www.apache.org/licenses/LICENSE-2.0 10*062a843bSAndroid Build Coastguard Worker ** 11*062a843bSAndroid Build Coastguard Worker ** Unless required by applicable law or agreed to in writing, software 12*062a843bSAndroid Build Coastguard Worker ** distributed under the License is distributed on an "AS IS" BASIS, 13*062a843bSAndroid Build Coastguard Worker ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*062a843bSAndroid Build Coastguard Worker ** See the License for the specific language governing permissions and 15*062a843bSAndroid Build Coastguard Worker ** limitations under the License. 16*062a843bSAndroid Build Coastguard Worker */ 17*062a843bSAndroid Build Coastguard Worker 18*062a843bSAndroid Build Coastguard Worker // Max number of fd's we watch at any one time. Increase if necessary. 19*062a843bSAndroid Build Coastguard Worker #define MAX_FD_EVENTS 8 20*062a843bSAndroid Build Coastguard Worker 21*062a843bSAndroid Build Coastguard Worker typedef void (*ril_event_cb)(int fd, short events, void *userdata); 22*062a843bSAndroid Build Coastguard Worker 23*062a843bSAndroid Build Coastguard Worker struct ril_event { 24*062a843bSAndroid Build Coastguard Worker struct ril_event *next; 25*062a843bSAndroid Build Coastguard Worker struct ril_event *prev; 26*062a843bSAndroid Build Coastguard Worker 27*062a843bSAndroid Build Coastguard Worker int fd; 28*062a843bSAndroid Build Coastguard Worker int index; 29*062a843bSAndroid Build Coastguard Worker bool persist; 30*062a843bSAndroid Build Coastguard Worker struct timeval timeout; 31*062a843bSAndroid Build Coastguard Worker ril_event_cb func; 32*062a843bSAndroid Build Coastguard Worker void *param; 33*062a843bSAndroid Build Coastguard Worker }; 34*062a843bSAndroid Build Coastguard Worker 35*062a843bSAndroid Build Coastguard Worker // Initialize internal data structs 36*062a843bSAndroid Build Coastguard Worker void ril_event_init(); 37*062a843bSAndroid Build Coastguard Worker 38*062a843bSAndroid Build Coastguard Worker // Initialize an event 39*062a843bSAndroid Build Coastguard Worker void ril_event_set(struct ril_event * ev, int fd, bool persist, ril_event_cb func, void * param); 40*062a843bSAndroid Build Coastguard Worker 41*062a843bSAndroid Build Coastguard Worker // Add event to watch list 42*062a843bSAndroid Build Coastguard Worker void ril_event_add(struct ril_event * ev); 43*062a843bSAndroid Build Coastguard Worker 44*062a843bSAndroid Build Coastguard Worker // Add timer event 45*062a843bSAndroid Build Coastguard Worker void ril_timer_add(struct ril_event * ev, struct timeval * tv); 46*062a843bSAndroid Build Coastguard Worker 47*062a843bSAndroid Build Coastguard Worker // Remove event from watch list 48*062a843bSAndroid Build Coastguard Worker void ril_event_del(struct ril_event * ev); 49*062a843bSAndroid Build Coastguard Worker 50*062a843bSAndroid Build Coastguard Worker // Event loop 51*062a843bSAndroid Build Coastguard Worker void ril_event_loop(); 52*062a843bSAndroid Build Coastguard Worker 53