pmt: initial 2.5.0 update
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
# By YZBruh | ShawkTeam
|
||||
|
||||
# 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.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(LOCAL_PATH)/config/env.mk
|
||||
|
||||
PMT_CFLAGS = -O3 -std=c11 -Wall $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
ifeq ($(ENABLE_DEBUGGING), true)
|
||||
PMT_CFLAGS += -g -Wextra
|
||||
else
|
||||
$(warning Unknown debugging flag: $(ENABLE_DEBUGGING). Please see: src/config/env.mk. Using non-debugging flags)
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_root
|
||||
LOCAL_SRC_FILES := root.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_debugging
|
||||
LOCAL_SRC_FILES := debugging.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_partitiontool
|
||||
LOCAL_SRC_FILES := partitiontool.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_list
|
||||
LOCAL_SRC_FILES := listpart.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := pmt
|
||||
LOCAL_SRC_FILES := \
|
||||
pmt.c \
|
||||
versioner.c \
|
||||
get_stat.c \
|
||||
tools.c \
|
||||
lang_tools.c \
|
||||
languages.c \
|
||||
docs.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libpmt_root \
|
||||
libpmt_debugging \
|
||||
libpmt_partitiontool \
|
||||
libpmt_list
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# end
|
||||
@@ -1,26 +0,0 @@
|
||||
# By YZBruh | ShawkTeam
|
||||
|
||||
# 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.
|
||||
|
||||
# architecture
|
||||
APP_ABI := \
|
||||
arm64-v8a \
|
||||
armeabi-v7a
|
||||
|
||||
APP_PLATFORM := android-21
|
||||
|
||||
APP_OPTIM := release
|
||||
|
||||
# end
|
||||
161
jni/Makefile
Executable file
161
jni/Makefile
Executable file
@@ -0,0 +1,161 @@
|
||||
# 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.
|
||||
|
||||
#####
|
||||
# sub-make for building package
|
||||
#####
|
||||
|
||||
THIS_IS = src
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
ifeq ($(INC_OLDENV),true)
|
||||
include $(BUILD)/config/oldenv.mk
|
||||
endif
|
||||
|
||||
# make objects. Usage $(call make_obj,<SRCFILE>)
|
||||
define make_obj
|
||||
$(eval OBJ := $(1:.c=.o))
|
||||
$(call m_stat,CC,`basename $(SOURCE_DIR)`/`basename $(OBJ)`,n)
|
||||
$(CC) $(CFLAGS) -c "$1" || exit 1;
|
||||
$(hide)printf "\n"
|
||||
endef
|
||||
|
||||
# make executable file with using static libraries and objects. Usage: $(call make_executable)
|
||||
define make_executable
|
||||
printf " - Making executable file...\n"; \
|
||||
printf " LD $(TARGET)"; \
|
||||
$(CC) $(CFLAGS) -L$(SOURCE_DIR) \
|
||||
$(foreach s_obj_b, \
|
||||
$(shell basename -a $(STATICLIB_OBJS)), \
|
||||
$(eval s_obj_t_b = $(s_obj_b:.o=)) \
|
||||
$(shell echo -lpmt_$(s_obj_t_b)) \
|
||||
) \
|
||||
-o $(TARGET) $(OBJS_EXEC) || exit 1;
|
||||
endef
|
||||
|
||||
# make static library. Usage $(call make_staticlib,<LIBRARY_NAME>,<OBJECT(S)>)
|
||||
define make_staticlib
|
||||
echo -n " AR $1"; \
|
||||
$(AR) rcs "$1" "$2" || exit 1; \
|
||||
echo;
|
||||
endef
|
||||
|
||||
# controls the presence of source file. usage: $(call check_cfile,<SOURCE_FILE>)
|
||||
define check_cfile
|
||||
# the first argument is taken and controlled by the file with -f option
|
||||
printf " CHK $(SOURCE_DIRNAME)/`basename $1`\n"; \
|
||||
if [ ! -f $1 ]; then \
|
||||
printf " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $1`\n"; \
|
||||
if [ -d "$(TEMP_DIR)" ]; then \
|
||||
rm -rf $(TEMP_DIR); \
|
||||
fi; \
|
||||
exit 1; \
|
||||
fi;
|
||||
endef
|
||||
|
||||
# controls the presence of header file. usage: $(call check_hfile,<SOURCE_FILE>)
|
||||
define check_hfile
|
||||
# the first argument is taken and controlled by the file with -f option
|
||||
printf " CHK include/pmt/`basename $1`\n"; \
|
||||
if [ ! -f $1 ]; then \
|
||||
printf " ==> Couldn't found required header file: include/pmt/`basename $1`\n"; \
|
||||
if [ -d "$(TEMP_DIR)" ]; then \
|
||||
rm -rf $(TEMP_DIR); \
|
||||
fi; \
|
||||
exit 1; \
|
||||
fi;
|
||||
endef
|
||||
|
||||
# all target for building
|
||||
all:
|
||||
$(hide)rm -f $(BUILD)/config/oldenv.mk
|
||||
$(hide)printf " ---- Partition Manager Builder ---- \n\n"
|
||||
$(hide)printf " - Version: $(VERSION)\n"
|
||||
$(hide)printf " - Version code: $(VERSION_CODE)\n\n"
|
||||
$(hide)printf " -------------------------------- \n\n"
|
||||
$(hide)if [ -f $(SOURCE_DIR)/debugging.o ]; then \
|
||||
printf " - Please clean up before you build it.\n\n"; \
|
||||
printf " ----------------------------------- \n"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(hide)printf " - Checking required source files...\n"
|
||||
$(hide)sleep 1
|
||||
$(foreach src_cf, \
|
||||
$(SRCS_REQ), \
|
||||
$(call check_cfile,$(src_cf)) \
|
||||
)
|
||||
$(foreach src_hf, \
|
||||
$(HEADERS_REQ), \
|
||||
$(call check_hfile,$(src_hf)) \
|
||||
)
|
||||
$(hide)printf " - Building objects...\n"
|
||||
$(hide)sleep 2
|
||||
$(foreach csrc, \
|
||||
$(SRCS), \
|
||||
$(call make_obj,$(csrc)) \
|
||||
)
|
||||
$(foreach reqdir,$(IN_OUT_DIR),$(call mdir,$(reqdir)))
|
||||
$(hide)printf " - Making static libraries...\n"
|
||||
$(foreach s_obj, \
|
||||
$(shell basename -a $(STATICLIB_OBJS)), \
|
||||
$(eval s_obj_t = $(s_obj:.o=.a)) \
|
||||
$(call make_staticlib,libpmt_$(s_obj_t),$(s_obj)) \
|
||||
)
|
||||
$(hide)sleep 1
|
||||
$(call make_executable)
|
||||
$(hide)sleep 1
|
||||
$(hide)abort_build() { \
|
||||
if [ -d "$(PACKAGE_DIR)" ]; then \
|
||||
rm -rf "$(PACKAGE_DIR)"; \
|
||||
fi; \
|
||||
if [ -d "$(BINARY_DIR)" ]; then \
|
||||
rm -rf "$(BINARY_DIR)"; \
|
||||
fi; \
|
||||
if [ -d "$(STATICLIB_DIR)" ]; then \
|
||||
rm -rf "$(STATICLIB_DIR)"; \
|
||||
fi; \
|
||||
exit 1; \
|
||||
}; \
|
||||
mv $(TARGET) $(BINARY_DIR) || abort_build; \
|
||||
mv *.a $(STATICLIB_DIR) || abort_build; \
|
||||
printf "\n - Generating package...\n"; \
|
||||
cp $(BINARY_DIR)/$(TARGET) $(PACKAGE_DIR) || abort_build; \
|
||||
printf " XZ $(OUT_DIRNAME)/package/$(TARGET)-$(ARCH).xz"
|
||||
xz $(PACKAGE_DIR)/$(TARGET) || abort_build; \
|
||||
sleep 1; \
|
||||
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-$(ARCH).xz || abort_build; \
|
||||
printf "\n - Success"; \
|
||||
sleep 1; \
|
||||
printf "\n\n ----------------------------------- \n"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(eval STATICLIBS = $(wildcard $(SOURCE_DIR)/*.a))
|
||||
$(eval OBJS = $(wildcard $(SOURCE_DIR)/*.o))
|
||||
$(info Cleaning files...)
|
||||
$(foreach obj, \
|
||||
$(OBJS), \
|
||||
$(call m_stat_nn,$(SOURCE_DIRNAME)/$(shell basename $(obj))) \
|
||||
$(call erase,$(obj)) \
|
||||
)
|
||||
$(foreach lib, \
|
||||
$(STATICLIBS), \
|
||||
$(call m_stat_nn,$(SOURCE_DIRNAME)/$(shell basename $(lib))) \
|
||||
$(call erase,$(lib)) \
|
||||
)
|
||||
|
||||
# end
|
||||
@@ -1,31 +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.
|
||||
|
||||
#########################################
|
||||
# #
|
||||
# Configuration Flags #
|
||||
# #
|
||||
# Warning: you can edit #
|
||||
# #
|
||||
#########################################
|
||||
|
||||
# addionital compiler flags
|
||||
EXTRA_COMPILER_FLAGS ?=
|
||||
|
||||
# debugging mode (binary)
|
||||
ENABLE_DEBUGGING ?= false
|
||||
|
||||
# end of environment configuration
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,20 +16,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
extern char* bin_name;
|
||||
extern bool pmt_silent;
|
||||
|
||||
extern struct pmt_langdb_general* current;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
|
||||
void debug(LogLevel status, const char* _Nullable fmt, ...)
|
||||
{
|
||||
@@ -72,7 +66,7 @@ void debug(LogLevel status, const char* _Nullable fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
42
jni/docs.c
42
jni/docs.c
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,47 +16,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_DOCS_REQS
|
||||
|
||||
#include <pmt.h>
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
#include <pmt/docs.h>
|
||||
|
||||
extern char* bin_name;
|
||||
extern char* pmt_langdb_langs_docs[];
|
||||
extern char* curr_lang;
|
||||
|
||||
struct pmt_langdb_docs* curr_docs = NULL;
|
||||
extern struct pmt_langdb_docs en_docs;
|
||||
extern struct pmt_langdb_docs tr_docs;
|
||||
|
||||
static void
|
||||
prepare_langconf_docs(void)
|
||||
{
|
||||
static char* langctrl_str;
|
||||
langctrl_str = loadlang();
|
||||
|
||||
if (strcmp(langctrl_str, "en") == 0)
|
||||
if (strcmp(curr_lang, "en") == 0)
|
||||
curr_docs = &en_docs;
|
||||
else if (strcmp(langctrl_str, "tr") == 0)
|
||||
else if (strcmp(curr_lang, "tr") == 0)
|
||||
curr_docs = &tr_docs;
|
||||
}
|
||||
|
||||
void licenses(void)
|
||||
{
|
||||
printf("Copyright 2024 Partition Manager\n");
|
||||
printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
|
||||
printf("you may not use this file except in compliance with the License.\n");
|
||||
printf("You may obtain a copy of the License at\n\n");
|
||||
printf(" http://www.apache.org/licenses/LICENSE-2.0\n\n");
|
||||
printf("Unless required by applicable law or agreed to in writing, software\n");
|
||||
printf("distributed under the License is distributed on an \"AS IS\" BASIS,\n");
|
||||
printf("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
|
||||
printf("See the License for the specific language governing permissions and limitations under the License.\n");
|
||||
}
|
||||
|
||||
void help(void)
|
||||
{
|
||||
prepare_langconf_docs();
|
||||
@@ -71,17 +54,16 @@ void help(void)
|
||||
printf(" -f, --force %s\n", curr_docs->docs_strs_l9);
|
||||
printf(" -S, --set-lang %s\n", curr_docs->docs_strs_l10);
|
||||
printf(" -v, --version %s\n", curr_docs->docs_strs_l11);
|
||||
printf(" --help %s\n", curr_docs->docs_strs_l12);
|
||||
printf(" -L, --license %s\n\n", curr_docs->docs_strs_l13);
|
||||
printf("%s:\n", curr_docs->docs_strs_l14);
|
||||
printf(" --help %s\n\n", curr_docs->docs_strs_l12);
|
||||
printf("%s:\n", curr_docs->docs_strs_l13);
|
||||
printf(" %s backup boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
||||
printf(" %s flash /sdcard/twrp/boot.img boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
||||
printf(" %s format ext4 system_a --logical\n", bin_name);
|
||||
printf(" %s -c /dev/block/platform/bootdevice/by-name --list\n\n", bin_name);
|
||||
printf("%s <t.me / ShawkTeam | Community / Topics -- pmt>\n", curr_docs->docs_strs_l15);
|
||||
printf("%s <t.me/ShawkTeam | Topics | pmt>\n", curr_docs->docs_strs_l14);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,14 +16,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_STAT
|
||||
|
||||
#include <pmt.h>
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
|
||||
/**
|
||||
* The target file is controlled by the stat function.
|
||||
@@ -71,7 +72,7 @@ int get_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
||||
return 2;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,26 +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.
|
||||
*/
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void help(void);
|
||||
void licenses(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
/* end */
|
||||
@@ -1,105 +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(__PMT_STRINGKEYS_)
|
||||
#define __PMT_STRINGKEYS_
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* The struct is a very good option for setting the languages of texts etc. */
|
||||
struct pmt_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_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;
|
||||
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 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 list_of_dir;
|
||||
const char* _Nonnull see_license;
|
||||
const char* _Nonnull success_backup;
|
||||
const char* _Nonnull success_flash;
|
||||
const char* _Nonnull warn;
|
||||
const char* _Nonnull fatal;
|
||||
const char* _Nonnull switching_lang;
|
||||
const char* _Nonnull welcome;
|
||||
const char* _Nullable welcome_;
|
||||
const char* _Nonnull for_more;
|
||||
const char* _Nonnull try_h;
|
||||
const char* _Nonnull usage_head;
|
||||
const char* _Nonnull compiler_str;
|
||||
const char* _Nonnull version_str;
|
||||
const char* _Nonnull bin_str;
|
||||
const char* _Nonnull unknw_str;
|
||||
const char* _Nonnull by_str;
|
||||
};
|
||||
|
||||
/* docs, licenses etc. */
|
||||
struct pmt_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;
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __PMT_STRINGKEYS_ */
|
||||
|
||||
/* end of code */
|
||||
@@ -1,42 +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.
|
||||
*/
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <android/ndk-version.h>
|
||||
|
||||
#if __NDK_MINOR__ == 1
|
||||
#define __NDK_MINOR_STATUS__ "b"
|
||||
#else
|
||||
#define __NDK_MINOR_STATUS__ ""
|
||||
#endif
|
||||
|
||||
#if __NDK_BETA__ == 1 || __NDK_BETA__ == 2
|
||||
#define __NDK_BETA_STATUS__ "beta"
|
||||
#else
|
||||
#define __NDK_BETA_STATUS__ ""
|
||||
#endif
|
||||
|
||||
/* versioning */
|
||||
#define PMT_MAJOR 2
|
||||
#define PMT_MINOR 4
|
||||
#define PMT_PATCHLEVEL 0
|
||||
|
||||
__END_DECLS
|
||||
|
||||
/* end */
|
||||
@@ -1,127 +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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if !defined(__PMT_H_)
|
||||
#define __PMT_H_
|
||||
|
||||
#define PMT_PACKAGE_NAME "Partition Manager"
|
||||
|
||||
#if defined(INC_MAIN_LIBS)
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <pmt-stringkeys.h>
|
||||
#endif
|
||||
|
||||
#if defined(INC_GETOPT)
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#if defined(INC_DIRENT)
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#if defined(INC_STAT)
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(INC_DEBUGERS)
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#if defined(INC_PMT_LANGS)
|
||||
#include <pmt-langs.h>
|
||||
#endif
|
||||
|
||||
#if defined(INC_DOCS_REQS)
|
||||
#include <pmt-docs.h>
|
||||
#endif
|
||||
|
||||
#if defined(INC_VERSIONER_REQS)
|
||||
#include <pmt-versioning.h>
|
||||
#endif
|
||||
|
||||
#if defined(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 search_sls(void);
|
||||
char* _Nonnull loadlang(void);
|
||||
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
|
||||
|
||||
__END_DECLS
|
||||
|
||||
/* end of code */
|
||||
193
jni/lang_tools.c
193
jni/lang_tools.c
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -24,45 +24,35 @@ extern "C" {
|
||||
#define INC_DEBUGERS
|
||||
#define INC_STAT
|
||||
|
||||
#include <pmt.h>
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
|
||||
/* pmt's man doc file path on termux */
|
||||
#define TERMUX_PMT_MANDOC "/data/data/com.termux/files/usr/share/man/man8/pmt.8.gz"
|
||||
|
||||
/* language configuration paths */
|
||||
#define PMTLANG_CONF "/sdcard/.pmtlang.conf"
|
||||
|
||||
/* for termux */
|
||||
#define TERMUX_PMTLANG_CONF "/data/data/com.termux/files/usr/etc/pmtlang.conf"
|
||||
#define PMT_SW_POINT "/sdcard/.pmtlangsw"
|
||||
|
||||
/* for internal storage */
|
||||
#define INTRNL_PMTLANG_CONF "/sdcard/.pmtlang.conf"
|
||||
extern struct pmt_langdb_langs lang[];
|
||||
struct pmt_langdb_general* current = NULL;
|
||||
|
||||
/* shortcuts to check that language is changed */
|
||||
char* curr_lang;
|
||||
static FILE *langconf;
|
||||
|
||||
/* for termux */
|
||||
#define TERMUX_PMT_SW_POINT "/data/data/com.termux/files/usr/etc/pmtlangsw"
|
||||
|
||||
/* for internal storage */
|
||||
#define INTRNL_PMT_SW_POINT "/sdcard/.pmtlangsw"
|
||||
|
||||
extern bool pmt_inst_on_termux;
|
||||
extern char* bin_name;
|
||||
extern char* pmt_langdb_langs[];
|
||||
extern int pmt_langdb_total;
|
||||
extern int pmt_langdb_ctrl;
|
||||
|
||||
FILE *langconf;
|
||||
|
||||
static int
|
||||
static const char*
|
||||
langctrl(const char* _Nonnull lang_)
|
||||
{
|
||||
if (strcmp(lang_, "en") == 0 || strcmp(lang_, "tr") == 0)
|
||||
return 0;
|
||||
for (int langct = 0; lang[langct].lang_pr != NULL; langct++)
|
||||
{
|
||||
if (strcmp(lang_, lang[langct].lang_pr) == 0)
|
||||
return lang_;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* loadlang(void)
|
||||
int loadlang(void)
|
||||
{
|
||||
static char lang_fpr[10] = "en";
|
||||
langconf = NULL;
|
||||
@@ -70,126 +60,88 @@ char* loadlang(void)
|
||||
if (get_stat(TERMUX_PMT_MANDOC, "file") == 0)
|
||||
pmt_inst_on_termux = true;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
|
||||
langconf = fopen(PMTLANG_CONF, "r+");
|
||||
|
||||
if (langconf == NULL)
|
||||
{
|
||||
if (get_stat(TERMUX_PMTLANG_CONF, "file") == 0)
|
||||
langconf = fopen(PMTLANG_CONF, "w+");
|
||||
|
||||
if (langconf == NULL || langconf != NULL)
|
||||
{
|
||||
langconf = fopen(TERMUX_PMTLANG_CONF, "r+");
|
||||
setlang("en", 1);
|
||||
current = &en;
|
||||
curr_lang = "en";
|
||||
|
||||
if (langconf == NULL)
|
||||
{
|
||||
langconf = fopen(TERMUX_PMTLANG_CONF, "w+");
|
||||
if (langconf != NULL)
|
||||
fclose(langconf);
|
||||
|
||||
if (langconf == NULL)
|
||||
{
|
||||
setlang("en");
|
||||
return "en";
|
||||
}
|
||||
fclose(langconf);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (fgets(lang_fpr, sizeof(lang_fpr), langconf) != NULL)
|
||||
{
|
||||
if (strcmp(lang_fpr, "en") == 0)
|
||||
{
|
||||
fclose(langconf);
|
||||
return "en";
|
||||
}
|
||||
else if (strcmp(lang_fpr, "tr") == 0)
|
||||
{
|
||||
fclose(langconf);
|
||||
return "tr";
|
||||
}
|
||||
}
|
||||
fclose(langconf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (get_stat(INTRNL_PMTLANG_CONF, "file") == 0)
|
||||
while (fgets(lang_fpr, sizeof(lang_fpr), langconf) != NULL)
|
||||
{
|
||||
langconf = fopen(INTRNL_PMTLANG_CONF, "r");
|
||||
|
||||
if (langconf == NULL)
|
||||
if (strcmp(lang_fpr, "en") == 0)
|
||||
{
|
||||
langconf = fopen(INTRNL_PMTLANG_CONF, "w+");
|
||||
|
||||
if (langconf == NULL)
|
||||
{
|
||||
setlang("en");
|
||||
return "en";
|
||||
}
|
||||
fclose(langconf);
|
||||
current = &en;
|
||||
curr_lang = "en";
|
||||
return 0;
|
||||
}
|
||||
else if (strcmp(lang_fpr, "tr") == 0)
|
||||
{
|
||||
fclose(langconf);
|
||||
current = &tr;
|
||||
curr_lang = "tr";
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (fgets(lang_fpr, sizeof(lang_fpr), langconf) != NULL)
|
||||
{
|
||||
if (strcmp(lang_fpr, "en") == 0)
|
||||
{
|
||||
fclose(langconf);
|
||||
return "en";
|
||||
}
|
||||
else if (strcmp(lang_fpr, "tr") == 0)
|
||||
{
|
||||
fclose(langconf);
|
||||
return "tr";
|
||||
}
|
||||
}
|
||||
fclose(langconf);
|
||||
setlang("en", 0);
|
||||
loadlang();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else return "en";
|
||||
|
||||
if (fgets(lang_fpr, sizeof(lang_fpr), langconf) == NULL)
|
||||
{
|
||||
setlang("en", 1);
|
||||
loadlang();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return "en";
|
||||
return 1;
|
||||
}
|
||||
|
||||
void setlang(const char* _Nonnull lang)
|
||||
void setlang(const char* _Nonnull lang, int null_conf_stat)
|
||||
{
|
||||
static char* lcf_path;
|
||||
if (langctrl(lang) == NULL)
|
||||
LOGE("Unknown language: %s.\n", lang);
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
lcf_path = TERMUX_PMTLANG_CONF;
|
||||
else
|
||||
lcf_path = INTRNL_PMTLANG_CONF;
|
||||
|
||||
if (get_stat(lcf_path, "file") == 0)
|
||||
remove(lcf_path);
|
||||
if (get_stat(PMTLANG_CONF, "file") == 0)
|
||||
remove(PMTLANG_CONF);
|
||||
|
||||
langconf = NULL;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
langconf = fopen(TERMUX_PMTLANG_CONF, "w");
|
||||
else
|
||||
langconf = fopen(INTRNL_PMTLANG_CONF, "w");
|
||||
langconf = fopen(PMTLANG_CONF, "w");
|
||||
|
||||
if (langconf == NULL)
|
||||
LOGE("Failed!!! Cannot open/write config file.\n");
|
||||
|
||||
if (langctrl(lang) == 0)
|
||||
{
|
||||
if (fprintf(langconf, "%s", lang) < 2)
|
||||
LOGE("Failed!!! Couldn't write config!\n");
|
||||
else
|
||||
fclose(langconf);
|
||||
}
|
||||
if (fprintf(langconf, "%s", lang) < 2)
|
||||
LOGE("Failed!!! Couldn't write config!\n");
|
||||
else
|
||||
LOGE("Unknown language: %s.\n", lang);
|
||||
fclose(langconf);
|
||||
|
||||
static int status;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
if (null_conf_stat != 1)
|
||||
{
|
||||
status = open(TERMUX_PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (status == 0)
|
||||
close(status);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = open(INTRNL_PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
status = open(PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (status == 0)
|
||||
close(status);
|
||||
}
|
||||
@@ -197,23 +149,16 @@ void setlang(const char* _Nonnull lang)
|
||||
|
||||
int search_sls(void)
|
||||
{
|
||||
static char* sw_point_path;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
sw_point_path = TERMUX_PMT_SW_POINT;
|
||||
else
|
||||
sw_point_path = INTRNL_PMT_SW_POINT;
|
||||
|
||||
if (get(sw_point_path, "file") == 0)
|
||||
if (get_stat(PMT_SW_POINT, "file") == 0)
|
||||
{
|
||||
remove(sw_point_path);
|
||||
remove(PMT_SW_POINT);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,13 +16,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt.h>
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
|
||||
struct pmt_langdb_general en = {
|
||||
.lang_by_s = "YZBruh & r0manas",
|
||||
@@ -35,10 +36,11 @@ struct pmt_langdb_general en = {
|
||||
.not_open = "Couldn't open",
|
||||
.not_block = "The specified partition is not recognized as a block device.",
|
||||
.not_read = "Couldn't read",
|
||||
.not_readdir = "Couldn't read directory",
|
||||
.not_write = "Couldn't write",
|
||||
.not_gen = "Couldn't generate",
|
||||
.no_root = "Root access could not be detected! Please run this with root permissions.",
|
||||
.no_target = "No target specified (backup, flash, or format).",
|
||||
.no_target = "No target specified (backup, flash, or format)",
|
||||
.expected_backup_arg = "Expected backup argument 2 (1 of them are not mandatory), retrieved",
|
||||
.expected_flash_arg = "Expected flash argument 2, retrieved",
|
||||
.expected_format_arg = "Expected format argument 2, retrieved",
|
||||
@@ -52,18 +54,24 @@ struct pmt_langdb_general en = {
|
||||
.ffile_more_part = "Flash file size exceeds partition capacity.",
|
||||
.cannot_get_bsz = "Failed to retrieve partition block size.",
|
||||
.format_fail = "Formatting failed! There is a possibility of data damage.",
|
||||
.depr_backup_opt = "These options for the backup are unavailable.",
|
||||
.depr_flash_opt = "These options for the flash are unavailable.",
|
||||
.depr_format_opt = "These options for the format are unavailable.",
|
||||
.depr_Vlicense_opt = "No memory for unnecessary options!",
|
||||
.depr_ch_list_opt = "Use -p argument for listing partitions.",
|
||||
.not_spec_opt = "Specify the necessary arguments, not option",
|
||||
.logical_warn = "This device uses logical partitions.",
|
||||
.ab_warn = "This device uses A/B partition style.",
|
||||
.out_not_spec = "Output file name not specified. Using default name:",
|
||||
.out_not_spec = "Output file name not specified. Using default name",
|
||||
.please_rerun = "Please rerun the command.",
|
||||
.part_disk_sz = "Partition disk size",
|
||||
.flash_file_sz = "Flash file size",
|
||||
.part_disk_sz_fail = "Failed to retrieve partition disk size.",
|
||||
.flash_file_sz_fail = "Failed to retrieve flash file size.",
|
||||
.unknown_opr = "Unknown operand",
|
||||
.list_of_dir = "Directory listing",
|
||||
.see_license = "View licenses using the -L argument.",
|
||||
.success_backup = "Backup successful. Output:",
|
||||
.success_flash = "Flash successful.",
|
||||
.success_backup = "Backup successful. Output",
|
||||
.success_flash = "Flash successful",
|
||||
.warn = "WARNING",
|
||||
.fatal = "FATAL ERROR",
|
||||
.switching_lang = "Switching language...",
|
||||
@@ -72,6 +80,9 @@ struct pmt_langdb_general en = {
|
||||
.for_more = "for more information",
|
||||
.try_h = "Try",
|
||||
.usage_head = "Usage",
|
||||
.depr_opt_str = "DEPRECATED OPTION",
|
||||
.switched_opt_str = "SWITCHED OPTION",
|
||||
.not_changed_opt = "not changed",
|
||||
.compiler_str = "Compiler",
|
||||
.version_str = "version",
|
||||
.bin_str = "binary",
|
||||
@@ -90,6 +101,7 @@ struct pmt_langdb_general tr = {
|
||||
.not_open = "Açılamıyor",
|
||||
.not_block = "Belirtilen bölüm bir blok değil. Yani aslında bu bir bölüm bile değil (disk). Bu hatayı almak için şanslı olmak gerek..!",
|
||||
.not_read = "Veri okunamıyor",
|
||||
.not_readdir = "Dizin verisi okunamıyor",
|
||||
.not_write = "Veri yazılamıyor",
|
||||
.not_gen = "Oluşturulamıyor",
|
||||
.no_root = "Root erişimi tespit edilemedi! Lütfen root erişimi ile çalıştırın.",
|
||||
@@ -97,7 +109,7 @@ struct pmt_langdb_general tr = {
|
||||
.expected_backup_arg = "Beklenen yedekleme argümanı 2 (bir tanesi zorunlu değil), alınan",
|
||||
.expected_flash_arg = "Beklenen flaş argümanı 2, alınan",
|
||||
.expected_format_arg = "Beklenen format argümanı 2, alınan",
|
||||
.missing_operand = "işlem belirtilmedi",
|
||||
.missing_operand = "İşlem belirtilmedi",
|
||||
.multiple_wiewers = "Birden fazla görüntüleme işlemi yapan fonksiyonlar bir arada kullanılamaz. Aynı anda sadece bir tanesi kullanılabilir.",
|
||||
.common_symbol_rule = "Bir seçeneğin argümanını verirken argüman önüne '-' sembolü getirilemez. Sembolü kaldırın ve tekrar deneyin.",
|
||||
.req_part_name = "Bölüm adı gereklidir.",
|
||||
@@ -107,7 +119,13 @@ struct pmt_langdb_general tr = {
|
||||
.ffile_more_part = "Flaşlanacak dosyanın boyutu mevcut bölüm boyutundan fazla.",
|
||||
.cannot_get_bsz = "Bölüm blok boyutu tespit edilemedi!",
|
||||
.format_fail = "Formatlama başarısız oldu. Bazı şeyler zarar görmüş olabilir!",
|
||||
.depr_backup_opt = "Yedek için artık bu seçeneği kullanamazsınız.",
|
||||
.depr_flash_opt = "Flaşlama için artık bu seçeneği kullanamazsınız.",
|
||||
.depr_format_opt = "Formatlama için artıi bu seçeneği kullanamazsınız.",
|
||||
.depr_Vlicense_opt = "Gereksiz seçeneklere bellek yok!",
|
||||
.depr_ch_list_opt = "Listeleme için -p seçeneğini kullanabilirsiniz.",
|
||||
.logical_warn = "Uyarı: bu cihaz mantıksal (logical) bölümlere sahip.",
|
||||
.not_spec_opt = "Seçenek değil, gerekli argümanları belirtin",
|
||||
.ab_warn = "Uyarı: bu cihazın bazı bölümleri A/B kullanıyor.",
|
||||
.out_not_spec = "Uyarı: çıktı dosya belirtilmedi. Çıktı dosya adı bölüm adına göre belirlenecek.",
|
||||
.please_rerun = "Lütfen yeniden çalıştırın",
|
||||
@@ -115,8 +133,8 @@ struct pmt_langdb_general tr = {
|
||||
.flash_file_sz = "Flaşlanacak dosyanın boyutu",
|
||||
.flash_file_sz_fail = "Uyarı: flaşlanacak dosyanın boyutu tespit edilemedi.",
|
||||
.part_disk_sz_fail = "Uyarı: bölüm boyutunun boyutu tespit edilemedi.",
|
||||
.unknown_opr = "Bilinmeyen işlem",
|
||||
.list_of_dir = "Dizin içeriğinin listesi",
|
||||
.see_license = "Lisansı -L seçeneği ile görüntüleyebilirsiniz.",
|
||||
.success_backup = "Başarılı. Çıktı",
|
||||
.success_flash = "Başarılı.",
|
||||
.warn = "UYARI",
|
||||
@@ -127,6 +145,9 @@ struct pmt_langdb_general tr = {
|
||||
.for_more = "komutunu kullanabilirsiniz",
|
||||
.try_h = "Daha fazla bilgi",
|
||||
.usage_head = "Kullanımı",
|
||||
.depr_opt_str = "KALDIRILMIŞ SEÇENEK",
|
||||
.switched_opt_str = "DEĞİŞTİRİLMİŞ SEÇENEK",
|
||||
.not_changed_opt = "değiştirilmedi",
|
||||
.compiler_str = "Derleyici",
|
||||
.version_str = "versiyon",
|
||||
.bin_str = "yapı",
|
||||
@@ -136,8 +157,8 @@ struct pmt_langdb_general tr = {
|
||||
|
||||
struct pmt_langdb_docs en_docs = {
|
||||
.docs_strs_l1 = "backup PARTITION [OUTPUT] [OPTIONS]...",
|
||||
.docs_strs_l2 = "flash FILE PARTITION [OPTIONS]...",
|
||||
.docs_strs_l3 = "format FILE_SYSTEM[ext/2/3/4] PARTITION [OPTIONS]...",
|
||||
.docs_strs_l2 = "flash PARTITION FILE [OPTIONS]...",
|
||||
.docs_strs_l3 = "format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...",
|
||||
.docs_strs_l4 = "Options",
|
||||
.docs_strs_l5 = "It is meant to determine whether the target partition is logical.",
|
||||
.docs_strs_l6 = "It is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name).",
|
||||
@@ -147,42 +168,38 @@ struct pmt_langdb_docs en_docs = {
|
||||
.docs_strs_l10 = "Set current language.",
|
||||
.docs_strs_l11 = "See version.",
|
||||
.docs_strs_l12 = "See this help message.",
|
||||
.docs_strs_l13 = "See license.",
|
||||
.docs_strs_l14 = "Examples",
|
||||
.docs_strs_l15 = "Report bugs to",
|
||||
.docs_strs_l13 = "Examples",
|
||||
.docs_strs_l14 = "Report bugs to",
|
||||
.or_str = "or",
|
||||
.usage_docstr = "Usage"
|
||||
};
|
||||
|
||||
struct pmt_langdb_docs tr_docs = {
|
||||
.docs_strs_l1 = "backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
|
||||
.docs_strs_l2 = "flash DOSYA BÖLÜM [SEÇENEKLER]...",
|
||||
.docs_strs_l3 = "format DOSYA_SİSTEMİ[ext/2/3/4] BÖLÜM [SEÇENEKLER]...",
|
||||
.docs_strs_l2 = "flash BÖLÜM DOSYA [SEÇENEKLER]...",
|
||||
.docs_strs_l3 = "format BÖLÜM DOSYA_SİSTEMİ[ext/2/3/4] [SEÇENEKLER]...",
|
||||
.docs_strs_l4 = "Seçenekler",
|
||||
.docs_strs_l5 = "Bu seçeneği kullanarak mantıksal (logical) bir bölümle işlem yapılacağını belirtebilirsiniz.",
|
||||
.docs_strs_l6 = "Bu seçeneği kullanarak özel /dev bağlamı belirtebilirsiniz. Sadece normal (mantıksal olmayan) bölümler içindir (Varsayılan: /dev/block/by-name).",
|
||||
.docs_strs_l5 = "Mantıksal (logical) bölüm ile işlem yapın.",
|
||||
.docs_strs_l6 = "Özel /dev bağlamı belirtin. Sadece normal bölümler içindir (Varsayılan: /dev/block/by-name).",
|
||||
.docs_strs_l7 = "Bölümler listelenir.",
|
||||
.docs_strs_l8 = "Bilgi ve uyarı mesajları susturulur.",
|
||||
.docs_strs_l9 = "Zorlama modu. Bazı şeyler göz ardı edilir.",
|
||||
.docs_strs_l10 = "Mevcut dili ayarlayın.",
|
||||
.docs_strs_l11 = "Sürümü görüntüleyin.",
|
||||
.docs_strs_l12 = "Bu yardım mesajını görüntüleyin.",
|
||||
.docs_strs_l13 = "Lisansı gorüntüleyin.",
|
||||
.docs_strs_l14 = "Örnekler",
|
||||
.docs_strs_l15 = "Sorunları şu adrese bildirin:",
|
||||
.docs_strs_l13 = "Örnekler",
|
||||
.docs_strs_l14 = "Sorunları şu adrese bildirin:",
|
||||
.or_str = "yada",
|
||||
.usage_docstr = "Kullanımı"
|
||||
};
|
||||
|
||||
char* pmt_langdb_langs[] = {
|
||||
"en",
|
||||
"tr"
|
||||
struct pmt_langdb_langs lang[] = {
|
||||
{"en"},
|
||||
{"tr"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int pmt_langdb_total = 2;
|
||||
int pmt_langdb_ctrl = 1;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,8 @@ extern "C" {
|
||||
#define INC_DEBUGERS
|
||||
#define INC_DIRENT
|
||||
|
||||
#include <pmt.h>
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
|
||||
/* current /dev context */
|
||||
#define CUR_DEV_CNTX "/dev/block/by-name"
|
||||
@@ -32,25 +33,14 @@ extern "C" {
|
||||
/* for logical partitions */
|
||||
#define LGC_DEV_CNTX "/dev/block/mapper"
|
||||
|
||||
extern bool pmt_use_cust_cxt;
|
||||
extern bool pmt_ab;
|
||||
extern bool pmt_logical;
|
||||
extern bool pmt_silent;
|
||||
extern bool pmt_force_mode;
|
||||
extern char* cust_cxt;
|
||||
extern char* bin_name;
|
||||
|
||||
extern struct pmt_langdb_general* current;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
|
||||
DIR *dir;
|
||||
static DIR *dir;
|
||||
|
||||
static int
|
||||
list(const char* operation, const char* target_dir)
|
||||
{
|
||||
static bool list = false;
|
||||
struct dirent *entry;
|
||||
static int count;
|
||||
struct dirent **nlist;
|
||||
dir = NULL;
|
||||
|
||||
if (strcmp(operation, "access") == 0)
|
||||
@@ -64,25 +54,32 @@ list(const char* operation, const char* target_dir)
|
||||
|
||||
if (dir != NULL)
|
||||
{
|
||||
if (!list)
|
||||
{
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGD("%s: `%s'\n", current->list_of_dir, target_dir);
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
LOGD("%s\n", entry->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (list)
|
||||
{
|
||||
count = scandir(target_dir, &nlist, NULL, alphasort);
|
||||
|
||||
if (count < 0)
|
||||
LOGE("%s: `%s': %s\n", current->not_readdir, target_dir, strerror(errno));
|
||||
|
||||
for (int cont_count = 0; cont_count < count; cont_count++)
|
||||
{
|
||||
if (nlist[cont_count]->d_name[0] != '.')
|
||||
LOGD("%s\n", nlist[cont_count]->d_name);
|
||||
|
||||
free(nlist[cont_count]);
|
||||
}
|
||||
|
||||
free(nlist);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -131,7 +128,7 @@ int listpart(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,24 +16,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
extern bool pmt_use_cust_cxt;
|
||||
extern bool pmt_ab;
|
||||
extern bool pmt_logical;
|
||||
extern char* cust_cxt;
|
||||
#include <pmt/pmt.h>
|
||||
|
||||
static int
|
||||
accf(const char* _Nonnull target) { return access(target, F_OK); }
|
||||
|
||||
/* check parts */
|
||||
void check_dev_point()
|
||||
void check_dev_point(void)
|
||||
{
|
||||
/* true = ab | false = a */
|
||||
if (pmt_use_cust_cxt)
|
||||
@@ -74,7 +69,7 @@ void check_dev_point()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
253
jni/pmt.c
Normal file → Executable file
253
jni/pmt.c
Normal file → Executable file
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/* force use C std (if default is C++) */
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -25,9 +25,11 @@ extern "C" {
|
||||
#define INC_DEBUGERS
|
||||
#define INC_STAT
|
||||
#define INC_GETOPT
|
||||
#define INC_DOCS_REQS
|
||||
|
||||
#include <pmt.h>
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
#include <pmt/deprecates.h>
|
||||
#include <pmt/docs.h>
|
||||
|
||||
/* add value to variables that are added globally and are not worth */
|
||||
char* out = NULL;
|
||||
@@ -48,13 +50,6 @@ bool pmt_format = false;
|
||||
bool pmt_force_mode = false;
|
||||
bool pmt_inst_on_termux = false;
|
||||
|
||||
/* import language structs etc. */
|
||||
struct pmt_langdb_general* current = NULL;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
extern const char* pmt_langdb_langs[];
|
||||
extern int pmt_langdb_total;
|
||||
|
||||
/* variable for use in control of '-' expression */
|
||||
static const char* opt_symbol = "-";
|
||||
static char common_symbol_rule[350];
|
||||
@@ -79,32 +74,37 @@ strdup(const char* s)
|
||||
* the beginning of the given word
|
||||
*/
|
||||
static void
|
||||
check_optsym(const char* _Nonnull mystring)
|
||||
check_optsym(const char* _Nullable symbol)
|
||||
{
|
||||
if (strncmp(mystring, opt_symbol, 1) == 0)
|
||||
if (symbol != NULL)
|
||||
{
|
||||
if (!pmt_force_mode)
|
||||
if (strncmp(symbol, opt_symbol, 1) == 0)
|
||||
LOGE("%s\n", common_symbol_rule);
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
ctrl_arg(const char* _Nullable argv_holder)
|
||||
{
|
||||
if (strcmp(argv_holder, "--logical") != 0 && strcmp(argv_holder, "--context") != 0 && strcmp(argv_holder, "--silent") != 0 && strcmp(argv_holder, "-l") != 0 && strcmp(argv_holder, "-c") != 0 && strcmp(argv_holder, "-s") != 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* classic main function (C binary here xd) */
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
bin_name = argv[0];
|
||||
|
||||
/* load language */
|
||||
static char* langctrl_str;
|
||||
langctrl_str = loadlang();
|
||||
if (loadlang() != 0)
|
||||
{
|
||||
printf("loadlang fail\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(langctrl_str, "en") == 0)
|
||||
current = &en;
|
||||
else if (strcmp(langctrl_str, "tr") == 0)
|
||||
current = &tr;
|
||||
|
||||
sprintf(common_symbol_rule, "%s\n", current->common_symbol_rule);
|
||||
sprintf(common_symbol_rule, "%s", current->common_symbol_rule);
|
||||
|
||||
if (search_sls() == 0)
|
||||
{
|
||||
@@ -119,7 +119,11 @@ int main(int argc, char* argv[])
|
||||
LOGE("%s.\n%s `%s --help' %s.\n", current->missing_operand, current->try_h, argv[0], current->for_more);
|
||||
|
||||
/* a structure for long arguments */
|
||||
struct option long_options[] = {
|
||||
struct option option_table[] = {
|
||||
{"backup", no_argument, 0, 'b'},
|
||||
{"flash", no_argument, 0, 'F'},
|
||||
{"format", no_argument, 0, 'r'},
|
||||
{"is_dummy", no_argument, 0, 'D'},
|
||||
{"logical", no_argument, 0, 'l'},
|
||||
{"context", required_argument, 0, 'c'},
|
||||
{"list", no_argument, 0, 'p'},
|
||||
@@ -134,8 +138,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
/* boolean statements (only valid in this file) to distinguish. and pointer from a shortcut for the symbol rule */
|
||||
static bool wiew_help = false;
|
||||
static bool wiew_licenses = false;
|
||||
static bool wiew_version = false;
|
||||
static bool logical_spec = false;
|
||||
static bool list_partitions = false;
|
||||
static bool combo_wiewers = false;
|
||||
static bool pmt_setlang = false;
|
||||
@@ -143,20 +147,104 @@ int main(int argc, char* argv[])
|
||||
static int search_result = 3;
|
||||
static int opt;
|
||||
|
||||
if (strcmp(argv[1], "backup") == 0)
|
||||
{
|
||||
if (argc <= 2)
|
||||
LOGE("%s 0.\n", current->expected_backup_arg);
|
||||
|
||||
if (ctrl_arg(argv[2]))
|
||||
target_partition = argv[2];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
out = target_partition;
|
||||
|
||||
if (argc > 3 && ctrl_arg(argv[3]))
|
||||
out = argv[3];
|
||||
|
||||
check_optsym(target_partition);
|
||||
check_optsym(out);
|
||||
|
||||
pmt_backup = true;
|
||||
}
|
||||
else if (strcmp(argv[1], "flash") == 0)
|
||||
{
|
||||
if (argc <= 2)
|
||||
LOGE("%s 0.\n", current->expected_flash_arg);
|
||||
|
||||
if (argc <= 3)
|
||||
LOGE("%s 1.\n", current->expected_flash_arg);
|
||||
|
||||
if (ctrl_arg(argv[2]))
|
||||
target_partition = argv[2];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
if (ctrl_arg(argv[3]))
|
||||
target_flash_file = argv[3];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
check_optsym(target_flash_file);
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_flash = true;
|
||||
}
|
||||
else if (strcmp(argv[1], "format") == 0)
|
||||
{
|
||||
|
||||
if (argc <= 2)
|
||||
LOGE("%s 0.\n", current->expected_format_arg);
|
||||
|
||||
if (argc <= 3)
|
||||
LOGE("%s 1.\n", current->expected_format_arg);
|
||||
|
||||
if (ctrl_arg(argv[2]))
|
||||
target_partition = argv[2];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
if (ctrl_arg(argv[3]))
|
||||
format_fs = argv[3];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
check_optsym(format_fs);
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_format = true;
|
||||
}
|
||||
|
||||
/* control for each argument */
|
||||
while ((opt = getopt_long(argc, argv, "lc:psfS:vL", long_options, NULL)) != -1)
|
||||
while ((opt = getopt_long(argc, argv, "bFrDlc:psfS:vL", option_table, NULL)) != -1)
|
||||
{
|
||||
/* process arguments */
|
||||
switch (opt)
|
||||
{
|
||||
/* handle deprecates */
|
||||
case 'b':
|
||||
DEPR_HANDLE('b', "backup", current->depr_backup_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'F':
|
||||
DEPR_HANDLE('F', "flash", current->depr_flash_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'r':
|
||||
DEPR_HANDLE('r', "format", current->depr_format_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'D':
|
||||
DEPR_HANDLE('D', "NULLPTR", current->depr_ch_list_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'L':
|
||||
DEPR_HANDLE('L', "license", current->depr_Vlicense_opt);
|
||||
exit(1);
|
||||
break;
|
||||
/* logical partitions option */
|
||||
case 'l':
|
||||
check_root();
|
||||
check_dev_point();
|
||||
if (pmt_logical)
|
||||
pmt_use_logical = true;
|
||||
else
|
||||
LOGE("%s\n", current->not_logical);
|
||||
logical_spec = true;
|
||||
break;
|
||||
/* context selector option */
|
||||
case 'c':
|
||||
@@ -168,7 +256,7 @@ int main(int argc, char* argv[])
|
||||
case 'p':
|
||||
list_partitions = true;
|
||||
/* check combo wiewer options and progress */
|
||||
if (wiew_version || wiew_help || wiew_licenses) combo_wiewers = true;
|
||||
if (wiew_version || wiew_help) combo_wiewers = true;
|
||||
break;
|
||||
/* force mode option */
|
||||
case 'f':
|
||||
@@ -187,19 +275,13 @@ int main(int argc, char* argv[])
|
||||
case 'v':
|
||||
wiew_version = true;
|
||||
/* check combo wiewer options and progress */
|
||||
if (list_partitions || wiew_help || wiew_licenses) combo_wiewers = true;
|
||||
if (list_partitions || wiew_help) combo_wiewers = true;
|
||||
break;
|
||||
/* help message opption */
|
||||
case 0:
|
||||
wiew_help = true;
|
||||
/* check combo wiewer options and progress */
|
||||
if (wiew_version || list_partitions || wiew_licenses) combo_wiewers = true;
|
||||
break;
|
||||
/* license wiewer option */
|
||||
case 'L':
|
||||
wiew_licenses = true;
|
||||
/* check combo wiewer options and progress */
|
||||
if (wiew_version || wiew_help || list_partitions) combo_wiewers = true;
|
||||
if (wiew_version || list_partitions) combo_wiewers = true;
|
||||
break;
|
||||
/* for invalid options */
|
||||
case '?':
|
||||
@@ -207,7 +289,7 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
LOGD("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-p | --list] [-v | --version] [--help] [-L | --license]\n", current->usage_head, argv[0]);
|
||||
LOGD("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-p | --list] [-s | --silent] [-v | --version] [--help]\n", current->usage_head, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -227,11 +309,6 @@ int main(int argc, char* argv[])
|
||||
version();
|
||||
return 0;
|
||||
}
|
||||
else if (wiew_licenses)
|
||||
{
|
||||
licenses();
|
||||
return 0;
|
||||
}
|
||||
else if (list_partitions)
|
||||
{
|
||||
check_root();
|
||||
@@ -241,81 +318,31 @@ int main(int argc, char* argv[])
|
||||
if (pmt_setlang)
|
||||
{
|
||||
LOGD("%s: %s\n", argv[0], current->switching_lang);
|
||||
setlang(langpr);
|
||||
setlang(langpr, 0);
|
||||
sleep(2);
|
||||
LOGD("%s: %s.\n", argv[0], current->please_rerun);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* detect target mode */
|
||||
static char arg1[20];
|
||||
sprintf(arg1, "%s", argv[1]);
|
||||
|
||||
if (strcmp(argv[1], "backup") == 0)
|
||||
{
|
||||
if (argc == 2)
|
||||
LOGE("%s 0.\n", current->expected_backup_arg);
|
||||
|
||||
target_partition = argv[2];
|
||||
|
||||
if (argc == 3)
|
||||
out = target_partition;
|
||||
else
|
||||
out = argv[3];
|
||||
|
||||
check_optsym(target_partition);
|
||||
check_optsym(out);
|
||||
|
||||
pmt_backup = true;
|
||||
}
|
||||
else if (strcmp(argv[1], "flash") == 0)
|
||||
{
|
||||
if (argc == 2)
|
||||
LOGE("%s 0.\n", current->expected_flash_arg);
|
||||
|
||||
if (argc == 2)
|
||||
LOGE("%s 1.\n", current->expected_flash_arg);
|
||||
|
||||
target_flash_file = argv[2];
|
||||
|
||||
target_partition = argv[3];
|
||||
|
||||
check_optsym(target_flash_file);
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_flash = true;
|
||||
}
|
||||
else if (strcmp(argv[1], "format") == 0)
|
||||
{
|
||||
|
||||
if (argc == 2)
|
||||
LOGE("%s 0.\n", current->expected_format_arg);
|
||||
|
||||
if (argc == 3)
|
||||
LOGE("%s 1.\n", current->expected_format_arg);
|
||||
|
||||
format_fs = argv[2];
|
||||
|
||||
target_partition = argv[3];
|
||||
|
||||
check_optsym(format_fs);
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_format = true;
|
||||
}
|
||||
|
||||
/* target control is done */
|
||||
if (!pmt_backup && !pmt_flash && !pmt_format)
|
||||
LOGE("%s `%s --help` %s\n", current->missing_operand, current->try_h, current->for_more);
|
||||
LOGE("%s.\n%s `%s --help` %s\n", current->no_target, current->try_h, argv[0], current->for_more);
|
||||
|
||||
if (pmt_format)
|
||||
{
|
||||
if (strcmp(format_fs, "ext4") != 0 && strcmp(format_fs, "ext3") != 0 && strcmp(format_fs, "ext2") != 0)
|
||||
LOGE("%s: %s\n", current->unsupported_fs, format_fs);
|
||||
}
|
||||
|
||||
/* checks */
|
||||
check_root();
|
||||
check_dev_point();
|
||||
|
||||
if (pmt_format)
|
||||
if (logical_spec)
|
||||
{
|
||||
if (strcmp(format_fs, "ext4") != 0 || strcmp(format_fs, "ext3") != 0 || strcmp(format_fs, "ext2") != 0)
|
||||
LOGE("%s: %s\n", current->unsupported_fs, format_fs);
|
||||
if (pmt_logical)
|
||||
pmt_use_logical = true;
|
||||
else
|
||||
LOGE("%s\n", current->not_logical);
|
||||
}
|
||||
|
||||
if (pmt_flash)
|
||||
@@ -362,13 +389,11 @@ int main(int argc, char* argv[])
|
||||
return pmt(2);
|
||||
else if (pmt_format)
|
||||
return pmt(3);
|
||||
else
|
||||
LOGE("%s\n%s `%s --help' %s\n", current->no_target, current->try_h, argv[0], current->for_more);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
/* end of code */
|
||||
|
||||
13
jni/root.c
13
jni/root.c
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,18 +16,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_DEBUGERS
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
extern struct pmt_langdb_general* current;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
|
||||
/* root checker function */
|
||||
void check_root(void)
|
||||
@@ -37,7 +34,7 @@ void check_root(void)
|
||||
LOGE("%s\n", current->no_root);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
49
jni/tools.c
49
jni/tools.c
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -26,26 +26,8 @@ extern "C" {
|
||||
#define INC_DEBUGERS
|
||||
#define INC_TOOLS_REQS
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
extern char* out;
|
||||
extern char* format_fs;
|
||||
extern char* cust_cxt;
|
||||
extern char* target_partition;
|
||||
extern char* target_flash_file;
|
||||
extern char* partition_type;
|
||||
extern char* bin_name;
|
||||
extern bool pmt_use_logical;
|
||||
extern bool pmt_use_cust_cxt;
|
||||
extern bool pmt_logical;
|
||||
extern bool pmt_flash;
|
||||
extern bool pmt_backup;
|
||||
extern bool pmt_silent;
|
||||
extern bool pmt_force_mode;
|
||||
|
||||
extern struct pmt_langdb_general* current;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
|
||||
/**
|
||||
* it is meant to calculate the size of the quickly given file.
|
||||
@@ -80,8 +62,6 @@ partition_not_found(void) { LOGE("%s\n", current->part_not_found); }
|
||||
/* to stop use of function type */
|
||||
#define partition_not_found partition_not_found()
|
||||
|
||||
|
||||
|
||||
/* the partitions are meant to quickly find. */
|
||||
static void
|
||||
search_partition(const char* _Nonnull partition)
|
||||
@@ -135,13 +115,13 @@ int pmt(unsigned short progress_code)
|
||||
/* determine output */
|
||||
if (strcmp(out, target_partition) == 0)
|
||||
{
|
||||
sprintf(outf, "%s.img", target_partition);
|
||||
sprintf(outf, "%s.img", out);
|
||||
LOGW("%s: %s\n", current->out_not_spec, outf);
|
||||
}
|
||||
else
|
||||
sprintf(outf, "%s", target_partition);
|
||||
sprintf(outf, "%s", out);
|
||||
|
||||
targetf = open(outf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
targetf = open(outf, O_WRONLY | O_CREAT | O_TRUNC, 0660);
|
||||
if (targetf == -1)
|
||||
LOGE("%s: %s: %s\n", current->not_gen, outf, strerror(errno));
|
||||
|
||||
@@ -188,19 +168,22 @@ int pmt(unsigned short progress_code)
|
||||
else
|
||||
LOGW("%s\n", current->flash_file_sz_fail);
|
||||
|
||||
if (calc_flsz(target_partition) != -1)
|
||||
LOGD("%s: %.2f\n", current->part_disk_sz, calc_flsz(target_partition));
|
||||
if (calc_flsz(flasher_path) != -1)
|
||||
LOGD("%s: %.2f\n", current->part_disk_sz, calc_flsz(flasher_path));
|
||||
else
|
||||
LOGW("%s\n", current->part_disk_sz_fail);
|
||||
|
||||
if (calc_flsz(target_flash_file) > calc_flsz(target_partition))
|
||||
LOGE("%s\n", current->ffile_more_part);
|
||||
if (calc_flsz(target_flash_file) != -1 && calc_flsz(flasher_path) != -1)
|
||||
{
|
||||
if (calc_flsz(target_flash_file) > calc_flsz(flasher_path))
|
||||
LOGE("%s\n", current->ffile_more_part);
|
||||
}
|
||||
|
||||
srcf = open(target_flash_file, O_RDONLY);
|
||||
if (srcf == -1)
|
||||
LOGF("%s: %s: %s\n", current->not_read, target_flash_file, strerror(errno));
|
||||
|
||||
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0660);
|
||||
if (targetf == -1)
|
||||
LOGF("%s: %s: %s\n", current->not_read, target_partition, strerror(errno));
|
||||
|
||||
@@ -252,7 +235,7 @@ int pmt(unsigned short progress_code)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -16,20 +16,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_VERSIONER_REQS
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
extern char* bin_name;
|
||||
|
||||
extern struct pmt_langdb_general* current;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
#include <pmt/pmt.h>
|
||||
#include <pmt/stringkeys.h>
|
||||
#include <pmt/versioning.h>
|
||||
|
||||
void version(void)
|
||||
{
|
||||
@@ -43,14 +38,14 @@ void version(void)
|
||||
LOGD("<%s> %s\n", current->unknw_str, current->bin_str);
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
LOGD("%s: clang %d.%d.%d (NDK r%d%s %s)\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__, __NDK_MAJOR__, __NDK_MINOR_STATUS__, __NDK_BETA_STATUS__);
|
||||
#if defined(__clang__) && !defined(__NDK_BUILD)
|
||||
LOGD("%s: clang %d.%d.%d\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
#elif defined(__clang__) && defined(__NDK_BUILD)
|
||||
LOGD("%s\n", __NDK_CC_VERSION__);
|
||||
#endif
|
||||
|
||||
LOGD("%s\n", current->see_license);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user