slp_config.c revision 2
1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License (the "License"). 1N/A * You may not use this file except in compliance with the License. 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * When distributing Covered Code, include this CDDL HEADER in each 1N/A * If applicable, add the following below this CDDL HEADER, with the 1N/A * fields enclosed by brackets "[]" replaced with your own identifying 1N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 1N/A * Use is subject to license terms. 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A * Provides accessors to configuration properties. 1N/A * slp_readConfig: attempts to locate slp.conf, and reads in all 1N/A * properties specified therein. 1N/A * slp_get_mtu: returns the MTU 1N/A * slp_get_next_onlist: parses a comma separated list of integers (in 1N/A * string form), returning one at a time. 1N/A * slp_parse_static_das: parses the list of DAs given in the DAAddresses 1N/A * Reads from fp and dynamically reallocates the buffer if necessary. 1N/A * Returns 1 on success, 0 on read completion, and -1 on failure. /* else buf is too small */ while (*p && **p !=
'\n' &&
isspace(**p))
* Reads into the local property store all properties defined in /* check env for alternate config file */ "cannot open config file");
"error reading file: %d",
/* skip comments and newlines */ if (*p ==
'#' || *p ==
';' || *p ==
'\n')
/* get property and value */ /* remove the trailing newline */ * Config convenience wrappers * On the first invocation, *state should == the value of the property * If there are no more timeouts, returns -1, otherwise the timeout. * If the value in the property is invalid, returns the default 2000. (*
state)++;
/* skip the ',' */