-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
53 lines (43 loc) · 1.15 KB
/
main.c
File metadata and controls
53 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "includes/io.h"
#include "includes/generator.h"
int main(void)
{
short running = 1;
char* buffer = calloc(MAX_USR_CHARS, sizeof(char));
prompts_t* prompts = prompts_create();
mmenu_t* main_menu = main_menu_create();
charset_t* charset = charset_create();
password_t* password = password_create();
while (running)
{
main_menu_display(main_menu, prompts);
memset(buffer, 0, MAX_USR_CHARS);
ask_for_input(buffer, prompts);
switch (validate_user_input(buffer[0], MAIN_MENU_OPTIONS))
{
case GENERATE:
password_set_length(buffer, password, prompts);
password_set_charset(buffer, charset, password, prompts);
generate_password(password, prompts);
break;
case HELP:
help_menu_display(prompts);
break;
case EXIT:
running = 0;
break;
case INVALID:
printf("\n%s Invalid option (Use 1, 2 or 3).\n", prompts->out);
break;
}
}
free(buffer);
prompts_free(prompts);
main_menu_free(main_menu);
charset_free(charset);
password_free(password);
return 0;
}