Nilorea Library

- Main Page
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Macros Groups
Data Structures | Macros | Typedefs | Functions | Variables
COMMONS: generally used headers, defines, timers, allocators,...

## Data Structures

struct | N_TIME

## Macros

#define | __EXTENSIONS__
#define | ALLEGRO_ALREADY_INLUDED
#define | true (1==1)
#define | TRUE true
#define | false (1==0)
#define | FALSE false
#define | EMPTY 2
#define | _str(__PTR) ((__PTR)?(__PTR):"NULL")
#define | _strw(__PTR) ((__PTR)?(__PTR):"NULL")
#define | _nstr(__PTR) ((__PTR&&__PTR->data)?(__PTR->data):"NULL")
#define | Malloc(__ptr, __struct, __size)
#define | Free(__ptr)
#define | FreeNoLog(__ptr)
#define | Realloc(__ptr, __struct, __size)
#define | Reallocz(__ptr, __struct, __old_size, __size)
#define | _assert(__ptr, __ret)
#define | SET 1234
#define | GET 4321
#define | DEFAULT 1000
#define | RUNNING 1001
#define | STOPWANTED 1002
#define | STOPPED 1003
#define | PAUSED 1004
#define | randomize() { srand((unsigned)time(NULL)); rand(); }
#define | MIN(a, b) (((a)<(b))?(a):(b))
#define | MAX(a, b) (((a)>(b))?(a):(b))

## Typedefs

typedef unsigned int | uint
typedef unsigned long | ulong
typedef unsigned short | ushort
typedef unsigned char | uchar
typedef struct N_TIME | N_TIME

## Functions

void | PAUSE ()
| make a pause in a terminal More...
int | start_HiTimer (N_TIME *timer)
| Initialize or restart from zero any N_TIME HiTimer. More...
time_t | get_usec (N_TIME *timer)
| Poll any N_TIME HiTimer, returning usec, and moving currentTime to startTime. More...
time_t | get_msec (N_TIME *timer)
| Poll any N_TIME HiTimer, returning msec, and moving currentTime to startTime. More...
time_t | get_sec (N_TIME *timer)
| Poll any N_TIME HiTimer, returning sec, and moving currentTime to startTime. More...
void | get_keyboard (char *keybuf, int *cur, int min, int max)
| Function for getting a keyboard input, unicode. More...

## Variables

FONT * | allegro_font

## Detailed Description

## Macro Definition Documentation

#define __EXTENSIONS__

feature test macro

Definition at line 22 of file n_common.h.

#define _assert | ( |  | __ptr,
|  |  | __ret
| ) |  |

Value:
if( !(__ptr) ) \
{ \
n_log( LOG_DEBUG , "%s is NULL at line %d of %s" , #__ptr , __LINE__ , __FILE__ );\
__ret ; \
}

macro to assert things

Definition at line 158 of file n_common.h.

#define _nstr | ( |  | __PTR | ) | ((__PTR&&__PTR->data)?(__PTR->data):"NULL")

N_STR or "NULL" string for logging purposes

Definition at line 109 of file n_common.h.

#define _str | ( |  | __PTR | ) | ((__PTR)?(__PTR):"NULL")

String or "NULL" string for logging purposes

Definition at line 105 of file n_common.h.

#define _strw | ( |  | __PTR | ) | ((__PTR)?(__PTR):"NULL")

String or " " string for config purposes

Definition at line 107 of file n_common.h.

#define ALLEGRO_ALREADY_INLUDED

guard for mutliple allegro inclusion. Not that allegro's header would fail, but there would be multiple FONT declaration.

Definition at line 67 of file n_common.h.

#define DEFAULT 1000

Default APP_STATUS Value

Definition at line 186 of file n_common.h.

#define EMPTY 2

returned by N_STRLIST functions to tell the caller that the list is empty

Definition at line 101 of file n_common.h.

#define false (1==0)

define false

Definition at line 91 of file n_common.h.

#define FALSE false

define FALSE

Definition at line 96 of file n_common.h.

#define Free | ( |  | __ptr | ) |

Value:
if ( __ptr )\
{\
free( __ptr );\
__ptr = NULL;\
}\
else\
{\
n_log( LOG_DEBUG , "Free( %s ) already done or NULL at line %d of %s \n", #__ptr , __LINE__ , __FILE__ );\
}

Free Handler to get errors

Definition at line 118 of file n_common.h.

#define FreeNoLog | ( |  | __ptr | ) |

Value:
if ( __ptr )\
{\
free( __ptr );\
__ptr = NULL;\
}

Free Handler without log

Definition at line 129 of file n_common.h.

#define GET 4321

Flag for GET something , passing as a function parameter

Definition at line 184 of file n_common.h.

#define Malloc | ( |  | __ptr,
|  |  | __struct,
|  |  | __size
| ) |  |

Value:
if ( !( __ptr = ( __struct *)calloc( __size , sizeof( __struct ) ) ) ) \
{ \
n_log( LOG_ERR , "( %s *)malloc( %s * sizeof( %d ) ) Error at line %d of %s \n", #__ptr , #__struct , __size , __LINE__ , __FILE__); \
}

Malloc Handler to get errors

Definition at line 112 of file n_common.h.

#define MAX | ( |  | a,
|  |  | b
| ) |  | (((a)>(b))?(a):(b))

define MIN macro

Definition at line 205 of file n_common.h.

#define MIN | ( |  | a,
|  |  | b
| ) |  | (((a)<(b))?(a):(b))

define MIN macro

Definition at line 201 of file n_common.h.

#define PAUSED 1004

Value of the state of an application who is paused

Definition at line 194 of file n_common.h.

#define randomize | ( |  | ) | { srand((unsigned)time(NULL)); rand(); }

Initialize the random sequence with time

Definition at line 197 of file n_common.h.

#define Realloc | ( |  | __ptr,
|  |  | __struct,
|  |  | __size
| ) |  |

Value:
if( !( __ptr = ( __struct *)realloc( __ptr , __size * sizeof( __struct ) ) ) )\
{ \
n_log( LOG_ERR , "( %s *)malloc( %s * sizeof( %d ) ) Error at line %d of %s \n", #__ptr , #__struct , __size , __LINE__ , __FILE__);\
__ptr = NULL;\
}

Realloc Handler to get errors

Definition at line 138 of file n_common.h.

#define Reallocz | ( |  | __ptr,
|  |  | __struct,
|  |  | __old_size,
|  |  | __size
| ) |  |

Value:
if ( !( __ptr = ( __struct *)realloc( __ptr , __size * sizeof( __struct ) ) ) )\
{\
n_log( LOG_ERR , "( %s *)malloc( %s * sizeof( %d ) ) Error at line %d of %s \n", #__ptr , #__struct , __size , __LINE__ , __FILE__);\
__ptr = NULL;\
}\
else\
{\
if( __size > __old_size )memset( ( __ptr + __old_size ) , 0 , __size - __old_size );\
}

Realloc + zero new memory zone Handler to get errors

Definition at line 146 of file n_common.h.

#define RUNNING 1001

Value of the state of an application who is running

Definition at line 188 of file n_common.h.

#define SET 1234

Flag for SET something , passing as a function parameter

Definition at line 182 of file n_common.h.

#define STOPPED 1003

Value of the state of an application who is stopped

Definition at line 192 of file n_common.h.

#define STOPWANTED 1002

Value of the state of an application who want to stop his activity

Definition at line 190 of file n_common.h.

#define true (1==1)

define true

Definition at line 81 of file n_common.h.

#define TRUE true

define TRUE

Definition at line 86 of file n_common.h.

## Typedef Documentation

typedef struct N_TIME N_TIME

Timing Structure

typedef unsigned char uchar

shortcut for unsigned char

Definition at line 177 of file n_common.h.

typedef unsigned int uint

shortcut for unsigned int

Definition at line 171 of file n_common.h.

typedef unsigned long ulong

shortcut for unsigned long

Definition at line 173 of file n_common.h.

typedef unsigned short ushort

shortcut for unsigned short

Definition at line 175 of file n_common.h.

## Function Documentation

void get_keyboard | ( | char * | keybuf,
|  | int * | cur,
|  | int | min,
|  | int | max
| ) |  |

Function for getting a keyboard input, unicode.

Parameters

  keybuf | a valid char buffer
  cur | a pointer to the current_cursor_position
  min | the minimum carret position in byte
  max | the maximim carret position in byte

Definition at line 128 of file n_common.c.

Here is the caller graph for this function:

time_t get_msec | ( | N_TIME * | timer | ) |

Poll any N_TIME HiTimer, returning msec, and moving currentTime to startTime.

Parameters

  timer | Any N_TIMER *timer you wanna poll

Returns
  The elapsed number of msec for the given N_TIME *timer

Definition at line 81 of file n_common.c.

Here is the caller graph for this function:

time_t get_sec | ( | N_TIME * | timer | ) |

Poll any N_TIME HiTimer, returning sec, and moving currentTime to startTime.

Parameters

  timer | Any N_TIMER *timer you wanna poll

Returns
  The elapsed number of sec for the given N_TIME *timer

Definition at line 104 of file n_common.c.

time_t get_usec | ( | N_TIME * | timer | ) |

Poll any N_TIME HiTimer, returning usec, and moving currentTime to startTime.

Parameters

  timer | Any N_TIMER *timer you wanna poll

Returns
  The elapsed number of usec for the given N_TIME *timer

Definition at line 58 of file n_common.c.

Here is the caller graph for this function:

void PAUSE | ( |  | ) |

make a pause in a terminal

Definition at line 13 of file n_common.c.

int start_HiTimer | ( | N_TIME * | timer | ) |

Initialize or restart from zero any N_TIME HiTimer.

Parameters

  timer | Any N_TIMER *timer you wanna start or reset

Returns
  TRUE or FALSE

Definition at line 33 of file n_common.c.

Here is the caller graph for this function:

## Variable Documentation

FONT* allegro_font

default font for our usage

Definition at line 71 of file n_common.h.