updated file database added get_all_users get_user_by_id
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 14s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Failing after 9s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Successful in 12s

get_user_by_username get_user_field_by_id
This commit is contained in:
wt committed 2025-10-22 16:46:36 +07:00
1 parent 73a73976fe
commit d14db43e9b
13 files changed
+158 -9

No files matched your search

+19 -2
View File
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *read_file(const char *path) {
FILE *fp = fopen(path, "rb");
@@ -14,7 +15,7 @@ char *read_file(const char *path) {
long file_size = ftell(fp);
rewind(fp);
char *buffer = (char *)malloc(file_size + 1);
char *buffer = (char *) malloc(file_size + 1);
if (!buffer) {
perror("Error allocating memory");
fclose(fp);
@@ -32,4 +33,20 @@ char *read_file(const char *path) {
buffer[file_size] = '\0';
fclose(fp);
return buffer;
}
}
char *write_file(const char *path, const char *data) {
FILE *fp = fopen(path, "w");
if (fp == NULL) {
printf("%s\n", path);
perror("Error opening file");
return nullptr;
}
if (fprintf(fp, "%s", data) < 0) {
perror("Error write file");
return nullptr;
}
fclose(fp);
char *ret = strdup(data);
return ret;
}