source: trunk/gsdl/packages/mg/lib/messages.c@ 10853

Last change on this file since 10853 was 439, checked in by sjboddie, 25 years ago

renamed mg-1.3d directory mg

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/**************************************************************************
2 *
3 * messages.c -- Message and error functions
4 * Copyright (C) 1994 Neil Sharman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: messages.c 439 1999-08-10 21:23:37Z sjboddie $
21 *
22 **************************************************************************/
23
24/*
25 $Log$
26 Revision 1.1 1999/08/10 21:16:55 sjboddie
27 renamed mg-1.3d directory mg
28
29 Revision 1.2 1998/11/23 03:38:06 rjmcnab
30
31 combined unix and windows versions of mg
32
33 Revision 1.1 1998/11/19 03:00:32 sjboddie
34 Added windows gdbm and mg versions
35
36 * Revision 1.1 1994/08/22 00:24:48 tes
37 * Initial placement under CVS.
38 *
39 */
40
41static char *RCSID = "$Id: messages.c 439 1999-08-10 21:23:37Z sjboddie $";
42
43#include "sysfuncs.h"
44
45#include <stdarg.h>
46#include "messages.h"
47
48char *msg_prefix = "";
49
50
51void VOLATILE
52FatalError (int ExitCode, const char *fmt,...)
53{
54 char buf[1024];
55 char *s, *pfx;
56 va_list args;
57 va_start (args, fmt);
58 vsprintf (buf, fmt, args);
59 s = strrchr (buf, '\n');
60 if (!s || *(s + 1) != '\0')
61 strcat (buf, "\n");
62 pfx = strrchr (msg_prefix, '/');
63 pfx = pfx ? pfx + 1 : msg_prefix;
64 fprintf (stderr, "%s%s%s", pfx, *pfx ? " : " : "", buf);
65 exit (ExitCode);
66}
67
68
69
70/*
71 * This function writes messages to stderr. Due to the fact that I can't
72 * guarantee that the fprintf call is monatomic I have to implement a
73 * semaphore system.
74 */
75void
76Message (const char *fmt,...)
77{
78 char buf[1024];
79 char *s, *pfx;
80 va_list args;
81
82#ifdef QUIET
83 return; /* stop those messages!!!! */
84#endif
85
86 va_start (args, fmt);
87 vsprintf (buf, fmt, args);
88 s = strrchr (buf, '\n');
89 if (!s || *(s + 1) != '\0')
90 strcat (buf, "\n");
91
92 pfx = strrchr (msg_prefix, '/');
93 pfx = pfx ? pfx + 1 : msg_prefix;
94 fprintf (stderr, "%s%s%s", pfx, *pfx ? " : " : "", buf);
95
96}
Note: See TracBrowser for help on using the repository browser.