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

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

revision 192 by matthewc, Tue Sep 24 07:59:14 2002 UTC revision 340 by forsberg, Thu Mar 6 14:11:17 2003 UTC
# Line 1  Line 1 
1  /*  /*
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Protocol services - RDP layer     Protocol services - RDP layer
4     Copyright (C) Matthew Chapman 1999-2001     Copyright (C) Matthew Chapman 1999-2002
5        
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 30  extern BOOL desktop_save; Line 30  extern BOOL desktop_save;
30  uint8 *next_packet;  uint8 *next_packet;
31  uint32 rdp_shareid;  uint32 rdp_shareid;
32    
33    #if WITH_DEBUG
34    static uint32 packetno;
35    #endif
36    
37  /* Initialise an RDP packet */  /* Initialise an RDP packet */
38  static STREAM  static STREAM
39  rdp_init(int maxlen)  rdp_init(int maxlen)
# Line 79  rdp_recv(uint8 * type) Line 83  rdp_recv(uint8 * type)
83          }          }
84    
85          in_uint16_le(rdp_s, length);          in_uint16_le(rdp_s, length);
86            /* 32k packets are really 8, keepalive fix */
87            if (length == 0x8000)
88            {
89                    next_packet += 8;
90                    *type = 0;
91                    return rdp_s;
92            }
93          in_uint16_le(rdp_s, pdu_type);          in_uint16_le(rdp_s, pdu_type);
94          in_uint8s(rdp_s, 2);    /* userid */          in_uint8s(rdp_s, 2);    /* userid */
95          *type = pdu_type & 0xf;          *type = pdu_type & 0xf;
96    
97  #if WITH_DEBUG  #if WITH_DEBUG
98          DEBUG(("RDP packet (type %x):\n", *type));          DEBUG(("RDP packet #%d, (type %x):\n", ++packetno, *type));
99          hexdump(next_packet, length);          hexdump(next_packet, length);
100  #endif /*  */  #endif /*  */
101    
# Line 545  process_bitmap_updates(STREAM s) Line 556  process_bitmap_updates(STREAM s)
556  {  {
557          uint16 num_updates;          uint16 num_updates;
558          uint16 left, top, right, bottom, width, height;          uint16 left, top, right, bottom, width, height;
559          uint16 cx, cy, bpp, compress, bufsize, size;          uint16 cx, cy, bpp, Bpp, compress, bufsize, size;
560          uint8 *data, *bmpdata;          uint8 *data, *bmpdata;
561          int i;          int i;
562    
# Line 560  process_bitmap_updates(STREAM s) Line 571  process_bitmap_updates(STREAM s)
571                  in_uint16_le(s, width);                  in_uint16_le(s, width);
572                  in_uint16_le(s, height);                  in_uint16_le(s, height);
573                  in_uint16_le(s, bpp);                  in_uint16_le(s, bpp);
574                    Bpp = (bpp + 7) / 8;
575                  in_uint16_le(s, compress);                  in_uint16_le(s, compress);
576                  in_uint16_le(s, bufsize);                  in_uint16_le(s, bufsize);
577    
# Line 572  process_bitmap_updates(STREAM s) Line 584  process_bitmap_updates(STREAM s)
584                  if (!compress)                  if (!compress)
585                  {                  {
586                          int y;                          int y;
587                          bmpdata = xmalloc(width * height);                          bmpdata = xmalloc(width * height * Bpp);
588                          for (y = 0; y < height; y++)                          for (y = 0; y < height; y++)
589                          {                          {
590                                  in_uint8a(s, &bmpdata[(height - y - 1) * width], width);                                  in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],
591                                              width * Bpp);
592                          }                          }
593                          ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);                          ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);
594                          xfree(bmpdata);                          xfree(bmpdata);
# Line 586  process_bitmap_updates(STREAM s) Line 599  process_bitmap_updates(STREAM s)
599                  in_uint16_le(s, size);                  in_uint16_le(s, size);
600                  in_uint8s(s, 4);        /* line_size, final_size */                  in_uint8s(s, 4);        /* line_size, final_size */
601                  in_uint8p(s, data, size);                  in_uint8p(s, data, size);
602                    bmpdata = xmalloc(width * height * Bpp);
603                  bmpdata = xmalloc(width * height);                  if (bitmap_decompress(bmpdata, width, height, data, size, Bpp))
                 if (bitmap_decompress(bmpdata, width, height, data, size))  
604                  {                  {
605                          ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);                          ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);
606                  }                  }
   
607                  xfree(bmpdata);                  xfree(bmpdata);
608          }          }
609  }  }
# Line 601  process_bitmap_updates(STREAM s) Line 612  process_bitmap_updates(STREAM s)
612  static void  static void
613  process_palette(STREAM s)  process_palette(STREAM s)
614  {  {
615          HCOLOURMAP hmap;          COLOURENTRY *entry;
616          COLOURMAP map;          COLOURMAP map;
617          uint8 *colours;          HCOLOURMAP hmap;
618            int i;
619    
620          in_uint8s(s, 2);        /* pad */          in_uint8s(s, 2);        /* pad */
621          in_uint16_le(s, map.ncolours);          in_uint16_le(s, map.ncolours);
622          in_uint8s(s, 2);        /* pad */          in_uint8s(s, 2);        /* pad */
623          in_uint8p(s, colours, (map.ncolours * 3));  
624          map.colours = (COLOURENTRY *) colours;          map.colours = xmalloc(3 * map.ncolours);
625    
626            for (i = 0; i < map.ncolours; i++)
627            {
628                    entry = &map.colours[i];
629                    in_uint8(s, entry->red);
630                    in_uint8(s, entry->green);
631                    in_uint8(s, entry->blue);
632            }
633    
634          hmap = ui_create_colourmap(&map);          hmap = ui_create_colourmap(&map);
635          ui_set_colourmap(hmap);          ui_set_colourmap(hmap);
636    
637            xfree(map.colours);
638  }  }
639    
640  /* Process an update PDU */  /* Process an update PDU */
# Line 701  rdp_main_loop(void) Line 723  rdp_main_loop(void)
723                                  process_data_pdu(s);                                  process_data_pdu(s);
724                                  break;                                  break;
725    
726                            case 0:
727                                    break;
728    
729                          default:                          default:
730                                  unimpl("PDU %d\n", type);                                  unimpl("PDU %d\n", type);
731                  }                  }

Legend:
Removed from v.192  
changed lines
  Added in v.340

  ViewVC Help
Powered by ViewVC 1.1.26