このコミットが含まれているのは:
守矢諏訪子 2024-05-22 03:57:10 +09:00
コミット 29eba8983f
2個のファイルの変更11行の追加14行の削除

ファイルの表示

@ -1,10 +1,7 @@
// TODO:未完了 // TODO:未完了
#include <stdio.h>
#include <dirent.h> #include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#include "common.h"
#include "chkpass.h" #include "chkpass.h"
#include "showpass.h" #include "showpass.h"
@ -13,13 +10,13 @@ struct PassList {
char password[256]; char password[256];
}; };
void chkpass(char* basePath) { void chkpass(char *basePath) {
char *lang = getenv("SP_LANG"); char *lang = getlang();
// パスワードを保存する // パスワードを保存する
struct PassList* allpass = malloc(2048 * sizeof(struct PassList)); struct PassList* allpass = malloc(2048 * sizeof(struct PassList));
if (allpass == NULL) { if (allpass == NULL) {
if (lang != NULL && strncmp(lang, "en", 2) == 0) if (strncmp(lang, "en", 2) == 0)
perror("Failed to allocating memory"); perror("Failed to allocating memory");
else perror("メモリを役割に失敗"); else perror("メモリを役割に失敗");
return; return;
@ -28,7 +25,7 @@ void chkpass(char* basePath) {
struct dirent* entry; struct dirent* entry;
DIR* dir = opendir(basePath); DIR* dir = opendir(basePath);
if (!dir) { if (!dir) {
if (lang != NULL && strncmp(lang, "en", 2) == 0) if (strncmp(lang, "en", 2) == 0)
perror("Could not opening directory"); perror("Could not opening directory");
else perror("ディレクトリを開けられません"); else perror("ディレクトリを開けられません");
free(allpass); free(allpass);
@ -45,7 +42,7 @@ void chkpass(char* basePath) {
char path[1000]; char path[1000];
int needed = snprintf(path, sizeof(path), "%s/%s", basePath, entry->d_name); int needed = snprintf(path, sizeof(path), "%s/%s", basePath, entry->d_name);
if (needed >= (int)sizeof(path) || needed < 0) { 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"); perror("Error: Path is too long, or failed to getting lenth");
else perror("エラー:パスが長すぎる、又は長さを受取に失敗"); else perror("エラー:パスが長すぎる、又は長さを受取に失敗");
continue; continue;
@ -53,7 +50,7 @@ void chkpass(char* basePath) {
struct stat statbuf; struct stat statbuf;
if (stat(path, &statbuf) == -1) { 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"); perror("Failed to reading file status");
else perror("ファイル状況を読込に失敗"); else perror("ファイル状況を読込に失敗");
continue; continue;
@ -63,14 +60,14 @@ void chkpass(char* basePath) {
continue; continue;
} }
char* filename = entry->d_name; char *filename = entry->d_name;
char* ext = strstr(filename, ".gpg"); char *ext = strstr(filename, ".gpg");
if (ext) *ext = '\0'; if (ext) *ext = '\0';
char spath[2048]; char spath[2048];
snprintf(spath, sizeof(spath), "%s/%s", path, filename); snprintf(spath, sizeof(spath), "%s/%s", path, filename);
if (i >= 2048) { 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("パスワードが多すぎる"); else perror("パスワードが多すぎる");
break; break;
} }

ファイルの表示

@ -1,6 +1,6 @@
#ifndef CHKPASS_H #ifndef CHKPASS_H
#define CHKPASS_H #define CHKPASS_H
void chkpass(char* basePath); void chkpass(char *basePath);
#endif #endif