home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / WEBSERVE / PI3 / PI3WEB.EXE / DEVEL / Plugins / ImageMap.c < prev    next >
C/C++ Source or Header  |  1997-10-19  |  8KB  |  325 lines

  1. /*____________________________________________________________________________*\
  2.  
  3.  Copyright (c) 1997 John Roy. All rights reserved.
  4.  
  5.  These sources, libraries and applications are
  6.  FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
  7.  as long as the following conditions are adhered to.
  8.  
  9.  Redistribution and use in source and binary forms, with or without
  10.  modification, are permitted provided that the following conditions
  11.  are met:
  12.  
  13.  1. Redistributions of source code must retain the above copyright
  14.     notice, this list of conditions and the following disclaimer. 
  15.  
  16.  2. Redistributions in binary form must reproduce the above copyright
  17.     notice, this list of conditions and the following disclaimer in
  18.     the documentation and/or other materials provided with the
  19.     distribution.
  20.  
  21.  3. Redistributions of any form whatsoever and all advertising materials 
  22.     mentioning features must contain the following
  23.     acknowledgment:
  24.     "This product includes software developed by John Roy
  25.     (http://www.johnroy.com/pi3/)."
  26.  
  27.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  28.  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29.  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  30.  IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  31.  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32.  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  33.  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34.  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  35.  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36.  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  37.  OF THE POSSIBILITY OF SUCH DAMAGE.
  38.  
  39.  *____________________________________________________________________________*|
  40.  *
  41.  * $Source: ImageMap.c$
  42.  * $Date: Sun Aug 10 06:37:32 1997$
  43.  *
  44.  Description:
  45.     ImageMap handler module.
  46.  
  47. \*____________________________________________________________________________*/
  48. /* $SourceTop:$ */
  49.  
  50. #include <assert.h>
  51. #include <stdio.h>
  52.  
  53. #include "Pi3API.h"
  54.  
  55.  
  56. /*____________________________________________________________________________*\
  57.  *
  58.  Description:
  59.     Documentation
  60. \*____________________________________________________________________________*/
  61. #if 0
  62.     /*
  63.     ** HTML documentation for this handler
  64.     */
  65. /*___+++HTMLDOC_BEGIN+++___*/
  66. Name:
  67.     ImageMap
  68.  
  69. Description:
  70.     Server-side image maps are not included in this configuration. 
  71.  
  72. <!--
  73.  
  74. Options:
  75. <H5>Overview</H5>
  76. <TABLE BORDER=1>
  77. <TH>Option
  78. <TH>Default
  79. <TH>Values
  80. <TH>Short Description
  81. <TH>Example(s)
  82.  
  83. <TR>
  84. <TD>Pi3Expression
  85. <TD>+
  86. <TD>A Pi3Expression
  87. <TD>Expression to place in debug log
  88. <TD>Pi3Expression="$c/* value of Content-Type */"
  89.  
  90. </TABLE>
  91. <STRONG>-</STRONG> in the <IT>default</IT> indicates no default<BR>
  92. <STRONG>+</STRONG> in the <IT>default</IT> indicates the field is mandatory<BR>
  93.  
  94. <H4>Description of Options</H4>
  95. <H5>
  96.     Pi3Expression
  97. </H5>
  98. Pi3Expression to write in the debug log.
  99.  
  100. -->
  101.  
  102. Phase:
  103.     HANDLE
  104.  
  105. Returns:
  106.     PIAPI_COMPLETED
  107.  
  108. Note:
  109. Example:
  110.     <PRE>
  111.     <Object>
  112.         Name ImageMap
  113.         Class ImageMapClass
  114.     </Object>
  115.  
  116.     <Object>
  117.         ...
  118.         Handle ImageMap 
  119.         ...
  120.     </Object>
  121.     </PRE>
  122. /*___+++HTMLDOC_END+++___*/
  123. #endif
  124.  
  125. /*____________________________________________________________________________*\
  126.  *
  127.  Description:
  128. \*____________________________________________________________________________*/
  129. struct _ImageMap
  130. {
  131.     int xxx;
  132. };
  133. typedef struct _ImageMap ImageMap;
  134.  
  135. /*____________________________________________________________________________*\
  136.  *
  137.  Function:
  138.  Synopsis:
  139.  Description:
  140. \*____________________________________________________________________________*/
  141. int ImageMap_fnParameter( void *pData, const char *pVar, const char *pVal,
  142.     const char *pWhere )
  143. {
  144.     PIObject *pObject = (PIObject *)pData;
  145.     ImageMap *pImageMap = (ImageMap *)PIObject_getUserData( pObject );
  146.     (void)pImageMap;
  147.     assert( pVar );
  148.     assert( pVal );
  149.  
  150. #if 0
  151.     if ( !PIUtil_stricmp( pVar, "Variable1" ) )
  152.         {
  153.         xxx = pVal;
  154.         }
  155. #endif
  156.     if ( 1 )
  157.         {
  158.         }
  159.     else
  160.         {
  161.         /* ---
  162.         Configuration error
  163.         --- */
  164.         PILog_addMessage(
  165.             PIObject_getDB( pObject ),
  166.             PIObject_getConfigurationDB( pObject ),
  167.             PILOG_ERROR, "ImageMap: %sUnknown directive '%s'.", pWhere, pVar );
  168.         return 0;
  169.         };
  170.     return 1;
  171. }
  172.  
  173. /*____________________________________________________________________________*\
  174.  *
  175.  Function:
  176.  Synopsis:
  177.  Description:
  178. \*____________________________________________________________________________*/
  179. int ImageMap_init( ImageMap *pImageMap, PIObject *pObject, int iArgc,
  180.     const char *ppArgv[] )
  181. {
  182.     int iRet = PIObject_readParameters( pObject, iArgc, ppArgv,
  183.         ImageMap_fnParameter, pObject );
  184.  
  185.     /* --- set defaults --- */
  186.     if ( iRet )
  187.         {
  188. #if 0
  189.         pImageMap->xxx = "yyy"
  190. #endif
  191.         };
  192.  
  193.     return iRet;
  194. }
  195.  
  196. /*____________________________________________________________________________*\
  197.  *
  198.  Function:
  199.  Synopsis:
  200.  Description:
  201. \*____________________________________________________________________________*/
  202. PUBLIC_PIAPI int ImageMap_onClassLoad( PIClass_LoadAction eLoad, int i,
  203.     const char *a[] )
  204. {
  205.     return PIAPI_COMPLETED;
  206. }
  207.  
  208. /*____________________________________________________________________________*\
  209.  *
  210.  Function:
  211.  Synopsis:
  212.  Description:
  213. \*____________________________________________________________________________*/
  214. PUBLIC_PIAPI int ImageMap_constructor( PIObject *pObj,
  215.     int iArgc, const char *ppArgv[] )
  216. {
  217.     ImageMap *pImageMap = PIUtil_malloc( sizeof( ImageMap ) );
  218.     PIObject_setUserData( pObj, pImageMap );
  219.     if ( !ImageMap_init( pImageMap, pObj, iArgc, ppArgv ) )
  220.         {
  221.         return PIAPI_ERROR;
  222.         };
  223.     return PIAPI_COMPLETED;
  224. }
  225.  
  226. /*____________________________________________________________________________*\
  227.  *
  228.  Function:
  229.  Synopsis:
  230.  Description:
  231. \*____________________________________________________________________________*/
  232. PUBLIC_PIAPI int ImageMap_copyConstructor( PIObject *o, int i, const char *a[] )
  233. {
  234.     return PIAPI_ERROR;
  235. }
  236.  
  237. /*____________________________________________________________________________*\
  238.  *
  239.  Function:
  240.  Synopsis:
  241.  Description:
  242. \*____________________________________________________________________________*/
  243. #define MSG "\
  244. <HTML>\
  245. <BODY BACKGROUND=\"/icons/Pi3Tile.gif\" BGCOLOR=\"#FFFFFF\">\
  246. <TITLE>Image Map Handler</TITLE>\
  247. <H1>Image Map Handler</H1>\
  248. The image map handler has not been included in this distribution.<BR>\
  249. </BODY></HTML>\
  250. "
  251. PUBLIC_PIAPI int ImageMap_execute( PIObject *pObj,
  252.     int iArgc, const char *ppArgv[] )
  253. {
  254.     enum { SMALL_BUF=64 };
  255.     char szBuf[SMALL_BUF];
  256.     PIHTTP *pPIHTTP;
  257.  
  258.     if ( iArgc<1 )
  259.         { return PIAPI_ERROR; };
  260.  
  261.     pPIHTTP = (PIHTTP *)*ppArgv;
  262.  
  263.     if ( pPIHTTP->ciPhase!=PH_HANDLE )
  264.         { return PIAPI_ERROR; };
  265.  
  266.     /* ---
  267.     Replace headers
  268.     --- */
  269.     PIDB_replace( pPIHTTP->pResponseDB, PIDBTYPE_RFC822, KEY_HTTP_CONTENTTYPE,
  270.         (void *)"text/html", 0 );
  271.     sprintf( szBuf, "%d", sizeof(MSG) );
  272.     PIDB_replace( pPIHTTP->pResponseDB, PIDBTYPE_RFC822, KEY_HTTP_CONTENTLENGTH,
  273.         (void *)szBuf, 0 );
  274.     
  275.     /* ---
  276.     Send headers
  277.     -- */
  278.        if (    HTTPCore_sendGeneralHeaders( pPIHTTP ) ||
  279.             HTTPCore_sendEntityHeaders( pPIHTTP, pPIHTTP->pResponseDB ) )
  280.         {
  281.         return PIAPI_ERROR;
  282.         };
  283.  
  284.     /* ---
  285.     Send a brief message
  286.     --- */
  287.     PIIOBuffer_write( pPIHTTP->pBuffer, MSG, sizeof(MSG), PIIOBUF_NONE );
  288.  
  289.     return PIAPI_COMPLETED;
  290. }
  291.  
  292. /*____________________________________________________________________________*\
  293.  *
  294.  Function:
  295.  Synopsis:
  296.  Description:
  297. \*____________________________________________________________________________*/
  298. PUBLIC_PIAPI int ImageMap_destructor( PIObject *pObj, int i, const char *a[] )
  299. {
  300.     PIUtil_free( PIObject_getUserData( pObj ) );
  301.     return PIAPI_COMPLETED;
  302. }
  303.  
  304. #if 0
  305. /*___+++CNF_BEGIN+++___*/
  306.     <Class>
  307.         Name ImageMapClass
  308.         Type LogicExtension
  309.         Library Plugins
  310.         OnClassLoad ImageMap_onClassLoad
  311.         Constructor ImageMap_constructor
  312.         CopyConstructor ImageMap_copyConstructor
  313.         Destructor ImageMap_destructor
  314.         Execute ImageMap_execute
  315.     </Class>
  316.  
  317.     <Object>
  318.         Name ImageMap
  319.         Class ImageMapClass
  320.     </Object>
  321.  
  322. /*___+++CNF_END+++___*/
  323. #endif
  324.  
  325.