LibC: Implement closelog and make syslog print to stddbg

This commit is contained in:
Bananymous 2024-12-03 01:45:54 +02:00
parent 415b20f884
commit fbcf10c86d
2 changed files with 23 additions and 4 deletions

View File

@ -580,6 +580,7 @@ extern "C" int printf_impl(const char* format, va_list arguments, int (*putc_fun
case 'm':
{
// NOTE: this is a glibc extension
// NOTE: syslog() requires %m to be handled
if (options.alternate_form)
string = strerrorname_np(errno);
else

View File

@ -1,12 +1,30 @@
#include <BAN/Assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <syslog.h>
void openlog(const char*, int, int)
static const char* s_ident = nullptr;
void openlog(const char* ident, int option, int facility)
{
ASSERT_NOT_REACHED();
(void)option;
(void)facility;
s_ident = ident;
}
void syslog(int, const char*, ...)
void syslog(int priority, const char* format, ...)
{
ASSERT_NOT_REACHED();
(void)priority;
if (s_ident)
fprintf(stddbg, "%s", s_ident);
va_list args;
va_start(args, format);
vfprintf(stddbg, format, args);
va_end(args);
}
void closelog()
{
s_ident = nullptr;
}