nscd_parse.c revision cb5caa98562cf06753163f558cbcfe30b8f4673a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1994-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* routine to parse configuration file
*
* returns -1 on error, 0 on sucess. Error messages to log.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <synch.h>
#include <unistd.h>
#include "getxby_door.h"
#include "server_door.h"
#include "nscd.h"
static int strbreak(char **, char *, char *);
static int nscd_yesno(char *);
static int nscd_set_integer(int *, char *, char *, int, int, int);
static int nscd_set_short(short *, char *, char *, int, int, int);
static int nscd_setyesno(int *, char *, char *, int);
static int nscd_setyesno_sh(short *, char *, char *, int);
static int nscd_set_cf(nsc_stat_t *, char *, int);
int
{
char buffer[255];
char *fields [128];
int errflg;
int linecnt;
int fieldcnt;
logit("%s: open of configuration file %s failed: %s\n",
return (-1);
}
errflg = 0;
linecnt = 0;
linecnt++;
/* blank */
continue;
}
switch (*fields[0]) {
case '#': /* comment ignore it */
break;
case 'p':
(fieldcnt != 3) ||
errflg++;
break;
}
errflg++;
break;
case 'n':
(fieldcnt != 3) ||
errflg++;
break;
}
errflg++;
break;
case 's':
(fieldcnt != 3) ||
errflg++;
break;
}
errflg++;
break;
case 'k':
(fieldcnt != 3) ||
errflg++;
break;
}
errflg++;
break;
case 'o':
(fieldcnt != 3) ||
errflg++;
break;
}
errflg++;
}
break;
case 'e':
(fieldcnt != 3) ||
errflg++;
break;
}
errflg++;
break;
case 'c':
(fieldcnt != 3) ||
errflg++;
break;
}
errflg++;
break;
case 'l':
errflg++;
break;
}
errflg++;
break;
case 'd':
errflg++;
break;
}
errflg++;
break;
default:
errflg++;
break;
}
if (errflg) {
logit("Syntax error line %d of configuration file %s\n",
return (-1);
}
}
return (errflg?-1:0);
}
static int
{
register int i;
char *lasts;
;
return (i);
}
static int
nscd_yesno(char *s)
{
if (strcmp(s, "yes") == 0)
return (1);
if (strcmp(s, "no") == 0)
return (0);
return (-1);
}
static int
{
logit("attempted to set value of %s for %s to %d, which is not"
return (-1);
}
if (current_admin.debug_level)
logit("Setting %s for %s to %d\n",
return (1);
}
return (0);
}
static int
{
logit("attempted to set value of %s for %s to %d, which is not "
return (-1);
}
if (current_admin.debug_level) {
logit("Setting %s for %s to %d\n",
}
return (1);
}
return (0);
}
static int
{
int yn;
case 1:
case 0:
if (current_admin.debug_level)
return (1);
}
else
return (0);
}
return (-1);
}
static int
{
int yn;
case 1:
case 0:
if (current_admin.debug_level) {
logit("%s now %s for %s\n",
}
return (1);
}
else
return (0);
}
return (-1);
}
int
{
value, 0, 10));
}
int
{
}
static int
{
}
int
{
logit("ttl less than 600 seconds - disabling keep warm for %s "
"cache\n", name);
return (0);
} else {
}
}
int
{
}
int
{
}
int
{
"Time to live for positive cache entries",
cache->nsc_keephot = 0;
logit("Disabling keephot for cache %s since ttl is less than "
"600 seconds\n", name);
}
return (result);
}
int
{
"Time to live for negative cache entries",
return (result);
}