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

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

revision 828 by stargo, Sun Mar 6 21:11:18 2005 UTC revision 1327 by stargo, Fri Nov 3 19:56:42 2006 UTC
# Line 60  extern DEVICE_FNS serial_fns; Line 60  extern DEVICE_FNS serial_fns;
60  extern DEVICE_FNS printer_fns;  extern DEVICE_FNS printer_fns;
61  extern DEVICE_FNS parallel_fns;  extern DEVICE_FNS parallel_fns;
62  extern DEVICE_FNS disk_fns;  extern DEVICE_FNS disk_fns;
63    #ifdef WITH_SCARD
64    extern DEVICE_FNS scard_fns;
65    #endif
66  extern FILEINFO g_fileinfo[];  extern FILEINFO g_fileinfo[];
67  extern BOOL g_notify_stamp;  extern BOOL g_notify_stamp;
68    
69    #ifdef WITH_SCARD
70    VCHANNEL *rdpdr_channel;
71    #else
72  static VCHANNEL *rdpdr_channel;  static VCHANNEL *rdpdr_channel;
73    #endif
74    
75  /* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */  /* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */
76  NTHANDLE g_min_timeout_fd;  NTHANDLE g_min_timeout_fd;
# Line 155  add_async_iorequest(uint32 device, uint3 Line 162  add_async_iorequest(uint32 device, uint3
162    
163          while (iorq->fd != 0)          while (iorq->fd != 0)
164          {          {
165                  // create new element if needed                  /* create new element if needed */
166                  if (iorq->next == NULL)                  if (iorq->next == NULL)
167                  {                  {
168                          iorq->next =                          iorq->next =
# Line 228  announcedata_size() Line 235  announcedata_size()
235          int size, i;          int size, i;
236          PRINTER *printerinfo;          PRINTER *printerinfo;
237    
238          size = 8;               //static announce size          size = 8;               /* static announce size */
239          size += g_num_devices * 0x14;          size += g_num_devices * 0x14;
240    
241          for (i = 0; i < g_num_devices; i++)          for (i = 0; i < g_num_devices; i++)
# Line 309  rdpdr_send_available(void) Line 316  rdpdr_send_available(void)
316          channel_send(s, rdpdr_channel);          channel_send(s, rdpdr_channel);
317  }  }
318    
319  static void  void
320  rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer,  rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer,
321                        uint32 length)                        uint32 length)
322  {  {
# Line 327  rdpdr_send_completion(uint32 device, uin Line 334  rdpdr_send_completion(uint32 device, uin
334          /* JIF */          /* JIF */
335  #ifdef WITH_DEBUG_RDP5  #ifdef WITH_DEBUG_RDP5
336          printf("--> rdpdr_send_completion\n");          printf("--> rdpdr_send_completion\n");
337          //hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8);          /* hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8); */
338  #endif  #endif
339          channel_send(s, rdpdr_channel);          channel_send(s, rdpdr_channel);
340  }  }
# Line 352  rdpdr_process_irp(STREAM s) Line 359  rdpdr_process_irp(STREAM s)
359                  error_mode,                  error_mode,
360                  share_mode, disposition, total_timeout, interval_timeout, flags_and_attributes = 0;                  share_mode, disposition, total_timeout, interval_timeout, flags_and_attributes = 0;
361    
362          char filename[256];          char filename[PATH_MAX];
363          uint8 *buffer, *pst_buf;          uint8 *buffer, *pst_buf;
364          struct stream out;          struct stream out;
365          DEVICE_FNS *fns;          DEVICE_FNS *fns;
# Line 395  rdpdr_process_irp(STREAM s) Line 402  rdpdr_process_irp(STREAM s)
402                          break;                          break;
403    
404                  case DEVICE_TYPE_SCARD:                  case DEVICE_TYPE_SCARD:
405    #ifdef WITH_SCARD
406                            fns = &scard_fns;
407                            rw_blocking = False;
408                            break;
409    #endif
410                  default:                  default:
411    
412                          error("IRP for bad device %ld\n", device);                          error("IRP for bad device %ld\n", device);
# Line 406  rdpdr_process_irp(STREAM s) Line 418  rdpdr_process_irp(STREAM s)
418                  case IRP_MJ_CREATE:                  case IRP_MJ_CREATE:
419    
420                          in_uint32_be(s, desired_access);                          in_uint32_be(s, desired_access);
421                          in_uint8s(s, 0x08);     // unknown                          in_uint8s(s, 0x08);     /* unknown */
422                          in_uint32_le(s, error_mode);                          in_uint32_le(s, error_mode);
423                          in_uint32_le(s, share_mode);                          in_uint32_le(s, share_mode);
424                          in_uint32_le(s, disposition);                          in_uint32_le(s, disposition);
# Line 463  rdpdr_process_irp(STREAM s) Line 475  rdpdr_process_irp(STREAM s)
475                                  break;                                  break;
476                          }                          }
477    
478                          if (rw_blocking)        // Complete read immediately                          if (rw_blocking)        /* Complete read immediately */
479                          {                          {
480                                  buffer = (uint8 *) xrealloc((void *) buffer, length);                                  buffer = (uint8 *) xrealloc((void *) buffer, length);
481                                  if (!buffer)                                  if (!buffer)
# Line 476  rdpdr_process_irp(STREAM s) Line 488  rdpdr_process_irp(STREAM s)
488                                  break;                                  break;
489                          }                          }
490    
491                          // Add request to table                          /* Add request to table */
492                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
493                          if (!pst_buf)                          if (!pst_buf)
494                          {                          {
# Line 516  rdpdr_process_irp(STREAM s) Line 528  rdpdr_process_irp(STREAM s)
528                                  break;                                  break;
529                          }                          }
530    
531                          if (rw_blocking)        // Complete immediately                          if (rw_blocking)        /* Complete immediately */
532                          {                          {
533                                  status = fns->write(file, s->p, length, offset, &result);                                  status = fns->write(file, s->p, length, offset, &result);
534                                  break;                                  break;
535                          }                          }
536    
537                          // Add to table                          /* Add to table */
538                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
539                          if (!pst_buf)                          if (!pst_buf)
540                          {                          {
# Line 629  rdpdr_process_irp(STREAM s) Line 641  rdpdr_process_irp(STREAM s)
641                                          /* JIF                                          /* JIF
642                                             unimpl("IRP major=0x%x minor=0x%x: IRP_MN_NOTIFY_CHANGE_DIRECTORY\n", major, minor);  */                                             unimpl("IRP major=0x%x minor=0x%x: IRP_MN_NOTIFY_CHANGE_DIRECTORY\n", major, minor);  */
643    
644                                          in_uint32_le(s, info_level);    // notify mask                                          in_uint32_le(s, info_level);    /* notify mask */
645    
646                                          g_notify_stamp = True;                                          g_notify_stamp = True;
647    
# Line 671  rdpdr_process_irp(STREAM s) Line 683  rdpdr_process_irp(STREAM s)
683    
684                          out.data = out.p = buffer;                          out.data = out.p = buffer;
685                          out.size = sizeof(buffer);                          out.size = sizeof(buffer);
686    
687                            DEBUG_SCARD(("[SMART-CARD TRACE]\n"));
688                            DEBUG_SCARD(("device 0x%.8x\n", device));
689                            DEBUG_SCARD(("file   0x%.8x\n", file));
690                            DEBUG_SCARD(("id     0x%.8x\n", id));
691    #ifdef WITH_SCARD
692                            scardSetInfo(device, id, bytes_out + 0x14);
693    #endif
694                          status = fns->device_control(file, request, s, &out);                          status = fns->device_control(file, request, s, &out);
695                          result = buffer_len = out.p - out.data;                          result = buffer_len = out.p - out.data;
696    
697                            DEBUG_SCARD(("[SMART-CARD TRACE] OUT 0x%.8x\n", status));
698    
699                          /* Serial SERIAL_WAIT_ON_MASK */                          /* Serial SERIAL_WAIT_ON_MASK */
700                          if (status == STATUS_PENDING)                          if (status == STATUS_PENDING)
701                          {                          {
# Line 684  rdpdr_process_irp(STREAM s) Line 706  rdpdr_process_irp(STREAM s)
706                                          break;                                          break;
707                                  }                                  }
708                          }                          }
709    #ifdef WITH_SCARD
710                            else if (status == (STATUS_PENDING | 0xC0000000))
711                                    status = STATUS_PENDING;
712    #endif
713                          break;                          break;
714    
715    
# Line 835  rdpdr_init() Line 861  rdpdr_init()
861  void  void
862  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)
863  {  {
864          uint32 select_timeout = 0;      // Timeout value to be used for select() (in millisecons).          uint32 select_timeout = 0;      /* Timeout value to be used for select() (in millisecons). */
865          struct async_iorequest *iorq;          struct async_iorequest *iorq;
866          char c;          char c;
867    
# Line 920  rdpdr_remove_iorequest(struct async_iore Line 946  rdpdr_remove_iorequest(struct async_iore
946          }          }
947          else          else
948          {          {
949                  // Even if NULL                  /* Even if NULL */
950                  g_iorequest = iorq->next;                  g_iorequest = iorq->next;
951                  xfree(iorq);                  xfree(iorq);
952                  iorq = NULL;                  iorq = NULL;
# Line 929  rdpdr_remove_iorequest(struct async_iore Line 955  rdpdr_remove_iorequest(struct async_iore
955  }  }
956    
957  /* 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 */
958  void  static void
959  _rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out)  _rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out)
960  {  {
961          NTSTATUS status;          NTSTATUS status;
# Line 959  _rdpdr_check_fds(fd_set * rfds, fd_set * Line 985  _rdpdr_check_fds(fd_set * rfds, fd_set *
985                                  {                                  {
986    
987                                          /* iv_timeout between 2 chars, send partial_len */                                          /* iv_timeout between 2 chars, send partial_len */
988                                          //printf("RDPDR: IVT total %u bytes read of %u\n", iorq->partial_len, iorq->length);                                          /*printf("RDPDR: IVT total %u bytes read of %u\n", iorq->partial_len, iorq->length); */
989                                          rdpdr_send_completion(iorq->device,                                          rdpdr_send_completion(iorq->device,
990                                                                iorq->id, STATUS_SUCCESS,                                                                iorq->id, STATUS_SUCCESS,
991                                                                iorq->partial_len,                                                                iorq->partial_len,
# Line 1180  rdpdr_abort_io(uint32 fd, uint32 major, Line 1206  rdpdr_abort_io(uint32 fd, uint32 major,
1206          prev = NULL;          prev = NULL;
1207          while (iorq != NULL)          while (iorq != NULL)
1208          {          {
1209                  // Only remove from table when major is not set, or when correct major is supplied.                  /* Only remove from table when major is not set, or when correct major is supplied.
1210                  // Abort read should not abort a write io request.                     Abort read should not abort a write io request. */
1211                  if ((iorq->fd == fd) && (major == 0 || iorq->major == major))                  if ((iorq->fd == fd) && (major == 0 || iorq->major == major))
1212                  {                  {
1213                          result = 0;                          result = 0;

Legend:
Removed from v.828  
changed lines
  Added in v.1327

  ViewVC Help
Powered by ViewVC 1.1.26