Make libdebug not depend on libdisplay
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "../libsample/sample.h"
|
||||
#include "debug.h"
|
||||
#include "../libdisplay/display.h"
|
||||
@@ -72,6 +73,24 @@ void (*print_console_text)(void) = NULL;
|
||||
|
||||
int debug_limit_scroll = 0;
|
||||
|
||||
void get_win_size(int *w, int *h)
|
||||
{
|
||||
struct winsize win;
|
||||
int rc;
|
||||
|
||||
rc = ioctl(0, TIOCGWINSZ, &win);
|
||||
if (rc) {
|
||||
*w = 80;
|
||||
*h = 25;
|
||||
return;
|
||||
}
|
||||
|
||||
*h = win.ws_row;
|
||||
*w = win.ws_col;
|
||||
if (*w > MAX_DISPLAY_WIDTH - 1)
|
||||
*w = MAX_DISPLAY_WIDTH - 1;
|
||||
}
|
||||
|
||||
void _printdebug(const char *file, const char __attribute__((unused)) *function, int line, int cat, int level, int chan, const char *fmt, ...)
|
||||
{
|
||||
char buffer[4096], *b = buffer;
|
||||
|
@@ -25,6 +25,8 @@
|
||||
#define DUHD 18
|
||||
#define DSOAPY 19
|
||||
|
||||
void get_win_size(int *w, int *h);
|
||||
|
||||
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, -1, fmt, ## arg)
|
||||
#define PDEBUG_CHAN(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, CHAN, fmt, ## arg)
|
||||
void _printdebug(const char *file, const char *function, int line, int cat, int level, int chan, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 7, 8)));
|
||||
|
Reference in New Issue
Block a user