1 #ifndef CORELIB___NCBISYS__HPP
2 #define CORELIB___NCBISYS__HPP
3 
4 /*  $Id: ncbisys.hpp 604426 2020-03-27 15:54:07Z ivanov $
5  * ===========================================================================
6  *
7  *                            PUBLIC DOMAIN NOTICE
8  *               National Center for Biotechnology Information
9  *
10  *  This software/database is a "United States Government Work" under the
11  *  terms of the United States Copyright Act.  It was written as part of
12  *  the author's official duties as a United States Government employee and
13  *  thus cannot be copyrighted.  This software/database is freely available
14  *  to the public for use. The National Library of Medicine and the U.S.
15  *  Government have not placed any restriction on its use or reproduction.
16  *
17  *  Although all reasonable efforts have been taken to ensure the accuracy
18  *  and reliability of the software and data, the NLM and the U.S.
19  *  Government do not and cannot warrant the performance or results that
20  *  may be obtained by using this software or data. The NLM and the U.S.
21  *  Government disclaim all warranties, express or implied, including
22  *  warranties of performance, merchantability or fitness for any particular
23  *  purpose.
24  *
25  *  Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrei Gourianov
30  *
31  * File Description:
32  *      Wrappers around standard functions
33  */
34 
35 #include <ncbiconf.h>
36 
37 
38 #if defined(NCBI_OS_MSWIN)
39 
40 #    define NcbiSys_close        _close
41 #    define NcbiSys_dup          _dup
42 #    define NcbiSys_dup2         _dup2
43 #    define NcbiSys_fileno       _fileno
44 #    define NcbiSys_fstat        _fstat64
45 #    define NcbiSys_getpid       _getpid
46 #    define NcbiSys_lseek        _lseek
47 #    define NcbiSys_setmode      _setmode
48 #    define NcbiSys_swab         _swab
49 #    define NcbiSys_tzset        _tzset
50 #    define NcbiSys_umask        _umask
51 #    define NcbiSys_write        _write
52 
53 #  if defined(_UNICODE)
54 
55 #    define NcbiSys_chdir        _wchdir
56 #    define NcbiSys_chmod        _wchmod
57 #    define NcbiSys_creat        _wcreat
58 #    define NcbiSys_fopen        _wfopen
59 #    define NcbiSys_getcwd       _wgetcwd
60 #    define NcbiSys_getenv       _wgetenv
61 #    define NcbiSys_mkdir        _wmkdir
62 #    define NcbiSys_open         _wopen
63 #    define NcbiSys_putenv       _wputenv
64 #    define NcbiSys_remove       _wremove
65 #    define NcbiSys_rename       _wrename
66 #    define NcbiSys_rmdir        _wrmdir
67 #    define NcbiSys_spawnv       _wspawnv
68 #    define NcbiSys_spawnve      _wspawnve
69 #    define NcbiSys_spawnvp      _wspawnvp
70 #    define NcbiSys_spawnve      _wspawnve
71 #    define NcbiSys_spawnvpe     _wspawnvpe
72 #    define NcbiSys_stat         _wstat64
73 #    define NcbiSys_strcmp        wcscmp
74 #    define NcbiSys_strdup       _wcsdup
75 #    define NcbiSys_strerror     _wcserror
76 #    define NcbiSys_strerror_s   _wcserror_s
77 #    define NcbiSys_system       _wsystem
78 #    define NcbiSys_tempnam      _wtempnam
79 #    define NcbiSys_unlink       _wunlink
80 
81 #  else // _UNICODE
82 
83 #    define NcbiSys_chdir        _chdir
84 #    define NcbiSys_chmod        _chmod
85 #    define NcbiSys_creat        _creat
86 #    define NcbiSys_fopen         fopen
87 #    define NcbiSys_getcwd       _getcwd
88 #    define NcbiSys_getenv        getenv
89 #    define NcbiSys_mkdir        _mkdir
90 #    define NcbiSys_open         _open
91 #    define NcbiSys_putenv       _putenv
92 #    define NcbiSys_remove        remove
93 #    define NcbiSys_rename        rename
94 #    define NcbiSys_rmdir        _rmdir
95 #    define NcbiSys_spawnv       _spawnv
96 #    define NcbiSys_spawnve      _spawnve
97 #    define NcbiSys_spawnvp      _spawnvp
98 #    define NcbiSys_spawnve      _spawnve
99 #    define NcbiSys_spawnvpe     _spawnvpe
100 #    define NcbiSys_stat         _stat64
101 #    define NcbiSys_strcmp        strcmp
102 #    define NcbiSys_strdup       _strdup
103 #    define NcbiSys_strerror      strerror
104 #    define NcbiSys_strerror_s    strerror_s
105 #    define NcbiSys_system        system
106 #    define NcbiSys_tempnam      _tempnam
107 #    define NcbiSys_unlink       _unlink
108 
109 #  endif // _UNICODE
110 
111 #else // NCBI_OS_MSWIN
112 
113 #  define NcbiSys_chdir         chdir
114 #  define NcbiSys_chmod         chmod
115 #  define NcbiSys_close         close
116 #  define NcbiSys_creat         creat
117 #  define NcbiSys_dup           dup
118 #  define NcbiSys_dup2          dup2
119 #  define NcbiSys_fileno        fileno
120 #  define NcbiSys_fstat         fstat
121 #  define NcbiSys_fopen         fopen
122 #  define NcbiSys_getcwd        getcwd
123 #  define NcbiSys_getenv        getenv
124 #  define NcbiSys_getpid        getpid
125 #  define NcbiSys_lseek         lseek
126 #  define NcbiSys_mkdir         mkdir
127 #  define NcbiSys_open          open
128 #  define NcbiSys_putenv        putenv
129 #  define NcbiSys_remove        remove
130 #  define NcbiSys_rename        rename
131 #  define NcbiSys_rmdir         rmdir
132 #  define NcbiSys_setmode       setmode
133 #  define NcbiSys_spawnv        spawnv
134 #  define NcbiSys_spawnve       spawnve
135 #  define NcbiSys_spawnvp       spawnvp
136 #  define NcbiSys_spawnve       spawnve
137 #  define NcbiSys_spawnvpe      spawnvpe
138 #  define NcbiSys_stat          stat
139 #  define NcbiSys_strdup        strdup
140 #  define NcbiSys_strerror      strerror
141 #  define NcbiSys_swab          swab
142 #  define NcbiSys_tempnam       tempnam
143 #  define NcbiSys_tzset         tzset
144 #  define NcbiSys_umask         umask
145 #  define NcbiSys_unlink        unlink
146 #  define NcbiSys_write         write
147 
148 #endif // NCBI_OS_MSWIN
149 
150 
151 
152 /// C++ Toolkit Unicode is different, all strings are still char*
153 
154 #if defined(NCBI_OS_MSWIN)
155 
156 #  define NcbiSysChar_chdir        _chdir
157 #  define NcbiSysChar_creat        _creat
158 #  define NcbiSysChar_fopen         fopen
159 #  define NcbiSysChar_getcwd       _getcwd
160 #  define NcbiSysChar_getenv        getenv
161 #  define NcbiSysChar_mkdir        _mkdir
162 #  define NcbiSysChar_open         _open
163 #  define NcbiSysChar_putenv       _putenv
164 #  define NcbiSysChar_remove        remove
165 #  define NcbiSysChar_rename        rename
166 #  define NcbiSysChar_rmdir        _rmdir
167 #  define NcbiSysChar_spawnv       _spawnv
168 #  define NcbiSysChar_spawnve      _spawnve
169 #  define NcbiSysChar_spawnvp      _spawnvp
170 #  define NcbiSysChar_spawnve      _spawnve
171 #  define NcbiSysChar_spawnvpe     _spawnvpe
172 #  define NcbiSysChar_stat         _stat64
173 #  define NcbiSysChar_strcmp        strcmp
174 #  define NcbiSysChar_strdup       _strdup
175 #  define NcbiSysChar_strerror      strerror
176 #  define NcbiSysChar_strerror_s    strerror_s
177 #  define NcbiSysChar_system        system
178 #  define NcbiSysChar_tempnam      _tempnam
179 #  define NcbiSysChar_unlink       _unlink
180 
181 #else // NCBI_OS_MSWIN
182 
183 #  define NcbiSysChar_chdir         chdir
184 #  define NcbiSysChar_creat         creat
185 #  define NcbiSysChar_fstat         fstat
186 #  define NcbiSysChar_fopen         fopen
187 #  define NcbiSysChar_getcwd        getcwd
188 #  define NcbiSysChar_getenv        getenv
189 #  define NcbiSysChar_lseek         lseek
190 #  define NcbiSysChar_mkdir         mkdir
191 #  define NcbiSysChar_open          open
192 #  define NcbiSysChar_putenv        putenv
193 #  define NcbiSysChar_remove        remove
194 #  define NcbiSysChar_rename        rename
195 #  define NcbiSysChar_rmdir         rmdir
196 #  define NcbiSysChar_setmode       setmode
197 #  define NcbiSysChar_spawnv        spawnv
198 #  define NcbiSysChar_spawnve       spawnve
199 #  define NcbiSysChar_spawnvp       spawnvp
200 #  define NcbiSysChar_spawnve       spawnve
201 #  define NcbiSysChar_spawnvpe      spawnvpe
202 #  define NcbiSysChar_stat          stat
203 #  define NcbiSysChar_strdup        strdup
204 #  define NcbiSysChar_strerror      strerror
205 #  define NcbiSysChar_tempnam       tempnam
206 #  define NcbiSysChar_unlink        unlink
207 
208 #endif // NCBI_OS_MSWIN
209 
210 
211 
212 
213 
214 // TNcbiSys_(f)stat structures
215 
216 #if defined(NCBI_OS_MSWIN)
217 typedef struct _fstat64 TNcbiSys_fstat;
218 typedef struct _stat64  TNcbiSys_stat;
219 #else
220 typedef struct stat     TNcbiSys_fstat;
221 typedef struct stat     TNcbiSys_stat;
222 #endif
223 
224 
225 #endif  /* CORELIB___NCBISYS__HPP */
226