| 1 | /* $Id: kRdrAll.h 29 2009-07-01 20:30:29Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * kRdr - The File Provider, All Details and Dependencies Included.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * Copyright (c) 2006-2007 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
|
|---|
| 8 | *
|
|---|
| 9 | * Permission is hereby granted, free of charge, to any person
|
|---|
| 10 | * obtaining a copy of this software and associated documentation
|
|---|
| 11 | * files (the "Software"), to deal in the Software without
|
|---|
| 12 | * restriction, including without limitation the rights to use,
|
|---|
| 13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|---|
| 14 | * copies of the Software, and to permit persons to whom the
|
|---|
| 15 | * Software is furnished to do so, subject to the following
|
|---|
| 16 | * conditions:
|
|---|
| 17 | *
|
|---|
| 18 | * The above copyright notice and this permission notice shall be
|
|---|
| 19 | * included in all copies or substantial portions of the Software.
|
|---|
| 20 | *
|
|---|
| 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|---|
| 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|---|
| 23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|---|
| 24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|---|
| 25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|---|
| 26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|---|
| 27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|---|
| 28 | * OTHER DEALINGS IN THE SOFTWARE.
|
|---|
| 29 | */
|
|---|
| 30 |
|
|---|
| 31 | #ifndef ___k_kRdrAll_h___
|
|---|
| 32 | #define ___k_kRdrAll_h___
|
|---|
| 33 |
|
|---|
| 34 | #include <k/kDefs.h>
|
|---|
| 35 | #include <k/kLdr.h>
|
|---|
| 36 | #include <k/kRdr.h>
|
|---|
| 37 |
|
|---|
| 38 | #ifdef __cplusplus
|
|---|
| 39 | extern "C" {
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | /** @defgroup grp_kRdrAll All
|
|---|
| 44 | * @addtogroup grp_kRdr
|
|---|
| 45 | * @{
|
|---|
| 46 | */
|
|---|
| 47 |
|
|---|
| 48 | /**
|
|---|
| 49 | * File provider instance operations.
|
|---|
| 50 | */
|
|---|
| 51 | typedef struct KRDROPS
|
|---|
| 52 | {
|
|---|
| 53 | /** The name of this file provider. */
|
|---|
| 54 | const char *pszName;
|
|---|
| 55 | /** Pointer to the next file provider. */
|
|---|
| 56 | const struct KRDROPS *pNext;
|
|---|
| 57 |
|
|---|
| 58 | /** Try create a new file provider instance.
|
|---|
| 59 | *
|
|---|
| 60 | * @returns 0 on success, OS specific error code on failure.
|
|---|
| 61 | * @param ppRdr Where to store the file provider instance.
|
|---|
| 62 | * @param pszFilename The filename to open.
|
|---|
| 63 | */
|
|---|
| 64 | int (* pfnCreate)( PPKRDR ppRdr, const char *pszFilename);
|
|---|
| 65 | /** Destroy the file provider instance.
|
|---|
| 66 | *
|
|---|
| 67 | * @returns 0 on success, OS specific error code on failure.
|
|---|
| 68 | * On failure, the file provider instance will be in an indeterminate state - don't touch it!
|
|---|
| 69 | * @param pRdr The file provider instance.
|
|---|
| 70 | */
|
|---|
| 71 | int (* pfnDestroy)( PKRDR pRdr);
|
|---|
| 72 | /** @copydoc kRdrRead */
|
|---|
| 73 | int (* pfnRead)( PKRDR pRdr, void *pvBuf, KSIZE cb, KFOFF off);
|
|---|
| 74 | /** @copydoc kRdrAllMap */
|
|---|
| 75 | int (* pfnAllMap)( PKRDR pRdr, const void **ppvBits);
|
|---|
| 76 | /** @copydoc kRdrAllUnmap */
|
|---|
| 77 | int (* pfnAllUnmap)(PKRDR pRdr, const void *pvBits);
|
|---|
| 78 | /** @copydoc kRdrSize */
|
|---|
| 79 | KFOFF (* pfnSize)( PKRDR pRdr);
|
|---|
| 80 | /** @copydoc kRdrTell */
|
|---|
| 81 | KFOFF (* pfnTell)( PKRDR pRdr);
|
|---|
| 82 | /** @copydoc kRdrName */
|
|---|
| 83 | const char * (* pfnName)(PKRDR pRdr);
|
|---|
| 84 | /** @copydoc kRdrNativeFH */
|
|---|
| 85 | KIPTR (* pfnNativeFH)(PKRDR pRdr);
|
|---|
| 86 | /** @copydoc kRdrPageSize */
|
|---|
| 87 | KSIZE (* pfnPageSize)(PKRDR pRdr);
|
|---|
| 88 | /** @copydoc kRdrMap */
|
|---|
| 89 | int (* pfnMap)( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed);
|
|---|
| 90 | /** @copydoc kRdrRefresh */
|
|---|
| 91 | int (* pfnRefresh)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments);
|
|---|
| 92 | /** @copydoc kRdrProtect */
|
|---|
| 93 | int (* pfnProtect)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect);
|
|---|
| 94 | /** @copydoc kRdrUnmap */
|
|---|
| 95 | int (* pfnUnmap)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments);
|
|---|
| 96 | /** @copydoc kRdrDone */
|
|---|
| 97 | void (* pfnDone)( PKRDR pRdr);
|
|---|
| 98 | /** The usual non-zero dummy that makes sure we've initialized all members. */
|
|---|
| 99 | KU32 u32Dummy;
|
|---|
| 100 | } KRDROPS;
|
|---|
| 101 | /** Pointer to file provider operations. */
|
|---|
| 102 | typedef KRDROPS *PKRDROPS;
|
|---|
| 103 | /** Pointer to const file provider operations. */
|
|---|
| 104 | typedef const KRDROPS *PCKRDROPS;
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 | /**
|
|---|
| 108 | * File provider instance core.
|
|---|
| 109 | */
|
|---|
| 110 | typedef struct KRDR
|
|---|
| 111 | {
|
|---|
| 112 | /** Magic number (KRDR_MAGIC). */
|
|---|
| 113 | KU32 u32Magic;
|
|---|
| 114 | /** Pointer to the file provider operations. */
|
|---|
| 115 | PCKRDROPS pOps;
|
|---|
| 116 | } KRDR;
|
|---|
| 117 |
|
|---|
| 118 | void kRdrAddProvider(PKRDROPS pAdd);
|
|---|
| 119 |
|
|---|
| 120 | /** @} */
|
|---|
| 121 |
|
|---|
| 122 | #ifdef __cplusplus
|
|---|
| 123 | }
|
|---|
| 124 | #endif
|
|---|
| 125 |
|
|---|
| 126 | #endif
|
|---|
| 127 |
|
|---|