aboutsummaryrefslogtreecommitdiff
path: root/lib/errmsg_put.c
blob: 9afe0ce5a762900e4348cd7b83c29eda53a5a5e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <sys/uio.h>
#include "../ninitfeatures.h"

#ifndef ERRMSG_PUTS_LEN
#define ERRMSG_PUTS_LEN	15
#endif

void errmsg_put(int fd, const char *buf, unsigned int len) /*EXTRACT_INCL*/ {
  static struct iovec errmsg_iov[ERRMSG_PUTS_LEN];
  static int k;
  if (buf==0 || k==ERRMSG_PUTS_LEN) {
    if (fd>=0) writev(fd,errmsg_iov,k);
    k = 0;
  }
  if (buf && len) {
    errmsg_iov[k].iov_base = (char *)buf;
    errmsg_iov[k].iov_len = len;
    k++;
  }
}