tutil.h - vaccinewars - be a doctor and try to vaccinate the world
HTML git clone git://src.adamsgaard.dk/vaccinewars
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tutil.h (2814B)
---
1 /************************************************************************
2 * util.h Miscellaneous utility and portability functions *
3 * Copyright (C) 1998-2021 Ben Webb *
4 * Email: benwebb@users.sf.net *
5 * WWW: https://dopewars.sourceforge.io/ *
6 * *
7 * This program is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU General Public License *
9 * as published by the Free Software Foundation; either version 2 *
10 * of the License, or (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, *
20 * MA 02111-1307, USA. *
21 ************************************************************************/
22
23 #ifndef __DP_UTIL_H__
24 #define __DP_UTIL_H__
25
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29
30 #include <stdio.h>
31
32 #ifdef CYGWIN /* Definitions for native Win32 build */
33 #include <winsock2.h>
34 #include <windows.h>
35 #include <string.h>
36
37 #define SIGWINCH 0
38 #define SIGPIPE 0
39 #define SIG_BLOCK 0
40 #define SIG_UNBLOCK 0
41
42 struct sigaction {
43 void *sa_handler;
44 int sa_flags;
45 int sa_mask;
46 };
47
48 void sigemptyset(int *mask);
49 void sigaddset(int *mask, int sig);
50 int sigaction(int sig, struct sigaction *sact, char *pt);
51 void sigprocmask(int flag, int *mask, char *pt);
52 int bselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfs,
53 struct timeval *tm);
54 #else /* Definitions for Unix build */
55 #define bselect select
56 #endif /* CYGWIN */
57
58 #ifndef HAVE_GETOPT
59 int getopt(int argc, char *const argv[], const char *str);
60 extern char *optarg;
61 #endif
62
63 void MicroSleep(int microsec);
64
65 int ReadLock(FILE *fp);
66 int WriteLock(FILE *fp);
67 void ReleaseLock(FILE *fp);
68
69 /* Now make definitions if they haven't been done properly */
70 #ifndef WEXITSTATUS
71 #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
72 #endif
73
74 #ifndef WIFEXITED
75 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
76 #endif
77
78 #endif /* __DP_UTIL_H__ */