X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/dd3c57bc8cac59e0d657ee665ce462988d27d714..18c831dcd0ae4d660c70ccac69d27ed2a97851be:/ui/report.c diff --git a/ui/report.c b/ui/report.c new file mode 100644 index 0000000..84a0f8d --- /dev/null +++ b/ui/report.c @@ -0,0 +1,83 @@ +/* -*-c-*- + * + * Reporting errors and things + * + * (c) 1998 Straylight/Edgeware + */ + +/*----- Licensing notice --------------------------------------------------* + * + * This file is part of the mLib utilities library. + * + * mLib is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * mLib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with mLib; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +/*----- Header files ------------------------------------------------------*/ + +#include +#include +#include +#include + +#include "quis.h" +#include "report.h" + +/*----- Functions provided ------------------------------------------------*/ + +/* --- @moan@ --- * + * + * Arguments: @const char *f@ = a @printf@-style format string + * @...@ = other arguments + * + * Returns: --- + * + * Use: Reports an error. + */ + +void moan(const char *f, ...) +{ + va_list ap; + va_start(ap, f); + fprintf(stderr, "%s: ", QUIS); + vfprintf(stderr, f, ap); + va_end(ap); + putc('\n', stderr); +} + +/* --- @die@ --- * + * + * Arguments: @int status@ = exit status to return + * @const char *f@ = a @printf@-style format string + * @...@ = other arguments + * + * Returns: Never. + * + * Use: Reports an error and exits. Like @moan@ above, only more + * permanent. + */ + +void die(int status, const char *f, ...) +{ + va_list ap; + va_start(ap, f); + fprintf(stderr, "%s: ", QUIS); + vfprintf(stderr, f, ap); + va_end(ap); + putc('\n', stderr); + exit(status); +} + +/*----- That's all, folks -------------------------------------------------*/