2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * iom.c: implements the io mask routines
30 * Known contributors to this file:
34 #include <stdlib.h> /* malloc */
48 imp = (struct io_mask *)malloc(sizeof(*imp));
50 imp->readmask = bit_newfdmask();
51 imp->user_readmask = bit_newfdmask();
54 imp->user_readmask = 0;
56 if (what & IO_WRITE) {
57 imp->writemask = bit_newfdmask();
58 imp->user_writemask = bit_newfdmask();
61 imp->user_writemask = 0;
69 iom_getmask(struct io_mask *mask, int *nfdp, bit_fdmask *readp,
72 if (mask->what & IO_READ)
73 bit_copy(mask->readmask, mask->user_readmask);
74 if (mask->what & IO_WRITE)
75 bit_copy(mask->writemask, mask->user_writemask);
76 *readp = mask->user_readmask;
77 *writep = mask->user_writemask;
82 iom_set(struct io_mask *mask, int what, int fd)
84 if ((mask->what & what) == 0)
87 BIT_SETB(fd, mask->readmask);
89 BIT_SETB(fd, mask->writemask);
95 iom_clear(struct io_mask *mask, int what, int fd)
97 if ((mask->what & what) == 0)
100 BIT_CLRB(fd, mask->readmask);
102 BIT_CLRB(fd, mask->writemask);
106 iom_zero(struct io_mask *mask, int what)
108 if ((mask->what & what) == 0)
111 bit_zero(mask->readmask);
113 bit_zero(mask->writemask);