Context algorithm
Semi-predictive context algorithm implementation
 All Data Structures Files Functions Variables Typedefs Macros Pages
mapfile.c File Reference
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "mapfile.h"
#include "debug.h"
#include <sys/mman.h>

Go to the source code of this file.

Functions

static int fileOpen (char *name, Uint *textlen, BOOL writefile)
 Opens a file and reads gets its size. More...
 
static void * fileParts (int fd, Uint offset, Uint len, BOOL writemap)
 Maps an open file into RAM memory. More...
 
static void * genfile2String (char *name, Uint *textlen, BOOL writefile, BOOL writemap)
 Opens a file and maps it into memory. More...
 
void freetextspace (Uchar *text, Uint textlen)
 Frees the memory used by the mapping of a file. More...
 
void * file2String (char *name, Uint *textlen)
 Opens a file and maps it into memory. More...
 

Function Documentation

void* file2String ( char *  name,
Uint textlen 
)

Opens a file and maps it into memory.

Parameters
[in]namename and path of the file to open.
[out]textlensize in bytes of the file.
Returns
a pointer to the memory map area.

Definition at line 237 of file mapfile.c.

static int fileOpen ( char *  name,
Uint textlen,
BOOL  writefile 
)
static

Opens a file and reads gets its size.

Parameters
[in]namename and path of the file to open.
[out]textlensize in bytes of the file.
[in]writefileflag indicating if the file shall be open with write aceess.
Returns
descriptor of the open file.

Definition at line 157 of file mapfile.c.

static void* fileParts ( int  fd,
Uint  offset,
Uint  len,
BOOL  writemap 
)
static

Maps an open file into RAM memory.

Parameters
[in]fdfile descriptor of the file to map.
[in]offsetstart the map at this offset from the file begining.
[in]lenlength of the section of the file to map.
[in]writemapflag indicating if it will be possible to write the file though the memory map.
Returns
a pointer to the memory map area.

Definition at line 185 of file mapfile.c.

void freetextspace ( Uchar text,
Uint  textlen 
)

Frees the memory used by the mapping of a file.

Parameters
[in]textpointer to the mapped file.
[in]textlensize in bytes of the mapped file memory area.

Definition at line 225 of file mapfile.c.

static void* genfile2String ( char *  name,
Uint textlen,
BOOL  writefile,
BOOL  writemap 
)
static

Opens a file and maps it into memory.

Parameters
[in]namename and path of the file to open.
[out]textlensize in bytes of the file.
[in]writefileflag indicating if the file shall be open with write aceess.
[in]writemapflag indicating if it will be possible to write the file though the memory map.
Returns
a pointer to the memory map area.

Definition at line 209 of file mapfile.c.