1 /**
2  * @namespace   biewlib
3  * @file        biewlib/sysdep/__os_dep.h
4  * @brief       This file contains all operating system depended part of BIEW project.
5  * @version     -
6  * @remark      this source file is part of Binary vIEW project (BIEW).
7  *              The Binary vIEW (BIEW) is copyright (C) 1995 Nickols_K.
8  *              All rights reserved. This software is redistributable under the
9  *              licence given in the file "Licence.en" ("Licence.ru" in russian
10  *              translation) distributed in the BIEW archive.
11  * @note        Requires POSIX compatible development system
12  *
13  * @author      Nickols_K
14  * @since       1999
15  * @note        Development, fixes and improvements
16  * @warning     Under some OSes program may be destroyed if more than one timer per program is created
17  * @deprecated  OS File manipulating functions: I had problem with standard i/o
18  *              function like: open, read, write in different C libraries such
19  *              as emx and possible some one.  It cause to born this section.
20  *
21  * @author      Mauro Giachero
22  * @since       11.2007
23  * @note        Added __get_home_dir()
24 **/
25 #ifndef __OS_DEP_H
26 #define __OS_DEP_H 1
27 
28 #ifndef __SYS_DEP_H
29 #include "biewlib/_sys_dep.h"
30 #endif
31 
32 #ifndef __BIEWLIB_H
33 #define __NORECURSIVE
34 #include "biewlib/biewlib.h"
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /* KEYBOARD handling */
42 
43 #define KBD_NONSTOP_ON_MOUSE_PRESS 0x00000001L /**< Defines that \e kbdGetKey must receive mouse events as frequently as it possible. Otherwise each press on mouse button will send only one event. */
44 
45                    /** Initializes keyboard handler.
46                      * @return                none
47                      * @note                  You must call this function before calling any other keyboard related functions
48                      * @see                   __term_keyboard
49                     **/
50 extern void      __FASTCALL__ __init_keyboard( const char *user_cp );
51 
52                    /** Terminates keyboard handler.
53                      * @return                none
54                      * @note                  You must call this function after last call any other keyboard related functions
55                      * @see                   __init_keyboard
56                     **/
57 extern void      __FASTCALL__ __term_keyboard( void );
58 
59                    /** Receives next keyboard event or note about mouse event.
60                      * @return                event. For detail see KE_* flag definitions in keycode.h file.
61                      * @param flg             Indicates how to react on mouse events. See KBD_* flag definitions.
62                      * @note                  This function only sends note about
63                      *                        occured mouse event. For detailizing
64                      *                        event you must call one of__Ms*
65                      *                        function family.
66                      * @see                   __kbdTestKey __kbdGetShiftKey
67                     **/
68 extern int       __FASTCALL__ __kbdGetKey( unsigned long flg );
69 
70                    /** Checks the keyboard and mouse to determine whether there is available event.
71                      * @return                event if available, 0 - otherwise. For detail see KE_* flag definitions in keycode.h file.
72                      * @param flg             Indicates how to react on mouse events. See KBD_* flag definitions.
73                      * @note                  This function only sends note about
74                      *                        occured mouse event. For detailizing
75                      *                        event you must call one of__Ms*
76                      *                        function family.
77                      * @see                   __kbdGetKey __kbdGetShiftKey
78                     **/
79 extern int       __FASTCALL__ __kbdTestKey( unsigned long flg );
80 
81                    /** Determines the current SHIFT key status.
82                      * @return                Current SHIFT key state. For detail see KS_* flag definitions in keycode.h file.
83                      * @see                   __kbdTestKey __kbdGetKey
84                     **/
85 extern int       __FASTCALL__ __kbdGetShiftsKey( void );
86 
87                    /** Describes info about input events.
88                      * @param head            Pointer to header to be filled
89                      * @param text            Pointer to formatted text to be filled
90                      * @return                0 if ESCAPE's functionality key pressed;
91                                               1 if regulare event occured
92                                               -1 if functionality is not implemented(supported).
93                     **/
94 extern int       __FASTCALL__ __inputRawInfo(char *head, char *text);
95 
96 
97 #if __WORDSIZE == 16
98 typedef unsigned char tAbsCoord; /**< This is the data type used to represent screen-related coordinates */
99 #else
100 typedef unsigned tAbsCoord; /**< This is the data type used to represent screen-related coordinates */
101 #endif
102 
103 /* MOUSE handling */
104 
105 #define MS_LEFTPRESS    1  /**< Defines that left button of mouse have been pressed */
106 #define MS_RIGHTPRESS   2  /**< Defines that middle button of mouse have been pressed */
107 #define MS_MIDDLEPRESS  4  /**< Defines that right button of mouse have been pressed */
108 
109                    /** Initializes mouse handler.
110                      * @return                none
111                      * @note                  You must call this function before calling any other mouse related functions
112                      * @see                   __term_mouse
113                     **/
114 extern int       __FASTCALL__ __init_mouse( void );
115 
116                    /** Terminates mouse handler.
117                      * @return                none
118                      * @note                  You must call this function after last call any other mouse related functions
119                      * @see                   __init_mouse
120                     **/
121 extern void      __FASTCALL__ __term_mouse( void );
122 
123                    /** Returns mouse cursor visibility.
124                      * @return                True if mouse cursor is in visible state
125                      * @see                   __MsGetPos __MsGetBtns __MsSetState
126                     **/
127 extern tBool     __FASTCALL__ __MsGetState( void );
128 
129                    /** Sets mouse cursor visibility.
130                      * @return                none
131                      * @param is_visible      Indicates visibility of mouse cursor
132                      * @see                   __MsGetState
133                     **/
134 extern void      __FASTCALL__ __MsSetState( tBool is_visible );
135 
136                    /** Returns mouse position in screen coordinates.
137                      * @return                none
138                      * @param x,y             Pointers to memory where will be stored current mouse coordinates.
139                      * @note                  Coordinates is measured in text cells of screen
140                      * @see                   __MsGetBtns __MsGetState
141                     **/
142 extern void      __FASTCALL__ __MsGetPos( tAbsCoord *x, tAbsCoord *y );
143 
144                    /** Returns mouse buttons state.
145                      * @return                State of mouse button. For detail see MS_ flag definitions.
146                      * @see                   __MsGetState __MsGetPos
147                     **/
148 extern int       __FASTCALL__ __MsGetBtns( void );
149 
150 /* VIDEO subsystem handling */
151 
152 typedef tUInt8 ColorAttr; /**< This is the data type used to represent attributes of color */
153 typedef tUInt8 t_vchar;   /**< This is the data type used to represent video character */
154 
155 /** Internal structure of video buffer */
156 typedef struct tag_tvioBuff
157 {
158   t_vchar *   chars;       /**< Pointer to video character array */
159   t_vchar *   oem_pg;      /**< Pointer to OEM pseudographics. It needed for *nix terminals */
160   ColorAttr * attrs;       /**< Pointer to color attributes array */
161 }tvioBuff;
162 
163 /*
164 #define __TVIO_MAXSCREENHEIGHT  100 - No dependencies from screen height.
165                                       Today project support any height of
166                                       screen.
167 */
168 #if __WORDSIZE == 16
169 #define __TVIO_MAXSCREENWIDTH   132 /**< Defines maximal width of screen */
170 #else
171 #define __TVIO_MAXSCREENWIDTH   255 /**< Defines maximal width of screen */
172 #endif
173 
174 #define __TVIO_FLG_DIRECT_CONSOLE_ACCESS  0x00000001L /**< Defines that video subsystem must access to console directly, if it possible */
175 #define __TVIO_FLG_USE_7BIT               0x00000002L /**< Defines that video subsystem must strip high bit of video characters */
176 
177 
178                    /** Initializes video handler.
179                      * @return                none
180                      * @note                  You must call this function before calling any other video related functions
181                      * @see                   __term_vio
182                     **/
183 extern void      __FASTCALL__ __init_vio(const char *user_cp, unsigned long flags );
184 
185                    /** Terminates video handler.
186                      * @return                none
187                      * @note                  You must call this function after last call any other video related functions
188                      * @see                   __init_vio
189                     **/
190 extern void      __FASTCALL__ __term_vio( void );
191 
192 #define __TVIO_CUR_OFF   0 /** Defines that cursor in invisible state */
193 #define __TVIO_CUR_NORM  1 /**< Defines that cursor in normal state (filles 20% of the character cell) */
194 #define __TVIO_CUR_SOLID 2 /**< Defines that cursor in solid state (filles 100% of the character cell) */
195 
196                    /** Returns type of cursor.
197                      * @return                cursor type. For detail see __TVIO_CUR* flag definitions.
198                      * @see                   __vioSetCursorType
199                     **/
200 extern int       __FASTCALL__ __vioGetCursorType( void );
201 
202                    /** Sets type of cursor.
203                      * @return                none
204                      * @param c_type          Type of cursor. For detail see __TVIO_CUR* flag definitions
205                      * @see                   __vioGetCursorType
206                     **/
207 extern void      __FASTCALL__ __vioSetCursorType( int c_type );
208 
209                    /** Returns cursor position.
210                      * @return                none
211                      * @param x,y             pointers to memory where will be stored current cursor coordinates.
212                      * @note                  coordinates of cursor is measured in text cells
213                      * @see                   __vioSetCursorPos
214                     **/
215 extern void      __FASTCALL__ __vioGetCursorPos(tAbsCoord* x,tAbsCoord* y);
216 
217                    /** Sets cursor position.
218                      * @return                none
219                      * @param x,y             indicate cursor coordinates.
220                      * @note                  coordinates of cursor is measured in text cells
221                      * @see                   __vioGetCursorPos
222                     **/
223 extern void      __FASTCALL__ __vioSetCursorPos(tAbsCoord x,tAbsCoord y);
224 
225                    /** Rereads information about state of video subsystem.
226                      * @return                none
227                      * @note                  This function updates information
228                      *                        about width and height of video
229                      *                        subsystem, number of colors e.t.c.
230                     **/
231 extern void      __FASTCALL__ __vioRereadState( void );
232 
233                    /** Reads buffer from console (or terminal) video memory at given offset.
234                      * @return                none
235                      * @param x,y             indicate x and y coordinates at which buffer must be readed
236                      * @param buff            pointer to logical video buffer where will be stored readed information
237                      * @param len             indicates length of buffer
238                      * @note                  When program is run in terminal
239                      *                        mode then information will readed from
240                      *                        console emulator but not from terminal
241                      *                        directly.
242                      * @see                   __tvioWriteBuff
243                     **/
244 extern void      __FASTCALL__ __vioReadBuff(tAbsCoord x,tAbsCoord y,tvioBuff *buff,unsigned len);
245 
246                    /** Writes buffer to console (or terminal) video memory at given offset.
247                      * @return                none
248                      * @param x,y             indicate x and y coordinates at which buffer must be readed
249                      * @param buff            pointer to logical video buffer to be written
250                      * @param len             indicates length of buffer
251                      * @see                   __tvioReadBuff
252                     **/
253 extern void      __FASTCALL__ __vioWriteBuff(tAbsCoord x,tAbsCoord y,const tvioBuff *buff,unsigned len);
254 
255 extern tAbsCoord              tvioWidth;     /**< Contains actual width of console (or terminal) */
256 extern tAbsCoord              tvioHeight;    /**< Contains actual height of console (or terminal) */
257 extern unsigned               tvioNumColors; /**< Contains number of actual colors that used by console (or terminal) */
258 
259                    /** Sets color to be transparented
260                      * @return                none
261                      * @param value           indicates logical number of physical color to be transparented
262                      * @note                  Function works only if current
263                      *                        terminal has support of transparent
264                      *                        colors. Returns immediately otherwise.
265                     **/
266 extern void      __FASTCALL__ __vioSetTransparentColor(unsigned char value);
267 
268 /* OS specific functions */
269                    /** Initializes system depended part of biewlib.
270                      * @return                none
271                      * @note                  You must call this function before calling any other function from biewlib library
272                      * @see                   __term_sys
273                     **/
274 extern void      __FASTCALL__ __init_sys( void );
275 
276                    /** Terminates system depended part of biewlib.
277                      * @return                none
278                      * @note                  You must call this function after last call any other function from biewlib library
279                      * @see                   __init_sys
280                     **/
281 extern void      __FASTCALL__ __term_sys( void );
282 
283                    /** Realizes time slice between waiting of input events
284                      * @return                none
285                      * @note                  This function provides mechanism of
286                      *                        system speedup, when application is
287                      *                        waiting for input events. For realizing
288                      *                        time slice inside of computing loops
289                      *                        application must call SLEEP or it
290                      *                        analogs.
291                     **/
292 extern void      __FASTCALL__ __OsYield( void );
293 
294                    /** Gets ctrl-break signal
295                      * @return                True if occured; False - otherwise
296                      * @note                  Function does not differ soft and
297                      *                        hard c-break.
298                      * @warning               After getting signal by program
299                                               semaphore is not being cleaned.
300                     **/
301 extern tBool     __FASTCALL__ __OsGetCBreak( void );
302 
303                    /** Sets control-break signal
304                      * @return                none
305                      * @param state           indicates new state of
306                                               control-break semaphore
307                      * @note                  Function does not differ soft and
308                      *                        hard c-break.
309                     **/
310 extern void      __FASTCALL__ __OsSetCBreak( tBool state );
311 
312                    /** Builds OS specific name of home directory
313                      * @return                Slash terminated path to home directory
314                      * @param progname        indicates name of program, that can be used to revert to a fallback in case the path gets too long
315                      * @note                  Best way it always pass to function
316                      *                        argv[0] program argument.
317                      * @see                   __get_home_dir
318                     **/
319 extern char *    __FASTCALL__ __get_home_dir( const char *progname );
320 
321                    /** Builds OS specific name of initializing file
322                      * @return                fully qualified name of .ini file
323                      * @param progname        indicates name of program, that will be used as part of .ini file name
324                      * @note                  Best way it always pass to function
325                      *                        argv[0] program argument.
326                      * @see                   __get_rc_dir
327                     **/
328 extern char *    __FASTCALL__ __get_ini_name( const char *progname );
329 
330                    /** Builds OS specific name of program resource directory
331                      * @return                Slash terminated path to program resource directory
332                      * @param progname        indicates name of program.
333                      * @note                  Best way it always pass to function
334                      *                        argv[0] program argument.
335                      * @see                   __get_ini_name
336                     **/
337 extern char *    __FASTCALL__ __get_rc_dir( const char *progname );
338 
339 typedef void timer_callback( void ); /**< This is the code type used to represent user supplied function of timer callback */
340 
341                    /** Sets user defined function as timer callback with given time interval
342                      * @return                Real call back interval in milliseconds
343                      * @param ms              indicates desired call back interval in milliseconds
344                      * @param func            indicates user supplied function to be used as timer callback
345                      * @see                   __OsRestoreTimer
346                     **/
347 extern unsigned  __FASTCALL__ __OsSetTimerCallBack(unsigned ms,timer_callback *func);
348 
349                    /** Restores time callback function to original state
350                      * @return                none
351                      * @see                   __OsSetTimercallBack
352                     **/
353 extern void      __FASTCALL__ __OsRestoreTimer(void);
354 
355 #if __WORDSIZE >= 32
356 #define __fileoff_t  tInt64
357 #define __filesize_t tUInt64
358 #define FILEOFF_MAX INT64_MAX
359 #define FILESIZE_MAX UINT64_MAX
360 #else
361 #define __fileoff_t  tInt32
362 #define __filesize_t tUInt32
363 #define FILEOFF_MAX LONG_MAX
364 #define FILESIZE_MAX ULONG_MAX
365 #endif
366 
367 #if __WORDSIZE >= 64
368 typedef void* bhandle_t;
369 #else
370 typedef int   bhandle_t;
371 #endif
372 #define NULL_HANDLE ((bhandle_t)-1)
373 
374                    /** Closes opened stream
375                      * @return                none
376                      * @param handle          handle of opened stream
377                      * @see                   __OsOpen
378                     **/
379 extern void      __FASTCALL__ __OsClose(bhandle_t handle);
380 
381                    /** Changes size of opened file
382                      * @return                0 if operation was succesfully performed
383                      * @param handle          handle of opened file
384                      * @param size            new size of file in bytes
385                      * @warning               If file is truncated, the data from
386                      *                        the new end of file to the original
387                      *                        end of the file are lost.
388                      * @see                   __OsTruncFile
389                     **/
390 extern int       __FASTCALL__ __OsChSize(bhandle_t handle, __fileoff_t size);
391 
392                    /** Creates new file and return handle of opened stream associated with file
393                      * @return                handle of opened stream if successful, -1 otherwise
394                      * @param name            name of new file to be created
395                      * @note                  Function creates file with read/write
396                      *                        access by user.
397                      * @see                   __OsOpen __OsClose __OsDelete
398                     **/
399 extern bhandle_t __FASTCALL__ __OsCreate(const char *name);
400 
401                    /** Duplicates an opened file handle by assigning the same file to a new handle.
402                      * @return                handle of new opened stream if successful, -1 otherwise
403                      * @param name            opened handle to be duplicated
404                      * @note                  Function duplicates handle with
405                      *                        same characteristics as opened handle.
406                     **/
407 extern bhandle_t __FASTCALL__ __OsDupHandle(bhandle_t handle);
408 
409                    /** Deletes the file.
410                      * @return                0 if operation was succesfully performed
411                      * @param name            indicates file to be deleted
412                      * @see                   __OsCreate __OsRename
413                     **/
414 extern int       __FASTCALL__ __OsDelete(const char *name);
415 
416 #define FO_READONLY           0x0000 /**< Defines flag of file opening, that indicates opening in read-only mode */
417 #define FO_WRITEONLY          0x0001 /**< Defines flag of file opening, that indicates opening in write-only mode */
418 #define FO_READWRITE          0x0002 /**< Defines flag of file opening, that indicates opening in read-write mode */
419 
420 #define SO_COMPAT             0x0000 /**< Defines flag of file sharing, that indicates opening in compatibility mode */
421 #define SO_DENYALL            0x0010 /**< Defines flag of file sharing, that indicates opening in mode, which denies any access to file by other processes */
422 #define SO_DENYWRITE          0x0020 /**< Defines flag of file sharing, that indicates opening in mode, which denies write access to file by other processes */
423 #define SO_DENYREAD           0x0030 /**< Defines flag of file sharing, that indicates opening in mode, which denies read access to file by other processes */
424 #define SO_DENYNONE           0x0040 /**< Defines flag of file sharing, that indicates opening in mode, which allows any access to file by other processes */
425 #define SO_PRIVATE            0x0080 /**< Defines flag of file sharing, that indicates opening in mode, which denies any access to file by child processes */
426 
427                    /** Opens existed file.
428                      * @return                handle of opened stream if successful, -1 otherwise
429                      * @param name            name of existed file to be opened
430                      * @param mode            combination of FO_* and SO_* flags
431                      * @see                   __OsCreate __OsClose
432                     **/
433 extern bhandle_t __FASTCALL__ __OsOpen(const char *name,int mode);
434 
435                    /** Checks whether the specified file exists
436                      * @return                True if specified file is exists
437                      * @param name            file being checked
438                     **/
439 extern tBool  __FASTCALL__    __IsFileExists(const char *name);
440 
441                    /** Returns length of file in bytes
442                      * @return                length of file if successful; 0 - otherwise
443                      * @param handle          handle of opened stream
444                     **/
445 extern __fileoff_t   __FASTCALL__    __FileLength(bhandle_t handle);
446 
447 #define SEEKF_START           (int)0  /**< Defines references location of computing file offset from beginning of file */
448 #define SEEKF_CUR             (int)1  /**< Defines references location of computing file offset from current position */
449 #define SEEKF_END             (int)2  /**< Defines references location of computing file offset from end of file */
450 
451                    /** Positions file pointer.
452                      * @return                offset from beginning of file to new pointer position in bytes
453                      * @param handle          handle of opened stream
454                      * @param newpos          indicates number of bytes the new position is displaced from origin
455                      * @param origin          indicates reference location from which an offset will be computed
456                      * @see                   __OsTell
457                     **/
458 extern __fileoff_t   __FASTCALL__    __OsSeek(bhandle_t handle, __fileoff_t newpos, int origin);
459 
460                    /** Returns current file position
461                      * @return                offset from beginning of file to file position in bytes
462                      * @param handle          handle of opened stream
463                      * @see                   __OsSeek
464                     **/
465 extern __fileoff_t   __FASTCALL__    __OsTell(bhandle_t handle);
466 
467                    /** Truncates of opened file
468                      * @return                0 if operation was succesfully performed
469                      * @param handle          handle of opened file
470                      * @param newsize         new size of file in bytes
471                      * @depricated            Different C libraries have different
472                      *                        methods for changing size of file
473                      *                        and in many case it undocumented
474                      * @see                   __OsChSize
475                     **/
476 extern int       __FASTCALL__ __OsTruncFile(bhandle_t handle, __filesize_t newsize);
477 
478                    /** Changes name of specified file or directory
479                      * @return                0 if operation was succesfully performed
480                      * @param oldname         indicates name of an existing file or directory
481                      * @param newname         indicates new name of file or directory
482                      * @see                   __OsDelete
483                     **/
484 extern int       __FASTCALL__ __OsRename(const char *oldname,const char *newname);
485 
486                    /** Reads specified number of bytes from file
487                      * @return                number actually readed bytes if successful; -1 on error
488                      * @param handle          handle of opened stream
489                      * @param buff            pointer to memory where will be stored readed information
490                      * @param size            specifies number of bytes to be readed from file
491                      * @note                  Function reads specified number of bytes
492                      *                        from current file position. File
493                      *                        position is changed after reading
494                      *                        on specified number of bytes.
495                      * @see                   __OsWrite
496                     **/
497 extern int       __FASTCALL__ __OsRead(bhandle_t handle,void *buff,unsigned size);
498 
499                    /** Writes specified number of bytes to file
500                      * @return                number actually writed bytes if successful; -1 on error
501                      * @param handle          handle of opened stream
502                      * @param buff            pointer to memory to be written
503                      * @param size            specifies number of bytes to be writed to file
504                      * @note                  Function writes specified number of bytes
505                      *                        at current file position. File
506                      *                        position is changed after writing
507                      *                        on specified number of bytes.
508                      * @see                   __OsRead
509                     **/
510 extern int       __FASTCALL__ __OsWrite(bhandle_t handle,const void *buff,unsigned size);
511 
512 /** Structure for storing and setting file time information */
513 typedef struct tagFTime
514 {
515    unsigned long acctime; /**< contains last access time */
516    unsigned long modtime; /**< constains modification time */
517 }FTime;
518                    /** Gets last access and modification time for given file.
519                      * @return                True if success False otherwise
520                      * @param name            specified name of file
521                      * @param data            pointer to memory where information will be stored
522                      * @see                   __OsSetFTime
523                     **/
524 extern tBool      __FASTCALL__ __OsGetFTime(const char *name,FTime *data);
525 
526                    /** Sets last access and modification time for given file.
527                      * @return                True if success False otherwise
528                      * @param name            specified name of file
529                      * @param data            pointer to memory where information is stored
530                      * @see                   __OsGetFTime
531                     **/
532 extern tBool      __FASTCALL__ __OsSetFTime(const char *name,const FTime *data);
533 
534 /*
535    First edition of Memory Mapped File Support (For modern OS).
536    Note: MMF does not support preffered memory addresses and many other features
537          of standard mmap technology.
538    In this release it would be better to use this technique only for read only
539    operations.
540 */
541 
542 typedef void * mmfHandle;
543 
544                    /** Opens existed file and mapped it into memory.
545                      * @return                handle of opened stream if successful, NULL otherwise
546                      * @param name            name of existed file to be opened
547                      * @param mode            combination of FO_* and SO_* flags
548                      * @see                   __mmfClose
549                     **/
550 mmfHandle          __FASTCALL__ __mmfOpen(const char *fname,int mode);
551 
552                    /** Flushes memory mapped file to the physical file.
553                      * @return                True if successful, False otherwise
554                      * @param mh              handle of opened stream
555                      * @see                   __mmfOpen __mmfClose __mmfSync
556                     **/
557 tBool              __FASTCALL__ __mmfFlush(mmfHandle mh);
558 
559                    /** Synchronizes memory mapped file with the physical file.
560                      * @param mh              handle of opened stream
561                      * @return                mh if successful, NULL otherwise.
562                      * @note                  This function performs both operations
563                                               writting to the file of dirty
564                                               areas and rereading of the file
565                                               back into the memory. On failure
566                                               it closed all handles and freed
567                                               mmfHandle structure.
568                      * @see                   __mmfFlush
569                     **/
570 mmfHandle          __FASTCALL__ __mmfSync(mmfHandle mh);
571 
572                    /** Changes access to the memory mapping of file.
573                      * @return                True if successful, False otherwise
574                      * @param mh              handle of opened stream
575                      * @param flags           combination of FO_* and SO_* flags
576                      * @see                   __mmfOpen __mmfClose
577                     **/
578 tBool              __FASTCALL__ __mmfProtect(mmfHandle mh,int flags);
579 
580                    /** Changes size of existed file mapping.
581                      * @return                True if successful, False otherwise
582                      * @param mh              handle of opened stream
583                      * @param size            new size of mapping in bytes
584                      * @note                  May be not supported by some OS.
585                      * @warning               If mapping is truncated, the data from
586                      *                        the new end of file to the original
587                      *                        end of the file are lost.
588                      * @see                   __mmfOpen __mmfClose __mmfProtect
589                     **/
590 tBool              __FASTCALL__ __mmfResize(mmfHandle mh,long size);
591 
592                    /** Closes existed file mapping.
593                      * @return                None
594                      * @param mh              handle of stream to be closed
595                      * @see                   __mmfOpen
596                     **/
597 void               __FASTCALL__ __mmfClose(mmfHandle mh);
598 
599                    /** Return address in memory where file mapping is assigned.
600                      * @return                Assigned address of file mapping or -1 on error
601                      * @param mh              handle of stream to be closed
602                      * @see                   __mmfOpen
603                     **/
604 void *             __FASTCALL__ __mmfAddress(mmfHandle mh);
605 
606                    /** Returns size of opened MMF stream.
607                      * @return                Length in bytes of opened MMF stream
608                      * @param mh              handle of stream
609                      * @see                   __mmfOpen __mmfAddress
610                     **/
611 long              __FASTCALL__ __mmfSize(mmfHandle mh);
612 
613                    /** Returns workability of MMF subsystem.
614                      * @return                True if mmf is workable on given OS
615                     **/
616 tBool             __FASTCALL__ __mmfIsWorkable( void );
617 
618 /* National Language Support */
619 
620            /** Checks whether the specified character is OEM pseudographical symbol */
621 #define NLS_IS_OEMPG(ch) (((unsigned char)ch) >= 0xB0 && ((unsigned char)ch) <= 0xDF)
622 
623                    /** Prepares tvioBuff buffer from OEM codepage to currently used by OS.
624                      * @return                none
625                      * @param it              buffer to be converted
626                      * @param size            size of buffer elemets in bytes
627                      * @see                   __nls_OemToOsdep __nls_CmdlineToOem NLS_IS_OEMPG
628                     **/
629 extern void      __FASTCALL__ __nls_PrepareOEMForTVio(tvioBuff *it,unsigned size);
630 
631                    /** Converts buffer from OEM codepage to currently used by OS.
632                      * @return                none
633                      * @param str             buffer to be converted
634                      * @param size            size of buffer in bytes
635                      * @see                   __nls_CmdlineToOem __nls_CmdlineToFs
636                     **/
637 extern void      __FASTCALL__ __nls_OemToOsdep(unsigned char *str,unsigned size);
638 
639                    /** Converts buffer from codepage of command line to currently used by OS.
640                      * @return                none
641                      * @param str             buffer to be converted
642                      * @param size            size of buffer in bytes
643                      * @depricated            This function only used in Win32
644                      *                        where codepages of console and command
645                      *                        line is differ.
646                      * @see                   __nls_OemToOsdep __nls_CmdlineToFs
647                     **/
648 extern void      __FASTCALL__ __nls_CmdlineToOem(unsigned char *str,unsigned size);
649 
650                    /** Converts buffer from OEM codepage to currently used by OS's file system.
651                      * @return                none
652                      * @param str             buffer to be converted
653                      * @param size            size of buffer in bytes
654                      * @see                   __nls_OemToOsdep __nls_CmdlineToOem
655                     **/
656 extern void      __FASTCALL__ __nls_OemToFs(unsigned char *str,unsigned size);
657 
658 #ifdef __cplusplus
659 }
660 #endif
661 
662 #endif
663