Root/
| 1 | /* |
| 2 | * misc/diag.h - Diagnostics |
| 3 | * |
| 4 | * Written 2016 by Werner Almesberger |
| 5 | * Copyright 2016 by Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #ifndef MISC_DIAG_H |
| 14 | #define MISC_DIAG_H |
| 15 | |
| 16 | /* |
| 17 | * 0: no progress indications |
| 18 | * 1: reasonable progress indications |
| 19 | * 2: verbose output |
| 20 | * > 2: go wild ! |
| 21 | */ |
| 22 | |
| 23 | extern unsigned verbose; |
| 24 | |
| 25 | |
| 26 | /* ----- Specialized diagnostic functions ---------------------------------- */ |
| 27 | |
| 28 | |
| 29 | /* perror, based on "fatal" or "error" */ |
| 30 | |
| 31 | void __attribute__((noreturn)) diag_pfatal(const char *s); |
| 32 | void diag_perror(const char *s); |
| 33 | |
| 34 | |
| 35 | /* ----- General diagnostic functions -------------------------------------- */ |
| 36 | |
| 37 | |
| 38 | /* |
| 39 | * Terminate immediately. Further execution makes no sense. |
| 40 | * E.g., out of memory. |
| 41 | */ |
| 42 | |
| 43 | void __attribute__((noreturn)) fatal(const char *fmt, ...) |
| 44 | __attribute__((format(printf, 1, 2))); |
| 45 | |
| 46 | /* |
| 47 | * Operation has failed, but the program as a whole may still be able to |
| 48 | * continue. E.g., a schematics component was not found. |
| 49 | */ |
| 50 | |
| 51 | void error(const char *fmt, ...) |
| 52 | __attribute__((format(printf, 1, 2))); |
| 53 | |
| 54 | /* |
| 55 | * A minor operation has failed or some other issue was detected. This may |
| 56 | * be (or lead to) a more serious problem, but does not immediately affect |
| 57 | * operation. |
| 58 | */ |
| 59 | |
| 60 | void warning(const char *fmt, ...) |
| 61 | __attribute__((format(printf, 1, 2))); |
| 62 | |
| 63 | /* |
| 64 | * Progress message, used mainly for debugging. "level" is the minimum |
| 65 | * verbosity level required. |
| 66 | */ |
| 67 | |
| 68 | void progress(unsigned level, const char *fmt, ...) |
| 69 | __attribute__((format(printf, 2, 3))); |
| 70 | |
| 71 | #endif /* !MISC_DIAG_H */ |
| 72 |
Branches:
master
