home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Troubleshooting Netware Systems
/
CSTRIAL0196.BIN
/
attach
/
msj
/
v10n10
/
gmmfsrc.exe
/
GMMF.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-10-01
|
4KB
|
114 lines
/*****************************************************************************
Module name: GMMF.h
Written by: Jeffrey Richter
Purpose: Function prototypes for using growable memory-mapped files.
*****************************************************************************/
// If you application runs on Windows NT only, uncomment the line below.
// If you rapplication runs on both Windows 95 and Windows NT, leave the line
// below commented out.
//#define GMMF_WINNT_ONLY
//////////////////////////////////////////////////////////////////////////////
// Opaque data structure initialized by GMMF_Create and used by
// GMMF_ExcFilter and GMMF_Close.
typedef struct {
DWORD cbFileSizeMax; // Max size that file can grow to
DWORD cbFileGrowInc; // File grows by this increment
DWORD cbOverrunBuf; // Reserved area to catch file overflow
HANDLE hFile; // File object
HANDLE hFileMap; // File-mapping object
PBYTE pbFile; // Address to start of file
#ifndef GMMF_WINNT_ONLY
HANDLE hFileMapRes; // Used to reserve address space
#endif
} GMMF, *PGMMF;
//////////////////////////////////////////////////////////////////////////////
// Creates a GMMF and places it in the process's address space. Note that the
// cbFIleSizeMax and cbFileSizeInc values are rounded up to an even
// allocation-granularity boundary. The return value is the address of the
// GMMF or NULL if the GMMF could not be created.
PVOID WINAPI GMMF_Create (PGMMF pgmmf, HANDLE hFile, DWORD cbFileSizeMax,
DWORD cbFileGrowInc, DWORD cbOverrunBuf);
//////////////////////////////////////////////////////////////////////////////
// SEH Exception filter used to grow the GMMF.
long WINAPI GMMF_ExcFilter (PEXCEPTION_POINTERS pexp, PGMMF pgmmf);
//////////////////////////////////////////////////////////////////////////////
// Closes a GMMF and truncates the file to the specified size.
void WINAPI GMMF_Close (PGMMF pgmmf, DWORD cbDiskFile);
//////////////////////////////////////////////////////////////////////////////
// Useful macro for creating our own software exception codes
#define MAKESOFTWAREEXCEPTION(Severity, Facility, Exception) \
((DWORD) ( \
/* Severity code */ (Severity << 0) | \
/* MS(0) or Cust(1) */ (1 << 29) | \
/* Reserved(0) */ (0 << 28) | \
/* Facility code */ (Facility << 16) | \
/* Exception code */ (Exception << 0)))
//////////////////////////////////////////////////////////////////////////////
// GMMF software exceptions thrown when problems arise.
#define FACILITY_GMMF 0
// GMMF_DISKFULL_EXCEPTION is thrown by GMMF_ExcFilter if the GMMF cannot be
// grown because the user is out of disk space.
#define EXCEPTION_GMMF_DISKFULL \
MAKESOFTWAREEXCEPTION(ERROR_SEVERITY_ERROR, FACILITY_GMMF, 1)
// GMMF_CORRUPTEDRGN_EXCEPTION is thrown by GMMF_Create or GMMF_ExcFilter if
// the memory address region containing the GMMF is corrupted due to other
// threads pre-empting the GMMF thread and manipulating the address space.
#define EXCEPTION_GMMF_CORRUPTEDRGN \
MAKESOFTWAREEXCEPTION(ERROR_SEVERITY_ERROR, FACILITY_GMMF, 2)
// GMMF_WRITEPASTMAX_EXCEPTION is thrown by GMMF_ExcFilter if your code
// attempts to write past the GMMF into the overrun buffer.
#define EXCEPTION_GMMF_WRITEPASTMAX \
MAKESOFTWAREEXCEPTION(ERROR_SEVERITY_WARNING, FACILITY_GMMF, 3)
//////////////////////////////////////////////////////////////////////////////
// Returns TRUE if Val is between Low and High inclusively.
#define InRange(Low, Val, High) (((Low) <= (Val)) && ((Val) <= (High)))
//////////////////////////////////////////////////////////////////////////////
// Rounds Val down to the nearest Gran
#define RoundDown(Val, Gran) ((Val) / (Gran) * (Gran))
// Rounds Val up to the nearest Gran
#define RoundUp(Val, Gran) (((Val) + (Gran) - 1) / (Gran) * (Gran))
//////////////////////////////// End of File /////////////////////////////////