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

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

revision 888 by stargo, Sun Mar 6 21:11:18 2005 UTC revision 889 by jdmeijer, Sun Apr 17 23:14:20 2005 UTC
# Line 155  mppc_expand(uint8 * data, uint32 clen, u Line 155  mppc_expand(uint8 * data, uint32 clen, u
155                  /* decode offset  */                  /* decode offset  */
156                  /* length pair    */                  /* length pair    */
157                  walker <<= 1;                  walker <<= 1;
158                  if (--walker_len < 2)                  if (--walker_len < (ctype & RDP_MPPC_BIG ? 3 : 2))
159                  {                  {
160                          if (i >= clen)                          if (i >= clen)
161                                  return -1;                                  return -1;
162                          walker |= (data[i++] & 0xff) << (24 - walker_len);                          walker |= (data[i++] & 0xff) << (24 - walker_len);
163                          walker_len += 8;                          walker_len += 8;
164                  }                  }
165                  /* offset decoding where offset len is:  
166                     -63: 1111 followed by the lower 6 bits of the value                  if (ctype & RDP_MPPC_BIG)
                    64-319: 1110 followed by the lower 8 bits of the value ( value - 64 )  
                    320-8191: 110 followed by the lower 13 bits of the value ( value - 320 )  
                  */  
                 switch (((uint32) walker) >> ((uint32) 30))  
167                  {                  {
168                          case 3: /* - 63 */                          /* offset decoding where offset len is:
169                                  if (walker_len < 8)                             -63: 11111 followed by the lower 6 bits of the value
170                                  {                             64-319: 11110 followed by the lower 8 bits of the value ( value - 64 )
171                                          if (i >= clen)                             320-2367: 1110 followed by lower 11 bits of the value ( value - 320 )
172                                                  return -1;                             2368-65535: 110 followed by lower 16 bits of the value ( value - 2368 )
173                                          walker |= (data[i++] & 0xff) << (24 - walker_len);                           */
174                                          walker_len += 8;                          switch (((uint32) walker) >> ((uint32) 29))
175                                  }                          {
176                                  walker <<= 2;                                  case 7: /* - 63 */
177                                  match_off = ((uint32) walker) >> ((uint32) 26);                                          for (; walker_len < 9; walker_len += 8)
178                                  walker <<= 6;                                          {
179                                  walker_len -= 8;                                                  if (i >= clen)
180                                  break;                                                          return -1;
181                                                    walker |= (data[i++] & 0xff) << (24 - walker_len);
182                                            }
183                                            walker <<= 3;
184                                            match_off = ((uint32) walker) >> ((uint32) 26);
185                                            walker <<= 6;
186                                            walker_len -= 9;
187                                            break;
188    
189                          case 2: /* 64 - 319 */                                  case 6: /* 64 - 319 */
190                                  for (; walker_len < 10; walker_len += 8)                                          for (; walker_len < 11; walker_len += 8)
191                                  {                                          {
192                                          if (i >= clen)                                                  if (i >= clen)
193                                                  return -1;                                                          return -1;
194                                          walker |= (data[i++] & 0xff) << (24 - walker_len);                                                  walker |= (data[i++] & 0xff) << (24 - walker_len);
195                                  }                                          }
196    
197                                  walker <<= 2;                                          walker <<= 3;
198                                  match_off = (((uint32) walker) >> ((uint32) 24)) + 64;                                          match_off = (((uint32) walker) >> ((uint32) 24)) + 64;
199                                  walker <<= 8;                                          walker <<= 8;
200                                  walker_len -= 10;                                          walker_len -= 11;
201                                  break;                                          break;
202    
203                          default:        /* 320 - 8191 */                                  case 5:
204                                  for (; walker_len < 14; walker_len += 8)                                  case 4: /* 320 - 2367 */
205                                  {                                          for (; walker_len < 13; walker_len += 8)
206                                          if (i >= clen)                                          {
207                                                  return -1;                                                  if (i >= clen)
208                                          walker |= (data[i++] & 0xff) << (24 - walker_len);                                                          return -1;
209                                  }                                                  walker |= (data[i++] & 0xff) << (24 - walker_len);
210                                            }
211    
212                                  match_off = (walker >> 18) + 320;                                          walker <<= 2;
213                                  walker <<= 14;                                          match_off = (((uint32) walker) >> ((uint32) 21)) + 320;
214                                  walker_len -= 14;                                          walker <<= 11;
215                                  break;                                          walker_len -= 13;
216                                            break;
217    
218                                    default:        /* 2368 - 65535 */
219                                            for (; walker_len < 17; walker_len += 8)
220                                            {
221                                                    if (i >= clen)
222                                                            return -1;
223                                                    walker |= (data[i++] & 0xff) << (24 - walker_len);
224                                            }
225    
226                                            walker <<= 1;
227                                            match_off = (((uint32) walker) >> ((uint32) 16)) + 2368;
228                                            walker <<= 16;
229                                            walker_len -= 17;
230                                            break;
231                            }
232                    }
233                    else
234                    {
235                            /* offset decoding where offset len is:
236                               -63: 1111 followed by the lower 6 bits of the value
237                               64-319: 1110 followed by the lower 8 bits of the value ( value - 64 )
238                               320-8191: 110 followed by the lower 13 bits of the value ( value - 320 )
239                             */
240                            switch (((uint32) walker) >> ((uint32) 30))
241                            {
242                                    case 3: /* - 63 */
243                                            if (walker_len < 8)
244                                            {
245                                                    if (i >= clen)
246                                                            return -1;
247                                                    walker |= (data[i++] & 0xff) << (24 - walker_len);
248                                                    walker_len += 8;
249                                            }
250                                            walker <<= 2;
251                                            match_off = ((uint32) walker) >> ((uint32) 26);
252                                            walker <<= 6;
253                                            walker_len -= 8;
254                                            break;
255    
256                                    case 2: /* 64 - 319 */
257                                            for (; walker_len < 10; walker_len += 8)
258                                            {
259                                                    if (i >= clen)
260                                                            return -1;
261                                                    walker |= (data[i++] & 0xff) << (24 - walker_len);
262                                            }
263    
264                                            walker <<= 2;
265                                            match_off = (((uint32) walker) >> ((uint32) 24)) + 64;
266                                            walker <<= 8;
267                                            walker_len -= 10;
268                                            break;
269    
270                                    default:        /* 320 - 8191 */
271                                            for (; walker_len < 14; walker_len += 8)
272                                            {
273                                                    if (i >= clen)
274                                                            return -1;
275                                                    walker |= (data[i++] & 0xff) << (24 - walker_len);
276                                            }
277    
278                                            match_off = (walker >> 18) + 320;
279                                            walker <<= 14;
280                                            walker_len -= 14;
281                                            break;
282                            }
283                  }                  }
284                  if (walker_len == 0)                  if (walker_len == 0)
285                  {                  {
# Line 289  mppc_expand(uint8 * data, uint32 clen, u Line 360  mppc_expand(uint8 * data, uint32 clen, u
360                          return -1;                          return -1;
361                  }                  }
362                  /* memory areas can overlap - meaning we can't use memXXX functions */                  /* memory areas can overlap - meaning we can't use memXXX functions */
363                  k = (next_offset - match_off) & (RDP_MPPC_DICT_SIZE - 1);                  k = (next_offset - match_off) & (ctype & RDP_MPPC_BIG ? 65535 : 8191);
364                  do                  do
365                  {                  {
366                          dict[next_offset++] = dict[k++];                          dict[next_offset++] = dict[k++];

Legend:
Removed from v.888  
changed lines
  Added in v.889

  ViewVC Help
Powered by ViewVC 1.1.26