aboutsummaryrefslogtreecommitdiffstats
path: root/src/implementation.c
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-03-03 20:21:20 +0000
committerJoursoir <chat@joursoir.net>2021-03-03 20:21:20 +0000
commit1c5f7fd29fce3008218d781ab148a6974e898cac (patch)
tree54e1da521c476ca510e5db6cb830c0e58049b665 /src/implementation.c
parent8a48afccb97462b0dc261e8c99c0825295ebc019 (diff)
downloadlock-password-1c5f7fd29fce3008218d781ab148a6974e898cac.tar.gz
lock-password-1c5f7fd29fce3008218d781ab148a6974e898cac.tar.bz2
lock-password-1c5f7fd29fce3008218d781ab148a6974e898cac.zip
some chore and delete useless thing
Diffstat (limited to 'src/implementation.c')
-rw-r--r--src/implementation.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/implementation.c b/src/implementation.c
index af9f79d..5fcd17e 100644
--- a/src/implementation.c
+++ b/src/implementation.c
@@ -28,7 +28,6 @@
#include "implementation.h"
#include "constants.h"
-#include "xstd.h"
#include "easydir.h"
#include "r-gpgme.h"
#if defined(DISPLAY)
@@ -174,19 +173,19 @@ char *get_input(int minlen, int maxlen)
return pass;
}
-void gen_password(char *dest, int amount)
+char *gen_password(int length)
{
int i, min = 33, max = 126;
- char password[amount];
+ char *password = malloc(sizeof(char) * (length + 1));
srand(time(NULL));
- for(i = 0; i < amount; i++)
+ for(i = 0; i < length; i++)
password[i] = min + rand() % (max-min);
- strcpy(dest, password);
+ return password;
}
-static void clearStdinBuff()
+static void clear_stdin()
{
int garbage;
while( (garbage = fgetc(stdin)) != '\n' && garbage != EOF )
@@ -199,7 +198,7 @@ int overwrite_answer(const char *path)
printf("Password for \"%s\" exists. Overwrite? (Y/N)\n", path);
while((answer = fgetc(stdin)))
{
- clearStdinBuff();
+ clear_stdin();
switch(answer)
{
case 'Y':