1 /* 2 * file com_base.h 3 * 4 * $Id: com_base.h,v 1.5 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 #ifndef XBLAST_COM_BASE_H 24 #define XBLAST_COM_BASE_H 25 26 /* 27 * type definitions 28 */ 29 30 /* types of communication */ 31 typedef enum 32 { 33 XCS_Init, 34 XCS_Connected, 35 XCS_Finished, 36 XCS_Start 37 } XBCommStatus; 38 39 /* types of communications */ 40 typedef enum 41 { 42 COMM_ToServer, /* connection to server */ 43 COMM_ToClient, /* connection to client */ 44 COMM_DgServer, /* datagram link to server */ 45 COMM_DgClient, /* datagram link to client */ 46 COMM_Listen, /* listen for clients to connect */ 47 COMM_Query, /* query for network games */ 48 COMM_Reply, /* reply with network game */ 49 COMM_NewGame, /* XBCC */ 50 COMM_NewGameOK, /* XBCC */ 51 COMM_ToCentral, /* XBCC connection to central */ 52 COMM_FromCentral /* XBCC connection from central */ 53 } XBCommType; 54 55 /* process functions */ 56 typedef XBCommResult (*XBCommFunc) (XBComm *); 57 58 /* generic data of communication */ 59 struct _xb_comm 60 { 61 XBCommType type; 62 XBComm *next; 63 XBComm *prev; 64 XBSocket *socket; 65 XBCommFunc readFunc; 66 XBCommFunc writeFunc; 67 XBCommFunc deleteFunc; 68 }; 69 70 /* 71 * global prototypes 72 */ 73 extern void CommInit (XBComm * comm, XBCommType type, XBSocket * socket, XBCommFunc readFunc, 74 XBCommFunc writeFunc, XBCommFunc deleteFunc); 75 extern void CommFinish (XBComm * comm); 76 extern XBSocket *CommSocket (XBComm * comm); 77 extern XBComm *CommFind (int fd); 78 79 #endif 80 /* 81 * end of file com_base.h 82 */ 83