| 1 | /* |
| 2 | * Copyright (c) - 2011 David Goulet <david.goulet@polymtl.ca> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by as |
| 6 | * published by the Free Software Foundation; only version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along with |
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 51 |
| 15 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 | */ |
| 17 | |
| 18 | #include <stdio.h> |
| 19 | #include <unistd.h> |
| 20 | |
| 21 | #define BRIGHT 1 |
| 22 | #define GREEN 32 |
| 23 | #define RED 31 |
| 24 | |
| 25 | #define PRINT_OK() \ |
| 26 | do { \ |
| 27 | /* Check for color support */ \ |
| 28 | if (isatty(STDOUT_FILENO)) { \ |
| 29 | printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0); \ |
| 30 | } else { \ |
| 31 | printf("OK\n"); \ |
| 32 | } \ |
| 33 | } while (0) |
| 34 | |
| 35 | #define PRINT_FAIL() \ |
| 36 | do { \ |
| 37 | /* Check for color support */ \ |
| 38 | if (isatty(STDOUT_FILENO)) { \ |
| 39 | printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0); \ |
| 40 | } else { \ |
| 41 | printf("FAIL\n"); \ |
| 42 | } \ |
| 43 | } while (0) |