| 1 | // SPDX-License-Identifier: GPL-2.0-or-latercxx . . $ `<file>/src/lib/rt-error.c`/ |
| 2 | /* |
| 3 | * Copyright (C) 2009 John Kacur <[email protected]> |
| 4 | * |
| 5 | * error routines, similar to those found in |
| 6 | * Advanced Programming in the UNIX Environment 2nd ed. |
| 7 | */ |
| 8 | #include "rt-error.h"cxx . . $ `<file>/src/include/rt-error.h`/ |
| 9 | |
| 10 | /* Print an error message, plus a message for err and exit with error err */ |
| 11 | void err_exitcxx . . $ err_exit(7cbaebca1c50800).(int err, char *fmt, ...) |
| 12 | { |
| 13 | va_listcxx . . $ va_list# ap; |
| 14 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 15 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(err, fmt, ap); |
| 16 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 17 | exitcxx . . $ exit(3ca292c338df9bb3).(err); |
| 18 | } |
| 19 | |
| 20 | /* print an error message and return */ |
| 21 | void err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).(char *fmt, ...) |
| 22 | { |
| 23 | va_listcxx . . $ va_list# ap; |
| 24 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 25 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(0, fmt, ap); |
| 26 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | /* Print an error message, plus a message for err, and return */ |
| 31 | void err_msg_ncxx . . $ err_msg_n(26800c7917ec8ef2).(int err, char *fmt, ...) |
| 32 | { |
| 33 | va_listcxx . . $ va_list# ap; |
| 34 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 35 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(err, fmt, ap); |
| 36 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | /* print an error message and quit */ |
| 41 | void err_quitcxx . . $ err_quit(5313ecf19fd40d4d).(char *fmt, ...) |
| 42 | { |
| 43 | va_listcxx . . $ va_list# ap; |
| 44 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 45 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(0, fmt, ap); |
| 46 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 47 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 48 | } |
| 49 | |
| 50 | void debugcxx . . $ debug(26800c7917ec8ef2).(int enable, char *fmt, ...) |
| 51 | { |
| 52 | if (enable) { |
| 53 | va_listcxx . . $ va_list# ap; |
| 54 | |
| 55 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 56 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("DEBUG: ", stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 57 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(0, fmt, ap); |
| 58 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | void infocxx . . $ info(26800c7917ec8ef2).(int enable, char *fmt, ...) |
| 63 | { |
| 64 | if (enable) { |
| 65 | va_listcxx . . $ va_list# ap; |
| 66 | |
| 67 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 68 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("INFO: ", stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 69 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(0, fmt, ap); |
| 70 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | void warncxx . . $ warn(d5d9ff45db7b5d36).(char *fmt, ...) |
| 75 | { |
| 76 | va_listcxx . . $ va_list# ap; |
| 77 | |
| 78 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 79 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("WARN: ", stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 80 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(0, fmt, ap); |
| 81 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 82 | } |
| 83 | |
| 84 | void fatalcxx . . $ fatal(5313ecf19fd40d4d).(char *fmt, ...) |
| 85 | { |
| 86 | va_listcxx . . $ va_list# ap; |
| 87 | |
| 88 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, fmt); |
| 89 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("FATAL: ", stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 90 | err_doitcxx . . $ err_doit(7aa579bceef62d01).(0, fmt, ap); |
| 91 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 92 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 93 | } |
| 94 | |
| 95 | void err_doitcxx . . $ err_doit(7aa579bceef62d01).(int err, const char *fmt, va_listcxx . . $ va_list# ap) |
| 96 | { |
| 97 | vfprintfcxx . . $ vfprintf(bded311e54d67f9c).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, fmt, ap); |
| 98 | if (err) |
| 99 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, ": %s\n", strerrorcxx . . $ strerror(ff224f080444ee45).(err)); |
| 100 | return; |
| 101 | } |