From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9856E1382C5 for ; Sun, 17 May 2020 12:35:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CA30EE08F6; Sun, 17 May 2020 12:35:44 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B05CBE08F6 for ; Sun, 17 May 2020 12:35:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CFFFA34F89F for ; Sun, 17 May 2020 12:35:43 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3B69A18F for ; Sun, 17 May 2020 12:35:42 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1589709814.0d354ac463a11013068f61cb7c1db987048f2a12.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/xpak.c X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 0d354ac463a11013068f61cb7c1db987048f2a12 X-VCS-Branch: master Date: Sun, 17 May 2020 12:35:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 10315748-cfc5-4526-b17d-5c0bd9c7ce8a X-Archives-Hash: b6846657cc96996b6181ee0d659acaa8 commit: 0d354ac463a11013068f61cb7c1db987048f2a12 Author: Fabian Groffen gentoo org> AuthorDate: Sun May 17 10:03:34 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun May 17 10:03:34 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0d354ac4 xpak: change xpak_process to return start position of XPAKPACK Allow to get the size of the archive by a call to xpak_process, or failure if size is -1. Signed-off-by: Fabian Groffen gentoo.org> libq/xpak.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libq/xpak.c b/libq/xpak.c index 59c541d..0e8bd7e 100644 --- a/libq/xpak.c +++ b/libq/xpak.c @@ -1,5 +1,5 @@ /* - * Copyright 2005-2019 Gentoo Foundation + * Copyright 2005-2020 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 * * Copyright 2005-2010 Ned Ludd - @@ -46,9 +46,11 @@ typedef struct { void *ctx; FILE *fp; + unsigned int xpakstart; /* offset in the file for XPAKPACK */ unsigned int index_len; unsigned int data_len; - char *index, *data; + char *index; + char *data; } _xpak_archive; static void _xpak_walk_index( @@ -119,6 +121,7 @@ static _xpak_archive *_xpak_open(const int fd) if (fseek(ret.fp, -(xpaklen + TBZ2_FOOTER_LEN), SEEK_END) == 0) { + ret.xpakstart = (unsigned int)ftell(ret.fp); if (fread(buf, 1, XPAK_START_LEN, ret.fp) != XPAK_START_LEN) goto close_and_ret; if (memcmp(buf, XPAK_START_MSG, XPAK_START_MSG_LEN) == 0) @@ -129,6 +132,7 @@ static _xpak_archive *_xpak_open(const int fd) warn("Not an xpak file"); goto close_and_ret; } + ret.xpakstart = 0; /* pure xpak file */ setup_lens: /* calc index and data sizes */ @@ -165,7 +169,7 @@ xpak_process_fd( x = _xpak_open(fd); if (!x) - return 1; + return -1; x->ctx = ctx; x->index = buf; @@ -196,7 +200,7 @@ xpak_process_fd( if (get_data) free(x->data); - return 0; + return x->xpakstart; } int @@ -215,7 +219,7 @@ xpak_process( return -1; ret = xpak_process_fd(fd, get_data, ctx, func); - if (ret != 0) + if (ret < 0) warn("Unable to open file '%s'", file); return ret;