pmt.c: cleanup unnecessary code and fix wrong log text
pmt: cleanup pmt: cleanup
This commit is contained in:
@@ -53,53 +53,6 @@ extern int pmt_langdb_ctrl;
|
|||||||
|
|
||||||
FILE *langconf;
|
FILE *langconf;
|
||||||
|
|
||||||
/**
|
|
||||||
* The target file is controlled by the stat function.
|
|
||||||
* Files, directories, links and blocks (disks) are for.
|
|
||||||
* If it is never found, it returns 1 value.
|
|
||||||
* If he finds 0 value is returned.
|
|
||||||
* If the desired type is not in -1 value is returned.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
|
||||||
{
|
|
||||||
struct stat search_stat;
|
|
||||||
|
|
||||||
if (stat(filepath, &search_stat) != 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (strcmp(stype, "dir") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISDIR(search_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "file") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISREG(search_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "blk") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISBLK(search_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "link") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISLNK(search_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
langctrl(const char* _Nonnull lang_)
|
langctrl(const char* _Nonnull lang_)
|
||||||
{
|
{
|
||||||
@@ -114,12 +67,12 @@ char* loadlang(void)
|
|||||||
static char lang_fpr[10] = "en";
|
static char lang_fpr[10] = "en";
|
||||||
langconf = NULL;
|
langconf = NULL;
|
||||||
|
|
||||||
if (search_stat(TERMUX_PMT_MANDOC, "file") == 0)
|
if (get_stat(TERMUX_PMT_MANDOC, "file") == 0)
|
||||||
pmt_inst_on_termux = true;
|
pmt_inst_on_termux = true;
|
||||||
|
|
||||||
if (pmt_inst_on_termux)
|
if (pmt_inst_on_termux)
|
||||||
{
|
{
|
||||||
if (search_stat(TERMUX_PMTLANG_CONF, "file") == 0)
|
if (get_stat(TERMUX_PMTLANG_CONF, "file") == 0)
|
||||||
{
|
{
|
||||||
langconf = fopen(TERMUX_PMTLANG_CONF, "r+");
|
langconf = fopen(TERMUX_PMTLANG_CONF, "r+");
|
||||||
|
|
||||||
@@ -155,7 +108,7 @@ char* loadlang(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (search_stat(INTRNL_PMTLANG_CONF, "file") == 0)
|
if (get_stat(INTRNL_PMTLANG_CONF, "file") == 0)
|
||||||
{
|
{
|
||||||
langconf = fopen(INTRNL_PMTLANG_CONF, "r");
|
langconf = fopen(INTRNL_PMTLANG_CONF, "r");
|
||||||
|
|
||||||
@@ -203,7 +156,7 @@ void setlang(const char* _Nonnull lang)
|
|||||||
else
|
else
|
||||||
lcf_path = INTRNL_PMTLANG_CONF;
|
lcf_path = INTRNL_PMTLANG_CONF;
|
||||||
|
|
||||||
if (search_stat(lcf_path, "file") == 0)
|
if (get_stat(lcf_path, "file") == 0)
|
||||||
remove(lcf_path);
|
remove(lcf_path);
|
||||||
|
|
||||||
langconf = NULL;
|
langconf = NULL;
|
||||||
@@ -251,7 +204,7 @@ int search_sls(void)
|
|||||||
else
|
else
|
||||||
sw_point_path = INTRNL_PMT_SW_POINT;
|
sw_point_path = INTRNL_PMT_SW_POINT;
|
||||||
|
|
||||||
if (search_stat(sw_point_path, "file") == 0)
|
if (get(sw_point_path, "file") == 0)
|
||||||
{
|
{
|
||||||
remove(sw_point_path);
|
remove(sw_point_path);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
49
jni/pmt.c
49
jni/pmt.c
@@ -75,53 +75,6 @@ check_optsym(const char* _Nonnull mystring)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The target file is controlled by the stat function.
|
|
||||||
* Files, directories, links and blocks (disks) are for.
|
|
||||||
* If it is never found, it returns 1 value.
|
|
||||||
* If he finds 0 value is returned.
|
|
||||||
* If the desired type is not in -1 value is returned.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
get_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
|
||||||
{
|
|
||||||
struct stat get_stat;
|
|
||||||
|
|
||||||
if (stat(filepath, &get_stat) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (strcmp(stype, "dir") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISDIR(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "file") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISREG(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "blk") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISBLK(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "link") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISLNK(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* classic main function (C binary here xd) */
|
/* classic main function (C binary here xd) */
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
@@ -141,7 +94,7 @@ int main(int argc, char* argv[])
|
|||||||
if (search_sls() == 0)
|
if (search_sls() == 0)
|
||||||
{
|
{
|
||||||
if (current->welcome_ != NULL)
|
if (current->welcome_ != NULL)
|
||||||
LOGD("%s\n", current->welcome_);
|
LOGD("%s", current->welcome_);
|
||||||
|
|
||||||
LOGD("%s %s %s %s.\n", current->language, current->welcome, current->by_str, current->lang_by_s);
|
LOGD("%s %s %s %s.\n", current->language, current->welcome, current->by_str, current->lang_by_s);
|
||||||
}
|
}
|
||||||
|
|||||||
45
jni/tools.c
45
jni/tools.c
@@ -80,52 +80,7 @@ partition_not_found(void) { LOGE("%s\n", current->part_not_found); }
|
|||||||
/* to stop use of function type */
|
/* to stop use of function type */
|
||||||
#define partition_not_found partition_not_found()
|
#define partition_not_found partition_not_found()
|
||||||
|
|
||||||
/**
|
|
||||||
* The target file is controlled by the stat function.
|
|
||||||
* Files, directories, links and blocks (disks) are for.
|
|
||||||
* If it is never found, it returns 1 value.
|
|
||||||
* If he finds 0 value is returned.
|
|
||||||
* If the desired type is not in -1 value is returned.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
get_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
|
||||||
{
|
|
||||||
struct stat get_stat;
|
|
||||||
|
|
||||||
if (stat(filepath, &get_stat) != 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (strcmp(stype, "dir") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISDIR(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "file") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISREG(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "blk") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISBLK(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (strcmp(stype, "link") == 0)
|
|
||||||
{
|
|
||||||
if (S_ISLNK(get_stat.st_mode))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the partitions are meant to quickly find. */
|
/* the partitions are meant to quickly find. */
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user