cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER START
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The contents of this file are subject to the terms of the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Common Development and Distribution License (the "License").
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You may not use this file except in compliance with the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * or http://www.opensolaris.org/os/licensing.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * See the License for the specific language governing permissions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * and limitations under the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * When distributing Covered Code, include this CDDL HEADER in each
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * If applicable, add the following below this CDDL HEADER, with the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * fields enclosed by brackets "[]" replaced with your own identifying
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * information: Portions Copyright [yyyy] [name of copyright owner]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER END
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Use is subject to license terms.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#pragma ident "%Z%%M% %I% %E% SMI"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <stdlib.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <locale.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <string.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include "nscd_config.h"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include "nscd_log.h"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include "nscd_switch.h"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Configuration data for the nscd switch functions.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_cfg_global_switch_t nscd_switch_cfg_g;
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_cfg_switch_t *nscd_switch_cfg;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * statistics of the nscd switch functions.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_cfg_stat_global_switch_t nscd_switch_stats_g;
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_cfg_stat_switch_t *nscd_switch_stats;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * cookie is set up by the verify function for passing to
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the notify function
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl struct __nsw_switchconfig_v1 *cfg;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *cfgstr;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl} nsw_cfg_cookie_t;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_rc_t
cb5caa98562cf06753163f558cbcfe30b8f4673adjl_nscd_alloc_switch_cfg()
cb5caa98562cf06753163f558cbcfe30b8f4673adjl{
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_switch_cfg = calloc(NSCD_NUM_DB, sizeof (nscd_cfg_switch_t));
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (nscd_switch_cfg == NULL)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_NO_MEMORY);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_SUCCESS);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl}
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_rc_t
cb5caa98562cf06753163f558cbcfe30b8f4673adjl_nscd_alloc_switch_stats()
cb5caa98562cf06753163f558cbcfe30b8f4673adjl{
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_switch_stats = calloc(NSCD_NUM_DB,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl sizeof (nscd_cfg_stat_switch_t));
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (nscd_switch_stats == NULL)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_NO_MEMORY);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_SUCCESS);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl}
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* ARGSUSED */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_rc_t
cb5caa98562cf06753163f558cbcfe30b8f4673adjl_nscd_cfg_switch_notify(
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void *data,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl struct nscd_cfg_param_desc *pdesc,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_id_t *nswdb,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_flag_t dflag,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_error_t **errorp,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void *cookie)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl{
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void *dp;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_rc_t rc;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nsw_cfg_cookie_t *ck = (nsw_cfg_cookie_t *)cookie;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (_nscd_cfg_flag_is_set(dflag, NSCD_CFG_DFLAG_INIT) ||
cb5caa98562cf06753163f558cbcfe30b8f4673adjl _nscd_cfg_flag_is_set(dflag, NSCD_CFG_DFLAG_GROUP)) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * group data is received, copy in the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * entire strcture
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (_nscd_cfg_flag_is_set(pdesc->pflag,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl NSCD_CFG_PFLAG_GLOBAL)) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_switch_cfg_g = *(nscd_cfg_global_switch_t *)data;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_switch_cfg[nswdb->index] =
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *(nscd_cfg_switch_t *)data;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * individual paramater is received: copy in the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * parameter value except for nsw-config-string.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (_nscd_cfg_flag_is_set(pdesc->pflag,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl NSCD_CFG_PFLAG_GLOBAL)) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl dp = (char *)&nscd_switch_cfg_g + pdesc->p_offset;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) memcpy(dp, data, pdesc->p_size);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl dp = (char *)&nscd_switch_cfg[nswdb->index] +
cb5caa98562cf06753163f558cbcfe30b8f4673adjl pdesc->p_offset;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (pdesc->p_offset !=
cb5caa98562cf06753163f558cbcfe30b8f4673adjl offsetof(nscd_cfg_switch_t, nsw_config_string))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) memcpy(dp, data, pdesc->p_size);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * cookie contains data for the switch policy config
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (cookie != NULL) {
ad0e80f7538b612141768bfda60009eb76550ee7michen rc = _nscd_create_sw_struct(nswdb->index, -1, nswdb->name,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl ck->cfgstr, ck->cfg, NULL);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (rc != NSCD_SUCCESS) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) __nsw_freeconfig_v1(ck->cfg);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl free(ck);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (rc);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl free(ck);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (_nscd_cfg_flag_is_not_set(dflag, NSCD_CFG_DFLAG_STATIC_DATA))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl free(data);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_SUCCESS);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl}
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* ARGSUSED */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_rc_t
cb5caa98562cf06753163f558cbcfe30b8f4673adjl_nscd_cfg_switch_verify(
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void *data,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl struct nscd_cfg_param_desc *pdesc,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_id_t *nswdb,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_flag_t dflag,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_error_t **errorp,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void **cookie)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl{
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *me = "_nscd_cfg_switch_verify";
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_switch_t *cfg;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *nswcfgstr;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int size;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl struct __nsw_switchconfig_v1 *switchcfg = NULL;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl enum __nsw_parse_err err;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nsw_cfg_cookie_t *ck;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char buf[MAX_NSSWITCH_CONFIG_STRING_SZ];
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char msg[NSCD_CFG_MAX_ERR_MSG_LEN];
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * global config data has nothing special to verify
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (_nscd_cfg_flag_is_set(pdesc->pflag, NSCD_CFG_PFLAG_GLOBAL))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_SUCCESS);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *cookie = NULL;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * switch policy string is the one to parse and verify
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (_nscd_cfg_flag_is_set(dflag, NSCD_CFG_DFLAG_INIT) ||
cb5caa98562cf06753163f558cbcfe30b8f4673adjl _nscd_cfg_flag_is_set(dflag, NSCD_CFG_DFLAG_GROUP)) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* get it from the group data */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl cfg = (nscd_cfg_switch_t *)data;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nswcfgstr = cfg->nsw_config_string;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* not group, and not the switch policy string, return */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (pdesc->p_offset != offsetof(nscd_cfg_switch_t,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nsw_config_string))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_SUCCESS);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* the data itself is the string */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nswcfgstr = (char *)data;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * convert the string into struct __nsw_switchconfig_v1
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl size = MAX_NSSWITCH_CONFIG_STRING_SZ;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (strlcpy(buf, nswcfgstr, size) >= size) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) snprintf(msg, sizeof (msg),
cb5caa98562cf06753163f558cbcfe30b8f4673adjl gettext("switch policy string too long (\"%s : %s\" > %d)"),
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nswdb->name, nswcfgstr, size);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl _NSCD_LOG(NSCD_LOG_CONFIG, NSCD_LOG_LEVEL_ERROR)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (me, "%s\n", msg);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (*errorp)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *errorp = _nscd_cfg_make_error(
cb5caa98562cf06753163f558cbcfe30b8f4673adjl NSCD_CFG_SYNTAX_ERROR, msg);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_CFG_SYNTAX_ERROR);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl switchcfg = _nsw_getoneconfig_v1(nswdb->name, buf, &err);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (switchcfg == NULL) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) snprintf(msg, sizeof (msg),
cb5caa98562cf06753163f558cbcfe30b8f4673adjl gettext("syntax error: switch policy string (%s : %s) rc = %d"),
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nswdb->name, nswcfgstr, err);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl _NSCD_LOG(NSCD_LOG_CONFIG, NSCD_LOG_LEVEL_ERROR)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (me, "%s\n", msg);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (*errorp)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *errorp = _nscd_cfg_make_error(
cb5caa98562cf06753163f558cbcfe30b8f4673adjl NSCD_CFG_SYNTAX_ERROR, msg);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_CFG_SYNTAX_ERROR);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* save the __nsw_switchconfig_v1 for the notify function */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl ck = calloc(1, sizeof (nsw_cfg_cookie_t));
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (ck == NULL) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) __nsw_freeconfig_v1(switchcfg);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_CFG_SYNTAX_ERROR);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl ck->cfg = switchcfg;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl ck->cfgstr = nswcfgstr;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *cookie = ck;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_SUCCESS);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl}
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* ARGSUSED */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_rc_t
cb5caa98562cf06753163f558cbcfe30b8f4673adjl_nscd_cfg_switch_get_stat(
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void **stat,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl struct nscd_cfg_stat_desc *sdesc,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_id_t *nswdb,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_flag_t *dflag,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void (**free_stat)(void *stat),
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nscd_cfg_error_t **errorp)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl{
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (_nscd_cfg_flag_is_set(sdesc->sflag, NSCD_CFG_SFLAG_GLOBAL)) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *stat = &NSCD_SW_STATS_G;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *stat = &NSCD_SW_STATS(nswdb->index);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* indicate the statistics are static, i.e., do not free */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *dflag = _nscd_cfg_flag_set(*dflag, NSCD_CFG_DFLAG_STATIC_DATA);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (NSCD_SUCCESS);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl}