1 |
#define MAX_PRINTERS 5 |
/* -*- c-basic-offset: 8 -*- |
2 |
|
rdesktop: A Remote Desktop Protocol client. |
3 |
|
Copyright (C) Matthew Chapman 1999-2005 |
4 |
|
|
5 |
|
This program is free software; you can redistribute it and/or modify |
6 |
|
it under the terms of the GNU General Public License as published by |
7 |
|
the Free Software Foundation; either version 2 of the License, or |
8 |
|
(at your option) any later version. |
9 |
|
|
10 |
|
This program is distributed in the hope that it will be useful, |
11 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
GNU General Public License for more details. |
14 |
|
|
15 |
|
You should have received a copy of the GNU General Public License |
16 |
|
along with this program; if not, write to the Free Software |
17 |
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 |
|
*/ |
19 |
|
|
20 |
#include "rdesktop.h" |
#include "rdesktop.h" |
21 |
|
|
22 |
extern RDPDR_DEVICE g_rdpdr_device[]; |
extern RDPDR_DEVICE g_rdpdr_device[]; |
23 |
|
|
24 |
PRINTER * |
static PRINTER * |
25 |
get_printer_data(HANDLE handle) |
get_printer_data(NTHANDLE handle) |
26 |
{ |
{ |
27 |
int index; |
int index; |
28 |
|
|
35 |
} |
} |
36 |
|
|
37 |
int |
int |
38 |
printer_enum_devices(int *id, char *optarg) |
printer_enum_devices(uint32 * id, char *optarg) |
39 |
{ |
{ |
40 |
PRINTER *pprinter_data; |
PRINTER *pprinter_data; |
41 |
|
|
44 |
int count = 0; |
int count = 0; |
45 |
int already = 0; |
int already = 0; |
46 |
|
|
47 |
// we need to know how many printers we've already set up |
/* we need to know how many printers we've already set up |
48 |
// supplied from other -r flags than this one. |
supplied from other -r flags than this one. */ |
49 |
while (count < *id) |
while (count < *id) |
50 |
{ |
{ |
51 |
if (g_rdpdr_device[count].device_type == DEVICE_TYPE_PRINTER) |
if (g_rdpdr_device[count].device_type == DEVICE_TYPE_PRINTER) |
63 |
pprinter_data = (PRINTER *) xmalloc(sizeof(PRINTER)); |
pprinter_data = (PRINTER *) xmalloc(sizeof(PRINTER)); |
64 |
|
|
65 |
strcpy(g_rdpdr_device[*id].name, "PRN"); |
strcpy(g_rdpdr_device[*id].name, "PRN"); |
66 |
strcat(g_rdpdr_device[*id].name, ltoa(already + count + 1, 10)); |
strcat(g_rdpdr_device[*id].name, l_to_a(already + count + 1, 10)); |
67 |
|
|
68 |
/* first printer is set as default printer */ |
/* first printer is set as default printer */ |
69 |
if ((already + count) == 0) |
if ((already + count) == 0) |
81 |
} |
} |
82 |
|
|
83 |
if (!pos2 || (*pos2 == (char) 0x00)) |
if (!pos2 || (*pos2 == (char) 0x00)) |
84 |
pprinter_data->driver = "HP LaserJet IIIP"; /* no printer driver supplied set default */ |
pprinter_data->driver = "HP Color LaserJet 8500 PS"; /* no printer driver supplied set default */ |
85 |
else |
else |
86 |
{ |
{ |
87 |
pprinter_data->driver = xmalloc(strlen(pos2) + 1); |
pprinter_data->driver = xmalloc(strlen(pos2) + 1); |
102 |
|
|
103 |
static NTSTATUS |
static NTSTATUS |
104 |
printer_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, uint32 flags, |
printer_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, uint32 flags, |
105 |
char *filename, HANDLE * handle) |
char *filename, NTHANDLE * handle) |
106 |
{ |
{ |
107 |
char cmd[256]; |
char cmd[256]; |
108 |
PRINTER *pprinter_data; |
PRINTER *pprinter_data; |
126 |
} |
} |
127 |
|
|
128 |
static NTSTATUS |
static NTSTATUS |
129 |
printer_close(HANDLE handle) |
printer_close(NTHANDLE handle) |
130 |
{ |
{ |
131 |
PRINTER *pprinter_data; |
int i = get_device_index(handle); |
132 |
|
if (i >= 0) |
133 |
pprinter_data = get_printer_data(handle); |
{ |
134 |
|
PRINTER *pprinter_data = g_rdpdr_device[i].pdevice_data; |
135 |
g_rdpdr_device[get_device_index(handle)].handle = 0; |
if (pprinter_data) |
136 |
|
pclose(pprinter_data->printer_fp); |
137 |
pclose(pprinter_data->printer_fp); |
g_rdpdr_device[i].handle = 0; |
138 |
|
} |
139 |
return STATUS_SUCCESS; |
return STATUS_SUCCESS; |
140 |
} |
} |
141 |
|
|
142 |
static NTSTATUS |
static NTSTATUS |
143 |
printer_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
printer_write(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
144 |
{ |
{ |
145 |
PRINTER *pprinter_data; |
PRINTER *pprinter_data; |
146 |
|
|