initial commit
[jalview.git] / forester / archive / RIO / others / hmmer / squid / sqerror.c
1 /*****************************************************************
2  * HMMER - Biological sequence analysis with profile HMMs
3  * Copyright (C) 1992-1999 Washington University School of Medicine
4  * All Rights Reserved
5  * 
6  *     This source code is distributed under the terms of the
7  *     GNU General Public License. See the files COPYING and LICENSE
8  *     for details.
9  *****************************************************************/
10
11 /* sqerror.c
12  * 
13  * error handling for the squid library
14  * RCS $Id: sqerror.c,v 1.1.1.1 2005/03/22 08:34:26 cmzmasek Exp $
15  */
16
17                                 /* a global errno equivalent */
18 int squid_errno;
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <stdarg.h>
23
24 #ifdef MEMDEBUG
25 #include "dbmalloc.h"
26 #endif
27
28 /* Function: Die()
29  * 
30  * Purpose:  Print an error message and die. The arguments
31  *           are formatted exactly like arguments to printf().
32  *           
33  * Return:   None. Exits the program.
34  */          
35 /* VARARGS0 */
36 void
37 Die(char *format, ...)
38 {
39   va_list  argp;
40                                 /* format the error mesg */
41   fprintf(stderr, "\nFATAL: ");
42   va_start(argp, format);
43   vfprintf(stderr, format, argp);
44   va_end(argp);
45   fprintf(stderr, "\n");
46   fflush(stderr);
47                                 /* exit  */
48   exit(1);
49 }
50
51
52
53 /* Function: Warn()
54  * 
55  * Purpose:  Print an error message and return. The arguments
56  *           are formatted exactly like arguments to printf().
57  *           
58  * Return:   (void)
59  */          
60 /* VARARGS0 */
61 void
62 Warn(char *format, ...)
63 {
64   va_list  argp;
65                                 /* format the error mesg */
66   fprintf(stderr, "WARNING: ");
67   va_start(argp, format);
68   vfprintf(stderr, format, argp);
69   va_end(argp);
70   fprintf(stderr, "\n");
71   fflush(stderr);
72 }
73
74 /* Function: Panic()
75  * 
76  * Purpose:  Die from a lethal error that's not my problem,
77  *           but instead a failure of a StdC/POSIX call that
78  *           shouldn't fail. Call perror() to get the
79  *           errno flag, then die.
80  *           
81  *           Usually called by the PANIC macro which adds
82  *           the __FILE__ and __LINE__ information; see
83  *           structs.h.
84  *           
85  *           Inspired by code in Donald Lewine's book, _POSIX 
86  *           Programmer's Guide_.
87  */
88 void
89 Panic(char *file, int line)
90 {
91   (void) fprintf(stderr, "\nPANIC [%s line %d] ", file, line);
92   (void) perror("Unusual error");
93   exit(EXIT_FAILURE);
94 }
95