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 |
1242
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
172
|
28 #include "info.h" |
|
29 #include "dribble.h" |
|
30 #include "terminal.h" |
|
31 #include "getopt.h" |
|
32 |
|
33 /* The version numbers of this version of Info. */ |
|
34 int info_major_version = 2; |
|
35 int info_minor_version = 10; |
|
36 int info_patch_level = 1; |
|
37 |
|
38 /* When non-zero, the Info window system has been initialized. */ |
|
39 int info_windows_initialized_p = 0; |
|
40 |
|
41 |
|
42 /* **************************************************************** */ |
|
43 /* */ |
|
44 /* Main Entry Point to the Info Program */ |
|
45 /* */ |
|
46 /* **************************************************************** */ |
|
47 |
|
48 /* Return a string describing the current version of Info. */ |
|
49 char * |
|
50 version_string () |
|
51 { |
|
52 static char *vstring = (char *)NULL; |
|
53 |
|
54 if (!vstring) |
|
55 { |
|
56 vstring = (char *)xmalloc (50); |
|
57 sprintf (vstring, "%d.%d", info_major_version, info_minor_version); |
|
58 if (info_patch_level) |
|
59 sprintf (vstring + strlen (vstring), "-p%d", info_patch_level); |
|
60 } |
|
61 return (vstring); |
|
62 } |
|
63 |
|
64 /* **************************************************************** */ |
|
65 /* */ |
|
66 /* Error Handling for Info */ |
|
67 /* */ |
|
68 /* **************************************************************** */ |
|
69 |
251
|
70 static char *program_name = "info"; |
172
|
71 |
|
72 /* Non-zero if an error has been signalled. */ |
|
73 int info_error_was_printed = 0; |
|
74 |
|
75 /* Non-zero means ring terminal bell on errors. */ |
|
76 int info_error_rings_bell_p = 1; |
|
77 |
|
78 /* Print FORMAT with ARG1 and ARG2. If the window system was initialized, |
|
79 then the message is printed in the echo area. Otherwise, a message is |
|
80 output to stderr. */ |
|
81 void |
|
82 info_error (format, arg1, arg2) |
|
83 char *format; |
|
84 void *arg1, *arg2; |
|
85 { |
|
86 info_error_was_printed = 1; |
|
87 |
|
88 if (!info_windows_initialized_p || display_inhibited) |
|
89 { |
|
90 fprintf (stderr, "%s: ", program_name); |
|
91 fprintf (stderr, format, arg1, arg2); |
|
92 fprintf (stderr, "\n"); |
|
93 fflush (stderr); |
|
94 } |
|
95 else |
|
96 { |
|
97 if (!echo_area_is_active) |
|
98 { |
|
99 if (info_error_rings_bell_p) |
|
100 terminal_ring_bell (); |
|
101 window_message_in_echo_area (format, arg1, arg2); |
|
102 } |
|
103 else |
|
104 { |
|
105 NODE *temp; |
|
106 |
|
107 temp = build_message_node (format, arg1, arg2); |
|
108 if (info_error_rings_bell_p) |
|
109 terminal_ring_bell (); |
|
110 inform_in_echo_area (temp->contents); |
|
111 free (temp->contents); |
|
112 free (temp); |
|
113 } |
|
114 } |
|
115 } |
|
116 |
|
117 |