()
| 357 | }; |
| 358 | |
| 359 | function DeflateLoop() { |
| 360 | var last, c, type, i, len; |
| 361 | |
| 362 | do { |
| 363 | /*if((last = readBit())){ |
| 364 | fprintf(errfp, "Last Block: "); |
| 365 | } else { |
| 366 | fprintf(errfp, "Not Last Block: "); |
| 367 | }*/ |
| 368 | last = readBit(); |
| 369 | type = readBits(2); |
| 370 | |
| 371 | switch(type) { |
| 372 | case 0: |
| 373 | if (debug) |
| 374 | util.debug("Stored"); |
| 375 | break; |
| 376 | case 1: |
| 377 | if (debug) |
| 378 | util.debug("Fixed Huffman codes"); |
| 379 | break; |
| 380 | case 2: |
| 381 | if (debug) |
| 382 | util.debug("Dynamic Huffman codes"); |
| 383 | break; |
| 384 | case 3: |
| 385 | if (debug) |
| 386 | util.debug("Reserved block type!!"); |
| 387 | break; |
| 388 | default: |
| 389 | if (debug) |
| 390 | util.debug("Unexpected value " + type); |
| 391 | break; |
| 392 | } |
| 393 | |
| 394 | if(type==0) { |
| 395 | var blockLen, cSum; |
| 396 | |
| 397 | // Stored |
| 398 | byteAlign(); |
| 399 | blockLen = readByte(); |
| 400 | blockLen |= (readByte()<<8); |
| 401 | |
| 402 | cSum = readByte(); |
| 403 | cSum |= (readByte()<<8); |
| 404 | |
| 405 | if(((blockLen ^ ~cSum) & 0xffff)) { |
| 406 | util.debug("BlockLen checksum mismatch"); |
| 407 | } |
| 408 | while(blockLen--) { |
| 409 | c = readByte(); |
| 410 | addBuffer(c); |
| 411 | } |
| 412 | } else if(type==1) { |
| 413 | var j; |
| 414 | |
| 415 | /* Fixed Huffman tables -- fixed decode routine */ |
| 416 | while(1) { |
no test coverage detected