Coverage Report

Created: 2025-11-16 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/upx/src/ui.h
Line
Count
Source
1
/* ui.h -- User Interface
2
3
   This file is part of the UPX executable compressor.
4
5
   Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
6
   Copyright (C) 1996-2025 Laszlo Molnar
7
   All Rights Reserved.
8
9
   UPX and the UCL library are free software; you can redistribute them
10
   and/or modify them under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of
12
   the License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; see the file COPYING.
21
   If not, write to the Free Software Foundation, Inc.,
22
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24
   Markus F.X.J. Oberhumer              Laszlo Molnar
25
   <markus@oberhumer.com>               <ezerotven+github@gmail.com>
26
 */
27
28
#pragma once
29
30
class OutputFile;
31
class PackerBase;
32
33
/*************************************************************************
34
//
35
**************************************************************************/
36
37
class UiPacker final {
38
public:
39
    explicit UiPacker(const PackerBase *);
40
41
public:
42
    virtual ~UiPacker() noexcept;
43
44
    static void uiConfirmUpdate();
45
    static void uiPackTotal();
46
    static void uiUnpackTotal();
47
    static void uiListTotal(bool uncompress = false);
48
    static void uiTestTotal();
49
    static void uiFileInfoTotal();
50
51
    virtual void uiPackStart(const OutputFile *fo);
52
    virtual void uiPackEnd(const OutputFile *fo);
53
    virtual void uiUnpackStart(const OutputFile *fo);
54
    virtual void uiUnpackEnd(const OutputFile *fo);
55
    virtual void uiListStart();
56
    virtual void uiList();
57
    virtual void uiListEnd();
58
    virtual void uiTestStart();
59
    virtual void uiTestEnd();
60
    virtual bool uiFileInfoStart();
61
    virtual void uiFileInfoEnd();
62
63
    // callback
64
    virtual void startCallback(unsigned u_len, unsigned step, int pass, int total_passes);
65
    virtual void firstCallback();
66
    virtual void finalCallback(unsigned u_len, unsigned c_len);
67
    virtual void endCallback();
68
    virtual void endCallback(bool done);
69
0
    virtual upx_callback_t *getCallback() { return &cb; }
70
71
protected:
72
    static void __acc_cdecl progress_callback(upx_callback_t *, unsigned, unsigned);
73
    virtual void doCallback(unsigned isize, unsigned osize);
74
75
protected:
76
    virtual void uiUpdate(upx_off_t fc_len = -1, upx_off_t fu_len = -1);
77
78
public:
79
    static void uiHeader();
80
    static void uiFooter(const char *n);
81
82
    int ui_pass = 0;
83
    int ui_total_passes = 0;
84
85
protected:
86
    virtual void printInfo(int nl = 0);
87
    const PackerBase *const pb; // reference, required
88
89
    // callback
90
    upx_callback_t cb = {};
91
92
    // internal state
93
    struct State;
94
    OwningPointer(State) s = nullptr; // owner
95
96
    // static totals
97
    static unsigned total_files;
98
    static unsigned total_files_done;
99
    static upx_uint64_t total_c_len;
100
    static upx_uint64_t total_u_len;
101
    static upx_uint64_t total_fc_len;
102
    static upx_uint64_t total_fu_len;
103
    static unsigned update_c_len;
104
    static unsigned update_u_len;
105
    static unsigned update_fc_len;
106
    static unsigned update_fu_len;
107
108
private: // UPX conventions
109
    UPX_CXX_DISABLE_ADDRESS(UiPacker)
110
    UPX_CXX_DISABLE_COPY_MOVE(UiPacker)
111
};
112
113
/* vim:set ts=4 sw=4 et: */