All LP and CD devices: Removed use of ftell for pipe compatibility

Merge changes from v3.12-2
This commit is contained in:
Bob Supnik 2022-06-16 16:13:46 -07:00 committed by Mark Pizzolato
parent 8d49d8c297
commit 28fd79ef06
16 changed files with 141 additions and 95 deletions

View file

@ -1,6 +1,6 @@
/* h316_lp.c: Honeywell 316/516 line printer /* h316_lp.c: Honeywell 316/516 line printer
Copyright (c) 1999-2015, Robert M. Supnik Copyright (c) 1999-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,7 +25,8 @@
lpt line printer lpt line printer
03-Jul-13 RLA compatibility changes for extended interrupts 09-Jun-21 RMS Added error detection, removed use of ftell
03-Jul-13 RLA Compatibility changes for extended interrupts
09-Jun-07 RMS Fixed lost last print line (Theo Engel) 09-Jun-07 RMS Fixed lost last print line (Theo Engel)
19-Jan-06 RMS Added UNIT_TEXT flag 19-Jan-06 RMS Added UNIT_TEXT flag
03-Apr-06 RMS Fixed bug in blanks backscanning (Theo Engel) 03-Apr-06 RMS Fixed bug in blanks backscanning (Theo Engel)
@ -321,7 +322,12 @@ if (lpt_svcst & LPT_SVCSH) { /* shuttling? */
} }
lpt_buf[i + 1] = 0; lpt_buf[i + 1] = 0;
fputs (lpt_buf, uptr->fileref); /* output buf */ fputs (lpt_buf, uptr->fileref); /* output buf */
uptr->pos = ftell (uptr->fileref); /* update pos */ if (ferror (uptr->fileref)) { /* error? */
perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lpt_buf); /* update pos */
for (i = 0; i < LPT_WIDTH; i++) /* clear buf */ for (i = 0; i < LPT_WIDTH; i++) /* clear buf */
lpt_buf[i] = ' '; lpt_buf[i] = ' ';
lpt_prdn = 1; /* print done */ lpt_prdn = 1; /* print done */
@ -330,7 +336,12 @@ if (lpt_svcst & LPT_SVCSH) { /* shuttling? */
if (lpt_svcst & LPT_SVCPA) { /* paper advance */ if (lpt_svcst & LPT_SVCPA) { /* paper advance */
SET_INT (INT_LPT); /* interrupt */ SET_INT (INT_LPT); /* interrupt */
fputs (lpt_cc[lpt_svcch & 03], uptr->fileref); /* output eol */ fputs (lpt_cc[lpt_svcch & 03], uptr->fileref); /* output eol */
uptr->pos = ftell (uptr->fileref); /* update pos */ if (ferror (uptr->fileref)) { /* error? */
perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lpt_cc[lpt_svcch & 03]); /* update pos */
} }
lpt_svcst = 0; lpt_svcst = 0;
return SCPE_OK; return SCPE_OK;

View file

@ -1,6 +1,6 @@
/* i1401_cd.c: IBM 1402 card reader/punch /* i1401_cd.c: IBM 1402 card reader/punch
Copyright (c) 1993-2017, Robert M. Supnik Copyright (c) 1993-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -35,6 +35,7 @@
Cards are represented as ASCII text streams terminated by newlines. Cards are represented as ASCII text streams terminated by newlines.
This allows cards to be created and edited as normal files. This allows cards to be created and edited as normal files.
09-Jun-21 RMS Removed use of ftell on output for pipe compatibility
09-Mar-17 RMS Protect character conversions from gargage files (COVERITY) 09-Mar-17 RMS Protect character conversions from gargage files (COVERITY)
05-May-16 RMS Fixed calling sequence inconsistency (Mark Pizzolato) 05-May-16 RMS Fixed calling sequence inconsistency (Mark Pizzolato)
28-Feb-15 RMS Added read from console 28-Feb-15 RMS Added read from console
@ -295,13 +296,13 @@ else uptr = &stack_unit[0]; /* then default */
if ((uptr->flags & UNIT_ATT) == 0) /* attached? */ if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return SCPE_OK; return SCPE_OK;
fputs (cdr_buf, uptr->fileref); /* write card */ fputs (cdr_buf, uptr->fileref); /* write card */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("Card stacker I/O error"); sim_perror ("Card stacker I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
if (iochk) if (iochk)
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (cdr_buf); /* update position */
return SCPE_OK; return SCPE_OK;
} }
@ -375,7 +376,6 @@ if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return SCPE_UNATT; return SCPE_UNATT;
fputs (cdp_buf, uptr->fileref); /* output card */ fputs (cdp_buf, uptr->fileref); /* output card */
fputc ('\n', uptr->fileref); /* plus new line */ fputc ('\n', uptr->fileref); /* plus new line */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("Card punch I/O error"); sim_perror ("Card punch I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
@ -383,6 +383,7 @@ if (ferror (uptr->fileref)) { /* error? */
return SCPE_IOERR; return SCPE_IOERR;
ind[IN_PNCH] = 1; ind[IN_PNCH] = 1;
} }
uptr->pos = uptr->pos + strlen (cdp_buf) + 1; /* update position */
return SCPE_OK; return SCPE_OK;
} }

View file

@ -1,6 +1,6 @@
/* i1401_lp.c: IBM 1403 line printer simulator /* i1401_lp.c: IBM 1403 line printer simulator
Copyright (c) 1993-2015, Robert M. Supnik Copyright (c) 1993-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt 1403 line printer lpt 1403 line printer
09-Jun-21 RMS Removed use of ftell for pipe compatibility
08-Mar-15 RMS Added print to console option 08-Mar-15 RMS Added print to console option
16-Apr-13 RMS Fixed printer chain selection 16-Apr-13 RMS Fixed printer chain selection
19-Jan-07 RMS Added UNIT_TEXT flag 19-Jan-07 RMS Added UNIT_TEXT flag
@ -245,19 +246,19 @@ if ((lpt_unit.flags & UNIT_ATT) != 0) { /* attached? */
ind[IN_LPT] = 1; ind[IN_LPT] = 1;
sim_perror ("Line printer I/O error"); sim_perror ("Line printer I/O error");
clearerr (lpt_unit.fileref); clearerr (lpt_unit.fileref);
if (iochk) if (iochk != 0)
return SCPE_IOERR; return SCPE_IOERR;
} }
lpt_unit.pos = ftell (lpt_unit.fileref); /* update position */ lpt_unit.pos = lpt_unit.pos + strlen (buf); /* update position */
return SCPE_OK; return SCPE_OK;
} }
if ((lpt_unit.flags & UNIT_CONS) != 0) { /* default to cons? */ if ((lpt_unit.flags & UNIT_CONS) != 0) { /* default to cons? */
if (buf[0] == '\n') { /* bare lf? */ if (buf[0] == '\n') { /* bare lf? */
inq_puts ("\r"); /* cvt to crlf */ inq_puts ("\r"); /* cvt to crlf */
lpt_unit.pos = lpt_unit.pos + 1; lpt_unit.pos = lpt_unit.pos + 1;
} }
inq_puts (buf); inq_puts (buf);
lpt_unit.pos = lpt_unit.pos + strlen (buf); lpt_unit.pos = lpt_unit.pos + strlen (buf); /* update position */
return SCPE_OK; return SCPE_OK;
} }
return SCPE_UNATT; return SCPE_UNATT;

View file

@ -1,6 +1,6 @@
/* i1620_cd.c: IBM 1622 card reader/punch /* i1620_cd.c: IBM 1622 card reader/punch
Copyright (c) 2002-2017, Robert M. Supnik Copyright (c) 2002-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -26,6 +26,7 @@
cdr 1622 card reader cdr 1622 card reader
cdp 1622 card punch cdp 1622 card punch
09-Jun-21 RMS Removed use of ftell on output for pipe compatibility
23-Jun-17 RMS Unattached error does not set RDCHK/WRCHK 23-Jun-17 RMS Unattached error does not set RDCHK/WRCHK
09-Mar-17 RMS Guardbanded translation table lookups (COVERITY) 09-Mar-17 RMS Guardbanded translation table lookups (COVERITY)
31-Jan-15 TFM Changes to translation tables (Tom McBride) 31-Jan-15 TFM Changes to translation tables (Tom McBride)
@ -528,13 +529,13 @@ cdp_buf[len] = '\n'; /* newline, null */
cdp_buf[len + 1] = 0; cdp_buf[len + 1] = 0;
fputs (cdp_buf, cdp_unit.fileref); /* write card */ fputs (cdp_buf, cdp_unit.fileref); /* write card */
cdp_unit.pos = ftell (cdp_unit.fileref); /* count char */
if (ferror (cdp_unit.fileref)) { /* error? */ if (ferror (cdp_unit.fileref)) { /* error? */
ind[IN_WRCHK] = 1; ind[IN_WRCHK] = 1;
sim_perror ("CDP I/O error"); sim_perror ("CDP I/O error");
clearerr (cdp_unit.fileref); clearerr (cdp_unit.fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
cdp_unit.pos = cdp_unit.pos + strlen (cdp_buf); /* update position */
return SCPE_OK; return SCPE_OK;
} }

View file

@ -1,6 +1,6 @@
/* i1620_lp.c: IBM 1443 line printer simulator /* i1620_lp.c: IBM 1443 line printer simulator
Copyright (c) 2002-2017, Robert M. Supnik Copyright (c) 2002-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt 1443 line printer lpt 1443 line printer
10-Jun-21 RMS Removed use of ftell for pipe compatibility
15-Jun-17 RMS Fixed K constants and print-no-spacing (Tom McBride) 15-Jun-17 RMS Fixed K constants and print-no-spacing (Tom McBride)
Added option to emulate form feed with newlines Added option to emulate form feed with newlines
31-Jan-15 TFM Fixed various problems ... see comments in code 31-Jan-15 TFM Fixed various problems ... see comments in code
@ -279,7 +280,7 @@ return sta;
t_stat lpt_print (uint32 flag) t_stat lpt_print (uint32 flag)
{ {
int32 i; int32 i, cc;
if ((lpt_unit.flags & UNIT_ATT) == 0) { /* not attached? */ if ((lpt_unit.flags & UNIT_ATT) == 0) { /* not attached? */
ind[IN_PRCHK] = 1; /* pri check */ ind[IN_PRCHK] = 1; /* pri check */
@ -292,9 +293,11 @@ while ((lpt_bptr > 0) && (lpt_buf[lpt_bptr - 1] == ' '))
lpt_buf[--lpt_bptr] = 0; /* trim buffer */ lpt_buf[--lpt_bptr] = 0; /* trim buffer */
if (lpt_bptr != 0) { /* any line? */ if (lpt_bptr != 0) { /* any line? */
fputs (lpt_buf, lpt_unit.fileref); /* print */ fputs (lpt_buf, lpt_unit.fileref); /* print */
if ((flag & 1) != 0) /* no space? */ cc = strlen (lpt_buf);
if ((flag & 1) != 0) { /* no space? */
fputc ('\r', lpt_unit.fileref); /* bare return */ fputc ('\r', lpt_unit.fileref); /* bare return */
lpt_unit.pos = ftell (lpt_unit.fileref); /* update pos */ cc++;
}
lpt_buf_init (); /* reinit buf */ lpt_buf_init (); /* reinit buf */
if (ferror (lpt_unit.fileref)) { /* error? */ if (ferror (lpt_unit.fileref)) { /* error? */
ind[IN_PRCHK] = 1; /* pri check */ ind[IN_PRCHK] = 1; /* pri check */
@ -302,6 +305,7 @@ if (lpt_bptr != 0) { /* any line? */
clearerr (lpt_unit.fileref); clearerr (lpt_unit.fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
lpt_unit.pos = lpt_unit.pos + (t_addr)cc; /* update pos */
} }
if ((flag & 1) == 0) /* spacing? */ if ((flag & 1) == 0) /* spacing? */
return lpt_spcop (lpt_savctrl); /* execute */ return lpt_spcop (lpt_savctrl); /* execute */
@ -336,17 +340,19 @@ return STOP_CCT; /* runaway channel */
t_stat lpt_space (int32 count, int32 sflag) t_stat lpt_space (int32 count, int32 sflag)
{ {
int32 i; int32 i, cc;
cct_ptr = (cct_ptr + count) % cct_lnt; /* adv cct, mod lnt */ cct_ptr = (cct_ptr + count) % cct_lnt; /* adv cct, mod lnt */
if (sflag && CHP (0, cct[cct_ptr]) && /* skip, top of form, */ if (sflag && CHP (0, cct[cct_ptr]) && /* skip, top of form, */
((lpt_unit.flags & UNIT_FF) != 0)) /* and use form feeds? */ ((lpt_unit.flags & UNIT_FF) != 0)) { /* and use form feeds? */
fputs ("\n\f", lpt_unit.fileref); /* nl, ff */ fputs ("\n\f", lpt_unit.fileref); /* nl, ff */
cc = 2;
}
else { else {
for (i = 0; i < count; i++) /* count lines */ for (i = 0; i < count; i++) /* count lines */
fputc ('\n', lpt_unit.fileref); fputc ('\n', lpt_unit.fileref);
cc = count;
} }
lpt_unit.pos = ftell (lpt_unit.fileref); /* update position */
ind[IN_PRCH9] = CHP (9, cct[cct_ptr]) != 0; /* set indicators */ ind[IN_PRCH9] = CHP (9, cct[cct_ptr]) != 0; /* set indicators */
ind[IN_PRCH12] = CHP (12, cct[cct_ptr]) != 0; ind[IN_PRCH12] = CHP (12, cct[cct_ptr]) != 0;
if (ferror (lpt_unit.fileref)) { /* error? */ if (ferror (lpt_unit.fileref)) { /* error? */
@ -355,6 +361,7 @@ if (ferror (lpt_unit.fileref)) { /* error? */
clearerr (lpt_unit.fileref); clearerr (lpt_unit.fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
lpt_unit.pos = lpt_unit.pos + (t_addr)cc; /* update position */
ind[IN_PRBSY] = 1; /* print busy */ ind[IN_PRBSY] = 1; /* print busy */
sim_activate (&lpt_unit, lpt_unit.wait); /* start timer */ sim_activate (&lpt_unit, lpt_unit.wait); /* start timer */
return SCPE_OK; return SCPE_OK;

View file

@ -1,6 +1,6 @@
/* i7094_cd.c: IBM 711/721 card reader/punch /* i7094_cd.c: IBM 711/721 card reader/punch
Copyright (c) 2003-2017, Robert M. Supnik Copyright (c) 2003-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -26,6 +26,7 @@
cdr 711 card reader cdr 711 card reader
cdp 721 card punch cdp 721 card punch
09-Jun-21 RMS Removed use of ftell on output for pipe compatibility
13-Mar-17 RMS Annotated fall through in switch 13-Mar-17 RMS Annotated fall through in switch
19-Mar-12 RMS Fixed declaration of sim_switches (Mark Pizzolato) 19-Mar-12 RMS Fixed declaration of sim_switches (Mark Pizzolato)
19-Jan-07 RMS Added UNIT_TEXT 19-Jan-07 RMS Added UNIT_TEXT
@ -448,12 +449,12 @@ for (i = ((2 * CD_CHRLNT) + 1); (i > 0) &&
cdp_cbuf[i++] = '\n'; /* append nl */ cdp_cbuf[i++] = '\n'; /* append nl */
cdp_cbuf[i++] = 0; /* append nul */ cdp_cbuf[i++] = 0; /* append nul */
fputs (cdp_cbuf, uptr->fileref); /* write card */ fputs (cdp_cbuf, uptr->fileref); /* write card */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("CDP I/O error"); sim_perror ("CDP I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (cdp_cbuf); /* update position */
cdp_sta = CDS_END; /* end state */ cdp_sta = CDS_END; /* end state */
sim_cancel (uptr); /* cancel current */ sim_cancel (uptr); /* cancel current */
sim_activate (uptr, cdp_tstop); /* long timer */ sim_activate (uptr, cdp_tstop); /* long timer */

View file

@ -1,6 +1,6 @@
/* i7094_lp.c: IBM 716 line printer simulator /* i7094_lp.c: IBM 716 line printer simulator
Copyright (c) 2003-2017, Robert M. Supnik Copyright (c) 2003-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt 716 line printer lpt 716 line printer
09-Jun-21 RMS Removed use of ftell for pipe compatibility
13-Mar-17 RMS Fixed GET_PCHAIN macro (COVERITY) 13-Mar-17 RMS Fixed GET_PCHAIN macro (COVERITY)
19-Jan-07 RMS Added UNIT_TEXT flag 19-Jan-07 RMS Added UNIT_TEXT flag
@ -331,12 +332,12 @@ lpt_cbuf[i] = 0; /* append nul */
if (uptr->flags & UNIT_ATT) { /* file? */ if (uptr->flags & UNIT_ATT) { /* file? */
fputs (lpt_cbuf, uptr->fileref); /* write line */ fputs (lpt_cbuf, uptr->fileref); /* write line */
fputc ('\n', uptr->fileref); /* append nl */ fputc ('\n', uptr->fileref); /* append nl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (lpt_cbuf) + 1; /* update pos, add nl */
} }
else if (uptr->flags & UNIT_CONS) { /* print to console? */ else if (uptr->flags & UNIT_CONS) { /* print to console? */
for (i = 0; lpt_cbuf[i] != 0; i++) for (i = 0; lpt_cbuf[i] != 0; i++)

View file

@ -1,6 +1,6 @@
/* id_lp.c: Interdata line printer /* id_lp.c: Interdata line printer
Copyright (c) 2001-2008, Robert M. Supnik Copyright (c) 2001-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt M46-206 line printer lpt M46-206 line printer
10-Jun-21 RMS Removed use of ftell for pipe compatibility
27-May-08 RMS Fixed bug in printing test (Davis Johnson) 27-May-08 RMS Fixed bug in printing test (Davis Johnson)
19-Jan-07 RMS Added UNIT_TEXT flag 19-Jan-07 RMS Added UNIT_TEXT flag
25-Apr-03 RMS Revised for extended file support 25-Apr-03 RMS Revised for extended file support
@ -72,8 +73,8 @@ t_stat lpt_svc (UNIT *uptr);
t_stat lpt_reset (DEVICE *dptr); t_stat lpt_reset (DEVICE *dptr);
t_stat lpt_attach (UNIT *uptr, CONST char *cptr); t_stat lpt_attach (UNIT *uptr, CONST char *cptr);
t_stat lpt_bufout (UNIT *uptr); t_stat lpt_bufout (UNIT *uptr);
t_stat lpt_vfu (UNIT *uptr, int32 ch); int32 lpt_vfu (UNIT *uptr, int32 ch);
t_stat lpt_spc (UNIT *uptr, int32 cnt); int32 lpt_spc (UNIT *uptr, int32 cnt);
/* LPT data structures /* LPT data structures
@ -158,8 +159,7 @@ return 0;
t_stat lpt_svc (UNIT *uptr) t_stat lpt_svc (UNIT *uptr)
{ {
int32 t; int32 t, cc;
t_stat r = SCPE_OK;
lpt_sta = 0; /* clear busy */ lpt_sta = 0; /* clear busy */
if (lpt_arm) /* armed? intr */ if (lpt_arm) /* armed? intr */
@ -172,22 +172,27 @@ if (lpt_spnd || ((t >= LF) && (t < CR))) { /* spc pend or spc op? *
if (lpt_bufout (uptr) != SCPE_OK) /* print */ if (lpt_bufout (uptr) != SCPE_OK) /* print */
return SCPE_IOERR; return SCPE_IOERR;
if ((t == 1) || (t == LF)) /* single space */ if ((t == 1) || (t == LF)) /* single space */
lpt_spc (uptr, 1); cc = lpt_spc (uptr, 1);
else if (t == VT) /* VT->VFU */ else if (t == VT) /* VT->VFU */
r = lpt_vfu (uptr, VT_VFU - 1); cc = lpt_vfu (uptr, VT_VFU - 1);
else if (t == 0xC) /* FF->VFU */ else if (t == 0xC) /* FF->VFU */
r = lpt_vfu (uptr, FF_VFU - 1); cc = lpt_vfu (uptr, FF_VFU - 1);
else if ((t >= SPC_BASE) && (t < VFU_BASE)) else if ((t >= SPC_BASE) && (t < VFU_BASE)) /* space */
lpt_spc (uptr, t - SPC_BASE); /* space */ cc = lpt_spc (uptr, t - SPC_BASE);
else if ((t >= VFU_BASE) && (t < VFU_BASE + VFU_WIDTH)) else if ((t >= VFU_BASE) && (t < VFU_BASE + VFU_WIDTH))
r = lpt_vfu (uptr, t - VFU_BASE); /* VFU */ cc = lpt_vfu (uptr, t - VFU_BASE); /* VFU */
else fputs ("\r", uptr->fileref); /* overprint */ else {
uptr->pos = ftell (uptr->fileref); /* update position */ fputs ("\r", uptr->fileref); /* overprint */
if (ferror (lpt_unit.fileref)) { cc = 1;
}
if (cc < 0) /* VFU runaway? */
return STOP_VFU;
if (ferror (lpt_unit.fileref)) { /* I/O error? */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + (t_addr)cc; /* update position */
} }
else if (t == CR) { /* CR? */ else if (t == CR) { /* CR? */
lpt_spnd = 1; /* set spc pend */ lpt_spnd = 1; /* set spc pend */
@ -199,7 +204,7 @@ else if (t >= 0x20) { /* printable? */
if (lpt_bptr < LPT_WIDTH) if (lpt_bptr < LPT_WIDTH)
lpxb[lpt_bptr++] = t; lpxb[lpt_bptr++] = t;
} }
return r; return SCPE_OK;
} }
/* Printing and spacing routines */ /* Printing and spacing routines */
@ -214,12 +219,12 @@ for (i = LPT_WIDTH - 1; (i >= 0) && (lpxb[i] == ' '); i--)
lpxb[i] = 0; /* backscan line */ lpxb[i] = 0; /* backscan line */
if (lpxb[0]) { /* any char left? */ if (lpxb[0]) { /* any char left? */
fputs (lpxb, uptr->fileref); /* write line */ fputs (lpxb, uptr->fileref); /* write line */
lpt_unit.pos = ftell (uptr->fileref); /* update position */ if (ferror (uptr->fileref)) { /* I/O error? */
if (ferror (uptr->fileref)) {
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
r = SCPE_IOERR; r = SCPE_IOERR;
} }
lpt_unit.pos = lpt_unit.pos + strlen (lpxb); /* update position */
} }
lpt_bptr = 0; /* reset buffer */ lpt_bptr = 0; /* reset buffer */
for (i = 0; i < LPT_WIDTH; i++) for (i = 0; i < LPT_WIDTH; i++)

View file

@ -1,6 +1,6 @@
/* nova_lp.c: NOVA line printer simulator /* nova_lp.c: NOVA line printer simulator
Copyright (c) 1993-2008, Robert M. Supnik Copyright (c) 1993-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt line printer lpt line printer
09-Jun-21 RMS Reverted use of ftell for pipe compatibility
04-Jul-07 BKR DEV_SET/CLR macros now used, 04-Jul-07 BKR DEV_SET/CLR macros now used,
<FF>, <CR>, <LF> output character delay now contingent upon non-zero TIME value, <FF>, <CR>, <LF> output character delay now contingent upon non-zero TIME value,
LPT can now be DISABLED LPT can now be DISABLED

View file

@ -1,6 +1,6 @@
/* pdp1_lp.c: PDP-1 line printer simulator /* pdp1_lp.c: PDP-1 line printer simulator
Copyright (c) 1993-2008, Robert M. Supnik Copyright (c) 1993-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt Type 62 line printer for the PDP-1 lpt Type 62 line printer for the PDP-1
09-Jun-21 RMS Removed use of ftell for pipe compatibility
19-Jan-07 RMS Added UNIT_TEXT flag 19-Jan-07 RMS Added UNIT_TEXT flag
21-Dec-06 RMS Added 16-channel SBS support 21-Dec-06 RMS Added 16-channel SBS support
07-Sep-03 RMS Changed ioc to ios 07-Sep-03 RMS Changed ioc to ios
@ -173,12 +174,12 @@ if (lpt_spc) { /* space? */
if ((uptr->flags & UNIT_ATT) == 0) /* attached? */ if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return IORETURN (lpt_stopioe, SCPE_UNATT); return IORETURN (lpt_stopioe, SCPE_UNATT);
fputs (lpt_cc[lpt_spc & 07], uptr->fileref); /* print cctl */ fputs (lpt_cc[lpt_spc & 07], uptr->fileref); /* print cctl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (lpt_cc[lpt_spc & 07]);
lpt_ovrpr = 0; /* dont overprint */ lpt_ovrpr = 0; /* dont overprint */
} }
else { else {
@ -188,12 +189,12 @@ else {
if (lpt_ovrpr) /* overprint? */ if (lpt_ovrpr) /* overprint? */
fputc ('\r', uptr->fileref); fputc ('\r', uptr->fileref);
fputs (lpt_buf, uptr->fileref); /* print buffer */ fputs (lpt_buf, uptr->fileref); /* print buffer */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* test error */ if (ferror (uptr->fileref)) { /* test error */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (lpt_buf); /* update position */
lpt_bptr = 0; lpt_bptr = 0;
for (i = 0; i <= LPT_BSIZE; i++) /* clear buffer */ for (i = 0; i <= LPT_BSIZE; i++) /* clear buffer */
lpt_buf[i] = 0; lpt_buf[i] = 0;

View file

@ -799,19 +799,18 @@ for (i = 0; i < cnt; i++) { /* print 'n' newlines; e
fputc ('\n', lp20_unit->fileref); fputc ('\n', lp20_unit->fileref);
if (dvuadv) { /* update DAVFU ptr */ if (dvuadv) { /* update DAVFU ptr */
dvptr = (dvptr + cnt) % dvlnt; dvptr = (dvptr + cnt) % dvlnt;
if (davfu[dvptr] & (1 << DV_TOF)) { /* at top of form? */ if (davfu[dvptr] & (1 << DV_TOF)) { /* at top of form? */
lppagc = (lppagc - 1) & PAGC_MASK; /* decr page cntr */ lppagc = (lppagc - 1) & PAGC_MASK; /* decr page cntr */
if (lppagc == 0) { if (lppagc == 0) {
lpcsa = lpcsa | CSA_PZRO; /* stop if zero */ lpcsa = lpcsa | CSA_PZRO; /* stop if zero */
stoppc = TRUE; stoppc = TRUE;
} }
} /* At TOF */ } /* At TOF */
} /* update pointer */ } /* update pointer */
} }
lp20_unit->pos = (t_addr)sim_ftell (lp20_unit->fileref); lp20_unit->pos = (t_addr)sim_ftell (lp20_unit->fileref);
if (stoppc) /* Crossed one or more TOFs? */ if (stoppc) /* crossed one or more TOFs? */
return FALSE; return FALSE;
return TRUE; return TRUE;
} }

View file

@ -1,6 +1,6 @@
/* pdp11_lp.c: PDP-11 line printer simulator /* pdp11_lp.c: PDP-11 line printer simulator
Copyright (c) 1993-2008, Robert M Supnik Copyright (c) 1993-2021, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt LP11 line printer lpt LP11 line printer
20-Mar-21 RMS Reverted use of ftell for pipe compatibility
19-Jan-07 RMS Added UNIT_TEXT flag 19-Jan-07 RMS Added UNIT_TEXT flag
07-Jul-05 RMS Removed extraneous externs 07-Jul-05 RMS Removed extraneous externs
19-May-03 RMS Revised for new conditional compilation scheme 19-May-03 RMS Revised for new conditional compilation scheme

View file

@ -1,6 +1,6 @@
/* pdp18b_lp.c: 18b PDP's line printer simulator /* pdp18b_lp.c: 18b PDP's line printer simulator
Copyright (c) 1993-2017, Robert M Supnik Copyright (c) 1993-2021, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -28,6 +28,7 @@
lp09 (PDP-9,15) LP09 line printer lp09 (PDP-9,15) LP09 line printer
lp15 (PDP-15) LP15 line printer lp15 (PDP-15) LP15 line printer
09-Jun-21 RMS Reverted use of ftell for pipe compatibility
13-Mar-17 RMS Annotated fall throughs in switch 13-Mar-17 RMS Annotated fall throughs in switch
10-Mar-16 RMS Added 3-cycle databreak set/show entry 10-Mar-16 RMS Added 3-cycle databreak set/show entry
07-Mar-16 RMS Revised for dynamically allocated memory 07-Mar-16 RMS Revised for dynamically allocated memory
@ -190,12 +191,12 @@ if (lp62_spc) { /* space? */
if ((uptr->flags & UNIT_ATT) == 0) /* attached? */ if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return IORETURN (lp62_stopioe, SCPE_UNATT); return IORETURN (lp62_stopioe, SCPE_UNATT);
fputs (lp62_cc[lp62_spc & 07], uptr->fileref); /* print cctl */ fputs (lp62_cc[lp62_spc & 07], uptr->fileref); /* print cctl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (lp62_cc[lp62_spc & 07]); /* update position */
lp62_ovrpr = 0; /* clear overprint */ lp62_ovrpr = 0; /* clear overprint */
} }
else { else {
@ -205,12 +206,13 @@ else {
if (lp62_ovrpr) /* overprint? */ if (lp62_ovrpr) /* overprint? */
fputc ('\r', uptr->fileref); fputc ('\r', uptr->fileref);
fputs (lp62_buf, uptr->fileref); /* print buffer */ fputs (lp62_buf, uptr->fileref); /* print buffer */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* test error */ if (ferror (uptr->fileref)) { /* test error */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (lp62_buf) + /* update position */
(lp62_ovrpr? 1: 0); /* including \r */
lp62_bp = 0; lp62_bp = 0;
for (i = 0; i <= LP62_BSIZE; i++) /* clear buffer */ for (i = 0; i <= LP62_BSIZE; i++) /* clear buffer */
lp62_buf[i] = 0; lp62_buf[i] = 0;
@ -439,23 +441,23 @@ if ((lp647_iot & 020) == 0) { /* print? */
for (i = 0; i < LP647_BSIZE; i++) /* clear buffer */ for (i = 0; i < LP647_BSIZE; i++) /* clear buffer */
lp647_buf[i] = 0; lp647_buf[i] = 0;
fputs (pbuf, uptr->fileref); /* print buffer */ fputs (pbuf, uptr->fileref); /* print buffer */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
lp647_bp = 0; lp647_bp = 0;
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (pbuf); /* update position */
lp647_bp = 0; /* clear buffer ptr */ lp647_bp = 0; /* clear buffer ptr */
} }
if (lp647_iot & 060) { /* space? */ if (lp647_iot & 060) { /* space? */
fputs (lp647_cc[lp647_iot & 07], uptr->fileref); /* write cctl */ fputs (lp647_cc[lp647_iot & 07], uptr->fileref); /* write cctl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (lp647_cc[lp647_iot & 07]);
} }
return SCPE_OK; return SCPE_OK;
} }
@ -838,7 +840,6 @@ for (more = 1; more != 0; ) { /* loop until ctrl */
lp15_buf[lp15_bp] = 0; /* append nul */ lp15_buf[lp15_bp] = 0; /* append nul */
fputs (lp15_buf, uptr->fileref); /* print line */ fputs (lp15_buf, uptr->fileref); /* print line */
fputs (ctrl[c[i] & 037], uptr->fileref); /* space */ fputs (ctrl[c[i] & 037], uptr->fileref); /* space */
uptr->pos = ftell (uptr->fileref);
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error"); sim_perror ("LPT I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
@ -846,6 +847,8 @@ for (more = 1; more != 0; ) { /* loop until ctrl */
lp15_updsta (STA_DON | STA_ALM); lp15_updsta (STA_DON | STA_ALM);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + strlen (lp15_buf) /* update position */
+ strlen (ctrl[c[i] & 037]); /* incl spacing */
lp15_bp = more = 0; lp15_bp = more = 0;
} }
else { else {

View file

@ -1,6 +1,6 @@
/* pdp8_lp.c: PDP-8 line printer simulator /* pdp8_lp.c: PDP-8 line printer simulator
Copyright (c) 1993-2016, Robert M Supnik Copyright (c) 1993-2021, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,7 +25,8 @@
lpt LP8E line printer lpt LP8E line printer
16-Dec-16 DJG Added IOT 6660 to allow WPS WS78 3.4 to print 20-Mar-21 RMS Reverted use of ftell for pipe compatibility
15-Dec-16 RMS Added LS8E decode (6660) for WPS8 (Dave Gesswein)
19-Jan-07 RMS Added UNIT_TEXT 19-Jan-07 RMS Added UNIT_TEXT
25-Apr-03 RMS Revised for extended file support 25-Apr-03 RMS Revised for extended file support
04-Oct-02 RMS Added DIB, enable/disable, device number support 04-Oct-02 RMS Added DIB, enable/disable, device number support

View file

@ -1,6 +1,6 @@
/* sds_lp.c: SDS 940 line printer simulator /* sds_lp.c: SDS 940 line printer simulator
Copyright (c) 2001-2008, Robert M. Supnik Copyright (c) 2001-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt line printer lpt line printer
10-Jun-21 RMS Removed use of ftell for pipe compatibility
24-Nov-08 RMS Fixed loss of carriage control position on space op 24-Nov-08 RMS Fixed loss of carriage control position on space op
19-Jan-07 RMS Added UNIT_TEXT flag 19-Jan-07 RMS Added UNIT_TEXT flag
25-Apr-03 RMS Revised for extended file support 25-Apr-03 RMS Revised for extended file support
@ -61,13 +62,13 @@ DSPT lpt_tplt[] = { /* template */
t_stat lpt_svc (UNIT *uptr); t_stat lpt_svc (UNIT *uptr);
t_stat lpt_reset (DEVICE *dptr); t_stat lpt_reset (DEVICE *dptr);
t_stat lpt_attach (UNIT *uptr, CONST char *cptr); t_stat lpt_attach (UNIT *uptr, CONST char *cptr);
t_stat lpt_crctl (UNIT *uptr, int32 ch); int32 lpt_crctl (UNIT *uptr, int32 ch);
t_stat lpt_space (UNIT *uptr, int32 cnt); int32 lpt_space (UNIT *uptr, int32 cnt);
t_stat lpt_status (UNIT *uptr); t_stat lpt_status (UNIT *uptr, int32 cnt);
t_stat lpt_bufout (UNIT *uptr); t_stat lpt_bufout (UNIT *uptr);
void lpt_end_op (int32 fl); void lpt_end_op (int32 fl);
t_stat lpt (uint32 fnc, uint32 inst, uint32 *dat); t_stat lpt (uint32 fnc, uint32 inst, uint32 *dat);
int8 sds_to_ascii(int8 c); int8 sds_to_ascii (int8 c);
/* LPT data structures /* LPT data structures
@ -181,7 +182,7 @@ switch (fnc) { /* case function */
break; break;
case IO_WRITE: /* write */ case IO_WRITE: /* write */
asc = sds_to_ascii(*dat); /* convert data */ asc = sds_to_ascii (*dat); /* convert data */
xfr_req = xfr_req & ~XFR_LPT; /* clr xfr flag */ xfr_req = xfr_req & ~XFR_LPT; /* clr xfr flag */
if (lpt_bptr < LPT_WIDTH) /* store data */ if (lpt_bptr < LPT_WIDTH) /* store data */
lpt_buf[lpt_bptr++] = asc; lpt_buf[lpt_bptr++] = asc;
@ -201,6 +202,7 @@ return SCPE_OK;
t_stat lpt_svc (UNIT *uptr) t_stat lpt_svc (UNIT *uptr)
{ {
t_stat r = SCPE_OK; t_stat r = SCPE_OK;
int32 cc = 0;
if (lpt_sta & SET_XFR) /* need lpt xfr? */ if (lpt_sta & SET_XFR) /* need lpt xfr? */
chan_set_ordy (lpt_dib.chan); chan_set_ordy (lpt_dib.chan);
@ -212,10 +214,14 @@ if (lpt_sta & SET_SPC) { /* spacing? */
if (uptr->flags & UNIT_ATT) { /* attached? */ if (uptr->flags & UNIT_ATT) { /* attached? */
int32 ln = LPT_GETLN (lpt_spc); /* get lines, ch */ int32 ln = LPT_GETLN (lpt_spc); /* get lines, ch */
if (lpt_spc & 0200) /* n lines? */ if (lpt_spc & 0200) /* n lines? */
lpt_space (uptr, ln); /* upspace */ cc = lpt_space (uptr, ln); /* upspace */
else lpt_crctl (uptr, ln); /* carriage ctl */ else {
cc = lpt_crctl (uptr, ln); /* carriage ctl */
if (cc < 0) /* tape error? */
return STOP_CCT;
}
} }
r = lpt_status (uptr); /* update status */ r = lpt_status (uptr, cc); /* update status */
} }
lpt_sta = 0; /* clear state */ lpt_sta = 0; /* clear state */
return r; return r;
@ -226,28 +232,30 @@ return r;
t_stat lpt_bufout (UNIT *uptr) t_stat lpt_bufout (UNIT *uptr)
{ {
int32 i; int32 i;
int32 cc = 0;
if ((uptr->flags & UNIT_ATT) && lpt_bptr) { /* attached? */ if ((uptr->flags & UNIT_ATT) && lpt_bptr) { /* attached? */
for (i = LPT_WIDTH - 1; (i >= 0) && (lpt_buf[i] == ' '); i--) for (i = LPT_WIDTH - 1; (i >= 0) && (lpt_buf[i] == ' '); i--)
lpt_buf[i] = 0; /* trim line */ lpt_buf[i] = 0; /* trim line */
fputs (lpt_buf, uptr->fileref); /* write line */ fputs (lpt_buf, uptr->fileref); /* write line */
cc = strlen (lpt_buf);
lpt_bptr = 0; lpt_bptr = 0;
} }
return lpt_status (uptr); /* return status */ return lpt_status (uptr, cc); /* return status */
} }
/* Status update after I/O */ /* Status update after I/O */
t_stat lpt_status (UNIT *uptr) t_stat lpt_status (UNIT *uptr, int32 cnt)
{ {
if (uptr->flags & UNIT_ATT) { /* attached? */ if (uptr->flags & UNIT_ATT) { /* attached? */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* I/O error? */ if (ferror (uptr->fileref)) { /* I/O error? */
lpt_end_op (CHF_EOR | CHF_ERR); /* set err, disc */ lpt_end_op (CHF_EOR | CHF_ERR); /* set err, disc */
sim_perror ("LPT I/O error"); /* print msg */ sim_perror ("LPT I/O error"); /* print msg */
clearerr (uptr->fileref); clearerr (uptr->fileref);
return SCPE_IOERR; /* ret error */ return SCPE_IOERR; /* ret error */
} }
uptr->pos = uptr->pos + (t_addr)cnt; /* udpate position */
} }
else { else {
lpt_end_op (CHF_EOR | CHF_ERR); /* set err, disc */ lpt_end_op (CHF_EOR | CHF_ERR); /* set err, disc */
@ -273,40 +281,40 @@ return;
/* Carriage control */ /* Carriage control */
t_stat lpt_crctl (UNIT *uptr, int32 ch) int32 lpt_crctl (UNIT *uptr, int32 ch)
{ {
int32 i, j; int32 i, j;
if ((ch == 1) && CHP (ch, lpt_cct[0])) { /* top of form? */ if ((ch == 1) && CHP (ch, lpt_cct[0])) { /* top of form? */
fputs ("\f\n", uptr->fileref); /* ff + nl */ fputs ("\f\n", uptr->fileref); /* ff + nl */
lpt_ccp = 0; /* top of page */ lpt_ccp = 0; /* top of page */
return SCPE_OK; return 2;
} }
for (i = 1; i < lpt_ccl + 1; i++) { /* sweep thru cct */ for (i = 1; i < lpt_ccl + 1; i++) { /* sweep thru cct */
lpt_ccp = (lpt_ccp + 1) % lpt_ccl; /* adv pointer */ lpt_ccp = (lpt_ccp + 1) % lpt_ccl; /* adv pointer */
if (CHP (ch, lpt_cct[lpt_ccp])) { /* chan punched? */ if (CHP (ch, lpt_cct[lpt_ccp])) { /* chan punched? */
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
fputc ('\n', uptr->fileref); fputc ('\n', uptr->fileref);
return SCPE_OK; return i;
} }
} }
return STOP_CCT; /* runaway channel */ return -1; /* runaway channel */
} }
/* Spacing */ /* Spacing */
t_stat lpt_space (UNIT *uptr, int32 cnt) int32 lpt_space (UNIT *uptr, int32 cnt)
{ {
int32 i; int32 i;
if (cnt == 0) if (cnt == 0) { /* overprint */
fputc ('\r', uptr->fileref); fputc ('\r', uptr->fileref);
else { return 1;
for (i = 0; i < cnt; i++) }
fputc ('\n', uptr->fileref); for (i = 0; i < cnt; i++) /* 'cnt' newlines */
lpt_ccp = (lpt_ccp + cnt) % lpt_ccl; fputc ('\n', uptr->fileref);
} lpt_ccp = (lpt_ccp + cnt) % lpt_ccl; /* advance CCT */
return SCPE_OK; return cnt;
} }
/* Reset routine */ /* Reset routine */

View file

@ -1,6 +1,6 @@
/* sigma_lp.c: Sigma 7440/7450 line printer /* sigma_lp.c: Sigma 7440/7450 line printer
Copyright (c) 2007-2017, Robert M. Supnik Copyright (c) 2007-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lp 7440/7445 or 7450 line printer lp 7440/7445 or 7450 line printer
10-Jun-2021 RMS Removed use of ftell for pipe compatibility
09-Mar-2017 RMS Fixed unclosed file returns in CCT load (COVERITY) 09-Mar-2017 RMS Fixed unclosed file returns in CCT load (COVERITY)
*/ */
@ -300,7 +301,7 @@ switch (lp_cmd) { /* case on state */
return SCPE_OK; return SCPE_OK;
} }
/* Format routine */ /* Format routine - uses skip or space */
uint32 lp_fmt (UNIT *uptr) uint32 lp_fmt (UNIT *uptr)
{ {
@ -327,7 +328,7 @@ else if ((c & ~CCH_MASK) == FMT_SKP) /* skip? */
return 0; return 0;
} }
/* Skip to channel */ /* Skip to channel - uses space */
uint32 lp_skip (UNIT *uptr, uint32 ch) uint32 lp_skip (UNIT *uptr, uint32 ch)
{ {
@ -345,22 +346,25 @@ return lp_space (uptr, lp_cctl, TRUE); /* space max */
uint32 lp_space (UNIT *uptr, uint32 cnt, t_bool skp) uint32 lp_space (UNIT *uptr, uint32 cnt, t_bool skp)
{ {
uint32 i; uint32 i, cc;
lp_cctp = (lp_cctp + cnt) % lp_cctl; /* adv cct, mod lnt */ lp_cctp = (lp_cctp + cnt) % lp_cctl; /* adv cct, mod lnt */
if (skp && CHP (CH_TOF, lp_cct[lp_cctp])) /* skip, TOF? */ if (skp && CHP (CH_TOF, lp_cct[lp_cctp])) { /* skip, TOF? */
fputs ("\f", uptr->fileref); /* ff */ fputc ('\f', uptr->fileref); /* ff */
cc = 1;
}
else { /* space */ else { /* space */
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
fputc ('\n', uptr->fileref); fputc ('\n', uptr->fileref);
cc = cnt;
} }
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
perror ("Line printer I/O error"); perror ("Line printer I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
chan_set_chf (lp_dib.dva, CHF_XMDE); chan_set_chf (lp_dib.dva, CHF_XMDE);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + cc; /* update position */
return 0; return 0;
} }
@ -386,16 +390,16 @@ for (bp = 0, st = 0; (bp < max) && !st; bp++) { /* fill buffer */
if ((lp_model == LP_7440) || lp_pass) { /* ready to print? */ if ((lp_model == LP_7440) || lp_pass) { /* ready to print? */
lp_pass = 0; lp_pass = 0;
for (i = BUF_LNT4; (i > 0) && (lp_buf[i - 1] == ' '); i--) ; /* trim */ for (i = BUF_LNT4; (i > 0) && (lp_buf[i - 1] == ' '); i--) ; /* trim */
if (i) /* write line */ if (i != 0) /* write line */
sim_fwrite (lp_buf, 1, i, uptr->fileref); sim_fwrite (lp_buf, 1, i, uptr->fileref);
fputc (lp_inh? '\r': '\n', uptr->fileref); /* cr or nl */ fputc (lp_inh? '\r': '\n', uptr->fileref); /* cr or nl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */ if (ferror (uptr->fileref)) { /* error? */
perror ("Line printer I/O error"); perror ("Line printer I/O error");
clearerr (uptr->fileref); clearerr (uptr->fileref);
chan_set_chf (lp_dib.dva, CHF_XMDE); chan_set_chf (lp_dib.dva, CHF_XMDE);
return SCPE_IOERR; return SCPE_IOERR;
} }
uptr->pos = uptr->pos + i + 1; /* update position */
if ((lp_model == LP_7440) && /* 7440? */ if ((lp_model == LP_7440) && /* 7440? */
((bp != BUF_LNT4) || (st != CHS_ZBC)) && /* check lnt err */ ((bp != BUF_LNT4) || (st != CHS_ZBC)) && /* check lnt err */
chan_set_chf (lp_dib.dva, CHF_LNTE)) chan_set_chf (lp_dib.dva, CHF_LNTE))