add errmsg API

This commit is contained in:
leitner
2004-05-05 16:36:00 +00:00
parent f26451c086
commit a6a00edd75
7 changed files with 121 additions and 0 deletions

28
buffer/errmsg_warnsys.c Normal file
View File

@@ -0,0 +1,28 @@
#include <stdarg.h>
#include <sys/uio.h>
#include "errmsg.h"
#include "str.h"
#include <string.h>
#include <errno.h>
extern int errmsg_cvt(struct iovec* x,const char* message, va_list a);
void errmsg_warnsys(const char* message, ...) {
struct iovec x[25];
va_list a;
int i;
va_start(a,message);
i=errmsg_cvt(x,message,a);
x[i-1].iov_base=": ";
x[i-1].iov_len=2;
x[i].iov_base=strerror(errno);
x[i].iov_len=str_len(x[i].iov_base);
x[i+1].iov_base="\n";
x[i+1].iov_len=1;
writev(2,x,i+2);
va_end(a);
}