Portability
Chargement...
Recherche...
Aucune correspondance
Macros | Énumérations | Fonctions
Portability

Fonctions compatibles. Plus de détails...

Macros

#define gotoligcol(x, y)   portability_gotoligcol(x, y)
 
#define kbhit()   portability_kbhit()
 
#define Sleep(time)   portability_sleep(time)
 
#define system(arg)   portability_system_call(arg)
 
#define fflush(arg)   portability_clear_buffer(arg)
 
#define strcasecmp(str1, str2)   _stricmp(str1, str2)
 
#define ERROR(message, ...)    fprintf(stderr, "*** [%s:%i] "msg"\n", __func__, __LINE__, ## __VA_ARGS__)
 

Énumérations

enum  Color {
  COLOR_DEFAULT = 0 , COLOR_BLACK = 30 , COLOR_RED = 31 , COLOR_GREEN = 32 ,
  COLOR_YELLOW = 33 , COLOR_BLUE = 34 , COLOR_MAGENTA = 35 , COLOR_CYAN = 36 ,
  COLOR_GRAY = 37
}
 

Fonctions

void portability_background_color_set (Color color)
 
void portability_text_color_set (Color color)
 
void portability_init (void)
 
void portability_shutdown (void)
 

Description détaillée

Fonctions compatibles.

Documentation des macros

◆ ERROR

#define ERROR (   message,
  ... 
)     fprintf(stderr, "*** [%s:%i] "msg"\n", __func__, __LINE__, ## __VA_ARGS__)

Affiche une message d'erreur dans la console qui indique le nom de la fonction ainsi que la ligne à laquelle ce message a été appelé.

void
my_gorgeous_function(void)
{
   int i = 4;
   ERROR("Here, the value of i is %i. This is not normal!", i);
   // Displays:
   // *** [my_gorgeous_function:5] Here, the value of i is 4. This is not normal!
}
Paramètres
messageFormat du message (comme printf)
...Arguments du message (comme printf)

◆ fflush

#define fflush (   arg)    portability_clear_buffer(arg)

Efface le buffer d'entrée

// Nettoyer l'entrée clavier:
fflush(stdin);
Paramètres
fPointeur sur un descripteur FILE

◆ gotoligcol

#define gotoligcol (   x,
 
)    portability_gotoligcol(x, y)

Déplace le curseur dans la console À noter que le repère est de la forme: ————-> |(0,0) X (poscol) | | | v Y (poslig)

IMPORTANT: On fait donc un appel avec des coordonnées (Y, X) et non (X, Y)

// Put the cursor at line 0, column 0:
gotoligcol(0, 0);
Paramètres
xCorrespond à l'index de ligne
yCorrespond à l'index de colonne

◆ kbhit

#define kbhit ( )    portability_kbhit()

Détecte qu'une touche a été tapée dans le terminal

// Waits for a key input
kbhit();
Renvoie
0 si aucune touche frappée, > 0 sinon

◆ Sleep

#define Sleep (   time)    portability_sleep(time)

Pause le programme pendant un temps donné

// Waits for two seconds (2000 milliseconds)
Sleep(2000);
Paramètres
timeTemps en millisecondes

◆ strcasecmp

#define strcasecmp (   str1,
  str2 
)    _stricmp(str1, str2)

Compare deux chaînes de caractère sans tenir compte de la casse

strcasecmp("A string", "a StRinG"); // Identical strings
strcasecmp("A string", "Q string"); // Different strings
strcasecmp("A string", "A string"); // Identical strings
Paramètres
str1Une chaîne de caractères
str2Une autre chaîne de caractères
Renvoie
0 if the strings are identical

◆ system

#define system (   arg)    portability_system_call(arg)

Remplace les appels systèmes Windows courants par leurs correspondances

Example:

// Clear the console
system("cls");

// Pause the console
system("pause");
Paramètres
cmdChaîne de caractère correspondant à la commande système
Renvoie
0 si la commande a bien été exécutée, -1 si cmd est NULL, > 0 si une erreur interne est survenue.

Documentation du type de l'énumération

◆ Color

enum Color

Colors that are available in the terminal. They can be used to change the background and the text colors.

Valeurs énumérées
COLOR_DEFAULT 

Couleur par défaut

COLOR_BLACK 

Couleur noire

COLOR_RED 

Couleur rouge

COLOR_GREEN 

Couleur verte

COLOR_YELLOW 

Couleur jaune

COLOR_BLUE 

Couleur bleue

COLOR_MAGENTA 

Couleur magenta

COLOR_CYAN 

Couleur cyan

COLOR_GRAY 

Couleur grise

Documentation des fonctions

◆ portability_background_color_set()

void portability_background_color_set ( Color  color)

Change la couleur de l'arrière plan

Paramètres
colorCouleur à appliquer
Exemples
test.c.

◆ portability_init()

void portability_init ( void  )

Initialize the portability library

  • Disables the line bufferrng of defaults fds
Exemples
base.c, et test.c.

◆ portability_shutdown()

void portability_shutdown ( void  )

Shuts down the portability resources.

Exemples
base.c, et test.c.

◆ portability_text_color_set()

void portability_text_color_set ( Color  color)

Change la couleur du texte

Paramètres
colorCouleur à appliquer
Exemples
test.c.