Qsmtp  0.23svn
Functions
lib/mmap.c File Reference

function to mmap a file More...

#include <sys/file.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <syslog.h>
#include "mmap.h"
#include "log.h"

Functions

void * mmap_fd (int fd, off_t *len)
void * mmap_name (const char *fname, off_t *len, int *fd)

Detailed Description

function to mmap a file


Function Documentation

void* mmap_fd ( int  fd,
off_t *  len 
)

map an already opened file into memory

Parameters:
fdfile descriptor of opened file
lenlength of mapping will be stored here
Returns:
pointer to mapped area
Return values:
NULLan error occured (errno is set) or file is empty (errno is 0)
void* mmap_name ( const char *  fname,
off_t *  len,
int *  fd 
)

map a file into memory

The file is flock()'ed to allow atomic modification of this file.

Parameters:
fnamepath to file to map
lenlength of mapping will be stored here
fdfile descriptor of opened file will be stored here
Returns:
pointer to mapped area
Return values:
NULLan error occured (errno is set)