/[gentoo-projects]/portage-utils/qxpak.c
Gentoo

Diff of /portage-utils/qxpak.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.16 Revision 1.17
1/* 1/*
2 * Copyright 2005-2007 Gentoo Foundation 2 * Copyright 2005-2007 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2 3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/portage-utils/Attic/qxpak.c,v 1.16 2007/05/24 14:47:18 solar Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/portage-utils/Attic/qxpak.c,v 1.17 2010/01/13 13:52:15 vapier Exp $
5 * 5 *
6 * Copyright 2005-2007 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
44 "Create an archive of a directory/files", 44 "Create an archive of a directory/files",
45 "Change to specified directory", 45 "Change to specified directory",
46 "Write files to stdout", 46 "Write files to stdout",
47 COMMON_OPTS_HELP 47 COMMON_OPTS_HELP
48}; 48};
49static const char qxpak_rcsid[] = "$Id: qxpak.c,v 1.16 2007/05/24 14:47:18 solar Exp $"; 49static const char qxpak_rcsid[] = "$Id: qxpak.c,v 1.17 2010/01/13 13:52:15 vapier Exp $";
50#define qxpak_usage(ret) usage(ret, QXPAK_FLAGS, qxpak_long_opts, qxpak_opts_help, lookup_applet_idx("qxpak")) 50#define qxpak_usage(ret) usage(ret, QXPAK_FLAGS, qxpak_long_opts, qxpak_opts_help, lookup_applet_idx("qxpak"))
51 51
52typedef struct { 52typedef struct {
53 FILE *fp; 53 FILE *fp;
54 int index_len; 54 int index_len;
201 201
202 x = _xpak_open(file); 202 x = _xpak_open(file);
203 if (!x) return; 203 if (!x) return;
204 204
205 x->index = buf; 205 x->index = buf;
206 x->data = ext;
207 206
208 assert((size_t)x->index_len < sizeof(buf)); 207 assert((size_t)x->index_len < sizeof(buf));
209 in = fread(x->index, 1, x->index_len, x->fp); 208 in = fread(x->index, 1, x->index_len, x->fp);
210 if (in != x->index_len) 209 if (in != x->index_len)
211 err("index chunk: read %i bytes, wanted %i bytes", (int)in, (int)x->index_len); 210 err("index chunk: read %i bytes, wanted %i bytes", (int)in, x->index_len);
212 211
213 assert((size_t)x->data_len < sizeof(ext)); 212 /* the xpak may be large (like when it has CONTENTS) #300744 */
213 x->data = (size_t)x->data_len < sizeof(ext) ? ext : malloc(x->data_len);
214 in = fread(x->data, 1, x->data_len, x->fp); 214 in = fread(x->data, 1, x->data_len, x->fp);
215 if (in != x->data_len) 215 if (in != x->data_len)
216 err("data chunk: read %i bytes, wanted %i bytes", (int)in, (int)x->data_len); 216 err("data chunk: read %i bytes, wanted %i bytes", (int)in, x->data_len);
217 217
218 _xpak_walk_index(x, argc, argv, &_xpak_extract_callback); 218 _xpak_walk_index(x, argc, argv, &_xpak_extract_callback);
219 219
220 _xpak_close(x); 220 _xpak_close(x);
221
222 if (x->data != ext)
223 free(x->data);
221} 224}
222 225
223void _xpak_add_file(const char *filename, struct stat *st, FILE *findex, int *index_len, FILE *fdata, int *data_len); 226void _xpak_add_file(const char *filename, struct stat *st, FILE *findex, int *index_len, FILE *fdata, int *data_len);
224void _xpak_add_file(const char *filename, struct stat *st, FILE *findex, int *index_len, FILE *fdata, int *data_len) 227void _xpak_add_file(const char *filename, struct stat *st, FILE *findex, int *index_len, FILE *fdata, int *data_len)
225{ 228{

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.20