home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 May
/
Pcwk5b98.iso
/
WEBSERVE
/
PI3
/
PI3WEB.EXE
/
DEVEL
/
Plugins
/
ImageMap.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-19
|
8KB
|
325 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: ImageMap.c$
* $Date: Sun Aug 10 06:37:32 1997$
*
Description:
ImageMap handler module.
\*____________________________________________________________________________*/
/* $SourceTop:$ */
#include <assert.h>
#include <stdio.h>
#include "Pi3API.h"
/*____________________________________________________________________________*\
*
Description:
Documentation
\*____________________________________________________________________________*/
#if 0
/*
** HTML documentation for this handler
*/
/*___+++HTMLDOC_BEGIN+++___*/
Name:
ImageMap
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>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:
HANDLE
Returns:
PIAPI_COMPLETED
Note:
Example:
<PRE>
<Object>
Name ImageMap
Class ImageMapClass
</Object>
<Object>
...
Handle ImageMap
...
</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;
ImageMap *pImageMap = (ImageMap *)PIObject_getUserData( pObject );
(void)pImageMap;
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, "ImageMap: %sUnknown directive '%s'.", pWhere, pVar );
return 0;
};
return 1;
}
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
int ImageMap_init( ImageMap *pImageMap, PIObject *pObject, int iArgc,
const char *ppArgv[] )
{
int iRet = PIObject_readParameters( 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[] )
{
ImageMap *pImageMap = PIUtil_malloc( sizeof( ImageMap ) );
PIObject_setUserData( 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
--- */
PIDB_replace( pPIHTTP->pResponseDB, PIDBTYPE_RFC822, KEY_HTTP_CONTENTTYPE,
(void *)"text/html", 0 );
sprintf( szBuf, "%d", sizeof(MSG) );
PIDB_replace( pPIHTTP->pResponseDB, PIDBTYPE_RFC822, KEY_HTTP_CONTENTLENGTH,
(void *)szBuf, 0 );
/* ---
Send headers
-- */
if ( HTTPCore_sendGeneralHeaders( pPIHTTP ) ||
HTTPCore_sendEntityHeaders( pPIHTTP, pPIHTTP->pResponseDB ) )
{
return PIAPI_ERROR;
};
/* ---
Send a brief message
--- */
PIIOBuffer_write( 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[] )
{
PIUtil_free( PIObject_getUserData( 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 ImageMap
Class ImageMapClass
</Object>
/*___+++CNF_END+++___*/
#endif