🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #41234

Re: Windows 16/32 printer code for slrn

#41234
From: root
Date: Sat, 30 May 1998 00:00
115 lines
3630 bytes
On 28 May 1998 18:08:38 GMT, John E. Davis <davis@space.mit.edu> wrote:
>On 28 May 1998 13:14:55 GMT, root@gte.net <root@gte.net>
>wrote:
>>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?
>
>It does not:
>  
>    copy con: prn:
>    test
>    ^Z
>    Write fault error writing device PRN
>    Abort, Retry, Ignore, Fail?
>    Fail on INT 24 - prn
>            0 files(s) copied
>
>This is the reason I coded the printer interface in C instead of a
>macro that opened prn: and wrote out the article to that.
>
The following is (roughly and approximately) what your code would
look like if it didn't rely on winspool.lib and was upwardly
compatible with everything from Windows 3 up to the latest NT
and 98:


typedef struct
{
	FILE *fp;
	int error_status;
	int nLines;
} Slrn_Print_Type;

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

  pd = (PRINTDLG *)(p->fp);

  /* Send the next line to the printer's driver: */
  if (TextOut(pd->hDC, 50, 50 * p->nLines, buf, len) == 0)
   {
    p->error_status = 1;
    return -1;
   };

  /* End of page? */
  if ((p->nLines = p->nLines % 50) == 0)
   Escape(pd->hDC, NEWFRAME, 0, NULL, NULL);

  p->nLines++;

  return 0;
}

int win16_close_printer (Slrn_Print_Type *p)
{
 int nRval;
 PRINTDLG *pd = (PRINTDLG *)(p->fp);

  nRval = Escape(pd->hDC, ENDDOC, 0, NULL, NULL);
  DeleteDC(pd->hDC);
  if (pd->hDevMode != NULL)
   GlobalFree(pd->hDevMode);
  if (pd->hDevNames != NULL)
   GlobalFree(pd->hDevNames);
  slrn_free ((char *) p);
  slrn_free ((char *)pd);  
 return nRval;
}

Slrn_Print_Type *win16_open_printer ( )
{
  Slrn_Print_Type *p;
  PRINTDLG *pd;
  /* This is a the wstdio library name for the main text */
  /* window, but could be gotten through a Get....() call: */
  extern HWND hWndCurrent;

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

  if ((pd = (PRINTDLG *)SLmalloc(sizeof(PRINTDLG))) == NULL)
	return NULL;
  /* Set all structure members to zero. */
  memset((char *)pd, 0, sizeof(PRINTDLG));

  p->fp = (FILE *)pd;
  p->nLines = 5; /* Leave 5 blank lines at top of page. */

  pd->lStructSize = sizeof(PRINTDLG);
  pd->hwndOwner = hWndCurrent;
  pd->Flags = PD_RETURNDC;

  /* This calls a commdlg dialog that connects to the system */
  /* printer and initializes the device context: */
  if (PrintDlg(pd) == 0)
   {
    _message_error("Missing commdlg.dll file, or printer not connected.", NULL);
    return NULL;
   }
  else
   {
    Escape(pd->hDC, STARTDOC, 8, "Article-Doc", NULL);
    return p;
   };
}


Technical Details
Message-ID: <6knkf7$kea$1@gte2.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> <6kjo0f$81p$1@gte1.gte.net> <slrn6mra14.m2b.davis@aluche.mit.edu>

Show Full Headers
Complete Article Headers
Message-ID: <6knkf7$kea$1@gte2.gte.net>
Subject: Re: Windows 16/32 printer code for slrn
Date: Sat, 30 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> <6kjo0f$81p$1@gte1.gte.net> <slrn6mra14.m2b.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: 357817211
Reply-To: vtailor@gte.net-nospam
Organization: The Light
X-Auth: C01F8F020AD8D6CB45C18491
Newsgroups: news.software.readers