diff --git a/include/dynmem.h b/include/dynmem.h index 755e3fb..9b6910f 100644 --- a/include/dynmem.h +++ b/include/dynmem.h @@ -42,7 +42,7 @@ */ #define add(ptr, index, value) ptr[index] = value //@param ptr Pointer to add the value @param index Index of the value to add @param value Value to add -#define remove(ptr, index) ptr[index] = 0 //@param ptr Pointer to remove the value @param index Index of the value to remove +#define removePTR(ptr, index) ptr[index] = 0 //@param ptr Pointer to remove the value @param index Index of the value to remove #ifdef __INTELLISENSE__ #define create(type) ((type *)malloc(sizeof(type))) //@param type Type of the vector @example int *vector = create(int); diff --git a/src/server.c b/src/server.c index 73782fe..fd66609 100644 --- a/src/server.c +++ b/src/server.c @@ -170,6 +170,28 @@ int main(void) emcryptText(key2, req.key); writel(filepath, key2, 256); } + else if (req.type == 2) + { + // debug + printf("Received request type 2\n"); + + char filepath[256]; + + printf("Received key: %s\n", req.key); + printf("Received level: %d\n", req.level); + sprintf(filepath, "%s%d.bin", PASSWORDS, req.level); + + printf("Deleting key from file: %s\n", filepath); + + if (remove(filepath) != 0) + { + fprintf(stderr, "Error deleting file\n"); + } + } + else + { + fprintf(stderr, "Invalid request type\n"); + } } // Close the socket