1 /*
2 **
3 ** error.c
4 **
5 ** Copyright (C) 1995, 1996, 1997 Johannes Plass
6 ** Copyright (C) 2004 Jose E. Marchesi
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 3 of the License, or
11 ** (at your option) 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 GNU gv; see the file COPYING.  If not, write to
20 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ** Boston, MA 02111-1307, USA.
22 **
23 ** Author:   Johannes Plass (plass@thep.physik.uni-mainz.de)
24 **           Department of Physics
25 **           Johannes Gutenberg-University
26 **           Mainz, Germany
27 **
28 **           Jose E. Marchesi (jemarch@gnu.org)
29 **           GNU Project
30 **
31 */
32 #include "ac_config.h"
33 
34 
35 /*
36 #define MESSAGES
37 */
38 #include "message.h"
39 
40 #include "config.h"
41 
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45 
46 #include "paths.h"
47 #include INC_X11(Xos.h)
48 #include INC_X11(Intrinsic.h)
49 
50 #include "types.h"
51 #include "error.h"
52 #include "main_resources.h"
53 #include "main_globals.h"
54 
55 char*
open_fail_error(errornumber,error_str,file_name,show)56 open_fail_error(errornumber,error_str,file_name,show)
57   int errornumber;
58   char *error_str;
59   char *file_name;
60   int show;
61 {
62   char *m;
63 
64   if (!(m = strerror(errornumber))) m = "Unknown error";
65 
66   if (show) {
67     fprintf(stderr,"%s: %s %s (%s)\n",gv_name,error_str,file_name,m);
68     m = NULL;
69   } else {
70     char buf[1024];
71     sprintf(buf,"%s %s: %s",error_str,file_name,m);
72     m = XtNewString(buf);
73   }
74   ENDMESSAGE(open_fail_error_message)
75   return(m);
76 }
77 
78