/usr/include/cgicc/CgiUtils.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 | /* -*-mode:c++; c-file-style: "gnu";-*- */
/*
* $Id: CgiUtils.h,v 1.16 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 _CGIUTILS_H_
#define _CGIUTILS_H_ 1
#ifdef __GNUG__
# pragma interface
#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 <string>
#include <fstream>
#include "cgicc/CgiDefs.h"
namespace cgicc {
/*!
* \brief Compare two strings for equality, ignoring case.
*
* For case-sensitive comparison, use (s1 == s2);
* \param s1 The first string to compare
* \param s2 The second string to compare
* \return \c true if the strings are equal, \c false if they are not
*/
CGICC_API bool
stringsAreEqual(const std::string& s1,
const std::string& s2);
/*!
* \brief Compare two strings for equality, ignoring case.
*
* For case-sensitive comparison, use (s1 == s2);
* \param s1 The first string to compare
* \param s2 The second string to compare
* \param n The number of characters to compare.
* \return \c true if the strings are equal, \c false if they are not
*/
CGICC_API bool
stringsAreEqual(const std::string& ss1,
const std::string& ss2,
size_t n);
/*!
* \brief Convert encoded characters in form data to normal ASCII.
*
* For example, "%21" is converted to '!' and '+' is converted to a space.
* Normally, this is called internally to decode the query string or post
* data.
* \param src The src string containing the encoded characters
* \return The converted string
*/
CGICC_API std::string
form_urldecode(const std::string& src);
/*!
* \brief Convert an ASCII string to a URL-safe string.
*
* For example, '!' is converted to "%21" and ' ' is converted to '+'.
* \param src The src string containing the characters to encode
* \return The converted string
*/
CGICC_API std::string
form_urlencode(const std::string& src);
/*!
* \brief Convert an ASCII character to its hexadecimal equivalent.
*
* For example, after the call
* \code
* string s = charToHex(':');
* \endcode
* \c s will have a value of "3A".
* Normally, this is called internally to encode characters by
* escapeString.
* \param c The character to encode
* \return A string representing the hexadecimal value of c
*/
CGICC_API std::string
charToHex(char c);
/*!
* \brief Convert a hex-encoded character to its ASCII equivalent.
*
* For example, after the call
* \code
* char c = hexToChar('2', '1');
* \endcode
* \c c will have a value of '!'.
* Normally, this is called internally to decode encoded characters in
* the query string or post data.
* \param first The first hex digit
* \param second The second hex digit
* \return The ASCII character
*/
CGICC_API char
hexToChar(char first,
char second);
/*!
* \brief Extract a substring contained within two separators.
*
* For example, after the call
* \code
* std::string data = "11foo22";
* std::string res;
* res = extractBetween(data, "11", "22");
* \endcode
* \c res will be "foo".
* \param data The data to search.
* \param separator1 The first logical separator.
* \param separator2 The second logical separator.
* \return The substring between the separators.
*/
std::string
extractBetween(const std::string& data,
const std::string& separator1,
const std::string& separator2);
/*!
* \brief Extract a substring contained between a separator.
*
* This function is used internally to decode \c multipart/form-data
* \param data The data to search.
* \param separator The separator.
* \return The substring between the separator.
*/
inline std::string
extractBetween(const std::string& datas,
const std::string& separators)
{ return extractBetween(datas, separators, separators); }
/*!
* \brief Write a string to an ostream.
*
* This function is used internally for saving environments.
* \param out The ostream to which to write.
* \param s The string to write.
*/
void
writeString(std::ostream& out,
const std::string& s);
/*!
* \brief Write a long to an ostream.
*
* This function is used internally for saving environments.
* \param out The ostream to which to write.
* \param l The long to write.
*/
void
writeLong(std::ostream& out,
unsigned long l);
/*!
* \brief Read a string from an istream.
*
* This function is used internally by cgicc for restoring environments.
* \param in The istream from which to read.
* \return The string read.
*/
std::string
readString(std::istream& in);
/*!
* \brief Read a long from an istream.
*
* This function is used internally by cgicc for restoring environments.
* \param in The istream from which to read.
* \return The long read.
*/
unsigned long
readLong(std::istream& in);
} // namespace cgicc
#endif /* ! _CGIUTILS_H_ */
|