1 /* 2 * file com.c - toplevel functions for all communications 3 * 4 * $Id: com.c,v 1.6 2006/02/09 21:21:23 fzago Exp $ 5 * 6 * Program XBLAST 7 * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net) 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published 11 * by the Free Software Foundation; either version 2; or (at your option) 12 * any later version 13 * 14 * This program is distributed in the hope that it will be entertaining, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 * Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc. 21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 24 #include "xblast.h" 25 26 /* 27 * file descriptor becomes writeable 28 */ 29 void CommWriteable(int fd)30CommWriteable (int fd) 31 { 32 /* find associated XBComm */ 33 XBComm *comm = CommFind (fd); 34 if (NULL != comm) { 35 /* call write handler */ 36 assert (NULL != comm->writeFunc); 37 switch ((*comm->writeFunc) (comm)) { 38 case XCR_Finished: 39 case XCR_Error: 40 /* remove on error or finish */ 41 assert (NULL != comm->deleteFunc); 42 (void)(*comm->deleteFunc) (comm); 43 break; 44 default: 45 break; 46 } 47 } 48 } /* CommWriteable */ 49 50 /* 51 * file descriptor becomes readable 52 */ 53 void CommReadable(int fd)54CommReadable (int fd) 55 { 56 /* find associated XBComm */ 57 XBComm *comm = CommFind (fd); 58 if (NULL != comm) { 59 /* call read handler */ 60 assert (NULL != comm->readFunc); 61 switch ((*comm->readFunc) (comm)) { 62 case XCR_Finished: 63 case XCR_Error: 64 /* remove on error or finish */ 65 assert (NULL != comm->deleteFunc); 66 (void)(*comm->deleteFunc) (comm); 67 break; 68 default: 69 break; 70 } 71 } 72 } /* CommReadable */ 73 74 /* 75 * delete given communication 76 */ 77 void CommDelete(XBComm * comm)78CommDelete (XBComm * comm) 79 { 80 assert (NULL != comm); 81 assert (NULL != comm->deleteFunc); 82 (void)(*comm->deleteFunc) (comm); 83 } /* CommDelete */ 84 85 /* 86 * end of file com.c 87 */ 88