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