/[rdesktop]/jpeg/rdesktop/trunk/printer.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /jpeg/rdesktop/trunk/printer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

sourceforge.net/trunk/rdesktop/printer.c revision 664 by astrand, Sat Apr 17 07:14:41 2004 UTC sourceforge.net/rdesktop/trunk/printer.c revision 1488 by astrand, Fri May 15 08:18:08 2009 UTC
# Line 1  Line 1 
1    /* -*- c-basic-offset: 8 -*-
2       rdesktop: A Remote Desktop Protocol client.
3       Copyright (C) Matthew Chapman 1999-2008
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  static PRINTER *  static PRINTER *
25  get_printer_data(HANDLE handle)  get_printer_data(RD_NTHANDLE handle)
26  {  {
27          int index;          int index;
28    
# Line 25  printer_enum_devices(uint32 * id, char * Line 44  printer_enum_devices(uint32 * id, char *
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)
# Line 62  printer_enum_devices(uint32 * id, char * Line 81  printer_enum_devices(uint32 * id, char *
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);
# Line 81  printer_enum_devices(uint32 * id, char * Line 100  printer_enum_devices(uint32 * id, char *
100          return count;          return count;
101  }  }
102    
103  static NTSTATUS  static RD_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, RD_NTHANDLE * handle)
106  {  {
107          char cmd[256];          char cmd[256];
108          PRINTER *pprinter_data;          PRINTER *pprinter_data;
# Line 91  printer_create(uint32 device_id, uint32 Line 110  printer_create(uint32 device_id, uint32
110          pprinter_data = (PRINTER *) g_rdpdr_device[device_id].pdevice_data;          pprinter_data = (PRINTER *) g_rdpdr_device[device_id].pdevice_data;
111    
112          /* default printer name use default printer queue as well in unix */          /* default printer name use default printer queue as well in unix */
113          if (pprinter_data->printer == "mydeskjet")          if (strncmp(pprinter_data->printer, "mydeskjet", strlen(pprinter_data->printer)) == 0)
114          {          {
115                  pprinter_data->printer_fp = popen("lpr", "w");                  pprinter_data->printer_fp = popen("lpr", "w");
116          }          }
# Line 103  printer_create(uint32 device_id, uint32 Line 122  printer_create(uint32 device_id, uint32
122    
123          g_rdpdr_device[device_id].handle = fileno(pprinter_data->printer_fp);          g_rdpdr_device[device_id].handle = fileno(pprinter_data->printer_fp);
124          *handle = g_rdpdr_device[device_id].handle;          *handle = g_rdpdr_device[device_id].handle;
125          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
126  }  }
127    
128  static NTSTATUS  static RD_NTSTATUS
129  printer_close(HANDLE handle)  printer_close(RD_NTHANDLE handle)
130  {  {
131          int i = get_device_index(handle);          int i = get_device_index(handle);
132          if (i >= 0)          if (i >= 0)
# Line 117  printer_close(HANDLE handle) Line 136  printer_close(HANDLE handle)
136                          pclose(pprinter_data->printer_fp);                          pclose(pprinter_data->printer_fp);
137                  g_rdpdr_device[i].handle = 0;                  g_rdpdr_device[i].handle = 0;
138          }          }
139          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
140  }  }
141    
142  static NTSTATUS  static RD_NTSTATUS
143  printer_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)  printer_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
144  {  {
145          PRINTER *pprinter_data;          PRINTER *pprinter_data;
146    
# Line 131  printer_write(HANDLE handle, uint8 * dat Line 150  printer_write(HANDLE handle, uint8 * dat
150          if (ferror(pprinter_data->printer_fp))          if (ferror(pprinter_data->printer_fp))
151          {          {
152                  *result = 0;                  *result = 0;
153                  return STATUS_INVALID_HANDLE;                  return RD_STATUS_INVALID_HANDLE;
154          }          }
155          return STATUS_SUCCESS;          return RD_STATUS_SUCCESS;
156  }  }
157    
158  DEVICE_FNS printer_fns = {  DEVICE_FNS printer_fns = {
# Line 143  DEVICE_FNS printer_fns = { Line 162  DEVICE_FNS printer_fns = {
162          printer_write,          printer_write,
163          NULL                    /* device_control */          NULL                    /* device_control */
164  };  };
   

Legend:
Removed from v.664  
changed lines
  Added in v.1488

  ViewVC Help
Powered by ViewVC 1.1.26