![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
#include "nilorea/n_common.h"#include "nilorea/n_files.h"#include "nilorea/n_log.h"#include "nilorea/n_tiff.h"#include <math.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <unistd.h>Go to the source code of this file.
Functions | |
| static size_t | build (unsigned char *buf, int be) |
| Build a DCP shaped buffer: a name, a short, three signed rationals, two floats, and one entry pointing past the end. | |
| static void | check (const char *what, int ok) |
| Count and print a failed condition. | |
| static int | list_file (const char *path) |
| List the tags of a file's first directory. | |
| int | main (int argc, char **argv) |
| Run the checks, or list a file given as the argument. | |
| static void | put16 (unsigned char *p, uint16_t v, int be) |
| Write a 16 bit value in a byte order. | |
| static void | put32 (unsigned char *p, uint32_t v, int be) |
| Write a 32 bit value in a byte order. | |
| static void | put_entry (unsigned char *e, uint16_t tag, uint16_t type, uint32_t count, uint32_t value, int be) |
| Write one directory entry. | |
| static void | test_broken (void) |
| Broken buffers are refused, never read out of bounds. | |
| static void | test_order (int be) |
| Parse a built buffer and check every value. | |
Variables | |
| static int | failures = 0 |
| failures counted by check() | |
|
static |
Build a DCP shaped buffer: a name, a short, three signed rationals, two floats, and one entry pointing past the end.
| buf | receives it, 256 bytes |
| be | non-zero for big endian |
Definition at line 93 of file ex_tiff.c.
References N_TIFF_MAGIC_DCP, put16(), put32(), and put_entry().
Referenced by test_broken(), and test_order().
|
static |
|
static |
List the tags of a file's first directory.
| path | the file |
Definition at line 176 of file ex_tiff.c.
References N_TIFF::big_endian, N_TIFF::count, N_TIFF_ENTRY::count, N_TIFF::entries, N_TIFF::magic, n_file_read_bounded(), n_tiff_free(), n_tiff_parse(), N_TIFF_ENTRY::tag, and N_TIFF_ENTRY::type.
Referenced by main().
| int main | ( | int | argc, |
| char ** | argv ) |
Run the checks, or list a file given as the argument.
-V LEVEL sets the log level, as for every example: run_tests.sh passes it, and before this it was taken for the name of a file to list.
| argc | argument count |
| argv | arguments |
Definition at line 210 of file ex_tiff.c.
References failures, list_file(), LOG_ERR, log_level, set_log_level(), test_broken(), and test_order().
|
static |
Write a 16 bit value in a byte order.
| p | where |
| v | the value |
| be | non-zero for big endian |
Definition at line 58 of file ex_tiff.c.
Referenced by build(), put32(), put_entry(), test_broken(), and write_zip().
|
static |
Write a 32 bit value in a byte order.
| p | where |
| v | the value |
| be | non-zero for big endian |
Definition at line 67 of file ex_tiff.c.
Referenced by build(), put_entry(), test_broken(), and write_zip().
|
static |
Write one directory entry.
| e | where |
| tag | tag |
| type | field type |
| count | value count |
| value | the value itself, or the offset of the values |
| be | non-zero for big endian |
Definition at line 81 of file ex_tiff.c.
References put16(), put32(), and type().
Referenced by build().
|
static |
|
static |
Parse a built buffer and check every value.
| be | non-zero for big endian |
Definition at line 127 of file ex_tiff.c.
References N_TIFF::big_endian, build(), check(), N_TIFF::count, N_TIFF::magic, n_tiff_count(), n_tiff_find(), n_tiff_free(), n_tiff_get_ascii(), n_tiff_get_doubles(), N_TIFF_MAGIC_DCP, and n_tiff_parse().
Referenced by main().