1*35186Smarc /*
2*35186Smarc 
3*35186Smarc  *      Copyright (c) 1984, 1985, 1986 AT&T
4*35186Smarc  *      All Rights Reserved
5*35186Smarc 
6*35186Smarc  *      THIS IS UNPUBLISHED PROPRIETARY SOURCE
7*35186Smarc  *      CODE OF AT&T.
8*35186Smarc  *      The copyright notice above does not
9*35186Smarc  *      evidence any actual or intended
10*35186Smarc  *      publication of such source code.
11*35186Smarc 
12*35186Smarc  */
13*35186Smarc /* @(#)failed.c	1.1 */
14*35186Smarc 
15*35186Smarc /*
16*35186Smarc  *   FAILED.C
17*35186Smarc  *
18*35186Smarc  *   Programmer:  D. A. Lambeth
19*35186Smarc  *
20*35186Smarc  *        Owner:  D. A. Lambeth
21*35186Smarc  *
22*35186Smarc  *         Date:  April 17, 1980
23*35186Smarc  *
24*35186Smarc  *
25*35186Smarc  *
26*35186Smarc  *   FAILED (S1, S2)
27*35186Smarc  *
28*35186Smarc  *        Program Failure.  Print an error diagnostic containing
29*35186Smarc  *        the strings S1 and S2, and longjmp to an error-handling
30*35186Smarc  *        routine.
31*35186Smarc  *
32*35186Smarc  *
33*35186Smarc  *
34*35186Smarc  *   See Also:  SETJMP(3C)
35*35186Smarc  */
36*35186Smarc 
37*35186Smarc /*
38*35186Smarc  *   FAILED (S1, S2)
39*35186Smarc  *
40*35186Smarc  *        char *S1;
41*35186Smarc  *
42*35186Smarc  *        char *S2;
43*35186Smarc  *
44*35186Smarc  *   Print an error message of the format
45*35186Smarc  *
46*35186Smarc  *        S1 : S2
47*35186Smarc  *
48*35186Smarc  *   at the stderr file.
49*35186Smarc  *
50*35186Smarc  *   Longjmp to the location errshell, which must have been
51*35186Smarc  *   established previously by a call to setjmp.
52*35186Smarc  *
53*35186Smarc  *   Note that the return value from setjmp will always be
54*35186Smarc  *   '1'.
55*35186Smarc  */
56*35186Smarc 
57*35186Smarc #include <stdio.h>
58*35186Smarc #include <setjmp.h>
59*35186Smarc 
60*35186Smarc extern jmp_buf errshell;
61*35186Smarc extern char colon[], newline[];
62*35186Smarc 
failed(s1,s2)63*35186Smarc void	failed(s1,s2)
64*35186Smarc char	*s1, *s2;
65*35186Smarc {
66*35186Smarc 	write (2, s1, strlen(s1));
67*35186Smarc 	if (s2)
68*35186Smarc 	{
69*35186Smarc 		write (2, colon, strlen(colon));
70*35186Smarc 		write (2, s2, strlen(s2));
71*35186Smarc 	}
72*35186Smarc 	write (2, newline, strlen(newline));
73*35186Smarc 	longjmp(errshell, 1);
74*35186Smarc }
75