rasdaman API
memfs.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
35 #ifndef _MEMFS_HH_
36 #define _MEMFS_HH_
37 
38 /* For data types used by the memfs */
39 #include "tiffio.h"
40 #include "raslib/odmgtypes.hh"
41 
42 
43 /* Claim blocks in 4k chunks */
44 const int MEMFS_LD_BLOCKSIZE = 12;
45 /* Initially preserve enough room for 16 blocks */
46 const int MEMFS_MAM_ENTRIES = 16;
47 
48 typedef struct memFSContext
49 {
50  r_Long pos, high;
51  int mamSize, mamHighest;
52  char **mam;
53  char *chunk;
54 } memFSContext;
55 
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61  /* Flexible, read-write memFS */
62  int memfs_initfs(thandle_t handle);
63  void memfs_killfs(thandle_t handle);
64  void memfs_newfile(thandle_t handle);
65  tsize_t memfs_read(thandle_t handle, tdata_t mem, tsize_t size);
66  tsize_t memfs_write(thandle_t handle, tdata_t mem, tsize_t size);
67  toff_t memfs_seek(thandle_t handle, toff_t offset, int mode);
68  int memfs_close(thandle_t handle);
69  toff_t memfs_size(thandle_t handle);
70  int memfs_map(thandle_t handle, tdata_t *memp, toff_t *top);
71  void memfs_unmap(thandle_t handle, tdata_t mem, toff_t top);
72 
73  /* Simple, read-only memFS */
74  void memfs_chunk_initfs(thandle_t handle, char *src, r_Long size);
75  tsize_t memfs_chunk_read(thandle_t handle, tdata_t mem, tsize_t size);
76  toff_t memfs_chunk_seek(thandle_t handle, toff_t offset, int mode);
77  int memfs_chunk_close(thandle_t handle);
78  toff_t memfs_chunk_size(thandle_t handle);
79  int memfs_chunk_map(thandle_t handle, tdata_t *memp, toff_t *top);
80  void memfs_chunk_unmap(thandle_t handle, tdata_t mem, toff_t to);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif
int memfs_chunk_map(thandle_t handle, tdata_t *memp, toff_t *top)
toff_t memfs_chunk_size(thandle_t handle)
char * chunk
Definition: memfs.h:53
int mamSize
Definition: memfs.h:51
int memfs_initfs(thandle_t handle)
const int MEMFS_MAM_ENTRIES
Definition: memfs.hh:46
tsize_t memfs_write(thandle_t handle, tdata_t mem, tsize_t size)
char ** mam
Definition: memfs.h:52
toff_t memfs_size(thandle_t handle)
struct memFSContext memFSContext
toff_t memfs_chunk_seek(thandle_t handle, toff_t offset, int mode)
toff_t memfs_seek(thandle_t handle, toff_t offset, int mode)
void memfs_unmap(thandle_t handle, tdata_t mem, toff_t top)
void memfs_chunk_initfs(thandle_t handle, char *src, r_Long size)
r_Long high
Definition: memfs.h:50
int mamHighest
Definition: memfs.h:51
const int MEMFS_LD_BLOCKSIZE
Definition: memfs.hh:44
int memfs_chunk_close(thandle_t handle)
tsize_t memfs_chunk_read(thandle_t handle, tdata_t mem, tsize_t size)
int r_Long
Definition: odmgtypes.hh:100
int memfs_close(thandle_t handle)
Definition: memfs.h:48
void memfs_killfs(thandle_t handle)
int memfs_map(thandle_t handle, tdata_t *memp, toff_t *top)
r_Long pos
Definition: memfs.h:50
tsize_t memfs_read(thandle_t handle, tdata_t mem, tsize_t size)
void memfs_newfile(thandle_t handle)
void memfs_chunk_unmap(thandle_t handle, tdata_t mem, toff_t to)