Welcome to Mike95.com
Home
WELCOME
ABOUT MIKE95.COM
CONTACT ME


Features
FUNNY JOKES
HUMAN FACTOR


C++
Library Source Code:
CGIPARSE
JSTRING
JVECTOR
JSTACK
JHASHTABLE


COM / ASP
MIKE95 COM SVR
- ASP STACK
- ASP QUEUE
- ASP VECTOR


Tutorials:
TEMPLATES
ALGORITHMS
DESIGN PATTERNS


Sample Work
Internet Based
TASK/BUG TRACKER


Visual C++ / MFC
FLIGHT PATH (C++)
MP3 PLAY LIST


Java
JAVA TALK
BAR GRAPH
WEB CAM


Personal
CONTACT ME
RESUME
PICTURES
TRIPS
CGIparse

/*
  This library was downloaded from: http://www.mike95.com

  This library is copyright.  It may freely be used for personal purposes
  if the restriction listed below is adhered to.
      Author: Michael Olivero
      Email:  mike95@mike95.com

  //===============================
  //Start of Restriction Definition
  //===============================
  Anyone can have full use of the library provided they keep this complete comment
  with the source.  Also I would like to ask if any changes are made to the
  code for efficiency reasons, please let me know so I may look into your change and
  likewise incorporate it into library.  If a suggestion makes it into the library,
  your credits will be added to this information.

  Authors of Computer related books are welcome to include this source code as part
  of their publishing, provided credit the Author and make note of where the source
  code was obtained from: http://www.mike95.com
  //=============================
  //End of Restriction Definition
  //=============================

  Description:
  Visit http://www.mike95.com/c_plusplus/classes/CGIparse/
  Parses CGI information into an easy to use object.
*/
  
#ifndef CGICGIparse_NEW_H
#define CGICGIparse_NEW_H

#include "M95_types.h"
#include <stdlib.h>

//Global definitions
//------------------
#define AUTH_TYPE getenv("AUTH_TYPE")
#define GATEWAY_INTERFACE getenv("GATEWAY_INTERFACE")
#define LOGON_USER getenv("LOGON_USER")
#define REQUEST_METHOD getenv("REQUEST_METHOD")
#define QUERY_STRING getenv("QUERY_STRING")

#define CONTENT_LENGTH getenv("CONTENT_LENGTH")
#define CONTENT_TYPE getenv("CONTENT_TYPE")

#define DOCUMENT getenv("DOCUMENT")
#define DOCUMENT_URI getenv("DOCUMENT_URI")
#define DOCUMENT_ROOT getenv("DOCUMENT_ROOT")

#define HTTP_ACCEPT getenv("HTTP_ACCEPT")
#define HTTP_ACCEPT_LANGUAGE getenv("HTTP_ACCEPT_LANGUAGE")
#define HTTP_CONNECTION getenv("HTTP_CONNECTION")
#define HTTP_HOST getenv("HTTP_HOST")
#define HTTP_REFERER getenv("HTTP_REFERER")
#define HTTP_USER_AGENT getenv("HTTP_USER_AGENT")
#define HTTP_COOKIE getenv("HTTP_COOKIE")

#define REMOTE_ADDR getenv("REMOTE_ADDR")
#define REMOTE_HOST getenv("REMOTE_HOST")
#define REMOTE_USER getenv("REMOTE_USER")
#define REMOTE_IDENT getenv("REMOTE_IDENT")

#define SCRIPT_FILENAME getenv("SCRIPT_FILENAME")
#define SCRIPT_NAME getenv("SCRIPT_NAME")

#define SERVER_ADMIN getenv("SERVER_ADMIN")
#define SERVER_PORT getenv("SERVER_PORT")
#define SERVER_PROTOCOL getenv("SERVER_PROTOCOL")
#define SERVER_SOFTWARE getenv("SERVER_SOFTWARE")
#define SERVER_NAME getenv("SERVER_NAME")

#define PATH getenv("PATH")
#define PATH_INFO getenv("PATH_INFO")
#define PATH_TRANSLATED getenv("PATH_TRANSLATED")

using namespace std;

class CGIparse
{
public:
    //Simulate an array of key/value pairs via a dynamic linked list.
    //this is the node of the linked list.
    //=======================================================
    struct node
    {
        //Constructor(s) / Destructors
        //============================
        node( const char* aKey = "", const char* aValue = "", node* alink = NULL );
        virtual ~node();

        const char* getKey() const { return key; }
        const char* getValue() const { return value; }
        const node* getLink() const { return link; }

    private:
        node( const node& ) { } //disable copy constructor

        //Data Members
        //============
        char* key;
        char* value;
        node* link;

        friend class CGIparse;
    };

public:
    // Constructor / Destructor
    //=========================
    CGIparse();
    virtual ~CGIparse();

    //Inspectors
    //==========
    UINT getSize() const { return m_size; }
    const char* getMethod() const { return m_method; }
    const node* getHead() const { return m_head; }
    bool defined( const char* aKey ) const;
    const char* valueOf( const char* key );
    const char* getNextValue( );

    //Modifiers
    //=========
    void addKey( const char* aKey, const char* aValue );
    void replaceKey( const char* aKey, const char* aValue );
    void removeKey( const char* aKey );

    //Useful Functions and public vars
    //================================
    void formDump();

    //Class wide functions
    //====================
    static void envDump();
    static void endMessage( const char* title, const char* message);
    static void printMime( const char* mime = "text/html", bool isLast = false );
    static bool mimeSent() { return mime_sent; }

protected:

    //static class variables
    //======================
    static bool mime_sent;

    //Data Members
    //============
    const node* m_marker;
    char* m_method;
    node* m_head;
    node* m_tail;
    UINT m_size;    //number of key/value pairs


private:
    CGIparse( const CGIparse& obj ) { }    //disable copy constructor
  
    //Private Functions
    //=================
    const UINT convertHex( const char* hexvalue ) const;
    const char* parseHex( char* hexstr ) const;
    const char* errorString( const UINT number ) const;
};

#endif

(c)2024 Mike95.com / Site Disclaimer
Site Meter