about summary refs log tree commit diff
path: root/src/libnsss/nsss_switch_op.c
blob: 47534321520d8d68b3d7e6950f7aebdba48c09c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* ISC license. */

#include <errno.h>

#include <skalibs/unix-timed.h>

#include <nsss/nsss-switch.h>
#include "nsss-switch-internal.h"

int nsss_switch_op (nsss_switch_t *a, char op, tain const *deadline, tain *stamp)
{
  unsigned char c ;
  if (!nsss_switch_send(a, &op, 1, deadline, stamp)) return 0 ;
  if (!buffer_timed_get(&a->b, (char *)&c, 1, deadline, stamp)) return 0 ;
  if (c) return (errno = c, 0) ;
  return 1 ;
}