pmt: initial 2.8.0 update
This commit is contained in:
@@ -16,18 +16,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_DEPRECATED_H
|
||||
#define __PMT_DEPRECATED_H
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
#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 NULL
|
||||
#define not_changed_long nullptr
|
||||
|
||||
/* versions */
|
||||
#define v150 "1.5.0"
|
||||
@@ -43,6 +39,7 @@ PMT_EXTERN_C_BEGIN
|
||||
#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 {
|
||||
@@ -54,38 +51,44 @@ struct pmt_deprecates {
|
||||
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 char* opt_long, const char* depr_msg)
|
||||
__deprecated_opt_handle(int opt, const string opt_long, const char* depr_msg)
|
||||
{
|
||||
static char long_e_msg[250];
|
||||
static string long_e_msg;
|
||||
|
||||
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}
|
||||
};
|
||||
|
||||
if (opt_long == NULL)
|
||||
sprintf(long_e_msg, "%s", current->not_changed_opt);
|
||||
if (opt_long == "")
|
||||
long_e_msg = PartitionManager::Display::UsingDispString->not_changed_opt;
|
||||
else
|
||||
sprintf(long_e_msg, "%s", opt_long);
|
||||
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, depr_table[optctrl].option_long) == 0)
|
||||
LOGD("%s [%s]: -%c (%s): %s\n", current->depr_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, depr_table[optctrl].option_long, depr_msg);
|
||||
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, depr_table[optctrl].option_long) == 0)
|
||||
LOGD("%s [%s]: -%c (%s): %s\n", current->switched_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, long_e_msg, depr_msg);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,8 +97,6 @@ __deprecated_opt_handle(int opt, const char* opt_long, const char* depr_msg)
|
||||
|
||||
#define DEPR_HANDLE(x, y, z) __deprecated_opt_handle(x, y, z)
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
#endif
|
||||
#endif /* __PMT_DEPRECATES_H */
|
||||
|
||||
/* end of code */
|
||||
@@ -19,13 +19,11 @@
|
||||
#ifndef __PMT_HELP_MSGS_H
|
||||
#define __PMT_HELP_MSGS_H
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
void help(void);
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
namespace PartitionManager {
|
||||
namespace Functions {
|
||||
void DisplayHelp(void);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
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 */
|
||||
@@ -19,12 +19,8 @@
|
||||
#ifndef __PMT_STRINGKEYS_
|
||||
#define __PMT_STRINGKEYS_
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
/* The struct is a very good option for setting the languages of texts etc. */
|
||||
struct pmt_langdb_general {
|
||||
struct langdb_general {
|
||||
const char* _Nonnull lang_by_s;
|
||||
const char* _Nonnull language;
|
||||
const char* _Nonnull lang_prefix;
|
||||
@@ -39,7 +35,6 @@ struct pmt_langdb_general {
|
||||
const char* _Nonnull not_write;
|
||||
const char* _Nonnull not_gen;
|
||||
const char* _Nonnull no_root;
|
||||
const char* _Nonnull no_target;
|
||||
const char* _Nonnull expected_backup_arg;
|
||||
const char* _Nonnull expected_flash_arg;
|
||||
const char* _Nonnull expected_format_arg;
|
||||
@@ -59,6 +54,7 @@ struct pmt_langdb_general {
|
||||
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;
|
||||
@@ -68,15 +64,22 @@ struct pmt_langdb_general {
|
||||
const char* _Nonnull part_disk_sz_fail;
|
||||
const char* _Nonnull flash_file_sz_fail;
|
||||
const char* _Nonnull unknown_opr;
|
||||
const char* _Nonnull list_of_dir;
|
||||
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;
|
||||
@@ -85,12 +88,13 @@ struct pmt_langdb_general {
|
||||
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 pmt_langdb_docs {
|
||||
struct langdb_docs {
|
||||
const char* _Nonnull docs_strs_l1;
|
||||
const char* _Nonnull docs_strs_l2;
|
||||
const char* _Nonnull docs_strs_l3;
|
||||
@@ -105,17 +109,11 @@ struct pmt_langdb_docs {
|
||||
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;
|
||||
};
|
||||
|
||||
/* for checks etc */
|
||||
struct pmt_langdb_langs {
|
||||
const char* _Nullable lang_pr;
|
||||
};
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
#endif /* __PMT_STRINGKEYS_ */
|
||||
|
||||
/* end of code */
|
||||
@@ -19,21 +19,21 @@
|
||||
#ifndef __PMT_VERSIONING_H
|
||||
#define __PMT_VERSIONING_H
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
#ifdef __NDK_BUILD
|
||||
#include <android/ndk-version.h>
|
||||
#include <pmt/generated/clang-version.h>
|
||||
#include <PartitionManager/generated/clang-version.h>
|
||||
#endif
|
||||
|
||||
/* versioning */
|
||||
#define PMT_MAJOR 2
|
||||
#define PMT_MINOR 7
|
||||
#define PMT_MINOR 8
|
||||
#define PMT_PATCHLEVEL 0
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
namespace PartitionManager {
|
||||
namespace Functions {
|
||||
void DisplayVersion(void);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/* 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_EXTERN_C_H_
|
||||
#define __PMT_EXTERN_C_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define PMT_EXTERN_C_BEGIN extern "C" {
|
||||
#define PMT_EXTERN_C_END }
|
||||
#else
|
||||
#define PMT_EXTERN_C_BEGIN
|
||||
#define PMT_EXTERN_C_END
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,121 +0,0 @@
|
||||
/* 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
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
#ifndef __PMT_H_
|
||||
#define __PMT_H_
|
||||
|
||||
#ifdef INC_MAIN_LIBS
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(HELP) || !defined(VERSIONING)
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef INC_GETOPT
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_DIRENT
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_STAT
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_DEBUGERS
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_TOOLS_REQS
|
||||
#include <fcntl.h>
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
/* variable definations */
|
||||
extern char* _Nullable out;
|
||||
extern char* _Nullable cust_cxt;
|
||||
extern char* _Nullable target_partition;
|
||||
extern char* _Nullable target_flash_file;
|
||||
extern char* _Nullable format_fs;
|
||||
extern char* _Nullable partition_type;
|
||||
extern char* _Nullable bin_name;
|
||||
extern bool pmt_use_logical;
|
||||
extern bool pmt_use_cust_cxt;
|
||||
extern bool pmt_ab;
|
||||
extern bool pmt_logical;
|
||||
extern bool pmt_silent;
|
||||
extern bool pmt_flash;
|
||||
extern bool pmt_backup;
|
||||
extern bool pmt_format;
|
||||
extern bool pmt_force_mode;
|
||||
extern bool pmt_inst_on_termux;
|
||||
|
||||
/* language struces configurations */
|
||||
extern struct pmt_langdb_general* _Nullable current;
|
||||
extern struct pmt_langdb_docs* _Nullable curr_docs;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
extern struct pmt_langdb_docs en_docs;
|
||||
extern struct pmt_langdb_docs tr_docs;
|
||||
|
||||
/* logging levels */
|
||||
typedef enum {
|
||||
LOG_LEVEL_FATAL,
|
||||
LOG_LEVEL_ERR,
|
||||
LOG_LEVEL_WARN,
|
||||
LOG_LEVEL_DEBUG
|
||||
} LogLevel;
|
||||
|
||||
/* function definations */
|
||||
int listpart(void);
|
||||
void check_dev_point(void);
|
||||
void check_root(void);
|
||||
int pmt(unsigned short progress_code);
|
||||
void version(void);
|
||||
void setlang(const char* _Nonnull lang, int null_conf_stat);
|
||||
int search_sls(void);
|
||||
int loadlang(void);
|
||||
int get_stat(const char* _Nonnull filepath, const char* _Nonnull stype);
|
||||
void debug(LogLevel status, const char* _Nullable fmt, ...);
|
||||
|
||||
/* logging macros */
|
||||
#define LOGF(fmt, ...) debug(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
|
||||
#define LOGE(fmt, ...) debug(LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
|
||||
#define LOGW(fmt, ...) debug(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
|
||||
#define LOGD(fmt, ...) debug(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
/* end of code */
|
||||
Reference in New Issue
Block a user