source: trunk/gsdl/src/mgpp/lib/messages.cpp@ 855

Last change on this file since 855 was 855, checked in by sjboddie, 24 years ago

Rodgers new C++ mg

  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 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.cpp 855 2000-01-14 02:17:52Z sjboddie $
21 *
22 **************************************************************************/
23
24/*
25 $Log$
26 Revision 1.1 2000/01/14 02:17:10 sjboddie
27 Rodgers new C++ mg
28
29 Revision 1.1 1999/10/11 02:55:16 cs025
30 Base install of MG-PP
31
32 Revision 1.1 1999/08/10 21:16:55 sjboddie
33 renamed mg-1.3d directory mg
34
35 Revision 1.2 1998/11/23 03:38:06 rjmcnab
36
37 combined unix and windows versions of mg
38
39 Revision 1.1 1998/11/19 03:00:32 sjboddie
40 Added windows gdbm and mg versions
41
42 * Revision 1.1 1994/08/22 00:24:48 tes
43 * Initial placement under CVS.
44 *
45 */
46
47static char *RCSID = "$Id: messages.cpp 855 2000-01-14 02:17:52Z sjboddie $";
48
49#include "sysfuncs.h"
50
51#include <stdarg.h>
52#include "messages.h"
53
54char *msg_prefix = "";
55
56
57void VOLATILE
58FatalError (int ExitCode, const char *fmt,...)
59{
60 char buf[1024];
61 char *s, *pfx;
62 va_list args;
63 va_start (args, fmt);
64 vsprintf (buf, fmt, args);
65 s = strrchr (buf, '\n');
66 if (!s || *(s + 1) != '\0')
67 strcat (buf, "\n");
68 pfx = strrchr (msg_prefix, '/');
69 pfx = pfx ? pfx + 1 : msg_prefix;
70 fprintf (stderr, "%s%s%s", pfx, *pfx ? " : " : "", buf);
71 exit (ExitCode);
72}
73
74
75
76/*
77 * This function writes messages to stderr. Due to the fact that I can't
78 * guarantee that the fprintf call is monatomic I have to implement a
79 * semaphore system.
80 */
81void
82Message (const char *fmt,...)
83{
84 char buf[1024];
85 char *s, *pfx;
86 va_list args;
87
88#ifdef QUIET
89 return; /* stop those messages!!!! */
90#endif
91
92 va_start (args, fmt);
93 vsprintf (buf, fmt, args);
94 s = strrchr (buf, '\n');
95 if (!s || *(s + 1) != '\0')
96 strcat (buf, "\n");
97
98 pfx = strrchr (msg_prefix, '/');
99 pfx = pfx ? pfx + 1 : msg_prefix;
100 fprintf (stderr, "%s%s%s", pfx, *pfx ? " : " : "", buf);
101
102}
Note: See TracBrowser for help on using the repository browser.