home *** CD-ROM | disk | FTP | other *** search
- /*____________________________________________________________________________*\
- *
-
- Copyright (c) 1997 John Roy. All rights reserved.
-
- These sources, libraries and applications are
- FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
- as long as the following conditions are adhered to.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- 3. Redistributions of any form whatsoever and all advertising materials
- mentioning features must contain the following
- acknowledgment:
- "This product includes software developed by John Roy
- (http://www.johnroy.com/pi3/)."
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- OF THE POSSIBILITY OF SUCH DAMAGE.
-
- *____________________________________________________________________________*|
- *
- * $Source: PIFMap.h$
- * $Date: Sun Aug 10 06:29:37 1997$
- *
- Description:
- \*____________________________________________________________________________*/
- /* $HeaderTop:$ */
-
- #ifndef PIFMAP_H_
- #define PIFMAP_H_
-
- #include "PiAPI.h"
-
- /*____________________________________________________________________________*\
- *
- Typedefs:
- \*____________________________________________________________________________*/
- typedef struct MappedFile PIFMap;
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFMap_new
-
- Synopsis:
- PIFMap *PIFMap_new( const PIFInfo *pFileInfo )
-
- Description:
- Create a new mapped file object to map a file into virtual
- memory.
-
- Notes:
- The mapped file object should be destroyed using PIFMap_delete()
- when it is no longer needed.
-
- Return Values:
- On success PIFInfo returns a pointer to a new mapped file object.
-
- Errors:
- If pFileInfo is NULL or memory cannot be allocated PIFMap_new() will
- return NULL.
-
- More specific error information can be retrieved using
- PIPlatform_getLastError().
-
- See Also:
- PIFMap_delete().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI PIFMap *PIFMap_new( const PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFMap_delete
-
- Synopsis:
- int PIFMap_delete( PIFMap *pMappedFile )
-
- Description:
- Destroys and free memory associated with the mapped file object
- pMappedFile.
-
- Notes:
- Return Values:
- On success PIFMap_delete() returns zero (PIAPI_COMPLETED).
-
- Errors:
- On error PIFMap_delete() returns a negative value.
-
- More specific error information can be retrieved using
- PIPlatform_getLastError().
-
- See Also:
- PIFMap_new()
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFMap_delete( PIFMap *pMappedFile );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFMap_lock
-
- Synopsis:
- void *PIFMap_lock( PIFMap *pMappedFile, int *piLength )
-
- Description:
- Locks a mapped file object in memory and returns a pointer
- to the first byte. If piLength is not NULL the length of
- the mapped file will be written in the location it points at.
-
- Notes:
- PIFMap_lock() maps the file in read only mode. When the address
- of the file map is no longer needed the mapped file object should
- be unlocked using PIFMap_unlock(). PIFMap_lock() and PIFMap_unlock()
- may be invoked any number of times in order.
-
- Return Values:
- On success PIFMap_lock() returns a pointer to a memory address where
- the file has been mapped.
-
- Errors:
- PIFMap_lock() returns NULL if pMappedFile is NULL or an error
- occurred.
-
- More specific error information can be retrieved using
- PIPlatform_getLastError().
-
- See Also:
- PIFMap_unlock().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI void *PIFMap_lock( PIFMap *pMappedFile, int *piLength );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFMap_unlock
-
- Synopsis:
- int PIFMap_unlock( PIFMap *pMappedFile )
-
- Description:
- Unlocks the mapped file object pMappedFile. This invalidates any
- memory pointer obtained from PIFMap_lock().
-
- Notes:
- The use of lock and unlock on a file mapping object allows some operating
- systems to more efficiently manage system resources.
- It is an error to invoke PIFMap_unlock() on a file mapping object
- that has not been locked with PIFMap_lock().
-
- Return Values:
- On success PIFMap_unlock() returns zero (PIAPI_COMPLETED).
-
- Errors:
- On error PIFMap_unlock() returns a negative value.
-
- More specific error information can be retrieved using
- PIPlatform_getLastError().
-
- See Also:
- PIFMap_lock().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFMap_unlock( PIFMap *pMappedFile );
-
- #endif /* PIFMAP_H_ */
-
-