FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
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
) {
23
int
res =
fb_FileOpenVfsRawEx
(
FB_HANDLE_PRINTER
,
24
pszPrinterDev
,
25
strlen(
pszPrinterDev
),
26
FB_FILE_MODE_APPEND
,
27
FB_FILE_ACCESS_WRITE
,
28
FB_FILE_LOCK_READWRITE
,
29
0,
30
FB_FILE_ENCOD_DEFAULT
,
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 ) )
46
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
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
rtlib
file_openlpt.c
Generated on Thu Jan 23 2014 19:40:11 for FreeBASIC by
1.8.4