Regenerate Japanese resources
[cygwin-setup.git] / archive_tar.h
blobda8eaa667f80cb7be889033be80d9c50e27ca8b3
1 /*
2 * Copyright (c) 2000, Red Hat, Inc.
3 * Copyright (c) 2002, Robert Collins.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * A copy of the GNU General Public License can be found at
11 * http://www.gnu.org/
13 * Written by DJ Delorie <dj@cygnus.com>
14 * Made OOP by R Collins <rbtcollins@hotmail.com>
18 #ifndef SETUP_ARCHIVE_TAR_H
19 #define SETUP_ARCHIVE_TAR_H
21 #include "io_stream.h"
22 #include "archive.h"
23 #include "win32.h"
25 typedef struct
27 char name[100]; /* 0 */
28 char mode[8]; /* 100 */
29 char uid[8]; /* 108 */
30 char gid[8]; /* 116 */
31 char size[12]; /* 124 */
32 char mtime[12]; /* 136 */
33 char chksum[8]; /* 148 */
34 char typeflag; /* 156 */
35 char linkname[100]; /* 157 */
36 char magic[6]; /* 257 */
37 char version[2]; /* 263 */
38 char uname[32]; /* 265 */
39 char gname[32]; /* 297 */
40 char devmajor[8]; /* 329 */
41 char devminor[8]; /* 337 */
42 char prefix[155]; /* 345 */
43 char junk[12]; /* 500 */
45 tar_header_type;
47 typedef struct tar_map_result_type_s
49 struct tar_map_result_type_s *next;
50 std::string stored_name;
51 std::string mapped_name;
53 tar_map_result_type;
55 class tar_state
57 public:
58 tar_state ():lasterr (0), eocf (0), have_longname ('\0'), file_offset (0),
59 file_length (0), header_read (0)
61 parent = NULL;
62 filename[0] = '\0';
63 tar_map_result = NULL;
65 io_stream *parent;
66 int lasterr;
67 int eocf;
68 char have_longname;
69 bool have_longlink;
70 /* where in the current file are we? */
71 off_t file_offset;
72 off_t file_length;
73 int header_read;
74 tar_header_type tar_header;
75 char filename[CYG_PATH_MAX + 512];
76 char linkname[CYG_PATH_MAX + 512];
77 tar_map_result_type *tar_map_result;
80 class archive_tar_file:public io_stream
82 private:
83 bool read_something;
84 public:
85 archive_tar_file (tar_state &);
86 virtual ssize_t read (void *buffer, size_t len);
87 /* provide data to (double duh!) */
88 virtual ssize_t write (const void *buffer, size_t len);
89 /* read data without removing it from the class's internal buffer */
90 virtual ssize_t peek (void *buffer, size_t len);
91 virtual off_t tell ();
92 virtual off_t seek (off_t where, io_stream_seek_t whence);
93 /* try guessing this one */
94 virtual int error ();
95 virtual time_t get_mtime ();
96 virtual mode_t get_mode ();
97 virtual size_t get_size () {return state.file_length;};
98 virtual int set_mtime (time_t) { return 1; };
99 virtual ~ archive_tar_file ();
100 private:
101 tar_state & state;
104 class archive_tar:public archive
106 public:
107 archive_tar (io_stream * original);
108 virtual io_stream *extract_file ();
109 /* read data (duh!) */
110 virtual ssize_t read (void *buffer, size_t len);
111 /* provide data to (double duh!) */
112 virtual ssize_t write (const void *buffer, size_t len);
113 /* read data without removing it from the class's internal buffer */
114 virtual ssize_t peek (void *buffer, size_t len);
115 virtual off_t tell ();
116 virtual off_t seek (off_t where, io_stream_seek_t whence);
117 /* try guessing this one */
118 virtual int error ();
119 /* Find out the next stream name -
120 * ie for foo.tar.gz, at offset 0, next_file_name = foo.tar
121 * for foobar that is an compress, next_file_name is the next
122 * extractable filename.
124 virtual const std::string next_file_name ();
125 virtual archive_file_t next_file_type ();
126 /* returns the mtime of the archive file, not of the current file */
127 virtual time_t get_mtime ();
128 virtual mode_t get_mode ();
129 /* nonsense for a tarball */
130 virtual size_t get_size () {return 0;};
131 /* only of use when we support writing to tar */
132 virtual int set_mtime (time_t) { return 1; };
133 virtual const std::string linktarget ();
134 virtual int skip_file ();
135 /* if you are still needing these hints... give up now! */
136 virtual ~ archive_tar ();
137 archive_tar& operator= (const archive_tar &);
138 archive_tar (archive_tar const &);
139 private:
140 archive_tar ()
143 tar_state state;
144 unsigned int archive_children;
147 /* Only one tarfile may be open at a time. gzipped files handled
148 automatically */
150 /* returns zero on success, nonzero on failure */
151 //int tar_open (const char *pathname);
153 /* pass adjusted path, returns zero on success, nonzero on failure */
154 //int tar_read_file (char *path);
157 #if 0
158 /* pass path to tar file and from/to pairs for path prefix (NULLs at
159 end , returns zero if completely successful, nonzero (counts
160 errors) on failure */
161 int tar_auto (char *pathname, char **map);
162 #endif
165 //int tar_mkdir_p (int isadir, char *path);
168 extern int _tar_verbose;
169 extern FILE * _tar_vfile;
172 #endif /* SETUP_ARCHIVE_TAR_H */