source: trunk/gsdl/packages/mg-1.3d/lib/messages.c@ 13

Last change on this file since 13 was 13, checked in by rjmcnab, 25 years ago

* empty log message *

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 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 13 1998-11-17 09:36:00Z rjmcnab $
21 *
22 **************************************************************************/
23
24/*
25 $Log$
26 Revision 1.1 1998/11/17 09:32:14 rjmcnab
27 *** empty log message ***
28
29 * Revision 1.1 1994/08/22 00:24:48 tes
30 * Initial placement under CVS.
31 *
32 */
33
34static char *RCSID = "$Id: messages.c 13 1998-11-17 09:36:00Z rjmcnab $";
35
36#include "sysfuncs.h"
37
38#include <stdarg.h>
39#include "messages.h"
40
41char *msg_prefix = "";
42
43
44void VOLATILE
45FatalError (int ExitCode, const char *fmt,...)
46{
47 char buf[1024];
48 char *s, *pfx;
49 va_list args;
50 va_start (args, fmt);
51 vsprintf (buf, fmt, args);
52 s = strrchr (buf, '\n');
53 if (!s || *(s + 1) != '\0')
54 strcat (buf, "\n");
55 pfx = strrchr (msg_prefix, '/');
56 pfx = pfx ? pfx + 1 : msg_prefix;
57 fprintf (stderr, "%s%s%s", pfx, *pfx ? " : " : "", buf);
58 exit (ExitCode);
59}
60
61
62
63/*
64 * This function writes messages to stderr. Due to the fact that I can't
65 * guarantee that the fprintf call is monatomic I have to implement a
66 * semaphore system.
67 */
68void
69Message (const char *fmt,...)
70{
71 char buf[1024];
72 char *s, *pfx;
73 va_list args;
74 va_start (args, fmt);
75 vsprintf (buf, fmt, args);
76 s = strrchr (buf, '\n');
77 if (!s || *(s + 1) != '\0')
78 strcat (buf, "\n");
79
80 pfx = strrchr (msg_prefix, '/');
81 pfx = pfx ? pfx + 1 : msg_prefix;
82 fprintf (stderr, "%s%s%s", pfx, *pfx ? " : " : "", buf);
83
84}
Note: See TracBrowser for help on using the repository browser.