source: trunk/Jgraph/exit.c @ 662

Last change on this file since 662 was 419, checked in by Nicholas Riley, 12 years ago

Jgraph: Debian changes by pzn@…

File size: 1.1 KB
Line 
1/*
2**++
3**  FUNCTIONAL DESCRIPTION:
4**
5**      Exit is a VMS replacement for the standard Unix exit function
6**
7**  FORMAL PARAMETERS:
8**
9**      error_code      integer passed by value (optional)
10**
11**  SIDE EFFECTS:
12**
13**      Exit will never return to calling program
14**      VMS exit status ($STATUS) will be set
15**--
16**/
17#include <stdarg.h>
18
19exit(va_alist)
20va_dcl
21{
22        int             nargs;
23        va_list         va;
24        int             exit_code = 0;
25        /*
26         * Pick up the argument, if present
27         */
28        va_count(nargs);
29        va_start(va);
30        if (nargs > 0) exit_code = va_arg(va,int);
31        /*
32         * Set the VMS $STATUS to the appropriate value:
33         *      if exit_code == 0 then $STATUS := success
34         *      if exit_code >  0 then $STATUS := error
35         *      if exit_code <  0 then $STATUS := severe_error
36         * and perform exit.
37         *
38         * Note:
39         *      the %X10000000 added to the actual success/error indicator
40         *      will prevent DCL from printing a message.
41         *      A 'on error' will be obeyed however.
42         */
43        if (exit_code == 0)             /* success      */
44                sys$exit(0x10000001);
45        else if (exit_code > 0)         /* error        */
46                sys$exit(0x10000002);
47        else                            /* severe error */
48                sys$exit(0x10000004);
49}
Note: See TracBrowser for help on using the repository browser.