Diffstat (limited to 'noncore/apps/opie-reader/ppm_expander.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/ppm_expander.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp index 2a4318b..61ef90e 100644 --- a/noncore/apps/opie-reader/ppm_expander.cpp +++ b/noncore/apps/opie-reader/ppm_expander.cpp | |||
@@ -29,25 +29,25 @@ char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; | |||
29 | ppm_expander::~ppm_expander() { | 29 | ppm_expander::~ppm_expander() { |
30 | if (needppmend) ppm.PPM_End(); | 30 | if (needppmend) ppm.PPM_End(); |
31 | ppm.arith.Arith_DecodeEnd(); | 31 | ppm.arith.Arith_DecodeEnd(); |
32 | if (buf_in!=NULL) delete [] buf_in; | 32 | if (buf_in!=NULL) delete [] buf_in; |
33 | if (buf_out!=NULL) delete [] buf_out; | 33 | if (buf_out!=NULL) delete [] buf_out; |
34 | if (my_read_buf != NULL) delete my_read_buf; | 34 | if (my_read_buf != NULL) delete my_read_buf; |
35 | if (my_file_in != NULL) fclose(my_file_in); | 35 | if (my_file_in != NULL) fclose(my_file_in); |
36 | } | 36 | } |
37 | 37 | ||
38 | int ppm_expander::OpenFile(const char* infile) | 38 | int ppm_expander::OpenFile(const char* infile) |
39 | { | 39 | { |
40 | my_file_in=fopen(infile,"rb"); | 40 | my_file_in=fopen(infile,"rb"); |
41 | my_read_buf = new PPM_ReadBuf(my_file_in); | 41 | my_read_buf = new PPM_ReadBuf(my_file_in, this); |
42 | return home(); | 42 | return home(); |
43 | } | 43 | } |
44 | 44 | ||
45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) | 45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) |
46 | { | 46 | { |
47 | struct stat _stat; | 47 | struct stat _stat; |
48 | fstat(fileno(my_file_in),&_stat); | 48 | fstat(fileno(my_file_in),&_stat); |
49 | file = _stat.st_size; | 49 | file = _stat.st_size; |
50 | text = numblocks*blocksize; | 50 | text = numblocks*blocksize; |
51 | } | 51 | } |
52 | 52 | ||
53 | int ppm_expander::home() | 53 | int ppm_expander::home() |
@@ -98,18 +98,27 @@ int ppm_expander::getch() { | |||
98 | if (curblock >= numblocks) return EOF; | 98 | if (curblock >= numblocks) return EOF; |
99 | int c=ppm.PPM_Decode(); | 99 | int c=ppm.PPM_Decode(); |
100 | if (c == SYM_EOF) | 100 | if (c == SYM_EOF) |
101 | { | 101 | { |
102 | if (++curblock >= numblocks) return EOF; | 102 | if (++curblock >= numblocks) return EOF; |
103 | locate(curblock,0); | 103 | locate(curblock,0); |
104 | c = ppm.PPM_Decode(); | 104 | c = ppm.PPM_Decode(); |
105 | } | 105 | } |
106 | outbytes++; | 106 | outbytes++; |
107 | return (c==SYM_EOF) ? EOF : c; | 107 | return (c==SYM_EOF) ? EOF : c; |
108 | } | 108 | } |
109 | 109 | ||
110 | UINT PPM_ReadBuf::readbuf(UCHAR *buf,UINT len) | ||
111 | { | ||
112 | UINT len1; | ||
113 | parent->unsuspend(); | ||
114 | len1=fread(buf,1,len,my_file_in); | ||
115 | return len1; | ||
116 | } | ||
117 | |||
118 | |||
110 | #ifndef __STATIC | 119 | #ifndef __STATIC |
111 | extern "C" | 120 | extern "C" |
112 | { | 121 | { |
113 | CExpander* newcodec() { return new ppm_expander; } | 122 | CExpander* newcodec() { return new ppm_expander; } |
114 | } | 123 | } |
115 | #endif | 124 | #endif |