Make some corrections.

This commit is contained in:
2024-06-10 06:28:01 +03:00
parent d0a7b2d16f
commit 99ecb9daf3
15 changed files with 42 additions and 52 deletions

Binary file not shown.

BIN
debutils/mandoc/pmt.8.gz Executable file

Binary file not shown.

View File

@@ -25,7 +25,7 @@ extern "C" {
extern char* bin_name;
void licenses()
void licenses(void)
{
printf("Copyright 2024 Partition Manager\n");
printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
@@ -38,7 +38,7 @@ void licenses()
printf("See the License for the specific language governing permissions and limitations under the License.\n");
}
void help()
void help(void)
{
printf("Usage: \n");
printf(" %s backup PARTITION [OUTPUT] [OPTIONS]...\n", bin_name);

View File

@@ -16,15 +16,11 @@
* limitations under the License.
*/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
__BEGIN_DECLS
void help();
void licenses();
void help(void);
void licenses(void);
#if defined(__cplusplus)
}
#endif /* __cplusplus */
__END_DECLS
/* end */

View File

@@ -16,17 +16,13 @@
* limitations under the License.
*/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
__BEGIN_DECLS
/* versioning */
#define PMT_MAJOR 2
#define PMT_MINOR 1
#define PMT_PATCHLEVEL 0
#if defined(__cplusplus)
}
#endif /* __cplusplus */
__END_DECLS
/* end */

View File

@@ -16,9 +16,7 @@
* limitations under the License.
*/
#if defined(__cplusplus)
extern "C" {
#endif
__BEGIN_DECLS
#if !defined(__PMT_H_)
#define __PMT_H_
@@ -50,16 +48,14 @@ extern bool pmt_format;
extern bool pmt_force_mode;
/* function definations */
int listpart();
void check_dev_point();
void check_root();
int listpart(void);
void check_dev_point(void);
void check_root(void);
int pmt(unsigned short progress_code);
void version();
void version(void);
#endif /* __PMT_H_ */
#if defined(__cplusplus)
}
#endif /* __cplusplus */
__END_DECLS
/* end of code */

View File

@@ -40,7 +40,7 @@ extern char* cust_cxt;
extern char* bin_name;
/* list existing partitions */
int listpart() {
int listpart(void) {
DIR *dir;
struct dirent *entry;

View File

@@ -69,3 +69,5 @@ void check_dev_point()
#if defined(__cplusplus)
}
#endif /* __cplusplus */
/* end */

View File

@@ -205,7 +205,7 @@ int main(int argc, char* argv[])
break;
default:
printf("Usage: %s [backup] flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", argv[0]);
exit(EX_USAGE);
return EX_USAGE;
}
}

View File

@@ -29,7 +29,7 @@ extern "C" {
#include <pmt.h>
/* root checker function */
void check_root()
void check_root(void)
{
/* a quick, easy method to verify root */
if (getuid() != 0)

View File

@@ -84,7 +84,7 @@ calc_flsz(const char* _Nonnull filepath)
* It's for quick action.
*/
static int
partition_not_found()
partition_not_found(void)
{
if (!pmt_silent) errx(EX_OSFILE, "partition not found!");
else return EX_OSFILE;
@@ -95,7 +95,7 @@ partition_not_found()
* It's for quick action.
*/
static int
invalid_partition_type()
invalid_partition_type(void)
{
if (!pmt_silent) errx(EX_USAGE, "invalid partition type!");
else exit(EX_USAGE);
@@ -142,7 +142,7 @@ search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
else return -1;
}
return 0;
return 2;
}
/* the partitions are meant to quickly find. */

View File

@@ -26,7 +26,7 @@ extern "C" {
extern char* bin_name;
void version()
void version(void)
{
printf("%s version %d.%d.%d (code %d%d%d) ", bin_name, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);

View File

@@ -19,13 +19,23 @@
RED='\e[31m'
NC='\e[0m'
# needed variables
VERSION="2.1.0"
CUR_DIR=$(pwd)
LIB_DIR=${CUR_DIR}/libs
ARMV8A_DIR=${LIB_DIR}/arm64-v8a
ARMV7A_DIR=${LIB_DIR}/armeabi-v7a
DEB_DIR=${CUR_DIR}/deb
DEBUTILS_DIR=${CUR_DIR}/debutils
DEBTERMUX_USR=${DEBUTILS_DIR}/data/data/com.termux/files/usr
# error messages
abort() {
if [ ! "$1" = "" ]; then
printf "${RED}${1}${NC}\n"
fi
if [ -d ${DEBUTILS_DIR}/temp ]; then
rm -rf ${DEB_DIR}/temp
rm -rf ${DEBUTILS_DIR}/temp
fi
exit 1
}
@@ -55,16 +65,6 @@ case "$2" in
SUDO=""
esac
# variables
VERSION="2.1.0"
CUR_DIR=$(pwd)
LIB_DIR=${CUR_DIR}/libs
ARMV8A_DIR=${LIB_DIR}/arm64-v8a
ARMV7A_DIR=${LIB_DIR}/armeabi-v7a
DEB_DIR=${CUR_DIR}/deb
DEBUTILS_DIR=${CUR_DIR}/debutils
DEBTERMUX_USR=${DEBUTILS_DIR}/data/data/com.termux/files/usr
# set file modes (all) to 755
${SUDO} chmod -R 755 *
@@ -92,11 +92,11 @@ fi
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin ]; then
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin\n"
fi
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man1 ]; then
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man1\n"
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8 ]; then
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8\n"
fi
if [ ! -f ${DEBUTILS_DIR}/mandoc/pmt.1 ]; then
abort " - Not found: ${DEBUTILS_DIR}/mandoc/pmt.1\n"
if [ ! -f ${DEBUTILS_DIR}/mandoc/pmt.8.gz ]; then
abort " - Not found: ${DEBUTILS_DIR}/mandoc/pmt.8.gz\n"
fi
if [ ! -f ${DEBUTILS_DIR}/DEBIAN/control_32 ]; then
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN/control_32\n"
@@ -121,14 +121,14 @@ ${SUDO} mkdir -p ${DEB_DIR} || abort
# copy files
printf " - Copying files...\n"
${SUDO} cp -r ${DEBUTILS_DIR}/data ${DEBUTILS_DIR}/temp || abort
${SUDO} rm -f ${DEBTERMUX_USR}/share/man/man1/dummy
${SUDO} rm -f ${DEBTERMUX_USR}/share/man/man8/dummy
${SUDO} rm -f ${DEBTERMUX_USR}/bin/dummy
${SUDO} mkdir -p ${DEBUTILS_DIR}/temp/DEBIAN || abort
# select control file
printf " - Selected arm-${PREFIX} package control file.\n"
${SUDO} cp ${DEBUTILS_DIR}/DEBIAN/control_${PREFIX} ${DEBUTILS_DIR}/temp/DEBIAN/control || exit 1
${SUDO} cp ${DEBUTILS_DIR}/mandoc/pmt.1.gz ${DEBTERMUX_USR}/share/man/man1 || abort
${SUDO} cp ${DEBUTILS_DIR}/mandoc/pmt.8.gz ${DEBTERMUX_USR}/share/man/man8 || abort
if [ "${PREFIX}" = "64" ]; then
${SUDO} cp ${ARMV8A_DIR}/pmt ${DEBTERMUX_USR}/bin || abort
elif [ "${PREFIX}" = "32" ]; then