🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #41203

Re: Windows 16/32 printer code for slrn

#41203
From: root
Date: Thu, 28 May 1998 00:00
72 lines
2917 bytes
On 28 May 1998 06:05:11 GMT, John E. Davis <davis@space.mit.edu> wrote:
>On 27 May 1998 23:46:58 GMT, root <vtailor@gte.net>
>wrote:
>>BTW, does anyone know where in the slrn code the information about
>>article numbers > 32KB (for integer variables) is stored?
>
>Nowhere. I wrote it with the assumption that sizeof(int) >= 4, and on
>such a system, ints can can be larger than 2 billion.
>
Well, sizeof(int) == 2 on 16-bit systems, therefore the problem with
article numbers that occurs in a number of news readers.  Have you
checked whether your network considers the file "prn" to be the
network printer?

========================================================================
Corrected and tested 16-bit printer code for slrn:

#ifdef USE_WIN16_PRINT_CODE /*{{{*/
  /* stdio fopen will work, but printer errors with stdio calls */
  /* cause the system to crash.  _lopen, _hwrite, and _lclose do */
  /* not cause system crashes. Note that this works with Dos- */
  /* compatible printers, such as pin printers, and most, but */
  /* not all inkjets (IBM Lexmark has problems with file I/O). */
  /* Using "prn" as the printer forces the system to select the */
  /* currently-installed system printer. The 16-bit Windows family */
  /* of _lopen calls is considered obsolete, but still supported, */
  /* in Windows 95/98 and Windows NT. */

int win16_write_to_printer (Slrn_Print_Type *p, char *buf, unsigned int len)
{
  if ((p == NULL) || (p->h == NULL) || (p->error_status))
	return -1;

  if (len != _hwrite(p->h, buf, (long)len))
	{
	 p->error_status = 1;
	 slrn_error ("Error writing to print process");
	 return -1;
	};
  return 0;
}

int win16_close_printer (Slrn_Print_Type *p)
{
 int nRval;
  nRval = _lclose(p->h);
  slrn_free ((char *) p);
  return nRval;
}

Slrn_Print_Type *win16_open_printer ( )
{
  Slrn_Print_Type *p;

  if (NULL == (p = (Slrn_Print_Type *)SLmalloc(sizeof (Slrn_Print_Type))))
	return NULL;
  memset((char *)p, 0, sizeof(Slrn_Print_Type));

  if (HFILE_ERROR == (p->h = _lopen ("prn", OF_SHARE_DENY_WRITE | WRITE)))
	{
	 slrn_error ("Printer not supported");
	 return NULL;
	}
  else
 return p;
}

/*}}}*/
#endif				       /* USE_WIN16_PRINT_CODE */

Technical Details
Message-ID: <6kjo0f$81p$1@gte1.gte.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
References: <6kefal$6pn$1@gte1.gte.net> <6ki8li$j57$1@gte2.gte.net> <slrn6mpvkk.lsk.davis@aluche.mit.edu>

Show Full Headers
Complete Article Headers
Message-ID: <6kjo0f$81p$1@gte1.gte.net>
Subject: Re: Windows 16/32 printer code for slrn
Date: Thu, 28 May 1998 00:00:00 +0000
From: root@gte.net ()
References: <6kefal$6pn$1@gte1.gte.net> <6ki8li$j57$1@gte2.gte.net> <slrn6mpvkk.lsk.davis@aluche.mit.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
X-Deja-AN: 357297487
Reply-To: vtailor@gte.net-nospam
Organization: The Light
X-Auth: C01F8B065C89D69811D08491
Newsgroups: news.software.readers