date and time created 88/07/21 17:35:30 by marc
authorMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Fri, 22 Jul 1988 08:35:30 +0000 (00:35 -0800)
committerMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Fri, 22 Jul 1988 08:35:30 +0000 (00:35 -0800)
SCCS-vsn: local/toolchest/ksh/shlib/failed.c 1.1

usr/src/local/toolchest/ksh/shlib/failed.c [new file with mode: 0644]

diff --git a/usr/src/local/toolchest/ksh/shlib/failed.c b/usr/src/local/toolchest/ksh/shlib/failed.c
new file mode 100644 (file)
index 0000000..9f8f846
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+
+ *      Copyright (c) 1984, 1985, 1986 AT&T
+ *      All Rights Reserved
+
+ *      THIS IS UNPUBLISHED PROPRIETARY SOURCE 
+ *      CODE OF AT&T.
+ *      The copyright notice above does not 
+ *      evidence any actual or intended
+ *      publication of such source code.
+
+ */
+/* @(#)failed.c        1.1 */
+
+/*
+ *   FAILED.C
+ *
+ *   Programmer:  D. A. Lambeth
+ *
+ *        Owner:  D. A. Lambeth
+ *
+ *         Date:  April 17, 1980
+ *
+ *
+ *
+ *   FAILED (S1, S2)
+ *
+ *        Program Failure.  Print an error diagnostic containing
+ *        the strings S1 and S2, and longjmp to an error-handling
+ *        routine.
+ *
+ *
+ *
+ *   See Also:  SETJMP(3C)
+ */
+
+/*
+ *   FAILED (S1, S2)
+ *
+ *        char *S1;
+ *
+ *        char *S2;
+ *
+ *   Print an error message of the format
+ *
+ *        S1 : S2
+ *
+ *   at the stderr file.
+ *
+ *   Longjmp to the location errshell, which must have been
+ *   established previously by a call to setjmp.
+ *
+ *   Note that the return value from setjmp will always be
+ *   '1'.
+ */
+
+#include <stdio.h>
+#include <setjmp.h>
+
+extern jmp_buf errshell;
+extern char colon[], newline[];
+
+void   failed(s1,s2)
+char   *s1, *s2;
+{
+       write (2, s1, strlen(s1));
+       if (s2)
+       {
+               write (2, colon, strlen(colon));
+               write (2, s2, strlen(s2));
+       }
+       write (2, newline, strlen(newline));
+       longjmp(errshell, 1);
+}