/[rdesktop]/sourceforge.net/trunk/rdesktop/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 /sourceforge.net/trunk/rdesktop/printer.c

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

revision 569 by n-ki, Wed Jan 21 14:40:40 2004 UTC revision 664 by astrand, Sat Apr 17 07:14:41 2004 UTC
# Line 1  Line 1 
 #define MAX_PRINTERS    5  
   
1  #include "rdesktop.h"  #include "rdesktop.h"
2    
3  extern RDPDR_DEVICE g_rdpdr_device[];  extern RDPDR_DEVICE g_rdpdr_device[];
4    
5  PRINTER * get_printer_data(HANDLE handle)  static PRINTER *
6    get_printer_data(HANDLE handle)
7  {  {
8          int index;          int index;
9    
# Line 17  PRINTER * get_printer_data(HANDLE handle Line 16  PRINTER * get_printer_data(HANDLE handle
16  }  }
17    
18  int  int
19  printer_enum_devices(int *id, char *optarg)  printer_enum_devices(uint32 * id, char *optarg)
20  {  {
21          PRINTER *pprinter_data;          PRINTER *pprinter_data;
22    
# Line 45  printer_enum_devices(int *id, char *opta Line 44  printer_enum_devices(int *id, char *opta
44                  pprinter_data = (PRINTER *) xmalloc(sizeof(PRINTER));                  pprinter_data = (PRINTER *) xmalloc(sizeof(PRINTER));
45    
46                  strcpy(g_rdpdr_device[*id].name, "PRN");                  strcpy(g_rdpdr_device[*id].name, "PRN");
47                  strcat(g_rdpdr_device[*id].name, ltoa(already + count + 1, 10));                  strcat(g_rdpdr_device[*id].name, l_to_a(already + count + 1, 10));
48    
49                  /* first printer is set as default printer */                  /* first printer is set as default printer */
50                  if ((already + count) == 0)                  if ((already + count) == 0)
# Line 53  printer_enum_devices(int *id, char *opta Line 52  printer_enum_devices(int *id, char *opta
52                  else                  else
53                          pprinter_data->default_printer = False;                          pprinter_data->default_printer = False;
54    
55                  pos2 = next_arg(optarg, ':');                  pos2 = next_arg(optarg, '=');
56                  if (*optarg == (char) 0x00)                  if (*optarg == (char) 0x00)
57                          pprinter_data->printer = "mydeskjet";   /* set default */                          pprinter_data->printer = "mydeskjet";   /* set default */
58                  else                  else
# Line 102  printer_create(uint32 device_id, uint32 Line 101  printer_create(uint32 device_id, uint32
101                  pprinter_data->printer_fp = popen(cmd, "w");                  pprinter_data->printer_fp = popen(cmd, "w");
102          }          }
103    
104          g_rdpdr_device[device_id].handle = pprinter_data->printer_fp->_fileno;          g_rdpdr_device[device_id].handle = fileno(pprinter_data->printer_fp);
105          *handle = g_rdpdr_device[device_id].handle;          *handle = g_rdpdr_device[device_id].handle;
106          return STATUS_SUCCESS;          return STATUS_SUCCESS;
107  }  }
# Line 110  printer_create(uint32 device_id, uint32 Line 109  printer_create(uint32 device_id, uint32
109  static NTSTATUS  static NTSTATUS
110  printer_close(HANDLE handle)  printer_close(HANDLE handle)
111  {  {
112          PRINTER *pprinter_data;          int i = get_device_index(handle);
113            if (i >= 0)
114          pprinter_data = get_printer_data(handle);          {
115                    PRINTER *pprinter_data = g_rdpdr_device[i].pdevice_data;
116          g_rdpdr_device[get_device_index(handle)].handle = 0;                  if (pprinter_data)
117                            pclose(pprinter_data->printer_fp);
118          pclose(pprinter_data->printer_fp);                  g_rdpdr_device[i].handle = 0;
119            }
120          return STATUS_SUCCESS;          return STATUS_SUCCESS;
121  }  }
122    
# Line 144  DEVICE_FNS printer_fns = { Line 143  DEVICE_FNS printer_fns = {
143          printer_write,          printer_write,
144          NULL                    /* device_control */          NULL                    /* device_control */
145  };  };
146    

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

  ViewVC Help
Powered by ViewVC 1.1.26