libclosedcaption 1.0.3
ISDB-Tb/SBTVD (Brazilian DTV) closed caption extraction from MPEG-TS
Loading...
Searching...
No Matches
caption-common.h File Reference

Standard headers and helper macros used all over the library. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <errno.h>
Include dependency graph for caption-common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define is_latin_iso8859_15(x)   (((x) >= 0x20 && (x) <= 0x7e) || ((x) >= 0xa1 && (x) <= 0xfe))
 
#define ARRAY_SIZE(x)   ((unsigned)(sizeof(x)/sizeof((x)[0])))
 
#define PRINT_BOOL(x)   (((x) == TRUE)?"TRUE":(((x) == FALSE)?"FALSE":"UNKNOWN"))
 
#define UNUSED(x)   x __attribute__ ((__unused__))
 
#define FALSE   0
 
#define TRUE   1
 
#define IS_PRINTABLE(a)   ((a) >= 33 && (a) <= 126)
 
#define DTV_DEBUG(fmt, ...)    helper_print("DEBUG", __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
 
#define DTV_HEXDUMP(buff, buffLen)    helper_hexdump("DEBUG", __FILE__, __func__, __LINE__, #buff, #buffLen, (const char*)(buff), (buffLen))
 

Functions

void helper_hexdump (const char *platform, const char *fileFull, const char *func, uint32_t fileLine, const char *namebuff, const char *namebufflen, const char *buff, size_t buffLen)
 
void helper_print (const char *platform, const char *fileFull, const char *func, uint32_t line, const char *format,...) __attribute__((format(printf
 

Detailed Description

Standard headers and helper macros used all over the library.

Author
Jorge Pereira jpere.nosp@m.iran.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
Thu Aug 12 13:49:21 BRT 2010

Debugging

Building with -DDEBUG_CLOSEDCAPTION, the macros DTV_DEBUG and DTV_HEXDUMP start printing messages and hex dumps to stdout. Without that flag they generate no code.

Definition in file caption-common.h.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Enables the libc GNU extensions (e.g. POSIX/GNU function declarations).

Definition at line 18 of file caption-common.h.

◆ is_latin_iso8859_15

#define is_latin_iso8859_15 (   x)    (((x) >= 0x20 && (x) <= 0x7e) || ((x) >= 0xa1 && (x) <= 0xfe))

Checks if x is a printable ISO-8859-15 character, that is, if it is in the GL (0x20 to 0x7e) or GR (0xa1 to 0xfe) ranges of the character table.

Definition at line 35 of file caption-common.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   x)    ((unsigned)(sizeof(x)/sizeof((x)[0])))

Number of elements of a static array.

Definition at line 41 of file caption-common.h.

◆ PRINT_BOOL

#define PRINT_BOOL (   x)    (((x) == TRUE)?"TRUE":(((x) == FALSE)?"FALSE":"UNKNOWN"))

Turns a boolean into text, for debug messages.

Definition at line 44 of file caption-common.h.

◆ UNUSED

#define UNUSED (   x)    x __attribute__ ((__unused__))

Marks a parameter as unused, to avoid the compiler warning.

Definition at line 48 of file caption-common.h.

◆ FALSE

#define FALSE   0

False. Kept for compatibility; same as false.

Definition at line 52 of file caption-common.h.

◆ TRUE

#define TRUE   1

True. Kept for compatibility; same as true.

Definition at line 57 of file caption-common.h.

◆ IS_PRINTABLE

#define IS_PRINTABLE (   a)    ((a) >= 33 && (a) <= 126)

Visible ASCII character (no space), used in the hex dump.

Definition at line 63 of file caption-common.h.

◆ DTV_DEBUG

#define DTV_DEBUG (   fmt,
  ... 
)     helper_print("DEBUG", __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)

Prints a debug message, printf() style, with the file, line and function it came from. Only exists with -DDEBUG_CLOSEDCAPTION.

Definition at line 70 of file caption-common.h.

◆ DTV_HEXDUMP

#define DTV_HEXDUMP (   buff,
  buffLen 
)     helper_hexdump("DEBUG", __FILE__, __func__, __LINE__, #buff, #buffLen, (const char*)(buff), (buffLen))

Prints the hex dump of a buffer. Only exists with -DDEBUG_CLOSEDCAPTION.

Definition at line 79 of file caption-common.h.

Function Documentation

◆ helper_hexdump()

void helper_hexdump ( const char *  platform,
const char *  fileFull,
const char *  func,
uint32_t  fileLine,
const char *  namebuff,
const char *  namebufflen,
const char *  buff,
size_t  buffLen 
)

Prints the hex dump of a buffer. Use the DTV_HEXDUMP macro.

Parameters
platformMessage prefix (not used).
fileFullSource file (__FILE__).
funcSource function (__func__).
fileLineSource line (__LINE__).
namebuffName of the buffer variable.
namebufflenName of the size variable.
buffBuffer.
buffLenBuffer size; above 8192 bytes the content is not printed.

◆ helper_print()

void helper_print ( const char *  platform,
const char *  fileFull,
const char *  func,
uint32_t  line,
const char *  format,
  ... 
)

Prints a debug message. Use the DTV_DEBUG macro.

Parameters
platformMessage prefix (not used).
fileFullSource file (__FILE__).
funcSource function (__func__).
lineSource line (__LINE__).
formatFormat, like printf().