//==================================== // Common.C // // Common definitions for ZNibbles // // ZNibbles // Vincent Mallet 1997, 1998 //==================================== // $Id: Common.C,v 1.3 1999/04/03 23:50:24 vmallet Exp $ /* ZNibbles - a small multiplayer game * Copyright (C) 1997, 1998, 1999 Vincent Mallet - vmallet@enst.fr * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include "Common.H" // check if there's something to read on fd int read_ready(int fd, int tmout) // default: tmout = 0 (see Common.H) { fd_set rfds; struct timeval tv; int retval; FD_ZERO(&rfds); FD_SET(fd, &rfds); tv.tv_sec = 0; tv.tv_usec = tmout; // non-blocking retval = select(fd + 1, &rfds, NULL, NULL, &tv); return (retval > 0); }