Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fileheader.h
Go to the documentation of this file.
1 /*
2  FILEHEADER.h - Definitions of generic lumiera file headers and identification
3 
4  Copyright (C) Lumiera.org
5  2010, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
35 #ifndef BACKEND_FILEHEADER_H
36 #define BACKEND_FILEHEADER_H
37 
38 #include "lib/error.h"
39 
40 
41 
42 LUMIERA_ERROR_DECLARE (FILEHEADER_NOWRITE);
43 LUMIERA_ERROR_DECLARE (FILEHEADER_HEADER);
44 LUMIERA_ERROR_DECLARE (FILEHEADER_FLAGS);
45 LUMIERA_ERROR_DECLARE (FILEHEADER_FLAGSPACE);
46 LUMIERA_ERROR_DECLARE (FILEHEADER_ENDIANESS);
47 
48 #define LUMIERA_FILEHEADER_ENDIANMAGIC 0x0123456789ABCDEFULL
49 
50 typedef struct lumiera_fileheader_struct lumiera_fileheader;
51 typedef lumiera_fileheader* LumieraFileheader;
52 
53 typedef struct lumiera_fileheader_raw_struct lumiera_fileheader_raw;
54 typedef lumiera_fileheader_raw* LumieraFileheaderRaw;
55 
56 
57 #include "backend/file.h"
58 
59 
60 #include <nobug.h>
61 #include <semaphore.h>
62 
63 
64 
65 
66 #ifndef LUMIERA_PACKED
67 #define LUMIERA_PACKED __attribute__((__packed__))
68 #endif
69 
76 {
78  char fourcc[4];
80  char version[3];
82  char newline1;
84  char meta[15];
86  char newline2;
87 
89  char flags[6];
91  char newline3;
93  char null;
94 
95  /* natively written 0x0123456789ABCDEFULL by the host created this */
96  uint64_t endianess_mark;
97 };
98 
105 #define LUMIERA_FILEHEADER_FLAG_CLEAN "c"
106 
108 #define LUMIERA_FILEHEADER_FLAG_ENDIANESS "e"
109 
110 
111 
112 
113 
119 {
122 };
123 
124 
137 lumiera_fileheader
138 lumiera_fileheader_create (LumieraFile file, char* fourcc, int version, size_t size, const char* flags);
139 
140 
152 lumiera_fileheader
153 lumiera_fileheader_open (LumieraFile file, char* fourcc, size_t size, const char* flags_expected, const char* flags_remove);
154 
155 
162 void
163 lumiera_fileheader_close (LumieraFileheader self, const char* flags_add);
164 
165 
171 int
173 
174 
178 int
179 lumiera_fileheader_flags_validate (LumieraFileheader self, const char* expected, const char* unexpected);
180 
181 
186 lumiera_fileheader_flags_set (LumieraFileheader self, const char* flags);
187 
192 lumiera_fileheader_flags_clear (LumieraFileheader self, const char* flags);
193 
194 
195 #endif /*BACKEND_FILEHEADER_H*/
196 /*
197 // Local Variables:
198 // mode: C
199 // c-file-style: "gnu"
200 // indent-tabs-mode: nil
201 // End:
202 */
lumiera_file * LumieraFile
Definition: file.h:49
lumiera_mmap * LumieraMMap
Definition: mmap.h:36
#define LUMIERA_PACKED
Definition: fileheader.h:67
char newline3
always ' '
Definition: fileheader.h:91
A basic file header On-Disk representation starts with 32 bytes identifying the file.
Definition: fileheader.h:75
File management.
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: fileheader.c:176
char newline1
always ' '
Definition: fileheader.h:82
Lumiera error handling (C interface).
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.
Definition: fileheader.c:51
LUMIERA_ERROR_DECLARE(FILEHEADER_NOWRITE)
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.
Definition: fileheader.c:92
lumiera_fileheader_raw * LumieraFileheaderRaw
Definition: fileheader.h:54
A file header object encapsulates the underlying mmap object which keeps the raw header data in memor...
Definition: fileheader.h:118
int lumiera_fileheader_version(LumieraFileheader self)
Queries the version of a file header.
Definition: fileheader.c:153
LumieraFileheaderRaw header
Definition: fileheader.h:120
lumiera_fileheader * LumieraFileheader
Definition: fileheader.h:51
LumieraFileheader lumiera_fileheader_flags_set(LumieraFileheader self, const char *flags)
Sets flags if not already set.
Definition: fileheader.c:194
LumieraFileheader lumiera_fileheader_flags_clear(LumieraFileheader self, const char *flags)
Clear flags if present.
Definition: fileheader.c:216
void lumiera_fileheader_close(LumieraFileheader self, const char *flags_add)
Closes a previously created or opened file header.
Definition: fileheader.c:141
char newline2
always ' '
Definition: fileheader.h:86