home *** CD-ROM | disk | FTP | other *** search
- <HTML><TITLE>ImageMap.c</TITLE><BODY><PRE>/*____________________________________________________________________________*\
-
- 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: ImageMap.c$
- * $Date: Sun Aug 10 06:37:32 1997$
- *
- Description:
- <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A> handler module.
-
- \*____________________________________________________________________________*/
- /* $SourceTop:$ */
-
- #include <assert.h>
- #include <stdio.h>
-
- #include "Pi3API.h"
-
-
- /*____________________________________________________________________________*\
- *
- Description:
- Documentation
- \*____________________________________________________________________________*/
- #if 0
- /*
- ** HTML documentation for this handler
- */
- /*___+++HTMLDOC_BEGIN+++___*/
- Name:
- <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A>
-
- Description:
- Server-side image maps are not included in this configuration.
-
- <!--
-
- Options:
- <H5>Overview</H5>
- <TABLE BORDER=1>
- <TH>Option
- <TH>Default
- <TH>Values
- <TH>Short Description
- <TH>Example(s)
-
- <TR>
- <TD><A HREF="/pidocs/Objects/Pi3API.html#Pi3Expression">Pi3Expression</A>
- <TD>+
- <TD>A <A HREF="/pidocs/Objects/Pi3API.html#Pi3Expression">Pi3Expression</A>
- <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>
- <A HREF="/pidocs/Objects/Pi3API.html#Pi3Expression">Pi3Expression</A>
- </H5>
- <A HREF="/pidocs/Objects/Pi3API.html#Pi3Expression">Pi3Expression</A> to write in the debug log.
-
- -->
-
- Phase:
- HANDLE
-
- Returns:
- PIAPI_COMPLETED
-
- Note:
- Example:
- <PRE>
- <Object>
- Name <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A>
- Class ImageMapClass
- </Object>
-
- <Object>
- ...
- Handle <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A>
- ...
- </Object>
- </PRE>
- /*___+++HTMLDOC_END+++___*/
- #endif
-
- /*____________________________________________________________________________*\
- *
- Description:
- \*____________________________________________________________________________*/
- struct _ImageMap
- {
- int xxx;
- };
- typedef struct _ImageMap ImageMap;
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- int ImageMap_fnParameter( void *pData, const char *pVar, const char *pVal,
- const char *pWhere )
- {
- PIObject *pObject = (PIObject *)pData;
- <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A> *pImageMap = (<A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A> *)<A HREF="/pidocs/APISpec/Pi2API.html#PIObject_getUserData">PIObject_getUserData</A>( pObject );
- (void)pImageMap;
- assert( pVar );
- assert( pVal );
-
- #if 0
- if ( !<A HREF="/pidocs/APISpec/PiAPI.html#PIUtil_stricmp">PIUtil_stricmp</A>( pVar, "Variable1" ) )
- {
- xxx = pVal;
- }
- #endif
- if ( 1 )
- {
- }
- else
- {
- /* ---
- Configuration error
- --- */
- <A HREF="/pidocs/APISpec/Pi2API.html#PILog_addMessage">PILog_addMessage</A>(
- <A HREF="/pidocs/APISpec/Pi2API.html#PIObject_getDB">PIObject_getDB</A>( pObject ),
- <A HREF="/pidocs/APISpec/Pi2API.html#PIObject_getConfigurationDB">PIObject_getConfigurationDB</A>( pObject ),
- PILOG_ERROR, "ImageMap: %sUnknown directive '%s'.", pWhere, pVar );
- return 0;
- };
- return 1;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- int ImageMap_init( <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A> *pImageMap, PIObject *pObject, int iArgc,
- const char *ppArgv[] )
- {
- int iRet = <A HREF="/pidocs/APISpec/Pi2API.html#PIObject_readParameters">PIObject_readParameters</A>( pObject, iArgc, ppArgv,
- ImageMap_fnParameter, pObject );
-
- /* --- set defaults --- */
- if ( iRet )
- {
- #if 0
- pImageMap->xxx = "yyy"
- #endif
- };
-
- return iRet;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int ImageMap_onClassLoad( PIClass_LoadAction eLoad, int i,
- const char *a[] )
- {
- return PIAPI_COMPLETED;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int ImageMap_constructor( PIObject *pObj,
- int iArgc, const char *ppArgv[] )
- {
- <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A> *pImageMap = <A HREF="/pidocs/APISpec/PiAPI.html#PIUtil_malloc">PIUtil_malloc</A>( sizeof( <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A> ) );
- <A HREF="/pidocs/APISpec/Pi2API.html#PIObject_setUserData">PIObject_setUserData</A>( pObj, pImageMap );
- if ( !ImageMap_init( pImageMap, pObj, iArgc, ppArgv ) )
- {
- return PIAPI_ERROR;
- };
- return PIAPI_COMPLETED;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int ImageMap_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>Image Map Handler</TITLE>\
- <H1>Image Map Handler</H1>\
- The image map handler has not been included in this distribution.<BR>\
- </BODY></HTML>\
- "
- PUBLIC_PIAPI int ImageMap_execute( PIObject *pObj,
- int iArgc, const char *ppArgv[] )
- {
- enum { SMALL_BUF=64 };
- char szBuf[SMALL_BUF];
- PIHTTP *pPIHTTP;
-
- if ( iArgc<1 )
- { return PIAPI_ERROR; };
-
- pPIHTTP = (PIHTTP *)*ppArgv;
-
- if ( pPIHTTP->ciPhase!=PH_HANDLE )
- { return PIAPI_ERROR; };
-
- /* ---
- Replace headers
- --- */
- <A HREF="/pidocs/APISpec/Pi2API.html#PIDB_replace">PIDB_replace</A>( pPIHTTP->pResponseDB, PIDBTYPE_RFC822, KEY_HTTP_CONTENTTYPE,
- (void *)"text/html", 0 );
- sprintf( szBuf, "%d", sizeof(MSG) );
- <A HREF="/pidocs/APISpec/Pi2API.html#PIDB_replace">PIDB_replace</A>( pPIHTTP->pResponseDB, PIDBTYPE_RFC822, KEY_HTTP_CONTENTLENGTH,
- (void *)szBuf, 0 );
-
- /* ---
- Send headers
- -- */
- if ( <A HREF="/pidocs/APISpec/Pi3API.html#HTTPCore_sendGeneralHeaders">HTTPCore_sendGeneralHeaders</A>( pPIHTTP ) ||
- <A HREF="/pidocs/APISpec/Pi3API.html#HTTPCore_sendEntityHeaders">HTTPCore_sendEntityHeaders</A>( pPIHTTP, pPIHTTP->pResponseDB ) )
- {
- return PIAPI_ERROR;
- };
-
- /* ---
- Send a brief message
- --- */
- <A HREF="/pidocs/APISpec/Pi3API.html#PIIOBuffer_write">PIIOBuffer_write</A>( pPIHTTP->pBuffer, MSG, sizeof(MSG), PIIOBUF_NONE );
-
- return PIAPI_COMPLETED;
- }
-
- /*____________________________________________________________________________*\
- *
- Function:
- Synopsis:
- Description:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int ImageMap_destructor( PIObject *pObj, int i, const char *a[] )
- {
- <A HREF="/pidocs/APISpec/PiAPI.html#PIUtil_free">PIUtil_free</A>( <A HREF="/pidocs/APISpec/Pi2API.html#PIObject_getUserData">PIObject_getUserData</A>( pObj ) );
- return PIAPI_COMPLETED;
- }
-
- #if 0
- /*___+++CNF_BEGIN+++___*/
- <Class>
- Name ImageMapClass
- Type LogicExtension
- Library Plugins
- OnClassLoad ImageMap_onClassLoad
- Constructor ImageMap_constructor
- CopyConstructor ImageMap_copyConstructor
- Destructor ImageMap_destructor
- Execute ImageMap_execute
- </Class>
-
- <Object>
- Name <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A>
- Class ImageMapClass
- </Object>
-
- /*___+++CNF_END+++___*/
- #endif
-
- </PRE></BODY></HTML>