summaryrefslogtreecommitdiff
path: root/dviware/beebe/src/abortrun.h
blob: a7dba6cde150b4111a56e78433856116005e957b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* -*-C-*- abortrun.h */
/*-->abortrun*/
/**********************************************************************/
/***************************  abortrun  *******************************/
/**********************************************************************/

void
abortrun(code)
int code;

{
    /*******************************************************************
    This routine  is called  on both  success and  failure to  terminate
    execution.  All open files (except stdin, stdout, stderr) are closed
    before calling EXIT() to quit.
    *******************************************************************/

    UNSIGN16 k;

    for (k = 0; k < (UNSIGN16)nopen; ++k)
	if (font_files[k].font_id != (FILE*)NULL)
	    (void)fclose(font_files[k].font_id);

    if (dvifp != (FILE*)NULL)
        (void)fclose(dvifp);
    if (plotfp != (FILE*)NULL)
        (void)fclose(plotfp);
    if (g_dolog && (g_logfp != (FILE *)NULL))
	(void)fclose(g_logfp);

#if    (OS_TOPS20 | OS_VAXVMS)
    if (code)
    {
	NEWLINE(stderr);
	(void)fprintf(stderr,"?Aborted with error code %d",code);
	NEWLINE(stderr);
	(void)perror("?perror() says");
    }
#endif

    (void)EXIT(code);
}