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 | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp index ea5b955..2a4318b 100644 --- a/noncore/apps/opie-reader/ppm_expander.cpp +++ b/noncore/apps/opie-reader/ppm_expander.cpp | |||
@@ -1,59 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * Interface pour le programme de compression | 2 | * Interface pour le programme de compression |
3 | * (c) 1995 Fabrice Bellard | 3 | * (c) 1995 Fabrice Bellard |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | //#include <unistd.h> | 7 | //#include <unistd.h> |
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <time.h> | 10 | #include <time.h> |
11 | #include "static.h" | ||
12 | 11 | ||
13 | /*************************************************************************** | 12 | /*************************************************************************** |
14 | * Interface avec les routines de compression | 13 | * Interface avec les routines de compression |
15 | */ | 14 | */ |
16 | 15 | ||
17 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ | 16 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ |
18 | 17 | ||
19 | #define METHOD_STORE 0 | 18 | #define METHOD_STORE 0 |
20 | #define METHOD_PPM 1 | 19 | #define METHOD_PPM 1 |
21 | 20 | ||
22 | 21 | ||
23 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ | 22 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ |
24 | /* signature en début de fichier */ | 23 | /* signature en début de fichier */ |
25 | #define STAT_MAGIC_SIZE 4 | 24 | #define STAT_MAGIC_SIZE 4 |
26 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; | 25 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; |
27 | 26 | ||
28 | #include "ppm_expander.h" | 27 | #include "ppm_expander.h" |
29 | 28 | ||
30 | ppm_expander::~ppm_expander() { | 29 | ppm_expander::~ppm_expander() { |
31 | if (needppmend) ppm.PPM_End(); | 30 | if (needppmend) ppm.PPM_End(); |
32 | ppm.arith.Arith_DecodeEnd(); | 31 | ppm.arith.Arith_DecodeEnd(); |
33 | if (buf_in!=NULL) delete [] buf_in; | 32 | if (buf_in!=NULL) delete [] buf_in; |
34 | if (buf_out!=NULL) delete [] buf_out; | 33 | if (buf_out!=NULL) delete [] buf_out; |
35 | if (my_read_buf != NULL) delete my_read_buf; | 34 | if (my_read_buf != NULL) delete my_read_buf; |
36 | if (my_file_in != NULL) fclose(my_file_in); | 35 | if (my_file_in != NULL) fclose(my_file_in); |
37 | } | 36 | } |
38 | 37 | ||
39 | int ppm_expander::OpenFile(const char* infile) | 38 | int ppm_expander::OpenFile(const char* infile) |
40 | { | 39 | { |
41 | my_file_in=fopen(infile,"rb"); | 40 | my_file_in=fopen(infile,"rb"); |
42 | my_read_buf = new PPM_ReadBuf(my_file_in); | 41 | my_read_buf = new PPM_ReadBuf(my_file_in); |
43 | return home(); | 42 | return home(); |
44 | } | 43 | } |
45 | 44 | ||
46 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) | 45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) |
47 | { | 46 | { |
48 | struct stat _stat; | 47 | struct stat _stat; |
49 | fstat(fileno(my_file_in),&_stat); | 48 | fstat(fileno(my_file_in),&_stat); |
50 | file = _stat.st_size; | 49 | file = _stat.st_size; |
51 | text = numblocks*blocksize; | 50 | text = numblocks*blocksize; |
52 | } | 51 | } |
53 | 52 | ||
54 | int ppm_expander::home() | 53 | int ppm_expander::home() |
55 | { | 54 | { |
56 | fseek(my_file_in,0, SEEK_SET); | 55 | fseek(my_file_in,0, SEEK_SET); |
57 | unsigned char header[STAT_MAGIC_SIZE]; | 56 | unsigned char header[STAT_MAGIC_SIZE]; |
58 | size_t len=fread(header,1,STAT_MAGIC_SIZE,my_file_in); | 57 | size_t len=fread(header,1,STAT_MAGIC_SIZE,my_file_in); |
59 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { | 58 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { |