#include "cbf.h"#include "cbf_file.h"#include "cbf_context.h"#include "cbf_binary.h"#include "cbf_codes.h"#include <ctype.h>
Go to the source code of this file.
Functions | |
| int | cbf_parse_binaryheader (cbf_file *file, size_t *size, long *id, unsigned int *compression, int mime) |
| int cbf_parse_binaryheader | ( | cbf_file * | file, |
| size_t * | size, | ||
| long * | id, | ||
| unsigned int * | compression, | ||
| int | mime | ||
| ) |
Definition at line 135 of file cbf_read_binary.c.
References cbf_failnez, CBF_FORMAT, cbf_get_character(), cbf_get_integer(), and cbf_reset_bits().
Referenced by cbf_lex().
{
unsigned int file_size, file_compression;
int file_id, c;
/* Skip ASCII characters */
do
c = cbf_get_character (file);
while (isspace (c) || isgraph (c));
/* Skip the separators:
Byte
-1? Ctrl-L 12 (FF)
0 Ctrl-Z 26 (SUB)
1 Ctrl-D 4 (EOT)
2 213
3-6 id
7-14 size */
while (c == 12 || c == 26 || c == 4)
c = cbf_get_character (file);
/* OK? */
if (c != 213)
return CBF_FORMAT;
/* Discard any bits in the buffer */
cbf_failnez (cbf_reset_bits (file))
/* If there was a mime header, there is no id, size or compression */
if (mime) return 0;
/* id */
cbf_failnez (cbf_get_integer (file, &file_id, 1, 64))
if (id)
*id = file_id;
/* Size */
cbf_failnez (cbf_get_integer (file, (int *) &file_size, 0, 64))
if (size)
*size = file_size;
/* Compression Type */
cbf_failnez (cbf_get_integer (file, (int *) &file_compression, 0, 64))
if (compression)
*compression = file_compression;
/* Success */
return 0;
}
1.7.3