Implemented the Menu

This commit is contained in:
Afonso Clerigo Mendes de Sousa 2025-02-26 22:06:20 +00:00
commit 7dd12105a9
5 changed files with 41 additions and 3 deletions

BIN
KeyMaster Executable file

Binary file not shown.

Binary file not shown.

View File

@ -40,7 +40,7 @@ char *prompNormalRequest(char *message)
temp = size(temp, 256); temp = size(temp, 256);
printf("%s\n", message); printf("%s", message);
scanf("%s", temp); scanf("%s", temp);
return temp; return temp;

View File

@ -55,7 +55,7 @@ int main(void)
return 0; return 0;
} }
} }
printf("KeyMaster\nVersion: 0.1.0 (no cli)\n\n"); printf("KeyMaster\nVersion: 0.2\n\n");
try try
{ {
@ -99,7 +99,6 @@ int main(void)
free(askedPass); free(askedPass);
free(key); free(key);
} }
catch (MEMORY_ALLOC_FAILURE) catch (MEMORY_ALLOC_FAILURE)
{ {
fprintf(stderr, "Memory allocation failure\n"); fprintf(stderr, "Memory allocation failure\n");
@ -112,6 +111,45 @@ int main(void)
} }
end_try; end_try;
char *choice = NULL;
try
{
choice = create(char);
choice = size(choice, 256);
if (choice == NULL)
{
throw(MEMORY_ALLOC_FAILURE);
}
}
catch (MEMORY_ALLOC_FAILURE)
{
fprintf(stderr, "Memory allocation failure\n");
return 1;
}
end_try;
// Menu loop
while (1)
{
printf("List of existing passwords:\n<------->\n");
// Show passwords that are stored in the server
printf("<------->\n\n");
choice = prompNormalRequest(">> ");
if (strcmp(choice, "exit") == 0 || strcmp(choice, "quit") == 0 || strcmp(choice, "q") == 0)
{
break;
}
else
{
printf("Invalid command (%s)\n\"Q\" or \"quit\" or \"exit\" to close the program\n", choice);
}
// Connect to the server and get the list of passwords tro HTTP GET
}
free(choice);
free(password); free(password);
return 0; return 0;
} }