PageRenderTime 54ms CodeModel.GetById 29ms app.highlight 23ms RepoModel.GetById 0ms app.codeStats 0ms

/packages/httpd22/src/apr/apr_lib.inc

https://github.com/slibre/freepascal
Pascal | 223 lines | 22 code | 15 blank | 186 comment | 0 complexity | ae0884b95e7add85eee7e3e944ae13b5 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  1{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
  2 * applicable.
  3 *
  4 * Licensed under the Apache License, Version 2.0 (the "License");
  5 * you may not use this file except in compliance with the License.
  6 * You may obtain a copy of the License at
  7 *
  8 *     http://www.apache.org/licenses/LICENSE-2.0
  9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed under the License is distributed on an "AS IS" BASIS,
 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 * See the License for the specific language governing permissions and
 14 * limitations under the License.
 15 }
 16
 17{
 18 * @file apr_lib.h
 19 * This is collection of oddballs that didn't fit anywhere else,
 20 * and might move to more appropriate headers with the release
 21 * of APR 1.0.
 22 * @brief APR general purpose library routines
 23 }
 24
 25{#include "apr.h"
 26#include "apr_errno.h"
 27
 28#if APR_HAVE_CTYPE_H
 29#include <ctype.h>
 30#endif
 31#if APR_HAVE_STDARG_H
 32#include <stdarg.h>
 33#endif}
 34
 35{
 36 * @defgroup apr_lib General Purpose Library Routines
 37 * @ingroup APR 
 38 * This is collection of oddballs that didn't fit anywhere else,
 39 * and might move to more appropriate headers with the release
 40 * of APR 1.0.
 41 }
 42
 43{ A constant representing a 'large' string. }
 44const HUGE_STRING_LEN = 8192;
 45
 46{
 47 * Define the structures used by the APR general-purpose library.
 48 }
 49
 50{ @see apr_vformatter_buff_t }
 51type
 52  Papr_vformatter_buff_t = ^apr_vformatter_buff_t;
 53
 54{
 55 * Structure used by the variable-formatter routines.
 56 }
 57  apr_vformatter_buff_t = record
 58    { The current position }
 59    curpos: PChar;
 60    { The end position of the format string }
 61    endpos: PChar;
 62  end;
 63
 64{
 65 * return the final element of the pathname
 66 * @param pathname The path to get the final element of
 67 * @return the final element of the path
 68 * @remark
 69 * <PRE>
 70 * For example:
 71 *                 "/foo/bar/gum"    -> "gum"
 72 *                 "/foo/bar/gum/"   -> ""
 73 *                 "gum"             -> "gum"
 74 *                 "bs\\path\\stuff" -> "stuff"
 75 * </PRE>
 76 }
 77function apr_filepath_name_get(const pathname: PChar): PChar;
 78 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 79 external LibAPR name LibNamePrefix + 'apr_filepath_name_get' + LibSuff4;
 80
 81{
 82 * apr_killpg
 83 * Small utility macros to make things easier to read.  Not usually a
 84 * goal, to be sure..
 85 }
 86
 87//#ifdef WIN32
 88//#define apr_killpg(x, y)
 89//#else { WIN32 }
 90//#ifdef NO_KILLPG
 91//#define apr_killpg(x, y)        (kill (-(x), (y)))
 92//#else { NO_KILLPG }
 93//#define apr_killpg(x, y)        (killpg ((x), (y)))
 94//#endif { NO_KILLPG }
 95//#endif { WIN32 }
 96
 97{
 98 * apr_vformatter() is a generic printf-style formatting routine
 99 * with some extensions.
100 * @param flush_func The function to call when the buffer is full
101 * @param c The buffer to write to
102 * @param fmt The format string
103 * @param ap The arguments to use to fill out the format string.
104 *
105 * @remark
106 * <PRE>
107 * The extensions are:
108 *
109 * %%pA	takes a struct in_addr *, and prints it as a.b.c.d
110 * %%pI	takes an apr_sockaddr_t * and prints it as a.b.c.d:port or
111 *      [ipv6-address]:port
112 * %%pT takes an apr_os_thread_t * and prints it in decimal
113 *      ('0' is printed if !APR_HAS_THREADS)
114 * %%pt takes an apr_os_thread_t * and prints it in hexadecimal
115 *      ('0' is printed if !APR_HAS_THREADS)
116 * %%pp takes a void * and outputs it in hex
117 *
118 * The %%p hacks are to force gcc's printf warning code to skip
119 * over a pointer argument without complaining.  This does
120 * mean that the ANSI-style %%p (output a void * in hex format) won't
121 * work as expected at all, but that seems to be a fair trade-off
122 * for the increased robustness of having printf-warnings work.
123 *
124 * Additionally, apr_vformatter allows for arbitrary output methods
125 * using the apr_vformatter_buff and flush_func.
126 *
127 * The apr_vformatter_buff has two elements curpos and endpos.
128 * curpos is where apr_vformatter will write the next byte of output.
129 * It proceeds writing output to curpos, and updating curpos, until
130 * either the end of output is reached, or curpos == endpos (i.e. the
131 * buffer is full).
132 *
133 * If the end of output is reached, apr_vformatter returns the
134 * number of bytes written.
135 *
136 * When the buffer is full, the flush_func is called.  The flush_func
137 * can return -1 to indicate that no further output should be attempted,
138 * and apr_vformatter will return immediately with -1.  Otherwise
139 * the flush_func should flush the buffer in whatever manner is
140 * appropriate, re apr_pool_t nitialize curpos and endpos, and return 0.
141 *
142 * Note that flush_func is only invoked as a result of attempting to
143 * write another byte at curpos when curpos >= endpos.  So for
144 * example, it's possible when the output exactly matches the buffer
145 * space available that curpos == endpos will be true when
146 * apr_vformatter returns.
147 *
148 * apr_vformatter does not call out to any other code, it is entirely
149 * self-contained.  This allows the callers to do things which are
150 * otherwise "unsafe".  For example, apr_psprintf uses the "scratch"
151 * space at the unallocated end of a block, and doesn't actually
152 * complete the allocation until apr_vformatter returns.  apr_psprintf
153 * would be completely broken if apr_vformatter were to call anything
154 * that used this same pool.  Similarly http_bprintf() uses the "scratch"
155 * space at the end of its output buffer, and doesn't actually note
156 * that the space is in use until it either has to flush the buffer
157 * or until apr_vformatter returns.
158 * </PRE>
159 }
160type
161  flush_func_t = function (b: Papr_vformatter_buff_t): Integer;
162  
163function apr_vformatter(flush_func: flush_func_t;
164 c: Papr_vformatter_buff_t; const fmt: PChar; ap: va_list): Integer;
165 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
166 external LibAPR name LibNamePrefix + 'apr_vformatter' + LibSuff16;
167
168{
169 * Display a prompt and read in the password from stdin.
170 * @param prompt The prompt to display
171 * @param pwbuf Buffer to store the password
172 * @param bufsize The length of the password buffer.
173 * @remark If the password entered must be truncated to fit in
174 * the provided buffer, APR_ENAMETOOLONG will be returned.
175 * Note that the bufsize paramater is passed by reference for no
176 * reason; its value will never be modified by the apr_password_get()
177 * function.
178 }
179function apr_password_get(const prompt: PChar;
180 pwbuf: PChar; bufsize: Papr_size_t): apr_status_t;
181 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
182 external LibAPR name LibNamePrefix + 'apr_password_get' + LibSuff12;
183
184{
185 * @defgroup apr_ctype ctype functions
186 * These macros allow correct support of 8-bit characters on systems which
187 * support 8-bit characters.  Pretty dumb how the cast is required, but
188 * that's legacy libc for ya.  These new macros do not support EOF like
189 * the standard macros do.  Tough.
190 }
191{ @see isalnum }
192//#define apr_isalnum(c) (isalnum(((unsigned char)(c))))
193{ @see isalpha }
194//#define apr_isalpha(c) (isalpha(((unsigned char)(c))))
195{ @see iscntrl }
196//#define apr_iscntrl(c) (iscntrl(((unsigned char)(c))))
197{ @see isdigit }
198//#define apr_isdigit(c) (isdigit(((unsigned char)(c))))
199{ @see isgraph }
200//#define apr_isgraph(c) (isgraph(((unsigned char)(c))))
201{ @see islower}
202//#define apr_islower(c) (islower(((unsigned char)(c))))
203{ @see isascii }
204{#ifdef isascii
205#define apr_isascii(c) (isascii(((unsigned char)(c))))
206#else
207#define apr_isascii(c) (((c) & ~0x7f)==0)
208#endif}
209{ @see isprint }
210//#define apr_isprint(c) (isprint(((unsigned char)(c))))
211{ @see ispunct }
212//#define apr_ispunct(c) (ispunct(((unsigned char)(c))))
213{ @see isspace }
214//#define apr_isspace(c) (isspace(((unsigned char)(c))))
215{ @see isupper }
216//#define apr_isupper(c) (isupper(((unsigned char)(c))))
217{ @see isxdigit }
218//#define apr_isxdigit(c) (isxdigit(((unsigned char)(c))))
219{ @see tolower }
220function apr_tolower(c: Char): Char;
221{ @see toupper }
222function apr_toupper(c: Char): Char;
223