| CgiEnvironment.h | | CgiEnvironment.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: CgiEnvironment.h,v 1.4 1999/08/20 20:51:43 sbooth Exp $ | | * $Id: CgiEnvironment.h,v 1.9 2001/09/05 02:18:28 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _CGIENVIRONMENT_H_ | | #ifndef _CGIENVIRONMENT_H_ | |
| #define _CGIENVIRONMENT_H_ 1 | | #define _CGIENVIRONMENT_H_ 1 | |
| | | | |
| #ifdef __GNUG__ | | #ifdef __GNUG__ | |
| # pragma interface | | # pragma interface | |
| #endif | | #endif | |
| | | | |
|
| #include <vector> | | /*! \file CgiEnvironment.h | |
| | | * \brief Class encapsulating the CGI runtime environment | |
| | | * | |
| | | * The \c CgiEnvironment class encapsulates the environment of | |
| | | * the CGI application as described by the HTTP server. \c CgiEnvironment | |
| | | * contains the \c GET or \c POST data along with all environment variables | |
| | | * set by the HTTP server specified in the CGI specification. | |
| | | */ | |
| | | | |
| #include <string> | | #include <string> | |
|
| | | #include <vector> | |
| #include <cstdlib> | | #include <cstdlib> | |
| | | | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/CgiDefs.h" | |
| #include "cgicc/CgiUtils.h" | | #include "cgicc/CgiUtils.h" | |
|
| #include "cgicc/HTTPHeaders.h" | | #include "cgicc/HTTPCookie.h" | |
| | | | |
| CGICC_BEGIN_NAMESPACE | | CGICC_BEGIN_NAMESPACE | |
| | | | |
|
| | | //! A stream-reader function, for FastCGI compatibility | |
| | | typedef size_t (* reader_function_t)(void *, size_t); | |
| | | | |
| #ifdef WIN32 | | #ifdef WIN32 | |
| template class CGICC_API STDNS vector<HTTPCookie>; | | template class CGICC_API STDNS vector<HTTPCookie>; | |
| #endif | | #endif | |
| | | | |
| // ============================================================ | | // ============================================================ | |
|
| | | // Iterator typedefs | |
| | | // ============================================================ | |
| | | | |
| | | //! A vector of HTTPCookie objects | |
| | | typedef STDNS vector<HTTPCookie>::iterator cookie_iterator; | |
| | | //! A vector of \c const HTTPCookie objects | |
| | | typedef STDNS vector<HTTPCookie>::const_iterator const_cookie_iterator; | |
| | | | |
| | | // ============================================================ | |
| // Class CgiEnvironment | | // Class CgiEnvironment | |
| // ============================================================ | | // ============================================================ | |
|
| /** | | | |
| * Encapsulates all the data passed from the server to the application. | | /*! \class CgiEnvironment CgiEnvironment.h cgicc/CgiEnvironment.h | |
| * <P>To read in the environment, simply instantiate an object of this type | | * \brief Class encapsulating the CGI runtime environment | |
| . | | * | |
| * </P> | | * The \c CgiEnvironment class encapsulates the environment of | |
| | | * the CGI application as described by the HTTP server. \c CgiEnvironment | |
| | | * contains the \c GET or \c POST data along with all environment variables | |
| | | * set by the HTTP server specified in the CGI specification. | |
| */ | | */ | |
| class CGICC_API CgiEnvironment | | class CGICC_API CgiEnvironment | |
| { | | { | |
| public: | | public: | |
| | | | |
| friend class Cgicc; | | friend class Cgicc; | |
| | | | |
|
| /** Read in the environment */ | | // ============================================================ | |
| CgiEnvironment(); | | | |
| | | | |
|
| /** Destructor */ | | /*! \name Constructor and Destructor */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Read in the CGI environment passed to the CGI application | |
| | | * by the server | |
| | | * | |
| | | * This function is not usually called directly; instead, an object of ty | |
| | | pe | |
| | | * CgiEnvironment is retrieved by calling the \c getEnvironment() method | |
| | | * on Cgicc. | |
| | | * \param stream_reader \c 0 for \c cout, or a valid FastCGI reader funct | |
| | | ion | |
| | | * \see Cgicc::getEnvironment | |
| | | */ | |
| | | CgiEnvironment(reader_function_t stream_reader); | |
| | | | |
| | | /*! | |
| | | * \brief Destructor | |
| | | * | |
| | | * Delete this CgiEnvironment object | |
| | | */ | |
| ~CgiEnvironment(); | | ~CgiEnvironment(); | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Get the name and version of the http server software. | | | |
| * An example of this is Apache/1.3.4. | | /*! \name Server Information | |
| * @return The name of the server software | | * Information on the server handling the HTTP/CGI request | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Get the name and version of the HTTP server software | |
| | | * | |
| | | * For example, \c Apache/1.3.4 | |
| | | * \return The name of the server software | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getServerSoftware() const | | getServerSoftware() const | |
| { return fServerSoftware; } | | { return fServerSoftware; } | |
| | | | |
|
| /** | | /*! | |
| * Get the hostname, DNS name or IP address of the http server. | | * \brief Get the hostname, DNS name or IP address of the HTTP server | |
| * This is <EM>not</EM> a URL, for example www.gnu.org. | | * | |
| * @return The name of the server | | * This is \e not a URL, for example \c www.gnu.org (no leading http://) | |
| | | * \return The name of the server | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getServerName() const | | getServerName() const | |
| { return fServerName; } | | { return fServerName; } | |
| | | | |
|
| /** | | /*! | |
| * Get the name and version of the gateway interface. | | * \brief Get the name and version of the gateway interface. | |
| * This is usually CGI/1.1. | | * | |
| * @return The name and version of the gateway interface | | * This is usually \c CGI/1.1 | |
| | | * \return The name and version of the gateway interface | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getGatewayInterface() const | | getGatewayInterface() const | |
| { return fGatewayInterface;} | | { return fGatewayInterface;} | |
| | | | |
|
| /** | | /*! | |
| * Get the name and revision of the protocol used for this request. | | * \brief Get the name and revision of the protocol used for this request | |
| * This is usually HTTP/1.0. | | . | |
| * @return The protocol in use | | * | |
| | | * This is usually \c HTTP/1.0 or \c HTTP/1.1 | |
| | | * \return The protocol in use | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getServerProtocol() const | | getServerProtocol() const | |
| { return fServerProtocol; } | | { return fServerProtocol; } | |
| | | | |
|
| /** | | /*! | |
| * Get the port number on the server to which this request was sent. | | * \brief Get the port number on the server to which this request was sen | |
| | | t. | |
| | | * | |
| * This will usually be 80. | | * This will usually be 80. | |
|
| * @return The port number | | * \return The port number | |
| */ | | */ | |
| inline unsigned long | | inline unsigned long | |
| getServerPort() const | | getServerPort() const | |
| { return fServerPort; } | | { return fServerPort; } | |
| | | | |
|
| /** | | /*! | |
| * Get the HTTP cookies associated with this query, if any. | | * \brief Determine if this is a secure request | |
| * @return The HTTP cookies | | * | |
| | | * A secure request is usually made using SSL via HTTPS | |
| | | * \return \c true if this connection is via https, \c false otherwise | |
| | | */ | |
| | | inline bool | |
| | | usingHTTPS() const | |
| | | { return fUsingHTTPS; } | |
| | | //@} | |
| | | | |
| | | // ============================================================ | |
| | | | |
| | | /*! \name CGI Query Information | |
| | | * Information specific to this CGI query | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Get the HTTP cookies associated with this query, if any. | |
| | | * | |
| | | * The string returned by this method may contain multiple cookies; it is | |
| | | * recommended to use the method getCookieList() instead, which returns | |
| | | * a \c vector<HTTPCookie>. | |
| | | * \return The HTTP cookies | |
| | | * \see getCookieList | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getCookies() const | | getCookies() const | |
| { return fCookie; } | | { return fCookie; } | |
| | | | |
|
| /** | | /*! | |
| * Get a vector containing the HTTP cookies associated with this query. | | * \brief Get a \c vector containing the HTTP cookies | |
| * @return A vector containing the HTTP cookies associated with this quer | | * associated with this query | |
| y. | | * | |
| * @see HTTPCookie | | * This vector may be empty | |
| | | * \return A \c vector containing the HTTP cookies associated with this | |
| | | * query | |
| | | * \see HTTPCookie | |
| */ | | */ | |
| inline const STDNS vector<HTTPCookie>& | | inline const STDNS vector<HTTPCookie>& | |
| getCookieList() const | | getCookieList() const | |
| { return fCookies; } | | { return fCookies; } | |
| | | | |
|
| /** | | /*! | |
| * Get the request method used for this query. | | * \brief Get the request method used for this query. | |
| * This is usually one of GET or POST. | | * | |
| * @return The request method | | * This is usually one of \c GET or \c POST | |
| | | * \return The request method | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRequestMethod() const | | getRequestMethod() const | |
| { return fRequestMethod; } | | { return fRequestMethod; } | |
| | | | |
|
| /** | | /*! | |
| * Get the extra path information for this request, given by the client. | | * \brief Get the extra path information for this request, given by the | |
| * @return The absolute path info | | * client. | |
| | | * | |
| | | * For example, in the string \c foo.cgi/cgicc the path information is | |
| | | * \c cgicc. | |
| | | * \return The absolute path info | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getPathInfo() const | | getPathInfo() const | |
| { return fPathInfo; } | | { return fPathInfo; } | |
| | | | |
|
| /** | | /*! | |
| * Get the translated path information (virtual to physical mapping). | | * \brief Get the translated path information (virtual to physical mappin | |
| * @return The translated path info | | g). | |
| | | * | |
| | | * For example, \c www.gnu.org may be translated to \c /htdocs/index.html | |
| | | * \return The translated path info | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getPathTranslated() const | | getPathTranslated() const | |
| { return fPathTranslated; } | | { return fPathTranslated; } | |
| | | | |
|
| /** | | /*! | |
| * Get the path to this application, for self-referencing URLs. | | * \brief Get the full path to this CGI application | |
| * @return The name of this application | | * | |
| | | * This is useful for self-referencing URIs | |
| | | * \return The full path of this application | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getScriptName() const | | getScriptName() const | |
| { return fScriptName; } | | { return fScriptName; } | |
| | | | |
|
| /** | | /*! | |
| * Get string following the ? in the URL which called this application. | | * \brief Get the query string for this request. | |
| * This is usually only valid for scripts called with the GET method. | | * | |
| | | * The query string follows the <TT>?</TT> in the URI which called this | |
| | | * application. This is usually only valid for scripts called with | |
| | | * the \c GET method. For example, in the string \c foo.cgi?cgicc=yes | |
| | | * the query string is \c cgicc=yes. | |
| * @return The query string | | * @return The query string | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getQueryString() const | | getQueryString() const | |
| { return fQueryString; } | | { return fQueryString; } | |
| | | | |
|
| /** | | /*! | |
| * Get the length of the data read from standard in, in chars. | | * \brief Get the length of the data read from standard input, in chars. | |
| * @return The data length | | * | |
| | | * This is usually only valid for scripts called with the POST method. | |
| | | * \return The data length | |
| */ | | */ | |
| inline unsigned long | | inline unsigned long | |
| getContentLength() const | | getContentLength() const | |
| { return fContentLength; } | | { return fContentLength; } | |
| | | | |
|
| /** | | /*! | |
| * Get the content type of the attached information. | | * \brief Get the content type of the submitted information. | |
| * For POST methods, this is usually application/x-www-form-urlencoded. | | * | |
| * @return The content type | | * For applications called via the GET method, this information is | |
| | | * irrelevant. For applications called with the POST method, this is | |
| | | * specifies the MIME type of the information, | |
| | | * usually \c application/x-www-form-urlencoded or as specified by | |
| | | * getContentType(). | |
| | | * \return The content type | |
| | | * \see getContentType | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getContentType() const | | getContentType() const | |
| { return fContentType; } | | { return fContentType; } | |
| | | | |
|
| /** | | /*! | |
| * Get the data passed via standard input. | | * \brief Get the data passed to the CGI application via standard input. | |
| * This data is of MIME type getContentType(). | | * | |
| * @return The post data. | | * This data is of MIME type \c getContentType(). | |
| | | * \return The post data. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getPostData() const | | getPostData() const | |
| { return fPostData; } | | { return fPostData; } | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Get the page which called this application. | | | |
| * Depending on the http server software, this may not be set. | | /*! \name Server Specific Information | |
| * @return The URL which called this application. | | * Information dependent on the type of HTTP server in use | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Get the URL of the page which called this CGI application. | |
| | | * | |
| | | * Depending on the HTTP server software, this value may not be set. | |
| | | * \return The URI which called this application. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getReferrer() const | | getReferrer() const | |
| { return fReferrer; } | | { return fReferrer; } | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Get the hostname making this request. | | | |
| * @return The remote host | | /*! \name Remote User Information | |
| | | * Information about the user making the CGI request | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Get the hostname of the remote machine making this request | |
| | | * | |
| | | * This may be either an IP address or a hostname | |
| | | * \return The remote host | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRemoteHost() const | | getRemoteHost() const | |
| { return fRemoteHost; } | | { return fRemoteHost; } | |
| | | | |
|
| /** | | /*! | |
| * Get the IP address of the remote host making this request. | | * \brief Get the IP address of the remote machine making this request | |
| * @return The remote IP address | | * | |
| | | * This is a standard IP address of the form \c 123.123.123.123 | |
| | | * \return The remote IP address | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRemoteAddr() const | | getRemoteAddr() const | |
| { return fRemoteAddr; } | | { return fRemoteAddr; } | |
| | | | |
|
| /** | | /*! | |
| * Get the protocol-specific user authentication method used. | | * \brief Get the protocol-specific user authentication method used. | |
| | | * | |
| * This is only applicable if the server supports user authentication, | | * This is only applicable if the server supports user authentication, | |
| * and the user has authenticated. | | * and the user has authenticated. | |
|
| * @return The authorization type | | * \return The authorization type | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getAuthType() const | | getAuthType() const | |
| { return fAuthType; } | | { return fAuthType; } | |
| | | | |
|
| /** | | /*! | |
| * Get the authenticated remote user name. | | * \brief Get the authenticated remote user name. | |
| | | * | |
| * This is only applicable if the server supports user authentication, | | * This is only applicable if the server supports user authentication, | |
| * and the user has authenticated. | | * and the user has authenticated. | |
|
| * @return The remote username | | * \return The remote username | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRemoteUser() const | | getRemoteUser() const | |
| { return fRemoteUser; } | | { return fRemoteUser; } | |
| | | | |
|
| /** | | /*! | |
| * Get the remote user name retrieved from the server. | | * \brief Get the remote user name retrieved from the server. | |
| | | * | |
| * This is only applicable if the server supports RFC 931 | | * This is only applicable if the server supports RFC 931 | |
|
| * identification. This variable should <EM>only</EM> be used | | * identification. This variable should \e only be used | |
| * for logging. | | * for logging purposes. | |
| * @return The remote identification | | * \return The remote identification | |
| | | * \see RFC 1431 at | |
| | | * http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1413.txt | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRemoteIdent() const | | getRemoteIdent() const | |
| { return fRemoteIdent; } | | { return fRemoteIdent; } | |
| | | | |
|
| /** | | /*! | |
| * Get the MIME data types accepted by the client's browser. | | * \brief Get the MIME data types accepted by the client's browser. | |
| * For example image/gif, image/x-xbitmap, image/jpeg, image/pjpeg. | | * | |
| * @return The accepted data types | | * For example <TT>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg</T | |
| | | T> | |
| | | * \return The accepted data types | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getAccept() const | | getAccept() const | |
| { return fAccept; } | | { return fAccept; } | |
| | | | |
|
| /** | | /*! | |
| * Get the name of the browser used for this CGI request. | | * \brief Get the name of the browser used for this CGI request. | |
| * For example Mozilla/4.01 [en] (WinNT; U). | | * | |
| * @return The browser name | | * For example <TT>Mozilla/5.0 (X11; U; Linux 2.4.0 i686; en-US; 0.8.1) | |
| | | * Gecko/20010421</TT> | |
| | | * \return The browser name | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getUserAgent() const | | getUserAgent() const | |
| { return fUserAgent; } | | { return fUserAgent; } | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Determine whether this is a secure request (using https). | | | |
| * @return true if this connection is via https | | /*! \name ErrorDocument Handling | |
| | | * For a tutorial on ErrorDocument handling, see | |
| | | * http://hoohoo.ncsa.uiuc.edu/cgi/ErrorCGI.html | |
| */ | | */ | |
|
| inline bool | | //@{ | |
| usingHTTPS() const | | | |
| { return (getenv("HTTPS") != 0); } | | | |
| | | | |
|
| /** | | /*! | |
| * Get the redirect request. | | * \brief Get the redirect request. | |
| | | * | |
| * This will only be valid if you are using this script as a script | | * This will only be valid if you are using this script as a script | |
| * to use in place of the default server messages. | | * to use in place of the default server messages. | |
| * @return The redirect request. | | * @return The redirect request. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRedirectRequest() const | | getRedirectRequest() const | |
| { return fRedirectRequest; } | | { return fRedirectRequest; } | |
| | | | |
|
| /** | | /*! | |
| * Get the redirect URL. | | * \brief Get the redirect URL. | |
| | | * | |
| * This will only be valid if you are using this script as a script | | * This will only be valid if you are using this script as a script | |
| * to use in place of the default server messages. | | * to use in place of the default server messages. | |
|
| * @return The redirect URL. | | * \return The redirect URL. | |
| * @see \URL{http://hoohoo.ncsa.uiuc.edu/docs/setup/srm/ErrorDocument.htm | | * \see \URL{http://hoohoo.ncsa.uiuc.edu/docs/setup/srm/ErrorDocument.htm | |
| l} | | l} | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRedirectURL() const | | getRedirectURL() const | |
| { return fRedirectURL; } | | { return fRedirectURL; } | |
| | | | |
|
| /** | | /*! | |
| * Get the redirect status. | | * \brief Get the redirect status. | |
| | | * | |
| * This will only be valid if you are using this script as a script | | * This will only be valid if you are using this script as a script | |
| * to use in place of the default server messages. | | * to use in place of the default server messages. | |
|
| * @return The redirect status. | | * \return The redirect status. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getRedirectStatus() const | | getRedirectStatus() const | |
| { return fRedirectStatus; } | | { return fRedirectStatus; } | |
|
| | | //@} | |
| | | | |
| protected: | | protected: | |
| | | | |
|
| // Implementation of save | | // ============================================================ | |
| | | | |
| | | /*! \name Saving and Restoring | |
| | | * These are implementation methods only | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Implementation of save, for saving CGI environments | |
| | | * | |
| | | * This is called internally by Cgicc | |
| | | * \param filename The name of the file to which to save | |
| | | */ | |
| void | | void | |
| save(const STDNS string& filename) const; | | save(const STDNS string& filename) const; | |
| | | | |
|
| | | /*! | |
| | | * \brief Implementation of restore, for restoring CGI environments | |
| | | * | |
| | | * This is called internally by Cgicc | |
| | | * \param filename The name of the file from which to restore | |
| | | */ | |
| // Implementation of restore | | // Implementation of restore | |
| void | | void | |
| restore(const STDNS string& filename); | | restore(const STDNS string& filename); | |
|
| | | //@} | |
| | | | |
| | | // ============================================================ | |
| | | | |
| private: | | private: | |
| | | | |
| // Parse the list of cookies from a string to a vector | | // Parse the list of cookies from a string to a vector | |
| void | | void | |
| parseCookies(); | | parseCookies(); | |
| | | | |
| // Parse a single cookie string (name=value) pair | | // Parse a single cookie string (name=value) pair | |
| void | | void | |
| parseCookie(const STDNS string& data); | | parseCookie(const STDNS string& data); | |
| | | | |
| // Read in all the environment variables | | // Read in all the environment variables | |
| void | | void | |
| readEnvironmentVariables(); | | readEnvironmentVariables(); | |
| | | | |
| unsigned long fServerPort; | | unsigned long fServerPort; | |
| unsigned long fContentLength; | | unsigned long fContentLength; | |
|
| | | bool fUsingHTTPS; | |
| STDNS string fServerSoftware; | | STDNS string fServerSoftware; | |
| STDNS string fServerName; | | STDNS string fServerName; | |
| STDNS string fGatewayInterface; | | STDNS string fGatewayInterface; | |
| STDNS string fServerProtocol; | | STDNS string fServerProtocol; | |
| STDNS string fRequestMethod; | | STDNS string fRequestMethod; | |
| STDNS string fPathInfo; | | STDNS string fPathInfo; | |
| STDNS string fPathTranslated; | | STDNS string fPathTranslated; | |
| STDNS string fScriptName; | | STDNS string fScriptName; | |
| STDNS string fQueryString; | | STDNS string fQueryString; | |
| STDNS string fRemoteHost; | | STDNS string fRemoteHost; | |
| | | | |
End of changes. 57 change blocks. |
| 121 lines changed or deleted | | 286 lines changed or added | |
|
| CgiUtils.h | | CgiUtils.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: CgiUtils.h,v 1.2 1999/08/09 23:03:41 sbooth Exp $ | | * $Id: CgiUtils.h,v 1.4 2001/09/03 16:19:51 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _CGIUTILS_H_ | | #ifndef _CGIUTILS_H_ | |
| #define _CGIUTILS_H_ 1 | | #define _CGIUTILS_H_ 1 | |
| | | | |
| #ifdef __GNUG__ | | #ifdef __GNUG__ | |
| # pragma interface | | # pragma interface | |
| #endif | | #endif | |
| | | | |
|
| | | /*! \file CgiUtils.h | |
| | | * \brief A collection of utility functions. | |
| | | * | |
| | | * These utility functions are used internally by cgicc to | |
| | | * decode posted form data, and to read/write from streams. | |
| | | */ | |
| | | | |
| #include <new> | | #include <new> | |
| #include <string> | | #include <string> | |
| #include <fstream> | | #include <fstream> | |
| | | | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/CgiDefs.h" | |
| | | | |
| #if DEBUG | | #if DEBUG | |
| | | | |
|
| extern ofstream gLogFile; | | extern STDNS ofstream gLogFile; | |
| #define LOGLN(s) gLogFile << s << endl; | | #define LOGLN(s) gLogFile << s << STDNS endl; | |
| #define LOG(s) gLogFile << s; | | #define LOG(s) gLogFile << s; | |
| | | | |
| #else | | #else | |
| | | | |
|
| /** | | /*! | |
| * Output a string to the debugging log, followed by a newline. | | * \brief Output a string to the debugging log, followed by a newline. | |
| * <P>The debugging log is a user-specified ostream.</P> | | * | |
| * @param s The string to log | | * The debugging log is a user-specified \c ostream. | |
| | | * \param s The string to log | |
| */ | | */ | |
| #define LOGLN(s) | | #define LOGLN(s) | |
| | | | |
|
| /** | | /*! | |
| * Output a string to the debugging log. | | * \brief Output a string to the debugging log | |
| * <P>The debugging log is a user-specified ostream.</P> | | * | |
| * @param s The string to log | | * The debugging log is a user-specified \c ostream. | |
| | | * \param s The string to log | |
| */ | | */ | |
| #define LOG(s) | | #define LOG(s) | |
| | | | |
| #endif | | #endif | |
| | | | |
| CGICC_BEGIN_NAMESPACE | | CGICC_BEGIN_NAMESPACE | |
| | | | |
|
| /** | | /*! | |
| * Query the value of an environment variable. | | * \brief Query the value of an environment variable | |
| * This function never returns null. | | * | |
| * @param varName The name of an environment variable | | * This function is used internally by CgiEnvironment | |
| * @return The value of the requested environment variable, or an empty | | * \param varName The name of an environment variable | |
| | | * \return The value of the requested environment variable, or an empty | |
| * string if not found. | | * string if not found. | |
| */ | | */ | |
| CGICC_API STDNS string | | CGICC_API STDNS string | |
| safeGetenv(const char *varName); | | safeGetenv(const char *varName); | |
| | | | |
|
| /* | | /*! | |
| * Compare two strings for equality, ignoring case. | | * \brief Compare two strings for equality, ignoring case. | |
| | | * | |
| * For case-sensitive comparison, use (s1 == s2); | | * For case-sensitive comparison, use (s1 == s2); | |
|
| * @param s1 The first string to compare | | * \param s1 The first string to compare | |
| * @param s2 The second string to compare | | * \param s2 The second string to compare | |
| * @return True if the strings are equal, false if they are not | | * \return \c true if the strings are equal, \c false if they are not | |
| */ | | */ | |
| CGICC_API bool | | CGICC_API bool | |
| stringsAreEqual(const STDNS string& s1, | | stringsAreEqual(const STDNS string& s1, | |
| const STDNS string& s2); | | const STDNS string& s2); | |
| | | | |
|
| /* | | /*! | |
| * Compare two strings for equality, ignoring case. | | * \brief Compare two strings for equality, ignoring case. | |
| | | * | |
| * For case-sensitive comparison, use (s1 == s2); | | * For case-sensitive comparison, use (s1 == s2); | |
|
| * @param s1 The first string to compare | | * \param s1 The first string to compare | |
| * @param s2 The second string to compare | | * \param s2 The second string to compare | |
| * @param n The number of characters to compare. | | * \param n The number of characters to compare. | |
| * @return True if the strings are equal, false if they are not | | * \return \c true if the strings are equal, \c false if they are not | |
| */ | | */ | |
| CGICC_API bool | | CGICC_API bool | |
| stringsAreEqual(const STDNS string& s1, | | stringsAreEqual(const STDNS string& s1, | |
| const STDNS string& s2, | | const STDNS string& s2, | |
| size_t n); | | size_t n); | |
| | | | |
|
| /** | | /*! | |
| * A safer alternative to system(). | | * \brief A safer alternative to system(). | |
| * <P>This command will escape out (by prepending \) all semicolons, pipes | | * | |
| * and redirects (;|<>) present in the command string.</P> | | * This command will escape out (by prepending \) all semicolons, pipes | |
| * @param command The command to be sanitized and run | | * and redirects (;|<>) present in the command string. | |
| * @return The result of running the sanitized version of <EM>command</EM> | | * \param command The command to be sanitized and run | |
| | | * \return The result of running the sanitized version of \e command | |
| */ | | */ | |
| CGICC_API int | | CGICC_API int | |
| saferSystem(const STDNS string& command); | | saferSystem(const STDNS string& command); | |
| | | | |
|
| /** | | /*! | |
| * Convert encoded characters in form data to normal ASCII. | | * \brief Convert encoded characters in form data to normal ASCII. | |
| * <P>For example, %21 is converted to ! and + is converted to a space. | | * | |
| | | * For example, %21 is converted to ! and + is converted to a space. | |
| * Normally, this is called internally to decode the query string or post | | * Normally, this is called internally to decode the query string or post | |
|
| * data.</P> | | * data. | |
| * @param src The src string containing the encoded characters | | * \param src The src string containing the encoded characters | |
| * @return The converted string | | * \return The converted string | |
| */ | | */ | |
| CGICC_API STDNS string | | CGICC_API STDNS string | |
| unescapeString(const STDNS string& src); | | unescapeString(const STDNS string& src); | |
| | | | |
|
| /** | | /*! | |
| * Convert a hex-encoded character to its ASCII equivalent. | | * \brief Convert a hex-encoded character to its ASCII equivalent. | |
| * <P>For example, after the call | | * | |
| * <PRE class="code"> | | * For example, after the call | |
| * . char c = hexToChar('2', '1'); | | * \code | |
| * </PRE> | | * char c = hexToChar('2', '1'); | |
| * <TT>c</TT> will have a value of '!'.</P> | | * \endcode | |
| * <P>Normally, this is called internally to decode encoded characters in | | * \c c will have a value of '!'. | |
| * the query string or post data.</P> | | * Normally, this is called internally to decode encoded characters in | |
| * @param first The first character of the hex value | | * the query string or post data. | |
| * @param second the second character of the hex value | | * \param first The first character of the hex value | |
| * @return The ASCII character | | * \param second the second character of the hex value | |
| | | * \return The ASCII character | |
| */ | | */ | |
| CGICC_API char | | CGICC_API char | |
| hexToChar(char first, | | hexToChar(char first, | |
| char second); | | char second); | |
| | | | |
|
| /** | | /*! | |
| * Extract a substring contained within two separators. | | * \brief Extract a substring contained within two separators. | |
| * <P>For example, after the call | | | |
| * <PRE class="code"> | | | |
| * STDNS string data = "11foo22"; | | | |
| * | | * | |
|
| | | * For example, after the call | |
| | | * \code | |
| | | * STDNS string data = "11foo22"; | |
| * STDNS string res; | | * STDNS string res; | |
| * res = extractBetween(data, "11", "22"); | | * res = extractBetween(data, "11", "22"); | |
|
| * </PRE> | | * \endcode | |
| * <TT>res</TT> will be "foo". | | * \c res will be "foo". | |
| * @param data The data to search. | | * \param data The data to search. | |
| * @param separator1 The first logical separator. | | * \param separator1 The first logical separator. | |
| * @param separator2 The second logical separator. | | * \param separator2 The second logical separator. | |
| * return The substring between the separators. | | * \return The substring between the separators. | |
| */ | | */ | |
| STDNS string | | STDNS string | |
| extractBetween(const STDNS string& data, | | extractBetween(const STDNS string& data, | |
| const STDNS string& separator1, | | const STDNS string& separator1, | |
| const STDNS string& separator2); | | const STDNS string& separator2); | |
| | | | |
|
| /** | | /*! | |
| * Extract a substring contained between a separator. | | * \brief Extract a substring contained between a separator. | |
| * @param data The data to search. | | * | |
| * @param separator The separator. | | * This function is used internally to decode \c multipart/form-data | |
| * return The substring between the separator. | | * \param data The data to search. | |
| | | * \param separator The separator. | |
| | | * \return The substring between the separator. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| extractBetween(const STDNS string& data, | | extractBetween(const STDNS string& data, | |
| const STDNS string& separator) | | const STDNS string& separator) | |
| { return extractBetween(data, separator, separator); } | | { return extractBetween(data, separator, separator); } | |
| | | | |
|
| /** | | /*! | |
| * Write a string to an ostream. | | * \brief Write a string to an ostream. | |
| * <P>This function is used internally by Cgicc for saving environments.</P | | * | |
| > | | * This function is used internally for saving environments. | |
| * @param out The ostream to which to write. | | * \param out The ostream to which to write. | |
| * @param s The string to write. | | * \param s The string to write. | |
| */ | | */ | |
| void | | void | |
| writeString(STDNS ostream& out, | | writeString(STDNS ostream& out, | |
| const STDNS string& s); | | const STDNS string& s); | |
| | | | |
|
| /** | | /*! | |
| * Write a long to an ostream. | | * \brief Write a long to an ostream. | |
| * <P>This function is used internally by Cgicc for saving environments.</P | | * | |
| > | | * This function is used internally for saving environments. | |
| * @param out The ostream to which to write. | | * \param out The ostream to which to write. | |
| * @param l The long to write. | | * \param l The long to write. | |
| */ | | */ | |
| void | | void | |
| writeLong(STDNS ostream& out, | | writeLong(STDNS ostream& out, | |
| unsigned long l); | | unsigned long l); | |
| | | | |
|
| /** | | /*! | |
| * Read a string from an istream. | | * \brief Read a string from an istream. | |
| * <P>This function is used internally by Cgicc for restoring | | * | |
| * environments.</P> | | * This function is used internally by cgicc for restoring environments. | |
| * @param in The istream from which to read. | | * \param in The istream from which to read. | |
| * @return The string read. | | * \return The string read. | |
| */ | | */ | |
| STDNS string | | STDNS string | |
| readString(STDNS istream& in); | | readString(STDNS istream& in); | |
| | | | |
|
| /** | | /*! | |
| * Read a long from an istream. | | * \brief Read a long from an istream. | |
| * <P>This function is used internally by Cgicc for restoring | | * | |
| * environments.</P> | | * This function is used internally by cgicc for restoring environments. | |
| * @param in The istream from which to read. | | * \param in The istream from which to read. | |
| * @return The long read. | | * \return The long read. | |
| */ | | */ | |
| unsigned long | | unsigned long | |
| readLong(STDNS istream& in); | | readLong(STDNS istream& in); | |
| | | | |
| CGICC_END_NAMESPACE | | CGICC_END_NAMESPACE | |
| | | | |
| #endif /* ! _CGIUTILS_H_ */ | | #endif /* ! _CGIUTILS_H_ */ | |
| | | | |
End of changes. 27 change blocks. |
| 101 lines changed or deleted | | 118 lines changed or added | |
|
| Cgicc.h | | Cgicc.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: Cgicc.h,v 1.5 1999/09/30 17:38:19 sbooth Exp $ | | * $Id: Cgicc.h,v 1.7 2001/09/02 19:53:17 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _CGICC_H_ | | #ifndef _CGICC_H_ | |
| #define _CGICC_H_ 1 | | #define _CGICC_H_ 1 | |
| | | | |
| #ifdef __GNUG__ | | #ifdef __GNUG__ | |
| # pragma interface | | # pragma interface | |
| #endif | | #endif | |
| | | | |
|
| | | /*! \file Cgicc.h | |
| | | * The main header file for the GNU cgicc library | |
| | | */ | |
| | | | |
| /* | | /* | |
|
| * The GNU Cgicc library, by Stephen F. Booth. | | * The GNU cgicc library, by Stephen F. Booth <sbooth@gnu.org> | |
| * | | * | |
| * The latest version can be found on your closest GNU mirror site. | | * The latest version can be found on your closest GNU mirror site. | |
|
| * | | * Please mail bug reports to <bug-cgicc@gnu.org> | |
| * Please mail bug reports to <mailto:bug-cgicc@gnu.org> | | | |
| * | | | |
| * To subscribe, send a message to <mailto:bug-cgicc-request@gnu.org> | | | |
| * with the word "subscribe" in the subject field. | | | |
| * | | | |
| * Cgicc is intended to simplify and speed the development of C++ | | | |
| * CGI(Common Gateway Interface) applications by providing a simple, | | | |
| * yet comprehensive set of classes that present full CGI | | | |
| * functionality. | | | |
| */ | | */ | |
| | | | |
| #include <vector> | | #include <vector> | |
| #include <string> | | #include <string> | |
| | | | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/CgiDefs.h" | |
| #include "cgicc/FormEntry.h" | | #include "cgicc/FormEntry.h" | |
| #include "cgicc/FormFile.h" | | #include "cgicc/FormFile.h" | |
| #include "cgicc/CgiEnvironment.h" | | #include "cgicc/CgiEnvironment.h" | |
| | | | |
| | | | |
| skipping to change at line 65 | | skipping to change at line 60 | |
| #ifdef WIN32 | | #ifdef WIN32 | |
| template class CGICC_API STDNS vector<FormEntry>; | | template class CGICC_API STDNS vector<FormEntry>; | |
| template class CGICC_API STDNS vector<FormFile>; | | template class CGICC_API STDNS vector<FormFile>; | |
| #endif | | #endif | |
| | | | |
| class MultipartHeader; | | class MultipartHeader; | |
| | | | |
| // ============================================================ | | // ============================================================ | |
| // Iterator typedefs | | // Iterator typedefs | |
| // ============================================================ | | // ============================================================ | |
|
| | | | |
| | | //! A vector of FormEntry objects | |
| typedef STDNS vector<FormEntry>::iterator form_iterator; | | typedef STDNS vector<FormEntry>::iterator form_iterator; | |
|
| | | //! A vector of \c const FormEntry objects | |
| typedef STDNS vector<FormEntry>::const_iterator const_form_iterator; | | typedef STDNS vector<FormEntry>::const_iterator const_form_iterator; | |
| | | | |
|
| | | //! A vector of FormFile objects | |
| typedef STDNS vector<FormFile>::iterator file_iterator; | | typedef STDNS vector<FormFile>::iterator file_iterator; | |
|
| | | //! A vector of \c const FormFile objects | |
| typedef STDNS vector<FormFile>::const_iterator const_file_iterator; | | typedef STDNS vector<FormFile>::const_iterator const_file_iterator; | |
| | | | |
| // ============================================================ | | // ============================================================ | |
| // Class Cgicc | | // Class Cgicc | |
| // ============================================================ | | // ============================================================ | |
|
| /** | | | |
| * Cgicc is the main class of the Cgicc library. | | /*! \class Cgicc Cgicc.h cgicc/Cgicc.h | |
| * <P>Normally, you will instantiate an object of this type in | | * \brief The main class of the GNU %cgicc library | |
| * <TT>main()</TT>:</P> | | * | |
| * <PRE CLASS="code"> | | * Cgicc is used to retrieve information on specific HTML form elements | |
| | | * (such as checkboxes, radio buttons, and text fields), on uploaded files, | |
| | | * and to save, restore, and retrieve information on the CGI | |
| | | * environment. | |
| | | * | |
| | | * Normally, you will instantiate an object of this type in | |
| | | * \c main(): | |
| | | * \code | |
| * int | | * int | |
| * main(int argc, char **argv) { | | * main(int argc, char **argv) { | |
| * try { | | * try { | |
|
| * Cgicc cgi; | | * cgicc::Cgicc cgi; | |
| * <SPAN CLASS="green">\\ do something with cgi</SPAN> | | * // do something with cgi | |
| * } | | * } | |
| * | | * | |
| * catch(const exception& e) { | | * catch(const exception& e) { | |
|
| * <SPAN CLASS="green"> \\ handle the error</SPAN> | | * //handle the error | |
| * } | | * } | |
| * } | | * } | |
|
| * </PRE> | | * \endcode | |
| */ | | */ | |
| class CGICC_API Cgicc { | | class CGICC_API Cgicc { | |
| public: | | public: | |
| | | | |
|
| /** Constructor */ | | // ============================================================ | |
| Cgicc(); | | | |
| | | | |
|
| /** Destructor */ | | /*! \name Constructor and Destructor */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Constructor | |
| | | * | |
| | | * If you are using %cgicc with FastCGI, you will need to pass | |
| | | * a \c reader_function_t that %cgicc will use to read input. If | |
| | | * \c stream_reader is omitted or \c NULL, standard input will be used. | |
| | | * \param stream_reader A reader_function_t to use for reading input | |
| | | */ | |
| | | Cgicc(reader_function_t stream_reader = NULL); | |
| | | | |
| | | /*! | |
| | | * \brief Destructor | |
| | | * | |
| | | * Delete this Cgicc object | |
| | | */ | |
| ~Cgicc(); | | ~Cgicc(); | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Get the date on which this library was compiled. | | | |
| * <P>This is a string of the form mmm dd yyyy.</P> | | /*! \name Library Information | |
| * @return The compile date | | * Information on this installation of %cgicc | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Get the date on which this library was compiled. | |
| | | * | |
| | | * This is a string of the form <TT>mmm dd yyyy</TT>. | |
| | | * \return The compile date | |
| */ | | */ | |
| const char* | | const char* | |
| getCompileDate() const; | | getCompileDate() const; | |
| | | | |
|
| /** | | /*! | |
| * Get the time at which this library was compiled. | | * \brief Get the time at which this library was compiled. | |
| * <P>This is a string of the form hh:mm:ss in 24-hour time.</P> | | * | |
| * @return The compile time | | * This is a string of the form \c hh:mm:ss in 24-hour time. | |
| | | * \return The compile time | |
| */ | | */ | |
| const char* | | const char* | |
| getCompileTime() const; | | getCompileTime() const; | |
| | | | |
|
| /** | | /*! | |
| * Get the version number of Cgicc. | | * \brief Get the version number of cgicc. | |
| * <P>The version number is a string of the form #.#.</P> | | * | |
| * @return The version number | | * The version number is a string of the form \c #.#. | |
| | | * \return The version number | |
| */ | | */ | |
| const char* | | const char* | |
| getVersion() const; | | getVersion() const; | |
| | | | |
|
| /** | | /*! | |
| * Get the platform for which Cgicc was configured. | | * \brief Get the platform for which Cgicc was configured. | |
| * <P>The host is a string of the form processor-manufacturer-os</P> | | * | |
| * @return The host triplet. | | * The host is a string of the form \c processor-manufacturer-os | |
| | | * return The host triplet. | |
| */ | | */ | |
| const char* | | const char* | |
| getHost() const; | | getHost() const; | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Query whether a checkbox is checked. | | | |
| * @param elementName The name of the element to query | | /*! \name Form Element Access | |
| * @return True if the desired checkbox was checked, false if not | | * Information on submitted form elements | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Query whether a checkbox is checked. | |
| | | * | |
| | | * \param elementName The name of the element to query | |
| | | * \return \c true if the desired checkbox was checked, \c false if not | |
| */ | | */ | |
| bool | | bool | |
| queryCheckbox(const STDNS string& elementName) const; | | queryCheckbox(const STDNS string& elementName) const; | |
| | | | |
|
| /** | | /*! | |
| * Find a radio button in a radio group, or a selected list item. | | * \brief Find a radio button in a radio group, or a selected list item. | |
| * @param name The name of the radio button or list item to find. | | * | |
| * @return An iterator referring to the desired element, if found. | | * \param name The name of the radio button or list item to find. | |
| | | * \return An iterator referring to the desired element, if found. | |
| */ | | */ | |
| inline form_iterator | | inline form_iterator | |
| operator[] (const STDNS string& name) | | operator[] (const STDNS string& name) | |
| { return getElement(name); } | | { return getElement(name); } | |
| | | | |
|
| /** | | /*! | |
| * Find a radio button in a radio group, or a selected list item. | | * \brief Find a radio button in a radio group, or a selected list item. | |
| * @param name The name of the radio button or list item to find. | | * | |
| * @return An iterator referring to the desired element, if found. | | * \param name The name of the radio button or list item to find. | |
| | | * \return An iterator referring to the desired element, if found. | |
| */ | | */ | |
| inline const_form_iterator | | inline const_form_iterator | |
| operator[] (const STDNS string& name) const | | operator[] (const STDNS string& name) const | |
| { return getElement(name); } | | { return getElement(name); } | |
| | | | |
|
| /** | | /*! | |
| * Find a radio button in a radio group, or a selected list item. | | * \brief Find a radio button in a radio group, or a selected list item. | |
| * @param name The name of the radio button or list item to find. | | * | |
| * @return An iterator referring to the desired element, if found. | | * \param name The name of the radio button or list item to find. | |
| | | * \return An iterator referring to the desired element, if found. | |
| */ | | */ | |
| form_iterator | | form_iterator | |
| getElement(const STDNS string& name); | | getElement(const STDNS string& name); | |
| | | | |
|
| /** | | /*! | |
| * Find a radio button in a radio group, or a selected list item. | | * \brief Find a radio button in a radio group, or a selected list item. | |
| * @param name The name of the radio button or list item to find. | | * | |
| * @return A const_iterator referring to the desired element, if found. | | * \param name The name of the radio button or list item to find. | |
| | | * \return A const_iterator referring to the desired element, if found. | |
| */ | | */ | |
| const_form_iterator | | const_form_iterator | |
| getElement(const STDNS string& name) const; | | getElement(const STDNS string& name) const; | |
| | | | |
|
| /** | | /*! | |
| * Find multiple checkboxes in a group or selected items in a list. | | * \brief Find multiple checkboxes in a group or selected items in a list | |
| * @param name The name of the checkboxes or list to find. | | . | |
| * @param result A vector to hold the result. | | * | |
| * @return true if any elements were found, false if not. | | * \param name The name of the checkboxes or list to find. | |
| | | * \param result A vector to hold the result. | |
| | | * \return \c true if any elements were found, \c false if not. | |
| */ | | */ | |
| bool | | bool | |
| getElement(const STDNS string& name, | | getElement(const STDNS string& name, | |
| STDNS vector<FormEntry>& result) const; | | STDNS vector<FormEntry>& result) const; | |
| | | | |
|
| /** | | /*! | |
| * Find a radio button in a radio group, or a selected list item. | | * \brief Find a radio button in a radio group, or a selected list item. | |
| * @param value The value of the radio button or list item to find. | | * | |
| * @return An iterator referring to the desired element, if found. | | * \param value The value of the radio button or list item to find. | |
| | | * \return An iterator referring to the desired element, if found. | |
| */ | | */ | |
| form_iterator | | form_iterator | |
| getElementByValue(const STDNS string& value); | | getElementByValue(const STDNS string& value); | |
| | | | |
|
| /** | | /*! | |
| * Find a radio button in a radio group, or a selected list item. | | * \brief Find a radio button in a radio group, or a selected list item. | |
| * @param value The value of the radio button or list item to find. | | * | |
| * @return A const_iterator referring to the desired element, if found. | | * \param value The value of the radio button or list item to find. | |
| | | * \return A const_iterator referring to the desired element, if found. | |
| */ | | */ | |
| const_form_iterator | | const_form_iterator | |
| getElementByValue(const STDNS string& value) const; | | getElementByValue(const STDNS string& value) const; | |
| | | | |
|
| /** | | /*! | |
| * Find multiple checkboxes in a group or selected items in a list. | | * \brief Find multiple checkboxes in a group or selected items in a list | |
| * @param value The value of the checkboxes or list to find. | | . | |
| * @param result A vector to hold the result. | | * | |
| * @return true if any elements were found, false if not. | | * \param value The value of the checkboxes or list to find. | |
| | | * \param result A vector to hold the result. | |
| | | * \return true if any elements were found, false if not. | |
| */ | | */ | |
| bool | | bool | |
| getElementByValue(const STDNS string& value, | | getElementByValue(const STDNS string& value, | |
| STDNS vector<FormEntry>& result) const; | | STDNS vector<FormEntry>& result) const; | |
| | | | |
|
| /** | | /*! | |
| * Get all the submitted form entries, excluding files. | | * \brief Get all the submitted form entries, excluding files. | |
| * @return A vector containing all the submitted elements. | | * | |
| | | * \return A vector containing all the submitted elements. | |
| */ | | */ | |
| inline const STDNS vector<FormEntry>& | | inline const STDNS vector<FormEntry>& | |
| operator* () const | | operator* () const | |
| { return fFormData; } | | { return fFormData; } | |
| | | | |
|
| /** | | /*! | |
| * Get all the submitted form elements, excluding files. | | * \brief Get all the submitted form elements, excluding files. | |
| * @return A vector containing all the submitted elements. | | * | |
| | | * \return A vector containing all the submitted elements. | |
| */ | | */ | |
| inline const STDNS vector<FormEntry>& | | inline const STDNS vector<FormEntry>& | |
| getElements() const | | getElements() const | |
| { return fFormData; } | | { return fFormData; } | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Find an uploaded file. | | | |
| * @param name The name of the file. | | /*! \name Uploaded File Access */ | |
| * @return An iterator referring to the desired file, if found. | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Find an uploaded file. | |
| | | * | |
| | | * \param name The name of the file. | |
| | | * \return An iterator referring to the desired file, if found. | |
| */ | | */ | |
| file_iterator | | file_iterator | |
| getFile(const STDNS string& name); | | getFile(const STDNS string& name); | |
| | | | |
|
| /** | | /*! | |
| * Find an uploaded file. | | * \brief Find an uploaded file. | |
| * @param name The name of the file. | | * | |
| * @return An iterator referring to the desired file, if found. | | * \param name The name of the file. | |
| | | * \return An iterator referring to the desired file, if found. | |
| */ | | */ | |
| const_file_iterator | | const_file_iterator | |
| getFile(const STDNS string& name) const; | | getFile(const STDNS string& name) const; | |
| | | | |
|
| /** | | /*! | |
| * Get all uploaded files. | | * Get all uploaded files. | |
|
| * @return A vector containing all the uploaded files. | | * \return A vector containing all the uploaded files. | |
| */ | | */ | |
| inline const STDNS vector<FormFile>& | | inline const STDNS vector<FormFile>& | |
| getFiles() const | | getFiles() const | |
| { return fFormFiles; } | | { return fFormFiles; } | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| | | | |
| | | /*! \name Environment Access */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| * Get the current runtime environment. | | * Get the current runtime environment. | |
|
| * @return The current CGI environment. | | * \return The current CGI environment. | |
| */ | | */ | |
| inline const CgiEnvironment& | | inline const CgiEnvironment& | |
| getEnvironment() const | | getEnvironment() const | |
| { return fEnvironment;} | | { return fEnvironment;} | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Save the current CGI environment to a file. | | | |
| * @param filename The name of the file to which to save. | | /*! \name Save and Restore */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Save the current CGI environment to a file. | |
| | | * | |
| | | * This is useful for debugging CGI applications. | |
| | | * \param filename The name of the file to which to save. | |
| */ | | */ | |
| void | | void | |
| save(const STDNS string& filename) const; | | save(const STDNS string& filename) const; | |
| | | | |
|
| /** | | /*! | |
| * Restore from a previously-saved CGI environment. | | * \brief Restore from a previously-saved CGI environment. | |
| * @param filename The name of the file from which to restore. | | * | |
| | | * This is useful for debugging CGI applications. | |
| | | * \param filename The name of the file from which to restore. | |
| */ | | */ | |
| void | | void | |
| restore(const STDNS string& filename); | | restore(const STDNS string& filename); | |
|
| | | //@} | |
| | | | |
| private: | | private: | |
| CgiEnvironment fEnvironment; | | CgiEnvironment fEnvironment; | |
| STDNS vector<FormEntry> fFormData; | | STDNS vector<FormEntry> fFormData; | |
| STDNS vector<FormFile> fFormFiles; | | STDNS vector<FormFile> fFormFiles; | |
| | | | |
| // Convert query string into a list of FormEntries | | // Convert query string into a list of FormEntries | |
| void | | void | |
| parseFormInput(const STDNS string& data); | | parseFormInput(const STDNS string& data); | |
| | | | |
| | | | |
End of changes. 48 change blocks. |
| 112 lines changed or deleted | | 193 lines changed or added | |
|
| FormEntry.h | | FormEntry.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: FormEntry.h,v 1.3 1999/08/16 17:40:04 sbooth Exp $ | | * $Id: FormEntry.h,v 1.4 2001/09/02 19:53:17 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _FORMENTRY_H_ | | #ifndef _FORMENTRY_H_ | |
| #define _FORMENTRY_H_ 1 | | #define _FORMENTRY_H_ 1 | |
| | | | |
| #ifdef __GNUG__ | | #ifdef __GNUG__ | |
| # pragma interface | | # pragma interface | |
| #endif | | #endif | |
| | | | |
|
| | | /*! \file FormEntry.h | |
| | | * \brief Class representing a single HTML form entry. | |
| | | * | |
| | | * FormEntry is an immutable class representing a single user entry | |
| | | * in an HTML form element such as a text field, radio button, or a | |
| | | * checkbox. A FormEntry is essentially a name/value pair, where the | |
| | | * name is the name of the form element as specified in the HTML form | |
| | | * itself, and the value is the user-entered or user-selected value. | |
| | | */ | |
| | | | |
| #include <iostream> | | #include <iostream> | |
| #include <string> | | #include <string> | |
| #include <climits> | | #include <climits> | |
| #include <cfloat> | | #include <cfloat> | |
| | | | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/CgiDefs.h" | |
| #include "cgicc/CgiUtils.h" | | #include "cgicc/CgiUtils.h" | |
| | | | |
| CGICC_BEGIN_NAMESPACE | | CGICC_BEGIN_NAMESPACE | |
| | | | |
|
| /** Immutable class representing a single HTML form entry (name/value pair) | | // ============================================================ | |
| . */ | | // Class FormEntry | |
| | | // ============================================================ | |
| | | | |
| | | /*! \class FormEntry FormEntry.h cgicc/FormEntry.h | |
| | | * \brief Class representing a single HTML form entry. | |
| | | * | |
| | | * FormEntry is an immutable class representing a single user entry | |
| | | * in an HTML form element such as a text field, radio button, or a | |
| | | * checkbox. A FormEntry is essentially a name/value pair, where the | |
| | | * name is the name of the form element as specified in the HTML form | |
| | | * itself, and the value is the user-entered or user-selected value. | |
| | | * | |
| | | * If a \c QUERY_STRING contained the fragment \c cgicc=yes the | |
| | | * corresponding FormEntry would have a name of \c cgicc and a value | |
| | | * of \c yes | |
| | | * | |
| | | * \sa FormFile | |
| | | */ | |
| class CGICC_API FormEntry | | class CGICC_API FormEntry | |
| { | | { | |
| public: | | public: | |
| | | | |
|
| /** | | // ============================================================ | |
| * Default constructor - shouldn't be used | | | |
| | | /*! \name Constructors and Destructor */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Default constructor | |
| | | * | |
| | | * Shouldn't be used. | |
| */ | | */ | |
| inline | | inline | |
| FormEntry() | | FormEntry() | |
| {} | | {} | |
| | | | |
|
| /** | | /*! | |
| * Create a new FormEntry | | * \brief Create a new FormEntry | |
| * @param name The name of the form element | | * | |
| * @param value The value of the form element | | * This is usually not called directly, but by Cgicc. | |
| | | * \param name The name of the form element | |
| | | * \param value The value of the form element | |
| */ | | */ | |
| inline | | inline | |
| FormEntry(const STDNS string& name, | | FormEntry(const STDNS string& name, | |
| const STDNS string& value) | | const STDNS string& value) | |
| : fName(name), fValue(value) | | : fName(name), fValue(value) | |
| {} | | {} | |
| | | | |
|
| /** | | /*! | |
| * Copy constructor. | | * \brief Copy constructor. | |
| * @param entry The FormEntry to copy. | | * | |
| | | * Sets the name and value of this FormEntry to those of \c entry. | |
| | | * \param entry The FormEntry to copy. | |
| */ | | */ | |
| inline | | inline | |
| FormEntry(const FormEntry& entry) | | FormEntry(const FormEntry& entry) | |
| { operator=(entry); } | | { operator=(entry); } | |
| | | | |
|
| /** Delete this FormEntry */ | | /*! | |
| | | * \brief Destructor. | |
| | | * | |
| | | * Delete this FormEntry object | |
| | | */ | |
| inline | | inline | |
| ~FormEntry() | | ~FormEntry() | |
| {} | | {} | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Compare two FormEntries for equality. | | | |
| * FormEntries are equal if they have the same name and value. | | /*! \name Overloaded Operators */ | |
| * @param entry The FormEntry to compare to this one. | | //@{ | |
| * @return true if the two FormEntries are equal, false otherwise. | | | |
| | | /*! | |
| | | * \brief Compare two FormEntrys for equality. | |
| | | * | |
| | | * FormEntrys are equal if they have the same name and value. | |
| | | * \param entry The FormEntry to compare to this one. | |
| | | * \return \c true if the two FormEntrys are equal, \c false otherwise. | |
| */ | | */ | |
| inline bool | | inline bool | |
| operator== (const FormEntry& entry) const | | operator== (const FormEntry& entry) const | |
| { return stringsAreEqual(fName, entry.fName); } | | { return stringsAreEqual(fName, entry.fName); } | |
| | | | |
|
| /** | | /*! | |
| * Compare two FormEntries for inequality. | | * \brief Compare two FormEntrys for inequality. | |
| * FormEntries are equal if they have the same name and value. | | * | |
| * @param entry The FormEntry to compare to this one. | | * FormEntrys are equal if they have the same name and value. | |
| * @return false if the two FormEntries are equal, true otherwise. | | * \param entry The FormEntry to compare to this one. | |
| | | * \return \c false if the two FormEntrys are equal, \c true otherwise. | |
| */ | | */ | |
| inline bool | | inline bool | |
| operator!= (const FormEntry& entry) const | | operator!= (const FormEntry& entry) const | |
| { return ! operator==(entry); } | | { return ! operator==(entry); } | |
| | | | |
| #ifdef WIN32 | | #ifdef WIN32 | |
|
| /** Dummy operator for MSVC++ */ | | /* Dummy operator for MSVC++ */ | |
| inline bool | | inline bool | |
| operator< (const FormEntry& entry) const | | operator< (const FormEntry& entry) const | |
| { return false; } | | { return false; } | |
| #endif | | #endif | |
| | | | |
|
| /** | | /*! | |
| * Assign one FormEntry to another. | | * \brief Assign one FormEntry to another. | |
| * @param entry The FormEntry to copy. | | * | |
| * @return A reference to this. | | * Sets the name and value of this FormEntry to those of \c entry. | |
| | | * \param entry The FormEntry to copy. | |
| | | * \return A reference to this. | |
| */ | | */ | |
| FormEntry& | | FormEntry& | |
| operator= (const FormEntry& entry); | | operator= (const FormEntry& entry); | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Get the name of the form element. | | | |
| * @return The name of the form element. | | /*! \name Accessor Methods | |
| | | * Information on the form element | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Get the name of the form element. | |
| | | * | |
| | | * The name of the form element is specified in the HTML form that | |
| | | * called the CGI application. | |
| | | * \return The name of the form element. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getName() const | | getName() const | |
| { return fName; } | | { return fName; } | |
| | | | |
|
| /** | | /*! | |
| * Get the value of the form element. | | * \brief Get the value of the form element as a string | |
| * The value may contain line breaks. | | * | |
| * @return The value of the form element. | | * The value returned may contain line breaks. | |
| | | * \return The value of the form element. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getValue() const | | getValue() const | |
| { return fValue; } | | { return fValue; } | |
| | | | |
|
| /** | | /*! | |
| * Get the value of the form element. | | * \brief Get the value of the form element as a string | |
| * The value may contain line breaks. | | * | |
| * @return The value of the form element. | | * The value returned may contain line breaks. | |
| | | * \return The value of the form element. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| operator* () const | | operator* () const | |
| { return getValue(); } | | { return getValue(); } | |
| | | | |
|
| /** | | /*! | |
| * Get the value of the form element, truncated to a specific length. | | * \brief Get the value of the form element as a string | |
| * The value may contain line breaks.<BR> | | * | |
| * <STRONG CLASS="red">It is the caller's responsibility to delete | | * The value returned will be truncated to a specific length. | |
| * <TT>value</TT> when it is no longer needed.</STRONG> | | * The value may contain line breaks. | |
| * @param maxChars The maximum number of characters to return. | | * \param maxChars The maximum number of characters to return. | |
| * @return The value of the form element, truncated to the specified len | | * \return The value of the form element, truncated to the specified len | |
| gth. | | gth. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getValue(STDNS string::size_type maxChars) const | | getValue(STDNS string::size_type maxChars) const | |
| { return makeString(maxChars, true); } | | { return makeString(maxChars, true); } | |
| | | | |
|
| /** | | /*! | |
| * Get the value of the form element, stripped of all line breaks. | | * \brief Get the value of the form element as a string | |
| * <BR><STRONG CLASS="red">It is the caller's responsibility to delete | | * | |
| * <TT>value</TT> when it is no longer needed.</STRONG> | | * The value returned will be stripped of all line breaks. | |
| * @return The value of the form element, stripped of all line breaks. | | * \return The value of the form element, stripped of all line breaks. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getStrippedValue() const | | getStrippedValue() const | |
| { return getStrippedValue(INT_MAX); } | | { return getStrippedValue(INT_MAX); } | |
| | | | |
|
| /** | | /*! | |
| * Get the value of the form element, stripped of all line breaks | | * \brief Get the value of the form element as a string | |
| | | * | |
| | | * The value returned will be stripped of all line breaks | |
| * and truncated to a specific length. | | * and truncated to a specific length. | |
|
| * <BR><STRONG CLASS="red">It is the caller's responsibility to delete | | * \param maxChars The maximum number of characters to return. | |
| * <TT>value</TT> when it is no longer needed.</STRONG> | | * \return The value of the form element, stripped of all line breaks and | |
| * @param maxChars The maximum number of characters to return. | | | |
| * @return The value of the form element, stripped of all line breaks and | | | |
| * truncated to the specified length. | | * truncated to the specified length. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getStrippedValue(STDNS string::size_type maxChars) const | | getStrippedValue(STDNS string::size_type maxChars) const | |
| { return makeString(maxChars, false); } | | { return makeString(maxChars, false); } | |
| | | | |
|
| /** | | /*! | |
| * Get the value of the form element as an integer. | | * \brief Get the value of the form element as an integer | |
| * @param min The minimum value to return (optional). | | * | |
| * @param max The maximum value to return (optional). | | * No syntax checking is performed on the string value. | |
| * @return The integer value of the form element. | | * \param min The minimum value to return (optional). | |
| | | * \param max The maximum value to return (optional). | |
| | | * \return The integer value of the form element. | |
| */ | | */ | |
| long | | long | |
| getIntegerValue(long min = LONG_MIN, | | getIntegerValue(long min = LONG_MIN, | |
| long max = LONG_MAX) const; | | long max = LONG_MAX) const; | |
| | | | |
|
| /** | | /*! | |
| * Get the value of the form element as a double. | | * \brief Get the value of the form element as a double | |
| * @param min The minimum value to return (optional). | | * | |
| * @param max The maximum value to return (optional). | | * No syntax checking is performed on the string value. | |
| * @return The double value of the form element. | | * \param min The minimum value to return (optional). | |
| | | * \param max The maximum value to return (optional). | |
| | | * \return The double value of the form element. | |
| */ | | */ | |
| double | | double | |
| getDoubleValue(double min = DBL_MIN, | | getDoubleValue(double min = DBL_MIN, | |
| double max = DBL_MAX) const; | | double max = DBL_MAX) const; | |
| | | | |
|
| /** | | /*! | |
| * Get the length of the value of the form element. | | * \brief Get the number of characters in the value of the form element. | |
| * @return The length of the value of the form element, in bytes. | | * | |
| | | * Note that a character may or may not equal one byte. | |
| | | * \return The length of the value of the form element | |
| */ | | */ | |
| inline STDNS string::size_type | | inline STDNS string::size_type | |
| length() const | | length() const | |
| { return fValue.length(); } | | { return fValue.length(); } | |
| | | | |
|
| /** | | /*! | |
| * Determine if this form element is empty (length() == 0). | | * \brief Determine if this form element is empty | |
| * @return True if this form element is empty, false otherwise. | | * | |
| | | * In an empty form element, length() == 0. | |
| | | * \return \c true if this form element is empty, \c false otherwise. | |
| */ | | */ | |
| inline bool | | inline bool | |
| isEmpty() const | | isEmpty() const | |
| { return (length() == 0); } | | { return (length() == 0); } | |
|
| | | //@} | |
| | | | |
| private: | | private: | |
| // utility function | | // utility function | |
| STDNS string | | STDNS string | |
| makeString(STDNS string::size_type maxLen, | | makeString(STDNS string::size_type maxLen, | |
| bool allowNewlines) const; | | bool allowNewlines) const; | |
| | | | |
| STDNS string fName; // the name of this form element | | STDNS string fName; // the name of this form element | |
| STDNS string fValue; // the value of this form element | | STDNS string fValue; // the value of this form element | |
| }; | | }; | |
| | | | |
End of changes. 30 change blocks. |
| 84 lines changed or deleted | | 158 lines changed or added | |
|
| FormFile.h | | FormFile.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: FormFile.h,v 1.3 1999/08/16 17:40:04 sbooth Exp $ | | * $Id: FormFile.h,v 1.5 2001/09/03 22:06:39 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _FORMFILE_H_ | | #ifndef _FORMFILE_H_ | |
| #define _FORMFILE_H_ 1 | | #define _FORMFILE_H_ 1 | |
| | | | |
| #ifdef __GNUG__ | | #ifdef __GNUG__ | |
| # pragma interface | | # pragma interface | |
| #endif | | #endif | |
| | | | |
|
| | | /*! \file FormFile.h | |
| | | * \brief Class representing a file submitted via an HTML form. | |
| | | * | |
| | | * FormFile is an immutable class reprenting a file uploaded via | |
| | | * the HTTP file upload mechanism. If you are going to use file upload | |
| | | * in your CGI application, remember to set the ENCTYPE of the form to | |
| | | * \c multipart/form-data. | |
| | | */ | |
| | | | |
| #include <iostream> | | #include <iostream> | |
| #include <string> | | #include <string> | |
| | | | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/CgiDefs.h" | |
| | | | |
| CGICC_BEGIN_NAMESPACE | | CGICC_BEGIN_NAMESPACE | |
| | | | |
|
| /** | | // ============================================================ | |
| * Immutable class representing a file uploaded via the HTTP file upload | | // Class FormFile | |
| * mechanism. | | // ============================================================ | |
| * <P>If you are going to use file upload, remember to set the | | | |
| * <TT>ENCTYPE</TT> of the form to <TT>multipart/form-data</TT>: | | /*! \class FormFile FormFile.h cgicc/FormFile.h | |
| * <PRE CLASS="html"> | | * \brief Class representing a file submitted via an HTML form. | |
| * <FORM METHOD="POST" ACTION="..." ENCTYPE="multipart/form-data"> | | * | |
| * </PRE> | | * FormFile is an immutable class reprenting a file uploaded via | |
| * </P> | | * the HTTP file upload mechanism. If you are going to use file upload | |
| | | * in your CGI application, remember to set the ENCTYPE of the form to | |
| | | * \c multipart/form-data. | |
| | | * \verbatim | |
| | | <form method="post" action="http://change_this_path/cgi-bin/upload.cgi" | |
| | | enctype="multipart/form-data"> | |
| | | \endverbatim | |
| | | * \sa FormEntry | |
| */ | | */ | |
| class CGICC_API FormFile | | class CGICC_API FormFile | |
| { | | { | |
| public: | | public: | |
| | | | |
|
| /** Default constructor - shouldn't be used. */ | | // ============================================================ | |
| | | | |
| | | /*! \name Constructors and Destructor */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Default constructor | |
| | | * | |
| | | * Shouldn't be used. | |
| | | */ | |
| inline | | inline | |
| FormFile() | | FormFile() | |
| {} | | {} | |
| | | | |
|
| /** | | /*! | |
| * Create a new FormFile. | | * \brief Create a new FormFile. | |
| * @param name The <EM>name</EM> of the form element. | | * | |
| * @param filename The <EM>filename</EM> of the file on the remote machin | | * This is usually not called directly, but by Cgicc. | |
| e. | | * \param name The \e name of the form element. | |
| * @param dataType The MIME content type of the data, if specified, or 0. | | * \param filename The \e filename of the file on the remote machine. | |
| * @param data The file data. | | * \param dataType The MIME content type of the data, if specified, or 0. | |
| | | * \param data The file data. | |
| */ | | */ | |
| FormFile(const STDNS string& name, | | FormFile(const STDNS string& name, | |
| const STDNS string& filename, | | const STDNS string& filename, | |
| const STDNS string& dataType, | | const STDNS string& dataType, | |
| const STDNS string& data); | | const STDNS string& data); | |
| | | | |
|
| /** | | /*! | |
| * Copy constructor. | | * \brief Copy constructor. | |
| | | * | |
| | | * Sets the name, filename, datatype, and data to those of \c file | |
| * @param file The FormFile to copy. | | * @param file The FormFile to copy. | |
| */ | | */ | |
| inline | | inline | |
| FormFile(const FormFile& file) | | FormFile(const FormFile& file) | |
| { operator=(file); } | | { operator=(file); } | |
| | | | |
|
| /** Destructor */ | | /*! | |
| | | * \brief Destructor | |
| | | * | |
| | | * Delete this FormFile object | |
| | | */ | |
| inline | | inline | |
| ~FormFile() | | ~FormFile() | |
| {} | | {} | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Compare two FormFiles for equality. | | | |
| | | /*! \name Overloaded Operators */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Compare two FormFiles for equality. | |
| | | * | |
| * FormFiles are equal if they have the same filename. | | * FormFiles are equal if they have the same filename. | |
| * @param file The FormFile to compare to this one. | | * @param file The FormFile to compare to this one. | |
|
| * @return true if the two FormFiles are equal, false otherwise. | | * @return \c true if the two FormFiles are equal, \c false otherwise. | |
| */ | | */ | |
| bool | | bool | |
| operator== (const FormFile& file) const; | | operator== (const FormFile& file) const; | |
| | | | |
|
| /** | | /*! | |
| * Compare two FormFiles for inequality. | | * \brief Compare two FormFiles for inequality. | |
| | | * | |
| * FormFiles are equal if they have the same filename. | | * FormFiles are equal if they have the same filename. | |
|
| * @param file The FormFile to compare to this one. | | * \param file The FormFile to compare to this one. | |
| * @return false if the two FormFiles are equal, true otherwise. | | * \return \c false if the two FormFiles are equal, \c true otherwise. | |
| */ | | */ | |
| inline bool | | inline bool | |
| operator!= (const FormFile& file) const | | operator!= (const FormFile& file) const | |
| { return ! operator==(file); } | | { return ! operator==(file); } | |
| | | | |
| #ifdef WIN32 | | #ifdef WIN32 | |
|
| /** Dummy operator for MSVC++ */ | | /* Dummy operator for MSVC++ */ | |
| inline bool | | inline bool | |
| operator< (const FormFile& file) const | | operator< (const FormFile& file) const | |
| { return false; } | | { return false; } | |
| #endif | | #endif | |
| | | | |
|
| /** | | /*! | |
| * Assign one FormFile to another. | | * \brief Assign one FormFile to another. | |
| * @param file The FormFile to copy. | | * | |
| * @return A reference to this. | | * Sets the name, filename, datatype, and data to those of \c file | |
| | | * \param file The FormFile to copy. | |
| | | * \return A reference to this. | |
| */ | | */ | |
| FormFile& | | FormFile& | |
| operator= (const FormFile& file); | | operator= (const FormFile& file); | |
|
| | | //@} | |
| | | | |
|
| /** | | // ============================================================ | |
| * Write this file data to the specified stream. | | | |
| * @param out The ostream to which to write. | | /*! \name Accessor Methods | |
| | | * Information on the uploaded file | |
| | | */ | |
| | | //@{ | |
| | | | |
| | | /*! | |
| | | * \brief Write this file data to the specified stream. | |
| | | * | |
| | | * This is useful for saving uploaded data to disk | |
| | | * \param out The ostream to which to write. | |
| */ | | */ | |
| void | | void | |
| writeToStream(STDNS ostream& out) const; | | writeToStream(STDNS ostream& out) const; | |
| | | | |
|
| /** | | /*! | |
| * Get the name of the form element. | | * \brief Get the name of the form element. | |
| * @return The name of the form element. | | * | |
| | | * The name of the form element is specified in the HTML form that | |
| | | * called the CGI application. | |
| | | * \return The name of the form element. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getName() const | | getName() const | |
| { return fName; } | | { return fName; } | |
| | | | |
|
| /** | | /*! | |
| * Get the name of the file on the remote machine. | | * \brief Get the basename of the file on the remote machine. | |
| * @return The name of the file on the remote machine. | | * | |
| | | * The filename is stripped of all leading directory information | |
| | | * \return The basename of the file on the remote machine. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getFilename() const | | getFilename() const | |
| { return fFilename; } | | { return fFilename; } | |
| | | | |
|
| /** | | /*! | |
| * Get the MIME type of the file data. | | * \brief Get the MIME type of the file data. | |
| * @return The MIME type of the file data. | | * | |
| | | * This will be of the form \c text/plain or \c image/jpeg | |
| | | * \return The MIME type of the file data. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getDataType() const | | getDataType() const | |
| { return fDataType; } | | { return fDataType; } | |
| | | | |
|
| /** | | /*! | |
| * Get the file data. | | * \brief Get the file data. | |
| * @return The file data. | | * | |
| | | * This returns the raw file data as a string | |
| | | * \return The file data. | |
| */ | | */ | |
| inline STDNS string | | inline STDNS string | |
| getData() const | | getData() const | |
| { return fData; } | | { return fData; } | |
| | | | |
|
| /** | | /*! | |
| * Get the length of the file data, in bytes. | | * \brief Get the length of the file data | |
| * @return The length of the file data, in bytes. | | * | |
| | | * The length of the file data is usually measured in bytes. | |
| | | * \return The length of the file data, in bytes. | |
| */ | | */ | |
| inline STDNS string::size_type | | inline STDNS string::size_type | |
| getDataLength() const | | getDataLength() const | |
| { return fData.length(); } | | { return fData.length(); } | |
|
| | | //@} | |
| | | | |
| private: | | private: | |
| STDNS string fName; | | STDNS string fName; | |
| STDNS string fFilename; | | STDNS string fFilename; | |
| STDNS string fDataType; | | STDNS string fDataType; | |
| STDNS string fData; | | STDNS string fData; | |
| }; | | }; | |
| | | | |
| CGICC_END_NAMESPACE | | CGICC_END_NAMESPACE | |
| | | | |
| | | | |
End of changes. 27 change blocks. |
| 61 lines changed or deleted | | 125 lines changed or added | |
|
| HTMLClasses.h | | HTMLClasses.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: HTMLClasses.h,v 1.6 1999/09/22 22:30:11 sbooth Exp $ | | * $Id: HTMLClasses.h,v 1.8 2001/09/03 22:06:39 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _HTMLCLASSES_H_ | | #ifndef _HTMLCLASSES_H_ | |
| #define _HTMLCLASSES_H_ 1 | | #define _HTMLCLASSES_H_ 1 | |
| | | | |
|
| | | /*! \file HTMLClasses.h | |
| | | * \brief The header file containing HTML output classes. | |
| | | * | |
| | | * One class is defined for each element in the HTML 4.0 standard. | |
| | | */ | |
| | | | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/CgiDefs.h" | |
|
| #include "cgicc/HTMLGeneric.h" | | #include "cgicc/HTMLAtomicElement.h" | |
| | | #include "cgicc/HTMLBooleanElement.h" | |
| | | #include "cgicc/HTMLDoctype.h" | |
| | | | |
| // ============================================================ | | // ============================================================ | |
| // Macros defining types of elements | | // Macros defining types of elements | |
| // ============================================================ | | // ============================================================ | |
| | | | |
|
| | | /*! | |
| | | * \brief Create an HTML element rendering class | |
| | | * | |
| | | * \param name The name of the class to define | |
| | | * \param tag The text to output when this tag is rendered | |
| | | */ | |
| #define TAG(name, tag) \ | | #define TAG(name, tag) \ | |
| class name##Tag \ | | class name##Tag \ | |
| { public: inline static const char* getName() { return tag; } } | | { public: inline static const char* getName() { return tag; } } | |
| | | | |
|
| | | /*! | |
| | | * \brief Create an atomic HTML element | |
| | | * | |
| | | * Atomic HTML elements maintain no internal on/off state. For | |
| | | * example, \c br and \c meta are atomic elements. | |
| | | * \param name The name of the class to define | |
| | | * \param tag The text to output when this tag is rendered | |
| | | */ | |
| #define ATOMIC_ELEMENT(name, tag) \ | | #define ATOMIC_ELEMENT(name, tag) \ | |
|
| TAG(name, tag); typedef GenericAtomicElement<name##Tag> name | | TAG(name, tag); typedef HTMLAtomicElement<name##Tag> name | |
| | | | |
|
| | | /*! | |
| | | * \brief An HTML element maintaining an internal on/off state | |
| | | * | |
| | | * Boolean HTML elements maintain an internal state, and the output | |
| | | * rendered depends on the current state. For example, \c h1 and \c | |
| | | * title are boolean elements. | |
| | | * \param name The name of the class to define | |
| | | * \param tag The text to output when this tag is rendered | |
| | | */ | |
| #define BOOLEAN_ELEMENT(name, tag) \ | | #define BOOLEAN_ELEMENT(name, tag) \ | |
|
| TAG(name, tag); typedef GenericBooleanElement<name##Tag> name | | TAG(name, tag); typedef HTMLBooleanElement<name##Tag> name | |
| | | | |
| // ============================================================ | | // ============================================================ | |
|
| // HTML 4.0 elements - for details see http://www.w3c.org/ | | // HTML 4.0 elements - for details see http://www.w3.org/ | |
| // ============================================================ | | // ============================================================ | |
| | | | |
| CGICC_BEGIN_NAMESPACE | | CGICC_BEGIN_NAMESPACE | |
| | | | |
|
| // 'comment' is defined in HTMLGeneric.hh | | // ============================================================ | |
| | | // Class comment - needs special render function | |
| | | // ============================================================ | |
| | | | |
|
| // global structure | | class nullTag | |
| | | { public: inline static const char* getName() { return 0; } }; | |
| | | | |
|
| BOOLEAN_ELEMENT (html, "HTML"); // HTML document | | /*! \class comment HTMLGeneric.h cgicc/HTMLGeneric.h | |
| BOOLEAN_ELEMENT (head, "HEAD"); // document head | | * \brief An HTML comment | |
| BOOLEAN_ELEMENT (title, "TITLE"); // document title | | */ | |
| ATOMIC_ELEMENT (meta, "META"); // meta data | | class comment : public HTMLBooleanElement<nullTag> | |
| BOOLEAN_ELEMENT (style, "STYLE"); // style sheet | | { | |
| BOOLEAN_ELEMENT (body, "BODY"); // document body | | virtual void render(STDNS ostream& out) const | |
| | | { | |
| | | if(getData().empty() && dataSpecified() == false) { | |
| | | swapState(); | |
| | | out << (getState() ? "<!-- " : " -->"); | |
| | | } | |
| | | else | |
| | | out << "<!-- " << getData() << " -->"; | |
| | | } | |
| | | }; | |
| | | | |
| | | BOOLEAN_ELEMENT (html, "html"); // HTML document | |
| | | BOOLEAN_ELEMENT (head, "head"); // document head | |
| | | BOOLEAN_ELEMENT (title, "title"); // document title | |
| | | ATOMIC_ELEMENT (meta, "meta"); // meta data | |
| | | BOOLEAN_ELEMENT (style, "style"); // style sheet | |
| | | BOOLEAN_ELEMENT (body, "body"); // document body | |
| #if CGICC_USE_NAMESPACES | | #if CGICC_USE_NAMESPACES | |
|
| BOOLEAN_ELEMENT (div, "DIV"); // block-level grouping | | BOOLEAN_ELEMENT (div, "div"); // block-level grouping | |
| #else | | #else | |
|
| BOOLEAN_ELEMENT (div_, "DIV"); // block-level grouping | | BOOLEAN_ELEMENT (div_, "div"); // block-level grouping | |
| #endif | | #endif | |
|
| BOOLEAN_ELEMENT (span, "SPAN"); // inline grouping | | BOOLEAN_ELEMENT (span, "span"); // inline grouping | |
| BOOLEAN_ELEMENT (h1, "H1"); // level 1 heading | | BOOLEAN_ELEMENT (h1, "h1"); // level 1 heading | |
| BOOLEAN_ELEMENT (h2, "H2"); // level 2 heading | | BOOLEAN_ELEMENT (h2, "h2"); // level 2 heading | |
| BOOLEAN_ELEMENT (h3, "H3"); // level 3 heading | | BOOLEAN_ELEMENT (h3, "h3"); // level 3 heading | |
| BOOLEAN_ELEMENT (h4, "H4"); // level 4 heading | | BOOLEAN_ELEMENT (h4, "h4"); // level 4 heading | |
| BOOLEAN_ELEMENT (h5, "H5"); // level 5 heading | | BOOLEAN_ELEMENT (h5, "h5"); // level 5 heading | |
| BOOLEAN_ELEMENT (h6, "H6"); // level 6 heading | | BOOLEAN_ELEMENT (h6, "h6"); // level 6 heading | |
| BOOLEAN_ELEMENT (address, "ADDRESS"); // contact information | | BOOLEAN_ELEMENT (address, "address"); // contact information | |
| | | | |
| // text markup | | // text markup | |
| | | | |
|
| BOOLEAN_ELEMENT (em, "EM"); // emphasis | | BOOLEAN_ELEMENT (em, "em"); // emphasis | |
| BOOLEAN_ELEMENT (strong, "STRONG"); // stronger emphasis | | BOOLEAN_ELEMENT (strong, "strong"); // stronger emphasis | |
| BOOLEAN_ELEMENT (cite, "CITE"); // citation/reference | | BOOLEAN_ELEMENT (cite, "cite"); // citation/reference | |
| BOOLEAN_ELEMENT (dfn, "DFN"); // defining instance | | BOOLEAN_ELEMENT (dfn, "dfn"); // defining instance | |
| BOOLEAN_ELEMENT (code, "CODE"); // computer code | | BOOLEAN_ELEMENT (code, "code"); // computer code | |
| BOOLEAN_ELEMENT (samp, "SAMP"); // sample output | | BOOLEAN_ELEMENT (samp, "samp"); // sample output | |
| BOOLEAN_ELEMENT (kbd, "KBD"); // user input | | BOOLEAN_ELEMENT (kbd, "kbd"); // user input | |
| BOOLEAN_ELEMENT (var, "VAR"); // variable/argument | | BOOLEAN_ELEMENT (var, "var"); // variable/argument | |
| BOOLEAN_ELEMENT (abbr, "ABBR"); // abbreviated form | | BOOLEAN_ELEMENT (abbr, "abbr"); // abbreviated form | |
| BOOLEAN_ELEMENT (acronym, "ACRONYM"); // acronym | | BOOLEAN_ELEMENT (acronym, "acronym"); // acronym | |
| BOOLEAN_ELEMENT (blockquote, "BLOCKQUOTE"); // block-level quotation | | BOOLEAN_ELEMENT (blockquote, "blockquote"); // block-level quotation | |
| BOOLEAN_ELEMENT (q, "Q"); // inline quotation | | BOOLEAN_ELEMENT (q, "q"); // inline quotation | |
| BOOLEAN_ELEMENT (sub, "SUB"); // subscript | | BOOLEAN_ELEMENT (sub, "sub"); // subscript | |
| BOOLEAN_ELEMENT (sup, "SUP"); // superscript | | BOOLEAN_ELEMENT (sup, "sup"); // superscript | |
| BOOLEAN_ELEMENT (p, "P"); // paragraph | | BOOLEAN_ELEMENT (p, "p"); // paragraph | |
| ATOMIC_ELEMENT (br, "BR"); // line break | | ATOMIC_ELEMENT (br, "br"); // line break | |
| BOOLEAN_ELEMENT (pre, "PRE"); // preformatted text | | BOOLEAN_ELEMENT (pre, "pre"); // preformatted text | |
| BOOLEAN_ELEMENT (ins, "INS"); // inserted text | | BOOLEAN_ELEMENT (ins, "ins"); // inserted text | |
| BOOLEAN_ELEMENT (del, "DEL"); // deleted text | | BOOLEAN_ELEMENT (del, "del"); // deleted text | |
| BOOLEAN_ELEMENT (bdo, "BDO"); // overriding direction | | BOOLEAN_ELEMENT (bdo, "bdo"); // overriding direction | |
| | | | |
| // lists | | // lists | |
| | | | |
|
| BOOLEAN_ELEMENT (ul, "UL"); // unordered list | | BOOLEAN_ELEMENT (ul, "ul"); // unordered list | |
| BOOLEAN_ELEMENT (ol, "OL"); // ordered list | | BOOLEAN_ELEMENT (ol, "ol"); // ordered list | |
| BOOLEAN_ELEMENT (li, "LI"); // list item | | BOOLEAN_ELEMENT (li, "li"); // list item | |
| BOOLEAN_ELEMENT (dl, "DL"); // definition list | | BOOLEAN_ELEMENT (dl, "dl"); // definition list | |
| BOOLEAN_ELEMENT (dt, "DT"); // term to be defined | | BOOLEAN_ELEMENT (dt, "dt"); // term to be defined | |
| BOOLEAN_ELEMENT (dd, "DD"); // definition of term | | BOOLEAN_ELEMENT (dd, "dd"); // definition of term | |
| | | | |
| // tables | | // tables | |
| | | | |
|
| BOOLEAN_ELEMENT (table, "TABLE"); // table element | | BOOLEAN_ELEMENT (table, "table"); // table element | |
| BOOLEAN_ELEMENT (caption, "CAPTION"); // table caption | | BOOLEAN_ELEMENT (caption, "caption"); // table caption | |
| BOOLEAN_ELEMENT (thead, "THEAD"); // table head section | | BOOLEAN_ELEMENT (thead, "thead"); // table head section | |
| BOOLEAN_ELEMENT (tfoot, "TFOOT"); // table foot section | | BOOLEAN_ELEMENT (tfoot, "tfoot"); // table foot section | |
| BOOLEAN_ELEMENT (tbody, "TBODY"); // table body section | | BOOLEAN_ELEMENT (tbody, "tbody"); // table body section | |
| BOOLEAN_ELEMENT (colgroup, "COLGROUP"); // vertical section | | BOOLEAN_ELEMENT (colgroup, "colgroup"); // vertical section | |
| ATOMIC_ELEMENT (col, "COL"); // column attributes | | ATOMIC_ELEMENT (col, "col"); // column attributes | |
| BOOLEAN_ELEMENT (tr, "TR"); // table row | | BOOLEAN_ELEMENT (tr, "tr"); // table row | |
| BOOLEAN_ELEMENT (th, "TH"); // table header cell | | BOOLEAN_ELEMENT (th, "th"); // table header cell | |
| BOOLEAN_ELEMENT (td, "TD"); // table data cell | | BOOLEAN_ELEMENT (td, "td"); // table data cell | |
| | | | |
| // links | | // links | |
| | | | |
|
| BOOLEAN_ELEMENT (a, "A"); // anchor | | BOOLEAN_ELEMENT (a, "a"); // anchor | |
| #if CGICC_USE_NAMESPACES | | #if CGICC_USE_NAMESPACES | |
|
| ATOMIC_ELEMENT (link, "LINK"); // document link | | ATOMIC_ELEMENT (link, "link"); // document link | |
| #else | | #else | |
|
| ATOMIC_ELEMENT (link_, "LINK"); // document link | | ATOMIC_ELEMENT (link_, "link"); // document link | |
| #endif | | #endif | |
|
| ATOMIC_ELEMENT (base, "BASE"); // path information | | ATOMIC_ELEMENT (base, "base"); // path information | |
| | | | |
| // objects | | // objects | |
| | | | |
|
| ATOMIC_ELEMENT (img, "IMG"); // inline image | | ATOMIC_ELEMENT (img, "img"); // inline image | |
| BOOLEAN_ELEMENT (object, "OBJECT"); // generic object | | BOOLEAN_ELEMENT (object, "object"); // generic object | |
| ATOMIC_ELEMENT (param, "PARAM"); // object parameters | | ATOMIC_ELEMENT (param, "param"); // object parameters | |
| BOOLEAN_ELEMENT (map, "MAP"); // client image map | | BOOLEAN_ELEMENT (map, "map"); // client image map | |
| ATOMIC_ELEMENT (area, "AREA"); // image map region | | ATOMIC_ELEMENT (area, "area"); // image map region | |
| ATOMIC_ELEMENT (hr, "HR"); // horizontal rule | | ATOMIC_ELEMENT (hr, "hr"); // horizontal rule | |
| | | | |
| // fonts - preferably use stylesheets | | // fonts - preferably use stylesheets | |
| | | | |
|
| BOOLEAN_ELEMENT (tt, "TT"); // monospaced text | | BOOLEAN_ELEMENT (tt, "tt"); // monospaced text | |
| BOOLEAN_ELEMENT (i, "I"); // italic text style | | BOOLEAN_ELEMENT (i, "i"); // italic text style | |
| BOOLEAN_ELEMENT (b, "B"); // bold text style | | BOOLEAN_ELEMENT (b, "b"); // bold text style | |
| BOOLEAN_ELEMENT (big, "BIG"); // large font | | BOOLEAN_ELEMENT (big, "big"); // large font | |
| BOOLEAN_ELEMENT (small, "SMALL"); // small font | | BOOLEAN_ELEMENT (small, "small"); // small font | |
| | | | |
| // frames - not part of the strict DTD | | // frames - not part of the strict DTD | |
| | | | |
|
| BOOLEAN_ELEMENT (frameset, "FRAMESET"); // frame layout | | BOOLEAN_ELEMENT (frameset, "frameset"); // frame layout | |
| ATOMIC_ELEMENT (frame, "FRAME"); // frame contents | | ATOMIC_ELEMENT (frame, "frame"); // frame contents | |
| BOOLEAN_ELEMENT (noframes, "NOFRAMES"); // alternative text | | BOOLEAN_ELEMENT (noframes, "noframes"); // alternative text | |
| BOOLEAN_ELEMENT (iframe, "IFRAME"); // inline frame | | BOOLEAN_ELEMENT (iframe, "iframe"); // inline frame | |
| | | | |
| // forms | | // forms | |
| | | | |
|
| BOOLEAN_ELEMENT (form, "FORM"); // form element | | BOOLEAN_ELEMENT (form, "form"); // form element | |
| ATOMIC_ELEMENT (input, "INPUT"); // generic input | | ATOMIC_ELEMENT (input, "input"); // generic input | |
| BOOLEAN_ELEMENT (button, "BUTTON"); // special button | | BOOLEAN_ELEMENT (button, "button"); // special button | |
| #if CGICC_USE_NAMESPACES | | #if CGICC_USE_NAMESPACES | |
|
| BOOLEAN_ELEMENT (select, "SELECT"); // option menu | | BOOLEAN_ELEMENT (select, "select"); // option menu | |
| #else | | #else | |
|
| BOOLEAN_ELEMENT (select_, "SELECT"); // option menu | | BOOLEAN_ELEMENT (select_, "select"); // option menu | |
| #endif | | #endif | |
|
| BOOLEAN_ELEMENT (optgroup, "OPTGROUP"); // option group | | BOOLEAN_ELEMENT (optgroup, "optgroup"); // option group | |
| BOOLEAN_ELEMENT (option, "OPTION"); // option item | | BOOLEAN_ELEMENT (option, "option"); // option item | |
| BOOLEAN_ELEMENT (textarea, "TEXTAREA"); // multi-line text input | | BOOLEAN_ELEMENT (textarea, "textarea"); // multi-line text input | |
| BOOLEAN_ELEMENT (label, "LABEL"); // input label | | BOOLEAN_ELEMENT (label, "label"); // input label | |
| BOOLEAN_ELEMENT (fieldset, "FIELDSET"); // grouping input fields | | BOOLEAN_ELEMENT (fieldset, "fieldset"); // grouping input fields | |
| BOOLEAN_ELEMENT (legend, "LEGEND"); // caption for field set | | BOOLEAN_ELEMENT (legend, "legend"); // caption for field set | |
| | | | |
| // scripts | | // scripts | |
| | | | |
|
| BOOLEAN_ELEMENT (script, "SCRIPT"); // script element | | BOOLEAN_ELEMENT (script, "script"); // script element | |
| BOOLEAN_ELEMENT (noscript, "NOSCRIPT"); // alternative text | | BOOLEAN_ELEMENT (noscript, "noscript"); // alternative text | |
| | | | |
| CGICC_END_NAMESPACE | | CGICC_END_NAMESPACE | |
| | | | |
| #endif /* ! _HTMLCLASSES_H_ */ | | #endif /* ! _HTMLCLASSES_H_ */ | |
| | | | |
End of changes. 35 change blocks. |
| 101 lines changed or deleted | | 151 lines changed or added | |
|
| HTTPHeaders.h | | HTTPHeaders.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: HTTPHeaders.h,v 1.3 1999/08/16 17:40:05 sbooth Exp $ | | * $Id: HTTPHeaders.h,v 1.7 2001/09/05 02:18:28 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _HTTPHEADERS_H_ | | #ifndef _HTTPHEADERS_H_ | |
| #define _HTTPHEADERS_H_ 1 | | #define _HTTPHEADERS_H_ 1 | |
| | | | |
| #ifdef __GNUG__ | | #ifdef __GNUG__ | |
| # pragma interface | | # pragma interface | |
| #endif | | #endif | |
| | | | |
|
| #include <string> | | #include "cgicc/HTTPHeader.h" | |
| | | #include "cgicc/HTTPContentHeader.h" | |
| #include "cgicc/MStreamable.h" | | #include "cgicc/HTTPHTMLHeader.h" | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/HTTPPlainHeader.h" | |
| | | #include "cgicc/HTTPRedirectHeader.h" | |
| CGICC_BEGIN_NAMESPACE | | #include "cgicc/HTTPStatusHeader.h" | |
| | | | |
| // ============================================================ | | | |
| // Class HTMLDoctype | | | |
| // ============================================================ | | | |
| /** | | | |
| * Specifies the DTD of the HTML 4 document. | | | |
| * <P>To use this class, simply write an object of this type to an ostream: | | | |
| * <BR><PRE CLASS="code"> | | | |
| * . out << HTMLDoctype(); | | | |
| * </PRE> | | | |
| * <P>For more information, see <TT>\URL{http://www.w3.org/MarkUp/}</TT> an | | | |
| d | | | |
| * <TT>\URL{http://www.w3.org/TR/REC-html40/}</TT></P> | | | |
| */ | | | |
| class CGICC_API HTMLDoctype : public MStreamable | | | |
| { | | | |
| public: | | | |
| | | | |
| /** The DTD used by this document. */ | | | |
| enum EDocumentType { | | | |
| /** The HTML 4.0 strict DTD */ | | | |
| eStrict, | | | |
| /** The HTML 4.0 Transitional DTD */ | | | |
| eTransitional, | | | |
| /** The HTML 4.0 Frameset DTD */ | | | |
| eFrames | | | |
| }; | | | |
| | | | |
| /** | | | |
| * Constructor. | | | |
| * @param type The version of the HTML 4.0 DTD used by this document. | | | |
| */ | | | |
| HTMLDoctype(EDocumentType type = eStrict); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTMLDoctype(); | | | |
| | | | |
| virtual void | | | |
| render(STDNS ostream& out) const; | | | |
| | | | |
| private: | | | |
| EDocumentType fType; | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPCookie | | | |
| // ============================================================ | | | |
| /** | | | |
| * An HTTP cookie. | | | |
| * <P>Use this like any other \Ref{MStreamable} object. For example, to set | | | |
| * an HTTP cookie:</P> | | | |
| * <PRE class="code"> | | | |
| * out << HTTPCookie("count","1"); | | | |
| * </PRE> | | | |
| */ | | | |
| class CGICC_API HTTPCookie : public MStreamable | | | |
| { | | | |
| public: | | | |
| | | | |
| /** Create a new, empty HTTPCookie. */ | | | |
| HTTPCookie(); | | | |
| | | | |
| /** | | | |
| * Create a new HTTPCookie. | | | |
| * @param name The name of the cookie. | | | |
| * @param value The value of the cookie. | | | |
| */ | | | |
| HTTPCookie(const STDNS string& name, | | | |
| const STDNS string& value); | | | |
| | | | |
| /** | | | |
| * Create a new HTTPCookie. | | | |
| * @param name The name of the cookie. | | | |
| * @param value The value of the cookie. | | | |
| * @param comment Any comment associated with the cookie. | | | |
| * @param domain The domain for which this cookie is valid- an empty stri | | | |
| ng | | | |
| * will use the hostname of the server which generated the cookie respons | | | |
| e. | | | |
| * If specified, the domain <EM>must</EM> start with a period('.'). | | | |
| * @param maxAge A number of seconds defining the lifetime of this cookie | | | |
| . | | | |
| * A value of <TT>0</TT> indicates the cookie expires immediately. | | | |
| * @param path The subset of URLS in a domain for which the cookie is | | | |
| * valid, for example "/". | | | |
| * @param secure Specifies whether this is a secure cookie. | | | |
| */ | | | |
| HTTPCookie(const STDNS string& name, | | | |
| const STDNS string& value, | | | |
| const STDNS string& comment, | | | |
| const STDNS string& domain, | | | |
| unsigned long maxAge, | | | |
| const STDNS string& path, | | | |
| bool secure); | | | |
| | | | |
| /** | | | |
| * Copy constructor. | | | |
| * @param cookie The HTTPCookie to copy. | | | |
| */ | | | |
| HTTPCookie(const HTTPCookie& cookie); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPCookie(); | | | |
| | | | |
| /** | | | |
| * Compare two HTTPCookies for equality. | | | |
| * @param cookie The HTTPCookie to compare to this one | | | |
| * @return true if the two HTTPCookies are equal, false otherwise. | | | |
| */ | | | |
| bool | | | |
| operator== (const HTTPCookie& cookie) const; | | | |
| | | | |
| /** | | | |
| * Compare two HTTPCookies for inequality. | | | |
| * @param cookie The HTTPCookie to compare to this one | | | |
| * @return false if the two HTTPCookies are equal, true otherwise. | | | |
| */ | | | |
| inline bool | | | |
| operator != (const HTTPCookie& cookie) const | | | |
| { return ! operator==(cookie); } | | | |
| | | | |
| #ifdef WIN32 | | | |
| /** Dummy operator for MSVC++ */ | | | |
| inline bool | | | |
| operator< (const HTTPCookie& cookie) const | | | |
| { return false; } | | | |
| #endif | | | |
| | | | |
| /** | | | |
| * Get the name of this cookie. | | | |
| * @return The name of this cookie. | | | |
| */ | | | |
| inline STDNS string | | | |
| getName() const | | | |
| { return fName; } | | | |
| | | | |
| /** | | | |
| * Get the value of this cookie. | | | |
| * @return The value of this cookie. | | | |
| */ | | | |
| inline STDNS string | | | |
| getValue() const | | | |
| { return fValue; } | | | |
| | | | |
| /** | | | |
| * Get the comment of this cookie. | | | |
| * @return The comment of this cookie. | | | |
| */ | | | |
| inline STDNS string | | | |
| getComment() const | | | |
| { return fComment; } | | | |
| | | | |
| /** | | | |
| * Get the domain of this cookie. | | | |
| * @return The domain of this cookie, or "" if none. | | | |
| */ | | | |
| inline STDNS string | | | |
| getDomain() const | | | |
| { return fDomain; } | | | |
| | | | |
| /** | | | |
| * Get the lifetime of this cookie, in seconds. | | | |
| * @return The lifetime of this cookie, or 0 if none. | | | |
| */ | | | |
| inline unsigned long | | | |
| getMaxAge() const | | | |
| { return fMaxAge; } | | | |
| | | | |
| /** | | | |
| * Get the path of this cookie. | | | |
| * @return The path of this cookie, or "" if none. | | | |
| */ | | | |
| inline STDNS string | | | |
| getPath() const | | | |
| { return fPath; } | | | |
| | | | |
| /** | | | |
| * Determine if this is a secure cookie. | | | |
| * @return True if this cookie is secure, false if not. | | | |
| */ | | | |
| inline bool | | | |
| isSecure() const | | | |
| { return fSecure; } | | | |
| | | | |
| /** | | | |
| * Set the name of this cookie. | | | |
| * @param name The name of this cookie. | | | |
| */ | | | |
| inline void | | | |
| setName(const STDNS string& name) | | | |
| { fName = name; } | | | |
| | | | |
| /** | | | |
| * Set the value of this cookie. | | | |
| * @param value The value of this cookie. | | | |
| */ | | | |
| inline void | | | |
| setValue(const STDNS string& value) | | | |
| { fValue = value; } | | | |
| | | | |
| /** | | | |
| * Set the comment of this cookie. | | | |
| * @param comment The comment of this cookie. | | | |
| */ | | | |
| inline void | | | |
| setComment(const STDNS string& comment) | | | |
| { fComment = comment; } | | | |
| | | | |
| /** | | | |
| * Set the domain of this cookie. | | | |
| * @param domain The domain of this cookie. | | | |
| */ | | | |
| inline void | | | |
| setDomain(const STDNS string& domain) | | | |
| { fDomain = domain; } | | | |
| | | | |
| /** | | | |
| * Set the lifetime of this cookie, in seconds. | | | |
| * @param maxAge The lifetime of this cookie, in seconds. | | | |
| */ | | | |
| inline void | | | |
| setMaxAge(unsigned long maxAge) | | | |
| { fMaxAge = maxAge; } | | | |
| | | | |
| /** | | | |
| * Set the path of this cookie. | | | |
| * @param path The path of this cookie. | | | |
| */ | | | |
| inline void | | | |
| setPath(const STDNS string& path) | | | |
| { fPath = path; } | | | |
| | | | |
| /** | | | |
| * Mark this cookie as secure or unsecure. | | | |
| * @param secure Whether this is a secure cookie. | | | |
| */ | | | |
| inline void | | | |
| setSecure(bool secure) | | | |
| { fSecure = secure; } | | | |
| | | | |
| virtual void | | | |
| render(STDNS ostream& out) const; | | | |
| | | | |
| private: | | | |
| STDNS string fName; | | | |
| STDNS string fValue; | | | |
| STDNS string fComment; | | | |
| STDNS string fDomain; | | | |
| unsigned long fMaxAge; | | | |
| STDNS string fPath; | | | |
| bool fSecure; | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPHeader | | | |
| // ============================================================ | | | |
| /** Abstract base class for all HTTP headers. */ | | | |
| class CGICC_API HTTPHeader : public MStreamable | | | |
| { | | | |
| public: | | | |
| | | | |
| /** | | | |
| * Constructor. | | | |
| * @param data The header data. | | | |
| */ | | | |
| HTTPHeader(const STDNS string& data); | | | |
| | | | |
| /** | | | |
| * Copy constructor. | | | |
| * @param header The HTTPHeader to copy. | | | |
| */ | | | |
| HTTPHeader(const HTTPHeader& header); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPHeader(); | | | |
| | | | |
| /** | | | |
| * Get the data contained in this HTTP header. | | | |
| * @return The data contained in this header. | | | |
| */ | | | |
| inline STDNS string | | | |
| getData() const | | | |
| { return fData; } | | | |
| | | | |
| virtual void | | | |
| render(STDNS ostream& out) const = 0; | | | |
| | | | |
| private: | | | |
| HTTPHeader(); | | | |
| | | | |
| STDNS string fData; | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPContentHeader | | | |
| // ============================================================ | | | |
| /** HTTP header for data of a specified MIME type. */ | | | |
| class CGICC_API HTTPContentHeader : public HTTPHeader | | | |
| { | | | |
| public: | | | |
| /** | | | |
| * Create a new MIME type header. | | | |
| * @param mimeType The MIME type of the data which will be sent. | | | |
| */ | | | |
| HTTPContentHeader(const STDNS string& mimeType); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPContentHeader(); | | | |
| | | | |
| virtual void | | | |
| render(STDNS ostream& out) const; | | | |
| | | | |
| private: | | | |
| HTTPContentHeader(); | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPRedirectHeader | | | |
| // ============================================================ | | | |
| /** HTTP Redirection Header */ | | | |
| class CGICC_API HTTPRedirectHeader : public HTTPHeader | | | |
| { | | | |
| public: | | | |
| /** | | | |
| * Create a new redirection header. | | | |
| * @param url The redirection URL. | | | |
| */ | | | |
| HTTPRedirectHeader(const STDNS string& url); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPRedirectHeader(); | | | |
| | | | |
| virtual void | | | |
| render(STDNS ostream& out) const; | | | |
| | | | |
| private: | | | |
| HTTPRedirectHeader(); | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPStatusHeader | | | |
| // ============================================================ | | | |
| /** HTTP Status Header */ | | | |
| class CGICC_API HTTPStatusHeader : public HTTPHeader | | | |
| { | | | |
| public: | | | |
| /** | | | |
| * Create a new status header. | | | |
| * @param status The 3-digit status code, for example 404. | | | |
| * @param message The message associated with the status code, for exampl | | | |
| e | | | |
| * "not found". | | | |
| */ | | | |
| HTTPStatusHeader(int status, | | | |
| const STDNS string& message); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPStatusHeader(); | | | |
| | | | |
| /** | | | |
| * Get the status code associated with this header. | | | |
| * @return The 3-digit status code of this header. | | | |
| */ | | | |
| inline int | | | |
| getStatusCode() const | | | |
| { return fStatus; } | | | |
| | | | |
| virtual void | | | |
| render(STDNS ostream& out) const; | | | |
| | | | |
| private: | | | |
| HTTPStatusHeader(); | | | |
| int fStatus; | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPNPHeader | | | |
| // ============================================================ | | | |
| /** HTTP No-parse Header */ | | | |
| class CGICC_API HTTPNPHeader : public HTTPHeader | | | |
| { | | | |
| public: | | | |
| /** Create a new No-parse header */ | | | |
| HTTPNPHeader(); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPNPHeader(); | | | |
| | | | |
| virtual void | | | |
| render(STDNS ostream& out) const; | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPHTMLHeader | | | |
| // ============================================================ | | | |
| /** Shortcut to HTTPContentHeader for "text/html" */ | | | |
| class CGICC_API HTTPHTMLHeader : public HTTPContentHeader | | | |
| { | | | |
| public: | | | |
| /** Create a new "text/html" header */ | | | |
| HTTPHTMLHeader(); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPHTMLHeader(); | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPPlainHeader | | | |
| // ============================================================ | | | |
| /** Shortcut to HTTPContentHeader for "text/plain" */ | | | |
| class CGICC_API HTTPPlainHeader : public HTTPContentHeader | | | |
| { | | | |
| public: | | | |
| /** Create a new "text/plain" header */ | | | |
| HTTPPlainHeader(); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPPlainHeader(); | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPGIFHeader | | | |
| // ============================================================ | | | |
| /** Shortcut to HTTPContentHeader for "image/gif" */ | | | |
| class CGICC_API HTTPGIFHeader : public HTTPContentHeader | | | |
| { | | | |
| public: | | | |
| /** Create a new "image/gif" header */ | | | |
| HTTPGIFHeader(); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPGIFHeader(); | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPJPEGHeader | | | |
| // ============================================================ | | | |
| /** Shortcut to HTTPContentHeader for "image/jpeg" */ | | | |
| class CGICC_API HTTPJPEGHeader : public HTTPContentHeader | | | |
| { | | | |
| public: | | | |
| /** Create a new "image/jpeg" header */ | | | |
| HTTPJPEGHeader(); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPJPEGHeader(); | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPXBMHeader | | | |
| // ============================================================ | | | |
| /** Shortcut to HTTPContentHeader for "image/x-xbitmap" */ | | | |
| class CGICC_API HTTPXBMHeader : public HTTPContentHeader | | | |
| { | | | |
| public: | | | |
| /** Create a new "image/x-xbitmap" header */ | | | |
| HTTPXBMHeader(); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPXBMHeader(); | | | |
| }; | | | |
| | | | |
| // ============================================================ | | | |
| // Class HTTPAudioHeader | | | |
| // ============================================================ | | | |
| /** Shortcut to HTTPContentHeader for "audio/basic" */ | | | |
| class CGICC_API HTTPAudioHeader : public HTTPContentHeader | | | |
| { | | | |
| public: | | | |
| /** Create a new "audio/basic" header */ | | | |
| HTTPAudioHeader(); | | | |
| | | | |
| /** Destructor */ | | | |
| virtual ~HTTPAudioHeader(); | | | |
| }; | | | |
| | | | |
|
| CGICC_END_NAMESPACE | | #include "cgicc/HTTPResponseHeader.h" | |
| | | | |
| #endif /* ! _HTTPHEADERS_H_ */ | | #endif /* ! _HTTPHEADERS_H_ */ | |
| | | | |
End of changes. 8 change blocks. |
| 493 lines changed or deleted | | 18 lines changed or added | |
|
| MStreamable.h | | MStreamable.h | |
| /* -*-c++-*- */ | | /* -*-c++-*- */ | |
| /* | | /* | |
|
| * $Id: MStreamable.h,v 1.4 1999/08/20 20:51:32 sbooth Exp $ | | * $Id: MStreamable.h,v 1.6 2001/09/03 22:06:39 sbooth Exp $ | |
| * | | * | |
|
| * Copyright (C) 1996, 1997, 1998, 1999 Stephen F. Booth | | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Stephen F. Booth | |
| * | | * | |
|
| * This program is free software; you can redistribute it and/or modify | | * This library is free software; you can redistribute it and/or | |
| * it under the terms of the GNU General Public License as published by | | * modify it under the terms of the GNU Lesser General Public | |
| * the Free Software Foundation; either version 2 of the License, or | | * License as published by the Free Software Foundation; either | |
| * (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
|
| * This program is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * GNU General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
|
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU Lesser General Public | |
| * along with this program; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U
SA | |
| */ | | */ | |
| | | | |
| #ifndef _MSTREAMABLE_H_ | | #ifndef _MSTREAMABLE_H_ | |
| #define _MSTREAMABLE_H_ 1 | | #define _MSTREAMABLE_H_ 1 | |
| | | | |
| #ifdef __GNUG__ | | #ifdef __GNUG__ | |
| # pragma interface | | # pragma interface | |
| #endif | | #endif | |
| | | | |
|
| | | /*! \file MStreamable.h | |
| | | * \brief Abstract base class for all streamable objects. | |
| | | * | |
| | | * A streamable object is an object that can be written to an \c | |
| | | * ostream using the \c << operator. | |
| | | */ | |
| | | | |
| #include <iostream> | | #include <iostream> | |
| | | | |
| #include "cgicc/CgiDefs.h" | | #include "cgicc/CgiDefs.h" | |
| | | | |
| CGICC_BEGIN_NAMESPACE | | CGICC_BEGIN_NAMESPACE | |
| | | | |
| class MStreamable; | | class MStreamable; | |
| | | | |
|
| /** Prototype for overloading streaming operator */ | | /*! | |
| | | * Prototype for overloading streaming operator | |
| | | * \param out The ostream to which to write | |
| | | * \param obj The MStreamable object to write | |
| | | * \return A reference to \c out | |
| | | */ | |
| CGICC_API STDNS ostream& | | CGICC_API STDNS ostream& | |
| operator<<(STDNS ostream& out, const MStreamable& obj); | | operator<<(STDNS ostream& out, const MStreamable& obj); | |
| | | | |
| // ============================================================ | | // ============================================================ | |
| // Class MStreamable | | // Class MStreamable | |
| // ============================================================ | | // ============================================================ | |
|
| /** | | | |
| | | /*! \class MStreamable MStreamable.h cgicc/MStreamable.h | |
| | | * \brief Mix-in streamable interface. | |
| | | * | |
| * Abstract mix-in class which makes classes streamable via | | * Abstract mix-in class which makes classes streamable via | |
|
| * the << operator. | | * the \c << operator. | |
| * Written in the spirit of a Java interface. | | * Written in the spirit of a Java interface. | |
| */ | | */ | |
| class CGICC_API MStreamable | | class CGICC_API MStreamable | |
| { | | { | |
| | | | |
| friend CGICC_API STDNS ostream& | | friend CGICC_API STDNS ostream& | |
| operator<<(STDNS ostream& out, const MStreamable& obj); | | operator<<(STDNS ostream& out, const MStreamable& obj); | |
| | | | |
| public: | | public: | |
|
| /** Contructor. Empty */ | | /*! | |
| | | * \brief Empty constructor | |
| | | * | |
| | | */ | |
| inline MStreamable() | | inline MStreamable() | |
| {} | | {} | |
| | | | |
|
| /** Destructor. Empty */ | | /*! | |
| | | * \brief Empty destructor | |
| | | * | |
| | | */ | |
| inline virtual ~MStreamable() | | inline virtual ~MStreamable() | |
| {} | | {} | |
| | | | |
|
| /** | | /*! | |
| * Write this object to a stream. Subclasses must implement this functio | | * \brief Write this object to a stream. | |
| n. | | * | |
| * @param out The ostream to which to write. | | * Subclasses must implement this function. | |
| | | * \param out The ostream to which to write. | |
| */ | | */ | |
| virtual void | | virtual void | |
| render(STDNS ostream& out) const = 0; | | render(STDNS ostream& out) const = 0; | |
| }; | | }; | |
| | | | |
| CGICC_END_NAMESPACE | | CGICC_END_NAMESPACE | |
| | | | |
| #endif /* ! _MSTREAMABLE_H_ */ | | #endif /* ! _MSTREAMABLE_H_ */ | |
| | | | |
End of changes. 13 change blocks. |
| 20 lines changed or deleted | | 42 lines changed or added | |
|