⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 piconfig.h

📁 mini http server,可以集成嵌入到程序中,实现简单的web功能
💻 H
字号:
/*____________________________________________________________________________*\
 *

 Copyright (c) 1997-2003 John Roy, Holger Zimmermann. 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. The name of the author may not be used to endorse or promote products
    derived from this software without specific prior written permission.

 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: /cvsroot/pi3web/Pi3Web_200/Source/Pi2API/PIConfig.h,v $
 * $Date: 2003/05/13 18:42:08 $
 *
 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
	<PRE>
	&lt;key&gt;=&lt;value&gt; &lt;additional values&gt;
	</PRE>
	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
	<PRE>
	&lt;key&gt;
	  ...
	  ...
	&lt;/key&gt;
	</PRE>
	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.
		<LI>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.
	</UL>

	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_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -