home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 May
/
Pcwk5b98.iso
/
WEBSERVE
/
PI3
/
PI3WEB.EXE
/
DEVEL
/
INCLUDE
/
PIConfig.h
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-19
|
8KB
|
254 lines
/*____________________________________________________________________________*\
*
Copyright (c) 1997 John Roy. All rights reserved.
These sources, libraries and applications are
FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
as long as the following conditions are adhered to.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Redistributions of any form whatsoever and all advertising materials
mentioning features must contain the following
acknowledgment:
"This product includes software developed by John Roy
(http://www.johnroy.com/pi3/)."
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*____________________________________________________________________________*|
*
* $Source: PIConfig.h$
* $Date: Sun Aug 10 06:42:17 1997$
*
Description:
Definition of interface to configuration files and parsed
configuration trees.
\*____________________________________________________________________________*/
/* $HeaderTop:$ */
#ifndef PICONFIG_H_
#define PICONFIG_H_
#include "PIDB.h"
/*____________________________________________________________________________*\
*
Decription:
Definitions and function prototypes for the program database.
\*____________________________________________________________________________*/
typedef struct PIConfigDBString PIConfigString;
typedef struct PIConfigDB PIConfig;
/*____________________________________________________________________________*\
*
Name:
PIConfig_loadConfigurationFile
Synopsis:
int PIConfig_loadConfigurationFile( PIDB *pDB, const char *pFileName,
PIConfig **ppConfigDB )
Description:
Parse the configuration file pFileName and place the parsed
contents in a new DB tree under the specified tree pDB, with the key
PIDBKEY_CONFIGURATION.
If ppConfigDB is non-NULL and a configuration tree is created
the pointer to the new configuration tree will be placed in ppConfigDB.
Notes:
In all cases where pDB and pFileName are non-NULL a new child DB tree
with the key PIDBKEY_CONFIGURATION will be added under the tree pDB.
Return Values:
On complete success PIConfig_loadConfigurationFile() will return zero
(PIAPI_COMPLETED). Other errors may be returned as described below.
Errors:
PIAPI_EINVAL if pDB or pFileName is NULL.
PIAPI_ERROR if an error occurred while parsing the configuration file.
[PIAPI_WARNING] this error code may be returned if a warning was generated
while parsing the configuraton file. Currently
PIAPI_COMPLETED will be returned when a configuration
file is loaded with only warnings.
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI int PIConfig_loadConfigurationFile( PIDB *pDB,
const char *pFileName, PIConfig **ppConfigDB );
/*____________________________________________________________________________*\
*
Name:
PIConfig_findConfiguration
Synopsis:
PIConfig *PIConfig_findConfiguration( PIDB *pDB )
Description:
Search under the PIDB tree node pDB for another tree with the key
PIDBKEY_CONFIGURATION.
The tree hierarchy is search recusively upwards from the node pDB
until the configuration tree is found or the root node is reached
with no match.
Notes:
This function is implemented as
PIConfig *PIDB_Lookup( pDB, <internal type>, PIDBKEY_CONFIGURATION,
PIDBFLAG_PROPAGATEUP )
Return Values:
Returns a pointer to the configuration tree or NULL if it was not
found.
Errors:
Returns NULL is pDB is NULL.
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI PIConfig *PIConfig_findConfiguration( PIDB *pDB );
/*____________________________________________________________________________*\
*
Name:
PIConfig_lookupValue
Synopsis:
const char *PIConfig_lookupValue( PIConfig *pConfig, const char *pKey,
char *pInfoBuffer, int iLen )
Description:
Lookup a value within the specified configuration tree.
If the value is found and pInfoBuffer is non-NULL a description of the
location where the value was defined will be written into it, up to iLen
characters.
Notes:
A configuration file definition line is of the form
Key=<value> <addition values>
The exact format of the description placed in pInfoBuffer is subject to
change but may include the following information:-
<UL>
<LI>The filename from which the value was read.
<LI>The line number within the file where the value was found.
</UL>
If multiple definitions for a key are found within pConfig then the first
will be returned.
Return Values:
Returns a pointer to the value for the key pKey under the configuration
tree. PIConfig_lookupValue() returns NULL if no match is found.
Errors:
Returns NULL if pConfig is NULL.
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI const char *PIConfig_lookupValue( PIConfig *pConfig,
const char *pKey, char *pInfoBuffer, int iLen );
/*____________________________________________________________________________*\
*
Name:
PIConfig_lookupTree
Synopsis:
PIConfig *PIConfig_lookupTree( PIConfig *pConfig, const char *pKey,
char *pInfoBuffer, int iLen )
Description:
Lookup the configuration tree with the key pKey in pConfig.
If the definition is found and pInfoBuffer is non-NULL a description of the
location where the tree was defined will be written into it, up to iLen
characters.
Notes:
A configuration file tree is of the following form
<Key>
...
...
</Key>
The exact format of the description placed in pInfoBuffer is subject to
change but may include the following information:-
- The filename from which the value was read.
- The line number within the file where the value was found.
- The character position within the line where the key definition was
found. For configuration files with
content-type x-pi-internal/x-scl1.0 (.conf or .scl) this will
be the length of the line.
If multiple defintions for a key are found within pConfig
then the first will be returned.
Return Values:
Returns a PIConfig structure. The functions PIConfig_lookupValue()
and PIConfig_lookupTree() can be used to find definitions and trees
within this tree.
Errors:
Returns NULL if a tree with the specified key was not found within
this key.
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI PIConfig *PIConfig_lookupTree( PIConfig *pConfig,
const char *pKey, char *pInfoBuffer, int iLen );
/*____________________________________________________________________________*\
*
Name:
PIConfigString_getString
Synopsis:
const char *PIConfigString_getString( PIConfigString *pString )
Description:
Returns the string value of a given PIConfigString data structure.
Notes:
Return Values:
Returns a pointer to the string of the given PIConfigString data
structure.
Errors:
On error PIConfigString_getString() returns NULL.
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI const char *PIConfigString_getString( PIConfigString *pString );
#endif /* PICONFIG_H_ */