* Clean up a bit

* Close the ttyrec file when watching is done


git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@332 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Jilles Tjoelker 2004-08-23 12:30:24 +00:00
parent e31ca985ee
commit 30973454e4
1 changed files with 7 additions and 10 deletions

View File

@ -49,7 +49,6 @@
#include "io.h" #include "io.h"
#include "stripgfx.h" #include "stripgfx.h"
off_t seek_offset_clrscr;
int stripped = NO_GRAPHICS; int stripped = NO_GRAPHICS;
struct timeval struct timeval
@ -264,10 +263,11 @@ ttyplay (FILE * fp, double speed, ReadFunc read_func,
return r; return r;
} }
void static off_t
set_seek_offset_clrscr (FILE * fp) find_seek_offset_clrscr (FILE * fp)
{ {
off_t raw_seek_offset = 0; off_t raw_seek_offset = 0;
off_t seek_offset_clrscr;
char *buf; char *buf;
struct stat mystat; struct stat mystat;
int state = 0; int state = 0;
@ -312,6 +312,7 @@ set_seek_offset_clrscr (FILE * fp)
free (buf); free (buf);
seek_offset_clrscr = 0;
/* now find last filepos that is less than seek offset */ /* now find last filepos that is less than seek offset */
fseek (fp, 0, SEEK_SET); fseek (fp, 0, SEEK_SET);
while (1) while (1)
@ -332,6 +333,7 @@ set_seek_offset_clrscr (FILE * fp)
free (buf); free (buf);
} }
return seek_offset_clrscr;
} }
#if 0 /* not used anymore */ #if 0 /* not used anymore */
@ -359,11 +361,7 @@ ttypeek (FILE * fp, double speed)
do do
{ {
setvbuf (fp, NULL, _IOFBF, 0); setvbuf (fp, NULL, _IOFBF, 0);
set_seek_offset_clrscr (fp); ttyplay (fp, 0, ttyread, ttywrite, ttynowait, find_seek_offset_clrscr (fp));
if (seek_offset_clrscr)
{
ttyplay (fp, 0, ttyread, ttywrite, ttynowait, seek_offset_clrscr);
}
clearerr (fp); clearerr (fp);
setvbuf (fp, NULL, _IONBF, 0); setvbuf (fp, NULL, _IONBF, 0);
fflush (stdout); fflush (stdout);
@ -383,8 +381,6 @@ ttyplay_main (char *ttyfile, int mode)
populate_gfx_array (stripped); populate_gfx_array (stripped);
seek_offset_clrscr = 0;
input = efopen (ttyfile, "r"); input = efopen (ttyfile, "r");
tcgetattr (0, &old); /* Get current terminal state */ tcgetattr (0, &old); /* Get current terminal state */
@ -400,6 +396,7 @@ ttyplay_main (char *ttyfile, int mode)
ttyplayback (input, speed, read_func, wait_func); ttyplayback (input, speed, read_func, wait_func);
tcsetattr (0, TCSANOW, &old); /* Return terminal state */ tcsetattr (0, TCSANOW, &old); /* Return terminal state */
fclose (input);
return 0; return 0;
} }