From 29eba8983f1f34cabad929e1463e147e1da1517c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Wed, 22 May 2024 03:57:10 +0900 Subject: [PATCH] . --- src/chkpass.c | 23 ++++++++++------------- src/chkpass.h | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/chkpass.c b/src/chkpass.c index c412679..4b3788b 100644 --- a/src/chkpass.c +++ b/src/chkpass.c @@ -1,10 +1,7 @@ // TODO:未完了 -#include #include -#include -#include -#include +#include "common.h" #include "chkpass.h" #include "showpass.h" @@ -13,13 +10,13 @@ struct PassList { char password[256]; }; -void chkpass(char* basePath) { - char *lang = getenv("SP_LANG"); +void chkpass(char *basePath) { + char *lang = getlang(); // パスワードを保存する struct PassList* allpass = malloc(2048 * sizeof(struct PassList)); if (allpass == NULL) { - if (lang != NULL && strncmp(lang, "en", 2) == 0) + if (strncmp(lang, "en", 2) == 0) perror("Failed to allocating memory"); else perror("メモリを役割に失敗"); return; @@ -28,7 +25,7 @@ void chkpass(char* basePath) { struct dirent* entry; DIR* dir = opendir(basePath); if (!dir) { - if (lang != NULL && strncmp(lang, "en", 2) == 0) + if (strncmp(lang, "en", 2) == 0) perror("Could not opening directory"); else perror("ディレクトリを開けられません"); free(allpass); @@ -45,7 +42,7 @@ void chkpass(char* basePath) { char path[1000]; int needed = snprintf(path, sizeof(path), "%s/%s", basePath, entry->d_name); if (needed >= (int)sizeof(path) || needed < 0) { - if (lang != NULL && strncmp(lang, "en", 2) == 0) + if (strncmp(lang, "en", 2) == 0) perror("Error: Path is too long, or failed to getting lenth"); else perror("エラー:パスが長すぎる、又は長さを受取に失敗"); continue; @@ -53,7 +50,7 @@ void chkpass(char* basePath) { struct stat statbuf; if (stat(path, &statbuf) == -1) { - if (lang != NULL && strncmp(lang, "en", 2) == 0) + if (strncmp(lang, "en", 2) == 0) perror("Failed to reading file status"); else perror("ファイル状況を読込に失敗"); continue; @@ -63,14 +60,14 @@ void chkpass(char* basePath) { continue; } - char* filename = entry->d_name; - char* ext = strstr(filename, ".gpg"); + char *filename = entry->d_name; + char *ext = strstr(filename, ".gpg"); if (ext) *ext = '\0'; char spath[2048]; snprintf(spath, sizeof(spath), "%s/%s", path, filename); if (i >= 2048) { - if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Too much password"); + if (strncmp(lang, "en", 2) == 0) perror("Too much password"); else perror("パスワードが多すぎる"); break; } diff --git a/src/chkpass.h b/src/chkpass.h index 26d674b..20ffc6a 100644 --- a/src/chkpass.h +++ b/src/chkpass.h @@ -1,6 +1,6 @@ #ifndef CHKPASS_H #define CHKPASS_H -void chkpass(char* basePath); +void chkpass(char *basePath); #endif