1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Terminal stuff

This commit is contained in:
Julian Barathieu 2019-03-18 14:21:00 +01:00
parent 281964500b
commit d718561a9c
3 changed files with 65 additions and 0 deletions

View File

@ -239,6 +239,30 @@ DEC_CTYPE_FUNC(isalnum, (_AL|_DG));
//------------------------------------------// //------------------------------------------//
#ifndef __min_defined
#define __min_defined
static inline int min(int __x, int __y)
{ return __x < __y ? __x : __y; }
#endif
#ifndef __lmin_defined
#define __lmin_defined
static inline int lmin(long __x, long __y)
{ return __x < __y ? __x : __y; }
#endif
#ifndef __max_defined
#define __max_defined
static inline int max(int __x, int __y)
{ return __x > __y ? __x : __y; }
#endif
#ifndef __lmax_defined
#define __lmax_defined
static inline int lmax(long __x, long __y)
{ return __x > __y ? __x : __y; }
#endif
#ifndef __abs_defined #ifndef __abs_defined
#define __abs_defined #define __abs_defined
static inline int abs(int __x) static inline int abs(int __x)

View File

@ -37,6 +37,11 @@
// //
enum { KTABSIZE = 4 }; enum { KTABSIZE = 4 };
//
// Upper bound on what a single KernLog() can write
//
enum { KLOG_MAX_BUFSIZE = 4096 };
// //
// The VGA colors // The VGA colors
// //

View File

@ -116,3 +116,39 @@ error_t PrintOnTerm(Terminal_t *term, const char *str)
return retcode; return retcode;
} }
//
// Print formatted string on standard output
// Prints at most KLOG_MAX_BUFSIZE characters
//
error_t KernLog(const char *fmt, ...)
{
va_list ap;
char logbuf[KLOG_MAX_BUFSIZE];
va_start(ap, fmt);
vsnprintf(logbuf, KLOG_MAX_BUFSIZE, fmt, ap);
va_end(ap);
return PrintOnTerm(stdOut, logbuf);
}
#ifndef _NO_DEBUG
//
// Print formatted string on debug output
// Prints at most KLOG_MAX_BUFSIZE characters
//
error_t DebugLog(const char *fmt, ...)
{
va_list ap;
char logbuf[KLOG_MAX_BUFSIZE];
va_start(ap, fmt);
vsnprintf(logbuf, KLOG_MAX_BUFSIZE, fmt, ap);
va_end(ap);
return PrintOnTerm(stdDbg, logbuf);
}
#endif