Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fileheader.c File Reference

Go to the source code of this file.

Description

Implementation of a common header format for working data files created by the lumiera backend.

Todo:
development in this area is stalled since 2010

Definition in file fileheader.c.

#include "lib/tmpbuf.h"
#include "backend/fileheader.h"
#include "backend/file.h"
#include "include/logging.h"
#include <errno.h>

Functions

 LUMIERA_ERROR_DEFINE (FILEHEADER_NOWRITE,"File is not writable")
 
 LUMIERA_ERROR_DEFINE (FILEHEADER_HEADER,"Error in header")
 
 LUMIERA_ERROR_DEFINE (FILEHEADER_FLAGS,"Inconsistent Flags")
 
 LUMIERA_ERROR_DEFINE (FILEHEADER_FLAGSPACE,"No more space for flags left")
 
 LUMIERA_ERROR_DEFINE (FILEHEADER_ENDIANESS,"Unsupported Endianess")
 
void lumiera_fileheader_close (LumieraFileheader self, const char *flags_add)
 Closes a previously created or opened file header. More...
 
lumiera_fileheader lumiera_fileheader_create (LumieraFile file, char *fourcc, int version, size_t size, const char *flags)
 Create a file header on a file open for writing. More...
 
LumieraFileheader lumiera_fileheader_flags_clear (LumieraFileheader self, const char *flags)
 Clear flags if present. More...
 
LumieraFileheader lumiera_fileheader_flags_set (LumieraFileheader self, const char *flags)
 Sets flags if not already set. More...
 
int lumiera_fileheader_flags_validate (LumieraFileheader self, const char *expected, const char *unexpected)
 check if all flags given from some sets are either set or not. More...
 
lumiera_fileheader lumiera_fileheader_open (LumieraFile file, char *fourcc, size_t size, const char *flags_expected, const char *flags_remove)
 Open an existing file header. More...
 
int lumiera_fileheader_version (LumieraFileheader self)
 Queries the version of a file header. More...
 

Function Documentation

LUMIERA_ERROR_DEFINE ( FILEHEADER_NOWRITE  ,
"File is not writable"   
)
LUMIERA_ERROR_DEFINE ( FILEHEADER_HEADER  ,
"Error in header"   
)
LUMIERA_ERROR_DEFINE ( FILEHEADER_FLAGS  ,
"Inconsistent Flags"   
)
LUMIERA_ERROR_DEFINE ( FILEHEADER_FLAGSPACE  ,
"No more space for flags left"   
)
LUMIERA_ERROR_DEFINE ( FILEHEADER_ENDIANESS  ,
"Unsupported Endianess"   
)
lumiera_fileheader lumiera_fileheader_create ( LumieraFile  file,
char *  fourcc,
int  version,
size_t  size,
const char *  flags 
)

Create a file header on a file open for writing.

This overwrites any existing date, take care. The created file header is mmaped into memory and must be closed after use. The File should be locked for operations on the file header.

Parameters
fileThe file on which to create the header.
fourccpointer to a string of length 4
versionversion number for the header (should be incremented after changes) the value '0' is reserved for experimental versions.
sizeThe actual size of all header data, including following format specific data.
flagsinitial flags which should be set (don't include CLEAN here, should be set on close)
Returns
A lumiera_fileheader object by value, .header and .map are set to NULL on error.

Definition at line 51 of file fileheader.c.

References for(), LUMIERA_ERROR_SET_CRITICAL, lumiera_file_checkflags(), LUMIERA_FILEHEADER_ENDIANMAGIC, lumiera_fileheader_flags_set(), lumiera_mmap_address(), lumiera_mmap_new_exact(), and NULL.

Referenced by TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

lumiera_fileheader lumiera_fileheader_open ( LumieraFile  file,
char *  fourcc,
size_t  size,
const char *  flags_expected,
const char *  flags_remove 
)

Open an existing file header.

The underlying file might be readonly. The opened file header is mmaped into memory and must be closed after use. The File should be locked for operations on the file header.

Parameters
fileThe file on which to open the header.
fourccpointer to a string of length 4 with the expected identifier for the file
sizeThe actual size of all header data, including following format specific data
flags_expectedexpect this flags being set
flags_removeremove this flags when opening
Returns
A lumiera_fileheader object by value, .header and .map are set to NULL on error.

Definition at line 92 of file fileheader.c.

References LUMIERA_ERROR_SET_CRITICAL, LUMIERA_ERROR_SET_WARNING, LUMIERA_FILEHEADER_ENDIANMAGIC, LUMIERA_FILEHEADER_FLAG_ENDIANESS, lumiera_fileheader_flags_clear(), lumiera_fileheader_flags_validate(), lumiera_mmap_address(), lumiera_mmap_delete(), lumiera_mmap_new_exact(), and NULL.

Referenced by TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lumiera_fileheader_close ( LumieraFileheader  self,
const char *  flags_add 
)

Closes a previously created or opened file header.

Parameters
selfthe file header to close.
flags_addset this flags if not already set no errors, no nothing returned (yet)

Definition at line 141 of file fileheader.c.

References lumiera_fileheader_flags_set(), lumiera_mmap_delete(), and NULL.

Referenced by TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int lumiera_fileheader_version ( LumieraFileheader  self)

Queries the version of a file header.

Parameters
selfthe file header to query
Returns
the version stored in the file header or -1 on error.

Definition at line 153 of file fileheader.c.

References LUMIERA_ERROR_SET_WARNING, lumiera_tmpbuf_snprintf(), and NULL.

Referenced by TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int lumiera_fileheader_flags_validate ( LumieraFileheader  self,
const char *  expected,
const char *  unexpected 
)

check if all flags given from some sets are either set or not.

Definition at line 176 of file fileheader.c.

Referenced by lumiera_fileheader_open().

+ Here is the caller graph for this function:

LumieraFileheader lumiera_fileheader_flags_set ( LumieraFileheader  self,
const char *  flags 
)

Sets flags if not already set.

Definition at line 194 of file fileheader.c.

References LUMIERA_ERROR_SET_CRITICAL, and NULL.

Referenced by lumiera_fileheader_close(), and lumiera_fileheader_create().

+ Here is the caller graph for this function:

LumieraFileheader lumiera_fileheader_flags_clear ( LumieraFileheader  self,
const char *  flags 
)

Clear flags if present.

Definition at line 216 of file fileheader.c.

Referenced by lumiera_fileheader_open().

+ Here is the caller graph for this function: