home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / WEBSERVE / PI3 / PI3WEB.EXE / DEVEL / INCLUDE / PIHTTP.H < prev    next >
C/C++ Source or Header  |  1997-10-19  |  7KB  |  264 lines

  1. /*____________________________________________________________________________*\
  2.  *
  3.  
  4.  Copyright (c) 1997 John Roy. All rights reserved.
  5.  
  6.  These sources, libraries and applications are
  7.  FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
  8.  as long as the following conditions are adhered to.
  9.  
  10.  Redistribution and use in source and binary forms, with or without
  11.  modification, are permitted provided that the following conditions
  12.  are met:
  13.  
  14.  1. Redistributions of source code must retain the above copyright
  15.     notice, this list of conditions and the following disclaimer. 
  16.  
  17.  2. Redistributions in binary form must reproduce the above copyright
  18.     notice, this list of conditions and the following disclaimer in
  19.     the documentation and/or other materials provided with the
  20.     distribution.
  21.  
  22.  3. Redistributions of any form whatsoever and all advertising materials 
  23.     mentioning features must contain the following
  24.     acknowledgment:
  25.     "This product includes software developed by John Roy
  26.     (http://www.johnroy.com/pi3/)."
  27.  
  28.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  29.  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30.  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  31.  IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  32.  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34.  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36.  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  37.  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  38.  OF THE POSSIBILITY OF SUCH DAMAGE.
  39.  
  40.  *____________________________________________________________________________*|
  41.  *
  42.  * $Source: PIHTTP.h$
  43.  * $Date: Sun Aug 10 06:36:32 1997$
  44.  *
  45.  Description:
  46.  
  47. \*____________________________________________________________________________*/
  48. /* $SourceTop:$ */
  49.  
  50. #ifndef PIHTTP_H_
  51. #define PIHTTP_H_
  52.  
  53. #include "Pi2API.h"
  54. #include "PIIOBuf.h"
  55. #include "HTTPDefs.h"
  56.  
  57.     /* -------------- +++++++++++++++++++++++++++++++ ------------------ *\
  58.     
  59.                         Internal C++ Interface
  60.  
  61.     \* -------------- +++++++++++++++++++++++++++++++ ------------------ */
  62. #if defined(__cplusplus) && defined(PI3_INTERNAL)
  63.  
  64. #include <assert.h>
  65. #include <stddef.h>
  66.  
  67. #include "DblList.h"        /* --- from Base library --- */
  68.  
  69. #define HTTP_DB                "HTTP DB"
  70. #define HTTP_REQUEST_DB        "HTTP Request DB"
  71. #define HTTP_RESPONSE_DB    "HTTP Response DB"
  72.  
  73. /*____________________________________________________________________________*\
  74.  *
  75.  Description:
  76. \*____________________________________________________________________________*/
  77. class PIHTTP
  78. {
  79. public:
  80.     /* --- public constant values --- */
  81.     const int ciPhase;
  82.  
  83.     /* --- public mutable values --- */    
  84.     int iStatus;
  85.     
  86.     PIDB *pConnectionDB;
  87.     PIDB *pHostDB;
  88.     PIDB *pRequestDB;
  89.     PIDB *pResponseDB;
  90.     PIIOBuffer *pBuffer;
  91.  
  92. public:
  93.     /* --- private members, don't access, even though not marked private --- */
  94.     PIHTTP *pParent;        /* --- NULL if this is not a subrequest --- */
  95.     PIDB *pDB;
  96.     int iLastResultCode;
  97.     PITimer *pTimer;
  98.     const char *pHandlerName;
  99.     int iDelta;                /* --- profile delta of time in handler --- */
  100.     int iDepth;                /* --- depth of current request if nested --- */
  101.     DblList    lMemoryRecords;    /* --- memory records --- */
  102.         
  103. private:
  104.     /* --- copy constructor will be disallowed --- */
  105.     PIHTTP( const PIHTTP &tH );
  106.  
  107.     /* --- internal methods --- */
  108.     void ClearRequest();
  109.  
  110. public:
  111.     PIHTTP( PIHTTP *pTheParentRequest );
  112.     PIHTTP( PIObject *pTheIOObject, PIDB *pTheHostDB );
  113.     PIHTTP( PIDB *pHost );
  114.     ~PIHTTP();
  115.  
  116.     /* --- new request --- */
  117.     void NewRequest();
  118.  
  119.     /* ---
  120.     High level data structures that make up a request/response
  121.     cycle
  122.     --- */
  123.     inline PIDB *GetConnectionDB()            /* connection DB */
  124.         { return pConnectionDB; };    
  125.     inline PIDB *GetHostDB()                /* virtual host DB */
  126.         { return pHostDB; };    
  127.     inline PIDB *GetDB()                    /* generic DB */
  128.         { return pDB; };
  129.     inline PIDB *GetRequestDB()                /* request specific information */
  130.         { return pRequestDB; };
  131.     inline PIDB *GetResponseDB()            /* response specific information */
  132.         { return pResponseDB; };
  133.     inline PIIOBuffer &GetIOBuffer()        /* IO buffer object */
  134.         { return *pBuffer; };
  135.     inline int IsSubRequest()                /* is this a subrequest? */
  136.         { return pParent!=0; };
  137.  
  138.     /* --- allow the virtual host to be changed --- */
  139.     inline void SetHostDB( PIDB *pNewHostDB )
  140.         { pHostDB = pNewHostDB; };
  141.  
  142.     /* --- non-inline functions --- */
  143.     void *AllocMem( size_t tSize );            /* allocate memory */
  144.  
  145. };
  146.  
  147. /* --- inlines --- */
  148. inline void PIHTTP_disableKeepOpen( PIHTTP &tPIHTTP ) 
  149.     { 
  150.     PIDB_replace( tPIHTTP.GetConnectionDB(), PIDBTYPE_OPAQUE, 
  151.         KEY_INT_KEEPOPEN, (void *)0, 0 );
  152.     };
  153.  
  154.     /* -------------- +++++++++++++++++++++++++++++++ ------------------ *\
  155.     
  156.                         External C Interface
  157.  
  158.     \* -------------- +++++++++++++++++++++++++++++++ ------------------ */
  159. #else
  160. /*____________________________________________________________________________*\
  161.  *
  162.  Description:
  163.     C structure version of C++ class.
  164. \*____________________________________________________________________________*/
  165. struct _PIHTTP
  166. {
  167.     /* --- public constant values --- */
  168.     int ciPhase;
  169.  
  170.     /* --- public mutable values --- */    
  171.     int iStatus;
  172.     
  173.     PIDB *pConnectionDB;
  174.     PIDB *pHostDB;
  175.     PIDB *pRequestDB;
  176.     PIDB *pResponseDB;
  177.     PIIOBuffer *pBuffer;
  178.  
  179.     /* --- other members are private --- */
  180.  
  181. };
  182. typedef struct _PIHTTP PIHTTP;
  183.  
  184. #endif
  185.     /* -------------- +++++++++++++++++++++++++++++++ ------------------ *\
  186.     
  187.                         C Functions
  188.  
  189.     \* -------------- +++++++++++++++++++++++++++++++ ------------------ */
  190. /*____________________________________________________________________________*\
  191.  *
  192.  Name:
  193.     PIHTTP_new
  194.  
  195.  Synopsis:
  196.     PIHTTP *PIHTTP_new( PIObject *pIOObject, PIDB *pHostDB )
  197.  
  198.  Description:
  199.     This function is not yet documented.
  200.  
  201.  Notes:
  202.  Return Values:
  203.  Errors:
  204.  See Also:
  205. \*____________________________________________________________________________*/
  206. PUBLIC_PIAPI PIHTTP *PIHTTP_new( PIObject *pIOObject, PIDB *pHostDB );
  207.  
  208. /*____________________________________________________________________________*\
  209.  *
  210.  Name:
  211.     PIHTTP_newChild
  212.  
  213.  Synopsis:
  214.     PIHTTP *PIHTTP_newChild( PIHTTP *pParent )
  215.  
  216.  Description:
  217.     This function is not yet documented.
  218.  
  219.  Notes:
  220.  Return Values:
  221.  Errors:
  222.  See Also:
  223. \*____________________________________________________________________________*/
  224. PUBLIC_PIAPI PIHTTP *PIHTTP_newChild( PIHTTP *pParent );
  225.  
  226. /*____________________________________________________________________________*\
  227.  *
  228.  Name:
  229.     PIHTTP_delete
  230.  
  231.  Synopsis:
  232.     int PIHTTP_delete( PIHTTP *pPIHTTP )
  233.  
  234.  Description:
  235.     This function is not yet documented.
  236.  
  237.  Notes:
  238.  Return Values:
  239.  Errors:
  240.  See Also:
  241. \*____________________________________________________________________________*/
  242. PUBLIC_PIAPI int PIHTTP_delete( PIHTTP *pPIHTTP );
  243.  
  244. /*____________________________________________________________________________*\
  245.  *
  246.  Name:
  247.     PIHTTP_allocMem
  248.  
  249.  Synopsis:
  250.     void *PIHTTP_allocMem( PIHTTP *pPIHTTP, unsigned int iSize )
  251.  
  252.  Description:
  253.     This function is not yet documented.
  254.  
  255.  Notes:
  256.  Return Values:
  257.  Errors:
  258.  See Also:
  259. \*____________________________________________________________________________*/
  260. PUBLIC_PIAPI void *PIHTTP_allocMem( PIHTTP *pPIHTTP, unsigned int iSize );
  261.  
  262. #endif /* PIHTTP_H_ */
  263.  
  264.