Move mprintf to libaux
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
include ../make/ufuncs.mk
|
||||
|
||||
$(eval $(call add_include,libsystem))
|
||||
$(eval $(call add_include,libmalloc))
|
||||
$(eval $(call add_include,libprocess))
|
||||
$(eval $(call add_include,libstring))
|
||||
|
||||
libname := libaux
|
||||
|
||||
|
||||
27
libaux/mprintf.c
Normal file
27
libaux/mprintf.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <malloc.h>
|
||||
#include <mprintf.h>
|
||||
#include <printf.h>
|
||||
#include <process_self.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <system.h>
|
||||
|
||||
void mprintf (const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
|
||||
char* buf = malloc (MPRINTF_BUF_MAX);
|
||||
|
||||
if (buf == NULL) {
|
||||
va_end (args);
|
||||
return;
|
||||
}
|
||||
|
||||
memset (buf, 0, MPRINTF_BUF_MAX);
|
||||
int len = vsnprintf (buf, MPRINTF_BUF_MAX, fmt, args);
|
||||
|
||||
va_end (args);
|
||||
|
||||
mail_send (process_get_exec_pgid (), buf, len);
|
||||
free (buf);
|
||||
}
|
||||
8
libaux/mprintf.h
Normal file
8
libaux/mprintf.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _LIBAUX_MPRINTF_H
|
||||
#define _LIBAUX_MPRINTF_H
|
||||
|
||||
#define MPRINTF_BUF_MAX (1024 * 16)
|
||||
|
||||
void mprintf (const char* fmt, ...);
|
||||
|
||||
#endif // _LIBAUX_MPRINTF_H
|
||||
@@ -1,7 +1,9 @@
|
||||
include $(platform)/src.mk
|
||||
|
||||
c += printf.c \
|
||||
path.c
|
||||
path.c \
|
||||
mprintf.c
|
||||
|
||||
o += printf.o \
|
||||
path.o
|
||||
path.o \
|
||||
mprintf.o
|
||||
|
||||
Reference in New Issue
Block a user