ref: 4a0c2c887f448b6725f84f83499f1a18a257b591
parent: e72aa2d79aff1b39b24c98ad9d02c487a0014ad5
author: mkf <mkf@cloud9p.org>
date: Thu May 9 17:05:31 EDT 2024
util: add dprint, only prints if client got debug on, quite handy.
--- a/util.c
+++ b/util.c
@@ -8,7 +8,6 @@
#include "engine.h"
-
int
isnum(char *s, unsigned int n)
{
@@ -94,4 +93,19 @@
sysfatal("parseput(): input isnt a number?");
return Pt(atoi(x), atoi(y));
+}
+
+int
+dprint(char *fmt, ...)
+{
+ va_list va;
+ int n;
+
+ if(!debug)
+ return 0;
+
+ va_start(va, fmt);
+ n = vfprint(2, fmt, va);
+ va_end(va);
+ return n;
}
\ No newline at end of file
--- a/util.h
+++ b/util.h
@@ -1,4 +1,5 @@
int isnum(char *s, unsigned int n);
int parsemove(char *s);
char* dirtostr(int dir);
-Point parseput(char *x, char *y);
\ No newline at end of file
+Point parseput(char *x, char *y);
+int dprint(char *fmt, ...);