1 /* $Id$
2  *  Microsoft Visual C/C++ compiler-specific declarations
3  *
4  * HUSKYLIB: common defines, types and functions for HUSKY
5  *
6  * This is part of The HUSKY Fidonet Software project:
7  * see http://husky.sourceforge.net for details
8  *
9  *
10  * HUSKYLIB is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * HUSKYLIB is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; see file COPYING. If not, write to the
22  * Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  * See also http://www.gnu.org, license may be found here.
25  */
26 
27 /* MS Visual C/C++ */
28 
29 #ifndef HUSKY_MSVC_H
30 #define HUSKY_MSVC_H
31 
32 #ifndef _MSC_VER
33 #  error This file used only with MS Visual C !
34 #endif
35 
36 #if _MSC_VER<1000
37 #  error This file used only with MS Visual C !
38 #endif
39 
40 #if _MSC_VER<1200
41 #  error We can't build HUSKY on your MS Visual C version, sorry.
42 #endif
43 
44 #  ifdef _MAKE_DLL
45 #    define _MAKE_DLL_MVC_
46 #  endif /* ifdef _MAKE_DLL */
47 /*   must be included before function redefenition like '#define fileno _fileno' */
48 #    include <sys/stat.h>
49 #    include <stdio.h>
50 #    include <io.h>
51 #    include <direct.h>
52 #    include <process.h>
53 /* system functions substitutions for DLL build */
54 #    define fileno       _fileno
55 #    define read         _read
56 #    define lseek        _lseek
57 #    define sopen        _sopen
58 #    define write        _write
59 #    define tell         _tell
60 #    define close        _close
61 #    define unlink       _unlink
62 #    define tzset        _tzset
63 #    define stricmp      _stricmp
64 #    define strnicmp     _strnicmp
65 #    define rmdir        _rmdir
66 #    define fstat        _fstat
67 #    define strdup       _strdup
68 #    define strupr       _strupr
69 #    define strlwr       _strlwr
70 #    define stat         _stat
71 #    define getpid       _getpid
72 #    define chsize       _chsize
73 #    define open         _open
74 #    define access       _access
75 #    define spawnvp      _spawnvp
76 #    define spawnl       _spawnl
77 #    define dup          _dup
78 #    define mktemp       _mktemp
79 #    define fdopen       _fdopen
80 #    define chdir        _chdir
81 #    define getcwd       _getcwd
82 #    define isatty       _isatty
83 
84 #   include <limits.h>
85 #   ifndef MAXPATHLEN
86 #     define MAXPATHLEN _MAX_PATH
87 #   endif
88 
89 /*   must be included before macro redefenition '# define SH_DENYNONE _SH_DENYNO' */
90 #   include <share.h>
91 #   ifndef SH_DENYNONE
92 #     ifdef _SH_DENYNO
93 #       define SH_DENYNONE _SH_DENYNO
94 #     else
95 #       pragma message("Please set SH_DENYNONE to proprietary value: used for file locking")
96 #     endif
97 #   endif
98 #   ifndef SH_DENYNO
99 #     ifdef SH_DENYNONE
100 #       define SH_DENYNO SH_DENYNONE
101 #     else
102 #       pragma message("Please set SH_DENYNO to proprietary value: used for file locking")
103 #     endif
104 #   endif
105 /*   must be included before function redefenition '#define P_WAIT _P_WAIT'  */
106 #   include <process.h>
107 #   ifndef P_WAIT
108 #     ifdef _P_WAIT
109 #       define P_WAIT		_P_WAIT   /* process.h */
110 #     else
111 #       pragma message("Please set P_WAIT to proprietary value: used for spawnvp() call")
112 #     endif
113 #   endif
114 
115 #  define _stdc
116 #  ifndef pascal
117 #    define pascal
118 #  endif
119 #  ifndef far
120 #    define far
121 #  endif
122 #  define _fast
123 #  define near
124 #  define _XPENTRY
125 #  define _intr
126 #  define _intcast
127 #  define _veccast
128 #  define _loadds
129 #  define cdecl
130 
131 #  define strcasecmp  stricmp
132 #  define strncasecmp strnicmp
133 
134 #  define sleep(x)    Sleep(1000L*(x))
135 #  define mysleep(x)  Sleep(1000L*(x))
136 #  define farread     read
137 #  define farwrite    write
138 
139 #  define mode_t int
140 
141 /* define macrofunctions for fexist.c */
142 #  ifndef S_ISDIR
143 #    define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
144 #  endif
145 #  ifndef S_ISREG
146 #    define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
147 #  endif
148 
149 /* define constants for 2nd parameter of access() function */
150 #  ifndef F_OK                  /* does file exist */
151 #    define F_OK 0
152 #  endif
153 
154 #  ifndef X_OK                  /* is it executable by caller */
155 #    define X_OK  1
156 #  endif
157 
158 #  ifndef R_OK                  /* is it readable by caller */
159 #    define R_OK 04
160 #  endif
161 
162 #  ifndef W_OK                  /* is it writable by caller */
163 #    define W_OK 02
164 #  endif
165 
166 #  define mymkdir       _mkdir
167 #  define snprintf      _snprintf
168 #  define vsnprintf     _vsnprintf
169 #  define HAS_snprintf       /* snprintf() presents */
170 #  define HAS_vsnprintf      /* vsnprintf() presents */
171 #  define HAS_spawnvp        /* spawnwp() presents */
172 #  define HAS_strftime
173 #  define HAS_mktime
174 #  define HAS_sopen
175 #  define HAS_sleep
176 #  define HAS_strupr
177 
178 #  define USE_SYSTEM_COPY     /* OS have system call for files copiing */
179 #  define USE_SYSTEM_COPY_WIN32
180 #  define USE_STAT_MACROS     /* S_ISDIR, S_ISREG and stat() presents */
181 
182 #  define HAS_IO_H         /* may use "#include <io.h> */
183 #  define HAS_SHARE_H      /* may use "#include <share.h> */
184 #  define HAS_MALLOC_H     /* use "#include <malloc.h>" for malloc() etc. */
185 #  define HAS_SYS_UTIME_H  /* #include <sys/utime.h> in alternate to <utime.h> */
186 #  define HAS_DIRECT_H     /* #include <direct.h> */
187 #  define HAS_PROCESS_H   /* may use "#include <process.h> */
188 
189 
190 typedef unsigned bit;
191 
192 typedef unsigned char byte;
193 typedef signed char sbyte;
194 
195 typedef unsigned short word;
196 typedef signed short sword;
197 
198 #ifdef _M_ALPHA    /* 64 bit system */
199 typedef unsigned int dword;
200 typedef signed   int sdword;
201 #else             /* 32 and 16 bit machines */
202 typedef unsigned long dword;
203 typedef signed long sdword;
204 #endif
205 
206 typedef signed short sshort;
207 typedef unsigned short ushort;
208 
209 typedef signed long slong;
210 typedef unsigned long ulong;
211 
212 
213 typedef   signed char        hCHAR;              /*  1 byte */
214 typedef   signed char       hSCHAR;              /*  1 byte */
215 typedef unsigned char       hUCHAR;              /*  1 byte */
216 
217 typedef   signed __int8      hINT8;              /*  1 byte */
218 typedef   signed __int8     hSINT8;              /*  1 byte */
219 typedef unsigned __int8     hUINT8;              /*  1 byte */
220 
221 typedef   signed __int16    hINT16;              /*  2 bytes */
222 typedef   signed __int16   hSINT16;              /*  2 bytes */
223 typedef unsigned __int16   hUINT16;              /*  2 bytes */
224 
225 typedef   signed __int32    hINT32;              /*  4 bytes */
226 typedef   signed __int32   hSINT32;              /*  4 bytes */
227 typedef unsigned __int32   hUINT32;              /*  4 bytes */
228 
229 typedef   signed __int64    hINT64;              /*  8 bytes */
230 typedef   signed __int64   hSINT64;              /*  8 bytes */
231 typedef unsigned __int64   hUINT64;              /*  8 bytes */
232 #define HAS_INT64
233 
234 #endif
235