gen_gr.c revision 9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if !defined(LINT) && !defined(CODECENTER)
#endif
/* Imports */
#include "port_before.h"
#ifndef WANT_IRS_GR
static int __bind_irs_gr_unneeded;
#else
#include <isc/assertions.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Definitions */
struct pvt {
/*
* Need space to store the entries read from the group file.
* The members list also needs space per member, and the
* strings making up the user names must be allocated
* somewhere. Rather than doing lots of small allocations,
* we keep one buffer and resize it as needed.
*/
char * membuf;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void gr_minimize(struct irs_gr *);
static void gr_res_set(struct irs_gr *,
struct __res_state *,
void (*)(void *));
int preserve);
/* Macros */
/* Public */
struct irs_gr *
return (NULL);
}
return (NULL);
}
return (gr);
}
/* Methods. */
static void
}
static struct group *
if (rval)
return (rval);
break;
}
}
return (NULL);
}
static struct group *
int dirty;
dirty = 0;
if (tval) {
return (NULL);
break;
} else {
break;
}
}
if (dirty)
return (NULL);
}
static struct group *
int dirty;
dirty = 0;
if (tval) {
return (NULL);
break;
} else {
break;
}
}
if (dirty)
return (NULL);
}
static void
}
}
static int
{
int n, t, rval = 0;
*ngroups = 0;
if (!t_groups) {
return (-1);
}
for (n = 0; n < t_ngroups; n++) {
rval = -1;
goto done;
}
}
}
if (t == 0) {
break;
} else {
break;
}
}
done:
return (rval);
}
static void
}
}
static struct __res_state *
struct __res_state *res;
if (!res) {
return (NULL);
}
}
}
static void
void (*free_res)(void *)) {
}
}
}
/* Private. */
static int
if (!preserve) {
m = malloc(sizeof *m);
if (m == NULL) {
/* No harm done, no work done. */
return (0);
}
}
}
/*
* Make sure destination member array is large enough.
* p points to new portion.
*/
if (m == NULL) {
/* No harm done, no work done. */
return (0);
}
}
/*
* Enlarge destination membuf; cp points at new portion.
*/
if (!preserve) {
}
if (n == 0) {
/* No work to do. */
return (1);
}
/* No harm done, no work done. */
return (0);
}
if (used != 0)
/*
* Adjust group.gr_mem.
*/
/*
* Add new elements.
*/
*p++ = cp;
*p = NULL;
n = strlen(*m) + 1;
return (0);
}
cp += n;
}
if (preserve) {
} else {
return (0);
}
cp += n;
return (0);
}
cp += n;
}
return (1);
}
static int
int n = 0;
while (*vec++)
n++;
return (n);
}
static int
return (0);
return (1);
}
static int
int n = 0;
return (n);
}
static size_t
size_t n = 0;
return (n);
}
static int
return (0);
return (1);
}
#endif /* WANT_IRS_GR */
/*! \file */