chiark / gitweb /
Infrastructure: Strip away crufty CVS $Id$ tags.
[mLib] / report.c
CommitLineData
0875b58f 1/* -*-c-*-
0875b58f 2 *
3 * Reporting errors and things
4 *
5 * (c) 1998 Straylight/Edgeware
6 */
7
d4efbcd9 8/*----- Licensing notice --------------------------------------------------*
0875b58f 9 *
10 * This file is part of the mLib utilities library.
11 *
12 * mLib is free software; you can redistribute it and/or modify
c846879c 13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
d4efbcd9 16 *
0875b58f 17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c846879c 20 * GNU Library General Public License for more details.
d4efbcd9 21 *
c846879c 22 * You should have received a copy of the GNU Library General Public
0bd98442 23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
0875b58f 26 */
27
0875b58f 28/*----- Header files ------------------------------------------------------*/
29
30#include <stdarg.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include "quis.h"
36#include "report.h"
37
38/*----- Functions provided ------------------------------------------------*/
39
40/* --- @moan@ --- *
41 *
42 * Arguments: @const char *f@ = a @printf@-style format string
43 * @...@ = other arguments
44 *
45 * Returns: ---
46 *
47 * Use: Reports an error.
48 */
49
50void moan(const char *f, ...)
51{
52 va_list ap;
53 va_start(ap, f);
54 fprintf(stderr, "%s: ", QUIS);
55 vfprintf(stderr, f, ap);
56 va_end(ap);
57 putc('\n', stderr);
58}
59
60/* --- @die@ --- *
61 *
62 * Arguments: @int status@ = exit status to return
63 * @const char *f@ = a @printf@-style format string
64 * @...@ = other arguments
65 *
66 * Returns: Never.
67 *
68 * Use: Reports an error and exits. Like @moan@ above, only more
69 * permanent.
70 */
71
72void die(int status, const char *f, ...)
73{
74 va_list ap;
75 va_start(ap, f);
76 fprintf(stderr, "%s: ", QUIS);
77 vfprintf(stderr, f, ap);
78 va_end(ap);
79 putc('\n', stderr);
80 exit(status);
81}
82
83/*----- That's all, folks -------------------------------------------------*/