Code reorganization
This commit is contained in:
20
src/util.c
20
src/util.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user