0
|
1 /*
|
|
2 * $Id: wnn_os.h,v 1.17 2006/03/04 19:01:45 aonoto Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 * Copyright FreeWnn Project 1999, 2000, 2002, 2005, 2006
|
|
14 *
|
|
15 * Maintainer: FreeWnn Project
|
|
16 *
|
|
17 * This library is free software; you can redistribute it and/or
|
|
18 * modify it under the terms of the GNU Lesser General Public
|
|
19 * License as published by the Free Software Foundation; either
|
|
20 * version 2 of the License, or (at your option) any later version.
|
|
21 *
|
|
22 * This library is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
25 * Lesser General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU Lesser General Public
|
|
28 * License along with this library; if not, write to the
|
|
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
30 * Boston, MA 02111-1307, USA.
|
|
31 */
|
|
32
|
|
33 #ifndef WNN_OS_H
|
|
34 #define WNN_OS_H
|
|
35
|
|
36 #ifdef HAVE_CONFIG_H
|
|
37 # include <config.h>
|
|
38 #endif
|
|
39
|
|
40 /* system headers needed for system dependent configuration */
|
|
41 #include <signal.h>
|
|
42 #if STDC_HEADERS
|
|
43 # include <stdlib.h>
|
|
44 # include <limits.h>
|
|
45 #endif /* STDC_HEADERS */
|
|
46
|
|
47 #include <sys/types.h>
|
|
48 #include <sys/file.h>
|
|
49 #if HAVE_SYS_PARAM_H
|
|
50 # include <sys/param.h>
|
|
51 #endif
|
|
52
|
|
53 /* strchr vs. index, etc. */
|
|
54 #if (HAVE_MEMSET) && !(HAVE_BZERO)
|
|
55 # define bzero(adr,n) memset((adr),0,(n))
|
|
56 #endif
|
|
57 #if !(HAVE_STRCHR) && (HAVE_INDEX)
|
|
58 # define strchr index
|
|
59 #endif
|
|
60 #if !(HAVE_STRRCHR) && (HAVE_RINDEX)
|
|
61 # define strrchr rindex
|
|
62 #endif
|
|
63
|
|
64 /* SIGNAL */
|
|
65
|
|
66 #ifdef SYSVR2
|
|
67 #ifndef re_signal
|
|
68 # define re_signal(x, y) signal((x), (y))
|
|
69 #endif
|
|
70 #else
|
|
71 # define re_signal(x, y)
|
|
72 #endif
|
|
73
|
|
74 #if !defined (SIGCHLD) && defined (SIGCLD)
|
|
75 # define SIGCHLD SIGCLD
|
|
76 #endif
|
|
77
|
|
78 typedef RETSIGTYPE (*intfnptr) ();
|
|
79
|
|
80 /* Temporally place the number of filedescripters hack here. */
|
|
81 #if HAVE_GETDTABLESIZE
|
|
82 # define WNN_NFD getdtablesize()
|
|
83 #elif defined (OPEN_MAX)
|
|
84 # define WNN_NFD OPEN_MAX
|
|
85 #elif defined (NOFILE)
|
|
86 # define WNN_NFD NOFILE
|
|
87 #endif /* HAVE_GETDTABLESIZE */
|
|
88
|
|
89 /* pseudo ramdom number */
|
|
90 #if !defined (RAND_MAX)
|
|
91 # if defined (INT_MAX)
|
|
92 # define RAND_MAX INT_MAX
|
|
93 # else
|
|
94 # define RAND_MAX 0x7fffffff
|
|
95 # endif /* INT_MAX */
|
|
96 #endif /* RAND_MAX*/
|
|
97
|
|
98 #if HAVE_DRAND48
|
|
99 # define DRAND() drand48 ()
|
|
100 # define SDRAND(x) srand48 (x)
|
|
101 #elif HAVE_RAMDOM
|
|
102 # define DRAND() ((double) random() / (double) RAND_MAX)
|
|
103 # define SDRAND(x) srandom (x)
|
|
104 #else
|
|
105 # define DRAND() ((double) rand() / (double) RAND_MAX)
|
|
106 # define SDRAND(x) srand (x)
|
|
107 #endif /* HAVE_DRAND48 */
|
|
108
|
|
109 #if HAVE_RANDOM
|
|
110 # define RAND() random ()
|
|
111 # define SRAND(x) srandom (x)
|
|
112 #else
|
|
113 # define RAND() rand ()
|
|
114 # define SRAND(x) srand (x)
|
|
115 #endif /* HAVE_RANDOM */
|
|
116
|
|
117 /*
|
|
118 * It may be needless and had better be removed, however,
|
|
119 * Wnn4 did not take it for granted that the system provided
|
|
120 * FD_SET and other feature that SUS v.2 determines.
|
|
121 * So I left Wnn4's own definition with a little modification
|
|
122 * in case the system did not provide the feature.
|
|
123 * I took a look into the FreeBSD definition of FD_* family.
|
|
124 * A small change comes from Canna 3.6p3.
|
|
125 */
|
|
126 #if !defined(HAVE_FD_SET) && !defined(FD_SET) && defined(HAVE_UNISTD_H)
|
|
127 # include <unistd.h> /* to define FD_SET */
|
|
128 #endif
|
|
129 #if !defined(HAVE_FD_SET) && !defined(FD_SET)
|
|
130 typedef unsigned long fd_mask;
|
|
131 #define BINTSIZE (sizeof(unsigend long) *8)
|
|
132 #define SETSIZE WNN_NFD
|
|
133 #define SET_WIDTH ((SETSIZE) + (BINTSIZE - 1U) / (BINTSIZE))
|
|
134 typedef struct wnn_fd_set {
|
|
135 wnn_fd_mask fds_bits[SET_WIDTH];
|
|
136 }
|
|
137 #define FD_SET(pos,array) (array[pos/BINTSIZE] |= (1<<(pos%BINTSIZE)))
|
|
138 #define FD_CLR(pos,array) (array[pos/BINTSIZE] &= ~(1<<(pos%BINTSIZE)))
|
|
139 #define FD_ISSET(pos,array) (array[pos/BINTSIZE] & (1<<(pos%BINTSIZ
|
|
140 E)))
|
|
141 #define FD_ZERO(array) (bzero (array, FD_SET_WIDTH))
|
|
142 #endif /* !HAVE_FD_SET */
|
|
143
|
|
144
|
|
145 /* function prototypes (temporal use. need reconstruction) */
|
|
146 char *get_server_env (char *lang); /* server_env.c */
|
|
147 unsigned int create_cswidth (char *s); /* xutoj.c */
|
|
148 int euksc_to_ksc (unsigned char *ksc,
|
|
149 unsigned char *euksc,
|
|
150 int eusiz); /* xutoj.c */
|
|
151
|
|
152 #endif /* WNN_OS_H */
|