pmt: initial 2.8.0 update
This commit is contained in:
102
include/PartitionManager/Deprecates.h
Executable file
102
include/PartitionManager/Deprecates.h
Executable file
@@ -0,0 +1,102 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_DEPRECATES_H
|
||||
#define __PMT_DEPRECATES_H
|
||||
|
||||
#define deprecated_opt 1
|
||||
#define changed_opt 2
|
||||
#define end_depr_pointer 0
|
||||
#define not_changed 0
|
||||
#define not_changed_long 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 vUNK NULL
|
||||
|
||||
struct pmt_deprecates {
|
||||
int depr_type;
|
||||
int option;
|
||||
int option_new;
|
||||
const char* option_long;
|
||||
const char* option_long_new;
|
||||
const char* depr_version;
|
||||
};
|
||||
|
||||
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},
|
||||
{end_depr_pointer, not_changed, not_changed, not_changed_long, not_changed_long, vUNK}
|
||||
};
|
||||
|
||||
static void
|
||||
__deprecated_opt_handle(int opt, const string opt_long, const char* depr_msg)
|
||||
{
|
||||
static string long_e_msg;
|
||||
|
||||
if (opt_long == "")
|
||||
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++)
|
||||
{
|
||||
|
||||
if (depr_table[optctrl].depr_type == 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);
|
||||
}
|
||||
|
||||
}
|
||||
else if (depr_table[optctrl].depr_type == 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#define DEPR_HANDLE(x, y, z) __deprecated_opt_handle(x, y, z)
|
||||
|
||||
#endif /* __PMT_DEPRECATES_H */
|
||||
|
||||
/* end of code */
|
||||
30
include/PartitionManager/HelpFn.h
Executable file
30
include/PartitionManager/HelpFn.h
Executable file
@@ -0,0 +1,30 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_HELP_MSGS_H
|
||||
#define __PMT_HELP_MSGS_H
|
||||
|
||||
namespace PartitionManager {
|
||||
namespace Functions {
|
||||
void DisplayHelp(void);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* end */
|
||||
149
include/PartitionManager/PartitionManager.h
Executable file
149
include/PartitionManager/PartitionManager.h
Executable file
@@ -0,0 +1,149 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(__clang__) && !defined(__NDK_BUILD)
|
||||
#error "Your compiler is NOT clang. Please build with LLVM clang."
|
||||
#endif
|
||||
|
||||
#ifndef __PMT_H_
|
||||
#define __PMT_H_
|
||||
|
||||
#ifdef INC_MAIN_LIBS
|
||||
#include <iostream>
|
||||
#include <stdbool.h>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cstdarg>
|
||||
#include <clocale>
|
||||
|
||||
#if !defined(HELP) || !defined(VERSIONING)
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef INC_STRINGKEYS
|
||||
#include <PartitionManager/StringKeys.h>
|
||||
#endif
|
||||
#ifdef INC_DIRENT
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#ifdef INC_STAT
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef INC_DEBUGERS
|
||||
#include <cerrno>
|
||||
#endif
|
||||
#ifdef INC_TOOLS_REQS
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
#ifdef INC_LIBGEN
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* logging levels */
|
||||
typedef enum {
|
||||
LOG_LEVEL_FATAL,
|
||||
LOG_LEVEL_ERROR,
|
||||
LOG_LEVEL_WARN,
|
||||
LOG_LEVEL_DEBUG
|
||||
} LogLevel;
|
||||
|
||||
/* fast error processing without errno entry
|
||||
* but errno can be given in the entrance
|
||||
*/
|
||||
char* strqerror(int errno_macro = errno);
|
||||
|
||||
/* create a special namespace */
|
||||
namespace PartitionManager {
|
||||
namespace Strings {
|
||||
extern string OutputName;
|
||||
extern string CustomContext;
|
||||
extern string TargetPartition;
|
||||
extern string TargetFlashFile;
|
||||
extern string TargetFormatFS;
|
||||
extern string PartitionType;
|
||||
extern string ExecutingName;
|
||||
extern string CurrentLanguage;
|
||||
} /* namespace Strings */
|
||||
|
||||
namespace Booleans {
|
||||
extern bool UseLogical;
|
||||
extern bool UseCustomContext;
|
||||
extern bool UsesSlots;
|
||||
extern bool UsesLogical;
|
||||
extern bool SilentEnabled;
|
||||
extern bool FlashMode;
|
||||
extern bool BackupMode;
|
||||
extern bool FormatMode;
|
||||
extern bool ForceMode;
|
||||
extern bool VerboseMode;
|
||||
extern bool InstalledOnTermux;
|
||||
extern bool ActivateRoot;
|
||||
} /* namespace Booleans */
|
||||
|
||||
namespace Display {
|
||||
extern struct langdb_general* UsingDispString;
|
||||
extern struct langdb_docs* UsingDocDispString;
|
||||
extern struct langdb_general LangEn;
|
||||
extern struct langdb_general LangTr;
|
||||
extern struct langdb_docs LangDocEn;
|
||||
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 */
|
||||
|
||||
} /* namespace PartitionManager */
|
||||
|
||||
/* logging macros */
|
||||
#define LOGF(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
|
||||
#define LOGE(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
|
||||
#define LOGW(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
|
||||
#define LOGD(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define VLOGF(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
|
||||
#define VLOGE(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
|
||||
#define VLOGW(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
|
||||
#define VLOGD(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
119
include/PartitionManager/StringKeys.h
Executable file
119
include/PartitionManager/StringKeys.h
Executable file
@@ -0,0 +1,119 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_STRINGKEYS_
|
||||
#define __PMT_STRINGKEYS_
|
||||
|
||||
/* The struct is a very good option for setting the languages of texts etc. */
|
||||
struct langdb_general {
|
||||
const char* _Nonnull lang_by_s;
|
||||
const char* _Nonnull language;
|
||||
const char* _Nonnull lang_prefix;
|
||||
const char* _Nonnull not_logical;
|
||||
const char* _Nonnull not_file;
|
||||
const char* _Nonnull not_dir;
|
||||
const char* _Nonnull not_in_dev;
|
||||
const char* _Nonnull not_open;
|
||||
const char* _Nonnull not_block;
|
||||
const char* _Nonnull not_read;
|
||||
const char* _Nonnull not_readdir;
|
||||
const char* _Nonnull not_write;
|
||||
const char* _Nonnull not_gen;
|
||||
const char* _Nonnull no_root;
|
||||
const char* _Nonnull expected_backup_arg;
|
||||
const char* _Nonnull expected_flash_arg;
|
||||
const char* _Nonnull expected_format_arg;
|
||||
const char* _Nonnull missing_operand;
|
||||
const char* _Nonnull multiple_wiewers;
|
||||
const char* _Nonnull common_symbol_rule;
|
||||
const char* _Nonnull req_part_name;
|
||||
const char* _Nonnull part_not_found;
|
||||
const char* _Nonnull unsupported_fs;
|
||||
const char* _Nonnull cannot_stat;
|
||||
const char* _Nonnull ffile_more_part;
|
||||
const char* _Nonnull cannot_get_bsz;
|
||||
const char* _Nonnull format_fail;
|
||||
const char* _Nonnull depr_backup_opt;
|
||||
const char* _Nonnull depr_flash_opt;
|
||||
const char* _Nonnull depr_format_opt;
|
||||
const char* _Nonnull depr_Vlicense_opt;
|
||||
const char* _Nonnull depr_ch_list_opt;
|
||||
const char* _Nonnull not_spec_opt;
|
||||
const char* _Nonnull some_spec;
|
||||
const char* _Nonnull logical_warn;
|
||||
const char* _Nonnull ab_warn;
|
||||
const char* _Nonnull out_not_spec;
|
||||
const char* _Nonnull please_rerun;
|
||||
const char* _Nonnull part_disk_sz;
|
||||
const char* _Nonnull flash_file_sz;
|
||||
const char* _Nonnull part_disk_sz_fail;
|
||||
const char* _Nonnull flash_file_sz_fail;
|
||||
const char* _Nonnull unknown_opr;
|
||||
const char* _Nonnull req_an_arg;
|
||||
const char* _Nonnull list_of_general;
|
||||
const char* _Nonnull list_of_logc;
|
||||
const char* _Nonnull success_backup;
|
||||
const char* _Nonnull success_flash;
|
||||
const char* _Nonnull success_format;
|
||||
const char* _Nonnull formatting;
|
||||
const char* _Nonnull warn;
|
||||
const char* _Nonnull fatal;
|
||||
const char* _Nonnull is_requires_arg;
|
||||
const char* _Nonnull unknw_arg;
|
||||
const char* _Nonnull switching_lang;
|
||||
const char* _Nonnull welcome;
|
||||
const char* _Nullable welcome_;
|
||||
const char* _Nonnull for_more;
|
||||
const char* _Nonnull s_and_v;
|
||||
const char* _Nonnull try_h;
|
||||
const char* _Nonnull usage_head;
|
||||
const char* _Nonnull depr_opt_str;
|
||||
const char* _Nonnull switched_opt_str;
|
||||
const char* _Nonnull not_changed_opt;
|
||||
const char* _Nonnull compiler_str;
|
||||
const char* _Nonnull version_str;
|
||||
const char* _Nonnull bin_str;
|
||||
const char* _Nonnull fs_str;
|
||||
const char* _Nonnull unknw_str;
|
||||
const char* _Nonnull by_str;
|
||||
};
|
||||
|
||||
/* docs etc. */
|
||||
struct langdb_docs {
|
||||
const char* _Nonnull docs_strs_l1;
|
||||
const char* _Nonnull docs_strs_l2;
|
||||
const char* _Nonnull docs_strs_l3;
|
||||
const char* _Nonnull docs_strs_l4;
|
||||
const char* _Nonnull docs_strs_l5;
|
||||
const char* _Nonnull docs_strs_l6;
|
||||
const char* _Nonnull docs_strs_l7;
|
||||
const char* _Nonnull docs_strs_l8;
|
||||
const char* _Nonnull docs_strs_l9;
|
||||
const char* _Nonnull docs_strs_l10;
|
||||
const char* _Nonnull docs_strs_l11;
|
||||
const char* _Nonnull docs_strs_l12;
|
||||
const char* _Nonnull docs_strs_l13;
|
||||
const char* _Nonnull docs_strs_l14;
|
||||
const char* _Nonnull docs_strs_l15;
|
||||
const char* _Nonnull or_str;
|
||||
const char* _Nonnull usage_docstr;
|
||||
};
|
||||
|
||||
#endif /* __PMT_STRINGKEYS_ */
|
||||
|
||||
/* end of code */
|
||||
40
include/PartitionManager/VersionFnVars.h
Executable file
40
include/PartitionManager/VersionFnVars.h
Executable file
@@ -0,0 +1,40 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_VERSIONING_H
|
||||
#define __PMT_VERSIONING_H
|
||||
|
||||
#ifdef __NDK_BUILD
|
||||
#include <android/ndk-version.h>
|
||||
#include <PartitionManager/generated/clang-version.h>
|
||||
#endif
|
||||
|
||||
/* versioning */
|
||||
#define PMT_MAJOR 2
|
||||
#define PMT_MINOR 8
|
||||
#define PMT_PATCHLEVEL 0
|
||||
|
||||
namespace PartitionManager {
|
||||
namespace Functions {
|
||||
void DisplayVersion(void);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* end */
|
||||
Reference in New Issue
Block a user