Code reorganization

This commit is contained in:
Nate Choe
2022-03-30 17:39:55 -05:00
parent 266a087655
commit 26c0eaca15
7 changed files with 241 additions and 160 deletions

View File

@@ -20,6 +20,9 @@
#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <sys/shm.h>
#include <swebs/util.h>
#include <swebs/types.h>
@@ -30,6 +33,23 @@ int initLogging(char *path) {
return logs == NULL;
}
int smalloc(size_t size) {
return shmget(IPC_PRIVATE, size,
IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
}
void *saddr(int id) {
return shmat(id, NULL, 0);
}
void sfree(void *addr) {
shmdt(addr);
}
void sdestroy(int id) {
shmctl(id, IPC_RMID, 0);
}
int createLog(char *msg) {
time_t currenttime;
struct tm *timeinfo;