| 1 | /* $Id: kRdrAll.h 3550 2007-08-26 01:13:35Z 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-src-spam@anduin.net>
|
|---|
| 8 | *
|
|---|
| 9 | * This file is part of kStuff.
|
|---|
| 10 | *
|
|---|
| 11 | * kStuff is free software; you can redistribute it and/or modify
|
|---|
| 12 | * it under the terms of the GNU Lesser General Public License as published
|
|---|
| 13 | * by the Free Software Foundation; either version 2 of the License, or
|
|---|
| 14 | * (at your option) any later version.
|
|---|
| 15 | *
|
|---|
| 16 | * kStuff is distributed in the hope that it will be useful,
|
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | * GNU Lesser General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU Lesser General Public License
|
|---|
| 22 | * along with kStuff; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | #ifndef ___k_kRdrAll_h___
|
|---|
| 28 | #define ___k_kRdrAll_h___
|
|---|
| 29 |
|
|---|
| 30 | #include <k/kDefs.h>
|
|---|
| 31 | #include "../kLdr/kLdr.h" //later - <k/kLdr.h>
|
|---|
| 32 | #include <k/kRdr.h>
|
|---|
| 33 |
|
|---|
| 34 | #ifdef __cplusplus
|
|---|
| 35 | extern "C" {
|
|---|
| 36 | #endif
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | /** @defgroup grp_kRdrAll All
|
|---|
| 40 | * @addtogroup grp_kRdr
|
|---|
| 41 | * @{
|
|---|
| 42 | */
|
|---|
| 43 |
|
|---|
| 44 | /**
|
|---|
| 45 | * File provider instance operations.
|
|---|
| 46 | */
|
|---|
| 47 | typedef struct KRDROPS
|
|---|
| 48 | {
|
|---|
| 49 | /** The name of this file provider. */
|
|---|
| 50 | const char *pszName;
|
|---|
| 51 | /** Pointer to the next file provider. */
|
|---|
| 52 | const struct KRDROPS *pNext;
|
|---|
| 53 |
|
|---|
| 54 | /** Try create a new file provider instance.
|
|---|
| 55 | *
|
|---|
| 56 | * @returns 0 on success, OS specific error code on failure.
|
|---|
| 57 | * @param ppRdr Where to store the file provider instance.
|
|---|
| 58 | * @param pszFilename The filename to open.
|
|---|
| 59 | */
|
|---|
| 60 | int (* pfnCreate)( PPKRDR ppRdr, const char *pszFilename);
|
|---|
| 61 | /** Destroy the file provider instance.
|
|---|
| 62 | *
|
|---|
| 63 | * @returns 0 on success, OS specific error code on failure.
|
|---|
| 64 | * On failure, the file provider instance will be in an indeterminate state - don't touch it!
|
|---|
| 65 | * @param pRdr The file provider instance.
|
|---|
| 66 | */
|
|---|
| 67 | int (* pfnDestroy)( PKRDR pRdr);
|
|---|
| 68 | /** @copydoc kRdrRead */
|
|---|
| 69 | int (* pfnRead)( PKRDR pRdr, void *pvBuf, KSIZE cb, KFOFF off);
|
|---|
| 70 | /** @copydoc kRdrAllMap */
|
|---|
| 71 | int (* pfnAllMap)( PKRDR pRdr, const void **ppvBits);
|
|---|
| 72 | /** @copydoc kRdrAllUnmap */
|
|---|
| 73 | int (* pfnAllUnmap)(PKRDR pRdr, const void *pvBits);
|
|---|
| 74 | /** @copydoc kRdrSize */
|
|---|
| 75 | KFOFF (* pfnSize)( PKRDR pRdr);
|
|---|
| 76 | /** @copydoc kRdrTell */
|
|---|
| 77 | KFOFF (* pfnTell)( PKRDR pRdr);
|
|---|
| 78 | /** @copydoc kRdrName */
|
|---|
| 79 | const char * (* pfnName)(PKRDR pRdr);
|
|---|
| 80 | /** @copydoc kRdrNativeFH */
|
|---|
| 81 | KIPTR (* pfnNativeFH)(PKRDR pRdr);
|
|---|
| 82 | /** @copydoc kRdrPageSize */
|
|---|
| 83 | KSIZE (* pfnPageSize)(PKRDR pRdr);
|
|---|
| 84 | /** @copydoc kRdrMap */
|
|---|
| 85 | int (* pfnMap)( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed);
|
|---|
| 86 | /** @copydoc kRdrRefresh */
|
|---|
| 87 | int (* pfnRefresh)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments);
|
|---|
| 88 | /** @copydoc kRdrProtect */
|
|---|
| 89 | int (* pfnProtect)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect);
|
|---|
| 90 | /** @copydoc kRdrUnmap */
|
|---|
| 91 | int (* pfnUnmap)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments);
|
|---|
| 92 | /** @copydoc kRdrDone */
|
|---|
| 93 | void (* pfnDone)( PKRDR pRdr);
|
|---|
| 94 | /** The usual non-zero dummy that makes sure we've initialized all members. */
|
|---|
| 95 | KU32 u32Dummy;
|
|---|
| 96 | } KRDROPS;
|
|---|
| 97 | /** Pointer to file provider operations. */
|
|---|
| 98 | typedef KRDROPS *PKRDROPS;
|
|---|
| 99 | /** Pointer to const file provider operations. */
|
|---|
| 100 | typedef const KRDROPS *PCKRDROPS;
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | /**
|
|---|
| 104 | * File provider instance core.
|
|---|
| 105 | */
|
|---|
| 106 | typedef struct KRDR
|
|---|
| 107 | {
|
|---|
| 108 | /** Magic number (KRDR_MAGIC). */
|
|---|
| 109 | KU32 u32Magic;
|
|---|
| 110 | /** Pointer to the file provider operations. */
|
|---|
| 111 | PCKRDROPS pOps;
|
|---|
| 112 | } KRDR;
|
|---|
| 113 |
|
|---|
| 114 | void kRdrAddProvider(PKRDROPS pAdd);
|
|---|
| 115 |
|
|---|
| 116 | /** @} */
|
|---|
| 117 |
|
|---|
| 118 | #ifdef __cplusplus
|
|---|
| 119 | }
|
|---|
| 120 | #endif
|
|---|
| 121 |
|
|---|
| 122 | #endif
|
|---|
| 123 |
|
|---|