/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Provides accessors to configuration properties.
*
* slp_readConfig: attempts to locate slp.conf, and reads in all
* properties specified therein.
* slp_get_mtu: returns the MTU
* slp_get_next_onlist: parses a comma separated list of integers (in
* string form), returning one at a time.
* slp_parse_static_das: parses the list of DAs given in the DAAddresses
* property.
*
* Also see the config wrapper macros in slp-internal.h.
*/
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <slp-internal.h>
/*
* Reads from fp and dynamically reallocates the buffer if necessary.
* Returns 1 on success, 0 on read completion, and -1 on failure.
*/
char *r, *p;
p = *buf;
real_bufsize = *bufsize;
for (;;) {
return (0);
if (!r)
return (-1);
return (1);
/* else buf is too small */
*bufsize *= 2;
return (-1);
}
}
}
static void skip_space(char **p) {
while (*p && **p != '\n' && isspace(**p))
(*p)++;
}
static void null_space(char *p) {
for (; *p; p++)
if (isspace(*p))
*p = 0;
}
/*
* Reads into the local property store all properties defined in
* the config file.
*/
void slp_readConfig() {
/* check env for alternate config file */
if (!fp)
"cannot open config file");
return;
}
return;
}
char *val, *p;
int err;
/* read a line */
if (err == 0) continue;
if (err == -1) {
"error reading file: %d",
return;
}
/* skip comments and newlines */
p = buf;
skip_space(&p);
if (*p == '#' || *p == ';' || *p == '\n')
continue;
/* get property and value */
*val++ = 0;
skip_space(&val);
/* remove the trailing newline */
}
null_space(p);
}
}
/*
* Config convenience wrappers
*/
return (size);
}
/*
* On the first invocation, *state should == the value of the property
* to parse.
* If there are no more timeouts, returns -1, otherwise the timeout.
* If the value in the property is invalid, returns the default 2000.
*/
size_t l;
int answer;
if (!*state)
return (-1);
if (**state == ',') {
(*state)++; /* skip the ',' */
}
p = *state;
if (!*state)
l = strlen(p);
else {
l = *state - p;
l = (l > 32 ? 32 : l);
}
buf[l] = 0;
}
int slp_get_maxResults() {
}