mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 04:43:34 +02:00
Add wrappers to reduce #ifdefs.
Signed-off-by: Edward Tomasz Napierala <trasz@FreeBSD.org>
This commit is contained in:
parent
c00d4753ae
commit
12e2c46d6a
5 changed files with 37 additions and 55 deletions
|
|
@ -26,9 +26,7 @@
|
|||
#include "servers.h"
|
||||
#include "log.h"
|
||||
#include "write-buffer.h"
|
||||
#ifdef HAVE_CAPSICUM
|
||||
#include "capsicum.h"
|
||||
#endif
|
||||
|
||||
#include "lib-config/iconfig.h"
|
||||
#include "settings.h"
|
||||
|
|
@ -76,16 +74,6 @@ static void log_write_timestamp(int handle, const char *format,
|
|||
if (text != NULL) write_buffer(handle, text, strlen(text));
|
||||
}
|
||||
|
||||
static int log_open_wrapper(const char *path, int flags, int mode)
|
||||
{
|
||||
#ifdef HAVE_CAPSICUM
|
||||
if (capsicum_enabled())
|
||||
return capsicum_open(path, flags, mode);
|
||||
#endif
|
||||
|
||||
return open(path, flags, mode);
|
||||
}
|
||||
|
||||
static char *log_filename(LOG_REC *log)
|
||||
{
|
||||
char *str, fname[1024];
|
||||
|
|
@ -127,19 +115,12 @@ int log_start_logging(LOG_REC *log)
|
|||
/* path may contain variables (%time, $vars),
|
||||
make sure the directory is created */
|
||||
dir = g_path_get_dirname(log->real_fname);
|
||||
#ifdef HAVE_CAPSICUM
|
||||
if (capsicum_enabled())
|
||||
capsicum_mkdir_with_parents(dir, log_dir_create_mode);
|
||||
else
|
||||
g_mkdir_with_parents(dir, log_dir_create_mode);
|
||||
#else
|
||||
g_mkdir_with_parents(dir, log_dir_create_mode);
|
||||
#endif
|
||||
capsicum_mkdir_with_parents_wrapper(dir, log_dir_create_mode);
|
||||
g_free(dir);
|
||||
}
|
||||
|
||||
log->handle = log->real_fname == NULL ? -1 :
|
||||
log_open_wrapper(log->real_fname, O_WRONLY | O_APPEND | O_CREAT,
|
||||
capsicum_open_wrapper(log->real_fname, O_WRONLY | O_APPEND | O_CREAT,
|
||||
log_file_create_mode);
|
||||
if (log->handle == -1) {
|
||||
signal_emit("log create failed", 1, log);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue