/[rdesktop]/jpeg/rdesktop/trunk/rdpdr.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/rdpdr.c

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

revision 570 by stargo, Wed Jan 21 18:02:38 2004 UTC revision 590 by n-ki, Thu Jan 29 12:27:21 2004 UTC
# Line 1  Line 1 
1  #include <unistd.h>  #include <unistd.h>
2    #include <sys/types.h>
3    #include <time.h>
4  #include "rdesktop.h"  #include "rdesktop.h"
5    
6  #define IRP_MJ_CREATE           0x00  #define IRP_MJ_CREATE           0x00
# Line 20  Line 22 
22  #define IRP_MN_QUERY_DIRECTORY          0x01  #define IRP_MN_QUERY_DIRECTORY          0x01
23  #define IRP_MN_NOTIFY_CHANGE_DIRECTORY  0x02  #define IRP_MN_NOTIFY_CHANGE_DIRECTORY  0x02
24    
25  #define MAX_ASYNC_IO_REQUESTS   10  //#define MAX_ASYNC_IO_REQUESTS   10
26    
27  extern char hostname[16];  extern char hostname[16];
28  extern DEVICE_FNS serial_fns;  extern DEVICE_FNS serial_fns;
# Line 38  uint32 g_num_devices; Line 40  uint32 g_num_devices;
40  /* Table with information about rdpdr devices */  /* Table with information about rdpdr devices */
41  RDPDR_DEVICE g_rdpdr_device[RDPDR_MAX_DEVICES];  RDPDR_DEVICE g_rdpdr_device[RDPDR_MAX_DEVICES];
42    
43    #if 0
44  /* Used to store incoming io request, until they are ready to be completed */  /* Used to store incoming io request, until they are ready to be completed */
45  struct async_iorequest  struct async_iorequest
46  {  {
# Line 47  struct async_iorequest Line 50  struct async_iorequest
50          uint8 *buffer;          uint8 *buffer;
51          DEVICE_FNS *fns;          DEVICE_FNS *fns;
52  } g_iorequest[MAX_ASYNC_IO_REQUESTS];  } g_iorequest[MAX_ASYNC_IO_REQUESTS];
53    #endif
54    
55  /* Return device_id for a given handle */  /* Return device_id for a given handle */
56  int  int
# Line 73  convert_to_unix_filename(char *filename) Line 77  convert_to_unix_filename(char *filename)
77          }          }
78  }  }
79    
80    #if 0
81  /* Add a new io request to the table containing pending io requests so it won't block rdesktop */  /* Add a new io request to the table containing pending io requests so it won't block rdesktop */
82  BOOL  BOOL
83  add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length,  add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length,
# Line 102  add_async_iorequest(uint32 device, uint3 Line 107  add_async_iorequest(uint32 device, uint3
107          error("IO request table full. Increase MAX_ASYNC_IO_REQUESTS in rdpdr.c!\n");          error("IO request table full. Increase MAX_ASYNC_IO_REQUESTS in rdpdr.c!\n");
108          return False;          return False;
109  }  }
110    #endif
111    
112  void  void
113  rdpdr_send_connect(void)  rdpdr_send_connect(void)
# Line 186  rdpdr_send_available(void) Line 191  rdpdr_send_available(void)
191                  out_uint32_le(s, i);    /* RDP Device ID */                  out_uint32_le(s, i);    /* RDP Device ID */
192                  out_uint8p(s, g_rdpdr_device[i].name, 8);                  out_uint8p(s, g_rdpdr_device[i].name, 8);
193    
194                  if (g_rdpdr_device[i].device_type == DEVICE_TYPE_PRINTER)                  switch (g_rdpdr_device[i].device_type)
195                  {                  {
196                          printerinfo = (PRINTER *) g_rdpdr_device[i].pdevice_data;                          case DEVICE_TYPE_PRINTER:
197                                    printerinfo = (PRINTER *) g_rdpdr_device[i].pdevice_data;
198    
199                          driverlen = 2 * strlen(printerinfo->driver) + 2;                                  driverlen = 2 * strlen(printerinfo->driver) + 2;
200                          printerlen = 2 * strlen(printerinfo->printer) + 2;                                  printerlen = 2 * strlen(printerinfo->printer) + 2;
201                          bloblen = printerinfo->bloblen;                                  bloblen = printerinfo->bloblen;
202    
203                          out_uint32_le(s, 24 + driverlen + printerlen + bloblen);        /* length of extra info */                                  out_uint32_le(s, 24 + driverlen + printerlen + bloblen);        /* length of extra info */
204                          out_uint32_le(s, printerinfo->default_printer ? 2 : 0);                                  out_uint32_le(s, printerinfo->default_printer ? 2 : 0);
205                          out_uint8s(s, 8);       /* unknown */                                  out_uint8s(s, 8);       /* unknown */
206                          out_uint32_le(s, driverlen);                                  out_uint32_le(s, driverlen);
207                          out_uint32_le(s, printerlen);                                  out_uint32_le(s, printerlen);
208                          out_uint32_le(s, bloblen);                                  out_uint32_le(s, bloblen);
209                          rdp_out_unistr(s, printerinfo->driver, driverlen - 2);                                  rdp_out_unistr(s, printerinfo->driver, driverlen - 2);
210                          rdp_out_unistr(s, printerinfo->printer, printerlen - 2);                                  rdp_out_unistr(s, printerinfo->printer, printerlen - 2);
211                          out_uint8a(s, printerinfo->blob, bloblen);                                  out_uint8a(s, printerinfo->blob, bloblen);
212    
213                          xfree(printerinfo->blob);       /* Blob is sent twice if reconnecting */                                  xfree(printerinfo->blob);       /* Blob is sent twice if reconnecting */
214                  }                                  break;
215                  else                          default:
216                  {                                  out_uint32(s, 0);
                         out_uint32(s, 0);  
217                  }                  }
218          }          }
219  #if 0  #if 0
# Line 280  rdpdr_process_irp(STREAM s) Line 285  rdpdr_process_irp(STREAM s)
285          buffer = (uint8 *) xmalloc(1024);          buffer = (uint8 *) xmalloc(1024);
286          buffer[0] = 0;          buffer[0] = 0;
287    
   
288          switch (g_rdpdr_device[device].device_type)          switch (g_rdpdr_device[device].device_type)
289          {          {
290                  case DEVICE_TYPE_SERIAL:                  case DEVICE_TYPE_SERIAL:
291    
292                          fns = &serial_fns;                          fns = &serial_fns;
293                          rw_blocking = False;                          /* should be async when aio is finished */
294                            /*rw_blocking = False; */
295                          break;                          break;
296    
297                  case DEVICE_TYPE_PARALLEL:                  case DEVICE_TYPE_PARALLEL:
298    
299                          fns = &parallel_fns;                          fns = &parallel_fns;
300                          rw_blocking = False;                          /* should be async when aio is finished */
301                            /*rw_blocking = False;*/
302                          break;                          break;
303    
304                  case DEVICE_TYPE_PRINTER:                  case DEVICE_TYPE_PRINTER:
# Line 368  rdpdr_process_irp(STREAM s) Line 374  rdpdr_process_irp(STREAM s)
374  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
375                          DEBUG(("RDPDR IRP Read (length: %d, offset: %d)\n", length, offset));                          DEBUG(("RDPDR IRP Read (length: %d, offset: %d)\n", length, offset));
376  #endif  #endif
377                          if (rw_blocking)        // Complete read immediately  //                      if (rw_blocking)        // Complete read immediately
378                          {  //                      {
379                                  buffer = (uint8 *) xrealloc((void *) buffer, length);                                  buffer = (uint8 *) xrealloc((void *) buffer, length);
380                                  status = fns->read(file, buffer, length, offset, &result);                                  status = fns->read(file, buffer, length, offset, &result);
381                                  buffer_len = result;                                  buffer_len = result;
382                                  break;                                  break;
383                          }  //                      }
384    
385    #if 0
386                          // Add request to table                          // Add request to table
387                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
388                          serial_get_timeout(file, length, &total_timeout, &interval_timeout);                          serial_get_timeout(file, length, &total_timeout, &interval_timeout);
# Line 389  rdpdr_process_irp(STREAM s) Line 396  rdpdr_process_irp(STREAM s)
396    
397                          status = STATUS_CANCELLED;                          status = STATUS_CANCELLED;
398                          break;                          break;
399    #endif
400                  case IRP_MJ_WRITE:                  case IRP_MJ_WRITE:
401    
402                          buffer_len = 1;                          buffer_len = 1;
# Line 406  rdpdr_process_irp(STREAM s) Line 413  rdpdr_process_irp(STREAM s)
413  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
414                          DEBUG(("RDPDR IRP Write (length: %d)\n", result));                          DEBUG(("RDPDR IRP Write (length: %d)\n", result));
415  #endif  #endif
416                          if (rw_blocking)        // Complete immediately  //                      if (rw_blocking)        // Complete immediately
417                          {  //                      {
418                                  status = fns->write(file, s->p, length, offset, &result);                                  status = fns->write(file, s->p, length, offset, &result);
419                                  break;                                  break;
420                          }  //                      }
421    #if 0
422                          // Add to table                          // Add to table
423                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
424                          in_uint8a(s, pst_buf, length);                          in_uint8a(s, pst_buf, length);
# Line 425  rdpdr_process_irp(STREAM s) Line 432  rdpdr_process_irp(STREAM s)
432    
433                          status = STATUS_CANCELLED;                          status = STATUS_CANCELLED;
434                          break;                          break;
435    #endif
436    
437                  case IRP_MJ_QUERY_INFORMATION:                  case IRP_MJ_QUERY_INFORMATION:
438    
# Line 659  rdpdr_init() Line 667  rdpdr_init()
667  {  {
668          if (g_num_devices > 0)          if (g_num_devices > 0)
669          {          {
670                  rdpdr_channel = channel_register("rdpdr", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_COMPRESS_RDP, rdpdr_process);                  rdpdr_channel =
671                            channel_register("rdpdr",
672                                             CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_COMPRESS_RDP,
673                                             rdpdr_process);
674          }          }
675    
676          return (rdpdr_channel != NULL);          return (rdpdr_channel != NULL);
677  }  }
678    
679    #if 0
680  /* Add file descriptors of pending io request to select() */  /* Add file descriptors of pending io request to select() */
681  void  void
682  rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout)  rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout)
# Line 710  rdpdr_add_fds(int *n, fd_set * rfds, fd_ Line 722  rdpdr_add_fds(int *n, fd_set * rfds, fd_
722          }          }
723  }  }
724    
725    
726  /* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */  /* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */
727  void  void
728  rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out)  rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out)
# Line 802  rdpdr_abort_io(uint32 fd, uint32 major, Line 815  rdpdr_abort_io(uint32 fd, uint32 major,
815          }          }
816          return False;          return False;
817  }  }
818    #endif

Legend:
Removed from v.570  
changed lines
  Added in v.590

  ViewVC Help
Powered by ViewVC 1.1.26