replaced _Bool with boolean typedef

basically char but it looks good and smart now
This commit is contained in:
Václav Šmejkal 2022-10-15 15:21:28 +02:00
parent 344c9eb296
commit a40f9637f0
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19
4 changed files with 14 additions and 12 deletions

View File

@ -31,11 +31,13 @@ const enum EXIT_CODES //exit codes you fucking idiot
#define DEPRECATED __attribute__((deprecated)) //SAME COMMENT AS VERSIONS_NAME'S #define DEPRECATED __attribute__((deprecated)) //SAME COMMENT AS VERSIONS_NAME'S
#define UNUSED __attribute__((unused)) //SAME COMMENT AS DEPRECATED'S #define UNUSED __attribute__((unused)) //SAME COMMENT AS DEPRECATED'S
typedef char boolean;
typedef struct typedef struct
{ {
_Bool noCheck; //BOOLEAN FOR SKIPPING VERSION CHECK boolean noCheck; //BOOLEAN FOR SKIPPING VERSION CHECK
_Bool noOutput; //BOOLEAN FOR NOT PRINTING OUTPUT WHEN ENCRYPTING/DECRYPTING boolean noOutput; //BOOLEAN FOR NOT PRINTING OUTPUT WHEN ENCRYPTING/DECRYPTING
_Bool update; //BOOLEAN FOR UPDATING YOUR WHY VERSION IF OLD IS USED boolean update; //BOOLEAN FOR UPDATING YOUR WHY VERSION IF OLD IS USED
} inputFlags; } inputFlags;
typedef struct typedef struct
@ -45,7 +47,7 @@ typedef struct
unsigned long unusedKeySize; //VARIABLE FOR COUNT OF UNUSED CHARACTERS IN KEY unsigned long unusedKeySize; //VARIABLE FOR COUNT OF UNUSED CHARACTERS IN KEY
unsigned long repeatedKeySize; //VARIABLE FOR COUNT OF REPEATED CHARACTERS IN KEY (basically reversed unusedKeySize) unsigned long repeatedKeySize; //VARIABLE FOR COUNT OF REPEATED CHARACTERS IN KEY (basically reversed unusedKeySize)
unsigned long elapsedTime; //VARIABLE FOR ELAPSED TIME IN MICROSECONDS => 1s = 1000000µs unsigned long elapsedTime; //VARIABLE FOR ELAPSED TIME IN MICROSECONDS => 1s = 1000000µs
_Bool exitCode; //VARIABLE FOR EXIT CODE boolean exitCode; //VARIABLE FOR EXIT CODE
} outputFlags; } outputFlags;
//NOTE: Variables were moved to 'flags.c' to force y'all using getters //NOTE: Variables were moved to 'flags.c' to force y'all using getters
@ -55,7 +57,7 @@ char getEncryptionSeparator();
unsigned long getKeyLength(); unsigned long getKeyLength();
inputFlags defaultFlags(); //THIS GENERATES inputFlags WITH DEFAULT VALUES inputFlags defaultFlags(); //THIS GENERATES inputFlags WITH DEFAULT VALUES
inputFlags getFlags(); //RETURNS USED FLAGS inputFlags getFlags(); //RETURNS USED FLAGS
outputFlags noOutput(_Bool exitCode); //SAME AS defaultFlags() BUT FOR outputFlags outputFlags noOutput(boolean exitCode); //SAME AS defaultFlags() BUT FOR outputFlags
//SETTERS //SETTERS
void setEncryptionSeparator(char encryptionSeparatorNew); void setEncryptionSeparator(char encryptionSeparatorNew);

View File

@ -7,9 +7,9 @@
void generateTextKeyChain(char *key, int *textKeyChain, int textKeyChainSize); //GENERATES ARRAY FOR ENCRYPTION/DECRYPTION void generateTextKeyChain(char *key, int *textKeyChain, int textKeyChainSize); //GENERATES ARRAY FOR ENCRYPTION/DECRYPTION
void deallocateOutput(outputFlags flags); //DEALLOCATES flags void deallocateOutput(outputFlags flags); //DEALLOCATES flags
_Bool checkVersion(); //THIS FUNCTION CHECKS IF LATEST VERSION OF WHY2 IS USED boolean checkVersion(); //THIS FUNCTION CHECKS IF LATEST VERSION OF WHY2 IS USED
_Bool checkKey(char *key); //CHECKS IF KEY IS VALID boolean checkKey(char *key); //CHECKS IF KEY IS VALID
_Bool checkText(char *text); //CHECKS IF TEXT IS VALID boolean checkText(char *text); //CHECKS IF TEXT IS VALID
unsigned long countIntLength(int number); //RETURNS LENGTH OF number unsigned long countIntLength(int number); //RETURNS LENGTH OF number
unsigned long countUnusedKeySize(char *text, char *key); //COUNT unusedKeySize unsigned long countUnusedKeySize(char *text, char *key); //COUNT unusedKeySize
unsigned long countRepeatedKeySize(char *text, char *key); //COUNT repeatedKeySize unsigned long countRepeatedKeySize(char *text, char *key); //COUNT repeatedKeySize

View File

@ -31,7 +31,7 @@ inputFlags getFlags()
return flags; return flags;
} }
outputFlags noOutput(_Bool exitCode) outputFlags noOutput(boolean exitCode)
{ {
char *emptyText = malloc(1); //TEXT char *emptyText = malloc(1); //TEXT
emptyText[0] = '\0'; emptyText[0] = '\0';

View File

@ -72,7 +72,7 @@ char *replaceWord(char *string, char *old, char *new) //CODE FROM: https://www.g
return result; return result;
} }
_Bool checkVersion() boolean checkVersion()
{ {
if (getFlags().noCheck) return SUCCESS; if (getFlags().noCheck) return SUCCESS;
@ -300,7 +300,7 @@ void deallocateOutput(outputFlags flags)
free(flags.usedKey); free(flags.usedKey);
} }
_Bool checkKey(char *key) boolean checkKey(char *key)
{ {
if (strlen(key) < getKeyLength()) if (strlen(key) < getKeyLength())
{ {
@ -311,7 +311,7 @@ _Bool checkKey(char *key)
return SUCCESS; return SUCCESS;
} }
_Bool checkText(char *text) boolean checkText(char *text)
{ {
if (strcmp(text, "") == 0) if (strcmp(text, "") == 0)
{ {