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
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
copy of this software and associated documentation files (the "Software"),
@ -25,7 +25,8 @@
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)
19-Jan-06 RMS Added UNIT_TEXT flag
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;
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 */
lpt_buf[i] = ' ';
lpt_prdn = 1; /* print done */
@ -330,7 +336,12 @@ if (lpt_svcst & LPT_SVCSH) { /* shuttling? */
if (lpt_svcst & LPT_SVCPA) { /* paper advance */
SET_INT (INT_LPT); /* interrupt */
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;
return SCPE_OK;

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -35,6 +35,7 @@
Cards are represented as ASCII text streams terminated by newlines.
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)
05-May-16 RMS Fixed calling sequence inconsistency (Mark Pizzolato)
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? */
return SCPE_OK;
fputs (cdr_buf, uptr->fileref); /* write card */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("Card stacker I/O error");
clearerr (uptr->fileref);
if (iochk)
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (cdr_buf); /* update position */
return SCPE_OK;
}
@ -375,7 +376,6 @@ if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return SCPE_UNATT;
fputs (cdp_buf, uptr->fileref); /* output card */
fputc ('\n', uptr->fileref); /* plus new line */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("Card punch I/O error");
clearerr (uptr->fileref);
@ -383,6 +383,7 @@ if (ferror (uptr->fileref)) { /* error? */
return SCPE_IOERR;
ind[IN_PNCH] = 1;
}
uptr->pos = uptr->pos + strlen (cdp_buf) + 1; /* update position */
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt 1403 line printer
09-Jun-21 RMS Removed use of ftell for pipe compatibility
08-Mar-15 RMS Added print to console option
16-Apr-13 RMS Fixed printer chain selection
19-Jan-07 RMS Added UNIT_TEXT flag
@ -245,10 +246,10 @@ if ((lpt_unit.flags & UNIT_ATT) != 0) { /* attached? */
ind[IN_LPT] = 1;
sim_perror ("Line printer I/O error");
clearerr (lpt_unit.fileref);
if (iochk)
if (iochk != 0)
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;
}
if ((lpt_unit.flags & UNIT_CONS) != 0) { /* default to cons? */
@ -257,7 +258,7 @@ if ((lpt_unit.flags & UNIT_CONS) != 0) { /* default to cons? */
lpt_unit.pos = lpt_unit.pos + 1;
}
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_UNATT;

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -26,6 +26,7 @@
cdr 1622 card reader
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
09-Mar-17 RMS Guardbanded translation table lookups (COVERITY)
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;
fputs (cdp_buf, cdp_unit.fileref); /* write card */
cdp_unit.pos = ftell (cdp_unit.fileref); /* count char */
if (ferror (cdp_unit.fileref)) { /* error? */
ind[IN_WRCHK] = 1;
sim_perror ("CDP I/O error");
clearerr (cdp_unit.fileref);
return SCPE_IOERR;
}
cdp_unit.pos = cdp_unit.pos + strlen (cdp_buf); /* update position */
return SCPE_OK;
}

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
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)
Added option to emulate form feed with newlines
31-Jan-15 TFM Fixed various problems ... see comments in code
@ -279,7 +280,7 @@ return sta;
t_stat lpt_print (uint32 flag)
{
int32 i;
int32 i, cc;
if ((lpt_unit.flags & UNIT_ATT) == 0) { /* not attached? */
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 */
if (lpt_bptr != 0) { /* any line? */
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 */
lpt_unit.pos = ftell (lpt_unit.fileref); /* update pos */
cc++;
}
lpt_buf_init (); /* reinit buf */
if (ferror (lpt_unit.fileref)) { /* error? */
ind[IN_PRCHK] = 1; /* pri check */
@ -302,6 +305,7 @@ if (lpt_bptr != 0) { /* any line? */
clearerr (lpt_unit.fileref);
return SCPE_IOERR;
}
lpt_unit.pos = lpt_unit.pos + (t_addr)cc; /* update pos */
}
if ((flag & 1) == 0) /* spacing? */
return lpt_spcop (lpt_savctrl); /* execute */
@ -336,17 +340,19 @@ return STOP_CCT; /* runaway channel */
t_stat lpt_space (int32 count, int32 sflag)
{
int32 i;
int32 i, cc;
cct_ptr = (cct_ptr + count) % cct_lnt; /* adv cct, mod lnt */
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 */
cc = 2;
}
else {
for (i = 0; i < count; i++) /* count lines */
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_PRCH12] = CHP (12, cct[cct_ptr]) != 0;
if (ferror (lpt_unit.fileref)) { /* error? */
@ -355,6 +361,7 @@ if (ferror (lpt_unit.fileref)) { /* error? */
clearerr (lpt_unit.fileref);
return SCPE_IOERR;
}
lpt_unit.pos = lpt_unit.pos + (t_addr)cc; /* update position */
ind[IN_PRBSY] = 1; /* print busy */
sim_activate (&lpt_unit, lpt_unit.wait); /* start timer */
return SCPE_OK;

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -26,6 +26,7 @@
cdr 711 card reader
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
19-Mar-12 RMS Fixed declaration of sim_switches (Mark Pizzolato)
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++] = 0; /* append nul */
fputs (cdp_cbuf, uptr->fileref); /* write card */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("CDP I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (cdp_cbuf); /* update position */
cdp_sta = CDS_END; /* end state */
sim_cancel (uptr); /* cancel current */
sim_activate (uptr, cdp_tstop); /* long timer */

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt 716 line printer
09-Jun-21 RMS Removed use of ftell for pipe compatibility
13-Mar-17 RMS Fixed GET_PCHAIN macro (COVERITY)
19-Jan-07 RMS Added UNIT_TEXT flag
@ -331,12 +332,12 @@ lpt_cbuf[i] = 0; /* append nul */
if (uptr->flags & UNIT_ATT) { /* file? */
fputs (lpt_cbuf, uptr->fileref); /* write line */
fputc ('\n', uptr->fileref); /* append nl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lpt_cbuf) + 1; /* update pos, add nl */
}
else if (uptr->flags & UNIT_CONS) { /* print to console? */
for (i = 0; lpt_cbuf[i] != 0; i++)

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
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)
19-Jan-07 RMS Added UNIT_TEXT flag
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_attach (UNIT *uptr, CONST char *cptr);
t_stat lpt_bufout (UNIT *uptr);
t_stat lpt_vfu (UNIT *uptr, int32 ch);
t_stat lpt_spc (UNIT *uptr, int32 cnt);
int32 lpt_vfu (UNIT *uptr, int32 ch);
int32 lpt_spc (UNIT *uptr, int32 cnt);
/* LPT data structures
@ -158,8 +159,7 @@ return 0;
t_stat lpt_svc (UNIT *uptr)
{
int32 t;
t_stat r = SCPE_OK;
int32 t, cc;
lpt_sta = 0; /* clear busy */
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 */
return SCPE_IOERR;
if ((t == 1) || (t == LF)) /* single space */
lpt_spc (uptr, 1);
cc = lpt_spc (uptr, 1);
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 */
r = lpt_vfu (uptr, FF_VFU - 1);
else if ((t >= SPC_BASE) && (t < VFU_BASE))
lpt_spc (uptr, t - SPC_BASE); /* space */
cc = lpt_vfu (uptr, FF_VFU - 1);
else if ((t >= SPC_BASE) && (t < VFU_BASE)) /* space */
cc = lpt_spc (uptr, t - SPC_BASE);
else if ((t >= VFU_BASE) && (t < VFU_BASE + VFU_WIDTH))
r = lpt_vfu (uptr, t - VFU_BASE); /* VFU */
else fputs ("\r", uptr->fileref); /* overprint */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (lpt_unit.fileref)) {
cc = lpt_vfu (uptr, t - VFU_BASE); /* VFU */
else {
fputs ("\r", uptr->fileref); /* overprint */
cc = 1;
}
if (cc < 0) /* VFU runaway? */
return STOP_VFU;
if (ferror (lpt_unit.fileref)) { /* I/O error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + (t_addr)cc; /* update position */
}
else if (t == CR) { /* CR? */
lpt_spnd = 1; /* set spc pend */
@ -199,7 +204,7 @@ else if (t >= 0x20) { /* printable? */
if (lpt_bptr < LPT_WIDTH)
lpxb[lpt_bptr++] = t;
}
return r;
return SCPE_OK;
}
/* Printing and spacing routines */
@ -214,12 +219,12 @@ for (i = LPT_WIDTH - 1; (i >= 0) && (lpxb[i] == ' '); i--)
lpxb[i] = 0; /* backscan line */
if (lpxb[0]) { /* any char left? */
fputs (lpxb, uptr->fileref); /* write line */
lpt_unit.pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) {
if (ferror (uptr->fileref)) { /* I/O error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
r = SCPE_IOERR;
}
lpt_unit.pos = lpt_unit.pos + strlen (lpxb); /* update position */
}
lpt_bptr = 0; /* reset buffer */
for (i = 0; i < LPT_WIDTH; i++)

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt line printer
09-Jun-21 RMS Reverted use of ftell for pipe compatibility
04-Jul-07 BKR DEV_SET/CLR macros now used,
<FF>, <CR>, <LF> output character delay now contingent upon non-zero TIME value,
LPT can now be DISABLED

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
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
21-Dec-06 RMS Added 16-channel SBS support
07-Sep-03 RMS Changed ioc to ios
@ -173,12 +174,12 @@ if (lpt_spc) { /* space? */
if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return IORETURN (lpt_stopioe, SCPE_UNATT);
fputs (lpt_cc[lpt_spc & 07], uptr->fileref); /* print cctl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lpt_cc[lpt_spc & 07]);
lpt_ovrpr = 0; /* dont overprint */
}
else {
@ -188,12 +189,12 @@ else {
if (lpt_ovrpr) /* overprint? */
fputc ('\r', uptr->fileref);
fputs (lpt_buf, uptr->fileref); /* print buffer */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* test error */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lpt_buf); /* update position */
lpt_bptr = 0;
for (i = 0; i <= LPT_BSIZE; i++) /* clear buffer */
lpt_buf[i] = 0;

View file

@ -809,9 +809,8 @@ for (i = 0; i < cnt; i++) { /* print 'n' newlines; e
} /* update pointer */
}
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 TRUE;
}

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
lpt LP11 line printer
20-Mar-21 RMS Reverted use of ftell for pipe compatibility
19-Jan-07 RMS Added UNIT_TEXT flag
07-Jul-05 RMS Removed extraneous externs
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
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
copy of this software and associated documentation files (the "Software"),
@ -28,6 +28,7 @@
lp09 (PDP-9,15) LP09 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
10-Mar-16 RMS Added 3-cycle databreak set/show entry
07-Mar-16 RMS Revised for dynamically allocated memory
@ -190,12 +191,12 @@ if (lp62_spc) { /* space? */
if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return IORETURN (lp62_stopioe, SCPE_UNATT);
fputs (lp62_cc[lp62_spc & 07], uptr->fileref); /* print cctl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lp62_cc[lp62_spc & 07]); /* update position */
lp62_ovrpr = 0; /* clear overprint */
}
else {
@ -205,12 +206,13 @@ else {
if (lp62_ovrpr) /* overprint? */
fputc ('\r', uptr->fileref);
fputs (lp62_buf, uptr->fileref); /* print buffer */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* test error */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lp62_buf) + /* update position */
(lp62_ovrpr? 1: 0); /* including \r */
lp62_bp = 0;
for (i = 0; i <= LP62_BSIZE; i++) /* clear buffer */
lp62_buf[i] = 0;
@ -439,23 +441,23 @@ if ((lp647_iot & 020) == 0) { /* print? */
for (i = 0; i < LP647_BSIZE; i++) /* clear buffer */
lp647_buf[i] = 0;
fputs (pbuf, uptr->fileref); /* print buffer */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
lp647_bp = 0;
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (pbuf); /* update position */
lp647_bp = 0; /* clear buffer ptr */
}
if (lp647_iot & 060) { /* space? */
fputs (lp647_cc[lp647_iot & 07], uptr->fileref); /* write cctl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lp647_cc[lp647_iot & 07]);
}
return SCPE_OK;
}
@ -838,7 +840,6 @@ for (more = 1; more != 0; ) { /* loop until ctrl */
lp15_buf[lp15_bp] = 0; /* append nul */
fputs (lp15_buf, uptr->fileref); /* print line */
fputs (ctrl[c[i] & 037], uptr->fileref); /* space */
uptr->pos = ftell (uptr->fileref);
if (ferror (uptr->fileref)) { /* error? */
sim_perror ("LPT I/O error");
clearerr (uptr->fileref);
@ -846,6 +847,8 @@ for (more = 1; more != 0; ) { /* loop until ctrl */
lp15_updsta (STA_DON | STA_ALM);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (lp15_buf) /* update position */
+ strlen (ctrl[c[i] & 037]); /* incl spacing */
lp15_bp = more = 0;
}
else {

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,7 +25,8 @@
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
25-Apr-03 RMS Revised for extended file 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
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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
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
19-Jan-07 RMS Added UNIT_TEXT flag
25-Apr-03 RMS Revised for extended file support
@ -61,9 +62,9 @@ DSPT lpt_tplt[] = { /* template */
t_stat lpt_svc (UNIT *uptr);
t_stat lpt_reset (DEVICE *dptr);
t_stat lpt_attach (UNIT *uptr, CONST char *cptr);
t_stat lpt_crctl (UNIT *uptr, int32 ch);
t_stat lpt_space (UNIT *uptr, int32 cnt);
t_stat lpt_status (UNIT *uptr);
int32 lpt_crctl (UNIT *uptr, int32 ch);
int32 lpt_space (UNIT *uptr, int32 cnt);
t_stat lpt_status (UNIT *uptr, int32 cnt);
t_stat lpt_bufout (UNIT *uptr);
void lpt_end_op (int32 fl);
t_stat lpt (uint32 fnc, uint32 inst, uint32 *dat);
@ -201,6 +202,7 @@ return SCPE_OK;
t_stat lpt_svc (UNIT *uptr)
{
t_stat r = SCPE_OK;
int32 cc = 0;
if (lpt_sta & SET_XFR) /* need lpt xfr? */
chan_set_ordy (lpt_dib.chan);
@ -212,10 +214,14 @@ if (lpt_sta & SET_SPC) { /* spacing? */
if (uptr->flags & UNIT_ATT) { /* attached? */
int32 ln = LPT_GETLN (lpt_spc); /* get lines, ch */
if (lpt_spc & 0200) /* n lines? */
lpt_space (uptr, ln); /* upspace */
else lpt_crctl (uptr, ln); /* carriage ctl */
cc = lpt_space (uptr, ln); /* upspace */
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 */
return r;
@ -226,28 +232,30 @@ return r;
t_stat lpt_bufout (UNIT *uptr)
{
int32 i;
int32 cc = 0;
if ((uptr->flags & UNIT_ATT) && lpt_bptr) { /* attached? */
for (i = LPT_WIDTH - 1; (i >= 0) && (lpt_buf[i] == ' '); i--)
lpt_buf[i] = 0; /* trim line */
fputs (lpt_buf, uptr->fileref); /* write line */
cc = strlen (lpt_buf);
lpt_bptr = 0;
}
return lpt_status (uptr); /* return status */
return lpt_status (uptr, cc); /* return status */
}
/* 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? */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* I/O error? */
lpt_end_op (CHF_EOR | CHF_ERR); /* set err, disc */
sim_perror ("LPT I/O error"); /* print msg */
clearerr (uptr->fileref);
return SCPE_IOERR; /* ret error */
}
uptr->pos = uptr->pos + (t_addr)cnt; /* udpate position */
}
else {
lpt_end_op (CHF_EOR | CHF_ERR); /* set err, disc */
@ -273,40 +281,40 @@ return;
/* Carriage control */
t_stat lpt_crctl (UNIT *uptr, int32 ch)
int32 lpt_crctl (UNIT *uptr, int32 ch)
{
int32 i, j;
if ((ch == 1) && CHP (ch, lpt_cct[0])) { /* top of form? */
fputs ("\f\n", uptr->fileref); /* ff + nl */
lpt_ccp = 0; /* top of page */
return SCPE_OK;
return 2;
}
for (i = 1; i < lpt_ccl + 1; i++) { /* sweep thru cct */
lpt_ccp = (lpt_ccp + 1) % lpt_ccl; /* adv pointer */
if (CHP (ch, lpt_cct[lpt_ccp])) { /* chan punched? */
for (j = 0; j < i; j++)
fputc ('\n', uptr->fileref);
return SCPE_OK;
return i;
}
}
return STOP_CCT; /* runaway channel */
return -1; /* runaway channel */
}
/* Spacing */
t_stat lpt_space (UNIT *uptr, int32 cnt)
int32 lpt_space (UNIT *uptr, int32 cnt)
{
int32 i;
if (cnt == 0)
if (cnt == 0) { /* overprint */
fputc ('\r', uptr->fileref);
else {
for (i = 0; i < cnt; i++)
fputc ('\n', uptr->fileref);
lpt_ccp = (lpt_ccp + cnt) % lpt_ccl;
return 1;
}
return SCPE_OK;
for (i = 0; i < cnt; i++) /* 'cnt' newlines */
fputc ('\n', uptr->fileref);
lpt_ccp = (lpt_ccp + cnt) % lpt_ccl; /* advance CCT */
return cnt;
}
/* Reset routine */

View file

@ -1,6 +1,6 @@
/* 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
copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
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)
*/
@ -300,7 +301,7 @@ switch (lp_cmd) { /* case on state */
return SCPE_OK;
}
/* Format routine */
/* Format routine - uses skip or space */
uint32 lp_fmt (UNIT *uptr)
{
@ -327,7 +328,7 @@ else if ((c & ~CCH_MASK) == FMT_SKP) /* skip? */
return 0;
}
/* Skip to channel */
/* Skip to channel - uses space */
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 i;
uint32 i, cc;
lp_cctp = (lp_cctp + cnt) % lp_cctl; /* adv cct, mod lnt */
if (skp && CHP (CH_TOF, lp_cct[lp_cctp])) /* skip, TOF? */
fputs ("\f", uptr->fileref); /* ff */
if (skp && CHP (CH_TOF, lp_cct[lp_cctp])) { /* skip, TOF? */
fputc ('\f', uptr->fileref); /* ff */
cc = 1;
}
else { /* space */
for (i = 0; i < cnt; i++)
fputc ('\n', uptr->fileref);
cc = cnt;
}
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
perror ("Line printer I/O error");
clearerr (uptr->fileref);
chan_set_chf (lp_dib.dva, CHF_XMDE);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + cc; /* update position */
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? */
lp_pass = 0;
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);
fputc (lp_inh? '\r': '\n', uptr->fileref); /* cr or nl */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
perror ("Line printer I/O error");
clearerr (uptr->fileref);
chan_set_chf (lp_dib.dva, CHF_XMDE);
return SCPE_IOERR;
}
uptr->pos = uptr->pos + i + 1; /* update position */
if ((lp_model == LP_7440) && /* 7440? */
((bp != BUF_LNT4) || (st != CHS_ZBC)) && /* check lnt err */
chan_set_chf (lp_dib.dva, CHF_LNTE))