/usr/include/cgicc/Cgicc.h is in libcgicc5-dev 3.2.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | /* -*-mode:c++; c-file-style: "gnu";-*- */
/*
* $Id: Cgicc.h,v 1.19 2009/01/03 17:12:07 sebdiaz Exp $
*
* Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
* 2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
* Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
#ifndef _CGICC_H_
#define _CGICC_H_ 1
#ifdef __GNUG__
# pragma interface
#endif
/*! \file Cgicc.h
* \brief The main header file for the GNU %cgicc library
*/
/*
* The GNU cgicc library, by Stephen F. Booth <sbooth@gnu.org>
* http://www.cgicc.org
*
* The latest version can be found on your closest GNU mirror site.
* Please mail bug reports to <bug-cgicc@gnu.org>
*/
#include <vector>
#include <string>
#include "cgicc/CgiDefs.h"
#include "cgicc/FormEntry.h"
#include "cgicc/FormFile.h"
#include "cgicc/CgiInput.h"
#include "cgicc/CgiEnvironment.h"
namespace cgicc {
#ifdef WIN32
template class CGICC_API std::vector<FormEntry>;
template class CGICC_API std::vector<FormFile>;
#endif
class MultipartHeader;
// ============================================================
// Iterator typedefs
// ============================================================
//! A vector of FormEntry objects
typedef std::vector<FormEntry>::iterator form_iterator;
//! A vector of \c const FormEntry objects
typedef std::vector<FormEntry>::const_iterator const_form_iterator;
//! A vector of FormFile objects
typedef std::vector<FormFile>::iterator file_iterator;
//! A vector of \c const FormFile objects
typedef std::vector<FormFile>::const_iterator const_file_iterator;
// ============================================================
// Class Cgicc
// ============================================================
/*! \class Cgicc Cgicc.h cgicc/Cgicc.h
* \brief The main class of the GNU %cgicc library
*
* 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
* main(int argc, char **argv) {
* try {
* cgicc::Cgicc cgi;
* // do something with cgi
* }
*
* catch(const exception& e) {
* //handle the error
* }
* }
* \endcode
*/
class CGICC_API Cgicc {
public:
// ============================================================
/*! \name Constructors and Destructor */
//@{
/*!
* \brief Constructor
*
* If you are using %cgicc with FastCGI, you will need to pass
* a \c CgiInput subclass that %cgicc will use to read input. If
* \c input is omitted, standard input and environment
* variables will be used.
* \param input A CgiInput object to use for reading input
*/
Cgicc(CgiInput *input = 0);
/*!
* \brief Copy constructor.
*
* Sets the values of this Cgicc to those of \c cgi.
* \param env The Cgicc to copy.
*/
inline
Cgicc(const Cgicc& cgi)
: fEnvironment(cgi.fEnvironment)
{ operator=(cgi); }
/*!
* \brief Destructor
*
* Delete this Cgicc object
*/
~Cgicc();
//@}
// ============================================================
/*! \name Overloaded Operators */
//@{
/*!
* \brief Compare two Cgiccs for equality.
*
* Cgiccs are equal if they represent the same environment.
* \param cgi The Cgicc to compare to this one.
* \return \c true if the two Cgiccs are equal, \c false otherwise.
*/
inline bool
operator== (const Cgicc& cgi) const
{ return this->fEnvironment == cgi.fEnvironment; }
/*!
* \brief Compare two Cgiccs for inequality.
*
* Cgiccs are equal if they represent the same environment.
* \param cgi The Cgicc to compare to this one.
* \return \c false if the two Cgiccs are equal, \c true otherwise.
*/
inline bool
operator!= (const Cgicc& cgi) const
{ return ! operator==(cgi); }
#ifdef WIN32
/* Dummy operator for MSVC++ */
inline bool
operator< (const Cgicc& cgi) const
{ return false; }
#endif
/*!
* \brief Assign one Cgicc to another.
*
* Sets the environment in this Cgicc to that of \c cgi.
* \param cgi The Cgicc to copy.
* \return A reference to this.
*/
Cgicc&
operator= (const Cgicc& cgi);
//@}
// ============================================================
/*! \name Library Information
* 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*
getCompileDate() const;
/*!
* \brief Get the time at which this library was compiled.
*
* This is a string of the form \c hh:mm:ss in 24-hour time.
* \return The compile time
*/
const char*
getCompileTime() const;
/*!
* \brief Get the version number of cgicc.
*
* The version number is a string of the form \c #.#.
* \return The version number
*/
const char*
getVersion() const;
/*!
* \brief Get the platform for which Cgicc was configured.
*
* The host is a string of the form \c processor-manufacturer-os
* return The host triplet.
*/
const char*
getHost() const;
//@}
// ============================================================
/*! \name Form Element Access
* 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
queryCheckbox(const std::string& elementName) const;
/*!
* \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.
*/
inline form_iterator
operator[] (const std::string& name)
{ return getElement(name); }
/*!
* \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 The desired element, or an empty string if not found.
*/
std::string
operator() (const std::string& name) const;
/*!
* \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.
*/
inline const_form_iterator
operator[] (const std::string& name) const
{ return getElement(name); }
/*!
* \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.
*/
form_iterator
getElement(const std::string& name);
/*!
* \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.
*/
const_form_iterator
getElement(const std::string& name) const;
/*!
* \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 \c true if any elements were found, \c false if not.
*/
bool
getElement(const std::string& name,
std::vector<FormEntry>& result) const;
/*!
* \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.
*/
form_iterator
getElementByValue(const std::string& value);
/*!
* \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.
*/
const_form_iterator
getElementByValue(const std::string& value) const;
/*!
* \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.
*/
bool
getElementByValue(const std::string& value,
std::vector<FormEntry>& result) const;
/*!
* \brief Get all the submitted form entries, excluding files.
*
* \return A vector containing all the submitted elements.
*/
inline const std::vector<FormEntry>&
operator* () const
{ return fFormData; }
/*!
* \brief Get all the submitted form elements, excluding files.
*
* \return A vector containing all the submitted elements.
*/
inline const std::vector<FormEntry>&
getElements() const
{ return fFormData; }
//@}
// ============================================================
/*! \name Uploaded File Access */
//@{
/*!
* \brief Find an uploaded file.
*
* \param name The name of the file.
* \return An iterator referring to the desired file, if found.
*/
file_iterator
getFile(const std::string& name);
/*!
* \brief Find an uploaded file.
*
* \param name The name of the file.
* \return An iterator referring to the desired file, if found.
*/
const_file_iterator
getFile(const std::string& name) const;
/*!
* Get all uploaded files.
* \return A vector containing all the uploaded files.
*/
inline const std::vector<FormFile>&
getFiles() const
{ return fFormFiles; }
//@}
// ============================================================
/*! \name Environment Access */
//@{
/*!
* Get the current runtime environment.
* \return The current CGI environment.
*/
inline const CgiEnvironment&
getEnvironment() const
{ return fEnvironment;}
//@}
// ============================================================
/*! \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
save(const std::string& filename) const;
/*!
* \brief Restore from a previously-saved CGI environment.
*
* This is useful for debugging CGI applications.
* \param filename The name of the file from which to restore.
*/
void
restore(const std::string& filename);
//@}
private:
CgiEnvironment fEnvironment;
std::vector<FormEntry> fFormData;
std::vector<FormFile> fFormFiles;
// Convert query string into a list of FormEntries
void
parseFormInput(const std::string& data, const std::string& content_type = "application/x-www-form-urlencoded");
// Parse a multipart/form-data header
MultipartHeader
parseHeader(const std::string& data);
// Parse a (name=value) form entry
void
parsePair(const std::string& data);
// Parse a MIME entry for ENCTYPE=""
void
parseMIME(const std::string& data);
// Find elements in the list of entries
bool
findEntries(const std::string& param,
bool byName,
std::vector<FormEntry>& result) const;
};
} // namespace cgicc
#endif /* ! _CGICC_H_ */
|