1 /*
2    Hebcal - A Jewish Calendar Generator
3    Copyright (C) 1994-2004  Danny Sadinoff
4 
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License
7    as published by the Free Software Foundation; either version 2
8    of the License, or (at your option) any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19    Danny Sadinoff can be reached at
20    danny@sadinoff.com
21 
22  */
23 
24 /*
25   a la perl
26 */
27 
28 #include "myerror.h"
29 #include <errno.h>
30 #include <stdlib.h>
31 
32 extern char *progname;
33 
34 /* print error message and die */
die(const char * s1,const char * s2)35 void die( const char *s1, const char *s2)
36 {
37     if (errno)
38         perror (progname);
39     else
40         fprintf (stderr, "%s: ", progname);
41     fprintf (stderr, s1, s2);
42     fprintf (stderr, "\n");
43     exit (1);
44 }
45 
46 /* print error message but don't die */
warn(const char * s1,const char * s2)47 void warn( const char *s1, const char *s2)
48 {
49     if (errno)
50         perror (progname);
51     else
52         fprintf (stderr, "%s: ", progname);
53     fprintf (stderr, s1, s2);
54     fprintf (stderr, "\n");
55     errno = 0;
56 }
57