WHY2/src/lib/flags.c

51 lines
1.0 KiB
C
Raw Normal View History

#include <why2/flags.h>
#include <stdlib.h>
//VARIABLES
static char encryptionSeparator = '.'; //NOPE > DO NOT TOUCH THIS, USE setEncryptionSeparator instead <
static unsigned long keyLength = 50; //LENGTH OF KEY > DO NOT TOUCH THIS, USE setKeyLength instead <
//GETTERS
char getEncryptionSeparator()
{
return encryptionSeparator;
}
2022-05-29 17:45:34 +02:00
unsigned long getKeyLength()
{
return keyLength;
}
2022-05-27 17:25:02 +02:00
inputFlags noFlags()
{
2022-06-11 18:53:25 +02:00
return (inputFlags) {0, 0, 1};
2022-05-27 17:25:02 +02:00
}
outputFlags noOutput(unsigned char exitCode)
{
char *emptyText = malloc(1); //TEXT
emptyText[0] = '\0';
char *emptyKey = malloc(getKeyLength() + 1); //KEY
for (int i = 0; i < (int) getKeyLength(); i++)
{
emptyKey[i] = 'x';
}
emptyKey[getKeyLength()] = '\0';
return (outputFlags) { emptyText, emptyKey, 0, 0, exitCode };
}
//SETTERS
void setEncryptionSeparator(char encryptionSeparatorNew)
{
if (encryptionSeparatorNew == '\0') return;
encryptionSeparator = encryptionSeparatorNew;
}
void setKeyLength(int keyLengthNew)
{
keyLength = keyLengthNew;
}