summaryrefslogtreecommitdiff
path: root/dviware/beebe/src/dviterm.h
blob: aa0959753e3320ca166edc848d1c05cb9f1bdb28 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*-C-*- dviterm.h */
/*-->dviterm*/
/**********************************************************************/
/****************************** dviterm *******************************/
/**********************************************************************/

void
dviterm()			/* terminate DVI file processing */
{
    register INT16 k;		/* loop index */

#if    OS_VAXVMS
    /* Stupid VMS fflush() raises error and loses last data block
       unless it is full for a fixed-length record binary file.
       Pad it here with IM_EOF characters, sigh... */
    for (k = (INT16)((*plotfp)->_cnt); k > 0; --k)
#if    IMPRESS
        OUTC(IM_EOF);
#else
        OUTC('\0');
#endif
#endif /* OS_VAXVMS */

    if (fflush(plotfp) == EOF)
	(void)fatal("dviterm(): Output error -- disk storage probably full");

    /* Close all files and free dynamically-allocated font space.  Stdin
       is never closed, however, because it might be needed later for
       ioctl(). */

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

    for (k = 1; k <= (INT16)nopen; ++k)
    {
	if (font_files[k].font_id != (FILE *)NULL)
	{

#if    VIRTUAL_FONTS
	    if (virt_font)
	        (void)virtfree(font_files[k].font_id);
#endif /* VIRTUAL_FONTS */

	    (void)fclose(font_files[k].font_id);
	    font_files[k].font_id = (FILE *)NULL;
	}
    }

    fontptr = hfontptr;
    while (fontptr != (struct font_entry *)NULL)
    {
	for (k = 0; k < NPXLCHARS; ++k)
	    if ((fontptr->ch[k].rasters) != (UNSIGN32 *)NULL)
		(void)free((char *)fontptr->ch[k].rasters);
	pfontptr = fontptr;
	fontptr = fontptr->next;
	(void)free((char *)pfontptr);
    }
    if (!quiet)
    {
	(void)fprintf(stderr," [OK]");
	NEWLINE(stderr);
    }

#if    (BSD42 | OS_TOPS20)
    if (spool_output)
    {
	register char *p;

#if    BSD42
	(void)sprintf(message,"DVISPOOL %s\n",dvoname);
#endif

#if    OS_TOPS20
	(void)sprintf(message,"DVISPOOL: %s\n",dvoname);
#endif

	for (p = message; *p; ++p)
	{
#if    OS_TOPS20
	    ac1 = 0100;		/* .priin (primary input) */
	    ac2 = *p;		/* next character from string */
	    jsys(JSsti, acs);	/* stuff it into terminal input buffer */
#endif

#if    BSD42
	    (void)ioctl(fileno(stdin),TIOCSTI,p);
#endif

	}
    }
#endif /* (BSD42 | OS_TOPS20) */

}