nemea-common 1.6.3
Macros
progress_printer.h File Reference

Macros for printing a given character (dot by default) every N records – header file. More...

Go to the source code of this file.

Macros

#define NMCM_CNT_VALUE   1
 
#define NMCM_PROGRESS_DECL
 Declares progress structure prototype. Prototype contains counter, limit and printed character.
 
#define NMCM_PROGRESS_DEF
 Declares structure trap_progress, pointer to this structure. Uses pointer for better accessibility from functions other than main. Initializes its limit value to 0.
 
#define NMCM_PROGRESS_INIT(a, err_cmd)
 Initializes progress variables. Initializes limit value. If not inserted, prints error message and carries out optional error command (e.g. returns nonzero value). Initializes counter and progress character to default value.
 
#define NMCM_PROGRESS_PRINT
 Print a character ('.' by default) on every N-th invocation.
 
#define NMCM_PROGRESS_NEWLINE
 Print newline if progress printing is enabled. Typically used before something else should be printed out or before module termination.
 

Detailed Description

Macros for printing a given character (dot by default) every N records – header file.

Author
Katerina Pilatova xpila.nosp@m.t05@.nosp@m.stud..nosp@m.fit..nosp@m.vutbr.nosp@m..cz
Date
2014

Definition in file progress_printer.h.

Macro Definition Documentation

◆ NMCM_CNT_VALUE

#define NMCM_CNT_VALUE   1

Initial value of record counter.

Definition at line 15 of file progress_printer.h.

◆ NMCM_PROGRESS_DECL

#define NMCM_PROGRESS_DECL
Value:
struct nmcm_progress_t { \
int cnt, limit; \
char print_char; \
}; \

Declares progress structure prototype. Prototype contains counter, limit and printed character.

Definition at line 22 of file progress_printer.h.

◆ NMCM_PROGRESS_DEF

#define NMCM_PROGRESS_DEF
Value:
struct nmcm_progress_t nmcm_progress; \
struct nmcm_progress_t *nmcm_progress_ptr = &nmcm_progress;\
nmcm_progress_ptr->print_char = 0; \
nmcm_progress_ptr->limit = 0;

Declares structure trap_progress, pointer to this structure. Uses pointer for better accessibility from functions other than main. Initializes its limit value to 0.

Definition at line 33 of file progress_printer.h.

◆ NMCM_PROGRESS_INIT

#define NMCM_PROGRESS_INIT ( a,
err_cmd )
Value:
do { \
if (a <= 0) { \
fprintf(stderr,"Error: 'progress' argument has to be greater than zero.\n"); \
err_cmd; \
} else { \
nmcm_progress_ptr->cnt = NMCM_CNT_VALUE; \
nmcm_progress_ptr->limit = (a); \
nmcm_progress_ptr->print_char = '.'; \
} \
} while (0);
#define NMCM_CNT_VALUE

Initializes progress variables. Initializes limit value. If not inserted, prints error message and carries out optional error command (e.g. returns nonzero value). Initializes counter and progress character to default value.

Parameters
[in]aParsed progress limit.
[in]err_cmdWhich error command is to be executed.

Definition at line 47 of file progress_printer.h.

◆ NMCM_PROGRESS_NEWLINE

#define NMCM_PROGRESS_NEWLINE
Value:
do { \
if (nmcm_progress_ptr->limit > 0) { \
putchar('\n'); \
} \
} while (0);

Print newline if progress printing is enabled. Typically used before something else should be printed out or before module termination.

Definition at line 78 of file progress_printer.h.

◆ NMCM_PROGRESS_PRINT

#define NMCM_PROGRESS_PRINT
Value:
do { \
if (nmcm_progress_ptr->cnt == nmcm_progress.limit) { \
putchar(nmcm_progress_ptr->print_char); \
fflush(stdout); \
nmcm_progress_ptr->cnt = NMCM_CNT_VALUE; \
} else { \
nmcm_progress_ptr->cnt++; \
} \
} while (0);

Print a character ('.' by default) on every N-th invocation.

Definition at line 62 of file progress_printer.h.