From fe3eb0c31d8ee6e7aed88da5b3d2650535896cab Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Tue, 30 May 2023 13:27:17 -0400 Subject: [PATCH] fix return values --- src/libecrypt.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/libecrypt.c b/src/libecrypt.c index ee3f178..6ae49f8 100644 --- a/src/libecrypt.c +++ b/src/libecrypt.c @@ -5,6 +5,13 @@ #include #include +/* +key_status +0 - keys match +1 - keys do not match +*/ +int key_status; + void ecrypt_gen(int N) { @@ -46,6 +53,12 @@ ecrypt_gen(int N) } } +/* +Return values for ecrypt_check: +0 - keys match +1 - keys do not match +2 - error opening key +*/ int ecrypt_check(char *firstkey, char *secondkey) { @@ -59,7 +72,8 @@ ecrypt_check(char *firstkey, char *secondkey) key1 = fopen(firstkey, "r"); if (key1 == NULL) { printf("error opening %s\n", firstkey); - return 2; + key_status = 2; + return key_status; } fseek(key1, 0, SEEK_END); @@ -68,14 +82,16 @@ ecrypt_check(char *firstkey, char *secondkey) key2 = fopen(secondkey, "r"); if (key2 == NULL) { printf("error opening %s\n", secondkey); - return 2; + key_status = 2; + return key_status; } fseek(key2, 0, SEEK_END); cnt1 = ftell(key2); if (cnt1 != cnt2) { - return 1; + key_status = 1; + return key_status; } else { while (! feof(key1)) { if (fgetc(key1) != fgetc(key2)) { @@ -84,9 +100,11 @@ ecrypt_check(char *firstkey, char *secondkey) } } if (flg) { - return 1; + key_status = 1; + return key_status; } else { - return 0; + key_status = 0; + return key_status; } }