/*===========================================================================
 *
 * File:	CGIQuery.H
 * Author:	Dave Humphrey (uesp@m0use.net)
 * Created On:	Friday, March 30, 2001
 *
 * Defines the CHTMLQuery class, used to input and parse output from
 * form queries.
 *
 *=========================================================================*/
#ifndef __CGIQUERY_H
#define __CGIQUERY_H


/*===========================================================================
 *
 * Begin Required Include Files
 *
 *=========================================================================*/
  #include "dl_cgi.h"
/*===========================================================================
 *		End of Required Include Files
 *=========================================================================*/


/*===========================================================================
 *
 * Begin Type and Structure Definitions
 *
 *=========================================================================*/

	/* ParseQuery callback function type */
  typedef boolean (*PPARSEQUERYCALLBACK) (char* pVar, char* pValue);

/*===========================================================================
 *		End of Type and Structure Definitions
 *=========================================================================*/


/*===========================================================================
 *
 * Begin Class CHTMLQuery Definition
 *
 * Attempts to read and parse a GET or POST form query.
 *
 *=========================================================================*/
class CHTMLQuery {

  /*---------- Begin Protected Class Members --------------------*/
protected:
  char*  pQueryBuffer;		/* The query buffer */
  size_t QueryLength;		/* Size, in bytes, of the query buffer */


  /*---------- Begin Protected Class Methods --------------------*/
protected:

	/* Read the GET or POST type queries */
  boolean ReadGETQuery  (void);
  boolean ReadPOSTQuery (void);
  
	/* Convert a webified form output query to regular characters */
  boolean UnWebQuery (void);


  /*---------- Begin Public Class Methods -----------------------*/
public:

	/* Class Constructors/Destructors */
  CHTMLQuery();
  virtual ~CHTMLQuery();
  virtual void Destroy (void);

	/* Get class members */
  char*  GetQuery       (void) const;
  size_t GetQueryLength (void) const;

  	/* Parse the current query string into individual variable-value pairs */
  boolean ParseQuery (PPARSEQUERYCALLBACK CallBackFunc);

	/* Read a POST/GET form query if available*/
  boolean ReadQuery (void);
  boolean ReadQuery (PPARSEQUERYCALLBACK CallBackFunc);

 };
/*===========================================================================
 *		End of Class CHTMLQuery Definition
 *=========================================================================*/


/*===========================================================================
 *
 * Begin Class CHTMLQuery Inline Methods
 *
 *=========================================================================*/
inline CHTMLQuery::~CHTMLQuery() { Destroy(); }
inline char*   CHTMLQuery::GetQuery       (void) const { return (pQueryBuffer); }
inline size_t  CHTMLQuery::GetQueryLength (void) const { return (QueryLength); }
/*===========================================================================
 *		End of Class CHTMLQuery Inline Methods
 *=========================================================================*/


#endif
/*===========================================================================
 *		End of File CGIQuery.H
 *=========================================================================*/