Ensure correct Remote Console functionality when log files get big

This commit is contained in:
Mark Pizzolato 2013-04-21 05:46:52 -07:00
parent 4c6f086eb3
commit 02b3477d20
3 changed files with 14 additions and 13 deletions

View file

@ -484,7 +484,7 @@ TMLN *lp;
char cbuf[4*CBUFSIZE], gbuf[CBUFSIZE], *cptr, *argv[1] = {NULL}; char cbuf[4*CBUFSIZE], gbuf[CBUFSIZE], *cptr, *argv[1] = {NULL};
CTAB *cmdp; CTAB *cmdp;
uint32 read_start_time; uint32 read_start_time;
long cmd_log_start; t_offset cmd_log_start;
tmxr_poll_rx (&sim_rem_con_tmxr); /* poll input */ tmxr_poll_rx (&sim_rem_con_tmxr); /* poll input */
for (i=0; i < sim_rem_con_tmxr.lines; i++) { for (i=0; i < sim_rem_con_tmxr.lines; i++) {
@ -603,7 +603,7 @@ for (i=0; i < sim_rem_con_tmxr.lines; i++) {
cptr = cbuf; cptr = cbuf;
cptr = get_glyph (cptr, gbuf, 0); /* get command glyph */ cptr = get_glyph (cptr, gbuf, 0); /* get command glyph */
sim_switches = 0; /* init switches */ sim_switches = 0; /* init switches */
cmd_log_start = ftell (sim_log); cmd_log_start = sim_ftell (sim_log);
if (!find_cmd (gbuf)) /* validate command */ if (!find_cmd (gbuf)) /* validate command */
stat = SCPE_UNK; stat = SCPE_UNK;
else { else {
@ -633,7 +633,7 @@ for (i=0; i < sim_rem_con_tmxr.lines; i++) {
} }
} }
fflush (sim_log); fflush (sim_log);
fseek (sim_log, cmd_log_start, SEEK_SET); sim_fseeko (sim_log, cmd_log_start, SEEK_SET);
cbuf[sizeof(cbuf)-1] = '\0'; cbuf[sizeof(cbuf)-1] = '\0';
while (fgets (cbuf, sizeof(cbuf)-1, sim_log)) { while (fgets (cbuf, sizeof(cbuf)-1, sim_log)) {
tmxr_linemsg (lp, cbuf); tmxr_linemsg (lp, cbuf);

View file

@ -176,7 +176,7 @@ return total;
/* Forward Declaration */ /* Forward Declaration */
static t_offset _sim_ftell (FILE *st); t_offset sim_ftell (FILE *st);
/* Get file size */ /* Get file size */
@ -186,9 +186,9 @@ t_offset pos, sz;
if (fp == NULL) if (fp == NULL)
return 0; return 0;
pos = _sim_ftell (fp); pos = sim_ftell (fp);
sim_fseek (fp, 0, SEEK_END); sim_fseek (fp, 0, SEEK_END);
sz = _sim_ftell (fp); sz = sim_ftell (fp);
sim_fseeko (fp, pos, SEEK_SET); sim_fseeko (fp, pos, SEEK_SET);
return sz; return sz;
} }
@ -242,7 +242,7 @@ int sim_fseeko (FILE *st, t_offset offset, int whence)
return fseeko (st, (off_t)offset, whence); return fseeko (st, (off_t)offset, whence);
} }
static t_offset _sim_ftell (FILE *st) t_offset sim_ftell (FILE *st)
{ {
return (t_offset)(ftello (st)); return (t_offset)(ftello (st));
} }
@ -258,7 +258,7 @@ int sim_fseeko (FILE *st, t_offset offset, int whence)
return fseek (st, offset, whence); return fseek (st, offset, whence);
} }
static t_offset _sim_ftell (FILE *st) t_offset sim_ftell (FILE *st)
{ {
return (t_offset)(ftell (st)); return (t_offset)(ftell (st));
} }
@ -301,7 +301,7 @@ switch (whence) {
return fsetpos (st, &fileaddr); return fsetpos (st, &fileaddr);
} }
static t_offset _sim_ftell (FILE *st) t_offset sim_ftell (FILE *st)
{ {
fpos_t fileaddr; fpos_t fileaddr;
if (fgetpos (st, &fileaddr)) if (fgetpos (st, &fileaddr))
@ -320,7 +320,7 @@ int sim_fseeko (FILE *st, t_offset xpos, int origin)
return fseeko64 (st, (off64_t)xpos, origin); return fseeko64 (st, (off64_t)xpos, origin);
} }
static t_offset _sim_ftell (FILE *st) t_offset sim_ftell (FILE *st)
{ {
return (t_offset)(ftello64 (st)); return (t_offset)(ftello64 (st));
} }
@ -336,7 +336,7 @@ int sim_fseeko (FILE *st, t_offset xpos, int origin)
return fseeko (st, (off_t)xpos, origin); return fseeko (st, (off_t)xpos, origin);
} }
static t_offset _sim_ftell (FILE *st) t_offset sim_ftell (FILE *st)
{ {
return (t_offset)(ftello (st)); return (t_offset)(ftello (st));
} }
@ -352,7 +352,7 @@ int sim_fseeko (FILE *st, t_offset xpos, int origin)
return fseek (st, (long) xpos, origin); return fseek (st, (long) xpos, origin);
} }
static t_offset _sim_ftell (FILE *st) t_offset sim_ftell (FILE *st)
{ {
return (t_offset)(ftell (st)); return (t_offset)(ftell (st));
} }

View file

@ -57,6 +57,7 @@ size_t sim_fread (void *bptr, size_t size, size_t count, FILE *fptr);
size_t sim_fwrite (void *bptr, size_t size, size_t count, FILE *fptr); size_t sim_fwrite (void *bptr, size_t size, size_t count, FILE *fptr);
uint32 sim_fsize (FILE *fptr); uint32 sim_fsize (FILE *fptr);
uint32 sim_fsize_name (char *fname); uint32 sim_fsize_name (char *fname);
t_offset sim_ftell (FILE *st);
t_offset sim_fsize_ex (FILE *fptr); t_offset sim_fsize_ex (FILE *fptr);
t_offset sim_fsize_name_ex (char *fname); t_offset sim_fsize_name_ex (char *fname);
void sim_buf_swap_data (void *bptr, size_t size, size_t count); void sim_buf_swap_data (void *bptr, size_t size, size_t count);