Added the first server request.

This commit is contained in:
Afonso Clerigo Mendes de Sousa 2025-02-27 11:59:45 +00:00
parent a17f7baf0a
commit 74e47ea1bf
3 changed files with 11 additions and 4 deletions

BIN
KeyMaster

Binary file not shown.

Binary file not shown.

View File

@ -20,6 +20,7 @@ typedef struct Request
unsigned char type; unsigned char type;
char *key; char *key;
int ID; int ID;
int level;
} Request; } Request;
void clear_input_buffer(void) void clear_input_buffer(void)
@ -59,7 +60,7 @@ int main(void)
buffer = size(buffer, 256); buffer = size(buffer, 256);
emcryptText(buffer, password); emcryptText(buffer, password);
writel(PASS_FILE, buffer, 256 * sizeof(int)); writel(PASS_FILE, buffer, 256);
free(buffer); free(buffer);
} }
@ -176,9 +177,11 @@ int main(void)
send(sockfd, &req, sizeof(Request), 0); send(sockfd, &req, sizeof(Request), 0);
// Receive response from the server // Receive response from the server
char response[1024] = {0}; recv(sockfd, &req, sizeof(req), 0);
recv(sockfd, response, sizeof(response), 0); if (req.level == -1)
printf("%s\n", response); {
printf("No existing passwords, use \"addpass\" command to add a password to the list.\n");
}
printf("<------->\n\n"); printf("<------->\n\n");
choice = prompNormalRequest(">> "); choice = prompNormalRequest(">> ");
@ -186,6 +189,10 @@ int main(void)
{ {
break; break;
} }
else if (strcmp("choise", "addpass"))
{
printf("adding new password to the server.");
}
else else
{ {
printf("Invalid command (%s)\n\"Q\" or \"quit\" or \"exit\" to close the program\n", choice); printf("Invalid command (%s)\n\"Q\" or \"quit\" or \"exit\" to close the program\n", choice);