summaryrefslogtreecommitdiff
path: root/src/libunixonacid/textclient_command.c
blob: a0015ac0c50675f29afbba2fba76f0df1ed2d09c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* ISC license. */

#include <sys/uio.h>
#include <errno.h>

#include <skalibs/textclient.h>
#include <skalibs/posixishard.h>

int textclient_command (textclient_t *a, char const *s, size_t len, tain_t const *deadline, tain_t *stamp)
{
  struct iovec ans ;
  if (!textclient_exchange(a, s, len, &ans, deadline, stamp)) return 0 ;
  if (ans.iov_len != 1) return (errno = EPROTO, 0) ;
  if (*(char *)ans.iov_base) return (errno = *(char *)ans.iov_base, 0) ;
  return 1 ;
}