Fonctions compatibles.
Plus de détails...
|
#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__) |
|
Fonctions compatibles.
◆ 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
-
message | Format 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
-
f | Pointeur sur un descripteur FILE |
◆ gotoligcol
#define gotoligcol |
( |
|
x, |
|
|
|
y |
|
) |
| 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
-
x | Correspond à l'index de ligne |
y | Correspond à 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
-
time | Temps 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
-
str1 | Une chaîne de caractères |
str2 | Une 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
-
cmd | Chaî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.
◆ 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
|
◆ portability_background_color_set()
void portability_background_color_set |
( |
Color |
color | ) |
|
Change la couleur de l'arrière plan
- Paramètres
-
- 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
-
- Exemples
- test.c.