root/branches/3.00/src/compress.cc

Revision 644, 2.4 kB (checked in by fujii, 4 years ago)

Add new netinstall source.

Line 
1 /*
2  * Copyright (c) 2001, Robert Collins.
3  *
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  *
9  *     A copy of the GNU General Public License can be found at
10  *     http://www.gnu.org/
11  *
12  * Written by Robert Collins  <rbtcollins@hotmail.com>
13  *
14  */
15
16 /* Archive IO operations
17  */
18
19 #if 0
20 static const char *cvsid =
21   "\n%%% $Id: compress.cc,v 2.3 2004/10/25 17:06:08 maxb Exp $\n";
22 #endif
23
24 #include "win32.h"
25 #include <stdio.h>
26 #include "log.h"
27
28 #include "io_stream.h"
29 #include "compress.h"
30 #include "zlib/zlib.h"
31 #include "compress_gz.h"
32 #include "compress_bz.h"
33
34 /* In case you are wondering why the file magic is not in one place:
35  * It could be. But there is little (any?) benefit.
36  * What is important is that the file magic required for any _task_ is centralised.
37  * One such task is identifying compresss
38  *
39  * to federate into each class one might add a magic parameter to the constructor, which
40  * the class could test itself.
41  */
42
43 #define longest_magic 3
44
45 io_stream *
46 compress::decompress (io_stream * original)
47 {
48   if (!original)
49     return NULL;
50   char magic[longest_magic];
51   if (original->peek (magic, longest_magic) > 0)
52     {
53       if (memcmp (magic, "\037\213", 2) == 0)
54         {
55           /* tar */
56           compress_gz *rv = new compress_gz (original);
57           if (!rv->error ())
58             return rv;
59           return NULL;
60         }
61       else if (memcmp (magic, "BZh", 3) == 0)
62         {
63           compress_bz *rv = new compress_bz (original);
64           if (!rv->error ())
65             return rv;
66           return NULL;
67         }
68     }
69   return NULL;
70 }
71
72 ssize_t
73 compress::read (void *buffer, size_t len)
74 {
75   log (LOG_TIMESTAMP, "compress::read called");
76   return 0;
77 }
78
79 ssize_t
80 compress::write (void *buffer, size_t len)
81 {
82   log (LOG_TIMESTAMP, "compress::write called");
83   return 0;
84 }
85
86 ssize_t
87 compress::peek (void *buffer, size_t len)
88 {
89   log (LOG_TIMESTAMP, "compress::peek called");
90   return 0;
91 }
92
93 long
94 compress::tell ()
95 {
96   log (LOG_TIMESTAMP, "bz::tell called");
97   return 0;
98 }
99
100 int
101 compress::error ()
102 {
103   log (LOG_TIMESTAMP, "compress::error called");
104   return 0;
105 }
106
107 const char *
108 compress::next_file_name ()
109 {
110   log (LOG_TIMESTAMP, "compress::next_file_name called");
111   return NULL;
112 }
113
114 compress::~compress ()
115 {
116   log (LOG_BABBLE, "compress::~compress called");
117   return;
118 }
Note: See TracBrowser for help on using the browser.