15#include "nilorea/n_stack.h"
19 fprintf( stderr,
" -v version\n"
20 " -V log level: LOG_INFO, LOG_NOTICE, LOG_ERR, LOG_DEBUG\n"
24void process_args(
int argc,
char **argv )
34 while( ( getoptret = getopt( argc, argv,
"hvV:" ) ) != EOF)
39 fprintf( stderr,
"Date de compilation : %s a %s.\n", __DATE__, __TIME__ );
42 if( !strncmp(
"LOG_NULL", optarg, 5 ) )
48 if( !strncmp(
"LOG_NOTICE", optarg, 6 ) )
54 if( !strncmp(
"LOG_INFO", optarg, 7 ) )
60 if( !strncmp(
"LOG_ERR", optarg, 5 ) )
66 if( !strncmp(
"LOG_DEBUG", optarg, 5 ) )
72 fprintf( stderr,
"%s n'est pas un niveau de log valide.\n", optarg );
85 fprintf( stderr,
"\n Missing log level\n" );
87 else if( optopt ==
'p' )
89 fprintf( stderr,
"\n Missing port\n" );
91 else if( optopt !=
's' )
93 fprintf( stderr,
"\n Unknow missing option %c\n", optopt );
110int main(
int argc,
char **argv)
115 process_args( argc, argv );
118 n_log(
LOG_INFO ,
"created stack of 16 elements at %p" , stack );
120 for(
int it = 0 ; it < 20 ; it ++ )
122 int32_t nb = rand()%10 ;
123 bool btest = rand()%1 ;
129 for(
int it = 0 ; it < 20 ; it ++ )
136 switch( item -> v_type )
158 n_log(
LOG_ERR ,
"error popping value ! status: %d" , status );
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
#define LOG_NULL
no log output
#define LOG_INFO
informational
bool stack_pop_b(STACK *stack, uint8_t *status)
helper to pop a bool
STACK_ITEM * stack_peek(STACK *stack, size_t position)
peek in the stack with un stacking the stack item
#define STACK_ITEM_INT32
v_type value for a int32_t
#define STACK_ITEM_OK
code for a successfully retrieved item
#define STACK_ITEM_BOOL
v_type value for a bool
#define STACK_IS_UNDEFINED
code for a NULL stack state
int32_t stack_pop_i32(STACK *stack, uint8_t *status)
helper to pop a int32_t
#define stack_push(__STACK, __VAL)
stack push helper with automatic value selection
bool delete_stack(STACK **stack)
delete a STACK *stack
STACK * new_stack(size_t size)
allocate a new STACK
structure of a STACK item
Common headers and low-level hugly functions & define.
N_STR and string function declaration.