mirror of
https://github.com/jarun/nnn.git
synced 2025-03-01 20:39:20 +00:00
Add a simple dprintf() implementation for systems that do not have it
This commit is contained in:
parent
3639f1bbb4
commit
3e8555fdc6
1 changed files with 17 additions and 0 deletions
17
noice.c
17
noice.c
|
@ -10,6 +10,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
@ -90,6 +91,22 @@ void printwarn(void);
|
||||||
void printerr(int ret, char *prefix);
|
void printerr(int ret, char *prefix);
|
||||||
char *makepath(char *dir, char *name);
|
char *makepath(char *dir, char *name);
|
||||||
|
|
||||||
|
#undef dprintf
|
||||||
|
int
|
||||||
|
dprintf(int fd, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ];
|
||||||
|
int r;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
r = vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
if (r > 0)
|
||||||
|
write(fd, buf, r);
|
||||||
|
va_end(ap);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
xmalloc(size_t size)
|
xmalloc(size_t size)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue