about summary refs log tree commit diff
path: root/src/libnsss/nsss_switch_grp_get.c
blob: 65da4e36c8110f84ecaefb43a3cbfb05caaee45f (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/buffer.h>
#include <skalibs/unix-timed.h>
#include <nsss/nsss-switch.h>
#include "nsss-switch-internal.h"

int nsss_switch_grp_get (nsss_switch_t *a, struct group *gr, stralloc *sa, genalloc *ga, tain_t const *deadline, tain_t *stamp)
{
  unsigned char c = NSSS_SWITCH_GRP_GET ;
  if (!ipc_timed_send(buffer_fd(&a->b), (char *)&c, 1, deadline, stamp)) return 0 ;
  if (!buffer_timed_get(&a->b, (char *)&c, 1, deadline, stamp)) return 0 ;
  if (c == 255) return 0 ;
  if (c) return (errno = c, 0) ;
  return nsss_switch_grp_read(&a->b, gr, sa, ga, deadline, stamp) ;
}