<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Apache Portable Runtime: apr_general.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.3.9.1 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> <div class="nav"> <a class="el" href="dir_000000.html">home</a> / <a class="el" href="dir_000001.html">oden</a> / <a class="el" href="dir_000002.html">RPM</a> / <a class="el" href="dir_000003.html">BUILD</a> / <a class="el" href="dir_000004.html">apr-1.1.1</a> / <a class="el" href="dir_000005.html">include</a></div> <h1>apr_general.h</h1><a href="apr__general_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/* Copyright 2000-2004 The Apache Software Foundation</span> 00002 <span class="comment"> *</span> 00003 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span> 00004 <span class="comment"> * you may not use this file except in compliance with the License.</span> 00005 <span class="comment"> * You may obtain a copy of the License at</span> 00006 <span class="comment"> *</span> 00007 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span> 00008 <span class="comment"> *</span> 00009 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span> 00010 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span> 00011 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> 00012 <span class="comment"> * See the License for the specific language governing permissions and</span> 00013 <span class="comment"> * limitations under the License.</span> 00014 <span class="comment"> */</span> 00015 00016 <span class="preprocessor">#ifndef APR_GENERAL_H</span> 00017 <span class="preprocessor"></span><span class="preprocessor">#define APR_GENERAL_H</span> 00018 <span class="preprocessor"></span><span class="comment"></span> 00019 <span class="comment">/**</span> 00020 <span class="comment"> * @file apr_general.h</span> 00021 <span class="comment"> * This is collection of oddballs that didn't fit anywhere else,</span> 00022 <span class="comment"> * and might move to more appropriate headers with the release</span> 00023 <span class="comment"> * of APR 1.0.</span> 00024 <span class="comment"> * @brief APR Miscellaneous library routines</span> 00025 <span class="comment"> */</span> 00026 00027 <span class="preprocessor">#include "<a class="code" href="apr_8h.html">apr.h</a>"</span> 00028 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span> 00029 <span class="preprocessor">#include "<a class="code" href="apr__errno_8h.html">apr_errno.h</a>"</span> 00030 00031 <span class="preprocessor">#if APR_HAVE_SIGNAL_H</span> 00032 <span class="preprocessor"></span><span class="preprocessor">#include <signal.h></span> 00033 <span class="preprocessor">#endif</span> 00034 <span class="preprocessor"></span> 00035 <span class="preprocessor">#ifdef __cplusplus</span> 00036 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { 00037 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span> 00038 <span class="comment"></span> 00039 <span class="comment">/**</span> 00040 <span class="comment"> * @defgroup apr_general Miscellaneous library routines</span> 00041 <span class="comment"> * @ingroup APR </span> 00042 <span class="comment"> * This is collection of oddballs that didn't fit anywhere else,</span> 00043 <span class="comment"> * and might move to more appropriate headers with the release</span> 00044 <span class="comment"> * of APR 1.0.</span> 00045 <span class="comment"> * @{</span> 00046 <span class="comment"> */</span> 00047 <span class="comment"></span> 00048 <span class="comment">/** FALSE */</span> 00049 <span class="preprocessor">#ifndef FALSE</span> <a name="l00050"></a><a class="code" href="group__apr__general.html#ga1">00050</a> <span class="preprocessor"></span><span class="preprocessor">#define FALSE 0</span> 00051 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00052 <span class="preprocessor"></span><span class="comment">/** TRUE */</span> 00053 <span class="preprocessor">#ifndef TRUE</span> <a name="l00054"></a><a class="code" href="group__apr__general.html#ga2">00054</a> <span class="preprocessor"></span><span class="preprocessor">#define TRUE (!FALSE)</span> 00055 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00056 <span class="preprocessor"></span><span class="comment"></span> 00057 <span class="comment">/** a space */</span> <a name="l00058"></a><a class="code" href="group__apr__general.html#ga3">00058</a> <span class="preprocessor">#define APR_ASCII_BLANK '\040'</span> 00059 <span class="preprocessor"></span><span class="comment">/** a carrige return */</span> <a name="l00060"></a><a class="code" href="group__apr__general.html#ga4">00060</a> <span class="preprocessor">#define APR_ASCII_CR '\015'</span> 00061 <span class="preprocessor"></span><span class="comment">/** a line feed */</span> <a name="l00062"></a><a class="code" href="group__apr__general.html#ga5">00062</a> <span class="preprocessor">#define APR_ASCII_LF '\012'</span> 00063 <span class="preprocessor"></span><span class="comment">/** a tab */</span> <a name="l00064"></a><a class="code" href="group__apr__general.html#ga6">00064</a> <span class="preprocessor">#define APR_ASCII_TAB '\011'</span> 00065 <span class="preprocessor"></span><span class="comment"></span> 00066 <span class="comment">/** signal numbers typedef */</span> <a name="l00067"></a><a class="code" href="group__apr__general.html#ga0">00067</a> <span class="keyword">typedef</span> <span class="keywordtype">int</span> apr_signum_t; 00068 <span class="comment"></span> 00069 <span class="comment">/**</span> 00070 <span class="comment"> * Finding offsets of elements within structures.</span> 00071 <span class="comment"> * Taken from the X code... they've sweated portability of this stuff</span> 00072 <span class="comment"> * so we don't have to. Sigh...</span> 00073 <span class="comment"> * @param p_type pointer type name</span> 00074 <span class="comment"> * @param field data field within the structure pointed to</span> 00075 <span class="comment"> * @return offset</span> 00076 <span class="comment"> */</span> 00077 00078 <span class="preprocessor">#if defined(CRAY) || (defined(__arm) && !defined(LINUX))</span> 00079 <span class="preprocessor"></span><span class="preprocessor">#ifdef __STDC__</span> 00080 <span class="preprocessor"></span><span class="preprocessor">#define APR_OFFSET(p_type,field) _Offsetof(p_type,field)</span> 00081 <span class="preprocessor"></span><span class="preprocessor">#else</span> 00082 <span class="preprocessor"></span><span class="preprocessor">#ifdef CRAY2</span> 00083 <span class="preprocessor"></span><span class="preprocessor">#define APR_OFFSET(p_type,field) \</span> 00084 <span class="preprocessor"> (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))</span> 00085 <span class="preprocessor"></span> 00086 <span class="preprocessor">#else </span><span class="comment">/* !CRAY2 */</span> 00087 00088 <span class="preprocessor">#define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field))</span> 00089 <span class="preprocessor"></span> 00090 <span class="preprocessor">#endif </span><span class="comment">/* !CRAY2 */</span> 00091 <span class="preprocessor">#endif </span><span class="comment">/* __STDC__ */</span> 00092 <span class="preprocessor">#else </span><span class="comment">/* ! (CRAY || __arm) */</span> 00093 <a name="l00094"></a><a class="code" href="group__apr__general.html#ga7">00094</a> <span class="preprocessor">#define APR_OFFSET(p_type,field) \</span> 00095 <span class="preprocessor"> ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))</span> 00096 <span class="preprocessor"></span> 00097 <span class="preprocessor">#endif </span><span class="comment">/* !CRAY */</span> 00098 <span class="comment"></span> 00099 <span class="comment">/**</span> 00100 <span class="comment"> * Finding offsets of elements within structures.</span> 00101 <span class="comment"> * @param s_type structure type name</span> 00102 <span class="comment"> * @param field data field within the structure</span> 00103 <span class="comment"> * @return offset</span> 00104 <span class="comment"> */</span> 00105 <span class="preprocessor">#if defined(offsetof) && !defined(__cplusplus)</span> 00106 <span class="preprocessor"></span><span class="preprocessor">#define APR_OFFSETOF(s_type,field) offsetof(s_type,field)</span> 00107 <span class="preprocessor"></span><span class="preprocessor">#else</span> <a name="l00108"></a><a class="code" href="group__apr__general.html#ga8">00108</a> <span class="preprocessor"></span><span class="preprocessor">#define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)</span> 00109 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00110 <span class="preprocessor"></span> 00111 <span class="preprocessor">#ifndef DOXYGEN</span> 00112 <span class="preprocessor"></span> 00113 <span class="comment">/* A couple of prototypes for functions in case some platform doesn't </span> 00114 <span class="comment"> * have it</span> 00115 <span class="comment"> */</span> 00116 <span class="preprocessor">#if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP) </span> 00117 <span class="preprocessor"></span><span class="preprocessor">#define strcasecmp(s1, s2) stricmp(s1, s2)</span> 00118 <span class="preprocessor"></span><span class="preprocessor">#elif (!APR_HAVE_STRCASECMP)</span> 00119 <span class="preprocessor"></span><span class="keywordtype">int</span> strcasecmp(<span class="keyword">const</span> <span class="keywordtype">char</span> *a, <span class="keyword">const</span> <span class="keywordtype">char</span> *b); 00120 <span class="preprocessor">#endif</span> 00121 <span class="preprocessor"></span> 00122 <span class="preprocessor">#if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)</span> 00123 <span class="preprocessor"></span><span class="preprocessor">#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)</span> 00124 <span class="preprocessor"></span><span class="preprocessor">#elif (!APR_HAVE_STRNCASECMP)</span> 00125 <span class="preprocessor"></span><span class="keywordtype">int</span> strncasecmp(<span class="keyword">const</span> <span class="keywordtype">char</span> *a, <span class="keyword">const</span> <span class="keywordtype">char</span> *b, size_t n); 00126 <span class="preprocessor">#endif</span> 00127 <span class="preprocessor"></span> 00128 <span class="preprocessor">#endif</span> 00129 <span class="preprocessor"></span><span class="comment"></span> 00130 <span class="comment">/**</span> 00131 <span class="comment"> * Alignment macros</span> 00132 <span class="comment"> */</span> 00133 00134 <span class="comment">/* APR_ALIGN() is only to be used to align on a power of 2 boundary */</span> <a name="l00135"></a><a class="code" href="group__apr__general.html#ga9">00135</a> <span class="preprocessor">#define APR_ALIGN(size, boundary) \</span> 00136 <span class="preprocessor"> (((size) + ((boundary) - 1)) & ~((boundary) - 1))</span> 00137 <span class="preprocessor"></span><span class="comment"></span> 00138 <span class="comment">/** Default alignment */</span> <a name="l00139"></a><a class="code" href="group__apr__general.html#ga10">00139</a> <span class="preprocessor">#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)</span> 00140 <span class="preprocessor"></span> 00141 <span class="comment"></span> 00142 <span class="comment">/**</span> 00143 <span class="comment"> * String and memory functions</span> 00144 <span class="comment"> */</span> 00145 00146 <span class="comment">/* APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it */</span> 00147 <span class="preprocessor">#ifndef APR_STRINGIFY</span> 00148 <span class="preprocessor"></span><span class="comment">/** Properly quote a value as a string in the C preprocessor */</span> <a name="l00149"></a><a class="code" href="group__apr__general.html#ga11">00149</a> <span class="preprocessor">#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)</span> 00150 <span class="preprocessor"></span><span class="comment">/** Helper macro for APR_STRINGIFY */</span> <a name="l00151"></a><a class="code" href="group__apr__general.html#ga12">00151</a> <span class="preprocessor">#define APR_STRINGIFY_HELPER(n) #n</span> 00152 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00153 <span class="preprocessor"></span> 00154 <span class="preprocessor">#if (!APR_HAVE_MEMMOVE)</span> 00155 <span class="preprocessor"></span><span class="preprocessor">#define memmove(a,b,c) bcopy(b,a,c)</span> 00156 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00157 <span class="preprocessor"></span> 00158 <span class="preprocessor">#if (!APR_HAVE_MEMCHR)</span> 00159 <span class="preprocessor"></span><span class="keywordtype">void</span> *memchr(<span class="keyword">const</span> <span class="keywordtype">void</span> *s, <span class="keywordtype">int</span> c, size_t n); 00160 <span class="preprocessor">#endif</span> 00161 <span class="preprocessor"></span><span class="comment"></span> 00162 <span class="comment">/** @} */</span> 00163 <span class="comment"></span> 00164 <span class="comment">/**</span> 00165 <span class="comment"> * @defgroup apr_library Library initialization and termination</span> 00166 <span class="comment"> * @{</span> 00167 <span class="comment"> */</span> 00168 <span class="comment"></span> 00169 <span class="comment">/**</span> 00170 <span class="comment"> * Setup any APR internal data structures. This MUST be the first function </span> 00171 <span class="comment"> * called for any APR library.</span> 00172 <span class="comment"> * @remark See apr_app_initialize if this is an application, rather than</span> 00173 <span class="comment"> * a library consumer of apr.</span> 00174 <span class="comment"> */</span> 00175 <a class="code" href="group__apr__platform.html#ga123">APR_DECLARE</a>(apr_status_t) apr_initialize(<span class="keywordtype">void</span>); 00176 <span class="comment"></span> 00177 <span class="comment">/**</span> 00178 <span class="comment"> * Set up an application with normalized argc, argv (and optionally env) in</span> 00179 <span class="comment"> * order to deal with platform-specific oddities, such as Win32 services,</span> 00180 <span class="comment"> * code pages and signals. This must be the first function called for any</span> 00181 <span class="comment"> * APR program.</span> 00182 <span class="comment"> * @param argc Pointer to the argc that may be corrected</span> 00183 <span class="comment"> * @param argv Pointer to the argv that may be corrected</span> 00184 <span class="comment"> * @param env Pointer to the env that may be corrected, may be NULL</span> 00185 <span class="comment"> * @remark See apr_initialize if this is a library consumer of apr.</span> 00186 <span class="comment"> * Otherwise, this call is identical to apr_initialize, and must be closed</span> 00187 <span class="comment"> * with a call to apr_terminate at the end of program execution.</span> 00188 <span class="comment"> */</span> 00189 APR_DECLARE(apr_status_t) apr_app_initialize(<span class="keywordtype">int</span> *argc, 00190 <span class="keywordtype">char</span> const * const * *argv, 00191 <span class="keywordtype">char</span> const * const * *env); 00192 <span class="comment"></span> 00193 <span class="comment">/**</span> 00194 <span class="comment"> * Tear down any APR internal data structures which aren't torn down </span> 00195 <span class="comment"> * automatically.</span> 00196 <span class="comment"> * @remark An APR program must call this function at termination once it </span> 00197 <span class="comment"> * has stopped using APR services. The APR developers suggest using</span> 00198 <span class="comment"> * atexit to ensure this is called. When using APR from a language</span> 00199 <span class="comment"> * other than C that has problems with the calling convention, use</span> 00200 <span class="comment"> * apr_terminate2() instead.</span> 00201 <span class="comment"> */</span> 00202 APR_DECLARE_NONSTD(<span class="keywordtype">void</span>) apr_terminate(<span class="keywordtype">void</span>); 00203 <span class="comment"></span> 00204 <span class="comment">/**</span> 00205 <span class="comment"> * Tear down any APR internal data structures which aren't torn down </span> 00206 <span class="comment"> * automatically, same as apr_terminate</span> 00207 <span class="comment"> * @remark An APR program must call either the apr_terminate or apr_terminate2 </span> 00208 <span class="comment"> * function once it it has finished using APR services. The APR </span> 00209 <span class="comment"> * developers suggest using atexit(apr_terminate) to ensure this is done.</span> 00210 <span class="comment"> * apr_terminate2 exists to allow non-c language apps to tear down apr, </span> 00211 <span class="comment"> * while apr_terminate is recommended from c language applications.</span> 00212 <span class="comment"> */</span> 00213 APR_DECLARE(<span class="keywordtype">void</span>) apr_terminate2(<span class="keywordtype">void</span>); 00214 <span class="comment"></span> 00215 <span class="comment">/** @} */</span> 00216 <span class="comment"></span> 00217 <span class="comment">/**</span> 00218 <span class="comment"> * @defgroup apr_random Random Functions</span> 00219 <span class="comment"> * @{</span> 00220 <span class="comment"> */</span> 00221 00222 #if APR_HAS_RANDOM || defined(DOXYGEN) 00223 00224 <span class="comment">/* TODO: I'm not sure this is the best place to put this prototype...*/</span><span class="comment"></span> 00225 <span class="comment">/**</span> 00226 <span class="comment"> * Generate random bytes.</span> 00227 <span class="comment"> * @param buf Buffer to fill with random bytes</span> 00228 <span class="comment"> * @param length Length of buffer in bytes</span> 00229 <span class="comment"> */</span> 00230 APR_DECLARE(apr_status_t) apr_generate_random_bytes(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * buf, 00231 apr_size_t length); 00232 00233 #endif<span class="comment"></span> 00234 <span class="comment">/** @} */</span> 00235 00236 #ifdef __cplusplus 00237 } 00238 #endif 00239 00240 #endif <span class="comment">/* ! APR_GENERAL_H */</span> </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Mar 20 19:52:26 2005 for Apache Portable Runtime by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address> </body> </html>