#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: util.c,v 1.1.1.1 2003/01/10 00:48:15 bbraun Exp $";
#endif
#include "port_before.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintfx)
#else
# define SPRINTF(x) sprintf x
#endif
void
map_v4v6_address(const char *src, char *dst) {
u_char *p = (u_char *)dst;
char tmp[NS_INADDRSZ];
int i;
memcpy(tmp, src, NS_INADDRSZ);
for (i = 0; i < 10; i++)
*p++ = 0x00;
*p++ = 0xff;
*p++ = 0xff;
memcpy((void*)p, tmp, NS_INADDRSZ);
}
int
make_group_list(struct irs_gr *this, const char *name,
gid_t basegid, gid_t *groups, int *ngroups)
{
struct group *grp;
int i, ng;
int ret, maxgroups;
ret = -1;
ng = 0;
maxgroups = *ngroups;
if (ng >= maxgroups)
goto done;
groups[ng++] = basegid;
if (ng >= maxgroups)
goto done;
groups[ng++] = basegid;
(*this->rewind)(this);
while ((grp = (*this->next)(this)) != NULL) {
if ((gid_t)grp->gr_gid == basegid)
continue;
for (i = 0; grp->gr_mem[i]; i++) {
if (!strcmp(grp->gr_mem[i], name)) {
if (ng >= maxgroups)
goto done;
groups[ng++] = grp->gr_gid;
break;
}
}
}
ret = 0;
done:
*ngroups = ng;
return (ret);
}