Imported Upstream version 0.4.8
[platform/upstream/libsmi.git] / win / win.h
1 /*
2  * win.h --
3  *
4  *      Some helper functions to make libsmi compile with vc++ for win32.
5  *
6  * Copyright (c) 2000 E. Schoenfelder, Gaertner Datensysteme Braunschweig.
7  * Copyright (c) 2000 J. Schoenwaelder, Technical University of Braunschweig.
8  *
9  * See the file "COPYING" for information on usage and redistribution
10  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11  *
12  * @(#) $Id: win.h 8057 2008-04-15 14:31:18Z schoenw $
13  */
14
15 #ifndef _WIN_H
16 #define _WIN_H
17
18 #include <ctype.h>
19 #include <limits.h>
20 #include <io.h>
21
22 /*
23  * The access() function exists in the Win32 API, but there are no
24  * defines for the mode parameter. So we provided them here.
25  */
26
27 #ifndef F_OK
28 #define F_OK    00
29 #endif
30 #ifndef W_OK
31 #define W_OK    02
32 #endif
33 #ifndef R_OK
34 #define R_OK    04
35 #endif
36
37 /*
38  * Other function prototypes...
39  */
40
41 #if ! defined(__GNUC__) && defined(__STDC__)
42 int __cdecl fileno(FILE *); 
43 #endif
44
45 /*
46  * isascii() is a non __STDC__ extension needed when __STDC__ is defined in
47  * Win32 environment.
48  */
49
50 #if defined(__STDC__)
51 #ifndef isascii
52 #define isascii(_c)   ( (unsigned)(_c) < 0x80 )
53 #endif
54 #endif
55
56 /*
57  * Windows seems to lacks C99 function fabsf(), strtold(). Well, this
58  * is only true for some compilers on Windows - gcc is fine since it
59  * comes with a C99 library.
60  */
61
62 #if ! defined(__GNUC__)
63 #define fabsf           fabs
64 #define strtold         strtod
65 #endif
66
67 /*
68  * Some Windows compilers seem to lack strtof() so we fake it here.
69  */
70
71 #if defined(_MSC_VER)
72 #define strtof(f1,f2) ((float)strtod(f1,f2))
73
74 /*
75  * Windows compiler writers love to issue warnings for C functions
76  * whose names were changed by C++ standards.  Since access is used as
77  * the name of a structure member it has to be treated differently.
78  */
79
80 #define access(f1,f2) _access(f1,f2)
81 #define putenv        _putenv
82 #define strdup        _strdup
83 #define vsnprintf     _vsnprintf
84 #define strcasecmp    _stricmp
85
86 #endif /* _MSC_VER */
87
88 #endif /* _WIN_H */