home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / WEBSERVE / PI3 / PI3WEB.EXE / DEVEL / INCLUDE / PIFMap.h < prev    next >
C/C++ Source or Header  |  1997-10-19  |  6KB  |  187 lines

  1. /*____________________________________________________________________________*\
  2.  *
  3.  
  4.  Copyright (c) 1997 John Roy. All rights reserved.
  5.  
  6.  These sources, libraries and applications are
  7.  FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
  8.  as long as the following conditions are adhered to.
  9.  
  10.  Redistribution and use in source and binary forms, with or without
  11.  modification, are permitted provided that the following conditions
  12.  are met:
  13.  
  14.  1. Redistributions of source code must retain the above copyright
  15.     notice, this list of conditions and the following disclaimer. 
  16.  
  17.  2. Redistributions in binary form must reproduce the above copyright
  18.     notice, this list of conditions and the following disclaimer in
  19.     the documentation and/or other materials provided with the
  20.     distribution.
  21.  
  22.  3. Redistributions of any form whatsoever and all advertising materials 
  23.     mentioning features must contain the following
  24.     acknowledgment:
  25.     "This product includes software developed by John Roy
  26.     (http://www.johnroy.com/pi3/)."
  27.  
  28.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  29.  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30.  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  31.  IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  32.  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34.  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36.  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  37.  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  38.  OF THE POSSIBILITY OF SUCH DAMAGE.
  39.  
  40.  *____________________________________________________________________________*|
  41.  *
  42.  * $Source: PIFMap.h$
  43.  * $Date: Sun Aug 10 06:29:37 1997$
  44.  *
  45.  Description:
  46. \*____________________________________________________________________________*/
  47. /* $HeaderTop:$ */
  48.  
  49. #ifndef PIFMAP_H_
  50. #define PIFMAP_H_
  51.  
  52. #include "PiAPI.h"
  53.  
  54. /*____________________________________________________________________________*\
  55.  *
  56.  Typedefs:
  57. \*____________________________________________________________________________*/
  58. typedef struct MappedFile PIFMap;
  59.  
  60. /*____________________________________________________________________________*\
  61.  *
  62.  Name:
  63.     PIFMap_new
  64.  
  65.  Synopsis:
  66.     PIFMap *PIFMap_new( const PIFInfo *pFileInfo )
  67.  
  68.  Description:
  69.     Create a new mapped file object to map a file into virtual
  70.     memory.
  71.  
  72.  Notes:
  73.     The mapped file object should be destroyed using PIFMap_delete()
  74.     when it is no longer needed.
  75.  
  76.  Return Values:
  77.     On success PIFInfo returns a pointer to a new mapped file object.
  78.  
  79.  Errors:
  80.     If pFileInfo is NULL or memory cannot be allocated PIFMap_new() will
  81.     return NULL.
  82.  
  83.     More specific error information can be retrieved using
  84.     PIPlatform_getLastError().
  85.  
  86.  See Also:
  87.     PIFMap_delete().
  88. \*____________________________________________________________________________*/
  89. PUBLIC_PIAPI PIFMap *PIFMap_new( const PIFInfo *pFileInfo );
  90.  
  91. /*____________________________________________________________________________*\
  92.  *
  93.  Name:
  94.     PIFMap_delete
  95.  
  96.  Synopsis:
  97.     int PIFMap_delete( PIFMap *pMappedFile )
  98.  
  99.  Description:
  100.     Destroys and free memory associated with the mapped file object
  101.     pMappedFile.
  102.  
  103.  Notes:
  104.  Return Values:
  105.     On success PIFMap_delete() returns zero (PIAPI_COMPLETED).
  106.  
  107.  Errors:
  108.     On error PIFMap_delete() returns a negative value.
  109.  
  110.     More specific error information can be retrieved using
  111.     PIPlatform_getLastError().
  112.  
  113.  See Also:
  114.     PIFMap_new()
  115. \*____________________________________________________________________________*/
  116. PUBLIC_PIAPI int PIFMap_delete( PIFMap *pMappedFile );
  117.  
  118. /*____________________________________________________________________________*\
  119.  *
  120.  Name:
  121.     PIFMap_lock
  122.  
  123.  Synopsis:
  124.     void *PIFMap_lock( PIFMap *pMappedFile, int *piLength )
  125.  
  126.  Description:
  127.     Locks a mapped file object in memory and returns a pointer 
  128.     to the first byte. If piLength is not NULL the length of
  129.     the mapped file will be written in the location it points at.
  130.  
  131.  Notes:
  132.     PIFMap_lock() maps the file in read only mode. When the address
  133.     of the file map is no longer needed the mapped file object should
  134.     be unlocked using PIFMap_unlock(). PIFMap_lock() and PIFMap_unlock()
  135.     may be invoked any number of times in order.
  136.  
  137.  Return Values:
  138.     On success PIFMap_lock() returns a pointer to a memory address where
  139.     the file has been mapped.
  140.  
  141.  Errors:
  142.     PIFMap_lock() returns NULL if pMappedFile is NULL or an error
  143.     occurred.
  144.  
  145.     More specific error information can be retrieved using
  146.     PIPlatform_getLastError().
  147.  
  148.  See Also:
  149.     PIFMap_unlock().
  150. \*____________________________________________________________________________*/
  151. PUBLIC_PIAPI void *PIFMap_lock( PIFMap *pMappedFile, int *piLength );
  152.  
  153. /*____________________________________________________________________________*\
  154.  *
  155.  Name:
  156.     PIFMap_unlock
  157.  
  158.  Synopsis:
  159.     int PIFMap_unlock( PIFMap *pMappedFile )
  160.  
  161.  Description:
  162.     Unlocks the mapped file object pMappedFile. This invalidates any
  163.     memory pointer obtained from PIFMap_lock().
  164.  
  165.  Notes:
  166.     The use of lock and unlock on a file mapping object allows some operating
  167.     systems to more efficiently manage system resources.
  168.     It is an error to invoke PIFMap_unlock() on a file mapping object
  169.     that has not been locked with PIFMap_lock().
  170.  
  171.  Return Values:
  172.     On success PIFMap_unlock() returns zero (PIAPI_COMPLETED). 
  173.  
  174.  Errors:
  175.     On error PIFMap_unlock() returns a negative value.
  176.  
  177.     More specific error information can be retrieved using
  178.     PIPlatform_getLastError().
  179.  
  180.  See Also:
  181.     PIFMap_lock().
  182. \*____________________________________________________________________________*/
  183. PUBLIC_PIAPI int PIFMap_unlock( PIFMap *pMappedFile );
  184.  
  185. #endif    /* PIFMAP_H_ */
  186.  
  187.