1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/*
* ufed-types.h
*
* Created on: 28.01.2013
* Author: Sven Eden
*/
#pragma once
#ifndef UFED_TYPES_H_INCLUDED
#define UFED_TYPES_H_INCLUDED 1
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <curses.h>
#include "ufed-curses-debug.h"
#ifdef HAVE_STDINT_H
# include <stdint.h>
// TODO : else branch
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifndef bool
# ifdef HAVE__BOOL
# define bool _Bool
# else
# define bool int
# endif
#endif
/* =============
* === enums ===
* =============
*/
/** @enum eMask_
* @brief determine which flags are shown concerning masked status
**/
typedef enum eMask_ {
eMask_unmasked,
eMask_both,
eMask_masked
} eMask;
/** @enum eOrder_
* @brief determine whether package lists are shown left or right of the description
**/
typedef enum eOrder_ {
eOrder_left,
eOrder_right
} eOrder;
/** @enum eScope_
* @brief determine whether global, local or all flags are listed
**/
typedef enum eScope_ {
eScope_all,
eScope_global,
eScope_local
} eScope;
/** @enum eState_
* @brief determine whether installed, not installed or all packages are listed
**/
typedef enum eState_ {
eState_all,
eState_installed,
eState_notinstalled
} eState;
/** @enum eWin_
* @brief list of used curses windows
**/
typedef enum eWin_ {
Top = 0,
Left, List, Input, Scrollbar, Right, Bottom,
wCount // always last
} eWin;
/* ===============
* === structs ===
* ===============
*/
/** @struct sDesc_
* @brief Describe one description line
**/
typedef struct sDesc_ {
char* desc; //!< The description line
bool isGlobal; //!< true if this is the global description and setting
bool isInstalled; //!< global: at least one pkg is installed, local: all in *pkg are installed.
char* pkg; //!< affected packages
char stateForced; //!< unforced '-', forced '+' or not set ' ' by *use.force
char stateMasked; //!< unmasked '-', masked '+' or not sed ' ' by *use.mask
char stateDefault; //!< disabled '-', enabled '+' or not set ' ' ebuilds IUSE (installed packages only)
char statePackage; //!< disabled '-', enabled '+' or not set ' ' by profiles package.use
char statePkgUse; //!< disabled '-', enabled '+' or not set ' ' by users package.use
} sDesc;
/** @struct sFlag_
* @brief Describe one flag and its make.conf setting in a doubly linked ring
**/
typedef struct sFlag_ {
int currline; //!< The current line on the screen this flag starts
sDesc* desc; //!< variable array of sDesc structs
bool globalForced; //!< true if the first global description is force enabled.
bool globalMasked; //!< true if the first global description is mask enabled.
int listline; //!< The fixed line within the full list this flag starts
char* name; //!< Name of the flag or NULL for help lines
int ndesc; //!< number of description lines
struct
sFlag_* next; //!< Next flag in the doubly linked ring
struct
sFlag_* prev; //!< Previous flag in the doubly linked ring
char stateConf; //!< disabled '-', enabled '+' or not set ' ' by make.conf
char stateDefault; //!< disabled '-', enabled '+' or not set ' ' by make.defaults
} sFlag;
/** @struct sListStats_
* @brief hold stats of the flag list like line counts
**/
typedef struct sListStats_ {
int lineCountGlobal;
int lineCountGlobalInstalled;
int lineCountLocal;
int lineCountLocalInstalled;
int lineCountMasked;
int lineCountMaskedInstalled;
} sListStats;
/** @struct sKey_
* @brief describe one main control key
**/
typedef struct sKey_ {
int key; //!< curses key or -1 if no key shall be used
const char *descr; //!< Help text to display
size_t length; //!< length of the description
int row; //!< On which row this key is to be displayed, 0 or 1
} sKey;
/** @struct sWindow_
* @brief describe one curses window dimensions
**/
typedef struct sWindow_ {
WINDOW *win;
const int top, left, height, width;
} sWindow;
/* =======================================
* === public functions handling types ===
* =======================================
*/
sFlag* addFlag (sFlag** root, const char* name, int line, int ndesc, const char state[2]);
size_t addFlagDesc (sFlag* flag, const char* pkg, const char* desc, const char state[6]);
void addLineStats (const sFlag* flag, sListStats* stats);
void destroyFlag (sFlag** root, sFlag** flag);
void genFlagStats (sFlag* flag);
int getFlagHeight(const sFlag* flag);
bool isDescForced (const sFlag* flag, int idx);
bool isDescLegal (const sFlag* flag, int idx);
bool isDescMasked (const sFlag* flag, int idx);
bool isFlagLegal (const sFlag* flag);
#endif /* UFED_TYPES_H_INCLUDED */
|