/[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 608 by astrand, Sun Feb 15 21:19:28 2004 UTC revision 614 by n-ki, Mon Feb 23 12:07:30 2004 UTC
# Line 1  Line 1 
1  #include <unistd.h>  #include <unistd.h>
2  #include <sys/types.h>  #include <sys/types.h>
3    #include <sys/time.h>
4  #include <time.h>  #include <time.h>
5  #include "rdesktop.h"  #include "rdesktop.h"
6    
# Line 81  convert_to_unix_filename(char *filename) Line 82  convert_to_unix_filename(char *filename)
82  /* 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 */
83  BOOL  BOOL
84  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,
85                      DEVICE_FNS * fns, uint32 total_timeout, uint32 interval_timeout, uint8 * buffer)                      DEVICE_FNS * fns, uint32 total_timeout, uint32 interval_timeout, uint8 * buffer,
86                        uint32 offset)
87  {  {
88          struct async_iorequest *iorq;          struct async_iorequest *iorq;
89    
90          if (g_iorequest == NULL)          if (g_iorequest == NULL)
91          {          {
92                  g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));                  g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
93                    if (!g_iorequest)
94                            return False;
95                  g_iorequest->fd = 0;                  g_iorequest->fd = 0;
96                  g_iorequest->next = NULL;                  g_iorequest->next = NULL;
97          }          }
# Line 101  add_async_iorequest(uint32 device, uint3 Line 105  add_async_iorequest(uint32 device, uint3
105                  {                  {
106                          iorq->next =                          iorq->next =
107                                  (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));                                  (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
108                            if (!iorq->next)
109                                    return False;
110                          iorq->next->fd = 0;                          iorq->next->fd = 0;
111                          iorq->next->next = NULL;                          iorq->next->next = NULL;
112                  }                  }
# Line 116  add_async_iorequest(uint32 device, uint3 Line 122  add_async_iorequest(uint32 device, uint3
122          iorq->timeout = total_timeout;          iorq->timeout = total_timeout;
123          iorq->itv_timeout = interval_timeout;          iorq->itv_timeout = interval_timeout;
124          iorq->buffer = buffer;          iorq->buffer = buffer;
125            iorq->offset = offset;
126          return True;          return True;
127  }  }
128    
# Line 387  rdpdr_process_irp(STREAM s) Line 394  rdpdr_process_irp(STREAM s)
394                          if (rw_blocking)        // Complete read immediately                          if (rw_blocking)        // Complete read immediately
395                          {                          {
396                                  buffer = (uint8 *) xrealloc((void *) buffer, length);                                  buffer = (uint8 *) xrealloc((void *) buffer, length);
397                                    if (!buffer)
398                                    {
399                                            status = STATUS_CANCELLED;
400                                            break;
401                                    }
402                                  status = fns->read(file, buffer, length, offset, &result);                                  status = fns->read(file, buffer, length, offset, &result);
403                                  buffer_len = result;                                  buffer_len = result;
404                                  break;                                  break;
# Line 394  rdpdr_process_irp(STREAM s) Line 406  rdpdr_process_irp(STREAM s)
406    
407                          // Add request to table                          // Add request to table
408                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
409                            if (!pst_buf)
410                            {
411                                    status = STATUS_CANCELLED;
412                                    break;
413                            }
414                          serial_get_timeout(file, length, &total_timeout, &interval_timeout);                          serial_get_timeout(file, length, &total_timeout, &interval_timeout);
415                          if (add_async_iorequest                          if (add_async_iorequest
416                              (device, file, id, major, length, fns, total_timeout, interval_timeout,                              (device, file, id, major, length, fns, total_timeout, interval_timeout,
417                               pst_buf))                               pst_buf, offset))
418                          {                          {
419                                  status = STATUS_PENDING;                                  status = STATUS_PENDING;
420                                  break;                                  break;
# Line 429  rdpdr_process_irp(STREAM s) Line 446  rdpdr_process_irp(STREAM s)
446    
447                          // Add to table                          // Add to table
448                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
449                            if (!pst_buf)
450                            {
451                                    status = STATUS_CANCELLED;
452                                    break;
453                            }
454    
455                          in_uint8a(s, pst_buf, length);                          in_uint8a(s, pst_buf, length);
456    
457                          if (add_async_iorequest                          if (add_async_iorequest
458                              (device, file, id, major, length, fns, 0, 0, pst_buf))                              (device, file, id, major, length, fns, 0, 0, pst_buf, offset))
459                          {                          {
460                                  status = STATUS_PENDING;                                  status = STATUS_PENDING;
461                                  break;                                  break;
# Line 552  rdpdr_process_irp(STREAM s) Line 575  rdpdr_process_irp(STREAM s)
575                          in_uint8s(s, 0x14);                          in_uint8s(s, 0x14);
576    
577                          buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14);                          buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14);
578                            if (!buffer)
579                            {
580                                    status = STATUS_CANCELLED;
581                                    break;
582                            }
583    
584                          out.data = out.p = buffer;                          out.data = out.p = buffer;
585                          out.size = sizeof(buffer);                          out.size = sizeof(buffer);
586                          status = fns->device_control(file, request, s, &out);                          status = fns->device_control(file, request, s, &out);
# Line 567  rdpdr_process_irp(STREAM s) Line 596  rdpdr_process_irp(STREAM s)
596          {          {
597                  rdpdr_send_completion(device, id, status, result, buffer, buffer_len);                  rdpdr_send_completion(device, id, status, result, buffer, buffer_len);
598          }          }
599          xfree(buffer);          if (buffer)
600                    xfree(buffer);
601            buffer = NULL;
602  }  }
603    
604  void  void
# Line 766  rdpdr_check_fds(fd_set * rfds, fd_set * Line 796  rdpdr_check_fds(fd_set * rfds, fd_set *
796                                                  /* never read larger chunks than 8k - chances are that it will block */                                                  /* never read larger chunks than 8k - chances are that it will block */
797                                                  status = fns->read(iorq->fd,                                                  status = fns->read(iorq->fd,
798                                                                     iorq->buffer + iorq->partial_len,                                                                     iorq->buffer + iorq->partial_len,
799                                                                     req_size, 0, &result);                                                                     req_size, iorq->offset, &result);
800                                                  iorq->partial_len += result;                                                  iorq->partial_len += result;
801                                                    iorq->offset += result;
802    
803  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
804                                                  DEBUG(("RDPDR: %d bytes of data read\n", result));                                                  DEBUG(("RDPDR: %d bytes of data read\n", result));
# Line 793  rdpdr_check_fds(fd_set * rfds, fd_set * Line 824  rdpdr_check_fds(fd_set * rfds, fd_set *
824                                                          {                                                          {
825                                                                  prev->next = iorq->next;                                                                  prev->next = iorq->next;
826                                                                  xfree(iorq);                                                                  xfree(iorq);
827                                                                    iorq = prev->next;
828                                                          }                                                          }
829                                                          else                                                          else
830                                                          {                                                          {
831                                                                  // Even if NULL                                                                  // Even if NULL
832                                                                  g_iorequest = iorq->next;                                                                  g_iorequest = iorq->next;
833                                                                  xfree(iorq);                                                                  xfree(iorq);
834                                                                    iorq = NULL;
835                                                          }                                                          }
836                                                  }                                                  }
837                                          }                                          }
# Line 817  rdpdr_check_fds(fd_set * rfds, fd_set * Line 850  rdpdr_check_fds(fd_set * rfds, fd_set *
850                                                  /* never write larger chunks than 8k - chances are that it will block */                                                  /* never write larger chunks than 8k - chances are that it will block */
851                                                  status = fns->write(iorq->fd,                                                  status = fns->write(iorq->fd,
852                                                                      iorq->buffer +                                                                      iorq->buffer +
853                                                                      iorq->partial_len, req_size, 0,                                                                      iorq->partial_len, req_size,
854                                                                      &result);                                                                      iorq->offset, &result);
855                                                  iorq->partial_len += result;                                                  iorq->partial_len += result;
856                                                    iorq->offset += result;
857  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
858                                                  DEBUG(("RDPDR: %d bytes of data written\n",                                                  DEBUG(("RDPDR: %d bytes of data written\n",
859                                                         result));                                                         result));
# Line 845  rdpdr_check_fds(fd_set * rfds, fd_set * Line 879  rdpdr_check_fds(fd_set * rfds, fd_set *
879                                                          {                                                          {
880                                                                  prev->next = iorq->next;                                                                  prev->next = iorq->next;
881                                                                  xfree(iorq);                                                                  xfree(iorq);
882                                                                    iorq = prev->next;
883                                                          }                                                          }
884                                                          else                                                          else
885                                                          {                                                          {
886                                                                  // Even if NULL                                                                  // Even if NULL
887                                                                  g_iorequest = iorq->next;                                                                  g_iorequest = iorq->next;
888                                                                  xfree(iorq);                                                                  xfree(iorq);
889                                                                    iorq = NULL;
890                                                          }                                                          }
891                                                  }                                                  }
892                                          }                                          }
# Line 859  rdpdr_check_fds(fd_set * rfds, fd_set * Line 895  rdpdr_check_fds(fd_set * rfds, fd_set *
895    
896                  }                  }
897                  prev = iorq;                  prev = iorq;
898                  iorq = iorq->next;                  if (iorq)
899                            iorq = iorq->next;
900          }          }
901    
902  }  }

Legend:
Removed from v.608  
changed lines
  Added in v.614

  ViewVC Help
Powered by ViewVC 1.1.26