pmt: initial 2.9.6 release [source]

This commit is contained in:
2024-10-26 11:03:52 +03:00
parent ce7fcae4a4
commit 638062c42f
43 changed files with 672 additions and 10601 deletions

View File

@@ -18,84 +18,84 @@
#pragma once
#define deprecated_opt 1
#define changed_opt 2
#define end_depr_pointer 0
#define not_changed 0
#define not_changed_long nullptr
/* annotated macros */
#define DeprecatedOption 1
#define ChangedOption 2
#define EndDeprcationPoint 0
#define NotChanged 0
#define NotChangedLong nullptr
/* versions */
#define v150 "1.5.0"
#define v160 "1.6.0"
#define v170 "1.7.0"
#define v180 "1.8.0"
#define v190 "1.9.0"
#define v200 "2.0.0"
#define v210 "2.1.0"
#define v220 "2.2.0"
#define v230 "2.3.0"
#define v240 "2.4.0"
#define v250 "2.5.0"
#define v260 "2.6.0"
#define v270 "2.7.0"
#define v280 "2.8.0"
#define v290 "2.9.0"
#define vUNK nullptr
#define v150 "1.5.0"
#define v160 "1.6.0"
#define v170 "1.7.0"
#define v180 "1.8.0"
#define v190 "1.9.0"
#define v200 "2.0.0"
#define v210 "2.1.0"
#define v220 "2.2.0"
#define v230 "2.3.0"
#define v240 "2.4.0"
#define v250 "2.5.0"
#define v260 "2.6.0"
#define v270 "2.7.0"
#define v280 "2.8.0"
#define v290 "2.9.0"
#define v291 "2.9.1"
#define v296 "2.9.6"
#define vUNKNOWN nullptr
struct pmt_deprecates {
int depr_type;
int option;
int option_new;
const char* option_long;
const char* option_long_new;
const char* depr_version;
struct DeprecationVarTab {
const int DeprecationType;
const int Option;
const int Option_new;
const char* Option_long;
const char* Option_long_new;
const char* DeprecatedOnVersion;
};
static struct pmt_deprecates depr_table[] = {
{deprecated_opt, 'b', not_changed, "backup", not_changed_long, v210},
{deprecated_opt, 'F', not_changed, "flash", not_changed_long, v210},
{deprecated_opt, 'r', not_changed, "format", not_changed_long, v210},
{deprecated_opt, 'L', not_changed, "license", not_changed_long, v250},
{changed_opt, 'D', 'p', "list", not_changed_long, v210},
{changed_opt, 'c', 'P', "context", "search-path", v290},
{end_depr_pointer, not_changed, not_changed, not_changed_long, not_changed_long, vUNK}
static struct DeprecationVarTab DeprecationTable[] = {
{DeprecatedOption, 'b', NotChanged, "backup", NotChangedLong, v210},
{DeprecatedOption, 'F', NotChanged, "flash", NotChangedLong, v210},
{DeprecatedOption, 'r', NotChanged, "format", NotChangedLong, v210},
{DeprecatedOption, 'L', NotChanged, "license", NotChangedLong, v250},
{ChangedOption, 'D', 'p', "list", NotChangedLong, v210},
{ChangedOption, 'c', 'P', "context", "search-path", v290},
{EndDeprcationPoint, NotChanged, NotChanged, NotChangedLong, NotChanged, vUNKNOWN}
};
static void
__process_deprecated_opts(int opt, const string& opt_long, const char* depr_msg)
__process_deprecated_opts(int Opt, const string& OptionLong, const char* DeprecationMsg)
{
static string long_e_msg;
string LongErrMsg = (OptionLong.empty()) ? PartitionManager::Display::UsingDispString->not_changed_opt : OptionLong;
if (opt_long.empty())
long_e_msg = PartitionManager::Display::UsingDispString->not_changed_opt;
else
long_e_msg = opt_long;
for (int optctrl = 0; depr_table[optctrl].depr_type != 0; optctrl++)
for (int optctrl = 0; DeprecationTable[optctrl].DeprecationType != 0; optctrl++)
{
if (depr_table[optctrl].depr_type == 1)
if (DeprecationTable[optctrl].DeprecationType == 1)
{
if (opt == depr_table[optctrl].option || strcmp(opt_long.c_str(), depr_table[optctrl].option_long) == 0)
{
LOGD("%s [%s]: -%c (%s): %s\n", PartitionManager::Display::UsingDispString->depr_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, depr_table[optctrl].option_long, depr_msg);
exit(1);
}
if (Opt == DeprecationTable[optctrl].Option || strcmp(OptionLong.c_str(), DeprecationTable[optctrl].Option_long) == 0)
LOGD("%s [%s]: -%c (%s): %s\n",
PartitionManager::Display::UsingDispString->depr_opt_str,
DeprecationTable[optctrl].DeprecatedOnVersion,
(char)DeprecationTable[optctrl].Option,
DeprecationTable[optctrl].Option_long,
DeprecationMsg); exit(1);
}
else if (depr_table[optctrl].depr_type == 2)
else if (DeprecationTable[optctrl].DeprecationType == 2)
{
if (opt == depr_table[optctrl].option || strcmp(opt_long.c_str(), depr_table[optctrl].option_long) == 0)
{
LOGD("%s [%s]: -%c (%s): %s\n", PartitionManager::Display::UsingDispString->switched_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, long_e_msg.c_str(), depr_msg);
exit(1);
}
if (Opt == DeprecationTable[optctrl].Option || strcmp(OptionLong.c_str(), DeprecationTable[optctrl].Option_long) == 0)
LOGD("%s [%s]: -%c (%s): %s\n",
PartitionManager::Display::UsingDispString->switched_opt_str,
DeprecationTable[optctrl].DeprecatedOnVersion,
(char)DeprecationTable[optctrl].Option,
LongErrMsg.c_str(),
DeprecationMsg); exit(1);
}
}
}
#define DEPR_HANDLE(x, y, z) \
__process_deprecated_opts(x, y, z)
#define DEPR_HANDLE __process_deprecated_opts
/* end of code */

View File

@@ -18,8 +18,6 @@
#pragma once
extern "C" {
int mke2fs_main(int argc, char* argv[]);
}
extern "C" int mke2fs_main(int argc, char* argv[]);
/* end of code */

View File

@@ -18,10 +18,6 @@
#pragma once
namespace PartitionManager {
namespace Functions {
void DisplayHelp(void);
}
}
namespace PartitionManager { void DisplayHelp(void); }
/* end */

View File

@@ -29,7 +29,6 @@
#include <string>
#include <cstring>
#include <cstdarg>
#ifdef IS_MAIN
#include <clocale>
#endif
@@ -54,8 +53,6 @@
#endif
#ifdef INC_TOOLS_REQS
#include <sys/vfs.h>
typedef unsigned short ushort_t;
#endif
#ifdef INC_LIBGEN
#include <libgen.h>
@@ -71,11 +68,38 @@ typedef enum {
LOG_LEVEL_DEBUG
} LogLevel;
/* config structure */
struct Configuration {
bool UseLogical;
bool UseCustomSearchPath;
bool UsesSlots;
bool UsesLogical;
bool OnlyViewSize;
bool SilentEnabled;
bool FlashMode;
bool BackupMode;
bool FormatMode;
bool PartSizeViewMode;
bool ForceMode;
bool VerboseMode;
bool InstalledOnTermux;
};
/**
* Fast error processing without errno entry
* Fast error processing without errno entry
* but errno can be given in the entrance
*/
extern "C" char* strqerror(int errno_macro = errno);
extern "C" char* strqerror(int __qerrno = errno);
/**
* ushort_t = unsigned short type
*/
typedef unsigned short ushort_t;
/**
* bool type configurations
*/
extern struct Configuration Config;
/* create a special namespace */
namespace PartitionManager {
@@ -94,22 +118,6 @@ namespace PartitionManager {
extern int PartSizeViewType;
} /* namespace Integers */
namespace Booleans {
extern bool UseLogical;
extern bool UseCustomSearchPath;
extern bool UsesSlots;
extern bool UsesLogical;
extern bool OnlyViewSize;
extern bool SilentEnabled;
extern bool FlashMode;
extern bool BackupMode;
extern bool FormatMode;
extern bool PartSizeViewMode;
extern bool ForceMode;
extern bool VerboseMode;
extern bool InstalledOnTermux;
} /* namespace Booleans */
namespace Display {
extern struct langdb_general* UsingDispString;
extern struct langdb_docs* UsingDocDispString;
@@ -119,39 +127,37 @@ namespace PartitionManager {
extern struct langdb_docs LangDocTr;
} /* namespace Display */
namespace Functions {
int ListPartitions(void);
int GetState(const string& filepath, const string& stype = "file");
int Start(unsigned short progress_code);
void SetLanguage(const string& lang, unsigned short null_conf_stat);
void DisplayLog(LogLevel status, const char* fmt, ...);
void DisplayVerboseLog(LogLevel status, const char* fmt, ...);
void CheckDevPoint(void);
void CheckRoot(void);
bool CleanSWPoint(void);
bool LoadLanguage(void);
} /* namespace Functions */
/* functions */
int ListPartitions(void);
int GetState(const string& filepath, const string& stype = "file");
int PartitionManagerMain(const ushort_t& progress_code);
void SetLanguage(const string& lang, ushort_t null_conf_stat);
void DisplayLog(LogLevel LogPriority, const char* fmt, ...);
void DisplayVerboseLog(LogLevel LogPriority, const char* func, const int& line, const char* fmt, ...);
void CheckDevPoint(void);
void CheckRoot(void);
bool CleanSWPoint(void);
bool LoadLanguage(void);
} /* namespace PartitionManager */
/* logging macros */
#define LOGF(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayLog(LOG_LEVEL_FATAL, (fmt)__VA_OPT__(, ) __VA_ARGS__))
#define LOGE(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayLog(LOG_LEVEL_ERROR, (fmt)__VA_OPT__(, ) __VA_ARGS__))
#define LOGW(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayLog(LOG_LEVEL_WARN, (fmt)__VA_OPT__(, ) __VA_ARGS__))
#define LOGD(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayLog(LOG_LEVEL_DEBUG, (fmt)__VA_OPT__(, ) __VA_ARGS__))
/* verbose logging macros */
#define VLOGF(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayVerboseLog(LOG_LEVEL_FATAL, __func__, __LINE__, (fmt)__VA_OPT__(, ) __VA_ARGS__))
#define VLOGE(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayVerboseLog(LOG_LEVEL_ERROR, __func__, __LINE__, (fmt)__VA_OPT__(, ) __VA_ARGS__))
#define VLOGW(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayVerboseLog(LOG_LEVEL_WARN, __func__, __LINE__, (fmt)__VA_OPT__(, ) __VA_ARGS__))
#define VLOGD(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
((void)PartitionManager::DisplayVerboseLog(LOG_LEVEL_DEBUG, __func__, __LINE__, (fmt)__VA_OPT__(, ) __VA_ARGS__))
/* end of code */

View File

@@ -25,7 +25,7 @@
/* versioning */
#define PMT_MAJOR 2
#define PMT_MINOR 9
#define PMT_PATCHLEVEL 1
#define PMT_PATCHLEVEL 6
namespace PartitionManager {
namespace Functions {