172
|
1 /* error.c -- Handle info errors. */ |
|
2 |
|
3 /* This file is part of GNU Info, a program for reading online documentation |
|
4 stored in Info format. |
|
5 |
|
6 Copyright (C) 1993 Free Software Foundation, Inc. |
|
7 |
|
8 This program is free software; you can redistribute it and/or modify |
|
9 it under the terms of the GNU General Public License as published by |
|
10 the Free Software Foundation; either version 2, or (at your option) |
|
11 any later version. |
|
12 |
|
13 This program is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with this program; if not, write to the Free Software |
|
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 Written by Brian Fox (bfox@ai.mit.edu). */ |
|
23 |
|
24 #include "info.h" |
|
25 #include "dribble.h" |
|
26 #include "terminal.h" |
|
27 #include "getopt.h" |
|
28 |
|
29 /* The version numbers of this version of Info. */ |
|
30 int info_major_version = 2; |
|
31 int info_minor_version = 10; |
|
32 int info_patch_level = 1; |
|
33 |
|
34 /* When non-zero, the Info window system has been initialized. */ |
|
35 int info_windows_initialized_p = 0; |
|
36 |
|
37 |
|
38 /* **************************************************************** */ |
|
39 /* */ |
|
40 /* Main Entry Point to the Info Program */ |
|
41 /* */ |
|
42 /* **************************************************************** */ |
|
43 |
|
44 /* Return a string describing the current version of Info. */ |
|
45 char * |
|
46 version_string () |
|
47 { |
|
48 static char *vstring = (char *)NULL; |
|
49 |
|
50 if (!vstring) |
|
51 { |
|
52 vstring = (char *)xmalloc (50); |
|
53 sprintf (vstring, "%d.%d", info_major_version, info_minor_version); |
|
54 if (info_patch_level) |
|
55 sprintf (vstring + strlen (vstring), "-p%d", info_patch_level); |
|
56 } |
|
57 return (vstring); |
|
58 } |
|
59 |
|
60 /* **************************************************************** */ |
|
61 /* */ |
|
62 /* Error Handling for Info */ |
|
63 /* */ |
|
64 /* **************************************************************** */ |
|
65 |
|
66 static char *program_name = (char *)NULL; |
|
67 |
|
68 /* Non-zero if an error has been signalled. */ |
|
69 int info_error_was_printed = 0; |
|
70 |
|
71 /* Non-zero means ring terminal bell on errors. */ |
|
72 int info_error_rings_bell_p = 1; |
|
73 |
|
74 /* Print FORMAT with ARG1 and ARG2. If the window system was initialized, |
|
75 then the message is printed in the echo area. Otherwise, a message is |
|
76 output to stderr. */ |
|
77 void |
|
78 info_error (format, arg1, arg2) |
|
79 char *format; |
|
80 void *arg1, *arg2; |
|
81 { |
|
82 info_error_was_printed = 1; |
|
83 |
|
84 if (!info_windows_initialized_p || display_inhibited) |
|
85 { |
|
86 fprintf (stderr, "%s: ", program_name); |
|
87 fprintf (stderr, format, arg1, arg2); |
|
88 fprintf (stderr, "\n"); |
|
89 fflush (stderr); |
|
90 } |
|
91 else |
|
92 { |
|
93 if (!echo_area_is_active) |
|
94 { |
|
95 if (info_error_rings_bell_p) |
|
96 terminal_ring_bell (); |
|
97 window_message_in_echo_area (format, arg1, arg2); |
|
98 } |
|
99 else |
|
100 { |
|
101 NODE *temp; |
|
102 |
|
103 temp = build_message_node (format, arg1, arg2); |
|
104 if (info_error_rings_bell_p) |
|
105 terminal_ring_bell (); |
|
106 inform_in_echo_area (temp->contents); |
|
107 free (temp->contents); |
|
108 free (temp); |
|
109 } |
|
110 } |
|
111 } |
|
112 |
|
113 |