home *** CD-ROM | disk | FTP | other *** search
- /*____________________________________________________________________________*\
-
- 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: Dummy.c$
- * $Date: Sun Aug 10 06:37:32 1997$
- *
- Description:
- Dummy handler module.
-
- \*____________________________________________________________________________*/
- /* $SourceTop:$ */
-
- #include <assert.h>
-
- #include "Pi3API.h"
-
-
- /*____________________________________________________________________________*\
- *
- Description:
- Documentation
- \*____________________________________________________________________________*/
- #if 0
- /*
- ** HTML documentation for this handler
- */
- /*___+++HTMLDOC_BEGIN+++___*/
- Name:
- Dummy
-
- Description:
- This handler does not do anything. It is useful as a template and
- as a substitute for handlers that are removed from distribution.
-
- Options:
- <!--
- <H5>Overview</H5>
- <TABLE BORDER=1>
- <TH>Option
- <TH>Default
- <TH>Values
- <TH>Short Description
- <TH>Example(s)
-
- <TR>
- <TD>Pi3Expression
- <TD>+
- <TD>A Pi3Expression
- <TD>Expression to place in debug log
- <TD>Pi3Expression="$c/* value of Content-Type */"
-
- </TABLE>
- <STRONG>-</STRONG> in the <IT>default</IT> indicates no default<BR>
- <STRONG>+</STRONG> in the <IT>default</IT> indicates the field is mandatory<BR>
-
- <H4>Description of Options</H4>
- <H5>
- Pi3Expression
- </H5>
- Pi3Expression to write in the debug log.
- -->
-
- Phase:
- All phases
-
- Returns:
- PIAPI_COMPLETED
-
- Note:
- Example:
- <PRE>
- <Object>
- Name Dummy
- Class DummyClass
- Variable3 "Value3"
- </Object>
-
- <Object>
- ...
- Handle Dummy Variable1="Value1" Variable2="Value2"
- ...
- </Object>
- </PRE>
- /*___+++HTMLDOC_END+++___*/
- #endif
-
- /*____________________________________________________________________________*\
- *
- Description:
- \*____________________________________________________________________________*/
- struct _Dummy
- {
- int xxx;
- };
- typedef struct _Dummy Dummy;
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- int Dummy_fnParameter( void *pData, const char *pVar, const char *pVal,
- const char *pWhere )
- {
- PIObject *pObject = (PIObject *)pData;
- Dummy *pDummy = (Dummy *)PIObject_getUserData( pObject );
- (void)pDummy;
- assert( pVar );
- assert( pVal );
-
- #if 0
- if ( !PIUtil_stricmp( pVar, "Variable1" ) )
- {
- xxx = pVal;
- }
- #endif
- if ( 1 )
- {
- }
- else
- {
- /* ---
- Configuration error
- --- */
- PILog_addMessage(
- PIObject_getDB( pObject ),
- PIObject_getConfigurationDB( pObject ),
- PILOG_ERROR, "Dummy: %sUnknown directive '%s'.", pWhere, pVar );
- return 0;
- };
- return 1;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- int Dummy_init( Dummy *pDummy, PIObject *pObject, int iArgc,
- const char *ppArgv[] )
- {
- int iRet = PIObject_readParameters( pObject, iArgc, ppArgv,
- Dummy_fnParameter, pObject );
-
- /* --- set defaults --- */
- if ( iRet )
- {
- #if 0
- pDummy->xxx = "yyy"
- #endif
- };
-
- return iRet;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int Dummy_onClassLoad( PIClass_LoadAction eLoad, int i,
- const char *a[] )
- {
- return PIAPI_COMPLETED;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int Dummy_constructor( PIObject *pObj,
- int iArgc, const char *ppArgv[] )
- {
- Dummy *pDummy = PIUtil_malloc( sizeof( Dummy ) );
- PIObject_setUserData( pObj, pDummy );
- if ( !Dummy_init( pDummy, pObj, iArgc, ppArgv ) )
- {
- return PIAPI_ERROR;
- };
- return PIAPI_COMPLETED;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int Dummy_copyConstructor( PIObject *o, int i, const char *a[] )
- {
- return PIAPI_ERROR;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- #define MSG "\
- <HTML>\
- <BODY BACKGROUND=\"/icons/Pi3Tile.gif\" BGCOLOR=\"#FFFFFF\">\
- <TITLE>Stub Handler</TITLE>\
- <H1>Stub Handler</H1>\
- This requested handler service has not been added loaded into this server.<BR>\
- </BODY></HTML>\
- "
- PUBLIC_PIAPI int Dummy_execute( PIObject *pObj,
- int iArgc, const char *ppArgv[] )
- {
- PIHTTP *pPIHTTP;
-
- if ( iArgc<1 )
- { return PIAPI_ERROR; };
-
- pPIHTTP = (PIHTTP *)*ppArgv;
-
- /* ---
- If this is a handler phase then send a message
- --- */
- if ( pPIHTTP->ciPhase==PH_HANDLE )
- {
- PIDB *pR = pPIHTTP->pResponseDB;
- /* PIDB *pQ = pPIHTTP->pRequestDB; */
- PIIOBuffer *pB = pPIHTTP->pBuffer;
-
- /* ---
- Send headers
- -- */
- if ( HTTPCore_sendGeneralHeaders( pPIHTTP ) ||
- HTTPCore_sendEntityHeaders( pPIHTTP, pR ) )
- {
- return PIAPI_ERROR;
- };
-
- /* ---
- Send a brief message
- --- */
- PIIOBuffer_writeLn( pB, MSG, sizeof(MSG), PIIOBUF_NONE );
- };
-
- return PIAPI_COMPLETED;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int Dummy_destructor( PIObject *pObj, int i, const char *a[] )
- {
- PIUtil_free( PIObject_getUserData( pObj ) );
- return PIAPI_COMPLETED;
- }
-
- #if 0
- /*___+++CNF_BEGIN+++___*/
- <Class>
- Name DummyClass
- Type LogicExtension
- Library Plugins
- OnClassLoad Dummy_onClassLoad
- Constructor Dummy_constructor
- CopyConstructor Dummy_copyConstructor
- Destructor Dummy_destructor
- Execute Dummy_execute
- </Class>
-
- <Object>
- Name Dummy
- Class DummyClass
- </Object>
-
- /*___+++CNF_END+++___*/
- #endif
-
-