From ad8d88a066392ea37d3f823eade43cf80b197890 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Wed, 25 Jul 2018 02:34:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code=20quality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 30f3323..32130d8 100644 --- a/src/main.c +++ b/src/main.c @@ -11,6 +11,7 @@ #define BUFFER_SIZE 0xffffUL #define ENCRYPTION_HEADER_LENGTH 12UL +#define LOCAL_FILE_HEADER_MAGIC (uint32_t)0x04034b50 uint16_t getUint16(char* buffer) { return (uint16_t)buffer[0] | \ @@ -25,7 +26,7 @@ uint32_t getUint32(char* buffer) { int main(int argc, unsigned char *argv[]) { if (argc != 4 && argc != 7) { - fprintf(stderr, "Wrong arguments. Usage: patcher-installer [ ]"); + fprintf(stderr, "Wrong number of arguments. Usage: patcher-installer [ ]"); exit(1); } //TODO: verify argv and assign it to variables @@ -38,21 +39,21 @@ int main(int argc, unsigned char *argv[]) { uint32_t key0 = atoi(argv[4]); uint32_t key1 = atoi(argv[5]); uint32_t key2 = atoi(argv[6]); - //Initialise decryption (pass decryption keys) + //Initialize decryption (pass decryption keys) initDecryptor(key0, key1, key2); } //------------------------------------------------- - //Initialise file reader + //Initialize file reader initFileReader(archiveName, archiveOffset); //Skip local file header (30 bytes + additional length) char* fileHeader = getBytes(30UL); //Check that header is correct const uint32_t magic = getUint32(fileHeader); - if (magic != (uint32_t)0x04034b50) { - fprintf(stderr, "Wrong magic in local file header, expected 0x04034b50 but found %#010x.", magic); + if (magic != LOCAL_FILE_HEADER_MAGIC) { + fprintf(stderr, "Wrong magic in local file header, expected %#010x but found %#010x.", LOCAL_FILE_HEADER_MAGIC, magic); exit(1); } free(fileHeader);