1 /*	Copyright 1993,94 H.Ogasawara (COR.)	*/
2 
3 /* v1.00  1993 10/10	Ogasawara Hiroyuki		*/
4 /*			oga@dgw.yz.yamagata-u.ac.jp	*/
5 /* v1.10  1994 03/19	Ogasawara Hiroyuki		*/
6 
7 #include	<stdio.h>
8 
9 #define	EMPTY		0
10 #define	STACKSIZE	256
11 #define	PRESIZE		(1024*16)
12 
13 static int	cstack[STACKSIZE],
14 		*cstackptr= cstack,
15 		presize= 0;
16 unsigned char	prebuf[PRESIZE],
17 		*preptr= prebuf;
18 
19 FILE	*FP, *FO;
20 
21 void
putcode(code)22 putcode( code )
23 unsigned int	code;
24 {
25 	putc( code, FO );
26 }
27 
28 void
putcodew(code)29 putcodew( code )
30 unsigned int	code;
31 {
32 	unsigned int	hi= code>>8;
33 	if( hi )
34 		putcode( hi );
35 	putcode( code & 0xff );
36 }
37 
38 int
getcode()39 getcode()
40 {
41 	if( cstackptr > cstack )
42 		return	*--cstackptr;
43 	if( presize ){
44 		presize--;
45 		return	*preptr++;
46 	}
47 	return	getc( FP );
48 }
49 
50 void
ungetcode(code)51 ungetcode( code )
52 {
53 	*cstackptr++= code;
54 }
55 
56 void
preread(cp)57 preread( cp )
58 void	*cp;
59 {
60 	presize= fread( preptr= prebuf, 1, PRESIZE, FP );
61 	SjisEucCheck( prebuf, presize, cp );
62 }
63 
64 #if HUMAN
isdir(name)65 isdir( name )
66 char	*name;
67 {
68 	return	CHMOD( name, -1 ) & 0x10;
69 }
70 #else
71 #include	<sys/types.h>
72 #include	<sys/stat.h>
filedate(fn)73 filedate( fn )
74 {
75 	struct stat	st;
76 	fstat( fn, &st );
77 	return	st.st_mtime;
78 }
79 
filesetdate(name,set)80 filesetdate( name, set )
81 char	*name;
82 {
83 	time_t	tim[2];
84 	tim[0]= tim[1]= set;
85 	utime( name, tim );
86 }
87 
isdir(name)88 isdir( name )
89 char	*name;
90 {
91 	struct stat	st;
92 	stat( name, &st );
93 	return	st.st_mode & S_IFDIR;
94 }
95 #endif
96