Diffstat (limited to 'noncore/apps/opie-reader/plucker_base.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/plucker_base.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index 849edfc..302ac73 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -660,97 +660,97 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) | |||
660 | { | 660 | { |
661 | return jmin; | 661 | return jmin; |
662 | } | 662 | } |
663 | gotorecordnumber(jmax); | 663 | gotorecordnumber(jmax); |
664 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 664 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
665 | luid = thishdr_uid; | 665 | luid = thishdr_uid; |
666 | //qDebug("jmax at end:%u,%u", jmax, luid); | 666 | //qDebug("jmax at end:%u,%u", jmax, luid); |
667 | if (luid == urlid) | 667 | if (luid == urlid) |
668 | { | 668 | { |
669 | return jmax; | 669 | return jmax; |
670 | } | 670 | } |
671 | //qDebug("Couldn't find %u", urlid); | 671 | //qDebug("Couldn't find %u", urlid); |
672 | return 0; // Not found! | 672 | return 0; // Not found! |
673 | } | 673 | } |
674 | 674 | ||
675 | #include <qnamespace.h> | 675 | #include <qnamespace.h> |
676 | 676 | ||
677 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 677 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
678 | { | 678 | { |
679 | unsigned short sz = 0; | 679 | unsigned short sz = 0; |
680 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 680 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
681 | { | 681 | { |
682 | sz++; | 682 | sz++; |
683 | } | 683 | } |
684 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); | 684 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); |
685 | unsigned char* newdata = new unsigned char[newlen]; | 685 | unsigned char* newdata = new unsigned char[newlen]; |
686 | unsigned char* pdata = newdata; | 686 | unsigned char* pdata = newdata; |
687 | memcpy(newdata, src, srclen); | 687 | memcpy(newdata, src, srclen); |
688 | newdata += srclen; | 688 | newdata += srclen; |
689 | memcpy(newdata, &sz, sizeof(sz)); | 689 | memcpy(newdata, &sz, sizeof(sz)); |
690 | newdata += sizeof(sz); | 690 | newdata += sizeof(sz); |
691 | #ifdef _WINDOWS | 691 | #ifdef _WINDOWS |
692 | for (it = visited.begin(); it != visited.end(); it++) | 692 | for (it = visited.begin(); it != visited.end(); it++) |
693 | #else | 693 | #else |
694 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 694 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
695 | #endif | 695 | #endif |
696 | { | 696 | { |
697 | unsigned long t = *it; | 697 | unsigned long t = *it; |
698 | //qDebug("[%u]", t); | 698 | //qDebug("[%u]", t); |
699 | memcpy(newdata, &t, sizeof(t)); | 699 | memcpy(newdata, &t, sizeof(t)); |
700 | newdata += sizeof(t); | 700 | newdata += sizeof(t); |
701 | } | 701 | } |
702 | m_nav.setSaveData(data, len, pdata, newlen); | 702 | m_nav.setSaveData(data, len, pdata, newlen); |
703 | delete [] pdata; | 703 | delete [] pdata; |
704 | } | 704 | } |
705 | 705 | ||
706 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) | 706 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) |
707 | { | 707 | { |
708 | unsigned short sz; | 708 | unsigned short sz = 0; |
709 | if (srclen >= sizeof(sz)) | 709 | if (srclen >= sizeof(sz)) |
710 | { | 710 | { |
711 | memcpy(&sz, src, sizeof(sz)); | 711 | memcpy(&sz, src, sizeof(sz)); |
712 | src += sizeof(sz); | 712 | src += sizeof(sz); |
713 | srclen -= sizeof(sz); | 713 | srclen -= sizeof(sz); |
714 | } | 714 | } |
715 | for (int i = 0; i < sz; i++) | 715 | for (int i = 0; i < sz; i++) |
716 | { | 716 | { |
717 | unsigned long t; | 717 | unsigned long t; |
718 | if (srclen >= sizeof(t)) | 718 | if (srclen >= sizeof(t)) |
719 | { | 719 | { |
720 | memcpy(&t, src, sizeof(t)); | 720 | memcpy(&t, src, sizeof(t)); |
721 | // qDebug("[%u]", t); | 721 | // qDebug("[%u]", t); |
722 | visited.push_front(t); | 722 | visited.push_front(t); |
723 | src += sizeof(t); | 723 | src += sizeof(t); |
724 | srclen -= sizeof(t); | 724 | srclen -= sizeof(t); |
725 | } | 725 | } |
726 | else | 726 | else |
727 | { | 727 | { |
728 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); | 728 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); |
729 | break; | 729 | break; |
730 | } | 730 | } |
731 | } | 731 | } |
732 | m_nav.putSaveData(src, srclen); | 732 | m_nav.putSaveData(src, srclen); |
733 | } | 733 | } |
734 | 734 | ||
735 | int CPlucker_base::OpenFile(const char *src) | 735 | int CPlucker_base::OpenFile(const char *src) |
736 | { | 736 | { |
737 | qDebug("plucker openfile:%s", src); | 737 | qDebug("plucker openfile:%s", src); |
738 | m_lastBreak = 0; | 738 | m_lastBreak = 0; |
739 | if (!Cpdb::openpdbfile(src)) | 739 | if (!Cpdb::openpdbfile(src)) |
740 | { | 740 | { |
741 | return -1; | 741 | return -1; |
742 | } | 742 | } |
743 | 743 | ||
744 | if (!CorrectDecoder()) return -1; | 744 | if (!CorrectDecoder()) return -1; |
745 | 745 | ||
746 | gotorecordnumber(0); | 746 | gotorecordnumber(0); |
747 | fread(&hdr0, 1, 6, fin); | 747 | fread(&hdr0, 1, 6, fin); |
748 | qDebug("Compression type:%u", ntohs(hdr0.version)); | 748 | qDebug("Compression type:%u", ntohs(hdr0.version)); |
749 | 749 | ||
750 | 750 | ||
751 | switch (ntohs(hdr0.version)) | 751 | switch (ntohs(hdr0.version)) |
752 | { | 752 | { |
753 | case 2: | 753 | case 2: |
754 | m_decompress = UnZip; | 754 | m_decompress = UnZip; |
755 | break; | 755 | break; |
756 | case 1: | 756 | case 1: |