FreeBASIC  0.91.0
file_openlpt.c
Go to the documentation of this file.
1 /* open LPTx */
2 
3 #include "fb.h"
4 
5 static void close_printer_handle(void)
6 {
7  if( FB_HANDLE_PRINTER->hooks==NULL )
8  return;
9  FB_HANDLE_PRINTER->hooks->pfnClose( FB_HANDLE_PRINTER );
10 }
11 
12 #if defined( HOST_WIN32 )
13 static const char *pszPrinterDev = "LPT:EMU=TTY";
14 #elif defined( HOST_LINUX )
15 static const char *pszPrinterDev = "LPT:";
16 #else
17 static const char *pszPrinterDev = "LPT1:";
18 #endif
19 
20 int fb_LPrintInit(void)
21 {
22  if( FB_HANDLE_PRINTER->hooks==NULL) {
25  strlen(pszPrinterDev),
29  0,
31  fb_DevLptOpen );
32  if( res==FB_RTERROR_OK ) {
33  atexit(close_printer_handle);
34  }
35  return res;
36  }
37  return fb_ErrorSetNum( FB_RTERROR_OK );
38 }
39 
40 /*:::::*/
41 FBCALL int fb_FileOpenLpt ( FBSTRING *str_filename, unsigned int mode,
42  unsigned int access, unsigned int lock,
43  int fnum, int len, const char *encoding )
44 {
45  if( !FB_FILE_INDEX_VALID( fnum ) )
47 
48  return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
49  str_filename,
50  mode,
51  access,
52  lock,
53  len,
54  fb_hFileStrToEncoding( encoding ),
55  fb_DevLptOpen );
56 
57 }
58