Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
CherryPill committed Jun 3, 2023
1 parent 959a5fc commit 4b26c3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/consts/text_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

#include <tchar.h>

enum errorMsgResolver {
openFileError = 0,
enum ErrorMsgResolver {
OpenFileError = 0,
CryptAcquireCtxError,
CryptCreateHashError,
CryptHashDataError,
fileReadError,
clipboardError
FileReadError,
ClipboardError
};

static TCHAR* errorMessages[] = {
Expand Down
10 changes: 5 additions & 5 deletions src/enc/hashing.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void generateHash(TCHAR *filePath, char *hash) {
GetFileSizeEx(hFile, &totalBytes);

if (hFile == INVALID_HANDLE_VALUE) {
enum errorMsgResolver errorMsgIdx = openFileError;
enum ErrorMsgResolver errorMsgIdx = OpenFileError;
struct ERROR_INFO errorInfo = {errorMessages[errorMsgIdx], GetLastError()};
handleError(errorInfo);
}
Expand All @@ -53,7 +53,7 @@ void generateHash(TCHAR *filePath, char *hash) {
CRYPT_VERIFYCONTEXT)) {
CloseHandle(hFile);

enum errorMsgResolver errorMsgIdx = CryptAcquireCtxError;
enum ErrorMsgResolver errorMsgIdx = CryptAcquireCtxError;
struct ERROR_INFO errorInfo = {errorMessages[errorMsgIdx], GetLastError()};
handleError(errorInfo);
}
Expand All @@ -63,7 +63,7 @@ void generateHash(TCHAR *filePath, char *hash) {
CloseHandle(hFile);
CryptReleaseContext(hProv, 0);

enum errorMsgResolver errorMsgIdx = CryptCreateHashError;
enum ErrorMsgResolver errorMsgIdx = CryptCreateHashError;
struct ERROR_INFO errorInfo = {errorMessages[errorMsgIdx], GetLastError()};
handleError(errorInfo);
}
Expand All @@ -75,7 +75,7 @@ void generateHash(TCHAR *filePath, char *hash) {
}
if (!CryptHashData(hHash, rgbFile, cbRead, 0)) {
cleanUpResources(hProv, hHash, hFile);
enum errorMsgResolver errorMsgIdx = CryptHashDataError;
enum ErrorMsgResolver errorMsgIdx = CryptHashDataError;
struct ERROR_INFO errorInfo = {errorMessages[errorMsgIdx], GetLastError()};
handleError(errorInfo);
}
Expand All @@ -95,7 +95,7 @@ void generateHash(TCHAR *filePath, char *hash) {

if (!bResult) {
cleanUpResources(hProv, hHash, hFile);
enum errorMsgResolver errorMsgIdx = fileReadError;
enum ErrorMsgResolver errorMsgIdx = FileReadError;
struct ERROR_INFO errorInfo = {errorMessages[errorMsgIdx], GetLastError()};
}
cbHash = MD5LEN;
Expand Down
2 changes: 1 addition & 1 deletion src/proc/mainwindowProc.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void copyToClipBoard(HWND parent, const char *hashText) {
CloseClipboard();
SetWindowText(infoHolderLabel, "Copied to clipboard");
} else {
enum errorMsgResolver errorMsgIdx = clipboardError;
enum ErrorMsgResolver errorMsgIdx = ClipboardError;
SetWindowText(infoHolderLabel, errorMessages[errorMsgIdx]);
}
}
Expand Down

0 comments on commit 4b26c3f

Please sign in to comment.