source: trunk/gsdl3/src/packages/mg/lib/messages.c@ 3745

Last change on this file since 3745 was 3745, checked in by mdewsnip, 21 years ago

Addition of MG package for search and retrieval

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