1 /* @(#) turboc.c 1.2 87/06/21 16:08:54 */
2
3 int _stklen = 30000; /* stack size in bytes */
_setenvp()4 void _setenvp() {} /* don't initialize environment pointer etc. */
5 #include <stdio.h> /* to get fileno() */
6
7 /* following not needed any more since zoocreate() is fixed in portable.c */
8 /* unsigned _fmode = O_BINARY; */
9
10 void dosname PARMS((char *, char *));
11 #ifdef ANSI_HDRS
12 # include <stdlib.h>
13 #else
14 char *strcpy PARMS((char *, char *));
15 #endif
16
17 #include <signal.h>
18
19 /* register definitions specific for Turbo C */
20 union REGS {
21 struct { unsigned ax, bx, cx, dx, si, di, carry, flags; } x;
22 struct { unsigned char al, ah, bl, bh, cl, ch, dl, dh; } h;
23 };
24
25 /****************
26 function zootrunc() truncates a file at the current seek position.
27 */
28
zootrunc(f)29 int zootrunc (f)
30 FILE *f;
31 {
32 int handle = fileno(f);
33 extern long tell();
34 extern int chsize();
35 return chsize(handle, tell(handle));
36 }
37
38 /****************
39 Function fixfname() converts the supplied filename to a syntax
40 legal for the host system. It is used during extraction.
41 */
42
fixfname(fname)43 char *fixfname(fname)
44 char *fname;
45 {
46 char tmpname[PATHSIZE];
47 dosname (nameptr(fname), tmpname);
48 strcpy(fname,tmpname);
49 return(fname);
50 }
51
set_break(int flag)52 static int set_break (int flag)
53 {
54 extern int intdos();
55 int retval;
56 union REGS regs;
57 regs.x.ax = 0x3300; /* get ctrl-break flag */
58 intdos (®s, ®s);
59 retval = regs.h.dl; /* retval is old value of setting */
60 regs.x.ax = 0x3301; /* set ctrl-break flag */
61 regs.h.dl = flag; /* status to set to */
62 intdos (®s, ®s);
63 return (retval);
64 }
65
66 static int break_flag;
67
zooexit(int status)68 void zooexit (int status)
69 {
70 set_break (break_flag); /* restore control_break setting */
71 exit (status);
72 }
73
74 void gentab (void);
75
spec_init(void)76 void spec_init(void)
77 {
78 break_flag = set_break (0);
79 signal (SIGINT, zooexit); /* install our own control-C handler */
80 }
81
82 #ifndef fileno
83 /* To allow compilation with -A (for testing), which makes fileno()
84 unavailable, we define a function here by that name. This may be
85 compiler-specific for Turbo C++ 1.0. */
86
fileno(f)87 int fileno(f)
88 FILE *f;
89 {
90 return f->fd;
91 }
92 #endif /* ! fileno */
93